const {
  SvelteComponent: dW,
  assign: fW,
  create_slot: pW,
  detach: hW,
  element: mW,
  get_all_dirty_from_scope: gW,
  get_slot_changes: vW,
  get_spread_update: yW,
  init: bW,
  insert: _W,
  safe_not_equal: xW,
  set_dynamic_element_data: XA,
  set_style: ns,
  toggle_class: Wu,
  transition_in: RF,
  transition_out: OF,
  update_slot_base: SW
} = window.__gradio__svelte__internal;
function CW(t) {
  let e, r, n;
  const i = (
    /*#slots*/
    t[18].default
  ), a = pW(
    i,
    t,
    /*$$scope*/
    t[17],
    null
  );
  let o = [
    { "data-testid": (
      /*test_id*/
      t[7]
    ) },
    { id: (
      /*elem_id*/
      t[2]
    ) },
    {
      class: r = "block " + /*elem_classes*/
      t[3].join(" ") + " svelte-nl1om8"
    }
  ], s = {};
  for (let u = 0; u < o.length; u += 1)
    s = fW(s, o[u]);
  return {
    c() {
      e = mW(
        /*tag*/
        t[14]
      ), a && a.c(), XA(
        /*tag*/
        t[14]
      )(e, s), Wu(
        e,
        "hidden",
        /*visible*/
        t[10] === !1
      ), Wu(
        e,
        "padded",
        /*padding*/
        t[6]
      ), Wu(
        e,
        "border_focus",
        /*border_mode*/
        t[5] === "focus"
      ), Wu(
        e,
        "border_contrast",
        /*border_mode*/
        t[5] === "contrast"
      ), Wu(e, "hide-container", !/*explicit_call*/
      t[8] && !/*container*/
      t[9]), ns(
        e,
        "height",
        /*get_dimension*/
        t[15](
          /*height*/
          t[0]
        )
      ), ns(e, "width", typeof /*width*/
      t[1] == "number" ? `calc(min(${/*width*/
      t[1]}px, 100%))` : (
        /*get_dimension*/
        t[15](
          /*width*/
          t[1]
        )
      )), ns(
        e,
        "border-style",
        /*variant*/
        t[4]
      ), ns(
        e,
        "overflow",
        /*allow_overflow*/
        t[11] ? "visible" : "hidden"
      ), ns(
        e,
        "flex-grow",
        /*scale*/
        t[12]
      ), ns(e, "min-width", `calc(min(${/*min_width*/
      t[13]}px, 100%))`), ns(e, "border-width", "var(--block-border-width)");
    },
    m(u, c) {
      _W(u, e, c), a && a.m(e, null), n = !0;
    },
    p(u, c) {
      a && a.p && (!n || c & /*$$scope*/
      131072) && SW(
        a,
        i,
        u,
        /*$$scope*/
        u[17],
        n ? vW(
          i,
          /*$$scope*/
          u[17],
          c,
          null
        ) : gW(
          /*$$scope*/
          u[17]
        ),
        null
      ), XA(
        /*tag*/
        u[14]
      )(e, s = yW(o, [
        (!n || c & /*test_id*/
        128) && { "data-testid": (
          /*test_id*/
          u[7]
        ) },
        (!n || c & /*elem_id*/
        4) && { id: (
          /*elem_id*/
          u[2]
        ) },
        (!n || c & /*elem_classes*/
        8 && r !== (r = "block " + /*elem_classes*/
        u[3].join(" ") + " svelte-nl1om8")) && { class: r }
      ])), Wu(
        e,
        "hidden",
        /*visible*/
        u[10] === !1
      ), Wu(
        e,
        "padded",
        /*padding*/
        u[6]
      ), Wu(
        e,
        "border_focus",
        /*border_mode*/
        u[5] === "focus"
      ), Wu(
        e,
        "border_contrast",
        /*border_mode*/
        u[5] === "contrast"
      ), Wu(e, "hide-container", !/*explicit_call*/
      u[8] && !/*container*/
      u[9]), c & /*height*/
      1 && ns(
        e,
        "height",
        /*get_dimension*/
        u[15](
          /*height*/
          u[0]
        )
      ), c & /*width*/
      2 && ns(e, "width", typeof /*width*/
      u[1] == "number" ? `calc(min(${/*width*/
      u[1]}px, 100%))` : (
        /*get_dimension*/
        u[15](
          /*width*/
          u[1]
        )
      )), c & /*variant*/
      16 && ns(
        e,
        "border-style",
        /*variant*/
        u[4]
      ), c & /*allow_overflow*/
      2048 && ns(
        e,
        "overflow",
        /*allow_overflow*/
        u[11] ? "visible" : "hidden"
      ), c & /*scale*/
      4096 && ns(
        e,
        "flex-grow",
        /*scale*/
        u[12]
      ), c & /*min_width*/
      8192 && ns(e, "min-width", `calc(min(${/*min_width*/
      u[13]}px, 100%))`);
    },
    i(u) {
      n || (RF(a, u), n = !0);
    },
    o(u) {
      OF(a, u), n = !1;
    },
    d(u) {
      u && hW(e), a && a.d(u);
    }
  };
}
function AW(t) {
  let e, r = (
    /*tag*/
    t[14] && CW(t)
  );
  return {
    c() {
      r && r.c();
    },
    m(n, i) {
      r && r.m(n, i), e = !0;
    },
    p(n, [i]) {
      /*tag*/
      n[14] && r.p(n, i);
    },
    i(n) {
      e || (RF(r, n), e = !0);
    },
    o(n) {
      OF(r, n), e = !1;
    },
    d(n) {
      r && r.d(n);
    }
  };
}
function wW(t, e, r) {
  let { $$slots: n = {}, $$scope: i } = e, { height: a = void 0 } = e, { width: o = void 0 } = e, { elem_id: s = "" } = e, { elem_classes: u = [] } = e, { variant: c = "solid" } = e, { border_mode: l = "base" } = e, { padding: d = !0 } = e, { type: f = "normal" } = e, { test_id: h = void 0 } = e, { explicit_call: m = !1 } = e, { container: p = !0 } = e, { visible: v = !0 } = e, { allow_overflow: g = !0 } = e, { scale: y = null } = e, { min_width: b = 0 } = e, S = f === "fieldset" ? "fieldset" : "div";
  const _ = (x) => {
    if (x !== void 0) {
      if (typeof x == "number")
        return x + "px";
      if (typeof x == "string")
        return x;
    }
  };
  return t.$$set = (x) => {
    "height" in x && r(0, a = x.height), "width" in x && r(1, o = x.width), "elem_id" in x && r(2, s = x.elem_id), "elem_classes" in x && r(3, u = x.elem_classes), "variant" in x && r(4, c = x.variant), "border_mode" in x && r(5, l = x.border_mode), "padding" in x && r(6, d = x.padding), "type" in x && r(16, f = x.type), "test_id" in x && r(7, h = x.test_id), "explicit_call" in x && r(8, m = x.explicit_call), "container" in x && r(9, p = x.container), "visible" in x && r(10, v = x.visible), "allow_overflow" in x && r(11, g = x.allow_overflow), "scale" in x && r(12, y = x.scale), "min_width" in x && r(13, b = x.min_width), "$$scope" in x && r(17, i = x.$$scope);
  }, [
    a,
    o,
    s,
    u,
    c,
    l,
    d,
    h,
    m,
    p,
    v,
    g,
    y,
    b,
    S,
    _,
    f,
    i,
    n
  ];
}
class DW extends dW {
  constructor(e) {
    super(), bW(this, e, wW, AW, xW, {
      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: EW,
  append: c_,
  attr: nl,
  bubble: IW,
  create_component: TW,
  destroy_component: MW,
  detach: LF,
  element: l_,
  init: PW,
  insert: kF,
  listen: BW,
  mount_component: FW,
  safe_not_equal: NW,
  set_data: RW,
  set_style: g1,
  space: OW,
  text: LW,
  toggle_class: Bo,
  transition_in: kW,
  transition_out: GW
} = window.__gradio__svelte__internal;
function YA(t) {
  let e, r;
  return {
    c() {
      e = l_("span"), r = LW(
        /*label*/
        t[1]
      ), nl(e, "class", "svelte-1lrphxw");
    },
    m(n, i) {
      kF(n, e, i), c_(e, r);
    },
    p(n, i) {
      i & /*label*/
      2 && RW(
        r,
        /*label*/
        n[1]
      );
    },
    d(n) {
      n && LF(e);
    }
  };
}
function zW(t) {
  let e, r, n, i, a, o, s, u = (
    /*show_label*/
    t[2] && YA(t)
  );
  return i = new /*Icon*/
  t[0]({}), {
    c() {
      e = l_("button"), u && u.c(), r = OW(), n = l_("div"), TW(i.$$.fragment), nl(n, "class", "svelte-1lrphxw"), Bo(
        n,
        "small",
        /*size*/
        t[4] === "small"
      ), Bo(
        n,
        "large",
        /*size*/
        t[4] === "large"
      ), Bo(
        n,
        "medium",
        /*size*/
        t[4] === "medium"
      ), e.disabled = /*disabled*/
      t[7], nl(
        e,
        "aria-label",
        /*label*/
        t[1]
      ), nl(
        e,
        "aria-haspopup",
        /*hasPopup*/
        t[8]
      ), nl(
        e,
        "title",
        /*label*/
        t[1]
      ), nl(e, "class", "svelte-1lrphxw"), Bo(
        e,
        "pending",
        /*pending*/
        t[3]
      ), Bo(
        e,
        "padded",
        /*padded*/
        t[5]
      ), Bo(
        e,
        "highlight",
        /*highlight*/
        t[6]
      ), Bo(
        e,
        "transparent",
        /*transparent*/
        t[9]
      ), g1(e, "color", !/*disabled*/
      t[7] && /*_color*/
      t[12] ? (
        /*_color*/
        t[12]
      ) : "var(--block-label-text-color)"), g1(e, "--bg-color", /*disabled*/
      t[7] ? "auto" : (
        /*background*/
        t[10]
      )), g1(
        e,
        "margin-left",
        /*offset*/
        t[11] + "px"
      );
    },
    m(c, l) {
      kF(c, e, l), u && u.m(e, null), c_(e, r), c_(e, n), FW(i, n, null), a = !0, o || (s = BW(
        e,
        "click",
        /*click_handler*/
        t[14]
      ), o = !0);
    },
    p(c, [l]) {
      /*show_label*/
      c[2] ? u ? u.p(c, l) : (u = YA(c), u.c(), u.m(e, r)) : u && (u.d(1), u = null), (!a || l & /*size*/
      16) && Bo(
        n,
        "small",
        /*size*/
        c[4] === "small"
      ), (!a || l & /*size*/
      16) && Bo(
        n,
        "large",
        /*size*/
        c[4] === "large"
      ), (!a || l & /*size*/
      16) && Bo(
        n,
        "medium",
        /*size*/
        c[4] === "medium"
      ), (!a || l & /*disabled*/
      128) && (e.disabled = /*disabled*/
      c[7]), (!a || l & /*label*/
      2) && nl(
        e,
        "aria-label",
        /*label*/
        c[1]
      ), (!a || l & /*hasPopup*/
      256) && nl(
        e,
        "aria-haspopup",
        /*hasPopup*/
        c[8]
      ), (!a || l & /*label*/
      2) && nl(
        e,
        "title",
        /*label*/
        c[1]
      ), (!a || l & /*pending*/
      8) && Bo(
        e,
        "pending",
        /*pending*/
        c[3]
      ), (!a || l & /*padded*/
      32) && Bo(
        e,
        "padded",
        /*padded*/
        c[5]
      ), (!a || l & /*highlight*/
      64) && Bo(
        e,
        "highlight",
        /*highlight*/
        c[6]
      ), (!a || l & /*transparent*/
      512) && Bo(
        e,
        "transparent",
        /*transparent*/
        c[9]
      ), l & /*disabled, _color*/
      4224 && g1(e, "color", !/*disabled*/
      c[7] && /*_color*/
      c[12] ? (
        /*_color*/
        c[12]
      ) : "var(--block-label-text-color)"), l & /*disabled, background*/
      1152 && g1(e, "--bg-color", /*disabled*/
      c[7] ? "auto" : (
        /*background*/
        c[10]
      )), l & /*offset*/
      2048 && g1(
        e,
        "margin-left",
        /*offset*/
        c[11] + "px"
      );
    },
    i(c) {
      a || (kW(i.$$.fragment, c), a = !0);
    },
    o(c) {
      GW(i.$$.fragment, c), a = !1;
    },
    d(c) {
      c && LF(e), u && u.d(), MW(i), o = !1, s();
    }
  };
}
function VW(t, e, r) {
  let n, { Icon: i } = e, { label: a = "" } = e, { show_label: o = !1 } = e, { pending: s = !1 } = e, { size: u = "small" } = e, { padded: c = !0 } = e, { highlight: l = !1 } = e, { disabled: d = !1 } = e, { hasPopup: f = !1 } = e, { color: h = "var(--block-label-text-color)" } = e, { transparent: m = !1 } = e, { background: p = "var(--background-fill-primary)" } = e, { offset: v = 0 } = e;
  function g(y) {
    IW.call(this, t, y);
  }
  return t.$$set = (y) => {
    "Icon" in y && r(0, i = y.Icon), "label" in y && r(1, a = y.label), "show_label" in y && r(2, o = y.show_label), "pending" in y && r(3, s = y.pending), "size" in y && r(4, u = y.size), "padded" in y && r(5, c = y.padded), "highlight" in y && r(6, l = y.highlight), "disabled" in y && r(7, d = y.disabled), "hasPopup" in y && r(8, f = y.hasPopup), "color" in y && r(13, h = y.color), "transparent" in y && r(9, m = y.transparent), "background" in y && r(10, p = y.background), "offset" in y && r(11, v = y.offset);
  }, t.$$.update = () => {
    t.$$.dirty & /*highlight, color*/
    8256 && r(12, n = l ? "var(--color-accent)" : h);
  }, [
    i,
    a,
    o,
    s,
    u,
    c,
    l,
    d,
    f,
    m,
    p,
    v,
    n,
    h,
    g
  ];
}
class UW extends EW {
  constructor(e) {
    super(), PW(this, e, VW, zW, NW, {
      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: HW,
  append: D6,
  attr: mu,
  detach: qW,
  init: KW,
  insert: XW,
  noop: E6,
  safe_not_equal: YW,
  set_style: ju,
  svg_element: Pg
} = window.__gradio__svelte__internal;
function WW(t) {
  let e, r, n, i;
  return {
    c() {
      e = Pg("svg"), r = Pg("g"), n = Pg("path"), i = Pg("path"), mu(n, "d", "M18,6L6.087,17.913"), ju(n, "fill", "none"), ju(n, "fill-rule", "nonzero"), ju(n, "stroke-width", "2px"), mu(r, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), mu(i, "d", "M4.364,4.364L19.636,19.636"), ju(i, "fill", "none"), ju(i, "fill-rule", "nonzero"), ju(i, "stroke-width", "2px"), mu(e, "width", "100%"), mu(e, "height", "100%"), mu(e, "viewBox", "0 0 24 24"), mu(e, "version", "1.1"), mu(e, "xmlns", "http://www.w3.org/2000/svg"), mu(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), mu(e, "xml:space", "preserve"), mu(e, "stroke", "currentColor"), ju(e, "fill-rule", "evenodd"), ju(e, "clip-rule", "evenodd"), ju(e, "stroke-linecap", "round"), ju(e, "stroke-linejoin", "round");
    },
    m(a, o) {
      XW(a, e, o), D6(e, r), D6(r, n), D6(e, i);
    },
    p: E6,
    i: E6,
    o: E6,
    d(a) {
      a && qW(e);
    }
  };
}
class jW extends HW {
  constructor(e) {
    super(), KW(this, e, null, WW, YW, {});
  }
}
const ZW = [
  { 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 }
], WA = {
  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"
  }
};
ZW.reduce(
  (t, { color: e, primary: r, secondary: n }) => ({
    ...t,
    [e]: {
      primary: WA[e][r],
      secondary: WA[e][n]
    }
  }),
  {}
);
function ep(t) {
  let e = ["", "k", "M", "G", "T", "P", "E", "Z"], r = 0;
  for (; t > 1e3 && r < e.length - 1; )
    t /= 1e3, r++;
  let n = e[r];
  return (Number.isInteger(t) ? t : t.toFixed(1)) + n;
}
function Zv() {
}
function QW(t, e) {
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
}
const GF = typeof window < "u";
let jA = GF ? () => window.performance.now() : () => Date.now(), zF = GF ? (t) => requestAnimationFrame(t) : Zv;
const cp = /* @__PURE__ */ new Set();
function VF(t) {
  cp.forEach((e) => {
    e.c(t) || (cp.delete(e), e.f());
  }), cp.size !== 0 && zF(VF);
}
function JW(t) {
  let e;
  return cp.size === 0 && zF(VF), {
    promise: new Promise((r) => {
      cp.add(e = { c: t, f: r });
    }),
    abort() {
      cp.delete(e);
    }
  };
}
const v1 = [];
function $W(t, e = Zv) {
  let r;
  const n = /* @__PURE__ */ new Set();
  function i(s) {
    if (QW(t, s) && (t = s, r)) {
      const u = !v1.length;
      for (const c of n)
        c[1](), v1.push(c, t);
      if (u) {
        for (let c = 0; c < v1.length; c += 2)
          v1[c][0](v1[c + 1]);
        v1.length = 0;
      }
    }
  }
  function a(s) {
    i(s(t));
  }
  function o(s, u = Zv) {
    const c = [s, u];
    return n.add(c), n.size === 1 && (r = e(i, a) || Zv), s(t), () => {
      n.delete(c), n.size === 0 && r && (r(), r = null);
    };
  }
  return { set: i, update: a, subscribe: o };
}
function ZA(t) {
  return Object.prototype.toString.call(t) === "[object Date]";
}
function d_(t, e, r, n) {
  if (typeof r == "number" || ZA(r)) {
    const i = n - r, a = (r - e) / (t.dt || 1 / 60), o = t.opts.stiffness * i, s = t.opts.damping * a, u = (o - s) * t.inv_mass, c = (a + u) * t.dt;
    return Math.abs(c) < t.opts.precision && Math.abs(i) < t.opts.precision ? n : (t.settled = !1, ZA(r) ? new Date(r.getTime() + c) : r + c);
  } else {
    if (Array.isArray(r))
      return r.map(
        (i, a) => d_(t, e[a], r[a], n[a])
      );
    if (typeof r == "object") {
      const i = {};
      for (const a in r)
        i[a] = d_(t, e[a], r[a], n[a]);
      return i;
    } else
      throw new Error(`Cannot spring ${typeof r} values`);
  }
}
function QA(t, e = {}) {
  const r = $W(t), { stiffness: n = 0.15, damping: i = 0.8, precision: a = 0.01 } = e;
  let o, s, u, c = t, l = t, d = 1, f = 0, h = !1;
  function m(v, g = {}) {
    l = v;
    const y = u = {};
    return t == null || g.hard || p.stiffness >= 1 && p.damping >= 1 ? (h = !0, o = jA(), c = v, r.set(t = l), Promise.resolve()) : (g.soft && (f = 1 / ((g.soft === !0 ? 0.5 : +g.soft) * 60), d = 0), s || (o = jA(), h = !1, s = JW((b) => {
      if (h)
        return h = !1, s = null, !1;
      d = Math.min(d + f, 1);
      const S = {
        inv_mass: d,
        opts: p,
        settled: !0,
        dt: (b - o) * 60 / 1e3
      }, _ = d_(S, c, t, l);
      return o = b, c = t, r.set(t = _), S.settled && (s = null), !S.settled;
    })), new Promise((b) => {
      s.promise.then(() => {
        y === u && b();
      });
    }));
  }
  const p = {
    set: m,
    update: (v, g) => m(v(l, t), g),
    subscribe: r.subscribe,
    stiffness: n,
    damping: i,
    precision: a
  };
  return p;
}
const {
  SvelteComponent: ej,
  append: gu,
  attr: Jr,
  component_subscribe: JA,
  detach: tj,
  element: rj,
  init: nj,
  insert: ij,
  noop: $A,
  safe_not_equal: aj,
  set_style: Bg,
  svg_element: vu,
  toggle_class: ew
} = window.__gradio__svelte__internal, { onMount: oj } = window.__gradio__svelte__internal;
function sj(t) {
  let e, r, n, i, a, o, s, u, c, l, d, f;
  return {
    c() {
      e = rj("div"), r = vu("svg"), n = vu("g"), i = vu("path"), a = vu("path"), o = vu("path"), s = vu("path"), u = vu("g"), c = vu("path"), l = vu("path"), d = vu("path"), f = vu("path"), Jr(i, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), Jr(i, "fill", "#FF7C00"), Jr(i, "fill-opacity", "0.4"), Jr(i, "class", "svelte-43sxxs"), Jr(a, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), Jr(a, "fill", "#FF7C00"), Jr(a, "class", "svelte-43sxxs"), Jr(o, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), Jr(o, "fill", "#FF7C00"), Jr(o, "fill-opacity", "0.4"), Jr(o, "class", "svelte-43sxxs"), Jr(s, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), Jr(s, "fill", "#FF7C00"), Jr(s, "class", "svelte-43sxxs"), Bg(n, "transform", "translate(" + /*$top*/
      t[1][0] + "px, " + /*$top*/
      t[1][1] + "px)"), Jr(c, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), Jr(c, "fill", "#FF7C00"), Jr(c, "fill-opacity", "0.4"), Jr(c, "class", "svelte-43sxxs"), Jr(l, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), Jr(l, "fill", "#FF7C00"), Jr(l, "class", "svelte-43sxxs"), Jr(d, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), Jr(d, "fill", "#FF7C00"), Jr(d, "fill-opacity", "0.4"), Jr(d, "class", "svelte-43sxxs"), Jr(f, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), Jr(f, "fill", "#FF7C00"), Jr(f, "class", "svelte-43sxxs"), Bg(u, "transform", "translate(" + /*$bottom*/
      t[2][0] + "px, " + /*$bottom*/
      t[2][1] + "px)"), Jr(r, "viewBox", "-1200 -1200 3000 3000"), Jr(r, "fill", "none"), Jr(r, "xmlns", "http://www.w3.org/2000/svg"), Jr(r, "class", "svelte-43sxxs"), Jr(e, "class", "svelte-43sxxs"), ew(
        e,
        "margin",
        /*margin*/
        t[0]
      );
    },
    m(h, m) {
      ij(h, e, m), gu(e, r), gu(r, n), gu(n, i), gu(n, a), gu(n, o), gu(n, s), gu(r, u), gu(u, c), gu(u, l), gu(u, d), gu(u, f);
    },
    p(h, [m]) {
      m & /*$top*/
      2 && Bg(n, "transform", "translate(" + /*$top*/
      h[1][0] + "px, " + /*$top*/
      h[1][1] + "px)"), m & /*$bottom*/
      4 && Bg(u, "transform", "translate(" + /*$bottom*/
      h[2][0] + "px, " + /*$bottom*/
      h[2][1] + "px)"), m & /*margin*/
      1 && ew(
        e,
        "margin",
        /*margin*/
        h[0]
      );
    },
    i: $A,
    o: $A,
    d(h) {
      h && tj(e);
    }
  };
}
function uj(t, e, r) {
  let n, i;
  var a = this && this.__awaiter || function(h, m, p, v) {
    function g(y) {
      return y instanceof p ? y : new p(function(b) {
        b(y);
      });
    }
    return new (p || (p = Promise))(function(y, b) {
      function S(C) {
        try {
          x(v.next(C));
        } catch (A) {
          b(A);
        }
      }
      function _(C) {
        try {
          x(v.throw(C));
        } catch (A) {
          b(A);
        }
      }
      function x(C) {
        C.done ? y(C.value) : g(C.value).then(S, _);
      }
      x((v = v.apply(h, m || [])).next());
    });
  };
  let { margin: o = !0 } = e;
  const s = QA([0, 0]);
  JA(t, s, (h) => r(1, n = h));
  const u = QA([0, 0]);
  JA(t, u, (h) => r(2, i = h));
  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 f() {
    return a(this, void 0, void 0, function* () {
      yield Promise.all([s.set([125, 0]), u.set([-125, 0])]), d();
    });
  }
  return oj(() => (f(), () => c = !0)), t.$$set = (h) => {
    "margin" in h && r(0, o = h.margin);
  }, [o, n, i, s, u];
}
class cj extends ej {
  constructor(e) {
    super(), nj(this, e, uj, sj, aj, { margin: 0 });
  }
}
const {
  SvelteComponent: lj,
  append: s0,
  attr: Bu,
  binding_callbacks: tw,
  check_outros: f_,
  create_component: UF,
  create_slot: HF,
  destroy_component: qF,
  destroy_each: KF,
  detach: xr,
  element: dc,
  empty: Yp,
  ensure_array_like: m3,
  get_all_dirty_from_scope: XF,
  get_slot_changes: YF,
  group_outros: p_,
  init: dj,
  insert: Sr,
  mount_component: WF,
  noop: h_,
  safe_not_equal: fj,
  set_data: uu,
  set_style: Ld,
  space: ru,
  text: hi,
  toggle_class: Ws,
  transition_in: Iu,
  transition_out: fc,
  update_slot_base: jF
} = window.__gradio__svelte__internal, { tick: pj } = window.__gradio__svelte__internal, { onDestroy: hj } = window.__gradio__svelte__internal, { createEventDispatcher: mj } = window.__gradio__svelte__internal, gj = (t) => ({}), rw = (t) => ({}), vj = (t) => ({}), nw = (t) => ({});
function iw(t, e, r) {
  const n = t.slice();
  return n[41] = e[r], n[43] = r, n;
}
function aw(t, e, r) {
  const n = t.slice();
  return n[41] = e[r], n;
}
function yj(t) {
  let e, r, n, i, a = (
    /*i18n*/
    t[1]("common.error") + ""
  ), o, s, u;
  r = new UW({
    props: {
      Icon: jW,
      label: (
        /*i18n*/
        t[1]("common.clear")
      ),
      disabled: !1
    }
  }), r.$on(
    "click",
    /*click_handler*/
    t[32]
  );
  const c = (
    /*#slots*/
    t[30].error
  ), l = HF(
    c,
    t,
    /*$$scope*/
    t[29],
    rw
  );
  return {
    c() {
      e = dc("div"), UF(r.$$.fragment), n = ru(), i = dc("span"), o = hi(a), s = ru(), l && l.c(), Bu(e, "class", "clear-status svelte-vopvsi"), Bu(i, "class", "error svelte-vopvsi");
    },
    m(d, f) {
      Sr(d, e, f), WF(r, e, null), Sr(d, n, f), Sr(d, i, f), s0(i, o), Sr(d, s, f), l && l.m(d, f), u = !0;
    },
    p(d, f) {
      const h = {};
      f[0] & /*i18n*/
      2 && (h.label = /*i18n*/
      d[1]("common.clear")), r.$set(h), (!u || f[0] & /*i18n*/
      2) && a !== (a = /*i18n*/
      d[1]("common.error") + "") && uu(o, a), l && l.p && (!u || f[0] & /*$$scope*/
      536870912) && jF(
        l,
        c,
        d,
        /*$$scope*/
        d[29],
        u ? YF(
          c,
          /*$$scope*/
          d[29],
          f,
          gj
        ) : XF(
          /*$$scope*/
          d[29]
        ),
        rw
      );
    },
    i(d) {
      u || (Iu(r.$$.fragment, d), Iu(l, d), u = !0);
    },
    o(d) {
      fc(r.$$.fragment, d), fc(l, d), u = !1;
    },
    d(d) {
      d && (xr(e), xr(n), xr(i), xr(s)), qF(r), l && l.d(d);
    }
  };
}
function bj(t) {
  let e, r, n, i, a, o, s, u, c, l = (
    /*variant*/
    t[8] === "default" && /*show_eta_bar*/
    t[18] && /*show_progress*/
    t[6] === "full" && ow(t)
  );
  function d(b, S) {
    if (
      /*progress*/
      b[7]
    ) return Sj;
    if (
      /*queue_position*/
      b[2] !== null && /*queue_size*/
      b[3] !== void 0 && /*queue_position*/
      b[2] >= 0
    ) return xj;
    if (
      /*queue_position*/
      b[2] === 0
    ) return _j;
  }
  let f = d(t), h = f && f(t), m = (
    /*timer*/
    t[5] && cw(t)
  );
  const p = [Dj, wj], v = [];
  function g(b, S) {
    return (
      /*last_progress_level*/
      b[15] != null ? 0 : (
        /*show_progress*/
        b[6] === "full" ? 1 : -1
      )
    );
  }
  ~(a = g(t)) && (o = v[a] = p[a](t));
  let y = !/*timer*/
  t[5] && gw(t);
  return {
    c() {
      l && l.c(), e = ru(), r = dc("div"), h && h.c(), n = ru(), m && m.c(), i = ru(), o && o.c(), s = ru(), y && y.c(), u = Yp(), Bu(r, "class", "progress-text svelte-vopvsi"), Ws(
        r,
        "meta-text-center",
        /*variant*/
        t[8] === "center"
      ), Ws(
        r,
        "meta-text",
        /*variant*/
        t[8] === "default"
      );
    },
    m(b, S) {
      l && l.m(b, S), Sr(b, e, S), Sr(b, r, S), h && h.m(r, null), s0(r, n), m && m.m(r, null), Sr(b, i, S), ~a && v[a].m(b, S), Sr(b, s, S), y && y.m(b, S), Sr(b, u, S), c = !0;
    },
    p(b, S) {
      /*variant*/
      b[8] === "default" && /*show_eta_bar*/
      b[18] && /*show_progress*/
      b[6] === "full" ? l ? l.p(b, S) : (l = ow(b), l.c(), l.m(e.parentNode, e)) : l && (l.d(1), l = null), f === (f = d(b)) && h ? h.p(b, S) : (h && h.d(1), h = f && f(b), h && (h.c(), h.m(r, n))), /*timer*/
      b[5] ? m ? m.p(b, S) : (m = cw(b), m.c(), m.m(r, null)) : m && (m.d(1), m = null), (!c || S[0] & /*variant*/
      256) && Ws(
        r,
        "meta-text-center",
        /*variant*/
        b[8] === "center"
      ), (!c || S[0] & /*variant*/
      256) && Ws(
        r,
        "meta-text",
        /*variant*/
        b[8] === "default"
      );
      let _ = a;
      a = g(b), a === _ ? ~a && v[a].p(b, S) : (o && (p_(), fc(v[_], 1, 1, () => {
        v[_] = null;
      }), f_()), ~a ? (o = v[a], o ? o.p(b, S) : (o = v[a] = p[a](b), o.c()), Iu(o, 1), o.m(s.parentNode, s)) : o = null), /*timer*/
      b[5] ? y && (p_(), fc(y, 1, 1, () => {
        y = null;
      }), f_()) : y ? (y.p(b, S), S[0] & /*timer*/
      32 && Iu(y, 1)) : (y = gw(b), y.c(), Iu(y, 1), y.m(u.parentNode, u));
    },
    i(b) {
      c || (Iu(o), Iu(y), c = !0);
    },
    o(b) {
      fc(o), fc(y), c = !1;
    },
    d(b) {
      b && (xr(e), xr(r), xr(i), xr(s), xr(u)), l && l.d(b), h && h.d(), m && m.d(), ~a && v[a].d(b), y && y.d(b);
    }
  };
}
function ow(t) {
  let e, r = `translateX(${/*eta_level*/
  (t[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      e = dc("div"), Bu(e, "class", "eta-bar svelte-vopvsi"), Ld(e, "transform", r);
    },
    m(n, i) {
      Sr(n, e, i);
    },
    p(n, i) {
      i[0] & /*eta_level*/
      131072 && r !== (r = `translateX(${/*eta_level*/
      (n[17] || 0) * 100 - 100}%)`) && Ld(e, "transform", r);
    },
    d(n) {
      n && xr(e);
    }
  };
}
function _j(t) {
  let e;
  return {
    c() {
      e = hi("processing |");
    },
    m(r, n) {
      Sr(r, e, n);
    },
    p: h_,
    d(r) {
      r && xr(e);
    }
  };
}
function xj(t) {
  let e, r = (
    /*queue_position*/
    t[2] + 1 + ""
  ), n, i, a, o;
  return {
    c() {
      e = hi("queue: "), n = hi(r), i = hi("/"), a = hi(
        /*queue_size*/
        t[3]
      ), o = hi(" |");
    },
    m(s, u) {
      Sr(s, e, u), Sr(s, n, u), Sr(s, i, u), Sr(s, a, u), Sr(s, o, u);
    },
    p(s, u) {
      u[0] & /*queue_position*/
      4 && r !== (r = /*queue_position*/
      s[2] + 1 + "") && uu(n, r), u[0] & /*queue_size*/
      8 && uu(
        a,
        /*queue_size*/
        s[3]
      );
    },
    d(s) {
      s && (xr(e), xr(n), xr(i), xr(a), xr(o));
    }
  };
}
function Sj(t) {
  let e, r = m3(
    /*progress*/
    t[7]
  ), n = [];
  for (let i = 0; i < r.length; i += 1)
    n[i] = uw(aw(t, r, i));
  return {
    c() {
      for (let i = 0; i < n.length; i += 1)
        n[i].c();
      e = Yp();
    },
    m(i, a) {
      for (let o = 0; o < n.length; o += 1)
        n[o] && n[o].m(i, a);
      Sr(i, e, a);
    },
    p(i, a) {
      if (a[0] & /*progress*/
      128) {
        r = m3(
          /*progress*/
          i[7]
        );
        let o;
        for (o = 0; o < r.length; o += 1) {
          const s = aw(i, r, o);
          n[o] ? n[o].p(s, a) : (n[o] = uw(s), n[o].c(), n[o].m(e.parentNode, e));
        }
        for (; o < n.length; o += 1)
          n[o].d(1);
        n.length = r.length;
      }
    },
    d(i) {
      i && xr(e), KF(n, i);
    }
  };
}
function sw(t) {
  let e, r = (
    /*p*/
    t[41].unit + ""
  ), n, i, a = " ", o;
  function s(l, d) {
    return (
      /*p*/
      l[41].length != null ? Aj : Cj
    );
  }
  let u = s(t), c = u(t);
  return {
    c() {
      c.c(), e = ru(), n = hi(r), i = hi(" | "), o = hi(a);
    },
    m(l, d) {
      c.m(l, d), Sr(l, e, d), Sr(l, n, d), Sr(l, i, d), Sr(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(e.parentNode, e))), d[0] & /*progress*/
      128 && r !== (r = /*p*/
      l[41].unit + "") && uu(n, r);
    },
    d(l) {
      l && (xr(e), xr(n), xr(i), xr(o)), c.d(l);
    }
  };
}
function Cj(t) {
  let e = ep(
    /*p*/
    t[41].index || 0
  ) + "", r;
  return {
    c() {
      r = hi(e);
    },
    m(n, i) {
      Sr(n, r, i);
    },
    p(n, i) {
      i[0] & /*progress*/
      128 && e !== (e = ep(
        /*p*/
        n[41].index || 0
      ) + "") && uu(r, e);
    },
    d(n) {
      n && xr(r);
    }
  };
}
function Aj(t) {
  let e = ep(
    /*p*/
    t[41].index || 0
  ) + "", r, n, i = ep(
    /*p*/
    t[41].length
  ) + "", a;
  return {
    c() {
      r = hi(e), n = hi("/"), a = hi(i);
    },
    m(o, s) {
      Sr(o, r, s), Sr(o, n, s), Sr(o, a, s);
    },
    p(o, s) {
      s[0] & /*progress*/
      128 && e !== (e = ep(
        /*p*/
        o[41].index || 0
      ) + "") && uu(r, e), s[0] & /*progress*/
      128 && i !== (i = ep(
        /*p*/
        o[41].length
      ) + "") && uu(a, i);
    },
    d(o) {
      o && (xr(r), xr(n), xr(a));
    }
  };
}
function uw(t) {
  let e, r = (
    /*p*/
    t[41].index != null && sw(t)
  );
  return {
    c() {
      r && r.c(), e = Yp();
    },
    m(n, i) {
      r && r.m(n, i), Sr(n, e, i);
    },
    p(n, i) {
      /*p*/
      n[41].index != null ? r ? r.p(n, i) : (r = sw(n), r.c(), r.m(e.parentNode, e)) : r && (r.d(1), r = null);
    },
    d(n) {
      n && xr(e), r && r.d(n);
    }
  };
}
function cw(t) {
  let e, r = (
    /*eta*/
    t[0] ? `/${/*formatted_eta*/
    t[19]}` : ""
  ), n, i;
  return {
    c() {
      e = hi(
        /*formatted_timer*/
        t[20]
      ), n = hi(r), i = hi("s");
    },
    m(a, o) {
      Sr(a, e, o), Sr(a, n, o), Sr(a, i, o);
    },
    p(a, o) {
      o[0] & /*formatted_timer*/
      1048576 && uu(
        e,
        /*formatted_timer*/
        a[20]
      ), o[0] & /*eta, formatted_eta*/
      524289 && r !== (r = /*eta*/
      a[0] ? `/${/*formatted_eta*/
      a[19]}` : "") && uu(n, r);
    },
    d(a) {
      a && (xr(e), xr(n), xr(i));
    }
  };
}
function wj(t) {
  let e, r;
  return e = new cj({
    props: { margin: (
      /*variant*/
      t[8] === "default"
    ) }
  }), {
    c() {
      UF(e.$$.fragment);
    },
    m(n, i) {
      WF(e, n, i), r = !0;
    },
    p(n, i) {
      const a = {};
      i[0] & /*variant*/
      256 && (a.margin = /*variant*/
      n[8] === "default"), e.$set(a);
    },
    i(n) {
      r || (Iu(e.$$.fragment, n), r = !0);
    },
    o(n) {
      fc(e.$$.fragment, n), r = !1;
    },
    d(n) {
      qF(e, n);
    }
  };
}
function Dj(t) {
  let e, r, n, i, a, o = `${/*last_progress_level*/
  t[15] * 100}%`, s = (
    /*progress*/
    t[7] != null && lw(t)
  );
  return {
    c() {
      e = dc("div"), r = dc("div"), s && s.c(), n = ru(), i = dc("div"), a = dc("div"), Bu(r, "class", "progress-level-inner svelte-vopvsi"), Bu(a, "class", "progress-bar svelte-vopvsi"), Ld(a, "width", o), Bu(i, "class", "progress-bar-wrap svelte-vopvsi"), Bu(e, "class", "progress-level svelte-vopvsi");
    },
    m(u, c) {
      Sr(u, e, c), s0(e, r), s && s.m(r, null), s0(e, n), s0(e, i), s0(i, a), t[31](a);
    },
    p(u, c) {
      /*progress*/
      u[7] != null ? s ? s.p(u, c) : (s = lw(u), s.c(), s.m(r, null)) : s && (s.d(1), s = null), c[0] & /*last_progress_level*/
      32768 && o !== (o = `${/*last_progress_level*/
      u[15] * 100}%`) && Ld(a, "width", o);
    },
    i: h_,
    o: h_,
    d(u) {
      u && xr(e), s && s.d(), t[31](null);
    }
  };
}
function lw(t) {
  let e, r = m3(
    /*progress*/
    t[7]
  ), n = [];
  for (let i = 0; i < r.length; i += 1)
    n[i] = mw(iw(t, r, i));
  return {
    c() {
      for (let i = 0; i < n.length; i += 1)
        n[i].c();
      e = Yp();
    },
    m(i, a) {
      for (let o = 0; o < n.length; o += 1)
        n[o] && n[o].m(i, a);
      Sr(i, e, a);
    },
    p(i, a) {
      if (a[0] & /*progress_level, progress*/
      16512) {
        r = m3(
          /*progress*/
          i[7]
        );
        let o;
        for (o = 0; o < r.length; o += 1) {
          const s = iw(i, r, o);
          n[o] ? n[o].p(s, a) : (n[o] = mw(s), n[o].c(), n[o].m(e.parentNode, e));
        }
        for (; o < n.length; o += 1)
          n[o].d(1);
        n.length = r.length;
      }
    },
    d(i) {
      i && xr(e), KF(n, i);
    }
  };
}
function dw(t) {
  let e, r, n, i, a = (
    /*i*/
    t[43] !== 0 && Ej()
  ), o = (
    /*p*/
    t[41].desc != null && fw(t)
  ), s = (
    /*p*/
    t[41].desc != null && /*progress_level*/
    t[14] && /*progress_level*/
    t[14][
      /*i*/
      t[43]
    ] != null && pw()
  ), u = (
    /*progress_level*/
    t[14] != null && hw(t)
  );
  return {
    c() {
      a && a.c(), e = ru(), o && o.c(), r = ru(), s && s.c(), n = ru(), u && u.c(), i = Yp();
    },
    m(c, l) {
      a && a.m(c, l), Sr(c, e, l), o && o.m(c, l), Sr(c, r, l), s && s.m(c, l), Sr(c, n, l), u && u.m(c, l), Sr(c, i, l);
    },
    p(c, l) {
      /*p*/
      c[41].desc != null ? o ? o.p(c, l) : (o = fw(c), o.c(), o.m(r.parentNode, r)) : 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 = pw(), s.c(), s.m(n.parentNode, n)) : s && (s.d(1), s = null), /*progress_level*/
      c[14] != null ? u ? u.p(c, l) : (u = hw(c), u.c(), u.m(i.parentNode, i)) : u && (u.d(1), u = null);
    },
    d(c) {
      c && (xr(e), xr(r), xr(n), xr(i)), a && a.d(c), o && o.d(c), s && s.d(c), u && u.d(c);
    }
  };
}
function Ej(t) {
  let e;
  return {
    c() {
      e = hi(" /");
    },
    m(r, n) {
      Sr(r, e, n);
    },
    d(r) {
      r && xr(e);
    }
  };
}
function fw(t) {
  let e = (
    /*p*/
    t[41].desc + ""
  ), r;
  return {
    c() {
      r = hi(e);
    },
    m(n, i) {
      Sr(n, r, i);
    },
    p(n, i) {
      i[0] & /*progress*/
      128 && e !== (e = /*p*/
      n[41].desc + "") && uu(r, e);
    },
    d(n) {
      n && xr(r);
    }
  };
}
function pw(t) {
  let e;
  return {
    c() {
      e = hi("-");
    },
    m(r, n) {
      Sr(r, e, n);
    },
    d(r) {
      r && xr(e);
    }
  };
}
function hw(t) {
  let e = (100 * /*progress_level*/
  (t[14][
    /*i*/
    t[43]
  ] || 0)).toFixed(1) + "", r, n;
  return {
    c() {
      r = hi(e), n = hi("%");
    },
    m(i, a) {
      Sr(i, r, a), Sr(i, n, a);
    },
    p(i, a) {
      a[0] & /*progress_level*/
      16384 && e !== (e = (100 * /*progress_level*/
      (i[14][
        /*i*/
        i[43]
      ] || 0)).toFixed(1) + "") && uu(r, e);
    },
    d(i) {
      i && (xr(r), xr(n));
    }
  };
}
function mw(t) {
  let e, r = (
    /*p*/
    (t[41].desc != null || /*progress_level*/
    t[14] && /*progress_level*/
    t[14][
      /*i*/
      t[43]
    ] != null) && dw(t)
  );
  return {
    c() {
      r && r.c(), e = Yp();
    },
    m(n, i) {
      r && r.m(n, i), Sr(n, e, i);
    },
    p(n, i) {
      /*p*/
      n[41].desc != null || /*progress_level*/
      n[14] && /*progress_level*/
      n[14][
        /*i*/
        n[43]
      ] != null ? r ? r.p(n, i) : (r = dw(n), r.c(), r.m(e.parentNode, e)) : r && (r.d(1), r = null);
    },
    d(n) {
      n && xr(e), r && r.d(n);
    }
  };
}
function gw(t) {
  let e, r, n, i;
  const a = (
    /*#slots*/
    t[30]["additional-loading-text"]
  ), o = HF(
    a,
    t,
    /*$$scope*/
    t[29],
    nw
  );
  return {
    c() {
      e = dc("p"), r = hi(
        /*loading_text*/
        t[9]
      ), n = ru(), o && o.c(), Bu(e, "class", "loading svelte-vopvsi");
    },
    m(s, u) {
      Sr(s, e, u), s0(e, r), Sr(s, n, u), o && o.m(s, u), i = !0;
    },
    p(s, u) {
      (!i || u[0] & /*loading_text*/
      512) && uu(
        r,
        /*loading_text*/
        s[9]
      ), o && o.p && (!i || u[0] & /*$$scope*/
      536870912) && jF(
        o,
        a,
        s,
        /*$$scope*/
        s[29],
        i ? YF(
          a,
          /*$$scope*/
          s[29],
          u,
          vj
        ) : XF(
          /*$$scope*/
          s[29]
        ),
        nw
      );
    },
    i(s) {
      i || (Iu(o, s), i = !0);
    },
    o(s) {
      fc(o, s), i = !1;
    },
    d(s) {
      s && (xr(e), xr(n)), o && o.d(s);
    }
  };
}
function Ij(t) {
  let e, r, n, i, a;
  const o = [bj, yj], s = [];
  function u(c, l) {
    return (
      /*status*/
      c[4] === "pending" ? 0 : (
        /*status*/
        c[4] === "error" ? 1 : -1
      )
    );
  }
  return ~(r = u(t)) && (n = s[r] = o[r](t)), {
    c() {
      e = dc("div"), n && n.c(), Bu(e, "class", i = "wrap " + /*variant*/
      t[8] + " " + /*show_progress*/
      t[6] + " svelte-vopvsi"), Ws(e, "hide", !/*status*/
      t[4] || /*status*/
      t[4] === "complete" || /*show_progress*/
      t[6] === "hidden"), Ws(
        e,
        "translucent",
        /*variant*/
        t[8] === "center" && /*status*/
        (t[4] === "pending" || /*status*/
        t[4] === "error") || /*translucent*/
        t[11] || /*show_progress*/
        t[6] === "minimal"
      ), Ws(
        e,
        "generating",
        /*status*/
        t[4] === "generating"
      ), Ws(
        e,
        "border",
        /*border*/
        t[12]
      ), Ld(
        e,
        "position",
        /*absolute*/
        t[10] ? "absolute" : "static"
      ), Ld(
        e,
        "padding",
        /*absolute*/
        t[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(c, l) {
      Sr(c, e, l), ~r && s[r].m(e, null), t[33](e), a = !0;
    },
    p(c, l) {
      let d = r;
      r = u(c), r === d ? ~r && s[r].p(c, l) : (n && (p_(), fc(s[d], 1, 1, () => {
        s[d] = null;
      }), f_()), ~r ? (n = s[r], n ? n.p(c, l) : (n = s[r] = o[r](c), n.c()), Iu(n, 1), n.m(e, null)) : n = null), (!a || l[0] & /*variant, show_progress*/
      320 && i !== (i = "wrap " + /*variant*/
      c[8] + " " + /*show_progress*/
      c[6] + " svelte-vopvsi")) && Bu(e, "class", i), (!a || l[0] & /*variant, show_progress, status, show_progress*/
      336) && Ws(e, "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) && Ws(
        e,
        "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) && Ws(
        e,
        "generating",
        /*status*/
        c[4] === "generating"
      ), (!a || l[0] & /*variant, show_progress, border*/
      4416) && Ws(
        e,
        "border",
        /*border*/
        c[12]
      ), l[0] & /*absolute*/
      1024 && Ld(
        e,
        "position",
        /*absolute*/
        c[10] ? "absolute" : "static"
      ), l[0] & /*absolute*/
      1024 && Ld(
        e,
        "padding",
        /*absolute*/
        c[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(c) {
      a || (Iu(n), a = !0);
    },
    o(c) {
      fc(n), a = !1;
    },
    d(c) {
      c && xr(e), ~r && s[r].d(), t[33](null);
    }
  };
}
var Tj = function(t, e, r, n) {
  function i(a) {
    return a instanceof r ? a : new r(function(o) {
      o(a);
    });
  }
  return new (r || (r = Promise))(function(a, o) {
    function s(l) {
      try {
        c(n.next(l));
      } catch (d) {
        o(d);
      }
    }
    function u(l) {
      try {
        c(n.throw(l));
      } catch (d) {
        o(d);
      }
    }
    function c(l) {
      l.done ? a(l.value) : i(l.value).then(s, u);
    }
    c((n = n.apply(t, e || [])).next());
  });
};
let Fg = [], I6 = !1;
function Mj(t) {
  return Tj(this, arguments, void 0, function* (e, r = !0) {
    if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && r !== !0)) {
      if (Fg.push(e), !I6) I6 = !0;
      else return;
      yield pj(), requestAnimationFrame(() => {
        let n = [0, 0];
        for (let i = 0; i < Fg.length; i++) {
          const o = Fg[i].getBoundingClientRect();
          (i === 0 || o.top + window.scrollY <= n[0]) && (n[0] = o.top + window.scrollY, n[1] = i);
        }
        window.scrollTo({ top: n[0] - 20, behavior: "smooth" }), I6 = !1, Fg = [];
      });
    }
  });
}
function Pj(t, e, r) {
  let n, { $$slots: i = {}, $$scope: a } = e;
  this && this.__awaiter;
  const o = mj();
  let { i18n: s } = e, { eta: u = null } = e, { queue_position: c } = e, { queue_size: l } = e, { status: d } = e, { scroll_to_output: f = !1 } = e, { timer: h = !0 } = e, { show_progress: m = "full" } = e, { message: p = null } = e, { progress: v = null } = e, { variant: g = "default" } = e, { loading_text: y = "Loading..." } = e, { absolute: b = !0 } = e, { translucent: S = !1 } = e, { border: _ = !1 } = e, { autoscroll: x } = e, C, A = !1, w = 0, I = 0, P = null, M = null, T = 0, F = null, N, R = null, L = !0;
  const V = () => {
    r(0, u = r(27, P = r(19, K = null))), r(25, w = performance.now()), r(26, I = 0), A = !0, U();
  };
  function U() {
    requestAnimationFrame(() => {
      r(26, I = (performance.now() - w) / 1e3), A && U();
    });
  }
  function H() {
    r(26, I = 0), r(0, u = r(27, P = r(19, K = null))), A && (A = !1);
  }
  hj(() => {
    A && H();
  });
  let K = null;
  function X(J) {
    tw[J ? "unshift" : "push"](() => {
      R = J, r(16, R), r(7, v), r(14, F), r(15, N);
    });
  }
  const Y = () => {
    o("clear_status");
  };
  function Q(J) {
    tw[J ? "unshift" : "push"](() => {
      C = J, r(13, C);
    });
  }
  return t.$$set = (J) => {
    "i18n" in J && r(1, s = J.i18n), "eta" in J && r(0, u = J.eta), "queue_position" in J && r(2, c = J.queue_position), "queue_size" in J && r(3, l = J.queue_size), "status" in J && r(4, d = J.status), "scroll_to_output" in J && r(22, f = J.scroll_to_output), "timer" in J && r(5, h = J.timer), "show_progress" in J && r(6, m = J.show_progress), "message" in J && r(23, p = J.message), "progress" in J && r(7, v = J.progress), "variant" in J && r(8, g = J.variant), "loading_text" in J && r(9, y = J.loading_text), "absolute" in J && r(10, b = J.absolute), "translucent" in J && r(11, S = J.translucent), "border" in J && r(12, _ = J.border), "autoscroll" in J && r(24, x = J.autoscroll), "$$scope" in J && r(29, a = J.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/
    436207617 && (u === null && r(0, u = P), u != null && P !== u && (r(28, M = (performance.now() - w) / 1e3 + u), r(19, K = M.toFixed(1)), r(27, P = u))), t.$$.dirty[0] & /*eta_from_start, timer_diff*/
    335544320 && r(17, T = M === null || M <= 0 || !I ? null : Math.min(I / M, 1)), t.$$.dirty[0] & /*progress*/
    128 && v != null && r(18, L = !1), t.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (v != null ? r(14, F = v.map((J) => {
      if (J.index != null && J.length != null)
        return J.index / J.length;
      if (J.progress != null)
        return J.progress;
    })) : r(14, F = null), F ? (r(15, N = F[F.length - 1]), R && (N === 0 ? r(16, R.style.transition = "0", R) : r(16, R.style.transition = "150ms", R))) : r(15, N = void 0)), t.$$.dirty[0] & /*status*/
    16 && (d === "pending" ? V() : H()), t.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    20979728 && C && f && (d === "pending" || d === "complete") && Mj(C, x), t.$$.dirty[0] & /*status, message*/
    8388624, t.$$.dirty[0] & /*timer_diff*/
    67108864 && r(20, n = I.toFixed(1));
  }, [
    u,
    s,
    c,
    l,
    d,
    h,
    m,
    v,
    g,
    y,
    b,
    S,
    _,
    C,
    F,
    N,
    R,
    T,
    L,
    K,
    n,
    o,
    f,
    p,
    x,
    w,
    I,
    P,
    M,
    a,
    i,
    X,
    Y,
    Q
  ];
}
class Bj extends lj {
  constructor(e) {
    super(), dj(
      this,
      e,
      Pj,
      Ij,
      fj,
      {
        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 m_ = function(t, e) {
  return m_ = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
    r.__proto__ = n;
  } || function(r, n) {
    for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (r[i] = n[i]);
  }, m_(t, e);
};
function ka(t, e) {
  if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
  function r() {
    this.constructor = t;
  }
  m_(t, e), t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r());
}
var O = function() {
  return O = Object.assign || function(t) {
    for (var e, r = 1, n = arguments.length; r < n; r++) for (var i in e = arguments[r]) Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
    return t;
  }, O.apply(this, arguments);
};
function _e(t, e, r, n) {
  return new (r || (r = Promise))(function(i, a) {
    function o(c) {
      try {
        u(n.next(c));
      } catch (l) {
        a(l);
      }
    }
    function s(c) {
      try {
        u(n.throw(c));
      } catch (l) {
        a(l);
      }
    }
    function u(c) {
      var l;
      c.done ? i(c.value) : (l = c.value, l instanceof r ? l : new r(function(d) {
        d(l);
      })).then(o, s);
    }
    u((n = n.apply(t, [])).next());
  });
}
function ye(t, e) {
  var r, n, 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 (r) throw new TypeError("Generator is already executing.");
        for (; o; ) try {
          if (r = 1, n && (i = 2 & l[0] ? n.return : l[0] ? n.throw || ((i = n.return) && i.call(n), 0) : n.next) && !(i = i.call(n, l[1])).done) return i;
          switch (n = 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++, n = 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 = e.call(t, o);
        } catch (d) {
          l = [6, d], n = 0;
        } finally {
          r = i = 0;
        }
        if (5 & l[0]) throw l[1];
        return { value: l[0] ? l[1] : void 0, done: !0 };
      }([u, c]);
    };
  }
}
function g_(t) {
  var e = typeof Symbol == "function" && Symbol.iterator, r = e && t[e], n = 0;
  if (r) return r.call(t);
  if (t && typeof t.length == "number") return { next: function() {
    return t && n >= t.length && (t = void 0), { value: t && t[n++], done: !t };
  } };
  throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function g3(t, e) {
  var r = typeof Symbol == "function" && t[Symbol.iterator];
  if (!r) return t;
  var n, i, a = r.call(t), o = [];
  try {
    for (; (e === void 0 || e-- > 0) && !(n = a.next()).done; ) o.push(n.value);
  } catch (s) {
    i = { error: s };
  } finally {
    try {
      n && !n.done && (r = a.return) && r.call(a);
    } finally {
      if (i) throw i.error;
    }
  }
  return o;
}
function Ze(t, e, r) {
  if (r || arguments.length === 2) for (var n, i = 0, a = e.length; i < a; i++) !n && i in e || (n || (n = Array.prototype.slice.call(e, 0, i)), n[i] = e[i]);
  return t.concat(n || Array.prototype.slice.call(e));
}
function ml(t) {
  return typeof t == "function";
}
function ZF(t) {
  var e = t(function(r) {
    Error.call(r), r.stack = new Error().stack;
  });
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
}
var T6 = ZF(function(t) {
  return function(e) {
    t(this), this.message = e ? e.length + ` errors occurred during unsubscription:
` + e.map(function(r, n) {
      return n + 1 + ") " + r.toString();
    }).join(`
  `) : "", this.name = "UnsubscriptionError", this.errors = e;
  };
});
function v_(t, e) {
  if (t) {
    var r = t.indexOf(e);
    0 <= r && t.splice(r, 1);
  }
}
var Py = function() {
  function t(r) {
    this.initialTeardown = r, this.closed = !1, this._parentage = null, this._teardowns = null;
  }
  var e;
  return t.prototype.unsubscribe = function() {
    var r, n, 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 = g_(s), c = u.next(); !c.done; c = u.next())
          c.value.remove(this);
      } catch (p) {
        r = { error: p };
      } finally {
        try {
          c && !c.done && (n = u.return) && n.call(u);
        } finally {
          if (r) throw r.error;
        }
      }
      else s.remove(this);
      var l = this.initialTeardown;
      if (ml(l)) try {
        l();
      } catch (p) {
        o = p instanceof T6 ? p.errors : [p];
      }
      var d = this._teardowns;
      if (d) {
        this._teardowns = null;
        try {
          for (var f = g_(d), h = f.next(); !h.done; h = f.next()) {
            var m = h.value;
            try {
              vw(m);
            } catch (p) {
              o = o ?? [], p instanceof T6 ? o = Ze(Ze([], g3(o)), g3(p.errors)) : o.push(p);
            }
          }
        } catch (p) {
          i = { error: p };
        } finally {
          try {
            h && !h.done && (a = f.return) && a.call(f);
          } finally {
            if (i) throw i.error;
          }
        }
      }
      if (o) throw new T6(o);
    }
  }, t.prototype.add = function(r) {
    var n;
    if (r && r !== this) if (this.closed) vw(r);
    else {
      if (r instanceof t) {
        if (r.closed || r._hasParent(this)) return;
        r._addParent(this);
      }
      (this._teardowns = (n = this._teardowns) !== null && n !== void 0 ? n : []).push(r);
    }
  }, t.prototype._hasParent = function(r) {
    var n = this._parentage;
    return n === r || Array.isArray(n) && n.includes(r);
  }, t.prototype._addParent = function(r) {
    var n = this._parentage;
    this._parentage = Array.isArray(n) ? (n.push(r), n) : n ? [n, r] : r;
  }, t.prototype._removeParent = function(r) {
    var n = this._parentage;
    n === r ? this._parentage = null : Array.isArray(n) && v_(n, r);
  }, t.prototype.remove = function(r) {
    var n = this._teardowns;
    n && v_(n, r), r instanceof t && r._removeParent(this);
  }, t.EMPTY = ((e = new t()).closed = !0, e), t;
}(), QF = Py.EMPTY;
function JF(t) {
  return t instanceof Py || t && "closed" in t && ml(t.remove) && ml(t.add) && ml(t.unsubscribe);
}
function vw(t) {
  ml(t) ? t() : t.unsubscribe();
}
var $F = { onUnhandledError: null, onStoppedNotification: null, Promise: void 0, useDeprecatedSynchronousErrorHandling: !1, useDeprecatedNextContext: !1 }, Fj = { setTimeout: function() {
  for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  return setTimeout.apply(void 0, Ze([], g3(t)));
}, clearTimeout: function(t) {
  return clearTimeout(t);
}, delegate: void 0 };
function v3() {
}
function Qv(t) {
  t();
}
var eN = function(t) {
  function e(r) {
    var n = t.call(this) || this;
    return n.isStopped = !1, r ? (n.destination = r, JF(r) && r.add(n)) : n.destination = Nj, n;
  }
  return ka(e, t), e.create = function(r, n, i) {
    return new y_(r, n, i);
  }, e.prototype.next = function(r) {
    this.isStopped || this._next(r);
  }, e.prototype.error = function(r) {
    this.isStopped || (this.isStopped = !0, this._error(r));
  }, e.prototype.complete = function() {
    this.isStopped || (this.isStopped = !0, this._complete());
  }, e.prototype.unsubscribe = function() {
    this.closed || (this.isStopped = !0, t.prototype.unsubscribe.call(this), this.destination = null);
  }, e.prototype._next = function(r) {
    this.destination.next(r);
  }, e.prototype._error = function(r) {
    try {
      this.destination.error(r);
    } finally {
      this.unsubscribe();
    }
  }, e.prototype._complete = function() {
    try {
      this.destination.complete();
    } finally {
      this.unsubscribe();
    }
  }, e;
}(Py), y_ = function(t) {
  function e(r, n, i) {
    var a, o = t.call(this) || this;
    if (ml(r)) a = r;
    else if (r) {
      var s;
      a = r.next, n = r.error, i = r.complete, o && $F.useDeprecatedNextContext ? (s = Object.create(r)).unsubscribe = function() {
        return o.unsubscribe();
      } : s = r, a = a == null ? void 0 : a.bind(s), n = n == null ? void 0 : n.bind(s), i = i == null ? void 0 : i.bind(s);
    }
    return o.destination = { next: a ? M6(a) : v3, error: M6(n ?? tN), complete: i ? M6(i) : v3 }, o;
  }
  return ka(e, t), e;
}(eN);
function M6(t, e) {
  return function() {
    for (var r = [], n = 0; n < arguments.length; n++) r[n] = arguments[n];
    try {
      t.apply(void 0, Ze([], g3(r)));
    } catch (i) {
      (function(a) {
        Fj.setTimeout(function() {
          throw a;
        });
      })(i);
    }
  };
}
function tN(t) {
  throw t;
}
var Nj = { closed: !0, next: v3, error: tN, complete: v3 }, Rj = typeof Symbol == "function" && Symbol.observable || "@@observable";
function Oj(t) {
  return t;
}
var yw = function() {
  function t(e) {
    e && (this._subscribe = e);
  }
  return t.prototype.lift = function(e) {
    var r = new t();
    return r.source = this, r.operator = e, r;
  }, t.prototype.subscribe = function(e, r, n) {
    var i, a = this, o = (i = e) && i instanceof eN || function(s) {
      return s && ml(s.next) && ml(s.error) && ml(s.complete);
    }(i) && JF(i) ? e : new y_(e, r, n);
    return Qv(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;
  }, t.prototype._trySubscribe = function(e) {
    try {
      return this._subscribe(e);
    } catch (r) {
      e.error(r);
    }
  }, t.prototype.forEach = function(e, r) {
    var n = this;
    return new (r = bw(r))(function(i, a) {
      var o = new y_({ next: function(s) {
        try {
          e(s);
        } catch (u) {
          a(u), o.unsubscribe();
        }
      }, error: a, complete: i });
      n.subscribe(o);
    });
  }, t.prototype._subscribe = function(e) {
    var r;
    return (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e);
  }, t.prototype[Rj] = function() {
    return this;
  }, t.prototype.pipe = function() {
    for (var e, r = [], n = 0; n < arguments.length; n++) r[n] = arguments[n];
    return ((e = r).length === 0 ? Oj : e.length === 1 ? e[0] : function(i) {
      return e.reduce(function(a, o) {
        return o(a);
      }, i);
    })(this);
  }, t.prototype.toPromise = function(e) {
    var r = this;
    return new (e = bw(e))(function(n, i) {
      var a;
      r.subscribe(function(o) {
        return a = o;
      }, function(o) {
        return i(o);
      }, function() {
        return n(a);
      });
    });
  }, t.create = function(e) {
    return new t(e);
  }, t;
}();
function bw(t) {
  var e;
  return (e = t ?? $F.Promise) !== null && e !== void 0 ? e : Promise;
}
var Lj = ZF(function(t) {
  return function() {
    t(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
  };
}), Si = function(t) {
  function e() {
    var r = t.call(this) || this;
    return r.closed = !1, r.observers = [], r.isStopped = !1, r.hasError = !1, r.thrownError = null, r;
  }
  return ka(e, t), e.prototype.lift = function(r) {
    var n = new _w(this, this);
    return n.operator = r, n;
  }, e.prototype._throwIfClosed = function() {
    if (this.closed) throw new Lj();
  }, e.prototype.next = function(r) {
    var n = this;
    Qv(function() {
      var i, a;
      if (n._throwIfClosed(), !n.isStopped) {
        var o = n.observers.slice();
        try {
          for (var s = g_(o), u = s.next(); !u.done; u = s.next())
            u.value.next(r);
        } catch (c) {
          i = { error: c };
        } finally {
          try {
            u && !u.done && (a = s.return) && a.call(s);
          } finally {
            if (i) throw i.error;
          }
        }
      }
    });
  }, e.prototype.error = function(r) {
    var n = this;
    Qv(function() {
      if (n._throwIfClosed(), !n.isStopped) {
        n.hasError = n.isStopped = !0, n.thrownError = r;
        for (var i = n.observers; i.length; ) i.shift().error(r);
      }
    });
  }, e.prototype.complete = function() {
    var r = this;
    Qv(function() {
      if (r._throwIfClosed(), !r.isStopped) {
        r.isStopped = !0;
        for (var n = r.observers; n.length; ) n.shift().complete();
      }
    });
  }, e.prototype.unsubscribe = function() {
    this.isStopped = this.closed = !0, this.observers = null;
  }, Object.defineProperty(e.prototype, "observed", { get: function() {
    var r;
    return ((r = this.observers) === null || r === void 0 ? void 0 : r.length) > 0;
  }, enumerable: !1, configurable: !0 }), e.prototype._trySubscribe = function(r) {
    return this._throwIfClosed(), t.prototype._trySubscribe.call(this, r);
  }, e.prototype._subscribe = function(r) {
    return this._throwIfClosed(), this._checkFinalizedStatuses(r), this._innerSubscribe(r);
  }, e.prototype._innerSubscribe = function(r) {
    var n = this, i = n.hasError, a = n.isStopped, o = n.observers;
    return i || a ? QF : (o.push(r), new Py(function() {
      return v_(o, r);
    }));
  }, e.prototype._checkFinalizedStatuses = function(r) {
    var n = this, i = n.hasError, a = n.thrownError, o = n.isStopped;
    i ? r.error(a) : o && r.complete();
  }, e.prototype.asObservable = function() {
    var r = new yw();
    return r.source = this, r;
  }, e.create = function(r, n) {
    return new _w(r, n);
  }, e;
}(yw), _w = function(t) {
  function e(r, n) {
    var i = t.call(this) || this;
    return i.destination = r, i.source = n, i;
  }
  return ka(e, t), e.prototype.next = function(r) {
    var n, i;
    (i = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || i === void 0 || i.call(n, r);
  }, e.prototype.error = function(r) {
    var n, i;
    (i = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || i === void 0 || i.call(n, r);
  }, e.prototype.complete = function() {
    var r, n;
    (n = (r = this.destination) === null || r === void 0 ? void 0 : r.complete) === null || n === void 0 || n.call(r);
  }, e.prototype._subscribe = function(r) {
    var n, i;
    return (i = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(r)) !== null && i !== void 0 ? i : QF;
  }, e;
}(Si), kd = function(t) {
  function e(r) {
    var n = t.call(this) || this;
    return n._value = r, n;
  }
  return ka(e, t), Object.defineProperty(e.prototype, "value", { get: function() {
    return this.getValue();
  }, enumerable: !1, configurable: !0 }), e.prototype._subscribe = function(r) {
    var n = t.prototype._subscribe.call(this, r);
    return !n.closed && r.next(this._value), n;
  }, e.prototype.getValue = function() {
    var r = this, n = r.hasError, i = r.thrownError, a = r._value;
    if (n) throw i;
    return this._throwIfClosed(), a;
  }, e.prototype.next = function(r) {
    t.prototype.next.call(this, this._value = r);
  }, e;
}(Si), wi = function() {
  if (typeof window < "u" && window.performance) {
    var t = window.performance;
    return function() {
      return t.now();
    };
  }
  return typeof process < "u" && process.hrtime !== "undefined" && typeof process.hrtime == "function" ? function() {
    var e = process.hrtime();
    return 1e3 * e[0] + e[1] / 1e6;
  } : Date.now ? function() {
    return Date.now();
  } : function() {
    return +/* @__PURE__ */ new Date();
  };
}(), Cn = 1e-6;
function jn(t, e, r) {
  return Math.abs(t - e) <= r;
}
var Qn, Ga, Ir, Ki, xw, wm, Sw = Math.PI / 2, rN = Math.PI / 180;
function qn(t) {
  return t * rN;
}
function Ua(t) {
  return t / rN;
}
function nN(t, e) {
  return t * e;
}
function he() {
  return he.zero();
}
function _o(t, e, r) {
  return Math.max(e, Math.min(r, t));
}
function Vi(t, e, r) {
  return t + (e - t) * r;
}
function Jv(t, e, r, n, i, a) {
  var o = (r - t) * a, s = (n - e) * a, u = i * i;
  return (2 * e - 2 * r + o + s) * (i * u) + (-3 * e + 3 * r - 2 * o - s) * u + o * i + e;
}
function P6(t, e, r, n) {
  var i = 1 - n;
  return i * i * t + 2 * i * n * e + n * n * r;
}
function iN(t, e, r) {
  var n;
  return n = function(i, a, o) {
    return (i - a) / (o - a);
  }(r, t, e), (r = _o(n, 0, 1)) * r * (3 - 2 * r);
}
function E() {
  return E.zero();
}
function Wi() {
  return Wi.zero();
}
function ze() {
  return ze.zero();
}
function Ut() {
  return Ut.zero();
}
function kn() {
  return kn.zero();
}
function kj(t, e) {
  return t - e;
}
function io(t, e) {
  t === void 0 && (t = 0), e === void 0 && (e = Number.MAX_SAFE_INTEGER);
  var r = t;
  return function() {
    var n = r;
    return r = (r + 1) % e, n;
  };
}
(function(t) {
  function e() {
    var p = [0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    return p[0] = 0, p;
  }
  function r() {
    var p = e();
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  function n(p) {
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  function i(p) {
    for (var v = 0; v < 16; v++) p[v] = 0;
    return p;
  }
  t.zero = e, t.identity = r, t.setIdentity = n, t.setZero = i, t.ofRows = function(p) {
    for (var v = e(), g = 0; g < 4; g++) for (var y = p[g], b = 0; b < 4; b++) v[4 * b + g] = y[b];
    return v;
  };
  var a = r();
  function o(p, v, g) {
    for (var y = 0; y < 16; y++) if (Math.abs(p[y] - v[y]) > g) return !1;
    return !0;
  }
  function s(p, v, g, y) {
    p[4 * g + v] = y;
  }
  function u(p, v) {
    return p[0] = v[0], p[1] = v[1], p[2] = v[2], p[3] = v[3], p[4] = v[4], p[5] = v[5], p[6] = v[6], p[7] = v[7], p[8] = v[8], p[9] = v[9], p[10] = v[10], p[11] = v[11], p[12] = v[12], p[13] = v[13], p[14] = v[14], p[15] = v[15], p;
  }
  function c(p, v) {
    var g = v[0], y = v[1], b = v[2], S = v[3], _ = v[4], x = v[5], C = v[6], A = v[7], w = v[8], I = v[9], P = v[10], M = v[11], T = v[12], F = v[13], N = v[14], R = v[15], L = g * x - y * _, V = g * C - b * _, U = g * A - S * _, H = y * C - b * x, K = y * A - S * x, X = b * A - S * C, Y = w * F - I * T, Q = w * N - P * T, J = w * R - M * T, te = I * N - P * F, W = I * R - M * F, j = P * R - M * N, ee = L * j - V * W + U * te + H * J - K * Q + X * Y;
    return !!ee && (ee = 1 / ee, p[0] = (x * j - C * W + A * te) * ee, p[1] = (b * W - y * j - S * te) * ee, p[2] = (F * X - N * K + R * H) * ee, p[3] = (P * K - I * X - M * H) * ee, p[4] = (C * J - _ * j - A * Q) * ee, p[5] = (g * j - b * J + S * Q) * ee, p[6] = (N * U - T * X - R * V) * ee, p[7] = (w * X - P * U + M * V) * ee, p[8] = (_ * W - x * J + A * Y) * ee, p[9] = (y * J - g * W - S * Y) * ee, p[10] = (T * K - F * U + R * L) * ee, p[11] = (I * U - w * K - M * L) * ee, p[12] = (x * Q - _ * te - C * Y) * ee, p[13] = (g * te - y * Q + b * Y) * ee, p[14] = (F * V - T * H - N * L) * ee, p[15] = (w * H - I * V + P * L) * ee, !0);
  }
  function l(p, v, g) {
    var y = v[0], b = v[1], S = v[2], _ = v[3], x = v[4], C = v[5], A = v[6], w = v[7], I = v[8], P = v[9], M = v[10], T = v[11], F = v[12], N = v[13], R = v[14], L = v[15], V = g[0], U = g[1], H = g[2], K = g[3];
    return p[0] = V * y + U * x + H * I + K * F, p[1] = V * b + U * C + H * P + K * N, p[2] = V * S + U * A + H * M + K * R, p[3] = V * _ + U * w + H * T + K * L, V = g[4], U = g[5], H = g[6], K = g[7], p[4] = V * y + U * x + H * I + K * F, p[5] = V * b + U * C + H * P + K * N, p[6] = V * S + U * A + H * M + K * R, p[7] = V * _ + U * w + H * T + K * L, V = g[8], U = g[9], H = g[10], K = g[11], p[8] = V * y + U * x + H * I + K * F, p[9] = V * b + U * C + H * P + K * N, p[10] = V * S + U * A + H * M + K * R, p[11] = V * _ + U * w + H * T + K * L, V = g[12], U = g[13], H = g[14], K = g[15], p[12] = V * y + U * x + H * I + K * F, p[13] = V * b + U * C + H * P + K * N, p[14] = V * S + U * A + H * M + K * R, p[15] = V * _ + U * w + H * T + K * L, p;
  }
  function d(p, v, g) {
    var y = g[0], b = g[1], S = g[2], _ = Math.sqrt(y * y + b * b + S * S);
    if (Math.abs(_) < Cn) return n(p);
    y *= _ = 1 / _, b *= _, S *= _;
    var x = Math.sin(v), C = Math.cos(v), A = 1 - C;
    return p[0] = y * y * A + C, p[1] = b * y * A + S * x, p[2] = S * y * A - b * x, p[3] = 0, p[4] = y * b * A - S * x, p[5] = b * b * A + C, p[6] = S * b * A + y * x, p[7] = 0, p[8] = y * S * A + b * x, p[9] = b * S * A - y * x, p[10] = S * S * A + C, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  t.isIdentity = function(p, v) {
    return o(p, a, v === void 0 ? Cn : v);
  }, t.hasNaN = function(p) {
    for (var v = 0; v < 16; v++) if (isNaN(p[v])) return !0;
    return !1;
  }, t.areEqual = o, t.setValue = s, t.getValue = function(p, v, g) {
    return p[4 * g + v];
  }, t.toArray = function(p, v, g) {
    return v[g + 0] = p[0], v[g + 1] = p[1], v[g + 2] = p[2], v[g + 3] = p[3], v[g + 4] = p[4], v[g + 5] = p[5], v[g + 6] = p[6], v[g + 7] = p[7], v[g + 8] = p[8], v[g + 9] = p[9], v[g + 10] = p[10], v[g + 11] = p[11], v[g + 12] = p[12], v[g + 13] = p[13], v[g + 14] = p[14], v[g + 15] = p[15], v;
  }, t.fromArray = function(p, v, g) {
    return p[0] = v[g + 0], p[1] = v[g + 1], p[2] = v[g + 2], p[3] = v[g + 3], p[4] = v[g + 4], p[5] = v[g + 5], p[6] = v[g + 6], p[7] = v[g + 7], p[8] = v[g + 8], p[9] = v[g + 9], p[10] = v[g + 10], p[11] = v[g + 11], p[12] = v[g + 12], p[13] = v[g + 13], p[14] = v[g + 14], p[15] = v[g + 15], p;
  }, t.fromBasis = function(p, v, g, y) {
    return i(p), s(p, 0, 0, v[0]), s(p, 1, 0, v[1]), s(p, 2, 0, v[2]), s(p, 0, 1, g[0]), s(p, 1, 1, g[1]), s(p, 2, 1, g[2]), s(p, 0, 2, y[0]), s(p, 1, 2, y[1]), s(p, 2, 2, y[2]), s(p, 3, 3, 1), p;
  }, t.copy = u, t.clone = function(p) {
    return u(e(), p);
  }, t.getTranslation = function(p, v) {
    return p[0] = v[12], p[1] = v[13], p[2] = v[14], p;
  }, t.getScaling = function(p, v) {
    var g = v[0], y = v[1], b = v[2], S = v[4], _ = v[5], x = v[6], C = v[8], A = v[9], w = v[10];
    return p[0] = Math.sqrt(g * g + y * y + b * b), p[1] = Math.sqrt(S * S + _ * _ + x * x), p[2] = Math.sqrt(C * C + A * A + w * w), p;
  }, t.getRotation = function(p, v) {
    var g = v[0] + v[5] + v[10], y = 0;
    return g > 0 ? (y = 2 * Math.sqrt(g + 1), p[3] = 0.25 * y, p[0] = (v[6] - v[9]) / y, p[1] = (v[8] - v[2]) / y, p[2] = (v[1] - v[4]) / y) : v[0] > v[5] && v[0] > v[10] ? (y = 2 * Math.sqrt(1 + v[0] - v[5] - v[10]), p[3] = (v[6] - v[9]) / y, p[0] = 0.25 * y, p[1] = (v[1] + v[4]) / y, p[2] = (v[8] + v[2]) / y) : v[5] > v[10] ? (y = 2 * Math.sqrt(1 + v[5] - v[0] - v[10]), p[3] = (v[8] - v[2]) / y, p[0] = (v[1] + v[4]) / y, p[1] = 0.25 * y, p[2] = (v[6] + v[9]) / y) : (y = 2 * Math.sqrt(1 + v[10] - v[0] - v[5]), p[3] = (v[1] - v[4]) / y, p[0] = (v[8] + v[2]) / y, p[1] = (v[6] + v[9]) / y, p[2] = 0.25 * y), p;
  }, t.extractRotation = function(p, v) {
    var g = 1 / Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]), y = 1 / Math.sqrt(v[4] * v[4] + v[5] * v[5] + v[6] * v[6]), b = 1 / Math.sqrt(v[8] * v[8] + v[9] * v[9] + v[10] * v[10]);
    return p[0] = v[0] * g, p[1] = v[1] * g, p[2] = v[2] * g, p[3] = 0, p[4] = v[4] * y, p[5] = v[5] * y, p[6] = v[6] * y, p[7] = 0, p[8] = v[8] * b, p[9] = v[9] * b, p[10] = v[10] * b, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, t.transpose = function(p, v) {
    if (p === v) {
      var g = v[1], y = v[2], b = v[3], S = v[6], _ = v[7], x = v[11];
      p[1] = v[4], p[2] = v[8], p[3] = v[12], p[4] = g, p[6] = v[9], p[7] = v[13], p[8] = y, p[9] = S, p[11] = v[14], p[12] = b, p[13] = _, p[14] = x;
    } else p[0] = v[0], p[1] = v[4], p[2] = v[8], p[3] = v[12], p[4] = v[1], p[5] = v[5], p[6] = v[9], p[7] = v[13], p[8] = v[2], p[9] = v[6], p[10] = v[10], p[11] = v[14], p[12] = v[3], p[13] = v[7], p[14] = v[11], p[15] = v[15];
    return p;
  }, t.tryInvert = c, t.invert = function(p, v) {
    return c(p, v) || console.warn("non-invertible matrix.", v), p;
  }, t.mul = l, t.mulOffset = function(p, v, g, y, b, S) {
    var _ = v[0 + b], x = v[1 + b], C = v[2 + b], A = v[3 + b], w = v[4 + b], I = v[5 + b], P = v[6 + b], M = v[7 + b], T = v[8 + b], F = v[9 + b], N = v[10 + b], R = v[11 + b], L = v[12 + b], V = v[13 + b], U = v[14 + b], H = v[15 + b], K = g[0 + S], X = g[1 + S], Y = g[2 + S], Q = g[3 + S];
    return p[0 + y] = K * _ + X * w + Y * T + Q * L, p[1 + y] = K * x + X * I + Y * F + Q * V, p[2 + y] = K * C + X * P + Y * N + Q * U, p[3 + y] = K * A + X * M + Y * R + Q * H, K = g[4 + S], X = g[5 + S], Y = g[6 + S], Q = g[7 + S], p[4 + y] = K * _ + X * w + Y * T + Q * L, p[5 + y] = K * x + X * I + Y * F + Q * V, p[6 + y] = K * C + X * P + Y * N + Q * U, p[7 + y] = K * A + X * M + Y * R + Q * H, K = g[8 + S], X = g[9 + S], Y = g[10 + S], Q = g[11 + S], p[8 + y] = K * _ + X * w + Y * T + Q * L, p[9 + y] = K * x + X * I + Y * F + Q * V, p[10 + y] = K * C + X * P + Y * N + Q * U, p[11 + y] = K * A + X * M + Y * R + Q * H, K = g[12 + S], X = g[13 + S], Y = g[14 + S], Q = g[15 + S], p[12 + y] = K * _ + X * w + Y * T + Q * L, p[13 + y] = K * x + X * I + Y * F + Q * V, p[14 + y] = K * C + X * P + Y * N + Q * U, p[15 + y] = K * A + X * M + Y * R + Q * H, p;
  }, t.mul3 = function(p, v, g, y) {
    return l(p, l(p, v, g), y);
  }, t.translate = function(p, v, g) {
    var y, b, S, _, x, C, A, w, I, P, M, T, F = g[0], N = g[1], R = g[2];
    return v === p ? (p[12] = v[0] * F + v[4] * N + v[8] * R + v[12], p[13] = v[1] * F + v[5] * N + v[9] * R + v[13], p[14] = v[2] * F + v[6] * N + v[10] * R + v[14], p[15] = v[3] * F + v[7] * N + v[11] * R + v[15]) : (y = v[0], b = v[1], S = v[2], _ = v[3], x = v[4], C = v[5], A = v[6], w = v[7], I = v[8], P = v[9], M = v[10], T = v[11], p[0] = y, p[1] = b, p[2] = S, p[3] = _, p[4] = x, p[5] = C, p[6] = A, p[7] = w, p[8] = I, p[9] = P, p[10] = M, p[11] = T, p[12] = y * F + x * N + I * R + v[12], p[13] = b * F + C * N + P * R + v[13], p[14] = S * F + A * N + M * R + v[14], p[15] = _ * F + w * N + T * R + v[15]), p;
  }, t.fromTranslation = function(p, v) {
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = v[0], p[13] = v[1], p[14] = v[2], p[15] = 1, p;
  }, t.setTranslation = function(p, v) {
    return p[12] = v[0], p[13] = v[1], p[14] = v[2], p;
  }, t.setAxes = function(p, v, g, y) {
    return p[0] = g[0], p[4] = g[1], p[8] = g[2], p[1] = y[0], p[5] = y[1], p[9] = y[2], p[2] = v[0], p[6] = v[1], p[10] = v[2], p;
  }, t.rotate = function(p, v, g, y) {
    var b = y[0], S = y[1], _ = y[2], x = Math.sqrt(b * b + S * S + _ * _);
    if (Math.abs(x) < Cn) return r();
    b *= x = 1 / x, S *= x, _ *= x;
    var C = Math.sin(g), A = Math.cos(g), w = 1 - A, I = v[0], P = v[1], M = v[2], T = v[3], F = v[4], N = v[5], R = v[6], L = v[7], V = v[8], U = v[9], H = v[10], K = v[11], X = b * b * w + A, Y = S * b * w + _ * C, Q = _ * b * w - S * C, J = b * S * w - _ * C, te = S * S * w + A, W = _ * S * w + b * C, j = b * _ * w + S * C, ee = S * _ * w - b * C, ie = _ * _ * w + A;
    return p[0] = I * X + F * Y + V * Q, p[1] = P * X + N * Y + U * Q, p[2] = M * X + R * Y + H * Q, p[3] = T * X + L * Y + K * Q, p[4] = I * J + F * te + V * W, p[5] = P * J + N * te + U * W, p[6] = M * J + R * te + H * W, p[7] = T * J + L * te + K * W, p[8] = I * j + F * ee + V * ie, p[9] = P * j + N * ee + U * ie, p[10] = M * j + R * ee + H * ie, p[11] = T * j + L * ee + K * ie, v !== p && (p[12] = v[12], p[13] = v[13], p[14] = v[14], p[15] = v[15]), p;
  }, t.fromRotation = d, t.scale = function(p, v, g) {
    var y = g[0], b = g[1], S = g[2];
    return p[0] = v[0] * y, p[1] = v[1] * y, p[2] = v[2] * y, p[3] = v[3] * y, p[4] = v[4] * b, p[5] = v[5] * b, p[6] = v[6] * b, p[7] = v[7] * b, p[8] = v[8] * S, p[9] = v[9] * S, p[10] = v[10] * S, p[11] = v[11] * S, p[12] = v[12], p[13] = v[13], p[14] = v[14], p[15] = v[15], p;
  }, t.scaleUniformly = function(p, v, g) {
    return p[0] = v[0] * g, p[1] = v[1] * g, p[2] = v[2] * g, p[3] = v[3] * g, p[4] = v[4] * g, p[5] = v[5] * g, p[6] = v[6] * g, p[7] = v[7] * g, p[8] = v[8] * g, p[9] = v[9] * g, p[10] = v[10] * g, p[11] = v[11] * g, p[12] = v[12], p[13] = v[13], p[14] = v[14], p[15] = v[15], p;
  }, t.fromScaling = function(p, v) {
    return p[0] = v[0], p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = v[1], p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = v[2], p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, t.fromUniformScaling = function(p, v) {
    return p[0] = v, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = v, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = v, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, t.fromMat3 = function(p, v) {
    return p[0] = v[0], p[1] = v[1], p[2] = v[2], p[4] = v[3], p[5] = v[4], p[6] = v[5], p[8] = v[6], p[9] = v[7], p[10] = v[8], p;
  }, t.makeTable = function(p) {
    for (var v = "", g = 0; g < 4; g++) {
      for (var y = 0; y < 4; y++) v += p[4 * y + g].toString(), y < 3 && (v += " ");
      g < 3 && (v += `
`);
    }
    return v;
  }, t.determinant = function(p) {
    var v = p[0], g = p[1], y = p[2], b = p[3], S = p[4], _ = p[5], x = p[6], C = p[7], A = p[8], w = p[9], I = p[10], P = p[11], M = p[12], T = p[13], F = p[14], N = p[15];
    return (v * _ - g * S) * (I * N - P * F) - (v * x - y * S) * (w * N - P * T) + (v * C - b * S) * (w * F - I * T) + (g * x - y * _) * (A * N - P * M) - (g * C - b * _) * (A * F - I * M) + (y * C - b * x) * (A * T - w * M);
  }, t.isRotationAndTranslation = function(p, v) {
    return function(g, y) {
      var b = g[0], S = g[1], _ = g[2], x = g[3], C = g[4], A = g[5], w = g[6], I = g[7], P = g[8], M = g[9], T = g[10], F = g[11], N = g[15];
      return !(!(jn(N, 1, y) && jn(x, 0, y) && jn(I, 0, y) && jn(F, 0, y)) || !jn(Math.abs(b * (A * T - w * M) - S * (C * T - w * P) + _ * (C * M - A * P)), 1, y));
    }(p, v !== void 0 ? v : Cn);
  }, t.isTranslationAndUniformScaling = function(p, v) {
    return function(g, y) {
      var b = g[0];
      return jn(g[1], 0, y) && jn(g[2], 0, y) && jn(g[3], 0, y) && jn(g[4], 0, y) && jn(g[5], b, y) && jn(g[6], 0, y) && jn(g[7], 0, y) && jn(g[8], 0, y) && jn(g[9], 0, y) && jn(g[10], b, y) && jn(g[11], 0, y) && jn(g[15], 1, y);
    }(p, v !== void 0 ? v : Cn);
  }, t.fromQuat = function(p, v) {
    var g = v[0], y = v[1], b = v[2], S = v[3], _ = g + g, x = y + y, C = b + b, A = g * _, w = y * _, I = y * x, P = b * _, M = b * x, T = b * C, F = S * _, N = S * x, R = S * C;
    return p[0] = 1 - I - T, p[1] = w + R, p[2] = P - N, p[3] = 0, p[4] = w - R, p[5] = 1 - A - T, p[6] = M + F, p[7] = 0, p[8] = P + N, p[9] = M - F, p[10] = 1 - A - I, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, t.perspective = function(p, v, g, y, b, S, _) {
    var x = 2 * S / (g - v), C = 2 * S / (y - b), A = (g + v) / (g - v), w = (y + b) / (y - b), I = -(_ + S) / (_ - S), P = -2 * _ * S / (_ - S);
    return p[0] = x, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = C, p[6] = 0, p[7] = 0, p[8] = A, p[9] = w, p[10] = I, p[11] = -1, p[12] = 0, p[13] = 0, p[14] = P, p[15] = 0, p;
  }, t.ortho = function(p, v, g, y, b, S, _) {
    var x = 1 / (g - v), C = 1 / (y - b), A = 1 / (_ - S), w = (g + v) * x, I = (y + b) * C, P = (_ + S) * A;
    return p[0] = 2 * x, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 2 * C, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = -2 * A, p[11] = 0, p[12] = -w, p[13] = -I, p[14] = -P, p[15] = 1, p;
  }, t.lookAt = function(p, v, g, y) {
    var b, S, _, x, C, A, w, I, P, M, T = v[0], F = v[1], N = v[2], R = y[0], L = y[1], V = y[2], U = g[0], H = g[1], K = g[2];
    return Math.abs(T - U) < Cn && Math.abs(F - H) < Cn && Math.abs(N - K) < Cn ? n(p) : (w = T - U, I = F - H, P = N - K, b = L * (P *= M = 1 / Math.sqrt(w * w + I * I + P * P)) - V * (I *= M), S = V * (w *= M) - R * P, _ = R * I - L * w, (M = Math.sqrt(b * b + S * S + _ * _)) ? (b *= M = 1 / M, S *= M, _ *= M) : (b = 0, S = 0, _ = 0), x = I * _ - P * S, C = P * b - w * _, A = w * S - I * b, (M = Math.sqrt(x * x + C * C + A * A)) ? (x *= M = 1 / M, C *= M, A *= M) : (x = 0, C = 0, A = 0), p[0] = b, p[1] = x, p[2] = w, p[3] = 0, p[4] = S, p[5] = C, p[6] = I, p[7] = 0, p[8] = _, p[9] = A, p[10] = P, p[11] = 0, p[12] = -(b * T + S * F + _ * N), p[13] = -(x * T + C * F + A * N), p[14] = -(w * T + I * F + P * N), p[15] = 1, p);
  }, t.targetTo = function(p, v, g, y) {
    var b = v[0], S = v[1], _ = v[2], x = y[0], C = y[1], A = y[2], w = b - g[0], I = S - g[1], P = _ - g[2], M = w * w + I * I + P * P;
    M > 0 && (w *= M = 1 / Math.sqrt(M), I *= M, P *= M);
    var T = C * P - A * I, F = A * w - x * P, N = x * I - C * w;
    return (M = T * T + F * F + N * N) > 0 && (T *= M = 1 / Math.sqrt(M), F *= M, N *= M), p[0] = T, p[1] = F, p[2] = N, p[3] = 0, p[4] = I * N - P * F, p[5] = P * T - w * N, p[6] = w * F - I * T, p[7] = 0, p[8] = w, p[9] = I, p[10] = P, p[11] = 0, p[12] = b, p[13] = S, p[14] = _, p[15] = 1, p;
  }, t.fromPermutation = function(p, v) {
    i(p);
    for (var g = 0; g < 4; g++)
      s(p, g, v[g], 1);
    return p;
  }, t.getMaxScaleOnAxis = function(p) {
    var v = p[0] * p[0] + p[1] * p[1] + p[2] * p[2], g = p[4] * p[4] + p[5] * p[5] + p[6] * p[6], y = p[8] * p[8] + p[9] * p[9] + p[10] * p[10];
    return Math.sqrt(Math.max(v, g, y));
  };
  var f = [1, 0, 0], h = [0, 1, 0], m = [0, 0, 1];
  t.rotX90 = d(e(), qn(90), f), t.rotX180 = d(e(), qn(180), f), t.rotY90 = d(e(), qn(90), h), t.rotY180 = d(e(), qn(180), h), t.rotY270 = d(e(), qn(270), h), t.rotZ90 = d(e(), qn(90), m), t.rotZ180 = d(e(), qn(180), m), t.rotXY90 = l(e(), t.rotX90, t.rotY90), t.rotZY90 = l(e(), t.rotZ90, t.rotY90), t.rotZYZ90 = l(e(), t.rotZY90, t.rotZ90), t.rotZ90X180 = l(e(), t.rotZ90, t.rotX180), t.rotY90Z180 = l(e(), t.rotY90, t.rotZ180), t.id = r();
})(he || (he = {})), function(t) {
  function e() {
    var M = [0.1, 0, 0];
    return M[0] = 0, M;
  }
  function r(M, T, F) {
    var N = e();
    return N[0] = M, N[1] = T, N[2] = F, N;
  }
  function n(M, T) {
    return M[0] = T[0], M[1] = T[1], M[2] = T[2], M;
  }
  function i(M, T, F) {
    return M[0] = T[0] + F[0], M[1] = T[1] + F[1], M[2] = T[2] + F[2], M;
  }
  function a(M, T, F) {
    return M[0] = T[0] - F[0], M[1] = T[1] - F[1], M[2] = T[2] - F[2], M;
  }
  function o(M, T, F) {
    return M[0] = T[0] * F, M[1] = T[1] * F, M[2] = T[2] * F, M;
  }
  function s(M, T, F, N) {
    return M[0] = T[0] + F[0] * N, M[1] = T[1] + F[1] * N, M[2] = T[2] + F[2] * N, M;
  }
  function u(M) {
    var T = M[0], F = M[1], N = M[2];
    return T * T + F * F + N * N;
  }
  function c(M, T) {
    return M[0] = -T[0], M[1] = -T[1], M[2] = -T[2], M;
  }
  function l(M, T) {
    var F = T[0], N = T[1], R = T[2], L = F * F + N * N + R * R;
    return L > 0 && (L = 1 / Math.sqrt(L), M[0] = T[0] * L, M[1] = T[1] * L, M[2] = T[2] * L), M;
  }
  function d(M, T) {
    return M[0] * T[0] + M[1] * T[1] + M[2] * T[2];
  }
  function f(M, T, F) {
    var N = T[0], R = T[1], L = T[2], V = F[0], U = F[1], H = F[2];
    return M[0] = R * H - L * U, M[1] = L * V - N * H, M[2] = N * U - R * V, M;
  }
  t.zero = e, t.clone = function(M) {
    var T = e();
    return T[0] = M[0], T[1] = M[1], T[2] = M[2], T;
  }, t.hasNaN = function(M) {
    return isNaN(M[0]) || isNaN(M[1]) || isNaN(M[2]);
  }, t.setNaN = function(M) {
    return M[0] = NaN, M[1] = NaN, M[2] = NaN, M;
  }, t.fromObj = function(M) {
    return r(M.x, M.y, M.z);
  }, t.toObj = function(M) {
    return { x: M[0], y: M[1], z: M[2] };
  }, t.fromArray = function(M, T, F) {
    return M[0] = T[F + 0], M[1] = T[F + 1], M[2] = T[F + 2], M;
  }, t.toArray = function(M, T, F) {
    return T[F + 0] = M[0], T[F + 1] = M[1], T[F + 2] = M[2], T;
  }, t.create = r, t.ofArray = function(M) {
    var T = e();
    return T[0] = M[0], T[1] = M[1], T[2] = M[2], T;
  }, t.set = function(M, T, F, N) {
    return M[0] = T, M[1] = F, M[2] = N, M;
  }, t.copy = n, t.add = i, t.sub = a, t.mul = function(M, T, F) {
    return M[0] = T[0] * F[0], M[1] = T[1] * F[1], M[2] = T[2] * F[2], M;
  }, t.div = function(M, T, F) {
    return M[0] = T[0] / F[0], M[1] = T[1] / F[1], M[2] = T[2] / F[2], M;
  }, t.scale = o, t.scaleAndAdd = s, t.scaleAndSub = function(M, T, F, N) {
    return M[0] = T[0] - F[0] * N, M[1] = T[1] - F[1] * N, M[2] = T[2] - F[2] * N, M;
  }, t.addScalar = function(M, T, F) {
    return M[0] = T[0] + F, M[1] = T[1] + F, M[2] = T[2] + F, M;
  }, t.subScalar = function(M, T, F) {
    return M[0] = T[0] - F, M[1] = T[1] - F, M[2] = T[2] - F, M;
  }, t.round = function(M, T) {
    return M[0] = Math.round(T[0]), M[1] = Math.round(T[1]), M[2] = Math.round(T[2]), M;
  }, t.ceil = function(M, T) {
    return M[0] = Math.ceil(T[0]), M[1] = Math.ceil(T[1]), M[2] = Math.ceil(T[2]), M;
  }, t.floor = function(M, T) {
    return M[0] = Math.floor(T[0]), M[1] = Math.floor(T[1]), M[2] = Math.floor(T[2]), M;
  }, t.trunc = function(M, T) {
    return M[0] = Math.trunc(T[0]), M[1] = Math.trunc(T[1]), M[2] = Math.trunc(T[2]), M;
  }, t.abs = function(M, T) {
    return M[0] = Math.abs(T[0]), M[1] = Math.abs(T[1]), M[2] = Math.abs(T[2]), M;
  }, t.min = function(M, T, F) {
    return M[0] = Math.min(T[0], F[0]), M[1] = Math.min(T[1], F[1]), M[2] = Math.min(T[2], F[2]), M;
  }, t.max = function(M, T, F) {
    return M[0] = Math.max(T[0], F[0]), M[1] = Math.max(T[1], F[1]), M[2] = Math.max(T[2], F[2]), M;
  }, t.distance = function(M, T) {
    var F = T[0] - M[0], N = T[1] - M[1], R = T[2] - M[2];
    return Math.sqrt(F * F + N * N + R * R);
  }, t.squaredDistance = function(M, T) {
    var F = T[0] - M[0], N = T[1] - M[1], R = T[2] - M[2];
    return F * F + N * N + R * R;
  }, t.magnitude = function(M) {
    var T = M[0], F = M[1], N = M[2];
    return Math.sqrt(T * T + F * F + N * N);
  }, t.squaredMagnitude = u, t.setMagnitude = function(M, T, F) {
    return o(M, l(M, T), F);
  }, t.negate = c, t.inverse = function(M, T) {
    return M[0] = 1 / T[0], M[1] = 1 / T[1], M[2] = 1 / T[2], M;
  }, t.normalize = l, t.dot = d, t.cross = f, t.lerp = function(M, T, F, N) {
    var R = T[0], L = T[1], V = T[2];
    return M[0] = R + N * (F[0] - R), M[1] = L + N * (F[1] - L), M[2] = V + N * (F[2] - V), M;
  };
  var h = e();
  function m(M, T) {
    var F = Math.sqrt(u(M) * u(T));
    if (F === 0) return Math.PI / 2;
    var N = d(M, T) / F;
    return Math.acos(_o(N, -1, 1));
  }
  t.slerp = function(M, T, F, N) {
    var R = _o(d(T, F), -1, 1), L = Math.acos(R) * N;
    return s(h, F, T, -R), l(h, h), i(M, o(M, T, Math.cos(L)), o(h, h, Math.sin(L)));
  }, t.hermite = function(M, T, F, N, R, L) {
    var V = L * L, U = V * (2 * L - 3) + 1, H = V * (L - 2) + L, K = V * (L - 1), X = V * (3 - 2 * L);
    return M[0] = T[0] * U + F[0] * H + N[0] * K + R[0] * X, M[1] = T[1] * U + F[1] * H + N[1] * K + R[1] * X, M[2] = T[2] * U + F[2] * H + N[2] * K + R[2] * X, M;
  }, t.bezier = function(M, T, F, N, R, L) {
    var V = 1 - L, U = V * V, H = L * L, K = U * V, X = 3 * L * U, Y = 3 * H * V, Q = H * L;
    return M[0] = T[0] * K + F[0] * X + N[0] * Y + R[0] * Q, M[1] = T[1] * K + F[1] * X + N[1] * Y + R[1] * Q, M[2] = T[2] * K + F[2] * X + N[2] * Y + R[2] * Q, M;
  }, t.quadraticBezier = function(M, T, F, N, R) {
    return M[0] = P6(T[0], F[0], N[0], R), M[1] = P6(T[1], F[1], N[1], R), M[2] = P6(T[2], F[2], N[2], R), M;
  }, t.spline = function(M, T, F, N, R, L, V) {
    return M[0] = Jv(T[0], F[0], N[0], R[0], L, V), M[1] = Jv(T[1], F[1], N[1], R[1], L, V), M[2] = Jv(T[2], F[2], N[2], R[2], L, V), M;
  }, t.random = function(M, T) {
    var F = 2 * Math.random() * Math.PI, N = 2 * Math.random() - 1, R = Math.sqrt(1 - N * N) * T;
    return M[0] = Math.cos(F) * R, M[1] = Math.sin(F) * R, M[2] = N * T, M;
  }, t.transformMat4 = function(M, T, F) {
    var N = T[0], R = T[1], L = T[2], V = 1 / (F[3] * N + F[7] * R + F[11] * L + F[15] || 1);
    return M[0] = (F[0] * N + F[4] * R + F[8] * L + F[12]) * V, M[1] = (F[1] * N + F[5] * R + F[9] * L + F[13]) * V, M[2] = (F[2] * N + F[6] * R + F[10] * L + F[14]) * V, M;
  }, t.transformMat4Offset = function(M, T, F, N, R, L) {
    var V = T[0 + R], U = T[1 + R], H = T[2 + R], K = 1 / (F[3 + L] * V + F[7 + L] * U + F[11 + L] * H + F[15 + L] || 1);
    return M[0 + N] = (F[0 + L] * V + F[4 + L] * U + F[8 + L] * H + F[12 + L]) * K, M[1 + N] = (F[1 + L] * V + F[5 + L] * U + F[9 + L] * H + F[13 + L]) * K, M[2 + N] = (F[2 + L] * V + F[6 + L] * U + F[10 + L] * H + F[14 + L]) * K, M;
  }, t.transformMat3 = function(M, T, F) {
    var N = T[0], R = T[1], L = T[2];
    return M[0] = N * F[0] + R * F[3] + L * F[6], M[1] = N * F[1] + R * F[4] + L * F[7], M[2] = N * F[2] + R * F[5] + L * F[8], M;
  }, t.transformQuat = function(M, T, F) {
    var N = T[0], R = T[1], L = T[2], V = F[0], U = F[1], H = F[2], K = F[3], X = K * N + U * L - H * R, Y = K * R + H * N - V * L, Q = K * L + V * R - U * N, J = -V * N - U * R - H * L;
    return M[0] = X * K + J * -V + Y * -H - Q * -U, M[1] = Y * K + J * -U + Q * -V - X * -H, M[2] = Q * K + J * -H + X * -U - Y * -V, M;
  }, t.angle = m;
  var p = e(), v = e(), g = e(), y = e(), b = e(), S = e(), _ = e();
  t.dihedralAngle = function(M, T, F, N) {
    a(p, M, T), a(v, F, T), a(g, T, F), a(y, N, F), f(b, p, v), f(S, g, y);
    var R = m(b, S);
    return f(_, b, S), d(v, _) > 0 ? R : -R;
  }, t.directionFromSpherical = function(M, T, F, N) {
    return t.set(M, N * Math.cos(F) * Math.sin(T), N * Math.sin(F) * Math.sin(T), N * Math.cos(T));
  }, t.exactEquals = function(M, T) {
    return M[0] === T[0] && M[1] === T[1] && M[2] === T[2];
  }, t.equals = function(M, T) {
    var F = M[0], N = M[1], R = M[2], L = T[0], V = T[1], U = T[2];
    return Math.abs(F - L) <= Cn * Math.max(1, Math.abs(F), Math.abs(L)) && Math.abs(N - V) <= Cn * Math.max(1, Math.abs(N), Math.abs(V)) && Math.abs(R - U) <= Cn * Math.max(1, Math.abs(R), Math.abs(U));
  };
  var x = e();
  t.makeRotation = function(M, T, F) {
    var N = m(T, F);
    if (Math.abs(N) < 1e-4) return he.setIdentity(M);
    if (Math.abs(N - Math.PI) < Cn) return he.fromScaling(M, t.negUnit);
    var R = f(x, T, F);
    return he.fromRotation(M, N, R);
  }, t.isZero = function(M) {
    return M[0] === 0 && M[1] === 0 && M[2] === 0;
  }, t.projectPointOnVector = function(M, T, F, N) {
    return a(M, T, N), i(M, o(M, F, d(F, M) / u(F)), N);
  };
  var C = e();
  function A(M, T, F) {
    return o(M, F, d(F, T) / u(F));
  }
  t.projectPointOnPlane = function(M, T, F, N) {
    return l(C, F), a(M, T, N), a(M, T, o(C, C, d(M, C)));
  }, t.projectOnVector = A;
  var w = e();
  t.projectOnPlane = function(M, T, F) {
    return A(w, T, F), a(M, T, w);
  }, t.orthogonalize = function(M, T, F) {
    return l(M, f(M, f(M, T, F), T));
  }, t.matchDirection = function(M, T, F) {
    return d(T, F) > 0 ? n(M, T) : c(M, n(M, T)), M;
  };
  var I = e(), P = e();
  t.triangleNormal = function(M, T, F, N) {
    return a(I, F, T), a(P, N, T), l(M, f(M, I, P));
  }, t.toString = function(M, T) {
    return "[".concat(M[0].toPrecision(T), " ").concat(M[1].toPrecision(T), " ").concat(M[2].toPrecision(T), "]");
  }, t.origin = r(0, 0, 0), t.unit = r(1, 1, 1), t.negUnit = r(-1, -1, -1), t.unitX = r(1, 0, 0), t.unitY = r(0, 1, 0), t.unitZ = r(0, 0, 1), t.negUnitX = r(-1, 0, 0), t.negUnitY = r(0, -1, 0), t.negUnitZ = r(0, 0, -1);
}(E || (E = {})), function(t) {
  function e() {
    var _ = [0.1, 0, 0, 0, 0, 0, 0, 0, 0];
    return _[0] = 0, _;
  }
  function r() {
    var _ = e();
    return _[0] = 1, _[1] = 0, _[2] = 0, _[3] = 0, _[4] = 1, _[5] = 0, _[6] = 0, _[7] = 0, _[8] = 1, _;
  }
  function n(_, x) {
    return _[0] = x[0], _[1] = x[1], _[2] = x[2], _[3] = x[4], _[4] = x[5], _[5] = x[6], _[6] = x[8], _[7] = x[9], _[8] = x[10], _;
  }
  t.zero = e, t.identity = r, t.setIdentity = function(_) {
    return _[0] = 1, _[1] = 0, _[2] = 0, _[3] = 0, _[4] = 1, _[5] = 0, _[6] = 0, _[7] = 0, _[8] = 1, _;
  }, t.toArray = function(_, x, C) {
    return x[C + 0] = _[0], x[C + 1] = _[1], x[C + 2] = _[2], x[C + 3] = _[3], x[C + 4] = _[4], x[C + 5] = _[5], x[C + 6] = _[6], x[C + 7] = _[7], x[C + 8] = _[8], x;
  }, t.fromArray = function(_, x, C) {
    return _[0] = x[C + 0], _[1] = x[C + 1], _[2] = x[C + 2], _[3] = x[C + 3], _[4] = x[C + 4], _[5] = x[C + 5], _[6] = x[C + 6], _[7] = x[C + 7], _[8] = x[C + 8], _;
  }, t.fromMat4 = n, t.create = function(_, x, C, A, w, I, P, M, T) {
    var F = e();
    return F[0] = _, F[1] = x, F[2] = C, F[3] = A, F[4] = w, F[5] = I, F[6] = P, F[7] = M, F[8] = T, F;
  };
  var i = r();
  function a(_, x, C) {
    for (var A = 0; A < 9; A++) if (Math.abs(_[A] - x[A]) > C) return !1;
    return !0;
  }
  function o(_, x) {
    return _[0] = x[0], _[1] = x[1], _[2] = x[2], _[3] = x[3], _[4] = x[4], _[5] = x[5], _[6] = x[6], _[7] = x[7], _[8] = x[8], _;
  }
  function s(_, x) {
    if (_ === x) {
      var C = x[1], A = x[2], w = x[5];
      _[1] = x[3], _[2] = x[6], _[3] = C, _[5] = x[7], _[6] = A, _[7] = w;
    } else _[0] = x[0], _[1] = x[3], _[2] = x[6], _[3] = x[1], _[4] = x[4], _[5] = x[7], _[6] = x[2], _[7] = x[5], _[8] = x[8];
    return _;
  }
  function u(_, x) {
    var C = x[0], A = x[1], w = x[2], I = x[3], P = x[4], M = x[5], T = x[6], F = x[7], N = x[8], R = N * P - M * F, L = -N * I + M * T, V = F * I - P * T, U = C * R + A * L + w * V;
    return U ? (U = 1 / U, _[0] = R * U, _[1] = (-N * A + w * F) * U, _[2] = (M * A - w * P) * U, _[3] = L * U, _[4] = (N * C - w * T) * U, _[5] = (-M * C + w * I) * U, _[6] = V * U, _[7] = (-F * C + A * T) * U, _[8] = (P * C - A * I) * U, _) : (console.warn("non-invertible matrix.", x), _);
  }
  function c(_) {
    var x = _[0], C = _[1], A = _[2], w = _[3], I = _[4], P = _[5], M = _[6], T = _[7], F = _[8];
    return x * (F * I - P * T) + C * (-F * w + P * M) + A * (T * w - I * M);
  }
  function l(_) {
    return _[0] + _[4] + _[8];
  }
  function d(_, x, C) {
    return _[0] = x[0] - C[0], _[1] = x[1] - C[1], _[2] = x[2] - C[2], _[3] = x[3] - C[3], _[4] = x[4] - C[4], _[5] = x[5] - C[5], _[6] = x[6] - C[6], _[7] = x[7] - C[7], _[8] = x[8] - C[8], _;
  }
  function f(_, x, C) {
    return _[0] = x[0] * C, _[1] = x[1] * C, _[2] = x[2] * C, _[3] = x[3] * C, _[4] = x[4] * C, _[5] = x[5] * C, _[6] = x[6] * C, _[7] = x[7] * C, _[8] = x[8] * C, _;
  }
  t.isIdentity = function(_, x) {
    return a(_, i, x === void 0 ? Cn : x);
  }, t.hasNaN = function(_) {
    for (var x = 0; x < 9; x++) if (isNaN(_[x])) return !0;
    return !1;
  }, t.clone = function(_) {
    return o(e(), _);
  }, t.areEqual = a, t.setValue = function(_, x, C, A) {
    _[3 * C + x] = A;
  }, t.getValue = function(_, x, C) {
    return _[3 * C + x];
  }, t.copy = o, t.transpose = s, t.invert = u, t.symmtricFromUpper = function(_, x) {
    return _ === x ? (_[3] = x[1], _[6] = x[2], _[7] = x[5]) : (_[0] = x[0], _[1] = x[1], _[2] = x[2], _[3] = x[1], _[4] = x[4], _[5] = x[5], _[6] = x[2], _[7] = x[5], _[8] = x[8]), _;
  }, t.symmtricFromLower = function(_, x) {
    return _ === x ? (_[1] = x[3], _[2] = x[6], _[5] = x[7]) : (_[0] = x[0], _[1] = x[3], _[2] = x[6], _[3] = x[3], _[4] = x[4], _[5] = x[7], _[6] = x[6], _[7] = x[7], _[8] = x[8]), _;
  }, t.determinant = c, t.trace = l, t.sub = d, t.add = function(_, x, C) {
    return _[0] = x[0] + C[0], _[1] = x[1] + C[1], _[2] = x[2] + C[2], _[3] = x[3] + C[3], _[4] = x[4] + C[4], _[5] = x[5] + C[5], _[6] = x[6] + C[6], _[7] = x[7] + C[7], _[8] = x[8] + C[8], _;
  }, t.mul = function(_, x, C) {
    var A = x[0], w = x[1], I = x[2], P = x[3], M = x[4], T = x[5], F = x[6], N = x[7], R = x[8], L = C[0], V = C[1], U = C[2], H = C[3], K = C[4], X = C[5], Y = C[6], Q = C[7], J = C[8];
    return _[0] = L * A + V * P + U * F, _[1] = L * w + V * M + U * N, _[2] = L * I + V * T + U * R, _[3] = H * A + K * P + X * F, _[4] = H * w + K * M + X * N, _[5] = H * I + K * T + X * R, _[6] = Y * A + Q * P + J * F, _[7] = Y * w + Q * M + J * N, _[8] = Y * I + Q * T + J * R, _;
  }, t.subScalar = function(_, x, C) {
    return _[0] = x[0] - C, _[1] = x[1] - C, _[2] = x[2] - C, _[3] = x[3] - C, _[4] = x[4] - C, _[5] = x[5] - C, _[6] = x[6] - C, _[7] = x[7] - C, _[8] = x[8] - C, _;
  }, t.addScalar = function(_, x, C) {
    return _[0] = x[0] + C, _[1] = x[1] + C, _[2] = x[2] + C, _[3] = x[3] + C, _[4] = x[4] + C, _[5] = x[5] + C, _[6] = x[6] + C, _[7] = x[7] + C, _[8] = x[8] + C, _;
  }, t.mulScalar = f;
  var h = Math.PI / 3, m = e();
  t.symmetricEigenvalues = function(_, x) {
    var C = x[1] * x[1] + x[2] * x[2] + x[5] * x[5];
    if (C === 0) _[0] = x[0], _[1] = x[4], _[2] = x[8];
    else {
      var A = l(x) / 3, w = x[0] - A, I = x[4] - A, P = x[8] - A, M = w * w + I * I + P * P + 2 * C, T = Math.sqrt(M / 6);
      f(m, t.Identity, A), d(m, x, m), f(m, m, 1 / T);
      var F = c(m) / 2, N = F <= -1 ? h : F >= 1 ? 0 : Math.acos(F) / 3;
      _[0] = A + 2 * T * Math.cos(N), _[2] = A + 2 * T * Math.cos(N + 2 * h), _[1] = 3 * A - _[0] - _[2];
    }
    return _;
  };
  var p = [0.1, 0, 0], v = [0.1, 0, 0], g = [0.1, 0, 0], y = [0.1, 0, 0], b = [0.1, 0, 0], S = [0.1, 0, 0];
  t.eigenvector = function(_, x, C) {
    E.set(p, x[0] - C, x[1], x[2]), E.set(v, x[1], x[4] - C, x[5]), E.set(g, x[2], x[5], x[8] - C), E.cross(y, p, v), E.cross(b, p, g), E.cross(S, v, g);
    var A = E.dot(y, y), w = E.dot(b, b), I = E.dot(S, S), P = A, M = 0;
    return w > P && (P = w, M = 1), I > P && (M = 2), M === 0 ? E.scale(_, y, 1 / Math.sqrt(A)) : M === 1 ? E.scale(_, b, 1 / Math.sqrt(w)) : E.scale(_, S, 1 / Math.sqrt(I)), _;
  }, t.directionTransform = function(_, x) {
    return n(_, x), u(_, _), s(_, _), _;
  }, t.Identity = r();
}(Wi || (Wi = {})), function(t) {
  function e() {
    var r = [0.1, 0];
    return r[0] = 0, r;
  }
  t.zero = e, t.clone = function(r) {
    var n = e();
    return n[0] = r[0], n[1] = r[1], n;
  }, t.create = function(r, n) {
    var i = e();
    return i[0] = r, i[1] = n, i;
  }, t.hasNaN = function(r) {
    return isNaN(r[0]) || isNaN(r[1]);
  }, t.toArray = function(r, n, i) {
    return n[i + 0] = r[0], n[i + 1] = r[1], n;
  }, t.fromArray = function(r, n, i) {
    return r[0] = n[i + 0], r[1] = n[i + 1], r;
  }, t.copy = function(r, n) {
    return r[0] = n[0], r[1] = n[1], r;
  }, t.set = function(r, n, i) {
    return r[0] = n, r[1] = i, r;
  }, t.add = function(r, n, i) {
    return r[0] = n[0] + i[0], r[1] = n[1] + i[1], r;
  }, t.sub = function(r, n, i) {
    return r[0] = n[0] - i[0], r[1] = n[1] - i[1], r;
  }, t.mul = function(r, n, i) {
    return r[0] = n[0] * i[0], r[1] = n[1] * i[1], r;
  }, t.div = function(r, n, i) {
    return r[0] = n[0] / i[0], r[1] = n[1] / i[1], r;
  }, t.scale = function(r, n, i) {
    return r[0] = n[0] * i, r[1] = n[1] * i, r;
  }, t.round = function(r, n) {
    return r[0] = Math.round(n[0]), r[1] = Math.round(n[1]), r;
  }, t.ceil = function(r, n) {
    return r[0] = Math.ceil(n[0]), r[1] = Math.ceil(n[1]), r;
  }, t.floor = function(r, n) {
    return r[0] = Math.floor(n[0]), r[1] = Math.floor(n[1]), r;
  }, t.distance = function(r, n) {
    var i = n[0] - r[0], a = n[1] - r[1];
    return Math.sqrt(i * i + a * a);
  }, t.squaredDistance = function(r, n) {
    var i = n[0] - r[0], a = n[1] - r[1];
    return i * i + a * a;
  }, t.magnitude = function(r) {
    var n = r[0], i = r[1];
    return Math.sqrt(n * n + i * i);
  }, t.squaredMagnitude = function(r) {
    var n = r[0], i = r[1];
    return n * n + i * i;
  }, t.inverse = function(r, n) {
    return r[0] = 1 / n[0], r[1] = 1 / n[1], r;
  }, t.areEqual = function(r, n) {
    return r[0] === n[0] && r[1] === n[1];
  }, t.toString = function(r, n) {
    return "[".concat(r[0].toPrecision(n), " ").concat(r[1].toPrecision(n), "}]");
  }, t.normalize = function(r, n) {
    var i = n[0], a = n[1], o = i * i + a * a;
    return o > 0 && (o = 1 / Math.sqrt(o), r[0] = n[0] * o, r[1] = n[1] * o), r;
  };
}(ze || (ze = {})), function(t) {
  function e() {
    var n = [0.1, 0, 0, 0];
    return n[0] = 0, n;
  }
  function r(n, i) {
    return n[0] = i.center[0], n[1] = i.center[1], n[2] = i.center[2], n[3] = i.radius, n;
  }
  t.zero = e, t.clone = function(n) {
    var i = e();
    return i[0] = n[0], i[1] = n[1], i[2] = n[2], i[3] = n[3], i;
  }, t.create = function(n, i, a, o) {
    var s = e();
    return s[0] = n, s[1] = i, s[2] = a, s[3] = o, s;
  }, t.fromSphere = r, t.ofSphere = function(n) {
    return r(e(), n);
  }, t.hasNaN = function(n) {
    return isNaN(n[0]) || isNaN(n[1]) || isNaN(n[2]) || isNaN(n[3]);
  }, t.toArray = function(n, i, a) {
    return i[a + 0] = n[0], i[a + 1] = n[1], i[a + 2] = n[2], i[a + 3] = n[3], i;
  }, t.fromArray = function(n, i, a) {
    return n[0] = i[a + 0], n[1] = i[a + 1], n[2] = i[a + 2], n[3] = i[a + 3], n;
  }, t.toVec3Array = function(n, i, a) {
    i[a + 0] = n[0], i[a + 1] = n[1], i[a + 2] = n[2];
  }, t.fromVec3Array = function(n, i, a) {
    return n[0] = i[a + 0], n[1] = i[a + 1], n[2] = i[a + 2], n[3] = 0, n;
  }, t.copy = function(n, i) {
    return n[0] = i[0], n[1] = i[1], n[2] = i[2], n[3] = i[3], n;
  }, t.set = function(n, i, a, o, s) {
    return n[0] = i, n[1] = a, n[2] = o, n[3] = s, n;
  }, t.add = function(n, i, a) {
    return n[0] = i[0] + a[0], n[1] = i[1] + a[1], n[2] = i[2] + a[2], n[3] = i[3] + a[3], n;
  }, t.distance = function(n, i) {
    var a = i[0] - n[0], o = i[1] - n[1], s = i[2] - n[2], u = i[3] - n[3];
    return Math.sqrt(a * a + o * o + s * s + u * u);
  }, t.scale = function(n, i, a) {
    return n[0] = i[0] * a, n[1] = i[1] * a, n[2] = i[2] * a, n[4] = i[4] * a, n;
  }, t.round = function(n, i) {
    return n[0] = Math.round(i[0]), n[1] = Math.round(i[1]), n[2] = Math.round(i[2]), n[3] = Math.round(i[3]), n;
  }, t.ceil = function(n, i) {
    return n[0] = Math.ceil(i[0]), n[1] = Math.ceil(i[1]), n[2] = Math.ceil(i[2]), n[3] = Math.ceil(i[3]), n;
  }, t.floor = function(n, i) {
    return n[0] = Math.floor(i[0]), n[1] = Math.floor(i[1]), n[2] = Math.floor(i[2]), n[3] = Math.floor(i[3]), n;
  }, t.squaredDistance = function(n, i) {
    var a = i[0] - n[0], o = i[1] - n[1], s = i[2] - n[2], u = i[3] - n[3];
    return a * a + o * o + s * s + u * u;
  }, t.norm = function(n) {
    var i = n[0], a = n[1], o = n[2], s = n[3];
    return Math.sqrt(i * i + a * a + o * o + s * s);
  }, t.squaredNorm = function(n) {
    var i = n[0], a = n[1], o = n[2], s = n[3];
    return i * i + a * a + o * o + s * s;
  }, t.transformMat4 = function(n, i, a) {
    var o = i[0], s = i[1], u = i[2], c = i[3];
    return n[0] = a[0] * o + a[4] * s + a[8] * u + a[12] * c, n[1] = a[1] * o + a[5] * s + a[9] * u + a[13] * c, n[2] = a[2] * o + a[6] * s + a[10] * u + a[14] * c, n[3] = a[3] * o + a[7] * s + a[11] * u + a[15] * c, n;
  }, t.dot = function(n, i) {
    return n[0] * i[0] + n[1] * i[1] + n[2] * i[2] + n[3] * i[3];
  }, t.inverse = function(n, i) {
    return n[0] = 1 / i[0], n[1] = 1 / i[1], n[2] = 1 / i[2], n[3] = 1 / i[3], n;
  }, t.exactEquals = function(n, i) {
    return n[0] === i[0] && n[1] === i[1] && n[2] === i[2] && n[3] === i[3];
  }, t.equals = function(n, i) {
    var a = n[0], o = n[1], s = n[2], u = n[3], c = i[0], l = i[1], d = i[2], f = i[3];
    return Math.abs(a - c) <= Cn * Math.max(1, Math.abs(a), Math.abs(c)) && Math.abs(o - l) <= Cn * Math.max(1, Math.abs(o), Math.abs(l)) && Math.abs(s - d) <= Cn * Math.max(1, Math.abs(s), Math.abs(d)) && Math.abs(u - f) <= Cn * Math.max(1, Math.abs(u), Math.abs(f));
  }, t.toString = function(n, i) {
    return "[".concat(n[0].toPrecision(i), " ").concat(n[1].toPrecision(i), " ").concat(n[2].toPrecision(i), "  ").concat(n[3].toPrecision(i), "]");
  };
}(Ut || (Ut = {})), function(t) {
  function e() {
    var m = [0.1, 0, 0, 0];
    return m[0] = 0, m;
  }
  function r() {
    var m = e();
    return m[3] = 1, m;
  }
  function n(m, p, v) {
    v *= 0.5;
    var g = Math.sin(v);
    return m[0] = g * p[0], m[1] = g * p[1], m[2] = g * p[2], m[3] = Math.cos(v), m;
  }
  function i(m, p, v, g) {
    var y, b, S, _, x, C = p[0], A = p[1], w = p[2], I = p[3], P = v[0], M = v[1], T = v[2], F = v[3];
    return (b = C * P + A * M + w * T + I * F) < 0 && (b = -b, P = -P, M = -M, T = -T, F = -F), 1 - b > 1e-6 ? (y = Math.acos(b), S = Math.sin(y), _ = Math.sin((1 - g) * y) / S, x = Math.sin(g * y) / S) : (_ = 1 - g, x = g), m[0] = _ * C + x * P, m[1] = _ * A + x * M, m[2] = _ * w + x * T, m[3] = _ * I + x * F, m;
  }
  function a(m, p) {
    var v, g = p[0] + p[4] + p[8];
    if (g > 0) v = Math.sqrt(g + 1), m[3] = 0.5 * v, v = 0.5 / v, m[0] = (p[5] - p[7]) * v, m[1] = (p[6] - p[2]) * v, m[2] = (p[1] - p[3]) * v;
    else {
      var y = 0;
      p[4] > p[0] && (y = 1), p[8] > p[3 * y + y] && (y = 2);
      var b = (y + 1) % 3, S = (y + 2) % 3;
      v = Math.sqrt(p[3 * y + y] - p[3 * b + b] - p[3 * S + S] + 1), m[y] = 0.5 * v, v = 0.5 / v, m[3] = (p[3 * b + S] - p[3 * S + b]) * v, m[b] = (p[3 * b + y] + p[3 * y + b]) * v, m[S] = (p[3 * S + y] + p[3 * y + S]) * v;
    }
    return m;
  }
  t.zero = e, t.identity = r, t.setIdentity = function(m) {
    m[0] = 0, m[1] = 0, m[2] = 0, m[3] = 1;
  }, t.hasNaN = function(m) {
    return isNaN(m[0]) || isNaN(m[1]) || isNaN(m[2]) || isNaN(m[3]);
  }, t.create = function(m, p, v, g) {
    var y = r();
    return y[0] = m, y[1] = p, y[2] = v, y[3] = g, y;
  }, t.setAxisAngle = n, t.getAxisAngle = function(m, p) {
    var v = 2 * Math.acos(p[3]), g = Math.sin(v / 2);
    return g !== 0 ? (m[0] = p[0] / g, m[1] = p[1] / g, m[2] = p[2] / g) : (m[0] = 1, m[1] = 0, m[2] = 0), v;
  }, t.multiply = function(m, p, v) {
    var g = p[0], y = p[1], b = p[2], S = p[3], _ = v[0], x = v[1], C = v[2], A = v[3];
    return m[0] = g * A + S * _ + y * C - b * x, m[1] = y * A + S * x + b * _ - g * C, m[2] = b * A + S * C + g * x - y * _, m[3] = S * A - g * _ - y * x - b * C, m;
  }, t.rotateX = function(m, p, v) {
    v *= 0.5;
    var g = p[0], y = p[1], b = p[2], S = p[3], _ = Math.sin(v), x = Math.cos(v);
    return m[0] = g * x + S * _, m[1] = y * x + b * _, m[2] = b * x - y * _, m[3] = S * x - g * _, m;
  }, t.rotateY = function(m, p, v) {
    v *= 0.5;
    var g = p[0], y = p[1], b = p[2], S = p[3], _ = Math.sin(v), x = Math.cos(v);
    return m[0] = g * x - b * _, m[1] = y * x + S * _, m[2] = b * x + g * _, m[3] = S * x - y * _, m;
  }, t.rotateZ = function(m, p, v) {
    v *= 0.5;
    var g = p[0], y = p[1], b = p[2], S = p[3], _ = Math.sin(v), x = Math.cos(v);
    return m[0] = g * x + y * _, m[1] = y * x - g * _, m[2] = b * x + S * _, m[3] = S * x - b * _, m;
  }, t.calculateW = function(m, p) {
    var v = p[0], g = p[1], y = p[2];
    return m[0] = v, m[1] = g, m[2] = y, m[3] = Math.sqrt(Math.abs(1 - v * v - g * g - y * y)), m;
  }, t.slerp = i, t.invert = function(m, p) {
    var v = p[0], g = p[1], y = p[2], b = p[3], S = v * v + g * g + y * y + b * b, _ = S ? 1 / S : 0;
    return m[0] = -v * _, m[1] = -g * _, m[2] = -y * _, m[3] = b * _, m;
  }, t.conjugate = function(m, p) {
    return m[0] = -p[0], m[1] = -p[1], m[2] = -p[2], m[3] = p[3], m;
  }, t.fromMat3 = a;
  var o = [0, 0, 0];
  function s(m, p) {
    var v = p[0], g = p[1], y = p[2], b = p[3], S = v * v + g * g + y * y + b * b;
    return S > 0 && (S = 1 / Math.sqrt(S), m[0] = v * S, m[1] = g * S, m[2] = y * S, m[3] = b * S), m;
  }
  t.fromUnitVec3 = function(m, p, v) {
    var g = E.dot(p, v) + 1;
    return g < Cn ? (g = 0, Math.abs(p[0]) > Math.abs(p[2]) ? E.set(o, -p[1], p[0], 0) : E.set(o, 0, -p[2], p[1])) : E.cross(o, p, v), m[0] = o[0], m[1] = o[1], m[2] = o[2], m[3] = g, s(m, m), m;
  }, t.clone = function(m) {
    var p = e();
    return p[0] = m[0], p[1] = m[1], p[2] = m[2], p[3] = m[3], p;
  }, t.toArray = function(m, p, v) {
    return p[v + 0] = m[0], p[v + 1] = m[1], p[v + 2] = m[2], p[v + 3] = m[3], p;
  }, t.fromArray = function(m, p, v) {
    return m[0] = p[v + 0], m[1] = p[v + 1], m[2] = p[v + 2], m[3] = p[v + 3], m;
  }, t.copy = function(m, p) {
    return m[0] = p[0], m[1] = p[1], m[2] = p[2], m[3] = p[3], m;
  }, t.set = function(m, p, v, g, y) {
    return m[0] = p, m[1] = v, m[2] = g, m[3] = y, m;
  }, t.exactEquals = function(m, p) {
    return m[0] === p[0] && m[1] === p[1] && m[2] === p[2] && m[3] === p[3];
  }, t.equals = function(m, p) {
    var v = m[0], g = m[1], y = m[2], b = m[3], S = p[0], _ = p[1], x = p[2], C = p[3];
    return Math.abs(v - S) <= Cn * Math.max(1, Math.abs(v), Math.abs(S)) && Math.abs(g - _) <= Cn * Math.max(1, Math.abs(g), Math.abs(_)) && Math.abs(y - x) <= Cn * Math.max(1, Math.abs(y), Math.abs(x)) && Math.abs(b - C) <= Cn * Math.max(1, Math.abs(b), Math.abs(C));
  }, t.add = function(m, p, v) {
    return m[0] = p[0] + v[0], m[1] = p[1] + v[1], m[2] = p[2] + v[2], m[3] = p[3] + v[3], m;
  }, t.normalize = s;
  var u = [0, 0, 0], c = [1, 0, 0], l = [0, 1, 0];
  t.rotationTo = function(m, p, v) {
    var g = E.dot(p, v);
    return g < -0.999999 ? (E.cross(u, c, p), E.magnitude(u) < 1e-6 && E.cross(u, l, p), E.normalize(u, u), n(m, u, Math.PI), m) : g > 0.999999 ? (m[0] = 0, m[1] = 0, m[2] = 0, m[3] = 1, m) : (E.cross(u, p, v), m[0] = u[0], m[1] = u[1], m[2] = u[2], m[3] = 1 + g, s(m, m));
  };
  var d = e(), f = e();
  t.sqlerp = function(m, p, v, g, y, b) {
    return i(d, p, y, b), i(f, v, g, b), i(m, d, f, 2 * b * (1 - b)), m;
  };
  var h = [0, 0, 0, 0, 0, 0, 0, 0, 0];
  t.setAxes = function(m, p, v, g) {
    return h[0] = v[0], h[3] = v[1], h[6] = v[2], h[1] = g[0], h[4] = g[1], h[7] = g[2], h[2] = -p[0], h[5] = -p[1], h[8] = -p[2], s(m, a(m, h));
  }, t.toString = function(m, p) {
    return "[".concat(m[0].toPrecision(p), " ").concat(m[1].toPrecision(p), " ").concat(m[2].toPrecision(p), "  ").concat(m[3].toPrecision(p), "]");
  }, t.Identity = r();
}(kn || (kn = {})), function(t) {
  function e(o, s, u) {
    var c = function(v, g, y) {
      for (var b = [], S = 0; S < g.length; S++) b[S] = g[g.length - S - 1];
      var _ = [1];
      for (S = 1; S < v.length; S++) _[S] = v[b[S - 1]];
      return { dimensions: v, axisOrderFastToSlow: b, axisOrderSlowToFast: g, accessDimensions: _, defaultCtor: y || Float64Array };
    }(o, s, u), l = r(c), d = l.get, f = l.set, h = l.add, m = l.dataOffset, p = l.getCoords;
    return { rank: o.length, dimensions: o, axisOrderSlowToFast: s, create: n(c), get: d, set: f, add: h, dataOffset: m, getCoords: p };
  }
  function r(o) {
    var s = o.dimensions, u = o.axisOrderFastToSlow;
    switch (s.length) {
      case 1:
        return { get: function(T, F) {
          return T[F];
        }, set: function(T, F, N) {
          return T[F] = N;
        }, add: function(T, F, N) {
          return T[F] += N;
        }, dataOffset: function(T) {
          return T;
        }, getCoords: function(T, F) {
          return F[0] = T, F;
        } };
      case 2:
        if (u[0] === 0 && u[1] === 1) {
          var c = s[0];
          return { get: function(T, F, N) {
            return T[N * c + F];
          }, set: function(T, F, N, R) {
            return T[N * c + F] = R;
          }, add: function(T, F, N, R) {
            return T[N * c + F] += R;
          }, dataOffset: function(T, F) {
            return F * c + T;
          }, getCoords: function(T, F) {
            return F[0] = T % c, F[1] = Math.floor(T / c), F;
          } };
        }
        if (u[0] === 1 && u[1] === 0) {
          var l = s[1];
          return { get: function(T, F, N) {
            return T[F * l + N];
          }, set: function(T, F, N, R) {
            return T[F * l + N] = R;
          }, add: function(T, F, N, R) {
            return T[F * l + N] += R;
          }, dataOffset: function(T, F) {
            return T * l + F;
          }, getCoords: function(T, F) {
            return F[0] = Math.floor(T / l), F[1] = T % l, F;
          } };
        }
        throw new Error("bad axis order");
      case 3:
        if (u[0] === 0 && u[1] === 1 && u[2] === 2) {
          var d = s[0], f = s[1], h = d * f;
          return { get: function(T, F, N, R) {
            return T[F + N * d + R * h];
          }, set: function(T, F, N, R, L) {
            return T[F + N * d + R * h] = L;
          }, add: function(T, F, N, R, L) {
            return T[F + N * d + R * h] += L;
          }, dataOffset: function(T, F, N) {
            return T + F * d + N * h;
          }, getCoords: function(T, F) {
            var N = Math.floor(T / d);
            return F[0] = T % d, F[1] = N % f, F[2] = Math.floor(N / f), F;
          } };
        }
        if (u[0] === 0 && u[1] === 2 && u[2] === 1) {
          var m = s[0], p = s[2], v = m * p;
          return { get: function(T, F, N, R) {
            return T[F + R * m + N * v];
          }, set: function(T, F, N, R, L) {
            return T[F + R * m + N * v] = L;
          }, add: function(T, F, N, R, L) {
            return T[F + R * m + N * v] += L;
          }, dataOffset: function(T, F, N) {
            return T + N * m + F * v;
          }, getCoords: function(T, F) {
            var N = Math.floor(T / m);
            return F[0] = T % m, F[1] = Math.floor(N / p), F[2] = N % p, F;
          } };
        }
        if (u[0] === 1 && u[1] === 0 && u[2] === 2) {
          var g = s[1], y = s[0], b = g * y;
          return { get: function(T, F, N, R) {
            return T[N + F * g + R * b];
          }, set: function(T, F, N, R, L) {
            return T[N + F * g + R * b] = L;
          }, add: function(T, F, N, R, L) {
            return T[N + F * g + R * b] += L;
          }, dataOffset: function(T, F, N) {
            return F + T * g + N * b;
          }, getCoords: function(T, F) {
            var N = Math.floor(T / g);
            return F[0] = N % y, F[1] = T % g, F[2] = Math.floor(N / y), F;
          } };
        }
        if (u[0] === 1 && u[1] === 2 && u[2] === 0) {
          var S = s[1], _ = s[2], x = S * _;
          return { get: function(T, F, N, R) {
            return T[N + R * S + F * x];
          }, set: function(T, F, N, R, L) {
            return T[N + R * S + F * x] = L;
          }, add: function(T, F, N, R, L) {
            return T[N + R * S + F * x] += L;
          }, dataOffset: function(T, F, N) {
            return F + N * S + T * x;
          }, getCoords: function(T, F) {
            var N = Math.floor(T / S);
            return F[0] = Math.floor(N / _), F[1] = T % S, F[2] = N % _, F;
          } };
        }
        if (u[0] === 2 && u[1] === 0 && u[2] === 1) {
          var C = s[2], A = s[0], w = C * A;
          return { get: function(T, F, N, R) {
            return T[R + F * C + N * w];
          }, set: function(T, F, N, R, L) {
            return T[R + F * C + N * w] = L;
          }, add: function(T, F, N, R, L) {
            return T[R + F * C + N * w] += L;
          }, dataOffset: function(T, F, N) {
            return N + T * C + F * w;
          }, getCoords: function(T, F) {
            var N = Math.floor(T / C);
            return F[0] = N % A, F[1] = Math.floor(N / A), F[2] = T % C, F;
          } };
        }
        if (u[0] === 2 && u[1] === 1 && u[2] === 0) {
          var I = s[2], P = s[1], M = I * P;
          return { get: function(T, F, N, R) {
            return T[R + N * I + F * M];
          }, set: function(T, F, N, R, L) {
            return T[R + N * I + F * M] = L;
          }, add: function(T, F, N, R, L) {
            return T[R + N * I + F * M] += L;
          }, dataOffset: function(T, F, N) {
            return N + F * I + T * M;
          }, getCoords: function(T, F) {
            var N = Math.floor(T / I);
            return F[0] = Math.floor(N / P), F[1] = N % P, F[2] = T % I, F;
          } };
        }
        throw new Error("bad axis order");
      default:
        return { get: function(T) {
          for (var F = [], N = 1; N < arguments.length; N++) F[N - 1] = arguments[N];
          return T[i(o, F)];
        }, set: function(T) {
          for (var F = [], N = 1; N < arguments.length; N++) F[N - 1] = arguments[N];
          return T[i(o, F)] = F[F.length - 1];
        }, add: function(T) {
          for (var F = [], N = 1; N < arguments.length; N++) F[N - 1] = arguments[N];
          return T[i(o, F)] += F[F.length - 1];
        }, dataOffset: function() {
          for (var T = [], F = 0; F < arguments.length; F++) T[F] = arguments[F];
          return i(o, T);
        }, getCoords: function(T, F) {
          return function(N, R, L) {
            for (var V = N.dimensions, U = N.axisOrderFastToSlow, H = V.length, K = R, X = 0; X < H; X++) {
              var Y = V[U[X]];
              L[U[X]] = K % Y, K = Math.floor(K / Y);
            }
            return L[U[H + 1]] = K, L;
          }(o, T, F);
        } };
    }
  }
  function n(o) {
    for (var s = o.dimensions, u = 1, c = 0, l = s.length; c < l; c++) u *= s[c];
    return function(d) {
      return new (d || o.defaultCtor)(u);
    };
  }
  function i(o, s) {
    for (var u = o.accessDimensions, c = o.axisOrderFastToSlow, l = u.length - 1, d = u[l] * s[c[l]], f = l - 1; f >= 0; f--) d = (d + s[c[f]]) * u[f];
    return d;
  }
  function a(o, s) {
    for (var u = [], c = 0; c < o.length; c++) u[c] = o[s[c]];
    return u;
  }
  t.create = function(o, s) {
    return { space: o, data: s };
  }, t.Space = e, t.Data1 = function(o) {
    return o;
  }, t.Vector = function(o, s) {
    return e([o], [0], s);
  }, t.ColumnMajorMatrix = function(o, s, u) {
    return e([o, s], [1, 0], u);
  }, t.RowMajorMatrix = function(o, s, u) {
    return e([o, s], [0, 1], u);
  }, t.toMat4 = function(o, s, u) {
    if (s.rank !== 2) throw new Error("Invalid tensor rank");
    for (var c = Math.min(4, s.dimensions[0]), l = Math.min(4, s.dimensions[1]), d = 0; d < c; d++) for (var f = 0; f < l; f++) he.setValue(o, d, f, s.get(u, d, f));
    return o;
  }, t.toMat3 = function(o, s, u) {
    if (s.rank !== 2) throw new Error("Invalid tensor rank");
    for (var c = Math.min(3, s.dimensions[0]), l = Math.min(3, s.dimensions[1]), d = 0; d < c; d++) for (var f = 0; f < l; f++) Wi.setValue(o, d, f, s.get(u, d, f));
    return o;
  }, t.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;
  }, t.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;
  }, t.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;
  }, t.invertAxisOrder = function(o) {
    for (var s = [], u = 0; u < o.length; u++) s[u] = o[o.length - u - 1];
    return s;
  }, t.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);
    };
  }, t.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);
    };
  };
}(Qn || (Qn = {})), function(t) {
  t.create = function(e) {
    return e;
  }, t.has = function(e, r) {
    return !!(e & r);
  }, t.hasAll = function(e, r) {
    return !!r && (e & r) === r;
  };
}(Ga || (Ga = {})), function(t) {
  t.create = function(i) {
    return i === void 0 && (i = 512), { current: [], offset: 0, capacity: i, chunks: [] };
  }, t.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("");
  }, t.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;
  }, t.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 e = [];
  function r(i, a) {
    a > 0 && n(i, e[a]);
  }
  function n(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++) e[a] = i, i += " ";
  })(), t.newline = function(i) {
    n(i, `
`);
  }, t.whitespace = r, t.whitespace1 = function(i) {
    n(i, " ");
  }, t.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);
  }, t.writeSafe = n, t.writePadLeft = function(i, a, o) {
    a ? (r(i, o - a.length), n(i, a)) : r(i, o);
  }, t.writePadRight = function(i, a, o) {
    if (a) {
      var s = o - a.length;
      n(i, a), r(i, s);
    } else r(i, o);
  }, t.writeInteger = function(i, a) {
    n(i, "" + a);
  }, t.writeIntegerAndSpace = function(i, a) {
    n(i, a + " ");
  }, t.writeIntegerPadLeft = function(i, a, o) {
    var s = "" + a;
    r(i, o - s.length), n(i, s);
  }, t.writeIntegerPadRight = function(i, a, o) {
    var s = "" + a, u = o - s.length;
    n(i, s), r(i, u);
  }, t.writeFloat = function(i, a, o) {
    n(i, "" + Math.round(o * a) / o);
  }, t.writeFloatPadLeft = function(i, a, o, s) {
    var u = "" + Math.round(o * a) / o;
    r(i, s - u.length), n(i, u);
  }, t.writeFloatPadRight = function(i, a, o, s) {
    var u = "" + Math.round(o * a) / o, c = s - u.length;
    n(i, u), r(i, c);
  };
}(Ir || (Ir = {})), function(t) {
  var e = typeof btoa < "u" ? btoa : function(n) {
    return Buffer.from(n).toString("base64");
  }, r = [];
  t.create22 = function() {
    for (var n = +/* @__PURE__ */ new Date() + wi(), i = 0; i < 16; i++) r[i] = String.fromCharCode((n + 255 * Math.random()) % 255 | 0), n = Math.floor(n / 255);
    return e(r.join("")).replace(/\+/g, "-").replace(/\//g, "_").substr(0, 22);
  }, t.createv4 = function() {
    var n = +/* @__PURE__ */ new Date() + wi(), i = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(a) {
      var o = (n + 16 * Math.random()) % 16 | 0;
      return n = Math.floor(n / 16), (a === "x" ? o : 3 & o | 8).toString(16);
    });
    return i;
  }, t.is = function(n) {
    return typeof n == "string";
  };
}(Ki || (Ki = {})), function(t) {
  var e = function() {
    function u() {
      this.size = 0;
    }
    return u.prototype.has = function(c) {
      return !1;
    }, u.prototype.forEach = function(c, l) {
      return l;
    }, u;
  }(), r = function() {
    function u(c) {
      this.idx = c, this.size = 1;
    }
    return u.prototype.has = function(c) {
      return c === this.idx;
    }, u.prototype.forEach = function(c, l) {
      return c(this.idx, l), l;
    }, u;
  }(), n = function() {
    function u(c, l) {
      this.mask = c, this.size = l, this.length = c.length;
    }
    return u.prototype.has = function(c) {
      return c < this.length && !!this.mask[c];
    }, u.prototype._forEach = function(c, l) {
      for (var d = 0; d < this.length; d++) this.mask[d] && c(d, l);
    }, u.prototype.forEach = function(c, l) {
      return this._forEach(c, l), l;
    }, u;
  }(), 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, f = this.flatten(); d < f.length; d++)
        c(f[d], l);
    }, u.prototype.flatten = function() {
      if (this._flat) return this._flat;
      var c = new Int32Array(this.size), l = 0;
      return this.set.forEach(function(d) {
        return c[l++] = d;
      }), function(d) {
        Array.prototype.sort.call(d, kj);
      }(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 n(u, c);
  }
  t.always = function(u) {
    return new i(u);
  }, t.never = new e(), t.ofSet = o, t.singleton = function(u) {
    return new r(u);
  }, t.ofUniqueIndices = function(u) {
    var c = u.length;
    if (c === 0) return new e();
    if (c === 1) return new r(u[0]);
    for (var l = 0, d = 0, f = u; d < f.length; d++)
      (v = f[d]) > l && (l = v);
    if (c === l) return new i(c);
    if (c / l < 1 / 12) {
      for (var h = /* @__PURE__ */ new Set(), m = 0, p = u; m < p.length; m++) {
        var v = p[m];
        h.add(v);
      }
      return new a(h);
    }
    for (var g = new Int8Array(l + 1), y = 0, b = u; y < b.length; y++)
      g[v = b[y]] = 1;
    return new n(g, u.length);
  }, t.ofMask = s, t.hasAny = function(u, c) {
    for (var l = 0, d = c; l < d.length; l++) {
      var f = d[l];
      if (u.has(f)) return !0;
    }
    return !1;
  }, t.complement = function(u, c) {
    var l = 0, d = 0;
    if (c.forEach(function(m) {
      u.has(m) || (l++, m > d && (d = m));
    }), l / d < 1 / 12) {
      var f = /* @__PURE__ */ new Set();
      return c.forEach(function(m) {
        u.has(m) || f.add(m);
      }), o(f);
    }
    var h = new Uint8Array(d + 1);
    return c.forEach(function(m) {
      u.has(m) || (h[m] = 1);
    }), s(h, l);
  };
}(xw || (xw = {})), function(t) {
  t.create = function(e) {
    return { ref: e };
  }, t.set = function(e, r) {
    return e.ref = r, e;
  };
}(wm || (wm = {}));
var Gd, G, Gj = io(0, 2147483647);
function xa() {
  return xa.zero();
}
function ac() {
  return ac.zero();
}
function qe(t) {
  return t;
}
function hr(t, e, r, n) {
  return { label: t, description: r, list: n, type: e };
}
function N0(t, e, r) {
  var n = {};
  for (var i in t) {
    var a = t[i];
    a = qe.saturate(a, e), a = qe.darken(a, -r), n[i] = a;
  }
  return n;
}
(function(t) {
  t.create = function(e, r) {
    return { id: Gj(), version: 0, value: e, metadata: r };
  }, t.withValue = function(e, r) {
    return { id: e.id, version: e.version + 1, value: r, metadata: e.metadata };
  };
})(Gd || (Gd = {})), function(t) {
  function e(r, n) {
    return wm.set(r, Gd.withValue(r.ref, n));
  }
  t.create = function(r, n) {
    return wm.create(Gd.create(r, n));
  }, t.update = e, t.set = function(r, n) {
    return wm.set(r, n);
  }, t.updateIfChanged = function(r, n) {
    return r.ref.value !== n ? e(r, n) : r;
  };
}(G || (G = {})), function(t) {
  function e() {
    var y = [0.1, 0, 0];
    return y[0] = 0, y;
  }
  function r(y, b) {
    var S = b[0], _ = b[1], x = b[2], C = Math.sqrt(_ * _ + x * x), A = (Ua(Math.atan2(x, _)) + 360) % 360;
    return Math.round(1e4 * C) === 0 && (A = Number.NaN), y[0] = A, y[1] = C, y[2] = S, y;
  }
  function n(y, b, S) {
    return y[0] = b[0] - o * S, y[1] = b[1], y[2] = b[2], y;
  }
  t.zero = e, t.create = function(y, b, S) {
    var _ = e();
    return _[0] = y, _[1] = b, _[2] = S, _;
  }, t.fromColor = function(y, b) {
    var S = qe.toRgb(b), _ = function(I, P, M) {
      I = v(I), P = v(P), M = v(M);
      var T = g((0.4124564 * I + 0.3575761 * P + 0.1804375 * M) / s), F = g((0.2126729 * I + 0.7151522 * P + 0.072175 * M) / u), N = g((0.0193339 * I + 0.119192 * P + 0.9503041 * M) / c);
      return [T, F, N];
    }(S[0], S[1], S[2]), x = _[0], C = _[1], A = _[2], w = 116 * C - 16;
    return y[0] = w < 0 ? 0 : w, y[1] = 500 * (x - C), y[2] = 200 * (C - A), y;
  }, t.fromHcl = function(y, b) {
    return ac.toLab(y, b);
  }, t.toColor = function(y) {
    var b = (y[0] + 16) / 116, S = isNaN(y[1]) ? b : b + y[1] / 500, _ = isNaN(y[2]) ? b : b - y[2] / 200;
    b = u * p(b);
    var x = m(3.2404542 * (S = s * p(S)) - 1.5371385 * b - 0.4985314 * (_ = c * p(_))), C = m(-0.969266 * S + 1.8760108 * b + 0.041556 * _), A = m(0.0556434 * S - 0.2040259 * b + 1.0572252 * _);
    return qe.fromRgb(Math.round(_o(x, 0, 255)), Math.round(_o(C, 0, 255)), Math.round(_o(A, 0, 255)));
  }, t.toHcl = r, t.copy = function(y, b) {
    return y[0] = b[0], y[1] = b[1], y[2] = b[2], y;
  }, t.darken = n, t.lighten = function(y, b, S) {
    return n(y, b, -S);
  };
  var i = [0, 0, 0];
  function a(y, b, S) {
    return r(i, b), ac.toLab(y, ac.saturate(i, i, S));
  }
  t.saturate = a, t.desaturate = function(y, b, S) {
    return a(y, b, -S);
  };
  var o = 18, s = 0.95047, u = 1, c = 1.08883, l = 0.137931034, d = 0.206896552, f = 0.12841855, h = 8856452e-9;
  function m(y) {
    return 255 * (y <= 304e-5 ? 12.92 * y : 1.055 * Math.pow(y, 1 / 2.4) - 0.055);
  }
  function p(y) {
    return y > d ? y * y * y : f * (y - l);
  }
  function v(y) {
    return (y /= 255) <= 0.04045 ? y / 12.92 : Math.pow((y + 0.055) / 1.055, 2.4);
  }
  function g(y) {
    return y > h ? Math.pow(y, 1 / 3) : y / f + l;
  }
}(xa || (xa = {})), function(t) {
  function e() {
    var c = [0.1, 0, 0];
    return c[0] = 0, c;
  }
  t.zero = e, t.create = function(c, l, d) {
    var f = e();
    return f[0] = c, f[1] = l, f[2] = d, f;
  };
  var r = [0, 0, 0];
  t.fromColor = function(c, l) {
    return xa.toHcl(c, xa.fromColor(r, l));
  }, t.fromLab = function(c, l) {
    return xa.toHcl(c, l);
  };
  var n = [0, 0, 0];
  function i(c, l) {
    var d = l[0], f = l[1], h = l[2];
    return isNaN(d) && (d = 0), d = qn(d), c[0] = h, c[1] = Math.cos(d) * f, c[2] = Math.sin(d) * f, 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;
  }
  t.toColor = function(c) {
    return xa.toColor(i(n, c));
  }, t.toLab = i, t.copy = function(c, l) {
    return c[0] = l[0], c[1] = l[1], c[2] = l[2], c;
  }, t.saturate = a, t.desaturate = function(c, l, d) {
    return a(c, l, -d);
  };
  var o = [0, 0, 0];
  function s(c, l, d) {
    return i(o, l), xa.toHcl(c, xa.darken(o, o, d));
  }
  t.darken = s, t.lighten = function(c, l, d) {
    return s(c, l, -d);
  };
  var u = 18;
}(ac || (ac = {})), function(t) {
  function e(c, l, d) {
    return c << 16 | l << 8 | d;
  }
  function r(c, l, d) {
    return 255 * c << 16 | 255 * l << 8 | 255 * d;
  }
  t.toStyle = function(c) {
    return "rgb(".concat(c >> 16 & 255, ", ").concat(c >> 8 & 255, ", ").concat(255 & c, ")");
  }, t.toHexString = function(c) {
    return "0x" + ("000000" + c.toString(16)).slice(-6);
  }, t.toRgbString = function(c) {
    return "RGB: ".concat(t.toRgb(c).join(", "));
  }, t.toRgb = function(c) {
    return [c >> 16 & 255, c >> 8 & 255, 255 & c];
  }, t.toRgbNormalized = function(c) {
    return [(c >> 16 & 255) / 255, (c >> 8 & 255) / 255, (255 & c) / 255];
  }, t.fromRgb = e, t.fromNormalizedRgb = r, t.fromArray = function(c, l) {
    return e(c[l], c[l + 1], c[l + 2]);
  }, t.fromNormalizedArray = function(c, l) {
    return r(c[l], c[l + 1], c[l + 2]);
  }, t.toArray = function(c, l, d) {
    return l[d] = c >> 16 & 255, l[d + 1] = c >> 8 & 255, l[d + 2] = 255 & c, l;
  }, t.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;
  }, t.toVec3 = function(c, l) {
    return c[0] = l >> 16 & 255, c[1] = l >> 8 & 255, c[2] = 255 & l, c;
  }, t.toVec3Normalized = function(c, l) {
    return c[0] = (l >> 16 & 255) / 255, c[1] = (l >> 8 & 255) / 255, c[2] = (255 & l) / 255, c;
  }, t.interpolate = function(c, l, d) {
    var f = c >> 16 & 255, h = c >> 8 & 255, m = 255 & c;
    return f + ((l >> 16 & 255) - f) * d << 16 | h + ((l >> 8 & 255) - h) * d << 8 | m + ((255 & l) - m) * d;
  };
  var n = [0, 0, 0];
  function i(c, l) {
    return ac.fromColor(n, c), ac.toColor(ac.saturate(n, n, l));
  }
  t.saturate = i, t.desaturate = function(c, l) {
    return i(c, -l);
  };
  var a = [0, 0, 0];
  function o(c, l) {
    return xa.fromColor(a, c), xa.toColor(xa.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;
  }
  t.darken = o, t.lighten = function(c, l) {
    return o(c, -l);
  }, t.sRGBToLinear = function(c) {
    return r(s((c >> 16 & 255) / 255), s((c >> 8 & 255) / 255), s((255 & c) / 255));
  }, t.linearToSRGB = function(c) {
    return r(u((c >> 16 & 255) / 255), u((c >> 8 & 255) / 255), u((255 & c) / 255));
  };
}(qe || (qe = {}));
var zj = function(t) {
  return t.toUpperCase();
};
function R9(t) {
  return t.toLowerCase().replace(/^\w|\s\w/g, zj);
}
function mc(t) {
  return R9(function(e, r) {
    return r === void 0 && (r = " "), e.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g, "$1".concat(r, "$2"));
  }(function(e) {
    return e.replace(/_/g, " ");
  }(function(e) {
    return e.replace(/-/g, " ");
  }(t))));
}
function _i(t, e, r, n) {
  var i = n.length;
  if (i > r - e) return !1;
  for (var a = 0; a < i; a++) if (t.charCodeAt(e + a) !== n.charCodeAt(a)) return !1;
  return !0;
}
function O9(t) {
  return t.replace(/<\/?[^>]+>/g, "");
}
var Le, Uo = { "orange-red": hr("Orange-Red", "sequential", "Orange-Red, sequential color scheme from ColorBrewer 2.0", [16775148, 16705736, 16635038, 16628612, 16551257, 15689032, 14102559, 11730944, 8323072]), "purple-blue": hr("Purple-Blue", "sequential", "Purple-Blue, sequential color scheme from ColorBrewer 2.0", [16775163, 15525874, 13685222, 10927579, 7645647, 3576e3, 356528, 285325, 145496]), "blue-purple": hr("Blue-Purple", "sequential", "Blue-Purple, sequential color scheme from ColorBrewer 2.0", [16252157, 14740724, 12571622, 10403034, 9213638, 9202609, 8929693, 8458108, 5046347]), oranges: hr("Oranges", "sequential", "", [16774635, 16705230, 16634018, 16625259, 16616764, 15821075, 14239745, 10892803, 8333060]), "blue-green": hr("Blue-Green", "sequential", "", [16252157, 15070713, 13429990, 10082505, 6734500, 4304502, 2329413, 27948, 17435]), "yellow-orange-brown": hr("Yellow-Orange-Brown", "sequential", "", [16777189, 16775100, 16704401, 16696399, 16685353, 15495188, 13388802, 10040324, 6694150]), "yellow-green": hr("Yellow-Green", "sequential", "", [16777189, 16252089, 14282915, 11394446, 7915129, 4303709, 2327619, 26679, 17705]), reds: hr("Reds", "sequential", "", [16774640, 16703698, 16563105, 16552562, 16476746, 15678252, 13309981, 10817301, 6750221]), "red-purple": hr("Red-Purple", "sequential", "", [16775155, 16638173, 16565696, 16424885, 16214177, 14496919, 11403646, 7995767, 4784234]), greens: hr("Greens", "sequential", "", [16252149, 15070688, 13101504, 10607003, 7652470, 4303709, 2329413, 27948, 17435]), "yellow-green-blue": hr("Yellow-Green-Blue", "sequential", "", [16777177, 15595697, 13101492, 8375739, 4306628, 1937856, 2252456, 2438292, 531800]), purples: hr("Purples", "sequential", "", [16579581, 15724021, 14342891, 12369372, 10394312, 8420794, 6967715, 5515151, 4128893]), "green-blue": hr("Green-Blue", "sequential", "", [16252144, 14742491, 13429701, 11066805, 8113348, 5157843, 2854078, 551084, 540801]), greys: hr("Greys", "sequential", "", [16777215, 15790320, 14277081, 12434877, 9868950, 7566195, 5395026, 2434341, 0]), "yellow-orange-red": hr("Yellow-Orange-Red", "sequential", "", [16777164, 16772512, 16701814, 16691788, 16616764, 16535082, 14883356, 12386342, 8388646]), "purple-red": hr("Purple-Red", "sequential", "", [16250105, 15196655, 13941210, 13210823, 14640560, 15149450, 13505110, 9961539, 6750239]), blues: hr("Blues", "sequential", "", [16251903, 14609399, 13032431, 10406625, 7057110, 4362950, 2191797, 545180, 536683]), "purple-blue-green": hr("Purple-Blue-Green", "sequential", "", [16775163, 15524592, 13685222, 10927579, 6793679, 3576e3, 164234, 93273, 83510]), spectral: hr("Spectral", "diverging", "", [10355010, 13975119, 16018755, 16625249, 16703627, 16777151, 15136152, 11263396, 6734501, 3311805, 6180770]), "red-yellow-green": hr("Red-Yellow-Green", "diverging", "", [10813478, 14102567, 16018755, 16625249, 16703627, 16777151, 14282635, 10934634, 6733155, 1742928, 26679]), "red-blue": hr("Red-Blue", "diverging", "", [6750239, 11671595, 14049357, 16033154, 16636871, 16250871, 13755888, 9618910, 4428739, 2188972, 340065]), "pink-yellow-green": hr("Pink-Yellow-Green", "diverging", "", [9306450, 12917629, 14579630, 15840986, 16638191, 16250871, 15136208, 12116358, 8371265, 5083681, 2581529]), "purple-green": hr("Purple-Green", "diverging", "", [4194379, 7744131, 10055851, 12756431, 15193320, 16250871, 14282963, 10935200, 5942881, 1800247, 17435]), "red-yellow-blue": hr("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": hr("Brown-White-Green", "diverging", "", [5517317, 9195786, 12550445, 14664317, 16181443, 16119285, 13101797, 8441281, 3512207, 91742, 15408]), "red-grey": hr("Red-Grey", "diverging", "", [6750239, 11671595, 14049357, 16033154, 16636871, 16777215, 14737632, 12237498, 8882055, 5066061, 1710618]), "orange-purple": hr("Orange-Purple", "diverging", "", [8338184, 11753478, 14713364, 16627811, 16703670, 16250871, 14211819, 11709394, 8418220, 5515144, 2949195]), "set-2": hr("Set-2", "qualitative", "", [6734501, 16551266, 9281739, 15174339, 10934356, 16767279, 15058068, 11776947]), accent: hr("Accent", "qualitative", "", [8374655, 12496596, 16629894, 16777113, 3697840, 15729279, 12540695, 6710886]), "set-1": hr("Set-1", "qualitative", "", [14948892, 3636920, 5091146, 9981603, 16744192, 16777011, 10901032, 16220607, 10066329]), "set-3": hr("Set-3", "qualitative", "", [9294791, 16777139, 12499674, 16482418, 8434131, 16626786, 11787881, 16567781, 14277081, 12353725, 13429701, 16772463]), "dark-2": hr("Dark-2", "qualitative", "", [1810039, 14245634, 7696563, 15149450, 6727198, 15117058, 10909213, 6710886]), paired: hr("Paired", "qualitative", "", [10931939, 2062516, 11722634, 3383340, 16489113, 14883356, 16629615, 16744192, 13284054, 6962586, 16777113, 11622696]), "pastel-2": hr("Pastel-2", "qualitative", "", [11789005, 16633260, 13358568, 16042724, 15136201, 16773806, 15852236, 13421772]), "pastel-1": hr("Pastel-1", "qualitative", "", [16495790, 11783651, 13429701, 14601188, 16701862, 16777164, 15063229, 16636652, 15921906]), "many-distinct": hr("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: hr("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: hr("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: hr("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: hr("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: hr("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: hr("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: hr("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: hr("Rainbow", "sequential", "", [3367393, 3516485, 16383744, 15501073, 12526114]), "red-white-blue": hr("Red-White-Blue", "diverging", "", [12526114, 16777215, 3367393]) }, Cw = Object.keys(Uo).map(function(t) {
  return [t, Uo[t].label, R9(Uo[t].type)];
});
function Cl(t) {
  return t in Uo ? Uo[t] : (console.warn("unknown color list named '".concat(t, "'")), Uo["red-yellow-blue"]);
}
function zu(t) {
  return { kind: "table-legend", table: t };
}
function $v(t, e, r) {
  return t[e] - t[r];
}
function u0(t, e, r) {
  var n = t[e];
  t[e] = t[r], t[r] = n;
}
function aN(t, e, r, n) {
  var i = r + n >> 1;
  return e(t, r, n) > 0 ? e(t, r, i) > 0 ? e(t, i, n) > 0 ? i : n : r : e(t, n, i) > 0 ? e(t, i, r) > 0 ? i : r : n;
}
function Vj(t, e, r) {
  var n = t.cmp, i = t.swap, a = t.data, o = t.parts, s = e + 1, u = r;
  for (i(a, e, aN(a, n, e, r)); n(a, u, e) > 0; ) --u;
  for (var c = e + 1; c <= u; c++) {
    var l = n(a, c, e);
    if (l > 0) {
      for (i(a, c, u), --u; n(a, u, e) > 0; ) --u;
      c--;
    } else l === 0 && (i(a, c, s), s++);
  }
  for (c = e; c < s; c++) i(a, c, e + u - c);
  o[0] = u - s + e + 1, o[1] = u;
}
function Uj(t, e, r) {
  for (var n = t.data, i = t.cmp, a = t.swap, o = e + 1; o <= r; o++) for (var s = o - 1; s >= e && i(n, s, s + 1) > 0; ) a(n, s, s + 1), s -= 1;
}
function y3(t, e, r) {
  for (var n = t.parts; e < r; ) {
    if (r - e < 16) return void Uj(t, e, r);
    Vj(t, e, r);
    var i = n[0], a = n[1];
    i - e < r - a ? (y3(t, e, i - 1), e = a + 1) : (y3(t, a + 1, r), r = i - 1);
  }
}
function Hj(t, e, r, n) {
  var i = r + 1, a = n;
  u0(t, r, aN(t, $v, r, n));
  for (var o = t[r]; t[a] > o; ) --a;
  for (var s = r + 1; s <= a; s++) {
    var u = t[s];
    if (u > o) {
      for (u0(t, s, a), --a; t[a] > o; ) --a;
      s--;
    } else u === o && (u0(t, s, i), ++i);
  }
  for (s = r; s < i; s++) u0(t, s, r + a - s);
  e[0] = a - i + r + 1, e[1] = a;
}
function qj(t, e, r) {
  for (var n = e + 1; n <= r; n++) {
    for (var i = t[n], a = n - 1; a >= e && t[a] > i; ) t[a + 1] = t[a], a -= 1;
    t[a + 1] = i;
  }
}
function b_(t, e, r, n) {
  for (; r < n; ) {
    if (n - r < 16) return void qj(t, r, n);
    Hj(t, e, r, n);
    var i = e[0], a = e[1];
    i - r < n - a ? (b_(t, e, r, i - 1), r = a + 1) : (b_(t, e, a + 1, n), n = i - 1);
  }
}
function Ru(t, e) {
  return e === void 0 && (e = $v), function(r, n, i, a) {
    return a === void 0 && (a = $v), a === $v ? b_(r, [0, 0], n, i - 1) : y3({ data: r, cmp: a, swap: u0, parts: [0, 0] }, n, i - 1), r;
  }(t, 0, t.length, e);
}
function oN(t, e, r, n, i) {
  return y3({ data: t, cmp: n, swap: i, parts: [0, 0] }, e, r - 1), t;
}
function Kj(t, e, r) {
  return t[e].key < t[r].key ? -1 : 1;
}
function B6(t, e, r) {
  var n = r && r.start || 0, i = r && r.end || t.length;
  if (i - n <= 0) throw new Error("Can only bucket non-empty collections.");
  return function(a, o, s, u, c) {
    for (var l = /* @__PURE__ */ new Map(), d = [], f = o(a[0]), h = !0, m = u; m < c; m++) {
      var p = o(a[m]);
      if (l.has(p)) l.get(p).count++, f !== p && (h = !1);
      else {
        var v = { key: p, count: 1, offset: m };
        l.set(p, v), d[d.length] = v;
      }
      f = p;
    }
    var g = new Int32Array(d.length + 1);
    g[d.length] = c;
    var y = !0;
    if (s) {
      m = 1;
      for (var b = d.length; m < b; m++) if (d[m - 1].key > d[m].key) {
        y = !1;
        break;
      }
    }
    if (h && y) {
      for (m = 0; m < d.length; m++) g[m] = d[m].offset;
      return g;
    }
    s && !y && oN(d, 0, d.length, Kj, u0);
    var S = 0;
    for (m = 0; m < d.length; m++) {
      var _ = d[m];
      _.offset = S, S += _.count;
    }
    var x = new Int32Array(c - u);
    for (m = u; m < c; m++) p = o(a[m]), x[(v = l.get(p)).offset++] = a[m];
    for (m = 0, b = x.length; m < b; m++) a[m + u] = x[m];
    for (g[0] = u, m = 1; m < d.length; m++) g[m] = d[m - 1].offset + u;
    return g;
  }(t, e, !(!r || !r.sort), n, i);
}
Cw.filter(function(t) {
  return Uo[t[0]].type === "diverging" || Uo[t[0]].type === "sequential";
}), Cw.filter(function(t) {
  return Uo[t[0]].type === "qualitative";
}), function(t) {
  function e(n) {
    var i = n.growBy * n.elementSize;
    n.currentSize = i, n.currentIndex = 0, n.currentChunk = new n.ctor(i), n.allocatedSize += i, n.chunks[n.chunks.length] = n.currentChunk;
  }
  function r(n, i) {
    var a = n.ctor, o = n.chunks, s = n.currentIndex;
    if (!o.length) return new a(0);
    if (o.length === 1 && (i || s === n.allocatedSize)) return o[0];
    for (var u = 0, c = 0, l = o.length - 1; c < l; c++) u += o[c].length;
    var d = new a(u += n.currentIndex), f = 0;
    if (d.buffer) for (c = 0, l = o.length - 1; c < l; c++) d.set(o[c], f), f += o[c].length;
    else for (c = 0, l = o.length - 1; c < l; c++) {
      for (var h = o[c], m = 0, p = h.length; m < p; m++) d[f + m] = h[m];
      f += h.length;
    }
    var v = o[o.length - 1];
    if (d.buffer && s >= n.currentSize) d.set(v, f);
    else for (m = 0, p = v.length; m < p; m++) d[f + m] = v[m];
    return d;
  }
  t.is = function(n) {
    return n.creator && n.chunkSize;
  }, t.add4 = function(n, i, a, o, s) {
    n.currentIndex >= n.currentSize && e(n);
    var u = n.currentChunk, c = n.currentIndex;
    return u[c] = i, u[c + 1] = a, u[c + 2] = o, u[c + 3] = s, n.currentIndex += 4, n.elementCount++;
  }, t.add3 = function(n, i, a, o) {
    n.currentIndex >= n.currentSize && e(n);
    var s = n.currentChunk, u = n.currentIndex;
    return s[u] = i, s[u + 1] = a, s[u + 2] = o, n.currentIndex += 3, n.elementCount++;
  }, t.add2 = function(n, i, a) {
    n.currentIndex >= n.currentSize && e(n);
    var o = n.currentChunk, s = n.currentIndex;
    return o[s] = i, o[s + 1] = a, n.currentIndex += 2, n.elementCount++;
  }, t.add = function(n, i) {
    return n.currentIndex >= n.currentSize && e(n), n.currentChunk[n.currentIndex] = i, n.currentIndex += 1, n.elementCount++;
  }, t.addRepeat = function(n, i, a) {
    for (var o = 0; o < i; o++) n.currentIndex >= n.currentSize && e(n), n.currentChunk[n.currentIndex++] = a, n.elementCount++;
    return n.elementCount;
  }, t.addMany = function(n, i) {
    for (var a = n.elementSize, o = 0, s = i.length; o < s; o += a) {
      n.currentIndex >= n.currentSize && e(n);
      for (var u = n.currentChunk, c = 0; c < a; c++) u[n.currentIndex++] = i[o + c];
      n.elementCount++;
    }
    return n.elementCount;
  }, t.compact = function(n, i) {
    return i === void 0 && (i = !1), r(n, i);
  }, t._compact = r, t.create = function(n, i, a, o) {
    var s = { ctor: n, 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 n(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;
  };
}(Le || (Le = {}));
var se, Hr, __, Ei, Xj = function() {
  function t(e, r) {
    this.getHash = e, this.areEqual = r, this.id = 0, this.byHash = /* @__PURE__ */ new Map(), this.groups = [];
  }
  return t.prototype.createGroup = function(e, r) {
    var n = this.id++, i = [e];
    return this.groups[n] = i, { id: n, keys: i, value: r };
  }, t.prototype.add = function(e, r) {
    var n = this.getHash(r);
    if (this.byHash.has(n)) {
      for (var i = this.byHash.get(n), a = 0, o = i.length; a < o; a++) {
        var s = i[a];
        if (this.areEqual(r, s.value)) return s.keys[s.keys.length] = e, s.value;
      }
      var u = this.createGroup(e, r);
      return i[i.length] = u, u.value;
    }
    return u = this.createGroup(e, r), this.byHash.set(n, [u]), u.value;
  }, t;
}();
function sN(t) {
  var e = t ^ t >> 4;
  return e = (3735928559 ^ e) + (e << 5), e ^= e >> 11;
}
function Wp(t, e) {
  var r = 23;
  return r = 31 * (r = 31 * r + t | 0) + e | 0, r = (3735928559 ^ (r ^= r >> 4)) + (r << 5), r ^= r >> 11;
}
function x_(t) {
  for (var e = 0, r = 0, n = t.length; r < n; r++) e = (e << 5) - e + t.charCodeAt(r++) | 0;
  return e;
}
function iu(t, e) {
  return (t + e) * (t + e + 1) / 2 + e;
}
function b3(t, e) {
  return t < e ? iu(t, e) : iu(e, t);
}
function ro(t) {
  for (var e = 2166136261, r = 0, n = t.length; r < n; ++r) e ^= t[r], e += (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
  return e >>> 0;
}
function _3(t, e) {
  return { start: e && e.start !== void 0 ? Math.max(Math.min(e.start, t - 1), 0) : 0, end: e && e.end !== void 0 ? Math.min(e.end, t) : t };
}
function f2(t, e) {
  var r = e && e.array !== void 0 ? e.array : Array, n = _3(t, e), i = n.start, a = n.end;
  return { array: new r(a - i), start: i, end: a };
}
function Sa(t, e, r) {
  var n = f2(t, r);
  return function(i, a, o) {
    for (var s = 0, u = a.length; s < u; s++) a[s] = i(o + s);
    return a;
  }(e, n.array, n.start);
}
function L9(t) {
  return !!t.buffer && typeof t.byteLength == "number" && typeof t.BYTES_PER_ELEMENT == "number";
}
function x3(t, e) {
  var r = t.constructor, n = t.buffer, i = t.length, a = t.byteOffset, o = t.BYTES_PER_ELEMENT, s = _3(i, e), u = s.start, c = s.end;
  return u === 0 && c === i ? t : new r(n, a + o * u, Math.min(i, c - u));
}
function e0(t, e, r) {
  for (; e < r && t.charCodeAt(e) === 32; ) e++;
  return Zd(t, e, r);
}
function Zd(t, e, r) {
  var n = e, i = 0, a = 1;
  for (t.charCodeAt(n) === 45 ? (a = -1, ++n) : t.charCodeAt(n) === 43 && ++n; n < r; n++) {
    var o = t.charCodeAt(n) - 48;
    if (o > 9 || o < 0) return a * i | 0;
    i = 10 * i + o | 0;
  }
  return a * i;
}
function Aw(t, e, r, n) {
  return e.charCodeAt(r) === 43 && r++, t * Math.pow(10, Zd(e, r, n));
}
function p0(t, e, r) {
  var n = e, i = 1, a = 0, o = 0, s = 1;
  for (t.charCodeAt(n) === 45 ? (i = -1, ++n) : t.charCodeAt(n) === 43 && ++n; n < r; ) {
    var u = t.charCodeAt(n) - 48;
    if (!(u >= 0 && u < 10)) {
      if (u === -2) {
        for (++n; n < r; ) {
          if (!((u = t.charCodeAt(n) - 48) >= 0 && u < 10)) return u === 53 || u === 21 ? Aw(i * (a + o / s), t, n + 1, r) : i * (a + o / s);
          o = 10 * o + u, s *= 10, ++n;
        }
        return i * (a + o / s);
      }
      if (u === 53 || u === 21) return Aw(i * a, t, n + 1, r);
      break;
    }
    a = 10 * a + u, ++n;
  }
  return i * a;
}
function ww(t, e, r, n) {
  return { schema: r, __array: void 0, isDefined: n === 0, rowCount: e, value: function(i) {
    return t;
  }, valueKind: function(i) {
    return n;
  }, toArray: function(i) {
    for (var a = f2(e, i).array, o = 0, s = a.length; o < s; o++) a[o] = t;
    return a;
  }, areValuesEqual: function(i, a) {
    return !0;
  } };
}
function Ng(t) {
  var e = t.value, r = t.valueKind, n = t.areValuesEqual, i = t.rowCount;
  return { schema: t.schema, __array: void 0, isDefined: !0, rowCount: i, value: e, valueKind: r || function(a) {
    return 0;
  }, toArray: function(a) {
    for (var o = f2(i, a), s = o.array, u = o.start, c = 0, l = s.length; c < l; c++) s[c] = e(c + u);
    return s;
  }, areValuesEqual: n || function(a, o) {
    return e(a) === e(o);
  } };
}
function ol(t) {
  var e = t.array, r = t.schema, n = t.valueKind, i = e.length, a = r.valueType === "str" ? function(s) {
    var u = e[s];
    return typeof u == "string" ? u : "" + u;
  } : function(s) {
    return e[s];
  }, o = L9(e);
  return { schema: r, __array: e, isDefined: !0, rowCount: i, value: a, valueKind: n || function(s) {
    return 0;
  }, toArray: r.valueType === "str" ? function(s) {
    for (var u = _3(i, s), c = u.start, l = u.end, d = new (s && s.array !== void 0 ? s.array : e.constructor)(l - c), f = 0, h = l - c; f < h; f++) {
      var m = e[c + f];
      d[f] = typeof m == "string" ? m : "" + m;
    }
    return d;
  } : o ? function(s) {
    return x3(e, s);
  } : function(s) {
    var u = _3(i, s), c = u.start, l = u.end;
    if (c === 0 && l === e.length) return e;
    for (var d = new (s && s.array !== void 0 ? s.array : e.constructor)(l - c), f = 0, h = l - c; f < h; f++) d[f] = e[c + f];
    return d;
  }, areValuesEqual: function(s, u) {
    return e[s] === e[u];
  } };
}
function Yj(t, e, r) {
  return t.isDefined ? e === 0 && r === t.rowCount ? t : t.__array && L9(t.__array) ? function(n, i, a) {
    var o = x3(n.__array, { start: i, end: a }), s = n.valueKind;
    return ol({ array: o, schema: n.schema, valueKind: function(u) {
      return s(i + u);
    } });
  }(t, e, r) : function(n, i, a) {
    var o = n.value, s = n.valueKind, u = n.areValuesEqual, c = i === 0 ? o : function(d) {
      return o(d + i);
    }, l = a - i;
    return { schema: n.schema, __array: void 0, isDefined: n.isDefined, rowCount: l, value: c, valueKind: i === 0 ? s : function(d) {
      return s(d + i);
    }, toArray: function(d) {
      for (var f = f2(l, d).array, h = 0, m = f.length; h < m; h++) f[h] = o(h + i);
      return f;
    }, areValuesEqual: i === 0 ? u : function(d, f) {
      return u(d + i, f + i);
    } };
  }(t, e, r) : se.Undefined(r - e, t.schema);
}
function Wj(t, e, r) {
  return t.rowCount === 0 || r && function(n, i) {
    if (n.length !== i) return !1;
    for (var a = 0, o = n.length; a < o; a++) if (n[a] !== a) return !1;
    return !0;
  }(e, t.rowCount) ? t : t.__array && typeof t.value(0) == typeof t.__array[0] ? function(n, i) {
    for (var a = n.__array, o = new a.constructor(i.length), s = 0, u = i.length; s < u; s++) o[s] = a[i[s]];
    var c = n.valueKind;
    return ol({ array: o, schema: n.schema, valueKind: function(l) {
      return c(i[l]);
    } });
  }(t, e) : function(n, i) {
    var a = n.value, o = n.valueKind, s = n.areValuesEqual, u = function(l) {
      return a(i[l]);
    }, c = i.length;
    return { schema: n.schema, __array: void 0, isDefined: n.isDefined, rowCount: c, value: u, valueKind: function(l) {
      return o(i[l]);
    }, toArray: function(l) {
      for (var d = f2(c, l).array, f = 0, h = d.length; f < h; f++) d[f] = a(i[f]);
      return d;
    }, areValuesEqual: function(l, d) {
      return s(i[l], i[d]);
    } };
  }(t, e);
}
function k9(t) {
  if (Array.from) return Array.from(t);
  for (var e = []; ; ) {
    var r = t.next(), n = r.done, i = r.value;
    if (n) break;
    e[e.length] = i;
  }
  return e;
}
function S_(t, e, r) {
  for (var n = e - t + 1, i = new Int32Array(n), a = 0; a < n; a++) i[a] = a + t;
  return i;
}
function jj(t, e) {
  for (var r = new (function(a) {
    var o = a.constructor;
    if (!o) throw new Error("data does not define a constructor and it should");
    return o;
  }(t))(e.length), n = 0, i = e.length; n < i; n++) r[n] = t[e[n]];
  return r;
}
(function(t) {
  var e;
  function r(i, a) {
    return ww(a.T, i, a, 1);
  }
  function n(i) {
    return Ng(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(Qn.Vector(o, s["@type"] === "int" ? Int32Array : Float64Array), s);
    }, i.Matrix = function(o, s, u) {
      return u === void 0 && (u = i.float), a(Qn.ColumnMajorMatrix(o, s, u["@type"] === "int" ? Int32Array : Float64Array), u);
    }, i.Aliased = function(o, s) {
      return s !== void 0 ? O(O({}, 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" };
    };
  })(e = t.Schema || (t.Schema = {})), t.is = function(i) {
    return !!i && !!i.schema && !!i.value;
  }, t.Undefined = r, t.ofConst = function(i, a, o) {
    return ww(i, a, o, 0);
  }, t.ofLambda = n, t.range = function(i, a) {
    return n({ value: function(o) {
      return o + i;
    }, rowCount: Math.max(a - i + 1, 0), schema: e.int });
  }, t.ofArray = function(i) {
    return ol(i);
  }, t.ofIntArray = function(i) {
    return ol({ array: i, schema: e.int });
  }, t.ofFloatArray = function(i) {
    return ol({ array: i, schema: e.float });
  }, t.ofStringArray = function(i) {
    return ol({ array: i, schema: e.str });
  }, t.ofStringAliasArray = function(i) {
    return ol({ array: i, schema: e.Aliased(e.str) });
  }, t.ofStringListArray = function(i, a) {
    return a === void 0 && (a = ","), ol({ array: i, schema: e.List(a, function(o) {
      return o;
    }) });
  }, t.ofIntTokens = function(i) {
    var a = i.count, o = i.data, s = i.indices;
    return Ng({ value: function(u) {
      return Zd(o, s[2 * u], s[2 * u + 1]) || 0;
    }, rowCount: a, schema: e.int });
  }, t.ofFloatTokens = function(i) {
    var a = i.count, o = i.data, s = i.indices;
    return Ng({ value: function(u) {
      return p0(o, s[2 * u], s[2 * u + 1]) || 0;
    }, rowCount: a, schema: e.float });
  }, t.ofStringTokens = function(i) {
    var a = i.count, o = i.data, s = i.indices;
    return Ng({ value: function(u) {
      var c = o.substring(s[2 * u], s[2 * u + 1]);
      return c === "." || c === "?" ? "" : c;
    }, rowCount: a, schema: e.str });
  }, t.window = function(i, a, o) {
    return Yj(i, a, o);
  }, t.view = function(i, a, o) {
    return o === void 0 && (o = !0), Wj(i, a, o);
  }, t.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);
  }, t.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);
  }, t.mapToArray = function(i, a, o) {
    return function(s, u, c) {
      for (var l = new c(s.rowCount), d = 0, f = s.rowCount; d < f; d++) l[d] = u(s.value(d));
      return l;
    }(i, a, o || Array);
  }, t.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, f = 0, h = u.rowCount; f < h; f++) if (l[f] !== d[f]) return !1;
        return !0;
      }(o, s) : function(u, c) {
        for (var l = u.value, d = c.value, f = 0, h = u.rowCount; f < h; f++) if (l(f) !== d(f)) return !1;
        return !0;
      }(o, s));
    }(i, a);
  }, t.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);
  }, t.asArrayColumn = function(i, a) {
    return i.__array ? i : i.isDefined ? ol({ array: i.toArray({ array: a }), schema: i.schema, valueKind: i.valueKind }) : r(i.rowCount, i.schema);
  }, t.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);
    }
  }, t.isIdentity = function(i) {
    for (var a = 0, o = i.rowCount; a < o; a++) if (a !== i.value(a)) return !1;
    return !0;
  };
})(se || (se = {})), function(t) {
  function e(n, 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] = se.view(n[l], a);
    }
    return o;
  }
  function r(n, i) {
    for (var a = /* @__PURE__ */ Object.create(null), o = n._columns, s = 0; s < o.length; s++) {
      var u = o[s];
      a[u] = n[u].value(i);
    }
    return a;
  }
  t.is = function(n) {
    return n && typeof n._rowCount == "number" && !!n._columns && !!n._schema;
  }, t.pickColumns = function(n, i, a) {
    a === void 0 && (a = {});
    var o = /* @__PURE__ */ Object.create(null), s = Object.keys(n);
    o._rowCount = i._rowCount, o._columns = s, o._schema = n;
    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;
  }, t.ofColumns = function(n, i) {
    var a = Object.keys(i), o = i[a[0]].rowCount;
    return O({ _rowCount: o, _columns: a, _schema: n }, i);
  }, t.ofPartialColumns = function(n, i, a) {
    var o = /* @__PURE__ */ Object.create(null), s = Object.keys(n);
    o._rowCount = a, o._columns = s, o._schema = n;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      o[l] = l in i ? i[l] : se.Undefined(a, n[l]);
    }
    return o;
  }, t.ofUndefinedColumns = function(n, i) {
    var a = /* @__PURE__ */ Object.create(null), o = Object.keys(n);
    a._rowCount = i, a._columns = o, a._schema = n;
    for (var s = 0, u = o; s < u.length; s++) {
      var c = u[s];
      a[c] = se.Undefined(i, n[c]);
    }
    return a;
  }, t.ofRows = function(n, i) {
    var a = /* @__PURE__ */ Object.create(null), o = i.length, s = Object.keys(n);
    a._rowCount = o, a._columns = s, a._schema = n;
    for (var u = function(d) {
      a[d] = se.ofLambda({ rowCount: o, schema: n[d], value: function(f) {
        return i[f][d];
      }, valueKind: function(f) {
        return i[f][d] === void 0 ? 1 : 0;
      } });
    }, c = 0, l = s; c < l.length; c++)
      u(l[c]);
    return a;
  }, t.ofArrays = function(n, i) {
    var a, o = /* @__PURE__ */ Object.create(null), s = Object.keys(n);
    o._rowCount = 0, o._columns = s, o._schema = n;
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      i[l] !== void 0 ? (o[l] = se.ofArray({ array: i[l], schema: n[l] }), o._rowCount = (a = i[l]) === null || a === void 0 ? void 0 : a.length) : o[l] = se.Undefined(o._rowCount, n[l]);
    }
    return o;
  }, t.view = e, t.pick = function(n, i, a) {
    for (var o = [], s = 0, u = n._rowCount; s < u; ++s) a(s) && o.push(s);
    return e(n, i, o);
  }, t.window = function(n, i, a, o) {
    if (a === 0 && o === n._rowCount) return n;
    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] = se.window(n[d], a, o);
    }
    return s;
  }, t.concat = function(n, i) {
    var a = /* @__PURE__ */ Object.create(null), o = Object.keys(i);
    a._rowCount = 0;
    for (var s = 0, u = n; s < u.length; s++) {
      var c = u[s];
      a._rowCount += c._rowCount;
    }
    for (var l = {}, d = 0, f = o; d < f.length; d++)
      l[f[d]] = new Array(a._rowCount);
    a._columns = o, a._schema = i;
    for (var h = 0, m = 0, p = n; m < p.length; m++) {
      c = p[m];
      for (var v = 0, g = o; v < g.length; v++) {
        var y = g[v];
        se.copyToArray(c[y], l[y], h);
      }
      h += c._rowCount;
    }
    for (var b = 0, S = o; b < S.length; b++)
      a[y = S[b]] = se.ofArray({ array: l[y], schema: i[y] });
    return a;
  }, t.columnToArray = function(n, i, a) {
    n[i] = se.asArrayColumn(n[i], a);
  }, t.sort = function(n, i) {
    for (var a = new Int32Array(n._rowCount), o = 0, s = a.length; o < s; o++) a[o] = o;
    Ru(a, function(h, m, p) {
      return i(m, p);
    });
    var u = !0;
    for (o = 0, s = a.length; o < s; o++) if (a[o] !== o) {
      u = !1;
      break;
    }
    if (u) return n;
    var c = /* @__PURE__ */ Object.create(null);
    c._rowCount = n._rowCount, c._columns = n._columns, c._schema = n._schema;
    for (var l = 0, d = n._columns; l < d.length; l++) {
      var f = d[l];
      c[f] = se.view(n[f], a, !1);
    }
    return c;
  }, t.areEqual = function(n, i) {
    if (n._rowCount !== i._rowCount || n._columns.length !== i._columns.length) return !1;
    for (var a = 0, o = n._columns; a < o.length; a++)
      if (!i[c = o[a]]) return !1;
    for (var s = 0, u = n._columns; s < u.length; s++) {
      var c = u[s];
      if (!se.areEqual(n[c], i[c])) return !1;
    }
    return !0;
  }, t.getRow = r, t.pickRow = function(n, i) {
    for (var a = 0, o = n._rowCount; a < o; ++a) if (i(a)) return r(n, a);
  }, t.getRows = function(n) {
    for (var i = [], a = n._rowCount, o = 0; o < a; o++) i[o] = r(n, o);
    return i;
  }, t.toArrays = function(n) {
    for (var i = {}, a = n._columns, o = 0; o < a.length; o++) {
      var s = a[o];
      i[s] = n[s].toArray();
    }
    return i;
  }, t.formatToString = function(n) {
    var i = Ir.create(), a = n._columns, o = n._rowCount, s = 1;
    Ir.write(i, "|");
    for (var u = 0; u < a.length; u++) Ir.write(i, a[u]), Ir.write(i, "|"), s += a[u].length + 1;
    Ir.newline(i), Ir.write(i, new Array(s + 1).join("-")), Ir.newline(i);
    for (var c = 0; c < o; c++) {
      for (Ir.write(i, "|"), u = 0; u < a.length; u++) {
        var l = n[a[u]];
        l.valueKind(c) === 0 ? (Ir.write(i, l.value(c)), Ir.write(i, "|")) : Ir.write(i, ".|");
      }
      Ir.newline(i);
    }
    return Ir.getString(i);
  };
}(Hr || (Hr = {})), function(t) {
  t.ofTables = function(e, r, n) {
    var i = Object.keys(n), a = /* @__PURE__ */ Object.create(null), o = [];
    a._name = e, a._tableNames = o, a._schema = r;
    for (var s = 0, u = i; s < u.length; s++) {
      var c = u[s];
      Hr.is(n[c]) && (a[c] = n[c], o[o.length] = c);
    }
    return a;
  }, t.getTablesAsRows = function(e) {
    for (var r = {}, n = 0, i = e._tableNames; n < i.length; n++) {
      var a = i[n];
      r[a] = Hr.getRows(e[a]);
    }
    return r;
  };
}(__ || (__ = {})), function(t) {
  t.Zero = 0;
  var e, r, n = (e = new ArrayBuffer(8), r = new ArrayBuffer(8), { _int32: new Int32Array(e), _float64: new Float64Array(e), _int32_1: new Int32Array(r), _float64_1: new Float64Array(r) }), i = n._int32, a = n._float64, o = n._int32_1, s = n._float64_1;
  t.is = function(u) {
    return typeof u == "number";
  }, t.create = function(u, c) {
    return i[0] = u, i[1] = c, a[0];
  }, t.diff = function(u) {
    return a[0] = u, i[1] - i[0];
  }, t.fst = function(u) {
    return a[0] = u, i[0];
  }, t.snd = function(u) {
    return a[0] = u, i[1];
  }, t.areEqual = function(u, c) {
    return a[0] = u, s[0] = c, i[0] === o[0] && i[1] === o[1];
  }, t.compare = function(u, c) {
    a[0] = u, s[0] = c;
    var l = i[0] - o[0];
    return l !== 0 ? l : i[1] - o[1];
  }, t.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];
  }, t.hashCode = function(u) {
    return a[0] = u, Wp(i[0], i[1]);
  }, t.toString = function(u) {
    return a[0] = u, "(".concat(i[0], ", ").concat(i[1], ")");
  };
}(Ei || (Ei = {}));
var uN = Ei.Zero;
function Dw(t, e) {
  return e < t ? Ei.create(t, t) : Ei.create(t, e + 1);
}
function G9(t, e) {
  return e <= t ? Ei.create(t, t) : Ei.create(t, e);
}
function Zj(t) {
  return t < 0 ? Ei.create(0, 0) : Ei.create(0, t);
}
var Qj = Ei.is, Al = Ei.fst, rf = Ei.snd, S3 = Ei.fst;
function C3(t) {
  return Ei.snd(t) - 1;
}
var h0 = Ei.diff, Jj = Ei.hashCode, $j = Ei.toString;
function eZ(t, e) {
  return Ei.fst(t) <= e && e < Ei.snd(t);
}
function tZ(t, e) {
  var r = Al(t);
  return e >= r && e < rf(t) ? e - r : -1;
}
function rZ(t, e) {
  return Ei.fst(t) + e;
}
var Se, nZ = Ei.areEqual;
function cN(t, e) {
  var r = h0(t), n = h0(e);
  return r === 0 && n === 0 || r > 0 && n > 0 && C3(t) >= S3(e) && S3(t) <= C3(e);
}
function iZ(t, e) {
  return h0(t) ? !h0(e) || Al(t) <= Al(e) && rf(t) >= rf(e) : h0(e) === 0;
}
function C_(t, e) {
  var r = Al(t);
  if (e <= r) return 0;
  var n = rf(t);
  return e >= n ? n - r : e - r;
}
function aZ(t, e, r) {
  var n = Al(r), i = Al(t);
  if (e <= n + i) return n;
  var a = rf(r);
  return e >= a + i ? a : e - i;
}
function lN(t, e, r) {
  return G9(C_(t, e), C_(t, r + 1));
}
function oZ(t, e) {
  return cN(t, e) ? G9(Math.max(Al(t), Al(e)), Math.min(rf(t), rf(e))) : uN;
}
function sZ(t, e) {
  return h0(lN(t, S3(e), C3(e)));
}
(function(t) {
  t.Empty = uN, t.ofSingleton = function(e) {
    return Dw(e, e);
  }, t.ofRange = Dw, t.ofBounds = G9, t.ofLength = Zj, t.is = Qj, t.has = eZ, t.indexOf = tZ, t.getAt = rZ, t.start = Al, t.end = rf, t.min = S3, t.max = C3, t.size = h0, t.hashCode = Jj, t.toString = $j, t.areEqual = nZ, t.areIntersecting = cN, t.isSubInterval = iZ, t.findPredecessorIndex = C_, t.findPredecessorIndexInInterval = aZ, t.findRange = lN, t.intersectionSize = sZ, t.intersect = oZ;
})(Se || (Se = {}));
var zm = [];
function uZ(t) {
  return [t];
}
function cZ(t) {
  return t;
}
function lZ(t) {
  return Ru(t), t;
}
function Ew(t, e) {
  if (e < t) return [];
  for (var r = new Int32Array(e - t + 1), n = t; n <= e; n++) r[n - t] = n;
  return r;
}
function dZ(t) {
  return t && (Array.isArray(t) || !!t.buffer);
}
function dN(t) {
  return t[t.length - 1] - t[0] + 1 === t.length;
}
function A_(t) {
  return t[0];
}
function w_(t) {
  return t[t.length - 1] + 1;
}
function fZ(t) {
  return t[0];
}
function pZ(t) {
  return t[t.length - 1];
}
function fN(t) {
  return t.length;
}
function hZ(t) {
  var e = t.length;
  return e ? e > 2 ? function(r, n, i, a) {
    var o = 23;
    return o = 31 * (o = 31 * (o = 31 * (o = 31 * o + r | 0) + n | 0) + i | 0) + a | 0, o = (3735928559 ^ (o ^= o >> 4)) + (o << 5), o ^ o >> 11;
  }(e, t[0], t[e - 1], t[e >> 1]) : function(r, n, i) {
    var a = 23;
    return a = 31 * (a = 31 * (a = 31 * a + r | 0) + n | 0) + i | 0, a = (3735928559 ^ (a ^= a >> 4)) + (a << 5), a ^ a >> 11;
  }(e, t[0], t[e - 1]) : 0;
}
function mZ(t) {
  var e = t.length;
  return e > 5 ? "[".concat(t[0], ", ").concat(t[1], ", ..., ").concat(t[e - 1], "], length ").concat(e) : "[".concat(t.join(", "), "]");
}
function pN(t, e) {
  var r = t.length;
  return r === 0 ? -1 : t[0] <= e && e <= t[r - 1] ? gN(t, e, 0, r) : -1;
}
function gZ(t, e, r) {
  return hN(t, e, Se.start(r), Se.end(r));
}
function hN(t, e, r, n) {
  return t.length === 0 || n <= r ? -1 : t[r] <= e && e <= t[n - 1] ? gN(t, e, r, n) : -1;
}
function vZ(t, e) {
  return pN(t, e) >= 0;
}
function mN(t, e) {
  if (t === e) return !0;
  var r = t.length;
  if (r !== e.length || t[0] !== e[0] || t[r - 1] !== e[r - 1]) return !1;
  if (dN(t)) return !0;
  r--;
  for (var n = 1; n < r; n++) if (t[n] !== e[n]) return !1;
  return !0;
}
function c0(t, e) {
  var r = t.length;
  return e <= t[0] ? 0 : e > t[r - 1] ? r : vN(t, e, 0, r);
}
function yZ(t, e, r) {
  var n = Se.start(r), i = Se.end(r), a = t[n];
  return e <= a ? n : i > n && e > t[i - 1] ? i : e - a <= 11 ? function(o, s, u, c) {
    for (var l = u; l < c; l++) if (s <= o[l]) return l;
    return c;
  }(t, e, n + 1, i) : vN(t, e, n, i);
}
function bZ(t, e, r) {
  return Se.ofBounds(c0(t, e), c0(t, r + 1));
}
function gN(t, e, r, n) {
  for (var i = r, a = n - 1; i <= a; ) {
    if (i + 11 > a) {
      for (var o = i; o <= a; o++) if (e === t[o]) return o;
      return -1;
    }
    var s = i + a >> 1, u = t[s];
    if (e < u) a = s - 1;
    else {
      if (!(e > u)) return s;
      i = s + 1;
    }
  }
  return -1;
}
function vN(t, e, r, n) {
  for (var i = r, a = n - 1; i < a; ) {
    if (i + 11 > a) {
      for (var o = i; o <= a; o++) if (e <= t[o]) return o;
      return a + 1;
    }
    var s = i + a >> 1, u = t[s];
    if (e < u) a = s - 1;
    else {
      if (!(e > u)) return s;
      i = s + 1;
    }
  }
  return i > a ? a + 1 : t[i] >= e ? i : i + 1;
}
function _Z(t, e) {
  if (t === e) return !0;
  for (var r = R0(t, e), n = r.startI, i = r.startJ, a = r.endI, o = r.endJ; n < a && i < o; ) {
    var s = t[n], u = e[i];
    if (s < u) n++;
    else {
      if (!(s > u)) return !0;
      i++;
    }
  }
  return !1;
}
function xZ(t, e) {
  if (t === e) return !0;
  var r = e.length, n = R0(t, e), i = n.startI, a = n.startJ, o = n.endI, s = n.endJ;
  if (s - a < r || o - i < r) return !1;
  for (var u = 0; i < o && a < s; ) {
    var c = t[i], l = e[a];
    c < l ? i++ : c > l ? a++ : (i++, a++, u++);
  }
  return u === r;
}
function yN(t, e) {
  if (t === e) return t;
  var r = t.length, n = e.length;
  if (r === 0) return e;
  if (n === 0) return t;
  if (t[0] > e[0]) return yN(e, t);
  var i = R0(t, e), a = i.startI, o = i.startJ, s = i.endI, u = i.endJ, c = z9(t, e, a, o, s, u);
  if (c === r && c === n || c === n) return t;
  if (c === r) return e;
  var l = new Int32Array(r + n - c), d = 0, f = 0, h = 0;
  for (d = 0; d < a; d++) l[h++] = t[d];
  for (; f < u && t[a] > e[f]; ) l[h++] = e[f++];
  for (; d < s && f < u; ) {
    var m = t[d], p = e[f];
    m < p ? (l[h++] = m, d++) : m > p ? (l[h++] = p, f++) : (l[h++] = m, d++, f++);
  }
  for (; d < s; d++) l[h++] = t[d];
  for (; f < u; f++) l[h++] = e[f];
  for (; d < r; d++) l[h++] = t[d];
  for (; f < n; f++) l[h++] = e[f];
  return l;
}
function SZ(t, e) {
  if (t === e) return fN(t);
  var r = R0(t, e);
  return z9(t, e, r.startI, r.startJ, r.endI, r.endJ);
}
function z9(t, e, r, n, i, a) {
  for (var o = r, s = n, u = 0; o < i && s < a; ) {
    var c = t[o], l = e[s];
    c < l ? o++ : c > l ? s++ : (o++, s++, u++);
  }
  return u;
}
function CZ(t, e) {
  if (t === e) return t;
  var r = R0(t, e), n = r.startI, i = r.startJ, a = r.endI, o = r.endJ, s = z9(t, e, n, i, a, o), u = t.length, c = e.length;
  if (!s) return zm;
  if (s === u && s === c || s === c) return e;
  if (s === u) return t;
  for (var l = new Int32Array(s), d = 0, f = n, h = i; f < a && h < o; ) {
    var m = t[f], p = e[h];
    m < p ? f++ : (m > p || (l[d++] = m, f++), h++);
  }
  return l;
}
function AZ(t, e) {
  if (t === e) return zm;
  for (var r = t.length, n = R0(t, e), i = n.startI, a = n.startJ, o = n.endI, s = n.endJ, u = i, c = a, l = 0; u < o && c < s; )
    (m = t[u]) < (p = e[c]) ? u++ : m > p ? c++ : (u++, c++, l++);
  if (!l) return t;
  if (l >= r) return zm;
  for (var d = new Int32Array(r - l), f = 0, h = 0; h < i; h++) d[f++] = t[h];
  for (u = i, c = a; u < o && c < s; ) {
    var m, p;
    (m = t[u]) < (p = e[c]) ? (d[f++] = m, u++) : (m > p || u++, c++);
  }
  for (; u < r; u++) d[f++] = t[u];
  return d;
}
function wZ(t) {
  if (t.length < 2) return t;
  for (var e = 1, r = 0, n = t.length - 1; r < n; r++) t[r] !== t[r + 1] && e++;
  if (e === t.length) return t;
  var i = new Int32Array(e), a = 0;
  for (r = 0, n = t.length - 1; r < n; r++) t[r] !== t[r + 1] && (i[a++] = t[r]);
  return i[a] = t[t.length - 1], i;
}
function DZ(t, e) {
  if (mN(t, e)) return S_(0, t.length - 1);
  for (var r = R0(t, e), n = r.startI, i = r.startJ, a = r.endI, o = r.endJ, s = n, u = i, c = 0; s < a && u < o; )
    (h = t[s]) < (m = e[u]) ? s++ : h > m ? u++ : (s++, u++, c++);
  var l = t.length;
  if (!c) return zm;
  if (c === l) return S_(0, t.length - 1);
  var d = new Int32Array(c), f = 0;
  for (s = n, u = i; s < a && u < o; ) {
    var h, m;
    (h = t[s]) < (m = e[u]) ? s++ : (h > m || (d[f++] = s, s++), u++);
  }
  return d;
}
var Ke, Vc = { startI: 0, startJ: 0, endI: 0, endJ: 0 };
function R0(t, e) {
  var r = t.length, n = e.length, i = r / n;
  return r >= 128 || n >= 128 || i <= 0.34 || i >= 2.99 ? (Vc.startI = c0(t, A_(e)), Vc.startJ = c0(e, A_(t)), Vc.endI = c0(t, w_(e)), Vc.endJ = c0(e, w_(t))) : (Vc.startI = 0, Vc.startJ = 0, Vc.endI = r, Vc.endJ = n), Vc;
}
(function(t) {
  t.Empty = zm, t.ofUnsortedArray = lZ, t.ofSingleton = uZ, t.ofSortedArray = cZ, t.ofRange = Ew, t.ofBounds = function(e, r) {
    return Ew(e, r - 1);
  }, t.is = dZ, t.isRange = dN, t.has = vZ, t.indexOf = pN, t.indexOfInInterval = gZ, t.indexOfInRange = hN, t.start = A_, t.end = w_, t.min = fZ, t.max = pZ, t.size = fN, t.hashCode = hZ, t.toString = mZ, t.areEqual = mN, t.areIntersecting = _Z, t.isSubset = xZ, t.union = yN, t.intersect = CZ, t.subtract = AZ, t.findPredecessorIndex = c0, t.findPredecessorIndexInInterval = yZ, t.findRange = bZ, t.intersectionSize = SZ, t.deduplicate = wZ, t.indicesOf = DZ;
})(Ke || (Ke = {}));
var Ge, pc = Se.Empty, EZ = Se.ofSingleton, IZ = Se.ofRange, TZ = Se.ofBounds;
function Fu(t) {
  return t.length ? Ke.isRange(t) ? Se.ofRange(t[0], t[t.length - 1]) : t : pc;
}
function m0(t) {
  return Se.is(t) ? Se.size(t) : Ke.size(t);
}
function MZ(t, e) {
  return Se.is(t) ? Se.has(t, e) : Ke.has(t, e);
}
function PZ(t, e) {
  return Se.is(t) ? Se.indexOf(t, e) : Ke.indexOf(t, e);
}
function D_(t, e) {
  return Se.is(t) ? Se.getAt(t, e) : t[e];
}
function gp(t) {
  return Se.is(t) ? Se.min(t) : Ke.min(t);
}
function vp(t) {
  return Se.is(t) ? Se.max(t) : Ke.max(t);
}
function BZ(t) {
  return Se.is(t) ? Se.start(t) : Ke.start(t);
}
function FZ(t) {
  return Se.is(t) ? Se.end(t) : Ke.end(t);
}
function NZ(t) {
  return Se.is(t) ? Se.hashCode(t) : Ke.hashCode(t);
}
function RZ(t, e) {
  return Se.is(t) ? Se.is(e) ? Se.areEqual(t, e) : Iw(t, e) : Se.is(e) ? Iw(e, t) : Ke.areEqual(t, e);
}
function OZ(t, e) {
  return Se.is(t) ? Se.is(e) ? Se.areIntersecting(t, e) : Tw(e, t) : Se.is(e) ? Tw(t, e) : Ke.areIntersecting(t, e);
}
function LZ(t, e) {
  return Se.is(t) ? Se.is(e) ? Se.isSubInterval(t, e) : function(r, n) {
    var i = Se.min(r), a = Se.max(r);
    if (a - i + 1 == 0) return !1;
    var o = Ke.min(n), s = Ke.max(n);
    return o >= i && s <= a;
  }(t, e) : Se.is(e) ? function(r, n) {
    var i = Se.min(n), a = Se.max(n);
    if (a - i + 1 == 0) return !0;
    var o = Ke.min(r), s = Ke.max(r);
    if (i < o || a > s) return !1;
    var u = Ke.findRange(r, i, a);
    return Se.size(u) === Se.size(n);
  }(t, e) : Ke.isSubset(t, e);
}
function kZ(t, e) {
  return Se.is(t) ? Se.findPredecessorIndex(t, e) : Ke.findPredecessorIndex(t, e);
}
function GZ(t, e, r) {
  return Se.is(t) ? Se.findPredecessorIndexInInterval(t, e, r) : Ke.findPredecessorIndexInInterval(t, e, r);
}
function zZ(t, e, r) {
  return Se.is(t) ? Se.findRange(t, e, r) : Ke.findRange(t, e, r);
}
function VZ(t, e) {
  return Se.is(t) ? Se.is(e) ? Se.intersectionSize(t, e) : Pw(e, t) : Se.is(e) ? Pw(t, e) : Ke.intersectionSize(t, e);
}
function UZ(t, e) {
  return Se.is(t) ? Se.is(e) ? function(r, n) {
    if (Se.areEqual(r, n)) return r;
    var i = Se.size(r), a = Se.size(n);
    if (!a) return r;
    if (!i) return n;
    var o, s, u, c, l = Se.min(r), d = Se.min(n);
    if (function(m, p) {
      var v = m0(m), g = m0(p);
      return v === 0 && g === 0 || v > 0 && g > 0 && vp(m) >= gp(p) && gp(m) <= vp(p);
    }(r, n)) return Se.ofRange(Math.min(l, d), Math.max(Se.max(r), Se.max(n)));
    l < d ? (o = i, s = l, u = a, c = d) : (o = a, s = d, u = i, c = l);
    for (var f = new Int32Array(i + a), h = 0; h < o; h++) f[h] = h + s;
    for (h = 0; h < u; h++) f[h + o] = h + c;
    return Fu(f);
  }(t, e) : Mw(e, t) : Se.is(e) ? Mw(t, e) : Fu(Ke.union(t, e));
}
function HZ(t, e) {
  return Se.is(t) ? Se.is(e) ? Se.intersect(t, e) : Bw(e, t) : Se.is(e) ? Bw(t, e) : Fu(Ke.intersect(t, e));
}
function qZ(t, e) {
  return Se.is(t) ? Se.is(e) ? function(r, n) {
    if (Se.areEqual(r, n)) return pc;
    if (!Se.areIntersecting(r, n)) return r;
    var i = Se.min(r), a = Se.max(r), o = Se.min(n), s = Se.max(n);
    if (a < i || s < o) return r;
    if (Se.isSubInterval(n, r)) return pc;
    if (Se.isSubInterval(r, n)) {
      var u = o - i, c = a - s;
      if (u <= 0) return Se.ofRange(s + 1, s + c);
      if (c <= 0) return Se.ofRange(i, i + u - 1);
      for (var l = new Int32Array(u + c), d = 0, f = 0; f < u; f++) l[d++] = i + f;
      for (f = 1; f <= c; f++) l[d++] = s + f;
      return Fu(l);
    }
    return i < o ? Se.ofRange(i, o - 1) : Se.ofRange(s + 1, a);
  }(t, e) : function(r, n) {
    var i = Se.min(r), a = Se.max(r);
    if (a < i) return r;
    var o = a - i + 1, s = Ke.findRange(n, i, a), u = Se.start(s), c = Se.end(s), l = c - u;
    if (l === 0) return r;
    var d = o - l;
    if (d <= 0) return pc;
    for (var f = new Int32Array(d), h = n.length - 1, m = n[Math.min(u, h)], p = n[Math.min(c, h)], v = 0, g = i; g < m; g++) f[v++] = g;
    for (g = m; g <= p; g++) Ke.indexOfInInterval(n, g, s) < 0 && (f[v++] = g);
    for (g = p + 1; g <= a; g++) f[v++] = g;
    return Fu(f);
  }(t, e) : Se.is(e) ? function(r, n) {
    var i = Se.min(n), a = Se.max(n);
    if (a < i) return r;
    var o = Ke.findRange(r, i, a), s = Se.start(o), u = Se.end(o), c = r.length - (u - s);
    if (c <= 0) return pc;
    if (c === r.length) return r;
    for (var l = new Int32Array(c), d = 0, f = 0; f < s; f++) l[d++] = r[f];
    f = u;
    for (var h = r.length; f < h; f++) l[d++] = r[f];
    return Fu(l);
  }(t, e) : Fu(Ke.subtract(t, e));
}
function Iw(t, e) {
  return Se.size(t) === Ke.size(e) && Se.start(t) === Ke.start(e) && Se.end(t) === Ke.end(e);
}
function Tw(t, e) {
  return t.length !== 0 && Se.size(Ke.findRange(t, Se.min(e), Se.max(e))) !== 0;
}
function KZ(t, e) {
  return m0(t) ? !m0(e) || gp(t) <= gp(e) && vp(t) >= vp(e) : m0(e) === 0;
}
function Mw(t, e) {
  var r = Se.size(e);
  if (!r) return t;
  if (KZ(e, t)) return e;
  for (var n = Se.min(e), i = Se.max(e), a = Ke.findRange(t, n, i), o = Se.start(a), s = Se.end(a), u = new Int32Array(o + (t.length - s) + r), c = 0, l = 0; l < o; l++) u[c++] = t[l];
  for (l = n; l <= i; l++) u[c++] = l;
  l = s;
  for (var d = t.length; l < d; l++) u[c++] = t[l];
  return Fu(u);
}
function Pw(t, e) {
  if (!Se.size(e)) return 0;
  var r = Ke.findRange(t, Se.min(e), Se.max(e));
  return Se.end(r) - Se.start(r);
}
function Bw(t, e) {
  if (!Se.size(e)) return pc;
  var r = Ke.findRange(t, Se.min(e), Se.max(e)), n = Se.start(r), i = Se.end(r), a = i - n;
  if (!a) return pc;
  if (a === t.length) return t;
  for (var o = new Int32Array(a), s = 0, u = n; u < i; u++) o[s++] = t[u];
  return Fu(o);
}
function XZ(t, e, r) {
  if (e === r) return t;
  var n = m0(t), i = e.length, a = r.length;
  if (n === 0 || i === 0 || a === 0) return pc;
  for (var o = Ke.findPredecessorIndex(r, e[gp(t)]), s = Ke.findPredecessorIndex(r, e[vp(t)] + 1), u = 0, c = 0, l = 0, d = o; l < n && d < s; )
    (h = e[D_(t, l)]) < (m = r[d]) ? l++ : (h > m || (u++, l++), d++);
  if (u === 0) return pc;
  if (u === i && u === a) return t;
  var f = new Int32Array(u);
  for (c = 0, l = 0, d = o; l < n && d < s; ) {
    var h, m;
    (h = e[D_(t, l)]) < (m = r[d]) ? l++ : (h > m || (f[c++] = d, l++), d++);
  }
  return Fu(f);
}
function bN(t) {
  for (var e = Ke.ofSortedArray(t), r = Ke.max(e), n = new Int32Array(r), i = 0, a = t.length - 1; i < a; i++) for (var o = t[i], s = t[i + 1]; o < s; o++) n[o] = i;
  return { offsets: e, index: n, count: t.length - 1 };
}
function YZ(t, e) {
  for (var r = Se.start(e), n = new Int32Array(t.length + 1), i = 0, a = t.length; i < a; i++) n[i] = t[i] - r;
  return n[t.length] = Se.end(e) - r, bN(n);
}
function WZ(t) {
  return t.count;
}
function jZ(t, e) {
  return t.index[e];
}
function ZZ(t, e, r) {
  var n = t.offsets, i = r >= Ge.max(n) ? -1 : Ge.findPredecessorIndex(n, r - 1);
  return Ge.findRange(e, Ge.getAt(n, i), Ge.getAt(n, i + 1) - 1);
}
(function(t) {
  t.Empty = pc, t.ofSingleton = EZ, t.ofRange = IZ, t.ofBounds = TZ, t.ofSortedArray = Fu, t.has = MZ, t.indexOf = PZ, t.getAt = D_, t.min = gp, t.max = vp, t.start = BZ, t.end = FZ, t.size = m0, t.hashCode = NZ, t.areEqual = RZ, t.areIntersecting = OZ, t.isSubset = LZ, t.union = UZ, t.intersect = HZ, t.indexedIntersect = XZ, t.subtract = qZ, t.findPredecessorIndex = kZ, t.findPredecessorIndexInInterval = GZ, t.findRange = zZ, t.intersectionSize = VZ, t.forEach = function(e, r, n) {
    return function(i, a, o) {
      if (Se.is(i)) for (var s = Se.min(i), u = s, c = Se.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;
    }(e, r, n);
  }, t.forEachSegment = function(e, r, n, i) {
    return function(a, o, s, u) {
      if (Se.is(a)) for (var c = 0, l = Se.min(a), d = Se.max(a); l <= d; l++) {
        for (var f = o(l), h = l + 1; h < d && o(h) === f; ) h++;
        l = h - 1, s(f, c, u), c++;
      }
      else for (c = 0, l = 0, d = a.length; l < d; l++) {
        for (f = o(a[l]), h = l + 1; h < d && o(a[h]) === f; ) h++;
        l = h - 1, s(f, c, u), c++;
      }
      return u;
    }(e, r, n, i);
  }, t.isInterval = function(e) {
    return Se.is(e);
  }, t.isSortedArray = function(e) {
    return !Se.is(e);
  }, t.toArray = function(e) {
    var r = [];
    return t.forEach(e, function(n) {
      return r.push(n);
    }), r;
  }, t.toString = function(e) {
    return function(r) {
      return Se.is(r) ? Se.toString(r) : Ke.toString(r);
    }(e);
  };
})(Ge || (Ge = {}));
var Qt, QZ = function() {
  function t(e, r, n, i) {
    this.segments = e, this.segmentMap = r, this.set = n, this.segmentMin = 0, this.segmentMax = 0, this.setRange = Se.Empty, this.value = { index: 0, start: 0, end: 0 }, this.hasNext = !1, this.setRange = i, this.updateSegmentRange();
  }
  return t.prototype.move = function() {
    for (; this.hasNext; ) {
      if (this.updateValue()) {
        this.value.index = this.segmentMin++, this.hasNext = this.segmentMax >= this.segmentMin && Se.size(this.setRange) > 0;
        break;
      }
      this.updateSegmentRange();
    }
    return this.value;
  }, t.prototype.updateValue = function() {
    var e = this.segments[this.segmentMin + 1], r = Ge.findPredecessorIndexInInterval(this.set, e, this.setRange);
    return this.value.start = Se.start(this.setRange), this.value.end = r, this.setRange = Se.ofBounds(r, Se.end(this.setRange)), r > this.value.start;
  }, t.prototype.updateSegmentRange = function() {
    var e = Se.min(this.setRange), r = Se.max(this.setRange);
    r < e ? this.hasNext = !1 : (this.segmentMin = this.segmentMap[Ge.getAt(this.set, e)], this.segmentMax = this.segmentMap[Ge.getAt(this.set, r)], this.hasNext = this.segmentMax >= this.segmentMin);
  }, t.prototype.setSegment = function(e) {
    this.setRange = Se.ofBounds(e.start, e.end), this.updateSegmentRange();
  }, t;
}();
function JZ(t, e, r) {
  var n = r !== void 0 ? Se.ofBounds(r.start, r.end) : Se.ofBounds(0, Ge.size(e));
  return new QZ(t.offsets, t.index, e, n);
}
(function(t) {
  t.create = bN, t.ofOffsets = YZ, t.count = WZ, t.getSegment = jZ, t.projectValue = ZZ, t.transientSegments = JZ;
})(Qt || (Qt = {}));
var bc, $Z = function() {
  function t(e) {
    this.head = e > 0 ? 0 : -1, this.prev = new Int32Array(e), this.next = new Int32Array(e);
    for (var r = 0; r < e; r++) this.next[r] = r + 1, this.prev[r] = r - 1;
    this.prev[0] = -1, this.next[e - 1] = -1;
  }
  return t.prototype.remove = function(e) {
    var r = this.prev, n = this.next, i = r[e], a = n[e];
    i >= 0 && (n[i] = a, r[e] = -1), a >= 0 && (r[a] = i, n[e] = -1), e === this.head && (this.head = i < 0 ? a : i);
  }, t.prototype.has = function(e) {
    return this.prev[e] >= 0 || this.next[e] >= 0 || this.head === e;
  }, t;
}();
(function(t) {
  function e() {
    return /* @__PURE__ */ new Map();
  }
  t.Empty = /* @__PURE__ */ new Map(), t.keyArray = function(r) {
    return k9(r.keys());
  }, t.Mutable = e, t.asImmutable = function(r) {
    return r;
  }, t.copy = function(r) {
    for (var n = e(), i = r.keys(); ; ) {
      var a = i.next(), o = a.done, s = a.value;
      if (o) break;
      n.set(s, r.get(s));
    }
    return n;
  }, t.addFrom = function(r, n) {
    for (var i = n.keys(); ; ) {
      var a = i.next(), o = a.done, s = a.value;
      if (o) break;
      r.set(s, n.get(s));
    }
    return r;
  };
})(bc || (bc = {}));
var A3, eQ = function() {
  function t(e) {
    this.xs = [], this.index = -1, this.length = 0, this.hasNext = !1, this.length = e.length, this.hasNext = e.length > 0, this.xs = e, this.index = -1, this.lastValue = e.length > 0 ? e[0] : void 0;
  }
  return t.prototype.move = function() {
    return ++this.index, this.lastValue = this.xs[this.index], this.hasNext = this.index < this.length - 1, this.lastValue;
  }, t;
}(), Fw = function() {
  function t(e, r) {
    this.max = r, this.value = 0, this.hasNext = !1, this.value = e - 1, this.hasNext = r >= e;
  }
  return t.prototype.move = function() {
    return ++this.value, this.hasNext = this.value < this.max, this.value;
  }, t;
}(), tQ = function() {
  function t(e) {
    this.value = e, this.hasNext = !0;
  }
  return t.prototype.move = function() {
    return this.hasNext = !1, this.value;
  }, t;
}(), rQ = function() {
  function t(e, r) {
    this.base = e, this.f = r, this.hasNext = !1, this.hasNext = e.hasNext;
  }
  return t.prototype.move = function() {
    var e = this.f(this.base.move());
    return this.hasNext = this.base.hasNext, e;
  }, t;
}(), nQ = function() {
  function t(e, r) {
    this.base = e, this.p = r, this.hasNext = this.findNext();
  }
  return t.prototype.move = function() {
    var e = this.next;
    return this.hasNext = this.findNext(), e;
  }, t.prototype.findNext = function() {
    for (; this.base.hasNext; ) if (this.next = this.base.move(), this.p(this.next)) return !0;
    return !1;
  }, t;
}();
(function(t) {
  t.Empty = new Fw(0, -1), t.Array = function(e) {
    return new eQ(e);
  }, t.Value = function(e) {
    return new tQ(e);
  }, t.Range = function(e, r) {
    return new Fw(e, r);
  }, t.map = function(e, r) {
    return new rQ(e, r);
  }, t.filter = function(e, r) {
    return new nQ(e, r);
  }, t.forEach = function(e, r, n) {
    for (; e.hasNext; )
      if (r(e.move(), n)) return n;
    return n;
  };
})(A3 || (A3 = {}));
var _c, Ao, iQ = { domain: [0, 1], reverse: !1, listOrName: "red-yellow-blue", minLabel: "", maxLabel: "" };
function V9(t) {
  return Object.keys(t);
}
function ca(t) {
  throw new Error("unreachable");
}
function U9(t) {
  return typeof (t == null ? void 0 : t.then) == "function";
}
(function(t) {
  t.create = function(e) {
    var r = O(O({}, iQ), e), n = r.domain, i = r.reverse, a = r.listOrName, o = typeof a == "string" ? Cl(a).list : a, s = i ? o.slice().reverse() : o, u = s.length - 1, c = 0, l = 0, d = 0;
    function f(_, x) {
      c = (d = x) - (l = _) || 1;
    }
    f(n[0], n[1]);
    var h, m = Ui(e.minLabel, l.toString()), p = Ui(e.maxLabel, d.toString()), v = s.every(function(_) {
      return Array.isArray(_);
    });
    if (v) {
      var g = Ze([], s, !0);
      g.sort(function(_, x) {
        return _[1] - x[1];
      });
      var y = g.map(function(_) {
        return _[0];
      }), b = Ke.ofSortedArray(g.map(function(_) {
        return _[1];
      })), S = y.length - 1;
      h = function(_) {
        var x = _o((_ - l) / c, 0, 1), C = Ke.findPredecessorIndex(b, x);
        if (C === 0) return y[l];
        if (C > S) return y[S];
        var A = b[C - 1], w = _o((x - A) / (b[C] - A), 0, 1);
        return qe.interpolate(y[C - 1], y[C], w);
      };
    } else h = function(_) {
      var x = Math.min(s.length - 1, Math.max(0, (_ - l) / c * u)), C = Math.floor(x), A = s[C], w = s[Math.ceil(x)];
      return qe.interpolate(A, w, x - C);
    };
    return { color: h, colorToArray: function(_, x, C) {
      qe.toArray(h(_), x, C);
    }, normalizedColorToArray: function(_, x, C) {
      qe.toArrayNormalized(h(_), x, C);
    }, setDomain: f, get legend() {
      return /* @__PURE__ */ function(_, x, C) {
        return { kind: "scale-legend", minLabel: _, maxLabel: x, colors: C };
      }(m, p, s);
    } };
  };
})(_c || (_c = {})), function(t) {
  t.toArray = function(e) {
    return k9(e.values());
  }, t.isSuperset = function(e, r) {
    var n = !0;
    return r.forEach(function(i) {
      e.has(i) || (n = !1);
    }), n;
  }, t.add = function(e) {
    for (var r = [], n = 1; n < arguments.length; n++) r[n - 1] = arguments[n];
    for (var i = 0; i < r.length; i++) r[i].forEach(function(a) {
      return e.add(a);
    });
    return e;
  }, t.union = function(e, r) {
    var n = new Set(e);
    return r.forEach(function(i) {
      return n.add(i);
    }), n;
  }, t.unionMany = function() {
    for (var e = [], r = 0; r < arguments.length; r++) e[r] = arguments[r];
    if (e.length === 0) return /* @__PURE__ */ new Set();
    e.length === 1 && new Set(e[0]);
    for (var n = new Set(e[0]), i = 1, a = e.length; i < a; i++) e[i].forEach(function(o) {
      return n.add(o);
    });
    return n;
  }, t.unionManyArrays = function(e) {
    if (e.length === 0) return /* @__PURE__ */ new Set();
    for (var r = new Set(e[0]), n = 1; n < e.length; n++) for (var i = 0, a = e[n]; i < a.length; i++) {
      var o = a[i];
      r.add(o);
    }
    return r;
  }, t.intersection = function(e, r) {
    var n = /* @__PURE__ */ new Set();
    return r.forEach(function(i) {
      e.has(i) && n.add(i);
    }), n;
  }, t.areIntersecting = function(e, r) {
    var n = !1;
    return r.forEach(function(i) {
      e.has(i) && (n = !0);
    }), n;
  }, t.intersectionSize = function(e, r) {
    var n = 0;
    return r.forEach(function(i) {
      e.has(i) && (n += 1);
    }), n;
  }, t.difference = function(e, r) {
    var n = new Set(e);
    return r.forEach(function(i) {
      return n.delete(i);
    }), n;
  }, t.differenceSize = function(e, r) {
    var n = e.size;
    return e.forEach(function(i) {
      r.has(i) && (n -= 1);
    }), n;
  }, t.areEqual = function(e, r) {
    if (e.size !== r.size) return !1;
    var n = !0;
    return r.forEach(function(i) {
      e.has(i) || (n = !1);
    }), n;
  };
}(Ao || (Ao = {}));
var H9 = function() {
};
function xo(t, e) {
  var r = t.length;
  if (r !== e.length) return !1;
  for (var n = 0; n < r; n++) if (t[n] !== e[n]) return !1;
  return !0;
}
var _N = Object.prototype.hasOwnProperty;
function nf(t, e) {
  if (t === e) return !0;
  var r = Array.isArray(t), n = Array.isArray(e);
  if (r && n) {
    if (t.length !== e.length) return !1;
    for (var i = 0; i < t.length; i++) if (!nf(t[i], e[i])) return !1;
    return !0;
  }
  if (r !== n) return !1;
  if (t && e && typeof t == "object" && typeof e == "object") {
    var a = Object.keys(t);
    if (a.length !== Object.keys(e).length) return !1;
    var o = t instanceof Date, s = e instanceof Date;
    if (o && s) return t.getTime() === e.getTime();
    if (o !== s) return !1;
    var u = t instanceof RegExp, c = e instanceof RegExp;
    if (u && c) return t.toString() === e.toString();
    if (u !== c) return !1;
    for (i = 0; i < a.length; i++) if (!_N.call(e, a[i])) return !1;
    for (i = 0; i < a.length; i++) if (!nf(t[a[i]], e[a[i]])) return !1;
    return !0;
  }
  return !1;
}
function E_(t, e) {
  if (t === e) return !0;
  var r = Array.isArray(t), n = Array.isArray(e);
  return r && n ? aQ(t, e) : r === n && !(!t || !e || typeof t != "object" || typeof e != "object") && xN(t, e);
}
function xN(t, e) {
  if (t === e) return !0;
  if (!t || !e) return !1;
  var r = Object.keys(t);
  if (Object.keys(e).length !== r.length) return !1;
  for (var n = 0, i = r; n < i.length; n++) {
    var a = i[n];
    if (!_N.call(t, a) || t[a] !== e[a]) return !1;
  }
  return !0;
}
function aQ(t, e) {
  if (t === e) return !0;
  if (!t || !e || t.length !== e.length) return !1;
  for (var r = 0, n = t.length; r < n; ++r) if (t[r] !== e[r]) return !1;
  return !0;
}
function Ui(t, e) {
  return t !== void 0 ? t : e;
}
function F6(t) {
  if (typeof t == "object") {
    if ("buttons" in t) return t.buttons;
    if ("which" in t) {
      var e = t.which;
      if (e === 2) return 4;
      if (e === 3) return 2;
      if (e > 0) return 1 << e - 1;
    }
  }
  return 0;
}
function Nw(t) {
  if (typeof t == "object" && "button" in t) {
    var e = t.button;
    if (e === 1) return 4;
    if (e === 2) return 2;
    if (e >= 0) return 1 << e;
  }
  return 0;
}
var yp, x0, Rw = { noScroll: !0, noMiddleClickScroll: !0, noContextMenu: !0, noPinchZoom: !0, noTextSelect: !0, preventGestures: !1, mask: function(t, e) {
  return !0;
}, pixelScale: 1 };
function Ow() {
  return { drag: new Si(), interactionEnd: new Si(), click: new Si(), move: new Si(), wheel: new Si(), pinch: new Si(), gesture: new Si(), resize: new Si(), leave: new Si(), enter: new Si(), modifiers: new Si(), key: new Si() };
}
(function(t) {
  function e(r) {
    return r === void 0 && (r = {}), { shift: !!r.shift, alt: !!r.alt, control: !!r.control, meta: !!r.meta };
  }
  t.None = e(), t.areEqual = function(r, n) {
    return r.shift === n.shift && r.alt === n.alt && r.control === n.control && r.meta === n.meta;
  }, t.size = function(r) {
    if (!r) return 0;
    var n = 0;
    return r.shift && n++, r.alt && n++, r.control && n++, r.meta && n++, n;
  }, t.create = e;
})(yp || (yp = {})), function(t) {
  t.has = Ga.has, t.create = Ga.create;
}(x0 || (x0 = {}));
var I_, oQ = ["Backspace", "Delete"];
function sa() {
  return sa.zero();
}
(function(t) {
  t.create = function(e) {
    e === void 0 && (e = {});
    var r = O(O({}, Rw), e), n = r.noScroll, i = r.noContextMenu;
    return O(O({ noScroll: n, noContextMenu: i, width: 0, height: 0, pixelRatio: 1 }, Ow()), { dispose: H9 });
  }, t.fromElement = function(e, r) {
    r === void 0 && (r = {});
    var n = O(O({}, Rw), r), i = n.noScroll, a = n.noMiddleClickScroll, o = n.noContextMenu, s = n.noPinchZoom, u = n.noTextSelect, c = n.mask, l = n.pixelScale, d = n.preventGestures, f = e.clientWidth * x(), h = e.clientHeight * x(), m = 0, p = 0, v = ze(), g = ze(), y = ze(), b = ze(), S = ze(), _ = { shift: !1, alt: !1, control: !1, meta: !1 };
    function x() {
      return window.devicePixelRatio * l;
    }
    function C() {
      return O({}, _);
    }
    var A, w, I = 0, P = !1, M = x0.create(0), T = 0, F = !1, N = Ow(), R = N.drag, L = N.interactionEnd, V = N.wheel, U = N.pinch, H = N.gesture, K = N.click, X = N.move, Y = N.leave, Q = N.enter, J = N.resize, te = N.modifiers, W = N.key;
    return e.addEventListener("contextmenu", j, !1), e.addEventListener("wheel", le, !1), e.addEventListener("mousedown", Ne, !1), window.addEventListener("mousemove", Je, !1), window.addEventListener("mouseup", Re, !1), e.addEventListener("mouseenter", Ue, !1), e.addEventListener("mouseleave", Ve, !1), e.addEventListener("touchstart", ke, !1), e.addEventListener("touchmove", We, !1), e.addEventListener("touchend", He, !1), e.addEventListener("gesturechange", Ae, !1), e.addEventListener("gesturestart", ge, !1), e.addEventListener("gestureend", Oe, !1), window.addEventListener("blur", ie), window.addEventListener("keyup", ce, !1), window.addEventListener("keydown", ae, !1), window.addEventListener("keypress", de, !1), window.addEventListener("resize", ht, !1), O(O({ get noScroll() {
      return i;
    }, set noScroll(Ee) {
      i = Ee;
    }, get noContextMenu() {
      return o;
    }, set noContextMenu(Ee) {
      o = Ee;
    }, get width() {
      return f;
    }, get height() {
      return h;
    }, get pixelRatio() {
      return x();
    } }, N), { dispose: function() {
      P || (P = !0, e.removeEventListener("contextmenu", j, !1), e.removeEventListener("wheel", le, !1), e.removeEventListener("mousedown", Ne, !1), window.removeEventListener("mousemove", Je, !1), window.removeEventListener("mouseup", Re, !1), e.removeEventListener("mouseenter", Ue, !1), e.removeEventListener("mouseleave", Ve, !1), e.removeEventListener("touchstart", ke, !1), e.removeEventListener("touchmove", We, !1), e.removeEventListener("touchend", He, !1), e.removeEventListener("gesturechange", Ae, !1), e.removeEventListener("gesturestart", ge, !1), e.removeEventListener("gestureend", Oe, !1), window.removeEventListener("blur", ie), window.removeEventListener("keyup", ce, !1), window.removeEventListener("keydown", ae, !1), window.removeEventListener("keypress", de, !1), window.removeEventListener("resize", ht, !1));
    } });
    function j(Ee) {
      c(Ee.clientX, Ee.clientY) && o && Ee.preventDefault();
    }
    function ee(Ee) {
      _.alt = Ee.altKey, _.shift = Ee.shiftKey, _.control = Ee.ctrlKey, _.meta = Ee.metaKey;
    }
    function ie() {
      (M || _.shift || _.alt || _.meta || _.control) && (M = 0, _.shift = _.alt = _.control = _.meta = !1);
    }
    function ae(Ee) {
      var st = !1;
      !_.alt && Ee.altKey && (st = !0, _.alt = !0), !_.shift && Ee.shiftKey && (st = !0, _.shift = !0), !_.control && Ee.ctrlKey && (st = !0, _.control = !0), !_.meta && Ee.metaKey && (st = !0, _.meta = !0), st && F && te.next(C());
    }
    function ce(Ee) {
      var st = !1;
      _.alt && !Ee.altKey && (st = !0, _.alt = !1), _.shift && !Ee.shiftKey && (st = !0, _.shift = !1), _.control && !Ee.ctrlKey && (st = !0, _.control = !1), _.meta && !Ee.metaKey && (st = !0, _.meta = !1), st && F && te.next(C()), oQ.includes(Ee.key) && de(Ee);
    }
    function de(Ee) {
      W.next({ key: Ee.key, modifiers: C() });
    }
    function Ce(Ee) {
      var st = Ee.touches[0], Et = Ee.touches[1];
      return { clientX: (st.clientX + Et.clientX) / 2, clientY: (st.clientY + Et.clientY) / 2, pageX: (st.pageX + Et.pageX) / 2, pageY: (st.pageY + Et.pageY) / 2 };
    }
    function De(Ee) {
      var st = Ee.touches[0].pageX - Ee.touches[1].pageX, Et = Ee.touches[0].pageY - Ee.touches[1].pageY;
      return Math.sqrt(st * st + Et * Et);
    }
    function ke(Ee) {
      if (Ee.preventDefault(), Ee.touches.length === 1) M = T = 1, ne(Ee.touches[0]);
      else if (Ee.touches.length === 2) {
        M = 0, T = 2, ne(Ce(Ee));
        var st = De(Ee);
        m = st, U.next({ distance: st, fraction: 1, fractionDelta: 0, delta: 0, isStart: !0, buttons: M, button: T, modifiers: C() });
      } else Ee.touches.length === 3 && (M = T = 8, ne(Ce(Ee)));
    }
    function He(Ee) {
      nt();
    }
    function We(Ee) {
      if (T = 0, s && (Ee.preventDefault(), Ee.stopPropagation(), Ee.originalEvent && (Ee.originalEvent.preventDefault(), Ee.originalEvent.stopPropagation())), Ee.touches.length === 1) M = 1, re(Ee.touches[0]);
      else if (Ee.touches.length === 2) {
        var st = De(Ee), Et = m - st;
        if (Math.abs(Et) < 4) M = 2, re(Ce(Ee));
        else {
          M = 4, ee(Ee);
          var ur = m / st;
          U.next({ delta: Et, fraction: ur, fractionDelta: p - ur, distance: st, isStart: !1, buttons: M, button: T, modifiers: C() }), p = ur;
        }
        m = st;
      } else Ee.touches.length === 3 && (M = 8, re(Ce(Ee)));
    }
    function Ne(Ee) {
      ee(Ee), M = F6(Ee), T = Nw(Ee), a && M === 4 && Ee.preventDefault, ne(Ee);
    }
    function Je(Ee) {
      ee(Ee), M = F6(Ee), T = 0, re(Ee);
    }
    function Re(Ee) {
      ee(Ee), M = F6(Ee), T = Nw(Ee), function(st) {
        if (I = 0, !!c(st.clientX, st.clientY) && (At(y, st), ze.distance(y, v) < 4)) {
          var Et = st.pageX, ur = st.pageY, ir = y[0], Nr = y[1];
          K.next({ x: ir, y: Nr, pageX: Et, pageY: ur, buttons: M, button: T, modifiers: C() });
        }
      }(Ee), nt();
    }
    function nt() {
      L.next(void 0);
    }
    function ne(Ee) {
      c(Ee.clientX, Ee.clientY) && (At(g, Ee), ze.copy(v, g), bt(g) && (I = 1));
    }
    function re(Ee) {
      var st;
      At(y, Ee);
      var Et, ur = Ee.pageX, ir = Ee.pageY, Nr = y[0], pr = y[1], _n = bt(y);
      if (X.next({ x: Nr, y: pr, pageX: ur, pageY: ir, buttons: M, button: T, modifiers: C(), inside: _n }), I !== 0 && (u && ((st = Ee.preventDefault) === null || st === void 0 || st.call(Ee)), ze.div(b, ze.sub(b, y, g), ((Et = S)[0] = e.clientWidth, Et[1] = e.clientHeight, Et)), !(ze.magnitude(b) < Cn))) {
        var Jn = I === 1;
        if (!Jn || c(Ee.clientX, Ee.clientY)) {
          var Yn = b[0], Rn = b[1];
          R.next({ x: Nr, y: pr, dx: Yn, dy: Rn, pageX: ur, pageY: ir, buttons: M, button: T, modifiers: C(), isStart: Jn }), ze.copy(g, y), I = 2;
        }
      }
    }
    function le(Ee) {
      if (c(Ee.clientX, Ee.clientY)) {
        At(y, Ee);
        var st = Ee.pageX, Et = Ee.pageY, ur = y[0], ir = y[1];
        i && Ee.preventDefault();
        var Nr = function(pr) {
          var _n = 10, Jn = 40, Yn = 800, Rn = 0, un = 0, yi = 0, cn = 0, ln = 0;
          return "detail" in pr && (un = pr.detail), "wheelDelta" in pr && (un = -pr.wheelDelta / 120), "wheelDeltaY" in pr && (un = -pr.wheelDeltaY / 120), "wheelDeltaX" in pr && (Rn = -pr.wheelDeltaX / 120), "axis" in pr && pr.axis === pr.HORIZONTAL_AXIS && (Rn = un, un = 0), yi = Rn * _n, cn = un * _n, "deltaY" in pr && (cn = pr.deltaY), "deltaX" in pr && (yi = pr.deltaX), "deltaZ" in pr && (ln = pr.deltaZ), (yi || cn || ln) && pr.deltaMode && (pr.deltaMode === 1 ? (yi *= Jn, cn *= Jn, ln *= Jn) : (yi *= Yn, cn *= Yn, ln *= Yn)), yi && !Rn && (Rn = yi < 1 ? -1 : 1), cn && !un && (un = cn < 1 ? -1 : 1), { spinX: Rn, spinY: un, dx: yi, dy: cn, dz: ln };
        }(Ee);
        M = T = 4, (Nr.dx || Nr.dy || Nr.dz) && V.next(O(O({ x: ur, y: ir, pageX: st, pageY: Et }, Nr), { buttons: M, button: T, modifiers: C() }));
      }
    }
    function fe(Ee) {
      var st, Et;
      d && (Ee.preventDefault(), (st = Ee.stopImmediatePropagation) === null || st === void 0 || st.call(Ee), (Et = Ee.stopPropagation) === null || Et === void 0 || Et.call(Ee));
    }
    function ge(Ee) {
      fe(Ee), A = Ee.scale, w = Ee.rotation, H.next({ scale: Ee.scale, rotation: Ee.rotation, deltaRotation: 0, deltaScale: 0, isStart: !0 });
    }
    function me(Ee, st) {
      H.next({ scale: Ee.scale, rotation: Ee.rotation, deltaRotation: w - Ee.rotation, deltaScale: A - Ee.scale, isEnd: st }), w = Ee.rotation, A = Ee.scale;
    }
    function Ae(Ee) {
      fe(Ee), me(Ee);
    }
    function Oe(Ee) {
      fe(Ee), me(Ee, !0);
    }
    function Ue(Ee) {
      F = !0, Q.next(void 0);
    }
    function Ve(Ee) {
      F = !1, Y.next(void 0);
    }
    function ht(Ee) {
      J.next({});
    }
    function bt(Ee) {
      if (e instanceof Window || e instanceof Document || e === document.body) return !0;
      var st = e.getBoundingClientRect();
      return Ee[0] >= 0 && Ee[1] >= 0 && Ee[0] < st.width && Ee[1] < st.height;
    }
    function At(Ee, st) {
      f = e.clientWidth * x(), h = e.clientHeight * x();
      var Et = st.clientX || 0, ur = st.clientY || 0, ir = e.getBoundingClientRect();
      return Ee[0] = Et - ir.left, Ee[1] = ur - ir.top, Ee;
    }
  };
})(I_ || (I_ = {})), function(t) {
  t.zero = function() {
    return { x: 0, y: 0, width: 0, height: 0 };
  }, t.create = function(e, r, n, i) {
    return { x: e, y: r, width: n, height: i };
  }, t.clone = function(e) {
    return O({}, e);
  }, t.copy = function(e, r) {
    return Object.assign(e, r);
  }, t.set = function(e, r, n, i, a) {
    return e.x = r, e.y = n, e.width = i, e.height = a, e;
  }, t.toVec4 = function(e, r) {
    return e[0] = r.x, e[1] = r.y, e[2] = r.width, e[3] = r.height, e;
  }, t.equals = function(e, r) {
    return e.x === r.x && e.y === r.y && e.width === r.width && e.height === r.height;
  };
}(sa || (sa = {}));
var Zu = Ut();
function lm(t, e, r, n) {
  var i = r.x, a = r.y, o = r.width, s = r.height, u = e[0] - i, c = s - e[1] - 1 - a, l = e[2];
  return t[0] = 2 * u / o - 1, t[1] = 2 * c / s - 1, t[2] = 2 * l - 1, E.transformMat4(t, t, n);
}
var SN = Object.prototype.hasOwnProperty;
function sQ(t, e) {
  if (!t) return !e;
  if (!e) return !1;
  var r = Object.keys(t);
  if (Object.keys(e).length !== r.length) return !1;
  for (var n = 0, i = r; n < i.length; n++) {
    var a = i[n];
    if (!SN.call(t, a) || t[a] !== e[a]) return !1;
  }
  return !0;
}
function wl(t) {
  if (t === null || typeof t != "object") return t;
  if (t instanceof Array) {
    for (var e = [], r = 0, n = t.length; r < n; r++) e[r] = wl(t[r]);
    return e;
  }
  if (typeof t == "object" && !("prototype" in t)) {
    e = {};
    for (var i in t) SN.call(t, i) && (e[i] = wl(t[i]));
    return e;
  }
  throw new Error(`Can't clone, type "`.concat(typeof t, '" unsupported'));
}
function CN(t, e) {
  if (t) for (var r = 0, n = Object.keys(t); r < n.length; r++) {
    var i = n[r];
    e(t[i], i);
  }
}
var T_ = typeof setImmediate < "u" ? typeof window < "u" ? { setImmediate: function(t) {
  for (var e, r = [], n = 1; n < arguments.length; n++) r[n - 1] = arguments[n];
  return (e = window).setImmediate.apply(e, Ze([t], r, !1));
}, clearImmediate: function(t) {
  return window.clearImmediate(t);
} } : { setImmediate, clearImmediate } : function() {
  var t, e, r, n, i, a, o, s, u = (t = typeof window < "u" && window, e = typeof self < "u" && typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope && self, r = typeof global < "u" && global, t || r || e), c = {}, l = typeof document < "u" ? document : void 0, d = 1;
  function f(m) {
    delete c[m];
  }
  function h(m) {
    var p = c[m];
    f(m), function(v) {
      var g = v.callback, y = v.args;
      switch (y.length) {
        case 0:
          g();
          break;
        case 1:
          g(y[0]);
          break;
        case 2:
          g(y[0], y[1]);
          break;
        case 3:
          g(y[0], y[1], y[2]);
          break;
        default:
          g.apply(void 0, y);
      }
    }(p);
  }
  return typeof process < "u" && {}.toString.call(process) === "[object process]" ? n = function(m) {
    process.nextTick(function() {
      h(m);
    });
  } : function() {
    if (u && u.postMessage && !u.importScripts) {
      var m = !0, p = u.onmessage;
      return u.onmessage = function() {
        m = !1;
      }, u.postMessage("", "*"), u.onmessage = p, m;
    }
  }() ? (o = "setImmediate$" + Math.random() + "$", s = function(m) {
    m.source === u && typeof m.data == "string" && m.data.indexOf(o) === 0 && h(+m.data.slice(o.length));
  }, window.addEventListener ? window.addEventListener("message", s, !1) : window.attachEvent("onmessage", s), n = function(m) {
    window.postMessage(o + m, "*");
  }) : typeof MessageChannel < "u" ? ((a = new MessageChannel()).port1.onmessage = function(m) {
    h(m.data);
  }, n = function(m) {
    a.port2.postMessage(m);
  }) : l && "onreadystatechange" in l.createElement("script") ? (i = l.documentElement, n = function(m) {
    var p = l.createElement("script");
    p.onreadystatechange = function() {
      h(m), p.onreadystatechange = null, i.removeChild(p), p = null;
    }, i.appendChild(p);
  }) : n = function(m) {
    setTimeout(h, 0, m);
  }, { setImmediate: function(m) {
    for (var p = [], v = 1; v < arguments.length; v++) p[v - 1] = arguments[v];
    typeof m != "function" && (m = new Function("" + m));
    var g = { callback: m, args: p };
    return c[d] = g, n(d), d++;
  }, clearImmediate: f };
}();
function uQ(t) {
  T_.setImmediate(t);
}
var Dm, q9 = { setImmediate: T_.setImmediate, clearImmediate: T_.clearImmediate, immediatePromise: function() {
  return new Promise(uQ);
}, delay: function(t, e) {
  return e === void 0 && (e = void 0), new Promise(function(r) {
    return setTimeout(r, t, e);
  });
} }, AN = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}(), Pr = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}(), N6 = typeof performance < "u" && !!performance.mark && performance.measure && !AN;
function cQ(t, e, r) {
  r === void 0 && (r = 250);
  var n = function(i, a, o) {
    var s = { abortRequested: !1, treeAborted: !1, reason: "" };
    return { updateRateMs: o, lastNotified: wi(), observer: a, abortToken: s, taskId: i.id, root: { progress: wN(i), children: [] }, tryAbort: lQ(s) };
  }(t, e, r);
  return K9(t, new dQ(n, n.root));
}
function wN(t) {
  return { taskId: t.id, taskName: t.name, message: "", startedTime: 0, canAbort: !0, isIndeterminate: !0, current: 0, max: 0 };
}
function lQ(t) {
  return function(e) {
    t.abortRequested = !0, t.reason = e || t.reason;
  };
}
function DN(t) {
  return { progress: O({}, t.progress), children: t.children.map(DN) };
}
function EN(t) {
  return t.progress.canAbort && t.children.every(EN);
}
function K9(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          Dm.markStart(t), e.node.progress.startedTime = wi(), i.label = 1;
        case 1:
          return i.trys.push([1, 3, , 7]), [4, t.f(e)];
        case 2:
          return r = i.sent(), Dm.markEnd(t), Dm.measure(t), e.info.abortToken.abortRequested && IN(e.info), [2, r];
        case 3:
          return n = i.sent(), tr.isAbort(n) ? (e.isAborted = !0, e.node.children.length > 0 ? [4, new Promise(function(a) {
            e.onChildrenFinished = a;
          })] : [3, 5]) : [3, 6];
        case 4:
          i.sent(), i.label = 5;
        case 5:
          t.onAbort && t.onAbort(), i.label = 6;
        case 6:
          throw n;
        case 7:
          return [2];
      }
    });
  });
}
function IN(t) {
  throw t.abortToken.treeAborted || (t.abortToken.treeAborted = !0, TN(t.root), MN(t, wi())), tr.Aborted(t.abortToken.reason);
}
function TN(t) {
  var e = t.progress;
  e.isIndeterminate = !0, e.canAbort = !1, e.message = "Aborting...";
  for (var r = 0, n = t.children; r < n.length; r++)
    TN(n[r]);
}
function MN(t, e) {
  t.lastNotified = e;
  var r = function(n) {
    return { root: DN(n.root), canAbort: EN(n.root), requestAbort: n.tryAbort };
  }(t);
  t.observer(r);
}
(function(t) {
  function e(n) {
    return "startTask".concat(n.id);
  }
  function r(n) {
    return "endTask".concat(n.id);
  }
  t.markStart = function(n) {
    N6 && performance.mark(e(n));
  }, t.markEnd = function(n) {
    N6 && performance.mark(r(n));
  }, t.measure = function(n) {
    N6 && performance.measure("✳️ ".concat(n.name), e(n), r(n));
  };
})(Dm || (Dm = {}));
var tr, Lw, kw, dQ = function() {
  function t(e, r) {
    this.isSynchronous = !1, this.isExecuting = !0, this.lastUpdatedTime = 0, this.onChildrenFinished = void 0, this.node = r, this.info = e;
  }
  return t.prototype.checkAborted = function() {
    this.info.abortToken.abortRequested && (this.isAborted = !0, IN(this.info));
  }, Object.defineProperty(t.prototype, "shouldUpdate", { get: function() {
    return this.checkAborted(), wi() - this.lastUpdatedTime > this.info.updateRateMs;
  }, enumerable: !1, configurable: !0 }), t.prototype.updateProgress = function(e) {
    if (this.checkAborted(), e) {
      var r = this.node.progress;
      typeof e == "string" ? (r.message = e, r.isIndeterminate = !0) : (e.canAbort !== void 0 && (r.canAbort = e.canAbort), e.message !== void 0 && (r.message = e.message), e.current !== void 0 && (r.current = e.current), e.max !== void 0 && (r.max = e.max), r.isIndeterminate = r.current === void 0 || r.max === void 0, e.isIndeterminate !== void 0 && (r.isIndeterminate = e.isIndeterminate));
    }
  }, t.prototype.update = function(e, r) {
    if (this.lastUpdatedTime = wi(), this.updateProgress(e), !r) return MN(this.info, this.lastUpdatedTime), this.checkAborted(), q9.immediatePromise();
  }, t.prototype.runChild = function(e, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u, c;
      return ye(this, function(l) {
        switch (l.label) {
          case 0:
            this.updateProgress(r), n = { progress: wN(e), children: [] }, (i = this.node.children).push(n), a = new t(this.info, n), l.label = 1;
          case 1:
            return l.trys.push([1, 3, 4, 5]), [4, K9(e, a)];
          case 2:
            return [2, l.sent()];
          case 3:
            if (o = l.sent(), tr.isAbort(o) && this.isAborted) return [2, void 0];
            throw o;
          case 4:
            if ((s = i.indexOf(n)) >= 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];
        }
      });
    });
  }, t;
}(), hs = new (function() {
  function t() {
    this.shouldUpdate = !1, this.isSynchronous = !0;
  }
  return t.prototype.update = function(e, r) {
  }, t;
}())();
function Vm(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, s, u, c, l, d;
    return ye(this, function(f) {
      switch (f.label) {
        case 0:
          if (a = Math.max(e, 0), o = 0, s = 0, t.isSynchronous) return n(Number.MAX_SAFE_INTEGER, r), [2, r];
          u = wi(), c = 0, l = 0, f.label = 1;
        case 1:
          return (c = n(a, r)) > 0 ? (o += c, d = wi() - u, l += d, s += d, t.shouldUpdate ? [4, i(t, r, o)] : [3, 3]) : [3, 4];
        case 2:
          f.sent(), a = Math.round(l * o / s) + 1, u = wi(), l = 0, f.label = 3;
        case 3:
          return [3, 1];
        case 4:
          return t.shouldUpdate ? [4, i(t, r, o)] : [3, 6];
        case 5:
          f.sent(), f.label = 6;
        case 6:
          return [2, r];
      }
    });
  });
}
function zd(t, e) {
  return t[e] | t[e + 1] << 8;
}
function i0(t, e) {
  return 16777216 * t[e + 3] + (t[e + 2] << 16 | t[e + 1] << 8 | t[e]);
}
function fQ(t) {
  return t.length < 2 ? "0" + t : t;
}
function pQ(t, e, r) {
  for (var n, i = "", a = 0; a < r; a++) i += "%" + fQ(t[e + a].toString(16));
  try {
    n = decodeURIComponent(i);
  } catch {
    return function(s, u, c) {
      for (var l = "", d = 0; d < c; d++) l += String.fromCharCode(s[u + d]);
      return l;
    }(t, e, r);
  }
  return n;
}
(function(t) {
  var e = 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 ? cQ(this, o, s) : this.f(hs);
    }, a.prototype.runAsChild = function(o, s) {
      return o.isSynchronous ? this.f(hs) : function(u, c, l) {
        return u.runChild(c, l);
      }(o, this, s);
    }, a.prototype.runInContext = function(o) {
      return o.isSynchronous ? this.f(hs) : function(s, u) {
        return K9(u, s);
      }(o, this);
    }, a;
  }();
  function r(a) {
    var o = a;
    return !!a && typeof o.id == "number" && typeof o.name == "string" && !!o.run;
  }
  function n(a, o, s) {
    return new e(a, o, s);
  }
  t.is = r, t.isAbort = function(a) {
    return !!a && !!a.isAborted;
  }, t.Aborted = function(a) {
    return { isAborted: !0, reason: a, toString: function() {
      return "Aborted".concat(a ? ": " + a : "");
    } };
  }, t.create = n, t.constant = function(a, o) {
    var s = this;
    return n(a, function(u) {
      return _e(s, 0, void 0, function() {
        return ye(this, function(c) {
          return [2, o];
        });
      });
    });
  }, t.empty = function() {
    var a = this;
    return n("", function(o) {
      return _e(a, 0, void 0, function() {
        return ye(this, function(s) {
          return [2];
        });
      });
    });
  }, t.fail = function(a, o) {
    var s = this;
    return n(a, function(u) {
      return _e(s, 0, void 0, function() {
        return ye(this, function(c) {
          throw new Error(o);
        });
      });
    });
  }, t.resolveInContext = function(a, o) {
    return r(a) ? o ? a.runInContext(o) : a.run() : a;
  };
  var i = io(0, 1073741823);
})(tr || (tr = {})), function(t) {
  t.Synchronous = hs;
}(Lw || (Lw = {})), function(t) {
  function e(r, n) {
    n === void 0 && (n = "");
    var i = r.progress;
    if (!r.children.length) return i.isIndeterminate ? "".concat(n).concat(i.taskName, ": ").concat(i.message) : "".concat(n).concat(i.taskName, ": [").concat(i.current, "/").concat(i.max, "] ").concat(i.message);
    var a = n + "  |_ ", o = r.children.map(function(s) {
      return e(s, a);
    });
    return i.isIndeterminate ? "".concat(n).concat(i.taskName, ": ").concat(i.message, `
`).concat(o.join(`
`)) : "".concat(n).concat(i.taskName, ": [").concat(i.current, "/").concat(i.max, "] ").concat(i.message, `
`).concat(o.join(`
`));
  }
  t.format = function(r) {
    return e(r.root);
  };
}(kw || (kw = {}));
var hQ = function() {
  for (var t = new Uint32Array(256), e = 0; e < 256; e++) {
    for (var r = e, n = 0; n < 8; n++) 1 & r ? r = 3988292384 ^ r >>> 1 : r >>>= 1;
    t[e] = r;
  }
  return t;
}();
function mQ(t, e, r) {
  return 4294967295 ^ function(n, i, a, o) {
    for (var s = 0; s < o; s++) n = hQ[255 & (n ^ i[a + s])] ^ n >>> 8;
    return n;
  }(4294967295, t, e, r);
}
var Bs, y1, jt = (Bs = Uint16Array, y1 = Uint32Array, { next_code: new Bs(16), bl_count: new Bs(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 Bs(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 y1(32), flmap: new Bs(512), fltree: [], fdmap: new Bs(32), fdtree: [], lmap: new Bs(32768), ltree: [], ttree: [], dmap: new Bs(32768), dtree: [], imap: new Bs(512), itree: [], rev15: new Bs(32768), lhst: new y1(286), dhst: new y1(30), ihst: new y1(19), lits: new y1(15e3), strt: new Bs(65536), prev: new Bs(32768) });
function Em(t, e, r) {
  for (var n = t.length, i = jt.rev15, a = 0; a < n; a += 2) if (t[a + 1] !== 0) for (var o = a >> 1, s = t[a + 1], u = o << 4 | s, c = e - s, l = t[a] << c, d = l + (1 << c); l !== d; )
    r[i[l] >>> 15 - e] = u, l++;
}
function Im(t, e) {
  for (var r = t.length, n = jt.bl_count, i = 0; i <= e; i++) n[i] = 0;
  for (i = 1; i < r; i += 2) n[t[i]]++;
  var a = jt.next_code, o = 0;
  n[0] = 0;
  for (var s = 1; s <= e; s++) o = o + n[s - 1] << 1, a[s] = o;
  for (var u = 0; u < r; u += 2) {
    var c = t[u + 1];
    c !== 0 && (t[u] = a[c], a[c]++);
  }
}
function Gw(t, e) {
  for (var r = jt.rev15, n = 15 - e, i = 0; i < t.length; i += 2) {
    var a = t[i] << e - t[i + 1];
    t[i] = r[a] >>> n;
  }
}
function gQ(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          if (e[0] === 3 && e[1] === 0) return [2, r || new Uint8Array(0)];
          n = 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 };
          }(e, r), i.label = 1;
        case 1:
          return n.BFINAL !== 0 ? [3, 4] : t.shouldUpdate ? [4, t.update({ message: "Inflating blocks...", current: n.pos, max: e.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, f = a.pos, h = 0; l === 0 && h < o; ) {
              var m = void 0, p = void 0, v = 0, g = 0;
              l = O6(s, f, 1), h += 1;
              var y = O6(s, f + 1, 2);
              if (f += 3, y !== 0) {
                if (u && (c = R6(c, d + (1 << 17))), y === 1) m = jt.flmap, p = jt.fdmap, v = 511, g = 31;
                else {
                  if (y !== 2) throw new Error("unknown BTYPE ".concat(y));
                  var b = Pd(s, f, 5) + 257, S = Pd(s, f + 5, 5) + 1, _ = Pd(s, f + 10, 4) + 4;
                  f += 14;
                  for (var x = 0; x < 38; x += 2) jt.itree[x] = 0, jt.itree[x + 1] = 0;
                  var C = 1;
                  for (x = 0; x < _; x++) {
                    var A = Pd(s, f + 3 * x, 3);
                    jt.itree[1 + (jt.ordr[x] << 1)] = A, A > C && (C = A);
                  }
                  f += 3 * _, Im(jt.itree, C), Em(jt.itree, C, jt.imap), m = jt.lmap, p = jt.dmap, f = vQ(jt.imap, (1 << C) - 1, b + S, s, f, jt.ttree);
                  var w = zw(jt.ttree, 0, b, jt.ltree);
                  v = (1 << w) - 1;
                  var I = zw(jt.ttree, b, S, jt.dtree);
                  g = (1 << I) - 1, Im(jt.ltree, w), Em(jt.ltree, w, m), Im(jt.dtree, I), Em(jt.dtree, I, p);
                }
                for (; ; ) {
                  var P = m[M_(s, f) & v];
                  f += 15 & P;
                  var M = P >>> 4;
                  if (!(M >>> 8)) c[d++] = M;
                  else {
                    if (M === 256) break;
                    var T = d + M - 254;
                    if (M > 264) {
                      var F = jt.ldef[M - 257];
                      T = d + (F >>> 3) + Pd(s, f, 7 & F), f += 7 & F;
                    }
                    var N = p[M_(s, f) & g];
                    f += 15 & N;
                    var R = N >>> 4, L = jt.ddef[R], V = (L >>> 4) + O6(s, f, 15 & L);
                    for (f += 15 & L, u && (c = R6(c, d + (1 << 17))); d < T; ) c[d] = c[d++ - V], c[d] = c[d++ - V], c[d] = c[d++ - V], c[d] = c[d++ - V];
                    d = T;
                  }
                }
              } else {
                7 & f && (f += 8 - (7 & f));
                var U = 4 + (f >>> 3), H = s[U - 4] | s[U - 3] << 8;
                u && (c = R6(c, d + H)), c.set(new Uint8Array(s.buffer, s.byteOffset + U, H), d), f = U + H << 3, d += H;
              }
            }
            a.buf = c, a.BFINAL = l, a.off = d, a.pos = f;
          }(n, 100), [3, 1];
        case 4:
          return [2, n.buf.length === n.off ? n.buf : n.buf.slice(0, n.off)];
      }
    });
  });
}
function R6(t, e) {
  var r = t.length;
  if (e <= r) return t;
  var n = new Uint8Array(Math.max(r << 1, e));
  return n.set(t, 0), n;
}
function vQ(t, e, r, n, i, a) {
  for (var o = 0; o < r; ) {
    var s = t[M_(n, i) & e];
    i += 15 & s;
    var u = s >>> 4;
    if (u <= 15) a[o] = u, o++;
    else {
      var c = 0, l = 0;
      u === 16 ? (l = 3 + Pd(n, i, 2), i += 2, c = a[o - 1]) : u === 17 ? (l = 3 + Pd(n, i, 3), i += 3) : u === 18 && (l = 11 + Pd(n, i, 7), i += 7);
      for (var d = o + l; o < d; ) a[o] = c, o++;
    }
  }
  return i;
}
function zw(t, e, r, n) {
  for (var i = 0, a = 0, o = n.length >>> 1; a < r; ) {
    var s = t[a + e];
    n[a << 1] = 0, n[1 + (a << 1)] = s, s > i && (i = s), a++;
  }
  for (; a < o; ) n[a << 1] = 0, n[1 + (a << 1)] = 0, a++;
  return i;
}
function Pd(t, e, r) {
  return (t[e >>> 3] | t[1 + (e >>> 3)] << 8) >>> (7 & e) & (1 << r) - 1;
}
function O6(t, e, r) {
  return (t[e >>> 3] | t[1 + (e >>> 3)] << 8 | t[2 + (e >>> 3)] << 16) >>> (7 & e) & (1 << r) - 1;
}
function M_(t, e) {
  return (t[e >>> 3] | t[1 + (e >>> 3)] << 8 | t[2 + (e >>> 3)] << 16) >>> (7 & e);
}
function PN(t, e, r) {
  return r === void 0 && (r = !1), _e(this, 0, void 0, function() {
    var n, i, a, o, s, u, c, l, d, f, h, m, p;
    return ye(this, function(v) {
      switch (v.label) {
        case 0:
          for (n = /* @__PURE__ */ Object.create(null), i = new Uint8Array(e), a = i.length - 4; i0(i, a) !== 101010256; ) a--;
          o = a, o += 4, s = zd(i, o += 4), o += 2, o += 2, u = i0(i, o += 4), o += 4, o = u, c = 0, v.label = 1;
        case 1:
          return c < s ? (o += 4, o += 4, o += 4, o += 4, l = i0(i, o += 4), d = i0(i, o += 4), f = zd(i, o += 4), h = zd(i, o + 2), m = zd(i, o + 4), o += 6, p = i0(i, o += 8), o += 4, o += f + h + m, [4, yQ(t, i, p, n, l, d, r)]) : [3, 4];
        case 2:
          v.sent(), v.label = 3;
        case 3:
          return c++, [3, 1];
        case 4:
          return [2, n];
      }
    });
  });
}
function yQ(t, e, r, n, i, a, o) {
  return _e(this, 0, void 0, function() {
    var s, u, c, l, d, f;
    return ye(this, function(h) {
      switch (h.label) {
        case 0:
          return r += 4, r += 2, s = zd(e, r += 2), r += 2, r += 4, r += 4, u = zd(e, r += 8), c = zd(e, r += 2), l = pQ(e, r += 2, u), r += u, r += c, o ? (n[l] = { size: a, csize: i }, [2]) : (d = new Uint8Array(e.buffer, r), s !== 0 ? [3, 1] : (n[l] = new Uint8Array(d.buffer.slice(r, r + i)), [3, 4]));
        case 1:
          return s !== 8 ? [3, 3] : (f = new Uint8Array(a), [4, BN(t, d, f)]);
        case 2:
          return h.sent(), n[l] = f, [3, 4];
        case 3:
          throw new Error("unknown compression method: ".concat(s));
        case 4:
          return [2];
      }
    });
  });
}
function BN(t, e, r) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(n) {
      return [2, gQ(t, e, r)];
    });
  });
}
function bQ(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, s, u, c, l, d;
    return ye(this, function(f) {
      switch (f.label) {
        case 0:
          if (n = e[3], i = 10, 4 & n && (a = zd(e, i), i += a), 8 & n) {
            for (o = i; e[o] !== 0; ) ++o;
            i = o + 1;
          }
          if (16 & n) {
            for (o = i; e[o] !== 0; ) ++o;
            i = o + 1;
          }
          return 1 & n && (i += 2), s = function(h) {
            return 0 | h;
          }(i0(e, e.length - 8)), u = i0(e, e.length - 4), r === void 0 && (r = new Uint8Array(u)), c = new Uint8Array(e.buffer, e.byteOffset + i, e.length - i - 8), [4, BN(t, c, r)];
        case 1:
          return l = f.sent(), d = mQ(l, 0, l.length), s !== d && console.error("ungzip: checksums don't match"), [2, l];
      }
    });
  });
}
function Rg(t, e, r) {
  for (var n = 0, i = r.length; n < i; n++) {
    var a = r.charCodeAt(n);
    if (a < 128) t[e++] = a >>> 0 & 127;
    else if (a < 2048) t[e++] = a >>> 6 & 31 | 192, t[e++] = a >>> 0 & 63 | 128;
    else if (a < 65536) t[e++] = a >>> 12 & 15 | 224, t[e++] = a >>> 6 & 63 | 128, t[e++] = a >>> 0 & 63 | 128;
    else {
      if (!(a < 1114112)) throw new Error("bad codepoint " + a);
      t[e++] = a >>> 18 & 7 | 240, t[e++] = a >>> 12 & 63 | 128, t[e++] = a >>> 6 & 63 | 128, t[e++] = a >>> 0 & 63 | 128;
    }
  }
}
(function() {
  for (var t = 0; t < 32768; t++) {
    var e = t;
    e = (4278255360 & (e = (4042322160 & (e = (3435973836 & (e = (2863311530 & e) >>> 1 | (1431655765 & e) << 1)) >>> 2 | (858993459 & e) << 2)) >>> 4 | (252645135 & e) << 4)) >>> 8 | (16711935 & e) << 8, jt.rev15[t] = (e >>> 16 | e << 16) >>> 17;
  }
  function r(n, i, a) {
    for (; i-- != 0; ) n.push(0, a);
  }
  for (t = 0; t < 32; t++) jt.ldef[t] = jt.of0[t] << 3 | jt.exb[t], jt.ddef[t] = jt.df0[t] << 4 | jt.dxb[t];
  r(jt.fltree, 144, 8), r(jt.fltree, 112, 9), r(jt.fltree, 24, 7), r(jt.fltree, 8, 8), Im(jt.fltree, 9), Em(jt.fltree, 9, jt.flmap), Gw(jt.fltree, 9), r(jt.fdtree, 32, 5), Im(jt.fdtree, 5), Em(jt.fdtree, 5, jt.fdmap), Gw(jt.fdtree, 5), r(jt.itree, 19, 0), r(jt.ltree, 286, 0), r(jt.dtree, 30, 0), r(jt.ttree, 320, 0);
})();
var _Q = function() {
  for (var t = [], e = 0; e < 1024; e++) t[e] = String.fromCharCode(e);
  return t;
}();
function FN(t) {
  throw new Error(t);
}
var Vw = typeof TextDecoder < "u" ? new TextDecoder() : void 0;
function NN(t, e, r) {
  if (Vw) {
    var n = e || r !== t.length ? t.subarray(e, e + r) : t;
    return Vw.decode(n);
  }
  return function(i, a, o) {
    for (var s = _Q, u = void 0, c = 0, l = [], d = a, f = a + o; d < f; d++) {
      var h = i[d];
      128 & h ? (224 & h) == 192 ? l[c++] = s[(15 & h) << 6 | 63 & i[++d]] : (240 & h) == 224 ? l[c++] = String.fromCharCode((15 & h) << 12 | (63 & i[++d]) << 6 | 63 & i[++d]) : (248 & h) == 240 ? l[c++] = String.fromCharCode((7 & h) << 18 | (63 & i[++d]) << 12 | (63 & i[++d]) << 6 | 63 & i[++d]) : FN("Invalid byte " + h.toString(16)) : l[c++] = s[h], 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("");
  }(t, e, r);
}
function RN(t) {
  for (var e = 0, r = 0, n = t.length; r < n; r++) {
    var i = t.charCodeAt(r);
    i < 128 ? e += 1 : i < 2048 ? e += 2 : i < 65536 ? e += 3 : i < 1114112 ? e += 4 : FN("bad codepoint " + i);
  }
  return e;
}
var Tu, xQ = XMLHttpRequest;
function Og(t, e) {
  return function(r, n) {
    var i = this, a = void 0;
    return tr.create("Read File", function(o) {
      return _e(i, 0, void 0, function() {
        var s, u;
        return ye(this, function(c) {
          switch (c.label) {
            case 0:
              return c.trys.push([0, , 5, 6]), a = new FileReader(), s = n === "zip" ? Tu.None : (l = r.name, /\.gz$/i.test(l) ? Tu.Gzip : /\.zip$/i.test(l) ? Tu.Zip : Tu.None), n === "binary" || n === "zip" || s !== Tu.None ? a.readAsArrayBuffer(r) : a.readAsText(r), [4, o.update({ message: "Opening file...", canAbort: !0 })];
            case 1:
              return c.sent(), [4, ON(o, "Reading...", a)];
            case 2:
              return u = c.sent(), [4, o.update({ message: "Processing file...", canAbort: !1 })];
            case 3:
              return c.sent(), [4, AQ(o, u, n, s)];
            case 4:
              return [2, c.sent()];
            case 5:
              return a = void 0, [7];
            case 6:
              return [2];
          }
          var l;
        });
      });
    }, function() {
      a && a.abort();
    });
  }(t, e);
}
function Uw(t) {
  return typeof t == "string" ? qw(t, t, "string") : qw(t.title, t.url, t.type || "string", t.body, t.headers);
}
function Hw(t) {
  return t ? "Failed to download data. Possible reasons: Resource is not available, or CORS is not allowed on the server." : "Failed to open file.";
}
function ON(t, e, r) {
  return new Promise(function(n, 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");
    }(r)) {
      var a = r.error;
      a != null ? i(a ?? Hw(r instanceof XMLHttpRequest)) : n(r);
    } else {
      var o = !1;
      r.onerror = function(s) {
        if (!o) {
          var u = s.target.error;
          i(u ?? Hw(r instanceof XMLHttpRequest));
        }
      }, r.onprogress = function(s) {
        if (t.shouldUpdate && !o) try {
          s.lengthComputable ? t.update({ message: e, isIndeterminate: !1, current: s.loaded, max: s.total }) : t.update({ message: "".concat(e, " ").concat((s.loaded / 1024 / 1024).toFixed(2), " MB"), isIndeterminate: !0 });
        } catch (u) {
          o = !0, i(u);
        }
      }, r.onload = function(s) {
        n(r);
      };
    }
  });
}
(function(t) {
  t[t.None = 0] = "None", t[t.Gzip = 1] = "Gzip", t[t.Zip = 2] = "Zip";
})(Tu || (Tu = {}));
var SQ = /^(__MACOSX|.DS_Store)/;
function CQ(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          switch (r) {
            case Tu.None:
              return [3, 1];
            case Tu.Gzip:
              return [3, 2];
            case Tu.Zip:
              return [3, 3];
          }
          return [3, 5];
        case 1:
          return [2, e];
        case 2:
          return [2, bQ(t, e)];
        case 3:
          return [4, PN(t, e.buffer)];
        case 4:
          if (n = a.sent(), i = Object.keys(n).filter(function(o) {
            return !SQ.test(o);
          }), i.length !== 1) throw new Error("can only decompress zip files with a single entry");
          return [2, n[i[0]]];
        case 5:
          return [2];
      }
    });
  });
}
function AQ(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          if (i = e.result, (a = i instanceof ArrayBuffer ? new Uint8Array(i) : i) === null) throw new Error("no data given");
          if (n === Tu.None) return [3, 4];
          if (!(a instanceof Uint8Array)) throw new Error("need Uint8Array for decompression");
          return [4, CQ(t, a, n)];
        case 1:
          return o = s.sent(), r !== "string" ? [3, 3] : [4, t.update({ message: "Decoding text..." })];
        case 2:
          return s.sent(), a = NN(o, 0, o.length), [3, 4];
        case 3:
          a = o, s.label = 4;
        case 4:
          return r === "binary" && a instanceof Uint8Array ? [2, a] : [3, 5];
        case 5:
          return r === "zip" && a instanceof Uint8Array ? [4, PN(t, a.buffer)] : [3, 7];
        case 6:
          return [2, s.sent()];
        case 7:
          if (r === "string" && typeof a == "string") return [2, a];
          if (r === "xml" && typeof a == "string") return [2, new DOMParser().parseFromString(a, "application/xml")];
          if (r === "json" && typeof a == "string") return [2, JSON.parse(a)];
          s.label = 8;
        case 8:
          throw new Error("could not get requested response data '".concat(r, "'"));
      }
    });
  });
}
var Au, L6 = function() {
  function t() {
  }
  return t.get = function() {
    return this.pool.length ? this.pool.pop() : new xQ();
  }, t.emptyFunc = function() {
  }, t.deposit = function(e) {
    this.pool.length < this.poolSize && (e.onabort = t.emptyFunc, e.onerror = t.emptyFunc, e.onload = t.emptyFunc, e.onprogress = t.emptyFunc, this.pool.push(e));
  }, t.pool = [], t.poolSize = 15, t;
}();
function qw(t, e, r, n, i) {
  var a = this, o = void 0;
  return tr.create(t || "Download", function(s) {
    return _e(a, 0, void 0, function() {
      var u, c, l, d, f, h, m;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            if ((o = L6.get()).open(n ? "post" : "get", e, !0), i) for (u = 0, c = i; u < c.length; u++) l = c[u], d = l[0], f = l[1], o.setRequestHeader(d, f);
            return o.responseType = function(v) {
              switch (v) {
                case "json":
                  return "json";
                case "xml":
                  return "document";
                case "string":
                  return "text";
                case "binary":
                case "zip":
                  return "arraybuffer";
              }
            }(r), o.send(n), [4, s.update({ message: "Waiting for server...", canAbort: !0 })];
          case 1:
            return p.sent(), [4, ON(s, "Downloading...", o)];
          case 2:
            return h = p.sent(), o = void 0, [4, s.update({ message: "Parsing response...", canAbort: !1 })];
          case 3:
            return p.sent(), m = function(v, g) {
              if (v.status >= 200 && v.status < 400) {
                var y = v.response;
                if (L6.deposit(v), (g === "binary" || g === "zip") && y instanceof ArrayBuffer) return new Uint8Array(y);
                if (g === "string" && typeof y == "string" || g === "xml" && y instanceof XMLDocument || g === "json" && typeof y == "object") return y;
                throw new Error("could not get requested response data '".concat(g, "'"));
              }
              throw L6.deposit(v), new Error("Download failed with status code ".concat(v.status));
            }(h, r), [2, m];
        }
      });
    });
  }, function() {
    o && (o.abort(), o = void 0);
  });
}
(function(t) {
  function e(r, n) {
    return O({ kind: "url", id: Ki.create22(), url: r }, n);
  }
  t.Url = e, t.File = function(r) {
    return { kind: "file", id: Ki.create22(), name: r.name, file: r };
  }, t.isUrl = function(r) {
    return (r == null ? void 0 : r.kind) === "url";
  }, t.isFile = function(r) {
    return (r == null ? void 0 : r.kind) === "file";
  }, t.Wrapper = function(r, n, i) {
    return { data: r, dispose: function() {
      i.release(n);
    } };
  }, t.getUrl = function(r) {
    return typeof r == "string" ? r : r.url;
  }, t.getUrlAsset = function(r, n, i) {
    return typeof n == "string" ? r.tryFindUrl(n, i) || e(n, { body: i }) : n;
  };
})(Au || (Au = {}));
var z, pl = function() {
  function t() {
    this._assets = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(t.prototype, "assets", { get: function() {
    return k9(this._assets.values());
  }, enumerable: !1, configurable: !0 }), t.prototype.tryFindUrl = function(e, r) {
    for (var n = this.assets.values(); ; ) {
      var i = n.next();
      if (i.done) return;
      var a = i.value.asset;
      if (Au.isUrl(a) && a.url === e && (a.body || "") === (r || "")) return a;
    }
  }, t.prototype.set = function(e, r) {
    this._assets.set(e.id, { asset: e, file: r, refCount: 0 });
  }, t.prototype.get = function(e) {
    return this._assets.get(e);
  }, t.prototype.remove = function(e) {
    this._assets.delete(e);
  }, t.prototype.resolve = function(e, r, n) {
    var i = this;
    return n === void 0 && (n = !0), Au.isUrl(e) ? tr.create("Download ".concat(e.title || e.url), function(a) {
      return _e(i, 0, void 0, function() {
        var o, s, u, c, l, d, f, h, m;
        return ye(this, function(p) {
          switch (p.label) {
            case 0:
              return this._assets.has(e.id) ? ((o = this._assets.get(e.id)).refCount++, u = (s = Au).Wrapper, [4, Og(o.file, r).runInContext(a)]) : [3, 2];
            case 1:
              return [2, u.apply(s, [p.sent(), e, this])];
            case 2:
              return n ? [3, 4] : (l = (c = Au).Wrapper, [4, Uw(O(O({}, e), { type: r })).runInContext(a)]);
            case 3:
              return [2, l.apply(c, [p.sent(), e, this])];
            case 4:
              return [4, Uw(O(O({}, e), { type: "binary" })).runInContext(a)];
            case 5:
              return d = p.sent(), f = new File([d], "raw-data"), this._assets.set(e.id, { asset: e, file: f, refCount: 1 }), m = (h = Au).Wrapper, [4, Og(f, r).runInContext(a)];
            case 6:
              return [2, m.apply(h, [p.sent(), e, this])];
          }
        });
      });
    }) : tr.create("Read ".concat(e.name), function(a) {
      return _e(i, 0, void 0, function() {
        var o, s, u, c, l;
        return ye(this, function(d) {
          switch (d.label) {
            case 0:
              return this._assets.has(e.id) ? (o = this._assets.get(e.id), e.file = o.file, o.refCount++, u = (s = Au).Wrapper, [4, Og(o.file, r).runInContext(a)]) : [3, 2];
            case 1:
              return [2, u.apply(s, [d.sent(), e, this])];
            case 2:
              if (!(e.file instanceof File)) throw new Error("Cannot resolve file asset '".concat(e.name, "' (").concat(e.id, ")"));
              return n && this._assets.set(e.id, { asset: e, file: e.file, refCount: 1 }), l = (c = Au).Wrapper, [4, Og(e.file, r).runInContext(a)];
            case 3:
              return [2, l.apply(c, [d.sent(), e, this])];
          }
        });
      });
    });
  }, t.prototype.release = function(e) {
    var r = this._assets.get(e.id);
    r && (r.refCount--, r.refCount <= 0 && this._assets.delete(e.id));
  }, t;
}();
function w3(t) {
  for (var e = -1 / 0, r = 0, n = t.length; r < n; ++r) t[r] > e && (e = t[r]);
  return e;
}
function wQ(t) {
  for (var e = 1 / 0, r = 0, n = t.length; r < n; ++r) t[r] < e && (e = t[r]);
  return e;
}
function os(t) {
  for (var e = 1 / 0, r = -1 / 0, n = 0, i = t.length; n < i; ++n) t[n] < e && (e = t[n]), t[n] > r && (r = t[n]);
  return [e, r];
}
function e3(t, e, r) {
  e === void 0 && (e = 1), r === void 0 && (r = 0);
  for (var n = t.length, i = 0, a = r; a < n; a += e) i += t[a];
  return i;
}
function DQ(t, e, r) {
  return e === void 0 && (e = 1), r === void 0 && (r = 0), e3(t, e, r) / (t.length / e);
}
function EQ(t) {
  for (var e = t.length, r = 0, n = 0; n < e; ++n) {
    var i = t[n];
    r += i * i;
  }
  return Math.sqrt(r / e);
}
function xc(t, e) {
  for (var r = 0, n = e ? Math.min(e, t.length) : t.length; r < n; ++r) t[r] = r;
  return t;
}
function Qs(t, e) {
  return !(t.indexOf(e) >= 0) && (t.push(e), !0);
}
function t3(t, e) {
  var r = t.indexOf(e);
  if (r < 0) return !1;
  for (var n = r, i = t.length - 1; n < i; n++) t[n] = t[n + 1];
  return t.pop(), !0;
}
function D3(t, e) {
  for (var r = 0, n = 0, i = t.length; n < i; ++n) e.includes(t[n]) && (r += 1);
  return r;
}
(function(t) {
  function e(_, x) {
    return x && (x.label && (_.label = x.label), x.description && (_.description = x.description), x.legend && (_.legend = x.legend), x.fieldLabels && (_.fieldLabels = x.fieldLabels), x.isHidden && (_.isHidden = x.isHidden), x.shortLabel && (_.shortLabel = x.shortLabel), x.twoColumns && (_.twoColumns = x.twoColumns), x.isEssential && (_.isEssential = x.isEssential), x.category && (_.category = x.category), x.hideIf && (_.hideIf = x.hideIf), x.help && (_.help = x.help)), _;
  }
  function r(_, x, C) {
    return e({ type: "select", defaultValue: S(_, x), options: x, cycle: C == null ? void 0 : C.cycle }, C);
  }
  function n(_, x) {
    return x && (x.min !== void 0 && (_.min = x.min), x.max !== void 0 && (_.max = x.max), x.step !== void 0 && (_.step = x.step)), _;
  }
  function i(_, x) {
    var C = e({ type: "group", defaultValue: (x == null ? void 0 : x.customDefault) || s(_), params: _ }, x);
    return x != null && x.presets && (C.presets = x.presets), x != null && x.isExpanded && (C.isExpanded = x.isExpanded), x != null && x.isFlat && (C.isFlat = x.isFlat), x != null && x.pivot && (C.pivot = x.pivot), C;
  }
  function a() {
    return s(this.element);
  }
  function o() {
    throw new Error("getValue not set. Fix runtime.");
  }
  function s(_) {
    for (var x = {}, C = 0, A = Object.keys(_); C < A.length; C++) {
      var w = A[C];
      _[w].isOptional || (x[w] = _[w].defaultValue);
    }
    return x;
  }
  function u(_, x) {
    return function() {
      return _(x);
    };
  }
  function c(_, x, C) {
    if (x) {
      if (_.type === "value-ref") (A = x).ref ? A.getValue = u(_.resolveRef, A.ref) : A.getValue = function() {
        throw new Error("Unset ref in ValueRef value.");
      };
      else if (_.type === "data-ref")
        (A = x).ref ? A.getValue = u(C, A.ref) : A.getValue = function() {
          throw new Error("Unset ref in ValueRef value.");
        };
      else if (_.type === "group") f(_.params, x, C);
      else if (_.type === "mapped") {
        var A = x;
        c(_.map(A.name), A.params, C);
      } else if (_.type === "object-list") {
        if (!d(_.element)) return;
        for (var w = 0, I = x; w < I.length; w++) {
          var P = I[w];
          f(_.element, P, C);
        }
      }
    }
  }
  function l(_) {
    if (_.type === "value-ref" || _.type === "data-ref") return !0;
    if (_.type === "group") {
      if (d(_.params)) return !0;
    } else if (_.type === "mapped") for (var x = 0, C = _.select.options; x < C.length; x++) {
      var A = C[x][0];
      if (l(_.map(A))) return !0;
    }
    else if (_.type === "object-list") return d(_.element);
    return !1;
  }
  function d(_) {
    for (var x = 0, C = Object.keys(_); x < C.length; x++)
      if (l(_[C[x]])) return !0;
    return !1;
  }
  function f(_, x, C) {
    for (var A = 0, w = Object.keys(_); A < w.length; A++) {
      var I = w[A];
      c(_[I], x == null ? void 0 : x[I], C);
    }
  }
  function h(_, x, C) {
    if (x === C) return !0;
    if (typeof x != "object" || typeof C != "object") return !1;
    for (var A = 0, w = Object.keys(_); A < w.length; A++) {
      var I = w[A];
      if (!m(_[I], x[I], C[I])) return !1;
    }
    return !0;
  }
  function m(_, x, C) {
    if (x === C) return !0;
    if (_.type === "group") return h(_.params, x, C);
    if (_.type === "mapped") {
      var A = C;
      return (M = x).name === A.name && m(_.map(M.name), M.params, A.params);
    }
    if (_.type === "multi-select") {
      if (A = C, (M = x).length !== A.length) return !1;
      if (M.length < 10) {
        for (var w = 0, I = M.length; w < I; w++) if (M[w] !== A[w] && A.indexOf(M[w]) < 0) return !1;
      } else {
        var P = new Set(A);
        for (w = 0, I = M.length; w < I; w++) if (M[w] !== A[w] && !P.has(M[w])) return !1;
      }
      return !0;
    }
    if (_.type === "interval") return x[0] === C[0] && x[1] === C[1];
    if (_.type === "line-graph") {
      if (A = C, (M = x).length !== A.length) return !1;
      for (w = 0, I = M.length; w < I; w++) if (!ze.areEqual(M[w], A[w])) return !1;
      return !0;
    }
    if (_.type === "vec3") return E.equals(x, C);
    if (_.type === "mat4") return he.areEqual(x, C, Cn);
    if (_.type === "script")
      return A = C, (M = x).language === A.language && M.expression === A.expression;
    if (_.type === "object-list") {
      A = C;
      var M, T = (M = x).length;
      if (T !== A.length) return !1;
      for (w = 0; w < T; w++) if (!h(_.element, M[w], A[w])) return !1;
      return !0;
    }
    return typeof x == "object" && typeof C == "object" && xN(x, C);
  }
  function p(_, x, C) {
    if (x === void 0) return O({}, C);
    if (C === void 0) return O({}, x);
    for (var A = /* @__PURE__ */ Object.create(null), w = 0, I = Object.keys(_); w < I.length; w++) {
      var P = I[w];
      A[P] = v(_[P], x[P], C[P]);
    }
    return A;
  }
  function v(_, x, C) {
    if (x === void 0) return typeof C != "object" || Array.isArray(C) ? C : O({}, C);
    if (C === void 0) return typeof x != "object" || Array.isArray(x) ? x : O({}, x);
    if (_.type === "group") return p(_.params, x, C);
    if (_.type === "mapped") {
      var A = x, w = C;
      if (A.name !== w.name) return O({}, w);
      var I = _.map(w.name);
      return { name: w.name, params: v(I, A.params, w.params) };
    }
    return _.type === "value" ? C : typeof x == "object" && typeof C == "object" ? Array.isArray(C) ? C : O(O({}, x), C) : C;
  }
  function g(_, x) {
    for (var C = 0, A = _.options; C < A.length; C++)
      if (A[C][0] === x) return !0;
    return !1;
  }
  function y(_, x, C) {
    if (x == null) return C ? _.defaultValue : void 0;
    if (_.type === "value") return x;
    if (_.type === "group") {
      for (var A = /* @__PURE__ */ Object.create(null), w = 0, I = Object.keys(_.params); w < I.length; w++) {
        var P = I[w], M = _.params[P];
        x[P] === void 0 ? C && (A[P] = M.defaultValue) : A[P] = y(M, x[P], C);
      }
      return A;
    }
    if (_.type === "mapped") {
      var T = x;
      return typeof T.name != "string" ? _.defaultValue : T.params === void 0 ? C ? _.defaultValue : void 0 : g(_.select, T.name) ? (M = _.map(T.name), { name: T.name, params: y(M, T.params, C) }) : _.defaultValue;
    }
    return _.type === "select" ? g(_, x) ? x : _.defaultValue : _.type === "multi-select" ? Array.isArray(x) ? (A = x.filter(function(F) {
      return g(this, F);
    }, _), x.length > 0 && A.length === 0 ? _.defaultValue : A) : _.defaultValue : _.type === "object-list" ? Array.isArray(x) ? x.map(function(F) {
      return b(_.element, F, C ? "all" : "skip");
    }) : _.defaultValue : x;
  }
  function b(_, x, C) {
    if (typeof x != "object" || x === null) return C ? s(_) : x;
    for (var A = /* @__PURE__ */ Object.create(null), w = 0, I = Object.keys(_); w < I.length; w++) {
      var P = I[w], M = _[P];
      x[P] === void 0 ? C === "all" && (A[P] = M.defaultValue) : A[P] = y(M, x[P], C !== "skip");
    }
    return A;
  }
  function S(_, x) {
    for (var C = 0, A = x; C < A.length; C++)
      if (A[C][0] === _) return _;
    return x.length > 0 ? x[0][0] : void 0;
  }
  t.Essential = { isEssential: !0 }, t.Optional = function(_) {
    var x = O({}, _);
    return x.isOptional = !0, x;
  }, t.Value = function(_, x) {
    return e({ type: "value", defaultValue: _ }, x);
  }, t.Select = r, t.MultiSelect = function(_, x, C) {
    var A = e({ type: "multi-select", defaultValue: _, options: x }, C);
    return C != null && C.emptyValue && (A.emptyValue = C.emptyValue), A;
  }, t.Boolean = function(_, x) {
    return e({ type: "boolean", defaultValue: _ }, x);
  }, t.Text = function(_, x) {
    return _ === void 0 && (_ = ""), e({ type: "text", defaultValue: _ }, x);
  }, t.Color = function(_, x) {
    var C = e({ type: "color", defaultValue: _ }, x);
    return x != null && x.isExpanded && (C.isExpanded = x.isExpanded), C;
  }, t.ColorList = function(_, x) {
    var C;
    if (typeof _ == "string") {
      var A = Cl(_);
      C = { kind: A.type !== "qualitative" ? "interpolate" : "set", colors: A.list };
    } else C = _;
    return e({ type: "color-list", presetKind: (x == null ? void 0 : x.presetKind) || "all", defaultValue: C, offsets: !!(x != null && x.offsets) }, x);
  }, t.Vec3 = function(_, x, C) {
    return e(n({ type: "vec3", defaultValue: _ }, x), C);
  }, t.Mat4 = function(_, x) {
    return e({ type: "mat4", defaultValue: _ }, x);
  }, t.Url = function(_, x) {
    return e({ type: "url", defaultValue: typeof _ == "string" ? Au.Url(_) : Au.Url(_.url, { body: _.body }) }, x);
  }, t.File = function(_) {
    var x = e({ type: "file", defaultValue: null }, _);
    return _ != null && _.accept && (x.accept = _.accept), x;
  }, t.FileList = function(_) {
    var x = e({ type: "file-list", defaultValue: null }, _);
    return _ != null && _.accept && (x.accept = _.accept), x;
  }, t.Numeric = function(_, x, C) {
    var A = e(n({ type: "number", defaultValue: _ }, x), C);
    return C != null && C.immediateUpdate && (A.immediateUpdate = !0), A;
  }, t.Interval = function(_, x, C) {
    return e(n({ type: "interval", defaultValue: _ }, x), C);
  }, t.LineGraph = function(_, x) {
    return e({ type: "line-graph", defaultValue: _ }, x);
  }, t.Group = i, t.EmptyGroup = function(_) {
    return i({}, _);
  }, t.Mapped = function(_, x, C, A) {
    var w = S(_, x);
    return e({ type: "mapped", defaultValue: { name: w, params: C(w).defaultValue }, select: r(w, x, A), map: C }, A);
  }, t.MappedStatic = function(_, x, C) {
    var A = C != null && C.options ? C.options : Object.keys(x).map(function(I) {
      return [I, x[I].label || mc(I)];
    }), w = S(_, A);
    return e({ type: "mapped", defaultValue: { name: w, params: x[w].defaultValue }, select: r(w, A, C), map: function(I) {
      return x[I];
    } }, C);
  }, t.ObjectList = function(_, x, C) {
    return e({ type: "object-list", element: _, getLabel: x, ctor: a, defaultValue: (C == null ? void 0 : C.defaultValue) || [] }, C);
  }, t.ValueRef = function(_, x, C) {
    var A;
    return e({ type: "value-ref", defaultValue: { ref: (A = C == null ? void 0 : C.defaultRef) !== null && A !== void 0 ? A : "", getValue: o }, getOptions: _, resolveRef: x }, C);
  }, t.DataRef = function(_) {
    var x;
    return e({ type: "data-ref", defaultValue: { ref: (x = _ == null ? void 0 : _.defaultRef) !== null && x !== void 0 ? x : "", getValue: o } }, _);
  }, t.Converted = function(_, x, C) {
    return { type: "converted", defaultValue: x(C.defaultValue), converted: C, fromValue: _, toValue: x };
  }, t.Conditioned = function(_, x, C, A, w) {
    var I = Object.keys(x).map(function(P) {
      return [P, P];
    });
    return e({ type: "conditioned", select: r(C(_), I, w), defaultValue: _, conditionParams: x, conditionForValue: C, conditionedValue: A }, w);
  }, t.Script = function(_, x) {
    return e({ type: "script", defaultValue: _ }, x);
  }, t.For = function(_) {
    return 0;
  }, t.getDefaultValues = s, t.resolveRefs = f, t.setDefaultValues = function(_, x) {
    for (var C = 0, A = Object.keys(_); C < A.length; C++) {
      var w = A[C];
      _[w].isOptional || (_[w].defaultValue = x[w]);
    }
  }, t.clone = function(_) {
    return wl(_);
  }, t.validate = function(_, x) {
  }, t.areEqual = h, t.isParamEqual = m, t.merge = p, t.mergeParam = v, t.normalizeParams = b, t.objectToOptions = function(_, x) {
    for (var C = [], A = 0, w = Object.keys(_); A < w.length; A++) {
      var I = w[A];
      if (x) {
        var P = x(I, _[I]);
        C.push(typeof P == "string" ? [I, P] : [I, P[0], P[1]]);
      } else typeof _[I] == "string" ? C.push([I, _[I]]) : C.push([I, x === null ? I : mc(I)]);
    }
    return C;
  }, t.arrayToOptions = function(_, x) {
    for (var C = [], A = 0, w = _; A < w.length; A++) {
      var I = w[A];
      x ? C.push([I, x(I)]) : C.push([I, x === null ? I : mc(I)]);
    }
    return C;
  }, t.optionLabel = function(_, x) {
    for (var C = 0, A = _.options; C < A.length; C++) {
      var w = A[C];
      if (w[0] === x) return w[1];
    }
    return "";
  };
})(z || (z = {}));
var P_, B_ = { backgroundColor: z.Color(qe(0), { description: "Background color of the 3D canvas" }), pickingAlphaThreshold: z.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "The minimum opacity value needed for an object to be pickable." }), interiorDarkening: z.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), interiorColorFlag: z.Boolean(!0, { label: "Use Interior Color" }), interiorColor: z.Color(qe.fromNormalizedRgb(0.3, 0.3, 0.3)), highlightColor: z.Color(qe.fromNormalizedRgb(1, 0.4, 0.6)), selectColor: z.Color(qe.fromNormalizedRgb(0.2, 1, 0.1)), highlightStrength: z.Numeric(0.3, { min: 0, max: 1, step: 0.1 }), selectStrength: z.Numeric(0.3, { min: 0, max: 1, step: 0.1 }), markerPriority: z.Select(1, [[1, "Highlight"], [2, "Select"]]), xrayEdgeFalloff: z.Numeric(1, { min: 0, max: 3, step: 0.1 }), light: z.ObjectList({ inclination: z.Numeric(180, { min: 0, max: 180, step: 1 }), azimuth: z.Numeric(0, { min: 0, max: 360, step: 1 }), color: z.Color(qe.fromNormalizedRgb(1, 1, 1)), intensity: z.Numeric(0.6, { min: 0, max: 1, step: 0.01 }) }, function(t) {
  return qe.toHexString(t.color);
}, { defaultValue: [{ inclination: 180, azimuth: 0, color: qe.fromNormalizedRgb(1, 1, 1), intensity: 0.6 }] }), ambientColor: z.Color(qe.fromNormalizedRgb(1, 1, 1)), ambientIntensity: z.Numeric(0.45, { min: 0, max: 1, step: 0.01 }), invalidColor: z.Color(qe(16410214)), invalidStrength: z.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) }, Kw = E(), k6 = E();
function Xw(t, e) {
  for (var r = e || { direction: new Array(15).fill(0), color: new Array(15).fill(0) }, n = r.direction, i = r.color, a = 0, o = t.length; a < o; ++a) {
    var s = t[a];
    E.directionFromSpherical(Kw, qn(s.inclination), qn(s.azimuth), 1), E.toArray(Kw, n, 3 * a), E.scale(k6, qe.toVec3Normalized(k6, s.color), s.intensity), E.toArray(k6, i, 3 * a);
  }
  return { count: t.length, direction: n, color: i };
}
function Ci(t, e, r) {
  return e === void 0 && (e = ""), r === void 0 && (r = ""), Ci.create(t, e, r);
}
(function(t) {
  t.create = function(e, r) {
    r === void 0 && (r = {});
    var n = e.gl, i = e.state, a = e.stats, o = z.merge(B_, z.getDefaultValues(B_), r), s = Xw(o.light), u = sa(), c = ze.create(n.drawingBufferWidth, n.drawingBufferHeight), l = qe.toVec3Normalized(E(), o.backgroundColor), d = !1, f = e.resources.texture("image-depth", "depth", "ushort", "nearest"), h = [["tDepth", f]], m = he(), p = he(), v = he(), g = he(), y = he(), b = he(), S = he(), _ = E(), x = ze(), C = E();
    E.scale(C, qe.toArrayNormalized(o.ambientColor, C, 0), o.ambientIntensity);
    var A = { uModel: G.create(he.identity()), uView: G.create(m), uInvView: G.create(p), uModelView: G.create(v), uInvModelView: G.create(g), uInvProjection: G.create(y), uProjection: G.create(he()), uModelViewProjection: G.create(b), uInvModelViewProjection: G.create(S), uIsOrtho: G.create(1), uViewOffset: G.create(x), uPixelRatio: G.create(e.pixelRatio), uViewport: G.create(sa.toVec4(Ut(), u)), uDrawingBufferSize: G.create(c), uCameraPosition: G.create(E()), uCameraDir: G.create(_), uNear: G.create(1), uFar: G.create(1e4), uFogNear: G.create(1), uFogFar: G.create(1e4), uFogColor: G.create(l), uRenderWboit: G.create(!1), uMarkingDepthTest: G.create(!1), uPickType: G.create(0), uMarkingType: G.create(0), uTransparentBackground: G.create(!1), uLightDirection: G.create(s.direction), uLightColor: G.create(s.color), uAmbientColor: G.create(C), uPickingAlphaThreshold: G.create(o.pickingAlphaThreshold), uInteriorDarkening: G.create(o.interiorDarkening), uInteriorColorFlag: G.create(o.interiorColorFlag), uInteriorColor: G.create(qe.toVec3Normalized(E(), o.interiorColor)), uHighlightColor: G.create(qe.toVec3Normalized(E(), o.highlightColor)), uSelectColor: G.create(qe.toVec3Normalized(E(), o.selectColor)), uHighlightStrength: G.create(o.highlightStrength), uSelectStrength: G.create(o.selectStrength), uMarkerPriority: G.create(o.markerPriority), uXrayEdgeFalloff: G.create(o.xrayEdgeFalloff), uInvalidColor: G.create(qe.toVec3Normalized(E(), o.invalidColor)), uInvalidStrength: G.create(o.invalidStrength) }, w = Object.entries(A), I = !0, P = function(N, R) {
      if (!N.state.disposed && N.state.visible && (N.state.pickable || R !== "pick")) {
        var L = !1;
        N.values.dLightCount.ref.value !== s.count && (G.update(N.values.dLightCount, s.count), L = !0), L && N.update();
        var V = N.getProgram(R);
        if (i.currentProgramId !== V.id && (I = !0, V.use()), I && (V.setUniforms(w), I = !1), N.values.dGeometryType.ref.value === "directVolume") {
          if (R !== "colorWboit" && R !== "colorBlended") return;
          i.disable(n.CULL_FACE), i.frontFace(n.CCW), R === "colorBlended" && (i.disable(n.DEPTH_TEST), i.depthMask(!1));
        } else N.values.uDoubleSided ? N.values.uDoubleSided.ref.value || N.values.hasReflection.ref.value ? i.disable(n.CULL_FACE) : i.enable(n.CULL_FACE) : i.disable(n.CULL_FACE), N.values.dFlipSided && N.values.dFlipSided.ref.value ? (i.frontFace(n.CW), i.cullFace(n.FRONT)) : (i.frontFace(n.CCW), i.cullFace(n.BACK));
        N.render(R, h);
      }
    }, M = function(N, R, L, V, U) {
      (function(Q, J, te) {
        for (var W = 0, j = Q.length; W < j; ++W) if (Q[W][0] === J) return void (Q[W][1] = te);
        Q.push([J, te]);
      })(h, "tDepth", L || f), G.update(A.uModel, N.view), G.update(A.uModelView, he.mul(v, N.view, R.view)), G.update(A.uInvModelView, he.invert(g, v)), G.update(A.uModelViewProjection, he.mul(b, v, R.projection)), G.update(A.uInvModelViewProjection, he.invert(S, b)), G.updateIfChanged(A.uRenderWboit, V), G.updateIfChanged(A.uMarkingDepthTest, U), i.enable(n.SCISSOR_TEST), i.colorMask(!0, !0, !0, !0);
      var H = u.x, K = u.y, X = u.width, Y = u.height;
      n.viewport(H, K, X, Y), n.scissor(H, K, X, Y), I = !0, i.currentRenderItemId = -1;
    }, T = function(N, R, L) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), M(N, R, L, !1, !1);
      for (var V = N.renderables, U = 0, H = V.length; U < H; ++U) {
        var K = V[U];
        K.state.opaque && P(K, "colorBlended");
      }
    }, F = function(N, R, L) {
      i.enable(n.DEPTH_TEST), M(N, R, L, !1, !1);
      var V = N.renderables;
      d ? i.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA) : i.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA), i.enable(n.BLEND), i.depthMask(!0);
      for (var U = 0, H = V.length; U < H; ++U)
        !(K = V[U]).state.opaque && K.state.writeDepth && P(K, "colorBlended");
      for (i.depthMask(!1), U = 0, H = V.length; U < H; ++U) {
        var K;
        (K = V[U]).state.opaque || K.state.writeDepth || P(K, "colorBlended");
      }
    };
    return { clear: function(N, R) {
      i.enable(n.SCISSOR_TEST), i.enable(n.DEPTH_TEST), i.colorMask(!0, !0, !0, !0), i.depthMask(!0), d && !R ? i.clearColor(0, 0, 0, 0) : N ? i.clearColor(l[0], l[1], l[2], 1) : i.clearColor(1, 1, 1, 1), n.clear(n.COLOR_BUFFER_BIT | n.DEPTH_BUFFER_BIT);
    }, clearDepth: function() {
      i.enable(n.SCISSOR_TEST), i.enable(n.DEPTH_TEST), i.depthMask(!0), n.clear(n.DEPTH_BUFFER_BIT);
    }, update: function(N) {
      G.update(A.uView, N.view), G.update(A.uInvView, he.invert(p, N.view)), G.update(A.uProjection, N.projection), G.update(A.uInvProjection, he.invert(y, N.projection)), G.updateIfChanged(A.uIsOrtho, N.state.mode === "orthographic" ? 1 : 0), G.update(A.uViewOffset, N.viewOffset.enabled ? ze.set(x, 16 * N.viewOffset.offsetX, 16 * N.viewOffset.offsetY) : ze.set(x, 0, 0)), G.update(A.uCameraPosition, N.state.position), G.update(A.uCameraDir, E.normalize(_, E.sub(_, N.state.target, N.state.position))), G.updateIfChanged(A.uFar, N.far), G.updateIfChanged(A.uNear, N.near), G.updateIfChanged(A.uFogFar, N.fogFar), G.updateIfChanged(A.uFogNear, N.fogNear), G.updateIfChanged(A.uTransparentBackground, d);
    }, renderPick: function(N, R, L, V, U) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), M(N, R, V, !1, !1), G.updateIfChanged(A.uPickType, U);
      for (var H = N.renderables, K = 0, X = H.length; K < X; ++K) H[K].state.colorOnly || P(H[K], L);
    }, renderDepth: function(N, R, L) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), M(N, R, L, !1, !1);
      for (var V = N.renderables, U = 0, H = V.length; U < H; ++U) P(V[U], "depth");
    }, renderMarkingDepth: function(N, R, L) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), M(N, R, L, !1, !1), G.updateIfChanged(A.uMarkingType, 1);
      for (var V = N.renderables, U = 0, H = V.length; U < H; ++U)
        V[U].values.markerAverage.ref.value !== 1 && P(V[U], "marking");
    }, renderMarkingMask: function(N, R, L) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), M(N, R, L, !1, !!L), G.updateIfChanged(A.uMarkingType, 2);
      for (var V = N.renderables, U = 0, H = V.length; U < H; ++U)
        V[U].values.markerAverage.ref.value > 0 && P(V[U], "marking");
    }, renderBlended: function(N, R, L) {
      T(N, R, L), F(N, R, L);
    }, renderBlendedOpaque: T, renderBlendedTransparent: F, renderBlendedVolumeOpaque: function(N, R, L) {
      var V;
      i.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), i.enable(n.BLEND), M(N, R, L, !1, !1);
      for (var U = N.renderables, H = 0, K = U.length; H < K; ++H) {
        var X = U[H];
        _o(X.values.alpha.ref.value * X.state.alphaFactor, 0, 1) !== 1 || X.values.transparencyAverage.ref.value === 1 || !((V = X.values.dXrayShaded) === null || V === void 0) && V.ref.value || P(X, "colorBlended");
      }
    }, renderBlendedVolumeTransparent: function(N, R, L) {
      var V;
      i.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), i.enable(n.BLEND), M(N, R, L, !1, !1);
      for (var U = N.renderables, H = 0, K = U.length; H < K; ++H) {
        var X = U[H];
        (_o(X.values.alpha.ref.value * X.state.alphaFactor, 0, 1) < 1 || X.values.transparencyAverage.ref.value > 0 || !((V = X.values.dXrayShaded) === null || V === void 0) && V.ref.value) && P(X, "colorBlended");
      }
    }, renderWboitOpaque: function(N, R, L) {
      var V, U;
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), M(N, R, L, !1, !1);
      for (var H = N.renderables, K = 0, X = H.length; K < X; ++K) {
        var Y = H[K];
        _o(Y.values.alpha.ref.value * Y.state.alphaFactor, 0, 1) !== 1 || Y.values.transparencyAverage.ref.value === 1 || Y.values.dGeometryType.ref.value === "directVolume" || ((V = Y.values.dPointStyle) === null || V === void 0 ? void 0 : V.ref.value) === "fuzzy" || !((U = Y.values.dXrayShaded) === null || U === void 0) && U.ref.value || P(Y, "colorWboit");
      }
    }, renderWboitTransparent: function(N, R, L) {
      var V, U;
      M(N, R, L, !0, !1);
      for (var H = N.renderables, K = 0, X = H.length; K < X; ++K) {
        var Y = H[K];
        (_o(Y.values.alpha.ref.value * Y.state.alphaFactor, 0, 1) < 1 || Y.values.transparencyAverage.ref.value > 0 || Y.values.dGeometryType.ref.value === "directVolume" || ((V = Y.values.dPointStyle) === null || V === void 0 ? void 0 : V.ref.value) === "fuzzy" || Y.values.uBackgroundColor || !((U = Y.values.dXrayShaded) === null || U === void 0) && U.ref.value) && P(Y, "colorWboit");
      }
    }, setProps: function(N) {
      N.backgroundColor !== void 0 && N.backgroundColor !== o.backgroundColor && (o.backgroundColor = N.backgroundColor, qe.toVec3Normalized(l, o.backgroundColor), G.update(A.uFogColor, E.copy(A.uFogColor.ref.value, l))), N.pickingAlphaThreshold !== void 0 && N.pickingAlphaThreshold !== o.pickingAlphaThreshold && (o.pickingAlphaThreshold = N.pickingAlphaThreshold, G.update(A.uPickingAlphaThreshold, o.pickingAlphaThreshold)), N.interiorDarkening !== void 0 && N.interiorDarkening !== o.interiorDarkening && (o.interiorDarkening = N.interiorDarkening, G.update(A.uInteriorDarkening, o.interiorDarkening)), N.interiorColorFlag !== void 0 && N.interiorColorFlag !== o.interiorColorFlag && (o.interiorColorFlag = N.interiorColorFlag, G.update(A.uInteriorColorFlag, o.interiorColorFlag)), N.interiorColor !== void 0 && N.interiorColor !== o.interiorColor && (o.interiorColor = N.interiorColor, G.update(A.uInteriorColor, qe.toVec3Normalized(A.uInteriorColor.ref.value, o.interiorColor))), N.highlightColor !== void 0 && N.highlightColor !== o.highlightColor && (o.highlightColor = N.highlightColor, G.update(A.uHighlightColor, qe.toVec3Normalized(A.uHighlightColor.ref.value, o.highlightColor))), N.selectColor !== void 0 && N.selectColor !== o.selectColor && (o.selectColor = N.selectColor, G.update(A.uSelectColor, qe.toVec3Normalized(A.uSelectColor.ref.value, o.selectColor))), N.highlightStrength !== void 0 && N.highlightStrength !== o.highlightStrength && (o.highlightStrength = N.highlightStrength, G.update(A.uHighlightStrength, o.highlightStrength)), N.selectStrength !== void 0 && N.selectStrength !== o.selectStrength && (o.selectStrength = N.selectStrength, G.update(A.uSelectStrength, o.selectStrength)), N.markerPriority !== void 0 && N.markerPriority !== o.markerPriority && (o.markerPriority = N.markerPriority, G.update(A.uMarkerPriority, o.markerPriority)), N.xrayEdgeFalloff !== void 0 && N.xrayEdgeFalloff !== o.xrayEdgeFalloff && (o.xrayEdgeFalloff = N.xrayEdgeFalloff, G.update(A.uXrayEdgeFalloff, o.xrayEdgeFalloff)), N.light === void 0 || nf(N.light, o.light) || (o.light = N.light, Object.assign(s, Xw(N.light, s)), G.update(A.uLightDirection, s.direction), G.update(A.uLightColor, s.color)), N.ambientColor !== void 0 && N.ambientColor !== o.ambientColor && (o.ambientColor = N.ambientColor, E.scale(C, qe.toArrayNormalized(o.ambientColor, C, 0), o.ambientIntensity), G.update(A.uAmbientColor, C)), N.ambientIntensity !== void 0 && N.ambientIntensity !== o.ambientIntensity && (o.ambientIntensity = N.ambientIntensity, E.scale(C, qe.toArrayNormalized(o.ambientColor, C, 0), o.ambientIntensity), G.update(A.uAmbientColor, C)), N.invalidColor !== void 0 && N.invalidColor !== o.invalidColor && (o.invalidColor = N.invalidColor, G.update(A.uInvalidColor, qe.toVec3Normalized(A.uInvalidColor.ref.value, o.invalidColor))), N.invalidStrength !== void 0 && N.invalidStrength !== o.invalidStrength && (o.invalidStrength = N.invalidStrength, G.update(A.uInvalidStrength, o.invalidStrength));
    }, setViewport: function(N, R, L, V) {
      n.viewport(N, R, L, V), n.scissor(N, R, L, V), N === u.x && R === u.y && L === u.width && V === u.height || (sa.set(u, N, R, L, V), G.update(A.uViewport, Ut.set(A.uViewport.ref.value, N, R, L, V)));
    }, setTransparentBackground: function(N) {
      d = N;
    }, setDrawingBufferSize: function(N, R) {
      N === c[0] && R === c[1] || G.update(A.uDrawingBufferSize, ze.set(c, N, R));
    }, setPixelRatio: function(N) {
      G.update(A.uPixelRatio, N);
    }, props: o, get stats() {
      return { programCount: e.stats.resourceCounts.program, shaderCount: e.stats.resourceCounts.shader, attributeCount: e.stats.resourceCounts.attribute, elementsCount: e.stats.resourceCounts.elements, framebufferCount: e.stats.resourceCounts.framebuffer, renderbufferCount: e.stats.resourceCounts.renderbuffer, textureCount: e.stats.resourceCounts.texture, vertexArrayCount: e.stats.resourceCounts.vertexArray, drawCount: a.drawCount, instanceCount: a.instanceCount, instancedDrawCount: a.instancedDrawCount };
    }, dispose: function() {
    } };
  };
})(P_ || (P_ = {})), function(t) {
  function e(n) {
    return n.triggers.map(r.format).join(" or ");
  }
  function r(n, i) {
    return r.create(n, i);
  }
  t.create = function(n, i, a) {
    return i === void 0 && (i = ""), a === void 0 && (a = ""), { triggers: n, action: i, description: a };
  }, t.Empty = { triggers: [], action: "", description: "" }, t.isEmpty = function(n) {
    return n.triggers.length === 0 || n.triggers.every(function(i) {
      return i.buttons === void 0 && i.modifiers === void 0;
    });
  }, t.match = function(n, i, a) {
    return n.triggers.some(function(o) {
      return r.match(o, i, a);
    });
  }, t.formatTriggers = e, t.format = function(n, i) {
    return i === void 0 && (i = ""), function(a, o) {
      var s = Object.keys(o), u = Object.values(o);
      return new (Function.bind.apply(Function, Ze(Ze([void 0], s, !1), ["return `".concat(a, "`;")], !1)))().apply(void 0, u);
    }(n.description || mc(i), { triggers: "<i>" + e(n) + "</i>" });
  }, t.Trigger = r, function(n) {
    n.create = function(i, a) {
      return { buttons: i, modifiers: a };
    }, n.Empty = {}, n.match = function(i, a, o) {
      var s = i.buttons, u = i.modifiers;
      return s !== void 0 && (s === a || x0.has(s, a)) && (!u || yp.areEqual(u, o));
    }, n.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") : (Lg.has(u, 1) && c.push("left mouse button"), Lg.has(u, 2) && c.push("right mouse button"), Lg.has(u, 4) && c.push("wheel/middle mouse button"), Lg.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(" + ");
    };
  }(r = t.Trigger || (t.Trigger = {}));
}(Ci || (Ci = {}));
var wo, Lg = x0;
(function(t) {
  t.create = function() {
    var e = new IQ(), r = function() {
      return e.create();
    };
    return r.dispose = function() {
      return e.dispose();
    }, r.behavior = function(n) {
      return e.behavior(n);
    }, r;
  };
})(wo || (wo = {}));
var F_, IQ = function() {
  function t() {
    this._eventList = [], this._disposed = !1;
  }
  return t.prototype.create = function() {
    var e = new Si();
    return this._eventList.push(e), e;
  }, t.prototype.behavior = function(e) {
    var r = new kd(e);
    return this._eventList.push(r), r;
  }, t.prototype.dispose = function() {
    if (!this._disposed) {
      for (var e = 0, r = this._eventList; e < r.length; e++)
        r[e].complete();
      this._disposed = !0;
    }
  }, t;
}(), ad = yp, od = Ci.Trigger, TQ = { dragRotate: Ci([od(1, ad.create())], "Rotate", "Drag using ${triggers}"), dragRotateZ: Ci([od(1, ad.create({ shift: !0 }))], "Rotate around z-axis", "Drag using ${triggers}"), dragPan: Ci([od(2, ad.create()), od(1, ad.create({ control: !0 }))], "Pan", "Drag using ${triggers}"), dragZoom: Ci.Empty, dragFocus: Ci([od(8, ad.create())], "Focus", "Drag using ${triggers}"), dragFocusZoom: Ci([od(4, ad.create())], "Focus and zoom", "Drag using ${triggers}"), scrollZoom: Ci([od(4, ad.create())], "Zoom", "Scroll using ${triggers}"), scrollFocus: Ci([od(4, ad.create({ shift: !0 }))], "Clip", "Scroll using ${triggers}"), scrollFocusZoom: Ci.Empty }, LN = { noScroll: z.Boolean(!0, { isHidden: !0 }), rotateSpeed: z.Numeric(5, { min: 1, max: 10, step: 1 }), zoomSpeed: z.Numeric(7, { min: 1, max: 15, step: 1 }), panSpeed: z.Numeric(1, { min: 0.1, max: 5, step: 0.1 }), animate: z.MappedStatic("off", { off: z.EmptyGroup(), spin: z.Group({ speed: z.Numeric(1, { min: -20, max: 20, step: 1 }) }, { description: "Spin the 3D scene around the x-axis in view space" }), rock: z.Group({ speed: z.Numeric(0.3, { min: -5, max: 5, step: 0.1 }), angle: z.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: z.Boolean(!0, { isHidden: !0 }), dynamicDampingFactor: z.Numeric(0.2, {}, { isHidden: !0 }), minDistance: z.Numeric(0.01, {}, { isHidden: !0 }), maxDistance: z.Numeric(1e150, {}, { isHidden: !0 }), gestureScaleFactor: z.Numeric(1, {}, { isHidden: !0 }), maxWheelDelta: z.Numeric(0.02, {}, { isHidden: !0 }), bindings: z.Value(TQ, { isHidden: !0 }), autoAdjustMinMaxDistance: z.MappedStatic("on", { off: z.EmptyGroup(), on: z.Group({ minDistanceFactor: z.Numeric(0), minDistancePadding: z.Numeric(5), maxDistanceFactor: z.Numeric(10), maxDistanceMin: z.Numeric(20) }) }, { isHidden: !0 }) };
(function(t) {
  t.create = function(e, r, n) {
    n === void 0 && (n = {});
    var i = wo.create(), a = O(O({}, z.getDefaultValues(LN)), n), o = sa.clone(r.viewport), s = !1, u = i.behavior(!1), c = i.behavior([]), l = i.behavior(!1), d = e.drag.subscribe(function(Ne) {
      var Je = Ne.x, Re = Ne.y, nt = Ne.pageX, ne = Ne.pageY, re = Ne.buttons, le = Ne.modifiers, fe = Ne.isStart, ge = ce(Je, Re);
      if (!(u.value && c.value.includes("drag") && (l.value || re !== 1)) && !(fe && ge) && !(!fe && !v)) {
        v = !0, We();
        var me = Ci.match(a.bindings.dragRotate, re, le), Ae = Ci.match(a.bindings.dragRotateZ, re, le), Oe = Ci.match(a.bindings.dragPan, re, le), Ue = Ci.match(a.bindings.dragZoom, re, le), Ve = Ci.match(a.bindings.dragFocus, re, le), ht = Ci.match(a.bindings.dragFocusZoom, re, le);
        if (function(At, Ee) {
          ze.set(H, (At - 0.5 * o.width - o.x) / (0.5 * o.width), (o.height + 2 * (o.y - Ee)) / o.width);
        }(nt, ne), function(At, Ee) {
          ze.set(U, (At - o.x) / o.width, (Ee - o.y) / o.height);
        }(nt, ne), fe && (me && (ze.copy(S, H), ze.copy(b, S)), Ae && (ze.copy(A, H), ze.copy(C, A)), (Ue || ht) && (ze.copy(I, U), ze.copy(P, I)), Ve && (ze.copy(M, U), ze.copy(T, M)), Oe && (ze.copy(F, U), ze.copy(N, F))), me && ze.copy(S, H), Ae && ze.copy(A, H), (Ue || ht) && ze.copy(P, U), Ve && ze.copy(T, U), ht) {
          var bt = E.distance(r.state.position, r.state.target);
          r.setState({ radius: bt / 5 });
        }
        Oe && ze.copy(N, U);
      }
    }), f = e.interactionEnd.subscribe(function() {
      v = !1;
    }), h = e.wheel.subscribe(function(Ne) {
      var Je = Ne.x, Re = Ne.y, nt = Ne.spinX, ne = Ne.spinY, re = Ne.dz, le = Ne.buttons, fe = Ne.modifiers;
      if (!ce(Je, Re)) {
        var ge = function() {
          for (var me = [], Ae = 0; Ae < arguments.length; Ae++) me[Ae] = arguments[Ae];
          for (var Oe = 0, Ue = 0, Ve = 0, ht = me.length; Ve < ht; ++Ve) {
            var bt = me[Ve], At = Math.abs(bt);
            At > Ue && (Oe = bt, Ue = At);
          }
          return Oe;
        }(0.075 * nt, 0.075 * ne, 1e-4 * re);
        ge < -a.maxWheelDelta ? ge = -a.maxWheelDelta : ge > a.maxWheelDelta && (ge = a.maxWheelDelta), Ci.match(a.bindings.scrollZoom, le, fe) && (P[1] += ge), Ci.match(a.bindings.scrollFocus, le, fe) && (T[1] += ge);
      }
    }), m = e.pinch.subscribe(function(Ne) {
      var Je = Ne.fractionDelta, Re = Ne.buttons, nt = Ne.modifiers;
      Ci.match(a.bindings.scrollZoom, Re, nt) && (v = !0, P[1] += a.gestureScaleFactor * Je);
    }), p = e.gesture.subscribe(function(Ne) {
      var Je = Ne.deltaScale;
      v = !0, P[1] += a.gestureScaleFactor * Je;
    }), v = !1, g = E(), y = E(), b = ze(), S = ze(), _ = E(), x = 0, C = ze(), A = ze(), w = 0, I = ze(), P = ze(), M = ze(), T = ze(), F = ze(), N = ze(), R = E.clone(r.target), L = E.clone(r.position), V = E.clone(r.up), U = ze(), H = ze();
    function K() {
      var Ne = e.width / e.height;
      return a.rotateSpeed * e.pixelRatio * Ne;
    }
    var X = E(), Y = kn(), Q = E(), J = E(), te = E(), W = E(), j = kn(), ee = ze(), ie = E(), ae = E();
    function ce(Ne, Je) {
      return Ne *= e.pixelRatio, Je *= e.pixelRatio, Ne > o.x + o.width || e.height - Je > o.y + o.height || Ne < o.x || e.height - Je < o.y;
    }
    var de = -1;
    function Ce(Ne) {
      var Je, Re, nt, ne, re;
      de !== Ne && (de > 0 && (a.animate.name === "spin" ? function(le) {
        if (!(a.animate.name !== "spin" || a.animate.params.speed === 0 || v)) {
          var fe = a.animate.params.speed / 1e3;
          De[0] = 60 * Math.min(Math.abs(le), 125) / 1e3 * fe, ze.add(S, b, De);
        }
      }(Ne - de) : a.animate.name === "rock" && function(le) {
        if (!(a.animate.name !== "rock" || a.animate.params.speed === 0 || v)) {
          var fe = le / 1e3 * a.animate.params.speed, ge = qn(a.animate.params.angle) / K(), me = Math.sin(ke * Math.PI * 2) * ge, Ae = Math.sin((ke + fe) * Math.PI * 2) * ge;
          He[0] = Ae - me, ze.add(S, b, He), (ke += fe) >= 1 && (ke = 0);
        }
      }(Ne - de)), E.sub(y, r.position, r.target), function() {
        var le = S[0] - b[0], fe = S[1] - b[1];
        E.set(W, le, fe, 0);
        var ge = E.magnitude(W) * K();
        ge ? (E.sub(y, r.position, r.target), E.normalize(Q, y), E.normalize(J, r.up), E.normalize(te, E.cross(te, J, Q)), E.setMagnitude(J, J, fe), E.setMagnitude(te, te, le), E.add(W, J, te), E.normalize(X, E.cross(X, W, y)), kn.setAxisAngle(Y, X, ge), E.transformQuat(y, y, Y), E.transformQuat(r.up, r.up, Y), E.copy(_, X), x = ge) : !a.staticMoving && x && (x *= Math.sqrt(1 - a.dynamicDampingFactor), E.sub(y, r.position, r.target), kn.setAxisAngle(Y, _, x), E.transformQuat(y, y, Y), E.transformQuat(r.up, r.up, Y)), ze.copy(b, S);
      }(), Je = A[0] - C[0], Re = A[1] - C[1], (nt = a.rotateSpeed * (-Je + Re) * -0.05) ? (E.sub(y, r.position, r.target), kn.setAxisAngle(j, y, nt), E.transformQuat(r.up, r.up, j), w = nt) : !a.staticMoving && w && (w *= Math.sqrt(1 - a.dynamicDampingFactor), E.sub(y, r.position, r.target), kn.setAxisAngle(j, y, w), E.transformQuat(r.up, r.up, j)), ze.copy(C, A), (ne = 1 + (P[1] - I[1]) * a.zoomSpeed) !== 1 && ne > 0 && E.scale(y, y, ne), a.staticMoving ? ze.copy(I, P) : I[1] += (P[1] - I[1]) * a.dynamicDampingFactor, function() {
        var le = (T[1] - M[1]) * a.zoomSpeed;
        if (le !== 0) {
          var fe = Math.max(1, r.state.radius + r.state.radius * le);
          r.setState({ radius: fe });
        }
        a.staticMoving ? ze.copy(M, T) : M[1] += (T[1] - M[1]) * a.dynamicDampingFactor;
      }(), function() {
        if (ze.sub(ee, ze.copy(ee, N), F), ze.squaredMagnitude(ee)) {
          var le = e.pixelRatio * a.panSpeed;
          ee[0] *= 1 / r.zoom * r.viewport.width * le, ee[1] *= 1 / r.zoom * r.viewport.height * le, E.cross(ae, E.copy(ae, y), r.up), E.setMagnitude(ae, ae, ee[0]), E.setMagnitude(ie, r.up, ee[1]), E.add(ae, ae, ie), E.add(r.position, r.position, ae), E.add(r.target, r.target, ae), a.staticMoving ? ze.copy(F, N) : (ze.sub(ee, N, F), ze.scale(ee, ee, a.dynamicDampingFactor), ze.add(F, F, ee));
        }
      }(), E.add(r.position, r.target, y), re = Math.min(Math.max(1e3 * r.state.radiusMax, 0.01), a.maxDistance), E.squaredMagnitude(y) > re * re && (E.setMagnitude(y, y, re), E.add(r.position, r.target, y), ze.copy(I, P), ze.copy(M, T)), E.squaredMagnitude(y) < a.minDistance * a.minDistance && (E.setMagnitude(y, y, a.minDistance), E.add(r.position, r.target, y), ze.copy(I, P), ze.copy(M, T)), E.squaredDistance(g, r.position) > Cn && E.copy(g, r.position), de = Ne);
    }
    var De = ze.create(5e-3, 0), ke = 0, He = ze.create(5e-3, 0);
    function We() {
      ke = 0;
    }
    return { viewport: o, get isAnimating() {
      return a.animate.name !== "off";
    }, get props() {
      return a;
    }, setProps: function(Ne) {
      var Je;
      ((Je = Ne.animate) === null || Je === void 0 ? void 0 : Je.name) === "rock" && a.animate.name !== "rock" && We(), Object.assign(a, Ne);
    }, get isEditing() {
      return u.value;
    }, get disabledInteraction() {
      return c.value;
    }, get isLockCamera() {
      return l.value;
    }, start: function(Ne) {
      de = -1, Ce(Ne);
    }, update: Ce, reset: function() {
      E.copy(r.target, R), E.copy(r.position, L), E.copy(r.up, V), E.sub(y, r.position, r.target), E.copy(g, r.position);
    }, dispose: function() {
      s || (s = !0, d.unsubscribe(), h.unsubscribe(), m.unsubscribe(), p.unsubscribe(), f.unsubscribe());
    }, setEditState: function(Ne) {
      u.next(Ne);
    }, setLockCameraState: function(Ne) {
      l.next(Ne);
    }, setDisabledInteractionState: function(Ne) {
      c.next(Ne);
    } };
  };
})(F_ || (F_ = {}));
var kN = io(), MQ = { 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
` }, PQ = /^(?!\/\/)\s*#include\s+(\S+)/gm, BQ = /#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, FQ = /[ \t]*\/\/.*\n/g, NQ = /[ \t]*\/\*[\s\S]*?\*\//g, RQ = /\n{2,}/g;
function Yw(t) {
  return t.replace(PQ, function(e, r) {
    var n = MQ[r];
    if (!n) throw new Error("empty chunk, '".concat(r, "'"));
    return n;
  }).trim().replace(FQ, `
`).replace(NQ, `
`).replace(RQ, `
`);
}
function OQ(t, e, r, n) {
  for (var i = "", a = parseInt(e); a < parseInt(r); ++a) i += n.replace(/\[\s*i\s*\]/g, "[".concat(a, "]")).replace(/UNROLLED_LOOP_INDEX/g, "".concat(a));
  return i;
}
function Ww(t, e) {
  return function(r) {
    return r.replace(BQ, OQ);
  }(function(r, n) {
    return n.dLightCount && (r = r.replace(/dLightCount/g, "".concat(n.dLightCount.ref.value))), n.dClipObjectCount && (r = r.replace(/dClipObjectCount/g, "".concat(n.dClipObjectCount.ref.value))), r;
  }(t, e));
}
function Nn(t, e, r, n, i, a) {
  return n === void 0 && (n = {}), i === void 0 && (i = {}), { id: kN(), name: t, vert: Yw(e), frag: Yw(r), extensions: n, outTypes: i, ignoreDefine: a };
}
function p2(t, e, r) {
  var n;
  return e.startsWith("color") ? t === "dLightCount" && !!(!((n = r.dIgnoreLight) === null || n === void 0) && n.ref.value) : ["dColorType", "dUsePalette", "dLightCount", "dOverpaintType", "dOverpaint", "dSubstanceType", "dSubstance"].includes(t);
}
function By(t, e, r) {
  return t === "dLightCount" || p2(t, e, r);
}
var LQ = Nn("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" }, {}, By), kQ = Nn("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" }, {}, p2), GQ = Nn("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" }, {}, p2), zQ = Nn("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" }, {}, By), VQ = Nn("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" }, {}, By), jw = Nn("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" }, {}, p2), UQ = Nn("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" }, {}, p2), HQ = Nn("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" }, {}, By);
function Zw(t, e) {
  var r;
  if (t === void 0) return "";
  var n = ((r = t.dRenderVariant) === null || r === void 0 ? void 0 : r.ref.value) || "", i = [];
  for (var a in t) if (!(e != null && e(a, n, t))) {
    var o = t[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)) : ca());
  }
  return i.join(`
`) + `
`;
}
var qQ = `#version 300 es
#define attribute in
#define varying out
#define texture2D texture
`, KQ = `
#define varying in
#define texture2D texture
#define texture2DLodEXT textureLod

#define gl_FragColor out_FragData0
#define gl_FragDepthEXT gl_FragDepth

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

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

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

void main() {
    gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor;
}`, dJ = new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]);
function eD(t, e) {
  var r = E3(t, { type: "vert", source: cJ }), n = E3(t, { type: "frag", source: lJ });
  if (!r || !n) return !1;
  var i = N_(t);
  t.attachShader(i, r), t.attachShader(i, n), t.linkProgram(i), t.useProgram(i);
  var a = t.getAttribLocation(i, "aPosition"), o = t.getUniformLocation(i, "uColor");
  if (!o) return Pr && console.log("error getting 'uColor' uniform location"), !1;
  var s = t.createBuffer();
  t.bindBuffer(t.ARRAY_BUFFER, s), t.bufferData(t.ARRAY_BUFFER, dJ, t.STATIC_DRAW), t.enableVertexAttribArray(a), t.vertexAttribPointer(a, 2, t.FLOAT, !1, 0, 0);
  var u = t.createTexture(), c = new Uint8Array([255, 255, 255, 255]);
  t.bindTexture(t.TEXTURE_2D, u), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, 1, 1, 0, t.RGBA, t.UNSIGNED_BYTE, c);
  var l = t.createTexture();
  t.bindTexture(t.TEXTURE_2D, l), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, 1, 1, 0, t.RGBA, e, null), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST);
  var d = t.createFramebuffer();
  if (t.bindFramebuffer(t.FRAMEBUFFER, d), t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, l, 0), t.checkFramebufferStatus(t.FRAMEBUFFER) !== t.FRAMEBUFFER_COMPLETE) return Pr && console.log("error creating framebuffer for '".concat(e, "'")), !1;
  t.bindTexture(t.TEXTURE_2D, u), t.uniform4fv(o, [0, 10, 20, 1]), t.drawArrays(t.TRIANGLES, 0, 6), t.bindTexture(t.TEXTURE_2D, l), t.bindFramebuffer(t.FRAMEBUFFER, null), t.clearColor(1, 0, 0, 1), t.clear(t.COLOR_BUFFER_BIT), t.uniform4fv(o, [0, 0.1, 0.05, 1]), t.drawArrays(t.TRIANGLES, 0, 6);
  var f = new Uint8Array(4);
  if (t.readPixels(0, 0, 1, 1, t.RGBA, t.UNSIGNED_BYTE, f), f[0] !== 0 || f[1] < 248 || f[2] < 248 || f[3] < 254) return Pr && console.log("not able to actually render to '".concat(e, "' texture")), !1;
  if (e === t.FLOAT) {
    t.bindFramebuffer(t.FRAMEBUFFER, d);
    var h = new Float32Array(4);
    t.readPixels(0, 0, 1, 1, t.RGBA, t.FLOAT, h);
    var m = t.getError();
    if (m) return Pr && console.log("error reading float pixels: '".concat(UN(t, m), "'")), !1;
  }
  return !0;
}
var g0, GN = io();
function X9(t) {
  var e = t.checkFramebufferStatus(t.FRAMEBUFFER);
  if (e !== t.FRAMEBUFFER_COMPLETE) {
    var r = function(n, i) {
      switch (i) {
        case n.FRAMEBUFFER_COMPLETE:
          return "complete";
        case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
          return "incomplete attachment";
        case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
          return "incomplete missing attachment";
        case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
          return "incomplete dimensions";
        case n.FRAMEBUFFER_UNSUPPORTED:
          return "unsupported";
      }
      if (ar(n)) switch (i) {
        case n.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
          return "incomplete multisample";
        case n.RENDERBUFFER_SAMPLES:
          return "renderbuffer samples";
      }
      return "unknown error";
    }(t, e);
    throw new Error("Framebuffer status: ".concat(r));
  }
}
function tD(t) {
  var e = t.createFramebuffer();
  if (e === null) throw new Error("Could not create WebGL framebuffer");
  return e;
}
function rD(t) {
  var e = function(g) {
    if (ar(g)) return { drawArraysInstanced: g.drawArraysInstanced.bind(g), drawElementsInstanced: g.drawElementsInstanced.bind(g), vertexAttribDivisor: g.vertexAttribDivisor.bind(g), VERTEX_ATTRIB_ARRAY_DIVISOR: g.VERTEX_ATTRIB_ARRAY_DIVISOR };
    var y = g.getExtension("ANGLE_instanced_arrays");
    return y === null ? null : { drawArraysInstanced: y.drawArraysInstancedANGLE.bind(y), drawElementsInstanced: y.drawElementsInstancedANGLE.bind(y), vertexAttribDivisor: y.vertexAttribDivisorANGLE.bind(y), VERTEX_ATTRIB_ARRAY_DIVISOR: y.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE };
  }(t);
  if (e === null) throw new Error('Could not find support for "instanced_arrays"');
  var r = function(g) {
    return ar(g) ? {} : g.getExtension("OES_element_index_uint");
  }(t);
  if (r === null) throw new Error('Could not find support for "element_index_uint"');
  var n = function(g) {
    if (ar(g)) return { FRAGMENT_SHADER_DERIVATIVE_HINT: g.FRAGMENT_SHADER_DERIVATIVE_HINT };
    var y = g.getExtension("OES_standard_derivatives");
    return y === null ? null : { FRAGMENT_SHADER_DERIVATIVE_HINT: y.FRAGMENT_SHADER_DERIVATIVE_HINT_OES };
  }(t);
  if (n === null) throw new Error('Could not find support for "standard_derivatives"');
  var i = function(g) {
    return ar(g) ? {} : g.getExtension("OES_texture_float");
  }(t);
  Pr && i === null && console.log('Could not find support for "texture_float"');
  var a = function(g) {
    return g.getExtension("OES_texture_float_linear");
  }(t);
  Pr && a === null && console.log('Could not find support for "texture_float_linear"');
  var o = function(g) {
    if (ar(g)) return { HALF_FLOAT: g.HALF_FLOAT };
    var y = g.getExtension("OES_texture_half_float");
    return y === null ? null : { HALF_FLOAT: y.HALF_FLOAT_OES };
  }(t);
  Pr && o === null && console.log('Could not find support for "texture_half_float"');
  var s = function(g) {
    return g.getExtension("OES_texture_half_float_linear");
  }(t);
  Pr && s === null && console.log('Could not find support for "texture_half_float_linear"');
  var u = function(g) {
    if (ar(g)) return { UNSIGNED_INT_24_8: g.UNSIGNED_INT_24_8 };
    var y = g.getExtension("WEBGL_depth_texture");
    return y === null ? null : { UNSIGNED_INT_24_8: y.UNSIGNED_INT_24_8_WEBGL };
  }(t);
  Pr && u === null && console.log('Could not find support for "depth_texture"');
  var c = function(g) {
    if (ar(g)) return { MIN: g.MIN, MAX: g.MAX };
    var y = g.getExtension("EXT_blend_minmax");
    return y === null ? null : { MIN: y.MIN_EXT, MAX: y.MAX_EXT };
  }(t);
  Pr && c === null && console.log('Could not find support for "blend_minmax"');
  var l = function(g) {
    if (ar(g)) return { VERTEX_ARRAY_BINDING: g.VERTEX_ARRAY_BINDING, bindVertexArray: g.bindVertexArray.bind(g), createVertexArray: g.createVertexArray.bind(g), deleteVertexArray: g.deleteVertexArray.bind(g), isVertexArray: g.isVertexArray.bind(g) };
    var y = g.getExtension("OES_vertex_array_object");
    return y === null ? null : { VERTEX_ARRAY_BINDING: y.VERTEX_ARRAY_BINDING_OES, bindVertexArray: y.bindVertexArrayOES.bind(y), createVertexArray: y.createVertexArrayOES.bind(y), deleteVertexArray: y.deleteVertexArrayOES.bind(y), isVertexArray: y.isVertexArrayOES.bind(y) };
  }(t);
  Pr && l === null && console.log('Could not find support for "vertex_array_object"');
  var d = function(g) {
    return ar(g) ? {} : g.getExtension("EXT_frag_depth");
  }(t);
  Pr && d === null && console.log('Could not find support for "frag_depth"');
  var f = function(g) {
    if (ar(g)) return g.getExtension("EXT_color_buffer_float") === null ? null : (g.getExtension("EXT_float_blend"), { RGBA32F: g.RGBA32F });
    var y = g.getExtension("WEBGL_color_buffer_float");
    return y === null ? (g.getExtension("OES_texture_float"), eD(g, g.FLOAT) ? { RGBA32F: 34836 } : null) : (g.getExtension("EXT_float_blend"), { RGBA32F: y.RGBA32F_EXT });
  }(t);
  Pr && f === null && console.log('Could not find support for "color_buffer_float"');
  var h = function(g) {
    if (ar(g)) return g.getExtension("EXT_color_buffer_half_float") === null ? null : (g.getExtension("EXT_float_blend"), { RGBA16F: g.RGBA16F });
    var y = g.getExtension("EXT_color_buffer_half_float");
    return y === null ? (g.getExtension("OES_texture_half_float"), eD(g, 36193) ? { RGBA16F: 34842 } : null) : (g.getExtension("EXT_float_blend"), { RGBA16F: y.RGBA16F_EXT });
  }(t);
  Pr && h === null && console.log('Could not find support for "color_buffer_half_float"');
  var m = function(g) {
    if (ar(g)) return { drawBuffers: g.drawBuffers.bind(g), COLOR_ATTACHMENT0: g.COLOR_ATTACHMENT0, COLOR_ATTACHMENT1: g.COLOR_ATTACHMENT1, COLOR_ATTACHMENT2: g.COLOR_ATTACHMENT2, COLOR_ATTACHMENT3: g.COLOR_ATTACHMENT3, COLOR_ATTACHMENT4: g.COLOR_ATTACHMENT4, COLOR_ATTACHMENT5: g.COLOR_ATTACHMENT5, COLOR_ATTACHMENT6: g.COLOR_ATTACHMENT6, COLOR_ATTACHMENT7: g.COLOR_ATTACHMENT7, DRAW_BUFFER0: g.DRAW_BUFFER0, DRAW_BUFFER1: g.DRAW_BUFFER1, DRAW_BUFFER2: g.DRAW_BUFFER2, DRAW_BUFFER3: g.DRAW_BUFFER3, DRAW_BUFFER4: g.DRAW_BUFFER4, DRAW_BUFFER5: g.DRAW_BUFFER5, DRAW_BUFFER6: g.DRAW_BUFFER6, DRAW_BUFFER7: g.DRAW_BUFFER7, MAX_COLOR_ATTACHMENTS: g.MAX_COLOR_ATTACHMENTS, MAX_DRAW_BUFFERS: g.MAX_DRAW_BUFFERS };
    var y = g.getExtension("WEBGL_draw_buffers");
    return y === null ? null : { drawBuffers: y.drawBuffersWEBGL.bind(y), COLOR_ATTACHMENT0: y.COLOR_ATTACHMENT0_WEBGL, COLOR_ATTACHMENT1: y.COLOR_ATTACHMENT1_WEBGL, COLOR_ATTACHMENT2: y.COLOR_ATTACHMENT2_WEBGL, COLOR_ATTACHMENT3: y.COLOR_ATTACHMENT3_WEBGL, COLOR_ATTACHMENT4: y.COLOR_ATTACHMENT4_WEBGL, COLOR_ATTACHMENT5: y.COLOR_ATTACHMENT5_WEBGL, COLOR_ATTACHMENT6: y.COLOR_ATTACHMENT6_WEBGL, COLOR_ATTACHMENT7: y.COLOR_ATTACHMENT7_WEBGL, DRAW_BUFFER0: y.DRAW_BUFFER0_WEBGL, DRAW_BUFFER1: y.DRAW_BUFFER1_WEBGL, DRAW_BUFFER2: y.DRAW_BUFFER2_WEBGL, DRAW_BUFFER3: y.DRAW_BUFFER3_WEBGL, DRAW_BUFFER4: y.DRAW_BUFFER4_WEBGL, DRAW_BUFFER5: y.DRAW_BUFFER5_WEBGL, DRAW_BUFFER6: y.DRAW_BUFFER6_WEBGL, DRAW_BUFFER7: y.DRAW_BUFFER7_WEBGL, MAX_COLOR_ATTACHMENTS: y.MAX_COLOR_ATTACHMENTS_WEBGL, MAX_DRAW_BUFFERS: y.MAX_DRAW_BUFFERS_WEBGL };
  }(t);
  Pr && m === null && console.log('Could not find support for "draw_buffers"');
  var p = function(g) {
    return ar(g) ? {} : g.getExtension("EXT_shader_texture_lod");
  }(t);
  Pr && p === null && console.log('Could not find support for "shader_texture_lod"');
  var v = function(g) {
    if (ar(g)) return { FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: g.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, SRGB8_ALPHA8: g.SRGB8_ALPHA8, SRGB8: g.SRGB8, SRGB: g.SRGB };
    var y = g.getExtension("EXT_sRGB");
    return y === null ? null : { FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: y.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT, SRGB8_ALPHA8: y.SRGB8_ALPHA8_EXT, SRGB8: y.SRGB_ALPHA_EXT, SRGB: y.SRGB_EXT };
  }(t);
  return Pr && v === null && console.log('Could not find support for "sRGB"'), { instancedArrays: e, standardDerivatives: n, textureFloat: i, textureFloatLinear: a, textureHalfFloat: o, textureHalfFloatLinear: s, elementIndexUint: r, depthTexture: u, blendMinMax: c, vertexArrayObject: l, fragDepth: d, colorBufferFloat: f, colorBufferHalfFloat: h, drawBuffers: m, shaderTextureLod: p, sRGB: v };
}
function nD(t, e, r) {
  var n = /* @__PURE__ */ new Map();
  return { get: function(i) {
    var a, o, s = t(i), u = n.get(s);
    return u || (a = e(i), o === void 0 && (o = 0), u = { value: a, usageCount: o }, n.set(s, u)), u.usageCount += 1, function(c) {
      return { free: function() {
        c.usageCount -= 1;
      }, value: c.value };
    }(u);
  }, clear: function() {
    n.forEach(function(i, a) {
      i.usageCount <= 0 && (i.usageCount < 0 && console.warn("Reference usageCount below zero."), r(i.value), n.delete(a));
    });
  }, get count() {
    return n.size;
  }, dispose: function() {
    n.forEach(function(i) {
      return r(i.value);
    }), n.clear();
  } };
}
(function(t) {
  t.create = function(e, r, n) {
    return { array: e, width: r, height: n };
  }, t.flipY = function(e) {
    for (var r = e.array, n = e.width, i = e.height, a = 4 * n, 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, f = r[l];
      r[l] = r[d], r[d] = f;
    }
    return e;
  }, t.divideByAlpha = function(e) {
    for (var r = e.array, n = r instanceof Uint8Array ? 255 : 1, i = 0, a = r.length; i < a; i += 4) {
      var o = r[i + 3] / n;
      o !== 0 ? (r[i] /= o, r[i + 1] /= o, r[i + 2] /= o) : (r[i] = 0, r[i + 1] = 0, r[i + 2] = 0);
    }
    return e;
  };
})(g0 || (g0 = {}));
var fJ = io();
function iD(t) {
  var e = t.createRenderbuffer();
  if (e === null) throw new Error("Could not create WebGL renderbuffer");
  return e;
}
function pJ(t, e, r, n, i) {
  var a = iD(t), o = function() {
    return t.bindRenderbuffer(t.RENDERBUFFER, a);
  }, s = function(d, f) {
    switch (f) {
      case "depth16":
        return d.DEPTH_COMPONENT16;
      case "stencil8":
        return d.STENCIL_INDEX8;
      case "rgba4":
        return d.RGBA4;
      case "depth-stencil":
        return d.DEPTH_STENCIL;
      case "depth32f":
        if (ar(d)) return d.DEPTH_COMPONENT32F;
        throw new Error("WebGL2 needed for `depth32f` renderbuffer format");
    }
  }(t, e), u = function(d, f) {
    switch (f) {
      case "depth":
        return d.DEPTH_ATTACHMENT;
      case "stencil":
        return d.STENCIL_ATTACHMENT;
      case "depth-stencil":
        return d.DEPTH_STENCIL_ATTACHMENT;
      case "color0":
        return d.COLOR_ATTACHMENT0;
    }
  }(t, r);
  function c() {
    o(), t.renderbufferStorage(t.RENDERBUFFER, s, n, i);
  }
  c();
  var l = !1;
  return { id: fJ(), bind: o, attachFramebuffer: function(d) {
    d.bind(), o(), t.framebufferRenderbuffer(t.FRAMEBUFFER, u, t.RENDERBUFFER, a), Pr && X9(t);
  }, setSize: function(d, f) {
    n = d, i = f, c();
  }, reset: function() {
    a = iD(t), c();
  }, destroy: function() {
    l || (t.deleteRenderbuffer(a), l = !0);
  } };
}
var zN = io();
function aD(t, e, r) {
  switch (e) {
    case "alpha":
      return ar(t) && r === "float" ? t.RED : ar(t) && r === "int" ? t.RED_INTEGER : t.ALPHA;
    case "rgb":
      return ar(t) && r === "int" ? t.RGB_INTEGER : t.RGB;
    case "rgba":
      return ar(t) && r === "int" ? t.RGBA_INTEGER : t.RGBA;
    case "depth":
      return t.DEPTH_COMPONENT;
  }
}
function oD(t, e) {
  switch (e) {
    case "nearest":
      return t.NEAREST;
    case "linear":
      return t.LINEAR;
  }
}
function kg(t, e, r) {
  switch (r) {
    case "depth":
      return t.DEPTH_ATTACHMENT;
    case "stencil":
      return t.STENCIL_ATTACHMENT;
    case "color0":
    case 0:
      return t.COLOR_ATTACHMENT0;
  }
  if (e.drawBuffers) switch (r) {
    case "color1":
    case 1:
      return e.drawBuffers.COLOR_ATTACHMENT1;
    case "color2":
    case 2:
      return e.drawBuffers.COLOR_ATTACHMENT2;
    case "color3":
    case 3:
      return e.drawBuffers.COLOR_ATTACHMENT3;
    case "color4":
    case 4:
      return e.drawBuffers.COLOR_ATTACHMENT4;
    case "color5":
    case 5:
      return e.drawBuffers.COLOR_ATTACHMENT5;
    case "color6":
    case 6:
      return e.drawBuffers.COLOR_ATTACHMENT6;
    case "color7":
    case 7:
      return e.drawBuffers.COLOR_ATTACHMENT7;
  }
  throw new Error("unknown texture attachment");
}
function sD(t) {
  return typeof HTMLImageElement < "u" && t instanceof HTMLImageElement;
}
function uD(t, e, r) {
  return e === r.TEXTURE_3D;
}
function cD(t) {
  var e = t.createTexture();
  if (e === null) throw new Error("Could not create WebGL texture");
  return e;
}
function R_(t, e, r, n, i, a) {
  var o = zN(), s = cD(t);
  if (r.endsWith("float32") && i !== "float" || r.endsWith("float16") && i !== "fp16" || r.endsWith("uint8") && i !== "ubyte" || r.endsWith("int32") && i !== "int" || r.endsWith("depth") && i !== "ushort" && i !== "float") throw new Error("texture kind '".concat(r, "' and type '").concat(i, "' are incompatible"));
  var u = function(_, x) {
    switch (x) {
      case "image-uint8":
      case "image-float32":
      case "image-float16":
      case "image-depth":
        return _.TEXTURE_2D;
    }
    if (ar(_)) switch (x) {
      case "image-int32":
        return _.TEXTURE_2D;
      case "volume-uint8":
      case "volume-float32":
      case "volume-float16":
        return _.TEXTURE_3D;
    }
    throw new Error("unknown texture kind '".concat(x, "'"));
  }(t, r), c = oD(t, a), l = aD(t, n, i), d = function(_, x, C) {
    if (ar(_)) switch (x) {
      case "alpha":
        switch (C) {
          case "ubyte":
            return _.ALPHA;
          case "float":
            return _.R32F;
          case "fp16":
            return _.R16F;
          case "int":
            return _.R32I;
        }
      case "rgb":
        switch (C) {
          case "ubyte":
            return _.RGB;
          case "float":
            return _.RGB32F;
          case "fp16":
            return _.RGB16F;
          case "int":
            return _.RGB32I;
        }
      case "rgba":
        switch (C) {
          case "ubyte":
            return _.RGBA;
          case "float":
            return _.RGBA32F;
          case "fp16":
            return _.RGBA16F;
          case "int":
            return _.RGBA32I;
        }
      case "depth":
        switch (C) {
          case "ushort":
            return _.DEPTH_COMPONENT16;
          case "float":
            return _.DEPTH_COMPONENT32F;
        }
    }
    return aD(_, x, C);
  }(t, n, i), f = function(_, x, C) {
    switch (C) {
      case "ubyte":
        return _.UNSIGNED_BYTE;
      case "ushort":
        return _.UNSIGNED_SHORT;
      case "float":
        return _.FLOAT;
      case "fp16":
        if (x.textureHalfFloat) return x.textureHalfFloat.HALF_FLOAT;
        throw new Error('extension "texture_half_float" unavailable');
      case "int":
        if (ar(_)) return _.INT;
        throw new Error('texture type "int" requires webgl2');
    }
  }(t, e, i);
  function h() {
    t.bindTexture(u, s), t.texParameteri(u, t.TEXTURE_MAG_FILTER, c), t.texParameteri(u, t.TEXTURE_MIN_FILTER, c), t.texParameteri(u, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(u, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.bindTexture(u, null);
  }
  h();
  var m, p = 0, v = 0, g = 0, y = !1;
  function b(_, x, C) {
    if (_ === 0 || x === 0 || ar(t) && u === t.TEXTURE_3D && C === 0) throw new Error("empty textures are not allowed");
    if (p !== _ || v !== x || g !== (C || 0)) if (p = _, v = x, g = C || 0, t.bindTexture(u, s), u === t.TEXTURE_2D) t.texImage2D(u, 0, d, p, v, 0, l, f, null);
    else {
      if (!ar(t) || u !== t.TEXTURE_3D || g === void 0) throw new Error("unknown texture target");
      t.texImage3D(u, 0, d, p, v, g, 0, l, f, null);
    }
  }
  function S(_, x) {
    if (x === void 0 && (x = !1), _.width === 0 || _.height === 0 || !sD(_) && ar(t) && uD(0, u, t) && _.depth === 0) throw new Error("empty textures are not allowed");
    if (t.bindTexture(u, s), t.pixelStorei(t.UNPACK_ALIGNMENT, 1), t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL, t.NONE), t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), sD(_)) p = _.width, v = _.height, t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, !1), t.bindTexture(t.TEXTURE_2D, s), t.texImage2D(t.TEXTURE_2D, 0, d, l, f, _);
    else if (function(A, w, I) {
      return w === I.TEXTURE_2D;
    }(0, u, t)) {
      var C = _.filter ? oD(t, _.filter) : c;
      t.texParameteri(u, t.TEXTURE_MAG_FILTER, C), t.texParameteri(u, t.TEXTURE_MIN_FILTER, C), t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, !!_.flipY), x ? t.texSubImage2D(u, 0, 0, 0, _.width, _.height, l, f, _.array) : (p = _.width, v = _.height, t.texImage2D(u, 0, d, p, v, 0, l, f, _.array));
    } else {
      if (!ar(t) || !uD(0, u, t)) throw new Error("unknown texture target");
      t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, !1), x ? t.texSubImage3D(u, 0, 0, 0, 0, _.width, _.height, _.depth, l, f, _.array) : (p = _.width, v = _.height, g = _.depth, t.texImage3D(u, 0, d, p, v, g, 0, l, f, _.array));
    }
    t.bindTexture(u, null), m = _;
  }
  return b(1, 1, ar(t) && u === t.TEXTURE_3D ? 1 : 0), { id: o, target: u, format: l, internalFormat: d, type: f, filter: c, getWidth: function() {
    return p;
  }, getHeight: function() {
    return v;
  }, getDepth: function() {
    return g;
  }, getByteCount: function() {
    return function(_, x, C, A, w) {
      var I = function(P) {
        switch (P) {
          case "alpha":
            return 1;
          case "rgb":
            return 3;
          case "rgba":
          case "depth":
            return 4;
        }
      }(_) * function(P) {
        switch (P) {
          case "ubyte":
            return 1;
          case "ushort":
          case "fp16":
            return 2;
          case "float":
          case "int":
            return 4;
        }
      }(x);
      return I * C * A * (w || 1);
    }(n, i, p, v, g);
  }, define: b, load: S, bind: function(_) {
    t.activeTexture(t.TEXTURE0 + _), t.bindTexture(u, s);
  }, unbind: function(_) {
    t.activeTexture(t.TEXTURE0 + _), t.bindTexture(u, null);
  }, attachFramebuffer: function(_, x, C) {
    if (_.bind(), u === t.TEXTURE_2D) t.framebufferTexture2D(t.FRAMEBUFFER, kg(t, e, x), t.TEXTURE_2D, s, 0);
    else {
      if (!ar(t) || u !== t.TEXTURE_3D) throw new Error("unknown/unsupported texture target");
      if (C === void 0) throw new Error("need `layer` to attach 3D texture");
      t.framebufferTextureLayer(t.FRAMEBUFFER, kg(t, e, x), s, 0, C);
    }
  }, detachFramebuffer: function(_, x) {
    if (_.bind(), u === t.TEXTURE_2D) t.framebufferTexture2D(t.FRAMEBUFFER, kg(t, e, x), t.TEXTURE_2D, null, 0);
    else {
      if (!ar(t) || u !== t.TEXTURE_3D) throw new Error("unknown texture target");
      t.framebufferTextureLayer(t.FRAMEBUFFER, kg(t, e, x), null, 0, 0);
    }
  }, reset: function() {
    s = cD(t), h();
    var _ = [p, v, g];
    p = 0, v = 0, g = 0, b(_[0], _[1], _[2]), m && S(m);
  }, destroy: function() {
    y || (t.deleteTexture(s), y = !0);
  } };
}
function lD(t, e, r) {
  var n = new Image();
  n.onload = function() {
    r.load(n), G.update(e, r);
  }, n.src = t;
}
function zo(t) {
  var e, r = (e = t == null ? void 0 : t.TEXTURE_2D) !== null && e !== void 0 ? e : 3553;
  return { id: zN(), target: r, format: 0, internalFormat: 0, type: 0, filter: 0, getWidth: function() {
    return 0;
  }, getHeight: function() {
    return 0;
  }, getDepth: function() {
    return 0;
  }, getByteCount: function() {
    return 0;
  }, define: function() {
  }, load: function() {
  }, bind: function(n) {
    t && (t.activeTexture(t.TEXTURE0 + n), t.bindTexture(r, null));
  }, unbind: function(n) {
    t && (t.activeTexture(t.TEXTURE0 + n), t.bindTexture(r, null));
  }, attachFramebuffer: function() {
  }, detachFramebuffer: function() {
  }, reset: function() {
  }, destroy: function() {
  } };
}
var hJ = io();
function dD(t) {
  var e = t.vertexArrayObject;
  if (!e) throw new Error("VertexArrayObject not supported");
  var r = e.createVertexArray();
  if (!r) throw new Error("Could not create WebGL vertex array");
  return r;
}
function fD(t) {
  var e = t.vertexArrayObject;
  if (e === null) throw new Error("VertexArrayObject not supported");
  return e;
}
function pD(t) {
  return O(O({}, t.value), { destroy: function() {
    t.free();
  } });
}
function mJ(t, e, r, n) {
  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), r.resourceCounts[c] += 1, O(O({}, l), { destroy: function() {
      l.destroy(), i[c].delete(l), r.resourceCounts[c] -= 1;
    } });
  }
  var o = nD(function(c) {
    return JSON.stringify(c);
  }, function(c) {
    return a("shader", uJ(t, c));
  }, function(c) {
    c.destroy();
  });
  function s(c, l) {
    return pD(o.get({ type: c, source: l }));
  }
  var u = nD(function(c) {
    var l, d = [c.shaderCode.id], f = ((l = c.defineValues.dRenderVariant) === null || l === void 0 ? void 0 : l.ref.value) || "";
    return Object.keys(c.defineValues).forEach(function(h) {
      var m, p;
      !((p = (m = c.shaderCode).ignoreDefine) === null || p === void 0) && p.call(m, h, f, c.defineValues) || d.push(x_(h), function(v) {
        return typeof v == "boolean" ? v ? 1 : 0 : typeof v == "number" ? 1e4 * v : x_(v);
      }(c.defineValues[h].ref.value));
    }), ro(d).toString();
  }, function(c) {
    return a("program", oJ(t, e, n, s, c));
  }, function(c) {
    c.destroy();
  });
  return { attribute: function(c, l, d, f) {
    return a("attribute", function(h, m, p, v, g, y, b) {
      b === void 0 && (b = "dynamic");
      var S = p.instancedArrays, _ = $w(h, v, b, "attribute"), x = _._bufferType, C = _._dataType, A = _._bpe;
      return O(O({}, _), { bind: function(w) {
        if (h.bindBuffer(x, _.getBuffer()), g === 16) for (var I = 0; I < 4; ++I) m.enableVertexAttrib(w + I), h.vertexAttribPointer(w + I, 4, C, !1, 16 * A, 4 * I * A), S.vertexAttribDivisor(w + I, y);
        else m.enableVertexAttrib(w), h.vertexAttribPointer(w, g, C, !1, 0, 0), S.vertexAttribDivisor(w, y);
      } });
    }(t, e, n, c, l, d, f));
  }, elements: function(c, l) {
    return a("elements", function(d, f, h) {
      h === void 0 && (h = "static");
      var m = $w(d, f, h, "elements");
      return O(O({}, m), { bind: function() {
        d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, m.getBuffer());
      } });
    }(t, c, l));
  }, framebuffer: function() {
    return a("framebuffer", function(c) {
      var l = tD(c), d = !1;
      return { id: GN(), bind: function() {
        return c.bindFramebuffer(c.FRAMEBUFFER, l);
      }, reset: function() {
        l = tD(c);
      }, destroy: function() {
        d || (c.deleteFramebuffer(l), d = !0);
      } };
    }(t));
  }, program: function(c, l, d) {
    return pD(u.get({ defineValues: c, shaderCode: l, schema: d }));
  }, renderbuffer: function(c, l, d, f) {
    return a("renderbuffer", pJ(t, c, l, d, f));
  }, shader: s, texture: function(c, l, d, f) {
    return a("texture", R_(t, n, c, l, d, f));
  }, vertexArray: function(c, l, d) {
    return a("vertexArray", function(f, h, m, p, v) {
      var g = hJ(), y = dD(h), b = fD(h);
      function S() {
        b.bindVertexArray(y), v && v.bind(), m.bindAttributes(p), b.bindVertexArray(null);
      }
      S();
      var _ = !1;
      return { id: g, bind: function() {
        b.bindVertexArray(y);
      }, update: S, reset: function() {
        y = dD(h), b = fD(h), S();
      }, destroy: function() {
        _ || (v && (b.bindVertexArray(y), f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, null)), b.deleteVertexArray(y), _ = !0);
      } };
    }(t, n, c, l, d));
  }, getByteCounts: function() {
    var c = 0;
    i.texture.forEach(function(f) {
      c += f.getByteCount();
    });
    var l = 0;
    i.attribute.forEach(function(f) {
      l += 4 * f.length;
    });
    var d = 0;
    return i.elements.forEach(function(f) {
      d += 4 * f.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 VN = io();
function UN(t, e) {
  switch (e) {
    case t.NO_ERROR:
      return "no error";
    case t.INVALID_ENUM:
      return "invalid enum";
    case t.INVALID_VALUE:
      return "invalid value";
    case t.INVALID_OPERATION:
      return "invalid operation";
    case t.INVALID_FRAMEBUFFER_OPERATION:
      return "invalid framebuffer operation";
    case t.OUT_OF_MEMORY:
      return "out of memory";
    case t.CONTEXT_LOST_WEBGL:
      return "context lost";
  }
  return "unknown error";
}
function HN(t) {
  var e = t.getError();
  if (e !== t.NO_ERROR) throw new Error("WebGL error: '".concat(UN(t, e), "'"));
}
function Gg(t) {
  t.bindFramebuffer(t.FRAMEBUFFER, null);
}
var qN = new Uint8Array(4);
function KN(t, e, r) {
  t.getSyncParameter(e, t.SYNC_STATUS) === t.SIGNALED ? (t.deleteSync(e), r()) : q9.setImmediate(KN, t, e, r);
}
function hD(t, e) {
  var r = t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE, 0);
  r ? q9.setImmediate(KN, t, r, e) : (console.warn("Could not create a WebGLSync object"), t.readPixels(0, 0, 1, 1, t.RGBA, t.UNSIGNED_BYTE, qN), e());
}
var I3, mD, gD = !1;
function vD(t) {
  t.bindFramebuffer(t.FRAMEBUFFER, null), t.readPixels(0, 0, 1, 1, t.RGBA, t.UNSIGNED_BYTE, qN);
}
function G6(t, e, r, n, i, a) {
  if (Pr && X9(t), a instanceof Uint8Array) t.readPixels(e, r, n, i, t.RGBA, t.UNSIGNED_BYTE, a);
  else if (a instanceof Float32Array) t.readPixels(e, r, n, i, t.RGBA, t.FLOAT, a);
  else {
    if (!(a instanceof Int32Array && ar(t))) throw new Error("unsupported readPixels buffer type");
    t.readPixels(e, r, n, i, t.RGBA_INTEGER, t.INT, a);
  }
  Pr && HN(t);
}
function gJ(t, e) {
  var r = this;
  e === void 0 && (e = {});
  var n = rD(t), i = function(g) {
    var y = {}, b = g.getParameter(g.FRONT_FACE), S = g.getParameter(g.CULL_FACE_MODE), _ = g.getParameter(g.DEPTH_WRITEMASK), x = g.getParameter(g.COLOR_WRITEMASK), C = g.getParameter(g.COLOR_CLEAR_VALUE), A = g.getParameter(g.BLEND_SRC_RGB), w = g.getParameter(g.BLEND_DST_RGB), I = g.getParameter(g.BLEND_SRC_ALPHA), P = g.getParameter(g.BLEND_DST_ALPHA), M = g.getParameter(g.BLEND_EQUATION_RGB), T = g.getParameter(g.BLEND_EQUATION_ALPHA), F = g.getParameter(g.MAX_VERTEX_ATTRIBS), N = [], R = function() {
      for (var L = 0; L < F; ++L) N[L] = 0;
    };
    return R(), { currentProgramId: -1, currentMaterialId: -1, currentRenderItemId: -1, enable: function(L) {
      y[L] !== !0 && (g.enable(L), y[L] = !0);
    }, disable: function(L) {
      y[L] !== !1 && (g.disable(L), y[L] = !1);
    }, frontFace: function(L) {
      L !== b && (g.frontFace(L), b = L);
    }, cullFace: function(L) {
      L !== S && (g.cullFace(L), S = L);
    }, depthMask: function(L) {
      L !== _ && (g.depthMask(L), _ = L);
    }, colorMask: function(L, V, U, H) {
      L === x[0] && V === x[1] && U === x[2] && H === x[3] || (g.colorMask(L, V, U, H), x[0] = L, x[1] = V, x[2] = U, x[3] = H);
    }, clearColor: function(L, V, U, H) {
      L === C[0] && V === C[1] && U === C[2] && H === C[3] || (g.clearColor(L, V, U, H), C[0] = L, C[1] = V, C[2] = U, C[3] = H);
    }, blendFunc: function(L, V) {
      L === A && V === w && L === I && V === P || (g.blendFunc(L, V), A = L, w = V, I = L, P = V);
    }, blendFuncSeparate: function(L, V, U, H) {
      L === A && V === w && U === I && H === P || (g.blendFuncSeparate(L, V, U, H), A = L, w = V, I = U, P = H);
    }, blendEquation: function(L) {
      L === M && L === T || (g.blendEquation(L), M = L, T = L);
    }, blendEquationSeparate: function(L, V) {
      L === M && V === T || (g.blendEquationSeparate(L, V), M = L, T = V);
    }, enableVertexAttrib: function(L) {
      g.enableVertexAttribArray(L), N[L] = 1;
    }, clearVertexAttribsState: R, disableUnusedVertexAttribs: function() {
      for (var L = 0; L < F; ++L) N[L] === 0 && g.disableVertexAttribArray(L);
    }, reset: function() {
      y = {}, b = g.getParameter(g.FRONT_FACE), S = g.getParameter(g.CULL_FACE_MODE), _ = g.getParameter(g.DEPTH_WRITEMASK), x = g.getParameter(g.COLOR_WRITEMASK), C = g.getParameter(g.COLOR_CLEAR_VALUE), A = g.getParameter(g.BLEND_SRC_RGB), w = g.getParameter(g.BLEND_DST_RGB), I = g.getParameter(g.BLEND_SRC_ALPHA), P = g.getParameter(g.BLEND_DST_ALPHA), M = g.getParameter(g.BLEND_EQUATION_RGB), T = g.getParameter(g.BLEND_EQUATION_ALPHA), F = g.getParameter(g.MAX_VERTEX_ATTRIBS), N.length = 0;
      for (var L = 0; L < F; ++L) N[L] = 0;
    } };
  }(t), 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 = mJ(t, i, a, n), s = { maxTextureSize: t.getParameter(t.MAX_TEXTURE_SIZE), max3dTextureSize: ar(t) ? t.getParameter(t.MAX_3D_TEXTURE_SIZE) : 0, maxRenderbufferSize: t.getParameter(t.MAX_RENDERBUFFER_SIZE), maxDrawBuffers: n.drawBuffers ? t.getParameter(n.drawBuffers.MAX_DRAW_BUFFERS) : 0, maxTextureImageUnits: t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), maxVertexTextureImageUnits: t.getParameter(t.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 kd(0);
  if (ar(t)) {
    var d = t.createBuffer(), f = void 0, h = void 0, m = !1, p = function() {
      t.bindBuffer(t.PIXEL_PACK_BUFFER, d), t.getBufferSubData(t.PIXEL_PACK_BUFFER, 0, f), t.bindBuffer(t.PIXEL_PACK_BUFFER, null), m = !1, h(), h = void 0, f = void 0;
    };
    u = function(g, y, b, S, _) {
      return new Promise(function(x, C) {
        m ? C("Can not call multiple readPixelsAsync at the same time") : (m = !0, t.bindBuffer(t.PIXEL_PACK_BUFFER, d), t.bufferData(t.PIXEL_PACK_BUFFER, b * S * 4, t.STREAM_READ), t.readPixels(g, y, b, S, t.RGBA, t.UNSIGNED_BYTE, 0), t.bindBuffer(t.PIXEL_PACK_BUFFER, null), h = x, f = _, hD(t, p));
      });
    };
  } else u = function(g, y, b, S, _) {
    return _e(r, 0, void 0, function() {
      return ye(this, function(x) {
        return G6(t, g, y, b, S, _), [2];
      });
    });
  };
  var v = /* @__PURE__ */ new Set();
  return { gl: t, isWebGL2: ar(t), get pixelRatio() {
    return (typeof window < "u" && window.devicePixelRatio || 1) * (e.pixelScale || 1);
  }, extensions: n, 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 || t.isContextLost();
  }, contextRestored: l, setContextLost: function() {
    c = !0;
  }, handleContextRestored: function(g) {
    Object.assign(n, rD(t)), i.reset(), i.currentMaterialId = -1, i.currentProgramId = -1, i.currentRenderItemId = -1, o.reset(), v.forEach(function(y) {
      return y.reset();
    }), g == null || g(), c = !1, l.next(wi());
  }, createRenderTarget: function(g, y, b, S, _) {
    var x = function(C, A, w, I, P, M, T) {
      P === void 0 && (P = !0), M === void 0 && (M = "uint8"), T === void 0 && (T = "nearest");
      var F = A.framebuffer(), N = M === "fp16" ? A.texture("image-float16", "rgba", "fp16", T) : M === "float32" ? A.texture("image-float32", "rgba", "float", T) : A.texture("image-uint8", "rgba", "ubyte", T), R = P ? ar(C) ? A.renderbuffer("depth32f", "depth", w, I) : A.renderbuffer("depth16", "depth", w, I) : null;
      function L() {
        N.define(w, I), N.attachFramebuffer(F, "color0"), R && R.attachFramebuffer(F);
      }
      L();
      var V = !1;
      return { id: VN(), texture: N, framebuffer: F, getWidth: function() {
        return w;
      }, getHeight: function() {
        return I;
      }, bind: function() {
        F.bind();
      }, setSize: function(U, H) {
        w === U && I === H || (w = U, I = H, N.define(w, I), R && R.setSize(w, I));
      }, reset: function() {
        L();
      }, destroy: function() {
        V || (N.destroy(), F.destroy(), R && R.destroy(), V = !0);
      } };
    }(t, o, g, y, b, S, _);
    return v.add(x), O(O({}, x), { destroy: function() {
      x.destroy(), v.delete(x);
    } });
  }, unbindFramebuffer: function() {
    return Gg(t);
  }, readPixels: function(g, y, b, S, _) {
    G6(t, g, y, b, S, _);
  }, readPixelsAsync: u, waitForGpuCommandsComplete: function() {
    return function(g) {
      return new Promise(function(y) {
        ar(g) ? hD(g, y) : (gD || (console.info("Sync object not supported in WebGL"), gD = !0), vD(g), y());
      });
    }(t);
  }, waitForGpuCommandsCompleteSync: function() {
    return vD(t);
  }, getDrawingBufferPixelData: function() {
    return function(g) {
      var y = g.drawingBufferWidth, b = g.drawingBufferHeight, S = new Uint8Array(y * b * 4);
      return Gg(g), g.viewport(0, 0, y, b), G6(g, 0, 0, y, b, S), g0.flipY(g0.create(S, y, b));
    }(t);
  }, clear: function(g, y, b, S) {
    Gg(t), i.enable(t.SCISSOR_TEST), i.depthMask(!0), i.colorMask(!0, !0, !0, !0), i.clearColor(g, y, b, S), t.viewport(0, 0, t.drawingBufferWidth, t.drawingBufferHeight), t.scissor(0, 0, t.drawingBufferWidth, t.drawingBufferHeight), t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT);
  }, destroy: function(g) {
    var y, b;
    o.destroy(), function(S) {
      for (var _ = S.getParameter(S.MAX_TEXTURE_IMAGE_UNITS), x = 0; x < _; ++x) S.activeTexture(S.TEXTURE0 + x), S.bindTexture(S.TEXTURE_2D, null), S.bindTexture(S.TEXTURE_CUBE_MAP, null), ar(S) && (S.bindTexture(S.TEXTURE_2D_ARRAY, null), S.bindTexture(S.TEXTURE_3D, null));
      var C = S.createBuffer();
      S.bindBuffer(S.ARRAY_BUFFER, C);
      var A = S.getParameter(S.MAX_VERTEX_ATTRIBS);
      for (x = 0; x < A; ++x) S.vertexAttribPointer(x, 1, S.FLOAT, !1, 0, 0);
      S.bindBuffer(S.ARRAY_BUFFER, null), S.bindBuffer(S.ELEMENT_ARRAY_BUFFER, null), S.bindRenderbuffer(S.RENDERBUFFER, null), Gg(S);
    }(t), g != null && g.doNotForceWebGLContextLoss || ((y = t.getExtension("WEBGL_lose_context")) === null || y === void 0 || y.loseContext(), (b = t.getExtension("STACKGL_destroy_context")) === null || b === void 0 || b.destroy());
  } };
}
function z6(t, e) {
  return { value: t, unit: e };
}
function ku(t) {
  return t;
}
(function(t) {
  t.create = function(o, s, u) {
    var c = !!o[0].cell, l = !!o[0].velocities, d = !!o[0].forces;
    return { id: Ki.create22(), frames: o, hasCell: c, hasVelocities: l, hasForces: d, deltaTime: s, timeOffset: u };
  }, t.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)) : xo(o.xyzOrdering.index, u) || (c = n(c, o.xyzOrdering.index, u), l = n(l, o.xyzOrdering.index, u), d = n(d, o.xyzOrdering.index, u)) : o.xyzOrdering.isIdentity || (c = 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, r(c, u), r(l, u), r(d, u)) : xo(o.xyzOrdering.index, u) || (c = n(c, o.xyzOrdering.index, u), l = n(l, o.xyzOrdering.index, u), d = n(d, o.xyzOrdering.index, u))), o.xyzOrdering.frozen = !0, { id: Ki.create22(), atomId: s, occupancy: se.ofConst(1, o.elementCount, se.Schema.int), B_iso_or_equiv: se.ofConst(0, o.elementCount, se.Schema.float), xyzDefined: !0, x: c, y: l, z: d };
  };
  var e = [0.123];
  function r(o, s) {
    for (var u = e, c = 0, l = o.length; c < l; c++) u[c] = o[s[c]];
    for (c = 0, l = o.length; c < l; c++) o[c] = u[c];
  }
  function n(o, s, u) {
    for (var c = new Float32Array(o.length), l = 0, d = o.length; l < d; l++) c[l] = o[s[u[l]]];
    return c;
  }
  function 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;
  }
})(I3 || (I3 = {})), function(t) {
  t.create = function(e, r, n, i) {
    return { id: Ki.create22(), label: e, basic: r, sourceData: i, bonds: n };
  };
}(mD || (mD = {})), function(t) {
  t.getUUID = function(e) {
    return e.__key || (e.__key = Ki.create22()), e.__key;
  };
}(ku || (ku = {}));
var Xo, jp = function() {
  function t() {
    this._list = [], this._set = /* @__PURE__ */ new Set(), this._refs = /* @__PURE__ */ new Map(), this._assets = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(t.prototype, "all", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), t.prototype.add = function(e) {
    this._set.has(e) || (this._list.push(e), this._set.add(e));
  }, t.prototype.reference = function(e, r) {
    var n = this._refs.get(e) || 0;
    n += r ? 1 : -1, this._refs.set(e, Math.max(n, 0));
  }, t.prototype.hasReference = function(e) {
    return (this._refs.get(e) || 0) > 0;
  }, t.prototype.has = function(e) {
    return this._set.has(e);
  }, t.prototype.assets = function(e, r) {
    var n = this._assets.get(e);
    if (n) for (var i = 0, a = n; i < a.length; i++)
      a[i].dispose();
    r ? this._assets.set(e, r) : this._assets.delete(e);
  }, t.prototype.dispose = function() {
    this._assets.forEach(function(e) {
      for (var r = 0, n = e; r < n.length; r++)
        n[r].dispose();
    });
  }, t;
}();
function XN(t, e, r, n, i) {
  for (var a = t.b, o = t.offset, s = [], u = 0, c = e.length; u < c; ++u) for (var l = e[u], d = o[l], f = o[l + 1]; d < f; ++d) {
    var h = a[d];
    if (!i.has(h)) {
      if (Ke.has(r, h)) return !0;
      i.add(h), s[s.length] = h;
    }
  }
  return n > 1 && XN(t, s, r, n - 1, i);
}
(function(t) {
  t.areEqual = function(s, u) {
    if (s === u) return !0;
    if (s.vertexCount !== u.vertexCount || s.edgeCount !== u.edgeCount) return !1;
    for (var c = s.a, l = s.b, d = s.offset, f = u.a, h = u.b, m = u.offset, p = 0, v = s.a.length; p < v; p++) if (c[p] !== f[p]) return !1;
    for (p = 0, v = s.b.length; p < v; p++) if (l[p] !== h[p]) return !1;
    for (p = 0, v = s.offset.length; p < v; p++) if (d[p] !== m[p]) return !1;
    for (var g = 0, y = Object.keys(s.edgeProps); g < y.length; g++) {
      var b = y[g], S = s.edgeProps[b], _ = u.edgeProps[b];
      if (!_) return !1;
      for (p = 0, v = S.length; p < v; p++) if (S[p] !== _[p]) return !1;
    }
    return !0;
  };
  var e = function() {
    function s(u, c, l, d, f, h) {
      this.offset = u, this.a = c, this.b = l, this.edgeCount = d, this.props = h, this.vertexCount = u.length - 1, this.edgeProps = f || {};
    }
    return s.prototype.getEdgeIndex = function(u, c) {
      var l, d;
      u < c ? (l = u, d = c) : (l = c, d = u);
      for (var f = this.offset[l], h = this.offset[l + 1]; f < h; f++) if (this.b[f] === d) return f;
      return -1;
    }, s.prototype.getDirectedEdgeIndex = function(u, c) {
      for (var l = this.offset[u], d = this.offset[u + 1]; l < d; l++) if (this.b[l] === c) return l;
      return -1;
    }, s.prototype.getVertexEdgeCount = function(u) {
      return this.offset[u + 1] - this.offset[u];
    }, s;
  }();
  function r(s, u, c, l, d, f) {
    return new e(s, u, c, l, d, f);
  }
  t.create = r;
  var n = function() {
    function s(u, c, l) {
      this.vertexCount = u, this.xs = c, this.ys = l, this.current = 0, this.curA = 0, this.curB = 0, this.edgeCount = c.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
      for (var d = new Int32Array(this.vertexCount), f = 0, h = this.xs.length; f < h; f++) d[this.xs[f]]++;
      for (f = 0, h = this.ys.length; f < h; f++) d[this.ys[f]]++;
      var m = 0;
      for (f = 0; f < this.vertexCount; f++) this.offsets[f] = m, m += d[f];
      this.offsets[this.vertexCount] = m, this.slotCount = m, this.a = new Int32Array(m), this.b = new Int32Array(m);
    }
    return s.prototype.createGraph = function(u, c) {
      return r(this.offsets, this.a, this.b, this.edgeCount, u, c);
    }, s.prototype.addNextEdge = function() {
      var u = this.xs[this.current], c = this.ys[this.current], l = this.offsets[u] + this.bucketFill[u], d = this.offsets[c] + this.bucketFill[c];
      this.a[l] = u, this.b[l] = c, this.bucketFill[u]++, this.a[d] = c, this.b[d] = u, this.bucketFill[c]++, this.current++, this.curA = l, this.curB = d;
    }, s.prototype.addAllEdges = function() {
      for (var u = 0; u < this.edgeCount; u++) this.addNextEdge();
    }, s.prototype.assignProperty = function(u, c) {
      u[this.curA] = c, u[this.curB] = c;
    }, s;
  }();
  t.EdgeBuilder = n;
  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), f = 0, h = this.xs.length; f < h; f++) d[this.xs[f]]++;
      var m = 0;
      for (f = 0; f < this.vertexCount; f++) this.offsets[f] = m, m += d[f];
      this.offsets[this.vertexCount] = m, this.slotCount = m, this.a = new Int32Array(m), this.b = new Int32Array(m);
    }
    return s.prototype.createGraph = function(u) {
      return r(this.offsets, this.a, this.b, this.edgeCount, u);
    }, s.prototype.addNextEdge = function() {
      var u = this.xs[this.current], c = this.ys[this.current], l = this.offsets[u] + this.bucketFill[u];
      this.a[l] = u, this.b[l] = c, this.bucketFill[u]++, this.current++, this.curA = l;
    }, s.prototype.addAllEdges = function() {
      for (var u = 0; u < this.edgeCount; u++) this.addNextEdge();
    }, s.prototype.assignProperty = function(u, c) {
      u[this.curA] = c;
    }, s;
  }();
  t.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 f = iu(l, d);
      return !this.included.has(f) && (this.included.add(f), this.xs[this.xs.length] = l, this.ys[this.ys.length] = d, !0);
    }, s.prototype.getGraph = function() {
      return o(this.vertexCount, this.xs, this.ys);
    }, s.prototype.getEdgeBuiler = function() {
      return new n(this.vertexCount, this.xs, this.ys);
    }, s;
  }();
  function o(s, u, c) {
    var l = new t.EdgeBuilder(s, u, c);
    return l.addAllEdges(), l.createGraph({});
  }
  t.UniqueEdgeBuilder = a, t.fromVertexPairs = o, t.induceByVertices = function(s, u) {
    for (var c = s.b, l = s.offset, d = s.vertexCount, f = s.edgeProps, h = new Int32Array(d), m = 0, p = u.length; m < p; m++) h[u[m]] = m + 1;
    var v = 0;
    for (m = 0; m < d; m++) if (h[m] !== 0) for (var g = l[m], y = l[m + 1]; g < y; g++) c[g] > m && h[c[g]] !== 0 && v++;
    var b = new Int32Array(u.length + 1), S = new Int32Array(2 * v), _ = new Int32Array(2 * v), x = new Int32Array(2 * v), C = 0, A = 0;
    for (m = 0; m < d; m++) if (h[m] !== 0) {
      var w = h[m] - 1;
      for (g = l[m], y = l[m + 1]; g < y; g++) {
        var I = h[c[g]];
        I !== 0 && (_[C] = w, x[C] = I - 1, S[C] = g, C++);
      }
      b[++A] = C;
    }
    for (var P = {}, M = 0, T = Object.keys(f); M < T.length; M++) {
      var F = T[M];
      P[F] = jj(f[F], S);
    }
    return r(b, _, x, v, P);
  }, t.connectedComponents = function(s) {
    var u = s.vertexCount;
    if (u === 0) return { componentCount: 0, componentIndex: new Int32Array(0) };
    if (s.edgeCount === 0) {
      for (var c = new Int32Array(u), l = 0, d = u; l < d; l++) c[l] = l;
      return { componentCount: u, componentIndex: c };
    }
    var f = new Int32Array(u);
    for (l = 0, d = u; l < d; l++) f[l] = -1;
    var h = 0;
    f[0] = h;
    var m = s.offset, p = s.b, v = [0], g = function(C) {
      return new $Z(C);
    }(u);
    for (g.remove(0); v.length > 0; ) {
      for (var y = v.pop(), b = f[y], S = m[y], _ = m[y + 1]; S < _; S++) {
        var x = p[S];
        g.has(x) && (g.remove(x), v.push(x), f[x] = b);
      }
      v.length === 0 && g.head >= 0 && (v.push(g.head), f[g.head] = ++h, g.remove(g.head));
    }
    return { componentCount: u, componentIndex: f };
  }, t.areVertexSetsConnected = function(s, u, c, l) {
    if (Ke.areIntersecting(u, c)) return !0;
    if (l < 1) return !1;
    for (var d = /* @__PURE__ */ new Set(), f = 0, h = u.length; f < h; ++f) d.add(u[f]);
    return XN(s, u, c, l, d);
  };
})(Xo || (Xo = {}));
var gc, Xi, ut, lp, vJ = function() {
  function t() {
    this.map = /* @__PURE__ */ new Map(), this.applicable = /* @__PURE__ */ new Map();
  }
  return t.prototype.add = function(e, r, n) {
    this.map.set(e, r), n && this.applicable.set(e, n);
  }, t.prototype.remove = function(e) {
    this.map.delete(e), this.applicable.delete(e);
  }, t.prototype.get = function(e) {
    return this.map.get(e);
  }, t.prototype.isApplicable = function(e) {
    var r = this.applicable.get(e.sourceData.kind);
    return !r || r(e);
  }, t;
}();
function yJ(t, e, r, n) {
  for (var i = new Xo.EdgeBuilder(n, t, e), 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, r.key ? r.key[c] : -1), i.assignProperty(o, r.order ? r.order[c] : 1), i.assignProperty(s, r.distance ? r.distance[c] : -1), i.assignProperty(u, r.flag ? r.flag[c] : 1);
  return i.createGraph({ key: a, order: o, distance: s, flag: u });
}
function Wr(t) {
  return function(e) {
    return function(r, n) {
      var i = r.data, a = r.indices, o = r.count, s = n.valueType, u = s === "str" ? function(c) {
        return i.substring(a[2 * c], a[2 * c + 1]);
      } : s === "int" ? function(c) {
        return Zd(i, a[2 * c], a[2 * c + 1]) || 0;
      } : function(c) {
        return p0(i, a[2 * c], a[2 * c + 1]) || 0;
      };
      return { schema: n, __array: void 0, isDefined: !0, rowCount: o, value: u, valueKind: function(c) {
        return 0;
      }, toArray: function(c) {
        return Sa(o, u, c);
      }, areValuesEqual: YN(r) };
    }(t, e);
  };
}
function YN(t) {
  var e = t.data, r = t.indices;
  return function(n, i) {
    var a = r[2 * n], o = r[2 * i], s = r[2 * n + 1] - a;
    if (s !== r[2 * i + 1] - o) return !1;
    for (var u = 0; u < s; u++) if (e.charCodeAt(u + a) !== e.charCodeAt(u + o)) return !1;
    return !0;
  };
}
function bJ(t) {
  for (var e = t.count, r = t.indices, n = 0; n < e; ++n) if (r[2 * n] !== r[2 * n + 1]) return !1;
  return !0;
}
function WN(t, e) {
  return { name: e, blocks: t };
}
function Y9(t, e, r, n) {
  return n === void 0 && (n = []), { categoryNames: t, header: r, categories: e, saveFrames: n, getField: function(i) {
    var a = i.split("."), o = a[0], s = a[1];
    return e[o].getField(s || "");
  } };
}
function La(t, e, r, n) {
  return { rowCount: e, name: t, fieldNames: Ze([], r, !0), getField: function(i) {
    return n[i];
  } };
}
function t0(t, e, r) {
  return function(n, i, a) {
    for (var o = /* @__PURE__ */ Object.create(null), s = 0, u = Object.keys(n); s < u.length; s++) {
      var c = u[s];
      o[c] = SJ(c, n[c], i, a);
    }
    return __.ofTables(i.header, n, o);
  }(t, e, r);
}
function V6(t, e, r, n) {
  return { schema: t, __array: e.__array, isDefined: e.isDefined, rowCount: e.rowCount, value: r, valueKind: e.valueKind, areValuesEqual: e.areValuesEqual, toArray: n };
}
function _J(t, e, r) {
  var n = t.space, i = e.fieldNames.includes("".concat(r, "[0]")) || e.fieldNames.includes("".concat(r, "[0][0]")) || e.fieldNames.includes("".concat(r, "[0][0][0]")), a = i ? 0 : 1, o = e.fieldNames.includes("".concat(r, "_1")) || e.fieldNames.includes("".concat(r, "_11")) || e.fieldNames.includes("".concat(r, "_111")) ? "underscore" : "brackets", s = function(l, d, f, h) {
    var m = f ? 0 : 1;
    switch (d) {
      case 1:
        return h === "brackets" ? function(p) {
          return "".concat(l, "[").concat(p + m, "]");
        } : function(p) {
          return "".concat(l, "_").concat(p + m);
        };
      case 2:
        return h === "brackets" ? function(p, v) {
          return "".concat(l, "[").concat(p + m, "][").concat(v + m, "]");
        } : function(p, v) {
          return "".concat(l, "_").concat(p + m).concat(v + m);
        };
      case 3:
        return h === "brackets" ? function(p, v, g) {
          return "".concat(l, "[").concat(p + m, "][").concat(v + m, "][").concat(g + m, "]");
        } : function(p, v, g) {
          return "".concat(l, "_").concat(p + m).concat(v + m).concat(g + m);
        };
      default:
        throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    }
  }(r, n.rank, i, o), u = e.getField(s(a, a, a)) || se.Undefined(e.rowCount, t), c = function(l) {
    return function(d, f, h, m) {
      var p = f.create();
      if (f.rank === 1) for (var v = f.dimensions[0], g = 0; g < v; g++) {
        var y = d.getField(m(g));
        f.set(p, g, y ? y.float(h) : 0);
      }
      else if (f.rank === 2) {
        v = f.dimensions[0];
        var b = f.dimensions[1];
        for (g = 0; g < v; g++) for (var S = 0; S < b; S++) y = d.getField(m(g, S)), f.set(p, g, S, y ? y.float(h) : 0);
      } else {
        if (f.rank !== 3) throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
        var _ = f.dimensions[0], x = f.dimensions[1], C = f.dimensions[2];
        for (g = 0; g < _; g++) for (S = 0; S < x; S++) for (var A = 0; A < C; A++) y = d.getField(m(g, S, A)), f.set(p, g, S, A, y ? y.float(h) : 0);
      }
      return p;
    }(e, n, l, s);
  };
  return { schema: t, __array: void 0, isDefined: u.isDefined, rowCount: e.rowCount, value: c, valueKind: u.valueKind, areValuesEqual: function(l, d) {
    return Qn.areEqualExact(c(l), c(d));
  }, toArray: function(l) {
    return Sa(e.rowCount, c, l);
  } };
}
(function(t) {
  t.create = function(e, r) {
    var n = e.name, i = new vJ();
    return { descriptor: e, formatRegistry: i, isApplicable: function(a) {
      return i.isApplicable(a);
    }, get: function(a) {
      var o = r != null && r.asDynamic ? a._dynamicPropertyData : a._staticPropertyData;
      if (o[n]) return o[n];
      if (!a.customProperties.has(e)) {
        var s = i.get(a.sourceData.kind);
        if (s) return o[n] = s(a), a.customProperties.add(e), o[n];
      }
    }, set: function(a, o) {
      r != null && r.asDynamic ? a._dynamicPropertyData[n] = o : a._staticPropertyData[n] = o;
    }, delete: function(a) {
      r != null && r.asDynamic ? delete a._dynamicPropertyData[n] : delete a._staticPropertyData[n];
    } };
  };
})(gc || (gc = {})), function(t) {
  t.Descriptor = { name: "index_pair_bonds" }, t.Provider = gc.create(t.Descriptor, { asDynamic: !0 }), t.DefaultProps = { maxDistance: -1 }, t.fromData = function(e, r) {
    r === void 0 && (r = {});
    var n = O(O({}, t.DefaultProps), r), i = e.pairs, a = e.count;
    return { bonds: yJ(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: n.maxDistance };
  };
}(Xi || (Xi = {})), function(t) {
  function e(r, n) {
    var i = Object.keys(n);
    return { rowCount: i.length > 0 ? n[i[0]].rowCount : 0, name: r, fieldNames: i, getField: function(a) {
      return n[a];
    } };
  }
  t.empty = function(r) {
    return { rowCount: 0, name: r, fieldNames: [], getField: function(n) {
    } };
  }, t.ofFields = e, t.ofTable = function(r, n) {
    for (var i = {}, a = 0, o = n._columns; a < o.length; a++) {
      var s = o[a];
      i[s] = ut.ofColumn(n[s]);
    }
    return e(r, i);
  };
}(La || (La = {})), function(t) {
  function e(n) {
    var i = n.length, a = function(u) {
      var c = n[u];
      return c && c !== "." && c !== "?" ? c : "";
    }, o = function(u) {
      var c = n[u];
      return Zd(c, 0, c.length) || 0;
    }, s = function(u) {
      var c = n[u];
      return p0(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 = n[u], l = c.length;
      if (l > 1) return 0;
      if (l === 0) return 1;
      var d = c.charCodeAt(0);
      return d === 46 ? 1 : d === 63 ? 2 : 0;
    }, areValuesEqual: function(u, c) {
      return n[u] === n[c];
    }, toStringArray: function(u) {
      return u ? Sa(i, a, u) : n;
    }, toIntArray: function(u) {
      return Sa(i, o, u);
    }, toFloatArray: function(u) {
      return Sa(i, s, u);
    } };
  }
  function r(n) {
    var i, a, o, s = n.rowCount, u = n.valueKind, c = n.areValuesEqual, l = n.isDefined;
    switch (n.schema.valueType) {
      case "float":
      case "int":
        i = function(f) {
          return "" + n.value(f);
        }, a = n.value, o = n.value;
        break;
      case "str":
        i = n.value, a = function(f) {
          var h = n.value(f);
          return Zd(h, 0, h.length) || 0;
        }, o = function(f) {
          var h = n.value(f);
          return p0(h, 0, h.length) || 0;
        };
        break;
      case "list":
        var d = n.schema.separator;
        i = function(f) {
          return n.value(f).join(d);
        }, a = function(f) {
          return NaN;
        }, o = function(f) {
          return NaN;
        };
        break;
      default:
        throw new Error("unsupported valueType '".concat(n.schema.valueType, "'"));
    }
    return { __array: void 0, binaryEncoding: void 0, isDefined: l, rowCount: s, str: i, int: a, float: o, valueKind: u, areValuesEqual: c, toStringArray: function(f) {
      return Sa(s, i, f);
    }, toIntArray: function(f) {
      return Sa(s, a, f);
    }, toFloatArray: function(f) {
      return Sa(s, o, f);
    } };
  }
  t.ofString = function(n) {
    return e([n]);
  }, t.ofStrings = e, t.ofNumbers = function(n) {
    var i = n.length, a = function(u) {
      return "" + n[u];
    }, o = function(u) {
      return n[u];
    }, s = function(u) {
      return !u || u.array && n instanceof u.array ? n : Sa(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 n[u] === n[c];
    }, toStringArray: function(u) {
      return Sa(i, a, u);
    }, toIntArray: s, toFloatArray: s };
  }, t.ofTokens = function(n) {
    var i = n.data, a = n.indices, o = n.count, s = function(l) {
      var d = i.substring(a[2 * l], a[2 * l + 1]);
      return d === "." || d === "?" ? "" : d;
    }, u = function(l) {
      return Zd(i, a[2 * l], a[2 * l + 1]) || 0;
    }, c = function(l) {
      return p0(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], f = a[2 * l + 1] - d;
      if (f > 1) return 0;
      if (f === 0) return 1;
      var h = i.charCodeAt(d);
      return h === 46 ? 1 : h === 63 ? 2 : 0;
    }, areValuesEqual: YN(n), toStringArray: function(l) {
      return Sa(o, s, l);
    }, toIntArray: function(l) {
      return Sa(o, u, l);
    }, toFloatArray: function(l) {
      return Sa(o, c, l);
    } };
  }, t.ofColumn = r, t.ofUndefined = function(n, i) {
    return r(se.Undefined(n, i));
  };
}(ut || (ut = {})), function(t) {
  function e(r) {
    return r.replace(".", "_").replace(/\[/, "_").replace(/(\[|\])/g, "");
  }
  t.canonical = e, t.equal = function(r, n) {
    return e(r) === e(n);
  }, t.create = function(r, n, i) {
    i === void 0 && (i = !1);
    var a = "".concat(r).concat(n ? ".".concat(n) : "");
    return i ? e(a) : a;
  };
}(lp || (lp = {}));
var wn, jN = function(t, e, r) {
  this._isDefined = r;
  var n = Object.keys(e);
  this._rowCount = t.rowCount, this._columns = n, this._schema = e;
  for (var i = /* @__PURE__ */ Object.create(null), a = function(c) {
    Object.defineProperty(o, c, { get: function() {
      if (i[c]) return i[c];
      var l = e[c];
      if (l.valueType === "list") i[c] = function(h, m, p) {
        var v = h.separator, g = h.itemParse, y = m.getField(p), b = y ? function(S) {
          return y.str(S).split(v).map(function(_) {
            return g(_.trim());
          }).filter(function(_) {
            return !!_;
          });
        } : function(S) {
          return [];
        };
        return { schema: h, __array: void 0, isDefined: !!y, rowCount: m.rowCount, value: b, valueKind: y ? y.valueKind : function() {
          return 1;
        }, areValuesEqual: function(S, _) {
          return xo(b(S), b(_));
        }, toArray: function(S) {
          return Sa(m.rowCount, b, S);
        } };
      }(l, t, c);
      else if (l.valueType === "tensor") i[c] = _J(l, t, c);
      else {
        var d = function(h) {
          switch (h.valueType) {
            case "str":
              return function(m, p, v) {
                return V6(h, m, m.str, m.toStringArray);
              };
            case "int":
              return function(m, p, v) {
                return V6(h, m, m.int, m.toIntArray);
              };
            case "float":
              return function(m, p, v) {
                return V6(h, m, m.float, m.toFloatArray);
              };
            case "list":
              throw new Error("Use createListColumn instead.");
            case "tensor":
              throw new Error("Use createTensorColumn instead.");
          }
        }(l), f = t.getField(c);
        i[c] = f ? d(f, t, c) : se.Undefined(t.rowCount, l);
      }
      return i[c];
    }, enumerable: !0, configurable: !1 });
  }, o = this, s = 0, u = n; s < u.length; s++) a(u[s]);
};
function xJ(t, e, r, n) {
  var i = lp.create(e, t), a = lp.canonical(i);
  if (a in r) return r[a];
  if (n && i in n) for (var o = 0, s = n[i]; o < s.length; o++) {
    var u = s[o], c = lp.canonical(u);
    if (c in r) return r[c];
  }
}
function SJ(t, e, r, n) {
  var i = r.categories[t];
  if (n) {
    for (var a = function(h) {
      for (var m = /* @__PURE__ */ Object.create(null), p = 0, v = Object.keys(h.categories); p < v.length; p++) for (var g = v[p], y = 0, b = h.categories[g].fieldNames; y < b.length; y++) {
        var S = b[y];
        m[lp.create(g, S, !0)] = h.categories[g].getField(S);
      }
      return m;
    }(r), o = /* @__PURE__ */ Object.create(null), s = [], u = 0, c = 0, l = Object.keys(e); c < l.length; c++) {
      var d = l[c], f = xJ(d, t, a, n);
      f && (o[d] = f, s.push(d), u = f.rowCount);
    }
    i = { rowCount: u, name: t, fieldNames: Ze([], s, !0), getField: function(h) {
      return o[h];
    } };
  }
  return new jN(i || La.empty(t), e, !!i);
}
function U6(t, e, r) {
  for (var n = new Float32Array(t), i = 0; i < n.length; i++) n[i] = e + r * i;
  return n;
}
function CJ(t) {
  return 0;
}
function H6(t) {
  return function(e) {
    return t[e];
  };
}
function Fy(t) {
  return t[3] === 0 && t[7] === 0 && t[11] === 0 && t[15] === 1;
}
function AJ(t, e) {
  var r = t.matrix, n = e.x, i = e.y, a = e.z, o = r[0], s = r[4], u = r[8], c = r[12];
  return Fy(r) ? function(l) {
    return o * n[l] + s * i[l] + u * a[l] + c;
  } : function(l) {
    var d = n[l], f = i[l], h = a[l], m = r[3] * d + r[7] * f + r[11] * h + r[15] || 1;
    return (o * d + s * f + u * h + c) / m;
  };
}
function wJ(t, e) {
  var r = t.matrix, n = e.x, i = e.y, a = e.z, o = r[1], s = r[5], u = r[9], c = r[13];
  return Fy(r) ? function(l) {
    return o * n[l] + s * i[l] + u * a[l] + c;
  } : function(l) {
    var d = n[l], f = i[l], h = a[l], m = r[3] * d + r[7] * f + r[11] * h + r[15] || 1;
    return (o * d + s * f + u * h + c) / m;
  };
}
function DJ(t, e) {
  var r = t.matrix, n = e.x, i = e.y, a = e.z, o = r[2], s = r[6], u = r[10], c = r[14];
  return Fy(r) ? function(l) {
    return o * n[l] + s * i[l] + u * a[l] + c;
  } : function(l) {
    var d = n[l], f = i[l], h = a[l], m = r[3] * d + r[7] * f + r[11] * h + r[15] || 1;
    return (o * d + s * f + u * h + c) / m;
  };
}
(function(t) {
  function e(o, s, u) {
    var c = u || {}, l = c.assembly, d = c.ncsId, f = c.hkl, h = c.spgrOp, m = f ? E.clone(f) : E();
    h = Ui(h, -1), d = d || -1;
    var p = he.isIdentity(s), v = function(g, y) {
      if (!g) return "";
      if (g.assembly) return function(C) {
        return !!C && !!C.matrix && !!C.inverse && typeof C.name == "string";
      }(g) ? g.suffix : y ? "" : "_".concat(g.assembly.operId);
      if (g.spgrOp !== void 0 && g.hkl !== void 0 && g.spgrOp !== -1) {
        var b = g.hkl, S = b[0], _ = b[1], x = b[2];
        return "-".concat(g.spgrOp + 1, "_").concat(5 + S).concat(5 + _).concat(5 + x);
      }
      return g.ncsId !== -1 ? "_".concat(g.ncsId) : "";
    }(u, p);
    return p ? { name: o, assembly: l, matrix: s, inverse: he.identity(), isIdentity: !0, hkl: m, spgrOp: h, ncsId: d, suffix: v } : (he.isRotationAndTranslation(s, t.RotationTranslationEpsilon) || console.warn("Symmetry operator (".concat(o, ") should be a composition of rotation and translation.")), { name: o, assembly: l, matrix: s, inverse: he.invert(he(), s), isIdentity: !1, hkl: m, spgrOp: h, ncsId: d, suffix: v });
  }
  t.DefaultName = "1_555", t.Default = e(t.DefaultName, he.identity()), t.RotationTranslationEpsilon = 5e-3, t.create = e, t.checkIfRotationAndTranslation = function(o, s) {
    for (var u = he.identity(), c = 0; c < 3; c++) for (var l = 0; l < 3; l++) he.setValue(u, c, l, Wi.getValue(o, c, l));
    return he.setTranslation(u, s), he.isRotationAndTranslation(u, t.RotationTranslationEpsilon);
  }, t.ofRotationAndOffset = function(o, s, u, c) {
    for (var l = he.identity(), d = 0; d < 3; d++) for (var f = 0; f < 3; f++) he.setValue(l, d, f, Wi.getValue(s, d, f));
    return he.setTranslation(l, u), e(o, l, { ncsId: c });
  };
  var r = kn.identity(), n = kn(), i = kn(), a = E();
  t.lerpFromIdentity = function(o, s, u) {
    var c = s.inverse;
    if (s.isIdentity) return he.copy(o, c);
    var l = 1 - u;
    he.getRotation(n, c), kn.slerp(n, r, n, l);
    var d = kn.getAxisAngle(a, n);
    return he.fromRotation(o, d, a), he.setValue(o, 0, 3, l * he.getValue(c, 0, 3)), he.setValue(o, 1, 3, l * he.getValue(c, 1, 3)), he.setValue(o, 2, 3, l * he.getValue(c, 2, 3)), o;
  }, t.slerp = function(o, s, u, c) {
    if (Math.abs(c) <= 1e-5) return he.copy(o, s);
    if (Math.abs(c - 1) <= 1e-5) return he.copy(o, u);
    he.getRotation(n, s), he.getRotation(i, u), kn.slerp(i, n, i, c);
    var l = kn.getAxisAngle(a, i);
    return he.fromRotation(o, l, a), he.setValue(o, 0, 3, Vi(he.getValue(s, 0, 3), he.getValue(u, 0, 3), c)), he.setValue(o, 1, 3, Vi(he.getValue(s, 1, 3), he.getValue(u, 1, 3), c)), he.setValue(o, 2, 3, Vi(he.getValue(s, 2, 3), he.getValue(u, 2, 3), c)), o;
  }, t.compose = function(o, s) {
    var u = he.mul(he(), s.matrix, o.matrix);
    return e(s.name, u, s);
  }, t.createMapping = function(o, s, u) {
    var c = t.createCoordinateMapper(t.Default, s), l = o.isIdentity ? c : t.createCoordinateMapper(o, s), d = function(f, h) {
      return f.isIdentity ? { x: H6(h.x), y: H6(h.y), z: H6(h.z) } : { x: AJ(f, h), y: wJ(f, h), z: DJ(f, h) };
    }(o, s);
    return { operator: o, coordinates: s, invariantPosition: c, position: l, x: d.x, y: d.y, z: d.z, r: u || CJ };
  }, t.createCoordinateMapper = function(o, s) {
    return o.isIdentity ? function(u) {
      var c = u.x, l = u.y, d = u.z;
      return function(f, h) {
        return h[0] = c[f], h[1] = l[f], h[2] = d[f], h;
      };
    }(s) : function(u, c) {
      var l = u.matrix, d = c.x, f = c.y, h = c.z;
      return Fy(l) ? function(m, p) {
        var v = d[m], g = f[m], y = h[m];
        return p[0] = l[0] * v + l[4] * g + l[8] * y + l[12], p[1] = l[1] * v + l[5] * g + l[9] * y + l[13], p[2] = l[2] * v + l[6] * g + l[10] * y + l[14], p;
      } : function(m, p) {
        return p[0] = d[m], p[1] = f[m], p[2] = h[m], E.transformMat4(p, p, l), p;
      };
    }(o, s);
  };
})(wn || (wn = {}));
var q6 = [[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]], EJ = [[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]], IJ = [[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]], Um = { "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 TJ(t) {
  if (t < 146) return t + 1;
  if (t === 146) return 1146;
  if (t < 149) return t + 1 - 1;
  if (t === 149) return 1148;
  if (t < 157) return t + 1 - 2;
  if (t === 157) return 1155;
  if (t < 163) return t + 1 - 3;
  if (t === 163) return 1160;
  if (t < 165) return t + 1 - 4;
  if (t === 165) return 1161;
  if (t < 171) return t + 1 - 5;
  if (t === 171) return 1166;
  if (t < 173) return t + 1 - 6;
  if (t === 173) return 1167;
  if (t < 237) return t + 1 - 7;
  if (t === 237) return 1003;
  if (t === 238) return 1004;
  if (t === 239) return 1005;
  if (t === 240) return 2005;
  if (t === 241) return 3005;
  if (t === 242) return 4005;
  if (t === 243) return 5005;
  if (t === 244) return 1006;
  if (t === 245) return 1007;
  if (t === 246) return 1008;
  if (t === 247) return 1009;
  if (t === 248) return 1010;
  if (t === 249) return 1011;
  if (t === 250) return 1012;
  if (t === 251) return 1013;
  if (t === 252) return 1014;
  if (t === 253) return 2014;
  if (t === 254) return 3014;
  if (t === 255) return 1015;
  if (t === 256) return 1017;
  if (t === 257) return 2017;
  if (t === 258) return 1018;
  if (t === 259) return 2018;
  if (t === 260) return 3018;
  if (t === 261) return 1020;
  if (t === 262) return 1021;
  if (t === 263) return 1022;
  if (t === 264) return 1023;
  if (t === 265) return 1059;
  if (t === 266) return 1094;
  if (t === 267) return 1197;
  throw new Error("unknown spacegroup index '".concat(t, "'"));
}
var au, ko, af, Ri, ZN = function() {
  for (var t = /* @__PURE__ */ Object.create(null), e = 0, r = Object.keys(Um); e < r.length; e++) {
    var n = r[e];
    t[Um[n]] = n;
  }
  return t;
}(), MJ = function() {
  for (var t = /* @__PURE__ */ Object.create(null), e = 0, r = Object.keys(Um); e < r.length; e++) {
    var n = r[e], i = Um[n];
    t[i] = TJ(i);
  }
  return t;
}();
function yD(t) {
  var e = typeof t == "number" ? function(r) {
    switch (r) {
      case 1146:
        return 146;
      case 1148:
        return 149;
      case 1155:
        return 157;
      case 1160:
        return 163;
      case 1161:
        return 165;
      case 1166:
        return 171;
      case 1167:
        return 173;
      case 1003:
        return 237;
      case 1004:
        return 238;
      case 1005:
        return 239;
      case 2005:
        return 240;
      case 3005:
        return 241;
      case 4005:
        return 242;
      case 5005:
        return 243;
      case 1006:
        return 244;
      case 1007:
        return 245;
      case 1008:
        return 246;
      case 1009:
        return 247;
      case 1010:
        return 248;
      case 1011:
        return 249;
      case 1012:
        return 250;
      case 1013:
        return 251;
      case 1014:
        return 252;
      case 2014:
        return 253;
      case 3014:
        return 254;
      case 1015:
        return 255;
      case 1017:
        return 256;
      case 2017:
        return 257;
      case 1018:
        return 258;
      case 2018:
        return 259;
      case 3018:
        return 260;
      case 1020:
        return 261;
      case 1021:
        return 262;
      case 1022:
        return 263;
      case 1023:
        return 264;
      case 1059:
        return 265;
      case 1094:
        return 266;
      case 1197:
        return 267;
    }
    var n = 0;
    return r > 146 && ++n, r > 148 && ++n, r > 155 && ++n, r > 160 && ++n, r > 161 && ++n, r > 166 && ++n, r > 167 && ++n, r - 1 + n;
  }(t) : Um[t];
  return e === void 0 || ZN[e] === void 0 ? -1 : e;
}
function ul() {
  return ul.empty();
}
function K6(t, e, r, n) {
  n = t[e], t[e] = t[r], t[r] = n;
}
function PJ(t, e) {
  return (t = Math.abs(t)) > (e = Math.abs(e)) ? (e /= t, t * Math.sqrt(1 + e * e)) : e > 0 ? (t /= e, e * Math.sqrt(1 + t * t)) : 0;
}
(function(t) {
  function e(r, n, i) {
    var a = yD(r);
    if (a < 0) return console.warn("Unknown spacegroup '".concat(r, "', returning a 'P 1' with cellsize [1, 1, 1]")), t.Zero;
    var o = n[0] * n[1] * n[2], s = i[0], u = i[1], c = i[2], l = n[0], d = n[1], f = n[2], h = Math.cos(u), m = (Math.cos(s) - Math.cos(u) * Math.cos(c)) / Math.sin(c), p = Math.sqrt(1 - h * h - m * m), v = [l, 0, 0], g = [Math.cos(c) * d, Math.sin(c) * d, 0], y = [h * f, m * f, p * f], b = he.ofRows([[v[0], g[0], y[0], 0], [0, g[1], y[1], 0], [0, 0, y[2], 0], [0, 0, 0, 1]]);
    return { index: a, size: n, volume: o, anglesInRadians: i, toFractional: he.invert(he.zero(), b), fromFractional: b };
  }
  t.Zero = e("P 1", E.create(1, 1, 1), E.create(Math.PI / 2, Math.PI / 2, Math.PI / 2)), t.isZero = function(r) {
    return !r || r.index === 0 && r.size[0] === 1 && r.size[1] === 1 && r.size[1] === 1;
  }, t.create = e, t.createMaterial = function(r, n, i, a, o, s) {
    var u = yD(r);
    return u < 0 ? (console.warn("Unknown spacegroup '".concat(r, "', returning a 'P 1' with cellsize [1, 1, 1]")), t.Zero) : { index: u, size: n, volume: a, anglesInRadians: i, toFractional: o, fromFractional: s };
  };
})(au || (au = {})), function(t) {
  function e(f) {
    var h = IJ[f.index].map(function(m) {
      return v = q6[(p = EJ[m])[0]], g = q6[p[1]], y = q6[p[2]], he.ofRows([v, g, y, [0, 0, 0, 1]]);
      var p, v, g, y;
    });
    return { name: ZN[f.index], num: MJ[f.index], cell: f, operators: h };
  }
  t.ZeroP1 = e(au.Zero), t.create = e;
  var r = E(), n = he();
  function i(f, h, m, p, v, g) {
    return E.set(r, m, p, v), he.fromTranslation(n, r), he.mul(g, he.mul(g, he.mul(g, f.cell.fromFractional, n), f.operators[h]), f.cell.toFractional);
  }
  t.setOperatorMatrix = i, t.getSymmetryOperator = function(f, h, m, p, v) {
    var g = i(f, h, m, p, v, he.zero());
    return wn.create("".concat(h + 1, "_").concat(5 + m).concat(5 + p).concat(5 + v), g, { hkl: E.create(m, p, v), spgrOp: h });
  };
  var a = E(), o = E(), s = E(), u = E();
  function c(f, h, m) {
    var p = [];
    if (f > 0 ? p.push("+X") : f < 0 && p.push("-X"), h > 0 ? p.push("+Y") : h < 0 && p.push("-Y"), m > 0 ? p.push("+Z") : m < 0 && p.push("-Z"), p.length === 1) return p[0].charAt(0) === "+" ? p[0].substr(1) : p[0];
    if (p.length === 2) {
      var v = p[0].charAt(0), g = p[1].charAt(0);
      if (v === "+") return "".concat(p[0].substr(1)).concat(p[1]);
      if (g === "+") return "".concat(p[1].substr(1)).concat(p[0]);
    }
    throw new Error("unknown rotation '".concat(p, "', ").concat(f, " ").concat(h, " ").concat(m));
  }
  function l(f) {
    switch (f) {
      case 0.5:
        return "1/2";
      case 1 / 4:
        return "1/4";
      case 3 / 4:
        return "3/4";
      case 1 / 3:
        return "1/3";
      case 2 / 3:
        return "2/3";
      case 1 / 6:
        return "1/6";
      case 5 / 6:
        return "5/6";
    }
    return "";
  }
  function d(f, h) {
    return h === "" ? f : f.length > 2 ? "".concat(f, "+").concat(h) : f.charAt(0) === "-" ? "".concat(h).concat(f) : "".concat(h, "+").concat(f);
  }
  t.getSymmetryOperatorRef = function(f, h, m, p, v, g) {
    var y = he.zero();
    E.set(r, m, p, v), E.floor(a, g), he.copy(y, f.operators[h]), E.floor(o, E.transformMat4(o, g, y)), he.getTranslation(u, y), E.sub(u, u, o), E.add(u, u, a), E.add(u, u, r), he.setTranslation(y, u), he.mul(y, f.cell.fromFractional, y), he.mul(y, y, f.cell.toFractional), E.sub(s, o, a);
    var b = m - s[0], S = p - s[1], _ = v - s[2];
    return wn.create("".concat(h + 1, "_").concat(5 + b).concat(5 + S).concat(5 + _), y, { hkl: E.create(b, S, _), spgrOp: h });
  }, t.getOperatorXyz = function(f) {
    return [d(c(f[0], f[4], f[8]), l(f[12])), d(c(f[1], f[5], f[9]), l(f[13])), d(c(f[2], f[6], f[10]), l(f[14]))].join(",");
  };
}(ko || (ko = {})), function(t) {
  t.add = function(e, r, n) {
    e.squaredDistances[e.count] = n, e.indices[e.count++] = r;
  }, t.reset = function(e) {
    e.count = 0;
  }, t.create = function() {
    return { count: 0, indices: [], squaredDistances: [] };
  }, t.copy = function(e, r) {
    for (var n = 0; n < r.count; ++n) e.indices[n] = r.indices[n], e.squaredDistances[n] = r.squaredDistances[n];
    return e.count = r.count, e;
  };
}(af || (af = {})), function(t) {
  function e() {
    return { origin: E(), dirA: E(), dirB: E(), dirC: E() };
  }
  function r(o, s) {
    return E.copy(o.origin, s.origin), E.copy(o.dirA, s.dirA), E.copy(o.dirB, s.dirB), E.copy(o.dirC, s.dirC), o;
  }
  function n(o, s) {
    return E.set(o, 2 * E.magnitude(s.dirA), 2 * E.magnitude(s.dirB), 2 * E.magnitude(s.dirC));
  }
  t.create = function(o, s, u, c) {
    return { origin: o, dirA: s, dirB: u, dirC: c };
  }, t.empty = e, t.copy = r, t.clone = function(o) {
    return r(e(), o);
  }, t.size = n;
  var i = E();
  t.volume = function(o) {
    return n(i, o), i[0] * i[1] * i[2];
  }, t.normalize = function(o, s) {
    return E.copy(o.origin, s.origin), E.normalize(o.dirA, s.dirA), E.normalize(o.dirB, s.dirB), E.normalize(o.dirC, s.dirC), o;
  };
  var a = Wi();
  t.transform = function(o, s, u) {
    E.transformMat4(o.origin, s.origin, u);
    var c = Wi.directionTransform(a, u);
    return E.transformMat3(o.dirA, s.dirA, c), E.transformMat3(o.dirB, s.dirB, c), E.transformMat3(o.dirC, s.dirC, c), o;
  }, t.scale = function(o, s, u) {
    return E.scale(o.dirA, s.dirA, u), E.scale(o.dirB, s.dirB, u), E.scale(o.dirC, s.dirC, u), o;
  };
}(ul || (ul = {})), function(t) {
  t.create = function(e, r, n) {
    n === void 0 && (n = Float32Array);
    var i = e * r;
    return { data: new n(i), size: i, cols: e, rows: r };
  }, t.get = function(e, r, n) {
    return e.data[e.rows * n + r];
  }, t.set = function(e, r, n, i) {
    return e.data[e.rows * n + r] = i, e;
  }, t.add = function(e, r, n, i) {
    return e.data[e.rows * n + r] += i, e;
  }, t.makeZero = function(e) {
    return e.data.fill(0), e;
  }, t.clone = function(e) {
    return { data: e.data.slice(), size: e.size, cols: e.cols, rows: e.rows };
  }, t.fromArray = function(e, r, n) {
    return { data: e, size: r * n, cols: r, rows: n };
  }, t.transpose = function(e, r) {
    if (e.cols !== r.rows || e.rows !== r.cols) throw new Error("transpose: matrix dimensions incompatible");
    if (e.data === r.data) throw new Error("transpose: matrices share memory");
    for (var n = r.rows, i = r.cols, a = r.data, o = e.data, s = 0, u = 0, c = 0; s < n; c += 1, u += i, ++s) for (var l = c, d = 0; d < i; l += n, d++) o[l] = a[u + d];
    return e;
  }, t.multiplyABt = function(e, r, n) {
    for (var i = r.cols, a = r.rows, o = n.rows, s = r.data, u = n.data, c = e.data, l = 0, d = 0, f = 0; l < a; d += i, l++) for (var h = 0, m = 0; m < o; f++, m++) {
      for (var p = 0, v = d, g = 0; g < i; v++, h++, g++) p += s[v] * u[h];
      c[f] = p;
    }
    return e;
  }, t.meanRows = function(e) {
    for (var r = e.rows, n = e.cols, i = e.data, a = new Array(n), o = 0; o < n; ++o) a[o] = 0;
    for (var s = 0, u = 0; s < r; ++s) for (o = 0; o < n; ++o, ++u) a[o] += i[u];
    for (o = 0; o < n; ++o) a[o] /= r;
    return a;
  }, t.subRows = function(e, r) {
    for (var n = e.rows, i = e.cols, a = e.data, o = 0, s = 0; o < n; ++o) for (var u = 0; u < i; ++u, ++s) a[s] -= r[u];
    return e;
  };
}(Ri || (Ri = {}));
var Qd, BJ = 1192092896e-16, FJ = 1e-37;
function NJ(t, e, r, n) {
  var i = 0, a = 0, o = t.rows, s = t.cols, u = o, c = s;
  u < c && (i = 1, a = u, u = c, c = a);
  var l = Ri.create(u, u), d = Ri.create(1, c), f = Ri.create(c, c);
  if (i === 0) Ri.transpose(l, t);
  else {
    for (a = 0; a < s * o; a++) l.data[a] = t.data[a];
    for (; a < c * u; a++) l.data[a] = 0;
  }
  if (function(h, m, p, v, g, y, b, S) {
    for (var _ = 2 * BJ, x = FJ, C = 0, A = 0, w = 0, I = 0, P = Math.max(y, 30), M = 0, T = 0, F = 0, N = 0, R = 0, L = 0, V = 0, U = 0, H = 0, K = 0, X = 0, Y = 0, Q = 0, J = 0, te = 0, W = 0, j = 0, ee = 4660, ie = 0, ae = 0, ce = 0, de = new Float64Array(b << 3); C < b; C++) {
      for (w = 0, X = 0; w < y; w++) X += (U = h[C * m + w]) * U;
      if (de[C] = X, v) {
        for (w = 0; w < b; w++) v[C * g + w] = 0;
        v[C * g + C] = 1;
      }
    }
    for (; I < P; I++) {
      for (R = 0, C = 0; C < b - 1; C++) for (A = C + 1; A < b; A++) {
        for (M = C * m | 0, T = A * m | 0, te = de[C], W = 0, j = de[A], w = 2, W += h[M] * h[T], W += h[M + 1] * h[T + 1]; w < y; w++) W += h[M + w] * h[T + w];
        if (!(Math.abs(W) <= _ * Math.sqrt(te * j))) {
          for (Q = PJ(W *= 2, Y = te - j), Y < 0 ? (J = 0.5 * (Q - Y), L = W / (Q * (V = Math.sqrt(J / Q)) * 2)) : V = W / (Q * (L = Math.sqrt((Q + Y) / (2 * Q))) * 2), te = 0, j = 0, w = 2, H = L * h[M] + V * h[T], K = -V * h[M] + L * h[T], h[M] = H, h[T] = K, te += H * H, j += K * K, H = L * h[M + 1] + V * h[T + 1], K = -V * h[M + 1] + L * h[T + 1], h[M + 1] = H, h[T + 1] = K, te += H * H, j += K * K; w < y; w++) H = L * h[M + w] + V * h[T + w], K = -V * h[M + w] + L * h[T + w], h[M + w] = H, h[T + w] = K, te += H * H, j += K * K;
          if (de[C] = te, de[A] = j, R = 1, v) for (N = A * g | 0, w = 2, H = L * v[F = C * g | 0] + V * v[N], K = -V * v[F] + L * v[N], v[F] = H, v[N] = K, H = L * v[F + 1] + V * v[N + 1], K = -V * v[F + 1] + L * v[N + 1], v[F + 1] = H, v[N + 1] = K; w < b; w++) H = L * v[F + w] + V * v[N + w], K = -V * v[F + w] + L * v[N + w], v[F + w] = H, v[N + w] = K;
        }
      }
      if (R === 0) break;
    }
    for (C = 0; C < b; C++) {
      for (w = 0, X = 0; w < y; w++) X += (U = h[C * m + w]) * U;
      de[C] = Math.sqrt(X);
    }
    for (C = 0; C < b - 1; C++) {
      for (A = C, w = C + 1; w < b; w++) de[A] < de[w] && (A = w);
      if (C !== A && (K6(de, C, A, X), v)) {
        for (w = 0; w < y; w++) K6(h, C * m + w, A * m + w, U);
        for (w = 0; w < b; w++) K6(v, C * g + w, A * g + w, U);
      }
    }
    for (C = 0; C < b; C++) p[C] = de[C];
    if (v) for (C = 0; C < S; C++) {
      for (X = C < b ? de[C] : 0; X <= x; ) {
        for (ae = 1 / y, w = 0; w < y; w++) ie = 256 & (ee = 214013 * ee + 2531011) >> 16 ? ae : -ae, h[C * m + w] = ie;
        for (I = 0; I < 2; I++) for (A = 0; A < C; A++) {
          for (X = 0, w = 0; w < y; w++) X += h[C * m + w] * h[A * m + w];
          for (ce = 0, w = 0; w < y; w++) U = h[C * m + w] - X * h[A * m + w], h[C * m + w] = U, ce += Math.abs(U);
          for (ce = ce ? 1 / ce : 0, w = 0; w < y; w++) h[C * m + w] *= ce;
        }
        for (X = 0, w = 0; w < y; w++) X += (U = h[C * m + w]) * U;
        X = Math.sqrt(X);
      }
      for (V = 1 / X, w = 0; w < y; w++) h[C * m + w] *= V;
    }
  }(l.data, u, d.data, f.data, c, u, c, u), e) {
    for (a = 0; a < c; a++) e.data[a] = d.data[a];
    for (; a < s; a++) e.data[a] = 0;
  }
  i === 0 ? (r && Ri.transpose(r, l), n && Ri.transpose(n, f)) : (r && Ri.transpose(r, f), n && Ri.transpose(n, l));
}
function Me() {
  return Me.zero();
}
function $r() {
  return $r.zero();
}
function S0(t, e, r) {
  return new RJ(t, e, r);
}
(function(t) {
  function e(s) {
    if (s.length === 3) return ul.create(E.fromArray(E(), s, 0), E.create(1, 0, 0), E.create(0, 1, 0), E.create(0, 1, 0));
    var u = Ri.fromArray(s, 3, s.length / 3), c = u.rows, l = c / 3, d = Ri.create(3, 3), f = Ri.create(1, 3), h = Ri.create(3, 3), m = Ri.create(3, 3), p = Ri.meanRows(u), v = Ri.subRows(Ri.clone(u), p), g = Ri.transpose(Ri.create(c, 3), v);
    Ri.multiplyABt(d, g, g), NJ(d, f, h, m);
    var y = E.create(p[0], p[1], p[2]), b = E.create(h.data[0], h.data[3], h.data[6]), S = E.create(h.data[1], h.data[4], h.data[7]), _ = E.create(h.data[2], h.data[5], h.data[8]);
    return E.scale(b, b, Math.sqrt(f.data[0] / l)), E.scale(S, S, Math.sqrt(f.data[1] / l)), E.scale(_, _, Math.sqrt(f.data[2] / l)), ul.create(y, b, S, _);
  }
  t.ofPositions = function(s) {
    var u = e(s);
    return { momentsAxes: u, boxAxes: o(s, u) };
  }, t.calculateMomentsAxes = e;
  var r = E(), n = E(), i = E(), a = E();
  function o(s, u) {
    if (s.length === 3) return ul.clone(u);
    for (var c = -1 / 0, l = -1 / 0, d = -1 / 0, f = -1 / 0, h = -1 / 0, m = -1 / 0, p = E(), v = E(), g = u.origin, y = E.normalize(n, u.dirA), b = E.normalize(i, u.dirB), S = E.normalize(a, u.dirC), _ = 0, x = s.length; _ < x; _ += 3) {
      E.projectPointOnVector(p, E.fromArray(p, s, _), y, g);
      var C = E.dot(y, E.normalize(v, E.sub(v, p, g))), A = E.distance(p, g);
      C > 0 ? A > c && (c = A) : A > l && (l = A), E.projectPointOnVector(p, E.fromArray(p, s, _), b, g);
      var w = E.dot(b, E.normalize(v, E.sub(v, p, g))), I = E.distance(p, g);
      w > 0 ? I > d && (d = I) : I > f && (f = I), E.projectPointOnVector(p, E.fromArray(p, s, _), S, g);
      var P = E.dot(S, E.normalize(v, E.sub(v, p, g))), M = E.distance(p, g);
      P > 0 ? M > h && (h = M) : M > m && (m = M);
    }
    var T = E.setMagnitude(E(), y, (c + l) / 2), F = E.setMagnitude(E(), b, (d + f) / 2), N = E.setMagnitude(E(), S, (h + m) / 2), R = E(), L = function(V, U, H) {
      E.copy(r, g), E.scaleAndAdd(r, r, y, V), E.scaleAndAdd(r, r, b, U), E.scaleAndAdd(r, r, S, H), E.add(R, R, r);
    };
    return L(c, d, h), L(c, d, -m), L(c, -f, -m), L(c, -f, h), L(-l, -f, -m), L(-l, -f, h), L(-l, d, h), L(-l, d, -m), E.scale(R, R, 1 / 8), ul.create(R, T, F, N);
  }
  t.calculateBoxAxes = o;
})(Qd || (Qd = {})), function(t) {
  function e(s) {
    return s.extrema !== void 0;
  }
  function r(s, u) {
    return { center: s, radius: u };
  }
  function n(s, u) {
    var c;
    return s.extrema !== void 0 ? (s.extrema.length = 0, (c = s.extrema).push.apply(c, u)) : s.extrema = u, s;
  }
  t.hasExtrema = e, t.create = r, t.zero = function() {
    return { center: E(), radius: 0 };
  }, t.clone = function(s) {
    var u = r(E.clone(s.center), s.radius);
    return e(s) && (u.extrema = s.extrema.map(function(c) {
      return E.clone(c);
    })), u;
  }, t.set = function(s, u, c) {
    return E.copy(s.center, u), s.radius = c, s;
  }, t.copy = function(s, u) {
    return E.copy(s.center, u.center), s.radius = u.radius, e(u) && n(s, u.extrema.map(function(c) {
      return E.clone(c);
    })), s;
  }, t.setExtrema = n, t.computeBounding = function(s) {
    for (var u = s.x, c = s.y, l = s.z, d = s.indices, f = 0, h = 0, m = 0, p = 0, v = Ge.size(d), g = 0; g < v; g++)
      f += u[y = Ge.getAt(d, g)], h += c[y], m += l[y];
    for (v > 0 && (f /= v, h /= v, m /= v), g = 0; g < v; g++) {
      var y, b = u[y = Ge.getAt(d, g)] - f, S = c[y] - h, _ = l[y] - m, x = b * b + S * S + _ * _;
      x > p && (p = x);
    }
    return { center: E.create(f, h, m), radius: Math.sqrt(p) };
  }, t.transform = function(s, u, c) {
    return E.transformMat4(s.center, u.center, c), s.radius = u.radius * he.getMaxScaleOnAxis(c), e(u) && n(s, u.extrema.map(function(l) {
      return E.transformMat4(E(), l, c);
    })), s;
  }, t.translate = function(s, u, c) {
    return E.add(s.center, u.center, c), e(u) && n(s, u.extrema.map(function(l) {
      return E.add(E(), l, c);
    })), s;
  }, t.toArray = function(s, u, c) {
    E.toArray(s.center, u, c), u[c + 3] = s.radius;
  }, t.fromArray = function(s, u, c) {
    return E.fromArray(s.center, u, c), s.radius = u[c + 3], s;
  }, t.fromBox3D = function(s, u) {
    return E.scale(s.center, E.add(s.center, u.max, u.min), 0.5), s.radius = E.distance(s.center, u.max), t.setExtrema(s, [E.create(u.min[0], u.min[1], u.min[2]), E.create(u.max[0], u.max[1], u.max[2]), E.create(u.max[0], u.min[1], u.min[2]), E.create(u.min[0], u.max[1], u.max[2]), E.create(u.min[0], u.min[1], u.max[2]), E.create(u.max[0], u.min[1], u.max[2]), E.create(u.max[0], u.max[1], u.min[2]), E.create(u.min[0], u.max[1], u.min[2])]), s;
  }, t.fromAxes3D = function(s, u) {
    return E.copy(s.center, u.origin), s.radius = Math.max(E.magnitude(u.dirA), E.magnitude(u.dirB), E.magnitude(u.dirC)), s;
  };
  var i = E();
  t.fromDimensionsAndTransform = function(s, u, c) {
    var l = u[0], d = u[1], f = u[2], h = E.create(0, 0, 0);
    E.transformMat4(h, h, c);
    var m = E.create(l, d, f);
    E.transformMat4(m, m, c);
    var p = E.create(l, 0, 0);
    E.transformMat4(p, p, c);
    var v = E.create(0, d, f);
    E.transformMat4(v, v, c);
    var g = E.create(0, 0, f);
    E.transformMat4(g, g, c);
    var y = E.create(l, 0, f);
    E.transformMat4(y, y, c);
    var b = E.create(l, d, 0);
    E.transformMat4(b, b, c);
    var S = E.create(0, d, 0);
    E.transformMat4(S, S, c), E.add(i, h, m), E.scale(i, i, 0.5);
    var _ = Math.max(E.distance(h, m), E.distance(p, v));
    return t.set(s, i, _ / 2), t.setExtrema(s, [h, m, p, v, g, y, b, S]), s;
  };
  var a = E();
  t.addVec3 = function(s, u, c) {
    return E.distance(u.center, c) < u.radius ? t.copy(s, u) : (E.sub(a, u.center, c), E.sub(a, u.center, a), E.setMagnitude(a, a, u.radius), E.scale(s.center, E.add(a, a, c), 0.5), s.radius = E.distance(s.center, c), s);
  }, t.expandBySphere = function(s, u, c) {
    return E.copy(s.center, u.center), s.radius = Math.max(u.radius, E.distance(u.center, c.center) + c.radius), e(u) && e(c) && n(s, Ze(Ze([], u.extrema.map(function(l) {
      return E.clone(l);
    }), !0), c.extrema.map(function(l) {
      return E.clone(l);
    }), !0)), s;
  };
  var o = E();
  t.expand = function(s, u, c) {
    var l, d;
    if (E.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 (e(u)) {
      for (var f = new Float32Array(3 * u.extrema.length), h = 0; h < u.extrema.length; h++) E.toArray(u.extrema[h], f, 3 * h);
      var m = Qd.calculateMomentsAxes(f);
      ul.scale(m, ul.normalize(m, m), c), n(s, u.extrema.map(function(p) {
        E.normalize(o, E.sub(o, p, u.center));
        var v = E.clone(p), g = E.dot(o, m.dirA) < 0 ? -1 : 1;
        E.scaleAndAdd(v, v, m.dirA, g);
        var y = E.dot(o, m.dirB) < 0 ? -1 : 1;
        E.scaleAndAdd(v, v, m.dirB, y);
        var b = E.dot(o, m.dirC) < 0 ? -1 : 1;
        return E.scaleAndAdd(v, v, m.dirC, b), E.distance(s.center, v) > s.radius && (u.extrema.length >= 14 && E.normalize(o, E.sub(o, v, u.center)), E.scaleAndAdd(v, s.center, o, s.radius)), v;
      }));
    }
    return s;
  }, t.exactEquals = function(s, u) {
    return s.radius === u.radius && E.exactEquals(s.center, u.center);
  }, t.equals = function(s, u) {
    var c = s.radius, l = u.radius;
    return Math.abs(c - l) <= Cn * Math.max(1, Math.abs(c), Math.abs(l)) && E.equals(s.center, u.center);
  }, t.includes = function(s, u) {
    if (e(u)) {
      for (var c = 0, l = u.extrema; c < l.length; c++) {
        var d = l[c];
        if (E.distance(s.center, d) > s.radius) return !1;
      }
      return !0;
    }
    return E.distance(s.center, u.center) + u.radius <= s.radius;
  }, t.overlaps = function(s, u) {
    return E.distance(s.center, u.center) <= s.radius + u.radius;
  }, t.distance = function(s, u) {
    return E.distance(s.center, u.center) - s.radius + u.radius;
  };
}(Me || (Me = {})), function(t) {
  function e() {
    return { min: E(), max: E() };
  }
  function r(c, l) {
    return E.copy(c.min, l.min), E.copy(c.max, l.max), c;
  }
  function n(c, l) {
    t.setEmpty(c);
    for (var d = 0, f = l.length; d < f; d++) t.add(c, l[d]);
    return c;
  }
  function i(c, l) {
    return E.sub(c, l.max, l.min);
  }
  t.create = function(c, l) {
    return { min: c, max: l };
  }, t.zero = e, t.copy = r, t.clone = function(c) {
    return r(e(), c);
  }, t.fromSphere3D = function(c, l) {
    if (Me.hasExtrema(l) && l.extrema.length >= 14) return n(c, l.extrema);
    var d = E.create(l.radius, l.radius, l.radius);
    return E.sub(c.min, l.center, d), E.add(c.max, l.center, d), c;
  }, t.fromVec3Array = n, t.computeBounding = function(c) {
    for (var l = E.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), d = E.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), f = c.x, h = c.y, m = c.z, p = c.indices, v = 0, g = Ge.size(p); v < g; v++) {
      var y = Ge.getAt(p, v);
      l[0] = Math.min(f[y], l[0]), l[1] = Math.min(h[y], l[1]), l[2] = Math.min(m[y], l[2]), d[0] = Math.max(f[y], d[0]), d[1] = Math.max(h[y], d[1]), d[2] = Math.max(m[y], d[2]);
    }
    return { min: l, max: d };
  }, t.size = i;
  var a = E();
  function o(c) {
    return E.set(c.min, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), E.set(c.max, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), c;
  }
  function s(c, l) {
    return E.min(c.min, c.min, l), E.max(c.max, c.max, l), c;
  }
  t.volume = function(c) {
    return i(a, c), a[0] * a[1] * a[2];
  }, t.setEmpty = o, t.add = s, t.expand = function(c, l, d) {
    return E.sub(c.min, l.min, d), E.add(c.max, l.max, d), c;
  }, t.scale = function(c, l, d) {
    return E.scale(c.min, l.min, d), E.scale(c.max, l.max, d), c;
  };
  var u = E();
  t.transform = function(c, l, d) {
    var f = l.min, h = f[0], m = f[1], p = f[2], v = l.max, g = v[0], y = v[1], b = v[2];
    return o(c), s(c, E.transformMat4(u, E.set(u, h, m, p), d)), s(c, E.transformMat4(u, E.set(u, h, m, b), d)), s(c, E.transformMat4(u, E.set(u, h, y, p), d)), s(c, E.transformMat4(u, E.set(u, h, y, b), d)), s(c, E.transformMat4(u, E.set(u, g, m, p), d)), s(c, E.transformMat4(u, E.set(u, g, m, b), d)), s(c, E.transformMat4(u, E.set(u, g, y, p), d)), s(c, E.transformMat4(u, E.set(u, g, y, b), d)), c;
  }, t.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]);
  };
}($r || ($r = {}));
var at, RJ = function() {
  function t(e, r, n) {
    var i = function(a, o, s) {
      var u, c, l = $r.expand($r(), o.box, E.create(0.5, 0.5, 0.5)), d = a.indices, f = $r.size(E.zero(), l), h = Ge.size(d), m = typeof s == "number" ? s : 32, p = Array.isArray(s) && s;
      if (p) c = [Math.ceil(f[0] / p[0]), Math.ceil(f[1] / p[1]), Math.ceil(f[2] / p[2])], u = p;
      else if (h > 0) {
        var v = Math.ceil(h / m), g = Math.pow(v / (f[0] * f[1] * f[2]), 1 / 3);
        c = [Math.ceil(f[0] * g), Math.ceil(f[1] * g), Math.ceil(f[2] * g)], u = [f[0] / c[0], f[1] / c[1], f[2] / c[2]];
      } else u = f, c = [1, 1, 1];
      var y = { x: a.x, y: a.y, z: a.z, indices: d, radius: a.radius }, b = { size: c, data: y, expandedBox: l, boundingBox: o.box, boundingSphere: o.sphere, elementCount: h, delta: u };
      return function(S) {
        for (var _ = S.expandedBox, x = S.size, C = x[0], A = x[1], w = x[2], I = S.data, P = I.x, M = I.y, T = I.z, F = I.radius, N = I.indices, R = S.elementCount, L = S.delta, V = C * A * w, U = _.min, H = U[0], K = U[1], X = U[2], Y = 0, Q = 0, J = new Uint32Array(V), te = new Int32Array(R), W = 0; W < R; W++) {
          var j = Ge.getAt(N, W), ee = (Math.floor((P[j] - H) / L[0]) * A + Math.floor((M[j] - K) / L[1])) * w + Math.floor((T[j] - X) / L[2]);
          (J[ee] += 1) === 1 && (Q += 1), te[W] = ee;
        }
        if (F) for (W = 0; W < R; W++)
          F[j = Ge.getAt(N, W)] > Y && (Y = F[j]);
        for (var ie = new Int32Array(Q), ae = (j = 0, 0); j < V; j++) {
          var ce = J[j];
          ce > 0 && (J[j] = ae + 1, ie[ae] = ce, ae += 1);
        }
        var de = new Uint32Array(Q);
        for (j = 1; j < Q; ++j) de[j] += de[j - 1] + ie[j - 1];
        var Ce = new Int32Array(Q), De = new Int32Array(R);
        for (j = 0; j < R; j++) {
          var ke = J[te[j]];
          if (ke > 0) {
            var He = ke - 1;
            De[de[He] + Ce[He]] = j, Ce[He] += 1;
          }
        }
        return { size: S.size, bucketArray: De, bucketCounts: ie, bucketOffset: de, grid: J, delta: L, min: S.expandedBox.min, data: S.data, maxRadius: Y, expandedBox: S.expandedBox, boundingBox: S.boundingBox, boundingSphere: S.boundingSphere };
      }(b);
    }(e, r, n);
    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 = af.create();
  }
  return t.prototype.find = function(e, r, n, i, a) {
    this.ctx.x = e, this.ctx.y = r, this.ctx.z = n, this.ctx.radius = i, this.ctx.isCheck = !1;
    var o = a ?? this.result;
    return bD(this.ctx, o), o;
  }, t.prototype.check = function(e, r, n, i) {
    return this.ctx.x = e, this.ctx.y = r, this.ctx.z = n, this.ctx.radius = i, this.ctx.isCheck = !0, bD(this.ctx, this.result);
  }, t;
}();
function bD(t, e) {
  var r = t.grid, n = r.min, i = r.size, a = i[0], o = i[1], s = i[2], u = r.bucketOffset, c = r.bucketCounts, l = r.bucketArray, d = r.grid, f = r.data, h = f.x, m = f.y, p = f.z, v = f.indices, g = f.radius, y = r.delta, b = r.maxRadius, S = t.radius, _ = t.isCheck, x = t.x, C = t.y, A = t.z, w = S + b, I = w * w;
  af.reset(e);
  var P = Math.max(0, Math.floor((x - w - n[0]) / y[0])), M = Math.max(0, Math.floor((C - w - n[1]) / y[1])), T = Math.max(0, Math.floor((A - w - n[2]) / y[2])), F = Math.min(a - 1, Math.floor((x + w - n[0]) / y[0])), N = Math.min(o - 1, Math.floor((C + w - n[1]) / y[1])), R = Math.min(s - 1, Math.floor((A + w - n[2]) / y[2]));
  if (P > F || M > N || T > R) return !1;
  for (var L = P; L <= F; L++) for (var V = M; V <= N; V++) for (var U = T; U <= R; U++) {
    var H = d[(L * o + V) * s + U];
    if (H !== 0) for (var K = H - 1, X = u[K], Y = X + c[K], Q = X; Q < Y; Q++) {
      var J = Ge.getAt(v, l[Q]), te = h[J] - x, W = m[J] - C, j = p[J] - A, ee = te * te + W * W + j * j;
      if (ee <= I) {
        if (b > 0 && Math.sqrt(ee) - g[J] > S) continue;
        if (_) return !0;
        af.add(e, l[Q], ee);
      }
    }
  }
  return e.count > 0;
}
(function(t) {
  function e(i, a, o) {
    return { kind: "element-location", structure: i, unit: a, element: o || 0 };
  }
  t.create = e, t.clone = function(i) {
    return e(i.structure, i.unit, i.element);
  }, t.set = function(i, a, o, s) {
    return a && (i.structure = a), o && (i.unit = o), s !== void 0 && (i.element = s), i;
  }, t.copy = function(i, a) {
    return i.unit = a.unit, i.element = a.element, i;
  }, t.is = function(i) {
    return !!i && i.kind === "element-location";
  }, t.areEqual = function(i, a) {
    return i.unit === a.unit && i.element === a.element;
  };
  var r = E.zero(), n = E.zero();
  t.distance = function(i, a) {
    return i.unit.conformation.position(i.element, r), a.unit.conformation.position(a.element, n), E.distance(r, n);
  }, t.residueIndex = function(i) {
    return i.unit.model.atomicHierarchy.residueAtomSegments.index[i.element];
  }, t.chainIndex = function(i) {
    return i.unit.model.atomicHierarchy.chainAtomSegments.index[i.element];
  };
})(at || (at = {}));
var OJ = function() {
  function t(e, r) {
    this.getHash = e, this.areEqual = r, this.size = 0, this.byHash = /* @__PURE__ */ new Map();
  }
  return t.prototype.add = function(e) {
    var r = this.getHash(e);
    if (this.byHash.has(r)) {
      for (var n = this.byHash.get(r), i = 0, a = n.length; i < a; i++) if (this.areEqual(e, n[i])) return !1;
      return n[n.length] = e, this.size++, !0;
    }
    return this.byHash.set(r, [e]), this.size++, !0;
  }, t.prototype.has = function(e) {
    var r = this.getHash(e);
    if (!this.byHash.has(r)) return !1;
    for (var n = this.byHash.get(r), i = 0, a = n.length; i < a; i++) if (this.areEqual(e, n[i])) return !0;
    return !1;
  }, t;
}();
function W9(t, e) {
  return new OJ(t, e);
}
function _D() {
  return new LJ();
}
function xD(t) {
  return { previous: null, next: null, inList: !0, value: t };
}
var bn, xe, wa, xt, yr, LJ = function() {
  function t() {
    this.count = 0, this.first = null, this.last = null;
  }
  return t.prototype.addFirst = function(e) {
    var r = xD(e);
    return r.inList = !0, this.first && (this.first.previous = r), r.next = this.first, this.first = r, this.count++, this.last || (this.last = r), r;
  }, t.prototype.addLast = function(e) {
    var r = xD(e);
    return this.last !== null && (this.last.next = r), r.previous = this.last, this.last = r, this.first === null && (this.first = r), r.inList = !0, this.count++, r;
  }, t.prototype.removeFirst = function() {
    var e = this.first;
    if (e) return this.remove(e), e.value;
  }, t.prototype.removeLast = function() {
    var e = this.last;
    if (e) return this.remove(e), e.value;
  }, t.prototype.remove = function(e) {
    e.inList && (e.inList = !1, e.previous !== null ? e.previous.next = e.next : e.previous === null && (this.first = e.next), e.next !== null ? e.next.previous = e.previous : e.next === null && (this.last = e.previous), e.next = null, e.previous = null, this.count--);
  }, t.prototype.find = function(e) {
    for (var r = this.first; r !== null; ) {
      if (r.value === e) return r;
      r = r.next;
    }
  }, t;
}();
function et(t, e) {
  var r = e || {}, n = r.description, i = n === void 0 ? void 0 : n, a = r.isOptional, o = a !== void 0 && a, s = r.isRest, u = s !== void 0 && s, c = r.defaultValue;
  return { type: t, isOptional: o, isRest: u, defaultValue: c === void 0 ? void 0 : c, description: i };
}
function dm(t, e, r, n) {
  var i = function(a) {
    return wa.Apply(wa.Symbol(i.id), a);
  };
  return i.info = { namespace: "", name: t, description: n }, i.id = "", i.args = e, i.type = r, i;
}
function T3(t) {
  var e = t;
  return typeof e == "function" && !!e.info && !!e.args && typeof e.info.namespace == "string" && !!e.type;
}
function It(t, e, r) {
  return dm("", t, e, r);
}
function QN(t) {
  $N("", "", t);
}
function JN(t) {
  var e = [];
  return eR(t, e), e;
}
function SD(t) {
  var e = /([a-z])([A-Z])([a-z]|$)/g;
  return t.replace(e, function(r, n, i, a) {
    return "".concat(n, "-").concat(i.toLocaleLowerCase()).concat(a);
  }).replace(e, function(r, n, i, a) {
    return "".concat(n, "-").concat(i.toLocaleLowerCase()).concat(a);
  });
}
function $N(t, e, r) {
  if (T3(r)) return r.info.namespace = t, r.info.name = r.info.name || SD(e), void (r.id = "".concat(r.info.namespace, ".").concat(r.info.name));
  for (var n = "".concat(r["@namespace"] || SD(e)), i = t ? "".concat(t, ".").concat(n) : n, a = 0, o = Object.keys(r); a < o.length; a++) {
    var s = o[a];
    (typeof r[s] == "object" || T3(r[s])) && $N(i, s, r[s]);
  }
}
function eR(t, e) {
  if (T3(t)) e.push(t);
  else for (var r = 0, n = Object.keys(t); r < n.length; r++) {
    var i = n[r];
    (typeof t[i] == "object" || T3(t[i])) && eR(t[i], e);
  }
}
function ea(t, e) {
  return It(xt.Dictionary({ 0: et(t) }), t, e);
}
function sd(t, e) {
  return It(xt.List(t, { nonEmpty: !0 }), t, e);
}
function Qu(t, e, r) {
  return It(xt.Dictionary({ 0: et(t), 1: et(t) }), e, r);
}
(function(t) {
  t.create = function() {
    return { keys: /* @__PURE__ */ new Set(), array: [] };
  }, t.add = function(e, r, n) {
    var i = e.keys, a = e.array;
    return !i.has(r) && (i.add(r), a[a.length] = n, !0);
  }, t.has = function(e, r) {
    return e.keys.has(r);
  };
})(bn || (bn = {})), function(t) {
  function e(n, i, a) {
    return { kind: "value", namespace: n, name: i, parent: a };
  }
  function r(n, 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: n, name: i, type: a, values: s };
  }
  t.Variable = function(n, i, a) {
    return { kind: "variable", name: n, type: i, isConstraint: a };
  }, t.Value = e, t.Container = function(n, i, a, o) {
    return { kind: "container", namespace: n, name: i, child: a, alias: o };
  }, t.Union = function(n) {
    return { kind: "union", types: n };
  }, t.OneOf = r, t.Any = { kind: "any" }, t.AnyValue = { kind: "any-value" }, t.Num = e("", "Number"), t.Str = e("", "String"), t.Bool = r("", "Bool", t.Str, ["true", "false"]), t.oneOfValues = function(n) {
    var i = n.values;
    return Object.keys(i).sort();
  };
}(xe || (xe = {})), function(t) {
  function e(n) {
    return !!n && !!n.head && typeof n == "object";
  }
  function r(n) {
    return !!n && typeof n.name == "string";
  }
  t.Symbol = function(n) {
    return { name: n };
  }, t.Apply = function(n, i) {
    return i ? { head: n, args: i } : { head: n };
  }, t.isArgumentsArray = function(n) {
    return !!n && Array.isArray(n);
  }, t.isArgumentsMap = function(n) {
    return !!n && !Array.isArray(n);
  }, t.isLiteral = function(n) {
    return !e(n) && !r(n);
  }, t.isApply = e, t.isSymbol = r;
}(wa || (wa = {})), function(t) {
  function e(r) {
    return { kind: "dictionary", map: r, "@type": 0 };
  }
  t.None = e({}), t.Dictionary = e, t.List = function(r, n) {
    var i = (n || {}).nonEmpty;
    return { kind: "list", type: r, nonEmpty: i !== void 0 && i, "@type": 0 };
  };
}(xt || (xt = {})), function(t) {
  t.AnyVar = xe.Variable("a", xe.Any), t.AnyValueVar = xe.Variable("a", xe.Any), t.ConstrainedVar = xe.Variable("a", xe.Any, !0), t.Regex = xe.Value("Core", "Regex"), t.Set = function(e) {
    return xe.Container("Core", "Set", e || t.AnyValueVar);
  }, t.List = function(e) {
    return xe.Container("Core", "List", e || t.AnyVar);
  }, t.Fn = function(e, r) {
    return xe.Container("Core", "Fn", e || t.AnyVar, r);
  }, t.Flags = function(e, r) {
    return xe.Container("Core", "Flags", e, r);
  }, t.BitFlags = t.Flags(xe.Num, "BitFlags");
}(yr || (yr = {})), xt.Dictionary({ 0: et(xe.Num), 1: et(xe.Num) }), et(xe.Str);
var j9 = { "@header": "Language Primitives", type: { "@header": "Types", bool: It(xt.Dictionary({ 0: et(xe.AnyValue) }), xe.Bool, "Convert a value to boolean."), num: It(xt.Dictionary({ 0: et(xe.AnyValue) }), xe.Num, "Convert a value to number."), str: It(xt.Dictionary({ 0: et(xe.AnyValue) }), xe.Str, "Convert a value to string."), regex: It(xt.Dictionary({ 0: et(xe.Str, { description: "Expression" }), 1: et(xe.Str, { isOptional: !0, description: "Flags, e.g. 'i' for ignore case" }) }), yr.Regex, "Creates a regular expression from a string using the ECMAscript syntax."), list: It(xt.List(yr.AnyVar), yr.List()), set: It(xt.List(yr.AnyValueVar), yr.Set()), bitflags: It(xt.Dictionary({ 0: et(xe.Num) }), yr.BitFlags, "Interpret a number as bitflags."), compositeKey: It(xt.List(xe.AnyValue), xe.AnyValue) }, logic: { "@header": "Logic", not: ea(xe.Bool), and: sd(xe.Bool), or: sd(xe.Bool) }, ctrl: { "@header": "Control", eval: It(xt.Dictionary({ 0: et(yr.Fn(yr.AnyVar)) }), yr.AnyVar, "Evaluate a function."), fn: It(xt.Dictionary({ 0: et(yr.AnyVar) }), yr.Fn(yr.AnyVar), 'Wrap an expression to a "lazy" function.'), if: It(xt.Dictionary({ 0: et(xe.Bool, { description: "Condition" }), 1: et(xe.Variable("a", xe.Any), { description: "If true" }), 2: et(xe.Variable("b", xe.Any), { description: "If false" }) }), xe.Union([xe.Variable("a", xe.Any), xe.Variable("b", xe.Any)])), assoc: It(xt.Dictionary({ 0: et(xe.Str, { description: "Name" }), 1: et(xe.Variable("a", xe.Any), { description: "Value to assign" }) }), xe.Variable("a", xe.Any)) }, rel: { "@header": "Relational", eq: Qu(xe.Variable("a", xe.AnyValue, !0), xe.Bool), neq: Qu(xe.Variable("a", xe.AnyValue, !0), xe.Bool), lt: Qu(xe.Num, xe.Bool), lte: Qu(xe.Num, xe.Bool), gr: Qu(xe.Num, xe.Bool), gre: Qu(xe.Num, xe.Bool), inRange: It(xt.Dictionary({ 0: et(xe.Num, { description: "Value to test" }), 1: et(xe.Num, { description: "Minimum value" }), 2: et(xe.Num, { description: "Maximum value" }) }), xe.Bool, "Check if the value of the 1st argument is >= 2nd and <= 3rd.") }, math: { "@header": "Math", add: sd(xe.Num), sub: sd(xe.Num), mult: sd(xe.Num), div: Qu(xe.Num, xe.Num), pow: Qu(xe.Num, xe.Num), mod: Qu(xe.Num, xe.Num), min: sd(xe.Num), max: sd(xe.Num), floor: ea(xe.Num), ceil: ea(xe.Num), roundInt: ea(xe.Num), abs: ea(xe.Num), sqrt: ea(xe.Num), cbrt: ea(xe.Num), sin: ea(xe.Num), cos: ea(xe.Num), tan: ea(xe.Num), asin: ea(xe.Num), acos: ea(xe.Num), atan: ea(xe.Num), sinh: ea(xe.Num), cosh: ea(xe.Num), tanh: ea(xe.Num), exp: ea(xe.Num), log: ea(xe.Num), log10: ea(xe.Num), atan2: Qu(xe.Num, xe.Num) }, str: { "@header": "Strings", concat: sd(xe.Str), match: It(xt.Dictionary({ 0: et(yr.Regex), 1: et(xe.Str) }), xe.Bool) }, list: { "@header": "Lists", getAt: It(xt.Dictionary({ 0: et(yr.List()), 1: et(xe.Num) }), yr.AnyVar), equal: It(xt.Dictionary({ 0: et(yr.List()), 1: et(yr.List()) }), xe.Bool) }, set: { "@header": "Sets", has: It(xt.Dictionary({ 0: et(yr.Set(yr.ConstrainedVar)), 1: et(yr.ConstrainedVar) }), xe.Bool, "Check if the the 1st argument includes the value of the 2nd."), isSubset: It(xt.Dictionary({ 0: et(yr.Set(yr.ConstrainedVar)), 1: et(yr.Set(yr.ConstrainedVar)) }), xe.Bool, "Check if the the 1st argument is a subset of the 2nd.") }, flags: { "@header": "Flags", hasAny: It(xt.Dictionary({ 0: et(yr.Flags(yr.ConstrainedVar)), 1: et(yr.Flags(yr.ConstrainedVar)) }), xe.Bool, "Check if the the 1st argument has at least one of the 2nd one's flags."), hasAll: It(xt.Dictionary({ 0: et(yr.Flags(yr.ConstrainedVar)), 1: et(yr.Flags(yr.ConstrainedVar)) }), xe.Bool, "Check if the the 1st argument has all 2nd one's flags.") } };
QN(j9);
var pt, kJ = JN(j9);
function mr(t, e) {
  return It(xt.Dictionary({ 0: et(pt.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }) }), t, e);
}
function Bh(t, e) {
  return It(xt.None, t, e);
}
(function() {
  for (var t = /* @__PURE__ */ Object.create(null), e = 0, r = kJ; e < r.length; e++) {
    var n = r[e];
    t[n.id] = n;
  }
})(), function(t) {
  t.ElementSymbol = xe.Value("Structure", "ElementSymbol"), t.AtomName = xe.Value("Structure", "AtomName"), t.BondFlag = xe.OneOf("Structure", "BondFlag", xe.Str, ["covalent", "metallic", "ion", "hydrogen", "sulfide", "computed", "aromatic"]), t.BondFlags = yr.Flags(t.BondFlag, "BondFlags"), t.SecondaryStructureFlag = xe.OneOf("Structure", "SecondaryStructureFlag", xe.Str, ["alpha", "beta", "3-10", "pi", "sheet", "strand", "helix", "turn", "none"]), t.SecondaryStructureFlags = yr.Flags(t.SecondaryStructureFlag, "SecondaryStructureFlag"), t.RingFingerprint = xe.Value("Structure", "RingFingerprint"), t.EntityType = xe.OneOf("Structure", "EntityType", xe.Str, ["polymer", "non-polymer", "water", "branched"]), t.EntitySubtype = xe.OneOf("Structure", "EntitySubtype", xe.Str, ["other", "polypeptide(D)", "polypeptide(L)", "polydeoxyribonucleotide", "polyribonucleotide", "polydeoxyribonucleotide/polyribonucleotide hybrid", "cyclic-pseudo-peptide", "peptide nucleic acid", "oligosaccharide"]), t.ObjectPrimitive = xe.OneOf("Structure", "ObjectPrimitive", xe.Str, ["atomistic", "sphere", "gaussian", "other"]), t.ResidueId = xe.Value("Structure", "ResidueId"), t.ElementSet = xe.Value("Structure", "ElementSet"), t.ElementSelection = xe.Value("Structure", "ElementSelection"), t.ElementReference = xe.Value("Structure", "ElementReference"), t.ElementSelectionQuery = yr.Fn(t.ElementSelection, "ElementSelectionQuery");
}(pt || (pt = {}));
var pe = { core: j9, structureQuery: { "@header": "Structure Queries", type: { "@header": "Types", elementSymbol: It(xt.Dictionary({ 0: et(xe.Str) }), pt.ElementSymbol, "Create element symbol representation from a string value."), atomName: It(xt.Dictionary({ 0: et(xe.AnyValue) }), pt.AtomName, "Convert a value to an atom name."), entityType: It(xt.Dictionary({ 0: et(pt.EntityType) }), pt.EntityType, "Create normalized representation of entity type: ".concat(xe.oneOfValues(pt.EntityType).join(", "), ".")), bondFlags: It(xt.List(pt.BondFlag), pt.BondFlags, "Create bond flags representation from a list of strings. Allowed flags: ".concat(xe.oneOfValues(pt.BondFlag).join(", "), ".")), ringFingerprint: It(xt.List(pt.ElementSymbol, { nonEmpty: !0 }), pt.RingFingerprint, "Create ring fingerprint from the supplied atom element list."), secondaryStructureFlags: It(xt.List(pt.SecondaryStructureFlag), pt.SecondaryStructureFlags, "Create secondary structure flags representation from a list of strings. Allowed flags: ".concat(xe.oneOfValues(pt.SecondaryStructureFlag).join(", "), ".")), authResidueId: It(xt.Dictionary({ 0: et(xe.Str, { description: "auth_asym_id" }), 1: et(xe.Num, { description: "auth_seq_id" }), 2: et(xe.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 }) }), pt.ResidueId, 'Residue identifier based on "auth_" annotation.'), labelResidueId: It(xt.Dictionary({ 0: et(xe.Str, { description: "label_entity_id" }), 1: et(xe.Str, { description: "label_asym_id" }), 2: et(xe.Num, { description: "label_seq_id" }), 3: et(xe.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 }) }), pt.ResidueId, `Residue identifier based on mmCIF's "label_" annotation.`) }, slot: { "@header": "Iteration Slots", element: It(xt.None, pt.ElementReference, "A reference to the current element."), elementSetReduce: It(xt.None, xe.Variable("a", xe.AnyValue, !0), "Current value of the element set reducer.") }, generator: { "@header": "Generators", all: It(xt.None, pt.ElementSelectionQuery, "The entire structure."), atomGroups: It(xt.Dictionary({ "entity-test": et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every entity" }), "chain-test": et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every chain" }), "residue-test": et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom every residue" }), "atom-test": et(xe.Bool, { isOptional: !0, defaultValue: !0 }), "group-by": et(xe.Any, { isOptional: !0, defaultValue: "atom-key", description: "Group atoms to sets based on this property. Default: each atom has its own set" }) }), pt.ElementSelectionQuery, "Return all atoms for which the tests are satisfied, grouped into sets."), bondedAtomicPairs: It(xt.Dictionary({ 0: et(xe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds", description: "Test each bond with this predicate. Each bond is visited twice with swapped atom order." }) }), pt.ElementSelectionQuery, "Return all pairs of atoms for which the test is satisfied."), rings: It(xt.Dictionary({ fingerprint: et(pt.RingFingerprint, { isOptional: !0 }), "only-aromatic": et(xe.Bool, { isOptional: !0, defaultValue: !1 }) }), pt.ElementSelectionQuery, "Return all rings or those with the specified fingerprint and/or only aromatic rings."), queryInSelection: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), query: et(pt.ElementSelectionQuery), "in-complement": et(xe.Bool, { isOptional: !0, defaultValue: !1 }) }), pt.ElementSelectionQuery, "Executes query only on atoms that are in the source selection."), empty: It(xt.None, pt.ElementSelectionQuery, "Nada.") }, modifier: { "@header": "Selection Modifications", queryEach: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), query: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Query every atom set in the input selection separately."), intersectBy: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), by: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Intersect each atom set from the first sequence from atoms in the second one."), exceptBy: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), by: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Remove all atoms from 'selection' that occur in 'by'."), unionBy: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), by: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "For each atom set A in the orginal sequence, combine all atoms sets in the target selection that intersect with A."), union: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Collects all atom sets in the sequence into a single atom set."), cluster: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), "min-distance": et(xe.Num, { isOptional: !0, defaultValue: 0 }), "max-distance": et(xe.Num), "min-size": et(xe.Num, { description: "Minimal number of sets to merge, must be at least 2", isOptional: !0, defaultValue: 2 }), "max-size": et(xe.Num, { description: "Maximal number of sets to merge, if not set, no limit", isOptional: !0 }) }), pt.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(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), radius: et(xe.Num), "atom-radius": et(xe.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": et(xe.Bool, { isOptional: !0 }) }), pt.ElementSelectionQuery, "For each atom set in the selection, include all surrouding atoms/residues that are within the specified radius."), surroundingLigands: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), radius: et(xe.Num), "include-water": et(xe.Bool, { isOptional: !0, defaultValue: !0 }) }), pt.ElementSelectionQuery, "Find all ligands components around the source query."), includeConnected: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), "bond-test": et(xe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }), "layer-count": et(xe.Num, { isOptional: !0, defaultValue: 1, description: "Number of bonded layers to include." }), "fixed-point": et(xe.Bool, { isOptional: !0, defaultValue: !1, description: "Continue adding layers as long as new connections exist." }), "as-whole-residues": et(xe.Bool, { isOptional: !0 }) }), pt.ElementSelectionQuery, "Pick all atom sets that are connected to the target."), wholeResidues: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Expand the selection to whole residues."), expandProperty: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), property: et(xe.AnyValue) }), pt.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(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), test: et(xe.Bool) }), pt.ElementSelectionQuery, "Pick all atom sets that satisfy the test."), first: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Take the 1st atom set in the sequence."), withSameAtomProperties: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), source: et(pt.ElementSelectionQuery), property: et(xe.Any) }), pt.ElementSelectionQuery, "Pick all atom sets for which the set of given atom properties is a subset of the source properties."), intersectedBy: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), by: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Pick all atom sets that have non-zero intersection with the target."), within: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), target: et(pt.ElementSelectionQuery), "min-radius": et(xe.Num, { isOptional: !0, defaultValue: 0 }), "max-radius": et(xe.Num), "atom-radius": et(xe.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: et(xe.Bool, { isOptional: !0, defaultValue: !1, description: "If true, pick only atom sets that are further than the specified radius." }) }), pt.ElementSelectionQuery, "Pick all atom sets from selection that have any atom within the radius of any atom from target."), isConnectedTo: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), target: et(pt.ElementSelectionQuery), "bond-test": et(xe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }), disjunct: et(xe.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: et(xe.Bool, { isOptional: !0, defaultValue: !1, description: "If true, return atom sets that are not connected." }) }), pt.ElementSelectionQuery, "Pick all atom sets that are connected to the target.") }, combinator: { "@header": "Selection Combinators", intersect: It(xt.List(pt.ElementSelectionQuery), pt.ElementSelectionQuery, "Return all unique atom sets that appear in all of the source selections."), merge: It(xt.List(pt.ElementSelectionQuery), pt.ElementSelectionQuery, "Merges multiple selections into a single one. Only unique atom sets are kept."), distanceCluster: It(xt.Dictionary({ matrix: et(yr.List(yr.List(xe.Num)), { description: "Distance matrix, represented as list of rows (num[][])). Lower triangle is min distance, upper triangle is max distance." }), selections: et(yr.List(pt.ElementSelectionQuery), { description: "A list of held selections." }) }), pt.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(xt.None, xe.Num), countQuery: It(xt.Dictionary({ 0: et(pt.ElementSelectionQuery) }), xe.Num, "Counts the number of occurences of a specific query inside the current atom set."), reduce: It(xt.Dictionary({ initial: et(xe.Variable("a", xe.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: et(xe.Variable("a", xe.AnyValue, !0), { description: "Expression executed for each atom in the set" }) }), xe.Variable("a", xe.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(xt.Dictionary({ 0: et(yr.ConstrainedVar) }), yr.Set(yr.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: mr(pt.ElementSymbol), vdw: mr(xe.Num, "Van der Waals radius"), mass: mr(xe.Num, "Atomic weight"), atomicNumber: mr(xe.Num, "Atomic number"), x: mr(xe.Num, "Cartesian X coordinate"), y: mr(xe.Num, "Cartesian Y coordinate"), z: mr(xe.Num, "Cartesian Z coordinate"), atomKey: mr(xe.AnyValue, "Unique value for each atom. Main use case is grouping of atoms."), bondCount: It(xt.Dictionary({ 0: et(pt.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }), flags: et(pt.BondFlags, { isOptional: !0, defaultValue: "covalent" }) }), xe.Num, "Number of bonds (by default only covalent bonds are counted)."), sourceIndex: mr(xe.Num, "Index of the atom/element in the input file."), operatorName: mr(xe.Str, "Name of the symmetry operator applied to this element."), modelIndex: mr(xe.Num, "Index of the model in the input file."), modelLabel: mr(xe.Str, "Label/header of the model in the input file.") }, topology: { connectedComponentKey: mr(xe.AnyValue, "Unique value for each connected component.") }, macromolecular: { "@header": "Macromolecular Properties (derived from the mmCIF format)", authResidueId: mr(pt.ResidueId, "type.auth-residue-id symbol executed on current atom's residue"), labelResidueId: mr(pt.ResidueId, "type.label-residue-id symbol executed on current atom's residue"), residueKey: mr(xe.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: mr(xe.AnyValue, "Unique value for each tuple ``(label_entity_id, auth_asym_id)``, main use case is grouping of atoms"), entityKey: mr(xe.AnyValue, "Unique value for each tuple ``label_entity_id``, main use case is grouping of atoms"), isHet: mr(xe.Bool, "Equivalent to atom_site.group_PDB !== ATOM"), id: mr(xe.Num, "_atom_site.id"), label_atom_id: mr(pt.AtomName), label_alt_id: mr(xe.Str), label_comp_id: mr(xe.Str), label_asym_id: mr(xe.Str), label_entity_id: mr(xe.Str), label_seq_id: mr(xe.Num), auth_atom_id: mr(pt.AtomName), auth_comp_id: mr(xe.Str), auth_asym_id: mr(xe.Str), auth_seq_id: mr(xe.Num), pdbx_PDB_ins_code: mr(xe.Str), pdbx_formal_charge: mr(xe.Num), occupancy: mr(xe.Num), B_iso_or_equiv: mr(xe.Num), entityType: mr(pt.EntityType, "Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)"), entitySubtype: mr(pt.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: mr(xe.Str, "The PRD ID of the entity."), entityDescription: mr(yr.List(xe.Str)), objectPrimitive: mr(pt.ObjectPrimitive, "Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)"), secondaryStructureKey: mr(xe.AnyValue, "Unique value for each secondary structure element."), secondaryStructureFlags: mr(pt.SecondaryStructureFlags), isModified: mr(xe.Bool, "True if the atom belongs to modification of a standard residue."), modifiedParentName: mr(xe.Str, "'3-letter' code of the modifed parent residue."), isNonStandard: mr(xe.Bool, "True if this is a non-standard residue."), chemCompType: mr(xe.Str, "Type of the chemical component as defined in mmCIF.") } }, bondProperty: { "@header": "Bond Properties", flags: Bh(pt.BondFlags), order: Bh(xe.Num), length: Bh(xe.Num), atomA: Bh(pt.ElementReference), atomB: Bh(pt.ElementReference) } }, internal: { "@header": "Internal Queries", generator: { "@header": "Generators", bundleElement: It(xt.Dictionary({ groupedUnits: et(xe.Any), set: et(xe.Any), ranges: et(xe.Any) }), xe.Any), bundle: It(xt.Dictionary({ elements: et(xe.Any) }), pt.ElementSelectionQuery, "A selection with single structure containing represented by the bundle."), current: It(xt.None, pt.ElementSelectionQuery, "Current selection provided by the query context. Avoid using this in State Transforms.") } } };
QN(pe);
var Nt, GJ = JN(pe);
(function() {
  for (var t = /* @__PURE__ */ Object.create(null), e = 0, r = GJ; e < r.length; e++) {
    var n = r[e];
    t[n.id] = n;
  }
})(), function(t) {
  t.core = pe.core, t.struct = pe.structureQuery, t.internal = pe.internal, t.atomName = function(u) {
    return t.struct.type.atomName([u]);
  }, t.es = function(u) {
    return t.struct.type.elementSymbol([u]);
  }, t.list = function() {
    for (var u = [], c = 0; c < arguments.length; c++) u[c] = arguments[c];
    return t.core.type.list(u);
  }, t.set = function() {
    for (var u = [], c = 0; c < arguments.length; c++) u[c] = arguments[c];
    return t.core.type.set(u);
  }, t.re = function(u, c) {
    return t.core.type.regex([u, c]);
  }, t.fn = function(u) {
    return t.core.ctrl.fn([u]);
  }, t.evaluate = function(u) {
    return t.core.ctrl.eval([u]);
  };
  var e = t.struct.atomProperty.core, r = t.struct.atomProperty.macromolecular, n = t.struct.atomProperty.topology;
  function i(u) {
    return e[u]();
  }
  function a(u) {
    return n[u]();
  }
  function o(u) {
    return r[u]();
  }
  t.acp = i, t.atp = a, t.ammp = o;
  var s = t.struct.atomSet.propertySet;
  t.acpSet = function(u) {
    return s([i(u)]);
  }, t.atpSet = function(u) {
    return s([a(u)]);
  }, t.ammpSet = function(u) {
    return s([o(u)]);
  };
}(Nt || (Nt = {}));
var Fs, Ns, zJ = /* @__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"]), yt = { Blue: 37052, Green: 42577, Yellow: 16765952, Orange: 16021792, Pink: 16162465, Purple: 10830745, LightBlue: 9424105, Brown: 10582605, Red: 15539236, Secondary: 15854817 };
(Fs = {})[0] = "Hexose", Fs[1] = "HexNAc", Fs[2] = "Hexosamine", Fs[3] = "Hexuronate", Fs[4] = "Deoxyhexose", Fs[5] = "DeoxyhexNAc", Fs[6] = "Di-deoxyhexose", Fs[7] = "Pentose", Fs[8] = "Deoxynonulosonate", Fs[9] = "Di-deoxynonulosonate", Fs[10] = "Unknown", Fs[11] = "Assigned", (Ns = {})[0] = 0, Ns[1] = 1, Ns[2] = 2, Ns[3] = 3, Ns[4] = 4, Ns[5] = 5, Ns[6] = 6, Ns[7] = 7, Ns[8] = 8, Ns[9] = 9, Ns[10] = 10, Ns[11] = 11;
var ud, tR = { abbr: "Unk", name: "Unknown", color: yt.Secondary, type: 10 }, M3 = [{ abbr: "Glc", name: "Glucose", color: yt.Blue, type: 0 }, { abbr: "Man", name: "Mannose", color: yt.Green, type: 0 }, { abbr: "Gal", name: "Galactose", color: yt.Yellow, type: 0 }, { abbr: "Gul", name: "Gulose", color: yt.Orange, type: 0 }, { abbr: "Alt", name: "Altrose", color: yt.Pink, type: 0 }, { abbr: "All", name: "Allose", color: yt.Purple, type: 0 }, { abbr: "Tal", name: "Talose", color: yt.LightBlue, type: 0 }, { abbr: "Ido", name: "Idose", color: yt.Brown, type: 0 }, { abbr: "GlcNAc", name: "N-Acetyl Glucosamine", color: yt.Blue, type: 1 }, { abbr: "ManNAc", name: "N-Acetyl Mannosamine", color: yt.Green, type: 1 }, { abbr: "GalNAc", name: "N-Acetyl Galactosamine", color: yt.Yellow, type: 1 }, { abbr: "GulNAc", name: "N-Acetyl Gulosamine", color: yt.Orange, type: 1 }, { abbr: "AltNAc", name: "N-Acetyl Altrosamine", color: yt.Pink, type: 1 }, { abbr: "AllNAc", name: "N-Acetyl Allosamine", color: yt.Purple, type: 1 }, { abbr: "TalNAc", name: "N-Acetyl Talosamine", color: yt.LightBlue, type: 1 }, { abbr: "IdoNAc", name: "N-Acetyl Idosamine", color: yt.Brown, type: 1 }, { abbr: "GlcN", name: "Glucosamine", color: yt.Blue, type: 2 }, { abbr: "ManN", name: "Mannosamine", color: yt.Green, type: 2 }, { abbr: "GalN", name: "Galactosamine", color: yt.Yellow, type: 2 }, { abbr: "GulN", name: "Gulosamine", color: yt.Orange, type: 2 }, { abbr: "AltN", name: "Altrosamine", color: yt.Pink, type: 2 }, { abbr: "AllN", name: "Allosamine", color: yt.Purple, type: 2 }, { abbr: "TalN", name: "Talosamine", color: yt.LightBlue, type: 2 }, { abbr: "IdoN", name: "Idosamine", color: yt.Brown, type: 2 }, { abbr: "GlcA", name: "Glucuronic Acid", color: yt.Blue, type: 3 }, { abbr: "ManA", name: "Mannuronic Acid", color: yt.Green, type: 3 }, { abbr: "GalA", name: "Galacturonic Acid", color: yt.Yellow, type: 3 }, { abbr: "GulA", name: "Guluronic Acid", color: yt.Orange, type: 3 }, { abbr: "AltA", name: "Altruronic Acid", color: yt.Pink, type: 3 }, { abbr: "AllA", name: "Alluronic Acid", color: yt.Purple, type: 3 }, { abbr: "TalA", name: "Taluronic Acid", color: yt.LightBlue, type: 3 }, { abbr: "IdoA", name: "Iduronic Acid", color: yt.Brown, type: 3 }, { abbr: "Qui", name: "Quinovose", color: yt.Blue, type: 4 }, { abbr: "Rha", name: "Rhamnose", color: yt.Green, type: 4 }, { abbr: "6dGul", name: "6-Deoxy Gulose", color: yt.Orange, type: 4 }, { abbr: "6dAlt", name: "6-Deoxy Altrose", color: yt.Pink, type: 4 }, { abbr: "6dTal", name: "6-Deoxy Talose", color: yt.LightBlue, type: 4 }, { abbr: "Fuc", name: "Fucose", color: yt.Red, type: 4 }, { abbr: "QuiNAc", name: "N-Acetyl Quinovosamine", color: yt.Blue, type: 5 }, { abbr: "RhaNAc", name: "N-Acetyl Rhamnosamine", color: yt.Green, type: 5 }, { abbr: "6dAltNAc", name: "N-Acetyl 6-Deoxy Altrosamine", color: yt.Pink, type: 5 }, { abbr: "6dTalNAc", name: "N-Acetyl 6-Deoxy Talosamine", color: yt.LightBlue, type: 5 }, { abbr: "FucNAc", name: "N-Acetyl Fucosamine", color: yt.Red, type: 5 }, { abbr: "Oli", name: "Olivose", color: yt.Blue, type: 6 }, { abbr: "Tyv", name: "Tyvelose", color: yt.Green, type: 6 }, { abbr: "Abe", name: "Abequose", color: yt.Orange, type: 6 }, { abbr: "Par", name: "Paratose", color: yt.Pink, type: 6 }, { abbr: "Dig", name: "Digitoxose", color: yt.Purple, type: 6 }, { abbr: "Col", name: "Colitose", color: yt.LightBlue, type: 6 }, { abbr: "Ara", name: "Arabinose", color: yt.Green, type: 7 }, { abbr: "Lyx", name: "Lyxose", color: yt.Yellow, type: 7 }, { abbr: "Xyl", name: "Xylose", color: yt.Orange, type: 7 }, { abbr: "Rib", name: "Ribose", color: yt.Pink, type: 7 }, { abbr: "Kdn", name: "Keto-Deoxy Nonulonic Acid", color: yt.Green, type: 8 }, { abbr: "Neu5Ac", name: "N-Acetyl Neuraminic Acid", color: yt.Purple, type: 8 }, { abbr: "Neu5Gc", name: "N-Glycolyl Neuraminic Acid", color: yt.LightBlue, type: 8 }, { abbr: "Neu", name: "Neuraminic Acid", color: yt.Brown, type: 8 }, { abbr: "Sia", name: "Sialic acid", color: yt.Red, type: 8 }, { abbr: "Pse", name: "Pseudaminic Acid", color: yt.Green, type: 9 }, { abbr: "Leg", name: "Legionaminic Acid", color: yt.Yellow, type: 9 }, { abbr: "Aci", name: "Acinetaminic Acid", color: yt.Pink, type: 9 }, { abbr: "4eLeg", name: "4-Epilegionaminic Acid", color: yt.LightBlue, type: 9 }, { abbr: "Bac", name: "Bacillosamine", color: yt.Blue, type: 10 }, { abbr: "LDmanHep", name: "L-Glycero-D-Manno Heptose", color: yt.Green, type: 10 }, { abbr: "Kdo", name: "Keto-Deoxy Octulonic Acid", color: yt.Yellow, type: 10 }, { abbr: "Dha", name: "3-Deoxy Lyxo-Heptulosaric Acid", color: yt.Orange, type: 10 }, { abbr: "DDmanHep", name: "D-Glycero-D-Manno-Heptose", color: yt.Pink, type: 10 }, { abbr: "MurNAc", name: "N-Acetyl Muramic Acid", color: yt.Purple, type: 10 }, { abbr: "MurNGc", name: "N-Glycolyl Muramic Acid", color: yt.LightBlue, type: 10 }, { abbr: "Mur", name: "Muramic Acid", color: yt.Brown, type: 10 }, { abbr: "Api", name: "Apicose", color: yt.Green, type: 11 }, { abbr: "Fru", name: "Fructose", color: yt.Green, type: 11 }, { abbr: "Tag", name: "Tagatose", color: yt.Yellow, type: 11 }, { abbr: "Sor", name: "Sorbose", color: yt.Orange, type: 11 }, { abbr: "Psi", name: "Psicose", color: yt.Pink, type: 11 }], VJ = function() {
  for (var t = /* @__PURE__ */ new Map(), e = 0, r = M3.length; e < r; ++e) {
    var n = M3[e];
    t.set(n.abbr, n);
  }
  return t;
}(), UJ = [["Glc-family", yt.Blue], ["Man-family", yt.Green], ["Gal-family", yt.Yellow], ["Gul-family", yt.Orange], ["Alt-family", yt.Pink], ["All-family", yt.Purple], ["Tal-family", yt.LightBlue], ["Ido-family", yt.Brown], ["Fuc-family", yt.Red], ["Generic/Unknown/Secondary", yt.Secondary]], HJ = { 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"] }, qJ = { 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"] }, Jd = function() {
  for (var t = /* @__PURE__ */ new Map(), e = 0, r = M3.length; e < r; ++e) {
    var n = M3[e], i = HJ[n.abbr];
    if (i) for (var a = 0, o = i.length; a < o; ++a) t.set(i[a], n);
    var s = qJ[n.abbr];
    if (s) for (a = 0, o = s.length; a < o; ++a) t.set(s[a], n);
  }
  return zJ.forEach(function(u) {
    t.has(u) || t.set(u, tR);
  }), t;
}(), rR = /* @__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"]), h2 = /* @__PURE__ */ new Set(["118", "119", "543", "1AL", "1CU", "2FK", "2HP", "2OF", "3CO", "3MT", "3NI", "3OF", "3P8", "4MO", "4PU", "4TI", "6MO", "ACT", "AG", "AL", "ALF", "AM", "ATH", "AU", "AU3", "AUC", "AZI", "BA", "BCT", "BEF", "BF4", "BO4", "BR", "BS3", "BSY", "CA", "CAC", "CD", "CD1", "CD3", "CD5", "CE", "CF", "CHT", "CL", "CO", "CO3", "CO5", "CON", "CR", "CS", "CSB", "CU", "CU1", "CU3", "CUA", "CUZ", "CYN", "DME", "DMI", "DSC", "DTI", "DY", "E4N", "EDR", "EMC", "ER3", "EU", "EU3", "F", "FE", "FE2", "FPO", "GA", "GD3", "GEP", "HAI", "HG", "HGC", "IN", "IOD", "IR", "IR3", "IRI", "IUM", "K", "KO4", "LA", "LCO", "LCP", "LI", "LU", "MAC", "MG", "MH2", "MH3", "MLI", "MMC", "MN", "MN3", "MN5", "MN6", "MO1", "MO2", "MO3", "MO4", "MO5", "MO6", "MOO", "MOS", "MOW", "MW1", "MW2", "MW3", "NA", "NA2", "NA5", "NA6", "NAO", "NAW", "ND", "NET", "NH4", "NI", "NI1", "NI2", "NI3", "NO2", "NO3", "NRU", "O4M", "OAA", "OC1", "OC2", "OC3", "OC4", "OC5", "OC6", "OC7", "OC8", "OCL", "OCM", "OCN", "OCO", "OF1", "OF2", "OF3", "OH", "OS", "OS4", "OXL", "PB", "PBM", "PD", "PDV", "PER", "PI", "PO3", "PO4", "PR", "PT", "PT4", "PTN", "RB", "RH3", "RHD", "RU", "SB", "SCN", "SE4", "SEK", "SM", "SMO", "SO3", "SO4", "SR", "T1A", "TB", "TBA", "TCN", "TEA", "TH", "THE", "TL", "TMA", "TRA", "UNX", "V", "VN3", "VO4", "W", "WO5", "Y1", "YB", "YB2", "YH", "YT3", "ZCM", "ZN", "ZN2", "ZN3", "ZNO", "ZO3", "ZR", "NCO", "OHX"]), KJ = function() {
  for (var t = /* @__PURE__ */ Object.create(null), e = [], r = 65; r <= 90; r++) e[e.length] = String.fromCharCode(r);
  for (r = 97; r <= 122; r++) e[e.length] = String.fromCharCode(r);
  for (r = 48; r <= 57; r++) e[e.length] = String.fromCharCode(r);
  for (var n = 0, i = e; n < i.length; n++) {
    var a = i[n];
    t[a] = a.toUpperCase();
    for (var o = 0, s = e; o < s.length; o++) {
      var u = s[o];
      t[a + u] = (a + u).toUpperCase();
      for (var c = 0, l = e; c < l.length; c++) {
        var d = l[c];
        t[a + u + d] = (a + u + d).toUpperCase();
      }
    }
  }
  return t;
}();
function bp(t) {
  return KJ[t] || t.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(t) {
  return [t[0], bp(t[1])];
}));
var _r, lr, XJ = ((ud = {})[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() }, ud[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"]) }, ud[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"]) }, ud[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"]) }, ud[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"]) }, ud[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"]) }, ud[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"]) }, ud), Z9 = /* @__PURE__ */ new Set(["CA", "C", "N", "O", "O1", "O2", "OC1", "OC2", "OT1", "OT2", "OX1", "OXT", "H", "H1", "H2", "H3", "HA", "HN", "HXT", "BB"]), YJ = /* @__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*"]), nR = /* @__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"]), iR = /* @__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"]), WJ = /* @__PURE__ */ new Set(["D-GAMMA-PEPTIDE, C-DELTA LINKING", "L-GAMMA-PEPTIDE, C-DELTA LINKING"]), jJ = /* @__PURE__ */ new Set(["D-BETA-PEPTIDE, C-GAMMA LINKING", "L-BETA-PEPTIDE, C-GAMMA LINKING"]), ZJ = /* @__PURE__ */ new Set(["D-PEPTIDE NH3 AMINO TERMINUS", "D-PEPTIDE COOH CARBOXY TERMINUS", "L-PEPTIDE NH3 AMINO TERMINUS", "L-PEPTIDE COOH CARBOXY TERMINUS"]), aR = /* @__PURE__ */ new Set(["PEPTIDE LINKING", "PEPTIDE-LIKE"]), QJ = Ao.unionMany(nR, iR, aR), oR = /* @__PURE__ */ new Set(["DNA LINKING", "L-DNA LINKING", "DNA OH 5 PRIME TERMINUS", "DNA OH 3 PRIME TERMINUS"]), sR = /* @__PURE__ */ new Set(["RNA LINKING", "L-RNA LINKING", "RNA OH 5 PRIME TERMINUS", "RNA OH 3 PRIME TERMINUS"]), uR = /* @__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"]), JJ = /* @__PURE__ */ new Set(["NON-POLYMER", "OTHER"]), $J = /* @__PURE__ */ new Set(["ION"]), e$ = /* @__PURE__ */ new Set(["LIPID"]), Zp = /* @__PURE__ */ new Set(["SOL", "WAT", "HOH", "H2O", "W", "DOD", "D3O", "TIP", "TIP3", "TIP4", "SPC"]), cR = /* @__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"]), lR = /* @__PURE__ */ new Set(["DAL", "DAR", "DSG", "DAS", "DCY", "DGL", "DGN", "DHI", "DIL", "DLE", "DLY", "MED", "DPN", "DPR", "DSN", "DTH", "DTR", "DTY", "DVA", "DNE"]), m2 = Ao.unionMany(cR, lR), Ny = /* @__PURE__ */ new Set(["A", "C", "T", "G", "I", "U", "N"]), Ry = /* @__PURE__ */ new Set(["DA", "DC", "DT", "DG", "DI", "DU", "DN"]), Q9 = /* @__PURE__ */ new Set(["APN", "CPN", "TPN", "GPN"]), t$ = /* @__PURE__ */ new Set(["A", "G", "I", "DA", "DG", "DI", "APN", "GPN"]), r$ = /* @__PURE__ */ new Set(["C", "T", "U", "DC", "DT", "DU", "CPN", "TPN"]), J9 = Ao.unionMany(Ny, Ry, Q9), dR = function(t) {
  return t$.has(t.toUpperCase());
}, fR = function(t) {
  return r$.has(t.toUpperCase());
}, $9 = Ao.unionMany(m2, J9);
function g2(t, e) {
  return t = t.toUpperCase(), e = e.toUpperCase(), Q9.has(e) ? 8 : QJ.has(t) ? 5 : sR.has(t) ? 6 : oR.has(t) ? 7 : uR.has(t) ? 9 : Zp.has(e) ? 2 : h2.has(e) ? 3 : rR.has(e) ? 4 : JJ.has(t) ? Jd.has(e) ? 9 : m2.has(e) ? 5 : Ny.has(e) ? 6 : Ry.has(e) ? 7 : 1 : 0;
}
function n$(t, e) {
  return t = t.toUpperCase(), e === 5 ? WJ.has(t) ? 2 : jJ.has(t) ? 3 : ZJ.has(t) ? 0 : 1 : e === 6 ? 4 : e === 7 ? 5 : e === 8 ? 6 : 0;
}
function pR(t) {
  return t = t.toUpperCase(), m2.has(t) ? "peptide linking" : Ny.has(t) ? "RNA linking" : Ry.has(t) ? "DNA linking" : Jd.has(t) ? "saccharide" : "other";
}
function i$(t) {
  return t = t.toUpperCase(), Zp.has(t) ? "water" : $9.has(t) ? "polymer" : Jd.has(t) ? "branched" : "non-polymer";
}
function a$(t, e) {
  return t = t.toUpperCase(), e = e.toUpperCase(), iR.has(e) ? "polypeptide(L)" : nR.has(e) ? "polypeptide(D)" : sR.has(e) ? "polyribonucleotide" : oR.has(e) ? "polydeoxyribonucleotide" : uR.has(e) || Jd.has(t) ? "oligosaccharide" : Q9.has(t) ? "peptide nucleic acid" : cR.has(t) ? "polypeptide(L)" : lR.has(t) ? "polypeptide(D)" : Ny.has(t) ? "polyribonucleotide" : Ry.has(t) ? "polydeoxyribonucleotide" : $J.has(e) || h2.has(t) ? "ion" : e$.has(e) || rR.has(t) ? "lipid" : aR.has(e) ? "peptide-like" : "other";
}
function ex(t) {
  return Qp(t) || hR(t);
}
function Qp(t) {
  return t === 7 || t === 6 || t === 8;
}
function hR(t) {
  return t === 5;
}
(function(t) {
  t.is = Ga.has, t.create = Ga.create, t.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 }, t.SecondaryStructurePdb = { 1: 4162, 2: 16450, 3: 32834, 4: 8258, 5: 2114, 6: 4130, 7: 16418, 8: 8226, 9: 1026, 10: 65538 }, t.SecondaryStructureStride = { H: 4098, G: 2050, I: 32770, E: 8388612, B: 4194308, T: 16, C: 536870912 }, t.SecondaryStructureDssp = { H: 4098, B: 4194308, E: 8388612, G: 2050, I: 32770, T: 16, S: 8 };
})(_r || (_r = {})), function(t) {
  function e(r) {
    switch (r) {
      case "covalent":
        return 1;
      case "metal-coordination":
        return 2;
      case "hydrogen-bond":
        return 4;
      case "disulfide":
        return 8;
      case "aromatic":
        return 16;
      case "computed":
        return 32;
    }
  }
  t.is = Ga.has, t.create = function(r) {
    return Ga.create(r);
  }, t.isCovalent = function(r) {
    return !!(1 & r);
  }, t.isAll = function(r) {
    return r === Math.pow(2, 6) - 1;
  }, t.Names = { covalent: 1, "metal-coordination": 2, "hydrogen-bond": 4, disulfide: 8, aromatic: 16, computed: 32 }, t.isName = function(r) {
    return r in t.Names;
  }, t.fromName = e, t.fromNames = function(r) {
    for (var n = 0, i = 0, a = r.length; i < a; ++i) n |= e(r[i]);
    return n;
  };
}(lr || (lr = {}));
var X6 = { 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] }, _p = function() {
  function t() {
    this.count = 0, this.center = E(), this.radiusSq = 0;
  }
  return t.prototype.reset = function() {
    E.set(this.center, 0, 0, 0), this.radiusSq = 0, this.count = 0;
  }, t.prototype.includeStep = function(e) {
    E.add(this.center, this.center, e), this.count++;
  }, t.prototype.finishedIncludeStep = function() {
    this.count !== 0 && E.scale(this.center, this.center, 1 / this.count);
  }, t.prototype.radiusStep = function(e) {
    var r = E.squaredDistance(e, this.center);
    r > this.radiusSq && (this.radiusSq = r);
  }, t.prototype.radiusSphereStep = function(e, r) {
    var n = E.distance(e, this.center) + r, i = n * n;
    i > this.radiusSq && (this.radiusSq = i);
  }, t.prototype.getSphere = function(e) {
    return e || (e = Me()), E.copy(e.center, this.center), e.radius = Math.sqrt(this.radiusSq), e;
  }, t.prototype.getCount = function() {
    return this.count;
  }, t;
}();
(function(t) {
  var e = new t(), r = E(), n = E();
  t.fromArrays = function(i, a) {
    var o = i.x, s = i.y, u = i.z;
    e.reset();
    for (var c = o.length, l = 0; l < c; l++) E.set(r, o[l], s[l], u[l]), e.includeStep(r);
    for (e.finishedIncludeStep(), l = 0; l < c; l++) E.set(r, o[l], s[l], u[l]), e.radiusStep(r);
    return E.copy(a.center, e.center), a.radius = Math.sqrt(e.radiusSq), a;
  }, t.fromProvider = function(i, a, o) {
    e.reset();
    for (var s = 0; s < i; s++) a(s, r), e.includeStep(r);
    for (e.finishedIncludeStep(), s = 0; s < i; s++) a(s, r), e.radiusStep(r);
    return E.copy(o.center, e.center), o.radius = Math.sqrt(e.radiusSq), o;
  }, t.fromPairProvider = function(i, a, o) {
    e.reset();
    for (var s = 0; s < i; s++) a(s, r, n), e.includeStep(r), e.includeStep(n);
    for (e.finishedIncludeStep(), s = 0; s < i; s++) a(s, r, n), e.radiusStep(r), e.radiusStep(n);
    return E.copy(o.center, e.center), o.radius = Math.sqrt(e.radiusSq), o;
  };
})(_p || (_p = {}));
var C0 = function() {
  function t(e) {
    this.map = e;
    var r = 0, n = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
    this.map.forEach(function(o) {
      o.forEach(function(s) {
        r += s.edgeCount, s.connectedIndices.forEach(function(u) {
          s.getEdges(u).forEach(function(c) {
            var l = s.unitA, d = s.unitB, f = t.getEdgeKey(u, l, c.indexB, d);
            i.set(f, n.length);
            var h = t.getVertexKey(u, l), m = a.get(h);
            m === void 0 ? a.set(h, [n.length]) : m.push(n.length), n.push(O(O({}, c), { indexA: u, unitA: l, unitB: d }));
          });
        });
      });
    }), this.edgeCount = r, this.edges = n, this.edgeKeyIndex = i, this.vertexKeyIndex = a;
  }
  return t.prototype.getConnectedUnits = function(e) {
    return this.map.has(e) ? this.map.get(e) : mR;
  }, t.prototype.getEdgeIndex = function(e, r, n, i) {
    var a = t.getEdgeKey(e, r, n, i), o = this.edgeKeyIndex.get(a);
    return o !== void 0 ? o : -1;
  }, t.prototype.hasEdge = function(e, r, n, i) {
    return this.getEdgeIndex(e, r, n, i) !== -1;
  }, t.prototype.getEdge = function(e, r, n, i) {
    var a = this.getEdgeIndex(e, r, n, i);
    return a !== -1 ? this.edges[a] : void 0;
  }, t.prototype.getEdgeIndices = function(e, r) {
    return this.vertexKeyIndex.get(t.getVertexKey(e, r)) || [];
  }, t;
}();
(function(t) {
  var e = 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) : mR;
    }, Object.defineProperty(i.prototype, "areUnitsOrdered", { get: function() {
      return this.unitA < this.unitB;
    }, enumerable: !1, configurable: !0 }), i;
  }();
  function r(i, a, o) {
    i.has(a) ? i.get(a).push(o) : i.set(a, [o]);
  }
  t.UnitPairEdges = e, t.getEdgeKey = function(i, a, o, s) {
    return "".concat(i, "|").concat(a, "|").concat(o, "|").concat(s);
  }, t.getVertexKey = function(i, a) {
    return "".concat(i, "|").concat(a);
  };
  var n = 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 = bn.create(), this.linkedB = bn.create(), this.linkCount = 0;
    }, i.prototype.finishUnitPair = function() {
      this.linkCount !== 0 && (r(this.map, this.uA, new e(this.uA, this.uB, this.linkCount, this.linkedA.array, this.mapAB)), r(this.map, this.uB, new e(this.uB, this.uA, this.linkCount, this.linkedB.array, this.mapBA)));
    }, i.prototype.add = function(a, o, s) {
      r(this.mapAB, a, { indexB: o, props: s }), r(this.mapBA, o, { indexB: a, props: s }), bn.add(this.linkedA, a, a), bn.add(this.linkedB, o, o), this.linkCount += 1;
    }, i.prototype.getMap = function() {
      return this.map;
    }, i;
  }();
  t.Builder = n;
})(C0 || (C0 = {}));
var O_, mR = [];
(function(t) {
  t.Empty = Xo.create([], [], [], 0, { flags: [], order: [] });
})(O_ || (O_ = {}));
var P3 = function(t) {
  function e() {
    return t !== null && t.apply(this, arguments) || this;
  }
  return ka(e, t), e.prototype.getBondFromLocation = function(r) {
    return Fe.isAtomic(r.aUnit) && Fe.isAtomic(r.bUnit) ? this.getEdge(r.aIndex, r.aUnit.id, r.bIndex, r.bUnit.id) : void 0;
  }, e.prototype.getBondIndexFromLocation = function(r) {
    return Fe.isAtomic(r.aUnit) && Fe.isAtomic(r.bUnit) ? this.getEdgeIndex(r.aIndex, r.aUnit.id, r.bIndex, r.bUnit.id) : -1;
  }, e;
}(C0);
(function(t) {
  var e = function(r) {
    function n() {
      return r !== null && r.apply(this, arguments) || this;
    }
    return ka(n, r), n;
  }(C0.UnitPairEdges);
  t.UnitPairBonds = e;
})(P3 || (P3 = {}));
var gR = { forceCompute: !1, noCompute: !1, maxRadius: 4 }, Hm = { 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 }, o$ = { 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 }, vR = { 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 }, yR = { 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 }, CD = 2.001, B3 = function() {
  for (var t = /* @__PURE__ */ new Set(), e = 0, r = ["LI", "NA", "K", "RB", "CS", "FR", "BE", "MG", "CA", "SR", "BA", "RA", "AL", "GA", "IN", "SN", "TL", "PB", "BI", "SC", "TI", "V", "CR", "MN", "FE", "CO", "NI", "CU", "ZN", "Y", "ZR", "NB", "MO", "TC", "RU", "RH", "PD", "AG", "CD", "LA", "HF", "TA", "W", "RE", "OS", "IR", "PT", "AU", "HG", "AC", "RF", "DB", "SG", "BH", "HS", "MT", "CE", "PR", "ND", "PM", "SM", "EU", "GD", "TB", "DY", "HO", "ER", "TM", "YB", "LU", "TH", "PA", "U", "NP", "PU", "AM", "CM", "BK", "CF", "ES", "FM", "MD", "NO", "LR"]; e < r.length; e++) {
    var n = r[e];
    t.add(Hm[n]);
  }
  return t;
}();
function bR(t, e) {
  return t < e ? (t + e) * (t + e + 1) / 2 + e : (t + e) * (t + e + 1) / 2 + t;
}
function Vd(t) {
  var e = Hm[t];
  return e === void 0 ? -1 : e;
}
function tp(t) {
  if (t < 0) return CD;
  var e = o$[t];
  return e === void 0 ? CD : e;
}
function L_(t, e, r, n, i) {
  var a = function(o, s, u) {
    if (o < 0 || s < 0) return -1;
    var c = (u ? yR : vR)[bR(o, s)];
    return c === void 0 ? -1 : c;
  }(t, e, i);
  return a > 0 ? a : e < 0 ? r : (r + n) / 1.95;
}
var s$ = Hm.H;
function Ud(t) {
  return t === s$;
}
var u$ = /* @__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 c$(t, e, r) {
  var n;
  return e = (n = e < r ? [e, r] : [r, e])[0], r = n[1], m2.has(t) && e === "C" && r === "O" || J9.has(t) && e === "OP1" && r === "P" ? 2 : u$.get("".concat(t, "|").concat(e, "|").concat(r)) || 1;
}
var l$ = /* @__PURE__ */ new Map([["LYS|NZ|RET|C15", 2]]);
function _R(t, e, r, n) {
  var i, a;
  return t > r && (t = (i = [r, t])[0], r = i[1], e = (a = [n, e])[0], n = a[1]), l$.get("".concat(t, "|").concat(e, "|").concat(r, "|").concat(n)) || 1;
}
var pf = se.Schema, Z = pf.str, be = pf.int, Kt = pf.float, Y6 = pf.coord, mt = pf.Aliased, cd = pf.Matrix, zg = pf.Vector, Ff = pf.List, rr = { atom_site: { auth_asym_id: Z, auth_atom_id: Z, auth_comp_id: Z, auth_seq_id: be, B_iso_or_equiv: Kt, Cartn_x: Y6, Cartn_y: Y6, Cartn_z: Y6, group_PDB: mt(Z), id: be, label_alt_id: Z, label_asym_id: Z, label_atom_id: Z, label_comp_id: Z, label_entity_id: Z, label_seq_id: be, occupancy: Kt, type_symbol: Z, pdbx_PDB_ins_code: Z, pdbx_PDB_model_num: be, pdbx_formal_charge: be, pdbx_label_index: be, 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: be, cdr: be, em_confidence: Z }, atom_site_anisotrop: { id: be, type_symbol: Z, U: cd(3, 3), U_esd: cd(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: be, 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: cd(3, 3), fract_transf_vector: zg(3) }, audit_author: { name: Z, pdbx_ordinal: be, identifier_ORCID: Z }, audit_conform: { dict_location: Z, dict_name: Z, dict_version: Z }, cell: { angle_alpha: Kt, angle_beta: Kt, angle_gamma: Kt, entry_id: Z, length_a: Kt, length_b: Kt, length_c: Kt, Z_PDB: be, pdbx_unique_axis: Z }, chem_comp: { formula: Z, formula_weight: Kt, id: Z, mon_nstd_flag: mt(Z), name: Z, type: mt(Z), pdbx_synonyms: Ff(";", function(t) {
  return t;
}) }, chem_comp_bond: { atom_id_1: Z, atom_id_2: Z, comp_id: Z, value_order: mt(Z), pdbx_ordinal: be, pdbx_stereo_config: mt(Z), pdbx_aromatic_flag: mt(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: be, pdbx_database_id_DOI: Z, pdbx_database_id_PubMed: be }, citation_author: { citation_id: Z, name: Z, ordinal: be }, database_2: { database_id: mt(Z), database_code: Z }, entity: { details: Z, formula_weight: Kt, id: Z, src_method: mt(Z), type: mt(Z), pdbx_description: Ff(",", function(t) {
  return t;
}), pdbx_number_of_molecules: be, pdbx_mutation: Z, pdbx_fragment: Z, pdbx_ec: Ff(",", function(t) {
  return t;
}) }, entity_poly: { entity_id: Z, nstd_linkage: mt(Z), nstd_monomer: mt(Z), type: mt(Z), pdbx_strand_id: Ff(",", function(t) {
  return t;
}), pdbx_seq_one_letter_code: Z, pdbx_seq_one_letter_code_can: Z, pdbx_target_identifier: Z }, entity_poly_seq: { entity_id: Z, hetero: mt(Z), mon_id: Z, num: be }, entry: { id: Z }, exptl: { entry_id: Z, method: mt(Z) }, software: { classification: Z, date: Z, description: Z, name: Z, type: mt(Z), version: Z, pdbx_ordinal: be }, 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: mt(Z) }, struct_conf: { beg_label_asym_id: Z, beg_label_comp_id: Z, beg_label_seq_id: be, beg_auth_asym_id: Z, beg_auth_comp_id: Z, beg_auth_seq_id: be, conf_type_id: mt(Z), details: Z, end_label_asym_id: Z, end_label_comp_id: Z, end_label_seq_id: be, end_auth_asym_id: Z, end_auth_comp_id: Z, end_auth_seq_id: be, id: Z, pdbx_beg_PDB_ins_code: Z, pdbx_end_PDB_ins_code: Z, pdbx_PDB_helix_class: Z, pdbx_PDB_helix_length: be, pdbx_PDB_helix_id: Z }, struct_conn: { conn_type_id: mt(Z), details: Z, id: Z, ptnr1_label_asym_id: Z, ptnr1_label_atom_id: Z, ptnr1_label_comp_id: Z, ptnr1_label_seq_id: be, ptnr1_auth_asym_id: Z, ptnr1_auth_comp_id: Z, ptnr1_auth_seq_id: be, ptnr1_symmetry: Z, ptnr2_label_asym_id: Z, ptnr2_label_atom_id: Z, ptnr2_label_comp_id: Z, ptnr2_label_seq_id: be, ptnr2_auth_asym_id: Z, ptnr2_auth_comp_id: Z, ptnr2_auth_seq_id: be, 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: be, pdbx_PDB_id: Z, pdbx_dist_value: Kt, pdbx_value_order: mt(Z) }, struct_conn_type: { criteria: Z, id: mt(Z), reference: Z }, struct_keywords: { entry_id: Z, text: Ff(",", function(t) {
  return t;
}), pdbx_keywords: Z }, struct_ncs_oper: { code: mt(Z), details: Z, id: be, matrix: cd(3, 3), vector: zg(3) }, struct_sheet_range: { beg_label_asym_id: Z, beg_label_comp_id: Z, beg_label_seq_id: be, end_label_asym_id: Z, end_label_comp_id: Z, end_label_seq_id: be, beg_auth_asym_id: Z, beg_auth_comp_id: Z, beg_auth_seq_id: be, end_auth_asym_id: Z, end_auth_comp_id: Z, end_auth_seq_id: be, 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: be, 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: be, 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: be }, symmetry: { entry_id: Z, cell_setting: mt(Z), Int_Tables_number: be, space_group_name_Hall: Z, "space_group_name_H-M": Z }, pdbx_database_status: { status_code: mt(Z), status_code_sf: mt(Z), status_code_mr: mt(Z), entry_id: Z, recvd_initial_deposition_date: Z, SG_entry: mt(Z), deposit_site: mt(Z), process_site: mt(Z), status_code_cs: mt(Z), methods_development_category: mt(Z), pdb_format_compatible: mt(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: mt(Z) }, pdbx_entity_nonpoly: { entity_id: Z, comp_id: Z, name: Z }, pdbx_chem_comp_synonyms: { name: Z, comp_id: Z, provenance: mt(Z) }, pdbx_chem_comp_identifier: { comp_id: Z, identifier: Z, type: mt(Z), program: Z, program_version: Z }, pdbx_unobs_or_zero_occ_residues: { id: be, polymer_flag: mt(Z), occupancy_flag: mt(be), PDB_model_num: be, 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: be }, pdbx_struct_mod_residue: { id: be, auth_asym_id: Z, auth_comp_id: Z, auth_seq_id: be, PDB_ins_code: Z, label_asym_id: Z, label_comp_id: Z, label_seq_id: be, parent_comp_id: Z, details: Z }, pdbx_struct_oper_list: { id: Z, type: mt(Z), name: Z, symmetry_operation: Z, matrix: cd(3, 3), vector: zg(3) }, pdbx_struct_assembly: { method_details: Z, oligomeric_details: Z, oligomeric_count: be, details: Z, id: Z }, pdbx_struct_assembly_gen: { asym_id_list: Ff(",", function(t) {
  return t;
}), assembly_id: Z, oper_expression: Z }, pdbx_reference_entity_list: { prd_id: Z, ref_entity_id: Z, type: mt(Z), details: Z, component_id: be }, pdbx_reference_entity_link: { link_id: be, prd_id: Z, details: Z, ref_entity_id_1: Z, ref_entity_id_2: Z, entity_seq_num_1: be, entity_seq_num_2: be, comp_id_1: Z, comp_id_2: Z, atom_id_1: Z, atom_id_2: Z, value_order: mt(Z), component_1: be, component_2: be, link_class: mt(Z) }, pdbx_reference_entity_poly_link: { link_id: be, prd_id: Z, ref_entity_id: Z, component_id: be, entity_seq_num_1: be, entity_seq_num_2: be, comp_id_1: Z, comp_id_2: Z, atom_id_1: Z, atom_id_2: Z, value_order: mt(Z) }, pdbx_molecule: { prd_id: Z, instance_id: be, asym_id: Z }, pdbx_molecule_features: { prd_id: Z, class: mt(Z), type: mt(Z), name: Z, details: Z }, entity_src_nat: { entity_id: Z, pdbx_organism_scientific: Z, pdbx_plasmid_name: Z, pdbx_src_id: be, pdbx_beg_seq_num: be, pdbx_end_seq_num: be }, entity_src_gen: { entity_id: Z, pdbx_gene_src_gene: Ff(",", function(t) {
  return t;
}), pdbx_gene_src_scientific_name: Z, plasmid_name: Z, pdbx_src_id: be, pdbx_beg_seq_num: be, pdbx_end_seq_num: be }, pdbx_entity_src_syn: { organism_scientific: Z, entity_id: Z, pdbx_src_id: be, pdbx_beg_seq_num: be, pdbx_end_seq_num: be }, pdbx_entity_branch_descriptor: { entity_id: Z, descriptor: Z, type: mt(Z), program: Z, program_version: Z, ordinal: be }, pdbx_entity_instance_feature: { details: Z, feature_type: mt(Z), auth_asym_id: Z, asym_id: Z, auth_seq_num: Z, seq_num: be, comp_id: Z, auth_comp_id: Z, ordinal: be }, pdbx_entity_branch_list: { entity_id: Z, hetero: mt(Z), comp_id: Z, num: be }, pdbx_entity_branch_link: { link_id: be, details: Z, entity_id: Z, entity_branch_list_num_1: be, entity_branch_list_num_2: be, comp_id_1: Z, comp_id_2: Z, atom_id_1: Z, leaving_atom_id_1: Z, atom_stereo_config_1: mt(Z), atom_id_2: Z, leaving_atom_id_2: Z, atom_stereo_config_2: mt(Z), value_order: mt(Z) }, pdbx_entity_branch: { entity_id: Z, type: mt(Z) }, pdbx_branch_scheme: { entity_id: Z, hetero: mt(Z), asym_id: Z, mon_id: Z, num: be, 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: mt(Z), details: Z }, ihm_starting_model_details: { starting_model_id: Z, entity_id: Z, entity_description: Z, asym_id: Z, entity_poly_segment_id: be, starting_model_source: mt(Z), starting_model_auth_asym_id: Z, starting_model_sequence_offset: be, dataset_list_id: be }, ihm_starting_comparative_models: { id: be, starting_model_id: Z, starting_model_auth_asym_id: Z, starting_model_seq_id_begin: be, starting_model_seq_id_end: be, template_auth_asym_id: Z, template_seq_id_begin: be, template_seq_id_end: be, template_sequence_identity: Kt, template_sequence_identity_denominator: mt(be), template_dataset_list_id: be, alignment_file_id: be }, ihm_starting_model_seq_dif: { id: be, entity_id: Z, asym_id: Z, seq_id: be, comp_id: Z, starting_model_id: Z, db_asym_id: Z, db_seq_id: be, db_comp_id: Z, details: Z }, ihm_model_representation: { id: be, name: Z, details: Z }, ihm_model_representation_details: { id: be, representation_id: be, entity_poly_segment_id: be, entity_id: Z, entity_description: Z, entity_asym_id: Z, model_object_primitive: mt(Z), starting_model_id: Z, model_mode: mt(Z), model_granularity: mt(Z), model_object_count: be }, ihm_struct_assembly_details: { id: be, assembly_id: be, parent_assembly_id: be, entity_description: Z, entity_id: Z, asym_id: Z, entity_poly_segment_id: be }, ihm_struct_assembly: { id: be, name: Z, description: Z }, ihm_modeling_protocol: { id: be, num_steps: be, protocol_name: Z }, ihm_modeling_protocol_details: { id: be, protocol_id: be, step_id: be, struct_assembly_id: be, dataset_group_id: be, struct_assembly_description: Z, step_name: Z, step_method: Z, num_models_begin: be, num_models_end: be, multi_scale_flag: mt(Z), multi_state_flag: mt(Z), ordered_flag: mt(Z), script_file_id: be, software_id: be }, ihm_multi_state_modeling: { state_id: be, state_group_id: be, population_fraction: Kt, population_fraction_sd: Kt, state_type: Z, state_name: Z, experiment_type: mt(Z), details: Z }, ihm_modeling_post_process: { id: be, protocol_id: be, analysis_id: be, step_id: be, type: mt(Z), feature: mt(Z), num_models_begin: be, num_models_end: be }, ihm_ensemble_info: { ensemble_id: be, ensemble_name: Z, post_process_id: be, model_group_id: be, ensemble_clustering_method: mt(Z), ensemble_clustering_feature: mt(Z), num_ensemble_models: be, num_ensemble_models_deposited: be, ensemble_precision_value: Kt, ensemble_file_id: be }, ihm_model_list: { model_id: be, model_name: Z, assembly_id: be, protocol_id: be, representation_id: be }, ihm_model_group: { id: be, name: Z, details: Z }, ihm_model_group_link: { model_id: be, group_id: be }, ihm_model_representative: { id: be, model_group_id: be, model_id: be, selection_criteria: mt(Z) }, ihm_dataset_list: { id: be, data_type: mt(Z), database_hosted: mt(Z) }, ihm_dataset_group: { id: be, name: Z, application: mt(Z), details: Z }, ihm_dataset_group_link: { dataset_list_id: be, group_id: be }, ihm_related_datasets: { dataset_list_id_derived: be, dataset_list_id_primary: be }, ihm_dataset_related_db_reference: { id: be, dataset_list_id: be, db_name: mt(Z), accession_code: Z, version: Z, details: Z }, ihm_external_reference_info: { reference_id: be, reference_provider: Z, reference_type: mt(Z), reference: Z, refers_to: mt(Z), associated_url: Z }, ihm_external_files: { id: be, reference_id: be, file_path: Z, content_type: mt(Z), file_size_bytes: Kt, details: Z }, ihm_dataset_external_reference: { id: be, dataset_list_id: be, file_id: be }, ihm_localization_density_files: { id: be, file_id: be, ensemble_id: be, entity_id: Z, entity_poly_segment_id: be, asym_id: Z }, ihm_predicted_contact_restraint: { id: be, group_id: be, 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: be, seq_id_2: be, rep_atom_1: mt(Z), rep_atom_2: mt(Z), distance_lower_limit: Kt, distance_upper_limit: Kt, probability: Kt, restraint_type: mt(Z), model_granularity: mt(Z), dataset_list_id: be, software_id: be }, ihm_cross_link_list: { id: be, group_id: be, 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: be, seq_id_2: be, linker_type: mt(Z), dataset_list_id: be }, ihm_cross_link_restraint: { id: be, group_id: be, 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: be, seq_id_2: be, atom_id_1: Z, atom_id_2: Z, restraint_type: mt(Z), conditional_crosslink_flag: mt(Z), model_granularity: mt(Z), distance_threshold: Kt, psi: Kt, sigma_1: Kt, sigma_2: Kt }, ihm_cross_link_result_parameters: { id: be, restraint_id: be, model_id: be, psi: Kt, sigma_1: Kt, sigma_2: Kt }, ihm_2dem_class_average_restraint: { id: be, dataset_list_id: be, number_raw_micrographs: be, pixel_size_width: Kt, pixel_size_height: Kt, image_resolution: Kt, image_segment_flag: mt(Z), number_of_projections: be, struct_assembly_id: be, details: Z }, ihm_2dem_class_average_fitting: { id: be, restraint_id: be, model_id: be, cross_correlation_coefficient: Kt, rot_matrix: cd(3, 3), tr_vector: zg(3) }, ihm_3dem_restraint: { id: be, dataset_list_id: be, model_id: be, struct_assembly_id: be, fitting_method: Z, number_of_gaussians: be, cross_correlation_coefficient: Kt }, ihm_sas_restraint: { id: be, dataset_list_id: be, model_id: be, struct_assembly_id: be, profile_segment_flag: mt(Z), fitting_atom_type: Z, fitting_method: Z, fitting_state: mt(Z), radius_of_gyration: Kt, chi_value: Kt, details: Z }, ihm_starting_model_coord: { ordinal_id: be, starting_model_id: Z, group_PDB: mt(Z), id: be, type_symbol: Z, entity_id: Z, atom_id: Z, comp_id: Z, seq_id: be, asym_id: Z, Cartn_x: Kt, Cartn_y: Kt, Cartn_z: Kt, B_iso_or_equiv: Kt }, ihm_sphere_obj_site: { id: be, entity_id: Z, seq_id_begin: be, seq_id_end: be, asym_id: Z, Cartn_x: Kt, Cartn_y: Kt, Cartn_z: Kt, object_radius: Kt, rmsf: Kt, model_id: be }, ihm_gaussian_obj_site: { id: be, entity_id: Z, seq_id_begin: be, seq_id_end: be, asym_id: Z, mean_Cartn_x: Kt, mean_Cartn_y: Kt, mean_Cartn_z: Kt, weight: Kt, covariance_matrix: cd(3, 3), model_id: be }, ihm_gaussian_obj_ensemble: { id: be, entity_id: Z, seq_id_begin: be, seq_id_end: be, asym_id: Z, mean_Cartn_x: Kt, mean_Cartn_y: Kt, mean_Cartn_z: Kt, weight: Kt, covariance_matrix: cd(3, 3), ensemble_id: be }, ihm_feature_list: { feature_id: be, feature_type: mt(Z), entity_type: mt(Z) }, ihm_poly_residue_feature: { ordinal_id: be, feature_id: be, entity_id: Z, asym_id: Z, comp_id_begin: Z, comp_id_end: Z, seq_id_begin: be, seq_id_end: be }, ihm_derived_distance_restraint: { id: be, group_id: be, feature_id_1: be, feature_id_2: be, group_conditionality: mt(Z), random_exclusion_fraction: Kt, distance_upper_limit: Kt, restraint_type: mt(Z), dataset_list_id: be }, ma_model_list: { ordinal_id: be, model_id: be, model_group_id: be, model_name: Z, model_group_name: Z, model_type: mt(Z), data_id: be }, ma_target_entity: { entity_id: Z, data_id: be, origin: mt(Z) }, ma_target_entity_instance: { asym_id: Z, entity_id: Z, details: Z }, ma_target_ref_db_details: { target_entity_id: Z, db_name: mt(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: be, content_type: mt(Z), content_type_other_details: Z, name: Z }, ma_software_group: { ordinal_id: be, group_id: be, software_id: be }, ma_qa_metric: { id: be, name: Z, type: mt(Z), mode: mt(Z), software_group_id: be }, ma_qa_metric_global: { ordinal_id: be, model_id: be, metric_id: be, metric_value: Kt }, ma_qa_metric_local: { ordinal_id: be, model_id: be, label_asym_id: Z, label_seq_id: be, label_comp_id: Z, metric_id: be, metric_value: Kt } }, d$ = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330;
function F3(t) {
  for (var e = t.data, r = t.encoding.length - 1; r >= 0; r--) e = f$(e, t.encoding[r]);
  return e;
}
function f$(t, e) {
  switch (e.kind) {
    case "ByteArray":
      switch (e.type) {
        case 4:
          return t;
        case 1:
          return function(r) {
            return new Int8Array(r.buffer, r.byteOffset);
          }(t);
        case 2:
          return function(r) {
            return b1(r, 2, Int16Array);
          }(t);
        case 5:
          return function(r) {
            return b1(r, 2, Uint16Array);
          }(t);
        case 3:
          return function(r) {
            return b1(r, 4, Int32Array);
          }(t);
        case 6:
          return function(r) {
            return b1(r, 4, Uint32Array);
          }(t);
        case 32:
          return function(r) {
            return b1(r, 4, Float32Array);
          }(t);
        case 33:
          return function(r) {
            return b1(r, 8, Float64Array);
          }(t);
        default:
          ca(e.type);
      }
    case "FixedPoint":
      return function(r, n) {
        for (var i = r.length, a = wD(n.srcType, i), o = 1 / n.factor, s = 0; s < i; s++) a[s] = o * r[s];
        return a;
      }(t, e);
    case "IntervalQuantization":
      return function(r, n) {
        for (var i = r.length, a = wD(n.srcType, i), o = (n.max - n.min) / (n.numSteps - 1), s = n.min, u = 0; u < i; u++) a[u] = s + o * r[u];
        return a;
      }(t, e);
    case "RunLength":
      return function(r, n) {
        for (var i = AD(n.srcType, n.srcSize), a = 0, o = 0, s = r.length; o < s; o += 2) for (var u = r[o], c = r[o + 1], l = 0; l < c; ++l) i[a++] = u;
        return i;
      }(t, e);
    case "Delta":
      return function(r, n) {
        var i = r.length, a = AD(n.srcType, i);
        if (!i) return r;
        a[0] = r[0] + (0 | n.origin);
        for (var o = 1; o < i; ++o) a[o] = r[o] + a[o - 1];
        return a;
      }(t, e);
    case "IntegerPacking":
      return function(r, n) {
        return r.length === n.srcSize ? r : n.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, f = i[c]; f === o; ) d += f, f = i[++c];
            d += f, u[l] = d, c++, l++;
          }
          return u;
        }(r, n) : 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 f = 0, h = i[l]; h === o || h === s; ) f += h, h = i[++l];
            f += h, c[d] = f, l++, d++;
          }
          return c;
        }(r, n);
      }(t, e);
    case "StringArray":
      return function(r, n) {
        var i = F3({ encoding: n.offsetEncoding, data: n.offsets }), a = F3({ encoding: n.dataEncoding, data: r }), o = n.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;
      }(t, e);
  }
}
function AD(t, e) {
  switch (t) {
    case 1:
      return new Int8Array(e);
    case 2:
      return new Int16Array(e);
    case 3:
      return new Int32Array(e);
    case 4:
      return new Uint8Array(e);
    case 5:
      return new Uint16Array(e);
    case 6:
      return new Uint32Array(e);
    default:
      ca();
  }
}
function wD(t, e) {
  switch (t) {
    case 32:
      return new Float32Array(e);
    case 33:
      return new Float64Array(e);
    default:
      ca();
  }
}
function b1(t, e, r) {
  return new r(d$ ? t.buffer : function(n, i) {
    for (var a = new ArrayBuffer(n.length), o = new Uint8Array(a), s = 0, u = n.length; s < u; s += i) for (var c = 0; c < i; c++) o[s + i - c - 1] = n[s + c];
    return a;
  }(t, e));
}
var Id, fm, k_;
function p$(t, e, r) {
  var n, i = 1;
  for (n = 0; n < e; n++) {
    var a = i * t;
    if (Math.abs(Math.round(a) - a) <= r) return n;
    i *= 10;
  }
  return -1;
}
function DD(t, e) {
  return parseFloat(t.toPrecision(e));
}
function G_(t) {
  return fm.classify(t);
}
(function(t) {
  t.getDataType = function(e) {
    return e instanceof Int8Array ? 1 : e instanceof Int16Array ? 2 : e instanceof Int32Array ? 3 : e instanceof Uint8Array ? 4 : e instanceof Uint16Array ? 5 : e instanceof Uint32Array ? 6 : e instanceof Float32Array ? 32 : e instanceof Float64Array ? 33 : 3;
  }, t.isSignedIntegerDataType = function(e) {
    if (e instanceof Int8Array || e instanceof Int16Array || e instanceof Int32Array) return !0;
    for (var r = 0, n = e.length; r < n; r++) if (r < 0) return !1;
    return !0;
  };
})(Id || (Id = {})), function(t) {
  function e(l, d) {
    return l >= 0 ? Math.ceil((l + 1) / d) : Math.ceil((l + 1) / (-d - 1));
  }
  function r(l, d, f) {
    var h = l.limit8, m = l.limit16;
    d.pack8 += e(f, h), d.pack16 += e(f, m), d.count += 1;
  }
  function n(l, d) {
    l.pack8 += e(d, 127), l.pack16 += e(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 f = { pack8: 0, pack16: 0, count: 0 }, h = 0, m = l.length; h < m; h++) r(d, f, l[h]);
    return O(O({}, i(f)), { kind: "pack" });
  }
  function o(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, h = l[0], m = 1, p = l.length; m < p; m++) n(f, l[m] - h), h = l[m];
    return O(O({}, i(f)), { kind: "delta" });
  }
  function s(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, h = 1, m = 1, p = l.length; m < p; m++) l[m - 1] !== l[m] ? (r(d, f, l[m - 1]), r(d, f, h), h = 1) : h++;
    return r(d, f, l[l.length - 1]), r(d, f, h), O(O({}, i(f)), { kind: "rle" });
  }
  function u(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, h = 1, m = 0, p = 0, v = 1, g = l.length; v < g; v++) {
      var y = l[v] - m;
      p !== y ? (n(f, p), n(f, h), h = 1) : h++, p = y, m = l[v];
    }
    return n(f, p), n(f, h), O(O({}, i(f)), { kind: "delta-rle" });
  }
  function c(l) {
    var d = function(h) {
      for (var m = !1, p = 0, v = h.length; p < v; p++) if (h[p] < 0) {
        m = !0;
        break;
      }
      return m ? { signed: m, limit8: 127, limit16: 32767 } : { signed: m, limit8: 255, limit16: 65535 };
    }(l), f = [a(l, d), s(l, d), o(l), u(l)];
    return f.sort(function(h, m) {
      return h.length - m.length;
    }), f;
  }
  t.getSize = c, t.classify = function(l) {
    if (l.length < 2) return cr.by(cr.byteArray);
    switch (c(l)[0].kind) {
      case "pack":
        return cr.by(cr.integerPacking);
      case "rle":
        return cr.by(cr.runLength).and(cr.integerPacking);
      case "delta":
        return cr.by(cr.delta).and(cr.integerPacking);
      case "delta-rle":
        return cr.by(cr.delta).and(cr.runLength).and(cr.integerPacking);
      default:
        ca();
    }
  };
}(fm || (fm = {})), function(t) {
  t.classify = function(e) {
    var r = function(d, f, h) {
      for (var m = 1, p = 0, v = 0, g = d.length; v < g; v++) {
        if (m >= 0) {
          var y = p$(d[v], f, h);
          y < 0 ? m = -1 : y > m && (m = y);
        }
        var b = Math.abs(d[v]);
        if (b > h) {
          var S = Math.floor(Math.log10(Math.abs(b))) + 1;
          S > p && (p = S);
        }
      }
      return { mantissaDigits: m, integerDigits: p };
    }(e, 4, 1e-6), n = r.mantissaDigits, i = r.integerDigits;
    if (n < 0 || n + i > 10) return cr.by(cr.byteArray);
    if (n === 0) return fm.classify(e);
    for (var a = function(d) {
      for (var f = 1, h = 0; h < d; h++) f *= 10;
      return f;
    }(n), o = new Int32Array(e.length), s = 0, u = e.length; s < u; s++) o[s] = Math.round(a * e[s]);
    var c = fm.getSize(o)[0], l = cr.by(cr.fixedPoint(a));
    switch (c.kind) {
      case "pack":
        return l.and(cr.integerPacking);
      case "rle":
        return l.and(cr.runLength).and(cr.integerPacking);
      case "delta":
        return l.and(cr.delta).and(cr.integerPacking);
      case "delta-rle":
        return l.and(cr.delta).and(cr.runLength).and(cr.integerPacking);
      default:
        ca();
    }
  };
}(k_ || (k_ = {}));
var Hd, cr, z_, fs, V_, ED = function() {
  function t(e) {
    this.providers = e;
  }
  return t.prototype.and = function(e) {
    return new t(this.providers.concat([e]));
  }, t.prototype.encode = function(e) {
    for (var r = [], n = 0, i = this.providers; n < i.length; n++) {
      var a = (0, i[n])(e);
      if (!a.encodings.length) throw new Error("Encodings must be non-empty.");
      e = a.data;
      for (var o = 0, s = a.encodings; o < s.length; o++) {
        var u = s[o];
        r.push(u);
      }
    }
    if (!(e instanceof Uint8Array)) throw new Error("The encoding must result in a Uint8Array. Fix your encoding chain.");
    return { encoding: r, data: e };
  }, t;
}();
function W6(t) {
  return function(e, r) {
    return r[t].value(e);
  };
}
function h$(t) {
  return function(e, r) {
    return r[t].value(e).join(r[t].schema.separator);
  };
}
function j6(t) {
  for (var e = [], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r];
  return function(n, i) {
    var a;
    return (a = i[t].schema.space).get.apply(a, Ze([i[t].value(n)], e, !1));
  };
}
function pm(t) {
  return function(e, r) {
    return r[t].valueKind(e);
  };
}
function m$(t, e) {
  var r = [], n = pm(t);
  if (e.rank === 1) for (var i = e.dimensions[0], a = 0; a < i; a++) {
    var o = "".concat(t, "[").concat(a + 1, "]");
    r.push({ name: o, type: 2, value: j6(t, a), valueKind: n });
  }
  else if (e.rank === 2) {
    i = e.dimensions[0];
    var s = e.dimensions[1];
    for (a = 0; a < i; a++) for (var u = 0; u < s; u++) {
      var c = "".concat(t, "[").concat(a + 1, "][").concat(u + 1, "]");
      r.push({ name: c, type: 2, value: j6(t, a, u), valueKind: n });
    }
  } else {
    if (e.rank !== 3) throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    var l = e.dimensions[0], d = e.dimensions[1], f = e.dimensions[2];
    for (a = 0; a < l; a++) for (u = 0; u < d; u++) for (var h = 0; h < f; h++) {
      var m = "".concat(t, "[").concat(a + 1, "][").concat(u + 1, "][").concat(h + 1, "]");
      r.push({ name: m, type: 2, value: j6(t, a, u, h), valueKind: n });
    }
  }
  return r;
}
function ID(t) {
  for (var e = [], r = 0, n = Object.keys(t); r < n.length; r++) {
    var i = n[r], a = t[i];
    a.valueType === "int" ? e.push({ name: i, type: 1, value: W6(i), valueKind: pm(i) }) : a.valueType === "float" ? e.push({ name: i, type: 2, value: W6(i), valueKind: pm(i) }) : a.valueType === "str" ? e.push({ name: i, type: 0, value: W6(i), valueKind: pm(i) }) : a.valueType === "list" ? e.push({ name: i, type: 0, value: h$(i), valueKind: pm(i) }) : a.valueType === "tensor" ? e.push.apply(e, m$(i, a.space)) : ca(a.valueType);
  }
  return e;
}
function U_(t) {
  return t.fields.some(function(e) {
    return !!e.shouldInclude;
  }) ? t.fields.filter(function(e) {
    return !e.shouldInclude || t.source.some(function(r) {
      return e.shouldInclude(r.data);
    });
  }) : t.fields;
}
function xR(t, e) {
  var r = t.instance(e), n = r.source.filter(function(o) {
    return o.rowCount > 0;
  });
  if (!n.length) return { instance: r, rowCount: 0, source: [] };
  var i = n.reduce(function(o, s) {
    return o + s.rowCount;
  }, 0), a = n.map(function(o) {
    return { data: o.data, keys: function() {
      return o.keys ? o.keys() : A3.Range(0, o.rowCount - 1);
    }, rowCount: o.rowCount };
  });
  return { instance: r, rowCount: i, source: a };
}
(function(t) {
  function e(n) {
    return new ED([n]);
  }
  function r(n) {
    switch (n.kind) {
      case "ByteArray":
        return cr.byteArray;
      case "FixedPoint":
        return cr.fixedPoint(n.factor);
      case "IntervalQuantization":
        return cr.intervalQuantizaiton(n.min, n.max, n.numSteps);
      case "RunLength":
        return cr.runLength;
      case "Delta":
        return cr.delta;
      case "IntegerPacking":
        return cr.integerPacking;
      case "StringArray":
        return cr.stringArray;
    }
  }
  t.by = e, t.fromEncoding = function(n) {
    for (var i = e(r(n[0])), a = 1; a < n.length; a++) i = i.and(r(n[a]));
    return i;
  };
})(Hd || (Hd = {})), function(t) {
  var e, r;
  t.by = function(s) {
    return new ED([s]);
  };
  var n = ((e = {})[2] = function(s, u, c) {
    s.setInt16(2 * u, c, !0);
  }, e[5] = function(s, u, c) {
    s.setUint16(2 * u, c, !0);
  }, e[3] = function(s, u, c) {
    s.setInt32(4 * u, c, !0);
  }, e[6] = function(s, u, c) {
    s.setUint32(4 * u, c, !0);
  }, e[32] = function(s, u, c) {
    s.setFloat32(4 * u, c, !0);
  }, e[33] = function(s, u, c) {
    s.setFloat64(8 * u, c, !0);
  }, e), i = ((r = {})[2] = 2, r[5] = 2, r[3] = 4, r[6] = 4, r[32] = 4, r[33] = 8, r);
  function a(s) {
    var u = Id.getDataType(s);
    if (u === 1) return function(m) {
      return { encodings: [{ kind: "ByteArray", type: 1 }], data: new Uint8Array(m.buffer, m.byteOffset) };
    }(s);
    if (u === 4) return /* @__PURE__ */ function(m) {
      return { encodings: [{ kind: "ByteArray", type: 4 }], data: m };
    }(s);
    for (var c = new Uint8Array(s.length * i[u]), l = n[u], d = new DataView(c.buffer), f = 0, h = s.length; f < h; f++) l(d, f, s[f]);
    return { encodings: [{ kind: "ByteArray", type: u }], data: c };
  }
  function o(s, u) {
    for (var c = -u - 1, l = 0, d = 0, f = s.length; d < f; d++) {
      var h = s[d];
      h === 0 ? l += 1 : h > 0 ? (l += Math.ceil(h / u), h % u == 0 && (l += 1)) : (l += Math.ceil(h / c), h % c == 0 && (l += 1));
    }
    return l;
  }
  t.byteArray = a, t.fixedPoint = function(s) {
    return function(u) {
      return function(c, l) {
        for (var d = Id.getDataType(c), f = new Int32Array(c.length), h = 0, m = c.length; h < m; h++) f[h] = Math.round(c[h] * l);
        return { encodings: [{ kind: "FixedPoint", factor: l, srcType: d }], data: f };
      }(u, s);
    };
  }, t.intervalQuantizaiton = function(s, u, c, l) {
    return l === void 0 && (l = Int32Array), function(d) {
      return function(f, h, m, p, v) {
        var g = Id.getDataType(f);
        if (!f.length) return { encodings: [{ kind: "IntervalQuantization", min: h, max: m, numSteps: p, srcType: g }], data: new Int32Array(0) };
        if (m < h) {
          var y = h;
          h = m, m = y;
        }
        for (var b = (m - h) / (p - 1), S = new v(f.length), _ = 0, x = f.length; _ < x; _++) {
          var C = f[_];
          S[_] = C <= h ? 0 : C >= m ? p - 1 : 0 | Math.round((C - h) / b);
        }
        return { encodings: [{ kind: "IntervalQuantization", min: h, max: m, numSteps: p, srcType: g }], data: S };
      }(d, s, u, c, l);
    };
  }, t.runLength = function(s) {
    var u = Id.getDataType(s);
    if (u === void 0 && (s = new Int32Array(s), u = 3), !s.length) return { encodings: [{ kind: "RunLength", srcType: u, srcSize: 0 }], data: new Int32Array(0) };
    for (var c = 2, l = 1, d = s.length; l < d; l++) s[l - 1] !== s[l] && (c += 2);
    var f = new Int32Array(c), h = 0, m = 1;
    for (l = 1, d = s.length; l < d; l++) s[l - 1] !== s[l] ? (f[h] = s[l - 1], f[h + 1] = m, m = 1, h += 2) : ++m;
    return f[h] = s[s.length - 1], f[h + 1] = m, { encodings: [{ kind: "RunLength", srcType: u, srcSize: s.length }], data: f };
  }, t.delta = function(s) {
    if (!Id.isSignedIntegerDataType(s)) throw new Error("Only signed integer types can be encoded using delta encoding.");
    var u = Id.getDataType(s);
    if (u === void 0 && (s = new Int32Array(s), u = 3), !s.length) return { encodings: [{ kind: "Delta", origin: 0, srcType: u }], data: new s.constructor(0) };
    var c = new s.constructor(s.length), l = s[0];
    c[0] = s[0];
    for (var d = 1, f = s.length; d < f; d++) c[d] = s[d] - s[d - 1];
    return c[0] = 0, { encodings: [{ kind: "Delta", origin: l, srcType: u }], data: c };
  }, t.integerPacking = function(s) {
    var u = function(c) {
      var l = function(h) {
        for (var m = 0, p = h.length; m < p; m++) if (h[m] < 0) return !0;
        return !1;
      }(c), d = o(c, l ? 127 : 255), f = o(c, l ? 32767 : 65535);
      return 4 * c.length < 2 * f ? { isSigned: l, size: c.length, bytesPerElement: 4 } : 2 * f < d ? { isSigned: l, size: f, bytesPerElement: 2 } : { isSigned: l, size: d, bytesPerElement: 1 };
    }(s);
    return u.bytesPerElement === 4 ? a(s) : function(c, l) {
      for (var d = l.isSigned ? l.bytesPerElement === 1 ? 127 : 32767 : l.bytesPerElement === 1 ? 255 : 65535, f = -d - 1, h = c.length, m = l.isSigned ? l.bytesPerElement === 1 ? new Int8Array(l.size) : new Int16Array(l.size) : l.bytesPerElement === 1 ? new Uint8Array(l.size) : new Uint16Array(l.size), p = 0, v = 0; v < h; v++) {
        var g = c[v];
        if (g >= 0) for (; g >= d; ) m[p] = d, ++p, g -= d;
        else for (; g <= f; ) m[p] = f, ++p, g -= f;
        m[p] = g, ++p;
      }
      var y = a(m);
      return { encodings: [{ kind: "IntegerPacking", byteCount: l.bytesPerElement, isUnsigned: !l.isSigned, srcSize: h }, y.encodings[0]], data: y.data };
    }(s, u);
  }, t.stringArray = function(s) {
    var u = /* @__PURE__ */ Object.create(null), c = [], l = new Int32Array(s.length), d = Le.create(Int32Array, 1, Math.min(1024, s.length < 32 ? s.length + 1 : Math.round(s.length / 8) + 1));
    Le.add(d, 0);
    for (var f = 0, h = 0, m = 0, p = s; m < p.length; m++) {
      var v = p[m];
      if (v != null) {
        var g = u[v];
        g === void 0 && (f += v.length, c[g = c.length] = v, u[v] = g, Le.add(d, f)), l[h++] = g;
      } else l[h++] = -1;
    }
    var y = Le.compact(d), b = G_(y).encode(y), S = G_(l).encode(l);
    return { encodings: [{ kind: "StringArray", dataEncoding: S.encoding, stringData: c.join(""), offsetEncoding: b.encoding, offsets: b.data }], data: S.data };
  };
}(cr || (cr = {})), function(t) {
  function e(n, i, a) {
    return { name: n, type: 1, value: i, valueKind: a && a.valueKind, defaultFormat: a ? { encoder: a.encoder, typedArray: a.typedArray } : void 0, shouldInclude: a && a.shouldInclude };
  }
  t.str = function(n, i, a) {
    return { name: n, type: 0, value: i, valueKind: a && a.valueKind, defaultFormat: a && a.encoder ? { encoder: a.encoder } : void 0, shouldInclude: a && a.shouldInclude };
  }, t.int = e, t.float = function(n, i, a) {
    return { name: n, 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 };
  }, t.index = function(n) {
    return e(n, function(i, a, o) {
      return o + 1;
    }, { typedArray: Int32Array, encoder: cr.by(cr.delta).and(cr.runLength).and(cr.integerPacking) });
  };
  var r = function() {
    function n() {
      this.fields = [];
    }
    return n.prototype.index = function(i) {
      return this.fields.push(t.index(i)), this;
    }, n.prototype.str = function(i, a, o) {
      return this.fields.push(t.str(i, a, o)), this;
    }, n.prototype.int = function(i, a, o) {
      return this.fields.push(t.int(i, a, o)), this;
    }, n.prototype.vec = function(i, a, o) {
      for (var s = 0; s < a.length; s++) this.fields.push(t.int("".concat(i, "[").concat(s + 1, "]"), a[s], o));
      return this;
    }, n.prototype.float = function(i, a, o) {
      return this.fields.push(t.float(i, a, o)), this;
    }, n.prototype.many = function(i) {
      for (var a = 0; a < i.length; a++) this.fields.push(i[a]);
      return this;
    }, n.prototype.add = function(i) {
      return this.fields.push(i), this;
    }, n.prototype.getFields = function() {
      return this.fields;
    }, n;
  }();
  t.Builder = r, t.build = function() {
    return new r();
  };
}(z_ || (z_ = {})), function(t) {
  t.Empty = { fields: [], source: [] }, t.filterOf = function(e) {
    for (var r = [], n = [], i = [], a = [], o = 0, s = e.split(/[\r\n]+/); o < s.length; o++) {
      var u = s[o];
      if ((u = u.trim()).length !== 0) {
        var c = /^!/.test(u);
        c && (u = u.substr(1));
        var l = u.split(/\./), d = l[1], f = c ? d ? a : n : d ? i : r;
        f[f.length] = u, d && !r.includes(l[0]) && (r[r.length] = l[0]);
      }
    }
    var h = i.map(function(m) {
      return m.split(".")[0];
    });
    return { includeCategory: function(m) {
      return !n.includes(m) && (r.length <= 0 || r.indexOf(m) !== -1);
    }, includeField: function(m, p) {
      var v = m + "." + p;
      return !a.includes(v) && (!h.includes(m) || i.includes(v));
    } };
  }, t.DefaultFilter = { includeCategory: function(e) {
    return !0;
  }, includeField: function(e, r) {
    return !0;
  } }, t.DefaultFormatter = { getFormat: function(e, r) {
  } }, t.ofTable = function(e, r) {
    return r ? { fields: ID(e._schema), source: [{ data: e, rowCount: r.length, keys: function() {
      return A3.Array(r);
    } }] } : { fields: ID(e._schema), source: [{ data: e, rowCount: e._rowCount }] };
  };
}(fs || (fs = {})), function(t) {
  function e(r, n, i) {
    r.startDataBlock(n);
    for (var a = function(u) {
      r.writeCategory({ name: u, instance: function() {
        return fs.ofTable(i[u]);
      } });
    }, o = 0, s = i._tableNames; o < s.length; o++)
      a(s[o]);
  }
  t.writeDatabase = e, t.writeDatabaseCollection = function(r, n) {
    for (var i = 0, a = Object.keys(n); i < a.length; i++) {
      var o = a[i];
      e(r, o, n[o]);
    }
  };
}(V_ || (V_ = {}));
var g$ = function() {
  function t() {
    this.builder = Ir.create(), this.encoded = !1, this.dataBlockCreated = !1, this.filter = fs.DefaultFilter, this.formatter = fs.DefaultFormatter, this.isBinary = !1, this.binaryEncodingProvider = void 0;
  }
  return t.prototype.setFilter = function(e) {
    this.filter = e || fs.DefaultFilter;
  }, t.prototype.isCategoryIncluded = function(e) {
    return this.filter.includeCategory(e);
  }, t.prototype.setFormatter = function(e) {
    this.formatter = e || fs.DefaultFormatter;
  }, t.prototype.startDataBlock = function(e) {
    this.dataBlockCreated = !0, Ir.write(this.builder, "data_".concat((e || "").replace(/[ \n\t]/g, "").toUpperCase(), `
#
`));
  }, t.prototype.writeCategory = function(e, r, n) {
    if (this.encoded) throw new Error("The writer contents have already been encoded, no more writing.");
    if (!this.dataBlockCreated) throw new Error("No data block created.");
    if (n != null && n.ignoreFilter || this.filter.includeCategory(e.name)) {
      var i = xR(e, r), a = i.instance, o = i.rowCount, s = i.source;
      o && (o === 1 ? function(u, c, l, d, f, h) {
        var m = U_(c), p = l[0], v = p.data, g = m.reduce(function(x, C) {
          return f.includeField(u.name, C.name) ? Math.max(x, C.name.length) : 0;
        }, 0);
        if (g !== 0) {
          g += u.name.length + 6;
          for (var y = p.keys().move(), b = MD(u.name, c.fields, h), S = 0; S < m.length; S++) {
            var _ = m[S];
            f.includeField(u.name, _.name) && (Ir.writePadRight(d, "_".concat(u.name, ".").concat(_.name), g), TD(d, v, y, _, b[S], 0) || Ir.newline(d));
          }
          Ir.write(d, `#
`);
        }
      }(e, a, s, this.builder, this.filter, this.formatter) : function(u, c, l, d, f, h) {
        var m = U_(c), p = f === fs.DefaultFilter ? m : m.filter(function(P) {
          return f.includeField(u.name, P.name);
        }), v = p.length;
        if (v !== 0) {
          var g = MD(u.name, p, h);
          PD(d, "loop_");
          for (var y = 0; y < v; y++) PD(d, "_".concat(u.name, ".").concat(p[y].name));
          for (var b = 0, S = 0; S < l.length; S++) {
            var _ = l[S], x = _.data;
            if (_.rowCount !== 0) for (var C = _.keys(); C.hasNext; ) {
              for (var A = C.move(), w = !1, I = 0; I < v; I++) w = TD(d, x, A, p[I], g[I], b);
              w || Ir.newline(d), b++;
            }
          }
          Ir.write(d, `#
`);
        }
      }(e, a, s, this.builder, this.filter, this.formatter));
    }
  }, t.prototype.encode = function() {
    this.encoded = !0;
  }, t.prototype.writeTo = function(e) {
    for (var r = Ir.getChunks(this.builder), n = 0, i = r.length; n < i; n++) e.writeString(r[n]);
  }, t.prototype.getSize = function() {
    return Ir.getSize(this.builder);
  }, t.prototype.getData = function() {
    return Ir.getString(this.builder);
  }, t;
}();
function TD(t, e, r, n, i, a) {
  var o, s = n.valueKind, u = s ? s(r, e) : 0;
  if (u !== 0) u === 1 ? function(d) {
    Ir.writeSafe(d, ". ");
  }(t) : function(d) {
    Ir.writeSafe(d, "? ");
  }(t);
  else {
    var c = n.value(r, e, a), l = n.type;
    if (l === 0) return typeof (o = c) == "string" && o.indexOf(`
`) >= 0 ? (Vg(t, c), !0) : function(d, f) {
      if (!f) return Ir.writeSafe(d, ". "), !1;
      for (var h = f.charCodeAt(0), m = !1, p = 0, v = !1, g = !1, y = 0, b = f.length - 1; y <= b; y++)
        switch (f.charCodeAt(y)) {
          case 9:
          case 32:
            m = !0;
            break;
          case 10:
            return Vg(d, f), !0;
          case 34:
            if (y && y === b) break;
            if (v) return Vg(d, f), !0;
            g = !0, m = !0, p = 0;
            break;
          case 39:
            if (y && y === b) break;
            if (g) return Vg(d, f), !0;
            v = !0, m = !0, p = 1;
        }
      return m || h !== 35 && h !== 36 && h !== 59 && h !== 91 && h !== 93 && h !== 95 || (m = !0), m ? (Ir.writeSafe(d, p ? '"' : "'"), Ir.writeSafe(d, f), Ir.writeSafe(d, p ? '" ' : "' ")) : (Ir.writeSafe(d, f), Ir.writeSafe(d, " ")), !1;
    }(t, c);
    l === 1 ? function(d, f) {
      Ir.writeInteger(d, f), Ir.whitespace1(d);
    }(t, c) : function(d, f, h) {
      Ir.writeFloat(d, f, h), Ir.whitespace1(d);
    }(t, c, i);
  }
  return !1;
}
function MD(t, e, r) {
  for (var n, i = [], a = 0, o = e; a < o.length; a++) {
    var s = o[a], u = r.getFormat(t, 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, (n = s).defaultFormat && n.defaultFormat.digitCount !== void 0 ? Math.max(0, Math.min(n.defaultFormat.digitCount, 16)) : 6) : 0;
  }
  return i;
}
function PD(t, e) {
  Ir.write(t, e), Ir.newline(t);
}
function Vg(t, e) {
  Ir.writeSafe(t, `
;` + e), Ir.writeSafe(t, `
;
`);
}
function v$(t) {
  var e = new ArrayBuffer(r3(t)), r = new DataView(e), n = new Uint8Array(e);
  return n3(t, r, n, 0), n;
}
function r3(t) {
  var e = typeof t;
  if (e === "string") {
    var r = RN(t);
    if (r < 32) return 1 + r;
    if (r < 256) return 2 + r;
    if (r < 65536) return 3 + r;
    if (r < 4294967296) return 5 + r;
  }
  if (t instanceof Uint8Array) {
    var n = t.byteLength;
    if (n < 256) return 2 + n;
    if (n < 65536) return 3 + n;
    if (n < 4294967296) return 5 + n;
  }
  if (e === "number") {
    if (Math.floor(t) !== t) return 9;
    if (t >= 0) {
      if (t < 128) return 1;
      if (t < 256) return 2;
      if (t < 65536) return 3;
      if (t < 4294967296) return 5;
      throw new Error("Number too big 0x" + t.toString(16));
    }
    if (t >= -32) return 1;
    if (t >= -128) return 2;
    if (t >= -32768) return 3;
    if (t >= -2147483648) return 5;
    throw new Error("Number too small -0x" + t.toString(16).substr(1));
  }
  if (e === "boolean" || t == null) return 1;
  if (e === "object") {
    var i, a = 0;
    if (Array.isArray(t)) {
      i = t.length;
      for (var o = 0; o < i; o++) a += r3(t[o]);
    } else {
      var s = Object.keys(t);
      for (i = s.length, o = 0; o < i; o++) {
        var u = s[o];
        a += r3(u) + r3(t[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 " + e);
}
function n3(t, e, r, n) {
  var i = typeof t;
  if (i === "string") {
    var a = RN(t);
    if (a < 32) return e.setUint8(n, 160 | a), Rg(r, n + 1, t), 1 + a;
    if (a < 256) return e.setUint8(n, 217), e.setUint8(n + 1, a), Rg(r, n + 2, t), 2 + a;
    if (a < 65536) return e.setUint8(n, 218), e.setUint16(n + 1, a), Rg(r, n + 3, t), 3 + a;
    if (a < 4294967296) return e.setUint8(n, 219), e.setUint32(n + 1, a), Rg(r, n + 5, t), 5 + a;
  }
  if (t instanceof Uint8Array) {
    var o = t.byteLength, s = new Uint8Array(e.buffer);
    if (o < 256) return e.setUint8(n, 196), e.setUint8(n + 1, o), s.set(t, n + 2), 2 + o;
    if (o < 65536) return e.setUint8(n, 197), e.setUint16(n + 1, o), s.set(t, n + 3), 3 + o;
    if (o < 4294967296) return e.setUint8(n, 198), e.setUint32(n + 1, o), s.set(t, n + 5), 5 + o;
  }
  if (i === "number") {
    if (!isFinite(t)) throw new Error("Number not finite: " + t);
    if (Math.floor(t) !== t) return e.setUint8(n, 203), e.setFloat64(n + 1, t), 9;
    if (t >= 0) {
      if (t < 128) return e.setUint8(n, t), 1;
      if (t < 256) return e.setUint8(n, 204), e.setUint8(n + 1, t), 2;
      if (t < 65536) return e.setUint8(n, 205), e.setUint16(n + 1, t), 3;
      if (t < 4294967296) return e.setUint8(n, 206), e.setUint32(n + 1, t), 5;
      throw new Error("Number too big 0x" + t.toString(16));
    }
    if (t >= -32) return e.setInt8(n, t), 1;
    if (t >= -128) return e.setUint8(n, 208), e.setInt8(n + 1, t), 2;
    if (t >= -32768) return e.setUint8(n, 209), e.setInt16(n + 1, t), 3;
    if (t >= -2147483648) return e.setUint8(n, 210), e.setInt32(n + 1, t), 5;
    throw new Error("Number too small -0x" + (-t).toString(16).substr(1));
  }
  if (t == null) return e.setUint8(n, 192), 1;
  if (i === "boolean") return e.setUint8(n, t ? 195 : 194), 1;
  if (i === "object") {
    var u, c = 0, l = Array.isArray(t), d = void 0;
    if ((u = l ? t.length : (d = Object.keys(t)).length) < 16 ? (e.setUint8(n, u | (l ? 144 : 128)), c = 1) : u < 65536 ? (e.setUint8(n, l ? 220 : 222), e.setUint16(n + 1, u), c = 3) : u < 4294967296 && (e.setUint8(n, l ? 221 : 223), e.setUint32(n + 1, u), c = 5), l) for (var f = 0; f < u; f++) c += n3(t[f], e, r, n + c);
    else {
      f = 0;
      for (var h = d.length; f < h; f++) {
        var m = d[f];
        c += n3(m, e, r, n + c), c += n3(t[m], e, r, n + c);
      }
    }
    return c;
  }
  throw new Error("Unknown type " + i);
}
var na, qm, vc, y$ = function() {
  function t(e, r, n) {
    this.autoClassify = n, this.dataBlocks = [], this.filter = fs.DefaultFilter, this.formatter = fs.DefaultFormatter, this.isBinary = !0, this.binaryEncodingProvider = void 0, this.binaryEncodingProvider = r, this.data = { encoder: e, version: "0.3.0", dataBlocks: this.dataBlocks };
  }
  return t.prototype.setFilter = function(e) {
    this.filter = e || fs.DefaultFilter;
  }, t.prototype.isCategoryIncluded = function(e) {
    return this.filter.includeCategory(e);
  }, t.prototype.setFormatter = function(e) {
    this.formatter = e || fs.DefaultFormatter;
  }, t.prototype.startDataBlock = function(e) {
    this.dataBlocks.push({ header: (e || "").replace(/[ \n\t]/g, "").toUpperCase(), categories: [] });
  }, t.prototype.writeCategory = function(e, r, n) {
    if (!this.data) throw new Error("The writer contents have already been encoded, no more writing.");
    if (!this.dataBlocks.length) throw new Error("No data block created.");
    if (n != null && n.ignoreFilter || this.filter.includeCategory(e.name)) {
      var i = xR(e, r), a = i.instance, o = i.rowCount, s = i.source;
      if (o) {
        for (var u = { name: "_" + e.name, columns: [], rowCount: o }, c = 0, l = U_(a); c < l.length; c++) {
          var d = l[c];
          if (this.filter.includeField(e.name, d.name)) {
            var f = this.formatter.getFormat(e.name, d.name);
            u.columns.push(_$(e.name, d, s, o, f, this.binaryEncodingProvider, this.autoClassify));
          }
        }
        u.columns.length && this.dataBlocks[this.dataBlocks.length - 1].categories.push(u);
      }
    }
  }, t.prototype.encode = function() {
    this.encodedData || (this.encodedData = v$(this.data), this.data = null, this.dataBlocks = null);
  }, t.prototype.writeTo = function(e) {
    e.writeBinary(this.encodedData);
  }, t.prototype.getData = function() {
    return this.encode(), this.encodedData;
  }, t.prototype.getSize = function() {
    return this.encodedData.length;
  }, t;
}();
function b$(t, e) {
  return t === 0 ? Hd.by(cr.stringArray) : t === 1 ? G_(e) : (r = e, k_.classify(r));
  var r;
}
function _$(t, e, r, n, i, a, o) {
  var s = function(p, v, g, y) {
    for (var b = p.type === 0, S = new v(g), _ = new Uint8Array(g), x = p.valueKind, C = p.value, A = !0, w = 0, I = 0; I < y.length; I++) for (var P = y[I].data, M = y[I].keys(); M.hasNext; ) {
      var T = M.move(), F = x ? x(T, P) : 0;
      if (F !== 0) _[w] = F, b && (S[w] = ""), A = !1;
      else {
        var N = C(T, P, w);
        typeof N != "string" || N ? _[w] = 0 : (_[w] = 1, A = !1), S[w] = N;
      }
      w++;
    }
    return { array: S, allPresent: A, mask: _ };
  }(e, function(p, v) {
    return v && v.typedArray ? v.typedArray : p.defaultFormat && p.defaultFormat.typedArray ? p.defaultFormat.typedArray : p.type === 0 ? Array : p.type === 1 ? Int32Array : Float64Array;
  }(e, i), n, r), u = s.array, c = s.allPresent, l = s.mask, d = function(p, v, g, y) {
    return g && g.encoder ? g.encoder : v.defaultFormat && v.defaultFormat.encoder ? v.defaultFormat.encoder : y ? y.get(p, v.name) : void 0;
  }(t, e, i, a);
  d || (d = o ? b$(e.type, u) : function(p) {
    return p === 0 ? Hd.by(cr.stringArray) : Hd.by(cr.byteArray);
  }(e.type));
  var f = d.encode(u), h = void 0;
  if (!c) {
    var m = Hd.by(cr.runLength).and(cr.byteArray).encode(l);
    h = m.data.length < l.length ? m : Hd.by(cr.byteArray).encode(l);
  }
  return { name: e.name, data: f, mask: h };
}
function Ug(t, e, r, n, i, a) {
  for (var o = new Xo.EdgeBuilder(i, t, e), s = new Uint16Array(o.slotCount), u = new Int8Array(o.slotCount), c = 0, l = o.edgeCount; c < l; c++) o.addNextEdge(), o.assignProperty(s, n[c]), o.assignProperty(u, r[c]);
  return o.createGraph({ flags: s, order: u }, { canRemap: a });
}
(function(t) {
  t.Encoder = V_, t.Category = fs, t.Field = z_, t.Encoding = cr, t.createEncoder = function(n) {
    var i = n || {}, a = i.binary, o = a !== void 0 && a, s = i.encoderName;
    return o ? new y$(s === void 0 ? "mol*" : s, n ? n.binaryEncodingPovider : void 0, !!n && !!n.binaryAutoClassifyEncoding) : new g$();
  }, t.fields = function() {
    return t.Field.build();
  };
  var e = t.Encoding;
  function r(n) {
    var i = n.precision;
    if (i !== void 0) {
      var a = Math.pow(10, i), o = e.by(e.fixedPoint(a));
      switch (n.encoding) {
        case "pack":
          return o.and(e.integerPacking);
        case "rle":
          return o.and(e.runLength).and(e.integerPacking);
        case "delta":
          return o.and(e.delta).and(e.integerPacking);
        case "delta-rle":
          return o.and(e.delta).and(e.runLength).and(e.integerPacking);
      }
    } else switch (n.encoding) {
      case "pack":
        return e.by(e.integerPacking);
      case "rle":
        return e.by(e.runLength).and(e.integerPacking);
      case "delta":
        return e.by(e.delta).and(e.integerPacking);
      case "delta-rle":
        return e.by(e.delta).and(e.runLength).and(e.integerPacking);
    }
    throw new Error("cannot be reached");
  }
  t.Encodings = { deltaRLE: e.by(e.delta).and(e.runLength).and(e.integerPacking), fixedPoint2: e.by(e.fixedPoint(100)).and(e.delta).and(e.integerPacking), fixedPoint3: e.by(e.fixedPoint(1e3)).and(e.delta).and(e.integerPacking) }, t.categoryInstance = function(n, i) {
    return { fields: n, source: [i] };
  }, t.createEncodingProviderFromCifFrame = function(n) {
    return { get: function(i, a) {
      var o = n.categories[i];
      if (o) {
        var s = o.getField(a);
        return s && s.binaryEncoding ? Hd.fromEncoding(s.binaryEncoding) : void 0;
      }
    } };
  }, t.createEncodingProviderFromJsonConfig = function(n) {
    return { get: function(i, a) {
      for (var o = 0; o < n.length; o++) {
        var s = n[o];
        if (s.categoryName === i && s.columnName === a) return r(s);
      }
    } };
  };
})(na || (na = {})), function(t) {
  t.Descriptor = { name: "chem_comp_bond", cifExport: { prefix: "", categories: [{ name: "chem_comp_bond", instance: function(r) {
    var n = t.Provider.get(r.firstModel);
    if (!n) return na.Category.Empty;
    var i = n.data;
    if (!i) return na.Category.Empty;
    for (var a = r.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 na.Category.ofTable(i, u);
  } }] } }, t.Provider = gc.create(t.Descriptor), t.chemCompBondFromTable = function(r, n) {
    return Hr.pick(n, rr.chem_comp_bond, function(i) {
      return r.properties.chemicalComponentMap.has(n.comp_id.value(i));
    });
  }, t.getEntriesFromChemCompBond = function(r) {
    var n = /* @__PURE__ */ new Map();
    function i(S) {
      if (n.has(S)) return n.get(S);
      var _ = new e(S);
      return n.set(S, _), _;
    }
    for (var a = r.comp_id, o = r.atom_id_1, s = r.atom_id_2, u = r.value_order, c = r.pdbx_aromatic_flag, l = r._rowCount, d = i(a.value(0)), f = 0; f < l; f++) {
      var h = a.value(f), m = o.value(f), p = s.value(f), v = u.value(f), g = c.value(f) === "Y";
      d.id !== h && (d = i(h));
      var y = 1, b = 1;
      switch (g && (y |= 16), v.toLowerCase()) {
        case "delo":
          y |= 16;
          break;
        case "doub":
          b = 2;
          break;
        case "trip":
          b = 3;
          break;
        case "quad":
          b = 4;
      }
      d.add(m, p, b, y);
    }
    return n;
  };
  var e = function() {
    function r(n) {
      this.id = n, this.map = /* @__PURE__ */ new Map();
    }
    return r.prototype.add = function(n, i, a, o, s) {
      s === void 0 && (s = !0);
      var u = this.map.get(n);
      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(n, c);
      }
      s && this.add(i, n, a, o, !1);
    }, r;
  }();
  t.Entry = e;
}(qm || (qm = {})), function(t) {
  function e(r, n) {
    for (var i = r.units, a = 0, o = i.length; a < o; a++) if (Ke.indexOf(i[a].elements, n) >= 0) return !0;
    return !1;
  }
  t.Descriptor = { name: "struct_conn", cifExport: { prefix: "", categories: [{ name: "struct_conn", instance: function(r) {
    var n = t.Provider.get(r.firstModel);
    if (!n || n.entries.length === 0) return na.Category.Empty;
    for (var i = r.structures[0], a = [], o = 0, s = n.entries; o < s.length; o++) {
      var u = s[o];
      e(i, u.partnerA.atomIndex) && e(i, u.partnerB.atomIndex) && (a[a.length] = u.rowIndex);
    }
    return na.Category.ofTable(n.data, a);
  } }] } }, t.Provider = gc.create(t.Descriptor), t.isExhaustive = function(r) {
    var n = t.Provider.get(r);
    return !!n && n.data.id.rowCount / r.atomicConformation.atomId.rowCount > 0.95;
  }, t.getAtomIndexFromEntries = function(r) {
    for (var n = /* @__PURE__ */ new Map(), i = 0, a = r; i < a.length; i++) {
      var o = a[i], s = o.partnerA.atomIndex, u = o.partnerB.atomIndex;
      n.has(s) ? n.get(s).push(o) : n.set(s, [o]), n.has(u) ? n.get(u).push(o) : n.set(u, [o]);
    }
    return n;
  }, t.getEntriesFromStructConn = function(r, n) {
    for (var i = r.conn_type_id, a = r.pdbx_dist_value, o = r.pdbx_value_order, s = { label_asym_id: r.ptnr1_label_asym_id, label_seq_id: r.ptnr1_label_seq_id, auth_seq_id: r.ptnr1_auth_seq_id, label_atom_id: r.ptnr1_label_atom_id, label_alt_id: r.pdbx_ptnr1_label_alt_id, ins_code: r.pdbx_ptnr1_PDB_ins_code, symmetry: r.ptnr1_symmetry }, u = { label_asym_id: r.ptnr2_label_asym_id, label_seq_id: r.ptnr2_label_seq_id, auth_seq_id: r.ptnr2_auth_seq_id, label_atom_id: r.ptnr2_label_atom_id, label_alt_id: r.pdbx_ptnr2_label_alt_id, ins_code: r.pdbx_ptnr2_PDB_ins_code, symmetry: r.ptnr2_symmetry }, c = function(g, y) {
      if (y.label_asym_id.valueKind(g) === 0) {
        var b = y.label_asym_id.value(g), S = n.atomicHierarchy.index.findEntity(b);
        if (!(S < 0)) {
          var _ = n.atomicHierarchy.index.findResidue(n.entities.data.id.value(S), b, y.auth_seq_id.value(g), y.ins_code.value(g));
          if (!(_ < 0)) {
            var x = y.label_atom_id.value(g);
            if (x) {
              var C = n.atomicHierarchy.index.findAtomOnResidue(_, x, y.label_alt_id.value(g));
              if (!(C < 0)) return { residueIndex: _, atomIndex: C, symmetry: y.symmetry.value(g) };
            }
          }
        }
      }
    }, l = [], d = 0; d < r._rowCount; d++) {
      var f = c(d, s), h = c(d, u);
      if (f !== void 0 && h !== void 0) {
        var m = i.value(d), p = 0, v = 1;
        switch ((o.value(d) || "").toLowerCase()) {
          case "sing":
            v = 1;
            break;
          case "doub":
            v = 2;
            break;
          case "trip":
            v = 3;
            break;
          case "quad":
            v = 4;
            break;
          default:
            v = _R(r.ptnr1_label_comp_id.value(d), r.ptnr1_label_atom_id.value(d), r.ptnr2_label_comp_id.value(d), r.ptnr2_label_atom_id.value(d));
        }
        switch (m) {
          case "covale":
            p = 1;
            break;
          case "disulf":
            p = 9;
            break;
          case "hydrog":
            p = 4;
            break;
          case "metalc":
            p = 2;
        }
        l.push({ rowIndex: d, flags: p, order: v, distance: a.value(d), partnerA: f, partnerB: h });
      }
    }
    return l;
  };
}(vc || (vc = {}));
var BD = E(), FD = E();
function x$(t, e, r) {
  return t.conformation.position(e, BD), t.conformation.position(r, FD), E.distance(BD, FD);
}
var S$ = /* @__PURE__ */ new Set();
function C$(t, e) {
  var r = O(O({}, gR), e);
  return r.noCompute || pn.isCoarseGrained(t.model) ? O_.Empty : pn.isMaterial(t.model) && (r.isMaterial = !0, Xi.Provider.get(t.model)) ? function(n) {
    var i = Xi.Provider.get(n.model);
    return i ? Ug(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) : Ug([], [], [], [], 0, !1);
  }(t) : !r.forceCompute && Xi.Provider.get(t.model) ? function(n) {
    for (var i = Xi.Provider.get(n.model), a = n.elements, o = n.model.atomicHierarchy.atoms.type_symbol, s = n.elements.length, u = i.bonds, c = u.offset, l = u.b, d = u.edgeProps, f = d.order, h = d.distance, m = d.flag, p = n.model.atomicHierarchy.atomSourceIndex, v = pn.getInvertedAtomSourceIndex(n.model).invertedIndex, g = [], y = [], b = [], S = [], _ = 0; _ < s; _++) for (var x = a[_], C = Vd(o.value(x)), A = Ud(C), w = p.value(x), I = c[w], P = c[w + 1]; I < P; ++I) {
      var M = v[l[I]];
      if (!(x >= M)) {
        var T = Ke.indexOf(n.elements, M);
        if (!(T < 0)) {
          var F = Vd(o.value(M)), N = h[I], R = x$(n, x, M), L = !1;
          n.model.sourceData.kind === "mol" || n.model.sourceData.kind === "sdf" || n.model.sourceData.kind === "mol2" ? L = !0 : N >= 0 ? L = jn(R, N, 0.3) : C === -1 || F === -1 ? L = !0 : A && Ud(F) && (L = !1), L && (g[g.length] = _, y[y.length] = T, S[S.length] = f[I], b[b.length] = m[I]);
        }
      }
    }
    return Ug(g, y, S, b, s, !1);
  }(t) : function(n, i) {
    for (var a = i.maxRadius, o = i.isMaterial, s = n.model.atomicConformation, u = s.x, c = s.y, l = s.z, d = n.elements.length, f = n.elements, h = n.residueIndex, m = n.chainIndex, p = n.model.atomicHierarchy.atoms, v = p.type_symbol, g = p.label_atom_id, y = p.label_alt_id, b = p.label_comp_id, S = n.model.atomicHierarchy.residues.label_seq_id, _ = n.model.atomicHierarchy.index, x = n.model.sequence.byEntityKey, C = n.lookup3d, A = vc.Provider.get(n.model), w = qm.Provider.get(n.model), I = vc.isExhaustive(n.model), P = [], M = [], T = [], F = [], N = -1, R = void 0, L = !0, V = !0, U = !0, H = S$, K = 0; K < d; K++) {
      var X = f[K], Y = v.value(X);
      L && Y !== "H" && Y !== "O" && (L = !1);
      var Q = i.forceCompute ? void 0 : A && A.byAtomIndex.get(X), J = !1;
      if (Q) for (var te = 0, W = Q; te < W.length; te++) {
        var j = W[te], ee = j.partnerA, ie = j.partnerB;
        if (ee.symmetry === ie.symmetry) {
          var ae = ee.atomIndex === X ? ie : ee;
          (me = Ke.indexOf(n.elements, ae.atomIndex)) < 0 || f[me] < X || (P[P.length] = K, M[M.length] = me, T[T.length] = j.flags, F[F.length] = j.order, J || H.clear(), J = !0, H.add(me));
        }
      }
      if (!I) {
        var ce = h[X], de = S.value(ce), Ce = b.value(X);
        if (!i.forceCompute && ce !== N) if (w && w.entries.has(Ce)) {
          var De = x[_.getEntityFromChain(m[X])];
          R = De && De.sequence.microHet.has(de) ? void 0 : w.entries.get(Ce).map;
        } else R = void 0;
        N = ce;
        for (var ke = Vd(Y), He = g.value(X), We = R ? R.get(He) : void 0, Ne = C.find(u[X], c[X], l[X], a), Je = Ne.indices, Re = Ne.count, nt = Ne.squaredDistances, ne = Ud(ke), re = tp(ke), le = y.value(X), fe = B3.has(ke), ge = 0; ge < Re; ge++) {
          var me = Je[ge];
          if (!J || !H.has(me)) {
            var Ae = f[me];
            if (!(Ae <= X)) {
              var Oe = y.value(Ae);
              if (!le || !Oe || le === Oe) {
                var Ue = Vd(v.value(Ae)), Ve = Ud(Ue);
                if (!ne || !Ve) {
                  var ht = (fe || B3.has(Ue)) && !(ne || Ve), bt = h[Ae];
                  if (ce === bt && We) {
                    var At = We.get(g.value(Ae));
                    if (At) {
                      P[P.length] = K, M[M.length] = me, F[F.length] = At.order;
                      var Ee = At.flags;
                      ht && (o ? Ee = 33 : (1 | Ee && (Ee ^= 1), Ee |= 2)), T[T.length] = Ee;
                    }
                  } else {
                    var st = Math.sqrt(nt[ge]);
                    if (st !== 0 && st <= L_(ke, Ue, re, tp(Ue), o)) {
                      P[P.length] = K, M[M.length] = me, F[F.length] = c$(Ce, He, g.value(Ae)), T[T.length] = 32 | (ht && !o ? 2 : 1);
                      var Et = S.value(bt);
                      de === Et && (V = !1), Math.abs(de - Et) > 1 && (U = !1);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    return Ug(P, M, F, T, d, L || V && U);
  }(t, r);
}
var ND = E(), RD = E();
function OD(t, e, r, n) {
  return t.conformation.position(e, ND), r.conformation.position(n, RD), E.distance(ND, RD);
}
var A$ = he(), Nf = E(), Dt, w$ = O(O({}, gR), { ignoreWater: !0, ignoreIon: !0 });
function D$(t, e) {
  var r = new C0.Builder(), n = t.models.some(function(i) {
    return Xi.Provider.get(i);
  });
  return e.noCompute || t.isCoarseGrained && !n || tt.eachUnitPair(t, function(i, a) {
    (function(o, s, u, c) {
      var l = u.maxRadius, d = o.elements, f = o.residueIndex, h = o.model.atomicConformation, m = h.x, p = h.y, v = h.z, g = s.elements, y = s.residueIndex, b = o.elements.length, S = o.model.atomicHierarchy.atoms, _ = S.type_symbol, x = S.label_alt_id, C = S.label_atom_id, A = S.label_comp_id, w = s.model.atomicHierarchy.atoms, I = w.type_symbol, P = w.label_alt_id, M = w.label_atom_id, T = w.label_comp_id, F = o.model.atomicHierarchy.residues.auth_seq_id, N = s.model.atomicHierarchy.residues.auth_seq_id, R = o.model.atomicConformation.occupancy, L = s.model.atomicConformation.occupancy, V = R.isDefined && L.isDefined, U = o.model === s.model && vc.Provider.get(o.model), H = !u.forceCompute && o.model === s.model && Xi.Provider.get(o.model), K = o.model.atomicHierarchy.atomSourceIndex, X = (H ? pn.getInvertedAtomSourceIndex(s.model) : { invertedIndex: void 0 }).invertedIndex, Y = o.model === s.model && vc.isExhaustive(o.model), Q = he.mul(A$, s.conformation.operator.inverse, o.conformation.operator.matrix), J = !he.isIdentity(Q), te = s.boundary.sphere, W = te.center, j = te.radius, ee = (j + l) * (j + l);
      c.startUnitPair(o.id, s.id);
      for (var ie = 0; ie < b; ie++) {
        var ae = d[ie];
        if (E.set(Nf, m[ae], p[ae], v[ae]), J && E.transformMat4(Nf, Nf, Q), !(E.squaredDistance(Nf, W) > ee)) if (u.forceCompute || !H) {
          var ce = u.forceCompute ? void 0 : U && U.byAtomIndex.get(ae);
          if (ce && ce.length) {
            for (var de = !1, Ce = 0, De = ce; Ce < De.length; Ce++) {
              var ke = De[Ce], He = ke.partnerA, We = ke.partnerB, Ne = He.atomIndex === ae ? We : He;
              (cn = Ke.indexOf(s.elements, Ne.atomIndex)) < 0 || OD(o, ae, s, Ne.atomIndex) > l || (c.add(ie, cn, { order: ke.order, flag: ke.flags }), de = !0);
            }
            if (de) continue;
          }
          if (!Y) {
            var Je = R.value(ae), Re = s.lookup3d.find(Nf[0], Nf[1], Nf[2], l), nt = Re.indices, ne = Re.count, re = Re.squaredDistances;
            if (ne !== 0) for (var le = Vd(_.value(ae)), fe = Ud(le), ge = tp(le), me = x.value(ae), Ae = B3.has(le), Oe = C.value(ae), Ue = A.value(f[ae]), Ve = 0; Ve < ne; Ve++) {
              ln = g[cn = nt[Ve]];
              var ht = P.value(ln);
              if (!(me && ht && me !== ht || V && L.value(ln) < 1 && Je < 1 && F.value(ae) === N.value(ln))) {
                var bt = Ud(Mi = Vd(I.value(ln)));
                if (!fe || !bt) {
                  var At = (Ae || B3.has(Mi)) && !(fe || bt);
                  if (!At && (On = Math.sqrt(re[Ve])) !== 0 && On <= L_(le, Mi, ge, tp(Mi))) {
                    var Ee = M.value(ln), st = T.value(y[ln]);
                    c.add(ie, cn, { order: _R(Ue, st, Oe, Ee), flag: 32 | (At ? 2 : 1) });
                  }
                }
              }
            }
          }
        } else for (var Et = H.maxDistance, ur = H.bonds, ir = ur.offset, Nr = ur.b, pr = ur.edgeProps, _n = pr.order, Jn = pr.distance, Yn = pr.flag, Rn = K.value(ae), un = ir[Rn], yi = ir[Rn + 1]; un < yi; ++un) {
          var cn, ln = X[Nr[un]];
          if (!((cn = Ke.indexOf(s.elements, ln)) < 0)) {
            var Ti = Vd(_.value(ae)), Mi = Vd(_.value(ln)), so = Jn[un], On = OD(o, ae, s, ln), xn = !1;
            so >= 0 ? xn = jn(On, so, 0.3) : Et >= 0 ? xn = On < Et : (xn = On < L_(Ti, Mi, tp(Ti), tp(Mi)), Ud(Ti) && Ud(Mi) && (xn = !1)), xn && c.add(ie, cn, { order: _n[un], flag: Yn[un] });
          }
        }
      }
      c.finishUnitPair();
    })(i, a, e, r);
  }, { maxRadius: e.maxRadius, validUnit: function(i) {
    return Fe.isAtomic(i);
  }, validUnitPair: function(i, a) {
    return e.validUnitPair(t, i, a);
  } }), new P3(r.getMap());
}
function E$(t, e) {
  var r = O(O({}, w$), e);
  return D$(t, O(O({}, r), { validUnitPair: e && e.validUnitPair || function(n, i, a) {
    var o = i.model.atomicHierarchy.derived.residue.moleculeType, s = a.model.atomicHierarchy.derived.residue.moleculeType, u = !(Fe.isAtomic(i) && o[i.residueIndex[i.elements[0]]] === 2 || Fe.isAtomic(a) && s[a.residueIndex[a.elements[0]]] === 2), c = i.model === a.model, l = !Fe.isAtomic(i) || o[i.residueIndex[i.elements[0]]] !== 3 || c && LD(i), d = !Fe.isAtomic(a) || s[a.residueIndex[a.elements[0]]] !== 3 || c && LD(a), f = l && d;
    return tt.validUnitPair(n, i, a) && (u || !r.ignoreWater) && (f || !r.ignoreIon);
  } }));
}
function LD(t) {
  if (!Fe.isAtomic(t)) return !1;
  var e = t.elements, r = vc.Provider.get(t.model);
  if (r) {
    for (var n = 0, i = e.length; n < i; n++) if (r.byAtomIndex.get(e[n])) return !0;
  }
  return !1;
}
function I$(t) {
  for (var e = function(a) {
    for (var o = Qt.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;
  }(t), r = 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 };
  }(t, e), n = Qt.transientSegments(t.model.atomicHierarchy.residueAtomSegments, t.elements); n.hasNext; ) {
    var i = n.move();
    T$(r, i.start, i.end);
  }
  return r.rings;
}
function kD(t) {
  t.count = t.endVertex - t.startVertex;
  for (var e = t.isRingAtom, r = t.pred, n = t.color, i = t.depth, a = t.marked, o = 0; o < t.count; o++) e[o] = 0, r[o] = -1, a[o] = -1, n[o] = 0, i[o] = 0;
  t.currentColor = 0, t.currentAltLoc = "", t.hasAltLoc = !1;
}
function GD(t) {
  for (var e = t.depth, r = 0; r < t.count; r++) e[r] = t.count + 1;
}
function zD(t, e) {
  var r = t.bonds.offset, n = t.startVertex + e, i = r[n], a = r[n + 1] - i;
  return !(a <= 1 || t.isRingAtom[e] && a === 2);
}
function T$(t, e, r) {
  if (t.startVertex = e, t.endVertex = r, !(t.endVertex - t.startVertex < 3)) {
    t.currentRings = [];
    for (var n = t.unit.elements, i = [], a = t.startVertex; a < t.endVertex; a++)
      Qs(i, u = t.altLoc.value(n[a]));
    t3(i, "");
    var o = 1;
    if (i.length === 0)
      for (kD(t), a = 0; a < t.count; a++) zD(t, a) && (GD(t), o = VD(t, a, o));
    else for (var s = 0; s < i.length; s++)
      for (kD(t), t.hasAltLoc = !0, t.currentAltLoc = i[s], a = 0; a < t.count; a++) {
        var u;
        zD(t, a) && ((u = t.altLoc.value(n[t.startVertex + a])) && u !== t.currentAltLoc || (GD(t), o = VD(t, a, o)));
      }
    a = 0;
    for (var c = t.currentRings.length; a < c; a++) t.rings.push(t.currentRings[a]);
  }
}
function M$(t, e, r, n) {
  if (r < e) return !1;
  for (var i = t.pred, a = t.color, o = t.left, s = t.right, u = ++t.currentColor, c = e, l = 0; l < 5 && (a[c] = u, !((c = i[c]) < 0)); l++) ;
  var d = 0, f = 0, h = !1, m = 0;
  for (c = r, l = 0; l < 5; l++) {
    if (a[c] === u) {
      m = c, h = !0;
      break;
    }
    if (s[f++] = c, (c = i[c]) < 0) break;
  }
  if (!h) return !1;
  for (c = e, l = 0; l < 5 && (o[d++] = c, m !== c) && !((c = i[c]) < 0); l++) ;
  var p = d + f;
  if (p < 3) return !1;
  var v = new Int32Array(p), g = 0;
  for (l = 0; l < d; l++) v[g++] = t.startVertex + o[l], n[o[l]] = 1;
  for (l = f - 1; l >= 0; l--) v[g++] = t.startVertex + s[l], n[s[l]] = 1;
  Ru(v);
  for (var y = 0, b = t.currentRings.length; y < b; y++) {
    var S = t.currentRings[y];
    if (v.length === S.length) {
      if (Ke.areEqual(v, S)) return !1;
    } else if (v.length > S.length && Ke.isSubset(v, S)) return !1;
  }
  return t.currentRings.push(Ke.ofSortedArray(v)), !0;
}
function VD(t, e, r) {
  var n = t.bonds, i = t.startVertex, a = t.endVertex, o = t.isRingAtom, s = t.marked, u = t.queue, c = t.pred, l = t.depth, d = t.unit.elements, f = n.b, h = n.edgeProps.flags, m = n.offset;
  s[e] = r, l[e] = 0, u[0] = e;
  for (var p = 0, v = 1; p < v; ) for (var g = u[p++], y = l[g], b = i + g, S = m[b], _ = m[b + 1], x = S; x < _; x++) {
    var C = f[x];
    if (!(C < i || C >= a) && lr.isCovalent(h[x])) {
      if (t.hasAltLoc) {
        var A = t.altLoc.value(d[C]);
        if (A && t.currentAltLoc !== A) continue;
      }
      var w = C - i;
      if (s[w] !== r) {
        var I = Math.min(l[w], y + 1);
        I > 5 || (l[w] = I, s[w] = r, u[v++] = w, c[w] = g);
      } else if (c[w] !== g && c[g] !== w && M$(t, g, w, o)) return r + 1;
    }
  }
  return r + 1;
}
function UD(t) {
  for (var e = t.length, r = new Int32Array(2 * e), n = 0; n < r.length; n++) r[n] = -1;
  for (var i = "", a = "", o = 0, s = 1; s < r.length; s++) {
    for (n = r[s - o - 1]; n !== -1 && (i = t[s % e]) !== (a = t[(o + n + 1) % e]); ) i < a && (o = s - n - 1), n = r[n];
    n === -1 && (i = t[s % e]) !== (a = t[(o + n + 1) % e]) ? (i < a && (o = s), r[s - o] = -1) : r[s - o] = n + 1;
  }
  return o;
}
function HD(t, e) {
  var r, n = t.length, i = [];
  for (r = 0; r < n - 1; r++) i.push(t[(r + e) % n]), i.push("-");
  return i.push(t[(r + e) % n]), i.join("");
}
function SR(t, e) {
  switch (t.kind) {
    case 0:
      return t.model.atomicHierarchy.derived.residue.moleculeType[t.residueIndex[e]];
    case 1:
    case 2:
      var r = 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);
      }(t, e), n = t.model.properties.chemicalComponentMap.get(r);
      if (n) return g2(n.type, r);
  }
  return 0;
}
(function(t) {
  function e(a, o, s, u, c, l) {
    return { kind: "bond-location", aStructure: a, aUnit: o, aIndex: s, bStructure: u, bUnit: c, bIndex: l };
  }
  function r(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 n(a, o) {
    return { kind: "bond-loci", structure: a, bonds: o };
  }
  t.Location = e, t.isLocation = function(a) {
    return !!a && a.kind === "bond-location";
  }, t.areLocationsEqual = r, t.Loci = n, t.isLoci = function(a) {
    return !!a && a.kind === "bond-loci";
  }, t.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 (!r(a.bonds[s], o.bonds[s])) return !1;
    return !0;
  }, t.isLociEmpty = function(a) {
    return a.bonds.length === 0;
  }, t.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], f = Ke.indexOf(c.elements, d);
          if (f !== -1) {
            var h = u.bUnit.elements[u.bIndex], m = Ke.indexOf(l.elements, h);
            m !== -1 && s.push(e(a.structure, c, f, a.structure, l, m));
          }
        }
      }
    }), n(o, s);
  }, t.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, f = l.aUnit, h = l.bIndex, m = l.bUnit;
      f === m ? s.has(f.id) ? s.get(f.id).push(d, h) : s.set(f.id, [d, h]) : (s.has(f.id) ? s.get(f.id).push(d) : s.set(f.id, [d]), s.has(m.id) ? s.get(m.id).push(h) : s.set(m.id, [h]));
    }
    return s.forEach(function(p, v) {
      o.push({ unit: a.structure.unitMap.get(v), indices: Ke.deduplicate(Ke.ofUnsortedArray(p)) });
    }), Xe(a.structure, o);
  }, t.toFirstStructureElementLoci = function(a) {
    var o = a.bonds[0], s = o.aUnit, u = o.aIndex;
    return Xe(a.structure, [{ unit: s, indices: Ge.ofSingleton(u) }]);
  }, t.getType = function(a, o) {
    if (o.aUnit === o.bUnit) {
      var s = o.aUnit.bonds, u = s.getEdgeIndex(o.aIndex, o.bIndex);
      return u < 0 ? lr.create(0) : lr.create(s.edgeProps.flags[u]);
    }
    var c = a.interUnitBonds.getBondFromLocation(o);
    return c ? lr.create(c.props.flag) : lr.create(0);
  }, t.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;
  }, t.getIntraUnitBondCount = function(a) {
    for (var o = 0, s = 0, u = a.units.length; s < u; ++s) {
      var c = a.units[s];
      Fe.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;
  }();
  t.ElementBondIterator = i, t.getBoundingSphere = function(a, o) {
    return _p.fromPairProvider(a.bonds.length, function(s, u, c) {
      var l = a.bonds[s], d = l.aUnit, f = l.aIndex, h = l.bUnit, m = l.bIndex;
      d.conformation.position(d.elements[f], u), h.conformation.position(h.elements[m], c);
    }, o);
  };
})(Dt || (Dt = {}));
var P$ = /* @__PURE__ */ new Set();
function qd(t, e) {
  var r = XJ[t];
  if (r !== void 0) {
    var n = r[e];
    if (n !== void 0) return n;
  }
  return P$;
}
var qD = E.zero();
function CR(t, e) {
  for (var r = t.conformation.position, n = new Float32Array(3 * e.length), i = t.elements, a = 0, o = e.length; a < o; ++a) r(i[e[a]], qD), E.toArray(qD, n, 3 * a);
  return n;
}
var nu, rn, N3 = function() {
  function t(e, r) {
    this.unit = r, this.all = e;
  }
  return Object.defineProperty(t.prototype, "index", { get: function() {
    return this._index || (this._index = function(e, r) {
      for (var n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0, o = e.length; a < o; a++) for (var s = 0, u = (h = e[a]).length; s < u; s++) {
        var c = h[s];
        n.has(c) ? n.get(c).push(a) : n.set(c, [a]);
      }
      for (var l = 0, d = r.length; l < d; l++) for (s = 0, u = (h = e[a = r[l]]).length; s < u; s++) c = h[s], i.has(c) ? i.get(c).push(a) : i.set(c, [a]);
      var f = new Xo.UniqueEdgeBuilder(e.length);
      for (a = 0, o = e.length; a < o; a++) {
        var h;
        for (s = 0, u = (h = e[a]).length; s < u; s++) {
          c = h[s];
          var m = n.get(c);
          if (m.length !== 1) for (var p = 0, v = m.length; p < v; p++) {
            var g = m[p];
            a >= g || f.addEdge(a, g);
          }
        }
      }
      var y = Xo.connectedComponents(f.getGraph()), b = y.componentIndex, S = [];
      for (s = 0; s < y.componentCount; s++) S[s] = [];
      for (a = 0, o = e.length; a < o; a++) S[b[a]].push(a);
      return { elementRingIndices: n, elementAromaticRingIndices: i, ringComponentIndex: b, ringComponents: S };
    }(this.all, this.aromaticRings)), this._index;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "byFingerprint", { get: function() {
    return this._byFingerprint || (this._byFingerprint = function(e, r) {
      for (var n = /* @__PURE__ */ new Map(), i = 0, a = 0, o = r.length; a < o; a++) {
        var s = r[a], u = nu.fingerprint(e, s);
        n.has(u) ? n.get(u).push(i) : n.set(u, [i]), i++;
      }
      return n;
    }(this.unit, this.all)), this._byFingerprint;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "elementRingIndices", { get: function() {
    return this.index.elementRingIndices;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "elementAromaticRingIndices", { get: function() {
    return this.index.elementAromaticRingIndices;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ringComponentIndex", { get: function() {
    return this.index.ringComponentIndex;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ringComponents", { get: function() {
    return this.index.ringComponents;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "aromaticRings", { get: function() {
    return this._aromaticRings || (this._aromaticRings = function(e, r) {
      for (var n = [], i = 0, a = r.length; i < a; ++i) nu.isAromatic(e, r[i]) && n.push(i);
      return n;
    }(this.unit, this.all)), this._aromaticRings;
  }, enumerable: !1, configurable: !0 }), t;
}();
function B$(t, e) {
  for (var r = t.elements, n = t.model.atomicHierarchy.residueAtomSegments.index, i = n[r[e[0]]], a = 1, o = e.length; a < o; a++) if (i !== n[r[e[a]]]) return -1;
  return i;
}
function F$(t, e, r) {
  var n = t.byFingerprint.get(e);
  if (n) for (var i = 0, a = n.length; i < a; i++) {
    var o = n[i], s = B$(t.unit, t.all[o]);
    s >= 0 && (r.has(s) ? r.get(s).push(o) : r.set(s, [o]));
  }
}
function N$(t) {
  for (var e = [], r = t.elements, n = t.model.coarseHierarchy, i = n.spheres, a = n.gaussians, o = Fe.isSpheres(t) ? i.polymerRanges : a.polymerRanges, s = rn.transientSegments(o, r); s.hasNext; ) for (var u = s.move(), c = u.start, l = u.end, d = c; d < l; ++d) e.push(r[d]);
  return Ke.ofSortedArray(e);
}
function R$(t) {
  for (var e = [], r = t.elements, n = t.model.coarseHierarchy, i = n.spheres, a = n.gaussians, o = Fe.isSpheres(t) ? i.gapRanges : a.gapRanges, s = rn.transientSegments(o, r); s.hasNext; ) {
    var u = s.move(), c = u.start, l = u.end;
    e.push(r[c], r[l - 1]);
  }
  return Ke.ofSortedArray(e);
}
(function(t) {
  function e(n) {
    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 = UD(i), c = UD(o), l = !1;
      for (s = 0; s < a; s++) {
        var d = i[(s + u) % a], f = o[(s + c) % a];
        if (d !== f) {
          l = d < f;
          break;
        }
      }
      return l ? HD(i, u) : HD(o, c);
    }(n);
  }
  t.fingerprint = function(n, i) {
    for (var a = n.elements, o = n.model.atomicHierarchy.atoms.type_symbol, s = [], u = 0, c = i.length; u < c; u++) s[s.length] = o.value(a[i[u]]);
    return e(s);
  }, t.elementFingerprint = e;
  var r = /* @__PURE__ */ new Set(["B", "C", "N", "O", "SI", "P", "S", "GE", "AS", "SN", "SB", "BI"]);
  t.isAromatic = function(n, i) {
    var a = n.elements, o = n.bonds, s = o.b, u = o.offset, c = o.edgeProps.flags, l = n.model.atomicHierarchy.atoms, d = l.type_symbol;
    if (l.label_comp_id.value(n.elements[i[0]]) === "PRO") return !1;
    for (var f = 0, h = !1, m = 0, p = i.length; m < p; ++m) {
      var v = i[m];
      !h && r.has(d.value(a[v])) && (h = !0);
      for (var g = u[v], y = u[v + 1]; g < y; ++g) lr.is(16, c[g]) && Ke.has(i, s[g]) && (f += 1);
    }
    if (f === 2 * i.length) return !0;
    if (!h || i.length < 5) return !1;
    var b = Qd.calculateMomentsAxes(CR(n, i));
    return E.magnitude(b.dirC) < 0.05;
  }, t.getAltId = function(n, i) {
    for (var a = n.model.atomicHierarchy.atoms.label_alt_id, o = n.elements, s = 0, u = i.length; s < u; ++s) {
      var c = o[i[s]], l = a.value(c);
      if (l) return l;
    }
    return "";
  };
})(nu || (nu = {})), function(t) {
  t.create = function(e) {
    var r = I$(e);
    return new t(r, e);
  }, t.byFingerprintAndResidue = function(e, r) {
    for (var n = /* @__PURE__ */ new Map(), i = 0, a = r.length; i < a; i++)
      F$(e, r[i], n);
    return n;
  };
}(N3 || (N3 = {})), function(t) {
  function e(l) {
    return l[l.length - 1];
  }
  function r(l) {
    return l.length / 2;
  }
  function n(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, f) {
    if (a(l, f) > Ge.max(d) || e(l) < Ge.min(d)) return -1;
    for (var h = f, m = r(l); h < m; ++h) {
      var p = Se.ofRange(a(l, h), o(l, h));
      if (Ge.areIntersecting(p, d)) return h;
    }
    return -1;
  }
  t.ofSortedRanges = function(l) {
    return Ke.ofSortedArray(l);
  }, t.start = function(l) {
    return l[0];
  }, t.end = function(l) {
    return l[l.length - 1] + 1;
  }, t.min = function(l) {
    return l[0];
  }, t.max = e, t.size = function(l) {
    for (var d = 0, f = 0, h = l.length; f < h; f += 2) d += l[f + 1] - l[f] + 1;
    return d;
  }, t.count = r, t.startAt = n, t.endAt = i, t.minAt = a, t.maxAt = o, t.areEqual = function(l, d) {
    if (l.length !== d.length) return !1;
    for (var f = 0, h = l.length; f < h; ++f) if (l[f] !== d[f]) return !1;
    return !0;
  }, t.forEach = function(l, d) {
    for (var f = 0, h = 0, m = l.length; h < m; h += 2) for (var p = l[h], v = l[h + 1]; p <= v; ++p) d(p, f), ++f;
  }, t.has = function(l, d) {
    return s(l, d) !== -1;
  }, t.hasFrom = function(l, d, f) {
    return u(l, d, f) !== -1;
  }, t.firstIntersectionIndex = s, t.firstIntersectionIndexFrom = u, t.transientSegments = function(l, d) {
    return new c(l, d);
  };
  var c = function() {
    function l(d, f) {
      this.ranges = d, this.set = f, this.value = { index: 0, start: 0, end: 0 }, this.curIndex = 0, this.hasNext = !1, this.curIndex = s(d, f), this.hasNext = this.curIndex !== -1;
    }
    return l.prototype.updateValue = function() {
      this.value.index = this.curIndex, this.value.start = Ge.findPredecessorIndex(this.set, n(this.ranges, this.curIndex)), this.value.end = Ge.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;
  }();
  t.Iterator = c;
}(rn || (rn = {}));
var KD = E.zero();
function XD(t) {
  var e = function(r) {
    for (var n = r.conformation.invariantPosition, i = r.elements, a = new Float32Array(3 * i.length), o = 0, s = i.length; o < s; o++) n(i[o], KD), E.toArray(KD, a, 3 * o);
    return a;
  }(t);
  return Qd.ofPositions(e);
}
var cu = function() {
  function t(e) {
    this.minDist = [], this.maxDist = [], this.extrema = [], this.centroidHelper = new _p(), this.dir = function(r) {
      var n;
      switch (r) {
        case "6":
          n = Ze([], Hg, !0);
          break;
        case "14":
          n = Ze(Ze([], Hg, !0), Z6, !0);
          break;
        case "26":
          n = Ze(Ze(Ze([], Hg, !0), Z6, !0), YD, !0);
          break;
        case "98":
          n = Ze(Ze(Ze(Ze(Ze(Ze([], Hg, !0), Z6, !0), YD, !0), O$, !0), L$, !0), k$, !0);
      }
      return n.map(function(i) {
        var a = E.create(i[0], i[1], i[2]);
        return E.normalize(a, a);
      });
    }(e), this.reset();
  }
  return t.prototype.computeExtrema = function(e, r) {
    var n = E.dot(this.dir[e], r);
    n < this.minDist[e] && (this.minDist[e] = n, E.copy(this.extrema[2 * e], r)), n > this.maxDist[e] && (this.maxDist[e] = n, E.copy(this.extrema[2 * e + 1], r));
  }, t.prototype.computeSphereExtrema = function(e, r, n) {
    var i = E.dot(this.dir[e], r);
    i - n < this.minDist[e] && (this.minDist[e] = i - n, E.scaleAndSub(this.extrema[2 * e], r, this.dir[e], n)), i + n > this.maxDist[e] && (this.maxDist[e] = i + n, E.scaleAndAdd(this.extrema[2 * e + 1], r, this.dir[e], n));
  }, t.prototype.includeSphere = function(e) {
    if (Me.hasExtrema(e) && e.extrema.length > 1) for (var r = 0, n = e.extrema; r < n.length; r++) {
      var i = n[r];
      this.includePosition(i);
    }
    else this.includePositionRadius(e.center, e.radius);
  }, t.prototype.includePosition = function(e) {
    for (var r = 0, n = this.dir.length; r < n; ++r) this.computeExtrema(r, e);
  }, t.prototype.includePositionRadius = function(e, r) {
    for (var n = 0, i = this.dir.length; n < i; ++n) this.computeSphereExtrema(n, e, r);
  }, t.prototype.finishedIncludeStep = function() {
    for (var e = 0; e < this.extrema.length; e++) this.centroidHelper.includeStep(this.extrema[e]);
    this.centroidHelper.finishedIncludeStep();
  }, t.prototype.radiusSphere = function(e) {
    if (Me.hasExtrema(e) && e.extrema.length > 1) for (var r = 0, n = e.extrema; r < n.length; r++) {
      var i = n[r];
      this.radiusPosition(i);
    }
    else this.radiusPositionRadius(e.center, e.radius);
  }, t.prototype.radiusPosition = function(e) {
    this.centroidHelper.radiusStep(e);
  }, t.prototype.radiusPositionRadius = function(e, r) {
    this.centroidHelper.radiusSphereStep(e, r);
  }, t.prototype.getSphere = function(e) {
    return Me.setExtrema(this.centroidHelper.getSphere(e), Ze([], this.extrema, !0));
  }, t.prototype.getBox = function(e) {
    return $r.fromVec3Array(e || $r(), this.extrema);
  }, t.prototype.reset = function() {
    for (var e = 0, r = this.dir.length; e < r; ++e) this.minDist[e] = 1 / 0, this.maxDist[e] = -1 / 0, this.extrema[2 * e] = E(), this.extrema[2 * e + 1] = E();
    this.centroidHelper.reset();
  }, t;
}(), Hg = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], Z6 = [[1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1]], YD = [[1, 1, 0], [1, -1, 0], [1, 0, 1], [1, 0, -1], [0, 1, 1], [0, 1, -1]], O$ = [[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]], L$ = [[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]], k$ = [[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]], WD = E.set, G$ = new cu("14"), z$ = new cu("98"), qg = E();
function xp(t) {
  var e = t.x, r = t.y, n = t.z, i = t.radius, a = t.indices, o = Ge.size(a);
  if (o > 25e4) {
    var s = $r.computeBounding(t);
    return { box: s, sphere: Me.fromBox3D(Me(), s) };
  }
  var u = function(h) {
    return h > 1e4 ? G$ : z$;
  }(o);
  u.reset();
  for (var c = 0; c < o; c++) {
    var l = Ge.getAt(a, c);
    WD(qg, e[l], r[l], n[l]), u.includePositionRadius(qg, i && i[l] || 0);
  }
  for (u.finishedIncludeStep(), c = 0; c < o; c++)
    l = Ge.getAt(a, c), WD(qg, e[l], r[l], n[l]), u.radiusPositionRadius(qg, i && i[l] || 0);
  var d = u.getSphere();
  if (!i && Me.hasExtrema(d) && o <= d.extrema.length) {
    var f = [];
    for (c = 0; c < o; c++)
      l = Ge.getAt(a, c), f.push(E.create(e[l], r[l], n[l]));
    Me.setExtrema(d, f);
  }
  return { box: u.getBox(), sphere: d };
}
var R3, Da, Fe, O3, V$ = function() {
  function t() {
    this.data = /* @__PURE__ */ new Map();
  }
  return t.prototype.get = function(e) {
    var r = Ke.hashCode(e);
    if (this.data.has(r)) for (var n = 0, i = this.data.get(r); n < i.length; n++) {
      var a = i[n], o = a[0], s = a[1];
      if (Ke.areEqual(e, o)) return s;
    }
  }, t.prototype.set = function(e, r) {
    var n = Ke.hashCode(e);
    if (this.data.has(n)) {
      for (var i = this.data.get(n), a = 0, o = i; a < o.length; a++) {
        var s = o[a];
        if (Ke.areEqual(e, s[0])) return void (s[1] = r);
      }
      i.push([e, r]);
    } else this.data.set(n, [[e, r]]);
  }, t.get = function(e) {
    return e._dynamicPropertyData.ElementSetIntraBondCache || (e._dynamicPropertyData.ElementSetIntraBondCache = new t()), e._dynamicPropertyData.ElementSetIntraBondCache;
  }, t;
}(), H_ = function() {
  function t(e, r, n) {
    this.operatorsProvider = n, this.id = e, this.details = r;
  }
  return Object.defineProperty(t.prototype, "operatorGroups", { get: function() {
    return this._operators || (this._operators = this.operatorsProvider()), this._operators;
  }, enumerable: !1, configurable: !0 }), t;
}();
function U$(t, e, r) {
  if (!t._rowCount) return [];
  for (var n = function(o) {
    for (var s = o.id, u = o.matrix, c = o.vector, l = o._schema, d = /* @__PURE__ */ new Map(), f = 0, h = o._rowCount; f < h; f++) {
      var m = Qn.toMat4(he(), l.matrix.space, u.value(f)), p = Qn.toVec3(E(), l.vector.space, c.value(f));
      he.setTranslation(m, p), he.setValue(m, 3, 3, 1), d.set(s.value(f), m);
    }
    return d;
  }(r), i = [], a = 0; a < t._rowCount; a++) i[i.length] = H$(t, e, a, n);
  return i;
}
function H$(t, e, r, n) {
  for (var i = t.id.value(r), a = t.details.value(r), o = [], s = e.assembly_id, u = e.oper_expression, c = e.asym_id_list, l = 0, d = e._rowCount; l < d; l++) s.value(l) === i && (o[o.length] = { assemblyId: i, expression: u.value(l), asymIds: c.value(l) });
  return H_.create(i, a, /* @__PURE__ */ function(f, h) {
    return function() {
      for (var m = [], p = 0, v = 0; v < f.length; v++) {
        var g = f[v], y = q$(X$(g.expression)), b = K$(h, y, p, g.assemblyId), S = En.generators.atoms({ chainTest: En.pred.and(En.pred.eq(function(_) {
          return Qe.unit.operator_name(_.element);
        }, wn.DefaultName), En.pred.inSet(function(_) {
          return Qe.chain.label_asym_id(_.element);
        }, g.asymIds)) });
        m[m.length] = { selector: S, operators: b }, p += b.length;
      }
      return m;
    };
  }(o, n));
}
function q$(t) {
  for (var e = [], r = [], n = 0; n < t.length; n++) r[n] = "";
  return AR(t, e, t.length - 1, r), e;
}
function AR(t, e, r, n) {
  if (r < 0) e[e.length] = n.slice(0);
  else for (var i = t[r], a = i.length, o = 0; o < a; o++) n[r] = i[o], AR(t, e, r - 1, n);
}
function K$(t, e, r, n) {
  for (var i = [], a = r, o = 0, s = e; o < s.length; o++) {
    for (var u = s[o], c = he.identity(), l = 0; l < u.length; l++) he.mul(c, c, t.get(u[l]));
    a++, i[i.length] = wn.create("ASM_".concat(a), c, { assembly: { id: n, operId: a, operList: u } });
  }
  return i;
}
function X$(t) {
  for (var e, r = /\(?([^\(\)]+)\)?]*/g, n = [], i = []; e = r.exec(t); ) n[n.length] = e[1];
  return n.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 Y$(t) {
  if (t._rowCount !== 0) {
    for (var e = t.id, r = t.matrix, n = t.vector, i = rr.struct_ncs_oper.matrix.space, a = rr.struct_ncs_oper.vector.space, o = [], s = 0; s < t._rowCount; s++) {
      var u = Qn.toMat3(Wi(), i, r.value(s)), c = Qn.toVec3(E(), a, n.value(s));
      if (wn.checkIfRotationAndTranslation(u, c) && (t.code.value(s) !== "given" || Wi.isIdentity(u) || E.isZero(c))) {
        var l = e.value(s);
        o[o.length] = wn.ofRotationAndOffset("ncs_".concat(l), u, c, l);
      }
    }
    return o;
  }
}
function W$(t) {
  var e = t.bonds, r = e.b, n = e.edgeProps, i = e.offset;
  n.order;
  for (var a = n.flags, o = t.rings.elementAromaticRingIndices, s = [], u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = function(y, b, S) {
    var _ = s.length;
    s.push(Ke.ofUnsortedArray([y, b, S])), u.set(b3(y, b), S), c.has(y) ? c.get(y).push(_) : c.set(y, [_]);
  }, d = 0; d < t.elements.length; d++)
    if (!o.has(d) && !(i[d + 1] - i[d] + 1 < 2)) {
      for (var f = [], h = i[d], m = i[d + 1]; h < m; h++) {
        var p = a[h];
        lr.is(p, 16) && f.push(r[h]);
      }
      if (f.length >= 2) {
        l(d, f[0], f[1]);
        for (var v = 1, g = f.length; v < g; v++) l(d, f[v], f[0]);
      }
    }
  return { getThirdElement: function(y, b) {
    return u.get(b3(y, b));
  }, getTripletIndices: function(y) {
    return c.get(y);
  }, triplets: s };
}
function wR() {
  return { result: O3.create(), closeUnitsResult: af.create(), unitGroupResult: af.create() };
}
(function(t) {
  t.create = function(e, r, n) {
    return new t(e, r, n);
  };
})(H_ || (H_ = {})), function(t) {
  t.Default = { assemblies: [], spacegroup: ko.ZeroP1, isNonStandardCrystalFrame: !1 }, t.findAssembly = function(e, r) {
    var n = r.toLocaleLowerCase(), i = Da.Provider.get(e);
    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() === n;
    }) : void 0;
  }, t.getUnitcellLabel = function(e) {
    var r = e.spacegroup, n = r.cell, i = r.name, a = r.num, o = n.size, s = n.anglesInRadians, u = o[0].toFixed(2), c = o[1].toFixed(2), l = o[2].toFixed(2), d = Ua(s[0]).toFixed(2), f = Ua(s[1]).toFixed(2), h = Ua(s[2]).toFixed(2), m = [];
    return m.push("Unit Cell <b>".concat(i, "</b> #").concat(a)), m.push("".concat(u, "×").concat(c, "×").concat(l, " Å")), m.push("α=".concat(d, "° β=").concat(f, "° γ=").concat(h, "°")), m.join(" | ");
  };
}(R3 || (R3 = {})), function(t) {
  t.Descriptor = { name: "model_symmetry" }, t.Provider = gc.create(t.Descriptor), t.fromData = function(e) {
    var r = U$(e.pdbx_struct_assembly, e.pdbx_struct_assembly_gen, e.pdbx_struct_oper_list), n = function(i, a) {
      if (i._rowCount === 0 || a._rowCount === 0) return ko.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 ko.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 ko.ZeroP1;
      var f = function(m) {
        var p = m.Int_Tables_number.value(0), v = m["space_group_name_H-M"].value(0);
        return m.Int_Tables_number.isDefined ? m["space_group_name_H-M"].isDefined ? v : p : v;
      }(i), h = au.create(f, E.create(o, s, u), E.scale(E(), E.create(c, l, d), Math.PI / 180));
      return ko.create(h);
    }(e.symmetry, e.cell);
    return { assemblies: r, spacegroup: n, isNonStandardCrystalFrame: (e.atom_sites._rowCount, !1), ncsOperators: Y$(e.struct_ncs_oper) };
  }, t.fromCell = function(e, r) {
    var n = au.create("P 1", e, r);
    return { assemblies: [], spacegroup: ko.create(n), isNonStandardCrystalFrame: !1 };
  };
}(Da || (Da = {})), function(t) {
  function e(g) {
    for (var y = [], b = 0, S = g.length; b < S; b++) y.push(g[b].id);
    return ro(y);
  }
  function r(g) {
    var y = {};
    return { elements: g[0].elements, units: g, get unitIndexMap() {
      return y.unitIndexMap || (y.unitIndexMap = function(b) {
        for (var S = bc.Mutable(), _ = 0, x = b.length; _ < x; _++) S.set(b[_].id, _);
        return S;
      }(g)), y.unitIndexMap;
    }, hashCode: n(g[0]), transformHash: e(g) };
  }
  function n(g) {
    return Wp(g.invariantId, Ke.hashCode(g.elements));
  }
  var i;
  t.isAtomic = function(g) {
    return g.kind === 0;
  }, t.isCoarse = function(g) {
    return g.kind === 1 || g.kind === 2;
  }, t.isSpheres = function(g) {
    return g.kind === 1;
  }, t.isGaussians = function(g) {
    return g.kind === 2;
  }, t.create = function(g, y, b, S, _, x, C, A, w) {
    switch (_) {
      case 0:
        return new a(g, y, b, S, x, A, wn.createMapping(C, x.atomicConformation, void 0), w ?? o());
      case 1:
        return f(g, y, b, S, x, 1, A, wn.createMapping(C, x.coarseConformation.spheres, function(I) {
          var P = I.coarseConformation.spheres.radius;
          return function(M) {
            return P[M];
          };
        }(x)), w ?? c());
      case 2:
        return f(g, y, b, S, x, 2, A, wn.createMapping(C, x.coarseConformation.gaussians, function(I) {
          return 0;
        }), w ?? c());
    }
  }, t.SymmetryGroup = r, function(g) {
    g.areInvariantElementsEqual = function(y, b) {
      return y.hashCode === b.hashCode && Ke.areEqual(y.elements, b.elements);
    }, g.getUnitSymmetryGroupsIndexMap = function(y) {
      for (var b = bc.Mutable(), S = 0, _ = y.length; S < _; ++S) for (var x = y[S], C = 0, A = x.units.length; C < A; ++C) b.set(x.units[C].id, S);
      return b;
    };
  }(r = t.SymmetryGroup || (t.SymmetryGroup = {})), t.conformationId = function(g) {
    return t.isAtomic(g) ? g.model.atomicConformation.id : g.model.coarseConformation.id;
  }, t.hashUnit = n, (i = t.Traits || (t.Traits = {})).is = Ga.has, i.create = Ga.create;
  var a = function() {
    function g(y, b, S, _, x, C, A, w) {
      this.kind = 0, this.objectPrimitive = "atomistic", this.id = y, this.invariantId = b, this.chainGroupId = S, this.traits = _, this.model = x, this.elements = C, this.conformation = A, this.residueIndex = x.atomicHierarchy.residueAtomSegments.index, this.chainIndex = x.atomicHierarchy.chainAtomSegments.index, this.props = w;
    }
    return g.prototype.getChild = function(y) {
      return y.length === this.elements.length ? this : new g(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, y, this.conformation, o());
    }, g.prototype.applyOperator = function(y, b, S) {
      S === void 0 && (S = !1);
      var _ = S ? b : wn.compose(this.conformation.operator, b);
      return new g(y, this.invariantId, this.chainGroupId, this.traits, this.model, this.elements, wn.createMapping(_, this.model.atomicConformation, this.conformation.r), this.props);
    }, g.prototype.remapModel = function(y, b, S) {
      var _, x;
      S || (S = O(O({}, this.props), { bonds: b && !(!((x = (_ = this.props.bonds) === null || _ === void 0 ? void 0 : _.props) === null || x === void 0) && x.canRemap) ? void 0 : h(this, this.props.bonds, y, b) }), t.isSameConformation(this, y) || (S.boundary = void 0, S.lookup3d = void 0, S.principalAxes = void 0));
      var C = this.conformation.operator, A = Da.Provider.get(y);
      if (C.spgrOp !== -1 && A && A !== Da.Provider.get(this.model)) {
        var w = C.hkl, I = w[0], P = w[1], M = w[2], T = A.spacegroup.cell.toFractional, F = E.transformMat4(E(), pn.getCenter(y), T);
        C = ko.getSymmetryOperatorRef(A.spacegroup, C.spgrOp, I, P, M, F);
      }
      var N = this.model.atomicConformation !== y.atomicConformation || C !== this.conformation.operator ? wn.createMapping(C, y.atomicConformation) : this.conformation;
      return new g(this.id, this.invariantId, this.chainGroupId, this.traits, y, this.elements, N, S);
    }, Object.defineProperty(g.prototype, "boundary", { get: function() {
      if (this.props.boundary) return this.props.boundary;
      var y = this.model.atomicConformation, b = y.x, S = y.y, _ = y.z;
      return this.props.boundary = xp({ x: b, y: S, z: _, indices: this.elements }), this.props.boundary;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "lookup3d", { get: function() {
      if (this.props.lookup3d) return this.props.lookup3d;
      var y = this.model.atomicConformation, b = y.x, S = y.y, _ = y.z;
      return this.props.lookup3d = S0({ x: b, y: S, z: _, indices: this.elements }, this.boundary), this.props.lookup3d;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "principalAxes", { get: function() {
      return this.props.principalAxes || (this.props.principalAxes = XD(this)), this.props.principalAxes;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "bonds", { get: function() {
      if (this.props.bonds) return this.props.bonds;
      var y = V$.get(this.model), b = y.get(this.elements);
      return b || (b = C$(this), y.set(this.elements, b)), this.props.bonds = b, this.props.bonds;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "rings", { get: function() {
      return this.props.rings || (this.props.rings = N3.create(this)), this.props.rings;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "resonance", { get: function() {
      return this.props.resonance || (this.props.resonance = function(y) {
        return { delocalizedTriplets: W$(y) };
      }(this)), this.props.resonance;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "polymerElements", { get: function() {
      return this.props.polymerElements || (this.props.polymerElements = function(y) {
        for (var b = [], S = y.elements, _ = y.model, x = y.model.atomicHierarchy.residueAtomSegments, C = _.atomicHierarchy.derived.residue.traceElementIndex, A = rn.transientSegments(y.model.atomicRanges.polymerRanges, S), w = Qt.transientSegments(x, S); A.hasNext; ) {
          var I = A.move();
          for (w.setSegment(I); w.hasNext; ) {
            var P = w.move(), M = P.start, T = P.end, F = P.index;
            if (Ge.areIntersecting(Se.ofRange(S[M], S[T - 1]), S)) {
              var N = C[F];
              b.push(N === -1 ? x.offsets[F] : N);
            }
          }
        }
        return Ke.ofSortedArray(b);
      }(this)), this.props.polymerElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "gapElements", { get: function() {
      return this.props.gapElements || (this.props.gapElements = function(y) {
        for (var b = [], S = y.elements, _ = y.model, x = y.residueIndex, C = y.model.atomicHierarchy.residueAtomSegments, A = _.atomicHierarchy.derived.residue.traceElementIndex, w = rn.transientSegments(y.model.atomicRanges.gapRanges, y.elements); w.hasNext; ) {
          var I = w.move(), P = x[S[I.start]], M = x[S[I.end - 1]], T = A[P], F = A[M];
          b.push(T === -1 ? C.offsets[P] : T), b.push(F === -1 ? C.offsets[M] : F);
        }
        return Ke.ofSortedArray(b);
      }(this)), this.props.gapElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "nucleotideElements", { get: function() {
      return this.props.nucleotideElements || (this.props.nucleotideElements = function(y) {
        for (var b = [], S = y.elements, _ = y.model, x = _.atomicHierarchy, C = x.chainAtomSegments, A = x.residueAtomSegments, w = _.atomicHierarchy.derived.residue, I = w.moleculeType, P = w.traceElementIndex, M = Qt.transientSegments(C, S), T = Qt.transientSegments(A, S); M.hasNext; ) for (T.setSegment(M.move()); T.hasNext; ) {
          var F = T.move().index;
          if (Qp(I[F])) {
            var N = P[F];
            b.push(N === -1 ? A.offsets[F] : N);
          }
        }
        return Ke.ofSortedArray(b);
      }(this)), this.props.nucleotideElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "proteinElements", { get: function() {
      return this.props.proteinElements || (this.props.proteinElements = function(y) {
        for (var b = [], S = y.elements, _ = y.model, x = _.atomicHierarchy, C = x.chainAtomSegments, A = x.residueAtomSegments, w = _.atomicHierarchy.derived.residue, I = w.moleculeType, P = w.traceElementIndex, M = Qt.transientSegments(C, S), T = Qt.transientSegments(A, S); M.hasNext; ) for (T.setSegment(M.move()); T.hasNext; ) {
          var F = T.move().index;
          if (hR(I[F])) {
            var N = P[F];
            b.push(N === -1 ? A.offsets[F] : N);
          }
        }
        return Ke.ofSortedArray(b);
      }(this)), this.props.proteinElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "residueCount", { get: function() {
      if (this.props.residueCount !== void 0) return this.props.residueCount;
      for (var y = 0, b = Qt.transientSegments(this.model.atomicHierarchy.residueAtomSegments, this.elements); b.hasNext; ) b.move(), y += 1;
      return this.props.residueCount = y, this.props.residueCount;
    }, enumerable: !1, configurable: !0 }), g.prototype.getResidueIndex = function(y) {
      return this.residueIndex[this.elements[y]];
    }, g;
  }();
  function o() {
    return {};
  }
  t.Atomic = a;
  var s = function() {
    function g(y, b, S, _, x, C, A, w, I) {
      this.kind = C, this.objectPrimitive = C === 1 ? "sphere" : "gaussian", this.id = y, this.invariantId = b, this.chainGroupId = S, this.traits = _, this.model = x, this.elements = A, this.conformation = w, this.coarseElements = C === 1 ? x.coarseHierarchy.spheres : x.coarseHierarchy.gaussians, this.coarseConformation = C === 1 ? x.coarseConformation.spheres : x.coarseConformation.gaussians, this.props = I;
    }
    return g.prototype.getChild = function(y) {
      return y.length === this.elements.length ? this : f(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, y, this.conformation, c());
    }, g.prototype.applyOperator = function(y, b, S) {
      S === void 0 && (S = !1);
      var _ = S ? b : wn.compose(this.conformation.operator, b);
      return f(y, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, this.elements, wn.createMapping(_, this.getCoarseConformation(), this.conformation.r), this.props);
    }, g.prototype.remapModel = function(y, b, S) {
      var _ = this.getCoarseConformation(), x = u(this.kind, y);
      S || (S = O({}, this.props), t.isSameConformation(this, y) || (S.boundary = void 0, S.lookup3d = void 0, S.principalAxes = void 0));
      var C = _ !== x ? wn.createMapping(this.conformation.operator, x) : this.conformation;
      return new g(this.id, this.invariantId, this.chainGroupId, this.traits, y, this.kind, this.elements, C, S);
    }, Object.defineProperty(g.prototype, "boundary", { get: function() {
      if (this.props.boundary) return this.props.boundary;
      var y = this.getCoarseConformation(), b = y.x, S = y.y, _ = y.z;
      return this.props.boundary = xp({ x: b, y: S, z: _, indices: this.elements }), this.props.boundary;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "lookup3d", { get: function() {
      if (this.props.lookup3d) return this.props.lookup3d;
      var y = this.getCoarseConformation(), b = y.x, S = y.y, _ = y.z;
      return this.props.lookup3d = S0({ x: b, y: S, z: _, indices: this.elements }, this.boundary), this.props.lookup3d;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "principalAxes", { get: function() {
      return this.props.principalAxes || (this.props.principalAxes = XD(this)), this.props.principalAxes;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "polymerElements", { get: function() {
      return this.props.polymerElements || (this.props.polymerElements = N$(this)), this.props.polymerElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "gapElements", { get: function() {
      return this.props.gapElements || (this.props.gapElements = R$(this)), this.props.gapElements;
    }, enumerable: !1, configurable: !0 }), g.prototype.getCoarseConformation = function() {
      return u(this.kind, this.model);
    }, g;
  }();
  function u(g, y) {
    return g === 1 ? y.coarseConformation.spheres : y.coarseConformation.gaussians;
  }
  function c() {
    return {};
  }
  var l = function(g) {
    function y() {
      return g !== null && g.apply(this, arguments) || this;
    }
    return ka(y, g), y;
  }(s);
  t.Spheres = l;
  var d = function(g) {
    function y() {
      return g !== null && g.apply(this, arguments) || this;
    }
    return ka(y, g), y;
  }(s);
  function f(g, y, b, S, _, x, C, A, w) {
    return new s(g, y, b, S, _, x, C, A, w);
  }
  function h(g, y, b, S) {
    var _;
    if (y) {
      if (g.model.atomicConformation.id === b.atomicConformation.id) return y;
      var x = Xi.Provider.get(g.model);
      if (x) {
        var C = Xi.Provider.get(b);
        return C && x !== C ? void 0 : y;
      }
      return !((_ = y.props) === null || _ === void 0) && _.canRemap || !S || m(g, b) ? y : void 0;
    }
  }
  function m(g, y) {
    var b = pn.CoordinatesHistory.get(pn.getRoot(y));
    if (b) return b.areEqual(g.elements, g.kind, y);
    for (var S = g.elements, _ = g.conformation.coordinates, x = _.x, C = _.y, A = _.z, w = p(g.kind, y), I = w.x, P = w.y, M = w.z, T = 0, F = S.length; T < F; T++) {
      var N = S[T];
      if (x[N] !== I[N] || C[N] !== P[N] || A[N] !== M[N]) return !1;
    }
    return !0;
  }
  function p(g, y) {
    return g === 0 ? y.atomicConformation : g === 1 ? y.coarseConformation.spheres : y.coarseConformation.gaussians;
  }
  function v(g, y) {
    return g === 0 ? y.atomicHierarchy : g === 1 ? y.coarseHierarchy.spheres : y.coarseHierarchy.gaussians;
  }
  t.Gaussians = d, t.areSameChainOperatorGroup = function(g, y) {
    return g.chainGroupId === y.chainGroupId && g.conformation.operator.name === y.conformation.operator.name;
  }, t.areOperatorsEqual = function(g, y) {
    return he.areEqual(g.conformation.operator.matrix, y.conformation.operator.matrix, 1e-6);
  }, t.areConformationsEqual = function(g, y) {
    return !!Ke.areEqual(g.elements, y.elements) && m(g, y.model);
  }, t.isSameConformation = m, t.getModelConformationOfKind = p, t.getConformation = function(g) {
    return p(g.kind, g.model);
  }, t.getModelHierarchyOfKind = v, t.getHierarchy = function(g) {
    return v(g.kind, g.model);
  };
}(Fe || (Fe = {})), function(t) {
  t.add = function(e, r, n, i) {
    e.indices[e.count] = n, e.units[e.count] = r, e.squaredDistances[e.count] = i, e.count++;
  }, t.create = function() {
    return { count: 0, indices: [], units: [], squaredDistances: [] };
  }, t.copy = function(e, r) {
    for (var n = 0; n < r.count; ++n) e.indices[n] = r.indices[n], e.units[n] = r.units[n], e.squaredDistances[n] = r.squaredDistances[n];
    return e.count = r.count, e;
  };
}(O3 || (O3 = {}));
var gt, So, j$ = function() {
  function t(e) {
    this.structure = e, this.pivot = E(), this.findContext = wR();
    for (var r = e.units, n = e.boundary, i = r.length, a = new Float32Array(i), o = new Float32Array(i), s = new Float32Array(i), u = new Float32Array(i), c = E(), l = 0; l < i; l++) {
      var d = r[l], f = d.boundary.sphere;
      E.transformMat4(c, f.center, d.conformation.operator.matrix), a[l] = c[0], o[l] = c[1], s[l] = c[2], u[l] = f.radius;
    }
    var h = { x: a, y: o, z: s, radius: u, indices: Ge.ofBounds(0, i) };
    this.unitLookup = S0(h, n);
  }
  return t.prototype.findUnitIndices = function(e, r, n, i) {
    return this.unitLookup.find(e, r, n, i);
  }, t.prototype.find = function(e, r, n, i, a) {
    return this._find(e, r, n, i, a ?? this.findContext);
  }, t.prototype._find = function(e, r, n, i, a) {
    af.reset(a.result);
    var o = this.structure.units, s = this.unitLookup.find(e, r, n, 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]];
      E.set(this.pivot, e, r, n), l.conformation.operator.isIdentity || E.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), f = 0, h = d.count; f < h; f++) O3.add(a.result, l, d.indices[f], d.squaredDistances[f]);
    }
    return a.result;
  }, t.prototype.findIntoBuilder = function(e, r, n, i, a) {
    var o = this.structure.units, s = this.unitLookup.find(e, r, n, i);
    if (s.count !== 0) for (var u = 0, c = s.count; u < c; u++) {
      var l = o[s.indices[u]];
      E.set(this.pivot, e, r, n), l.conformation.operator.isIdentity || E.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 f = l.elements;
        a.beginUnit(l.id);
        for (var h = 0, m = d.count; h < m; h++) a.addElement(f[d.indices[h]]);
        a.commitUnit();
      }
    }
  }, t.prototype.findIntoBuilderIf = function(e, r, n, i, a, o) {
    var s = this.structure.units, u = this.unitLookup.find(e, r, n, i);
    if (u.count !== 0) for (var c = at.create(this.structure), l = 0, d = u.count; l < d; l++) {
      var f = s[u.indices[l]];
      E.set(this.pivot, e, r, n), f.conformation.operator.isIdentity || E.transformMat4(this.pivot, this.pivot, f.conformation.operator.inverse);
      var h = f.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], i);
      if (h.count !== 0) {
        var m = f.elements;
        c.unit = f, a.beginUnit(f.id);
        for (var p = 0, v = h.count; p < v; p++) c.element = m[h.indices[p]], o(c) && a.addElement(c.element);
        a.commitUnit();
      }
    }
  }, t.prototype.findIntoBuilderWithRadius = function(e, r, n, i, a, o, s, u) {
    var c = this.structure.units, l = this.unitLookup.find(e, r, n, o);
    if (l.count !== 0) for (var d = at.create(this.structure), f = i + a + o, h = 0, m = l.count; h < m; h++) {
      var p = c[l.indices[h]];
      E.set(this.pivot, e, r, n), p.conformation.operator.isIdentity || E.transformMat4(this.pivot, this.pivot, p.conformation.operator.inverse);
      var v = p.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], f);
      if (v.count !== 0) {
        var g = p.elements;
        d.unit = p, u.beginUnit(p.id);
        for (var y = 0, b = v.count; y < b; y++) {
          d.element = g[v.indices[y]];
          var S = s(d);
          Math.sqrt(v.squaredDistances[y]) - i - S > o || u.addElement(g[v.indices[y]]);
        }
        u.commitUnit();
      }
    }
  }, t.prototype.check = function(e, r, n, i) {
    var a = this.structure.units, o = this.unitLookup.find(e, r, n, i);
    if (o.count === 0) return !1;
    for (var s = 0, u = o.count; s < u; s++) {
      var c = a[o.indices[s]];
      if (E.set(this.pivot, e, r, n), c.conformation.operator.isIdentity || E.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(t.prototype, "boundary", { get: function() {
    return this.structure.boundary;
  }, enumerable: !1, configurable: !0 }), t;
}();
function L3(t, e) {
  if (e.length === 0) return tt.Empty;
  if (e.length === 1) return e[0];
  for (var r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), i = 0, a = e; i < a.length; i++) for (var o = a[i].units, s = 0, u = o.length; s < u; s++) {
    var c = o[s];
    if (r.has(c.id)) {
      if (n.has(c.id)) continue;
      var l = Ke.union(r.get(c.id), c.elements);
      r.set(c.id, l), l.length === t.unitMap.get(c.id).elements.length && n.add(c.id);
    } else r.set(c.id, c.elements), c.elements.length === t.unitMap.get(c.id).elements.length && n.add(c.id);
  }
  var d = t.subsetBuilder(!0);
  return r.forEach(Z$, d), d.getStructure();
}
function Z$(t, e) {
  this.setUnit(e, t);
}
function tx(t, e) {
  if (t === e) return !0;
  var r, n;
  t.units.length < e.units.length ? (r = t, n = e) : (r = e, n = t);
  for (var i = r.units, a = n.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 (Ke.areIntersecting(u.elements, c.elements)) return !0;
    }
  }
  return !1;
}
function DR(t, e) {
  if (t === e) return tt.Empty;
  if (!tx(t, e)) return t;
  for (var r = t.units, n = e.unitMap, i = [], a = 0, o = r.length; a < o; a++) {
    var s = r[a];
    if (n.has(s.id)) {
      var u = n.get(s.id), c = Ke.subtract(s.elements, u.elements);
      c.length > 0 && (i[i.length] = s.getChild(c));
    } else i[i.length] = s;
  }
  return tt.create(i, { parent: t.parent || e.parent });
}
function q_(t) {
  return lr.isCovalent(t.atomicBond.type);
}
function ER(t, e, r) {
  return { groupedUnits: t, ranges: e, set: r };
}
function IR(t) {
  return function(e) {
    var r = { hash: e.inputStructure.hashCode, elements: t };
    return gt.Sequence(e.inputStructure, [So.toStructure(r, e.inputStructure)]);
  };
}
(function(t) {
  function e(l, d) {
    return { kind: "singletons", source: l, structure: d };
  }
  function r(l, d) {
    return { kind: "sequence", source: l, structures: d };
  }
  function n(l) {
    return e(l, tt.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) ? tt.Empty : i(l) ? l.structure : L3(l.source, l.structures);
  }
  function s(l, d, f) {
    return d.length === 0 ? n(l) : f ? e(l, L3(l, d)) : r(l, d);
  }
  t.Singletons = e, t.Sequence = r, t.Empty = n, t.isSingleton = i, t.isEmpty = a, t.structureCount = function(l) {
    return i(l) ? l.structure.elementCount : l.structures.length;
  }, t.unionStructure = o, t.toLociWithCurrentUnits = function(l) {
    for (var d = [], f = l.source.unitMap, h = 0, m = o(l).units; h < m.length; h++) {
      var p = m[h];
      p === f.get(p.id) ? d[d.length] = { unit: p, indices: Ge.ofBounds(0, p.elements.length) } : d[d.length] = { unit: p, indices: Ge.ofSortedArray(Ke.indicesOf(f.get(p.id).elements, p.elements)) };
    }
    return Xe(l.source, d);
  }, t.toLociWithSourceUnits = function(l) {
    for (var d = [], f = l.source.unitMap, h = 0, m = o(l).units; h < m.length; h++) {
      var p = m[h];
      if (f.has(p.id)) {
        var v = f.get(p.id);
        d[d.length] = v === p ? { unit: v, indices: Ge.ofBounds(0, v.elements.length) } : { unit: v, indices: Ge.ofSortedArray(Ke.indicesOf(v.elements, p.elements)) };
      }
    }
    return Xe(l.source, d);
  };
  var u = function() {
    function l(d) {
      this.source = d, this.structures = [], this.allSingletons = !0;
    }
    return l.prototype.add = function(d) {
      var f = d.elementCount;
      f !== 0 && (this.structures[this.structures.length] = d, f !== 1 && (this.allSingletons = !1));
    }, l.prototype.getSelection = function() {
      return s(this.source, this.structures, this.allSingletons);
    }, l;
  }(), c = function() {
    function l(d) {
      this.structure = d, this.structures = [], this.allSingletons = !0, this.uniqueSets = W9(tt.hashCode, tt.areUnitIdsAndIndicesEqual);
    }
    return l.prototype.add = function(d) {
      var f = d.elementCount;
      f !== 0 && this.uniqueSets.add(d) && (this.structures[this.structures.length] = d, f !== 1 && (this.allSingletons = !1));
    }, l.prototype.getSelection = function() {
      return s(this.structure, this.structures, this.allSingletons);
    }, l;
  }();
  t.LinearBuilder = function(l) {
    return new u(l);
  }, t.UniqueBuilder = function(l) {
    return new c(l);
  }, t.forEach = function(l, d) {
    var f = 0;
    if (t.isSingleton(l)) for (var h = 0, m = l.structure.units; h < m.length; h++) for (var p = m[h], v = p.elements, g = 0, y = v.length; g < y; g++)
      d(tt.create([p.getChild(Ke.ofSingleton(v[g]))], { parent: l.source }), f++);
    else for (var b = 0, S = l.structures; b < S.length; b++)
      d(S[b], f++);
  }, t.withInputStructure = function(l, d) {
    return i(l) ? e(d, l.structure) : r(d, l.structures);
  };
})(gt || (gt = {})), function(t) {
  function e(i) {
    for (var a = [], o = 0, s = i.elements; o < s.length; o++) {
      var u = (b = s[o]).unit, c = b.indices;
      if (Ge.size(c) !== 0) {
        var l = [], d = [];
        if (Ge.isInterval(c)) Ge.size(c) === 1 ? d.push(Se.min(c)) : l.push(Se.min(c), Se.max(c));
        else for (var f = 0, h = c.length; f < h; ) {
          var m = f;
          for (f++; f < h && c[f - 1] + 1 === c[f]; ) f++;
          var p = f;
          if (p - m > 2) l.push(c[m], c[p - 1]);
          else for (var v = m; v < p; v++) d[d.length] = c[v];
        }
        a.push({ unit: u, set: Ke.ofSortedArray(d), ranges: rn.ofSortedRanges(l) });
      }
    }
    for (var g = /* @__PURE__ */ new Map(), y = (f = 0, a.length); f < y; ++f) {
      var b, S, _ = Wp(ro((b = a[f]).ranges), ro(b.set));
      g.has(_) ? (S = g.get(_).groupedUnits).has(b.unit.invariantId) ? S.get(b.unit.invariantId).push(b.unit.id) : S.set(b.unit.invariantId, [b.unit.id]) : ((S = /* @__PURE__ */ new Map()).set(b.unit.invariantId, [b.unit.id]), g.set(_, { groupedUnits: S, set: b.set, ranges: b.ranges }));
    }
    var x = [];
    return g.forEach(function(C) {
      var A = [];
      C.groupedUnits.forEach(function(w) {
        return A.push(Ke.ofUnsortedArray(w));
      }), A.sort(function(w, I) {
        return w[0] - I[0];
      }), x.push({ groupedUnits: A, set: C.set, ranges: C.ranges });
    }), { hash: i.structure.hashCode, elements: x };
  }
  function r(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 n(i) {
    return Nt.internal.generator.bundleElement({ groupedUnits: Nt.core.type.list(i.groupedUnits.map(function(a) {
      return Nt.core.type.list(a);
    })), ranges: Nt.core.type.list(i.ranges), set: Nt.core.type.list(i.set) });
  }
  t.Empty = { hash: -1, elements: [] }, t.fromSubStructure = function(i, a) {
    return e(gt.toLociWithSourceUnits(gt.Singletons(i, a)));
  }, t.fromSelection = function(i) {
    return e(gt.toLociWithSourceUnits(i));
  }, t.fromLoci = e, t.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(h) {
      var m = r(h, a);
      if (m.length === 0) return "continue";
      var p = void 0;
      if (c.ranges.length === 0) p = c.set;
      else if (c.set.length === 0) if (c.ranges.length === 2) p = Se.ofRange(c.ranges[0], c.ranges[1]);
      else {
        var v = new Int32Array(rn.size(c.ranges));
        rn.forEach(c.ranges, function(x, C) {
          return v[C] = x;
        }), p = Ke.ofSortedArray(v);
      }
      else {
        var g = rn.size(c.ranges), y = new Int32Array(c.set.length + g);
        rn.forEach(c.ranges, function(x, C) {
          return y[C] = x;
        }), y.set(c.set, g), p = Ke.ofUnsortedArray(y);
      }
      for (var b = 0, S = m; b < S.length; b++) {
        var _ = S[b];
        o.push({ unit: _, indices: p });
      }
    }, d = 0, f = c.groupedUnits; d < f.length; d++)
      l(f[d]);
    return Xe(a, o);
  }, t.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(h) {
      var m = r(h, a);
      if (m.length === 0) return "continue";
      var p = m[0].elements, v = rn.size(c.ranges), g = c.set.length, y = new Int32Array(g + v), b = void 0;
      if (v === 0) {
        for (var S = 0, _ = g; S < _; ++S) y[S] = p[c.set[S]];
        b = Ke.ofSortedArray(y);
      } else if (g === 0) rn.forEach(c.ranges, function(w, I) {
        return y[I] = p[w];
      }), b = Ke.ofSortedArray(y);
      else if (Ke.min(c.set) > rn.max(c.ranges)) {
        for (rn.forEach(c.ranges, function(w, I) {
          return y[I] = p[w];
        }), S = 0, _ = g; S < _; ++S) y[S + v] = p[c.set[S]];
        b = Ke.ofSortedArray(y);
      } else if (rn.min(c.ranges) > Ke.max(c.set)) {
        for (S = 0, _ = g; S < _; ++S) y[S] = p[c.set[S]];
        rn.forEach(c.ranges, function(w, I) {
          return y[I + g] = p[w];
        }), b = Ke.ofSortedArray(y);
      } else {
        for (rn.forEach(c.ranges, function(w, I) {
          return y[I] = p[w];
        }), S = 0, _ = g; S < _; ++S) y[S + v] = p[c.set[S]];
        b = Ke.ofUnsortedArray(y);
      }
      for (var x = 0, C = m; x < C.length; x++) {
        var A = C[x];
        o.push(A.getChild(b));
      }
    }, d = 0, f = c.groupedUnits; d < f.length; d++)
      l(f[d]);
    return tt.create(o, { parent: a });
  }, t.toExpression = function(i) {
    return Nt.internal.generator.bundle({ elements: Nt.core.type.list(i.elements.map(n)) });
  }, t.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 (!Ke.areEqual(u.groupedUnits[l], c.groupedUnits[l])) return !1;
      if (!Ke.areEqual(u.set, c.set) || !rn.areEqual(u.ranges, c.ranges)) return !1;
    }
    return !0;
  };
}(So || (So = {}));
var jD, Q$ = Object.freeze({ __proto__: null, atomicHet: function() {
  return function(t) {
    for (var e = t.inputStructure, r = at.create(e), n = [], i = 0, a = e.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        r.unit = o;
        var s = o.elements;
        if (r.element = s[0], Qe.entity.type(r) !== "water") {
          if (Qe.entity.type(r) === "polymer") {
            for (var u = Qt.transientSegments(o.model.atomicHierarchy.residueAtomSegments, s), c = 0; u.hasNext; ) c++, u.move();
            if (c >= 8) continue;
          }
          n.push(o);
        }
      }
    }
    return gt.Singletons(e, tt.create(n, { parent: e }));
  };
}, atomicSequence: function() {
  return function(t) {
    for (var e = t.inputStructure, r = at.create(e), n = [], i = 0, a = e.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        r.unit = o;
        var s = o.elements;
        if (r.element = s[0], Qe.entity.type(r) === "polymer") {
          for (var u = Qt.transientSegments(o.model.atomicHierarchy.residueAtomSegments, s), c = 0; u.hasNext; ) c++, u.move();
          c < 8 || n.push(o);
        }
      }
    }
    return gt.Singletons(e, tt.create(n, { parent: e }));
  };
}, bundleElementImpl: ER, bundleGenerator: IR, defaultBondTest: q_, spheres: function() {
  return function(t) {
    for (var e = t.inputStructure, r = [], n = 0, i = e.units; n < i.length; n++) {
      var a = i[n];
      a.kind === 1 && r.push(a);
    }
    return gt.Singletons(e, tt.create(r, { parent: e }));
  };
}, water: function() {
  return function(t) {
    for (var e = t.inputStructure, r = at.create(e), n = [], i = 0, a = e.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        r.unit = o;
        var s = o.elements;
        r.element = s[0], Qe.entity.type(r) === "water" && n.push(o);
      }
    }
    return gt.Singletons(e, tt.create(n, { parent: e }));
  };
} }), A0 = function() {
  function t(e, r) {
    this.currentElementStack = [], this.currentAtomicBondStack = [], this.currentStructureStack = [], this.inputStructureStack = [], this.timeCreated = wi(), this.element = at.create(void 0), this.currentStructure = void 0, this.atomicBond = new ZD(), this.currentSelection = void 0, this.inputStructure = e, this.timeoutMs = r && r.timeoutMs || 0, this.currentSelection = r && r.currentSelection;
  }
  return t.prototype.pushCurrentElement = function() {
    return this.currentElementStack[this.currentElementStack.length] = this.element, this.element = at.create(void 0), this.element;
  }, t.prototype.popCurrentElement = function() {
    this.element = this.currentElementStack.pop();
  }, t.prototype.pushCurrentBond = function() {
    return this.atomicBond && this.currentAtomicBondStack.push(this.atomicBond), this.atomicBond = new ZD(), this.atomicBond;
  }, t.prototype.popCurrentBond = function() {
    this.currentAtomicBondStack.length > 0 ? this.atomicBond = this.currentAtomicBondStack.pop() : this.atomicBond = void 0;
  }, t.prototype.pushCurrentStructure = function() {
    this.currentStructure && this.currentStructureStack.push(this.currentStructure);
  }, t.prototype.popCurrentStructure = function() {
    this.currentStructureStack.length ? this.currentStructure = this.currentStructureStack.pop() : this.currentStructure = void 0;
  }, t.prototype.pushInputStructure = function(e) {
    this.inputStructureStack.push(this.inputStructure), this.inputStructure = e;
  }, t.prototype.popInputStructure = function() {
    if (this.inputStructureStack.length === 0) throw new Error("Must push before pop.");
    this.inputStructure = this.inputStructureStack.pop();
  }, t.prototype.throwIfTimedOut = function() {
    if (this.timeoutMs !== 0 && wi() - this.timeCreated > this.timeoutMs) throw new Error("The query took too long to execute (> ".concat(this.timeoutMs / 1e3, "s)."));
  }, t.prototype.tryGetCurrentSelection = function() {
    if (!this.currentSelection) throw new Error("The current selection is not assigned.");
    return this.currentSelection;
  }, t;
}(), ZD = function() {
  function t() {
    this.a = at.create(void 0), this.aIndex = 0, this.b = at.create(void 0), this.bIndex = 0, this.type = 0, this.order = 0, this.testFn = q_;
  }
  return t.prototype.setStructure = function(e) {
    this.a.structure = e, this.b.structure = e;
  }, t.prototype.setTestFn = function(e) {
    this.testFn = e || q_;
  }, t.prototype.test = function(e, r) {
    return !!this.testFn(e) || !!r && (this.swap(), this.testFn(e));
  }, t.prototype.swap = function() {
    var e = this.aIndex;
    this.aIndex = this.bIndex, this.bIndex = e;
    var r = this.a.unit;
    this.a.unit = this.b.unit, this.b.unit = r;
    var n = this.a.element;
    this.a.element = this.b.element, this.b.element = n;
  }, Object.defineProperty(t.prototype, "length", { get: function() {
    return at.distance(this.a, this.b);
  }, enumerable: !1, configurable: !0 }), t;
}();
(function(t) {
  t.run = function(e, r, n) {
    return e(new A0(r, n));
  };
})(jD || (jD = {}));
var Q6 = function() {
  function t(e) {
    this.source = e, this.set = W9(tt.hashCode, tt.areUnitIdsAndIndicesEqual), this.structures = [], this.allSingletons = !0;
  }
  return t.prototype.add = function(e) {
    e.elementCount && (e.elementCount !== 1 && (this.allSingletons = !1), this.set.add(e) && (this.structures[this.structures.length] = e));
  }, t.prototype.getSelection = function() {
    return this.allSingletons ? gt.Singletons(this.source, L3(this.source, this.structures)) : gt.Sequence(this.source, this.structures);
  }, t;
}(), J$ = function() {
  function t(e) {
    this.source = e, this.builders = [], this.builderMap = /* @__PURE__ */ new Map();
  }
  return t.prototype.add = function(e, r, n) {
    var i = this.builderMap.get(e);
    i || (i = this.source.subsetBuilder(!0), this.builders[this.builders.length] = i, this.builderMap.set(e, i)), i.addToUnit(r, n);
  }, t.prototype.allSingletons = function() {
    for (var e = 0, r = this.builders.length; e < r; e++) if (this.builders[e].elementCount > 1) return !1;
    return !0;
  }, t.prototype.singletonSelection = function() {
    for (var e = this.source.subsetBuilder(!0), r = at.create(this.source), n = 0, i = this.builders.length; n < i; n++) this.builders[n].setSingletonLocation(r), e.addToUnit(r.unit.id, r.element);
    return gt.Singletons(this.source, e.getStructure());
  }, t.prototype.fullSelection = function() {
    for (var e = new Array(this.builders.length), r = 0, n = this.builders.length; r < n; r++) e[r] = this.builders[r].getStructure();
    return gt.Sequence(this.source, e);
  }, t.prototype.getSelection = function() {
    return this.builders.length === 0 ? gt.Empty(this.source) : this.allSingletons() ? this.singletonSelection() : this.fullSelection();
  }, t;
}(), K_ = function(t) {
  return gt.Sequence(t.inputStructure, []);
}, TR = function(t) {
  return gt.Singletons(t.inputStructure, t.inputStructure);
};
function ld(t) {
  return !0;
}
function $$(t) {
  return 0;
}
function J6(t) {
  if (!(t && (t.atomTest || t.residueTest || t.chainTest || t.entityTest || t.unitTest || t.groupBy))) return TR;
  if (t.atomTest && !t.residueTest && !t.chainTest && !t.entityTest && !t.unitTest && !t.groupBy) return e = t.atomTest, function(n) {
    var i = n.inputStructure, a = i.units, o = n.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 f = 0, h = d.length; f < h; f++) o.element = d[f], e(n) && s.addElement(o.element);
      s.commitUnit(), n.throwIfTimedOut();
    }
    return n.popCurrentElement(), gt.Singletons(i, s.getStructure());
  };
  var e, r = { unitTest: t.unitTest || ld, entityTest: t.entityTest || ld, chainTest: t.chainTest || ld, residueTest: t.residueTest || ld, atomTest: t.atomTest || ld, groupBy: t.groupBy || $$ };
  return t.groupBy ? function(n) {
    var i = n.unitTest, a = n.entityTest, o = n.chainTest, s = n.residueTest, u = n.atomTest, c = n.groupBy;
    return function(l) {
      var d = l.inputStructure, f = d.units, h = l.pushCurrentElement(), m = new J$(d);
      h.structure = d;
      for (var p = 0, v = f; p < v.length; p++) {
        var g = v[p];
        if (h.unit = g, i(l)) {
          var y = g.elements, b = g.model;
          if (g.kind === 0) for (var S = Qt.transientSegments(b.atomicHierarchy.chainAtomSegments, y), _ = Qt.transientSegments(b.atomicHierarchy.residueAtomSegments, y); S.hasNext; ) {
            var x = S.move();
            if (h.element = y[x.start], a(l) && o(l)) for (_.setSegment(x); _.hasNext; ) {
              var C = _.move();
              if (h.element = y[C.start], s(l)) for (var A = C.start, w = C.end; A < w; A++) h.element = y[A], u(l) && m.add(c(l), g.id, h.element);
            }
          }
          else {
            var I = b.coarseHierarchy.spheres.chainElementSegments;
            for (S = Qt.transientSegments(I, y); S.hasNext; )
              if (x = S.move(), h.element = y[x.start], a(l) && o(l)) for (A = x.start, w = x.end; A < w; A++) h.element = y[A], s(l) && m.add(c(l), g.id, h.element);
          }
          l.throwIfTimedOut();
        }
      }
      return l.popCurrentElement(), m.getSelection();
    };
  }(r) : function(n) {
    var i = n.unitTest, a = n.entityTest, o = n.chainTest, s = n.residueTest, u = n.atomTest;
    return function(c) {
      var l = c.inputStructure, d = l.units, f = c.pushCurrentElement(), h = l.subsetBuilder(!0), m = s === ld && u === ld, p = u === ld;
      f.structure = l;
      for (var v = 0, g = d; v < g.length; v++) {
        var y = g[v];
        if (f.unit = y, i(c)) {
          var b = y.elements, S = y.model;
          if (h.beginUnit(y.id), y.kind === 0) for (var _ = Qt.transientSegments(y.model.atomicHierarchy.chainAtomSegments, b), x = Qt.transientSegments(y.model.atomicHierarchy.residueAtomSegments, b); _.hasNext; ) {
            var C = _.move();
            if (f.element = b[C.start], a(c) && o(c)) if (m) h.addElementRange(b, C.start, C.end);
            else for (x.setSegment(C); x.hasNext; ) {
              var A = x.move();
              if (f.element = b[A.start], s(c)) if (p) h.addElementRange(b, A.start, A.end);
              else for (var w = A.start, I = A.end; w < I; w++) f.element = b[w], u(c) && h.addElement(f.element);
            }
          }
          else {
            var P = S.coarseHierarchy.spheres.chainElementSegments;
            for (_ = Qt.transientSegments(P, b); _.hasNext; )
              if (C = _.move(), f.element = b[C.start], a(c) && o(c)) if (m) h.addElementRange(b, C.start, C.end);
              else for (w = C.start, I = C.end; w < I; w++) f.element = b[w], s(c) && h.addElement(f.element);
          }
          h.commitUnit(), c.throwIfTimedOut();
        }
      }
      return c.popCurrentElement(), gt.Singletons(l, h.getStructure());
    };
  }(r);
}
function $6(t, e, r) {
  for (var n = new Int32Array(e.length), i = 0, a = e.length; i < a; i++) n[i] = t.elements[e[i]];
  return tt.create([t.getChild(Ke.ofSortedArray(n))], { parent: r });
}
var ct, ji, eee = Object.freeze({ __proto__: null, all: TR, atoms: J6, bondedAtomicPairs: function(t) {
  return function(e) {
    var r = e.inputStructure, n = r.interUnitBonds, i = gt.UniqueBuilder(e.inputStructure);
    e.pushCurrentBond();
    var a = e.atomicBond;
    a.setTestFn(t), a.setStructure(r);
    for (var o = 0, s = r.units; o < s.length; o++) {
      var u = s[o];
      if (u.kind === 0) {
        var c = u.bonds, l = c.offset, d = c.b, f = c.edgeProps, h = f.flags, m = f.order;
        a.a.unit = u, a.b.unit = u;
        for (var p = 0, v = u.elements.length; p < v; p++) {
          a.aIndex = p, a.a.element = u.elements[p];
          for (var g = l[p], y = l[p + 1]; g < y; g++)
            a.bIndex = d[g], a.b.element = u.elements[d[g]], a.type = h[g], a.order = m[g], a.test(e, !1) && ((_ = r.subsetBuilder(!1)).beginUnit(u.id), _.addElement(a.a.element), _.addElement(a.b.element), _.commitUnit(), i.add(_.getStructure()));
        }
      }
    }
    for (var b = 0, S = n.edges; b < S.length; b++) {
      var _, x = S[b];
      a.a.unit = r.unitMap.get(x.unitA), a.a.element = a.a.unit.elements[x.indexA], a.aIndex = x.indexA, a.b.unit = r.unitMap.get(x.unitA), a.b.element = a.b.unit.elements[x.indexB], a.bIndex = x.indexB, a.order = x.props.order, a.type = x.props.flag, a.test(e, !1) && ((_ = r.subsetBuilder(!1)).addToUnit(a.a.unit.id, a.a.element), _.addToUnit(a.b.unit.id, a.b.element), i.add(_.getStructure()));
    }
    return e.popCurrentBond(), i.getSelection();
  };
}, chains: function(t) {
  return J6(O(O({}, t), { groupBy: function(e) {
    return Qe.chain.key(e.element);
  } }));
}, none: K_, querySelection: function(t, e, r) {
  return r === void 0 && (r = !1), function(n) {
    var i = t(n);
    if (gt.structureCount(i) === 0) return i;
    var a = r ? DR(n.inputStructure, gt.unionStructure(i)) : gt.unionStructure(i);
    if (a.elementCount === 0) return gt.Empty(n.inputStructure);
    n.throwIfTimedOut(), n.pushInputStructure(a);
    var o = e(n);
    return n.popInputStructure(), gt.withInputStructure(o, n.inputStructure);
  };
}, residues: function(t) {
  return J6(O(O({}, t), { groupBy: function(e) {
    return Qe.residue.key(e.element);
  } }));
}, rings: function(t, e) {
  return function(r) {
    var n = r.inputStructure.units, i = gt.LinearBuilder(r.inputStructure);
    if (t && t.length !== 0) {
      for (var a = bn.create(), o = 0; o < t.length; o++) bn.add(a, t[o], t[o]);
      for (var s = 0, u = n; s < u.length; s++)
        if (g = u[s], Fe.isAtomic(g)) for (var c = g.rings, l = 0, d = a.array; l < d.length; l++) {
          var f = d[l];
          if (c.byFingerprint.has(f)) for (var h = 0, m = c.byFingerprint.get(f); h < m.length; h++)
            S = m[h], e && !c.aromaticRings.includes(S) || i.add($6(g, c.all[S], r.inputStructure));
        }
    } else for (var p = 0, v = n; p < v.length; p++) {
      var g = v[p];
      if (Fe.isAtomic(g)) if (e) for (var y = 0, b = g.rings.aromaticRings; y < b.length; y++) {
        var S = b[y];
        i.add($6(g, g.rings.all[S], r.inputStructure));
      }
      else for (var _ = 0, x = g.rings.all; _ < x.length; _++) {
        var S = x[_];
        i.add($6(g, S, r.inputStructure));
      }
    }
    return i.getSelection();
  };
} }), Oy = function() {
  function t(e) {
    this.parent = e, this.ids = [], this.unitMap = bc.Mutable(), this.parentId = -1, this.currentUnit = bn.create(), this.elementCount = 0;
  }
  return t.prototype.addToUnit = function(e, r) {
    var n = this.unitMap.get(e);
    if (n) bn.add(n, r, r) && this.elementCount++;
    else {
      var i = bn.create();
      bn.add(i, r, r), this.unitMap.set(e, i), this.ids[this.ids.length] = e, this.elementCount++;
    }
  }, t.prototype.has = function(e, r) {
    var n = this.unitMap.get(e);
    return !!n && bn.has(n, r);
  }, t.prototype.beginUnit = function(e) {
    this.parentId = e, this.unitMap.has(e) ? this.currentUnit = this.unitMap.get(e) : this.currentUnit = this.currentUnit.array.length > 0 ? bn.create() : this.currentUnit;
  }, t.prototype.addElement = function(e) {
    bn.add(this.currentUnit, e, e) && this.elementCount++;
  }, t.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);
  }, t.prototype.getStructure = function() {
    if (this.isEmpty) return tt.Empty;
    var e = [];
    Ru(this.ids);
    for (var r = Ap.UnitEquivalenceBuilder(), n = 0, i = this.ids.length; n < i; n++) {
      var a = this.ids[n], o = this.parent.unitMap.get(a), s = this.unitMap.get(a).array, u = s.length;
      if (s.length !== o.elements.length) {
        u > 1 && Ru(s);
        var c = o.getChild(Ke.ofSortedArray(s)), l = r.add(c.id, c);
        c !== l && (c = l.applyOperator(c.id, c.conformation.operator, !0)), e[e.length] = c;
      } else e[e.length] = o, r.add(o.id, o);
    }
    return tt.create(e, { parent: this.parent });
  }, Object.defineProperty(t.prototype, "isEmpty", { get: function() {
    return this.elementCount === 0;
  }, enumerable: !1, configurable: !0 }), t;
}();
function ot(t) {
  return { data: t, position: 0, length: t.length, lineNumber: 1, tokenStart: 0, tokenEnd: 0 };
}
function QD(t) {
  for (; t.position < t.length; ) switch (t.data.charCodeAt(t.position)) {
    case 9:
    case 10:
    case 13:
    case 32:
      return void (t.tokenEnd = t.position);
    default:
      ++t.position;
  }
  t.tokenEnd = t.position;
}
function JD(t) {
  return !(t.length - t.position < 2) && t.data.charCodeAt(t.position + 1) === 39 && t.data.charCodeAt(t.position + 2) === 39;
}
function tee(t, e, r) {
  var n, i = r - e, a = t.tokenStart - e, o = t.tokenEnd - t.tokenStart;
  if (o < i) return !1;
  for (n = e; n < r; ++n) if (t.data.charCodeAt(n) !== t.data.charCodeAt(n + a)) return !1;
  return i === o || t.data.charCodeAt(n + a) === 46;
}
function MR(t) {
  var e;
  for (e = t.tokenStart; e < t.tokenEnd; ++e) if (t.data.charCodeAt(e) === 46) return e;
  return e;
}
function PR(t, e) {
  return t.data.substring(t.tokenStart, e);
}
function X_(t) {
  return t.data.substring(t.tokenStart, t.tokenEnd);
}
function $D(t) {
  var e = function(n) {
    for (var i = 10; n.position < n.length; ) {
      var a = n.data.charCodeAt(n.position);
      switch (a) {
        case 9:
        case 32:
          i = a, ++n.position;
          break;
        case 10:
          i !== 13 && ++n.lineNumber, i = a, ++n.position;
          break;
        case 13:
          i = a, ++n.position, ++n.lineNumber;
          break;
        default:
          return i;
      }
    }
    return i;
  }(t);
  if (t.position >= t.length) t.tokenType = 6;
  else {
    t.tokenStart = t.position, t.tokenEnd = t.position, t.isEscaped = !1;
    var r = t.data.charCodeAt(t.position);
    switch (r) {
      case 35:
        (function(n) {
          for (; n.position < n.length; ) {
            var i = n.data.charCodeAt(n.position);
            if (i === 10 || i === 13) return;
            ++n.position;
          }
        })(t), t.tokenType = 5;
        break;
      case 39:
        if (JD(t)) {
          (function(n) {
            for (n.position += 3; n.position < n.length; ) {
              if (n.data.charCodeAt(n.position) === 39 && JD(n)) return n.tokenStart += 3, n.tokenEnd = n.position, n.isEscaped = !0, void (n.position += 3);
              ++n.position;
            }
            n.tokenEnd = n.position;
          })(t), t.tokenType = 3;
          break;
        }
      case 34:
        (function(n, i) {
          var a, o;
          for (++n.position; n.position < n.length; ) if ((o = n.data.charCodeAt(n.position)) === i) switch (a = n.data.charCodeAt(n.position + 1)) {
            case 9:
            case 10:
            case 13:
            case 32:
              return n.tokenStart++, n.tokenEnd = n.position, n.isEscaped = !0, void ++n.position;
            default:
              if (a === void 0) return n.tokenStart++, n.tokenEnd = n.position, n.isEscaped = !0, void ++n.position;
              ++n.position;
          }
          else {
            if (o === 10 || o === 13) return void (n.tokenEnd = n.position);
            ++n.position;
          }
          n.tokenEnd = n.position;
        })(t, r), t.tokenType = 3;
        break;
      case 59:
        e === 10 || e === 13 ? function(n) {
          for (var i, a = 59, o = n.position + 1; o < n.length; ) {
            if ((i = n.data.charCodeAt(o)) === 59 && (a === 10 || a === 13)) {
              for (n.position = o + 1, n.tokenStart++, o--, i = n.data.charCodeAt(o); i === 10 || i === 13; ) o--, i = n.data.charCodeAt(o);
              return n.tokenEnd = o + 1, void (n.isEscaped = !0);
            }
            (i === 13 || i === 10 && a !== 13) && n.lineNumber++, a = i, ++o;
          }
          n.position = o;
        }(t) : QD(t), t.tokenType = 3;
        break;
      default:
        t.isImportGet ? function(n) {
          for (; n.position < n.length; ) {
            if (n.data.charCodeAt(n.position) === 93) return ++n.position, n.tokenEnd = n.position, void (n.isImportGet = !1);
            ++n.position;
          }
        }(t) : QD(t), t.isEscaped ? t.tokenType = 3 : t.data.charCodeAt(t.tokenStart) === 95 ? (t.inSaveFrame && function(n) {
          return n.tokenEnd - n.tokenStart == 11 && n.data.charCodeAt(n.tokenStart + 1) === 105 && n.data.charCodeAt(n.tokenStart + 2) === 109 && n.data.charCodeAt(n.tokenStart + 3) === 112 && n.data.charCodeAt(n.tokenStart + 4) === 111 && n.data.charCodeAt(n.tokenStart + 5) === 114 && n.data.charCodeAt(n.tokenStart + 6) === 116 && n.data.charCodeAt(n.tokenStart + 7) === 46 && n.data.charCodeAt(n.tokenStart + 8) === 103 && n.data.charCodeAt(n.tokenStart + 9) === 101 && n.data.charCodeAt(n.tokenStart + 10) === 116;
        }(t) && (t.isImportGet = !0), t.tokenType = 4) : t.tokenEnd - t.tokenStart >= 5 && t.data.charCodeAt(t.tokenStart + 4) === 95 ? function(n) {
          var i = n.data.charCodeAt(n.tokenStart);
          return !(i !== 68 && i !== 100 || (i = n.data.charCodeAt(n.tokenStart + 1)) !== 65 && i !== 97 || (i = n.data.charCodeAt(n.tokenStart + 2)) !== 84 && i !== 116 || (i = n.data.charCodeAt(n.tokenStart + 3)) !== 65 && i !== 97);
        }(t) ? t.tokenType = 0 : function(n) {
          var i = n.data.charCodeAt(n.tokenStart);
          return !(i !== 83 && i !== 115 || (i = n.data.charCodeAt(n.tokenStart + 1)) !== 65 && i !== 97 || (i = n.data.charCodeAt(n.tokenStart + 2)) !== 86 && i !== 118 || (i = n.data.charCodeAt(n.tokenStart + 3)) !== 69 && i !== 101);
        }(t) ? t.tokenType = 1 : function(n) {
          if (n.tokenEnd - n.tokenStart != 5) return !1;
          var i = n.data.charCodeAt(n.tokenStart);
          return !(i !== 76 && i !== 108 || (i = n.data.charCodeAt(n.tokenStart + 1)) !== 79 && i !== 111 || (i = n.data.charCodeAt(n.tokenStart + 2)) !== 79 && i !== 111 || (i = n.data.charCodeAt(n.tokenStart + 3)) !== 80 && i !== 112);
        }(t) ? t.tokenType = 2 : t.tokenType = 3 : t.tokenType = 3;
    }
  }
}
function Bd(t) {
  for ($D(t); t.tokenType === 5; ) $D(t);
}
function Kg() {
  return { categoryNames: [], categoryData: /* @__PURE__ */ Object.create(null) };
}
function Y_(t, e) {
  for (var r = /* @__PURE__ */ Object.create(null), n = 0, i = t; n < i.length; n++) {
    var a = i[n], o = e[a];
    r[a] = La(o.name, o.rowCount, o.fieldNames, o.fields);
  }
  return r;
}
function eE(t, e, r) {
  return Y9(t.categoryNames, Y_(t.categoryNames, t.categoryData), e, r);
}
function W_(t, e, r, n, i) {
  var a;
  if (e in t.categoryData) {
    var o = t.categoryData[e];
    (a = o.fieldNames).push.apply(a, n), Object.assign(o.fields, i);
  } else t.categoryData[e] = { name: e, rowCount: r, fieldNames: n, fields: i }, t.categoryNames.push(e);
}
function ree(t, e) {
  for (var r = e.tokenizer, n = e.tokens, i = e.fieldCount, a = e.tokenCount, o = 0; r.tokenType === 3 && o < t; ) ct.add(n[a++ % i], r.tokenStart, r.tokenEnd), Bd(r), o++;
  return e.tokenCount = a, o;
}
function nee(t, e) {
  return t.update({ message: "Parsing...", current: e.tokenizer.position, max: e.tokenizer.data.length });
}
function iee(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, s, u, c, l, d, f;
    return ye(this, function(h) {
      switch (h.label) {
        case 0:
          for (r = t.lineNumber, Bd(t), n = PR(t, MR(t)), i = function(m) {
            var p;
            for (p = m.tokenStart; p < m.tokenEnd; ++p) if (m.data.charCodeAt(p) === 46) return !1;
            return !0;
          }(t), a = []; t.tokenType === 4; ) a[a.length] = i ? X_(t) : X_(t).substring(n.length + 1), Bd(t);
          for (o = n === "_atom_site" ? t.data.length / 100 | 0 : 32, s = [], u = a.length, f = 0; f < u; f++) s[f] = ct.create(t.data, o);
          return c = { fieldCount: u, tokenCount: 0, tokenizer: t, tokens: s }, [4, Vm(t.runtimeCtx, 1e6, c, ree, nee)];
        case 1:
          if (h.sent(), c.tokenCount % u != 0) return [2, { hasError: !0, errorLine: t.lineNumber, errorMessage: "The number of values for loop starting at line ".concat(r, " is not a multiple of the number of columns.") }];
          if (l = c.tokenCount / u | 0, i) for (f = 0; f < u; f++) d = { "": ut.ofTokens(s[f]) }, W_(e, a[f].substr(1), l, [""], d);
          else {
            for (d = /* @__PURE__ */ Object.create(null), f = 0; f < u; f++) d[a[f]] = ut.ofTokens(s[f]);
            W_(e, n.substr(1), l, a, d);
          }
          return [2, { hasError: !1, errorLine: 0, errorMessage: "" }];
      }
    });
  });
}
function _1(t, e) {
  return ji.error(e, t);
}
function aee(t) {
  return ji.success(t);
}
function oee(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, s, u, c, l, d;
    return ye(this, function(f) {
      switch (f.label) {
        case 0:
          r = [], n = function(p, v) {
            return { data: p, length: p.length, position: 0, tokenStart: 0, tokenEnd: 0, tokenType: 6, lineNumber: 1, isEscaped: !1, isImportGet: !1, inSaveFrame: !1, runtimeCtx: v };
          }(t, e), i = "", a = Kg(), o = [], s = Kg(), h = s.categoryNames, m = Y_(s.categoryNames, s.categoryData), u = { categoryNames: h, header: "", categories: m }, c = "", e.update({ message: "Parsing...", current: 0, max: t.length }), Bd(n), f.label = 1;
        case 1:
          return n.tokenType === 6 ? [3, 7] : (l = n.tokenType) !== 0 ? [3, 2] : n.inSaveFrame ? [2, _1(n.lineNumber, "Unexpected data block inside a save frame.")] : (a.categoryNames.length > 0 && r.push(eE(a, i, o)), i = t.substring(n.tokenStart + 5, n.tokenEnd), a = Kg(), o = [], Bd(n), [3, 6]);
        case 2:
          if (l !== 1) return [3, 3];
          if (n.tokenEnd - n.tokenStart == 5) s.categoryNames.length > 0 && (o[o.length] = function(p, v) {
            return Y9(p.categoryNames, Y_(p.categoryNames, p.categoryData), v);
          }(s, c)), n.inSaveFrame = !1;
          else {
            if (n.inSaveFrame) return [2, _1(n.lineNumber, "Save frames cannot be nested.")];
            n.inSaveFrame = !0, c = t.substring(n.tokenStart + 5, n.tokenEnd), s = Kg();
          }
          return Bd(n), [3, 6];
        case 3:
          return l !== 2 ? [3, 5] : [4, iee(n, n.inSaveFrame ? s : a)];
        case 4:
          return (d = f.sent()).hasError ? [2, _1(d.errorLine, d.errorMessage)] : [3, 6];
        case 5:
          if (l !== 4) return console.log(n.tokenType, ot.getTokenString(n)), [2, _1(n.lineNumber, "Unexpected token. Expected data_, loop_, or data name.")];
          if (d = function(p, v) {
            for (var g = p.tokenStart, y = MR(p), b = PR(p, y), S = /* @__PURE__ */ Object.create(null), _ = [], x = !0; x; ) {
              if (p.tokenType !== 4 || !tee(p, g, y)) {
                x = !1;
                break;
              }
              var C = X_(p).substring(b.length + 1);
              if (Bd(p), p.tokenType !== 3) return { hasError: !0, errorLine: p.lineNumber, errorMessage: "Expected value." };
              S[C] = ut.ofTokens({ data: p.data, indices: [p.tokenStart, p.tokenEnd], count: 1 }), _[_.length] = C, Bd(p);
            }
            return W_(v, b.substr(1), 1, _, S), { hasError: !1, errorLine: 0, errorMessage: "" };
          }(n, n.inSaveFrame ? s : a), d.hasError) return [2, _1(d.errorLine, d.errorMessage)];
          f.label = 6;
        case 6:
          return [3, 1];
        case 7:
          return n.inSaveFrame ? [2, _1(n.lineNumber, "Unfinished save frame (".concat(u.header, ")."))] : ((a.categoryNames.length > 0 || o.length > 0) && r.push(eE(a, i, o)), [2, aee(WN(r))]);
      }
      var h, m;
    });
  });
}
function see(t) {
  var e = this;
  return tr.create("Parse CIF", function(r) {
    return _e(e, 0, void 0, function() {
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, oee(t, r)];
          case 1:
            return [2, n.sent()];
        }
      });
    });
  });
}
function eb(t, e) {
  for (var r = {}, n = 0; n < e; n++)
    r[k3(t)] = k3(t);
  return r;
}
function tb(t, e) {
  for (var r = new Uint8Array(e), n = t.offset, i = 0; i < e; i++) r[i] = t.buffer[i + n];
  return t.offset += e, r;
}
function Xg(t, e) {
  var r = NN(t.buffer, t.offset, e);
  return t.offset += e, r;
}
function rb(t, e) {
  for (var r = new Array(e), n = 0; n < e; n++) r[n] = k3(t);
  return r;
}
function k3(t) {
  var e, r, n = t.buffer[t.offset];
  if (!(128 & n)) return t.offset++, n;
  if ((240 & n) == 128) return r = 15 & n, t.offset++, eb(t, r);
  if ((240 & n) == 144) return r = 15 & n, t.offset++, rb(t, r);
  if ((224 & n) == 160) return r = 31 & n, t.offset++, Xg(t, r);
  if (!(224 & ~n)) return e = t.dataView.getInt8(t.offset), t.offset++, e;
  switch (n) {
    case 192:
      return t.offset++, null;
    case 194:
      return t.offset++, !1;
    case 195:
      return t.offset++, !0;
    case 196:
      return r = t.dataView.getUint8(t.offset + 1), t.offset += 2, tb(t, r);
    case 197:
      return r = t.dataView.getUint16(t.offset + 1), t.offset += 3, tb(t, r);
    case 198:
      return r = t.dataView.getUint32(t.offset + 1), t.offset += 5, tb(t, r);
    case 202:
      return e = t.dataView.getFloat32(t.offset + 1), t.offset += 5, e;
    case 203:
      return e = t.dataView.getFloat64(t.offset + 1), t.offset += 9, e;
    case 204:
      return e = t.buffer[t.offset + 1], t.offset += 2, e;
    case 205:
      return e = t.dataView.getUint16(t.offset + 1), t.offset += 3, e;
    case 206:
      return e = t.dataView.getUint32(t.offset + 1), t.offset += 5, e;
    case 208:
      return e = t.dataView.getInt8(t.offset + 1), t.offset += 2, e;
    case 209:
      return e = t.dataView.getInt16(t.offset + 1), t.offset += 3, e;
    case 210:
      return e = t.dataView.getInt32(t.offset + 1), t.offset += 5, e;
    case 217:
      return r = t.dataView.getUint8(t.offset + 1), t.offset += 2, Xg(t, r);
    case 218:
      return r = t.dataView.getUint16(t.offset + 1), t.offset += 3, Xg(t, r);
    case 219:
      return r = t.dataView.getUint32(t.offset + 1), t.offset += 5, Xg(t, r);
    case 220:
      return r = t.dataView.getUint16(t.offset + 1), t.offset += 3, rb(t, r);
    case 221:
      return r = t.dataView.getUint32(t.offset + 1), t.offset += 5, rb(t, r);
    case 222:
      return r = t.dataView.getUint16(t.offset + 1), t.offset += 3, eb(t, r);
    case 223:
      return r = t.dataView.getUint32(t.offset + 1), t.offset += 5, eb(t, r);
  }
  throw new Error("Unknown type 0x" + n.toString(16));
}
function uee(t) {
  for (var e = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ Object.create(null), n = 0, i = t.columns; n < i.length; n++) {
    var a = i[n];
    e[a.name] = a;
  }
  return { rowCount: t.rowCount, name: t.name.substr(1), fieldNames: t.columns.map(function(o) {
    return o.name;
  }), getField: function(o) {
    var s = e[o];
    if (s) return r[o] || (r[o] = function(u) {
      var c = u.mask ? F3(u.mask) : void 0, l = F3(u.data), d = L9(l), f = d ? c ? function(g) {
        return c[g] === 0 ? "" + l[g] : "";
      } : function(g) {
        return "" + l[g];
      } : c ? function(g) {
        return c[g] === 0 ? l[g] : "";
      } : function(g) {
        return l[g];
      }, h = d ? function(g) {
        return l[g];
      } : function(g) {
        var y = l[g];
        return Zd(y, 0, y.length);
      }, m = d ? function(g) {
        return l[g];
      } : function(g) {
        var y = l[g];
        return p0(y, 0, y.length);
      }, p = c ? function(g) {
        return c[g];
      } : function(g) {
        return 0;
      }, v = l.length;
      return { __array: l, binaryEncoding: u.data.encoding, isDefined: !0, rowCount: v, str: f, int: h, float: m, valueKind: p, areValuesEqual: function(g, y) {
        return l[g] === l[y];
      }, toStringArray: function(g) {
        return Sa(v, f, g);
      }, toIntArray: d ? function(g) {
        return x3(l, g);
      } : function(g) {
        return Sa(v, h, g);
      }, toFloatArray: d ? function(g) {
        return x3(l, g);
      } : function(g) {
        return Sa(v, m, g);
      } };
    }(s)), r[o];
  } };
}
function cee(t) {
  var e = this;
  return tr.create("Parse BinaryCIF", function(r) {
    return _e(e, 0, void 0, function() {
      var n, i, a;
      return ye(this, function(o) {
        n = [0, 3];
        try {
          return i = k3({ buffer: s = t, offset: 0, dataView: new DataView(s.buffer) }), function(u, c) {
            for (var l = 0; l < 2; l++) if (u[l] > c[l]) return !1;
            return !0;
          }(n, i.version.match(/(\d)\.(\d)\.\d/).slice(1).map(function(u) {
            return +u;
          })) ? (a = WN(i.dataBlocks.map(function(u) {
            for (var c = /* @__PURE__ */ Object.create(null), l = 0, d = u.categories; l < d.length; l++) {
              var f = d[l];
              c[f.name.substr(1)] = uee(f);
            }
            return Y9(u.categories.map(function(h) {
              return h.name.substr(1);
            }), c, u.header);
          })), [2, ji.success(a)]) : [2, ji.error("Unsupported format version. Current ".concat(i.version, ", required ").concat(n.join("."), "."))];
        } catch (u) {
          return [2, ji.error("" + u)];
        }
        var s;
        return [2];
      });
    });
  });
}
(function(t) {
  function e(o) {
    return o.data.substring(o.tokenStart, o.tokenEnd);
  }
  function r(o) {
    for (var s = o.data; o.position < o.length; ) switch (s.charCodeAt(o.position)) {
      case 10:
        return o.tokenEnd = o.position, ++o.position, ++o.lineNumber, !0;
      case 13:
        return o.tokenEnd = o.position, ++o.position, ++o.lineNumber, s.charCodeAt(o.position) === 10 && ++o.position, !0;
      default:
        ++o.position;
    }
    return o.tokenEnd = o.position, o.tokenStart !== o.tokenEnd;
  }
  function n(o) {
    return o.tokenStart = o.position, r(o);
  }
  function i(o, s, u) {
    for (var c = 0, l = 0; l < s; l++) {
      if (!n(o)) return c;
      ct.addUnchecked(u, o.tokenStart, o.tokenEnd), c++;
    }
    return c;
  }
  function a(o, s, u) {
    for (var c = o.data, l = s, d = u - 1, f = c.charCodeAt(l); (f === 9 || f === 32) && l <= d; ) f = c.charCodeAt(++l);
    for (f = c.charCodeAt(d); (f === 9 || f === 32) && d >= l; ) f = c.charCodeAt(--d);
    return o.tokenStart = l, o.tokenEnd = d + 1, o.position = u, o;
  }
  t.getTokenString = e, t.reset = function(o) {
    o.position = 0, o.lineNumber = 1, o.tokenStart = 0, o.tokenEnd = 0;
  }, t.eatLine = r, t.markStart = function(o) {
    o.tokenStart = o.position;
  }, t.markLine = n, t.readLine = function(o) {
    return n(o), e(o);
  }, t.readLineTrim = function(o) {
    n(o);
    var s = o.position;
    return a(o, o.tokenStart, o.tokenEnd), o.position = s, e(o);
  }, t.markLines = function(o, s) {
    var u = ct.create(o.data, 2 * s);
    return i(o, s, u), u;
  }, t.readLines = function(o, s) {
    for (var u = [], c = 0; c < s; c++) u.push(t.readLine(o));
    return u;
  }, t.readLinesAsync = function(o, s, u, c) {
    return c === void 0 && (c = 1e5), _e(this, 0, void 0, function() {
      var l, d, f;
      return ye(this, function(h) {
        switch (h.label) {
          case 0:
            return l = o.length, d = ct.create(o.data, 2 * s), f = 0, [4, Vm(u, c, o, function(m, p) {
              var v = Math.min(s - f, m);
              return i(p, v, d), f += v, v;
            }, function(m, p) {
              return m.update({ message: "Parsing...", current: p.position, max: l });
            })];
          case 1:
            return h.sent(), [2, d];
        }
      });
    });
  }, t.readAllLines = function(o) {
    for (var s = t(o), u = ct.create(s.data, Math.max(o.length / 80, 2)); n(s); ) ct.add(u, s.tokenStart, s.tokenEnd);
    return u;
  }, t.readAllLinesAsync = function(o, s, u) {
    return u === void 0 && (u = 1e5), _e(this, 0, void 0, function() {
      var c, l;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            return c = t(o), l = ct.create(c.data, Math.max(o.length / 80, 2)), [4, Vm(s, u, c, function(f, h) {
              return function(m, p, v) {
                for (var g = 0, y = 0; y < p; y++) {
                  if (!n(m)) return g;
                  ct.add(v, m.tokenStart, m.tokenEnd), g++;
                }
              }(h, f, l), h.position < h.length ? f : 0;
            }, function(f, h) {
              return f.update({ message: "Parsing...", current: h.position, max: length });
            })];
          case 1:
            return d.sent(), [2, l];
        }
      });
    });
  }, t.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;
  }, t.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;
  }, t.trim = a;
})(ot || (ot = {})), function(t) {
  function e(r, n, i) {
    var a = r;
    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++] = n, a.indices[a.offset++] = i, r.count++;
  }
  t.add = e, t.addToken = function(r, n) {
    e(r, n.tokenStart, n.tokenEnd);
  }, t.addUnchecked = function(r, n, i) {
    r.indices[r.offset++] = n, r.indices[r.offset++] = i, r.count++;
  }, t.create = function(r, n) {
    return { data: r, indicesLenMinus2: (n = Math.max(10, n)) - 2 | 0, count: 0, offset: 0, indices: new Uint32Array(n) };
  };
}(ct || (ct = {})), function(t) {
  t.error = function(n, i) {
    return i === void 0 && (i = -1), new e(n, i);
  }, t.success = function(n, i) {
    return i === void 0 && (i = []), new r(n, i);
  };
  var e = function() {
    function n(i, a) {
      this.message = i, this.line = a, this.isError = !0;
    }
    return n.prototype.toString = function() {
      return this.line >= 0 ? "[Line ".concat(this.line, "] ").concat(this.message) : this.message;
    }, n;
  }();
  t.Error = e;
  var r = function(n, i) {
    this.result = n, this.warnings = i, this.isError = !1;
  };
  t.Success = r;
}(ji || (ji = {}));
var Jp = se.Schema, wr = Jp.str, lee = Jp.float, tE = Jp.List, is = Jp.Aliased, Fh = Jp.int, x1 = Jp.coord, dee = { chem_comp: { formula: wr, formula_weight: lee, id: wr, mon_nstd_parent_comp_id: tE(",", function(t) {
  return t;
}), name: wr, one_letter_code: wr, three_letter_code: wr, type: is(wr), pdbx_synonyms: tE(";", function(t) {
  return t;
}), pdbx_type: wr, pdbx_ambiguous_flag: wr, pdbx_replaced_by: wr, pdbx_replaces: wr, pdbx_formal_charge: Fh, pdbx_model_coordinates_details: wr, pdbx_model_coordinates_db_code: wr, pdbx_ideal_coordinates_details: wr, pdbx_ideal_coordinates_missing_flag: is(wr), pdbx_model_coordinates_missing_flag: is(wr), pdbx_initial_date: wr, pdbx_modified_date: wr, pdbx_release_status: is(wr), pdbx_processing_site: is(wr) }, chem_comp_atom: { alt_atom_id: wr, atom_id: wr, charge: Fh, model_Cartn_x: x1, model_Cartn_y: x1, model_Cartn_z: x1, comp_id: wr, type_symbol: wr, pdbx_align: Fh, pdbx_ordinal: Fh, pdbx_model_Cartn_x_ideal: x1, pdbx_model_Cartn_y_ideal: x1, pdbx_model_Cartn_z_ideal: x1, pdbx_stereo_config: is(wr), pdbx_aromatic_flag: is(wr), pdbx_leaving_atom_flag: is(wr) }, chem_comp_bond: { atom_id_1: wr, atom_id_2: wr, comp_id: wr, value_order: is(wr), pdbx_ordinal: Fh, pdbx_stereo_config: is(wr), pdbx_aromatic_flag: is(wr) }, pdbx_chem_comp_descriptor: { comp_id: wr, descriptor: wr, type: is(wr), program: wr, program_version: wr }, pdbx_chem_comp_identifier: { comp_id: wr, identifier: wr, type: is(wr), program: wr, program_version: wr } }, Ly = se.Schema, Pt = Ly.str, fee = Ly.float, po = Ly.Aliased, Rs = Ly.int, pee = { pdbx_reference_molecule: { prd_id: Pt, formula_weight: fee, formula: Pt, type: po(Pt), type_evidence_code: Pt, class: po(Pt), class_evidence_code: Pt, name: Pt, represent_as: po(Pt), chem_comp_id: Pt, compound_details: Pt, description: Pt, representative_PDB_id_code: Pt, release_status: po(Pt), replaces: Pt, replaced_by: Pt }, pdbx_reference_entity_list: { prd_id: Pt, ref_entity_id: Pt, type: po(Pt), details: Pt, component_id: Rs }, pdbx_reference_entity_nonpoly: { prd_id: Pt, ref_entity_id: Pt, name: Pt, chem_comp_id: Pt }, pdbx_reference_entity_link: { link_id: Rs, prd_id: Pt, details: Pt, ref_entity_id_1: Pt, ref_entity_id_2: Pt, entity_seq_num_1: Rs, entity_seq_num_2: Rs, comp_id_1: Pt, comp_id_2: Pt, atom_id_1: Pt, atom_id_2: Pt, value_order: po(Pt), component_1: Rs, component_2: Rs, link_class: po(Pt) }, pdbx_reference_entity_poly_link: { link_id: Rs, prd_id: Pt, ref_entity_id: Pt, component_id: Rs, entity_seq_num_1: Rs, entity_seq_num_2: Rs, comp_id_1: Pt, comp_id_2: Pt, atom_id_1: Pt, atom_id_2: Pt, value_order: po(Pt) }, pdbx_reference_entity_poly: { prd_id: Pt, ref_entity_id: Pt, type: po(Pt), db_code: Pt, db_name: Pt }, pdbx_reference_entity_poly_seq: { prd_id: Pt, ref_entity_id: Pt, mon_id: Pt, parent_mon_id: Pt, num: Rs, observed: po(Pt), hetero: po(Pt) }, pdbx_reference_entity_sequence: { prd_id: Pt, ref_entity_id: Pt, type: po(Pt), NRP_flag: po(Pt), one_letter_codes: Pt }, pdbx_reference_entity_src_nat: { prd_id: Pt, ref_entity_id: Pt, ordinal: Rs, organism_scientific: Pt, taxid: Pt, db_code: Pt, db_name: Pt }, pdbx_prd_audit: { prd_id: Pt, date: Pt, processing_site: po(Pt), action_type: po(Pt) } }, BR = se.Schema, xi = BR.str, hee = { datablock: { id: xi, description: xi }, dictionary: { title: xi, datablock_id: xi, version: xi }, dictionary_history: { version: xi, update: xi, revision: xi }, sub_category: { id: xi, description: xi }, category_group_list: { id: xi, parent_id: xi, description: xi }, item_type_list: { code: xi, primitive_code: xi, construct: xi, detail: xi }, item_units_list: { code: xi, detail: xi }, item_units_conversion: { from_code: xi, to_code: xi, operator: xi, factor: BR.float } }, v2 = se.Schema, hm = v2.str, Yg = v2.int, Uc = v2.float, Wg = v2.Aliased, Td = v2.Vector;
Wg(hm), Wg(hm), Wg(hm), Wg(hm), Td(3), Td(3);
var j_, w0, mee = { volume_data_3d_info: { name: hm, axis_order: Td(3, Yg), origin: Td(3), dimensions: Td(3), sample_rate: Yg, sample_count: Td(3, Yg), spacegroup_number: Yg, spacegroup_cell_size: Td(3), spacegroup_cell_angles: Td(3), mean_source: Uc, mean_sampled: Uc, sigma_source: Uc, sigma_sampled: Uc, min_source: Uc, min_sampled: Uc, max_source: Uc, max_sampled: Uc }, volume_data_3d: { values: Uc } }, ky = se.Schema, ei = ky.float, nb = ky.int, fn = ky.str, gee = { cell: { angle_alpha: ei, angle_beta: ei, angle_gamma: ei, formula_units_z: nb, length_a: ei, length_b: ei, length_c: ei, volume: ei }, chemical: { melting_point: ei, name_common: fn, name_systematic: fn }, chemical_formula: { moiety: fn, sum: fn, weight: ei }, space_group: { crystal_system: fn, it_number: nb, "name_h-m_full": fn }, space_group_symop: { operation_xyz: fn }, geom_bond: { atom_site_label_1: fn, atom_site_label_2: fn, distance: ei, publ_flag: fn, site_symmetry_1: fn, site_symmetry_2: fn, valence: ei }, audit: { block_doi: fn }, database_code: { cod: fn, csd: fn, depnum_ccdc_archive: fn, depnum_ccdc_fiz: fn, icsd: fn, mdf: fn, nbs: fn }, atom_site: { adp_type: fn, calc_flag: fn, disorder_assembly: fn, disorder_group: fn, fract_x: ei, fract_y: ei, fract_z: ei, label: fn, occupancy: ei, refinement_flags: fn, site_symmetry_multiplicity: nb, type_symbol: fn, u_iso_or_equiv: ei }, atom_site_aniso: { label: fn, u_11: ei, u: (0, ky.Matrix)(3, 3), u_12: ei, u_13: ei, u_22: ei, u_23: ei, u_33: ei }, atom_type: { description: fn, symbol: fn }, atom_type_scat: { dispersion_imag: ei, dispersion_real: ei, source: fn } }, vee = { "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"] }, FR = function(t) {
  return typeof t == "string" ? see(t) : cee(t);
}, NR = { mmCIF: function(t) {
  return t0(rr, t);
}, CCD: function(t) {
  return t0(dee, t);
}, BIRD: function(t) {
  return t0(pee, t);
}, dic: function(t) {
  return t0(hee, t);
}, cifCore: function(t) {
  return t0(gee, t, vee);
}, densityServer: function(t) {
  return t0(mee, t);
} }, yee = { type_symbol: se.Schema.Aliased(rr.atom_site.type_symbol), label_atom_id: rr.atom_site.label_atom_id, auth_atom_id: rr.atom_site.auth_atom_id, label_alt_id: rr.atom_site.label_alt_id, label_comp_id: rr.atom_site.label_comp_id, auth_comp_id: rr.atom_site.auth_comp_id, pdbx_formal_charge: rr.atom_site.pdbx_formal_charge, cdr: rr.atom_site.cdr, B_iso_or_equiv: rr.atom_site.B_iso_or_equiv, em_confidence: rr.atom_site.em_confidence }, bee = { group_PDB: rr.atom_site.group_PDB, label_seq_id: rr.atom_site.label_seq_id, auth_seq_id: rr.atom_site.auth_seq_id, pdbx_PDB_ins_code: rr.atom_site.pdbx_PDB_ins_code }, _ee = { label_asym_id: rr.atom_site.label_asym_id, auth_asym_id: rr.atom_site.auth_asym_id, label_entity_id: rr.atom_site.label_entity_id };
(function(t) {
  t.EmptyResidueKey = function() {
    return { label_entity_id: "", label_asym_id: "", auth_seq_id: 0, pdbx_PDB_ins_code: void 0 };
  };
})(j_ || (j_ = {})), function(t) {
  function e(n, i) {
    return n.residueAtomSegments.index[n.chainAtomSegments.offsets[i]];
  }
  function r(n, i) {
    return n.residueAtomSegments.index[n.chainAtomSegments.offsets[i + 1] - 1] + 1;
  }
  t.chainStartResidueIndex = e, t.chainEndResidueIndexExcl = r, t.chainResidueCount = function(n, i) {
    return r(n, i) - e(n, i);
  };
}(w0 || (w0 = {}));
var Km, Sp = { 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 }, xee = { 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 }, See = { 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 }, Cee = 1.7, Aee = 0;
function Gy(t) {
  var e = Sp[t];
  return e === void 0 ? Cee : xee[e];
}
function Xm(t) {
  var e = Sp[t];
  return e === void 0 ? Aee : e;
}
function RR(t, e, r, n) {
  return { type: t, key: e, elements: r, getIndex: n };
}
function wee(t, e, r, n, i, a) {
  for (var o = t.residues, s = o.auth_seq_id, u = o.label_seq_id, c = o.pdbx_PDB_ins_code, l = r.endSeqId, d = r.endInsCode, f = r.key, h = r.type, m = e === "label" ? u : s, p = n; p < i; ) {
    var v = m.value(p);
    if (a.type[p] = h, a.key[p] = f, v > l || v === l && c.value(p) === d) break;
    p++;
  }
}
(function(t) {
  t.Descriptor = { name: "model_secondary_structure" }, t.Provider = gc.create(t.Descriptor), t.fromStruct = function(e, r, n) {
    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";
    }(e, r);
    (function(c, l, d, f) {
      if (c._rowCount)
        for (var h = c.beg_label_asym_id, m = c.beg_label_seq_id, p = c.beg_auth_seq_id, v = c.pdbx_beg_PDB_ins_code, g = c.end_label_seq_id, y = c.end_auth_seq_id, b = c.pdbx_end_PDB_ins_code, S = c.pdbx_PDB_helix_class, _ = c.conf_type_id, x = c.details, C = l === "label" ? m : p, A = l === "label" ? g : y, w = 0, I = c._rowCount; w < I; w++) {
          var P = _r.create(S.valueKind(w) === 0 ? _r.SecondaryStructurePdb[S.value(w)] : _.valueKind(w) === 0 ? _r.SecondaryStructureMmcif[_.value(w)] : 536870912), M = { kind: "helix", flags: P, type_id: _.valueKind(w) === 0 ? _.value(w) : "HELIX_P", helix_class: S.value(w), details: x.valueKind(w) === 0 ? x.value(w) : void 0 }, T = { startSeqId: C.value(w), startInsCode: v.value(w), endSeqId: A.value(w), endInsCode: b.value(w), type: P, key: f.length };
          f[f.length] = M;
          var F = h.value(w);
          if (d.has(F)) {
            var N = d.get(F);
            N.has(T.startSeqId) ? N.get(T.startSeqId).push(T) : N.set(T.startSeqId, [T]);
          } else d.set(F, /* @__PURE__ */ new Map([[T.startSeqId, [T]]]));
        }
    })(e, o, i, a), function(c, l, d, f, h) {
      if (c._rowCount)
        for (var m = c.beg_label_asym_id, p = c.beg_label_seq_id, v = c.beg_auth_seq_id, g = c.pdbx_beg_PDB_ins_code, y = c.end_label_seq_id, b = c.end_auth_seq_id, S = c.pdbx_end_PDB_ins_code, _ = c.sheet_id, x = l === "label" ? p : v, C = l === "label" ? y : b, A = /* @__PURE__ */ new Map(), w = f + 1, I = 0, P = c._rowCount; I < P; I++) {
          var M = _.value(I), T = void 0;
          A.has(M) ? T = A.get(M) : (T = w++, A.set(M, T));
          var F = _r.create(8388612), N = { kind: "sheet", flags: F, sheet_id: M, symmetry: void 0 }, R = { startSeqId: x.value(I), startInsCode: g.value(I), endSeqId: C.value(I), endInsCode: S.value(I), type: F, key: h.length };
          h[h.length] = N;
          var L = m.value(I);
          if (d.has(L)) {
            var V = d.get(L);
            V.has(R.startSeqId) ? V.get(R.startSeqId).push(R) : V.set(R.startSeqId, [R]);
          } else d.set(L, /* @__PURE__ */ new Map([[R.startSeqId, [R]]]));
        }
    }(r, o, i, e._rowCount, a);
    var s = n.residues._rowCount, u = { type: new Int32Array(s), key: new Int32Array(s), elements: a };
    return i.size > 0 && function(c, l, d, f) {
      for (var h = c.chainAtomSegments.count, m = c.chains.label_asym_id, p = c.residues, v = p.auth_seq_id, g = p.label_seq_id, y = p.pdbx_PDB_ins_code, b = l === "label" ? g : v, S = 0; S < h; S++) {
        var _ = w0.chainStartResidueIndex(c, S), x = w0.chainEndResidueIndexExcl(c, S), C = m.value(S);
        if (d.has(C)) for (var A = d.get(C), w = _; w < x; w++) {
          var I = b.value(w);
          if (A.has(I)) for (var P = 0, M = A.get(I); P < M.length; P++) {
            var T = M[P], F = y.value(w);
            T.startInsCode === F && wee(c, l, T, w, x, f);
          }
        }
      }
    }(n, o, i, u), RR(u.type, u.key, u.elements, function(c) {
      return c;
    });
  };
})(Km || (Km = {}));
var $d, Tm, Dee = { U: rr.atom_site_anisotrop.U, U_esd: rr.atom_site_anisotrop.U_esd };
(function(t) {
  t.Schema = Dee, t.Descriptor = { name: "atom_site_anisotrop", cifExport: { prefix: "", categories: [{ name: "atom_site_anisotrop", instance: function(e) {
    return t.Provider.get(e.firstModel) && An.is(e.firstModel.sourceData) ? na.Category.ofTable(e.firstModel.sourceData.data.db.atom_site_anisotrop) : na.Category.Empty;
  } }] } }, t.Provider = gc.create(t.Descriptor), t.getElementToAnsiotrop = function(e, r) {
    var n = new Int32Array(e.rowCount);
    n.fill(-1);
    for (var i = 0, a = e.rowCount; i < a; i++) n[e.value(i)] = i;
    var o = new Int32Array(e.rowCount);
    for (o.fill(-1), i = 0, a = r.rowCount; i < a; ++i) {
      var s = n[r.value(i)];
      s !== -1 && (o[s] = i);
    }
    return o;
  }, t.getElementToAnsiotropFromLabel = function(e, r) {
    for (var n = {}, i = 0, a = e.rowCount; i < a; i++) n[e.value(i)] = i;
    var o = new Int32Array(e.rowCount);
    for (o.fill(-1), i = 0, a = r.rowCount; i < a; ++i) {
      var s = n[r.value(i)];
      s !== void 0 && (o[s] = i);
    }
    return o;
  };
})($d || ($d = {})), function(t) {
  var e, r = "molstar_global_model_transform_info";
  function n(i) {
    return t.Provider.get(i);
  }
  t.Schema = ((e = {})[r] = { matrix: se.Schema.Matrix(4, 4, se.Schema.float) }, e), t.Descriptor = ku({ name: r, cifExport: { categories: [{ name: r, instance: function(i) {
    var a = n(i.firstModel);
    if (!a) return na.Category.Empty;
    var o = Hr.ofRows(t.Schema.molstar_global_model_transform_info, [{ matrix: a }]);
    return na.Category.ofTable(o);
  } }], prefix: "molstar" } }), t.Provider = gc.create(t.Descriptor), t.attach = function(i, a) {
    i.customProperties.has(t.Descriptor) || i.customProperties.add(t.Descriptor), t.Provider.set(i, a);
  }, t.get = n, t.fromMmCif = function(i) {
    if (An.is(i.sourceData)) {
      var a = i.sourceData.data.frame.categories[r];
      if (a) {
        var o, s = (o = t.Schema[r], new jN(a, o, !0));
        if (s._rowCount !== 0) return s.matrix.value(0);
      }
    }
  }, t.hasData = function(i) {
    if (!An.is(i.sourceData)) return !1;
    var a = i.sourceData.data.frame.categories[r];
    return !!a && a.rowCount > 0;
  }, t.writeMmCif = function(i, a) {
    i.writeCategory({ name: r, instance: function() {
      var o = Hr.ofRows(t.Schema.molstar_global_model_transform_info, [{ matrix: a }]);
      return na.Category.ofTable(o);
    } });
  };
}(Tm || (Tm = {})), rr.atom_site.label_comp_id, rr.atom_site.label_seq_id, rr.atom_site.pdbx_PDB_ins_code, rr.atom_site.label_asym_id, rr.atom_site.label_entity_id, rr.atom_site.auth_atom_id, rr.atom_site.auth_seq_id, rr.atom_site.auth_asym_id, O(O({}, rr.chem_comp_bond), { molstar_protonation_variant: se.Schema.Str() });
var Eee = O(O({}, rr.chem_comp), { type: se.Schema.Aliased(se.Schema.str) });
function Iee(t, e) {
  var r = e.ihm_model_group, n = e.ihm_model_group_link, i = Hr.pickRow(n, function(o) {
    return n.model_id.value(o) === t;
  });
  if (i) {
    var a = Hr.pickRow(r, function(o) {
      return r.id.value(o) === i.group_id;
    });
    if (a) return a.name;
  }
  return "";
}
function rE(t) {
  for (var e = 0, r = t.rowCount; e < r; e++) if (t.valueKind(e) === 0) return !0;
  return !1;
}
function jg(t, e, r) {
  t[e].isDefined && rE(t[e]) || (t[e] = t[r]), t[r].isDefined && rE(t[r]) || (t[r] = t[e]);
}
var An, Ho = { entry: rr.entry, struct: rr.struct, struct_asym: rr.struct_asym, ihm_model_list: rr.ihm_model_list, ihm_model_group: rr.ihm_model_group, ihm_model_group_link: rr.ihm_model_group_link, entity: rr.entity, entity_poly: rr.entity_poly, entity_poly_seq: rr.entity_poly_seq, pdbx_entity_branch: rr.pdbx_entity_branch, chem_comp: Eee, pdbx_chem_comp_identifier: rr.pdbx_chem_comp_identifier, atom_site: rr.atom_site, ihm_sphere_obj_site: rr.ihm_sphere_obj_site, ihm_gaussian_obj_site: rr.ihm_gaussian_obj_site, pdbx_unobs_or_zero_occ_residues: rr.pdbx_unobs_or_zero_occ_residues, pdbx_molecule: rr.pdbx_molecule };
function hf(t, e) {
  e === void 0 && (e = !1);
  for (var r = /* @__PURE__ */ Object.create(null), n = 0, i = Object.keys(Ho); n < i.length; n++) {
    var a = i[n];
    r[a] = a in t ? t[a] : Hr.ofUndefinedColumns(Ho[a], 0);
  }
  return e && (r.atom_site = function(o) {
    var s = Hr.ofColumns(o._schema, o);
    return jg(s, "label_atom_id", "auth_atom_id"), jg(s, "label_comp_id", "auth_comp_id"), jg(s, "label_seq_id", "auth_seq_id"), jg(s, "label_asym_id", "auth_asym_id"), s;
  }(r.atom_site)), r;
}
function OR(t) {
  var e = An.fromFrame(t), r = hf(e.data.db, !0);
  return tr.create("Create mmCIF Model", function(n) {
    return Pl(r, e, n);
  });
}
Da.Provider.formatRegistry.add("mmCIF", function(t) {
  if (An.is(t.sourceData)) return Da.fromData(t.sourceData.data.db);
}), Km.Provider.formatRegistry.add("mmCIF", function(t) {
  if (An.is(t.sourceData)) {
    var e = t.sourceData.data.db, r = e.struct_conf, n = e.struct_sheet_range;
    return Km.fromStruct(r, n, t.atomicHierarchy);
  }
}), $d.Provider.formatRegistry.add("mmCIF", function(t) {
  if (An.is(t.sourceData)) {
    var e = t.sourceData.data.db.atom_site_anisotrop;
    return { data: Hr.ofColumns($d.Schema, e), elementToAnsiotrop: $d.getElementToAnsiotrop(t.atomicConformation.atomId, e.id) };
  }
}, function(t) {
  return !!An.is(t.sourceData) && t.sourceData.data.db.atom_site_anisotrop.U.isDefined;
}), qm.Provider.formatRegistry.add("mmCIF", function(t) {
  if (An.is(t.sourceData)) {
    var e = t.sourceData.data.db.chem_comp_bond;
    if (e._rowCount !== 0) return { data: e, entries: qm.getEntriesFromChemCompBond(e) };
  }
}), vc.Provider.formatRegistry.add("mmCIF", function(t) {
  if (An.is(t.sourceData)) {
    var e = t.sourceData.data.db.struct_conn;
    if (e._rowCount !== 0) {
      var r = vc.getEntriesFromStructConn(e, t);
      return { data: e, byAtomIndex: vc.getAtomIndexFromEntries(r), entries: r };
    }
  }
}), Tm.Provider.formatRegistry.add("mmCIF", Tm.fromMmCif, Tm.hasData), function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "mmCIF";
  }, t.fromFrame = function(e, r, n) {
    return r || (r = NR.mmCIF(e)), { kind: "mmCIF", name: r._name, data: { db: r, frame: e, source: n } };
  };
}(An || (An = {}));
var qt, Tee = 9, Zg = -27.888, Mee = -0.5, nE = -9.9;
function Pee(t, e, r, n) {
  var i = E.distance(t, n), a = E.distance(e, n), o = E.distance(e, r), s = E.distance(t, r), u = Zg / i - Zg / a + (Zg / o - Zg / s);
  return u < nE ? nE : u;
}
function Bee(t, e, r) {
  for (var n = e.residueIndices, i = e.cIndices, a = e.hIndices, o = e.nIndices, s = e.oIndices, u = t.model.atomicHierarchy.index, c = t.conformation.invariantPosition, l = t.model.atomicHierarchy.derived.residue.traceElementIndex, d = n.length, f = [], h = [], m = [], p = E(), v = E(), g = E(), y = E(), b = E(), S = E(), _ = E(), x = 0, C = n.length; x < C; ++x) {
    var A = x, w = n[x], I = s[A], P = i[A], M = l[w];
    if (I !== -1 && P !== -1 && u.findAtomOnResidue(w, "OXT") === -1) {
      c(I, p), c(P, v), c(M, g);
      for (var T = r.find(g[0], g[1], g[2], Tee), F = T.indices, N = T.count, R = 0; R < N; ++R) {
        var L = F[R];
        if (L !== A && L - 1 !== A && L + 1 !== A) {
          var V = o[L];
          if (V !== -1) {
            c(V, y);
            var U = a[L];
            if (U === -1) {
              if (L === 0) continue;
              var H = L - 1, K = s[H], X = i[H];
              if (K === -1 || X === -1) continue;
              c(K, _), c(X, S), E.sub(b, S, _);
              var Y = E.distance(_, S);
              E.scaleAndAdd(b, y, b, 1 / Y);
            } else c(U, b);
            var Q = Pee(p, v, y, b);
            Q > Mee || (f[f.length] = A, h[h.length] = L, m[m.length] = Q);
          }
        }
      }
    }
  }
  return function(J, te, W, j) {
    for (var ee = new Xo.DirectedEdgeBuilder(J, te, W), ie = new Float32Array(ee.slotCount), ae = 0, ce = ee.edgeCount; ae < ce; ae++) ee.addNextEdge(), ee.assignProperty(ie, j[ae]);
    return ee.createGraph({ energies: j });
  }(d, f, h, m);
}
(function(t) {
  t.is = Ga.has, t.create = Ga.create;
})(qt || (qt = {}));
var Qg = function(t, e, r) {
  this.partner1 = Math.min(t, e), this.partner2 = Math.max(t, e), this.type = r;
};
function Fee(t, e) {
  if (e.type !== t.type || e.partner1 !== t.firstEnd + 1) return !1;
  if (e.type === 0) {
    if (e.partner2 === t.secondEnd + 1) return !0;
  } else if (e.partner2 === t.secondStart - 1) return !0;
  return !1;
}
function Nee(t, e) {
  return t.type === e.type && e.firstStart - t.firstEnd < 6 && t.firstStart < e.firstStart && e.nextLadder === 0 && (t.type === 0 ? iE(t, e) : iE(e, t));
}
function iE(t, e) {
  return e.secondStart - t.secondEnd > 0 && (e.secondStart - t.secondEnd < 6 && e.firstStart - t.firstEnd < 3 || e.secondStart - t.secondEnd < 3);
}
function aE(t) {
  return qt.is(t, 8) || qt.is(t, 1) || qt.is(t, 16);
}
var Cp, Ree = { oldDefinition: z.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: z.Boolean(!0, { description: "Alpha-helices are preferred over 3-10 helices" }) };
function LR(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x;
    return ye(this, function(C) {
      for (r = function(A) {
        for (var w = A.model.atomicHierarchy.index, I = A.proteinElements, P = A.residueIndex, M = I.length, T = new Uint32Array(M), F = new Int32Array(M), N = new Int32Array(M), R = new Int32Array(M), L = new Int32Array(M), V = 0; V < M; ++V) {
          var U = P[I[V]];
          T[V] = U, F[V] = w.findAtomOnResidue(U, "C"), N[V] = w.findAtomOnResidue(U, "H"), R[V] = w.findAtomOnResidue(U, "O"), L[V] = w.findAtomOnResidue(U, "N");
        }
        return { residueIndices: Ke.ofSortedArray(T), cIndices: F, hIndices: N, oIndices: R, nIndices: L };
      }(t), n = r.residueIndices, i = function(A, w) {
        for (var I = A.model.atomicConformation, P = I.x, M = I.y, T = I.z, F = A.model.atomicHierarchy.derived.residue.traceElementIndex, N = new Uint32Array(w.length), R = 0, L = w.length; R < L; ++R) N[R] = F[w[R]];
        var V = { x: P, y: M, z: T, indices: Ke.ofSortedArray(N) };
        return S0(V, xp(V));
      }(t, n), a = Bee(t, r, i), o = n.length, s = new Uint32Array(o), u = function(A, w) {
        var I = w.cIndices, P = w.nIndices, M = w.residueIndices, T = A.conformation.position, F = A.model.atomicHierarchy.index, N = A.model.atomicHierarchy.derived.residue.traceElementIndex, R = M.length, L = function(ie, ae) {
          return ie === -1 ? E.setNaN(ae) : T(ie, ae);
        }, V = E(), U = E(), H = E(), K = E(), X = E(), Y = E(), Q = E(), J = E(), te = E();
        if (R === 0) return { phi: new Float32Array(0), psi: new Float32Array(0) };
        var W = new Float32Array(R - 1), j = new Float32Array(R - 1);
        L(-1, V), L(-1, U), L(-1, H), L(I[0], K), L(N[M[0]], X), L(P[0], Y), L(I[1], Q), L(N[M[1]], J), L(P[1], te);
        for (var ee = 0; ee < R - 1; ++ee) F.findAtomOnResidue(M[ee], "OXT") === -1 && (W[ee] = Ua(E.dihedralAngle(V, Y, X, K)), j[ee] = Ua(E.dihedralAngle(Y, X, K, te)), V = K, U = X, H = Y, K = Q, X = J, Y = te, L(I[ee + 1], Q), L(N[M[ee + 1]], J), L(P[ee + 1], te));
        return { phi: W, psi: j };
      }(t, r), c = [], l = [], d = e.oldDefinition ? kee : zee, f = e.oldOrdering ? Gee : Vee, function(A) {
        for (var w = A.proteinInfo, I = A.hbonds, P = A.flags, M = [1024, 2048, 4096, 128, 256, 512], T = 0; T < 3; T++) for (var F = 0, N = w.residueIndices.length - 1; F < N; ++F) if (I.getDirectedEdgeIndex(F, F + T + 3) !== -1) if (P[F] |= M[T + 3] | M[T], A.params.oldDefinition) for (var R = 1; R < T + 3; ++R) P[F + R] |= 64 | M[T + 3];
        else for (R = 0; R <= T + 3; ++R) P[F + R] |= 64 | M[T + 3];
      }(h = { params: e, getResidueFlag: d, getFlagName: f, unit: t, proteinInfo: r, flags: s, hbonds: a, torsionAngles: u, ladders: c, bridges: l }), function(A) {
        for (var w = A.proteinInfo, I = A.flags, P = w.residueIndices.length, M = [1024, 2048, 4096, 128, 256, 512], T = [0, 0, 0, 8, 1, 16], F = A.params.oldOrdering ? [4, 3, 5] : [3, 4, 5], N = 0; N < F.length; N++) for (var R = F[N], L = 1, V = P - R; L < V; L++) {
          var U = qt.create(I[L]), H = qt.create(I[L - 1]), K = qt.create(I[L + 1]);
          if (A.params.oldOrdering) {
            if (R === 3 && (qt.is(U, 1) || qt.is(K, 1)) || R === 5 && (qt.is(U, 1) || qt.is(U, 8) || qt.is(K, 1) || qt.is(K, 8))) continue;
          } else if (R === 4 && (qt.is(U, 8) || qt.is(K, 8)) || R === 5 && (qt.is(U, 1) || qt.is(U, 8) || qt.is(K, 1) || qt.is(K, 8))) continue;
          if (qt.is(U, M[R]) && qt.is(U, M[R - 3]) && qt.is(H, M[R]) && qt.is(H, M[R - 3])) if (A.params.oldDefinition) for (var X = 0; X < R; X++) I[L + X] |= T[R];
          else for (X = -1; X <= R; X++) I[L + X] |= T[R];
        }
      }(h), function(A) {
        var w = A.unit, I = A.flags, P = A.proteinInfo, M = w.conformation.position, T = w.model.atomicHierarchy.derived.residue.traceElementIndex, F = P.residueIndices, N = P.nIndices, R = F.length, L = function(De, ke) {
          return De === -1 ? E.setNaN(ke) : M(De, ke);
        }, V = E(), U = E(), H = E(), K = E(), X = E(), Y = E(), Q = E();
        e: for (var J = 2; J < R - 2; J++) {
          for (var te = 0; te < 4; te++) {
            var W = J + te - 2;
            if (L(T[W], K), L(N[W + 1], X), E.squaredDistance(K, X) > 6.25) continue e;
          }
          var j = F[J - 2], ee = F[J], ie = F[J + 2], ae = T[j], ce = T[ee], de = T[ie];
          L(ae, V), L(ce, U), L(de, H), E.sub(Y, V, U), E.sub(Q, U, H);
          var Ce = Ua(E.angle(Y, Q));
          Ce && Ce > 70 && (I[J] |= 32);
        }
      }(h), function(A) {
        for (var w, I, P = A.proteinInfo, M = A.hbonds, T = A.flags, F = A.bridges, N = M.offset, R = M.b, L = 0, V = P.residueIndices.length; L < V; ++L) for (var U = N[L], H = N[L + 1]; U < H; U++) {
          var K = R[U];
          L > K || ((w = L + 1) !== (I = K) && M.getDirectedEdgeIndex(I, w + 1) !== -1 && (T[w] |= 2, T[I] |= 2, F[F.length] = new Qg(w, I, 0)), (w = L) !== (I = K - 1) && M.getDirectedEdgeIndex(I - 1, w) !== -1 && (T[w] |= 2, T[I] |= 2, F[F.length] = new Qg(I, w, 0)), (w = L) !== (I = K) && M.getDirectedEdgeIndex(I, w) !== -1 && (T[w] |= 2, T[I] |= 2, F[F.length] = new Qg(I, w, 1)), (w = L + 1) !== (I = K - 1) && M.getDirectedEdgeIndex(I - 1, w + 1) !== -1 && (T[w] |= 2, T[I] |= 2, F[F.length] = new Qg(I, w, 1)));
        }
        F.sort(function(X, Y) {
          return X.partner1 > Y.partner1 ? 1 : X.partner1 < Y.partner1 ? -1 : 0;
        });
      }(h), function(A) {
        for (var w = A.bridges, I = A.ladders, P = 0; P < w.length; P++) {
          for (var M = w[P], T = !1, F = 0; F < I.length; F++) {
            var N = I[F];
            Fee(N, M) && (T = !0, N.firstEnd++, M.type === 0 ? N.secondEnd++ : N.secondStart--);
          }
          T || (I[I.length] = { previousLadder: 0, nextLadder: 0, firstStart: M.partner1, firstEnd: M.partner1, secondStart: M.partner2, secondEnd: M.partner2, type: M.type });
        }
        for (var R = 0; R < I.length; R++) for (var L = I[R], V = R; V < I.length; V++) {
          var U = I[V];
          Nee(L, U) && (L.nextLadder = V, U.previousLadder = R);
        }
      }(h), function(A) {
        for (var w = A.ladders, I = A.flags, P = 0; P < w.length; P++) {
          for (var M = w[P], T = M.firstStart; T <= M.firstEnd; T++) {
            var F = M.firstStart - T, N = M.secondStart - F;
            M.firstStart !== M.firstEnd ? (I[T] |= 4, I[N] |= 4) : (!aE(I[T]) && qt.is(I[T], 4) && (I[T] |= 2), !aE(I[N]) && qt.is(I[N], 4) && (I[N] |= 2));
          }
          if (M.nextLadder !== 0) {
            var R = w[M.nextLadder];
            for (T = M.firstStart; T <= R.firstEnd; T++) I[T] |= 4;
            if (M.type === 0) for (T = M.secondStart; T <= R.secondEnd; T++) I[T] |= 4;
            else for (T = R.secondEnd; T <= M.secondStart; T++) I[T] |= 4;
          }
        }
      }(h), m = function(A, w) {
        for (var I = new Uint32Array(A.length), P = 0, M = A.length; P < M; ++P) {
          var T = qt.create(A[P]);
          I[P] = w(T);
        }
        return I;
      }(s, d), p = new Uint32Array(o), v = [], g = [], y = function(A) {
        return Ke.indexOf(n, A);
      }, b = 0, S = n.length; b < S; ++b) _ = m[b], p[b] = _, x = d(s[b]), g.length !== 0 && x === g[g.length - 1].flags || (g[g.length] = Oee(Lee(_), s[b], d)), v[b] = g.length - 1;
      return [2, RR(p, v, g, y)];
    });
  });
}
function Oee(t, e, r) {
  return t === "helix" ? { kind: "helix", flags: r(e) } : t === "sheet" ? { kind: "sheet", flags: r(e) } : t === "turn" || t === "bend" ? { kind: "turn", flags: r(e) } : { kind: "none" };
}
function Lee(t) {
  return t === _r.SecondaryStructureDssp.H || t === _r.SecondaryStructureDssp.G || t === _r.SecondaryStructureDssp.I ? "helix" : t === _r.SecondaryStructureDssp.B || t === _r.SecondaryStructureDssp.E ? "sheet" : t === _r.SecondaryStructureDssp.T ? "turn" : t === _r.SecondaryStructureDssp.S ? "bend" : "none";
}
function kee(t) {
  return qt.is(t, 1) ? _r.SecondaryStructureDssp.H : qt.is(t, 4) ? _r.SecondaryStructureDssp.E : qt.is(t, 2) ? _r.SecondaryStructureDssp.B : qt.is(t, 8) ? _r.SecondaryStructureDssp.G : qt.is(t, 16) ? _r.SecondaryStructureDssp.I : qt.is(t, 64) ? _r.SecondaryStructureDssp.T : qt.is(t, 32) ? _r.SecondaryStructureDssp.S : 0;
}
function Gee(t) {
  return qt.is(t, 1) ? "H" : qt.is(t, 4) ? "E" : qt.is(t, 2) ? "B" : qt.is(t, 8) ? "G" : qt.is(t, 16) ? "I" : qt.is(t, 64) ? "T" : qt.is(t, 32) ? "S" : "-";
}
function zee(t) {
  return qt.is(t, 16) ? _r.SecondaryStructureDssp.I : qt.is(t, 1) ? _r.SecondaryStructureDssp.H : qt.is(t, 4) ? _r.SecondaryStructureDssp.E : qt.is(t, 2) ? _r.SecondaryStructureDssp.B : qt.is(t, 8) ? _r.SecondaryStructureDssp.G : qt.is(t, 64) ? _r.SecondaryStructureDssp.T : qt.is(t, 32) ? _r.SecondaryStructureDssp.S : 0;
}
function Vee(t) {
  return qt.is(t, 16) ? "I" : qt.is(t, 1) ? "H" : qt.is(t, 4) ? "E" : qt.is(t, 2) ? "B" : qt.is(t, 8) ? "G" : qt.is(t, 64) ? "T" : qt.is(t, 32) ? "S" : "-";
}
function kR(t) {
  var e = "model";
  if (t) {
    e = "model";
    for (var r = 0, n = t.models.length; r < n; ++r) {
      var i = t.models[r];
      if (!pn.isFromPdbArchive(i) && !pn.hasSecondaryStructure(i)) {
        e = "dssp";
        break;
      }
    }
  }
  return { type: z.MappedStatic(e, { model: z.EmptyGroup({ label: "Model" }), dssp: z.Group(Ree, { label: "DSSP", isFlat: !0 }) }, { options: [["model", "Model"], ["dssp", "DSSP"]] }) };
}
(function(t) {
  function e(r) {
    var n = this, i = r.descriptor.name, a = r.type === "root" ? "inheritedPropertyData" : "currentPropertyData", o = function(u) {
      return i in u[a] || (u[a][i] = { props: O({}, z.getDefaultValues(r.getParams(u))), data: Gd.create(void 0) }), u[a][i];
    }, s = function(u, c, l) {
      var d = o(u);
      u[a][i] = { props: c, data: Gd.withValue(d.data, l) };
    };
    return { label: r.label, descriptor: r.descriptor, isHidden: r.isHidden, getParams: function(u) {
      var c = z.clone(r.getParams(u));
      return z.setDefaultValues(c, o(u).props), c;
    }, defaultParams: r.defaultParams, isApplicable: r.isApplicable, attach: function(u, c, l, d) {
      return l === void 0 && (l = {}), _e(n, 0, void 0, function() {
        var f, h, m, p, v, g;
        return ye(this, function(y) {
          switch (y.label) {
            case 0:
              return d && c.customPropertyDescriptors.reference(r.descriptor, !0), r.type === "root" && (c = c.root), f = o(c.root).props, h = o(c), m = z.merge(r.defaultParams, f, l), h.data.value && z.areEqual(r.defaultParams, h.props, m) ? [2] : [4, r.obtain(u, c, m)];
            case 1:
              return p = y.sent(), v = p.value, g = p.assets, c.customPropertyDescriptors.add(r.descriptor), c.customPropertyDescriptors.assets(r.descriptor, g), s(c, m, v), [2];
          }
        });
      });
    }, ref: function(u, c) {
      return u.customPropertyDescriptors.reference(r.descriptor, c);
    }, get: function(u) {
      return o(u).data;
    }, set: function(u, c, l) {
      c === void 0 && (c = {}), r.type === "root" && (u = u.root);
      var d = o(u), f = z.merge(r.defaultParams, d.props, c);
      z.areEqual(r.defaultParams, d.props, f) || (s(u, f, l), u.customPropertyDescriptors.assets(r.descriptor));
    }, props: function(u) {
      return o(u).props;
    } };
  }
  t.createProvider = e, t.createSimple = function(r, n, i) {
    var a = this, o = { value: z.Value(i, { isHidden: !0 }) };
    return e({ label: mc(r), descriptor: ku({ name: r }), isHidden: !0, type: n, defaultParams: o, getParams: function() {
      return { value: z.Value(i, { isHidden: !0 }) };
    }, isApplicable: function() {
      return !0;
    }, obtain: function(s, u, c) {
      return _e(a, 0, void 0, function() {
        return ye(this, function(l) {
          return [2, O(O({}, z.getDefaultValues(o)), c)];
        });
      });
    } });
  };
})(Cp || (Cp = {}));
var oE = kR(), Ha = Cp.createProvider({ label: "Secondary Structure", descriptor: ku({ name: "molstar_computed_secondary_structure" }), type: "root", defaultParams: oE, getParams: kR, isApplicable: function(t) {
  return !0;
}, obtain: function(t, e, r) {
  return _e(void 0, 0, void 0, function() {
    var n, i, a;
    return ye(this, function(o) {
      switch (o.label) {
        case 0:
          switch (n = O(O({}, z.getDefaultValues(oE)), r), n.type.name) {
            case "dssp":
              return [3, 1];
            case "model":
              return [3, 3];
          }
          return [3, 5];
        case 1:
          return i = {}, [4, Uee(e, n.type.params)];
        case 2:
          return [2, (i.value = o.sent(), i)];
        case 3:
          return a = {}, [4, Hee(e)];
        case 4:
          return [2, (a.value = o.sent(), a)];
        case 5:
          return [2];
      }
    });
  });
} });
function Uee(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          r = /* @__PURE__ */ new Map(), n = 0, i = t.unitSymmetryGroups.length, s.label = 1;
        case 1:
          return n < i ? (a = t.unitSymmetryGroups[n].units[0], !Fe.isAtomic(a) || pn.isCoarseGrained(a.model) ? [3, 3] : [4, LR(a, e)]) : [3, 4];
        case 2:
          o = s.sent(), r.set(a.invariantId, o), s.label = 3;
        case 3:
          return ++n, [3, 1];
        case 4:
          return [2, r];
      }
    });
  });
}
function Hee(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a;
    return ye(this, function(o) {
      switch (o.label) {
        case 0:
          e = /* @__PURE__ */ new Map(), r = 0, n = t.unitSymmetryGroups.length, o.label = 1;
        case 1:
          return r < n ? (i = t.unitSymmetryGroups[r].units[0], Fe.isAtomic(i) ? pn.isFromPdbArchive(i.model) || pn.hasSecondaryStructure(i.model) ? [3, 3] : [4, LR(i, { oldDefinition: !0, oldOrdering: !0 })] : [3, 4]) : [3, 5];
        case 2:
          return a = o.sent(), e.set(i.invariantId, a), [3, 4];
        case 3:
          (a = Km.Provider.get(i.model)) && e.set(i.invariantId, a), o.label = 4;
        case 4:
          return ++r, [3, 1];
        case 5:
          return [2, e];
      }
    });
  });
}
function Tn() {
  throw new Error("Property only available for atomic models.");
}
function Hc(t) {
  throw t ? new Error("Property only available for coarse models (".concat(t, ").")) : new Error("Property only available for coarse models.");
}
var mm = { key: function(t) {
  return t.element;
}, x: function(t) {
  return t.unit.conformation.x(t.element);
}, y: function(t) {
  return t.unit.conformation.y(t.element);
}, z: function(t) {
  return t.unit.conformation.z(t.element);
}, id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicConformation.atomId.value(t.element) : Tn();
}, occupancy: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicConformation.occupancy.value(t.element) : Tn();
}, B_iso_or_equiv: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicConformation.B_iso_or_equiv.value(t.element) : Tn();
}, sourceIndex: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atomSourceIndex.value(t.element) : t.element;
}, type_symbol: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atoms.type_symbol.value(t.element) : Tn();
}, label_atom_id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atoms.label_atom_id.value(t.element) : Tn();
}, auth_atom_id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atoms.auth_atom_id.value(t.element) : Tn();
}, label_alt_id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atoms.label_alt_id.value(t.element) : Tn();
}, label_comp_id: rx, auth_comp_id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atoms.auth_comp_id.value(t.element) : Tn();
}, pdbx_formal_charge: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(t.element) : Tn();
}, vdw_radius: function(t) {
  return Fe.isAtomic(t.unit) ? Gy(t.unit.model.atomicHierarchy.atoms.type_symbol.value(t.element)) : Tn();
}, cdr: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atoms.cdr.value(t.element) : Tn();
}, em_confidence: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.atoms.em_confidence.value(t.element) : Tn();
} };
function rx(t) {
  return Fe.isAtomic(t.unit) || Tn(), t.unit.model.atomicHierarchy.atoms.label_comp_id.value(t.element);
}
function Z_(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.residues.label_seq_id.value(t.unit.residueIndex[t.element]) : Tn();
}
function sE(t) {
  Fe.isAtomic(t.unit) || Tn();
  var e = t.unit.model.sequence.byEntityKey[go(t)];
  return e && e.sequence.microHet.get(Z_(t)) || [rx(t)];
}
var qee = { key: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.residueIndex[t.element] : Tn();
}, group_PDB: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.residues.group_PDB.value(t.unit.residueIndex[t.element]) : Tn();
}, label_seq_id: Z_, auth_seq_id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.residues.auth_seq_id.value(t.unit.residueIndex[t.element]) : Tn();
}, pdbx_PDB_ins_code: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(t.unit.residueIndex[t.element]) : Tn();
}, isNonStandard: function(t) {
  return Fe.isAtomic(t.unit) ? sE(t).some(function(e) {
    return t.unit.model.properties.chemicalComponentMap.get(e).mon_nstd_flag[0] === "n";
  }) : Tn();
}, hasMicroheterogeneity: function(t) {
  Fe.isAtomic(t.unit) || Tn();
  var e = t.unit.model.sequence.byEntityKey[go(t)];
  return e && e.sequence.microHet.has(Z_(t));
}, microheterogeneityCompIds: sE, secondary_structure_type: function(t) {
  var e;
  Fe.isAtomic(t.unit) || Tn();
  var r = (e = Ha.get(t.structure).value) === null || e === void 0 ? void 0 : e.get(t.unit.invariantId);
  return r ? r.type[r.getIndex(t.unit.residueIndex[t.element])] : 536870912;
}, secondary_structure_key: function(t) {
  var e;
  Fe.isAtomic(t.unit) || Tn();
  var r = (e = Ha.get(t.structure).value) === null || e === void 0 ? void 0 : e.get(t.unit.invariantId);
  return r ? r.key[r.getIndex(t.unit.residueIndex[t.element])] : -1;
}, chem_comp_type: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.properties.chemicalComponentMap.get(rx(t)).type : Tn();
} }, Kee = { key: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.chainIndex[t.element] : Tn();
}, label_asym_id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.chains.label_asym_id.value(t.unit.chainIndex[t.element]) : Tn();
}, auth_asym_id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.chains.auth_asym_id.value(t.unit.chainIndex[t.element]) : Tn();
}, label_entity_id: function(t) {
  return Fe.isAtomic(t.unit) ? t.unit.model.atomicHierarchy.chains.label_entity_id.value(t.unit.chainIndex[t.element]) : Tn();
} }, Xee = { key: mm.key, entityKey: function(t) {
  return Fe.isCoarse(t.unit) ? t.unit.coarseElements.entityKey[t.element] : Hc();
}, x: mm.x, y: mm.y, z: mm.z, asym_id: function(t) {
  return Fe.isCoarse(t.unit) ? t.unit.coarseElements.asym_id.value(t.element) : Hc();
}, entity_id: function(t) {
  return Fe.isCoarse(t.unit) ? t.unit.coarseElements.entity_id.value(t.element) : Hc();
}, seq_id_begin: function(t) {
  return Fe.isCoarse(t.unit) ? t.unit.coarseElements.seq_id_begin.value(t.element) : Hc();
}, seq_id_end: function(t) {
  return Fe.isCoarse(t.unit) ? t.unit.coarseElements.seq_id_end.value(t.element) : Hc();
}, sphere_radius: function(t) {
  return Fe.isSpheres(t.unit) ? t.unit.coarseConformation.radius[t.element] : Hc("spheres");
}, sphere_rmsf: function(t) {
  return Fe.isSpheres(t.unit) ? t.unit.coarseConformation.rmsf[t.element] : Hc("spheres");
}, gaussian_weight: function(t) {
  return Fe.isGaussians(t.unit) ? t.unit.coarseConformation.weight[t.element] : Hc("gaussians");
}, gaussian_covariance_matrix: function(t) {
  return Fe.isGaussians(t.unit) ? t.unit.coarseConformation.covariance_matrix[t.element] : Hc("gaussians");
} };
function go(t) {
  switch (t.unit.kind) {
    case 0:
      return t.unit.model.atomicHierarchy.index.getEntityFromChain(t.unit.chainIndex[t.element]);
    case 1:
      return t.unit.model.coarseHierarchy.spheres.entityKey[t.element];
    case 2:
      return t.unit.model.coarseHierarchy.gaussians.entityKey[t.element];
  }
}
var Yee = { key: go, id: function(t) {
  return t.unit.model.entities.data.id.value(go(t));
}, type: function(t) {
  return t.unit.model.entities.data.type.value(go(t));
}, src_method: function(t) {
  return t.unit.model.entities.data.src_method.value(go(t));
}, pdbx_description: function(t) {
  return t.unit.model.entities.data.pdbx_description.value(go(t));
}, formula_weight: function(t) {
  return t.unit.model.entities.data.formula_weight.value(go(t));
}, pdbx_number_of_molecules: function(t) {
  return t.unit.model.entities.data.pdbx_number_of_molecules.value(go(t));
}, details: function(t) {
  return t.unit.model.entities.data.details.value(go(t));
}, pdbx_mutation: function(t) {
  return t.unit.model.entities.data.pdbx_mutation.value(go(t));
}, pdbx_fragment: function(t) {
  return t.unit.model.entities.data.pdbx_fragment.value(go(t));
}, pdbx_ec: function(t) {
  return t.unit.model.entities.data.pdbx_ec.value(go(t));
}, subtype: function(t) {
  return t.unit.model.entities.subtype.value(go(t));
}, prd_id: function(t) {
  var e, r;
  return (r = (e = t.unit.model.entities.prd_id) === null || e === void 0 ? void 0 : e.value(go(t))) !== null && r !== void 0 ? r : "";
} }, Wee = [], jee = { id: function(t) {
  return t.unit.id;
}, chainGroupId: function(t) {
  return t.unit.chainGroupId;
}, multiChain: function(t) {
  return Fe.Traits.is(t.unit.traits, 1);
}, object_primitive: function(t) {
  return t.unit.objectPrimitive;
}, operator_name: function(t) {
  return t.unit.conformation.operator.name;
}, model_index: function(t) {
  return t.unit.model.modelNum;
}, model_label: function(t) {
  return t.unit.model.label;
}, model_entry_id: function(t) {
  return t.unit.model.entryId;
}, hkl: function(t) {
  return t.unit.conformation.operator.hkl;
}, spgrOp: function(t) {
  return t.unit.conformation.operator.spgrOp;
}, model_num: function(t) {
  return t.unit.model.modelNum;
}, pdbx_struct_assembly_id: function(t) {
  var e;
  return ((e = t.unit.conformation.operator.assembly) === null || e === void 0 ? void 0 : e.id) || wn.DefaultName;
}, pdbx_struct_oper_list_ids: function(t) {
  var e;
  return ((e = t.unit.conformation.operator.assembly) === null || e === void 0 ? void 0 : e.operList) || Wee;
}, struct_ncs_oper_id: function(t) {
  return t.unit.conformation.operator.ncsId;
} }, Qe = { constant: { true: function(t) {
  return !0;
}, false: function(t) {
  return !1;
}, zero: function(t) {
  return 0;
} }, atom: mm, residue: qee, chain: Kee, entity: Yee, unit: jee, coarse: Xee }, Mm = function() {
  function t(e) {
    var r;
    this.index = /* @__PURE__ */ new Map(), this.checkOperator = !1, this.checkOperator = (r = e == null ? void 0 : e.checkOperator) !== null && r !== void 0 && r;
  }
  return t.prototype.add = function(e) {
    var r = this.index.get(e.label_asym_id);
    r || (r = /* @__PURE__ */ new Map(), this.index.set(e.label_asym_id, r));
    var n = r.get(e.label_seq_id);
    return n || (n = [], r.set(e.label_seq_id, n)), !this._find(e, n) && (n.push(e), !0);
  }, t.prototype.hasLabelAsymId = function(e) {
    return this.index.has(e);
  }, t.prototype.has = function(e) {
    var r, n, i = uE(e);
    if (this.index.has(i)) {
      var a = this.index.get(i), o = cE(e);
      if (a.has(o)) for (var s = a.get(o), u = lE(e), c = dE(e), l = fE(e), d = (r = pE(e)) !== null && r !== void 0 ? r : "1_555", f = 0, h = s; f < h.length; f++) {
        var m = h[f];
        if (m.label_comp_id === u && m.label_alt_id === c && m.ins_code === l && (!this.checkOperator || ((n = m.operator_name) !== null && n !== void 0 ? n : "1_555") === d)) return m;
      }
    }
  }, t.getLabel = function(e, r) {
    var n;
    return r === void 0 && (r = !1), "".concat(e.label_asym_id, " ").concat(e.label_comp_id, " ").concat(e.label_seq_id, ":").concat(e.ins_code, ":").concat(e.label_alt_id).concat(r ? " " + ((n = e.operator_name) !== null && n !== void 0 ? n : "1_555") : "");
  }, t.getEntryFromLocation = function(e) {
    var r;
    return { label_asym_id: uE(e), label_comp_id: lE(e), label_seq_id: cE(e), label_alt_id: dE(e), ins_code: fE(e), operator_name: (r = pE(e)) !== null && r !== void 0 ? r : "1_555" };
  }, t.prototype._find = function(e, r) {
    for (var n, i, a = 0, o = r; a < o.length; a++) {
      var s = o[a];
      if (s.label_comp_id === e.label_comp_id && s.label_alt_id === e.label_alt_id && s.ins_code === e.ins_code && (!this.checkOperator || ((n = s.operator_name) !== null && n !== void 0 ? n : "1_555") === ((i = e.operator_name) !== null && i !== void 0 ? i : "1_555"))) return !0;
    }
    return !1;
  }, t;
}(), uE = Qe.chain.label_asym_id, cE = Qe.residue.label_seq_id, lE = Qe.atom.label_comp_id, dE = Qe.atom.label_alt_id, fE = Qe.residue.pdbx_PDB_ins_code, pE = Qe.unit.operator_name;
function dp(t, e, r) {
  for (var n = e.subsetBuilder(!0), i = 0, a = r.units; i < a.length; i++) {
    var o = a[i];
    if (o.kind === 0) {
      var s = o.model.atomicHierarchy.residueAtomSegments, u = e.unitMap.get(o.id).elements, c = o.elements;
      n.beginUnit(o.id);
      for (var l = Qt.transientSegments(s, c); l.hasNext; ) for (var d = l.move().index, f = s.offsets[d], h = s.offsets[d + 1]; f < h; f++) Ke.has(u, f) && n.addElement(f);
      n.commitUnit(), t.throwIfTimedOut();
    } else n.setUnit(o.id, o.elements);
  }
  return n.getStructure();
}
function ib(t, e, r, n) {
  for (var i = new Oy(e), a = e.lookup3d, o = n.radius, s = 0, u = r.units; s < u.length; s++) {
    for (var c = u[s], l = c.conformation, d = l.x, f = l.y, h = l.z, m = c.elements, p = 0, v = m.length; p < v; p++) {
      var g = m[p];
      a.findIntoBuilder(d(g), f(g), h(g), o, i);
    }
    t.throwIfTimedOut();
  }
  return n.wholeResidues ? dp(t, e, i.getStructure()) : i.getStructure();
}
function hE(t, e, r, n) {
  var i = new Oy(e), a = e.lookup3d, o = n.elementRadius, s = n.elementRadiusClosure, u = n.sourceMaxRadius, c = n.radius;
  t.pushCurrentElement(), t.element.structure = r;
  for (var l = 0, d = r.units; l < d.length; l++) {
    var f = d[l];
    t.element.unit = f;
    for (var h = f.conformation, m = h.x, p = h.y, v = h.z, g = f.elements, y = 0, b = g.length; y < b; y++) {
      var S = g[y];
      t.element.element = S;
      var _ = o(t);
      a.findIntoBuilderWithRadius(m(S), p(S), v(S), _, u, c, s, i);
    }
    t.throwIfTimedOut();
  }
  return t.popCurrentElement(), n.wholeResidues ? dp(t, e, i.getStructure()) : i.getStructure();
}
function Zee(t, e) {
  return function(r) {
    return t.element.structure = r.structure, t.element.unit = r.unit, t.element.element = r.element, e(t);
  };
}
function Qee(t, e) {
  var r = 0;
  t.element.structure = t.inputStructure;
  for (var n = 0, i = t.inputStructure.units; n < i.length; n++) {
    var a = i[n];
    t.element.unit = a;
    for (var o = a.elements, s = 0, u = o.length; s < u; s++) {
      var c = o[s];
      t.element.element = c;
      var l = e(t);
      l > r && (r = l);
    }
  }
  return t.throwIfTimedOut(), r;
}
function mE(t, e, r) {
  var n = function(i, a) {
    for (var o = i.inputStructure, s = o.interUnitBonds, u = new Oy(o), c = i.atomicBond, l = 0, d = a.units; l < d.length; l++) {
      var f = d[l];
      if (f.kind === 0) {
        var h = o.unitMap.get(f.id), m = h.bonds, p = m.offset, v = m.b, g = m.edgeProps, y = g.flags, b = g.order;
        for (c.setStructure(o), c.a.unit = h, c.b.unit = h, H = 0, K = f.elements.length; H < K; H++) {
          u.addToUnit(f.id, f.elements[H]);
          for (var S = Ke.indexOf(h.elements, f.elements[H]), _ = p[S], x = p[S + 1]; _ < x; _++) {
            var C = v[_], A = h.elements[C];
            Ke.has(f.elements, A) || u.has(f.id, A) || (c.aIndex = S, c.a.element = f.elements[H], c.bIndex = C, c.b.element = A, c.type = y[_], c.order = b[_], c.test(i, !0) && u.addToUnit(f.id, A));
          }
        }
        for (var w = 0, I = s.getConnectedUnits(h.id); w < I.length; w++) for (var P = I[w], M = a.unitMap.get(P.unitB), T = o.unitMap.get(P.unitB), F = 0, N = P.connectedIndices; F < N.length; F++) {
          var R = N[F];
          if (Ke.has(f.elements, h.elements[R])) for (var L = 0, V = P.getEdges(R); L < V.length; L++) {
            var U = V[L];
            A = T.elements[U.indexB], M && Ke.has(M.elements, A) || u.has(P.unitB, A) || (c.a.unit = h, c.aIndex = R, c.a.element = h.elements[R], c.b.unit = T, c.bIndex = U.indexB, c.b.element = A, c.type = U.props.flag, c.order = U.props.order, c.test(i, !0) && u.addToUnit(P.unitB, A));
          }
        }
      } else {
        u.beginUnit(f.id);
        for (var H = 0, K = f.elements.length; H < K; H++) u.addElement(f.elements[H]);
        u.commitUnit();
      }
    }
    return u.getStructure();
  }(t, r);
  return e ? dp(t, t.inputStructure, n) : n;
}
var Jee = Qe.entity.type;
function $ee(t) {
  return Jee(t) === "water";
}
var G3, z3, ete = function() {
  function t() {
    this.vertices = /* @__PURE__ */ new Map(), this.edges = /* @__PURE__ */ new Map();
  }
  return t.prototype.addVertex = function(e, r) {
    this.vertices.has(r) || (this.vertices.set(r, e), this.edges.set(r, []));
  }, t.prototype.addEdge = function(e, r) {
    var n = Mm.getLabel(e), i = Mm.getLabel(r);
    this.addVertex(e, n), this.addVertex(r, i), Qs(this.edges.get(n), i), Qs(this.edges.get(i), n);
  }, t.prototype.addComponent = function(e, r) {
    var n = Mm.getLabel(e);
    if (this.vertices.has(n)) {
      var i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = [n];
      for (a.add(n), r.add(e); 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 f = this.vertices.get(d);
            u.operator_name === f.operator_name ? r.add(O(O({}, f), { operator_name: e.operator_name })) : r.add(f);
          }
        }
      }
    } else r.add(e);
  }, t;
}(), tte = Object.freeze({ __proto__: null, exceptBy: function(t, e) {
  return function(r) {
    var n = t(r);
    if (gt.structureCount(n) === 0) return n;
    var i = e(r);
    if (gt.structureCount(i) === 0) return n;
    var a = gt.unionStructure(i), o = gt.UniqueBuilder(r.inputStructure);
    return gt.forEach(n, function(s, u) {
      var c = DR(s, a);
      c.elementCount !== 0 && o.add(c), u % 50 == 0 && r.throwIfTimedOut();
    }), o.getSelection();
  };
}, expandProperty: function(t, e) {
  return function(r) {
    var n = t(r), i = /* @__PURE__ */ new Map(), a = [];
    r.pushCurrentElement(), gt.forEach(n, function(S, _) {
      r.element.structure = S;
      for (var x = 0, C = S.units; x < C.length; x++) {
        var A = C[x];
        r.element.unit = A;
        for (var w = A.elements, I = 0, P = w.length; I < P; I++) {
          r.element.element = w[I];
          var M = e(r), T = void 0;
          i.has(M) ? T = i.get(M) : (T = bn.create(), i.set(M, T)), bn.add(T, _, _);
        }
      }
      a[_] = r.inputStructure.subsetBuilder(!0), _ % 10 == 0 && r.throwIfTimedOut();
    }), r.element.structure = r.inputStructure;
    for (var o = 0, s = r.inputStructure.units; o < s.length; o++) {
      var u = s[o];
      r.element.unit = u;
      for (var c = u.elements, l = 0, d = c.length; l < d; l++) {
        r.element.element = c[l];
        var f = e(r);
        if (i.has(f)) for (var h = i.get(f).array, m = 0, p = h.length; m < p; m++) a[h[m]].addToUnit(u.id, c[l]);
      }
    }
    r.popCurrentElement();
    for (var v = gt.UniqueBuilder(r.inputStructure), g = 0, y = a; g < y.length; g++) {
      var b = y[g];
      v.add(b.getStructure());
    }
    return v.getSelection();
  };
}, includeConnected: function(t) {
  var e = t.query, r = t.layerCount, n = t.wholeResidues, i = t.bondTest, a = t.fixedPoint, o = Math.max(r, 0);
  return function(s) {
    var u = gt.UniqueBuilder(s.inputStructure), c = e(s);
    return s.pushCurrentBond(), s.atomicBond.setTestFn(i), gt.forEach(c, function(l, d) {
      var f = l;
      if (a) for (; ; ) {
        var h = f.elementCount;
        if ((f = mE(s, n, f)).elementCount === h) break;
      }
      else for (var m = 0; m < o; m++) f = mE(s, n, f);
      u.add(f), d % 10 == 0 && s.throwIfTimedOut();
    }), s.popCurrentBond(), u.getSelection();
  };
}, includeSurroundings: function(t, e) {
  return function(r) {
    var n = t(r);
    if (e.elementRadius) {
      var i = O(O({}, e), { elementRadius: e.elementRadius, elementRadiusClosure: Zee(r, e.elementRadius), sourceMaxRadius: Qee(r, e.elementRadius) });
      if (gt.isSingleton(n)) {
        var a = hE(r, r.inputStructure, n.structure, i);
        return gt.Singletons(r.inputStructure, a);
      }
      for (var o = new Q6(r.inputStructure), s = 0, u = n.structures; s < u.length; s++) {
        var c = u[s];
        o.add(hE(r, r.inputStructure, c, i));
      }
      return o.getSelection();
    }
    if (gt.isSingleton(n))
      return a = ib(r, r.inputStructure, n.structure, e), gt.Singletons(r.inputStructure, a);
    o = new Q6(r.inputStructure);
    for (var l = 0, d = n.structures; l < d.length; l++)
      c = d[l], o.add(ib(r, r.inputStructure, c, e));
    return o.getSelection();
  };
}, intersectBy: function(t, e) {
  return function(r) {
    var n = t(r);
    if (gt.structureCount(n) === 0) return n;
    var i = e(r);
    if (gt.structureCount(i) === 0) return gt.Empty(r.inputStructure);
    var a = gt.unionStructure(i), o = gt.UniqueBuilder(r.inputStructure);
    return gt.forEach(n, function(s, u) {
      var c = function(l, d) {
        if (l === d) return l;
        if (!tx(l, d)) return tt.Empty;
        var f, h;
        l.units.length < d.units.length ? (f = l, h = d) : (f = d, h = l);
        for (var m = f.units, p = h.unitMap, v = [], g = 0, y = m.length; g < y; g++) {
          var b = m[g];
          if (p.has(b.id)) {
            var S = p.get(b.id);
            if (Ke.areIntersecting(b.elements, S.elements)) {
              var _ = Ke.intersect(b.elements, S.elements);
              v[v.length] = b.getChild(_);
            }
          }
        }
        return tt.create(v, { parent: l.parent || d.parent });
      }(a, s);
      c.elementCount !== 0 && o.add(c), u % 50 == 0 && r.throwIfTimedOut();
    }), o.getSelection();
  };
}, querySelection: function(t, e) {
  return function(r) {
    var n = t(r);
    if (gt.structureCount(n) === 0) return n;
    var i = gt.UniqueBuilder(r.inputStructure), a = function(o) {
      return i.add(o);
    };
    return gt.forEach(n, function(o, s) {
      r.pushInputStructure(o), gt.forEach(e(r), a), r.popInputStructure(), s % 10 == 0 && r.throwIfTimedOut();
    }), i.getSelection();
  };
}, surroundingLigands: function(t) {
  var e = t.query, r = t.radius, n = t.includeWater;
  return function(i) {
    for (var a = gt.unionStructure(e(i)), o = dp(i, i.inputStructure, ib(i, i.inputStructure, a, { radius: r })), s = function(X) {
      var Y = X.models[0], Q = /* @__PURE__ */ new Set();
      if (!An.is(Y.sourceData)) return Q;
      for (var J = Y.sourceData.data.db.pdbx_molecule, te = J._rowCount, W = J.asym_id, j = 0; j < te; j++) Q.add(W.value(j));
      return Q;
    }(i.inputStructure), u = function(X) {
      var Y, Q, J = X.models[0], te = new ete();
      if (!An.is(J.sourceData)) return te;
      for (var W = J.sourceData.data.db.struct_conn, j = W.conn_type_id, ee = W.ptnr1_label_asym_id, ie = W.ptnr1_label_comp_id, ae = W.ptnr1_label_seq_id, ce = W.ptnr1_symmetry, de = W.pdbx_ptnr1_label_alt_id, Ce = W.pdbx_ptnr1_PDB_ins_code, De = W.ptnr2_label_asym_id, ke = W.ptnr2_label_comp_id, He = W.ptnr2_label_seq_id, We = W.ptnr2_symmetry, Ne = W.pdbx_ptnr2_label_alt_id, Je = W.pdbx_ptnr2_PDB_ins_code, Re = 0; Re < W._rowCount; Re++) {
        var nt = j.value(Re);
        if (nt === "covale" || nt === "metalc") {
          var ne = { label_asym_id: ee.value(Re), label_comp_id: ie.value(Re), label_seq_id: ae.value(Re), label_alt_id: de.value(Re), ins_code: Ce.value(Re), operator_name: (Y = ce.value(Re)) !== null && Y !== void 0 ? Y : "1_555" }, re = { label_asym_id: De.value(Re), label_comp_id: ke.value(Re), label_seq_id: He.value(Re), label_alt_id: Ne.value(Re), ins_code: Je.value(Re), operator_name: (Q = We.value(Re)) !== null && Q !== void 0 ? Q : "1_555" };
          te.addEdge(ne, re);
        }
      }
      return te;
    }(i.inputStructure), c = at.create(o), l = /* @__PURE__ */ new Map(), d = new Mm({ checkOperator: !0 }), f = 0, h = o.units; f < h.length; f++)
      if ((F = h[f]).kind === 0) {
        c.unit = F;
        for (var m = F.elements, p = Qt.transientSegments(F.model.atomicHierarchy.chainAtomSegments, m), v = Qt.transientSegments(F.model.atomicHierarchy.residueAtomSegments, m); p.hasNext; ) {
          var g = p.move();
          c.element = m[g.start];
          var y = Qe.chain.label_asym_id(c), b = Qe.unit.operator_name(c);
          if (s.has(y)) l.has(y) ? Qs(l.get(y), b) : l.set(y, [b]);
          else {
            var S = Qe.entity.type(c);
            if (S !== "water" && S !== "polymer") for (v.setSegment(g); v.hasNext; ) {
              var _ = v.move();
              c.element = m[_.start], u.addComponent(Mm.getEntryFromLocation(c), d);
            }
          }
        }
        i.throwIfTimedOut();
      }
    for (var x = i.inputStructure.subsetBuilder(!0), C = 0, A = i.inputStructure.units; C < A.length; C++)
      if ((F = A[C]).kind === 0) {
        for (c.unit = F, m = F.elements, p = Qt.transientSegments(F.model.atomicHierarchy.chainAtomSegments, m), v = Qt.transientSegments(F.model.atomicHierarchy.residueAtomSegments, m), x.beginUnit(F.id); p.hasNext; )
          if (g = p.move(), c.element = m[g.start], y = Qe.chain.label_asym_id(c), b = Qe.unit.operator_name(c), l.has(y) && l.get(y).indexOf(b) >= 0) x.addElementRange(m, g.start, g.end);
          else if (d.hasLabelAsymId(y)) for (v.setSegment(g); v.hasNext; )
            _ = v.move(), c.element = m[_.start], d.has(c) && x.addElementRange(m, _.start, _.end);
        x.commitUnit(), i.throwIfTimedOut();
      }
    var w = L3(i.inputStructure, [x.getStructure(), a]);
    if (n) {
      for (var I = new Oy(i.inputStructure), P = i.inputStructure.lookup3d, M = 0, T = w.units; M < T.length; M++) {
        for (var F, N = (F = T[M]).conformation, R = N.x, L = N.y, V = N.z, U = 0, H = (m = F.elements).length; U < H; U++) {
          var K = m[U];
          P.findIntoBuilderIf(R(K), L(K), V(K), r, I, $ee), I.addToUnit(F.id, K);
        }
        i.throwIfTimedOut();
      }
      return gt.Sequence(i.inputStructure, [I.getStructure()]);
    }
    return gt.Sequence(i.inputStructure, [w]);
  };
}, union: function(t) {
  return function(e) {
    var r = gt.LinearBuilder(e.inputStructure);
    return r.add(gt.unionStructure(t(e))), r.getSelection();
  };
}, wholeResidues: function(t) {
  return function(e) {
    var r = t(e);
    if (gt.isSingleton(r)) return gt.Singletons(e.inputStructure, dp(e, e.inputStructure, r.structure));
    for (var n = new Q6(e.inputStructure), i = 0, a = r.structures; i < a.length; i++) {
      var o = a[i];
      n.add(dp(e, e.inputStructure, o));
    }
    return n.getSelection();
  };
} });
function ab(t, e, r) {
  var n = t.currentStructure.units, i = t.pushCurrentElement();
  i.structure = t.currentStructure;
  for (var a = 0, o = n; a < o.length; a++) {
    var s = o[a];
    i.unit = s;
    var u = s.elements, c = void 0;
    if (c = Fe.isAtomic(s) ? e.atomic : e.coarse) {
      for (var l = 0, d = u.length; l < d; l++) i.element = u[l], r.add(c(t));
      t.throwIfTimedOut();
    }
  }
  return t.popCurrentElement(), r;
}
(function(t) {
  var e = E.zero();
  function r(a, o, s, u, c, l, d) {
    var f = o.elements, h = o.conformation.position, m = e;
    a.element.unit = o;
    for (var p = !1, v = 0, g = f.length; v < g; v++) {
      var y = f[v];
      a.element.element = y;
      var b = Math.max(0, E.distance(s, h(y, m)) - u - d(a));
      if (b < c) return 0;
      b < l && (p = !0);
    }
    return p ? 1 : 2;
  }
  function n(a, o, s, u, c, l, d) {
    for (var f = o.units, h = !1, m = 0, p = f.length; m < p; m++) {
      var v = r(a, f[m], s, u, c, l, d);
      if (v === 0) return 0;
      v === 1 && (h = !0);
    }
    return h ? 1 : 2;
  }
  t.toPoint = n;
  var i = E.zero();
  t.check = function(a, o, s, u, c, l) {
    if (o.elementCount === 0 || s.elementCount === 0) return 0;
    var d = o.units, f = !1;
    a.element.structure = o;
    for (var h = 0, m = d.length; h < m; h++) {
      var p = d[h], v = p.elements, g = p.conformation.position;
      a.element.unit = p;
      for (var y = 0, b = v.length; y < b; y++) {
        var S = v[y];
        a.element.element = S;
        var _ = n(a, s, g(S, i), l(a), u, c, l);
        if (_ === 0) return 0;
        _ === 1 && (f = !0);
      }
    }
    return f;
  };
})(G3 || (G3 = {})), function(t) {
  var e = E.zero();
  function r(a, o, s, u, c, l) {
    var d = o.elements, f = o.conformation.position, h = e;
    a.element.unit = o;
    for (var m = 0, p = d.length; m < p; m++) {
      var v = d[m];
      if (a.element.element = v, Math.max(0, E.distance(s, f(v, h)) - u - l(a)) <= c) return !0;
    }
    return !1;
  }
  function n(a, o, s, u, c, l) {
    for (var d = o.units, f = 0, h = d.length; f < h; f++) if (r(a, d[f], s, u, c, l)) return !0;
    return !1;
  }
  t.toPoint = n;
  var i = E.zero();
  t.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, f = l.length; d < f; d++) {
      var h = l[d];
      a.element.unit = h;
      for (var m = h.elements, p = h.conformation.position, v = 0, g = m.length; v < g; v++) {
        var y = m[v];
        if (a.element.element = y, n(a, s, p(y, i), c(a), u, c)) return !0;
      }
    }
    return !1;
  };
}(z3 || (z3 = {}));
var rte = Object.freeze({ __proto__: null, areIntersectedBy: function(t, e) {
  return function(r) {
    var n = gt.unionStructure(e(r)), i = gt.LinearBuilder(r.inputStructure);
    return gt.forEach(t(r), function(a, o) {
      tx(n, a) && i.add(a), o % 10 && r.throwIfTimedOut();
    }), i.getSelection();
  };
}, first: function(t) {
  return function(e) {
    var r = t(e), n = gt.LinearBuilder(e.inputStructure);
    if (r.kind === "singletons") {
      if (r.structure.elementCount > 0) {
        var i = r.structure.units[0], a = tt.create([i.getChild(Ke.ofSingleton(i.elements[0]))], { parent: e.inputStructure });
        n.add(a);
      }
    } else r.structures.length > 0 && n.add(r.structures[0]);
    return n.getSelection();
  };
}, getCurrentStructureProperties: ab, isConnectedTo: function(t) {
  var e = t.query, r = t.target, n = t.disjunct, i = t.invert, a = t.bondTest;
  return function(o) {
    var s = r(o);
    if (gt.isEmpty(s)) return s;
    var u = e(o);
    if (gt.isEmpty(u)) return u;
    var c = { queryCtx: o, input: o.inputStructure, disjunct: n, target: gt.unionStructure(s) }, l = gt.LinearBuilder(o.inputStructure);
    return o.pushCurrentBond(), o.atomicBond.setTestFn(a), gt.forEach(u, function(d, f) {
      (function(h, m) {
        var p = h.queryCtx, v = h.input, g = h.target, y = h.disjunct, b = p.atomicBond, S = v.interUnitBonds;
        b.setStructure(v);
        for (var _ = 0, x = m.units; _ < x.length; _++) {
          var C = x[_];
          if (Fe.isAtomic(C)) for (var A = v.unitMap.get(C.id), w = A.bonds, I = w.offset, P = w.b, M = w.edgeProps, T = M.flags, F = M.order, N = S.getConnectedUnits(C.id), R = N.length, L = C.elements, V = A.elements, U = 0, H = L.length; U < H; U++) {
            var K = Ke.indexOf(V, L[U]);
            b.a.unit = A, b.b.unit = A;
            for (var X = I[K], Y = I[K + 1]; X < Y; X++) if (b.b.element = A.elements[P[X]], (!y || !Ke.has(C.elements, b.b.element)) && g.hasElement(b.b) && (b.aIndex = K, b.a.element = L[U], b.bIndex = P[X], b.type = T[X], b.order = F[X], b.test(p, !0))) return !0;
            for (var Q = 0; Q < R; Q++) for (var J = N[Q], te = v.unitMap.get(J.unitB), W = te.elements, j = J.getEdges(K), ee = 0, ie = j.length; ee < ie; ee++) {
              var ae = j[ee];
              if (b.b.unit = te, b.b.element = W[ae.indexB], g.hasElement(b.b) && (!y || !m.hasElement(b.b)) && (b.a.unit = A, b.aIndex = K, b.a.element = L[U], b.bIndex = ae.indexB, b.type = ae.props.flag, b.order = ae.props.order, b.test(p, !0))) return !0;
            }
          }
        }
        return !1;
      }(c, d) || i) && l.add(d), f % 5 == 0 && o.throwIfTimedOut();
    }), o.popCurrentBond(), l.getSelection();
  };
}, pick: function(t, e) {
  return function(r) {
    var n = t(r), i = gt.LinearBuilder(r.inputStructure);
    return r.pushCurrentElement(), gt.forEach(n, function(a, o) {
      r.currentStructure = a, e(r) && i.add(a), o % 100 && r.throwIfTimedOut();
    }), r.popCurrentStructure(), i.getSelection();
  };
}, withSameAtomProperties: function(t, e, r) {
  return function(n) {
    var i = t(n), a = function(s, u, c) {
      var l = /* @__PURE__ */ new Set(), d = u(s);
      return s.pushCurrentElement(), gt.forEach(d, function(f, h) {
        s.currentStructure = f, ab(s, c, l), h % 10 && s.throwIfTimedOut();
      }), s.popCurrentElement(), l;
    }(n, e, r), o = gt.LinearBuilder(n.inputStructure);
    return n.pushCurrentStructure(), gt.forEach(i, function(s, u) {
      n.currentStructure = s;
      var c = ab(n, r, /* @__PURE__ */ new Set());
      Ao.isSuperset(c, a) && o.add(s), u % 10 && n.throwIfTimedOut();
    }), n.popCurrentStructure(), o.getSelection();
  };
}, within: function(t) {
  return function(e) {
    var r = { queryCtx: e, selection: t.query(e), target: t.target(e), maxRadius: t.maxRadius, minRadius: t.minRadius ? Math.max(0, t.minRadius) : 0, elementRadius: t.elementRadius, invert: !!t.invert };
    return r.minRadius === 0 && t.minRadius === void 0 ? function(n) {
      var i = n.queryCtx, a = n.selection, o = n.target, s = n.maxRadius, u = n.invert, c = gt.unionStructure(o).lookup3d, l = gt.LinearBuilder(i.inputStructure), d = E.zero();
      return gt.forEach(a, function(f, h) {
        for (var m = f.units, p = !1, v = 0, g = m.length; v < g; v++) {
          for (var y = m[v], b = y.elements, S = y.conformation, _ = S.position, x = S.r, C = 0, A = b.length; C < A; C++) {
            var w = b[C];
            if (_(w, d), c.check(d[0], d[1], d[2], s + x(w))) {
              p = !0;
              break;
            }
          }
          if (p) break;
        }
        u && (p = !p), p && l.add(f), h % 10 == 0 && i.throwIfTimedOut();
      }), l.getSelection();
    }(r) : r.minRadius === 0 ? function(n) {
      var i = n.queryCtx, a = n.selection, o = n.target, s = n.maxRadius, u = n.invert, c = n.elementRadius, l = gt.unionStructure(o), d = gt.LinearBuilder(i.inputStructure);
      return i.pushCurrentElement(), gt.forEach(a, function(f, h) {
        var m = function(p, v, g, y, b) {
          return v.elementCount === 0 || g.elementCount === 0 || (v.elementCount <= g.elementCount ? z3.check(p, v, g, y, b) : z3.check(p, g, v, y, b));
        }(i, l, f, s, c);
        u && (m = !m), m && d.add(f), h % 10 == 0 && i.throwIfTimedOut();
      }), i.popCurrentElement(), d.getSelection();
    }(r) : function(n) {
      var i = n.queryCtx, a = n.selection, o = n.target, s = n.minRadius, u = n.maxRadius, c = n.invert, l = n.elementRadius, d = gt.unionStructure(o), f = gt.LinearBuilder(i.inputStructure);
      return i.pushCurrentElement(), gt.forEach(a, function(h, m) {
        var p = function(v, g, y, b, S, _) {
          return g.elementCount === 0 || y.elementCount === 0 || (g.elementCount <= y.elementCount ? G3.check(v, g, y, b, S, _) : G3.check(v, y, g, b, S, _));
        }(i, d, h, s, u, l);
        c && (p = !p), p && f.add(h), m % 10 == 0 && i.throwIfTimedOut();
      }), i.popCurrentElement(), f.getSelection();
    }(r);
  };
} }), Q_, nte = Object.freeze({ __proto__: null, intersect: function(t) {
  return t.length === 0 ? K_ : t.length === 1 ? t[0] : function(e) {
    for (var r = [], n = 0; n < t.length; n++) r.push(t[n](e));
    var i = 0, a = gt.structureCount(r[0]);
    for (n = 1; n < r.length; n++) {
      var o = gt.structureCount(r[n]);
      o < a && (i = n, a = o);
    }
    e.throwIfTimedOut();
    var s = W9(function(l) {
      return l.hashCode;
    }, tt.areUnitIdsAndIndicesEqual);
    gt.forEach(r[i], function(l) {
      return s.add(l);
    });
    for (var u = gt.UniqueBuilder(e.inputStructure), c = 0; c < r.length; c++) c !== i && (gt.forEach(r[c], function(l) {
      s.has(l) && u.add(l);
    }), e.throwIfTimedOut());
    return u.getSelection();
  };
}, merge: function(t) {
  return t.length === 0 ? K_ : t.length === 1 ? t[0] : function(e) {
    for (var r = gt.UniqueBuilder(e.inputStructure), n = function(a) {
      gt.forEach(t[a](e), function(o, s) {
        r.add(o), a % 100 && e.throwIfTimedOut();
      });
    }, i = 0; i < t.length; i++) n(i);
    return r.getSelection();
  };
} });
(function(t) {
  function e(n) {
    return !0;
  }
  function r(n) {
    return !1;
  }
  t.eq = function(n, i) {
    return function(a) {
      return n(a) === i;
    };
  }, t.lt = function(n, i) {
    return function(a) {
      return n(a) < i;
    };
  }, t.lte = function(n, i) {
    return function(a) {
      return n(a) <= i;
    };
  }, t.gt = function(n, i) {
    return function(a) {
      return n(a) > i;
    };
  }, t.gte = function(n, i) {
    return function(a) {
      return n(a) >= i;
    };
  }, t.inSet = function(n, i) {
    if (function(s) {
      return !!s && !!s.has;
    }(i)) return function(s) {
      return i.has(n(s));
    };
    if (i.length === 0) return r;
    for (var a = /* @__PURE__ */ new Set(), o = 0; o < i.length; o++) a.add(i[o]);
    return function(s) {
      return a.has(n(s));
    };
  }, t.and = function() {
    for (var n = [], i = 0; i < arguments.length; i++) n[i] = arguments[i];
    switch (n.length) {
      case 0:
        return e;
      case 1:
        return n[0];
      case 2:
        var a = n[0], o = n[1];
        return function(I) {
          return a(I) && o(I);
        };
      case 3:
        var s = n[0], u = n[1], c = n[2];
        return function(I) {
          return s(I) && u(I) && c(I);
        };
      case 4:
        var l = n[0], d = n[1], f = n[2], h = n[3];
        return function(I) {
          return l(I) && d(I) && f(I) && h(I);
        };
      case 5:
        var m = n[0], p = n[1], v = n[2], g = n[3], y = n[4];
        return function(I) {
          return m(I) && p(I) && v(I) && g(I) && y(I);
        };
      case 6:
        var b = n[0], S = n[1], _ = n[2], x = n[3], C = n[4], A = n[5];
        return function(I) {
          return b(I) && S(I) && _(I) && x(I) && C(I) && A(I);
        };
      default:
        var w = n.length;
        return function(I) {
          for (var P = 0; P < w; P++) if (!n[P]) return !1;
          return !0;
        };
    }
  }, t.or = function() {
    for (var n = [], i = 0; i < arguments.length; i++) n[i] = arguments[i];
    switch (n.length) {
      case 0:
        return r;
      case 1:
        return n[0];
      case 2:
        var a = n[0], o = n[1];
        return function(I) {
          return a(I) || o(I);
        };
      case 3:
        var s = n[0], u = n[1], c = n[2];
        return function(I) {
          return s(I) || u(I) || c(I);
        };
      case 4:
        var l = n[0], d = n[1], f = n[2], h = n[3];
        return function(I) {
          return l(I) || d(I) || f(I) || h(I);
        };
      case 5:
        var m = n[0], p = n[1], v = n[2], g = n[3], y = n[4];
        return function(I) {
          return m(I) || p(I) || v(I) || g(I) || y(I);
        };
      case 6:
        var b = n[0], S = n[1], _ = n[2], x = n[3], C = n[4], A = n[5];
        return function(I) {
          return b(I) || S(I) || _(I) || x(I) || C(I) || A(I);
        };
      default:
        var w = n.length;
        return function(I) {
          for (var P = 0; P < w; P++) if (n[P]) return !0;
          return !1;
        };
    }
  };
})(Q_ || (Q_ = {}));
var Ap, En = { generators: eee, filters: rte, modifiers: tte, combinators: nte, pred: Q_, internal: Q$ };
function GR(t, e, r, n, i, a) {
  var o = t.spacegroup, s = t.ncsOperators, u = [], c = o.cell.toFractional, l = E.transformMat4(E(), a, c), d = ko.getSymmetryOperatorRef(o, e, r, n, i, l);
  if (s && s.length) for (var f = 0, h = s.length; f < h; ++f) {
    var m = s[f], p = he.mul(he(), d.matrix, m.matrix), v = wn.create("".concat(d.name, " ").concat(m.name), p, { assembly: d.assembly, ncsId: m.ncsId, hkl: d.hkl, spgrOp: d.spgrOp });
    u.push(v);
  }
  else u.push(d);
  return u;
}
function gE(t, e, r, n) {
  var i = t.spacegroup, a = t.ncsOperators, o = a && a.length || 0, s = [];
  !o && e[0] <= 0 && r[0] >= 0 && e[1] <= 0 && r[1] >= 0 && e[2] <= 0 && r[2] >= 0 && (s[0] = ko.getSymmetryOperator(i, 0, 0, 0, 0));
  for (var u = 0; u < i.operators.length; u++) for (var c = e[0]; c <= r[0]; c++) for (var l = e[1]; l <= r[1]; l++) for (var d = e[2]; d <= r[2]; d++) (o || u !== 0 || c !== 0 || l !== 0 || d !== 0) && s.push.apply(s, GR(t, u, c, l, d, n));
  return s;
}
function vE(t, e) {
  for (var r = tt.Builder({ label: t.label, dynamicBonds: t.dynamicBonds }), n = t.units, i = 0, a = e; i < a.length; i++) for (var o = a[i], s = 0, u = n; s < u.length; s++) {
    var c = u[s];
    r.addWithOperator(c, o);
  }
  return r.getStructure();
}
(function(t) {
  function e(n, i) {
    return n.invariantId === i.invariantId && n.model.id === i.model.id && Ke.areEqual(n.elements, i.elements);
  }
  function r() {
    return function(n, i) {
      return new Xj(n, i);
    }(Fe.hashUnit, e);
  }
  t.buildAssembly = function(n, i) {
    var a = this;
    return tr.create("Build Assembly", function(o) {
      return _e(a, 0, void 0, function() {
        var s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x;
        return ye(this, function(C) {
          if ((s = n.models).length !== 1) throw new Error("Can only build assemblies from structures based on 1 model.");
          if (!(u = R3.findAssembly(s[0], i))) throw new Error("Assembly '".concat(i, "' is not defined."));
          for (c = wn.create(u.id, he.identity(), { assembly: { id: u.id, operId: 0, operList: [] } }), l = tt.Builder({ coordinateSystem: c, label: n.label, dynamicBonds: n.dynamicBonds }), d = new A0(n), f = 0, h = u.operatorGroups; f < h.length; f++) if (m = h[f], p = m.selector(d), gt.structureCount(p) !== 0) for (v = gt.unionStructure(p).units, g = 0, y = m.operators; g < y.length; g++) for (b = y[g], S = 0, _ = v; S < _.length; S++) x = _[S], l.addWithOperator(x, b);
          return [2, l.getStructure()];
        });
      });
    });
  }, t.buildSymmetryAssembly = function(n, i, a) {
    var o = this;
    return tr.create("Build Symmetry Assembly", function(s) {
      return _e(o, 0, void 0, function() {
        var u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F, N, R;
        return ye(this, function(L) {
          if ((u = n.models).length !== 1) throw new Error("Can only build symmetry assemblies from structures based on 1 model.");
          for (c = E(), l = tt.Builder({ label: n.label, representativeModel: u[0], dynamicBonds: n.dynamicBonds }), d = new A0(n), f = 0, h = i; f < h.length; f++) if (m = h[f], V = m.asymIds, p = En.generators.atoms({ chainTest: En.pred.and(En.pred.eq(function(U) {
            return Qe.unit.operator_name(U.element);
          }, wn.DefaultName), En.pred.inSet(function(U) {
            return Qe.chain.label_asym_id(U.element);
          }, V)) }), v = p(d), gt.structureCount(v) !== 0) for (g = gt.unionStructure(v).units, y = 0, b = m.operators; y < b.length; y++) for (S = b[y], _ = S.index, x = S.shift, C = x[0], A = x[1], w = x[2], I = GR(a, _, C, A, w, c), P = 0, M = g; P < M.length; P++) for (T = M[P], F = 0, N = I; F < N.length; F++) R = N[F], l.addWithOperator(T, R);
          var V;
          return [2, l.getStructure()];
        });
      });
    });
  }, t.builderSymmetryMates = function(n, i) {
    return tr.create("Find Symmetry Mates", function(a) {
      return function(o, s, u) {
        return _e(this, 0, void 0, function() {
          function c(N, R) {
            return "".concat(N.invariantId, "|").concat(R.name);
          }
          var l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F;
          return ye(this, function(N) {
            switch (N.label) {
              case 0:
                if ((l = s.models).length !== 1) throw new Error("Can only build symmetries from structures based on 1 model.");
                return (d = Da.Provider.get(l[0])) ? (f = d.spacegroup, au.isZero(f.cell) ? [2, s] : o.shouldUpdate ? [4, o.update("Initialing...")] : [3, 2]) : [2, s];
              case 1:
                N.sent(), N.label = 2;
              case 2:
                h = pn.getCenter(l[0]), m = function(R, L) {
                  return R._operators_333 && E.equals(L, R._operators_333.ref) || (R._operators_333 = { ref: E.clone(L), operators: gE(R, E.create(-3, -3, -3), E.create(3, 3, 3), L) }), R._operators_333.operators;
                }(d, h), p = s.lookup3d, v = /* @__PURE__ */ new Set(), g = tt.Builder({ label: s.label, dynamicBonds: s.dynamicBonds }), y = s.units, b = E.zero(), S = 0, _ = m, N.label = 3;
              case 3:
                if (!(S < _.length)) return [3, 6];
                for (x = _[S], C = 0, A = y; C < A.length; C++) for (w = A[C], I = w.lookup3d.boundary.sphere, E.transformMat4(b, I.center, x.matrix), P = p.findUnitIndices(b[0], b[1], b[2], I.radius + u), M = 0, T = P.count; M < T; M++) y[P.indices[M]].lookup3d.check(b[0], b[1], b[2], I.radius + u) && (F = c(w, x), v.has(F) || (g.addWithOperator(w, x), v.add(F)));
                return o.shouldUpdate ? [4, o.update("Building symmetry...")] : [3, 5];
              case 4:
                N.sent(), N.label = 5;
              case 5:
                return S++, [3, 3];
              case 6:
                return [2, g.getStructure()];
            }
          });
        });
      }(a, n, i);
    });
  }, t.buildSymmetryRange = function(n, i, a) {
    return tr.create("Build Symmetry", function(o) {
      return function(s, u, c, l) {
        return _e(this, 0, void 0, function() {
          var d, f, h, m, p;
          return ye(this, function(v) {
            if ((d = u.models).length !== 1) throw new Error("Can only build symmetries from structures based on 1 model.");
            return (f = Da.Provider.get(d[0])) ? (h = f.spacegroup, au.isZero(h.cell) ? [2, u] : (m = pn.getCenter(d[0]), p = gE(f, c, l, m), [2, vE(u, p)])) : [2, u];
          });
        });
      }(0, n, i, a);
    });
  }, t.buildNcs = function(n) {
    return tr.create("Build NCS", function(i) {
      return function(a, o) {
        return _e(this, 0, void 0, function() {
          var s, u, c;
          return ye(this, function(l) {
            if ((s = o.models).length !== 1) throw new Error("Can only build NCS from structures based on 1 model.");
            return (u = Da.Provider.get(s[0])) && (c = u.ncsOperators) && c.length ? [2, vE(o, c)] : [2, o];
          });
        });
      }(0, n);
    });
  }, t.areUnitsEquivalent = e, t.UnitEquivalenceBuilder = r, t.computeTransformGroups = function(n) {
    for (var i = r(), a = 0, o = n.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(Fe.SymmetryGroup(d.map(function(f) {
        return n.unitMap.get(f);
      })));
    }
    return u;
  }, t.areTransformGroupsEquivalent = function(n, i) {
    if (n.length !== i.length) return !1;
    for (var a = 0, o = n.length; a < o; ++a) {
      var s = n[a].units, u = i[a].units;
      if (s.length !== u.length || n[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;
  };
})(Ap || (Ap = {}));
var ite = function() {
  function t(e, r) {
    this.parent = e, this.isSorted = r, this.ids = [], this.unitMap = bc.Mutable(), this.parentId = -1, this.currentUnit = [], this.elementCount = 0;
  }
  return t.prototype.addToUnit = function(e, r) {
    var n = this.unitMap.get(e);
    n ? n[n.length] = r : (this.unitMap.set(e, [r]), this.ids[this.ids.length] = e), this.elementCount++;
  }, t.prototype.beginUnit = function(e) {
    this.parentId = e, this.currentUnit = this.currentUnit.length > 0 ? [] : this.currentUnit;
  }, t.prototype.addElement = function(e) {
    this.currentUnit[this.currentUnit.length] = e, this.elementCount++;
  }, t.prototype.addElementRange = function(e, r, n) {
    for (var i = r; i < n; i++) this.currentUnit[this.currentUnit.length] = e[i], this.elementCount++;
  }, t.prototype.commitUnit = function() {
    this.currentUnit.length !== 0 && (this.ids[this.ids.length] = this.parentId, this.unitMap.set(this.parentId, this.currentUnit), this.parentId = -1);
  }, t.prototype.setUnit = function(e, r) {
    this.ids[this.ids.length] = e, this.unitMap.set(e, r), this.elementCount += r.length;
  }, t.prototype._getStructure = function(e) {
    if (this.isEmpty) return tt.Empty;
    var r = [];
    Ru(this.ids);
    for (var n = Ap.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;
      e && (this.isSorted || Ru(u), u = Ke.deduplicate(Ke.ofSortedArray(this.currentUnit)), c = !0);
      var l = u.length;
      if (u.length !== s.elements.length) {
        !this.isSorted && !c && l > 1 && Ru(u);
        var d = s.getChild(Ke.ofSortedArray(u)), f = n.add(d.id, d);
        d !== f && (d = f.applyOperator(d.id, d.conformation.operator, !0)), r[r.length] = d;
      } else r[r.length] = s, n.add(s.id, s);
    }
    return tt.create(r, { parent: this.parent });
  }, t.prototype.getStructure = function() {
    return this._getStructure(!1);
  }, t.prototype.getStructureDeduplicate = function() {
    return this._getStructure(!0);
  }, t.prototype.setSingletonLocation = function(e) {
    var r = this.ids[0];
    e.unit = this.parent.unitMap.get(r), e.element = this.unitMap.get(r)[0];
  }, Object.defineProperty(t.prototype, "isEmpty", { get: function() {
    return this.elementCount === 0;
  }, enumerable: !1, configurable: !0 }), t;
}();
function yE(t, e) {
  for (var r = 1; e--; ) r *= t--;
  return r;
}
var ate = function() {
  function t(e, r) {
    this.array = e, this.hasNext = !1, this.index = (1 << r) - 1, this.size = function(n, i) {
      return i > n ? 0 : yE(n, i) / yE(i, i);
    }(e.length, r), this.maxIndex = 1 << e.length, this.value = new Array(r), this.hasNext = r > 0 && r <= e.length;
  }
  return t.prototype.move = function() {
    if (this.hasNext) {
      for (var e = 0, r = 0, n = this.index; n; n >>>= 1, e++) 1 & n && (this.value[r++] = this.array[e]);
      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;
  }, t;
}();
function zR(t, e) {
  for (var r = [], n = new ate(t, e); n.hasNext; ) r.push(n.move().slice());
  return r;
}
var Rf = [], ote = { links: Rf, terminalLinks: Rf, elements: Rf, partialElements: Rf, getElementIndices: function() {
  return Rf;
}, getLinkIndices: function() {
  return Rf;
}, getTerminalLinkIndices: function() {
  return Rf;
} }, zi = bp("C"), gm = bp("O"), ste = [nu.elementFingerprint([zi, zi, zi, gm]), nu.elementFingerprint([zi, zi, zi, zi, gm]), nu.elementFingerprint([zi, zi, zi, zi, zi, gm]), nu.elementFingerprint([zi, zi, zi, zi, zi, zi, gm])];
function ute(t, e) {
  for (var r = -1, n = -1, i = -1, a = -1, o = t.elements, s = t.model.atomicHierarchy.atoms, u = s.type_symbol, c = s.label_atom_id, l = t.bonds, d = l.b, f = l.offset, h = 0, m = e.length; h < m; ++h) {
    var p = o[e[h]];
    if (u.value(p) === zi) {
      for (var v = 0, g = 0, y = f[e[h]], b = f[e[h] + 1]; y < b; ++y) {
        var S = o[d[y]], _ = u.value(S);
        _ === gm ? ++v : _ === zi && ++g;
      }
      if (v === 2) {
        r = p;
        break;
      }
      v === 1 && g === 1 ? n = p : c.value(p).startsWith("C1") ? i = p : a = p;
    }
  }
  return r !== -1 ? r : n !== -1 ? n : i !== -1 ? i : a !== -1 ? a : o[e[0]];
}
function cte(t, e, r, n) {
  var i = e.conformation.position;
  return E.normalize(t, E.sub(t, n, i(r, t))), t;
}
function bE(t, e) {
  var r = t.elements;
  return t.model.atomicHierarchy.atoms.label_atom_id.value(r[e]);
}
function lte(t, e) {
  if (e && e.length) {
    for (var r = t.unit, n = t.all, i = /* @__PURE__ */ new Set(), a = zR(xc(new Array(e.length)), 2), o = 0, s = a.length; o < s; ++o) {
      var u = a[o], c = n[e[u[0]]], l = n[e[u[1]]];
      Ke.areIntersecting(c, l) && nu.getAltId(r, c) === nu.getAltId(r, l) && (i.add(e[u[0]]), i.add(e[u[1]]));
    }
    if (i.size) {
      var d = [];
      for (o = 0, s = e.length; o < s; ++o) i.has(e[o]) || d.push(e[o]);
      return d;
    }
    return e;
  }
}
function dte(t, e) {
  return e.properties.saccharideComponentMap.get(t);
}
function fte(t) {
  if (t.models.reduce(function(ce, de) {
    return ce + de.properties.saccharideComponentMap.size;
  }, 0) === 0) return ote;
  var e = [], r = [], n = [], i = [], a = /* @__PURE__ */ new Map();
  function o(ce, de, Ce) {
    return "".concat(ce, "|").concat(de, "|").concat(Ce);
  }
  function s(ce, de) {
    a.has(ce) ? a.get(ce).push(de) : a.set(ce, [de]);
  }
  function u(ce, de) {
    E.sub(n[ce].geometry.direction, n[de].geometry.center, n[ce].geometry.center), E.normalize(n[ce].geometry.direction, n[ce].geometry.direction);
  }
  var c = E.zero();
  function l(ce, de, Ce) {
    var De = Ce.conformation.position, ke = n[ce].geometry;
    E.sub(ke.direction, De(Ce.elements[de], c), ke.center), E.normalize(ke.direction, ke.direction);
  }
  for (var d = 0, f = t.units.length; d < f; ++d) {
    var h = t.units[d];
    if (Fe.isAtomic(h)) for (var m = h.model, p = h.rings, v = m.atomicHierarchy, g = v.chainAtomSegments, y = v.residueAtomSegments, b = v.atoms.label_comp_id, S = Qt.transientSegments(g, h.elements), _ = Qt.transientSegments(y, h.elements), x = void 0; S.hasNext; ) for (_.setSegment(S.move()); _.hasNext; ) {
      var C = _.move().index, A = dte(b.value(y.offsets[C]), m);
      if (A) {
        x || (x = N3.byFingerprintAndResidue(p, ste));
        var w = lte(p, x.get(C));
        if (w && w.length) {
          for (var I = [], P = 0, M = w.length; P < M; ++P) {
            var T = p.all[w[P]], F = ute(h, T), N = Qd.calculateMomentsAxes(CR(h, T)), R = E.copy(E.zero(), N.origin), L = E.copy(E.zero(), N.dirC), V = cte(E.zero(), h, F, R);
            E.orthogonalize(V, L, V);
            var U = nu.getAltId(h, T), H = n.length;
            I.push(H), s(o(C, h.id, U), H), U && s(o(C, h.id, ""), H), n.push({ geometry: { center: R, normal: L, direction: V }, component: A, ringIndex: w[P], altId: U, unit: h, residueIndex: C });
          }
          var K = zR(xc(new Array(w.length)), 2);
          for (P = 0, M = K.length; P < M; ++P) {
            var X = K[P], Y = p.all[w[X[0]]], Q = p.all[w[X[1]]];
            if (Xo.areVertexSetsConnected(h.bonds, Y, Q, 3)) {
              var J = I[X[0]], te = I[X[1]];
              n[J].altId === n[te].altId && (u(J, te), u(te, J), e.push({ carbohydrateIndexA: J, carbohydrateIndexB: te }), e.push({ carbohydrateIndexA: te, carbohydrateIndexB: J }));
            }
          }
        } else i.push({ unit: h, residueIndex: C, component: A });
      }
    }
  }
  function W(ce, de) {
    return a.get(o(ce.getResidueIndex(de), ce.id, function(Ce, De) {
      var ke = Ce.elements;
      return Ce.model.atomicHierarchy.atoms.label_alt_id.value(ke[De]);
    }(ce, de))) || [];
  }
  for (d = 0, f = n.length; d < f; ++d) {
    var j = n[d];
    for (h = j.unit, P = d + 1; P < f; ++P) {
      var ee = n[P];
      if (h === ee.unit && j.residueIndex !== ee.residueIndex) {
        var ie = h.rings.all[j.ringIndex], ae = h.rings.all[ee.ringIndex];
        Xo.areVertexSetsConnected(h.bonds, ie, ae, 3) && (u(d, P), u(P, d), e.push({ carbohydrateIndexA: d, carbohydrateIndexB: P }), e.push({ carbohydrateIndexA: P, carbohydrateIndexB: d }));
      }
    }
  }
  for (d = 0, f = t.units.length; d < f; ++d)
    h = t.units[d], Fe.isAtomic(h) && t.interUnitBonds.getConnectedUnits(h.id).forEach(function(ce) {
      ce.connectedIndices.forEach(function(de) {
        ce.getEdges(de).forEach(function(Ce) {
          var De = Ce.props, ke = Ce.indexB;
          if (lr.isCovalent(De.flag)) {
            var He = t.unitMap.get(ce.unitA), We = t.unitMap.get(ce.unitB), Ne = W(He, de), Je = W(We, ke);
            if (Ne.length > 0 && Je.length > 0) for (var Re = Ne.length, nt = Je.length, ne = 0, re = Math.max(Re, nt); ne < re; ++ne) {
              var le = Ne[Math.min(ne, Re - 1)], fe = Je[Math.min(ne, nt - 1)];
              ((Ae = bE(He, de)).startsWith("O1") || Ae.startsWith("C1")) && u(le, fe), e.push({ carbohydrateIndexA: le, carbohydrateIndexB: fe });
            }
            else if (Je.length === 0) for (var ge = 0, me = Ne; ge < me.length; ge++) {
              var Ae;
              le = me[ge], ((Ae = bE(He, de)).startsWith("O1") || Ae.startsWith("C1")) && l(le, ke, We), r.push({ carbohydrateIndex: le, elementIndex: ke, elementUnit: We, fromCarbohydrate: !0 });
            }
            else if (Ne.length === 0) for (var Oe = 0, Ue = Je; Oe < Ue.length; Oe++)
              fe = Ue[Oe], r.push({ carbohydrateIndex: fe, elementIndex: de, elementUnit: He, fromCarbohydrate: !1 });
          }
        });
      });
    });
  return O({ links: e, terminalLinks: r, elements: n, partialElements: i }, function(ce, de, Ce) {
    function De(ir, Nr) {
      return iu(ir.id, Nr);
    }
    function ke(ir, Nr, pr) {
      var _n = [], Jn = ir.get(De(Nr, pr));
      if (Jn !== void 0) for (var Yn = 0, Rn = Jn; Yn < Rn.length; Yn++)
        Qs(_n, Rn[Yn]);
      return _n;
    }
    for (var He = /* @__PURE__ */ new Map(), We = 0, Ne = ce.length; We < Ne; ++We) for (var Je = ce[We], Re = Je.unit, nt = Je.ringIndex, ne = 0, re = (Ee = Re.rings.all[nt]).length; ne < re; ++ne) {
      var le = De(Re, Re.elements[Ee[ne]]);
      (Et = He.get(le)) === void 0 ? He.set(le, [We]) : Et.push(We);
    }
    function fe(ir, Nr) {
      return ke(He, ir, Nr);
    }
    var ge = /* @__PURE__ */ new Map();
    for (We = 0, Ne = de.length; We < Ne; ++We) {
      var me = ce[de[We].carbohydrateIndexA];
      for (Re = me.unit, nt = me.ringIndex, ne = 0, re = (Ee = Re.rings.all[nt]).length; ne < re; ++ne)
        le = De(Re, Re.elements[Ee[ne]]), (Et = ge.get(le)) === void 0 ? ge.set(le, [We]) : Et.push(We);
    }
    function Ae(ir, Nr) {
      return ke(ge, ir, Nr);
    }
    var Oe = /* @__PURE__ */ new Map();
    for (We = 0, Ne = Ce.length; We < Ne; ++We) {
      var Ue = Ce[We], Ve = Ue.fromCarbohydrate, ht = Ue.carbohydrateIndex, bt = Ue.elementUnit, At = Ue.elementIndex;
      if (Ve) {
        var Ee, st = ce[ht];
        for (Re = st.unit, nt = st.ringIndex, ne = 0, re = (Ee = Re.rings.all[nt]).length; ne < re; ++ne)
          le = De(Re, Re.elements[Ee[ne]]), (Et = Oe.get(le)) === void 0 ? Oe.set(le, [We]) : Et.push(We);
      } else {
        var Et;
        le = De(bt, bt.elements[At]), (Et = Oe.get(le)) === void 0 ? Oe.set(le, [We]) : Et.push(We);
      }
    }
    function ur(ir, Nr) {
      return ke(Oe, ir, Nr);
    }
    return { getElementIndices: fe, getLinkIndices: Ae, getTerminalLinkIndices: ur };
  }(n, e, r));
}
var Jg = Me(), pte = new cu("14"), hte = new cu("98");
function mte(t) {
  var e = t.units, r = function(u) {
    return u > 500 ? pte : hte;
  }(e.length);
  r.reset();
  for (var n = 0, i = e.length; n < i; n++) {
    var a = (o = e[n]).boundary;
    (s = o.conformation.operator).isIdentity ? r.includeSphere(a.sphere) : (Me.transform(Jg, a.sphere, s.matrix), r.includeSphere(Jg));
  }
  for (r.finishedIncludeStep(), n = 0, i = e.length; n < i; n++) {
    var o, s;
    a = (o = e[n]).boundary, (s = o.conformation.operator).isIdentity ? r.radiusSphere(a.sphere) : (Me.transform(Jg, a.sphere, s.matrix), r.radiusSphere(Jg));
  }
  return { box: r.getBox(), sphere: r.getSphere() };
}
var tt = function() {
  function t(e, r, n, i, a) {
    this.units = e, this.unitMap = r, this.unitIndexMap = n, this.state = i, this._child = a == null ? void 0 : a.child, this._target = a == null ? void 0 : a.target, this._proxy = void 0;
  }
  return t.prototype.subsetBuilder = function(e) {
    return new ite(this, e);
  }, Object.defineProperty(t.prototype, "elementCount", { get: function() {
    return this.state.elementCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bondCount", { get: function() {
    return this.state.bondCount === -1 && (this.state.bondCount = this.interUnitBonds.edgeCount + Dt.getIntraUnitBondCount(this)), this.state.bondCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasCustomProperties", { get: function() {
    return !!this.state.customProps && this.state.customProps.all.length > 0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "customPropertyDescriptors", { get: function() {
    return this.state.customProps || (this.state.customProps = new jp()), this.state.customProps;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "currentPropertyData", { get: function() {
    return this.state.propertyData || (this.state.propertyData = /* @__PURE__ */ Object.create(null)), this.state.propertyData;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "inheritedPropertyData", { get: function() {
    return this.parent ? this.parent.currentPropertyData : this.currentPropertyData;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "polymerResidueCount", { get: function() {
    return this.state.polymerResidueCount === -1 && (this.state.polymerResidueCount = function(e) {
      for (var r = e.units, n = 0, i = 0, a = r.length; i < a; i++) n += r[i].polymerElements.length;
      return n;
    }(this)), this.state.polymerResidueCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "polymerGapCount", { get: function() {
    return this.state.polymerGapCount === -1 && (this.state.polymerGapCount = function(e) {
      for (var r = e.units, n = 0, i = 0, a = r.length; i < a; i++) n += r[i].gapElements.length / 2;
      return n;
    }(this)), this.state.polymerGapCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "polymerUnitCount", { get: function() {
    return this.state.polymerUnitCount === -1 && (this.state.polymerUnitCount = function(e) {
      for (var r = e.units, n = 0, i = 0, a = r.length; i < a; i++) r[i].polymerElements.length > 0 && (n += 1);
      return n;
    }(this)), this.state.polymerUnitCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uniqueElementCount", { get: function() {
    return this.state.uniqueElementCount === -1 && (this.state.uniqueElementCount = function(e) {
      for (var r = e.unitSymmetryGroups, n = 0, i = 0, a = r.length; i < a; i++) n += r[i].elements.length;
      return n;
    }(this)), this.state.uniqueElementCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "atomicResidueCount", { get: function() {
    return this.state.atomicResidueCount === -1 && (this.state.atomicResidueCount = function(e) {
      for (var r = e.units, n = 0, i = 0, a = r.length; i < a; i++) {
        var o = r[i];
        if (Fe.isAtomic(o)) for (var s = o.elements, u = o.residueIndex, c = -1, l = -1, d = 0, f = s.length; d < f; ++d) (c = u[s[d]]) !== l && (n += 1, l = c);
      }
      return n;
    }(this)), this.state.atomicResidueCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isCoarseGrained", { get: function() {
    return this.models.some(function(e) {
      return pn.isCoarseGrained(e);
    });
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isEmpty", { get: function() {
    return this.units.length === 0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hashCode", { get: function() {
    return this.state.hashCode !== -1 ? this.state.hashCode : this.computeHash();
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "transformHash", { get: function() {
    return this.state.transformHash !== -1 || (this.state.transformHash = ro(this.units.map(function(e) {
      return e.id;
    }))), this.state.transformHash;
  }, enumerable: !1, configurable: !0 }), t.prototype.computeHash = function() {
    for (var e = 23, r = 0, n = this.units.length; r < n; r++) {
      var i = this.units[r];
      e = 31 * (e = 31 * e + i.id | 0) + Ke.hashCode(i.elements) | 0;
    }
    return (e = sN(e = 31 * e + this.elementCount | 0)) === -1 && (e = 0), this.state.hashCode = e, e;
  }, t.prototype.elementLocations = function() {
    return new t.ElementLocationIterator(this);
  }, Object.defineProperty(t.prototype, "root", { get: function() {
    var e;
    return (e = this.state.parent) !== null && e !== void 0 ? e : this;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "parent", { get: function() {
    return this.state.parent;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "coordinateSystem", { get: function() {
    return this.state.coordinateSystem;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "label", { get: function() {
    return this.state.label;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "boundary", { get: function() {
    return this.state.boundary || (this.state.boundary = mte(this)), this.state.boundary;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lookup3d", { get: function() {
    return this.state.lookup3d || (this.state.lookup3d = new j$(this)), this.state.lookup3d;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.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 P3(/* @__PURE__ */ new Map()) : this.state.interUnitBonds = E$(this, { ignoreWater: !this.dynamicBonds, ignoreIon: !this.dynamicBonds })), this.state.interUnitBonds;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dynamicBonds", { get: function() {
    return this.state.dynamicBonds;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "unitSymmetryGroups", { get: function() {
    return this.state.unitSymmetryGroups || (this.state.unitSymmetryGroups = Ap.computeTransformGroups(this)), this.state.unitSymmetryGroups;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "unitSymmetryGroupsIndexMap", { get: function() {
    return this.state.unitSymmetryGroupsIndexMap || (this.state.unitSymmetryGroupsIndexMap = Fe.SymmetryGroup.getUnitSymmetryGroupsIndexMap(this.unitSymmetryGroups)), this.state.unitSymmetryGroupsIndexMap;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "carbohydrates", { get: function() {
    return this.state.carbohydrates || (this.state.carbohydrates = fte(this)), this.state.carbohydrates;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "models", { get: function() {
    return this.state.models || (this.state.models = function(e) {
      for (var r = e.units, n = bn.create(), i = 0, a = r; i < a.length; i++) {
        var o = a[i];
        bn.add(n, o.model.id, o.model);
      }
      return n.array;
    }(this)), this.state.models;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uniqueResidueNames", { get: function() {
    return this.state.uniqueResidueNames || (this.state.uniqueResidueNames = function(e) {
      for (var r = Qe.residue.microheterogeneityCompIds, n = /* @__PURE__ */ new Set(), i = at.create(e), a = 0, o = e.unitSymmetryGroups; a < o.length; a++) {
        var s = o[a].units[0];
        if (Fe.isAtomic(s)) {
          var u = Qt.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 = r(i); l < d.length; l++) {
              var f = d[l];
              n.add(f);
            }
          }
        }
      }
      return n;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uniqueElementSymbols", { get: function() {
    return this.state.uniqueElementSymbols || (this.state.uniqueElementSymbols = function(e) {
      for (var r = Qe.atom.type_symbol, n = /* @__PURE__ */ new Set(), i = at.create(e), a = 0, o = e.unitSymmetryGroups; a < o.length; a++) {
        var s = o[a].units[0];
        if (Fe.isAtomic(s)) {
          i.unit = s;
          for (var u = 0, c = s.elements.length; u < c; ++u) i.element = s.elements[u], n.add(r(i));
        }
      }
      return n;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "entityIndices", { get: function() {
    return this.state.entityIndices || (this.state.entityIndices = function(e) {
      for (var r = e.units, n = at.create(e), i = bn.create(), a = 0, o = r; a < o.length; a++) {
        var s = o[a], u = s.kind === 0 ? Qe.entity.key : Qe.coarse.entityKey;
        n.unit = s;
        for (var c = s.elements, l = Qt.transientSegments(s.model.atomicHierarchy.chainAtomSegments, c); l.hasNext; ) {
          var d = l.move();
          n.element = c[d.start];
          var f = u(n);
          bn.add(i, f, f);
        }
      }
      return Ru(i.array), i.array;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uniqueAtomicResidueIndices", { get: function() {
    return this.state.uniqueAtomicResidueIndices || (this.state.uniqueAtomicResidueIndices = function(e) {
      for (var r = /* @__PURE__ */ new Map(), n = [], i = e.unitSymmetryGroups, a = 0, o = i; a < o.length; a++) {
        var s = o[a].units[0];
        if (Fe.isAtomic(s)) {
          var u = void 0;
          r.has(s.model.id) ? u = r.get(s.model.id) : (u = bn.create(), n.push(s.model.id), r.set(s.model.id, u));
          for (var c = Qt.transientSegments(s.model.atomicHierarchy.residueAtomSegments, s.elements); c.hasNext; ) {
            var l = c.move();
            bn.add(u, l.index, l.index);
          }
        }
      }
      for (var d = /* @__PURE__ */ new Map(), f = 0, h = n; f < h.length; f++) {
        var m = h[f], p = r.get(m).array;
        Ru(p), d.set(m, p);
      }
      return d;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isAtomic", { get: function() {
    for (var e = 0, r = this.units; e < r.length; e++) {
      var n = r[e];
      if (!Fe.isAtomic(n)) return !1;
    }
    return !0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasAtomic", { get: function() {
    for (var e = 0, r = this.units; e < r.length; e++) {
      var n = r[e];
      if (Fe.isAtomic(n)) return !0;
    }
    return !1;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isCoarse", { get: function() {
    for (var e = 0, r = this.units; e < r.length; e++) {
      var n = r[e];
      if (!Fe.isCoarse(n)) return !1;
    }
    return !0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasCoarse", { get: function() {
    for (var e = 0, r = this.units; e < r.length; e++) {
      var n = r[e];
      if (Fe.isCoarse(n)) return !0;
    }
    return !1;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "serialMapping", { get: function() {
    return this.state.serialMapping || (this.state.serialMapping = function(e) {
      for (var r = e.units, n = e.elementCount, i = e.unitIndexMap, a = new Uint32Array(r.length), o = new Uint32Array(n), s = new Uint32Array(n), u = 0, c = 0, l = r.length; u < l; ++u) {
        a[u] = c;
        for (var d = r[u].elements, f = 0, h = d.length; f < h; ++f) {
          var m = c + f;
          o[m] = u, s[m] = d[f];
        }
        c += d.length;
      }
      return { cumulativeUnitElementCount: a, unitIndices: o, elementIndices: s, getSerialIndex: function(p, v) {
        return a[i.get(p.id)] + Ge.indexOf(p.elements, v);
      } };
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.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 e = this.models;
    if (e.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 = e[0], this.state.model;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "masterModel", { get: function() {
    return this.state.masterModel;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "representativeModel", { get: function() {
    return this.state.representativeModel;
  }, enumerable: !1, configurable: !0 }), t.prototype.hasElement = function(e) {
    return !!this.unitMap.has(e.unit.id) && Ke.has(this.unitMap.get(e.unit.id).elements, e.element);
  }, t.prototype.getModelIndex = function(e) {
    return this.models.indexOf(e);
  }, t.prototype.remapModel = function(e) {
    for (var r = this.state, n = r.dynamicBonds, i = r.interUnitBonds, a = r.parent, o = [], s = 0, u = this.unitSymmetryGroups; s < u.length; s++) {
      var c = u[s], l = c.units[0].remapModel(e, n);
      o.push(l);
      for (var d = 1, f = c.units.length; d < f; ++d) {
        var h = c.units[d];
        o.push(h.remapModel(e, n, l.props));
      }
    }
    return t.create(o, { parent: a == null ? void 0 : a.remapModel(e), label: this.label, interUnitBonds: n ? void 0 : i, dynamicBonds: n });
  }, t.prototype.asParent = function() {
    if (this._proxy) return this._proxy;
    if (this.parent) {
      var e = this.parent.coordinateSystem.isIdentity ? this.parent : t.transform(this.parent, this.parent.coordinateSystem.inverse), r = this.coordinateSystem.isIdentity ? e : t.transform(e, this.coordinateSystem.matrix);
      this._proxy = new t(r.units, r.unitMap, r.unitIndexMap, O(O({}, r.state), { dynamicBonds: this.dynamicBonds }), { child: this, target: this.parent });
    } else this._proxy = this;
    return this._proxy;
  }, Object.defineProperty(t.prototype, "child", { get: function() {
    return this._child;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
    var e;
    return (e = this._target) !== null && e !== void 0 ? e : this;
  }, enumerable: !1, configurable: !0 }), t;
}();
function gte(t, e, r) {
  return t[e].id - t[r].id;
}
(function(t) {
  function e(g) {
    return { kind: "structure-loci", structure: g };
  }
  function r(g, y) {
    y === void 0 && (y = {});
    for (var b = bc.Mutable(), S = bc.Mutable(), _ = 0, x = !0, C = g.length > 0 ? g[0].id : 0, A = 0, w = g.length; A < w; A++) {
      var I = g[A];
      b.set(I.id, I), _ += I.elements.length, I.id < C && (x = !1), C = I.id;
    }
    for (x || oN(g, 0, g.length, gte, u0), A = 0, w = g.length; A < w; A++) S.set(g[A].id, A);
    var P = { hashCode: -1, transformHash: -1, elementCount: _, bondCount: -1, uniqueElementCount: -1, atomicResidueCount: -1, polymerResidueCount: -1, polymerGapCount: -1, polymerUnitCount: -1, dynamicBonds: !1, coordinateSystem: wn.Default, label: "" };
    return y.parent && (P.parent = y.parent.parent || y.parent), y.interUnitBonds && (P.interUnitBonds = y.interUnitBonds), y.dynamicBonds ? P.dynamicBonds = y.dynamicBonds : y.parent && (P.dynamicBonds = y.parent.dynamicBonds), y.coordinateSystem ? P.coordinateSystem = y.coordinateSystem : y.parent && (P.coordinateSystem = y.parent.coordinateSystem), y.label ? P.label = y.label : y.parent && (P.label = y.parent.label), y.masterModel ? P.masterModel = y.masterModel : y.parent && (P.masterModel = y.parent.masterModel), y.representativeModel ? P.representativeModel = y.representativeModel : y.parent && (P.representativeModel = y.parent.representativeModel), new t(g, b, S, P);
  }
  function n(g, y) {
    y === void 0 && (y = {});
    for (var b = g.atomicHierarchy.chainAtomSegments, S = g.atomicHierarchy.index, _ = g.atomicHierarchy.chains.auth_asym_id, x = g.atomicChainOperatorMappinng, C = new o(O({ label: g.label }, y)), A = 0; A < b.count; A++) {
      var w = x.get(A) || wn.Default, I = b.offsets[A];
      w0.chainResidueCount(g.atomicHierarchy, A), b.offsets[A + 1], b.offsets[A];
      var P = !1;
      if (i(g, A)) for (; A + 1 < b.count && i(g, A + 1) && x.get(A) === x.get(A + 1); )
        P = !0, A++;
      else for (; A + 1 < b.count && b.offsets[A + 1] - b.offsets[A] == 1 && b.offsets[A + 2] - b.offsets[A + 1] == 1 && !(S.getEntityFromChain(A) !== S.getEntityFromChain(A + 1) || _.value(A) !== _.value(A + 1) || x.get(A) !== x.get(A + 1)); )
        P = !0, A++;
      var M = Ke.ofBounds(I, b.offsets[A + 1]);
      C.addUnit(0, g, w, M, P ? 1 : 0);
    }
    var T = g.coarseHierarchy;
    return T.isDefined && (T.spheres.count > 0 && a(C, g, g.coarseHierarchy.spheres, 1), T.gaussians.count > 0 && a(C, g, g.coarseHierarchy.gaussians, 2)), C.getStructure();
  }
  function i(g, y) {
    var b = g.atomicHierarchy.index.getEntityFromChain(y);
    return g.entities.data.type.value(b) === "water";
  }
  function a(g, y, b, S) {
    for (var _ = b.chainElementSegments, x = 0; x < _.count; x++) {
      var C = Ke.ofBounds(_.offsets[x], _.offsets[x + 1]);
      g.addUnit(S, y, wn.Default, C, 0);
    }
  }
  t.Empty = r([]), t.Loci = e, t.toStructureElementLoci = function(g) {
    for (var y = [], b = 0, S = g.units; b < S.length; b++) {
      var _ = S[b];
      y.push({ unit: _, indices: Se.ofBounds(0, _.elements.length) });
    }
    return Xe(g, y);
  }, t.toSubStructureElementLoci = function(g, y) {
    return gt.toLociWithSourceUnits(gt.Singletons(g, y));
  }, t.isLoci = function(g) {
    return !!g && g.kind === "structure-loci";
  }, t.areLociEqual = function(g, y) {
    return g.structure === y.structure;
  }, t.isLociEmpty = function(g) {
    return g.structure.isEmpty;
  }, t.remapLoci = function(g, y) {
    return y === g.structure ? g : e(y);
  }, t.create = r, t.ofTrajectory = function(g, y) {
    return _e(this, 0, void 0, function() {
      var b, S, _, x, C, A, w, I, P, M, T, F, N;
      return ye(this, function(R) {
        switch (R.label) {
          case 0:
            if (g.frameCount === 0) return [2, t.Empty];
            b = [], S = void 0, _ = 0, x = 0, C = g.frameCount, R.label = 1;
          case 1:
            return x < C ? [4, tr.resolveInContext(g.getFrameAtIndex(x), y)] : [3, 4];
          case 2:
            for (A = R.sent(), S || (S = A), w = n(A), I = 0, P = w.units.length; I < P; ++I) M = w.units[I], T = M.invariantId + _, F = M.chainGroupId + _, N = Fe.create(b.length, T, F, M.traits, M.kind, M.model, M.conformation.operator, M.elements), b.push(N);
            _ = b.length, R.label = 3;
          case 3:
            return ++x, [3, 1];
          case 4:
            return [2, r(b, { representativeModel: S, label: S.label })];
        }
      });
    });
  }, t.ofModel = n, t.transform = function(g, y) {
    if (he.isIdentity(y)) return g;
    if (!he.isRotationAndTranslation(y, wn.RotationTranslationEpsilon)) throw new Error("Only rotation/translation combination can be applied.");
    for (var b = [], S = 0, _ = g.units; S < _.length; S++) {
      var x = _[S], C = x.conformation.operator, A = wn.create(C.name, y, C);
      b.push(x.applyOperator(x.id, A));
    }
    var w = g.coordinateSystem;
    return r(b, { parent: g, coordinateSystem: wn.compose(wn.create(w.name, y, w), w) });
  };
  var o = function() {
    function g(y) {
      y === void 0 && (y = {}), this.props = y, this.units = [], this.invariantId = io(), this.chainGroupId = -1, this.inChainGroup = !1, this.p = E(), this.singleElementUnits = /* @__PURE__ */ new Map();
    }
    return g.prototype.beginChainGroup = function() {
      this.chainGroupId++, this.inChainGroup = !0;
    }, g.prototype.endChainGroup = function() {
      this.inChainGroup = !1;
    }, g.prototype.addUnit = function(y, b, S, _, x, C) {
      C === void 0 && (C = this.invariantId());
      var A = this.inChainGroup ? this.chainGroupId : ++this.chainGroupId, w = Fe.create(C, C, A, x, y, b, S, _);
      return this.add(w);
    }, g.prototype.add = function(y) {
      if (y.elements.length === 1) {
        y.conformation.position(y.elements[0], this.p);
        var b = [y.invariantId, this.p[0], this.p[1], this.p[2]].join("|");
        if (this.singleElementUnits.has(b)) return this.singleElementUnits.get(b);
        this.singleElementUnits.set(b, y);
      }
      return this.units.push(y), y;
    }, g.prototype.addWithOperator = function(y, b, S) {
      return S === void 0 && (S = !1), this.add(y.applyOperator(this.units.length, b, S));
    }, g.prototype.getStructure = function() {
      return r(this.units, this.props);
    }, Object.defineProperty(g.prototype, "isEmpty", { get: function() {
      return this.units.length === 0;
    }, enumerable: !1, configurable: !0 }), g;
  }();
  function s(g, y) {
    if (g === y) return !0;
    if (g.elementCount !== y.elementCount) return !1;
    var b = g.units.length;
    if (b !== y.units.length) return !1;
    for (var S = 0; S < b; S++) if (g.units[S].id !== y.units[S].id) return !1;
    return !0;
  }
  function u(g, y) {
    return g === y || g.hashCode === y.hashCode && Ap.areTransformGroupsEquivalent(g.unitSymmetryGroups, y.unitSymmetryGroups);
  }
  t.StructureBuilder = o, t.Builder = function(g) {
    return g === void 0 && (g = {}), new o(g);
  }, t.hashCode = function(g) {
    return g.hashCode;
  }, t.conformationHash = function(g) {
    return x_(g.units.map(function(y) {
      return Fe.conformationId(y);
    }).join("|"));
  }, t.areUnitIdsEqual = s, t.areUnitIdsAndIndicesEqual = function(g, y) {
    if (!s(g, y)) return !1;
    for (var b = 0, S = g.units.length; b < S; b++) if (!Ke.areEqual(g.units[b].elements, y.units[b].elements)) return !1;
    return !0;
  }, t.areHierarchiesEqual = function(g, y) {
    if (g.hashCode !== y.hashCode) return !1;
    var b = g.models.length;
    if (b !== y.models.length) return !1;
    for (var S = 0; S < b; S++) if (!pn.areHierarchiesEqual(g.models[S], y.models[S])) return !1;
    return !0;
  }, t.areEquivalent = u, t.areRootsEquivalent = function(g, y) {
    return u(g.root, y.root);
  }, t.areRootsEqual = function(g, y) {
    return g.root === y.root;
  };
  var c = function() {
    function g(y) {
      this.structure = y, this.unitIndex = 0, this.maxIdx = 0, this.idx = -1, this.current = at.create(y), this.hasNext = y.elementCount > 0, this.hasNext && (this.elements = y.units[0].elements, this.maxIdx = this.elements.length - 1, this.current.unit = y.units[0]);
    }
    return g.prototype.move = function() {
      return this.advance(), this.current.element = this.elements[this.idx], this.current;
    }, g.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));
    }, g;
  }();
  t.ElementLocationIterator = c;
  var l = E();
  function d(g, y, b) {
    for (var S = g.elements, _ = g.conformation, x = _.position, C = _.r, A = l, w = Number.MAX_VALUE, I = 0, P = S.length; I < P; I++) {
      var M = S[I], T = E.distance(y, x(M, A)) - b - C(M);
      T < w && (w = T);
    }
    return w;
  }
  function f(g, y, b) {
    for (var S = g.units, _ = Number.MAX_VALUE, x = 0, C = S.length; x < C; x++) {
      var A = d(S[x], y, b);
      A < _ && (_ = A);
    }
    return _;
  }
  t.minDistanceToPoint = f;
  var h, m = E();
  function p(g) {
    return g.unitSymmetryGroups.filter(function(y) {
      return y.units[0].polymerElements.length > 0;
    });
  }
  t.distance = function(g, y) {
    if (g.elementCount === 0 || y.elementCount === 0) return 0;
    for (var b = g.units, S = Number.MAX_VALUE, _ = 0, x = b.length; _ < x; _++) for (var C = b[_], A = C.elements, w = C.conformation, I = w.position, P = w.r, M = 0, T = A.length; M < T; M++) {
      var F = A[M], N = f(y, I(F, m), P(F));
      N < S && (S = N);
    }
    return S;
  }, t.elementDescription = function(g) {
    return g.elementCount === 1 ? "1 element" : "".concat(g.elementCount, " elements");
  }, t.validUnitPair = function(g, y, b) {
    return !0;
  }, t.eachUnitPair = function(g, y, b) {
    var S = b.maxRadius, _ = b.validUnit, x = b.validUnitPair;
    if (g.units.some(function(R) {
      return _(R);
    })) for (var C = g.lookup3d, A = E(), w = 0, I = g.units; w < I.length; w++) {
      var P = I[w];
      if (_(P)) {
        var M = P.boundary.sphere;
        E.transformMat4(A, M.center, P.conformation.operator.matrix);
        for (var T = C.findUnitIndices(A[0], A[1], A[2], M.radius + S + 9999), F = 0; F < T.count; F++) {
          var N = g.units[T.indices[F]];
          !_(N) || P.id >= N.id || !x(P, N) || (N.elements.length >= P.elements.length ? y(P, N) : y(N, P));
        }
      }
    }
  }, t.eachAtomicHierarchyElement = function(g, y) {
    for (var b = y.chain, S = y.residue, _ = y.atom, x = at.create(g), C = 0, A = g.units; C < A.length; C++) {
      var w = A[C];
      if (w.kind === 0) {
        x.unit = w;
        for (var I = w.elements, P = Qt.transientSegments(w.model.atomicHierarchy.chainAtomSegments, I), M = Qt.transientSegments(w.model.atomicHierarchy.residueAtomSegments, I); P.hasNext; ) {
          var T = P.move();
          if (b && (x.element = I[T.start], b(x)), S || _) for (M.setSegment(T); M.hasNext; ) {
            var F = M.move();
            if (S && (x.element = I[F.start], S(x)), _) for (var N = F.start, R = F.end; N < R; N++) x.element = I[N], _(x);
          }
        }
      }
    }
  }, t.DefaultSizeThresholds = { smallResidueCount: 10, mediumResidueCount: 5e3, largeResidueCount: 3e4, highSymmetryUnitCount: 10, fiberResidueCount: 15 }, function(g) {
    g[g.Small = 0] = "Small", g[g.Medium = 1] = "Medium", g[g.Large = 2] = "Large", g[g.Huge = 3] = "Huge", g[g.Gigantic = 4] = "Gigantic";
  }(h = t.Size || (t.Size = {})), t.getSize = function(g, y, b) {
    y === void 0 && (y = {}), b === void 0 && (b = 1);
    var S = O(O({}, t.DefaultSizeThresholds), y);
    return g.polymerResidueCount >= S.largeResidueCount * b ? function(_, x) {
      var C = p(_);
      return C.length >= 1 && C[0].units.length > x.highSymmetryUnitCount;
    }(g, S) ? h.Huge : h.Gigantic : function(_, x) {
      var C = p(_);
      return C.length === 1 && C[0].units.length > 2 && C[0].units[0].polymerElements.length < x.fiberResidueCount;
    }(g, S) || g.polymerResidueCount < S.smallResidueCount * b ? h.Small : g.polymerResidueCount < S.mediumResidueCount * b ? h.Medium : h.Large;
  }, t.Index = Cp.createSimple("index", "root");
  var v = "__PrincipalAxes__";
  t.getPrincipalAxes = function(g) {
    if (g.currentPropertyData[v]) return g.currentPropertyData[v];
    var y = Xe.getPrincipalAxes(t.toStructureElementLoci(g));
    return g.currentPropertyData[v] = y, y;
  };
})(tt || (tt = {}));
var D0, vte = Ei.diff;
function Xe(t, e) {
  return { kind: "element-loci", structure: t, elements: e };
}
function yte(t) {
  return Fe.isAtomic(t.unit) ? t.unit.residueIndex[t.element] : -1;
}
function bte(t) {
  return Fe.isAtomic(t.unit) ? t.unit.chainIndex[t.element] : -1;
}
function _te(t) {
  return Qe.entity.key(t);
}
(function(t) {
  function e(S) {
    for (var _ = 0, x = S.elements; _ < x.length; _++) {
      var C = x[_];
      if (Ge.size(C.indices) > 0) return !1;
    }
    return !0;
  }
  function r(S) {
    for (var _ = 0, x = 0, C = S.elements; x < C.length; x++) {
      var A = C[x].indices;
      _ += typeof A == "number" ? vte(A) : A.length;
    }
    return _;
  }
  function n(S) {
    return e(S) ? S : t(S.structure, [{ unit: S.elements[0].unit, indices: Ge.ofSingleton(Ge.start(S.elements[0].indices)) }]);
  }
  function i(S) {
    return S.length > 3 && Ke.isRange(S) ? Se.ofRange(S[0], S[S.length - 1]) : Ke.ofSortedArray(S);
  }
  function a(S, _) {
    for (var x = [], C = /* @__PURE__ */ new Set(), A = 0, w = S.elements; A < w.length; A++) {
      var I = w[A];
      if (s(I)) x[x.length] = I;
      else if (I.unit.kind === 0) {
        for (var P = I.unit.elements, M = I.unit.model.atomicHierarchy, T = I.unit.model.atomicHierarchy.atoms.label_alt_id, F = M.residueAtomSegments, N = F.index, R = F.offsets, L = [], V = I.indices, U = Ge.size(V), H = 0; H < U; ) {
          C.clear();
          var K = P[Ge.getAt(V, H)], X = N[K];
          for (C.add(T.value(K)), H++; H < U; ) {
            var Y = P[Ge.getAt(V, H)];
            if (N[Y] !== X) break;
            C.add(T.value(Y)), H++;
          }
          for (var Q = C.has(""), J = R[X], te = R[X + 1]; J < te; J++) {
            var W = Ge.indexOf(P, J);
            if (W >= 0) {
              var j = T.value(J);
              _ && !Q && j && !C.has(j) || (L[L.length] = W);
            }
          }
        }
        x[x.length] = { unit: I.unit, indices: i(L) };
      } else x[x.length] = I;
    }
    return t(S.structure, x);
  }
  function o(S) {
    switch (S.kind) {
      case 0:
        return S.model.atomicHierarchy.chainAtomSegments;
      case 1:
        return S.model.coarseHierarchy.spheres.chainElementSegments;
      case 2:
        return S.model.coarseHierarchy.gaussians.chainElementSegments;
    }
  }
  function s(S) {
    return S.unit.elements.length === Ge.size(S.indices);
  }
  function u(S, _, x) {
    for (var C = o(S).index, A = S.elements, w = 0, I = 0, P = A.length; I < P; I++) {
      var M = C[A[I]];
      _.has(M) && w++;
    }
    if (w !== S.elements.length) {
      var T = new Int32Array(w);
      for (w = 0, I = 0, P = A.length; I < P; I++)
        M = C[A[I]], _.has(M) && (T[w++] = I);
      T.length > 0 && (x[x.length] = { unit: S, indices: i(T) });
    } else x[x.length] = { unit: S, indices: Se.ofBounds(0, w) };
  }
  function c(S, _, x, C, A) {
    for (var w = o(S.elements[0].unit).index, I = /* @__PURE__ */ new Set(), P = _; P < x; P++) for (var M = S.elements[P], T = M.indices, F = M.unit.elements, N = 0, R = Ge.size(T); N < R; N++) I.add(w[F[Ge.getAt(T, N)]]);
    if (C) for (var L = S.elements[0].unit, V = 0, U = S.structure.units; V < U.length; V++) {
      var H = U[V];
      Fe.areSameChainOperatorGroup(H, L) && u(H, I, A);
    }
    else for (P = _; P < x; P++) u(S.elements[P].unit, I, A);
  }
  function l(S) {
    for (var _ = [], x = 0, C = S.elements.length; x < C; x++) {
      var A = S.elements[x];
      if (Fe.Traits.is(A.unit.traits, 2)) {
        for (var w = x; x < C && Fe.areSameChainOperatorGroup(S.elements[x].unit, A.unit); ) x++;
        var I = x;
        x--, c(S, w, I, !0, _);
      } else s(A) ? _[_.length] = A : c(S, x, x + 1, !1, _);
    }
    return t(S.structure, _);
  }
  function d(S) {
    return "".concat(S.unit.model.id, "|").concat(Qe.entity.id(S));
  }
  function f(S, _) {
    for (var x = [], C = 0, A = Ge.size(_); C < A; ++C) x.push(S[Ge.getAt(_, C)]);
    return Ke.ofSortedArray(x);
  }
  function h(S, _) {
    return Ke.isRange(S) && Ke.areEqual(S, _) ? Se.ofLength(S.length) : i(Ke.indicesOf(S, _));
  }
  t.is = function(S) {
    return !!S && S.kind === "element-loci";
  }, t.areEqual = function(S, _) {
    if (S.structure !== _.structure || S.elements.length !== _.elements.length) return !1;
    for (var x = 0, C = S.elements.length; x < C; ++x) {
      var A = S.elements[x], w = _.elements[x];
      if (A.unit.id !== w.unit.id || !Ge.areEqual(A.indices, w.indices)) return !1;
    }
    return !0;
  }, t.isEmpty = e, t.isWholeStructure = function(S) {
    return r(S) === S.structure.elementCount;
  }, t.size = r, t.all = function(S) {
    return t(S, S.units.map(function(_) {
      return { unit: _, indices: Ge.ofBounds(0, _.elements.length) };
    }));
  }, t.none = function(S) {
    return t(S, []);
  }, t.getFirstLocation = function(S, _) {
    if (!e(S)) {
      var x = S.elements[0].unit, C = x.elements[Ge.getAt(S.elements[0].indices, 0)];
      return _ ? (_.structure = S.structure, _.unit = S.elements[0].unit, _.element = C, _) : at.create(S.structure, x, C);
    }
  }, t.firstElement = n, t.firstResidue = function(S) {
    return e(S) ? S : a(n(S));
  }, t.firstChain = function(S) {
    return e(S) ? S : l(n(S));
  }, t.toStructure = function(S) {
    for (var _ = [], x = function(w) {
      var I = w.unit, P = w.indices, M = new Int32Array(Ge.size(P));
      Ge.forEach(P, function(T, F) {
        return M[F] = I.elements[T];
      }), _.push(I.getChild(Ke.ofSortedArray(M)));
    }, C = 0, A = S.elements; C < A.length; C++)
      x(A[C]);
    return tt.create(_, { parent: S.structure.parent });
  }, t.remap = function(S, _) {
    if (_ === S.structure) return S;
    var x = [];
    return S.elements.forEach(function(C) {
      if (_.unitMap.has(C.unit.id)) {
        var A = _.unitMap.get(C.unit.id), w = Ge.indexedIntersect(C.indices, C.unit.elements, A.elements);
        Ge.size(w) > 0 && x.push({ unit: A, indices: w });
      }
    }), t(_, x);
  }, t.union = function S(_, x) {
    if (_.elements.length > x.elements.length) return S(x, _);
    if (t.isEmpty(_)) return x;
    for (var C = /* @__PURE__ */ new Map(), A = 0, w = _.elements; A < w.length; A++) {
      var I = w[A];
      C.set(I.unit.id, I.indices);
    }
    for (var P = [], M = 0, T = x.elements; M < T.length; M++)
      I = T[M], C.has(I.unit.id) ? (P[P.length] = { unit: I.unit, indices: Ge.union(C.get(I.unit.id), I.indices) }, C.delete(I.unit.id)) : P[P.length] = I;
    return C.forEach(function(F, N) {
      P[P.length] = { unit: _.structure.unitMap.get(N), indices: F };
    }), t(_.structure, P);
  }, t.subtract = function(S, _) {
    for (var x = /* @__PURE__ */ new Map(), C = 0, A = _.elements; C < A.length; C++) {
      var w = A[C];
      x.set(w.unit.id, w.indices);
    }
    for (var I = [], P = 0, M = S.elements; P < M.length; P++)
      if (w = M[P], x.has(w.unit.id)) {
        var T = Ge.subtract(w.indices, x.get(w.unit.id));
        if (Ge.size(T) === 0) continue;
        I[I.length] = { unit: w.unit, indices: T };
      } else I[I.length] = w;
    return t(S.structure, I);
  }, t.intersect = function(S, _) {
    for (var x = /* @__PURE__ */ new Map(), C = 0, A = S.elements; C < A.length; C++) {
      var w = A[C];
      x.set(w.unit.id, w.indices);
    }
    for (var I = [], P = 0, M = _.elements; P < M.length; P++)
      if (w = M[P], x.has(w.unit.id)) {
        var T = Ge.intersect(x.get(w.unit.id), w.indices);
        Ge.size(T) !== 0 && (I[I.length] = { unit: w.unit, indices: T });
      }
    return t(S.structure, I);
  }, t.areIntersecting = function S(_, x) {
    if (_.elements.length > x.elements.length) return S(x, _);
    if (t.isEmpty(_)) return t.isEmpty(x);
    for (var C = /* @__PURE__ */ new Map(), A = 0, w = _.elements; A < w.length; A++) {
      var I = w[A];
      C.set(I.unit.id, I.indices);
    }
    for (var P = 0, M = x.elements; P < M.length; P++)
      if (I = M[P], C.has(I.unit.id) && Ge.areIntersecting(C.get(I.unit.id), I.indices)) return !0;
    return !1;
  }, t.isSubset = function(S, _) {
    if (t.isEmpty(S)) return t.isEmpty(_);
    for (var x = /* @__PURE__ */ new Map(), C = 0, A = S.elements; C < A.length; C++) {
      var w = A[C];
      x.set(w.unit.id, w.indices);
    }
    for (var I = !1, P = 0, M = _.elements; P < M.length; P++)
      if (w = M[P], x.has(w.unit.id)) {
        if (!Ge.isSubset(x.get(w.unit.id), w.indices)) return !1;
        I = !0;
      }
    return I;
  }, t.extendToWholeResidues = a, t.extendToWholeChains = l, t.extendToWholeEntities = function(S) {
    for (var _ = [], x = at.create(S.structure), C = /* @__PURE__ */ new Set(), A = S.structure.units, w = 0, I = S.elements.length; w < I; w++) {
      var P = S.elements[w];
      x.unit = P.unit, x.element = P.unit.elements[0], C.add(d(x));
    }
    w = 0;
    for (var M = A.length; w < M; ++w) {
      var T = A[w];
      if (x.unit = T, x.element = T.elements[0], C.has(d(x))) {
        var F = Ge.ofBounds(0, T.elements.length);
        _[_.length] = { unit: T, indices: F };
      }
    }
    return t(S.structure, _);
  }, t.extendToWholeModels = function(S) {
    for (var _ = [], x = /* @__PURE__ */ new Set(), C = S.structure.units, A = 0, w = S.elements.length; A < w; A++) {
      var I = S.elements[A];
      x.add(I.unit.model.id);
    }
    A = 0;
    for (var P = C.length; A < P; ++A) {
      var M = C[A];
      if (x.has(M.model.id)) {
        var T = Ge.ofBounds(0, M.elements.length);
        _[_.length] = { unit: M, indices: T };
      }
    }
    return t(S.structure, _);
  }, t.extendToAllInstances = function(S) {
    for (var _ = [], x = /* @__PURE__ */ new Map(), C = 0, A = S.elements.length; C < A; C++) {
      var w = S.elements[C], I = w.unit.model, P = f(w.unit.elements, w.indices);
      x.has(I) ? x.set(I, Ke.union(P, x.get(I))) : x.set(I, P);
    }
    C = 0;
    for (var M = S.structure.units.length; C < M; ++C) {
      var T = S.structure.units[C];
      if (P = x.get(T.model)) {
        var F = h(T.elements, P);
        Ge.size(F) && (_[_.length] = { unit: T, indices: F });
      }
    }
    return t(S.structure, _);
  }, t.extendToWholeOperators = function(S) {
    for (var _ = [], x = /* @__PURE__ */ new Set(), C = S.structure.units, A = 0, w = S.elements.length; A < w; A++) {
      var I = S.elements[A];
      x.add(I.unit.conformation.operator.name);
    }
    A = 0;
    for (var P = C.length; A < P; ++A) {
      var M = C[A];
      if (x.has(M.conformation.operator.name)) {
        var T = Ge.ofBounds(0, M.elements.length);
        _[_.length] = { unit: M, indices: T };
      }
    }
    return t(S.structure, _);
  };
  var m = new cu("98"), p = E();
  t.getBoundary = function(S, _) {
    m.reset();
    for (var x = 0, C = S.elements; x < C.length; x++) for (var A = (R = C[x]).indices, w = R.unit.conformation.position, I = R.unit.conformation.r, P = R.unit.elements, M = 0, T = Ge.size(A); M < T; M++)
      w(L = P[Ge.getAt(A, M)], p), _ && E.transformMat4(p, p, _), m.includePositionRadius(p, I(L));
    m.finishedIncludeStep();
    for (var F = 0, N = S.elements; F < N.length; F++) {
      var R;
      for (A = (R = N[F]).indices, w = R.unit.conformation.position, I = R.unit.conformation.r, P = R.unit.elements, M = 0, T = Ge.size(A); M < T; M++) {
        var L;
        w(L = P[Ge.getAt(A, M)], p), _ && E.transformMat4(p, p, _), m.radiusPositionRadius(p, I(L));
      }
    }
    return { box: m.getBox(), sphere: m.getSphere() };
  };
  var v = E();
  function g(S, _, x) {
    x === void 0 && (x = 0);
    for (var C = x, A = 0, w = S.elements; A < w.length; A++) {
      for (var I = w[A], P = I.indices, M = I.unit.conformation.position, T = I.unit.elements, F = Ge.size(P), N = 0; N < F; N++)
        M(T[Ge.getAt(P, N)], v), E.toArray(v, _, C + 3 * N);
      C += 3 * F;
    }
    return _;
  }
  function y(S, _) {
    return Fe.isAtomic(S) ? S.model.atomicHierarchy.atomSourceIndex.value(_) : _;
  }
  function b(S, _, x, C, A) {
    Ru(_);
    for (var w = [], I = [], P = 0, M = _.length; P < M; ) {
      var T = P;
      for (P++; P < M && _[P - 1] + 1 === _[P]; ) P++;
      var F = P;
      if (F - T > 12) w[w.length] = _[T], w[w.length] = _[F - 1];
      else for (var N = T; N < F; N++) I[I.length] = _[N];
    }
    return x ? { atom: { set: I, ranges: w }, chain: { opName: [S] }, entity: { modelLabel: C, modelIndex: A } } : { atom: { set: I, ranges: w }, chain: { opName: [S] } };
  }
  t.toPositionsArray = g, t.getPrincipalAxes = function(S) {
    var _ = r(S), x = g(S, new Float32Array(3 * _));
    return Qd.ofPositions(x);
  }, t.getPrincipalAxesMany = function(S) {
    var _ = 0;
    S.forEach(function(A) {
      _ += r(A);
    });
    var x = new Float32Array(3 * _), C = 0;
    return S.forEach(function(A) {
      g(A, x, C), C += 3 * r(A);
    }), Qd.ofPositions(x);
  }, t.toExpression = function(S) {
    var _;
    if (t.isEmpty(S)) return Nt.struct.generator.empty();
    for (var x = S.structure.models, C = /* @__PURE__ */ new Map(), A = 0, w = S.elements; A < w.length; A++) {
      var I = (H = w[A]).indices, P = H.unit.elements, M = H.unit.conformation.operator.name, T = void 0;
      C.has(M) ? T = C.get(M).xs : (T = bn.create(), C.set(M, { modelLabel: H.unit.model.label, modelIndex: H.unit.model.modelNum, xs: T }));
      for (var F = 0, N = Ge.size(I); F < N; F++) {
        var R = y(H.unit, P[Ge.getAt(I, F)]);
        bn.add(T, R, R);
      }
    }
    for (var L = [], V = C.keys(); ; ) {
      var U = V.next();
      if (U.done) break;
      var H = C.get(U.value);
      L.push(b(U.value, H.xs.array, x.length > 1, H.modelLabel, H.modelIndex));
    }
    for (var K = /* @__PURE__ */ new Map(), X = (F = 0, L.length); F < X; ++F) {
      var Y = L[F], Q = Wp(ro(Y.atom.ranges), ro(Y.atom.set));
      M = "".concat(Q, "|").concat(Y.entity ? Y.entity.modelLabel + Y.entity.modelIndex : ""), K.has(M) ? (_ = K.get(M).chain.opName).push.apply(_, Y.chain.opName) : K.set(M, Y);
    }
    var J = [];
    return K.forEach(function(te) {
      var W = te.atom, j = W.ranges, ee = W.set, ie = te.chain.opName, ae = Nt.struct.atomProperty.core.operatorName(), ce = Nt.struct.atomProperty.core.sourceIndex(), de = [];
      ee.length > 0 && (de[de.length] = Nt.core.set.has([Nt.core.type.set(ee), ce]));
      for (var Ce = 0, De = j.length / 2; Ce < De; Ce++) de[de.length] = Nt.core.rel.inRange([ce, j[2 * Ce], j[2 * Ce + 1]]);
      if (te.entity) {
        var ke = te.entity, He = ke.modelLabel, We = ke.modelIndex;
        J.push(Nt.struct.generator.atomGroups({ "atom-test": de.length > 1 ? Nt.core.logic.or(de) : de[0], "chain-test": ie.length > 1 ? Nt.core.set.has([Nt.core.type.set(ie), ae]) : Nt.core.rel.eq([ae, ie[0]]), "entity-test": Nt.core.logic.and([Nt.core.rel.eq([Nt.struct.atomProperty.core.modelLabel(), He]), Nt.core.rel.eq([Nt.struct.atomProperty.core.modelIndex(), We])]) }));
      } else J.push(Nt.struct.generator.atomGroups({ "atom-test": de.length > 1 ? Nt.core.logic.or(de) : de[0], "chain-test": ie.length > 1 ? Nt.core.set.has([Nt.core.type.set(ie), ae]) : Nt.core.rel.eq([ae, ie[0]]) }));
    }), Nt.struct.modifier.union([J.length === 1 ? J[0] : Nt.struct.combinator.merge(J.map(function(te) {
      return Nt.struct.modifier.union([te]);
    }))]);
  };
})(Xe || (Xe = {})), function(t) {
  function e() {
    return { elementCount: 0, conformationCount: 0, residueCount: 0, chainCount: 0, unitCount: 0, structureCount: 0, firstElementLoc: at.create(void 0), firstConformationLoc: at.create(void 0), firstResidueLoc: at.create(void 0), firstChainLoc: at.create(void 0), firstUnitLoc: at.create(void 0), firstStructureLoc: at.create(void 0) };
  }
  function r(o, s, u) {
    var c = o.get(s) || 0;
    o.set(s, c + u);
  }
  function n(o, s, u) {
    var c = u.indices, l = u.unit, d = l.elements, f = Ge.size(c), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
    if (f > 0 && at.set(o.firstElementLoc, s, l, d[Ge.start(c)]), f === d.length) o.unitCount += 1, o.unitCount === 1 && at.set(o.firstUnitLoc, s, l, d[Ge.start(c)]);
    else if (f === 1) {
      if (Fe.Traits.is(l.traits, 1)) return;
      o.elementCount += 1, o.elementCount === 1 && at.set(o.firstElementLoc, s, l, d[Ge.start(c)]);
    } else if (Fe.isAtomic(l)) for (var p = l.model.atomicHierarchy.residueAtomSegments, v = p.index, g = p.offsets, y = l.model.atomicHierarchy.atoms.label_alt_id, b = 0, S = function() {
      h.clear();
      var _ = 0, x = d[Ge.getAt(c, b)], C = v[x];
      for (r(h, y.value(x), 1), ++b, ++_; b < f; ) {
        var A = d[Ge.getAt(c, b)];
        if (v[A] !== C) break;
        r(h, y.value(A), 1), ++b, ++_;
      }
      if (g[C + 1] - g[C] === _) o.residueCount += 1, o.residueCount === 1 && at.set(o.firstResidueLoc, s, l, g[C]);
      else {
        m.clear();
        for (var w = g[C], I = g[C + 1]; w < I; ++w) r(m, y.value(w), 1);
        m.get("") === h.get("") && h.forEach(function(P, M) {
          if (m.get(M) === P) {
            if (M !== "" && (o.conformationCount += 1, o.conformationCount === 1)) {
              for (var T = g[C], F = g[C + 1]; T < F; ++T) if (M === y.value(T)) {
                at.set(o.firstConformationLoc, s, l, T);
                break;
              }
            }
            _ -= P;
          }
        }), o.elementCount += _;
      }
    }; b < f; ) S();
    else o.elementCount += f, o.elementCount === 1 && at.set(o.firstElementLoc, s, l, d[Ge.start(c)]);
  }
  function i(o, s, u) {
    var c = u.indices, l = u.unit, d = Ge.size(c);
    if (d !== 0) {
      var f = l.elements;
      if (Fe.Traits.is(l.traits, 1)) {
        var h = Fe.isAtomic(l) ? l.model.atomicHierarchy.chainAtomSegments : Fe.isSpheres(l) ? l.model.coarseHierarchy.spheres.chainElementSegments : Fe.isGaussians(l) ? l.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
        if (h) for (var m = h.index, p = h.offsets, v = 0; v < d; ) {
          var g = 0, y = f[Ge.getAt(c, v)], b = m[y];
          for (++v, ++g; v < d && m[f[Ge.getAt(c, v)]] === b; )
            ++v, ++g;
          p[b + 1] - p[b] === g ? (o.chainCount += 1, o.chainCount === 1 && at.set(o.firstChainLoc, s, l, p[b])) : d === 1 && (o.elementCount += 1, o.elementCount === 1 && at.set(o.firstElementLoc, s, l, y));
        }
        else console.warn("StructureElement loci stats: unknown unit type");
      } else d === f.length && (o.chainCount += 1, o.chainCount === 1 && at.set(o.firstChainLoc, s, l, f[Ge.start(c)]));
    }
  }
  function a(o, s, u, c, l) {
    var d = u[c], f = Fe.isAtomic(d.unit) ? d.unit.model.atomicHierarchy.chainAtomSegments : Fe.isSpheres(d.unit) ? d.unit.model.coarseHierarchy.spheres.chainElementSegments : Fe.isGaussians(d.unit) ? d.unit.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
    if (f) {
      for (var h = f.index, m = f.offsets, p = /* @__PURE__ */ new Map(), v = c; v < l; v++) {
        var g = (d = u[v]).indices, y = d.unit;
        if ((A = Ge.size(g)) !== 0) {
          var b = y.elements;
          if (Fe.Traits.is(y.traits, 1)) for (var S = 0; S < A; ) {
            var _ = 0, x = h[w = b[Ge.getAt(g, S)]];
            for (++S, ++_; S < A && h[b[Ge.getAt(g, S)]] === x; )
              ++S, ++_;
            r(p, x, _);
          }
          else r(p, h[w = b[Ge.start(g)]], b.length);
        }
      }
      var C = -1;
      if (p.forEach(function(I, P) {
        m[P + 1] - m[P] === I && (o.chainCount += 1, o.chainCount === 1 && (C = P));
      }), !(C < 0)) for (v = c; v < l; v++) {
        var A;
        if (g = (d = u[v]).indices, y = d.unit, (A = Ge.size(g)) !== 0) for (b = y.elements, S = 0; S < A; ) {
          var w;
          if ((x = h[w = b[Ge.getAt(g, S)]]) === C) return void at.set(o.firstChainLoc, s, y, w);
        }
      }
    } else console.warn("StructureElement loci stats: unknown unit type");
  }
  t.create = e, t.ofLoci = function(o) {
    var s = e();
    if (Xe.isEmpty(o)) return s;
    var u = !1;
    if (Xe.isWholeStructure(o)) {
      if (s.structureCount += 1, s.structureCount === 1) {
        var c = o.elements[0], l = c.unit, d = c.indices;
        at.set(s.firstStructureLoc, o.structure, l, l.elements[Ge.min(d)]);
      }
    } else for (var f = 0, h = o.elements; f < h.length; f++) {
      var m = h[f];
      n(s, o.structure, m), Fe.Traits.is(m.unit.traits, 2) ? u = !0 : i(s, o.structure, m);
    }
    if (u) {
      for (var p = 0, v = o.elements.length; p < v; p++)
        if (m = o.elements[p], Fe.Traits.is(m.unit.traits, 2)) {
          for (var g = p; p < v && Fe.areSameChainOperatorGroup(o.elements[p].unit, m.unit); ) p++;
          var y = p;
          p--, y - g == 1 ? i(s, o.structure, m) : a(s, o.structure, o.elements, g, y);
        }
    }
    return s;
  }, t.add = function(o, s, u) {
    return s.elementCount === 1 && u.elementCount === 0 ? at.copy(o.firstElementLoc, s.firstElementLoc) : s.elementCount === 0 && u.elementCount === 1 && at.copy(o.firstElementLoc, u.firstElementLoc), s.conformationCount === 1 && u.conformationCount === 0 ? at.copy(o.firstConformationLoc, s.firstConformationLoc) : s.conformationCount === 0 && u.conformationCount === 1 && at.copy(o.firstConformationLoc, u.firstConformationLoc), s.residueCount === 1 && u.residueCount === 0 ? at.copy(o.firstResidueLoc, s.firstResidueLoc) : s.residueCount === 0 && u.residueCount === 1 && at.copy(o.firstResidueLoc, u.firstResidueLoc), s.chainCount === 1 && u.chainCount === 0 ? at.copy(o.firstChainLoc, s.firstChainLoc) : s.chainCount === 0 && u.chainCount === 1 && at.copy(o.firstChainLoc, u.firstChainLoc), s.unitCount === 1 && u.unitCount === 0 ? at.copy(o.firstUnitLoc, s.firstUnitLoc) : s.unitCount === 0 && u.unitCount === 1 && at.copy(o.firstUnitLoc, u.firstUnitLoc), s.structureCount === 1 && u.structureCount === 0 ? at.copy(o.firstStructureLoc, s.firstStructureLoc) : s.structureCount === 0 && u.structureCount === 1 && at.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;
  };
}(D0 || (D0 = {}));
var fp, _E;
(function(t) {
  function e(r) {
    var n = this, i = r.descriptor.name, a = r.type === "static" ? "_staticPropertyData" : "_dynamicPropertyData", o = function(u) {
      return i in u[a] || (u[a][i] = { props: O({}, z.getDefaultValues(r.getParams(u))), data: Gd.create(void 0) }), u[a][i];
    }, s = function(u, c, l) {
      var d = o(u);
      u[a][i] = { props: c, data: Gd.withValue(d.data, l) };
    };
    return { label: r.label, descriptor: r.descriptor, isHidden: r.isHidden, getParams: function(u) {
      var c = z.clone(r.getParams(u));
      return z.setDefaultValues(c, o(u).props), c;
    }, defaultParams: r.defaultParams, isApplicable: r.isApplicable, attach: function(u, c, l, d) {
      return l === void 0 && (l = {}), _e(n, 0, void 0, function() {
        var f, h, m, p, v;
        return ye(this, function(g) {
          switch (g.label) {
            case 0:
              return d && c.customProperties.reference(r.descriptor, !0), f = o(c), h = z.merge(r.defaultParams, f.props, l), f.data.value && z.areEqual(r.defaultParams, f.props, h) ? [2] : [4, r.obtain(u, c, h)];
            case 1:
              return m = g.sent(), p = m.value, v = m.assets, c.customProperties.add(r.descriptor), c.customProperties.assets(r.descriptor, v), s(c, h, p), [2];
          }
        });
      });
    }, ref: function(u, c) {
      return u.customProperties.reference(r.descriptor, c);
    }, get: function(u) {
      var c;
      return (c = o(u)) === null || c === void 0 ? void 0 : c.data;
    }, set: function(u, c) {
      c === void 0 && (c = {});
      var l = o(u), d = z.merge(r.defaultParams, l.props, c);
      z.areEqual(r.defaultParams, l.props, d) || (s(u, d, void 0), u.customProperties.assets(r.descriptor));
    }, props: function(u) {
      return o(u).props;
    } };
  }
  t.createProvider = e, t.createSimple = function(r, n, i) {
    var a = this, o = { value: z.Value(i, { isHidden: !0 }) };
    return e({ label: mc(r), descriptor: ku({ name: r }), isHidden: !0, type: n, defaultParams: o, getParams: function() {
      return { value: z.Value(i, { isHidden: !0 }) };
    }, isApplicable: function() {
      return !0;
    }, obtain: function(s, u, c) {
      return _e(a, 0, void 0, function() {
        var l;
        return ye(this, function(d) {
          return [2, { value: (l = c.value) !== null && l !== void 0 ? l : i }];
        });
      });
    } });
  };
})(fp || (fp = {})), function(t) {
  var e = this;
  function r(i) {
    if (!An.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 n(i) {
    if (An.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, f = d.count, h = d.offsets, m = new Array(f), p = new Array(f), v = new Array(f), g = new Array(f), y = 0; y < f; y++) {
          var b = l.value(h[y]);
          o.valueKind(b) === 0 ? (m[y] = o.value(b), p[y] = s.value(b), v[y] = u.value(b), g[y] = c.value(b)) : (m[y] = "", p[y] = "", v[y] = "", g[y] = "");
        }
        return { dbName: m, accession: p, num: v, residue: g };
      }
    }
  }
  t.Provider = fp.createProvider({ label: "SIFTS Mapping", descriptor: ku({ name: "sifts_sequence_mapping" }), type: "static", defaultParams: {}, getParams: function() {
    return {};
  }, isApplicable: function(i) {
    return r(i);
  }, obtain: function(i, a) {
    return _e(e, 0, void 0, function() {
      return ye(this, function(o) {
        return [2, { value: n(a) }];
      });
    });
  } }), t.isAvailable = r, t.getKey = function(i) {
    var a = i.unit.model, o = t.Provider.get(a).value;
    if (!o) return "";
    var s = i.unit.elements[i.element], u = a.atomicHierarchy.residueAtomSegments.index[s];
    return o.accession[u];
  }, t.getLabel = function(i) {
    var a = i.unit.model, o = t.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]);
    }
  };
}(_E || (_E = {})), na.Field;
na.Encodings;
na.Field;
na.Category;
na.Category;
var xE;
na.Category;
(function(t) {
  t.create = function(e) {
    var r = Array.isArray(e) ? e : [e];
    return { structures: r, firstModel: r[0].model, cache: /* @__PURE__ */ Object.create(null) };
  };
})(xE || (xE = {}));
var SE;
(function(t) {
  t.AtomSitePositionsFieldNames = /* @__PURE__ */ new Set(["id", "Cartn_x", "Cartn_y", "Cartn_z"]);
})(SE || (SE = {}));
var xte = { molstar_atom_site_operator_mapping: { label_asym_id: se.Schema.Str(), auth_asym_id: se.Schema.Str(), operator_name: se.Schema.Str(), suffix: se.Schema.Str(), assembly_id: se.Schema.Str(), assembly_operator_id: se.Schema.Int(), symmetry_operator_index: se.Schema.Int(), symmetry_hkl: se.Schema.Vector(3), ncs_id: se.Schema.Int() } }, CE = function(t, e) {
  return e[t].operator.assembly === void 0 ? 1 : 0;
}, ob = function(t, e) {
  return e[t].operator.spgrOp === -1 ? 1 : 0;
};
na.fields().str("label_asym_id", function(t, e) {
  return e[t].label_asym_id;
}).str("auth_asym_id", function(t, e) {
  return e[t].auth_asym_id;
}).str("operator_name", function(t, e) {
  return e[t].operator.name;
}).str("suffix", function(t, e) {
  return e[t].operator.suffix;
}).str("assembly_id", function(t, e) {
  var r;
  return ((r = e[t].operator.assembly) === null || r === void 0 ? void 0 : r.id) || "";
}, { valueKind: CE }).int("assembly_operator_id", function(t, e) {
  var r;
  return ((r = e[t].operator.assembly) === null || r === void 0 ? void 0 : r.operId) || 0;
}, { valueKind: CE }).int("symmetry_operator_index", function(t, e) {
  return e[t].operator.spgrOp;
}, { valueKind: ob }).vec("symmetry_hkl", [function(t, e) {
  return e[t].operator.hkl[0];
}, function(t, e) {
  return e[t].operator.hkl[1];
}, function(t, e) {
  return e[t].operator.hkl[2];
}], { valueKind: ob }).int("ncs_id", function(t, e) {
  return e[t].operator.ncsId;
}, { valueKind: ob }).getFields();
function Pm(t, e) {
  return e ? e.length === 1 ? iu(e.charCodeAt(0), t) : e.length === 2 ? iu(e.charCodeAt(0), iu(e.charCodeAt(1), t)) : "".concat(t, " ").concat(e) : t;
}
function Ste(t, e, r, n) {
  if (t.has(e))
    (i = t.get(e)).has(r) || i.set(r, n);
  else {
    var i = /* @__PURE__ */ new Map();
    t.set(e, i), i.set(r, n);
  }
}
function Cte(t) {
  throw new Error("Missing entity entry for entity id '".concat(t, "'."));
}
var Nh = j_.EmptyResidueKey(), Ate = function() {
  function t(e) {
    this.map = e, this.entityIndex = e.entities.getEntityIndex, this.residueOffsets = this.map.segments.residueAtomSegments.offsets;
  }
  return t.prototype.getEntityFromChain = function(e) {
    return this.map.chain_index_entity_index[e];
  }, t.prototype.findEntity = function(e) {
    var r = this.map.label_asym_id.get(e);
    return r !== void 0 ? r : -1;
  }, t.prototype.findChainLabel = function(e) {
    var r = this.entityIndex(e.label_entity_id);
    if (r < 0 || !this.map.entity_index_label_asym_id.has(r)) return -1;
    var n = this.map.entity_index_label_asym_id.get(r);
    return n && n.has(e.label_asym_id) ? n.get(e.label_asym_id) : -1;
  }, t.prototype.findChainAuth = function(e) {
    if (!this.map.auth_asym_id_auth_seq_id.has(e.auth_asym_id)) return -1;
    var r = this.map.auth_asym_id_auth_seq_id.get(e.auth_asym_id);
    return r.has(e.auth_seq_id) ? r.get(e.auth_seq_id) : -1;
  }, t.prototype.findResidue = function(e, r, n, i) {
    var a;
    arguments.length === 1 ? a = e : (Nh.label_entity_id = e, Nh.label_asym_id = r, Nh.auth_seq_id = n, Nh.pdbx_PDB_ins_code = i, a = Nh);
    var o = this.findChainLabel(a);
    if (o < 0) return -1;
    var s = this.map.chain_index_auth_seq_id.get(o), u = Pm(a.auth_seq_id, a.pdbx_PDB_ins_code || "");
    return s.has(u) ? s.get(u) : -1;
  }, t.prototype.findResidueAuth = function(e) {
    var r = this.findChainAuth(e);
    if (r < 0) return -1;
    var n = this.map.chain_index_auth_seq_id.get(r), i = Pm(e.auth_seq_id, e.pdbx_PDB_ins_code || "");
    return n.has(i) ? n.get(i) : -1;
  }, t.prototype.findResidueInsertion = function(e) {
    var r = this.findChainLabel(e);
    if (r < 0) return -1;
    var n = this.map.chain_index_label_seq_id.get(r), i = Pm(e.label_seq_id, e.pdbx_PDB_ins_code || "");
    if (n.has(i)) return n.get(i);
    var a = Ke.findPredecessorIndex(this.map.label_seq_id, e.label_seq_id), o = w0.chainStartResidueIndex(this.map.segments, r);
    if (a < o) return o;
    var s = w0.chainEndResidueIndexExcl(this.map.segments, r) - 1;
    return a >= s ? s : a;
  }, t.prototype.findAtom = function(e) {
    var r = this.findResidue(e);
    return r < 0 ? -1 : e.label_alt_id === void 0 ? sb(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, e.label_atom_id) : ub(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, this.map.label_alt_id, e.label_atom_id, e.label_alt_id);
  }, t.prototype.findAtomAuth = function(e) {
    var r = this.findResidueAuth(e);
    return r < 0 ? -1 : e.label_alt_id === void 0 ? sb(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.auth_atom_id, e.auth_atom_id) : ub(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.auth_atom_id, this.map.label_alt_id, e.auth_atom_id, e.label_alt_id);
  }, t.prototype.findAtomOnResidue = function(e, r, n) {
    return n === void 0 ? sb(this.residueOffsets[e], this.residueOffsets[e + 1], this.map.label_atom_id, r) : ub(this.residueOffsets[e], this.residueOffsets[e + 1], this.map.label_atom_id, this.map.label_alt_id, r, n);
  }, t.prototype.findAtomsOnResidue = function(e, r) {
    return function(n, i, a, o) {
      for (var s = n; s < i; s++) if (o.has(a.value(s))) return s;
      return -1;
    }(this.residueOffsets[e], this.residueOffsets[e + 1], this.map.label_atom_id, r);
  }, t.prototype.findElementOnResidue = function(e, r) {
    return function(n, i, a, o) {
      for (var s = n; s < i; s++) if (a.value(s) === o) return s;
      return -1;
    }(this.residueOffsets[e], this.residueOffsets[e + 1], this.map.type_symbol, r);
  }, t;
}();
function sb(t, e, r, n) {
  for (var i = t; i < e; i++) if (r.value(i) === n) return i;
  return -1;
}
function ub(t, e, r, n, i, a) {
  for (var o = t; o < e; o++) if (r.value(o) === i && n.value(o) === a) return o;
  return -1;
}
function wte(t, e, r) {
  for (var n = function(I, P, M) {
    return { entities: I, segments: M, label_seq_id: Ke.ofSortedArray(P.residues.label_seq_id.toArray({ array: Int32Array })), label_atom_id: P.atoms.label_atom_id, auth_atom_id: P.atoms.auth_atom_id, label_alt_id: P.atoms.label_alt_id, type_symbol: P.atoms.type_symbol, chain_index_entity_index: new Int32Array(P.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() };
  }(e, t, r), i = t.residues, a = i.label_seq_id, o = i.auth_seq_id, s = i.pdbx_PDB_ins_code, u = t.chains, c = u.label_entity_id, l = u.label_asym_id, d = u.auth_asym_id, f = Se.ofBounds(0, t.atoms._rowCount), h = Qt.transientSegments(r.chainAtomSegments, f); h.hasNext; ) {
    var m = h.move(), p = m.index, v = e.getEntityIndex(c.value(p));
    v < 0 && Cte(c.value(p)), n.chain_index_entity_index[p] = v;
    var g = d.value(p), y = n.auth_asym_id_auth_seq_id.get(g);
    y || (y = /* @__PURE__ */ new Map(), n.auth_asym_id_auth_seq_id.set(g, y));
    var b = l.value(p);
    n.label_asym_id.has(b) || n.label_asym_id.set(b, v), Ste(n.entity_index_label_asym_id, v, b, p);
    var S = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
    n.chain_index_label_seq_id.set(p, S), n.chain_index_auth_seq_id.set(p, _);
    for (var x = Qt.transientSegments(r.residueAtomSegments, f, m); x.hasNext; ) {
      var C = x.move().index, A = o.value(C), w = s.value(C);
      S.set(Pm(a.value(C), w), C), _.set(Pm(A, w), C), y.set(A, p);
    }
  }
  return new Ate(n);
}
function Dte(t, e, r, n, i, a) {
  var o = function(f) {
    if (f._rowCount === 0) return { residues: [], chains: [] };
    for (var h = f._rowCount, m = [0], p = [0], v = f.label_entity_id, g = f.label_asym_id, y = f.label_seq_id, b = f.auth_seq_id, S = f.pdbx_PDB_ins_code, _ = 1; _ < h; _++) {
      var x = !v.areValuesEqual(_ - 1, _) || !g.areValuesEqual(_ - 1, _);
      (x || !y.areValuesEqual(_ - 1, _) || !b.areValuesEqual(_ - 1, _) || !S.areValuesEqual(_ - 1, _)) && (m[m.length] = _), x && (p[p.length] = _);
    }
    return { residues: m, chains: p };
  }(t), s = function(f, h, m) {
    var p = Hr.ofColumns(yee, { type_symbol: se.ofArray({ array: se.mapToArray(f.type_symbol, bp), schema: se.Schema.Aliased(se.Schema.str) }), label_atom_id: f.label_atom_id, auth_atom_id: f.auth_atom_id, label_alt_id: f.label_alt_id, label_comp_id: f.label_comp_id, auth_comp_id: f.auth_comp_id, pdbx_formal_charge: f.pdbx_formal_charge, cdr: f.cdr, B_iso_or_equiv: f.B_iso_or_equiv, em_confidence: f.em_confidence }), v = Hr.view(f, bee, m.residues), g = Hr.view(f, _ee, m.chains);
    if (!v.label_seq_id.isDefined) {
      for (var y = new Int32Array(v.label_seq_id.rowCount), b = m.residues, S = m.chains, _ = 0, x = 0, C = 0, A = y.length; C < A; ++C) b[C] >= S[_ + 1] && (_ += 1, x = 0), y[C] = ++x;
      v.label_seq_id = se.ofIntArray(y);
    }
    return Hr.columnToArray(v, "label_seq_id", Int32Array), Hr.columnToArray(v, "auth_seq_id", Int32Array), { atoms: p, residues: v, chains: g, atomSourceIndex: h };
  }(t, e, o), u = function(f, h) {
    var m = /* @__PURE__ */ new Map();
    if (!An.is(h)) return m;
    var p = t0(xte, h.data.frame).molstar_atom_site_operator_mapping;
    if (p._rowCount === 0) return m;
    for (var v = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), y = 0; y < p._rowCount; y++) {
      var b = p.assembly_operator_id.valueKind(y) === 0 ? { id: p.assembly_id.value(y), operList: [], operId: p.assembly_operator_id.value(y) } : void 0, S = wn.create(p.operator_name.value(y), he.identity(), { assembly: b, spgrOp: p.symmetry_operator_index.valueKind(y) === 0 ? p.symmetry_operator_index.value(y) : void 0, hkl: E.ofArray(p.symmetry_hkl.value(y)), ncsId: p.ncs_id.value(y) }), _ = p.suffix.value(y), x = p.label_asym_id.value(y);
      v.set("".concat(x).concat(_), { name: x, operator: S });
      var C = p.auth_asym_id.value(y);
      g.set("".concat(C).concat(_), C);
    }
    var A = f.chains, w = A.label_asym_id, I = A.auth_asym_id, P = new Array(w.rowCount), M = new Array(w.rowCount);
    for (y = 0; y < w.rowCount; y++) if (x = w.value(y), C = I.value(y), v.has(x)) {
      var T = v.get(x), F = T.name;
      S = T.operator, m.set(y, S), P[y] = F, M[y] = g.get(C) || C;
    } else P[y] = x, M[y] = C;
    return f.chains.label_asym_id = se.ofArray({ array: P, valueKind: f.chains.label_asym_id.valueKind, schema: f.chains.label_asym_id.schema }), f.chains.auth_asym_id = se.ofArray({ array: M, valueKind: f.chains.auth_asym_id.valueKind, schema: f.chains.auth_asym_id.schema }), m;
  }(s, i);
  if (a && function(f, h) {
    return Hr.areEqual(f.chains, h.chains) && Hr.areEqual(f.residues, h.residues) && Hr.areEqual(f.atoms, h.atoms);
  }(a.atomicHierarchy, s)) return { sameAsPrevious: !0, hierarchy: a.atomicHierarchy, chainOperatorMapping: u };
  var c = { residueAtomSegments: Qt.ofOffsets(o.residues, Se.ofBounds(0, t._rowCount)), chainAtomSegments: Qt.ofOffsets(o.chains, Se.ofBounds(0, t._rowCount)) }, l = wte(s, r, c), d = function(f, h, m, p) {
    for (var v = f.atoms, g = v.label_comp_id, y = v.type_symbol, b = v._rowCount, S = f.residues._rowCount, _ = h.residueAtomSegments.offsets, x = new Uint8Array(b), C = 0; C < b; ++C) x[C] = Xm(y.value(C));
    var A = new Int32Array(S), w = new Int32Array(S), I = new Int32Array(S), P = new Uint8Array(S), M = new Uint8Array(S), T = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
    for (C = 0; C < S; ++C) {
      var N = g.value(_[C]), R = p, L = void 0, V = void 0;
      if (T.has(N)) L = T.get(N), V = F.get(N);
      else {
        var U = void 0;
        R.has(N) ? U = R.get(N).type : (AN || console.info("chemComp not found", N), U = pR(N)), V = n$(U, L = g2(U, N)), T.set(N, L), F.set(N, V);
      }
      P[C] = L, M[C] = V;
      var H = qd(V, "trace"), K = m.findAtomsOnResidue(C, H);
      if (K === -1) {
        var X = qd(V, "coarseBackbone");
        (K = m.findAtomsOnResidue(C, X)) === -1 && ex(L) && (K = m.findElementOnResidue(C, bp("C")));
      }
      A[C] = K;
      var Y = qd(V, "directionFrom");
      w[C] = m.findAtomsOnResidue(C, Y);
      var Q = qd(V, "directionTo");
      I[C] = m.findAtomsOnResidue(C, Q);
    }
    return { atom: { atomicNumber: x }, residue: { traceElementIndex: A, directionFromElementIndex: w, directionToElementIndex: I, moleculeType: P, polymerType: M } };
  }(s, c, l, n);
  return { sameAsPrevious: !1, hierarchy: O(O(O({}, s), c), { index: l, derived: d }), chainOperatorMapping: u };
}
function VR(t, e, r, n, i, a) {
  var o = Dte(t, e, r, n, i, a), s = o.sameAsPrevious, u = o.hierarchy, c = o.chainOperatorMapping, l = function(d) {
    return { id: Ki.create22(), atomId: d.id, occupancy: d.occupancy.isDefined ? d.occupancy : se.ofConst(1, d._rowCount, se.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 }) };
  }(t);
  return { sameAsPrevious: s, hierarchy: u, conformation: l, chainOperatorMapping: c };
}
var J_, AE = { chainKey: [], entityKey: [], findSequenceKey: function() {
  return -1;
}, findChainKey: function() {
  return -1;
}, getEntityFromChain: function() {
  return -1;
}, count: 0, entity_id: se.Undefined(0, se.Schema.str), asym_id: se.Undefined(0, se.Schema.str), seq_id_begin: se.Undefined(0, se.Schema.int), seq_id_end: se.Undefined(0, se.Schema.int), chainElementSegments: Qt.create([]), polymerRanges: rn.ofSortedRanges([]), gapRanges: rn.ofSortedRanges([]) };
function Ete(t, e, r) {
  if (t.has(e)) return t.get(e);
  var n = r.index++;
  return t.set(e, n), n;
}
function Ite(t, e) {
  if (t.has(e)) return t.get(e);
  var r = /* @__PURE__ */ new Map();
  return t.set(e, r), r;
}
function Tte(t) {
  throw new Error("Missing entity entry for entity id '".concat(t, "'."));
}
function wE(t, e) {
  for (var r = t.entity_id, n = t.asym_id, i = t.seq_id_begin, a = t.seq_id_end, o = t.count, s = t.chainElementSegments, u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = { index: 0 }, d = new Int32Array(o), f = new Int32Array(o), h = new Int32Array(s.count), m = 0; m < o; m++) f[m] = e.getEntityIndex(r.value(m)), f[m] < 0 && Tte(r.value(m));
  for (var p = 0; p < s.count; p++) {
    var v = s.offsets[p], g = s.offsets[p + 1], y = f[v];
    h[p] = y;
    var b = Ete(Ite(c, y), n.value(v), l);
    for (m = v; m < g; m++) d[m] = b;
    var S = [], _ = [];
    for (m = v; m < g; m++) {
      var x = i.value(m), C = a.value(m);
      S.push(m), _.push(x, C);
    }
    var A = { elementIndices: S, seqRanges: rn.ofSortedRanges(_) };
    u.set(b, A);
  }
  var w = function(P, M, T) {
    var F = P.getEntityIndex;
    return { findChainKey: function(N, R) {
      var L = F(N);
      if (L < 0) return -1;
      var V = M.get(L);
      return V.has(R) ? V.get(R) : -1;
    }, findSequenceKey: function(N, R, L) {
      var V = F(N);
      if (V < 0) return -1;
      var U = M.get(V);
      if (U === void 0) return -1;
      var H = U.get(R);
      if (H === void 0) return -1;
      var K = T.get(H), X = K.elementIndices, Y = K.seqRanges, Q = rn.firstIntersectionIndex(Y, Ge.ofSingleton(L));
      return Q !== -1 ? X[Q] : -1;
    } };
  }(e, c, u), I = w.findChainKey;
  return { chainKey: d, entityKey: f, findSequenceKey: w.findSequenceKey, findChainKey: I, getEntityFromChain: function(P) {
    return h[P];
  } };
}
function DE(t, e) {
  for (var r = [], n = [], i = Qt.transientSegments(t.chainElementSegments, Se.ofBounds(0, t.count)), a = t.seq_id_begin, o = t.seq_id_end; i.hasNext; ) for (var s = i.move(), u = s.start, c = s.end, l = -1, d = -1, f = u; f < c; ++f) {
    var h = o.value(f);
    f === u ? (l = f, d = o.value(f)) : a.value(f) - d > 1 && (r.push(l, f - 1), n.push(f - 1, f), l = f), f === c - 1 && r.push(l, f), d = h;
  }
  return { polymerRanges: rn.ofSortedRanges(r), gapRanges: rn.ofSortedRanges(n) };
}
(function(t) {
  t.Empty = { isDefined: !1, spheres: AE, gaussians: AE };
})(J_ || (J_ = {}));
var UR = { hierarchy: J_.Empty, conformation: void 0 };
function Mte(t, e) {
  var r = t.ihm_sphere_obj_site, n = t.ihm_gaussian_obj_site;
  if (r._rowCount === 0 && n._rowCount === 0) return UR;
  var i = EE(r), a = function(f) {
    return { x: f.Cartn_x.toArray({ array: Float32Array }), y: f.Cartn_y.toArray({ array: Float32Array }), z: f.Cartn_z.toArray({ array: Float32Array }), radius: f.object_radius.toArray({ array: Float32Array }), rmsf: f.rmsf.toArray({ array: Float32Array }) };
  }(r), o = wE(i, t.entities), s = DE(i), u = EE(n), c = function(f) {
    for (var h = Ho.ihm_gaussian_obj_site.covariance_matrix.space, m = [], p = f.covariance_matrix, v = 0, g = p.rowCount; v < g; v++) m[v] = Qn.toMat3(Wi(), h, p.value(v));
    return { x: f.mean_Cartn_x.toArray({ array: Float32Array }), y: f.mean_Cartn_y.toArray({ array: Float32Array }), z: f.mean_Cartn_z.toArray({ array: Float32Array }), weight: f.weight.toArray({ array: Float32Array }), covariance_matrix: m };
  }(n), l = wE(u, t.entities), d = DE(u);
  return { hierarchy: { isDefined: !0, spheres: O(O(O({}, i), o), s), gaussians: O(O(O({}, u), l), d) }, conformation: { id: Ki.create22(), spheres: a, gaussians: c } };
}
function EE(t) {
  var e = t.entity_id, r = t.seq_id_begin, n = t.seq_id_end, i = t.asym_id;
  return O({ count: e.rowCount, entity_id: e, asym_id: i, seq_id_begin: r, seq_id_end: n }, 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: Qt.ofOffsets(u, Se.ofBounds(0, a.rowCount)) };
  }(i));
}
var vm, $_, Pte = { 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" }, Bte = { DA: "A", DC: "C", DG: "G", DT: "T", DU: "U" }, Fte = { A: "A", C: "C", G: "G", T: "T", U: "U" };
function IE(t) {
  return Pte[t] || "X";
}
function TE(t) {
  return Fte[t] || "X";
}
function ME(t) {
  return Bte[t] || "X";
}
function HR(t, e, r, n) {
  if (!t.entity_poly_seq || !t.entity_poly_seq._rowCount) return $_.fromHierarchy(e, r, n);
  for (var i = t.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 f = d; d < l - 1 && a.areValuesEqual(d, d + 1); ) d++;
    d++;
    var h = a.value(f), m = se.window(s, f, d), p = se.window(o, f, d), v = e.getEntityIndex(h);
    u[v] = { entityId: h, sequence: vm.ofResidueNames(m, p) }, c.push(u[v]);
  }
  return { byEntityKey: u, sequences: c };
}
function qR(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o, s, u, c, l, d, f, h, m;
    return ye(this, function(p) {
      switch (p.label) {
        case 0:
          return i = S_(r, n - 1), a = e.label_entity_id, o = e.label_asym_id, s = e.label_seq_id, u = B6(i, a.value), t.shouldUpdate ? [4, t.update()] : [3, 2];
        case 1:
          p.sent(), p.label = 2;
        case 2:
          c = 0, l = u.length - 1, p.label = 3;
        case 3:
          if (!(c < l)) return [3, 10];
          d = B6(i, o.value, { start: u[c], end: u[c + 1] }), f = 0, h = d.length - 1, p.label = 4;
        case 4:
          return f < h ? (m = d[f], s.valueKind(m) !== 0 ? [3, 6] : (B6(i, s.value, { sort: !0, start: m, end: d[f + 1] }), t.shouldUpdate ? [4, t.update()] : [3, 6])) : [3, 7];
        case 5:
          p.sent(), p.label = 6;
        case 6:
          return f++, [3, 4];
        case 7:
          return t.shouldUpdate ? [4, t.update()] : [3, 9];
        case 8:
          p.sent(), p.label = 9;
        case 9:
          return c++, [3, 3];
        case 10:
          return function(v) {
            for (var g = 0, y = v.length; g < y; g++) if (v[g] !== g) return !1;
            return !0;
          }(i) && i.length === e._rowCount ? [2, { atom_site: e, sourceIndex: se.ofIntArray(i) }] : [2, { atom_site: Hr.view(e, e._schema, i), sourceIndex: se.ofIntArray(i) }];
      }
    });
  });
}
function PE(t, e, r, n, i) {
  var a = i.residue, o = a.polymerType, s = a.traceElementIndex, u = a.directionFromElementIndex, c = a.directionToElementIndex, l = o[t], d = o[e];
  if (l === 0 || d === 0 || s[t] === -1 || s[e] === -1) return !1;
  var f = n.findAtomsOnResidue(t, qd(l, "backboneStart")), h = n.findAtomsOnResidue(e, qd(d, "backboneEnd"));
  f !== -1 && h !== -1 || (f = n.findAtomsOnResidue(t, qd(l, "coarseBackbone")), h = n.findAtomsOnResidue(e, qd(d, "coarseBackbone")));
  var m = r.x, p = r.y, v = r.z, g = E.create(m[f], p[f], v[f]), y = E.create(m[h], p[h], v[h]), b = u[t] === -1 || c[t] === -1 || u[e] === -1 || c[e] === -1;
  return E.distance(g, y) < (b ? 10 : 3);
}
function KR(t, e, r, n) {
  for (var i, a, o, s, u = [], c = [], l = /* @__PURE__ */ new Map(), d = Qt.transientSegments(t.chainAtomSegments, Se.ofBounds(0, t.atoms._rowCount)), f = Qt.transientSegments(t.residueAtomSegments, Se.ofBounds(0, t.atoms._rowCount)), h = t.index, m = t.derived, p = t.residues.label_seq_id, v = t.chains.label_entity_id, g = m.residue, y = g.moleculeType, b = g.traceElementIndex; d.hasNext; ) {
    var S = d.move();
    f.setSegment(S), i = -1, a = -1, o = -1, s = -1;
    var _ = e.getEntityIndex(v.value(S.index)), x = n.byEntityKey[_], C = x ? x.sequence.seqId.value(x.sequence.seqId.rowCount - 1) : -1, A = t.residueAtomSegments.index[S.start], w = t.residueAtomSegments.index[S.end - 1], I = p.value(A), P = p.value(w);
    for (I === 1 && P === C && r.xyzDefined && PE(A, w, r, h, m) && (l.set(A, w), l.set(w, A)); f.hasNext; ) {
      var M = f.move(), T = M.index, F = p.value(T);
      if (ex(y[T]) && b[T] !== -1) if (s !== -1) if (F !== i + 1) u.push(s, o - 1), c.push(a, M.end - 1), s = M.start;
      else if (f.hasNext) {
        var N = t.residueAtomSegments.index[M.start], R = t.residueAtomSegments.index[o - 1];
        r.xyzDefined && !PE(N, R, r, t.index, m) && (u.push(s, o - 1), c.push(a, M.end - 1), s = M.start);
      } else u.push(s, M.end - 1);
      else s = M.start;
      else s !== -1 && (u.push(s, o - 1), s = -1);
      a = M.start, o = M.end, i = F;
    }
  }
  return { polymerRanges: rn.ofSortedRanges(u), gapRanges: rn.ofSortedRanges(c), cyclicPolymerMap: l };
}
function XR(t) {
  var e = /* @__PURE__ */ new Map();
  return function(r) {
    if (e.has(r)) return e.get(r);
    var n = t(r);
    return e.set(r, n), n;
  };
}
function Nte(t) {
  for (var e = /* @__PURE__ */ new Map(), r = function(s, u, c) {
    return "".concat(s, "|").concat(u, "|").concat(c);
  }, n = t.pdbx_unobs_or_zero_occ_residues, i = 0, a = n._rowCount; i < a; ++i) {
    var o = r(n.PDB_model_num.value(i), n.label_asym_id.value(i), n.label_seq_id.value(i));
    e.set(o, { polymer_flag: n.polymer_flag.value(i), occupancy_flag: n.occupancy_flag.value(i) });
  }
  return { has: function(s, u, c) {
    return e.has(r(s, u, c));
  }, get: function(s, u, c) {
    return e.get(r(s, u, c));
  }, size: e.size };
}
function Rte(t) {
  var e = /* @__PURE__ */ new Map();
  if (t.chem_comp._rowCount > 0) for (var r = t.chem_comp.id, n = 0, i = r.rowCount; n < i; ++n) e.set(r.value(n), Hr.getRow(t.chem_comp, n));
  else YR(t).forEach(function(a) {
    e.set(a, function(o) {
      return { formula: "", formula_weight: 0, id: o, name: o, mon_nstd_flag: $9.has(o) ? "y" : "n", pdbx_synonyms: [], type: pR(o) };
    }(a));
  });
  return e;
}
function Ote(t) {
  var e = /* @__PURE__ */ new Map();
  if (t.pdbx_chem_comp_identifier._rowCount > 0) {
    for (var r = t.pdbx_chem_comp_identifier, n = r.comp_id, i = r.type, a = r.identifier, o = 0, s = n.rowCount; o < s; ++o) if (i.value(o) === "SNFG CARBOHYDRATE SYMBOL" || i.value(o) === "SNFG CARB SYMBOL") {
      var u = a.value(o), c = VJ.get(u);
      c ? e.set(n.value(o), c) : console.warn("Unknown SNFG name '".concat(u, "'"));
    }
  }
  if (t.chem_comp._rowCount > 0) {
    var l = t.chem_comp, d = l.id;
    for (i = l.type, o = 0, s = d.rowCount; o < s; ++o) {
      var f = d.value(o);
      if (!e.has(f)) {
        var h = i.value(o);
        Jd.has(f) ? e.set(f, Jd.get(f)) : g2(h, f) === 9 && e.set(f, tR);
      }
    }
  } else {
    var m = YR(t);
    Jd.forEach(function(p, v) {
      !e.has(v) && m.has(v) && e.set(v, p);
    });
  }
  return e;
}
(function(t) {
  t.getSequenceString = function(n) {
    var i = n.code.toArray();
    return (i instanceof Array ? i : Array.from(i)).join("");
  }, t.ofResidueNames = function(n, 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 (IE(c) !== "X") return "protein";
        if (TE(c) !== "X") return "RNA";
        if (ME(c) !== "X") return "DNA";
      }
      return "generic";
    }(n);
    return new e(a, n, i);
  };
  var e = function() {
    function n(i, a, o) {
      this.kind = i, this.microHet = /* @__PURE__ */ new Map();
      for (var s = function(_, x) {
        var C;
        switch (_) {
          case "protein":
            C = IE;
            break;
          case "DNA":
            C = ME;
            break;
          case "RNA":
            C = TE;
            break;
          case "generic":
            C = function() {
              return "X";
            };
            break;
          default:
            ca();
        }
        return C;
      }(i), u = [], c = [], l = [], d = /* @__PURE__ */ new Map(), f = 0, h = /* @__PURE__ */ new Map(), m = 0, p = o.rowCount; m < p; ++m) {
        var v = o.value(m);
        if (h.has(v)) d.has(v) ? d.get(v).push(a.value(m)) : d.set(v, [c[h.get(v)], a.value(m)]);
        else {
          h.set(v, f);
          var g = a.value(m);
          c[f] = g, l[f] = v, u[f] = s(g), f += 1;
        }
      }
      var y = [];
      for (m = 0, p = f; m < p; ++m) {
        var b = d.get(l[m]);
        if (b) {
          var S = b.map(function(_) {
            var x = s(_);
            return x === "X" ? _ : x;
          });
          y[m] = "(".concat(S.join("|"), ")");
        } else y[m] = u[m] === "X" ? c[m] : u[m];
      }
      this.length = f, this.code = se.ofStringArray(u), this.compId = se.ofStringArray(c), this.seqId = se.ofIntArray(l), this.label = se.ofStringArray(y), this.microHet = d, this.indexMap = h;
    }
    return n.prototype.index = function(i) {
      return this.indexMap.get(i);
    }, n;
  }();
  t.ofSequenceRanges = function(n, i) {
    return new r("generic", n, i);
  };
  var r = function() {
    function n(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), f = this.seqIdEnd.value(c);
        d < u && (u = d), s < f && (s = f);
      }
      var h = s - u + 1;
      this.code = se.ofConst("X", h, se.Schema.str), this.label = se.ofConst("", h, se.Schema.str), this.seqId = se.ofLambda({ value: function(m) {
        return m + u + 1;
      }, rowCount: h, schema: se.Schema.int }), this.compId = se.ofConst("", h, se.Schema.str), this.length = h, this.minSeqId = u;
    }
    return n.prototype.index = function(i) {
      return i - this.minSeqId;
    }, n;
  }();
})(vm || (vm = {})), function(t) {
  var e = { byEntityKey: {}, sequences: [] };
  function r() {
    for (var o = [], s = 0; s < arguments.length; s++) o[s] = arguments[s];
    for (var u = [], c = {}, l = 0, d = o.length; l < d; ++l) u.push.apply(u, o[l].sequences), Object.assign(c, o[l].byEntityKey);
    return { sequences: u, byEntityKey: c };
  }
  function n(o, s) {
    var u = s.atoms.label_comp_id, c = s.residues.label_seq_id, l = s.chainAtomSegments, d = s.residueAtomSegments, f = l.count, h = l.offsets, m = {}, p = [];
    if (f === 1 && h[0] === 0 && h[1] === 0) return { byEntityKey: m, sequences: p };
    for (var v = 0, g = s.chains._rowCount; v < g; v++) {
      var y = s.index.getEntityFromChain(v);
      if (m[y] === void 0 && o.data.type.value(y) === "polymer") {
        var b = v;
        for (v++; v < g && y === s.index.getEntityFromChain(v) && o.data.type.value(y) !== "polymer"; ) v++;
        v--;
        for (var S = d.index[h[b]], _ = d.index[h[v + 1] - 1] + 1, x = se.window(c, S, _), C = [], A = S; A < _; ++A) C.push(u.value(d.offsets[A]));
        var w = se.ofStringArray(C);
        m[y] = { entityId: o.data.id.value(y), sequence: vm.ofResidueNames(w, x) }, p.push(m[y]);
      }
    }
    return { byEntityKey: m, sequences: p };
  }
  function i(o, s) {
    return r(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, f = u.offsets, h = {}, m = [];
    if (d === 1 && f[0] === 0 && f[1] === 0) return { byEntityKey: h, sequences: m };
    for (var p = 0, v = d; p < v; p++) {
      var g = s.getEntityFromChain(p);
      if (h[g] === void 0) {
        var y = p;
        for (p++; p < v && g === s.getEntityFromChain(p); ) p++;
        p--;
        var b = f[y], S = f[p + 1] - 1, _ = se.window(c, b, S), x = se.window(l, b, S);
        h[g] = { entityId: o.data.id.value(g), sequence: vm.ofSequenceRanges(_, x) }, m.push(h[g]);
      }
    }
    return { byEntityKey: h, sequences: m };
  }
  t.fromHierarchy = function(o, s, u) {
    return r(n(o, s), u.isDefined ? i(o, u) : e);
  }, t.fromAtomicHierarchy = n, t.fromCoarseHierarchy = i, t.fromCoarseElements = a;
}($_ || ($_ = {}));
var YR = XR(function(t) {
  for (var e = /* @__PURE__ */ new Set(), r = t.atom_site, n = r.label_comp_id, i = r.auth_comp_id, a = n.isDefined ? n : i, o = 0, s = a.rowCount; o < s; ++o) e.add(a.value(o));
  return e;
});
function WR(t, e) {
  for (var r = /* @__PURE__ */ new Map(), n = t.chains, i = n.auth_asym_id, a = n.label_asym_id, o = n.label_entity_id, s = 0, u = t.chains._rowCount; s < u; s++) {
    var c = a.value(s);
    r.set(c, { id: c, auth_id: i.value(s), entity_id: o.value(s) });
  }
  if (e != null && e.struct_asym._rowCount) for (var l = e.struct_asym, d = (c = l.id, l.entity_id), f = (s = 0, c.rowCount); s < f; ++s) {
    var h = c.value(s);
    r.has(h) || r.set(h, { id: h, auth_id: "", entity_id: d.value(s) });
  }
  return r;
}
var Lte = se.Schema.Aliased(se.Schema.Str(""));
function jR(t) {
  var e;
  if (t.entity.id.isDefined) e = t.entity;
  else {
    for (var r = /* @__PURE__ */ new Set(), n = [], i = [], a = t.atom_site, o = a.label_entity_id, s = a.label_comp_id, u = 0, c = t.atom_site._rowCount; u < c; u++) {
      var l = o.value(u);
      r.has(l) || (n.push(l), i.push(i$(s.value(u))), r.add(l));
    }
    var d = t.ihm_sphere_obj_site.entity_id;
    for (u = 0, c = t.ihm_sphere_obj_site._rowCount; u < c; u++)
      l = d.value(u), r.has(l) || (n.push(l), i.push("polymer"), r.add(l));
    var f = t.ihm_gaussian_obj_site.entity_id;
    for (u = 0, c = t.ihm_gaussian_obj_site._rowCount; u < c; u++)
      l = f.value(u), r.has(l) || (n.push(l), i.push("polymer"), r.add(l));
    e = Hr.ofPartialColumns(Ho.entity, { id: se.ofArray({ array: n, schema: Ho.entity.id }), type: se.ofArray({ array: i, schema: Ho.entity.type }) }, n.length);
  }
  var h = se.createIndexer(e.id), m = new Array(e._rowCount);
  m.fill("other");
  var p = /* @__PURE__ */ new Set(), v = !1;
  if (t.entity_poly && t.entity_poly.type.isDefined) {
    var g = t.entity_poly, y = g.entity_id, b = g.type, S = g._rowCount;
    for (u = 0; u < S; ++u)
      m[h(l = y.value(u))] = b.value(u), p.add(l);
  } else v = !0;
  if (t.pdbx_entity_branch && t.pdbx_entity_branch.entity_id.isDefined) {
    var _ = t.pdbx_entity_branch;
    for (y = _.entity_id, b = _.type, S = _._rowCount, u = 0; u < S; ++u)
      m[h(l = y.value(u))] = b.value(u), p.add(l);
  } else v = !0;
  if (p.size < m.length && (v = !0), v) {
    var x = /* @__PURE__ */ new Map();
    if (t.chem_comp) {
      var C = t.chem_comp, A = C.id;
      for (b = C.type, u = 0, c = t.chem_comp._rowCount; u < c; u++) x.set(A.value(u), b.value(u));
    }
    if (t.atom_site) {
      var w = t.atom_site;
      for (o = w.label_entity_id, s = w.label_comp_id, u = 0, c = t.atom_site._rowCount; u < c; u++)
        if (l = o.value(u), !p.has(l)) {
          var I = s.value(u), P = x.get(I) || "";
          m[h(l)] = a$(I, P), p.add(l);
        }
    }
  }
  return { data: e, subtype: se.ofArray({ array: m, schema: Lte }), getEntityIndex: h };
}
function ZR(t, e, r) {
  var n;
  if (!t.pdbx_molecule || !t.pdbx_molecule.prd_id.isDefined) return e;
  var i = new Array(e.data._rowCount);
  i.fill("");
  for (var a = t.pdbx_molecule, o = a.asym_id, s = a.prd_id, u = a._rowCount, c = 0; c < u; ++c) {
    var l = o.value(c), d = (n = r.get(l)) === null || n === void 0 ? void 0 : n.entity_id;
    d !== void 0 && (i[e.getEntityIndex(d)] = s.value(c));
  }
  var f = se.ofArray({ array: i, schema: se.Schema.str });
  return O(O({}, e), { prd_id: f });
}
var pn, BE, Ym = function() {
  function t(e) {
    this.frames = e, this.frameCount = e.length, this.representative = e[0], this.duration = e.length;
  }
  return t.prototype.getFrameAtIndex = function(e) {
    return this.frames[e];
  }, t;
}();
function Pl(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return n = function(u, c) {
            return { missingResidues: Nte(u), chemicalComponentMap: Rte(u), saccharideComponentMap: Ote(u) };
          }(t), t.ihm_model_list._rowCount > 0 ? [4, Gte(r, t, n, e)] : [3, 2];
        case 1:
          return a = s.sent(), [3, 4];
        case 2:
          return [4, kte(r, t, n, e)];
        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 Ym(i)];
      }
    });
  });
}
function QR(t, e) {
  var r = t.rowCount;
  if (!t.isDefined) return r;
  for (var n = e + 1; n < r && t.areValuesEqual(e, n); ) n++;
  return n;
}
function kte(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o, s, u, c, l, d, f;
    return ye(this, function(h) {
      switch (h.label) {
        case 0:
          if (i = [], !e.atom_site) return [3, 3];
          a = e.atom_site.id.rowCount, o = jR(e), s = 0, h.label = 1;
        case 1:
          return s < a ? (u = QR(e.atom_site.pdbx_PDB_model_num, s), [4, qR(t, e.atom_site, s, u)]) : [3, 3];
        case 2:
          return c = h.sent(), l = c.atom_site, d = c.sourceIndex, f = function(m, p, v, g, y, b, S) {
            var _ = VR(p, v, g, y.chemicalComponentMap, b, S), x = p.pdbx_PDB_model_num.value(0);
            if (S && _.sameAsPrevious) return O(O({}, S), { id: Ki.create22(), modelNum: x, atomicConformation: _.conformation, _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
            var C = UR, A = HR(m, g, _.hierarchy, C.hierarchy), w = KR(_.hierarchy, g, _.conformation, A), I = WR(_.hierarchy), P = m.entry.id.valueKind(0) === 0 ? m.entry.id.value(0) : b.name, M = [];
            return P && M.push(P), m.struct.title.valueKind(0) === 0 && M.push(m.struct.title.value(0)), { id: Ki.create22(), entryId: P, label: M.join(" | "), entry: P, sourceData: b, modelNum: x, parent: void 0, entities: ZR(m, g, I), sequence: A, atomicHierarchy: _.hierarchy, atomicConformation: _.conformation, atomicRanges: w, atomicChainOperatorMappinng: _.chainOperatorMapping, coarseHierarchy: C.hierarchy, coarseConformation: C.conformation, properties: O(O({}, y), { structAsymMap: I }), customProperties: new jp(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) };
          }(e, l, d, o, r, n, i.length > 0 ? i[i.length - 1] : void 0), i.push(f), s = u, [3, 1];
        case 3:
          return [2, i];
      }
    });
  });
}
function cb(t, e) {
  for (var r = /* @__PURE__ */ new Map(), n = t._rowCount, i = 0; i < n; ) {
    var a = QR(e, i), o = e.value(i);
    r.set(o, { table: Hr.window(t, t._schema, i, a), start: i, end: a }), i = a;
  }
  return r;
}
function Gte(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x;
    return ye(this, function(C) {
      switch (C.label) {
        case 0:
          if (i = jR(e), a = e.atom_site.ihm_model_id.isDefined ? e.atom_site.ihm_model_id : e.atom_site.pdbx_PDB_model_num, o = cb(e.atom_site, a), s = cb(e.ihm_sphere_obj_site, e.ihm_sphere_obj_site.model_id), u = cb(e.ihm_gaussian_obj_site, e.ihm_gaussian_obj_site.model_id), c = [], !e.ihm_model_list) return [3, 6];
          l = e.ihm_model_list, d = l.model_id, f = l.model_name, h = 0, C.label = 1;
        case 1:
          return h < e.ihm_model_list._rowCount ? (m = d.value(h), p = void 0, v = void 0, o.has(m) ? (g = o.get(m), [4, qR(t, e.atom_site, g.start, g.end)]) : [3, 3]) : [3, 6];
        case 2:
          return y = C.sent(), b = y.atom_site, S = y.sourceIndex, p = b, v = S, [3, 4];
        case 3:
          p = Hr.window(e.atom_site, e.atom_site._schema, 0, 0), v = se.ofIntArray([]), C.label = 4;
        case 4:
          _ = { model_id: m, model_name: f.value(h), model_group_name: Iee(m, e), entities: i, atom_site: p, atom_site_sourceIndex: v, ihm_sphere_obj_site: s.has(m) ? s.get(m).table : Hr.window(e.ihm_sphere_obj_site, e.ihm_sphere_obj_site._schema, 0, 0), ihm_gaussian_obj_site: u.has(m) ? u.get(m).table : Hr.window(e.ihm_gaussian_obj_site, e.ihm_gaussian_obj_site._schema, 0, 0) }, x = function(A, w, I, P) {
            var M = VR(w.atom_site, w.atom_site_sourceIndex, w.entities, I.chemicalComponentMap, P), T = Mte(w, I.chemicalComponentMap), F = HR(A, w.entities, M.hierarchy, T.hierarchy), N = KR(M.hierarchy, w.entities, M.conformation, F), R = A.entry.id.valueKind(0) === 0 ? A.entry.id.value(0) : P.name, L = [];
            R && L.push(R), A.struct.title.valueKind(0) === 0 && L.push(A.struct.title.value(0)), w.model_name && L.push(w.model_name), w.model_group_name && L.push(w.model_group_name);
            var V = WR(M.hierarchy, A);
            return { id: Ki.create22(), entryId: R, label: L.join(" | "), entry: R, sourceData: P, modelNum: w.model_id, parent: void 0, entities: ZR(A, w.entities, V), sequence: F, atomicHierarchy: M.hierarchy, atomicConformation: M.conformation, atomicRanges: N, atomicChainOperatorMappinng: M.chainOperatorMapping, coarseHierarchy: T.hierarchy, coarseConformation: T.conformation, properties: O(O({}, I), { structAsymMap: V }), customProperties: new jp(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) };
          }(e, _, r, n), c.push(x), C.label = 5;
        case 5:
          return h++, [3, 1];
        case 6:
          return [2, c];
      }
    });
  });
}
function lb(t) {
  for (var e = /* @__PURE__ */ new Map(), r = 0, n = t.length; r < n; r++) e.set(r, t[r]);
  return e;
}
(function(t) {
  function e(g, y) {
    for (var b = [], S = y.frames, _ = g.atomicHierarchy.atomSourceIndex, x = se.isIdentity(_) ? void 0 : _.toArray({ array: Int32Array }), C = u(g), A = 0, w = S.length; A < w; ++A) {
      var I = S[A], P = O(O({}, g), { id: Ki.create22(), modelNum: A, atomicConformation: I3.getAtomicConformation(I, g.atomicConformation.atomId, x), customProperties: new jp(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
      if (I.cell) {
        var M = Da.fromCell(I.cell.size, I.cell.anglesInRadians);
        Da.Provider.set(P, M);
      }
      t.TrajectoryInfo.set(P, { index: A, size: S.length }), t.CoarseGrained.set(P, C), b.push(P);
    }
    return { trajectory: b, srcIndexArray: x };
  }
  t.trajectoryFromModelAndCoordinates = function(g, y) {
    return new Ym(e(g, y).trajectory);
  }, t.trajectoryFromTopologyAndCoordinates = function(g, y) {
    var b = this;
    return tr.create("Create Trajectory", function(S) {
      return _e(b, 0, void 0, function() {
        var _, x, C, A, w, I, P, M, T, F;
        return ye(this, function(N) {
          switch (N.label) {
            case 0:
              return [4, Pl(g.basic, g.sourceData, S)];
            case 1:
              if ((_ = N.sent()).frameCount === 0) throw new Error("found no model");
              for (x = _.representative, C = e(x, y).trajectory, A = { pairs: g.bonds, count: x.atomicHierarchy.atoms._rowCount }, w = Xi.fromData(A), I = u(x), P = 0, M = 0, T = C; M < T.length; M++) F = T[M], Xi.Provider.set(F, w), t.TrajectoryInfo.set(F, { index: P++, size: C.length }), t.CoarseGrained.set(F, I);
              return [2, new Ym(C)];
          }
        });
      });
    });
  };
  var r = "__Center__";
  t.getCenter = function(g) {
    if (g._dynamicPropertyData[r]) return g._dynamicPropertyData[r];
    var y = function(b, S) {
      var _ = [], x = [], C = [];
      b.x.length && (_.push.apply(_, os(b.x)), x.push.apply(x, os(b.y)), C.push.apply(C, os(b.z))), S && (S.spheres.x.length && (_.push.apply(_, os(S.spheres.x)), x.push.apply(x, os(S.spheres.y)), C.push.apply(C, os(S.spheres.z))), S.gaussians.x.length && (_.push.apply(_, os(S.gaussians.x)), x.push.apply(x, os(S.gaussians.y)), C.push.apply(C, os(S.gaussians.z))));
      var A = os(_), w = A[0], I = A[1], P = os(x), M = P[0], T = P[1], F = os(C), N = F[0], R = w + (I - w) / 2, L = M + (T - M) / 2, V = N + (F[1] - N) / 2;
      return E.create(R, L, V);
    }(g.atomicConformation, g.coarseConformation);
    return g._dynamicPropertyData[r] = y, y;
  };
  var n = "__InvertedAtomSrcIndex__";
  t.getInvertedAtomSourceIndex = function(g) {
    if (g._staticPropertyData[n]) return g._staticPropertyData[n];
    var y = function(b) {
      for (var S = new Int32Array(b.rowCount), _ = !1, x = 0, C = b.rowCount; x < C; x++) {
        var A = b.value(x);
        A !== x && (_ = !1), S[A] = x;
      }
      return { isIdentity: _, invertedIndex: S };
    }(g.atomicHierarchy.atomSourceIndex);
    return g._staticPropertyData[n] = y, y;
  };
  var i = "__TrajectoryInfo__";
  t.TrajectoryInfo = { get: function(g) {
    return g._dynamicPropertyData[i] || { index: 0, size: 1 };
  }, set: function(g, y) {
    return g._dynamicPropertyData[i] = y;
  } };
  var a = "__AsymIdCount__";
  t.AsymIdCount = { get: function(g) {
    if (g._dynamicPropertyData[a]) return g._dynamicPropertyData[a];
    var y = function(b) {
      var S = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set();
      return b.properties.structAsymMap.forEach(function(x, C) {
        var A = x.auth_id;
        S.add(A), _.add(C);
      }), { auth: S.size, label: _.size };
    }(g);
    return g._dynamicPropertyData[a] = y, y;
  } }, t.AsymIdOffset = fp.createSimple("asym_id_offset", "static"), t.Index = fp.createSimple("index", "static"), t.getRoot = function(g) {
    return g.parent || g;
  }, t.areHierarchiesEqual = function(g, y) {
    return g.atomicHierarchy === y.atomicHierarchy && g.coarseHierarchy === y.coarseHierarchy;
  };
  var o = "__CoordinatesHistory__";
  t.CoordinatesHistory = { get: function(g) {
    return g._staticPropertyData[o];
  }, set: function(g, y) {
    return g._staticPropertyData[o] = y;
  } };
  var s = "__CoarseGrained__";
  function u(g) {
    var y = t.CoarseGrained.get(g);
    if (y === void 0) {
      for (var b = 0, S = g.atomicHierarchy.derived.residue.polymerType, _ = 0; _ < S.length; ++_) S[_] !== 0 && (b += 1);
      var x = !1, C = !1, A = g.atomicHierarchy.atoms, w = A.label_atom_id, I = A._rowCount;
      for (_ = 0; _ < I; ++_) {
        var P = w.value(_);
        if (x || P !== "BB" || (x = !0), C || P !== "SC1" || (C = !0), x && C) break;
      }
      y = x && C || !(!b || !I) && I / b < 3, t.CoarseGrained.set(g, y);
    }
    return y;
  }
  function c(g) {
    return !!An.is(g.sourceData) && (g.entryId.match(/^[1-9][a-z0-9]{3,3}$/i) !== null || g.entryId.match(/^pdb_[0-9]{4,4}[1-9][a-z0-9]{3,3}$/i) !== null);
  }
  t.CoarseGrained = { get: function(g) {
    return g._staticPropertyData[s];
  }, set: function(g, y) {
    return g._staticPropertyData[s] = y;
  } }, t.isCoarseGrained = u, t.isMaterial = function(g) {
    var y, b;
    return !!(!((b = (y = g.sourceData) === null || y === void 0 ? void 0 : y.data) === null || b === void 0) && b.isMaterial);
  }, t.isMaterialCrystal = function(g) {
    var y, b, S, _ = (y = g.sourceData) === null || y === void 0 ? void 0 : y.data;
    return !(_ != null && _.isMaterial) && !!(!((S = (b = _ == null ? void 0 : _.molecules) === null || b === void 0 ? void 0 : b[0]) === null || S === void 0) && S.cell);
  }, t.hasCarbohydrate = function(g) {
    return g.properties.saccharideComponentMap.size > 0;
  }, t.hasProtein = function(g) {
    for (var y = g.entities.subtype, b = 0, S = y.rowCount; b < S; ++b) if (y.value(b).startsWith("polypeptide")) return !0;
    return !1;
  }, t.hasNucleic = function(g) {
    for (var y = g.entities.subtype, b = 0, S = y.rowCount; b < S; ++b) {
      var _ = y.value(b);
      if (_.endsWith("ribonucleotide hybrid") || _.endsWith("ribonucleotide")) return !0;
    }
    return !1;
  }, t.isFromPdbArchive = function(g) {
    if (!An.is(g.sourceData)) return !1;
    for (var y = g.sourceData.data.db, b = 0, S = y.database_2.database_id.rowCount; b < S; ++b) if (y.database_2.database_id.value(b) === "PDB") return !0;
    return !1;
  }, t.hasPdbId = c, t.hasSecondaryStructure = function(g) {
    if (!An.is(g.sourceData)) return !1;
    var y = g.sourceData.data.db;
    return y.struct_conf.id.isDefined || y.struct_sheet_range.id.isDefined;
  };
  var l = E.create(1.5707963, 1.5707963, 1.5707963), d = E.create(1, 1, 1);
  function f(g) {
    if (!An.is(g.sourceData)) return !1;
    for (var y = g.sourceData.data.db, b = 0; b < y.exptl.method.rowCount; b++)
      if (y.exptl.method.value(b).toUpperCase().indexOf("DIFFRACTION") >= 0) return !0;
    return !1;
  }
  function h(g) {
    if (!An.is(g.sourceData)) return !1;
    for (var y = g.sourceData.data.db, b = 0; b < y.exptl.method.rowCount; b++)
      if (y.exptl.method.value(b).toUpperCase().indexOf("MICROSCOPY") >= 0) return !0;
    return !1;
  }
  function m(g) {
    if (!An.is(g.sourceData) || !f(g)) return !1;
    var y = g.sourceData.data.db.pdbx_database_status.status_code_sf;
    return y.isDefined && y.value(0) === "REL";
  }
  function p(g) {
    if (!An.is(g.sourceData)) return !1;
    for (var y = g.sourceData.data.db, b = y.pdbx_database_related, S = b.db_name, _ = b.content_type, x = 0, C = y.pdbx_database_related._rowCount; x < C; ++x) if (S.value(x).toUpperCase() === "EMDB" && _.value(x) === "associated EM volume") return !0;
    return !1;
  }
  function v(g) {
    return !!An.is(g.sourceData) && (m(g) || p(g));
  }
  t.hasCrystalSymmetry = function(g) {
    var y, b = (y = Da.Provider.get(g)) === null || y === void 0 ? void 0 : y.spacegroup;
    return !(!b || b.num === 1 && E.equals(b.cell.anglesInRadians, l) && E.equals(b.cell.size, d));
  }, t.isFromXray = f, t.isFromEm = h, t.isFromNmr = function(g) {
    if (!An.is(g.sourceData)) return !1;
    for (var y = g.sourceData.data.db, b = 0; b < y.exptl.method.rowCount; b++)
      if (y.exptl.method.value(b).toUpperCase().indexOf("NMR") >= 0) return !0;
    return !1;
  }, t.hasXrayMap = m, t.hasEmMap = p, t.hasDensityMap = v, t.probablyHasDensityMap = function(g) {
    if (!An.is(g.sourceData)) return !1;
    var y = g.sourceData.data.db;
    return v(g) || c(g) && (!y.exptl.method.isDefined || f(g) && (!y.pdbx_database_status.status_code_sf.isDefined || y.pdbx_database_status.status_code_sf.valueKind(0) === 2) || h(g) && !y.pdbx_database_related.db_name.isDefined);
  };
})(pn || (pn = {})), function(t) {
  t.getCifDataSource = function(n, i, a) {
    if (!i) return { rowCount: 0 };
    if (a && a[i.id]) return a[i.id];
    var o = i.getElements(n), s = { data: o, rowCount: o.elements.length };
    return a && (a[i.id] = s), s;
  }, t.fromAtomMap = function(n) {
    return new FE(n);
  }, t.fromAtomArray = function(n) {
    return new FE(lb(n));
  };
  var e = function(n) {
    return n.atomicHierarchy.residueAtomSegments;
  };
  t.fromResidueMap = function(n) {
    return new $g("residue", n, e, 0);
  }, t.fromResidueArray = function(n) {
    return new $g("residue", lb(n), e, 0);
  };
  var r = function(n) {
    return n.atomicHierarchy.chainAtomSegments;
  };
  t.fromChainMap = function(n) {
    return new $g("chain", n, r, 0);
  }, t.fromChainArray = function(n) {
    return new $g("chain", lb(n), r, 0);
  }, t.fromEntityMap = function(n) {
    return new zte(n);
  };
}(BE || (BE = {}));
var $g = function() {
  function t(e, r, n, i) {
    this.level = e, this.map = r, this.segmentGetter = n, this.id = Ki.create22(), this.kind = i;
  }
  return t.prototype.has = function(e) {
    return this.map.has(e);
  }, t.prototype.get = function(e) {
    return this.map.get(e);
  }, t.prototype.getStructureElements = function(e) {
    var r = e.models;
    if (r.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var n = /* @__PURE__ */ new Set(), i = e.unitSymmetryGroups, a = [], o = this.segmentGetter(r[0]), s = 0, u = i; s < u.length; s++) {
      var c = u[s].units[0];
      if (c.kind === this.kind) for (var l = Qt.transientSegments(o, c.elements); l.hasNext; ) {
        var d = l.move();
        this.has(d.index) && !n.has(d.index) && (n.add(d.index), a[a.length] = at.create(e, c, c.elements[d.start]));
      }
    }
    return a.sort(function(f, h) {
      return f.element - h.element;
    }), a;
  }, t.prototype.getElements = function(e) {
    var r = this, n = this.segmentGetter(e.model).index, i = this.getStructureElements(e);
    return { elements: i, property: function(a) {
      return r.get(n[i[a].element]);
    } };
  }, t;
}(), FE = function() {
  function t(e) {
    this.map = e, this.id = Ki.create22(), this.level = "atom", this.kind = 0;
  }
  return t.prototype.has = function(e) {
    return this.map.has(e);
  }, t.prototype.get = function(e) {
    return this.map.get(e);
  }, t.prototype.getStructureElements = function(e) {
    if (e.models.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var r = /* @__PURE__ */ new Set(), n = [], i = 0, a = e.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) && !r.has(l) && (r.add(s[u]), n[n.length] = at.create(e, o, l));
      }
    }
    return n.sort(function(d, f) {
      return d.element - f.element;
    }), n;
  }, t.prototype.getElements = function(e) {
    var r = this, n = this.getStructureElements(e);
    return { elements: n, property: function(i) {
      return r.get(n[i].element);
    } };
  }, t;
}(), zte = function() {
  function t(e) {
    this.map = e, this.id = Ki.create22(), this.level = "entity", this.kind = 0;
  }
  return t.prototype.has = function(e) {
    return this.map.has(e);
  }, t.prototype.get = function(e) {
    return this.map.get(e);
  }, t.prototype.getStructureElements = function(e) {
    var r = e.models;
    if (r.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var n = r[0].atomicHierarchy.index, i = /* @__PURE__ */ new Set(), a = e.unitSymmetryGroups, o = [], s = r[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 = Qt.transientSegments(s, l.elements); d.hasNext; ) {
        var f = d.move(), h = n.getEntityFromChain(f.index);
        this.has(h) && !i.has(h) && (i.add(h), o[o.length] = at.create(e, l, l.elements[f.start]));
      }
    }
    return o.sort(function(m, p) {
      return m.element - p.element;
    }), o;
  }, t.prototype.getElements = function(e) {
    var r = this, n = this.getStructureElements(e), i = e.model.atomicHierarchy.chainAtomSegments.index, a = e.model.atomicHierarchy.index;
    return { elements: n, property: function(o) {
      return r.get(a.getEntityFromChain(i[n[o].element]));
    } };
  }, t;
}(), ev = qe(13421772), NE = {}, Vte = { name: "carbohydrate-symbol", label: "Carbohydrate Symbol", category: "Residue Property", factory: function t(e, r) {
  var n;
  if (e.structure) {
    var i = e.structure.carbohydrates, a = i.elements, o = i.getElementIndices, s = function(u, c) {
      if (!Fe.isAtomic(u)) return ev;
      var l = o(u, c);
      return l.length > 0 ? a[l[0]].component.color : ev;
    };
    n = function(u, c) {
      return c ? yt.Secondary : at.is(u) ? s(u.unit, u.element) : Dt.isLocation(u) ? s(u.aUnit, u.aUnit.elements[u.aIndex]) : ev;
    };
  } else n = function() {
    return ev;
  };
  return { factory: t, granularity: "group", color: n, props: r, description: "Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).", legend: zu(UJ) };
}, getParams: function(t) {
  return NE;
}, defaultValues: z.getDefaultValues(NE), isApplicable: function(t) {
  return !!t.structure && t.structure.models.some(function(e) {
    return pn.hasCarbohydrate(e);
  });
} }, JR = qe(14539007), Ute = "Gives everything the same, uniform color.", V3 = { value: z.Color(JR) };
function y2(t, e) {
  var r = Ui(e.value, JR);
  return { factory: y2, granularity: "uniform", color: function() {
    return r;
  }, props: e, description: Ute, legend: zu([["uniform", r]]) };
}
var Hte = { name: "uniform", label: "Uniform", category: "Miscellaneous", factory: y2, getParams: function(t) {
  return V3;
}, defaultValues: z.getDefaultValues(V3), isApplicable: function(t) {
  return !0;
} }, RE = { value: z.Numeric(1, { min: 0, max: 20, step: 0.1 }) };
function nx(t, e) {
  var r = e.value;
  return { factory: nx, granularity: "uniform", size: function() {
    return r;
  }, props: e, description: "Gives everything the same, uniform size." };
}
var qte = { name: "uniform", label: "Uniform", category: "", factory: nx, getParams: function(t) {
  return RE;
}, defaultValues: z.getDefaultValues(RE), isApplicable: function(t) {
  return !0;
} }, OE = { scale: z.Numeric(1, { min: 0.1, max: 5, step: 0.1 }) };
function db(t, e) {
  return Fe.isAtomic(t) ? Gy(t.model.atomicHierarchy.atoms.type_symbol.value(e)) : Fe.isSpheres(t) ? t.model.coarseConformation.spheres.radius[e] : 0;
}
var Kte = { name: "physical", label: "Physical", category: "", factory: function t(e, r) {
  var n = r.scale === void 0 ? 1 : r.scale;
  return { factory: t, granularity: "group", size: function(i) {
    return at.is(i) ? n * db(i.unit, i.element) : Dt.isLocation(i) ? n * Math.min(db(i.aUnit, i.aUnit.elements[i.aIndex]), db(i.bUnit, i.bUnit.elements[i.bIndex])) : 1 * n;
  }, props: r, description: "Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres." };
}, getParams: function(t) {
  return OE;
}, defaultValues: z.getDefaultValues(OE), isApplicable: function(t) {
  return !!t.structure;
} }, Go = E();
function wp(t, e, r, n) {
  for (var i = 0, a = 3 * n; i < a; i += 3) E.fromArray(Go, e, r + i), E.transformMat4(Go, Go, t), E.toArray(Go, e, r + i);
}
var LE = E(), fb = E(), kE = E(), Os = E(), GE = E();
function $R(t, e, r, n, i) {
  for (var a = 0, o = 3 * i; a < o; a += 3) {
    var s = 3 * e[a], u = 3 * e[a + 1], c = 3 * e[a + 2];
    E.fromArray(LE, t, s), E.fromArray(fb, t, u), E.fromArray(kE, t, c), E.sub(Os, kE, fb), E.sub(GE, LE, fb), E.cross(Os, Os, GE), r[s] += Os[0], r[s + 1] += Os[1], r[s + 2] += Os[2], r[u] += Os[0], r[u + 1] += Os[1], r[u + 2] += Os[2], r[c] += Os[0], r[c + 1] += Os[1], r[c + 2] += Os[2];
  }
  return function(l, d) {
    for (var f = 0, h = 3 * d; f < h; f += 3) {
      var m = l[f], p = l[f + 1], v = l[f + 2], g = 1 / Math.sqrt(m * m + p * p + v * v);
      l[f] = m * g, l[f + 1] = p * g, l[f + 2] = v * g;
    }
    return l;
  }(r, n);
}
function $p(t, e, r) {
  r === void 0 && (r = 1);
  for (var n = w3(t), i = new Int32Array(n + 2), a = new Int32Array(e), o = new Int32Array(e), s = 0, u = e * r; s < u; s += r) ++o[t[s]];
  var c = 0;
  for (s = 0; s < e; s++) i[s] = c, c += o[s];
  i[e] = c;
  var l = new Int32Array(c);
  for (s = 0, u = e * r; s < u; s += r) {
    var d = t[s];
    l[i[d] + a[d]] = s, ++a[d];
  }
  return { indices: l, offsets: i };
}
function qi(t, e, r, n) {
  var i = function(u, c) {
    u = Math.max(u, 2);
    var l = Math.sqrt(u), d = Math.ceil(l), f = (d += (c - d % c) % c) > 0 ? Math.ceil(u / d) : 0;
    return { width: d, height: f, length: d * f * c };
  }(t, e), a = i.length, o = i.width, s = i.height;
  return { array: n = n && n.length >= a ? n : new r(a), width: o, height: s };
}
var js = E(), Xte = new cu("14"), Yte = new cu("98");
function eO(t) {
  return t > 1e5 ? Xte : Yte;
}
function of(t, e, r) {
  var n = 3 * r, i = eO(e);
  i.reset();
  for (var a = 0, o = 3 * e; a < o; a += n) E.fromArray(js, t, a), i.includePosition(js);
  for (i.finishedIncludeStep(), a = 0, o = 3 * e; a < o; a += n) E.fromArray(js, t, a), i.radiusPosition(js);
  var s = i.getSphere();
  if (e <= 98) {
    var u = [];
    for (a = 0, o = 3 * e; a < o; a += n) u.push(E.fromArray(E(), t, a));
    Me.setExtrema(s, u);
  }
  return s;
}
var pb = he();
function aa(t, e, r) {
  if (r === 1) {
    he.fromArray(pb, e, 0);
    var n = Me.clone(t);
    return he.isIdentity(pb) ? n : Me.transform(n, n, pb);
  }
  var i = eO(r);
  i.reset();
  var a = t.center, o = t.radius, s = t.extrema;
  if (s && r < 50) {
    for (var u = 0, c = r; u < c; ++u) for (var l = 0, d = s; l < d.length; l++) {
      var f = d[l];
      E.transformMat4Offset(js, f, e, 0, 0, 16 * u), i.includePosition(js);
    }
    for (i.finishedIncludeStep(), u = 0, c = r; u < c; ++u) for (var h = 0, m = s; h < m.length; h++)
      f = m[h], E.transformMat4Offset(js, f, e, 0, 0, 16 * u), i.radiusPosition(js);
  } else {
    for (u = 0, c = r; u < c; ++u) E.transformMat4Offset(js, a, e, 0, 0, 16 * u), i.includePositionRadius(js, o);
    for (i.finishedIncludeStep(), u = 0, c = r; u < c; ++u) E.transformMat4Offset(js, a, e, 0, 0, 16 * u), i.radiusPositionRadius(js, o);
  }
  return i.getSphere();
}
var Fa = new Uint8Array(772);
function tO(t, e) {
  if (e === 0) return 0;
  var r = new Uint32Array(t.buffer, 0, t.buffer.byteLength >> 2), n = e - 4 >> 2, i = 4 * n, a = 0;
  if (n < 0) for (var o = 0; o < e; ++o) a += t[o] && 1;
  else {
    for (o = 0; o < n; ++o) {
      var s = r[o];
      a += Fa[65535 & s] + Fa[s >> 16];
    }
    for (o = i; o < e; ++o) a += t[o] && 1;
  }
  return a / e;
}
function ou(t, e) {
  var r = qi(Math.max(1, t), 1, Uint8Array, e && e.tMarker.ref.value.array), n = tO(r.array, t), i = n === 0 ? 0 : -1;
  return e ? (G.updateIfChanged(e.uMarker, 0), G.update(e.tMarker, r), G.update(e.uMarkerTexDim, ze.create(r.width, r.height)), G.updateIfChanged(e.markerAverage, n), G.updateIfChanged(e.markerStatus, i), e) : { uMarker: G.create(0), tMarker: G.create(r), uMarkerTexDim: G.create(ze.create(r.width, r.height)), markerAverage: G.create(n), markerStatus: G.create(i) };
}
Fa[1] = 1, Fa[2] = 1, Fa[3] = 1, Fa[256] = 1, Fa[512] = 1, Fa[768] = 1, Fa[257] = 2, Fa[513] = 2, Fa[769] = 2, Fa[258] = 2, Fa[514] = 2, Fa[770] = 2, Fa[259] = 2, Fa[515] = 2, Fa[771] = 2;
var Sc = { kind: "null-location" };
function gi(t, e, r, n, i, a) {
  if (i === void 0 && (i = !1), a === void 0 && (a = function() {
    return !1;
  }), t % r != 0) throw new Error("incompatible groupCount and stride");
  var o = { location: Sc, index: 0, groupIndex: 0, instanceIndex: 0, isSecondary: !1 }, s = o.groupIndex < t, u = !1, c = 0, l = 0, d = !1;
  return { get hasNext() {
    return s;
  }, get isNextNewInstance() {
    return u;
  }, groupCount: t, instanceCount: e, count: t * e, stride: r, nonInstanceable: i, move: function() {
    return s && (o.groupIndex = c, o.instanceIndex = l, o.index = l * t + c, o.location = n(c, d ? -1 : l), o.isSecondary = a(c, d ? -1 : l), (c += r) === t ? (++l, u = !0, l < e && (c = 0)) : u = !1, s = c < t), o;
  }, reset: function() {
    o.location = Sc, o.index = 0, o.groupIndex = 0, o.instanceIndex = 0, o.isSecondary = !1, s = o.groupIndex < t, u = !1, c = 0, l = 0, d = !1;
  }, skipInstance: function() {
    s && o.instanceIndex === l && (++l, c = 0, s = l < e);
  }, voidInstances: function() {
    d = !0;
  } };
}
function E0(t) {
  return { kind: "position-location", position: E() };
}
function vs(t, e, r, n) {
  var i = function(a, o, s, u) {
    switch (Ia.getGranularity(a, s.granularity)) {
      case "uniform":
        return function(c, l, d) {
          return function(f, h) {
            return h ? (G.update(h.uColor, qe.toVec3Normalized(h.uColor.ref.value, f)), G.updateIfChanged(h.dColorType, "uniform"), h) : { uColor: G.create(qe.toVec3Normalized(E(), f)), tColor: G.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: G.create(zo()), tPalette: G.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: G.create(ze.create(1, 1)), uColorGridDim: G.create(E.create(1, 1, 1)), uColorGridTransform: G.create(Ut.create(0, 0, 0, 1)), dColorType: G.create("uniform"), dUsePalette: G.create(!1) };
          }(l(Sc, !1), d);
        }(0, s.color, u);
      case "instance":
        return function(c, l, d) {
          var f = c.instanceCount, h = qi(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) {
            var m = c.move(), p = m.location, v = m.isSecondary, g = m.instanceIndex;
            qe.toArray(l(p, v), h.array, 3 * g), c.skipInstance();
          }
          return Rh(h, "instance", d);
        }(a, s.color, u);
      case "group":
        return function(c, l, d) {
          var f = c.groupCount, h = qi(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext && !c.isNextNewInstance; ) {
            var m = c.move(), p = m.location, v = m.isSecondary, g = m.groupIndex;
            qe.toArray(l(p, v), h.array, 3 * g);
          }
          return Rh(h, "group", d);
        }(a, s.color, u);
      case "groupInstance":
        return function(c, l, d) {
          var f = c.groupCount, h = c.instanceCount, m = h * f, p = qi(Math.max(1, m), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) {
            var v = c.move(), g = v.location, y = v.isSecondary, b = v.index;
            qe.toArray(l(g, y), p.array, 3 * b);
          }
          return Rh(p, "groupInstance", d);
        }(a, s.color, u);
      case "vertex":
        return function(c, l, d) {
          var f = c.groupCount, h = c.stride, m = qi(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(), c.voidInstances(); c.hasNext && !c.isNextNewInstance; ) for (var p = c.move(), v = p.location, g = p.isSecondary, y = p.groupIndex, b = l(v, g), S = 0; S < h; ++S) qe.toArray(b, m.array, 3 * (y + S));
          return Rh(m, "vertex", d);
        }(o, s.color, u);
      case "vertexInstance":
        return function(c, l, d) {
          var f = c.groupCount, h = c.instanceCount, m = c.stride, p = h * f, v = qi(Math.max(1, p), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) for (var g = c.move(), y = g.location, b = g.isSecondary, S = g.index, _ = l(y, b), x = 0; x < m; ++x) qe.toArray(_, v.array, 3 * (S + x));
          return Rh(v, "vertexInstance", d);
        }(o, s.color, u);
      case "volume":
        return zE(s.grid, "volume", u);
      case "volumeInstance":
        return zE(s.grid, "volumeInstance", u);
      case "direct":
        return function(c) {
          return c ? (G.updateIfChanged(c.dColorType, "direct"), c) : { uColor: G.create(E()), tColor: G.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: G.create(zo()), tPalette: G.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: G.create(ze.create(1, 1)), uColorGridDim: G.create(E.create(1, 1, 1)), uColorGridTransform: G.create(Ut.create(0, 0, 0, 1)), dColorType: G.create("direct"), dUsePalette: G.create(!1) };
        }(u);
    }
  }(t, e, r, n);
  return r.palette ? (G.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, f = a.colors; d < f.length; d++) {
      var h = f[d], m = qe.toRgb(h), p = m[0], v = m[1], g = m[2];
      if (c[l++] !== p || c[l++] !== v || c[l++] !== g) {
        s = !1;
        break;
      }
    }
    if (!s) {
      for (var y = new Uint8Array(3 * a.colors.length), b = 0, S = 0, _ = a.colors; S < _.length; S++) {
        h = _[S];
        var x = qe.toRgb(h);
        p = x[0], v = x[1], g = x[2], y[b++] = p, y[b++] = v, y[b++] = g;
      }
      G.update(o, { array: y, height: 1, width: a.colors.length, filter: a.filter });
    }
  }(r.palette, i.tPalette)) : G.updateIfChanged(i.dUsePalette, !1), i;
}
function Rh(t, e, r) {
  return r ? (G.update(r.tColor, t), G.update(r.uColorTexDim, ze.create(t.width, t.height)), G.updateIfChanged(r.dColorType, e), r) : { uColor: G.create(E()), tColor: G.create(t), tColorGrid: G.create(zo()), tPalette: G.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: G.create(ze.create(t.width, t.height)), uColorGridDim: G.create(E.create(1, 1, 1)), uColorGridTransform: G.create(Ut.create(0, 0, 0, 1)), dColorType: G.create(e), dUsePalette: G.create(!1) };
}
function zE(t, e, r) {
  var n = t.colors, i = t.dimension, a = t.transform, o = n.getWidth(), s = n.getHeight();
  return r ? (G.update(r.tColorGrid, n), G.update(r.uColorTexDim, ze.create(o, s)), G.update(r.uColorGridDim, E.clone(i)), G.update(r.uColorGridTransform, Ut.clone(a)), G.updateIfChanged(r.dColorType, e), r) : { uColor: G.create(E()), tColor: G.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: G.create(n), tPalette: G.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: G.create(ze.create(o, s)), uColorGridDim: G.create(E.clone(i)), uColorGridTransform: G.create(Ut.clone(a)), dColorType: G.create(e), dUsePalette: G.create(!1) };
}
var VE = Wi(), Wte = he();
function ix(t, e, r) {
  var n = function(u, c) {
    for (var l = 0; l < c; l++) if (Wi.fromMat4(VE, he.fromArray(Wte, u, 16 * l)), Wi.determinant(VE) < 0) return !0;
    return !1;
  }(t, e);
  if (r) {
    G.update(r.matrix, r.matrix.ref.value);
    var i = r.transform.ref.value.length >= 16 * e ? r.transform.ref.value : new Float32Array(16 * e);
    i.set(t), G.update(r.transform, i), G.updateIfChanged(r.uInstanceCount, e), G.updateIfChanged(r.instanceCount, e);
    var a = r.aTransform.ref.value.length >= 16 * e ? r.aTransform.ref.value : new Float32Array(16 * e);
    G.update(r.aTransform, a);
    var o = r.extraTransform.ref.value.length >= 16 * e ? r.extraTransform.ref.value : new Float32Array(16 * e);
    G.update(r.extraTransform, e7(o, e));
    var s = r.aInstance.ref.value.length >= e ? r.aInstance.ref.value : new Float32Array(e);
    G.update(r.aInstance, xc(s, e)), G.update(r.hasReflection, n);
  } else r = { aTransform: G.create(new Float32Array(16 * e)), matrix: G.create(he.identity()), transform: G.create(new Float32Array(t)), extraTransform: G.create(e7(new Float32Array(16 * e), e)), uInstanceCount: G.create(e), instanceCount: G.create(e), aInstance: G.create(xc(new Float32Array(e))), hasReflection: G.create(n) };
  return rO(r), r;
}
var ax = new Float32Array(16);
function ox(t) {
  return ix(new Float32Array(ax), 1, t);
}
function e7(t, e) {
  for (var r = 0; r < e; r++) t.set(ax, 16 * r);
  return t;
}
function rO(t) {
  for (var e = t.aTransform.ref.value, r = t.instanceCount.ref.value, n = t.matrix.ref.value, i = t.transform.ref.value, a = t.extraTransform.ref.value, o = 0; o < r; o++) {
    var s = 16 * o;
    he.mulOffset(e, a, i, s, s, s), he.mulOffset(e, n, e, s, 0, s);
  }
  G.update(t.aTransform, e);
}
he.toArray(he.identity(), ax, 0);
var Yt = { 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 Dp(t) {
  return O(O({}, Dp.Zero), t);
}
function Bm() {
}
(function() {
  var t = /* @__PURE__ */ new Map();
  Object.keys(Yt).forEach(function(e) {
    t.set(Yt[e], e);
  });
})(), function(t) {
  t.Zero = { metalness: 0, roughness: 0, bumpiness: 0 }, t.toArray = function(e, r, n) {
    return r[n] = 255 * e.metalness, r[n + 1] = 255 * e.roughness, r[n + 2] = 255 * e.bumpiness, r;
  }, t.toString = function(e) {
    var r = e.metalness, n = e.roughness, i = e.bumpiness;
    return "M ".concat(r.toFixed(2), " | R ").concat(n.toFixed(2), " | B ").concat(i.toFixed(2));
  }, t.getParam = function(e) {
    return z.Group({ metalness: z.Numeric(0, { min: 0, max: 1, step: 0.01 }), roughness: z.Numeric(1, { min: 0, max: 1, step: 0.01 }), bumpiness: z.Numeric(0, { min: 0, max: 1, step: 0.01 }) }, O(O({}, e), { 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"]] }));
  };
}(Dp || (Dp = {})), function(t) {
  t.Type = { none: 0, plane: 1, sphere: 2, cube: 3, cylinder: 4, infiniteCone: 5 }, t.Params = { variant: z.Select("pixel", z.arrayToOptions(["instance", "pixel"])), objects: z.ObjectList({ type: z.Select("plane", z.objectToOptions(t.Type, function(a) {
    return mc(a);
  })), invert: z.Boolean(!1), position: z.Vec3(E()), rotation: z.Group({ axis: z.Vec3(E.create(1, 0, 0)), angle: z.Numeric(0, { min: -180, max: 180, step: 1 }, { description: "Angle in Degrees" }) }, { isExpanded: !0 }), scale: z.Vec3(E.create(1, 1, 1)) }, function(a) {
    return mc(a.type);
  }) };
  var e = kn(), r = kn(), n = E(), i = E();
  t.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, f = s.scale, h = 0, m = a.objects.length; h < m; ++h) {
      var p = a.objects[h];
      u[h] = t.Type[p.type], c[h] = p.invert, E.toArray(p.position, l, 3 * h), kn.toArray(kn.setAxisAngle(e, p.rotation.axis, qn(p.rotation.angle)), d, 4 * h), E.toArray(p.scale, f, 3 * h);
    }
    return { variant: a.variant, objects: { count: a.objects.length, type: u, invert: c, position: l, rotation: d, scale: f } };
  }, t.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] || (E.fromArray(n, s.position, 3 * c), E.fromArray(i, u.position, 3 * c), !E.equals(n, i)) || (E.fromArray(n, s.scale, 3 * c), E.fromArray(i, u.scale, 3 * c), !E.equals(n, i)) || (kn.fromArray(e, s.rotation, 4 * c), kn.fromArray(r, u.rotation, 4 * c), !kn.equals(e, r))) return !1;
    return !0;
  };
}(Bm || (Bm = {}));
var ft, jte = Object.keys({ custom: {}, auto: {}, highest: {}, higher: {}, high: {}, medium: {}, low: {}, lower: {}, lowest: {} }), Zte = z.arrayToOptions(jte), Qte = { smoothColors: z.MappedStatic("auto", { auto: z.Group({}), on: z.Group({ resolutionFactor: z.Numeric(2, { min: 0.5, max: 6, step: 0.1 }), sampleStride: z.Numeric(3, { min: 1, max: 12, step: 1 }) }), off: z.Group({}) }) };
function hb(t) {
  return !!t.smoothColors;
}
function r0(t, e, r) {
  if ((t.name === "on" || t.name === "auto" && e) && r && r < 3) {
    var n = 3;
    return t.name === "on" ? (r *= t.params.resolutionFactor, n = t.params.sampleStride) : (r *= 2 - iN(0, 1.1, r), (r = Math.max(0.5, r)) > 1.2 && (n = 2)), { resolution: r, stride: n };
  }
}
function UE(t, e, r) {
  return t.fill(0, 4 * e, 4 * r), !0;
}
(function(t) {
  t.MaterialCategory = { category: "Material" }, t.ShadingCategory = { category: "Shading" }, t.CustomQualityParamInfo = { category: "Custom Quality", hideIf: function(e) {
    return e.quality !== void 0 && e.quality !== "custom";
  } }, t.Params = { alpha: z.Numeric(1, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }), quality: z.Select("auto", Zte, { isEssential: !0, description: "Visual/rendering quality of the representation." }), material: Dp.getParam(), clip: z.Group(Bm.Params) }, t.createSimple = function(e, r, n) {
    return e === void 0 && (e = Yt.grey), r === void 0 && (r = 1), n || (n = ox()), { transform: n, locationIterator: gi(1, n.instanceCount.ref.value, 1, function() {
      return Sc;
    }, !1, function() {
      return !1;
    }), theme: { color: y2(0, { value: e }), size: nx(0, { value: r }) } };
  }, t.createValues = function(e, r) {
    var n = Bm.getClip(e.clip);
    return { alpha: G.create(e.alpha), uAlpha: G.create(e.alpha), uVertexCount: G.create(r.vertexCount), uGroupCount: G.create(r.groupCount), drawCount: G.create(r.drawCount), uMetalness: G.create(e.material.metalness), uRoughness: G.create(e.material.roughness), uBumpiness: G.create(e.material.bumpiness), dLightCount: G.create(1), dClipObjectCount: G.create(n.objects.count), dClipVariant: G.create(n.variant), uClipObjectType: G.create(n.objects.type), uClipObjectInvert: G.create(n.objects.invert), uClipObjectPosition: G.create(n.objects.position), uClipObjectRotation: G.create(n.objects.rotation), uClipObjectScale: G.create(n.objects.scale) };
  }, t.updateValues = function(e, r) {
    G.updateIfChanged(e.alpha, r.alpha), G.updateIfChanged(e.uMetalness, r.material.metalness), G.updateIfChanged(e.uRoughness, r.material.roughness), G.updateIfChanged(e.uBumpiness, r.material.bumpiness);
    var n = Bm.getClip(r.clip);
    G.update(e.dClipObjectCount, n.objects.count), G.update(e.dClipVariant, n.variant), G.update(e.uClipObjectType, n.objects.type), G.update(e.uClipObjectInvert, n.objects.invert), G.update(e.uClipObjectPosition, n.objects.position), G.update(e.uClipObjectRotation, n.objects.rotation), G.update(e.uClipObjectScale, n.objects.scale);
  }, t.createRenderableState = function(e) {
    e === void 0 && (e = {});
    var r = e.alpha === void 0 || e.alpha === 1;
    return { disposed: !1, visible: !0, alphaFactor: 1, pickable: !0, colorOnly: !1, opaque: r, writeDepth: r };
  }, t.updateRenderableState = function(e, r) {
    e.opaque = r.alpha * e.alphaFactor >= 1, e.writeDepth = e.opaque;
  };
})(ft || (ft = {}));
var Jte = { array: new Uint8Array(4), width: 1, height: 1 };
function gl(t) {
  return { tOverpaint: G.create(Jte), uOverpaintTexDim: G.create(ze.create(1, 1)), dOverpaint: G.create(!1), tOverpaintGrid: G.create(zo()), uOverpaintGridDim: G.create(E.create(1, 1, 1)), uOverpaintGridTransform: G.create(Ut.create(0, 0, 0, 1)), dOverpaintType: G.create("groupInstance") };
}
function HE(t, e) {
  for (var r = 0, n = 0; n < e; ++n) r += t[n];
  return r / (255 * e);
}
var $te = { array: new Uint8Array(1), width: 1, height: 1 };
function vl(t) {
  return { tTransparency: G.create($te), uTransparencyTexDim: G.create(ze.create(1, 1)), dTransparency: G.create(!1), transparencyAverage: G.create(0), tTransparencyGrid: G.create(zo()), uTransparencyGridDim: G.create(E.create(1, 1, 1)), uTransparencyGridTransform: G.create(Ut.create(0, 0, 0, 1)), dTransparencyType: G.create("groupInstance") };
}
var ere = { array: new Uint8Array(1), width: 1, height: 1 };
function yl(t) {
  return { tClipping: G.create(ere), uClippingTexDim: G.create(ze.create(1, 1)), dClipping: G.create(!1) };
}
function qE(t, e, r) {
  return t.fill(0, 4 * e, 4 * r), !0;
}
var Vt, tre = { array: new Uint8Array(4), width: 1, height: 1 };
function bl(t) {
  return { tSubstance: G.create(tre), uSubstanceTexDim: G.create(ze.create(1, 1)), dSubstance: G.create(!1), tSubstanceGrid: G.create(zo()), uSubstanceGridDim: G.create(E.create(1, 1, 1)), uSubstanceGridTransform: G.create(Ut.create(0, 0, 0, 1)), dSubstanceType: G.create("groupInstance") };
}
function mb(t, e, r) {
  return t = _o(Math.round(t), 0, 16777215) + 1, e[r + 2] = t % 256, t = Math.floor(t / 256), e[r + 1] = t % 256, t = Math.floor(t / 256), e[r] = t % 256, e;
}
function sx(t, e, r) {
  return 256 * Math.floor(t) * 256 + 256 * Math.floor(e) + Math.floor(r) - 1;
}
(function(t) {
  function e(h, m, p, v, g, y, b) {
    return b ? function(S, _, x, C, A, w, I) {
      return I.vertexCount = A, I.triangleCount = w, G.update(I.vertexBuffer, S), G.update(I.indexBuffer, _), G.update(I.normalBuffer, x), G.update(I.groupBuffer, C), I;
    }(h, m, p, v, g, y, b) : function(S, _, x, C, A, w) {
      var I, P = Me(), M = -1, T = -1, F = { kind: "mesh", vertexCount: A, triangleCount: w, vertexBuffer: G.create(S), indexBuffer: G.create(_), normalBuffer: G.create(x), groupBuffer: G.create(C), get boundingSphere() {
        var N = n(F);
        if (N !== M) {
          var R = of(F.vertexBuffer.ref.value, F.vertexCount, 1);
          Me.copy(P, R), M = N;
        }
        return P;
      }, get groupMapping() {
        return F.groupBuffer.ref.version !== T && (I = $p(F.groupBuffer.ref.value, F.vertexCount), T = F.groupBuffer.ref.version), I;
      }, setBoundingSphere: function(N) {
        Me.copy(P, N), M = n(F);
      }, meta: {} };
      return F;
    }(h, m, p, v, g, y);
  }
  function r(h) {
    return e(h ? h.vertexBuffer.ref.value : new Float32Array(0), h ? h.indexBuffer.ref.value : new Uint32Array(0), h ? h.normalBuffer.ref.value : new Float32Array(0), h ? h.groupBuffer.ref.value : new Float32Array(0), 0, 0, h);
  }
  function n(h) {
    return ro([h.vertexCount, h.triangleCount, h.vertexBuffer.ref.version, h.indexBuffer.ref.version, h.normalBuffer.ref.version, h.groupBuffer.ref.version]);
  }
  t.create = e, t.createEmpty = r, t.computeNormals = function(h) {
    var m = h.vertexCount, p = h.triangleCount, v = h.vertexBuffer.ref.value, g = h.indexBuffer.ref.value, y = h.normalBuffer.ref.value.length >= 3 * m ? h.normalBuffer.ref.value : new Float32Array(3 * m);
    y === h.normalBuffer.ref.value && y.fill(0, 0, 3 * m), $R(v, g, y, m, p), G.update(h.normalBuffer, y);
  }, t.checkForDuplicateVertices = function(h, m) {
    m === void 0 && (m = 3);
    for (var p = h.vertexBuffer.ref.value, v = /* @__PURE__ */ new Map(), g = function(A, w) {
      return "".concat(A[0].toFixed(w), "|").concat(A[1].toFixed(w), "|").concat(A[2].toFixed(w));
    }, y = 0, b = E(), S = 0, _ = h.vertexCount; S < _; ++S) {
      E.fromArray(b, p, 3 * S);
      var x = g(b, m), C = v.get(x);
      C !== void 0 ? (y += 1, v.set(x, C + 1)) : v.set(x, 1);
    }
    return y;
  };
  var i = Wi();
  function a(h) {
    for (var m = h.vertexCount, p = h.triangleCount, v = h.indexBuffer.ref.value, g = [], y = 0; y < m; ++y) g[y] = [];
    for (y = 0; y < p; ++y) {
      var b = v[3 * y], S = v[3 * y + 1], _ = v[3 * y + 2];
      Qs(g[b], S), Qs(g[b], _), Qs(g[S], b), Qs(g[S], _), Qs(g[_], b), Qs(g[_], S);
    }
    return g;
  }
  function o(h) {
    for (var m = h.triangleCount, p = h.indexBuffer.ref.value, v = /* @__PURE__ */ new Map(), g = function(x, C) {
      var A = b3(x, C), w = v.get(A) || 0;
      v.set(A, w + 1);
    }, y = 0; y < m; ++y) {
      var b = p[3 * y], S = p[3 * y + 1], _ = p[3 * y + 2];
      g(b, S), g(b, _), g(S, _);
    }
    return v;
  }
  function s(h) {
    var m = /* @__PURE__ */ new Set(), p = [0, 0];
    return h.forEach(function(v, g) {
      v === 1 && (function(y, b) {
        var S = Math.floor((Math.sqrt(8 * b + 1) - 1) / 2), _ = b - (S * S + S) / 2;
        y[0] = S - _, y[1] = _;
      }(p, g), m.add(p[0]), m.add(p[1]));
    }), m;
  }
  function u(h, m, p) {
    var v = /* @__PURE__ */ new Map(), g = function(y, b) {
      v.has(y) ? Qs(v.get(y), b) : v.set(y, [b]);
    };
    return m.forEach(function(y) {
      for (var b = 0, S = h[y]; b < S.length; b++) {
        var _ = S[b];
        m.has(_) && p.get(b3(y, _)) === 1 && g(y, _);
      }
    }), v;
  }
  function c(h, m, p, v) {
    for (var g, y = h.vertexBuffer, b = h.indexBuffer, S = h.normalBuffer, _ = h.triangleCount, x = y.ref.value, C = b.ref.value, A = S.ref.value, w = Le.create(Uint32Array, 3, 1024, _), I = 0, P = 0; P < _; ++P) Le.add3(w, C[3 * P], C[3 * P + 1], C[3 * P + 2]), I += 1;
    var M = E(), T = E(), F = E(), N = E(), R = E(), L = E(), V = E(), U = E(), H = E(), K = E(), X = qn(120), Y = /* @__PURE__ */ new Set(), Q = Array.from(p.keys()).filter(function(ke) {
      return p.get(ke).length < 2;
    }).map(function(ke) {
      var He = p.get(ke);
      return E.fromArray(M, x, 3 * ke), E.fromArray(T, x, 3 * He[0]), E.fromArray(F, x, 3 * He[1]), E.sub(R, T, M), E.sub(L, F, M), [ke, E.angle(R, L)];
    });
    Q.sort(function(ke, He) {
      return ke[1] - He[1];
    });
    for (var J = 0, te = Q; J < te.length; J++) {
      var W = te[J], j = W[0], ee = W[1];
      if (!(Y.has(j) || ee > X)) {
        var ie = p.get(j);
        if ((!m[ie[0]].includes(ie[1]) || !((g = p.get(ie[0])) === null || g === void 0) && g.includes(ie[1])) && (E.fromArray(M, x, 3 * j), E.fromArray(T, x, 3 * ie[0]), E.fromArray(F, x, 3 * ie[1]), E.sub(R, T, M), E.sub(L, F, M), E.add(U, R, L), !(E.squaredDistance(M, T) >= v))) {
          for (var ae = !1, ce = 0, de = m[j]; ce < de.length; ce++) {
            var Ce = de[ce];
            if (!ie.includes(Ce) && (E.fromArray(N, x, 3 * Ce), E.sub(V, N, M), E.dot(U, V) < 0)) {
              ae = !0;
              break;
            }
          }
          ae && (E.fromArray(H, A, 3 * j), E.triangleNormal(K, M, T, F), E.dot(K, H) > 0 ? Le.add3(w, j, ie[0], ie[1]) : Le.add3(w, ie[1], ie[0], j), Y.add(j), Y.add(ie[0]), Y.add(ie[1]), I += 1);
        }
      }
    }
    var De = Le.compact(w);
    return h.triangleCount = I, G.update(b, De), h;
  }
  function l(h, m) {
    var p = h.vertexCount, v = m.instanceCount.ref.value, g = E0(), y = g.position, b = h.vertexBuffer.ref.value, S = m.aTransform.ref.value;
    return gi(p, v, 1, function(_, x) {
      return x < 0 ? E.fromArray(y, b, 3 * _) : E.transformMat4Offset(y, b, S, 0, 3 * _, 16 * x), g;
    });
  }
  function d(h, m, p, v, g) {
    var y = p.instanceCount, b = p.groupCount, S = vs(p, l(h, m), v.color), _ = ou(y * b), x = gl(), C = vl(), A = bl(), w = yl(), I = { drawCount: 3 * h.triangleCount, vertexCount: h.vertexCount, groupCount: b, instanceCount: y }, P = Me.clone(h.boundingSphere), M = aa(P, m.aTransform.ref.value, y);
    return O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("mesh"), aPosition: h.vertexBuffer, aNormal: h.normalBuffer, aGroup: h.groupBuffer, elements: h.indexBuffer, boundingSphere: G.create(M), invariantBoundingSphere: G.create(P), uInvariantBoundingSphere: G.create(Ut.ofSphere(P)) }, S), _), x), C), A), w), m), ft.createValues(g, I)), { uDoubleSided: G.create(g.doubleSided), dFlatShaded: G.create(g.flatShaded), dFlipSided: G.create(g.flipSided), dIgnoreLight: G.create(g.ignoreLight), dXrayShaded: G.create(g.xrayShaded), uBumpFrequency: G.create(g.bumpFrequency), uBumpAmplitude: G.create(g.bumpAmplitude), meta: G.create(h.meta) });
  }
  function f(h, m) {
    ft.updateRenderableState(h, m), h.opaque = h.opaque && !m.xrayShaded, h.writeDepth = h.opaque;
  }
  t.transform = function(h, m) {
    var p = h.vertexBuffer.ref.value;
    wp(m, p, 0, h.vertexCount), he.isTranslationAndUniformScaling(m) || function(v, g, y, b) {
      for (var S = 0, _ = 3 * b; S < _; S += 3) E.fromArray(Go, g, y + S), E.transformMat3(Go, Go, v), E.toArray(Go, g, y + S);
    }(Wi.directionTransform(i, m), h.normalBuffer.ref.value, 0, h.vertexCount), G.update(h.vertexBuffer, p);
  }, t.getOriginalData = function(h) {
    return ("kind" in h ? h.meta : h.meta.ref.value).originalData;
  }, t.uniformTriangleGroup = function(h, m) {
    m === void 0 && (m = !0);
    var p = h.indexBuffer, v = h.vertexBuffer, g = h.groupBuffer, y = h.normalBuffer, b = h.triangleCount, S = h.vertexCount, _ = p.ref.value, x = v.ref.value, C = g.ref.value, A = y.ref.value, w = Le.create(Uint32Array, 3, 1024, b), I = Le.create(Float32Array, 3, 1024, x);
    I.currentIndex = 3 * S, I.elementCount = S;
    var P = Le.create(Float32Array, 3, 1024, A);
    P.currentIndex = 3 * S, P.elementCount = S;
    var M = Le.create(Float32Array, 1, 1024, C);
    M.currentIndex = S, M.elementCount = S;
    var T = E(), F = E(), N = E(), R = E(), L = E(), V = E();
    function U(Ne) {
      E.fromArray(T, x, 3 * Ne), E.fromArray(R, A, 3 * Ne), Le.add3(I, T[0], T[1], T[2]), Le.add3(P, R[0], R[1], R[2]);
    }
    function H(Ne, Je) {
      E.fromArray(T, x, 3 * Ne), E.fromArray(F, x, 3 * Je), E.scale(T, E.add(T, T, F), 0.5), E.fromArray(R, A, 3 * Ne), E.fromArray(L, A, 3 * Je), E.scale(R, E.add(R, R, L), 0.5), Le.add3(I, T[0], T[1], T[2]), Le.add3(P, R[0], R[1], R[2]);
    }
    function K(Ne, Je, Re) {
      E.fromArray(T, x, 3 * Ne), E.fromArray(F, x, 3 * Je), E.fromArray(N, x, 3 * Re), E.scale(T, E.add(T, E.add(T, T, F), N), 1 / 3), E.fromArray(R, A, 3 * Ne), E.fromArray(L, A, 3 * Je), E.fromArray(V, A, 3 * Re), E.scale(R, E.add(R, E.add(R, R, L), V), 1 / 3), Le.add3(I, T[0], T[1], T[2]), Le.add3(P, R[0], R[1], R[2]);
    }
    function X(Ne, Je, Re, nt, ne) {
      ++Q, U(Ne), H(Ne, Je), H(Ne, Re), Le.add3(w, Y, Y + 1, Y + 2);
      for (var re = 0; re < 3; ++re) Le.add(M, nt);
      for (Y += 3, Q += 2, U(Je), U(Re), H(Ne, Je), H(Ne, Re), Le.add3(w, Y, Y + 1, Y + 3), Le.add3(w, Y, Y + 3, Y + 2), re = 0; re < 4; ++re) Le.add(M, ne);
      Y += 4;
    }
    var Y = S, Q = 0;
    if (m) for (var J = 0, te = b; J < te; ++J) {
      var W = _[3 * J], j = _[3 * J + 1], ee = _[3 * J + 2], ie = C[W], ae = C[j], ce = C[ee];
      if (ie === ae && ie === ce) ++Q, Le.add3(w, W, j, ee);
      else if (ie === ae) X(ee, W, j, ce, ie);
      else if (ie === ce) X(j, ee, W, ae, ce);
      else if (ae === ce) X(W, j, ee, ie, ae);
      else {
        Q += 2, U(W), H(W, j), H(W, ee), K(W, j, ee), Le.add3(w, Y, Y + 1, Y + 3), Le.add3(w, Y, Y + 3, Y + 2);
        for (var de = 0; de < 4; ++de) Le.add(M, ie);
        for (Y += 4, Q += 2, U(j), H(j, ee), H(j, W), K(W, j, ee), Le.add3(w, Y, Y + 1, Y + 3), Le.add3(w, Y, Y + 3, Y + 2), de = 0; de < 4; ++de) Le.add(M, ae);
        for (Y += 4, Q += 2, U(ee), H(ee, j), H(ee, W), K(W, j, ee), Le.add3(w, Y + 3, Y + 1, Y), Le.add3(w, Y + 2, Y + 3, Y), de = 0; de < 4; ++de) Le.add(M, ce);
        Y += 4;
      }
    }
    else for (J = 0, te = b; J < te; ++J)
      if (W = _[3 * J], j = _[3 * J + 1], ee = _[3 * J + 2], ie = C[W], ae = C[j], ce = C[ee], ie !== ae || ie !== ce) {
        ++Q, U(W), U(j), U(ee), Le.add3(w, Y, Y + 1, Y + 2);
        var Ce = ae === ce ? ae : ie;
        for (de = 0; de < 3; ++de) Le.add(M, Ce);
        Y += 3;
      } else ++Q, Le.add3(w, W, j, ee);
    var De = Le.compact(w), ke = Le.compact(I), He = Le.compact(P), We = Le.compact(M);
    return h.vertexCount = Y, h.triangleCount = Q, G.update(v, ke), G.update(g, We), G.update(p, De), G.update(y, He), h.meta.originalData = { indexBuffer: _, vertexCount: S, triangleCount: b }, h;
  }, t.smoothEdges = function(h, m) {
    (function(S, _) {
      for (var x = S.indexBuffer, C = S.triangleCount, A = x.ref.value, w = Le.create(Uint32Array, 3, 1024, C), I = 0, P = 0; P < C; ++P) {
        var M = A[3 * P], T = A[3 * P + 1], F = A[3 * P + 2];
        _[M].length !== 2 && _[T].length !== 2 && _[F].length !== 2 && (Le.add3(w, M, T, F), I += 1);
      }
      var N = Le.compact(w);
      S.triangleCount = I, G.update(x, N);
    })(h, a(h));
    for (var p = 0; p < 10; ++p) {
      var v = h.triangleCount, g = o(h), y = a(h);
      if (c(h, y, u(y, s(g), g), m.maxNewEdgeLength * m.maxNewEdgeLength), h.triangleCount === v) break;
    }
    var b = o(h);
    return function(S, _, x) {
      for (var C = x.iterations, A = x.lambda, w = E(), I = E(), P = E(), M = E(), T = -A, F = new Float32Array(S.vertexBuffer.ref.value.length), N = function(L) {
        var V = S.vertexBuffer.ref.value;
        F.set(V), _.forEach(function(H, K) {
          if (H.length === 2) {
            E.fromArray(w, V, 3 * K), E.fromArray(I, V, 3 * H[0]), E.fromArray(P, V, 3 * H[1]);
            var X = 1 / E.distance(w, I), Y = 1 / E.distance(w, P);
            E.scale(I, I, X), E.scale(P, P, Y), E.add(M, I, P), E.scale(M, M, 1 / (X + Y)), E.sub(M, M, w), E.scale(M, M, L), E.add(M, w, M), E.toArray(M, F, 3 * K);
          }
        });
        var U = S.vertexBuffer.ref.value;
        G.update(S.vertexBuffer, F), F = U;
      }, R = 0; R < C; ++R) N(A), N(T);
    }(h, u(a(h), s(b), b), { iterations: m.iterations, lambda: 0.5 }), h;
  }, t.Params = O(O({}, ft.Params), { doubleSided: z.Boolean(!1, ft.CustomQualityParamInfo), flipSided: z.Boolean(!1, ft.ShadingCategory), flatShaded: z.Boolean(!1, ft.ShadingCategory), ignoreLight: z.Boolean(!1, ft.ShadingCategory), xrayShaded: z.Boolean(!1, ft.ShadingCategory), bumpFrequency: z.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), bumpAmplitude: z.Numeric(1, { min: 0, max: 5, step: 0.1 }, ft.ShadingCategory) }), t.Utils = { Params: t.Params, createEmpty: r, createValues: d, createValuesSimple: function(h, m, p, v, g) {
    var y = ft.createSimple(p, v, g), b = O(O({}, z.getDefaultValues(t.Params)), m);
    return d(h, y.transform, y.locationIterator, y.theme, b);
  }, updateValues: function(h, m) {
    ft.updateValues(h, m), G.updateIfChanged(h.uDoubleSided, m.doubleSided), G.updateIfChanged(h.dFlatShaded, m.flatShaded), G.updateIfChanged(h.dFlipSided, m.flipSided), G.updateIfChanged(h.dIgnoreLight, m.ignoreLight), G.updateIfChanged(h.dXrayShaded, m.xrayShaded), G.updateIfChanged(h.uBumpFrequency, m.bumpFrequency), G.updateIfChanged(h.uBumpAmplitude, m.bumpAmplitude);
  }, updateBoundingSphere: function(h, m) {
    var p = Me.clone(m.boundingSphere), v = aa(p, h.aTransform.ref.value, h.instanceCount.ref.value);
    Me.equals(v, h.boundingSphere.ref.value) || G.update(h.boundingSphere, v), Me.equals(p, h.invariantBoundingSphere.ref.value) || (G.update(h.invariantBoundingSphere, p), G.update(h.uInvariantBoundingSphere, Ut.fromSphere(h.uInvariantBoundingSphere.ref.value, p)));
  }, createRenderableState: function(h) {
    var m = ft.createRenderableState(h);
    return f(m, h), m;
  }, updateRenderableState: f, createPositionIterator: l };
})(Vt || (Vt = {}));
var gb = 255 / 256, vb = E.create(16777216, 65536, 256), rre = Ut.create(gb / vb[0], gb / vb[1], gb / vb[2], 0.99609375), KE = Ut();
function Bl(t, e, r) {
  switch (Ia.getGranularity(t, e.granularity)) {
    case "uniform":
      return function(n, i, a) {
        return function(o, s) {
          return s ? (G.update(s.uSize, o), G.updateIfChanged(s.dSizeType, "uniform"), s) : O(O({ uSize: G.create(o) }, { tSize: G.create(nre), uSizeTexDim: G.create(ze.create(1, 1)) }), { dSizeType: G.create("uniform") });
        }(i(Sc), a);
      }(0, e.size, r);
    case "group":
      return function(n, i, a) {
        var o = n.groupCount, s = qi(Math.max(1, o), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (n.reset(); n.hasNext && !n.isNextNewInstance; ) {
          var u = n.move();
          mb(i(u.location) * i3, s.array, 3 * u.groupIndex);
        }
        return yb(s, "group", a);
      }(t, e.size, r);
    case "groupInstance":
      return function(n, i, a) {
        var o = n.groupCount, s = n.instanceCount, u = s * o, c = qi(Math.max(1, u), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (n.reset(); n.hasNext; ) {
          var l = n.move();
          mb(i(l.location) * i3, c.array, 3 * l.index);
        }
        return yb(c, "groupInstance", a);
      }(t, e.size, r);
    case "instance":
      return function(n, i, a) {
        var o = n.instanceCount, s = qi(Math.max(1, o), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (n.reset(); n.hasNext && !n.isNextNewInstance; ) {
          var u = n.move();
          mb(i(u.location) * i3, s.array, 3 * u.instanceIndex), n.skipInstance();
        }
        return yb(s, "instance", a);
      }(t, e.size, r);
  }
}
var i3 = 100;
function Wm(t) {
  switch (t.dSizeType.ref.value) {
    case "uniform":
      return t.uSize.ref.value;
    case "instance":
    case "group":
    case "groupInstance":
      for (var e = 0, r = t.tSize.ref.value.array, n = 0, i = r.length; n < i; n += 3) {
        var a = sx(r[n], r[n + 1], r[n + 2]);
        e < a && (e = a);
      }
      return e / i3;
  }
}
var I0, nre = { array: new Uint8Array(3), width: 1, height: 1 };
function yb(t, e, r) {
  return r ? (G.update(r.tSize, t), G.update(r.uSizeTexDim, ze.create(t.width, t.height)), G.updateIfChanged(r.dSizeType, e), r) : { uSize: G.create(0), tSize: G.create(t), uSizeTexDim: G.create(ze.create(t.width, t.height)), dSizeType: G.create(e) };
}
function XE(t, e, r, n, i, a, o) {
  for (var s = 0; s < e; s++) {
    for (var u = 0; u < r; u++) n[u] = t[u * e + s];
    for (YE(n, i, a, o, r), u = 0; u < r; u++) t[u * e + s] = i[u];
  }
  for (u = 0; u < r; u++) {
    for (s = 0; s < e; s++) n[s] = t[u * e + s];
    for (YE(n, i, a, o, e), s = 0; s < e; s++) t[u * e + s] = Math.sqrt(i[s]);
  }
}
function YE(t, e, r, n, i) {
  r[0] = 0, n[0] = Number.MIN_SAFE_INTEGER, n[1] = Number.MAX_SAFE_INTEGER;
  for (var a = 1, o = 0; a < i; a++) {
    for (var s = (t[a] + a * a - (t[r[o]] + r[o] * r[o])) / (2 * a - 2 * r[o]); s <= n[o]; ) o--, s = (t[a] + a * a - (t[r[o]] + r[o] * r[o])) / (2 * a - 2 * r[o]);
    r[++o] = a, n[o] = s, n[o + 1] = Number.MAX_SAFE_INTEGER;
  }
  for (a = 0, o = 0; a < i; a++) {
    for (; n[o + 1] < a; ) o++;
    e[a] = (a - r[o]) * (a - r[o]) + t[r[o]];
  }
}
(function(t) {
  function e(s, u, c, l) {
    return l ? function(d, f, h, m) {
      return m.pointCount = h, G.update(m.centerBuffer, d), G.update(m.groupBuffer, f), m;
    }(s, u, c, l) : function(d, f, h) {
      var m, p = Me(), v = -1, g = -1, y = { kind: "points", pointCount: h, centerBuffer: G.create(d), groupBuffer: G.create(f), get boundingSphere() {
        var b = n(y);
        if (b !== v) {
          var S = of(y.centerBuffer.ref.value, y.pointCount, 1);
          Me.copy(p, S), v = b;
        }
        return p;
      }, get groupMapping() {
        return y.groupBuffer.ref.version !== g && (m = $p(y.groupBuffer.ref.value, y.pointCount), g = y.groupBuffer.ref.version), m;
      }, setBoundingSphere: function(b) {
        Me.copy(p, b), v = n(y);
      } };
      return y;
    }(s, u, c);
  }
  function r(s) {
    return e(s ? s.centerBuffer.ref.value : new Float32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function n(s) {
    return ro([s.pointCount, s.centerBuffer.ref.version, s.groupBuffer.ref.version]);
  }
  function i(s, u) {
    var c = s.pointCount, l = u.instanceCount.ref.value, d = E0(), f = d.position, h = s.centerBuffer.ref.value, m = u.aTransform.ref.value;
    return gi(c, l, 1, function(p, v) {
      return v < 0 ? E.fromArray(f, h, 3 * p) : E.transformMat4Offset(f, h, m, 0, 3 * p, 16 * v), d;
    });
  }
  function a(s, u, c, l, d) {
    var f = c.instanceCount, h = c.groupCount, m = vs(c, i(s, u), l.color), p = Bl(c, l.size), v = ou(f * h), g = gl(), y = vl(), b = bl(), S = yl(), _ = { drawCount: s.pointCount, vertexCount: s.pointCount, groupCount: h, instanceCount: f }, x = Me.clone(s.boundingSphere), C = aa(x, u.aTransform.ref.value, f);
    return O(O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("points"), aPosition: s.centerBuffer, aGroup: s.groupBuffer, boundingSphere: G.create(C), invariantBoundingSphere: G.create(x), uInvariantBoundingSphere: G.create(Ut.ofSphere(x)) }, m), p), v), g), y), b), S), u), ft.createValues(d, _)), { uSizeFactor: G.create(d.sizeFactor), dPointSizeAttenuation: G.create(d.pointSizeAttenuation), dPointStyle: G.create(d.pointStyle) });
  }
  function o(s, u) {
    ft.updateRenderableState(s, u), s.opaque = s.opaque && u.pointStyle !== "fuzzy", s.writeDepth = s.opaque;
  }
  t.create = e, t.createEmpty = r, t.transform = function(s, u) {
    var c = s.centerBuffer.ref.value;
    wp(u, c, 0, s.pointCount), G.update(s.centerBuffer, c);
  }, t.StyleTypes = { square: "Square", circle: "Circle", fuzzy: "Fuzzy" }, t.StyleTypeNames = Object.keys(t.StyleTypes), t.Params = O(O({}, ft.Params), { sizeFactor: z.Numeric(3, { min: 0, max: 10, step: 0.1 }), pointSizeAttenuation: z.Boolean(!1), pointStyle: z.Select("square", z.objectToOptions(t.StyleTypes)) }), t.Utils = { Params: t.Params, createEmpty: r, createValues: a, createValuesSimple: function(s, u, c, l, d) {
    var f = ft.createSimple(c, l, d), h = O(O({}, z.getDefaultValues(t.Params)), u);
    return a(s, f.transform, f.locationIterator, f.theme, h);
  }, updateValues: function(s, u) {
    ft.updateValues(s, u), G.updateIfChanged(s.uSizeFactor, u.sizeFactor), G.updateIfChanged(s.dPointSizeAttenuation, u.pointSizeAttenuation), G.updateIfChanged(s.dPointStyle, u.pointStyle);
  }, updateBoundingSphere: function(s, u) {
    var c = Me.clone(u.boundingSphere), l = aa(c, s.aTransform.ref.value, s.instanceCount.ref.value);
    Me.equals(l, s.boundingSphere.ref.value) || G.update(s.boundingSphere, l), Me.equals(c, s.invariantBoundingSphere.ref.value) || (G.update(s.invariantBoundingSphere, c), G.update(s.uInvariantBoundingSphere, Ut.fromSphere(s.uInvariantBoundingSphere.ref.value, c)));
  }, createRenderableState: function(s) {
    var u = ft.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: i };
})(I0 || (I0 = {}));
var bb = {}, bs, nO = { fontFamily: z.Select("sans-serif", [["sans-serif", "Sans Serif"], ["monospace", "Monospace"], ["serif", "Serif"], ["cursive", "Cursive"]]), fontQuality: z.Select(3, [[0, "lower"], [1, "low"], [2, "medium"], [3, "high"], [4, "higher"]]), fontStyle: z.Select("normal", [["normal", "Normal"], ["italic", "Italic"], ["oblique", "Oblique"]]), fontVariant: z.Select("normal", [["normal", "Normal"], ["small-caps", "Small Caps"]]), fontWeight: z.Select("normal", [["normal", "Normal"], ["bold", "Bold"]]) }, ire = function() {
  function t(e) {
    e === void 0 && (e = {}), this.mapped = {}, this.scratchW = 0, this.scratchH = 0, this.currentX = 0, this.currentY = 0, this.cutoff = 0.5;
    var r = O(O({}, z.getDefaultValues(nO)), e);
    this.props = r;
    var n = 32 * (r.fontQuality + 1);
    this.buffer = n / 8, this.radius = n / 3, this.lineHeight = Math.round(n + 2 * this.buffer + this.radius), this.maxWidth = Math.round(0.75 * this.lineHeight), this.texture = qi(350 * this.lineHeight * this.maxWidth, 1, Uint8Array), this.scratchCanvas = document.createElement("canvas"), this.scratchCanvas.width = this.maxWidth, this.scratchCanvas.height = this.lineHeight, this.scratchContext = this.scratchCanvas.getContext("2d"), this.scratchContext.font = "".concat(r.fontStyle, " ").concat(r.fontVariant, " ").concat(r.fontWeight, " ").concat(n, "px ").concat(r.fontFamily), this.scratchContext.fillStyle = "black", this.scratchContext.textBaseline = "middle", this.scratchData = new Uint8Array(this.lineHeight * this.maxWidth), this.gridOuter = new Float64Array(this.lineHeight * this.maxWidth), this.gridInner = new Float64Array(this.lineHeight * this.maxWidth), this.f = new Float64Array(Math.max(this.lineHeight, this.maxWidth)), this.d = new Float64Array(Math.max(this.lineHeight, this.maxWidth)), this.z = new Float64Array(Math.max(this.lineHeight, this.maxWidth) + 1), this.v = new Int16Array(Math.max(this.lineHeight, this.maxWidth)), this.middle = Math.ceil(this.lineHeight / 2), this.placeholder = this.get("�");
  }
  return t.prototype.get = function(e) {
    if (this.mapped[e] === void 0) {
      this.draw(e);
      var r = this.texture, n = r.array, i = r.width, a = r.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[e] = { x: this.currentX, y: this.currentY, w: this.scratchW, h: this.scratchH, nw: this.scratchW / this.lineHeight, nh: this.scratchH / this.lineHeight };
      for (var s = 0; s < this.scratchH; ++s) for (var u = 0; u < this.scratchW; ++u) n[i * (this.currentY + s) + this.currentX + u] = o[s * this.scratchW + u];
      this.currentX += this.scratchW;
    }
    return this.mapped[e];
  }, t.prototype.draw = function(e) {
    var r = this.lineHeight, n = this.scratchContext, i = this.scratchData, a = n.measureText(e), o = Math.min(this.maxWidth, Math.ceil(a.width + 2 * this.buffer)), s = o * r;
    n.clearRect(0, 0, o, r), n.fillText(e, this.buffer, this.middle);
    for (var u = n.getImageData(0, 0, o, r), c = 0; c < s; c++) {
      var l = u.data[4 * c + 3] / 255;
      this.gridOuter[c] = l === 1 ? 0 : l === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - l), 2), this.gridInner[c] = l === 1 ? Number.MAX_SAFE_INTEGER : l === 0 ? 0 : Math.pow(Math.max(0, l - 0.5), 2);
    }
    for (XE(this.gridOuter, o, r, this.f, this.d, this.v, this.z), XE(this.gridInner, o, r, this.f, this.d, this.v, this.z), c = 0; c < s; c++) {
      var d = this.gridOuter[c] - this.gridInner[c];
      i[c] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));
    }
    this.scratchW = o, this.scratchH = r;
  }, t;
}();
function WE(t, e, r, n) {
  for (var i = 0, a = 0, o = 0, s = 4 * r; o < s; ++o) {
    var u = 2 * o, c = Math.abs(t[u]);
    c > i && (i = c);
    var l = Math.abs(t[u + 1]);
    l > i && (i = l);
    var d = Math.abs(e[o]);
    d > a && (a = d);
  }
  return Math.max(a, n + n * i);
}
(function(t) {
  function e(s, u, c, l, d, f, h, m, p) {
    return p ? function(v, g, y, b, S, _, x, C, A) {
      return A.charCount = C, G.update(A.fontTexture, v), G.update(A.centerBuffer, g), G.update(A.mappingBuffer, y), G.update(A.depthBuffer, b), G.update(A.indexBuffer, S), G.update(A.groupBuffer, _), G.update(A.tcoordBuffer, x), A;
    }(s, u, c, l, d, f, h, m, p) : function(v, g, y, b, S, _, x, C) {
      var A, w = Me(), I = -1, P = -1, M = { kind: "text", charCount: C, fontTexture: G.create(v), centerBuffer: G.create(g), mappingBuffer: G.create(y), depthBuffer: G.create(b), indexBuffer: G.create(S), groupBuffer: G.create(_), tcoordBuffer: G.create(x), get boundingSphere() {
        var T = n(M);
        if (T !== I) {
          var F = of(M.centerBuffer.ref.value, 4 * M.charCount, 4);
          Me.copy(w, F), I = T;
        }
        return w;
      }, get groupMapping() {
        return M.groupBuffer.ref.version !== P && (A = $p(M.groupBuffer.ref.value, M.charCount, 4), P = M.groupBuffer.ref.version), A;
      }, setBoundingSphere: function(T) {
        Me.copy(w, T), I = n(M);
      } };
      return M;
    }(s, u, c, l, d, f, h, m);
  }
  function r(s) {
    return e(s ? s.fontTexture.ref.value : qi(0, 1, Uint8Array), s ? s.centerBuffer.ref.value : new Float32Array(0), s ? s.mappingBuffer.ref.value : new Float32Array(0), s ? s.depthBuffer.ref.value : new Float32Array(0), s ? s.indexBuffer.ref.value : new Uint32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), s ? s.tcoordBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function n(s) {
    return ro([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 = E0(), f = d.position, h = s.centerBuffer.ref.value, m = u.aTransform.ref.value;
    return gi(c, l, 4, function(p, v) {
      return v < 0 ? E.fromArray(f, h, 3 * p) : E.transformMat4Offset(f, h, m, 0, 3 * p, 16 * v), d;
    });
  }
  function a(s, u, c, l, d) {
    var f = c.instanceCount, h = c.groupCount, m = vs(c, i(s, u), l.color), p = Bl(c, l.size), v = ou(f * h), g = gl(), y = vl(), b = bl(), S = yl(), _ = { drawCount: 2 * s.charCount * 3, vertexCount: 4 * s.charCount, groupCount: h, instanceCount: f }, x = WE(s.mappingBuffer.ref.value, s.depthBuffer.ref.value, s.charCount, Wm(p)), C = Me.expand(Me(), s.boundingSphere, x), A = aa(C, u.aTransform.ref.value, f);
    return O(O(O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("text"), aPosition: s.centerBuffer, aMapping: s.mappingBuffer, aDepth: s.depthBuffer, aGroup: s.groupBuffer, elements: s.indexBuffer, boundingSphere: G.create(A), invariantBoundingSphere: G.create(C), uInvariantBoundingSphere: G.create(Ut.ofSphere(C)) }, m), p), v), g), y), b), S), u), { aTexCoord: s.tcoordBuffer, tFont: s.fontTexture, padding: G.create(x) }), ft.createValues(d, _)), { uSizeFactor: G.create(d.sizeFactor), uBorderWidth: G.create(_o(d.borderWidth, 0, 0.5)), uBorderColor: G.create(qe.toArrayNormalized(d.borderColor, E.zero(), 0)), uOffsetX: G.create(d.offsetX), uOffsetY: G.create(d.offsetY), uOffsetZ: G.create(d.offsetZ), uBackgroundColor: G.create(qe.toArrayNormalized(d.backgroundColor, E.zero(), 0)), uBackgroundOpacity: G.create(d.backgroundOpacity) });
  }
  function o(s, u) {
    ft.updateRenderableState(s, u), s.pickable = !1, s.opaque = !1, s.writeDepth = !0;
  }
  t.create = e, t.createEmpty = r, t.Params = O(O(O({}, ft.Params), nO), { sizeFactor: z.Numeric(1, { min: 0, max: 10, step: 0.1 }), borderWidth: z.Numeric(0, { min: 0, max: 0.5, step: 0.01 }), borderColor: z.Color(Yt.grey), offsetX: z.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetY: z.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetZ: z.Numeric(0, { min: 0, max: 10, step: 0.1 }), background: z.Boolean(!1), backgroundMargin: z.Numeric(0.2, { min: 0, max: 1, step: 0.01 }), backgroundColor: z.Color(Yt.grey), backgroundOpacity: z.Numeric(1, { min: 0, max: 1, step: 0.01 }), tether: z.Boolean(!1), tetherLength: z.Numeric(1, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: z.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), attachment: z.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"]]) }), t.Utils = { Params: t.Params, createEmpty: r, createValues: a, createValuesSimple: function(s, u, c, l, d) {
    var f = ft.createSimple(c, l, d), h = O(O({}, z.getDefaultValues(t.Params)), u);
    return a(s, f.transform, f.locationIterator, f.theme, h);
  }, updateValues: function(s, u) {
    ft.updateValues(s, u), G.updateIfChanged(s.uSizeFactor, u.sizeFactor), G.updateIfChanged(s.uBorderWidth, u.borderWidth), qe.fromNormalizedArray(s.uBorderColor.ref.value, 0) !== u.borderColor && (qe.toArrayNormalized(u.borderColor, s.uBorderColor.ref.value, 0), G.update(s.uBorderColor, s.uBorderColor.ref.value)), G.updateIfChanged(s.uOffsetX, u.offsetX), G.updateIfChanged(s.uOffsetY, u.offsetY), G.updateIfChanged(s.uOffsetZ, u.offsetZ), qe.fromNormalizedArray(s.uBackgroundColor.ref.value, 0) !== u.backgroundColor && (qe.toArrayNormalized(u.backgroundColor, s.uBackgroundColor.ref.value, 0), G.update(s.uBackgroundColor, s.uBackgroundColor.ref.value)), G.updateIfChanged(s.uBackgroundOpacity, u.backgroundOpacity);
  }, updateBoundingSphere: function(s, u) {
    var c = WE(s.aMapping.ref.value, s.aDepth.ref.value, u.charCount, Wm(s)), l = Me.expand(Me(), u.boundingSphere, c), d = aa(l, s.aTransform.ref.value, s.instanceCount.ref.value);
    Me.equals(d, s.boundingSphere.ref.value) || G.update(s.boundingSphere, d), Me.equals(l, s.invariantBoundingSphere.ref.value) || (G.update(s.invariantBoundingSphere, l), G.update(s.uInvariantBoundingSphere, Ut.fromSphere(s.uInvariantBoundingSphere.ref.value, l))), G.update(s.padding, c);
  }, createRenderableState: function(s) {
    var u = ft.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: i };
})(bs || (bs = {}));
var Ea, Rr, Ju = E(), $u = E(), Of = E(), jE = Le.add, tv = Le.add3;
(function(t) {
  t.create = function(e, r, n) {
    e === void 0 && (e = 2048), r === void 0 && (r = 1024);
    var i = Le.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : e), a = Le.create(Float32Array, 3, r, n ? n.startBuffer.ref.value : e), o = Le.create(Float32Array, 3, r, n ? n.endBuffer.ref.value : e), s = function(c, l, d, f, h, m, p) {
      for (var v = 0; v < 4; ++v) tv(a, c, l, d), tv(o, f, h, m), jE(i, p);
    }, u = function(c, l, d, f) {
      var h = E.distance(c, l), m = Math.floor(d / 2), p = 1 / d;
      E.sub(Of, l, c);
      for (var v = 0; v < m; ++v) {
        var g = p * (2 * v + 1);
        E.setMagnitude(Of, Of, h * g), E.add(Ju, c, Of), E.setMagnitude(Of, Of, h * p * (2 * (v + 1))), E.add($u, c, Of), s(Ju[0], Ju[1], Ju[2], $u[0], $u[1], $u[2], f);
      }
    };
    return { add: s, addVec: function(c, l, d) {
      for (var f = 0; f < 4; ++f) tv(a, c[0], c[1], c[2]), tv(o, l[0], l[1], l[2]), jE(i, d);
    }, addFixedCountDashes: u, addFixedLengthDashes: function(c, l, d, f) {
      var h = E.distance(c, l);
      u(c, l, h / d, f);
    }, addCage: function(c, l, d) {
      for (var f = l.vertices, h = l.edges, m = 0, p = h.length; m < p; m += 2) E.fromArray(Ju, f, 3 * h[m]), E.fromArray($u, f, 3 * h[m + 1]), E.transformMat4(Ju, Ju, c), E.transformMat4($u, $u, c), s(Ju[0], Ju[1], Ju[2], $u[0], $u[1], $u[2], d);
    }, getLines: function() {
      var c = i.elementCount / 4, l = Le.compact(i, !0), d = Le.compact(a, !0), f = Le.compact(o, !0), h = n && c <= n.lineCount ? n.mappingBuffer.ref.value : new Float32Array(8 * c), m = n && c <= n.lineCount ? n.indexBuffer.ref.value : new Uint32Array(6 * c);
      return (!n || c > n.lineCount) && function(p, v, g) {
        for (var y = 0; y < p; ++y) {
          var b = 8 * y;
          v[b] = -1, v[b + 1] = -1, v[b + 2] = 1, v[b + 3] = -1, v[b + 4] = -1, v[b + 5] = 1, v[b + 6] = 1, v[b + 7] = 1;
        }
        for (y = 0; y < p; ++y) {
          var S = 4 * y, _ = 6 * y;
          g[_] = S, g[_ + 1] = S + 1, g[_ + 2] = S + 2, g[_ + 3] = S + 1, g[_ + 4] = S + 3, g[_ + 5] = S + 2;
        }
      }(c, h, m), Rr.create(h, m, l, d, f, c, n);
    } };
  };
})(Ea || (Ea = {})), function(t) {
  function e(o, s, u, c, l, d, f) {
    return f ? function(h, m, p, v, g, y, b) {
      return y > b.lineCount && (G.update(b.mappingBuffer, h), G.update(b.indexBuffer, m)), b.lineCount = y, G.update(b.groupBuffer, p), G.update(b.startBuffer, v), G.update(b.endBuffer, g), b;
    }(o, s, u, c, l, d, f) : function(h, m, p, v, g, y) {
      var b, S = Me(), _ = -1, x = -1, C = { kind: "lines", lineCount: y, mappingBuffer: G.create(h), indexBuffer: G.create(m), groupBuffer: G.create(p), startBuffer: G.create(v), endBuffer: G.create(g), get boundingSphere() {
        var A = n(C);
        if (A !== _) {
          var w = of(C.startBuffer.ref.value, 4 * C.lineCount, 4), I = of(C.endBuffer.ref.value, 4 * C.lineCount, 4);
          Me.expandBySphere(S, w, I), _ = A;
        }
        return S;
      }, get groupMapping() {
        return C.groupBuffer.ref.version !== x && (b = $p(C.groupBuffer.ref.value, C.lineCount, 4), x = C.groupBuffer.ref.version), b;
      }, setBoundingSphere: function(A) {
        Me.copy(S, A), _ = n(C);
      } };
      return C;
    }(o, s, u, c, l, d);
  }
  function r(o) {
    return e(o ? o.mappingBuffer.ref.value : new Float32Array(0), o ? o.indexBuffer.ref.value : new Uint32Array(0), o ? o.groupBuffer.ref.value : new Float32Array(0), o ? o.startBuffer.ref.value : new Float32Array(0), o ? o.endBuffer.ref.value : new Float32Array(0), 0, o);
  }
  function n(o) {
    return ro([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 = E0(), d = l.position, f = o.startBuffer.ref.value, h = o.endBuffer.ref.value, m = s.aTransform.ref.value;
    return gi(u, c, 2, function(p, v) {
      var g = p % 4 == 0 ? f : h;
      return v < 0 ? E.fromArray(d, g, 3 * p) : E.transformMat4Offset(d, g, m, 0, 3 * p, 16 * v), l;
    });
  }
  function a(o, s, u, c, l) {
    var d = u.instanceCount, f = u.groupCount, h = vs(u, i(o, s), c.color), m = Bl(u, c.size), p = ou(d * f), v = gl(), g = vl(), y = bl(), b = yl(), S = { drawCount: 2 * o.lineCount * 3, vertexCount: 4 * o.lineCount, groupCount: f, instanceCount: d }, _ = Me.clone(o.boundingSphere), x = aa(_, s.aTransform.ref.value, d);
    return O(O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("lines"), aMapping: o.mappingBuffer, aGroup: o.groupBuffer, aStart: o.startBuffer, aEnd: o.endBuffer, elements: o.indexBuffer, boundingSphere: G.create(x), invariantBoundingSphere: G.create(_), uInvariantBoundingSphere: G.create(Ut.ofSphere(_)) }, h), m), p), v), g), y), b), s), ft.createValues(l, S)), { uSizeFactor: G.create(l.sizeFactor), dLineSizeAttenuation: G.create(l.lineSizeAttenuation), uDoubleSided: G.create(!0), dFlipSided: G.create(!1) });
  }
  t.create = e, t.createEmpty = r, t.fromMesh = function(o, s) {
    for (var u = o.vertexBuffer.ref.value, c = o.indexBuffer.ref.value, l = o.groupBuffer.ref.value, d = Ea.create(3 * o.triangleCount, o.triangleCount / 10, s), f = 0, h = 3 * o.triangleCount; f < h; f += 3) {
      var m = c[f], p = c[f + 1], v = c[f + 2], g = u[3 * m], y = u[3 * m + 1], b = u[3 * m + 2], S = u[3 * p], _ = u[3 * p + 1], x = u[3 * p + 2], C = u[3 * v], A = u[3 * v + 1], w = u[3 * v + 2];
      d.add(g, y, b, S, _, x, l[m]), d.add(g, y, b, C, A, w, l[m]), d.add(S, _, x, C, A, w, l[p]);
    }
    return d.getLines();
  }, t.transform = function(o, s) {
    var u = o.startBuffer.ref.value;
    wp(s, u, 0, 4 * o.lineCount), G.update(o.startBuffer, u);
    var c = o.endBuffer.ref.value;
    wp(s, c, 0, 4 * o.lineCount), G.update(o.endBuffer, c);
  }, t.Params = O(O({}, ft.Params), { sizeFactor: z.Numeric(2, { min: 0, max: 10, step: 0.1 }), lineSizeAttenuation: z.Boolean(!1) }), t.Utils = { Params: t.Params, createEmpty: r, createValues: a, createValuesSimple: function(o, s, u, c, l) {
    var d = ft.createSimple(u, c, l), f = O(O({}, z.getDefaultValues(t.Params)), s);
    return a(o, d.transform, d.locationIterator, d.theme, f);
  }, updateValues: function(o, s) {
    ft.updateValues(o, s), G.updateIfChanged(o.uSizeFactor, s.sizeFactor), G.updateIfChanged(o.dLineSizeAttenuation, s.lineSizeAttenuation);
  }, updateBoundingSphere: function(o, s) {
    var u = Me.clone(s.boundingSphere), c = aa(u, o.aTransform.ref.value, o.instanceCount.ref.value);
    Me.equals(c, o.boundingSphere.ref.value) || G.update(o.boundingSphere, c), Me.equals(u, o.invariantBoundingSphere.ref.value) || (G.update(o.invariantBoundingSphere, u), G.update(o.uInvariantBoundingSphere, Ut.fromSphere(o.uInvariantBoundingSphere.ref.value, u)));
  }, createRenderableState: ft.createRenderableState, updateRenderableState: ft.updateRenderableState, createPositionIterator: i };
}(Rr || (Rr = {}));
var ZE = E(), QE = E(), JE = E();
function iO(t, e) {
  for (var r = e.length, n = b2(r / 3), i = 0; i < r; i += 3) E.fromArray(ZE, t, 3 * e[i]), E.fromArray(QE, t, 3 * e[i + 1]), E.fromArray(JE, t, 3 * e[i + 2]), n.add(ZE, QE, JE);
  return n.getPrimitive();
}
var rv = E();
function b2(t, e) {
  e === void 0 && (e = 3 * t);
  var r = new Float32Array(3 * e), n = new Float32Array(3 * e), i = new Uint32Array(3 * t), a = 0, o = 0;
  return { add: function(s, u, c) {
    E.toArray(s, r, a), E.toArray(u, r, a + 3), E.toArray(c, r, a + 6), E.triangleNormal(rv, s, u, c);
    for (var l = 0; l < 3; ++l) E.toArray(rv, n, a + 3 * l), i[o + l] = a / 3 + l;
    a += 9, o += 3;
  }, addQuad: function(s, u, c, l) {
    E.toArray(s, r, a), E.toArray(u, r, a + 3), E.toArray(c, r, a + 6), E.toArray(l, r, a + 9), E.triangleNormal(rv, s, u, c);
    for (var d = 0; d < 4; ++d) E.toArray(rv, n, a + 3 * d);
    var f = a / 3;
    i[o] = f, i[o + 1] = f + 1, i[o + 2] = f + 2, i[o + 3] = f + 2, i[o + 4] = f + 3, i[o + 5] = f, a += 12, o += 6;
  }, getPrimitive: function() {
    return { vertices: r, normals: n, indices: i };
  } };
}
var S1 = E(), are = Wi();
function zy(t, e) {
  for (var r = t.vertices, n = t.normals, i = Wi.directionTransform(are, e), a = 0, o = r.length; a < o; a += 3) E.transformMat4(S1, E.fromArray(S1, r, a), e), E.toArray(S1, r, a), E.transformMat3(S1, E.fromArray(S1, n, a), i), E.toArray(S1, n, a);
  return t;
}
function Vy(t, e, r) {
  r === void 0 && (r = -1);
  for (var n = new Float32Array(3 * t), i = r === -1 ? t <= 4 ? Math.sqrt(2) / 2 : 0.6 : r, a = e ? 1 : 0, o = 0, s = t; o < s; ++o) {
    var u = (2 * o + a) / t * Math.PI;
    n[3 * o] = Math.cos(u) * i, n[3 * o + 1] = Math.sin(u) * i, n[3 * o + 2] = 0;
  }
  return n;
}
function Uy(t) {
  return { vertices: new Float32Array(t.vertices), edges: new Uint32Array(t.edges) };
}
var _b = E.zero();
function Hy(t, e) {
  for (var r = t.vertices, n = 0, i = r.length; n < i; n += 3) E.transformMat4(_b, E.fromArray(_b, r, n), e), E.toArray(_b, r, n);
  return t;
}
var xb, Sb, Lo, Cb, Ab, or, C1 = E(), A1 = E(), w1 = E(), D1 = E(), ti = Vy(4, !0);
function aO() {
  return xb || (xb = function(t) {
    for (var e = b2(12, 24), r = 0; r < 4; ++r) {
      var n = (r + 1) % 4;
      E.set(C1, ti[3 * r], ti[3 * r + 1], -0.5), E.set(A1, ti[3 * n], ti[3 * n + 1], -0.5), E.set(w1, ti[3 * n], ti[3 * n + 1], 0.5), E.set(D1, ti[3 * r], ti[3 * r + 1], 0.5), e.addQuad(C1, A1, w1, D1);
    }
    return E.set(C1, ti[0], ti[1], -0.5), E.set(A1, ti[3], ti[4], -0.5), E.set(w1, ti[6], ti[7], -0.5), E.set(D1, ti[9], ti[10], -0.5), e.addQuad(D1, w1, A1, C1), E.set(C1, ti[0], ti[1], 0.5), E.set(A1, ti[3], ti[4], 0.5), E.set(w1, ti[6], ti[7], 0.5), E.set(D1, ti[9], ti[10], 0.5), e.addQuad(C1, A1, w1, D1), e.getPrimitive();
  }()), xb;
}
function oO() {
  return Sb || (Sb = /* @__PURE__ */ function(t, e) {
    return { vertices: t, edges: e };
  }([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])), Sb;
}
function $E(t) {
  return t.map(function(e) {
    return { x: e[0], alpha: e[1] };
  });
}
function eI(t, e) {
  for (var r, n, i, a, o, s, u = Ze(Ze([{ x: 0, alpha: 0 }, { x: 0, alpha: 0 }], t, !0), [{ x: 1, alpha: 0 }, { x: 1, alpha: 0 }], !1), c = e ? e.ref.value.array : new Uint8Array(256), l = 0, d = t.length + 1, f = 0; f < d; ++f) {
    r = u[f + 1].x, n = u[f + 2].x, i = u[f].alpha, a = u[f + 1].alpha, o = u[f + 2].alpha, s = u[f + 3].alpha;
    for (var h = Math.round(256 * (n - r)), m = 0; m < h; ++m) {
      var p = m / h;
      c[l] = Math.max(0, 255 * Jv(i, a, o, s, p, 0.5)), ++l;
    }
  }
  var v = { array: c, width: 256, height: 1 };
  return e ? (G.update(e, v), e) : G.create(v);
}
function tI(t, e, r, n) {
  var i = (n - r) / e;
  i === 0 && (i = 1);
  for (var a = new Int32Array(e), o = 0, s = t.length; o < s; o++) {
    var u = Math.floor((t[o] - r) / i);
    u >= e ? u = e - 1 : u < 0 && (u = 0), a[u]++;
  }
  return { min: r, max: n, binWidth: i, counts: a };
}
(function(t) {
  t.One = { transform: { kind: "matrix", matrix: he.identity() }, cells: Qn.create(Qn.Space([1, 1, 1], [0, 1, 2]), Qn.Data1([0])), stats: { min: 0, max: 0, mean: 0, sigma: 0 } };
  var e = he.zero(), r = he.zero();
  t.getGridToCartesianTransform = function(n) {
    if (n.transform.kind === "matrix") return he.copy(he(), n.transform.matrix);
    if (n.transform.kind === "spacegroup") {
      var i = n.cells.space, a = he.fromScaling(e, E.div(E.zero(), $r.size(E.zero(), n.transform.fractionalBox), E.ofArray(i.dimensions))), o = he.fromTranslation(r, n.transform.fractionalBox.min);
      return he.mul3(he.zero(), n.transform.cell.fromFractional, o, a);
    }
    return he.identity();
  }, t.areEquivalent = function(n, i) {
    return n === i;
  }, t.isEmpty = function(n) {
    return n.cells.data.length === 0;
  }, t.getBoundingSphere = function(n, i) {
    i || (i = Me());
    var a = n.cells.space.dimensions, o = t.getGridToCartesianTransform(n);
    return Me.fromDimensionsAndTransform(i, a, o);
  }, t.getHistogram = function(n, i) {
    var a = n._historams;
    return a || (a = n._historams = {}), a[i] || (a[i] = function(o, s, u) {
      if (u) return tI(o, s, u.min, u.max);
      var c = os(o);
      return tI(o, s, c[0], c[1]);
    }(n.cells.data, i, { min: n.stats.min, max: n.stats.max })), a[i];
  };
})(Lo || (Lo = {})), function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "cube";
  }, t.create = function(e) {
    return { kind: "cube", name: e.name, data: e };
  };
}(Cb || (Cb = {})), function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "dscif";
  }, t.create = function(e) {
    return { kind: "dscif", name: e._name, data: e };
  };
}(Ab || (Ab = {})), function(t) {
  var e;
  t.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 jn(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));
    };
  }(e = t.IsoValue || (t.IsoValue = {})), t.adjustedIsoValue = function(a, o, s) {
    if (s === "relative") return e.relative(o);
    var u = e.absolute(o);
    if (Ab.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 t.IsoValue.toRelative(u, c);
    }
    return u;
  };
  var r, n = { min: -1, max: 1, mean: 0, sigma: 0.1 };
  function i(a, o) {
    var s = o || n, u = s.min, c = s.max, l = s.mean, d = s.sigma, f = (u - l) / d, h = (c - l) / d, m = a;
    return a.kind === "absolute" ? a.absoluteValue < u ? m = t.IsoValue.absolute(u) : a.absoluteValue > c && (m = t.IsoValue.absolute(c)) : a.relativeValue < f ? m = t.IsoValue.relative(f) : a.relativeValue > h && (m = t.IsoValue.relative(h)), z.Conditioned(m, { absolute: z.Converted(function(p) {
      return t.IsoValue.toAbsolute(p, Lo.One.stats).absoluteValue;
    }, function(p) {
      return t.IsoValue.absolute(p);
    }, z.Numeric(l, { min: u, max: c, step: DD(d / 100, 2) })), relative: z.Converted(function(p) {
      return t.IsoValue.toRelative(p, Lo.One.stats).relativeValue;
    }, function(p) {
      return t.IsoValue.relative(p);
    }, z.Numeric(Math.min(1, h), { min: f, max: h, step: DD(Math.round((c - u) / d) / 100, 2) })) }, function(p) {
      return p.kind === "absolute" ? "absolute" : "relative";
    }, function(p, v) {
      return v === "absolute" ? t.IsoValue.toAbsolute(p, s) : t.IsoValue.toRelative(p, s);
    }, { isEssential: !0 });
  }
  t.createIsoValueParam = i, t.IsoValueParam = i(t.IsoValue.relative(2)), t.One = { label: "", grid: Lo.One, sourceData: { kind: "", name: "", data: {} }, customProperties: new jp(), _propertyData: /* @__PURE__ */ Object.create(null) }, t.areEquivalent = function(a, o) {
    return Lo.areEquivalent(a.grid, o.grid);
  }, t.isEmpty = function(a) {
    return Lo.isEmpty(a.grid);
  }, t.isOrbitals = function(a) {
    return !!Cb.is(a.sourceData) && a.sourceData.data.header.orbitals;
  }, t.Loci = function(a) {
    return { kind: "volume-loci", volume: a };
  }, t.isLoci = function(a) {
    return !!a && a.kind === "volume-loci";
  }, t.areLociEqual = function(a, o) {
    return a.volume === o.volume;
  }, t.isLociEmpty = function(a) {
    return Lo.isEmpty(a.volume.grid);
  }, t.getBoundingSphere = function(a, o) {
    return Lo.getBoundingSphere(a.grid, o);
  }, (r = t.Isosurface || (t.Isosurface = {})).Loci = function(a, o) {
    return { kind: "isosurface-loci", volume: a, isoValue: o };
  }, r.isLoci = function(a) {
    return !!a && a.kind === "isosurface-loci";
  }, r.areLociEqual = function(a, o) {
    return a.volume === o.volume && t.IsoValue.areSame(a.isoValue, o.isoValue, a.volume.grid.stats);
  }, r.isLociEmpty = function(a) {
    return a.volume.grid.cells.data.length === 0;
  }, r.getBoundingSphere = function(a, o, s) {
    return t.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 && Ge.areEqual(u.indices, c.indices);
    }, a.isLociEmpty = function(u) {
      return Ge.size(u.indices) === 0;
    };
    var o = new cu("98"), s = E();
    a.getBoundingSphere = function(u, c, l) {
      o.reset();
      for (var d = Lo.getGridToCartesianTransform(u.grid), f = u.grid.cells.space.getCoords, h = 0, m = Ge.size(c); h < m; h++)
        f(Ge.getAt(c, h), s), E.transformMat4(s, s, d), o.includePosition(s);
      for (o.finishedIncludeStep(), h = 0, m = Ge.size(c); h < m; h++)
        f(Ge.getAt(c, h), s), E.transformMat4(s, s, d), o.radiusPosition(s);
      var p = o.getSphere(l);
      return Me.expand(p, p, 10 * he.getMaxScaleOnAxis(d));
    };
  }(t.Cell || (t.Cell = {}));
}(or || (or = {}));
var U3, Gu, sf, wb = aO();
function jr(t, e, r) {
  return { type: "attribute", kind: t, itemSize: e, divisor: r };
}
function Ie(t, e) {
  return { type: "uniform", kind: t, variant: e };
}
function zt(t, e, r, n) {
  return { type: "texture", kind: t, format: e, dataType: r, filter: n };
}
function O0(t) {
  return { type: "elements", kind: t };
}
function Gt(t, e) {
  return { type: "define", kind: t, options: e };
}
function Ai(t) {
  return { type: "value", kind: t };
}
(function(t) {
  function e(u, c, l, d, f, h, m, p, v, g) {
    return g ? function(y, b, S, _, x, C, A, w, I, P) {
      var M = C.getWidth(), T = C.getHeight(), F = C.getDepth();
      return G.update(P.gridDimension, b), G.update(P.gridTexture, C), G.update(P.gridTextureDim, E.set(P.gridTextureDim.ref.value, M, T, F)), G.update(P.gridStats, Ut.set(P.gridStats.ref.value, A.min, A.max, A.mean, A.sigma)), G.update(P.bboxMin, y.min), G.update(P.bboxMax, y.max), G.update(P.bboxSize, E.sub(P.bboxSize.ref.value, y.max, y.min)), G.update(P.transform, S), G.update(P.cellDim, x), G.update(P.unitToCartn, _), G.update(P.cartnToUnit, he.invert(he(), _)), G.updateIfChanged(P.packedGroup, w), G.updateIfChanged(P.axisOrder, E.fromArray(P.axisOrder.ref.value, I, 0)), P;
    }(u, c, l, d, f, h, m, p, v, g) : function(y, b, S, _, x, C, A, w, I) {
      var P = Me(), M = -1, T = C.getWidth(), F = C.getHeight(), N = C.getDepth(), R = { kind: "direct-volume", gridDimension: G.create(b), gridTexture: G.create(C), gridTextureDim: G.create(E.create(T, F, N)), gridStats: G.create(Ut.create(A.min, A.max, A.mean, A.sigma)), bboxMin: G.create(y.min), bboxMax: G.create(y.max), bboxSize: G.create(E.sub(E(), y.max, y.min)), transform: G.create(S), cellDim: G.create(x), unitToCartn: G.create(_), cartnToUnit: G.create(he.invert(he(), _)), get boundingSphere() {
        var L = r(R);
        if (L !== M) {
          var V = function(U, H) {
            return Me.fromDimensionsAndTransform(Me(), U, H);
          }(R.gridDimension.ref.value, R.transform.ref.value);
          Me.copy(P, V), M = L;
        }
        return P;
      }, packedGroup: G.create(w), axisOrder: G.create(I), setBoundingSphere: function(L) {
        Me.copy(P, L), M = r(R);
      } };
      return R;
    }(u, c, l, d, f, h, m, p, v);
  }
  function r(u) {
    return ro([u.bboxSize.ref.version, u.gridDimension.ref.version, u.gridTexture.ref.version, u.transform.ref.version, u.gridStats.ref.version]);
  }
  function n(u) {
    return e($r(), E(), he.identity(), he.identity(), E(), zo(), Lo.One.stats, !1, E.create(0, 1, 2), u);
  }
  function i(u, c) {
    return Math.ceil(E.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, f) {
    var h = u.gridTexture, m = u.gridTextureDim, p = u.gridStats, v = u.bboxSize, g = u.bboxMin, y = u.bboxMax, b = u.gridDimension, S = u.transform, _ = l.instanceCount, x = l.groupCount, C = vs(l, t.Utils.createPositionIterator(u, c), d.color), A = ou(_ * x), w = gl(), I = vl(), P = bl(), M = yl(), T = b.ref.value, F = T[0], N = T[1], R = T[2], L = { drawCount: wb.indices.length, vertexCount: F * N * R, groupCount: x, instanceCount: _ }, V = Me.clone(u.boundingSphere), U = aa(V, c.aTransform.ref.value, _), H = eI($E(f.controlPoints));
    return O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("directVolume") }, C), A), w), I), P), M), c), ft.createValues(f, L)), { aPosition: G.create(wb.vertices), elements: G.create(wb.indices), boundingSphere: G.create(U), invariantBoundingSphere: G.create(V), uInvariantBoundingSphere: G.create(Ut.ofSphere(V)), uBboxMin: g, uBboxMax: y, uBboxSize: v, uMaxSteps: G.create(i(b.ref.value, f.stepsPerCell)), uStepScale: G.create(a(u.cellDim.ref.value, f.stepsPerCell)), uJumpLength: G.create(f.jumpLength), uTransform: S, uGridDim: b, tTransferTex: H, uTransferScale: G.create(o(f.stepsPerCell)), dGridTexType: G.create(h.ref.value.getDepth() > 0 ? "3d" : "2d"), uGridTexDim: m, tGridTex: h, uGridStats: p, uCellDim: u.cellDim, uCartnToUnit: u.cartnToUnit, uUnitToCartn: u.unitToCartn, dPackedGroup: u.packedGroup, dAxisOrder: G.create(u.axisOrder.ref.value.join("")), dIgnoreLight: G.create(f.ignoreLight), dXrayShaded: G.create(f.xrayShaded) });
  }
  t.create = e, t.createEmpty = n, t.Params = O(O({}, ft.Params), { ignoreLight: z.Boolean(!1, ft.ShadingCategory), xrayShaded: z.Boolean(!1, ft.ShadingCategory), controlPoints: z.LineGraph([ze.create(0.19, 0), ze.create(0.2, 0.05), ze.create(0.25, 0.05), ze.create(0.26, 0), ze.create(0.79, 0), ze.create(0.8, 0.05), ze.create(0.85, 0.05), ze.create(0.86, 0)], { isEssential: !0 }), stepsPerCell: z.Numeric(3, { min: 1, max: 10, step: 1 }), jumpLength: z.Numeric(0, { min: 0, max: 20, step: 0.1 }) }), t.Utils = { Params: t.Params, createEmpty: n, createValues: s, createValuesSimple: function(u, c, l, d, f) {
    var h = ft.createSimple(l, d, f), m = O(O({}, z.getDefaultValues(t.Params)), c);
    return s(u, h.transform, h.locationIterator, h.theme, m);
  }, updateValues: function(u, c) {
    ft.updateValues(u, c), G.updateIfChanged(u.dIgnoreLight, c.ignoreLight), G.updateIfChanged(u.dXrayShaded, c.xrayShaded), eI($E(c.controlPoints), u.tTransferTex), G.updateIfChanged(u.uMaxSteps, i(u.uGridDim.ref.value, c.stepsPerCell)), G.updateIfChanged(u.uStepScale, a(u.uCellDim.ref.value, c.stepsPerCell)), G.updateIfChanged(u.uTransferScale, o(c.stepsPerCell)), G.updateIfChanged(u.uJumpLength, c.jumpLength);
  }, updateBoundingSphere: function(u, c) {
    var l = Me.clone(c.boundingSphere), d = aa(l, u.aTransform.ref.value, u.instanceCount.ref.value);
    Me.equals(d, u.boundingSphere.ref.value) || G.update(u.boundingSphere, d), Me.equals(l, u.invariantBoundingSphere.ref.value) || (G.update(u.invariantBoundingSphere, l), G.update(u.uInvariantBoundingSphere, Ut.fromSphere(u.uInvariantBoundingSphere.ref.value, l)));
  }, createRenderableState: function(u) {
    var c = ft.createRenderableState(u);
    return c.opaque = !1, c.writeDepth = !1, c;
  }, updateRenderableState: function(u, c) {
    ft.updateRenderableState(u, c), u.opaque = !1, u.writeDepth = !1;
  }, createPositionIterator: function(u, c) {
    var l = u.transform.ref.value, d = u.gridDimension.ref.value, f = d[0], h = d[1], m = d[2], p = f * h * m, v = c.instanceCount.ref.value, g = E0(), y = g.position, b = c.aTransform.ref.value;
    return gi(p, v, 1, function(S, _) {
      var x = Math.floor(S / m);
      return y[0] = Math.floor(x / h), y[1] = x % h, y[2] = S % m, E.transformMat4(y, y, l), _ >= 0 && E.transformMat4Offset(y, y, b, 0, 0, 16 * _), g;
    });
  } };
})(U3 || (U3 = {})), function(t) {
  function e(s, u, c, l, d, f) {
    return f ? function(h, m, p, v, g, y) {
      return g > y.sphereCount && (G.update(y.mappingBuffer, m), G.update(y.indexBuffer, p)), y.sphereCount = g, G.update(y.centerBuffer, h), G.update(y.groupBuffer, v), y;
    }(s, u, c, l, d, f) : function(h, m, p, v, g) {
      var y, b = Me(), S = -1, _ = -1, x = { kind: "spheres", sphereCount: g, centerBuffer: G.create(h), mappingBuffer: G.create(m), indexBuffer: G.create(p), groupBuffer: G.create(v), get boundingSphere() {
        var C = n(x);
        if (C !== S) {
          var A = of(x.centerBuffer.ref.value, 4 * x.sphereCount, 4);
          Me.copy(b, A), S = C;
        }
        return b;
      }, get groupMapping() {
        return x.groupBuffer.ref.version !== _ && (y = $p(x.groupBuffer.ref.value, x.sphereCount, 4), _ = x.groupBuffer.ref.version), y;
      }, setBoundingSphere: function(C) {
        Me.copy(b, C), S = n(x);
      } };
      return x;
    }(s, u, c, l, d);
  }
  function r(s) {
    return e(s ? s.centerBuffer.ref.value : new Float32Array(0), s ? s.mappingBuffer.ref.value : new Float32Array(0), s ? s.indexBuffer.ref.value : new Uint32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function n(s) {
    return ro([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 = E0(), f = d.position, h = s.centerBuffer.ref.value, m = u.aTransform.ref.value;
    return gi(c, l, 4, function(p, v) {
      return v < 0 ? E.fromArray(f, h, 3 * p) : E.transformMat4Offset(f, h, m, 0, 3 * p, 16 * v), d;
    });
  }
  function a(s, u, c, l, d) {
    var f = c.instanceCount, h = c.groupCount, m = vs(c, i(s, u), l.color), p = Bl(c, l.size), v = ou(f * h), g = gl(), y = vl(), b = bl(), S = yl(), _ = { drawCount: 2 * s.sphereCount * 3, vertexCount: 4 * s.sphereCount, groupCount: h, instanceCount: f }, x = s.boundingSphere.radius ? Wm(p) * d.sizeFactor : 0, C = Me.expand(Me(), s.boundingSphere, x), A = aa(C, u.aTransform.ref.value, f);
    return O(O(O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("spheres"), aPosition: s.centerBuffer, aMapping: s.mappingBuffer, aGroup: s.groupBuffer, elements: s.indexBuffer, boundingSphere: G.create(A), invariantBoundingSphere: G.create(C), uInvariantBoundingSphere: G.create(Ut.ofSphere(C)) }, m), p), v), g), y), b), S), u), { padding: G.create(x) }), ft.createValues(d, _)), { uSizeFactor: G.create(d.sizeFactor), uDoubleSided: G.create(d.doubleSided), dIgnoreLight: G.create(d.ignoreLight), dXrayShaded: G.create(d.xrayShaded), uBumpFrequency: G.create(d.bumpFrequency), uBumpAmplitude: G.create(d.bumpAmplitude) });
  }
  function o(s, u) {
    ft.updateRenderableState(s, u), s.opaque = s.opaque && !u.xrayShaded, s.writeDepth = s.opaque;
  }
  t.create = e, t.createEmpty = r, t.Params = O(O({}, ft.Params), { sizeFactor: z.Numeric(1, { min: 0, max: 10, step: 0.1 }), doubleSided: z.Boolean(!1, ft.CustomQualityParamInfo), ignoreLight: z.Boolean(!1, ft.ShadingCategory), xrayShaded: z.Boolean(!1, ft.ShadingCategory), bumpFrequency: z.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), bumpAmplitude: z.Numeric(1, { min: 0, max: 5, step: 0.1 }, ft.ShadingCategory) }), t.Utils = { Params: t.Params, createEmpty: r, createValues: a, createValuesSimple: function(s, u, c, l, d) {
    var f = ft.createSimple(c, l, d), h = O(O({}, z.getDefaultValues(t.Params)), u);
    return a(s, f.transform, f.locationIterator, f.theme, h);
  }, updateValues: function(s, u) {
    ft.updateValues(s, u), G.updateIfChanged(s.uSizeFactor, u.sizeFactor), G.updateIfChanged(s.uDoubleSided, u.doubleSided), G.updateIfChanged(s.dIgnoreLight, u.ignoreLight), G.updateIfChanged(s.dXrayShaded, u.xrayShaded), G.updateIfChanged(s.uBumpFrequency, u.bumpFrequency), G.updateIfChanged(s.uBumpAmplitude, u.bumpAmplitude);
  }, updateBoundingSphere: function(s, u) {
    var c = u.boundingSphere.radius ? Wm(s) * s.uSizeFactor.ref.value : 0, l = Me.expand(Me(), u.boundingSphere, c), d = aa(l, s.aTransform.ref.value, s.instanceCount.ref.value);
    Me.equals(d, s.boundingSphere.ref.value) || G.update(s.boundingSphere, d), Me.equals(l, s.invariantBoundingSphere.ref.value) || (G.update(s.invariantBoundingSphere, l), G.update(s.uInvariantBoundingSphere, Ut.fromSphere(s.uInvariantBoundingSphere.ref.value, l))), G.update(s.padding, c);
  }, createRenderableState: function(s) {
    var u = ft.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: i };
}(Gu || (Gu = {})), function(t) {
  var e = 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 r(a, o, s, u, c, l, d) {
    var f = s.getWidth(), h = s.getHeight();
    return d ? (d.vertexCount = a, d.groupCount = o, G.update(d.geoTextureDim, ze.set(d.geoTextureDim.ref.value, f, h)), G.update(d.vertexTexture, s), G.update(d.groupTexture, u), G.update(d.normalTexture, c), d.doubleBuffer.set(s, u, c), Me.copy(d.boundingSphere, l), d) : { kind: "texture-mesh", vertexCount: a, groupCount: o, geoTextureDim: G.create(ze.create(f, h)), vertexTexture: G.create(s), groupTexture: G.create(u), normalTexture: G.create(c), doubleBuffer: new e(), boundingSphere: Me.clone(l), meta: {} };
  }
  function n(a) {
    return r(0, 0, a ? a.vertexTexture.ref.value : zo(), a ? a.groupTexture.ref.value : zo(), a ? a.normalTexture.ref.value : zo(), a ? a.boundingSphere : Me(), a);
  }
  function i(a, o, s, u, c) {
    var l = s.instanceCount, d = s.groupCount, f = vs(s, t.Utils.createPositionIterator(a, o), u.color), h = ou(l * d), m = gl(), p = vl(), v = bl(), g = yl(), y = { drawCount: a.vertexCount, vertexCount: a.vertexCount, groupCount: d, instanceCount: l }, b = Me.clone(a.boundingSphere), S = aa(b, o.aTransform.ref.value, l);
    return O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("textureMesh"), uGeoTexDim: a.geoTextureDim, tPosition: a.vertexTexture, tGroup: a.groupTexture, tNormal: a.normalTexture, boundingSphere: G.create(S), invariantBoundingSphere: G.create(b), uInvariantBoundingSphere: G.create(Ut.ofSphere(b)) }, f), h), m), p), v), g), o), ft.createValues(c, y)), { uDoubleSided: G.create(c.doubleSided), dFlatShaded: G.create(c.flatShaded), dFlipSided: G.create(c.flipSided), dIgnoreLight: G.create(c.ignoreLight), dXrayShaded: G.create(c.xrayShaded), uBumpFrequency: G.create(c.bumpFrequency), uBumpAmplitude: G.create(c.bumpAmplitude), meta: G.create(a.meta) });
  }
  t.DoubleBuffer = e, t.create = r, t.createEmpty = n, t.Params = O(O({}, ft.Params), { doubleSided: z.Boolean(!1, ft.CustomQualityParamInfo), flipSided: z.Boolean(!1, ft.ShadingCategory), flatShaded: z.Boolean(!1, ft.ShadingCategory), ignoreLight: z.Boolean(!1, ft.ShadingCategory), xrayShaded: z.Boolean(!1, ft.ShadingCategory), bumpFrequency: z.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), bumpAmplitude: z.Numeric(1, { min: 0, max: 5, step: 0.1 }, ft.ShadingCategory) }), t.Utils = { Params: t.Params, createEmpty: n, createValues: i, createValuesSimple: function(a, o, s, u, c) {
    var l = ft.createSimple(s, u, c), d = O(O({}, z.getDefaultValues(t.Params)), o);
    return i(a, l.transform, l.locationIterator, l.theme, d);
  }, updateValues: function(a, o) {
    ft.updateValues(a, o), G.updateIfChanged(a.uDoubleSided, o.doubleSided), G.updateIfChanged(a.dFlatShaded, o.flatShaded), G.updateIfChanged(a.dFlipSided, o.flipSided), G.updateIfChanged(a.dIgnoreLight, o.ignoreLight), G.updateIfChanged(a.dXrayShaded, o.xrayShaded), G.updateIfChanged(a.uBumpFrequency, o.bumpFrequency), G.updateIfChanged(a.uBumpAmplitude, o.bumpAmplitude);
  }, updateBoundingSphere: function(a, o) {
    var s = Me.clone(o.boundingSphere), u = aa(s, a.aTransform.ref.value, a.instanceCount.ref.value);
    Me.equals(u, a.boundingSphere.ref.value) || G.update(a.boundingSphere, u), Me.equals(s, a.invariantBoundingSphere.ref.value) || (G.update(a.invariantBoundingSphere, s), G.update(a.uInvariantBoundingSphere, Ut.fromSphere(a.uInvariantBoundingSphere.ref.value, s)));
  }, createRenderableState: ft.createRenderableState, updateRenderableState: ft.updateRenderableState, createPositionIterator: function() {
    return gi(1, 1, 1, function() {
      return Sc;
    });
  } };
}(sf || (sf = {}));
var qc = { uModel: Ie("m4"), uView: Ie("m4"), uInvView: Ie("m4"), uModelView: Ie("m4"), uInvModelView: Ie("m4"), uProjection: Ie("m4"), uInvProjection: Ie("m4"), uModelViewProjection: Ie("m4"), uInvModelViewProjection: Ie("m4"), uIsOrtho: Ie("f"), uPixelRatio: Ie("f"), uViewport: Ie("v4"), uViewOffset: Ie("v2"), uDrawingBufferSize: Ie("v2"), uCameraPosition: Ie("v3"), uCameraDir: Ie("v3"), uNear: Ie("f"), uFar: Ie("f"), uFogNear: Ie("f"), uFogFar: Ie("f"), uFogColor: Ie("v3"), uTransparentBackground: Ie("b"), uLightDirection: Ie("v3[]"), uLightColor: Ie("v3[]"), uAmbientColor: Ie("v3"), uPickingAlphaThreshold: Ie("f"), uInteriorDarkening: Ie("f"), uInteriorColorFlag: Ie("b"), uInteriorColor: Ie("v3"), uHighlightColor: Ie("v3"), uSelectColor: Ie("v3"), uHighlightStrength: Ie("f"), uSelectStrength: Ie("f"), uMarkerPriority: Ie("i"), uXrayEdgeFalloff: Ie("f"), uRenderWboit: Ie("b"), uMarkingDepthTest: Ie("b"), uMarkingType: Ie("i"), uPickType: Ie("i"), uInvalidColor: Ie("v3"), uInvalidStrength: Ie("f") }, Kc = { tDepth: zt("texture", "depth", "ushort", "nearest") }, Xc = { uObjectId: Ie("i") }, ore = { uColor: Ie("v3", "material"), uColorTexDim: Ie("v2"), uColorGridDim: Ie("v3"), uColorGridTransform: Ie("v4"), tColor: zt("image-uint8", "rgb", "ubyte", "nearest"), tPalette: zt("image-uint8", "rgb", "ubyte", "nearest"), tColorGrid: zt("texture", "rgb", "ubyte", "linear"), dColorType: Gt("string", ["uniform", "attribute", "instance", "group", "groupInstance", "vertex", "vertexInstance", "volume", "volumeInstance", "direct"]), dUsePalette: Gt("boolean") }, _2 = { uSize: Ie("f", "material"), uSizeTexDim: Ie("v2"), tSize: zt("image-uint8", "rgb", "ubyte", "nearest"), dSizeType: Gt("string", ["uniform", "attribute", "instance", "group", "groupInstance"]), uSizeFactor: Ie("f") }, sre = { uMarker: Ie("f"), uMarkerTexDim: Ie("v2"), tMarker: zt("image-uint8", "alpha", "ubyte", "nearest"), markerAverage: Ai("number"), markerStatus: Ai("number") }, ure = { uOverpaintTexDim: Ie("v2"), tOverpaint: zt("image-uint8", "rgba", "ubyte", "nearest"), dOverpaint: Gt("boolean"), uOverpaintGridDim: Ie("v3"), uOverpaintGridTransform: Ie("v4"), tOverpaintGrid: zt("texture", "rgba", "ubyte", "linear"), dOverpaintType: Gt("string", ["groupInstance", "volumeInstance"]) }, cre = { uTransparencyTexDim: Ie("v2"), tTransparency: zt("image-uint8", "alpha", "ubyte", "nearest"), dTransparency: Gt("boolean"), transparencyAverage: Ai("number"), uTransparencyGridDim: Ie("v3"), uTransparencyGridTransform: Ie("v4"), tTransparencyGrid: zt("texture", "alpha", "ubyte", "linear"), dTransparencyType: Gt("string", ["groupInstance", "volumeInstance"]) }, lre = { uSubstanceTexDim: Ie("v2"), tSubstance: zt("image-uint8", "rgba", "ubyte", "nearest"), dSubstance: Gt("boolean"), uSubstanceGridDim: Ie("v3"), uSubstanceGridTransform: Ie("v4"), tSubstanceGrid: zt("texture", "rgba", "ubyte", "linear"), dSubstanceType: Gt("string", ["groupInstance", "volumeInstance"]) }, dre = { uClippingTexDim: Ie("v2"), tClipping: zt("image-uint8", "alpha", "ubyte", "nearest"), dClipping: Gt("boolean") }, Fl = O(O(O(O(O(O(O({ dGeometryType: Gt("string", ["cylinders", "directVolume", "image", "lines", "mesh", "points", "spheres", "text", "textureMesh"]) }, ore), sre), ure), cre), lre), dre), { dLightCount: Gt("number"), dClipObjectCount: Gt("number"), dClipVariant: Gt("string", ["instance", "pixel"]), uClipObjectType: Ie("i[]"), uClipObjectInvert: Ie("b[]"), uClipObjectPosition: Ie("v3[]"), uClipObjectRotation: Ie("v4[]"), uClipObjectScale: Ie("v3[]"), aInstance: jr("float32", 1, 1), aTransform: jr("float32", 16, 1), uAlpha: Ie("f", "material"), uMetalness: Ie("f", "material"), uRoughness: Ie("f", "material"), uBumpiness: Ie("f", "material"), uVertexCount: Ie("i"), uInstanceCount: Ie("i"), uGroupCount: Ie("i"), uInvariantBoundingSphere: Ie("v4"), drawCount: Ai("number"), instanceCount: Ai("number"), alpha: Ai("number"), matrix: Ai("m4"), transform: Ai("float32"), extraTransform: Ai("float32"), hasReflection: Ai("boolean"), boundingSphere: Ai("sphere"), invariantBoundingSphere: Ai("sphere") }), eo = `
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);
}
`, fre = io(), ux = Object.keys({ colorBlended: "", colorWboit: "", pick: "", depth: "", marking: "" }), qy = ux.filter(function(t) {
  return t !== "colorWboit";
}), pre = ux.filter(function(t) {
  return t !== "colorBlended";
}), hre = Object.keys({ compute: "" });
function rI(t, e, r, n, i) {
  return r = O(O({}, r), { dRenderVariant: G.create(e) }), i.dRenderVariant === void 0 && Object.defineProperty(i, "dRenderVariant", { value: Gt("string") }), t.resources.program(r, n, i);
}
function Yc(t, e, r, n, i, a, o) {
  return sO(t, e, r, n, i, a, o);
}
function Zi(t, e, r, n, i, a) {
  return a === void 0 && (a = -1), sO(t, e, r, n, i, a, hre);
}
function sO(t, e, r, n, i, a, o) {
  var s = fre(), u = t.stats, c = t.state, l = t.resources, d = t.extensions, f = d.instancedArrays, h = d.vertexArrayObject;
  if (i.uVertexCount) {
    var m = i.uVertexCount.ref.value;
    i.aVertex = G.create(xc(new Float32Array(m))), n.aVertex = jr("float32", 1, 0);
  }
  for (var p = function(ee, ie) {
    var ae = {}, ce = {}, de = {}, Ce = {}, De = {}, ke = {};
    return Object.keys(ee).forEach(function(He) {
      var We = ee[He];
      We.type === "attribute" && (ae[He] = ie[He]), We.type === "define" && (ce[He] = ie[He]), We.type === "texture" && ie[He] !== void 0 && (de[He] = ie[He]), We.type === "uniform" && ie[He] !== void 0 && (We.variant === "material" ? De[He] = ie[He] : We.variant === "buffered" ? ke[He] = ie[He] : Ce[He] = ie[He]);
    }), { attributeValues: ae, defineValues: ce, textureValues: de, uniformValues: Ce, materialUniformValues: De, bufferedUniformValues: ke };
  }(n, i), v = p.attributeValues, g = p.defineValues, y = p.textureValues, b = p.uniformValues, S = p.materialUniformValues, _ = p.bufferedUniformValues, x = Object.entries(b), C = Object.entries(S), A = Object.entries(_), w = Object.entries(function(ee) {
    var ie = {};
    return Object.keys(ee).forEach(function(ae) {
      ie[ae] = G.create(wl(ee[ae].ref.value));
    }), ie;
  }(_)), I = Object.entries(g), P = function(ee) {
    var ie = {};
    return Object.keys(ee).forEach(function(ae) {
      ie[ae] = ee[ae].ref.version;
    }), ie;
  }(i), M = function(ee, ie) {
    var ae = ee.gl;
    switch (ie) {
      case "points":
        return ae.POINTS;
      case "lines":
        return ae.LINES;
      case "line-strip":
        return ae.LINE_STRIP;
      case "line-loop":
        return ae.LINE_LOOP;
      case "triangles":
        return ae.TRIANGLES;
      case "triangle-strip":
        return ae.TRIANGLE_STRIP;
      case "triangle-fan":
        return ae.TRIANGLE_FAN;
    }
  }(t, e), T = {}, F = 0, N = o; F < N.length; F++) {
    var R = N[F];
    T[R] = rI(t, R, g, r, n);
  }
  var L, V = function(ee, ie, ae) {
    var ce = ee.resources, de = [];
    return Object.keys(ie).forEach(function(Ce) {
      var De = ie[Ce];
      if (De.type === "texture") {
        var ke = ae[Ce];
        if (ke) if (De.kind === "texture") de[de.length] = [Ce, ke.ref.value];
        else {
          var He = ce.texture(De.kind, De.format, De.dataType, De.filter);
          He.load(ke.ref.value), de[de.length] = [Ce, He];
        }
      }
    }), de;
  }(t, n, y), U = function(ee, ie, ae) {
    var ce = [];
    return Object.keys(ie).forEach(function(de) {
      var Ce = ie[de];
      Ce.type === "attribute" && (ce[ce.length] = [de, ee.resources.attribute(ae[de].ref.value, Ce.itemSize, Ce.divisor)]);
    }), ce;
  }(t, n, v), H = i.elements;
  H && H.ref.value && (L = l.elements(H.ref.value));
  for (var K = {}, X = 0, Y = o; X < Y.length; X++)
    R = Y[X], K[R] = h ? l.vertexArray(T[R], U, L) : null;
  var Q = i.drawCount.ref.value, J = i.instanceCount.ref.value;
  u.drawCount += Q, u.instanceCount += J, u.instancedDrawCount += J * Q;
  var te = { attributes: !1, defines: !1, elements: !1, textures: !1 }, W = !1, j = -1;
  return { id: s, materialId: a, getProgram: function(ee) {
    return T[ee];
  }, render: function(ee, ie) {
    if (Q !== 0 && J !== 0 && !t.isContextLost) {
      var ae = T[ee];
      if (ae.id === j && c.currentRenderItemId === s) ae.setUniforms(x), ie && ie.length > 0 ? (ae.bindTextures(ie, 0), ae.bindTextures(V, ie.length)) : ae.bindTextures(V, 0);
      else {
        var ce = K[ee];
        ae.id === c.currentProgramId && ae.id === j && a !== -1 && a === c.currentMaterialId || (ae.id !== c.currentProgramId && ae.use(), ae.setUniforms(C), c.currentMaterialId = a, j = ae.id), ae.setUniforms(x), ae.setUniforms(w), ie && ie.length > 0 ? (ae.bindTextures(ie, 0), ae.bindTextures(V, ie.length)) : ae.bindTextures(V, 0), ce ? (ce.bind(), L && L.bind()) : (L && L.bind(), ae.bindAttributes(U)), c.currentRenderItemId = s;
      }
      if (Pr) try {
        X9(t.gl);
      } catch (de) {
        throw new Error("Framebuffer error rendering item id ".concat(s, ": '").concat(de, "'"));
      }
      if (L ? f.drawElementsInstanced(M, Q, L._dataType, 0, J) : f.drawArraysInstanced(M, 0, Q, J), Pr) try {
        HN(t.gl);
      } catch (de) {
        throw new Error("Draw error rendering item id ".concat(s, ": '").concat(de, "'"));
      }
    }
  }, update: function() {
    if (function(Ae) {
      Ae.attributes = !1, Ae.defines = !1, Ae.elements = !1, Ae.textures = !1;
    }(te), i.aVertex) {
      var ee = i.uVertexCount.ref.value;
      i.aVertex.ref.value.length < ee && G.update(i.aVertex, xc(new Float32Array(ee)));
    }
    for (var ie = 0, ae = I.length; ie < ae; ++ie) {
      var ce = I[ie], de = ce[0];
      (re = ce[1]).ref.version !== P[de] && (te.defines = !0, P[de] = re.ref.version);
    }
    if (te.defines) for (var Ce = 0, De = o; Ce < De.length; Ce++)
      de = De[Ce], T[de].destroy(), T[de] = rI(t, de, g, r, n);
    for (i.drawCount.ref.version !== P.drawCount && (u.drawCount += i.drawCount.ref.value - Q, u.instancedDrawCount += J * i.drawCount.ref.value - J * Q, Q = i.drawCount.ref.value, P.drawCount = i.drawCount.ref.version), i.instanceCount.ref.version !== P.instanceCount && (u.instanceCount += i.instanceCount.ref.value - J, u.instancedDrawCount += i.instanceCount.ref.value * Q - J * Q, J = i.instanceCount.ref.value, P.instanceCount = i.instanceCount.ref.version), ie = 0, ae = U.length; ie < ae; ++ie) {
      var ke = U[ie], He = (de = ke[0], ke[1]);
      if ((re = v[de]).ref.version !== P[de]) {
        if (He.length >= re.ref.value.length) He.updateSubData(re.ref.value, 0, He.length);
        else {
          He.destroy();
          var We = n[de], Ne = We.itemSize, Je = We.divisor;
          U[ie][1] = l.attribute(re.ref.value, Ne, Je), te.attributes = !0;
        }
        P[de] = re.ref.version;
      }
    }
    if (L && i.elements.ref.version !== P.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), te.elements = !0), P.elements = i.elements.ref.version), te.attributes || te.defines || te.elements) for (var Re = 0, nt = o; Re < nt.length; Re++) {
      de = nt[Re];
      var ne = K[de];
      ne && ne.destroy(), K[de] = h ? l.vertexArray(T[de], U, L) : null;
    }
    for (ie = 0, ae = V.length; ie < ae; ++ie) {
      var re, le = V[ie], fe = (de = le[0], le[1]);
      (re = y[de]).ref.version !== P[de] && (n[de].kind !== "texture" ? (fe.load(re.ref.value), te.textures = !0) : V[ie][1] = re.ref.value, P[de] = re.ref.version);
    }
    for (ie = 0, ae = A.length; ie < ae; ++ie) {
      var ge = A[ie], me = (de = ge[0], ge[1]);
      me.ref.version !== P[de] && (G.update(w[ie][1], wl(me.ref.value)), P[de] = me.ref.version);
    }
    return te;
  }, destroy: function() {
    if (!W) {
      for (var ee = 0, ie = o; ee < ie.length; ee++) {
        var ae = ie[ee];
        T[ae].destroy();
        var ce = K[ae];
        ce && ce.destroy();
      }
      V.forEach(function(de) {
        var Ce = de[0], De = de[1];
        n[Ce].kind !== "texture" && De.destroy();
      }), U.forEach(function(de) {
        return de[0], de[1].destroy();
      }), L && L.destroy(), u.drawCount -= Q, u.instanceCount -= J, u.instancedDrawCount -= J * Q, W = !0;
    }
  } };
}
var uO = io();
function Wc(t, e, r) {
  return { id: uO(), materialId: t.materialId, values: e, state: r, render: function(n, i) {
    e.uAlpha && e.alpha && G.updateIfChanged(e.uAlpha, _o(e.alpha.ref.value * r.alphaFactor, 0, 1)), t.render(n, i);
  }, getProgram: function(n) {
    return t.getProgram(n);
  }, update: function() {
    return t.update();
  }, dispose: function() {
    return t.destroy();
  } };
}
function Qi(t, e) {
  return { id: uO(), values: e, render: function() {
    return t.render("compute");
  }, update: function() {
    return t.update();
  }, dispose: function() {
    return t.destroy();
  } };
}
var cO = new Float32Array([1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1]), la = { drawCount: Ai("number"), instanceCount: Ai("number"), aPosition: jr("float32", 2, 0), uQuadScale: Ie("v2") }, ua = { drawCount: G.create(6), instanceCount: G.create(1), aPosition: G.create(cO), uQuadScale: G.create(ze.create(1, 1)) }, mre = O(O({}, la), { tColor: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2") }), gre = Nn("copy", eo, `
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 t7(t, e) {
  var r = O(O({}, ua), { tColor: G.create(e), uTexSize: G.create(ze.create(e.getWidth(), e.getHeight())) }), n = O({}, mre);
  return Qi(Zi(t, "triangles", gre, n, r), r);
}
var Db, to, Ia, nI = new Uint32Array([0, 1, 2, 1, 3, 2]), vre = new Float32Array([0, 1, 0, 0, 1, 1, 1, 0]), lO = { nearest: "Nearest", catmulrom: "Catmulrom (Cubic)", mitchell: "Mitchell (Cubic)", bspline: "B-Spline (Cubic)" }, yre = Object.keys(lO);
(function(t) {
  function e(i, a, o, s) {
    return s ? function(u, c, l, d) {
      var f = u.width, h = u.height;
      return G.update(d.imageTexture, u), G.update(d.imageTextureDim, ze.set(d.imageTextureDim.ref.value, f, h)), G.update(d.cornerBuffer, c), G.update(d.groupTexture, l), d;
    }(i, a, o, s) : function(u, c, l) {
      var d = Me(), f = -1, h = u.width, m = u.height, p = { kind: "image", imageTexture: G.create(u), imageTextureDim: G.create(ze.create(h, m)), cornerBuffer: G.create(c), groupTexture: G.create(l), get boundingSphere() {
        var v = function(y) {
          return ro([y.cornerBuffer.ref.version]);
        }(p);
        if (v !== f) {
          var g = function(y) {
            for (var b = E(), S = [], _ = 0, x = y.length; _ < x; _ += 3) {
              var C = E.fromArray(E(), y, _);
              S.push(C), E.add(b, b, C);
            }
            E.scale(b, b, 1 / (y.length / 3));
            for (var A = 0, w = 0, I = S; w < I.length; w++) {
              C = I[w];
              var P = E.distance(b, C);
              P > A && (A = P);
            }
            var M = Me.create(b, A);
            return Me.setExtrema(M, S), M;
          }(p.cornerBuffer.ref.value);
          Me.copy(d, g), f = v;
        }
        return d;
      } };
      return p;
    }(i, a, o);
  }
  function r(i) {
    return e(qi(0, 4, Uint8Array), i ? i.cornerBuffer.ref.value : new Float32Array(24), qi(0, 4, Uint8Array), i);
  }
  function n(i, a, o, s, u) {
    var c = o.instanceCount, l = o.groupCount, d = vs(o, t.Utils.createPositionIterator(i, a), s.color), f = ou(c * l), h = gl(), m = vl(), p = bl(), v = yl(), g = { drawCount: nI.length, vertexCount: cO.length / 3, groupCount: l, instanceCount: c }, y = Me.clone(i.boundingSphere), b = aa(y, a.aTransform.ref.value, c);
    return O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("image") }, d), f), h), m), p), v), a), ft.createValues(u, g)), { aPosition: i.cornerBuffer, aUv: G.create(vre), elements: G.create(nI), aGroup: G.create(xc(new Float32Array(4))), boundingSphere: G.create(b), invariantBoundingSphere: G.create(y), uInvariantBoundingSphere: G.create(Ut.ofSphere(y)), dInterpolation: G.create(u.interpolation), uImageTexDim: i.imageTextureDim, tImageTex: i.imageTexture, tGroupTex: i.groupTexture });
  }
  t.create = e, t.createEmpty = r, t.Params = O(O({}, ft.Params), { interpolation: z.Select("bspline", z.objectToOptions(lO)) }), t.Utils = { Params: t.Params, createEmpty: r, createValues: n, createValuesSimple: function(i, a, o, s, u) {
    var c = ft.createSimple(o, s, u), l = O(O({}, z.getDefaultValues(t.Params)), a);
    return n(i, c.transform, c.locationIterator, c.theme, l);
  }, updateValues: function(i, a) {
    ft.updateValues(i, a), G.updateIfChanged(i.dInterpolation, a.interpolation);
  }, updateBoundingSphere: function(i, a) {
    var o = Me.clone(a.boundingSphere), s = aa(o, i.aTransform.ref.value, i.instanceCount.ref.value);
    Me.equals(s, i.boundingSphere.ref.value) || G.update(i.boundingSphere, s), Me.equals(o, i.invariantBoundingSphere.ref.value) || (G.update(i.invariantBoundingSphere, o), G.update(i.uInvariantBoundingSphere, Ut.fromSphere(i.uInvariantBoundingSphere.ref.value, o)));
  }, createRenderableState: function(i) {
    var a = ft.createRenderableState(i);
    return a.opaque = !1, a;
  }, updateRenderableState: function(i, a) {
    ft.updateRenderableState(i, a), i.opaque = !1;
  }, createPositionIterator: function() {
    return gi(1, 1, 1, function() {
      return Sc;
    });
  } };
})(Db || (Db = {})), function(t) {
  function e(s, u, c, l, d, f, h, m, p) {
    return p ? function(v, g, y, b, S, _, x, C, A) {
      return C > A.cylinderCount && (G.update(A.mappingBuffer, v), G.update(A.indexBuffer, g)), A.cylinderCount = C, G.update(A.groupBuffer, y), G.update(A.startBuffer, b), G.update(A.endBuffer, S), G.update(A.scaleBuffer, _), G.update(A.capBuffer, x), A;
    }(s, u, c, l, d, f, h, m, p) : function(v, g, y, b, S, _, x, C) {
      var A, w = Me(), I = -1, P = -1, M = { kind: "cylinders", cylinderCount: C, mappingBuffer: G.create(v), indexBuffer: G.create(g), groupBuffer: G.create(y), startBuffer: G.create(b), endBuffer: G.create(S), scaleBuffer: G.create(_), capBuffer: G.create(x), get boundingSphere() {
        var T = n(M);
        if (T !== I) {
          var F = of(M.startBuffer.ref.value, 6 * M.cylinderCount, 6), N = of(M.endBuffer.ref.value, 6 * M.cylinderCount, 6);
          Me.expandBySphere(w, F, N), I = T;
        }
        return w;
      }, get groupMapping() {
        return M.groupBuffer.ref.version !== P && (A = $p(M.groupBuffer.ref.value, M.cylinderCount, 6), P = M.groupBuffer.ref.version), A;
      }, setBoundingSphere: function(T) {
        Me.copy(w, T), I = n(M);
      } };
      return M;
    }(s, u, c, l, d, f, h, m);
  }
  function r(s) {
    return e(s ? s.mappingBuffer.ref.value : new Float32Array(0), s ? s.indexBuffer.ref.value : new Uint32Array(0), s ? s.groupBuffer.ref.value : new Float32Array(0), s ? s.startBuffer.ref.value : new Float32Array(0), s ? s.endBuffer.ref.value : new Float32Array(0), s ? s.scaleBuffer.ref.value : new Float32Array(0), s ? s.capBuffer.ref.value : new Float32Array(0), 0, s);
  }
  function n(s) {
    return ro([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 = E0(), f = d.position, h = s.startBuffer.ref.value, m = s.endBuffer.ref.value, p = u.aTransform.ref.value;
    return gi(c, l, 2, function(v, g) {
      var y = v % 6 == 0 ? h : m;
      return g < 0 ? E.fromArray(f, y, 3 * v) : E.transformMat4Offset(f, y, p, 0, 3 * v, 16 * g), d;
    });
  }
  function a(s, u, c, l, d) {
    var f = c.instanceCount, h = c.groupCount, m = vs(c, i(s, u), l.color), p = Bl(c, l.size), v = ou(f * h), g = gl(), y = vl(), b = bl(), S = yl(), _ = { drawCount: 4 * s.cylinderCount * 3, vertexCount: 6 * s.cylinderCount, groupCount: h, instanceCount: f }, x = Wm(p) * d.sizeFactor, C = Me.clone(s.boundingSphere), A = aa(C, u.aTransform.ref.value, f);
    return O(O(O(O(O(O(O(O(O(O(O({ dGeometryType: G.create("cylinders"), aMapping: s.mappingBuffer, aGroup: s.groupBuffer, aStart: s.startBuffer, aEnd: s.endBuffer, aScale: s.scaleBuffer, aCap: s.capBuffer, elements: s.indexBuffer, boundingSphere: G.create(A), invariantBoundingSphere: G.create(C), uInvariantBoundingSphere: G.create(Ut.ofSphere(C)) }, m), p), v), g), y), b), S), u), { padding: G.create(x) }), ft.createValues(d, _)), { uSizeFactor: G.create(d.sizeFactor * d.sizeAspectRatio), uDoubleSided: G.create(d.doubleSided), dIgnoreLight: G.create(d.ignoreLight), dXrayShaded: G.create(d.xrayShaded), uBumpFrequency: G.create(d.bumpFrequency), uBumpAmplitude: G.create(d.bumpAmplitude) });
  }
  function o(s, u) {
    ft.updateRenderableState(s, u), s.opaque = s.opaque && !u.xrayShaded, s.writeDepth = s.opaque;
  }
  t.create = e, t.createEmpty = r, t.transform = function(s, u) {
    var c = s.startBuffer.ref.value;
    wp(u, c, 0, 6 * s.cylinderCount), G.update(s.startBuffer, c);
    var l = s.endBuffer.ref.value;
    wp(u, l, 0, 6 * s.cylinderCount), G.update(s.endBuffer, l);
  }, t.Params = O(O({}, ft.Params), { sizeFactor: z.Numeric(1, { min: 0, max: 10, step: 0.1 }), sizeAspectRatio: z.Numeric(1, { min: 0, max: 3, step: 0.01 }), doubleSided: z.Boolean(!1, ft.CustomQualityParamInfo), ignoreLight: z.Boolean(!1, ft.ShadingCategory), xrayShaded: z.Boolean(!1, ft.ShadingCategory), bumpFrequency: z.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), bumpAmplitude: z.Numeric(1, { min: 0, max: 5, step: 0.1 }, ft.ShadingCategory) }), t.Utils = { Params: t.Params, createEmpty: r, createValues: a, createValuesSimple: function(s, u, c, l, d) {
    var f = ft.createSimple(c, l, d), h = O(O({}, z.getDefaultValues(t.Params)), u);
    return a(s, f.transform, f.locationIterator, f.theme, h);
  }, updateValues: function(s, u) {
    ft.updateValues(s, u), G.updateIfChanged(s.uSizeFactor, u.sizeFactor * u.sizeAspectRatio), G.updateIfChanged(s.uDoubleSided, u.doubleSided), G.updateIfChanged(s.dIgnoreLight, u.ignoreLight), G.updateIfChanged(s.dXrayShaded, u.xrayShaded), G.updateIfChanged(s.uBumpFrequency, u.bumpFrequency), G.updateIfChanged(s.uBumpAmplitude, u.bumpAmplitude);
  }, updateBoundingSphere: function(s, u) {
    var c = Me.clone(u.boundingSphere), l = aa(c, s.aTransform.ref.value, s.instanceCount.ref.value);
    Me.equals(l, s.boundingSphere.ref.value) || G.update(s.boundingSphere, l), Me.equals(c, s.invariantBoundingSphere.ref.value) || (G.update(s.invariantBoundingSphere, c), G.update(s.uInvariantBoundingSphere, Ut.fromSphere(s.uInvariantBoundingSphere.ref.value, c)));
  }, createRenderableState: function(s) {
    var u = ft.createRenderableState(s);
    return o(u, s), u;
  }, updateRenderableState: o, createPositionIterator: i };
}(to || (to = {})), function(t) {
  function e(r) {
    switch (r.kind) {
      case "mesh":
        return 3 * r.triangleCount;
      case "points":
        return r.pointCount;
      case "spheres":
        return 2 * r.sphereCount * 3;
      case "cylinders":
        return 4 * r.cylinderCount * 3;
      case "text":
        return 2 * r.charCount * 3;
      case "lines":
        return 2 * r.lineCount * 3;
      case "direct-volume":
        return 36;
      case "image":
        return 6;
      case "texture-mesh":
        return r.vertexCount;
    }
  }
  t.getDrawCount = e, t.getVertexCount = function(r) {
    switch (r.kind) {
      case "mesh":
      case "texture-mesh":
        return r.vertexCount;
      case "points":
        return r.pointCount;
      case "spheres":
        return 4 * r.sphereCount;
      case "cylinders":
        return 6 * r.cylinderCount;
      case "text":
        return 4 * r.charCount;
      case "lines":
        return 4 * r.lineCount;
      case "direct-volume":
        var n = r.gridDimension.ref.value;
        return n[0] * n[1] * n[2];
      case "image":
        return 4;
    }
  }, t.getGroupCount = function(r) {
    switch (r.kind) {
      case "mesh":
      case "points":
      case "spheres":
      case "cylinders":
      case "text":
      case "lines":
        return e(r) === 0 ? 0 : w3(r.groupBuffer.ref.value) + 1;
      case "direct-volume":
        return 1;
      case "image":
        return w3(r.groupTexture.ref.value.array) + 1;
      case "texture-mesh":
        return r.groupCount;
    }
  }, t.getUtils = function(r) {
    switch (r.kind) {
      case "mesh":
        return Vt.Utils;
      case "points":
        return I0.Utils;
      case "spheres":
        return Gu.Utils;
      case "cylinders":
        return to.Utils;
      case "text":
        return bs.Utils;
      case "lines":
        return Rr.Utils;
      case "direct-volume":
        return U3.Utils;
      case "image":
        return Db.Utils;
      case "texture-mesh":
        return sf.Utils;
    }
  }, t.getGranularity = function(r, n) {
    return n === "instance" && r.nonInstanceable ? "group" : n;
  };
}(Ia || (Ia = {}));
var bre = qe(13421772), iI = {};
function cx(t, e) {
  return { factory: cx, granularity: "groupInstance", color: function(r) {
    return bo.isLocation(r) ? r.shape.getColor(r.group, r.instance) : bre;
  }, props: e, description: "Assigns colors as defined by the shape object." };
}
var _re = { name: "shape-group", label: "Shape Group", category: "Miscellaneous", factory: cx, getParams: function(t) {
  return iI;
}, defaultValues: z.getDefaultValues(iI), isApplicable: function(t) {
  return !!t.shape;
} }, xre = O(O({}, Fl), { aPosition: jr("float32", 3, 0), elements: O0("uint32"), uBboxMin: Ie("v3"), uBboxMax: Ie("v3"), uBboxSize: Ie("v3"), uMaxSteps: Ie("i"), uStepScale: Ie("f"), uJumpLength: Ie("f"), uTransform: Ie("m4"), uGridDim: Ie("v3"), tTransferTex: zt("image-uint8", "alpha", "ubyte", "linear"), uTransferScale: Ie("f"), dGridTexType: Gt("string", ["2d", "3d"]), uGridTexDim: Ie("v3"), tGridTex: zt("texture", "rgba", "ubyte", "linear"), uGridStats: Ie("v4"), uCellDim: Ie("v3"), uCartnToUnit: Ie("m4"), uUnitToCartn: Ie("m4"), dPackedGroup: Gt("boolean"), dAxisOrder: Gt("string", ["012", "021", "102", "120", "201", "210"]), dIgnoreLight: Gt("boolean"), dXrayShaded: Gt("boolean") }), Sre = O(O({}, Fl), { aGroup: jr("float32", 1, 0), aPosition: jr("float32", 3, 0), aNormal: jr("float32", 3, 0), elements: O0("uint32"), dFlatShaded: Gt("boolean"), uDoubleSided: Ie("b"), dFlipSided: Gt("boolean"), dIgnoreLight: Gt("boolean"), dXrayShaded: Gt("boolean"), uBumpFrequency: Ie("f"), uBumpAmplitude: Ie("f"), meta: Ai("unknown") }), Cre = O(O(O({}, Fl), _2), { aGroup: jr("float32", 1, 0), aPosition: jr("float32", 3, 0), dPointSizeAttenuation: Gt("boolean"), dPointStyle: Gt("string", ["square", "circle", "fuzzy"]) }), Are = O(O(O({}, Fl), _2), { aGroup: jr("float32", 1, 0), aMapping: jr("float32", 2, 0), aStart: jr("float32", 3, 0), aEnd: jr("float32", 3, 0), elements: O0("uint32"), dLineSizeAttenuation: Gt("boolean"), uDoubleSided: Ie("b"), dFlipSided: Gt("boolean") }), wre = O(O(O({}, Fl), _2), { aGroup: jr("float32", 1, 0), aPosition: jr("float32", 3, 0), aMapping: jr("float32", 2, 0), elements: O0("uint32"), padding: Ai("number"), uDoubleSided: Ie("b"), dIgnoreLight: Gt("boolean"), dXrayShaded: Gt("boolean"), uBumpFrequency: Ie("f"), uBumpAmplitude: Ie("f") }), Dre = O(O(O({}, Fl), _2), { aGroup: jr("float32", 1, 0), aPosition: jr("float32", 3, 0), aMapping: jr("float32", 2, 0), aDepth: jr("float32", 1, 0), elements: O0("uint32"), aTexCoord: jr("float32", 2, 0), tFont: zt("image-uint8", "alpha", "ubyte", "linear"), padding: Ai("number"), uBorderWidth: Ie("f"), uBorderColor: Ie("v3"), uOffsetX: Ie("f"), uOffsetY: Ie("f"), uOffsetZ: Ie("f"), uBackgroundColor: Ie("v3"), uBackgroundOpacity: Ie("f") }), Ere = O(O({}, Fl), { uGeoTexDim: Ie("v2", "buffered"), tPosition: zt("texture", "rgb", "float", "nearest"), tGroup: zt("texture", "alpha", "float", "nearest"), tNormal: zt("texture", "rgb", "float", "nearest"), dFlatShaded: Gt("boolean"), uDoubleSided: Ie("b"), dFlipSided: Gt("boolean"), dIgnoreLight: Gt("boolean"), dXrayShaded: Gt("boolean"), uBumpFrequency: Ie("f"), uBumpAmplitude: Ie("f"), meta: Ai("unknown") }), Ire = O(O({}, Fl), { aGroup: jr("float32", 1, 0), aPosition: jr("float32", 3, 0), aUv: jr("float32", 2, 0), elements: O0("uint32"), uImageTexDim: Ie("v2"), tImageTex: zt("image-uint8", "rgba", "ubyte", "nearest"), tGroupTex: zt("image-uint8", "rgba", "ubyte", "nearest"), dInterpolation: Gt("string", yre) }), Tre = O(O(O({}, Fl), _2), { aGroup: jr("float32", 1, 0), aStart: jr("float32", 3, 0), aEnd: jr("float32", 3, 0), aMapping: jr("float32", 3, 0), aScale: jr("float32", 1, 0), aCap: jr("float32", 1, 0), elements: O0("uint32"), padding: Ai("number"), uDoubleSided: Ie("b"), dIgnoreLight: Gt("boolean"), dXrayShaded: Gt("boolean"), uBumpFrequency: Ie("f"), uBumpAmplitude: Ie("f") }), er, bo, Mre = io(0, 2147483647), Nl = io(0, 2147483647);
function eh(t, e, r, n) {
  return { id: Mre(), type: t, values: e, state: r, materialId: n };
}
function Pre(t, e, r) {
  switch (e.type) {
    case "mesh":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), Sre), l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "triangles", jw, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
    case "points":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), Cre), l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "points", LQ, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
    case "spheres":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), wre), l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "triangles", kQ, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
    case "cylinders":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), Tre), l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "triangles", GQ, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
    case "text":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), Dre), l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "triangles", zQ, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
    case "lines":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), Are), l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "triangles", VQ, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
    case "direct-volume":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), xre);
        n.isWebGL2 || (c.uMaxSteps = Gt("number"));
        var l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "triangles", UQ, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
    case "image":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), Ire), l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "triangles", HQ, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
    case "texture-mesh":
      return function(n, i, a, o, s, u) {
        var c = O(O(O(O({}, qc), Kc), Xc), Ere), l = { uObjectId: G.create(i) };
        return Wc(Yc(n, "triangles", jw, c, O(O({}, a), l), s, u), a, o);
      }(t, e.id, e.values, e.state, e.materialId, r);
  }
  throw new Error("unsupported type");
}
(function(t) {
  function e(r) {
    var n = r.transforms.length, i = bo.Location(r);
    return gi(r.groupCount, n, 1, function(a, o) {
      return i.group = a, i.instance = o, i;
    });
  }
  t.create = function(r, n, i, a, o, s, u) {
    return { id: Ki.create22(), name: r, sourceData: n, geometry: i, transforms: u || [he.identity()], get groupCount() {
      return Ia.getGroupCount(i);
    }, getColor: a, getSize: o, getLabel: s };
  }, t.getTheme = function(r) {
    return { color: cx(0, {}), size: lx({ shape: r }, {}) };
  }, t.groupIterator = e, t.createTransform = function(r, n) {
    for (var i = n && n.aTransform.ref.value.length >= 16 * r.length ? n.aTransform.ref.value : new Float32Array(16 * r.length), a = 0, o = r.length; a < o; ++a) he.toArray(r[a], i, 16 * a);
    return ix(i, r.length, n);
  }, t.createRenderObject = function(r, n) {
    var i = t.getTheme(r), a = Ia.getUtils(r.geometry), o = Nl(), s = e(r), u = t.createTransform(r.transforms), c = a.createValues(r.geometry, u, s, i, n), l = a.createRenderableState(n);
    return eh(r.geometry.kind, c, l, o);
  }, t.Loci = function(r) {
    return { kind: "shape-loci", shape: r };
  }, t.isLoci = function(r) {
    return !!r && r.kind === "shape-loci";
  }, t.areLociEqual = function(r, n) {
    return r.shape === n.shape;
  }, t.isLociEmpty = function(r) {
    return r.shape.groupCount === 0;
  };
})(er || (er = {})), function(t) {
  function e(o) {
    for (var s = 0, u = 0, c = o.groups; u < c.length; u++) {
      var l = c[u];
      s += Ge.size(l.ids);
    }
    return s;
  }
  t.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 };
  }, t.isLocation = function(o) {
    return !!o && o.kind === "group-location";
  }, t.Loci = function(o, s) {
    return { kind: "group-loci", shape: o, groups: s };
  }, t.isLoci = function(o) {
    return !!o && o.kind === "group-loci";
  }, t.areLociEqual = function(o, s) {
    if (o.shape !== s.shape || o.groups.length !== s.groups.length) return !1;
    for (var u = 0, c = o.groups.length; u < c; ++u) {
      var l = o.groups[u], d = l.ids, f = l.instance, h = s.groups[u], m = h.ids;
      if (f !== h.instance || !Ge.areEqual(d, m)) return !1;
    }
    return !0;
  }, t.isLociEmpty = function(o) {
    return e(o) === 0;
  }, t.size = e;
  var r = new _p(), n = E.zero();
  function i(o, s, u, c) {
    for (var l = s.indices, d = s.offsets, f = function(v, g) {
      Ge.forEach(v, function(y) {
        for (var b = d[y], S = d[y + 1]; b < S; ++b) E.fromArray(n, u, 3 * l[b]), E.transformMat4(n, n, c[g]), r.includeStep(n);
      });
    }, h = 0, m = o; h < m.length; h++) {
      var p = m[h];
      f(p.ids, p.instance);
    }
  }
  function a(o, s, u, c) {
    for (var l = s.indices, d = s.offsets, f = function(v, g) {
      Ge.forEach(v, function(y) {
        for (var b = d[y], S = d[y + 1]; b < S; ++b) E.fromArray(n, u, 3 * l[b]), E.transformMat4(n, n, c[g]), r.radiusStep(n);
      });
    }, h = 0, m = o; h < m.length; h++) {
      var p = m[h];
      f(p.ids, p.instance);
    }
  }
  t.getBoundingSphere = function(o, s) {
    s || (s = Me()), r.reset();
    var u = 0, c = o.shape, l = c.geometry, d = c.transforms;
    if (l.kind === "mesh" || l.kind === "points") {
      var f = l.kind === "mesh" ? l.vertexBuffer.ref.value : l.centerBuffer.ref.value;
      i(o.groups, l.groupMapping, f, d), r.finishedIncludeStep(), a(o.groups, l.groupMapping, f, d);
    } else if (l.kind === "lines") {
      var h = l.startBuffer.ref.value, m = l.endBuffer.ref.value;
      i(o.groups, l.groupMapping, h, d), i(o.groups, l.groupMapping, m, d), r.finishedIncludeStep(), a(o.groups, l.groupMapping, h, d), a(o.groups, l.groupMapping, m, d);
    } else {
      if (l.kind !== "spheres" && l.kind !== "text") return Me.copy(s, l.boundingSphere);
      f = l.centerBuffer.ref.value, i(o.groups, l.groupMapping, f, d), r.finishedIncludeStep(), a(o.groups, l.groupMapping, f, d);
      for (var p = function(b, S) {
        Ge.forEach(b, function(_) {
          var x = o.shape.getSize(_, S);
          u < x && (u = x);
        });
      }, v = 0, g = o.groups; v < g.length; v++) {
        var y = g[v];
        p(y.ids, y.instance);
      }
    }
    return E.copy(s.center, r.center), s.radius = Math.sqrt(r.radiusSq), Me.expand(s, s, u), s;
  };
}(bo || (bo = {}));
var Bre = 1, Fre = "Assigns sizes as defined by the shape object.", aI = {};
function lx(t, e) {
  return { factory: lx, granularity: "groupInstance", size: function(r) {
    return bo.isLocation(r) ? r.shape.getSize(r.group, r.instance) : Bre;
  }, props: e, description: Fre };
}
var Nre = { name: "shape-group", label: "Shape Group", category: "", factory: lx, getParams: function(t) {
  return aI;
}, defaultValues: z.getDefaultValues(aI), isApplicable: function(t) {
  return !!t.shape;
} }, oI = { bfactorFactor: z.Numeric(0.1, { min: 0, max: 1, step: 0.01 }), rmsfFactor: z.Numeric(0.05, { min: 0, max: 1, step: 0.01 }), baseSize: z.Numeric(0.2, { min: 0, max: 2, step: 0.1 }) };
function sI(t, e, r) {
  return Fe.isAtomic(t) ? t.model.atomicConformation.B_iso_or_equiv.value(e) * r.bfactorFactor : Fe.isSpheres(t) ? t.model.coarseConformation.spheres.rmsf[e] * r.rmsfFactor : 0;
}
var Rre = { name: "uncertainty", label: "Uncertainty/Disorder", category: "", factory: function t(e, r) {
  return { factory: t, granularity: "group", size: function(n) {
    var i = r.baseSize;
    return at.is(n) ? i += sI(n.unit, n.element, r) : Dt.isLocation(n) && (i += sI(n.aUnit, n.aUnit.elements[n.aIndex], r)), i;
  }, props: r, description: "Assigns a size reflecting the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique." };
}, getParams: function(t) {
  return oI;
}, defaultValues: z.getDefaultValues(oI), isApplicable: function(t) {
  return !!t.structure && t.structure.models.some(function(e) {
    return e.atomicConformation.B_iso_or_equiv.isDefined || e.coarseHierarchy.isDefined;
  });
} }, uI = { hydrogenSize: z.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), oxygenSize: z.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), baseSize: z.Numeric(0.2, { min: 0, max: 2, step: 0.1 }) }, Co, su, Ore = { name: "aquasite", label: "Aquasite", category: "", factory: function t(e, r) {
  return { factory: t, granularity: "group", size: function(n) {
    var i = r.baseSize;
    return at.is(n) && (i += function(a, o, s) {
      if (Fe.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;
    }(n.unit, n.element, r)), i;
  }, props: r, description: "Aquasite" };
}, getParams: function(t) {
  return uI;
}, defaultValues: z.getDefaultValues(uI), isApplicable: function(t) {
  return !!t.structure && t.structure.models.some(function(e) {
    return e.atomicConformation.B_iso_or_equiv.isDefined || e.coarseHierarchy.isDefined;
  });
} };
function cI(t) {
  return t.map(function(e) {
    return [e.name, e.provider.label, e.provider.category];
  });
}
(function(t) {
  t.EmptyFactory = function() {
    return t.Empty;
  }, t.Empty = { factory: t.EmptyFactory, granularity: "uniform", size: function() {
    return 1;
  }, props: {} }, t.areEqual = function(e, r) {
    return e.factory === r.factory && nf(e.props, r.props);
  }, t.EmptyProvider = { name: "", label: "", category: "", factory: t.EmptyFactory, getParams: function() {
    return {};
  }, defaultValues: {}, isApplicable: function() {
    return !0;
  } }, t.createRegistry = function() {
    return new dO(t.BuiltIn, t.EmptyProvider);
  }, t.BuiltIn = { physical: Kte, "shape-group": Nre, uncertainty: Rre, uniform: qte, aquasite: Ore };
})(Co || (Co = {})), function(t) {
  function e() {
    return { color: El.Empty, size: Co.Empty };
  }
  t.create = function(r, n, i, a) {
    a = a || e();
    var o = i.colorTheme, s = i.sizeTheme;
    return a.color = r.colorThemeRegistry.create(o.name, n, o.params), a.size = r.sizeThemeRegistry.create(s.name, n, s.params), a;
  }, t.createEmpty = e, t.ensureDependencies = function(r, n, i, a) {
    var o, s;
    return _e(this, 0, void 0, function() {
      return ye(this, function(u) {
        switch (u.label) {
          case 0:
            return [4, (o = n.colorThemeRegistry.get(a.colorTheme.name).ensureCustomProperties) === null || o === void 0 ? void 0 : o.attach(r, i)];
          case 1:
            return u.sent(), [4, (s = n.sizeThemeRegistry.get(a.sizeTheme.name).ensureCustomProperties) === null || s === void 0 ? void 0 : s.attach(r, i)];
          case 2:
            return u.sent(), [2];
        }
      });
    });
  }, t.releaseDependencies = function(r, n, i) {
    var a, o;
    (a = r.colorThemeRegistry.get(i.colorTheme.name).ensureCustomProperties) === null || a === void 0 || a.detach(n), (o = r.sizeThemeRegistry.get(i.sizeTheme.name).ensureCustomProperties) === null || o === void 0 || o.detach(n);
  };
}(su || (su = {}));
var dO = function() {
  function t(e, r) {
    var n = this;
    this.emptyProvider = r, this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map(), CN(e, function(i, a) {
      if (i.name !== a) throw new Error("Fix build in themes to have matching names. ".concat(i.name, " ").concat(a));
      n.add(i);
    });
  }
  return Object.defineProperty(t.prototype, "default", { get: function() {
    return this._list[0];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "list", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "types", { get: function() {
    return cI(this._list);
  }, enumerable: !1, configurable: !0 }), t.prototype.sort = function() {
    this._list.sort(function(e, r) {
      return e.provider.category === r.provider.category ? e.provider.label < r.provider.label ? -1 : e.provider.label > r.provider.label ? 1 : 0 : e.provider.category < r.provider.category ? -1 : 1;
    });
  }, t.prototype.add = function(e) {
    if (this._map.has(e.name)) throw new Error("".concat(e.name, " already registered."));
    var r = e.name;
    this._list.push({ name: r, provider: e }), this._map.set(r, e), this._name.set(e, r), this.sort();
  }, t.prototype.remove = function(e) {
    this._list.splice(this._list.findIndex(function(n) {
      return n.name === e.name;
    }), 1);
    var r = this._map.get(e.name);
    r && (this._map.delete(e.name), this._name.delete(r));
  }, t.prototype.has = function(e) {
    return this._map.has(e.name);
  }, t.prototype.get = function(e) {
    return this._map.get(e) || this.emptyProvider;
  }, t.prototype.getName = function(e) {
    if (!this._name.has(e)) throw new Error("'".concat(e.label, "' is not a registered theme provider."));
    return this._name.get(e);
  }, t.prototype.create = function(e, r, n) {
    n === void 0 && (n = {});
    var i = this.get(e);
    return i.factory(r, O(O({}, z.getDefaultValues(i.getParams(r))), n));
  }, t.prototype.getApplicableList = function(e) {
    return this._list.filter(function(r) {
      return r.provider.isApplicable(e);
    });
  }, t.prototype.getApplicableTypes = function(e) {
    return cI(this.getApplicableList(e));
  }, t;
}(), fO = { hue: z.Interval([1, 360], { min: 0, max: 360, step: 1 }), chroma: z.Interval([40, 70], { min: 0, max: 100, step: 1 }), luminance: z.Interval([15, 85], { min: 0, max: 100, step: 1 }), clusteringStepCount: z.Numeric(50, { min: 10, max: 200, step: 1 }, { isHidden: !0 }), minSampleCount: z.Numeric(800, { min: 100, max: 5e3, step: 100 }, { isHidden: !0 }) };
function lI(t, e) {
  return Math.sqrt(Math.pow(Math.abs(t[0] - e[0]), 2) + Math.pow(Math.abs(t[1] - e[1]), 2) + Math.pow(Math.abs(t[2] - e[2]), 2));
}
var E1 = 2, Lf = [0, 0, 0], kf = [0, 0, 0];
function Lre(t, e) {
  return xa.toHcl(Lf, t), xa.fromColor(kf, xa.toColor(t)), Lf[0] >= e.hue[0] && Lf[0] <= e.hue[1] && Lf[1] >= e.chroma[0] && Lf[1] <= e.chroma[1] && Lf[2] >= e.luminance[0] && Lf[2] <= e.luminance[1] && kf[0] >= t[0] - E1 && kf[0] <= t[0] + E1 && kf[1] >= t[1] - E1 && kf[1] <= t[1] + E1 && kf[2] >= t[2] - E1 && kf[2] <= t[2] + E1;
}
function kre(t, e) {
  e === void 0 && (e = {});
  var r = O(O({}, z.getDefaultValues(fO)), e);
  if (t <= 0) return [];
  var n = function(I, P) {
    for (var M = /* @__PURE__ */ new Map(), T = 1.001 * Math.cbrt(I), F = (P.hue[1] - P.hue[0]) / T, N = (P.chroma[1] - P.chroma[0]) / T, R = (P.luminance[1] - P.luminance[0]) / T, L = P.hue[0]; L <= P.hue[1]; L += F) for (var V = P.chroma[0]; V <= P.chroma[1]; V += N) for (var U = P.luminance[0]; U <= P.luminance[1]; U += R) {
      var H = xa.fromHcl(xa(), ac.create(L, V, U));
      Lre(H, P) && M.set(H.toString(), H);
    }
    return Array.from(M.values());
  }(Math.max(r.minSampleCount, 5 * t), r);
  if (n.length < t) throw new Error("Not enough samples to generate distinct colors, increase sample count.");
  for (var i = [], a = [], o = Math.floor(n.length / t), s = 0; s < n.length && (i.push(n[s]), a.push([]), !(i.length >= t)); s += o) ;
  for (var u = 1; u <= r.clusteringStepCount; ++u) {
    var c = wl(a);
    for (s = 0; s < n.length; ++s) {
      for (var l = Number.MAX_SAFE_INTEGER, d = 0, f = 0; f < i.length; f++) {
        var h = lI(n[s], i[f]);
        h < l && (l = h, d = f);
      }
      c[d].push(n[s]);
    }
    var m = wl(i);
    for (s = 0; s < c.length; ++s) {
      for (var p = c[s], v = p.length, g = [], y = [], b = [], S = 0, _ = p; S < _.length; S++) {
        var x = _[S];
        g.push(x[0]), y.push(x[1]), b.push(x[2]);
      }
      var C = e3(g) / v, A = e3(y) / v, w = e3(b) / v;
      i[s] = [C, A, w];
    }
    if (nf(m, i)) break;
  }
  return function(I) {
    for (var P = I.slice(0), M = [P.shift()]; P.length > 0; ) {
      for (var T = M[M.length - 1], F = 0, N = Number.MIN_SAFE_INTEGER, R = 0; R < P.length; ++R) {
        var L = lI(T, P[R]);
        L > N && (N = L, F = R);
      }
      M.push(P.splice(F, 1)[0]);
    }
    return M;
  }(i).map(function(I) {
    return xa.toColor(I);
  });
}
var pO = { type: "generate", colorList: "red-yellow-blue" };
function Cs(t) {
  t === void 0 && (t = {});
  var e = O(O({}, pO), t);
  return { palette: z.MappedStatic(e.type, { colors: z.Group({ list: z.ColorList(e.colorList) }, { isFlat: !0 }), generate: z.Group(O(O({}, fO), { maxCount: z.Numeric(75, { min: 1, max: 250, step: 1 }) }), { isFlat: !0 }) }, { options: [["colors", "Color List"], ["generate", "Generate Distinct"]] }) };
}
z.getDefaultValues(Cs());
var dI = { valueLabel: function(t) {
  return "".concat(t + 1);
}, minLabel: "Start", maxLabel: "End" };
function Vu(t, e, r) {
  var n, i, a;
  if (r === void 0 && (r = {}), e.palette.name === "colors" && e.palette.params.list.kind === "interpolate") {
    var o = e.palette.params.list, s = [0, t - 1], u = O(O({}, dI), r), c = u.minLabel, l = u.maxLabel, d = o.colors;
    d.length === 0 && (d = Cl(pO.colorList).list);
    var f = _c.create({ listOrName: d, domain: s, minLabel: c, maxLabel: l });
    a = f.legend, i = f.color;
  } else {
    var h;
    e.palette.name === "colors" ? (h = e.palette.params.list.colors.map(function(b) {
      return Array.isArray(b) ? b[0] : b;
    }), h.length === 0 && (h = Cl("dark-2").list.map(function(b) {
      return Array.isArray(b) ? b[0] : b;
    }))) : (t = Math.min(t, e.palette.params.maxCount), h = kre(t, e.palette.params));
    for (var m = (n = r.valueLabel) !== null && n !== void 0 ? n : dI.valueLabel, p = h.length, v = [], g = 0; g < t; ++g) {
      var y = g % p;
      v[y] === void 0 ? v[y] = [m(g), h[y]] : v[y][0] += ", ".concat(m(g));
    }
    a = zu(v), i = function(b) {
      return h[b % p];
    };
  }
  return { color: i, legend: a };
}
var fI = qe(16448250), Gre = "Gives every chain a color based on its `asym_id` value.", T0 = O({ asymId: z.Select("auth", z.arrayToOptions(["auth", "label"])) }, Cs({ type: "colors", colorList: "many-distinct" }));
function pI(t, e) {
  var r = function(n, i) {
    switch (n.kind) {
      case 0:
        return i === "auth" ? Qe.chain.auth_asym_id : Qe.chain.label_asym_id;
      case 1:
      case 2:
        return Qe.coarse.asym_id;
    }
  }(t.unit, e)(t);
  return t.structure.root.models.length > 1 ? hO(t.unit.model, r) : r;
}
function hO(t, e) {
  return "".concat(e, "|").concat((pn.Index.get(t).value || 0) + 1);
}
function Ky(t, e) {
  var r, n;
  if (t.structure) {
    var i = at.create(t.structure.root), a = function(u, c) {
      for (var l = /* @__PURE__ */ new Map(), d = function(m) {
        var p = pn.AsymIdOffset.get(m).value, v = (c === "auth" ? p == null ? void 0 : p.auth : p == null ? void 0 : p.label) || 0, g = 0;
        m.properties.structAsymMap.forEach(function(y, b) {
          var S = y.auth_id, _ = c === "auth" ? S : b, x = u.models.length > 1 ? hO(m, _) : _;
          l.has(x) || (l.set(x, g + v), ++g);
        });
      }, f = 0, h = u.models; f < h.length; f++) d(h[f]);
      return l;
    }(t.structure.root, e.asymId), o = Array.from(a.keys()), s = Vu(a.size, e, { valueLabel: function(u) {
      return o[u];
    } });
    n = s.legend, r = function(u) {
      var c = void 0;
      if (at.is(u)) {
        var l = pI(u, e.asymId);
        c = a.get(l);
      } else Dt.isLocation(u) && (i.unit = u.aUnit, i.element = u.aUnit.elements[u.aIndex], l = pI(i, e.asymId), c = a.get(l));
      return c === void 0 ? fI : s.color(c);
    };
  } else r = function() {
    return fI;
  };
  return { factory: Ky, granularity: "group", color: r, props: e, description: Gre, legend: n };
}
var zre = { name: "chain-id", label: "Chain Id", category: "Chain Property", factory: Ky, getParams: function(t) {
  var e, r = z.clone(T0);
  return !((e = t.structure) === null || e === void 0) && e.models.some(function(n) {
    return n.coarseHierarchy.isDefined;
  }) && (r.asymId.defaultValue = "label"), r;
}, defaultValues: z.getDefaultValues(T0), isApplicable: function(t) {
  return !!t.structure;
} }, hI = qe(13421772), mI = O({}, Cs({ type: "colors", colorList: "red-yellow-blue" })), Vre = { name: "element-index", label: "Element Index", category: "Atom Property", factory: function t(e, r) {
  var n, i;
  if (e.structure) {
    for (var a = e.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 = Vu(c, r);
    i = d.legend, n = function(f) {
      if (at.is(f)) {
        var h = u.get(f.unit.id), m = Ge.findPredecessorIndex(a[h].elements, f.element);
        return d.color(s.get(h) + m);
      }
      return Dt.isLocation(f) ? (h = u.get(f.aUnit.id), m = Ge.findPredecessorIndex(a[h].elements, f.aUnit.elements[f.aIndex]), d.color(s.get(h) + m)) : hI;
    };
  } else n = function() {
    return hI;
  };
  return { factory: t, granularity: "groupInstance", preferSmoothing: !0, color: n, props: r, description: "Gives every element (atom or coarse sphere/gaussian) a unique color based on the position (index) of the element in the list of elements in the structure.", legend: i };
}, getParams: function(t) {
  return mI;
}, defaultValues: z.getDefaultValues(mI), isApplicable: function(t) {
  return !!t.structure;
} };
function th(t) {
  var e = {};
  return CN(t, function(r, n) {
    e[n] = z.Color(t[n]);
  }), e;
}
var gI = qe(13421772), Ure = "Assigns a color based on the operator name of a transformed chain.", Ep = O({}, Cs({ type: "colors", colorList: "many-distinct" }));
function dx(t, e) {
  var r, n;
  if (t.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;
    }(t.structure.root), a = Array.from(i.keys()), o = Vu(i.size, e, { valueLabel: function(s) {
      return a[s];
    } });
    n = o.legend, r = function(s) {
      var u = void 0;
      if (at.is(s)) {
        var c = s.unit.conformation.operator.name;
        u = i.get(c);
      } else if (Dt.isLocation(s)) {
        var l = s.aUnit.conformation.operator.name;
        u = i.get(l);
      }
      return u === void 0 ? gI : o.color(u);
    };
  } else r = function() {
    return gI;
  };
  return { factory: dx, granularity: "instance", color: r, props: e, description: Ure, legend: n };
}
var Hre = { name: "operator-name", label: "Operator Name", category: "Symmetry", factory: dx, getParams: function(t) {
  return z.clone(Ep);
}, defaultValues: z.getDefaultValues(Ep), isApplicable: function(t) {
  return !!t.structure;
} }, vI = qe(16448250), qre = "Gives every chain a color based on its `label_entity_id` value.", Ip = O({}, Cs({ type: "colors", colorList: "many-distinct" }));
function Oh(t, e) {
  return "".concat(t, "|").concat(e);
}
function yI(t) {
  switch (t.unit.kind) {
    case 0:
      return Qe.chain.label_entity_id(t);
    case 1:
    case 2:
      return Qe.coarse.entity_id(t);
  }
}
function Xy(t, e) {
  var r, n;
  if (t.structure) {
    var i = at.create(t.structure.root), a = function(u) {
      for (var c = /* @__PURE__ */ new Map(), l = 0, d = u.models.length; l < d; ++l) {
        for (var f = u.models[l].atomicHierarchy.chains.label_entity_id, h = 0, m = f.rowCount; h < m; ++h) {
          var p = Oh(f.value(h), l);
          c.has(p) || c.set(p, c.size);
        }
        var v = u.models[l].coarseHierarchy;
        if (v.isDefined) {
          var g = v.spheres.entity_id;
          for (h = 0, m = g.rowCount; h < m; ++h) p = Oh(g.value(h), l), c.has(p) || c.set(p, c.size);
          var y = v.gaussians.entity_id;
          for (h = 0, m = y.rowCount; h < m; ++h) p = Oh(y.value(h), l), c.has(p) || c.set(p, c.size);
        }
      }
      return c;
    }(t.structure.root), o = Array.from(a.keys()), s = Vu(a.size, e, { valueLabel: function(u) {
      return o[u];
    } });
    n = s.legend, r = function(u) {
      var c = void 0;
      if (at.is(u)) {
        var l = Oh(yI(u), u.structure.models.indexOf(u.unit.model));
        c = a.get(l);
      } else Dt.isLocation(u) && (i.unit = u.aUnit, i.element = u.aUnit.elements[u.aIndex], l = Oh(yI(i), i.structure.models.indexOf(i.unit.model)), c = a.get(l));
      return c === void 0 ? vI : s.color(c);
    };
  } else r = function() {
    return vI;
  };
  return { factory: Xy, granularity: "group", color: r, props: e, description: qre, legend: n };
}
var Kre = { name: "entity-id", label: "Entity Id", category: "Chain Property", factory: Xy, getParams: function(t) {
  return z.clone(Ip);
}, defaultValues: z.getDefaultValues(Ip), isApplicable: function(t) {
  return !!t.structure;
} }, r7 = "dark-2", nv = qe(16448250), Xre = "Gives ranges of a polymer chain a color based on the entity source it originates from (e.g. gene, plasmid, organism).", Tp = O({}, Cs({ type: "colors", colorList: r7 }));
function mO(t, e) {
  return "".concat(t, "|").concat(e);
}
function Yre(t, e, r, n, i, a) {
  return "".concat(t, "|").concat(e, "|").concat(r, "|").concat(a || i || n);
}
function Eb(t, e, r, n, 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, f = 0, h = i._rowCount; f < h; ++f) {
    var m = u.value(f), p = mO(r, m), v = void 0;
    if (t.has(p)) v = t.get(p);
    else {
      var g = n.entities.getEntityIndex(m), y = n.sequence.sequences[g].sequence;
      v = new Int16Array(y.length), t.set(p, v);
    }
    var b = o ? o.value(f) : "", S = s ? s.value(f)[0] : "", _ = Yre(r, m, a.value(f), c.value(f), b, S), x = l.valueKind(f) === 0 ? l.value(f) : 1, C = d.valueKind(f) === 0 ? d.value(f) : v.length, A = void 0;
    e.has(_) ? A = e.get(_) : (A = e.size + 1, e.set(_, A));
    for (var w = x, I = C; w <= I; ++w) v[w - 1] = A;
  }
}
function gO(t) {
  for (var e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = 0, i = t.length; n < i; ++n) {
    var a = t[n];
    if (An.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;
      Eb(e, r, n, a, s, s.pdbx_gene_src_scientific_name, s.plasmid_name, s.pdbx_gene_src_gene), Eb(e, r, n, a, u, u.pdbx_organism_scientific, u.pdbx_plasmid_name), Eb(e, r, n, a, c, c.organism_scientific);
    }
  }
  return { seqToSrcByModelEntity: e, srcKeySerialMap: r };
}
function Wre(t) {
  var e = 0;
  return Array.from(t.keys()).map(function(r) {
    var n = r.split("|"), i = n[2], a = function(o) {
      o = o.trim();
      var s = parseInt(o, 10);
      return !isNaN(s) && s.toString() === o;
    }(n[3]) ? "Unnamed ".concat(++e) : n[3];
    return "".concat(a).concat(i ? " (".concat(i, ")") : "");
  });
}
function Yy(t, e) {
  var r, n;
  if (t.structure) {
    var i = at.create(t.structure), a = t.structure.root.models, o = gO(a), s = o.seqToSrcByModelEntity, u = o.srcKeySerialMap, c = Wre(u), l = Vu(u.size, e, { valueLabel: function(f) {
      return c[f];
    } });
    n = l.legend;
    var d = function(f) {
      var h = mO(a.indexOf(f.unit.model), Qe.entity.id(f)), m = s.get(h);
      if (m) {
        var p = m[Qe.residue.label_seq_id(f) - 1] - 1;
        return p === -1 ? nv : l.color(p);
      }
      return nv;
    };
    r = function(f) {
      return at.is(f) ? d(f) : Dt.isLocation(f) ? (i.unit = f.aUnit, i.element = f.aUnit.elements[f.aIndex], d(i)) : nv;
    };
  } else r = function() {
    return nv;
  };
  return { factory: Yy, granularity: "group", color: r, props: e, description: Xre, legend: n };
}
var jre = { name: "entity-source", label: "Entity Source", category: "Chain Property", factory: Yy, getParams: function(t) {
  var e = z.clone(Tp);
  return t.structure && gO(t.structure.root.models).srcKeySerialMap.size > Uo[r7].list.length && (e.palette.defaultValue.name = "colors", e.palette.defaultValue.params = O(O({}, e.palette.defaultValue.params), { list: { kind: "interpolate", colors: Cl(r7).list } })), e;
}, defaultValues: z.getDefaultValues(Tp), isApplicable: function(t) {
  return !!t.structure;
} }, vO = { 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 }, yO = qe(16777215), bO = { carbonColor: z.MappedStatic("chain-id", { "chain-id": z.Group(T0), "entity-id": z.Group(Ip), "entity-source": z.Group(Tp), "operator-name": z.Group(Ep), "element-symbol": z.EmptyGroup(), uniform: z.Group(V3) }, { description: "Use chain-id coloring for carbon atoms." }), saturation: z.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: z.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: z.MappedStatic("default", { default: z.EmptyGroup(), custom: z.Group(th(vO)) }) };
function Zre(t) {
  return bO;
}
function Qre(t, e) {
  var r = t[e];
  return r === void 0 ? yO : r;
}
function _O(t, e) {
  var r = N0(e.colors.name === "default" ? vO : e.colors.params, e.saturation, e.lightness), n = e.carbonColor, i = n.name === "chain-id" ? Ky(t, n.params).color : n.name === "entity-id" ? Xy(t, n.params).color : n.name === "entity-source" ? Yy(t, n.params).color : n.name === "operator-name" ? dx(t, n.params).color : n.name === "element-symbol" ? void 0 : n.name === "uniform" ? y2(0, n.params).color : ca();
  function a(o, s) {
    return i && o === "C" ? i(s, !1) : Qre(r, o);
  }
  return { factory: _O, granularity: e.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(o) {
    if (at.is(o)) {
      if (Fe.isAtomic(o.unit)) return a(o.unit.model.atomicHierarchy.atoms.type_symbol.value(o.element), o);
    } else if (Dt.isLocation(o) && Fe.isAtomic(o.aUnit))
      return a(o.aUnit.model.atomicHierarchy.atoms.type_symbol.value(o.aUnit.elements[o.aIndex]), o);
    return yO;
  }, props: e, description: "Assigns a color to every atom according to its chemical element.", legend: zu(Object.keys(r).map(function(o) {
    return [o, r[o]];
  })) };
}
var Jre = { name: "element-symbol", label: "Element Symbol", category: "Atom Property", factory: _O, getParams: Zre, defaultValues: z.getDefaultValues(bO), isApplicable: function(t) {
  return !!t.structure;
} }, xO = { water: 3697840, ion: 15729279, protein: 12496596, RNA: 16629894, DNA: 12540695, PNA: 4367514, saccharide: 8374655 }, n7 = qe(16777113), $re = "Assigns a color based on the molecule type of a residue.", i7 = { saturation: z.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: z.Numeric(0, { min: -6, max: 6, step: 0.1 }), colors: z.MappedStatic("default", { default: z.EmptyGroup(), custom: z.Group(th(xO)) }) };
function bI(t, e, r) {
  switch (SR(e, r)) {
    case 2:
      return t.water;
    case 3:
      return t.ion;
    case 5:
      return t.protein;
    case 6:
      return t.RNA;
    case 7:
      return t.DNA;
    case 8:
      return t.PNA;
    case 9:
      return t.saccharide;
  }
  return n7;
}
function fx(t, e) {
  var r = N0(e.colors.name === "default" ? xO : e.colors.params, e.saturation, e.lightness);
  return { factory: fx, granularity: "group", color: function(n) {
    return at.is(n) ? bI(r, n.unit, n.element) : Dt.isLocation(n) ? bI(r, n.aUnit, n.aUnit.elements[n.aIndex]) : n7;
  }, props: e, description: $re, legend: zu(Object.keys(r).map(function(n) {
    return [n, r[n]];
  }).concat([["Other/unknown", n7]])) };
}
var ene = { name: "molecule-type", label: "Molecule Type", category: "Residue Property", factory: fx, getParams: function(t) {
  return i7;
}, defaultValues: z.getDefaultValues(i7), isApplicable: function(t) {
  return !!t.structure;
} }, a7 = "dark-2", _I = qe(16448250), xI = O({}, Cs({ type: "colors", colorList: a7 }));
function SI(t) {
  switch (t.kind) {
    case 0:
      return Qe.chain.label_asym_id;
    case 1:
    case 2:
      return Qe.coarse.asym_id;
  }
}
function CI(t) {
  for (var e = /* @__PURE__ */ new Map(), r = 0, n = t.unitSymmetryGroups.length; r < n; ++r) {
    var i = t.unitSymmetryGroups[r].units[0], a = i.model;
    if (Fe.isAtomic(i)) for (var o = a.atomicHierarchy, s = o.chainAtomSegments, u = o.chains, c = Qt.transientSegments(s, i.elements); c.hasNext; ) {
      var l = c.move().index, d = u.label_entity_id.value(l), f = a.entities.getEntityIndex(d);
      if (a.entities.data.type.value(f) === "polymer") {
        var h = u.label_asym_id.value(l);
        e.has(h) || e.set(h, e.size);
      }
    }
    else if (Fe.isCoarse(i)) {
      var m = Fe.isSpheres(i) ? a.coarseHierarchy.spheres : a.coarseHierarchy.gaussians, p = m.chainElementSegments, v = m.asym_id, g = m.entity_id;
      for (c = Qt.transientSegments(p, i.elements); c.hasNext; ) {
        l = c.move().index;
        var y = p.offsets[l];
        d = g.value(y), f = a.entities.getEntityIndex(d), a.entities.data.type.value(f) === "polymer" && (h = v.value(y), e.has(h) || e.set(h, e.size));
      }
    }
  }
  return e;
}
var tne = { name: "polymer-id", label: "Polymer Chain Id", category: "Chain Property", factory: function t(e, r) {
  var n, i;
  if (e.structure) {
    var a = at.create(e.structure), o = CI(e.structure.root), s = Array.from(o.keys()), u = Vu(o.size, r, { valueLabel: function(c) {
      return s[c];
    } });
    i = u.legend, n = function(c) {
      var l = void 0;
      if (at.is(c)) {
        var d = SI(c.unit);
        l = o.get(d(c));
      } else Dt.isLocation(c) && (d = SI(c.aUnit), a.unit = c.aUnit, a.element = c.aUnit.elements[c.aIndex], l = o.get(d(a)));
      return l === void 0 ? _I : u.color(l);
    };
  } else n = function() {
    return _I;
  };
  return { factory: t, granularity: "group", color: n, props: r, description: "Gives every polymer chain a color based on its `asym_id` value.", legend: i };
}, getParams: function(t) {
  var e = z.clone(xI);
  return t.structure && CI(t.structure.root).size > Uo[a7].list.length && (e.palette.defaultValue.name = "colors", e.palette.defaultValue.params = O(O({}, e.palette.defaultValue.params), { list: { kind: "interpolate", colors: Cl(a7).list } })), e;
}, defaultValues: z.getDefaultValues(xI), isApplicable: function(t) {
  return !!t.structure;
} }, o7 = "dark-2", AI = qe(13421772), wI = O({}, Cs({ type: "colors", colorList: o7 }));
function DI(t) {
  for (var e = 0, r = t.units, n = 0, i = r.length; n < i; ++n) r[n].polymerElements.length > 0 && ++e;
  return e;
}
var rne = { name: "polymer-index", label: "Polymer Chain Instance", category: "Chain Property", factory: function t(e, r) {
  var n, i;
  if (e.structure) {
    var a = Vu(DI(e.structure.root), r);
    i = a.legend;
    for (var o = e.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);
    n = function(d) {
      var f;
      return at.is(d) ? f = s.get(d.unit.id) : Dt.isLocation(d) && (f = s.get(d.aUnit.id)), f !== void 0 ? f : AI;
    };
  } else n = function() {
    return AI;
  };
  return { factory: t, granularity: "instance", color: n, props: r, description: "Gives every polymer chain instance a unique color based on the position (index) of the polymer in the list of polymers in the structure.", legend: i };
}, getParams: function(t) {
  var e = z.clone(wI);
  return t.structure && DI(t.structure.root) > Uo[o7].list.length && (e.palette.defaultValue.name = "colors", e.palette.defaultValue.params = O(O({}, e.palette.defaultValue.params), { list: { kind: "interpolate", colors: Cl(o7).list } })), e;
}, defaultValues: z.getDefaultValues(wI), isApplicable: function(t) {
  return !!t.structure;
} }, SO = { 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 }, s7 = qe(16711935), EI = { saturation: z.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: z.Numeric(1, { min: -6, max: 6, step: 0.1 }), colors: z.MappedStatic("default", { default: z.EmptyGroup(), custom: z.Group(th(SO)) }) };
function II(t, e) {
  return t.model.atomicHierarchy.atoms.label_comp_id.value(e);
}
function TI(t, e) {
  var r = t.coarseElements.seq_id_begin.value(e);
  if (r === t.coarseElements.seq_id_end.value(e)) {
    var n = t.coarseElements.entityKey[e];
    return t.model.sequence.byEntityKey[n].sequence.compId.value(r - 1);
  }
}
function iv(t, e) {
  var r = t[e];
  return r === void 0 ? s7 : r;
}
var nne = { name: "residue-name", label: "Residue Name", category: "Residue Property", factory: function t(e, r) {
  var n = N0(r.colors.name === "default" ? SO : r.colors.params, r.saturation, r.lightness);
  return { factory: t, granularity: "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      if (Fe.isAtomic(i.unit)) {
        var a = II(i.unit, i.element);
        return iv(n, a);
      }
      if (a = TI(i.unit, i.element)) return iv(n, a);
    } else if (Dt.isLocation(i)) {
      if (Fe.isAtomic(i.aUnit))
        return a = II(i.aUnit, i.aUnit.elements[i.aIndex]), iv(n, a);
      if (a = TI(i.aUnit, i.aUnit.elements[i.aIndex])) return iv(n, a);
    }
    return s7;
  }, props: r, description: "Assigns a color to every residue according to its name.", legend: zu(Object.keys(n).map(function(i) {
    return [i, n[i]];
  }).concat([["Unknown", s7]])) };
}, getParams: function(t) {
  return EI;
}, defaultValues: z.getDefaultValues(EI), isApplicable: function(t) {
  return !!t.structure;
} }, CO = { alphaHelix: 16711808, threeTenHelix: 10485888, piHelix: 6291584, betaTurn: 6324479, betaStrand: 16762880, coil: 16777215, bend: 6740169, turn: 45670, dna: 11403518, rna: 16580962, carbohydrate: 10921722 }, u7 = qe(8421504), MI = { saturation: z.Numeric(-1, { min: -6, max: 6, step: 0.1 }), lightness: z.Numeric(0, { min: -6, max: 6, step: 0.1 }), colors: z.MappedStatic("default", { default: z.EmptyGroup(), custom: z.Group(th(CO)) }) };
function PI(t, e, r, n) {
  var i = _r.create(0);
  if (n && Fe.isAtomic(e)) {
    var a = n.get(e.invariantId);
    a && (i = a.type[a.getIndex(e.residueIndex[r])]);
  }
  if (_r.is(i, 2)) return _r.is(i, 2048) ? t.threeTenHelix : _r.is(i, 32768) ? t.piHelix : t.alphaHelix;
  if (_r.is(i, 4)) return t.betaStrand;
  if (_r.is(i, 8)) return t.bend;
  if (_r.is(i, 16)) return t.turn;
  var o = SR(e, r);
  return o === 7 ? t.dna : o === 6 ? t.rna : o === 9 ? t.carbohydrate : o === 5 ? t.coil : u7;
}
var ine = { name: "secondary-structure", label: "Secondary Structure", category: "Residue Property", factory: function t(e, r) {
  var n = e.structure && Ha.get(e.structure), i = n ? Wp(n.id, n.version) : -1, a = N0(r.colors.name === "default" ? CO : r.colors.params, r.saturation, r.lightness);
  return { factory: t, granularity: "group", preferSmoothing: !0, color: function(o) {
    return at.is(o) ? PI(a, o.unit, o.element, n == null ? void 0 : n.value) : Dt.isLocation(o) ? PI(a, o.aUnit, o.aUnit.elements[o.aIndex], n == null ? void 0 : n.value) : u7;
  }, props: r, contextHash: i, description: "Assigns a color based on the type of secondary structure and basic molecule type.", legend: zu(Object.keys(a).map(function(o) {
    return [o, a[o]];
  }).concat([["Other", u7]])) };
}, getParams: function(t) {
  return MI;
}, defaultValues: z.getDefaultValues(MI), isApplicable: function(t) {
  return !!t.structure;
}, ensureCustomProperties: { attach: function(t, e) {
  return e.structure ? Ha.attach(t, e.structure, void 0, !0) : Promise.resolve();
}, detach: function(t) {
  return t.structure && Ha.ref(t.structure, !1);
} } }, ane = qe(13421772), BI = { list: z.ColorList("turbo", { presetKind: "scale" }) };
function FI(t, e) {
  var r = t.model;
  switch (t.kind) {
    case 0:
      var n = r.atomicHierarchy.residueAtomSegments.index[e];
      return r.atomicHierarchy.residues.label_seq_id.value(n);
    case 1:
      return Math.round((r.coarseHierarchy.spheres.seq_id_begin.value(e) + r.coarseHierarchy.spheres.seq_id_end.value(e)) / 2);
    case 2:
      return Math.round((r.coarseHierarchy.gaussians.seq_id_begin.value(e) + r.coarseHierarchy.gaussians.seq_id_end.value(e)) / 2);
  }
}
function NI(t, e) {
  var r = t.model, n = "";
  switch (t.kind) {
    case 0:
      var i = r.atomicHierarchy.chainAtomSegments.index[e];
      n = r.atomicHierarchy.chains.label_entity_id.value(i);
      break;
    case 1:
      n = r.coarseHierarchy.spheres.entity_id.value(e);
      break;
    case 2:
      n = r.coarseHierarchy.gaussians.entity_id.value(e);
  }
  if (n === "") return 0;
  var a = r.entities.getEntityIndex(n);
  if (a === -1) return 0;
  var o = r.sequence.byEntityKey[a];
  return o === void 0 ? 0 : o.sequence.length;
}
var one = { name: "sequence-id", label: "Sequence Id", category: "Residue Property", factory: function t(e, r) {
  var n = _c.create({ listOrName: r.list.colors, minLabel: "Start", maxLabel: "End" });
  return { factory: t, granularity: "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      var a = i.unit, o = i.element;
      if ((s = FI(a, o)) > 0 && (u = NI(a, o))) return n.setDomain(0, u - 1), n.color(s);
    } else if (Dt.isLocation(i)) {
      var s, u, c = i.aUnit, l = i.aIndex;
      if ((s = FI(c, c.elements[l])) > 0 && (u = NI(c, c.elements[l]))) return n.setDomain(0, u - 1), n.color(s);
    }
    return ane;
  }, props: r, description: "Gives every polymer residue a color based on its `seq_id` value.", legend: n ? n.legend : void 0 };
}, getParams: function(t) {
  return BI;
}, defaultValues: z.getDefaultValues(BI), isApplicable: function(t) {
  return !!t.structure;
} }, c7 = "dark-2", RI = qe(13421772), OI = O({}, Cs({ type: "colors", colorList: c7 })), sne = { name: "unit-index", label: "Chain Instance", category: "Chain Property", factory: function t(e, r) {
  var n, i;
  if (e.structure) {
    var a = e.structure.root.units, o = Vu(a.length, r);
    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));
    n = function(l) {
      return at.is(l) ? s.get(l.unit.id) : Dt.isLocation(l) ? s.get(l.aUnit.id) : RI;
    };
  } else n = function() {
    return RI;
  };
  return { factory: t, granularity: "instance", color: n, props: r, description: "Gives every chain instance (single chain or collection of single elements) a unique color based on the position (index) of the chain in the list of chains in the structure.", legend: i };
}, getParams: function(t) {
  var e = z.clone(OI);
  return t.structure && t.structure.root.units.length > Uo[c7].list.length && (e.palette.defaultValue.name = "colors", e.palette.defaultValue.params = O(O({}, e.palette.defaultValue.params), { list: { kind: "interpolate", colors: Cl(c7).list } })), e;
}, defaultValues: z.getDefaultValues(OI), isApplicable: function(t) {
  return !!t.structure;
} }, une = qe(16777113), LI = { domain: z.Interval([0, 100]), list: z.ColorList("red-white-blue", { presetKind: "scale" }) };
function kI(t, e) {
  return Fe.isAtomic(t) ? t.model.atomicConformation.B_iso_or_equiv.value(e) : Fe.isSpheres(t) ? t.model.coarseConformation.spheres.rmsf[e] : 0;
}
var cne = { name: "uncertainty", label: "Uncertainty/Disorder", category: "Atom Property", factory: function t(e, r) {
  var n = _c.create({ reverse: !0, domain: r.domain, listOrName: r.list.colors });
  return { factory: t, granularity: "group", preferSmoothing: !0, color: function(i) {
    return at.is(i) ? n.color(kI(i.unit, i.element)) : Dt.isLocation(i) ? n.color(kI(i.aUnit, i.aUnit.elements[i.aIndex])) : une;
  }, props: r, description: "Assigns a color based on the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique.", legend: n ? n.legend : void 0 };
}, getParams: function(t) {
  return LI;
}, defaultValues: z.getDefaultValues(LI), isApplicable: function(t) {
  return !!t.structure && t.structure.models.some(function(e) {
    return e.atomicConformation.B_iso_or_equiv.isDefined || e.coarseHierarchy.isDefined;
  });
} }, lne = qe(15658734), GI = { style: z.MappedStatic("entity-id", { uniform: z.Group(V3), "chain-id": z.Group(T0), "entity-id": z.Group(Ip), "entity-source": z.Group(Tp), "molecule-type": z.Group(i7) }), carbonLightness: z.Numeric(0.8, { min: -6, max: 6, step: 0.1 }) }, dne = { name: "illustrative", label: "Illustrative", category: "Miscellaneous", factory: function t(e, r) {
  var n = r.style.name === "uniform" ? y2(0, r.style.params) : r.style.name === "chain-id" ? Ky(e, r.style.params) : r.style.name === "entity-id" ? Xy(e, r.style.params) : r.style.name === "entity-source" ? Yy(e, r.style.params) : r.style.name === "molecule-type" ? fx(0, r.style.params) : ca(r.style), i = n.color, a = n.legend;
  function o(s, u) {
    var c = i(s, !1);
    return u === "C" ? qe.lighten(c, r.carbonLightness) : c;
  }
  return { factory: t, granularity: "group", preferSmoothing: !0, color: function(s) {
    if (at.is(s) && Fe.isAtomic(s.unit)) {
      var u = s.unit.model.atomicHierarchy.atoms.type_symbol.value(s.element);
      return o(s, u);
    }
    if (Dt.isLocation(s) && Fe.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 lne;
  }, props: r, description: "Assigns an illustrative color that gives every chain a color based on the choosen style but with lighter carbons (inspired by David Goodsell's Molecule of the Month style).", legend: a };
}, getParams: function(t) {
  return z.clone(GI);
}, defaultValues: z.getDefaultValues(GI), isApplicable: function(t) {
  return !!t.structure;
} }, zI = { list: z.ColorList("red-yellow-green", { presetKind: "scale" }), scale: z.Select("DGwif", [["DGwif", "DG water-membrane"], ["DGwoct", "DG water-octanol"], ["Oct-IF", "DG difference"]]) }, fne = { DGwif: 0, DGwoct: 1, "Oct-IF": 2 };
function VI(t, e) {
  return t.model.atomicHierarchy.atoms.label_comp_id.value(e);
}
function UI(t, e) {
  var r = t.coarseElements.seq_id_begin.value(e);
  if (r === t.coarseElements.seq_id_end.value(e)) {
    var n = t.coarseElements.entityKey[e];
    return t.model.sequence.byEntityKey[n].sequence.compId.value(r - 1);
  }
}
var pne = { name: "hydrophobicity", label: "Hydrophobicity", category: "Residue Property", factory: function t(e, r) {
  var n = fne[r.scale], i = 1 / 0, a = -1 / 0;
  for (var o in X6) {
    var s = X6[o][n];
    i = Math.min(i, s), a = Math.max(a, s);
  }
  var u = _c.create({ listOrName: r.list.colors, domain: [a, i], minLabel: "Hydrophilic", maxLabel: "Hydrophobic" });
  return { factory: t, granularity: "group", preferSmoothing: !0, color: function(c) {
    var l;
    return at.is(c) ? l = Fe.isAtomic(c.unit) ? VI(c.unit, c.element) : UI(c.unit, c.element) : Dt.isLocation(c) && (l = Fe.isAtomic(c.aUnit) ? VI(c.aUnit, c.aUnit.elements[c.aIndex]) : UI(c.aUnit, c.aUnit.elements[c.aIndex])), u.color(l ? function(d, f) {
      var h = X6[d];
      return h === void 0 ? 0 : h[f];
    }(l, n) : 0);
  }, props: r, description: 'Assigns a color to every amino acid according to the "Experimentally determined hydrophobicity scale for proteins at membrane interfaces" by Wimely and White (doi:10.1038/nsb1096-842).', legend: u ? u.legend : void 0 };
}, getParams: function(t) {
  return zI;
}, defaultValues: z.getDefaultValues(zI), isApplicable: function(t) {
  return !!t.structure;
} }, HI = qe(13421772), qI = O({}, Cs({ type: "colors", colorList: "purples" })), hne = { name: "model-index", label: "Model Index", category: "Chain Property", factory: function t(e, r) {
  var n, i, a, o;
  if (e.structure) {
    for (var s = e.structure.root.models, u = 0, c = 0, l = s; c < l.length; c++) {
      var d = l[c];
      u = Math.max(u, ((n = pn.TrajectoryInfo.get(d)) === null || n === void 0 ? void 0 : n.size) || 0);
    }
    var f = Vu(u, r);
    o = f.legend;
    for (var h = /* @__PURE__ */ new Map(), m = 0, p = s.length; m < p; ++m) {
      var v = ((i = pn.TrajectoryInfo.get(s[m])) === null || i === void 0 ? void 0 : i.index) || 0;
      h.set(v, f.color(v));
    }
    a = function(g) {
      return at.is(g) ? h.get(pn.TrajectoryInfo.get(g.unit.model).index) : Dt.isLocation(g) ? h.get(pn.TrajectoryInfo.get(g.aUnit.model).index) : HI;
    };
  } else a = function() {
    return HI;
  };
  return { factory: t, granularity: "instance", color: a, props: r, description: "Gives every model a unique color based on the position (index) of the model in the list of models in the structure.", legend: o };
}, getParams: function(t) {
  return qI;
}, defaultValues: z.getDefaultValues(qI), isApplicable: function(t) {
  return !!t.structure && t.structure.elementCount > 0 && pn.TrajectoryInfo.get(t.structure.models[0]).size > 1;
} }, mne = qe(13421772), KI = { domain: z.Interval([0, 1]), list: z.ColorList("purples", { presetKind: "scale" }) };
function XI(t, e) {
  return Fe.isAtomic(t) ? t.model.atomicConformation.occupancy.value(e) : 0;
}
var gne = { name: "occupancy", label: "Occupancy", category: "Atom Property", factory: function t(e, r) {
  var n = _c.create({ reverse: !1, domain: r.domain, listOrName: r.list.colors });
  return { factory: t, granularity: "group", preferSmoothing: !0, color: function(i) {
    return at.is(i) ? n.color(XI(i.unit, i.element)) : Dt.isLocation(i) ? n.color(XI(i.aUnit, i.aUnit.elements[i.aIndex])) : mne;
  }, props: r, description: "Assigns a color based on the occupancy of an atom.", legend: n ? n.legend : void 0 };
}, getParams: function(t) {
  return KI;
}, defaultValues: z.getDefaultValues(KI), isApplicable: function(t) {
  return !!t.structure && t.structure.models.some(function(e) {
    return e.atomicConformation.occupancy.isDefined;
  });
} }, l7 = "dark-2", YI = qe(13421772), WI = O({}, Cs({ type: "colors", colorList: l7 })), ym = 1e4;
function d7(t) {
  return t.map(function(e) {
    return "".concat(e + ym).padStart(5, "0");
  }).join("");
}
function f7(t) {
  var e = function(a, o) {
    return Math.abs(a) < o ? 0 : Math.floor(Math.log10(Math.abs(a))) + 1;
  }(ym, 0), r = parseInt(t.substr(0, e)), n = parseInt(t.substr(e, e)), i = parseInt(t.substr(e + e, e));
  return [r - ym, n - ym, i - ym];
}
function Ib(t) {
  return t.map(function(e) {
    return e + 5;
  }).join("");
}
function jI(t) {
  for (var e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), n = 0, i = t.units.length; n < i; ++n) {
    var a = d7(t.units[n].conformation.operator.hkl);
    r.add(a);
  }
  var o = Array.from(r.values()).sort();
  return o.forEach(function(s) {
    return e.set(s, e.size);
  }), { min: f7(o[0]), max: f7(o[o.length - 1]), map: e };
}
var Dl, vne = { name: "operator-hkl", label: "Operator HKL", category: "Symmetry", factory: function t(e, r) {
  var n, i;
  if (e.structure) {
    var a = jI(e.structure.root), o = a.min, s = a.max, u = a.map, c = [];
    u.forEach(function(f, h) {
      var m = f % u.size, p = Ib(f7(h));
      c[m] === void 0 ? c[m] = p : c[m] += ", ".concat(p);
    });
    var l = { minLabel: Ib(o), maxLabel: Ib(s), valueLabel: function(f) {
      return c[f];
    } }, d = Vu(u.size, r, l);
    i = d.legend, n = function(f) {
      var h = void 0;
      if (at.is(f)) {
        var m = d7(f.unit.conformation.operator.hkl);
        h = u.get(m);
      } else Dt.isLocation(f) && (m = d7(f.aUnit.conformation.operator.hkl), h = u.get(m));
      return h === void 0 ? YI : d.color(h);
    };
  } else n = function() {
    return YI;
  };
  return { factory: t, granularity: "instance", color: n, props: r, description: "Assigns a color based on the operator HKL value of a transformed chain.", legend: i };
}, getParams: function(t) {
  var e = z.clone(WI);
  return t.structure && jI(t.structure.root).map.size > Uo[l7].list.length && (e.palette.defaultValue.name = "colors", e.palette.defaultValue.params = O(O({}, e.palette.defaultValue.params), { list: { kind: "interpolate", colors: Cl(l7).list } })), e;
}, defaultValues: z.getDefaultValues(WI), isApplicable: function(t) {
  return !!t.structure;
} };
(function(t) {
  t.Descriptor = { name: "atom_partial_charge" }, t.Provider = gc.create(t.Descriptor);
})(Dl || (Dl = {}));
var Tb = qe(16777113), ZI = { domain: z.Interval([-1, 1]), list: z.ColorList("red-white-blue", { presetKind: "scale" }) };
function QI(t, e) {
  var r;
  return (r = Dl.Provider.get(t.model)) === null || r === void 0 ? void 0 : r.data.value(e);
}
var yne = { name: "partial-charge", label: "Partial Charge", category: "Atom Property", factory: function t(e, r) {
  var n = _c.create({ domain: r.domain, listOrName: r.list.colors });
  return { factory: t, granularity: "group", preferSmoothing: !0, color: function(i) {
    var a;
    return at.is(i) ? (a = QI(i.unit, i.element)) === void 0 || Number.isNaN(a) ? Tb : n.color(a) : Dt.isLocation(i) ? (a = QI(i.aUnit, i.aUnit.elements[i.aIndex])) === void 0 || Number.isNaN(a) ? Tb : n.color(a) : Tb;
  }, props: r, description: "Assigns a color based on the partial charge of an atom.", legend: n ? n.legend : void 0 };
}, getParams: function(t) {
  return ZI;
}, defaultValues: z.getDefaultValues(ZI), isApplicable: function(t) {
  return !!t.structure && t.structure.models.some(function(e) {
    return Dl.Provider.get(e) !== void 0;
  });
} }, JI = qe(16448250), $I = O({}, Cs({ type: "colors", colorList: "many-distinct" })), bne = { name: "atom-id", label: "Atom Id", category: "Atom Property", factory: function t(e, r) {
  var n, i;
  if (e.structure) {
    var a = at.create(e.structure.root), o = function(c) {
      for (var l = /* @__PURE__ */ new Map(), d = 0, f = c.models; d < f.length; d++) for (var h = f[d].atomicHierarchy.atoms.label_atom_id, m = 0, p = h.rowCount; m < p; ++m) {
        var v = h.value(m);
        l.has(v) || l.set(v, l.size);
      }
      return l;
    }(e.structure.root), s = Array.from(o.keys()), u = Vu(o.size, r, { valueLabel: function(c) {
      return s[c];
    } });
    i = u.legend, n = function(c) {
      var l = void 0;
      if (at.is(c)) {
        var d = Qe.atom.label_atom_id(c);
        l = o.get(d);
      } else Dt.isLocation(c) && (a.unit = c.aUnit, a.element = c.aUnit.elements[c.aIndex], d = Qe.atom.label_atom_id(a), l = o.get(d));
      return l === void 0 ? JI : u.color(l);
    };
  } else n = function() {
    return JI;
  };
  return { factory: t, granularity: "group", preferSmoothing: !0, color: n, props: r, description: "Gives every atom a color based on its `label_atom_id` value.", legend: i };
}, getParams: function(t) {
  return z.clone($I);
}, defaultValues: z.getDefaultValues($I), isApplicable: function(t) {
  return !!t.structure;
} }, _ne = qe(13421772), eT = { colorList: z.ColorList({ kind: "interpolate", colors: [[Yt.white, 0], [Yt.red, 0.25], [Yt.white, 0.5], [Yt.blue, 0.75], [Yt.white, 1]] }, { offsets: !0, isEssential: !0 }) }, xne = { name: "volume-value", label: "Volume Value", category: "Miscellaneous", factory: function t(e, r) {
  for (var n = _c.create({ domain: [0, 1], listOrName: r.colorList.colors }), i = [], a = 0; a < 256; ++a) i[a] = n.color(a / 255);
  var o = { colors: i, filter: "linear" };
  return { factory: t, granularity: "direct", color: function() {
    return _ne;
  }, props: r, description: "Assign color based on the given value of a volume cell.", legend: n.legend, palette: o };
}, getParams: function(t) {
  return eT;
}, defaultValues: z.getDefaultValues(eT), isApplicable: function(t) {
  return !!t.volume;
} }, Sne = qe(13421772), tT = { list: z.ColorList("turbo", { presetKind: "scale" }) }, Cne = { name: "uni-fold", label: "Uni-Fold", category: "Residue Property", factory: function t(e, r) {
  var n = _c.create({ listOrName: r.list.colors, minLabel: "Start", maxLabel: "End" });
  return { factory: t, granularity: "group", color: function(i) {
    if (at.is(i)) {
      if (Fe.isAtomic(i.unit)) {
        if ((a = i.unit.model.atomicHierarchy.atoms.B_iso_or_equiv.value(i.element)) >= 90) return qe.fromRgb(148, 164, 239);
        if (a < 90 && a >= 70) return qe.fromRgb(148, 225, 239);
        if (a < 70 && a >= 50) return qe.fromRgb(240, 193, 145);
        if (a < 50) return qe.fromRgb(239, 156, 156);
      }
    } else if (Dt.isLocation(i) && Fe.isAtomic(i.aUnit)) {
      var a;
      if ((a = i.aUnit.model.atomicHierarchy.atoms.B_iso_or_equiv.value(i.aUnit.elements[i.aIndex])) >= 90) return qe.fromRgb(148, 164, 239);
      if (a < 90 && a >= 70) return qe.fromRgb(148, 225, 239);
      if (a < 70 && a >= 50) return qe.fromRgb(240, 193, 145);
      if (a < 50) return qe.fromRgb(239, 156, 156);
    }
    return Sne;
  }, props: r, description: "Fold", legend: n ? n.legend : void 0 };
}, getParams: function(t) {
  return tT;
}, defaultValues: z.getDefaultValues(tT), isApplicable: function(t) {
  return !!t.structure;
} }, AO = { 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 }, Ane = qe(16777215), rT = { carbonColor: z.MappedStatic("chain-id", { "chain-id": z.Group(T0), "entity-id": z.Group(Ip), "entity-source": z.Group(Tp), "operator-name": z.Group(Ep), "element-symbol": z.EmptyGroup() }, { description: "Use chain-id coloring for carbon atoms." }), saturation: z.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: z.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: z.MappedStatic("default", { default: z.EmptyGroup(), custom: z.Group(th(AO)) }) }, wne = { name: "cdr", label: "CDR", category: "Atom Property", factory: function t(e, r) {
  var n = N0(r.colors.name === "default" ? AO : r.colors.params, r.saturation, r.lightness);
  return { factory: t, granularity: r.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      if (Fe.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" ? qe.fromRgb(252, 180, 91) : qe.fromRgb(153, 154, 235) : u.toLocaleUpperCase() === "L" ? qe.fromRgb(145, 225, 192) : u.toLocaleUpperCase() === "H" ? qe.fromRgb(148, 223, 247) : qe(16777215);
      }
    } else if (Dt.isLocation(i) && Fe.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" ? qe.fromRgb(252, 180, 91) : qe.fromRgb(153, 154, 235) : u.toLocaleUpperCase() === "L" ? qe.fromRgb(145, 225, 192) : u.toLocaleUpperCase() === "H" ? qe.fromRgb(148, 223, 247) : qe(16777215);
    return Ane;
  }, props: r, description: "CDR", legend: zu(Object.keys(n).map(function(i) {
    return [i, n[i]];
  })) };
}, getParams: function(t) {
  return rT;
}, defaultValues: z.getDefaultValues(rT), isApplicable: function(t) {
  return !!t.structure;
} }, nT = qe(16448250), iT = O({ themes: z.Value([]) }, Cs({ type: "colors", colorList: "many-distinct" })), Dne = { name: "multi-theme", label: "Multi Theme", category: "Atom Property", factory: function t(e, r) {
  var n, i = r.themes;
  return n = e.structure ? function(a, o) {
    if (at.is(a)) for (var s = 0; s < i.length; s++) {
      var u = i[s];
      if ((c = So.toStructure(u.bundle, e.structure)).hasElement(a)) return u.colorTheme.color(a, o);
    }
    else if (Dt.isLocation(a) && Fe.isAtomic(a.aUnit)) for (s = 0; s < i.length; s++) {
      u = i[s];
      var c = So.toStructure(u.bundle, e.structure), l = at.create(a.aStructure, a.aUnit, a.aUnit.elements[a.aIndex]);
      if (c.hasElement(l)) return u.colorTheme.color(a, o);
    }
    return nT;
  } : function() {
    return nT;
  }, { factory: t, granularity: "group", preferSmoothing: !0, color: n, props: r, description: "Structure allows multi theme based on location" };
}, getParams: function(t) {
  return z.clone(iT);
}, defaultValues: z.getDefaultValues(iT), isApplicable: function(t) {
  return !!t.structure;
} }, wO = { 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 }, Ene = qe(16777215), aT = { carbonColor: z.MappedStatic("chain-id", { "chain-id": z.Group(T0), "entity-id": z.Group(Ip), "entity-source": z.Group(Tp), "operator-name": z.Group(Ep), "element-symbol": z.EmptyGroup() }, { description: "Use chain-id coloring for carbon atoms." }), saturation: z.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: z.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: z.MappedStatic("default", { default: z.EmptyGroup(), custom: z.Group(th(wO)) }) }, Ine = { name: "em-confidence", label: "EM Confidence", category: "Residue Property", factory: function t(e, r) {
  var n = N0(r.colors.name === "default" ? wO : r.colors.params, r.saturation, r.lightness);
  return { factory: t, granularity: r.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      if (Fe.isAtomic(i.unit)) {
        var a = i.unit.model.atomicHierarchy.atoms.em_confidence;
        switch (!0) {
          case (o = parseFloat(a.value(i.element))) < -1:
            return qe.fromRgb(239, 139, 139);
          case (o >= -1 && o < -0.8):
            return qe.fromRgb(239, 151, 139);
          case (o >= -0.8 && o < -0.6):
            return qe.fromRgb(239, 167, 138);
          case (o >= -0.6 && o < -0.4):
            return qe.fromRgb(239, 190, 136);
          case (o >= -0.4 && o < -0.2):
            return qe.fromRgb(239, 214, 136);
          case (o >= -0.2 && o < 0):
            return qe.fromRgb(239, 236, 135);
          case (o >= 0 && o < 0.2):
            return qe.fromRgb(134, 239, 134);
          case (o >= 0.2 && o < 0.4):
            return qe.fromRgb(134, 239, 227);
          case (o >= 0.4 && o < 0.6):
            return qe.fromRgb(134, 224, 239);
          case (o >= 0.6 && o < 0.8):
            return qe.fromRgb(134, 200, 239);
          case (o >= 0.8 && o <= 1):
            return qe.fromRgb(133, 175, 239);
          case o > 1:
            return qe.fromRgb(134, 153, 239);
          default:
            return qe(16777215);
        }
      }
    } else if (Dt.isLocation(i) && Fe.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 qe.fromRgb(239, 139, 139);
        case (o >= -1 && o < -0.8):
          return qe.fromRgb(239, 151, 139);
        case (o >= -0.8 && o < -0.6):
          return qe.fromRgb(239, 167, 138);
        case (o >= -0.6 && o < -0.4):
          return qe.fromRgb(239, 190, 136);
        case (o >= -0.4 && o < -0.2):
          return qe.fromRgb(239, 214, 136);
        case (o >= -0.2 && o < 0):
          return qe.fromRgb(239, 236, 135);
        case (o >= 0 && o < 0.2):
          return qe.fromRgb(134, 239, 134);
        case (o >= 0.2 && o < 0.4):
          return qe.fromRgb(134, 239, 227);
        case (o >= 0.4 && o < 0.6):
          return qe.fromRgb(134, 224, 239);
        case (o >= 0.6 && o < 0.8):
          return qe.fromRgb(134, 200, 239);
        case (o >= 0.8 && o <= 1):
          return qe.fromRgb(133, 175, 239);
        case o > 1:
          return qe.fromRgb(134, 153, 239);
        default:
          return qe(16777215);
      }
    }
    return Ene;
  }, props: r, description: "EM", legend: zu(Object.keys(n).map(function(i) {
    return [i, n[i]];
  })) };
}, getParams: function(t) {
  return aT;
}, defaultValues: z.getDefaultValues(aT), isApplicable: function(t) {
  return !!t.structure;
} }, H3 = { 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 }, q3 = window.materialColors, oT = function() {
  Object.keys(q3.settings).forEach(function(t) {
    H3[t] = q3.getColorNumber(t);
  });
};
q3 && (oT(), q3.setColorsSubject.subscribe(function() {
  oT();
}));
var Mb = H3, sT = qe(16777215), DO = { carbonColor: z.MappedStatic("chain-id", { "chain-id": z.Group(O({}, T0)), "operator-name": z.Group(O({}, Ep)), "element-symbol": z.Group({}) }, { description: "Use chain-id coloring for carbon atoms." }), saturation: z.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: z.Numeric(0.2, { min: -6, max: 6, step: 0.1 }) };
function Tne(t) {
  return DO;
}
function EO(t, e) {
  var r = N0(Mb, e.saturation, e.lightness);
  function n(i, a) {
    return function(o, s) {
      var u = o[s];
      return u === void 0 ? sT : u;
    }(r, i);
  }
  return { factory: EO, granularity: e.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      if (Fe.isAtomic(i.unit)) return n(i.unit.model.atomicHierarchy.atoms.type_symbol.value(i.element));
    } else if (Dt.isLocation(i) && Fe.isAtomic(i.aUnit))
      return n(i.aUnit.model.atomicHierarchy.atoms.type_symbol.value(i.aUnit.elements[i.aIndex]));
    return sT;
  }, props: e, description: "Assigns a color to every atom according to its chemical element.", legend: zu(Object.keys(Mb).map(function(i) {
    return [i, Mb[i]];
  })) };
}
var El, _t, Lr, Mne = { name: "material-element-symbol", label: "Material Element Symbol", category: "Atom Property", factory: EO, getParams: Tne, defaultValues: z.getDefaultValues(DO), isApplicable: function(t) {
  return !!t.structure;
} };
function Pb(t, e, r) {
  switch (r) {
    case _t.Highlight:
      t[e] |= 1;
      break;
    case _t.RemoveHighlight:
      t[e] &= -2;
      break;
    case _t.Select:
      t[e] |= 2;
      break;
    case _t.Deselect:
      t[e] &= -3;
      break;
    case _t.Toggle:
      t[e] ^= 2;
      break;
    case _t.Clear:
      t[e] = 0;
  }
}
function p7(t, e, r) {
  if (r === _t.None) return !1;
  if (Se.is(e)) {
    var n = Se.start(e), i = Se.end(e), a = n + 3 >> 2, o = a + (i - 4 * a >> 2);
    if (o <= a) {
      for (var s = n; s < i; ++s) Pb(t, s, r);
      return !0;
    }
    var u = new Uint32Array(t.buffer, 0, t.buffer.byteLength >> 2), c = n, l = Math.min(4 * a, i), d = Math.max(n, 4 * o), f = i;
    switch (r) {
      case _t.Highlight:
        for (s = a; s < o; ++s) u[s] |= 16843009;
        break;
      case _t.RemoveHighlight:
        for (s = a; s < o; ++s) u[s] &= -16843010;
        break;
      case _t.Select:
        for (s = a; s < o; ++s) u[s] |= 33686018;
        break;
      case _t.Deselect:
        for (s = a; s < o; ++s) u[s] &= -33686019;
        break;
      case _t.Toggle:
        for (s = a; s < o; ++s) u[s] ^= 33686018;
        break;
      case _t.Clear:
        for (s = a; s < o; ++s) u[s] = 0;
        break;
      default:
        ca();
    }
    for (s = c; s < l; ++s) Pb(t, s, r);
    for (s = d; s < f; ++s) Pb(t, s, r);
  } else switch (r) {
    case _t.Highlight:
      s = 0;
      for (var h = e.length; s < h; ++s) t[e[s]] |= 1;
      break;
    case _t.RemoveHighlight:
      for (s = 0, h = e.length; s < h; ++s) t[e[s]] &= -2;
      break;
    case _t.Select:
      for (s = 0, h = e.length; s < h; ++s) t[e[s]] |= 2;
      break;
    case _t.Deselect:
      for (s = 0, h = e.length; s < h; ++s) t[e[s]] &= -3;
      break;
    case _t.Toggle:
      for (s = 0, h = e.length; s < h; ++s) t[e[s]] ^= 2;
      break;
    case _t.Clear:
      for (s = 0, h = e.length; s < h; ++s) t[e[s]] = 0;
      break;
    default:
      ca();
  }
  return !0;
}
(function(t) {
  t.PaletteScale = 16777215, t.EmptyFactory = function() {
    return t.Empty;
  };
  var e = qe(13421772);
  t.Empty = { factory: t.EmptyFactory, granularity: "uniform", color: function() {
    return e;
  }, props: {} }, t.areEqual = function(r, n) {
    return r.contextHash === n.contextHash && r.factory === n.factory && nf(r.props, n.props);
  }, t.EmptyProvider = { name: "", label: "", category: "", factory: t.EmptyFactory, getParams: function() {
    return {};
  }, defaultValues: {}, isApplicable: function() {
    return !0;
  } }, t.createRegistry = function() {
    return new dO(t.BuiltIn, t.EmptyProvider);
  }, t.BuiltIn = { "atom-id": bne, "carbohydrate-symbol": Vte, "chain-id": zre, "element-index": Vre, "element-symbol": Jre, "material-element-symbol": Mne, "entity-id": Kre, "entity-source": jre, hydrophobicity: pne, illustrative: dne, "model-index": hne, "molecule-type": ene, occupancy: gne, "operator-hkl": vne, "operator-name": Hre, "partial-charge": yne, "polymer-id": tne, "polymer-index": rne, "residue-name": nne, "secondary-structure": ine, "sequence-id": one, "shape-group": _re, uncertainty: cne, "unit-index": sne, uniform: Hte, "volume-value": xne, "uni-fold": Cne, cdr: wne, "em-confidence": Ine, "multi-theme": Dne };
})(El || (El = {})), function(t) {
  t[t.None = 0] = "None", t[t.Highlight = 1] = "Highlight", t[t.RemoveHighlight = 2] = "RemoveHighlight", t[t.Select = 4] = "Select", t[t.Deselect = 8] = "Deselect", t[t.Toggle = 16] = "Toggle", t[t.Clear = 32] = "Clear";
}(_t || (_t = {})), function(t) {
  t.is = Ga.has, t.All = _t.Highlight | _t.RemoveHighlight | _t.Select | _t.Deselect | _t.Toggle | _t.Clear, t.Highlighting = _t.Highlight | _t.RemoveHighlight | _t.Clear, t.Selecting = _t.Select | _t.Deselect | _t.Toggle | _t.Clear, t.isReverse = function(e, r) {
    return e === _t.Highlight && r === _t.RemoveHighlight || e === _t.RemoveHighlight && r === _t.Highlight || e === _t.Select && r === _t.Deselect || e === _t.Deselect && r === _t.Select || e === _t.Toggle && r === _t.Toggle;
  };
}(Lr || (Lr = {}));
var px = { kind: "every-loci" };
function qo(t) {
  return !!t && t.kind === "every-loci";
}
var Qr, Dn = { kind: "empty-loci" };
function ef(t) {
  return !!t && t.kind === "empty-loci";
}
function Fm(t) {
  return !!t && t.kind === "data-loci";
}
function Pne(t, e) {
  if (!E_(t.data, e.data) || t.tag !== e.tag || t.elements.length !== e.elements.length) return !1;
  for (var r = 0, n = t.elements.length; r < n; ++r) if (!E_(t.elements[r], e.elements[r])) return !1;
  return !0;
}
function Bne(t) {
  return t.elements.length === 0;
}
function hx(t, e, r, n, i) {
  return { kind: "data-loci", tag: t, data: e, elements: r, getBoundingSphere: n, getLabel: i };
}
function Fne(t) {
  return Object.keys(t).filter(function(e) {
    return !isNaN(e);
  }).map(function(e) {
    return +e;
  }).sort(function(e, r) {
    return e - r;
  }).map(function(e) {
    return t[e];
  });
}
function Bb(t, e, r) {
  return t && t[e] !== void 0 ? t[e] : r;
}
function je(t) {
  for (var e = [], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r];
  return { kind: "alias", aliases: e, symbol: t };
}
function av(t, e) {
  for (var r = [], n = 2; n < arguments.length; n++) r[n - 2] = arguments[n];
  return t.info.namespace = "molscript-macro", t.id = "molscript-macro.".concat(t.info.name), { kind: "macro", symbol: t, translate: e, aliases: Ze([t.info.name], r, !0) };
}
function Nne(t) {
  return t.kind === "alias" || t.kind === "macro";
}
(function(t) {
  var e = new cu("98");
  function r(o, s) {
    var u;
    if (o.kind !== "every-loci" && o.kind !== "empty-loci") return s || (s = Me()), o.kind === "structure-loci" ? Me.copy(s, o.structure.boundary.sphere) : o.kind === "element-loci" ? Me.copy(s, Xe.getBoundary(o).sphere) : o.kind === "bond-loci" ? Dt.getBoundingSphere(o, s) : o.kind === "shape-loci" ? Me.copy(s, o.shape.geometry.boundingSphere) : o.kind === "group-loci" ? bo.getBoundingSphere(o, s) : o.kind === "data-loci" ? (u = o.getBoundingSphere) === null || u === void 0 ? void 0 : u.call(o, s) : o.kind === "volume-loci" ? or.getBoundingSphere(o.volume, s) : o.kind === "isosurface-loci" ? or.Isosurface.getBoundingSphere(o.volume, o.isoValue, s) : o.kind === "cell-loci" ? or.Cell.getBoundingSphere(o.volume, o.indices, s) : void 0;
  }
  t.getBundleBoundingSphere = function(o) {
    var s = o.loci.map(function(h) {
      return r(h);
    }).filter(function(h) {
      return !!h;
    });
    e.reset();
    for (var u = 0, c = s; u < c.length; u++) {
      var l = c[u];
      e.includePositionRadius(l.center, l.radius);
    }
    e.finishedIncludeStep();
    for (var d = 0, f = s; d < f.length; d++)
      l = f[d], e.radiusPositionRadius(l.center, l.radius);
    return e.getSphere();
  }, t.areEqual = function(o, s) {
    return !(!qo(o) || !qo(s)) || !(!ef(o) || !ef(s)) || (Fm(o) && Fm(s) ? Pne(o, s) : tt.isLoci(o) && tt.isLoci(s) ? tt.areLociEqual(o, s) : Xe.is(o) && Xe.is(s) ? Xe.areEqual(o, s) : Dt.isLoci(o) && Dt.isLoci(s) ? Dt.areLociEqual(o, s) : er.isLoci(o) && er.isLoci(s) ? er.areLociEqual(o, s) : bo.isLoci(o) && bo.isLoci(s) ? bo.areLociEqual(o, s) : or.isLoci(o) && or.isLoci(s) ? or.areLociEqual(o, s) : or.Isosurface.isLoci(o) && or.Isosurface.isLoci(s) ? or.Isosurface.areLociEqual(o, s) : !(!or.Cell.isLoci(o) || !or.Cell.isLoci(s)) && or.Cell.areLociEqual(o, s));
  }, t.isEvery = function(o) {
    return !!o && o.kind === "every-loci";
  }, t.isEmpty = function(o) {
    return !qo(o) && (!!ef(o) || (Fm(o) ? Bne(o) : tt.isLoci(o) ? tt.isLociEmpty(o) : Xe.is(o) ? Xe.isEmpty(o) : Dt.isLoci(o) ? Dt.isLociEmpty(o) : er.isLoci(o) ? er.isLociEmpty(o) : bo.isLoci(o) ? bo.isLociEmpty(o) : or.isLoci(o) ? or.isLociEmpty(o) : or.Isosurface.isLoci(o) ? or.Isosurface.isLociEmpty(o) : !!or.Cell.isLoci(o) && or.Cell.isLociEmpty(o)));
  }, t.remap = function(o, s) {
    return s instanceof tt && (Xe.is(o) ? o = Xe.remap(o, s) : tt.isLoci(o) ? o = tt.remapLoci(o, s) : Dt.isLoci(o) && (o = Dt.remapLoci(o, s))), o;
  }, t.getBoundingSphere = r;
  var n = Me.zero();
  t.getCenter = function(o, s) {
    var u = r(o, n);
    return u ? E.copy(s || E(), u.center) : void 0;
  }, t.getPrincipalAxes = function(o) {
    if (o.kind !== "every-loci" && o.kind !== "empty-loci") return o.kind === "structure-loci" ? Xe.getPrincipalAxes(tt.toStructureElementLoci(o.structure)) : o.kind === "element-loci" ? Xe.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 Xe.is(o) ? Xe.extendToWholeResidues(o, !0) : o;
  }, chain: function(o) {
    return Xe.is(o) ? Xe.extendToWholeChains(o) : o;
  }, entity: function(o) {
    return Xe.is(o) ? Xe.extendToWholeEntities(o) : o;
  }, model: function(o) {
    return Xe.is(o) ? Xe.extendToWholeModels(o) : o;
  }, operator: function(o) {
    return Xe.is(o) ? Xe.extendToWholeOperators(o) : o;
  }, structure: function(o) {
    return Xe.is(o) ? tt.toStructureElementLoci(o.structure) : bo.isLoci(o) ? er.Loci(o.shape) : o;
  }, elementInstances: function(o) {
    return Xe.is(o) ? Xe.extendToAllInstances(o) : o;
  }, residueInstances: function(o) {
    return Xe.is(o) ? Xe.extendToAllInstances(Xe.extendToWholeResidues(o, !0)) : o;
  }, chainInstances: function(o) {
    return Xe.is(o) ? Xe.extendToAllInstances(Xe.extendToWholeChains(o)) : o;
  } };
  function a(o, s) {
    return i[s](o);
  }
  t.GranularityOptions = z.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") ? [mc(o), "With Symmetry"] : mc(o);
    }
  }), t.simpleGranularity = function(o) {
    return o.replace("Instances", "");
  }, t.applyGranularity = a, t.normalize = function(o, s, u) {
    return u === void 0 && (u = !1), (s !== "element" || u) && Dt.isLoci(o) && (o = Dt.toStructureElementLoci(o)), tt.isLoci(o) && (o = tt.toStructureElementLoci(o.structure)), Xe.is(o) && (o = Xe.remap(o, o.structure.root)), s && (o = a(o, s)), o;
  };
})(Qr || (Qr = {}));
var Rne = [["Core symbols", je(pe.core.type.bool, "bool"), je(pe.core.type.num, "num"), je(pe.core.type.str, "str"), je(pe.core.type.regex, "regex"), je(pe.core.type.list, "list"), je(pe.core.type.set, "set"), je(pe.core.type.compositeKey, "composite-key"), je(pe.core.logic.not, "not"), je(pe.core.logic.and, "and"), je(pe.core.logic.or, "or"), je(pe.core.ctrl.if, "if"), je(pe.core.ctrl.fn, "fn"), je(pe.core.ctrl.eval, "eval"), je(pe.core.math.add, "add", "+"), je(pe.core.math.sub, "sub", "-"), je(pe.core.math.mult, "mult", "*"), je(pe.core.math.div, "div", "/"), je(pe.core.math.pow, "pow", "**"), je(pe.core.math.mod, "mod"), je(pe.core.math.min, "min"), je(pe.core.math.max, "max"), je(pe.core.math.floor, "floor"), je(pe.core.math.ceil, "ceil"), je(pe.core.math.roundInt, "round"), je(pe.core.math.abs, "abs"), je(pe.core.math.sqrt, "sqrt"), je(pe.core.math.cbrt, "cbrt"), je(pe.core.math.sin, "sin"), je(pe.core.math.cos, "cos"), je(pe.core.math.tan, "tan"), je(pe.core.math.asin, "asin"), je(pe.core.math.acos, "acos"), je(pe.core.math.atan, "atan"), je(pe.core.math.sinh, "sinh"), je(pe.core.math.cosh, "cosh"), je(pe.core.math.tanh, "tanh"), je(pe.core.math.exp, "exp"), je(pe.core.math.log, "log"), je(pe.core.math.log10, "log10"), je(pe.core.math.atan2, "atan2"), je(pe.core.rel.eq, "eq", "="), je(pe.core.rel.neq, "neq", "!="), je(pe.core.rel.lt, "lt", "<"), je(pe.core.rel.lte, "lte", "<="), je(pe.core.rel.gr, "gr", ">"), je(pe.core.rel.gre, "gre", ">="), je(pe.core.rel.inRange, "in-range"), je(pe.core.str.concat, "concat"), je(pe.core.str.match, "regex.match"), je(pe.core.list.getAt, "list.get"), je(pe.core.set.has, "set.has"), je(pe.core.set.isSubset, "set.subset")], ["Structure", ["Types", je(pe.structureQuery.type.entityType, "ent-type"), je(pe.structureQuery.type.authResidueId, "auth-resid"), je(pe.structureQuery.type.labelResidueId, "label-resid"), je(pe.structureQuery.type.ringFingerprint, "ringfp"), je(pe.structureQuery.type.bondFlags, "bond-flags")], ["Slots", je(pe.structureQuery.slot.elementSetReduce, "atom.set.reduce.value")], ["Generators", je(pe.structureQuery.generator.atomGroups, "sel.atom.atom-groups"), je(pe.structureQuery.generator.queryInSelection, "sel.atom.query-in-selection"), je(pe.structureQuery.generator.rings, "sel.atom.rings"), je(pe.structureQuery.generator.empty, "sel.atom.empty"), je(pe.structureQuery.generator.all, "sel.atom.all"), je(pe.structureQuery.generator.bondedAtomicPairs, "sel.atom.bonded-pairs"), av(dm("sel.atom.atoms", xt.Dictionary({ 0: et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to each atom." }) }), pt.ElementSelection, "A selection of singleton atom sets."), function(t) {
  return Nt.struct.generator.atomGroups({ "atom-test": Bb(t, 0, !0) });
}), av(dm("sel.atom.res", xt.Dictionary({ 0: et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each residue." }) }), pt.ElementSelection, "A selection of atom sets grouped by residue."), function(t) {
  return Nt.struct.generator.atomGroups({ "residue-test": Bb(t, 0, !0), "group-by": Nt.ammp("residueKey") });
}), av(dm("sel.atom.chains", xt.Dictionary({ 0: et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each chain." }) }), pt.ElementSelection, "A selection of atom sets grouped by chain."), function(t) {
  return Nt.struct.generator.atomGroups({ "chain-test": Bb(t, 0, !0), "group-by": Nt.ammp("chainKey") });
})], ["Modifiers", je(pe.structureQuery.modifier.queryEach, "sel.atom.query-each"), je(pe.structureQuery.modifier.intersectBy, "sel.atom.intersect-by"), je(pe.structureQuery.modifier.exceptBy, "sel.atom.except-by"), je(pe.structureQuery.modifier.unionBy, "sel.atom.union-by"), je(pe.structureQuery.modifier.union, "sel.atom.union"), je(pe.structureQuery.modifier.cluster, "sel.atom.cluster"), je(pe.structureQuery.modifier.includeSurroundings, "sel.atom.include-surroundings"), je(pe.structureQuery.modifier.surroundingLigands, "sel.atom.surrounding-ligands"), je(pe.structureQuery.modifier.includeConnected, "sel.atom.include-connected"), je(pe.structureQuery.modifier.expandProperty, "sel.atom.expand-property")], ["Filters", je(pe.structureQuery.filter.pick, "sel.atom.pick"), je(pe.structureQuery.filter.first, "sel.atom.first"), je(pe.structureQuery.filter.withSameAtomProperties, "sel.atom.with-same-atom-properties"), je(pe.structureQuery.filter.intersectedBy, "sel.atom.intersected-by"), je(pe.structureQuery.filter.within, "sel.atom.within"), je(pe.structureQuery.filter.isConnectedTo, "sel.atom.is-connected-to")], ["Combinators", je(pe.structureQuery.combinator.intersect, "sel.atom.intersect"), je(pe.structureQuery.combinator.merge, "sel.atom.merge"), je(pe.structureQuery.combinator.distanceCluster, "sel.atom.dist-cluster")], ["Atom Set Properties", je(pe.structureQuery.atomSet.atomCount, "atom.set.atom-count"), je(pe.structureQuery.atomSet.countQuery, "atom.set.count-query"), je(pe.structureQuery.atomSet.reduce, "atom.set.reduce"), je(pe.structureQuery.atomSet.propertySet, "atom.set.property")], ["Atom Properties", je(pe.structureQuery.atomProperty.core.elementSymbol, "atom.el"), je(pe.structureQuery.atomProperty.core.vdw, "atom.vdw"), je(pe.structureQuery.atomProperty.core.mass, "atom.mass"), je(pe.structureQuery.atomProperty.core.atomicNumber, "atom.atomic-number"), je(pe.structureQuery.atomProperty.core.x, "atom.x"), je(pe.structureQuery.atomProperty.core.y, "atom.y"), je(pe.structureQuery.atomProperty.core.z, "atom.z"), je(pe.structureQuery.atomProperty.core.sourceIndex, "atom.src-index"), je(pe.structureQuery.atomProperty.core.operatorName, "atom.op-name"), je(pe.structureQuery.atomProperty.core.modelIndex, "atom.model-index"), je(pe.structureQuery.atomProperty.core.modelLabel, "atom.model-label"), je(pe.structureQuery.atomProperty.core.atomKey, "atom.key"), je(pe.structureQuery.atomProperty.core.bondCount, "atom.bond-count"), je(pe.structureQuery.atomProperty.topology.connectedComponentKey, "atom.key.molecule"), je(pe.structureQuery.atomProperty.macromolecular.authResidueId, "atom.auth-resid"), je(pe.structureQuery.atomProperty.macromolecular.labelResidueId, "atom.label-resid"), je(pe.structureQuery.atomProperty.macromolecular.residueKey, "atom.key.res"), je(pe.structureQuery.atomProperty.macromolecular.chainKey, "atom.key.chain"), je(pe.structureQuery.atomProperty.macromolecular.entityKey, "atom.key.entity"), je(pe.structureQuery.atomProperty.macromolecular.isHet, "atom.is-het"), je(pe.structureQuery.atomProperty.macromolecular.id, "atom.id"), je(pe.structureQuery.atomProperty.macromolecular.label_atom_id, "atom.label_atom_id"), je(pe.structureQuery.atomProperty.macromolecular.label_alt_id, "atom.label_alt_id", "atom.altloc"), je(pe.structureQuery.atomProperty.macromolecular.label_comp_id, "atom.label_comp_id"), je(pe.structureQuery.atomProperty.macromolecular.label_asym_id, "atom.label_asym_id"), je(pe.structureQuery.atomProperty.macromolecular.label_entity_id, "atom.label_entity_id"), je(pe.structureQuery.atomProperty.macromolecular.label_seq_id, "atom.label_seq_id"), je(pe.structureQuery.atomProperty.macromolecular.auth_atom_id, "atom.auth_atom_id", "atom.name"), je(pe.structureQuery.atomProperty.macromolecular.auth_comp_id, "atom.auth_comp_id", "atom.resname"), je(pe.structureQuery.atomProperty.macromolecular.auth_asym_id, "atom.auth_asym_id", "atom.chain"), je(pe.structureQuery.atomProperty.macromolecular.auth_seq_id, "atom.auth_seq_id", "atom.resno"), je(pe.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, "atom.pdbx_PDB_ins_code", "atom.inscode"), je(pe.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, "atom.pdbx_formal_charge"), je(pe.structureQuery.atomProperty.macromolecular.occupancy, "atom.occupancy"), je(pe.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, "atom.B_iso_or_equiv", "atom.bfactor"), je(pe.structureQuery.atomProperty.macromolecular.entityType, "atom.entity-type"), je(pe.structureQuery.atomProperty.macromolecular.entitySubtype, "atom.entity-subtype"), je(pe.structureQuery.atomProperty.macromolecular.entityPrdId, "atom.entity-prd-id"), je(pe.structureQuery.atomProperty.macromolecular.entityDescription, "atom.entity-description"), je(pe.structureQuery.atomProperty.macromolecular.objectPrimitive, "atom.object-primitive"), je(pe.structureQuery.atomProperty.macromolecular.chemCompType, "atom.chem-comp-type"), je(pe.structureQuery.atomProperty.macromolecular.secondaryStructureKey, "atom.key.sec-struct"), je(pe.structureQuery.atomProperty.macromolecular.isModified, "atom.is-modified"), je(pe.structureQuery.atomProperty.macromolecular.modifiedParentName, "atom.modified-parent")], ["Bond Properties", je(pe.structureQuery.bondProperty.order, "bond.order"), je(pe.structureQuery.bondProperty.length, "bond.length"), je(pe.structureQuery.bondProperty.atomA, "bond.atom-a"), je(pe.structureQuery.bondProperty.atomB, "bond.atom-b"), av(dm("bond.is", xt.List(pt.BondFlag), xe.Bool, "Test if the current bond has at least one (or all if partial = false) of the specified flags: ".concat(xe.oneOfValues(pt.BondFlag).join(", "))), function(t) {
  return Nt.core.flags.hasAny([Nt.struct.bondProperty.flags(), Nt.struct.type.bondFlags(Fne(t))]);
})]]], IO = [];
(function t(e) {
  for (var r = 0, n = e; r < n.length; r++) {
    var i = n[r];
    Nne(i) ? IO.push(i) : i instanceof Array && t(i);
  }
})(Rne);
var One = function() {
  for (var t = [], e = /* @__PURE__ */ Object.create(null), r = bn.create(), n = bn.create(), i = 0, a = IO; i < a.length; i++) {
    for (var o = a[i], s = 0, u = o.aliases; s < u.length; s++) {
      var c = u[s];
      if (t.push([c, o]), e[c]) throw new Error("Alias '".concat(c, "' already in use."));
      e[c] = o;
    }
    var l = o.symbol.args;
    if (l.kind === "dictionary") for (var d = 0, f = Object.keys(l.map); d < f.length; d++) {
      c = f[d], isNaN(c) && bn.add(r, c, c);
      var h = l.map[c];
      h.type.kind === "oneof" && xe.oneOfValues(h.type).forEach(function(m) {
        return bn.add(n, m, m);
      });
    }
    else l.type.kind === "oneof" && xe.oneOfValues(l.type).forEach(function(m) {
      return bn.add(n, m, m);
    });
  }
  return { symbolList: t, symbolMap: e, namedArgs: r.array, constants: n.array };
}(), I1 = One.symbolMap;
function bm(t) {
  if (wa.isLiteral(t)) return t;
  if (wa.isSymbol(t)) {
    if (!I1[t.name]) return t;
    var e = I1[t.name];
    if (e.kind === "alias") return wa.Symbol(I1[t.name].symbol.id);
    throw e.translate([]);
  }
  var r = wa.isSymbol(t.head) && !!I1[t.head.name] && I1[t.head.name].kind === "macro", n = r ? t.head : bm(t.head), i = n !== t.head;
  if (!t.args) return r ? bm(t.head) : i ? wa.Apply(n) : t;
  var a, o = !1;
  if (wa.isArgumentsArray(t.args)) {
    a = [];
    for (var s = 0, u = t.args.length; s < u; s++)
      (d = t.args[s]) !== (f = bm(d)) && (o = !0), a[a.length] = f;
    if (o || (a = t.args), !r && !i && !o) return t;
  } else {
    a = {};
    for (var c = 0, l = Object.keys(t.args); c < l.length; c++) {
      var d, f, h = l[c];
      (d = t.args[h]) !== (f = bm(d)) && (o = !0), a[h] = f;
    }
    if (!r && !i && !o) return t;
    o || (a = t.args);
  }
  if (r) {
    var m = I1[t.head.name];
    return m.kind !== "macro" ? wa.Apply(n, a) : m.translate(a);
  }
  return wa.Apply(n, a);
}
function Lne(t) {
  return bm(t);
}
var h7, Su = function() {
  function t(e) {
    this._ = e;
  }
  return t.prototype.parse = function(e) {
    var r = this.skip(t.eof)._(e, 0);
    return r.status ? { success: !0, value: r.value } : { success: !1, index: TO(e, r.furthest), expected: r.expected };
  }, t.prototype.tryParse = function(e) {
    var r = this.parse(e);
    if (r.success) return r.value;
    var n = 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));
    }(e, r);
    throw new Error(n);
  }, t.prototype.or = function(e) {
    return t.alt(this, e);
  }, t.prototype.trim = function(e) {
    return this.wrap(e, e);
  }, t.prototype.wrap = function(e, r) {
    return Fb(1, typeof e == "string" ? t.string(e) : e, this, typeof r == "string" ? t.string(r) : r);
  }, t.prototype.thru = function(e) {
    return e(this);
  }, t.prototype.then = function(e) {
    return Fb(1, this, e);
  }, t.prototype.many = function() {
    var e = this;
    return new t(function(r, n) {
      for (var i = [], a = void 0; ; ) {
        if (!(a = Js(e._(r, n), a)).status) return Js(Wa(n, i), a);
        if (n === 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");
        n = a.index, i.push(a.value);
      }
    });
  }, t.prototype.times = function(e, r) {
    var n = this, i = r === void 0 ? e : r;
    return new t(function(a, o) {
      var s, u = [], c = void 0, l = void 0;
      for (s = 0; s < e; s++) {
        if (l = Js(c = n._(a, o), l), !c.status) return l;
        o = c.index, u.push(c.value);
      }
      for (; s < i && (l = Js(c = n._(a, o), l), c.status); s += 1) o = c.index, u.push(c.value);
      return Js(Wa(o, u), l);
    });
  }, t.prototype.result = function(e) {
    return this.map(function() {
      return e;
    });
  }, t.prototype.atMost = function(e) {
    return this.times(0, e);
  }, t.prototype.atLeast = function(e) {
    return t.seq(this.times(e), this.many()).map(function(r) {
      return Ze(Ze([], r[0], !0), r[1], !0);
    });
  }, t.prototype.map = function(e) {
    var r = this;
    return new t(function(n, i) {
      var a = r._(n, i);
      return a.status ? Js(Wa(a.index, e(a.value)), a) : a;
    });
  }, t.prototype.skip = function(e) {
    return Fb(0, this, e);
  }, t.prototype.mark = function() {
    return t.seq(t.index, this, t.index).map(function(e) {
      return { start: e[0], value: e[1], end: e[2] };
    });
  }, t.prototype.node = function(e) {
    return t.seq(t.index, this, t.index).map(function(r) {
      return { name: e, start: r[0], value: r[1], end: r[2] };
    });
  }, t.prototype.sepBy = function(e) {
    return t.sepBy(this, e);
  }, t.prototype.sepBy1 = function(e) {
    return t.sepBy1(this, e);
  }, t.prototype.lookahead = function(e) {
    return this.skip(t.lookahead(e));
  }, t.prototype.notFollowedBy = function(e) {
    return this.skip(t.notFollowedBy(e));
  }, t.prototype.desc = function(e) {
    var r = this;
    return new t(function(n, i) {
      var a = r._(n, i);
      return a.status || (a.expected = [e]), a;
    });
  }, t.prototype.fallback = function(e) {
    return this.or(t.succeed(e));
  }, t.prototype.ap = function(e) {
    return t.seq(e, this).map(function(r) {
      return (0, r[0])(r[1]);
    });
  }, t.prototype.chain = function(e) {
    var r = this;
    return new t(function(n, i) {
      var a = r._(n, i);
      return a.status ? Js(e(a.value)._(n, a.index), a) : a;
    });
  }, t;
}();
function Fb(t) {
  for (var e = [], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r];
  var n = e.length;
  return new Su(function(i, a) {
    for (var o, s, u = a, c = 0; c < n; c++) {
      if (!(o = Js(e[c]._(i, u), o)).status) return o;
      t === c && (s = o.value), u = o.index;
    }
    return Js(Wa(u, s), o);
  });
}
function Wa(t, e) {
  return { status: !0, index: t, value: e };
}
function jc(t, e) {
  return { status: !1, furthest: t, expected: [e] };
}
function Js(t, e) {
  if (!e || t.status || e.status || t.furthest > e.furthest) return t;
  var r = t.furthest === e.furthest ? function(n, i) {
    var a = n.length, o = i.length;
    if (a === 0) return i;
    if (o === 0) return n;
    for (var s = /* @__PURE__ */ new Set(), u = [], c = 0; c < a; c++) s.has(n[c]) || (u[u.length] = n[c], s.add(n[c]));
    for (c = 0; c < o; c++) s.has(i[c]) || (u[u.length] = i[c], s.add(i[c]));
    return u.sort(), u;
  }(t.expected, e.expected) : e.expected;
  return { status: t.status, furthest: e.furthest, expected: r };
}
function TO(t, e) {
  var r = t.slice(0, e).split(`
`);
  return { offset: e, line: r.length, column: r[r.length - 1].length + 1 };
}
function kne(t) {
  return t instanceof Su;
}
(function(t) {
  function e() {
    for (var c = [], l = 0; l < arguments.length; l++) c[l] = arguments[l];
    var d = c.length;
    return new t(function(f, h) {
      for (var m, p = new Array(d), v = h, g = 0; g < d; g++) {
        if (!(m = Js(c[g]._(f, v), m)).status) return m;
        p[g] = m.value, v = m.index;
      }
      return Js(Wa(v, p), m);
    });
  }
  function r() {
    for (var c = [], l = 0; l < arguments.length; l++) c[l] = arguments[l];
    return c.length === 0 ? s("zero alternates") : new t(function(d, f) {
      for (var h, m = 0; m < c.length; m++) if ((h = Js(c[m]._(d, f), h)).status) return h;
      return h;
    });
  }
  function n(c, l) {
    return e(c, l.then(c).many()).map(function(d) {
      return Ze([d[0]], d[1], !0);
    });
  }
  function i(c) {
    var l = "'".concat(c, "'");
    if (c.length === 1) {
      var d = c.charCodeAt(0);
      return new t(function(f, h) {
        return f.charCodeAt(h) === d ? Wa(h + 1, c) : jc(h, l);
      });
    }
    return new t(function(f, h) {
      var m = h + c.length;
      return f.slice(h, m) === c ? Wa(m, c) : jc(h, l);
    });
  }
  function a(c, l) {
    l === void 0 && (l = 0);
    var d = function(h) {
      return RegExp("^(?:" + h.source + ")", function(m) {
        var p = "" + m;
        return p.slice(p.lastIndexOf("/") + 1);
      }(h));
    }(c), f = "" + c;
    return new t(function(h, m) {
      var p = d.exec(h.slice(m));
      if (p) {
        if (0 <= l && l <= p.length) {
          var v = p[0], g = p[l];
          return Wa(m + v.length, g);
        }
        return jc(m, "invalid match group (0 to ".concat(p.length, ") in ").concat(f));
      }
      return jc(m, f);
    });
  }
  function o(c) {
    return new t(function(l, d) {
      return Wa(d, c);
    });
  }
  function s(c) {
    return new t(function(l, d) {
      return jc(d, c);
    });
  }
  function u(c) {
    return new t(function(l, d) {
      var f = l.charAt(d);
      return d < l.length && c(f) ? Wa(d + 1, f) : jc(d, "a character " + c);
    });
  }
  t.seq = e, t.alt = r, t.sepBy = function(c, l) {
    return n(c, l).or(o([]));
  }, t.sepBy1 = n, t.string = i, t.regexp = a, t.succeed = o, t.fail = s, t.lookahead = function c(l) {
    if (kne(l)) return new t(function(d, f) {
      var h = l._(d, f);
      return h.status && (h.index = f, h.value = null), h;
    });
    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);
  }, t.notFollowedBy = function(c) {
    return new t(function(l, d) {
      var f = c._(l, d);
      return f.status ? jc(d, 'not "' + l.slice(d, f.index) + '"') : Wa(d, null);
    });
  }, t.test = u, t.oneOf = function(c) {
    return u(function(l) {
      return c.indexOf(l) >= 0;
    });
  }, t.noneOf = function(c) {
    return u(function(l) {
      return c.indexOf(l) < 0;
    });
  }, t.range = function(c, l) {
    return u(function(d) {
      return c <= d && d <= l;
    }).desc(c + "-" + l);
  }, t.takeWhile = function(c) {
    return new t(function(l, d) {
      for (var f = d; f < l.length && c(l.charAt(f)); ) f++;
      return Wa(f, l.slice(d, f));
    });
  }, t.lazy = function(c) {
    var l = new t(function(d, f) {
      var h = c()._;
      return l._ = h, h(d, f);
    });
    return l;
  }, t.empty = function() {
    return s("empty");
  }, t.index = new t(function(c, l) {
    return Wa(l, TO(c, l));
  }), t.anyChar = new t(function(c, l) {
    return l >= c.length ? jc(l, "any character") : Wa(l + 1, c.charAt(l));
  }), t.all = new t(function(c, l) {
    return Wa(c.length, c.slice(l));
  }), t.eof = new t(function(c, l) {
    return l < c.length ? jc(l, "EOF") : Wa(l, null);
  }), t.digit = a(/[0-9]/).desc("a digit"), t.digits = a(/[0-9]*/).desc("optional digits"), t.letter = a(/[a-z]/i).desc("a letter"), t.letters = a(/[a-z]*/i).desc("optional letters"), t.optWhitespace = a(/\s*/).desc("optional whitespace"), t.whitespace = a(/\s+/).desc("whitespace"), t.cr = i("\r"), t.lf = i(`
`), t.crlf = i(`\r
`), t.newline = r(t.crlf, t.lf, t.cr).desc("newline"), t.end = r(t.newline, t.eof);
})(Su || (Su = {})), function(t) {
  var e;
  (function(p) {
    p.str = function(v) {
      return { kind: "string", value: v };
    }, p.symb = function(v) {
      return { kind: "symbol", value: v };
    }, p.list = function(v, g) {
      return { kind: "list", bracket: v, nodes: g };
    }, p.comment = function(v) {
      return { kind: "comment", value: v };
    };
  })(e || (e = {}));
  var r = Su.regexp(/[\n\r\s]*/), n = Su.lazy(function() {
    return Su.alt(i, d, a, o).trim(r);
  }), i = Su.takeWhile(function(p) {
    return p !== "`";
  }).trim("`").map(e.str), a = Su.regexp(/[^()\[\]{};`,\n\r\s]+/).map(e.symb), o = Su.regexp(/\s*;+([^\n\r]*)\n/, 1).map(e.comment), s = n.many(), u = s.wrap("(", ")").map(function(p) {
    return e.list("(", p);
  }), c = s.wrap("[", "]").map(function(p) {
    return e.list("[", p);
  }), l = s.wrap("{", "}").map(function(p) {
    return e.list("{", p);
  }), d = Su.alt(u, c, l), f = n.many();
  function h(p) {
    switch (p.kind) {
      case "string":
        return p.value;
      case "symbol":
        var v = p.value;
        if (v.length > 1) switch (v.charAt(0)) {
          case ".":
            return Nt.atomName(v.substr(1));
          case "_":
            return Nt.struct.type.elementSymbol([v.substr(1)]);
        }
        return v === "true" || v !== "false" && (function(y) {
          return /-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.test(y) && !isNaN(+y);
        }(v) ? +v : wa.Symbol(v));
      case "list":
        switch (p.bracket) {
          case "[":
            return Nt.core.type.list(m(p.nodes).map(h));
          case "{":
            return Nt.core.type.set(m(p.nodes).map(h));
          case "(":
            if (p.nodes[0].kind === "comment") throw new Error("Invalid expression");
            var g = h(p.nodes[0]);
            return wa.Apply(g, function(y) {
              if (!(y.length <= 1)) {
                if (!function(F) {
                  for (var N = 1, R = F.length; N < R; N++) {
                    var L = F[N];
                    if (L.kind === "symbol" && L.value.length > 1 && L.value.charAt(0) === ":") return !0;
                  }
                  return !1;
                }(y)) {
                  for (var b = [], S = 1, _ = y.length; S < _; S++)
                    (w = y[S]).kind !== "comment" && (b[b.length] = h(w));
                  return b;
                }
                var x = {}, C = !0, A = 0;
                for (S = 1, _ = y.length; S < _; S++) {
                  var w;
                  if ((w = y[S]).kind !== "comment") if (w.kind === "symbol" && w.value.length > 1 && w.value.charAt(0) === ":") {
                    var I = w.value.substr(1);
                    for (++S; S < _ && y[S].kind === "comment"; ) S++;
                    if (S >= _) throw new Error("There must be a value foolowed a named arg ':".concat(I, "'."));
                    if (y[S].kind === "comment") throw new Error("Invalid expression");
                    x[I] = h(y[S]), isNaN(+I) && (C = !1);
                  } else x[A++] = h(w);
                }
                if (C) {
                  var P = Object.keys(x).map(function(F) {
                    return +F;
                  }).sort(function(F, N) {
                    return F - N;
                  }), M = !0;
                  for (S = 0, _ = P.length; S < _; S++) if (P[S] !== S) {
                    M = !1;
                    break;
                  }
                  if (M) {
                    var T = [];
                    for (S = 0, _ = P.length; S < _; S++) T[S] = x[S];
                    return T;
                  }
                }
                return x;
              }
            }(p.nodes));
          default:
            ca(p.bracket);
        }
      default:
        ca();
    }
  }
  function m(p) {
    for (var v = !1, g = 0, y = p.length; g < y; g++) if (p[g].kind === "comment") {
      v = !0;
      break;
    }
    return v ? p.filter(function(b) {
      return b.kind !== "comment";
    }) : p;
  }
  t.parse = function(p) {
    for (var v = function(_) {
      return f.tryParse(_);
    }(p), g = [], y = 0, b = v; y < b.length; y++) {
      var S = b[y];
      S.kind !== "comment" && (g[g.length] = h(S));
    }
    return g;
  };
}(h7 || (h7 = {}));
var uT, Mp, Nm, K3, Gne = function() {
  function t() {
    this.map = /* @__PURE__ */ new Map();
  }
  return t.prototype.removeSymbol = function(e) {
    this.map.delete(e.symbol.id);
  }, t.prototype.addSymbol = function(e) {
    this.map.has(e.symbol.id) && console.warn("Symbol '".concat(e.symbol.id, "' already added. Call removeSymbol/removeCustomProps re-adding the symbol.")), this.map.set(e.symbol.id, e);
  }, t.prototype.addCustomProp = function(e) {
    if (e.symbols) for (var r = 0, n = Object.keys(e.symbols); r < n.length; r++) {
      var i = n[r];
      this.addSymbol(e.symbols[i]);
    }
  }, t.prototype.removeCustomProp = function(e) {
    if (e.symbols) for (var r = 0, n = Object.keys(e.symbols); r < n.length; r++) {
      var i = n[r];
      this.removeSymbol(e.symbols[i]);
    }
  }, t.prototype.getRuntime = function(e) {
    return this.map.get(e);
  }, t;
}(), MO = new Gne(), zne = function(t) {
  this.table = t, this.constQueryContext = new A0(tt.Empty);
};
(function(t) {
  t.Const = function(e) {
    return { kind: "const", value: e };
  }, t.Dynamic = function(e) {
    return { kind: "dynamic", runtime: e };
  };
})(uT || (uT = {})), function(t) {
  t.Const = function(e) {
    return { isConst: !0, fn: function(r) {
      return e;
    } };
  }, t.Dynamic = function(e) {
    return { isConst: !1, fn: e };
  };
}(Mp || (Mp = {})), function(t) {
  t.forEachEval = function(e, r, n, i) {
    if (typeof e.length == "number") for (var a = 0, o = e.length; a < o; a++) n(e[a](r), a, i);
    else {
      a = 0;
      for (var s = 0, u = Object.keys(e); s < u.length; s++)
        n(e[u[s]](r), a++, i);
    }
    return i;
  };
}(Nm || (Nm = {})), function(t) {
  t.Const = function(e, r) {
    return new cT(e, r, !0);
  }, t.Dynamic = function(e, r) {
    return new cT(e, r, !1);
  };
}(K3 || (K3 = {}));
var Cc, cT = function() {
  function t(e, r, n) {
    this.symbol = e, this.fn = r, this.isConst = n;
  }
  return t.prototype.compile = function(e, r) {
    var n, i = !1;
    if (r) if (wa.isArgumentsArray(r)) {
      n = [], i = !0;
      for (var a = 0, o = r; a < o.length; a++) {
        var s = m7(e, o[a]);
        i = i && s.isConst, n.push(s.fn);
      }
    } else {
      n = /* @__PURE__ */ Object.create(null), i = !0;
      for (var u = 0, c = Object.keys(r); u < c.length; u++) {
        var l = c[u];
        s = m7(e, r[l]), i = i && s.isConst, n[l] = s.fn;
      }
    }
    else n = void 0, i = !0;
    return this.isConst && this.isConst && i ? Mp.Const(this.fn(e.constQueryContext, n)) : Mp.Dynamic(Vne(this.fn, n));
  }, t;
}();
function Vne(t, e) {
  return function(r) {
    return t(r, e);
  };
}
function m7(t, e) {
  if (wa.isLiteral(e)) return Mp.Const(e);
  if (wa.isSymbol(e)) {
    var r = t.table.getRuntime(e.name);
    return r ? r.compile(t) : Mp.Const(e.name);
  }
  if (!wa.isSymbol(e.head)) throw new Error("Can only apply symbols.");
  var n = t.table.getRuntime(e.head.name);
  if (!n) throw new Error("Symbol '".concat(e.head.name, "' is not implemented."));
  return n.compile(t, e.args);
}
function X3(t) {
  return m7(new zne(MO), t).fn;
}
function Kd(t, e) {
  return { expression: t, language: e };
}
function jm(t) {
  return { layers: t };
}
function Zm(t, e) {
  return { kind: t, layers: e };
}
(function(t) {
  function e(n) {
    if (n.language === "mol-script") {
      var i = (a = n.expression, h7.parse(a));
      if (i.length === 0) throw new Error("No query");
      return Lne(i[0]);
    }
    var a;
    throw new Error("unsupported script language");
  }
  function r(n) {
    return X3(e(n));
  }
  t.is = function(n) {
    return !!n && typeof n.expression == "string" && !!n.language;
  }, t.areEqual = function(n, i) {
    return n.language === i.language && n.expression === i.expression;
  }, t.toExpression = e, t.toQuery = r, t.toLoci = function(n, i) {
    var a = r(n)(new A0(i));
    return gt.toLociWithSourceUnits(a);
  }, t.getStructureSelection = function(n, i, a) {
    return X3(typeof n == "function" ? n(Nt) : n)(new A0(i, a));
  };
})(Kd || (Kd = {})), function(t) {
  function e(r) {
    return r.layers.length === 0;
  }
  t.Empty = { layers: [] }, t.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var i = 0, a = r.layers.length; i < a; ++i)
      if (r.layers[i].clear !== n.layers[i].clear || r.layers[i].color !== n.layers[i].color || !Qr.areEqual(r.layers[i].loci, n.layers[i].loci)) return !1;
    return !0;
  }, t.isEmpty = e, t.remap = function(r, n) {
    for (var i = [], a = 0, o = r.layers; a < o.length; a++) {
      var s = o[a], u = s.loci, c = s.color, l = s.clear;
      u = Xe.remap(u, n), Xe.isEmpty(u) || i.push({ loci: u, color: c, clear: l });
    }
    return { layers: i };
  }, t.merge = function(r) {
    if (e(r)) return r;
    for (var n = r.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Xe.none(n), o = 0, s = r.layers.length; o < s; ++o) {
      var u = r.layers[s - o - 1], c = u.loci, l = u.color, d = u.clear;
      if (c = Xe.subtract(c, a), a = Xe.union(c, a), !Xe.isEmpty(c)) {
        var f = d ? -1 : l;
        i.has(f) && (c = Xe.union(c, i.get(f))), i.set(f, c);
      }
    }
    var h = [];
    return i.forEach(function(m, p) {
      var v = p === -1, g = v ? qe(0) : p;
      h.push({ loci: m, color: g, clear: v });
    }), { layers: h };
  }, t.filter = function(r, n) {
    if (e(r)) return r;
    for (var i = r.layers[0].loci.structure, a = [], o = 0, s = r.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.color, d = u.clear, f = Xe.remap(c, n);
      c = Xe.remap(f, i), Xe.isEmpty(c) || a.push({ loci: c, color: l, clear: d });
    }
    return { layers: a };
  }, t.ofScript = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var s = r[a], u = s.script, c = s.color, l = s.clear, d = Kd.toLoci(u, n);
      Xe.isEmpty(d) || i.push({ loci: d, color: c, clear: l });
    }
    return { layers: i };
  }, t.ofBundle = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var s = r[a], u = s.bundle, c = s.color, l = s.clear, d = So.toLoci(u, n.root);
      i.push({ loci: d, color: c, clear: l });
    }
    return { layers: i };
  }, t.toBundle = function(r) {
    for (var n = [], i = 0, a = r.layers.length; i < a; ++i) {
      var o = r.layers[i], s = o.loci, u = o.color, c = o.clear, l = So.fromLoci(s);
      n.push({ bundle: l, color: u, clear: c });
    }
    return { layers: n };
  };
}(jm || (jm = {})), function(t) {
  function e(r) {
    return r.layers.length === 0;
  }
  t.Empty = { kind: "empty-loci", layers: [] }, t.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var i = 0, a = r.layers.length; i < a; ++i)
      if (r.layers[i].value !== n.layers[i].value || !Qr.areEqual(r.layers[i].loci, n.layers[i].loci)) return !1;
    return !0;
  }, t.isEmpty = e, t.remap = function(r, n) {
    if (r.kind === "element-loci") {
      for (var i = [], a = 0, o = r.layers; a < o.length; a++) {
        var s = o[a], u = Xe.remap(s.loci, n);
        Xe.isEmpty(u) || i.push({ loci: u, value: s.value });
      }
      return { kind: "element-loci", layers: i };
    }
    return r;
  }, t.merge = function(r) {
    if (e(r)) return r;
    if (r.kind === "element-loci") {
      for (var n = r.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Xe.none(n), o = 0, s = r.layers.length; o < s; ++o) {
        var u = r.layers[s - o - 1], c = u.loci, l = u.value;
        c = Xe.subtract(c, a), a = Xe.union(c, a), Xe.isEmpty(c) || (i.has(l) && (c = Xe.union(c, i.get(l))), i.set(l, c));
      }
      var d = [];
      return i.forEach(function(f, h) {
        d.push({ loci: f, value: h });
      }), { kind: "element-loci", layers: d };
    }
    return r;
  }, t.filter = function(r, n) {
    if (e(r)) return r;
    if (r.kind === "element-loci") {
      for (var i = r.layers[0].loci.structure, a = [], o = 0, s = r.layers; o < s.length; o++) {
        var u = s[o], c = u.loci, l = u.value, d = Xe.remap(c, n);
        c = Xe.remap(d, i), Xe.isEmpty(c) || a.push({ loci: c, value: l });
      }
      return { kind: "element-loci", layers: a };
    }
    return r;
  }, t.ofScript = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var s = r[a], u = s.script, c = s.value, l = Kd.toLoci(u, n);
      Xe.isEmpty(l) || i.push({ loci: l, value: c });
    }
    return { kind: "element-loci", layers: i };
  }, t.ofBundle = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var s = r[a], u = s.bundle, c = s.value, l = So.toLoci(u, n.root);
      i.push({ loci: l, value: c });
    }
    return { kind: "element-loci", layers: i };
  }, t.toBundle = function(r) {
    for (var n = [], i = 0, a = r.layers.length; i < a; ++i) {
      var o = r.layers[i], s = o.loci, u = o.value, c = So.fromLoci(s);
      n.push({ bundle: c, value: u });
    }
    return { kind: "element-loci", layers: n };
  };
}(Zm || (Zm = {})), function(t) {
  t.create = function() {
    return { updateTransform: !1, updateMatrix: !1, updateColor: !1, updateSize: !1, createGeometry: !1, createNew: !1, info: {} };
  }, t.reset = function(e) {
    e.updateTransform = !1, e.updateMatrix = !1, e.updateColor = !1, e.updateSize = !1, e.createGeometry = !1, e.createNew = !1;
  };
}(Cc || (Cc = {}));
var Une = { lowestElementCount: 1e6, lowerElementCount: 5e5, lowElementCount: 1e5, mediumElementCount: 2e4, highElementCount: 2e3, coarseGrainedFactor: 10, elementCountFactor: 1 };
function g7(t, e) {
  var r = Ui(t.quality, "auto"), n = Ui(t.detail, 1), i = Ui(t.radialSegments, 12), a = Ui(t.linearSegments, 8), o = Ui(t.resolution, 2), s = Ui(t.probePositions, 12), u = Ui(t.doubleSided, !0), c = 0;
  if (r === "auto") {
    if (e instanceof tt) r = function(d, f) {
      f === void 0 && (f = {});
      var h = O(O({}, Une), f), m = d.elementCount * h.elementCountFactor;
      return d.isCoarseGrained && (m *= h.coarseGrainedFactor), m > h.lowestElementCount ? "lowest" : m > h.lowerElementCount ? "lower" : m > h.lowElementCount ? "low" : m > h.mediumElementCount ? "medium" : m > h.highElementCount ? "high" : "higher";
    }(e.root), c = function(d) {
      if (d.root.models.length === 1) {
        var f = Da.Provider.get(d.root.model);
        if (f && f.spacegroup.name === "P 1" && !au.isZero(f.spacegroup.cell)) return f.spacegroup.cell.volume;
      }
      return $r.volume(d.root.boundary.box);
    }(e);
    else if (or.is(e)) {
      var l = e.grid.cells.space.dimensions;
      r = (c = l[0] * l[1] * l[2]) < 1e7 ? "medium" : "low";
    }
  }
  switch (r) {
    case "highest":
      n = 3, i = 36, a = 18, o = 0.1, s = 72, u = !0;
      break;
    case "higher":
      n = 3, i = 28, a = 14, o = 0.3, s = 48, u = !0;
      break;
    case "high":
      n = 2, i = 20, a = 10, o = 0.5, s = 36, u = !0;
      break;
    case "medium":
      n = 1, i = 12, a = 8, o = 0.8, s = 24, u = !0;
      break;
    case "low":
      n = 0, i = 8, a = 3, o = 1.3, s = 24, u = !1;
      break;
    case "lower":
      n = 0, i = 4, a = 2, o = 3, s = 12, u = !1;
      break;
    case "lowest":
      n = 0, i = 2, a = 1, o = 8, s = 12, u = !1;
  }
  return o = Math.max(o, c / 5e8), o = Math.min(o, 20), (t.alpha !== void 0 && t.alpha < 1 || t.xrayShaded) && (u = !1), { detail: n, radialSegments: i, linearSegments: a, resolution: o, probePositions: s, doubleSided: u };
}
function Y3(t, e) {
  e === void 0 && (e = 0);
  var r = t[0] * t[1] * t[2], n = Math.sqrt(r), i = Math.pow(2, Math.ceil(Math.log(n) / Math.log(2))), a = t[0] + e, o = t[1] + e, s = 1, u = a;
  return i < a * t[2] ? (a *= u = Math.floor(i / a), o *= s = Math.ceil(t[2] / u)) : a *= t[2], { width: a, height: o, columns: u, rows: s, powerOfTwoSize: o < i ? i : 2 * i };
}
function a3(t, e, r, n, i) {
  var a = t.colorType, o = t.vertexCount, s = t.groupCount, u = t.positionBuffer, c = t.transformBuffer, l = t.groupBuffer, d = t.itemSize, f = a.endsWith("Instance"), h = $r.fromSphere3D($r(), f ? t.boundingSphere : t.invariantBoundingSphere), m = 1 + e, p = $r.expand($r(), h, E.create(m, m, m)), v = 1 / e, g = $r.scale($r(), p, v), y = $r.size(E(), g);
  E.ceil(y, y), E.add(y, y, E.create(2, 2, 2));
  var b = p.min, S = y[0], _ = y[1], x = Y3(y), C = x.width, A = x.height, w = new Float32Array(C * A * d), I = new Float32Array(C * A), P = new Uint8Array(C * A * d), M = { array: P, width: C, height: A, filter: "linear" }, T = f ? t.instanceCount : 1, F = t.colorData.array;
  function N(ht, bt, At) {
    var Ee = Math.floor(At * S % C / S), st = Math.floor(At * S / C);
    return d * (st * _ * C + bt * C + (Ee * S + ht));
  }
  for (var R = y[0], L = y[1], V = y[2], U = E(), H = 0; H < T; ++H) for (var K = 0; K < o; K += r) {
    E.fromArray(U, u, 3 * K), f && E.transformMat4Offset(U, U, c, 0, 0, 16 * H), E.sub(U, U, b), E.scale(U, U, v);
    for (var X = U[0], Y = U[1], Q = U[2], J = Math.floor(X), te = Math.floor(Y), W = Math.floor(Q), j = (H * s + l[K]) * d, ee = Math.max(0, J - 2), ie = Math.max(0, te - 2), ae = Math.max(0, W - 2), ce = Math.min(R, J + 2 + 2), de = Math.min(L, te + 2 + 2), Ce = Math.min(V, W + 2 + 2), De = ee; De < ce; ++De) for (var ke = De - X, He = ie; He < de; ++He) for (var We = He - Y, Ne = ae; Ne < Ce; ++Ne) {
      var Je = Ne - Q, Re = Math.sqrt(ke * ke + We * We + Je * Je);
      if (!(Re > 2)) {
        for (var nt = 2 - Re, ne = N(De, He, Ne), re = 0; re < d; ++re) w[ne + re] += F[j + re] * nt;
        I[ne / d] += nt;
      }
    }
  }
  H = 0;
  for (var le = I.length; H < le; ++H) {
    var fe = H * d, ge = I[H];
    for (re = 0; re < d; ++re) P[fe + re] = Math.round(w[fe + re] / ge);
  }
  var me = ze.create(C, A), Ae = Ut.create(b[0], b[1], b[2], v), Oe = f ? "volumeInstance" : "volume";
  if (n) {
    if (!i) {
      var Ue = d === 4 ? "rgba" : d === 3 ? "rgb" : "alpha";
      i = n.resources.texture("image-uint8", Ue, "ubyte", "linear");
    }
    return i.load(M), { kind: "volume", texture: i, gridTexDim: me, gridDim: y, gridTransform: Ae, type: Oe };
  }
  var Ve = function(ht) {
    var bt = ht.vertexCount, At = ht.positionBuffer, Ee = ht.transformBuffer, st = ht.grid, Et = ht.gridDim, ur = ht.gridTexDim, ir = ht.gridTransform, Nr = ht.vertexStride, pr = ht.colorStride, _n = ht.itemOffset || 0, Jn = ht.outputStride;
    if (Jn + _n > pr) throw new Error("outputStride + itemOffset must NOT be larger than colorStride");
    var Yn = ht.colorType.endsWith("Instance"), Rn = Yn ? ht.instanceCount : 1, un = qi(Math.max(1, Rn * bt), Jn, Uint8Array), yi = un.array, cn = Et[0], ln = Et[1], Ti = ur[0], Mi = E.fromArray(E(), ir, 0), so = ir[3];
    function On(b5, K2, r1) {
      var gh = Math.floor(r1 * cn % Ti / cn), jl = Math.floor(r1 * cn / Ti);
      return pr * (jl * ln * Ti + K2 * Ti + (gh * cn + b5));
    }
    for (var xn = E(), Wo = E(), jo = E(), Eo = E(), Hu = 0; Hu < Rn; ++Hu) for (var uo = 0; uo < bt; ++uo) {
      E.fromArray(xn, At, uo * Nr), Yn && E.transformMat4Offset(xn, xn, Ee, 0, 0, 16 * Hu), E.sub(xn, xn, Mi), E.scale(xn, xn, so), E.floor(Wo, xn), E.ceil(jo, xn), E.sub(Eo, xn, Wo), E.sub(xn, jo, Wo), E.div(Eo, Eo, xn);
      for (var Pi = Wo[0], Mc = Wo[1], Ul = Wo[2], Hl = jo[0], ql = jo[1], Kl = jo[2], Xl = Eo[0], $0 = Eo[1], Yl = Eo[2], Pc = On(Pi, Mc, Ul) + _n, Gr = On(Hl, Mc, Ul) + _n, ha = On(Pi, Mc, Kl) + _n, ph = On(Hl, Mc, Kl) + _n, Wl = On(Pi, ql, Ul) + _n, qu = On(Hl, ql, Ul) + _n, e1 = On(Pi, ql, Kl) + _n, L2 = On(Hl, ql, Kl) + _n, h5 = (Hu * bt + uo) * Jn, Zo = 0; Zo < Jn; ++Zo) {
        var m5 = st[Pc + Zo], g5 = st[Gr + Zo], k2 = st[ha + Zo], G2 = st[ph + Zo], z2 = st[Wl + Zo], hh = st[qu + Zo], v5 = st[e1 + Zo], V2 = st[L2 + Zo], t1 = Vi(m5, g5, Xl), U2 = Vi(k2, G2, Xl), y5 = Vi(z2, hh, Xl), H2 = Vi(v5, V2, Xl), q2 = Vi(t1, y5, $0), mh = Vi(U2, H2, $0);
        yi[h5 + Zo] = Vi(q2, mh, Yl);
      }
    }
    return un;
  }({ vertexCount: o, instanceCount: T, transformBuffer: c, positionBuffer: u, colorType: Oe, grid: P, gridDim: y, gridTexDim: me, gridTransform: Ae, vertexStride: 3, colorStride: d, outputStride: d });
  return { kind: "vertex", texture: Ve, texDim: ze.create(Ve.width, Ve.height), type: f ? "vertexInstance" : "vertex" };
}
E.set, E.normalize, E.sub, E.addScalar, E.scale, E.toArray;
var Hne = `
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;
}
`, qne = `
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);
}
`, Kne = `
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
}
`, Xne = { drawCount: Ai("number"), instanceCount: Ai("number"), stride: Ai("number"), uTotalCount: Ie("i"), uInstanceCount: Ie("i"), uGroupCount: Ie("i"), aTransform: jr("float32", 16, 1), aInstance: jr("float32", 1, 1), aSample: jr("float32", 1, 0), uGeoTexDim: Ie("v2", "buffered"), tPosition: zt("texture", "rgba", "float", "nearest"), tGroup: zt("texture", "rgba", "float", "nearest"), uColorTexDim: Ie("v2"), tColor: zt("texture", "rgba", "ubyte", "nearest"), dColorType: Gt("string", ["group", "groupInstance", "vertex", "vertexInstance"]), uCurrentSlice: Ie("f"), uCurrentX: Ie("f"), uCurrentY: Ie("f"), uBboxMin: Ie("v3", "material"), uBboxSize: Ie("v3", "material"), uResolution: Ie("f", "material") }, cs = "color-accumulate", Lh = "color-count";
function lT(t, e) {
  for (var r = new Float32Array(t), n = 0; n < t; ++n) r[n] = n * e;
  return r;
}
function Yne(t, e, r, n, i) {
  if (t.namedComputeRenderables[cs]) {
    var a = E.sub(E(), r.max, r.min), o = t.namedComputeRenderables[cs].values, s = Math.round(e.vertexCount / i);
    (s > o.drawCount.ref.value || i !== o.stride.ref.value) && G.update(o.aSample, lT(s, i)), G.updateIfChanged(o.drawCount, s), G.updateIfChanged(o.instanceCount, e.instanceCount), G.updateIfChanged(o.stride, i), G.updateIfChanged(o.uTotalCount, e.vertexCount), G.updateIfChanged(o.uInstanceCount, e.instanceCount), G.updateIfChanged(o.uGroupCount, e.groupCount), G.update(o.aTransform, e.transformBuffer), G.update(o.aInstance, e.instanceBuffer), G.update(o.uGeoTexDim, ze.set(o.uGeoTexDim.ref.value, e.positionTexture.getWidth(), e.positionTexture.getHeight())), G.update(o.tPosition, e.positionTexture), G.update(o.tGroup, e.groupTexture), G.update(o.uColorTexDim, ze.set(o.uColorTexDim.ref.value, e.colorData.getWidth(), e.colorData.getHeight())), G.update(o.tColor, e.colorData), G.updateIfChanged(o.dColorType, e.colorType), G.updateIfChanged(o.uCurrentSlice, 0), G.updateIfChanged(o.uCurrentX, 0), G.updateIfChanged(o.uCurrentY, 0), G.update(o.uBboxMin, r.min), G.update(o.uBboxSize, a), G.updateIfChanged(o.uResolution, n), t.namedComputeRenderables[cs].update();
  } else t.namedComputeRenderables[cs] = function(u, c, l, d, f) {
    var h = E.sub(E(), l.max, l.min), m = Math.round(c.vertexCount / f), p = { drawCount: G.create(m), instanceCount: G.create(c.instanceCount), stride: G.create(f), uTotalCount: G.create(c.vertexCount), uInstanceCount: G.create(c.instanceCount), uGroupCount: G.create(c.groupCount), aTransform: G.create(c.transformBuffer), aInstance: G.create(c.instanceBuffer), aSample: G.create(lT(m, f)), uGeoTexDim: G.create(ze.create(c.positionTexture.getWidth(), c.positionTexture.getHeight())), tPosition: G.create(c.positionTexture), tGroup: G.create(c.groupTexture), uColorTexDim: G.create(ze.create(c.colorData.getWidth(), c.colorData.getHeight())), tColor: G.create(c.colorData), dColorType: G.create(c.colorType), uCurrentSlice: G.create(0), uCurrentX: G.create(0), uCurrentY: G.create(0), uBboxMin: G.create(l.min), uBboxSize: G.create(h), uResolution: G.create(d) }, v = O({}, Xne), g = Nn("accumulate", Kne, qne, { drawBuffers: "required" }), y = Zi(u, "points", g, v, p);
    return Qi(y, p);
  }(t, e, r, n, i);
  return t.namedComputeRenderables[cs];
}
var Wne = O(O({}, la), { tColor: zt("texture", "rgba", "float", "nearest"), tCount: zt("texture", "alpha", "float", "nearest"), uTexSize: Ie("v2") }), kh = "color-normalize";
function jne(t, e, r) {
  if (t.namedComputeRenderables[kh]) {
    var n = t.namedComputeRenderables[kh].values;
    G.update(n.tColor, e), G.update(n.tCount, r), G.update(n.uTexSize, ze.set(n.uTexSize.ref.value, e.getWidth(), e.getHeight())), t.namedComputeRenderables[kh].update();
  } else t.namedComputeRenderables[kh] = function(i, a, o) {
    var s = O(O({}, ua), { tColor: G.create(a), tCount: G.create(o), uTexSize: G.create(ze.create(a.getWidth(), a.getHeight())) }), u = O({}, Wne), c = Nn("normalize", eo, Hne), l = Zi(i, "triangles", c, u, s);
    return Qi(l, s);
  }(t, e, r);
  return t.namedComputeRenderables[kh];
}
function Nb(t, e, r, n, i) {
  var a = n.extensions.drawBuffers;
  if (!a) throw new Error("need WebGL draw buffers");
  var o = n.gl, s = n.resources, u = n.state, c = n.extensions, l = c.colorBufferHalfFloat, d = c.textureHalfFloat, f = t.colorType.endsWith("Instance"), h = $r.fromSphere3D($r(), f ? t.boundingSphere : t.invariantBoundingSphere), m = 1 + e, p = $r.expand($r(), h, E.create(m, m, m)), v = 1 / e, g = $r.scale($r(), p, v), y = $r.size(E(), g);
  E.ceil(y, y), E.add(y, y, E.create(2, 2, 2));
  var b = p.min, S = y[0], _ = y[1], x = y[2], C = function(te) {
    var W = te[0] * te[1] * te[2], j = Math.sqrt(W), ee = Math.pow(2, Math.ceil(Math.log(j) / Math.log(2))), ie = 0, ae = te[1], ce = 1, de = te[2];
    return ee < te[0] * te[2] ? (de = Math.floor(ee / te[0]), ce = Math.ceil(te[2] / de), ie = de * te[0], ae *= ce) : ie = te[0] * te[2], { texDimX: ie, texDimY: ae, texRows: ce, texCols: de, powerOfTwoSize: ae < ee ? ee : 2 * ee };
  }(y), A = C.texDimX, w = C.texDimY, I = C.texCols;
  n.namedFramebuffers[cs] || (n.namedFramebuffers[cs] = n.resources.framebuffer());
  var P = n.namedFramebuffers[cs];
  ar(o) ? (n.namedTextures[cs] || (n.namedTextures[cs] = l && d ? s.texture("image-float16", "rgba", "fp16", "nearest") : s.texture("image-float32", "rgba", "float", "nearest")), n.namedTextures[Lh] || (n.namedTextures[Lh] = s.texture("image-float32", "alpha", "float", "nearest"))) : (n.namedTextures[cs] || (n.namedTextures[cs] = s.texture("image-float32", "rgba", "float", "nearest")), n.namedTextures[Lh] || (n.namedTextures[Lh] = s.texture("image-float32", "rgba", "float", "nearest")));
  var M = n.namedTextures[cs], T = n.namedTextures[Lh];
  M.define(A, w), T.define(A, w), M.attachFramebuffer(P, 0), T.attachFramebuffer(P, 1);
  var F = Yne(n, t, p, e, r);
  u.currentRenderItemId = -1, P.bind(), a.drawBuffers([a.COLOR_ATTACHMENT0, a.COLOR_ATTACHMENT1]);
  var N = F.values, R = N.uCurrentSlice, L = N.uCurrentX, V = N.uCurrentY;
  (function(te) {
    var W = te.gl, j = te.state;
    j.disable(W.CULL_FACE), j.enable(W.BLEND), j.disable(W.DEPTH_TEST), j.enable(W.SCISSOR_TEST), j.depthMask(!1), j.clearColor(0, 0, 0, 0), j.blendFunc(W.ONE, W.ONE), j.blendEquation(W.FUNC_ADD);
  })(n), o.viewport(0, 0, A, w), o.scissor(0, 0, A, w), o.clear(o.COLOR_BUFFER_BIT), G.update(V, 0);
  for (var U = 0, H = 0, K = 0, X = 0; X < x; ++X) U >= I && (U -= I, H += _, K = 0, G.update(V, H)), G.update(L, K), G.update(R, X), o.viewport(K, H, S, _), o.scissor(K, H, S, _), F.render(), ++U, K += S;
  M.detachFramebuffer(P, 0), T.detachFramebuffer(P, 1), a.drawBuffers([o.COLOR_ATTACHMENT0, o.NONE]), i || (i = s.texture("image-uint8", "rgba", "ubyte", "linear")), i.define(A, w);
  var Y = jne(n, M, T);
  u.currentRenderItemId = -1, function(te) {
    var W = te.gl, j = te.state;
    j.disable(W.CULL_FACE), j.enable(W.BLEND), j.disable(W.DEPTH_TEST), j.enable(W.SCISSOR_TEST), j.depthMask(!1), j.clearColor(0, 0, 0, 0), j.blendFunc(W.ONE, W.ONE), j.blendEquation(W.FUNC_ADD);
  }(n), i.attachFramebuffer(P, 0), o.viewport(0, 0, A, w), o.scissor(0, 0, A, w), o.clear(o.COLOR_BUFFER_BIT), Y.render();
  var Q = Ut.create(b[0], b[1], b[2], v), J = f ? "volumeInstance" : "volume";
  return { texture: i, gridDim: y, gridTexDim: ze.create(A, w), gridTransform: Q, type: J };
}
var nr, dT, T1 = "color-smoothing-rgba", Rb = "color-smoothing-alpha";
function Qm(t) {
  return { layers: t };
}
function Jm(t) {
  return { layers: t };
}
(function(t) {
  t.setVisibility = function(e, r) {
    e && (e.state.visible = r);
  }, t.setAlphaFactor = function(e, r) {
    e && (e.state.alphaFactor = r);
  }, t.setPickable = function(e, r) {
    e && (e.state.pickable = r);
  }, t.setColorOnly = function(e, r) {
    e && (e.state.colorOnly = r);
  }, t.mark = function(e, r, n, i, a) {
    if (!e || ef(r)) return !1;
    var o = e.values, s = o.tMarker, u = o.uMarker, c = o.markerAverage, l = o.markerStatus, d = o.uGroupCount, f = o.instanceCount, h = d.ref.value * f.ref.value, m = s.ref.value.array, p = l.ref.value;
    if (!qo(r)) {
      var v = 0;
      if (i(r, function(_) {
        return v += Se.size(_), !0;
      }, !0), v === 0) return !1;
      v === h && (r = px);
    }
    var g = !1, y = -1, b = -1;
    if (qo(r)) {
      var S = function(_, x) {
        var C = -1, A = -1;
        switch (_) {
          case _t.Highlight:
            x === 0 || x === 1 ? (C = 1, A = 1) : x === 2 || x === 3 ? (C = 1, A = 3) : C = 1;
            break;
          case _t.RemoveHighlight:
            x === 0 || x === 1 ? (C = 0, A = 0) : x !== 2 && x !== 3 || (C = 1, A = 2);
            break;
          case _t.Select:
            x === 1 || x === 3 ? (C = 1, A = 3) : x === 0 || x === 2 ? (C = 1, A = 2) : C = 1;
            break;
          case _t.Deselect:
            x === 1 || x === 3 ? (C = 1, A = 1) : x !== 0 && x !== 2 || (C = 0, A = 0);
            break;
          case _t.Toggle:
            x === 1 ? (C = 1, A = 3) : x === 2 ? (C = 0, A = 0) : x === 3 ? (C = 1, A = 1) : x === 0 && (C = 1, A = 2);
            break;
          case _t.Clear:
            C = 0, A = 0;
        }
        return { average: C, status: A };
      }(n, p);
      S.status !== -1 ? (g = p !== S.status) && function(_, x, C) {
        _.fill(x, 0, C);
      }(m, S.status, h) : g = p7(m, Se.ofLength(h), n), y = S.average, b = S.status;
    } else (g = i(r, function(_) {
      return p7(m, _, n);
    }, !0)) && (y = function(_, x) {
      switch (_) {
        case _t.Highlight:
          return 0.5;
        case _t.RemoveHighlight:
          return x === 0 ? 0 : x === 2 || x === 3 ? 0.5 : -1;
        case _t.Select:
          return 0.5;
        case _t.Deselect:
          return x === 1 || x === 3 ? 0.5 : x === 0 ? 0 : -1;
        case _t.Toggle:
          return x === -1 ? -1 : 0.5;
        case _t.Clear:
          return x === -1 ? -1 : x === 0 ? 0 : 0.5;
        case _t.None:
          return -1;
        default:
          ca();
      }
    }(n, p), a && a.status !== -1 && y === -1 && Lr.isReverse(a.action, n) && Qr.areEqual(r, a.loci) && (y = (b = a.status) === 0 ? 0 : 0.5));
    return g && (y === -1 && (y = tO(m, h)) === 0 && (b = 0), a && (a.action = n, a.loci = r, a.status = p), G.updateIfChanged(u, b), b === -1 && G.update(s, s.ref.value), G.updateIfChanged(c, y), G.updateIfChanged(l, b)), g;
  }, t.setOverpaint = function(e, r, n, i, a) {
    if (e) {
      var o = e.values, s = o.tOverpaint, u = o.dOverpaintType, c = o.dOverpaint, l = o.uGroupCount, d = o.instanceCount, f = l.ref.value * d.ref.value;
      (function(w, I) {
        var P = qi(Math.max(1, w), 4, Uint8Array, I && I.tOverpaint.ref.value.array);
        I ? (G.update(I.tOverpaint, P), G.update(I.uOverpaintTexDim, ze.create(P.width, P.height)), G.updateIfChanged(I.dOverpaint, w > 0)) : (G.create(P), G.create(ze.create(P.width, P.height)), G.create(w > 0), G.create(zo()), G.create(E.create(1, 1, 1)), G.create(Ut.create(0, 0, 0, 1)), G.create("groupInstance"));
      })(r.layers.length ? f : 0, e.values);
      var h = s.ref.value.array;
      i && UE(h, 0, f);
      for (var m = function(w, I) {
        var P = r.layers[w], M = P.loci, T = P.color, F = P.clear;
        n(M, function(N) {
          var R = Se.start(N), L = Se.end(N);
          return F ? UE(h, R, L) : function(V, U, H, K) {
            for (var X = U; X < H; ++X) qe.toArray(K, V, 4 * X), V[4 * X + 3] = 255;
            return !0;
          }(h, R, L, T);
        }, !1);
      }, p = 0, v = r.layers.length; p < v; ++p) m(p);
      if (G.update(s, s.ref.value), G.updateIfChanged(u, "groupInstance"), G.updateIfChanged(c, r.layers.length > 0), r.layers.length !== 0 && a && hb(a.props)) {
        var g = a.geometry, y = a.props, b = a.webgl;
        if (g.kind === "mesh") {
          var S = g.meta, _ = S.resolution, x = S.overpaintTexture;
          (C = r0(y.smoothColors, !0, _)) && (function(w, I, P, M, T) {
            if (/* @__PURE__ */ function(N) {
              return N === "groupInstance";
            }(w.dOverpaintType.ref.value)) {
              var F = a3({ 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 }, I, P, M, T);
              F.kind === "volume" ? (G.updateIfChanged(w.dOverpaintType, F.type), G.update(w.tOverpaintGrid, F.texture), G.update(w.uOverpaintTexDim, F.gridTexDim), G.update(w.uOverpaintGridDim, F.gridDim), G.update(w.uOverpaintGridTransform, F.gridTransform)) : F.kind === "vertex" && (G.updateIfChanged(w.dOverpaintType, F.type), G.update(w.tOverpaint, F.texture), G.update(w.uOverpaintTexDim, F.texDim));
            }
          }(e.values, C.resolution, C.stride, b, x), g.meta.overpaintTexture = e.values.tOverpaintGrid.ref.value);
        } else if (b && g.kind === "texture-mesh") {
          var C, A = g.meta;
          _ = A.resolution, x = A.overpaintTexture, (C = r0(y.smoothColors, !0, _)) && (function(w, I, P, M, T) {
            if (/* @__PURE__ */ function(R) {
              return R === "groupInstance";
            }(w.dOverpaintType.ref.value)) {
              P *= 3, M.namedTextures[T1] || (M.namedTextures[T1] = M.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
              var F = M.namedTextures[T1];
              F.load(w.tOverpaint.ref.value);
              var N = Nb({ 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: F, colorType: w.dOverpaintType.ref.value, boundingSphere: w.boundingSphere.ref.value, invariantBoundingSphere: w.invariantBoundingSphere.ref.value }, I, P, M, T);
              G.updateIfChanged(w.dOverpaintType, N.type), G.update(w.tOverpaintGrid, N.texture), G.update(w.uOverpaintTexDim, N.gridTexDim), G.update(w.uOverpaintGridDim, N.gridDim), G.update(w.uOverpaintGridTransform, N.gridTransform);
            }
          }(e.values, C.resolution, C.stride, b, x), g.meta.overpaintTexture = e.values.tOverpaintGrid.ref.value);
        }
      }
    }
  }, t.setTransparency = function(e, r, n, i, a) {
    if (e) {
      var o = e.values, s = o.tTransparency, u = o.dTransparencyType, c = o.transparencyAverage, l = o.dTransparency, d = o.uGroupCount, f = o.instanceCount, h = d.ref.value * f.ref.value;
      (function(I, P) {
        var M = qi(Math.max(1, I), 1, Uint8Array, P && P.tTransparency.ref.value.array);
        P ? (G.update(P.tTransparency, M), G.update(P.uTransparencyTexDim, ze.create(M.width, M.height)), G.updateIfChanged(P.dTransparency, I > 0), G.updateIfChanged(P.transparencyAverage, HE(M.array, I))) : (G.create(M), G.create(ze.create(M.width, M.height)), G.create(I > 0), G.create(0), G.create(zo()), G.create(E.create(1, 1, 1)), G.create(Ut.create(0, 0, 0, 1)), G.create("groupInstance"));
      })(r.layers.length ? h : 0, e.values);
      var m = s.ref.value.array;
      i && function(I, P, M) {
        I.fill(0, P, M);
      }(m, 0, h);
      for (var p = function(I, P) {
        var M = r.layers[I], T = M.loci, F = M.value;
        n(T, function(N) {
          var R = Se.start(N), L = Se.end(N);
          return function(V, U, H, K) {
            for (var X = U; X < H; ++X) V[X] = 255 * K;
            return !0;
          }(m, R, L, F);
        }, !1);
      }, v = 0, g = r.layers.length; v < g; ++v) p(v);
      if (G.update(s, s.ref.value), G.updateIfChanged(c, HE(m, h)), G.updateIfChanged(u, "groupInstance"), G.updateIfChanged(l, r.layers.length > 0), r.layers.length !== 0 && a && hb(a.props)) {
        var y = a.geometry, b = a.props, S = a.webgl;
        if (y.kind === "mesh") {
          var _ = y.meta, x = _.resolution, C = _.transparencyTexture;
          (A = r0(b.smoothColors, !0, x)) && (function(I, P, M, T, F) {
            if (/* @__PURE__ */ function(R) {
              return R === "groupInstance";
            }(I.dTransparencyType.ref.value)) {
              var N = a3({ vertexCount: I.uVertexCount.ref.value, instanceCount: I.uInstanceCount.ref.value, groupCount: I.uGroupCount.ref.value, transformBuffer: I.aTransform.ref.value, instanceBuffer: I.aInstance.ref.value, positionBuffer: I.aPosition.ref.value, groupBuffer: I.aGroup.ref.value, colorData: I.tTransparency.ref.value, colorType: I.dTransparencyType.ref.value, boundingSphere: I.boundingSphere.ref.value, invariantBoundingSphere: I.invariantBoundingSphere.ref.value, itemSize: 1 }, P, M, T, F);
              N.kind === "volume" ? (G.updateIfChanged(I.dTransparencyType, N.type), G.update(I.tTransparencyGrid, N.texture), G.update(I.uTransparencyTexDim, N.gridTexDim), G.update(I.uTransparencyGridDim, N.gridDim), G.update(I.uTransparencyGridTransform, N.gridTransform)) : N.kind === "vertex" && (G.updateIfChanged(I.dTransparencyType, N.type), G.update(I.tTransparency, N.texture), G.update(I.uTransparencyTexDim, N.texDim));
            }
          }(e.values, A.resolution, A.stride, S, C), y.meta.transparencyTexture = e.values.tTransparencyGrid.ref.value);
        } else if (S && y.kind === "texture-mesh") {
          var A, w = y.meta;
          x = w.resolution, C = w.transparencyTexture, (A = r0(b.smoothColors, !0, x)) && (function(I, P, M, T, F) {
            if (/* @__PURE__ */ function(L) {
              return L === "groupInstance";
            }(I.dTransparencyType.ref.value)) {
              M *= 3, T.namedTextures[Rb] || (T.namedTextures[Rb] = T.resources.texture("image-uint8", "alpha", "ubyte", "nearest"));
              var N = T.namedTextures[Rb];
              N.load(I.tTransparency.ref.value);
              var R = Nb({ vertexCount: I.uVertexCount.ref.value, instanceCount: I.uInstanceCount.ref.value, groupCount: I.uGroupCount.ref.value, transformBuffer: I.aTransform.ref.value, instanceBuffer: I.aInstance.ref.value, positionTexture: I.tPosition.ref.value, groupTexture: I.tGroup.ref.value, colorData: N, colorType: I.dTransparencyType.ref.value, boundingSphere: I.boundingSphere.ref.value, invariantBoundingSphere: I.invariantBoundingSphere.ref.value }, P, M, T, F);
              G.updateIfChanged(I.dTransparencyType, R.type), G.update(I.tTransparencyGrid, R.texture), G.update(I.uTransparencyTexDim, R.gridTexDim), G.update(I.uTransparencyGridDim, R.gridDim), G.update(I.uTransparencyGridTransform, R.gridTransform);
            }
          }(e.values, A.resolution, A.stride, S, C), y.meta.transparencyTexture = e.values.tTransparencyGrid.ref.value);
        }
      }
    }
  }, t.setSubstance = function(e, r, n, i, a) {
    if (e) {
      var o = e.values, s = o.tSubstance, u = o.dSubstanceType, c = o.dSubstance, l = o.uGroupCount, d = o.instanceCount, f = l.ref.value * d.ref.value;
      (function(w, I) {
        var P = qi(Math.max(1, w), 4, Uint8Array, I && I.tSubstance.ref.value.array);
        I ? (G.update(I.tSubstance, P), G.update(I.uSubstanceTexDim, ze.create(P.width, P.height)), G.updateIfChanged(I.dSubstance, w > 0)) : (G.create(P), G.create(ze.create(P.width, P.height)), G.create(w > 0), G.create(zo()), G.create(E.create(1, 1, 1)), G.create(Ut.create(0, 0, 0, 1)), G.create("groupInstance"));
      })(r.layers.length ? f : 0, e.values);
      var h = s.ref.value.array;
      i && qE(h, 0, f);
      for (var m = function(w, I) {
        var P = r.layers[w], M = P.loci, T = P.material, F = P.clear;
        n(M, function(N) {
          var R = Se.start(N), L = Se.end(N);
          return F ? qE(h, R, L) : function(V, U, H, K) {
            for (var X = U; X < H; ++X) Dp.toArray(K, V, 4 * X), V[4 * X + 3] = 255;
            return !0;
          }(h, R, L, T);
        }, !1);
      }, p = 0, v = r.layers.length; p < v; ++p) m(p);
      if (G.update(s, s.ref.value), G.updateIfChanged(u, "groupInstance"), G.updateIfChanged(c, r.layers.length > 0), r.layers.length !== 0 && a && hb(a.props)) {
        var g = a.geometry, y = a.props, b = a.webgl;
        if (g.kind === "mesh") {
          var S = g.meta, _ = S.resolution, x = S.substanceTexture;
          (C = r0(y.smoothColors, !0, _)) && (function(w, I, P, M, T) {
            if (/* @__PURE__ */ function(N) {
              return N === "groupInstance";
            }(w.dSubstanceType.ref.value)) {
              var F = a3({ 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 }, I, P, M, T);
              F.kind === "volume" ? (G.updateIfChanged(w.dSubstanceType, F.type), G.update(w.tSubstanceGrid, F.texture), G.update(w.uSubstanceTexDim, F.gridTexDim), G.update(w.uSubstanceGridDim, F.gridDim), G.update(w.uSubstanceGridTransform, F.gridTransform)) : F.kind === "vertex" && (G.updateIfChanged(w.dSubstanceType, F.type), G.update(w.tSubstance, F.texture), G.update(w.uSubstanceTexDim, F.texDim));
            }
          }(e.values, C.resolution, C.stride, b, x), g.meta.substanceTexture = e.values.tSubstanceGrid.ref.value);
        } else if (b && g.kind === "texture-mesh") {
          var C, A = g.meta;
          _ = A.resolution, x = A.substanceTexture, (C = r0(y.smoothColors, !0, _)) && (function(w, I, P, M, T) {
            if (/* @__PURE__ */ function(R) {
              return R === "groupInstance";
            }(w.dSubstanceType.ref.value)) {
              P *= 3, M.namedTextures[T1] || (M.namedTextures[T1] = M.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
              var F = M.namedTextures[T1];
              F.load(w.tSubstance.ref.value);
              var N = Nb({ 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: F, colorType: w.dSubstanceType.ref.value, boundingSphere: w.boundingSphere.ref.value, invariantBoundingSphere: w.invariantBoundingSphere.ref.value }, I, P, M, T);
              G.updateIfChanged(w.dSubstanceType, N.type), G.update(w.tSubstanceGrid, N.texture), G.update(w.uSubstanceTexDim, N.gridTexDim), G.update(w.uSubstanceGridDim, N.gridDim), G.update(w.uSubstanceGridTransform, N.gridTransform);
            }
          }(e.values, C.resolution, C.stride, b, x), g.meta.substanceTexture = e.values.tSubstanceGrid.ref.value);
        }
      }
    }
  }, t.setClipping = function(e, r, n, i) {
    if (e) {
      var a = e.values, o = a.tClipping, s = a.dClipping, u = a.uGroupCount, c = a.instanceCount, l = u.ref.value * c.ref.value;
      (function(p, v) {
        var g = qi(Math.max(1, p), 1, Uint8Array, v && v.tClipping.ref.value.array);
        v ? (G.update(v.tClipping, g), G.update(v.uClippingTexDim, ze.create(g.width, g.height)), G.updateIfChanged(v.dClipping, p > 0)) : (G.create(g), G.create(ze.create(g.width, g.height)), G.create(p > 0));
      })(r.layers.length ? l : 0, e.values);
      var d = o.ref.value.array;
      i && function(p, v, g) {
        p.fill(0, v, g);
      }(d, 0, l);
      for (var f = function(p, v) {
        var g = r.layers[p], y = g.loci, b = g.groups;
        n(y, function(S) {
          var _ = Se.start(S), x = Se.end(S);
          return function(C, A, w, I) {
            return C.fill(I, A, w), !0;
          }(d, _, x, b);
        }, !1);
      }, h = 0, m = r.layers.length; h < m; ++h) f(h);
      G.update(o, o.ref.value), G.updateIfChanged(s, r.layers.length > 0);
    }
  }, t.setTransform = function(e, r, n) {
    if (e && (r || n)) {
      var i = e.values;
      r && (he.copy(i.matrix.ref.value, r), G.update(i.matrix, i.matrix.ref.value)), n ? (i.extraTransform.ref.value.set(n), G.update(i.extraTransform, i.extraTransform.ref.value)) : n === null && (e7(i.extraTransform.ref.value, i.instanceCount.ref.value), G.update(i.extraTransform, i.extraTransform.ref.value)), rO(i);
      var a = aa(i.invariantBoundingSphere.ref.value, i.aTransform.ref.value, i.instanceCount.ref.value);
      G.update(i.boundingSphere, a);
    }
  };
})(nr || (nr = {})), function(t) {
  function e(r) {
    return r.layers.length === 0;
  }
  t.Empty = { layers: [] }, function(r) {
    function n(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;
      }
    }
    r.is = Ga.has, r.create = function(i) {
      return Ga.create(i);
    }, r.Names = { one: 1, two: 2, three: 4, four: 8, five: 16, six: 32 }, r.isName = function(i) {
      return i in r.Names;
    }, r.fromName = n, r.fromNames = function(i) {
      for (var a = 0, o = 0, s = i.length; o < s; ++o) a |= n(i[o]);
      return a;
    }, r.toNames = function(i) {
      var a = [];
      return r.is(i, 1) && a.push("one"), r.is(i, 2) && a.push("two"), r.is(i, 4) && a.push("three"), r.is(i, 8) && a.push("four"), r.is(i, 16) && a.push("five"), r.is(i, 32) && a.push("six"), a;
    };
  }(t.Groups || (t.Groups = {})), t.areEqual = function(r, n) {
    if (r.layers.length !== n.layers.length) return !1;
    for (var i = 0, a = r.layers.length; i < a; ++i)
      if (r.layers[i].groups !== n.layers[i].groups || !Qr.areEqual(r.layers[i].loci, n.layers[i].loci)) return !1;
    return !0;
  }, t.isEmpty = e, t.remap = function(r, n) {
    for (var i = [], a = 0, o = r.layers; a < o.length; a++) {
      var s = o[a], u = s.loci, c = s.groups;
      u = Xe.remap(u, n), Xe.isEmpty(u) || i.push({ loci: u, groups: c });
    }
    return { layers: i };
  }, t.merge = function(r) {
    if (e(r)) return r;
    for (var n = r.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Xe.none(n), o = 0, s = r.layers.length; o < s; ++o) {
      var u = r.layers[s - o - 1], c = u.loci, l = u.groups;
      c = Xe.subtract(c, a), a = Xe.union(c, a), Xe.isEmpty(c) || (i.has(l) && (c = Xe.union(c, i.get(l))), i.set(l, c));
    }
    var d = [];
    return i.forEach(function(f, h) {
      d.push({ loci: f, groups: h });
    }), { layers: d };
  }, t.filter = function(r, n) {
    if (e(r)) return r;
    for (var i = r.layers[0].loci.structure, a = [], o = 0, s = r.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.groups, d = Xe.remap(c, n);
      c = Xe.remap(d, i), Xe.isEmpty(c) || a.push({ loci: c, groups: l });
    }
    return { layers: a };
  }, t.ofScript = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var s = r[a], u = s.script, c = s.groups, l = Kd.toLoci(u, n);
      Xe.isEmpty(l) || i.push({ loci: l, groups: c });
    }
    return { layers: i };
  }, t.ofBundle = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var s = r[a], u = s.bundle, c = s.groups, l = So.toLoci(u, n.root);
      i.push({ loci: l, groups: c });
    }
    return { layers: i };
  }, t.toBundle = function(r) {
    for (var n = [], i = 0, a = r.layers.length; i < a; ++i) {
      var o = r.layers[i], s = o.loci, u = o.groups, c = So.fromLoci(s);
      n.push({ bundle: c, groups: u });
    }
    return { layers: n };
  };
}(Qm || (Qm = {})), function(t) {
  function e(r) {
    return r.layers.length === 0;
  }
  t.Empty = { layers: [] }, t.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var i = 0, a = r.layers.length; i < a; ++i)
      if (r.layers[i].clear !== n.layers[i].clear || !sQ(r.layers[i].material, n.layers[i].material) || !Qr.areEqual(r.layers[i].loci, n.layers[i].loci)) return !1;
    return !0;
  }, t.isEmpty = e, t.remap = function(r, n) {
    for (var i = [], a = 0, o = r.layers; a < o.length; a++) {
      var s = o[a], u = s.loci, c = s.material, l = s.clear;
      u = Xe.remap(u, n), Xe.isEmpty(u) || i.push({ loci: u, material: c, clear: l });
    }
    return { layers: i };
  }, t.merge = function(r) {
    if (e(r)) return r;
    for (var n = r.layers[0].loci.structure, i = void 0, a = /* @__PURE__ */ new Map(), o = Xe.none(n), s = 0, u = r.layers.length; s < u; ++s) {
      var c = r.layers[u - s - 1], l = c.loci, d = c.material, f = c.clear;
      l = Xe.subtract(l, o), o = Xe.union(l, o), Xe.isEmpty(l) || (f ? i = i ? Xe.union(l, i) : l : (a.has(d) && (l = Xe.union(l, a.get(d))), a.set(d, l)));
    }
    var h = [];
    return i && h.push({ loci: i, material: Dp(), clear: !0 }), a.forEach(function(m, p) {
      h.push({ loci: m, material: p, clear: !1 });
    }), { layers: h };
  }, t.filter = function(r, n) {
    if (e(r)) return r;
    for (var i = r.layers[0].loci.structure, a = [], o = 0, s = r.layers; o < s.length; o++) {
      var u = s[o], c = u.loci, l = u.material, d = u.clear, f = Xe.remap(c, n);
      c = Xe.remap(f, i), Xe.isEmpty(c) || a.push({ loci: c, material: l, clear: d });
    }
    return { layers: a };
  }, t.ofScript = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var s = r[a], u = s.script, c = s.material, l = s.clear, d = Kd.toLoci(u, n);
      Xe.isEmpty(d) || i.push({ loci: d, material: c, clear: l });
    }
    return { layers: i };
  }, t.ofBundle = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var s = r[a], u = s.bundle, c = s.material, l = s.clear, d = So.toLoci(u, n.root);
      i.push({ loci: d, material: c, clear: l });
    }
    return { layers: i };
  }, t.toBundle = function(r) {
    for (var n = [], i = 0, a = r.layers.length; i < a; ++i) {
      var o = r.layers[i], s = o.loci, u = o.material, c = o.clear, l = So.fromLoci(s);
      n.push({ bundle: l, material: u, clear: c });
    }
    return { layers: n };
  };
}(Jm || (Jm = {})), function(t) {
  t.getDetaultParams = function(e, r, n) {
    return z.getDefaultValues(e.getParams(r, n));
  };
}(dT || (dT = {}));
var sr, W3, Zne = { name: "", label: "", description: "", factory: function() {
  return sr.Empty;
}, getParams: function() {
  return {};
}, defaultValues: {}, defaultColorTheme: El.EmptyProvider, defaultSizeTheme: Co.EmptyProvider, isApplicable: function() {
  return !0;
} };
function fT(t) {
  return t.map(function(e) {
    return [e.name, e.provider.label];
  });
}
(function() {
  function t() {
    this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map();
  }
  Object.defineProperty(t.prototype, "default", { get: function() {
    return this._list[0];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "types", { get: function() {
    return fT(this._list);
  }, enumerable: !1, configurable: !0 }), t.prototype.add = function(e) {
    if (this._map.has(e.name)) throw new Error("".concat(e.name, " already registered."));
    this._list.push({ name: e.name, provider: e }), this._map.set(e.name, e), this._name.set(e, e.name);
  }, t.prototype.getName = function(e) {
    if (!this._name.has(e)) throw new Error("'".concat(e.label, "' is not a registered represenatation provider."));
    return this._name.get(e);
  }, t.prototype.remove = function(e) {
    var r = e.name;
    this._list.splice(this._list.findIndex(function(i) {
      return i.name === r;
    }), 1);
    var n = this._map.get(r);
    n && (this._map.delete(r), this._name.delete(n));
  }, t.prototype.get = function(e) {
    return this._map.get(e) || Zne;
  }, Object.defineProperty(t.prototype, "list", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), t.prototype.getApplicableList = function(e) {
    return this._list.filter(function(r) {
      return r.provider.isApplicable(e);
    });
  }, t.prototype.getApplicableTypes = function(e) {
    return fT(this.getApplicableList(e));
  };
})(), function(t) {
  function e() {
    return { visible: !0, alphaFactor: 1, pickable: !0, colorOnly: !1, syncManually: !1, transform: he.identity(), overpaint: jm.Empty, transparency: Zm.Empty, substance: Jm.Empty, clipping: Qm.Empty, markerActions: Lr.All };
  }
  function r(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 && he.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 && Qr.areEqual(a.loci, o.loci);
    }, i.isEmpty = function(a) {
      return Qr.isEmpty(a.loci);
    }, i.Empty = { loci: Dn };
  })(t.Loci || (t.Loci = {})), t.createState = e, t.updateState = r, t.StateBuilder = { create: e, update: r }, t.Empty = { label: "", groupCount: 0, renderObjects: [], geometryVersion: -1, props: {}, params: {}, updated: new Si(), state: e(), theme: su.createEmpty(), createOrUpdate: function() {
    return tr.constant("", void 0);
  }, setState: function() {
  }, setTheme: function() {
  }, getLoci: function() {
    return Dn;
  }, mark: function() {
    return !1;
  }, destroy: function() {
  } };
  var n = 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(iu(a, o));
    }, i.prototype.snapshot = function() {
      var a;
      Ao.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;
  }();
  t.GeometryState = n, t.createMulti = function(i, a, o, s, u) {
    var c, l, d, f = this, h = 0, m = new Si(), p = new n(), v = s.create(), g = su.createEmpty(), y = {}, b = Object.keys(u).map(function(S, _) {
      y[_] = S;
      var x = u[S](a, o);
      return x.setState(v), x;
    });
    return { label: i, updated: m, get groupCount() {
      var S = 0;
      if (l) for (var _ = l.visuals, x = 0, C = b.length; x < C; ++x) _ && !_.includes(y[x]) || (S += b[x].groupCount);
      return S;
    }, get renderObjects() {
      var S = [];
      if (l) for (var _ = l.visuals, x = 0, C = b.length; x < C; ++x) _ && !_.includes(y[x]) || S.push.apply(S, b[x].renderObjects);
      return S;
    }, get geometryVersion() {
      return p.version;
    }, get props() {
      return l;
    }, get params() {
      return c;
    }, createOrUpdate: function(S, _) {
      S === void 0 && (S = {}), _ && _ !== d && (c = o(a, _), d = _, l || (l = z.getDefaultValues(c))), l || (l = {});
      var x = g7(Object.assign({}, l || {}, S || {}), d);
      Object.assign(l, S || {}, x || {});
      var C = l.visuals;
      return tr.create("Creating or updating '".concat(i, "' representation"), function(A) {
        return _e(f, 0, void 0, function() {
          var w, I;
          return ye(this, function(P) {
            switch (P.label) {
              case 0:
                w = 0, I = b.length, P.label = 1;
              case 1:
                return w < I ? C && !C.includes(y[w]) ? [3, 3] : [4, b[w].createOrUpdate(l, d).runInContext(A)] : [3, 5];
              case 2:
                P.sent(), P.label = 3;
              case 3:
                p.add(w, b[w].geometryVersion), P.label = 4;
              case 4:
                return ++w, [3, 1];
              case 5:
                return p.snapshot(), m.next(h++), [2];
            }
          });
        });
      });
    }, get state() {
      return v;
    }, get theme() {
      return g;
    }, getLoci: function(S) {
      for (var _ = l.visuals, x = 0, C = b.length; x < C; ++x) if (!_ || _.includes(y[x])) {
        var A = b[x].getLoci(S);
        if (!ef(A)) return A;
      }
      return Dn;
    }, mark: function(S, _) {
      for (var x = !1, C = 0, A = b.length; C < A; ++C) x = b[C].mark(S, _) || x;
      return x;
    }, setState: function(S) {
      s.update(v, S);
      for (var _ = 0, x = b.length; _ < x; ++_) b[_].setState(S);
      m.next(h++);
    }, setTheme: function(S) {
      g = S;
      for (var _ = 0, x = b.length; _ < x; ++_) b[_].setTheme(S);
    }, destroy: function() {
      for (var S = 0, _ = b.length; S < _; ++S) b[S].destroy();
    } };
  }, t.fromRenderObject = function(i, a) {
    var o = this, s = 0, u = new Si(), c = new n(), l = t.createState(), d = su.createEmpty(), f = z.clone(ft.Params), h = z.getDefaultValues(ft.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 h;
    }, get params() {
      return f;
    }, createOrUpdate: function(m) {
      m === void 0 && (m = {});
      var p = g7(Object.assign({}, h, m));
      return Object.assign(h, m, p), tr.create("Updating '".concat(i, "' representation"), function(v) {
        return _e(o, 0, void 0, function() {
          return ye(this, function(g) {
            return c.add(0, a.id), c.snapshot(), u.next(s++), [2];
          });
        });
      });
    }, get state() {
      return l;
    }, get theme() {
      return d;
    }, getLoci: function() {
      return Dn;
    }, mark: function(m, p) {
      return !1;
    }, setState: function(m) {
      m.visible !== void 0 && nr.setVisibility(a, m.visible), m.alphaFactor !== void 0 && nr.setAlphaFactor(a, m.alphaFactor), m.pickable !== void 0 && nr.setPickable(a, m.pickable), m.colorOnly !== void 0 && nr.setColorOnly(a, m.colorOnly), m.overpaint, m.transparency, m.substance, m.transform !== void 0 && nr.setTransform(a, m.transform), t.updateState(l, m);
    }, setTheme: function() {
    }, destroy: function() {
    } };
  };
}(sr || (sr = {})), function(t) {
  t.create = function() {
    return { view: he.identity(), position: E.create(0, 0, 0), direction: E.create(0, 0, -1), up: E.create(0, 1, 0) };
  };
  var e = E.zero();
  t.update = function(r) {
    E.add(e, r.position, r.direction), he.lookAt(r.view, r.position, e, r.up);
  };
}(W3 || (W3 = {}));
var Pp, Qne = function() {
  function t() {
    this.removeList = _D(), this.removeMap = /* @__PURE__ */ new Map(), this.addList = _D(), this.addMap = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(t.prototype, "isEmpty", { get: function() {
    return this.removeList.count === 0 && this.addList.count === 0;
  }, enumerable: !1, configurable: !0 }), t.prototype.add = function(e) {
    if (this.removeMap.has(e)) {
      var r = this.removeMap.get(e);
      this.removeMap.delete(e), this.removeList.remove(r);
    }
    if (!this.addMap.has(e)) {
      var n = this.addList.addLast(e);
      this.addMap.set(e, n);
    }
  }, t.prototype.remove = function(e) {
    if (this.addMap.has(e)) {
      var r = this.addMap.get(e);
      this.addMap.delete(e), this.addList.remove(r);
    }
    if (!this.removeMap.has(e)) {
      var n = this.removeList.addLast(e);
      this.removeMap.set(e, n);
    }
  }, t.prototype.tryGetRemove = function() {
    var e = this.removeList.removeFirst();
    return e && this.removeMap.delete(e), e;
  }, t.prototype.tryGetAdd = function() {
    var e = this.addList.removeFirst();
    return e && this.addMap.delete(e), e;
  }, t;
}(), Gh = new cu("98");
function pT(t, e, r) {
  Gh.reset();
  for (var n = 0, i = t.length; n < i; ++n) if (!r || t[n].state.visible) {
    var a = t[n].values.boundingSphere.ref.value;
    a.radius && Gh.includeSphere(a);
  }
  for (Gh.finishedIncludeStep(), n = 0, i = t.length; n < i; ++n) if (!r || t[n].state.visible) {
    var o = t[n].values.boundingSphere.ref.value;
    o.radius && Gh.radiusSphere(o);
  }
  return Gh.getSphere(e);
}
function Jne(t, e) {
  var r = (t.getProgram("colorBlended") || t.getProgram("colorWboit")).id, n = (e.getProgram("colorBlended") || t.getProgram("colorWboit")).id, i = t.materialId, a = e.materialId;
  return r !== n ? r - n : i !== a ? i - a : t.id - e.id;
}
(function(t) {
  t.create = function(e, r) {
    r === void 0 && (r = ux);
    var n = /* @__PURE__ */ new Map(), i = [], a = Me(), o = Me(), s = [], u = [], c = !0, l = !0, d = W3.create(), f = d.view, h = d.position, m = d.direction, p = d.up;
    function v(x) {
      if (n.has(x)) return console.warn("RenderObject with id '".concat(x.id, "' already present")), n.get(x);
      var C = Pre(e, x, r);
      return i.push(C), x.type === "direct-volume" ? u.push(C) : s.push(C), n.set(x, C), c = !0, l = !0, C;
    }
    function g(x) {
      var C = n.get(x);
      C && (C.dispose(), t3(i, C), t3(s, C), t3(u, C), n.delete(x), c = !0, l = !0);
    }
    var y = new Qne(), b = -1;
    function S() {
      for (var x = 23, C = 0, A = i.length; C < A; ++C) i[C].state.visible && (x = 31 * x + i[C].id | 0);
      return (x = sN(x)) === -1 && (x = 0), x;
    }
    function _() {
      return S() !== b && (l = !0, !0);
    }
    return { view: f, position: h, direction: m, up: p, renderables: i, primitives: { view: f, position: h, direction: m, up: p, renderables: s }, volumes: { view: f, position: h, direction: m, up: p, renderables: u }, syncVisibility: _, update: function(x, C) {
      var A;
      if (W3.update(d), x) for (var w = 0, I = x.length; w < I; ++w) (A = n.get(x[w])) === null || A === void 0 || A.update();
      else for (w = 0, I = i.length; w < I; ++w) i[w].update();
      C ? _() : (c = !0, l = !0);
    }, add: function(x) {
      return y.add(x);
    }, remove: function(x) {
      return y.remove(x);
    }, commit: function(x) {
      return x === void 0 && (x = Number.MAX_VALUE), function(C) {
        for (var A = wi(), w = 0; I = y.tryGetRemove(); ) if (g(I), ++w % 100 == 0 && wi() - A > C) return !1;
        for (; ; ) {
          var I;
          if (!(I = y.tryGetAdd())) break;
          if (v(I), ++w % 100 == 0 && wi() - A > C) return !1;
        }
        return i.sort(Jne), !0;
      }(x);
    }, get needsCommit() {
      return !y.isEmpty;
    }, has: function(x) {
      return n.has(x);
    }, clear: function() {
      for (var x = 0, C = i.length; x < C; ++x) i[x].dispose();
      i.length = 0, n.clear(), c = !0, l = !0;
    }, forEach: function(x) {
      n.forEach(x);
    }, get count() {
      return i.length;
    }, get boundingSphere() {
      return c && (pT(i, a, !1), c = !1), a;
    }, get boundingSphereVisible() {
      return l && (pT(i, o, !0), l = !1, b = S()), o;
    }, getMarkerAverage: function() {
      if (s.length === 0 && u.length === 0) return 0;
      for (var x = 0, C = 0, A = s.length; C < A; ++C) x += s[C].values.markerAverage.ref.value;
      for (C = 0, A = u.length; C < A; ++C) x += u[C].values.markerAverage.ref.value;
      return x / (s.length + u.length);
    } };
  };
})(Pp || (Pp = {}));
var v7 = function() {
  function t(e) {
    this.camera = e, this.t = 0, this.func = t.defaultTransition, this.start = 0, this.inTransition = !1, this.durationMs = 0, this._source = di.createDefaultSnapshot(), this._target = di.createDefaultSnapshot(), this._current = di.createDefaultSnapshot();
  }
  return Object.defineProperty(t.prototype, "source", { get: function() {
    return this._source;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
    return this._target;
  }, enumerable: !1, configurable: !0 }), t.prototype.apply = function(e, r, n) {
    r === void 0 && (r = 0), (!this.inTransition || r > 0) && di.copySnapshot(this._source, this.camera.state), this.inTransition || di.copySnapshot(this._target, this.camera.state), di.copySnapshot(this._target, e), this._target.radius > this._target.radiusMax && (this._target.radius = this._target.radiusMax), this._target.radius < 0.01 && (this._target.radius = 0.01), this._target.radiusMax < 0.01 && (this._target.radiusMax = 0.01), !this.inTransition && r <= 0 || e.mode !== void 0 && e.mode !== this.camera.state.mode ? this.finish(this._target) : (this.inTransition = !0, this.func = n || t.defaultTransition, (!this.inTransition || r > 0) && (this.start = this.t, this.durationMs = r));
  }, t.prototype.tick = function(e) {
    this.t = e, this.update();
  }, t.prototype.finish = function(e) {
    di.copySnapshot(this.camera.state, e), this.inTransition = !1;
  }, t.prototype.update = function() {
    if (this.inTransition) {
      var e = Math.min((this.t - this.start) / this.durationMs, 1);
      e !== 1 ? (this.func(this._current, e, this._source, this._target), di.copySnapshot(this.camera.state, this._current)) : this.finish(this._target);
    }
  }, t;
}();
(function(t) {
  var e = kn.identity();
  t.defaultTransition = function(r, n, i, a) {
    di.copySnapshot(r, a), kn.slerp(e, kn.Identity, kn.rotationTo(e, i.up, a.up), n), E.transformQuat(r.up, i.up, e), E.lerp(r.target, i.target, a.target, n), E.lerp(r.position, i.position, a.position, n), r.radius = Vi(i.radius, a.radius, n), r.radiusMax = Vi(i.radiusMax, a.radiusMax, n), r.fov = Vi(i.fov, a.fov, n), r.fog = Vi(i.fog, a.fog, n);
  };
})(v7 || (v7 = {}));
var hT = E(), mT = E(), ov = Ut(), di = function() {
  function t(e, r, n) {
    r === void 0 && (r = sa.create(0, 0, 128, 128)), n === void 0 && (n = {}), this.view = he.identity(), this.projection = he.identity(), this.projectionView = he.identity(), this.inverseProjectionView = he.identity(), this.state = t.createDefaultSnapshot(), this.viewOffset = t.ViewOffset(), this.near = 1, this.far = 1e4, this.fogNear = 5e3, this.fogFar = 1e4, this.zoom = 1, this.transition = new v7(this), this.stateChanged = new kd(this.state), this.prevProjection = he.identity(), this.prevView = he.identity(), this.deltaDirection = E(), this.newPosition = E(), this.viewport = r, this.pixelScale = n.pixelScale || 1, t.copySnapshot(this.state, e);
  }
  return Object.defineProperty(t.prototype, "pixelRatio", { get: function() {
    return (typeof window < "u" ? window.devicePixelRatio : 1) * this.pixelScale;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "position", { get: function() {
    return this.state.position;
  }, set: function(e) {
    E.copy(this.state.position, e);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "up", { get: function() {
    return this.state.up;
  }, set: function(e) {
    E.copy(this.state.up, e);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
    return this.state.target;
  }, set: function(e) {
    E.copy(this.state.target, e);
  }, enumerable: !1, configurable: !0 }), t.prototype.update = function() {
    var e = this.state;
    if (e.radiusMax === 0) return !1;
    var r = 2 * Math.tan(e.fov / 2) * E.distance(e.position, e.target);
    switch (this.zoom = this.viewport.height / r, 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 = E.distance(i.position, i.target), f = d - o, h = d + l, m = d - l * (-(50 - u) / 50), p = h;
      f = Math.max(Math.min(s, 5), f), h = Math.max(5, h), f === h && (h = f + 0.01), i.near = f, i.far = 2 * h, i.fogNear = m, i.fogFar = p;
    }(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, f = a.height / 2, h = -a.height / 2, m = (d - l) / (2 * o), p = (f - h) / (2 * o), v = (d + l) / 2, g = (f + h) / 2, y = v - m, b = v + m, S = g + p, _ = g - p;
          if (c.enabled) {
            var x = o / (c.width / c.fullWidth), C = o / (c.height / c.fullHeight), A = (d - l) / c.width, w = (f - h) / c.height;
            b = (y += A * (c.offsetX / x)) + A * (c.width / x), _ = (S -= w * (c.offsetY / C)) - w * (c.height / C);
          }
          he.ortho(i.projection, y, b, S, _, s, u), he.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, f = -0.5 * d;
          u.enabled && (f += u.offsetX * d / u.fullWidth, c -= u.offsetY * l / u.fullHeight, d *= u.width / u.fullWidth, l *= u.height / u.fullHeight), he.perspective(i.projection, f, f + d, c, c - l, o, s), he.lookAt(i.view, i.position, i.target, i.up);
        })(this);
        break;
      default:
        ca(this.state.mode);
    }
    var n = !he.areEqual(this.projection, this.prevProjection, Cn) || !he.areEqual(this.view, this.prevView, Cn);
    if (n) {
      if (he.mul(this.projectionView, this.projection, this.view), !he.tryInvert(this.inverseProjectionView, this.projectionView)) return he.copy(this.view, this.prevView), he.copy(this.projection, this.prevProjection), he.mul(this.projectionView, this.projection, this.view), !1;
      he.copy(this.prevView, this.view), he.copy(this.prevProjection, this.projection);
    }
    return n;
  }, t.prototype.setState = function(e, r) {
    !Number.isNaN(e.radius) && e.radius <= 0.01 || (this.transition.apply(e, r), this.stateChanged.next(e));
  }, t.prototype.getSnapshot = function() {
    return t.copySnapshot(t.createDefaultSnapshot(), this.state);
  }, t.prototype.getTargetDistance = function(e) {
    return t.targetDistance(e, this.state.fov, this.viewport.width, this.viewport.height);
  }, t.prototype.getFocus = function(e, r, n, i) {
    var a = Math.max(r, 0.01), o = this.getTargetDistance(a);
    E.sub(this.deltaDirection, this.target, this.position), i && E.matchDirection(this.deltaDirection, i, this.deltaDirection), E.setMagnitude(this.deltaDirection, this.deltaDirection, o), E.sub(this.newPosition, e, this.deltaDirection);
    var s = t.copySnapshot(t.createDefaultSnapshot(), this.state);
    return s.target = E.clone(e), s.radius = a, s.position = E.clone(this.newPosition), n && E.matchDirection(s.up, n, s.up), s;
  }, t.prototype.getInvariantFocus = function(e, r, n, i) {
    var a = Math.max(r, 0.01), o = this.getTargetDistance(a);
    E.copy(this.deltaDirection, i), E.setMagnitude(this.deltaDirection, this.deltaDirection, o), E.sub(this.newPosition, e, this.deltaDirection);
    var s = t.copySnapshot(t.createDefaultSnapshot(), this.state);
    return s.target = E.clone(e), s.radius = a, s.position = E.clone(this.newPosition), E.copy(s.up, n), s;
  }, t.prototype.focus = function(e, r, n, i, a) {
    r > 0 && this.setState(this.getFocus(e, r, i, a), n);
  }, t.prototype.project = function(e, r) {
    return function(n, i, a, o) {
      var s = a.x, u = a.y, c = a.width, l = a.height;
      Ut.set(Zu, i[0], i[1], i[2], 1), Ut.transformMat4(Zu, Zu, o);
      var d = Zu[3];
      return d !== 0 && (Zu[0] /= d, Zu[1] /= d, Zu[2] /= d), n[0] = (Zu[0] + 1) * c * 0.5 + s, n[1] = (1 - Zu[1]) * l * 0.5 + u, n[2] = 0.5 * (Zu[2] + 1), n[3] = d === 0 ? 0 : 1 / d, n;
    }(e, r, this.viewport, this.projectionView);
  }, t.prototype.unproject = function(e, r) {
    return lm(e, r, this.viewport, this.inverseProjectionView);
  }, t.prototype.getPixelSize = function(e) {
    return this.project(ov, e), this.unproject(hT, ov), ov[0] += 1, this.unproject(mT, ov), E.distance(hT, mT);
  }, t;
}();
(function(t) {
  t.ViewOffset = function() {
    return { enabled: !1, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 };
  }, t.setViewOffset = function(e, r, n, i, a, o, s) {
    e.fullWidth = r, e.fullHeight = n, e.offsetX = i, e.offsetY = a, e.width = o, e.height = s;
  }, t.copyViewOffset = function(e, r) {
    e.enabled = r.enabled, e.fullWidth = r.fullWidth, e.fullHeight = r.fullHeight, e.offsetX = r.offsetX, e.offsetY = r.offsetY, e.width = r.width, e.height = r.height;
  }, t.targetDistance = function(e, r, n, i) {
    var a = Math.max(e, 0.01), o = i < n ? 1 : n / i;
    return Math.abs(a / o / Math.sin(r / 2));
  }, t.createDefaultSnapshot = function() {
    return { mode: "orthographic", fov: Math.PI / 4, position: E.create(0, 0, 100), up: E.create(0, 1, 0), target: E.create(0, 0, 0), radius: 0, radiusMax: 10, fog: 50, clipFar: !0 };
  }, t.copySnapshot = function(e, r) {
    return r && (r.mode !== void 0 && (e.mode = r.mode), r.fov !== void 0 && (e.fov = r.fov), r.position !== void 0 && E.copy(e.position, r.position), r.up !== void 0 && E.copy(e.up, r.up), r.target !== void 0 && E.copy(e.target, r.target), r.radius !== void 0 && (e.radius = r.radius), r.radiusMax !== void 0 && (e.radiusMax = r.radiusMax), r.fog !== void 0 && (e.fog = r.fog), r.clipFar !== void 0 && (e.clipFar = r.clipFar)), e;
  }, t.areSnapshotsEqual = function(e, r) {
    return e.mode === r.mode && e.fov === r.fov && e.radius === r.radius && e.radiusMax === r.radiusMax && e.fog === r.fog && e.clipFar === r.clipFar && E.exactEquals(e.position, r.position) && E.exactEquals(e.up, r.up) && E.exactEquals(e.target, r.target);
  };
})(di || (di = {}));
var $ne = { radius: 1, detail: 0 };
function eie(t, e, r) {
  var n = O(O({}, $ne), r), i = n.radius, a = n.detail, o = /* @__PURE__ */ function() {
    var d = [], f = [], h = /* @__PURE__ */ new Map();
    function m(p) {
      var v = "".concat(p[0].toFixed(5), "|").concat(p[1].toFixed(5), "|").concat(p[2].toFixed(5)), g = h.get(v);
      return g === void 0 && (g = d.length / 3, h.set(v, g), d.push.apply(d, p)), g;
    }
    return { vertices: d, indices: f, add: function(p, v, g) {
      f.push(m(p), m(v), m(g));
    } };
  }(), s = o.vertices, u = o.indices;
  (function(d) {
    for (var f = E(), h = E(), m = E(), p = 0; p < e.length; p += 3) E.fromArray(f, t, 3 * e[p + 0]), E.fromArray(h, t, 3 * e[p + 1]), E.fromArray(m, t, 3 * e[p + 2]), l(f, h, m, d);
  })(a), function(d, f) {
    for (var h = 0, m = d.length; h < m; h += 3) E.fromArray(Go, d, h), E.normalize(Go, Go), E.scale(Go, Go, f), E.toArray(Go, d, h);
  }(s, i);
  var c = new Float32Array(s.length);
  return $R(s, u, c, s.length / 3, u.length / 3), { vertices: new Float32Array(s), normals: new Float32Array(c), indices: new Uint32Array(u) };
  function l(d, f, h, m) {
    for (var p = Math.pow(2, m), v = [], g = 0; g <= p; ++g) {
      v[g] = [];
      var y = E();
      E.lerp(y, d, h, g / p);
      var b = E();
      E.lerp(b, f, h, g / p);
      for (var S = p - g, _ = 0; _ <= S; ++_) if (_ === 0 && g === p) v[g][_] = y;
      else {
        var x = E();
        E.lerp(x, y, b, _ / S), v[g][_] = x;
      }
    }
    for (g = 0; g < p; ++g) for (_ = 0; _ < 2 * (p - g) - 1; ++_) {
      var C = Math.floor(_ / 2);
      _ % 2 == 0 ? o.add(v[g][C + 1], v[g + 1][C], v[g][C]) : o.add(v[g][C + 1], v[g + 1][C + 1], v[g + 1][C]);
    }
  }
}
var Ob, Ls = (1 + Math.sqrt(5)) / 2, PO = (Ob || (Ob = iO([-1, Ls, 0, 1, Ls, 0, -1, -Ls, 0, 1, -Ls, 0, 0, -1, Ls, 0, 1, Ls, 0, -1, -Ls, 0, 1, -Ls, Ls, 0, -1, Ls, 0, 1, -Ls, 0, -1, -Ls, 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])), Ob), tie = PO.vertices, rie = PO.indices;
function BO(t) {
  return 10 * Math.pow(Math.pow(2, t), 2) + 2;
}
var gT = /* @__PURE__ */ new Map(), nie = he.identity();
function iie(t) {
  var e = gT.get(t);
  return e === void 0 && (e = function(r) {
    return eie(tie, rie, { detail: r, radius: 1 });
  }(t), gT.set(t, e)), e;
}
function Yi(t, e, r, n) {
  wt.addPrimitive(t, function(i, a, o) {
    return he.scaleUniformly(i, he.fromTranslation(i, a), o);
  }(nie, e, r), iie(n));
}
var ec = { radiusTop: 1, radiusBottom: 1, height: 1, radialSegments: 8, heightSegments: 1, topCap: !1, bottomCap: !1, thetaStart: 0, thetaLength: 2 * Math.PI }, vT = E(), yT = E(), Fo = E(), No = E(), tc = E(), M1 = E(), aie = { height: 1, topCap: !0, bottomCap: !0 }, bT = /* @__PURE__ */ new Map(), _T = E.create(0, 1, 0), cc = E(), sv = E(), xT = E(), Xd = he(), ST = he(), CT = E(), rp = E(), Lb = E();
function j3(t, e, r, n, i) {
  return E.setMagnitude(sv, r, n / 2), E.add(xT, e, sv), i ? E.matchDirection(Lb, _T, sv) : E.copy(Lb, _T), E.set(CT, 1, n, 1), E.makeRotation(ST, Lb, sv), he.scale(t, ST, CT), he.setTranslation(t, xT);
}
var rc = new Int32Array(9);
function mx(t) {
  var e = function(i) {
    var a, o, s, u, c, l, d, f, h;
    return rc[0] = Math.round(1e3 * ((a = i.radiusTop) !== null && a !== void 0 ? a : ec.radiusTop)), rc[1] = Math.round(1e3 * ((o = i.radiusBottom) !== null && o !== void 0 ? o : ec.radiusBottom)), rc[2] = Math.round(1e3 * ((s = i.height) !== null && s !== void 0 ? s : ec.height)), rc[3] = (u = i.radialSegments) !== null && u !== void 0 ? u : ec.radialSegments, rc[4] = (c = i.heightSegments) !== null && c !== void 0 ? c : ec.heightSegments, rc[5] = ((l = i.topCap) !== null && l !== void 0 ? l : ec.topCap) ? 1 : 0, rc[6] = ((d = i.bottomCap) !== null && d !== void 0 ? d : ec.bottomCap) ? 1 : 0, rc[7] = Math.round(1e3 * ((f = i.thetaStart) !== null && f !== void 0 ? f : ec.thetaStart)), rc[8] = Math.round(1e3 * ((h = i.thetaLength) !== null && h !== void 0 ? h : ec.thetaLength)), ro(rc);
  }(t), r = bT.get(e);
  if (r === void 0) {
    if (t.radialSegments && t.radialSegments <= 4) {
      var n = 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 = O(O({}, aie), a), u = s.height, c = s.topCap, l = s.bottomCap, d = 2 * o, f = 4 * o, h = (c ? 1 : 0) + (l ? 1 : 0);
        o === 3 ? (d += h, f += 3 * h) : o === 4 ? (d += 2 * h, f += 4 * h) : (d += h * o, f += h * o * 3);
        var m = b2(d, f), p = 0.5 * u;
        E.set(vT, 0, 0, -p), E.set(yT, 0, 0, p);
        for (var v = 0; v < o; ++v) {
          var g = (v + 1) % o;
          E.set(Fo, i[3 * v], i[3 * v + 1], -p), E.set(No, i[3 * g], i[3 * g + 1], -p), E.set(tc, i[3 * g], i[3 * g + 1], p), E.set(M1, i[3 * v], i[3 * v + 1], p), m.addQuad(Fo, No, tc, M1);
        }
        if (o === 3) c && (E.set(Fo, i[0], i[1], -p), E.set(No, i[3], i[4], -p), E.set(tc, i[6], i[7], -p), m.add(tc, No, Fo)), l && (E.set(Fo, i[0], i[1], p), E.set(No, i[3], i[4], p), E.set(tc, i[6], i[7], p), m.add(Fo, No, tc));
        else if (o === 4) c && (E.set(Fo, i[0], i[1], -p), E.set(No, i[3], i[4], -p), E.set(tc, i[6], i[7], -p), E.set(M1, i[9], i[10], -p), m.addQuad(M1, tc, No, Fo)), l && (E.set(Fo, i[0], i[1], p), E.set(No, i[3], i[4], p), E.set(tc, i[6], i[7], p), E.set(M1, i[9], i[10], p), m.addQuad(Fo, No, tc, M1));
        else for (v = 0; v < o; ++v) g = (v + 1) % o, c && (E.set(Fo, i[3 * v], i[3 * v + 1], -p), E.set(No, i[3 * g], i[3 * g + 1], -p), m.add(vT, No, Fo)), l && (E.set(Fo, i[3 * v], i[3 * v + 1], p), E.set(No, i[3 * g], i[3 * g + 1], p), m.add(Fo, No, yT));
        return m.getPrimitive();
      }(Vy(Math.max(3, t.radialSegments), !0, t.radiusTop), t);
      r = zy(n, he.rotX90);
    } else r = function(i) {
      var a = O(O({}, ec), i), o = a.radiusTop, s = a.radiusBottom, u = a.height, c = a.radialSegments, l = a.heightSegments, d = a.topCap, f = a.bottomCap, h = a.thetaStart, m = a.thetaLength, p = [], v = [], g = [], y = 0, b = [], S = u / 2;
      return function() {
        for (var x = E.zero(), C = (s - o) / u, A = 0; A <= l; ++A) {
          for (var w = [], I = A / l, P = I * (s - o) + o, M = 0; M <= c; ++M) {
            var T = M / c * m + h, F = Math.sin(T), N = Math.cos(T);
            v.push(P * F, -I * u + S, P * N), E.normalize(x, E.set(x, F, C, N)), g.push.apply(g, x), w.push(y++);
          }
          b.push(w);
        }
        for (M = 0; M < c; ++M) for (A = 0; A < l; ++A) {
          var R = b[A][M], L = b[A + 1][M], V = b[A + 1][M + 1], U = b[A][M + 1];
          p.push(R, L, U), p.push(L, V, U);
        }
      }(), d && o > 0 && _(!0), f && s > 0 && _(!1), { vertices: new Float32Array(v), normals: new Float32Array(g), indices: new Uint32Array(p) };
      function _(x) {
        for (var C = x === !0 ? o : s, A = x === !0 ? 1 : -1, w = y, I = 1; I <= c; ++I) v.push(0, S * A, 0), g.push(0, A, 0), ++y;
        var P = y;
        for (I = 0; I <= c; ++I) {
          var M = I / c * m + h, T = Math.cos(M), F = Math.sin(M);
          v.push(C * F, S * A, C * T), g.push(0, A, 0), ++y;
        }
        for (I = 0; I < c; ++I) {
          var N = w + I, R = P + I;
          x === !0 ? p.push(R, R + 1, N) : p.push(R + 1, R, N);
        }
      }
    }(t);
    bT.set(e, r);
  }
  return r;
}
function Hi(t, e, r, n, i) {
  var a = E.distance(e, r) * n;
  E.sub(cc, r, e), j3(Xd, e, cc, a, !0), wt.addPrimitive(t, Xd, mx(i));
}
function oie(t, e, r, n, i, a) {
  var o = E.distance(e, r) * n, s = mx(a);
  E.sub(cc, r, e), E.add(rp, e, i), j3(Xd, rp, cc, o, !0), wt.addPrimitive(t, Xd, s), E.sub(rp, e, i), j3(Xd, rp, cc, o, !0), wt.addPrimitive(t, Xd, s);
}
function Rm(t, e, r, n, i, a) {
  var o = Math.floor(i / 2), s = 1 / i;
  if (n < 1) {
    var u = n / 2 / i;
    n += i % 2 == 1 ? u : -u;
  }
  var c = E.distance(e, r) * n, l = mx(a);
  E.sub(cc, r, e);
  for (var d = 0; d < o; ++d) {
    var f = s * (2 * d + 1);
    E.setMagnitude(cc, cc, c * f), E.add(rp, e, cc), j3(Xd, rp, cc, c * s, !1), wt.addPrimitive(t, Xd, l);
  }
}
var wt, ri = E(), AT = Wi(), Zc = E(), nc = E(), Gf = E(), uv = E(), as = E.fromArray, sie = E.triangleNormal, wT = E.copy, cv = E.transformMat4, DT = E.transformMat3, ET = Wi.directionTransform, yu = Le.add3, kb = Le.add;
(function(t) {
  function e(n, i, a, o) {
    var s = n.vertices, u = n.normals, c = n.indices, l = n.groups, d = n.currentGroup, f = s.elementCount;
    yu(s, i[0], i[1], i[2]), yu(s, a[0], a[1], a[2]), yu(s, o[0], o[1], o[2]), sie(ri, i, a, o);
    for (var h = 0; h < 3; ++h) yu(u, ri[0], ri[1], ri[2]), kb(l, d);
    yu(c, f, f + 1, f + 2);
  }
  function r(n, i, a) {
    for (var o = a.vertices, s = a.normals, u = a.indices, c = n.vertices, l = n.normals, d = n.indices, f = n.groups, h = n.currentGroup, m = c.elementCount, p = ET(AT, i), v = 0, g = o.length; v < g; v += 3) cv(ri, as(ri, o, v), i), yu(c, ri[0], ri[1], ri[2]), DT(ri, as(ri, s, v), p), yu(l, ri[0], ri[1], ri[2]), kb(f, h);
    for (v = 0, g = u.length; v < g; v += 3) yu(d, u[v] + m, u[v + 1] + m, u[v + 2] + m);
  }
  t.createState = function(n, i, a) {
    return n === void 0 && (n = 2048), i === void 0 && (i = 1024), { currentGroup: -1, vertices: Le.create(Float32Array, 3, i, a ? a.vertexBuffer.ref.value : n), normals: Le.create(Float32Array, 3, i, a ? a.normalBuffer.ref.value : n), indices: Le.create(Uint32Array, 3, 3 * i, a ? a.indexBuffer.ref.value : 3 * n), groups: Le.create(Float32Array, 1, i, a ? a.groupBuffer.ref.value : n), mesh: a };
  }, t.addTriangle = e, t.addTriangleStrip = function(n, i, a) {
    as(Gf, i, 3 * a[0]), as(uv, i, 3 * a[1]);
    for (var o = 2, s = a.length; o < s; o += 2) wT(Zc, Gf), wT(nc, uv), as(Gf, i, 3 * a[o]), as(uv, i, 3 * a[o + 1]), e(n, Zc, nc, Gf), e(n, nc, uv, Gf);
  }, t.addTriangleFan = function(n, i, a) {
    as(Zc, i, 3 * a[0]);
    for (var o = 2, s = a.length; o < s; ++o) as(nc, i, 3 * a[o - 1]), as(Gf, i, 3 * a[o]), e(n, Zc, Gf, nc);
  }, t.addPrimitive = r, t.addPrimitiveFlipped = function(n, i, a) {
    for (var o = a.vertices, s = a.normals, u = a.indices, c = n.vertices, l = n.normals, d = n.indices, f = n.groups, h = n.currentGroup, m = c.elementCount, p = ET(AT, i), v = 0, g = o.length; v < g; v += 3) cv(ri, as(ri, o, v), i), yu(c, ri[0], ri[1], ri[2]), DT(ri, as(ri, s, v), p), yu(l, -ri[0], -ri[1], -ri[2]), kb(f, h);
    for (v = 0, g = u.length; v < g; v += 3) yu(d, u[v + 2] + m, u[v + 1] + m, u[v] + m);
  }, t.addCage = function(n, i, a, o, s, u) {
    for (var c = a.vertices, l = a.edges, d = { radiusTop: o, radiusBottom: o, radialSegments: u }, f = 0, h = l.length; f < h; f += 2) as(Zc, c, 3 * l[f]), as(nc, c, 3 * l[f + 1]), cv(Zc, Zc, i), cv(nc, nc, i), Yi(n, Zc, o, s), Yi(n, nc, o, s), Hi(n, Zc, nc, 1, d);
  }, t.addMesh = function(n, i, a) {
    r(n, 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) });
  }, t.getMesh = function(n) {
    var i = n.vertices, a = n.normals, o = n.indices, s = n.groups, u = n.mesh, c = Le.compact(i, !0), l = Le.compact(o, !0), d = Le.compact(a, !0), f = Le.compact(s, !0);
    return Vt.create(c, l, d, f, n.vertices.elementCount, n.indices.elementCount, u);
  };
})(wt || (wt = {}));
var gx = { sceneBoundingSpheres: z.Boolean(!1, { description: "Show full scene bounding spheres." }), visibleSceneBoundingSpheres: z.Boolean(!1, { description: "Show visible scene bounding spheres." }), objectBoundingSpheres: z.Boolean(!1, { description: "Show bounding spheres of visible render objects." }), instanceBoundingSpheres: z.Boolean(!1, { description: "Show bounding spheres of visible instances." }) }, uie = function() {
  function t(e, r, n) {
    this.objectsData = /* @__PURE__ */ new Map(), this.instancesData = /* @__PURE__ */ new Map(), this.scene = Pp.create(e, qy), this.parent = r, this._props = O(O({}, z.getDefaultValues(gx)), n);
  }
  return t.prototype.update = function() {
    var e = this, r = lv(this.scene, this.parent.boundingSphere, this.sceneData, Yt.lightgrey, cie);
    r && (this.sceneData = r);
    var n = lv(this.scene, this.parent.boundingSphereVisible, this.visibleSceneData, Yt.black, lie);
    n && (this.visibleSceneData = n), this.parent.forEach(function(i, a) {
      var o = e.objectsData.get(a), s = lv(e.scene, i.values.boundingSphere.ref.value, o, Yt.tomato, die);
      s && e.objectsData.set(a, s);
      var u = e.instancesData.get(a), c = lv(e.scene, i.values.invariantBoundingSphere.ref.value, u, Yt.skyblue, fie, { 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 && e.instancesData.set(a, c);
    }), this.objectsData.forEach(function(i, a) {
      e.parent.has(a) || (e.scene.remove(i.renderObject), e.objectsData.delete(a));
    }), this.instancesData.forEach(function(i, a) {
      e.parent.has(a) || (e.scene.remove(i.renderObject), e.instancesData.delete(a));
    }), this.scene.update(void 0, !1), this.scene.commit();
  }, t.prototype.syncVisibility = function() {
    var e = this;
    this.sceneData && (this.sceneData.renderObject.state.visible = this._props.sceneBoundingSpheres), this.visibleSceneData && (this.visibleSceneData.renderObject.state.visible = this._props.visibleSceneBoundingSpheres), this.parent.forEach(function(r, n) {
      var i = e.objectsData.get(n);
      i && (i.renderObject.state.visible = n.state.visible && e._props.objectBoundingSpheres);
      var a = e.instancesData.get(n);
      a && (a.renderObject.state.visible = n.state.visible && e._props.instanceBoundingSpheres);
    });
  }, t.prototype.clear = function() {
    this.sceneData = void 0, this.objectsData.clear(), this.scene.clear();
  }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
    return this._props.sceneBoundingSpheres || this._props.visibleSceneBoundingSpheres || this._props.objectBoundingSpheres || this._props.instanceBoundingSpheres;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "props", { get: function() {
    return this._props;
  }, enumerable: !1, configurable: !0 }), t.prototype.setProps = function(e) {
    Object.assign(this._props, e), this.isEnabled && this.update();
  }, t;
}();
function lv(t, e, r, n, i, a) {
  if (!r || !Me.equals(r.boundingSphere, e)) {
    var o = function(u, c) {
      var l = 2, d = BO(l), f = wt.createState(d, d / 2, c);
      if (u.radius && (Yi(f, u.center, u.radius, l), Me.hasExtrema(u))) for (var h = 0, m = u.extrema; h < m.length; h++)
        Yi(f, m[h], 1, 0);
      return wt.getMesh(f);
    }(e, r && r.mesh), s = r ? r.renderObject : function(u, c, l, d) {
      var f = Vt.Utils.createValuesSimple(u, { alpha: 0.1, doubleSided: !1 }, c, 1, d);
      return eh("mesh", f, { disposed: !1, visible: !0, alphaFactor: 1, pickable: !1, colorOnly: !1, opaque: !1, writeDepth: !1 }, l);
    }(o, n, i, a);
    return r ? G.updateIfChanged(s.values.drawCount, Ia.getDrawCount(o)) : t.add(s), { boundingSphere: Me.clone(e), renderObject: s, mesh: o };
  }
}
var cie = Nl(), lie = Nl(), die = Nl(), fie = Nl(), Gb = E(), zb = E(), IT = E(), FO = { maxFps: z.Numeric(30, { min: 10, max: 60, step: 10 }), preferAtomPixelPadding: z.Numeric(3, { min: 0, max: 20, step: 1 }, { description: "Number of extra pixels at which to prefer atoms over bonds." }) }, pie = function() {
  function t(e, r, n, i, a) {
    var o = this;
    a === void 0 && (a = {}), this.canvasIdentify = e, this.lociGetter = r, this.input = n, this.camera = i, this.ev = wo.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 = sr.Loci.Empty, this.prevT = 0, this.inside = !1, this.buttons = x0.create(0), this.button = x0.create(0), this.modifiers = yp.None, this.props = O(O({}, z.getDefaultValues(FO)), a), n.drag.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.buttons, d = s.button, f = s.modifiers;
      o.isInteracting = !0, o.drag(u, c, l, d, f);
    }), n.move.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.inside, d = s.buttons, f = s.button, h = s.modifiers;
      l && !o.isInteracting && o.move(u, c, d, f, h);
    }), n.leave.subscribe(function() {
      o.leave();
    }), n.click.subscribe(function(s) {
      var u = s.x, c = s.y, l = s.buttons, d = s.button, f = s.modifiers;
      o.outsideViewport(u, c) || o.click(u, c, l, d, f);
    }), n.interactionEnd.subscribe(function() {
      o.isInteracting = !1;
    }), n.modifiers.subscribe(function(s) {
      o.modify(s);
    });
  }
  return t.prototype.setProps = function(e) {
    Object.assign(this.props, e);
  }, t.prototype.identify = function(e, r) {
    var n = this.startX !== this.endX || this.startY !== this.endY;
    if (e !== 2) {
      if (n) {
        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 (e === 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: ze.create(this.endX, this.endY), position: this.position }), void (this.prevLoci = a);
      }
      if (this.inside && this.currentIdentifyT === r && n && !this.outsideViewport(this.endX, this.endY)) {
        var o = this.getLoci(this.id, this.position);
        this.events.hover.next({ current: o, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: ze.create(this.endX, this.endY), position: this.position }), this.prevLoci = o;
      }
    } else n && !this.outsideViewport(this.startX, this.startY) && (this.events.drag.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, pageStart: ze.create(this.startX, this.startY), pageEnd: ze.create(this.endX, this.endY) }), this.startX = this.endX, this.startY = this.endY);
  }, t.prototype.tick = function(e) {
    this.inside && e - this.prevT > 1e3 / this.props.maxFps && (this.prevT = e, this.currentIdentifyT = e, this.identify(this.isInteracting ? 2 : 0, e));
  }, t.prototype.leave = function() {
    this.inside = !1, sr.Loci.isEmpty(this.prevLoci) || (this.prevLoci = sr.Loci.Empty, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers }));
  }, t.prototype.move = function(e, r, n, i, a) {
    this.inside = !0, this.buttons = n, this.button = i, this.modifiers = a, this.endX = e, this.endY = r;
  }, t.prototype.click = function(e, r, n, i, a) {
    this.endX = e, this.endY = r, this.buttons = n, this.button = i, this.modifiers = a, this.identify(1, 0);
  }, t.prototype.drag = function(e, r, n, i, a) {
    this.endX = e, this.endY = r, this.buttons = n, this.button = i, this.modifiers = a, this.identify(2, 0);
  }, t.prototype.modify = function(e) {
    yp.areEqual(e, this.modifiers) || (this.modifiers = e, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: ze.create(this.endX, this.endY), position: this.position }));
  }, t.prototype.outsideViewport = function(e, r) {
    var n = this.input, i = this.camera.viewport;
    return e *= n.pixelRatio, r *= n.pixelRatio, e > i.x + i.width || n.height - r > i.y + i.height || e < i.x || n.height - r < i.y;
  }, t.prototype.getLoci = function(e, r) {
    var n, i = this.lociGetter(e), a = i.repr, o = i.loci;
    if (r && a && Dt.isLoci(o) && o.bonds.length === 2) {
      var s = o.bonds[0], u = s.aUnit, c = s.aIndex;
      u.conformation.position(u.elements[c], Gb), E.sub(IT, this.camera.state.position, this.camera.state.target), E.projectPointOnPlane(zb, r, IT, Gb);
      var l = this.camera.getPixelSize(zb), d = a.theme.size.size(o.bonds[0]) * ((n = a.props.sizeFactor) !== null && n !== void 0 ? n : 1);
      if (a.props.lineSizeAttenuation === !1 && (d *= l / 2), d += this.props.preferAtomPixelPadding * l, E.distance(zb, Gb) < d) return { repr: a, loci: Dt.toFirstStructureElementLoci(o) };
    }
    return { repr: a, loci: o };
  }, t.prototype.dispose = function() {
    this.ev.dispose();
  }, t;
}(), hie = { edgeThresholdMin: z.Numeric(0.0312, { min: 0.0312, max: 0.0833, step: 1e-4 }, { description: "Trims the algorithm from processing darks." }), edgeThresholdMax: z.Numeric(0.063, { min: 0.063, max: 0.333, step: 1e-3 }, { description: "The minimum amount of local contrast required to apply algorithm." }), iterations: z.Numeric(12, { min: 0, max: 16, step: 1 }, { description: "Number of edge exploration steps." }), subpixelQuality: z.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "Choose the amount of sub-pixel aliasing removal." }) }, mie = function() {
  function t(e, r) {
    var n, i, a, o, s, u;
    this.webgl = e, this.renderable = (n = e, a = (i = r).getWidth(), o = i.getHeight(), s = O(O({}, ua), { tColor: G.create(i), uTexSizeInv: G.create(ze.create(1 / a, 1 / o)), dEdgeThresholdMin: G.create(0.0312), dEdgeThresholdMax: G.create(0.125), dIterations: G.create(12), dSubpixelQuality: G.create(0.3) }), u = O({}, gie), Qi(Zi(n, "triangles", vie, u, s), s));
  }
  return t.prototype.updateState = function(e) {
    var r = this.webgl, n = r.gl, i = r.state;
    i.enable(n.SCISSOR_TEST), i.disable(n.BLEND), i.disable(n.DEPTH_TEST), i.depthMask(!1);
    var a = e.x, o = e.y, s = e.width, u = e.height;
    n.viewport(a, o, s, u), n.scissor(a, o, s, u), i.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT);
  }, t.prototype.setSize = function(e, r) {
    G.update(this.renderable.values.uTexSizeInv, ze.set(this.renderable.values.uTexSizeInv.ref.value, 1 / e, 1 / r));
  }, t.prototype.update = function(e, r) {
    var n = this.renderable.values, i = r.edgeThresholdMin, a = r.edgeThresholdMax, o = r.iterations, s = r.subpixelQuality, u = !1;
    n.tColor.ref.value !== e && (G.update(this.renderable.values.tColor, e), u = !0), n.dEdgeThresholdMin.ref.value !== i && (u = !0), G.updateIfChanged(n.dEdgeThresholdMin, i), n.dEdgeThresholdMax.ref.value !== a && (u = !0), G.updateIfChanged(n.dEdgeThresholdMax, a), n.dIterations.ref.value !== o && (u = !0), G.updateIfChanged(n.dIterations, o), n.dSubpixelQuality.ref.value !== s && (u = !0), G.updateIfChanged(n.dSubpixelQuality, s), u && this.renderable.update();
  }, t.prototype.render = function(e, r) {
    r ? r.bind() : this.webgl.unbindFramebuffer(), this.updateState(e), this.renderable.render();
  }, t;
}(), gie = O(O({}, la), { tColor: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), dEdgeThresholdMin: Gt("number"), dEdgeThresholdMax: Gt("number"), dIterations: Gt("number"), dSubpixelQuality: Gt("number") }), vie = Nn("fxaa", eo, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

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

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

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

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

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

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

    vec4 colorCenter = texture2D(tColor, coords);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

attribute vec2 aPosition;
uniform vec2 uQuadScale;

uniform vec2 uTexSizeInv;
uniform vec4 uViewport;

varying vec2 vUv;
varying vec4 vOffset[3];

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

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

uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

varying vec2 vUv;
varying vec4 vOffset[3];

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

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

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

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

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

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

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

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

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

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

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

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

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

    return vec4(edges, 0.0, 0.0);
}

void main() {
    gl_FragColor = SMAAColorEdgeDetectionPS(vUv, vOffset, tColor);
}
`), Sie = O(O({}, la), { tEdges: zt("texture", "rgba", "ubyte", "linear"), tArea: zt("texture", "rgb", "ubyte", "linear"), tSearch: zt("texture", "rgba", "ubyte", "nearest"), uTexSizeInv: Ie("v2"), uViewport: Ie("v4"), dMaxSearchSteps: Gt("number") }), Cie = Nn("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));
}
`), Aie = O(O({}, la), { tColor: zt("texture", "rgba", "ubyte", "linear"), tWeights: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), uViewport: Ie("v4") }), wie = Nn("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);
}
`), Die = O(O({}, la), { tDepth: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2"), dOrthographic: Gt("number"), uNear: Ie("f"), uFar: Ie("f"), uMaxPossibleViewZDiff: Ie("f") }), Eie = O(O({}, la), { tDepth: zt("texture", "rgba", "ubyte", "nearest"), uSamples: Ie("v3[]"), dNSamples: Gt("number"), uProjection: Ie("m4"), uInvProjection: Ie("m4"), uBounds: Ie("v4"), uTexSize: Ie("v2"), uRadius: Ie("f"), uBias: Ie("f") }), Iie = O(O({}, la), { tSsaoDepth: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2"), uKernel: Ie("f[]"), dOcclusionKernelSize: Gt("number"), uBlurDirectionX: Ie("f"), uBlurDirectionY: Ie("f"), uMaxPossibleViewZDiff: Ie("f"), uNear: Ie("f"), uFar: Ie("f"), uBounds: Ie("v4"), dOrthographic: Gt("number") });
function TT(t, e, r) {
  var n = O(O({}, ua), { tSsaoDepth: G.create(e), uTexSize: G.create(ze.create(e.getWidth(), e.getHeight())), uKernel: G.create([0]), dOcclusionKernelSize: G.create(15), uBlurDirectionX: G.create(r === "horizontal" ? 1 : 0), uBlurDirectionY: G.create(r === "vertical" ? 1 : 0), uMaxPossibleViewZDiff: G.create(0.5), uNear: G.create(0), uFar: G.create(1e4), uBounds: G.create(Ut()), dOrthographic: G.create(0) }), i = O({}, Iie);
  return Qi(Zi(t, "triangles", Nn("ssao_blur", eo, `
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, n), n);
}
var Tie = O(O({}, la), { tSsaoDepth: zt("texture", "rgba", "ubyte", "nearest"), tColor: zt("texture", "rgba", "ubyte", "nearest"), tDepth: zt("texture", "rgba", "ubyte", "nearest"), tOutlines: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2"), dOrthographic: Gt("number"), uNear: Ie("f"), uFar: Ie("f"), uFogNear: Ie("f"), uFogFar: Ie("f"), uFogColor: Ie("v3"), uOutlineColor: Ie("v3"), uTransparentBackground: Ie("b"), uMaxPossibleViewZDiff: Ie("f"), dOcclusionEnable: Gt("boolean"), uOcclusionOffset: Ie("v2"), dOutlineEnable: Gt("boolean"), dOutlineScale: Gt("number"), uOutlineThreshold: Ie("f") }), NO = { occlusion: z.MappedStatic("on", { on: z.Group({ samples: z.Numeric(32, { min: 1, max: 256, step: 1 }), radius: z.Numeric(5, { min: 0, max: 10, step: 0.1 }, { description: "Final occlusion radius is 2^x" }), bias: z.Numeric(0.8, { min: 0, max: 3, step: 0.1 }), blurKernelSize: z.Numeric(15, { min: 1, max: 25, step: 2 }), resolutionScale: z.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: "Adjust resolution of occlusion calculation" }) }), off: z.Group({}) }, { cycle: !0, description: "Darken occluded crevices with the ambient occlusion effect" }), outline: z.MappedStatic("off", { on: z.Group({ scale: z.Numeric(1, { min: 1, max: 5, step: 1 }), threshold: z.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }), color: z.Color(qe(0)) }), off: z.Group({}) }, { cycle: !0, description: "Draw outline around 3D objects" }), antialiasing: z.MappedStatic("smaa", { fxaa: z.Group(hie), smaa: z.Group(yie), off: z.Group({}) }, { options: [["fxaa", "FXAA"], ["smaa", "SMAA"], ["off", "Off"]], description: "Smooth pixel edges" }) }, sl = function() {
  function t(e, r) {
    this.webgl = e, this.drawPass = r, this.occlusionOffset = [0, 0];
    var n = r.colorTarget, i = r.depthTexture, a = n.getWidth(), o = n.getHeight();
    this.nSamples = 1, this.blurKernelSize = 1, this.downsampleFactor = 1, this.ssaoScale = this.calcSsaoScale(), this.target = e.createRenderTarget(a, o, !1, "uint8", "linear"), this.outlinesTarget = e.createRenderTarget(a, o, !1), this.outlinesRenderable = function(d, f) {
      var h = O(O({}, ua), { tDepth: G.create(f), uTexSize: G.create(ze.create(f.getWidth(), f.getHeight())), dOrthographic: G.create(0), uNear: G.create(1), uFar: G.create(1e4), uMaxPossibleViewZDiff: G.create(0.5) }), m = O({}, Die);
      return Qi(Zi(d, "triangles", Nn("outlines", eo, `
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);
}
`), m, h), h);
    }(e, i), this.randomHemisphereVector = [];
    for (var s = 0; s < 256; s++) {
      var u = E();
      u[0] = 2 * Math.random() - 1, u[1] = 2 * Math.random() - 1, u[2] = Math.random(), E.normalize(u, u), E.scale(u, u, Math.random()), this.randomHemisphereVector.push(u);
    }
    this.ssaoFramebuffer = e.resources.framebuffer(), this.ssaoBlurFirstPassFramebuffer = e.resources.framebuffer(), this.ssaoBlurSecondPassFramebuffer = e.resources.framebuffer();
    var c = Math.floor(a * this.ssaoScale), l = Math.floor(o * this.ssaoScale);
    this.downsampledDepthTarget = e.createRenderTarget(c, l, !1, "uint8", "linear"), this.downsampleDepthRenderable = t7(e, i), this.ssaoDepthTexture = e.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthTexture.define(c, l), this.ssaoDepthTexture.attachFramebuffer(this.ssaoFramebuffer, "color0"), this.ssaoDepthBlurProxyTexture = e.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthBlurProxyTexture.define(c, l), this.ssaoDepthBlurProxyTexture.attachFramebuffer(this.ssaoBlurFirstPassFramebuffer, "color0"), this.ssaoDepthTexture.attachFramebuffer(this.ssaoBlurSecondPassFramebuffer, "color0"), this.ssaoRenderable = function(d, f) {
      var h = O(O({}, ua), { tDepth: G.create(f), uSamples: G.create([0, 0, 1]), dNSamples: G.create(32), uProjection: G.create(he.identity()), uInvProjection: G.create(he.identity()), uBounds: G.create(Ut()), uTexSize: G.create(ze.create(d.gl.drawingBufferWidth, d.gl.drawingBufferHeight)), uRadius: G.create(8), uBias: G.create(0.025) }), m = O({}, Eie);
      return Qi(Zi(d, "triangles", Nn("ssao", eo, `
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);
}
`), m, h), h);
    }(e, this.downsampleFactor === 1 ? i : this.downsampledDepthTarget.texture), this.ssaoBlurFirstPassRenderable = TT(e, this.ssaoDepthTexture, "horizontal"), this.ssaoBlurSecondPassRenderable = TT(e, this.ssaoDepthBlurProxyTexture, "vertical"), this.renderable = function(d, f, h, m, p) {
      var v = O(O({}, ua), { tSsaoDepth: G.create(p), tColor: G.create(f), tDepth: G.create(h), tOutlines: G.create(m), uTexSize: G.create(ze.create(f.getWidth(), f.getHeight())), dOrthographic: G.create(0), uNear: G.create(1), uFar: G.create(1e4), uFogNear: G.create(1e4), uFogFar: G.create(1e4), uFogColor: G.create(E.create(1, 1, 1)), uOutlineColor: G.create(E.create(0, 0, 0)), uTransparentBackground: G.create(!1), uMaxPossibleViewZDiff: G.create(0.5), dOcclusionEnable: G.create(!0), uOcclusionOffset: G.create(ze.create(0, 0)), dOutlineEnable: G.create(!1), dOutlineScale: G.create(1), uOutlineThreshold: G.create(0.33) }), g = O({}, Tie);
      return Qi(Zi(d, "triangles", Nn("postprocessing", eo, `
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;
}
`), g, v), v);
    }(e, n.texture, i, this.outlinesTarget.texture, this.ssaoDepthTexture);
  }
  return t.isEnabled = function(e) {
    return e.occlusion.name === "on" || e.outline.name === "on";
  }, t.prototype.calcSsaoScale = function() {
    return Math.min(1, 1 / this.webgl.pixelRatio) * this.downsampleFactor;
  }, t.prototype.setSize = function(e, r) {
    var n = this.renderable.values.uTexSize.ref.value, i = n[0], a = n[1], o = this.calcSsaoScale();
    if (e !== i || r !== a || this.ssaoScale !== o) {
      this.ssaoScale = o;
      var s = Math.floor(e * this.ssaoScale), u = Math.floor(r * this.ssaoScale);
      this.target.setSize(e, r), this.outlinesTarget.setSize(e, r), this.downsampledDepthTarget.setSize(s, u), this.ssaoDepthTexture.define(s, u), this.ssaoDepthBlurProxyTexture.define(s, u), G.update(this.renderable.values.uTexSize, ze.set(this.renderable.values.uTexSize.ref.value, e, r)), G.update(this.outlinesRenderable.values.uTexSize, ze.set(this.outlinesRenderable.values.uTexSize.ref.value, e, r)), G.update(this.downsampleDepthRenderable.values.uTexSize, ze.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, s, u)), G.update(this.ssaoRenderable.values.uTexSize, ze.set(this.ssaoRenderable.values.uTexSize.ref.value, s, u)), G.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, ze.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, s, u)), G.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, ze.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, s, u));
    }
  }, t.prototype.updateState = function(e, r, n, i) {
    var a = !1, o = !1, s = !1, u = e.state.mode === "orthographic" ? 1 : 0, c = i.outline.name === "on", l = i.occlusion.name === "on", d = he.identity();
    if (he.invert(d, e.projection), i.occlusion.name === "on") {
      G.update(this.ssaoRenderable.values.uProjection, e.projection), G.update(this.ssaoRenderable.values.uInvProjection, d);
      var f = this.renderable.values.uTexSize.ref.value, h = f[0], m = f[1], p = this.ssaoRenderable.values.uBounds, v = e.viewport, g = this.ssaoScale;
      if (Ut.set(p.ref.value, Math.floor(v.x * g) / (h * g), Math.floor(v.y * g) / (m * g), Math.ceil((v.x + v.width) * g) / (h * g), Math.ceil((v.y + v.height) * g) / (m * g)), G.update(p, p.ref.value), G.update(this.ssaoBlurFirstPassRenderable.values.uBounds, p.ref.value), G.update(this.ssaoBlurSecondPassRenderable.values.uBounds, p.ref.value), G.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uNear, e.near), G.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uNear, e.near), G.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uFar, e.far), G.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uFar, e.far), this.ssaoBlurFirstPassRenderable.values.dOrthographic.ref.value !== u && (s = !0), G.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOrthographic, u), G.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOrthographic, u), this.nSamples !== i.occlusion.params.samples && (o = !0, this.nSamples = i.occlusion.params.samples, G.update(this.ssaoRenderable.values.uSamples, function(R, L) {
        for (var V = [], U = 0; U < L; U++) {
          var H = (U * U + 2 * U + 1) / (L * L);
          H = 0.1 + 0.9 * H, V.push(R[U][0] * H), V.push(R[U][1] * H), V.push(R[U][2] * H);
        }
        return V;
      }(this.randomHemisphereVector, this.nSamples)), G.updateIfChanged(this.ssaoRenderable.values.dNSamples, this.nSamples)), G.updateIfChanged(this.ssaoRenderable.values.uRadius, Math.pow(2, i.occlusion.params.radius)), G.updateIfChanged(this.ssaoRenderable.values.uBias, i.occlusion.params.bias), this.blurKernelSize !== i.occlusion.params.blurKernelSize) {
        s = !0, this.blurKernelSize = i.occlusion.params.blurKernelSize;
        var y = function(R) {
          for (var L = R / 3, V = Math.floor((R + 1) / 2), U = [], H = 0; H < V; H++) U.push(1 / (Math.sqrt(2 * Math.PI) * L) * Math.exp(-H * H / (2 * L * L)));
          return U;
        }(this.blurKernelSize);
        G.update(this.ssaoBlurFirstPassRenderable.values.uKernel, y), G.update(this.ssaoBlurSecondPassRenderable.values.uKernel, y), G.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize), G.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 b = Math.floor(h * this.ssaoScale), S = Math.floor(m * this.ssaoScale);
        this.downsampledDepthTarget.setSize(b, S), this.ssaoDepthTexture.define(b, S), this.ssaoDepthBlurProxyTexture.define(b, S), this.ssaoScale === 1 ? G.update(this.ssaoRenderable.values.tDepth, this.drawPass.depthTexture) : G.update(this.ssaoRenderable.values.tDepth, this.downsampledDepthTarget.texture), G.update(this.downsampleDepthRenderable.values.uTexSize, ze.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, b, S)), G.update(this.ssaoRenderable.values.uTexSize, ze.set(this.ssaoRenderable.values.uTexSize.ref.value, b, S)), G.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, ze.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, b, S)), G.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, ze.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, b, S));
      }
    }
    if (i.outline.name === "on") {
      var _ = i.outline.params.threshold;
      e.state.mode === "orthographic" && (_ /= 5);
      var x = Math.pow(1e3, _) / 1e3 * e.state.radiusMax, C = i.outline.params.scale - 1;
      G.updateIfChanged(this.outlinesRenderable.values.uNear, e.near), G.updateIfChanged(this.outlinesRenderable.values.uFar, e.far), G.updateIfChanged(this.outlinesRenderable.values.uMaxPossibleViewZDiff, x), G.update(this.renderable.values.uOutlineColor, qe.toVec3Normalized(this.renderable.values.uOutlineColor.ref.value, i.outline.params.color)), G.updateIfChanged(this.renderable.values.uMaxPossibleViewZDiff, x), this.renderable.values.dOutlineScale.ref.value !== C && (a = !0), G.updateIfChanged(this.renderable.values.dOutlineScale, C);
    }
    G.updateIfChanged(this.renderable.values.uFar, e.far), G.updateIfChanged(this.renderable.values.uNear, e.near), G.updateIfChanged(this.renderable.values.uFogFar, e.fogFar), G.updateIfChanged(this.renderable.values.uFogNear, e.fogNear), G.update(this.renderable.values.uFogColor, qe.toVec3Normalized(this.renderable.values.uFogColor.ref.value, n)), G.updateIfChanged(this.renderable.values.uTransparentBackground, r), this.renderable.values.dOrthographic.ref.value !== u && (a = !0), G.updateIfChanged(this.renderable.values.dOrthographic, u), this.renderable.values.dOutlineEnable.ref.value !== c && (a = !0), G.updateIfChanged(this.renderable.values.dOutlineEnable, c), this.renderable.values.dOcclusionEnable.ref.value !== l && (a = !0), G.updateIfChanged(this.renderable.values.dOcclusionEnable, l), o && this.ssaoRenderable.update(), s && (this.ssaoBlurFirstPassRenderable.update(), this.ssaoBlurSecondPassRenderable.update()), a && this.renderable.update();
    var A = this.webgl, w = A.gl, I = A.state;
    I.enable(w.SCISSOR_TEST), I.disable(w.BLEND), I.disable(w.DEPTH_TEST), I.depthMask(!1);
    var P = e.viewport, M = P.x, T = P.y, F = P.width, N = P.height;
    w.viewport(M, T, F, N), w.scissor(M, T, F, N);
  }, t.prototype.setOcclusionOffset = function(e, r) {
    this.occlusionOffset[0] = e, this.occlusionOffset[1] = r, G.update(this.renderable.values.uOcclusionOffset, ze.set(this.renderable.values.uOcclusionOffset.ref.value, e, r));
  }, t.prototype.render = function(e, r, n, i, a) {
    this.updateState(e, n, 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()), r ? this.webgl.unbindFramebuffer() : this.target.bind();
    var o = this.webgl, s = o.gl;
    o.state.clearColor(0, 0, 0, 1), s.clear(s.COLOR_BUFFER_BIT), this.renderable.render();
  }, t;
}(), Vb = function() {
  function t(e, r) {
    this.drawPass = r;
    var n = r.colorTarget, i = n.getWidth(), a = n.getHeight();
    this.target = e.createRenderTarget(i, a, !1), this.fxaa = new mie(e, this.target.texture), this.smaa = new bie(e, this.target.texture);
  }
  return t.isEnabled = function(e) {
    return e.antialiasing.name !== "off";
  }, t.prototype.setSize = function(e, r) {
    var n = this.target.texture.getWidth(), i = this.target.texture.getHeight();
    e === n && r === i || (this.target.setSize(e, r), this.fxaa.setSize(e, r), this.smaa.supported && this.smaa.setSize(e, r));
  }, t.prototype._renderFxaa = function(e, r, n) {
    if (n.antialiasing.name === "fxaa") {
      var i = sl.isEnabled(n) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
      this.fxaa.update(i, n.antialiasing.params), this.fxaa.render(e.viewport, r ? void 0 : this.target);
    }
  }, t.prototype._renderSmaa = function(e, r, n) {
    if (n.antialiasing.name === "smaa") {
      var i = sl.isEnabled(n) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
      this.smaa.update(i, n.antialiasing.params), this.smaa.render(e.viewport, r ? void 0 : this.target);
    }
  }, t.prototype.render = function(e, r, n) {
    if (n.antialiasing.name !== "off") {
      if (n.antialiasing.name === "fxaa") this._renderFxaa(e, r, n);
      else if (n.antialiasing.name === "smaa") {
        if (!this.smaa.supported) throw new Error('SMAA not supported, missing "HTMLImageElement"');
        this._renderSmaa(e, r, n);
      }
    }
  }, t;
}(), Mie = O(O({}, la), { tColor: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2"), uWeight: Ie("f") }), Pie = Nn("compose", eo, `
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;
}
`), RO = { mode: z.Select("temporal", [["off", "Off"], ["on", "On"], ["temporal", "Temporal"]]), sampleLevel: z.Numeric(2, { min: 0, max: 5, step: 1 }, { description: "Take level^2 samples." }) }, Z3 = function() {
  function t(e, r) {
    this.webgl = e, this.drawPass = r;
    var n = e.extensions, i = n.colorBufferFloat, a = n.textureFloat, o = n.colorBufferHalfFloat, s = n.textureHalfFloat, u = r.colorTarget.getWidth(), c = r.colorTarget.getHeight();
    this.colorTarget = e.createRenderTarget(u, c, !1);
    var l, d, f, h, m = o && s ? "fp16" : i && a ? "float32" : "uint8";
    this.composeTarget = e.createRenderTarget(u, c, !1, m), this.holdTarget = e.createRenderTarget(u, c, !1), this.compose = (l = e, d = r.colorTarget.texture, f = O(O({}, ua), { tColor: G.create(d), uTexSize: G.create(ze.create(d.getWidth(), d.getHeight())), uWeight: G.create(1) }), h = O({}, Mie), Qi(Zi(l, "triangles", Pie, h, f), f));
  }
  return t.isEnabled = function(e) {
    return e.mode !== "off";
  }, t.prototype.syncSize = function() {
    var e = this.drawPass.colorTarget.getWidth(), r = this.drawPass.colorTarget.getHeight(), n = this.compose.values.uTexSize.ref.value, i = n[0], a = n[1];
    e === i && r === a || (this.colorTarget.setSize(e, r), this.composeTarget.setSize(e, r), this.holdTarget.setSize(e, r), G.update(this.compose.values.uTexSize, ze.set(this.compose.values.uTexSize.ref.value, e, r)));
  }, t.prototype.render = function(e, r, n, i, a) {
    return n.multiSample.mode !== "temporal" || a ? (this.renderMultiSample(r, i, n), -2) : this.renderTemporalMultiSample(e, r, n, i);
  }, t.prototype.bindOutputTarget = function(e) {
    e ? this.webgl.unbindFramebuffer() : this.colorTarget.bind();
  }, t.prototype.renderMultiSample = function(e, r, n) {
    var i = e.camera, a = this, o = a.compose, s = a.composeTarget, u = a.drawPass, c = a.webgl, l = c.gl, d = c.state, f = y7[Math.max(0, Math.min(n.multiSample.sampleLevel, 5))], h = i.viewport, m = h.x, p = h.y, v = h.width, g = h.height, y = 1 / f.length;
    i.viewOffset.enabled = !0, G.update(o.values.tColor, u.getColorTarget(n.postprocessing).texture), o.update();
    for (var b = 0; b < f.length; ++b) {
      var S = f[b];
      di.setViewOffset(i.viewOffset, v, g, S[0], S[1], v, g), i.update();
      var _ = y + 0.03125 * ((b + 0.5) / f.length - 0.5);
      G.update(o.values.uWeight, _), b === 0 ? u.postprocessing.setOcclusionOffset(0, 0) : u.postprocessing.setOcclusionOffset(S[0] / v, S[1] / g), u.render(e, n, !1), s.bind(), d.enable(l.BLEND), d.blendEquationSeparate(l.FUNC_ADD, l.FUNC_ADD), d.blendFuncSeparate(l.ONE, l.ONE, l.ONE, l.ONE), d.disable(l.DEPTH_TEST), d.depthMask(!1), l.viewport(m, p, v, g), l.scissor(m, p, v, g), b === 0 && (d.clearColor(0, 0, 0, 0), l.clear(l.COLOR_BUFFER_BIT)), o.render();
    }
    u.postprocessing.setOcclusionOffset(0, 0), G.update(o.values.uWeight, 1), G.update(o.values.tColor, s.texture), o.update(), this.bindOutputTarget(r), l.viewport(m, p, v, g), l.scissor(m, p, v, g), d.disable(l.BLEND), o.render(), i.viewOffset.enabled = !1, i.update();
  }, t.prototype.renderTemporalMultiSample = function(e, r, n, i) {
    var a = r.camera, o = this, s = o.compose, u = o.composeTarget, c = o.holdTarget, l = o.drawPass, d = o.webgl, f = d.gl, h = d.state, m = y7[Math.max(0, Math.min(n.multiSample.sampleLevel, 5))];
    if (e === -2 || e >= m.length) return -2;
    var p = a.viewport, v = p.x, g = p.y, y = p.width, b = p.height, S = 1 / m.length;
    if (e === -1) l.render(r, n, !1), G.update(s.values.uWeight, 1), G.update(s.values.tColor, l.getColorTarget(n.postprocessing).texture), s.update(), c.bind(), h.disable(f.BLEND), h.disable(f.DEPTH_TEST), h.depthMask(!1), f.viewport(v, g, y, b), f.scissor(v, g, y, b), s.render(), e += 1;
    else {
      a.viewOffset.enabled = !0, G.update(s.values.tColor, l.getColorTarget(n.postprocessing).texture), G.update(s.values.uWeight, S), s.update();
      for (var _ = Math.pow(2, Math.max(0, n.multiSample.sampleLevel - 2)), x = 0; x < _; ++x) {
        var C = m[e];
        if (di.setViewOffset(a.viewOffset, y, b, C[0], C[1], y, b), a.update(), e === 0 ? l.postprocessing.setOcclusionOffset(0, 0) : l.postprocessing.setOcclusionOffset(C[0] / y, C[1] / b), l.render(r, n, !1), u.bind(), h.enable(f.BLEND), h.blendEquationSeparate(f.FUNC_ADD, f.FUNC_ADD), h.blendFuncSeparate(f.ONE, f.ONE, f.ONE, f.ONE), h.disable(f.DEPTH_TEST), h.depthMask(!1), f.viewport(v, g, y, b), f.scissor(v, g, y, b), e === 0 && (h.clearColor(0, 0, 0, 0), f.clear(f.COLOR_BUFFER_BIT)), s.render(), (e += 1) >= m.length) break;
      }
    }
    l.postprocessing.setOcclusionOffset(0, 0), this.bindOutputTarget(i), f.viewport(v, g, y, b), f.scissor(v, g, y, b);
    var A = e * S;
    return A > 0 && (G.update(s.values.uWeight, 1), G.update(s.values.tColor, u.texture), s.update(), h.disable(f.BLEND), s.render()), A < 1 && (G.update(s.values.uWeight, 1 - A), G.update(s.values.tColor, c.texture), s.update(), A === 0 ? h.disable(f.BLEND) : h.enable(f.BLEND), s.render()), a.viewOffset.enabled = !1, a.update(), e >= m.length ? -2 : e;
  }, t;
}(), y7 = [[[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]]];
y7.forEach(function(t) {
  t.forEach(function(e) {
    e[0] *= 0.0625, e[1] *= 0.0625;
  });
});
var OO = function() {
  function t(e) {
    this.multiSamplePass = e, this.sampleIndex = -2;
  }
  return t.prototype.update = function(e, r) {
    return e && (this.sampleIndex = -1), r.mode === "temporal" && this.sampleIndex !== -2;
  }, t.prototype.render = function(e, r, n, i) {
    return this.sampleIndex = this.multiSamplePass.render(this.sampleIndex, e, r, n, !!i), this.sampleIndex < 0;
  }, t;
}(), LO = { eyeSeparation: z.Numeric(0.064, { min: 0.01, max: 0.5, step: 1e-3 }), focus: z.Numeric(10, { min: 1, max: 100, step: 0.01 }) }, Bie = z.getDefaultValues(LO), Bp = function() {
  function t(e, r) {
    r === void 0 && (r = {}), this.parent = e, this.left = new MT(), this.right = new MT(), this.props = O(O({}, Bie), r);
  }
  return Object.defineProperty(t.prototype, "viewport", { get: function() {
    return this.parent.viewport;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewOffset", { get: function() {
    return this.parent.viewOffset;
  }, enumerable: !1, configurable: !0 }), t.prototype.setProps = function(e) {
    Object.assign(this.props, e);
  }, t.prototype.update = function() {
    this.parent.update(), function(e, r, n, i) {
      sa.copy(n.viewport, e.viewport), he.copy(n.view, e.view), he.copy(n.projection, e.projection), di.copySnapshot(n.state, e.state), di.copyViewOffset(n.viewOffset, e.viewOffset), n.far = e.far, n.near = e.near, n.fogFar = e.fogFar, n.fogNear = e.fogNear, sa.copy(i.viewport, e.viewport), he.copy(i.view, e.view), he.copy(i.projection, e.projection), di.copySnapshot(i.state, e.state), di.copyViewOffset(i.viewOffset, e.viewOffset), i.far = e.far, i.near = e.near, i.fogFar = e.fogFar, i.fogNear = e.fogNear;
      var a = Math.floor(e.viewport.width / 2), o = a / e.viewport.height;
      n.viewport.width = a, i.viewport.x += a, i.viewport.width -= a;
      var s, u, c = r.eyeSeparation / 2, l = c * e.near / r.focus, d = e.near * Math.tan(0.5 * e.state.fov);
      PT[12] = -c, BT[12] = c, s = -d * o + l, u = d * o + l, n.projection[0] = 2 * e.near / (u - s), n.projection[8] = (u + s) / (u - s), he.mul(n.view, n.view, PT), he.mul(n.projectionView, n.projection, n.view), he.invert(n.inverseProjectionView, n.projectionView), s = -d * o - l, u = d * o - l, i.projection[0] = 2 * e.near / (u - s), i.projection[8] = (u + s) / (u - s), he.mul(i.view, i.view, BT), he.mul(i.projectionView, i.projection, i.view), he.invert(i.inverseProjectionView, i.projectionView);
    }(this.parent, this.props, this.left, this.right);
  }, t;
}();
(function(t) {
  t.is = function(e) {
    return "left" in e && "right" in e;
  };
})(Bp || (Bp = {}));
var MT = function() {
  this.viewport = sa.create(0, 0, 0, 0), this.view = he(), this.projection = he(), this.projectionView = he(), this.inverseProjectionView = he(), this.state = di.createDefaultSnapshot(), this.viewOffset = di.ViewOffset(), this.far = 0, this.near = 0, this.fogFar = 0, this.fogNear = 0;
}, PT = he.identity(), BT = he.identity(), Ub = Math.pow(2, 24) - 2, Fie = function() {
  function t(e, r, n) {
    this.webgl = e, this.drawPass = r, this.pickBaseScale = n;
    var i = n / e.pixelRatio;
    this.pickWidth = Math.ceil(r.colorTarget.getWidth() * i), this.pickHeight = Math.ceil(r.colorTarget.getHeight() * i), this.objectPickTarget = e.createRenderTarget(this.pickWidth, this.pickHeight), this.instancePickTarget = e.createRenderTarget(this.pickWidth, this.pickHeight), this.groupPickTarget = e.createRenderTarget(this.pickWidth, this.pickHeight), this.depthPickTarget = e.createRenderTarget(this.pickWidth, this.pickHeight);
  }
  return Object.defineProperty(t.prototype, "drawingBufferHeight", { get: function() {
    return this.drawPass.colorTarget.getHeight();
  }, enumerable: !1, configurable: !0 }), t.prototype.syncSize = function() {
    var e = this.pickBaseScale / this.webgl.pixelRatio, r = Math.ceil(this.drawPass.colorTarget.getWidth() * e), n = Math.ceil(this.drawPass.colorTarget.getHeight() * e);
    r === this.pickWidth && n === this.pickHeight || (this.pickWidth = r, this.pickHeight = n, this.objectPickTarget.setSize(this.pickWidth, this.pickHeight), this.instancePickTarget.setSize(this.pickWidth, this.pickHeight), this.groupPickTarget.setSize(this.pickWidth, this.pickHeight), this.depthPickTarget.setSize(this.pickWidth, this.pickHeight));
  }, t.prototype.renderVariant = function(e, r, n, i, a, o) {
    var s = this.drawPass.depthTexturePrimitives;
    e.clear(!1), e.update(r), e.renderPick(n.primitives, r, a, null, o), e.renderPick(n.volumes, r, a, s, o), e.renderPick(i.handle.scene, r, a, null, o), i.camera.isEnabled && (i.camera.update(r), e.update(i.camera.camera), e.renderPick(i.camera.scene, i.camera.camera, a, null, o));
  }, t.prototype.render = function(e, r, n, i) {
    this.objectPickTarget.bind(), this.renderVariant(e, r, n, i, "pick", 1), this.instancePickTarget.bind(), this.renderVariant(e, r, n, i, "pick", 2), this.groupPickTarget.bind(), this.renderVariant(e, r, n, i, "pick", 3), this.depthPickTarget.bind(), this.renderVariant(e, r, n, i, "depth", 0);
  }, t;
}(), Nie = function() {
  function t(e, r, n, i, a, o, s) {
    s === void 0 && (s = 1), this.webgl = e, this.renderer = r, this.scene = n, this.helper = i, this.pickPass = a, this.pickPadding = s, this.dirty = !0, this.viewport = sa(), this.setViewport(o.x, o.y, o.width, o.height);
  }
  return t.prototype.setupBuffers = function() {
    var e = this.pickWidth * this.pickHeight * 4;
    this.objectBuffer && this.objectBuffer.length === e || (this.objectBuffer = new Uint8Array(e), this.instanceBuffer = new Uint8Array(e), this.groupBuffer = new Uint8Array(e), this.depthBuffer = new Uint8Array(e));
  }, t.prototype.setViewport = function(e, r, n, i) {
    sa.set(this.viewport, e, r, n, i), this.pickScale = this.pickPass.pickBaseScale / this.webgl.pixelRatio, this.pickX = Math.ceil(e * this.pickScale), this.pickY = Math.ceil(r * this.pickScale);
    var a = Math.floor(n * 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], f = 2 * s + 1, h = f / 2, m = [], p = Math.pow(f, 2); p > 0; --p) -h < c && c <= h && -h < l && l <= h && m.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 m;
    }(Math.round(this.pickScale * this.pickPadding));
  }, t.prototype.syncBuffers = function() {
    var e = this, r = e.pickX, n = e.pickY, i = e.pickWidth, a = e.pickHeight;
    this.pickPass.objectPickTarget.bind(), this.webgl.readPixels(r, n, i, a, this.objectBuffer), this.pickPass.instancePickTarget.bind(), this.webgl.readPixels(r, n, i, a, this.instanceBuffer), this.pickPass.groupPickTarget.bind(), this.webgl.readPixels(r, n, i, a, this.groupBuffer), this.pickPass.depthPickTarget.bind(), this.webgl.readPixels(r, n, i, a, this.depthBuffer);
  }, t.prototype.getBufferIdx = function(e, r) {
    return 4 * (r * this.pickWidth + e);
  }, t.prototype.getDepth = function(e, r) {
    var n = this.getBufferIdx(e, r), i = this.depthBuffer;
    return function(a, o, s, u) {
      return Ut.set(KE, a / 255, o / 255, s / 255, u / 255), Ut.dot(KE, rre);
    }(i[n], i[n + 1], i[n + 2], i[n + 3]);
  }, t.prototype.getId = function(e, r, n) {
    var i = this.getBufferIdx(e, r);
    return sx(n[i], n[i + 1], n[i + 2]);
  }, t.prototype.render = function(e) {
    var r = this, n = r.pickX, i = r.pickY, a = r.pickWidth, o = r.pickHeight, s = r.halfPickWidth, u = this, c = u.renderer, l = u.scene, d = u.helper;
    c.setTransparentBackground(!1), c.setDrawingBufferSize(this.pickPass.objectPickTarget.getWidth(), this.pickPass.objectPickTarget.getHeight()), c.setPixelRatio(this.pickScale), Bp.is(e) ? (c.setViewport(n, i, s, o), this.pickPass.render(c, e.left, l, d), c.setViewport(n + s, i, a - s, o), this.pickPass.render(c, e.right, l, d)) : (c.setViewport(n, i, a, o), this.pickPass.render(c, e, l, d)), this.dirty = !1;
  }, t.prototype.identifyInternal = function(e, r, n) {
    var i = this.webgl, a = this.pickScale;
    if (!i.isContextLost) {
      e *= i.pixelRatio, r *= i.pixelRatio, r = this.pickPass.drawingBufferHeight - r;
      var o = this.viewport;
      if (!(e < o.x || r < o.y || e > o.x + o.width || r > o.y + o.height)) {
        this.dirty && (this.render(n), this.syncBuffers());
        var s = e - o.x, u = r - o.y, c = Math.floor(s * a), l = Math.floor(u * a), d = this.getId(c, l, this.objectBuffer);
        if (d !== -1 && d !== Ub) {
          var f = this.getId(c, l, this.instanceBuffer);
          if (f !== -1 && f !== Ub) {
            var h = this.getId(c, l, this.groupBuffer);
            if (h !== -1 && h !== Ub) {
              var m = this.getDepth(c, l), p = E.create(e, o.height - r, m);
              if (Bp.is(n)) {
                var v = Math.floor(o.width / 2);
                e > o.x + v ? (p[0] = o.x + 2 * (s - v), lm(p, p, o, n.right.inverseProjectionView)) : (p[0] = o.x + 2 * s, lm(p, p, o, n.left.inverseProjectionView));
              } else lm(p, p, o, n.inverseProjectionView);
              return { id: { objectId: d, instanceId: f, groupId: h }, position: p };
            }
          }
        }
      }
    }
  }, t.prototype.identify = function(e, r, n) {
    for (var i = 0, a = this.spiral; i < a.length; i++) {
      var o = a[i], s = this.identifyInternal(e + o[0], r + o[1], n);
      if (s) return s;
    }
  }, t.prototype.getPosition = function(e, r, n) {
    var i = this.webgl;
    if (!i.isContextLost) {
      e *= i.pixelRatio, r *= i.pixelRatio, r = this.pickPass.drawingBufferHeight - r;
      var a = this.viewport;
      if (!(e < a.x || r < a.y || e > a.x + a.width || r > a.y + a.height)) {
        this.dirty && (this.render(n), this.syncBuffers());
        var o = 255 / 256, s = E.create(16777216, 65536, 256), u = Ut.create(o / s[0], o / s[1], o / s[2], 0.99609375), c = Ut();
        Ut.set(c, 128 / 255, 128 / 255, 30 / 255, 60 / 255);
        var l = Ut.dot(c, u) / (n.zoom / 40);
        l > 0.2 && (l = 0.1);
        var d = E.create(e, a.height - r, l);
        return lm(d, d, a, n.inverseProjectionView), { position: d };
      }
    }
  }, t;
}(), Rie = O(O({}, la), { tWboitA: zt("texture", "rgba", "float", "nearest"), tWboitB: zt("texture", "rgba", "float", "nearest"), uTexSize: Ie("v2") }), Oie = Nn("evaluate-wboit", eo, `
precision highp float;

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

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

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

    accum.a = texture2D(tWboitB, coords).r;
    // divisor needs to allow very small values for nice fading
    gl_FragColor = vec4(accum.rgb / clamp(accum.a, 0.00000001, 50000.0), r);
}
`), Lie = function() {
  function t(e, r, n) {
    if (this.webgl = e, this._supported = !1, t.isSupported(e)) {
      var i, a, o, s, u, c = e.resources;
      this.textureA = c.texture("image-float32", "rgba", "float", "nearest"), this.textureA.define(r, n), this.textureB = c.texture("image-float32", "rgba", "float", "nearest"), this.textureB.define(r, n), this.renderable = (i = e, a = this.textureA, o = this.textureB, s = O(O({}, ua), { tWboitA: G.create(a), tWboitB: G.create(o), uTexSize: G.create(ze.create(a.getWidth(), a.getHeight())) }), u = O({}, Rie), Qi(Zi(i, "triangles", Oie, u, s), s)), this.framebuffer = c.framebuffer(), this._supported = !0, this._init();
    }
  }
  return Object.defineProperty(t.prototype, "supported", { get: function() {
    return this._supported;
  }, enumerable: !1, configurable: !0 }), t.prototype.bind = function() {
    var e = this.webgl, r = e.state, n = e.gl;
    this.framebuffer.bind(), r.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT), r.disable(n.DEPTH_TEST), r.blendFuncSeparate(n.ONE, n.ONE, n.ZERO, n.ONE_MINUS_SRC_ALPHA), r.enable(n.BLEND);
  }, t.prototype.render = function() {
    var e = this.webgl, r = e.state, n = e.gl;
    r.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA), r.enable(n.BLEND), this.renderable.update(), this.renderable.render();
  }, t.prototype.setSize = function(e, r) {
    var n = this.renderable.values.uTexSize.ref.value, i = n[0], a = n[1];
    e === i && r === a || (this.textureA.define(e, r), this.textureB.define(e, r), G.update(this.renderable.values.uTexSize, ze.set(this.renderable.values.uTexSize.ref.value, e, r)));
  }, t.prototype.reset = function() {
    this._supported && this._init();
  }, t.prototype._init = function() {
    var e = this.webgl.extensions.drawBuffers;
    this.framebuffer.bind(), e.drawBuffers([e.COLOR_ATTACHMENT0, e.COLOR_ATTACHMENT1]), this.textureA.attachFramebuffer(this.framebuffer, "color0"), this.textureB.attachFramebuffer(this.framebuffer, "color1");
  }, t.isSupported = function(e) {
    var r = e.extensions, n = r.drawBuffers, i = r.textureFloat, a = r.colorBufferFloat, o = r.depthTexture;
    if (i && a && o && n) return !0;
    if (Pr) {
      var s = [];
      i || s.push("textureFloat"), a || s.push("colorBufferFloat"), o || s.push("depthTexture"), n || s.push("drawBuffers"), console.log('Missing "'.concat(s.join('", "'), '" extensions required for "wboit"'));
    }
    return !1;
  }, t;
}(), kO = { enabled: z.Boolean(!0), highlightEdgeColor: z.Color(qe.darken(qe.fromNormalizedRgb(1, 0.4, 0.6), 1)), selectEdgeColor: z.Color(qe.darken(qe.fromNormalizedRgb(0.2, 1, 0.1), 1)), edgeScale: z.Numeric(1, { min: 1, max: 3, step: 1 }, { description: "Thickness of the edge." }), ghostEdgeStrength: z.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: z.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Factor to multiply the inner edge color with - for added contrast." }) }, FT = function() {
  function t(e, r, n) {
    this.webgl = e, this.depthTarget = e.createRenderTarget(r, n), this.maskTarget = e.createRenderTarget(r, n), this.edgesTarget = e.createRenderTarget(r, n), this.edge = function(i, a) {
      var o = a.getWidth(), s = a.getHeight(), u = O(O({}, ua), { tMaskTexture: G.create(a), uTexSizeInv: G.create(ze.create(1 / o, 1 / s)), dEdgeScale: G.create(1) }), c = O({}, kie);
      return Qi(Zi(i, "triangles", Gie, c, u), u);
    }(e, this.maskTarget.texture), this.overlay = function(i, a) {
      var o = a.getWidth(), s = a.getHeight(), u = O(O({}, ua), { tEdgeTexture: G.create(a), uTexSizeInv: G.create(ze.create(1 / o, 1 / s)), uHighlightEdgeColor: G.create(E()), uSelectEdgeColor: G.create(E()), uGhostEdgeStrength: G.create(0), uInnerEdgeFactor: G.create(0) }), c = O({}, zie);
      return Qi(Zi(i, "triangles", Vie, c, u), u);
    }(e, this.edgesTarget.texture);
  }
  return t.isEnabled = function(e) {
    return e.enabled;
  }, t.prototype.setEdgeState = function(e) {
    var r = this.webgl, n = r.gl, i = r.state;
    i.enable(n.SCISSOR_TEST), i.enable(n.BLEND), i.blendFunc(n.ONE, n.ONE), i.blendEquation(n.FUNC_ADD), i.disable(n.DEPTH_TEST), i.depthMask(!1);
    var a = e.x, o = e.y, s = e.width, u = e.height;
    n.viewport(a, o, s, u), n.scissor(a, o, s, u), i.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT);
  }, t.prototype.setOverlayState = function(e) {
    var r = this.webgl, n = r.gl, i = r.state;
    i.enable(n.SCISSOR_TEST), i.enable(n.BLEND), i.blendFunc(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA), i.blendEquation(n.FUNC_ADD), i.disable(n.DEPTH_TEST), i.depthMask(!1);
    var a = e.x, o = e.y, s = e.width, u = e.height;
    n.viewport(a, o, s, u), n.scissor(a, o, s, u);
  }, t.prototype.setSize = function(e, r) {
    var n = this.depthTarget.getWidth(), i = this.depthTarget.getHeight();
    e === n && r === i || (this.depthTarget.setSize(e, r), this.maskTarget.setSize(e, r), this.edgesTarget.setSize(e, r), G.update(this.edge.values.uTexSizeInv, ze.set(this.edge.values.uTexSizeInv.ref.value, 1 / e, 1 / r)), G.update(this.overlay.values.uTexSizeInv, ze.set(this.overlay.values.uTexSizeInv.ref.value, 1 / e, 1 / r)));
  }, t.prototype.update = function(e) {
    var r = e.highlightEdgeColor, n = e.selectEdgeColor, i = e.edgeScale, a = e.innerEdgeFactor, o = e.ghostEdgeStrength, s = this.edge.values, u = Math.round(i * this.webgl.pixelRatio);
    s.dEdgeScale.ref.value !== u && (G.update(s.dEdgeScale, u), this.edge.update());
    var c = this.overlay.values;
    G.update(c.uHighlightEdgeColor, qe.toVec3Normalized(c.uHighlightEdgeColor.ref.value, r)), G.update(c.uSelectEdgeColor, qe.toVec3Normalized(c.uSelectEdgeColor.ref.value, n)), G.update(c.uInnerEdgeFactor, a), G.update(c.uGhostEdgeStrength, o);
  }, t.prototype.render = function(e, r) {
    this.edgesTarget.bind(), this.setEdgeState(e), this.edge.render(), r ? r.bind() : this.webgl.unbindFramebuffer(), this.setOverlayState(e), this.overlay.render();
  }, t;
}(), kie = O(O({}, la), { tMaskTexture: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), dEdgeScale: Gt("number") }), Gie = Nn("edge", eo, `
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);
}
`), zie = O(O({}, la), { tEdgeTexture: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), uHighlightEdgeColor: Ie("v3"), uSelectEdgeColor: Ie("v3"), uGhostEdgeStrength: Ie("f"), uInnerEdgeFactor: Ie("f") }), Vie = Nn("overlay", eo, `
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);
    }
}
`), Uie = O(O({}, la), { tDepthPrimitives: zt("texture", "depth", "ushort", "nearest"), tDepthVolumes: zt("texture", "depth", "ushort", "nearest"), uTexSize: Ie("v2"), dPackedDepth: Gt("boolean") }), Hie = Nn("depth-merge", eo, `
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);
}
`), GO = function() {
  function t(e, r, n, i) {
    this.webgl = e;
    var a, o, s, u, c, l, d, f = e.extensions, h = e.resources, m = e.isWebGL2;
    this.drawTarget = (a = e.gl, { id: VN(), texture: zo(a), framebuffer: { id: GN(), 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 = e.createRenderTarget(r, n, !0, "uint8", "linear"), this.packedDepth = !f.depthTexture, this.depthTarget = e.createRenderTarget(r, n), this.depthTexture = this.depthTarget.texture, this.depthTargetPrimitives = this.packedDepth ? e.createRenderTarget(r, n) : null, this.depthTargetVolumes = this.packedDepth ? e.createRenderTarget(r, n) : null, this.depthTexturePrimitives = this.depthTargetPrimitives ? this.depthTargetPrimitives.texture : h.texture("image-depth", "depth", m ? "float" : "ushort", "nearest"), this.depthTextureVolumes = this.depthTargetVolumes ? this.depthTargetVolumes.texture : h.texture("image-depth", "depth", m ? "float" : "ushort", "nearest"), this.packedDepth || (this.depthTexturePrimitives.define(r, n), this.depthTextureVolumes.define(r, n)), this.depthMerge = (o = e, s = this.depthTexturePrimitives, u = this.depthTextureVolumes, c = this.packedDepth, l = O(O({}, ua), { tDepthPrimitives: G.create(s), tDepthVolumes: G.create(u), uTexSize: G.create(ze.create(s.getWidth(), s.getHeight())), dPackedDepth: G.create(c) }), d = O({}, Uie), Qi(Zi(o, "triangles", Hie, d, l), l)), this.wboit = i ? new Lie(e, r, n) : void 0, this.marking = new FT(e, r, n), this.postprocessing = new sl(e, this), this.antialiasing = new Vb(e, this), this.copyFboTarget = t7(e, this.colorTarget.texture), this.copyFboPostprocessing = t7(e, this.postprocessing.target.texture);
  }
  return Object.defineProperty(t.prototype, "wboitEnabled", { get: function() {
    var e;
    return !!(!((e = this.wboit) === null || e === void 0) && e.supported);
  }, enumerable: !1, configurable: !0 }), t.prototype.reset = function() {
    var e;
    (e = this.wboit) === null || e === void 0 || e.reset();
  }, t.prototype.setSize = function(e, r) {
    var n, i = this.colorTarget.getWidth(), a = this.colorTarget.getHeight();
    e === i && r === a || (this.colorTarget.setSize(e, r), this.depthTarget.setSize(e, r), this.depthTargetPrimitives ? this.depthTargetPrimitives.setSize(e, r) : this.depthTexturePrimitives.define(e, r), this.depthTargetVolumes ? this.depthTargetVolumes.setSize(e, r) : this.depthTextureVolumes.define(e, r), G.update(this.depthMerge.values.uTexSize, ze.set(this.depthMerge.values.uTexSize.ref.value, e, r)), G.update(this.copyFboTarget.values.uTexSize, ze.set(this.copyFboTarget.values.uTexSize.ref.value, e, r)), G.update(this.copyFboPostprocessing.values.uTexSize, ze.set(this.copyFboPostprocessing.values.uTexSize.ref.value, e, r)), !((n = this.wboit) === null || n === void 0) && n.supported && this.wboit.setSize(e, r), this.marking.setSize(e, r), this.postprocessing.setSize(e, r), this.antialiasing.setSize(e, r));
  }, t.prototype._depthMerge = function() {
    var e = this.webgl, r = e.state, n = e.gl;
    this.depthMerge.update(), this.depthTarget.bind(), r.disable(n.BLEND), r.disable(n.DEPTH_TEST), r.disable(n.CULL_FACE), r.depthMask(!1), r.clearColor(1, 1, 1, 1), n.clear(n.COLOR_BUFFER_BIT), this.depthMerge.render();
  }, t.prototype._renderWboit = function(e, r, n, 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(), e.clear(!0), this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), e.clearDepth(), e.renderWboitOpaque(n.primitives, r, null), this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), e.clearDepth(), e.renderWboitOpaque(n.volumes, r, this.depthTexturePrimitives), this._depthMerge(), sl.isEnabled(a) && this.postprocessing.render(r, !1, i, e.props.backgroundColor, a), this.wboit.bind(), e.renderWboitTransparent(n.primitives, r, this.depthTexture), e.renderWboitTransparent(n.volumes, r, this.depthTexture), sl.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();
  }, t.prototype._renderBlended = function(e, r, n, i, a, o) {
    if (i ? this.drawTarget.bind() : (this.colorTarget.bind(), this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth")), e.clear(!0), e.renderBlendedOpaque(n.primitives, r, null), !i) {
      this.depthTargetPrimitives && (this.depthTargetPrimitives.bind(), e.clear(!1), e.renderDepth(n.primitives, r, null), this.colorTarget.bind()), this.packedDepth || (this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), e.clearDepth()), e.renderBlendedVolumeOpaque(n.volumes, r, this.depthTexturePrimitives), this.depthTargetVolumes && (this.depthTargetVolumes.bind(), e.clear(!1), e.renderDepth(n.volumes, r, this.depthTexturePrimitives), this.colorTarget.bind()), this._depthMerge(), this.colorTarget.bind(), sl.isEnabled(o) && this.postprocessing.render(r, !1, a, e.props.backgroundColor, o), e.renderBlendedVolumeTransparent(n.volumes, r, this.depthTexturePrimitives);
      var s = sl.isEnabled(o) ? this.postprocessing.target : this.colorTarget;
      this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(s.framebuffer, "depth"), s.bind();
    }
    e.renderBlendedTransparent(n.primitives, r, null);
  }, t.prototype._render = function(e, r, n, i, a, o) {
    var s = n.volumes.renderables.length > 0, u = sl.isEnabled(o.postprocessing), c = Vb.isEnabled(o.postprocessing), l = FT.isEnabled(o.marking), d = r.viewport, f = d.x, h = d.y, m = d.width, p = d.height;
    if (e.setViewport(f, h, m, p), e.update(r), o.transparentBackground && !c && a && (this.drawTarget.bind(), e.clear(!1)), this.wboitEnabled ? this._renderWboit(e, r, n, o.transparentBackground, o.postprocessing) : this._renderBlended(e, r, n, !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 v = n.getMarkerAverage();
      if (v > 0) {
        var g = o.marking.ghostEdgeStrength < 1;
        g && v !== 1 && (this.marking.depthTarget.bind(), e.clear(!1, !0), e.renderMarkingDepth(n.primitives, r, null)), this.marking.maskTarget.bind(), e.clear(!1, !0), e.renderMarkingMask(n.primitives, r, g ? this.marking.depthTarget.texture : null), this.marking.update(o.marking), this.marking.render(r.viewport, u ? this.postprocessing.target : this.colorTarget);
      }
    }
    i.debug.isEnabled && (i.debug.syncVisibility(), e.renderBlended(i.debug.scene, r, null)), i.handle.isEnabled && e.renderBlended(i.handle.scene, r, null), i.camera.isEnabled && (i.camera.update(r), e.update(i.camera.camera), e.renderBlended(i.camera.scene, i.camera.camera, null)), c ? this.antialiasing.render(r, 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();
  }, t.prototype.render = function(e, r, n) {
    var i = e.renderer, a = e.camera, o = e.scene, s = e.helper;
    i.setTransparentBackground(r.transparentBackground), i.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight()), i.setPixelRatio(this.webgl.pixelRatio), Bp.is(a) ? (this._render(i, a.left, o, s, n, r), this._render(i, a.right, o, s, n, r)) : this._render(i, a, o, s, n, r);
  }, t.prototype.getColorTarget = function(e) {
    return Vb.isEnabled(e) ? this.antialiasing.target : sl.isEnabled(e) ? this.postprocessing.target : this.colorTarget;
  }, t;
}();
function Mu(t) {
  for (var e = arguments.length, r = Array(e > 1 ? e - 1 : 0), n = 1; n < e; n++) r[n - 1] = arguments[n];
  throw Error("[Immer] minified error nr: " + t + (r.length ? " " + r.map(function(i) {
    return "'" + i + "'";
  }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
}
function Fp(t) {
  return !!t && !!t[_s];
}
function M0(t) {
  return !!t && (function(e) {
    if (!e || typeof e != "object") return !1;
    var r = Object.getPrototypeOf(e);
    if (r === null) return !0;
    var n = Object.hasOwnProperty.call(r, "constructor") && r.constructor;
    return n === Object || typeof n == "function" && Function.toString.call(n) === jie;
  }(t) || Array.isArray(t) || !!t[VT] || !!t.constructor[VT] || vx(t) || yx(t));
}
function $m(t, e, r) {
  r === void 0 && (r = !1), Np(t) === 0 ? (r ? Object.keys : Cx)(t).forEach(function(n) {
    r && typeof n == "symbol" || e(n, t[n], t);
  }) : t.forEach(function(n, i) {
    return e(i, n, t);
  });
}
function Np(t) {
  var e = t[_s];
  return e ? e.i > 3 ? e.i - 4 : e.i : Array.isArray(t) ? 1 : vx(t) ? 2 : yx(t) ? 3 : 0;
}
function b7(t, e) {
  return Np(t) === 2 ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
}
function zO(t, e, r) {
  var n = Np(t);
  n === 2 ? t.set(e, r) : n === 3 ? (t.delete(e), t.add(r)) : t[e] = r;
}
function vx(t) {
  return Yie && t instanceof Map;
}
function yx(t) {
  return Wie && t instanceof Set;
}
function n0(t) {
  return t.o || t.t;
}
function bx(t) {
  if (Array.isArray(t)) return Array.prototype.slice.call(t);
  var e = Zie(t);
  delete e[_s];
  for (var r = Cx(e), n = 0; n < r.length; n++) {
    var i = r[n], a = e[i];
    a.writable === !1 && (a.writable = !0, a.configurable = !0), (a.get || a.set) && (e[i] = { configurable: !0, writable: !0, enumerable: a.enumerable, value: t[i] });
  }
  return Object.create(Object.getPrototypeOf(t), e);
}
function _x(t, e) {
  return e === void 0 && (e = !1), xx(t) || Fp(t) || !M0(t) || (Np(t) > 1 && (t.set = t.add = t.clear = t.delete = qie), Object.freeze(t), e && $m(t, function(r, n) {
    return _x(n, !0);
  }, !0)), t;
}
function qie() {
  Mu(2);
}
function xx(t) {
  return t == null || typeof t != "object" || Object.isFrozen(t);
}
function yc(t) {
  var e = Qie[t];
  return e || Mu(18, t), e;
}
function NT() {
  return e2;
}
function Hb(t, e) {
  e && (yc("Patches"), t.u = [], t.s = [], t.v = e);
}
function Q3(t) {
  _7(t), t.p.forEach(Kie), t.p = null;
}
function _7(t) {
  t === e2 && (e2 = t.l);
}
function RT(t) {
  return e2 = { p: [], l: e2, h: t, m: !0, _: 0 };
}
function Kie(t) {
  var e = t[_s];
  e.i === 0 || e.i === 1 ? e.j() : e.O = !0;
}
function qb(t, e) {
  e._ = e.p.length;
  var r = e.p[0], n = t !== void 0 && t !== r;
  return e.h.g || yc("ES5").S(e, t, n), n ? (r[_s].P && (Q3(e), Mu(4)), M0(t) && (t = J3(e, t), e.l || $3(e, t)), e.u && yc("Patches").M(r[_s].t, t, e.u, e.s)) : t = J3(e, r, []), Q3(e), e.u && e.v(e.u, e.s), t !== VO ? t : void 0;
}
function J3(t, e, r) {
  if (xx(e)) return e;
  var n = e[_s];
  if (!n) return $m(e, function(a, o) {
    return OT(t, n, e, a, o, r);
  }, !0), e;
  if (n.A !== t) return e;
  if (!n.P) return $3(t, n.t, !0), n.t;
  if (!n.I) {
    n.I = !0, n.A._--;
    var i = n.i === 4 || n.i === 5 ? n.o = bx(n.k) : n.o;
    $m(n.i === 3 ? new Set(i) : i, function(a, o) {
      return OT(t, n, i, a, o, r);
    }), $3(t, i, !1), r && t.u && yc("Patches").R(n, r, t.u, t.s);
  }
  return n.o;
}
function OT(t, e, r, n, i, a) {
  if (Fp(i)) {
    var o = J3(t, i, a && e && e.i !== 3 && !b7(e.D, n) ? a.concat(n) : void 0);
    if (zO(r, n, o), !Fp(o)) return;
    t.m = !1;
  }
  if (M0(i) && !xx(i)) {
    if (!t.h.F && t._ < 1) return;
    J3(t, i), e && e.A.l || $3(t, i);
  }
}
function $3(t, e, r) {
  r === void 0 && (r = !1), t.h.F && t.m && _x(e, r);
}
function Kb(t, e) {
  var r = t[_s];
  return (r ? n0(r) : t)[e];
}
function LT(t, e) {
  if (e in t) for (var r = Object.getPrototypeOf(t); r; ) {
    var n = Object.getOwnPropertyDescriptor(r, e);
    if (n) return n;
    r = Object.getPrototypeOf(r);
  }
}
function x7(t) {
  t.P || (t.P = !0, t.l && x7(t.l));
}
function Xb(t) {
  t.o || (t.o = bx(t.t));
}
function S7(t, e, r) {
  var n = vx(e) ? yc("MapSet").N(e, r) : yx(e) ? yc("MapSet").T(e, r) : t.g ? function(i, a) {
    var o = Array.isArray(i), s = { i: o ? 1 : 0, A: a ? a.A : NT(), P: !1, I: !1, D: {}, l: a, t: i, k: null, o: null, j: null, C: !1 }, u = s, c = C7;
    o && (u = [s], c = _m);
    var l = Proxy.revocable(u, c), d = l.revoke, f = l.proxy;
    return s.k = f, s.j = d, f;
  }(e, r) : yc("ES5").J(e, r);
  return (r ? r.A : NT()).p.push(n), n;
}
function Xie(t) {
  return Fp(t) || Mu(22, t), function e(r) {
    if (!M0(r)) return r;
    var n, i = r[_s], a = Np(r);
    if (i) {
      if (!i.P && (i.i < 4 || !yc("ES5").K(i))) return i.t;
      i.I = !0, n = kT(r, a), i.I = !1;
    } else n = kT(r, a);
    return $m(n, function(o, s) {
      i && function(u, c) {
        return Np(u) === 2 ? u.get(c) : u[c];
      }(i.t, o) === s || zO(n, o, e(s));
    }), a === 3 ? new Set(n) : n;
  }(t);
}
function kT(t, e) {
  switch (e) {
    case 2:
      return new Map(t);
    case 3:
      return Array.from(t);
  }
  return bx(t);
}
var GT, e2, Sx = typeof Symbol < "u" && typeof Symbol("x") == "symbol", Yie = typeof Map < "u", Wie = typeof Set < "u", zT = typeof Proxy < "u" && Proxy.revocable !== void 0 && typeof Reflect < "u", VO = Sx ? Symbol.for("immer-nothing") : ((GT = {})["immer-nothing"] = !0, GT), VT = Sx ? Symbol.for("immer-draftable") : "__$immer_draftable", _s = Sx ? Symbol.for("immer-state") : "__$immer_state", jie = "" + Object.prototype.constructor, Cx = typeof Reflect < "u" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(t) {
  return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t));
} : Object.getOwnPropertyNames, Zie = Object.getOwnPropertyDescriptors || function(t) {
  var e = {};
  return Cx(t).forEach(function(r) {
    e[r] = Object.getOwnPropertyDescriptor(t, r);
  }), e;
}, Qie = {}, C7 = { get: function(t, e) {
  if (e === _s) return t;
  var r = n0(t);
  if (!b7(r, e)) return function(i, a, o) {
    var s, u = LT(a, o);
    return u ? "value" in u ? u.value : (s = u.get) === null || s === void 0 ? void 0 : s.call(i.k) : void 0;
  }(t, r, e);
  var n = r[e];
  return t.I || !M0(n) ? n : n === Kb(t.t, e) ? (Xb(t), t.o[e] = S7(t.A.h, n, t)) : n;
}, has: function(t, e) {
  return e in n0(t);
}, ownKeys: function(t) {
  return Reflect.ownKeys(n0(t));
}, set: function(t, e, r) {
  var n = LT(n0(t), e);
  if (n != null && n.set) return n.set.call(t.k, r), !0;
  if (!t.P) {
    var i = Kb(n0(t), e), a = i == null ? void 0 : i[_s];
    if (a && a.t === r) return t.o[e] = r, t.D[e] = !1, !0;
    if (function(o, s) {
      return o === s ? o !== 0 || 1 / o == 1 / s : o != o && s != s;
    }(r, i) && (r !== void 0 || b7(t.t, e))) return !0;
    Xb(t), x7(t);
  }
  return t.o[e] === r && typeof r != "number" && (r !== void 0 || e in t.o) || (t.o[e] = r, t.D[e] = !0, !0);
}, deleteProperty: function(t, e) {
  return Kb(t.t, e) !== void 0 || e in t.t ? (t.D[e] = !1, Xb(t), x7(t)) : delete t.D[e], t.o && delete t.o[e], !0;
}, getOwnPropertyDescriptor: function(t, e) {
  var r = n0(t), n = Reflect.getOwnPropertyDescriptor(r, e);
  return n && { writable: !0, configurable: t.i !== 1 || e !== "length", enumerable: n.enumerable, value: r[e] };
}, defineProperty: function() {
  Mu(11);
}, getPrototypeOf: function(t) {
  return Object.getPrototypeOf(t.t);
}, setPrototypeOf: function() {
  Mu(12);
} }, _m = {};
$m(C7, function(t, e) {
  _m[t] = function() {
    return arguments[0] = arguments[0][0], e.apply(this, arguments);
  };
}), _m.deleteProperty = function(t, e) {
  return _m.set.call(this, t, e, void 0);
}, _m.set = function(t, e, r) {
  return C7.set.call(this, t[0], e, r, t[0]);
};
var Jie = function() {
  function t(r) {
    var n = this;
    this.g = zT, this.F = !0, this.produce = function(i, a, o) {
      if (typeof i == "function" && typeof a != "function") {
        var s = a;
        a = i;
        var u = n;
        return function(p) {
          var v = this;
          p === void 0 && (p = s);
          for (var g = arguments.length, y = Array(g > 1 ? g - 1 : 0), b = 1; b < g; b++) y[b - 1] = arguments[b];
          return u.produce(p, function(S) {
            var _;
            return (_ = a).call.apply(_, [v, S].concat(y));
          });
        };
      }
      var c;
      if (typeof a != "function" && Mu(6), o !== void 0 && typeof o != "function" && Mu(7), M0(i)) {
        var l = RT(n), d = S7(n, i, void 0), f = !0;
        try {
          c = a(d), f = !1;
        } finally {
          f ? Q3(l) : _7(l);
        }
        return typeof Promise < "u" && c instanceof Promise ? c.then(function(p) {
          return Hb(l, o), qb(p, l);
        }, function(p) {
          throw Q3(l), p;
        }) : (Hb(l, o), qb(c, l));
      }
      if (!i || typeof i != "object") {
        if ((c = a(i)) === void 0 && (c = i), c === VO && (c = void 0), n.F && _x(c, !0), o) {
          var h = [], m = [];
          yc("Patches").M(i, c, h, m), o(h, m);
        }
        return c;
      }
      Mu(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), f = 1; f < l; f++) d[f - 1] = arguments[f];
        return n.produceWithPatches(c, function(h) {
          return i.apply(void 0, [h].concat(d));
        });
      };
      var o, s, u = n.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 (r == null ? void 0 : r.useProxies) == "boolean" && this.setUseProxies(r.useProxies), typeof (r == null ? void 0 : r.autoFreeze) == "boolean" && this.setAutoFreeze(r.autoFreeze);
  }
  var e = t.prototype;
  return e.createDraft = function(r) {
    M0(r) || Mu(8), Fp(r) && (r = Xie(r));
    var n = RT(this), i = S7(this, r, void 0);
    return i[_s].C = !0, _7(n), i;
  }, e.finishDraft = function(r, n) {
    var i = (r && r[_s]).A;
    return Hb(i, n), qb(void 0, i);
  }, e.setAutoFreeze = function(r) {
    this.F = r;
  }, e.setUseProxies = function(r) {
    r && !zT && Mu(20), this.g = r;
  }, e.applyPatches = function(r, n) {
    var i;
    for (i = n.length - 1; i >= 0; i--) {
      var a = n[i];
      if (a.path.length === 0 && a.op === "replace") {
        r = a.value;
        break;
      }
    }
    i > -1 && (n = n.slice(i + 1));
    var o = yc("Patches").$;
    return Fp(r) ? o(r, n) : this.produce(r, function(s) {
      return o(s, n);
    });
  }, t;
}(), ss = new Jie(), Ax = ss.produce;
ss.produceWithPatches.bind(ss), ss.setAutoFreeze.bind(ss), ss.setUseProxies.bind(ss), ss.applyPatches.bind(ss), ss.createDraft.bind(ss), ss.finishDraft.bind(ss);
var uf, ks = new Uint16Array([0, 1, 2, 1, 3, 2]), zf = Le.add3, ga = Le.add2, UT = Le.add;
(function(t) {
  t.create = function(e, r, n, i) {
    e === void 0 && (e = {}), r === void 0 && (r = 2048), n === void 0 && (n = 1024), r *= 2, n *= 2;
    var a = Le.create(Float32Array, 3, n, i ? i.centerBuffer.ref.value : r), o = Le.create(Float32Array, 2, n, i ? i.mappingBuffer.ref.value : r), s = Le.create(Float32Array, 1, n, i ? i.depthBuffer.ref.value : r), u = Le.create(Uint32Array, 3, n, i ? i.indexBuffer.ref.value : r), c = Le.create(Float32Array, 1, n, i ? i.groupBuffer.ref.value : r), l = Le.create(Float32Array, 2, n, i ? i.tcoordBuffer.ref.value : r), d = O(O({}, z.getDefaultValues(bs.Params)), e), f = d.attachment, h = d.background, m = d.backgroundMargin, p = d.tether, v = d.tetherLength, g = d.tetherBaseWidth, y = function(x) {
      var C = JSON.stringify(x);
      return bb[C] === void 0 && (bb[C] = new ire(x)), bb[C];
    }(d), b = 0.4 * m, S = y.buffer / y.lineHeight, _ = function(x, C, A, w, I) {
      zf(a, x, C, A), UT(s, w), UT(c, I);
    };
    return { add: function(x, C, A, w, I, P, M) {
      for (var T = 0, F = x.length, N = 0; N < F; ++N)
        T += (De = y.get(x[N])).nw - 2 * S;
      var R, L;
      if (R = f.startsWith("top") ? 0.8 : f.startsWith("middle") ? 0.4 : 0, L = f.endsWith("right") ? T : f.endsWith("center") ? T / 2 : 0, p) switch (f) {
        case "bottom-left":
          L -= v / 2 + b + 0.1, R -= v / 2 + b;
          break;
        case "bottom-center":
          R -= v + b;
          break;
        case "bottom-right":
          L += v / 2 + b + 0.1, R -= v / 2 + b;
          break;
        case "middle-left":
          L -= v + b + 0.1;
          break;
        case "middle-center":
          break;
        case "middle-right":
          L += v + b + 0.1;
          break;
        case "top-left":
          L -= v / 2 + b + 0.1, R += v / 2 + b;
          break;
        case "top-center":
          R += v + b;
          break;
        case "top-right":
          L += v / 2 + b + 0.1, R += v / 2 + b;
      }
      var V = (-L - b - 0.1) * P, U = (T - L + b + 0.1) * P, H = (0.8 - R + b) * P, K = (-R - b) * P;
      if (h) {
        ga(o, V, H), ga(o, V, K), ga(o, U, H), ga(o, U, K);
        for (var X = a.elementCount, Y = 0; Y < 4; ++Y) ga(l, 10, 10), _(C, A, w, I, M);
        zf(u, X + ks[0], X + ks[1], X + ks[2]), zf(u, X + ks[3], X + ks[4], X + ks[5]);
      }
      if (p) {
        var Q = void 0, J = void 0, te = void 0, W = void 0, j = void 0, ee = void 0, ie = void 0, ae = void 0, ce = v * P, de = g * P;
        switch (f) {
          case "bottom-left":
            Q = V - ce / 2, te = V + de / 2, j = V, ie = V, J = K - ce / 2, W = K, ee = K + de / 2, ae = K;
            break;
          case "bottom-center":
            Q = 0, te = de / 2, j = -de / 2, ie = 0, J = K - ce, W = K, ee = K, ae = K;
            break;
          case "bottom-right":
            Q = U + ce / 2, te = U, j = U - de / 2, ie = U, J = K - ce / 2, W = K + de / 2, ee = K, ae = K;
            break;
          case "middle-left":
            Q = V - ce, te = V, j = V, ie = V, J = 0, W = -de / 2, ee = de / 2, ae = 0;
            break;
          case "middle-center":
            Q = 0, te = 0, j = 0, ie = 0, J = 0, W = 0, ee = 0, ae = 0;
            break;
          case "middle-right":
            Q = U + ce, te = U, j = U, ie = U, J = 0, W = de / 2, ee = -de / 2, ae = 0;
            break;
          case "top-left":
            Q = V - ce / 2, te = V + de / 2, j = V, ie = V, J = H + ce / 2, W = H, ee = H - de / 2, ae = H;
            break;
          case "top-center":
            Q = 0, te = de / 2, j = -de / 2, ie = 0, J = H + ce, W = H, ee = H, ae = H;
            break;
          case "top-right":
            Q = U + ce / 2, te = U, j = U - de / 2, ie = U, J = H + ce / 2, W = H - de / 2, ee = H, ae = H;
            break;
          default:
            ca();
        }
        for (ga(o, Q, J), ga(o, te, W), ga(o, j, ee), ga(o, ie, ae), X = a.elementCount, Y = 0; Y < 4; ++Y) ga(l, 10, 10), _(C, A, w, I, M);
        zf(u, X, X + 1, X + 3), zf(u, X, X + 3, X + 2);
      }
      L += S, R += S;
      var Ce = 0;
      for (N = 0; N < F; ++N) {
        var De, ke = (Ce - L) * P, He = (Ce + (De = y.get(x[N])).nw - L) * P, We = (De.nh - R) * P, Ne = -R * P;
        ga(o, ke, We), ga(o, ke, Ne), ga(o, He, We), ga(o, He, Ne);
        var Je = y.texture.width, Re = y.texture.height;
        for (ga(l, De.x / Je, De.y / Re), ga(l, De.x / Je, (De.y + De.h) / Re), ga(l, (De.x + De.w) / Je, De.y / Re), ga(l, (De.x + De.w) / Je, (De.y + De.h) / Re), Ce += De.nw - 2 * S, X = a.elementCount, Y = 0; Y < 4; ++Y) _(C, A, w, I, M);
        zf(u, X + ks[0], X + ks[1], X + ks[2]), zf(u, X + ks[3], X + ks[4], X + ks[5]);
      }
    }, getText: function() {
      var x = y.texture, C = Le.compact(a, !0), A = Le.compact(o, !0), w = Le.compact(s, !0), I = Le.compact(u, !0), P = Le.compact(c, !0), M = Le.compact(l, !0);
      return bs.create(x, C, A, w, I, P, M, u.elementCount / 2, i);
    } };
  };
})(uf || (uf = {}));
var gn, UO = { alpha: z.Numeric(0.51, { min: 0, max: 1, step: 0.01 }, { isEssential: !0, label: "Opacity" }), hideX: z.Boolean(!1), hideY: z.Boolean(!1), hideZ: z.Boolean(!1), colorX: z.Color(Yt.red, { isEssential: !0 }), colorY: z.Color(Yt.green, { isEssential: !0 }), colorZ: z.Color(Yt.blue, { isEssential: !0 }), scale: z.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }), vecA: z.Vec3(E.unitX), vecB: z.Vec3(E.unitY), vecC: z.Vec3(E.unitZ), location: z.Select("bottom-left", z.arrayToOptions(["bottom-left", "bottom-right", "top-left", "top-right"])), locationOffsetX: z.Numeric(0), locationOffsetY: z.Numeric(0), originColor: z.Color(Yt.grey), radiusScale: z.Numeric(0.075, { min: 0.01, max: 0.3, step: 1e-3 }), showPlanes: z.Boolean(!1), planeColorXY: z.Color(Yt.grey, { label: "Plane Color XY" }), planeColorXZ: z.Color(Yt.grey, { label: "Plane Color XZ" }), planeColorYZ: z.Color(Yt.grey, { label: "Plane Color YZ" }), showLabels: z.Boolean(!0), labelX: z.Text("X"), labelY: z.Text("Y"), labelZ: z.Text("Z"), labelColorX: z.Color(Yt.grey), labelColorY: z.Color(Yt.grey), labelColorZ: z.Color(Yt.grey), labelOpacity: z.Numeric(1, { min: 0, max: 1, step: 0.01 }), labelScale: z.Numeric(0.15, { min: 0.1, max: 1, step: 0.01 }) }, Wy = { axes: z.MappedStatic("on", { on: z.Group(UO), off: z.Group({}) }, { cycle: !0, description: "Show camera orientation axes" }) }, HO = function() {
  function t(e, r) {
    var n = this;
    r === void 0 && (r = {}), this.webgl = e, this.props = { axes: { name: "off", params: {} } }, this.pixelRatio = 1, this.eachGroup = function(i, a) {
      if (!HT(i)) return !1;
      var o = !1;
      if (n.meshRenderObject) for (var s = n.meshRenderObject.values.uGroupCount.ref.value, u = 0, c = i.elements; u < c.length; u++) {
        var l = c[u], d = l.groupId, f = l.instanceId * s + d;
        a(Se.ofSingleton(f)) && (o = !0);
      }
      if (n.textRenderObject) {
        s = n.textRenderObject.values.uGroupCount.ref.value;
        for (var h = 0, m = i.elements; h < m.length; h++) {
          var p = m[h];
          d = p.groupId, f = p.instanceId * s + d, a(Se.ofSingleton(f)) && (o = !0);
        }
      }
      return o;
    }, this.scene = Pp.create(e, qy), this.camera = new di(), E.set(this.camera.up, 0, 1, 0), E.set(this.camera.target, 0, 0, 0), this.setProps(r);
  }
  return t.prototype.setProps = function(e) {
    var r = this;
    this.props = Ax(this.props, function(n) {
      if (e.axes !== void 0 && (n.axes.name = e.axes.name, e.axes.name === "on")) {
        r.scene.clear();
        var i = O(O({}, z.getDefaultValues(UO)), e.axes.params);
        r.pixelRatio = r.webgl.pixelRatio;
        var a = O(O({}, i), { scale: i.scale * r.pixelRatio, labelScale: i.labelScale * r.pixelRatio });
        r.meshRenderObject = function(o) {
          var s = function(u, c) {
            var l = 100 * u.scale, d = function(h, m) {
              var p = h.vecA, v = h.vecB, g = h.vecC, y = wt.createState(512, 256, m), b = 100 * h.scale, S = h.radiusScale * b, _ = h.showLabels ? 100 * h.labelScale / 3 : 0, x = E.sub(E(), E.scale(E(), p, b - _), E.scale(E(), E.create(0, 0, 1), 0.5 * b)), C = E.sub(E(), E.scale(E(), v, b - _), E.scale(E(), E.create(0, 0, 1), 0.5 * b)), A = E.sub(E(), E.scale(E(), g, b - _), E.scale(E(), E.create(0, 0, 1), 0.5 * b)), w = E.sub(E(), E.origin, E.scale(E(), E.create(0, 0, 1), 0.5 * b)), I = { radiusTop: S, radiusBottom: S, radialSegments: 32 };
              if (y.currentGroup = gn.Origin, Yi(y, w, S, 2), h.hideX || (y.currentGroup = gn.X, Yi(y, x, S, 2), Hi(y, w, x, 1, I)), h.hideY || (y.currentGroup = gn.Y, Yi(y, C, S, 2), Hi(y, w, C, 1, I)), h.hideZ || (y.currentGroup = gn.Z, Yi(y, A, S, 2), Hi(y, w, A, 1, I)), h.showPlanes) {
                if (E.scale(x, x, 0.5), E.scale(C, C, 0.5), E.scale(A, A, 0.5), !h.hideX && !h.hideY) {
                  y.currentGroup = gn.XY, wt.addTriangle(y, w, x, C), wt.addTriangle(y, w, C, x);
                  var P = E.add(E(), x, C);
                  wt.addTriangle(y, P, x, C), wt.addTriangle(y, P, C, x);
                }
                if (!h.hideX && !h.hideZ) {
                  y.currentGroup = gn.XZ, wt.addTriangle(y, w, x, A), wt.addTriangle(y, w, A, x);
                  var M = E.add(E(), x, A);
                  wt.addTriangle(y, M, x, A), wt.addTriangle(y, M, A, x);
                }
                if (!h.hideY && !h.hideZ) {
                  y.currentGroup = gn.YZ, wt.addTriangle(y, w, C, A), wt.addTriangle(y, w, A, C);
                  var T = E.add(E(), C, A);
                  wt.addTriangle(y, T, C, A), wt.addTriangle(y, T, A, C);
                }
              }
              return wt.getMesh(y);
            }(u, void 0);
            d.setBoundingSphere(Me.create(E.create(l / 2, l / 2, l / 2), l + l / 4));
            var f = function(h) {
              switch (h) {
                case gn.X:
                  return u.colorX;
                case gn.Y:
                  return u.colorY;
                case gn.Z:
                  return u.colorZ;
                case gn.XY:
                  return u.planeColorXY;
                case gn.XZ:
                  return u.planeColorXZ;
                case gn.YZ:
                  return u.planeColorYZ;
                case gn.Origin:
                  return u.originColor;
                default:
                  return Yt.grey;
              }
            };
            return er.create("axes-mesh", {}, d, f, function() {
              return 1;
            }, function() {
              return "";
            });
          }(o);
          return er.createRenderObject(s, O(O(O({}, z.getDefaultValues(Vt.Params)), o), { ignoreLight: !0 }));
        }(a), r.scene.add(r.meshRenderObject), a.showLabels ? (r.textRenderObject = function(o) {
          var s = function(u, c) {
            var l = 100 * u.scale, d = function(h, m) {
              var p = h.vecA, v = h.vecB, g = h.vecC, y = uf.create(h, 8, 8, m), b = 100 * h.scale, S = E.add(E(), E.scale(E(), p, b), E.scale(E(), E.create(0, 0, 1), 1.5 * b)), _ = E.add(E(), E.scale(E(), v, b), E.scale(E(), E.create(0, 0, 1), 1.5 * b)), x = E.add(E(), E.scale(E(), g, b), E.scale(E(), E.create(0, 0, 1), 1.5 * b)), C = 100 * h.labelScale;
              return h.hideX || y.add(h.labelX, S[0], S[1], S[2], 0, C, gn.X), h.hideY || y.add(h.labelY, _[0], _[1], _[2], 0, C, gn.Y), h.hideZ || y.add(h.labelZ, x[0], x[1], x[2], 0, C, gn.Z), y.getText();
            }(u, void 0);
            d.setBoundingSphere(Me.create(E.create(l / 2, l / 2, l / 2), l));
            var f = function(h) {
              switch (h) {
                case gn.X:
                  return u.labelColorX;
                case gn.Y:
                  return u.labelColorY;
                case gn.Z:
                  return u.labelColorZ;
                default:
                  return Yt.grey;
              }
            };
            return er.create("axes-text", {}, d, f, function() {
              return 1;
            }, function() {
              return "";
            });
          }(o);
          return er.createRenderObject(s, O(O(O({}, z.getDefaultValues(bs.Params)), o), { alpha: o.labelOpacity }));
        }(a), r.scene.add(r.textRenderObject)) : r.textRenderObject = void 0, r.scene.commit(), E.set(r.camera.position, 0, 0, 200 * a.scale), he.lookAt(r.camera.view, r.camera.position, r.camera.target, r.camera.up), n.axes.params = O({}, i);
      }
    });
  }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
    return this.props.axes.name === "on";
  }, enumerable: !1, configurable: !0 }), t.prototype.getLoci = function(e) {
    var r = e.objectId, n = e.groupId, i = e.instanceId;
    return (this.meshRenderObject && r === this.meshRenderObject.id || this.textRenderObject && r === this.textRenderObject.id) && n !== gn.None ? function(a, o, s) {
      return hx("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", f = l.name === "on" ? l.params.labelY : "Y", h = l.name === "on" ? l.params.labelZ : "Z";
          switch (u) {
            case gn.X:
              return "".concat(d, " Axis");
            case gn.Y:
              return "".concat(f, " Axis");
            case gn.Z:
              return "".concat(h, " Axis");
            case gn.XY:
              return "".concat(d).concat(f, " Plane");
            case gn.XZ:
              return "".concat(d).concat(h, " Plane");
            case gn.YZ:
              return "".concat(f).concat(h, " Plane");
            case gn.Origin:
              return "Origin";
            default:
              return "Axes";
          }
        }(o, a);
      });
    }(this, n, i) : Dn;
  }, t.prototype.mark = function(e, r) {
    return !Lr.is(Lr.Highlighting, r) || !qo(e) && (!HT(e) || e.data !== this) ? !1 : nr.mark(this.meshRenderObject, e, r, this.eachGroup) || nr.mark(this.textRenderObject, e, r, this.eachGroup);
  }, t.prototype.update = function(e) {
    if (this.meshRenderObject && this.props.axes.name !== "off") {
      this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), function(o, s, u) {
        var c = o.near, l = o.far, d = -s.width / 2, f = s.width / 2, h = s.height / 2, m = -s.height / 2, p = (f - d) / 2, v = (h - m) / 2, g = (f + d) / 2, y = (h + m) / 2, b = g - p, S = g + p, _ = y + v, x = y - v;
        if (u.enabled) {
          var C = (f - d) / u.width, A = (h - m) / u.height;
          S = (b += C * u.offsetX) + C * u.width, x = (_ -= A * u.offsetY) - A * u.height;
        }
        he.ortho(o.projection, b, S, _, x, c, l);
      }(this.camera, e.viewport, e.viewOffset), he.extractRotation(this.scene.view, e.view);
      var r = this.textRenderObject ? this.textRenderObject.values.boundingSphere.ref.value.radius : this.meshRenderObject.values.boundingSphere.ref.value.radius, n = this.props.axes.params.location, i = this.props.axes.params.locationOffsetX * this.pixelRatio, a = this.props.axes.params.locationOffsetY * this.pixelRatio;
      n === "bottom-left" ? he.setTranslation(this.scene.view, E.create(-e.viewport.width / 2 + r + i, -e.viewport.height / 2 + r + a, 0)) : n === "bottom-right" ? he.setTranslation(this.scene.view, E.create(e.viewport.width / 2 - r - i, -e.viewport.height / 2 + r + a, 0)) : n === "top-left" ? he.setTranslation(this.scene.view, E.create(-e.viewport.width / 2 + r + i, e.viewport.height / 2 - r - a, 0)) : n === "top-right" ? he.setTranslation(this.scene.view, E.create(e.viewport.width / 2 - r - i, e.viewport.height / 2 - r - a, 0)) : ca();
    }
  }, t;
}();
function HT(t) {
  return t.kind === "data-loci" && t.tag === "camera-axes";
}
(function(t) {
  t[t.None = 0] = "None", t[t.X = 1] = "X", t[t.Y = 2] = "Y", t[t.Z = 3] = "Z", t[t.XY = 4] = "XY", t[t.XZ = 5] = "XZ", t[t.YZ = 6] = "YZ", t[t.Origin = 7] = "Origin";
})(gn || (gn = {}));
var $ie = { transparentBackground: z.Boolean(!1), multiSample: z.Group(RO), postprocessing: z.Group(NO), marking: z.Group(kO), cameraHelper: z.Group(Wy) }, eae = function() {
  function t(e, r, n, i, a, o, s) {
    this.webgl = e, this.renderer = r, this.scene = n, this.camera = i, this._width = 0, this._height = 0, this._camera = new di(), this.props = O(O({}, z.getDefaultValues($ie)), s), this.drawPass = new GO(e, 128, 128, o), this.multiSamplePass = new Z3(e, this.drawPass), this.multiSampleHelper = new OO(this.multiSamplePass), this.helper = { camera: new HO(e, this.props.cameraHelper), debug: a.debug, handle: a.handle }, this.setSize(1024, 768);
  }
  return Object.defineProperty(t.prototype, "colorTarget", { get: function() {
    return this._colorTarget;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "width", { get: function() {
    return this._width;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "height", { get: function() {
    return this._height;
  }, enumerable: !1, configurable: !0 }), t.prototype.setSize = function(e, r) {
    e === this._width && r === this._height || (this._width = e, this._height = r, this.drawPass.setSize(e, r), this.multiSamplePass.syncSize());
  }, t.prototype.setProps = function(e) {
    e === void 0 && (e = {}), Object.assign(this.props, e), e.cameraHelper && this.helper.camera.setProps(e.cameraHelper);
  }, t.prototype.render = function() {
    di.copySnapshot(this._camera.state, this.camera.state), sa.set(this._camera.viewport, 0, 0, this._width, this._height), this._camera.update();
    var e = { renderer: this.renderer, camera: this._camera, scene: this.scene, helper: this.helper };
    Z3.isEnabled(this.props.multiSample) ? (this.multiSampleHelper.render(e, this.props, !1), this._colorTarget = this.multiSamplePass.colorTarget) : (this.drawPass.render(e, this.props, !1), this._colorTarget = this.drawPass.getColorTarget(this.props.postprocessing));
  }, t.prototype.getImageData = function(e, r, n) {
    var i, a;
    this.setSize(e, r), this.render(), this.colorTarget.bind();
    var o = (i = n == null ? void 0 : n.width) !== null && i !== void 0 ? i : e, s = (a = n == null ? void 0 : n.height) !== null && a !== void 0 ? a : r, u = new Uint8Array(o * s * 4);
    n ? this.webgl.readPixels(n.x, r - n.y - n.height, o, s, u) : this.webgl.readPixels(0, 0, o, s, u);
    var c = g0.create(u, o, s);
    return g0.flipY(c), g0.divideByAlpha(c), new ImageData(new Uint8ClampedArray(u), o, s);
  }, t;
}(), tae = O(O({}, Vt.Params), { alpha: O(O({}, Vt.Params.alpha), { defaultValue: 1 }), ignoreLight: O(O({}, Vt.Params.ignoreLight), { defaultValue: !0 }), colorX: z.Color(Yt.red, { isEssential: !0 }), colorY: z.Color(Yt.green, { isEssential: !0 }), colorZ: z.Color(Yt.blue, { isEssential: !0 }), scale: z.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }) }), qO = { handle: z.MappedStatic("off", { on: z.Group(tae), off: z.Group({}) }, { cycle: !0, description: "Show handle tool" }) }, rae = function() {
  function t(e, r) {
    var n = this;
    r === void 0 && (r = {}), this.webgl = e, this.props = { handle: { name: "off", params: {} } }, this.pixelRatio = 1, this._transform = he(), this.eachGroup = function(i, a) {
      if (!n.renderObject || !qT(i)) return !1;
      for (var o = !1, s = n.renderObject.values.uGroupCount.ref.value, u = 0, c = i.elements; u < c.length; u++) {
        var l = c[u], d = l.groupId, f = l.instanceId * s + d;
        a(Se.ofSingleton(f)) && (o = !0);
      }
      return o;
    }, this.scene = Pp.create(e, qy), this.setProps(r);
  }
  return t.prototype.getBoundingSphere = function(e, r) {
    return this.renderObject && (Me.copy(e, this.renderObject.values.invariantBoundingSphere.ref.value), he.fromArray(this._transform, this.renderObject.values.aTransform.ref.value, 16 * r), Me.transform(e, e, this._transform)), e;
  }, t.prototype.setProps = function(e) {
    var r = this;
    this.props = Ax(this.props, function(n) {
      if (e.handle !== void 0 && (n.handle.name = e.handle.name, e.handle.name === "on")) {
        r.scene.clear(), r.pixelRatio = r.webgl.pixelRatio;
        var i = O(O({}, e.handle.params), { scale: e.handle.params.scale * r.webgl.pixelRatio });
        r.renderObject = function(a) {
          var o = function(s, u) {
            var c = 10 * s.scale, l = function(f, h) {
              var m = wt.createState(512, 256, h), p = 0.05 * f, v = E.scale(E(), E.unitX, f), g = E.scale(E(), E.unitY, f), y = E.scale(E(), E.unitZ, f), b = { radiusTop: p, radiusBottom: p, radialSegments: 32 };
              return m.currentGroup = Vf.TranslateScreenXY, Yi(m, E.origin, 3 * p, 2), m.currentGroup = Vf.TranslateObjectX, Yi(m, v, p, 2), Hi(m, E.origin, v, 1, b), m.currentGroup = Vf.TranslateObjectY, Yi(m, g, p, 2), Hi(m, E.origin, g, 1, b), m.currentGroup = Vf.TranslateObjectZ, Yi(m, y, p, 2), Hi(m, E.origin, y, 1, b), wt.getMesh(m);
            }(c, void 0);
            l.setBoundingSphere(Me.create(E.create(c / 2, c / 2, c / 2), c + c / 4));
            var d = function(f) {
              switch (f) {
                case Vf.TranslateObjectX:
                  return s.colorX;
                case Vf.TranslateObjectY:
                  return s.colorY;
                case Vf.TranslateObjectZ:
                  return s.colorZ;
                default:
                  return Yt.grey;
              }
            };
            return er.create("handle", {}, l, d, function() {
              return 1;
            }, function() {
              return "";
            });
          }(a);
          return er.createRenderObject(o, a);
        }(i), r.scene.add(r.renderObject), r.scene.commit(), n.handle.params = O({}, e.handle.params);
      }
    });
  }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
    return this.props.handle.name === "on";
  }, enumerable: !1, configurable: !0 }), t.prototype.update = function(e, r, n) {
    this.renderObject && (this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), he.setTranslation(this.renderObject.values.aTransform.ref.value, r), he.fromMat3(this.renderObject.values.aTransform.ref.value, n), G.update(this.renderObject.values.aTransform, this.renderObject.values.aTransform.ref.value), this.scene.update([this.renderObject], !0));
  }, t.prototype.getLoci = function(e) {
    var r = e.objectId, n = e.groupId, i = e.instanceId;
    return this.renderObject && r === this.renderObject.id ? function(a, o, s) {
      return hx("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, n, i) : Dn;
  }, t.prototype.mark = function(e, r) {
    return !Lr.is(Lr.Highlighting, r) || !qo(e) && (!qT(e) || e.data !== this) ? !1 : nr.mark(this.renderObject, e, r, this.eachGroup);
  }, t;
}(), Vf = { None: 0, TranslateScreenXY: 1, TranslateObjectX: 3, TranslateObjectY: 4, TranslateObjectZ: 5 };
function qT(t) {
  return t.kind === "data-loci" && t.tag === "handle";
}
var A7, nae = { debug: z.Group(gx), camera: z.Group({ helper: z.Group(Wy) }), handle: z.Group(qO) }, iae = z.getDefaultValues(nae), aae = function(t, e, r) {
  r === void 0 && (r = {});
  var n = O(O({}, iae), r);
  this.debug = new uie(t, e, n.debug), this.camera = new HO(t, n.camera.helper), this.handle = new rae(t, n.handle);
}, oae = function() {
  function t(e, r) {
    r === void 0 && (r = {}), this.webgl = e;
    var n = e.gl;
    this.draw = new GO(e, n.drawingBufferWidth, n.drawingBufferHeight, r.enableWboit || !1), this.pick = new Fie(e, this.draw, r.pickScale || 0.25), this.multiSample = new Z3(e, this.draw);
  }
  return t.prototype.updateSize = function() {
    var e = this.webgl.gl;
    this.draw.setSize(e.drawingBufferWidth, e.drawingBufferHeight), this.pick.syncSize(), this.multiSample.syncSize();
  }, t;
}(), ey = { camera: z.Group({ mode: z.Select("orthographic", z.arrayToOptions(["perspective", "orthographic"]), { label: "Camera" }), helper: z.Group(Wy, { isFlat: !0 }), stereo: z.MappedStatic("off", { on: z.Group(LO), off: z.Group({}) }, { cycle: !0, hideIf: function(t) {
  return (t == null ? void 0 : t.mode) !== "perspective";
} }), manualReset: z.Boolean(!1, { isHidden: !0 }) }, { pivot: "mode" }), cameraFog: z.MappedStatic("on", { on: z.Group({ intensity: z.Numeric(50, { min: 1, max: 100, step: 1 }) }), off: z.Group({}) }, { cycle: !0, description: "Show fog in the distance" }), cameraClipping: z.Group({ radius: z.Numeric(100, { min: 0, max: 99, step: 1 }, { label: "Clipping", description: "How much of the scene to show." }), far: z.Boolean(!0, { description: "Hide scene in the distance" }) }, { pivot: "radius" }), viewport: z.MappedStatic("canvas", { canvas: z.Group({}), "static-frame": z.Group({ x: z.Numeric(0), y: z.Numeric(0), width: z.Numeric(128), height: z.Numeric(128) }), "relative-frame": z.Group({ x: z.Numeric(0.33, { min: 0, max: 1, step: 0.01 }), y: z.Numeric(0.33, { min: 0, max: 1, step: 0.01 }), width: z.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }), height: z.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }) }) }), cameraResetDurationMs: z.Numeric(250, { min: 0, max: 1e3, step: 1 }, { description: "The time it takes to reset the camera." }), transparentBackground: z.Boolean(!1), multiSample: z.Group(RO), postprocessing: z.Group(NO), marking: z.Group(kO), renderer: z.Group(B_), trackball: z.Group(LN), interaction: z.Group(FO), debug: z.Group(gx), handle: z.Group(qO) }, sae = z.getDefaultValues(ey);
(function(t) {
  t.DefaultAttribs = { antialias: !0, preserveDrawingBuffer: !0, pixelScale: 1, pickScale: 0.25, pickPadding: 1, enableWboit: !0, preferWebGl1: !1 }, t.fromCanvas = function(e, r) {
    r === void 0 && (r = {});
    var n = O(O({}, t.DefaultAttribs), r), i = n.antialias, a = n.preserveDrawingBuffer, o = n.pixelScale, s = n.preferWebGl1, u = function(v, g) {
      function y(S) {
        try {
          return v.getContext(S, g);
        } catch {
          return null;
        }
      }
      var b = (g != null && g.preferWebGl1 ? null : y("webgl2")) || y("webgl") || y("experimental-webgl");
      return Pr && console.log("isWebgl2: ".concat(ar(b))), b;
    }(e, { 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 = I_.fromElement(e, { pixelScale: o, preventGestures: !0 }), l = gJ(u, { pixelScale: o }), d = new oae(l, r);
    if (Pr) {
      var f = u.getExtension("WEBGL_lose_context");
      f && e.addEventListener("mousedown", function(v) {
        l.isContextLost || v.shiftKey && v.ctrlKey && v.altKey && (Pr && console.log("lose context"), f.loseContext(), setTimeout(function() {
          l.isContextLost && (Pr && console.log("restore context"), f.restoreContext());
        }, 1e3));
      }, !1);
    }
    var h = new kd(0), m = function(v) {
      l.setContextLost(), v && v.preventDefault(), Pr && console.log("context lost"), h.next(wi());
    }, p = function() {
      l.isContextLost && (l.handleContextRestored(function() {
        d.draw.reset();
      }), Pr && console.log("context restored"));
    };
    return e.addEventListener("webglcontextlost", m, !1), e.addEventListener("webglcontextrestored", p, !1), { canvas: e, webgl: l, input: c, passes: d, attribs: n, contextLost: h, contextRestored: l.contextRestored, dispose: function(v) {
      c.dispose(), e.removeEventListener("webglcontextlost", m, !1), e.removeEventListener("webglcontextrestored", p, !1), l.destroy(v);
    }, handleWebglContextLost: m, handlewWebglContextRestored: p };
  };
})(A7 || (A7 = {}));
var w7, uae = typeof window < "u" ? window.requestAnimationFrame : function(t) {
  return setImmediate(function() {
    return t(Date.now());
  });
}, cae = typeof window < "u" ? window.cancelAnimationFrame : function(t) {
  return clearImmediate(t);
};
function KT(t, e, r) {
  r === void 0 && (r = 1);
  var n = window.innerWidth, i = window.innerHeight;
  e !== document.body && (n = e.offsetWidth, i = e.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") });
  }(t, n, i, r);
}
function XT(t, e, r) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(n) {
      return [2, new Promise(function(i, a) {
        var o = function(s) {
          s ? i(s) : a("no blob returned");
        };
        HTMLCanvasElement.prototype.toBlob ? t.toBlob(o, e, r) : function(s, u, c, l) {
          for (var d = atob(s.toDataURL(c, l).split(",")[1]), f = d.length, h = f >> 2, m = new Uint8Array(f), p = new Uint32Array(m.buffer, 0, h), v = 0, g = 0; g < h; ++g) p[g] = d.charCodeAt(v++) | d.charCodeAt(v++) << 8 | d.charCodeAt(v++) << 16 | d.charCodeAt(v++) << 24;
          for (var y = 3 & f; y--; ) m[v] = d.charCodeAt(v++);
          u(new Blob([m], { type: c }));
        }(t, o, e, r);
      })];
    });
  });
}
function kr(t, e) {
  return t.model.atomicHierarchy.atoms.type_symbol.value(t.elements[e]);
}
function wx(t, e) {
  return t.model.atomicHierarchy.atoms.pdbx_formal_charge.value(t.elements[e]);
}
function KO(t, e) {
  return t.model.atomicHierarchy.atoms.label_atom_id.value(t.elements[e]);
}
function ty(t, e) {
  return t.model.atomicHierarchy.atoms.label_alt_id.value(t.elements[e]);
}
function lae(t, e) {
  return t.model.atomicHierarchy.atoms.label_comp_id.value(t.elements[e]);
}
function t2(t, e, r) {
  return function(n, i, a) {
    for (var o = 0, s = n.interUnitBonds.getEdgeIndices(a, i.id), u = 0, c = s.length; u < c; ++u) {
      var l = n.interUnitBonds.edges[s[u]];
      lr.isCovalent(l.props.flag) && (o += 1);
    }
    return o;
  }(t, e, r) + function(n, i) {
    for (var a = 0, o = n.bonds, s = o.offset, u = o.edgeProps.flags, c = s[i], l = s[i + 1]; c < l; ++c) lr.isCovalent(u[c]) && (a += 1);
    return a;
  }(e, r);
}
function YT(t, e, r, n) {
  var i = 0;
  return tf(t, e, r, function(a, o) {
    kr(a, o) === n && (i += 1);
  }), i;
}
function dae(t, e, r, n, i) {
  return e === n ? function(a, o, s) {
    var u = a.bonds, c = u.offset, l = u.b, d = u.edgeProps.flags;
    lr.is;
    for (var f = c[o], h = c[o + 1]; f < h; ++f) if (l[f] === s && lr.isCovalent(d[f])) return !0;
    return !1;
  }(e, r, i) : function(a, o, s, u, c) {
    var l = a.interUnitBonds.getEdge(s, o.id, c, u.id);
    return l && lr.isCovalent(l.props.flag);
  }(t, e, r, n, i);
}
function hc(t, e, r) {
  for (var n = t.bonds, i = n.offset, a = n.b, o = n.edgeProps.flags, s = i[e], u = i[e + 1]; s < u; ++s) lr.isCovalent(o[s]) && r(t, a[s]);
}
function tf(t, e, r, n) {
  (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]], f = i.unitMap.get(d.unitB);
      lr.isCovalent(d.props.flag) && s(f, d.indexB);
    }
  })(t, e, r, n), hc(e, r, n);
}
function dv(t) {
  switch (t) {
    case 0:
      return 0;
    case 1:
      return 1;
    case 2:
      return 2;
    case 3:
      return 3;
    case 4:
      return 4;
    default:
      return 8;
  }
}
(function(t) {
  t.create = function(e, r) {
    var n = e.webgl, i = e.input, a = e.passes, o = e.attribs;
    r === void 0 && (r = {});
    var s = O(O({}, sae), r), u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = new kd(0), d = wi(), f = new kd(0), h = new kd(0), m = n.gl, p = n.contextRestored, v = 0, g = 0, y = 128, b = 128;
    nt();
    var S = Pp.create(n, a.draw.wboitEnabled ? pre : qy), _ = new di({ position: E.create(0, 0, 100), mode: s.camera.mode, fog: s.cameraFog.name === "on" ? s.cameraFog.params.intensity : 0, clipFar: s.cameraClipping.far }, { x: v, y: g, width: y, height: b }, { pixelScale: o.pixelScale }), x = new Bp(_, s.camera.stereo.params), C = F_.create(i, _, s.trackball), A = P_.create(n, s.renderer), w = new aae(n, S, s), I = new Nie(n, A, S, w, a.pick, { x: v, y: g, width: y, height: b }, o.pickPadding), P = new pie(ae, V, i, _, s.interaction), M = new OO(a.multiSample), T = !1, F = void 0, N = void 0, R = !1, L = !0;
    function V(re) {
      var le = Dn, fe = sr.Empty;
      if (re) {
        var ge = w.camera.getLoci(re);
        if (ge !== Dn) return { loci: ge, repr: fe };
        le = w.handle.getLoci(re), u.forEach(function(me, Ae) {
          var Oe = Ae.getLoci(re);
          ef(Oe) || (ef(le) || console.warn("found another loci, this should not happen"), le = Oe, fe = Ae);
        });
      }
      return { loci: le, repr: fe };
    }
    var U = [];
    function H(re, le) {
      var fe = re.repr, ge = re.loci, me = !1;
      return fe ? me = fe.mark(ge, le) : (me = w.handle.mark(ge, le), me = w.camera.mark(ge, le) || me, u.forEach(function(Ae, Oe) {
        me = Oe.mark(ge, le) || me;
      })), me;
    }
    function K(re) {
      if (n.isContextLost) return !1;
      var le = !1;
      if (R && (Re(!1), R = !1, le = !0), v > m.drawingBufferWidth || v + y < 0 || g > m.drawingBufferHeight || g + b < 0) return !1;
      var fe = function() {
        for (var bt = !1, At = 0, Ee = U; At < Ee.length; At++) {
          var st = Ee[At];
          bt = H(st[0], st[1]) || bt;
        }
        return U = [], bt && (S.update(void 0, !0), w.handle.scene.update(void 0, !0), w.camera.scene.update(void 0, !0)), bt;
      }(), ge = !1;
      C.update(Q);
      var me = _.update(), Ae = re || me || le || X;
      X = !1;
      var Oe = M.update(fe || Ae, s.multiSample);
      if (Ae || Oe || fe) {
        var Ue = _;
        s.camera.stereo.name === "on" && (x.update(), Ue = x);
        var Ve = { renderer: A, camera: Ue, scene: S, helper: w };
        if (Z3.isEnabled(s.multiSample)) {
          var ht = !me && fe && !C.isAnimating;
          M.render(Ve, s, !0, ht);
        } else a.draw.render(Ve, s, !0);
        I.dirty = I.dirty || Ae, ge = !0;
      }
      return ge;
    }
    var X = !1, Y = !1, Q = 0, J = !1;
    function te(re) {
      J || K(!!(re != null && re.force)) && L && f.next(wi() - d);
    }
    function W() {
      X = !0;
    }
    var j = 0;
    function ee(re, le) {
      Q = re, ce(le == null ? void 0 : le.isSynchronous), _.transition.tick(Q), le != null && le.manualDraw || (te(), _.transition.inTransition || n.isContextLost || P.tick(Q));
    }
    function ie() {
      ee(wi()), j = uae(ie);
    }
    function ae(re, le) {
      var fe = s.camera.stereo.name === "on" ? x : _;
      return n.isContextLost ? void 0 : I.identify(re, le, fe);
    }
    function ce(re) {
      re === void 0 && (re = !1);
      var le = function(fe) {
        return S.needsCommit ? (Me.copy(de, S.boundingSphereVisible), S.commit(fe ? void 0 : De) ? (w.debug.isEnabled && w.debug.update(), s.camera.manualReset || l.value !== 0 && !function() {
          if (_.state.radiusMax === 0) return !0;
          if (_.transition.inTransition || N) return !1;
          var ge = !0, me = !0;
          Me.set(Ce, _.state.target, _.state.radius);
          for (var Ae = 0, Oe = S.renderables; Ae < Oe.length; Ae++) {
            var Ue = Oe[Ae];
            if (Ue.state.visible) {
              var Ve = Ue.values.boundingSphere.ref.value;
              if (Ve.radius) {
                me = !1;
                var ht = E.distance(Ce.center, Ve.center);
                if ((ht > Ce.radius || ht > Ve.radius || Ve.radius > _.state.radiusMax) && !Me.includes(de, Ve)) return !0;
                Me.overlaps(Ce, Ve) && (ge = !1);
              }
            }
          }
          return ge || !me && Ce.radius <= 0.1;
        }() || (T = !0), de.radius === 0 && (F = 0), _.setState({ radiusMax: S.boundingSphere.radius }, 0), l.next(u.size), Pr && ke(), !0) : !1) : !0;
      }(re);
      le && (C.isLockCamera ? (F = void 0, N = void 0, T = !1) : function() {
        if (!(!T || C.isLockCamera)) {
          var fe = S.boundingSphereVisible, ge = fe.center, me = fe.radius, Ae = C.props.autoAdjustMinMaxDistance;
          if (Ae.name === "on") {
            var Oe = Ae.params.minDistanceFactor * me + Ae.params.minDistancePadding, Ue = Math.max(Ae.params.maxDistanceFactor * me, Ae.params.maxDistanceMin);
            C.setProps({ minDistance: Oe, maxDistance: Ue });
          }
          if (me > 0) {
            var Ve = F === void 0 ? s.cameraResetDurationMs : F, ht = _.getFocus(ge, me), bt = typeof N == "function" ? N(S, _) : N, At = bt ? O(O({}, ht), bt) : ht;
            _.setState(O(O({}, At), { radiusMax: S.boundingSphere.radius }), Ve);
          }
          F = void 0, N = void 0, T = !1;
        }
      }(), Y && (w.debug.isEnabled && w.debug.update(), te({ force: !0 }), Y = !1), h.next(wi()));
    }
    var de = Me(), Ce = Me(), De = 250;
    function ke() {
      console.table(S.renderables.map(function(me) {
        return { drawCount: me.values.drawCount.ref.value, instanceCount: me.values.instanceCount.ref.value, materialId: me.materialId, renderItemId: me.id };
      })), console.log(n.stats);
      var re = n.resources.getByteCounts(), le = re.texture, fe = re.attribute, ge = re.elements;
      console.log({ texture: "".concat((le / 1024 / 1024).toFixed(3), " MiB"), attribute: "".concat((fe / 1024 / 1024).toFixed(3), " MiB"), elements: "".concat((ge / 1024 / 1024).toFixed(3), " MiB") });
    }
    function He(re) {
      (function(ge) {
        c.has(ge) || c.set(ge, ge.updated.subscribe(function(me) {
          ge.state.syncManually || He(ge);
        }));
      })(re);
      var le = u.get(re), fe = /* @__PURE__ */ new Set();
      re.renderObjects.forEach(function(ge) {
        return fe.add(ge);
      }), le ? Ao.areEqual(fe, le) || (fe.forEach(function(ge) {
        le.has(ge) || S.add(ge);
      }), le.forEach(function(ge) {
        fe.has(ge) || S.remove(ge);
      })) : re.renderObjects.forEach(function(ge) {
        return S.add(ge);
      }), u.set(re, fe), S.update(re.renderObjects, !1), Y = !0, Pr && ke();
    }
    function We() {
      var re = S.boundingSphere.radius > 0 ? 100 - Math.round(_.transition.target.radius / S.boundingSphere.radius * 100) : 0;
      return { camera: { mode: _.state.mode, helper: O({}, w.camera.props), stereo: O({}, s.camera.stereo), manualReset: !!s.camera.manualReset }, cameraFog: _.state.fog > 0 ? { name: "on", params: { intensity: _.state.fog } } : { name: "off", params: {} }, cameraClipping: { far: _.state.clipFar, radius: re }, cameraResetDurationMs: s.cameraResetDurationMs, transparentBackground: s.transparentBackground, viewport: s.viewport, postprocessing: O({}, s.postprocessing), marking: O({}, s.marking), multiSample: O({}, s.multiSample), renderer: O({}, A.props), trackball: O({}, C.props), interaction: O({}, P.props), debug: O({}, w.debug.props), handle: O({}, w.handle.props) };
    }
    var Ne = p.subscribe(function() {
      I.dirty = !0, te({ force: !0 }), te({ force: !0 });
    }), Je = new kd(0);
    function Re(re) {
      re === void 0 && (re = !0), a.updateSize(), nt(), ne(), re && W(), Je.next(+/* @__PURE__ */ new Date());
    }
    return { webgl: n, scene: S, helper: w, add: He, remove: function(re) {
      (function(fe) {
        var ge = c.get(fe);
        ge && (ge.unsubscribe(), c.delete(fe));
      })(re);
      var le = u.get(re);
      le && (le.forEach(function(fe) {
        return S.remove(fe);
      }), u.delete(re), Y = !0, Pr && ke());
    }, commit: ce, controls: C, update: function(re, le) {
      if (re) {
        if (!u.has(re)) return;
        S.update(re.renderObjects, !!le);
      } else S.update(void 0, !!le);
      Y = !0;
    }, clear: function() {
      c.forEach(function(re) {
        return re.unsubscribe();
      }), c.clear(), u.clear(), S.clear(), w.debug.clear(), W(), l.next(u.size);
    }, syncVisibility: function() {
      _.state.radiusMax === 0 && (T = !0, F = 0), S.syncVisibility() && w.debug.isEnabled && w.debug.update(), W();
    }, requestDraw: W, tick: ee, animate: function() {
      J = !1, C.start(wi()), j === 0 && ie();
    }, resetTime: function(re) {
      d = re, C.start(re);
    }, pause: function(re) {
      re === void 0 && (re = !1), J = re, cae(j), j = 0;
    }, resume: function() {
      J = !1;
    }, identify: ae, getPosition: function(re, le) {
      var fe = _;
      return n.isContextLost ? void 0 : I.getPosition(re, le, fe);
    }, mark: function(re, le) {
      U.push([re, le]);
    }, getLoci: V, handleResize: Re, requestResize: function() {
      R = !0;
    }, requestCameraReset: function(re) {
      F = re == null ? void 0 : re.durationMs, N = re == null ? void 0 : re.snapshot, T = !0;
    }, camera: _, boundingSphere: S.boundingSphere, boundingSphereVisible: S.boundingSphereVisible, get notifyDidDraw() {
      return L;
    }, set notifyDidDraw(re) {
      L = re;
    }, didDraw: f, commited: h, reprCount: l, resized: Je, setProps: function(re, le) {
      var fe, ge, me;
      le === void 0 && (le = !1);
      var Ae = typeof re == "function" ? Ax(We(), re) : re, Oe = /* @__PURE__ */ Object.create(null);
      if (Ae.camera && Ae.camera.mode !== void 0 && Ae.camera.mode !== _.state.mode && (Oe.mode = Ae.camera.mode), Ae.cameraFog !== void 0 && Ae.cameraFog.params) {
        var Ue = Ae.cameraFog.name === "on" ? Ae.cameraFog.params.intensity : 0;
        Ue !== _.state.fog && (Oe.fog = Ue);
      }
      if (Ae.cameraClipping !== void 0 && (Ae.cameraClipping.far !== void 0 && Ae.cameraClipping.far !== _.state.clipFar && (Oe.clipFar = Ae.cameraClipping.far), Ae.cameraClipping.radius !== void 0)) {
        var Ve = S.boundingSphere.radius / 100 * (100 - Ae.cameraClipping.radius);
        Ve > 0 && Ve !== Oe.radius && (Oe.radius = Math.max(Ve, 0.01));
      }
      Object.keys(Oe).length > 0 && _.setState(Oe), !((fe = Ae.camera) === null || fe === void 0) && fe.helper && w.camera.setProps(Ae.camera.helper), ((ge = Ae.camera) === null || ge === void 0 ? void 0 : ge.manualReset) !== void 0 && (s.camera.manualReset = Ae.camera.manualReset), ((me = Ae.camera) === null || me === void 0 ? void 0 : me.stereo) !== void 0 && Object.assign(s.camera.stereo, Ae.camera.stereo), Ae.cameraResetDurationMs !== void 0 && (s.cameraResetDurationMs = Ae.cameraResetDurationMs), Ae.transparentBackground !== void 0 && (s.transparentBackground = Ae.transparentBackground), Ae.viewport !== void 0 && (s.viewport === Ae.viewport || s.viewport.name === Ae.viewport.name && E_(s.viewport.params, Ae.viewport.params) || (s.viewport = Ae.viewport, nt(), ne())), Ae.postprocessing && Object.assign(s.postprocessing, Ae.postprocessing), Ae.marking && Object.assign(s.marking, Ae.marking), Ae.multiSample && Object.assign(s.multiSample, Ae.multiSample), Ae.renderer && A.setProps(Ae.renderer), Ae.trackball && C.setProps(Ae.trackball), Ae.interaction && P.setProps(Ae.interaction), Ae.debug && w.debug.setProps(Ae.debug), Ae.handle && w.handle.setProps(Ae.handle), Oe.mode === "orthographic" && (s.camera.stereo.name = "off"), le || W();
    }, getImagePass: function(re) {
      return re === void 0 && (re = {}), new eae(n, A, S, _, w, a.draw.wboitEnabled, re);
    }, getRenderObjects: function() {
      var re = [];
      return S.forEach(function(le, fe) {
        return re.push(fe);
      }), re;
    }, get props() {
      return We();
    }, get input() {
      return i;
    }, get stats() {
      return A.stats;
    }, get interaction() {
      return P.events;
    }, dispose: function() {
      Ne.unsubscribe(), U = [], S.clear(), w.debug.clear(), C.dispose(), A.dispose(), P.dispose();
    } };
    function nt() {
      var re = v, le = g, fe = y, ge = b;
      s.viewport.name === "canvas" ? (v = 0, g = 0, y = m.drawingBufferWidth, b = m.drawingBufferHeight) : s.viewport.name === "static-frame" ? (v = s.viewport.params.x * n.pixelRatio, b = s.viewport.params.height * n.pixelRatio, g = m.drawingBufferHeight - b - s.viewport.params.y * n.pixelRatio, y = s.viewport.params.width * n.pixelRatio) : s.viewport.name === "relative-frame" && (v = Math.round(s.viewport.params.x * m.drawingBufferWidth), b = Math.round(s.viewport.params.height * m.drawingBufferHeight), g = Math.round(m.drawingBufferHeight - b - s.viewport.params.y * m.drawingBufferHeight), y = Math.round(s.viewport.params.width * m.drawingBufferWidth)), re === v && le === g && fe === y && ge === b || (X = !0);
    }
    function ne() {
      I.setViewport(v, g, y, b), A.setViewport(v, g, y, b), sa.set(_.viewport, v, g, y, b), sa.set(C.viewport, v, g, y, b);
    }
  };
})(w7 || (w7 = {}));
var WT = E(), jT = E(), Yb = E(), ZT = E(), QT = E();
function D7(t, e, r, n, i) {
  var a = [];
  return e.conformation.position(e.elements[r], Yb), n.conformation.position(n.elements[i], ZT), E.sub(WT, ZT, Yb), tf(t, e, r, function(o, s) {
    kr(o, s) !== "H" && (o.conformation.position(o.elements[s], QT), E.sub(jT, QT, Yb), a.push(E.angle(WT, jT)));
  }), a;
}
var fae = /* @__PURE__ */ new Set(["LI", "NA", "K", "RB", "CS", "FR"]), pae = /* @__PURE__ */ new Set(["BE", "MG", "CA", "SR", "BA", "RA"]), hae = /* @__PURE__ */ new Set(["ZN", "GA", "CD", "IN", "SN", "HG", "TI", "PB", "BI", "PO", "CN"]), mae = /* @__PURE__ */ new Set(["F", "CL", "BR", "I", "AT"]);
function gae(t) {
  return mae.has(t);
}
function XO(t) {
  var e = Xm(t);
  return e >= 21 && e <= 29 || e >= 39 && e <= 47 || e >= 72 && e <= 79 || e >= 104 && e <= 108;
}
function vae(t) {
  return function(e) {
    return fae.has(e);
  }(t) || function(e) {
    return pae.has(e);
  }(t) || function(e) {
    var r = Xm(e);
    return r >= 57 && r <= 71;
  }(t) || function(e) {
    var r = Xm(e);
    return r >= 89 && r <= 103;
  }(t) || XO(t) || function(e) {
    return hae.has(e);
  }(t);
}
var Wb = new Dt.ElementBondIterator(), jb = new Dt.ElementBondIterator(), P1 = new Dt.ElementBondIterator(), Zb = new Dt.ElementBondIterator();
function yae(t, e, r, n) {
  var i = YT(t, e, r, "H"), a = kr(e, r), o = wx(e, r), s = n.assignCharge === "always" || n.assignCharge === "auto" && o === 0, u = !["sdf", "mol"].includes(e.model.sourceData.kind) && (n.assignH === "always" || n.assignH === "auto" && i === 0), c = t2(t, e, r), l = function(b, S, _) {
    for (var x = 0, C = S.bonds, A = C.offset, w = C.edgeProps, I = w.flags, P = w.order, M = A[_], T = A[_ + 1]; M < T; ++M) lr.isCovalent(I[M]) && (x += P[M]);
    return b.interUnitBonds.getEdgeIndices(_, S.id).forEach(function(F) {
      var N = b.interUnitBonds.edges[F];
      lr.isCovalent(N.props.flag) && (x += N.props.order);
    }), x;
  }(t, e, r), d = function(b, S, _) {
    var x = kr(S, _), C = x === "O" || x === "N";
    if (C && t2(b, S, _) === 4) return !1;
    for (Wb.setElement(b, S, _); Wb.hasNext; ) {
      var A = Wb.move();
      if (A.order > 1) return !0;
      if (C) {
        var w = kr(A.otherUnit, A.otherIndex);
        for (jb.setElement(b, A.otherUnit, A.otherIndex); jb.hasNext; ) {
          var I = jb.move();
          if (I.order > 1) {
            if ((w === "P" || w === "S") && kr(I.otherUnit, I.otherIndex) === "O") continue;
            return !0;
          }
        }
      }
    }
    return !1;
  }(t, e, r), f = l - c > 0, h = 0, m = 8;
  switch (a) {
    case "H":
      s && (c === 0 ? (o = 1, m = 0) : c === 1 && (o = 0, m = 1));
      break;
    case "C":
      s && (o = 0), u && (h = Math.max(0, 4 - l - Math.abs(o))), m = dv(c + h + 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 (P1.setElement(t, e, r); P1.hasNext; ) {
        var p = P1.move(), v = kr(p.otherUnit, p.otherIndex);
        if (v === "S" || vae(v) || lr.is(p.type, 32)) {
          o = 0;
          break;
        }
        o = 1;
      }
      else o = l - 3;
      u && (h = Math.max(0, 3 - l + o)), m = dv(d && !f ? c + h - o : c + h + 1 - o);
      break;
    case "O":
      if (s && (u || (o = l - 2), l === 1)) {
        P1.setElement(t, e, r);
        e: for (; P1.hasNext; ) {
          var g = P1.move();
          for (Zb.setElement(t, g.otherUnit, g.otherIndex); Zb.hasNext; ) {
            var y = Zb.move();
            if ((y.otherUnit !== e || y.otherIndex !== r) && kr(y.otherUnit, y.otherIndex) === "O" && y.order === 2) {
              o = -1;
              break e;
            }
          }
        }
      }
      u && (h = Math.max(0, 2 - l + o)), m = dv(d && !f ? c + h - o + 1 : c + h - o + 2);
      break;
    case "S":
      s && (u || (o = l <= 3 && YT(t, e, r, "O") === 0 ? l - 2 : 0)), u && l < 2 && (h = Math.max(0, 2 - l + o)), l <= 3 && (m = dv(c + h - 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:
      Pr && console.warn("Requested charge, protonation for an unhandled element", a);
  }
  return [o, h, h + i, m];
}
function bae(t, e, r) {
  for (var n = e.elements.length, i = new Int8Array(n), a = new Int8Array(n), o = new Int8Array(n), s = new Int8Array(n), u = 0; u < n; ++u) {
    var c = yae(t, e, u, r), l = c[0], d = c[1], f = c[2], h = c[3];
    i[u] = l, a[u] = d, o[u] = f, s[u] = h;
  }
  return { charge: i, implicitH: a, totalH: o, idealGeometry: s };
}
var YO = { assignCharge: z.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]), assignH: z.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]) };
function _ae(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, s, u;
    return ye(this, function(c) {
      for (n = O(O({}, z.getDefaultValues(YO)), r), i = /* @__PURE__ */ new Map(), a = 0, o = e.units.length; a < o; ++a) s = e.units[a], Fe.isAtomic(s) && (u = bae(e, s, n), i.set(s.id, u));
      return [2, i];
    });
  });
}
var Zr, E7, I7, Qb = O({}, YO), x2 = Cp.createProvider({ label: "Valence Model", descriptor: ku({ name: "molstar_computed_valence_model" }), type: "local", defaultParams: Qb, getParams: function(t) {
  return Qb;
}, isApplicable: function(t) {
  return !0;
}, obtain: function(t, e, r) {
  return _e(void 0, 0, void 0, function() {
    var n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return n = O(O({}, z.getDefaultValues(Qb)), r), i = {}, [4, _ae(t.runtime, e, n)];
        case 1:
          return [2, (i.value = a.sent(), i)];
      }
    });
  });
} });
(function(t) {
  function e(a, o) {
    for (var s = new Int32Array(o + 1), u = new Int32Array(o), c = new Int32Array(o), l = a.members, d = a.count, f = a.offsets, h = 0, m = f[d]; h < m; ++h) ++c[l[h]];
    var p = 0;
    for (h = 0; h < o; h++) s[h] = p, p += c[h];
    s[o] = p;
    var v = new Int32Array(p);
    for (h = 0; h < d; ++h) for (var g = f[h], y = f[h + 1]; g < y; ++g) {
      var b = l[g];
      v[s[b] + u[b]] = h, ++u[b];
    }
    return { indices: v, offsets: s };
  }
  function r(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 f = Ke.ofSortedArray(l);
    return { indices: f, get lookup3d() {
      if (!s) {
        var h = { x: a.x, y: a.y, z: a.z, indices: f };
        s = S0(h, xp(h));
      }
      return s;
    } };
  }
  t.setPosition = function(a, o, s, u) {
    return E.set(a, u.x[s], u.y[s], u.z[s]), E.transformMat4(a, a, o.conformation.operator.matrix), a;
  }, t.createElementsIndex = e, t.create = function(a, o) {
    var s, u;
    return O(O({}, o), { get lookup3d() {
      if (!s) {
        var c = { x: o.x, y: o.y, z: o.z, indices: Ge.ofBounds(0, o.count) };
        s = S0(c, xp(c));
      }
      return s;
    }, get elementsIndex() {
      return u || (u = e(o, a));
    }, subset: function(c) {
      return r(o, c);
    } });
  }, t.createSubset = r, t.Info = function(a, o, s) {
    var u = x2.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 };
  }, t.position = function(a, o) {
    return E.set(a, o.x[o.feature], o.y[o.feature], o.z[o.feature]), E.transformMat4(a, a, o.unit.conformation.operator.matrix), a;
  };
  var n = E(), i = E();
  t.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], n), o.unit.conformation.position(o.unit.elements[u], i), E.distance(n, i);
  }, t.Provider = function(a, o) {
    return { types: new Set(a), add: o };
  };
})(Zr || (Zr = {})), function(t) {
  t.create = function(e, r, n) {
    e === void 0 && (e = 2048), r === void 0 && (r = 1024);
    var i = Le.create(Float32Array, 1, r, n ? n.x : e), a = Le.create(Float32Array, 1, r, n ? n.y : e), o = Le.create(Float32Array, 1, r, n ? n.z : e), s = Le.create(Uint8Array, 1, r, n ? n.types : e), u = Le.create(Uint8Array, 1, r, n ? n.groups : e), c = Le.create(Uint32Array, 1, r, n ? n.offsets : e), l = Le.create(Uint32Array, 1, r, n ? n.members : e), d = { x: 0, y: 0, z: 0, offset: 0, count: 0 };
    return { startState: function() {
      d.x = 0, d.y = 0, d.z = 0, d.offset = l.elementCount, d.count = 0;
    }, pushMember: function(f, h, m, p) {
      Le.add(l, p), d.x += f, d.y += h, d.z += m, d.count += 1;
    }, finishState: function(f, h) {
      var m = d.count;
      m !== 0 && (Le.add(s, f), Le.add(u, h), Le.add(i, d.x / m), Le.add(a, d.y / m), Le.add(o, d.z / m), Le.add(c, d.offset));
    }, add: function(f, h, m, p, v, g) {
      Le.add(s, f), Le.add(u, h), Le.add(i, m), Le.add(a, p), Le.add(o, v), Le.add(c, l.elementCount), Le.add(l, g);
    }, getFeatures: function(f) {
      Le.add(c, l.elementCount);
      var h = Le.compact(i, !0), m = Le.compact(a, !0), p = Le.compact(o, !0), v = i.elementCount;
      return Zr.create(f, { x: h, y: m, z: p, count: v, types: Le.compact(s, !0), groups: Le.compact(u, !0), offsets: Le.compact(c, !0), members: Le.compact(l, !0) });
    } };
  };
}(E7 || (E7 = {})), function(t) {
  t.createElementsIndex = function(e, r, n) {
    for (var i = new Int32Array(n + 1), a = new Int32Array(n), o = new Int32Array(n), s = r.members, u = r.offsets, c = 0, l = 2 * e.edgeCount; c < l; ++c)
      if (!((p = e.a[c]) > (v = e.b[c]))) {
        for (var d = u[p], f = u[p + 1]; d < f; ++d) ++o[s[d]];
        for (d = u[v], f = u[v + 1]; d < f; ++d) ++o[s[d]];
      }
    var h = 0;
    for (c = 0; c < n; c++) i[c] = h, h += o[c];
    i[n] = h;
    var m = new Int32Array(h);
    for (c = 0, l = 2 * e.edgeCount; c < l; ++c) {
      var p, v;
      if (!((p = e.a[c]) > (v = e.b[c]))) {
        for (d = u[p], f = u[p + 1]; d < f; ++d)
          m[i[g = s[d]] + a[g]] = c, ++a[g];
        for (d = u[v], f = u[v + 1]; d < f; ++d) {
          var g;
          m[i[g = s[d]] + a[g]] = c, ++a[g];
        }
      }
    }
    return { indices: m, offsets: i };
  };
}(I7 || (I7 = {}));
var Do, br, xae = function(t) {
  function e(r, n) {
    var i = t.call(this, r) || 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 = n.get(u), d = l.offsets, f = l.members, h = d[c], m = d[c + 1]; h < m; ++h) {
      var p = i.getElementKey(f[h], u), v = i.elementKeyIndex.get(p);
      v === void 0 ? i.elementKeyIndex.set(p, [a]) : v.push(a);
    }
    return i;
  }
  return ka(e, t), e.prototype.getContactIndicesForElement = function(r, n) {
    return this.elementKeyIndex.get(this.getElementKey(r, n.id)) || [];
  }, e.prototype.getElementKey = function(r, n) {
    return "".concat(r, "|").concat(n);
  }, e;
}(C0);
function T7(t) {
  switch (t) {
    case br.HydrogenBond:
      return "Hydrogen Bond";
    case br.Hydrophobic:
      return "Hydrophobic Contact";
    case br.HalogenBond:
      return "Halogen Bond";
    case br.Ionic:
      return "Salt Bridge";
    case br.MetalCoordination:
      return "Metal Bond";
    case br.CationPi:
      return "Cation-Pi Interaction";
    case br.PiStacking:
      return "Pi Stacking";
    case br.WeakHydrogenBond:
      return "Weak Hydrogen Bond";
    case br.Unknown:
      return "Unknown Interaction";
  }
}
(function(t) {
  t[t.None = 0] = "None", t[t.Filtered = 1] = "Filtered";
})(Do || (Do = {})), function(t) {
  t[t.Unknown = 0] = "Unknown", t[t.Ionic = 1] = "Ionic", t[t.CationPi = 2] = "CationPi", t[t.PiStacking = 3] = "PiStacking", t[t.HydrogenBond = 4] = "HydrogenBond", t[t.HalogenBond = 5] = "HalogenBond", t[t.Hydrophobic = 6] = "Hydrophobic", t[t.MetalCoordination = 7] = "MetalCoordination", t[t.WeakHydrogenBond = 8] = "WeakHydrogenBond";
}(br || (br = {}));
var WO = { distanceMax: z.Numeric(2.8, { min: 1, max: 5, step: 0.1 }), backbone: z.Boolean(!0, { description: "Include backbone-to-backbone hydrogen bonds" }), accAngleDevMax: z.Numeric(90, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal acceptor angle" }), donAngleDevMax: z.Numeric(120, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal donor angle" }), accOutOfPlaneAngleMax: z.Numeric(90, { min: 0, max: 180, step: 1 }), donOutOfPlaneAngleMax: z.Numeric(45, { min: 0, max: 180, step: 1 }) }, jO = O(O({}, WO), { water: z.Boolean(!1, { description: "Include water-to-water hydrogen bonds" }), sulfurDistanceMax: z.Numeric(3.4, { min: 1, max: 5, step: 0.1 }) }), Sae = z.getDefaultValues(jO), ZO = O({}, WO), Cae = z.getDefaultValues(ZO);
function JT(t, e) {
  return t.model.atomicHierarchy.derived.residue.moleculeType[t.residueIndex[t.elements[e]]] === 2;
}
function $T(t, e) {
  return Z9.has(KO(t, e));
}
function QO(t) {
  return { includeBackbone: t.backbone, maxAccAngleDev: qn(t.accAngleDevMax), maxDonAngleDev: qn(t.donAngleDevMax), maxAccOutOfPlaneAngle: qn(t.accOutOfPlaneAngleMax), maxDonOutOfPlaneAngle: qn(t.donOutOfPlaneAngleMax) };
}
function JO(t, e, r, n) {
  var i = e.members[e.offsets[e.feature]], a = r.members[r.offsets[r.feature]];
  if (n.includeBackbone || (o = e.unit, s = i, u = r.unit, c = a, !$T(o, s) || !$T(u, c))) {
    var o, s, u, c, l = D7(t, e.unit, i, r.unit, a);
    if (Ua(l[0]) >= 120 && Ua(l[0]) <= 180) return !0;
  }
}
function Aae(t, e, r, n, i) {
  var a = e.types[e.feature], o = r.types[r.feature];
  if (u = o, (s = a) === 5 && u === 4 || s === 4 && u === 5) {
    var s, u, c, l, d, f, h = o === 5 ? [e, r] : [r, e], m = h[0], p = h[1], v = m.members[m.offsets[m.feature]], g = p.members[p.offsets[p.feature]];
    if (!(n > (kr(m.unit, v) === "S" || kr(p.unit, g) === "S" ? i.maxSulfurDistSq : i.maxDistSq)) && (i.includeWater || (c = m.unit, l = v, d = p.unit, f = g, !JT(c, l) || !JT(d, f))) && JO(t, m, p, i)) return br.HydrogenBond;
  }
}
var wae = Zr.Provider([4], function(t, e, r) {
  for (var n = e.elements, i = e.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = function(d, f) {
    var h = kr(e, d), m = !1;
    h === "H" && (hc(e, d, function(p, v) {
      var g = kr(p, v);
      g !== "N" && g !== "O" && g !== "S" || (m = !0);
    }), m && r.add(4, 0, a[n[d]], o[n[d]], s[n[d]], d));
  }, c = 0, l = n.length; c < l; ++c) u(c);
}), Dae = Zr.Provider([9], function(t, e, r) {
  for (var n = e.elements, i = e.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = function(d, f) {
    var h = kr(e, d), m = !1;
    if (h === "H") {
      var p = [];
      if (hc(e, d, function(g, y) {
        kr(g, y) === "C" && (function(b, S) {
          var _ = b.rings.elementAromaticRingIndices, x = _.get(S);
          return x !== void 0;
        }(g, y) ? m = !0 : p.push(y));
      }), !m && p.length === 1) {
        var v = 0;
        hc(e, p[0], function(g, y) {
          kr(g, y) === "F" && v++;
        }), v === 2 && (m = !0);
      }
      m && r.add(9, 0, a[n[d]], o[n[d]], s[n[d]], d);
    }
  }, c = 0, l = n.length; c < l; ++c) u(c);
}), Eae = Zr.Provider([5], function(t, e, r) {
  for (var n = function(y, b) {
    var S = x2.get(y).value;
    if (!S) throw Error("expected valence model to be available");
    var _ = S.get(b.id);
    if (!_) throw Error("expected valence model for unit to be available");
    return _;
  }(t, e), i = n.charge, a = n.implicitH, o = n.idealGeometry, s = e.elements, u = e.model.atomicConformation, c = u.x, l = u.y, d = u.z, f = function(y) {
    r.add(5, 0, c[s[y]], l[s[y]], d[s[y]], y);
  }, h = 0, m = s.length; h < m; ++h) {
    var p = kr(e, h);
    if (p === "O") f(h);
    else if (p === "N") {
      if (i[h] < 1) {
        var v = t2(t, e, h) + a[h], g = o[h];
        (g === 4 && v < 4 || g === 3 && v < 3 || g === 2 && v < 2) && f(h);
      }
    } else p === "S" ? wx(e, h) === -1 && f(h) : p === "F" && f(h);
  }
}), Iae = { name: "hydrogen-bonds", params: jO, createTester: function(t) {
  var e = Math.max(t.distanceMax, t.sulfurDistanceMax), r = function(n) {
    return O(O({}, QO(n)), { includeWater: n.water, maxSulfurDistSq: n.sulfurDistanceMax * n.sulfurDistanceMax, maxDistSq: n.distanceMax * n.distanceMax });
  }(t);
  return { maxDistance: e, requiredFeatures: /* @__PURE__ */ new Set([4, 5]), getType: function(n, i, a, o) {
    return Aae(n, i, a, o, r);
  } };
} }, Tae = { name: "weak-hydrogen-bonds", params: ZO, createTester: function(t) {
  var e = QO(t);
  return { maxDistance: t.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([9, 5]), getType: function(r, n, i, a) {
    return function(o, s, u, c, l) {
      var d = s.types[s.feature], f = u.types[u.feature];
      if (m = f, (h = d) === 9 && m === 5 || h === 5 && m === 9) {
        var h, m, p = f === 5 ? [s, u] : [u, s];
        if (JO(o, p[0], p[1], l)) return br.WeakHydrogenBond;
      }
    }(r, n, i, 0, e);
  } };
} }, $O = { distanceMax: z.Numeric(3.5, { min: 1, max: 5, step: 0.1 }), angleMax: z.Numeric(60, { min: 0, max: 60, step: 1 }) }, Mae = z.getDefaultValues($O), Pae = ["CL", "BR", "I", "AT"], Bae = qn(180), Fae = qn(120), Nae = Zr.Provider([6], function(t, e, r) {
  for (var n = e.elements, i = e.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = 0, c = n.length; u < c; ++u) {
    var l = kr(e, u);
    Pae.includes(l) && r.add(6, 0, a[n[u]], o[n[u]], s[n[u]], u);
  }
}), Rae = Zr.Provider([7], function(t, e, r) {
  for (var n = function(C, A) {
    var w = x2.get(C).value;
    if (!w) throw Error("expected valence model to be available");
    var I = w.get(A.id);
    if (!I) throw Error("expected valence model for unit to be available");
    return I;
  }(t, e), i = n.charge, a = n.implicitH, o = n.idealGeometry, s = e.elements, u = e.model.atomicConformation, c = u.x, l = u.y, d = u.z, f = function(C) {
    r.add(7, 0, c[s[C]], l[s[C]], d[s[C]], C);
  }, h = 0, m = s.length; h < m; ++h) {
    var p = kr(e, h);
    if (p === "O") f(h);
    else if (p === "N") {
      if (i[h] < 1) {
        var v = t2(t, e, h) + a[h], g = o[h];
        (g === 4 && v < 4 || g === 3 && v < 3 || g === 2 && v < 2) && f(h);
      }
    } else p === "S" ? wx(e, h) === -1 && f(h) : p === "F" && f(h);
  }
  for (var y = 0, b = e.rings.aromaticRings; y < b.length; y++) {
    var S = b[y], _ = e.rings.all[S];
    for (r.startState(), h = 0, m = _.length; h < m; ++h) {
      var x = _[h];
      r.pushMember(c[s[x]], l[s[x]], d[s[x]], x);
    }
    r.finishState(7, 0);
  }
}), Oae = { name: "halogen-bonds", params: $O, createTester: function(t) {
  var e = function(r) {
    return { angleMax: qn(r.angleMax) };
  }(t);
  return { maxDistance: t.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([6, 7]), getType: function(r, n, i) {
    return function(a, o, s, u) {
      var c = o.types[o.feature], l = s.types[s.feature];
      if (f = l, (d = c) === 7 && f === 6 || d === 6 && f === 7) {
        var d, f, h = c === 6 ? [o, s] : [s, o], m = h[0], p = h[1], v = m.members[m.offsets[m.feature]], g = p.members[p.offsets[p.feature]], y = D7(a, m.unit, v, p.unit, g);
        if (y.length === 1 && !(Bae - y[0] > u.angleMax)) {
          var b = D7(a, p.unit, g, m.unit, v);
          if (b.length !== 0 && !b.some(function(S) {
            return Fae - S > u.angleMax;
          })) return br.HalogenBond;
        }
      }
    }(r, n, i, e);
  } };
} }, eL = { distanceMax: z.Numeric(5, { min: 0, max: 8, step: 0.1 }) }, Lae = z.getDefaultValues(eL), tL = { distanceMax: z.Numeric(5.5, { min: 1, max: 8, step: 0.1 }), offsetMax: z.Numeric(2, { min: 0, max: 4, step: 0.1 }), angleDevMax: z.Numeric(30, { min: 0, max: 180, step: 1 }) }, kae = z.getDefaultValues(tL), rL = { distanceMax: z.Numeric(6.6, { min: 1, max: 8, step: 0.1 }), offsetMax: z.Numeric(2, { min: 0, max: 4, step: 0.1 }) }, Gae = z.getDefaultValues(rL);
function nL(t, e) {
  var r = x2.get(t).value;
  if (!r) throw Error("expected valence model to be available");
  var n = r.get(e.id);
  if (!n) throw Error("expected valence model for unit to be available");
  return n;
}
var eM = E(), tM = E(), Rp = E(), Yd = E(), v0 = E(), fv = E();
function M7(t, e) {
  var r = e.unit, n = e.feature, i = e.offsets, a = e.members, o = r.elements, s = i[n];
  return e.unit.conformation.position(o[a[s]], Rp), e.unit.conformation.position(o[a[s + 1]], Yd), e.unit.conformation.position(o[a[s + 2]], v0), E.triangleNormal(t, Rp, Yd, v0);
}
var Jb = qn(180), pv = qn(90), Om = E(), $b = E();
function zae(t, e, r, n, i) {
  var a, o, s = e.types[e.feature], u = r.types[r.feature];
  if (o = u, ((a = s) === 2 && o === 1 || a === 1 && o === 2) && function(c, l, d) {
    for (var f = c.feature, h = c.offsets, m = c.members, p = l.feature, v = l.offsets, g = l.members, y = h[f], b = h[f + 1]; y < b; ++y) {
      var S = m[y];
      c.unit.conformation.position(c.unit.elements[S], eM);
      for (var _ = v[p], x = v[p + 1]; _ < x; ++_) {
        var C = g[_];
        if (l.unit.conformation.position(l.unit.elements[C], tM), E.squaredDistance(eM, tM) < d) return !0;
      }
    }
    return !1;
  }(e, r, i.distanceMaxSq)) return br.Ionic;
}
function Vae(t, e, r, n, i) {
  var a, o, s = e.types[e.feature], u = r.types[r.feature];
  if (o = u, (a = s) === 3 && o === 1 || a === 1 && o === 3) {
    var c = s === 3 ? [e, r] : [r, e], l = c[0], d = c[1];
    M7(Om, l);
    var f = function(h, m, p) {
      return Zr.position(Rp, h), Zr.position(Yd, m), E.sub(v0, Rp, Yd), E.projectOnPlane(fv, v0, p), E.add(fv, fv, Yd), E.distance(fv, Yd);
    }(d, l, Om);
    if (f <= i.offsetMax) return br.CationPi;
  }
}
var Uae = Zr.Provider([2], function(t, e, r) {
  for (var n = nL(t, e).charge, i = e.elements, a = e.model.atomicConformation, o = a.x, s = a.y, u = a.z, c = Qt.transientSegments(e.model.atomicHierarchy.residueAtomSegments, i); c.hasNext; ) for (var l = c.move(), d = l.start, f = l.end, h = function(p) {
    if (n[p] < 0) r.add(2, 0, o[i[p]], s[i[p]], u[i[p]], p);
    else if (kr(e, p) === "O") {
      var v = -1, g = 0;
      if (hc(e, p, function(I, P) {
        kr(e, P) === "C" && (v = P, g++);
      }), g === 1 && v !== -1) {
        var y = /* @__PURE__ */ new Set(), b = 0;
        if (hc(e, v, function(I, P) {
          kr(e, P) === "O" && y.add(P);
        }), y.size === 2) {
          for (var S = e.bonds, _ = !0, x = 0, C = S.a.length; x < C; x++) {
            var A = S.a[x], w = S.b[x];
            y.has(w) && A !== v && kr(e, A) !== "H" && (b = -100), S.edgeProps.order[x] === 2 && w === p && (_ = !1), A === v && y.has(w) && S.edgeProps.order[x] === 2 && b++;
          }
          b === 1 && _ && r.add(2, 0, o[i[p]], s[i[p]], u[i[p]], p);
        }
      }
    }
  }, m = d; m < f; ++m) h(m);
}), Hae = Zr.Provider([1], function(t, e, r) {
  for (var n = nL(t, e).charge, i = e.elements, a = e.model.atomicConformation, o = a.x, s = a.y, u = a.z, c = Qt.transientSegments(e.model.atomicHierarchy.residueAtomSegments, i); c.hasNext; ) for (var l = c.move(), d = l.start, f = l.end, h = function(p) {
    if (n[p] > 0) r.add(1, 0, o[i[p]], s[i[p]], u[i[p]], p);
    else if (kr(e, p) === "N") {
      var v = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
      if (hc(e, p, function(b, S) {
        kr(e, S) === "C" && v.add(S);
      }), !v.size) return "continue";
      v.forEach(function(b) {
        var S = /* @__PURE__ */ new Set();
        hc(e, b, function(_, x) {
          kr(e, x) === "N" ? S.add(x) : v.delete(b);
        }), S.size !== 3 ? v.delete(b) : g.set(b, S);
      });
      var y = !1;
      if (!v.size) return "continue";
      v.forEach(function(b) {
        var S = e.bonds, _ = g.get(b), x = 0;
        if (_) {
          for (var C = function(I, P) {
            var M = S.a[I], T = S.b[I];
            if (M === b && _.has(T) && S.edgeProps.order[I] === 2) {
              T === p && (y = !0);
              var F = !0;
              hc(e, T, function(N, R) {
                R !== b && kr(e, R) !== "H" && (F = !1);
              }), F && _.delete(T), x++;
            }
          }, A = 0, w = S.a.length; A < w; A++) C(A);
          x !== 1 ? v.delete(b) : _.forEach(function(I) {
            var P = !0;
            hc(e, I, function(M, T) {
              T !== b && kr(e, T) !== "H" && (P = !1);
            }), P && _.delete(I);
          }), _.size > 1 && v.delete(b);
        }
      }), v.size && y && r.add(1, 0, o[i[p]], s[i[p]], u[i[p]], p);
    }
  }, m = d; m < f; ++m) h(m);
}), qae = Zr.Provider([3], function(t, e, r) {
  for (var n = e.elements, i = e.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = 0, c = e.rings.aromaticRings; u < c.length; u++) {
    var l = c[u], d = e.rings.all[l];
    r.startState();
    for (var f = 0, h = d.length; f < h; ++f) {
      var m = d[f];
      r.pushMember(a[n[m]], o[n[m]], s[n[m]], m);
    }
    r.finishState(3, 0);
  }
}), Kae = { name: "ionic", params: eL, createTester: function(t) {
  var e = function(r) {
    return { distanceMaxSq: r.distanceMax * r.distanceMax };
  }(t);
  return { maxDistance: t.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([2, 1]), getType: function(r, n, i, a) {
    return zae(0, n, i, 0, e);
  } };
} }, Xae = { name: "pi-stacking", params: tL, createTester: function(t) {
  var e = function(r) {
    return { offsetMax: r.offsetMax, angleDevMax: qn(r.angleDevMax) };
  }(t);
  return { maxDistance: t.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([3]), getType: function(r, n, i, a) {
    return function(o, s, u, c, l) {
      var d, f = s.types[s.feature], h = u.types[u.feature];
      if (d = h, f === 3 && d === 3) {
        M7(Om, s), M7($b, u);
        var m = E.angle(Om, $b);
        Zr.position(Rp, s), Zr.position(Yd, u), E.sub(v0, Rp, Yd);
        var p = E.angle(Om, v0), v = E.angle($b, v0), g = Ua(p > pv ? Jb - p : p), y = Ua(v > pv ? Jb - v : v), b = m <= l.angleDevMax || m >= Jb - l.angleDevMax ? "parallel" : m <= l.angleDevMax + pv && m >= pv - l.angleDevMax ? "t-shaped" : void 0, S = b === "parallel" ? [0, 33] : [0, 30];
        if (b && (g >= S[0] && g <= S[1] || y >= S[0] && y <= S[1])) return br.PiStacking;
      }
    }(0, n, i, 0, e);
  } };
} }, Yae = { name: "cation-pi", params: rL, createTester: function(t) {
  var e = function(r) {
    return { offsetMax: r.offsetMax };
  }(t);
  return { maxDistance: t.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([3, 1]), getType: function(r, n, i, a) {
    return Vae(0, n, i, 0, e);
  } };
} }, iL = { distanceMax: z.Numeric(3, { min: 1, max: 5, step: 0.1 }) }, Wae = z.getDefaultValues(iL), hv = { 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 }, jae = ["LI", "NA", "K", "RB", "CS", "MG", "CA", "SR", "BA", "AL", "GA", "IN", "TL", "SC", "SN", "PB", "BI", "SB", "HG"];
function rM(t) {
  return !Z9.has(t);
}
function Zae(t) {
  return Z9.has(t);
}
function Qae(t) {
  return YJ.has(t);
}
function nM(t, e) {
  return t === 12 ? e === 11 || e === 12 : t === 13 ? e === 10 : void 0;
}
var mv, zh, B1, gr, ja, Pe, St, Jae = Zr.Provider([13, 12], function(t, e, r) {
  for (var n = e.elements, i = e.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = 0, c = n.length; u < c; ++u) {
    var l = kr(e, u), d = 0;
    jae.includes(l) ? d = 13 : (XO(l) || l === "ZN" || l === "CD") && (d = 12), d && r.add(d, 0, a[n[u]], o[n[u]], s[n[u]], u);
  }
}), $ae = Zr.Provider([10, 11], function(t, e, r) {
  for (var n = e.elements, i = e.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = 0, c = n.length; u < c; ++u) {
    var l = kr(e, u), d = lae(e, u), f = KO(e, u), h = !1, m = !1, p = m2.has(d), v = J9.has(d);
    p || v ? p ? l === "O" ? (["ASP", "GLU", "SER", "THR", "TYR", "ASN", "GLN"].includes(d) && rM(f) || Zae(f)) && (h = !0, m = !0) : l !== "S" || d !== "CYS" && d !== "MET" ? l === "N" && d === "HIS" && rM(f) && (h = !0) : (h = !0, m = !0) : v && (l === "O" && Qae(f) ? (h = !0, m = !0) : ["N3", "N4", "N7"].includes(f) ? h = !0 : ["O2", "O4", "O6"].includes(f) && (h = !0, m = !0)) : gae(l) || l === "O" || l === "S" ? (h = !0, m = !0) : l === "N" && (h = !0), h && r.add(11, 0, a[n[u]], o[n[u]], s[n[u]], u), m && r.add(10, 0, a[n[u]], o[n[u]], s[n[u]], u);
  }
}), eoe = { name: "metal-coordination", params: iL, createTester: function(t) {
  return { maxDistance: t.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([13, 12, 10, 11]), getType: function(e, r, n, i) {
    return function(a, o, s, u) {
      var c = o.types[o.feature], l = s.types[s.feature];
      if (nM(c, l) || nM(l, c)) {
        var d = Sp[kr(o.unit, o.members[o.offsets[o.feature]])], f = Sp[kr(s.unit, s.members[s.offsets[s.feature]])];
        if (d && f && hv[d] && hv[f]) {
          var h = hv[d] + hv[f] + 0.5, m = E.create(0, 0, 0), p = E.create(0, 0, 0);
          if (Zr.position(m, o), Zr.position(p, s), E.distance(m, p) > h) return;
        }
        return br.MetalCoordination;
      }
    }(0, r, n);
  } };
} };
(function(t) {
  t.Pdb = "pdb", t.Sdf = "sdf", t.Mol = "mol", t.Mol2 = "mol2", t.MMCif = "mmcif", t.Gro = "gro", t.Xtc = "xtc", t.Dump = "dump", t.Xyz = "xyz", t.Cif = "cif", t.MCif = "mcif", t.POSCAR = "poscar", t.Material = "material", t.Pymatgen = "pymatgen";
})(gr || (gr = {})), function(t) {
  t.Molecular = "Molecular", t.Protein = "Protein", t.Chain = "Chain", t.Residue = "Residue", t.Ligand = "Ligand", t.Solvent = "Solvent", t.Water = "Water", t.Other = "Other", t.Metal = "Metal", t.Ions = "Ions", t.Atom = "Atom";
}(ja || (ja = {})), function(t) {
  t.Ribbon = "Ribbon", t.BallAndStick = "BallAndStick", t.Line = "Line", t.Stick = "Stick", t.CPK = "CPK", t.Label = "Label", t.Distance = "Distance", t.Angle = "Angle", t.Dihedral = "Dihedral", t.IntraInteractions = "IntraInteractions", t.BetweenInteractions = "BetweenInteractions", t.Pharmacophore = "Pharmacophore", t.Pocket = "Pocket", t.Surface = "Surface", t.IsoSurface = "IsoSurface", t.RotateArrow = "RotateArrow", t.MappingLine = "MappingLine", t.UnitCell = "UnitCell", t.CustomLines = "CustomLines", t.CustomPlanes = "CustomPlanes", t.Trajectory = "Trajectory";
}(Pe || (Pe = {})), function(t) {
  t.RIBBON = "Ribbon", t.ATOM = "Atom", t.SURFACE = "Surface";
}(St || (St = {}));
var Fd, Bn = ((mv = {})[St.RIBBON] = [Pe.Ribbon], mv[St.ATOM] = [Pe.CPK, Pe.Line, Pe.Stick, Pe.BallAndStick], mv[St.SURFACE] = [Pe.Surface], mv);
(function(t) {
  t[t.Not = 0] = "Not", t[t.Include = 1] = "Include", t[t.BeIncluded = 2] = "BeIncluded", t[t.Cross = 3] = "Cross";
})(Fd || (Fd = {}));
var Kr;
Pe.Ribbon, Pe.CPK, Pe.Line, Pe.Stick, Pe.BallAndStick, Pe.Surface;
var J1 = /* @__PURE__ */ new Set([Pe.BallAndStick, Pe.Line, Pe.Stick, Pe.CPK]), toe = /* @__PURE__ */ new Set([Pe.BallAndStick, Pe.Line, Pe.Stick]), Op = /* @__PURE__ */ new Set([Pe.Label, Pe.Distance, Pe.Angle, Pe.Dihedral]), roe = /* @__PURE__ */ new Set([Pe.Surface, Pe.Pharmacophore, Pe.Pocket]);
(function(t) {
  t.Atom = "Atom", t.Residue = "Residue", t.Chain = "Chain", t.Molecular = "Molecular";
})(Kr || (Kr = {}));
var oc, noe = ((zh = {})[Kr.Atom] = "element", zh[Kr.Residue] = "residue", zh[Kr.Chain] = "chain", zh[Kr.Molecular] = "entity", zh), ioe = { element: Kr.Atom, residue: Kr.Residue, chain: Kr.Chain, entity: Kr.Molecular };
(function(t) {
  t.HydrogenBonds = "hydrogen-bonds", t.WeakHydrogenBonds = "weak-hydrogen-bonds", t.HalogenBonds = "halogen-bonds", t.SaltBridge = "ionic", t.PiPiStacking = "pi-stacking", t.PiCations = "cation-pi", t.MetalBonds = "metal-coordination", t.Hydrophobic = "hydrophobic";
})(oc || (oc = {}));
var a0, P7 = function(t) {
  var e, r = ((e = {})[oc.HydrogenBonds] = { name: "on", params: Sae }, e[oc.WeakHydrogenBonds] = { name: "off", params: Cae }, e[oc.HalogenBonds] = { name: "on", params: Mae }, e[oc.SaltBridge] = { name: "on", params: Lae }, e[oc.PiPiStacking] = { name: "on", params: kae }, e[oc.PiCations] = { name: "on", params: Gae }, e[oc.MetalBonds] = { name: "on", params: Wae }, e[oc.Hydrophobic] = { name: "off", params: {} }, e);
  return t && Object.keys(r).forEach(function(n) {
    r[n].name = t.includes(n) ? "on" : "off";
  }), r;
};
(function(t) {
  t[t.All = 0] = "All", t[t.Residues = 1] = "Residues", t[t.Water = 2] = "Water", t[t.SolventWithoutWater = 3] = "SolventWithoutWater", t[t.Solvent = 4] = "Solvent";
})(a0 || (a0 = {}));
var Lm, Oi, l0, aoe = ((B1 = {})[a0.All] = [ja.Protein, ja.Water, ja.Ligand, ja.Solvent], B1[a0.Residues] = [ja.Protein], B1[a0.Water] = [ja.Water], B1[a0.SolventWithoutWater] = [ja.Solvent], B1[a0.Solvent] = [ja.Water, ja.Solvent], B1);
(function(t) {
  t.Structure = "Structure", t.Measurement = "Measurement", t.Interaction = "Interaction", t.Bond = "Bond";
})(Lm || (Lm = {})), function(t) {
  t[t.NotHydrogen = -1] = "NotHydrogen", t[t.NonPolar = 0] = "NonPolar", t[t.Polar = 1] = "Polar", t[t.ConnectPolar = 2] = "ConnectPolar", t[t.ConnectNonPolar = 3] = "ConnectNonPolar";
}(Oi || (Oi = {})), function(t) {
  t.Drug = "drug", t.Material = "material";
}(l0 || (l0 = {}));
var Oa = function(t) {
  if (t.kind === "element-loci") return t;
  if (t.kind === "structure-loci") return tt.toStructureElementLoci(t.structure);
  if (t.kind === "shape-loci") {
    var e, r = t.shape.sourceData, n = [];
    return r.infos ? n.push.apply(n, Ze([], r.infos, !0).map(function(i) {
      return i.loci;
    })) : r.pairs ? n.push.apply(n, r.pairs[0].loci) : r.triples ? n.push.apply(n, r.triples[0].loci) : r.quads && n.push.apply(n, r.quads[0].loci), n.forEach(function(i) {
      e = e ? Xe.union(e, Oa(i)) : Oa(i);
    }), e;
  }
}, pi = function(t, e) {
  var r = [], n = new Set(e), i = /* @__PURE__ */ new Set();
  return t.units.forEach(function(a) {
    if (!i.has(a.invariantId)) {
      i.add(a.invariantId);
      var o = [];
      a.elements.forEach(function(s, u) {
        e && !n.has(s) || o.push(u);
      }), o.length > 0 && r.push({ unit: a, indices: o });
    }
  }), Xe(t, r);
}, oa = function(t) {
  var e = [];
  return t.elements.forEach(function(r) {
    e.push.apply(e, Ge.toArray(r.indices).map(function(n) {
      return r.unit.elements[n];
    }).filter(function(n) {
      return n !== void 0;
    }));
  }), e;
}, ooe = function(t, e) {
  var r, n = D0.ofLoci(t);
  r = n.elementCount > 0 ? n.firstElementLoc : n.residueCount > 0 ? n.firstResidueLoc : n.chainCount > 0 ? n.firstChainLoc : n.unitCount > 0 ? n.firstUnitLoc : n.conformationCount > 0 ? n.firstConformationLoc : n.firstStructureLoc;
  var i = Qe.atom.em_confidence(r), a = Qe.atom.B_iso_or_equiv(r);
  switch (e) {
    case Kr.Atom:
      return n.elementCount === 1 ? { x: Qe.atom.x(r), y: Qe.atom.y(r), z: Qe.atom.z(r), granularity: Kr.Atom, atomName: Qe.atom.label_atom_id(r), atomId: Qe.atom.id(r), altId: Qe.atom.label_alt_id(r), residueName: Qe.atom.label_comp_id(r), residueId: Qe.residue.auth_seq_id(r), insertCode: Qe.residue.pdbx_PDB_ins_code(r), chainId: Qe.chain.label_asym_id(r), emConfidence: i, bfactor: a } : { granularity: Kr.Residue, altId: Qe.atom.label_alt_id(r), residueName: Qe.atom.label_comp_id(r), residueId: Qe.residue.auth_seq_id(r), chainId: Qe.chain.label_asym_id(r), insertCode: Qe.residue.pdbx_PDB_ins_code(r), emConfidence: i, bfactor: a };
    case Kr.Residue:
      return { granularity: Kr.Residue, altId: Qe.atom.label_alt_id(r), residueName: Qe.atom.label_comp_id(r), residueId: Qe.residue.auth_seq_id(r), chainId: Qe.chain.label_asym_id(r), insertCode: Qe.residue.pdbx_PDB_ins_code(r), bfactor: a };
    case Kr.Chain:
      return { granularity: Kr.Chain, chainId: Qe.chain.label_asym_id(r) };
    case Kr.Molecular:
      return { granularity: Kr.Molecular };
    default:
      return {};
  }
}, soe = function(t) {
  var e = t.elements[0], r = e.unitA, n = e.indexA, i = e.unitB, a = e.indexB, o = t.data.interactions, s = o.contacts, u = o.unitsContacts, c = o.unitsFeatures, l = c.get(r.id), d = l.members, f = l.offsets, h = c.get(i.id), m = h.members, p = h.offsets, v = -1;
  if (r === i) {
    var g = u.get(r.id), y = g.getDirectedEdgeIndex(n, a);
    v = g.edgeProps.type[y];
  } else
    y = s.getEdgeIndex(n, r.id, a, i.id), v = s.edges[y].props.type;
  var b = Dt.Location(t.data.structure, r, d[f[n]], t.data.structure, i, m[p[a]]), S = Xe(b.aStructure, [{ unit: b.aUnit, indices: Ge.ofSingleton(b.aIndex) }]), _ = Xe(b.bStructure, [{ unit: b.bUnit, indices: Ge.ofSingleton(b.bIndex) }]), x = D0.ofLoci(S), C = D0.ofLoci(_), A = x.firstElementLoc, w = C.firstElementLoc;
  return { infoA: { chainId: Qe.chain.label_asym_id(A), residueName: Qe.atom.label_comp_id(A), residueId: Qe.residue.auth_seq_id(A), atomName: Qe.atom.label_atom_id(A) }, infoB: { chainId: Qe.chain.label_asym_id(w), residueName: Qe.atom.label_comp_id(w), residueId: Qe.residue.auth_seq_id(w), atomName: Qe.atom.label_atom_id(w) }, interactionType: T7(v) };
}, uoe = function(t) {
  return fetch(t).then(function(e) {
    return e.text();
  });
}, coe = function(t) {
  return fetch(t).then(function(e) {
    return e.blob();
  });
}, loe = function(t) {
  return new Promise(function(e) {
    var r = new FileReader();
    r.onload = function(n) {
      return _e(this, 0, void 0, function() {
        return ye(this, function(i) {
          return e(r.result), [2];
        });
      });
    }, r.readAsText(t);
  });
}, y0 = function(t) {
  return _e(void 0, 0, void 0, function() {
    var e, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return typeof t != "string" ? [3, 4] : t.startsWith("http") || t.startsWith("https") ? [4, uoe(t)] : [3, 2];
        case 1:
          return r = n.sent(), [3, 3];
        case 2:
          r = t, n.label = 3;
        case 3:
          return e = r, [3, 6];
        case 4:
          return [4, loe(t)];
        case 5:
          e = n.sent(), n.label = 6;
        case 6:
          return [2, e];
      }
    });
  });
}, doe = function(t) {
  return _e(void 0, 0, void 0, function() {
    var e, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return typeof t != "string" ? [3, 2] : [4, coe(t)];
        case 1:
          return e = n.sent(), [3, 4];
        case 2:
          return r = Blob.bind, [4, t.arrayBuffer()];
        case 3:
          e = new (r.apply(Blob, [void 0, [n.sent()]]))(), n.label = 4;
        case 4:
          return [2, e];
      }
    });
  });
};
function foe(t, e, r) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(n) {
      return [2, new Promise(function(i, a) {
        var o = function(p) {
          p ? i(p) : a("no blob returned");
        };
        if (HTMLCanvasElement.prototype.toBlob) t.toBlob(o, e, r);
        else {
          for (var s = atob(t.toDataURL(e, r).split(",")[1]), u = s.length, c = u >> 2, l = new Uint8Array(u), d = new Uint32Array(l.buffer, 0, c), f = 0, h = 0; h < c; ++h) d[h] = s.charCodeAt(f++) | s.charCodeAt(f++) << 8 | s.charCodeAt(f++) << 16 | s.charCodeAt(f++) << 24;
          for (var m = 3 & u; m--; ) l[f] = s.charCodeAt(f++);
          o(new Blob([l], { type: e }));
        }
      })];
    });
  });
}
var poe = 1 / 0;
function aL(t, e, r, n, i) {
  var a = -1, o = t.length;
  for (r || (r = Array.isArray), i || (i = []); ++a < o; ) {
    var s = t[a];
    r(s) ? aL(s, e - 1, r, n, i) : i[i.length] = s;
  }
  return i;
}
function oL(t) {
  return t != null && t.length ? aL(t, poe) : [];
}
var e8 = function(t, e) {
  for (var r = [], n = 0, i = e.length; n < i; n++) {
    var a = e[n], o = a.start, s = a.end;
    a.regular.test(t.slice(o, s)) || r.push({ start: o, end: s });
  }
  return r;
}, r2 = function(t) {
  return t.length > 2 || t.length === 0 ? t : "".concat(t[0].toLocaleUpperCase()).concat(t.length === 2 ? t[1].toLocaleLowerCase() : "");
}, t8 = { 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" }, hoe = { 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" }, moe = [{ 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]+/ }], goe = [{ start: 0, end: 3, regular: /\s*[\d]+/ }, { start: 3, end: 6, regular: /\s*[\d]+/ }, { start: 6, end: 9, regular: /\s*[\d]+/ }], voe = [{ start: 0, end: 3, regular: /\s*[\d]+/ }, { start: 3, end: 6, regular: /\s*[\d]+/ }], sL = { Dihedral: Pe.Dihedral, Distance: Pe.Distance, Angle: Pe.Angle, Label: Pe.Label, "Molecular Surface": Pe.Surface, "Ball & Stick": Pe.BallAndStick, Line: Pe.Line, Stick: Pe.Stick, Spacefill: Pe.CPK, Cartoon: Pe.Ribbon }, uL = function(t, e, r) {
  var n, i = e[0], a = i.residueName, o = i.residueId, s = i.isEutectic, u = e.map(function(h) {
    return h.elementId;
  }), c = pi(t, u), l = D0.ofLoci(c);
  n = l.elementCount > 0 ? l.firstElementLoc : l.residueCount > 0 ? l.firstResidueLoc : l.chainCount > 0 ? l.firstChainLoc : l.unitCount > 0 ? l.firstUnitLoc : l.conformationCount > 0 ? l.firstConformationLoc : l.firstStructureLoc;
  var d, f = (d = Qe.residue.secondary_structure_type(n), _r.is(d, 2) ? "helix" : _r.is(d, 4) ? "sheet" : _r.is(d, 16) ? "turn" : _r.is(d, 8) ? "bend" : "none");
  return { residueNum: o, residueName: a.toUpperCase(), standardResidueName: t8[a.toUpperCase()], oneLetter: s ? "X" : hoe[t8[a.toUpperCase()]] || t8[a.toUpperCase()] || "X", elementIds: e.map(function(h) {
    return h.elementId;
  }), secondaryStructureType: f, secondaryStructureTypeInfo: Qe.residue.secondary_structure_type(n), secondaryStructureTypeKey: Qe.residue.secondary_structure_key(n), insCode: Qe.residue.pdbx_PDB_ins_code(n), index: r };
}, Dx = /* @__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"]), Ex = /* @__PURE__ */ new Set(["EOH", "GOL", "DMS", "PEG", "POL", "IOH", "DIO", "ACN", "SBT", "1BO", "CCN", "DMS", "GBL", "P2K", "MPD", "PGQ", "SEO"]), yo = function(t, e, r) {
  r === void 0 && (r = !1);
  var n = r ? "".concat(e.residueId, "_").concat(e.insertCode) : e.residueId;
  t[e.chainId] ? t[e.chainId][n] = (t[e.chainId][n] ? t[e.chainId][n] : []).concat(e) : (t[e.chainId] = {}, t[e.chainId][n] = [e]);
}, cL = function(t) {
  var e = {}, r = {}, n = {}, i = {}, a = {}, o = {}, s = {}, u = {}, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
  t.units.forEach(function(v) {
    var g;
    v.elements.forEach(function(x) {
      var C = Ac(v, x);
      if (Zp.has(C.residueName.toUpperCase())) yo(r, C);
      else if (Dx.has(C.typeSymbol.toUpperCase())) yo(i, C);
      else if (Ex.has(C.residueName.toUpperCase())) yo(n, C);
      else if (h2.has(C.residueName.toUpperCase())) yo(a, C);
      else {
        if (C.groupPDB === "ATOM" && !["UNK", "MOL"].includes(C.residueName)) return yo(e, C, !0), void c.add(C.elementId);
        if (C.groupPDB === "HETATM" || ["UNK", "MOL"].includes(C.residueName)) {
          var A = "".concat(C.chainId, "_").concat(C.residueId);
          l.set(A, l.has(A) ? Ze(Ze([], l.get(A), !0), [C], !1) : [C]);
        } else yo(s, C);
      }
    });
    for (var y = 0, b = v.bonds.a.length; y < b; y++) {
      var S = v.elements[v.bonds.a[y]], _ = v.elements[v.bonds.b[y]];
      d.has(S) ? (g = d.get(S)) === null || g === void 0 || g.add(_) : d.set(S, /* @__PURE__ */ new Set([_]));
    }
  }), l.forEach(function(v) {
    var g = !1;
    new Set(v.map(function(y) {
      return y.elementId;
    })).forEach(function(y) {
      if (d.has(y)) {
        var b = d.get(y);
        b == null || b.forEach(function(S) {
          c.has(S) && (g = !0);
        });
      }
    }), v.forEach(function(y) {
      g ? (Object.assign(y, { isEutectic: !0 }), yo(o, y)) : yo(s, y);
    });
  });
  var f = {};
  Object.keys(s).forEach(function(v) {
    var g = s[v];
    Object.keys(g).forEach(function(y) {
      var b = g[y], S = b.filter(function(_) {
        return _.typeSymbol !== "H";
      });
      S.length > 10 && S.length < 150 ? (u[v] || (u[v] = {}), u[v][y] = b) : (f[v] || (f[v] = {}), f[v][y] = b);
    });
  });
  var h = {};
  Object.keys(e).forEach(function(v) {
    var g;
    h[v] || (h[v] = []), (g = h[v]).push.apply(g, Object.values(e[v]));
  }), Object.keys(o).forEach(function(v) {
    var g = o[v];
    Object.keys(g).forEach(function(y) {
      var b = g[y];
      f[v] || (f[v] = {}), h[v] || (h[v] = []), h[v].push(b), f[v][y] = b;
    });
  });
  var m = 0, p = {};
  return Object.keys(h).forEach(function(v) {
    p[v] = {}, h[v].sort(function(g, y) {
      return g[0].residueId !== y[0].residueId ? g[0].residueId - y[0].residueId : g[0].insertCode.localeCompare(y[0].insertCode);
    }).forEach(function(g) {
      p[g[0].chainId]["".concat(g[0].residueId, "_").concat(g[0].insertCode)] = uL(t, g, m++);
    });
  }), { data: { polymer: e, water: r, otherSolvent: n, metal: i, ion: a, ligand: u, other: f }, extraData: { sequenceData: p } };
}, yoe = function(t) {
  var e = {}, r = {}, n = {}, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
  t.units.forEach(function(d) {
    var f;
    d.elements.forEach(function(g) {
      var y = Ac(d, g);
      if (!(Zp.has(y.residueName.toUpperCase()) || Dx.has(y.typeSymbol.toUpperCase()) || Ex.has(y.residueName.toUpperCase()) || h2.has(y.residueName.toUpperCase()))) {
        if (y.groupPDB === "ATOM" && !["UNK", "MOL"].includes(y.residueName)) return yo(e, y, !0), void i.add(y.elementId);
        if (y.groupPDB === "HETATM" || ["UNK", "MOL"].includes(y.residueName)) {
          var b = "".concat(y.chainId, "_").concat(y.residueId);
          a.set(b, a.has(b) ? Ze(Ze([], a.get(b), !0), [y], !1) : [y]);
        } else yo(n, y);
      }
    });
    for (var h = 0, m = d.bonds.a.length; h < m; h++) {
      var p = d.elements[d.bonds.a[h]], v = d.elements[d.bonds.b[h]];
      o.has(p) ? (f = o.get(p)) === null || f === void 0 || f.add(v) : o.set(p, /* @__PURE__ */ new Set([v]));
    }
  }), a.forEach(function(d) {
    var f = !1;
    new Set(d.map(function(h) {
      return h.elementId;
    })).forEach(function(h) {
      if (o.has(h)) {
        var m = o.get(h);
        m == null || m.forEach(function(p) {
          i.has(p) && (f = !0);
        });
      }
    }), d.forEach(function(h) {
      f ? (Object.assign(h, { isEutectic: !0 }), yo(r, h)) : yo(n, h);
    });
  });
  var s = {};
  Object.keys(n).forEach(function(d) {
    var f = n[d];
    Object.keys(f).forEach(function(h) {
      var m = f[h], p = m.filter(function(v) {
        return v.typeSymbol !== "H";
      });
      p.length <= 10 && p.length < 150 && (s[d] || (s[d] = {}), s[d][h] = m);
    });
  });
  var u = {};
  Object.keys(e).forEach(function(d) {
    var f;
    u[d] || (u[d] = []), (f = u[d]).push.apply(f, Object.values(e[d]));
  }), Object.keys(r).forEach(function(d) {
    var f = r[d];
    Object.keys(f).forEach(function(h) {
      var m = f[h];
      s[d] || (s[d] = {}), u[d] || (u[d] = []), u[d].push(m), s[d][h] = m;
    });
  });
  var c = 0, l = {};
  return Object.keys(u).forEach(function(d) {
    l[d] = {}, u[d].sort(function(f, h) {
      return f[0].residueId !== h[0].residueId ? f[0].residueId - h[0].residueId : f[0].insertCode.localeCompare(h[0].insertCode);
    }).forEach(function(f) {
      l[f[0].chainId]["".concat(f[0].residueId, "_").concat(f[0].insertCode)] = uL(t, f, c++);
    });
  }), l;
}, ry = function(t, e) {
  switch (e) {
    case Kr.Atom:
      return "".concat(t.elementId);
    case Kr.Residue:
      return "".concat(t.chainId, "_").concat(t.residueName, "_").concat(t.residueId);
    case Kr.Chain:
      return "".concat(t.chainId);
    case Kr.Molecular:
      return "".concat(t.unitId);
  }
  return "";
}, boe = function(t, e) {
  switch (e) {
    case Kr.Atom:
      return t;
    case Kr.Residue:
      return { unitId: t.unitId, chainId: t.chainId, groupPDB: t.groupPDB, residueId: t.residueId, residueName: t.residueName };
    case Kr.Chain:
      return { unitId: t.unitId, chainId: t.chainId };
    case Kr.Molecular:
      return { unitId: t.unitId };
  }
  return {};
};
function lL(t, e, r) {
  var n = this;
  return r === void 0 && (r = !1), tr.create("Parse PDB", function(i) {
    return _e(n, 0, void 0, function() {
      var a, o, s;
      return ye(this, function(u) {
        switch (u.label) {
          case 0:
            return o = (a = ji).success, s = {}, [4, ot.readAllLinesAsync(t, i)];
          case 1:
            return [2, o.apply(a, [(s.lines = u.sent(), s.id = e, s.isPdbqt = r, s)])];
        }
      });
    });
  });
}
function _oe(t, e) {
  var r = function(a, o) {
    return (e.substr(a, o) || "").trim();
  }, n = { entry_id: ut.ofString(t), length_a: ut.ofString(r(6, 9)), length_b: ut.ofString(r(15, 9)), length_c: ut.ofString(r(24, 9)), angle_alpha: ut.ofString(r(33, 7)), angle_beta: ut.ofString(r(40, 7)), angle_gamma: ut.ofString(r(47, 7)), Z_PDB: ut.ofString(r(66, 4)), pdbx_unique_axis: ut.ofString("?") }, i = { entry_id: ut.ofString(t), "space_group_name_H-M": ut.ofString(r(55, 11)), Int_Tables_number: ut.ofString("?"), cell_setting: ut.ofString("?"), space_group_name_Hall: ut.ofString("?") };
  return [La.ofFields("cell", n), La.ofFields("symmetry", i)];
}
function iM(t, e) {
  return { id: t, details: e, groups: [] };
}
function xoe(t, e, r) {
  for (var n, i, a, o = [], s = 1, u = 1, c = function(Y) {
    return t.data.substring(t.indices[2 * Y], t.indices[2 * Y + 1]);
  }, l = e; l < r; l++) {
    var d = c(l);
    if (d.substr(11, 12) === "BIOMOLECULE:") {
      var f = d.substr(23).trim(), h = "Biomolecule ".concat(f);
      (d = c(l + 1)).substr(11, 30) !== "APPLY THE FOLLOWING TO CHAINS:" && (l++, h = d.substr(11).trim()), n = iM(f, h), o.push(n);
    } else if (d.substr(13, 5) === "BIOMT") {
      var m = d.split(/\s+/);
      (H = parseInt(d[18]) - 1) === 0 && (a = he.identity(), i.operators.push({ id: s++, matrix: a })), he.setValue(a, H, 0, parseFloat(m[4])), he.setValue(a, H, 1, parseFloat(m[5])), he.setValue(a, H, 2, parseFloat(m[6])), he.setValue(a, H, 3, parseFloat(m[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: [] }, n.groups.push(i));
      for (var p = 0, v = (g = d.substr(41, 30).split(",")).length; p < v; ++p)
        (y = g[p].trim()) && i.chains.push(y);
    } else if (d.substr(11, 33) === "APPLYING THE FOLLOWING TO CHAINS:") {
      n = iM("".concat(u), "Biomolecule ".concat(u)), o.push(n), u += 1, i = { chains: [], operators: [] }, n.groups.push(i);
      var g;
      for (p = 0, v = (g = (d = c(++l)).substr(11, 69).split(",")).length; p < v; ++p) {
        var y;
        (y = g[p].trim()) && i.chains.push(y);
      }
    }
  }
  if (o.length === 0) return [];
  for (var b = { id: ut.ofStrings(o.map(function(Y) {
    return Y.id;
  })), details: ut.ofStrings(o.map(function(Y) {
    return Y.details;
  })) }, S = [], _ = 0, x = o; _ < x.length; _++) for (var C = 0, A = (F = x[_]).groups; C < A.length; C++) {
    var w = A[C];
    S.push({ assembly_id: F.id, oper_expression: w.operators.map(function(Y) {
      return Y.id;
    }).join(","), asym_id_list: w.chains.join(",") });
  }
  for (var I = { assembly_id: ut.ofStrings(S.map(function(Y) {
    return Y.assembly_id;
  })), oper_expression: ut.ofStrings(S.map(function(Y) {
    return Y.oper_expression;
  })), asym_id_list: ut.ofStrings(S.map(function(Y) {
    return Y.asym_id_list;
  })) }, P = [], M = 0, T = o; M < T.length; M++) for (var F, N = 0, R = (F = T[M]).groups; N < R.length; N++) for (var L = 0, V = R[N].operators; L < V.length; L++) {
    var U = V[L], H = { id: "" + U.id, type: "?", name: "?", symmetry_operation: "?" };
    for (l = 0; l < 3; l++) {
      for (p = 0; p < 3; p++) H["matrix[".concat(l + 1, "][").concat(p + 1, "]")] = "" + he.getValue(U.matrix, l, p);
      H["vector[".concat(l + 1, "]")] = "" + he.getValue(U.matrix, l, 3);
    }
    P.push(H);
  }
  var K = { id: ut.ofStrings(P.map(function(Y) {
    return Y.id;
  })), type: ut.ofStrings(P.map(function(Y) {
    return Y.type;
  })), name: ut.ofStrings(P.map(function(Y) {
    return Y.name;
  })), symmetry_operation: ut.ofStrings(P.map(function(Y) {
    return Y.symmetry_operation;
  })) }, X = function(Y) {
    for (var Q = function(W) {
      var j = "matrix[".concat(Y + 1, "][").concat(W + 1, "]");
      K[j] = ut.ofStrings(P.map(function(ee) {
        return ee[j];
      }));
    }, J = 0; J < 3; J++) Q(J);
    var te = "vector[".concat(Y + 1, "]");
    K[te] = ut.ofStrings(P.map(function(W) {
      return W[te];
    }));
  };
  for (l = 0; l < 3; l++) X(l);
  return [La.ofFields("pdbx_struct_assembly", b), La.ofFields("pdbx_struct_assembly_gen", I), La.ofFields("pdbx_struct_oper_list", K)];
}
function Soe(t, e, r) {
  for (var n, i = [], a = function(y) {
    return t.data.substring(t.indices[2 * y], t.indices[2 * y + 1]);
  }, o = e; o < r; o++) {
    var s = a(o), u = s.split(/\s+/);
    (m = parseInt(s[5]) - 1) === 0 && (n = he.identity(), i.push(n)), he.setValue(n, m, 0, parseFloat(u[2])), he.setValue(n, m, 1, parseFloat(u[3])), he.setValue(n, m, 2, parseFloat(u[4])), he.setValue(n, m, 3, parseFloat(u[5]));
  }
  if (i.length === 0) return [];
  for (var c = [], l = 1, d = 0, f = i; d < f.length; d++) {
    var h = f[d], m = { id: "ncsop" + l++, code: ".", details: "." };
    for (o = 0; o < 3; o++) {
      for (var p = 0; p < 3; p++) m["matrix[".concat(o + 1, "][").concat(p + 1, "]")] = "" + he.getValue(h, o, p);
      m["vector[".concat(o + 1, "]")] = "" + he.getValue(h, o, 3);
    }
    c.push(m);
  }
  var v = { id: ut.ofStrings(c.map(function(y) {
    return y.id;
  })), code: ut.ofStrings(c.map(function(y) {
    return y.code;
  })), details: ut.ofStrings(c.map(function(y) {
    return y.details;
  })) }, g = function(y) {
    for (var b = function(x) {
      var C = "matrix[".concat(y + 1, "][").concat(x + 1, "]");
      v[C] = ut.ofStrings(c.map(function(A) {
        return A[C];
      }));
    }, S = 0; S < 3; S++) b(S);
    var _ = "vector[".concat(y + 1, "]");
    v[_] = ut.ofStrings(c.map(function(x) {
      return x[_];
    }));
  };
  for (o = 0; o < 3; o++) g(o);
  return [La.ofFields("struct_ncs_oper", v)];
}
var Coe = { 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 Aoe(t, e, r) {
  for (var n = [], i = function(f) {
    return t.data.substring(t.indices[2 * f], t.indices[2 * f + 1]);
  }, a = e; a < r; a++) {
    var o = i(a);
    n.push({ serNum: o.substr(7, 3).trim(), helixID: o.substr(11, 3).trim(), initResName: o.substr(15, 3).trim(), initChainID: o.substr(19, 1).trim(), initSeqNum: o.substr(21, 4).trim(), initICode: o.substr(25, 1).trim(), endResName: o.substr(27, 3).trim(), endChainID: o.substr(31, 3).trim(), endSeqNum: o.substr(33, 4).trim(), endICode: o.substr(37, 1).trim(), helixClass: o.substr(38, 2).trim(), comment: o.substr(40, 30).trim(), length: o.substr(71, 5).trim() });
  }
  var s = ut.ofStrings(n.map(function(f) {
    return f.initChainID;
  })), u = ut.ofStrings(n.map(function(f) {
    return f.initResName;
  })), c = ut.ofStrings(n.map(function(f) {
    return f.endChainID;
  })), l = ut.ofStrings(n.map(function(f) {
    return f.endResName;
  })), d = { beg_label_asym_id: s, beg_label_comp_id: u, beg_label_seq_id: ut.ofUndefined(n.length, se.Schema.int), beg_auth_asym_id: s, beg_auth_comp_id: u, beg_auth_seq_id: ut.ofStrings(n.map(function(f) {
    return f.initSeqNum;
  })), conf_type_id: ut.ofStrings(n.map(function(f) {
    return function(h) {
      return Coe[h] || "HELX_P";
    }(f.helixClass);
  })), details: ut.ofStrings(n.map(function(f) {
    return f.comment;
  })), end_label_asym_id: c, end_label_comp_id: l, end_label_seq_id: ut.ofUndefined(n.length, se.Schema.int), end_auth_asym_id: c, end_auth_comp_id: l, end_auth_seq_id: ut.ofStrings(n.map(function(f) {
    return f.endSeqNum;
  })), id: ut.ofStrings(n.map(function(f) {
    return f.serNum;
  })), pdbx_beg_PDB_ins_code: ut.ofStrings(n.map(function(f) {
    return f.initICode;
  })), pdbx_end_PDB_ins_code: ut.ofStrings(n.map(function(f) {
    return f.endICode;
  })), pdbx_PDB_helix_class: ut.ofStrings(n.map(function(f) {
    return f.helixClass;
  })), pdbx_PDB_helix_length: ut.ofStrings(n.map(function(f) {
    return f.length;
  })), pdbx_PDB_helix_id: ut.ofStrings(n.map(function(f) {
    return f.helixID;
  })) };
  return La.ofFields("struct_conf", d);
}
function woe(t, e, r) {
  for (var n = [], i = function(m) {
    return t.data.substring(t.indices[2 * m], t.indices[2 * m + 1]);
  }, a = e; a < r; a++) {
    var o = i(a);
    n.push({ strand: o.substr(7, 3).trim(), sheetID: o.substr(11, 3).trim(), numStrands: o.substr(14, 2).trim(), initResName: o.substr(17, 3).trim(), initChainID: o.substr(21, 1).trim(), initSeqNum: o.substr(22, 4).trim(), initICode: o.substr(26, 1).trim(), endResName: o.substr(28, 3).trim(), endChainID: o.substr(32, 1).trim(), endSeqNum: o.substr(33, 4).trim(), endICode: o.substr(37, 1).trim(), sense: o.substr(38, 2).trim(), curAtom: o.substr(41, 4).trim(), curResName: o.substr(45, 3).trim(), curChainId: o.substr(49, 1).trim(), curResSeq: o.substr(50, 4).trim(), curICode: o.substr(54, 1).trim(), prevAtom: o.substr(56, 4).trim(), prevResName: o.substr(60, 3).trim(), prevChainId: o.substr(64, 1).trim(), prevResSeq: o.substr(65, 4).trim(), prevICode: o.substr(69, 1).trim() });
  }
  var s = ut.ofStrings(n.map(function(m) {
    return m.initChainID;
  })), u = ut.ofStrings(n.map(function(m) {
    return m.initResName;
  })), c = ut.ofStrings(n.map(function(m) {
    return m.initSeqNum;
  })), l = ut.ofStrings(n.map(function(m) {
    return m.endChainID;
  })), d = ut.ofStrings(n.map(function(m) {
    return m.endResName;
  })), f = ut.ofStrings(n.map(function(m) {
    return m.endSeqNum;
  })), h = { beg_label_asym_id: s, beg_label_comp_id: u, beg_label_seq_id: c, beg_auth_asym_id: s, beg_auth_comp_id: u, beg_auth_seq_id: c, end_label_asym_id: l, end_label_comp_id: l, end_label_seq_id: f, end_auth_asym_id: l, end_auth_comp_id: d, end_auth_seq_id: f, id: ut.ofStrings(n.map(function(m) {
    return m.strand;
  })), sheet_id: ut.ofStrings(n.map(function(m) {
    return m.sheetID;
  })), pdbx_beg_PDB_ins_code: ut.ofStrings(n.map(function(m) {
    return m.initICode;
  })), pdbx_end_PDB_ins_code: ut.ofStrings(n.map(function(m) {
    return m.endICode;
  })) };
  return La.ofFields("struct_sheet_range", h);
}
var Doe = { MOL_ID: "", MOLECULE: "", CHAIN: "", FRAGMENT: "", SYNONYM: "", EC: "", ENGINEERED: "", MUTATION: "", OTHER_DETAILS: "" };
function Eoe(t, e, r) {
  for (var n, i = function(b) {
    return t.data.substring(t.indices[2 * b], t.indices[2 * b + 1]);
  }, a = { chains: [], description: "" }, o = [], s = e; s < r; s++) {
    var u = i(s).substr(10, 70).trim(), c = u.indexOf(":"), l = u.substring(0, c), d = void 0;
    l in Doe ? (n = l, d = u.substring(c + 2)) : d = u, d = d.replace(/;$/, ""), n === "MOL_ID" ? (a = { chains: [], description: "" }, o.push(a)) : n === "MOLECULE" ? (a.description && (a.description += " "), a.description += d) : n === "CHAIN" && Array.prototype.push.apply(a.chains, d.split(/\s*,\s*/));
  }
  for (var f = [], h = 0, m = o; h < m.length; h++) for (var p = m[h], v = 0, g = p.chains; v < g.length; v++) {
    var y = g[v];
    f.push({ description: p.description, chains: [y] });
  }
  return f;
}
function Ioe(t, e, r) {
  for (var n = function(c) {
    return t.data.substring(t.indices[2 * c], t.indices[2 * c + 1]);
  }, i = /* @__PURE__ */ new Map(), a = e; a < r; a++) {
    var o = n(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 Toe = [/* @__PURE__ */ new Set(["CA"]), /* @__PURE__ */ new Set(["C"]), /* @__PURE__ */ new Set(["N"])], Moe = [/* @__PURE__ */ new Set(["P", "O3'", "O3*"]), /* @__PURE__ */ new Set(["C4'", "C4*"]), /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])], Poe = [/* @__PURE__ */ new Set(["P", "O3'", "O3*"]), /* @__PURE__ */ new Set(["C3'", "C3*"]), /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])], Boe = /* @__PURE__ */ new Set(["FMN", "NCN", "FNS", "FMA", "ATP", "ADP", "AMP", "GTP", "GDP", "GMP"]), aM = function() {
  var t = /* @__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(e) {
    return t.set(e.id, e);
  }), t;
}(), oM = function() {
  var t = /* @__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(e) {
    return t.set(e.id, e);
  }), t;
}(), L0 = function() {
  function t(e, r) {
    this.seqId = e, this.atomId = r, this.namesMap = /* @__PURE__ */ new Map(), this.comps = /* @__PURE__ */ new Map(), this.ids = [], this.names = [], this.types = [], this.mon_nstd_flags = [];
  }
  return t.prototype.set = function(e) {
    this.comps.set(e.id, e), this.ids.push(e.id), this.names.push(e.name), this.types.push(e.type), this.mon_nstd_flags.push($9.has(e.id) ? "y" : "n");
  }, t.prototype.getAtomIds = function(e) {
    for (var r = /* @__PURE__ */ new Set(), n = this.seqId.value(e); e < this.seqId.rowCount && this.seqId.value(e) === n; )
      r.add(this.atomId.value(e)), e += 1;
    return r;
  }, t.prototype.hasAtomIds = function(e, r) {
    for (var n = 0, i = r.length; n < i; ++n) if (!Ao.areIntersecting(e, r[n])) return !1;
    return !0;
  }, t.prototype.getType = function(e) {
    return this.hasAtomIds(e, Toe) ? "peptide linking" : this.hasAtomIds(e, Moe) ? "RNA linking" : this.hasAtomIds(e, Poe) ? "DNA linking" : "other";
  }, t.prototype.has = function(e) {
    return this.comps.has(e);
  }, t.prototype.get = function(e) {
    return this.comps.get(e);
  }, t.prototype.add = function(e, r) {
    if (!this.has(e)) if (aM.has(e)) this.set(aM.get(e));
    else if (Zp.has(e)) this.set({ id: e, name: "WATER", type: "non-polymer" });
    else if (Boe.has(e.toUpperCase())) this.set({ id: e, name: this.namesMap.get(e) || e, type: "non-polymer" });
    else if (Jd.has(e.toUpperCase())) this.set({ id: e, name: this.namesMap.get(e) || e, type: "saccharide" });
    else {
      var n = this.getAtomIds(r);
      if (n.size === 1 && oM.has(e)) this.set(oM.get(e));
      else {
        var i = this.getType(n);
        this.set({ id: e, name: this.namesMap.get(e) || e, type: i });
      }
    }
    return this.get(e);
  }, t.prototype.getChemCompTable = function() {
    return Hr.ofPartialColumns(Ho.chem_comp, { id: se.ofStringArray(this.ids), name: se.ofStringArray(this.names), type: se.ofStringAliasArray(this.types), mon_nstd_flag: se.ofStringAliasArray(this.mon_nstd_flags) }, this.ids.length);
  }, t.prototype.setNames = function(e) {
    var r = this;
    e.forEach(function(n) {
      return r.namesMap.set(n[0], n[1]);
    });
  }, t;
}(), k0 = function() {
  function t() {
    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 t.prototype.set = function(e, r) {
    this.count += 1, this.ids.push("".concat(this.count)), this.types.push(e), this.descriptions.push([r]);
  }, t.prototype.getEntityId = function(e, r, n, i) {
    return r === 2 ? (this.waterId === void 0 && (this.set("water", (i == null ? void 0 : i.customName) || "Water"), this.waterId = "".concat(this.count)), this.waterId) : ex(r) ? this.compoundsMap.has(n) ? this.compoundsMap.get(n) : (this.chainMap.has(n) || (this.set("polymer", (i == null ? void 0 : i.customName) || "Polymer ".concat(this.chainMap.size + 1)), this.chainMap.set(n, "".concat(this.count))), this.chainMap.get(n)) : (this.heteroMap.has(e) || (this.set("non-polymer", (i == null ? void 0 : i.customName) || this.namesMap.get(e) || e), this.heteroMap.set(e, "".concat(this.count))), this.heteroMap.get(e));
  }, t.prototype.getEntityTable = function() {
    return Hr.ofPartialColumns(Ho.entity, { id: se.ofStringArray(this.ids), type: se.ofStringAliasArray(this.types), pdbx_description: se.ofStringListArray(this.descriptions) }, this.count);
  }, t.prototype.setCompounds = function(e) {
    for (var r = 0, n = e.length; r < n; ++r) {
      var i = e[r], 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));
    }
  }, t.prototype.setNames = function(e) {
    var r = this;
    e.forEach(function(n) {
      return r.namesMap.set(n[0], n[1]);
    });
  }, t;
}();
function ny(t, e, r, n) {
  for (var i = r, a = n - 1, o = e.charCodeAt(i); (o === 32 || o >= 48 && o <= 57) && i <= a; ) o = e.charCodeAt(++i);
  for (o = e.charCodeAt(a); (o === 32 || o >= 48 && o <= 57) && a >= i; ) o = e.charCodeAt(--a);
  if (i === ++a || i + 1 === a) return ct.add(t, i, a);
  if (o = e.charCodeAt(i), i + 2 === a) {
    var s = e.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 ct.add(t, 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 ct.add(t, i, i + 1);
  ct.add(t, i, i);
}
var B7, Foe = /* @__PURE__ */ new Set(["NA", "CL", "FE", "SI", "BR", "AS", "LI"]), Noe = /* @__PURE__ */ new Set(["C", "H", "N", "O", "P", "S", "F", "B"]), Roe = /^[\s\d]+|[\s\d]+$/g;
function Ix(t, e) {
  var r = (t = t.replace(Roe, "").toUpperCase()).length;
  if (r === 0 || r === 1 || Foe.has(t)) return t;
  if (r === 3 && e === t) {
    if (t === "SOD") return "NA";
    if (t === "POT") return "K";
    if (t === "CES") return "CS";
    if (t === "CAL") return "CA";
    if (t === "CLA") return "CL";
  }
  return Noe.has(t[0]) ? t[0] : t;
}
function sM(t, e, r, n, i, a) {
  var o = r.data, s = i - n;
  ct.addToken(t.group_PDB, ot.trim(r, n, n + 6)), ot.trim(r, n + 6, n + 11), t.id[t.index] = r.data.substring(r.tokenStart, r.tokenEnd), ct.addToken(t.auth_atom_id, ot.trim(r, n + 12, n + 16)), o.charCodeAt(n + 16) === 32 ? ct.add(t.label_alt_id, 0, 0) : ct.add(t.label_alt_id, n + 16, n + 17), ct.addToken(t.auth_comp_id, ot.trim(r, n + 17, n + 20)), ct.add(t.auth_asym_id, n + 21, n + 22), ct.addToken(t.auth_seq_id, ot.trim(r, n + 22, n + 26)), o.charCodeAt(n + 26) === 32 ? ct.add(t.pdbx_PDB_ins_code, 0, 0) : ct.add(t.pdbx_PDB_ins_code, n + 26, n + 27), ct.addToken(t.Cartn_x, ot.trim(r, n + 30, n + 38)), ct.addToken(t.Cartn_y, ot.trim(r, n + 38, n + 46)), ct.addToken(t.Cartn_z, ot.trim(r, n + 46, n + 54)), ct.addToken(t.occupancy, ot.trim(r, n + 54, n + 60)), s >= 66 ? ct.addToken(t.B_iso_or_equiv, ot.trim(r, n + 60, n + 66)) : ct.add(t.B_iso_or_equiv, 0, 0), a && ct.addToken(t.partial_charge, ot.trim(r, n + 70, n + 76)), s >= 78 && !a ? (ot.trim(r, n + 76, n + 78), r.tokenStart < r.tokenEnd ? ct.addToken(t.type_symbol, r) : ny(t.type_symbol, o, n + 12, n + 16)) : ny(t.type_symbol, o, n + 12, n + 16), s >= 82 && ct.addToken(t.pdbx_formal_charge, ot.trim(r, n + 78, n + 82)), s >= 84 && ct.addToken(t.cdr, ot.trim(r, n + 82, n + 84)), s >= 90 && ct.addToken(t.em_confidence, ot.trim(r, n + 84, n + 90)), t.pdbx_PDB_model_num[t.index] = e, t.index++;
}
function Ooe(t) {
  var e = ut.ofTokens(t.pdbx_auth_seq_id), r = ut.ofTokens(t.pdbx_auth_comp_id), n = ut.ofTokens(t.pdbx_auth_asym_id), i = ut.ofTokens(t.pdbx_auth_atom_id), a = { id: ut.ofStrings(t.id), type_symbol: ut.ofTokens(t.type_symbol), pdbx_label_atom_id: i, pdbx_label_alt_id: ut.ofTokens(t.pdbx_label_alt_id), pdbx_label_comp_id: r, pdbx_label_asym_id: n, pdbx_label_seq_id: e, pdbx_PDB_ins_code: ut.ofTokens(t.pdbx_PDB_ins_code), pdbx_auth_seq_id: e, pdbx_auth_comp_id: r, pdbx_auth_asym_id: n, pdbx_auth_atom_id: i };
  return a["U[1][1]"] = ut.ofNumbers(t["U[1][1]"]), a["U[2][2]"] = ut.ofNumbers(t["U[2][2]"]), a["U[3][3]"] = ut.ofNumbers(t["U[3][3]"]), a["U[1][2]"] = ut.ofNumbers(t["U[1][2]"]), a["U[1][3]"] = ut.ofNumbers(t["U[1][3]"]), a["U[2][3]"] = ut.ofNumbers(t["U[2][3]"]), a;
}
function Loe(t, e, r, n, i) {
  var a = r.data, o = i - n;
  ot.trim(r, n + 6, n + 11), t.id[t.index] = a.substring(r.tokenStart, r.tokenEnd), ct.addToken(t.pdbx_auth_atom_id, ot.trim(r, n + 12, n + 16)), a.charCodeAt(n + 16) === 32 ? ct.add(t.pdbx_label_alt_id, 0, 0) : ct.add(t.pdbx_label_alt_id, n + 16, n + 17), ct.addToken(t.pdbx_auth_comp_id, ot.trim(r, n + 17, n + 20)), ct.add(t.pdbx_auth_asym_id, n + 21, n + 22), ct.addToken(t.pdbx_auth_seq_id, ot.trim(r, n + 22, n + 26)), a.charCodeAt(n + 26) === 32 ? ct.add(t.pdbx_PDB_ins_code, 0, 0) : ct.add(t.pdbx_PDB_ins_code, n + 26, n + 27), t["U[1][1]"][t.index] = e0(a, n + 28, n + 35) / 1e4, t["U[2][2]"][t.index] = e0(a, n + 35, n + 42) / 1e4, t["U[3][3]"][t.index] = e0(a, n + 42, n + 49) / 1e4, t["U[1][2]"][t.index] = e0(a, n + 49, n + 56) / 1e4, t["U[1][3]"][t.index] = e0(a, n + 56, n + 63) / 1e4, t["U[2][3]"][t.index] = e0(a, n + 63, n + 70) / 1e4, o >= 78 ? (ot.trim(r, n + 76, n + 78), r.tokenStart < r.tokenEnd ? ct.addToken(t.type_symbol, r) : ny(t.type_symbol, a, n + 12, n + 16)) : ny(t.type_symbol, a, n + 12, n + 16), t.index++;
}
function koe(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F, N, R, L;
    return ye(this, function(V) {
      for (e = t.lines, r = e.data, n = e.indices, i = ot(r), a = !!t.isPdbqt, o = 0, s = 0, w = 0, v = e.count; w < v; w++) switch (g = n[2 * w], y = n[2 * w + 1], r[g]) {
        case "A":
          _i(r, g, y, "ATOM  ") ? o++ : _i(r, g, y, "ANISOU") && s++;
          break;
        case "H":
          _i(r, g, y, "HETATM") && o++;
      }
      for (u = function(Y, Q) {
        var J = function() {
          return ct.create(Y, 2 * Q);
        };
        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() };
      }(r, o), c = function(Y, Q) {
        var J = function() {
          return new Float32Array(Q);
        }, te = function() {
          return ct.create(Y, 2 * Q);
        };
        return { index: 0, count: Q, id: [], type_symbol: te(), pdbx_label_atom_id: te(), pdbx_label_alt_id: te(), pdbx_label_comp_id: te(), pdbx_label_asym_id: te(), pdbx_label_seq_id: te(), pdbx_PDB_ins_code: te(), "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: te(), pdbx_auth_comp_id: te(), pdbx_auth_asym_id: te(), pdbx_auth_atom_id: te() };
      }(r, s), l = new k0(), d = [], f = [], h = 0, m = "", p = void 0, w = 0, v = e.count; w < v; w++) switch (g = n[2 * w], y = n[2 * w + 1], r[g]) {
        case "A":
          _i(r, g, y, "ATOM  ") ? (h || (h++, m = "" + h), sM(u, m, i, g, y, a)) : _i(r, g, y, "ANISOU") && Loe(c, 0, i, g, y);
          break;
        case "C":
          if (_i(r, g, y, "CRYST1")) d.push.apply(d, _oe(t.id || "?", r.substring(g, y)));
          else if (_i(r, g, y, "CONECT")) {
            for (b = w + 1; g = n[2 * b], y = n[2 * b + 1], _i(r, g, y, "CONECT"); ) b++;
            p ? Pr && console.log("only single CONECT block allowed, ignoring others") : p = [w, b], w = b - 1;
          } else if (_i(r, g, y, "COMPND")) {
            for (b = w + 1; g = n[2 * b], y = n[2 * b + 1], _i(r, g, y, "COMPND"); ) b++;
            l.setCompounds(Eoe(e, w, b)), w = b - 1;
          }
          break;
        case "H":
          if (_i(r, g, y, "HETATM")) h || (h++, m = "" + h), sM(u, m, i, g, y, a);
          else if (_i(r, g, y, "HELIX")) {
            for (b = w + 1; g = n[2 * b], y = n[2 * b + 1], _i(r, g, y, "HELIX"); ) b++;
            d.push(Aoe(e, w, b)), w = b - 1;
          } else if (_i(r, g, y, "HETNAM")) {
            for (b = w + 1; g = n[2 * b], y = n[2 * b + 1], _i(r, g, y, "HETNAM"); ) b++;
            f.push.apply(f, Array.from(Ioe(e, w, b).entries())), w = b - 1;
          }
          break;
        case "M":
          if (_i(r, g, y, "MODEL ") && (h++, m = "" + h), _i(r, g, y, "MTRIX")) {
            for (b = w + 1; g = n[2 * b], y = n[2 * b + 1], _i(r, g, y, "MTRIX"); ) b++;
            d.push.apply(d, Soe(e, w, b)), w = b - 1;
          }
          break;
        case "O":
          break;
        case "R":
          if (_i(r, g, y, "REMARK 350")) {
            for (b = w + 1; g = n[2 * b], y = n[2 * b + 1], _i(r, g, y, "REMARK 350"); ) b++;
            d.push.apply(d, xoe(e, w, b)), w = b - 1;
          }
          break;
        case "S":
          if (_i(r, g, y, "SHEET")) {
            for (b = w + 1; g = n[2 * b], y = n[2 * b + 1], _i(r, g, y, "SHEET"); ) b++;
            d.push(woe(e, w, b)), w = b - 1;
          }
      }
      for (S = se.ofIntTokens(u.auth_seq_id), _ = se.ofStringTokens(u.auth_atom_id), x = se.ofStringTokens(u.auth_comp_id), C = se.ofStringTokens(u.auth_asym_id), (A = new L0(S, _)).setNames(f), l.setNames(f), w = 0, I = x.rowCount; w < I; ++w) P = x.value(w), M = g2(A.add(P, w).type, P), u.label_entity_id[w] = l.getEntityId(P, M, C.value(w));
      var U, H, K, X;
      for (U = u, H = ut.ofTokens(U.auth_asym_id), K = ut.ofTokens(U.auth_atom_id), X = ut.ofTokens(U.auth_comp_id), T = { auth_asym_id: H, auth_atom_id: K, auth_comp_id: X, auth_seq_id: ut.ofTokens(U.auth_seq_id), B_iso_or_equiv: ut.ofTokens(U.B_iso_or_equiv), Cartn_x: ut.ofTokens(U.Cartn_x), Cartn_y: ut.ofTokens(U.Cartn_y), Cartn_z: ut.ofTokens(U.Cartn_z), group_PDB: ut.ofTokens(U.group_PDB), id: ut.ofStrings(U.id), label_alt_id: ut.ofTokens(U.label_alt_id), label_asym_id: H, label_atom_id: K, label_comp_id: X, label_seq_id: ut.ofUndefined(U.index, se.Schema.int), label_entity_id: ut.ofStrings(U.label_entity_id), occupancy: bJ(U.occupancy) ? ut.ofUndefined(U.index, se.Schema.float) : ut.ofTokens(U.occupancy), type_symbol: ut.ofTokens(U.type_symbol), pdbx_PDB_ins_code: ut.ofTokens(U.pdbx_PDB_ins_code), pdbx_PDB_model_num: ut.ofStrings(U.pdbx_PDB_model_num), partial_charge: ut.ofTokens(U.partial_charge), pdbx_formal_charge: ut.ofTokens(U.pdbx_formal_charge), cdr: ut.ofTokens(U.cdr), em_confidence: ut.ofTokens(U.em_confidence) }, p && d.push(function(Y, Q, J, te) {
        for (var W = {}, j = 0, ee = te.id.rowCount; j < ee; ++j) W[te.id.str(j)] = j;
        var ie = function(Oe) {
          return Y.data.substring(Y.indices[2 * Oe], Y.indices[2 * Oe + 1]);
        }, ae = [], ce = [], de = [], Ce = [], De = [], ke = [], He = [], We = [], Ne = [], Je = [], Re = [11, 16, 21, 26], nt = 1;
        for (j = Q; j < J; j++) {
          var ne = ie(j), re = W[parseInt(ne.substr(6, 5))], le = {};
          if (re !== void 0) for (var fe = 0; fe < 4; ++fe) {
            var ge = parseInt(ne.substr(Re[fe], 5));
            if (!Number.isNaN(ge)) {
              var me = W[ge];
              me !== void 0 && (re > me || le[me] === void 0 && (ae.push("covale".concat(nt)), ce.push("covale"), de.push(te.label_asym_id.str(re)), De.push(te.auth_seq_id.int(re)), Ce.push(te.label_seq_id.int(re)), ke.push(te.label_atom_id.str(re)), He.push(te.label_asym_id.str(me)), Ne.push(te.auth_seq_id.int(me)), We.push(te.label_seq_id.int(me)), Je.push(te.label_atom_id.str(me)), nt += 1));
            }
          }
        }
        var Ae = { id: ut.ofStrings(ae), conn_type_id: ut.ofStrings(ce), ptnr1_label_asym_id: ut.ofStrings(de), ptnr1_auth_seq_id: ut.ofNumbers(De), ptnr1_label_seq_id: ut.ofNumbers(Ce), ptnr1_label_atom_id: ut.ofStrings(ke), ptnr2_label_asym_id: ut.ofStrings(He), ptnr2_label_seq_id: ut.ofNumbers(We), ptnr2_auth_seq_id: ut.ofNumbers(Ne), ptnr2_label_atom_id: ut.ofStrings(Je) };
        return La.ofFields("struct_conn", Ae);
      }(e, p[0], p[1], T)), F = { entity: La.ofTable("entity", l.getEntityTable()), chem_comp: La.ofTable("chem_comp", A.getChemCompTable()), atom_site: La.ofFields("atom_site", T), atom_site_anisotrop: La.ofFields("atom_site_anisotrop", Ooe(c)) }, N = 0, R = d; N < R.length; N++) L = R[N], F[L.name] = L;
      return [2, { header: t.id || "PDB", categoryNames: Object.keys(F), categories: F }];
    });
  });
}
function dL(t) {
  var e = this;
  return tr.create("Parse PDB", function(r) {
    return _e(e, 0, void 0, function() {
      var n, i, a, o, s, u, c, l, d, f, h;
      return ye(this, function(m) {
        switch (m.label) {
          case 0:
            return [4, r.update("Converting to mmCIF")];
          case 1:
            return m.sent(), [4, koe(t)];
          case 2:
            return n = m.sent(), i = An.fromFrame(n, void 0, B7.create(t)), [4, Pl(hf(i.data.db, !0), i, r)];
          case 3:
            return a = m.sent(), (o = (h = n.categories.atom_site) === null || h === void 0 ? void 0 : h.getField("partial_charge")) && a.frameCount === 1 && (s = a.representative, u = s.atomicHierarchy.atomSourceIndex, c = se.isIdentity(u), l = c ? void 0 : u.toArray({ array: Int32Array }), d = o.toFloatArray(), f = l ? se.ofFloatArray(se.mapToArray(u, function(p) {
              return d[p];
            }, Float32Array)) : se.ofFloatArray(d), Dl.Provider.set(s, { data: f, type: "GASTEIGER" })), [2, a];
        }
      });
    });
  });
}
(function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "pdb";
  }, t.create = function(e) {
    return { kind: "pdb", name: e.id || "", data: e };
  };
})(B7 || (B7 = {}));
var F7, Goe = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return t.trim() ? [4, lL(t).run()] : [2, [Ec()]];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, dL(e.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return tt.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function zoe(t) {
  switch (t) {
    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(t, " is outside the 0-7 range, defaulting to 0.")), 0;
  }
}
function Tx(t, e) {
  for (var r = ct.create(t.data, 2 * e), n = ct.create(t.data, 2 * e), i = ct.create(t.data, 2 * e), a = ct.create(t.data, 2 * e), o = ct.create(t.data, 2 * e), s = 0; s < e; ++s) {
    ot.markLine(t);
    var u = t.tokenStart, c = t.position;
    ot.trim(t, u, u + 10), ct.addUnchecked(r, t.tokenStart, t.tokenEnd), ot.trim(t, u + 10, u + 20), ct.addUnchecked(n, t.tokenStart, t.tokenEnd), ot.trim(t, u + 20, u + 30), ct.addUnchecked(i, t.tokenStart, t.tokenEnd), ot.trim(t, u + 31, u + 34), ct.addUnchecked(a, t.tokenStart, t.tokenEnd), ot.trim(t, u + 36, u + 39), ct.addUnchecked(o, t.tokenStart, t.tokenEnd), t.position = c;
  }
  return { count: e, x: Wr(r)(se.Schema.float), y: Wr(n)(se.Schema.float), z: Wr(i)(se.Schema.float), type_symbol: Wr(a)(se.Schema.str), formal_charge: Wr(o)(se.Schema.int) };
}
function Mx(t, e) {
  for (var r = ct.create(t.data, 2 * e), n = ct.create(t.data, 2 * e), i = ct.create(t.data, 2 * e), a = 0; a < e; ++a) {
    ot.markLine(t);
    var o = t.tokenStart, s = t.position;
    ot.trim(t, o, o + 3), ct.addUnchecked(r, t.tokenStart, t.tokenEnd), ot.trim(t, o + 3, o + 6), ct.addUnchecked(n, t.tokenStart, t.tokenEnd), ot.trim(t, o + 6, o + 9), ct.addUnchecked(i, t.tokenStart, t.tokenEnd), t.position = s;
  }
  return { count: e, atomIdxA: Wr(r)(se.Schema.int), atomIdxB: Wr(n)(se.Schema.int), order: Wr(i)(se.Schema.int) };
}
function Voe(t, e, r) {
  ot.trim(t, e + 6, e + 9);
  for (var n = parseInt(ot.getTokenString(t)), i = 0; i < n; ++i) {
    var a = 9 + 8 * i;
    ot.trim(t, e + a, e + a + 4);
    var o = ot.getTokenString(t);
    r.atomIdx.push(+o), ot.trim(t, e + a + 4, e + a + 8);
    var s = ot.getTokenString(t);
    r.charge.push(+s);
  }
  ot.eatLine(t);
}
function Px(t) {
  for (var e = { atomIdx: [], charge: [] }; t.position < t.length; ) {
    var r = t.position;
    ot.trim(t, r + 3, r + 6);
    var n = ot.getTokenString(t);
    if (n === "END") break;
    ot.eatLine(t), n === "CHG" && Voe(t, r, e);
  }
  return { atomIdx: se.ofIntArray(e.atomIdx), charge: se.ofIntArray(e.charge) };
}
function Uoe(t) {
  var e = ot(t), r = ot.readLine(e).trim(), n = ot.readLine(e).trim(), i = ot.readLine(e).trim(), a = ot.readLine(e), o = +a.substr(0, 3), s = +a.substr(3, 3), u = { title: r, program: n, comment: i, atoms: Tx(e, o), bonds: Mx(e, s), formalCharges: Px(e) };
  return ji.success(u);
}
function Hoe(t) {
  var e = this;
  return tr.create("Parse Mol", function() {
    return _e(e, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, Uoe(t)];
      });
    });
  });
}
function fL(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b;
    return ye(this, function(S) {
      switch (S.label) {
        case 0:
          if (n = t.atoms, i = t.bonds, a = t.formalCharges, o = se.ofConst("MOL", t.atoms.count, se.Schema.str), s = se.ofConst("A", t.atoms.count, se.Schema.str), u = se.asArrayColumn(n.type_symbol), c = se.ofConst(1, n.count, se.Schema.int), l = new Int32Array(t.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 < t.atoms.count; d++) l[d] = zoe(n.formal_charge.value(d));
          return f = Hr.ofPartialColumns(Ho.atom_site, { auth_asym_id: s, auth_atom_id: u, auth_comp_id: o, auth_seq_id: c, Cartn_x: se.asArrayColumn(n.x, Float32Array), Cartn_y: se.asArrayColumn(n.y, Float32Array), Cartn_z: se.asArrayColumn(n.z, Float32Array), id: se.range(0, n.count - 1), label_asym_id: s, label_atom_id: u, label_comp_id: o, label_seq_id: c, label_entity_id: se.ofConst("1", n.count, se.Schema.str), occupancy: se.ofConst(1, n.count, se.Schema.float), type_symbol: u, pdbx_PDB_model_num: se.ofConst(1, n.count, se.Schema.int), pdbx_formal_charge: se.ofIntArray(l) }, n.count), (h = new k0()).setNames([["MOL", "Ligand"]]), h.getEntityId("MOL", 0, "A"), (m = new L0(c, u)).setNames([["MOL", "Unknown Molecule"]]), m.add("MOL", 0), [4, Pl(hf({ entity: h.getEntityTable(), chem_comp: m.getChemCompTable(), atom_site: f }), e ?? F7.create(t), r)];
        case 1:
          return (p = S.sent()).frameCount > 0 && (v = se.ofIntArray(se.mapToArray(i.atomIdxA, function(_) {
            return _ - 1;
          }, Int32Array)), g = se.ofIntArray(se.mapToArray(i.atomIdxB, function(_) {
            return _ - 1;
          }, Int32Array)), y = se.asArrayColumn(i.order, Int32Array), b = Xi.fromData({ pairs: { indexA: v, indexB: g, order: y }, count: n.count }), Xi.Provider.set(p.representative, b)), [2, p];
      }
    });
  });
}
(function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "mol";
  }, t.create = function(e) {
    return { kind: "mol", name: e.title, data: e };
  };
})(F7 || (F7 = {}));
var qoe = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return t.trim() ? [4, Hoe(t).run()] : [2, [Ec()]];
        case 1:
          if ((e = n.sent()).isError) throw e;
          return [4, (i = e.result, tr.create("Parse MOL", function(a) {
            return fL(i, void 0, a);
          })).run()];
        case 2:
          return r = n.sent(), [2, [tt.ofModel(r.representative)]];
      }
      var i;
    });
  });
} };
function Qc(t) {
  ot.skipWhitespace(t), ot.eatValue(t);
}
function Jc(t, e) {
  var r = t.position;
  ot.skipWhitespace(t), ot.eatValue(t), ot.trim(t, r, t.position), ct.addUnchecked(e, t.tokenStart, t.tokenEnd);
}
var N7, r8 = "$$$$";
function Koe(t) {
  var e = ot.readLine(t).trim(), r = ot.readLine(t).trim(), n = ot.readLine(t).trim(), i = ot.readLine(t), a = i.trim().endsWith("V3000"), o = a ? function(m) {
    var p = ct.create(m.data, 1), v = ct.create(m.data, 1);
    return ot.eatLine(m), Qc(m), Qc(m), Qc(m), Jc(m, p), Jc(m, v), ot.eatLine(m), { atomCount: Wr(p)(se.Schema.int).value(0), bondCount: Wr(v)(se.Schema.int).value(0) };
  }(t) : function(m) {
    return { atomCount: +m.substr(0, 3), bondCount: +m.substr(3, 3) };
  }(i), s = o.atomCount, u = o.bondCount;
  if (!Number.isNaN(s) && !Number.isNaN(u)) {
    var c = { atomIdx: se.ofConst(0, s, se.Schema.int), charge: se.ofConst(0, s, se.Schema.int) }, l = a ? function(m, p) {
      for (var v = ct.create(m.data, 2 * p), g = ct.create(m.data, 2 * p), y = ct.create(m.data, 2 * p), b = ct.create(m.data, 2 * p), S = 0; S < p; ++S) {
        ot.markLine(m), Qc(m), Qc(m), Qc(m);
        var _ = m.position;
        Jc(m, b), Jc(m, v), Jc(m, g), Jc(m, y), m.position = _;
      }
      return ot.eatLine(m), ot.eatLine(m), { count: p, x: Wr(v)(se.Schema.float), y: Wr(g)(se.Schema.float), z: Wr(y)(se.Schema.float), type_symbol: Wr(b)(se.Schema.str), formal_charge: se.ofConst(0, p, se.Schema.int) };
    }(t, s) : Tx(t, s), d = a ? function(m, p) {
      for (var v = ct.create(m.data, 2 * p), g = ct.create(m.data, 2 * p), y = ct.create(m.data, 2 * p), b = 0; b < p; ++b) {
        ot.markLine(m), Qc(m), Qc(m), Qc(m);
        var S = m.position;
        Jc(m, y), Jc(m, v), Jc(m, g), m.position = S;
      }
      return ot.eatLine(m), ot.eatLine(m), { count: p, atomIdxA: Wr(v)(se.Schema.float), atomIdxB: Wr(g)(se.Schema.float), order: Wr(y)(se.Schema.float) };
    }(t, u) : Mx(t, u), f = a ? c : Px(t), h = function(m) {
      for (var p = ct.create(m.data, 32), v = ct.create(m.data, 32); m.position < m.length; ) {
        var g = ot.readLine(m);
        if (g.startsWith(r8)) break;
        if (g && g.startsWith("> ")) {
          ct.add(p, m.tokenStart + 2, m.tokenEnd), ot.markLine(m);
          for (var y = m.tokenStart, b = m.tokenEnd, S = !1; m.position < m.length; ) {
            var _ = ot.readLine(m);
            if (!_ || _.startsWith(r8) || _.startsWith("> ")) {
              ct.add(v, y, b), S = !0;
              break;
            }
            b = m.tokenEnd;
          }
          S || ct.add(v, y, b);
        }
      }
      return { dataHeader: Wr(p)(se.Schema.str), data: Wr(v)(se.Schema.str) };
    }(t);
    return { molFile: { title: e, program: r, comment: n, atoms: l, bonds: d, formalCharges: f }, dataItems: h };
  }
  for (; t.position < t.length && !ot.readLine(t).startsWith(r8); )
    ;
}
function Xoe(t) {
  for (var e = ot(t), r = []; e.position < e.length; ) {
    var n = Koe(e);
    n && r.push(n);
  }
  return ji.success({ compounds: r });
}
function Yoe(t) {
  var e = this;
  return tr.create("Parse Sdf", function() {
    return _e(e, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, Xoe(t)];
      });
    });
  });
}
(function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "sdf";
  }, t.create = function(e) {
    return { kind: "sdf", name: e.molFile.title, data: e };
  };
})(N7 || (N7 = {}));
var n8, km, b0 = {};
n8 = b0, function() {
  var t = { 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 e(i) {
    return function(a, o) {
      var s, u, c, l, d, f, h, m, p, v = 1, g = a.length, y = "";
      for (u = 0; u < g; u++) if (typeof a[u] == "string") y += a[u];
      else if (typeof a[u] == "object") {
        if ((l = a[u]).keys) for (s = o[v], c = 0; c < l.keys.length; c++) {
          if (s == null) throw new Error(e('[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[v++];
        if (t.not_type.test(l.type) && t.not_primitive.test(l.type) && s instanceof Function && (s = s()), t.numeric_arg.test(l.type) && typeof s != "number" && isNaN(s)) throw new TypeError(e("[sprintf] expecting number but found %T", s));
        switch (t.number.test(l.type) && (m = 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();
        }
        t.json.test(l.type) ? y += s : (!t.number.test(l.type) || m && !l.sign ? p = "" : (p = m ? "+" : "-", s = s.toString().replace(t.sign, "")), f = l.pad_char ? l.pad_char === "0" ? "0" : l.pad_char.charAt(1) : " ", h = l.width - (p + s).length, d = l.width && h > 0 ? f.repeat(h) : "", y += l.align ? p + s + d : f === "0" ? p + d + s : d + p + s);
      }
      return y;
    }(function(a) {
      if (n[a]) return n[a];
      for (var o, s = a, u = [], c = 0; s; ) {
        if ((o = t.text.exec(s)) !== null) u.push(o[0]);
        else if ((o = t.modulo.exec(s)) !== null) u.push("%");
        else {
          if ((o = t.placeholder.exec(s)) === null) throw new SyntaxError("[sprintf] unexpected placeholder");
          if (o[2]) {
            c |= 1;
            var l = [], d = o[2], f = [];
            if ((f = t.key.exec(d)) === null) throw new SyntaxError("[sprintf] failed to parse named argument key");
            for (l.push(f[1]); (d = d.substring(f[0].length)) !== ""; ) if ((f = t.key_access.exec(d)) !== null) l.push(f[1]);
            else {
              if ((f = t.index_access.exec(d)) === null) throw new SyntaxError("[sprintf] failed to parse named argument key");
              l.push(f[1]);
            }
            o[2] = l;
          } else c |= 2;
          if (c === 3) throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
          u.push({ placeholder: o[0], param_no: o[1], keys: o[2], sign: o[3], pad_char: o[4], align: o[5], width: o[6], precision: o[7], type: o[8] });
        }
        s = s.substring(o[0].length);
      }
      return n[a] = u;
    }(i), arguments);
  }
  function r(i, a) {
    return e.apply(null, [i].concat(a || []));
  }
  var n = /* @__PURE__ */ Object.create(null);
  n8.sprintf = e, n8.vsprintf = r, typeof window < "u" && (window.sprintf = e, window.vsprintf = r);
}(), function(t) {
  t.PDB = "chemical/pdb", t.SDF = "chemical/x-mdl-sdf", t.MOL = "chemical/x-mdl-molfile", t.MOL2 = "chemical/x-mol2";
}(km || (km = {}));
var Woe = ["HEADER", "SOURCE", "AUTHOR", "OBSLTE", "KEYWDS", "REVDAT", "TITLE", "EXPDTA", "SPRSDE", "SPLT", "NUMMDL", "JRNL", "CAVEAT", "MDLTYP", "REMARKS", "COMPND"], joe = ["DBREF", "DBREF1", "DBREF2", "SEQADV", "SEQRES", "MODRES"], Zoe = ["HET   ", "HETNAM", "HETSYN", "FORMUL"], Bx = function(t, e) {
  var r = gs(t);
  return (r == null ? void 0 : r.sourceData.kind) === "mmCIF" ? r.sourceData.data.source.data.lines.data.split(`
`).filter(function(n) {
    for (var i = 0, a = e.length; i < a; i++) if (n.startsWith(e[i])) return !0;
    return !1;
  }) : [];
};
function Fx(t, e, r, n) {
  var i, a = [];
  if (((i = t.models[0]) === null || i === void 0 ? void 0 : i.sourceData.kind) === "mmCIF") {
    var o = Ze(Ze(Ze([], Woe, !0), joe, !0), Zoe, !0);
    a.push.apply(a, Bx(t, o));
  }
  var s = [];
  e ? s.push.apply(s, Ze([], e, !0).sort(function(p, v) {
    return p - v;
  })) : t.units.forEach(function(p) {
    return s.push.apply(s, Ze([], p.elements, !0));
  });
  var u = t.units[0], c = [], l = !1, d = !1;
  if (s.forEach(function(p) {
    var v = { elementId: p, group_PDB: u.model.atomicHierarchy.residues.group_PDB.value(u.residueIndex[p]), atom_id: u.model.atomicConformation.atomId.value(p), auth_atom_id: u.model.atomicHierarchy.atoms.auth_atom_id.value(p), label_alt_id: u.model.atomicHierarchy.atoms.label_alt_id.value(p), auth_comp_id: u.model.atomicHierarchy.atoms.label_comp_id.value(p), auth_asym_id: u.model.atomicHierarchy.chains.auth_asym_id.value(u.chainIndex[p]), auth_seq_id: u.model.atomicHierarchy.residues.auth_seq_id.value(u.residueIndex[p]), pdbx_PDB_ins_code: u.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(u.residueIndex[p]), x: u.model.atomicConformation.x[p], y: u.model.atomicConformation.y[p], z: u.model.atomicConformation.z[p], occupancy: u.model.atomicConformation.occupancy.value(p), B_iso_or_equiv: u.model.atomicConformation.B_iso_or_equiv.value(p), type_symbol: r2(u.model.atomicHierarchy.atoms.type_symbol.value(p)), charge: u.model.atomicHierarchy.atoms.pdbx_formal_charge.value(p), em_confidence: u.model.atomicHierarchy.atoms.em_confidence.value(p) };
    c.push(v), v.em_confidence && (l = !0), v.charge && (d = !0);
  }), n) {
    var f = n(c, []), h = f.editedAtomList, m = f.editedBondList;
    return a.push(R7(h, m, r && d, r && l)), a.join(`
`);
  }
  return a.push(R7(c, [], r && d, r && l)), a.join(`
`);
}
function R7(t, e, r, n) {
  var i = "ATOM  %5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(r ? "%4.1f" : "%2s  ").concat(n ? "   %5.2f" : ""), a = "HETATM%5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(r ? "%4.1f" : "%2s  ").concat(n ? "   %5.2f" : ""), o = "CONECT%5s%5s%5s%5s%5s", s = [], u = [];
  return t.forEach(function(c) {
    var l = c.elementId, d = c.atom_id, f = c.auth_atom_id, h = c.label_alt_id, m = c.auth_comp_id, p = c.auth_asym_id, v = c.auth_seq_id, g = c.pdbx_PDB_ins_code, y = g === void 0 ? " " : g, b = c.x, S = c.y, _ = c.z, x = c.occupancy, C = c.B_iso_or_equiv, A = c.type_symbol, w = c.group_PDB, I = c.charge, P = c.em_confidence, M = w === "HETATM" ? a : i;
    s.push(b0.sprintf(M, d, f, h, m, p, v, y, b, S, _, x, C, " ", A, r ? I : "  ", n ? P : ""));
    var T = [];
    if (e && (e.forEach(function(R) {
      if (R.a !== l || T.includes(R.atom_idB)) {
        if (R.b === l && !T.includes(R.atom_idA)) for (L = 0, V = R.order; L < V; L++) T.push(R.atom_idA);
      } else for (var L = 0, V = R.order; L < V; L++) T.push(R.atom_idB);
    }), T.length > 0)) {
      for (var F = []; T.length > 0; ) {
        var N = T.shift();
        N && F.push(N), F.length === 4 && (u.push(b0.sprintf(o, d, F[0], F[1], F[2], F[3])), F = []);
      }
      F.length > 0 && (u.push(b0.sprintf(o, d, F[0] || "", F[1] || "", F[2] || "", F[3] || "")), F = []);
    }
  }), Ze(Ze([], s, !0), u, !0).join(`
`);
}
function O7(t, e, r, n, i) {
  var a, o, s, u, c, l;
  i === void 0 && (i = !1);
  var d = [];
  if (t.units.forEach(function(R) {
    return d.push.apply(d, Ze([], R.elements, !0));
  }), d.length > 999) return "";
  if (d.length <= 0) {
    if (n) {
      var f = n([], []), h = f.editedAtomList, m = f.editedBondList, p = (a = t == null ? void 0 : t.state.model) !== null && a !== void 0 ? a : t == null ? void 0 : t.state.models[0], v = (o = p == null ? void 0 : p.sourceData) === null || o === void 0 ? void 0 : o.kind, g = o3(h, m);
      return v === "sdf" || v === "mol" ? Ze(Ze([p.entryId], g.split(`
`).slice(1), !0), ["$$$$"], !1).join(`
`) : "".concat(g, `
$$$$`);
    }
    return "";
  }
  var y = t.units[0], b = [], S = /* @__PURE__ */ new Map();
  d.forEach(function(R) {
    var L;
    b.push({ elementId: R, group_PDB: y.model.atomicHierarchy.residues.group_PDB.value(y.residueIndex[R]), atom_id: y.model.atomicConformation.atomId.value(R), auth_atom_id: y.model.atomicHierarchy.atoms.label_atom_id.value(R), label_alt_id: y.model.atomicHierarchy.atoms.label_alt_id.value(R), auth_comp_id: y.model.atomicHierarchy.atoms.label_comp_id.value(R), auth_asym_id: y.model.atomicHierarchy.chains.auth_asym_id.value(y.chainIndex[R]), auth_seq_id: y.model.atomicHierarchy.residues.auth_seq_id.value(y.residueIndex[R]), pdbx_PDB_ins_code: y.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(y.residueIndex[R]), x: y.model.atomicConformation.x[R], y: y.model.atomicConformation.y[R], z: y.model.atomicConformation.z[R], occupancy: y.model.atomicConformation.occupancy.value(R), B_iso_or_equiv: y.model.atomicConformation.B_iso_or_equiv.value(R), type_symbol: r2(y.model.atomicHierarchy.atoms.type_symbol.value(R)), charge: y.model.atomicHierarchy.atoms.pdbx_formal_charge.value(R) || ((L = Dl.Provider.get(y.model)) === null || L === void 0 ? void 0 : L.data.value(R)) || 0 });
  });
  var _ = new Set(e), x = /* @__PURE__ */ new Map();
  if (i && ((s = t.model) === null || s === void 0 ? void 0 : s.sourceData.kind) === "mmCIF") for (var C = function(R, L) {
    for (var V = t.units[R], U = function(X, Y) {
      var Q = V.rings.all[V.rings.aromaticRings[X]].map(function(J) {
        return V.elements[J];
      });
      Q.forEach(function(J, te) {
        _.has(J) && x.set(J, new Set(Ze(Ze([], Q.slice(0, te), !0), Q.slice(te + 1), !0)));
      });
    }, H = 0, K = V.rings.aromaticRings.length; H < K; H++) U(H);
  }, A = 0, w = t.units.length; A < w; A++) C(A);
  t.units.forEach(function(R) {
    for (var L, V = 0, U = R.bonds.a.length; V < U; V++) {
      var H = R.elements[R.bonds.a[V]], K = R.elements[R.bonds.b[V]];
      if (d.includes(H) && d.includes(K) && !S.has("".concat(H, "_").concat(K)) && !S.has("".concat(K, "_").concat(H))) {
        var X = i && x.has(H) && (!((L = x.get(H)) === null || L === void 0) && L.has(K)) ? 4 : R.bonds.edgeProps.order[V];
        S.set("".concat(H, "_").concat(K), { a: d.indexOf(H) + 1, b: d.indexOf(K) + 1, order: X });
      }
    }
  });
  var I = [];
  if (((u = t.model) === null || u === void 0 ? void 0 : u.sourceData.kind) === "sdf" && (!((c = t.state.models) === null || c === void 0) && c.length)) for (var P = (l = t.state.models[0]) === null || l === void 0 ? void 0 : l.sourceData.data.dataItems, M = (A = 0, P.data.rowCount); A < M; A++) I.push("> ".concat(P.dataHeader.value(A), `
`).concat(P.data.value(A)));
  if (n) {
    var T = n(b, Array.from(S).map(function(R) {
      return R[1];
    })), F = (h = T.editedAtomList, m = T.editedBondList, o3(h, m));
    return "".concat(F, `
`).concat(I.join(`

`)).concat(I.length ? `

` : "", "$$$$");
  }
  var N = o3(b, Array.from(S).map(function(R) {
    return R[1];
  }));
  return "".concat(N, `
`).concat(I.join(`

`)).concat(I.length ? `

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

`)), n.push(b0.sprintf("%3d%3d  0  0  0  0  0  0  0  0999 V2000", t.length, e.length)), t.forEach(function(i) {
    var a = i.x, o = i.y, s = i.z, u = i.type_symbol, c = i.charge;
    n.push(b0.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)));
  }), e.forEach(function(i) {
    var a = i.a, o = i.b, s = i.order;
    n.push(b0.sprintf("%3s%3s%3s  0  0  0  0", a, o, s));
  }), n.push("M  END"), n.join(`
`);
}, Vh = function(t, e, r, n) {
  return { elementId: -1, group_PDB: "HETATM", atom_id: t, auth_atom_id: e, label_alt_id: "", auth_comp_id: "UNK", auth_asym_id: " ", auth_seq_id: "1", x: parseFloat(r[0].toFixed(3)), y: parseFloat(r[1].toFixed(3)), z: parseFloat(r[2].toFixed(3)), occupancy: "1", B_iso_or_equiv: "0.00", type_symbol: e, charge: n ?? 0 };
}, Qoe = function(t, e) {
  var r = [], n = [], i = 1, a = "sdf", o = [], s = [], u = !1, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), d = t.sort(function(v) {
    var g;
    return ((g = gs(v)) === null || g === void 0 ? void 0 : g.sourceData.kind) === "mmCIF" ? -1 : 1;
  });
  d.forEach(function(v, g) {
    var y;
    v && ((y = gs(v)) === null || y === void 0 ? void 0 : y.sourceData.kind) === "mmCIF" && Array.from(gs(v).properties.structAsymMap.keys()).forEach(function(b) {
      l.set("".concat(g, `
`).concat(b), b), c.has(b) && (u = !0), c.add(b);
    });
  });
  var f = "", h = 1;
  if (l.size > 35) return { format: "pdb", type: km.PDB, content: "" };
  if (u) c.clear(), Array.from(l.keys()).forEach(function(v, g) {
    var y = 65 + g > 90 ? String.fromCharCode(65 + g) : "".concat(g);
    l.set(v, y), g === l.size - 1 && (f = 65 + g + 1 > 90 ? String.fromCharCode(65 + g + 1) : "".concat(g));
  });
  else {
    for (var m = 65; m < 91 && f === ""; m++) {
      var p = String.fromCharCode(m);
      c.has(p) || (f = p);
    }
    for (m = 48; m < 58 && f === ""; m++)
      p = String.fromCharCode(m), c.has(p) || (f = p);
  }
  return d.forEach(function(v, g) {
    var y;
    if (v) if (((y = gs(v)) === null || y === void 0 ? void 0 : y.sourceData.kind) === "mmCIF") {
      var b = [], S = Bx(v, ["HEADER"]);
      b.push.apply(b, S);
      var _ = ms(v), x = v.units[0], C = [];
      _.forEach(function(T) {
        var F, N = x.model.atomicHierarchy.chains.auth_asym_id.value(x.chainIndex[T]), R = { elementId: i, atom_id: "".concat(i), group_PDB: x.model.atomicHierarchy.residues.group_PDB.value(x.residueIndex[T]), auth_atom_id: x.model.atomicHierarchy.atoms.auth_atom_id.value(T), label_alt_id: x.model.atomicHierarchy.atoms.label_alt_id.value(T), auth_comp_id: x.model.atomicHierarchy.atoms.label_comp_id.value(T), auth_asym_id: (F = l.get("".concat(g, `
`).concat(N))) !== null && F !== void 0 ? F : N, auth_seq_id: x.model.atomicHierarchy.residues.auth_seq_id.value(x.residueIndex[T]), pdbx_PDB_ins_code: x.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(x.residueIndex[T]), x: x.model.atomicConformation.x[T], y: x.model.atomicConformation.y[T], z: x.model.atomicConformation.z[T], occupancy: x.model.atomicConformation.occupancy.value(T), B_iso_or_equiv: x.model.atomicConformation.B_iso_or_equiv.value(T), type_symbol: r2(x.model.atomicHierarchy.atoms.type_symbol.value(T)), charge: x.model.atomicHierarchy.atoms.pdbx_formal_charge.value(T) };
        C.push(R), i++;
      });
      var A = /* @__PURE__ */ new Map();
      v.units.forEach(function(T) {
        for (var F = 0, N = T.bonds.a.length; F < N; F++) {
          var R = T.elements[T.bonds.a[F]], L = T.elements[T.bonds.b[F]];
          if (_.includes(R) && _.includes(L) && !A.has("".concat(R, "_").concat(L)) && !A.has("".concat(L, "_").concat(R))) {
            var V = T.bonds.edgeProps.order[F];
            A.set("".concat(R, "_").concat(L), { a: C[_.indexOf(R)].elementId, b: C[_.indexOf(L)].elementId, order: V, atom_idA: C[_.indexOf(R)].atom_id, atom_idB: C[_.indexOf(R)].atom_id });
          }
        }
      }), r.push.apply(r, C), n.push.apply(n, Array.from(A).map(function(T) {
        return T[1];
      })), a = "pdb";
    } else {
      var w = ms(v), I = v.units[0], P = [], M = /* @__PURE__ */ new Map();
      w.forEach(function(T) {
        var F;
        P.push({ elementId: i, group_PDB: "HETATM", atom_id: "".concat(i), auth_atom_id: I.model.atomicHierarchy.atoms.label_atom_id.value(T), label_alt_id: I.model.atomicHierarchy.atoms.label_alt_id.value(T), auth_comp_id: I.model.atomicHierarchy.atoms.label_comp_id.value(T), auth_asym_id: f, auth_seq_id: "".concat(h), pdbx_PDB_ins_code: I.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(I.residueIndex[T]), x: I.model.atomicConformation.x[T], y: I.model.atomicConformation.y[T], z: I.model.atomicConformation.z[T], occupancy: I.model.atomicConformation.occupancy.value(T), B_iso_or_equiv: I.model.atomicConformation.B_iso_or_equiv.value(T), type_symbol: r2(I.model.atomicHierarchy.atoms.type_symbol.value(T)), charge: I.model.atomicHierarchy.atoms.pdbx_formal_charge.value(T) || ((F = Dl.Provider.get(I.model)) === null || F === void 0 ? void 0 : F.data.value(T)) || 0 }), i++;
      }), v.units.forEach(function(T) {
        for (var F = 0, N = T.bonds.a.length; F < N; F++) {
          var R = T.elements[T.bonds.a[F]], L = T.elements[T.bonds.b[F]];
          if (w.includes(R) && w.includes(L) && !M.has("".concat(R, "_").concat(L)) && !M.has("".concat(L, "_").concat(R))) {
            var V = T.bonds.edgeProps.order[F];
            M.set("".concat(R, "_").concat(L), { a: P[w.indexOf(R)].elementId, b: P[w.indexOf(L)].elementId, order: V, atom_idA: P[w.indexOf(R)].atom_id, atom_idB: P[w.indexOf(R)].atom_id });
          }
        }
      }), h++, s.push.apply(s, P), n.push.apply(n, Array.from(M).map(function(T) {
        return T[1];
      }));
    }
  }), o.length === 2 && n.push({ a: o[0], b: o[1], order: 1, atom_idA: "".concat(o[0]), atom_idB: "".concat(o[1]) }), r.push.apply(r, s), a === "pdb" ? { format: "pdb", type: km.PDB, content: r.length > 99999 ? "" : R7(r, n, !1, !1) } : { format: "sdf", type: km.SDF, content: r.length > 999 || n.length > 999 ? "" : "".concat(o3(r, n), `
$$$$`) };
}, Joe = function(t, e) {
  switch (e) {
    case gr.Pdb:
      return $oe(t);
    case gr.Sdf:
    case gr.Mol:
      return pL(t);
    default:
      return [t];
  }
}, $oe = function(t) {
  var e = t.split(`
`), r = [], n = [[]], i = 0;
  e.forEach(function(s) {
    switch (s[0]) {
      case "A":
        if (s.startsWith("ATOM")) return void n[i].push(s);
        if (s.startsWith("AUTHER")) return;
        r.push(s);
        break;
      case "C":
        if (s.startsWith("CONECT")) return void n[i].push(s);
        r.push(s);
        break;
      case "E":
        if (s.startsWith("ENDMDL")) return void (n[i].length > 0 && (i++, n.push([])));
        if (s.startsWith("END")) return;
        r.push(s);
        break;
      case "H":
        if (s.startsWith("HETATM")) return void n[i].push(s);
        r.push(s);
        break;
      case "M":
        if (s.startsWith("MODEL")) return void (n[i].length > 0 && (i++, n.push([])));
        if (s.startsWith("MASTER")) return;
        r.push(s);
        break;
      case "R":
        if (s.startsWith("REVDAT")) return;
        r.push(s);
        break;
      case "S":
        if (s.startsWith("SOURCE")) return;
        r.push(s);
        break;
      case "T":
        if (s.startsWith("TER")) return void n[i].push(s);
        r.push(s);
        break;
      default:
        r.push(s);
    }
  });
  var a = r.join(`
`), o = [];
  return n.forEach(function(s) {
    s.length > 0 && o.push("".concat(a).concat(a ? `
` : "").concat(s.join(`
`)));
  }), o;
}, pL = function(t) {
  return t.split(/\$\$\$\$\r?\n?/).filter(function(e) {
    return e.trim() !== "";
  });
}, ese = function(t) {
  for (var e = t.split(`
`), r = !0, n = !1, i = [], a = [], o = 0, s = e.length; o < s; o++) {
    var u = e[o];
    if (r) {
      if (i.length < 4)
        i.push(u), i.length === 4 && (c = e8(u, voe)).length > 0 && a.push({ index: o, info: c });
      else if (u.startsWith("M  END")) n = !0, r = !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 = e8(u, goe)).length > 0 && a.push({ index: o, info: c }) : (c = e8(u, moe)).length > 0 && a.push({ index: o, info: c });
        }
      }
    } else u.startsWith("$$$$") && (r = !0, i = []);
  }
  return n || a.push({ index: 0, info: [{ start: 0, end: 0 }] }), a;
}, tse = function(t, e) {
  switch (e) {
    case gr.Sdf:
    case gr.Mol:
      return ese(t);
    default:
      return [];
  }
}, rse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a, o, s, u, c, l;
    return ye(this, function(d) {
      switch (d.label) {
        case 0:
          if (!t.trim()) return [2, [Ec()]];
          e = [], r = pL(t), n = 0, i = r, d.label = 1;
        case 1:
          return n < i.length ? [4, Yoe(i[n]).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, (f = u, tr.create("Parse SDF", function(h) {
            return fL(f.molFile, N7.create(f), h);
          })).run()]) : [3, 6];
        case 4:
          c = d.sent(), l = tt.ofModel(c.representative), e.push(l), d.label = 5;
        case 5:
          return o++, [3, 3];
        case 6:
          return n++, [3, 1];
        case 7:
          return [2, e];
      }
      var f;
    });
  });
} };
function nse(t) {
  return function(e, r, n) {
    return function(i, a, o, s) {
      var u = i.data, c = i.indices, l = i.count, d = s.valueType, f = d === "str" ? function(h) {
        var m = c[2 * h] + a, p = c[2 * h + 1];
        if (m >= p) return "";
        var v = m + o;
        return v > p && (v = p), function(g, y, b) {
          for (var S = y, _ = b - 1, x = g.charCodeAt(S); (x === 9 || x === 32) && S <= _; ) x = g.charCodeAt(++S);
          for (x = g.charCodeAt(_); (x === 9 || x === 32) && _ >= S; ) x = g.charCodeAt(--_);
          return g.substring(S, _ + 1);
        }(u, m, v);
      } : d === "int" ? function(h) {
        var m = c[2 * h] + a;
        return m > c[2 * h + 1] ? 0 : e0(u, m, m + o);
      } : function(h) {
        var m = c[2 * h] + a;
        return m > c[2 * h + 1] ? 0 : function(p, v, g) {
          for (; v < g && p.charCodeAt(v) === 32; ) v++;
          return p0(p, v, g);
        }(u, m, m + o);
      };
      return { schema: s, __array: void 0, isDefined: !0, rowCount: l, value: f, valueKind: function(h) {
        return 0;
      }, toArray: function(h) {
        return Sa(l, f, h);
      }, areValuesEqual: function(h, m) {
        return f(h) === f(m);
      } };
    }(t, e, r, n);
  };
}
function ise(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a, o, s, u, c, l, d;
    return ye(this, function(f) {
      switch (f.label) {
        case 0:
          return e = t.tokenizer, r = t.numberOfAtoms, [4, ot.readLinesAsync(e, r, t.runtimeCtx, 1e5)];
        case 1:
          return n = f.sent(), i = e.data.substring(n.indices[0], n.indices[1]).substring(20), a = i.match(/\.\d+/g), o = a.length === 6, t.header.hasVelocities = o, t.header.precision.position = a[0].length - 1, t.header.precision.velocity = o ? a[3].length - 1 : 0, s = t.header.precision.position + 5, u = 20 + 3 * s, c = t.header.precision.velocity + 4, l = nse(n), d = se.Undefined(t.numberOfAtoms, se.Schema.float), [2, { count: t.numberOfAtoms, residueNumber: l(0, 5, se.Schema.int), residueName: l(5, 5, se.Schema.str), atomName: l(10, 5, se.Schema.str), atomNumber: l(15, 5, se.Schema.int), x: l(20, s, se.Schema.float), y: l(20 + s, s, se.Schema.float), z: l(20 + 2 * s, s, se.Schema.float), vx: o ? l(u, c, se.Schema.float) : d, vy: o ? l(u + c, c, se.Schema.float) : d, vz: o ? l(u + 2 * c, c, se.Schema.float) : d }];
      }
    });
  });
}
function ase(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return r = ot(t), [4, e.update({ message: "Parsing...", current: 0, max: t.length })];
        case 1:
          s.sent(), n = [], s.label = 2;
        case 2:
          return r.position < t.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 };
          }(r, e), function(u) {
            var c = u.tokenizer, l = u.header, d = ot.readLine(c);
            d.trim().length === 0 && (d = ot.readLine(c));
            var f = d.lastIndexOf("t=");
            f >= 0 ? (l.timeInPs = parseFloat(d.substring(f + 2)), l.title = d.substring(0, f).trim(), l.title && l.title[l.title.length - 1] === "," && (l.title = l.title.substring(0, l.title.length - 1))) : l.title = d;
          }(i), function(u) {
            var c = u.tokenizer;
            ot.markLine(c);
            var l = ot.getTokenString(c);
            u.numberOfAtoms = parseInt(l);
          }(i), [4, ise(i)]) : [3, 4];
        case 3:
          return a = s.sent(), function(u) {
            var c = u.tokenizer, l = ot.readLine(c).trim().split(/\s+/g);
            u.header.box = [+l[0], +l[1], +l[2]];
          }(i), n.push({ header: i.header, atoms: a }), [3, 2];
        case 4:
          return o = { structures: n }, [2, ji.success(o)];
      }
    });
  });
}
function hL(t) {
  var e = this;
  return tr.create("Parse GRO", function(r) {
    return _e(e, 0, void 0, function() {
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, ase(t, r)];
          case 1:
            return [2, n.sent()];
        }
      });
    });
  });
}
var uM = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", L7, ose = XR(function(t) {
  for (var e = t, r = 0, n = uM[e % 26]; e >= 26; ) e = Math.floor(e / 26), n += uM[e % 26], r += 1;
  return r >= 5 && console.warn("getChainId overflow"), n;
});
function mL(t) {
  var e = this;
  return tr.create("Parse GRO", function(r) {
    return _e(e, 0, void 0, function() {
      var n, i, a, o, s, u;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            n = L7.fromGro(t), i = [], a = 0, o = t.structures.length, c.label = 1;
          case 1:
            return a < o ? (s = function(l, d) {
              for (var f = l.atomName, h = l.residueName, m = new Array(l.count), p = new Array(l.count), v = new Uint32Array(l.count), g = new Uint32Array(l.count), y = new Array(l.count), b = new k0(), S = new L0(l.residueNumber, l.atomName), _ = "", x = 0, C = "", A = 0, w = 0, I = -1, P = 0, M = l.count; P < M; ++P) {
                var T = l.residueNumber.value(P);
                if (T !== I) {
                  var F = l.residueName.value(P), N = g2(S.add(F, P).type, F);
                  N === w && (T === I + 1 || I === 99999 && T === 0) || (C = ose(x), x += 1, A = 0), _ = b.getEntityId(F, N, C), A += 1, I = T, w = N;
                }
                m[P] = _, p[P] = C, v[P] = A, g[P] = P, y[P] = Ix(l.atomName.value(P), l.residueName.value(P));
              }
              var R = se.ofStringArray(p), L = Hr.ofPartialColumns(Ho.atom_site, { auth_asym_id: R, auth_atom_id: f, auth_comp_id: h, auth_seq_id: l.residueNumber, Cartn_x: se.ofFloatArray(se.mapToArray(l.x, function(V) {
                return 10 * V;
              }, Float32Array)), Cartn_y: se.ofFloatArray(se.mapToArray(l.y, function(V) {
                return 10 * V;
              }, Float32Array)), Cartn_z: se.ofFloatArray(se.mapToArray(l.z, function(V) {
                return 10 * V;
              }, Float32Array)), id: se.ofIntArray(g), label_asym_id: R, label_atom_id: f, label_comp_id: h, label_seq_id: se.ofIntArray(v), label_entity_id: se.ofStringArray(m), occupancy: se.ofConst(1, l.count, se.Schema.float), type_symbol: se.ofStringArray(y), pdbx_PDB_model_num: se.ofConst(d, l.count, se.Schema.int) }, l.count);
              return hf({ entity: b.getEntityTable(), chem_comp: S.getChemCompTable(), atom_site: L });
            }(t.structures[a].atoms, a + 1), [4, Pl(s, n, r)]) : [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 Ym(i)];
        }
      });
    });
  });
}
(function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "gro";
  }, t.fromGro = function(e) {
    return { kind: "gro", name: e.structures[0].header.title, data: e };
  };
})(L7 || (L7 = {}));
var Oo, sse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, hL(t).run()];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, mL(e.result).run()];
        case 2:
          return [2, r.sent().representative];
      }
    });
  });
} }, F1 = 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]), i8 = 9;
function use() {
  throw new Error("(xdrfile error) Undefined error.");
}
function cse(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F, N, R, L, V;
    return ye(this, function(U) {
      switch (U.label) {
        case 0:
          r = new DataView(e.buffer, e.byteOffset), i = (n = { frames: [], boxes: [], times: [], timeOffset: 0, deltaTime: 0 }).frames, a = n.boxes, o = n.times, s = [0, 0, 0, 0, 0, 0], u = [0, 0, 0], c = [0, 0, 0], l = [0, 0, 0], d = [0.1, 0.1, 0.1], f = [0.1, 0.1, 0.1], h = 0, m = Oo.buf, U.label = 1;
        case 1:
          for (p = void 0, v = r.getInt32(h + 4), h += 12, o.push(r.getFloat32(h)), h += 4, g = new Float32Array(9), T = 0; T < 9; ++T) g[T] = 10 * r.getFloat32(h), h += 4;
          if (a.push(g), v <= 9) for (p = { count: v / 3, x: new Float32Array(v / 3), y: new Float32Array(v / 3), z: new Float32Array(v / 3) }, T = 0; T < v / 3; ++T) p.x[T] = r.getFloat32(h), p.y[T] = r.getFloat32(h), p.z[T] = r.getFloat32(h), h += 4;
          else {
            for (m[0] = m[1] = m[2] = 0, u[0] = u[1] = u[2] = 0, l[0] = l[1] = l[2] = 0, c[0] = c[1] = c[2] = 0, d[0] = d[1] = d[2] = 0, f[0] = f[1] = f[2] = 0, p = { count: v, x: new Float32Array(v), y: new Float32Array(v), z: new Float32Array(v) }, y = 0, b = r.getInt32(h), h += 4, S = r.getFloat32(h), h += 4, s[0] = r.getInt32(h), s[1] = r.getInt32(h + 4), s[2] = r.getInt32(h + 8), s[3] = r.getInt32(h + 12), s[4] = r.getInt32(h + 16), s[5] = r.getInt32(h + 20), u[0] = s[3] - s[0] + 1, u[1] = s[4] - s[1] + 1, u[2] = s[5] - s[2] + 1, h += 24, _ = void 0, (u[0] | u[1] | u[2]) > 16777215 ? (c[0] = Oo.sizeOfInt(u[0]), c[1] = Oo.sizeOfInt(u[1]), c[2] = Oo.sizeOfInt(u[2]), _ = 0) : _ = Oo.sizeOfInts(3, u), x = r.getInt32(h), h += 4, A = F1[C = i8 > (C = x - 1) ? i8 : C] / 2 | 0, w = F1[x] / 2 | 0, l[0] = l[1] = l[2] = F1[x], I = 4 * Math.ceil(r.getInt32(h) / 4), h += 4, P = 1 / S, M = 0, T = 0, d[0] = d[1] = d[2] = 0; T < b; ) {
              if (_ === 0 ? (d[0] = Oo.decodeBits(e, h, c[0]), d[1] = Oo.decodeBits(e, h, c[1]), d[2] = Oo.decodeBits(e, h, c[2])) : Oo.decodeInts(e, h, _, u, d), T++, d[0] += s[0], d[1] += s[1], d[2] += s[2], f[0] = d[0], f[1] = d[1], f[2] = d[2], F = Oo.decodeBits(e, h, 1), N = 0, F === 1 && (M = Oo.decodeBits(e, h, 5), M -= N = M % 3, N--), M > 0) for (d[0] = d[1] = d[2] = 0, R = 0; R < M; R += 3) Oo.decodeInts(e, h, x, l, d), T++, d[0] += f[0] - w, d[1] += f[1] - w, d[2] += f[2] - w, R === 0 ? (L = d[0], d[0] = f[0], f[0] = L, L = d[1], d[1] = f[1], f[1] = L, L = d[2], d[2] = f[2], f[2] = L, p.x[y] = f[0] * P, p.y[y] = f[1] * P, p.z[y] = f[2] * P, y++) : (f[0] = d[0], f[1] = d[1], f[2] = d[2]), p.x[y] = d[0] * P, p.y[y] = d[1] * P, p.z[y] = d[2] * P, y++;
              else p.x[y] = d[0] * P, p.y[y] = d[1] * P, p.z[y] = d[2] * P, y++;
              x += N, N < 0 ? (w = A, A = x > i8 ? F1[x - 1] / 2 | 0 : 0) : N > 0 && (A = w, w = F1[x] / 2 | 0), l[0] = l[1] = l[2] = F1[x], l[0] !== 0 && l[1] !== 0 && l[2] !== 0 || use();
            }
            h += I;
          }
          for (V = 0; V < v; V++) p.x[V] *= 10, p.y[V] *= 10, p.z[V] *= 10;
          return i.push(p), t.shouldUpdate ? [4, t.update({ current: h, max: e.length })] : [3, 3];
        case 2:
          U.sent(), U.label = 3;
        case 3:
          return h >= e.length ? [3, 4] : [3, 1];
        case 4:
          return o.length >= 1 && (n.timeOffset = o[0]), o.length >= 2 && (n.deltaTime = o[1] - o[0]), [2, n];
      }
    });
  });
}
function lse(t) {
  var e = this;
  return tr.create("Parse XTC", function(r) {
    return _e(e, 0, void 0, function() {
      var n, i;
      return ye(this, function(a) {
        switch (a.label) {
          case 0:
            return a.trys.push([0, 2, , 3]), r.update({ canAbort: !0, message: "Parsing trajectory..." }), [4, cse(r, t)];
          case 1:
            return n = a.sent(), [2, ji.success(n)];
          case 2:
            return i = a.sent(), [2, ji.error("" + i)];
          case 3:
            return [2];
        }
      });
    });
  });
}
function iy() {
  return iy.empty();
}
function dse(t) {
  var e = this;
  return tr.create("Parse XTC", function(r) {
    return _e(e, 0, void 0, function() {
      var n, i, a, o, s, u, c, l, d;
      return ye(this, function(f) {
        switch (f.label) {
          case 0:
            return [4, r.update("Converting to coordinates")];
          case 1:
            for (f.sent(), n = z6(t.deltaTime, "step"), i = z6(t.timeOffset, n.unit), a = [], o = 0, s = t.frames.length; o < s; ++o) u = t.boxes[o], c = E.fromArray(E(), u, 0), l = E.fromArray(E(), u, 3), d = E.fromArray(E(), u, 6), a.push({ elementCount: t.frames[o].count, cell: iy.fromBasis(c, l, d), x: t.frames[o].x, y: t.frames[o].y, z: t.frames[o].z, xyzOrdering: { isIdentity: !0 }, time: z6(i.value + n.value * o, n.unit) });
            return [2, I3.create(a, n, i)];
        }
      });
    });
  });
}
(function(t) {
  t.sizeOfInt = function(s) {
    for (var u = 1, c = 0; s >= u && c < 32; ) c++, u <<= 1;
    return c;
  };
  var e = new Uint8Array(32);
  t.sizeOfInts = function(s, u) {
    var c = 1, l = 0;
    e[0] = 1;
    for (var d = 0; d < s; d++) {
      var f = void 0, h = 0;
      for (f = 0; f < c; f++) h += e[f] * u[d], e[f] = 255 & h, h >>= 8;
      for (; h !== 0; ) e[f++] = 255 & h, h >>= 8;
      c = f;
    }
    var m = 1;
    for (c--; e[c] >= m; ) l++, m *= 2;
    return l + 8 * c;
  };
  var r = new ArrayBuffer(24);
  t.buf = new Int32Array(r);
  var n = new Uint32Array(r);
  function i(s, u, c) {
    for (var l = c, d = (1 << l) - 1, f = n[1], h = n[2], m = t.buf[0], p = 0; l >= 8; ) p |= (h = h << 8 | s[u + m++]) >> f << l - 8, l -= 8;
    return l > 0 && (f < l && (f += 8, h = h << 8 | s[u + m++]), p |= h >> (f -= l) & (1 << l) - 1), p &= d, t.buf[0] = m, t.buf[1] = f, t.buf[2] = h, p;
  }
  function a(s, u) {
    var c = n[2], l = t.buf[0];
    return c = c << 8 | s[u + l], t.buf[0] = l + 1, t.buf[2] = c, c >> n[1] & 255;
  }
  t.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];
  t.decodeInts = function(s, u, c, l, d) {
    var f = c, h = 0;
    for (o[0] = 0, o[1] = 0, o[2] = 0, o[3] = 0; f > 8; ) o[h++] = a(s, u), f -= 8;
    f > 0 && (o[h++] = i(s, u, f));
    for (var m = 2; m > 0; m--) {
      for (var p = 0, v = l[m], g = h - 1; g >= 0; g--) {
        var y = (p = p << 8 | o[g]) / v | 0;
        o[g] = y, p -= y * v;
      }
      d[m] = p;
    }
    d[0] = o[0] | o[1] << 8 | o[2] << 16 | o[3] << 24;
  };
})(Oo || (Oo = {})), function(t) {
  function e(n, i) {
    return { size: n, anglesInRadians: i };
  }
  function r() {
    return e(E(), E());
  }
  t.create = e, t.empty = r, t.fromBasis = function(n, i, a) {
    var o = E.magnitude(n), s = E.magnitude(i), u = E.magnitude(a), c = Math.acos(E.dot(i, a) / (s * u)), l = Math.acos(E.dot(n, a) / (o * u)), d = Math.acos(E.dot(n, i) / (o * s));
    return o <= 0 || s <= 0 || u <= 0 || c >= Math.PI || l >= Math.PI || d >= Math.PI ? r() : e(E.create(o, s, u), E.create(c, l, d));
  };
}(iy || (iy = {}));
var fse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(e) {
      return [2, new Promise(function(r) {
        var n = new FileReader();
        n.onload = function(i) {
          return _e(this, 0, void 0, function() {
            var a, o;
            return ye(this, function(s) {
              switch (s.label) {
                case 0:
                  return [4, lse(new Uint8Array(n.result)).run()];
                case 1:
                  if ((a = s.sent()).isError) throw new Error(a.message);
                  return [4, dse(a.result).run()];
                case 2:
                  return o = s.sent(), r(o), [2];
              }
            });
          });
        }, n.readAsArrayBuffer(t);
      })];
    });
  });
} };
function gL(t, e, r, n, i, a) {
  var o = t, s = e, u = r, c = Math.cos(n * Math.PI / 180), l = Math.cos(i * Math.PI / 180), d = Math.cos(a * Math.PI / 180), f = Math.sin(n * Math.PI / 180), h = Math.sin(i * Math.PI / 180), m = function() {
    var _ = (c * l - d) / (f * h);
    return Math.max(Math.min(_, 1), -1);
  }(), p = Math.acos(m), v = he.ofRows([[o * h, -s * f * Math.cos(p), 0, 0], [0, s * f * Math.sin(p), 0, 0], [o * l, s * c, u, 0], [0, 0, 0, 1]]), g = he.invert(he.zero(), v), y = E.create(v[0], v[4], v[8]), b = E.create(v[1], v[5], v[9]), S = E.create(v[2], v[6], v[10]);
  return { a: t, b: e, c: r, volume: Math.abs(E.dot(y, y)) * r, alpha: n, beta: i, gamma: a, vecA: y, vecB: b, vecC: S, matrix: v, invertMatrix: g };
}
function vL(t, e, r) {
  var n = E.create.apply(null, t), i = E.create.apply(null, e), a = E.create.apply(null, r), o = n[0], s = n[1], u = n[2], c = i[0], l = i[1], d = i[2], f = a[0], h = a[1], m = a[2], p = he.ofRows([[o, c, f, 0], [s, l, h, 0], [u, d, m, 0], [0, 0, 0, 1]]), v = he.invert(he.zero(), p), g = Math.sqrt(Math.abs(E.dot(n, n))), y = Math.sqrt(Math.abs(E.dot(i, i))), b = Math.sqrt(Math.abs(E.dot(a, a))), S = E.angle(i, a) * (180 / Math.PI), _ = E.angle(n, a) * (180 / Math.PI), x = E.angle(n, i) * (180 / Math.PI);
  return { a: g, b: y, c: b, volume: Math.abs(E.dot(n, n)) * b, alpha: S, beta: _, gamma: x, vecA: n, vecB: i, vecC: a, matrix: p, invertMatrix: v };
}
var ay, yL = [];
function pse(t) {
  ot.readLine(t);
  var e = +ot.readLine(t);
  ot.readLine(t);
  var r = +ot.readLine(t);
  isNaN(r) && (r = 0);
  var n = ot.readLine(t), i = new Float64Array(3), a = new Float64Array(3), o = new Float64Array(3);
  n.includes("xy xz yz") && function(_, x) {
    var C = x[0], A = x[1], w = x[2], I = x.map(function() {
      return ot.readLine(_).trim().split(/\s+/g).map(function(ie) {
        return Number(ie);
      });
    }), P = I[0], M = P[0], T = P[1], F = P[2], N = I[1], R = N[0], L = N[1], V = N[2], U = I[2], H = U[0], K = U[1], X = U[2], Y = [[M, T], [R, L], [H, K]], Q = [F, V, X], J = [0, Q[0], Q[1], Q[0] + Q[1]], te = [0, Q[2]], W = [[Math.min.apply(null, J), Math.max.apply(null, J)], [Math.min.apply(null, te), Math.max.apply(null, te)], [0, 0]];
    Y.forEach(function(ie, ae) {
      ie.forEach(function(ce, de) {
        Y[ae][de] = ce - W[ae][de];
      });
    });
    var j = Y.map(function(ie) {
      return ie[1] - ie[0];
    }), ee = [[j[0], 0, 0], [Q[0], j[1], 0], [Q[1], Q[2], j[2]]];
    C[0] = ee[0][0], C[1] = ee[0][1], C[2] = ee[0][2], A[0] = ee[1][0], A[1] = ee[1][1], A[2] = ee[1][2], w[0] = ee[2][0], w[1] = ee[2][1], w[2] = ee[2][2];
  }(t, [i, a, o]);
  var s = function(_, x, C) {
    var A = new Float64Array(x), w = new Float64Array(x), I = new Float64Array(x), P = new Float64Array(x), M = new Float64Array(x), T = [["id", A], ["type", w], ["x", I], ["y", P], ["z", M]];
    T.sort(function(L, V) {
      return C.indexOf(L[0]) - C.indexOf(V[0]);
    });
    for (var F = T.map(function(L) {
      return L[1];
    }), N = function(L) {
      ot.readLine(_).trim().split(/\s+/g).forEach(function(V, U) {
        F[U][L] = Number(V);
      });
    }, R = 0; R < x; R++) N(R);
    return [A, w, I, P, M];
  }(t, r, ot.readLine(t).replace("ITEM: ATOMS", "").split(/\s+/g)), u = s[0], c = s[1], l = s[2], d = s[3], f = s[4], h = [], m = [];
  c.forEach(function(_) {
    h[_] || (h[_] = yL[_].symbol), m.push(h[_]);
  });
  for (var p = vL(i, a, o), v = new Float64Array(r), g = new Float64Array(r), y = new Float64Array(r), b = 0; b < r; b++) {
    var S = E.create(l[b], d[b], f[b]);
    E.transformMat4(S, S, p.invertMatrix), v[b] = S[0], g[b] = S[1], y[b] = S[2];
  }
  return { count: r, comment: "", x: se.ofFloatArray(l), y: se.ofFloatArray(d), z: se.ofFloatArray(f), type_symbol: se.ofStringArray(m), cell: p, timestep: e, fractX: se.ofFloatArray(v), fractY: se.ofFloatArray(g), fractZ: se.ofFloatArray(y), id: se.ofFloatArray(u) };
}
function hse(t) {
  for (var e = ot(t), r = []; ; ) {
    var n = pse(e);
    if (n.count === 0) break;
    r.push(n);
  }
  var i = { molecules: r, isMaterial: !0 };
  return ji.success(i);
}
function Nx(t) {
  var e = this;
  return tr.create("Parse Mol", function() {
    return _e(e, 0, void 0, function() {
      var r;
      return ye(this, function(n) {
        return r = 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], f = o[s + 3], h = l.split(" ").map(function(L) {
              return +L;
            }), m = h[0], p = h[1], v = h[2], g = v === void 0 ? 0 : v, y = d.split(" ").map(function(L) {
              return +L;
            }), b = y[0], S = y[1], _ = y[2], x = _ === void 0 ? 0 : _, C = f.split(" ").map(function(L) {
              return +L;
            }), A = C[0], w = C[1], I = C[2], P = I === void 0 ? 0 : I;
            if (c) {
              var M = [[p - m - Math.abs(g) - Math.abs(x), 0, 0], [g, S - b - Math.abs(P), 0], [x, P, w - A]], T = o.slice(u + 1).map(function(L) {
                return L.split(" ");
              }).map(function(L) {
                var V = L[0], U = L[1], H = function(K, X) {
                  for (var Y = [], Q = 0; Q < K.length; Q++) {
                    Y[Q] = [];
                    for (var J = 0; J < X[0].length; J++) {
                      for (var te = 0, W = 0; W < K[0].length; W++) te += +K[Q][W] * +X[W][J];
                      Y[Q][J] = te;
                    }
                  }
                  return Y;
                }([[L[2], L[3], L[4]]], M)[0];
                return [V, U, H[0], H[1], H[2]];
              }), F = T.map(function(L) {
                return L.join(" ");
              }).join(`
`);
              return [o.slice(0, s + 4).join(`
`), R = "ITEM: ATOMS id type x y z", F].join(`
`);
            }
            var N = [[m, p, g], [b, S, x], [A, w, P]].map(function(L) {
              return L.join(" ");
            });
            o.splice.apply(o, Ze([s + 1, 3], N, !1)), F = (T = 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 R = "ITEM: ATOMS id type x y z";
            return [o.slice(0, s + 4).join(`
`), R, F].join(`
`);
          });
          return a.join(`
`);
        }(t), [2, hse(r)];
      });
    });
  });
}
function mse(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F, N, R;
    return ye(this, function(L) {
      switch (L.label) {
        case 0:
          for (r = ay.formatMol(t), n = r.molecules, i = 0, a = 0, o = n; a < o.length; a++) p = o[a], i += p.count;
          for (s = new Array(i), u = new Int32Array(i), c = new Float32Array(i), l = new Float32Array(i), d = new Float32Array(i), f = new Int32Array(i), h = function(V) {
            if (V.length) {
              var U = V[0], H = U.cell, K = U.spaceGroup;
              if (H) {
                var X = H.a, Y = H.b, Q = H.c, J = H.alpha, te = H.beta, W = H.gamma, j = H.matrix, ee = H.invertMatrix, ie = function(ce) {
                  if (!ce) return "P 1";
                  var de = ce.it_number.value(0), Ce = ce["name_h-m_full"].value(0).replace("-", " ");
                  return ce.it_number.isDefined ? (ce["name_h-m_full"].isDefined, de) : Ce;
                }(K), ae = au.createMaterial(ie, E.create(X, Y, Q), E.scale(E(), E.create(J, te, W), Math.PI / 180), X * Y * Q, ee, j);
                return { spacegroup: ko.create(ae), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
              }
            }
          }(n), m = 0, R = 0; R < n.length; R++) for (p = n[R], v = 0; v < p.count; v++) s[m] = p.type_symbol.value(v), c[m] = p.x.value(v), l[m] = p.y.value(v), d[m] = p.z.value(v), u[m] = v, f[m] = R, m++;
          return g = se.ofConst("MOL", i, se.Schema.str), y = se.ofConst("A", i, se.Schema.str), b = se.ofConst(1, i, se.Schema.int), S = se.ofStringArray(s), _ = Hr.ofPartialColumns(Ho.atom_site, { auth_asym_id: y, auth_atom_id: S, auth_comp_id: g, auth_seq_id: b, Cartn_x: se.ofFloatArray(c), Cartn_y: se.ofFloatArray(l), Cartn_z: se.ofFloatArray(d), id: se.ofIntArray(u), label_asym_id: y, label_atom_id: S, label_comp_id: g, label_seq_id: b, label_entity_id: se.ofConst("1", i, se.Schema.str), occupancy: se.ofConst(1, i, se.Schema.float), type_symbol: S, pdbx_PDB_model_num: se.ofIntArray(f) }, i), (x = new k0()).setNames([["MOL", "Ligand"]]), x.getEntityId("MOL", 0, "A"), (C = new L0(b, S)).setNames([["MOL", "Unknown Molecule"]]), C.add("MOL", 0), [4, Pl(hf({ entity: x.getEntityTable(), chem_comp: C.getChemCompTable(), atom_site: _ }), ay.create(r), e)];
        case 1:
          if ((A = L.sent()).frameCount > 0 && (w = A.representative, Da.Provider.set(w, h)), I = n[0], P = I.bonds) for (M = se.ofIntArray(P.atomA), T = se.ofIntArray(P.atomB), F = se.ofIntArray(new Array(P.count).fill(1)), N = Xi.fromData({ pairs: { indexA: M, indexB: T, order: F }, count: I.count }), R = 0; R < A.frameCount; R++) Xi.Provider.set(A.getFrameAtIndex(R), N);
          return [2, A];
      }
    });
  });
}
function mf(t) {
  return tr.create("Parse Material", function(e) {
    return mse(t, e);
  });
}
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(t) {
  var e = t[0], r = t[1];
  yL[r["Atomic no"]] = O(O({}, r), { symbol: e });
}), function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "material";
  }, t.create = function(e) {
    return { kind: "material", name: "material", data: e };
  }, t.formatMol = function(e) {
    var r = e.isMaterial, n = e.molecules;
    if (!r || n.length > 1 || !n[0].cell) return e;
    for (var i = n[0], a = i.cell, o = i.x, s = i.y, u = i.z, c = o.rowCount, l = new Float32Array(c), d = new Float32Array(c), f = new Float32Array(c), h = 0; h < c; h++) {
      var m = E.create(o.value(h), s.value(h), u.value(h)), p = E.transformMat4(E.zero(), m, a.invertMatrix);
      l[h] = p[0], d[h] = p[1], f[h] = p[2];
    }
    return { isMaterial: !0, molecules: [O(O({}, n[0]), { fractX: se.ofFloatArray(l), fractY: se.ofFloatArray(d), fractZ: se.ofFloatArray(f) })] };
  };
}(ay || (ay = {}));
var k7, gse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, Nx(t).run()];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, mf(e.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return tt.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function vse(t) {
  var e = t.position >= t.data.length - 1 ? 0 : +ot.readLine(t);
  isNaN(e) && (e = 0);
  for (var r = ot.readLine(t), n = new Float64Array(e), i = new Float64Array(e), a = new Float64Array(e), o = new Array(e), s = 0; s < e; ++s) {
    var u = ot.readLineTrim(t).split(/\s+/g);
    o[s] = u[0], n[s] = +u[1], i[s] = +u[2], a[s] = +u[3];
  }
  return { count: e, comment: r, x: se.ofFloatArray(n), y: se.ofFloatArray(i), z: se.ofFloatArray(a), type_symbol: se.ofStringArray(o) };
}
function yse(t) {
  for (var e = ot(t), r = []; ; ) {
    var n = vse(e);
    if (n.count === 0) break;
    r.push(n);
  }
  var i = { molecules: r, isMaterial: !1 };
  return ji.success(i);
}
function bL(t) {
  var e = this;
  return tr.create("Parse Mol", function() {
    return _e(e, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, yse(t)];
      });
    });
  });
}
function _L(t) {
  return tr.create("Parse XYZ", function(e) {
    return function(r, n) {
      for (var i = r.molecules, a = 0, o = 0, s = i; o < s.length; o++) a += (v = s[o]).count;
      for (var u = new Array(a), c = new Int32Array(a), l = new Float32Array(a), d = new Float32Array(a), f = new Float32Array(a), h = new Int32Array(a), m = 0, p = 0; p < i.length; p++) for (var v = i[p], g = 0; g < v.count; g++) u[m] = v.type_symbol.value(g), l[m] = v.x.value(g), d[m] = v.y.value(g), f[m] = v.z.value(g), c[m] = g, h[m] = p, m++;
      var y = se.ofConst("MOL", a, se.Schema.str), b = se.ofConst("A", a, se.Schema.str), S = se.ofConst(1, a, se.Schema.int), _ = se.ofStringArray(u), x = Hr.ofPartialColumns(Ho.atom_site, { auth_asym_id: b, auth_atom_id: _, auth_comp_id: y, auth_seq_id: S, Cartn_x: se.ofFloatArray(l), Cartn_y: se.ofFloatArray(d), Cartn_z: se.ofFloatArray(f), id: se.ofIntArray(c), label_asym_id: b, label_atom_id: _, label_comp_id: y, label_seq_id: S, label_entity_id: se.ofConst("1", a, se.Schema.str), occupancy: se.ofConst(1, a, se.Schema.float), type_symbol: _, pdbx_PDB_model_num: se.ofIntArray(h) }, a), C = new k0();
      C.setNames([["MOL", "Unknown Entity"]]), C.getEntityId("MOL", 0, "A");
      var A = new L0(S, _);
      return A.setNames([["MOL", "Unknown Molecule"]]), A.add("MOL", 0), Pl(hf({ entity: C.getEntityTable(), chem_comp: A.getChemCompTable(), atom_site: x }), k7.create(r), n);
    }(t, e);
  });
}
(function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "xyz";
  }, t.create = function(e) {
    return { kind: "xyz", name: "xyz", data: e };
  };
})(k7 || (k7 = {}));
var xm, bse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return t.trim() ? [4, bL(t).run()] : [2, [Ec()]];
        case 1:
          if ((e = n.sent()).isError) throw e;
          return [4, _L(e.result).run()];
        case 2:
          return r = n.sent(), [2, [tt.ofModel(r.representative, { dynamicBonds: !0 })]];
      }
    });
  });
} };
function _se(t, e, r) {
  var n;
  return _e(this, 0, void 0, function() {
    var i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F, N, R, L, V, U, H, K, X, Y, Q, J, te, W, j, ee, ie, ae, ce, de, Ce, De, ke, He, We;
    return ye(this, function(Ne) {
      switch (Ne.label) {
        case 0:
          for (i = t.atom_site._rowCount, a = se.ofConst("MOL", i, se.Schema.str), o = se.ofConst("A", i, se.Schema.str), s = se.ofConst(1, i, se.Schema.int), u = function(Je) {
            var Re = Je.cell, nt = (re = Je.space_group, le = re.it_number.value(0), fe = re["name_h-m_full"].value(0).replace("-", " "), re.it_number.isDefined ? (re["name_h-m_full"].isDefined, le) : fe), ne = au.create(nt, E.create(Re.length_a.value(0), Re.length_b.value(0), Re.length_c.value(0)), E.scale(E(), E.create(Re.angle_alpha.value(0), Re.angle_beta.value(0), Re.angle_gamma.value(0)), Math.PI / 180)), re, le, fe;
            return { spacegroup: ko.create(ne), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
          }(t), c = u.spacegroup.cell.fromFractional, l = t.atom_site, d = l.fract_x, f = l.fract_y, h = l.fract_z, m = new Float32Array(i), p = new Float32Array(i), v = new Float32Array(i), g = E(), Ce = 0; Ce < i; ++Ce) E.set(g, d.value(Ce), f.value(Ce), h.value(Ce)), E.transformMat4(g, g, c), m[Ce] = g[0], p[Ce] = g[1], v[Ce] = g[2];
          if (y = t.atom_site, b = y.type_symbol, S = y.label, b.isDefined) {
            for (I = new Array(i), C = new Int8Array(i), Ce = 0; Ce < i; ++Ce) A = b.value(Ce), w = A.length, A[w - 1] === "+" ? C[Ce] = parseInt(A[w - 2]) : A[w - 2] === "+" ? C[Ce] = parseInt(A[w - 1]) : A[w - 1] === "-" ? C[Ce] = -parseInt(A[w - 2]) : A[w - 2] === "-" ? C[Ce] = -parseInt(A[w - 1]) : (I[Ce] = A, C[Ce] = 0), A = (A = (A = A.replace(/\-/g, "")).replace(/\+/g, "")).replace(/[0-9]/g, ""), I[Ce] = A;
            _ = se.ofStringArray(I), x = se.ofIntArray(C);
          } else {
            for (I = new Array(i), Ce = 0; Ce < i; ++Ce) I[Ce] = Ix(S.value(Ce), "");
            _ = se.ofStringArray(I), x = se.Undefined(i, se.Schema.int);
          }
          return P = Hr.ofPartialColumns(Ho.atom_site, { auth_asym_id: o, auth_atom_id: S, auth_comp_id: a, auth_seq_id: s, Cartn_x: se.ofFloatArray(m), Cartn_y: se.ofFloatArray(p), Cartn_z: se.ofFloatArray(v), id: se.range(0, i - 1), label_asym_id: o, label_atom_id: S, label_comp_id: a, label_seq_id: s, label_entity_id: se.ofConst("1", i, se.Schema.str), occupancy: t.atom_site.occupancy.isDefined ? t.atom_site.occupancy : se.ofConst(1, i, se.Schema.float), type_symbol: _, pdbx_formal_charge: x, pdbx_PDB_model_num: se.ofConst(1, i, se.Schema.int), B_iso_or_equiv: t.atom_site.u_iso_or_equiv }, i), M = t.chemical.name_common.value(0) || t.chemical.name_systematic.value(0) || t.chemical_formula.sum.value(0), (T = new k0()).setNames([["MOL", M || "Ligand"]]), T.getEntityId("MOL", 0, "A"), (F = new L0(s, t.atom_site.type_symbol)).setNames([["MOL", M || "Unknown Molecule"]]), F.add("MOL", 0), [4, Pl(hf({ entity: T.getEntityTable(), chem_comp: F.getChemCompTable(), atom_site: P }), e, r)];
        case 1:
          if ((N = Ne.sent()).frameCount > 0 && (R = N.representative, Da.Provider.set(R, u), (L = t.geom_bond._rowCount) > 0)) {
            for (V = {}, U = t.atom_site.label, Ce = 0, H = U.rowCount; Ce < H; ++Ce) V[U.value(Ce)] = Ce;
            for (K = (n = e.data.frame.categories.ccdc_geom_bond_type) === null || n === void 0 ? void 0 : n.getField(""), X = [], Y = [], Q = [], J = [], te = [], W = /* @__PURE__ */ new Set(), j = 0, ee = t.geom_bond, ie = ee.atom_site_label_1, ae = ee.atom_site_label_2, ce = ee.valence, de = ee.distance, Ce = 0; Ce < L; ++Ce) De = V[ie.value(Ce)], ke = V[ae.value(Ce)], He = De < ke ? iu(De, ke) : iu(ke, De), W.has(He) || (W.add(He), X[j] = De, Y[j] = ke, J[j] = de.value(Ce) || -1, K ? (We = K.str(Ce)) === "D" ? (Q[j] = 2, te[j] = 1) : We === "A" ? (Q[j] = 1, te[j] = 17) : (Q[j] = 1, te[j] = 1) : (te[j] = 1, Q[j] = ce.isDefined ? ce.value(Ce) : 1), j += 1);
            Xi.Provider.set(R, Xi.fromData({ pairs: { indexA: se.ofIntArray(X), indexB: se.ofIntArray(Y), order: se.ofIntArray(Q), distance: se.ofFloatArray(J), flag: se.ofIntArray(te) }, count: i }));
          }
          return [2, N];
      }
    });
  });
}
function xse(t) {
  var e = xm.fromFrame(t);
  return tr.create("Parse CIF Core", function(r) {
    return _se(e.data.db, e, r);
  });
}
$d.Provider.formatRegistry.add("cifCore", function(t) {
  if (xm.is(t.sourceData)) {
    var e = t.sourceData.data.db, r = e.atom_site, n = e.atom_site_aniso;
    return { data: Hr.ofPartialColumns($d.Schema, { U: n.u }, n._rowCount), elementToAnsiotrop: $d.getElementToAnsiotropFromLabel(r.label, n.label) };
  }
}, function(t) {
  return !!xm.is(t.sourceData) && t.sourceData.data.db.atom_site_aniso.u.isDefined;
}), function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "cifCore";
  }, t.fromFrame = function(e, r) {
    return r || (r = NR.cifCore(e)), { kind: "cifCore", name: r.database_code.depnum_ccdc_archive.value(0) || r.database_code.depnum_ccdc_fiz.value(0) || r.database_code.icsd.value(0) || r.database_code.mdf.value(0) || r.database_code.nbs.value(0) || r.database_code.csd.value(0) || r.database_code.cod.value(0) || r._name, data: { db: r, frame: e } };
  };
}(xm || (xm = {}));
var Sse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a, o, s;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return t.trim() ? [4, FR(t).run()] : [2, [Ec()]];
        case 1:
          if ((e = u.sent()).isError) throw e;
          r = function(c) {
            return c.startsWith(`data_SERVER
#
_density_server_result`) ? "dscif" : c.startsWith(`data_SERVER
#
data_SEGMENTATION_DATA`) ? "segcif" : c.includes("atom_site_fract_x") || c.includes("atom_site.fract_x") ? "coreCif" : -1;
          }(t) === -1 ? OR : xse, n = [], i = 0, a = e.result.blocks.length, u.label = 2;
        case 2:
          return i < a ? (o = e.result.blocks[i], [4, r(o).run()]) : [3, 5];
        case 3:
          s = u.sent(), n.push(tt.ofModel(s.frames[0], { dynamicBonds: !0 })), u.label = 4;
        case 4:
          return i++, [3, 2];
        case 5:
          return [2, n];
      }
    });
  });
} }, cM = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a;
    return ye(this, function(o) {
      switch (o.label) {
        case 0:
          return t.trim() ? [4, FR(t).run()] : [2, [Ec()]];
        case 1:
          if ((e = o.sent()).isError) throw e;
          r = [], n = 0, i = e.result.blocks.length, o.label = 2;
        case 2:
          return n < i ? [4, OR(e.result.blocks[n]).run()] : [3, 5];
        case 3:
          a = o.sent(), r.push(tt.ofModel(a.frames[0], { dynamicBonds: !0 })), o.label = 4;
        case 4:
          return n++, [3, 2];
        case 5:
          return [2, r];
      }
    });
  });
} };
function Cse(t) {
  var e = [], r = function(i) {
    var a = ot.readLine(i), o = +ot.readLine(i), s = new Float64Array(3), u = new Float64Array(3), c = new Float64Array(3);
    [s, u, c].forEach(function(N) {
      var R = ot.readLineTrim(i).trim().split(/\s+/g);
      N[0] = +R[0], N[1] = +R[1], N[2] = +R[2];
    });
    for (var l = vL(s, u, c), d = ot.readLineTrim(i).trim().split(/\s+/g), f = ot.readLineTrim(i).trim().split(/\s+/g), h = ot.readLineTrim(i), m = ["cartesian", "direct"].includes(h.toLowerCase()) ? "cartesian" : h, p = f.reduce(function(N, R) {
      return +N + +R;
    }, 0), v = new Float64Array(p), g = new Float64Array(p), y = new Float64Array(p), b = new Float64Array(p), S = new Float64Array(p), _ = new Float64Array(p), x = new Float64Array(p), C = new Float64Array(p), A = new Float64Array(p), w = new Array(p), I = function(N) {
      for (var R = N === 0 ? 0 : f.slice(0, N).reduce(function(H, K) {
        return +H + +K;
      }, 0), L = 0; L < Number(f[N]); L++) {
        var V = R + L, U = ot.readLineTrim(i).trim().split(/\s+/g);
        w[V] = d[N], x[V] = +U[0], C[V] = +U[1], A[V] = +U[2];
      }
    }, P = 0; P < f.length; P++) I(P);
    if (m === "cartesian") for (P = 0; P < p; P++) {
      v[P] = x[P], g[P] = C[P], y[P] = A[P];
      var M = E.create(v[P], g[P], y[P]), T = E.transformMat4(E.zero(), M, l.invertMatrix);
      b[P] = T[0], S[P] = T[1], _[P] = T[2];
    }
    else for (P = 0; P < p; P++) {
      b[P] = x[P], S[P] = C[P], _[P] = A[P];
      var F = E.create(v[P], g[P], y[P]);
      T = E.transformMat4(E.zero(), F, l.matrix), v[P] = T[0], g[P] = T[1], y[P] = T[2];
    }
    return { count: p, comment: a, scalingFactor: o, dynamics: m, type_symbol: se.ofStringArray(w), x: se.ofFloatArray(v), y: se.ofFloatArray(g), z: se.ofFloatArray(y), fractX: se.ofFloatArray(v), fractY: se.ofFloatArray(g), fractZ: se.ofFloatArray(y), cell: l };
  }(ot(t));
  e.push(r);
  var n = { isMaterial: !0, molecules: e };
  return ji.success(n);
}
function Ase(t) {
  var e = this;
  return tr.create("Parse Mol", function() {
    return _e(e, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, Cse(t)];
      });
    });
  });
}
var wse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return t.trim() ? [4, Ase(t).run()] : [2, [Ec()]];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, mf(e.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return tt.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function Dse(t) {
  var e = [], r = function(n, i, a) {
    for (var o = function() {
      if (a) return gL(a.a, a.b, a.c, a.alpha, a.beta, a.gamma);
    }(), s = n.length, u = new Float64Array(s), c = new Float64Array(s), l = new Float64Array(s), d = new Array(s), f = 0; f < s; f++) d[f] = n[f], u[f] = i[f][0], c[f] = i[f][1], l[f] = i[f][2];
    return { count: s, comment: "", type_symbol: se.ofStringArray(d), x: se.ofFloatArray(u), y: se.ofFloatArray(c), z: se.ofFloatArray(l), cell: o };
  }(t.elements, t.xyzs, t.lattice);
  return e.push(r), { isMaterial: !0, molecules: e };
}
function xL(t) {
  return Dse(t);
}
var Ese = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(e) {
      switch (e.label) {
        case 0:
          return [4, mf(xL(t)).run()];
        case 1:
          return [2, e.sent().frames.map(function(r) {
            return tt.ofModel(r, { dynamicBonds: !0 });
          })];
      }
    });
  });
} }, Sm = function(t, e, r, n) {
  this.name = t, this.visible = e, this.origin = r, this.contents = n;
};
(function(t) {
  function e() {
    return t !== null && t.apply(this, arguments) || this;
  }
  ka(e, t);
})(Sm), function(t) {
  function e() {
    return t !== null && t.apply(this, arguments) || this;
  }
  ka(e, t);
}(Sm), function(t) {
  function e() {
    return t !== null && t.apply(this, arguments) || this;
  }
  ka(e, t);
}(Sm), function(t) {
  function e() {
    return t !== null && t.apply(this, arguments) || this;
  }
  ka(e, t);
}(Sm);
var Ise = function(t) {
  function e() {
    return t !== null && t.apply(this, arguments) || this;
  }
  return ka(e, t), e.create = function(r) {
    var n = r.name, i = r.visible, a = r.origin, o = r.contents, s = {};
    return o.forEach(function(u) {
      Reflect.defineProperty(s, u.name, { value: u });
    }), new e(n, i, a, s);
  }, e;
}(Sm);
function Tse(t) {
  var e = t.scene, r = t.structure, n = Ise.create(e).contents, i = n.atoms, a = n.bonds, o = i.contents.length, s = new Float64Array(o), u = new Float64Array(o), c = new Float64Array(o), l = new Array(o), d = function() {
    if (r.lattice) {
      var g = r.lattice;
      return gL(g.a, g.b, g.c, g.alpha, g.beta, g.gamma);
    }
  }(), f = {};
  a.contents.forEach(function(g) {
    g.positionPairs.forEach(function(y) {
      var b = y[1].join(",");
      f[b] = f[b] || [], f[b].push(y[0]);
    });
  });
  var h = {};
  i.contents.forEach(function(g, y) {
    var b, S = g.positions, _ = g.tooltip, x = S[0];
    for (var C in s[y] = x[0], u[y] = x[1], c[y] = x[2], l[y] = ((b = _.split(/\s/)[0].match(/[A-Za-z]/g)) === null || b === void 0 ? void 0 : b.join("")) || "", f) {
      var A = f[C];
      h[C] = h[C] || [], A[0].every(function(w, I) {
        return w === x[I];
      }) && (h[C][0] = y), A[1].every(function(w, I) {
        return w === x[I];
      }) && (h[C][1] = y);
    }
  });
  var m = [], p = [];
  Object.values(h).forEach(function(g) {
    m.push(g[0]), p.push(g[1]);
  });
  var v = { count: 2 * m.length, atomA: Ze(Ze([], m, !0), p, !0), atomB: Ze(Ze([], p, !0), m, !0) };
  return { comment: "", count: o, x: se.ofFloatArray(s), y: se.ofFloatArray(u), z: se.ofFloatArray(c), type_symbol: se.ofStringArray(l), cell: d, bonds: v };
}
function Mse(t) {
  var e = { molecules: t.map(Tse), isMaterial: !0 };
  return ji.success(e);
}
function SL(t) {
  var e = this;
  return tr.create("Parse Mol", function() {
    return _e(e, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, Mse(t)];
      });
    });
  });
}
var Pse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, SL(t).run()];
        case 1:
          if ((e = r.sent()).isError) throw new Error(e.message);
          return [4, mf(e.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return tt.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} }, Rx = ot.skipWhitespace, CL = ot.eatValue, qs = ot.markLine, Ks = ot.getTokenString, AL = ot.readLine, G7, lM = /\s+/g;
function Bse(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x;
    return ye(this, function(C) {
      switch (C.label) {
        case 0:
          for (e = t.tokenizer, r = t.molecule; Ks(e) !== "@<TRIPOS>ATOM" && e.position < e.data.length; ) qs(e);
          return n = e.position, i = e.lineNumber, a = AL(e), o = a.trim().split(/\s+/g), s = o.length, u = ct.create(e.data, 2 * r.num_atoms), c = ct.create(e.data, 2 * r.num_atoms), l = ct.create(e.data, 2 * r.num_atoms), d = ct.create(e.data, 2 * r.num_atoms), f = ct.create(e.data, 2 * r.num_atoms), h = ct.create(e.data, 2 * r.num_atoms), m = ct.create(e.data, 2 * r.num_atoms), p = ct.create(e.data, 2 * r.num_atoms), v = ct.create(e.data, 2 * r.num_atoms), g = ct.create(e.data, 2 * r.num_atoms), y = se.Undefined(r.num_atoms, se.Schema.float), b = se.Undefined(r.num_atoms, se.Schema.int), S = se.Undefined(r.num_atoms, se.Schema.str), e.position = n, e.lineNumber = i, _ = e.length, x = 0, [4, Vm(t.runtimeCtx, 1e5, void 0, function(A) {
            for (var w = Math.min(r.num_atoms - x, A), I = 0; I < w; I++) for (var P = 0; P < s; P++) switch (Rx(e), e.tokenStart = e.position, CL(e), P) {
              case 0:
                ct.addUnchecked(u, e.tokenStart, e.tokenEnd);
                break;
              case 1:
                ct.addUnchecked(c, e.tokenStart, e.tokenEnd);
                break;
              case 2:
                ct.addUnchecked(l, e.tokenStart, e.tokenEnd);
                break;
              case 3:
                ct.addUnchecked(d, e.tokenStart, e.tokenEnd);
                break;
              case 4:
                ct.addUnchecked(f, e.tokenStart, e.tokenEnd);
                break;
              case 5:
                ct.addUnchecked(h, e.tokenStart, e.tokenEnd);
                break;
              case 6:
                ct.addUnchecked(m, e.tokenStart, e.tokenEnd);
                break;
              case 7:
                ct.addUnchecked(p, e.tokenStart, e.tokenEnd);
                break;
              case 8:
                ct.addUnchecked(v, e.tokenStart, e.tokenEnd);
                break;
              case 9:
                ct.addUnchecked(g, e.tokenStart, e.tokenEnd);
            }
            return x += w, w;
          }, function(A) {
            return A.update({ message: "Parsing...", current: e.position, max: _ });
          })];
        case 1:
          return C.sent(), [2, { count: r.num_atoms, atom_id: Wr(u)(se.Schema.int), atom_name: Wr(c)(se.Schema.str), x: Wr(l)(se.Schema.float), y: Wr(d)(se.Schema.float), z: Wr(f)(se.Schema.float), atom_type: s > 5 ? Wr(h)(se.Schema.str) : S, subst_id: s > 6 ? Wr(m)(se.Schema.int) : b, subst_name: s > 7 ? Wr(p)(se.Schema.str) : S, charge: s > 8 ? Wr(v)(se.Schema.float) : y, status_bit: s > 9 ? Wr(g)(se.Schema.str) : S }];
      }
    });
  });
}
function Fse(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a, o, s, u, c, l, d, f, h, m;
    return ye(this, function(p) {
      switch (p.label) {
        case 0:
          for (e = t.tokenizer, r = t.molecule; Ks(e) !== "@<TRIPOS>BOND" && e.position < e.data.length; ) qs(e);
          return n = e.position, i = e.lineNumber, a = AL(e), o = a.trim().split(/\s+/g), s = o.length, u = ct.create(e.data, 2 * r.num_bonds), c = ct.create(e.data, 2 * r.num_bonds), l = ct.create(e.data, 2 * r.num_bonds), d = ct.create(e.data, 2 * r.num_bonds), f = ct.create(e.data, 2 * r.num_bonds), e.position = n, e.lineNumber = i, h = e.length, m = 0, [4, Vm(t.runtimeCtx, 1e5, void 0, function(v) {
            for (var g = Math.min(r.num_bonds - m, v), y = 0; y < g; y++) for (var b = 0; b < s; b++) switch (Rx(e), e.tokenStart = e.position, CL(e), b) {
              case 0:
                ct.addUnchecked(u, e.tokenStart, e.tokenEnd);
                break;
              case 1:
                ct.addUnchecked(c, e.tokenStart, e.tokenEnd);
                break;
              case 2:
                ct.addUnchecked(l, e.tokenStart, e.tokenEnd);
                break;
              case 3:
                ct.addUnchecked(d, e.tokenStart, e.tokenEnd);
                break;
              default:
                ct.addUnchecked(f, e.tokenStart, e.tokenEnd);
            }
            return m += g, g;
          }, function(v) {
            return v.update({ message: "Parsing...", current: e.position, max: h });
          })];
        case 1:
          return p.sent(), [2, { count: r.num_bonds, bond_id: Wr(u)(se.Schema.int), origin_atom_id: Wr(c)(se.Schema.int), target_atom_id: Wr(l)(se.Schema.int), bond_type: Wr(d)(se.Schema.str), status_bits: s > 4 ? Wr(f)(se.Schema.str) : se.Undefined(r.num_bonds, se.Schema.str) }];
      }
    });
  });
}
function Nse(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, s, u, c;
    return ye(this, function(l) {
      switch (l.label) {
        case 0:
          n = ot(e), t.update({ message: "Parsing...", current: 0, max: e.length }), i = [], l.label = 1;
        case 1:
          return n.position < e.length ? (a = /* @__PURE__ */ function(d, f) {
            return { tokenizer: d, molecule: { mol_name: "", num_atoms: 0, num_bonds: 0, num_subst: 0, num_feat: 0, num_sets: 0, mol_type: "", charge_type: "", status_bits: "", mol_comment: "" }, runtimeCtx: f };
          }(n, t), function(d) {
            for (var f = d.tokenizer, h = d.molecule; Ks(f) !== "@<TRIPOS>MOLECULE" && f.position < f.data.length; ) qs(f);
            qs(f), h.mol_name = Ks(f), qs(f);
            var m = Ks(f).trim().split(lM);
            h.num_atoms = parseInt(m[0]), h.num_bonds = parseInt(m[1]), h.num_subst = parseInt(m[2]), h.num_feat = parseInt(m[3]), h.num_sets = parseInt(m[4]), qs(f);
            var p = Ks(f);
            if (!p.startsWith("@<TRIPOS>")) {
              h.mol_type = p, qs(f);
              var v = Ks(f);
              if (!v.startsWith("@<TRIPOS>")) {
                h.charge_type = v, qs(f);
                var g = Ks(f);
                if (!g.startsWith("@<TRIPOS>")) {
                  h.status_bits = g, qs(f);
                  var y = Ks(f);
                  y.startsWith("@<TRIPOS>") || (h.mol_comment = y);
                }
              }
            }
          }(a), [4, Bse(a)]) : [3, 4];
        case 2:
          return o = l.sent(), [4, Fse(a)];
        case 3:
          for (s = l.sent(), u = function(d) {
            for (var f = d.tokenizer; f.position < f.data.length; ) {
              var h = Ks(f);
              if (h === "@<TRIPOS>MOLECULE") return;
              if (h === "@<TRIPOS>CRYSIN") break;
              qs(f);
            }
            if (!(f.position >= f.data.length)) {
              qs(f);
              var m = Ks(f).trim().split(lM);
              return { a: parseFloat(m[0]), b: parseFloat(m[1]), c: parseFloat(m[2]), alpha: parseFloat(m[3]), beta: parseFloat(m[4]), gamma: parseFloat(m[5]), spaceGroup: parseInt(m[6], 10), setting: parseInt(m[7], 10) };
            }
          }(a), i.push({ molecule: a.molecule, atoms: o, bonds: s, crysin: u }), Rx(n); Ks(n) !== "@<TRIPOS>MOLECULE" && n.position < n.data.length; ) qs(n);
          return [3, 1];
        case 4:
          return c = { name: r, structures: i }, [2, ji.success(c)];
      }
    });
  });
}
function Rse(t, e) {
  var r = this;
  return tr.create("Parse MOL2", function(n) {
    return _e(r, 0, void 0, function() {
      return ye(this, function(i) {
        switch (i.label) {
          case 0:
            return [4, Nse(n, t, e)];
          case 1:
            return [2, i.sent()];
        }
      });
    });
  });
}
function Ose(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M;
    return ye(this, function(T) {
      switch (T.label) {
        case 0:
          r = [], n = 0, i = t.structures.length, T.label = 1;
        case 1:
          if (!(n < i)) return [3, 4];
          for (a = t.structures[n], o = a.molecule, s = a.atoms, u = a.bonds, c = a.crysin, l = se.ofConst("A", s.count, se.Schema.str), d = new Array(s.count), f = !1, h = 0; h < s.count; ++h) if (s.atom_type.value(h).includes(".")) {
            f = !0;
            break;
          }
          for (m = 0; m < s.count; ++m) d[m] = f ? s.atom_type.value(m).split(".")[0].toUpperCase() : Ix(s.atom_name.value(m), s.subst_name.value(m));
          for (p = Hr.ofPartialColumns(Ho.atom_site, { auth_asym_id: l, auth_atom_id: se.asArrayColumn(s.atom_name), auth_comp_id: s.subst_name, auth_seq_id: s.subst_id, Cartn_x: se.asArrayColumn(s.x, Float32Array), Cartn_y: se.asArrayColumn(s.y, Float32Array), Cartn_z: se.asArrayColumn(s.z, Float32Array), id: se.asArrayColumn(s.atom_id), label_asym_id: l, label_atom_id: se.asArrayColumn(s.atom_name), label_comp_id: s.subst_name, label_seq_id: s.subst_id, label_entity_id: se.ofConst("1", s.count, se.Schema.str), occupancy: se.ofConst(1, s.count, se.Schema.float), type_symbol: se.ofStringArray(d), pdbx_PDB_model_num: se.ofConst(n, s.count, se.Schema.int) }, s.count), (v = new k0()).setNames([["MOL", o.mol_name || "Ligand"]]), v.getEntityId("MOL", 0, "A"), g = new L0(s.subst_id, s.atom_name), y = 0, b = s.subst_name.rowCount; y < b; ++y) g.add(s.subst_name.value(y), y);
          return [4, Pl(hf({ entity: v.getEntityTable(), chem_comp: g.getChemCompTable(), atom_site: p }), G7.create(t), e)];
        case 2:
          (S = T.sent()).frameCount > 0 && (_ = se.ofIntArray(se.mapToArray(u.origin_atom_id, function(F) {
            return F - 1;
          }, Int32Array)), x = se.ofIntArray(se.mapToArray(u.target_atom_id, function(F) {
            return F - 1;
          }, Int32Array)), C = u.bond_id, A = se.ofIntArray(se.mapToArray(u.bond_type, function(F) {
            switch (F) {
              case "ar":
              case "am":
              case "un":
                return 1;
              case "du":
              case "nc":
                return 0;
              default:
                return parseInt(F);
            }
          }, Int8Array)), w = se.ofIntArray(se.mapToArray(u.bond_type, function(F) {
            switch (F) {
              case "ar":
              case "am":
                return 17;
              case "du":
              case "nc":
                return 0;
              default:
                return 1;
            }
          }, Int8Array)), I = Xi.fromData({ pairs: { key: C, indexA: _, indexB: x, order: A, flag: w }, count: s.count }), P = S.representative, Xi.Provider.set(P, I), Dl.Provider.set(P, { data: s.charge, type: o.charge_type }), c && (M = function(F) {
            if (F.setting === 1) {
              var N = au.create(F.spaceGroup, E.create(F.a, F.b, F.c), E.scale(E(), E.create(F.alpha, F.beta, F.gamma), Math.PI / 180));
              return { spacegroup: ko.create(N), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
            }
          }(c), M && Da.Provider.set(P, M)), r.push(P)), T.label = 3;
        case 3:
          return ++n, [3, 1];
        case 4:
          return [2, new Ym(r)];
      }
    });
  });
}
(function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "mol2";
  }, t.create = function(e) {
    return { kind: "mol2", name: e.name, data: e };
  };
})(G7 || (G7 = {}));
var ho, Lse = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return t.trim() ? [4, Rse(t, "").run()] : [2, [Ec()]];
        case 1:
          if ((e = n.sent()).isError) throw e;
          return [4, (i = e.result, tr.create("Parse MOL2", function(a) {
            return Ose(i, a);
          })).run()];
        case 2:
          return r = n.sent(), [2, [tt.ofModel(r.representative, { dynamicBonds: !0 })]];
      }
      var i;
    });
  });
} }, Il = ((ho = {})[gr.Pdb] = Goe, ho[gr.Mol] = qoe, ho[gr.Sdf] = rse, ho[gr.Gro] = sse, ho[gr.Xtc] = fse, ho[gr.Dump] = gse, ho[gr.Xyz] = bse, ho[gr.Cif] = Sse, ho[gr.MMCif] = cM, ho[gr.MCif] = cM, ho[gr.POSCAR] = wse, ho[gr.Material] = Ese, ho[gr.Pymatgen] = Pse, ho[gr.Mol2] = Lse, ho), kt = K3.Const, Tt = K3.Dynamic, kse = [kt(pe.core.type.bool, function(t, e) {
  return !!e[0](t);
}), kt(pe.core.type.num, function(t, e) {
  return +e[0](t);
}), kt(pe.core.type.str, function(t, e) {
  return "" + e[0](t);
}), kt(pe.core.type.list, function(t, e) {
  return Nm.forEachEval(e, t, function(r, n, i) {
    return i[n] = r;
  }, []);
}), kt(pe.core.type.set, function(t, e) {
  return Nm.forEachEval(e, t, function(r, n, i) {
    return i.add(r);
  }, /* @__PURE__ */ new Set());
}), kt(pe.core.type.regex, function(t, e) {
  return new RegExp(e[0](t), e[1] && e[1](t) || "");
}), kt(pe.core.type.bitflags, function(t, e) {
  return +e[0](t);
}), kt(pe.core.type.compositeKey, function(t, e) {
  return Nm.forEachEval(e, t, function(r, n, i) {
    return i[n] = "" + r;
  }, []).join("-");
}), kt(pe.core.logic.not, function(t, e) {
  return !e[0](t);
}), kt(pe.core.logic.and, function(t, e) {
  if (typeof e.length == "number") {
    for (var r = 0, n = e.length; r < n; r++) if (!e[r](t)) return !1;
  } else for (var i = 0, a = Object.keys(e); i < a.length; i++)
    if (!e[a[i]](t)) return !1;
  return !0;
}), kt(pe.core.logic.or, function(t, e) {
  if (typeof e.length == "number") {
    for (var r = 0, n = e.length; r < n; r++) if (e[r](t)) return !0;
  } else for (var i = 0, a = Object.keys(e); i < a.length; i++)
    if (e[a[i]](t)) return !0;
  return !1;
}), kt(pe.core.rel.eq, function(t, e) {
  return e[0](t) === e[1](t);
}), kt(pe.core.rel.neq, function(t, e) {
  return e[0](t) !== e[1](t);
}), kt(pe.core.rel.lt, function(t, e) {
  return e[0](t) < e[1](t);
}), kt(pe.core.rel.lte, function(t, e) {
  return e[0](t) <= e[1](t);
}), kt(pe.core.rel.gr, function(t, e) {
  return e[0](t) > e[1](t);
}), kt(pe.core.rel.gre, function(t, e) {
  return e[0](t) >= e[1](t);
}), kt(pe.core.rel.inRange, function(t, e) {
  var r = e[0](t);
  return r >= e[1](t) && r <= e[2](t);
}), kt(pe.core.math.add, function(t, e) {
  var r = 0;
  if (typeof e.length == "number") for (var n = 0, i = e.length; n < i; n++) r += e[n](t);
  else for (var a = 0, o = Object.keys(e); a < o.length; a++)
    r += e[o[a]](t);
  return r;
}), kt(pe.core.math.sub, function(t, e) {
  var r = 0;
  if (typeof e.length == "number") {
    if (e.length === 1) return -e[0](t);
    r = e[0](t) || 0;
    for (var n = 1, i = e.length; n < i; n++) r -= e[n](t);
  } else {
    var a = Object.keys(e);
    if (a.length === 1) return -e[a[0]](t);
    for (r = e[a[0]](t) || 0, n = 1, i = a.length; n < i; n++) r -= e[a[n]](t);
  }
  return r;
}), kt(pe.core.math.mult, function(t, e) {
  var r = 1;
  if (typeof e.length == "number") for (var n = 0, i = e.length; n < i; n++) r *= e[n](t);
  else for (var a = 0, o = Object.keys(e); a < o.length; a++)
    r *= e[o[a]](t);
  return r;
}), kt(pe.core.math.div, function(t, e) {
  return e[0](t) / e[1](t);
}), kt(pe.core.math.pow, function(t, e) {
  return Math.pow(e[0](t), e[1](t));
}), kt(pe.core.math.mod, function(t, e) {
  return e[0](t) % e[1](t);
}), kt(pe.core.math.min, function(t, e) {
  var r = Number.POSITIVE_INFINITY;
  if (typeof e.length == "number") for (var n = 0, i = e.length; n < i; n++) r = Math.min(e[n](t), r);
  else for (var a = 0, o = Object.keys(e); a < o.length; a++) {
    var s = o[a];
    r = Math.min(e[s](t), r);
  }
  return r;
}), kt(pe.core.math.max, function(t, e) {
  var r = Number.NEGATIVE_INFINITY;
  if (typeof e.length == "number") for (var n = 0, i = e.length; n < i; n++) r = Math.max(e[n](t), r);
  else for (var a = 0, o = Object.keys(e); a < o.length; a++) {
    var s = o[a];
    r = Math.max(e[s](t), r);
  }
  return r;
}), kt(pe.core.math.floor, function(t, e) {
  return Math.floor(e[0](t));
}), kt(pe.core.math.ceil, function(t, e) {
  return Math.ceil(e[0](t));
}), kt(pe.core.math.roundInt, function(t, e) {
  return Math.round(e[0](t));
}), kt(pe.core.math.abs, function(t, e) {
  return Math.abs(e[0](t));
}), kt(pe.core.math.sqrt, function(t, e) {
  return Math.sqrt(e[0](t));
}), kt(pe.core.math.cbrt, function(t, e) {
  return Math.cbrt(e[0](t));
}), kt(pe.core.math.sin, function(t, e) {
  return Math.sin(e[0](t));
}), kt(pe.core.math.cos, function(t, e) {
  return Math.cos(e[0](t));
}), kt(pe.core.math.tan, function(t, e) {
  return Math.tan(e[0](t));
}), kt(pe.core.math.asin, function(t, e) {
  return Math.asin(e[0](t));
}), kt(pe.core.math.acos, function(t, e) {
  return Math.acos(e[0](t));
}), kt(pe.core.math.atan, function(t, e) {
  return Math.atan(e[0](t));
}), kt(pe.core.math.sinh, function(t, e) {
  return Math.sinh(e[0](t));
}), kt(pe.core.math.cosh, function(t, e) {
  return Math.cosh(e[0](t));
}), kt(pe.core.math.tanh, function(t, e) {
  return Math.tanh(e[0](t));
}), kt(pe.core.math.exp, function(t, e) {
  return Math.exp(e[0](t));
}), kt(pe.core.math.log, function(t, e) {
  return Math.log(e[0](t));
}), kt(pe.core.math.log10, function(t, e) {
  return Math.log10(e[0](t));
}), kt(pe.core.math.atan2, function(t, e) {
  return Math.atan2(e[0](t), e[1](t));
}), kt(pe.core.str.match, function(t, e) {
  return e[0](t).test(e[1](t));
}), kt(pe.core.str.concat, function(t, e) {
  var r = [];
  if (typeof e.length == "number") for (var n = 0, i = e.length; n < i; n++) r.push(e[n](t).toString());
  else for (var a = 0, o = Object.keys(e); a < o.length; a++) {
    var s = o[a];
    r.push(e[s](t).toString());
  }
  return r.join("");
}), kt(pe.core.list.getAt, function(t, e) {
  return e[0](t)[e[1](t)];
}), kt(pe.core.list.equal, function(t, e) {
  return function(r, n) {
    if (!r || r.length === 0) return !n || n.length === 0;
    if (!n) return !1;
    var i = r.length;
    if (i !== n.length) return !1;
    for (var a = 0; a < i; a++) if (r[a] !== n[a]) return !1;
    return !0;
  }(e[0](t), e[1](t));
}), kt(pe.core.set.has, function(t, e) {
  return e[0](t).has(e[1](t));
}), kt(pe.core.set.isSubset, function(t, e) {
  return Ao.isSuperset(e[1](t), e[0](t));
}), kt(pe.core.flags.hasAny, function(t, e) {
  var r = e[1](t), n = e[0](t);
  return r ? !!(n & r) : !!n;
}), kt(pe.core.flags.hasAll, function(t, e) {
  var r = e[1](t), n = e[0](t);
  return r ? (n & r) === r : !n;
}), kt(pe.structureQuery.type.elementSymbol, function(t, e) {
  return bp(e[0](t));
}), kt(pe.structureQuery.type.atomName, function(t, e) {
  return (r = e[0](t)) ? typeof r == "string" ? r.toUpperCase() : "".concat(r).toUpperCase() : "";
  var r;
}), kt(pe.structureQuery.type.bondFlags, function(t, e) {
  var r = 0;
  if (typeof e.length == "number") for (var n = 0, i = e.length; n < i; n++) r = dM(r, e[n](t));
  else for (var a = 0, o = Object.keys(e); a < o.length; a++)
    r = dM(r, e[o[a]](t));
  return r;
}), kt(pe.structureQuery.type.ringFingerprint, function(t, e) {
  return nu.elementFingerprint(function(r, n) {
    var i = [];
    if (!n) return i;
    if (typeof n.length == "number") for (var a = 0, o = n.length; a < o; a++) i.push(n[a](r));
    else {
      var s = Object.keys(n);
      for (a = 1, o = s.length; a < o; a++) i.push(n[s[a]](r));
    }
    return i;
  }(t, e));
}), kt(pe.structureQuery.type.secondaryStructureFlags, function(t, e) {
  var r = 0;
  if (typeof e.length == "number") for (var n = 0, i = e.length; n < i; n++) r = fM(r, e[n](t));
  else for (var a = 0, o = Object.keys(e); a < o.length; a++)
    r = fM(r, e[o[a]](t));
  return r;
}), Tt(pe.structureQuery.filter.pick, function(t, e) {
  return En.filters.pick(e[0], e.test)(t);
}), Tt(pe.structureQuery.filter.first, function(t, e) {
  return En.filters.first(e[0])(t);
}), Tt(pe.structureQuery.filter.withSameAtomProperties, function(t, e) {
  return En.filters.withSameAtomProperties(e[0], e.source, e.property)(t);
}), Tt(pe.structureQuery.filter.intersectedBy, function(t, e) {
  return En.filters.areIntersectedBy(e[0], e.by)(t);
}), Tt(pe.structureQuery.filter.within, function(t, e) {
  return En.filters.within({ query: e[0], target: e.target, minRadius: e["min-radius"], maxRadius: e["max-radius"], elementRadius: e["atom-radius"], invert: e.invert })(t);
}), Tt(pe.structureQuery.filter.isConnectedTo, function(t, e) {
  return En.filters.isConnectedTo({ query: e[0], target: e.target, disjunct: e.disjunct, invert: e.invert, bondTest: e["bond-test"] })(t);
}), Tt(pe.structureQuery.generator.atomGroups, function(t, e) {
  return En.generators.atoms({ entityTest: e["entity-test"], chainTest: e["chain-test"], residueTest: e["residue-test"], atomTest: e["atom-test"], groupBy: e["group-by"] })(t);
}), Tt(pe.structureQuery.generator.all, function(t) {
  return En.generators.all(t);
}), Tt(pe.structureQuery.generator.empty, function(t) {
  return En.generators.none(t);
}), Tt(pe.structureQuery.generator.bondedAtomicPairs, function(t, e) {
  return En.generators.bondedAtomicPairs(e && e[0])(t);
}), Tt(pe.structureQuery.generator.rings, function(t, e) {
  var r, n;
  return En.generators.rings((r = e == null ? void 0 : e.fingerprint) === null || r === void 0 ? void 0 : r.call(e, t), (n = e == null ? void 0 : e["only-aromatic"]) === null || n === void 0 ? void 0 : n.call(e, t))(t);
}), Tt(pe.structureQuery.modifier.includeSurroundings, function(t, e) {
  return En.modifiers.includeSurroundings(e[0], { radius: e.radius(t), wholeResidues: !(!e["as-whole-residues"] || !e["as-whole-residues"](t)), elementRadius: e["atom-radius"] })(t);
}), Tt(pe.structureQuery.modifier.surroundingLigands, function(t, e) {
  return En.modifiers.surroundingLigands({ query: e[0], radius: e.radius(t), includeWater: !(!e["include-water"] || !e["include-water"](t)) })(t);
}), Tt(pe.structureQuery.modifier.wholeResidues, function(t, e) {
  return En.modifiers.wholeResidues(e[0])(t);
}), Tt(pe.structureQuery.modifier.union, function(t, e) {
  return En.modifiers.union(e[0])(t);
}), Tt(pe.structureQuery.modifier.expandProperty, function(t, e) {
  return En.modifiers.expandProperty(e[0], e.property)(t);
}), Tt(pe.structureQuery.modifier.exceptBy, function(t, e) {
  return En.modifiers.exceptBy(e[0], e.by)(t);
}), Tt(pe.structureQuery.modifier.intersectBy, function(t, e) {
  return En.modifiers.intersectBy(e[0], e.by)(t);
}), Tt(pe.structureQuery.modifier.includeConnected, function(t, e) {
  var r, n;
  return En.modifiers.includeConnected({ query: e[0], bondTest: e["bond-test"], wholeResidues: !(!e["as-whole-residues"] || !e["as-whole-residues"](t)), layerCount: e["layer-count"] && e["layer-count"](t) || 1, fixedPoint: (n = (r = e["fixed-point"]) === null || r === void 0 ? void 0 : r.call(e, t)) !== null && n !== void 0 && n })(t);
}), Tt(pe.structureQuery.combinator.merge, function(t, e) {
  return En.combinators.merge(e)(t);
}), Tt(pe.structureQuery.atomProperty.core.elementSymbol, tn(Qe.atom.type_symbol)), Tt(pe.structureQuery.atomProperty.core.vdw, function(t, e) {
  return Gy(Qe.atom.type_symbol(e && e[0] && e[0](t) || t.element));
}), Tt(pe.structureQuery.atomProperty.core.mass, function(t, e) {
  return function(r) {
    var n = Sp[r];
    return n === void 0 ? 10.81 : See[n];
  }(Qe.atom.type_symbol(e && e[0] && e[0](t) || t.element));
}), Tt(pe.structureQuery.atomProperty.core.atomicNumber, function(t, e) {
  return Xm(Qe.atom.type_symbol(e && e[0] && e[0](t) || t.element));
}), Tt(pe.structureQuery.atomProperty.core.x, tn(Qe.atom.x)), Tt(pe.structureQuery.atomProperty.core.y, tn(Qe.atom.y)), Tt(pe.structureQuery.atomProperty.core.z, tn(Qe.atom.z)), Tt(pe.structureQuery.atomProperty.core.sourceIndex, tn(Qe.atom.sourceIndex)), Tt(pe.structureQuery.atomProperty.core.operatorName, tn(Qe.unit.operator_name)), Tt(pe.structureQuery.atomProperty.core.modelIndex, tn(Qe.unit.model_index)), Tt(pe.structureQuery.atomProperty.core.modelLabel, tn(Qe.unit.model_label)), Tt(pe.structureQuery.atomProperty.core.atomKey, function(t, e) {
  var r = e && e[0] && e[0](t) || t.element;
  return iu(r.unit.id, r.element);
}), Tt(pe.structureQuery.atomProperty.macromolecular.residueKey, function(t, e) {
  return yte(e && e[0] && e[0](t) || t.element);
}), Tt(pe.structureQuery.atomProperty.macromolecular.chainKey, function(t, e) {
  return bte(e && e[0] && e[0](t) || t.element);
}), Tt(pe.structureQuery.atomProperty.macromolecular.entityKey, function(t, e) {
  return _te(e && e[0] && e[0](t) || t.element);
}), Tt(pe.structureQuery.atomProperty.macromolecular.id, tn(Qe.atom.id)), Tt(pe.structureQuery.atomProperty.macromolecular.isHet, function(t, e) {
  return Qe.residue.group_PDB(e && e[0] && e[0](t) || t.element) !== "ATOM";
}), Tt(pe.structureQuery.atomProperty.macromolecular.label_atom_id, tn(Qe.atom.label_atom_id)), Tt(pe.structureQuery.atomProperty.macromolecular.label_alt_id, tn(Qe.atom.label_alt_id)), Tt(pe.structureQuery.atomProperty.macromolecular.label_comp_id, tn(Qe.atom.label_comp_id)), Tt(pe.structureQuery.atomProperty.macromolecular.label_seq_id, tn(Qe.residue.label_seq_id)), Tt(pe.structureQuery.atomProperty.macromolecular.label_asym_id, tn(Qe.chain.label_asym_id)), Tt(pe.structureQuery.atomProperty.macromolecular.label_entity_id, tn(Qe.entity.id)), Tt(pe.structureQuery.atomProperty.macromolecular.auth_atom_id, tn(Qe.atom.auth_atom_id)), Tt(pe.structureQuery.atomProperty.macromolecular.auth_comp_id, tn(Qe.atom.auth_comp_id)), Tt(pe.structureQuery.atomProperty.macromolecular.auth_seq_id, tn(Qe.residue.auth_seq_id)), Tt(pe.structureQuery.atomProperty.macromolecular.auth_asym_id, tn(Qe.chain.auth_asym_id)), Tt(pe.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, tn(Qe.residue.pdbx_PDB_ins_code)), Tt(pe.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, tn(Qe.atom.pdbx_formal_charge)), Tt(pe.structureQuery.atomProperty.macromolecular.occupancy, tn(Qe.atom.occupancy)), Tt(pe.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, tn(Qe.atom.B_iso_or_equiv)), Tt(pe.structureQuery.atomProperty.macromolecular.entityType, tn(Qe.entity.type)), Tt(pe.structureQuery.atomProperty.macromolecular.entitySubtype, tn(Qe.entity.subtype)), Tt(pe.structureQuery.atomProperty.macromolecular.entityPrdId, tn(Qe.entity.prd_id)), Tt(pe.structureQuery.atomProperty.macromolecular.entityDescription, tn(Qe.entity.pdbx_description)), Tt(pe.structureQuery.atomProperty.macromolecular.objectPrimitive, tn(Qe.unit.object_primitive)), Tt(pe.structureQuery.atomProperty.macromolecular.isNonStandard, tn(Qe.residue.isNonStandard)), Tt(pe.structureQuery.atomProperty.macromolecular.secondaryStructureKey, tn(Qe.residue.secondary_structure_key)), Tt(pe.structureQuery.atomProperty.macromolecular.secondaryStructureFlags, tn(Qe.residue.secondary_structure_type)), Tt(pe.structureQuery.atomProperty.macromolecular.chemCompType, tn(Qe.residue.chem_comp_type)), Tt(pe.structureQuery.bondProperty.order, function(t, e) {
  return t.atomicBond.order;
}), Tt(pe.structureQuery.bondProperty.flags, function(t, e) {
  return t.atomicBond.type;
}), Tt(pe.structureQuery.bondProperty.atomA, function(t, e) {
  return t.atomicBond.a;
}), Tt(pe.structureQuery.bondProperty.atomB, function(t, e) {
  return t.atomicBond.b;
}), Tt(pe.structureQuery.bondProperty.length, function(t, e) {
  return t.atomicBond.length;
}), Tt(pe.internal.generator.bundleElement, function(t, e) {
  return ER(e.groupedUnits(t), e.ranges(t), e.set(t));
}), Tt(pe.internal.generator.bundle, function(t, e) {
  return IR(e.elements(t))(t);
}), Tt(pe.internal.generator.current, function(t, e) {
  return t.tryGetCurrentSelection();
})];
function tn(t) {
  return function(e, r) {
    return t(r && r[0] && r[0](e) || e.element);
  };
}
function dM(t, e) {
  return t | (lr.isName(e) ? lr.fromName(e) : 0);
}
function fM(t, e) {
  switch (e.toLowerCase()) {
    case "helix":
      return 2 | t;
    case "alpha":
      return 4098 | t;
    case "pi":
      return 32770 | t;
    case "310":
      return 2050 | t;
    case "beta":
      return 4 | t;
    case "strand":
      return 4194308 | t;
    case "sheet":
      return 8388612 | t;
    case "turn":
      return 16 | t;
    case "bend":
      return 8 | t;
    case "coil":
      return 536870912 | t;
    default:
      return t;
  }
}
(function() {
  for (var t = 0, e = kse; t < e.length; t++) {
    var r = e[t];
    MO.addSymbol(r);
  }
})();
var oy, Gse = /* @__PURE__ */ new Set(["N", "O", "S", "F", "CL", "BR", "I"]);
function zse(t, e, r) {
  var n = !1;
  return tf(t, e, r, function(i, a) {
    (function(o) {
      return Gse.has(o);
    })(kr(i, a)) && (n = !0);
  }), n;
}
(function(t) {
  t.Type = "Type", t.Structure = "Structure Property", t.Atom = "Atom Property", t.Bond = "Bond Property", t.Residue = "Residue Property", t.AminoAcid = "Amino Acid", t.NucleicBase = "Nucleic Base", t.Manipulate = "Manipulate Selection", t.Validation = "Validation", t.Misc = "Miscellaneous", t.Internal = "Internal";
})(oy || (oy = {}));
var Vse = function(t, e, r) {
  var n, i;
  return r === void 0 && (r = {}), { label: t, expression: e, description: r.description || "", category: (n = r.category) !== null && n !== void 0 ? n : oy.Misc, isHidden: !!r.isHidden, priority: r.priority || 0, referencesCurrent: !!r.referencesCurrent, get query() {
    return i || (i = X3(e)), i;
  }, ensureCustomProperties: r.ensureCustomProperties };
}("Polymer", Nt.struct.modifier.union([Nt.struct.generator.atomGroups({ "entity-test": Nt.core.logic.and([Nt.core.rel.eq([Nt.ammp("entityType"), "polymer"]), Nt.core.str.match([Nt.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)", "i"), Nt.ammp("entitySubtype")])]) })]), { category: oy.Type }), pM = { polymer: Vse }, Ec = function() {
  return tt.Builder().getStructure();
}, wL = function(t, e) {
  for (var r = tt.Builder(), n = new Set(e), i = 0, a = t.units; i < a.length; i++) {
    var o = a[i], s = Ze([], o.elements, !0).filter(function(u) {
      return !n.has(u);
    });
    s.length && r.addUnit(o.kind, o.model, o.conformation.operator, s, o.traits);
  }
  return r.getStructure();
}, Vo = function(t) {
  var e = t.getLoci();
  return e.kind === "structure-loci" ? e.structure : e.kind === "element-loci" ? Xe.toStructure(e) : tt.Empty;
}, jy = function(t) {
  var e = t.getLoci();
  return e.kind === "structure-loci" ? oa(tt.toStructureElementLoci(e.structure)) : e.kind === "element-loci" ? oa(e) : [];
}, fi = function(t, e, r, n) {
  if ((e == null ? void 0 : e.length) === 0 && !r) return tt.Empty;
  for (var i = tt.Builder(), a = new Set(e), o = typeof n == "string" ? n : Ki.create22(), s = 0, u = t.units; s < u.length; s++) {
    var c = u[s], l = e != null && e.length ? Ze([], c.elements, !0).filter(function(d) {
      return a.has(d);
    }) : c.elements;
    l.length && i.addUnit(c.kind, n ? O(O({}, c.model), { id: o }) : c.model, c.conformation.operator, l, c.traits);
  }
  return i.getStructure();
}, s3 = function(t, e) {
  for (var r = tt.Builder(), n = /* @__PURE__ */ new Map(), i = 0, a = function(u, c) {
    var l = t[u], d = l.ref, f = l.elementIds, h = on(e.cells.get(d)), m = new Set(f);
    n.set(u, []);
    for (var p = 0, v = h.units; p < v.length; p++) {
      var g = v[p], y = f ? Ze([], g.elements, !0).filter(function(b) {
        return m.has(b);
      }) : g.elements;
      y.length && (n.get(u).push(i), r.addUnit(g.kind, g.model, g.conformation.operator, y, g.traits, i), i++);
    }
  }, o = 0, s = t.length; o < s; o++) a(o);
  return { unitsMap: n, structure: r.getStructure() };
}, z7 = function(t) {
  if (t.model.sourceData.kind === "gro") return { polymer: ms(kp(Lp(t, pM.polymer.expression))), other: ms(kp(Lp(t, Nt.struct.modifier.exceptBy({ 0: Kd.toExpression(Kd("(sel.atom.all)", "mol-script")), by: pM.polymer.expression })))) };
  var e = {}, r = {}, n = /* @__PURE__ */ new Set(), i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
  t.units.forEach(function(u) {
    var c;
    u.elements.forEach(function(m) {
      var p = Ac(u, m);
      if (p.groupPDB === "ATOM" && !["UNK", "MOL"].includes(p.residueName)) return yo(e, p), n.add(p.elementId), void i.push(p.elementId);
      if (p.groupPDB === "HETATM" || ["UNK", "MOL"].includes(p.residueName)) {
        var v = "".concat(p.chainId, "_").concat(p.residueId);
        a.set(v, a.has(v) ? Ze(Ze([], a.get(v), !0), [p], !1) : [p]);
      } else yo(r, p);
    });
    for (var l = 0, d = u.bonds.a.length; l < d; l++) {
      var f = u.elements[u.bonds.a[l]], h = u.elements[u.bonds.b[l]];
      o.has(f) ? (c = o.get(f)) === null || c === void 0 || c.add(h) : o.set(f, /* @__PURE__ */ new Set([h]));
    }
  }), 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(f) {
          n.has(f) && (c = !0);
        });
      }
    }), u.forEach(function(l) {
      c ? (Object.assign(l, { isEutectic: !0 }), i.push(l.elementId), n.add(l.elementId)) : yo(r, l);
    });
  });
  var s = [];
  return Object.keys(r).forEach(function(u) {
    Object.keys(r[u]).forEach(function(c) {
      s.push.apply(s, r[u][c].map(function(l) {
        return l.elementId;
      }));
    });
  }), { polymer: i, other: s };
}, Zy = function(t, e) {
  var r;
  if (!t.elementCount) return "";
  if (e === gr.Pdb) return Fx(t, void 0, !0);
  var n = gs(t), i = (r = n == null ? void 0 : n.entryId) !== null && r !== void 0 ? r : "";
  return e === gr.Sdf || e === gr.Mol ? i ? Ze([i], O7(t).split(`
`).slice(1), !0).join(`
`) : O7(t) : void 0;
}, Use = function(t, e) {
  var r = gs(t);
  return e !== gr.Material ? r.sourceData.data : r.sourceData.data.molecules[0];
}, Hse = function(t, e, r, n) {
  return _e(void 0, 0, void 0, function() {
    var i, a, o, s, u, c, l;
    return ye(this, function(d) {
      switch (d.label) {
        case 0:
          return i = !((u = t == null ? void 0 : t.models) === null || u === void 0) && u.length ? t.models[0] : t == null ? void 0 : t.model, ((l = n ?? (i ? i.sourceData.kind : (c = t == null ? void 0 : t.parent) === null || c === void 0 ? void 0 : c.model.sourceData.kind)) !== null && l !== void 0 ? l : "sdf") !== "mmCIF" ? [3, 3] : (o = (a = Il[gr.Pdb]).parse, [4, Fx(t, void 0, !0, r)]);
        case 1:
          return [4, o.apply(a, [d.sent()])];
        case 2:
        case 5:
          return [2, d.sent()];
        case 3:
          return [4, O7(t, void 0, 0, e)];
        case 4:
          return s = d.sent(), [4, Il[gr.Sdf].parse(s)];
      }
    });
  });
}, Lp = function(t, e) {
  return X3(e)(new A0(t));
}, kp = function(t) {
  var e;
  if (t.structure) e = t.structure;
  else if (t.structures) {
    var r = t.structures.map(function(a) {
      return (a == null ? void 0 : a.units.length) > 0 ? tt.toStructureElementLoci(a) : void 0;
    }).filter(function(a) {
      return a;
    });
    if (r.length === 0) return Ec();
    for (var n = r[0], i = 1; i < r.length; i++) n = Xe.union(n, r[i]);
    e = Xe.toStructure(n);
  }
  return e;
}, ms = function(t) {
  var e = [];
  return t.units.forEach(function(r) {
    e.push.apply(e, r.elements);
  }), e;
}, Ac = function(t, e) {
  var r;
  return { unitId: t.invariantId, elementId: e, chainId: t.model.atomicHierarchy.chains.auth_asym_id.value(t.chainIndex[e]), groupPDB: t.model.atomicHierarchy.residues.group_PDB.value(t.residueIndex[e]), residueId: t.model.atomicHierarchy.residues.auth_seq_id.value(t.residueIndex[e]), insertCode: t.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(t.residueIndex[e]), residueName: t.model.atomicHierarchy.atoms.label_comp_id.value(e), atomId: t.model.atomicConformation.atomId.value(e), atomName: t.model.atomicHierarchy.atoms.label_atom_id.value(e), typeSymbol: r2(t.model.atomicHierarchy.atoms.type_symbol.value(e)), charge: ((r = Dl.Provider.get(t.model)) === null || r === void 0 ? void 0 : r.data.value(e)) || 0, altId: t.model.atomicHierarchy.atoms.label_alt_id.value(e), cdr: t.model.atomicHierarchy.atoms.cdr.value(e) || 0, bfactor: t.model.atomicHierarchy.atoms.B_iso_or_equiv.value(e), em_confidence: t.model.atomicHierarchy.atoms.em_confidence.value(e), x: t.model.atomicConformation.x[e], y: t.model.atomicConformation.y[e], z: t.model.atomicConformation.z[e], residueIndex: t.residueIndex[e], occupancy: t.model.atomicConformation.occupancy.value(e) };
}, DL = function(t, e, r) {
  var n = r;
  if (t.units.some(function(a) {
    return !!a.elements.includes(e) && (n = a.invariantId, !0);
  }), n === void 0 || !t.unitMap.has(n)) return {};
  var i = t.unitMap.get(n);
  return Ac(i, e);
}, EL = function(t, e) {
  t.units.forEach(function(r) {
    r.elements.forEach(function(n) {
      var i = Ac(r, n);
      e(i);
    });
  });
}, qse = function(t, e, r) {
  var n = [];
  return e.forEach(function(i) {
    var a = t.managers.cell.get(i.ref), o = on(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 f = Ac(c, l), h = ry(f, r);
          s.has(h) ? (d = s.get(h)) === null || d === void 0 || d.push(f) : s.set(h, [f]);
        }
      });
    }), s.forEach(function(c) {
      n.push({ ref: i.ref, elementIds: c.map(function(l) {
        return l.elementId;
      }), props: boe(c[0], r) });
    }));
  }), n;
}, IL = function(t, e) {
  var r = {}, n = /* @__PURE__ */ new Set(), i = e ?? [];
  return e || t.managers.cell.traverse(function(a, o) {
    on(a) && !o.isHidden && n.add(a.ref);
  }), n.forEach(function(a) {
    i.push({ ref: a });
  }), i.forEach(function(a) {
    var o, s = a.ref, u = a.elementIds, c = new Set(u), l = t.cells.get(s);
    if (l) {
      var d = on(l);
      if (d) {
        var f = [], h = [], m = [], p = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
        d.units.forEach(function(S) {
          var _;
          S.elements.forEach(function(I) {
            var P, M;
            if (!u || c.has(I)) {
              var T = Ac(S, I), F = ry(T, Kr.Residue);
              Ex.has(T.residueName.toUpperCase()) ? f.push(T.elementId) : Zp.has(T.residueName.toUpperCase()) ? h.push(T.elementId) : Dx.has(T.typeSymbol.toUpperCase()) || h2.has(T.residueName.toUpperCase()) ? m.push(T.elementId) : T.groupPDB !== "ATOM" || ["UNK", "MOL"].includes(T.residueName) ? T.groupPDB === "HETATM" || ["UNK", "MOL"].includes(T.residueName) ? y.has(F) ? (P = y.get(F)) === null || P === void 0 || P.push(T) : y.set(F, [T]) : g.has(F) ? (M = g.get(F)) === null || M === void 0 || M.push(T) : g.set(F, [T]) : p.add(T.elementId);
            }
          });
          for (var x = 0, C = S.bonds.a.length; x < C; x++) {
            var A = S.elements[S.bonds.a[x]], w = S.elements[S.bonds.b[x]];
            b.has(A) ? (_ = b.get(A)) === null || _ === void 0 || _.add(w) : b.set(A, /* @__PURE__ */ new Set([w]));
          }
        }), y.forEach(function(S, _) {
          var x = !1, C = new Set(S.map(function(A) {
            return A.elementId;
          }));
          C.forEach(function(A) {
            if (b.has(A)) {
              var w = b.get(A);
              w == null || w.forEach(function(I) {
                p.has(I) && (x = !0);
              });
            }
          }), S.forEach(function(A) {
            var w;
            x ? p.add(A.elementId) : g.has(_) ? (w = g.get(_)) === null || w === void 0 || w.push(A) : g.set(_, [A]);
          });
        }), g.forEach(function(S, _) {
          var x = S.filter(function(C) {
            return C.typeSymbol !== "H";
          });
          x.length > 10 && x.length < 150 ? v.set(_, S) : m.push.apply(m, S.map(function(C) {
            return C.elementId;
          }));
        }), r[s] = ((o = {})[ja.Protein] = p.size ? [{ ref: s, elementIds: Array.from(p.values()) }] : [], o[ja.Ligand] = Array.from(v.entries()).map(function(S) {
          var _ = S[0], x = S[1];
          return { ref: s, elementIds: x.map(function(C) {
            return C.elementId;
          }), name: _ };
        }), o[ja.Solvent] = f.length ? [{ ref: s, elementIds: f }] : [], o[ja.Water] = h.length ? [{ ref: s, elementIds: h }] : [], o[ja.Other] = m.length ? [{ ref: s, elementIds: m }] : [], o);
      }
    }
  }), r;
}, gs = function(t) {
  var e;
  return (e = t.model) !== null && e !== void 0 ? e : t.models[0];
}, Pu = function(t) {
  var e, r;
  return (r = (e = t.model) !== null && e !== void 0 ? e : t.models[0]) === null || r === void 0 ? void 0 : r.id;
}, on = function(t) {
  var e, r, n, i;
  return (e = t == null ? void 0 : t.model.structure) !== null && e !== void 0 ? e : !((r = t == null ? void 0 : t.model) === null || r === void 0) && r.trajectory ? tt.ofModel((n = t == null ? void 0 : t.model.trajectory) === null || n === void 0 ? void 0 : n.state.getFrameAtIndex((i = t == null ? void 0 : t.model.trajectory) === null || i === void 0 ? void 0 : i.frameIndex)) : void 0;
}, Qy = function(t, e) {
  var r = t.units.filter(function(a) {
    return Ke.has(a.elements, e);
  })[0];
  if (!r || Fe.isCoarse(r)) return Oi.NotHydrogen;
  if (r.model.atomicHierarchy.derived.atom.atomicNumber[e] !== 1) {
    var n = Oi.NotHydrogen;
    return tf(t, r, r.elements.indexOf(e), function(a, o) {
      if (a.model.atomicHierarchy.derived.atom.atomicNumber[a.elements[o]] === 1) switch (Qy(t, a.elements[o])) {
        case Oi.Polar:
          n = Oi.ConnectPolar;
          break;
        case Oi.NonPolar:
          n = Oi.ConnectNonPolar;
      }
    }), n;
  }
  var i = zse(t, r, Ke.indexOf(r.elements, e));
  return i ? Oi.Polar : i ? Oi.NotHydrogen : Oi.NonPolar;
}, Kse = function(t, e) {
  return _e(void 0, 0, void 0, function() {
    var r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, Promise.all(e.filter(function(i) {
            return t.cells.has(i.ref);
          }).map(function(i) {
            return t.managers.cell.getStructure(i.ref);
          }))];
        case 1:
          return r = n.sent(), [2, Qoe(r)];
      }
    });
  });
}, TL = function(t) {
  return Array.from(t.cells.entries()).map(function(e) {
    var r = e[0], n = e[1];
    return on(n) ? n.representations.size === 0 || Array.from(n.representations.values()).filter(function(i) {
      return !i.isHidden;
    }).length === 0 ? { ref: "" } : { ref: r } : { ref: "" };
  }).filter(function(e) {
    return e.ref;
  });
}, Uh = function(t, e) {
  return DL(t, e).typeSymbol === "H" && Qy(t, e) === Oi.NonPolar;
}, a8 = function(t) {
  if (!t) return t;
  var e = [], r = t.sort(function(i, a) {
    return +i - +a;
  }), n = [];
  return r.forEach(function(i, a) {
    n.length !== 0 ? n.length !== 1 ? n.length === 2 && (n[1] === i - 1 ? n[1] = i : (e.push.apply(e, n), n = [i])) : n[0] === i - 1 ? n.push(i) : (e.push(n[0], n[0]), n = [i]) : n.push(i);
  }), n.length && e.push.apply(e, n.length === 2 ? n : [n[0], n[0]]), e;
}, gv = function(t) {
  for (var e = [], r = 0, n = t.length; r < n; r += 2) for (var i = t[r]; i <= t[r + 1]; i++) e.push(i);
  return e;
};
function P0(t, e, r, n) {
  var i, a, o, s, u = 0, c = e.webgl, l = new Si(), d = new sr.GeometryState(), f = Nl(), h = [], m = xs.create(), p = su.createEmpty();
  function v(g) {
    if (xs.update(m, g), g.visible !== void 0 && i && i.setVisibility(g.visible && (m.unitTransforms === null || m.unitTransforms.isIdentity)), g.alphaFactor !== void 0 && i && i.setAlphaFactor(g.alphaFactor), g.pickable !== void 0 && i && i.setPickable(g.pickable), g.overpaint !== void 0 && i) {
      var y = jm.remap(g.overpaint, a);
      i.setOverpaint(y, c);
    }
    if (g.transparency !== void 0 && i) {
      var b = Zm.remap(g.transparency, a);
      i.setTransparency(b, c);
    }
    if (g.substance !== void 0 && i) {
      var S = Jm.remap(g.substance, a);
      i.setSubstance(S, c);
    }
    if (g.clipping !== void 0 && i) {
      var _ = Qm.remap(g.clipping, a);
      i.setClipping(_);
    }
    g.transform !== void 0 && i && i.setTransform(g.transform), g.unitTransforms !== void 0 && i && i.setVisibility(m.visible && (g.unitTransforms === null || g.unitTransforms.isIdentity));
  }
  return { label: t, get groupCount() {
    return i ? i.groupCount : 0;
  }, get props() {
    return s;
  }, get params() {
    return o;
  }, get state() {
    return m;
  }, get theme() {
    return p;
  }, get geometryVersion() {
    return d.version;
  }, renderObjects: h, updated: l, createOrUpdate: function(g, y) {
    var b = this;
    return g === void 0 && (g = {}), y && y !== a && (o = r(e, y), a = y, s || (s = z.getDefaultValues(o))), s = Object.assign({}, s, g), tr.create("Creating or updating ComplexRepresentation", function(S) {
      return _e(b, 0, void 0, function() {
        var _, x, C;
        return ye(this, function(A) {
          switch (A.label) {
            case 0:
              return _ = !1, i ? !((C = i.mustRecreate) === null || C === void 0) && C.call(i, a, s, c) && (i.destroy(), i = n(f, a, s, c), _ = !0) : (i = n(f, a, s, c), _ = !0), (x = i.createOrUpdate({ webgl: c, runtime: S }, p, s, y)) ? [4, x] : [3, 2];
            case 1:
              A.sent(), A.label = 2;
            case 2:
              return _ && v(m), h.length = 0, i && i.renderObject && (h.push(i.renderObject), d.add(i.renderObject.id, i.geometryVersion)), d.snapshot(), u += 1, l.next(u), [2];
          }
        });
      });
    });
  }, setState: v, setTheme: function(g) {
    p = g;
  }, getLoci: function(g) {
    return g === void 0 ? tt.Loci(a.target) : i ? i.getLoci(g) : Dn;
  }, mark: function(g, y) {
    if (!a || !Lr.is(m.markerActions, y)) return !1;
    if (tt.isLoci(g) || Xe.is(g) || Dt.isLoci(g)) {
      if (!tt.areRootsEquivalent(g.structure, a)) return !1;
      g = Qr.remap(g, a), (tt.isLoci(g) || Xe.is(g) && Xe.isWholeStructure(g)) && (g = px);
    } else if (!qo(g) && !Fm(g)) return !1;
    return !Qr.isEmpty(g) && !!i && i.mark(g, y);
  }, destroy: function() {
    i && i.destroy();
  } };
}
function ML(t, e, r) {
  var n = e.elements, i = e.model;
  if (Ge.indexOf(n, r) !== -1) {
    for (var a = i.atomicHierarchy.residueAtomSegments, o = a.index, s = a.offsets, u = o[r], c = [], l = s[u], d = s[u + 1]; l < d; ++l) {
      var f = Ge.indexOf(n, l);
      f !== -1 && c.push(f);
    }
    return Xe(t, [{ unit: e, indices: Ge.ofSortedArray(Ke.ofSortedArray(c)) }]);
  }
  return Dn;
}
function hM(t, e, r) {
  for (var n = t.structure.child, i = e && n ? t.group.units.filter(function(c) {
    return n.unitMap.has(c.id);
  }) : t.group.units, a = i.length, o = 16 * a, s = r && r.aTransform.ref.value.length >= o ? r.aTransform.ref.value : new Float32Array(o), u = 0; u < a; u++) he.toArray(i[u].conformation.operator.matrix, s, 16 * u);
  return ix(s, a, r);
}
var Xse = z.objectToOptions({ atomic: {}, spheres: {}, gaussians: {} }), mM = 5e8;
function Yse(t, e, r) {
  r === void 0 && (r = mM);
  var n = function(u, c, l) {
    l === void 0 && (l = mM);
    var d = $r.size(E(), u);
    E.ceil(d, d), d.sort(function(m, p) {
      return p - m;
    });
    var f = Math.floor(Math.cbrt(l) * Math.cbrt(l)), h = d[0] * d[1];
    return { area: h, areaCells: Math.ceil(h / (c * c)), maxAreaCells: f };
  }(t, e.resolution, r), i = n.area, a = n.areaCells, o = n.maxAreaCells, s = a > o ? Math.sqrt(i / o) : e.resolution;
  return O(O({}, e), { resolution: s });
}
var Ox = { ignoreHydrogens: z.Boolean(!1, { description: "Whether or not to include hydrogen atoms in the surface calculation." }), traceOnly: z.Boolean(!1, { description: "Whether or not to only use trace atoms in the surface calculation." }), includeParent: z.Boolean(!1, { description: "Include elements of the parent structure in surface calculation to get a surface patch of the current structure." }) };
z.getDefaultValues(Ox);
var Wse = E();
function jse(t, e, r, n) {
  return E.squaredDistance(E.set(Wse, t, e, r), n);
}
function Zse(t, e, r, n) {
  var i, a, o = n.ignoreHydrogens, s = n.traceOnly, u = n.includeParent, c = u ? t.root.unitMap.get(e.id) : e, l = function(P) {
    switch (P.kind) {
      case 0:
        return P.model.atomicConformation;
      case 1:
        return P.model.coarseConformation.spheres;
      case 2:
        return P.model.coarseConformation.gaussians;
    }
  }(c), d = l.x, f = l.y, h = l.z, m = c.elements, p = e.boundary.sphere, v = p.center, g = p.radius, y = (g + 7) * (g + 7);
  if (o || s || u && c !== e) {
    for (var b = [], S = [], _ = 0, x = m.length; _ < x; ++_) {
      var C = m[_];
      o && V7(c, C) || s && !BL(c, C) || u && jse(d[C], f[C], h[C], v) > y || (b.push(C), S.push(_));
    }
    i = Ke.ofSortedArray(b), a = S;
  } else i = m, a = xc(new Int32Array(i.length));
  u && c !== e && function(P, M, T) {
    for (var F = 0, N = M.length, R = 0, L = T.length; R < L; ++R) {
      var V = Ke.indexOfInRange(M, T[R], F, N);
      V === -1 ? P[R] = -2 : (P[R] = V, F = V);
    }
  }(a, e.elements, i);
  var A = { indices: i, x: d, y: f, z: h, id: a }, w = e === c ? e.boundary : xp(A), I = at.create(t, c);
  return { position: A, boundary: w, radius: function(P) {
    return I.element = P, r.size(I);
  } };
}
var PL = Sp.H;
function V7(t, e) {
  return !Fe.isCoarse(t) && t.model.atomicHierarchy.derived.atom.atomicNumber[e] === PL;
}
function U7(t, e) {
  return t[e] === PL;
}
function BL(t, e) {
  if (Fe.isCoarse(t)) return !0;
  var r = t.model.atomicHierarchy.atoms.label_atom_id.value(e);
  return r === "CA" || r === "BB" || r === "P";
}
function S2(t) {
  return z.MultiSelect(t, Xse, { description: "For which kinds of units/chains to show the representation visuals." });
}
var Ko = { unitKinds: S2(["atomic", "spheres"]), includeParent: z.Boolean(!1, { isHidden: !0 }) }, FL = O({}, Vt.Params), Qse = O({}, Gu.Params), NL = O({}, to.Params), Jse = O({}, I0.Params), RL = O({}, Rr.Params), OL = O({}, bs.Params), LL = O({}, U3.Params), kL = O({}, sf.Params);
function Jy(t, e) {
  var r, n, i, a, o, s, u, c, l = t.defaultProps, d = t.createGeometry, f = t.createLocationIterator, h = t.getLoci, m = t.eachLocation, p = t.setUpdateState, v = t.mustRecreate, g = t.processValues, y = t.dispose, b = t.geometryUtils, S = b.updateValues, _ = b.updateBoundingSphere, x = b.updateRenderableState, C = b.createPositionIterator, A = Cc.create(), w = { loci: Dn, action: _t.None, status: -1 }, I = Object.assign({}, l), P = su.createEmpty(), M = -1;
  function T(R) {
    if (A.createNew) {
      if (u = f(a), !R) throw new Error("expected geometry to be given");
      r = function(L, V, U, H, K, X) {
        var Y = Ia.getUtils(V), Q = Y.createValues, J = Y.createRenderableState, te = Q(V, ox(), U, H, K), W = J(K);
        return eh(V.kind, te, W, X);
      }(0, R, u, i, n, e), c = C(R, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (A.updateTransform && ou((u = f(a)).instanceCount * u.groupCount, r.values), A.createGeometry) {
        if (!R) throw new Error("expected geometry to be given");
        G.updateIfChanged(r.values.drawCount, Ia.getDrawCount(R)), G.updateIfChanged(r.values.uVertexCount, Ia.getVertexCount(R));
      }
      (A.updateTransform || A.createGeometry) && (_(r.values, R || s), c = C(s, r.values)), A.updateSize && "uSize" in r.values && Bl(u, i.size, r.values), A.updateColor && vs(u, c, i.color, r.values), S(r.values, n), x(r.state, n);
    }
    I = n, P = i, o = a, R && (s = R, M += 1);
  }
  function F(R, L, V) {
    return function(U) {
      return !!qo(U) || !(!tt.isLoci(U) || !tt.areRootsEquivalent(U.structure, o)) || !!(Xe.is(U) && tt.areRootsEquivalent(U.structure, o) && Xe.isWholeStructure(U));
    }(R) ? L(Se.ofBounds(0, u.groupCount * u.instanceCount)) : m(R, o, L, V);
  }
  function N(R) {
    r && (g == null || g(r.values, s, I, P, R.webgl));
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return u && u.count ? r : void 0;
  }, get geometryVersion() {
    return M;
  }, createOrUpdate: function(R, L, V, U) {
    if (V === void 0 && (V = {}), function(K, X, Y) {
      if (!Y && !o) throw new Error("missing structure");
      if (n = Object.assign({}, I, X), i = K, a = Y, Cc.reset(A), !r || !o) return A.createNew = !0, void (A.createGeometry = !0);
      p(A, n, I, i, P, a, o), tt.areEquivalent(a, o) || (A.createGeometry = !0), tt.areHierarchiesEqual(a, o) || (A.updateTransform = !0, A.createGeometry = !0), El.areEqual(K.color, P.color) || (A.updateColor = !0), nf(n.unitKinds, I.unitKinds) || (A.createGeometry = !0), o.child !== a.child && (A.createGeometry = !0), A.updateSize && !("uSize" in r.values) && (A.createGeometry = !0), A.createGeometry && (A.updateColor = !0, A.updateSize = !0);
    }(L, V, U || o), A.createGeometry) {
      var H = d(R, a, i, n, s);
      if (U9(H)) return H.then(function(K) {
        T(K), N(R);
      });
      T(H);
    } else T();
    N(R);
  }, getLoci: function(R) {
    return r ? h(R, o, r.id) : Dn;
  }, mark: function(R, L) {
    return nr.mark(r, R, L, F, w);
  }, setVisibility: function(R) {
    nr.setVisibility(r, R);
  }, setAlphaFactor: function(R) {
    nr.setAlphaFactor(r, R);
  }, setPickable: function(R) {
    nr.setPickable(r, R);
  }, setColorOnly: function(R) {
    nr.setColorOnly(r, R);
  }, setTransform: function(R, L) {
    nr.setTransform(r, R, L);
  }, setOverpaint: function(R, L) {
    var V = { geometry: s, props: I, webgl: L };
    nr.setOverpaint(r, R, F, !0, V);
  }, setTransparency: function(R, L) {
    var V = { geometry: s, props: I, webgl: L };
    nr.setTransparency(r, R, F, !0, V);
  }, setSubstance: function(R, L) {
    var V = { geometry: s, props: I, webgl: L };
    nr.setSubstance(r, R, F, !0, V);
  }, setClipping: function(R) {
    nr.setClipping(r, R, F, !0);
  }, destroy: function() {
    y == null || y(s), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: v };
}
var GL = O(O({}, FL), Ko);
function zL(t, e) {
  return Jy(O(O({}, t), { setUpdateState: function(r, n, i, a, o, s, u) {
    t.setUpdateState(r, n, i, a, o, s, u), Co.areEqual(a.size, o.size) || (r.createGeometry = !0);
  }, geometryUtils: Vt.Utils }), e);
}
var $se = O(O({}, NL), Ko), eue = O(O({}, RL), Ko), tue = O(O({}, OL), Ko);
function $a(t, e, r, n) {
  var i, a, o, s, u = 0, c = e.webgl, l = new Si(), d = Nl(), f = [], h = new sr.GeometryState(), m = xs.create(), p = /* @__PURE__ */ new Map(), v = su.createEmpty();
  function g(y, b, S) {
    var _ = S.visible, x = S.alphaFactor, C = S.pickable, A = S.overpaint, w = S.transparency, I = S.substance, P = S.clipping, M = S.transform, T = S.unitTransforms;
    _ !== void 0 && y.setVisibility(_), x !== void 0 && y.setAlphaFactor(x), C !== void 0 && y.setPickable(C), A !== void 0 && y.setOverpaint(A, c), w !== void 0 && y.setTransparency(w, c), I !== void 0 && y.setSubstance(I, c), P !== void 0 && y.setClipping(P), M !== void 0 && y.setTransform(M), T !== void 0 && (T ? y.setTransform(void 0, T.getSymmetryGroupTransforms(b)) : y.setTransform(void 0, null));
  }
  return { label: t, get groupCount() {
    var y = 0;
    return p.forEach(function(b) {
      var S = b.visual;
      S.renderObject && (y += S.groupCount);
    }), y;
  }, get geometryVersion() {
    return h.version;
  }, get props() {
    return s;
  }, get params() {
    return o;
  }, get state() {
    return m;
  }, get theme() {
    return v;
  }, renderObjects: f, updated: l, createOrUpdate: function(y, b) {
    var S = this;
    return y === void 0 && (y = {}), b && b !== i && (o = r(e, b), s || (s = z.getDefaultValues(o))), s = Object.assign({}, s, y), tr.create("Creating or updating UnitsRepresentation", function(_) {
      return _e(S, 0, void 0, function() {
        var x, C, A, w, I, P, M, T, F, N, R, L, V;
        return ye(this, function(U) {
          switch (U.label) {
            case 0:
              if (i || b) return [3, 1];
              throw new Error("missing structure");
            case 1:
              if (!b || i) return [3, 8];
              a = b.unitSymmetryGroups, I = 0, U.label = 2;
            case 2:
              return I < a.length ? (F = a[I], T = n(d, b, s, c), (N = T.createOrUpdate({ webgl: c, runtime: _ }, v, s, { group: F, structure: b })) ? [4, N] : [3, 4]) : [3, 7];
            case 3:
              U.sent(), U.label = 4;
            case 4:
              return g(T, F, m), p.set(F.hashCode, { visual: T, group: F }), _.shouldUpdate ? [4, _.update({ message: "Creating or updating UnitsVisual", current: I, max: a.length })] : [3, 6];
            case 5:
              U.sent(), U.label = 6;
            case 6:
              return I++, [3, 2];
            case 7:
              return [3, 43];
            case 8:
              if (!b || tt.areUnitIdsAndIndicesEqual(b, i) && b.child === i.child) return [3, 22];
              a = b.unitSymmetryGroups, x = p, p = /* @__PURE__ */ new Map(), I = 0, U.label = 9;
            case 9:
              return I < a.length ? (F = a[I], (A = x.get(F.hashCode)) ? (T = A.visual, !((R = T.mustRecreate) === null || R === void 0) && R.call(T, { group: F, structure: b }, s, c) ? (T.destroy(), T = n(d, b, s, c), (N = T.createOrUpdate({ webgl: c, runtime: _ }, v, s, { group: F, structure: b })) ? [4, N] : [3, 11]) : [3, 12]) : [3, 15]) : [3, 21];
            case 10:
              U.sent(), U.label = 11;
            case 11:
              return g(T, F, m), [3, 14];
            case 12:
              return (N = T.createOrUpdate({ webgl: c, runtime: _ }, v, s, { group: F, structure: b })) ? [4, N] : [3, 14];
            case 13:
              U.sent(), U.label = 14;
            case 14:
              return p.set(F.hashCode, { visual: T, group: F }), x.delete(F.hashCode), T.renderObject && p7(C = T.renderObject.values.tMarker.ref.value.array, Se.ofBounds(0, C.length), _t.RemoveHighlight), [3, 18];
            case 15:
              return T = n(d, b, s, c), (N = T.createOrUpdate({ webgl: c, runtime: _ }, v, s, { group: F, structure: b })) ? [4, N] : [3, 17];
            case 16:
              U.sent(), U.label = 17;
            case 17:
              g(T, F, m), p.set(F.hashCode, { visual: T, group: F }), U.label = 18;
            case 18:
              return _.shouldUpdate ? [4, _.update({ message: "Creating or updating UnitsVisual", current: I, max: a.length })] : [3, 20];
            case 19:
              U.sent(), U.label = 20;
            case 20:
              return I++, [3, 9];
            case 21:
              return x.forEach(function(H) {
                H.visual.destroy();
              }), [3, 43];
            case 22:
              if (!b || b === i || !tt.areUnitIdsAndIndicesEqual(b, i)) return [3, 34];
              a = b.unitSymmetryGroups, I = 0, U.label = 23;
            case 23:
              return I < a.length ? (F = a[I], (A = p.get(F.hashCode)) ? (T = A.visual, !((L = T.mustRecreate) === null || L === void 0) && L.call(T, { group: F, structure: b }, s, e.webgl) ? (T.destroy(), T = n(d, b, s, e.webgl), A.visual = T, (N = T.createOrUpdate({ webgl: c, runtime: _ }, v, s, { group: F, structure: b })) ? [4, N] : [3, 25]) : [3, 26]) : [3, 29]) : [3, 33];
            case 24:
              U.sent(), U.label = 25;
            case 25:
              return g(T, F, m), [3, 28];
            case 26:
              return (N = T.createOrUpdate({ webgl: c, runtime: _ }, v, s, { group: F, structure: b })) ? [4, N] : [3, 28];
            case 27:
              U.sent(), U.label = 28;
            case 28:
              return A.group = F, [3, 30];
            case 29:
              throw new Error("expected to find visual for hashCode ".concat(F.hashCode));
            case 30:
              return _.shouldUpdate ? [4, _.update({ message: "Creating or updating UnitsVisual", current: I, max: a.length })] : [3, 32];
            case 31:
              U.sent(), U.label = 32;
            case 32:
              return I++, [3, 23];
            case 33:
              return [3, 43];
            case 34:
              w = [], p.forEach(function(H) {
                return w.push(H);
              }), I = 0, P = w.length, U.label = 35;
            case 35:
              return I < P ? (M = w[I], T = M.visual, F = M.group, !((V = T.mustRecreate) === null || V === void 0) && V.call(T, { group: F, structure: i }, s, e.webgl) ? (T.destroy(), T = n(d, i, s, c), w[I].visual = T, (N = T.createOrUpdate({ webgl: c, runtime: _ }, v, s, { group: F, structure: i })) ? [4, N] : [3, 37]) : [3, 38]) : [3, 43];
            case 36:
              U.sent(), U.label = 37;
            case 37:
              return g(T, F, m), [3, 40];
            case 38:
              return (N = T.createOrUpdate({ webgl: c, runtime: _ }, v, s)) ? [4, N] : [3, 40];
            case 39:
              U.sent(), U.label = 40;
            case 40:
              return _.shouldUpdate ? [4, _.update({ message: "Creating or updating UnitsVisual", current: I, max: P })] : [3, 42];
            case 41:
              U.sent(), U.label = 42;
            case 42:
              return ++I, [3, 35];
            case 43:
              return f.length = 0, p.forEach(function(H) {
                var K = H.visual;
                K.renderObject && (f.push(K.renderObject), h.add(K.renderObject.id, K.geometryVersion));
              }), h.snapshot(), b && (i = b), l.next(u++), [2];
          }
        });
      });
    });
  }, setState: function(y) {
    var b = y.visible, S = y.alphaFactor, _ = y.pickable, x = y.overpaint, C = y.transparency, A = y.substance, w = y.clipping, I = y.transform, P = y.unitTransforms, M = y.syncManually, T = y.markerActions, F = {};
    b !== m.visible && (F.visible = b), S !== m.alphaFactor && (F.alphaFactor = S), _ !== m.pickable && (F.pickable = _), x !== void 0 && i && (F.overpaint = jm.remap(x, i)), C !== void 0 && i && (F.transparency = Zm.remap(C, i)), A !== void 0 && i && (F.substance = Jm.remap(A, i)), w !== void 0 && i && (F.clipping = Qm.remap(w, i)), I === void 0 || he.areEqual(I, m.transform, Cn) || (F.transform = I), P === m.unitTransforms && (P == null ? void 0 : P.version) === y.unitTransformsVersion || (F.unitTransforms = P, m.unitTransformsVersion = P ? P == null ? void 0 : P.version : -1), M !== m.syncManually && (F.syncManually = M), T !== m.markerActions && (F.markerActions = T), p.forEach(function(N) {
      return g(N.visual, N.group, F);
    }), xs.update(m, F);
  }, setTheme: function(y) {
    v = y;
  }, getLoci: function(y) {
    if (y === void 0) return tt.Loci(i.target);
    var b = Dn;
    return p.forEach(function(S) {
      var _ = S.visual.getLoci(y);
      ef(_) || (b = _);
    }), b;
  }, mark: function(y, b) {
    if (!i || !Lr.is(m.markerActions, b)) return !1;
    if (tt.isLoci(y) || Xe.is(y) || Dt.isLoci(y)) {
      if (!tt.areRootsEquivalent(y.structure, i)) return !1;
      y = Qr.remap(y, i), (tt.isLoci(y) || Xe.is(y) && Xe.isWholeStructure(y)) && (y = px);
    } else if (!qo(y) && !Fm(y)) return !1;
    if (Qr.isEmpty(y)) return !1;
    var S = !1;
    return p.forEach(function(_) {
      var x = _.visual;
      S = x.mark(y, b) || S;
    }), S;
  }, destroy: function() {
    p.forEach(function(y) {
      return y.visual.destroy();
    }), p.clear();
  } };
}
function C2(t, e) {
  var r, n, i, a, o, s, u, c, l = t.defaultProps, d = t.createGeometry, f = t.createLocationIterator, h = t.getLoci, m = t.eachLocation, p = t.setUpdateState, v = t.mustRecreate, g = t.processValues, y = t.dispose, b = t.geometryUtils, S = b.createEmpty, _ = b.updateValues, x = b.updateBoundingSphere, C = b.updateRenderableState, A = b.createPositionIterator, w = Cc.create(), I = { loci: Dn, action: _t.None, status: -1 }, P = Object.assign({}, l), M = su.createEmpty(), T = -1;
  function F(V) {
    if (w.createNew) {
      if (u = f(n), !V) throw new Error("expected geometry to be given");
      r = function(U, H, K, X, Y, Q) {
        var J = Ia.getUtils(H), te = J.createValues, W = J.createRenderableState, j = te(H, hM(U, Y.includeParent), K, X, Y), ee = W(Y);
        return eh(H.kind, j, ee, Q);
      }(n, V, u, M, P, e), c = A(V, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (w.updateTransform && ou((u = f(n)).instanceCount * u.groupCount, r.values), w.updateMatrix && hM(n, P.includeParent, r.values), w.createGeometry) {
        if (!V) throw new Error("expected geometry to be given");
        G.updateIfChanged(r.values.drawCount, Ia.getDrawCount(V)), G.updateIfChanged(r.values.uVertexCount, Ia.getVertexCount(V));
      }
      (w.updateTransform || w.createGeometry) && (x(r.values, V || s), c = A(V || s, r.values)), w.updateSize && "uSize" in r.values && Bl(u, M.size, r.values), w.updateColor && vs(u, c, M.color, r.values), _(r.values, P), C(r.state, P);
    }
    i = P, a = M, o = n, V && (s = V, T += 1);
  }
  function N(V, U, H, K, X, Y) {
    return function(Q, J) {
      for (var te = 0, W = Q.length; te < W; ++te)
        if (Fe.isAtomic(J) && Q[te] === "atomic" || Fe.isSpheres(J) && Q[te] === "spheres" || Fe.isGaussians(J) && Q[te] === "gaussians") return !0;
      return !1;
    }(X.unitKinds, U) ? d(V, U, H, K, X, Y) : S(Y);
  }
  function R(V, U, H) {
    return function(K) {
      return !!qo(K) || !(!tt.isLoci(K) || !tt.areRootsEquivalent(K.structure, o.structure)) || !!(Xe.is(K) && tt.areRootsEquivalent(K.structure, o.structure) && Xe.isWholeStructure(K));
    }(V) ? U(Se.ofBounds(0, u.groupCount * u.instanceCount)) : m(V, o, U, H);
  }
  function L(V) {
    r && (g == null || g(r.values, s, i, a, V.webgl));
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return u && u.count ? r : void 0;
  }, get geometryVersion() {
    return T;
  }, createOrUpdate: function(V, U, H, K) {
    if (function(Y, Q, J) {
      if (!J && !o) throw new Error("missing structureGroup");
      if (P = Q, M = Y, n = J, Cc.reset(w), !r || !o) return w.createNew = !0, void (w.createGeometry = !0);
      p(w, P, i, M, a, n, o), tt.areHierarchiesEqual(o.structure, n.structure) || (w.updateTransform = !0, w.updateColor = !0, w.updateSize = !0), El.areEqual(M.color, a.color) || (w.updateColor = !0), o.structure.child !== n.structure.child && (w.createGeometry = !0), nf(P.unitKinds, i.unitKinds) || (w.createGeometry = !0), n.group.transformHash !== o.group.transformHash && (n.group.units.length !== o.group.units.length || w.updateColor ? w.updateTransform = !0 : w.updateMatrix = !0);
      var te = n.group.units[0], W = o.group.units[0];
      Fe.areOperatorsEqual(te, W) || (w.updateTransform = !0), Fe.areConformationsEqual(te, W) || (w.createGeometry = !0), w.updateTransform && (w.updateMatrix = !0), w.updateSize && !("uSize" in r.values) && (w.createGeometry = !0), (w.createGeometry || w.updateTransform) && (o.structure.hashCode !== n.structure.hashCode && (w.updateColor = !0, w.updateSize = !0), (M.color.granularity.startsWith("vertex") || r.values.dColorType.ref.value.startsWith("vertex") || M.color.granularity.startsWith("volume") || r.values.dColorType.ref.value.startsWith("volume")) && (w.updateColor = !0));
    }(U, H, K || o), w.createGeometry) {
      var X = N(V, n.group.units[0], n.structure, M, P, s);
      if (U9(X)) return X.then(function(Y) {
        F(Y), L(V);
      });
      F(X);
    } else F();
    L(V);
  }, getLoci: function(V) {
    return r ? h(V, o, r.id) : Dn;
  }, mark: function(V, U) {
    var H = !0;
    if (Xe.is(V)) {
      H = !1;
      for (var K = o.group.units[0].invariantId, X = 0, Y = V.elements; X < Y.length; X++)
        if (Y[X].unit.invariantId === K) {
          H = !0;
          break;
        }
    }
    return !!H && nr.mark(r, V, U, R, I);
  }, setVisibility: function(V) {
    nr.setVisibility(r, V);
  }, setAlphaFactor: function(V) {
    nr.setAlphaFactor(r, V);
  }, setPickable: function(V) {
    nr.setPickable(r, V);
  }, setColorOnly: function(V) {
    nr.setColorOnly(r, V);
  }, setTransform: function(V, U) {
    nr.setTransform(r, V, U);
  }, setOverpaint: function(V, U) {
    var H = { geometry: s, props: i, webgl: U };
    nr.setOverpaint(r, V, R, !0, H);
  }, setTransparency: function(V, U) {
    var H = { geometry: s, props: i, webgl: U };
    nr.setTransparency(r, V, R, !0, H);
  }, setSubstance: function(V, U) {
    var H = { geometry: s, props: i, webgl: U };
    nr.setSubstance(r, V, R, !0, H);
  }, setClipping: function(V) {
    nr.setClipping(r, V, R, !0);
  }, destroy: function() {
    y == null || y(s), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: v };
}
O(O({}, LL), Ko), O(O({}, kL), Ko);
var Rl = O(O({}, FL), Ko);
function Ol(t, e) {
  return C2(O(O({}, t), { setUpdateState: function(r, n, i, a, o, s, u) {
    t.setUpdateState(r, n, i, a, o, s, u), Co.areEqual(a.size, o.size) || (r.createGeometry = !0);
  }, geometryUtils: Vt.Utils }), e);
}
var rue = O(O({}, Qse), Ko), nue = O(O({}, NL), Ko), iue = O(O({}, Jse), Ko), Lx = O(O({}, RL), Ko);
function kx(t, e) {
  return C2(O(O({}, t), { setUpdateState: function(r, n, i, a, o, s, u) {
    t.setUpdateState(r, n, i, a, o, s, u), Co.areEqual(a.size, o.size) || (r.updateSize = !0);
  }, geometryUtils: Rr.Utils }), e);
}
O(O({}, OL), Ko), O(O({}, LL), Ko), O(O({}, kL), Ko);
var xs = { create: function() {
  return O(O({}, sr.createState()), { unitTransforms: null, unitTransformsVersion: -1 });
}, update: function(t, e) {
  sr.updateState(t, e), e.unitTransforms !== void 0 && (t.unitTransforms = e.unitTransforms);
} };
function VL(t, e) {
  return { centerA: at.create(t, e), centerB: at.create(t, e) };
}
var aue = function() {
  function t(e, r) {
    this.unit = r, this.hasNext = !1, this.traceElementIndex = r.model.atomicHierarchy.derived.residue.traceElementIndex, this.gapIt = rn.transientSegments(XL(r), r.elements), this.value = VL(e, r), this.hasNext = this.gapIt.hasNext;
  }
  return t.prototype.move = function() {
    var e = this.unit, r = e.elements, n = e.residueIndex, i = this.gapIt.move();
    return this.value.centerA.element = this.traceElementIndex[n[r[i.start]]], this.value.centerB.element = this.traceElementIndex[n[r[i.end - 1]]], this.hasNext = this.gapIt.hasNext, this.value;
  }, t;
}(), oue = function() {
  function t(e, r) {
    this.unit = r, this.hasNext = !1, this.gapIt = rn.transientSegments(XL(r), r.elements), this.value = VL(e, r), this.hasNext = this.gapIt.hasNext;
  }
  return t.prototype.move = function() {
    var e = this.gapIt.move();
    return this.value.centerA.element = this.unit.elements[e.start], this.value.centerB.element = this.unit.elements[e.end - 1], this.hasNext = this.gapIt.hasNext, this.value;
  }, t;
}();
function sue(t) {
  for (var e = t.atomicConformation, r = e.x, n = e.y, i = e.z, a = t.atomicHierarchy.derived.residue, o = a.polymerType, s = a.traceElementIndex, u = o.length, c = Ge.ofBounds(0, t.atomicConformation.atomId.rowCount), l = rn.transientSegments(t.atomicRanges.polymerRanges, c), d = Qt.transientSegments(t.atomicHierarchy.residueAtomSegments, c), f = new Float32Array(3 * u), h = new Float32Array(3 * u), m = 0, p = -1, v = -1, g = E(), y = E(), b = E(), S = E(), _ = E(), x = E(), C = E(), A = E(), w = E(), I = E(), P = E(), M = E(), T = E(), F = E(); l.hasNext; ) {
    var N = l.move();
    for (d.setSegment(N), m = -1, v = -1; d.hasNext; ) {
      m += 1;
      var R = d.move().index;
      m === 0 && (v = R);
      var L = 3 * (p = R - 2);
      E.copy(g, y), E.copy(y, b), E.copy(b, S);
      var V = s[R];
      if (E.set(S, r[V], n[V], i[V]), !(m < 3)) {
        E.sub(_, y, g), E.sub(x, b, y), E.sub(C, S, b), E.sub(P, _, x), E.sub(M, x, C), E.cross(T, P, M), E.normalize(T, T), E.toArray(T, h, L);
        var U = Math.cos(E.angle(P, M)), H = E.magnitude(P), K = E.magnitude(M), X = Math.sqrt(K * H) / Math.max(2, 2 * (1 - U));
        E.scale(A, P, X / H), E.sub(A, y, A), E.toArray(A, f, L), E.scale(w, M, X / K), E.sub(w, b, w), E.toArray(w, f, L + 3), E.copy(F, T);
      }
    }
    var Y = 3 * v;
    E.fromArray(A, f, Y + 3), E.fromArray(w, f, Y + 6), E.normalize(T, E.sub(T, A, w));
    var Q = s[v];
    E.set(g, r[Q], n[Q], i[Q]), E.copy(I, g), E.projectPointOnVector(I, I, T, A), E.toArray(I, f, Y);
    var J = p + 2, te = 3 * J;
    E.fromArray(A, f, te - 3), E.fromArray(w, f, te - 6), E.normalize(T, E.sub(T, A, w));
    var W = s[J];
    E.set(g, r[W], n[W], i[W]), E.copy(I, g), E.projectPointOnVector(I, I, T, A), E.toArray(I, f, te);
  }
  return { centers: f };
}
var H7 = fp.createProvider({ label: "Helix Orientation", descriptor: ku({ name: "molstar_helix_orientation" }), type: "dynamic", defaultParams: {}, getParams: function() {
  return {};
}, isApplicable: function(t) {
  return !0;
}, obtain: function(t, e) {
  return _e(void 0, 0, void 0, function() {
    return ye(this, function(r) {
      return [2, { value: sue(e) }];
    });
  });
} });
function bu(t) {
  return _r.is(t, 2);
}
function UL(t, e, r) {
  switch (r === void 0 && (r = {}), t.kind) {
    case 0:
      return new uue(t, e, r);
    case 1:
    case 2:
      return new cue(t, e);
  }
}
var u3 = _r.create(536870912);
function HL(t, e) {
  return { center: at.create(t, e), centerPrev: at.create(t, e), centerNext: at.create(t, e), first: !1, last: !1, initial: !1, final: !1, secStrucFirst: !1, secStrucLast: !1, secStrucType: u3, moleculeType: 0, coarseBackboneFirst: !1, coarseBackboneLast: !1, isCoarseBackbone: !1, p0: E(), p1: E(), p2: E(), p3: E(), p4: E(), d12: E(), d23: E() };
}
var Ft = E(), vv = E(), yv = E(), uue = function() {
  function t(e, r, n) {
    var i;
    if (n === void 0 && (n = {}), this.unit = e, this.state = 0, this.p0 = E(), this.p1 = E(), this.p2 = E(), this.p3 = E(), this.p4 = E(), this.p5 = E(), this.p6 = E(), this.d01 = E(), this.d12 = E(), this.d23 = E(), this.d34 = E(), this.hasNext = !1, this.atomicConformation = e.model.atomicConformation, this.residueAtomSegments = e.model.atomicHierarchy.residueAtomSegments, this.polymerRanges = e.model.atomicRanges.polymerRanges, this.traceElementIndex = e.model.atomicHierarchy.derived.residue.traceElementIndex, this.directionFromElementIndex = e.model.atomicHierarchy.derived.residue.directionFromElementIndex, this.directionToElementIndex = e.model.atomicHierarchy.derived.residue.directionToElementIndex, this.moleculeType = e.model.atomicHierarchy.derived.residue.moleculeType, this.cyclicPolymerMap = e.model.atomicRanges.cyclicPolymerMap, this.polymerIt = rn.transientSegments(this.polymerRanges, e.elements), this.residueIt = Qt.transientSegments(this.residueAtomSegments, e.elements), this.value = HL(r, e), this.hasNext = this.residueIt.hasNext && this.polymerIt.hasNext, n.ignoreSecondaryStructure || (this.secondaryStructure = (i = Ha.get(r).value) === null || i === void 0 ? void 0 : i.get(e.invariantId)), n.useHelixOrientation) {
      var a = H7.get(e.model).value;
      if (!a) throw new Error("missing helix-orientation");
      this.helixOrientationCenters = a.centers;
    }
  }
  return t.prototype.atomicPos = function(e, r) {
    r !== -1 && (e[0] = this.atomicConformation.x[r], e[1] = this.atomicConformation.y[r], e[2] = this.atomicConformation.z[r]);
  }, t.prototype.pos = function(e, r, n) {
    var i = this.traceElementIndex[r];
    this.helixOrientationCenters && bu(n) ? E.fromArray(e, this.helixOrientationCenters, 3 * r) : this.atomicPos(e, i);
  }, t.prototype.updateResidueSegmentRange = function(e) {
    var r = this.residueAtomSegments.index;
    this.residueSegmentMin = r[this.polymerRanges[2 * e.index]], this.residueSegmentMax = r[this.polymerRanges[2 * e.index + 1]];
  }, t.prototype.getResidueIndex = function(e) {
    if (e < this.residueSegmentMin) e = (r = this.cyclicPolymerMap.get(this.residueSegmentMin)) !== void 0 ? r - (this.residueSegmentMin - e - 1) : this.residueSegmentMin;
    else if (e > this.residueSegmentMax) {
      var r;
      e = (r = this.cyclicPolymerMap.get(this.residueSegmentMax)) !== void 0 ? r + (e - this.residueSegmentMax - 1) : this.residueSegmentMax;
    }
    return e;
  }, t.prototype.getSecStruc = function(e) {
    if (this.secondaryStructure) {
      var r = this.secondaryStructure, n = r.type[(0, r.getIndex)(e)];
      return bu(n) ? 2 : n;
    }
    return u3;
  }, t.prototype.setControlPoint = function(e, r, n, i, a) {
    (function(o) {
      return _r.is(o, 4);
    })(a) || this.helixOrientationCenters && bu(a) ? E.scale(e, E.add(e, r, E.add(e, i, E.add(e, n, n))), 1 / 4) : E.copy(e, n);
  }, t.prototype.setFromToVector = function(e, r, n) {
    this.value.isCoarseBackbone || this.helixOrientationCenters && bu(n) ? E.set(e, 1, 0, 0) : (this.atomicPos(vv, this.directionFromElementIndex[r]), this.atomicPos(yv, this.directionToElementIndex[r]), E.sub(e, yv, vv));
  }, t.prototype.setDirection = function(e, r, n, i) {
    E.matchDirection(vv, r, n), E.matchDirection(yv, i, n), E.scale(e, E.add(e, vv, E.add(e, yv, E.add(e, n, n))), 1 / 4);
  }, t.prototype.move = function() {
    var e = this, r = e.residueIt, n = e.polymerIt, i = e.value;
    if (this.state === 0) {
      for (; n.hasNext; ) if (this.polymerSegment = n.move(), r.setSegment(this.polymerSegment), this.updateResidueSegmentRange(this.polymerSegment), r.hasNext) {
        this.state = 1;
        var a = this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]], o = this.getResidueIndex(a - 1);
        this.currSecStrucType = a === o ? u3 : 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 = r.move().index, u = this.getResidueIndex(s - 3), c = this.getResidueIndex(s - 2), l = this.getResidueIndex(s - 1), d = this.getResidueIndex(s + 1), f = this.getResidueIndex(s + 2), h = this.getResidueIndex(s + 3);
      this.prevSecStrucType = this.currSecStrucType, this.currSecStrucType = this.nextSecStrucType, this.nextSecStrucType = s === d ? u3 : 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 m = this.getSecStruc(u), p = this.getSecStruc(c), v = this.getSecStruc(l), g = this.getSecStruc(s), y = this.getSecStruc(d), b = this.getSecStruc(f), S = this.getSecStruc(h);
      this.pos(this.p0, u, m), this.pos(this.p1, c, p), this.pos(this.p2, l, v), this.pos(this.p3, s, g), this.pos(this.p4, d, y), this.pos(this.p5, f, b), this.pos(this.p6, h, S);
      var _ = bu(m), x = bu(p), C = bu(v), A = bu(g), w = bu(y), I = bu(b), P = bu(S);
      this.helixOrientationCenters && (A !== C ? A ? (E.copy(this.p0, this.p3), E.copy(this.p1, this.p3), E.copy(this.p2, this.p3)) : C && (E.scale(Ft, E.sub(Ft, this.p2, this.p3), 2), E.add(this.p2, this.p3, Ft), E.add(this.p1, this.p2, Ft), E.add(this.p0, this.p1, Ft)) : A !== x ? A ? (E.copy(this.p0, this.p2), E.copy(this.p1, this.p2)) : x && (E.scale(Ft, E.sub(Ft, this.p1, this.p2), 2), E.add(this.p1, this.p2, Ft), E.add(this.p0, this.p1, Ft)) : A !== _ && (A ? E.copy(this.p0, this.p1) : _ && (E.scale(Ft, E.sub(Ft, this.p0, this.p1), 2), E.add(this.p0, this.p1, Ft))), A !== w ? A ? (E.copy(this.p4, this.p3), E.copy(this.p5, this.p3), E.copy(this.p6, this.p3)) : w && (E.scale(Ft, E.sub(Ft, this.p4, this.p3), 2), E.add(this.p4, this.p3, Ft), E.add(this.p5, this.p4, Ft), E.add(this.p6, this.p5, Ft)) : A !== I ? A ? (E.copy(this.p5, this.p4), E.copy(this.p6, this.p4)) : I && (E.scale(Ft, E.sub(Ft, this.p5, this.p4), 2), E.add(this.p5, this.p4, Ft), E.add(this.p6, this.p5, Ft)) : A !== P && (A ? E.copy(this.p6, this.p5) : P && (E.scale(Ft, E.sub(Ft, this.p6, this.p5), 2), E.add(this.p6, this.p5, Ft)))), this.setFromToVector(this.d01, l, v), this.setFromToVector(this.d12, s, g), this.setFromToVector(this.d23, d, y), this.setFromToVector(this.d34, f, b);
      var M = A && this.helixOrientationCenters, T = 1.5;
      s === l || g !== v && M ? (E.setMagnitude(Ft, E.sub(Ft, this.p3, this.p4), T), E.add(this.p2, this.p3, Ft), E.add(this.p1, this.p2, Ft), E.add(this.p0, this.p1, Ft)) : l === c || g !== p && M ? (E.setMagnitude(Ft, E.sub(Ft, this.p2, this.p3), T), E.add(this.p1, this.p2, Ft), E.add(this.p0, this.p1, Ft)) : (c === u || g !== m && M) && (E.setMagnitude(Ft, E.sub(Ft, this.p1, this.p2), T), E.add(this.p0, this.p1, Ft)), s === d || g !== y && M ? (E.setMagnitude(Ft, E.sub(Ft, this.p3, this.p2), T), E.add(this.p4, this.p3, Ft), E.add(this.p5, this.p4, Ft), E.add(this.p6, this.p5, Ft)) : d === f || g !== b && M ? (E.setMagnitude(Ft, E.sub(Ft, this.p4, this.p3), T), E.add(this.p5, this.p4, Ft), E.add(this.p6, this.p5, Ft)) : (f === h || g !== S && M) && (E.setMagnitude(Ft, E.sub(Ft, this.p5, this.p4), T), E.add(this.p6, this.p5, Ft)), this.setControlPoint(i.p0, this.p0, this.p1, this.p2, p), this.setControlPoint(i.p1, this.p1, this.p2, this.p3, v), this.setControlPoint(i.p2, this.p2, this.p3, this.p4, g), this.setControlPoint(i.p3, this.p3, this.p4, this.p5, y), this.setControlPoint(i.p4, this.p4, this.p5, this.p6, b), this.setDirection(i.d12, this.d01, this.d12, this.d23), this.setDirection(i.d23, this.d12, this.d23, this.d34), r.hasNext || (this.state = 0);
    }
    return this.hasNext = r.hasNext || n.hasNext, this.value;
  }, t;
}(), cue = function() {
  function t(e, r) {
    switch (this.unit = e, this.state = 0, this.hasNext = !1, this.polymerIt = rn.transientSegments(function(n) {
      switch (n.kind) {
        case 0:
          return n.model.atomicRanges.polymerRanges;
        case 1:
          return n.model.coarseHierarchy.spheres.polymerRanges;
        case 2:
          return n.model.coarseHierarchy.gaussians.polymerRanges;
      }
    }(e), e.elements), this.value = HL(r, e), E.set(this.value.d12, 1, 0, 0), E.set(this.value.d23, 1, 0, 0), e.kind) {
      case 1:
        this.conformation = e.model.coarseConformation.spheres;
        break;
      case 2:
        this.conformation = e.model.coarseConformation.gaussians;
    }
    this.hasNext = this.polymerIt.hasNext;
  }
  return t.prototype.getElementIndex = function(e) {
    return Math.min(Math.max(this.polymerSegment.start, e), this.polymerSegment.end - 1);
  }, t.prototype.pos = function(e, r) {
    var n = this.unit.elements[r];
    e[0] = this.conformation.x[n], e[1] = this.conformation.y[n], e[2] = this.conformation.z[n];
  }, t.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 e = this.getElementIndex(this.elementIndex - 2), r = this.getElementIndex(this.elementIndex - 1), n = this.getElementIndex(this.elementIndex + 1), i = this.getElementIndex(this.elementIndex + 2);
      this.value.centerPrev.element = this.value.center.unit.elements[r], this.value.center.element = this.value.center.unit.elements[this.elementIndex], this.value.centerNext.element = this.value.center.unit.elements[n], this.pos(this.value.p0, e), this.pos(this.value.p1, r), this.pos(this.value.p2, this.elementIndex), this.pos(this.value.p3, n), this.pos(this.value.p4, i);
      var a = 0.5;
      this.elementIndex === r ? (E.scale(Ft, E.sub(Ft, this.value.p2, this.value.p3), a), E.add(this.value.p1, this.value.p2, Ft), E.add(this.value.p0, this.value.p1, Ft)) : r === e && (E.scale(Ft, E.sub(Ft, this.value.p1, this.value.p2), a), E.add(this.value.p0, this.value.p1, Ft)), this.elementIndex === n ? (E.scale(Ft, E.sub(Ft, this.value.p2, this.value.p1), a), E.add(this.value.p3, this.value.p2, Ft), E.add(this.value.p4, this.value.p3, Ft)) : n === i && (E.scale(Ft, E.sub(Ft, this.value.p3, this.value.p2), a), E.add(this.value.p4, this.value.p3, Ft)), 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;
  }, t;
}(), Uf = E.fromArray, N1 = E.toArray, o8 = E.normalize, lue = E.sub, R1 = E.spline, due = E.slerp, gM = E.copy, vM = E.cross, s8 = E.orthogonalize, fue = E.matchDirection, pue = E.scale, yM = E.add;
function qL(t) {
  var e = t + 1, r = 3 * e;
  return { curvePoints: new Float32Array(r), tangentVectors: new Float32Array(r), normalVectors: new Float32Array(r), binormalVectors: new Float32Array(r), widthValues: new Float32Array(e), heightValues: new Float32Array(e), linearSegments: t };
}
function KL(t, e, r, n) {
  (function(i, a, o, s) {
    for (var u = i.curvePoints, c = i.tangentVectors, l = i.linearSegments, d = a.p0, f = a.p1, h = a.p2, m = a.p3, p = a.p4, v = a.secStrucFirst, g = a.secStrucLast, y = 1 - s, b = v ? 0.5 : o, S = g ? 0.5 : o, _ = 0; _ <= l; ++_) {
      var x = 1 * _ / l;
      if (x < y) {
        var C = Vi(b, o, x);
        R1(l8, d, f, h, m, x + s, C), R1(u8, d, f, h, m, x + s + 0.01, b), R1(c8, d, f, h, m, x + s - 0.01, b);
      } else
        C = Vi(o, S, x), R1(l8, f, h, m, p, x - y, C), R1(u8, f, h, m, p, x - y + 0.01, C), R1(c8, f, h, m, p, x - y - 0.01, C);
      N1(l8, u, 3 * _), o8(dd, lue(dd, u8, c8)), N1(dd, c, 3 * _);
    }
  })(t, e, r, n), function(i, a) {
    var o = i.curvePoints, s = i.tangentVectors, u = i.normalVectors, c = i.binormalVectors, l = a.d12, d = a.d23, f = o.length / 3;
    Uf(_M, s, 0), Uf(xM, s, 3 * (f - 1)), s8(d8, _M, l), s8(bv, xM, d), fue(bv, bv, d8), gM(Hh, d8);
    for (var h = f - 1, m = 0; m < f; ++m) {
      var p = iN(0, h, m) * h, v = m === 0 ? 0 : 1 / (f - p);
      Uf(dd, s, 3 * m), s8(_u, dd, due(hue, Hh, bv, v)), N1(_u, u, 3 * m), gM(Hh, _u), o8(O1, vM(O1, dd, _u)), N1(O1, c, 3 * m);
    }
    for (m = 1; m < h; ++m) Uf(Hh, u, 3 * (m - 1)), Uf(_u, u, 3 * m), Uf(bM, u, 3 * (m + 1)), pue(_u, yM(_u, Hh, yM(_u, bM, _u)), 1 / 3), N1(_u, u, 3 * m), Uf(dd, s, 3 * m), o8(O1, vM(O1, dd, _u)), N1(O1, c, 3 * m);
  }(t, e);
}
var u8 = E(), c8 = E(), l8 = E(), hue = E(), dd = E(), _u = E(), O1 = E(), Hh = E(), bM = E(), _M = E(), xM = E(), d8 = E(), bv = E();
function SM(t, e, r, n, i, a, o, s) {
  for (var u = t.widthValues, c = t.heightValues, l = t.linearSegments, d = 1 - s, f = 0; f <= l; ++f) {
    var h = 1 * f / l;
    h < d ? (u[f] = Vi(e, r, h + s), c[f] = Vi(i, a, h + s)) : (u[f] = Vi(r, n, h - d), c[f] = Vi(a, o, h - d));
  }
}
var sy, q7, uy, mue = 0.5, gue = 0.9, vue = 0.5, yue = 0.3, CM = 2;
function XL(t) {
  switch (t.kind) {
    case 0:
      return t.model.atomicRanges.gapRanges;
    case 1:
      return t.model.coarseHierarchy.spheres.gapRanges;
    case 2:
      return t.model.coarseHierarchy.gaussians.gapRanges;
  }
}
function YL(t, e, r) {
  var n = t.objectId, i = t.instanceId, a = t.groupId;
  if (r === n) {
    var o = e.structure, s = e.group.units[i];
    if (Fe.isAtomic(s)) return ML(o, s, s.polymerElements[a]);
    var u = s.elements, c = s.polymerElements[a], l = Ge.indexOf(u, c);
    if (l !== -1) return Xe(o, [{ unit: s, indices: Ge.ofSingleton(l) }]);
  }
  return Dn;
}
function AM(t, e, r, n, i, a) {
  for (var o = -1, s = -1, u = i; u <= a; u++)
    if (!((l = r[u]) < 0) && (o = Ge.indexOf(e, l)) >= 0) {
      s = u;
      break;
    }
  if (o < 0) return !1;
  var c = o;
  for (u = a; u > s; u--) {
    var l;
    if (!((l = r[u]) < 0)) {
      var d = Ge.indexOf(e, l);
      if (d >= 0) {
        c = d;
        break;
      }
    }
  }
  return n(Se.ofRange(t + o, t + c));
}
function WL(t, e, r, n, i) {
  var a = !1, o = i.unit.elements, s = i.unit.model.atomicHierarchy.derived.residue.traceElementIndex, u = i.unit.model.atomicHierarchy.residueAtomSegments.index, c = r(i.unit);
  if (Se.is(i.indices)) a = Se.start(i.indices) === 0 && Se.end(i.indices) === i.unit.elements.length ? n(Se.ofBounds(t, t + e)) || a : AM(t, c, s, n, h = u[o[Se.min(i.indices)]], m = u[o[Se.max(i.indices)]]) || a;
  else for (var l = i.indices, d = 0, f = l.length; d < f; d++) {
    for (var h, m = h = u[o[l[d]]], p = d + 1; p < f; ) {
      var v = u[o[l[p]]];
      if (v - m > 1) break;
      m = v, p++;
    }
    d = p - 1, a = AM(t, c, s, n, h, m) || a;
  }
  return a;
}
function bue(t) {
  return t.polymerElements;
}
function jL(t, e, r) {
  var n = !1;
  if (!Xe.is(t)) return !1;
  var i = e.structure, a = e.group;
  if (!tt.areEquivalent(t.structure, i)) return !1;
  for (var o = a.units[0].polymerElements.length, s = 0, u = t.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 (Fe.isAtomic(c.unit)) n = WL(l, o, bue, r, c) || n;
      else if (Se.is(c.indices)) {
        var d = l + Se.start(c.indices), f = l + Se.end(c.indices);
        n = r(Se.ofBounds(d, f)) || n;
      } else for (var h = 0, m = c.indices.length; h < m; h++) {
        d = c.indices[h];
        for (var p = h + 1; p < m && c.indices[p] === d; ) p++;
        h = p - 1, f = c.indices[h], n = r(Se.ofRange(l + d, l + f)) || n;
      }
    }
  }
  return n;
}
function _ue(t, e, r) {
  var n = t.objectId, i = t.instanceId, a = t.groupId;
  if (r === n) {
    var o = e.structure, s = e.group.units[i], u = Ge.indexOf(s.elements, s.gapElements[a]), c = Ge.indexOf(s.elements, s.gapElements[a % 2 ? a - 1 : a + 1]);
    if (u !== -1 && c !== -1) return Dt.Loci(o, [Dt.Location(o, s, u, o, s, c), Dt.Location(o, s, c, o, s, u)]);
  }
  return Dn;
}
function xue(t, e, r) {
  var n = !1;
  if (Dt.isLoci(t)) {
    var i = e.structure, a = e.group;
    if (!tt.areRootsEquivalent(t.structure, i)) return !1;
    t = Dt.remapLoci(t, i);
    for (var o = a.units[0].gapElements.length, s = 0, u = t.bonds; s < u.length; s++) {
      var c = u[s], l = a.unitIndexMap.get(c.aUnit.id);
      if (l !== void 0) {
        var d = Ge.indexOf(c.aUnit.gapElements, c.aUnit.elements[c.aIndex]), f = Ge.indexOf(c.bUnit.gapElements, c.bUnit.elements[c.bIndex]);
        d !== -1 && f !== -1 && r(Se.ofSingleton(l * o + d)) && (n = !0);
      }
    }
  } else if (Xe.is(t)) {
    if (i = e.structure, a = e.group, !tt.areRootsEquivalent(t.structure, i)) return !1;
    t = Xe.remap(t, i);
    for (var h = a.units[0].gapElements.length, m = function(g) {
      var y = a.unitIndexMap.get(g.unit.id);
      y !== void 0 && Ge.forEach(g.indices, function(b) {
        var S = Ge.indexOf(g.unit.gapElements, g.unit.elements[b]);
        S !== -1 && r(Se.ofSingleton(y * h + S)) && (n = !0);
      });
    }, p = 0, v = t.elements; p < v.length; p++)
      m(v[p]);
  }
  return n;
}
function ZL(t, e, r) {
  var n = t.objectId, i = t.instanceId, a = t.groupId;
  if (r === n) {
    var o = e.structure, s = e.group.units[i];
    if (Fe.isAtomic(s)) return ML(o, s, s.nucleotideElements[a]);
  }
  return Dn;
}
function Sue(t) {
  return t.nucleotideElements;
}
function QL(t, e, r) {
  var n = !1;
  if (!Xe.is(t)) return !1;
  var i = e.structure, a = e.group;
  if (!tt.areEquivalent(t.structure, i)) return !1;
  var o = a.units[0];
  if (!Fe.isAtomic(o)) return !1;
  for (var s = o.nucleotideElements.length, u = 0, c = t.elements; u < c.length; u++) {
    var l = c[u];
    if (Fe.isAtomic(l.unit) && a.unitIndexMap.has(l.unit.id)) {
      var d = a.unitIndexMap.get(l.unit.id) * s;
      Fe.isAtomic(l.unit) && (n = WL(d, s, Sue, r, l) || n);
    }
  }
  return n;
}
(function(t) {
  t.fromGroup = function(e) {
    var r = e.group, n = e.structure, i = r.units[0].polymerElements, a = i.length, o = r.units.length, s = at.create(n);
    return gi(a, o, 1, function(u, c) {
      var l = r.units[c];
      return s.unit = l, s.element = i[u], s;
    });
  };
})(sy || (sy = {})), function(t) {
  t.fromGroup = function(e) {
    var r = e.group, n = e.structure, i = r.units[0].gapElements, a = i.length, o = r.units.length, s = at.create(n);
    return gi(a, o, 1, function(u, c) {
      var l = r.units[c];
      return s.unit = l, s.element = i[u], s;
    });
  };
}(q7 || (q7 = {})), function(t) {
  t.fromGroup = function(e) {
    var r = e.group, n = e.structure, i = r.units[0], a = Fe.isAtomic(i) ? i.nucleotideElements : [], o = a.length, s = r.units.length, u = at.create(n);
    return gi(o, s, 1, function(c, l) {
      var d = r.units[l];
      return u.unit = d, u.element = a[c], u;
    });
  };
}(uy || (uy = {}));
var qh = E(), _v = E(), wM = E(), DM = E(), EM = E(), IM = E(), xv = E(), f8 = E(), p8 = E(), TM = E(), Kh = he.identity(), Cue = E(), MM = aO(), JL = { sizeFactor: z.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: z.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo) };
function Aue(t, e, r, n, i, a) {
  if (!Fe.isAtomic(e)) return Vt.createEmpty(a);
  var o = e.nucleotideElements.length;
  if (!o) return Vt.createEmpty(a);
  for (var s = i.sizeFactor, u = i.radialSegments, c = o * (MM.vertices.length / 3 + 2 * u), l = wt.createState(c, c / 4, a), d = e.elements, f = e.model, h = f.atomicHierarchy, m = h.chainAtomSegments, p = h.residueAtomSegments, v = h.atoms, g = h.index, y = f.atomicHierarchy.derived.residue, b = y.moleculeType, S = y.traceElementIndex, _ = v.label_comp_id, x = e.conformation.invariantPosition, C = Qt.transientSegments(m, d), A = Qt.transientSegments(p, d), w = { radiusTop: 1 * s, radiusBottom: 1 * s, radialSegments: u, bottomCap: !0 }, I = 0; C.hasNext; ) for (A.setSegment(C.move()); A.hasNext; ) {
    var P = A.move().index;
    if (Qp(b[P])) {
      var M = _.value(p.offsets[P]), T = -1, F = -1, N = -1, R = -1, L = -1, V = -1, U = 2.5 * s, H = 4.5, K = dR(M), X = fR(M);
      if (!K && !X) {
        var Y = g.findAtomOnResidue(P, "C4"), Q = g.findAtomOnResidue(P, "N9");
        Y !== -1 && Q !== -1 && E.distance(x(Y, qh), x(Q, _v)) < 1.6 ? K = !0 : X = !0;
      }
      K ? (H = 4.5, T = g.findAtomOnResidue(P, "N1"), F = g.findAtomOnResidue(P, "C4"), N = g.findAtomOnResidue(P, "C6"), R = g.findAtomOnResidue(P, "C2"), L = g.findAtomOnResidue(P, "N9"), V = S[P]) : X && (H = 3, T = g.findAtomOnResidue(P, "N3"), F = g.findAtomOnResidue(P, "C6"), N = g.findAtomOnResidue(P, "C4"), R = g.findAtomOnResidue(P, "C2"), (L = g.findAtomOnResidue(P, "N1")) === -1 && (L = g.findAtomOnResidue(P, "C1")), V = S[P]), L !== -1 && V !== -1 && (x(L, EM), x(V, IM), l.currentGroup = I, Hi(l, EM, IM, 1, w), T !== -1 && F !== -1 && N !== -1 && R !== -1 && (x(T, qh), x(F, _v), x(N, wM), x(R, DM), E.normalize(xv, E.sub(xv, _v, qh)), E.normalize(f8, E.sub(f8, DM, wM)), E.normalize(p8, E.cross(p8, xv, f8)), he.targetTo(Kh, qh, _v, p8), E.scaleAndAdd(TM, qh, xv, H / 2 - 0.2), he.scale(Kh, Kh, E.set(Cue, 4.5, U, H)), he.setTranslation(Kh, TM), wt.addPrimitive(l, Kh, MM))), ++I;
    }
  }
  var J = wt.getMesh(l), te = Me.expand(Me(), e.boundary.sphere, 1 * i.sizeFactor);
  return J.setBoundingSphere(te), J;
}
z.getDefaultValues(JL);
var $L = O(O({}, Rl), JL);
function wue(t) {
  return Ol({ defaultProps: z.getDefaultValues($L), createGeometry: Aue, createLocationIterator: uy.fromGroup, getLoci: ZL, eachLocation: QL, setUpdateState: function(e, r, n) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, t);
}
var Sv = E.zero(), fd = E.zero(), Cv = E.zero(), Av = E.zero(), Hf = E.zero(), L1 = E.zero(), wv = E.zero(), PM = E.zero(), BM = E.zero(), Xh = E.zero(), pd = E.zero(), ek = { sizeFactor: z.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: z.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo), detail: z.Numeric(0, { min: 0, max: 3, step: 1 }, ft.CustomQualityParamInfo) };
z.getDefaultValues(ek);
var Dv = new Float32Array(54), Due = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 14, 15, 12, 13, 8, 9, 10, 11, 0, 1]), Eue = new Uint32Array([8, 12, 14, 16, 6, 4, 2, 0, 10]), Iue = new Uint32Array([9, 11, 1, 3, 5, 7, 17, 15, 13]), Ev = new Float32Array(36), Tue = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1]), Mue = new Uint32Array([0, 10, 8, 6, 4, 2]), Pue = new Uint32Array([1, 3, 5, 7, 9, 11]), FM = E.zero();
function NM(t, e) {
  for (var r = [], n = 2; n < arguments.length; n++) r[n - 2] = arguments[n];
  for (var i = 0, a = r.length; i < a; ++i) {
    var o = r[i];
    E.toArray(E.add(FM, o, e), t, 2 * i * 3), E.toArray(E.sub(FM, o, e), t, 3 * (2 * i + 1));
  }
}
function Bue(t, e, r, n, i, a) {
  if (!Fe.isAtomic(e)) return Vt.createEmpty(a);
  var o = e.nucleotideElements.length;
  if (!o) return Vt.createEmpty(a);
  for (var s = i.sizeFactor, u = i.radialSegments, c = i.detail, l = o * (26 + 2 * u), d = wt.createState(l, l / 4, a), f = e.elements, h = e.model, m = h.atomicHierarchy, p = m.chainAtomSegments, v = m.residueAtomSegments, g = m.atoms, y = m.index, b = h.atomicHierarchy.derived.residue, S = b.moleculeType, _ = b.traceElementIndex, x = g.label_comp_id, C = e.conformation.invariantPosition, A = Qt.transientSegments(p, f), w = Qt.transientSegments(v, f), I = 1 * s, P = 1.25 * s, M = { radiusTop: 1 * s, radiusBottom: 1 * s, radialSegments: u }, T = 0; A.hasNext; ) for (w.setSegment(A.move()); w.hasNext; ) {
    var F = w.move().index;
    if (Qp(S[F])) {
      var N = x.value(v.offsets[F]), R = -1, L = -1, V = -1, U = -1, H = -1, K = -1, X = -1, Y = -1, Q = -1, J = -1;
      d.currentGroup = T;
      var te = dR(N), W = fR(N);
      if (!te && !W) {
        var j = y.findAtomOnResidue(F, "C4"), ee = y.findAtomOnResidue(F, "N9");
        j !== -1 && ee !== -1 && E.distance(C(j, Hf), C(ee, Xh)) < 1.6 ? te = !0 : W = !0;
      }
      te ? (R = _[F], L = y.findAtomOnResidue(F, "N1"), V = y.findAtomOnResidue(F, "C2"), U = y.findAtomOnResidue(F, "N3"), H = y.findAtomOnResidue(F, "C4"), (K = y.findAtomOnResidue(F, "C5")) === -1 && (K = y.findAtomOnResidue(F, "N5")), X = y.findAtomOnResidue(F, "C6"), (Y = y.findAtomOnResidue(F, "N7")) === -1 && (Y = y.findAtomOnResidue(F, "C7")), Q = y.findAtomOnResidue(F, "C8"), (J = y.findAtomOnResidue(F, "N9")) !== -1 && R !== -1 && (C(J, Xh), C(R, Sv), d.currentGroup = T, Hi(d, Xh, Sv, 1, M), Yi(d, Xh, I, c)), L !== -1 && V !== -1 && U !== -1 && H !== -1 && K !== -1 && X !== -1 && Y !== -1 && Q !== -1 && J !== -1 && (C(L, fd), C(V, Cv), C(U, Av), C(H, Hf), C(K, L1), C(X, wv), C(Y, PM), C(Q, BM), E.triangleNormal(pd, fd, Hf, L1), E.scale(pd, pd, P), NM(Dv, pd, fd, Cv, Av, Hf, L1, wv, PM, BM, Xh), wt.addTriangleStrip(d, Dv, Due), wt.addTriangleFan(d, Dv, Eue), wt.addTriangleFan(d, Dv, Iue))) : W && (R = _[F], (L = y.findAtomOnResidue(F, "N1")) === -1 && (L = y.findAtomOnResidue(F, "C1")), V = y.findAtomOnResidue(F, "C2"), U = y.findAtomOnResidue(F, "N3"), H = y.findAtomOnResidue(F, "C4"), K = y.findAtomOnResidue(F, "C5"), X = y.findAtomOnResidue(F, "C6"), L !== -1 && R !== -1 && (C(L, fd), C(R, Sv), d.currentGroup = T, Hi(d, fd, Sv, 1, M), Yi(d, fd, I, c)), L !== -1 && V !== -1 && U !== -1 && H !== -1 && K !== -1 && X !== -1 && (C(V, Cv), C(U, Av), C(H, Hf), C(K, L1), C(X, wv), E.triangleNormal(pd, fd, Hf, L1), E.scale(pd, pd, P), NM(Ev, pd, fd, Cv, Av, Hf, L1, wv), wt.addTriangleStrip(d, Ev, Tue), wt.addTriangleFan(d, Ev, Mue), wt.addTriangleFan(d, Ev, Pue))), ++T;
    }
  }
  var ie = wt.getMesh(d), ae = Me.expand(Me(), e.boundary.sphere, 1 * i.sizeFactor);
  return ie.setBoundingSphere(ae), ie;
}
var tk = O(O({}, Rl), ek);
function Fue(t) {
  return Ol({ defaultProps: z.getDefaultValues(tk), createGeometry: Bue, createLocationIterator: uy.fromGroup, getLoci: ZL, eachLocation: QL, setUpdateState: function(e, r, n) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, t);
}
var h8, qf = E.zero(), k1 = E.zero(), Kf = E.zero(), RM = E.zero(), ki = Vy(3, !1), Xf = he.identity(), Nue = E.zero(), OM = E.zero(), LM = E.zero(), m8 = E.zero(), Rue = 4, Oue = 4, Lue = 6, kue = (h8 || (h8 = function() {
  for (var t = b2(8), e = 0; e < 3; ++e) {
    var r = (e + 1) % 3;
    E.set(qf, ki[3 * e], ki[3 * e + 1], -0.5), E.set(k1, ki[3 * r], ki[3 * r + 1], -0.5), E.set(Kf, ki[3 * r], ki[3 * r + 1], 0.5), E.set(RM, ki[3 * e], ki[3 * e + 1], 0.5), t.add(qf, k1, Kf), t.add(Kf, RM, qf);
  }
  return E.set(qf, ki[0], ki[1], -0.5), E.set(k1, ki[3], ki[4], -0.5), E.set(Kf, ki[6], ki[7], -0.5), t.add(Kf, k1, qf), E.set(qf, ki[0], ki[1], 0.5), E.set(k1, ki[3], ki[4], 0.5), E.set(Kf, ki[6], ki[7], 0.5), t.add(qf, k1, Kf), t.getPrimitive();
}()), h8), rk = { sizeFactor: z.Numeric(0.2, { min: 0, max: 10, step: 0.01 }) };
function Gue(t, e, r, n, i, a) {
  var o = e.polymerElements.length;
  if (!o) return Vt.createEmpty(a);
  for (var s = i.sizeFactor, u = 24 * o, c = wt.createState(u, u / 10, a), l = qL(1), d = l.normalVectors, f = l.binormalVectors, h = 0, m = UL(e, r); m.hasNext; ) {
    var p = m.move();
    c.currentGroup = h;
    var v = Qp(p.moleculeType), g = _r.is(p.secStrucType, 4);
    if (KL(l, p, v || g ? 0.5 : 0.9, v ? 0.3 : 0.5), g && !p.secStrucLast || !g) {
      var y = n.size.size(p.center) * s, b = Rue * y, S = Oue * y, _ = Lue * y, x = v ? f : d;
      E.fromArray(OM, x, 0), E.fromArray(LM, x, 3), E.normalize(m8, E.add(m8, OM, LM)), he.targetTo(Xf, p.p3, p.p1, m8), he.mul(Xf, Xf, he.rotY90Z180), he.scale(Xf, Xf, E.set(Nue, _, S, b)), he.setTranslation(Xf, p.p2), wt.addPrimitive(c, Xf, kue);
    }
    ++h;
  }
  var C = wt.getMesh(c), A = Me.expand(Me(), e.boundary.sphere, 1 * i.sizeFactor);
  return C.setBoundingSphere(A), C;
}
z.getDefaultValues(rk);
var nk = O(O({}, Rl), rk);
function zue(t) {
  return Ol({ defaultProps: z.getDefaultValues(nk), createGeometry: Gue, createLocationIterator: sy.fromGroup, getLoci: YL, eachLocation: jL, setUpdateState: function(e, r, n) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor;
  } }, t);
}
var g8 = 10, ik = { sizeFactor: z.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: z.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo) };
function Vue(t, e, r, n, i, a) {
  var o = e.gapElements.length;
  if (!o) return Vt.createEmpty(a);
  for (var s = i.sizeFactor, u = i.radialSegments, c = g8 * u * 2 * o * 2, l = wt.createState(c, c / 10, a), d = e.conformation.invariantPosition, f = E.zero(), h = E.zero(), m = { radiusTop: 1, radiusBottom: 1, topCap: !0, bottomCap: !0, radialSegments: u }, p = 0, v = function(x, C) {
    switch (C.kind) {
      case 0:
        return new aue(x, C);
      case 1:
      case 2:
        return new oue(x, C);
    }
  }(r, e); v.hasNext; ) {
    var g = v.move(), y = g.centerA, b = g.centerB;
    y.element === b.element || (d(y.element, f), d(b.element, h), m.radiusTop = m.radiusBottom = n.size.size(y) * s, l.currentGroup = p, Rm(l, f, h, 0.5, g8, m), m.radiusTop = m.radiusBottom = n.size.size(b) * s, l.currentGroup = p + 1, Rm(l, h, f, 0.5, g8, m)), p += 2;
  }
  var S = wt.getMesh(l), _ = Me.expand(Me(), e.boundary.sphere, 1 * i.sizeFactor);
  return S.setBoundingSphere(_), S;
}
z.getDefaultValues(ik);
var ak = O(O({}, Rl), ik);
function Uue(t) {
  return Ol({ defaultProps: z.getDefaultValues(ak), createGeometry: Vue, createLocationIterator: q7.fromGroup, getLoci: _ue, eachLocation: xue, setUpdateState: function(e, r, n) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, t);
}
var Dr = E(), Ur = E(), Hue = E(), ls = E(), sc = E(), Iv = E(), Tv = E(), Yh = E(), wu = E(), uc = E(), v8 = E(), hd = E(), md = E(), gd = E(), vd = E(), Xs = E.fromArray, pp = E.scale, Zs = E.add, dl = E.sub, que = E.magnitude, kM = E.negate, K7 = E.copy, ok = E.cross, Kue = E.set, Yr = Le.add3, Xue = Le.add;
function Mv(t, e, r, n, i, a, o, s, u) {
  var c = e.vertices, l = e.normals, d = e.indices, f = c.elementCount;
  if (Xs(Dr, n, t), pp(Tv, Dr, o), pp(Iv, Dr, s), Xs(Ur, i, t), pp(ls, Ur, a), ok(uc, Ur, Dr), Xs(wu, r, t), Zs(hd, Zs(hd, wu, ls), Iv), dl(md, Zs(md, wu, ls), Tv), dl(gd, dl(gd, wu, ls), Tv), Zs(vd, dl(vd, wu, ls), Iv), o < s ? (Yr(c, vd[0], vd[1], vd[2]), Yr(c, gd[0], gd[1], gd[2]), Yr(c, md[0], md[1], md[2]), Yr(c, hd[0], hd[1], hd[2]), K7(sc, Iv)) : (Yr(c, hd[0], hd[1], hd[2]), Yr(c, md[0], md[1], md[2]), Yr(c, gd[0], gd[1], gd[2]), Yr(c, vd[0], vd[1], vd[2]), K7(sc, Tv)), u) {
    for (var h = 0; h < 4; ++h) Yr(l, -uc[0], -uc[1], -uc[2]);
    Yr(d, f, f + 1, f + 2), Yr(d, f + 2, f + 3, f);
  } else {
    for (h = 0; h < 4; ++h) Yr(l, uc[0], uc[1], uc[2]);
    Yr(d, f + 2, f + 1, f), Yr(d, f, f + 3, f + 2);
  }
}
function y8(t, e, r, n, i, a, o, s, u, c) {
  var l = t.currentGroup, d = t.vertices, f = t.normals, h = t.indices, m = t.groups, p = d.elementCount, v = 0;
  s > 0 ? (Xs(Dr, e, 0), Xs(Ur, e, 3 * i), v = s / que(dl(Hue, Ur, Dr))) : Kue(Yh, 0, 0, 0);
  for (var g = 0; g <= i; ++g) {
    var y = a[g], b = o[g], S = s === 0 ? b : s * (1 - g / i), _ = 3 * g;
    Xs(sc, r, _), pp(sc, sc, S), Xs(ls, n, _), pp(ls, ls, y), s > 0 && (Xs(Dr, r, _), Xs(Ur, n, _), pp(Yh, ok(Yh, Dr, Ur), v)), Xs(wu, e, _), Xs(uc, r, _), Xs(v8, n, _), Zs(Dr, Zs(Dr, wu, ls), sc), Zs(Ur, uc, Yh), Yr(d, Dr[0], Dr[1], Dr[2]), Yr(f, Ur[0], Ur[1], Ur[2]), Zs(Dr, dl(Dr, wu, ls), sc), Yr(d, Dr[0], Dr[1], Dr[2]), Yr(f, Ur[0], Ur[1], Ur[2]), kM(Ur, v8), Yr(d, Dr[0], Dr[1], Dr[2]), Yr(f, Ur[0], Ur[1], Ur[2]), dl(Dr, dl(Dr, wu, ls), sc), Yr(d, Dr[0], Dr[1], Dr[2]), Yr(f, Ur[0], Ur[1], Ur[2]), Zs(Ur, kM(Ur, uc), Yh), Yr(d, Dr[0], Dr[1], Dr[2]), Yr(f, Ur[0], Ur[1], Ur[2]), dl(Dr, Zs(Dr, wu, ls), sc), Yr(d, Dr[0], Dr[1], Dr[2]), Yr(f, Ur[0], Ur[1], Ur[2]), K7(Ur, v8), Yr(d, Dr[0], Dr[1], Dr[2]), Yr(f, Ur[0], Ur[1], Ur[2]), Zs(Dr, Zs(Dr, wu, ls), sc), Yr(d, Dr[0], Dr[1], Dr[2]), Yr(f, Ur[0], Ur[1], Ur[2]);
  }
  for (g = 0; g < i; ++g) {
    for (var x = 0; x < 2; x++) Yr(h, p + 8 * g + 2 * x, p + 8 * (g + 1) + 2 * x + 1, p + 8 * g + 2 * x + 1), Yr(h, p + 8 * g + 2 * x, p + 8 * (g + 1) + 2 * x, p + 8 * (g + 1) + 2 * x + 1);
    for (x = 2; x < 4; x++) Yr(h, p + 8 * g + 2 * x, p + 8 * (g + 1) + 2 * x, p + 8 * g + 2 * x + 1), Yr(h, p + 8 * (g + 1) + 2 * x, p + 8 * (g + 1) + 2 * x + 1, p + 8 * g + 2 * x + 1);
  }
  if (u) {
    var y = a[0], b = o[0], C = s === 0 ? b : s;
    Mv(0, t, e, r, n, y, C, C, !1);
  } else s > 0 && (Mv(0, t, e, r, n, y = a[0], s, -(b = o[0]), !1), Mv(0, t, e, r, n, y, -s, b, !1));
  c && s === 0 && Mv(3 * i, t, e, r, n, y = a[i], b = o[i], b, !0), g = 0;
  for (var A = 8 * (i + 1) + (u ? 4 : s > 0 ? 8 : 0) + (c && s === 0 ? 4 : 0); g < A; ++g) Xue(m, l);
}
var ci = E(), Ni = E(), mo = E(), va = E(), Xa = E();
function Pv(t, e, r, n, i) {
  t[0] = e[0] * n + r[0] * i, t[1] = e[1] * n + r[1] * i, t[2] = e[2] * n + r[2] * i;
}
function G1(t, e, r, n, i, a) {
  t[0] = e[0] * i + r[0] * a + n[0], t[1] = e[1] * i + r[1] * a + n[1], t[2] = e[2] * i + r[2] * a + n[2];
}
var $c = E.fromArray, Yue = E.normalize, b8 = E.scaleAndAdd, GM = E.cross, Wue = E.dot, jue = E.unitX, Ya = Le.add3, _8 = /* @__PURE__ */ new Map();
function zM(t, e, r, n, i, a, o, s, u, c, l) {
  for (var d = t.currentGroup, f = t.vertices, h = t.normals, m = t.indices, p = t.groups, v = f.elementCount, g = function(L, V) {
    var U = V ? 1 : 0, H = iu(L, U);
    if (!_8.has(H)) {
      for (var K = [], X = [], Y = 0; Y < L; ++Y) {
        var Q = (2 * Y + U) / L * Math.PI;
        K[Y] = Math.cos(Q), X[Y] = Math.sin(Q);
      }
      _8.set(H, { cos: K, sin: X });
    }
    return _8.get(H);
  }(a, l === "rounded"), y = g.cos, b = g.sin, S = Math.round(a / 4), _ = 3 * S, x = 0; x <= i; ++x) {
    var C = 3 * x;
    $c(va, r, C), $c(Xa, n, C), $c(mo, e, C);
    for (var A = o[x], w = s[x], I = l === "rounded" && w > A, P = 0; P < a; ++P) {
      if (I) {
        G1(Ni, va, Xa, mo, A * y[P], A * b[P]);
        var M = Wue(Xa, jue) < 0 ? P < S || P >= _ ? w - A : -w + A : P >= S && P < _ ? -w + A : w - A;
        b8(Ni, Ni, va, M), P === S || P === S - 1 ? Pv(ci, va, Xa, 0, 1) : P === _ || P === _ - 1 ? Pv(ci, va, Xa, 0, -1) : Pv(ci, va, Xa, y[P], b[P]);
      } else G1(Ni, va, Xa, mo, w * y[P], A * b[P]), Pv(ci, va, Xa, A * y[P], w * b[P]);
      Yue(ci, ci), Ya(f, Ni[0], Ni[1], Ni[2]), Ya(h, ci[0], ci[1], ci[2]);
    }
  }
  var T = Math.round(a / 2);
  for (x = 0; x < i; ++x) {
    for (P = 0; P < T; ++P) Ya(m, v + x * a + (P + 1) % a, v + (x + 1) * a + (P + 1) % a, v + x * a + P), Ya(m, v + (x + 1) * a + (P + 1) % a, v + (x + 1) * a + P, v + x * a + P);
    for (P = T; P < a; ++P) Ya(m, v + x * a + (P + 1) % a, v + (x + 1) * a + P, v + x * a + P), Ya(m, v + (x + 1) * a + (P + 1) % a, v + (x + 1) * a + P, v + x * a + (P + 1) % a);
  }
  if (u) {
    var F = 0, N = f.elementCount;
    for ($c(va, r, F), $c(Xa, n, F), $c(mo, e, F), GM(ci, Xa, va), Ya(f, mo[0], mo[1], mo[2]), Ya(h, ci[0], ci[1], ci[2]), A = o[0], w = s[0], (I = l === "rounded" && w > A) && (w -= A), v = f.elementCount, x = 0; x < a; ++x) I ? (G1(Ni, va, Xa, mo, A * y[x], A * b[x]), b8(Ni, Ni, va, x < S || x >= _ ? w : -w)) : G1(Ni, va, Xa, mo, w * y[x], A * b[x]), Ya(f, Ni[0], Ni[1], Ni[2]), Ya(h, ci[0], ci[1], ci[2]), Ya(m, v + (x + 1) % a, v + x, N);
  }
  if (c)
    for (F = 3 * i, N = f.elementCount, $c(va, r, F), $c(Xa, n, F), $c(mo, e, F), GM(ci, va, Xa), Ya(f, mo[0], mo[1], mo[2]), Ya(h, ci[0], ci[1], ci[2]), A = o[i], w = s[i], (I = l === "rounded" && w > A) && (w -= A), v = f.elementCount, x = 0; x < a; ++x) I ? (G1(Ni, va, Xa, mo, A * y[x], A * b[x]), b8(Ni, Ni, va, x < S || x >= _ ? w : -w)) : G1(Ni, va, Xa, mo, w * y[x], A * b[x]), Ya(f, Ni[0], Ni[1], Ni[2]), Ya(h, ci[0], ci[1], ci[2]), Ya(m, v + x, v + (x + 1) % a, N);
  var R = (i + 1) * a + (u ? a + 1 : 0) + (c ? a + 1 : 0);
  Le.addRepeat(p, R, d);
}
var el = E.fromArray, Zue = E.magnitude, x8 = E.sub, VM = E.add, S8 = E.scale, Que = E.negate, Jue = E.copy, $ue = E.cross, Gs = Le.add3, ece = Le.add, Gi = E(), ya = E(), tce = E(), C8 = E(), Yf = E(), UM = E(), Wh = E(), rce = E(), A8 = E();
function w8(t, e, r, n, i, a, o, s) {
  var u = t.currentGroup, c = t.vertices, l = t.normals, d = t.indices, f = t.groups, h = c.elementCount, m = 0;
  s > 0 && (el(Gi, e, 0), el(ya, e, 3 * i), m = s / Zue(x8(tce, ya, Gi)));
  for (var p = 0; p <= i; ++p) {
    var v = a[p], g = o[p], y = s === 0 ? g : s * (1 - p / i), b = 3 * p;
    el(Yf, r, b), S8(Yf, Yf, y), el(C8, n, b), S8(C8, C8, v), s > 0 && (el(Gi, r, b), el(ya, n, b), S8(UM, $ue(UM, Gi, ya), m)), el(Wh, e, b), el(rce, r, b), el(A8, n, b), VM(Gi, Wh, Yf), Que(ya, A8), Gs(c, Gi[0], Gi[1], Gi[2]), Gs(l, ya[0], ya[1], ya[2]), x8(Gi, Wh, Yf), Gs(c, Gi[0], Gi[1], Gi[2]), Gs(l, ya[0], ya[1], ya[2]), VM(Gi, Wh, Yf), Jue(ya, A8), Gs(c, Gi[0], Gi[1], Gi[2]), Gs(l, ya[0], ya[1], ya[2]), x8(Gi, Wh, Yf), Gs(c, Gi[0], Gi[1], Gi[2]), Gs(l, ya[0], ya[1], ya[2]);
  }
  for (p = 0; p < i; ++p) Gs(d, h + 4 * p, h + 4 * (p + 1) + 1, h + 4 * p + 1), Gs(d, h + 4 * p, h + 4 * (p + 1), h + 4 * (p + 1) + 1), Gs(d, h + 4 * p + 2 + 1, h + 4 * (p + 1) + 2 + 1, h + 4 * p + 2), Gs(d, h + 4 * p + 2, h + 4 * (p + 1) + 2 + 1, h + 4 * (p + 1) + 2);
  p = 0;
  for (var S = 4 * (i + 1); p < S; ++p) ece(f, u);
}
var sk = { sizeFactor: z.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), aspectRatio: z.Numeric(5, { min: 0.1, max: 10, step: 0.1 }), arrowFactor: z.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Size factor for sheet arrows" }), tubularHelices: z.Boolean(!1, { description: "Draw alpha helices as tubes" }), helixProfile: z.Select("elliptical", z.arrayToOptions(["elliptical", "rounded", "square"]), { description: "Protein and nucleic helix trace profile" }), detail: z.Numeric(0, { min: 0, max: 3, step: 1 }, ft.CustomQualityParamInfo), linearSegments: z.Numeric(8, { min: 1, max: 48, step: 1 }, ft.CustomQualityParamInfo), radialSegments: z.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo) };
z.getDefaultValues(sk);
var Ro = E();
function nce(t, e, r, n, i, a) {
  var o = e.polymerElements.length;
  if (!o) return Vt.createEmpty(a);
  for (var s = i.sizeFactor, u = i.detail, c = i.linearSegments, l = i.radialSegments, d = i.aspectRatio, f = i.arrowFactor, h = i.tubularHelices, m = i.helixProfile, p = c * l * o + (l + 1) * o * 2, v = wt.createState(p, p / 10, a), g = Fe.isCoarse(e), y = qL(c), b = y.curvePoints, S = y.normalVectors, _ = y.binormalVectors, x = y.widthValues, C = y.heightValues, A = 0, w = UL(e, r, { ignoreSecondaryStructure: !1, useHelixOrientation: h }); w.hasNext; ) {
    var I = w.move();
    v.currentGroup = A;
    var P = Qp(I.moleculeType), M = _r.is(I.secStrucType, 4), T = _r.is(I.secStrucType, 2), F = P ? yue : vue;
    KL(y, I, T && !h ? gue : mue, F);
    var N = n.size.size(I.centerPrev) * s, R = n.size.size(I.center) * s, L = n.size.size(I.centerNext) * s;
    g && (N *= d / 2, R *= d / 2, L *= d / 2);
    var V = I.secStrucFirst || I.coarseBackboneFirst || I.first, U = I.secStrucLast || I.coarseBackboneLast || I.last, H = c;
    if (I.initial) {
      var K = c - (H = Math.max(Math.round(c * F), 1));
      b.copyWithin(0, 3 * K), _.copyWithin(0, 3 * K), S.copyWithin(0, 3 * K), E.fromArray(Ro, b, 3), E.normalize(Ro, E.sub(Ro, I.p2, Ro)), E.scaleAndAdd(Ro, I.p2, Ro, R * CM), E.toArray(Ro, b, 0);
    } else I.final && (H = Math.max(Math.round(c * (1 - F)), 1), E.fromArray(Ro, b, 3 * H - 3), E.normalize(Ro, E.sub(Ro, I.p2, Ro)), E.scaleAndAdd(Ro, I.p2, Ro, R * CM), E.toArray(Ro, b, 3 * H));
    if (I.initial === !0 && I.final === !0) Yi(v, I.p2, 2 * R, u);
    else if (M) {
      var X = N * d, Y = R * d, Q = L * d, J = I.secStrucLast ? Y * f : 0;
      SM(y, N, R, L, X, Y, Q, F), l === 2 ? w8(v, b, S, _, H, x, C, J) : y8(v, b, S, _, H, x, C, J, V, U);
    } else {
      X = void 0, Y = void 0, Q = void 0, T && !I.isCoarseBackbone ? h ? (X = N *= 1.5 * d, Y = R *= 1.5 * d, Q = L *= 1.5 * d) : (X = N * d, Y = R * d, Q = L * d) : P && !I.isCoarseBackbone ? (X = N * d, Y = R * d, Q = L * d) : (X = N, Y = R, Q = L), SM(y, N, R, L, X, Y, Q, F);
      var te = P && !I.isCoarseBackbone ? [_, S] : [S, _], W = te[0], j = te[1];
      if (P && !I.isCoarseBackbone) for (var ee = 0, ie = W.length; ee < ie; ee++) W[ee] *= -1;
      l === 2 ? P && !I.isCoarseBackbone ? w8(v, b, W, j, H, C, x, 0) : w8(v, b, W, j, H, x, C, 0) : l === 4 ? y8(v, b, W, j, H, x, C, 0, V, U) : Y === R ? zM(v, b, W, j, H, l, x, C, V, U, "elliptical") : m === "square" ? y8(v, b, W, j, H, x, C, 0, V, U) : zM(v, b, W, j, H, l, x, C, V, U, m);
    }
    ++A;
  }
  var ae = wt.getMesh(v), ce = Me.expand(Me(), e.boundary.sphere, 1 * i.sizeFactor);
  return ae.setBoundingSphere(ce), ae;
}
var uk = O(O({}, Rl), sk);
function ice(t) {
  return Ol({ defaultProps: z.getDefaultValues(uk), createGeometry: nce, createLocationIterator: sy.fromGroup, getLoci: YL, eachLocation: jL, setUpdateState: function(e, r, n, i, a, o, s) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor || r.tubularHelices !== n.tubularHelices || r.detail !== n.detail || r.linearSegments !== n.linearSegments || r.radialSegments !== n.radialSegments || r.aspectRatio !== n.aspectRatio || r.arrowFactor !== n.arrowFactor || r.helixProfile !== n.helixProfile;
    var u = Ha.get(o.structure).version;
    e.info.secondaryStructureHash !== u && (e.createGeometry = e.info.secondaryStructureHash !== void 0, e.info.secondaryStructureHash = u);
  } }, t);
}
var ck = { "polymer-trace": function(t, e) {
  return $a("Polymer trace mesh", t, e, ice);
}, "polymer-gap": function(t, e) {
  return $a("Polymer gap cylinder", t, e, Uue);
}, "nucleotide-block": function(t, e) {
  return $a("Nucleotide block mesh", t, e, wue);
}, "nucleotide-ring": function(t, e) {
  return $a("Nucleotide ring mesh", t, e, Fue);
}, "direction-wedge": function(t, e) {
  return $a("Polymer direction wedge", t, e, zue);
} }, HM = O(O(O(O(O(O({}, uk), ak), $L), tk), nk), { sizeFactor: z.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), visuals: z.MultiSelect(["polymer-trace", "polymer-gap", "nucleotide-ring"], z.objectToOptions(ck)), bumpFrequency: z.Numeric(2, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory) }), n2, cl = { name: "cartoon", label: "Cartoon", description: "Displays ribbons, planks, tubes smoothly following the trace atoms of polymers.", factory: function(t, e) {
  return sr.createMulti("Cartoon", t, e, xs, ck);
}, getParams: function(t, e) {
  var r = z.clone(HM), n = !1, i = !1;
  return e.units.forEach(function(a) {
    !n && Fe.isAtomic(a) && a.nucleotideElements.length && (n = !0), !i && a.gapElements.length && (i = !0);
  }), r.visuals.defaultValue = ["polymer-trace"], n && r.visuals.defaultValue.push("nucleotide-ring"), i && r.visuals.defaultValue.push("polymer-gap"), r;
}, defaultValues: z.getDefaultValues(HM), defaultColorTheme: { name: "chain-id" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(t) {
  return t.polymerResidueCount > 0;
}, ensureCustomProperties: { attach: function(t, e) {
  return _e(void 0, 0, void 0, function() {
    var r, n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, Ha.attach(t, e, void 0, !0)];
        case 1:
          a.sent(), r = 0, n = e.models, a.label = 2;
        case 2:
          return r < n.length ? (i = n[r], [4, H7.attach(t, i, void 0, !0)]) : [3, 5];
        case 3:
          a.sent(), a.label = 4;
        case 4:
          return r++, [3, 2];
        case 5:
          return [2];
      }
    });
  });
}, detach: function(t) {
  Ha.ref(t, !1);
  for (var e = 0, r = t.models; e < r.length; e++) {
    var n = r[e];
    H7.ref(n, !1);
  }
} } }, ace = { create: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return t.elementCount ? [4, Ha.attach({ runtime: hs, assetManager: new pl() }, t)] : [3, 2];
        case 1:
          i.sent(), i.label = 2;
        case 2:
          return (n = cl.factory(e, cl.getParams)).setTheme(r ?? { color: e.colorThemeRegistry.create("element-symbol", { structure: t }), size: e.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, n.createOrUpdate(O(O({}, cl.defaultValues), { quality: "auto" }), t).run()];
        case 3:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return t.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: e }), size: r.sizeThemeRegistry.create("uniform", { structure: e }) }), e.elementCount ? [4, Ha.attach({ runtime: hs, assetManager: new pl() }, e)] : [3, 2];
        case 1:
          i.sent(), i.label = 2;
        case 2:
          return [4, t.createOrUpdate({}, e).run()];
        case 3:
          return i.sent(), [2];
      }
    });
  });
} }, Bv = E(), Fv = E(), Wf = E(), D8 = Le.add, qM = Le.add3;
(function(t) {
  t.create = function(e, r, n) {
    e === void 0 && (e = 2048), r === void 0 && (r = 1024);
    var i = Le.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : e), a = Le.create(Float32Array, 3, r, n ? n.startBuffer.ref.value : e), o = Le.create(Float32Array, 3, r, n ? n.endBuffer.ref.value : e), s = Le.create(Float32Array, 1, r, n ? n.scaleBuffer.ref.value : e), u = Le.create(Float32Array, 1, r, n ? n.capBuffer.ref.value : e), c = function(d, f, h, m, p, v, g, y, b, S) {
      for (var _ = 0; _ < 6; ++_) qM(a, d, f, h), qM(o, m, p, v), D8(i, S), D8(s, g), D8(u, (y ? 1 : 0) + (b ? 2 : 0));
    }, l = function(d, f, h, m, p, v, g) {
      var y = E.distance(d, f), b = Math.floor(h / 2), S = 1 / h;
      E.sub(Wf, f, d);
      for (var _ = 0; _ < b; ++_) {
        var x = S * (2 * _ + 1);
        E.setMagnitude(Wf, Wf, y * x), E.add(Bv, d, Wf), E.setMagnitude(Wf, Wf, y * S * (2 * (_ + 1))), E.add(Fv, d, Wf), c(Bv[0], Bv[1], Bv[2], Fv[0], Fv[1], Fv[2], m, p, v, g);
      }
    };
    return { add: c, addFixedCountDashes: l, addFixedLengthDashes: function(d, f, h, m, p, v, g) {
      var y = E.distance(d, f);
      l(d, f, y / h, m, p, v, g);
    }, getCylinders: function() {
      var d = i.elementCount / 6, f = Le.compact(i, !0), h = Le.compact(a, !0), m = Le.compact(o, !0), p = Le.compact(s, !0), v = Le.compact(u, !0), g = n && d <= n.cylinderCount ? n.mappingBuffer.ref.value : new Float32Array(18 * d), y = n && d <= n.cylinderCount ? n.indexBuffer.ref.value : new Uint32Array(12 * d);
      return (!n || d > n.cylinderCount) && function(b, S, _) {
        for (var x = 0; x < b; ++x) {
          var C = 18 * x;
          S[C] = -1, S[C + 1] = 1, S[C + 2] = -1, S[C + 3] = -1, S[C + 4] = -1, S[C + 5] = -1, S[C + 6] = 1, S[C + 7] = 1, S[C + 8] = -1, S[C + 9] = 1, S[C + 10] = 1, S[C + 11] = 1, S[C + 12] = 1, S[C + 13] = -1, S[C + 14] = -1, S[C + 15] = 1, S[C + 16] = -1, S[C + 17] = 1;
        }
        for (x = 0; x < b; ++x) {
          var A = 6 * x, w = 12 * x;
          _[w] = A, _[w + 1] = A + 1, _[w + 2] = A + 2, _[w + 3] = A + 1, _[w + 4] = A + 4, _[w + 5] = A + 2, _[w + 6] = A + 2, _[w + 7] = A + 4, _[w + 8] = A + 3, _[w + 9] = A + 4, _[w + 10] = A + 5, _[w + 11] = A + 3;
        }
      }(d, g, y), to.create(g, y, f, h, m, p, v, d, n);
    } };
  };
})(n2 || (n2 = {}));
var $y = { linkScale: z.Numeric(0.45, { min: 0, max: 1, step: 0.01 }), linkSpacing: z.Numeric(1, { min: 0, max: 2, step: 0.01 }), linkCap: z.Boolean(!1), aromaticScale: z.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), aromaticSpacing: z.Numeric(1.5, { min: 0, max: 3, step: 0.01 }), aromaticDashCount: z.Numeric(2, { min: 2, max: 6, step: 2 }), dashCount: z.Numeric(4, { min: 2, max: 10, step: 2 }), dashScale: z.Numeric(0.8, { min: 0, max: 2, step: 0.1 }), dashCap: z.Boolean(!0), stubCap: z.Boolean(!0), radialSegments: z.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo) };
z.getDefaultValues($y);
var lk = { linkScale: z.Numeric(0.5, { min: 0, max: 1, step: 0.1 }), linkSpacing: z.Numeric(0.1, { min: 0, max: 2, step: 0.01 }), aromaticDashCount: z.Numeric(2, { min: 2, max: 6, step: 2 }), dashCount: z.Numeric(4, { min: 2, max: 10, step: 2 }) };
z.getDefaultValues(lk);
var Ar = E(), yd = E(), zs = E(), oce = E.create(0, 1, 0);
function Gx(t, e, r, n) {
  E.normalize(yd, E.sub(yd, e, r)), n !== null ? E.sub(zs, e, n) : E.copy(zs, e), E.normalize(zs, zs);
  var i = E.dot(yd, zs);
  return 1 - Math.abs(i) < 1e-5 && (E.set(zs, 1, 0, 0), i = E.dot(yd, zs), 1 - Math.abs(i) < 1e-5 && (E.set(zs, 0, 1, 0), i = E.dot(yd, zs))), E.setMagnitude(yd, yd, i), E.sub(zs, zs, yd), E.normalize(t, zs);
}
var ds = E.scale, ai = E.add, vn = E.sub, Ra = E.setMagnitude, sce = E.dot;
function e4(t, e, r, n) {
  var i = e.linkCount, a = e.referencePosition, o = e.position, s = e.style, u = e.radius, c = e.ignore, l = e.stub;
  if (!i) return { mesh: Vt.createEmpty(n) };
  for (var d = r.linkScale, f = r.linkSpacing, h = r.radialSegments, m = r.linkCap, p = r.aromaticScale, v = r.aromaticSpacing, g = r.aromaticDashCount, y = r.dashCount, b = r.dashScale, S = r.dashCap, _ = r.stubCap, x = 2 * h * i * 2, C = wt.createState(x, x / 4, n), A = E(), w = E(), I = E(), P = E(), M = 0, T = { radiusTop: 1, radiusBottom: 1, radialSegments: h, topCap: m, bottomCap: m }, F = y + 1, N = 0, R = i; N < R; ++N) if (!c || !c(N)) {
    o(A, w, N), ai(P, P, A), ai(P, P, w), M += 2, vn(Ar, w, A);
    var L = sce(Ar, oce) > 0, V = u(N), U = s ? s(N) : 0, H = _ && !!l && l(N), K = L ? [H, m] : [m, H], X = K[0], Y = K[1];
    C.currentGroup = N;
    var Q = g + 1;
    if (U === 0) T.radiusTop = T.radiusBottom = V, T.topCap = X, T.bottomCap = Y, Hi(C, A, w, 0.5, T);
    else if (U === 1) T.radiusTop = T.radiusBottom = V * b, T.topCap = T.bottomCap = S, Rm(C, A, w, 0.5, F, T);
    else if (U === 2 || U === 3 || U === 4 || U === 5 || U === 7 || U === 8) {
      var J = U === 2 || U === 3 ? 2 : U === 4 || U === 5 ? 3 : 1.5, te = V * (d / (0.5 * J)), W = (V - te) * f;
      if (Gx(I, A, w, a ? a(N) : null), T.topCap = X, T.bottomCap = Y, U === 7 || U === 8) {
        T.radiusTop = T.radiusBottom = V, Hi(C, A, w, 0.5, T);
        var j = V + p * V + p * V * v;
        Ra(Ar, vn(Ar, w, A), 0.5 * V), ai(A, A, Ar), vn(w, w, Ar), T.radiusTop = T.radiusBottom = V * p, T.topCap = T.bottomCap = S, Ra(I, I, j), vn(A, A, I), vn(w, w, I), Rm(C, A, w, 0.5, Q, T), U === 8 && (Ra(I, I, 2 * j), ai(A, A, I), ai(w, w, I), Rm(C, A, w, 0.5, Q, T));
      } else if (U === 3 || U === 5) {
        var ee = V + te + d * V * f;
        Ra(I, I, ee), T.radiusTop = T.radiusBottom = V, Hi(C, A, w, 0.5, T), ds(Ar, Ar, f * d * 0.2), ai(A, A, Ar), vn(w, w, Ar), T.radiusTop = T.radiusBottom = te, T.topCap = L ? H : S, T.bottomCap = L ? S : H, Ra(I, I, ee), vn(A, A, I), vn(w, w, I), Hi(C, A, w, 0.5, T), J === 3 && (Ra(I, I, 2 * ee), ai(A, A, I), ai(w, w, I), Hi(C, A, w, 0.5, T));
      } else Ra(I, I, W), T.radiusTop = T.radiusBottom = te, J === 3 && Hi(C, A, w, 0.5, T), oie(C, A, w, 0.5, I, T);
    } else U === 6 && (ds(Ar, Ar, 0.475), ai(A, A, Ar), vn(w, w, Ar), T.radiusTop = T.radiusBottom = V, T.topCap = X, T.bottomCap = Y, Hi(C, A, w, 0.5, T));
  }
  var ie = n ? Me.clone(n.boundingSphere) : void 0, ae = wt.getMesh(C);
  return M === 0 ? { mesh: ae } : (E.scale(P, P, 1 / M), ie && E.distance(P, ie.center) / ie.radius < 1 ? { mesh: ae, boundingSphere: ie } : { mesh: ae });
}
function dk(t, e, r, n) {
  var i = e.linkCount, a = e.referencePosition, o = e.position, s = e.style, u = e.radius, c = e.ignore, l = e.stub;
  if (!i) return { cylinders: to.createEmpty(n) };
  for (var d = r.linkScale, f = r.linkSpacing, h = r.linkCap, m = r.aromaticScale, p = r.aromaticSpacing, v = r.aromaticDashCount, g = r.dashCount, y = r.dashScale, b = r.dashCap, S = r.stubCap, _ = 2 * i, x = n2.create(_, _ / 4, n), C = E(), A = E(), w = E(), I = E(), P = E(), M = 0, T = g % 2 == 1 ? g : g + 1, F = 0.5 - 0.25 / T, N = v + 1, R = 0.5 - 0.25 / N, L = 0, V = i; L < V; ++L) if (!c || !c(L)) {
    o(C, A, L), ai(P, P, C), ai(P, P, A), M += 2;
    var U = u(L), H = s ? s(L) : 0, K = S && !!l && l(L);
    if (H === 0) ds(w, ai(w, C, A), 0.5), x.add(C[0], C[1], C[2], w[0], w[1], w[2], 1, h, K, L);
    else if (H === 1) ds(Ar, vn(Ar, A, C), F), vn(A, A, Ar), x.addFixedCountDashes(C, A, T, y, b, b, L);
    else if (H === 2 || H === 3 || H === 4 || H === 5 || H === 7 || H === 8) {
      var X = H === 2 || H === 3 ? 2 : H === 4 || H === 5 ? 3 : 1.5, Y = d / (0.5 * X), Q = (U - Y * U) * f;
      if (ds(w, ai(w, C, A), 0.5), Gx(I, C, A, a ? a(L) : null), H === 7 || H === 8) {
        x.add(C[0], C[1], C[2], w[0], w[1], w[2], 1, h, K, L);
        var J = U + m * U + m * U * p;
        ds(Ar, vn(Ar, A, C), R), vn(A, A, Ar), Ra(Ar, vn(Ar, A, C), 0.5 * U), ai(C, C, Ar), Ra(I, I, J), vn(C, C, I), vn(A, A, I), x.addFixedCountDashes(C, A, N, m, b, b, L), H === 8 && (Ra(I, I, 2 * J), ai(C, C, I), ai(A, A, I), x.addFixedCountDashes(C, A, N, m, b, b, L));
      } else H === 3 || H === 5 ? (Ra(I, I, U + Y * U + d * U * f), x.add(C[0], C[1], C[2], w[0], w[1], w[2], 1, h, K, L), Ra(Ar, vn(Ar, C, A), U / 1.5), vn(C, C, Ar), X === 3 && x.add(C[0] + I[0], C[1] + I[1], C[2] + I[2], w[0] + I[0], w[1] + I[1], w[2] + I[2], Y, h, K, L), x.add(C[0] - I[0], C[1] - I[1], C[2] - I[2], w[0] - I[0], w[1] - I[1], w[2] - I[2], Y, b, K, L)) : (Ra(I, I, Q), X === 3 && x.add(C[0], C[1], C[2], w[0], w[1], w[2], Y, h, K, L), x.add(C[0] + I[0], C[1] + I[1], C[2] + I[2], w[0] + I[0], w[1] + I[1], w[2] + I[2], Y, h, K, L), x.add(C[0] - I[0], C[1] - I[1], C[2] - I[2], w[0] - I[0], w[1] - I[1], w[2] - I[2], Y, h, K, L));
    } else H === 6 && (ds(Ar, vn(Ar, A, C), 0.475), ai(C, C, Ar), vn(A, A, Ar), x.add(C[0], C[1], C[2], A[0], A[1], A[2], 1, h, K, L));
  }
  var te = n ? Me.clone(n.boundingSphere) : void 0, W = x.getCylinders();
  return M === 0 ? { cylinders: W } : (E.scale(P, P, 1 / M), te && E.distance(P, te.center) / te.radius < 1 ? { cylinders: W, boundingSphere: te } : { cylinders: W });
}
function fk(t, e, r, n) {
  var i = e.linkCount, a = e.referencePosition, o = e.position, s = e.style, u = e.ignore;
  if (!i) return { lines: Rr.createEmpty(n) };
  for (var c = r.linkScale, l = r.linkSpacing, d = r.aromaticDashCount, f = r.dashCount, h = 2 * i, m = Ea.create(h, h / 4, n), p = E(), v = E(), g = E(), y = E(), b = E(), S = 0, _ = f % 2 == 1 ? f : f + 1, x = 0.5 - 0.25 / _, C = d + 1, A = 0.5 - 0.25 / C, w = 0, I = i; w < I; ++w) if (!u || !u(w)) {
    o(p, v, w), ai(b, b, p), ai(b, b, v), S += 2;
    var P = s ? s(w) : 0;
    if (P === 0) ds(g, ai(g, p, v), 0.5), m.add(p[0], p[1], p[2], g[0], g[1], g[2], w);
    else if (P === 1) ds(Ar, vn(Ar, v, p), x), vn(v, v, Ar), m.addFixedCountDashes(p, v, _, w);
    else if (P === 2 || P === 3 || P === 4 || P === 5 || P === 7 || P === 8) {
      var M = P === 2 || P === 3 ? 2 : P === 4 || P === 5 ? 3 : 1.5, T = (1 - c / (0.5 * M) * 1) * l;
      ds(g, ai(g, p, v), 0.5), Gx(y, p, v, a ? a(w) : null), P === 7 || P === 8 ? (m.add(p[0], p[1], p[2], g[0], g[1], g[2], w), ds(Ar, vn(Ar, v, p), A), vn(v, v, Ar), Ra(y, y, 4.5 * T), vn(p, p, y), vn(v, v, y), m.addFixedCountDashes(p, v, C, w), P === 8 && (Ra(y, y, 4.5 * T * 2), ai(p, p, y), ai(v, v, y), m.addFixedCountDashes(p, v, C, w))) : P === 3 || P === 5 ? (Ra(y, y, 3 * T), m.add(p[0], p[1], p[2], g[0], g[1], g[2], w), ds(Ar, vn(Ar, p, v), l * c), vn(p, p, Ar), M === 3 && m.add(p[0] + y[0], p[1] + y[1], p[2] + y[2], g[0] + y[0], g[1] + y[1], g[2] + y[2], w), m.add(p[0] - y[0], p[1] - y[1], p[2] - y[2], g[0] - y[0], g[1] - y[1], g[2] - y[2], w)) : (Ra(y, y, 1.5 * T), M === 3 && m.add(p[0], p[1], p[2], g[0], g[1], g[2], w), m.add(p[0] + y[0], p[1] + y[1], p[2] + y[2], g[0] + y[0], g[1] + y[1], g[2] + y[2], w), m.add(p[0] - y[0], p[1] - y[1], p[2] - y[2], g[0] - y[0], g[1] - y[1], g[2] - y[2], w));
    } else P === 6 && (ds(Ar, vn(Ar, v, p), 0.475), ai(p, p, Ar), vn(v, v, Ar), m.add(p[0], p[1], p[2], v[0], v[1], v[2], w));
  }
  var F = n ? Me.clone(n.boundingSphere) : void 0, N = m.getLines();
  return S === 0 ? { lines: N } : (E.scale(b, b, 1 / S), F && E.distance(b, F.center) / F.radius < 1 ? { lines: N, boundingSphere: F } : { lines: N });
}
var zx = { includeTypes: z.MultiSelect(V9(lr.Names), z.objectToOptions(lr.Names)), excludeTypes: z.MultiSelect([], z.objectToOptions(lr.Names)), ignoreHydrogens: z.Boolean(!1), aromaticBonds: z.Boolean(!0, { description: "Display aromatic bonds with dashes" }), multipleBonds: z.Select("symmetric", z.arrayToOptions(["off", "symmetric", "offset"])) };
z.getDefaultValues(zx);
var Vx = O(O(O({}, $y), zx), { adjustCylinderLength: z.Boolean(!1, { description: "Shorten cylinders to reduce overlap with spheres. Useful for for transparent bonds. Not working well with aromatic bonds." }) });
z.getDefaultValues(Vx);
var cf, Ux = O(O({}, lk), zx);
function t4(t, e, r) {
  return !lr.is(t, r) || lr.is(e, r);
}
function pk(t, e, r) {
  var n = e.elements, i = e.model.atomicHierarchy.derived.atom.atomicNumber, a = e.bonds, o = a.a, s = a.b, u = a.edgeProps.flags, c = r.ignoreHydrogens, l = r.includeTypes, d = r.excludeTypes, f = lr.fromNames(l), h = lr.fromNames(d), m = lr.isAll(f) && h === 0, p = t.child, v = p == null ? void 0 : p.unitMap.get(e.id);
  if (p && !v) throw new Error("expected childUnit to exist if child exists");
  if (!m || c || p) return function(g) {
    return !!v && !Ke.has(v.elements, n[o[g]]) || c && (U7(i, n[o[g]]) || U7(i, n[s[g]])) || !m && t4(f, h, u[g]);
  };
}
function hk(t, e) {
  var r = t.interUnitBonds.edges, n = e.ignoreHydrogens, i = e.includeTypes, a = e.excludeTypes, o = lr.fromNames(i), s = lr.fromNames(a), u = lr.isAll(o) && s === 0, c = t.child;
  if (!u || n || c) return function(l) {
    if (c) {
      var d = r[l], f = c.unitMap.get(d.unitA);
      if (!f) return !0;
      var h = t.unitMap.get(d.unitA).elements[d.indexA];
      if (!Ke.has(f.elements, h)) return !0;
    }
    if (n) {
      d = r[l];
      var m = t.unitMap.get(d.unitA), p = t.unitMap.get(d.unitB);
      if (V7(m, m.elements[d.indexA]) || V7(p, p.elements[d.indexB])) return !0;
    }
    return !(u || !t4(o, s, r[l].props.flag));
  };
}
function X7(t, e, r) {
  var n = t.objectId, i = t.instanceId, a = t.groupId;
  if (r === n) {
    var o = e.structure, s = e.group.units[i];
    if (Fe.isAtomic(s)) {
      var u = o.target, c = s.bonds.a[a], l = s.bonds.b[a];
      return Dt.Loci(u, [Dt.Location(u, s, c, u, s, l), Dt.Location(u, s, l, u, s, c)]);
    }
  }
  return Dn;
}
function Y7(t, e, r, n) {
  var i = !1;
  if (Dt.isLoci(t)) {
    var a = e.structure, o = e.group;
    if (!tt.areEquivalent(t.structure, a)) return !1;
    var s = o.units[0];
    if (!Fe.isAtomic(s)) return !1;
    for (var u = 2 * s.bonds.edgeCount, c = 0, l = t.bonds; c < l.length; c++) {
      var d = l[c];
      if (d.aUnit === d.bUnit) {
        var f = o.unitIndexMap.get(d.aUnit.id);
        if (f !== void 0) {
          var h = s.bonds.getDirectedEdgeIndex(d.aIndex, d.bIndex);
          h !== -1 && r(Se.ofSingleton(f * u + h)) && (i = !0);
        }
      }
    }
  } else if (Xe.is(t)) {
    if (a = e.structure, o = e.group, !tt.areEquivalent(t.structure, a) || (s = o.units[0], !Fe.isAtomic(s))) return !1;
    for (var m = 2 * s.bonds.edgeCount, p = function(y) {
      var b = o.unitIndexMap.get(y.unit.id);
      if (b !== void 0) {
        var S = s.bonds, _ = S.offset, x = S.b;
        Ge.forEach(y.indices, function(C) {
          for (var A = _[C], w = _[C + 1]; A < w; A++) n && !Ge.has(y.indices, x[A]) || r(Se.ofSingleton(b * m + A)) && (i = !0);
        });
      }
    }, v = 0, g = t.elements; v < g.length; v++)
      p(g[v]);
  }
  return i;
}
function W7(t, e, r) {
  var n = t.objectId, i = t.groupId;
  if (r === n) {
    var a = e.target, o = e.interUnitBonds.edges[i], s = e.unitMap.get(o.unitA), u = e.unitMap.get(o.unitB);
    return Dt.Loci(a, [Dt.Location(a, s, o.indexA, a, u, o.indexB), Dt.Location(a, u, o.indexB, a, s, o.indexA)]);
  }
  return Dn;
}
z.getDefaultValues(Ux), function(t) {
  t.fromGroup = function(e) {
    var r = e.group, n = e.structure, i = r.units[0], a = Fe.isAtomic(i) ? 2 * i.bonds.edgeCount : 0, o = r.units.length, s = Dt.Location(n, void 0, void 0, n, void 0, void 0);
    return gi(a, o, 1, function(u, c) {
      var l = r.units[c];
      return s.aUnit = l, s.bUnit = l, s.aIndex = l.bonds.a[u], s.bIndex = l.bonds.b[u], s;
    });
  }, t.fromStructure = function(e) {
    var r = e.interUnitBonds.edgeCount, n = Dt.Location(e, void 0, void 0, e, void 0, void 0);
    return gi(r, 1, 1, function(i) {
      var a = e.interUnitBonds.edges[i];
      return n.aUnit = e.unitMap.get(a.unitA), n.aIndex = a.indexA, n.bUnit = e.unitMap.get(a.unitB), n.bIndex = a.indexB, n;
    }, !0);
  };
}(cf || (cf = {}));
var E8 = /* @__PURE__ */ new Map();
function j7(t, e, r, n) {
  var i = !1;
  if (Dt.isLoci(t)) {
    if (!tt.areEquivalent(t.structure, e)) return !1;
    for (var a = 0, o = t.bonds; a < o.length; a++) {
      var s = o[a], u = e.interUnitBonds.getBondIndexFromLocation(s);
      u !== -1 && r(Se.ofSingleton(u)) && (i = !0);
    }
  } else if (Xe.is(t)) {
    if (!tt.areEquivalent(t.structure, e) || n && t.elements.length === 1) return !1;
    for (var c = 0, l = t.elements; c < l.length; c++) {
      var d = l[c];
      E8.set(d.unit.id, d.indices);
    }
    for (var f = function(p) {
      var v = p.unit;
      if (!Fe.isAtomic(v)) return "continue";
      e.interUnitBonds.getConnectedUnits(v.id).forEach(function(g) {
        var y = E8.get(g.unitB);
        n && !y || Ge.forEach(p.indices, function(b) {
          g.connectedIndices.includes(b) && g.getEdges(b).forEach(function(S) {
            if (!n || y && Ge.has(y, S.indexB)) {
              var _ = e.interUnitBonds.getEdgeIndex(b, v.id, S.indexB, g.unitB);
              r(Se.ofSingleton(_)) && (i = !0);
            }
          });
        });
      });
    }, h = 0, m = t.elements; h < m.length; h++)
      f(d = m[h]);
    E8.clear();
  }
  return i;
}
var I8 = lr.is;
function mk(t, e, r, n) {
  var i, a = t.elements, o = t.bonds, s = o.edgeCount, u = o.a, c = o.b, l = o.edgeProps, d = o.offset, f = l.order, h = l.flags, m = n.sizeFactor, p = n.sizeAspectRatio, v = n.adjustCylinderLength, g = n.aromaticBonds, y = n.includeTypes, b = n.excludeTypes, S = n.multipleBonds, _ = S === "off", x = S === "symmetric", C = t4(lr.fromNames(y), lr.fromNames(b), 32), A = E(), w = E(), I = t.conformation.invariantPosition, P = at.create(e, t), M = Dt.Location(e, t, void 0, e, t, void 0), T = e.child;
  if (n.includeParent && T) {
    var F = T.unitMap.get(t.id);
    if (!F) throw new Error("expected childUnit to exist");
    i = function(U) {
      var H = a[u[U]], K = a[c[U]];
      return Ke.has(F.elements, H) && !Ke.has(F.elements, K);
    };
  }
  var N = t.rings, R = N.elementRingIndices, L = N.elementAromaticRingIndices, V = g ? t.resonance.delocalizedTriplets : void 0;
  return { linkCount: 2 * s, referencePosition: function(U) {
    var H, K, X = u[U], Y = c[U], Q = V == null ? void 0 : V.getThirdElement(X, Y);
    if (Q !== void 0) return I(a[Q], A);
    X > Y && (X = (H = [Y, X])[0], Y = H[1]), d[X + 1] - d[X] == 1 && (X = (K = [Y, X])[0], Y = K[1]);
    for (var J = L.get(X) || R.get(X), te = 0, W = d[X], j = d[X + 1]; W < j; ++W) {
      var ee = c[W];
      if (ee !== Y && ee !== X) {
        if (!J) return I(a[ee], A);
        var ie = L.get(ee) || R.get(ee);
        if (!ie) continue;
        var ae = D3(J, ie);
        ae > te && (te = ae, I(a[ee], A));
      }
    }
    return te > 0 ? A : null;
  }, position: function(U, H, K) {
    if (I(a[u[K]], U), I(a[c[K]], H), v) {
      var X = function(W) {
        return P.element = a[u[W]], r.size.size(P) * m;
      }(K), Y = function(W) {
        return P.element = a[c[W]], r.size.size(P) * m;
      }(K), Q = Math.min(X, Y) * p, J = Math.sqrt(Math.max(0, X * X - Q * Q)) - 0.05, te = Math.sqrt(Math.max(0, Y * Y - Q * Q)) - 0.05;
      if (J <= 0.01 && te <= 0.01) return;
      E.normalize(w, E.sub(w, H, U)), E.scaleAndAdd(U, U, w, J), E.scaleAndAdd(H, H, w, -te);
    }
  }, style: function(U) {
    var H = f[U], K = h[U];
    if (I8(K, 2) || I8(K, 4)) return 1;
    if (H === 3) return _ ? 0 : x ? 4 : 5;
    if (g) {
      var X = u[U], Y = c[U], Q = L.get(X), J = L.get(Y), te = Q && J ? D3(Q, J) : 0;
      if (I8(K, 16) || te && !C) {
        if (te === 2) return 8;
        if (te === 1 || V != null && V.getThirdElement(X, Y)) return 7;
      }
    }
    return H !== 2 || _ ? 0 : x ? 2 : 3;
  }, radius: function(U) {
    return function(H) {
      return M.aIndex = u[H], M.bIndex = c[H], r.size.size(M) * m;
    }(U) * p;
  }, ignore: pk(e, t, n), stub: i };
}
function uce(t, e, r, n, i, a) {
  if (!Fe.isAtomic(e) || !e.bonds.edgeCount) return to.createEmpty(a);
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(e.id);
  if (o && !s) return to.createEmpty(a);
  var u = dk(0, mk(e, r, n, i), i, a), c = u.cylinders, l = u.boundingSphere;
  if (l) c.setBoundingSphere(l);
  else if (c.cylinderCount > 0) {
    var d = Me.expand(Me(), (s ?? e).boundary.sphere, 1 * i.sizeFactor);
    c.setBoundingSphere(d);
  }
  return c;
}
function cce(t, e, r, n, i, a) {
  if (!Fe.isAtomic(e) || !e.bonds.edgeCount) return Vt.createEmpty(a);
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(e.id);
  if (o && !s) return Vt.createEmpty(a);
  var u = e4(0, mk(e, r, n, i), i, a), c = u.mesh, l = u.boundingSphere;
  if (l) c.setBoundingSphere(l);
  else if (c.triangleCount > 0) {
    var d = Me.expand(Me(), (s ?? e).boundary.sphere, 1 * i.sizeFactor);
    c.setBoundingSphere(d);
  }
  return c;
}
var cy = O(O(O(O({}, Rl), nue), Vx), { sizeFactor: z.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: z.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: z.Boolean(!0), includeParent: z.Boolean(!1) });
function gk(t, e, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return C2(O(O({}, a), { setUpdateState: function(s, u, c, l, d, f, h) {
        a.setUpdateState(s, u, c, l, d, f, h), Co.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: to.Utils }), o);
    }({ defaultProps: z.getDefaultValues(cy), createGeometry: uce, createLocationIterator: cf.fromGroup, getLoci: X7, eachLocation: Y7, 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 || !xo(o.includeTypes, s.includeTypes) || !xo(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.aromaticBonds !== s.aromaticBonds || o.multipleBonds !== s.multipleBonds;
      var f = l.group.units[0], h = d.group.units[0];
      Fe.isAtomic(f) && Fe.isAtomic(h) && (Xo.areEqual(f.bonds, h.bonds) || (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0));
    }, mustRecreate: function(a, o, s) {
      return !o.tryUseImpostor || !s;
    } }, i);
  }(t) : function(i) {
    return Ol({ defaultProps: z.getDefaultValues(cy), createGeometry: cce, createLocationIterator: cf.fromGroup, getLoci: X7, eachLocation: Y7, 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 || !xo(o.includeTypes, s.includeTypes) || !xo(o.excludeTypes, s.excludeTypes) || o.adjustCylinderLength !== s.adjustCylinderLength || o.aromaticBonds !== s.aromaticBonds || o.multipleBonds !== s.multipleBonds;
      var f = l.group.units[0], h = d.group.units[0];
      Fe.isAtomic(f) && Fe.isAtomic(h) && (Xo.areEqual(f.bonds, h.bonds) || (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0));
    }, mustRecreate: function(a, o, s) {
      return o.tryUseImpostor && !!s;
    } }, i);
  }(t);
}
var T8 = new Dt.ElementBondIterator();
function KM(t, e, r, n) {
  for (T8.setElement(e, r, n); T8.hasNext; ) {
    var i = T8.move();
    return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex], t), t;
  }
  return null;
}
var XM = E();
function vk(t, e, r) {
  var n, i = at.create(t), a = Dt.Location(t, void 0, void 0, t, void 0, void 0), o = t.interUnitBonds, s = o.edgeCount, u = o.edges, c = r.sizeFactor, l = r.sizeAspectRatio, d = r.adjustCylinderLength, f = r.aromaticBonds, h = r.multipleBonds, m = h === "off", p = h === "symmetric", v = E(), g = t.child;
  return r.includeParent && g && (n = function(y) {
    var b = u[y], S = g.unitMap.get(b.unitA), _ = g.unitMap.get(b.unitB), x = t.unitMap.get(b.unitA).elements[b.indexA], C = t.unitMap.get(b.unitB).elements[b.indexB];
    return S && Ke.has(S.elements, x) && (!_ || !Ke.has(_.elements, C));
  }), { linkCount: s, referencePosition: function(y) {
    var b, S, _, x, C = u[y];
    if (C.unitA < C.unitB) b = t.unitMap.get(C.unitA), S = t.unitMap.get(C.unitB), _ = C.indexA, x = C.indexB;
    else {
      if (!(C.unitA > C.unitB)) throw new Error("same units in createInterUnitBondCylinderMesh");
      b = t.unitMap.get(C.unitB), S = t.unitMap.get(C.unitA), _ = C.indexB, x = C.indexA;
    }
    return KM(XM, t, b, _) || KM(XM, t, S, x);
  }, position: function(y, b, S) {
    var _ = u[S], x = t.unitMap.get(_.unitA), C = t.unitMap.get(_.unitB);
    if (x.conformation.position(x.elements[_.indexA], y), C.conformation.position(C.elements[_.indexB], b), d) {
      var A = function(T) {
        var F = u[T];
        return i.unit = t.unitMap.get(F.unitA), i.element = i.unit.elements[F.indexA], e.size.size(i) * c;
      }(S), w = function(T) {
        var F = u[T];
        return i.unit = t.unitMap.get(F.unitB), i.element = i.unit.elements[F.indexB], e.size.size(i) * c;
      }(S), I = Math.min(A, w) * l, P = Math.sqrt(Math.max(0, A * A - I * I)) - 0.05, M = Math.sqrt(Math.max(0, w * w - I * I)) - 0.05;
      if (P <= 0.01 && M <= 0.01) return;
      E.normalize(v, E.sub(v, b, y)), E.scaleAndAdd(y, y, v, P), E.scaleAndAdd(b, b, v, -M);
    }
  }, style: function(y) {
    var b = u[y].props.order, S = Ga.create(u[y].props.flag);
    return lr.is(S, 2) || lr.is(S, 4) ? 1 : b === 3 ? m ? 0 : p ? 4 : 5 : f && lr.is(S, 16) ? 7 : b !== 2 || m ? 0 : p ? 2 : 3;
  }, radius: function(y) {
    return function(b) {
      var S = u[b];
      return a.aUnit = t.unitMap.get(S.unitA), a.aIndex = S.indexA, a.bUnit = t.unitMap.get(S.unitB), a.bIndex = S.indexB, e.size.size(a) * c;
    }(y) * l;
  }, ignore: hk(t, r), stub: n };
}
function lce(t, e, r, n, i) {
  if (!e.interUnitBonds.edgeCount) return to.createEmpty(i);
  var a = dk(0, vk(e, r, n), n, i), o = a.cylinders, s = a.boundingSphere;
  if (s) o.setBoundingSphere(s);
  else if (o.cylinderCount > 0) {
    var u = e.child, c = Me.expand(Me(), (u ?? e).boundary.sphere, 1 * n.sizeFactor);
    o.setBoundingSphere(c);
  }
  return o;
}
function dce(t, e, r, n, i) {
  if (!e.interUnitBonds.edgeCount) return Vt.createEmpty(i);
  var a = e4(0, vk(e, r, n), n, i), o = a.mesh, s = a.boundingSphere;
  if (s) o.setBoundingSphere(s);
  else if (o.triangleCount > 0) {
    var u = e.child, c = Me.expand(Me(), (u ?? e).boundary.sphere, 1 * n.sizeFactor);
    o.setBoundingSphere(c);
  }
  return o;
}
var ly = O(O(O(O({}, GL), $se), Vx), { sizeFactor: z.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: z.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: z.Boolean(!0), includeParent: z.Boolean(!1) });
function yk(t, e, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return Jy(O(O({}, a), { setUpdateState: function(s, u, c, l, d, f, h) {
        a.setUpdateState(s, u, c, l, d, f, h), Co.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: to.Utils }), o);
    }({ defaultProps: z.getDefaultValues(ly), createGeometry: lce, createLocationIterator: cf.fromStructure, getLoci: W7, eachLocation: j7, 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 || !xo(o.includeTypes, s.includeTypes) || !xo(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);
  }(t) : function(i) {
    return zL({ defaultProps: z.getDefaultValues(ly), createGeometry: dce, createLocationIterator: cf.fromStructure, getLoci: W7, eachLocation: j7, 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 || !xo(o.includeTypes, s.includeTypes) || !xo(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);
  }(t);
}
var i2, YM = new Float32Array([-1, 1, -1, -1, 1, 1, 1, -1]), z1 = new Uint16Array([0, 1, 2, 1, 3, 2]), M8 = Le.add3, fce = Le.add2, pce = Le.add;
(function(t) {
  t.create = function(e, r, n) {
    e === void 0 && (e = 2048), r === void 0 && (r = 1024), e *= 4, r *= 4;
    var i = Le.create(Float32Array, 3, r, n ? n.centerBuffer.ref.value : e), a = Le.create(Float32Array, 2, r, n ? n.mappingBuffer.ref.value : e), o = Le.create(Uint32Array, 3, r / 2, n ? n.indexBuffer.ref.value : e / 2), s = Le.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : e);
    return { add: function(u, c, l, d) {
      for (var f = i.elementCount, h = 0; h < 4; ++h) M8(i, u, c, l), fce(a, YM[2 * h], YM[2 * h + 1]), pce(s, d);
      M8(o, f + z1[0], f + z1[1], f + z1[2]), M8(o, f + z1[3], f + z1[4], f + z1[5]);
    }, getSpheres: function() {
      var u = Le.compact(i, !0), c = Le.compact(a, !0), l = Le.compact(o, !0), d = Le.compact(s, !0);
      return Gu.create(u, c, l, d, i.elementCount / 4, n);
    } };
  };
})(i2 || (i2 = {}));
var Tl, bk = E.add;
function r4(t, e, r) {
  var n = r.ignoreHydrogens, i = r.traceOnly, a = e.model.atomicHierarchy.derived.atom.atomicNumber, o = Fe.isCoarse(e), s = t.child, u = s == null ? void 0 : s.unitMap.get(e.id);
  if (s && !u) throw new Error("expected childUnit to exist if child exists");
  if (s || n || i) return function(c) {
    return !!u && !Ke.has(u.elements, c) || !o && n && U7(a, c) || i && !BL(e, c);
  };
}
function hce(t, e, r, n, i, a) {
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(e.id);
  if (o && !s) return Vt.createEmpty(a);
  for (var u = i.detail, c = i.sizeFactor, l = e.elements, d = l.length, f = d * BO(u), h = wt.createState(f, f / 2, a), m = E(), p = e.conformation.invariantPosition, v = r4(r, e, i), g = at.create(r, e), y = n.size.size, b = E(), S = 0, _ = 0, x = 0; x < d; x++) if (!v || !v(l[x])) {
    g.element = l[x], p(l[x], m), bk(b, b, m), _ += 1, h.currentGroup = x;
    var C = y(g);
    C > S && (S = C), Yi(h, m, C * c, u);
  }
  var A, w = a ? Me.clone(a.boundingSphere) : void 0, I = wt.getMesh(h);
  return _ === 0 || (E.scale(b, b, 1 / _), A = w && E.distance(b, w.center) / w.radius < 1 ? w : Me.expand(Me(), (s ?? e).boundary.sphere, S * c + 0.05), I.setBoundingSphere(A)), I;
}
function mce(t, e, r, n, i, a) {
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(e.id);
  if (o && !s) return Gu.createEmpty(a);
  for (var u = e.elements, c = u.length, l = i2.create(c, c / 2, a), d = E(), f = e.conformation.invariantPosition, h = r4(r, e, i), m = at.create(r, e), p = n.size.size, v = E(), g = 0, y = 0, b = 0; b < c; b++) if (!(h != null && h(u[b]))) {
    f(u[b], d), l.add(d[0], d[1], d[2], b), bk(v, v, d), y += 1, m.element = u[b];
    var S = p(m);
    S > g && (g = S);
  }
  var _, x = a ? Me.clone(a.boundingSphere) : void 0, C = l.getSpheres();
  return y === 0 || (E.scale(v, v, 1 / y), _ = x && E.distance(v, x.center) / x.radius < 1 ? x : Me.expand(Me(), (s ?? e).boundary.sphere, g * i.sizeFactor + 0.05), C.setBoundingSphere(_)), C;
}
function Gp(t, e, r) {
  var n = !1;
  if (!Xe.is(t)) return !1;
  var i = e.structure, a = e.group;
  if (!tt.areEquivalent(t.structure, i)) return !1;
  for (var o = a.elements.length, s = a.unitIndexMap, u = 0, c = t.elements; u < c.length; u++) {
    var l = c[u], d = s.get(l.unit.id);
    if (d !== void 0) {
      var f = d * o;
      if (Se.is(l.indices)) {
        var h = f + Se.start(l.indices), m = f + Se.end(l.indices);
        r(Se.ofBounds(h, m)) && (n = !0);
      } else for (var p = 0, v = l.indices.length; p < v; p++) {
        h = l.indices[p];
        for (var g = p + 1; g < v && l.indices[g] === h; ) g++;
        p = g - 1, m = l.indices[p], n = r(Se.ofRange(f + h, f + m)) || n;
      }
    }
  }
  return n;
}
function zp(t, e, r) {
  var n = t.objectId, i = t.instanceId, a = t.groupId;
  if (r === n) {
    var o = e.structure, s = e.group.units[i], u = Ge.ofSingleton(a);
    return Xe(o.target, [{ unit: s, indices: u }]);
  }
  return Dn;
}
function gce(t, e, r) {
  var n = !1;
  if (!Xe.is(t) || !tt.areEquivalent(t.structure, e)) return !1;
  for (var i = e.serialMapping.cumulativeUnitElementCount, a = 0, o = t.elements; a < o.length; a++) {
    var s = o[a], u = e.unitIndexMap.get(s.unit.id);
    if (u !== void 0) if (Se.is(s.indices)) {
      var c = i[u] + Se.start(s.indices), l = i[u] + Se.end(s.indices);
      r(Se.ofBounds(c, l)) && (n = !0);
    } else for (var d = 0, f = s.indices.length; d < f; d++) {
      var h = i[u] + s.indices[d];
      r(Se.ofSingleton(h)) && (n = !0);
    }
  }
  return n;
}
function vce(t, e, r) {
  var n = t.objectId, i = t.groupId;
  if (r === n) {
    var a = e.serialMapping, o = a.unitIndices, s = a.cumulativeUnitElementCount, u = o[i], c = e.units[u], l = i - s[u];
    return Xe(e, [{ unit: c, indices: Ge.ofSingleton(l) }]);
  }
  return Dn;
}
(function(t) {
  t.fromGroup = function(e) {
    var r = e.group, n = e.structure, i = r.elements.length, a = r.units.length, o = at.create(n);
    return gi(i, a, 1, function(s, u) {
      var c = r.units[u];
      return o.unit = c, o.element = c.elements[s], o;
    });
  }, t.fromStructure = function(e) {
    var r = e.units, n = e.elementCount, i = e.serialMapping, a = i.unitIndices, o = i.elementIndices, s = at.create(e);
    return gi(n, 1, 1, function(u) {
      return s.unit = r[a[u]], s.element = o[u], s;
    }, !0);
  };
})(Tl || (Tl = {}));
var a2 = O(O(O({}, Rl), rue), { sizeFactor: z.Numeric(1, { min: 0, max: 10, step: 0.1 }), detail: z.Numeric(0, { min: 0, max: 3, step: 1 }, ft.CustomQualityParamInfo), ignoreHydrogens: z.Boolean(!1), traceOnly: z.Boolean(!1), tryUseImpostor: z.Boolean(!0) });
function Hx(t, e, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return C2(O(O({}, a), { setUpdateState: function(s, u, c, l, d, f, h) {
        a.setUpdateState(s, u, c, l, d, f, h), Co.areEqual(l.size, d.size) || (s.updateSize = !0);
      }, geometryUtils: Gu.Utils }), o);
    }({ defaultProps: z.getDefaultValues(a2), createGeometry: mce, createLocationIterator: Tl.fromGroup, getLoci: zp, eachLocation: Gp, 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);
  }(t) : function(i) {
    return Ol({ defaultProps: z.getDefaultValues(a2), createGeometry: hce, createLocationIterator: Tl.fromGroup, getLoci: zp, eachLocation: Gp, 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);
  }(t);
}
var yce = O(O({}, tue), { sizeFactor: z.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), background: z.Boolean(!1), backgroundMargin: z.Numeric(0, { min: 0, max: 1, step: 0.01 }), backgroundColor: z.Color(Yt.black), backgroundOpacity: z.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), borderWidth: z.Numeric(0.25, { min: 0, max: 0.5, step: 0.01 }), level: z.Select("element", [["element", "Element"]], { isEssential: !0 }), chainScale: z.Numeric(10, { min: 0, max: 20, step: 0.1 }), residueScale: z.Numeric(1, { min: 0, max: 20, step: 0.1 }), elementScale: z.Numeric(2, { min: 0, max: 20, step: 0.1 }), attachment: z.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: z.Boolean(!0), tetherLength: z.Numeric(0.2, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: z.Numeric(0, { min: 0, max: 1, step: 0.01 }) });
function qx(t) {
  return function(e, r) {
    return Jy(O(O({}, e), { setUpdateState: function(n, i, a, o, s, u, c) {
      e.setUpdateState(n, i, a, o, s, u, c), Co.areEqual(o.size, s.size) || (n.updateSize = !0), i.background !== a.background && (n.createGeometry = !0), i.backgroundMargin !== a.backgroundMargin && (n.createGeometry = !0), i.tether !== a.tether && (n.createGeometry = !0), i.tetherLength !== a.tetherLength && (n.createGeometry = !0), i.tetherBaseWidth !== a.tetherBaseWidth && (n.createGeometry = !0), i.attachment !== a.attachment && (n.createGeometry = !0), i.fontFamily !== a.fontFamily && (n.createGeometry = !0), i.fontQuality !== a.fontQuality && (n.createGeometry = !0), i.fontStyle !== a.fontStyle && (n.createGeometry = !0), i.fontVariant !== a.fontVariant && (n.createGeometry = !0), i.fontWeight !== a.fontWeight && (n.createGeometry = !0);
    }, geometryUtils: bs.Utils }), r);
  }({ defaultProps: z.getDefaultValues(yce), createGeometry: bce, createLocationIterator: Tl.fromStructure, getLoci: vce, eachLocation: gce, setUpdateState: function(e, r, n) {
    e.createGeometry = r.level !== n.level || r.level === "element" && r.elementScale !== n.elementScale;
  } }, t);
}
function bce(t, e, r, n, i) {
  return r.size.size = function() {
    return 1;
  }, r.color.color = function(a) {
    if (at.is(a) && Fe.isAtomic(a.unit)) {
      var o = (0, Qe.atom.pdbx_formal_charge)(a);
      if (o > 0) return Yt.red;
      if (o < 0) return Yt.blue;
    }
    return Yt.white;
  }, n.sizeFactor = 0.2, function(a, o, s, u, c) {
    for (var l = at.create(o), d = o.units, f = o.serialMapping, h = Qe.atom.pdbx_formal_charge, m = f.cumulativeUnitElementCount, p = o.elementCount, v = uf.create(u, p, p / 2, c), g = !1, y = 0, b = d.length; y < b; ++y) {
      var S = d[y], _ = S.conformation.position, x = S.elements;
      l.unit = S;
      for (var C = m[y], A = 0, w = x.length; A < w; A++) {
        l.element = x[A];
        var I = h(l);
        if (I !== 0) {
          _(l.element, Nv);
          var P = "".concat(I > 0 ? "+" : "").concat(I);
          v.add(P, Nv[0], Nv[1], Nv[2], 0, 5, C + A), g = !0;
        }
      }
      if (!g) {
        var M = o.boundary.sphere.center;
        v.add("", M[0], M[1], M[2], 0, 0, C + 1);
      }
    }
    return v.getText();
  }(0, e, 0, n, i);
}
var Nv = E(), _k = { "element-sphere": function(t, e) {
  return $a("Element sphere", t, e, Hx);
}, "intra-bond": function(t, e) {
  return $a("Intra-unit bond cylinder", t, e, gk);
}, "inter-bond": function(t, e) {
  return P0("Inter-unit bond cylinder", t, e, yk);
}, "charge-text": function(t, e) {
  return P0("Charge Text", t, e, qx);
} }, WM = O(O(O(O(O({}, a2), { traceOnly: z.Boolean(!1, { isHidden: !0 }) }), cy), ly), { includeParent: z.Boolean(!1), unitKinds: S2(["atomic"]), sizeFactor: z.Numeric(0.2, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: z.Numeric(0.5, { min: 0.01, max: 3, step: 0.01 }), visuals: z.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], z.objectToOptions(_k)), bumpFrequency: z.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory) }), vo = { name: "ball-and-stick", label: "Ball & Stick", description: "Displays atoms as spheres and bonds as cylinders.", factory: function(t, e) {
  return sr.createMulti("Ball & Stick", t, e, xs, _k);
}, getParams: function(t, e) {
  return z.clone(WM);
}, defaultValues: z.getDefaultValues(WM), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(t) {
  return t.elementCount > 0;
}, getData: function(t, e) {
  return e.includeParent ? t.asParent() : t;
}, mustRecreate: function(t, e) {
  return t.includeParent !== e.includeParent;
} }, xk = { create: function(t, e, r) {
  var n;
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = vo.factory(e, vo.getParams)).setTheme(r ?? { color: e.colorThemeRegistry.create("element-symbol", { structure: t }), size: e.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, i.createOrUpdate(O(O({}, vo.defaultValues), { aromaticBonds: ((n = t.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: e.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }), t).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return t.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: e }), size: r.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, t.createOrUpdate({ visuals: r.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }, e).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} };
function Fn(t, e, r) {
  r === void 0 && (r = {});
  var n, i, a, o, s = 0, u = new Si(), c = sr.createState(), l = Nl(), d = [], f = -1, h = su.createEmpty(), m = z.getDefaultValues(e.Params);
  r.modifyState && sr.updateState(c, r.modifyState(c));
  var p = Cc.create();
  function v(g, y) {
    return qo(g) || er.isLoci(g) && g.shape === i ? y(Se.ofBounds(0, i.groupCount * i.transforms.length)) : function(b, S, _) {
      if (!bo.isLoci(b) || b.shape !== S) return !1;
      for (var x = !1, C = S.groupCount, A = b.groups, w = 0, I = A; w < I.length; w++) {
        var P = I[w], M = P.ids, T = P.instance;
        if (Se.is(M)) {
          var F = T * C + Se.start(M), N = T * C + Se.end(M);
          _(Se.ofBounds(F, N)) && (x = !0);
        } else for (var R = 0, L = M.length; R < L; R++) {
          var V = T * C + M[R];
          _(Se.ofSingleton(V)) && (x = !0);
        }
      }
      return x;
    }(g, i, y);
  }
  return { label: "Shape geometry", get groupCount() {
    return a ? a.count : 0;
  }, get props() {
    return m;
  }, get params() {
  }, get state() {
    return c;
  }, get theme() {
    return h;
  }, renderObjects: d, get geometryVersion() {
    return f;
  }, updated: u, createOrUpdate: function(g, y) {
    var b = this;
    return g === void 0 && (g = {}), r.modifyProps && (g = r.modifyProps(g)), tr.create("ShapeRepresentation.create", function(S) {
      return _e(b, 0, void 0, function() {
        var _, x, C, A, w, I, P, M;
        return ye(this, function(T) {
          switch (T.label) {
            case 0:
              return _ = Object.assign(m, g), y ? [4, t(S, y, _, i)] : [3, 2];
            case 1:
              return C = T.sent(), [3, 3];
            case 2:
              C = void 0, T.label = 3;
            case 3:
              if (function(F, N) {
                Cc.reset(p), (N || i) && (N && !i ? p.createNew = !0 : N && i && N.id === i.id || (N && i && N.id !== i.id ? (p.updateTransform = !0, p.createGeometry = !0) : N && console.warn("unexpected state")), p.updateTransform && (p.updateColor = !0, p.updateSize = !0), p.createGeometry && (p.updateColor = !0, p.updateSize = !0));
              }(0, x = C), x && (i = x, Object.assign(h, er.getTheme(i))), p.createNew) d.length = 0, a = er.groupIterator(i), A = er.createTransform(i.transforms), w = e.createValues(i.geometry, A, a, h, _), I = e.createRenderableState(_), r.modifyState && Object.assign(I, r.modifyState(I)), sr.updateState(c, I), (n = eh(i.geometry.kind, w, I, l)) && d.push(n), o = e.createPositionIterator(i.geometry, n.values);
              else {
                if (!n) throw new Error("expected renderObject to be available");
                p.updateTransform && (er.createTransform(i.transforms, n.values), a = er.groupIterator(i), P = a.instanceCount, M = a.groupCount, ou(P * M, n.values)), p.createGeometry && (G.updateIfChanged(n.values.drawCount, Ia.getDrawCount(i.geometry)), G.updateIfChanged(n.values.uVertexCount, Ia.getVertexCount(i.geometry))), (p.updateTransform || p.createGeometry) && (e.updateBoundingSphere(n.values, i.geometry), o = e.createPositionIterator(i.geometry, n.values)), p.updateColor && vs(a, o, h.color, n.values), p.updateSize && "uSize" in n.values && Bl(a, h.size, n.values), e.updateValues(n.values, _), e.updateRenderableState(n.state, _);
              }
              return m = _, (p.createGeometry || p.createNew) && (f += 1), u.next(s++), [2];
          }
        });
      });
    });
  }, getLoci: function(g) {
    if (g === void 0) return er.Loci(i);
    var y = g.objectId, b = g.groupId, S = g.instanceId;
    return n && n.id === y ? bo.Loci(i, [{ ids: Ge.ofSingleton(b), instance: S }]) : Dn;
  }, mark: function(g, y) {
    if (!Lr.is(c.markerActions, y)) return !1;
    if (bo.isLoci(g) || er.isLoci(g)) {
      if (g.shape !== i) return !1;
    } else if (!qo(g)) return !1;
    return nr.mark(n, g, y, v);
  }, setState: function(g) {
    r.modifyState && (g = r.modifyState(g)), n && (g.visible !== void 0 && nr.setVisibility(n, g.visible), g.alphaFactor !== void 0 && nr.setAlphaFactor(n, g.alphaFactor), g.pickable !== void 0 && nr.setPickable(n, g.pickable), g.colorOnly !== void 0 && nr.setColorOnly(n, g.colorOnly), g.overpaint !== void 0 && nr.setOverpaint(n, g.overpaint, v, !0), g.transparency !== void 0 && nr.setTransparency(n, g.transparency, v, !0), g.substance !== void 0 && nr.setSubstance(n, g.substance, v, !0), g.transform !== void 0 && nr.setTransform(n, g.transform)), sr.updateState(c, g);
  }, setTheme: function(g) {
    Pr && console.warn("The `ShapeRepresentation` theme is fixed to `ShapeGroupColorTheme` and `ShapeGroupSizeTheme`. Colors are taken from `Shape.getColor` and sizes from `Shape.getSize`");
  }, destroy: function() {
    d.length = 0, n && (n.state.disposed = !0, n = void 0);
  } };
}
var rh = { granularity: "element", condensed: !1, reverse: !1, countsOnly: !1, hidePrefix: !1, htmlStyling: !0 };
function Sk(t, e) {
  switch (e === void 0 && (e = {}), t.kind) {
    case "structure-loci":
      return t.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 = O(O({}, rh), l), f = function(h, m, p, v, g) {
          m === void 0 && (m = !1), p === void 0 && (p = !1), v === void 0 && (v = !1), g === void 0 && (g = !1);
          var y = h.structureCount, b = h.chainCount, S = h.residueCount, _ = h.conformationCount, x = h.elementCount;
          if (m || x !== 1 || S !== 0 || b !== 0) {
            if (m || x !== 0 || S !== 1 || b !== 0) {
              if (m || x !== 0 || S !== 0 || b !== 1) {
                if (m)
                  return C = [], y > 0 && C.push($1(y, "Structure")), b > 0 && C.push($1(b, "Chain")), S > 0 && C.push($1(S, "Residue")), _ > 0 && C.push($1(_, "Conformation")), x > 0 && C.push($1(x, "Element")), C.join("<small> + </small>");
                var C = [];
                return y > 0 && C.push(y === 1 ? il(h.firstStructureLoc, { hidePrefix: p, condensed: v, granularity: "structure", reverse: g }, !0) : jh(y, h.firstStructureLoc, "structure", p, g, v)), b > 0 && (C.push(b === 1 ? il(h.firstChainLoc, { condensed: v, granularity: "chain", hidePrefix: p, reverse: g }, !0) : jh(b, h.firstChainLoc, "chain", p, g, v)), p = !0), S > 0 && (C.push(S === 1 ? il(h.firstResidueLoc, { condensed: v, granularity: "residue", hidePrefix: p, reverse: g }, !0) : jh(S, h.firstResidueLoc, "residue", p, g, v)), p = !0), _ > 0 && (C.push(_ === 1 ? il(h.firstConformationLoc, { condensed: v, granularity: "conformation", hidePrefix: p, reverse: g }, !0) : jh(_, h.firstConformationLoc, "conformation", p, g, v)), p = !0), x > 0 && C.push(x === 1 ? il(h.firstElementLoc, { condensed: v, granularity: "element", hidePrefix: p, reverse: g }, !0) : jh(x, h.firstElementLoc, "element", p, g, v)), C.join("<small> + </small>");
              }
              var A = h.firstChainLoc.unit, w = Fe.isAtomic(A) && function(I) {
                var P = I.elements, M = I.model, T = M.atomicHierarchy, F = T.chainAtomSegments, N = T.residueAtomSegments, R = F.offsets[F.index[P[0]]], L = F.offsets[F.index[P[P.length - 1]] + 1] - 1;
                return N.index[L] - N.index[R] + 1;
              }(A) === 1 || Fe.Traits.is(A.traits, 1) ? "residue" : "chain";
              return il(h.firstChainLoc, { hidePrefix: p, condensed: v, granularity: w, reverse: g }, !0);
            }
            return il(h.firstResidueLoc, { hidePrefix: p, condensed: v, granularity: "residue", reverse: g }, !0);
          }
          return il(h.firstElementLoc, { hidePrefix: p, condensed: v, granularity: "element", reverse: g }, !0);
        }(c, d.countsOnly, d.hidePrefix, d.condensed, d.reverse);
        return d.htmlStyling ? f : O9(f);
      }(D0.ofLoci(t), e);
    case "bond-loci":
      var r = t.bonds[0];
      return r ? Ck(r) : "";
    case "shape-loci":
      return t.shape.name;
    case "group-loci":
      var n = t.groups[0];
      return n ? t.shape.getLabel(Ge.start(n.ids), n.instance) : "";
    case "every-loci":
      return "Everything";
    case "empty-loci":
      return "Nothing";
    case "data-loci":
      return t.getLabel();
    case "volume-loci":
      return t.volume.label || "Volume";
    case "isosurface-loci":
      return ["".concat(t.volume.label || "Volume"), "Isosurface at ".concat(or.IsoValue.toString(t.isoValue))].join(" | ");
    case "cell-loci":
      var i = Ge.size(t.indices), a = Ge.start(t.indices), o = or.IsoValue.absolute(t.volume.grid.cells.data[a]), s = or.IsoValue.toRelative(o, t.volume.grid.stats), u = ["".concat(t.volume.label || "Volume"), "".concat(i === 1 ? "Cell #".concat(a) : "".concat(i, " Cells"))];
      return i === 1 && u.push("".concat(or.IsoValue.toString(o), " (").concat(or.IsoValue.toString(s), ")")), u.join(" | ");
  }
}
function $1(t, e) {
  return t === 1 ? "1 ".concat(e) : "".concat(t, " ").concat(e, "s");
}
function jh(t, e, r, n, i, a) {
  return "".concat(il(e, { granularity: r, hidePrefix: n, reverse: i, condensed: a }), " <small>[+ ").concat($1(t - 1, "other ".concat(R9(r))), "]</small>");
}
function Ck(t, e) {
  return e === void 0 && (e = {}), n4({ loci: [Xe(t.aStructure, [{ unit: t.aUnit, indices: Ge.ofSingleton(t.aIndex) }]), Xe(t.bStructure, [{ unit: t.bUnit, indices: Ge.ofSingleton(t.bIndex) }])] }, e);
}
function n4(t, e) {
  e === void 0 && (e = {});
  var r = O(O({}, rh), e), n = function(i, a) {
    for (var o = a.granularity, s = a.hidePrefix, u = a.reverse, c = a.condensed, l = !0, d = 0, f = i.loci; d < f.length; d++) {
      var h = f[d];
      if (!Xe.is(h) || Xe.size(h) !== 1) {
        l = !1;
        break;
      }
    }
    if (l) {
      var m = i.loci.map(function(C) {
        var A = C.elements[0], w = A.unit, I = A.indices;
        return at.create(C.structure, w, w.elements[Ge.start(I)]);
      }), p = m.map(function(C) {
        return Ak(C, o, s, u || c);
      });
      if (c) return p.map(function(C) {
        return C[0].replace(/\[.*\]/g, "").trim();
      }).filter(function(C) {
        return !!C;
      }).join(" — ");
      for (var v = 0, g = 0, y = Math.min.apply(Math, p.map(function(C) {
        return C.length;
      })) - 1; g < y; ++g) {
        for (var b = !0, S = 1, _ = p.length; S < _; ++S) if (p[0][g] !== p[S][g]) {
          b = !1;
          break;
        }
        if (!b) break;
        v += 1;
      }
      if (v > 0) {
        var x = [p[0].join(" | ")];
        for (S = 1, _ = p.length; S < _; ++S) x.push(p[S].slice(v).filter(function(C) {
          return !!C;
        }).join(" | "));
        return x.join(" — ");
      }
      return p.map(function(C) {
        return C.filter(function(A) {
          return !!A;
        }).join(" | ");
      }).filter(function(C) {
        return !!C;
      }).join("</br>");
    }
    return p = i.loci.map(function(C) {
      return Sk(C, a);
    }), p.filter(function(C) {
      return !!C;
    }).join(c ? " — " : "</br>");
  }(t, r);
  return r.htmlStyling ? n : O9(n);
}
function il(t, e, r) {
  var n, i;
  e === void 0 && (e = {});
  var a = O(O({}, rh), e), o = Ak(t, a.granularity, a.hidePrefix, a.reverse || a.condensed), s = (a.condensed ? (i = (n = o[0]) === null || n === void 0 ? void 0 : n.replace(/\[.*\]/g, "").trim()) !== null && i !== void 0 ? i : "" : o.filter(function(u) {
    return !!u;
  }).join(" | ")) + (r ? function(u) {
    if (u >= 90) return "<div><small>Plddt ".concat(u, " (Very high)</small></div>");
    if (u < 90 && u >= 70) return "<div><small>Plddt ".concat(u, " (Confident)</small></div>");
    if (u < 70 && u >= 50) return "<div><small>Plddt ".concat(u, " (Low)</small></div>");
    if (u < 50) return "<div><small>Plddt ".concat(u, " (Very low)</small></div>");
  }(Qe.atom.B_iso_or_equiv(t)) : "");
  return a.htmlStyling ? s : O9(s);
}
function Ak(t, e, r, n) {
  e === void 0 && (e = "element"), r === void 0 && (r = !1), n === void 0 && (n = !1);
  var i = [];
  if (!r) {
    var a = t.unit.model.entry;
    a.length > 30 && (a = a.substr(0, 27) + "…"), i.push("<small>".concat(a, "</small>")), e !== "structure" && (i.push("<small>Model ".concat(t.unit.model.modelNum, "</small>")), i.push("<small>Instance ".concat(t.unit.conformation.operator.name, "</small>")));
  }
  return Fe.isAtomic(t.unit) ? i.push.apply(i, function(o, s, u) {
    u === void 0 && (u = !1);
    var c = at.residueIndex(o), l = Qe.chain.label_asym_id(o), d = Qe.chain.auth_asym_id(o), f = o.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(c) === 0, h = Qe.residue.label_seq_id(o), m = Qe.residue.auth_seq_id(o), p = Qe.residue.pdbx_PDB_ins_code(o), v = Qe.atom.label_comp_id(o), g = Qe.atom.label_atom_id(o), y = Qe.atom.label_alt_id(o), b = Qe.atom.occupancy(o), S = Qe.atom.id(o), _ = Qe.residue.microheterogeneityCompIds(o), x = s === "residue" && _.length > 1 ? "(".concat(_.join("|"), ")") : v, C = [];
    switch (s) {
      case "element":
        C.push("<b>".concat(g, " ").concat(S, "</b>").concat(y ? "%".concat(y) : ""));
      case "conformation":
        s === "conformation" && y && C.push("<small>Conformation</small> <b>".concat(y, "</b>"));
      case "residue":
        var A = h === m && f ? h : m;
        C.push("<b>".concat(x, " ").concat(A, "</b>").concat(A !== h ? " <small>[auth</small> <b>".concat(h, "</b><small>]</small>") : "", "<b>").concat(p || "", "</b>"));
      case "chain":
        l === d ? C.push("<b>".concat(l, "</b>")) : s === "chain" && Fe.Traits.is(o.unit.traits, 1) ? C.push("<small>[auth</small> <b>".concat(d, "</b><small>]</small>")) : C.push("<b>".concat(l, "</b> <small>[auth</small> <b>").concat(d, "</b><small>]</small>"));
    }
    return C.length > 0 && b !== 1 && !u && (C[0] = "".concat(C[0], " <small>[occupancy</small> <b>").concat(Math.round(100 * b) / 100, "</b><small>]</small>")), C.reverse();
  }(t, e, n)) : Fe.isCoarse(t.unit) ? i.push.apply(i, function(o, s) {
    var u = Qe.coarse.asym_id(o), c = Qe.coarse.seq_id_begin(o), l = Qe.coarse.seq_id_end(o), d = [];
    switch (s) {
      case "element":
      case "conformation":
      case "residue":
        if (c === l) {
          var f = Qe.coarse.entityKey(o), h = o.unit.model.sequence.byEntityKey[f].sequence.compId.value(c - 1);
          d.push("<b>".concat(h, " ").concat(c, "</b>"));
        } else d.push("<b>".concat(c, "-").concat(l, "</b>"));
      case "chain":
        d.push("<b>".concat(u, "</b>"));
    }
    return d.reverse();
  }(t, e)) : i.push("Unknown"), n ? i.reverse() : i;
}
function o2(t, e) {
  e === void 0 && (e = {});
  var r = O(O(O({}, rh), { measureOnly: !1, unitLabel: "Å" }), e), n = t.loci.map(function(u) {
    return Qr.getCenter(u);
  }), i = n[0], a = n[1], o = "".concat(E.distance(i, a).toFixed(2), " ").concat(r.unitLabel);
  if (r.measureOnly) return o;
  var s = n4(t, r);
  return r.condensed ? "".concat(o, " | ").concat(s) : "Distance ".concat(o, "</br>").concat(s);
}
function Kx(t, e) {
  e === void 0 && (e = {});
  var r = O(O(O({}, rh), { measureOnly: !1 }), e), n = t.loci.map(function(d) {
    return Qr.getCenter(d);
  }), i = n[0], a = n[1], o = n[2], s = E.sub(E(), i, a), u = E.sub(E(), o, a), c = "".concat(Ua(E.angle(s, u)).toFixed(2), "°");
  if (r.measureOnly) return c;
  var l = n4(t, r);
  return r.condensed ? "".concat(c, " | ").concat(l) : "Angle ".concat(c, "</br>").concat(l);
}
function Xx(t, e) {
  e === void 0 && (e = {});
  var r = O(O(O({}, rh), { measureOnly: !1 }), e), n = t.loci.map(function(l) {
    return Qr.getCenter(l);
  }), i = n[0], a = n[1], o = n[2], s = n[3], u = "".concat(Ua(E.dihedralAngle(i, a, o, s)).toFixed(2), "°");
  if (r.measureOnly) return u;
  var c = n4(t, r);
  return r.condensed ? "".concat(u, " | ").concat(c) : "Dihedral ".concat(u, "</br>").concat(c);
}
var _ce = { customText: z.Text("", { label: "Text", description: "Override the label with custom value.", isEssential: !0 }), textColor: z.Color(Yt.black, { isEssential: !0 }), textSize: z.Numeric(0.5, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }, i4 = O(O(O({}, bs.Params), _ce), { borderWidth: z.Numeric(0.2, { min: 0, max: 0.5, step: 0.01 }) }), xce = O(O({}, i4), { offsetZ: z.Numeric(2, { min: 0, max: 10, step: 0.1 }), textSize: z.Numeric(0.7, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }), wk = { text: function(t, e) {
  return Fn(Ace, bs.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !0 });
  } });
} }, Sce = O(O({}, xce), { scaleByRadius: z.Boolean(!1), visuals: z.MultiSelect(["text"], z.objectToOptions(wk)), textColor: z.Color(qe.fromRgb(241, 160, 119), { isEssential: !0 }) }), Cce = Me();
function P8(t, e) {
  return e === void 0 && (e = !1), t.label || Sk(t.loci, { hidePrefix: !0, htmlStyling: !1, condensed: e }).split("Plddt")[0];
}
function Ace(t, e, r, n) {
  var i = function(u, c, l) {
    for (var d = uf.create(c, 128, 64, l), f = c.customText.trim(), h = 0, m = u.infos.length; h < m; ++h) {
      var p = u.infos[h], v = Qr.getBoundingSphere(p.loci, Cce);
      if (v) {
        var g = v.center, y = v.radius, b = f || P8(p, !0);
        d.add(b, g[0], g[1], g[2], c.scaleByRadius ? y / 0.9 : 0, c.scaleByRadius ? Math.max(1, y) : 1, h);
      }
    }
    return d.getText();
  }(e, r, n && n.geometry), a = function(u) {
    return u.infos.length === 1 ? P8(u.infos[0]) : "".concat(u.infos.length, " Labels");
  }(e), o = r.customText.trim(), s = o ? function(u) {
    return o;
  } : function(u) {
    return P8(e.infos[u]);
  };
  return er.create(a, e, i, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, s);
}
var wce = { create: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = sr.createMulti("Label", o, s, sr.StateBuilder, wk);
            return u.setState({ pickable: !0, markerActions: Lr.All }), u;
          }(e, function() {
            return Sce;
          }), [4, i.createOrUpdate(r ?? {}, { infos: t[0].loci ? t : t.map(function(o) {
            return { loci: o };
          }) }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n && t.setTheme(n), [4, t.createOrUpdate(r ?? {}, { infos: e.map(function(a) {
            return { loci: a };
          }) }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Dk = { unitLabel: z.Text("Å", { isEssential: !0 }) }, Dce = O(O(O({}, Rr.Params), Dk), { lineSizeAttenuation: z.Boolean(!0), linesColor: z.Color(Yt.lightgreen, { isEssential: !0 }), linesSize: z.Numeric(0.075, { min: 0.01, max: 5, step: 0.01 }), dashLength: z.Numeric(0.2, { min: 0.01, max: 0.2, step: 0.01 }) }), Ece = O(O({}, i4), Dk), Ek = { lines: function(t, e) {
  return Fn(Tce, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !0, markerActions: Lr.All });
  } });
}, text: function(t, e) {
  return Fn(Mce, bs.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !1, markerActions: Lr.All });
  } });
} }, Ice = O(O(O({}, Dce), Ece), { visuals: z.MultiSelect(["lines", "text"], z.objectToOptions(Ek)) });
function Ik(t, e) {
  var r = e.sphereA, n = e.sphereB, i = e.center, a = t.loci, o = a[0], s = a[1];
  return Qr.getBoundingSphere(o, r), Qr.getBoundingSphere(s, n), E.add(i, r.center, n.center), E.scale(i, i, 0.5), e.distance = E.distance(r.center, n.center), e;
}
var Nd = { sphereA: Me(), sphereB: Me(), center: E(), distance: 0 };
function Tk(t, e) {
  return t.pairs.length === 1 ? "Distance ".concat(o2(t.pairs[0], { unitLabel: e, measureOnly: !0 })) : "".concat(t.pairs.length, " Distances");
}
function Tce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) Ik(o.pairs[l], Nd), c.addFixedLengthDashes(Nd.sphereA.center, Nd.sphereB.center, s.dashLength, l);
    return c.getLines();
  }(e, r, n && n.geometry), a = Tk(e, r.unitLabel);
  return er.create(a, e, i, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function(o) {
    return o2(e.pairs[o], r);
  });
}
function Mce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = uf.create(s, 128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) {
      Ik(o.pairs[l], Nd);
      var f = Nd.center, h = Nd.distance, m = Nd.sphereA, p = Nd.sphereB, v = s.customText || "".concat(h.toFixed(2), " ").concat(s.unitLabel), g = Math.max(2, m.radius, p.radius) / 2;
      c.add(v, f[0], f[1], f[2], 1, g, l);
    }
    return c.getText();
  }(e, r, n && n.geometry), a = Tk(e, r.unitLabel);
  return er.create(a, e, i, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return o2(e.pairs[o], r);
  });
}
var Pce = { create: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = sr.createMulti("Distance", o, s, sr.StateBuilder, Ek);
            return u.setState({ pickable: !0, markerActions: Lr.All }), u;
          }(e, function() {
            return Ice;
          }), [4, i.createOrUpdate(r ?? {}, { pairs: [{ loci: t.slice(-2) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n && t.setTheme(n), [4, t.createOrUpdate(r ?? {}, { pairs: [{ loci: e }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Bce = { radius: 1, segments: 36, thetaStart: 0, thetaLength: 2 * Math.PI };
function Yx(t) {
  var e = O(O({}, Bce), t), r = e.radius, n = e.segments, i = e.thetaStart, a = e.thetaLength, o = a === 2 * Math.PI, s = o ? n + 1 : n + 2, u = new Float32Array(3 * s), c = new Float32Array(3 * s), l = new Uint32Array(3 * n);
  u[0] = 0, u[1] = 0, u[2] = 0, c[0] = 0, c[1] = 1, c[2] = 0;
  for (var d = 0, f = 3; d < n; ++d, f += 3) {
    var h = i + d / n * a;
    u[f] = r * Math.sin(h), u[f + 1] = 0, u[f + 2] = r * Math.cos(h), c[f] = 0, c[f + 1] = 1, c[f + 2] = 0;
  }
  for (d = 1, f = 0; d < n; ++d, f += 3) l[f] = d, l[f + 1] = d + 1, l[f + 2] = 0;
  if (o)
    l[m = 3 * (n - 1)] = n, l[m + 1] = 1, l[m + 2] = 0;
  else {
    var m;
    h = i + a, u[f = 3 * (n + 1)] = r * Math.sin(h), u[f + 1] = 0, u[f + 2] = r * Math.cos(h), c[f] = 0, c[f + 1] = 1, c[f + 2] = 0, l[m = 3 * (n - 1)] = n, l[m + 1] = n + 1, l[m + 2] = 0;
  }
  return { vertices: u, normals: c, indices: l };
}
var Mk = { color: z.Color(Yt.lightgreen), arcScale: z.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 }) }, Pk = O(O(O({}, Rr.Params), Mk), { lineSizeAttenuation: z.Boolean(!0), linesSize: z.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: z.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), Fce = O({}, Pk), Nce = O({}, Pk), Rce = O(O(O({}, Vt.Params), Mk), { ignoreLight: z.Boolean(!0), sectorOpacity: z.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), Bk = { vectors: function(t, e) {
  return Fn(Lce, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !1 });
  } });
}, arc: function(t, e) {
  return Fn(kce, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !1 });
  } });
}, sector: function(t, e) {
  return Fn(Gce, Vt.Utils, { modifyProps: function(r) {
    return O(O({}, r), { alpha: r.sectorOpacity });
  }, modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.Highlighting });
  } });
}, text: function(t, e) {
  return Fn(zce, bs.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: _t.None });
  } });
} }, Oce = O(O(O(O(O({}, Fce), Nce), Rce), i4), { visuals: z.MultiSelect(["vectors", "sector", "text"], z.objectToOptions(Bk)) }), bd = E(), Zh = he();
function a4(t, e, r) {
  var n = e.sphereA, i = e.sphereB, a = e.sphereC, o = e.arcDirA, s = e.arcDirC, u = e.arcNormal, c = t.loci, l = c[0], d = c[1], f = c[2];
  Qr.getBoundingSphere(l, n), Qr.getBoundingSphere(d, i), Qr.getBoundingSphere(f, a), E.sub(o, n.center, i.center), E.sub(s, a.center, i.center), E.cross(u, o, s);
  var h = Math.min(E.magnitude(o), E.magnitude(s)) * r;
  return e.radius = h, e.angle = E.angle(o, s), e;
}
function Fk(t, e) {
  var r = t.radius, n = t.angle, i = e ? nN(n, r) / e : 32;
  return he.targetTo(Zh, t.sphereB.center, t.sphereA.center, t.arcNormal), he.setTranslation(Zh, t.sphereB.center), he.mul(Zh, Zh, he.rotY180), zy(Yx({ radius: r, thetaLength: n, segments: i }), Zh);
}
var Ca = { sphereA: Me(), sphereB: Me(), sphereC: Me(), arcDirA: E(), arcDirC: E(), arcNormal: E(), radius: 0, angle: 0 };
function o4(t) {
  return t.triples.length === 1 ? "Angle ".concat(Kx(t.triples[0], { measureOnly: !0 })) : "".concat(t.triples.length, " Angles");
}
function Lce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) a4(o.triples[l], Ca, s.arcScale), c.addFixedLengthDashes(Ca.sphereB.center, Ca.sphereA.center, s.dashLength, l), c.addFixedLengthDashes(Ca.sphereB.center, Ca.sphereC.center, s.dashLength, l);
    return c.getLines();
  }(e, r, n && n.geometry), a = o4(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function kce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      a4(o.triples[l], Ca, s.arcScale);
      for (var f = Fk(Ca, s.dashLength), h = f.indices, m = f.vertices, p = 0, v = h.length; p < v; p += 3) if (p % 2 != 1) {
        var g = 3 * h[p], y = 3 * h[p + 1], b = m[g], S = m[g + 1], _ = m[g + 2], x = m[y], C = m[y + 1], A = m[y + 2];
        c.add(b, S, _, x, C, A, l);
      }
    }
    return c.getLines();
  }(e, r, n && n.geometry), a = o4(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Gce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = wt.createState(128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      a4(o.triples[l], Ca, s.arcScale);
      var f = Fk(Ca);
      c.currentGroup = l, wt.addPrimitive(c, he.id, f), wt.addPrimitiveFlipped(c, he.id, f);
    }
    return wt.getMesh(c);
  }(e, r, n && n.geometry), a = o4(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return 1;
  }, function(o) {
    return Kx(e.triples[o]);
  });
}
function zce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = uf.create(s, 128, 64, u), l = 0, d = o.triples.length; l < d; ++l) {
      a4(o.triples[l], Ca, s.arcScale), E.add(bd, Ca.arcDirA, Ca.arcDirC), E.setMagnitude(bd, bd, Ca.radius), E.add(bd, Ca.sphereB.center, bd);
      var f = Ua(Ca.angle).toFixed(2), h = s.customText || "".concat(f, "°"), m = Math.max(2, Ca.sphereA.radius, Ca.sphereB.radius, Ca.sphereC.radius) / 2;
      c.add(h, bd[0], bd[1], bd[2], 0.1, m, l);
    }
    return c.getText();
  }(e, r, n && n.geometry), a = o4(e);
  return er.create(a, e, i, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return Kx(e.triples[o]);
  });
}
var Vce = { create: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            return sr.createMulti("Angle", o, s, sr.StateBuilder, Bk);
          }(e, function() {
            return Oce;
          }), [4, i.createOrUpdate(r ?? {}, { triples: [{ loci: t.slice(-3) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n && t.setTheme(n), [4, t.createOrUpdate(r ?? {}, { triples: [{ loci: e.slice(-3) }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Nk = { color: z.Color(Yt.lightgreen), arcScale: z.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 }) }, s4 = O(O(O({}, Rr.Params), Nk), { lineSizeAttenuation: z.Boolean(!0), linesSize: z.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: z.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), Uce = O({}, s4), Hce = O({}, s4), qce = O({}, s4), Kce = O({}, s4), Xce = O(O(O({}, Vt.Params), Nk), { ignoreLight: z.Boolean(!0), sectorOpacity: z.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), Rk = { vectors: function(t, e) {
  return Fn(Wce, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !1, markerActions: Lr.All });
  } });
}, extenders: function(t, e) {
  return Fn(Qce, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !1, markerActions: Lr.All });
  } });
}, connector: function(t, e) {
  return Fn(jce, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !1, markerActions: Lr.All });
  } });
}, arms: function(t, e) {
  return Fn(Zce, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !1, markerActions: Lr.All });
  } });
}, arc: function(t, e) {
  return Fn(Jce, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { pickable: !1, markerActions: Lr.All });
  } });
}, sector: function(t, e) {
  return Fn($ce, Vt.Utils, { modifyProps: function(r) {
    return O(O({}, r), { alpha: r.sectorOpacity });
  }, modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.All });
  } });
}, text: function(t, e) {
  return Fn(ele, bs.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.All });
  } });
} }, Yce = O(O(O(O(O(O(O({}, Uce), Hce), qce), Kce), Xce), i4), { visuals: z.MultiSelect(["extenders", "arms", "sector", "text"], z.objectToOptions(Rk)) }), Qa = E(), Qh = he();
function G0(t, e, r) {
  var n = e.sphereA, i = e.sphereB, a = e.sphereC, o = e.sphereD, s = e.dirBA, u = e.dirCD, c = e.projA, l = e.projD, d = e.arcPointA, f = e.arcPointD, h = e.arcDirA, m = e.arcDirD, p = e.arcCenter, v = e.arcNormal, g = t.loci, y = g[0], b = g[1], S = g[2], _ = g[3];
  Qr.getBoundingSphere(y, n), Qr.getBoundingSphere(b, i), Qr.getBoundingSphere(S, a), Qr.getBoundingSphere(_, o), E.add(p, i.center, a.center), E.scale(p, p, 0.5), E.sub(s, n.center, i.center), E.sub(u, o.center, a.center), E.add(d, p, s), E.add(f, p, u), E.sub(v, a.center, i.center), E.orthogonalize(h, v, s), E.orthogonalize(m, v, u), E.projectPointOnVector(c, d, h, p), E.projectPointOnVector(l, f, m, p);
  var x = Math.min(E.distance(c, p), E.distance(l, p)) * r;
  E.setMagnitude(h, h, x), E.setMagnitude(m, m, x), E.add(d, p, h), E.add(f, p, m), e.radius = x, e.angle = E.dihedralAngle(n.center, i.center, a.center, o.center), E.matchDirection(Qa, v, E.sub(Qa, d, n.center));
  var C = E.angle(s, Qa), A = x / Math.cos(C - Sw);
  E.add(c, i.center, E.setMagnitude(Qa, s, A)), E.matchDirection(Qa, v, E.sub(Qa, f, o.center));
  var w = E.angle(u, Qa), I = x / Math.cos(w - Sw);
  return E.add(l, a.center, E.setMagnitude(Qa, u, I)), e;
}
function Ok(t, e) {
  var r = t.radius, n = t.angle, i = e ? nN(n, r) / e : 32;
  return he.targetTo(Qh, t.arcCenter, n < 0 ? t.arcPointD : t.arcPointA, t.arcNormal), he.setTranslation(Qh, t.arcCenter), he.mul(Qh, Qh, he.rotY180), zy(Yx({ radius: r, thetaLength: Math.abs(n), segments: i }), Qh);
}
var nn = { sphereA: Me(), sphereB: Me(), sphereC: Me(), sphereD: Me(), dirBA: E(), dirCD: E(), projA: E(), projD: E(), arcPointA: E(), arcPointD: E(), arcDirA: E(), arcDirD: E(), arcCenter: E(), arcNormal: E(), radius: 0, angle: 0 };
function z0(t) {
  return t.quads.length === 1 ? "Dihedral ".concat(Xx(t.quads[0], { measureOnly: !0 })) : "".concat(t.quads.length, " Dihedrals");
}
function Wce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) G0(o.quads[l], nn, s.arcScale), c.addFixedLengthDashes(nn.arcCenter, nn.arcPointA, s.dashLength, l), c.addFixedLengthDashes(nn.arcCenter, nn.arcPointD, s.dashLength, l);
    return c.getLines();
  }(e, r, n && n.geometry), a = z0(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function jce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) G0(o.quads[l], nn, s.arcScale), c.addFixedLengthDashes(nn.sphereB.center, nn.sphereC.center, s.dashLength, l);
    return c.getLines();
  }(e, r, n && n.geometry), a = z0(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Zce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) G0(o.quads[l], nn, s.arcScale), c.addFixedLengthDashes(nn.sphereB.center, nn.sphereA.center, s.dashLength, l), c.addFixedLengthDashes(nn.sphereC.center, nn.sphereD.center, s.dashLength, l);
    return c.getLines();
  }(e, r, n && n.geometry), a = z0(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Qce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) G0(o.quads[l], nn, s.arcScale), c.addFixedLengthDashes(nn.arcPointA, nn.projA, s.dashLength, l), c.addFixedLengthDashes(nn.arcPointD, nn.projD, s.dashLength, l);
    return c.getLines();
  }(e, r, n && n.geometry), a = z0(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Jce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      G0(o.quads[l], nn, s.arcScale);
      for (var f = Ok(nn, s.dashLength), h = f.indices, m = f.vertices, p = 0, v = h.length; p < v; p += 3) if (p % 2 != 1) {
        var g = 3 * h[p], y = 3 * h[p + 1], b = m[g], S = m[g + 1], _ = m[g + 2], x = m[y], C = m[y + 1], A = m[y + 2];
        c.add(b, S, _, x, C, A, l);
      }
    }
    return c.getLines();
  }(e, r, n && n.geometry), a = z0(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function $ce(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = wt.createState(128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      G0(o.quads[l], nn, s.arcScale);
      var f = Ok(nn);
      c.currentGroup = l, wt.addPrimitive(c, he.id, f), wt.addPrimitiveFlipped(c, he.id, f);
    }
    return wt.getMesh(c);
  }(e, r, n && n.geometry), a = z0(e);
  return er.create(a, e, i, function() {
    return r.color;
  }, function() {
    return 1;
  }, function(o) {
    return Xx(e.quads[o]);
  });
}
function ele(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = uf.create(s, 128, 64, u), l = 0, d = o.quads.length; l < d; ++l) {
      G0(o.quads[l], nn, s.arcScale), E.add(Qa, nn.arcDirA, nn.arcDirD), E.setMagnitude(Qa, Qa, nn.radius), E.add(Qa, nn.arcCenter, Qa);
      var f = Ua(nn.angle).toFixed(2);
      f === "-0.00" && (f = "0.00");
      var h = s.customText || "".concat(f, "°"), m = Math.max(2, nn.sphereA.radius, nn.sphereB.radius, nn.sphereC.radius, nn.sphereD.radius) / 2;
      c.add(h, Qa[0], Qa[1], Qa[2], 0.1, m, l);
    }
    return c.getText();
  }(e, r, n && n.geometry), a = z0(e);
  return er.create(a, e, i, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return Xx(e.quads[o]);
  });
}
var tle = { create: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = sr.createMulti("Dihedral", o, s, sr.StateBuilder, Rk);
            return u.setState({ pickable: !0, markerActions: Lr.All }), u;
          }(e, function() {
            return Yce;
          }), [4, i.createOrUpdate(r ?? {}, { quads: [{ loci: t.slice(-4) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n && t.setTheme(n), [4, t.createOrUpdate(r ?? {}, { quads: [{ loci: e.slice(-4) }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, B8 = lr.is;
function rle(t, e, r, n, i, a) {
  if (!Fe.isAtomic(e)) return Rr.createEmpty(a);
  var o = r.child, s = o == null ? void 0 : o.unitMap.get(e.id);
  if (o && !s) return Rr.createEmpty(a);
  var u = at.create(r, e), c = e.elements, l = e.bonds, d = l.edgeCount, f = l.a, h = l.b, m = l.edgeProps, p = l.offset;
  if (!d) return Rr.createEmpty(a);
  var v = m.order, g = m.flags, y = i.sizeFactor, b = i.aromaticBonds, S = i.includeTypes, _ = i.excludeTypes, x = i.multipleBonds, C = x === "off", A = x === "symmetric", w = t4(lr.fromNames(S), lr.fromNames(_), 32), I = E(), P = e.conformation.invariantPosition, M = e.rings, T = M.elementRingIndices, F = M.elementAromaticRingIndices, N = b ? e.resonance.delocalizedTriplets : void 0, R = { linkCount: 2 * d, referencePosition: function(K) {
    var X, Y, Q = f[K], J = h[K], te = N == null ? void 0 : N.getThirdElement(Q, J);
    if (te !== void 0) return P(c[te], I);
    Q > J && (Q = (X = [J, Q])[0], J = X[1]), p[Q + 1] - p[Q] == 1 && (Q = (Y = [J, Q])[0], J = Y[1]);
    for (var W = F.get(Q) || T.get(Q), j = 0, ee = p[Q], ie = p[Q + 1]; ee < ie; ++ee) {
      var ae = h[ee];
      if (ae !== J && ae !== Q) {
        if (!W) return P(c[ae], I);
        var ce = F.get(ae) || T.get(ae);
        if (!ce) continue;
        var de = D3(W, ce);
        de > j && (j = de, P(c[ae], I));
      }
    }
    return j > 0 ? I : null;
  }, position: function(K, X, Y) {
    P(c[f[Y]], K), P(c[h[Y]], X);
  }, style: function(K) {
    var X = v[K], Y = g[K];
    if (B8(Y, 2) || B8(Y, 4)) return 1;
    if (X === 3) return C ? 0 : A ? 4 : 5;
    if (b) {
      var Q = f[K], J = h[K], te = F.get(Q), W = F.get(J), j = te && W ? D3(te, W) : 0;
      if (B8(Y, 16) || j && !w) {
        if (j === 2) return 8;
        if (j === 1 || N != null && N.getThirdElement(Q, J)) return 7;
      }
    }
    return X !== 2 || C ? 0 : A ? 2 : 3;
  }, radius: function(K) {
    u.element = c[f[K]];
    var X = n.size.size(u);
    u.element = c[h[K]];
    var Y = n.size.size(u);
    return Math.min(X, Y) * y;
  }, ignore: pk(r, e, i) }, L = fk(0, R, i, a), V = L.lines, U = L.boundingSphere;
  if (U) V.setBoundingSphere(U);
  else if (V.lineCount > 0) {
    var H = Me.expand(Me(), (s ?? e).boundary.sphere, 1 * y);
    V.setBoundingSphere(H);
  }
  return V;
}
var Lk = O(O(O({}, Lx), Ux), { includeParent: z.Boolean(!1) });
function nle(t) {
  return kx({ defaultProps: z.getDefaultValues(Lk), createGeometry: rle, createLocationIterator: cf.fromGroup, getLoci: X7, eachLocation: Y7, setUpdateState: function(e, r, n, i, a, o, s) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor || r.linkScale !== n.linkScale || r.linkSpacing !== n.linkSpacing || r.aromaticDashCount !== n.aromaticDashCount || r.dashCount !== n.dashCount || r.ignoreHydrogens !== n.ignoreHydrogens || !xo(r.includeTypes, n.includeTypes) || !xo(r.excludeTypes, n.excludeTypes) || r.aromaticBonds !== n.aromaticBonds || r.multipleBonds !== n.multipleBonds;
    var u = o.group.units[0], c = s.group.units[0];
    Fe.isAtomic(u) && Fe.isAtomic(c) && (Xo.areEqual(u.bonds, c.bonds) || (e.createGeometry = !0, e.updateTransform = !0, e.updateColor = !0, e.updateSize = !0));
  } }, t);
}
var F8 = new Dt.ElementBondIterator();
function jM(t, e, r, n) {
  for (F8.setElement(e, r, n); F8.hasNext; ) {
    var i = F8.move();
    return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex], t), t;
  }
  return null;
}
function ile(t, e, r, n, i) {
  var a = e.interUnitBonds, o = a.edgeCount, s = a.edges;
  if (!o) return Rr.createEmpty(i);
  var u = n.sizeFactor, c = n.aromaticBonds, l = n.multipleBonds, d = l === "off", f = l === "symmetric", h = E(), m = at.create(), p = { linkCount: o, referencePosition: function(_) {
    var x, C, A, w, I = s[_];
    if (I.unitA < I.unitB) x = e.unitMap.get(I.unitA), C = e.unitMap.get(I.unitB), A = I.indexA, w = I.indexB;
    else {
      if (!(I.unitA > I.unitB)) throw new Error("same units in createInterUnitBondLines");
      x = e.unitMap.get(I.unitB), C = e.unitMap.get(I.unitA), A = I.indexB, w = I.indexA;
    }
    return jM(h, e, x, A) || jM(h, e, C, w);
  }, position: function(_, x, C) {
    var A = s[C], w = e.unitMap.get(A.unitA), I = e.unitMap.get(A.unitB);
    w.conformation.position(w.elements[A.indexA], _), I.conformation.position(I.elements[A.indexB], x);
  }, style: function(_) {
    var x = s[_].props.order, C = Ga.create(s[_].props.flag);
    return lr.is(C, 2) || lr.is(C, 4) ? 1 : x === 3 ? d ? 0 : f ? 4 : 5 : c && lr.is(C, 16) ? 7 : x !== 2 || d ? 0 : f ? 2 : 3;
  }, radius: function(_) {
    var x = s[_];
    m.structure = e, m.unit = e.unitMap.get(x.unitA), m.element = m.unit.elements[x.indexA];
    var C = r.size.size(m);
    m.unit = e.unitMap.get(x.unitB), m.element = m.unit.elements[x.indexB];
    var A = r.size.size(m);
    return Math.min(C, A) * u;
  }, ignore: hk(e, n) }, v = fk(0, p, n, i), g = v.lines, y = v.boundingSphere;
  if (y) g.setBoundingSphere(y);
  else if (g.lineCount > 0) {
    var b = e.child, S = Me.expand(Me(), (b ?? e).boundary.sphere, 1 * u);
    g.setBoundingSphere(S);
  }
  return g;
}
var kk = O(O(O({}, eue), Ux), { includeParent: z.Boolean(!1) });
function ale(t) {
  return function(e, r) {
    return Jy(O(O({}, e), { setUpdateState: function(n, i, a, o, s, u, c) {
      e.setUpdateState(n, i, a, o, s, u, c), Co.areEqual(o.size, s.size) || (n.updateSize = !0);
    }, geometryUtils: Rr.Utils }), r);
  }({ defaultProps: z.getDefaultValues(kk), createGeometry: ile, createLocationIterator: cf.fromStructure, getLoci: W7, eachLocation: j7, setUpdateState: function(e, r, n, i, a, o, s) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor || r.linkScale !== n.linkScale || r.linkSpacing !== n.linkSpacing || r.aromaticDashCount !== n.aromaticDashCount || r.dashCount !== n.dashCount || r.ignoreHydrogens !== n.ignoreHydrogens || !xo(r.includeTypes, n.includeTypes) || !xo(r.excludeTypes, n.excludeTypes) || r.multipleBonds !== n.multipleBonds, o.interUnitBonds !== s.interUnitBonds && (e.createGeometry = !0, e.updateTransform = !0, e.updateColor = !0, e.updateSize = !0);
  } }, t);
}
var Z7, ole = Le.add3, sle = Le.add;
(function(t) {
  t.create = function(e, r, n) {
    e === void 0 && (e = 2048), r === void 0 && (r = 1024);
    var i = Le.create(Float32Array, 3, r, n ? n.centerBuffer.ref.value : e), a = Le.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : e);
    return { add: function(o, s, u, c) {
      ole(i, o, s, u), sle(a, c);
    }, getPoints: function() {
      var o = Le.compact(i, !0), s = Le.compact(a, !0);
      return I0.create(o, s, i.elementCount, n);
    } };
  };
})(Z7 || (Z7 = {}));
var ZM = E.add, Gk = O(O({}, iue), { pointSizeAttenuation: z.Boolean(!1), ignoreHydrogens: z.Boolean(!1), traceOnly: z.Boolean(!1) });
function ule(t, e, r, n, i, a) {
  var o = r.child;
  if (o && !o.unitMap.get(e.id)) return I0.createEmpty(a);
  var s = e.elements, u = s.length, c = Z7.create(u, u / 10, a), l = E(), d = e.conformation.invariantPosition, f = r4(r, e, i), h = E(), m = 0;
  if (f) for (var p = 0; p < u; ++p) f(s[p]) || (d(s[p], l), ZM(h, h, l), m += 1, c.add(l[0], l[1], l[2], p));
  else for (p = 0; p < u; ++p) d(s[p], l), ZM(h, h, l), m += 1, c.add(l[0], l[1], l[2], p);
  var v, g = a ? Me.clone(a.boundingSphere) : void 0, y = c.getPoints();
  return m === 0 || (E.scale(h, h, 1 / m), v = g && E.distance(h, g.center) / g.radius < 1 ? g : Me.expand(Me(), e.boundary.sphere, 1), y.setBoundingSphere(v)), y;
}
function cle(t) {
  return function(e, r) {
    return C2(O(O({}, e), { setUpdateState: function(n, i, a, o, s, u, c) {
      e.setUpdateState(n, i, a, o, s, u, c), Co.areEqual(o.size, s.size) || (n.updateSize = !0);
    }, geometryUtils: I0.Utils }), r);
  }({ defaultProps: z.getDefaultValues(Gk), createGeometry: ule, createLocationIterator: Tl.fromGroup, getLoci: zp, eachLocation: Gp, setUpdateState: function(e, r, n) {
    e.createGeometry = r.ignoreHydrogens !== n.ignoreHydrogens || r.traceOnly !== n.traceOnly;
  } }, t);
}
var V1 = E.scaleAndAdd, QM = E.unitX, JM = E.unitY, $M = E.unitZ, zk = O(O({}, Lx), { lineSizeAttenuation: z.Boolean(!1), ignoreHydrogens: z.Boolean(!1), traceOnly: z.Boolean(!1), crosses: z.Select("lone", z.arrayToOptions(["lone", "all"])), crossSize: z.Numeric(0.35, { min: 0, max: 2, step: 0.01 }) });
function lle(t, e, r, n, i, a) {
  var o = r.child;
  if (o && !o.unitMap.get(e.id)) return Rr.createEmpty(a);
  for (var s = e.elements, u = s.length, c = Ea.create(u, u / 10, a), l = E(), d = E(), f = E(), h = e.conformation.invariantPosition, m = r4(r, e, i), p = i.crossSize / 2, v = i.crosses === "lone", g = 0; g < u; ++g) m && m(s[g]) || v && Fe.isAtomic(e) && t2(r, e, g) !== 0 || (h(s[g], l), V1(d, l, QM, p), V1(f, l, QM, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], g), V1(d, l, JM, p), V1(f, l, JM, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], g), V1(d, l, $M, p), V1(f, l, $M, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], g));
  var y = c.getLines(), b = Me.expand(Me(), e.boundary.sphere, 1 * i.sizeFactor);
  return y.setBoundingSphere(b), y;
}
function dle(t) {
  return kx({ defaultProps: z.getDefaultValues(zk), createGeometry: lle, createLocationIterator: Tl.fromGroup, getLoci: zp, eachLocation: Gp, setUpdateState: function(e, r, n) {
    e.createGeometry = r.ignoreHydrogens !== n.ignoreHydrogens || r.traceOnly !== n.traceOnly || r.crosses !== n.crosses || r.crossSize !== n.crossSize;
  } }, t);
}
var Vk = { "intra-bond": function(t, e) {
  return $a("Intra-unit bond line", t, e, nle);
}, "inter-bond": function(t, e) {
  return P0("Inter-unit bond line", t, e, ale);
}, "element-point": function(t, e) {
  return $a("Points", t, e, cle);
}, "element-cross": function(t, e) {
  return $a("Crosses", t, e, dle);
}, "charge-text": function(t, e) {
  return P0("Charge Text", t, e, qx);
} }, eP = O(O(O(O(O({}, Lk), kk), Gk), zk), { multipleBonds: z.Select("offset", z.arrayToOptions(["off", "symmetric", "offset"])), includeParent: z.Boolean(!1), sizeFactor: z.Numeric(0.01, { min: 0.01, max: 10, step: 0.01 }), unitKinds: S2(["atomic"]), visuals: z.MultiSelect(["intra-bond", "inter-bond", "element-point", "element-cross", "charge-text"], z.objectToOptions(Vk)), lineSizeAttenuation: z.Boolean(!0), traceOnly: z.Boolean(!1, { isHidden: !0 }), pointSizeAttenuation: z.Boolean(!0), pointStyle: z.Select("circle", z.objectToOptions({ square: "Square", circle: "Circle", fuzzy: "Fuzzy" })) }), N8 = { name: "line", label: "Line", description: "Displays bonds as lines and atoms as points or croses.", factory: function(t, e) {
  return sr.createMulti("Line", t, e, xs, Vk);
}, getParams: function(t, e) {
  var r = z.clone(eP);
  return r.pointStyle.defaultValue = "circle", r;
}, defaultValues: z.getDefaultValues(eP), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(t) {
  return t.elementCount > 0;
}, getData: function(t, e) {
  return e.includeParent ? t.asParent() : t;
}, mustRecreate: function(t, e) {
  return t.includeParent !== e.includeParent;
} }, fle = { create: function(t, e, r) {
  var n;
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = N8.factory(e, N8.getParams)).setTheme(r ?? { color: e.colorThemeRegistry.create("element-symbol", { structure: t }), size: e.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, i.createOrUpdate(O(O({}, N8.defaultValues), { aromaticBonds: ((n = t.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: e.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"] }), t).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return t.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: e }), size: r.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, t.createOrUpdate({ visuals: r.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"] }, e).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Uk = { "element-sphere": function(t, e) {
  return $a("Element sphere", t, e, Hx);
}, "intra-bond": function(t, e) {
  return $a("Intra-unit bond cylinder", t, e, gk);
}, "inter-bond": function(t, e) {
  return P0("Inter-unit bond cylinder", t, e, yk);
}, "charge-text": function(t, e) {
  return P0("Charge Text", t, e, qx);
} }, tP = O(O(O(O(O({}, a2), { traceOnly: z.Boolean(!1, { isHidden: !0 }) }), cy), ly), { includeParent: z.Boolean(!1), unitKinds: S2(["atomic"]), visuals: z.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], z.objectToOptions(Uk)), bumpFrequency: z.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), sizeFactor: z.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: z.Numeric(1, { min: 0.01, max: 3, step: 0.01 }), multipleBonds: z.Select("offset", z.arrayToOptions(["off", "symmetric", "offset"])), tryUseImpostor: z.Boolean(!0), linkScale: z.Numeric(0.55, { min: 0, max: 1, step: 0.01 }) }), R8 = { name: "stick", label: "Stick", description: "Displays atoms as spheres and bonds as cylinders.", factory: function(t, e) {
  return sr.createMulti("Ball & Stick", t, e, xs, Uk);
}, getParams: function(t, e) {
  return z.clone(tP);
}, defaultValues: z.getDefaultValues(tP), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(t) {
  return t.elementCount > 0;
}, getData: function(t, e) {
  return e.includeParent ? t.asParent() : t;
}, mustRecreate: function(t, e) {
  return t.includeParent !== e.includeParent;
} }, ple = { create: function(t, e, r) {
  var n;
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = R8.factory(e, R8.getParams)).setTheme(r ?? { color: e.colorThemeRegistry.create("element-symbol", { structure: t }), size: e.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, i.createOrUpdate(O(O({}, R8.defaultValues), { aromaticBonds: ((n = t.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: e.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }), t).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return t.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: e }), size: r.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, t.createOrUpdate({ visuals: r.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }, e).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Wx = { probeRadius: z.Numeric(1.4, { min: 0, max: 10, step: 0.1 }, { description: "Radius of the probe tracing the molecular surface." }), resolution: z.Numeric(0.5, { min: 0.01, max: 20, step: 0.01 }, O({ description: "Grid resolution/cell spacing." }, ft.CustomQualityParamInfo)), probePositions: z.Numeric(36, { min: 12, max: 90, step: 1 }, O({ description: "Number of positions tested for probe target intersection." }, ft.CustomQualityParamInfo)) };
function hle(t, e, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    function o(Re, nt, ne, re, le) {
      if (d !== -1) {
        if ((me = d) !== re && me !== le && s(me, Re, nt, ne)) return me;
        d = -1;
      }
      for (var fe = 0, ge = C.count; fe < ge; ++fe) {
        var me;
        if ((me = Ge.getAt(A, C.indices[fe])) !== re && me !== le && s(me, Re, nt, ne)) return d = me, me;
      }
      return -1;
    }
    function s(Re, nt, ne, re) {
      var le = T[Re], fe = w[Re] - nt, ge = I[Re] - ne, me = P[Re] - re;
      return fe * fe + ge * ge + me * me < le * le;
    }
    function u() {
      return _e(this, 0, void 0, function() {
        var Re;
        return ye(this, function(nt) {
          switch (nt.label) {
            case 0:
              Re = 0, nt.label = 1;
            case 1:
              return Re < F ? (function(ne, re) {
                for (var le = ne; le < re; ++le) {
                  var fe = Ge.getAt(A, le), ge = w[fe], me = I[fe], Ae = P[fe], Oe = T[fe], Ue = Oe * Oe;
                  x.find(ge, me, Ae, Oe);
                  for (var Ve = Math.ceil(Oe * b), ht = Math.floor(b * (ge - V)), bt = Math.floor(b * (me - U)), At = Math.floor(b * (Ae - H)), Ee = Math.max(0, ht - Ve), st = Math.max(0, bt - Ve), Et = Math.max(0, At - Ve), ur = Math.min(Y, ht + Ve + 2), ir = Math.min(Q, bt + Ve + 2), Nr = Math.min(J, At + Ve + 2), pr = Ee; pr < ur; ++pr) for (var _n = Ce[pr] - ge, Jn = pr * W, Yn = st; Yn < ir; ++Yn) for (var Rn = De[Yn] - me, un = _n * _n + Rn * Rn, yi = Yn * te + Jn, cn = Et; cn < Nr; ++cn) {
                    var ln = ke[cn] - Ae, Ti = un + ln * ln;
                    if (Ti < Ue) {
                      var Mi = cn + yi;
                      ce[Mi] < 0 && (ce[Mi] *= -1);
                      var so = Math.sqrt(Ti), On = Oe / so;
                      if (o(_n * On + ge, Rn * On + me, ln * On + Ae, fe, -1) === -1) {
                        var xn = Oe - so;
                        xn < ce[Mi] && (ce[Mi] = xn, de[Mi] = M[le]);
                      }
                    }
                  }
                }
              }(Re, Math.min(Re + He, F)), t.shouldUpdate ? [4, t.update({ message: "projecting points", current: Re, max: F })] : [3, 3]) : [3, 4];
            case 2:
              nt.sent(), nt.label = 3;
            case 3:
              return Re += He, [3, 1];
            case 4:
              return [2];
          }
        });
      });
    }
    function c(Re, nt) {
      var ne = T[Re], re = T[nt], le = f[0] = w[nt] - w[Re], fe = f[1] = I[nt] - I[Re], ge = f[2] = P[nt] - P[Re], me = le * le + fe * fe + ge * ge, Ae = Math.sqrt(me), Oe = ne * ((ne * ne + Ae * Ae - re * re) / (2 * ne * Ae));
      E.normalize(f, f), function(uo, Pi) {
        uo[0] = uo[1] = uo[2] = 1, Pi[0] !== 0 ? uo[0] = (Pi[1] + Pi[2]) / -Pi[0] : Pi[1] !== 0 ? uo[1] = (Pi[0] + Pi[2]) / -Pi[1] : Pi[2] !== 0 && (uo[2] = (Pi[0] + Pi[1]) / -Pi[2]);
      }(m, f), E.normalize(m, m), E.cross(p, f, m), E.normalize(p, p);
      var Ue = Math.sqrt(ne * ne - Oe * Oe);
      E.scale(m, m, Ue), E.scale(p, p, Ue), E.scale(f, f, Oe), h[0] = f[0] + w[Re], h[1] = f[1] + I[Re], h[2] = f[2] + P[Re], d = -1;
      for (var Ve = 0; Ve < y; ++Ve) {
        var ht = ee[Ve], bt = ie[Ve], At = h[0] + ht * m[0] + bt * p[0], Ee = h[1] + ht * m[1] + bt * p[1], st = h[2] + ht * m[2] + bt * p[2];
        if (o(At, Ee, st, Re, nt) === -1) for (var Et = Math.floor(b * (At - V)), ur = Math.floor(b * (Ee - U)), ir = Math.floor(b * (st - H)), Nr = Math.max(0, Et - S), pr = Math.max(0, ur - S), _n = Math.max(0, ir - S), Jn = Math.min(Y, Et + S + 2), Yn = Math.min(Q, ur + S + 2), Rn = Math.min(J, ir + S + 2), un = Nr; un < Jn; ++un) for (var yi = At - Ce[un], cn = un * W, ln = pr; ln < Yn; ++ln) for (var Ti = Ee - De[ln], Mi = yi * yi + Ti * Ti, so = ln * te + cn, On = _n; On < Rn; ++On) {
          var xn = st - ke[On], Wo = Mi + xn * xn, jo = On + so, Eo = ce[jo];
          if (Eo > 0 && Wo < Eo * Eo) {
            ce[jo] = Math.sqrt(Wo);
            var Hu = yi * f[0] + Ti * f[1] + xn * f[2];
            de[jo] = M[Ge.indexOf(A, Hu < 0 ? nt : Re)];
          }
        }
      }
    }
    function l() {
      return _e(this, 0, void 0, function() {
        var Re;
        return ye(this, function(nt) {
          switch (nt.label) {
            case 0:
              Re = 0, nt.label = 1;
            case 1:
              return Re < F ? (function(ne, re) {
                for (var le = ne; le < re; ++le) {
                  var fe = Ge.getAt(A, le);
                  x.find(w[fe], I[fe], P[fe], T[fe]);
                  for (var ge = 0, me = C.count; ge < me; ++ge) {
                    var Ae = Ge.getAt(A, C.indices[ge]);
                    fe < Ae && c(fe, Ae);
                  }
                }
              }(Re, Math.min(Re + He, F)), t.shouldUpdate ? [4, t.update({ message: "projecting torii", current: Re, max: F })] : [3, 3]) : [3, 4];
            case 2:
              nt.sent(), nt.label = 3;
            case 3:
              return Re += He, [3, 1];
            case 4:
              return [2];
          }
        });
      });
    }
    var d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F, N, R, L, V, U, H, K, X, Y, Q, J, te, W, j, ee, ie, ae, ce, de, Ce, De, ke, He, We, Ne, Je;
    return ye(this, function(Re) {
      switch (Re.label) {
        case 0:
          return d = -1, f = E(), h = E(), m = E(), p = E(), v = a.resolution, g = a.probeRadius, y = a.probePositions, b = 1 / v, S = Math.max(5, 2 + Math.floor(g * b)), _ = E.create(n, n, n), E.scale(_, _, 2), x = S0(e, r, _), C = x.result, i === null && (i = x.boundary.box), A = e.indices, w = e.x, I = e.y, P = e.z, M = e.id, T = e.radius, F = Ge.size(A), N = n + v, R = $r.expand($r(), i, E.create(N, N, N)), L = R.min, V = L[0], U = L[1], H = L[2], K = $r.scale($r(), R, b), X = $r.size(E(), K), E.ceil(X, X), Y = X[0], Q = X[1], J = X[2], W = (te = J) * Q, j = function(nt) {
            for (var ne = 0, re = 2 * Math.PI / nt, le = new Float32Array(nt), fe = new Float32Array(nt), ge = 0; ge < nt; ge++) le[ge] = Math.cos(ne), fe[ge] = Math.sin(ne), ne += re;
            return { cosTable: le, sinTable: fe };
          }(y), ee = j.cosTable, ie = j.sinTable, ae = Qn.Space(X, [0, 1, 2], Float32Array), ce = ae.create(), de = ae.create(), ce.fill(-1001), de.fill(-1), Ce = U6(Y, V, v), De = U6(Q, U, v), ke = U6(J, H, v), He = Math.ceil(1e5 / (Math.pow(Math.pow(n, 3), 3) * b)), [4, u()];
        case 1:
          return Re.sent(), [4, l()];
        case 2:
          return Re.sent(), We = Qn.create(ae, ce), Ne = Qn.create(ae, de), Je = he.identity(), he.fromScaling(Je, E.create(v, v, v)), he.setTranslation(Je, R.min), [2, { field: We, idField: Ne, transform: Je, resolution: v, maxRadius: n }];
      }
    });
  });
}
function Hk(t, e, r, n) {
  var i = this, a = e.lookup3d.boundary.box, o = Yse(a, n), s = function(d, f, h, m) {
    for (var p = m.probeRadius, v = Zse(d, f, h, m), g = v.position, y = v.boundary, b = v.radius, S = g.indices, _ = Ge.size(S), x = new Float32Array(Ge.end(S)), C = 0, A = 0; A < _; ++A) {
      var w = Ge.getAt(S, A), I = b(w);
      C < I && (C = I), x[w] = I + p;
    }
    return { position: O(O({}, g), { radius: x }), boundary: y, maxRadius: C };
  }(t, e, r, o), u = s.position, c = s.boundary, l = s.maxRadius;
  return tr.create("Molecular Surface", function(d) {
    return _e(i, 0, void 0, function() {
      return ye(this, function(f) {
        switch (f.label) {
          case 0:
            return [4, mle(d, u, c, l, a, o)];
          case 1:
            return [2, f.sent()];
        }
      });
    });
  });
}
function mle(t, e, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(o) {
      return [2, hle(t, e, r, n, i, a)];
    });
  });
}
function _d(t, e, r) {
  return { i: t, j: e, k: r };
}
function Vs(t, e) {
  return { a: t, b: e };
}
z.getDefaultValues(Wx);
var ni = [_d(0, 0, 0), _d(1, 0, 0), _d(1, 1, 0), _d(0, 1, 0), _d(0, 0, 1), _d(1, 0, 1), _d(1, 1, 1), _d(0, 1, 1)], gle = [Vs(ni[0], ni[1]), Vs(ni[1], ni[2]), Vs(ni[2], ni[3]), Vs(ni[3], ni[0]), Vs(ni[4], ni[5]), Vs(ni[5], ni[6]), Vs(ni[6], ni[7]), Vs(ni[7], ni[4]), Vs(ni[0], ni[4]), Vs(ni[1], ni[5]), Vs(ni[2], ni[6]), Vs(ni[3], ni[7])], vle = [{ 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 }], yle = [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], hp = [[], [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], []], O8 = [[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 qk(t) {
  return O(O({}, t), { bottomLeft: Ui(t.bottomLeft, [0, 0, 0]), topRight: Ui(t.topRight, t.scalarField.space.dimensions) });
}
function Kk(t) {
  return { dX: t.topRight[0] - t.bottomLeft[0], dY: t.topRight[1] - t.bottomLeft[1], dZ: t.topRight[2] - t.bottomLeft[2] };
}
function Xk(t, e) {
  var r = this;
  return tr.create("Marching Cubes Mesh", function(n) {
    return _e(r, 0, void 0, function() {
      var i, a, o, s, u, c, l;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            return i = qk(t), a = Kk(i), o = a.dX, s = a.dY, u = a.dZ, c = Math.min(262144, Math.max(o * s * u / 32, 1024)), l = function(f, h) {
              var m = Math.min(65536, 4 * f), p = Le.create(Float32Array, 3, f, h && h.vertexBuffer.ref.value), v = Le.create(Float32Array, 3, f, h && h.normalBuffer.ref.value), g = Le.create(Float32Array, 1, f, h && h.groupBuffer.ref.value), y = Le.create(Uint32Array, 3, m, h && h.indexBuffer.ref.value), b = 0, S = 0;
              return { addVertex: function(_, x, C) {
                return ++b, Le.add3(p, _, x, C);
              }, addNormal: function(_, x, C) {
                Le.add3(v, _, x, C);
              }, addGroup: function(_) {
                Le.add(g, _);
              }, addTriangle: function(_, x, C, A) {
                var w = _[x], I = _[C], P = _[A];
                w >= 0 && I >= 0 && P >= 0 && (++S, Le.add3(y, w, I, P));
              }, get: function() {
                var _ = Le.compact(p, !0), x = Le.compact(v, !0), C = Le.compact(y, !0), A = Le.compact(g, !0);
                return Vt.create(_, C, x, A, b, S, h);
              } };
            }(c, e), [4, new Wk(n, l, i).run()];
          case 1:
            return d.sent(), [2, l.get()];
        }
      });
    });
  });
}
function Yk(t, e) {
  var r = this;
  return tr.create("Marching Cubes Lines", function(n) {
    return _e(r, 0, void 0, function() {
      var i, a, o, s, u, c, l;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            return i = qk(t), a = Kk(i), o = a.dX, s = a.dY, u = a.dZ, c = Math.min(262144, Math.max(o * s * u / 32, 1024)), l = function(f, h) {
              var m = Le.create(Float32Array, 3, f), p = Le.create(Float32Array, 1, f), v = Le.create(Float32Array, 2, f), g = 0;
              return { addVertex: function(y, b, S) {
                return Le.add3(m, y, b, S);
              }, addNormal: function() {
                return H9;
              }, addGroup: function(y) {
                Le.add(p, y);
              }, addTriangle: function(y, b, S, _, x) {
                var C = y[b], A = y[S], w = y[_];
                C >= 0 && A >= 0 && w >= 0 && (O8[b][S] & x && (++g, Le.add2(v, y[b], y[S])), O8[S][_] & x && (++g, Le.add2(v, y[S], y[_])), O8[b][_] & x && (++g, Le.add2(v, y[b], y[_])));
              }, get: function() {
                for (var y = Le.compact(m, !0), b = Le.compact(v, !0), S = Le.compact(p, !0), _ = Ea.create(g, g / 10, h), x = 0; x < g; ++x) {
                  var C = b[2 * x], A = b[2 * x + 1];
                  _.add(y[3 * C], y[3 * C + 1], y[3 * C + 2], y[3 * A], y[3 * A + 1], y[3 * A + 2], S[C]);
                }
                return _.getLines();
              } };
            }(c, e), [4, new Wk(n, l, i).run()];
          case 1:
            return d.sent(), [2, l.get()];
        }
      });
    });
  });
}
var Wk = function() {
  function t(e, r, n) {
    this.ctx = e, this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.state = new ble(r, n), this.minX = n.bottomLeft[0], this.minY = n.bottomLeft[1], this.minZ = n.bottomLeft[2], this.maxX = n.topRight[0] - 1, this.maxY = n.topRight[1] - 1, this.maxZ = n.topRight[2] - 1, this.size = (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ), this.sliceSize = (this.maxX - this.minX) * (this.maxY - this.minY);
  }
  return t.prototype.doSlices = function() {
    return _e(this, 0, void 0, function() {
      var e, r;
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            e = 0, this.edgeFilter = 15, r = this.minZ, n.label = 1;
          case 1:
            return r < this.maxZ ? (this.slice(r), e += this.sliceSize, this.ctx.shouldUpdate ? [4, this.ctx.update({ message: "Computing surface...", current: e, max: this.size })] : [3, 3]) : [3, 4];
          case 2:
            n.sent(), n.label = 3;
          case 3:
            return r++, this.edgeFilter &= -5, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, t.prototype.slice = function(e) {
    this.edgeFilter |= 2;
    for (var r = this.minY; r < this.maxY; r++, this.edgeFilter &= -3) {
      this.edgeFilter |= 1;
      for (var n = this.minX; n < this.maxX; n++, this.edgeFilter &= -2) this.state.processCell(n, r, e, this.edgeFilter);
    }
    this.state.clearEdgeVertexIndexSlice(e);
  }, t.prototype.run = function() {
    return _e(this, 0, void 0, function() {
      return ye(this, function(e) {
        switch (e.label) {
          case 0:
            return [4, this.doSlices()];
          case 1:
            return e.sent(), [2];
        }
      });
    });
  }, t;
}(), ble = function() {
  function t(e, r) {
    this.builder = e, this.vertList = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this.i = 0, this.j = 0, this.k = 0;
    var n = r.scalarField.space.dimensions;
    this.nX = n[0], this.nY = n[1], this.nZ = n[2], this.isoLevel = r.isoLevel, this.scalarFieldGet = r.scalarField.space.get, this.scalarField = r.scalarField.data, r.idField && (this.idField = r.idField.data, this.idFieldGet = r.idField.space.get), this.verticesOnEdges = new Int32Array(3 * this.nX * this.nY * 2);
  }
  return t.prototype.get3dOffsetFromEdgeInfo = function(e) {
    return this.nX * ((this.k + e.k) % 2 * this.nY + this.j + e.j) + this.i + e.i;
  }, t.prototype.clearEdgeVertexIndexSlice = function(e) {
    var r = e % 2 == 0 ? 0 : 3 * this.nX * this.nY, n = e % 2 == 0 ? 3 * this.nX * this.nY : this.verticesOnEdges.length;
    this.verticesOnEdges.fill(0, r, n);
  }, t.prototype.interpolate = function(e) {
    var r = vle[e], n = 3 * this.get3dOffsetFromEdgeInfo(r) + r.e, i = this.verticesOnEdges[n];
    if (i > 0) return i - 1;
    var a = this.scalarField, o = this.scalarFieldGet, s = gle[e], u = s.a, c = s.b, l = u.i + this.i, d = u.j + this.j, f = u.k + this.k, h = c.i + this.i, m = c.j + this.j, p = c.k + this.k, v = o(a, l, d, f), g = o(a, h, m, p), y = (this.isoLevel - v) / (v - g);
    if (this.idField) {
      var b = this.idFieldGet(this.idField, l, d, f), S = this.idFieldGet(this.idField, h, m, p), _ = y < 0.5 ? b : S;
      if (_ === -1 && (_ = y < 0.5 ? S : b), _ === -2) return -1;
      this.builder.addGroup(_);
    } else this.builder.addGroup(0);
    var x = this.builder.addVertex(l + y * (l - h), d + y * (d - m), f + y * (f - p));
    this.verticesOnEdges[n] = x + 1;
    var C = o(a, Math.max(0, l - 1), d, f) - o(a, Math.min(this.nX - 1, l + 1), d, f), A = o(a, l, Math.max(0, d - 1), f) - o(a, l, Math.min(this.nY - 1, d + 1), f), w = o(a, l, d, Math.max(0, f - 1)) - o(a, l, d, Math.min(this.nZ, f + 1)), I = C + y * (C - (o(a, Math.max(0, h - 1), m, p) - o(a, Math.min(this.nX - 1, h + 1), m, p))), P = A + y * (A - (o(a, h, Math.max(0, m - 1), p) - o(a, h, Math.min(this.nY - 1, m + 1), p))), M = w + y * (w - (o(a, h, m, Math.max(0, p - 1)) - o(a, h, m, Math.min(this.nZ - 1, p + 1))));
    return this.isoLevel >= 0 ? this.builder.addNormal(I, P, M) : this.builder.addNormal(-I, -P, -M), x;
  }, t.prototype.get = function(e, r, n) {
    return this.scalarFieldGet(this.scalarField, e, r, n);
  }, t.prototype.processCell = function(e, r, n, i) {
    var a = 0;
    if (this.get(e, r, n) < this.isoLevel && (a |= 1), this.get(e + 1, r, n) < this.isoLevel && (a |= 2), this.get(e + 1, r + 1, n) < this.isoLevel && (a |= 4), this.get(e, r + 1, n) < this.isoLevel && (a |= 8), this.get(e, r, n + 1) < this.isoLevel && (a |= 16), this.get(e + 1, r, n + 1) < this.isoLevel && (a |= 32), this.get(e + 1, r + 1, n + 1) < this.isoLevel && (a |= 64), this.get(e, r + 1, n + 1) < this.isoLevel && (a |= 128), a !== 0 && a !== 255) {
      this.i = e, this.j = r, this.k = n;
      var o = yle[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 = hp[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);
      }
    }
  }, t;
}(), jk = O(O(O(O({}, Rl), Wx), Ox), Qte);
function _le(t, e, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    var o, s, u, c, l, d, f, h, m;
    return ye(this, function(p) {
      switch (p.label) {
        case 0:
          return [4, Hk(r, e, n.size, i).runInContext(t.runtime)];
        case 1:
          return o = p.sent(), s = o.transform, u = o.field, c = o.idField, l = o.resolution, d = o.maxRadius, [4, Xk({ isoLevel: i.probeRadius, scalarField: u, idField: c }, a).runAsChild(t.runtime)];
        case 2:
          return f = p.sent(), i.includeParent && (h = Math.ceil(2 / i.resolution), Vt.smoothEdges(f, { iterations: h, maxNewEdgeLength: Math.sqrt(2) })), Vt.transform(f, s), t.webgl && !t.webgl.isWebGL2 && Vt.uniformTriangleGroup(f), m = Me.expand(Me(), e.boundary.sphere, d), f.setBoundingSphere(m), f.meta.resolution = l, [2, f];
      }
    });
  });
}
function xle(t) {
  return Ol({ defaultProps: z.getDefaultValues(jk), createGeometry: _le, createLocationIterator: Tl.fromGroup, getLoci: zp, eachLocation: Gp, setUpdateState: function(e, r, n) {
    r.resolution !== n.resolution && (e.createGeometry = !0), r.probeRadius !== n.probeRadius && (e.createGeometry = !0), r.probePositions !== n.probePositions && (e.createGeometry = !0), r.ignoreHydrogens !== n.ignoreHydrogens && (e.createGeometry = !0), r.traceOnly !== n.traceOnly && (e.createGeometry = !0), r.includeParent !== n.includeParent && (e.createGeometry = !0), r.smoothColors.name !== n.smoothColors.name ? e.updateColor = !0 : r.smoothColors.name === "on" && n.smoothColors.name === "on" && (r.smoothColors.params.resolutionFactor !== n.smoothColors.params.resolutionFactor && (e.updateColor = !0), r.smoothColors.params.sampleStride !== n.smoothColors.params.sampleStride && (e.updateColor = !0));
  }, processValues: function(e, r, n, i, a) {
    var o = r.meta, s = o.resolution, u = o.colorTexture, c = r0(n.smoothColors, i.color.preferSmoothing, s);
    c && (function(l, d, f, h, m) {
      if (/* @__PURE__ */ function(v) {
        return v === "group" || v === "groupInstance";
      }(l.dColorType.ref.value)) {
        var p = a3({ vertexCount: l.uVertexCount.ref.value, instanceCount: l.uInstanceCount.ref.value, groupCount: l.uGroupCount.ref.value, transformBuffer: l.aTransform.ref.value, instanceBuffer: l.aInstance.ref.value, positionBuffer: l.aPosition.ref.value, groupBuffer: l.aGroup.ref.value, colorData: l.tColor.ref.value, colorType: l.dColorType.ref.value, boundingSphere: l.boundingSphere.ref.value, invariantBoundingSphere: l.invariantBoundingSphere.ref.value, itemSize: 3 }, d, f, h, m);
        p.kind === "volume" ? (G.updateIfChanged(l.dColorType, p.type), G.update(l.tColorGrid, p.texture), G.update(l.uColorTexDim, p.gridTexDim), G.update(l.uColorGridDim, p.gridDim), G.update(l.uColorGridTransform, p.gridTransform)) : p.kind === "vertex" && (G.updateIfChanged(l.dColorType, p.type), G.update(l.tColor, p.texture), G.update(l.uColorTexDim, p.texDim));
      }
    }(e, c.resolution, c.stride, a, u), r.meta.colorTexture = e.tColorGrid.ref.value);
  }, dispose: function(e) {
    var r;
    (r = e.meta.colorTexture) === null || r === void 0 || r.destroy();
  } }, t);
}
var Zk = O(O(O(O({}, Lx), Wx), Ox), { sizeFactor: z.Numeric(1.5, { min: 0, max: 10, step: 0.1 }) });
function Sle(t, e, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    var o, s, u, c, l, d, f;
    return ye(this, function(h) {
      switch (h.label) {
        case 0:
          return [4, Hk(r, e, n.size, i).runInContext(t.runtime)];
        case 1:
          return o = h.sent(), s = o.transform, u = o.field, c = o.idField, l = o.maxRadius, [4, Yk({ isoLevel: i.probeRadius, scalarField: u, idField: c }, a).runAsChild(t.runtime)];
        case 2:
          return d = h.sent(), Rr.transform(d, s), f = Me.expand(Me(), e.boundary.sphere, l), d.setBoundingSphere(f), [2, d];
      }
    });
  });
}
function Cle(t) {
  return kx({ defaultProps: z.getDefaultValues(Zk), createGeometry: Sle, createLocationIterator: Tl.fromGroup, getLoci: zp, eachLocation: Gp, setUpdateState: function(e, r, n) {
    r.resolution !== n.resolution && (e.createGeometry = !0), r.probeRadius !== n.probeRadius && (e.createGeometry = !0), r.probePositions !== n.probePositions && (e.createGeometry = !0), r.ignoreHydrogens !== n.ignoreHydrogens && (e.createGeometry = !0), r.includeParent !== n.includeParent && (e.createGeometry = !0);
  } }, t);
}
var Qk = { "molecular-surface-mesh": function(t, e) {
  return $a("Molecular surface mesh", t, e, xle);
}, "molecular-surface-wireframe": function(t, e) {
  return $a("Molecular surface wireframe", t, e, Cle);
} }, rP = O(O(O({}, jk), Zk), { visuals: z.MultiSelect(["molecular-surface-mesh"], z.objectToOptions(Qk)), bumpFrequency: z.Numeric(1, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory) }), L8, k8 = { name: "molecular-surface", label: "Molecular Surface", description: "Displays a molecular surface.", factory: function(t, e) {
  return sr.createMulti("Molecular Surface", t, e, xs, Qk);
}, getParams: function(t, e) {
  return z.clone(rP);
}, defaultValues: z.getDefaultValues(rP), defaultColorTheme: { name: "chain-id" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(t) {
  return t.elementCount > 0;
} }, Ale = { parse: function(t, e) {
  var r, n = e.managers.cell.get(t.ref), i = on(n);
  return i ? fi(i, (r = t.elementIds) !== null && r !== void 0 ? r : [], !0) : tt.Empty;
}, createTheme: function(t, e, r) {
  return e.managers.representation.createTheme(Pe.Surface, this.parse(t, e), r);
}, create: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return (n = k8.factory(e, k8.getParams)).setTheme(r ?? { color: e.colorThemeRegistry.create("element-symbol", { structure: t }), size: e.sizeThemeRegistry.create("physical", { structure: t }) }), [4, n.createOrUpdate(O(O({}, k8.defaultValues), { quality: "auto" }), t).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return t.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: e }), size: r.sizeThemeRegistry.create("physical", { structure: e }) }), [4, t.createOrUpdate({}, e).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, wle = E.create(0, 0, -0.5), Dle = E.create(0, 0, 0.5), xd = E(), Sd = E(), Rv = E(), nP = E();
function Ele() {
  return L8 || (L8 = function(t) {
    for (var e = t.length / 3, r = (e === 3 ? 1 : e === 4 ? 2 : e) + e, n = b2(r, e === 4 ? 3 * e + 4 : 3 * r), i = 0; i < e; ++i) {
      var a = (i + 1) % e;
      E.set(xd, t[3 * i], t[3 * i + 1], -0.5), E.set(Sd, t[3 * a], t[3 * a + 1], -0.5), n.add(xd, Sd, Dle);
    }
    if (e === 3) E.set(xd, t[0], t[1], -0.5), E.set(Sd, t[3], t[4], -0.5), E.set(Rv, t[6], t[7], -0.5), n.add(Rv, Sd, xd);
    else if (e === 4) E.set(xd, t[0], t[1], -0.5), E.set(Sd, t[3], t[4], -0.5), E.set(Rv, t[6], t[7], -0.5), E.set(nP, t[9], t[10], -0.5), n.addQuad(nP, Rv, Sd, xd);
    else for (i = 0; i < e; ++i) a = (i + 1) % e, E.set(xd, t[3 * i], t[3 * i + 1], -0.5), E.set(Sd, t[3 * a], t[3 * a + 1], -0.5), n.add(wle, Sd, xd);
    return n.getPrimitive();
  }(Vy(8, !0))), L8;
}
var Q7 = { center: z.Vec3(E()), vec: z.Vec3(E()), color: z.Color(qe.fromRgb(255, 196, 36)), alpha: z.Numeric(0.9, { min: 0, max: 1, step: 0.1 }) }, Jk = { "rotate-arrow-cylinder": function(t, e) {
  return Fn(Tle, to.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.All });
  } });
}, "rotate-arrow-arrowhead": function(t, e) {
  return Fn(Mle, Vt.Utils);
} }, Ile = O(O(O({}, Rr.Params), Q7), { visuals: z.MultiSelect(["rotate-arrow-cylinder", "rotate-arrow-arrowhead"], z.objectToOptions(Jk)) });
function Tle(t, e, r, n) {
  var i = r.center, a = r.vec, o = E.create(0, 0, 0);
  E.normalize(o, a);
  var s = E.create(0, 0, 0);
  E.scale(s, o, 0.25);
  var u = E.create(0, 0, 0);
  E.sub(u, a, s);
  var c = E.create(0, 0, 0);
  E.add(c, i, u);
  var l = E.create(0, 0, 0);
  E.scale(l, o, 0.45), E.sub(c, c, l);
  var d = n2.create(128, 64);
  return d.add(i[0], i[1], i[2], c[0], c[1], c[2], 0.05, !0, !0, 2), er.create("RotateArrow-cylinder", r, d.getCylinders(), function() {
    return r.color;
  }, function() {
    return r.sizeFactor;
  }, function() {
    return "RotateArrow";
  });
}
function Mle(t, e, r, n) {
  var i = wt.createState(256, 128), a = Ele(), o = r.center, s = r.vec, u = E.create(0, 0, 0);
  E.normalize(u, s);
  var c = E.create(0, 0, 0);
  E.scale(c, u, 0.1);
  var l = E.create(0, 0, 0);
  E.sub(l, s, c);
  var d = E.create(0, 0, 0);
  E.add(d, o, l);
  var f = E.create(0, 0, 0), h = E.create(0, 0, 0);
  E.scale(h, u, 0.35), E.sub(f, d, h);
  var m = he.identity(), p = E();
  return E.add(p, f, s), he.targetTo(m, p, f, E.create(1, 0, 0)), he.setTranslation(m, f), i.currentGroup = 0, he.scaleUniformly(m, m, 0.4 * 1.5), wt.addPrimitive(i, m, a), er.create("axes", r, wt.getMesh(i), function() {
    return r.color;
  }, function() {
    return 0.05;
  }, function() {
    return "";
  });
}
O(O(O({}, to.Params), Q7), { color: z.Color(qe.fromRgb(255, 196, 36)), sizeFactor: z.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), O(O(O({}, Vt.Params), Q7), { color: z.Color(Yt.brown) });
var Ple = { create: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n = function(a, o) {
            var s = sr.createMulti("RotateArrow", a, o, xs, Jk);
            return s.setState({ markerActions: Lr.All }), s;
          }(e, function() {
            return Ile;
          }), [4, n.createOrUpdate(t, t).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, t.createOrUpdate(e, e).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Ble = { "element-sphere": function(t, e) {
  return $a("Sphere mesh", t, e, Hx);
} }, iP = O(O({}, a2), { bumpFrequency: z.Numeric(1, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory) }), G8 = { name: "spacefill", label: "Spacefill", description: "Displays atomic/coarse elements as spheres.", factory: function(t, e) {
  return sr.createMulti("Spacefill", t, e, xs, Ble);
}, getParams: function(t, e) {
  var r = z.clone(iP);
  return e.isCoarseGrained && (r.sizeFactor.defaultValue = 2), r;
}, defaultValues: z.getDefaultValues(iP), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(t) {
  return t.elementCount > 0;
} }, Fle = { create: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return (n = G8.factory(e, G8.getParams)).setTheme(r ?? { color: e.colorThemeRegistry.create("element-symbol", { structure: t }), size: e.sizeThemeRegistry.create("physical", { structure: t }) }), [4, n.createOrUpdate(O(O({}, G8.defaultValues), { quality: "auto" }), t).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return t.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: e }), size: r.sizeThemeRegistry.create("physical", { structure: e }) }), [4, t.createOrUpdate({}, e).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Nle = he.fromTranslation(he(), E.create(0.5, 0.5, 0.5)), Rle = Hy(Uy(oO()), Nle), jf = E(), aP = he(), $k = O(O({}, Vt.Params), { alpha: O(O({}, Vt.Params.alpha), { defaultValue: 0.51 }), ignoreLight: O(O({}, Vt.Params.ignoreLight), { defaultValue: !0 }), colorX: z.Color(Yt.red, { isEssential: !0 }), colorY: z.Color(Yt.green, { isEssential: !0 }), colorZ: z.Color(Yt.blue, { isEssential: !0 }), scale: z.Numeric(2, { min: 0.1, max: 5, step: 0.1 }) }), Ole = O(O(O({}, Vt.Params), $k), { pocketColor: z.Color(Yt.red), pocketScale: z.Numeric(4, { min: 0.1, max: 5, step: 0.1 }), x: z.Numeric(10), y: z.Numeric(10), z: z.Numeric(10), center: z.Vec3(E()) }), Lle = O(O({}, Ole), $k), kle = { axes: function(t, e) {
  return Fn(zle, Vt.Utils);
}, mesh: function(t, e) {
  return Fn(Gle, Vt.Utils);
} };
function Gle(t, e, r, n) {
  var i = function(o, s, u) {
    var c = wt.createState(256, 128, u), l = o.gridPocket.fromFractional;
    E.copy(jf, o.ref), E.subScalar(jf, jf, 0.5), he.fromTranslation(aP, jf);
    var d = Hy(Uy(Rle), aP), f = Math.cbrt(o.gridPocket.volume) / 300 * s.pocketScale;
    c.currentGroup = 1, wt.addCage(c, l, d, f, 2, 20);
    var h = Me.fromDimensionsAndTransform(Me(), E.unit, l);
    E.transformMat4(jf, jf, l), Me.translate(h, h, jf), Me.expand(h, h, f);
    var m = wt.getMesh(c);
    return m.setBoundingSphere(h), m;
  }(e, r, n && n.geometry), a = "Grid Pocket Box";
  return er.create(a, e, i, function() {
    return r.pocketColor;
  }, function() {
    return 1;
  }, function() {
    return a;
  });
}
function oP(t, e, r, n) {
  var i = E(), a = he.ofRows([[t, 0, 0, 0], [0, e, 0, 0], [0, 0, r, 0], [0, 0, 0, 1]]), o = he.invert(he.zero(), a);
  return { ref: E.transformMat4(i, n, o), gridPocket: { fromFractional: a, toFractional: o, x: t, y: e, z: r, center: n, volume: t * e * r } };
}
function zle(t, e, r, n) {
  var i = r.scale, a = function(o, s, u) {
    var c = s.gridPocket, l = c.x, d = c.y, f = c.z, h = c.center, m = c.volume, p = wt.createState(512, 256, u), v = Math.cbrt(m) / 300 * o, g = h[0], y = h[1], b = h[2], S = Math.min(l, d, f), _ = E.create(g + S / 3, y, b), x = E.create(g, y + S / 3, b), C = E.create(g, y, b + S / 3), A = { radiusTop: v, radiusBottom: v, radialSegments: 32 };
    return p.currentGroup = 0, Yi(p, h, v, 2), p.currentGroup = 1, Yi(p, _, v, 2), Hi(p, h, _, 1, A), p.currentGroup = 2, Yi(p, x, v, 2), Hi(p, h, x, 1, A), p.currentGroup = 3, Yi(p, C, v, 2), Hi(p, h, C, 1, A), E.scale(_, _, 0.5), E.scale(x, x, 0.5), E.scale(C, C, 0.5), wt.getMesh(p);
  }(i, e, n == null ? void 0 : n.geometry);
  return a.setBoundingSphere(Me.create(E.create(i / 2, i / 2, i / 2), i + i / 4)), er.create("axes", {}, a, function(o) {
    switch (o) {
      case 1:
        return r.colorX;
      case 2:
        return r.colorY;
      case 3:
        return r.colorZ;
      default:
        return Yt.grey;
    }
  }, function() {
    return 1;
  }, function() {
    return "";
  });
}
var Vle = { create: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, s;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return n = function(c, l) {
            return sr.createMulti("Grid Pocket", c, l, sr.StateBuilder, kle);
          }(e, function() {
            return Lle;
          }), i = t.x, a = t.y, o = t.z, s = t.center, [4, n.createOrUpdate(t, oP(i, a, o, s)).run()];
        case 1:
          return u.sent(), [2, n];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o, s;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return i = e.x, a = e.y, o = e.z, s = e.center, [4, t.createOrUpdate(e, oP(i, a, o, s)).run()];
        case 1:
          return u.sent(), [2];
      }
    });
  });
} }, Ule = [2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1], np = { radiusFactor: z.Numeric(1, { min: 0.1, max: 3, step: 0.01 }, { description: "Scale the radius of the membrane layer" }), center: z.Vec3(E()), radius: z.Numeric(1), vec: z.Vec3(E()) }, eG = { "pharmacophore-ball-1": function(t, e) {
  return Fn(Xle, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.All });
  } });
}, "pharmacophore-ball-2": function(t, e) {
  return Fn(Yle, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.All });
  } });
}, "pharmacophore-sphere-1": function(t, e) {
  return Fn(jle, Gu.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.All });
  } });
}, "pharmacophore-sphere-2": function(t, e) {
  return Fn(Zle, Gu.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.All });
  } });
}, "pharmacophore-cylinder": function(t, e) {
  return Fn(Qle, to.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.All });
  } });
}, "pharmacophore-arrowhead": function(t, e) {
  return Fn(Jle, Vt.Utils);
} }, Hle = O(O(O({}, Rr.Params), np), { color: z.Color(Yt.blue), lineSizeAttenuation: z.Boolean(!1), linesSize: z.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: z.Boolean(!1), alpha: z.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), qle = O(O(O({}, Rr.Params), np), { color: z.Color(Yt.blue), lineSizeAttenuation: z.Boolean(!1), linesSize: z.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: z.Boolean(!1), alpha: z.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), Kle = O(O(O({}, Hle), qle), { visuals: z.MultiSelect(["pharmacophore-ball-1", "pharmacophore-ball-2", "pharmacophore-sphere-1", "pharmacophore-sphere-2", "pharmacophore-cylinder", "pharmacophore-arrowhead"], z.objectToOptions(eG)), alpha: z.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) });
function Xle(t, e, r, n) {
  var i = r.radiusFactor, a = r.center, o = i * r.radius, s = Ea.create(128, 64, n == null ? void 0 : n.geometry), u = E.create(0, 0, 0);
  E.add(u, a, E.create(0, 1, 0));
  var c = E.create(0, 0, 0);
  E.add(c, a, E.create(0, 0, 1));
  var l = E.create(0, 0, 0);
  E.add(l, a, E.create(1, 0, 0)), Aa(s, a, u, o, r), Aa(s, a, c, o, r), Aa(s, a, l, o, r);
  var d = E.create(0, 0, 0);
  E.add(d, a, E.create(0, 0.5 * o, 0));
  var f = E.create(0, 0, 0);
  E.add(f, d, E.create(0, Math.sqrt(0.75), 0)), Aa(s, d, f, Math.sqrt(0.75) * o, r);
  var h = E.create(0, 0, 0);
  E.add(h, a, E.create(0, -0.5 * o, 0));
  var m = E.create(0, 0, 0);
  return E.add(m, h, E.create(0, -Math.sqrt(0.75), 0)), Aa(s, h, m, Math.sqrt(0.75) * o, r), d = E.create(0, 0, 0), E.add(d, a, E.create(0.5 * o, 0, 0)), f = E.create(0, 0, 0), E.add(f, d, E.create(Math.sqrt(0.75), 0, 0)), Aa(s, d, f, Math.sqrt(0.75) * o, r), h = E.create(0, 0, 0), E.add(h, a, E.create(-0.5 * o, 0, 0)), m = E.create(0, 0, 0), E.add(m, h, E.create(-Math.sqrt(0.75), 0, 0)), Aa(s, h, m, Math.sqrt(0.75) * o, r), d = E.create(0, 0, 0), E.add(d, a, E.create(0, 0, 0.5 * o)), f = E.create(0, 0, 0), E.add(f, d, E.create(0, 0, Math.sqrt(0.75))), Aa(s, d, f, Math.sqrt(0.75) * o, r), h = E.create(0, 0, 0), E.add(h, a, E.create(0, 0, -0.5 * o)), m = E.create(0, 0, 0), E.add(m, h, E.create(0, 0, -Math.sqrt(0.75))), Aa(s, h, m, Math.sqrt(0.75) * o, r), er.create("pharmacophore-ball-1", r, s.getLines(), function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "pharmacophore";
  });
}
function Yle(t, e, r, n) {
  var i = r.radiusFactor, a = r.center, o = r.radius, s = r.vec, u = i * o, c = E.create(0, 0, 0);
  E.add(c, a, s);
  var l = Ea.create(128, 64, n == null ? void 0 : n.geometry), d = E.create(0, 0, 0);
  E.add(d, c, E.create(0, 1, 0));
  var f = E.create(0, 0, 0);
  E.add(f, c, E.create(0, 0, 1));
  var h = E.create(0, 0, 0);
  E.add(h, c, E.create(1, 0, 0)), Aa(l, c, d, u, r), Aa(l, c, f, u, r), Aa(l, c, h, u, r);
  var m = E.create(0, 0, 0);
  E.add(m, c, E.create(0, 0.5 * u, 0));
  var p = E.create(0, 0, 0);
  E.add(p, m, E.create(0, Math.sqrt(0.75), 0)), Aa(l, m, p, Math.sqrt(0.75) * u, r);
  var v = E.create(0, 0, 0);
  E.add(v, c, E.create(0, -0.5 * u, 0));
  var g = E.create(0, 0, 0);
  return E.add(g, v, E.create(0, -Math.sqrt(0.75), 0)), Aa(l, v, g, Math.sqrt(0.75) * u, r), m = E.create(0, 0, 0), E.add(m, c, E.create(0.5 * u, 0, 0)), p = E.create(0, 0, 0), E.add(p, m, E.create(Math.sqrt(0.75), 0, 0)), Aa(l, m, p, Math.sqrt(0.75) * u, r), v = E.create(0, 0, 0), E.add(v, c, E.create(-0.5 * u, 0, 0)), g = E.create(0, 0, 0), E.add(g, v, E.create(-Math.sqrt(0.75), 0, 0)), Aa(l, v, g, Math.sqrt(0.75) * u, r), m = E.create(0, 0, 0), E.add(m, c, E.create(0, 0, 0.5 * u)), p = E.create(0, 0, 0), E.add(p, m, E.create(0, 0, Math.sqrt(0.75))), Aa(l, m, p, Math.sqrt(0.75) * u, r), v = E.create(0, 0, 0), E.add(v, c, E.create(0, 0, -0.5 * u)), g = E.create(0, 0, 0), E.add(g, v, E.create(0, 0, -Math.sqrt(0.75))), Aa(l, v, g, Math.sqrt(0.75) * u, r), er.create("pharmacophore-ball-2", r, l.getLines(), function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "pharmacophore";
  });
}
function Aa(t, e, r, n, i, a) {
  for (var o = function(b, S, _) {
    E.dot(E.unitY, E.sub(Wle, b, S)) === 0 ? he.targetTo(U1, b, S, E.unitY) : he.targetTo(U1, b, S, E.unitX), he.setTranslation(U1, b), he.mul(U1, U1, he.rotX90);
    var x = Yx({ radius: _, segments: 64 });
    return zy(x, U1);
  }(e, r, n), 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], f = 3 * s[c + 1], h = u[d], m = u[d + 1], p = u[d + 2], v = u[f], g = u[f + 1], y = u[f + 2];
    t.add(h, m, p, v, g, y, 0);
  }
}
O(O(O({}, Gu.Params), np), { sizeFactor: z.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: z.Color(Yt.green), alpha: z.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), O(O(O({}, Gu.Params), np), { sizeFactor: z.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: z.Color(Yt.brown), alpha: z.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), O(O(O({}, to.Params), np), { color: z.Color(Yt.brown), sizeFactor: z.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), O(O(O({}, Vt.Params), np), { color: z.Color(Yt.brown) });
var U1 = he(), Wle = E();
function tG(t, e, r, n) {
  t.add(e[0], e[1], e[2], n);
}
function jle(t, e, r, n) {
  var i = r.center, a = r.radius, o = r.radiusFactor, s = i2.create(128, 64);
  return tG(s, i, 0, 0), er.create("pharmacophore-sphere-1", O(O({}, r), { sizeFactor: 0.1 * r.radius }), s.getSpheres(), function() {
    return r.color;
  }, function() {
    return a * o / 2;
  }, function() {
    return "pharmacophore";
  });
}
function Zle(t, e, r, n) {
  var i = r.center, a = r.radius, o = r.vec, s = r.radiusFactor, u = E.create(0, 0, 0);
  E.add(u, i, o);
  var c = i2.create(128, 64);
  return tG(c, u, 0, 1), er.create("pharmacophore-sphere-2", O(O({}, r), { sizeFactor: 0.1 * r.radius }), c.getSpheres(), function() {
    return r.color;
  }, function() {
    return a * s / 2;
  }, function() {
    return "pharmacophore";
  });
}
function Qle(t, e, r, n) {
  var i = r.center, a = r.vec, o = E.create(0, 0, 0);
  E.normalize(o, a);
  var s = E.create(0, 0, 0);
  E.scale(s, o, 0.25);
  var u = E.create(0, 0, 0);
  E.sub(u, a, s);
  var c = E.create(0, 0, 0);
  E.add(c, i, u);
  var l = E.create(0, 0, 0);
  E.scale(l, o, 0.3), E.sub(c, c, l);
  var d = n2.create(128, 64);
  return d.add(i[0], i[1], i[2], c[0], c[1], c[2], 0.025, !0, !0, 2), er.create("pharmacophore-cylinder", r, d.getCylinders(), function() {
    return r.color;
  }, function() {
    return r.sizeFactor;
  }, function() {
    return "pharmacophore";
  });
}
function Jle(t, e, r, n) {
  var i = r.center, a = r.vec, o = E.create(0, 0, 0);
  E.normalize(o, a);
  var s = E.create(0, 0, 0);
  E.scale(s, o, 0.25);
  var u = E.create(0, 0, 0);
  E.sub(u, a, s);
  var c = E.create(0, 0, 0);
  E.add(c, i, u);
  var l = E.create(0, 0, 0), d = E.create(0, 0, 0);
  E.scale(d, o, 0.3), E.sub(l, c, d);
  var f = E.create(0, 0, 0), h = E.create(1, 2, l[2] - (o[0] * (1 - l[0]) + o[1] * (2 - l[1])) / o[2]);
  E.sub(f, h, l), E.normalize(f, f);
  var m = E.create(0, 0, 0);
  E.scale(m, f, 0.3);
  var p = E.create(0, 0, 0);
  E.add(p, l, m);
  var v = E.create(0, 0, 0);
  E.sub(v, p, l);
  var g = E.create(0, 0, 0), y = E.create(0, 0, 0);
  E.scale(y, v, Math.cos(120 * Math.PI / 180));
  var b = E.create(0, 0, 0);
  E.cross(b, o, v), E.scale(b, b, Math.sin(120 * Math.PI / 180));
  var S = E.create(0, 0, 0);
  E.scale(S, o, E.dot(o, v) * (1 - Math.cos(120 * Math.PI / 180))), E.add(g, y, b), E.add(g, g, S), E.add(g, g, l);
  var _ = E.create(0, 0, 0);
  y = E.create(0, 0, 0), E.scale(y, v, Math.cos(240 * Math.PI / 180)), b = E.create(0, 0, 0), E.cross(b, o, v), E.scale(b, b, Math.sin(240 * Math.PI / 180)), S = E.create(0, 0, 0), E.scale(S, o, E.dot(o, v) * (1 - Math.cos(240 * Math.PI / 180))), E.add(_, y, b), E.add(_, _, S), E.add(_, _, l);
  var x = wt.createState(128, 64), C = function(I) {
    return iO(I, Ule);
  }([c[0], c[1], c[2], p[0], p[1], p[2], g[0], g[1], g[2], _[0], _[1], _[2]]), A = he.ofRows([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]), w = he.invert(he.zero(), A);
  return wt.addPrimitive(x, w, C), er.create("axes", {}, wt.getMesh(x), function() {
    return r.color;
  }, function() {
    return 0.15;
  }, function() {
    return "";
  });
}
var $le = { create: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n = function(a, o) {
            var s = sr.createMulti("Pharmacophore", a, o, xs, eG);
            return s.setState({ markerActions: Lr.All }), s;
          }(e, function() {
            return Kle;
          }), [4, n.createOrUpdate(t, t).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, t.createOrUpdate(e, e).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} };
function J7(t, e) {
  var r, n, i, a, o, s, u, c, l = t.defaultProps, d = t.createGeometry, f = t.createLocationIterator, h = t.getLoci, m = t.eachLocation, p = t.setUpdateState, v = t.mustRecreate, g = t.dispose, y = t.geometryUtils, b = y.updateValues, S = y.updateBoundingSphere, _ = y.updateRenderableState, x = y.createPositionIterator, C = Cc.create(), A = Object.assign({}, l), w = su.createEmpty(), I = -1;
  function P(T) {
    if (C.createNew) {
      if (u = f(a), !T) throw new Error("expected geometry to be given");
      r = function(F, N, R, L, V, U) {
        var H = Ia.getUtils(N), K = H.createValues, X = H.createRenderableState, Y = K(N, ox(), R, L, V), Q = X(V);
        return eh(N.kind, Y, Q, U);
      }(0, T, u, i, n, e), c = x(T, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (u.reset(), C.createGeometry) {
        if (!T) throw new Error("expected geometry to be given");
        G.updateIfChanged(r.values.drawCount, Ia.getDrawCount(T)), G.updateIfChanged(r.values.uVertexCount, Ia.getVertexCount(T));
      }
      (C.updateTransform || C.createGeometry) && (S(r.values, T || s), c = x(T || s, r.values)), C.updateSize && "uSize" in r.values && Bl(u, i.size, r.values), C.updateColor && vs(u, c, i.color, r.values), b(r.values, n), _(r.state, n);
    }
    A = n, w = i, o = a, T && (s = T, I += 1);
  }
  function M(T, F) {
    return qo(T) ? F(Se.ofBounds(0, u.groupCount * u.instanceCount)) : m(T, o, A, F);
  }
  return { get groupCount() {
    return u ? u.count : 0;
  }, get renderObject() {
    return r;
  }, get geometryVersion() {
    return I;
  }, createOrUpdate: function(T, F, N, R) {
    return N === void 0 && (N = {}), _e(this, 0, void 0, function() {
      var L;
      return ye(this, function(V) {
        return function(U, H, K) {
          if (!K && !o) throw new Error("missing volume");
          n = Object.assign({}, A, H), i = U, a = K, Cc.reset(C), r && o && or.areEquivalent(a, o) || (C.createNew = !0), C.createNew ? C.createGeometry = !0 : (p(C, K, n, A, i, w), El.areEqual(U.color, w.color) || (C.updateColor = !0), C.createGeometry && (C.updateColor = !0));
        }(F, N, R || o), C.createGeometry ? [2, U9(L = d(T, a, i, n, s)) ? L.then(P) : P(L)] : (P(), [2]);
      });
    });
  }, getLoci: function(T) {
    return r ? h(T, o, A, r.id) : Dn;
  }, mark: function(T, F) {
    return nr.mark(r, T, F, M);
  }, setVisibility: function(T) {
    nr.setVisibility(r, T);
  }, setAlphaFactor: function(T) {
    nr.setAlphaFactor(r, T);
  }, setPickable: function(T) {
    nr.setPickable(r, T);
  }, setColorOnly: function(T) {
    nr.setColorOnly(r, T);
  }, setTransform: function(T, F) {
    nr.setTransform(r, T, F);
  }, setOverpaint: function(T) {
    return nr.setOverpaint(r, T, M, !0);
  }, setTransparency: function(T) {
    return nr.setTransparency(r, T, M, !0);
  }, setSubstance: function(T) {
    return nr.setSubstance(r, T, M, !0);
  }, setClipping: function(T) {
    return nr.setClipping(r, T, M, !0);
  }, destroy: function() {
    g == null || g(s), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: v };
}
function sP(t, e, r, n, i) {
  var a, o, s, u, c = 0, l = e.webgl, d = new Si(), f = new sr.GeometryState(), h = Nl(), m = [], p = sr.createState(), v = su.createEmpty();
  return { label: t, get groupCount() {
    return a ? a.groupCount : 0;
  }, get props() {
    return u;
  }, get params() {
    return s;
  }, get state() {
    return p;
  }, get theme() {
    return v;
  }, get geometryVersion() {
    return f.version;
  }, renderObjects: m, updated: d, createOrUpdate: function(g, y) {
    var b = this;
    g === void 0 && (g = {}), y && y !== o && (s = r(e, y), o = y, u || (u = z.getDefaultValues(s)));
    var S = g7(Object.assign({}, u, g), o);
    return Object.assign(u, g, S), tr.create("Creating or updating VolumeRepresentation", function(_) {
      return _e(b, 0, void 0, function() {
        var x, C;
        return ye(this, function(A) {
          switch (A.label) {
            case 0:
              return a ? !((C = a.mustRecreate) === null || C === void 0) && C.call(a, o, u, l) && (a.destroy(), a = n(h, o, u, l)) : a = n(h, o, u, l), (x = a.createOrUpdate({ webgl: l, runtime: _ }, v, u, y)) ? [4, x] : [3, 2];
            case 1:
              A.sent(), A.label = 2;
            case 2:
              return m.length = 0, a && a.renderObject && (m.push(a.renderObject), f.add(a.renderObject.id, a.geometryVersion)), f.snapshot(), d.next(c++), [2];
          }
        });
      });
    });
  }, setState: function(g) {
    g.visible !== void 0 && a && a.setVisibility(g.visible), g.alphaFactor !== void 0 && a && a.setAlphaFactor(g.alphaFactor), g.pickable !== void 0 && a && a.setPickable(g.pickable), g.overpaint !== void 0 && a && a.setOverpaint(g.overpaint), g.transparency !== void 0 && a && a.setTransparency(g.transparency), g.transform !== void 0 && a && a.setTransform(g.transform), sr.updateState(p, g);
  }, setTheme: function(g) {
    v = g;
  }, getLoci: function(g) {
    return g === void 0 ? i(o, u) : a ? a.getLoci(g) : Dn;
  }, mark: function(g, y) {
    return !!a && a.mark(g, y);
  }, destroy: function() {
    a && a.destroy();
  } };
}
O({}, ft.Params);
var ede = `
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
}
`, tde = O(O({}, la), { tTexture: zt("texture", "rgba", "float", "nearest") }), $s = "histopyramid-sum";
function rde(t, e) {
  if (t.namedComputeRenderables[$s]) {
    var r = t.namedComputeRenderables[$s].values;
    G.update(r.tTexture, e), t.namedComputeRenderables[$s].update();
  } else t.namedComputeRenderables[$s] = function(n, i) {
    var a = O(O({}, ua), { tTexture: G.create(i) }), o = O({}, tde), s = Nn("sum", eo, ede, {}, { 0: "ivec4" }), u = Zi(n, "triangles", s, o, a);
    return Qi(u, a);
  }(t, e);
  return t.namedComputeRenderables[$s];
}
var Ov = new Uint8Array(4), uP = new Int32Array(4), Lv, kv, nde = `
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
}
`, ide = O(O({}, la), { tInputLevel: zt("texture", "rgba", "float", "nearest"), tPreviousLevel: zt("texture", "rgba", "float", "nearest"), uSize: Ie("f"), uTexSize: Ie("f"), uFirst: Ie("b") }), Rd = "histogram-pyramid";
function ade(t, e, r) {
  if (t.namedComputeRenderables[Rd]) {
    var n = t.namedComputeRenderables[Rd].values;
    G.update(n.tInputLevel, e), G.update(n.tPreviousLevel, r), t.namedComputeRenderables[Rd].update();
  } else t.namedComputeRenderables[Rd] = function(i, a, o) {
    var s = O(O({}, ua), { tInputLevel: G.create(a), tPreviousLevel: G.create(o), uSize: G.create(0), uTexSize: G.create(0), uFirst: G.create(!0) }), u = O({}, ide), c = Nn("reduction", eo, nde, {}, { 0: "ivec4" }), l = Zi(i, "triangles", c, u, s);
    return Qi(l, s);
  }(t, e, r);
  return t.namedComputeRenderables[Rd];
}
function ode(t, e) {
  var r = Math.pow(2, e), n = "level".concat(e), i = t.isWebGL2 ? dy(n, t, "image-int32", "alpha", "int", "nearest") : dy(n, t, "image-uint8", "rgba", "ubyte", "nearest");
  i.define(r, r);
  var a = function(o, s) {
    var u = "".concat(Rd, "-").concat(o);
    return s.namedFramebuffers[u];
  }(n, t);
  return a || (a = rG(n, t), i.attachFramebuffer(a, 0)), { texture: i, framebuffer: a };
}
function rG(t, e) {
  var r = "".concat(Rd, "-").concat(t);
  return e.namedFramebuffers[r] || (e.namedFramebuffers[r] = e.resources.framebuffer()), e.namedFramebuffers[r];
}
function dy(t, e, r, n, i, a) {
  var o = "".concat(Rd, "-").concat(t);
  return e.namedTextures[o] || (e.namedTextures[o] = e.resources.texture(r, n, i, a)), e.namedTextures[o];
}
function sde(t, e, r, n) {
  var i = t.gl, a = e.getWidth();
  if (a !== e.getHeight() || !function(b) {
    return b !== 0 && !(b & b - 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 = t.isWebGL2 ? dy("pyramid", t, "image-int32", "alpha", "int", "nearest") : dy("pyramid", t, "image-uint8", "rgba", "ubyte", "nearest");
  l.define(u, c);
  var d = rG("pyramid", t);
  l.attachFramebuffer(d, 0), i.viewport(0, 0, u, c), ar(i) ? i.clearBufferiv(i.COLOR, 0, [0, 0, 0, 0]) : i.clear(i.COLOR_BUFFER_BIT);
  for (var f = [], h = 0; h < o; ++h) f.push(ode(t, h));
  var m = ade(t, e, f[0].texture);
  t.state.currentRenderItemId = -1, function(b) {
    var S = b.gl, _ = b.state;
    _.disable(S.CULL_FACE), _.disable(S.BLEND), _.disable(S.DEPTH_TEST), _.enable(S.SCISSOR_TEST), _.depthMask(!1), _.colorMask(!0, !0, !0, !0), _.clearColor(0, 0, 0, 0);
  }(t);
  var p = 0;
  for (h = 0; h < o; h++) {
    var v = o - 1 - h;
    f[v].framebuffer.bind();
    var g = Math.pow(2, v);
    G.update(m.values.uSize, Math.pow(2, h + 1) / s), G.update(m.values.uTexSize, g), G.updateIfChanged(m.values.uFirst, h === 0), h > 0 && (G.update(m.values.tPreviousLevel, f[o - h].texture), m.update()), t.state.currentRenderItemId = -1, i.viewport(0, 0, g, g), i.scissor(0, 0, g, g), ar(i) ? i.clearBufferiv(i.COLOR, 0, [0, 0, 0, 0]) : i.clear(i.COLOR_BUFFER_BIT), i.scissor(0, 0, n[0], n[1]), m.render(), l.bind(0), i.copyTexSubImage2D(i.TEXTURE_2D, 0, p, 0, 0, 0, g, g), l.unbind(0), p += g;
  }
  i.finish();
  var y = Math.max(1, function(b, S) {
    var _ = b.gl, x = b.resources, C = rde(b, S);
    b.state.currentRenderItemId = -1, b.namedFramebuffers[$s] || (b.namedFramebuffers[$s] = x.framebuffer());
    var A = b.namedFramebuffers[$s];
    return b.namedTextures[$s] || (b.namedTextures[$s] = ar(_) ? x.texture("image-int32", "rgba", "int", "nearest") : x.texture("image-uint8", "rgba", "ubyte", "nearest"), b.namedTextures[$s].define(1, 1)), b.namedTextures[$s].attachFramebuffer(A, 0), function(w) {
      var I = w.gl, P = w.state;
      P.disable(I.CULL_FACE), P.disable(I.BLEND), P.disable(I.DEPTH_TEST), P.disable(I.SCISSOR_TEST), P.depthMask(!1), P.colorMask(!0, !0, !0, !0), P.clearColor(0, 0, 0, 0);
    }(b), _.viewport(0, 0, 1, 1), C.render(), _.finish(), b.readPixels(0, 0, 1, 1, ar(_) ? uP : Ov), b.unbindFramebuffer(), ar(_) ? uP[0] : sx(Ov[0], Ov[1], Ov[2]);
  }(t, f[0].texture));
  return { pyramidTex: l, count: y, height: Math.ceil(y / Math.pow(2, o)), levels: o, scale: r };
}
function ude() {
  if (Lv !== void 0) return Lv;
  for (var t = (Lv = qi(256, 1, Uint8Array)).array, e = 0, r = hp.length; e < r; ++e) t[e] = hp[e].length / 3;
  return Lv;
}
function cde() {
  if (kv !== void 0) return kv;
  for (var t = (kv = qi(4096, 1, Uint8Array)).array, e = 0, r = hp.length; e < r; ++e) for (var n = 0; n < 16; ++n) n < hp[e].length ? t[16 * e + n] = hp[e][n] : t[16 * e + n] = 255;
  return kv;
}
var lde = `
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)));
}
`, dde = `
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);
}
`, fde = O(O({}, la), { tTriCount: zt("image-uint8", "alpha", "ubyte", "nearest"), tVolumeData: zt("texture", "rgba", "ubyte", "nearest"), uIsoValue: Ie("f"), uGridDim: Ie("v3"), uGridTexDim: Ie("v3"), uScale: Ie("v2") }), Du = "active-voxels";
function pde(t, e, r, n, i, a) {
  if (t.namedComputeRenderables[Du]) {
    var o = t.namedComputeRenderables[Du].values;
    G.update(o.uQuadScale, a), G.update(o.tVolumeData, e), G.updateIfChanged(o.uIsoValue, i), G.update(o.uGridDim, r), G.update(o.uGridTexDim, n), G.update(o.uScale, a), t.namedComputeRenderables[Du].update();
  } else t.namedComputeRenderables[Du] = function(s, u, c, l, d, f) {
    var h = O(O({}, ua), { tTriCount: G.create(ude()), uQuadScale: G.create(f), tVolumeData: G.create(u), uIsoValue: G.create(d), uGridDim: G.create(c), uGridTexDim: G.create(l), uScale: G.create(f) }), m = O({}, fde), p = Nn("active-voxels", eo, dde), v = Zi(s, "triangles", p, m, h);
    return Qi(v, h);
  }(t, e, r, n, i, a);
  return t.namedComputeRenderables[Du];
}
var hde = O(O({}, la), { tTriIndices: zt("image-uint8", "alpha", "ubyte", "nearest"), tActiveVoxelsPyramid: zt("texture", "rgba", "float", "nearest"), tActiveVoxelsBase: zt("texture", "rgba", "float", "nearest"), tVolumeData: zt("texture", "rgba", "ubyte", "nearest"), uIsoValue: Ie("f"), uSize: Ie("f"), uLevels: Ie("f"), uCount: Ie("f"), uInvert: Ie("b"), uGridDim: Ie("v3"), uGridTexDim: Ie("v3"), uGridTransform: Ie("m4"), uScale: Ie("v2"), dPackedGroup: Gt("boolean"), dAxisOrder: Gt("string", ["012", "021", "102", "120", "201", "210"]) }), Od = "isosurface";
function mde(t, e, r, n, i, a, o, s, u, c, l, d, f, h) {
  if (t.namedComputeRenderables[Od]) {
    var m = t.namedComputeRenderables[Od].values;
    G.update(m.tActiveVoxelsPyramid, e), G.update(m.tActiveVoxelsBase, r), G.update(m.tVolumeData, n), G.updateIfChanged(m.uIsoValue, s), G.updateIfChanged(m.uSize, Math.pow(2, u)), G.updateIfChanged(m.uLevels, u), G.updateIfChanged(m.uCount, l), G.updateIfChanged(m.uInvert, d), G.update(m.uGridDim, i), G.update(m.uGridTexDim, a), G.update(m.uGridTransform, o), G.update(m.uScale, c), G.update(m.dPackedGroup, f), G.updateIfChanged(m.dAxisOrder, h.join("")), t.namedComputeRenderables[Od].update();
  } else t.namedComputeRenderables[Od] = function(p, v, g, y, b, S, _, x, C, A, w, I, P, M) {
    var T = O(O({}, ua), { tTriIndices: G.create(cde()), tActiveVoxelsPyramid: G.create(v), tActiveVoxelsBase: G.create(g), tVolumeData: G.create(y), uIsoValue: G.create(x), uSize: G.create(Math.pow(2, C)), uLevels: G.create(C), uCount: G.create(w), uInvert: G.create(I), uGridDim: G.create(b), uGridTexDim: G.create(S), uGridTransform: G.create(_), uScale: G.create(A), dPackedGroup: G.create(P), dAxisOrder: G.create(M.join("")) }), F = O({}, hde), N = Nn("isosurface", eo, lde, { drawBuffers: "required" }), R = Zi(p, "triangles", N, F, T);
    return Qi(R, T);
  }(t, e, r, n, i, a, o, s, u, c, l, d, f, h);
  return t.namedComputeRenderables[Od];
}
function gde(t, e, r, n, i, a, o, s, u, c, l, d, f) {
  var h = function(p, v, g, y, b, S) {
    var _ = p.gl, x = p.resources, C = v.getWidth(), A = v.getHeight();
    p.namedFramebuffers[Du] || (p.namedFramebuffers[Du] = x.framebuffer());
    var w = p.namedFramebuffers[Du];
    w.bind(), p.namedTextures[Du] || (p.namedTextures[Du] = x.texture("image-uint8", "rgba", "ubyte", "nearest"));
    var I = p.namedTextures[Du];
    I.define(C, A);
    var P = pde(p, v, g, y, b, S);
    return p.state.currentRenderItemId = -1, I.attachFramebuffer(w, 0), function(M) {
      var T = M.gl, F = M.state;
      F.disable(T.CULL_FACE), F.disable(T.BLEND), F.disable(T.DEPTH_TEST), F.enable(T.SCISSOR_TEST), F.depthMask(!1), F.colorMask(!0, !0, !0, !0), F.clearColor(0, 0, 0, 0);
    }(p), _.viewport(0, 0, C, A), _.scissor(0, 0, C, A), _.clear(_.COLOR_BUFFER_BIT), _.scissor(0, 0, y[0], y[1]), P.render(), _.finish(), I;
  }(t, e, r, n, o, i), m = function(p, v, g, y, b, S, _, x, C, A, w, I, P, M) {
    var T = p.extensions.drawBuffers;
    if (!T) throw new Error("need WebGL draw buffers");
    var F = p.gl, N = p.resources, R = p.extensions, L = y.pyramidTex, V = y.height, U = y.levels, H = y.scale, K = y.count, X = L.getWidth();
    p.namedFramebuffers[Od] || (p.namedFramebuffers[Od] = N.framebuffer());
    var Y = p.namedFramebuffers[Od];
    ar(F) ? (I || (I = R.colorBufferHalfFloat && R.textureHalfFloat ? N.texture("image-float16", "rgba", "fp16", "nearest") : N.texture("image-float32", "rgba", "float", "nearest")), P || (P = N.texture("image-uint8", "rgba", "ubyte", "nearest")), M || (M = R.colorBufferHalfFloat && R.textureHalfFloat ? N.texture("image-float16", "rgba", "fp16", "nearest") : N.texture("image-float32", "rgba", "float", "nearest"))) : (I || (I = N.texture("image-float32", "rgba", "float", "nearest")), P || (P = N.texture("image-float32", "rgba", "float", "nearest")), M || (M = N.texture("image-float32", "rgba", "float", "nearest"))), I.define(X, V), P.define(X, V), M.define(X, V), I.attachFramebuffer(Y, 0), P.attachFramebuffer(Y, 1), M.attachFramebuffer(Y, 2);
    var Q = mde(p, L, v, g, b, S, _, x, U, H, K, C, A, w);
    return p.state.currentRenderItemId = -1, Y.bind(), T.drawBuffers([T.COLOR_ATTACHMENT0, T.COLOR_ATTACHMENT1, T.COLOR_ATTACHMENT2]), function(J) {
      var te = J.gl, W = J.state;
      W.disable(te.CULL_FACE), W.disable(te.BLEND), W.disable(te.DEPTH_TEST), W.disable(te.SCISSOR_TEST), W.depthMask(!1), W.colorMask(!0, !0, !0, !0), W.clearColor(0, 0, 0, 0);
    }(p), F.viewport(0, 0, X, V), F.clear(F.COLOR_BUFFER_BIT), Q.render(), F.finish(), { vertexTexture: I, groupTexture: P, normalTexture: M, vertexCount: K };
  }(t, h, e, sde(t, h, i, n), r, n, a, o, s, u, c, l, d, f);
  return m;
}
var nG = { isoValue: or.IsoValueParam }, Cm = 1;
function z8(t, e) {
  return !(t.grid.cells.data.length < Math.pow(10, 3)) && Y3(t.grid.cells.space.dimensions, Cm).powerOfTwoSize <= e.maxTextureSize / 2;
}
function vde(t, e, r, n) {
  return r.tryUseGpu && n && function(i) {
    return i.extensions.colorBufferFloat && i.extensions.textureFloat && i.extensions.drawBuffers;
  }(n) && z8(e, n) ? function(i) {
    return J7({ defaultProps: z.getDefaultValues(r9), createGeometry: bde, createLocationIterator: function(a) {
      return gi(a.grid.cells.data.length, 1, 1, function() {
        return Sc;
      });
    }, getLoci: $7, eachLocation: e9, setUpdateState: function(a, o, s, u) {
      or.IsoValue.areSame(s.isoValue, u.isoValue, o.grid.stats) || (a.createGeometry = !0);
    }, geometryUtils: sf.Utils, mustRecreate: function(a, o, s) {
      return !o.tryUseGpu || !s || !z8(a, s);
    }, dispose: function(a) {
      a.vertexTexture.ref.value.destroy(), a.groupTexture.ref.value.destroy(), a.normalTexture.ref.value.destroy(), a.doubleBuffer.destroy();
    } }, i);
  }(t) : function(i) {
    return J7({ defaultProps: z.getDefaultValues(r9), createGeometry: yde, createLocationIterator: function(a) {
      return gi(a.grid.cells.data.length, 1, 1, function() {
        return Sc;
      });
    }, getLoci: $7, eachLocation: e9, setUpdateState: function(a, o, s, u) {
      or.IsoValue.areSame(s.isoValue, u.isoValue, o.grid.stats) || (a.createGeometry = !0);
    }, geometryUtils: Vt.Utils, mustRecreate: function(a, o, s) {
      return o.tryUseGpu && !!s && z8(a, s);
    } }, i);
  }(t);
}
function cP(t, e) {
  return or.Isosurface.Loci(t, e.isoValue);
}
function $7(t, e, r, n) {
  var i = t.objectId, a = t.groupId;
  return n === i ? or.Cell.Loci(e, Se.ofSingleton(a)) : Dn;
}
function e9(t, e, r, n) {
  return function(i, a, o, s) {
    var u = !1;
    if (or.isLoci(i)) {
      if (!or.areEquivalent(i.volume, a)) return !1;
      s(Se.ofLength(a.grid.cells.data.length)) && (u = !0);
    } else if (or.Isosurface.isLoci(i)) {
      if (!or.areEquivalent(i.volume, a)) return !1;
      if (o) {
        if (!or.IsoValue.areSame(i.isoValue, o, a.grid.stats)) return !1;
        s(Se.ofLength(a.grid.cells.data.length)) && (u = !0);
      } else for (var c = a.grid, l = c.stats, d = c.cells.data, f = l.sigma, h = or.IsoValue.toAbsolute(i.isoValue, l).absoluteValue, m = 0, p = d.length; m < p; ++m) jn(h, d[m], f) && s(Se.ofSingleton(m)) && (u = !0);
    } else if (or.Cell.isLoci(i)) {
      if (!or.areEquivalent(i.volume, a)) return !1;
      Se.is(i.indices) ? s(i.indices) && (u = !0) : Ge.forEach(i.indices, function(v) {
        s(Se.ofSingleton(v)) && (u = !0);
      });
    }
    return u;
  }(t, e, r.isoValue, n);
}
function yde(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, s;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return t.runtime.update({ message: "Marching cubes..." }), a = xc(new Int32Array(e.grid.cells.data.length)), [4, Xk({ isoLevel: or.IsoValue.toAbsolute(n.isoValue, e.grid.stats).absoluteValue, scalarField: e.grid.cells, idField: Qn.create(e.grid.cells.space, Qn.Data1(a)) }, i).runAsChild(t.runtime)];
        case 1:
          return o = u.sent(), s = Lo.getGridToCartesianTransform(e.grid), Vt.transform(o, s), t.webgl && !t.webgl.isWebGL2 && Vt.uniformTriangleGroup(o, !1), o.setBoundingSphere(or.getBoundingSphere(e)), [2, o];
      }
    });
  });
}
var t9, r9 = O(O(O(O({}, Vt.Params), sf.Params), nG), { quality: O(O({}, Vt.Params.quality), { isEssential: !1 }), tryUseGpu: z.Boolean(!0) });
function bde(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, s, u, c, l, d, f, h, m, p, v, g, y, b;
    return ye(this, function(S) {
      if (!t.webgl) throw new Error("webgl context required to create volume isosurface texture-mesh");
      return e.grid.cells.data.length <= 1 ? [2, sf.createEmpty(i)] : (a = e.grid.stats, o = a.max, s = a.min, u = o - s, c = or.IsoValue.toAbsolute(n.isoValue, e.grid.stats).absoluteValue, l = (c - s) / u, d = t9.get(e, t.webgl), f = d.texture, h = d.gridDimension, m = d.gridTexDim, p = d.gridTexScale, v = d.transform, g = e.grid.cells.space.axisOrderSlowToFast, y = i == null ? void 0 : i.doubleBuffer.get(), b = gde(t.webgl, f, h, m, p, v, l, c < 0, !1, g, y == null ? void 0 : y.vertex, y == null ? void 0 : y.group, y == null ? void 0 : y.normal), [2, sf.create(b.vertexCount, 1, b.vertexTexture, b.groupTexture, b.normalTexture, or.getBoundingSphere(e), i)]);
    });
  });
}
function _de(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, s;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return t.runtime.update({ message: "Marching cubes..." }), a = xc(new Int32Array(e.grid.cells.data.length)), [4, Yk({ isoLevel: or.IsoValue.toAbsolute(n.isoValue, e.grid.stats).absoluteValue, scalarField: e.grid.cells, idField: Qn.create(e.grid.cells.space, Qn.Data1(a)) }, i).runAsChild(t.runtime)];
        case 1:
          return o = u.sent(), s = Lo.getGridToCartesianTransform(e.grid), Rr.transform(o, s), o.setBoundingSphere(or.getBoundingSphere(e)), [2, o];
      }
    });
  });
}
(function(t) {
  var e = "volume-isosurface-texture";
  t.descriptor = ku({ name: e }), t.get = function(r, n) {
    var i = n.resources, a = Lo.getGridToCartesianTransform(r.grid), o = E.clone(r.grid.cells.space.dimensions), s = Y3(o, Cm), u = s.width, c = s.height, l = s.powerOfTwoSize, d = E.create(u, c, 0), f = ze.create(u / l, c / l);
    if (l > n.maxTextureSize / 2) throw new Error("volume too large for gpu isosurface extraction");
    if (!r._propertyData[e]) {
      r._propertyData[e] = i.texture("image-uint8", "alpha", "ubyte", "linear");
      var h = r._propertyData[e];
      h.define(l, l), h.load(function(m, p, v) {
        var g = m.grid, y = g.cells, b = y.space, S = y.data, _ = g.stats, x = _.max, C = _.min, A = b.dimensions, w = b.dataOffset, I = Y3(A, v), P = I.width, M = I.height, T = new Uint8Array(P * M * 1), F = { array: T, width: P, height: M }, N = x - C, R = A[0], L = A[1], V = A[2], U = R + v, H = L + v;
        E(), E();
        for (var K = 0; K < V; ++K) for (var X = 0; X < L; ++X) for (var Y = 0; Y < R; ++Y) {
          var Q = Math.floor(K * U % P / U), J = 1 * (Math.floor(K * U / P) * H * P + X * P + (Q * U + Y)), te = w(Y, X, K);
          T[J] = Math.round((S[te] - C) / N * 255);
        }
        return F;
      }(r, 0, Cm), !0), r.customProperties.add(t.descriptor), r.customProperties.assets(t.descriptor, [{ dispose: function() {
        return h.destroy();
      } }]);
    }
    return o[0] += Cm, o[1] += Cm, { texture: r._propertyData[e], transform: a, gridDimension: o, gridTexDim: d, gridTexScale: f };
  };
})(t9 || (t9 = {}));
var iG = O(O(O({}, Rr.Params), nG), { quality: O(O({}, Rr.Params.quality), { isEssential: !1 }), sizeFactor: z.Numeric(3, { min: 0, max: 10, step: 0.1 }) });
function xde(t) {
  return J7({ defaultProps: z.getDefaultValues(iG), createGeometry: _de, createLocationIterator: function(e) {
    return gi(e.grid.cells.data.length, 1, 1, function() {
      return Sc;
    });
  }, getLoci: $7, eachLocation: e9, setUpdateState: function(e, r, n, i) {
    or.IsoValue.areSame(n.isoValue, i.isoValue, r.grid.stats) || (e.createGeometry = !0);
  }, geometryUtils: Rr.Utils }, t);
}
var _l, n9, za, i9, aG = { solid: function(t, e) {
  return sP("Isosurface mesh", t, e, vde, cP);
}, wireframe: function(t, e) {
  return sP("Isosurface wireframe", t, e, xde, cP);
} }, oG = O(O(O({}, r9), iG), { visuals: z.MultiSelect(["solid"], z.objectToOptions(aG)), bumpFrequency: z.Numeric(1, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), alpha: z.Numeric(0.12, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }) });
function Sde(t, e) {
  return sr.createMulti("Isosurface", t, e, sr.StateBuilder, aG);
}
function lP(t) {
  return t === za.Float32 ? 4 : t === za.Int16 || t === za.Uint16 ? 2 : 1;
}
function Cde(t, e, r, n) {
  return r === void 0 && (r = 0), t === za.Float32 ? new Float32Array(e, r, n) : t === za.Int16 ? new Int16Array(e, r, n) : t === za.Uint16 ? new Uint16Array(e, r, n) : new Int8Array(e, r, n);
}
function Ade(t, e, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(o) {
      switch (o.label) {
        case 0:
          return [4, e.readBuffer(r, t.readBuffer, n, i)];
        case 1:
          return o.sent(), t.elementByteSize > 1 && (a !== void 0 && a !== _l.IsNativeEndianLittle || !_l.IsNativeEndianLittle) && _l.flipByteOrder(t.readBuffer, t.valuesBuffer, n, t.elementByteSize, i), [2, t.values];
      }
    });
  });
}
function wde(t) {
  return _e(this, 0, void 0, function() {
    var e, r, n, i, a, o;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return [4, t.readBuffer(0, 1024)];
        case 1:
          if (e = s.sent().buffer, (r = String.fromCharCode(e.readUInt8(208), e.readUInt8(209), e.readUInt8(210), e.readUInt8(211))) !== "MAP ") throw new Error('ccp4 format error, missing "MAP " string');
          return n = [e.readUInt8(212), e.readUInt8(213)], i = !1, n[0] === 68 && n[1] === 65 ? i = !0 : n[0] === 17 && n[1] === 17 ? i = !1 : e.readInt32LE(12) <= 16 && (i = !0), a = i ? function(u) {
            return e.readInt32LE(4 * u);
          } : function(u) {
            return e.readInt32BE(4 * u);
          }, o = i ? function(u) {
            return e.readFloatLE(4 * u);
          } : function(u) {
            return e.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: r, MACHST: n, ARMS: o(54) }, littleEndian: i }];
      }
    });
  });
}
function sG(t) {
  switch (t) {
    case 0:
      return za.Int8;
    case 1:
      return za.Int16;
    case 2:
      return za.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:
      za.Uint16;
    case 16:
      throw new Error("mode 16 unsupported, unsigned char * 3 (for rgb data, non-standard)");
  }
  throw new Error("unknown mode '".concat(t, "'"));
}
function uG(t) {
  return t.userFlag1 === -128 && t.userFlag2 === 127;
}
function cG(t) {
  return uG(t) ? za.Float32 : sG(t.MODE);
}
function Dde(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, s, u, c, l, d, f;
    return ye(this, function(h) {
      switch (h.label) {
        case 0:
          return [4, r.update({ message: "Parsing CCP4/MRC/MAP file..." })];
        case 1:
          return h.sent(), [4, wde(t)];
        case 2:
          return n = h.sent(), i = n.header, a = n.littleEndian, o = function(m) {
            return 1024 + m.NSYMBT;
          }(i), s = sG(i.MODE), u = cG(i), c = i.NC * i.NR * i.NS, l = lP(s), d = c * l, f = function(m, p) {
            var v = lP(p), g = new ArrayBuffer(v * m), y = _l.fromArrayBuffer(g), b = _l.IsNativeEndianLittle ? g : new ArrayBuffer(v * m);
            return { type: p, elementByteSize: v, readBuffer: y, valuesBuffer: new Uint8Array(b), values: Cde(p, b) };
          }(c, u), function(m, p, v, g, y, b) {
            _e(this, 0, void 0, function() {
              var S, _, x, C, A, w;
              return ye(this, function(I) {
                switch (I.label) {
                  case 0:
                    return uG(m) ? (S = 3 * y, [4, v.readBuffer(g, p.readBuffer, y, S)]) : [3, 2];
                  case 1:
                    for (I.sent(), _ = new Int8Array(p.valuesBuffer.buffer, S), x = (m.AMAX - m.AMIN) / 255, C = 0.5 * (m.AMIN + m.AMAX + x), A = 0, w = y; A < w; ++A) p.values[A] = x * _[A] + C;
                    return [3, 4];
                  case 2:
                    return [4, Ade(p, v, g, y, 0, b)];
                  case 3:
                    I.sent(), I.label = 4;
                  case 4:
                    return [2];
                }
              });
            });
          }(i, f, t, o, d, a), [2, { header: i, values: f.values, name: t.name }];
      }
    });
  });
}
function Ede(t, e) {
  return function(r, n) {
    var i = this;
    return tr.create("Parse CCP4/MRC/MAP", function(a) {
      return _e(i, 0, void 0, function() {
        var o, s, u;
        return ye(this, function(c) {
          switch (c.label) {
            case 0:
              return c.trys.push([0, 2, , 3]), s = (o = ji).success, [4, Dde(r, 0, a)];
            case 1:
              return [2, s.apply(o, [c.sent()])];
            case 2:
              return u = c.sent(), [2, ji.error(u)];
            case 3:
              return [2];
          }
        });
      });
    });
  }(n9.fromBuffer(_l.fromUint8Array(t), e), t.length);
}
function Ide(t, e) {
  var r = this;
  return tr.create("Create Volume", function(n) {
    return _e(r, 0, void 0, function() {
      var i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S;
      return ye(this, function(_) {
        return i = t.header, a = t.values, o = E.create(i.xLength, i.yLength, i.zLength), s = E.create(qn(i.alpha), qn(i.beta), qn(i.gamma)), u = i.ISPG > 65536 ? 0 : i.ISPG, c = au.create(u || "P 1", o, s), l = E.create(i.MAPC - 1, i.MAPR - 1, i.MAPS - 1), d = Qn.convertToCanonicalAxisIndicesFastToSlow(l), f = [i.NX, i.NY, i.NZ], h = d([i.NC, i.NR, i.NS]), m = function(x) {
          return x.originX === 0 && x.originY === 0 && x.originZ === 0 ? E.create(x.NCSTART, x.NRSTART, x.NSSTART) : E.create(x.originX / (x.xLength / x.NX), x.originY / (x.yLength / x.NY), x.originZ / (x.zLength / x.NZ));
        }(i), p = d(m), v = E.create(p[0] / f[0], p[1] / f[1], p[2] / f[2]), g = E.create(h[0] / f[0], h[1] / f[1], h[2] / f[2]), y = Qn.Space(h, Qn.invertAxisOrder(l), function(x) {
          var C = cG(x);
          switch (C) {
            case za.Float32:
              return Float32Array;
            case za.Int8:
              return Int8Array;
            case za.Int16:
              return Int16Array;
            case za.Uint16:
              return Uint16Array;
          }
          throw Error("".concat(C, " is not a supported value format."));
        }(i)), b = Qn.create(y, Qn.Data1(a)), S = 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: $r.create(v, E.add(E.zero(), v, g)) }, cells: b, stats: { min: isNaN(i.AMIN) || S ? wQ(a) : i.AMIN, max: isNaN(i.AMAX) || S ? w3(a) : i.AMAX, mean: isNaN(i.AMEAN) || S ? DQ(a) : i.AMEAN, sigma: isNaN(i.ARMS) || i.ARMS === 0 ? EQ(a) : i.ARMS } }, sourceData: i9.create(t), customProperties: new jp(), _propertyData: /* @__PURE__ */ Object.create(null) }];
      });
    });
  });
}
z.getDefaultValues(oG), function(t) {
  function e(n) {
    var i = new DataView(n.buffer);
    return Object.assign(n.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 = Ui(o, 0), s = Ui(s, 0), u = Ui(u, n.length), a.set(n.subarray(s, u), o), u - s;
    } });
  }
  function r(n, 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] = n[s + u + l];
  }
  t.fromUint8Array = e, t.fromArrayBuffer = function(n) {
    return e(new Uint8Array(n));
  }, t.fromBuffer = function(n) {
    return e(new Uint8Array(n));
  }, t.IsNativeEndianLittle = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330, t.flipByteOrder = r, t.flipByteOrderInPlace2 = function(n, i, a) {
    i === void 0 && (i = 0);
    for (var o = new Int16Array(n, i, a), s = 0, u = o.length; s < u; ++s) {
      var c = o[s];
      o[s] = (255 & c) << 8 | c >> 8 & 255;
    }
  }, t.ensureLittleEndian = function(n, i, a, o, s) {
    t.IsNativeEndianLittle || !a || o <= 1 || r(n, i, a, o, s);
  };
}(_l || (_l = {})), function(t) {
  t.fromBuffer = function(e, r) {
    return { name: r, readBuffer: function(n, i, a, o) {
      var s, u;
      if (typeof i == "number") {
        a = Ui(a, i);
        var c = n;
        s = (l = Math.min(e.length, c + a)) - c, u = _l.fromUint8Array(new Uint8Array(e.buffer, c, l - c));
      } else {
        a = Ui(a, i.length), c = n;
        var l = Math.min(e.length, c + a);
        i.set(e.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(n, i, a) {
      return a = Ui(a, i.length), console.error(".writeBuffer not implemented for FileHandle.fromBuffer"), Promise.resolve(0);
    }, writeBufferSync: function(n, i, a) {
      return a = Ui(a, i.length), console.error(".writeSync not implemented for FileHandle.fromBuffer"), 0;
    }, close: H9 };
  };
}(n9 || (n9 = {})), function(t) {
  t.Float32 = "float32", t.Int8 = "int8", t.Int16 = "int16", t.Uint16 = "uint16";
}(za || (za = {})), function(t) {
  t.is = function(e) {
    return (e == null ? void 0 : e.kind) === "ccp4";
  }, t.create = function(e) {
    return { kind: "ccp4", name: e.name, data: e };
  };
}(i9 || (i9 = {}));
var Tde = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, Ede(t, "Hermite").run()];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, Ide(e.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, Mde = { createTheme: function(t, e, r) {
  var n, i;
  if (r != null && r.color) return { color: (n = e.managers.representation.ctx) === null || n === void 0 ? void 0 : n.colorThemeRegistry.create(r.color.name, { volume: t }, r.color.props), size: (i = e.managers.representation.ctx) === null || i === void 0 ? void 0 : i.colorThemeRegistry.create("uniform", {}, {}) };
}, parse: function(t, e) {
  return _e(this, 0, void 0, function() {
    var r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, t.arrayBuffer()];
        case 1:
          return r = n.sent(), [4, Tde.parse(new Uint8Array(r))];
        case 2:
          return [2, n.sent()];
      }
    });
  });
}, create: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = Sde(e, function() {
            return oG;
          }), r && i.setTheme(r), [4, i.createOrUpdate(n ?? {}, t).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, t.createOrUpdate(i ?? {}, e).run()];
        case 1:
          return a.sent(), n && t.setTheme(n), [2];
      }
    });
  });
} }, Pde = { unitLabel: z.Text("Å", { isEssential: !0 }) }, Bde = O(O(O({}, Rr.Params), Pde), { lineSizeAttenuation: z.Boolean(!1), linesColor: z.Color(qe(14080239), { isEssential: !0 }), linesSize: z.Numeric(0.8), alpha: z.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }) }), lG = { lines: function(t, e) {
  return Fn(Rde, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.Highlighting });
  } });
} }, Fde = O(O({}, Bde), { visuals: z.MultiSelect(["lines"], z.objectToOptions(lG)) });
function Nde(t, e) {
  var r = e.sphereA, n = e.sphereB, i = e.center, a = t.loci, o = a[0], s = a[1];
  return Qr.getBoundingSphere(o, r), Qr.getBoundingSphere(s, n), E.add(i, r.center, n.center), E.scale(i, i, 0.5), e.distance = E.distance(r.center, n.center), e;
}
var Zf = { sphereA: Me(), sphereB: Me(), center: E(), distance: 0 };
function Rde(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.pairs.length; l < d; ++l) Nde(o.pairs[l], Zf), c.add(Zf.sphereA.center[0], Zf.sphereA.center[1], Zf.sphereA.center[2], Zf.sphereB.center[0], Zf.sphereB.center[1], Zf.sphereB.center[2], l);
    return c.getLines();
  }(e, 0, n && n.geometry), a = function(o, s) {
    return o.pairs.length === 1 ? "interactionLine ".concat(o2(o.pairs[0], { unitLabel: s, measureOnly: !0 })) : "".concat(o.pairs.length, " interactionLines");
  }(e, r.unitLabel);
  return er.create(a, e, i, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function(o) {
    return o2(e.pairs[o], r);
  });
}
var Ode = { parse: function(t, e) {
  return t.map(function(r) {
    var n = e.managers.cell.get(r.ref), i = on(n);
    return pi(i, r.elementIds);
  });
}, create: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n = function(a, o) {
            var s = sr.createMulti("interactionLine", a, o, sr.StateBuilder, lG);
            return s.setState({ pickable: !0, markerActions: Lr.All }), s;
          }(e, function() {
            return Fde;
          }), [4, n.createOrUpdate({}, { pairs: [{ loci: t }] }).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, t.createOrUpdate({}, { pairs: [{ loci: e }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, Lde = he.fromTranslation(he(), E.create(0.5, 0.5, 0.5)), kde = Hy(Uy(oO()), Lde), xu = E(), dP = he(), Gde = O(O({}, Vt.Params), { cellColor: z.Color(Yt.black), cellScale: z.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), ref: z.Select("model", z.objectToOptions({ origin: "Origin", model: "Model" }), { isEssential: !0 }), attachment: z.Select("corner", z.objectToOptions({ corner: "Corner", center: "Center" }), { isEssential: !0 }) }), zde = { mesh: function(t, e) {
  return Fn(Ude, Vt.Utils);
} }, Vde = O({}, Gde);
function Ude(t, e, r, n) {
  var i = function(o, s, u) {
    var c = wt.createState(256, 128, u), l = o.symmetry.spacegroup.cell.fromFractional;
    E.copy(xu, o.ref), s.attachment === "center" ? (E.trunc(xu, xu), E.subScalar(xu, xu, 0.5)) : E.floor(xu, xu), he.fromTranslation(dP, xu);
    var d = Hy(Uy(kde), dP), f = Math.cbrt(o.symmetry.spacegroup.cell.volume) / 300 * s.cellScale;
    c.currentGroup = 1, wt.addCage(c, l, d, f, 2, 20);
    var h = Me.fromDimensionsAndTransform(Me(), E.unit, l);
    E.transformMat4(xu, xu, l), Me.translate(h, h, xu), Me.expand(h, h, f);
    var m = wt.getMesh(c);
    return m.setBoundingSphere(h), m;
  }(e, r, n && n.geometry), a = R3.getUnitcellLabel(e.symmetry);
  return er.create(a, e, i, function() {
    return r.cellColor;
  }, function() {
    return 1;
  }, function() {
    return a;
  });
}
var Hde = { create: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n = function(a, o) {
            return sr.createMulti("Unit Cell", a, o, sr.StateBuilder, zde);
          }(e, function() {
            return Vde;
          }), [4, n.createOrUpdate({}, t).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, t.createOrUpdate({}, e).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, qde = { unitLabel: z.Text("Å", { isEssential: !0 }) }, Kde = O(O(O({}, Rr.Params), qde), { lineSizeAttenuation: z.Boolean(!1), linesColor: z.Color(Yt.black), linesSize: z.Numeric(2), alpha: z.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }), isDash: z.Boolean(!1), dashLength: z.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), dG = { lines: function(t, e) {
  return Fn(Yde, Rr.Utils, { modifyState: function(r) {
    return O(O({}, r), { markerActions: Lr.Selecting });
  } });
} }, Xde = O(O({}, Kde), { visuals: z.MultiSelect(["lines"], z.objectToOptions(dG)) });
function Yde(t, e, r, n) {
  var i = function(o, s, u) {
    for (var c = Ea.create(128, 64, u), l = 0, d = o.lines.length; l < d; ++l) s.isDash ? c.addFixedLengthDashes(E.create(o.lines[l][0][0], o.lines[l][0][1], o.lines[l][0][2]), E.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();
  }(e, r, n && n.geometry), a = function(o, s) {
    return "".concat(o.lines.length, " interactionLines");
  }(e, r.unitLabel);
  return er.create(a, e, i, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function() {
    return "CustomLines";
  });
}
var Wde = { create: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = sr.createMulti("customLines", o, s, sr.StateBuilder, dG);
            return u.setState({ pickable: !1, markerActions: Lr.Selecting }), u;
          }(e, function() {
            return Xde;
          }), [4, i.createOrUpdate(n ?? {}, { lines: t }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, t.createOrUpdate(i ?? {}, { lines: e }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, jde = O(O({}, Vt.Params), { color: z.Color(Yt.orange), scaleFactor: z.Numeric(1, { min: 0.1, max: 10, step: 0.1 }) }), fG = { plane: function(t, e) {
  return Fn(Qde, Vt.Utils);
} }, Zde = O(O({}, jde), { visuals: z.MultiSelect(["plane"], z.objectToOptions(fG)) });
function Qde(t, e, r, n) {
  var i = function(a, o, s) {
    var u = wt.createState(256, 128, s);
    return a.planes.forEach(function(c) {
      wt.addTriangle(u, E.create.apply(E, c[0]), E.create.apply(E, c[1]), E.create.apply(E, c[2]));
    }), wt.getMesh(u);
  }(e, 0, n && n.geometry);
  return er.create("CustomPlanes", e, i, function() {
    return r.color;
  }, function() {
    return 1;
  }, function() {
    return "CustomPlanes";
  });
}
var H1, Jh, ic, Na, $h, Jde = { create: function(t, e, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, s) {
            var u = sr.createMulti("CustomPlanes", o, s, sr.StateBuilder, fG);
            return u.setState({ pickable: !1, markerActions: Lr.Selecting }), u;
          }(e, function() {
            return Zde;
          }), [4, i.createOrUpdate(n ?? {}, { planes: t }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, t.createOrUpdate(i ?? {}, { planes: e }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, eu = ((H1 = {})[Pe.Ribbon] = ace, H1[Pe.BallAndStick] = xk, H1[Pe.Line] = fle, H1[Pe.Stick] = ple, H1[Pe.CPK] = Fle, H1), Am = ((Jh = {})[Pe.Label] = wce, Jh[Pe.Distance] = Pce, Jh[Pe.Angle] = Vce, Jh[Pe.Dihedral] = tle, Jh), c3 = ((ic = {})[Pe.Surface] = Ale, ic[Pe.IsoSurface] = Mde, ic[Pe.RotateArrow] = Ple, ic[Pe.Pocket] = Vle, ic[Pe.Pharmacophore] = $le, ic[Pe.MappingLine] = Ode, ic[Pe.UnitCell] = Hde, ic[Pe.CustomLines] = Wde, ic[Pe.CustomPlanes] = Jde, ic);
(function(t) {
  t.LigandReceptor = "ligand-receptor", t.IntraLigand = "intra-ligand", t.IntraReceptor = "intra-receptor", t.All = "all";
})(Na || (Na = {}));
var $de = function(t, e) {
  var r, n, i, a = Oa(t.getLoci());
  if (!a || !(!((i = (n = (r = a == null ? void 0 : a.elements) === null || r === void 0 ? void 0 : r[0]) === null || n === void 0 ? void 0 : n.unit) === null || i === void 0) && i.elements)) return Fd.Not;
  var o = new Set(oa(a)), s = 0;
  return e.forEach(function(u) {
    o.has(u) && s++;
  }), s ? s === e.length ? Fd.Include : s === o.size ? Fd.BeIncluded : Fd.Cross : Fd.Not;
}, efe = function(t, e) {
  var r, n;
  if (t.ref !== e.ref) return !1;
  if (!(!((r = t.elementIds) === null || r === void 0) && r.length) || !(!((n = e.elementIds) === null || n === void 0) && n.length)) return !0;
  var i = new Set(e.elementIds);
  return t.elementIds.some(function(a) {
    return i.has(a);
  });
}, fy = function(t, e) {
  var r = Oa(t.getLoci());
  if (!r) return [];
  var n = pi(r == null ? void 0 : r.structure, e), i = Xe.intersect(r, n);
  return oa(i);
}, a9 = function(t, e, r, n, i) {
  var a = Vo(t);
  if (a) {
    var o = wL(a, e);
    return eu[r].update(t, o, Dd.managers.representation.ctx, n ? n(o) : t.theme), i && t.setState({ transparency: i(o) }), t;
  }
  console.warn("removeElementIdsInRepresentation");
}, tfe = (($h = {})[Pe.Label] = ["customText", "textColor", "textSize"], $h[Pe.Distance] = ["linesColor", "textSize", "textColor"], $h[Pe.Angle] = ["color", "textSize", "textColor"], $h[Pe.Dihedral] = ["color", "textSize", "textColor"], $h), pG = function(t, e) {
  if (Op.has(t)) {
    var r = {};
    return tfe[t].forEach(function(n) {
      r[n] = e.props[n];
    }), r;
  }
}, fP = function(t, e, r, n) {
  var i = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], a = t[0], o = t[1], s = t[2], u = function(T) {
    var F = E.create(T[0], T[1], T[2]);
    return E.normalize(F, F), [F[0], F[1], F[2]];
  }(function(T, F) {
    return [F[0] - T[0], F[1] - T[1], F[2] - T[2]];
  }(t, e)), c = u[0], l = u[1], d = u[2], f = c * c, h = c * l, m = c * d, p = l * l, v = l * d, g = d * d, y = a * c, b = a * l, S = a * d, _ = o * c, x = o * l, C = o * d, A = s * c, w = s * l, I = s * d, P = Math.cos(r * (Math.PI / 180)), M = Math.sin(r * (Math.PI / 180));
  return i[0][0] = f + (p + g) * P, i[0][1] = h * (1 - P) + d * M, i[0][2] = m * (1 - P) - l * M, i[0][3] = 0, i[1][0] = h * (1 - P) - d * M, i[1][1] = p + (f + g) * P, i[1][2] = v * (1 - P) + c * M, i[1][3] = 0, i[2][0] = m * (1 - P) + l * M, i[2][1] = v * (1 - P) - c * M, i[2][2] = g + (f + p) * P, i[2][3] = 0, i[3][0] = (a * (p + g) - c * (x + I)) * (1 - P) + (C - w) * M, i[3][1] = (o * (f + g) - l * (y + I)) * (1 - P) + (A - S) * M, i[3][2] = (s * (f + p) - d * (y + x)) * (1 - P) + (b - _) * M, i[3][3] = 1, [n[0] * i[0][0] + n[1] * i[1][0] + n[2] * i[2][0] + i[3][0], n[0] * i[0][1] + n[1] * i[1][1] + n[2] * i[2][1] + i[3][1], n[0] * i[0][2] + n[1] * i[1][2] + n[2] * i[2][2] + i[3][2]];
}, hG = function(t, e, r) {
  var n, i, a, o, s, u;
  if (!t.canvas3d) return E.create(0, 0, 0);
  var c = ze.create(0, 0), l = E.create(0, 0, 0), d = E.create(0, 0, 0);
  if (ze.sub(c, ze.copy(c, r), e), ze.squaredMagnitude(c)) {
    var f = (i = (n = t.canvas3d) === null || n === void 0 ? void 0 : n.input.pixelRatio) !== null && i !== void 0 ? i : 1;
    return c[0] *= 1 / t.canvas3d.camera.zoom * t.canvas3d.camera.viewport.width * f, c[1] *= 1 / t.canvas3d.camera.zoom * t.canvas3d.camera.viewport.height * f * (((o = (a = t.layout) === null || a === void 0 ? void 0 : a.canvas.clientWidth) !== null && o !== void 0 ? o : 1) / ((u = (s = t.layout) === null || s === void 0 ? void 0 : s.canvas.clientHeight) !== null && u !== void 0 ? u : 1)), E.cross(l, E.sub(l, t.canvas3d.camera.position, t.canvas3d.camera.target), t.canvas3d.camera.up), E.setMagnitude(l, l, c[0]), E.setMagnitude(d, t.canvas3d.camera.up, c[1]), E.add(l, l, d), E.scale(l, l, 1 / 2100), l;
  }
  return E.create(0, 0, 0);
}, rfe = function(t, e) {
  var r = Xe.getBoundary(pi(t, e));
  return { center: E.create((r.box.max[0] + r.box.min[0]) / 2, (r.box.max[1] + r.box.min[1]) / 2, (r.box.max[2] + r.box.min[2]) / 2), size: E.create(r.box.max[0] - r.box.min[0], r.box.max[1] - r.box.min[1], r.box.max[2] - r.box.min[2]) };
}, nfe = function(t) {
  var e = gs(t);
  if (e) {
    var r = Da.Provider.get(e);
    if (r) {
      var n = function(i, a, o) {
        var s = E();
        return o.ref === "model" && E.transformMat4(s, pn.getCenter(i), a.spacegroup.cell.toFractional), { symmetry: a, ref: s };
      }(e, r, {});
      return n;
    }
  }
};
window.requestIdleCallback = window.requestIdleCallback || function(t) {
  var e = Date.now();
  return setTimeout(function() {
    t({ didTimeout: !1, timeRemaining: function() {
      return Math.max(0, 50 - (Date.now() - e));
    } });
  }, 1);
};
var o9, s9, em = new cu("98"), pP = function() {
  function t(e) {
    this.boundaryHelper = new cu("98"), this.plugin = e;
  }
  return t.prototype.focus = function(e) {
    var r;
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b = this;
      return ye(this, function(S) {
        switch (S.label) {
          case 0:
            if (n = !1, i = [], a = [], e ? e.forEach(function(_) {
              var x = b.plugin.cells.get(_.ref);
              x && (Array.from(x.representations.keys()).some(function(C) {
                return Op.has(C) || roe.has(C);
              }) ? a.push(_) : i.push(_));
            }) : (a.push.apply(a, Array.from(this.plugin.managers.selection.shape.selection.values()).map(function(_) {
              return { ref: _ };
            })), 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(_) {
              return { ref: _ };
            }))), !i.length && !a.length) return [2];
            o = E.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), s = E.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), em.reset(), u = [], a.forEach(function(_) {
              var x = b.plugin.cells.get(_.ref);
              if (x) if (x.representations.has(Pe.Surface)) i.push(x.model.other);
              else {
                if (x.representations.has(Pe.Pharmacophore)) {
                  var C = x.model.other, A = C.center, w = C.normal, I = C.radius;
                  if (!w) return E.min(o, o, E.create(A[0] - I, A[1] - I, A[2] - I)), E.max(s, s, E.create(A[0] + I, A[1] + I, A[2] + I)), void (n = !0);
                  var P = E.create((A[0] + w[0]) / 2, (A[1] + w[1]) / 2, (A[2] + w[2]) / 2), M = (E.distance(w, A) + I) / 2;
                  return E.min(o, o, E.create(P[0] - M, P[1] - M, P[2] - M)), E.max(s, s, E.create(P[0] + M, P[1] + M, P[2] + M)), void (n = !0);
                }
                if (x.representations.has(Pe.Pocket)) {
                  var T = x.model.other, F = (A = T.center, T.size), N = [(2 * A[0] + F[0]) / 2, (2 * A[1] + F[1]) / 2, (2 * A[2] + F[2]) / 2], R = [(2 * A[0] - F[0]) / 2, (2 * A[1] - F[1]) / 2, (2 * A[2] - F[2]) / 2], L = { min: E.fromArray(E.zero(), R, 0), max: E.fromArray(E.zero(), N, 0) };
                  return E.min(o, o, L.min), E.max(s, s, L.max), void (n = !0);
                }
                i.push.apply(i, x.dependency.on);
              }
            }), c = 0, l = i, S.label = 1;
          case 1:
            return c < l.length ? (d = l[c], this.plugin.cells.get(d.ref) ? [4, this.plugin.managers.cell.getStructure(d.ref)] : [2]) : [3, 4];
          case 2:
            if (!(f = S.sent())) return [2];
            h = pi(f, d.elementIds), (!Xe.isEmpty(h) || ((r = h == null ? void 0 : h.elements) === null || r === void 0 ? void 0 : r.length) > 0) && u.push(Xe.getBoundary(h)), S.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            if (!u.length) return n && this.focusSphere({ center: E.create((s[0] + o[0]) / 2, (s[1] + o[1]) / 2, (s[2] + o[2]) / 2), radius: E.distance(s, o) / 2 }), [2];
            for (v = 0, g = u.length; v < g; ++v) m = u[v], p = m.box, y = m.sphere, E.min(o, o, p.min), E.max(s, s, p.max), em.includePositionRadius(y.center, y.radius);
            for (em.finishedIncludeStep(), v = 0, g = u.length; v < g; ++v) y = u[v].sphere, em.radiusPositionRadius(y.center, y.radius);
            return this.focusSphere(em.getSphere()), [2];
        }
      });
    });
  }, t.prototype.focusSphere = function(e, r) {
    var n, i, a = O({ minRadius: 5, extraRadius: 4, durationMs: 250 }, r), o = a.extraRadius, s = a.minRadius, u = a.durationMs, c = Math.max(e.radius + o, s), l = (n = this.plugin.canvas3d) === null || n === void 0 ? void 0 : n.camera.getFocus(e.center, c);
    (i = this.plugin.canvas3d) === null || i === void 0 || i.requestCameraReset({ durationMs: u, snapshot: l });
  }, t.prototype.reset = function() {
    var e;
    (e = this.plugin.canvas3d) === null || e === void 0 || e.requestCameraReset({ durationMs: 200 });
  }, t.prototype.zoomIn = function() {
    var e, r, n = (e = this.plugin.canvas3d) === null || e === void 0 ? void 0 : e.camera.getSnapshot();
    if (n) {
      var i = hP(n, 1);
      E.distance(n.target, i) < 10 || (n.position = i, (r = this.plugin.canvas3d) === null || r === void 0 || r.camera.setState(n, 200));
    }
  }, t.prototype.zoomOut = function() {
    var e, r, n = (e = this.plugin.canvas3d) === null || e === void 0 ? void 0 : e.camera.getSnapshot();
    if (n) {
      var i = hP(n, -1);
      n.position = i, (r = this.plugin.canvas3d) === null || r === void 0 || r.camera.setState(n, 200);
    }
  }, t.prototype.updateAxes = function(e) {
    var r, n, i, a, o, s, u, c, l = { vecA: E.unitX, vecB: E.unitY, vecC: E.unitZ }, d = this.plugin.cells.get(e);
    if (d) {
      var f = on(d);
      if (f && (!((a = (i = (n = (r = gs(f)) === null || r === void 0 ? void 0 : r.sourceData) === null || n === void 0 ? void 0 : n.data) === null || i === void 0 ? void 0 : i.molecules) === null || a === void 0) && a.length)) {
        var h = (u = (s = (o = gs(f)) === null || o === void 0 ? void 0 : o.sourceData) === null || s === void 0 ? void 0 : s.data) === null || u === void 0 ? void 0 : u.molecules[0].cell, m = h.vecA, p = h.vecB, v = h.vecC;
        l = { vecA: E.scale(E(), m, 1 / E.distance(E(), m)), vecB: E.scale(E(), p, 1 / E.distance(E(), p)), vecC: E.scale(E(), v, 1 / E.distance(E(), v)) };
      }
    }
    (c = this.plugin.canvas3d) === null || c === void 0 || c.setProps({ camera: { helper: { axes: { name: "on", params: l } } } });
  }, t;
}();
function hP(t, e) {
  var r = E();
  E.sub(r, t.target, t.position), E.normalize(r, r), E.scale(r, r, 5 * e);
  var n = t.position;
  return E.add(n, n, r), n;
}
(function(t) {
  t.create = function(e, r) {
    var n = [], i = [], a = [];
    return { add: function(o, s, u) {
      n[n.length] = o, i[i.length] = s, a[a.length] = u;
    }, getContacts: function() {
      for (var o = new Xo.EdgeBuilder(e.count, n, 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, f = o.createGraph({ type: s, flag: u });
      return Object.defineProperty(f, "elementsIndex", { get: function() {
        return d || (d = I7.createElementsIndex(f, e, r));
      } });
    } };
  };
})(o9 || (o9 = {})), function(t) {
  t.create = function() {
    var e = new C0.Builder();
    return { startUnitPair: function(r, n) {
      e.startUnitPair(r.id, n.id);
    }, finishUnitPair: function() {
      e.finishUnitPair();
    }, add: function(r, n, i) {
      e.add(r, n, { type: i, flag: Do.None });
    }, getContacts: function(r) {
      return new xae(e.getMap(), r);
    } };
  };
}(s9 || (s9 = {}));
var ife = { lineOfSightDistFactor: z.Numeric(1, { min: 0, max: 3, step: 0.1 }) }, afe = 3;
function mG(t, e, r) {
  var n = e.members[e.offsets[e.feature]], i = r.members[r.offsets[r.feature]];
  if (n === i && e.unit === r.unit) return !1;
  var a = ty(e.unit, n), o = ty(r.unit, i);
  return (!a || !o || a === o) && (e.unit.residueIndex[e.unit.elements[n]] !== r.unit.residueIndex[r.unit.elements[i]] || e.unit !== r.unit) && !dae(t, e.unit, n, r.unit, i);
}
function mP(t, e, r, n) {
  var i = ty(t, e), a = ty(r, n);
  return i && a && i !== a;
}
function gP(t, e) {
  for (var r = e.feature, n = e.offsets, i = e.members, a = n[r], o = n[r + 1]; a < o; ++a) if (i[a] === t) return !0;
  return !1;
}
var Cd = E(), V8 = E(), U8 = E(), ofe = wR();
function sfe(t, e, r, n) {
  var i = e.feature, a = r.feature, o = e.members[e.offsets[i]], s = r.members[r.offsets[a]];
  Zr.position(V8, e), Zr.position(U8, r), E.scale(Cd, E.add(Cd, V8, U8), 0.5);
  var u = n * afe, c = t.lookup3d.find(Cd[0], Cd[1], Cd[2], u, ofe), l = c.count, d = c.indices, f = c.units, h = c.squaredDistances;
  if (l === 0) return !0;
  for (var m = 0; m < l; ++m) {
    var p = d[m], v = f[m];
    if (Fe.isAtomic(v)) {
      var g = kr(v, p);
      if (g !== "H") {
        var y = Gy(g);
        if (!(y * y * n * n <= h[m] || mP(v, p, e.unit, o) || mP(v, p, r.unit, s) || e.unit === v && gP(p, e) || r.unit === v && gP(p, r) || (v.conformation.position(v.elements[p], Cd), E.squaredDistance(Cd, V8) < 1 || E.squaredDistance(Cd, U8) < 1))) return !1;
      }
    }
  }
  return !0;
}
function ufe(t, e, r, n, i, a, o) {
  for (var s = r.x, u = r.y, c = r.z, l = r.subset(i.requiredFeatures), d = l.lookup3d, f = l.indices, h = Zr.Info(t, e, r), m = O({}, h), p = 0, v = Ge.size(f); p < v; ++p) {
    var g = Ge.getAt(f, p), y = d.find(s[g], u[g], c[g], i.maxDistance), b = y.count, S = y.indices, _ = y.squaredDistances;
    if (b !== 0) {
      h.feature = g;
      for (var x = 0; x < b; ++x) {
        var C = Ge.getAt(f, S[x]);
        if (!(C <= g)) {
          m.feature = C;
          var A = h.unit.elements[h.members[h.offsets[h.feature]]], w = m.unit.elements[m.members[m.offsets[m.feature]]];
          if ((!o || o(h.unit, A, m.unit, w)) && mG(t, h, m)) {
            var I = i.getType(t, h, m, _[x]);
            I && n.add(g, C, I);
          }
        }
      }
    }
  }
}
var cfe = he(), lfe = { distanceMax: z.Numeric(4, { min: 1, max: 5, step: 0.1 }) }, dfe = Zr.Provider([8], function(t, e, r) {
  for (var n = e.elements, i = e.model.atomicConformation, a = i.x, o = i.y, s = i.z, u = function(d, f) {
    var h = kr(e, d), m = !1;
    h === "C" ? (m = !0, tf(t, e, d, function(p, v) {
      var g = kr(p, v);
      g !== "C" && g !== "H" && (m = !1);
    })) : h === "F" && (m = !0), m && r.add(8, 0, a[n[d]], o[n[d]], s[n[d]], d);
  }, c = 0, l = n.length; c < l; ++c) u(c);
}), ffe = { name: "hydrophobic", params: lfe, createTester: function(t) {
  return { maxDistance: t.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([8]), getType: function(e, r, n, 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, f = o.members[o.offsets[o.feature]], h = s.members[s.offsets[s.feature]];
        if (kr(o.unit, f) !== "F" || kr(s.unit, h) !== "F") return br.Hydrophobic;
      }
    }(0, r, n);
  } };
} };
function pfe(t, e) {
  var r = e.contacts, n = function(c, l, d, f, h) {
    var m = f.get(d) || [1 / 0, -1], p = m[0], v = m[1];
    c < p ? (v !== -1 && h(v), f.set(d, [c, l])) : h(l);
  };
  function i(c, l, d, f, h) {
    var m = l.members[l.offsets[l.feature]], p = d.members[d.offsets[d.feature]], v = l.unit.getResidueIndex(m), g = d.unit.getResidueIndex(p), y = "".concat(m, "|").concat(l.unit.id, "|").concat(g, "|").concat(d.unit.id, "|A"), b = "".concat(p, "|").concat(d.unit.id, "|").concat(v, "|").concat(l.unit.id, "|B"), S = Zr.distance(l, d);
    n(S, c, y, f, h), n(S, c, b, f, h);
  }
  var a, o, s = /* @__PURE__ */ new Map(), u = function(c) {
    return r.edges[c].props.flag = Do.Filtered;
  };
  return { isApplicable: function(c) {
    return c === br.Hydrophobic;
  }, handleInterContact: function(c, l, d) {
    i(c, l, d, s, u);
  }, startUnit: function(c, l, d) {
    a = /* @__PURE__ */ new Map(), o = function(f) {
      return l.edgeProps.flag[f] = Do.Filtered;
    };
  }, handleIntraContact: function(c, l, d) {
    i(c, l, d, a, o);
  } };
}
function hfe(t, e) {
  var r = e.contacts, n = function(i, a) {
    for (var o = i.types[i.feature] === 9 ? a : i, s = o.members[o.offsets[o.feature]], u = e.unitsContacts.get(o.unit.id), c = u.edgeProps.type, l = u.elementsIndex, d = l.offsets, f = l.indices, h = d[s], m = d[s + 1]; h < m; ++h) if (c[f[h]] === br.HydrogenBond) return !0;
    var p = r.getEdgeIndices(o.feature, o.unit.id);
    for (h = 0, m = p.length; h < m; ++h) if (r.edges[p[h]].props.type === br.HydrogenBond) return !0;
    return !1;
  };
  return { isApplicable: function(i) {
    return i === br.WeakHydrogenBond;
  }, handleInterContact: function(i, a, o) {
    n(a, o) && (r.edges[i].props.flag = Do.Filtered);
  }, startUnit: function() {
  }, handleIntraContact: function(i, a, o) {
    n(a, o) && (e.unitsContacts.get(a.unit.id).edgeProps.flag[i] = Do.Filtered);
  } };
}
function jx(t, e, r, n, i) {
  for (var a = r.offsets, o = r.feature, s = n.offsets, u = n.feature, c = a[o], l = a[o + 1]; c < l; ++c) for (var d = r.members[c], f = i.getContactIndicesForElement(d, r.unit), h = 0, m = f.length; h < m; ++h) {
    var p = f[h];
    if (t.includes(i.edges[p].props.type)) for (var v = s[u], g = s[u + 1]; v < g; ++v) {
      var y = n.members[v];
      if (i.getContactIndicesForElement(y, n.unit).includes(p)) return void (i.edges[e].props.flag = Do.Filtered);
    }
  }
}
function Zx(t, e, r, n, i) {
  for (var a = i.edgeProps, o = a.type, s = a.flag, u = i.elementsIndex, c = u.offsets, l = u.indices, d = r.offsets, f = r.feature, h = n.offsets, m = n.feature, p = d[f], v = d[f + 1]; p < v; ++p) for (var g = r.members[p], y = c[g], b = c[g + 1]; y < b; ++y) {
    var S = l[y];
    if (t.includes(o[S])) {
      for (var _ = h[m], x = h[m + 1]; _ < x; ++_) for (var C = n.members[_], A = c[C], w = c[C + 1]; A < w; ++A) if (S === l[A]) return void (s[e] = Do.Filtered);
    }
  }
}
function mfe(t, e) {
  var r = e.contacts;
  return { isApplicable: function(n) {
    return n === br.Ionic;
  }, handleInterContact: function(n, i, a) {
    jx([br.HydrogenBond, br.WeakHydrogenBond], n, i, a, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, i, a) {
    Zx([br.HydrogenBond, br.WeakHydrogenBond], n, i, a, e.unitsContacts.get(i.unit.id));
  } };
}
function gfe(t, e) {
  var r = e.contacts;
  return { isApplicable: function(n) {
    return n === br.Hydrophobic || n === br.CationPi;
  }, handleInterContact: function(n, i, a) {
    jx([br.PiStacking], n, i, a, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, i, a) {
    Zx([br.PiStacking], n, i, a, e.unitsContacts.get(i.unit.id));
  } };
}
function vfe(t, e) {
  var r = e.contacts;
  return { isApplicable: function(n) {
    return n === br.Ionic;
  }, handleInterContact: function(n, i, a) {
    jx([br.MetalCoordination], n, i, a, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, i, a) {
    Zx([br.MetalCoordination], n, i, a, e.unitsContacts.get(i.unit.id));
  } };
}
function yfe(t, e, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    var o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I;
    return ye(this, function(P) {
      return Fe.isAtomic(e) ? (o = r.child, s = o == null ? void 0 : o.unitMap.get(e.id), o && !s ? [2, Vt.createEmpty(a)] : (u = at.create(r, e), c = oi.get(r).value, l = c.unitsFeatures.get(e.id), d = c.unitsContacts.get(e.id), f = l.x, h = l.y, m = l.z, p = l.members, v = l.offsets, g = d.edgeCount, y = d.a, b = d.b, S = d.edgeProps.flag, _ = i.sizeFactor, g ? (x = { linkCount: 2 * g, position: function(M, T, F) {
        E.set(M, f[y[F]], h[y[F]], m[y[F]]), E.set(T, f[b[F]], h[b[F]], m[b[F]]);
      }, style: function(M) {
        return 1;
      }, radius: function(M) {
        u.element = e.elements[p[v[y[M]]]];
        var T = n.size.size(u);
        u.element = e.elements[p[v[b[M]]]];
        var F = n.size.size(u);
        return Math.min(T, F) * _;
      }, ignore: function(M) {
        if (S[M] === Do.Filtered) return !0;
        if (s) for (var T = y[M], F = v[T], N = v[T + 1]; F < N; ++F) {
          var R = e.elements[p[v[F]]];
          if (!Ke.has(s.elements, R)) return !0;
        }
        return !1;
      } }, C = e4(0, x, i, a), A = C.mesh, (w = C.boundingSphere) ? A.setBoundingSphere(w) : A.triangleCount > 0 && (I = Me.expand(Me(), (s ?? e).boundary.sphere, 1 * _), A.setBoundingSphere(I)), [2, A]) : [2, Vt.createEmpty(a)])) : [2, Vt.createEmpty(a)];
    });
  });
}
var gG = O(O(O({}, Rl), $y), { sizeFactor: z.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: z.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: z.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: z.Boolean(!1) });
function bfe(t) {
  return Ol({ defaultProps: z.getDefaultValues(gG), createGeometry: yfe, createLocationIterator: Sfe, getLoci: _fe, eachLocation: xfe, setUpdateState: function(e, r, n, i, a, o, s) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor || r.dashCount !== n.dashCount || r.dashScale !== n.dashScale || r.dashCap !== n.dashCap || r.radialSegments !== n.radialSegments;
    var u = oi.get(o.structure).version;
    e.info.interactionsHash !== u && (e.createGeometry = !0, e.updateTransform = !0, e.updateColor = !0, e.info.interactionsHash = u);
  } }, t);
}
function _fe(t, e, r) {
  var n = t.objectId, i = t.instanceId, a = t.groupId;
  if (r === n) {
    var o = e.structure, s = e.group, u = o.unitMap.get(s.units[i].id), c = oi.get(o).value, l = c.unitsContacts.get(u.id), d = l.a, f = l.b;
    return Ml.Loci(o, c, [{ unitA: u, indexA: d[a], unitB: u, indexB: f[a] }, { unitA: u, indexA: f[a], unitB: u, indexB: d[a] }]);
  }
  return Dn;
}
var H8 = /* @__PURE__ */ new Set();
function xfe(t, e, r, n) {
  var i = !1;
  if (Ml.isLoci(t)) {
    var a = e.structure, o = e.group;
    if (!tt.areEquivalent(t.data.structure, a)) return !1;
    var s = oi.get(a).value;
    if (t.data.interactions !== s) return !1;
    for (var u = o.units[0], c = s.unitsContacts.get(u.id), l = 2 * c.edgeCount, d = 0, f = t.elements; d < f.length; d++)
      if ((P = f[d]).unitA === P.unitB) {
        var h = o.unitIndexMap.get(P.unitA.id);
        if (h !== void 0) {
          var m = c.getDirectedEdgeIndex(P.indexA, P.indexB);
          m !== -1 && r(Se.ofSingleton(h * l + m)) && (i = !0);
        }
      }
  } else if (Xe.is(t)) {
    if (a = e.structure, o = e.group, !tt.areEquivalent(t.structure, a) || !(s = oi.get(a).value)) return !1;
    u = o.units[0];
    for (var p = s.unitsContacts.get(u.id), v = s.unitsFeatures.get(u.id), g = 2 * p.edgeCount, y = p.offset, b = v.elementsIndex, S = b.offsets, _ = b.indices, x = v.members, C = v.offsets, A = function(M) {
      var T = o.unitIndexMap.get(M.unit.id);
      if (T === void 0) return "continue";
      Ge.forEach(M.indices, function(F) {
        for (var N = S[F], R = S[F + 1]; N < R; ++N) for (var L = _[N], V = y[L], U = y[L + 1]; V < U; ++V) H8.add(V);
      }), H8.forEach(function(F) {
        if (n) {
          for (var N = p.a[F], R = C[N], L = C[N + 1]; R < L; ++R) if (!Ge.has(M.indices, x[R])) return;
          var V = p.b[F];
          for (R = C[V], L = C[V + 1]; R < L; ++R) if (!Ge.has(M.indices, x[R])) return;
        }
        r(Se.ofSingleton(T * g + F)) && (i = !0);
      }), H8.clear();
    }, w = 0, I = t.elements; w < I.length; w++) {
      var P;
      A(P = I[w]);
    }
  }
  return i;
}
function Sfe(t) {
  var e = t.structure, r = t.group, n = r.units[0], i = oi.get(e).value, a = i.unitsContacts.get(n.id), o = 2 * a.edgeCount, s = r.units.length, u = Ml.Location(i, e), c = u.element;
  return gi(o, s, 1, function(l, d) {
    var f = r.units[d];
    return c.unitA = f, c.indexA = a.a[l], c.unitB = f, c.indexB = a.b[l], u;
  });
}
function Cfe(t, e, r, n, i) {
  if (!e.hasAtomic) return Vt.createEmpty(i);
  var a = at.create(e), o = oi.get(e).value, s = o.contacts, u = o.unitsFeatures, c = s.edgeCount, l = s.edges, d = n.sizeFactor;
  if (!c) return Vt.createEmpty(i);
  var f = e.child, h = { linkCount: c, position: function(b, S, _) {
    var x = l[_], C = x.unitA, A = x.indexA, w = x.unitB, I = x.indexB, P = u.get(C), M = u.get(w), T = e.unitMap.get(C), F = e.unitMap.get(w);
    E.set(b, P.x[A], P.y[A], P.z[A]), E.transformMat4(b, b, T.conformation.operator.matrix), E.set(S, M.x[I], M.y[I], M.z[I]), E.transformMat4(S, S, F.conformation.operator.matrix);
  }, style: function(b) {
    return 1;
  }, radius: function(b) {
    var S = l[b], _ = u.get(S.unitA);
    a.unit = e.unitMap.get(S.unitA), a.element = a.unit.elements[_.members[_.offsets[S.indexA]]];
    var x = r.size.size(a), C = u.get(S.unitB);
    a.unit = e.unitMap.get(S.unitB), a.element = a.unit.elements[C.members[C.offsets[S.indexB]]];
    var A = r.size.size(a);
    return Math.min(x, A) * d;
  }, ignore: function(b) {
    if (l[b].props.flag === Do.Filtered) return !0;
    if (f) {
      var S = l[b], _ = f.unitMap.get(S.unitA);
      if (!_) return !0;
      for (var x = e.unitMap.get(S.unitA), C = u.get(S.unitA), A = C.offsets, w = C.members, I = A[S.indexA], P = A[S.indexA + 1]; I < P; ++I) {
        var M = x.elements[w[I]];
        if (!Ke.has(_.elements, M)) return !0;
      }
    }
    return !1;
  } }, m = e4(0, h, n, i), p = m.mesh, v = m.boundingSphere;
  if (v) p.setBoundingSphere(v);
  else if (p.triangleCount > 0) {
    var g = e.child, y = Me.expand(Me(), (g ?? e).boundary.sphere, 1 * d);
    p.setBoundingSphere(y);
  }
  return p;
}
var vG = O(O(O({}, GL), $y), { sizeFactor: z.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: z.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: z.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: z.Boolean(!1) });
function Afe(t) {
  return zL({ defaultProps: z.getDefaultValues(vG), createGeometry: Cfe, createLocationIterator: Efe, getLoci: wfe, eachLocation: Dfe, setUpdateState: function(e, r, n, i, a, o, s) {
    e.createGeometry = r.sizeFactor !== n.sizeFactor || r.dashCount !== n.dashCount || r.dashScale !== n.dashScale || r.dashCap !== n.dashCap || r.radialSegments !== n.radialSegments;
    var u = oi.get(o).version;
    e.info.interactionsHash !== u && (e.createGeometry = !0, e.updateTransform = !0, e.updateColor = !0, e.info.interactionsHash = u);
  } }, t);
}
function wfe(t, e, r) {
  var n = t.objectId, i = t.groupId;
  if (r === n) {
    var a = oi.get(e).value, o = a.contacts.edges[i], s = e.unitMap.get(o.unitA), u = e.unitMap.get(o.unitB);
    return Ml.Loci(e, a, [{ unitA: s, indexA: o.indexA, unitB: u, indexB: o.indexB }, { unitA: u, indexA: o.indexB, unitB: s, indexB: o.indexA }]);
  }
  return Dn;
}
var Gv = /* @__PURE__ */ new Map(), q8 = /* @__PURE__ */ new Set();
function Dfe(t, e, r, n) {
  var i = !1;
  if (Ml.isLoci(t)) {
    if (!tt.areEquivalent(t.data.structure, e)) return !1;
    var a = oi.get(e).value;
    if (t.data.interactions !== a) return !1;
    for (var o = a.contacts, s = 0, u = t.elements; s < u.length; s++) {
      var c = u[s], l = o.getEdgeIndex(c.indexA, c.unitA.id, c.indexB, c.unitB.id);
      l !== -1 && r(Se.ofSingleton(l)) && (i = !0);
    }
  } else if (Xe.is(t)) {
    if (!tt.areEquivalent(t.structure, e) || n && t.elements.length === 1 || !(a = oi.get(e).value)) return !1;
    for (var d = a.contacts, f = a.unitsFeatures, h = 0, m = t.elements; h < m.length; h++) {
      var p = m[h];
      Gv.set(p.unit.id, p.indices);
    }
    for (var v = function(b) {
      var S = b.unit;
      if (!Fe.isAtomic(S)) return "continue";
      Ge.forEach(b.indices, function(_) {
        for (var x = 0, C = d.getContactIndicesForElement(_, S); x < C.length; x++) {
          var A = C[x];
          q8.add(A);
        }
      });
    }, g = 0, y = t.elements; g < y.length; g++)
      v(p = y[g]);
    q8.forEach(function(b) {
      if (n) {
        var S = d.edges[b], _ = S.indexA, x = S.unitA, C = S.indexB, A = S.unitB, w = Gv.get(x), I = Gv.get(A);
        if (!w || !I) return;
        for (var P = f.get(x), M = P.offsets, T = P.members, F = M[_], N = M[_ + 1]; F < N; ++F) if (!Ge.has(w, T[F])) return;
        var R = f.get(A), L = R.offsets, V = R.members;
        for (F = L[C], N = L[C + 1]; F < N; ++F) if (!Ge.has(I, V[F])) return;
      }
      r(Se.ofSingleton(b)) && (i = !0);
    }), Gv.clear(), q8.clear();
  }
  return i;
}
function Efe(t) {
  var e = oi.get(t).value, r = e.contacts, n = r.edgeCount, i = Ml.Location(e, t), a = i.element;
  return gi(n, 1, 1, function(o) {
    var s = r.edges[o];
    return a.unitA = t.unitMap.get(s.unitA), a.indexA = s.indexA, a.unitB = t.unitMap.get(s.unitB), a.indexB = s.indexB, i;
  }, !0);
}
var yG = { "intra-unit": function(t, e) {
  return $a("Intra-unit interactions cylinder", t, e, bfe);
}, "inter-unit": function(t, e) {
  return P0("Inter-unit interactions cylinder", t, e, Afe);
} }, vP = O(O(O({}, gG), vG), { unitKinds: S2(["atomic"]), sizeFactor: z.Numeric(0.15, { min: 0.01, max: 1, step: 0.01 }), visuals: z.MultiSelect(["intra-unit", "inter-unit"], z.objectToOptions(yG)) }), tm, Ml, q1 = { name: "interactions", label: "Non-covalent Interactions", description: "Displays non-covalent interactions as dashed cylinders.", factory: function(t, e) {
  return sr.createMulti("Interactions", t, e, xs, yG);
}, getParams: function(t, e) {
  return z.clone(vP);
}, defaultValues: z.getDefaultValues(vP), defaultColorTheme: { name: "interaction-type" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(t) {
  return t.elementCount > 0 && oi.isApplicable(t);
}, ensureCustomProperties: { attach: function(t, e) {
  return oi.attach(t, e, void 0, !0);
}, detach: function(t) {
  return oi.ref(t, !1);
} }, getData: function(t, e) {
  return e.includeParent ? t.asParent() : t;
}, mustRecreate: function(t, e) {
  return t.includeParent !== e.includeParent;
} }, K8 = { createOrUpdateInCellItems: function(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, s, u;
    return ye(this, function(c) {
      switch (c.label) {
        case 0:
          return a = s3(t, e).structure, o = O(O({}, oi.defaultParams), { type: r }), n && (o.providers.defaultValue = n), [4, oi.attach({ runtime: hs, assetManager: new pl() }, a, o)];
        case 1:
          return c.sent(), e.managers.cell.traverse(function(l, d) {
            var f;
            d.type === Pe.IntraInteractions && (s = l.ref, d.state && ((f = e.canvas3d) === null || f === void 0 || f.remove(d.state), d.state.destroy())), d.type === Pe.BetweenInteractions && e.managers.cell.remove([{ ref: l.ref }]);
          }), (u = q1.factory(e.managers.representation.ctx, q1.getParams)).setTheme({ color: e.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: a }), size: e.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(t, e, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x;
    return ye(this, function(C) {
      switch (C.label) {
        case 0:
          for (a = s3(Ze(Ze([], t, !0), e, !0), r), o = a.unitsMap, s = a.structure, u = O({}, oi.defaultParams), n && (u.providers.defaultValue = n), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), p = 0, d = t.length; p < d; p++) o.get(p).forEach(function(A) {
            return c.add(A);
          });
          for (p = 0, d = e.length; p < d; p++) o.get(p + t.length).forEach(function(A) {
            return l.add(A);
          });
          return [4, oi.attach({ runtime: hs, assetManager: new pl() }, s, u)];
        case 1:
          if (C.sent(), !s.state.propertyData.molstar_computed_interactions) return [2, {}];
          for (f = s.state.propertyData.molstar_computed_interactions.data.value, h = f.contacts, m = f.unitsFeatures, p = 0, v = h.edgeCount; p < v; ++p) g = h.edges[p], y = s.unitMap.get(g.unitA), b = s.unitMap.get(g.unitB), Zr.Info(s, y, m.get(g.unitA)).feature = g.indexA, Zr.Info(s, b, m.get(g.unitB)).feature = g.indexB, c.has(g.unitA) && l.has(g.unitB) || l.has(g.unitA) && c.has(g.unitB) || (h.edges[p].props.flag = Do.Filtered);
          return _ = [], r.managers.cell.traverse(function(A, w) {
            var I;
            w.type === Pe.BetweenInteractions && (S = A.ref, w.state && ((I = r.canvas3d) === null || I === void 0 || I.remove(w.state), w.state.destroy())), w.type === Pe.IntraInteractions && _.push({ ref: A.ref });
          }), [4, r.managers.cell.remove(_)];
        case 2:
          return C.sent(), (x = q1.factory(r.managers.representation.ctx, q1.getParams)).setTheme({ color: r.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: s }), size: r.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: s }) }), [4, x.createOrUpdate({ visuals: ["inter-unit"] }, s).run()];
        case 3:
          return C.sent(), [2, { representation: x, structure: s, ref: S }];
      }
    });
  });
}, createOrUpdateGlobal: function(t, e, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    var o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F, N, R, L, V;
    return ye(this, function(U) {
      switch (U.label) {
        case 0:
          o = /* @__PURE__ */ new Map(), s = [], u = 0, c = [], V9(Vp).forEach(function(H) {
            var K = (n ?? M.providers.defaultValue)[H], X = K.name, Y = K.params;
            X === "on" && c.push(Vp[H].createTester(Y));
          }), l = /* @__PURE__ */ new Set(), c.forEach(function(H) {
            return Ao.add(l, H.requiredFeatures);
          }), d = bG.filter(function(H) {
            return Ao.areIntersecting(l, H.types);
          }), w = 0, I = t.length, U.label = 1;
        case 1:
          return w < I ? (f = t[w], (h = e.cells.get(f.ref)) ? (m = f.elementIds ? fi(on(h), f.elementIds) : on(h), [4, x2.attach({ runtime: hs, assetManager: new pl() }, m)]) : [3, 3]) : [3, 4];
        case 2:
          for (U.sent(), m.currentPropertyData.molstar_computed_valence_model.data.value.forEach(function(H) {
            o.set(u, H), u++;
          }), p = 0, v = m.units.length; p < v; p++) g = xG(m, m.units[p], d), s.push(g);
          U.label = 3;
        case 3:
          return w++, [3, 1];
        case 4:
          for (y = s3(t, e), b = y.unitsMap, S = y.structure, _ = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), A = function(H, K) {
            C.set(t[H].ref, /* @__PURE__ */ new Set());
            var X = b.get(H), Y = e.cells.get(t[H].ref);
            if (Y) {
              var Q = on(Y).units;
              X.forEach(function(J, te) {
                _.set(J, t[H].ref), Q && Q[te] && x.set("".concat(t[H].ref, "_").concat(Q[te].invariantId), J);
              });
            }
          }, w = 0, I = t.length; w < I; w++) A(w);
          return Object.assign(S.currentPropertyData, { molstar_computed_valence_model: { props: { assignCharge: "auto", assignH: "auto" }, data: { id: 3224, version: 1, value: o } } }), P = /* @__PURE__ */ new Set(), a == null || a.map(function(H) {
            var K = H.ref, X = H.elementIds, Y = e.cells.get(K);
            Y && on(Y).units.forEach(function(Q) {
              Q.elements.filter(function(J) {
                return X == null ? void 0 : X.includes(J);
              }).forEach(function(J) {
                return P.add("".concat(x.get("".concat(K, "_").concat(Q.invariantId)), "_").concat(J));
              });
            });
          }), M = O(O({}, oi.defaultParams), { type: r, featuresList: s, filterKeys: a ? Array.from(P.values()) : void 0 }), n && (M.providers.defaultValue = n), [4, oi.attach({ runtime: hs, assetManager: new pl() }, S, M)];
        case 5:
          return U.sent(), T = S.state.propertyData.molstar_computed_interactions.data.value, F = T.contacts, N = T.unitsContacts, R = T.unitsFeatures, F.edges.forEach(function(H) {
            var K = H.indexA, X = H.indexB, Y = H.unitA, Q = H.unitB, J = H.props.flag, te = R.get(Y), W = te.members, j = te.offsets, ee = R.get(Q), ie = ee.members, ae = ee.offsets;
            if (J !== Do.Filtered) {
              var ce = S.unitMap.get(Y).elements[W[j[K]]], de = S.unitMap.get(Q).elements[ie[ae[X]]];
              C.get(_.get(Y)).add(ce), C.get(_.get(Q)).add(de);
            }
          }), Array.from(N.entries()).forEach(function(H) {
            for (var K = H[0], X = H[1], Y = R.get(K), Q = Y.members, J = Y.offsets, te = X.a, W = X.b, j = 0, ee = te.length; j < ee; j++) {
              var ie = S.unitMap.get(K).elements[Q[J[te[j]]]], ae = S.unitMap.get(K).elements[Q[J[W[j]]]];
              C.get(_.get(K)).add(ie), C.get(_.get(K)).add(ae);
            }
          }), e.managers.cell.traverse(function(H, K) {
            var X;
            K.type === Pe.IntraInteractions && (L = H.ref, K.state && ((X = e.canvas3d) === null || X === void 0 || X.remove(K.state), K.state.destroy()));
          }), (V = q1.factory(e.managers.representation.ctx, q1.getParams)).setTheme({ color: e.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: S }), size: e.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: S }) }), [4, V.createOrUpdate({}, S).run()];
        case 6:
          return U.sent(), [2, { representation: V, structure: S, ref: L, interactionElementIds: Array.from(C.keys()).map(function(H) {
            return { ref: H, elementIds: Array.from(C.get(H).values()) };
          }).filter(function(H) {
            return H.elementIds.length;
          }) }];
      }
    });
  });
} };
(function(t) {
  function e(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 f = d.get(o.id), h = f.getDirectedEdgeIndex(s, c);
      return T7(f.edgeProps.type[h]);
    }
    return h = l.getEdgeIndex(s, o.id, c, u.id), T7(l.edges[h].props.type);
  }
  function r(i, a, o) {
    var s = i.unitsFeatures;
    return _p.fromPairProvider(a.length, function(u, c, l) {
      var d = a[u];
      Zr.setPosition(c, d.unitA, d.indexA, s.get(d.unitA.id)), Zr.setPosition(l, d.unitB, d.indexB, s.get(d.unitB.id));
    }, o);
  }
  function n(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, f = a.unitsFeatures, h = f.get(u.id), m = h.members, p = h.offsets, v = f.get(l.id), g = v.members, y = v.offsets, b = { granularity: "element" };
    return (p[c + 1] - p[c] > 1 || y[d + 1] - y[d] > 1) && (b.granularity = "residue"), [e(a, s), Ck(Dt.Location(i, u, m[p[c]], i, l, g[y[d]]), b)].join("</br>");
  }
  t.Location = function(i, a, o, s, u, c) {
    return /* @__PURE__ */ function(l, d, f) {
      return { kind: "data-location", tag: l, data: d, element: f };
    }("interactions", { structure: a, interactions: i }, { unitA: o, indexA: s, unitB: u, indexB: c });
  }, t.isLocation = function(i) {
    return !!i && i.kind === "data-location" && i.tag === "interactions";
  }, t.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;
  }, t.locationLabel = function(i) {
    return e(i.data.interactions, i.element);
  }, t.Loci = function(i, a, o) {
    return hx("interactions", { structure: i, interactions: a }, o, function(s) {
      return r(a, o, s);
    }, function() {
      return n(i, a, o);
    });
  }, t.isLoci = function(i) {
    return !!i && i.kind === "data-loci" && i.tag === "interactions";
  }, t.getBoundingSphere = r, t.getLabel = n;
})(Ml || (Ml = {}));
var bG = [wae, Dae, Eae, Uae, Hae, qae, Nae, Rae, dfe, Jae, $ae], Vp = { ionic: Kae, "pi-stacking": Xae, "cation-pi": Yae, "halogen-bonds": Oae, "hydrogen-bonds": Iae, "weak-hydrogen-bonds": Tae, hydrophobic: ffe, "metal-coordination": eoe }, Ife = function(t) {
  t === void 0 && (t = []);
  var e = /* @__PURE__ */ Object.create(null);
  return Object.keys(Vp).forEach(function(r) {
    e[r] = z.MappedStatic(t.includes(r) ? "on" : "off", { on: z.Group(Vp[r].params), off: z.Group({}) }, { cycle: !0 });
  }), e;
}(["ionic", "cation-pi", "pi-stacking", "hydrogen-bonds", "halogen-bonds", "metal-coordination", "weak-hydrogen-bonds"]), Tfe = ((tm = {})[Na.LigandReceptor] = {}, tm[Na.IntraLigand] = {}, tm[Na.IntraReceptor] = {}, tm[Na.All] = {}, tm), Mfe = Object.keys(Tfe), Pfe = z.arrayToOptions(Mfe), _G = { providers: z.Group(Ife, { isFlat: !0 }), contacts: z.Group(ife, { label: "Advanced Options" }), type: z.Select(Na.LigandReceptor, Pfe, { isEssential: !0, description: "Visual/rendering quality of the representation." }), featuresList: z.Value([], { isHidden: !0 }), filterKeys: z.Value(void 0, { isHidden: !0 }) };
function Bfe(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P;
    return ye(this, function(M) {
      switch (M.label) {
        case 0:
          n = O(O({}, z.getDefaultValues(_G)), r), i = n.type, a = n.featuresList, o = n.filterKeys, s = new Set(o), u = cL(e).data, c = u.ligand, l = u.other, d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), Object.keys(c).forEach(function(T) {
            Object.keys(c[T]).forEach(function(F) {
              c[T][F].forEach(function(N) {
                d.add(N.unitId), f.add("".concat(N.unitId, "_").concat(N.elementId));
              });
            });
          }), Object.keys(l).forEach(function(T) {
            Object.keys(l[T]).forEach(function(F) {
              l[T][F].forEach(function(N) {
                d.add(N.unitId), f.add("".concat(N.unitId, "_").concat(N.elementId));
              });
            });
          }), h = [], V9(Vp).forEach(function(T) {
            var F = n.providers[T], N = F.name, R = F.params;
            N === "on" && h.push(Vp[T].createTester(i === Na.All && ["hydrogen-bonds", "weak-hydrogen-bonds"].includes(T) ? O(O({}, R), { water: !0 }) : R));
          }), m = /* @__PURE__ */ new Set(), h.forEach(function(T) {
            return Ao.add(m, T.requiredFeatures);
          }), p = bG.filter(function(T) {
            return Ao.areIntersecting(m, T.types);
          }), v = bc.Mutable(), g = bc.Mutable(), y = 0, b = e.unitSymmetryGroups.length, M.label = 1;
        case 1:
          return y < b ? (S = e.unitSymmetryGroups[y], t.runtime.shouldUpdate ? [4, t.runtime.update({ message: "computing interactions", current: y, max: b })] : [3, 3]) : [3, 5];
        case 2:
          M.sent(), M.label = 3;
        case 3:
          for (_ = a && a[y] ? a[y] : xG(e, S.units[0], p), x = function(T, F, N, R, L, V) {
            var U = o9.create(N, F.elements.length);
            return Fe.isAtomic(F) && function(H, K, X, Y, Q, J, te) {
              for (var W = 0, j = Q; W < j.length; W++) ufe(H, K, X, Y, j[W], 0, te);
            }(T, F, N, U, R, 0, V), U.getContacts();
          }(e, S.units[0], _, h, n.contacts, function(T, F, N, R) {
            return !!(!o || s.has("".concat(T.invariantId, "_").concat(F)) && s.has("".concat(N.invariantId, "_").concat(R))) && i !== Na.IntraReceptor && (i === Na.All || ["".concat(T.invariantId, "_").concat(F), "".concat(N.invariantId, "_").concat(R)].filter(function(L) {
              return f.has(L);
            }).length === (i === Na.LigandReceptor ? 1 : 2));
          }), C = 0, A = S.units.length; C < A; ++C) w = S.units[C], v.set(w.id, _), g.set(w.id, x);
          M.label = 4;
        case 4:
          return ++y, [3, 1];
        case 5:
          return I = function(T, F, N, R, L) {
            var V = s9.create();
            return tt.eachUnitPair(T, function(U, H) {
              var K = F.get(U.id), X = F.get(H.id);
              (function(Y, Q, J, te, W, j, ee, ie, ae) {
                var ce = J.count, de = J.x, Ce = J.y, De = J.z, ke = W.lookup3d, He = he.mul(cfe, te.conformation.operator.inverse, Q.conformation.operator.matrix), We = !he.isIdentity(He), Ne = E(), Je = Math.max.apply(Math, ee.map(function(ir) {
                  return ir.maxDistance;
                })), Re = ke.boundary.sphere, nt = Re.center, ne = Re.radius, re = (ne + Je) * (ne + Je), le = ie.lineOfSightDistFactor, fe = Zr.Info(Y, Q, J), ge = Zr.Info(Y, te, W);
                j.startUnitPair(Q, te);
                for (var me = 0; me < ce; ++me) if (E.set(Ne, de[me], Ce[me], De[me]), We && E.transformMat4(Ne, Ne, He), !(E.squaredDistance(Ne, nt) > re)) {
                  var Ae = ke.find(Ne[0], Ne[1], Ne[2], Je), Oe = Ae.indices, Ue = Ae.count, Ve = Ae.squaredDistances;
                  if (Ue !== 0) {
                    fe.feature = me;
                    for (var ht = 0; ht < Ue; ++ht) {
                      var bt = Oe[ht];
                      if (ge.feature = bt, (!ae || ae(fe.unit, fe.unit.elements[fe.members[fe.offsets[me]]], ge.unit, ge.unit.elements[ge.members[ge.offsets[bt]]])) && mG(Y, fe, ge)) for (var At = Ve[ht], Ee = 0, st = ee; Ee < st.length; Ee++) {
                        var Et = st[Ee];
                        if (At < Et.maxDistance * Et.maxDistance) {
                          var ur = Et.getType(Y, fe, ge, At);
                          if (ur && sfe(Y, fe, ge, le)) {
                            j.add(me, bt, ur);
                            break;
                          }
                        }
                      }
                    }
                  }
                }
                j.finishUnitPair();
              })(T, U, K, H, X, V, N, R, L == null ? void 0 : L.elementIdFilter);
            }, { maxRadius: Math.max.apply(Math, N.map(function(U) {
              return U.maxDistance;
            })), validUnit: function(U) {
              return Fe.isAtomic(U);
            }, validUnitPair: function(U, H) {
              return tt.validUnitPair(T, U, H) && (!(L != null && L.unitFilter) || L.unitFilter(U, H));
            } }), V.getContacts(F);
          }(e, v, h, n.contacts, { unitFilter: function(T, F) {
            return i === Na.LigandReceptor ? [T.invariantId, F.invariantId].filter(function(N) {
              return d.has(N);
            }).length >= 1 : i !== Na.IntraLigand || [T.invariantId, F.invariantId].filter(function(N) {
              return d.has(N);
            }).length === 2;
          }, elementIdFilter: function(T, F, N, R) {
            return !!(!o || s.has("".concat(T.invariantId, "_").concat(F)) && s.has("".concat(N.invariantId, "_").concat(R))) && (i === Na.All || ["".concat(T.invariantId, "_").concat(F), "".concat(N.invariantId, "_").concat(R)].filter(function(L) {
              return f.has(L);
            }).length === (i === Na.LigandReceptor ? 1 : i === Na.IntraReceptor ? 0 : 2));
          } }), function(T, F) {
            for (var N = F.contacts, R = F.unitsContacts, L = F.unitsFeatures, V = [pfe(0, F), hfe(0, F), mfe(0, F), gfe(0, F), vfe(0, F)], U = /* @__PURE__ */ new Set(), H = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map(), X = 0, Y = N.edgeCount; X < Y; ++X) {
              var Q = N.edges[X], J = T.unitMap.get(Q.unitA), te = T.unitMap.get(Q.unitB);
              if ((Ne = Zr.Info(T, J, L.get(Q.unitA))).feature = Q.indexA, (Je = Zr.Info(T, te, L.get(Q.unitB))).feature = Q.indexB, Q.props.type === 5) {
                for (var W = [], j = (ne = Ne.types[Ne.feature] === 5 ? Ne : Je).offsets[ne.feature], ee = ne.offsets[ne.feature + 1]; j < ee; j++) W.push(ne.members[j]);
                W.length > 1 && H.set(X, W), W.length === 1 && U.add(W[0]);
              }
              if (R.size) for (var ie = 0, ae = V; ie < ae.length; ie++) (fe = ae[ie]).isApplicable(Q.props.type) && fe.handleInterContact(X, Ne, Je);
            }
            for (var ce = R.keys(); ; ) {
              var de = ce.next(), Ce = de.done, De = de.value;
              if (Ce) break;
              var ke = R.get(De), He = L.get(De), We = T.unitMap.get(De);
              if (Fe.isAtomic(We)) {
                for (var Ne = Zr.Info(T, We, He), Je = Zr.Info(T, We, He), Re = 0, nt = V; Re < nt.length; Re++) (fe = nt[Re]).startUnit(We, ke, He);
                for (X = 0, Y = 2 * ke.edgeCount; X < Y; ++X) {
                  if (Ne.feature = ke.a[X], Je.feature = ke.b[X], ke.edgeProps.type[X] === 5) {
                    var ne;
                    for (W = [], j = (ne = Ne.types[Ne.feature] === 5 ? Ne : Je).offsets[ne.feature], ee = ne.offsets[ne.feature + 1]; j < ee; j++) W.push(ne.members[j]);
                    W.length > 1 && K.set(X, { elements: W, value: De }), W.length === 1 && U.add(W[0]);
                  }
                  for (var re = 0, le = V; re < le.length; re++) {
                    var fe;
                    (fe = le[re]).isApplicable(ke.edgeProps.type[X]) && fe.handleIntraContact(X, Ne, Je);
                  }
                }
              }
            }
            H.forEach(function(ge, me) {
              ge.filter(function(Ae) {
                return U.has(Ae);
              }).length > 0 && (N.edges[me].props.flag = Do.Filtered);
            }), K.forEach(function(ge, me) {
              var Ae = ge.elements, Oe = ge.value;
              Ae.filter(function(Ue) {
                return U.has(Ue);
              }).length > 0 && (R.get(Oe).edgeProps.flag[me] = Do.Filtered);
            });
          }(e, P = { unitsFeatures: v, unitsContacts: g, contacts: I }), [2, P];
      }
    });
  });
}
function xG(t, e, r) {
  var n = e.elements.length, i = E7.create(n, n / 2);
  if (Fe.isAtomic(e)) for (var a = 0, o = r; a < o.length; a++)
    o[a].add(t, e, i);
  return i.getFeatures(n);
}
var X8 = O({}, _G), oi = Cp.createProvider({ label: "Interactions", descriptor: ku({ name: "molstar_computed_interactions" }), type: "local", defaultParams: X8, getParams: function(t) {
  return X8;
}, isApplicable: function(t) {
  return !t.isCoarseGrained;
}, obtain: function(t, e, r) {
  return _e(void 0, 0, void 0, function() {
    var n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return n = O(O({}, z.getDefaultValues(X8)), r), i = {}, [4, Bfe(t, e, n)];
        case 1:
          return [2, (i.value = a.sent(), i)];
      }
    });
  });
} }), u9 = qe(13421772), Ja = { HydrogenBond: 16751667, Hydrophobic: 8421504, HalogenBond: 6154474, Ionic: 15820019, MetalCoordination: 11646163, CationPi: 3392621, PiStacking: 4436985, WeakHydrogenBond: 16771231 }, Ffe = [["Hydrogen Bond", Ja.HydrogenBond], ["Hydrophobic", Ja.Hydrophobic], ["Halogen Bond", Ja.HalogenBond], ["Ionic", Ja.Ionic], ["Metal Coordination", Ja.MetalCoordination], ["Cation Pi", Ja.CationPi], ["Pi Stacking", Ja.PiStacking], ["Weak HydrogenBond", Ja.WeakHydrogenBond]];
function yP(t) {
  switch (t) {
    case br.HydrogenBond:
      return Ja.HydrogenBond;
    case br.Hydrophobic:
      return Ja.Hydrophobic;
    case br.HalogenBond:
      return Ja.HalogenBond;
    case br.Ionic:
      return Ja.Ionic;
    case br.MetalCoordination:
      return Ja.MetalCoordination;
    case br.CationPi:
      return Ja.CationPi;
    case br.PiStacking:
      return Ja.PiStacking;
    case br.WeakHydrogenBond:
      return Ja.WeakHydrogenBond;
    case br.Unknown:
      return u9;
  }
}
var bP = {}, rm, Ad, nm, Qf, zv, Nfe = { name: "interaction-type", label: "Interaction Type", category: "Miscellaneous", factory: function t(e, r) {
  var n, i = e.structure ? oi.get(e.structure) : void 0, a = i ? Wp(i.id, i.version) : -1;
  return n = i && i.value ? function(o) {
    if (Ml.isLocation(o)) {
      var s = o.data.interactions, u = s.unitsContacts, c = s.contacts, l = o.element, d = l.unitA, f = l.unitB, h = l.indexA, m = l.indexB;
      if (d === f) {
        var p = u.get(d.id), v = p.getDirectedEdgeIndex(h, m);
        return yP(p.edgeProps.type[v]);
      }
      return v = c.getEdgeIndex(h, d.id, m, f.id), yP(c.edges[v].props.type);
    }
    return u9;
  } : function() {
    return u9;
  }, { factory: t, granularity: "group", color: n, props: r, contextHash: a, description: "Assigns colors according the interaction type of a link.", legend: zu(Ffe) };
}, getParams: function(t) {
  return bP;
}, defaultValues: z.getDefaultValues(bP), isApplicable: function(t) {
  return !!t.structure;
}, ensureCustomProperties: { attach: function(t, e) {
  return e.structure ? oi.attach(t, e.structure, void 0, !0) : Promise.resolve();
}, detach: function(t) {
  return t.structure && oi.ref(t.structure, !1);
} } }, c9 = { color: (rm = {}, rm[St.ATOM] = { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: qe(14474728) } } } }, rm[St.RIBBON] = { name: "uniform", props: { value: qe(14474728) } }, rm[St.SURFACE] = { name: "uniform" }, rm), size: (Ad = {}, Ad[Pe.BallAndStick] = { name: "physical" }, Ad[Pe.Stick] = { name: "uniform" }, Ad[Pe.Line] = { name: "physical" }, Ad[Pe.CPK] = { name: "physical" }, Ad[Pe.Ribbon] = { name: "uniform" }, Ad[Pe.Surface] = { name: "physical" }, Ad), transparency: (nm = {}, nm[St.ATOM] = 0, nm[St.RIBBON] = 0, nm[St.SURFACE] = 0, nm) }, Y8 = { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: qe(4777267) } } } }, Rfe = function() {
  function t(e, r) {
    this.plugin = e, this.defaultTheme = O(O({}, c9), r);
  }
  return t.prototype.createColorTheme = function(e, r, n) {
    var i, a, o, s, u, c = this;
    return e.name === "multi-theme" ? (i = this.ctx) === null || i === void 0 ? void 0 : i.colorThemeRegistry.create("multi-theme", { structure: r }, { themes: (s = !((o = (a = e.props) === null || a === void 0 ? void 0 : a.themes) === null || o === void 0) && o.length ? e.props.themes : [this.defaultTheme.color[n]]) === null || s === void 0 ? void 0 : s.map(function(l) {
      return { colorTheme: c.createColorTheme(l, l.elementIds ? fi(r, l.elementIds) : r, n), bundle: So.fromLoci(pi(r, l.elementIds)) };
    }) }) : (u = this.ctx) === null || u === void 0 ? void 0 : u.colorThemeRegistry.create(e.name, { structure: e.elementIds ? fi(r, e.elementIds) : r }, e.props);
  }, t.prototype.createTheme = function(e, r, n) {
    var i = Object.keys(Bn).find(function(s) {
      return Bn[s].includes(e);
    }), a = n != null && n.color ? n == null ? void 0 : n.color : this.defaultTheme.color[i], o = n != null && n.size ? n == null ? void 0 : n.size : this.defaultTheme.size[e];
    return { color: this.createColorTheme(a, r, i), size: this.ctx.sizeThemeRegistry.create(o.name, { structure: r }, o.props) };
  }, t.prototype.createTransparencyLayers = function(e, r) {
    if (!(r != null && r.length)) return { kind: "empty-loci", layers: [] };
    var n = r.map(function(i) {
      var a = i.elementIds, o = i.value;
      return { loci: pi(e, a), value: o !== void 0 ? 1 - o : 0 };
    });
    return { kind: "element-loci", layers: n };
  }, t.prototype.setColorTheme = function(e, r, n) {
    var i = this;
    e.forEach(function(a) {
      var o, s, u, c, l = a.ref, d = a.elementIds, f = i.plugin.cells.get(l);
      if (!(f != null && f.model.structure) && (f != null && f.representations.has(Pe.Surface))) {
        if (n !== St.SURFACE) return;
        var h = Xe.toStructure(Oa(f.representations.get(Pe.Surface).state.getLoci())), m = ms(h);
        return f.theme.color = ((o = { Atom: [], Ribbon: [] })[St.SURFACE] = [O({ elementIds: m }, r)], o), void c3[Pe.Surface].update((u = f == null ? void 0 : f.representations.get(Pe.Surface)) === null || u === void 0 ? void 0 : u.state, h, i.ctx, i.createTheme(Pe.Surface, h, { color: r }));
      }
      var p = Ze([], d ?? [], !0);
      d || p.push.apply(p, oa(tt.toStructureElementLoci(on(f))));
      var v = new Set(p);
      f && (f.theme.color ? (!((c = f.theme.color[n]) === null || c === void 0) && c.length && (f.theme.color[n].forEach(function(g, y) {
        f.theme.color[n][y].elementIds = f.theme.color[n][y].elementIds.filter(function(b) {
          return !v.has(b);
        });
      }), f.theme.color[n] = f.theme.color[n].filter(function(g) {
        var y = g.elementIds;
        return y == null ? void 0 : y.length;
      })), f.theme.color[n].push(O({ elementIds: Array.from(v.values()) }, r))) : f.theme.color = ((s = { Atom: [], Ribbon: [], Surface: [] })[n] = [O({ elementIds: Array.from(v.values()) }, r)], s), Bn[n].forEach(function(g) {
        var y, b = f.representations.get(g);
        if (b) {
          var S = Vo(b.state);
          eu[g].update(b.state, S, i.ctx, { color: i.ctx.colorThemeRegistry.create("multi-theme", { structure: S }, { themes: (y = f.theme.color[n]) === null || y === void 0 ? void 0 : y.map(function(_) {
            return { colorTheme: i.createColorTheme(_, S, n), bundle: So.fromLoci(pi(S, _.elementIds)) };
          }) }), size: b.state.theme.size });
        }
      }));
    }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: setColorTheme" });
  }, t.prototype.setTransparency = function(e, r, n) {
    var i = this, a = /* @__PURE__ */ new Set();
    e.forEach(function(s) {
      var u, c, l, d, f = s.ref, h = s.elementIds, m = i.plugin.cells.get(f);
      if (!(m != null && m.model.structure) && (m != null && m.representations.has(Pe.Surface))) {
        if (n !== St.SURFACE) return;
        var p = Xe.toStructure(Oa(m.representations.get(Pe.Surface).state.getLoci())), v = ms(p);
        return m.theme.transparency = ((u = {})[St.SURFACE] = [{ elementIds: v, value: r }], u), void ((l = m == null ? void 0 : m.representations.get(Pe.Surface)) === null || l === void 0 || l.state.setState({ transparency: i.createTransparencyLayers(Vo((d = m == null ? void 0 : m.representations.get(Pe.Surface)) === null || d === void 0 ? void 0 : d.state), m == null ? void 0 : m.theme.transparency[n]) }));
      }
      var g = Ze([], h ?? [], !0);
      !h && m && (p = on(m)) && g.push.apply(g, oa(tt.toStructureElementLoci(p)));
      var y = new Set(g);
      if (m) if (a.add(f), m.theme.transparency) {
        var b = m.theme.transparency[n];
        b.length && (b.forEach(function(S, _) {
          S.elementIds, b[_].elementIds = g.filter(function(x) {
            return !y.has(x);
          });
        }), m.theme.transparency[n] = b.filter(function(S) {
          return S.elementIds, g.length;
        })), m.theme.transparency[n].push({ elementIds: Array.from(y.values()), value: r });
      } else m.theme.transparency = ((c = {})[St.ATOM] = [], c[St.RIBBON] = [], c[St.SURFACE] = [], c[n] = { elementIds: Array.from(y.values()), value: r }, c);
    });
    var o = Bn[n];
    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 = Vo(l.state), f = i.createTransparencyLayers(d, u == null ? void 0 : u.theme.transparency[n]);
          l.state.setState({ transparency: f });
        }
      });
    }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: setColorTheme" });
  }, t.prototype.setDefaultTheme = function(e) {
    var r;
    this.defaultTheme = O(O(O({}, c9), (r = this.defaultTheme) !== null && r !== void 0 ? r : {}), e);
  }, t;
}(), im = [Pe.BallAndStick, Pe.Line, Pe.Stick, Pe.CPK], Ofe = function(t) {
  function e(r, n, i) {
    var a = t.call(this, r, n) || this;
    return a.ev = wo.create(), a.event = { interactionParamsUpdated: a.ev(), interactionUpdated: a.ev() }, a.plugin = r, a.type = Na.LigandReceptor, a.interactionParams = O(O({}, i), P7()), a;
  }
  return ka(e, t), e.prototype.showInteractionInCellItems = function(r, n, i, a) {
    var o;
    return _e(this, 0, void 0, function() {
      var s, u, c, l, d, f, h = this;
      return ye(this, function(m) {
        switch (m.label) {
          case 0:
            return s = /* @__PURE__ */ new Map(), a && Array.from(r.map(function(p) {
              return p.ref;
            })).forEach(function(p) {
              var v = h.plugin.cells.get(p);
              if (v) {
                var g = [];
                Bn[St.ATOM].forEach(function(y) {
                  v.representations.has(y) && v.representations.get(y).state && g.push.apply(g, oa(Oa(v.representations.get(y).state.getLoci())));
                }), s.set(p, new Set(g));
              }
            }), u = a ? r.map(function(p) {
              var v, g, y = p.ref, b = p.elementIds, S = b ? b.filter(function(_) {
                var x;
                return (x = s.get(y)) === null || x === void 0 ? void 0 : x.has(_);
              }) : Array.from((g = (v = s.get(y)) === null || v === void 0 ? void 0 : v.values()) !== null && g !== void 0 ? g : []);
              return { ref: y, elementIds: S };
            }).filter(function(p) {
              return p.elementIds.length;
            }) : r, [4, K8.createOrUpdateInCellItems(u, this.plugin, n, this.interactionParams, i)];
          case 1:
            return c = m.sent(), l = c.representation, d = c.ref, f = { representations: [{ state: l, isHidden: !1, type: Pe.IntraInteractions }], model: { other: null }, dependency: { on: r } }, (o = this.plugin.canvas3d) === null || o === void 0 || o.add(l), d ? (this.plugin.managers.cell.update(d, f), [2, d]) : [2, this.plugin.managers.cell.create(f)];
        }
      });
    });
  }, e.prototype.showInteractionBetweenCellItems = function(r, n, i, a) {
    var o;
    return a === void 0 && (a = !1), _e(this, 0, void 0, function() {
      var s, u, c, l, d, f, h, m = this;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            return s = /* @__PURE__ */ new Map(), a && Array.from(Ze(Ze([], r, !0), n, !0).map(function(v) {
              return v.ref;
            })).forEach(function(v) {
              var g = m.plugin.cells.get(v);
              if (g) {
                var y = [];
                Bn[St.ATOM].forEach(function(b) {
                  g.representations.has(b) && g.representations.get(b).state && y.push.apply(y, oa(Oa(g.representations.get(b).state.getLoci())));
                }), s.set(v, new Set(y));
              }
            }), u = a ? r.map(function(v) {
              var g, y, b = v.ref, S = v.elementIds, _ = S ? S.filter(function(x) {
                var C;
                return (C = s.get(b)) === null || C === void 0 ? void 0 : C.has(x);
              }) : Array.from((y = (g = s.get(b)) === null || g === void 0 ? void 0 : g.values()) !== null && y !== void 0 ? y : []);
              return { ref: b, elementIds: _ };
            }).filter(function(v) {
              return v.elementIds.length;
            }) : r, c = a ? n.map(function(v) {
              var g, y, b = v.ref, S = v.elementIds, _ = S ? S.filter(function(x) {
                var C;
                return (C = s.get(b)) === null || C === void 0 ? void 0 : C.has(x);
              }) : Array.from((y = (g = s.get(b)) === null || g === void 0 ? void 0 : g.values()) !== null && y !== void 0 ? y : []);
              return { ref: b, elementIds: _ };
            }).filter(function(v) {
              return v.elementIds.length;
            }) : n, [4, K8.createOrUpdateBetweenCellItems(u, c, this.plugin, this.interactionParams, i)];
          case 1:
            return l = p.sent(), d = l.representation, f = l.ref, d ? (h = { representations: [{ state: d, isHidden: !1, type: Pe.BetweenInteractions }], model: { other: { itemsA: u, itemsB: c } }, dependency: { on: u.concat(c) } }, (o = this.plugin.canvas3d) === null || o === void 0 || o.add(d), f ? (this.plugin.managers.cell.update(f, h), [2]) : [2, this.plugin.managers.cell.create(h)]) : [2];
        }
      });
    });
  }, e.prototype.setInteractionParams = function(r, n) {
    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 === n && r.length === a.size && r.every(function(s) {
      return a.has(s);
    })) return !1;
    this.type = n, this.interactionParams = P7(r);
    var o = !1;
    return this.plugin.managers.cell.traverse(function(s, u) {
      u.type === Pe.IntraInteractions && (o = !0, i.showGlobalInteraction(void 0, "lightPlugin.managers.representation.interactions.setInteractionParams"));
    }), this.event.interactionParamsUpdated.next({ params: this.interactionParams, type: n }), o;
  }, e.prototype.showGlobalInteraction = function(r, n) {
    var i;
    return _e(this, 0, void 0, function() {
      var a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S = this;
      return ye(this, function(_) {
        switch (_.label) {
          case 0:
            return a = /* @__PURE__ */ new Map(), o = TL(this.plugin), r && Array.from(o.map(function(x) {
              return x.ref;
            })).forEach(function(x) {
              var C = S.plugin.cells.get(x);
              if (C) {
                var A = [];
                Bn[St.ATOM].forEach(function(w) {
                  C.representations.has(w) && C.representations.get(w).state && A.push.apply(A, oa(Oa(C.representations.get(w).state.getLoci())));
                }), a.set(x, new Set(A));
              }
            }), s = r ? o.map(function(x) {
              var C, A, w = x.ref, I = x.elementIds, P = I ? I.filter(function(M) {
                var T;
                return (T = a.get(w)) === null || T === void 0 ? void 0 : T.has(M);
              }) : Array.from((A = (C = a.get(w)) === null || C === void 0 ? void 0 : C.values()) !== null && A !== void 0 ? A : []);
              return { ref: w, elementIds: P };
            }).filter(function(x) {
              return x.elementIds.length;
            }) : void 0, [4, K8.createOrUpdateGlobal(o, this.plugin, this.type, this.interactionParams, void 0, s)];
          case 1:
            if (u = _.sent(), c = u.representation, l = u.ref, d = u.interactionElementIds, f = { representations: [{ state: c, isHidden: !1, type: Pe.IntraInteractions }], model: { other: { type: this.type } }, dependency: { on: o } }, (i = this.plugin.canvas3d) === null || i === void 0 || i.add(c), r) return [3, 5];
            h = [], m = {}, d.forEach(function(x) {
              var C, A = x.ref, w = x.elementIds, I = S.plugin.cells.get(A);
              if (I) {
                m[A] = ((C = {})[Pe.BallAndStick] = /* @__PURE__ */ new Set(), C[Pe.Line] = /* @__PURE__ */ new Set(), C[Pe.Stick] = /* @__PURE__ */ new Set(), C[Pe.CPK] = /* @__PURE__ */ new Set(), C);
                var P = new Set(w);
                im.forEach(function(M) {
                  if (I.representations.has(M) && I.representations.get(M).state) {
                    var T = jy(I.representations.get(M).state);
                    m[A][M] = new Set(T), P.forEach(function(F) {
                      m[A][M].has(F) && P.delete(F);
                    });
                  }
                }), P.size && h.push({ ref: A, elementIds: Array.from(P.values()) });
              }
            }), (b = {})[Pe.BallAndStick] = [], b[Pe.Line] = [], b[Pe.Stick] = [], b[Pe.CPK] = [], p = b, h.forEach(function(x) {
              var C, A = x.ref, w = x.elementIds, I = ((C = {})[Pe.BallAndStick] = [], C[Pe.Line] = [], C[Pe.Stick] = [], C[Pe.CPK] = [], C), P = /* @__PURE__ */ new Map();
              if (w != null && w.length) {
                var M = S.plugin.managers.cell.get(A), T = on(M);
                if (T) {
                  var F = new Set(w), N = new Set(w.map(function(L) {
                    return ry(DL(T, L), Kr.Residue);
                  })), R = /* @__PURE__ */ new Map();
                  T.units.forEach(function(L) {
                    L.elements.forEach(function(V) {
                      var U = Ac(L, V), H = ry(U, Kr.Residue);
                      N.has(H) && (P.has(H) || P.set(H, /* @__PURE__ */ new Set()), (F.has(V) || U.typeSymbol !== "H" || Qy(T, V) === Oi.Polar) && R.set(H, Ze([V], R.has(H) ? R.get(H) : [], !0)), im.some(function(K) {
                        var X, Y;
                        !((X = m[A][K]) === null || X === void 0) && X.has(V) && ((Y = P.get(H)) === null || Y === void 0 || Y.add(K));
                      }));
                    });
                  }), N.forEach(function(L) {
                    var V, U, H = P.get(L);
                    H && H.size !== 0 ? H.size > 0 && (U = I[Array.from(H.values())[0]]).push.apply(U, R.get(L)) : (V = I[Pe.Stick]).push.apply(V, R.get(L));
                  }), im.forEach(function(L) {
                    I[L].length && p[L].push({ ref: A, elementIds: I[L] });
                  });
                }
              }
            }), v = 0, g = im.length, _.label = 2;
          case 2:
            return v < g ? (y = im[v], p[y].length ? [4, this.plugin.managers.representation.setMolecularRepr(p[y], y, !0, !1)] : [3, 4]) : [3, 5];
          case 3:
            _.sent(), _.label = 4;
          case 4:
            return v++, [3, 2];
          case 5:
            return l ? (this.plugin.managers.cell.update(l, f), this.event.interactionUpdated.next({ from: n }), [2, d]) : (this.event.interactionUpdated.next({ from: n }), [4, this.plugin.managers.cell.create(f)]);
          case 6:
            return _.sent(), [2, d];
        }
      });
    });
  }, e;
}(Rfe), SG = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, hL(t).run()];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, mL(e.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, Lfe = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, Nx(t).run()];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, mf(e.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, kfe = function(t, e) {
  return _e(void 0, 0, void 0, function() {
    var r, n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, Nx(t).run()];
        case 1:
          if ((r = a.sent()).isError) throw r;
          return n = r.result, e && (o = e[0], n.molecules[0], s = o.graph.graphs, u = s.nodes, c = s.adjacency, l = [], d = [], u.forEach(function(f, h) {
            c[h].forEach(function(m) {
              m.to_jimage.some(function(p) {
                return p !== 0;
              }) || (l.push(f.id), d.push(m.id));
            });
          }), i = { count: l.length, atomA: l, atomB: d }, n.molecules[0] = O(O({}, n.molecules[0]), { bonds: i })), [4, mf(n).run()];
        case 2:
          return [2, a.sent()];
      }
      var o, s, u, c, l, d;
    });
  });
}, Gfe = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, lL(t).run()];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, dL(e.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, zfe = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, bL(t).run()];
        case 1:
          if ((e = r.sent()).isError) throw e;
          return [4, _L(e.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, Vfe = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(e) {
      switch (e.label) {
        case 0:
          return [4, mf(xL(t)).run()];
        case 1:
          return [2, e.sent()];
      }
    });
  });
} }, Ufe = { parse: function(t) {
  return _e(this, 0, void 0, function() {
    var e;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, SL(t).run()];
        case 1:
          if ((e = r.sent()).isError) throw new Error(e.message);
          return [4, mf(e.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, l9 = ((Qf = {})[gr.Dump] = Lfe, Qf[gr.Gro] = SG, Qf[gr.Pdb] = Gfe, Qf[gr.Xyz] = zfe, Qf[gr.Material] = Vfe, Qf[gr.Pymatgen] = Ufe, Qf), _P = function(t) {
  function e(r, n, i) {
    var a = t.call(this, r, n) || this;
    return a.defaultTheme = O(O({}, c9), n), a.plugin = r, a.interactionParams = O(O({}, i), P7()), a.showPolarHydrogenOnly = !0, a.ctx = { webgl: void 0, colorThemeRegistry: El.createRegistry(), sizeThemeRegistry: Co.createRegistry(), props: { hideBond: !1 } }, a;
  }
  return ka(e, t), Object.defineProperty(e.prototype, "hideBond", { get: function() {
    var r, n;
    return (n = (r = this.ctx) === null || r === void 0 ? void 0 : r.props.hideBond) !== null && n !== void 0 && n;
  }, set: function(r) {
    this.ctx.props.hideBond !== r && (this.ctx.props.hideBond = r, this.plugin.managers.cell.traverse(function(n, i) {
      var a, o, s, u, c;
      if (toe.has(i.type)) {
        var l = r ? (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(Ze(Ze([], (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 }, Vo(i.state)).run();
      }
    }));
  }, enumerable: !1, configurable: !0 }), e.prototype.createContext = function() {
    this.ctx = { webgl: this.plugin.canvas3d.webgl, colorThemeRegistry: El.createRegistry(), sizeThemeRegistry: Co.createRegistry(), props: { hideBond: !1 } }, this.ctx.colorThemeRegistry.add(Nfe);
  }, e.prototype.createMolecular = function(r) {
    var n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w;
    return _e(this, 0, void 0, function() {
      var I, P, M, T, F, N, R, L, V, U, H, K, X, Y, Q, J, te, W, j, ee, ie, ae, ce, de, Ce, De, ke, He = this;
      return ye(this, function(We) {
        switch (We.label) {
          case 0:
            I = r.format, P = r.reprType, M = r.theme, T = M === void 0 ? {} : M, F = r.elementIds, N = r.ref, R = r.defaultShown, L = r.updateInteraction, V = L === void 0 || L, U = r.autoConvertToTrajectory, H = U !== void 0 && U, We.label = 1;
          case 1:
            return We.trys.push([1, 12, , 13]), (K = typeof r.data == "string" || r.data instanceof File) ? [4, y0(r.data)] : [3, 3];
          case 2:
            return Y = We.sent(), [3, 4];
          case 3:
            Y = r.data, We.label = 4;
          case 4:
            return X = Y, [4, Il[I].parse(X)];
          case 5:
            return (Q = We.sent()).length > 1 && H && l9[I] ? [4, this.plugin.managers.trajectory.importTrajectory({ data: X, format: I })] : [3, 7];
          case 6:
            return [2, (J = We.sent()) ? [J] : []];
          case 7:
            te = r.data instanceof File ? r.data.name : "", W = R ?? Q.length, j = Object.keys(Bn).find(function(Ne) {
              return Bn[Ne].includes(P);
            }), ee = [], ie = 0, ae = function(Ne) {
              var Je, Re, nt, ne, re, le, fe, ge, me, Ae, Oe, Ue, Ve, ht, bt, At, Ee, st, Et, ur;
              return ye(this, function(ir) {
                switch (ir.label) {
                  case 0:
                    return Je = Ze([], F ?? [], !0), Re = Ne, ce.showPolarHydrogenOnly && J1.has(P) && (Je = (F ?? ms(Ne)).filter(function(Nr) {
                      return !Uh(Ne, Nr);
                    }), Re = fi(Ne, Je)), nt = !W, ne = I === gr.Material || ((n = Zy(Ne, I)) !== null && n !== void 0 ? n : K) ? X : Use(Ne, I), re = { representations: [{ isHidden: nt, type: P }], model: {}, assets: [{ format: I, data: ["sdf", "mol"].includes(I) && te && !(ne != null && ne.split(`
`)[0].trim()) ? Ze(["".concat(te).concat(ie > 0 ? "_".concat(ie) : "")], ne.split(`
`).slice(1), !0).join(`
`) : ne }], theme: { color: (Ve = {}, Ve[j] = [O({ elementIds: F ?? oa(tt.toStructureElementLoci(Ne)) }, (a = (i = T[j]) === null || i === void 0 ? void 0 : i.color) !== null && a !== void 0 ? a : j === St.ATOM ? Y8 : ce.defaultTheme.color[j])], Ve), transparency: (ht = {}, ht[St.ATOM] = [], ht[St.RIBBON] = [], ht[St.SURFACE] = [], ht[j] = !((o = T[j]) === null || o === void 0) && o.transparency ? [(s = T[j]) === null || s === void 0 ? void 0 : s.transparency] : [], ht), size: (bt = {}, bt[St.ATOM] = [], bt[St.RIBBON] = [], bt[St.SURFACE] = [], bt[j] = !((u = T[j]) === null || u === void 0) && u.size ? [(c = T[j]) === null || c === void 0 ? void 0 : c.size] : [], bt) }, ref: N }, ie++, nt ? [3, 2] : [4, eu[P].create(Re, ce.ctx, ce.createTheme(P, Ne, O(O({}, T[j]), j !== St.ATOM || !((l = T[j]) === null || l === void 0) && l.color ? {} : { color: Y8 })))];
                  case 1:
                    return le = ir.sent(), !((d = T[j]) === null || d === void 0) && d.transparency && le.setState({ transparency: ce.createTransparencyLayers(Ne, [(f = T[j]) === null || f === void 0 ? void 0 : f.transparency]) }), W--, (h = ce.plugin.canvas3d) === null || h === void 0 || h.add(le), Object.assign(re.representations[0], { state: le }), [3, 3];
                  case 2:
                    Object.assign(re.representations[0], { cache: { isHidden: nt, type: P, elementIds: Je } }), ir.label = 3;
                  case 3:
                    return fe = ce.plugin.managers.cell.create(re), ee.push(fe), I !== gr.Pdb || F != null && F.length ? [3, 7] : (ge = z7(Ne), me = ge.polymer, (Ae = ge.other).length ? nt ? [3, 6] : (Oe = fi(Ne, me), [4, eu[Pe.Ribbon].update(re.representations[0].state, fi(Ne, me), ce.ctx, ce.createTheme(Pe.Ribbon, Oe, T[St.RIBBON]))]) : [3, 7]);
                  case 4:
                    return ir.sent(), Ue = fi(Ne, Ae), ce.plugin.managers.cell.update(fe, { representations: [], model: { structure: Ne }, theme: { color: (At = {}, At[St.ATOM] = [O({ elementIds: Ae ?? oa(tt.toStructureElementLoci(Ne)) }, (p = (m = T[St.ATOM]) === null || m === void 0 ? void 0 : m.color) !== null && p !== void 0 ? p : { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: qe(4777267) } } } })], At), transparency: (Ee = {}, Ee[St.ATOM] = !((v = T[St.ATOM]) === null || v === void 0) && v.transparency ? [(g = T[St.ATOM]) === null || g === void 0 ? void 0 : g.transparency] : [], Ee), size: (st = {}, st[St.ATOM] = [], st[St.RIBBON] = [], st[St.SURFACE] = [], st[j] = !((y = T[St.ATOM]) === null || y === void 0) && y.size ? [(b = T[St.ATOM]) === null || b === void 0 ? void 0 : b.size] : [], st) } }), [4, ce.addMolecularRepr(fe, { elementIds: Ae, reprType: Pe.BallAndStick, isHidden: nt, theme: ce.createTheme(Pe.BallAndStick, Ue, O({ color: O({ elementIds: Ae }, Y8) }, T[St.ATOM])), transparency: !((S = T[St.ATOM]) === null || S === void 0) && S.transparency ? [(_ = T[St.ATOM]) === null || _ === void 0 ? void 0 : _.transparency] : void 0 })];
                  case 5:
                    return ir.sent(), [3, 7];
                  case 6:
                    ce.plugin.managers.cell.update(fe, { representations: [O(O({}, re.representations[0]), { cache: O(O({}, re.representations[0].cache), { elementIds: me }) }), { isHidden: nt, type: Pe.BallAndStick, cache: { isHidden: nt, type: Pe.BallAndStick, elementIds: Ae } }], model: {}, theme: { color: (Et = {}, Et[St.ATOM] = [O({ elementIds: Ae ?? oa(tt.toStructureElementLoci(Ne)) }, (C = (x = T[St.ATOM]) === null || x === void 0 ? void 0 : x.color) !== null && C !== void 0 ? C : { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: qe(4777267) } } } })], Et), transparency: (ur = {}, ur[St.ATOM] = !((A = T[St.ATOM]) === null || A === void 0) && A.transparency ? [(w = T[St.ATOM]) === null || w === void 0 ? void 0 : w.transparency] : [], ur) } }), ir.label = 7;
                  case 7:
                    return nt || ce.plugin.managers.cell.update(fe, { model: { structure: Ne } }), V && ce.plugin.managers.cell.traverse(function(Nr, pr) {
                      pr.type === Pe.IntraInteractions && He.plugin.managers.representation.showGlobalInteraction(void 0, "lightPlugin.managers.representation.createMolecular");
                    }), ce.plugin.managers.snapshot.event.changed.next({ from: "repr: createMolecular" }), [2];
                }
              });
            }, ce = this, de = 0, Ce = Q, We.label = 8;
          case 8:
            return de < Ce.length ? (De = Ce[de], [5, ae(De)]) : [3, 11];
          case 9:
            We.sent(), We.label = 10;
          case 10:
            return de++, [3, 8];
          case 11:
            return [2, ee];
          case 12:
            return ke = We.sent(), console.log(ke), [2, []];
          case 13:
            return [2];
        }
      });
    });
  }, e.prototype.updateMolecular = function(r) {
    var n;
    return _e(this, 0, void 0, function() {
      var i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I = this;
      return ye(this, function(P) {
        for (i = r.ref, a = r.structure, o = this.plugin.managers.cell.get(i), s = Xe.toExpression(tt.toStructureElementLoci(o.model.structure)), u = Xe.toExpression(tt.toStructureElementLoci(a)), c = Nt.struct.modifier.exceptBy({ 0: u, by: s }), (l = ms(kp(Lp(a, c)))).length && (((d = o.theme.color[St.ATOM]) == null ? void 0 : d.length) === 1 ? d[0].elementIds ? (A = d[0].elementIds).push.apply(A, l) : d[0].elementIds = Ze([], l, !0) : d == null || d.push(O({ elementIds: l }, this.defaultTheme.color[St.ATOM])), this.plugin.managers.cell.update(i, { representations: [], model: {}, theme: { color: (w = {}, w[St.ATOM] = d, w) } })), (f = [Pe.BallAndStick, Pe.Stick, Pe.Line, Pe.CPK]).forEach(function(M) {
          !h && o.representations.has(M) && (h = M);
        }), m = function(M) {
          var T = M[0], F = M[1], N = Object.keys(Bn).find(function(H) {
            return Bn[H].includes(T);
          }), R = o.theme.color[N], L = F.state.getLoci(), V = Xe.toExpression(tt.toStructureElementLoci(L.structure));
          f.includes(T) && T !== h || (V = Nt.struct.modifier.union([Nt.struct.combinator.merge([c, V])]));
          var U = kp(Lp(a, V));
          eu[T].update(F.state, U, p.ctx, p.createTheme(T, a, { color: { name: "multi-theme", props: { themes: R } }, size: o.theme.size && (!((n = o.theme.size[N]) === null || n === void 0) && n.length) ? o.theme.size[N][0] : p.defaultTheme.size[T] })), F.state.setState({ transparency: p.createTransparencyLayers(U, o == null ? void 0 : o.theme.transparency[N]) });
        }, p = this, v = 0, g = Array.from(o.representations); v < g.length; v++) y = g[v], m(y);
        for (b = function(M) {
          var T = S.plugin.cells.get(M);
          T && T.representations.forEach(function(F, N) {
            N === Pe.IntraInteractions && I.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.updateMolecular"), Object.keys(Am).includes(N) && I.plugin.managers.representation.updateMeasurement({ items: T.dependency.on, ref: M });
          });
        }, S = this, _ = 0, x = o.dependency.by; _ < x.length; _++) C = x[_], b(C);
        return this.plugin.managers.snapshot.event.changed.next({ from: "repr: updateMolecular" }), [2, o];
      });
    });
  }, e.prototype.createMeasurement = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u, c, l, d, f, h, m;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            if (n = r.type, i = r.theme, a = r.items, o = r.ref, s = r.isHidden, !Op.has(n)) return console.warn("There is no ".concat(n, " type ")), [2, ""];
            u = [], c = 0, l = a, p.label = 1;
          case 1:
            return c < l.length ? (d = l[c], [4, this.plugin.managers.cell.getStructure(d.ref)]) : [3, 4];
          case 2:
            if (!(f = p.sent())) return [2, ""];
            u.push(pi(f, d.elementIds)), p.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            return [4, Am[n].create(u, this.ctx, r.props, i)];
          case 5:
            return h = p.sent(), m = this.plugin.managers.cell.create({ representations: [{ state: h, isHidden: s != null && s, type: n }], model: { loci: u }, dependency: { on: a }, ref: o }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createMeasurement" }), [2, m];
        }
      });
    });
  }, e.prototype.updateMeasurement = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u, c, l, d, f = this;
      return ye(this, function(h) {
        switch (h.label) {
          case 0:
            return n = r.items, i = r.ref, a = r.params, o = this.plugin.cells.get(i), s = n.filter(function(m) {
              return on(f.plugin.cells.get(m.ref));
            }), u = s.map(function(m) {
              return pi(on(f.plugin.cells.get(m.ref)), m.elementIds);
            }), o ? (c = Array.from(o.representations)[0], l = c[0], d = c[1], l && d ? d.state ? [4, Am[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:
            h.sent(), h.label = 2;
          case 2:
            return this.plugin.managers.cell.update(i, { model: { loci: u } }), [2, !0];
        }
      });
    });
  }, e.prototype.createStaticLabel = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u, c, l, d, f, h;
      return ye(this, function(m) {
        switch (m.label) {
          case 0:
            n = r.theme, i = r.items, a = r.ref, o = r.isHidden, s = [], u = 0, c = i, m.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 = m.sent())) return [2, ""];
            s.push({ loci: pi(d, l.item.elementIds), label: l.label }), m.label = 3;
          case 3:
            return u++, [3, 1];
          case 4:
            return [4, Am[Pe.Label].create(s, this.ctx, r.props, n)];
          case 5:
            return f = m.sent(), h = this.plugin.managers.cell.create({ representations: [{ state: f, isHidden: o != null && o, type: Pe.Label }], model: { loci: s.map(function(p) {
              return p.loci;
            }) }, dependency: { on: i.map(function(p) {
              return p.item;
            }) }, ref: a }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createMeasurement" }), [2, h];
        }
      });
    });
  }, e.prototype.createOther = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y;
      return ye(this, function(b) {
        switch (b.label) {
          case 0:
            return n = r.type, i = r.theme, a = r.data, o = r.ref, s = r.isHidden, u = s !== void 0 && s, c = r.serverData, l = r.params, c3[n] ? (d = c3[n]).parse ? [4, d.parse(a, this.plugin)] : [3, 2] : (console.warn("There is no ".concat(n, " type ")), [2]);
          case 1:
            return h = b.sent(), [3, 3];
          case 2:
            h = a, b.label = 3;
          case 3:
            return f = h, [4, d.create(f, this.ctx, d.createTheme ? d.createTheme(n === Pe.IsoSurface ? f : a, this.plugin, i) : void 0, l)];
          case 4:
            return m = b.sent(), n === Pe.Surface && (i != null && i.transparency) && m.setState({ transparency: this.createTransparencyLayers(f, [i == null ? void 0 : i.transparency]) }), p = this.plugin.managers.cell.create({ representations: [{ state: m, isHidden: u, type: n }], model: { other: c ? { serverData: c, data: a } : a }, theme: n === Pe.Surface ? { color: (v = {}, v[St.SURFACE] = i != null && i.color ? [i == null ? void 0 : i.color] : [], v), transparency: (g = {}, g[St.SURFACE] = i != null && i.transparency ? [i == null ? void 0 : i.transparency] : [], g), size: (y = {}, y[St.SURFACE] = i != null && i.size ? [i == null ? void 0 : i.size] : [], y) } : void 0, ref: o, dependency: n === Pe.Surface ? { on: [a] } : n === Pe.MappingLine ? { on: a } : void 0 }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createOther" }), [2, p];
        }
      });
    });
  }, e.prototype.updateOther = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            return n = r.data, i = r.ref, (a = this.plugin.cells.get(i)) ? (o = Array.from(a.representations)[0], s = o[0], u = o[1], s && u ? [4, c3[s].update(u.state, n, 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: n } }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: updateOther" }), [2, !0];
        }
      });
    });
  }, e.prototype.addMolecularRepr = function(r, n) {
    var i;
    return _e(this, 0, void 0, function() {
      var a, o, s, u, c, l, d, f, h, m;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            return a = n.elementIds, o = n.reprType, s = n.isHidden, u = n.theme, c = n.transparency, l = this.plugin.managers.cell.get(r), d = on(l), l && d ? (f = Ze([], a ?? [], !0), J1.has(o) && this.showPolarHydrogenOnly && (f = (a || ms(d)).filter(function(v) {
              return !Uh(d, v);
            })), h = fi(d, f, !0), [4, eu[o].create(h, this.ctx, u)]) : [2];
          case 1:
            return m = p.sent(), c && m.setState({ transparency: this.createTransparencyLayers(h, c) }), s || (i = this.plugin.canvas3d) === null || i === void 0 || i.add(m), l.representations.set(o, { state: m, isHidden: s, type: o }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: addMolecularRepr" }), [2];
        }
      });
    });
  }, e.prototype.checkStructuresDisplayed = function(r, n) {
    var i, a = this.plugin.managers.cell.get(r.ref), o = on(a), s = new Set(n && !J1.has(n) || !this.showPolarHydrogenOnly ? r.elementIds : ((i = r.elementIds) !== null && i !== void 0 ? i : []).filter(function(u) {
      return !Uh(o, u);
    }));
    return (n ? [a.representations.get(n)] : 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 f = Oa(u.state.getLoci());
        f && (!((d = (l = (c = f == null ? void 0 : f.elements) === null || c === void 0 ? void 0 : c[0]) === null || l === void 0 ? void 0 : l.unit) === null || d === void 0) && d.elements) && oa(f).forEach(function(h) {
          return s.delete(h);
        });
      }
    }), s.size === 0;
  }, e.prototype.setMolecularRepr = function(r, n, i, a, o) {
    var s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C;
    return a === void 0 && (a = !0), o === void 0 && (o = !0), _e(this, 0, void 0, function() {
      var A, w, I, P, M, T, F, N, R, L, V, U, H, K, X, Y, Q, J, te, W, j = this;
      return ye(this, function(ee) {
        switch (ee.label) {
          case 0:
            if (A = /* @__PURE__ */ new Map(), w = r.filter(function(ie) {
              return on(j.plugin.managers.cell.get(ie.ref));
            }), I = !!a && w.every(function(ie) {
              return j.checkStructuresDisplayed(ie, n);
            }), P = Object.keys(Bn).find(function(ie) {
              return Bn[ie].includes(n);
            }), M = [], !I) return [3, 5];
            T = function(ie) {
              var ae, ce, de;
              return ye(this, function(Ce) {
                switch (Ce.label) {
                  case 0:
                    return A.set(ie.ref, /* @__PURE__ */ new Set()), ae = F.plugin.managers.cell.get(ie.ref), ce = ae.representations.get(n), de = ae.theme.color[P], [4, a9(ce == null ? void 0 : ce.state, (s = ie.elementIds) !== null && s !== void 0 ? s : [], n, function(De) {
                      var ke;
                      return j.createTheme(n, De, { color: { name: "multi-theme", props: { themes: de } }, size: ae.theme.size && (!((ke = ae.theme.size[P]) === null || ke === void 0) && ke.length) ? ae.theme.size[P][0] : j.defaultTheme.size[n] });
                    }, function(De) {
                      return j.createTransparencyLayers(De, ae == null ? void 0 : ae.theme.transparency[P]);
                    })];
                  case 1:
                    return Ce.sent(), (u = A.get(ie.ref)) === null || u === void 0 || u.add(n), ae.dependency.by.length && M.push.apply(M, ae.dependency.by), [2];
                }
              });
            }, F = this, N = 0, R = w, ee.label = 1;
          case 1:
            return N < R.length ? (K = R[N], [5, T(K)]) : [3, 4];
          case 2:
            ee.sent(), ee.label = 3;
          case 3:
            return N++, [3, 1];
          case 4:
            return [3, 9];
          case 5:
            L = function(ie) {
              var ae, ce, de, Ce, De, ke, He, We, Ne, Je, Re, nt, ne, re, le, fe, ge, me, Ae;
              return ye(this, function(Oe) {
                switch (Oe.label) {
                  case 0:
                    if (A.set(ie.ref, /* @__PURE__ */ new Set()), ae = V.plugin.managers.cell.get(ie.ref), ce = ae.representations.get(n), de = on(ae), Ce = ae.theme.color[P], De = [], Ce == null || Ce.forEach(function(Ue) {
                      var Ve;
                      De.push.apply(De, (Ve = Ue.elementIds) !== null && Ve !== void 0 ? Ve : []);
                    }), ke = new Set(De), (He = ((c = ie.elementIds) !== null && c !== void 0 ? c : []).filter(function(Ue) {
                      return !ke.has(Ue);
                    })).length && (Ce == null || Ce.push(O({ elementIds: He }, V.defaultTheme.color[P])), ae.theme.color = O(O({}, ae.theme.color), ((Ae = {})[P] = Ce, Ae))), We = [], !i) return [3, 4];
                    Ne = function(Ue) {
                      var Ve;
                      return ye(this, function(ht) {
                        switch (ht.label) {
                          case 0:
                            return !a && Ue.type !== Pe.Ribbon && n !== Pe.Ribbon && (Ve = fy(Ue.state, (l = ie.elementIds) !== null && l !== void 0 ? l : [])).length ? (ie.elementIds = (d = ie.elementIds) === null || d === void 0 ? void 0 : d.filter(function(bt) {
                              return !Ve.includes(bt);
                            }), [2, "continue"]) : Ue.type === n || Ue.type === Pe.Ribbon || Ue.isHidden || $de(Ue.state, (f = ie.elementIds) !== null && f !== void 0 ? f : []) === Fd.Not ? [2, "continue"] : (We.push.apply(We, fy(Ue == null ? void 0 : Ue.state, (h = ie.elementIds) !== null && h !== void 0 ? h : [])), [4, a9(Ue == null ? void 0 : Ue.state, (m = ie.elementIds) !== null && m !== void 0 ? m : [], Ue == null ? void 0 : Ue.type, function(bt) {
                              var At;
                              return j.createTheme(Ue == null ? void 0 : Ue.type, bt, { color: { name: "multi-theme", props: { themes: Ce } }, size: ae.theme.size && (!((At = ae.theme.size[P]) === null || At === void 0) && At.length) ? ae.theme.size[P][0] : j.defaultTheme.size[Ue == null ? void 0 : Ue.type] });
                            }, function(bt) {
                              return j.createTransparencyLayers(bt, ae == null ? void 0 : ae.theme.transparency[P]);
                            })]);
                          case 1:
                            return ht.sent(), (p = A.get(ie.ref)) === null || p === void 0 || p.add(Ue.type), [2];
                        }
                      });
                    }, Je = 0, Re = Array.from(ae.representations), Oe.label = 1;
                  case 1:
                    return Je < Re.length ? (nt = Re[Je], ne = nt[1], [5, Ne(ne)]) : [3, 4];
                  case 2:
                    Oe.sent(), Oe.label = 3;
                  case 3:
                    return Je++, [3, 1];
                  case 4:
                    return re = new Set(We), ce ? (le = (v = jy(ce.state)) !== null && v !== void 0 ? v : [], fe = fi(de, Array.from(new Set(le.concat(J1.has(n) && V.showPolarHydrogenOnly ? ((g = ie.elementIds) !== null && g !== void 0 ? g : []).filter(function(Ue) {
                      return re.has(Ue) || !Uh(de, Ue);
                    }) : (y = ie.elementIds) !== null && y !== void 0 ? y : [])))), ge = V.createTransparencyLayers(fe, ae == null ? void 0 : ae.theme.transparency[P]), [4, eu[n].update(ce == null ? void 0 : ce.state, fe, V.ctx, V.createTheme(n, fe, { color: { name: "multi-theme", props: { themes: Ce } }, size: ae.theme.size && (!((b = ae.theme.size[P]) === null || b === void 0) && b.length) ? ae.theme.size[P][0] : V.defaultTheme.size[n] }))]) : [3, 6];
                  case 5:
                    return Oe.sent(), (S = A.get(ie.ref)) === null || S === void 0 || S.add(n), ce.state.setState({ transparency: ge }), [3, 8];
                  case 6:
                    return fe = fi(de, J1.has(n) && V.showPolarHydrogenOnly ? ie.elementIds.filter(function(Ue) {
                      return re.has(Ue) || !Uh(de, Ue);
                    }) : ie.elementIds), ge = V.createTransparencyLayers(ae == null ? void 0 : ae.model.structure, ae == null ? void 0 : ae.theme.transparency[P]), [4, eu[n].create(fe, V.plugin.managers.representation.ctx, V.createTheme(n, fe, { color: { name: "multi-theme", props: { themes: Ce } }, size: ae.theme.size && (!((_ = ae.theme.size[P]) === null || _ === void 0) && _.length) ? ae.theme.size[P][0] : V.defaultTheme.size[n] }))];
                  case 7:
                    me = Oe.sent(), (x = A.get(ie.ref)) === null || x === void 0 || x.add(n), (C = V.plugin.canvas3d) === null || C === void 0 || C.add(me), me.setState({ transparency: ge }), ae.representations.set(n, { state: me, isHidden: !1, type: n }), Oe.label = 8;
                  case 8:
                    return ae.dependency.by.length && M.push.apply(M, ae.dependency.by), [2];
                }
              });
            }, V = this, U = 0, H = w, ee.label = 6;
          case 6:
            return U < H.length ? (K = H[U], [5, L(K)]) : [3, 9];
          case 7:
            ee.sent(), ee.label = 8;
          case 8:
            return U++, [3, 6];
          case 9:
            for (X = this.plugin.managers.selection.structure.getSelection(), A.forEach(function(ie, ae) {
              var ce;
              if (ie.size) {
                var de = j.plugin.cells.get(ae), Ce = (ce = X[ae]) !== null && ce !== void 0 ? ce : [];
                ie.forEach(function(De) {
                  var ke, He = de == null ? void 0 : de.representations.get(De);
                  if (He) {
                    var We = pi(Vo(He.state), Ce);
                    (ke = j.plugin.canvas3d) === null || ke === void 0 || ke.mark({ loci: We, repr: He.state }, _t.Select);
                  }
                });
              }
            }), Y = Array.from(new Set(M).values()), Q = 0, J = Y; Q < J.length; Q++) te = J[Q], (W = this.plugin.cells.get(te)) && W.representations.forEach(function(ie, ae) {
              ae === Pe.IntraInteractions && o && j.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.setMolecularRepr");
            });
            return this.plugin.managers.snapshot.event.changed.next({ from: "repr: setMolecularRepr" }), [2];
        }
      });
    });
  }, e.prototype.showOrHideHs = function(r, n, i) {
    var a = this, o = i ?? this.plugin.managers.selection.structure.getSelectionCellItems(), s = [];
    o.forEach(function(f) {
      var h = a.plugin.cells.get(f.ref);
      if (h) {
        var m = on(h);
        if (m) {
          f.elementIds || Object.assign(f, { elementIds: ms(m) });
          var p = f.elementIds.map(function(S) {
            return Qy(m, S);
          }), v = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
          h.representations.forEach(function(S, _) {
            if ([Pe.BallAndStick, Pe.CPK, Pe.Stick, Pe.Line].includes(_)) {
              var x = Oa(S.state.getLoci());
              if (!x) return;
              var C = oa(x);
              g.set(_, Ze([], C, !0)), C.forEach(function(A) {
                v.set(A, _);
              });
            }
          });
          var y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
          p.forEach(function(S, _) {
            var x;
            if (f.elementIds) {
              var C = f.elementIds[_], A = m.units.filter(function(w) {
                return Ke.indexOf(w.elements, C) !== -1;
              })[0];
              (!n && S === Oi.NonPolar || !r && S === Oi.Polar) && v.has(C) ? y.has(v.get(C)) ? (x = y.get(v.get(C))) === null || x === void 0 || x.add(C) : y.set(v.get(C), /* @__PURE__ */ new Set([C])) : ((!n && S === Oi.ConnectNonPolar || !r && S === Oi.ConnectPolar) && tf(m, A, A.elements.indexOf(C), function(w, I) {
                var P;
                w.model.atomicHierarchy.derived.atom.atomicNumber[w.elements[I]] === 1 && v.has(w.elements[I]) && (y.has(v.get(C)) ? (P = y.get(v.get(C))) === null || P === void 0 || P.add(w.elements[I]) : y.set(v.get(C), /* @__PURE__ */ new Set([w.elements[I]])));
              }), !(n && S === Oi.NonPolar || r && S === Oi.Polar) || v.has(C) ? (n && S === Oi.ConnectNonPolar || r && S === Oi.ConnectPolar) && v.has(C) && tf(m, A, A.elements.indexOf(C), function(w, I) {
                var P;
                w.model.atomicHierarchy.derived.atom.atomicNumber[w.elements[I]] !== 1 || v.has(w.elements[I]) || (b.has(v.get(C)) ? (P = b.get(v.get(C))) === null || P === void 0 || P.add(w.elements[I]) : b.set(v.get(C), /* @__PURE__ */ new Set([w.elements[I]])));
              }) : tf(m, A, A.elements.indexOf(C), function(w, I) {
                var P;
                w.model.atomicHierarchy.derived.atom.atomicNumber[w.elements[I]] !== 1 && v.has(w.elements[I]) && (b.has(v.get(w.elements[I])) ? (P = b.get(v.get(w.elements[I]))) === null || P === void 0 || P.add(C) : b.set(v.get(w.elements[I]), /* @__PURE__ */ new Set([C])));
              }));
            }
          }), h.representations.forEach(function(S, _) {
            var x;
            if ([Pe.BallAndStick, Pe.CPK, Pe.Stick, Pe.Line].includes(_)) {
              var C = !1, A = g.get(_);
              if (y.has(_) && y.get(_).size > 0) {
                var w = y.get(_);
                A = A == null ? void 0 : A.filter(function(T) {
                  return !w.has(T);
                }), C = !0;
              }
              if (b.has(_) && b.get(_).size > 0) {
                var I = b.get(_);
                A = Array.from(new Set(Ze(Ze([], Array.from(I.values()), !0), A, !0))), C = !0;
              }
              if (C) {
                var P = fi(m, A), M = h.theme.color[St.ATOM];
                eu[_].update(S.state, P, a.ctx, a.createTheme(_, P, { color: { name: "multi-theme", props: { themes: M } }, size: h.theme.size && (!((x = h.theme.size[St.ATOM]) === null || x === void 0) && x.length) ? h.theme.size[St.ATOM][0] : a.defaultTheme.size[_] }));
              }
            }
          }), h.dependency.by.length && s.push.apply(s, h.dependency.by);
        }
      }
    });
    for (var u = 0, c = Array.from(new Set(s).values()); u < c.length; u++) {
      var l = c[u], d = this.plugin.cells.get(l);
      d && d.representations.forEach(function(f, h) {
        h === Pe.IntraInteractions && a.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.showOrHideHs");
      });
    }
  }, e.prototype.redraw = function() {
    var r = this;
    this.plugin.canvas3d && (this.plugin.canvas3d.clear(), Array.from(this.plugin.cells.values()).forEach(function(n) {
      n.representations.forEach(function(i) {
        var a;
        i.isHidden !== !0 && i.state && ((a = r.plugin.canvas3d) === null || a === void 0 || a.add(i.state));
      });
    }));
  }, e.prototype.updateBondThresholds = function(r) {
    var n = this, i = r.reduce(function(o, s) {
      var u;
      return O(O({}, o), ((u = {})[bR(Hm[s.atomA], Hm[s.atomB])] = s.distance, u));
    }, {});
    Object.assign(yR, i), Object.assign(vR, i);
    var a = /* @__PURE__ */ new Set();
    this.plugin.managers.cell.traverse(function(o, s) {
      return _e(n, 0, void 0, function() {
        var u, c, l, d;
        return ye(this, function(f) {
          switch (f.label) {
            case 0:
              return a.has(o.ref) || !o.model.structure ? [2] : (u = o.assets[0], c = u.format, l = u.data, [4, Il[c].parse(l)]);
            case 1:
              return d = f.sent(), this.plugin.managers.editor.coverStructure(o.ref, d[0], o.assets[0]), a.add(o.ref), [2];
          }
        });
      });
    });
  }, e;
}(Ofe), W8 = ((zv = {})[St.ATOM] = [], zv[St.RIBBON] = [], zv[St.SURFACE] = [], zv), xP = function() {
  function t(e) {
    var r, n = this;
    this.plugin = e, (r = this.plugin.canvas3d) === null || r === void 0 || r.reprCount.subscribe(function(i) {
      if (i > 100 && n.idleCellSet.size) {
        var a = Array.from(n.idleCellSet.values())[0];
        n.idleCellSet.delete(a), n.clearReprState(a);
      }
    }), this.idleCellSet = /* @__PURE__ */ new Set();
  }
  return t.prototype.get = function(e) {
    var r = this.plugin.cells.get(e);
    if (r) return r;
    console.error("no ".concat(e, " cell"));
  }, t.prototype.getHierarchy = function(e) {
    var r = this, n = this.get(e);
    if (!(n != null && n.model.structure)) return console.error("".concat(e, " cell does not have structure")), { data: { polymer: {}, water: {}, otherSolvent: {}, metal: {}, ion: {}, ligand: {}, other: {} }, extraData: { sequenceData: {} } };
    var i = [], a = [];
    n.dependency.by.forEach(function(s) {
      var u, c, l;
      if (r.plugin.cells.has(s)) {
        var d = r.get(s);
        d && (d.representations.has(Pe.Label) && a.push({ ref: s, dependencies: Ze([], d.dependency.on, !0), label: ((c = (u = d.representations.get(Pe.Label)) === null || u === void 0 ? void 0 : u.state) !== null && c !== void 0 ? c : (l = d.representations.get(Pe.Label)) === null || l === void 0 ? void 0 : l.cache).props.customText }), d.representations.has(Pe.Surface) && i.push({ ref: s, dependencies: Ze([], d.dependency.on, !0) }));
      }
    });
    var o = cL(n.model.structure);
    return O(O({}, o), { extraData: O(O({}, o.extraData), { label: a, surface: i }) });
  }, t.prototype.getSequence = function(e) {
    return _e(this, 0, void 0, function() {
      var r;
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, this.getStructure(e)];
          case 1:
            return (r = n.sent()) ? [2, yoe(r)] : [2];
        }
      });
    });
  }, t.prototype.getStructure = function(e) {
    var r;
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u, c, l;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            return (n = this.get(e)) ? (i = on(n)) ? [2, i] : i || !(!((r = n.assets) === null || r === void 0) && r.length) ? [3, 5] : (a = n.assets[0], o = a.data, s = a.format, l = (c = Il[s]).parse, [4, y0(o)]) : [2];
          case 1:
            return [4, l.apply(c, [d.sent()])];
          case 2:
            return u = d.sent()[0], s !== gr.Pdb || !u.elementCount || pn.hasSecondaryStructure(u == null ? void 0 : u.model) ? [3, 4] : [4, Ha.attach({}, u, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } }, !0)];
          case 3:
            d.sent(), d.label = 4;
          case 4:
            return this.update(e, { model: { structure: u } }), [2, u];
          case 5:
            return [2];
        }
      });
    });
  }, t.prototype.getLoci = function(e) {
    return _e(this, 0, void 0, function() {
      var r;
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, this.getStructure(e.ref)];
          case 1:
            return (r = n.sent()) ? [2, pi(r, e.elementIds)] : [2, Dn];
        }
      });
    });
  }, t.prototype.getMolecularName = function(e) {
    var r, n, i, a, o, s, u = this.get(e);
    if (!u.model.structure) return !((r = u.assets) === null || r === void 0) && r.length && ["sdf", "mol"].includes(u.assets[0].format) ? "".concat(u.assets[0].data).split(`
`)[0] : "";
    var c = ((i = (n = u.model.structure) === null || n === void 0 ? void 0 : n.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 : "";
  }, t.prototype.isFromPdb = function(e) {
    var r, n = this.plugin.cells.get(e);
    if (!n) return !1;
    var i = on(n);
    return !!i && ((r = gs(i)) === null || r === void 0 ? void 0 : r.sourceData.kind) === "mmCIF";
  }, t.prototype.getCellPdbId = function(e) {
    if (!this.isFromPdb(e)) return "";
    var r = this.plugin.cells.get(e);
    if (!r) return "";
    var n = on(r);
    if (!n) return "";
    var i = "";
    if (this.plugin.managers.cell.isFromPdb(e)) {
      for (var a = Bx(n, ["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;
  }, t.prototype.getMeasurementName = function(e, r) {
    var n, i, a = this.get(e);
    if (!a.representations.get(r)) return console.warn("There is no ".concat(r, " in ").concat(e, " cell"));
    var o = ((i = (n = a.model) === null || n === void 0 ? void 0 : n.loci) !== null && i !== void 0 ? i : []).map(function(s) {
      return Qr.getCenter(s);
    });
    return r === Pe.Distance ? "".concat(E.distance(o[0], o[1]).toFixed(2), "Å") : r === Pe.Angle ? "".concat(Ua(E.angle(E.sub(E(), o[0], o[1]), E.sub(E(), o[2], o[1]))).toFixed(2), "°") : r === Pe.Dihedral ? "".concat(Ua(E.dihedralAngle(o[0], o[1], o[2], o[3])).toFixed(2), "°") : "";
  }, t.prototype.create = function(e) {
    var r, n, i = this, a = e.representations, o = e.model, s = e.assets, u = e.dependency, c = e.ref, l = e.theme, d = c ?? Ki.create22(), f = /* @__PURE__ */ new Map();
    return a.forEach(function(h) {
      var m;
      !h.isHidden && h.state && ((m = i.plugin.canvas3d) === null || m === void 0 || m.add(h.state)), f.set(h.type, h);
    }), this.plugin.cells.set(d, { ref: d, representations: f, dependency: O({ on: [], by: [] }, u), theme: { color: O(O({}, W8), l == null ? void 0 : l.color), size: O(O({}, W8), l == null ? void 0 : l.size), transparency: O(O({}, W8), l == null ? void 0 : l.transparency) }, assets: s, model: o }), !((r = u == null ? void 0 : u.on) === null || r === void 0) && r.length && Array.from(new Set(u == null ? void 0 : u.on)).forEach(function(h) {
      i.addDependency(h.ref, { by: [d] });
    }), !((n = u == null ? void 0 : u.by) === null || n === void 0) && n.length && Array.from(new Set(u == null ? void 0 : u.by)).forEach(function(h) {
      i.addDependency(h, { on: [{ ref: d }] });
    }), this.plugin.managers.snapshot.event.changed.next({ from: "cell:create" }), d;
  }, t.prototype.createEmptyMolecularCell = function(e) {
    var r, n, i, a;
    return _e(this, 0, void 0, function() {
      var o, s, u, c;
      return ye(this, function(l) {
        switch (l.label) {
          case 0:
            return o = Ec(), [4, xk.create(o, this.plugin.managers.representation.ctx)];
          case 1:
            return s = l.sent(), [2, this.create({ representations: [{ state: s, isHidden: !1, type: Pe.BallAndStick }], model: { structure: o }, assets: [{ format: gr.Sdf, data: "" }], theme: { transparency: (u = {}, u[St.ATOM] = e && (!((r = e[St.ATOM]) === null || r === void 0) && r.transparency) ? [(n = e[St.ATOM]) === null || n === void 0 ? void 0 : n.transparency] : [], u[St.RIBBON] = [], u[St.SURFACE] = [], u), size: (c = {}, c[St.ATOM] = e && (!((i = e[St.ATOM]) === null || i === void 0) && i.size) ? [(a = e[St.ATOM]) === null || a === void 0 ? void 0 : a.size] : [], c[St.RIBBON] = [], c[St.SURFACE] = [], c) } })];
        }
      });
    });
  }, t.prototype.copyMolecular = function(e, r) {
    var n, i, a, o, s, u;
    return _e(this, 0, void 0, function() {
      var c, l, d, f, h, m;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            c = [], l = function(v) {
              var g, y, b, S, _, x, C, A, w, I, P, M, T;
              return ye(this, function(F) {
                switch (F.label) {
                  case 0:
                    return g = d.get(v.ref), [4, d.getStructure(v.ref)];
                  case 1:
                    return y = F.sent(), b = [], (S = fi(y, (n = v.elementIds) !== null && n !== void 0 ? n : [], !0, !0)).elementCount ? [4, Ha.attach({}, S, void 0, !0)] : [3, 3];
                  case 2:
                    F.sent(), F.label = 3;
                  case 3:
                    return _ = Pu(S), v.representationType ? (x = Object.keys(Bn).find(function(N) {
                      return Bn[N].includes(v.representationType);
                    }), [4, eu[v.representationType].create(S, d.plugin.managers.representation.ctx, d.plugin.managers.representation.createTheme(v.representationType, S, { color: { name: "multi-theme", props: { themes: g.theme.color[x] } }, size: g.theme.size && (!((i = g.theme.size[x]) === null || i === void 0) && i.length) ? g.theme.size[x][0] : d.plugin.managers.representation.defaultTheme.size[v.representationType] }))]) : [3, 5];
                  case 4:
                    return C = F.sent(), b.push({ state: C, isHidden: (a = r == null ? void 0 : r.isHidden) === null || a === void 0 || a, type: v.representationType }), [3, 9];
                  case 5:
                    A = function(N, R) {
                      var L, V, U;
                      return ye(this, function(H) {
                        switch (H.label) {
                          case 0:
                            return L = Object.keys(Bn).find(function(K) {
                              return Bn[K].includes(N);
                            }), !(!((o = v.elementIds) === null || o === void 0) && o.length) || fy(R.state, v.elementIds).length ? (V = fi(R.state ? Vo(R.state) : fi(S, R.cache.elementIds, !0), (s = v.elementIds) !== null && s !== void 0 ? s : [], !0, _), [4, eu[N].create(V, d.plugin.managers.representation.ctx, d.plugin.managers.representation.createTheme(N, V, { color: { name: "multi-theme", props: { themes: g.theme.color[L] } }, size: d.plugin.managers.representation.defaultTheme.size[N] }))]) : [3, 2];
                          case 1:
                            U = H.sent(), b.push({ state: U, isHidden: (u = r == null ? void 0 : r.isHidden) === null || u === void 0 || u, type: N }), H.label = 2;
                          case 2:
                            return [2];
                        }
                      });
                    }, w = 0, I = Array.from(g.representations), F.label = 6;
                  case 6:
                    return w < I.length ? (P = I[w], M = P[0], T = P[1], [5, A(M, T)]) : [3, 9];
                  case 7:
                    F.sent(), F.label = 8;
                  case 8:
                    return w++, [3, 6];
                  case 9:
                    return c.push(d.create({ representations: b, model: { structure: S }, assets: g.assets, theme: O({}, g.theme) })), [2];
                }
              });
            }, d = this, f = 0, h = e, p.label = 1;
          case 1:
            return f < h.length ? (m = h[f], [5, l(m)]) : [3, 4];
          case 2:
            p.sent(), p.label = 3;
          case 3:
            return f++, [3, 1];
          case 4:
            return this.plugin.managers.snapshot.event.changed.next({ from: "cell:copyMolecular" }), [2, c];
        }
      });
    });
  }, t.prototype.update = function(e, r) {
    var n, i, a, o, s, u, c, l = this, d = this.plugin.managers.cell.get(e);
    d.model = Object.assign(d.model, r.model), r.theme && (d.theme = { color: O(O({}, d.theme.color), r.theme.color), size: O(O({}, d.theme.size), r.theme.size), transparency: O(O({}, d.theme.transparency), r.theme.transparency) }), !((n = r.representations) === null || n === void 0) && n.length && r.representations.forEach(function(f) {
      var h;
      d.representations.set(f.type, Object.assign((h = d.representations.get(f.type)) !== null && h !== void 0 ? h : {}, f));
    }), !((a = (i = r.dependency) === null || i === void 0 ? void 0 : i.on) === null || a === void 0) && a.length && (this.removeDependency(e, { on: d.dependency.on }), Array.from(new Set((o = r.dependency) === null || o === void 0 ? void 0 : o.on)).forEach(function(f) {
      l.addDependency(f.ref, { by: [e] });
    })), !((u = (s = r.dependency) === null || s === void 0 ? void 0 : s.by) === null || u === void 0) && u.length && (this.removeDependency(e, { by: d.dependency.by }), Array.from(new Set((c = r.dependency) === null || c === void 0 ? void 0 : c.by)).forEach(function(f) {
      l.addDependency(f, { on: [{ ref: e }] });
    })), d.dependency = O(O({}, d.dependency), r.dependency), r.assets && (d.assets = r.assets), this.plugin.managers.snapshot.event.changed.next({ from: "cell:update" });
  }, t.prototype.remove = function(e, r) {
    var n, i;
    return _e(this, 0, void 0, function() {
      var a, o, s, u, c, l, d, f = this;
      return ye(this, function(h) {
        switch (h.label) {
          case 0:
            a = "", o = /* @__PURE__ */ new Map(), s = function(m) {
              var p, v, g, y, b, S, _, x, C, A, w, I;
              return ye(this, function(P) {
                switch (P.label) {
                  case 0:
                    return u.plugin.cells.has(m.ref) ? (p = u.get(m.ref), [4, u.getStructure(m.ref)]) : [2, "continue"];
                  case 1:
                    if (v = P.sent(), m.ref && v && u.plugin.managers.selection.structure.remove({ item: { ref: m.ref, elementIds: (n = m.elementIds) !== null && n !== void 0 ? n : ms(v) } }), o.has(m.ref) && o.get(m.ref) !== void 0 ? o.set(m.ref, m.elementIds === void 0 ? void 0 : Ze(Ze([], m.elementIds, !0), o.get(m.ref), !0)) : o.set(m.ref, m.elementIds), r) p.representations.forEach(function(M) {
                      var T, F;
                      if (Op.has(M.type) && p.dependency.on.length) {
                        var N = p.dependency.on.some(function(R) {
                          return efe(R, r);
                        });
                        N && (!M.isHidden && M.state && ((T = f.plugin.canvas3d) === null || T === void 0 || T.remove(M.state)), p.representations.delete(M.type));
                      }
                      M.type === Pe.Surface && (r.elementIds || (M.state && ((F = f.plugin.canvas3d) === null || F === void 0 || F.remove(M.state)), p.representations.delete(M.type)));
                    });
                    else if (!((i = m == null ? void 0 : m.elementIds) === null || i === void 0) && i.length) {
                      for (g = function(M, T) {
                        var F = Object.keys(Bn).find(function(N) {
                          return Bn[N].includes(M);
                        });
                        a9(T.state, m.elementIds, M, function(N) {
                          var R;
                          return f.plugin.managers.representation.createTheme(M, N, { color: { name: "multi-theme", props: { themes: p.theme.color[F] } }, size: p.theme.size && (!((R = p.theme.size[F]) === null || R === void 0) && R.length) ? p.theme.size[F][0] : f.plugin.managers.representation.defaultTheme.size[T.type] });
                        }, function(N) {
                          var R;
                          return f.plugin.managers.representation.createTransparencyLayers(N, Ze([], (R = p == null ? void 0 : p.theme.transparency[F]) !== null && R !== void 0 ? R : [], !0));
                        });
                      }, y = 0, b = Array.from(p.representations); y < b.length; y++) S = b[y], _ = S[0], x = S[1], g(_, x);
                      v && (p.model.structure = wL(v, m.elementIds));
                    } else p.representations.forEach(function(M) {
                      var T;
                      !M.isHidden && M.state && ((T = f.plugin.canvas3d) === null || T === void 0 || T.remove(M.state)), p.representations.delete(M.type);
                    });
                    if (!p.dependency.by.length) return [3, 6];
                    C = 0, A = Array.from(new Set(p.dependency.by)), P.label = 2;
                  case 2:
                    return C < A.length ? (w = A[C], (I = u.plugin.cells.get(w)) != null && I.representations.has(Pe.IntraInteractions) ? (a = w, [3, 5]) : [3, 3]) : [3, 6];
                  case 3:
                    return [4, u.remove([{ ref: w }], m)];
                  case 4:
                    P.sent(), P.label = 5;
                  case 5:
                    return C++, [3, 2];
                  case 6:
                    return p.representations.size || (p.dependency.on.length && Array.from(new Set(p.dependency.on)).forEach(function(M) {
                      var T = f.plugin.cells.get(M.ref);
                      if (T) {
                        var F = T.dependency.by.findIndex(function(N) {
                          return N === m.ref;
                        });
                        F !== -1 && T.dependency.by.splice(F, 1);
                      }
                    }), u.plugin.cells.delete(m.ref)), [2];
                }
              });
            }, u = this, c = 0, l = e, h.label = 1;
          case 1:
            return c < l.length ? (d = l[c], [5, s(d)]) : [3, 4];
          case 2:
            h.sent(), h.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];
        }
      });
    });
  }, t.prototype.extractMolecular = function(e, r) {
    var n, i, a, o, s;
    return _e(this, 0, void 0, function() {
      var u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C;
      return ye(this, function(A) {
        switch (A.label) {
          case 0:
            u = [], c = 0, l = e, A.label = 1;
          case 1:
            return c < l.length ? (d = l[c], f = this.get(d.ref), [4, this.getStructure(d.ref)]) : [3, 8];
          case 2:
            h = A.sent(), m = fi(h, (n = d.elementIds) !== null && n !== void 0 ? n : [], !0, !0), p = !((i = f.assets) === null || i === void 0) && i.length && (!((a = f.assets[0]) === null || a === void 0) && a.format) ? f.assets[0].format : gr.Pdb, v = [], g = function(w, I) {
              var P, M, T, F;
              return ye(this, function(N) {
                switch (N.label) {
                  case 0:
                    return P = Object.keys(Bn).find(function(R) {
                      return Bn[R].includes(w);
                    }), (M = fy(I.state, d.elementIds)).length ? (T = fi(m, M), [4, eu[w].create(T, y.plugin.managers.representation.ctx, y.plugin.managers.representation.createTheme(w, T, { color: { name: "multi-theme", props: { themes: f.theme.color[P] } }, size: f.theme.size && (!((o = f.theme.size[P]) === null || o === void 0) && o.length) ? f.theme.size[P][0] : y.plugin.managers.representation.defaultTheme.size[I.type] }))]) : [3, 2];
                  case 1:
                    F = N.sent(), v.push({ state: F, isHidden: (s = r == null ? void 0 : r.isHidden) === null || s === void 0 || s, type: w }), N.label = 2;
                  case 2:
                    return [2];
                }
              });
            }, y = this, b = 0, S = Array.from(f.representations), A.label = 3;
          case 3:
            return b < S.length ? (_ = S[b], x = _[0], C = _[1], [5, g(x, C)]) : [3, 6];
          case 4:
            A.sent(), A.label = 5;
          case 5:
            return b++, [3, 3];
          case 6:
            u.push(this.create({ representations: v, model: { structure: m }, assets: [{ format: p, data: Zy(m, p) }], theme: O({}, f.theme) })), this.remove([d]), A.label = 7;
          case 7:
            return c++, [3, 1];
          case 8:
            return this.plugin.managers.snapshot.event.changed.next({ from: "cell:extractMolecular" }), [2, u];
        }
      });
    });
  }, t.prototype.addDependency = function(e, r) {
    var n, i, a = this.get(e);
    !((n = r.on) === null || n === void 0) && n.length && (a.dependency.on = a.dependency.on.concat(r.on)), !((i = r.by) === null || i === void 0) && i.length && (a.dependency.by = Array.from(new Set(a.dependency.by.concat(r.by))));
  }, t.prototype.removeDependency = function(e, r) {
    var n, i, a = this;
    !((n = r.on) === null || n === void 0) && n.length && r.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 !== e;
      }));
    }), !((i = r.by) === null || i === void 0) && i.length && r.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 !== e;
      }));
    });
  }, t.prototype.query = function(e) {
    var r = [];
    return this.plugin.cells.forEach(function(n) {
      n.representations.forEach(function(i) {
        e(n, i) && r.push(n);
      });
    }), r;
  }, t.prototype.traverse = function(e) {
    this.plugin.cells.forEach(function(r) {
      r.representations.forEach(function(n) {
        e(r, n);
      });
    });
  }, t.prototype.getAllDisplayedCellsRef = function() {
    var e = /* @__PURE__ */ new Set();
    return this.plugin.managers.cell.traverse(function(r, n) {
      [Pe.Ribbon, Pe.BallAndStick, Pe.Line, Pe.Stick, Pe.CPK].includes(n.type) && !n.isHidden && on(r) && e.add(r.ref);
    }), Array.from(e.values());
  }, t.prototype.clearReprState = function(e) {
    var r = this, n = this.get(e), i = /* @__PURE__ */ new Map(), a = n.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(n.representations.entries()).forEach(function(s) {
        var u;
        s[0];
        var c = s[1];
        c.state && ((u = r.plugin.canvas3d) === null || u === void 0 || u.remove(c.state), n.representations.set(c.type, { isHidden: c.isHidden, type: c.type, cache: { type: c.type, elementIds: jy(c.state).map(function(l) {
          return i && (i != null && i.has(l)) ? i == null ? void 0 : i.get(l) : l;
        }), isHidden: c.isHidden, params: Op.has(c.type) ? pG(c.type, c.state) : void 0 } }));
      });
    }
  }, t.prototype.recoveryCache = function(e, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s;
      return ye(this, function(u) {
        switch (u.label) {
          case 0:
            return n = this.get(e), i = Array.from(n.representations.values()), r ? [4, this.recoveryReprCache(n, r)] : [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(n, s.cache)] : [3, 5] : [3, 6];
          case 4:
            u.sent(), u.label = 5;
          case 5:
            return a++, [3, 3];
          case 6:
            return [2];
        }
      });
    });
  }, t.prototype.recoveryReprCache = function(e, r) {
    var n, i;
    return _e(this, 0, void 0, function() {
      var a, o, s, u;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            return [4, this.getStructure(e.ref)];
          case 1:
            return (a = c.sent()) ? (o = Object.keys(Bn).find(function(l) {
              return Bn[l].includes(r.type);
            }), s = e.theme.color[o], u = e.theme.transparency ? e.theme.transparency[o] : void 0, [4, this.plugin.managers.representation.addMolecularRepr(e.ref, { reprType: r.type, elementIds: r.elementIds, isHidden: r.isHidden, theme: this.plugin.managers.representation.createTheme(r.type, fi(a, (n = r.elementIds) !== null && n !== void 0 ? n : [], !0), { color: { name: "multi-theme", props: { themes: s } }, size: e.theme.size && (!((i = e.theme.size[o]) === null || i === void 0) && i.length) ? e.theme.size[o][0] : this.plugin.managers.representation.defaultTheme.size[r.type] }), transparency: u })]) : [2];
          case 2:
            return c.sent(), [2];
        }
      });
    });
  }, t.prototype.overlapLigands = function(e, r, n) {
    return _e(this, 0, void 0, function() {
      var i, a, o, s, u, c, l, d, f, h, m;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            return i = function(v) {
              var g = ot(v), y = ot.readLine(g).trim(), b = ot.readLine(g).trim(), S = ot.readLine(g).trim(), _ = ot.readLine(g), x = +_.substr(0, 3), C = +_.substr(3, 3);
              return { title: y, program: b, comment: S, atoms: Tx(g, x), bonds: Mx(g, C), formalCharges: Px(g) };
            }(n), a = [Array.from(i.atoms.x.toArray()).reduce(function(v, g) {
              return v + g;
            }) / i.atoms.count, Array.from(i.atoms.y.toArray()).reduce(function(v, g) {
              return v + g;
            }) / i.atoms.count, Array.from(i.atoms.z.toArray()).reduce(function(v, g) {
              return v + g;
            }) / i.atoms.count], [4, this.getStructure(e)];
          case 1:
            for (o = p.sent(), s = pi(o, r), u = Xe.getBoundary(s).sphere.center, c = [u[0] - a[0], u[1] - a[1], u[2] - a[2]], l = [], d = /* @__PURE__ */ new Map(), h = 0, m = i.formalCharges.atomIdx.rowCount; h < m; h++) d.set(i.formalCharges.atomIdx.value(h) - 1, i.formalCharges.charge.value(h));
            for (h = 0, m = i.atoms.count; h < m; h++) l.push({ x: i.atoms.x.value(h) + c[0], y: i.atoms.y.value(h) + c[1], z: i.atoms.z.value(h) + c[2], type_symbol: i.atoms.type_symbol.value(h), charge: d.get(h) || 0 });
            for (f = [], h = 0, m = i.bonds.count; h < m; h++) f.push({ a: i.bonds.atomIdxA.value(h), b: i.bonds.atomIdxB.value(h), order: i.bonds.order.value(h) });
            return [2, { atoms: l, bonds: f }];
        }
      });
    });
  }, t.prototype.getUnitCellData = function(e) {
    var r = this.get(e);
    if (r) {
      var n = on(r);
      return nfe(n);
    }
  }, t;
}(), K1 = { createByTrajectory: function(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, s, u, c, l, d, f, h, m, p;
    return ye(this, function(v) {
      switch (v.label) {
        case 0:
          return r = t.trajectory, n = t.frameIndex, i = t.mode, a = r, o = tt.ofModel(a.getFrameAtIndex(n)), s = [], i !== l0.Drug ? [3, 7] : (u = z7(o), c = u.polymer, l = u.other, c.length ? (d = fi(o, c)).elementCount ? [4, Ha.attach({ runtime: hs, assetManager: new pl() }, d, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2] : [3, 4]);
        case 1:
          v.sent(), v.label = 2;
        case 2:
          return (f = cl.factory(e, cl.getParams)).setTheme({ color: e.colorThemeRegistry.create("uniform", { structure: d }, { value: qe(14474728) }), size: e.sizeThemeRegistry.create("uniform", { structure: d }) }), [4, f.createOrUpdate(O(O({}, cl.defaultValues), { quality: "auto" }), d).run()];
        case 3:
          v.sent(), s.push({ state: f, type: Pe.Ribbon }), v.label = 4;
        case 4:
          return l.length ? (h = fi(o, l), (m = vo.factory(e, vo.getParams)).setTheme({ color: e.colorThemeRegistry.create("element-symbol", { structure: h }, { carbonColor: { name: "uniform", params: { value: qe(14474728) } } }), size: e.sizeThemeRegistry.create("physical", { structure: h }) }), [4, m.createOrUpdate(O(O({}, vo.defaultValues), { quality: "auto" }), h).run()]) : [3, 6];
        case 5:
          v.sent(), s.push({ state: m, type: Pe.BallAndStick }), v.label = 6;
        case 6:
          return [3, 9];
        case 7:
          return (p = vo.factory(e, vo.getParams)).setTheme({ color: e.colorThemeRegistry.create("material-element-symbol", { structure: o }), size: e.sizeThemeRegistry.create("physical", { structure: o }) }), [4, p.createOrUpdate(O(O({}, vo.defaultValues), { quality: "auto" }), o).run()];
        case 8:
          v.sent(), s.push({ state: p, type: Pe.BallAndStick }), v.label = 9;
        case 9:
          return [2, { model: a, reprs: s }];
      }
    });
  });
}, create: function(t, e) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, s, u, c, l, d, f, h, m, p, v;
    return ye(this, function(g) {
      switch (g.label) {
        case 0:
          return r = t.model, n = t.coordinates, i = t.frameIndex, a = t.mode, o = pn.trajectoryFromModelAndCoordinates(r, n), s = tt.ofModel(o.getFrameAtIndex(i)), u = [], a !== l0.Drug ? [3, 7] : (c = z7(s), l = c.polymer, d = c.other, l.length ? (f = fi(s, l)).elementCount ? [4, Ha.attach({ runtime: hs, assetManager: new pl() }, f, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2] : [3, 4]);
        case 1:
          g.sent(), g.label = 2;
        case 2:
          return (h = cl.factory(e, cl.getParams)).setTheme({ color: e.colorThemeRegistry.create("uniform", { structure: f }, { value: qe(14474728) }), size: e.sizeThemeRegistry.create("uniform", { structure: f }) }), [4, h.createOrUpdate(O(O({}, cl.defaultValues), { quality: "auto" }), f).run()];
        case 3:
          g.sent(), u.push({ state: h, type: Pe.Ribbon }), g.label = 4;
        case 4:
          return d.length ? (m = fi(s, d), (p = vo.factory(e, vo.getParams)).setTheme({ color: e.colorThemeRegistry.create("element-symbol", { structure: m }, { carbonColor: { name: "uniform", params: { value: qe(14474728) } } }), size: e.sizeThemeRegistry.create("physical", { structure: m }) }), [4, p.createOrUpdate(O(O({}, vo.defaultValues), { quality: "auto" }), m).run()]) : [3, 6];
        case 5:
          g.sent(), u.push({ state: p, type: Pe.BallAndStick }), g.label = 6;
        case 6:
          return [3, 9];
        case 7:
          return (v = vo.factory(e, vo.getParams)).setTheme({ color: e.colorThemeRegistry.create("material-element-symbol", { structure: s }), size: e.sizeThemeRegistry.create("physical", { structure: s }) }), [4, v.createOrUpdate(O(O({}, vo.defaultValues), { quality: "auto" }), s).run()];
        case 8:
          g.sent(), u.push({ state: v, type: Pe.BallAndStick }), g.label = 9;
        case 9:
          return [2, { model: o, reprs: u }];
      }
    });
  });
}, update: function(t, e, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return n = e.trajectory, i = e.frameIndex, a = e.mode, (o = tt.ofModel(n.getFrameAtIndex(i))).elementCount ? [4, Ha.attach({ runtime: hs, assetManager: new pl() }, o, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2];
        case 1:
          s.sent(), s.label = 2;
        case 2:
          return [4, Promise.all(t.map(function(u) {
            var c = Object.keys(Bn).find(function(f) {
              return Bn[f].includes(u.type);
            }), l = Xe.toExpression(tt.toStructureElementLoci(u.getLoci().structure)), d = kp(Lp(o, l));
            u.setTheme({ color: r.colorThemeRegistry.create(a === l0.Drug ? c === St.RIBBON ? "uniform" : "element-symbol" : "material-element-symbol", { structure: d }, a === l0.Drug ? c === St.RIBBON ? { value: qe(14474728) } : { carbonColor: { name: "uniform", params: { value: qe(14474728) } } } : {}), size: r.sizeThemeRegistry.create(c === St.RIBBON ? "uniform" : "physical", { structure: d }, u.theme.size.props) }), u.createOrUpdate({}, d).run();
          }))];
        case 3:
          return s.sent(), [2];
      }
    });
  });
} }, SP = function() {
  function t(e) {
    this.ev = wo.create(), this.updated = this.ev(), this.plugin = e, this.paused = !1;
  }
  return t.prototype.import = function(e, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, s, u;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            return [4, y0(e.data)];
          case 1:
            return n = c.sent(), [4, Il[e.format].parse(n)];
          case 2:
            return i = c.sent(), [4, doe(r.data)];
          case 3:
            return a = c.sent(), [4, Il[r.format].parse(a)];
          case 4:
            return o = c.sent(), [4, K1.create({ model: e.format === gr.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 = oa(tt.toStructureElementLoci(e.format === gr.Gro ? tt.ofModel(s.model.frames[0], { dynamicBonds: !0 }) : i[0])), [2, this.plugin.managers.cell.create({ representations: s.reprs.map(function(l) {
              return O({ isHidden: !1 }, l);
            }), model: { trajectory: { state: s.model, frameIndex: 0 } }, assets: [{ data: n, format: e.format }, { data: a, format: r.format }], theme: { color: { Atom: [O({ elementIds: u }, this.plugin.managers.representation.defaultTheme.color[St.ATOM])], Ribbon: [O({ elementIds: u }, this.plugin.managers.representation.defaultTheme.color[St.RIBBON])] } } })];
        }
      });
    });
  }, t.prototype.importWithGro = function(e) {
    return _e(this, 0, void 0, function() {
      var r, n, i;
      return ye(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, y0(e.data)];
          case 1:
            return r = a.sent(), [4, SG.parse(r)];
          case 2:
            return n = a.sent(), [4, K1.createByTrajectory({ trajectory: n, 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 O({ isHidden: !1 }, o);
            }), model: { trajectory: { state: i.model, frameIndex: 0 } }, assets: [{ data: r, format: e.format }] })];
        }
      });
    });
  }, t.prototype.importTrajectory = function(e) {
    return _e(this, 0, void 0, function() {
      var r, n, i, a;
      return ye(this, function(o) {
        switch (o.label) {
          case 0:
            return l9[e.format] ? typeof e.data == "string" || e.data instanceof File ? [4, y0(e.data)] : [3, 2] : [2];
          case 1:
            return n = o.sent(), [3, 3];
          case 2:
            n = e.data, o.label = 3;
          case 3:
            return r = n, [4, l9[e.format].parse(r)];
          case 4:
            return i = o.sent(), [4, K1.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 O({ isHidden: !1 }, s);
            }), model: { trajectory: { state: a.model, frameIndex: 0 } }, assets: [{ data: r, format: e.format }] })];
        }
      });
    });
  }, t.prototype.getTrajectoryCell = function(e) {
    var r = [];
    if (e) {
      var n = this.plugin.cells.get(e);
      if (!(n != null && n.model.trajectory)) return [];
      r.push(n);
    } else this.plugin.cells.forEach(function(i) {
      i.model.trajectory && r.push(i);
    });
    return r;
  }, t.prototype.play = function(e) {
    var r = this;
    this.paused = !1;
    var n = function() {
      r.next(e), r.paused || window.requestAnimationFrame(n);
    };
    window.requestAnimationFrame(n);
  }, t.prototype.next = function(e) {
    return _e(this, 0, void 0, function() {
      var r, n, i, a, o, s, u, c;
      return ye(this, function(l) {
        switch (l.label) {
          case 0:
            r = this.getTrajectoryCell(e), n = 0, i = r, l.label = 1;
          case 1:
            return n < i.length ? (a = i[n], o = a.model.trajectory, s = o.state, u = o.frameIndex, c = u >= s.frameCount - 1 ? 0 : u + 1, [4, K1.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(e), e && this.updated.next({ ref: e, frame: c }), l.label = 3;
          case 3:
            return n++, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, t.prototype.setFrameIndex = function(e, r) {
    var n;
    return _e(this, 0, void 0, function() {
      var i, a, o, s;
      return ye(this, function(u) {
        switch (u.label) {
          case 0:
            i = this.getTrajectoryCell(r), a = 0, o = i, u.label = 1;
          case 1:
            return a < o.length ? (s = o[a], [4, K1.update(Array.from(s.representations).map(function(c) {
              return c[0], c[1].state;
            }), { trajectory: (n = s.model.trajectory) === null || n === void 0 ? void 0 : n.state, frameIndex: e, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)]) : [3, 4];
          case 2:
            u.sent(), s.model.trajectory.frameIndex = e, u.label = 3;
          case 3:
            return a++, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, t.prototype.updateDependencyByCells = function(e) {
    return _e(this, 0, void 0, function() {
      var r, n, i, a, o, s, u, c, l, d = this;
      return ye(this, function(f) {
        for (r = this.getTrajectoryCell(e), n = 0, i = r; n < i.length; n++) if ((a = i[n]).dependency.by.length) for (o = function(h) {
          var m = s.plugin.cells.get(h);
          m && m.representations.forEach(function(p, v) {
            v === Pe.IntraInteractions && d.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.trajectory.updateDependencyByCells"), Object.keys(Am).includes(v) && d.plugin.managers.representation.updateMeasurement({ items: m.dependency.on, ref: h });
          });
        }, s = this, u = 0, c = a.dependency.by; u < c.length; u++) l = c[u], o(l);
        return [2];
      });
    });
  }, t.prototype.mergeDumpAndPymatgen = function(e, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a;
      return ye(this, function(o) {
        switch (o.label) {
          case 0:
            return (n = this.getTrajectoryCell(r)).length && n[0].assets[0].format === gr.Dump ? (i = n[0], [4, kfe(i.assets[0].data, e)]) : [2];
          case 1:
            return a = o.sent(), i.model.trajectory = { state: a, frameIndex: i.model.trajectory.frameIndex }, [4, K1.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(r), [2];
        }
      });
    });
  }, t.prototype.pause = function() {
    this.paused = !0;
  }, t;
}();
function CP(t) {
  try {
    t.dispatchEvent(new MouseEvent("click"));
  } catch {
    var e = document.createEvent("MouseEvents");
    e.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), t.dispatchEvent(e);
  }
}
function CG(t, e) {
  if (e === void 0 && (e = "download"), t) if ("download" in HTMLAnchorElement.prototype) {
    var r = document.createElement("a");
    r.download = e, r.rel = "noopener", typeof t == "string" ? (r.href = t, CP(r)) : (r.href = URL.createObjectURL(t), setTimeout(function() {
      return URL.revokeObjectURL(r.href);
    }, 4e4), setTimeout(function() {
      return CP(r);
    }));
  } else if (typeof navigator < "u" && navigator.msSaveOrOpenBlob) navigator.msSaveOrOpenBlob(t, e);
  else {
    var n = window.navigator.userAgent, i = /Safari/i.test(n), a = /CriOS\/[\d]+/.test(n), 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 (t instanceof Blob) {
      var s = new FileReader();
      s.onloadend = function() {
        return o(s.result);
      }, s.readAsDataURL(t);
    } else o(t);
    else {
      var u = URL.createObjectURL(typeof t == "string" ? new Blob([t]) : t);
      location.href = u, setTimeout(function() {
        return URL.revokeObjectURL(u);
      }, 4e4);
    }
  }
}
var Ys, Gm, AP = function() {
  function t(e) {
    this.ev = wo.create(), this.event = { changed: this.ev() }, this.plugin = e;
  }
  return t.prototype.setSnapshot = function(e, r) {
    var n, i, a, o, s;
    return _e(this, 0, void 0, function() {
      var u, c, l, d, f, h, m, p;
      return ye(this, function(v) {
        switch (v.label) {
          case 0:
            for (u = /* @__PURE__ */ new Map(), ((n = e == null ? void 0 : e.params) === null || n === void 0 ? void 0 : n.showPolarHydrogenOnly) !== void 0 && (this.plugin.managers.representation.showPolarHydrogenOnly = e.params.showPolarHydrogenOnly), ((i = e == null ? void 0 : e.params) === null || i === void 0 ? void 0 : i.interactionParams) !== void 0 && (this.plugin.managers.representation.interactionParams = e.params.interactionParams), c = 0, l = e.cells; c < l.length; c++) p = l[c], u.set(p.ref, { ref: p.ref, assets: p.assets, dependency: p.dependency, model: {}, representations: /* @__PURE__ */ new Map(), theme: p.theme });
            this.plugin.cells = u, d = function(g) {
              var y, b, S, _, x, C, A, w, I, P, M, T, F, N, R, L, V, U, H, K, X;
              return ye(this, function(Y) {
                switch (Y.label) {
                  case 0:
                    return y = g.model, b = y.structure, y.trajectory, S = y.other, _ = g.representations, x = g.dependency, C = g.theme, A = void 0, b ? _ != null && _.some(function(Q) {
                      return Q.isHidden !== !0;
                    }) ? (w = typeof b.data == "string" || b.data instanceof File, M = (P = Il[b.format]).parse, w ? [4, y0(b.data)] : [3, 2]) : [3, 7] : [3, 8];
                  case 1:
                    return T = Y.sent(), [3, 3];
                  case 2:
                    T = b.data, Y.label = 3;
                  case 3:
                    return [4, M.apply(P, [T])];
                  case 4:
                    return I = Y.sent(), b.format !== gr.Pdb || !I[0].elementCount || pn.hasSecondaryStructure((a = I[0]) === null || a === void 0 ? void 0 : a.model) ? [3, 6] : [4, Ha.attach({}, I[0], { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } }, !0)];
                  case 5:
                    Y.sent(), Y.label = 6;
                  case 6:
                    return A = I[0], f.plugin.managers.cell.update(g.ref, { representations: [], model: { structure: I[0] }, assets: [{ format: b.format, data: b.data }] }), [3, 8];
                  case 7:
                    f.plugin.managers.cell.update(g.ref, { representations: [], model: { structure: void 0 }, assets: [{ format: b.format, data: b.data }] }), Y.label = 8;
                  case 8:
                    return F = g.theme, C && (N = {}, Object.keys(C).forEach(function(Q) {
                      var J = C[Q];
                      if (J) {
                        var te = {};
                        Object.keys(J).forEach(function(W) {
                          var j = J[W], ee = [];
                          j != null && j.length && j.forEach(function(ie) {
                            ee.push(O(O({}, ie), { elementIds: ie.elementIds ? gv(ie.elementIds) : ie.elementIds }));
                          }), te[W] = ee;
                        }), N[Q] = te;
                      }
                    }), F = N, f.plugin.managers.cell.update(g.ref, { representations: [], model: {}, theme: N })), _ != null && _.length ? A ? [3, 9] : (f.plugin.managers.cell.update(g.ref, { representations: _ == null ? void 0 : _.map(function(Q) {
                      var J;
                      return Q.cache ? Q : O(O({}, Q), { elementIds: [], cache: O(O({}, Q), { elementIds: !((J = Q.elementIds) === null || J === void 0) && J.length ? gv(Q.elementIds) : Q.elementIds }) });
                    }), model: {} }), [3, 13]) : [3, 13];
                  case 9:
                    R = function(Q) {
                      var J, te, W, j;
                      return ye(this, function(ee) {
                        switch (ee.label) {
                          case 0:
                            return !((o = Q.elementIds) === null || o === void 0) && o.length ? (J = Object.keys(Bn).find(function(ie) {
                              return Bn[ie].includes(Q.type);
                            }), te = F.color[J], W = F.transparency ? F.transparency[J] : void 0, j = Q.elementIds ? gv(Q.elementIds) : [], [4, f.plugin.managers.representation.addMolecularRepr(g.ref, { reprType: Q.type, elementIds: j, isHidden: Q.isHidden, theme: f.plugin.managers.representation.createTheme(Q.type, fi(A, j, !0), { color: { name: "multi-theme", props: { themes: te } }, size: F.size && (!((s = F.size[J]) === null || s === void 0) && s.length) ? F.size[J][0] : f.plugin.managers.representation.defaultTheme.size[Q.type] }), transparency: W })]) : [3, 2];
                          case 1:
                            ee.sent(), ee.label = 2;
                          case 2:
                            return [2];
                        }
                      });
                    }, L = 0, V = _, Y.label = 10;
                  case 10:
                    return L < V.length ? (U = V[L], [5, R(U)]) : [3, 13];
                  case 11:
                    Y.sent(), Y.label = 12;
                  case 12:
                    return L++, [3, 10];
                  case 13:
                    return S ? (U = _[0], S.serverData && !S.data && r ? [4, r(S.serverData)] : [3, 15]) : [3, 18];
                  case 14:
                    return K = Y.sent(), [3, 16];
                  case 15:
                    K = S, Y.label = 16;
                  case 16:
                    return H = K, [4, f.plugin.managers.representation.createOther({ data: U.type === Pe.IsoSurface ? new File([H.data], H.name) : H, serverData: S.serverData, type: U.type, ref: g.ref, isHidden: U.isHidden })];
                  case 17:
                    Y.sent(), Y.label = 18;
                  case 18:
                    return x.on.length ? (X = x.on.map(function(Q) {
                      return O(O({}, Q), { elementIds: Q.elementIds ? gv(Q.elementIds) : Q.elementIds });
                    }), [4, f.plugin.managers.representation.createMeasurement({ items: X, type: _[0].type, ref: g.ref, props: _[0].params, isHidden: _[0].isHidden })]) : [3, 20];
                  case 19:
                    Y.sent(), f.plugin.managers.cell.update(g.ref, { representations: [], model: {}, dependency: O(O({}, g.dependency), { on: X }) }), Y.label = 20;
                  case 20:
                    return [2];
                }
              });
            }, f = this, h = 0, m = e.cells, v.label = 1;
          case 1:
            return h < m.length ? (p = m[h], [5, d(p)]) : [3, 4];
          case 2:
            v.sent(), v.label = 3;
          case 3:
            return h++, [3, 1];
          case 4:
            return this.refresh(), [2];
        }
      });
    });
  }, t.prototype.getSnapshot = function(e) {
    return _e(this, 0, void 0, function() {
      var r, n, i = this;
      return ye(this, function(a) {
        switch (a.label) {
          case 0:
            return this.timestamp = Date.now(), r = [], n = {}, Array.from(this.plugin.cells.values()).map(function(o) {
              var s = o.model.structure, u = o.ref;
              if (s) {
                var c = /* @__PURE__ */ new Map(), l = 0;
                s.units.forEach(function(d) {
                  d.elements.forEach(function(f) {
                    c.set(f, l++);
                  });
                }), n[u] = c;
              }
            }), [4, Promise.all(Array.from(this.plugin.cells.values()).map(function(o) {
              return _e(i, 0, void 0, function() {
                var s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P;
                return ye(this, function(M) {
                  switch (M.label) {
                    case 0:
                      return s = o.representations, u = o.assets, c = o.model, l = c.structure, d = c.trajectory, f = c.other, h = function(T, F) {
                        var N = {};
                        for (var R in T) Object.prototype.hasOwnProperty.call(T, R) && F.indexOf(R) < 0 && (N[R] = T[R]);
                        if (T != null && typeof Object.getOwnPropertySymbols == "function") {
                          var L = 0;
                          for (R = Object.getOwnPropertySymbols(T); L < R.length; L++) F.indexOf(R[L]) < 0 && Object.prototype.propertyIsEnumerable.call(T, R[L]) && (N[R[L]] = T[R[L]]);
                        }
                        return N;
                      }(o, ["representations", "assets", "model"]), (m = wl(h)).model = {}, s.get(Pe.IntraInteractions) || s.get(Pe.BetweenInteractions) ? [2] : (l ? m.model.structure = { data: (A = (C = Zy(l, u == null ? void 0 : u[0].format)) !== null && C !== void 0 ? C : u == null ? void 0 : u[0].data) !== null && A !== void 0 ? A : gs(l).sourceData.data, format: u == null ? void 0 : u[0].format } : u && (m.assets = u), d && (m.model.trajectory = { data: "提取的结构信息", format: u == null ? void 0 : u[0].format }), f ? s.get(Pe.IsoSurface) ? (p = !!o.model.other.serverData, v = p ? o.model.other.data : o.model.other, g = m.model, e ? (y = { serverData: p ? o.model.other.serverData : o.model.other }, [3, 3]) : [3, 1]) : [3, 4] : [3, 5]);
                    case 1:
                      return x = {}, b = Uint8Array.bind, [4, v.arrayBuffer()];
                    case 2:
                      x.data = new (b.apply(Uint8Array, [void 0, M.sent()]))(), x.name = v.name, x.serverData = p ? o.model.other.serverData : o.model.other, y = x, M.label = 3;
                    case 3:
                      return g.other = y, [3, 5];
                    case 4:
                      m.model.other = o.model.other, M.label = 5;
                    case 5:
                      return s != null && s.size && (m.representations = [], S = n[h.ref], s.forEach(function(T) {
                        m.representations.push({ type: T.type, elementIds: T.state ? a8(jy(T.state).map(function(F) {
                          return S && (S != null && S.has(F)) ? S == null ? void 0 : S.get(F) : F;
                        })) : [], isHidden: T.isHidden, params: Op.has(T.type) && T.state ? pG(T.type, T.state) : void 0, cache: T.cache });
                      }), h.theme && Object.keys(h.theme).forEach(function(T) {
                        var F = h.theme[T];
                        if (F) {
                          var N = {};
                          Object.keys(F).forEach(function(R) {
                            var L = F[R], V = [];
                            L != null && L.length && L.forEach(function(U) {
                              V.push(O(O({}, U), { elementIds: a8(U.elementIds && S ? U.elementIds.map(function(H) {
                                var K;
                                return (K = S.get(H)) !== null && K !== void 0 ? K : H;
                              }) : U.elementIds) }));
                            }), N[R] = V;
                          }), m.theme[T] = N;
                        }
                      })), !((I = (w = h.dependency) === null || w === void 0 ? void 0 : w.on) === null || I === void 0) && I.length && (_ = [], (P = h.dependency) === null || P === void 0 || P.on.forEach(function(T) {
                        var F = n[h.ref];
                        _.push(O(O({}, T), { elementIds: a8(T.elementIds && F ? T.elementIds.map(function(N) {
                          var R;
                          return (R = F.get(N)) !== null && R !== void 0 ? R : N;
                        }) : T.elementIds) }));
                      }), m.dependency.on = _), r.push(m), [2];
                  }
                });
              });
            }))];
          case 1:
            return a.sent(), [2, { cells: r, timestamp: this.timestamp, params: { interactionParams: wl(this.plugin.managers.representation.interactionParams), showPolarHydrogenOnly: this.plugin.managers.representation.showPolarHydrogenOnly } }];
        }
      });
    });
  }, t.prototype.refresh = function() {
    var e, r, n, i = this.plugin;
    (e = i.canvas3d) === null || e === void 0 || e.pause(!0), (r = i.canvas3d) === null || r === void 0 || r.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));
      });
    }), (n = i.canvas3d) === null || n === void 0 || n.animate();
  }, t.prototype.downloadAsImage = function(e, r) {
    var n, i;
    return _e(this, 0, void 0, function() {
      var a, o, s, u, c, l, d, f, h, m, p, v, g, y;
      return ye(this, function(b) {
        switch (b.label) {
          case 0:
            if (a = r || { width: ((n = this.plugin.canvas3d) === null || n === void 0 ? void 0 : n.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, f = d.colorBufferFloat, h = d.textureFloat, m = l.props.postprocessing.occlusion, p = l.getImagePass({ transparentBackground: !0, cameraHelper: { axes: { name: "off", params: {} } }, multiSample: O(O({}, l.props.multiSample), { mode: "on", sampleLevel: f && h ? 4 : 2 }), postprocessing: O(O({}, l.props.postprocessing), { occlusion: m.name === "on" ? { name: "on", params: O(O({}, m.params), { samples: 128, resolutionScale: l.webgl.pixelRatio }) } : m }), marking: O({}, l.props.marking) }), v = p.getImageData(o, s, c), (g = document.createElement("canvas")).width = v.width, g.height = v.height, !(y = g.getContext("2d"))) throw new Error("Could not create canvas 2d context");
            return y.putImageData(v, 0, 0), [4, foe(g, "png")];
          case 1:
            return CG(b.sent(), e), [2];
        }
      });
    });
  }, t;
}(), Hfe = { Dihedral: Pe.Dihedral, Distance: Pe.Distance, Angle: Pe.Angle, Label: Pe.Label, "Molecular Surface": Pe.Surface }, qfe = function() {
  function t(e) {
    var r = this;
    this.ev = wo.create(), this.prev = /* @__PURE__ */ new Map(), this.event = { change: this.ev(), add: this.ev(), remove: this.ev(), clear: this.ev() }, this.plugin = e, this.selection = /* @__PURE__ */ new Set(), this.event.change.subscribe(function(n) {
      var i = n.current, a = i.repr;
      if (i.loci.kind !== "empty-loci") {
        var o = Hfe[a.label];
        o === Pe.Surface && (n.current.loci = n.current.repr.getLoci()), e.cells.forEach(function(s) {
          var u;
          s.representations.has(o) && ((u = s.representations.get(o)) === null || u === void 0 ? void 0 : u.state) === a && (r.selection.has(s.ref) ? n.button !== 2 && r.remove({ item: { ref: s.ref }, loci: n.current }) : r.add({ item: { ref: s.ref }, loci: n.current }));
        });
      } else r.clear();
    });
  }
  return t.prototype.add = function(e) {
    var r, n, i = e.item.ref;
    this.selection.add(i);
    var a = this.plugin.cells.get(i);
    if (a) {
      var o = Array.from(a.representations.values())[0];
      if (e != null && e.loci || o.state) {
        var s = (r = e.loci) !== null && r !== void 0 ? r : { repr: o.state, loci: o.state.getLoci() };
        (n = this.plugin.canvas3d) === null || n === void 0 || n.mark(s, _t.Select), this.event.add.next({ ref: i, loci: s }), this.prev.set(i, s), this.plugin.managers.selection.event.changed.next({});
      }
    }
  }, t.prototype.remove = function(e) {
    var r, n, i = e.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 = (r = e.loci) !== null && r !== void 0 ? r : { repr: o.state, loci: o.state.getLoci() };
        (n = this.plugin.canvas3d) === null || n === void 0 || n.mark(s, _t.Deselect), this.event.remove.next({ ref: i, loci: s }), this.prev.delete(i), this.plugin.managers.selection.event.changed.next({});
      }
    }
  }, t.prototype.clear = function() {
    var e = this;
    this.selection.clear(), this.prev.forEach(function(r) {
      var n;
      (n = e.plugin.canvas3d) === null || n === void 0 || n.mark(r, _t.Deselect);
    }), this.prev.clear(), this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
  }, t;
}(), Kfe = function() {
  function t(e) {
    var r = this;
    this.ev = wo.create(), this.lociGranularity = "residue", this.prev = [], this.event = { change: this.ev(), add: this.ev(), remove: this.ev(), clear: this.ev() }, this.plugin = e, this.selection = /* @__PURE__ */ new Map(), this.event.change.subscribe(function(n) {
      if (n.current.loci.kind === "element-loci" && r.plugin.cells.forEach(function(s, u) {
        var c;
        if (s != null && s.model.structure && Pu(s == null ? void 0 : s.model.structure) === Pu(n.current.loci.structure) || s.model.trajectory && (s == null ? void 0 : s.model.trajectory.state.getFrameAtIndex(s.model.trajectory.frameIndex).id) === Pu(n.current.loci.structure)) {
          var l = on(s);
          n.current.loci = Qr.normalize(pi(l, oa(n.current.loci)), r.lociGranularity, !0);
          var d = oa(n.current.loci), f = new Set((c = r.selection.get(u)) !== null && c !== void 0 ? c : []), h = f.size ? d.filter(function(m) {
            return !f.has(m);
          }) : d;
          n.button !== 2 && h.length === 0 ? r.remove({ item: { ref: u, elementIds: d }, reprLoci: n.current }) : r.add({ item: { ref: u, elementIds: h }, reprLoci: n.current });
        }
      }), n.current.loci.kind === "bond-loci") {
        var i = n.current.loci;
        n.current.loci = Qr.normalize(n.current.loci, r.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 = oa(n.current.loci);
        r.plugin.cells.forEach(function(s, u) {
          var c;
          if (s != null && s.model.structure && Pu(s == null ? void 0 : s.model.structure) === Pu(i.bonds[0].aStructure)) {
            var l = new Set((c = r.selection.get(u)) !== null && c !== void 0 ? c : []), d = l.size ? o.filter(function(f) {
              return !l.has(f);
            }) : o;
            n.button !== 2 && d.length === 0 ? r.remove({ item: { ref: u, elementIds: o }, reprLoci: n.current }) : r.add({ item: { ref: u, elementIds: d }, reprLoci: n.current });
          }
        });
      }
      n.current.loci.kind === "empty-loci" && r.clear();
    });
  }
  return Object.defineProperty(t.prototype, "granularity", { get: function() {
    return ioe[this.lociGranularity];
  }, enumerable: !1, configurable: !0 }), t.prototype.getSelectionCellItems = function(e) {
    e === void 0 && (e = !1);
    var r = Array.from(this.selection).map(function(n) {
      return { ref: n[0], elementIds: n[1] };
    }).filter(function(n) {
      var i;
      return (i = n.elementIds) === null || i === void 0 ? void 0 : i.length;
    });
    return e && !r.length ? TL(this.plugin) : r;
  }, t.prototype.getSelection = function() {
    return Array.from(this.selection).reduce(function(e, r) {
      var n;
      return O(O({}, e), ((n = {})[r[0]] = r[1], n));
    }, {});
  }, t.prototype.add = function(e, r, n) {
    var i, a, o = this;
    r === void 0 && (r = !0), n === void 0 && (n = !1);
    var s = e.item, u = s.ref, c = s.elementIds;
    if (!c || c.length) {
      this.selection.set(u, Array.from(new Set(Ze(Ze([], (i = this.selection.get(u)) !== null && i !== void 0 ? i : [], !0), c ?? [], !0))));
      var l = this.plugin.cells.get(u);
      if (l) {
        var d = on(l);
        if (d) {
          var f, h = this.selection.get(u);
          l == null || l.representations.forEach(function(m) {
            var p;
            if (!m.isHidden && m.state) {
              var v = r ? Qr.normalize(Xe.intersect(pi(Vo(m.state), h), Oa(m.state.getLoci())), o.lociGranularity, !0) : Xe.intersect(pi(Vo(m.state), h), Oa(m.state.getLoci()));
              f = { loci: v, repr: m.state }, (p = o.plugin.canvas3d) === null || p === void 0 || p.mark(f, _t.Select);
            }
          }), this.prev.push({ ref: u, elementIds: c }), n || (this.event.add.next({ loci: (a = e.reprLoci) !== null && a !== void 0 ? a : { loci: pi(d, h) }, item: e.item }), this.plugin.managers.selection.event.changed.next({}));
        }
      }
    } else console.warn("add selection, elementIds is empty");
  }, t.prototype.remove = function(e, r, n) {
    var i, a = this;
    r === void 0 && (r = !0), n === void 0 && (n = !1);
    var o = e.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(v) {
          d.has(v) ? c.add(v) : l.push(v);
        }), l.length ? this.selection.set(s, l) : this.selection.delete(s);
        var f, h = this.plugin.cells.get(s), m = (i = this.selection.get(s)) !== null && i !== void 0 ? i : [];
        h == null || h.representations.forEach(function(v) {
          var g, y;
          if (!v.isHidden && v.state) {
            var b = r ? Qr.normalize(Xe.intersect(pi(Vo(v.state), m), Oa(v.state.getLoci())), a.lociGranularity, !0) : Xe.intersect(pi(Vo(v.state), m), Oa(v.state.getLoci()));
            (g = a.plugin.canvas3d) === null || g === void 0 || g.mark({ loci: Oa(v.state.getLoci()), repr: v.state }, _t.Deselect), f = { loci: b, repr: v.state }, (y = a.plugin.canvas3d) === null || y === void 0 || y.mark(f, _t.Select);
          }
        });
        var p = [];
        this.prev.forEach(function(v) {
          var g = v.ref, y = v.elementIds;
          if (g === s) {
            var b = [];
            y == null || y.forEach(function(S) {
              c.has(S) || b.push(S);
            }), b.length && p.push({ ref: g, elementIds: b });
          }
        }), this.prev = p, n || (this.event.remove.next({ loci: f, item: e.item }), this.plugin.managers.selection.event.changed.next({}));
      }
    } else console.warn("remove selection, elementIds is empty");
  }, t.prototype.clear = function() {
    var e = this;
    Array.from(this.selection.keys()).forEach(function(r) {
      var n = e.plugin.cells.get(r);
      n && (n == null || n.representations.forEach(function(i) {
        var a;
        !i.isHidden && i.state && ((a = e.plugin.canvas3d) === null || a === void 0 || a.mark({ loci: Oa(i.state.getLoci()), repr: i.state }, _t.Deselect));
      }));
    }), this.selection.clear(), this.prev = [], this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
  }, t.prototype.setGranularity = function(e) {
    this.lociGranularity = noe[e];
  }, t.prototype.expand = function(e, r) {
    var n = this, i = r ?? this.getSelectionCellItems(), a = this.plugin.managers.cell.getAllDisplayedCellsRef(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), u = s3(a.map(function(S) {
      return { ref: S };
    }), this.plugin), c = u.unitsMap, l = u.structure;
    c.forEach(function(S, _) {
      o.set(a[_], S.map(function(x) {
        return l.unitMap.get(x);
      })), S.forEach(function(x) {
        return s.set(x, a[_]);
      });
    });
    var d = oL(i.map(function(S) {
      var _, x = o.get(S.ref), C = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
      x.forEach(function(I, P) {
        C.set(P, new Set(I.elements)), A.set(P, []);
      }), (_ = S.elementIds) === null || _ === void 0 || _.forEach(function(I) {
        C.forEach(function(P, M) {
          var T;
          P.has(I) && ((T = A.get(M)) === null || T === void 0 || T.push(x[M].elements.indexOf(I)));
        });
      });
      var w = Array.from(A.entries()).filter(function(I) {
        return I[0], I[1].length;
      }).map(function(I) {
        var P = I[0], M = I[1];
        return { unit: x[P], indices: M };
      });
      return w;
    })), f = Xe(l, d), h = Xe.toExpression(f), m = Nt.struct.modifier.union([Nt.struct.modifier.exceptBy({ 0: Nt.struct.modifier.includeSurroundings({ 0: h, radius: e.radius, "as-whole-residues": e.asWholeResidue }), by: h })]), p = kp(Lp(l, m)), v = /* @__PURE__ */ new Map();
    p.units.forEach(function(S) {
      var _, x = s.get(S.id);
      x && (v.has(x) ? (_ = v.get(x)) === null || _ === void 0 || _.push.apply(_, S.elements) : v.set(x, Ze([], S.elements, !0)));
    });
    var g = Array.from(v.entries()).map(function(S) {
      return { ref: S[0], elementIds: S[1] };
    }), y = IL(this.plugin, g), b = aoe[e.filter];
    e.excludeSelectedAtoms && this.clear(), Object.keys(y).forEach(function(S) {
      var _ = [];
      b.forEach(function(x) {
        y[S][x].forEach(function(C) {
          return _.push.apply(_, C.elementIds);
        });
      }), n.add({ item: { ref: S, elementIds: _ } }, !1);
    });
  }, t;
}(), wP = function() {
  function t(e) {
    this.ev = wo.create(), this.event = { changed: this.ev() }, this.plugin = e, this.structure = new Kfe(e), this.shape = new qfe(e);
  }
  return t.prototype.clear = function() {
    this.structure.clear(), this.shape.clear();
  }, t;
}(), DP = function() {
  function t(e) {
    this.ev = wo.create(), this.allowEmptyClick = !0, this.allowSelect = !0, this.rightClick = this.ev(), this.plugin = e, this.allowEmptyClick = !0, this.allowSelect = !0;
  }
  return t.prototype.subscribe = function() {
    var e, r, n = this;
    (e = this.plugin.canvas3d) === null || e === void 0 || e.interaction.click.subscribe(function(i) {
      if (i.current.loci.kind === "empty-loci") {
        if (!n.allowEmptyClick || i.button === 2) return;
        n.plugin.managers.selection.shape.event.change.next(i), n.plugin.managers.selection.structure.event.change.next(i);
      } else if (n.allowSelect) i.current.repr.label === "Molecular Surface" || i.current.loci.kind === "group-loci" ? n.plugin.managers.selection.shape.event.change.next(i) : i.current.loci.kind !== "element-loci" && i.current.loci.kind !== "bond-loci" || n.plugin.managers.selection.structure.event.change.next(i);
      else if (i.button !== 2) return;
      i.button === 2 && n.rightClick.next({ loci: i.current, modifiers: i.modifiers, isEmpty: i.current.loci.kind === "empty-loci", isSelection: !1, reprType: sL[i.current.repr.label] });
    }), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.hover.subscribe(function(i) {
      i.current.loci.kind !== "empty-loci" ? n.plugin.managers.highlight.setHoverSelection(i.current) : n.plugin.managers.highlight.setHoverSelection();
    });
  }, t.prototype.setAllowEmptyClick = function(e) {
    this.allowEmptyClick = e;
  }, t.prototype.setAllowSelect = function(e) {
    this.allowSelect = e;
  }, t;
}(), Xfe = { interval: void 0, observers: void 0, cRef: "", elementId: -1, totalOffset: E.create(0, 0, 0) }, Yfe = function() {
  function t(e) {
    this.state = Xfe, this.intervalTime = 300, this.plugin = e;
  }
  return t.prototype.start = function() {
    var e, r, n = this;
    this.plugin.managers.editor.disabledInteraction = ["click", "drag"], this.plugin.managers.selection.structure.setGranularity(Kr.Atom), this.state.observers = (e = this.plugin.canvas3d) === null || e === void 0 ? void 0 : e.interaction.drag.observers.pop(), this.state.interval = setInterval(function() {
      if (n.state.totalOffset.filter(function(a) {
        return a !== 0;
      }).length !== 0 && n.state.elementId !== -1) {
        var i = Ze([], n.state.totalOffset, !0);
        n.state.totalOffset = E.create(0, 0, 0), n.plugin.managers.editor.executeEdit(n.state.cRef, function(a, o) {
          var s = Ze([], a, !0), u = Ze([], o, !0);
          return s.forEach(function(c) {
            c.elementId === n.state.elementId && (c.x -= i[0], c.y -= i[1], c.z -= i[2]);
          }), { editedAtomList: s, editedBondList: u };
        }, function(a, o) {
          var s = Ze([], a, !0), u = Ze([], o, !0);
          return s.forEach(function(c) {
            c.elementId === n.state.elementId && (c.x -= i[0], c.y -= i[1], c.z -= i[2]);
          }), { editedAtomList: s, editedBondList: u };
        });
      }
    }, this.intervalTime), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(function(i) {
      var a = i.current.loci;
      if (a.kind === "element-loci") {
        var o = Ge.toArray(a.elements[0].indices);
        if (o.length === 1) {
          n.plugin.cells.forEach(function(u, c) {
            u.model.structure && Xe.isSubset(tt.toStructureElementLoci(u.model.structure), a) && (n.state.cRef = c);
          });
          var s = hG(n.plugin, i.pageStart, i.pageEnd);
          E.add(n.state.totalOffset, n.state.totalOffset, s), n.state.elementId = a.elements[0].unit.elements[o[0]];
        }
      }
    });
  }, t.prototype.end = function() {
    var e, r;
    this.state.interval && clearInterval(this.state.interval), (e = this.plugin.canvas3d) === null || e === void 0 || e.interaction.drag.observers.pop(), this.state.observers && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(this.state.observers)), this.state.observers = void 0, this.state.cRef = "", this.state.elementId = -1, this.state.totalOffset = E.create(0, 0, 0);
  }, t;
}(), Wfe = { elementType: "C", drawClickObserver: void 0, position: void 0, isDelete: !1 }, jfe = function() {
  function t(e) {
    this.ev = wo.create(), this.state = Wfe, this.event = { update: this.ev() }, this.plugin = e;
  }
  return t.prototype.setElementType = function(e) {
    this.state.elementType = e;
  }, t.prototype.setPosition = function(e) {
    this.state.position = e;
  }, t.prototype.setIsDelete = function(e) {
    this.state.isDelete = e;
  }, t.prototype.start = function() {
    var e, r, n = this;
    this.plugin.managers.editor.disabledInteraction = ["click"], this.plugin.managers.selection.structure.setGranularity(Kr.Atom), this.state.drawClickObserver = (e = this.plugin.canvas3d) === null || e === void 0 ? void 0 : e.interaction.click.observers.pop(), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(function(i) {
      return _e(n, 0, void 0, function() {
        var a, o, s, u, c, l, d, f, h, m, p, v, g, y = this;
        return ye(this, function(b) {
          switch (b.label) {
            case 0:
              return i.current.loci && i.current.loci.kind === "element-loci" ? (a = i.current.loci, (o = Ge.toArray(a.elements[0].indices)).length !== 1 ? [3, 5] : (this.plugin.cells.forEach(function(S, _) {
                S.model.structure && Xe.isSubset(tt.toStructureElementLoci(S.model.structure), a) && (s = _);
              }), 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 b.sent(), [3, 4];
            case 2:
              return [4, this.plugin.managers.cell.remove([{ ref: s, elementIds: [u] }])];
            case 3:
              b.sent(), b.label = 4;
            case 4:
              this.event.update.next({ isUpdateHierarchy: !0, cRef: s }), b.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(S) {
                S[0];
                var _ = S[1];
                return _.model.structure && (Array.from(_.representations.values()).findIndex(function(x) {
                  return x.isHidden === !1;
                }) !== -1 || !_.representations.size);
              }), c.length ? (l = ((m = c[0][1].model.structure) === null || m === void 0 ? void 0 : m.units.length) === 0, (d = (((p = this.plugin.canvas3d) === null || p === void 0 ? void 0 : p.getPosition(i.page[0], i.page[1])) || { position: void 0 }).position) ? c.length !== 1 ? [3, 8] : (f = c[0][1].model.structure) ? (h = "".concat(Math.max.apply(Math, Array.from((g = (v = f.model) === null || v === void 0 ? void 0 : v.atomicConformation.atomId.toArray()) !== null && g !== void 0 ? g : [0])) + 1), [4, this.plugin.managers.editor.executeEdit(c[0][0], function(S, _) {
                return { editedAtomList: Ze(Ze([], S, !0), [Vh(h, y.state.elementType, d)], !1), editedBondList: Ze([], _, !0), affectedAtomIds: [+h] };
              }, function(S, _) {
                return { editedAtomList: Ze(Ze([], S, !0), [Vh(h, y.state.elementType, d)], !1), editedBondList: Ze([], _, !0) };
              })]) : [2] : [3, 9]) : (this.event.update.next({ hasMultiRef: !0 }), [2]));
            case 7:
              return b.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: Vh("", this.state.elementType, d) }), b.label = 9;
            case 9:
              return [2];
          }
        });
      });
    });
  }, t.prototype.end = function() {
    var e, r;
    (e = this.plugin.canvas3d) === null || e === void 0 || e.interaction.click.observers.pop(), this.state.drawClickObserver && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(this.state.drawClickObserver)), this.state.drawClickObserver = void 0;
  }, t.prototype.addAtomByRef = function(e) {
    var r, n, i = this;
    if (this.state.position) {
      var a = this.plugin.cells.get(e);
      if (a) {
        var o = a.model.structure;
        if (o) {
          var s = "".concat(Math.max.apply(Math, Array.from((n = (r = o.model) === null || r === void 0 ? void 0 : r.atomicConformation.atomId.toArray()) !== null && n !== void 0 ? n : [0])) + 1);
          this.plugin.managers.editor.executeEdit(e, function(u, c) {
            return { editedAtomList: Ze(Ze([], u, !0), [Vh(s, i.state.elementType, i.state.position)], !1), editedBondList: Ze([], c, !0), affectedAtomIds: [+s] };
          }, function(u, c) {
            return { editedAtomList: Ze(Ze([], u, !0), [Vh(s, i.state.elementType, i.state.position)], !1), editedBondList: Ze([], c, !0) };
          }), this.setPosition();
        }
      }
    }
  }, t;
}(), Zfe = { interval: void 0, dragObserver: void 0, cRef: "", elementIds: [], unit: void 0, rotateOffset: E.create(0, 0, 0), rotateAtoms: [], arrowCRef: void 0, invert: !1, pointA: E.create(0, 0, 0), pointB: E.create(0, 0, 0) }, Qfe = function() {
  function t(e) {
    this.state = Zfe, this.intervalTime = 300, this.plugin = e;
  }
  return t.prototype.start = function() {
    var e, r, n;
    return _e(this, 0, void 0, function() {
      var i, a = this;
      return ye(this, function(o) {
        switch (o.label) {
          case 0:
            return this.plugin.managers.editor.disabledInteraction = ["drag"], this.plugin.managers.selection.structure.setGranularity(Kr.Atom), this.state.dragObserver = (e = this.plugin.canvas3d) === null || e === void 0 ? void 0 : e.interaction.drag.observers.pop(), i = function() {
              return _e(a, 0, void 0, function() {
                var s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T, F;
                return ye(this, function(N) {
                  switch (N.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(R) {
                        return R[0], R[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 = Ze([], c, !0), !(l = (F = this.plugin.cells.get(u[0][0])) === null || F === void 0 ? void 0 : F.model.structure)) return [2];
                      for (d = l.units.find(function(R) {
                        return Ke.has(R.elements, c[0]) && Ke.has(R.elements, c[1]);
                      }), this.state.unit = d, h = (f = d).bonds, m = f.conformation, p = f.rings, v = f.elements, g = /* @__PURE__ */ new Map(), y = -1, b = 0, S = h.a.length; b < S; b++) {
                        if (y === -1 && (v[h.a[b]] === c[0] && v[h.b[b]] === c[1] && h.edgeProps.order[b] === 1 || v[h.a[b]] === c[1] && v[h.b[b]] === c[0] && h.edgeProps.order[b] === 1)) {
                          for (_ = 0, x = p.all.length; _ < x; _++) if (p.all[_].includes(c[0]) && p.all[_].includes(c[1])) return [2];
                          y = b;
                        }
                        g.has(v[h.a[b]]) ? g.set(v[h.a[b]], Ze(Ze([], g.get(v[h.a[b]]), !0), [v[h.b[b]]], !1)) : g.set(v[h.a[b]], [v[h.b[b]]]);
                      }
                      return y !== -1 && g.get(c[0]).length > 1 && g.get(c[1]).length > 1 ? (C = this.state.invert ? 1 : 0, A = this.state.invert ? 0 : 1, this.state.pointA = E.create(m.x(c[A]), m.y(c[A]), m.z(c[A])), this.state.pointB = E.create(m.x(c[C]), m.y(c[C]), m.z(c[C])), w = this.state, [4, this.plugin.managers.representation.createOther({ data: { center: this.state.pointA, vec: E.create(this.state.pointB[0] - this.state.pointA[0], this.state.pointB[1] - this.state.pointA[1], this.state.pointB[2] - this.state.pointA[2]), color: qe.fromRgb(255, 196, 36), alpha: 0.9 }, type: Pe.RotateArrow })]) : [3, 2];
                    case 1:
                      for (w.arrowCRef = N.sent(), I = Ze([], g.get(c[C]).filter(function(R) {
                        return R !== c[A] && R !== c[C];
                      }), !0), P = [c[C]], this.state.rotateAtoms = Ze([], I, !0); I.length; ) M = I.shift(), (T = this.state.rotateAtoms).push.apply(T, g.get(M)), P.push(M), I.push.apply(I, g.get(M).filter(function(R) {
                        return !P.includes(R);
                      }));
                      this.state.rotateAtoms = Array.from(new Set(this.state.rotateAtoms.filter(function(R) {
                        return R !== c[A] && R !== c[C];
                      }))), N.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 = E.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 = E.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 = E.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 }]);
            }), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(function(s) {
              s.current.loci.kind === "group-loci" && (s.current.repr ? s.current.repr.label === "RotateArrow" : s.current.loci.shape.name.split("-").shift() === "RotateArrow") && (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 = E.angle(E.sub(E.create(0, 0, 0), a.state.pointA, a.state.pointB), E.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2]));
                E.cross(E.create(0, 0, 0), E.sub(E.create(0, 0, 0), a.state.pointA, a.state.pointB), E.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2]))[2] < 0 && (c = 2 * Math.PI - c);
                var l = 5 * E.distance(E.create(0, 0, 0), E.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2])) * (c < Math.PI && c > 0 ? -1 : 1);
                a.state.rotateOffset = E.create(0, 0, 0), a.plugin.managers.editor.executeEdit(a.state.cRef, function(d, f) {
                  var h = Ze([], d, !0), m = Ze([], f, !0);
                  return h.forEach(function(p) {
                    if (a.state.rotateAtoms.includes(p.elementId)) {
                      var v = fP([u.x(s[1]), u.y(s[1]), u.z(s[1])], [u.x(s[0]), u.y(s[0]), u.z(s[0])], l, [p.x, p.y, p.z]);
                      p.x = v[0], p.y = v[1], p.z = v[2];
                    }
                  }), { editedAtomList: h, editedBondList: m };
                }, function(d, f) {
                  var h = Ze([], d, !0), m = Ze([], f, !0);
                  return h.forEach(function(p) {
                    if (a.state.rotateAtoms.includes(p.elementId)) {
                      var v = fP([u.x(s[1]), u.y(s[1]), u.z(s[1])], [u.x(s[0]), u.y(s[0]), u.z(s[0])], l, [p.x, p.y, p.z]);
                      p.x = v[0], p.y = v[1], p.z = v[2];
                    }
                  }), { editedAtomList: h, editedBondList: m };
                });
              }
            }, this.intervalTime), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.drag.subscribe(function(s) {
              if (a.state.rotateAtoms.length) {
                var u = hG(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];
        }
      });
    });
  }, t.prototype.end = function() {
    var e, r, n;
    this.state.arrowCRef && (this.plugin.managers.cell.remove([{ ref: this.state.arrowCRef }]), this.state.arrowCRef = void 0), this.state.interval && clearInterval(this.state.interval), (e = this.plugin.canvas3d) === null || e === void 0 || e.interaction.drag.observers.pop(), this.state.dragObserver && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(this.state.dragObserver)), this.state.invert = !1, this.state.dragObserver = void 0, this.state.rotateOffset = E.create(0, 0, 0), this.state.rotateAtoms = [], this.state.elementIds = [], this.state.unit = void 0, this.plugin.managers.selection.structure.event.add.observers.pop(), this.plugin.managers.selection.structure.event.remove.observers.pop(), this.plugin.managers.selection.structure.event.clear.observers.pop(), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.click.observers.pop();
  }, t;
}();
(function(t) {
  t[t.None = 0] = "None", t[t.Drag = 1] = "Drag", t[t.Rotate = 2] = "Rotate", t[t.Draw = 3] = "Draw";
})(Ys || (Ys = {})), function(t) {
  t[t.SINGLE = 1] = "SINGLE", t[t.DOUBLE = 2] = "DOUBLE", t[t.TRIPLE = 3] = "TRIPLE", t[t.AROMATIC = 4] = "AROMATIC", t[t.SINGLE_OR_DOUBLE = 5] = "SINGLE_OR_DOUBLE", t[t.SINGLE_OR_AROMATIC = 6] = "SINGLE_OR_AROMATIC", t[t.DOUBLE_OR_AROMATIC = 7] = "DOUBLE_OR_AROMATIC", t[t.ANY = 8] = "ANY";
}(Gm || (Gm = {}));
var EP = [Gm.SINGLE, Gm.DOUBLE, Gm.TRIPLE], IP = function() {
  function t(e) {
    var r;
    this.state = { mode: Ys.None, editAtomDisabled: !1, addBondDisabled: !1, editBondDisabled: !1, selectedPdb: !1, isMergeNeeded: !1 }, this.ev = wo.create(), this.editStateUpdated = this.ev(), this.editStructureUpdated = this.ev(), this.plugin = e, this.instance = ((r = {})[Ys.Drag] = new Yfe(e), r[Ys.Rotate] = new Qfe(e), r[Ys.Draw] = new jfe(e), r[Ys.None] = void 0, r);
  }
  return Object.defineProperty(t.prototype, "isEditing", { get: function() {
    var e;
    return !!(!((e = this.plugin.canvas3d) === null || e === void 0) && e.controls.isEditing);
  }, set: function(e) {
    var r, n, i = ((r = this.plugin.canvas3d) === null || r === void 0 ? void 0 : r.controls.isEditing) === !1 && e;
    if ((n = this.plugin.canvas3d) === null || n === void 0 || n.controls.setEditState(e), i && this.setState(this.getEditState()), !e) {
      var a = [];
      this.plugin.cells.forEach(function(o, s) {
        o.representations.has(Pe.RotateArrow) && a.push({ ref: s });
      }), this.plugin.managers.cell.remove(a);
    }
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "disabledInteraction", { get: function() {
    var e;
    return ((e = this.plugin.canvas3d) === null || e === void 0 ? void 0 : e.controls.disabledInteraction) || [];
  }, set: function(e) {
    var r;
    (r = this.plugin.canvas3d) === null || r === void 0 || r.controls.setDisabledInteractionState(e);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isLockCamera", { get: function() {
    var e;
    return !!(!((e = this.plugin.canvas3d) === null || e === void 0) && e.controls.isLockCamera);
  }, set: function(e) {
    var r;
    (r = this.plugin.canvas3d) === null || r === void 0 || r.controls.setLockCameraState(e);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "drawEditor", { get: function() {
    return this.instance[Ys.Draw];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotateEditor", { get: function() {
    return this.instance[Ys.Rotate];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dragEditor", { get: function() {
    return this.instance[Ys.Drag];
  }, enumerable: !1, configurable: !0 }), t.prototype.setState = function(e) {
    Object.assign(this.state, e), this.editStateUpdated.next(this.state);
  }, t.prototype.setEditorMode = function(e, r, n) {
    r === void 0 && (r = !1), n === void 0 && (n = ["click", "drag"]), this.isEditing = e, this.isLockCamera = r, this.disabledInteraction = n;
  }, t.prototype.getEditState = function() {
    var e, r, n, 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, f = [];
    if (d.forEach(function(y, b) {
      f.push(b), c = c || a.plugin.managers.cell.isFromPdb(b);
    }), f.length > 0) for (var h = 0, m = f.length; h < m; h++) {
      var p = f[h];
      d.has(p) && (o = !1);
    }
    if (f.length === 0 || f.length > 2) return { editAtomDisabled: o, addBondDisabled: s, editBondDisabled: u, selectedPdb: c, isMergeNeeded: l };
    if (f.length === 2) (v = Ze(Ze([], (e = d.get(f[0])) !== null && e !== void 0 ? e : [], !0), (r = d.get(f[1])) !== null && r !== void 0 ? r : [], !0)).length === 2 && (s = !1, l = !0);
    else if (f.length === 1) {
      var v;
      if (((v = d.get(f[0])) == null ? void 0 : v.length) === 2) {
        s = !1;
        var g = this.plugin.cells.get(f[0]);
        !((n = g == null ? void 0 : g.model.structure) === null || n === void 0) && n.units.length && ((i = g == null ? void 0 : g.model.structure) === null || i === void 0 ? void 0 : i.units[0]).bonds.getEdgeIndex(v[0], v[1]) !== -1 && (u = !1);
      }
    }
    return { editAtomDisabled: o, addBondDisabled: s, editBondDisabled: u, selectedPdb: c, isMergeNeeded: l };
  }, t.prototype.coverStructure = function(e, r, n) {
    return _e(this, 0, void 0, function() {
      var i, a, o, s = this;
      return ye(this, function(u) {
        switch (u.label) {
          case 0:
            return i = n.format, a = n.data, [4, this.plugin.managers.representation.updateMolecular({ ref: e, structure: r })];
          case 1:
            return (o = u.sent()).model.structure = r, this.plugin.managers.cell.update(e, { model: o.model, representations: Array.from(o.representations.values()), assets: [{ format: i, data: a }] }), this.editStructureUpdated.next(e), this.plugin.managers.cell.traverse(function(c, l) {
              l.type === Pe.IntraInteractions && s.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
            }), [2];
        }
      });
    });
  }, t.prototype.executeEdit = function(e, r, n, i) {
    var a, o, s;
    return _e(this, 0, void 0, function() {
      var u, c, l, d, f, h = this;
      return ye(this, function(m) {
        switch (m.label) {
          case 0:
            return u = this.plugin.cells.get(e), (c = (a = u == null ? void 0 : u.model) === null || a === void 0 ? void 0 : a.structure) ? [4, Hse(c, r, n, i)] : [2];
          case 1:
            return (l = m.sent()).length <= 0 ? [2] : [4, this.plugin.managers.representation.updateMolecular({ ref: e, structure: l[0] })];
          case 2:
            return (d = m.sent()).model.structure = l[0], f = ((s = (o = gs(l[0])) === null || o === void 0 ? void 0 : o.sourceData) === null || s === void 0 ? void 0 : s.kind) !== "mmCIF" ? gr.Sdf : gr.Pdb, this.plugin.managers.cell.update(e, { model: d.model, representations: Array.from(d.representations.values()), assets: [{ format: f, data: Zy(l[0], f) }] }), this.editStructureUpdated.next(e), this.plugin.managers.cell.traverse(function(p, v) {
              v.type === Pe.IntraInteractions && h.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
            }), [2];
        }
      });
    });
  }, t.prototype.coverSourceData = function(e, r, n, i) {
    var a, o, s, u, c, l, d;
    return _e(this, 0, void 0, function() {
      var f, h, m, p, v, g, y, b, S, _, x, C = this;
      return ye(this, function(A) {
        switch (A.label) {
          case 0:
            return this.plugin.cells.has(e) ? (m = (h = Il[r]).parse, [4, y0(n)]) : [2];
          case 1:
            return [4, m.apply(h, [A.sent()])];
          case 2:
            return f = A.sent(), i ? ((p = this.plugin.cells.get(e)) == null || p.representations.forEach(function(w) {
              var I;
              w.state && ((I = C.plugin.canvas3d) === null || I === void 0 || I.remove(w.state));
            }), this.plugin.managers.cell.update(e, { model: { structure: f[0] }, representations: [], assets: [{ format: r, data: n }] }), p.representations = /* @__PURE__ */ new Map(), [4, this.plugin.managers.representation.setMolecularRepr([{ ref: e, elementIds: ms(f[0]) }], i, !1)]) : [3, 4];
          case 3:
            return A.sent(), v = this.plugin.managers.selection.structure.getSelection(), g = (a = v[e]) !== null && a !== void 0 ? a : [], (y = (o = this.plugin.cells.get(e)) === null || o === void 0 ? void 0 : o.representations.get(i)) && (b = pi(Vo(y.state), g), (s = this.plugin.canvas3d) === null || s === void 0 || s.mark({ loci: b, repr: y.state }, _t.Select)), [2];
          case 4:
            return [4, this.plugin.managers.representation.updateMolecular({ ref: e, structure: f[0] })];
          case 5:
            return (S = A.sent()).model.structure = f[0], this.plugin.managers.cell.update(e, { model: S.model, representations: Array.from(S.representations.values()), assets: [{ format: r, data: n }] }), _ = this.plugin.managers.selection.structure.getSelection(), x = (u = _[e]) !== null && u !== void 0 ? u : [], (c = this.plugin.cells.get(e)) === null || c === void 0 || c.representations.values(), Array.from((d = (l = this.plugin.cells.get(e)) === null || l === void 0 ? void 0 : l.representations.values()) !== null && d !== void 0 ? d : []).forEach(function(w) {
              var I, P = pi(Vo(w.state), x);
              (I = C.plugin.canvas3d) === null || I === void 0 || I.mark({ loci: P, repr: w.state }, _t.Select);
            }), this.plugin.managers.cell.traverse(function(w, I) {
              I.type === Pe.IntraInteractions && C.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.coverSourceData");
            }), [2];
        }
      });
    });
  }, t.prototype.edit = function(e, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o = this;
      return ye(this, function(s) {
        switch (s.label) {
          case 0:
            return n = this.isLockCamera, this.isLockCamera = !0, i = r ?? this.plugin.managers.selection.structure.getSelectionCellItems(), [4, Promise.all(i.map(function(u) {
              var c = u.ref, l = u.elementIds;
              return e(c, l ?? []);
            }))];
          case 1:
            return s.sent(), a = this.plugin.managers.selection.structure.getSelection(), i.forEach(function(u) {
              var c, l, d = u.ref, f = o.plugin.cells.get(d), h = (c = a[d]) !== null && c !== void 0 ? c : [];
              Array.from((l = f == null ? void 0 : f.representations.values()) !== null && l !== void 0 ? l : []).forEach(function(m) {
                var p, v = pi(Vo(m.state), h);
                (p = o.plugin.canvas3d) === null || p === void 0 || p.mark({ loci: v, repr: m.state }, _t.Select);
              });
            }), this.isLockCamera = n, [2];
        }
      });
    });
  }, t.prototype.deleteAtoms = function(e) {
    return _e(this, 0, void 0, function() {
      var r, n, i = this;
      return ye(this, function(a) {
        switch (a.label) {
          case 0:
            return r = {}, n = function(o, s) {
              return i.executeEdit(o, function(u, c) {
                var l = new Set(s), d = /* @__PURE__ */ new Map(), f = [];
                u.forEach(function(m) {
                  var p = l.has(m.elementId);
                  return p || (r[m.elementId] = f.length, f.push(O({}, m)), d.set(m.elementId + 1, f.length)), !p;
                });
                var h = c.filter(function(m) {
                  var p = l.has(m.a - 1) || l.has(m.b - 1);
                  return d.has(m.a) && (m.a = d.get(m.a)), d.has(m.b) && (m.b = d.get(m.b)), !p;
                });
                return { editedAtomList: f, editedBondList: h };
              }, function(u, c) {
                var l = new Set(s), d = [];
                u.forEach(function(h) {
                  l.has(h.elementId) || (r[h.elementId] = d.length, d.push(h));
                });
                var f = Ze([], c, !0);
                return { editedAtomList: d, editedBondList: f, affectedAtomIds: [] };
              });
            }, [4, this.edit(n, e)];
          case 1:
            return a.sent(), [2, r];
        }
      });
    });
  }, t.prototype.editAtomCharge = function(e, r) {
    var n = this;
    return this.edit(function(i, a) {
      return n.executeEdit(i, function(o, s) {
        var u = new Set(a), c = Ze([], o, !0), l = Ze([], s, !0), d = [];
        return c.forEach(function(f) {
          if (u.has(f.elementId)) {
            var h = f.charge !== void 0 ? f.charge + e : e;
            h <= 3 && h >= -3 && (f.charge = h, d.push(parseInt(f.atom_id, 10)));
          }
        }), { editedAtomList: c, editedBondList: l, affectedAtomIds: d };
      }, function(o, s) {
        var u = new Set(a), c = Ze([], o, !0), l = Ze([], s, !0), d = [];
        return c.forEach(function(f) {
          if (u.has(f.elementId)) {
            var h = f.charge !== void 0 ? f.charge + e : e;
            h <= 3 && h >= -3 && (f.charge = h, d.push(parseInt(f.atom_id, 10)));
          }
        }), { editedAtomList: c, editedBondList: l, affectedAtomIds: d };
      });
    }, r);
  }, t.prototype.editAtomType = function(e, r) {
    var n = this, i = e ?? this.instance[Ys.Draw].state.elementType;
    return this.edit(function(a, o) {
      return n.executeEdit(a, function(s, u) {
        var c = new Set(o), l = Ze([], s, !0), d = Ze([], u, !0), f = [];
        return l.forEach(function(h) {
          c.has(h.elementId) && (h.auth_atom_id = i, h.type_symbol = i, f.push(parseInt(h.atom_id, 10)));
        }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
      }, function(s, u) {
        var c = new Set(o), l = Ze([], s, !0), d = Ze([], u, !0), f = [];
        return l.forEach(function(h) {
          c.has(h.elementId) && (h.auth_atom_id = i, h.type_symbol = i, f.push(parseInt(h.atom_id, 10)));
        }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
      });
    }, r);
  }, t.prototype.editBondOrder = function(e, r) {
    var n = this;
    return this.edit(function(i, a) {
      return n.executeEdit(i, function(o, s) {
        var u = Ze([], o, !0), c = Ze([], 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 f = d.order + e;
            EP.includes(f) && (d.order = f, l.add(d.a - 1), l.add(d.b - 1));
          }
        }), { editedAtomList: u, editedBondList: c, affectedAtomIds: Array.from(l) };
      }, function(o, s) {
        var u = Ze([], o, !0), c = Ze([], 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 f = d.order + e;
            EP.includes(f) && (d.order = f, l.add(d.atom_idA === void 0 ? d.a - 1 : parseInt(d.atom_idA, 10)), l.add(d.atom_idB === void 0 ? d.b - 1 : parseInt(d.atom_idB, 10)));
          }
        }), { editedAtomList: u, editedBondList: c, affectedAtomIds: Array.from(l) };
      });
    }, r);
  }, t.prototype.addOrDelBond = function(e, r) {
    var n, i = this;
    if (!r || r.length === 1 && ((n = r[0].elementIds) === null || n === void 0 ? void 0 : n.length) === 2) {
      if (!r) {
        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 = Ze([], u, !0), d = Ze([], c, !0), f = Ze([], s, !0);
          return e ? d.filter(function(h) {
            return h.a - 1 === s[0] && h.b - 1 === s[1] || h.a - 1 === s[1] && h.b - 1 === s[0];
          }).length === 0 && d.push({ a: s[0] + 1, b: s[1] + 1, order: 1 }) : d = d.filter(function(h) {
            return !(h.a - 1 === s[0] && h.b - 1 === s[1] || h.a - 1 === s[1] && h.b - 1 === s[0]);
          }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
        }, function(u, c) {
          var l, d = Ze([], u, !0), f = Ze([], c, !0), h = [];
          if (e) {
            if (f.filter(function(y) {
              return y.a === s[0] && y.b === s[1] || y.a === s[1] && y.b === s[0];
            }).length === 0) {
              var m = (l = i.plugin.cells.get(o)) === null || l === void 0 ? void 0 : l.model.structure;
              if (m && m.units.length > 0) {
                var p = m.units[0], v = p.model.atomicConformation.atomId.value(s[0]), g = p.model.atomicConformation.atomId.value(s[1]);
                f.push({ a: s[0], b: s[1], order: 1, atom_idA: "".concat(v), atom_idB: "".concat(g) }), h.push(v, g);
              }
            }
          } else f = f.filter(function(y) {
            return !(y.a === s[0] && y.b === s[1] || y.a === s[1] && y.b === s[0]) || (h.push(y.atom_idA === void 0 ? y.a - 1 : parseInt(y.atom_idA, 10), y.atom_idB === void 0 ? y.b - 1 : parseInt(y.atom_idB, 10)), !1);
          });
          return { editedAtomList: d, editedBondList: f, affectedAtomIds: h };
        });
      }, r);
    }
  }, t.prototype.changeEditorMode = function(e) {
    var r = this.instance[this.state.mode];
    this.isLockCamera = !1, this.disabledInteraction = [], r && r.end();
    var n = this.instance[e];
    n && (this.isEditing = !0, this.isLockCamera = !0, n.start()), this.setState({ mode: e });
  }, t.prototype.start = function() {
    var e = this;
    this.plugin.managers.selection.event.changed.subscribe(function() {
      e.setState(e.getEditState());
    });
  }, t;
}(), TP = function() {
  function t(e) {
    this.ev = wo.create(), this.info = this.ev(), this.handleHighlightLocis = [], this.plugin = e;
  }
  return t.prototype.setHoverSelection = function(e, r) {
    var n, i, a, o = this;
    if (r === void 0 && (r = !0), this.hoverLoci && ((n = this.plugin.canvas3d) === null || n === void 0 || n.mark(this.hoverLoci, _t.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, _t.RemoveHighlight);
    }), e) {
      var s = { loci: Qr.normalize(e.loci, this.plugin.managers.selection.structure.lociGranularity), repr: e.repr };
      (a = this.plugin.canvas3d) === null || a === void 0 || a.mark(s, _t.Highlight), this.hoverLoci = s, r && this.info.next({ loci: s, info: this.createHighlightInfo(s) });
    } else this.info.next({});
  }, t.prototype.addHighlightLocis = function(e, r) {
    var n, i = this;
    r === void 0 && (r = !0), r && (this.handleHighlightLocis.forEach(function(a) {
      var o;
      (o = i.plugin.canvas3d) === null || o === void 0 || o.mark(a, _t.RemoveHighlight);
    }), this.handleHighlightLocis = []), e.forEach(function(a) {
      var o;
      (o = i.plugin.canvas3d) === null || o === void 0 || o.mark(a, _t.Highlight);
    }), (n = this.handleHighlightLocis).push.apply(n, e);
  }, t.prototype.createHighlightInfo = function(e) {
    if (e.loci.kind === "element-loci") {
      var r = "";
      if (Array.from(this.plugin.cells.entries()).some(function(p) {
        var v = p[0], g = p[1];
        return !(r || !on(g) || Pu(on(g)) !== Pu(e.loci.structure)) && (r = v, !0);
      }), !r) return;
      var n, i = this.plugin.cells.get(r), a = "";
      if (Object.entries(Bn).forEach(function(p) {
        var v = p[0];
        p[1].includes(sL[e.repr.label]) && (n = v);
      }), n && i.theme.color && i.theme.color[n]) {
        var o = i.theme.color[n], s = oa(e.loci);
        o.forEach(function(p) {
          var v = new Set(p.elementIds);
          s.filter(function(g) {
            return !v.has(g);
          }).length === 0 && (a = p.name);
        });
      }
      return h = O({ type: Lm.Structure, ref: r, colorThemeName: a }, ooe(e.loci, this.plugin.managers.selection.structure.granularity));
    }
    if (e.loci.kind === "data-loci" && e.loci.tag === "interactions") {
      var u = "", c = "", l = e.loci.elements[0], d = l.unitA, f = l.unitB;
      Array.from(this.plugin.cells.entries()).some(function(p) {
        var v = p[0], g = p[1];
        if (u && c) return !0;
        if (g.model.structure) {
          var y = Pu(g.model.structure);
          y === d.model.id && (u = v), y === f.model.id && (c = v);
        }
        return !1;
      });
      var h = O({ type: Lm.Interaction }, soe(e.loci));
      return Object.assign(h.infoA, { ref: u }), Object.assign(h.infoB, { ref: c }), h;
    }
    if (e.loci.kind === "group-loci") return {};
    if (e.loci.kind === "bond-loci") {
      var m = "";
      return Array.from(this.plugin.cells.entries()).some(function(p) {
        var v = p[0], g = p[1];
        return !(m || !g.model.structure || Pu(g.model.structure) !== Pu(e.loci.structure)) && (m = v, !0);
      }), h = { infoA: Ac(e.loci.bonds[0].aUnit, e.loci.bonds[0].aUnit.elements[e.loci.bonds[0].aIndex]), infoB: Ac(e.loci.bonds[0].bUnit, e.loci.bonds[0].bUnit.elements[e.loci.bonds[0].bIndex]), ref: m, type: Lm.Bond };
    }
  }, t.prototype.clear = function() {
    this.hoverLoci = void 0;
  }, t;
}(), Jfe = [["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"]], MP = function() {
  function t(e) {
    this.plugin = e, this.ev = wo.create(), this._params = void 0, this.behaviors = { values: this.ev.behavior({ transparent: this.params.transparent.defaultValue, axes: { name: "off", params: {} }, resolution: this.params.resolution.defaultValue }), cropParams: this.ev.behavior({ auto: !1, relativePadding: 0.1 }), relativeCrop: this.ev.behavior({ x: 0, y: 0, width: 1, height: 1 }) }, this.events = { previewed: this.ev() }, this._previewPass = void 0, this._imagePass = void 0, this.canvas = document.createElement("canvas"), this.previewCanvas = document.createElement("canvas"), this.previewData = { image: { data: new Uint8ClampedArray(1), width: 1, height: 0 }, background: qe(0), transparent: !1 };
  }
  return t.prototype.createParams = function() {
    var e = Math.min(this.plugin.canvas3d ? this.plugin.canvas3d.webgl.maxRenderbufferSize : 4096, 4096);
    return { resolution: z.MappedStatic("ultra-hd", { viewport: z.Group({}), hd: z.Group({}), "full-hd": z.Group({}), "ultra-hd": z.Group({}), custom: z.Group({ width: z.Numeric(1920, { min: 128, max: e, step: 1 }), height: z.Numeric(1080, { min: 128, max: e, step: 1 }) }, { isFlat: !0 }) }, { options: Jfe }), transparent: z.Boolean(!1), axes: Wy.axes };
  }, Object.defineProperty(t.prototype, "params", { get: function() {
    return this._params ? this._params : this._params = this.createParams();
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "values", { get: function() {
    return this.behaviors.values.value;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cropParams", { get: function() {
    return this.behaviors.cropParams.value;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "relativeCrop", { get: function() {
    return this.behaviors.relativeCrop.value;
  }, enumerable: !1, configurable: !0 }), t.prototype.getCanvasSize = function() {
    var e, r;
    return { width: ((e = this.plugin.canvas3d) === null || e === void 0 ? void 0 : e.webgl.gl.drawingBufferWidth) || 0, height: ((r = this.plugin.canvas3d) === null || r === void 0 ? void 0 : r.webgl.gl.drawingBufferHeight) || 0 };
  }, t.prototype.getSize = function() {
    var e = this.values;
    switch (e.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: e.resolution.params.width, height: e.resolution.params.height };
    }
  }, t.prototype.createPass = function(e) {
    var r = this.plugin.canvas3d, n = r.webgl.extensions, i = n.colorBufferFloat, a = n.textureFloat, o = r.props.postprocessing.occlusion;
    return r.getImagePass({ transparentBackground: this.values.transparent, cameraHelper: { axes: this.values.axes }, multiSample: { mode: e ? "on" : "off", sampleLevel: i && a ? 4 : 2 }, postprocessing: O(O({}, r.props.postprocessing), { occlusion: o.name === "on" ? { name: "on", params: O(O({}, o.params), { samples: 128, resolutionScale: 1 }) } : o }), marking: O({}, r.props.marking) });
  }, Object.defineProperty(t.prototype, "previewPass", { get: function() {
    return this._previewPass || (this._previewPass = this.createPass(!1));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imagePass", { get: function() {
    if (this._imagePass) {
      var e = this.plugin.canvas3d, r = e.props.postprocessing.occlusion;
      return this._imagePass.setProps({ cameraHelper: { axes: this.values.axes }, transparentBackground: this.values.transparent, postprocessing: O(O({}, e.props.postprocessing), { occlusion: r.name === "on" ? { name: "on", params: O(O({}, r.params), { samples: 128, resolutionScale: 1 }) } : r }), marking: O({}, e.props.marking) }), this._imagePass;
    }
    return this._imagePass = this.createPass(!0);
  }, enumerable: !1, configurable: !0 }), t.prototype.resetCrop = function() {
    this.behaviors.relativeCrop.next({ x: 0, y: 0, width: 1, height: 1 });
  }, t.prototype.toggleAutocrop = function() {
    this.cropParams.auto ? (this.behaviors.cropParams.next(O(O({}, this.cropParams), { auto: !1 })), this.resetCrop()) : this.behaviors.cropParams.next(O(O({}, this.cropParams), { auto: !0 }));
  }, Object.defineProperty(t.prototype, "isFullFrame", { get: function() {
    var e = this.relativeCrop;
    return jn(e.x, 0, 1e-5) && jn(e.y, 0, 1e-5) && jn(e.width, 1, 1e-5) && jn(e.height, 1, 1e-5);
  }, enumerable: !1, configurable: !0 }), t.prototype.autocrop = function(e) {
    e === void 0 && (e = this.cropParams.relativePadding);
    for (var r = this.previewData.image, n = r.data, i = r.width, a = r.height, o = this.previewData.transparent, s = o ? this.previewData.background : 4278190080 | this.previewData.background, u = i, c = 0, l = a, d = 0, f = 0; f < a; f++) for (var h = f * i, m = 0; m < i; m++) {
      var p = 4 * (h + m);
      if (o) {
        if (n[p + 3] === 0) continue;
      } else if ((n[p] << 16 | n[p + 1] << 8 | n[p + 2] | n[p + 3] << 24) === s) continue;
      m < u && (u = m), m > c && (c = m), f < l && (l = f), f > d && (d = f);
    }
    if (u > c) {
      var v = u;
      u = c, c = v;
    }
    l > d && (v = l, l = d, d = v);
    var g = c - u + 1, y = d - l + 1;
    u -= e * g, c += e * g, l -= e * y, d += e * y;
    var b = { 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(b);
  }, t.prototype.getPreview = function(e) {
    e === void 0 && (e = 320);
    var r = this.getSize(), n = r.width, i = r.height;
    if (!(n <= 0 || i <= 0)) {
      var a = n / i, o = 0, s = 0;
      a > 1 ? (o = e, s = Math.round(e / a)) : (s = e, o = Math.round(e * 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 };
    }
  }, t.prototype.getSizeAndViewport = function() {
    var e = this.getSize(), r = e.width, n = e.height, i = this.relativeCrop, a = { x: Math.floor(i.x * r), y: Math.floor(i.y * n), width: Math.ceil(i.width * r), height: Math.ceil(i.height * n) };
    return a.width + a.x > r && (a.width = r - a.x), a.height + a.y > n && (a.height = n - a.y), { width: r, height: n, viewport: a };
  }, t.prototype.draw = function() {
    return _e(this, 0, void 0, function() {
      var e, r, n, i, a, o, s;
      return ye(this, function(u) {
        if (e = this.getSizeAndViewport(), r = e.width, n = e.height, i = e.viewport, r <= 0 || n <= 0) return [2];
        if (a = this.imagePass.getImageData(r, n, 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];
      });
    });
  }, t.prototype.getImageDataUri = function() {
    return _e(this, 0, void 0, function() {
      return ye(this, function(e) {
        switch (e.label) {
          case 0:
            return [4, this.draw()];
          case 1:
            return e.sent(), [2, this.canvas.toDataURL("png")];
        }
      });
    });
  }, t.prototype.copyToClipboard = function() {
    return _e(this, 0, void 0, function() {
      var e, r, n;
      return ye(this, function(i) {
        switch (i.label) {
          case 0:
            return (e = navigator.clipboard) != null && e.write ? [4, this.draw()] : [2];
          case 1:
            return i.sent(), [4, XT(this.canvas, "png")];
          case 2:
            return r = i.sent(), n = new ClipboardItem({ "image/png": r }), [4, e.write([n])];
          case 3:
            return i.sent(), [2];
        }
      });
    });
  }, t.prototype.getAxesScale = function() {
    var e = this.getSize(), r = e.width * e.height;
    switch (!0) {
      case r <= 921600:
        return 0.22;
      case r <= 2073600:
        return 0.33;
      case r <= 8294400:
        return 0.5;
      default:
        return 0.65;
    }
  }, t.prototype.download = function(e) {
    return _e(this, 0, void 0, function() {
      return ye(this, function(r) {
        switch (r.label) {
          case 0:
            return this.behaviors.values.next({ transparent: this.values.transparent, axes: O(O({}, this.values.axes), { params: O(O(O({}, this.params.axes.defaultValue), this.values.axes.params), { scale: this.getAxesScale() }) }), resolution: this.values.resolution }), [4, this.draw()];
          case 1:
            return r.sent(), this.behaviors.cropParams.next(O(O({}, this.cropParams), { auto: !1 })), this.resetCrop(), [4, XT(this.canvas, "png")];
          case 2:
            return CG(r.sent(), e), this.behaviors.values.next({ transparent: this.values.transparent, axes: O(O({}, this.values.axes), { params: O(O(O({}, this.params.axes.defaultValue), this.values.axes.params), { scale: 0.11 }) }), resolution: this.values.resolution }), [2];
        }
      });
    });
  }, t;
}(), $fe = z.getDefaultValues(ey), AG = function() {
  function t() {
    this.mode = l0.Drug, this.cells = /* @__PURE__ */ new Map(), this.managers = { camera: new pP(this), representation: new _P(this), cell: new xP(this), trajectory: new SP(this), snapshot: new AP(this), selection: new wP(this), events: new DP(this), highlight: new TP(this), editor: new IP(this), screenshot: new MP(this) };
  }
  var e;
  return t.prototype.createCanvas = function(r, n) {
    var i = document.createElement("canvas");
    r.appendChild(i), KT(i, r), this.layout = { root: r, canvas: i }, this.canvas3d = w7.create(A7.fromCanvas(i), z.merge(ey, z.getDefaultValues(ey), O({ 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: O(O({}, $fe.renderer), { backgroundColor: qe(15922682) }), postprocessing: { occlusion: { name: "off", params: {} }, outline: { name: "off", params: {} }, antialiasing: { name: "fxaa", params: { edgeThresholdMin: 0.0312, edgeThresholdMax: 0.063, iterations: 12, subpixelQuality: 0.3 } }, background: { variant: { name: "off", params: {} } }, shadow: { name: "off", params: {} } }, helper: { handle: { handle: { name: "off" } } }, transparentBackground: !1 }, n))), this.canvas3d.animate(), this.managers.representation.createContext(), this.managers.events.subscribe(), this.managers.editor.start();
  }, t.prototype.focus = function(r, n) {
    return _e(this, 0, void 0, function() {
      var i, a, o, s, u = this;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            return i = [], a = new Set(r.map(function(l) {
              var d, f, h;
              return i.push.apply(i, (h = (f = (d = u.cells.get(l.ref)) === null || d === void 0 ? void 0 : d.dependency) === null || f === void 0 ? void 0 : f.by) !== null && h !== void 0 ? h : []), 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(r, n)];
          case 1:
            return c.sent(), [2, s];
        }
      });
    });
  }, t.prototype.show = function(r, n) {
    var i;
    return _e(this, 0, void 0, function() {
      var a, o, s, u, c, l = this;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            a = function(f) {
              var h, m, p, v, g, y, b, S;
              return ye(this, function(_) {
                switch (_.label) {
                  case 0:
                    return o.managers.cell.idleCellSet.delete(f.ref), h = o.managers.cell.get(f.ref), [4, o.managers.cell.getStructure(f.ref)];
                  case 1:
                    if (_.sent(), !h || !f.representationType && Array.from(h.representations.values()).some(function(x) {
                      return !x.isHidden;
                    })) return [2, "continue"];
                    m = 0, p = Array.from(h.representations), _.label = 2;
                  case 2:
                    return m < p.length ? (v = p[m], g = v[0], (y = v[1]).state ? (!y.isHidden || f.representationType && f.representationType !== g || ((i = o.canvas3d) === null || i === void 0 || i.add(y.state), h.representations.set(g, O(O({}, y), { isHidden: !1 }))), [3, 5]) : [3, 3]) : [3, 6];
                  case 3:
                    return y.cache ? [4, Dd.managers.cell.recoveryReprCache(h, O(O({}, y.cache), { isHidden: !1 }))] : [3, 5];
                  case 4:
                    _.sent(), _.label = 5;
                  case 5:
                    return m++, [3, 2];
                  case 6:
                    return h.dependency.by.length && (b = [], S = h.dependency.by.filter(function(x) {
                      var C = l.cells.has(x);
                      if (C) {
                        if (l.cells.get(x).dependency.on.some(function(A) {
                          var w, I;
                          return Array.from((I = (w = l.cells.get(A.ref)) === null || w === void 0 ? void 0 : w.representations.values()) !== null && I !== void 0 ? I : []).filter(function(P) {
                            return P.isHidden !== !0;
                          }).length === 0;
                        })) return !1;
                      } else b.push(x);
                      return C;
                    }), o.show(S.map(function(x) {
                      return { ref: x };
                    }), !0), b.length && o.managers.cell.update(f.ref, { model: {}, dependency: { by: S } })), [2];
                }
              });
            }, o = this, s = 0, u = r, d.label = 1;
          case 1:
            return s < u.length ? (c = u[s], [5, a(c)]) : [3, 4];
          case 2:
            d.sent(), d.label = 3;
          case 3:
            return s++, [3, 1];
          case 4:
            return n || this.managers.cell.traverse(function(f, h) {
              h.type === Pe.IntraInteractions && l.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
            }), this.managers.snapshot.event.changed.next({ from: "show" }), [2];
        }
      });
    });
  }, t.prototype.hide = function(r, n) {
    var i = this;
    r.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: ms(on(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, O(O(O({}, c), { isHidden: !0 }), c.cache ? { cache: O(O({}, 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(Pe.IntraInteractions)) && l;
        });
        i.hide(u.map(function(c) {
          return { ref: c };
        }), !0), s.length && i.managers.cell.update(a.ref, { model: {}, dependency: { by: u } });
      }
    }), n || this.managers.cell.traverse(function(a, o) {
      o.type === Pe.IntraInteractions && i.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
    }), this.managers.snapshot.event.changed.next({ from: "hide" });
  }, t.prototype.toggle = function(r) {
    var n = this, i = r.types, a = r.forceAction, o = r.refs, s = Array.from(this.cells).filter(function(l) {
      var d = l[0], f = l[1], h = (!o || o.includes(d)) && i.some(function(m) {
        return f.representations.get(m);
      });
      return !!h && !!f.dependency.on.every(function(m) {
        var p = n.cells.get(m.ref);
        return !!p && !Array.from(p.representations.values()).every(function(v) {
          return v.isHidden === !0;
        });
      });
    });
    if (s.length) {
      var u = a ?? s.some(function(l) {
        l[0];
        var d = l[1];
        return i.some(function(f) {
          var h;
          return (h = d.representations.get(f)) === null || h === void 0 ? void 0 : h.isHidden;
        });
      }) ? "show" : "hide", c = oL(s.map(function(l) {
        var d = l[0], f = l[1];
        return Array.from(f.representations).filter(function(h) {
          var m = h[0];
          return i.includes(m);
        }).map(function(h) {
          return { representationType: h[0], ref: d };
        });
      }));
      this[u](c);
    }
  }, t.prototype.refresh = function(r) {
    var n, i, a, o, s;
    this.canvas3d && (!((i = (n = this.layout) === null || n === void 0 ? void 0 : n.root.children[0]) === null || i === void 0) && i.clientWidth) && (r != null && r.fixCamera && (s = this.canvas3d.camera.getSnapshot()), KT(this.layout.canvas, this.layout.root), (a = this.canvas3d) === null || a === void 0 || a.handleResize(), r != null && r.fixCamera ? (o = this.canvas3d) === null || o === void 0 || o.camera.setState(s) : this.managers.camera.focus());
  }, t.prototype.clear = function() {
    var r;
    this.managers.selection.clear(), this.managers.highlight.clear(), this.managers.editor.changeEditorMode(Ys.None), this.cells = /* @__PURE__ */ new Map(), (r = this.canvas3d) === null || r === void 0 || r.clear();
  }, t.prototype.dispose = function() {
    var r;
    (r = this.canvas3d) === null || r === void 0 || r.dispose(), this.layout = void 0, this.canvas3d = void 0, this.cells = /* @__PURE__ */ new Map(), this.managers = { camera: new pP(this), representation: new _P(this), cell: new xP(this), trajectory: new SP(this), snapshot: new AP(this), selection: new wP(this), events: new DP(this), highlight: new TP(this), editor: new IP(this), screenshot: new MP(this) };
  }, e = t, t.Utils = { sliceCellItems: function(r, n) {
    return qse(Dd, r, n);
  }, queryCellItems: function(r) {
    return IL(Dd, r);
  }, exportToPdb: function(r) {
    return _e(void 0, 0, void 0, function() {
      return ye(e, function(n) {
        switch (n.label) {
          case 0:
            return [4, Dd.managers.cell.getStructure(r.ref)];
          case 1:
            return [2, Fx(n.sent(), r.elementIds, !1)];
        }
      });
    });
  }, getBox: function(r) {
    return _e(void 0, 0, void 0, function() {
      var n, i;
      return ye(e, function(a) {
        switch (a.label) {
          case 0:
            return [4, Dd.managers.cell.getStructure(r.ref)];
          case 1:
            return n = a.sent(), [2, rfe(n, (i = r.elementIds) !== null && i !== void 0 ? i : [])];
        }
      });
    });
  }, splitMolecularContent: function(r, n) {
    return Joe(r, n);
  }, checkMolecularContentVerify: function(r, n) {
    return tse(r, n);
  }, getMergedContent: function(r) {
    return Kse(Dd, r);
  }, traverseAtoms: function(r, n) {
    return _e(void 0, 0, void 0, function() {
      var i;
      return ye(e, function(a) {
        switch (a.label) {
          case 0:
            return [4, Dd.managers.cell.getStructure(r)];
          case 1:
            return (i = a.sent()) ? (EL(i, n), [2]) : [2];
        }
      });
    });
  } }, t;
}(), Dd = new AG();
function Up() {
  return Up = Object.assign ? Object.assign.bind() : function(t) {
    for (var e = 1; e < arguments.length; e++) {
      var r = arguments[e];
      for (var n in r) ({}).hasOwnProperty.call(r, n) && (t[n] = r[n]);
    }
    return t;
  }, Up.apply(null, arguments);
}
var wG = {
  // minimum relative difference between two compared values,
  // used by all comparison functions
  relTol: 1e-12,
  // minimum absolute difference between two compared values,
  // used by all comparison functions
  absTol: 1e-15,
  // type of default matrix output. Choose 'matrix' (default) or 'array'
  matrix: "Matrix",
  // type of default number output. Choose 'number' (default) 'BigNumber', 'bigint', or 'Fraction'
  number: "number",
  // type of fallback used for config { number: 'bigint' } when a value cannot be represented
  // in the configured numeric type. Choose 'number' (default) or 'BigNumber'.
  numberFallback: "number",
  // number of significant digits in BigNumbers
  precision: 64,
  // predictable output type of functions. When true, output type depends only
  // on the input types. When false (default), output type can vary depending
  // on input values. For example `math.sqrt(-4)` returns `complex('2i')` when
  // predictable is false, and returns `NaN` when true.
  predictable: !1,
  // random seed for seeded pseudo random number generation
  // null = randomly seed
  randomSeed: null
};
function Gn(t) {
  return typeof t == "number";
}
function mi(t) {
  return !t || typeof t != "object" || typeof t.constructor != "function" ? !1 : t.isBigNumber === !0 && typeof t.constructor.prototype == "object" && t.constructor.prototype.isBigNumber === !0 || typeof t.constructor.isDecimal == "function" && t.constructor.isDecimal(t) === !0;
}
function e0e(t) {
  return typeof t == "bigint";
}
function Qx(t) {
  return t && typeof t == "object" && Object.getPrototypeOf(t).isComplex === !0 || !1;
}
function Jx(t) {
  return t && typeof t == "object" && Object.getPrototypeOf(t).isFraction === !0 || !1;
}
function DG(t) {
  return t && t.constructor.prototype.isUnit === !0 || !1;
}
function Eu(t) {
  return typeof t == "string";
}
var Mn = Array.isArray;
function Xn(t) {
  return t && t.constructor.prototype.isMatrix === !0 || !1;
}
function py(t) {
  return Array.isArray(t) || Xn(t);
}
function EG(t) {
  return t && t.isDenseMatrix && t.constructor.prototype.isMatrix === !0 || !1;
}
function IG(t) {
  return t && t.isSparseMatrix && t.constructor.prototype.isMatrix === !0 || !1;
}
function TG(t) {
  return t && t.constructor.prototype.isRange === !0 || !1;
}
function $x(t) {
  return t && t.constructor.prototype.isIndex === !0 || !1;
}
function t0e(t) {
  return typeof t == "boolean";
}
function r0e(t) {
  return t && t.constructor.prototype.isResultSet === !0 || !1;
}
function n0e(t) {
  return t && t.constructor.prototype.isHelp === !0 || !1;
}
function i0e(t) {
  return typeof t == "function";
}
function a0e(t) {
  return t instanceof Date;
}
function o0e(t) {
  return t instanceof RegExp;
}
function eS(t) {
  return !!(t && typeof t == "object" && t.constructor === Object && !Qx(t) && !Jx(t));
}
function s0e(t) {
  return t === null;
}
function u0e(t) {
  return t === void 0;
}
function c0e(t) {
  return t && t.isAccessorNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function l0e(t) {
  return t && t.isArrayNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function d0e(t) {
  return t && t.isAssignmentNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function f0e(t) {
  return t && t.isBlockNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function p0e(t) {
  return t && t.isConditionalNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function h0e(t) {
  return t && t.isConstantNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function m0e(t) {
  return t && t.isFunctionAssignmentNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function g0e(t) {
  return t && t.isFunctionNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function v0e(t) {
  return t && t.isIndexNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function y0e(t) {
  return t && t.isNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function b0e(t) {
  return t && t.isObjectNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function _0e(t) {
  return t && t.isOperatorNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function x0e(t) {
  return t && t.isParenthesisNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function S0e(t) {
  return t && t.isRangeNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function C0e(t) {
  return t && t.isRelationalNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function A0e(t) {
  return t && t.isSymbolNode === !0 && t.constructor.prototype.isNode === !0 || !1;
}
function w0e(t) {
  return t && t.constructor.prototype.isChain === !0 || !1;
}
function xl(t) {
  var e = typeof t;
  return e === "object" ? t === null ? "null" : mi(t) ? "BigNumber" : t.constructor && t.constructor.name ? t.constructor.name : "Object" : e;
}
function an(t) {
  var e = typeof t;
  if (e === "number" || e === "bigint" || e === "string" || e === "boolean" || t === null || t === void 0)
    return t;
  if (typeof t.clone == "function")
    return t.clone();
  if (Array.isArray(t))
    return t.map(function(r) {
      return an(r);
    });
  if (t instanceof Date) return new Date(t.valueOf());
  if (mi(t)) return t;
  if (eS(t))
    return D0e(t, an);
  throw new TypeError("Cannot clone: unknown type of value (value: ".concat(t, ")"));
}
function D0e(t, e) {
  var r = {};
  for (var n in t)
    s2(t, n) && (r[n] = e(t[n]));
  return r;
}
function MG(t, e) {
  for (var r in e)
    s2(e, r) && (t[r] = e[r]);
  return t;
}
function lf(t, e) {
  var r, n, i;
  if (Array.isArray(t)) {
    if (!Array.isArray(e) || t.length !== e.length)
      return !1;
    for (n = 0, i = t.length; n < i; n++)
      if (!lf(t[n], e[n]))
        return !1;
    return !0;
  } else {
    if (typeof t == "function")
      return t === e;
    if (t instanceof Object) {
      if (Array.isArray(e) || !(e instanceof Object))
        return !1;
      for (r in t)
        if (!(r in e) || !lf(t[r], e[r]))
          return !1;
      for (r in e)
        if (!(r in t))
          return !1;
      return !0;
    } else
      return t === e;
  }
}
function s2(t, e) {
  return t && Object.hasOwnProperty.call(t, e);
}
function E0e(t, e) {
  for (var r = {}, n = 0; n < e.length; n++) {
    var i = e[n], a = t[i];
    a !== void 0 && (r[i] = a);
  }
  return r;
}
var I0e = ["Matrix", "Array"], T0e = ["number", "BigNumber", "Fraction"], da = function(e) {
  if (e)
    throw new Error(`The global config is readonly. 
Please create a mathjs instance if you want to change the default configuration. 
Example:

  import { create, all } from 'mathjs';
  const mathjs = create(all);
  mathjs.config({ number: 'BigNumber' });
`);
  return Object.freeze(wG);
};
Up(da, wG, {
  MATRIX_OPTIONS: I0e,
  NUMBER_OPTIONS: T0e
});
function PP() {
  return !0;
}
function Us() {
  return !1;
}
function X1() {
}
const BP = "Argument is not a typed-function.";
function PG() {
  function t(ne) {
    return typeof ne == "object" && ne !== null && ne.constructor === Object;
  }
  const e = [{
    name: "number",
    test: function(ne) {
      return typeof ne == "number";
    }
  }, {
    name: "string",
    test: function(ne) {
      return typeof ne == "string";
    }
  }, {
    name: "boolean",
    test: function(ne) {
      return typeof ne == "boolean";
    }
  }, {
    name: "Function",
    test: function(ne) {
      return typeof ne == "function";
    }
  }, {
    name: "Array",
    test: Array.isArray
  }, {
    name: "Date",
    test: function(ne) {
      return ne instanceof Date;
    }
  }, {
    name: "RegExp",
    test: function(ne) {
      return ne instanceof RegExp;
    }
  }, {
    name: "Object",
    test: t
  }, {
    name: "null",
    test: function(ne) {
      return ne === null;
    }
  }, {
    name: "undefined",
    test: function(ne) {
      return ne === void 0;
    }
  }], r = {
    name: "any",
    test: PP,
    isAny: !0
  };
  let n, i, a = 0, o = {
    createCount: 0
  };
  function s(ne) {
    const re = n.get(ne);
    if (re)
      return re;
    let le = 'Unknown type "' + ne + '"';
    const fe = ne.toLowerCase();
    let ge;
    for (ge of i)
      if (ge.toLowerCase() === fe) {
        le += '. Did you mean "' + ge + '" ?';
        break;
      }
    throw new TypeError(le);
  }
  function u(ne) {
    let re = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "any";
    const le = re ? s(re).index : i.length, fe = [];
    for (let me = 0; me < ne.length; ++me) {
      if (!ne[me] || typeof ne[me].name != "string" || typeof ne[me].test != "function")
        throw new TypeError("Object with properties {name: string, test: function} expected");
      const Ae = ne[me].name;
      if (n.has(Ae))
        throw new TypeError('Duplicate type name "' + Ae + '"');
      fe.push(Ae), n.set(Ae, {
        name: Ae,
        test: ne[me].test,
        isAny: ne[me].isAny,
        index: le + me,
        conversionsTo: []
        // Newly added type can't have any conversions to it
      });
    }
    const ge = i.slice(le);
    i = i.slice(0, le).concat(fe).concat(ge);
    for (let me = le + fe.length; me < i.length; ++me)
      n.get(i[me]).index = me;
  }
  function c() {
    n = /* @__PURE__ */ new Map(), i = [], a = 0, u([r], !1);
  }
  c(), u(e);
  function l() {
    let ne;
    for (ne of i)
      n.get(ne).conversionsTo = [];
    a = 0;
  }
  function d(ne) {
    const re = i.filter((le) => {
      const fe = n.get(le);
      return !fe.isAny && fe.test(ne);
    });
    return re.length ? re : ["any"];
  }
  function f(ne) {
    return ne && typeof ne == "function" && "_typedFunctionData" in ne;
  }
  function h(ne, re, le) {
    if (!f(ne))
      throw new TypeError(BP);
    const fe = le && le.exact, ge = Array.isArray(re) ? re.join(",") : re, me = S(ge), Ae = v(me);
    if (!fe || Ae in ne.signatures) {
      const ht = ne._typedFunctionData.signatureMap.get(Ae);
      if (ht)
        return ht;
    }
    const Oe = me.length;
    let Ue;
    if (fe) {
      Ue = [];
      let ht;
      for (ht in ne.signatures)
        Ue.push(ne._typedFunctionData.signatureMap.get(ht));
    } else
      Ue = ne._typedFunctionData.signatures;
    for (let ht = 0; ht < Oe; ++ht) {
      const bt = me[ht], At = [];
      let Ee;
      for (Ee of Ue) {
        const st = A(Ee.params, ht);
        if (!(!st || bt.restParam && !st.restParam)) {
          if (!st.hasAny) {
            const Et = b(st);
            if (bt.types.some((ur) => !Et.has(ur.name)))
              continue;
          }
          At.push(Ee);
        }
      }
      if (Ue = At, Ue.length === 0) break;
    }
    let Ve;
    for (Ve of Ue)
      if (Ve.params.length <= Oe)
        return Ve;
    throw new TypeError("Signature not found (signature: " + (ne.name || "unnamed") + "(" + v(me, ", ") + "))");
  }
  function m(ne, re, le) {
    return h(ne, re, le).implementation;
  }
  function p(ne, re) {
    const le = s(re);
    if (le.test(ne))
      return ne;
    const fe = le.conversionsTo;
    if (fe.length === 0)
      throw new Error("There are no conversions to " + re + " defined.");
    for (let ge = 0; ge < fe.length; ge++)
      if (s(fe[ge].from).test(ne))
        return fe[ge].convert(ne);
    throw new Error("Cannot convert " + ne + " to " + re);
  }
  function v(ne) {
    let re = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ",";
    return ne.map((le) => le.name).join(re);
  }
  function g(ne) {
    const re = ne.indexOf("...") === 0, fe = (re ? ne.length > 3 ? ne.slice(3) : "any" : ne).split("|").map((Oe) => s(Oe.trim()));
    let ge = !1, me = re ? "..." : "";
    return {
      types: fe.map(function(Oe) {
        return ge = Oe.isAny || ge, me += Oe.name + "|", {
          name: Oe.name,
          typeIndex: Oe.index,
          test: Oe.test,
          isAny: Oe.isAny,
          conversion: null,
          conversionIndex: -1
        };
      }),
      name: me.slice(0, -1),
      // remove trailing '|' from above
      hasAny: ge,
      hasConversion: !1,
      restParam: re
    };
  }
  function y(ne) {
    const re = ne.types.map((Ae) => Ae.name), le = L(re);
    let fe = ne.hasAny, ge = ne.name;
    const me = le.map(function(Ae) {
      const Oe = s(Ae.from);
      return fe = Oe.isAny || fe, ge += "|" + Ae.from, {
        name: Ae.from,
        typeIndex: Oe.index,
        test: Oe.test,
        isAny: Oe.isAny,
        conversion: Ae,
        conversionIndex: Ae.index
      };
    });
    return {
      types: ne.types.concat(me),
      name: ge,
      hasAny: fe,
      hasConversion: me.length > 0,
      restParam: ne.restParam
    };
  }
  function b(ne) {
    return ne.typeSet || (ne.typeSet = /* @__PURE__ */ new Set(), ne.types.forEach((re) => ne.typeSet.add(re.name))), ne.typeSet;
  }
  function S(ne) {
    const re = [];
    if (typeof ne != "string")
      throw new TypeError("Signatures must be strings");
    const le = ne.trim();
    if (le === "")
      return re;
    const fe = le.split(",");
    for (let ge = 0; ge < fe.length; ++ge) {
      const me = g(fe[ge].trim());
      if (me.restParam && ge !== fe.length - 1)
        throw new SyntaxError('Unexpected rest parameter "' + fe[ge] + '": only allowed for the last parameter');
      if (me.types.length === 0)
        return null;
      re.push(me);
    }
    return re;
  }
  function _(ne) {
    const re = ee(ne);
    return re ? re.restParam : !1;
  }
  function x(ne) {
    if (!ne || ne.types.length === 0)
      return PP;
    if (ne.types.length === 1)
      return s(ne.types[0].name).test;
    if (ne.types.length === 2) {
      const re = s(ne.types[0].name).test, le = s(ne.types[1].name).test;
      return function(ge) {
        return re(ge) || le(ge);
      };
    } else {
      const re = ne.types.map(function(le) {
        return s(le.name).test;
      });
      return function(fe) {
        for (let ge = 0; ge < re.length; ge++)
          if (re[ge](fe))
            return !0;
        return !1;
      };
    }
  }
  function C(ne) {
    let re, le, fe;
    if (_(ne)) {
      re = j(ne).map(x);
      const ge = re.length, me = x(ee(ne)), Ae = function(Oe) {
        for (let Ue = ge; Ue < Oe.length; Ue++)
          if (!me(Oe[Ue]))
            return !1;
        return !0;
      };
      return function(Ue) {
        for (let Ve = 0; Ve < re.length; Ve++)
          if (!re[Ve](Ue[Ve]))
            return !1;
        return Ae(Ue) && Ue.length >= ge + 1;
      };
    } else
      return ne.length === 0 ? function(me) {
        return me.length === 0;
      } : ne.length === 1 ? (le = x(ne[0]), function(me) {
        return le(me[0]) && me.length === 1;
      }) : ne.length === 2 ? (le = x(ne[0]), fe = x(ne[1]), function(me) {
        return le(me[0]) && fe(me[1]) && me.length === 2;
      }) : (re = ne.map(x), function(me) {
        for (let Ae = 0; Ae < re.length; Ae++)
          if (!re[Ae](me[Ae]))
            return !1;
        return me.length === re.length;
      });
  }
  function A(ne, re) {
    return re < ne.length ? ne[re] : _(ne) ? ee(ne) : null;
  }
  function w(ne, re) {
    const le = A(ne, re);
    return le ? b(le) : /* @__PURE__ */ new Set();
  }
  function I(ne) {
    return ne.conversion === null || ne.conversion === void 0;
  }
  function P(ne, re) {
    const le = /* @__PURE__ */ new Set();
    return ne.forEach((fe) => {
      const ge = w(fe.params, re);
      let me;
      for (me of ge)
        le.add(me);
    }), le.has("any") ? ["any"] : Array.from(le);
  }
  function M(ne, re, le) {
    let fe, ge;
    const me = ne || "unnamed";
    let Ae = le, Oe;
    for (Oe = 0; Oe < re.length; Oe++) {
      const bt = [];
      if (Ae.forEach((At) => {
        const Ee = A(At.params, Oe), st = x(Ee);
        (Oe < At.params.length || _(At.params)) && st(re[Oe]) && bt.push(At);
      }), bt.length === 0) {
        if (ge = P(Ae, Oe), ge.length > 0) {
          const At = d(re[Oe]);
          return fe = new TypeError("Unexpected type of argument in function " + me + " (expected: " + ge.join(" or ") + ", actual: " + At.join(" | ") + ", index: " + Oe + ")"), fe.data = {
            category: "wrongType",
            fn: me,
            index: Oe,
            actual: At,
            expected: ge
          }, fe;
        }
      } else
        Ae = bt;
    }
    const Ue = Ae.map(function(bt) {
      return _(bt.params) ? 1 / 0 : bt.params.length;
    });
    if (re.length < Math.min.apply(null, Ue))
      return ge = P(Ae, Oe), fe = new TypeError("Too few arguments in function " + me + " (expected: " + ge.join(" or ") + ", index: " + re.length + ")"), fe.data = {
        category: "tooFewArgs",
        fn: me,
        index: re.length,
        expected: ge
      }, fe;
    const Ve = Math.max.apply(null, Ue);
    if (re.length > Ve)
      return fe = new TypeError("Too many arguments in function " + me + " (expected: " + Ve + ", actual: " + re.length + ")"), fe.data = {
        category: "tooManyArgs",
        fn: me,
        index: re.length,
        expectedLength: Ve
      }, fe;
    const ht = [];
    for (let bt = 0; bt < re.length; ++bt)
      ht.push(d(re[bt]).join("|"));
    return fe = new TypeError('Arguments of type "' + ht.join(", ") + '" do not match any of the defined signatures of function ' + me + "."), fe.data = {
      category: "mismatch",
      actual: ht
    }, fe;
  }
  function T(ne) {
    let re = i.length + 1;
    for (let le = 0; le < ne.types.length; le++)
      I(ne.types[le]) && (re = Math.min(re, ne.types[le].typeIndex));
    return re;
  }
  function F(ne) {
    let re = a + 1;
    for (let le = 0; le < ne.types.length; le++)
      I(ne.types[le]) || (re = Math.min(re, ne.types[le].conversionIndex));
    return re;
  }
  function N(ne, re) {
    if (ne.hasAny) {
      if (!re.hasAny)
        return 1;
    } else if (re.hasAny)
      return -1;
    if (ne.restParam) {
      if (!re.restParam)
        return 1;
    } else if (re.restParam)
      return -1;
    if (ne.hasConversion) {
      if (!re.hasConversion)
        return 1;
    } else if (re.hasConversion)
      return -1;
    const le = T(ne) - T(re);
    if (le < 0)
      return -1;
    if (le > 0)
      return 1;
    const fe = F(ne) - F(re);
    return fe < 0 ? -1 : fe > 0 ? 1 : 0;
  }
  function R(ne, re) {
    const le = ne.params, fe = re.params, ge = ee(le), me = ee(fe), Ae = _(le), Oe = _(fe);
    if (Ae && ge.hasAny) {
      if (!Oe || !me.hasAny)
        return 1;
    } else if (Oe && me.hasAny)
      return -1;
    let Ue = 0, Ve = 0, ht;
    for (ht of le)
      ht.hasAny && ++Ue, ht.hasConversion && ++Ve;
    let bt = 0, At = 0;
    for (ht of fe)
      ht.hasAny && ++bt, ht.hasConversion && ++At;
    if (Ue !== bt)
      return Ue - bt;
    if (Ae && ge.hasConversion) {
      if (!Oe || !me.hasConversion)
        return 1;
    } else if (Oe && me.hasConversion)
      return -1;
    if (Ve !== At)
      return Ve - At;
    if (Ae) {
      if (!Oe)
        return 1;
    } else if (Oe)
      return -1;
    const Ee = (le.length - fe.length) * (Ae ? -1 : 1);
    if (Ee !== 0)
      return Ee;
    const st = [];
    let Et = 0;
    for (let ir = 0; ir < le.length; ++ir) {
      const Nr = N(le[ir], fe[ir]);
      st.push(Nr), Et += Nr;
    }
    if (Et !== 0)
      return Et;
    let ur;
    for (ur of st)
      if (ur !== 0)
        return ur;
    return 0;
  }
  function L(ne) {
    if (ne.length === 0)
      return [];
    const re = ne.map(s);
    ne.length > 1 && re.sort((ge, me) => ge.index - me.index);
    let le = re[0].conversionsTo;
    if (ne.length === 1)
      return le;
    le = le.concat([]);
    const fe = new Set(ne);
    for (let ge = 1; ge < re.length; ++ge) {
      let me;
      for (me of re[ge].conversionsTo)
        fe.has(me.from) || (le.push(me), fe.add(me.from));
    }
    return le;
  }
  function V(ne, re) {
    let le = re;
    if (ne.some((ge) => ge.hasConversion)) {
      const ge = _(ne), me = ne.map(U);
      le = function() {
        const Oe = [], Ue = ge ? arguments.length - 1 : arguments.length;
        for (let Ve = 0; Ve < Ue; Ve++)
          Oe[Ve] = me[Ve](arguments[Ve]);
        return ge && (Oe[Ue] = arguments[Ue].map(me[Ue])), re.apply(this, Oe);
      };
    }
    let fe = le;
    if (_(ne)) {
      const ge = ne.length - 1;
      fe = function() {
        return le.apply(this, ie(arguments, 0, ge).concat([ie(arguments, ge)]));
      };
    }
    return fe;
  }
  function U(ne) {
    let re, le, fe, ge;
    const me = [], Ae = [];
    switch (ne.types.forEach(function(Oe) {
      Oe.conversion && (me.push(s(Oe.conversion.from).test), Ae.push(Oe.conversion.convert));
    }), Ae.length) {
      case 0:
        return function(Ue) {
          return Ue;
        };
      case 1:
        return re = me[0], fe = Ae[0], function(Ue) {
          return re(Ue) ? fe(Ue) : Ue;
        };
      case 2:
        return re = me[0], le = me[1], fe = Ae[0], ge = Ae[1], function(Ue) {
          return re(Ue) ? fe(Ue) : le(Ue) ? ge(Ue) : Ue;
        };
      default:
        return function(Ue) {
          for (let Ve = 0; Ve < Ae.length; Ve++)
            if (me[Ve](Ue))
              return Ae[Ve](Ue);
          return Ue;
        };
    }
  }
  function H(ne) {
    function re(le, fe, ge) {
      if (fe < le.length) {
        const me = le[fe];
        let Ae = [];
        if (me.restParam) {
          const Oe = me.types.filter(I);
          Oe.length < me.types.length && Ae.push({
            types: Oe,
            name: "..." + Oe.map((Ue) => Ue.name).join("|"),
            hasAny: Oe.some((Ue) => Ue.isAny),
            hasConversion: !1,
            restParam: !0
          }), Ae.push(me);
        } else
          Ae = me.types.map(function(Oe) {
            return {
              types: [Oe],
              name: Oe.name,
              hasAny: Oe.isAny,
              hasConversion: Oe.conversion,
              restParam: !1
            };
          });
        return ce(Ae, function(Oe) {
          return re(le, fe + 1, ge.concat([Oe]));
        });
      } else
        return [ge];
    }
    return re(ne, 0, []);
  }
  function K(ne, re) {
    const le = Math.max(ne.length, re.length);
    for (let Oe = 0; Oe < le; Oe++) {
      const Ue = w(ne, Oe), Ve = w(re, Oe);
      let ht = !1, bt;
      for (bt of Ve)
        if (Ue.has(bt)) {
          ht = !0;
          break;
        }
      if (!ht)
        return !1;
    }
    const fe = ne.length, ge = re.length, me = _(ne), Ae = _(re);
    return me ? Ae ? fe === ge : ge >= fe : Ae ? fe >= ge : fe === ge;
  }
  function X(ne) {
    return ne.map((re) => He(re) ? De(re.referToSelf.callback) : ke(re) ? Ce(re.referTo.references, re.referTo.callback) : re);
  }
  function Y(ne, re, le) {
    const fe = [];
    let ge;
    for (ge of ne) {
      let me = le[ge];
      if (typeof me != "number")
        throw new TypeError('No definition for referenced signature "' + ge + '"');
      if (me = re[me], typeof me != "function")
        return !1;
      fe.push(me);
    }
    return fe;
  }
  function Q(ne, re, le) {
    const fe = X(ne), ge = new Array(fe.length).fill(!1);
    let me = !0;
    for (; me; ) {
      me = !1;
      let Ae = !0;
      for (let Oe = 0; Oe < fe.length; ++Oe) {
        if (ge[Oe]) continue;
        const Ue = fe[Oe];
        if (He(Ue))
          fe[Oe] = Ue.referToSelf.callback(le), fe[Oe].referToSelf = Ue.referToSelf, ge[Oe] = !0, Ae = !1;
        else if (ke(Ue)) {
          const Ve = Y(Ue.referTo.references, fe, re);
          Ve ? (fe[Oe] = Ue.referTo.callback.apply(this, Ve), fe[Oe].referTo = Ue.referTo, ge[Oe] = !0, Ae = !1) : me = !0;
        }
      }
      if (Ae && me)
        throw new SyntaxError("Circular reference detected in resolving typed.referTo");
    }
    return fe;
  }
  function J(ne) {
    const re = /\bthis(\(|\.signatures\b)/;
    Object.keys(ne).forEach((le) => {
      const fe = ne[le];
      if (re.test(fe.toString()))
        throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.");
    });
  }
  function te(ne, re) {
    if (o.createCount++, Object.keys(re).length === 0)
      throw new SyntaxError("No signatures provided");
    o.warnAgainstDeprecatedThis && J(re);
    const le = [], fe = [], ge = {}, me = [];
    let Ae;
    for (Ae in re) {
      if (!Object.prototype.hasOwnProperty.call(re, Ae))
        continue;
      const Gr = S(Ae);
      if (!Gr) continue;
      le.forEach(function(qu) {
        if (K(qu, Gr))
          throw new TypeError('Conflicting signatures "' + v(qu) + '" and "' + v(Gr) + '".');
      }), le.push(Gr);
      const ha = fe.length;
      fe.push(re[Ae]);
      const ph = Gr.map(y);
      let Wl;
      for (Wl of H(ph)) {
        const qu = v(Wl);
        me.push({
          params: Wl,
          name: qu,
          fn: ha
        }), Wl.every((e1) => !e1.hasConversion) && (ge[qu] = ha);
      }
    }
    me.sort(R);
    const Oe = Q(fe, ge, Pc);
    let Ue;
    for (Ue in ge)
      Object.prototype.hasOwnProperty.call(ge, Ue) && (ge[Ue] = Oe[ge[Ue]]);
    const Ve = [], ht = /* @__PURE__ */ new Map();
    for (Ue of me)
      ht.has(Ue.name) || (Ue.fn = Oe[Ue.fn], Ve.push(Ue), ht.set(Ue.name, Ue));
    const bt = Ve[0] && Ve[0].params.length <= 2 && !_(Ve[0].params), At = Ve[1] && Ve[1].params.length <= 2 && !_(Ve[1].params), Ee = Ve[2] && Ve[2].params.length <= 2 && !_(Ve[2].params), st = Ve[3] && Ve[3].params.length <= 2 && !_(Ve[3].params), Et = Ve[4] && Ve[4].params.length <= 2 && !_(Ve[4].params), ur = Ve[5] && Ve[5].params.length <= 2 && !_(Ve[5].params), ir = bt && At && Ee && st && Et && ur;
    for (let Gr = 0; Gr < Ve.length; ++Gr)
      Ve[Gr].test = C(Ve[Gr].params);
    const Nr = bt ? x(Ve[0].params[0]) : Us, pr = At ? x(Ve[1].params[0]) : Us, _n = Ee ? x(Ve[2].params[0]) : Us, Jn = st ? x(Ve[3].params[0]) : Us, Yn = Et ? x(Ve[4].params[0]) : Us, Rn = ur ? x(Ve[5].params[0]) : Us, un = bt ? x(Ve[0].params[1]) : Us, yi = At ? x(Ve[1].params[1]) : Us, cn = Ee ? x(Ve[2].params[1]) : Us, ln = st ? x(Ve[3].params[1]) : Us, Ti = Et ? x(Ve[4].params[1]) : Us, Mi = ur ? x(Ve[5].params[1]) : Us;
    for (let Gr = 0; Gr < Ve.length; ++Gr)
      Ve[Gr].implementation = V(Ve[Gr].params, Ve[Gr].fn);
    const so = bt ? Ve[0].implementation : X1, On = At ? Ve[1].implementation : X1, xn = Ee ? Ve[2].implementation : X1, Wo = st ? Ve[3].implementation : X1, jo = Et ? Ve[4].implementation : X1, Eo = ur ? Ve[5].implementation : X1, Hu = bt ? Ve[0].params.length : -1, uo = At ? Ve[1].params.length : -1, Pi = Ee ? Ve[2].params.length : -1, Mc = st ? Ve[3].params.length : -1, Ul = Et ? Ve[4].params.length : -1, Hl = ur ? Ve[5].params.length : -1, ql = ir ? 6 : 0, Kl = Ve.length, Xl = Ve.map((Gr) => Gr.test), $0 = Ve.map((Gr) => Gr.implementation), Yl = function() {
      for (let ha = ql; ha < Kl; ha++)
        if (Xl[ha](arguments))
          return $0[ha].apply(this, arguments);
      return o.onMismatch(ne, arguments, Ve);
    };
    function Pc(Gr, ha) {
      return arguments.length === Hu && Nr(Gr) && un(ha) ? so.apply(this, arguments) : arguments.length === uo && pr(Gr) && yi(ha) ? On.apply(this, arguments) : arguments.length === Pi && _n(Gr) && cn(ha) ? xn.apply(this, arguments) : arguments.length === Mc && Jn(Gr) && ln(ha) ? Wo.apply(this, arguments) : arguments.length === Ul && Yn(Gr) && Ti(ha) ? jo.apply(this, arguments) : arguments.length === Hl && Rn(Gr) && Mi(ha) ? Eo.apply(this, arguments) : Yl.apply(this, arguments);
    }
    try {
      Object.defineProperty(Pc, "name", {
        value: ne
      });
    } catch {
    }
    return Pc.signatures = ge, Pc._typedFunctionData = {
      signatures: Ve,
      signatureMap: ht
    }, Pc;
  }
  function W(ne, re, le) {
    throw M(ne, re, le);
  }
  function j(ne) {
    return ie(ne, 0, ne.length - 1);
  }
  function ee(ne) {
    return ne[ne.length - 1];
  }
  function ie(ne, re, le) {
    return Array.prototype.slice.call(ne, re, le);
  }
  function ae(ne, re) {
    for (let le = 0; le < ne.length; le++)
      if (re(ne[le]))
        return ne[le];
  }
  function ce(ne, re) {
    return Array.prototype.concat.apply([], ne.map(re));
  }
  function de() {
    const ne = j(arguments).map((le) => v(S(le))), re = ee(arguments);
    if (typeof re != "function")
      throw new TypeError("Callback function expected as last argument");
    return Ce(ne, re);
  }
  function Ce(ne, re) {
    return {
      referTo: {
        references: ne,
        callback: re
      }
    };
  }
  function De(ne) {
    if (typeof ne != "function")
      throw new TypeError("Callback function expected as first argument");
    return {
      referToSelf: {
        callback: ne
      }
    };
  }
  function ke(ne) {
    return ne && typeof ne.referTo == "object" && Array.isArray(ne.referTo.references) && typeof ne.referTo.callback == "function";
  }
  function He(ne) {
    return ne && typeof ne.referToSelf == "object" && typeof ne.referToSelf.callback == "function";
  }
  function We(ne, re) {
    if (!ne)
      return re;
    if (re && re !== ne) {
      const le = new Error("Function names do not match (expected: " + ne + ", actual: " + re + ")");
      throw le.data = {
        actual: re,
        expected: ne
      }, le;
    }
    return ne;
  }
  function Ne(ne) {
    let re;
    for (const le in ne)
      Object.prototype.hasOwnProperty.call(ne, le) && (f(ne[le]) || typeof ne[le].signature == "string") && (re = We(re, ne[le].name));
    return re;
  }
  function Je(ne, re) {
    let le;
    for (le in re)
      if (Object.prototype.hasOwnProperty.call(re, le)) {
        if (le in ne && re[le] !== ne[le]) {
          const fe = new Error('Signature "' + le + '" is defined twice');
          throw fe.data = {
            signature: le,
            sourceFunction: re[le],
            destFunction: ne[le]
          }, fe;
        }
        ne[le] = re[le];
      }
  }
  const Re = o;
  o = function(ne) {
    const re = typeof ne == "string", le = re ? 1 : 0;
    let fe = re ? ne : "";
    const ge = {};
    for (let me = le; me < arguments.length; ++me) {
      const Ae = arguments[me];
      let Oe = {}, Ue;
      if (typeof Ae == "function" ? (Ue = Ae.name, typeof Ae.signature == "string" ? Oe[Ae.signature] = Ae : f(Ae) && (Oe = Ae.signatures)) : t(Ae) && (Oe = Ae, re || (Ue = Ne(Ae))), Object.keys(Oe).length === 0) {
        const Ve = new TypeError("Argument to 'typed' at index " + me + " is not a (typed) function, nor an object with signatures as keys and functions as values.");
        throw Ve.data = {
          index: me,
          argument: Ae
        }, Ve;
      }
      re || (fe = We(fe, Ue)), Je(ge, Oe);
    }
    return te(fe || "", ge);
  }, o.create = PG, o.createCount = Re.createCount, o.onMismatch = W, o.throwMismatchError = W, o.createError = M, o.clear = c, o.clearConversions = l, o.addTypes = u, o._findType = s, o.referTo = de, o.referToSelf = De, o.convert = p, o.findSignature = h, o.find = m, o.isTypedFunction = f, o.warnAgainstDeprecatedThis = !0, o.addType = function(ne, re) {
    let le = "any";
    re !== !1 && n.has("Object") && (le = "Object"), o.addTypes([ne], le);
  };
  function nt(ne) {
    if (!ne || typeof ne.from != "string" || typeof ne.to != "string" || typeof ne.convert != "function")
      throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");
    if (ne.to === ne.from)
      throw new SyntaxError('Illegal to define conversion from "' + ne.from + '" to itself.');
  }
  return o.addConversion = function(ne) {
    let re = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
      override: !1
    };
    nt(ne);
    const le = s(ne.to), fe = le.conversionsTo.find((ge) => ge.from === ne.from);
    if (fe)
      if (re && re.override)
        o.removeConversion({
          from: fe.from,
          to: ne.to,
          convert: fe.convert
        });
      else
        throw new Error('There is already a conversion from "' + ne.from + '" to "' + le.name + '"');
    le.conversionsTo.push({
      from: ne.from,
      convert: ne.convert,
      index: a++
    });
  }, o.addConversions = function(ne, re) {
    ne.forEach((le) => o.addConversion(le, re));
  }, o.removeConversion = function(ne) {
    nt(ne);
    const re = s(ne.to), le = ae(re.conversionsTo, (ge) => ge.from === ne.from);
    if (!le)
      throw new Error("Attempt to remove nonexistent conversion from " + ne.from + " to " + ne.to);
    if (le.convert !== ne.convert)
      throw new Error("Conversion to remove does not match existing conversion");
    const fe = re.conversionsTo.indexOf(le);
    re.conversionsTo.splice(fe, 1);
  }, o.resolve = function(ne, re) {
    if (!f(ne))
      throw new TypeError(BP);
    const le = ne._typedFunctionData.signatures;
    for (let fe = 0; fe < le.length; ++fe)
      if (le[fe].test(re))
        return le[fe];
    return null;
  }, o;
}
const FP = PG();
function zn(t) {
  return typeof t == "boolean" ? !0 : isFinite(t) ? t === Math.round(t) : !1;
}
var M0e = Math.sign || function(t) {
  return t > 0 ? 1 : t < 0 ? -1 : 0;
};
function j8(t, e, r) {
  var n = {
    2: "0b",
    8: "0o",
    16: "0x"
  }, i = n[e], a = "";
  if (r) {
    if (r < 1)
      throw new Error("size must be in greater than 0");
    if (!zn(r))
      throw new Error("size must be an integer");
    if (t > 2 ** (r - 1) - 1 || t < -(2 ** (r - 1)))
      throw new Error("Value must be in range [-2^".concat(r - 1, ", 2^").concat(r - 1, "-1]"));
    if (!zn(t))
      throw new Error("Value must be an integer");
    t < 0 && (t = t + 2 ** r), a = "i".concat(r);
  }
  var o = "";
  return t < 0 && (t = -t, o = "-"), "".concat(o).concat(i).concat(t.toString(e)).concat(a);
}
function d9(t, e) {
  if (typeof e == "function")
    return e(t);
  if (t === 1 / 0)
    return "Infinity";
  if (t === -1 / 0)
    return "-Infinity";
  if (isNaN(t))
    return "NaN";
  var {
    notation: r,
    precision: n,
    wordSize: i
  } = BG(e);
  switch (r) {
    case "fixed":
      return FG(t, n);
    case "exponential":
      return NG(t, n);
    case "engineering":
      return P0e(t, n);
    case "bin":
      return j8(t, 2, i);
    case "oct":
      return j8(t, 8, i);
    case "hex":
      return j8(t, 16, i);
    case "auto":
      return B0e(t, n, e).replace(/((\.\d*?)(0+))($|e)/, function() {
        var a = arguments[2], o = arguments[4];
        return a !== "." ? a + o : o;
      });
    default:
      throw new Error('Unknown notation "' + r + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
  }
}
function BG(t) {
  var e = "auto", r, n;
  if (t !== void 0)
    if (Gn(t))
      r = t;
    else if (mi(t))
      r = t.toNumber();
    else if (eS(t))
      t.precision !== void 0 && (r = NP(t.precision, () => {
        throw new Error('Option "precision" must be a number or BigNumber');
      })), t.wordSize !== void 0 && (n = NP(t.wordSize, () => {
        throw new Error('Option "wordSize" must be a number or BigNumber');
      })), t.notation && (e = t.notation);
    else
      throw new Error("Unsupported type of options, number, BigNumber, or object expected");
  return {
    notation: e,
    precision: r,
    wordSize: n
  };
}
function A2(t) {
  var e = String(t).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);
  if (!e)
    throw new SyntaxError("Invalid number " + t);
  var r = e[1], n = e[2], i = parseFloat(e[4] || "0"), a = n.indexOf(".");
  i += a !== -1 ? a - 1 : n.length - 1;
  var o = n.replace(".", "").replace(/^0*/, function(s) {
    return i -= s.length, "";
  }).replace(/0*$/, "").split("").map(function(s) {
    return parseInt(s);
  });
  return o.length === 0 && (o.push(0), i++), {
    sign: r,
    coefficients: o,
    exponent: i
  };
}
function P0e(t, e) {
  if (isNaN(t) || !isFinite(t))
    return String(t);
  var r = A2(t), n = u4(r, e), i = n.exponent, a = n.coefficients, o = i % 3 === 0 ? i : i < 0 ? i - 3 - i % 3 : i - i % 3;
  if (Gn(e))
    for (; e > a.length || i - o + 1 > a.length; )
      a.push(0);
  else
    for (var s = Math.abs(i - o) - (a.length - 1), u = 0; u < s; u++)
      a.push(0);
  for (var c = Math.abs(i - o), l = 1; c > 0; )
    l++, c--;
  var d = a.slice(l).join(""), f = Gn(e) && d.length || d.match(/[1-9]/) ? "." + d : "", h = a.slice(0, l).join("") + f + "e" + (i >= 0 ? "+" : "") + o.toString();
  return n.sign + h;
}
function FG(t, e) {
  if (isNaN(t) || !isFinite(t))
    return String(t);
  var r = A2(t), n = typeof e == "number" ? u4(r, r.exponent + 1 + e) : r, i = n.coefficients, a = n.exponent + 1, o = a + (e || 0);
  return i.length < o && (i = i.concat(mp(o - i.length))), a < 0 && (i = mp(-a + 1).concat(i), a = 1), a < i.length && i.splice(a, 0, a === 0 ? "0." : "."), n.sign + i.join("");
}
function NG(t, e) {
  if (isNaN(t) || !isFinite(t))
    return String(t);
  var r = A2(t), n = e ? u4(r, e) : r, i = n.coefficients, a = n.exponent;
  i.length < e && (i = i.concat(mp(e - i.length)));
  var o = i.shift();
  return n.sign + o + (i.length > 0 ? "." + i.join("") : "") + "e" + (a >= 0 ? "+" : "") + a;
}
function B0e(t, e, r) {
  if (isNaN(t) || !isFinite(t))
    return String(t);
  var n = RP(r == null ? void 0 : r.lowerExp, -3), i = RP(r == null ? void 0 : r.upperExp, 5), a = A2(t), o = e ? u4(a, e) : a;
  if (o.exponent < n || o.exponent >= i)
    return NG(t, e);
  var s = o.coefficients, u = o.exponent;
  s.length < e && (s = s.concat(mp(e - s.length))), s = s.concat(mp(u - s.length + 1 + (s.length < e ? e - s.length : 0))), s = mp(-u).concat(s);
  var c = u > 0 ? u : 0;
  return c < s.length - 1 && s.splice(c + 1, 0, "."), o.sign + s.join("");
}
function u4(t, e) {
  for (var r = {
    sign: t.sign,
    coefficients: t.coefficients,
    exponent: t.exponent
  }, n = r.coefficients; e <= 0; )
    n.unshift(0), r.exponent++, e++;
  if (n.length > e) {
    var i = n.splice(e, n.length - e);
    if (i[0] >= 5) {
      var a = e - 1;
      for (n[a]++; n[a] === 10; )
        n.pop(), a === 0 && (n.unshift(0), r.exponent++, a++), a--, n[a]++;
    }
  }
  return r;
}
function mp(t) {
  for (var e = [], r = 0; r < t; r++)
    e.push(0);
  return e;
}
function F0e(t) {
  return t.toExponential().replace(/e.*$/, "").replace(/^0\.?0*|\./, "").length;
}
function Ss(t, e) {
  var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1e-8, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  if (r <= 0)
    throw new Error("Relative tolerance must be greater than 0");
  if (n < 0)
    throw new Error("Absolute tolerance must be at least 0");
  return isNaN(t) || isNaN(e) ? !1 : !isFinite(t) || !isFinite(e) ? t === e : t === e ? !0 : Math.abs(t - e) <= Math.max(r * Math.max(Math.abs(t), Math.abs(e)), n);
}
function NP(t, e) {
  if (Gn(t))
    return t;
  if (mi(t))
    return t.toNumber();
  e();
}
function RP(t, e) {
  return Gn(t) ? t : mi(t) ? t.toNumber() : e;
}
function vt(t, e, r, n) {
  function i(a) {
    var o = E0e(a, e.map(O0e));
    return N0e(t, e, a), r(o);
  }
  return i.isFactory = !0, i.fn = t, i.dependencies = e.slice().sort(), n && (i.meta = n), i;
}
function N0e(t, e, r) {
  var n = e.filter((a) => !R0e(a)).every((a) => r[a] !== void 0);
  if (!n) {
    var i = e.filter((a) => r[a] === void 0);
    throw new Error('Cannot create function "'.concat(t, '", ') + "some dependencies are missing: ".concat(i.map((a) => '"'.concat(a, '"')).join(", "), "."));
  }
}
function R0e(t) {
  return t && t[0] === "?";
}
function O0e(t) {
  return t && t[0] === "?" ? t.slice(1) : t;
}
function L0e(t, e) {
  if (OG(t) && RG(t, e))
    return t[e];
  throw typeof t[e] == "function" && z0e(t, e) ? new Error('Cannot access method "' + e + '" as a property') : new Error('No access to property "' + e + '"');
}
function k0e(t, e, r) {
  if (OG(t) && RG(t, e))
    return t[e] = r, r;
  throw new Error('No access to property "' + e + '"');
}
function G0e(t, e) {
  return e in t;
}
function RG(t, e) {
  return !t || typeof t != "object" ? !1 : s2(V0e, e) ? !0 : !(e in Object.prototype || e in Function.prototype);
}
function z0e(t, e) {
  return t == null || typeof t[e] != "function" || s2(t, e) && Object.getPrototypeOf && e in Object.getPrototypeOf(t) ? !1 : s2(U0e, e) ? !0 : !(e in Object.prototype || e in Function.prototype);
}
function OG(t) {
  return typeof t == "object" && t && t.constructor === Object;
}
var V0e = {
  length: !0,
  name: !0
}, U0e = {
  toString: !0,
  valueOf: !0,
  toLocaleString: !0
};
class H0e {
  constructor(e) {
    this.wrappedObject = e, this[Symbol.iterator] = this.entries;
  }
  keys() {
    return Object.keys(this.wrappedObject).values();
  }
  get(e) {
    return L0e(this.wrappedObject, e);
  }
  set(e, r) {
    return k0e(this.wrappedObject, e, r), this;
  }
  has(e) {
    return G0e(this.wrappedObject, e);
  }
  entries() {
    return q0e(this.keys(), (e) => [e, this.get(e)]);
  }
  forEach(e) {
    for (var r of this.keys())
      e(this.get(r), r, this);
  }
  delete(e) {
    delete this.wrappedObject[e];
  }
  clear() {
    for (var e of this.keys())
      this.delete(e);
  }
  get size() {
    return Object.keys(this.wrappedObject).length;
  }
}
function q0e(t, e) {
  return {
    next: () => {
      var r = t.next();
      return r.done ? r : {
        value: e(r.value),
        done: !1
      };
    }
  };
}
function K0e(t) {
  return t ? t instanceof Map || t instanceof H0e || typeof t.set == "function" && typeof t.get == "function" && typeof t.keys == "function" && typeof t.has == "function" : !1;
}
var LG = function() {
  return LG = FP.create, FP;
}, X0e = ["?BigNumber", "?Complex", "?DenseMatrix", "?Fraction"], Y0e = /* @__PURE__ */ vt("typed", X0e, function(e) {
  var {
    BigNumber: r,
    Complex: n,
    DenseMatrix: i,
    Fraction: a
  } = e, o = LG();
  return o.clear(), o.addTypes([
    {
      name: "number",
      test: Gn
    },
    {
      name: "Complex",
      test: Qx
    },
    {
      name: "BigNumber",
      test: mi
    },
    {
      name: "bigint",
      test: e0e
    },
    {
      name: "Fraction",
      test: Jx
    },
    {
      name: "Unit",
      test: DG
    },
    // The following type matches a valid variable name, i.e., an alphanumeric
    // string starting with an alphabetic character. It is used (at least)
    // in the definition of the derivative() function, as the argument telling
    // what to differentiate over must (currently) be a variable.
    {
      name: "identifier",
      test: (s) => Eu && /^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(s)
    },
    {
      name: "string",
      test: Eu
    },
    {
      name: "Chain",
      test: w0e
    },
    {
      name: "Array",
      test: Mn
    },
    {
      name: "Matrix",
      test: Xn
    },
    {
      name: "DenseMatrix",
      test: EG
    },
    {
      name: "SparseMatrix",
      test: IG
    },
    {
      name: "Range",
      test: TG
    },
    {
      name: "Index",
      test: $x
    },
    {
      name: "boolean",
      test: t0e
    },
    {
      name: "ResultSet",
      test: r0e
    },
    {
      name: "Help",
      test: n0e
    },
    {
      name: "function",
      test: i0e
    },
    {
      name: "Date",
      test: a0e
    },
    {
      name: "RegExp",
      test: o0e
    },
    {
      name: "null",
      test: s0e
    },
    {
      name: "undefined",
      test: u0e
    },
    {
      name: "AccessorNode",
      test: c0e
    },
    {
      name: "ArrayNode",
      test: l0e
    },
    {
      name: "AssignmentNode",
      test: d0e
    },
    {
      name: "BlockNode",
      test: f0e
    },
    {
      name: "ConditionalNode",
      test: p0e
    },
    {
      name: "ConstantNode",
      test: h0e
    },
    {
      name: "FunctionNode",
      test: g0e
    },
    {
      name: "FunctionAssignmentNode",
      test: m0e
    },
    {
      name: "IndexNode",
      test: v0e
    },
    {
      name: "Node",
      test: y0e
    },
    {
      name: "ObjectNode",
      test: b0e
    },
    {
      name: "OperatorNode",
      test: _0e
    },
    {
      name: "ParenthesisNode",
      test: x0e
    },
    {
      name: "RangeNode",
      test: S0e
    },
    {
      name: "RelationalNode",
      test: C0e
    },
    {
      name: "SymbolNode",
      test: A0e
    },
    {
      name: "Map",
      test: K0e
    },
    {
      name: "Object",
      test: eS
    }
    // order 'Object' last, it matches on other classes too
  ]), o.addConversions([{
    from: "number",
    to: "BigNumber",
    convert: function(u) {
      if (r || Vv(u), F0e(u) > 15)
        throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: " + u + "). Use function bignumber(x) to convert to BigNumber.");
      return new r(u);
    }
  }, {
    from: "number",
    to: "Complex",
    convert: function(u) {
      return n || Uv(u), new n(u, 0);
    }
  }, {
    from: "BigNumber",
    to: "Complex",
    convert: function(u) {
      return n || Uv(u), new n(u.toNumber(), 0);
    }
  }, {
    from: "bigint",
    to: "number",
    convert: function(u) {
      if (u > Number.MAX_SAFE_INTEGER)
        throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: " + u + ")");
      return Number(u);
    }
  }, {
    from: "bigint",
    to: "BigNumber",
    convert: function(u) {
      return r || Vv(u), new r(u.toString());
    }
  }, {
    from: "bigint",
    to: "Fraction",
    convert: function(u) {
      return a || Hv(u), new a(u.toString());
    }
  }, {
    from: "Fraction",
    to: "BigNumber",
    convert: function(u) {
      throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.");
    }
  }, {
    from: "Fraction",
    to: "Complex",
    convert: function(u) {
      return n || Uv(u), new n(u.valueOf(), 0);
    }
  }, {
    from: "number",
    to: "Fraction",
    convert: function(u) {
      a || Hv(u);
      var c = new a(u);
      if (c.valueOf() !== u)
        throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: " + u + "). Use function fraction(x) to convert to Fraction.");
      return c;
    }
  }, {
    // FIXME: add conversion from Fraction to number, for example for `sqrt(fraction(1,3))`
    //  from: 'Fraction',
    //  to: 'number',
    //  convert: function (x) {
    //    return x.valueOf()
    //  }
    // }, {
    from: "string",
    to: "number",
    convert: function(u) {
      var c = Number(u);
      if (isNaN(c))
        throw new Error('Cannot convert "' + u + '" to a number');
      return c;
    }
  }, {
    from: "string",
    to: "BigNumber",
    convert: function(u) {
      r || Vv(u);
      try {
        return new r(u);
      } catch {
        throw new Error('Cannot convert "' + u + '" to BigNumber');
      }
    }
  }, {
    from: "string",
    to: "bigint",
    convert: function(u) {
      try {
        return BigInt(u);
      } catch {
        throw new Error('Cannot convert "' + u + '" to BigInt');
      }
    }
  }, {
    from: "string",
    to: "Fraction",
    convert: function(u) {
      a || Hv(u);
      try {
        return new a(u);
      } catch {
        throw new Error('Cannot convert "' + u + '" to Fraction');
      }
    }
  }, {
    from: "string",
    to: "Complex",
    convert: function(u) {
      n || Uv(u);
      try {
        return new n(u);
      } catch {
        throw new Error('Cannot convert "' + u + '" to Complex');
      }
    }
  }, {
    from: "boolean",
    to: "number",
    convert: function(u) {
      return +u;
    }
  }, {
    from: "boolean",
    to: "BigNumber",
    convert: function(u) {
      return r || Vv(u), new r(+u);
    }
  }, {
    from: "boolean",
    to: "bigint",
    convert: function(u) {
      return BigInt(+u);
    }
  }, {
    from: "boolean",
    to: "Fraction",
    convert: function(u) {
      return a || Hv(u), new a(+u);
    }
  }, {
    from: "boolean",
    to: "string",
    convert: function(u) {
      return String(u);
    }
  }, {
    from: "Array",
    to: "Matrix",
    convert: function(u) {
      return i || W0e(), new i(u);
    }
  }, {
    from: "Matrix",
    to: "Array",
    convert: function(u) {
      return u.valueOf();
    }
  }]), o.onMismatch = (s, u, c) => {
    var l = o.createError(s, u, c);
    if (["wrongType", "mismatch"].includes(l.data.category) && u.length === 1 && py(u[0]) && // check if the function can be unary:
    c.some((f) => !f.params.includes(","))) {
      var d = new TypeError("Function '".concat(s, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(s, ")'."));
      throw d.data = l.data, d;
    }
    throw l;
  }, o.onMismatch = (s, u, c) => {
    var l = o.createError(s, u, c);
    if (["wrongType", "mismatch"].includes(l.data.category) && u.length === 1 && py(u[0]) && // check if the function can be unary:
    c.some((f) => !f.params.includes(","))) {
      var d = new TypeError("Function '".concat(s, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(s, ")'."));
      throw d.data = l.data, d;
    }
    throw l;
  }, o;
});
function Vv(t) {
  throw new Error("Cannot convert value ".concat(t, " into a BigNumber: no class 'BigNumber' provided"));
}
function Uv(t) {
  throw new Error("Cannot convert value ".concat(t, " into a Complex number: no class 'Complex' provided"));
}
function W0e() {
  throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided");
}
function Hv(t) {
  throw new Error("Cannot convert value ".concat(t, " into a Fraction, no class 'Fraction' provided."));
}
/*!
 *  decimal.js v10.4.3
 *  An arbitrary-precision Decimal type for JavaScript.
 *  https://github.com/MikeMcl/decimal.js
 *  Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
 *  MIT Licence
 */
var ip = 9e15, gf = 1e9, f9 = "0123456789abcdef", hy = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", my = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", p9 = {
  // These values must be integers within the stated ranges (inclusive).
  // Most of these values can be changed at run-time using the `Decimal.config` method.
  // The maximum number of significant digits of the result of a calculation or base conversion.
  // E.g. `Decimal.config({ precision: 20 });`
  precision: 20,
  // 1 to MAX_DIGITS
  // The rounding mode used when rounding to `precision`.
  //
  // ROUND_UP         0 Away from zero.
  // ROUND_DOWN       1 Towards zero.
  // ROUND_CEIL       2 Towards +Infinity.
  // ROUND_FLOOR      3 Towards -Infinity.
  // ROUND_HALF_UP    4 Towards nearest neighbour. If equidistant, up.
  // ROUND_HALF_DOWN  5 Towards nearest neighbour. If equidistant, down.
  // ROUND_HALF_EVEN  6 Towards nearest neighbour. If equidistant, towards even neighbour.
  // ROUND_HALF_CEIL  7 Towards nearest neighbour. If equidistant, towards +Infinity.
  // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  //
  // E.g.
  // `Decimal.rounding = 4;`
  // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
  rounding: 4,
  // 0 to 8
  // The modulo mode used when calculating the modulus: a mod n.
  // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  // The remainder (r) is calculated as: r = a - n * q.
  //
  // UP         0 The remainder is positive if the dividend is negative, else is negative.
  // DOWN       1 The remainder has the same sign as the dividend (JavaScript %).
  // FLOOR      3 The remainder has the same sign as the divisor (Python %).
  // HALF_EVEN  6 The IEEE 754 remainder function.
  // EUCLID     9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
  //
  // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
  // division (9) are commonly used for the modulus operation. The other rounding modes can also
  // be used, but they may not give useful results.
  modulo: 1,
  // 0 to 9
  // The exponent value at and beneath which `toString` returns exponential notation.
  // JavaScript numbers: -7
  toExpNeg: -7,
  // 0 to -EXP_LIMIT
  // The exponent value at and above which `toString` returns exponential notation.
  // JavaScript numbers: 21
  toExpPos: 21,
  // 0 to EXP_LIMIT
  // The minimum exponent value, beneath which underflow to zero occurs.
  // JavaScript numbers: -324  (5e-324)
  minE: -ip,
  // -1 to -EXP_LIMIT
  // The maximum exponent value, above which overflow to Infinity occurs.
  // JavaScript numbers: 308  (1.7976931348623157e+308)
  maxE: ip,
  // 1 to EXP_LIMIT
  // Whether to use cryptographically-secure random number generation, if available.
  crypto: !1
  // true/false
}, kG, hl, dr = !0, c4 = "[DecimalError] ", df = c4 + "Invalid argument: ", GG = c4 + "Precision limit exceeded", zG = c4 + "crypto unavailable", VG = "[object Decimal]", no = Math.floor, ra = Math.pow, j0e = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, Z0e = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, Q0e = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, UG = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, Ou = 1e7, Zt = 7, J0e = 9007199254740991, $0e = hy.length - 1, h9 = my.length - 1, lt = { toStringTag: VG };
lt.absoluteValue = lt.abs = function() {
  var t = new this.constructor(this);
  return t.s < 0 && (t.s = 1), Ht(t);
};
lt.ceil = function() {
  return Ht(new this.constructor(this), this.e + 1, 2);
};
lt.clampedTo = lt.clamp = function(t, e) {
  var r, n = this, i = n.constructor;
  if (t = new i(t), e = new i(e), !t.s || !e.s) return new i(NaN);
  if (t.gt(e)) throw Error(df + e);
  return r = n.cmp(t), r < 0 ? t : n.cmp(e) > 0 ? e : new i(n);
};
lt.comparedTo = lt.cmp = function(t) {
  var e, r, n, i, a = this, o = a.d, s = (t = new a.constructor(t)).d, u = a.s, c = t.s;
  if (!o || !s)
    return !u || !c ? NaN : u !== c ? u : o === s ? 0 : !o ^ u < 0 ? 1 : -1;
  if (!o[0] || !s[0]) return o[0] ? u : s[0] ? -c : 0;
  if (u !== c) return u;
  if (a.e !== t.e) return a.e > t.e ^ u < 0 ? 1 : -1;
  for (n = o.length, i = s.length, e = 0, r = n < i ? n : i; e < r; ++e)
    if (o[e] !== s[e]) return o[e] > s[e] ^ u < 0 ? 1 : -1;
  return n === i ? 0 : n > i ^ u < 0 ? 1 : -1;
};
lt.cosine = lt.cos = function() {
  var t, e, r = this, n = r.constructor;
  return r.d ? r.d[0] ? (t = n.precision, e = n.rounding, n.precision = t + Math.max(r.e, r.sd()) + Zt, n.rounding = 1, r = e1e(n, YG(n, r)), n.precision = t, n.rounding = e, Ht(hl == 2 || hl == 3 ? r.neg() : r, t, e, !0)) : new n(1) : new n(NaN);
};
lt.cubeRoot = lt.cbrt = function() {
  var t, e, r, n, i, a, o, s, u, c, l = this, d = l.constructor;
  if (!l.isFinite() || l.isZero()) return new d(l);
  for (dr = !1, a = l.s * ra(l.s * l, 1 / 3), !a || Math.abs(a) == 1 / 0 ? (r = Va(l.d), t = l.e, (a = (t - r.length + 1) % 3) && (r += a == 1 || a == -2 ? "0" : "00"), a = ra(r, 1 / 3), t = no((t + 1) / 3) - (t % 3 == (t < 0 ? -1 : 2)), a == 1 / 0 ? r = "5e" + t : (r = a.toExponential(), r = r.slice(0, r.indexOf("e") + 1) + t), n = new d(r), n.s = l.s) : n = new d(a.toString()), o = (t = d.precision) + 3; ; )
    if (s = n, u = s.times(s).times(s), c = u.plus(l), n = Vn(c.plus(l).times(s), c.plus(u), o + 2, 1), Va(s.d).slice(0, o) === (r = Va(n.d)).slice(0, o))
      if (r = r.slice(o - 3, o + 1), r == "9999" || !i && r == "4999") {
        if (!i && (Ht(s, t + 1, 0), s.times(s).times(s).eq(l))) {
          n = s;
          break;
        }
        o += 4, i = 1;
      } else {
        (!+r || !+r.slice(1) && r.charAt(0) == "5") && (Ht(n, t + 1, 1), e = !n.times(n).times(n).eq(l));
        break;
      }
  return dr = !0, Ht(n, t, d.rounding, e);
};
lt.decimalPlaces = lt.dp = function() {
  var t, e = this.d, r = NaN;
  if (e) {
    if (t = e.length - 1, r = (t - no(this.e / Zt)) * Zt, t = e[t], t) for (; t % 10 == 0; t /= 10) r--;
    r < 0 && (r = 0);
  }
  return r;
};
lt.dividedBy = lt.div = function(t) {
  return Vn(this, new this.constructor(t));
};
lt.dividedToIntegerBy = lt.divToInt = function(t) {
  var e = this, r = e.constructor;
  return Ht(Vn(e, new r(t), 0, 1, 1), r.precision, r.rounding);
};
lt.equals = lt.eq = function(t) {
  return this.cmp(t) === 0;
};
lt.floor = function() {
  return Ht(new this.constructor(this), this.e + 1, 3);
};
lt.greaterThan = lt.gt = function(t) {
  return this.cmp(t) > 0;
};
lt.greaterThanOrEqualTo = lt.gte = function(t) {
  var e = this.cmp(t);
  return e == 1 || e === 0;
};
lt.hyperbolicCosine = lt.cosh = function() {
  var t, e, r, n, i, a = this, o = a.constructor, s = new o(1);
  if (!a.isFinite()) return new o(a.s ? 1 / 0 : NaN);
  if (a.isZero()) return s;
  r = o.precision, n = o.rounding, o.precision = r + Math.max(a.e, a.sd()) + 4, o.rounding = 1, i = a.d.length, i < 32 ? (t = Math.ceil(i / 3), e = (1 / d4(4, t)).toString()) : (t = 16, e = "2.3283064365386962890625e-10"), a = Hp(o, 1, a.times(e), new o(1), !0);
  for (var u, c = t, l = new o(8); c--; )
    u = a.times(a), a = s.minus(u.times(l.minus(u.times(l))));
  return Ht(a, o.precision = r, o.rounding = n, !0);
};
lt.hyperbolicSine = lt.sinh = function() {
  var t, e, r, n, i = this, a = i.constructor;
  if (!i.isFinite() || i.isZero()) return new a(i);
  if (e = a.precision, r = a.rounding, a.precision = e + Math.max(i.e, i.sd()) + 4, a.rounding = 1, n = i.d.length, n < 3)
    i = Hp(a, 2, i, i, !0);
  else {
    t = 1.4 * Math.sqrt(n), t = t > 16 ? 16 : t | 0, i = i.times(1 / d4(5, t)), i = Hp(a, 2, i, i, !0);
    for (var o, s = new a(5), u = new a(16), c = new a(20); t--; )
      o = i.times(i), i = i.times(s.plus(o.times(u.times(o).plus(c))));
  }
  return a.precision = e, a.rounding = r, Ht(i, e, r, !0);
};
lt.hyperbolicTangent = lt.tanh = function() {
  var t, e, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (t = n.precision, e = n.rounding, n.precision = t + 7, n.rounding = 1, Vn(r.sinh(), r.cosh(), n.precision = t, n.rounding = e)) : new n(r.s);
};
lt.inverseCosine = lt.acos = function() {
  var t, e = this, r = e.constructor, n = e.abs().cmp(1), i = r.precision, a = r.rounding;
  return n !== -1 ? n === 0 ? e.isNeg() ? Nu(r, i, a) : new r(0) : new r(NaN) : e.isZero() ? Nu(r, i + 4, a).times(0.5) : (r.precision = i + 6, r.rounding = 1, e = e.asin(), t = Nu(r, i + 4, a).times(0.5), r.precision = i, r.rounding = a, t.minus(e));
};
lt.inverseHyperbolicCosine = lt.acosh = function() {
  var t, e, r = this, n = r.constructor;
  return r.lte(1) ? new n(r.eq(1) ? 0 : NaN) : r.isFinite() ? (t = n.precision, e = n.rounding, n.precision = t + Math.max(Math.abs(r.e), r.sd()) + 4, n.rounding = 1, dr = !1, r = r.times(r).minus(1).sqrt().plus(r), dr = !0, n.precision = t, n.rounding = e, r.ln()) : new n(r);
};
lt.inverseHyperbolicSine = lt.asinh = function() {
  var t, e, r = this, n = r.constructor;
  return !r.isFinite() || r.isZero() ? new n(r) : (t = n.precision, e = n.rounding, n.precision = t + 2 * Math.max(Math.abs(r.e), r.sd()) + 6, n.rounding = 1, dr = !1, r = r.times(r).plus(1).sqrt().plus(r), dr = !0, n.precision = t, n.rounding = e, r.ln());
};
lt.inverseHyperbolicTangent = lt.atanh = function() {
  var t, e, r, n, i = this, a = i.constructor;
  return i.isFinite() ? i.e >= 0 ? new a(i.abs().eq(1) ? i.s / 0 : i.isZero() ? i : NaN) : (t = a.precision, e = a.rounding, n = i.sd(), Math.max(n, t) < 2 * -i.e - 1 ? Ht(new a(i), t, e, !0) : (a.precision = r = n - i.e, i = Vn(i.plus(1), new a(1).minus(i), r + t, 1), a.precision = t + 4, a.rounding = 1, i = i.ln(), a.precision = t, a.rounding = e, i.times(0.5))) : new a(NaN);
};
lt.inverseSine = lt.asin = function() {
  var t, e, r, n, i = this, a = i.constructor;
  return i.isZero() ? new a(i) : (e = i.abs().cmp(1), r = a.precision, n = a.rounding, e !== -1 ? e === 0 ? (t = Nu(a, r + 4, n).times(0.5), t.s = i.s, t) : new a(NaN) : (a.precision = r + 6, a.rounding = 1, i = i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(), a.precision = r, a.rounding = n, i.times(2)));
};
lt.inverseTangent = lt.atan = function() {
  var t, e, r, n, i, a, o, s, u, c = this, l = c.constructor, d = l.precision, f = l.rounding;
  if (c.isFinite()) {
    if (c.isZero())
      return new l(c);
    if (c.abs().eq(1) && d + 4 <= h9)
      return o = Nu(l, d + 4, f).times(0.25), o.s = c.s, o;
  } else {
    if (!c.s) return new l(NaN);
    if (d + 4 <= h9)
      return o = Nu(l, d + 4, f).times(0.5), o.s = c.s, o;
  }
  for (l.precision = s = d + 10, l.rounding = 1, r = Math.min(28, s / Zt + 2 | 0), t = r; t; --t) c = c.div(c.times(c).plus(1).sqrt().plus(1));
  for (dr = !1, e = Math.ceil(s / Zt), n = 1, u = c.times(c), o = new l(c), i = c; t !== -1; )
    if (i = i.times(u), a = o.minus(i.div(n += 2)), i = i.times(u), o = a.plus(i.div(n += 2)), o.d[e] !== void 0) for (t = e; o.d[t] === a.d[t] && t--; ) ;
  return r && (o = o.times(2 << r - 1)), dr = !0, Ht(o, l.precision = d, l.rounding = f, !0);
};
lt.isFinite = function() {
  return !!this.d;
};
lt.isInteger = lt.isInt = function() {
  return !!this.d && no(this.e / Zt) > this.d.length - 2;
};
lt.isNaN = function() {
  return !this.s;
};
lt.isNegative = lt.isNeg = function() {
  return this.s < 0;
};
lt.isPositive = lt.isPos = function() {
  return this.s > 0;
};
lt.isZero = function() {
  return !!this.d && this.d[0] === 0;
};
lt.lessThan = lt.lt = function(t) {
  return this.cmp(t) < 0;
};
lt.lessThanOrEqualTo = lt.lte = function(t) {
  return this.cmp(t) < 1;
};
lt.logarithm = lt.log = function(t) {
  var e, r, n, i, a, o, s, u, c = this, l = c.constructor, d = l.precision, f = l.rounding, h = 5;
  if (t == null)
    t = new l(10), e = !0;
  else {
    if (t = new l(t), r = t.d, t.s < 0 || !r || !r[0] || t.eq(1)) return new l(NaN);
    e = t.eq(10);
  }
  if (r = c.d, c.s < 0 || !r || !r[0] || c.eq(1))
    return new l(r && !r[0] ? -1 / 0 : c.s != 1 ? NaN : r ? 0 : 1 / 0);
  if (e)
    if (r.length > 1)
      a = !0;
    else {
      for (i = r[0]; i % 10 === 0; ) i /= 10;
      a = i !== 1;
    }
  if (dr = !1, s = d + h, o = Wd(c, s), n = e ? gy(l, s + 10) : Wd(t, s), u = Vn(o, n, s, 1), u2(u.d, i = d, f))
    do
      if (s += 10, o = Wd(c, s), n = e ? gy(l, s + 10) : Wd(t, s), u = Vn(o, n, s, 1), !a) {
        +Va(u.d).slice(i + 1, i + 15) + 1 == 1e14 && (u = Ht(u, d + 1, 0));
        break;
      }
    while (u2(u.d, i += 10, f));
  return dr = !0, Ht(u, d, f);
};
lt.minus = lt.sub = function(t) {
  var e, r, n, i, a, o, s, u, c, l, d, f, h = this, m = h.constructor;
  if (t = new m(t), !h.d || !t.d)
    return !h.s || !t.s ? t = new m(NaN) : h.d ? t.s = -t.s : t = new m(t.d || h.s !== t.s ? h : NaN), t;
  if (h.s != t.s)
    return t.s = -t.s, h.plus(t);
  if (c = h.d, f = t.d, s = m.precision, u = m.rounding, !c[0] || !f[0]) {
    if (f[0]) t.s = -t.s;
    else if (c[0]) t = new m(h);
    else return new m(u === 3 ? -0 : 0);
    return dr ? Ht(t, s, u) : t;
  }
  if (r = no(t.e / Zt), l = no(h.e / Zt), c = c.slice(), a = l - r, a) {
    for (d = a < 0, d ? (e = c, a = -a, o = f.length) : (e = f, r = l, o = c.length), n = Math.max(Math.ceil(s / Zt), o) + 2, a > n && (a = n, e.length = 1), e.reverse(), n = a; n--; ) e.push(0);
    e.reverse();
  } else {
    for (n = c.length, o = f.length, d = n < o, d && (o = n), n = 0; n < o; n++)
      if (c[n] != f[n]) {
        d = c[n] < f[n];
        break;
      }
    a = 0;
  }
  for (d && (e = c, c = f, f = e, t.s = -t.s), o = c.length, n = f.length - o; n > 0; --n) c[o++] = 0;
  for (n = f.length; n > a; ) {
    if (c[--n] < f[n]) {
      for (i = n; i && c[--i] === 0; ) c[i] = Ou - 1;
      --c[i], c[n] += Ou;
    }
    c[n] -= f[n];
  }
  for (; c[--o] === 0; ) c.pop();
  for (; c[0] === 0; c.shift()) --r;
  return c[0] ? (t.d = c, t.e = l4(c, r), dr ? Ht(t, s, u) : t) : new m(u === 3 ? -0 : 0);
};
lt.modulo = lt.mod = function(t) {
  var e, r = this, n = r.constructor;
  return t = new n(t), !r.d || !t.s || t.d && !t.d[0] ? new n(NaN) : !t.d || r.d && !r.d[0] ? Ht(new n(r), n.precision, n.rounding) : (dr = !1, n.modulo == 9 ? (e = Vn(r, t.abs(), 0, 3, 1), e.s *= t.s) : e = Vn(r, t, 0, n.modulo, 1), e = e.times(t), dr = !0, r.minus(e));
};
lt.naturalExponential = lt.exp = function() {
  return m9(this);
};
lt.naturalLogarithm = lt.ln = function() {
  return Wd(this);
};
lt.negated = lt.neg = function() {
  var t = new this.constructor(this);
  return t.s = -t.s, Ht(t);
};
lt.plus = lt.add = function(t) {
  var e, r, n, i, a, o, s, u, c, l, d = this, f = d.constructor;
  if (t = new f(t), !d.d || !t.d)
    return !d.s || !t.s ? t = new f(NaN) : d.d || (t = new f(t.d || d.s === t.s ? d : NaN)), t;
  if (d.s != t.s)
    return t.s = -t.s, d.minus(t);
  if (c = d.d, l = t.d, s = f.precision, u = f.rounding, !c[0] || !l[0])
    return l[0] || (t = new f(d)), dr ? Ht(t, s, u) : t;
  if (a = no(d.e / Zt), n = no(t.e / Zt), c = c.slice(), i = a - n, i) {
    for (i < 0 ? (r = c, i = -i, o = l.length) : (r = l, n = a, o = c.length), a = Math.ceil(s / Zt), o = a > o ? a + 1 : o + 1, i > o && (i = o, r.length = 1), r.reverse(); i--; ) r.push(0);
    r.reverse();
  }
  for (o = c.length, i = l.length, o - i < 0 && (i = o, r = l, l = c, c = r), e = 0; i; )
    e = (c[--i] = c[i] + l[i] + e) / Ou | 0, c[i] %= Ou;
  for (e && (c.unshift(e), ++n), o = c.length; c[--o] == 0; ) c.pop();
  return t.d = c, t.e = l4(c, n), dr ? Ht(t, s, u) : t;
};
lt.precision = lt.sd = function(t) {
  var e, r = this;
  if (t !== void 0 && t !== !!t && t !== 1 && t !== 0) throw Error(df + t);
  return r.d ? (e = HG(r.d), t && r.e + 1 > e && (e = r.e + 1)) : e = NaN, e;
};
lt.round = function() {
  var t = this, e = t.constructor;
  return Ht(new e(t), t.e + 1, e.rounding);
};
lt.sine = lt.sin = function() {
  var t, e, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (t = n.precision, e = n.rounding, n.precision = t + Math.max(r.e, r.sd()) + Zt, n.rounding = 1, r = r1e(n, YG(n, r)), n.precision = t, n.rounding = e, Ht(hl > 2 ? r.neg() : r, t, e, !0)) : new n(NaN);
};
lt.squareRoot = lt.sqrt = function() {
  var t, e, r, n, i, a, o = this, s = o.d, u = o.e, c = o.s, l = o.constructor;
  if (c !== 1 || !s || !s[0])
    return new l(!c || c < 0 && (!s || s[0]) ? NaN : s ? o : 1 / 0);
  for (dr = !1, c = Math.sqrt(+o), c == 0 || c == 1 / 0 ? (e = Va(s), (e.length + u) % 2 == 0 && (e += "0"), c = Math.sqrt(e), u = no((u + 1) / 2) - (u < 0 || u % 2), c == 1 / 0 ? e = "5e" + u : (e = c.toExponential(), e = e.slice(0, e.indexOf("e") + 1) + u), n = new l(e)) : n = new l(c.toString()), r = (u = l.precision) + 3; ; )
    if (a = n, n = a.plus(Vn(o, a, r + 2, 1)).times(0.5), Va(a.d).slice(0, r) === (e = Va(n.d)).slice(0, r))
      if (e = e.slice(r - 3, r + 1), e == "9999" || !i && e == "4999") {
        if (!i && (Ht(a, u + 1, 0), a.times(a).eq(o))) {
          n = a;
          break;
        }
        r += 4, i = 1;
      } else {
        (!+e || !+e.slice(1) && e.charAt(0) == "5") && (Ht(n, u + 1, 1), t = !n.times(n).eq(o));
        break;
      }
  return dr = !0, Ht(n, u, l.rounding, t);
};
lt.tangent = lt.tan = function() {
  var t, e, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (t = n.precision, e = n.rounding, n.precision = t + 10, n.rounding = 1, r = r.sin(), r.s = 1, r = Vn(r, new n(1).minus(r.times(r)).sqrt(), t + 10, 0), n.precision = t, n.rounding = e, Ht(hl == 2 || hl == 4 ? r.neg() : r, t, e, !0)) : new n(NaN);
};
lt.times = lt.mul = function(t) {
  var e, r, n, i, a, o, s, u, c, l = this, d = l.constructor, f = l.d, h = (t = new d(t)).d;
  if (t.s *= l.s, !f || !f[0] || !h || !h[0])
    return new d(!t.s || f && !f[0] && !h || h && !h[0] && !f ? NaN : !f || !h ? t.s / 0 : t.s * 0);
  for (r = no(l.e / Zt) + no(t.e / Zt), u = f.length, c = h.length, u < c && (a = f, f = h, h = a, o = u, u = c, c = o), a = [], o = u + c, n = o; n--; ) a.push(0);
  for (n = c; --n >= 0; ) {
    for (e = 0, i = u + n; i > n; )
      s = a[i] + h[n] * f[i - n - 1] + e, a[i--] = s % Ou | 0, e = s / Ou | 0;
    a[i] = (a[i] + e) % Ou | 0;
  }
  for (; !a[--o]; ) a.pop();
  return e ? ++r : a.shift(), t.d = a, t.e = l4(a, r), dr ? Ht(t, d.precision, d.rounding) : t;
};
lt.toBinary = function(t, e) {
  return tS(this, 2, t, e);
};
lt.toDecimalPlaces = lt.toDP = function(t, e) {
  var r = this, n = r.constructor;
  return r = new n(r), t === void 0 ? r : (Yo(t, 0, gf), e === void 0 ? e = n.rounding : Yo(e, 0, 8), Ht(r, t + r.e + 1, e));
};
lt.toExponential = function(t, e) {
  var r, n = this, i = n.constructor;
  return t === void 0 ? r = wc(n, !0) : (Yo(t, 0, gf), e === void 0 ? e = i.rounding : Yo(e, 0, 8), n = Ht(new i(n), t + 1, e), r = wc(n, !0, t + 1)), n.isNeg() && !n.isZero() ? "-" + r : r;
};
lt.toFixed = function(t, e) {
  var r, n, i = this, a = i.constructor;
  return t === void 0 ? r = wc(i) : (Yo(t, 0, gf), e === void 0 ? e = a.rounding : Yo(e, 0, 8), n = Ht(new a(i), t + i.e + 1, e), r = wc(n, !1, t + n.e + 1)), i.isNeg() && !i.isZero() ? "-" + r : r;
};
lt.toFraction = function(t) {
  var e, r, n, i, a, o, s, u, c, l, d, f, h = this, m = h.d, p = h.constructor;
  if (!m) return new p(h);
  if (c = r = new p(1), n = u = new p(0), e = new p(n), a = e.e = HG(m) - h.e - 1, o = a % Zt, e.d[0] = ra(10, o < 0 ? Zt + o : o), t == null)
    t = a > 0 ? e : c;
  else {
    if (s = new p(t), !s.isInt() || s.lt(c)) throw Error(df + s);
    t = s.gt(e) ? a > 0 ? e : c : s;
  }
  for (dr = !1, s = new p(Va(m)), l = p.precision, p.precision = a = m.length * Zt * 2; d = Vn(s, e, 0, 1, 1), i = r.plus(d.times(n)), i.cmp(t) != 1; )
    r = n, n = i, i = c, c = u.plus(d.times(i)), u = i, i = e, e = s.minus(d.times(i)), s = i;
  return i = Vn(t.minus(r), n, 0, 1, 1), u = u.plus(i.times(c)), r = r.plus(i.times(n)), u.s = c.s = h.s, f = Vn(c, n, a, 1).minus(h).abs().cmp(Vn(u, r, a, 1).minus(h).abs()) < 1 ? [c, n] : [u, r], p.precision = l, dr = !0, f;
};
lt.toHexadecimal = lt.toHex = function(t, e) {
  return tS(this, 16, t, e);
};
lt.toNearest = function(t, e) {
  var r = this, n = r.constructor;
  if (r = new n(r), t == null) {
    if (!r.d) return r;
    t = new n(1), e = n.rounding;
  } else {
    if (t = new n(t), e === void 0 ? e = n.rounding : Yo(e, 0, 8), !r.d) return t.s ? r : t;
    if (!t.d)
      return t.s && (t.s = r.s), t;
  }
  return t.d[0] ? (dr = !1, r = Vn(r, t, 0, e, 1).times(t), dr = !0, Ht(r)) : (t.s = r.s, r = t), r;
};
lt.toNumber = function() {
  return +this;
};
lt.toOctal = function(t, e) {
  return tS(this, 8, t, e);
};
lt.toPower = lt.pow = function(t) {
  var e, r, n, i, a, o, s = this, u = s.constructor, c = +(t = new u(t));
  if (!s.d || !t.d || !s.d[0] || !t.d[0]) return new u(ra(+s, c));
  if (s = new u(s), s.eq(1)) return s;
  if (n = u.precision, a = u.rounding, t.eq(1)) return Ht(s, n, a);
  if (e = no(t.e / Zt), e >= t.d.length - 1 && (r = c < 0 ? -c : c) <= J0e)
    return i = qG(u, s, r, n), t.s < 0 ? new u(1).div(i) : Ht(i, n, a);
  if (o = s.s, o < 0) {
    if (e < t.d.length - 1) return new u(NaN);
    if (t.d[e] & 1 || (o = 1), s.e == 0 && s.d[0] == 1 && s.d.length == 1)
      return s.s = o, s;
  }
  return r = ra(+s, c), e = r == 0 || !isFinite(r) ? no(c * (Math.log("0." + Va(s.d)) / Math.LN10 + s.e + 1)) : new u(r + "").e, e > u.maxE + 1 || e < u.minE - 1 ? new u(e > 0 ? o / 0 : 0) : (dr = !1, u.rounding = s.s = 1, r = Math.min(12, (e + "").length), i = m9(t.times(Wd(s, n + r)), n), i.d && (i = Ht(i, n + 5, 1), u2(i.d, n, a) && (e = n + 10, i = Ht(m9(t.times(Wd(s, e + r)), e), e + 5, 1), +Va(i.d).slice(n + 1, n + 15) + 1 == 1e14 && (i = Ht(i, n + 1, 0)))), i.s = o, dr = !0, u.rounding = a, Ht(i, n, a));
};
lt.toPrecision = function(t, e) {
  var r, n = this, i = n.constructor;
  return t === void 0 ? r = wc(n, n.e <= i.toExpNeg || n.e >= i.toExpPos) : (Yo(t, 1, gf), e === void 0 ? e = i.rounding : Yo(e, 0, 8), n = Ht(new i(n), t, e), r = wc(n, t <= n.e || n.e <= i.toExpNeg, t)), n.isNeg() && !n.isZero() ? "-" + r : r;
};
lt.toSignificantDigits = lt.toSD = function(t, e) {
  var r = this, n = r.constructor;
  return t === void 0 ? (t = n.precision, e = n.rounding) : (Yo(t, 1, gf), e === void 0 ? e = n.rounding : Yo(e, 0, 8)), Ht(new n(r), t, e);
};
lt.toString = function() {
  var t = this, e = t.constructor, r = wc(t, t.e <= e.toExpNeg || t.e >= e.toExpPos);
  return t.isNeg() && !t.isZero() ? "-" + r : r;
};
lt.truncated = lt.trunc = function() {
  return Ht(new this.constructor(this), this.e + 1, 1);
};
lt.valueOf = lt.toJSON = function() {
  var t = this, e = t.constructor, r = wc(t, t.e <= e.toExpNeg || t.e >= e.toExpPos);
  return t.isNeg() ? "-" + r : r;
};
function Va(t) {
  var e, r, n, i = t.length - 1, a = "", o = t[0];
  if (i > 0) {
    for (a += o, e = 1; e < i; e++)
      n = t[e] + "", r = Zt - n.length, r && (a += Md(r)), a += n;
    o = t[e], n = o + "", r = Zt - n.length, r && (a += Md(r));
  } else if (o === 0)
    return "0";
  for (; o % 10 === 0; ) o /= 10;
  return a + o;
}
function Yo(t, e, r) {
  if (t !== ~~t || t < e || t > r)
    throw Error(df + t);
}
function u2(t, e, r, n) {
  var i, a, o, s;
  for (a = t[0]; a >= 10; a /= 10) --e;
  return --e < 0 ? (e += Zt, i = 0) : (i = Math.ceil((e + 1) / Zt), e %= Zt), a = ra(10, Zt - e), s = t[i] % a | 0, n == null ? e < 3 ? (e == 0 ? s = s / 100 | 0 : e == 1 && (s = s / 10 | 0), o = r < 4 && s == 99999 || r > 3 && s == 49999 || s == 5e4 || s == 0) : o = (r < 4 && s + 1 == a || r > 3 && s + 1 == a / 2) && (t[i + 1] / a / 100 | 0) == ra(10, e - 2) - 1 || (s == a / 2 || s == 0) && (t[i + 1] / a / 100 | 0) == 0 : e < 4 ? (e == 0 ? s = s / 1e3 | 0 : e == 1 ? s = s / 100 | 0 : e == 2 && (s = s / 10 | 0), o = (n || r < 4) && s == 9999 || !n && r > 3 && s == 4999) : o = ((n || r < 4) && s + 1 == a || !n && r > 3 && s + 1 == a / 2) && (t[i + 1] / a / 1e3 | 0) == ra(10, e - 3) - 1, o;
}
function l3(t, e, r) {
  for (var n, i = [0], a, o = 0, s = t.length; o < s; ) {
    for (a = i.length; a--; ) i[a] *= e;
    for (i[0] += f9.indexOf(t.charAt(o++)), n = 0; n < i.length; n++)
      i[n] > r - 1 && (i[n + 1] === void 0 && (i[n + 1] = 0), i[n + 1] += i[n] / r | 0, i[n] %= r);
  }
  return i.reverse();
}
function e1e(t, e) {
  var r, n, i;
  if (e.isZero()) return e;
  n = e.d.length, n < 32 ? (r = Math.ceil(n / 3), i = (1 / d4(4, r)).toString()) : (r = 16, i = "2.3283064365386962890625e-10"), t.precision += r, e = Hp(t, 1, e.times(i), new t(1));
  for (var a = r; a--; ) {
    var o = e.times(e);
    e = o.times(o).minus(o).times(8).plus(1);
  }
  return t.precision -= r, e;
}
var Vn = /* @__PURE__ */ function() {
  function t(n, i, a) {
    var o, s = 0, u = n.length;
    for (n = n.slice(); u--; )
      o = n[u] * i + s, n[u] = o % a | 0, s = o / a | 0;
    return s && n.unshift(s), n;
  }
  function e(n, i, a, o) {
    var s, u;
    if (a != o)
      u = a > o ? 1 : -1;
    else
      for (s = u = 0; s < a; s++)
        if (n[s] != i[s]) {
          u = n[s] > i[s] ? 1 : -1;
          break;
        }
    return u;
  }
  function r(n, i, a, o) {
    for (var s = 0; a--; )
      n[a] -= s, s = n[a] < i[a] ? 1 : 0, n[a] = s * o + n[a] - i[a];
    for (; !n[0] && n.length > 1; ) n.shift();
  }
  return function(n, i, a, o, s, u) {
    var c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T = n.constructor, F = n.s == i.s ? 1 : -1, N = n.d, R = i.d;
    if (!N || !N[0] || !R || !R[0])
      return new T(
        // Return NaN if either NaN, or both Infinity or 0.
        !n.s || !i.s || (N ? R && N[0] == R[0] : !R) ? NaN : (
          // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
          N && N[0] == 0 || !R ? F * 0 : F / 0
        )
      );
    for (u ? (h = 1, l = n.e - i.e) : (u = Ou, h = Zt, l = no(n.e / h) - no(i.e / h)), P = R.length, w = N.length, g = new T(F), y = g.d = [], d = 0; R[d] == (N[d] || 0); d++) ;
    if (R[d] > (N[d] || 0) && l--, a == null ? (x = a = T.precision, o = T.rounding) : s ? x = a + (n.e - i.e) + 1 : x = a, x < 0)
      y.push(1), m = !0;
    else {
      if (x = x / h + 2 | 0, d = 0, P == 1) {
        for (f = 0, R = R[0], x++; (d < w || f) && x--; d++)
          C = f * u + (N[d] || 0), y[d] = C / R | 0, f = C % R | 0;
        m = f || d < w;
      } else {
        for (f = u / (R[0] + 1) | 0, f > 1 && (R = t(R, f, u), N = t(N, f, u), P = R.length, w = N.length), A = P, b = N.slice(0, P), S = b.length; S < P; ) b[S++] = 0;
        M = R.slice(), M.unshift(0), I = R[0], R[1] >= u / 2 && ++I;
        do
          f = 0, c = e(R, b, P, S), c < 0 ? (_ = b[0], P != S && (_ = _ * u + (b[1] || 0)), f = _ / I | 0, f > 1 ? (f >= u && (f = u - 1), p = t(R, f, u), v = p.length, S = b.length, c = e(p, b, v, S), c == 1 && (f--, r(p, P < v ? M : R, v, u))) : (f == 0 && (c = f = 1), p = R.slice()), v = p.length, v < S && p.unshift(0), r(b, p, S, u), c == -1 && (S = b.length, c = e(R, b, P, S), c < 1 && (f++, r(b, P < S ? M : R, S, u))), S = b.length) : c === 0 && (f++, b = [0]), y[d++] = f, c && b[0] ? b[S++] = N[A] || 0 : (b = [N[A]], S = 1);
        while ((A++ < w || b[0] !== void 0) && x--);
        m = b[0] !== void 0;
      }
      y[0] || y.shift();
    }
    if (h == 1)
      g.e = l, kG = m;
    else {
      for (d = 1, f = y[0]; f >= 10; f /= 10) d++;
      g.e = d + l * h - 1, Ht(g, s ? a + g.e + 1 : a, o, m);
    }
    return g;
  };
}();
function Ht(t, e, r, n) {
  var i, a, o, s, u, c, l, d, f, h = t.constructor;
  e: if (e != null) {
    if (d = t.d, !d) return t;
    for (i = 1, s = d[0]; s >= 10; s /= 10) i++;
    if (a = e - i, a < 0)
      a += Zt, o = e, l = d[f = 0], u = l / ra(10, i - o - 1) % 10 | 0;
    else if (f = Math.ceil((a + 1) / Zt), s = d.length, f >= s)
      if (n) {
        for (; s++ <= f; ) d.push(0);
        l = u = 0, i = 1, a %= Zt, o = a - Zt + 1;
      } else
        break e;
    else {
      for (l = s = d[f], i = 1; s >= 10; s /= 10) i++;
      a %= Zt, o = a - Zt + i, u = o < 0 ? 0 : l / ra(10, i - o - 1) % 10 | 0;
    }
    if (n = n || e < 0 || d[f + 1] !== void 0 || (o < 0 ? l : l % ra(10, i - o - 1)), c = r < 4 ? (u || n) && (r == 0 || r == (t.s < 0 ? 3 : 2)) : u > 5 || u == 5 && (r == 4 || n || r == 6 && // Check whether the digit to the left of the rounding digit is odd.
    (a > 0 ? o > 0 ? l / ra(10, i - o) : 0 : d[f - 1]) % 10 & 1 || r == (t.s < 0 ? 8 : 7)), e < 1 || !d[0])
      return d.length = 0, c ? (e -= t.e + 1, d[0] = ra(10, (Zt - e % Zt) % Zt), t.e = -e || 0) : d[0] = t.e = 0, t;
    if (a == 0 ? (d.length = f, s = 1, f--) : (d.length = f + 1, s = ra(10, Zt - a), d[f] = o > 0 ? (l / ra(10, i - o) % ra(10, o) | 0) * s : 0), c)
      for (; ; )
        if (f == 0) {
          for (a = 1, o = d[0]; o >= 10; o /= 10) a++;
          for (o = d[0] += s, s = 1; o >= 10; o /= 10) s++;
          a != s && (t.e++, d[0] == Ou && (d[0] = 1));
          break;
        } else {
          if (d[f] += s, d[f] != Ou) break;
          d[f--] = 0, s = 1;
        }
    for (a = d.length; d[--a] === 0; ) d.pop();
  }
  return dr && (t.e > h.maxE ? (t.d = null, t.e = NaN) : t.e < h.minE && (t.e = 0, t.d = [0])), t;
}
function wc(t, e, r) {
  if (!t.isFinite()) return XG(t);
  var n, i = t.e, a = Va(t.d), o = a.length;
  return e ? (r && (n = r - o) > 0 ? a = a.charAt(0) + "." + a.slice(1) + Md(n) : o > 1 && (a = a.charAt(0) + "." + a.slice(1)), a = a + (t.e < 0 ? "e" : "e+") + t.e) : i < 0 ? (a = "0." + Md(-i - 1) + a, r && (n = r - o) > 0 && (a += Md(n))) : i >= o ? (a += Md(i + 1 - o), r && (n = r - i - 1) > 0 && (a = a + "." + Md(n))) : ((n = i + 1) < o && (a = a.slice(0, n) + "." + a.slice(n)), r && (n = r - o) > 0 && (i + 1 === o && (a += "."), a += Md(n))), a;
}
function l4(t, e) {
  var r = t[0];
  for (e *= Zt; r >= 10; r /= 10) e++;
  return e;
}
function gy(t, e, r) {
  if (e > $0e)
    throw dr = !0, r && (t.precision = r), Error(GG);
  return Ht(new t(hy), e, 1, !0);
}
function Nu(t, e, r) {
  if (e > h9) throw Error(GG);
  return Ht(new t(my), e, r, !0);
}
function HG(t) {
  var e = t.length - 1, r = e * Zt + 1;
  if (e = t[e], e) {
    for (; e % 10 == 0; e /= 10) r--;
    for (e = t[0]; e >= 10; e /= 10) r++;
  }
  return r;
}
function Md(t) {
  for (var e = ""; t--; ) e += "0";
  return e;
}
function qG(t, e, r, n) {
  var i, a = new t(1), o = Math.ceil(n / Zt + 4);
  for (dr = !1; ; ) {
    if (r % 2 && (a = a.times(e), LP(a.d, o) && (i = !0)), r = no(r / 2), r === 0) {
      r = a.d.length - 1, i && a.d[r] === 0 && ++a.d[r];
      break;
    }
    e = e.times(e), LP(e.d, o);
  }
  return dr = !0, a;
}
function OP(t) {
  return t.d[t.d.length - 1] & 1;
}
function KG(t, e, r) {
  for (var n, i = new t(e[0]), a = 0; ++a < e.length; )
    if (n = new t(e[a]), n.s)
      i[r](n) && (i = n);
    else {
      i = n;
      break;
    }
  return i;
}
function m9(t, e) {
  var r, n, i, a, o, s, u, c = 0, l = 0, d = 0, f = t.constructor, h = f.rounding, m = f.precision;
  if (!t.d || !t.d[0] || t.e > 17)
    return new f(t.d ? t.d[0] ? t.s < 0 ? 0 : 1 / 0 : 1 : t.s ? t.s < 0 ? 0 : t : NaN);
  for (e == null ? (dr = !1, u = m) : u = e, s = new f(0.03125); t.e > -2; )
    t = t.times(s), d += 5;
  for (n = Math.log(ra(2, d)) / Math.LN10 * 2 + 5 | 0, u += n, r = a = o = new f(1), f.precision = u; ; ) {
    if (a = Ht(a.times(t), u, 1), r = r.times(++l), s = o.plus(Vn(a, r, u, 1)), Va(s.d).slice(0, u) === Va(o.d).slice(0, u)) {
      for (i = d; i--; ) o = Ht(o.times(o), u, 1);
      if (e == null)
        if (c < 3 && u2(o.d, u - n, h, c))
          f.precision = u += 10, r = a = s = new f(1), l = 0, c++;
        else
          return Ht(o, f.precision = m, h, dr = !0);
      else
        return f.precision = m, o;
    }
    o = s;
  }
}
function Wd(t, e) {
  var r, n, i, a, o, s, u, c, l, d, f, h = 1, m = 10, p = t, v = p.d, g = p.constructor, y = g.rounding, b = g.precision;
  if (p.s < 0 || !v || !v[0] || !p.e && v[0] == 1 && v.length == 1)
    return new g(v && !v[0] ? -1 / 0 : p.s != 1 ? NaN : v ? 0 : p);
  if (e == null ? (dr = !1, l = b) : l = e, g.precision = l += m, r = Va(v), n = r.charAt(0), Math.abs(a = p.e) < 15e14) {
    for (; n < 7 && n != 1 || n == 1 && r.charAt(1) > 3; )
      p = p.times(t), r = Va(p.d), n = r.charAt(0), h++;
    a = p.e, n > 1 ? (p = new g("0." + r), a++) : p = new g(n + "." + r.slice(1));
  } else
    return c = gy(g, l + 2, b).times(a + ""), p = Wd(new g(n + "." + r.slice(1)), l - m).plus(c), g.precision = b, e == null ? Ht(p, b, y, dr = !0) : p;
  for (d = p, u = o = p = Vn(p.minus(1), p.plus(1), l, 1), f = Ht(p.times(p), l, 1), i = 3; ; ) {
    if (o = Ht(o.times(f), l, 1), c = u.plus(Vn(o, new g(i), l, 1)), Va(c.d).slice(0, l) === Va(u.d).slice(0, l))
      if (u = u.times(2), a !== 0 && (u = u.plus(gy(g, l + 2, b).times(a + ""))), u = Vn(u, new g(h), l, 1), e == null)
        if (u2(u.d, l - m, y, s))
          g.precision = l += m, c = o = p = Vn(d.minus(1), d.plus(1), l, 1), f = Ht(p.times(p), l, 1), i = s = 1;
        else
          return Ht(u, g.precision = b, y, dr = !0);
      else
        return g.precision = b, u;
    u = c, i += 2;
  }
}
function XG(t) {
  return String(t.s * t.s / 0);
}
function g9(t, e) {
  var r, n, i;
  for ((r = e.indexOf(".")) > -1 && (e = e.replace(".", "")), (n = e.search(/e/i)) > 0 ? (r < 0 && (r = n), r += +e.slice(n + 1), e = e.substring(0, n)) : r < 0 && (r = e.length), n = 0; e.charCodeAt(n) === 48; n++) ;
  for (i = e.length; e.charCodeAt(i - 1) === 48; --i) ;
  if (e = e.slice(n, i), e) {
    if (i -= n, t.e = r = r - n - 1, t.d = [], n = (r + 1) % Zt, r < 0 && (n += Zt), n < i) {
      for (n && t.d.push(+e.slice(0, n)), i -= Zt; n < i; ) t.d.push(+e.slice(n, n += Zt));
      e = e.slice(n), n = Zt - e.length;
    } else
      n -= i;
    for (; n--; ) e += "0";
    t.d.push(+e), dr && (t.e > t.constructor.maxE ? (t.d = null, t.e = NaN) : t.e < t.constructor.minE && (t.e = 0, t.d = [0]));
  } else
    t.e = 0, t.d = [0];
  return t;
}
function t1e(t, e) {
  var r, n, i, a, o, s, u, c, l;
  if (e.indexOf("_") > -1) {
    if (e = e.replace(/(\d)_(?=\d)/g, "$1"), UG.test(e)) return g9(t, e);
  } else if (e === "Infinity" || e === "NaN")
    return +e || (t.s = NaN), t.e = NaN, t.d = null, t;
  if (Z0e.test(e))
    r = 16, e = e.toLowerCase();
  else if (j0e.test(e))
    r = 2;
  else if (Q0e.test(e))
    r = 8;
  else
    throw Error(df + e);
  for (a = e.search(/p/i), a > 0 ? (u = +e.slice(a + 1), e = e.substring(2, a)) : e = e.slice(2), a = e.indexOf("."), o = a >= 0, n = t.constructor, o && (e = e.replace(".", ""), s = e.length, a = s - a, i = qG(n, new n(r), a, a * 2)), c = l3(e, r, Ou), l = c.length - 1, a = l; c[a] === 0; --a) c.pop();
  return a < 0 ? new n(t.s * 0) : (t.e = l4(c, l), t.d = c, dr = !1, o && (t = Vn(t, i, s * 4)), u && (t = t.times(Math.abs(u) < 54 ? ra(2, u) : B0.pow(2, u))), dr = !0, t);
}
function r1e(t, e) {
  var r, n = e.d.length;
  if (n < 3)
    return e.isZero() ? e : Hp(t, 2, e, e);
  r = 1.4 * Math.sqrt(n), r = r > 16 ? 16 : r | 0, e = e.times(1 / d4(5, r)), e = Hp(t, 2, e, e);
  for (var i, a = new t(5), o = new t(16), s = new t(20); r--; )
    i = e.times(e), e = e.times(a.plus(i.times(o.times(i).minus(s))));
  return e;
}
function Hp(t, e, r, n, i) {
  var a, o, s, u, c = t.precision, l = Math.ceil(c / Zt);
  for (dr = !1, u = r.times(r), s = new t(n); ; ) {
    if (o = Vn(s.times(u), new t(e++ * e++), c, 1), s = i ? n.plus(o) : n.minus(o), n = Vn(o.times(u), new t(e++ * e++), c, 1), o = s.plus(n), o.d[l] !== void 0) {
      for (a = l; o.d[a] === s.d[a] && a--; ) ;
      if (a == -1) break;
    }
    a = s, s = n, n = o, o = a;
  }
  return dr = !0, o.d.length = l + 1, o;
}
function d4(t, e) {
  for (var r = t; --e; ) r *= t;
  return r;
}
function YG(t, e) {
  var r, n = e.s < 0, i = Nu(t, t.precision, 1), a = i.times(0.5);
  if (e = e.abs(), e.lte(a))
    return hl = n ? 4 : 1, e;
  if (r = e.divToInt(i), r.isZero())
    hl = n ? 3 : 2;
  else {
    if (e = e.minus(r.times(i)), e.lte(a))
      return hl = OP(r) ? n ? 2 : 3 : n ? 4 : 1, e;
    hl = OP(r) ? n ? 1 : 4 : n ? 3 : 2;
  }
  return e.minus(i).abs();
}
function tS(t, e, r, n) {
  var i, a, o, s, u, c, l, d, f, h = t.constructor, m = r !== void 0;
  if (m ? (Yo(r, 1, gf), n === void 0 ? n = h.rounding : Yo(n, 0, 8)) : (r = h.precision, n = h.rounding), !t.isFinite())
    l = XG(t);
  else {
    for (l = wc(t), o = l.indexOf("."), m ? (i = 2, e == 16 ? r = r * 4 - 3 : e == 8 && (r = r * 3 - 2)) : i = e, o >= 0 && (l = l.replace(".", ""), f = new h(1), f.e = l.length - o, f.d = l3(wc(f), 10, i), f.e = f.d.length), d = l3(l, 10, i), a = u = d.length; d[--u] == 0; ) d.pop();
    if (!d[0])
      l = m ? "0p+0" : "0";
    else {
      if (o < 0 ? a-- : (t = new h(t), t.d = d, t.e = a, t = Vn(t, f, r, n, 0, i), d = t.d, a = t.e, c = kG), o = d[r], s = i / 2, c = c || d[r + 1] !== void 0, c = n < 4 ? (o !== void 0 || c) && (n === 0 || n === (t.s < 0 ? 3 : 2)) : o > s || o === s && (n === 4 || c || n === 6 && d[r - 1] & 1 || n === (t.s < 0 ? 8 : 7)), d.length = r, c)
        for (; ++d[--r] > i - 1; )
          d[r] = 0, r || (++a, d.unshift(1));
      for (u = d.length; !d[u - 1]; --u) ;
      for (o = 0, l = ""; o < u; o++) l += f9.charAt(d[o]);
      if (m) {
        if (u > 1)
          if (e == 16 || e == 8) {
            for (o = e == 16 ? 4 : 3, --u; u % o; u++) l += "0";
            for (d = l3(l, i, e), u = d.length; !d[u - 1]; --u) ;
            for (o = 1, l = "1."; o < u; o++) l += f9.charAt(d[o]);
          } else
            l = l.charAt(0) + "." + l.slice(1);
        l = l + (a < 0 ? "p" : "p+") + a;
      } else if (a < 0) {
        for (; ++a; ) l = "0" + l;
        l = "0." + l;
      } else if (++a > u) for (a -= u; a--; ) l += "0";
      else a < u && (l = l.slice(0, a) + "." + l.slice(a));
    }
    l = (e == 16 ? "0x" : e == 2 ? "0b" : e == 8 ? "0o" : "") + l;
  }
  return t.s < 0 ? "-" + l : l;
}
function LP(t, e) {
  if (t.length > e)
    return t.length = e, !0;
}
function n1e(t) {
  return new this(t).abs();
}
function i1e(t) {
  return new this(t).acos();
}
function a1e(t) {
  return new this(t).acosh();
}
function o1e(t, e) {
  return new this(t).plus(e);
}
function s1e(t) {
  return new this(t).asin();
}
function u1e(t) {
  return new this(t).asinh();
}
function c1e(t) {
  return new this(t).atan();
}
function l1e(t) {
  return new this(t).atanh();
}
function d1e(t, e) {
  t = new this(t), e = new this(e);
  var r, n = this.precision, i = this.rounding, a = n + 4;
  return !t.s || !e.s ? r = new this(NaN) : !t.d && !e.d ? (r = Nu(this, a, 1).times(e.s > 0 ? 0.25 : 0.75), r.s = t.s) : !e.d || t.isZero() ? (r = e.s < 0 ? Nu(this, n, i) : new this(0), r.s = t.s) : !t.d || e.isZero() ? (r = Nu(this, a, 1).times(0.5), r.s = t.s) : e.s < 0 ? (this.precision = a, this.rounding = 1, r = this.atan(Vn(t, e, a, 1)), e = Nu(this, a, 1), this.precision = n, this.rounding = i, r = t.s < 0 ? r.minus(e) : r.plus(e)) : r = this.atan(Vn(t, e, a, 1)), r;
}
function f1e(t) {
  return new this(t).cbrt();
}
function p1e(t) {
  return Ht(t = new this(t), t.e + 1, 2);
}
function h1e(t, e, r) {
  return new this(t).clamp(e, r);
}
function m1e(t) {
  if (!t || typeof t != "object") throw Error(c4 + "Object expected");
  var e, r, n, i = t.defaults === !0, a = [
    "precision",
    1,
    gf,
    "rounding",
    0,
    8,
    "toExpNeg",
    -ip,
    0,
    "toExpPos",
    0,
    ip,
    "maxE",
    0,
    ip,
    "minE",
    -ip,
    0,
    "modulo",
    0,
    9
  ];
  for (e = 0; e < a.length; e += 3)
    if (r = a[e], i && (this[r] = p9[r]), (n = t[r]) !== void 0)
      if (no(n) === n && n >= a[e + 1] && n <= a[e + 2]) this[r] = n;
      else throw Error(df + r + ": " + n);
  if (r = "crypto", i && (this[r] = p9[r]), (n = t[r]) !== void 0)
    if (n === !0 || n === !1 || n === 0 || n === 1)
      if (n)
        if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
          this[r] = !0;
        else
          throw Error(zG);
      else
        this[r] = !1;
    else
      throw Error(df + r + ": " + n);
  return this;
}
function g1e(t) {
  return new this(t).cos();
}
function v1e(t) {
  return new this(t).cosh();
}
function WG(t) {
  var e, r, n;
  function i(a) {
    var o, s, u, c = this;
    if (!(c instanceof i)) return new i(a);
    if (c.constructor = i, kP(a)) {
      c.s = a.s, dr ? !a.d || a.e > i.maxE ? (c.e = NaN, c.d = null) : a.e < i.minE ? (c.e = 0, c.d = [0]) : (c.e = a.e, c.d = a.d.slice()) : (c.e = a.e, c.d = a.d ? a.d.slice() : a.d);
      return;
    }
    if (u = typeof a, u === "number") {
      if (a === 0) {
        c.s = 1 / a < 0 ? -1 : 1, c.e = 0, c.d = [0];
        return;
      }
      if (a < 0 ? (a = -a, c.s = -1) : c.s = 1, a === ~~a && a < 1e7) {
        for (o = 0, s = a; s >= 10; s /= 10) o++;
        dr ? o > i.maxE ? (c.e = NaN, c.d = null) : o < i.minE ? (c.e = 0, c.d = [0]) : (c.e = o, c.d = [a]) : (c.e = o, c.d = [a]);
        return;
      } else if (a * 0 !== 0) {
        a || (c.s = NaN), c.e = NaN, c.d = null;
        return;
      }
      return g9(c, a.toString());
    } else if (u !== "string")
      throw Error(df + a);
    return (s = a.charCodeAt(0)) === 45 ? (a = a.slice(1), c.s = -1) : (s === 43 && (a = a.slice(1)), c.s = 1), UG.test(a) ? g9(c, a) : t1e(c, a);
  }
  if (i.prototype = lt, i.ROUND_UP = 0, i.ROUND_DOWN = 1, i.ROUND_CEIL = 2, i.ROUND_FLOOR = 3, i.ROUND_HALF_UP = 4, i.ROUND_HALF_DOWN = 5, i.ROUND_HALF_EVEN = 6, i.ROUND_HALF_CEIL = 7, i.ROUND_HALF_FLOOR = 8, i.EUCLID = 9, i.config = i.set = m1e, i.clone = WG, i.isDecimal = kP, i.abs = n1e, i.acos = i1e, i.acosh = a1e, i.add = o1e, i.asin = s1e, i.asinh = u1e, i.atan = c1e, i.atanh = l1e, i.atan2 = d1e, i.cbrt = f1e, i.ceil = p1e, i.clamp = h1e, i.cos = g1e, i.cosh = v1e, i.div = y1e, i.exp = b1e, i.floor = _1e, i.hypot = x1e, i.ln = S1e, i.log = C1e, i.log10 = w1e, i.log2 = A1e, i.max = D1e, i.min = E1e, i.mod = I1e, i.mul = T1e, i.pow = M1e, i.random = P1e, i.round = B1e, i.sign = F1e, i.sin = N1e, i.sinh = R1e, i.sqrt = O1e, i.sub = L1e, i.sum = k1e, i.tan = G1e, i.tanh = z1e, i.trunc = V1e, t === void 0 && (t = {}), t && t.defaults !== !0)
    for (n = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], e = 0; e < n.length; ) t.hasOwnProperty(r = n[e++]) || (t[r] = this[r]);
  return i.config(t), i;
}
function y1e(t, e) {
  return new this(t).div(e);
}
function b1e(t) {
  return new this(t).exp();
}
function _1e(t) {
  return Ht(t = new this(t), t.e + 1, 3);
}
function x1e() {
  var t, e, r = new this(0);
  for (dr = !1, t = 0; t < arguments.length; )
    if (e = new this(arguments[t++]), e.d)
      r.d && (r = r.plus(e.times(e)));
    else {
      if (e.s)
        return dr = !0, new this(1 / 0);
      r = e;
    }
  return dr = !0, r.sqrt();
}
function kP(t) {
  return t instanceof B0 || t && t.toStringTag === VG || !1;
}
function S1e(t) {
  return new this(t).ln();
}
function C1e(t, e) {
  return new this(t).log(e);
}
function A1e(t) {
  return new this(t).log(2);
}
function w1e(t) {
  return new this(t).log(10);
}
function D1e() {
  return KG(this, arguments, "lt");
}
function E1e() {
  return KG(this, arguments, "gt");
}
function I1e(t, e) {
  return new this(t).mod(e);
}
function T1e(t, e) {
  return new this(t).mul(e);
}
function M1e(t, e) {
  return new this(t).pow(e);
}
function P1e(t) {
  var e, r, n, i, a = 0, o = new this(1), s = [];
  if (t === void 0 ? t = this.precision : Yo(t, 1, gf), n = Math.ceil(t / Zt), this.crypto)
    if (crypto.getRandomValues)
      for (e = crypto.getRandomValues(new Uint32Array(n)); a < n; )
        i = e[a], i >= 429e7 ? e[a] = crypto.getRandomValues(new Uint32Array(1))[0] : s[a++] = i % 1e7;
    else if (crypto.randomBytes) {
      for (e = crypto.randomBytes(n *= 4); a < n; )
        i = e[a] + (e[a + 1] << 8) + (e[a + 2] << 16) + ((e[a + 3] & 127) << 24), i >= 214e7 ? crypto.randomBytes(4).copy(e, a) : (s.push(i % 1e7), a += 4);
      a = n / 4;
    } else
      throw Error(zG);
  else for (; a < n; ) s[a++] = Math.random() * 1e7 | 0;
  for (n = s[--a], t %= Zt, n && t && (i = ra(10, Zt - t), s[a] = (n / i | 0) * i); s[a] === 0; a--) s.pop();
  if (a < 0)
    r = 0, s = [0];
  else {
    for (r = -1; s[0] === 0; r -= Zt) s.shift();
    for (n = 1, i = s[0]; i >= 10; i /= 10) n++;
    n < Zt && (r -= Zt - n);
  }
  return o.e = r, o.d = s, o;
}
function B1e(t) {
  return Ht(t = new this(t), t.e + 1, this.rounding);
}
function F1e(t) {
  return t = new this(t), t.d ? t.d[0] ? t.s : 0 * t.s : t.s || NaN;
}
function N1e(t) {
  return new this(t).sin();
}
function R1e(t) {
  return new this(t).sinh();
}
function O1e(t) {
  return new this(t).sqrt();
}
function L1e(t, e) {
  return new this(t).sub(e);
}
function k1e() {
  var t = 0, e = arguments, r = new this(e[t]);
  for (dr = !1; r.s && ++t < e.length; ) r = r.plus(e[t]);
  return dr = !0, Ht(r, this.precision, this.rounding);
}
function G1e(t) {
  return new this(t).tan();
}
function z1e(t) {
  return new this(t).tanh();
}
function V1e(t) {
  return Ht(t = new this(t), t.e + 1, 1);
}
lt[Symbol.for("nodejs.util.inspect.custom")] = lt.toString;
lt[Symbol.toStringTag] = "Decimal";
var B0 = lt.constructor = WG(p9);
hy = new B0(hy);
my = new B0(my);
var U1e = "BigNumber", H1e = ["?on", "config"], q1e = /* @__PURE__ */ vt(U1e, H1e, (t) => {
  var {
    on: e,
    config: r
  } = t, n = B0.clone({
    precision: r.precision,
    modulo: B0.EUCLID
  });
  return n.prototype = Object.create(n.prototype), n.prototype.type = "BigNumber", n.prototype.isBigNumber = !0, n.prototype.toJSON = function() {
    return {
      mathjs: "BigNumber",
      value: this.toString()
    };
  }, n.fromJSON = function(i) {
    return new n(i.value);
  }, e && e("config", function(i, a) {
    i.precision !== a.precision && n.config({
      precision: i.precision
    });
  }), n;
}, {
  isClass: !0
}), o0 = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function K1e(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var jG = { exports: {} };
/**
 * @license Complex.js v2.1.1 12/05/2020
 *
 * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 **/
(function(t, e) {
  (function(r) {
    var n = Math.cosh || function(d) {
      return Math.abs(d) < 1e-9 ? 1 - d : (Math.exp(d) + Math.exp(-d)) * 0.5;
    }, i = Math.sinh || function(d) {
      return Math.abs(d) < 1e-9 ? d : (Math.exp(d) - Math.exp(-d)) * 0.5;
    }, a = function(d) {
      var f = Math.PI / 4;
      if (-f > d || d > f)
        return Math.cos(d) - 1;
      var h = d * d;
      return h * (h * (h * (h * (h * (h * (h * (h / 20922789888e3 - 1 / 87178291200) + 1 / 479001600) - 1 / 3628800) + 1 / 40320) - 1 / 720) + 1 / 24) - 1 / 2);
    }, o = function(d, f) {
      var h = Math.abs(d), m = Math.abs(f);
      return h < 3e3 && m < 3e3 ? Math.sqrt(h * h + m * m) : (h < m ? (h = m, m = d / f) : m = f / d, h * Math.sqrt(1 + m * m));
    }, s = function() {
      throw SyntaxError("Invalid Param");
    };
    function u(d, f) {
      var h = Math.abs(d), m = Math.abs(f);
      return d === 0 ? Math.log(m) : f === 0 ? Math.log(h) : h < 3e3 && m < 3e3 ? Math.log(d * d + f * f) * 0.5 : (d = d / 2, f = f / 2, 0.5 * Math.log(d * d + f * f) + Math.LN2);
    }
    var c = function(d, f) {
      var h = { re: 0, im: 0 };
      if (d == null)
        h.re = h.im = 0;
      else if (f !== void 0)
        h.re = d, h.im = f;
      else
        switch (typeof d) {
          case "object":
            if ("im" in d && "re" in d)
              h.re = d.re, h.im = d.im;
            else if ("abs" in d && "arg" in d) {
              if (!Number.isFinite(d.abs) && Number.isFinite(d.arg))
                return l.INFINITY;
              h.re = d.abs * Math.cos(d.arg), h.im = d.abs * Math.sin(d.arg);
            } else if ("r" in d && "phi" in d) {
              if (!Number.isFinite(d.r) && Number.isFinite(d.phi))
                return l.INFINITY;
              h.re = d.r * Math.cos(d.phi), h.im = d.r * Math.sin(d.phi);
            } else d.length === 2 ? (h.re = d[0], h.im = d[1]) : s();
            break;
          case "string":
            h.im = /* void */
            h.re = 0;
            var m = d.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g), p = 1, v = 0;
            m === null && s();
            for (var g = 0; g < m.length; g++) {
              var y = m[g];
              y === " " || y === "	" || y === `
` || (y === "+" ? p++ : y === "-" ? v++ : y === "i" || y === "I" ? (p + v === 0 && s(), m[g + 1] !== " " && !isNaN(m[g + 1]) ? (h.im += parseFloat((v % 2 ? "-" : "") + m[g + 1]), g++) : h.im += parseFloat((v % 2 ? "-" : "") + "1"), p = v = 0) : ((p + v === 0 || isNaN(y)) && s(), m[g + 1] === "i" || m[g + 1] === "I" ? (h.im += parseFloat((v % 2 ? "-" : "") + y), g++) : h.re += parseFloat((v % 2 ? "-" : "") + y), p = v = 0));
            }
            p + v > 0 && s();
            break;
          case "number":
            h.im = 0, h.re = d;
            break;
          default:
            s();
        }
      return isNaN(h.re) || isNaN(h.im), h;
    };
    function l(d, f) {
      if (!(this instanceof l))
        return new l(d, f);
      var h = c(d, f);
      this.re = h.re, this.im = h.im;
    }
    l.prototype = {
      re: 0,
      im: 0,
      /**
       * Calculates the sign of a complex number, which is a normalized complex
       *
       * @returns {Complex}
       */
      sign: function() {
        var d = this.abs();
        return new l(
          this.re / d,
          this.im / d
        );
      },
      /**
       * Adds two complex numbers
       *
       * @returns {Complex}
       */
      add: function(d, f) {
        var h = new l(d, f);
        return this.isInfinite() && h.isInfinite() ? l.NAN : this.isInfinite() || h.isInfinite() ? l.INFINITY : new l(
          this.re + h.re,
          this.im + h.im
        );
      },
      /**
       * Subtracts two complex numbers
       *
       * @returns {Complex}
       */
      sub: function(d, f) {
        var h = new l(d, f);
        return this.isInfinite() && h.isInfinite() ? l.NAN : this.isInfinite() || h.isInfinite() ? l.INFINITY : new l(
          this.re - h.re,
          this.im - h.im
        );
      },
      /**
       * Multiplies two complex numbers
       *
       * @returns {Complex}
       */
      mul: function(d, f) {
        var h = new l(d, f);
        return this.isInfinite() && h.isZero() || this.isZero() && h.isInfinite() ? l.NAN : this.isInfinite() || h.isInfinite() ? l.INFINITY : h.im === 0 && this.im === 0 ? new l(this.re * h.re, 0) : new l(
          this.re * h.re - this.im * h.im,
          this.re * h.im + this.im * h.re
        );
      },
      /**
       * Divides two complex numbers
       *
       * @returns {Complex}
       */
      div: function(d, f) {
        var h = new l(d, f);
        if (this.isZero() && h.isZero() || this.isInfinite() && h.isInfinite())
          return l.NAN;
        if (this.isInfinite() || h.isZero())
          return l.INFINITY;
        if (this.isZero() || h.isInfinite())
          return l.ZERO;
        d = this.re, f = this.im;
        var m = h.re, p = h.im, v, g;
        return p === 0 ? new l(d / m, f / m) : Math.abs(m) < Math.abs(p) ? (g = m / p, v = m * g + p, new l(
          (d * g + f) / v,
          (f * g - d) / v
        )) : (g = p / m, v = p * g + m, new l(
          (d + f * g) / v,
          (f - d * g) / v
        ));
      },
      /**
       * Calculate the power of two complex numbers
       *
       * @returns {Complex}
       */
      pow: function(d, f) {
        var h = new l(d, f);
        if (d = this.re, f = this.im, h.isZero())
          return l.ONE;
        if (h.im === 0) {
          if (f === 0 && d > 0)
            return new l(Math.pow(d, h.re), 0);
          if (d === 0)
            switch ((h.re % 4 + 4) % 4) {
              case 0:
                return new l(Math.pow(f, h.re), 0);
              case 1:
                return new l(0, Math.pow(f, h.re));
              case 2:
                return new l(-Math.pow(f, h.re), 0);
              case 3:
                return new l(0, -Math.pow(f, h.re));
            }
        }
        if (d === 0 && f === 0 && h.re > 0 && h.im >= 0)
          return l.ZERO;
        var m = Math.atan2(f, d), p = u(d, f);
        return d = Math.exp(h.re * p - h.im * m), f = h.im * p + h.re * m, new l(
          d * Math.cos(f),
          d * Math.sin(f)
        );
      },
      /**
       * Calculate the complex square root
       *
       * @returns {Complex}
       */
      sqrt: function() {
        var d = this.re, f = this.im, h = this.abs(), m, p;
        if (d >= 0) {
          if (f === 0)
            return new l(Math.sqrt(d), 0);
          m = 0.5 * Math.sqrt(2 * (h + d));
        } else
          m = Math.abs(f) / Math.sqrt(2 * (h - d));
        return d <= 0 ? p = 0.5 * Math.sqrt(2 * (h - d)) : p = Math.abs(f) / Math.sqrt(2 * (h + d)), new l(m, f < 0 ? -p : p);
      },
      /**
       * Calculate the complex exponent
       *
       * @returns {Complex}
       */
      exp: function() {
        var d = Math.exp(this.re);
        return this.im, new l(
          d * Math.cos(this.im),
          d * Math.sin(this.im)
        );
      },
      /**
       * Calculate the complex exponent and subtracts one.
       *
       * This may be more accurate than `Complex(x).exp().sub(1)` if
       * `x` is small.
       *
       * @returns {Complex}
       */
      expm1: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.expm1(d) * Math.cos(f) + a(f),
          Math.exp(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the natural log
       *
       * @returns {Complex}
       */
      log: function() {
        var d = this.re, f = this.im;
        return new l(
          u(d, f),
          Math.atan2(f, d)
        );
      },
      /**
       * Calculate the magnitude of the complex number
       *
       * @returns {number}
       */
      abs: function() {
        return o(this.re, this.im);
      },
      /**
       * Calculate the angle of the complex number
       *
       * @returns {number}
       */
      arg: function() {
        return Math.atan2(this.im, this.re);
      },
      /**
       * Calculate the sine of the complex number
       *
       * @returns {Complex}
       */
      sin: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.sin(d) * n(f),
          Math.cos(d) * i(f)
        );
      },
      /**
       * Calculate the cosine
       *
       * @returns {Complex}
       */
      cos: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.cos(d) * n(f),
          -Math.sin(d) * i(f)
        );
      },
      /**
       * Calculate the tangent
       *
       * @returns {Complex}
       */
      tan: function() {
        var d = 2 * this.re, f = 2 * this.im, h = Math.cos(d) + n(f);
        return new l(
          Math.sin(d) / h,
          i(f) / h
        );
      },
      /**
       * Calculate the cotangent
       *
       * @returns {Complex}
       */
      cot: function() {
        var d = 2 * this.re, f = 2 * this.im, h = Math.cos(d) - n(f);
        return new l(
          -Math.sin(d) / h,
          i(f) / h
        );
      },
      /**
       * Calculate the secant
       *
       * @returns {Complex}
       */
      sec: function() {
        var d = this.re, f = this.im, h = 0.5 * n(2 * f) + 0.5 * Math.cos(2 * d);
        return new l(
          Math.cos(d) * n(f) / h,
          Math.sin(d) * i(f) / h
        );
      },
      /**
       * Calculate the cosecans
       *
       * @returns {Complex}
       */
      csc: function() {
        var d = this.re, f = this.im, h = 0.5 * n(2 * f) - 0.5 * Math.cos(2 * d);
        return new l(
          Math.sin(d) * n(f) / h,
          -Math.cos(d) * i(f) / h
        );
      },
      /**
       * Calculate the complex arcus sinus
       *
       * @returns {Complex}
       */
      asin: function() {
        var d = this.re, f = this.im, h = new l(
          f * f - d * d + 1,
          -2 * d * f
        ).sqrt(), m = new l(
          h.re - f,
          h.im + d
        ).log();
        return new l(m.im, -m.re);
      },
      /**
       * Calculate the complex arcus cosinus
       *
       * @returns {Complex}
       */
      acos: function() {
        var d = this.re, f = this.im, h = new l(
          f * f - d * d + 1,
          -2 * d * f
        ).sqrt(), m = new l(
          h.re - f,
          h.im + d
        ).log();
        return new l(Math.PI / 2 - m.im, m.re);
      },
      /**
       * Calculate the complex arcus tangent
       *
       * @returns {Complex}
       */
      atan: function() {
        var d = this.re, f = this.im;
        if (d === 0) {
          if (f === 1)
            return new l(0, 1 / 0);
          if (f === -1)
            return new l(0, -1 / 0);
        }
        var h = d * d + (1 - f) * (1 - f), m = new l(
          (1 - f * f - d * d) / h,
          -2 * d / h
        ).log();
        return new l(-0.5 * m.im, 0.5 * m.re);
      },
      /**
       * Calculate the complex arcus cotangent
       *
       * @returns {Complex}
       */
      acot: function() {
        var d = this.re, f = this.im;
        if (f === 0)
          return new l(Math.atan2(1, d), 0);
        var h = d * d + f * f;
        return h !== 0 ? new l(
          d / h,
          -f / h
        ).atan() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).atan();
      },
      /**
       * Calculate the complex arcus secant
       *
       * @returns {Complex}
       */
      asec: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(0, 1 / 0);
        var h = d * d + f * f;
        return h !== 0 ? new l(
          d / h,
          -f / h
        ).acos() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).acos();
      },
      /**
       * Calculate the complex arcus cosecans
       *
       * @returns {Complex}
       */
      acsc: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(Math.PI / 2, 1 / 0);
        var h = d * d + f * f;
        return h !== 0 ? new l(
          d / h,
          -f / h
        ).asin() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).asin();
      },
      /**
       * Calculate the complex sinh
       *
       * @returns {Complex}
       */
      sinh: function() {
        var d = this.re, f = this.im;
        return new l(
          i(d) * Math.cos(f),
          n(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the complex cosh
       *
       * @returns {Complex}
       */
      cosh: function() {
        var d = this.re, f = this.im;
        return new l(
          n(d) * Math.cos(f),
          i(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the complex tanh
       *
       * @returns {Complex}
       */
      tanh: function() {
        var d = 2 * this.re, f = 2 * this.im, h = n(d) + Math.cos(f);
        return new l(
          i(d) / h,
          Math.sin(f) / h
        );
      },
      /**
       * Calculate the complex coth
       *
       * @returns {Complex}
       */
      coth: function() {
        var d = 2 * this.re, f = 2 * this.im, h = n(d) - Math.cos(f);
        return new l(
          i(d) / h,
          -Math.sin(f) / h
        );
      },
      /**
       * Calculate the complex coth
       *
       * @returns {Complex}
       */
      csch: function() {
        var d = this.re, f = this.im, h = Math.cos(2 * f) - n(2 * d);
        return new l(
          -2 * i(d) * Math.cos(f) / h,
          2 * n(d) * Math.sin(f) / h
        );
      },
      /**
       * Calculate the complex sech
       *
       * @returns {Complex}
       */
      sech: function() {
        var d = this.re, f = this.im, h = Math.cos(2 * f) + n(2 * d);
        return new l(
          2 * n(d) * Math.cos(f) / h,
          -2 * i(d) * Math.sin(f) / h
        );
      },
      /**
       * Calculate the complex asinh
       *
       * @returns {Complex}
       */
      asinh: function() {
        var d = this.im;
        this.im = -this.re, this.re = d;
        var f = this.asin();
        return this.re = -this.im, this.im = d, d = f.re, f.re = -f.im, f.im = d, f;
      },
      /**
       * Calculate the complex acosh
       *
       * @returns {Complex}
       */
      acosh: function() {
        var d = this.acos();
        if (d.im <= 0) {
          var f = d.re;
          d.re = -d.im, d.im = f;
        } else {
          var f = d.im;
          d.im = -d.re, d.re = f;
        }
        return d;
      },
      /**
       * Calculate the complex atanh
       *
       * @returns {Complex}
       */
      atanh: function() {
        var d = this.re, f = this.im, h = d > 1 && f === 0, m = 1 - d, p = 1 + d, v = m * m + f * f, g = v !== 0 ? new l(
          (p * m - f * f) / v,
          (f * m + p * f) / v
        ) : new l(
          d !== -1 ? d / 0 : 0,
          f !== 0 ? f / 0 : 0
        ), y = g.re;
        return g.re = u(g.re, g.im) / 2, g.im = Math.atan2(g.im, y) / 2, h && (g.im = -g.im), g;
      },
      /**
       * Calculate the complex acoth
       *
       * @returns {Complex}
       */
      acoth: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(0, Math.PI / 2);
        var h = d * d + f * f;
        return h !== 0 ? new l(
          d / h,
          -f / h
        ).atanh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).atanh();
      },
      /**
       * Calculate the complex acsch
       *
       * @returns {Complex}
       */
      acsch: function() {
        var d = this.re, f = this.im;
        if (f === 0)
          return new l(
            d !== 0 ? Math.log(d + Math.sqrt(d * d + 1)) : 1 / 0,
            0
          );
        var h = d * d + f * f;
        return h !== 0 ? new l(
          d / h,
          -f / h
        ).asinh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).asinh();
      },
      /**
       * Calculate the complex asech
       *
       * @returns {Complex}
       */
      asech: function() {
        var d = this.re, f = this.im;
        if (this.isZero())
          return l.INFINITY;
        var h = d * d + f * f;
        return h !== 0 ? new l(
          d / h,
          -f / h
        ).acosh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).acosh();
      },
      /**
       * Calculate the complex inverse 1/z
       *
       * @returns {Complex}
       */
      inverse: function() {
        if (this.isZero())
          return l.INFINITY;
        if (this.isInfinite())
          return l.ZERO;
        var d = this.re, f = this.im, h = d * d + f * f;
        return new l(d / h, -f / h);
      },
      /**
       * Returns the complex conjugate
       *
       * @returns {Complex}
       */
      conjugate: function() {
        return new l(this.re, -this.im);
      },
      /**
       * Gets the negated complex number
       *
       * @returns {Complex}
       */
      neg: function() {
        return new l(-this.re, -this.im);
      },
      /**
       * Ceils the actual complex number
       *
       * @returns {Complex}
       */
      ceil: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.ceil(this.re * d) / d,
          Math.ceil(this.im * d) / d
        );
      },
      /**
       * Floors the actual complex number
       *
       * @returns {Complex}
       */
      floor: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.floor(this.re * d) / d,
          Math.floor(this.im * d) / d
        );
      },
      /**
       * Ceils the actual complex number
       *
       * @returns {Complex}
       */
      round: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.round(this.re * d) / d,
          Math.round(this.im * d) / d
        );
      },
      /**
       * Compares two complex numbers
       *
       * **Note:** new Complex(Infinity).equals(Infinity) === false
       *
       * @returns {boolean}
       */
      equals: function(d, f) {
        var h = new l(d, f);
        return Math.abs(h.re - this.re) <= l.EPSILON && Math.abs(h.im - this.im) <= l.EPSILON;
      },
      /**
       * Clones the actual object
       *
       * @returns {Complex}
       */
      clone: function() {
        return new l(this.re, this.im);
      },
      /**
       * Gets a string of the actual complex number
       *
       * @returns {string}
       */
      toString: function() {
        var d = this.re, f = this.im, h = "";
        return this.isNaN() ? "NaN" : this.isInfinite() ? "Infinity" : (Math.abs(d) < l.EPSILON && (d = 0), Math.abs(f) < l.EPSILON && (f = 0), f === 0 ? h + d : (d !== 0 ? (h += d, h += " ", f < 0 ? (f = -f, h += "-") : h += "+", h += " ") : f < 0 && (f = -f, h += "-"), f !== 1 && (h += f), h + "i"));
      },
      /**
       * Returns the actual number as a vector
       *
       * @returns {Array}
       */
      toVector: function() {
        return [this.re, this.im];
      },
      /**
       * Returns the actual real value of the current object
       *
       * @returns {number|null}
       */
      valueOf: function() {
        return this.im === 0 ? this.re : null;
      },
      /**
       * Determines whether a complex number is not on the Riemann sphere.
       *
       * @returns {boolean}
       */
      isNaN: function() {
        return isNaN(this.re) || isNaN(this.im);
      },
      /**
       * Determines whether or not a complex number is at the zero pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isZero: function() {
        return this.im === 0 && this.re === 0;
      },
      /**
       * Determines whether a complex number is not at the infinity pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isFinite: function() {
        return isFinite(this.re) && isFinite(this.im);
      },
      /**
       * Determines whether or not a complex number is at the infinity pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isInfinite: function() {
        return !(this.isNaN() || this.isFinite());
      }
    }, l.ZERO = new l(0, 0), l.ONE = new l(1, 0), l.I = new l(0, 1), l.PI = new l(Math.PI, 0), l.E = new l(Math.E, 0), l.INFINITY = new l(1 / 0, 1 / 0), l.NAN = new l(NaN, NaN), l.EPSILON = 1e-15, Object.defineProperty(l, "__esModule", { value: !0 }), l.default = l, l.Complex = l, t.exports = l;
  })();
})(jG);
var X1e = jG.exports;
const Ba = /* @__PURE__ */ K1e(X1e);
var Y1e = "Complex", W1e = [], j1e = /* @__PURE__ */ vt(Y1e, W1e, () => (Object.defineProperty(Ba, "name", {
  value: "Complex"
}), Ba.prototype.constructor = Ba, Ba.prototype.type = "Complex", Ba.prototype.isComplex = !0, Ba.prototype.toJSON = function() {
  return {
    mathjs: "Complex",
    re: this.re,
    im: this.im
  };
}, Ba.prototype.toPolar = function() {
  return {
    r: this.abs(),
    phi: this.arg()
  };
}, Ba.prototype.format = function(t) {
  var e = "", r = this.im, n = this.re, i = d9(this.re, t), a = d9(this.im, t), o = Gn(t) ? t : t ? t.precision : null;
  if (o !== null) {
    var s = Math.pow(10, -o);
    Math.abs(n / r) < s && (n = 0), Math.abs(r / n) < s && (r = 0);
  }
  return r === 0 ? e = i : n === 0 ? r === 1 ? e = "i" : r === -1 ? e = "-i" : e = a + "i" : r < 0 ? r === -1 ? e = i + " - i" : e = i + " - " + a.substring(1) + "i" : r === 1 ? e = i + " + i" : e = i + " + " + a + "i", e;
}, Ba.fromPolar = function(t) {
  switch (arguments.length) {
    case 1: {
      var e = arguments[0];
      if (typeof e == "object")
        return Ba(e);
      throw new TypeError("Input has to be an object with r and phi keys.");
    }
    case 2: {
      var r = arguments[0], n = arguments[1];
      if (Gn(r)) {
        if (DG(n) && n.hasBase("ANGLE") && (n = n.toNumber("rad")), Gn(n))
          return new Ba({
            r,
            phi: n
          });
        throw new TypeError("Phi is not a number nor an angle unit.");
      } else
        throw new TypeError("Radius r is not a number.");
    }
    default:
      throw new SyntaxError("Wrong number of arguments in function fromPolar");
  }
}, Ba.prototype.valueOf = Ba.prototype.toString, Ba.fromJSON = function(t) {
  return new Ba(t);
}, Ba.compare = function(t, e) {
  return t.re > e.re ? 1 : t.re < e.re ? -1 : t.im > e.im ? 1 : t.im < e.im ? -1 : 0;
}, Ba), {
  isClass: !0
});
/**
 * @license Fraction.js v4.3.7 31/08/2023
 * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
 *
 * Copyright (c) 2023, Robert Eisele (robert@raw.org)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 **/
var Z1e = 2e3, Bt = {
  s: 1,
  n: 0,
  d: 1
};
function tl(t, e) {
  if (isNaN(t = parseInt(t, 10)))
    throw d3();
  return t * e;
}
function li(t, e) {
  if (e === 0)
    throw rS();
  var r = Object.create(Za.prototype);
  r.s = t < 0 ? -1 : 1, t = t < 0 ? -t : t;
  var n = ap(t, e);
  return r.n = t / n, r.d = e / n, r;
}
function GP(t) {
  for (var e = {}, r = t, n = 2, i = 4; i <= r; ) {
    for (; r % n === 0; )
      r /= n, e[n] = (e[n] || 0) + 1;
    i += 1 + 2 * n++;
  }
  return r !== t ? r > 1 && (e[r] = (e[r] || 0) + 1) : e[t] = (e[t] || 0) + 1, e;
}
var us = function(t, e) {
  var r = 0, n = 1, i = 1, a = 0, o = 0, s = 0, u = 1, c = 1, l = 0, d = 1, f = 1, h = 1, m = 1e7, p;
  if (t != null) if (e !== void 0) {
    if (r = t, n = e, i = r * n, r % 1 !== 0 || n % 1 !== 0)
      throw epe();
  } else
    switch (typeof t) {
      case "object": {
        if ("d" in t && "n" in t)
          r = t.n, n = t.d, "s" in t && (r *= t.s);
        else if (0 in t)
          r = t[0], 1 in t && (n = t[1]);
        else
          throw d3();
        i = r * n;
        break;
      }
      case "number": {
        if (t < 0 && (i = t, t = -t), t % 1 === 0)
          r = t;
        else if (t > 0) {
          for (t >= 1 && (c = Math.pow(10, Math.floor(1 + Math.log(t) / Math.LN10)), t /= c); d <= m && h <= m; )
            if (p = (l + f) / (d + h), t === p) {
              d + h <= m ? (r = l + f, n = d + h) : h > d ? (r = f, n = h) : (r = l, n = d);
              break;
            } else
              t > p ? (l += f, d += h) : (f += l, h += d), d > m ? (r = f, n = h) : (r = l, n = d);
          r *= c;
        } else (isNaN(t) || isNaN(e)) && (n = r = NaN);
        break;
      }
      case "string": {
        if (d = t.match(/\d+|./g), d === null)
          throw d3();
        if (d[l] === "-" ? (i = -1, l++) : d[l] === "+" && l++, d.length === l + 1 ? o = tl(d[l++], i) : d[l + 1] === "." || d[l] === "." ? (d[l] !== "." && (a = tl(d[l++], i)), l++, (l + 1 === d.length || d[l + 1] === "(" && d[l + 3] === ")" || d[l + 1] === "'" && d[l + 3] === "'") && (o = tl(d[l], i), u = Math.pow(10, d[l].length), l++), (d[l] === "(" && d[l + 2] === ")" || d[l] === "'" && d[l + 2] === "'") && (s = tl(d[l + 1], i), c = Math.pow(10, d[l + 1].length) - 1, l += 3)) : d[l + 1] === "/" || d[l + 1] === ":" ? (o = tl(d[l], i), u = tl(d[l + 2], 1), l += 3) : d[l + 3] === "/" && d[l + 1] === " " && (a = tl(d[l], i), o = tl(d[l + 2], i), u = tl(d[l + 4], 1), l += 5), d.length <= l) {
          n = u * c, i = /* void */
          r = s + n * a + c * o;
          break;
        }
      }
      default:
        throw d3();
    }
  if (n === 0)
    throw rS();
  Bt.s = i < 0 ? -1 : 1, Bt.n = Math.abs(r), Bt.d = Math.abs(n);
};
function Q1e(t, e, r) {
  for (var n = 1; e > 0; t = t * t % r, e >>= 1)
    e & 1 && (n = n * t % r);
  return n;
}
function J1e(t, e) {
  for (; e % 2 === 0; e /= 2)
    ;
  for (; e % 5 === 0; e /= 5)
    ;
  if (e === 1)
    return 0;
  for (var r = 10 % e, n = 1; r !== 1; n++)
    if (r = r * 10 % e, n > Z1e)
      return 0;
  return n;
}
function $1e(t, e, r) {
  for (var n = 1, i = Q1e(10, r, e), a = 0; a < 300; a++) {
    if (n === i)
      return a;
    n = n * 10 % e, i = i * 10 % e;
  }
  return 0;
}
function ap(t, e) {
  if (!t)
    return e;
  if (!e)
    return t;
  for (; ; ) {
    if (t %= e, !t)
      return e;
    if (e %= t, !e)
      return t;
  }
}
function Za(t, e) {
  if (us(t, e), this instanceof Za)
    t = ap(Bt.d, Bt.n), this.s = Bt.s, this.n = Bt.n / t, this.d = Bt.d / t;
  else
    return li(Bt.s * Bt.n, Bt.d);
}
var rS = function() {
  return new Error("Division by Zero");
}, d3 = function() {
  return new Error("Invalid argument");
}, epe = function() {
  return new Error("Parameters must be integer");
};
Za.prototype = {
  s: 1,
  n: 0,
  d: 1,
  /**
   * Calculates the absolute value
   *
   * Ex: new Fraction(-4).abs() => 4
   **/
  abs: function() {
    return li(this.n, this.d);
  },
  /**
   * Inverts the sign of the current fraction
   *
   * Ex: new Fraction(-4).neg() => 4
   **/
  neg: function() {
    return li(-this.s * this.n, this.d);
  },
  /**
   * Adds two rational numbers
   *
   * Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30
   **/
  add: function(t, e) {
    return us(t, e), li(
      this.s * this.n * Bt.d + Bt.s * this.d * Bt.n,
      this.d * Bt.d
    );
  },
  /**
   * Subtracts two rational numbers
   *
   * Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30
   **/
  sub: function(t, e) {
    return us(t, e), li(
      this.s * this.n * Bt.d - Bt.s * this.d * Bt.n,
      this.d * Bt.d
    );
  },
  /**
   * Multiplies two rational numbers
   *
   * Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111
   **/
  mul: function(t, e) {
    return us(t, e), li(
      this.s * Bt.s * this.n * Bt.n,
      this.d * Bt.d
    );
  },
  /**
   * Divides two rational numbers
   *
   * Ex: new Fraction("-17.(345)").inverse().div(3)
   **/
  div: function(t, e) {
    return us(t, e), li(
      this.s * Bt.s * this.n * Bt.d,
      this.d * Bt.n
    );
  },
  /**
   * Clones the actual object
   *
   * Ex: new Fraction("-17.(345)").clone()
   **/
  clone: function() {
    return li(this.s * this.n, this.d);
  },
  /**
   * Calculates the modulo of two rational numbers - a more precise fmod
   *
   * Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6)
   **/
  mod: function(t, e) {
    if (isNaN(this.n) || isNaN(this.d))
      return new Za(NaN);
    if (t === void 0)
      return li(this.s * this.n % this.d, 1);
    if (us(t, e), Bt.n === 0 && this.d === 0)
      throw rS();
    return li(
      this.s * (Bt.d * this.n) % (Bt.n * this.d),
      Bt.d * this.d
    );
  },
  /**
   * Calculates the fractional gcd of two rational numbers
   *
   * Ex: new Fraction(5,8).gcd(3,7) => 1/56
   */
  gcd: function(t, e) {
    return us(t, e), li(ap(Bt.n, this.n) * ap(Bt.d, this.d), Bt.d * this.d);
  },
  /**
   * Calculates the fractional lcm of two rational numbers
   *
   * Ex: new Fraction(5,8).lcm(3,7) => 15
   */
  lcm: function(t, e) {
    return us(t, e), Bt.n === 0 && this.n === 0 ? li(0, 1) : li(Bt.n * this.n, ap(Bt.n, this.n) * ap(Bt.d, this.d));
  },
  /**
   * Calculates the ceil of a rational number
   *
   * Ex: new Fraction('4.(3)').ceil() => (5 / 1)
   **/
  ceil: function(t) {
    return t = Math.pow(10, t || 0), isNaN(this.n) || isNaN(this.d) ? new Za(NaN) : li(Math.ceil(t * this.s * this.n / this.d), t);
  },
  /**
   * Calculates the floor of a rational number
   *
   * Ex: new Fraction('4.(3)').floor() => (4 / 1)
   **/
  floor: function(t) {
    return t = Math.pow(10, t || 0), isNaN(this.n) || isNaN(this.d) ? new Za(NaN) : li(Math.floor(t * this.s * this.n / this.d), t);
  },
  /**
   * Rounds a rational number
   *
   * Ex: new Fraction('4.(3)').round() => (4 / 1)
   **/
  round: function(t) {
    return t = Math.pow(10, t || 0), isNaN(this.n) || isNaN(this.d) ? new Za(NaN) : li(Math.round(t * this.s * this.n / this.d), t);
  },
  /**
   * Rounds a rational number to a multiple of another rational number
   *
   * Ex: new Fraction('0.9').roundTo("1/8") => 7 / 8
   **/
  roundTo: function(t, e) {
    return us(t, e), li(this.s * Math.round(this.n * Bt.d / (this.d * Bt.n)) * Bt.n, Bt.d);
  },
  /**
   * Gets the inverse of the fraction, means numerator and denominator are exchanged
   *
   * Ex: new Fraction([-3, 4]).inverse() => -4 / 3
   **/
  inverse: function() {
    return li(this.s * this.d, this.n);
  },
  /**
   * Calculates the fraction to some rational exponent, if possible
   *
   * Ex: new Fraction(-1,2).pow(-3) => -8
   */
  pow: function(t, e) {
    if (us(t, e), Bt.d === 1)
      return Bt.s < 0 ? li(Math.pow(this.s * this.d, Bt.n), Math.pow(this.n, Bt.n)) : li(Math.pow(this.s * this.n, Bt.n), Math.pow(this.d, Bt.n));
    if (this.s < 0) return null;
    var r = GP(this.n), n = GP(this.d), i = 1, a = 1;
    for (var o in r)
      if (o !== "1") {
        if (o === "0") {
          i = 0;
          break;
        }
        if (r[o] *= Bt.n, r[o] % Bt.d === 0)
          r[o] /= Bt.d;
        else return null;
        i *= Math.pow(o, r[o]);
      }
    for (var o in n)
      if (o !== "1") {
        if (n[o] *= Bt.n, n[o] % Bt.d === 0)
          n[o] /= Bt.d;
        else return null;
        a *= Math.pow(o, n[o]);
      }
    return Bt.s < 0 ? li(a, i) : li(i, a);
  },
  /**
   * Check if two rational numbers are the same
   *
   * Ex: new Fraction(19.6).equals([98, 5]);
   **/
  equals: function(t, e) {
    return us(t, e), this.s * this.n * Bt.d === Bt.s * Bt.n * this.d;
  },
  /**
   * Check if two rational numbers are the same
   *
   * Ex: new Fraction(19.6).equals([98, 5]);
   **/
  compare: function(t, e) {
    us(t, e);
    var r = this.s * this.n * Bt.d - Bt.s * Bt.n * this.d;
    return (0 < r) - (r < 0);
  },
  simplify: function(t) {
    if (isNaN(this.n) || isNaN(this.d))
      return this;
    t = t || 1e-3;
    for (var e = this.abs(), r = e.toContinued(), n = 1; n < r.length; n++) {
      for (var i = li(r[n - 1], 1), a = n - 2; a >= 0; a--)
        i = i.inverse().add(r[a]);
      if (Math.abs(i.sub(e).valueOf()) < t)
        return i.mul(this.s);
    }
    return this;
  },
  /**
   * Check if two rational numbers are divisible
   *
   * Ex: new Fraction(19.6).divisible(1.5);
   */
  divisible: function(t, e) {
    return us(t, e), !(!(Bt.n * this.d) || this.n * Bt.d % (Bt.n * this.d));
  },
  /**
   * Returns a decimal representation of the fraction
   *
   * Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183
   **/
  valueOf: function() {
    return this.s * this.n / this.d;
  },
  /**
   * Returns a string-fraction representation of a Fraction object
   *
   * Ex: new Fraction("1.'3'").toFraction(true) => "4 1/3"
   **/
  toFraction: function(t) {
    var e, r = "", n = this.n, i = this.d;
    return this.s < 0 && (r += "-"), i === 1 ? r += n : (t && (e = Math.floor(n / i)) > 0 && (r += e, r += " ", n %= i), r += n, r += "/", r += i), r;
  },
  /**
   * Returns a latex representation of a Fraction object
   *
   * Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}"
   **/
  toLatex: function(t) {
    var e, r = "", n = this.n, i = this.d;
    return this.s < 0 && (r += "-"), i === 1 ? r += n : (t && (e = Math.floor(n / i)) > 0 && (r += e, n %= i), r += "\\frac{", r += n, r += "}{", r += i, r += "}"), r;
  },
  /**
   * Returns an array of continued fraction elements
   *
   * Ex: new Fraction("7/8").toContinued() => [0,1,7]
   */
  toContinued: function() {
    var t, e = this.n, r = this.d, n = [];
    if (isNaN(e) || isNaN(r))
      return n;
    do
      n.push(Math.floor(e / r)), t = e % r, e = r, r = t;
    while (e !== 1);
    return n;
  },
  /**
   * Creates a string representation of a fraction with all digits
   *
   * Ex: new Fraction("100.'91823'").toString() => "100.(91823)"
   **/
  toString: function(t) {
    var e = this.n, r = this.d;
    if (isNaN(e) || isNaN(r))
      return "NaN";
    t = t || 15;
    var n = J1e(e, r), i = $1e(e, r, n), a = this.s < 0 ? "-" : "";
    if (a += e / r | 0, e %= r, e *= 10, e && (a += "."), n) {
      for (var o = i; o--; )
        a += e / r | 0, e %= r, e *= 10;
      a += "(";
      for (var o = n; o--; )
        a += e / r | 0, e %= r, e *= 10;
      a += ")";
    } else
      for (var o = t; e && o--; )
        a += e / r | 0, e %= r, e *= 10;
    return a;
  }
};
var tpe = "Fraction", rpe = [], npe = /* @__PURE__ */ vt(tpe, rpe, () => (Object.defineProperty(Za, "name", {
  value: "Fraction"
}), Za.prototype.constructor = Za, Za.prototype.type = "Fraction", Za.prototype.isFraction = !0, Za.prototype.toJSON = function() {
  return {
    mathjs: "Fraction",
    n: this.s * this.n,
    d: this.d
  };
}, Za.fromJSON = function(t) {
  return new Za(t);
}, Za), {
  isClass: !0
}), ipe = "Matrix", ape = [], ope = /* @__PURE__ */ vt(ipe, ape, () => {
  function t() {
    if (!(this instanceof t))
      throw new SyntaxError("Constructor must be called with the new operator");
  }
  return t.prototype.type = "Matrix", t.prototype.isMatrix = !0, t.prototype.storage = function() {
    throw new Error("Cannot invoke storage on a Matrix interface");
  }, t.prototype.datatype = function() {
    throw new Error("Cannot invoke datatype on a Matrix interface");
  }, t.prototype.create = function(e, r) {
    throw new Error("Cannot invoke create on a Matrix interface");
  }, t.prototype.subset = function(e, r, n) {
    throw new Error("Cannot invoke subset on a Matrix interface");
  }, t.prototype.get = function(e) {
    throw new Error("Cannot invoke get on a Matrix interface");
  }, t.prototype.set = function(e, r, n) {
    throw new Error("Cannot invoke set on a Matrix interface");
  }, t.prototype.resize = function(e, r) {
    throw new Error("Cannot invoke resize on a Matrix interface");
  }, t.prototype.reshape = function(e, r) {
    throw new Error("Cannot invoke reshape on a Matrix interface");
  }, t.prototype.clone = function() {
    throw new Error("Cannot invoke clone on a Matrix interface");
  }, t.prototype.size = function() {
    throw new Error("Cannot invoke size on a Matrix interface");
  }, t.prototype.map = function(e, r) {
    throw new Error("Cannot invoke map on a Matrix interface");
  }, t.prototype.forEach = function(e) {
    throw new Error("Cannot invoke forEach on a Matrix interface");
  }, t.prototype[Symbol.iterator] = function() {
    throw new Error("Cannot iterate a Matrix interface");
  }, t.prototype.toArray = function() {
    throw new Error("Cannot invoke toArray on a Matrix interface");
  }, t.prototype.valueOf = function() {
    throw new Error("Cannot invoke valueOf on a Matrix interface");
  }, t.prototype.format = function(e) {
    throw new Error("Cannot invoke format on a Matrix interface");
  }, t.prototype.toString = function() {
    throw new Error("Cannot invoke toString on a Matrix interface");
  }, t;
}, {
  isClass: !0
});
function Z8(t, e, r) {
  var n = t.constructor, i = new n(2), a = "";
  if (r) {
    if (r < 1)
      throw new Error("size must be in greater than 0");
    if (!zn(r))
      throw new Error("size must be an integer");
    if (t.greaterThan(i.pow(r - 1).sub(1)) || t.lessThan(i.pow(r - 1).mul(-1)))
      throw new Error("Value must be in range [-2^".concat(r - 1, ", 2^").concat(r - 1, "-1]"));
    if (!t.isInteger())
      throw new Error("Value must be an integer");
    t.lessThan(0) && (t = t.add(i.pow(r))), a = "i".concat(r);
  }
  switch (e) {
    case 2:
      return "".concat(t.toBinary()).concat(a);
    case 8:
      return "".concat(t.toOctal()).concat(a);
    case 16:
      return "".concat(t.toHexadecimal()).concat(a);
    default:
      throw new Error("Base ".concat(e, " not supported "));
  }
}
function spe(t, e) {
  if (typeof e == "function")
    return e(t);
  if (!t.isFinite())
    return t.isNaN() ? "NaN" : t.gt(0) ? "Infinity" : "-Infinity";
  var {
    notation: r,
    precision: n,
    wordSize: i
  } = BG(e);
  switch (r) {
    case "fixed":
      return cpe(t, n);
    case "exponential":
      return zP(t, n);
    case "engineering":
      return upe(t, n);
    case "bin":
      return Z8(t, 2, i);
    case "oct":
      return Z8(t, 8, i);
    case "hex":
      return Z8(t, 16, i);
    case "auto": {
      var a = VP(e == null ? void 0 : e.lowerExp, -3), o = VP(e == null ? void 0 : e.upperExp, 5);
      if (t.isZero()) return "0";
      var s, u = t.toSignificantDigits(n), c = u.e;
      return c >= a && c < o ? s = u.toFixed() : s = zP(t, n), s.replace(/((\.\d*?)(0+))($|e)/, function() {
        var l = arguments[2], d = arguments[4];
        return l !== "." ? l + d : d;
      });
    }
    default:
      throw new Error('Unknown notation "' + r + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
  }
}
function upe(t, e) {
  var r = t.e, n = r % 3 === 0 ? r : r < 0 ? r - 3 - r % 3 : r - r % 3, i = t.mul(Math.pow(10, -n)), a = i.toPrecision(e);
  if (a.includes("e")) {
    var o = t.constructor;
    a = new o(a).toFixed();
  }
  return a + "e" + (r >= 0 ? "+" : "") + n.toString();
}
function zP(t, e) {
  return e !== void 0 ? t.toExponential(e - 1) : t.toExponential();
}
function cpe(t, e) {
  return t.toFixed(e);
}
function VP(t, e) {
  return Gn(t) ? t : mi(t) ? t.toNumber() : e;
}
function Zn(t, e) {
  var r = lpe(t, e);
  return e && typeof e == "object" && "truncate" in e && r.length > e.truncate ? r.substring(0, e.truncate - 3) + "..." : r;
}
function lpe(t, e) {
  if (typeof t == "number")
    return d9(t, e);
  if (mi(t))
    return spe(t, e);
  if (dpe(t))
    return !e || e.fraction !== "decimal" ? t.s * t.n + "/" + t.d : t.toString();
  if (Array.isArray(t))
    return ZG(t, e);
  if (Eu(t))
    return UP(t);
  if (typeof t == "function")
    return t.syntax ? String(t.syntax) : "function";
  if (t && typeof t == "object") {
    if (typeof t.format == "function")
      return t.format(e);
    if (t && t.toString(e) !== {}.toString())
      return t.toString(e);
    var r = Object.keys(t).map((n) => UP(n) + ": " + Zn(t[n], e));
    return "{" + r.join(", ") + "}";
  }
  return String(t);
}
function UP(t) {
  for (var e = String(t), r = "", n = 0; n < e.length; ) {
    var i = e.charAt(n);
    r += i in HP ? HP[i] : i, n++;
  }
  return '"' + r + '"';
}
var HP = {
  '"': '\\"',
  "\\": "\\\\",
  "\b": "\\b",
  "\f": "\\f",
  "\n": "\\n",
  "\r": "\\r",
  "	": "\\t"
};
function ZG(t, e) {
  if (Array.isArray(t)) {
    for (var r = "[", n = t.length, i = 0; i < n; i++)
      i !== 0 && (r += ", "), r += ZG(t[i], e);
    return r += "]", r;
  } else
    return Zn(t, e);
}
function dpe(t) {
  return t && typeof t == "object" && typeof t.s == "number" && typeof t.n == "number" && typeof t.d == "number" || !1;
}
function sn(t, e, r) {
  if (!(this instanceof sn))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.actual = t, this.expected = e, this.relation = r, this.message = "Dimension mismatch (" + (Array.isArray(t) ? "[" + t.join(", ") + "]" : t) + " " + (this.relation || "!=") + " " + (Array.isArray(e) ? "[" + e.join(", ") + "]" : e) + ")", this.stack = new Error().stack;
}
sn.prototype = new RangeError();
sn.prototype.constructor = RangeError;
sn.prototype.name = "DimensionError";
sn.prototype.isDimensionError = !0;
function V0(t, e, r) {
  if (!(this instanceof V0))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.index = t, arguments.length < 3 ? (this.min = 0, this.max = e) : (this.min = e, this.max = r), this.min !== void 0 && this.index < this.min ? this.message = "Index out of range (" + this.index + " < " + this.min + ")" : this.max !== void 0 && this.index >= this.max ? this.message = "Index out of range (" + this.index + " > " + (this.max - 1) + ")" : this.message = "Index out of range (" + this.index + ")", this.stack = new Error().stack;
}
V0.prototype = new RangeError();
V0.prototype.constructor = RangeError;
V0.prototype.name = "IndexError";
V0.prototype.isIndexError = !0;
function Kn(t) {
  for (var e = []; Array.isArray(t); )
    e.push(t.length), t = t[0];
  return e;
}
function QG(t, e, r) {
  var n, i = t.length;
  if (i !== e[r])
    throw new sn(i, e[r]);
  if (r < e.length - 1) {
    var a = r + 1;
    for (n = 0; n < i; n++) {
      var o = t[n];
      if (!Array.isArray(o))
        throw new sn(e.length - 1, e.length, "<");
      QG(t[n], e, a);
    }
  } else
    for (n = 0; n < i; n++)
      if (Array.isArray(t[n]))
        throw new sn(e.length + 1, e.length, ">");
}
function qP(t, e) {
  var r = e.length === 0;
  if (r) {
    if (Array.isArray(t))
      throw new sn(t.length, 0);
  } else
    QG(t, e, 0);
}
function ii(t, e) {
  if (t !== void 0) {
    if (!Gn(t) || !zn(t))
      throw new TypeError("Index must be an integer (value: " + t + ")");
    if (t < 0 || typeof e == "number" && t >= e)
      throw new V0(t, e);
  }
}
function vy(t, e, r) {
  if (!Array.isArray(e))
    throw new TypeError("Array expected");
  if (e.length === 0)
    throw new Error("Resizing to scalar is not supported");
  e.forEach(function(i) {
    if (!Gn(i) || !zn(i) || i < 0)
      throw new TypeError("Invalid size, must contain positive integers (size: " + Zn(e) + ")");
  }), (Gn(t) || mi(t)) && (t = [t]);
  var n = r !== void 0 ? r : 0;
  return v9(t, e, 0, n), t;
}
function v9(t, e, r, n) {
  var i, a, o = t.length, s = e[r], u = Math.min(o, s);
  if (t.length = s, r < e.length - 1) {
    var c = r + 1;
    for (i = 0; i < u; i++)
      a = t[i], Array.isArray(a) || (a = [a], t[i] = a), v9(a, e, c, n);
    for (i = u; i < s; i++)
      a = [], t[i] = a, v9(a, e, c, n);
  } else {
    for (i = 0; i < u; i++)
      for (; Array.isArray(t[i]); )
        t[i] = t[i][0];
    for (i = u; i < s; i++)
      t[i] = n;
  }
}
function nS(t, e) {
  var r = y9(t), n = r.length;
  if (!Array.isArray(t) || !Array.isArray(e))
    throw new TypeError("Array expected");
  if (e.length === 0)
    throw new sn(0, n, "!=");
  e = iS(e, n);
  var i = JG(e);
  if (n !== i)
    throw new sn(i, n, "!=");
  try {
    return fpe(r, e);
  } catch (a) {
    throw a instanceof sn ? new sn(i, n, "!=") : a;
  }
}
function iS(t, e) {
  var r = JG(t), n = t.slice(), i = -1, a = t.indexOf(i), o = t.indexOf(i, a + 1) >= 0;
  if (o)
    throw new Error("More than one wildcard in sizes");
  var s = a >= 0, u = e % r === 0;
  if (s)
    if (u)
      n[a] = -e / r;
    else
      throw new Error("Could not replace wildcard, since " + e + " is no multiple of " + -r);
  return n;
}
function JG(t) {
  return t.reduce((e, r) => e * r, 1);
}
function fpe(t, e) {
  for (var r = t, n, i = e.length - 1; i > 0; i--) {
    var a = e[i];
    n = [];
    for (var o = r.length / a, s = 0; s < o; s++)
      n.push(r.slice(s * a, (s + 1) * a));
    r = n;
  }
  return r;
}
function KP(t, e) {
  for (var r = Kn(t); Array.isArray(t) && t.length === 1; )
    t = t[0], r.shift();
  for (var n = r.length; r[n - 1] === 1; )
    n--;
  return n < r.length && (t = $G(t, n, 0), r.length = n), t;
}
function $G(t, e, r) {
  var n, i;
  if (r < e) {
    var a = r + 1;
    for (n = 0, i = t.length; n < i; n++)
      t[n] = $G(t[n], e, a);
  } else
    for (; Array.isArray(t); )
      t = t[0];
  return t;
}
function ez(t, e, r, n) {
  var i = n || Kn(t);
  if (r)
    for (var a = 0; a < r; a++)
      t = [t], i.unshift(1);
  for (t = tz(t, e, 0); i.length < e; )
    i.push(1);
  return t;
}
function tz(t, e, r) {
  var n, i;
  if (Array.isArray(t)) {
    var a = r + 1;
    for (n = 0, i = t.length; n < i; n++)
      t[n] = tz(t[n], e, a);
  } else
    for (var o = r; o < e; o++)
      t = [t];
  return t;
}
function y9(t) {
  if (!Array.isArray(t))
    return t;
  var e = [];
  return t.forEach(function r(n) {
    Array.isArray(n) ? n.forEach(r) : e.push(n);
  }), e;
}
function c2(t, e) {
  for (var r, n = 0, i = 0; i < t.length; i++) {
    var a = t[i], o = Array.isArray(a);
    if (i === 0 && o && (n = a.length), o && a.length !== n)
      return;
    var s = o ? c2(a, e) : e(a);
    if (r === void 0)
      r = s;
    else if (r !== s)
      return "mixed";
  }
  return r;
}
function rz(t, e, r, n) {
  if (n < r) {
    if (t.length !== e.length)
      throw new sn(t.length, e.length);
    for (var i = [], a = 0; a < t.length; a++)
      i[a] = rz(t[a], e[a], r, n + 1);
    return i;
  } else
    return t.concat(e);
}
function nz() {
  var t = Array.prototype.slice.call(arguments, 0, -1), e = Array.prototype.slice.call(arguments, -1);
  if (t.length === 1)
    return t[0];
  if (t.length > 1)
    return t.slice(1).reduce(function(r, n) {
      return rz(r, n, e, 0);
    }, t[0]);
  throw new Error("Wrong number of arguments in function concat");
}
function iz() {
  for (var t = arguments.length, e = new Array(t), r = 0; r < t; r++)
    e[r] = arguments[r];
  for (var n = e.map((f) => f.length), i = Math.max(...n), a = new Array(i).fill(null), o = 0; o < e.length; o++)
    for (var s = e[o], u = n[o], c = 0; c < u; c++) {
      var l = i - u + c;
      s[c] > a[l] && (a[l] = s[c]);
    }
  for (var d = 0; d < e.length; d++)
    az(e[d], a);
  return a;
}
function az(t, e) {
  for (var r = e.length, n = t.length, i = 0; i < n; i++) {
    var a = r - n + i;
    if (t[i] < e[a] && t[i] > 1 || t[i] > e[a])
      throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(t, ") not possible to broadcast dimension ").concat(n, " with size ").concat(t[i], " to size ").concat(e[a]));
  }
}
function b9(t, e) {
  var r = Kn(t);
  if (lf(r, e))
    return t;
  az(r, e);
  var n = iz(r, e), i = n.length, a = [...Array(i - r.length).fill(1), ...r], o = hpe(t);
  r.length < i && (o = nS(o, a), r = Kn(o));
  for (var s = 0; s < i; s++)
    r[s] < n[s] && (o = ppe(o, n[s], s), r = Kn(o));
  return o;
}
function ppe(t, e, r) {
  return nz(...Array(e).fill(t), r);
}
function hpe(t) {
  return Up([], t);
}
function mpe(t) {
  var e = 0, r = 1, n = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null), a = 0, o = function(u) {
    var c = i[u];
    if (c && (delete n[c], delete i[u], --e, r === c)) {
      if (!e) {
        a = 0, r = 1;
        return;
      }
      for (; !Object.prototype.hasOwnProperty.call(n, ++r); )
        ;
    }
  };
  return t = Math.abs(t), {
    hit: function(u) {
      var c = i[u], l = ++a;
      if (n[l] = u, i[u] = l, !c)
        return ++e, e <= t ? void 0 : (u = n[r], o(u), u);
      if (delete n[c], r === c)
        for (; !Object.prototype.hasOwnProperty.call(n, ++r); )
          ;
    },
    delete: o,
    clear: function() {
      e = a = 0, r = 1, n = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null);
    }
  };
}
function f4(t) {
  var {
    hasher: e,
    limit: r
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  return r = r ?? Number.POSITIVE_INFINITY, e = e ?? JSON.stringify, function n() {
    typeof n.cache != "object" && (n.cache = {
      values: /* @__PURE__ */ new Map(),
      lru: mpe(r || Number.POSITIVE_INFINITY)
    });
    for (var i = [], a = 0; a < arguments.length; a++)
      i[a] = arguments[a];
    var o = e(i);
    if (n.cache.values.has(o))
      return n.cache.lru.hit(o), n.cache.values.get(o);
    var s = t.apply(t, i);
    return n.cache.values.set(o, s), n.cache.values.delete(n.cache.lru.hit(o)), s;
  };
}
function oz(t) {
  return Object.keys(t.signatures || {}).reduce(function(e, r) {
    var n = (r.match(/,/g) || []).length + 1;
    return Math.max(e, n);
  }, -1);
}
var gpe = "DenseMatrix", vpe = ["Matrix"], ype = /* @__PURE__ */ vt(gpe, vpe, (t) => {
  var {
    Matrix: e
  } = t;
  function r(l, d) {
    if (!(this instanceof r))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (d && !Eu(d))
      throw new Error("Invalid datatype: " + d);
    if (Xn(l))
      l.type === "DenseMatrix" ? (this._data = an(l._data), this._size = an(l._size), this._datatype = d || l._datatype) : (this._data = l.toArray(), this._size = l.size(), this._datatype = d || l._datatype);
    else if (l && Mn(l.data) && Mn(l.size))
      this._data = l.data, this._size = l.size, qP(this._data, this._size), this._datatype = d || l.datatype;
    else if (Mn(l))
      this._data = c(l), this._size = Kn(this._data), qP(this._data, this._size), this._datatype = d;
    else {
      if (l)
        throw new TypeError("Unsupported type of data (" + xl(l) + ")");
      this._data = [], this._size = [0], this._datatype = d;
    }
  }
  r.prototype = new e(), r.prototype.createDenseMatrix = function(l, d) {
    return new r(l, d);
  }, Object.defineProperty(r, "name", {
    value: "DenseMatrix"
  }), r.prototype.constructor = r, r.prototype.type = "DenseMatrix", r.prototype.isDenseMatrix = !0, r.prototype.getDataType = function() {
    return c2(this._data, xl);
  }, r.prototype.storage = function() {
    return "dense";
  }, r.prototype.datatype = function() {
    return this._datatype;
  }, r.prototype.create = function(l, d) {
    return new r(l, d);
  }, r.prototype.subset = function(l, d, f) {
    switch (arguments.length) {
      case 1:
        return n(this, l);
      case 2:
      case 3:
        return a(this, l, d, f);
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  }, r.prototype.get = function(l) {
    if (!Mn(l))
      throw new TypeError("Array expected");
    if (l.length !== this._size.length)
      throw new sn(l.length, this._size.length);
    for (var d = 0; d < l.length; d++)
      ii(l[d], this._size[d]);
    for (var f = this._data, h = 0, m = l.length; h < m; h++) {
      var p = l[h];
      ii(p, f.length), f = f[p];
    }
    return f;
  }, r.prototype.set = function(l, d, f) {
    if (!Mn(l))
      throw new TypeError("Array expected");
    if (l.length < this._size.length)
      throw new sn(l.length, this._size.length, "<");
    var h, m, p, v = l.map(function(y) {
      return y + 1;
    });
    u(this, v, f);
    var g = this._data;
    for (h = 0, m = l.length - 1; h < m; h++)
      p = l[h], ii(p, g.length), g = g[p];
    return p = l[l.length - 1], ii(p, g.length), g[p] = d, this;
  };
  function n(l, d) {
    if (!$x(d))
      throw new TypeError("Invalid index");
    var f = d.isScalar();
    if (f)
      return l.get(d.min());
    var h = d.size();
    if (h.length !== l._size.length)
      throw new sn(h.length, l._size.length);
    for (var m = d.min(), p = d.max(), v = 0, g = l._size.length; v < g; v++)
      ii(m[v], l._size[v]), ii(p[v], l._size[v]);
    return new r(i(l._data, d, h.length, 0), l._datatype);
  }
  function i(l, d, f, h) {
    var m = h === f - 1, p = d.dimension(h);
    return m ? p.map(function(v) {
      return ii(v, l.length), l[v];
    }).valueOf() : p.map(function(v) {
      ii(v, l.length);
      var g = l[v];
      return i(g, d, f, h + 1);
    }).valueOf();
  }
  function a(l, d, f, h) {
    if (!d || d.isIndex !== !0)
      throw new TypeError("Invalid index");
    var m = d.size(), p = d.isScalar(), v;
    if (Xn(f) ? (v = f.size(), f = f.valueOf()) : v = Kn(f), p) {
      if (v.length !== 0)
        throw new TypeError("Scalar expected");
      l.set(d.min(), f, h);
    } else {
      if (!lf(v, m))
        try {
          v.length === 0 ? f = b9([f], m) : f = b9(f, m), v = Kn(f);
        } catch {
        }
      if (m.length < l._size.length)
        throw new sn(m.length, l._size.length, "<");
      if (v.length < m.length) {
        for (var g = 0, y = 0; m[g] === 1 && v[g] === 1; )
          g++;
        for (; m[g] === 1; )
          y++, g++;
        f = ez(f, m.length, y, v);
      }
      if (!lf(m, v))
        throw new sn(m, v, ">");
      var b = d.max().map(function(x) {
        return x + 1;
      });
      u(l, b, h);
      var S = m.length, _ = 0;
      o(l._data, d, f, S, _);
    }
    return l;
  }
  function o(l, d, f, h, m) {
    var p = m === h - 1, v = d.dimension(m);
    p ? v.forEach(function(g, y) {
      ii(g), l[g] = f[y[0]];
    }) : v.forEach(function(g, y) {
      ii(g), o(l[g], d, f[y[0]], h, m + 1);
    });
  }
  r.prototype.resize = function(l, d, f) {
    if (!py(l))
      throw new TypeError("Array or Matrix expected");
    var h = l.valueOf().map((p) => Array.isArray(p) && p.length === 1 ? p[0] : p), m = f ? this.clone() : this;
    return s(m, h, d);
  };
  function s(l, d, f) {
    if (d.length === 0) {
      for (var h = l._data; Mn(h); )
        h = h[0];
      return h;
    }
    return l._size = d.slice(0), l._data = vy(l._data, l._size, f), l;
  }
  r.prototype.reshape = function(l, d) {
    var f = d ? this.clone() : this;
    f._data = nS(f._data, l);
    var h = f._size.reduce((m, p) => m * p);
    return f._size = iS(l, h), f;
  };
  function u(l, d, f) {
    for (var h = l._size.slice(0), m = !1; h.length < d.length; )
      h.push(0), m = !0;
    for (var p = 0, v = d.length; p < v; p++)
      d[p] > h[p] && (h[p] = d[p], m = !0);
    m && s(l, h, f);
  }
  r.prototype.clone = function() {
    var l = new r({
      data: an(this._data),
      size: an(this._size),
      datatype: this._datatype
    });
    return l;
  }, r.prototype.size = function() {
    return this._size.slice(0);
  }, r.prototype.map = function(l) {
    var d = this, f = oz(l), h = function v(g, y) {
      return Mn(g) ? g.map(function(b, S) {
        return v(b, y.concat(S));
      }) : f === 1 ? l(g) : f === 2 ? l(g, y) : l(g, y, d);
    }, m = h(this._data, []), p = this._datatype !== void 0 ? c2(m, xl) : void 0;
    return new r(m, p);
  }, r.prototype.forEach = function(l) {
    var d = this, f = function h(m, p) {
      Mn(m) ? m.forEach(function(v, g) {
        h(v, p.concat(g));
      }) : l(m, p, d);
    };
    f(this._data, []);
  }, r.prototype[Symbol.iterator] = function* () {
    var l = function* d(f, h) {
      if (Mn(f))
        for (var m = 0; m < f.length; m++)
          yield* d(f[m], h.concat(m));
      else
        yield {
          value: f,
          index: h
        };
    };
    yield* l(this._data, []);
  }, r.prototype.rows = function() {
    var l = [], d = this.size();
    if (d.length !== 2)
      throw new TypeError("Rows can only be returned for a 2D matrix.");
    var f = this._data;
    for (var h of f)
      l.push(new r([h], this._datatype));
    return l;
  }, r.prototype.columns = function() {
    var l = this, d = [], f = this.size();
    if (f.length !== 2)
      throw new TypeError("Rows can only be returned for a 2D matrix.");
    for (var h = this._data, m = function(g) {
      var y = h.map((b) => [b[g]]);
      d.push(new r(y, l._datatype));
    }, p = 0; p < f[1]; p++)
      m(p);
    return d;
  }, r.prototype.toArray = function() {
    return an(this._data);
  }, r.prototype.valueOf = function() {
    return this._data;
  }, r.prototype.format = function(l) {
    return Zn(this._data, l);
  }, r.prototype.toString = function() {
    return Zn(this._data);
  }, r.prototype.toJSON = function() {
    return {
      mathjs: "DenseMatrix",
      data: this._data,
      size: this._size,
      datatype: this._datatype
    };
  }, r.prototype.diagonal = function(l) {
    if (l) {
      if (mi(l) && (l = l.toNumber()), !Gn(l) || !zn(l))
        throw new TypeError("The parameter k must be an integer number");
    } else
      l = 0;
    for (var d = l > 0 ? l : 0, f = l < 0 ? -l : 0, h = this._size[0], m = this._size[1], p = Math.min(h - f, m - d), v = [], g = 0; g < p; g++)
      v[g] = this._data[g + f][g + d];
    return new r({
      data: v,
      size: [p],
      datatype: this._datatype
    });
  }, r.diagonal = function(l, d, f, h) {
    if (!Mn(l))
      throw new TypeError("Array expected, size parameter");
    if (l.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    if (l = l.map(function(C) {
      if (mi(C) && (C = C.toNumber()), !Gn(C) || !zn(C) || C < 1)
        throw new Error("Size values must be positive integers");
      return C;
    }), f) {
      if (mi(f) && (f = f.toNumber()), !Gn(f) || !zn(f))
        throw new TypeError("The parameter k must be an integer number");
    } else
      f = 0;
    var m = f > 0 ? f : 0, p = f < 0 ? -f : 0, v = l[0], g = l[1], y = Math.min(v - p, g - m), b;
    if (Mn(d)) {
      if (d.length !== y)
        throw new Error("Invalid value array length");
      b = function(A) {
        return d[A];
      };
    } else if (Xn(d)) {
      var S = d.size();
      if (S.length !== 1 || S[0] !== y)
        throw new Error("Invalid matrix length");
      b = function(A) {
        return d.get([A]);
      };
    } else
      b = function() {
        return d;
      };
    h || (h = mi(b(0)) ? b(0).mul(0) : 0);
    var _ = [];
    if (l.length > 0) {
      _ = vy(_, l, h);
      for (var x = 0; x < y; x++)
        _[x + p][x + m] = b(x);
    }
    return new r({
      data: _,
      size: [v, g]
    });
  }, r.fromJSON = function(l) {
    return new r(l);
  }, r.prototype.swapRows = function(l, d) {
    if (!Gn(l) || !zn(l) || !Gn(d) || !zn(d))
      throw new Error("Row index must be positive integers");
    if (this._size.length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    return ii(l, this._size[0]), ii(d, this._size[0]), r._swapRows(l, d, this._data), this;
  }, r._swapRows = function(l, d, f) {
    var h = f[l];
    f[l] = f[d], f[d] = h;
  };
  function c(l) {
    return Xn(l) ? c(l.valueOf()) : Mn(l) ? l.map(c) : l;
  }
  return r;
}, {
  isClass: !0
});
function Ta(t, e, r) {
  return t && typeof t.map == "function" ? t.map(function(n) {
    return Ta(n, e);
  }) : e(t);
}
var XP = "isInteger", bpe = ["typed"], _pe = /* @__PURE__ */ vt(XP, bpe, (t) => {
  var {
    typed: e
  } = t;
  return e(XP, {
    number: zn,
    // TODO: what to do with isInteger(add(0.1, 0.2))  ?
    BigNumber: function(n) {
      return n.isInt();
    },
    bigint: function(n) {
      return !0;
    },
    Fraction: function(n) {
      return n.d === 1 && isFinite(n.n);
    },
    "Array | Matrix": e.referToSelf((r) => (n) => Ta(n, r))
  });
}), aS = "number", p4 = "number, number";
function sz(t) {
  return Math.abs(t);
}
sz.signature = aS;
function uz(t, e) {
  return t + e;
}
uz.signature = p4;
function cz(t, e) {
  return t - e;
}
cz.signature = p4;
function lz(t, e) {
  return t * e;
}
lz.signature = p4;
function dz(t) {
  return -t;
}
dz.signature = aS;
function _9(t) {
  return M0e(t);
}
_9.signature = aS;
function fz(t, e) {
  return t * t < 1 && e === 1 / 0 || t * t > 1 && e === -1 / 0 ? 0 : Math.pow(t, e);
}
fz.signature = p4;
function am(t) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
  if (!zn(e) || e < 0 || e > 15)
    throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");
  return parseFloat(FG(t, e));
}
var xpe = Math.PI, Spe = "number";
function pz(t) {
  return t > 0;
}
pz.signature = Spe;
function Dc(t, e) {
  var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1e-9, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  if (r <= 0)
    throw new Error("Relative tolerance must be greater than 0");
  if (n < 0)
    throw new Error("Absolute tolerance must be at least 0");
  return t.isNaN() || e.isNaN() ? !1 : !t.isFinite() || !e.isFinite() ? t.eq(e) : t.eq(e) ? !0 : t.minus(e).abs().lte(t.constructor.max(t.constructor.max(t.abs(), e.abs()).mul(r), n));
}
var YP = "isPositive", Cpe = ["typed", "config"], Ape = /* @__PURE__ */ vt(YP, Cpe, (t) => {
  var {
    typed: e,
    config: r
  } = t;
  return e(YP, {
    number: (n) => Ss(n, 0, r.relTol, r.absTol) ? !1 : pz(n),
    BigNumber: (n) => Dc(n, new n.constructor(0), r.relTol, r.absTol) ? !1 : !n.isNeg() && !n.isZero() && !n.isNaN(),
    bigint: (n) => n > 0n,
    Fraction: (n) => n.s > 0 && n.n > 0,
    Unit: e.referToSelf((n) => (i) => e.find(n, i.valueType())(i.value)),
    "Array | Matrix": e.referToSelf((n) => (i) => Ta(i, n))
  });
}), WP = "isZero", wpe = ["typed", "equalScalar"], Dpe = /* @__PURE__ */ vt(WP, wpe, (t) => {
  var {
    typed: e,
    equalScalar: r
  } = t;
  return e(WP, {
    "number | BigNumber | Complex | Fraction": (n) => r(n, 0),
    bigint: (n) => n === 0n,
    Unit: e.referToSelf((n) => (i) => e.find(n, i.valueType())(i.value)),
    "Array | Matrix": e.referToSelf((n) => (i) => Ta(i, n))
  });
});
function Epe(t, e, r, n) {
  return Ss(t.re, e.re, r, n) && Ss(t.im, e.im, r, n);
}
var w2 = /* @__PURE__ */ vt("compareUnits", ["typed"], (t) => {
  var {
    typed: e
  } = t;
  return {
    "Unit, Unit": e.referToSelf((r) => (n, i) => {
      if (!n.equalBase(i))
        throw new Error("Cannot compare units with different base");
      return e.find(r, [n.valueType(), i.valueType()])(n.value, i.value);
    })
  };
}), yy = "equalScalar", Ipe = ["typed", "config"], Tpe = /* @__PURE__ */ vt(yy, Ipe, (t) => {
  var {
    typed: e,
    config: r
  } = t, n = w2({
    typed: e
  });
  return e(yy, {
    "boolean, boolean": function(a, o) {
      return a === o;
    },
    "number, number": function(a, o) {
      return Ss(a, o, r.relTol, r.absTol);
    },
    "BigNumber, BigNumber": function(a, o) {
      return a.eq(o) || Dc(a, o, r.relTol, r.absTol);
    },
    "bigint, bigint": function(a, o) {
      return a === o;
    },
    "Fraction, Fraction": function(a, o) {
      return a.equals(o);
    },
    "Complex, Complex": function(a, o) {
      return Epe(a, o, r.relTol, r.absTol);
    }
  }, n);
});
vt(yy, ["typed", "config"], (t) => {
  var {
    typed: e,
    config: r
  } = t;
  return e(yy, {
    "number, number": function(i, a) {
      return Ss(i, a, r.relTol, r.absTol);
    }
  });
});
var Mpe = "SparseMatrix", Ppe = ["typed", "equalScalar", "Matrix"], Bpe = /* @__PURE__ */ vt(Mpe, Ppe, (t) => {
  var {
    typed: e,
    equalScalar: r,
    Matrix: n
  } = t;
  function i(p, v) {
    if (!(this instanceof i))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (v && !Eu(v))
      throw new Error("Invalid datatype: " + v);
    if (Xn(p))
      a(this, p, v);
    else if (p && Mn(p.index) && Mn(p.ptr) && Mn(p.size))
      this._values = p.values, this._index = p.index, this._ptr = p.ptr, this._size = p.size, this._datatype = v || p.datatype;
    else if (Mn(p))
      o(this, p, v);
    else {
      if (p)
        throw new TypeError("Unsupported type of data (" + xl(p) + ")");
      this._values = [], this._index = [], this._ptr = [0], this._size = [0, 0], this._datatype = v;
    }
  }
  function a(p, v, g) {
    v.type === "SparseMatrix" ? (p._values = v._values ? an(v._values) : void 0, p._index = an(v._index), p._ptr = an(v._ptr), p._size = an(v._size), p._datatype = g || v._datatype) : o(p, v.valueOf(), g || v._datatype);
  }
  function o(p, v, g) {
    p._values = [], p._index = [], p._ptr = [], p._datatype = g;
    var y = v.length, b = 0, S = r, _ = 0;
    if (Eu(g) && (S = e.find(r, [g, g]) || r, _ = e.convert(0, g)), y > 0) {
      var x = 0;
      do {
        p._ptr.push(p._index.length);
        for (var C = 0; C < y; C++) {
          var A = v[C];
          if (Mn(A)) {
            if (x === 0 && b < A.length && (b = A.length), x < A.length) {
              var w = A[x];
              S(w, _) || (p._values.push(w), p._index.push(C));
            }
          } else
            x === 0 && b < 1 && (b = 1), S(A, _) || (p._values.push(A), p._index.push(C));
        }
        x++;
      } while (x < b);
    }
    p._ptr.push(p._index.length), p._size = [y, b];
  }
  i.prototype = new n(), i.prototype.createSparseMatrix = function(p, v) {
    return new i(p, v);
  }, Object.defineProperty(i, "name", {
    value: "SparseMatrix"
  }), i.prototype.constructor = i, i.prototype.type = "SparseMatrix", i.prototype.isSparseMatrix = !0, i.prototype.getDataType = function() {
    return c2(this._values, xl);
  }, i.prototype.storage = function() {
    return "sparse";
  }, i.prototype.datatype = function() {
    return this._datatype;
  }, i.prototype.create = function(p, v) {
    return new i(p, v);
  }, i.prototype.density = function() {
    var p = this._size[0], v = this._size[1];
    return p !== 0 && v !== 0 ? this._index.length / (p * v) : 0;
  }, i.prototype.subset = function(p, v, g) {
    if (!this._values)
      throw new Error("Cannot invoke subset on a Pattern only matrix");
    switch (arguments.length) {
      case 1:
        return s(this, p);
      case 2:
      case 3:
        return u(this, p, v, g);
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  };
  function s(p, v) {
    if (!$x(v))
      throw new TypeError("Invalid index");
    var g = v.isScalar();
    if (g)
      return p.get(v.min());
    var y = v.size();
    if (y.length !== p._size.length)
      throw new sn(y.length, p._size.length);
    var b, S, _, x, C = v.min(), A = v.max();
    for (b = 0, S = p._size.length; b < S; b++)
      ii(C[b], p._size[b]), ii(A[b], p._size[b]);
    var w = p._values, I = p._index, P = p._ptr, M = v.dimension(0), T = v.dimension(1), F = [], N = [];
    M.forEach(function(U, H) {
      N[U] = H[0], F[U] = !0;
    });
    var R = w ? [] : void 0, L = [], V = [];
    return T.forEach(function(U) {
      for (V.push(L.length), _ = P[U], x = P[U + 1]; _ < x; _++)
        b = I[_], F[b] === !0 && (L.push(N[b]), R && R.push(w[_]));
    }), V.push(L.length), new i({
      values: R,
      index: L,
      ptr: V,
      size: y,
      datatype: p._datatype
    });
  }
  function u(p, v, g, y) {
    if (!v || v.isIndex !== !0)
      throw new TypeError("Invalid index");
    var b = v.size(), S = v.isScalar(), _;
    if (Xn(g) ? (_ = g.size(), g = g.toArray()) : _ = Kn(g), S) {
      if (_.length !== 0)
        throw new TypeError("Scalar expected");
      p.set(v.min(), g, y);
    } else {
      if (b.length !== 1 && b.length !== 2)
        throw new sn(b.length, p._size.length, "<");
      if (_.length < b.length) {
        for (var x = 0, C = 0; b[x] === 1 && _[x] === 1; )
          x++;
        for (; b[x] === 1; )
          C++, x++;
        g = ez(g, b.length, C, _);
      }
      if (!lf(b, _))
        throw new sn(b, _, ">");
      if (b.length === 1) {
        var A = v.dimension(0);
        A.forEach(function(P, M) {
          ii(P), p.set([P, 0], g[M[0]], y);
        });
      } else {
        var w = v.dimension(0), I = v.dimension(1);
        w.forEach(function(P, M) {
          ii(P), I.forEach(function(T, F) {
            ii(T), p.set([P, T], g[M[0]][F[0]], y);
          });
        });
      }
    }
    return p;
  }
  i.prototype.get = function(p) {
    if (!Mn(p))
      throw new TypeError("Array expected");
    if (p.length !== this._size.length)
      throw new sn(p.length, this._size.length);
    if (!this._values)
      throw new Error("Cannot invoke get on a Pattern only matrix");
    var v = p[0], g = p[1];
    ii(v, this._size[0]), ii(g, this._size[1]);
    var y = c(v, this._ptr[g], this._ptr[g + 1], this._index);
    return y < this._ptr[g + 1] && this._index[y] === v ? this._values[y] : 0;
  }, i.prototype.set = function(p, v, g) {
    if (!Mn(p))
      throw new TypeError("Array expected");
    if (p.length !== this._size.length)
      throw new sn(p.length, this._size.length);
    if (!this._values)
      throw new Error("Cannot invoke set on a Pattern only matrix");
    var y = p[0], b = p[1], S = this._size[0], _ = this._size[1], x = r, C = 0;
    Eu(this._datatype) && (x = e.find(r, [this._datatype, this._datatype]) || r, C = e.convert(0, this._datatype)), (y > S - 1 || b > _ - 1) && (f(this, Math.max(y + 1, S), Math.max(b + 1, _), g), S = this._size[0], _ = this._size[1]), ii(y, S), ii(b, _);
    var A = c(y, this._ptr[b], this._ptr[b + 1], this._index);
    return A < this._ptr[b + 1] && this._index[A] === y ? x(v, C) ? l(A, b, this._values, this._index, this._ptr) : this._values[A] = v : x(v, C) || d(A, y, b, v, this._values, this._index, this._ptr), this;
  };
  function c(p, v, g, y) {
    if (g - v === 0)
      return g;
    for (var b = v; b < g; b++)
      if (y[b] === p)
        return b;
    return v;
  }
  function l(p, v, g, y, b) {
    g.splice(p, 1), y.splice(p, 1);
    for (var S = v + 1; S < b.length; S++)
      b[S]--;
  }
  function d(p, v, g, y, b, S, _) {
    b.splice(p, 0, y), S.splice(p, 0, v);
    for (var x = g + 1; x < _.length; x++)
      _[x]++;
  }
  i.prototype.resize = function(p, v, g) {
    if (!py(p))
      throw new TypeError("Array or Matrix expected");
    var y = p.valueOf().map((S) => Array.isArray(S) && S.length === 1 ? S[0] : S);
    if (y.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    y.forEach(function(S) {
      if (!Gn(S) || !zn(S) || S < 0)
        throw new TypeError("Invalid size, must contain positive integers (size: " + Zn(y) + ")");
    });
    var b = g ? this.clone() : this;
    return f(b, y[0], y[1], v);
  };
  function f(p, v, g, y) {
    var b = y || 0, S = r, _ = 0;
    Eu(p._datatype) && (S = e.find(r, [p._datatype, p._datatype]) || r, _ = e.convert(0, p._datatype), b = e.convert(b, p._datatype));
    var x = !S(b, _), C = p._size[0], A = p._size[1], w, I, P;
    if (g > A) {
      for (I = A; I < g; I++)
        if (p._ptr[I] = p._values.length, x)
          for (w = 0; w < C; w++)
            p._values.push(b), p._index.push(w);
      p._ptr[g] = p._values.length;
    } else g < A && (p._ptr.splice(g + 1, A - g), p._values.splice(p._ptr[g], p._values.length), p._index.splice(p._ptr[g], p._index.length));
    if (A = g, v > C) {
      if (x) {
        var M = 0;
        for (I = 0; I < A; I++) {
          p._ptr[I] = p._ptr[I] + M, P = p._ptr[I + 1] + M;
          var T = 0;
          for (w = C; w < v; w++, T++)
            p._values.splice(P + T, 0, b), p._index.splice(P + T, 0, w), M++;
        }
        p._ptr[A] = p._values.length;
      }
    } else if (v < C) {
      var F = 0;
      for (I = 0; I < A; I++) {
        p._ptr[I] = p._ptr[I] - F;
        var N = p._ptr[I], R = p._ptr[I + 1] - F;
        for (P = N; P < R; P++)
          w = p._index[P], w > v - 1 && (p._values.splice(P, 1), p._index.splice(P, 1), F++);
      }
      p._ptr[I] = p._values.length;
    }
    return p._size[0] = v, p._size[1] = g, p;
  }
  i.prototype.reshape = function(p, v) {
    if (!Mn(p))
      throw new TypeError("Array expected");
    if (p.length !== 2)
      throw new Error("Sparse matrices can only be reshaped in two dimensions");
    p.forEach(function(U) {
      if (!Gn(U) || !zn(U) || U <= -2 || U === 0)
        throw new TypeError("Invalid size, must contain positive integers or -1 (size: " + Zn(p) + ")");
    });
    var g = this._size[0] * this._size[1];
    p = iS(p, g);
    var y = p[0] * p[1];
    if (g !== y)
      throw new Error("Reshaping sparse matrix will result in the wrong number of elements");
    var b = v ? this.clone() : this;
    if (this._size[0] === p[0] && this._size[1] === p[1])
      return b;
    for (var S = [], _ = 0; _ < b._ptr.length; _++)
      for (var x = 0; x < b._ptr[_ + 1] - b._ptr[_]; x++)
        S.push(_);
    for (var C = b._values.slice(), A = b._index.slice(), w = 0; w < b._index.length; w++) {
      var I = A[w], P = S[w], M = I * b._size[1] + P;
      S[w] = M % p[1], A[w] = Math.floor(M / p[1]);
    }
    b._values.length = 0, b._index.length = 0, b._ptr.length = p[1] + 1, b._size = p.slice();
    for (var T = 0; T < b._ptr.length; T++)
      b._ptr[T] = 0;
    for (var F = 0; F < C.length; F++) {
      var N = A[F], R = S[F], L = C[F], V = c(N, b._ptr[R], b._ptr[R + 1], b._index);
      d(V, N, R, L, b._values, b._index, b._ptr);
    }
    return b;
  }, i.prototype.clone = function() {
    var p = new i({
      values: this._values ? an(this._values) : void 0,
      index: an(this._index),
      ptr: an(this._ptr),
      size: an(this._size),
      datatype: this._datatype
    });
    return p;
  }, i.prototype.size = function() {
    return this._size.slice(0);
  }, i.prototype.map = function(p, v) {
    if (!this._values)
      throw new Error("Cannot invoke map on a Pattern only matrix");
    var g = this, y = this._size[0], b = this._size[1], S = oz(p), _ = function(C, A, w) {
      return S === 1 ? p(C) : S === 2 ? p(C, [A, w]) : p(C, [A, w], g);
    };
    return h(this, 0, y - 1, 0, b - 1, _, v);
  };
  function h(p, v, g, y, b, S, _) {
    var x = [], C = [], A = [], w = r, I = 0;
    Eu(p._datatype) && (w = e.find(r, [p._datatype, p._datatype]) || r, I = e.convert(0, p._datatype));
    for (var P = function(Y, Q, J) {
      Y = S(Y, Q, J), w(Y, I) || (x.push(Y), C.push(Q));
    }, M = y; M <= b; M++) {
      A.push(x.length);
      var T = p._ptr[M], F = p._ptr[M + 1];
      if (_)
        for (var N = T; N < F; N++) {
          var R = p._index[N];
          R >= v && R <= g && P(p._values[N], R - v, M - y);
        }
      else {
        for (var L = {}, V = T; V < F; V++) {
          var U = p._index[V];
          L[U] = p._values[V];
        }
        for (var H = v; H <= g; H++) {
          var K = H in L ? L[H] : 0;
          P(K, H - v, M - y);
        }
      }
    }
    return A.push(x.length), new i({
      values: x,
      index: C,
      ptr: A,
      size: [g - v + 1, b - y + 1]
    });
  }
  i.prototype.forEach = function(p, v) {
    if (!this._values)
      throw new Error("Cannot invoke forEach on a Pattern only matrix");
    for (var g = this, y = this._size[0], b = this._size[1], S = 0; S < b; S++) {
      var _ = this._ptr[S], x = this._ptr[S + 1];
      if (v)
        for (var C = _; C < x; C++) {
          var A = this._index[C];
          p(this._values[C], [A, S], g);
        }
      else {
        for (var w = {}, I = _; I < x; I++) {
          var P = this._index[I];
          w[P] = this._values[I];
        }
        for (var M = 0; M < y; M++) {
          var T = M in w ? w[M] : 0;
          p(T, [M, S], g);
        }
      }
    }
  }, i.prototype[Symbol.iterator] = function* () {
    if (!this._values)
      throw new Error("Cannot iterate a Pattern only matrix");
    for (var p = this._size[1], v = 0; v < p; v++)
      for (var g = this._ptr[v], y = this._ptr[v + 1], b = g; b < y; b++) {
        var S = this._index[b];
        yield {
          value: this._values[b],
          index: [S, v]
        };
      }
  }, i.prototype.toArray = function() {
    return m(this._values, this._index, this._ptr, this._size, !0);
  }, i.prototype.valueOf = function() {
    return m(this._values, this._index, this._ptr, this._size, !1);
  };
  function m(p, v, g, y, b) {
    var S = y[0], _ = y[1], x = [], C, A;
    for (C = 0; C < S; C++)
      for (x[C] = [], A = 0; A < _; A++)
        x[C][A] = 0;
    for (A = 0; A < _; A++)
      for (var w = g[A], I = g[A + 1], P = w; P < I; P++)
        C = v[P], x[C][A] = p ? b ? an(p[P]) : p[P] : 1;
    return x;
  }
  return i.prototype.format = function(p) {
    for (var v = this._size[0], g = this._size[1], y = this.density(), b = "Sparse Matrix [" + Zn(v, p) + " x " + Zn(g, p) + "] density: " + Zn(y, p) + `
`, S = 0; S < g; S++)
      for (var _ = this._ptr[S], x = this._ptr[S + 1], C = _; C < x; C++) {
        var A = this._index[C];
        b += `
    (` + Zn(A, p) + ", " + Zn(S, p) + ") ==> " + (this._values ? Zn(this._values[C], p) : "X");
      }
    return b;
  }, i.prototype.toString = function() {
    return Zn(this.toArray());
  }, i.prototype.toJSON = function() {
    return {
      mathjs: "SparseMatrix",
      values: this._values,
      index: this._index,
      ptr: this._ptr,
      size: this._size,
      datatype: this._datatype
    };
  }, i.prototype.diagonal = function(p) {
    if (p) {
      if (mi(p) && (p = p.toNumber()), !Gn(p) || !zn(p))
        throw new TypeError("The parameter k must be an integer number");
    } else
      p = 0;
    var v = p > 0 ? p : 0, g = p < 0 ? -p : 0, y = this._size[0], b = this._size[1], S = Math.min(y - g, b - v), _ = [], x = [], C = [];
    C[0] = 0;
    for (var A = v; A < b && _.length < S; A++)
      for (var w = this._ptr[A], I = this._ptr[A + 1], P = w; P < I; P++) {
        var M = this._index[P];
        if (M === A - v + g) {
          _.push(this._values[P]), x[_.length - 1] = M - g;
          break;
        }
      }
    return C.push(_.length), new i({
      values: _,
      index: x,
      ptr: C,
      size: [S, 1]
    });
  }, i.fromJSON = function(p) {
    return new i(p);
  }, i.diagonal = function(p, v, g, y, b) {
    if (!Mn(p))
      throw new TypeError("Array expected, size parameter");
    if (p.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    if (p = p.map(function(U) {
      if (mi(U) && (U = U.toNumber()), !Gn(U) || !zn(U) || U < 1)
        throw new Error("Size values must be positive integers");
      return U;
    }), g) {
      if (mi(g) && (g = g.toNumber()), !Gn(g) || !zn(g))
        throw new TypeError("The parameter k must be an integer number");
    } else
      g = 0;
    var S = r, _ = 0;
    Eu(b) && (S = e.find(r, [b, b]) || r, _ = e.convert(0, b));
    var x = g > 0 ? g : 0, C = g < 0 ? -g : 0, A = p[0], w = p[1], I = Math.min(A - C, w - x), P;
    if (Mn(v)) {
      if (v.length !== I)
        throw new Error("Invalid value array length");
      P = function(H) {
        return v[H];
      };
    } else if (Xn(v)) {
      var M = v.size();
      if (M.length !== 1 || M[0] !== I)
        throw new Error("Invalid matrix length");
      P = function(H) {
        return v.get([H]);
      };
    } else
      P = function() {
        return v;
      };
    for (var T = [], F = [], N = [], R = 0; R < w; R++) {
      N.push(T.length);
      var L = R - x;
      if (L >= 0 && L < I) {
        var V = P(L);
        S(V, _) || (F.push(L + C), T.push(V));
      }
    }
    return N.push(T.length), new i({
      values: T,
      index: F,
      ptr: N,
      size: [A, w]
    });
  }, i.prototype.swapRows = function(p, v) {
    if (!Gn(p) || !zn(p) || !Gn(v) || !zn(v))
      throw new Error("Row index must be positive integers");
    if (this._size.length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    return ii(p, this._size[0]), ii(v, this._size[0]), i._swapRows(p, v, this._size[1], this._values, this._index, this._ptr), this;
  }, i._forEachRow = function(p, v, g, y, b) {
    for (var S = y[p], _ = y[p + 1], x = S; x < _; x++)
      b(g[x], v[x]);
  }, i._swapRows = function(p, v, g, y, b, S) {
    for (var _ = 0; _ < g; _++) {
      var x = S[_], C = S[_ + 1], A = c(p, x, C, b), w = c(v, x, C, b);
      if (A < C && w < C && b[A] === p && b[w] === v) {
        if (y) {
          var I = y[A];
          y[A] = y[w], y[w] = I;
        }
        continue;
      }
      if (A < C && b[A] === p && (w >= C || b[w] !== v)) {
        var P = y ? y[A] : void 0;
        b.splice(w, 0, v), y && y.splice(w, 0, P), b.splice(w <= A ? A + 1 : A, 1), y && y.splice(w <= A ? A + 1 : A, 1);
        continue;
      }
      if (w < C && b[w] === v && (A >= C || b[A] !== p)) {
        var M = y ? y[w] : void 0;
        b.splice(A, 0, p), y && y.splice(A, 0, M), b.splice(A <= w ? w + 1 : w, 1), y && y.splice(A <= w ? w + 1 : w, 1);
      }
    }
  }, i;
}, {
  isClass: !0
}), Fpe = "number", Npe = ["typed"];
function Rpe(t) {
  var e = t.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);
  if (e) {
    var r = {
      "0b": 2,
      "0o": 8,
      "0x": 16
    }[e[1]], n = e[2], i = e[3];
    return {
      input: t,
      radix: r,
      integerPart: n,
      fractionalPart: i
    };
  } else
    return null;
}
function Ope(t) {
  for (var e = parseInt(t.integerPart, t.radix), r = 0, n = 0; n < t.fractionalPart.length; n++) {
    var i = parseInt(t.fractionalPart[n], t.radix);
    r += i / Math.pow(t.radix, n + 1);
  }
  var a = e + r;
  if (isNaN(a))
    throw new SyntaxError('String "' + t.input + '" is not a valid number');
  return a;
}
var Lpe = /* @__PURE__ */ vt(Fpe, Npe, (t) => {
  var {
    typed: e
  } = t, r = e("number", {
    "": function() {
      return 0;
    },
    number: function(i) {
      return i;
    },
    string: function(i) {
      if (i === "NaN") return NaN;
      var a = Rpe(i);
      if (a)
        return Ope(a);
      var o = 0, s = i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
      s && (o = Number(s[2]), i = s[1]);
      var u = Number(i);
      if (isNaN(u))
        throw new SyntaxError('String "' + i + '" is not a valid number');
      if (s) {
        if (u > 2 ** o - 1)
          throw new SyntaxError('String "'.concat(i, '" is out of range'));
        u >= 2 ** (o - 1) && (u = u - 2 ** o);
      }
      return u;
    },
    BigNumber: function(i) {
      return i.toNumber();
    },
    bigint: function(i) {
      return Number(i);
    },
    Fraction: function(i) {
      return i.valueOf();
    },
    Unit: e.referToSelf((n) => (i) => {
      var a = i.clone();
      return a.value = n(i.value), a;
    }),
    null: function(i) {
      return 0;
    },
    "Unit, string | Unit": function(i, a) {
      return i.toNumber(a);
    },
    "Array | Matrix": e.referToSelf((n) => (i) => Ta(i, n))
  });
  return r.fromJSON = function(n) {
    return parseFloat(n.value);
  }, r;
}), kpe = "bignumber", Gpe = ["typed", "BigNumber"], zpe = /* @__PURE__ */ vt(kpe, Gpe, (t) => {
  var {
    typed: e,
    BigNumber: r
  } = t;
  return e("bignumber", {
    "": function() {
      return new r(0);
    },
    number: function(i) {
      return new r(i + "");
    },
    string: function(i) {
      var a = i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
      if (a) {
        var o = a[2], s = r(a[1]), u = new r(2).pow(Number(o));
        if (s.gt(u.sub(1)))
          throw new SyntaxError('String "'.concat(i, '" is out of range'));
        var c = new r(2).pow(Number(o) - 1);
        return s.gte(c) ? s.sub(u) : s;
      }
      return new r(i);
    },
    BigNumber: function(i) {
      return i;
    },
    bigint: function(i) {
      return new r(i.toString());
    },
    Unit: e.referToSelf((n) => (i) => {
      var a = i.clone();
      return a.value = n(i.value), a;
    }),
    Fraction: function(i) {
      return new r(i.n).div(i.d).times(i.s);
    },
    null: function(i) {
      return new r(0);
    },
    "Array | Matrix": e.referToSelf((n) => (i) => Ta(i, n))
  });
}), Vpe = "complex", Upe = ["typed", "Complex"], Hpe = /* @__PURE__ */ vt(Vpe, Upe, (t) => {
  var {
    typed: e,
    Complex: r
  } = t;
  return e("complex", {
    "": function() {
      return r.ZERO;
    },
    number: function(i) {
      return new r(i, 0);
    },
    "number, number": function(i, a) {
      return new r(i, a);
    },
    // TODO: this signature should be redundant
    "BigNumber, BigNumber": function(i, a) {
      return new r(i.toNumber(), a.toNumber());
    },
    Fraction: function(i) {
      return new r(i.valueOf(), 0);
    },
    Complex: function(i) {
      return i.clone();
    },
    string: function(i) {
      return r(i);
    },
    null: function(i) {
      return r(0);
    },
    Object: function(i) {
      if ("re" in i && "im" in i)
        return new r(i.re, i.im);
      if ("r" in i && "phi" in i || "abs" in i && "arg" in i)
        return new r(i);
      throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)");
    },
    "Array | Matrix": e.referToSelf((n) => (i) => Ta(i, n))
  });
}), qpe = "fraction", Kpe = ["typed", "Fraction"], Xpe = /* @__PURE__ */ vt(qpe, Kpe, (t) => {
  var {
    typed: e,
    Fraction: r
  } = t;
  return e("fraction", {
    number: function(i) {
      if (!isFinite(i) || isNaN(i))
        throw new Error(i + " cannot be represented as a fraction");
      return new r(i);
    },
    string: function(i) {
      return new r(i);
    },
    "number, number": function(i, a) {
      return new r(i, a);
    },
    null: function(i) {
      return new r(0);
    },
    BigNumber: function(i) {
      return new r(i.toString());
    },
    bigint: function(i) {
      return new r(i.toString());
    },
    Fraction: function(i) {
      return i;
    },
    Unit: e.referToSelf((n) => (i) => {
      var a = i.clone();
      return a.value = n(i.value), a;
    }),
    Object: function(i) {
      return new r(i);
    },
    "Array | Matrix": e.referToSelf((n) => (i) => Ta(i, n))
  });
}), jP = "matrix", Ype = ["typed", "Matrix", "DenseMatrix", "SparseMatrix"], Wpe = /* @__PURE__ */ vt(jP, Ype, (t) => {
  var {
    typed: e,
    Matrix: r,
    DenseMatrix: n,
    SparseMatrix: i
  } = t;
  return e(jP, {
    "": function() {
      return a([]);
    },
    string: function(s) {
      return a([], s);
    },
    "string, string": function(s, u) {
      return a([], s, u);
    },
    Array: function(s) {
      return a(s);
    },
    Matrix: function(s) {
      return a(s, s.storage());
    },
    "Array | Matrix, string": a,
    "Array | Matrix, string, string": a
  });
  function a(o, s, u) {
    if (s === "dense" || s === "default" || s === void 0)
      return new n(o, u);
    if (s === "sparse")
      return new i(o, u);
    throw new TypeError("Unknown matrix type " + JSON.stringify(s) + ".");
  }
}), ZP = "matrixFromColumns", jpe = ["typed", "matrix", "flatten", "size"], Zpe = /* @__PURE__ */ vt(ZP, jpe, (t) => {
  var {
    typed: e,
    matrix: r,
    flatten: n,
    size: i
  } = t;
  return e(ZP, {
    "...Array": function(u) {
      return a(u);
    },
    "...Matrix": function(u) {
      return r(a(u.map((c) => c.toArray())));
    }
    // TODO implement this properly for SparseMatrix
  });
  function a(s) {
    if (s.length === 0) throw new TypeError("At least one column is needed to construct a matrix.");
    for (var u = o(s[0]), c = [], l = 0; l < u; l++)
      c[l] = [];
    for (var d of s) {
      var f = o(d);
      if (f !== u)
        throw new TypeError("The vectors had different length: " + (u | 0) + " ≠ " + (f | 0));
      for (var h = n(d), m = 0; m < u; m++)
        c[m].push(h[m]);
    }
    return c;
  }
  function o(s) {
    var u = i(s);
    if (u.length === 1)
      return u[0];
    if (u.length === 2) {
      if (u[0] === 1)
        return u[1];
      if (u[1] === 1)
        return u[0];
      throw new TypeError("At least one of the arguments is not a vector.");
    } else
      throw new TypeError("Only one- or two-dimensional vectors are supported.");
  }
}), QP = "unaryMinus", Qpe = ["typed"], Jpe = /* @__PURE__ */ vt(QP, Qpe, (t) => {
  var {
    typed: e
  } = t;
  return e(QP, {
    number: dz,
    "Complex | BigNumber | Fraction": (r) => r.neg(),
    bigint: (r) => -r,
    Unit: e.referToSelf((r) => (n) => {
      var i = n.clone();
      return i.value = e.find(r, i.valueType())(n.value), i;
    }),
    // deep map collection, skip zeros since unaryMinus(0) = 0
    "Array | Matrix": e.referToSelf((r) => (n) => Ta(n, r))
    // TODO: add support for string
  });
}), JP = "abs", $pe = ["typed"], ehe = /* @__PURE__ */ vt(JP, $pe, (t) => {
  var {
    typed: e
  } = t;
  return e(JP, {
    number: sz,
    "Complex | BigNumber | Fraction | Unit": (r) => r.abs(),
    bigint: (r) => r < 0n ? -r : r,
    // deep map collection, skip zeros since abs(0) = 0
    "Array | Matrix": e.referToSelf((r) => (n) => Ta(n, r))
  });
}), $P = "addScalar", the = ["typed"], rhe = /* @__PURE__ */ vt($P, the, (t) => {
  var {
    typed: e
  } = t;
  return e($P, {
    "number, number": uz,
    "Complex, Complex": function(n, i) {
      return n.add(i);
    },
    "BigNumber, BigNumber": function(n, i) {
      return n.plus(i);
    },
    "bigint, bigint": function(n, i) {
      return n + i;
    },
    "Fraction, Fraction": function(n, i) {
      return n.add(i);
    },
    "Unit, Unit": e.referToSelf((r) => (n, i) => {
      if (n.value === null || n.value === void 0)
        throw new Error("Parameter x contains a unit with undefined value");
      if (i.value === null || i.value === void 0)
        throw new Error("Parameter y contains a unit with undefined value");
      if (!n.equalBase(i)) throw new Error("Units do not match");
      var a = n.clone();
      return a.value = e.find(r, [a.valueType(), i.valueType()])(a.value, i.value), a.fixPrefix = !1, a;
    })
  });
}), eB = "subtractScalar", nhe = ["typed"], ihe = /* @__PURE__ */ vt(eB, nhe, (t) => {
  var {
    typed: e
  } = t;
  return e(eB, {
    "number, number": cz,
    "Complex, Complex": function(n, i) {
      return n.sub(i);
    },
    "BigNumber, BigNumber": function(n, i) {
      return n.minus(i);
    },
    "bigint, bigint": function(n, i) {
      return n - i;
    },
    "Fraction, Fraction": function(n, i) {
      return n.sub(i);
    },
    "Unit, Unit": e.referToSelf((r) => (n, i) => {
      if (n.value === null || n.value === void 0)
        throw new Error("Parameter x contains a unit with undefined value");
      if (i.value === null || i.value === void 0)
        throw new Error("Parameter y contains a unit with undefined value");
      if (!n.equalBase(i)) throw new Error("Units do not match");
      var a = n.clone();
      return a.value = e.find(r, [a.valueType(), i.valueType()])(a.value, i.value), a.fixPrefix = !1, a;
    })
  });
}), ahe = "matAlgo11xS0s", ohe = ["typed", "equalScalar"], D2 = /* @__PURE__ */ vt(ahe, ohe, (t) => {
  var {
    typed: e,
    equalScalar: r
  } = t;
  return function(i, a, o, s) {
    var u = i._values, c = i._index, l = i._ptr, d = i._size, f = i._datatype;
    if (!u)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var h = d[0], m = d[1], p, v = r, g = 0, y = o;
    typeof f == "string" && (p = f, v = e.find(r, [p, p]), g = e.convert(0, p), a = e.convert(a, p), y = e.find(o, [p, p]));
    for (var b = [], S = [], _ = [], x = 0; x < m; x++) {
      _[x] = S.length;
      for (var C = l[x], A = l[x + 1], w = C; w < A; w++) {
        var I = c[w], P = s ? y(a, u[w]) : y(u[w], a);
        v(P, g) || (S.push(I), b.push(P));
      }
    }
    return _[m] = S.length, i.createSparseMatrix({
      values: b,
      index: S,
      ptr: _,
      size: [h, m],
      datatype: p
    });
  };
}), she = "matAlgo12xSfs", uhe = ["typed", "DenseMatrix"], Ll = /* @__PURE__ */ vt(she, uhe, (t) => {
  var {
    typed: e,
    DenseMatrix: r
  } = t;
  return function(i, a, o, s) {
    var u = i._values, c = i._index, l = i._ptr, d = i._size, f = i._datatype;
    if (!u)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var h = d[0], m = d[1], p, v = o;
    typeof f == "string" && (p = f, a = e.convert(a, p), v = e.find(o, [p, p]));
    for (var g = [], y = [], b = [], S = 0; S < m; S++) {
      for (var _ = S + 1, x = l[S], C = l[S + 1], A = x; A < C; A++) {
        var w = c[A];
        y[w] = u[A], b[w] = _;
      }
      for (var I = 0; I < h; I++)
        S === 0 && (g[I] = []), b[I] === _ ? g[I][S] = s ? v(a, y[I]) : v(y[I], a) : g[I][S] = s ? v(a, 0) : v(0, a);
    }
    return new r({
      data: g,
      size: [h, m],
      datatype: p
    });
  };
}), che = "matAlgo14xDs", lhe = ["typed"], E2 = /* @__PURE__ */ vt(che, lhe, (t) => {
  var {
    typed: e
  } = t;
  return function(i, a, o, s) {
    var u = i._data, c = i._size, l = i._datatype, d, f = o;
    typeof l == "string" && (d = l, a = e.convert(a, d), f = e.find(o, [d, d]));
    var h = c.length > 0 ? r(f, 0, c, c[0], u, a, s) : [];
    return i.createDenseMatrix({
      data: h,
      size: an(c),
      datatype: d
    });
  };
  function r(n, i, a, o, s, u, c) {
    var l = [];
    if (i === a.length - 1)
      for (var d = 0; d < o; d++)
        l[d] = c ? n(u, s[d]) : n(s[d], u);
    else
      for (var f = 0; f < o; f++)
        l[f] = r(n, i + 1, a, a[i + 1], s[f], u, c);
    return l;
  }
}), x9 = "floor", dhe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"], fhe = /* @__PURE__ */ vt(x9, ["typed", "config", "round"], (t) => {
  var {
    typed: e,
    config: r,
    round: n
  } = t;
  return e(x9, {
    number: function(a) {
      return Ss(a, n(a), r.relTol, r.absTol) ? n(a) : Math.floor(a);
    },
    "number, number": function(a, o) {
      if (Ss(a, n(a, o), r.relTol, r.absTol))
        return n(a, o);
      var [s, u] = "".concat(a, "e").split("e"), c = Math.floor(Number("".concat(s, "e").concat(Number(u) + o)));
      return [s, u] = "".concat(c, "e").split("e"), Number("".concat(s, "e").concat(Number(u) - o));
    }
  });
}), phe = /* @__PURE__ */ vt(x9, dhe, (t) => {
  var {
    typed: e,
    config: r,
    round: n,
    matrix: i,
    equalScalar: a,
    zeros: o,
    DenseMatrix: s
  } = t, u = D2({
    typed: e,
    equalScalar: a
  }), c = Ll({
    typed: e,
    DenseMatrix: s
  }), l = E2({
    typed: e
  }), d = fhe({
    typed: e,
    config: r,
    round: n
  });
  return e("floor", {
    number: d.signatures.number,
    "number,number": d.signatures["number,number"],
    Complex: function(h) {
      return h.floor();
    },
    "Complex, number": function(h, m) {
      return h.floor(m);
    },
    "Complex, BigNumber": function(h, m) {
      return h.floor(m.toNumber());
    },
    BigNumber: function(h) {
      return Dc(h, n(h), r.relTol, r.absTol) ? n(h) : h.floor();
    },
    "BigNumber, BigNumber": function(h, m) {
      return Dc(h, n(h, m), r.relTol, r.absTol) ? n(h, m) : h.toDecimalPlaces(m.toNumber(), B0.ROUND_FLOOR);
    },
    Fraction: function(h) {
      return h.floor();
    },
    "Fraction, number": function(h, m) {
      return h.floor(m);
    },
    "Fraction, BigNumber": function(h, m) {
      return h.floor(m.toNumber());
    },
    "Array | Matrix": e.referToSelf((f) => (h) => Ta(h, f)),
    "Array, number | BigNumber": e.referToSelf((f) => (h, m) => Ta(h, (p) => f(p, m))),
    "SparseMatrix, number | BigNumber": e.referToSelf((f) => (h, m) => u(h, m, f, !1)),
    "DenseMatrix, number | BigNumber": e.referToSelf((f) => (h, m) => l(h, m, f, !1)),
    "number | Complex | Fraction | BigNumber, Array": e.referToSelf((f) => (h, m) => l(i(m), h, f, !0).valueOf()),
    "number | Complex | Fraction | BigNumber, Matrix": e.referToSelf((f) => (h, m) => a(h, 0) ? o(m.size(), m.storage()) : m.storage() === "dense" ? l(m, h, f, !0) : c(m, h, f, !0))
  });
}), hhe = "matAlgo02xDS0", mhe = ["typed", "equalScalar"], ghe = /* @__PURE__ */ vt(hhe, mhe, (t) => {
  var {
    typed: e,
    equalScalar: r
  } = t;
  return function(i, a, o, s) {
    var u = i._data, c = i._size, l = i._datatype || i.getDataType(), d = a._values, f = a._index, h = a._ptr, m = a._size, p = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (c.length !== m.length)
      throw new sn(c.length, m.length);
    if (c[0] !== m[0] || c[1] !== m[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + c + ") must match Matrix B (" + m + ")");
    if (!d)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var v = c[0], g = c[1], y, b = r, S = 0, _ = o;
    typeof l == "string" && l === p && l !== "mixed" && (y = l, b = e.find(r, [y, y]), S = e.convert(0, y), _ = e.find(o, [y, y]));
    for (var x = [], C = [], A = [], w = 0; w < g; w++) {
      A[w] = C.length;
      for (var I = h[w], P = h[w + 1], M = I; M < P; M++) {
        var T = f[M], F = s ? _(d[M], u[T][w]) : _(u[T][w], d[M]);
        b(F, S) || (C.push(T), x.push(F));
      }
    }
    return A[g] = C.length, a.createSparseMatrix({
      values: x,
      index: C,
      ptr: A,
      size: [v, g],
      datatype: l === i._datatype && p === a._datatype ? y : void 0
    });
  };
}), vhe = "matAlgo03xDSf", yhe = ["typed"], U0 = /* @__PURE__ */ vt(vhe, yhe, (t) => {
  var {
    typed: e
  } = t;
  return function(n, i, a, o) {
    var s = n._data, u = n._size, c = n._datatype || n.getDataType(), l = i._values, d = i._index, f = i._ptr, h = i._size, m = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (u.length !== h.length)
      throw new sn(u.length, h.length);
    if (u[0] !== h[0] || u[1] !== h[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + h + ")");
    if (!l)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var p = u[0], v = u[1], g, y = 0, b = a;
    typeof c == "string" && c === m && c !== "mixed" && (g = c, y = e.convert(0, g), b = e.find(a, [g, g]));
    for (var S = [], _ = 0; _ < p; _++)
      S[_] = [];
    for (var x = [], C = [], A = 0; A < v; A++) {
      for (var w = A + 1, I = f[A], P = f[A + 1], M = I; M < P; M++) {
        var T = d[M];
        x[T] = o ? b(l[M], s[T][A]) : b(s[T][A], l[M]), C[T] = w;
      }
      for (var F = 0; F < p; F++)
        C[F] === w ? S[F][A] = x[F] : S[F][A] = o ? b(y, s[F][A]) : b(s[F][A], y);
    }
    return n.createDenseMatrix({
      data: S,
      size: [p, v],
      datatype: c === n._datatype && m === i._datatype ? g : void 0
    });
  };
}), bhe = "matAlgo05xSfSf", _he = ["typed", "equalScalar"], hz = /* @__PURE__ */ vt(bhe, _he, (t) => {
  var {
    typed: e,
    equalScalar: r
  } = t;
  return function(i, a, o) {
    var s = i._values, u = i._index, c = i._ptr, l = i._size, d = i._datatype || i._data === void 0 ? i._datatype : i.getDataType(), f = a._values, h = a._index, m = a._ptr, p = a._size, v = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (l.length !== p.length)
      throw new sn(l.length, p.length);
    if (l[0] !== p[0] || l[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + p + ")");
    var g = l[0], y = l[1], b, S = r, _ = 0, x = o;
    typeof d == "string" && d === v && d !== "mixed" && (b = d, S = e.find(r, [b, b]), _ = e.convert(0, b), x = e.find(o, [b, b]));
    var C = s && f ? [] : void 0, A = [], w = [], I = C ? [] : void 0, P = C ? [] : void 0, M = [], T = [], F, N, R, L;
    for (N = 0; N < y; N++) {
      w[N] = A.length;
      var V = N + 1;
      for (R = c[N], L = c[N + 1]; R < L; R++)
        F = u[R], A.push(F), M[F] = V, I && (I[F] = s[R]);
      for (R = m[N], L = m[N + 1]; R < L; R++)
        F = h[R], M[F] !== V && A.push(F), T[F] = V, P && (P[F] = f[R]);
      if (C)
        for (R = w[N]; R < A.length; ) {
          F = A[R];
          var U = M[F], H = T[F];
          if (U === V || H === V) {
            var K = U === V ? I[F] : _, X = H === V ? P[F] : _, Y = x(K, X);
            S(Y, _) ? A.splice(R, 1) : (C.push(Y), R++);
          }
        }
    }
    return w[y] = A.length, i.createSparseMatrix({
      values: C,
      index: A,
      ptr: w,
      size: [g, y],
      datatype: d === i._datatype && v === a._datatype ? b : void 0
    });
  };
}), xhe = "matAlgo13xDD", She = ["typed"], Che = /* @__PURE__ */ vt(xhe, She, (t) => {
  var {
    typed: e
  } = t;
  return function(i, a, o) {
    var s = i._data, u = i._size, c = i._datatype, l = a._data, d = a._size, f = a._datatype, h = [];
    if (u.length !== d.length)
      throw new sn(u.length, d.length);
    for (var m = 0; m < u.length; m++) {
      if (u[m] !== d[m])
        throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + d + ")");
      h[m] = u[m];
    }
    var p, v = o;
    typeof c == "string" && c === f && (p = c, v = e.find(o, [p, p]));
    var g = h.length > 0 ? r(v, 0, h, h[0], s, l) : [];
    return i.createDenseMatrix({
      data: g,
      size: h,
      datatype: p
    });
  };
  function r(n, i, a, o, s, u) {
    var c = [];
    if (i === a.length - 1)
      for (var l = 0; l < o; l++)
        c[l] = n(s[l], u[l]);
    else
      for (var d = 0; d < o; d++)
        c[d] = r(n, i + 1, a, a[i + 1], s[d], u[d]);
    return c;
  }
});
function ba(t, e) {
  if (lf(t.size(), e.size()))
    return [t, e];
  var r = iz(t.size(), e.size());
  return [t, e].map((n) => Ahe(n, r));
}
function Ahe(t, e) {
  return lf(t.size(), e) ? t : t.create(b9(t.valueOf(), e), t.datatype());
}
var whe = "matrixAlgorithmSuite", Dhe = ["typed", "matrix"], vf = /* @__PURE__ */ vt(whe, Dhe, (t) => {
  var {
    typed: e,
    matrix: r
  } = t, n = Che({
    typed: e
  }), i = E2({
    typed: e
  });
  return function(o) {
    var s = o.elop, u = o.SD || o.DS, c;
    s ? (c = {
      "DenseMatrix, DenseMatrix": (h, m) => n(...ba(h, m), s),
      "Array, Array": (h, m) => n(...ba(r(h), r(m)), s).valueOf(),
      "Array, DenseMatrix": (h, m) => n(...ba(r(h), m), s),
      "DenseMatrix, Array": (h, m) => n(...ba(h, r(m)), s)
    }, o.SS && (c["SparseMatrix, SparseMatrix"] = (h, m) => o.SS(...ba(h, m), s, !1)), o.DS && (c["DenseMatrix, SparseMatrix"] = (h, m) => o.DS(...ba(h, m), s, !1), c["Array, SparseMatrix"] = (h, m) => o.DS(...ba(r(h), m), s, !1)), u && (c["SparseMatrix, DenseMatrix"] = (h, m) => u(...ba(m, h), s, !0), c["SparseMatrix, Array"] = (h, m) => u(...ba(r(m), h), s, !0))) : (c = {
      "DenseMatrix, DenseMatrix": e.referToSelf((h) => (m, p) => n(...ba(m, p), h)),
      "Array, Array": e.referToSelf((h) => (m, p) => n(...ba(r(m), r(p)), h).valueOf()),
      "Array, DenseMatrix": e.referToSelf((h) => (m, p) => n(...ba(r(m), p), h)),
      "DenseMatrix, Array": e.referToSelf((h) => (m, p) => n(...ba(m, r(p)), h))
    }, o.SS && (c["SparseMatrix, SparseMatrix"] = e.referToSelf((h) => (m, p) => o.SS(...ba(m, p), h, !1))), o.DS && (c["DenseMatrix, SparseMatrix"] = e.referToSelf((h) => (m, p) => o.DS(...ba(m, p), h, !1)), c["Array, SparseMatrix"] = e.referToSelf((h) => (m, p) => o.DS(...ba(r(m), p), h, !1))), u && (c["SparseMatrix, DenseMatrix"] = e.referToSelf((h) => (m, p) => u(...ba(p, m), h, !0)), c["SparseMatrix, Array"] = e.referToSelf((h) => (m, p) => u(...ba(r(p), m), h, !0))));
    var l = o.scalar || "any", d = o.Ds || o.Ss;
    d && (s ? (c["DenseMatrix," + l] = (h, m) => i(h, m, s, !1), c[l + ", DenseMatrix"] = (h, m) => i(m, h, s, !0), c["Array," + l] = (h, m) => i(r(h), m, s, !1).valueOf(), c[l + ", Array"] = (h, m) => i(r(m), h, s, !0).valueOf()) : (c["DenseMatrix," + l] = e.referToSelf((h) => (m, p) => i(m, p, h, !1)), c[l + ", DenseMatrix"] = e.referToSelf((h) => (m, p) => i(p, m, h, !0)), c["Array," + l] = e.referToSelf((h) => (m, p) => i(r(m), p, h, !1).valueOf()), c[l + ", Array"] = e.referToSelf((h) => (m, p) => i(r(p), m, h, !0).valueOf())));
    var f = o.sS !== void 0 ? o.sS : o.Ss;
    return s ? (o.Ss && (c["SparseMatrix," + l] = (h, m) => o.Ss(h, m, s, !1)), f && (c[l + ", SparseMatrix"] = (h, m) => f(m, h, s, !0))) : (o.Ss && (c["SparseMatrix," + l] = e.referToSelf((h) => (m, p) => o.Ss(m, p, h, !1))), f && (c[l + ", SparseMatrix"] = e.referToSelf((h) => (m, p) => f(p, m, h, !0)))), s && s.signatures && MG(c, s.signatures), c;
  };
}), tB = "mod", Ehe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], Ihe = /* @__PURE__ */ vt(tB, Ehe, (t) => {
  var {
    typed: e,
    config: r,
    round: n,
    matrix: i,
    equalScalar: a,
    zeros: o,
    DenseMatrix: s,
    concat: u
  } = t, c = phe({
    typed: e,
    config: r,
    round: n,
    matrix: i,
    equalScalar: a,
    zeros: o,
    DenseMatrix: s
  }), l = ghe({
    typed: e,
    equalScalar: a
  }), d = U0({
    typed: e
  }), f = hz({
    typed: e,
    equalScalar: a
  }), h = D2({
    typed: e,
    equalScalar: a
  }), m = Ll({
    typed: e,
    DenseMatrix: s
  }), p = vf({
    typed: e,
    matrix: i,
    concat: u
  });
  return e(tB, {
    "number, number": v,
    "BigNumber, BigNumber": function(y, b) {
      return b.isZero() ? y : y.sub(b.mul(c(y.div(b))));
    },
    "bigint, bigint": function(y, b) {
      if (b === 0n)
        return y;
      if (y < 0) {
        var S = y % b;
        return S === 0n ? S : S + b;
      }
      return y % b;
    },
    "Fraction, Fraction": function(y, b) {
      return b.equals(0) ? y : y.sub(b.mul(c(y.div(b))));
    }
  }, p({
    SS: f,
    DS: d,
    SD: l,
    Ss: h,
    sS: m
  }));
  function v(g, y) {
    return y === 0 ? g : g - y * c(g / y);
  }
}), The = "matAlgo01xDSid", Mhe = ["typed"], mz = /* @__PURE__ */ vt(The, Mhe, (t) => {
  var {
    typed: e
  } = t;
  return function(n, i, a, o) {
    var s = n._data, u = n._size, c = n._datatype || n.getDataType(), l = i._values, d = i._index, f = i._ptr, h = i._size, m = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (u.length !== h.length)
      throw new sn(u.length, h.length);
    if (u[0] !== h[0] || u[1] !== h[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + h + ")");
    if (!l)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var p = u[0], v = u[1], g = typeof c == "string" && c !== "mixed" && c === m ? c : void 0, y = g ? e.find(a, [g, g]) : a, b, S, _ = [];
    for (b = 0; b < p; b++)
      _[b] = [];
    var x = [], C = [];
    for (S = 0; S < v; S++) {
      for (var A = S + 1, w = f[S], I = f[S + 1], P = w; P < I; P++)
        b = d[P], x[b] = o ? y(l[P], s[b][S]) : y(s[b][S], l[P]), C[b] = A;
      for (b = 0; b < p; b++)
        C[b] === A ? _[b][S] = x[b] : _[b][S] = s[b][S];
    }
    return n.createDenseMatrix({
      data: _,
      size: [p, v],
      datatype: c === n._datatype && m === i._datatype ? g : void 0
    });
  };
}), Phe = "matAlgo04xSidSid", Bhe = ["typed", "equalScalar"], Fhe = /* @__PURE__ */ vt(Phe, Bhe, (t) => {
  var {
    typed: e,
    equalScalar: r
  } = t;
  return function(i, a, o) {
    var s = i._values, u = i._index, c = i._ptr, l = i._size, d = i._datatype || i._data === void 0 ? i._datatype : i.getDataType(), f = a._values, h = a._index, m = a._ptr, p = a._size, v = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (l.length !== p.length)
      throw new sn(l.length, p.length);
    if (l[0] !== p[0] || l[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + p + ")");
    var g = l[0], y = l[1], b, S = r, _ = 0, x = o;
    typeof d == "string" && d === v && d !== "mixed" && (b = d, S = e.find(r, [b, b]), _ = e.convert(0, b), x = e.find(o, [b, b]));
    var C = s && f ? [] : void 0, A = [], w = [], I = s && f ? [] : void 0, P = s && f ? [] : void 0, M = [], T = [], F, N, R, L, V;
    for (N = 0; N < y; N++) {
      w[N] = A.length;
      var U = N + 1;
      for (L = c[N], V = c[N + 1], R = L; R < V; R++)
        F = u[R], A.push(F), M[F] = U, I && (I[F] = s[R]);
      for (L = m[N], V = m[N + 1], R = L; R < V; R++)
        if (F = h[R], M[F] === U) {
          if (I) {
            var H = x(I[F], f[R]);
            S(H, _) ? M[F] = null : I[F] = H;
          }
        } else
          A.push(F), T[F] = U, P && (P[F] = f[R]);
      if (I && P)
        for (R = w[N]; R < A.length; )
          F = A[R], M[F] === U ? (C[R] = I[F], R++) : T[F] === U ? (C[R] = P[F], R++) : A.splice(R, 1);
    }
    return w[y] = A.length, i.createSparseMatrix({
      values: C,
      index: A,
      ptr: w,
      size: [g, y],
      datatype: d === i._datatype && v === a._datatype ? b : void 0
    });
  };
}), Nhe = "matAlgo10xSids", Rhe = ["typed", "DenseMatrix"], gz = /* @__PURE__ */ vt(Nhe, Rhe, (t) => {
  var {
    typed: e,
    DenseMatrix: r
  } = t;
  return function(i, a, o, s) {
    var u = i._values, c = i._index, l = i._ptr, d = i._size, f = i._datatype;
    if (!u)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var h = d[0], m = d[1], p, v = o;
    typeof f == "string" && (p = f, a = e.convert(a, p), v = e.find(o, [p, p]));
    for (var g = [], y = [], b = [], S = 0; S < m; S++) {
      for (var _ = S + 1, x = l[S], C = l[S + 1], A = x; A < C; A++) {
        var w = c[A];
        y[w] = u[A], b[w] = _;
      }
      for (var I = 0; I < h; I++)
        S === 0 && (g[I] = []), b[I] === _ ? g[I][S] = s ? v(a, y[I]) : v(y[I], a) : g[I][S] = a;
    }
    return new r({
      data: g,
      size: [h, m],
      datatype: p
    });
  };
}), Ohe = "multiplyScalar", Lhe = ["typed"], khe = /* @__PURE__ */ vt(Ohe, Lhe, (t) => {
  var {
    typed: e
  } = t;
  return e("multiplyScalar", {
    "number, number": lz,
    "Complex, Complex": function(n, i) {
      return n.mul(i);
    },
    "BigNumber, BigNumber": function(n, i) {
      return n.times(i);
    },
    "bigint, bigint": function(n, i) {
      return n * i;
    },
    "Fraction, Fraction": function(n, i) {
      return n.mul(i);
    },
    "number | Fraction | BigNumber | Complex, Unit": (r, n) => n.multiply(r),
    "Unit, number | Fraction | BigNumber | Complex | Unit": (r, n) => r.multiply(n)
  });
}), rB = "multiply", Ghe = ["typed", "matrix", "addScalar", "multiplyScalar", "equalScalar", "dot"], zhe = /* @__PURE__ */ vt(rB, Ghe, (t) => {
  var {
    typed: e,
    matrix: r,
    addScalar: n,
    multiplyScalar: i,
    equalScalar: a,
    dot: o
  } = t, s = D2({
    typed: e,
    equalScalar: a
  }), u = E2({
    typed: e
  });
  function c(_, x) {
    switch (_.length) {
      case 1:
        switch (x.length) {
          case 1:
            if (_[0] !== x[0])
              throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");
            break;
          case 2:
            if (_[0] !== x[0])
              throw new RangeError("Dimension mismatch in multiplication. Vector length (" + _[0] + ") must match Matrix rows (" + x[0] + ")");
            break;
          default:
            throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has " + x.length + " dimensions)");
        }
        break;
      case 2:
        switch (x.length) {
          case 1:
            if (_[1] !== x[0])
              throw new RangeError("Dimension mismatch in multiplication. Matrix columns (" + _[1] + ") must match Vector length (" + x[0] + ")");
            break;
          case 2:
            if (_[1] !== x[0])
              throw new RangeError("Dimension mismatch in multiplication. Matrix A columns (" + _[1] + ") must match Matrix B rows (" + x[0] + ")");
            break;
          default:
            throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has " + x.length + " dimensions)");
        }
        break;
      default:
        throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has " + _.length + " dimensions)");
    }
  }
  function l(_, x, C) {
    if (C === 0)
      throw new Error("Cannot multiply two empty vectors");
    return o(_, x);
  }
  function d(_, x) {
    if (x.storage() !== "dense")
      throw new Error("Support for SparseMatrix not implemented");
    return f(_, x);
  }
  function f(_, x) {
    var C = _._data, A = _._size, w = _._datatype || _.getDataType(), I = x._data, P = x._size, M = x._datatype || x.getDataType(), T = A[0], F = P[1], N, R = n, L = i;
    w && M && w === M && typeof w == "string" && w !== "mixed" && (N = w, R = e.find(n, [N, N]), L = e.find(i, [N, N]));
    for (var V = [], U = 0; U < F; U++) {
      for (var H = L(C[0], I[0][U]), K = 1; K < T; K++)
        H = R(H, L(C[K], I[K][U]));
      V[U] = H;
    }
    return _.createDenseMatrix({
      data: V,
      size: [F],
      datatype: w === _._datatype && M === x._datatype ? N : void 0
    });
  }
  var h = e("_multiplyMatrixVector", {
    "DenseMatrix, any": p,
    "SparseMatrix, any": y
  }), m = e("_multiplyMatrixMatrix", {
    "DenseMatrix, DenseMatrix": v,
    "DenseMatrix, SparseMatrix": g,
    "SparseMatrix, DenseMatrix": b,
    "SparseMatrix, SparseMatrix": S
  });
  function p(_, x) {
    var C = _._data, A = _._size, w = _._datatype || _.getDataType(), I = x._data, P = x._datatype || x.getDataType(), M = A[0], T = A[1], F, N = n, R = i;
    w && P && w === P && typeof w == "string" && w !== "mixed" && (F = w, N = e.find(n, [F, F]), R = e.find(i, [F, F]));
    for (var L = [], V = 0; V < M; V++) {
      for (var U = C[V], H = R(U[0], I[0]), K = 1; K < T; K++)
        H = N(H, R(U[K], I[K]));
      L[V] = H;
    }
    return _.createDenseMatrix({
      data: L,
      size: [M],
      datatype: w === _._datatype && P === x._datatype ? F : void 0
    });
  }
  function v(_, x) {
    var C = _._data, A = _._size, w = _._datatype || _.getDataType(), I = x._data, P = x._size, M = x._datatype || x.getDataType(), T = A[0], F = A[1], N = P[1], R, L = n, V = i;
    w && M && w === M && typeof w == "string" && w !== "mixed" && w !== "mixed" && (R = w, L = e.find(n, [R, R]), V = e.find(i, [R, R]));
    for (var U = [], H = 0; H < T; H++) {
      var K = C[H];
      U[H] = [];
      for (var X = 0; X < N; X++) {
        for (var Y = V(K[0], I[0][X]), Q = 1; Q < F; Q++)
          Y = L(Y, V(K[Q], I[Q][X]));
        U[H][X] = Y;
      }
    }
    return _.createDenseMatrix({
      data: U,
      size: [T, N],
      datatype: w === _._datatype && M === x._datatype ? R : void 0
    });
  }
  function g(_, x) {
    var C = _._data, A = _._size, w = _._datatype || _.getDataType(), I = x._values, P = x._index, M = x._ptr, T = x._size, F = x._datatype || x._data === void 0 ? x._datatype : x.getDataType();
    if (!I)
      throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");
    var N = A[0], R = T[1], L, V = n, U = i, H = a, K = 0;
    w && F && w === F && typeof w == "string" && w !== "mixed" && (L = w, V = e.find(n, [L, L]), U = e.find(i, [L, L]), H = e.find(a, [L, L]), K = e.convert(0, L));
    for (var X = [], Y = [], Q = [], J = x.createSparseMatrix({
      values: X,
      index: Y,
      ptr: Q,
      size: [N, R],
      datatype: w === _._datatype && F === x._datatype ? L : void 0
    }), te = 0; te < R; te++) {
      Q[te] = Y.length;
      var W = M[te], j = M[te + 1];
      if (j > W)
        for (var ee = 0, ie = 0; ie < N; ie++) {
          for (var ae = ie + 1, ce = void 0, de = W; de < j; de++) {
            var Ce = P[de];
            ee !== ae ? (ce = U(C[ie][Ce], I[de]), ee = ae) : ce = V(ce, U(C[ie][Ce], I[de]));
          }
          ee === ae && !H(ce, K) && (Y.push(ie), X.push(ce));
        }
    }
    return Q[R] = Y.length, J;
  }
  function y(_, x) {
    var C = _._values, A = _._index, w = _._ptr, I = _._datatype || _._data === void 0 ? _._datatype : _.getDataType();
    if (!C)
      throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
    var P = x._data, M = x._datatype || x.getDataType(), T = _._size[0], F = x._size[0], N = [], R = [], L = [], V, U = n, H = i, K = a, X = 0;
    I && M && I === M && typeof I == "string" && I !== "mixed" && (V = I, U = e.find(n, [V, V]), H = e.find(i, [V, V]), K = e.find(a, [V, V]), X = e.convert(0, V));
    var Y = [], Q = [];
    L[0] = 0;
    for (var J = 0; J < F; J++) {
      var te = P[J];
      if (!K(te, X))
        for (var W = w[J], j = w[J + 1], ee = W; ee < j; ee++) {
          var ie = A[ee];
          Q[ie] ? Y[ie] = U(Y[ie], H(te, C[ee])) : (Q[ie] = !0, R.push(ie), Y[ie] = H(te, C[ee]));
        }
    }
    for (var ae = R.length, ce = 0; ce < ae; ce++) {
      var de = R[ce];
      N[ce] = Y[de];
    }
    return L[1] = R.length, _.createSparseMatrix({
      values: N,
      index: R,
      ptr: L,
      size: [T, 1],
      datatype: I === _._datatype && M === x._datatype ? V : void 0
    });
  }
  function b(_, x) {
    var C = _._values, A = _._index, w = _._ptr, I = _._datatype || _._data === void 0 ? _._datatype : _.getDataType();
    if (!C)
      throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
    var P = x._data, M = x._datatype || x.getDataType(), T = _._size[0], F = x._size[0], N = x._size[1], R, L = n, V = i, U = a, H = 0;
    I && M && I === M && typeof I == "string" && I !== "mixed" && (R = I, L = e.find(n, [R, R]), V = e.find(i, [R, R]), U = e.find(a, [R, R]), H = e.convert(0, R));
    for (var K = [], X = [], Y = [], Q = _.createSparseMatrix({
      values: K,
      index: X,
      ptr: Y,
      size: [T, N],
      datatype: I === _._datatype && M === x._datatype ? R : void 0
    }), J = [], te = [], W = 0; W < N; W++) {
      Y[W] = X.length;
      for (var j = W + 1, ee = 0; ee < F; ee++) {
        var ie = P[ee][W];
        if (!U(ie, H))
          for (var ae = w[ee], ce = w[ee + 1], de = ae; de < ce; de++) {
            var Ce = A[de];
            te[Ce] !== j ? (te[Ce] = j, X.push(Ce), J[Ce] = V(ie, C[de])) : J[Ce] = L(J[Ce], V(ie, C[de]));
          }
      }
      for (var De = Y[W], ke = X.length, He = De; He < ke; He++) {
        var We = X[He];
        K[He] = J[We];
      }
    }
    return Y[N] = X.length, Q;
  }
  function S(_, x) {
    var C = _._values, A = _._index, w = _._ptr, I = _._datatype || _._data === void 0 ? _._datatype : _.getDataType(), P = x._values, M = x._index, T = x._ptr, F = x._datatype || x._data === void 0 ? x._datatype : x.getDataType(), N = _._size[0], R = x._size[1], L = C && P, V, U = n, H = i;
    I && F && I === F && typeof I == "string" && I !== "mixed" && (V = I, U = e.find(n, [V, V]), H = e.find(i, [V, V]));
    for (var K = L ? [] : void 0, X = [], Y = [], Q = _.createSparseMatrix({
      values: K,
      index: X,
      ptr: Y,
      size: [N, R],
      datatype: I === _._datatype && F === x._datatype ? V : void 0
    }), J = L ? [] : void 0, te = [], W, j, ee, ie, ae, ce, de, Ce, De = 0; De < R; De++) {
      Y[De] = X.length;
      var ke = De + 1;
      for (ae = T[De], ce = T[De + 1], ie = ae; ie < ce; ie++)
        if (Ce = M[ie], L)
          for (j = w[Ce], ee = w[Ce + 1], W = j; W < ee; W++)
            de = A[W], te[de] !== ke ? (te[de] = ke, X.push(de), J[de] = H(P[ie], C[W])) : J[de] = U(J[de], H(P[ie], C[W]));
        else
          for (j = w[Ce], ee = w[Ce + 1], W = j; W < ee; W++)
            de = A[W], te[de] !== ke && (te[de] = ke, X.push(de));
      if (L)
        for (var He = Y[De], We = X.length, Ne = He; Ne < We; Ne++) {
          var Je = X[Ne];
          K[Ne] = J[Je];
        }
    }
    return Y[R] = X.length, Q;
  }
  return e(rB, i, {
    // we extend the signatures of multiplyScalar with signatures dealing with matrices
    "Array, Array": e.referTo("Matrix, Matrix", (_) => (x, C) => {
      c(Kn(x), Kn(C));
      var A = _(r(x), r(C));
      return Xn(A) ? A.valueOf() : A;
    }),
    "Matrix, Matrix": function(x, C) {
      var A = x.size(), w = C.size();
      return c(A, w), A.length === 1 ? w.length === 1 ? l(x, C, A[0]) : d(x, C) : w.length === 1 ? h(x, C) : m(x, C);
    },
    "Matrix, Array": e.referTo("Matrix,Matrix", (_) => (x, C) => _(x, r(C))),
    "Array, Matrix": e.referToSelf((_) => (x, C) => _(r(x, C.storage()), C)),
    "SparseMatrix, any": function(x, C) {
      return s(x, C, i, !1);
    },
    "DenseMatrix, any": function(x, C) {
      return u(x, C, i, !1);
    },
    "any, SparseMatrix": function(x, C) {
      return s(C, x, i, !0);
    },
    "any, DenseMatrix": function(x, C) {
      return u(C, x, i, !0);
    },
    "Array, any": function(x, C) {
      return u(r(x), C, i, !1).valueOf();
    },
    "any, Array": function(x, C) {
      return u(r(C), x, i, !0).valueOf();
    },
    "any, any": i,
    "any, any, ...any": e.referToSelf((_) => (x, C, A) => {
      for (var w = _(x, C), I = 0; I < A.length; I++)
        w = _(w, A[I]);
      return w;
    })
  });
}), nB = "sign", Vhe = ["typed", "BigNumber", "Fraction", "complex"], Uhe = /* @__PURE__ */ vt(nB, Vhe, (t) => {
  var {
    typed: e,
    BigNumber: r,
    complex: n,
    Fraction: i
  } = t;
  return e(nB, {
    number: _9,
    Complex: function(o) {
      return o.im === 0 ? n(_9(o.re)) : o.sign();
    },
    BigNumber: function(o) {
      return new r(o.cmp(0));
    },
    bigint: function(o) {
      return o > 0n ? 1n : o < 0n ? -1n : 0n;
    },
    Fraction: function(o) {
      return new i(o.s, 1);
    },
    // deep map collection, skip zeros since sign(0) = 0
    "Array | Matrix": e.referToSelf((a) => (o) => Ta(o, a)),
    Unit: e.referToSelf((a) => (o) => {
      if (!o._isDerived() && o.units[0].unit.offset !== 0)
        throw new TypeError("sign is ambiguous for units with offset");
      return e.find(a, o.valueType())(o.value);
    })
  });
}), Hhe = "sqrt", qhe = ["config", "typed", "Complex"], Khe = /* @__PURE__ */ vt(Hhe, qhe, (t) => {
  var {
    config: e,
    typed: r,
    Complex: n
  } = t;
  return r("sqrt", {
    number: i,
    Complex: function(o) {
      return o.sqrt();
    },
    BigNumber: function(o) {
      return !o.isNegative() || e.predictable ? o.sqrt() : i(o.toNumber());
    },
    Unit: function(o) {
      return o.pow(0.5);
    }
  });
  function i(a) {
    return isNaN(a) ? NaN : a >= 0 || e.predictable ? Math.sqrt(a) : new n(a, 0).sqrt();
  }
}), iB = "subtract", Xhe = ["typed", "matrix", "equalScalar", "subtractScalar", "unaryMinus", "DenseMatrix", "concat"], Yhe = /* @__PURE__ */ vt(iB, Xhe, (t) => {
  var {
    typed: e,
    matrix: r,
    equalScalar: n,
    subtractScalar: i,
    unaryMinus: a,
    DenseMatrix: o,
    concat: s
  } = t, u = mz({
    typed: e
  }), c = U0({
    typed: e
  }), l = hz({
    typed: e,
    equalScalar: n
  }), d = gz({
    typed: e,
    DenseMatrix: o
  }), f = Ll({
    typed: e,
    DenseMatrix: o
  }), h = vf({
    typed: e,
    matrix: r,
    concat: s
  });
  return e(iB, {
    "any, any": i
  }, h({
    elop: i,
    SS: l,
    DS: u,
    SD: c,
    Ss: f,
    sS: d
  }));
}), Whe = "matAlgo07xSSf", jhe = ["typed", "DenseMatrix"], I2 = /* @__PURE__ */ vt(Whe, jhe, (t) => {
  var {
    typed: e,
    DenseMatrix: r
  } = t;
  return function(a, o, s) {
    var u = a._size, c = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), l = o._size, d = o._datatype || o._data === void 0 ? o._datatype : o.getDataType();
    if (u.length !== l.length)
      throw new sn(u.length, l.length);
    if (u[0] !== l[0] || u[1] !== l[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + l + ")");
    var f = u[0], h = u[1], m, p = 0, v = s;
    typeof c == "string" && c === d && c !== "mixed" && (m = c, p = e.convert(0, m), v = e.find(s, [m, m]));
    var g, y, b = [];
    for (g = 0; g < f; g++)
      b[g] = [];
    var S = [], _ = [], x = [], C = [];
    for (y = 0; y < h; y++) {
      var A = y + 1;
      for (n(a, y, x, S, A), n(o, y, C, _, A), g = 0; g < f; g++) {
        var w = x[g] === A ? S[g] : p, I = C[g] === A ? _[g] : p;
        b[g][y] = v(w, I);
      }
    }
    return new r({
      data: b,
      size: [f, h],
      datatype: c === a._datatype && d === o._datatype ? m : void 0
    });
  };
  function n(i, a, o, s, u) {
    for (var c = i._values, l = i._index, d = i._ptr, f = d[a], h = d[a + 1]; f < h; f++) {
      var m = l[f];
      o[m] = u, s[m] = c[f];
    }
  }
}), aB = "conj", Zhe = ["typed"], Qhe = /* @__PURE__ */ vt(aB, Zhe, (t) => {
  var {
    typed: e
  } = t;
  return e(aB, {
    "number | BigNumber | Fraction": (r) => r,
    Complex: (r) => r.conjugate(),
    "Array | Matrix": e.referToSelf((r) => (n) => Ta(n, r))
  });
}), oB = "im", Jhe = ["typed"], $he = /* @__PURE__ */ vt(oB, Jhe, (t) => {
  var {
    typed: e
  } = t;
  return e(oB, {
    number: () => 0,
    "BigNumber | Fraction": (r) => r.mul(0),
    Complex: (r) => r.im,
    "Array | Matrix": e.referToSelf((r) => (n) => Ta(n, r))
  });
}), sB = "re", eme = ["typed"], tme = /* @__PURE__ */ vt(sB, eme, (t) => {
  var {
    typed: e
  } = t;
  return e(sB, {
    "number | BigNumber | Fraction": (r) => r,
    Complex: (r) => r.re,
    "Array | Matrix": e.referToSelf((r) => (n) => Ta(n, r))
  });
}), uB = "concat", rme = ["typed", "matrix", "isInteger"], nme = /* @__PURE__ */ vt(uB, rme, (t) => {
  var {
    typed: e,
    matrix: r,
    isInteger: n
  } = t;
  return e(uB, {
    // TODO: change signature to '...Array | Matrix, dim?' when supported
    "...Array | Matrix | number | BigNumber": function(a) {
      var o, s = a.length, u = -1, c, l = !1, d = [];
      for (o = 0; o < s; o++) {
        var f = a[o];
        if (Xn(f) && (l = !0), Gn(f) || mi(f)) {
          if (o !== s - 1)
            throw new Error("Dimension must be specified as last argument");
          if (c = u, u = f.valueOf(), !n(u))
            throw new TypeError("Integer number expected for dimension");
          if (u < 0 || o > 0 && u > c)
            throw new V0(u, c + 1);
        } else {
          var h = an(f).valueOf(), m = Kn(h);
          if (d[o] = h, c = u, u = m.length - 1, o > 0 && u !== c)
            throw new sn(c + 1, u + 1);
        }
      }
      if (d.length === 0)
        throw new SyntaxError("At least one matrix expected");
      for (var p = d.shift(); d.length; )
        p = nz(p, d.shift(), u);
      return l ? r(p) : p;
    },
    "...string": function(a) {
      return a.join("");
    }
  });
}), cB = "column", ime = ["typed", "Index", "matrix", "range"], ame = /* @__PURE__ */ vt(cB, ime, (t) => {
  var {
    typed: e,
    Index: r,
    matrix: n,
    range: i
  } = t;
  return e(cB, {
    "Matrix, number": a,
    "Array, number": function(s, u) {
      return a(n(an(s)), u).valueOf();
    }
  });
  function a(o, s) {
    if (o.size().length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    ii(s, o.size()[1]);
    var u = i(0, o.size()[0]), c = new r(u, s), l = o.subset(c);
    return Xn(l) ? l : n([[l]]);
  }
}), lB = "cross", ome = ["typed", "matrix", "subtract", "multiply"], sme = /* @__PURE__ */ vt(lB, ome, (t) => {
  var {
    typed: e,
    matrix: r,
    subtract: n,
    multiply: i
  } = t;
  return e(lB, {
    "Matrix, Matrix": function(s, u) {
      return r(a(s.toArray(), u.toArray()));
    },
    "Matrix, Array": function(s, u) {
      return r(a(s.toArray(), u));
    },
    "Array, Matrix": function(s, u) {
      return r(a(s, u.toArray()));
    },
    "Array, Array": a
  });
  function a(o, s) {
    var u = Math.max(Kn(o).length, Kn(s).length);
    o = KP(o), s = KP(s);
    var c = Kn(o), l = Kn(s);
    if (c.length !== 1 || l.length !== 1 || c[0] !== 3 || l[0] !== 3)
      throw new RangeError("Vectors with length 3 expected (Size A = [" + c.join(", ") + "], B = [" + l.join(", ") + "])");
    var d = [n(i(o[1], s[2]), i(o[2], s[1])), n(i(o[2], s[0]), i(o[0], s[2])), n(i(o[0], s[1]), i(o[1], s[0]))];
    return u > 1 ? [d] : d;
  }
}), dB = "diag", ume = ["typed", "matrix", "DenseMatrix", "SparseMatrix"], cme = /* @__PURE__ */ vt(dB, ume, (t) => {
  var {
    typed: e,
    matrix: r,
    DenseMatrix: n,
    SparseMatrix: i
  } = t;
  return e(dB, {
    // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments
    Array: function(c) {
      return a(c, 0, Kn(c), null);
    },
    "Array, number": function(c, l) {
      return a(c, l, Kn(c), null);
    },
    "Array, BigNumber": function(c, l) {
      return a(c, l.toNumber(), Kn(c), null);
    },
    "Array, string": function(c, l) {
      return a(c, 0, Kn(c), l);
    },
    "Array, number, string": function(c, l, d) {
      return a(c, l, Kn(c), d);
    },
    "Array, BigNumber, string": function(c, l, d) {
      return a(c, l.toNumber(), Kn(c), d);
    },
    Matrix: function(c) {
      return a(c, 0, c.size(), c.storage());
    },
    "Matrix, number": function(c, l) {
      return a(c, l, c.size(), c.storage());
    },
    "Matrix, BigNumber": function(c, l) {
      return a(c, l.toNumber(), c.size(), c.storage());
    },
    "Matrix, string": function(c, l) {
      return a(c, 0, c.size(), l);
    },
    "Matrix, number, string": function(c, l, d) {
      return a(c, l, c.size(), d);
    },
    "Matrix, BigNumber, string": function(c, l, d) {
      return a(c, l.toNumber(), c.size(), d);
    }
  });
  function a(u, c, l, d) {
    if (!zn(c))
      throw new TypeError("Second parameter in function diag must be an integer");
    var f = c > 0 ? c : 0, h = c < 0 ? -c : 0;
    switch (l.length) {
      case 1:
        return o(u, c, d, l[0], h, f);
      case 2:
        return s(u, c, d, l, h, f);
    }
    throw new RangeError("Matrix for function diag must be 2 dimensional");
  }
  function o(u, c, l, d, f, h) {
    var m = [d + f, d + h];
    if (l && l !== "sparse" && l !== "dense")
      throw new TypeError("Unknown matrix type ".concat(l, '"'));
    var p = l === "sparse" ? i.diagonal(m, u, c) : n.diagonal(m, u, c);
    return l !== null ? p : p.valueOf();
  }
  function s(u, c, l, d, f, h) {
    if (Xn(u)) {
      var m = u.diagonal(c);
      return l !== null ? l !== m.storage() ? r(m, l) : m : m.valueOf();
    }
    for (var p = Math.min(d[0] - f, d[1] - h), v = [], g = 0; g < p; g++)
      v[g] = u[g + f][g + h];
    return l !== null ? r(v) : v;
  }
}), fB = "flatten", lme = ["typed", "matrix"], dme = /* @__PURE__ */ vt(fB, lme, (t) => {
  var {
    typed: e,
    matrix: r
  } = t;
  return e(fB, {
    Array: function(i) {
      return y9(i);
    },
    Matrix: function(i) {
      var a = y9(i.toArray());
      return r(a);
    }
  });
}), pB = "getMatrixDataType", fme = ["typed"], pme = /* @__PURE__ */ vt(pB, fme, (t) => {
  var {
    typed: e
  } = t;
  return e(pB, {
    Array: function(n) {
      return c2(n, xl);
    },
    Matrix: function(n) {
      return n.getDataType();
    }
  });
}), hB = "identity", hme = ["typed", "config", "matrix", "BigNumber", "DenseMatrix", "SparseMatrix"], mme = /* @__PURE__ */ vt(hB, hme, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n,
    BigNumber: i,
    DenseMatrix: a,
    SparseMatrix: o
  } = t;
  return e(hB, {
    "": function() {
      return r.matrix === "Matrix" ? n([]) : [];
    },
    string: function(l) {
      return n(l);
    },
    "number | BigNumber": function(l) {
      return u(l, l, r.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber, string": function(l, d) {
      return u(l, l, d);
    },
    "number | BigNumber, number | BigNumber": function(l, d) {
      return u(l, d, r.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber, number | BigNumber, string": function(l, d, f) {
      return u(l, d, f);
    },
    Array: function(l) {
      return s(l);
    },
    "Array, string": function(l, d) {
      return s(l, d);
    },
    Matrix: function(l) {
      return s(l.valueOf(), l.storage());
    },
    "Matrix, string": function(l, d) {
      return s(l.valueOf(), d);
    }
  });
  function s(c, l) {
    switch (c.length) {
      case 0:
        return l ? n(l) : [];
      case 1:
        return u(c[0], c[0], l);
      case 2:
        return u(c[0], c[1], l);
      default:
        throw new Error("Vector containing two values expected");
    }
  }
  function u(c, l, d) {
    var f = mi(c) || mi(l) ? i : null;
    if (mi(c) && (c = c.toNumber()), mi(l) && (l = l.toNumber()), !zn(c) || c < 1)
      throw new Error("Parameters in function identity must be positive integers");
    if (!zn(l) || l < 1)
      throw new Error("Parameters in function identity must be positive integers");
    var h = f ? new i(1) : 1, m = f ? new f(0) : 0, p = [c, l];
    if (d) {
      if (d === "sparse")
        return o.diagonal(p, h, 0, m);
      if (d === "dense")
        return a.diagonal(p, h, 0, m);
      throw new TypeError('Unknown matrix type "'.concat(d, '"'));
    }
    for (var v = vy([], p, m), g = c < l ? c : l, y = 0; y < g; y++)
      v[y][y] = h;
    return v;
  }
});
function vz() {
  throw new Error('No "bignumber" implementation available');
}
function gme() {
  throw new Error('No "fraction" implementation available');
}
function yz() {
  throw new Error('No "matrix" implementation available');
}
var mB = "range", vme = ["typed", "config", "?matrix", "?bignumber", "smaller", "smallerEq", "larger", "largerEq", "add", "isPositive"], yme = /* @__PURE__ */ vt(mB, vme, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n,
    bignumber: i,
    smaller: a,
    smallerEq: o,
    larger: s,
    largerEq: u,
    add: c,
    isPositive: l
  } = t;
  return e(mB, {
    // TODO: simplify signatures when typed-function supports default values and optional arguments
    // TODO: a number or boolean should not be converted to string here
    string: f,
    "string, boolean": f,
    "number, number": function(v, g) {
      return d(h(v, g, 1, !1));
    },
    "number, number, number": function(v, g, y) {
      return d(h(v, g, y, !1));
    },
    "number, number, boolean": function(v, g, y) {
      return d(h(v, g, 1, y));
    },
    "number, number, number, boolean": function(v, g, y, b) {
      return d(h(v, g, y, b));
    },
    "BigNumber, BigNumber": function(v, g) {
      var y = v.constructor;
      return d(h(v, g, new y(1), !1));
    },
    "BigNumber, BigNumber, BigNumber": function(v, g, y) {
      return d(h(v, g, y, !1));
    },
    "BigNumber, BigNumber, boolean": function(v, g, y) {
      var b = v.constructor;
      return d(h(v, g, new b(1), y));
    },
    "BigNumber, BigNumber, BigNumber, boolean": function(v, g, y, b) {
      return d(h(v, g, y, b));
    },
    "Unit, Unit, Unit": function(v, g, y) {
      return d(h(v, g, y, !1));
    },
    "Unit, Unit, Unit, boolean": function(v, g, y, b) {
      return d(h(v, g, y, b));
    }
  });
  function d(p) {
    return r.matrix === "Matrix" ? n ? n(p) : yz() : p;
  }
  function f(p, v) {
    var g = m(p);
    if (!g)
      throw new SyntaxError('String "' + p + '" is no valid range');
    return r.number === "BigNumber" ? (i === void 0 && vz(), d(h(i(g.start), i(g.end), i(g.step)))) : d(h(g.start, g.end, g.step, v));
  }
  function h(p, v, g, y) {
    for (var b = [], S = l(g) ? y ? o : a : y ? u : s, _ = p; S(_, v); )
      b.push(_), _ = c(_, g);
    return b;
  }
  function m(p) {
    var v = p.split(":"), g = v.map(function(b) {
      return Number(b);
    }), y = g.some(function(b) {
      return isNaN(b);
    });
    if (y)
      return null;
    switch (g.length) {
      case 2:
        return {
          start: g[0],
          end: g[1],
          step: 1
        };
      case 3:
        return {
          start: g[0],
          end: g[2],
          step: g[1]
        };
      default:
        return null;
    }
  }
}), gB = "reshape", bme = ["typed", "isInteger", "matrix"], _me = /* @__PURE__ */ vt(gB, bme, (t) => {
  var {
    typed: e,
    isInteger: r
  } = t;
  return e(gB, {
    "Matrix, Array": function(i, a) {
      return i.reshape(a, !0);
    },
    "Array, Array": function(i, a) {
      return a.forEach(function(o) {
        if (!r(o))
          throw new TypeError("Invalid size for dimension: " + o);
      }), nS(i, a);
    }
  });
}), vB = "size", xme = ["typed", "config", "?matrix"], Sme = /* @__PURE__ */ vt(vB, xme, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n
  } = t;
  return e(vB, {
    Matrix: function(a) {
      return a.create(a.size());
    },
    Array: Kn,
    string: function(a) {
      return r.matrix === "Array" ? [a.length] : n([a.length]);
    },
    "number | Complex | BigNumber | Unit | boolean | null": function(a) {
      return r.matrix === "Array" ? [] : n ? n([]) : yz();
    }
  });
}), yB = "transpose", Cme = ["typed", "matrix"], Ame = /* @__PURE__ */ vt(yB, Cme, (t) => {
  var {
    typed: e,
    matrix: r
  } = t;
  return e(yB, {
    Array: (o) => n(r(o)).valueOf(),
    Matrix: n,
    any: an
    // scalars
  });
  function n(o) {
    var s = o.size(), u;
    switch (s.length) {
      case 1:
        u = o.clone();
        break;
      case 2:
        {
          var c = s[0], l = s[1];
          if (l === 0)
            throw new RangeError("Cannot transpose a 2D matrix with no columns (size: " + Zn(s) + ")");
          switch (o.storage()) {
            case "dense":
              u = i(o, c, l);
              break;
            case "sparse":
              u = a(o, c, l);
              break;
          }
        }
        break;
      default:
        throw new RangeError("Matrix must be a vector or two dimensional (size: " + Zn(s) + ")");
    }
    return u;
  }
  function i(o, s, u) {
    for (var c = o._data, l = [], d, f = 0; f < u; f++) {
      d = l[f] = [];
      for (var h = 0; h < s; h++)
        d[h] = an(c[h][f]);
    }
    return o.createDenseMatrix({
      data: l,
      size: [u, s],
      datatype: o._datatype
    });
  }
  function a(o, s, u) {
    for (var c = o._values, l = o._index, d = o._ptr, f = c ? [] : void 0, h = [], m = [], p = [], v = 0; v < s; v++)
      p[v] = 0;
    var g, y, b;
    for (g = 0, y = l.length; g < y; g++)
      p[l[g]]++;
    for (var S = 0, _ = 0; _ < s; _++)
      m.push(S), S += p[_], p[_] = m[_];
    for (m.push(S), b = 0; b < u; b++)
      for (var x = d[b], C = d[b + 1], A = x; A < C; A++) {
        var w = p[l[A]]++;
        h[w] = b, c && (f[w] = an(c[A]));
      }
    return o.createSparseMatrix({
      values: f,
      index: h,
      ptr: m,
      size: [u, s],
      datatype: o._datatype
    });
  }
}), bB = "ctranspose", wme = ["typed", "transpose", "conj"], Dme = /* @__PURE__ */ vt(bB, wme, (t) => {
  var {
    typed: e,
    transpose: r,
    conj: n
  } = t;
  return e(bB, {
    any: function(a) {
      return n(r(a));
    }
  });
}), _B = "zeros", Eme = ["typed", "config", "matrix", "BigNumber"], Ime = /* @__PURE__ */ vt(_B, Eme, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n,
    BigNumber: i
  } = t;
  return e(_B, {
    "": function() {
      return r.matrix === "Array" ? a([]) : a([], "default");
    },
    // math.zeros(m, n, p, ..., format)
    // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
    "...number | BigNumber | string": function(c) {
      var l = c[c.length - 1];
      if (typeof l == "string") {
        var d = c.pop();
        return a(c, d);
      } else return r.matrix === "Array" ? a(c) : a(c, "default");
    },
    Array: a,
    Matrix: function(c) {
      var l = c.storage();
      return a(c.valueOf(), l);
    },
    "Array | Matrix, string": function(c, l) {
      return a(c.valueOf(), l);
    }
  });
  function a(u, c) {
    var l = o(u), d = l ? new i(0) : 0;
    if (s(u), c) {
      var f = n(c);
      return u.length > 0 ? f.resize(u, d) : f;
    } else {
      var h = [];
      return u.length > 0 ? vy(h, u, d) : h;
    }
  }
  function o(u) {
    var c = !1;
    return u.forEach(function(l, d, f) {
      mi(l) && (c = !0, f[d] = l.toNumber());
    }), c;
  }
  function s(u) {
    u.forEach(function(c) {
      if (typeof c != "number" || !zn(c) || c < 0)
        throw new Error("Parameters in function zeros must be positive integers");
    });
  }
}), Tme = "numeric", Mme = ["number", "?bignumber", "?fraction"], Pme = /* @__PURE__ */ vt(Tme, Mme, (t) => {
  var {
    number: e,
    bignumber: r,
    fraction: n
  } = t, i = {
    string: !0,
    number: !0,
    BigNumber: !0,
    Fraction: !0
  }, a = {
    number: (o) => e(o),
    BigNumber: r ? (o) => r(o) : vz,
    bigint: (o) => BigInt(o),
    Fraction: n ? (o) => n(o) : gme
  };
  return function(s) {
    var u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "number", c = arguments.length > 2 ? arguments[2] : void 0;
    if (c !== void 0)
      throw new SyntaxError("numeric() takes one or two arguments");
    var l = xl(s);
    if (!(l in i))
      throw new TypeError("Cannot convert " + s + ' of type "' + l + '"; valid input types are ' + Object.keys(i).join(", "));
    if (!(u in a))
      throw new TypeError("Cannot convert " + s + ' to type "' + u + '"; valid output types are ' + Object.keys(a).join(", "));
    return u === l ? s : a[u](s);
  };
}), xB = "divideScalar", Bme = ["typed", "numeric"], Fme = /* @__PURE__ */ vt(xB, Bme, (t) => {
  var {
    typed: e,
    numeric: r
  } = t;
  return e(xB, {
    "number, number": function(i, a) {
      return i / a;
    },
    "Complex, Complex": function(i, a) {
      return i.div(a);
    },
    "BigNumber, BigNumber": function(i, a) {
      return i.div(a);
    },
    "bigint, bigint": function(i, a) {
      return i / a;
    },
    "Fraction, Fraction": function(i, a) {
      return i.div(a);
    },
    "Unit, number | Complex | Fraction | BigNumber | Unit": (n, i) => n.divide(i),
    "number | Fraction | Complex | BigNumber, Unit": (n, i) => i.divideInto(n)
  });
}), SB = "pow", Nme = ["typed", "config", "identity", "multiply", "matrix", "inv", "fraction", "number", "Complex"], Rme = /* @__PURE__ */ vt(SB, Nme, (t) => {
  var {
    typed: e,
    config: r,
    identity: n,
    multiply: i,
    matrix: a,
    inv: o,
    number: s,
    fraction: u,
    Complex: c
  } = t;
  return e(SB, {
    "number, number": l,
    "Complex, Complex": function(m, p) {
      return m.pow(p);
    },
    "BigNumber, BigNumber": function(m, p) {
      return p.isInteger() || m >= 0 || r.predictable ? m.pow(p) : new c(m.toNumber(), 0).pow(p.toNumber(), 0);
    },
    "bigint, bigint": (h, m) => h ** m,
    "Fraction, Fraction": function(m, p) {
      var v = m.pow(p);
      if (v != null)
        return v;
      if (r.predictable)
        throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");
      return l(m.valueOf(), p.valueOf());
    },
    "Array, number": d,
    "Array, BigNumber": function(m, p) {
      return d(m, p.toNumber());
    },
    "Matrix, number": f,
    "Matrix, BigNumber": function(m, p) {
      return f(m, p.toNumber());
    },
    "Unit, number | BigNumber": function(m, p) {
      return m.pow(p);
    }
  });
  function l(h, m) {
    if (r.predictable && !zn(m) && h < 0)
      try {
        var p = u(m), v = s(p);
        if ((m === v || Math.abs((m - v) / m) < 1e-14) && p.d % 2 === 1)
          return (p.n % 2 === 0 ? 1 : -1) * Math.pow(-h, m);
      } catch {
      }
    return r.predictable && (h < -1 && m === 1 / 0 || h > -1 && h < 0 && m === -1 / 0) ? NaN : zn(m) || h >= 0 || r.predictable ? fz(h, m) : h * h < 1 && m === 1 / 0 || h * h > 1 && m === -1 / 0 ? 0 : new c(h, 0).pow(m, 0);
  }
  function d(h, m) {
    if (!zn(m))
      throw new TypeError("For A^b, b must be an integer (value is " + m + ")");
    var p = Kn(h);
    if (p.length !== 2)
      throw new Error("For A^b, A must be 2 dimensional (A has " + p.length + " dimensions)");
    if (p[0] !== p[1])
      throw new Error("For A^b, A must be square (size is " + p[0] + "x" + p[1] + ")");
    if (m < 0)
      try {
        return d(o(h), -m);
      } catch (y) {
        throw y.message === "Cannot calculate inverse, determinant is zero" ? new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is " + m + ")") : y;
      }
    for (var v = n(p[0]).valueOf(), g = h; m >= 1; )
      (m & 1) === 1 && (v = i(g, v)), m >>= 1, g = i(g, g);
    return v;
  }
  function f(h, m) {
    return a(d(h.valueOf(), m));
  }
}), Y1 = "Number of decimals in function round must be an integer", CB = "round", Ome = ["typed", "config", "matrix", "equalScalar", "zeros", "BigNumber", "DenseMatrix"], Lme = /* @__PURE__ */ vt(CB, Ome, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n,
    equalScalar: i,
    zeros: a,
    BigNumber: o,
    DenseMatrix: s
  } = t, u = D2({
    typed: e,
    equalScalar: i
  }), c = Ll({
    typed: e,
    DenseMatrix: s
  }), l = E2({
    typed: e
  });
  function d(f) {
    return Math.abs(A2(f).exponent);
  }
  return e(CB, {
    number: function(h) {
      var m = am(h, d(r.relTol)), p = Ss(h, m, r.relTol, r.absTol) ? m : h;
      return am(p);
    },
    "number, number": function(h, m) {
      var p = d(r.relTol);
      if (m >= p)
        return am(h, m);
      var v = am(h, p), g = Ss(h, v, r.relTol, r.absTol) ? v : h;
      return am(g, m);
    },
    "number, BigNumber": function(h, m) {
      if (!m.isInteger())
        throw new TypeError(Y1);
      return new o(h).toDecimalPlaces(m.toNumber());
    },
    Complex: function(h) {
      return h.round();
    },
    "Complex, number": function(h, m) {
      if (m % 1)
        throw new TypeError(Y1);
      return h.round(m);
    },
    "Complex, BigNumber": function(h, m) {
      if (!m.isInteger())
        throw new TypeError(Y1);
      var p = m.toNumber();
      return h.round(p);
    },
    BigNumber: function(h) {
      var m = new o(h).toDecimalPlaces(d(r.relTol)), p = Dc(h, m, r.relTol, r.absTol) ? m : h;
      return p.toDecimalPlaces(0);
    },
    "BigNumber, BigNumber": function(h, m) {
      if (!m.isInteger())
        throw new TypeError(Y1);
      var p = d(r.relTol);
      if (m >= p)
        return h.toDecimalPlaces(m.toNumber());
      var v = h.toDecimalPlaces(p), g = Dc(h, v, r.relTol, r.absTol) ? v : h;
      return g.toDecimalPlaces(m.toNumber());
    },
    Fraction: function(h) {
      return h.round();
    },
    "Fraction, number": function(h, m) {
      if (m % 1)
        throw new TypeError(Y1);
      return h.round(m);
    },
    "Fraction, BigNumber": function(h, m) {
      if (!m.isInteger())
        throw new TypeError(Y1);
      return h.round(m.toNumber());
    },
    "Unit, number, Unit": e.referToSelf((f) => function(h, m, p) {
      var v = h.toNumeric(p);
      return p.multiply(f(v, m));
    }),
    "Unit, BigNumber, Unit": e.referToSelf((f) => (h, m, p) => f(h, m.toNumber(), p)),
    "Unit, Unit": e.referToSelf((f) => (h, m) => f(h, 0, m)),
    "Array | Matrix, number, Unit": e.referToSelf((f) => (h, m, p) => Ta(h, (v) => f(v, m, p))),
    "Array | Matrix, BigNumber, Unit": e.referToSelf((f) => (h, m, p) => f(h, m.toNumber(), p)),
    "Array | Matrix, Unit": e.referToSelf((f) => (h, m) => f(h, 0, m)),
    "Array | Matrix": e.referToSelf((f) => (h) => Ta(h, f)),
    "SparseMatrix, number | BigNumber": e.referToSelf((f) => (h, m) => u(h, m, f, !1)),
    "DenseMatrix, number | BigNumber": e.referToSelf((f) => (h, m) => l(h, m, f, !1)),
    "Array, number | BigNumber": e.referToSelf((f) => (h, m) => l(n(h), m, f, !1).valueOf()),
    "number | Complex | BigNumber | Fraction, SparseMatrix": e.referToSelf((f) => (h, m) => i(h, 0) ? a(m.size(), m.storage()) : c(m, h, f, !0)),
    "number | Complex | BigNumber | Fraction, DenseMatrix": e.referToSelf((f) => (h, m) => i(h, 0) ? a(m.size(), m.storage()) : l(m, h, f, !0)),
    "number | Complex | BigNumber | Fraction, Array": e.referToSelf((f) => (h, m) => l(n(m), h, f, !0).valueOf())
  });
});
function bz(t) {
  var {
    DenseMatrix: e
  } = t;
  return function(n, i, a) {
    var o = n.size();
    if (o.length !== 2)
      throw new RangeError("Matrix must be two dimensional (size: " + Zn(o) + ")");
    var s = o[0], u = o[1];
    if (s !== u)
      throw new RangeError("Matrix must be square (size: " + Zn(o) + ")");
    var c = [];
    if (Xn(i)) {
      var l = i.size(), d = i._data;
      if (l.length === 1) {
        if (l[0] !== s)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var f = 0; f < s; f++)
          c[f] = [d[f]];
        return new e({
          data: c,
          size: [s, 1],
          datatype: i._datatype
        });
      }
      if (l.length === 2) {
        if (l[0] !== s || l[1] !== 1)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        if (EG(i)) {
          if (a) {
            c = [];
            for (var h = 0; h < s; h++)
              c[h] = [d[h][0]];
            return new e({
              data: c,
              size: [s, 1],
              datatype: i._datatype
            });
          }
          return i;
        }
        if (IG(i)) {
          for (var m = 0; m < s; m++)
            c[m] = [0];
          for (var p = i._values, v = i._index, g = i._ptr, y = g[1], b = g[0]; b < y; b++) {
            var S = v[b];
            c[S][0] = p[b];
          }
          return new e({
            data: c,
            size: [s, 1],
            datatype: i._datatype
          });
        }
      }
      throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
    }
    if (Mn(i)) {
      var _ = Kn(i);
      if (_.length === 1) {
        if (_[0] !== s)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var x = 0; x < s; x++)
          c[x] = [i[x]];
        return new e({
          data: c,
          size: [s, 1]
        });
      }
      if (_.length === 2) {
        if (_[0] !== s || _[1] !== 1)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var C = 0; C < s; C++)
          c[C] = [i[C][0]];
        return new e({
          data: c,
          size: [s, 1]
        });
      }
      throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
    }
  };
}
var AB = "usolve", kme = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], Gme = /* @__PURE__ */ vt(AB, kme, (t) => {
  var {
    typed: e,
    matrix: r,
    divideScalar: n,
    multiplyScalar: i,
    subtractScalar: a,
    equalScalar: o,
    DenseMatrix: s
  } = t, u = bz({
    DenseMatrix: s
  });
  return e(AB, {
    "SparseMatrix, Array | Matrix": function(f, h) {
      return l(f, h);
    },
    "DenseMatrix, Array | Matrix": function(f, h) {
      return c(f, h);
    },
    "Array, Array | Matrix": function(f, h) {
      var m = r(f), p = c(m, h);
      return p.valueOf();
    }
  });
  function c(d, f) {
    f = u(d, f, !0);
    for (var h = f._data, m = d._size[0], p = d._size[1], v = [], g = d._data, y = p - 1; y >= 0; y--) {
      var b = h[y][0] || 0, S = void 0;
      if (o(b, 0))
        S = 0;
      else {
        var _ = g[y][y];
        if (o(_, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        S = n(b, _);
        for (var x = y - 1; x >= 0; x--)
          h[x] = [a(h[x][0] || 0, i(S, g[x][y]))];
      }
      v[y] = [S];
    }
    return new s({
      data: v,
      size: [m, 1]
    });
  }
  function l(d, f) {
    f = u(d, f, !0);
    for (var h = f._data, m = d._size[0], p = d._size[1], v = d._values, g = d._index, y = d._ptr, b = [], S = p - 1; S >= 0; S--) {
      var _ = h[S][0] || 0;
      if (o(_, 0))
        b[S] = [0];
      else {
        for (var x = 0, C = [], A = [], w = y[S], I = y[S + 1], P = I - 1; P >= w; P--) {
          var M = g[P];
          M === S ? x = v[P] : M < S && (C.push(v[P]), A.push(M));
        }
        if (o(x, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        for (var T = n(_, x), F = 0, N = A.length; F < N; F++) {
          var R = A[F];
          h[R] = [a(h[R][0], i(T, C[F]))];
        }
        b[S] = [T];
      }
    }
    return new s({
      data: b,
      size: [m, 1]
    });
  }
}), wB = "usolveAll", zme = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], Vme = /* @__PURE__ */ vt(wB, zme, (t) => {
  var {
    typed: e,
    matrix: r,
    divideScalar: n,
    multiplyScalar: i,
    subtractScalar: a,
    equalScalar: o,
    DenseMatrix: s
  } = t, u = bz({
    DenseMatrix: s
  });
  return e(wB, {
    "SparseMatrix, Array | Matrix": function(f, h) {
      return l(f, h);
    },
    "DenseMatrix, Array | Matrix": function(f, h) {
      return c(f, h);
    },
    "Array, Array | Matrix": function(f, h) {
      var m = r(f), p = c(m, h);
      return p.map((v) => v.valueOf());
    }
  });
  function c(d, f) {
    for (var h = [u(d, f, !0)._data.map((A) => A[0])], m = d._data, p = d._size[0], v = d._size[1], g = v - 1; g >= 0; g--)
      for (var y = h.length, b = 0; b < y; b++) {
        var S = h[b];
        if (o(m[g][g], 0))
          if (o(S[g], 0)) {
            if (b === 0) {
              var x = [...S];
              x[g] = 1;
              for (var C = g - 1; C >= 0; C--)
                x[C] = a(x[C], m[C][g]);
              h.push(x);
            }
          } else {
            if (b === 0)
              return [];
            h.splice(b, 1), b -= 1, y -= 1;
          }
        else {
          S[g] = n(S[g], m[g][g]);
          for (var _ = g - 1; _ >= 0; _--)
            S[_] = a(S[_], i(S[g], m[_][g]));
        }
      }
    return h.map((A) => new s({
      data: A.map((w) => [w]),
      size: [p, 1]
    }));
  }
  function l(d, f) {
    for (var h = [u(d, f, !0)._data.map((K) => K[0])], m = d._size[0], p = d._size[1], v = d._values, g = d._index, y = d._ptr, b = p - 1; b >= 0; b--)
      for (var S = h.length, _ = 0; _ < S; _++) {
        for (var x = h[_], C = [], A = [], w = y[b], I = y[b + 1], P = 0, M = I - 1; M >= w; M--) {
          var T = g[M];
          T === b ? P = v[M] : T < b && (C.push(v[M]), A.push(T));
        }
        if (o(P, 0))
          if (o(x[b], 0)) {
            if (_ === 0) {
              var L = [...x];
              L[b] = 1;
              for (var V = 0, U = A.length; V < U; V++) {
                var H = A[V];
                L[H] = a(L[H], C[V]);
              }
              h.push(L);
            }
          } else {
            if (_ === 0)
              return [];
            h.splice(_, 1), _ -= 1, S -= 1;
          }
        else {
          x[b] = n(x[b], P);
          for (var F = 0, N = A.length; F < N; F++) {
            var R = A[F];
            x[R] = a(x[R], i(x[b], C[F]));
          }
        }
      }
    return h.map((K) => new s({
      data: K.map((X) => [X]),
      size: [m, 1]
    }));
  }
}), by = "equal", Ume = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], Hme = /* @__PURE__ */ vt(by, Ume, (t) => {
  var {
    typed: e,
    matrix: r,
    equalScalar: n,
    DenseMatrix: i,
    concat: a
  } = t, o = U0({
    typed: e
  }), s = I2({
    typed: e,
    DenseMatrix: i
  }), u = Ll({
    typed: e,
    DenseMatrix: i
  }), c = vf({
    typed: e,
    matrix: r,
    concat: a
  });
  return e(by, qme({
    typed: e,
    equalScalar: n
  }), c({
    elop: n,
    SS: s,
    DS: o,
    Ss: u
  }));
}), qme = vt(by, ["typed", "equalScalar"], (t) => {
  var {
    typed: e,
    equalScalar: r
  } = t;
  return e(by, {
    "any, any": function(i, a) {
      return i === null ? a === null : a === null ? i === null : i === void 0 ? a === void 0 : a === void 0 ? i === void 0 : r(i, a);
    }
  });
}), _y = "smaller", Kme = ["typed", "config", "matrix", "DenseMatrix", "concat"], Xme = /* @__PURE__ */ vt(_y, Kme, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n,
    DenseMatrix: i,
    concat: a
  } = t, o = U0({
    typed: e
  }), s = I2({
    typed: e,
    DenseMatrix: i
  }), u = Ll({
    typed: e,
    DenseMatrix: i
  }), c = vf({
    typed: e,
    matrix: n,
    concat: a
  }), l = w2({
    typed: e
  });
  return e(_y, Yme({
    typed: e,
    config: r
  }), {
    "boolean, boolean": (d, f) => d < f,
    "BigNumber, BigNumber": function(f, h) {
      return f.lt(h) && !Dc(f, h, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d < f,
    "Fraction, Fraction": (d, f) => d.compare(f) === -1,
    "Complex, Complex": function(f, h) {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), Yme = /* @__PURE__ */ vt(_y, ["typed", "config"], (t) => {
  var {
    typed: e,
    config: r
  } = t;
  return e(_y, {
    "number, number": function(i, a) {
      return i < a && !Ss(i, a, r.relTol, r.absTol);
    }
  });
}), xy = "smallerEq", Wme = ["typed", "config", "matrix", "DenseMatrix", "concat"], jme = /* @__PURE__ */ vt(xy, Wme, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n,
    DenseMatrix: i,
    concat: a
  } = t, o = U0({
    typed: e
  }), s = I2({
    typed: e,
    DenseMatrix: i
  }), u = Ll({
    typed: e,
    DenseMatrix: i
  }), c = vf({
    typed: e,
    matrix: n,
    concat: a
  }), l = w2({
    typed: e
  });
  return e(xy, Zme({
    typed: e,
    config: r
  }), {
    "boolean, boolean": (d, f) => d <= f,
    "BigNumber, BigNumber": function(f, h) {
      return f.lte(h) || Dc(f, h, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d <= f,
    "Fraction, Fraction": (d, f) => d.compare(f) !== 1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), Zme = /* @__PURE__ */ vt(xy, ["typed", "config"], (t) => {
  var {
    typed: e,
    config: r
  } = t;
  return e(xy, {
    "number, number": function(i, a) {
      return i <= a || Ss(i, a, r.relTol, r.absTol);
    }
  });
}), Sy = "larger", Qme = ["typed", "config", "matrix", "DenseMatrix", "concat"], Jme = /* @__PURE__ */ vt(Sy, Qme, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n,
    DenseMatrix: i,
    concat: a
  } = t, o = U0({
    typed: e
  }), s = I2({
    typed: e,
    DenseMatrix: i
  }), u = Ll({
    typed: e,
    DenseMatrix: i
  }), c = vf({
    typed: e,
    matrix: n,
    concat: a
  }), l = w2({
    typed: e
  });
  return e(Sy, $me({
    typed: e,
    config: r
  }), {
    "boolean, boolean": (d, f) => d > f,
    "BigNumber, BigNumber": function(f, h) {
      return f.gt(h) && !Dc(f, h, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d > f,
    "Fraction, Fraction": (d, f) => d.compare(f) === 1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), $me = /* @__PURE__ */ vt(Sy, ["typed", "config"], (t) => {
  var {
    typed: e,
    config: r
  } = t;
  return e(Sy, {
    "number, number": function(i, a) {
      return i > a && !Ss(i, a, r.relTol, r.absTol);
    }
  });
}), Cy = "largerEq", e2e = ["typed", "config", "matrix", "DenseMatrix", "concat"], t2e = /* @__PURE__ */ vt(Cy, e2e, (t) => {
  var {
    typed: e,
    config: r,
    matrix: n,
    DenseMatrix: i,
    concat: a
  } = t, o = U0({
    typed: e
  }), s = I2({
    typed: e,
    DenseMatrix: i
  }), u = Ll({
    typed: e,
    DenseMatrix: i
  }), c = vf({
    typed: e,
    matrix: n,
    concat: a
  }), l = w2({
    typed: e
  });
  return e(Cy, r2e({
    typed: e,
    config: r
  }), {
    "boolean, boolean": (d, f) => d >= f,
    "BigNumber, BigNumber": function(f, h) {
      return f.gte(h) || Dc(f, h, r.relTol, r.absTol);
    },
    "bigint, bigint": function(f, h) {
      return f >= h;
    },
    "Fraction, Fraction": (d, f) => d.compare(f) !== -1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: s,
    DS: o,
    Ss: u
  }));
}), r2e = /* @__PURE__ */ vt(Cy, ["typed", "config"], (t) => {
  var {
    typed: e,
    config: r
  } = t;
  return e(Cy, {
    "number, number": function(i, a) {
      return i >= a || Ss(i, a, r.relTol, r.absTol);
    }
  });
}), n2e = "ImmutableDenseMatrix", i2e = ["smaller", "DenseMatrix"], a2e = /* @__PURE__ */ vt(n2e, i2e, (t) => {
  var {
    smaller: e,
    DenseMatrix: r
  } = t;
  function n(i, a) {
    if (!(this instanceof n))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (a && !Eu(a))
      throw new Error("Invalid datatype: " + a);
    if (Xn(i) || Mn(i)) {
      var o = new r(i, a);
      this._data = o._data, this._size = o._size, this._datatype = o._datatype, this._min = null, this._max = null;
    } else if (i && Mn(i.data) && Mn(i.size))
      this._data = i.data, this._size = i.size, this._datatype = i.datatype, this._min = typeof i.min < "u" ? i.min : null, this._max = typeof i.max < "u" ? i.max : null;
    else {
      if (i)
        throw new TypeError("Unsupported type of data (" + xl(i) + ")");
      this._data = [], this._size = [0], this._datatype = a, this._min = null, this._max = null;
    }
  }
  return n.prototype = new r(), n.prototype.type = "ImmutableDenseMatrix", n.prototype.isImmutableDenseMatrix = !0, n.prototype.subset = function(i) {
    switch (arguments.length) {
      case 1: {
        var a = r.prototype.subset.call(this, i);
        return Xn(a) ? new n({
          data: a._data,
          size: a._size,
          datatype: a._datatype
        }) : a;
      }
      case 2:
      case 3:
        throw new Error("Cannot invoke set subset on an Immutable Matrix instance");
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  }, n.prototype.set = function() {
    throw new Error("Cannot invoke set on an Immutable Matrix instance");
  }, n.prototype.resize = function() {
    throw new Error("Cannot invoke resize on an Immutable Matrix instance");
  }, n.prototype.reshape = function() {
    throw new Error("Cannot invoke reshape on an Immutable Matrix instance");
  }, n.prototype.clone = function() {
    return new n({
      data: an(this._data),
      size: an(this._size),
      datatype: this._datatype
    });
  }, n.prototype.toJSON = function() {
    return {
      mathjs: "ImmutableDenseMatrix",
      data: this._data,
      size: this._size,
      datatype: this._datatype
    };
  }, n.fromJSON = function(i) {
    return new n(i);
  }, n.prototype.swapRows = function() {
    throw new Error("Cannot invoke swapRows on an Immutable Matrix instance");
  }, n.prototype.min = function() {
    if (this._min === null) {
      var i = null;
      this.forEach(function(a) {
        (i === null || e(a, i)) && (i = a);
      }), this._min = i !== null ? i : void 0;
    }
    return this._min;
  }, n.prototype.max = function() {
    if (this._max === null) {
      var i = null;
      this.forEach(function(a) {
        (i === null || e(i, a)) && (i = a);
      }), this._max = i !== null ? i : void 0;
    }
    return this._max;
  }, n;
}, {
  isClass: !0
}), o2e = "Index", s2e = ["ImmutableDenseMatrix", "getMatrixDataType"], u2e = /* @__PURE__ */ vt(o2e, s2e, (t) => {
  var {
    ImmutableDenseMatrix: e,
    getMatrixDataType: r
  } = t;
  function n(a) {
    if (!(this instanceof n))
      throw new SyntaxError("Constructor must be called with the new operator");
    this._dimensions = [], this._sourceSize = [], this._isScalar = !0;
    for (var o = 0, s = arguments.length; o < s; o++) {
      var u = arguments[o], c = Mn(u), l = Xn(u), d = null;
      if (TG(u))
        this._dimensions.push(u), this._isScalar = !1;
      else if (c || l) {
        var f = void 0;
        r(u) === "boolean" ? (c && (f = i(DB(u).valueOf())), l && (f = i(DB(u._data).valueOf())), d = u.valueOf().length) : f = i(u.valueOf()), this._dimensions.push(f);
        var h = f.size();
        (h.length !== 1 || h[0] !== 1 || d !== null) && (this._isScalar = !1);
      } else if (typeof u == "number")
        this._dimensions.push(i([u]));
      else if (typeof u == "string")
        this._dimensions.push(u);
      else
        throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");
      this._sourceSize.push(d);
    }
  }
  n.prototype.type = "Index", n.prototype.isIndex = !0;
  function i(a) {
    for (var o = 0, s = a.length; o < s; o++)
      if (typeof a[o] != "number" || !zn(a[o]))
        throw new TypeError("Index parameters must be positive integer numbers");
    return new e(a);
  }
  return n.prototype.clone = function() {
    var a = new n();
    return a._dimensions = an(this._dimensions), a._isScalar = this._isScalar, a._sourceSize = this._sourceSize, a;
  }, n.create = function(a) {
    var o = new n();
    return n.apply(o, a), o;
  }, n.prototype.size = function() {
    for (var a = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      a[o] = typeof u == "string" ? 1 : u.size()[0];
    }
    return a;
  }, n.prototype.max = function() {
    for (var a = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      a[o] = typeof u == "string" ? u : u.max();
    }
    return a;
  }, n.prototype.min = function() {
    for (var a = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      a[o] = typeof u == "string" ? u : u.min();
    }
    return a;
  }, n.prototype.forEach = function(a) {
    for (var o = 0, s = this._dimensions.length; o < s; o++)
      a(this._dimensions[o], o, this);
  }, n.prototype.dimension = function(a) {
    return this._dimensions[a] || null;
  }, n.prototype.isObjectProperty = function() {
    return this._dimensions.length === 1 && typeof this._dimensions[0] == "string";
  }, n.prototype.getObjectProperty = function() {
    return this.isObjectProperty() ? this._dimensions[0] : null;
  }, n.prototype.isScalar = function() {
    return this._isScalar;
  }, n.prototype.toArray = function() {
    for (var a = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      a.push(typeof u == "string" ? u : u.toArray());
    }
    return a;
  }, n.prototype.valueOf = n.prototype.toArray, n.prototype.toString = function() {
    for (var a = [], o = 0, s = this._dimensions.length; o < s; o++) {
      var u = this._dimensions[o];
      typeof u == "string" ? a.push(JSON.stringify(u)) : a.push(u.toString());
    }
    return "[" + a.join(", ") + "]";
  }, n.prototype.toJSON = function() {
    return {
      mathjs: "Index",
      dimensions: this._dimensions
    };
  }, n.fromJSON = function(a) {
    return n.create(a.dimensions);
  }, n;
}, {
  isClass: !0
});
function DB(t) {
  var e = [];
  return t.forEach((r, n) => {
    r && e.push(n);
  }), e;
}
f4(function(t) {
  return new t(1).exp();
}, {
  hasher: h4
});
f4(function(t) {
  return new t(1).plus(new t(5).sqrt()).div(2);
}, {
  hasher: h4
});
var _z = f4(function(t) {
  return t.acos(-1);
}, {
  hasher: h4
});
f4(function(t) {
  return _z(t).times(2);
}, {
  hasher: h4
});
function h4(t) {
  return t[0].precision;
}
var EB = "acos", c2e = ["typed", "config", "Complex"], l2e = /* @__PURE__ */ vt(EB, c2e, (t) => {
  var {
    typed: e,
    config: r,
    Complex: n
  } = t;
  return e(EB, {
    number: function(a) {
      return a >= -1 && a <= 1 || r.predictable ? Math.acos(a) : new n(a, 0).acos();
    },
    Complex: function(a) {
      return a.acos();
    },
    BigNumber: function(a) {
      return a.acos();
    }
  });
}), d2e = "atan", f2e = ["typed"], p2e = /* @__PURE__ */ vt(d2e, f2e, (t) => {
  var {
    typed: e
  } = t;
  return e("atan", {
    number: function(n) {
      return Math.atan(n);
    },
    Complex: function(n) {
      return n.atan();
    },
    BigNumber: function(n) {
      return n.atan();
    }
  });
}), xz = /* @__PURE__ */ vt("trigUnit", ["typed"], (t) => {
  var {
    typed: e
  } = t;
  return {
    Unit: e.referToSelf((r) => (n) => {
      if (!n.hasBase(n.constructor.BASE_UNITS.ANGLE))
        throw new TypeError("Unit in function cot is no angle");
      return e.find(r, n.valueType())(n.value);
    })
  };
}), IB = "cos", h2e = ["typed"], m2e = /* @__PURE__ */ vt(IB, h2e, (t) => {
  var {
    typed: e
  } = t, r = xz({
    typed: e
  });
  return e(IB, {
    number: Math.cos,
    "Complex | BigNumber": (n) => n.cos()
  }, r);
}), TB = "sin", g2e = ["typed"], v2e = /* @__PURE__ */ vt(TB, g2e, (t) => {
  var {
    typed: e
  } = t, r = xz({
    typed: e
  });
  return e(TB, {
    number: Math.sin,
    "Complex | BigNumber": (n) => n.sin()
  }, r);
}), MB = "add", y2e = ["typed", "matrix", "addScalar", "equalScalar", "DenseMatrix", "SparseMatrix", "concat"], b2e = /* @__PURE__ */ vt(MB, y2e, (t) => {
  var {
    typed: e,
    matrix: r,
    addScalar: n,
    equalScalar: i,
    DenseMatrix: a,
    SparseMatrix: o,
    concat: s
  } = t, u = mz({
    typed: e
  }), c = Fhe({
    typed: e,
    equalScalar: i
  }), l = gz({
    typed: e,
    DenseMatrix: a
  }), d = vf({
    typed: e,
    matrix: r,
    concat: s
  });
  return e(MB, {
    "any, any": n,
    "any, any, ...any": e.referToSelf((f) => (h, m, p) => {
      for (var v = f(h, m), g = 0; g < p.length; g++)
        v = f(v, p[g]);
      return v;
    })
  }, d({
    elop: n,
    DS: u,
    SS: c,
    Ss: l
  }));
}), PB = "norm", _2e = ["typed", "abs", "add", "pow", "conj", "sqrt", "multiply", "equalScalar", "larger", "smaller", "matrix", "ctranspose", "eigs"], x2e = /* @__PURE__ */ vt(PB, _2e, (t) => {
  var {
    typed: e,
    abs: r,
    add: n,
    pow: i,
    conj: a,
    sqrt: o,
    multiply: s,
    equalScalar: u,
    larger: c,
    smaller: l,
    matrix: d,
    ctranspose: f,
    eigs: h
  } = t;
  return e(PB, {
    number: Math.abs,
    Complex: function(A) {
      return A.abs();
    },
    BigNumber: function(A) {
      return A.abs();
    },
    boolean: function(A) {
      return Math.abs(A);
    },
    Array: function(A) {
      return x(d(A), 2);
    },
    Matrix: function(A) {
      return x(A, 2);
    },
    "Array, number | BigNumber | string": function(A, w) {
      return x(d(A), w);
    },
    "Matrix, number | BigNumber | string": function(A, w) {
      return x(A, w);
    }
  });
  function m(C) {
    var A = 0;
    return C.forEach(function(w) {
      var I = r(w);
      c(I, A) && (A = I);
    }, !0), A;
  }
  function p(C) {
    var A;
    return C.forEach(function(w) {
      var I = r(w);
      (!A || l(I, A)) && (A = I);
    }, !0), A || 0;
  }
  function v(C, A) {
    if (A === Number.POSITIVE_INFINITY || A === "inf")
      return m(C);
    if (A === Number.NEGATIVE_INFINITY || A === "-inf")
      return p(C);
    if (A === "fro")
      return x(C, 2);
    if (typeof A == "number" && !isNaN(A)) {
      if (!u(A, 0)) {
        var w = 0;
        return C.forEach(function(I) {
          w = n(i(r(I), A), w);
        }, !0), i(w, 1 / A);
      }
      return Number.POSITIVE_INFINITY;
    }
    throw new Error("Unsupported parameter value");
  }
  function g(C) {
    var A = 0;
    return C.forEach(function(w, I) {
      A = n(A, s(w, a(w)));
    }), r(o(A));
  }
  function y(C) {
    var A = [], w = 0;
    return C.forEach(function(I, P) {
      var M = P[1], T = n(A[M] || 0, r(I));
      c(T, w) && (w = T), A[M] = T;
    }, !0), w;
  }
  function b(C) {
    var A = C.size();
    if (A[0] !== A[1])
      throw new RangeError("Invalid matrix dimensions");
    var w = f(C), I = s(w, C), P = h(I).values.toArray(), M = P[P.length - 1];
    return r(o(M));
  }
  function S(C) {
    var A = [], w = 0;
    return C.forEach(function(I, P) {
      var M = P[0], T = n(A[M] || 0, r(I));
      c(T, w) && (w = T), A[M] = T;
    }, !0), w;
  }
  function _(C, A) {
    if (A === 1)
      return y(C);
    if (A === Number.POSITIVE_INFINITY || A === "inf")
      return S(C);
    if (A === "fro")
      return g(C);
    if (A === 2)
      return b(C);
    throw new Error("Unsupported parameter value " + A);
  }
  function x(C, A) {
    var w = C.size();
    if (w.length === 1)
      return v(C, A);
    if (w.length === 2) {
      if (w[0] && w[1])
        return _(C, A);
      throw new RangeError("Invalid matrix dimensions");
    }
  }
}), BB = "dot", S2e = ["typed", "addScalar", "multiplyScalar", "conj", "size"], C2e = /* @__PURE__ */ vt(BB, S2e, (t) => {
  var {
    typed: e,
    addScalar: r,
    multiplyScalar: n,
    conj: i,
    size: a
  } = t;
  return e(BB, {
    "Array | DenseMatrix, Array | DenseMatrix": s,
    "SparseMatrix, SparseMatrix": u
  });
  function o(l, d) {
    var f = c(l), h = c(d), m, p;
    if (f.length === 1)
      m = f[0];
    else if (f.length === 2 && f[1] === 1)
      m = f[0];
    else
      throw new RangeError("Expected a column vector, instead got a matrix of size (" + f.join(", ") + ")");
    if (h.length === 1)
      p = h[0];
    else if (h.length === 2 && h[1] === 1)
      p = h[0];
    else
      throw new RangeError("Expected a column vector, instead got a matrix of size (" + h.join(", ") + ")");
    if (m !== p) throw new RangeError("Vectors must have equal length (" + m + " != " + p + ")");
    if (m === 0) throw new RangeError("Cannot calculate the dot product of empty vectors");
    return m;
  }
  function s(l, d) {
    var f = o(l, d), h = Xn(l) ? l._data : l, m = Xn(l) ? l._datatype || l.getDataType() : void 0, p = Xn(d) ? d._data : d, v = Xn(d) ? d._datatype || d.getDataType() : void 0, g = c(l).length === 2, y = c(d).length === 2, b = r, S = n;
    if (m && v && m === v && typeof m == "string" && m !== "mixed") {
      var _ = m;
      b = e.find(r, [_, _]), S = e.find(n, [_, _]);
    }
    if (!g && !y) {
      for (var x = S(i(h[0]), p[0]), C = 1; C < f; C++)
        x = b(x, S(i(h[C]), p[C]));
      return x;
    }
    if (!g && y) {
      for (var A = S(i(h[0]), p[0][0]), w = 1; w < f; w++)
        A = b(A, S(i(h[w]), p[w][0]));
      return A;
    }
    if (g && !y) {
      for (var I = S(i(h[0][0]), p[0]), P = 1; P < f; P++)
        I = b(I, S(i(h[P][0]), p[P]));
      return I;
    }
    if (g && y) {
      for (var M = S(i(h[0][0]), p[0][0]), T = 1; T < f; T++)
        M = b(M, S(i(h[T][0]), p[T][0]));
      return M;
    }
  }
  function u(l, d) {
    o(l, d);
    for (var f = l._index, h = l._values, m = d._index, p = d._values, v = 0, g = r, y = n, b = 0, S = 0; b < f.length && S < m.length; ) {
      var _ = f[b], x = m[S];
      if (_ < x) {
        b++;
        continue;
      }
      if (_ > x) {
        S++;
        continue;
      }
      _ === x && (v = g(v, y(h[b], p[S])), b++, S++);
    }
    return v;
  }
  function c(l) {
    return Xn(l) ? l.size() : a(l);
  }
}), FB = "qr", A2e = ["typed", "matrix", "zeros", "identity", "isZero", "equal", "sign", "sqrt", "conj", "unaryMinus", "addScalar", "divideScalar", "multiplyScalar", "subtractScalar", "complex"], w2e = /* @__PURE__ */ vt(FB, A2e, (t) => {
  var {
    typed: e,
    matrix: r,
    zeros: n,
    identity: i,
    isZero: a,
    equal: o,
    sign: s,
    sqrt: u,
    conj: c,
    unaryMinus: l,
    addScalar: d,
    divideScalar: f,
    multiplyScalar: h,
    subtractScalar: m,
    complex: p
  } = t;
  return Up(e(FB, {
    DenseMatrix: function(S) {
      return g(S);
    },
    SparseMatrix: function(S) {
      return y();
    },
    Array: function(S) {
      var _ = r(S), x = g(_);
      return {
        Q: x.Q.valueOf(),
        R: x.R.valueOf()
      };
    }
  }), {
    _denseQRimpl: v
  });
  function v(b) {
    var S = b._size[0], _ = b._size[1], x = i([S], "dense"), C = x._data, A = b.clone(), w = A._data, I, P, M, T = n([S], "");
    for (M = 0; M < Math.min(_, S); ++M) {
      var F = w[M][M], N = l(o(F, 0) ? 1 : s(F)), R = c(N), L = 0;
      for (I = M; I < S; I++)
        L = d(L, h(w[I][M], c(w[I][M])));
      var V = h(N, u(L));
      if (!a(V)) {
        var U = m(F, V);
        for (T[M] = 1, I = M + 1; I < S; I++)
          T[I] = f(w[I][M], U);
        var H = l(c(f(U, V))), K = void 0;
        for (P = M; P < _; P++) {
          for (K = 0, I = M; I < S; I++)
            K = d(K, h(c(T[I]), w[I][P]));
          for (K = h(K, H), I = M; I < S; I++)
            w[I][P] = h(m(w[I][P], h(T[I], K)), R);
        }
        for (I = 0; I < S; I++) {
          for (K = 0, P = M; P < S; P++)
            K = d(K, h(C[I][P], T[P]));
          for (K = h(K, H), P = M; P < S; ++P)
            C[I][P] = f(m(C[I][P], h(K, c(T[P]))), R);
        }
      }
    }
    return {
      Q: x,
      R: A,
      toString: function() {
        return "Q: " + this.Q.toString() + `
R: ` + this.R.toString();
      }
    };
  }
  function g(b) {
    var S = v(b), _ = S.R._data;
    if (b._data.length > 0)
      for (var x = _[0][0].type === "Complex" ? p(0) : 0, C = 0; C < _.length; ++C)
        for (var A = 0; A < C && A < (_[0] || []).length; ++A)
          _[C][A] = x;
    return S;
  }
  function y(b) {
    throw new Error("qr not implemented for sparse matrices yet");
  }
}), NB = "det", D2e = ["typed", "matrix", "subtractScalar", "multiply", "divideScalar", "isZero", "unaryMinus"], E2e = /* @__PURE__ */ vt(NB, D2e, (t) => {
  var {
    typed: e,
    matrix: r,
    subtractScalar: n,
    multiply: i,
    divideScalar: a,
    isZero: o,
    unaryMinus: s
  } = t;
  return e(NB, {
    any: function(l) {
      return an(l);
    },
    "Array | Matrix": function(l) {
      var d;
      switch (Xn(l) ? d = l.size() : Array.isArray(l) ? (l = r(l), d = l.size()) : d = [], d.length) {
        case 0:
          return an(l);
        case 1:
          if (d[0] === 1)
            return an(l.valueOf()[0]);
          if (d[0] === 0)
            return 1;
          throw new RangeError("Matrix must be square (size: " + Zn(d) + ")");
        case 2: {
          var f = d[0], h = d[1];
          if (f === h)
            return u(l.clone().valueOf(), f);
          if (h === 0)
            return 1;
          throw new RangeError("Matrix must be square (size: " + Zn(d) + ")");
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + Zn(d) + ")");
      }
    }
  });
  function u(c, l, d) {
    if (l === 1)
      return an(c[0][0]);
    if (l === 2)
      return n(i(c[0][0], c[1][1]), i(c[1][0], c[0][1]));
    for (var f = !1, h = new Array(l).fill(0).map((C, A) => A), m = 0; m < l; m++) {
      var p = h[m];
      if (o(c[p][m])) {
        var v = void 0;
        for (v = m + 1; v < l; v++)
          if (!o(c[h[v]][m])) {
            p = h[v], h[v] = h[m], h[m] = p, f = !f;
            break;
          }
        if (v === l) return c[p][m];
      }
      for (var g = c[p][m], y = m === 0 ? 1 : c[h[m - 1]][m - 1], b = m + 1; b < l; b++)
        for (var S = h[b], _ = m + 1; _ < l; _++)
          c[S][_] = a(n(i(c[S][_], g), i(c[S][m], c[p][_])), y);
    }
    var x = c[h[l - 1]][l - 1];
    return f ? s(x) : x;
  }
}), RB = "inv", I2e = ["typed", "matrix", "divideScalar", "addScalar", "multiply", "unaryMinus", "det", "identity", "abs"], T2e = /* @__PURE__ */ vt(RB, I2e, (t) => {
  var {
    typed: e,
    matrix: r,
    divideScalar: n,
    addScalar: i,
    multiply: a,
    unaryMinus: o,
    det: s,
    identity: u,
    abs: c
  } = t;
  return e(RB, {
    "Array | Matrix": function(f) {
      var h = Xn(f) ? f.size() : Kn(f);
      switch (h.length) {
        case 1:
          if (h[0] === 1)
            return Xn(f) ? r([n(1, f.valueOf()[0])]) : [n(1, f[0])];
          throw new RangeError("Matrix must be square (size: " + Zn(h) + ")");
        case 2: {
          var m = h[0], p = h[1];
          if (m === p)
            return Xn(f) ? r(l(f.valueOf(), m, p), f.storage()) : l(f, m, p);
          throw new RangeError("Matrix must be square (size: " + Zn(h) + ")");
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + Zn(h) + ")");
      }
    },
    any: function(f) {
      return n(1, f);
    }
  });
  function l(d, f, h) {
    var m, p, v, g, y;
    if (f === 1) {
      if (g = d[0][0], g === 0)
        throw Error("Cannot calculate inverse, determinant is zero");
      return [[n(1, g)]];
    } else if (f === 2) {
      var b = s(d);
      if (b === 0)
        throw Error("Cannot calculate inverse, determinant is zero");
      return [[n(d[1][1], b), n(o(d[0][1]), b)], [n(o(d[1][0]), b), n(d[0][0], b)]];
    } else {
      var S = d.concat();
      for (m = 0; m < f; m++)
        S[m] = S[m].concat();
      for (var _ = u(f).valueOf(), x = 0; x < h; x++) {
        var C = c(S[x][x]), A = x;
        for (m = x + 1; m < f; )
          c(S[m][x]) > C && (C = c(S[m][x]), A = m), m++;
        if (C === 0)
          throw Error("Cannot calculate inverse, determinant is zero");
        m = A, m !== x && (y = S[x], S[x] = S[m], S[m] = y, y = _[x], _[x] = _[m], _[m] = y);
        var w = S[x], I = _[x];
        for (m = 0; m < f; m++) {
          var P = S[m], M = _[m];
          if (m !== x) {
            if (P[x] !== 0) {
              for (v = n(o(P[x]), w[x]), p = x; p < h; p++)
                P[p] = i(P[p], a(v, w[p]));
              for (p = 0; p < h; p++)
                M[p] = i(M[p], a(v, I[p]));
            }
          } else {
            for (v = w[x], p = x; p < h; p++)
              P[p] = n(P[p], v);
            for (p = 0; p < h; p++)
              M[p] = n(M[p], v);
          }
        }
      }
      return _;
    }
  }
});
function M2e(t) {
  var {
    addScalar: e,
    subtract: r,
    flatten: n,
    multiply: i,
    multiplyScalar: a,
    divideScalar: o,
    sqrt: s,
    abs: u,
    bignumber: c,
    diag: l,
    size: d,
    reshape: f,
    inv: h,
    qr: m,
    usolve: p,
    usolveAll: v,
    equal: g,
    complex: y,
    larger: b,
    smaller: S,
    matrixFromColumns: _,
    dot: x
  } = t;
  function C(X, Y, Q, J) {
    var te = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, W = A(X, Y, Q, J, te);
    w(X, Y, Q, J, te, W);
    var {
      values: j,
      C: ee
    } = I(X, Y, Q, J, te);
    if (te) {
      var ie = P(X, Y, ee, W, j, Q, J);
      return {
        values: j,
        eigenvectors: ie
      };
    }
    return {
      values: j
    };
  }
  function A(X, Y, Q, J, te) {
    var W = J === "BigNumber", j = J === "Complex", ee = W ? c(0) : 0, ie = W ? c(1) : j ? y(1) : 1, ae = W ? c(1) : 1, ce = W ? c(10) : 2, de = a(ce, ce), Ce;
    te && (Ce = Array(Y).fill(ie));
    for (var De = !1; !De; ) {
      De = !0;
      for (var ke = 0; ke < Y; ke++) {
        for (var He = ee, We = ee, Ne = 0; Ne < Y; Ne++)
          ke !== Ne && (He = e(He, u(X[Ne][ke])), We = e(We, u(X[ke][Ne])));
        if (!g(He, 0) && !g(We, 0)) {
          for (var Je = ae, Re = He, nt = o(We, ce), ne = a(We, ce); S(Re, nt); )
            Re = a(Re, de), Je = a(Je, ce);
          for (; b(Re, ne); )
            Re = o(Re, de), Je = o(Je, ce);
          var re = S(o(e(Re, We), Je), a(e(He, We), 0.95));
          if (re) {
            De = !1;
            for (var le = o(1, Je), fe = 0; fe < Y; fe++)
              ke !== fe && (X[ke][fe] = a(X[ke][fe], le), X[fe][ke] = a(X[fe][ke], Je));
            te && (Ce[ke] = a(Ce[ke], le));
          }
        }
      }
    }
    return te ? l(Ce) : null;
  }
  function w(X, Y, Q, J, te, W) {
    var j = J === "BigNumber", ee = J === "Complex", ie = j ? c(0) : ee ? y(0) : 0;
    j && (Q = c(Q));
    for (var ae = 0; ae < Y - 2; ae++) {
      for (var ce = 0, de = ie, Ce = ae + 1; Ce < Y; Ce++) {
        var De = X[Ce][ae];
        S(u(de), u(De)) && (de = De, ce = Ce);
      }
      if (!S(u(de), Q)) {
        if (ce !== ae + 1) {
          var ke = X[ce];
          X[ce] = X[ae + 1], X[ae + 1] = ke;
          for (var He = 0; He < Y; He++) {
            var We = X[He][ce];
            X[He][ce] = X[He][ae + 1], X[He][ae + 1] = We;
          }
          if (te) {
            var Ne = W[ce];
            W[ce] = W[ae + 1], W[ae + 1] = Ne;
          }
        }
        for (var Je = ae + 2; Je < Y; Je++) {
          var Re = o(X[Je][ae], de);
          if (Re !== 0) {
            for (var nt = 0; nt < Y; nt++)
              X[Je][nt] = r(X[Je][nt], a(Re, X[ae + 1][nt]));
            for (var ne = 0; ne < Y; ne++)
              X[ne][ae + 1] = e(X[ne][ae + 1], a(Re, X[ne][Je]));
            if (te)
              for (var re = 0; re < Y; re++)
                W[Je][re] = r(W[Je][re], a(Re, W[ae + 1][re]));
          }
        }
      }
    }
    return W;
  }
  function I(X, Y, Q, J, te) {
    var W = J === "BigNumber", j = J === "Complex", ee = W ? c(1) : j ? y(1) : 1;
    W && (Q = c(Q));
    for (var ie = an(X), ae = [], ce = Y, de = [], Ce = te ? l(Array(Y).fill(ee)) : void 0, De = te ? l(Array(ce).fill(ee)) : void 0, ke = 0; ke <= 100; ) {
      ke += 1;
      for (var He = ie[ce - 1][ce - 1], We = 0; We < ce; We++)
        ie[We][We] = r(ie[We][We], He);
      var {
        Q: Ne,
        R: Je
      } = m(ie);
      ie = i(Je, Ne);
      for (var Re = 0; Re < ce; Re++)
        ie[Re][Re] = e(ie[Re][Re], He);
      if (te && (De = i(De, Ne)), ce === 1 || S(u(ie[ce - 1][ce - 2]), Q)) {
        ke = 0, ae.push(ie[ce - 1][ce - 1]), te && (de.unshift([[1]]), F(De, Y), Ce = i(Ce, De), ce > 1 && (De = l(Array(ce - 1).fill(ee)))), ce -= 1, ie.pop();
        for (var nt = 0; nt < ce; nt++)
          ie[nt].pop();
      } else if (ce === 2 || S(u(ie[ce - 2][ce - 3]), Q)) {
        ke = 0;
        var ne = M(ie[ce - 2][ce - 2], ie[ce - 2][ce - 1], ie[ce - 1][ce - 2], ie[ce - 1][ce - 1]);
        ae.push(...ne), te && (de.unshift(T(ie[ce - 2][ce - 2], ie[ce - 2][ce - 1], ie[ce - 1][ce - 2], ie[ce - 1][ce - 1], ne[0], ne[1], Q, J)), F(De, Y), Ce = i(Ce, De), ce > 2 && (De = l(Array(ce - 2).fill(ee)))), ce -= 2, ie.pop(), ie.pop();
        for (var re = 0; re < ce; re++)
          ie[re].pop(), ie[re].pop();
      }
      if (ce === 0)
        break;
    }
    if (ae.sort((ge, me) => +r(u(ge), u(me))), ke > 100) {
      var le = Error("The eigenvalues failed to converge. Only found these eigenvalues: " + ae.join(", "));
      throw le.values = ae, le.vectors = [], le;
    }
    var fe = te ? i(Ce, N(de, Y)) : void 0;
    return {
      values: ae,
      C: fe
    };
  }
  function P(X, Y, Q, J, te, W, j) {
    var ee = h(Q), ie = i(ee, X, Q), ae = j === "BigNumber", ce = j === "Complex", de = ae ? c(0) : ce ? y(0) : 0, Ce = ae ? c(1) : ce ? y(1) : 1, De = [], ke = [];
    for (var He of te) {
      var We = R(De, He, g);
      We === -1 ? (De.push(He), ke.push(1)) : ke[We] += 1;
    }
    for (var Ne = [], Je = De.length, Re = Array(Y).fill(de), nt = l(Array(Y).fill(Ce)), ne = function() {
      var fe = De[re], ge = r(ie, i(fe, nt)), me = v(ge, Re);
      for (me.shift(); me.length < ke[re]; ) {
        var Ae = L(ge, Y, me, W, j);
        if (Ae === null)
          break;
        me.push(Ae);
      }
      var Oe = i(h(J), Q);
      me = me.map((Ue) => i(Oe, Ue)), Ne.push(...me.map((Ue) => ({
        value: fe,
        vector: n(Ue)
      })));
    }, re = 0; re < Je; re++)
      ne();
    return Ne;
  }
  function M(X, Y, Q, J) {
    var te = e(X, J), W = r(a(X, J), a(Y, Q)), j = a(te, 0.5), ee = a(s(r(a(te, te), a(4, W))), 0.5);
    return [e(j, ee), r(j, ee)];
  }
  function T(X, Y, Q, J, te, W, j, ee) {
    var ie = ee === "BigNumber", ae = ee === "Complex", ce = ie ? c(0) : ae ? y(0) : 0, de = ie ? c(1) : ae ? y(1) : 1;
    if (S(u(Q), j))
      return [[de, ce], [ce, de]];
    if (b(u(r(te, W)), j))
      return [[r(te, J), r(W, J)], [Q, Q]];
    var Ce = r(X, te), De = r(J, te);
    return S(u(Y), j) && S(u(De), j) ? [[Ce, de], [Q, ce]] : [[Y, ce], [De, de]];
  }
  function F(X, Y) {
    for (var Q = 0; Q < X.length; Q++)
      X[Q].push(...Array(Y - X[Q].length).fill(0));
    for (var J = X.length; J < Y; J++)
      X.push(Array(Y).fill(0)), X[J][J] = 1;
    return X;
  }
  function N(X, Y) {
    for (var Q = [], J = 0; J < Y; J++)
      Q[J] = Array(Y).fill(0);
    var te = 0;
    for (var W of X) {
      for (var j = W.length, ee = 0; ee < j; ee++)
        for (var ie = 0; ie < j; ie++)
          Q[te + ee][te + ie] = W[ee][ie];
      te += j;
    }
    return Q;
  }
  function R(X, Y, Q) {
    for (var J = 0; J < X.length; J++)
      if (Q(X[J], Y))
        return J;
    return -1;
  }
  function L(X, Y, Q, J, te) {
    for (var W = te === "BigNumber" ? c(1e3) : 1e3, j, ee = 0; ee < 5; ++ee) {
      j = V(Y, Q, te);
      try {
        j = p(X, j);
      } catch {
        continue;
      }
      if (b(H(j), W))
        break;
    }
    if (ee >= 5)
      return null;
    for (ee = 0; ; ) {
      var ie = p(X, j);
      if (S(H(U(j, [ie])), J))
        break;
      if (++ee >= 10)
        return null;
      j = K(ie);
    }
    return j;
  }
  function V(X, Y, Q) {
    var J = Q === "BigNumber", te = Q === "Complex", W = Array(X).fill(0).map((j) => 2 * Math.random() - 1);
    return J && (W = W.map((j) => c(j))), te && (W = W.map((j) => y(j))), W = U(W, Y), K(W, Q);
  }
  function U(X, Y) {
    var Q = d(X);
    for (var J of Y)
      J = f(J, Q), X = r(X, i(o(x(J, X), x(J, J)), J));
    return X;
  }
  function H(X) {
    return u(s(x(X, X)));
  }
  function K(X, Y) {
    var Q = Y === "BigNumber", J = Y === "Complex", te = Q ? c(1) : J ? y(1) : 1;
    return i(o(te, H(X)), X);
  }
  return C;
}
function P2e(t) {
  var {
    config: e,
    addScalar: r,
    subtract: n,
    abs: i,
    atan: a,
    cos: o,
    sin: s,
    multiplyScalar: u,
    inv: c,
    bignumber: l,
    multiply: d,
    add: f
  } = t;
  function h(w, I) {
    var P = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : e.relTol, M = arguments.length > 3 ? arguments[3] : void 0, T = arguments.length > 4 ? arguments[4] : void 0;
    if (M === "number")
      return m(w, P, T);
    if (M === "BigNumber")
      return p(w, P, T);
    throw TypeError("Unsupported data type: " + M);
  }
  function m(w, I, P) {
    var M = w.length, T = Math.abs(I / M), F, N;
    if (P) {
      N = new Array(M);
      for (var R = 0; R < M; R++)
        N[R] = Array(M).fill(0), N[R][R] = 1;
    }
    for (var L = x(w); Math.abs(L[1]) >= Math.abs(T); ) {
      var V = L[0][0], U = L[0][1];
      F = v(w[V][V], w[U][U], w[V][U]), w = _(w, F, V, U), P && (N = y(N, F, V, U)), L = x(w);
    }
    for (var H = Array(M).fill(0), K = 0; K < M; K++)
      H[K] = w[K][K];
    return A(an(H), N, P);
  }
  function p(w, I, P) {
    var M = w.length, T = i(I / M), F, N;
    if (P) {
      N = new Array(M);
      for (var R = 0; R < M; R++)
        N[R] = Array(M).fill(0), N[R][R] = 1;
    }
    for (var L = C(w); i(L[1]) >= i(T); ) {
      var V = L[0][0], U = L[0][1];
      F = g(w[V][V], w[U][U], w[V][U]), w = S(w, F, V, U), P && (N = b(N, F, V, U)), L = C(w);
    }
    for (var H = Array(M).fill(0), K = 0; K < M; K++)
      H[K] = w[K][K];
    return A(an(H), N, P);
  }
  function v(w, I, P) {
    var M = I - w;
    return Math.abs(M) <= e.relTol ? Math.PI / 4 : 0.5 * Math.atan(2 * P / (I - w));
  }
  function g(w, I, P) {
    var M = n(I, w);
    return i(M) <= e.relTol ? l(-1).acos().div(4) : u(0.5, a(d(2, P, c(M))));
  }
  function y(w, I, P, M) {
    for (var T = w.length, F = Math.cos(I), N = Math.sin(I), R = Array(T).fill(0), L = Array(T).fill(0), V = 0; V < T; V++)
      R[V] = F * w[V][P] - N * w[V][M], L[V] = N * w[V][P] + F * w[V][M];
    for (var U = 0; U < T; U++)
      w[U][P] = R[U], w[U][M] = L[U];
    return w;
  }
  function b(w, I, P, M) {
    for (var T = w.length, F = o(I), N = s(I), R = Array(T).fill(l(0)), L = Array(T).fill(l(0)), V = 0; V < T; V++)
      R[V] = n(u(F, w[V][P]), u(N, w[V][M])), L[V] = r(u(N, w[V][P]), u(F, w[V][M]));
    for (var U = 0; U < T; U++)
      w[U][P] = R[U], w[U][M] = L[U];
    return w;
  }
  function S(w, I, P, M) {
    for (var T = w.length, F = l(o(I)), N = l(s(I)), R = u(F, F), L = u(N, N), V = Array(T).fill(l(0)), U = Array(T).fill(l(0)), H = d(l(2), F, N, w[P][M]), K = r(n(u(R, w[P][P]), H), u(L, w[M][M])), X = f(u(L, w[P][P]), H, u(R, w[M][M])), Y = 0; Y < T; Y++)
      V[Y] = n(u(F, w[P][Y]), u(N, w[M][Y])), U[Y] = r(u(N, w[P][Y]), u(F, w[M][Y]));
    w[P][P] = K, w[M][M] = X, w[P][M] = l(0), w[M][P] = l(0);
    for (var Q = 0; Q < T; Q++)
      Q !== P && Q !== M && (w[P][Q] = V[Q], w[Q][P] = V[Q], w[M][Q] = U[Q], w[Q][M] = U[Q]);
    return w;
  }
  function _(w, I, P, M) {
    for (var T = w.length, F = Math.cos(I), N = Math.sin(I), R = F * F, L = N * N, V = Array(T).fill(0), U = Array(T).fill(0), H = R * w[P][P] - 2 * F * N * w[P][M] + L * w[M][M], K = L * w[P][P] + 2 * F * N * w[P][M] + R * w[M][M], X = 0; X < T; X++)
      V[X] = F * w[P][X] - N * w[M][X], U[X] = N * w[P][X] + F * w[M][X];
    w[P][P] = H, w[M][M] = K, w[P][M] = 0, w[M][P] = 0;
    for (var Y = 0; Y < T; Y++)
      Y !== P && Y !== M && (w[P][Y] = V[Y], w[Y][P] = V[Y], w[M][Y] = U[Y], w[Y][M] = U[Y]);
    return w;
  }
  function x(w) {
    for (var I = w.length, P = 0, M = [0, 1], T = 0; T < I; T++)
      for (var F = T + 1; F < I; F++)
        Math.abs(P) < Math.abs(w[T][F]) && (P = Math.abs(w[T][F]), M = [T, F]);
    return [M, P];
  }
  function C(w) {
    for (var I = w.length, P = 0, M = [0, 1], T = 0; T < I; T++)
      for (var F = T + 1; F < I; F++)
        i(P) < i(w[T][F]) && (P = i(w[T][F]), M = [T, F]);
    return [M, P];
  }
  function A(w, I, P) {
    var M = w.length, T = Array(M), F;
    if (P) {
      F = Array(M);
      for (var N = 0; N < M; N++)
        F[N] = Array(M);
    }
    for (var R = 0; R < M; R++) {
      for (var L = 0, V = w[0], U = 0; U < w.length; U++)
        i(w[U]) < i(V) && (L = U, V = w[L]);
      if (T[R] = w.splice(L, 1)[0], P)
        for (var H = 0; H < M; H++)
          F[R][H] = I[H][L], I[H].splice(L, 1);
    }
    if (!P) return {
      values: T
    };
    var K = F.map((X, Y) => ({
      value: T[Y],
      vector: X
    }));
    return {
      values: T,
      eigenvectors: K
    };
  }
  return h;
}
var B2e = "eigs", F2e = ["config", "typed", "matrix", "addScalar", "equal", "subtract", "abs", "atan", "cos", "sin", "multiplyScalar", "divideScalar", "inv", "bignumber", "multiply", "add", "larger", "column", "flatten", "number", "complex", "sqrt", "diag", "size", "reshape", "qr", "usolve", "usolveAll", "im", "re", "smaller", "matrixFromColumns", "dot"], N2e = /* @__PURE__ */ vt(B2e, F2e, (t) => {
  var {
    config: e,
    typed: r,
    matrix: n,
    addScalar: i,
    subtract: a,
    equal: o,
    abs: s,
    atan: u,
    cos: c,
    sin: l,
    multiplyScalar: d,
    divideScalar: f,
    inv: h,
    bignumber: m,
    multiply: p,
    add: v,
    larger: g,
    column: y,
    flatten: b,
    number: S,
    complex: _,
    sqrt: x,
    diag: C,
    size: A,
    reshape: w,
    qr: I,
    usolve: P,
    usolveAll: M,
    im: T,
    re: F,
    smaller: N,
    matrixFromColumns: R,
    dot: L
  } = t, V = P2e({
    config: e,
    addScalar: i,
    subtract: a,
    column: y,
    flatten: b,
    equal: o,
    abs: s,
    atan: u,
    cos: c,
    sin: l,
    multiplyScalar: d,
    inv: h,
    bignumber: m,
    complex: _,
    multiply: p,
    add: v
  }), U = M2e({
    config: e,
    addScalar: i,
    subtract: a,
    multiply: p,
    multiplyScalar: d,
    flatten: b,
    divideScalar: f,
    sqrt: x,
    abs: s,
    bignumber: m,
    diag: C,
    size: A,
    reshape: w,
    qr: I,
    inv: h,
    usolve: P,
    usolveAll: M,
    equal: o,
    complex: _,
    larger: g,
    smaller: N,
    matrixFromColumns: R,
    dot: L
  });
  return r("eigs", {
    // The conversion to matrix in the first two implementations,
    // just to convert back to an array right away in
    // computeValuesAndVectors, is unfortunate, and should perhaps be
    // streamlined. It is done because the Matrix object carries some
    // type information about its entries, and so constructing the matrix
    // is a roundabout way of doing type detection.
    Array: function(W) {
      return H(n(W));
    },
    "Array, number|BigNumber": function(W, j) {
      return H(n(W), {
        precision: j
      });
    },
    "Array, Object"(te, W) {
      return H(n(te), W);
    },
    Matrix: function(W) {
      return H(W, {
        matricize: !0
      });
    },
    "Matrix, number|BigNumber": function(W, j) {
      return H(W, {
        precision: j,
        matricize: !0
      });
    },
    "Matrix, Object": function(W, j) {
      var ee = {
        matricize: !0
      };
      return Up(ee, j), H(W, ee);
    }
  });
  function H(te) {
    var W, j = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, ee = "eigenvectors" in j ? j.eigenvectors : !0, ie = (W = j.precision) !== null && W !== void 0 ? W : e.relTol, ae = K(te, ie, ee);
    return j.matricize && (ae.values = n(ae.values), ee && (ae.eigenvectors = ae.eigenvectors.map((ce) => {
      var {
        value: de,
        vector: Ce
      } = ce;
      return {
        value: de,
        vector: n(Ce)
      };
    }))), ee && Object.defineProperty(ae, "vectors", {
      enumerable: !1,
      // to make sure that the eigenvectors can still be
      // converted to string.
      get: () => {
        throw new Error("eigs(M).vectors replaced with eigs(M).eigenvectors");
      }
    }), ae;
  }
  function K(te, W, j) {
    var ee = te.toArray(), ie = te.size();
    if (ie.length !== 2 || ie[0] !== ie[1])
      throw new RangeError("Matrix must be square (size: ".concat(Zn(ie), ")"));
    var ae = ie[0];
    if (Y(ee, ae, W) && (Q(ee, ae), X(ee, ae, W))) {
      var ce = J(te, ee, ae);
      return V(ee, ae, W, ce, j);
    }
    var de = J(te, ee, ae);
    return U(ee, ae, W, de, j);
  }
  function X(te, W, j) {
    for (var ee = 0; ee < W; ee++)
      for (var ie = ee; ie < W; ie++)
        if (g(m(s(a(te[ee][ie], te[ie][ee]))), j))
          return !1;
    return !0;
  }
  function Y(te, W, j) {
    for (var ee = 0; ee < W; ee++)
      for (var ie = 0; ie < W; ie++)
        if (g(m(s(T(te[ee][ie]))), j))
          return !1;
    return !0;
  }
  function Q(te, W) {
    for (var j = 0; j < W; j++)
      for (var ee = 0; ee < W; ee++)
        te[j][ee] = F(te[j][ee]);
  }
  function J(te, W, j) {
    var ee = te.datatype();
    if (ee === "number" || ee === "BigNumber" || ee === "Complex")
      return ee;
    for (var ie = !1, ae = !1, ce = !1, de = 0; de < j; de++)
      for (var Ce = 0; Ce < j; Ce++) {
        var De = W[de][Ce];
        if (Gn(De) || Jx(De))
          ie = !0;
        else if (mi(De))
          ae = !0;
        else if (Qx(De))
          ce = !0;
        else
          throw TypeError("Unsupported type in Matrix: " + xl(De));
      }
    if (ae && ce && console.warn("Complex BigNumbers not supported, this operation will lose precission."), ce) {
      for (var ke = 0; ke < j; ke++)
        for (var He = 0; He < j; He++)
          W[ke][He] = _(W[ke][He]);
      return "Complex";
    }
    if (ae) {
      for (var We = 0; We < j; We++)
        for (var Ne = 0; Ne < j; Ne++)
          W[We][Ne] = m(W[We][Ne]);
      return "BigNumber";
    }
    if (ie) {
      for (var Je = 0; Je < j; Je++)
        for (var Re = 0; Re < j; Re++)
          W[Je][Re] = S(W[Je][Re]);
      return "number";
    } else
      throw TypeError("Matrix contains unsupported types only.");
  }
}), R2e = "divide", O2e = ["typed", "matrix", "multiply", "equalScalar", "divideScalar", "inv"], L2e = /* @__PURE__ */ vt(R2e, O2e, (t) => {
  var {
    typed: e,
    matrix: r,
    multiply: n,
    equalScalar: i,
    divideScalar: a,
    inv: o
  } = t, s = D2({
    typed: e,
    equalScalar: i
  }), u = E2({
    typed: e
  });
  return e("divide", MG({
    // we extend the signatures of divideScalar with signatures dealing with matrices
    "Array | Matrix, Array | Matrix": function(l, d) {
      return n(l, o(d));
    },
    "DenseMatrix, any": function(l, d) {
      return u(l, d, a, !1);
    },
    "SparseMatrix, any": function(l, d) {
      return s(l, d, a, !1);
    },
    "Array, any": function(l, d) {
      return u(r(l), d, a, !1).valueOf();
    },
    "any, Array | Matrix": function(l, d) {
      return n(l, o(d));
    }
  }, a.signatures));
}), k2e = /* @__PURE__ */ G2e("pi", ["config", "?BigNumber"], (t) => {
  var {
    config: e,
    BigNumber: r
  } = t;
  return e.number === "BigNumber" ? _z(r) : xpe;
});
function G2e(t, e, r) {
  return vt(t, e, r, {
    recreateOnConfigChange: !0
  });
}
var H0 = /* @__PURE__ */ q1e({
  config: da
}), T2 = /* @__PURE__ */ j1e({}), oS = /* @__PURE__ */ npe({}), sS = /* @__PURE__ */ ope({}), ao = /* @__PURE__ */ ype({
  Matrix: sS
}), op = /* @__PURE__ */ k2e({
  BigNumber: H0,
  config: da
}), Lt = /* @__PURE__ */ Y0e({
  BigNumber: H0,
  Complex: T2,
  DenseMatrix: ao,
  Fraction: oS
}), d0 = /* @__PURE__ */ ehe({
  typed: Lt
}), z2e = /* @__PURE__ */ l2e({
  Complex: T2,
  config: da,
  typed: Lt
}), nh = /* @__PURE__ */ rhe({
  typed: Lt
}), V2e = /* @__PURE__ */ p2e({
  typed: Lt
}), uS = /* @__PURE__ */ Hpe({
  Complex: T2,
  typed: Lt
}), m4 = /* @__PURE__ */ Qhe({
  typed: Lt
}), f3 = /* @__PURE__ */ m2e({
  typed: Lt
}), lu = /* @__PURE__ */ Tpe({
  config: da,
  typed: Lt
}), U2e = /* @__PURE__ */ pme({
  typed: Lt
}), H2e = /* @__PURE__ */ $he({
  typed: Lt
}), Sz = /* @__PURE__ */ _pe({
  typed: Lt
}), q2e = /* @__PURE__ */ Ape({
  config: da,
  typed: Lt
}), Cz = /* @__PURE__ */ Dpe({
  equalScalar: lu,
  typed: Lt
}), ih = /* @__PURE__ */ khe({
  typed: Lt
}), cS = /* @__PURE__ */ Lpe({
  typed: Lt
}), K2e = /* @__PURE__ */ tme({
  typed: Lt
}), X2e = /* @__PURE__ */ Uhe({
  BigNumber: H0,
  Fraction: oS,
  complex: uS,
  typed: Lt
}), Az = /* @__PURE__ */ v2e({
  typed: Lt
}), g4 = /* @__PURE__ */ Bpe({
  Matrix: sS,
  equalScalar: lu,
  typed: Lt
}), M2 = /* @__PURE__ */ ihe({
  typed: Lt
}), lS = /* @__PURE__ */ zpe({
  BigNumber: H0,
  typed: Lt
}), v4 = /* @__PURE__ */ Khe({
  Complex: T2,
  config: da,
  typed: Lt
}), y4 = /* @__PURE__ */ Jpe({
  typed: Lt
}), wz = /* @__PURE__ */ Xpe({
  Fraction: oS,
  typed: Lt
}), en = /* @__PURE__ */ Wpe({
  DenseMatrix: ao,
  Matrix: sS,
  SparseMatrix: g4,
  typed: Lt
}), Y2e = /* @__PURE__ */ Pme({
  bignumber: lS,
  fraction: wz,
  number: cS
}), W2e = /* @__PURE__ */ _me({
  isInteger: Sz,
  matrix: en,
  typed: Lt
}), dS = /* @__PURE__ */ Sme({
  matrix: en,
  config: da,
  typed: Lt
}), Dz = /* @__PURE__ */ Ame({
  matrix: en,
  typed: Lt
}), fS = /* @__PURE__ */ Ime({
  BigNumber: H0,
  config: da,
  matrix: en,
  typed: Lt
}), yf = /* @__PURE__ */ nme({
  isInteger: Sz,
  matrix: en,
  typed: Lt
}), j2e = /* @__PURE__ */ Dme({
  conj: m4,
  transpose: Dz,
  typed: Lt
}), Z2e = /* @__PURE__ */ cme({
  DenseMatrix: ao,
  SparseMatrix: g4,
  matrix: en,
  typed: Lt
}), q0 = /* @__PURE__ */ Fme({
  numeric: Y2e,
  typed: Lt
}), Ez = /* @__PURE__ */ Hme({
  DenseMatrix: ao,
  concat: yf,
  equalScalar: lu,
  matrix: en,
  typed: Lt
}), Iz = /* @__PURE__ */ dme({
  matrix: en,
  typed: Lt
}), P2 = /* @__PURE__ */ mme({
  BigNumber: H0,
  DenseMatrix: ao,
  SparseMatrix: g4,
  config: da,
  matrix: en,
  typed: Lt
}), Q2e = /* @__PURE__ */ t2e({
  DenseMatrix: ao,
  concat: yf,
  config: da,
  matrix: en,
  typed: Lt
}), J2e = /* @__PURE__ */ Zpe({
  flatten: Iz,
  matrix: en,
  size: dS,
  typed: Lt
}), $2e = /* @__PURE__ */ w2e({
  addScalar: nh,
  complex: uS,
  conj: m4,
  divideScalar: q0,
  equal: Ez,
  identity: P2,
  isZero: Cz,
  matrix: en,
  multiplyScalar: ih,
  sign: X2e,
  sqrt: v4,
  subtractScalar: M2,
  typed: Lt,
  unaryMinus: y4,
  zeros: fS
}), ege = /* @__PURE__ */ Lme({
  BigNumber: H0,
  DenseMatrix: ao,
  config: da,
  equalScalar: lu,
  matrix: en,
  typed: Lt,
  zeros: fS
}), b4 = /* @__PURE__ */ Xme({
  DenseMatrix: ao,
  concat: yf,
  config: da,
  matrix: en,
  typed: Lt
}), Tz = /* @__PURE__ */ Yhe({
  DenseMatrix: ao,
  concat: yf,
  equalScalar: lu,
  matrix: en,
  subtractScalar: M2,
  typed: Lt,
  unaryMinus: y4
}), tge = /* @__PURE__ */ Gme({
  DenseMatrix: ao,
  divideScalar: q0,
  equalScalar: lu,
  matrix: en,
  multiplyScalar: ih,
  subtractScalar: M2,
  typed: Lt
}), fl = /* @__PURE__ */ b2e({
  DenseMatrix: ao,
  SparseMatrix: g4,
  addScalar: nh,
  concat: yf,
  equalScalar: lu,
  matrix: en,
  typed: Lt
}), _4 = /* @__PURE__ */ C2e({
  addScalar: nh,
  conj: m4,
  multiplyScalar: ih,
  size: dS,
  typed: Lt
}), rge = /* @__PURE__ */ a2e({
  DenseMatrix: ao,
  smaller: b4
}), nge = /* @__PURE__ */ u2e({
  ImmutableDenseMatrix: rge,
  getMatrixDataType: U2e
}), pS = /* @__PURE__ */ Jme({
  DenseMatrix: ao,
  concat: yf,
  config: da,
  matrix: en,
  typed: Lt
}), ige = /* @__PURE__ */ Ihe({
  DenseMatrix: ao,
  concat: yf,
  config: da,
  equalScalar: lu,
  matrix: en,
  round: ege,
  typed: Lt,
  zeros: fS
}), ys = /* @__PURE__ */ zhe({
  addScalar: nh,
  dot: _4,
  equalScalar: lu,
  matrix: en,
  multiplyScalar: ih,
  typed: Lt
}), age = /* @__PURE__ */ Vme({
  DenseMatrix: ao,
  divideScalar: q0,
  equalScalar: lu,
  matrix: en,
  multiplyScalar: ih,
  subtractScalar: M2,
  typed: Lt
}), OB = /* @__PURE__ */ sme({
  matrix: en,
  multiply: ys,
  subtract: Tz,
  typed: Lt
}), Mz = /* @__PURE__ */ E2e({
  divideScalar: q0,
  isZero: Cz,
  matrix: en,
  multiply: ys,
  subtractScalar: M2,
  typed: Lt,
  unaryMinus: y4
}), oge = /* @__PURE__ */ jme({
  DenseMatrix: ao,
  concat: yf,
  config: da,
  matrix: en,
  typed: Lt
}), sge = /* @__PURE__ */ yme({
  bignumber: lS,
  matrix: en,
  add: fl,
  config: da,
  isPositive: q2e,
  larger: pS,
  largerEq: Q2e,
  smaller: b4,
  smallerEq: oge,
  typed: Lt
}), uge = /* @__PURE__ */ ame({
  Index: nge,
  matrix: en,
  range: sge,
  typed: Lt
}), x4 = /* @__PURE__ */ T2e({
  abs: d0,
  addScalar: nh,
  det: Mz,
  divideScalar: q0,
  identity: P2,
  matrix: en,
  multiply: ys,
  typed: Lt,
  unaryMinus: y4
}), cge = /* @__PURE__ */ Rme({
  Complex: T2,
  config: da,
  fraction: wz,
  identity: P2,
  inv: x4,
  matrix: en,
  multiply: ys,
  number: cS,
  typed: Lt
}), lge = /* @__PURE__ */ L2e({
  divideScalar: q0,
  equalScalar: lu,
  inv: x4,
  matrix: en,
  multiply: ys,
  typed: Lt
}), dge = /* @__PURE__ */ N2e({
  abs: d0,
  add: fl,
  addScalar: nh,
  atan: V2e,
  bignumber: lS,
  column: uge,
  complex: uS,
  config: da,
  cos: f3,
  diag: Z2e,
  divideScalar: q0,
  dot: _4,
  equal: Ez,
  flatten: Iz,
  im: H2e,
  inv: x4,
  larger: pS,
  matrix: en,
  matrixFromColumns: J2e,
  multiply: ys,
  multiplyScalar: ih,
  number: cS,
  qr: $2e,
  re: K2e,
  reshape: W2e,
  sin: Az,
  size: dS,
  smaller: b4,
  sqrt: v4,
  subtract: Tz,
  typed: Lt,
  usolve: tge,
  usolveAll: age
}), hS = /* @__PURE__ */ x2e({
  abs: d0,
  add: fl,
  conj: m4,
  ctranspose: j2e,
  eigs: dge,
  equalScalar: lu,
  larger: pS,
  matrix: en,
  multiply: ys,
  pow: cge,
  smaller: b4,
  sqrt: v4,
  typed: Lt
}), Ay = { exports: {} };
/**
 * @license
 * Lodash <https://lodash.com/>
 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
 * Released under MIT license <https://lodash.com/license>
 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 */
Ay.exports;
(function(t, e) {
  (function() {
    var r, n = "4.17.21", i = 200, a = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", o = "Expected a function", s = "Invalid `variable` option passed into `_.template`", u = "__lodash_hash_undefined__", c = 500, l = "__lodash_placeholder__", d = 1, f = 2, h = 4, m = 1, p = 2, v = 1, g = 2, y = 4, b = 8, S = 16, _ = 32, x = 64, C = 128, A = 256, w = 512, I = 30, P = "...", M = 800, T = 16, F = 1, N = 2, R = 3, L = 1 / 0, V = 9007199254740991, U = 17976931348623157e292, H = NaN, K = 4294967295, X = K - 1, Y = K >>> 1, Q = [
      ["ary", C],
      ["bind", v],
      ["bindKey", g],
      ["curry", b],
      ["curryRight", S],
      ["flip", w],
      ["partial", _],
      ["partialRight", x],
      ["rearg", A]
    ], J = "[object Arguments]", te = "[object Array]", W = "[object AsyncFunction]", j = "[object Boolean]", ee = "[object Date]", ie = "[object DOMException]", ae = "[object Error]", ce = "[object Function]", de = "[object GeneratorFunction]", Ce = "[object Map]", De = "[object Number]", ke = "[object Null]", He = "[object Object]", We = "[object Promise]", Ne = "[object Proxy]", Je = "[object RegExp]", Re = "[object Set]", nt = "[object String]", ne = "[object Symbol]", re = "[object Undefined]", le = "[object WeakMap]", fe = "[object WeakSet]", ge = "[object ArrayBuffer]", me = "[object DataView]", Ae = "[object Float32Array]", Oe = "[object Float64Array]", Ue = "[object Int8Array]", Ve = "[object Int16Array]", ht = "[object Int32Array]", bt = "[object Uint8Array]", At = "[object Uint8ClampedArray]", Ee = "[object Uint16Array]", st = "[object Uint32Array]", Et = /\b__p \+= '';/g, ur = /\b(__p \+=) '' \+/g, ir = /(__e\(.*?\)|\b__t\)) \+\n'';/g, Nr = /&(?:amp|lt|gt|quot|#39);/g, pr = /[&<>"']/g, _n = RegExp(Nr.source), Jn = RegExp(pr.source), Yn = /<%-([\s\S]+?)%>/g, Rn = /<%([\s\S]+?)%>/g, un = /<%=([\s\S]+?)%>/g, yi = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, cn = /^\w*$/, ln = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, Ti = /[\\^$.*+?()[\]{}|]/g, Mi = RegExp(Ti.source), so = /^\s+/, On = /\s/, xn = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, Wo = /\{\n\/\* \[wrapped with (.+)\] \*/, jo = /,? & /, Eo = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, Hu = /[()=,{}\[\]\/\s]/, uo = /\\(\\)?/g, Pi = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, Mc = /\w*$/, Ul = /^[-+]0x[0-9a-f]+$/i, Hl = /^0b[01]+$/i, ql = /^\[object .+?Constructor\]$/, Kl = /^0o[0-7]+$/i, Xl = /^(?:0|[1-9]\d*)$/, $0 = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Yl = /($^)/, Pc = /['\n\r\u2028\u2029\\]/g, Gr = "\\ud800-\\udfff", ha = "\\u0300-\\u036f", ph = "\\ufe20-\\ufe2f", Wl = "\\u20d0-\\u20ff", qu = ha + ph + Wl, e1 = "\\u2700-\\u27bf", L2 = "a-z\\xdf-\\xf6\\xf8-\\xff", h5 = "\\xac\\xb1\\xd7\\xf7", Zo = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", m5 = "\\u2000-\\u206f", g5 = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", k2 = "A-Z\\xc0-\\xd6\\xd8-\\xde", G2 = "\\ufe0e\\ufe0f", z2 = h5 + Zo + m5 + g5, hh = "['’]", v5 = "[" + Gr + "]", V2 = "[" + z2 + "]", t1 = "[" + qu + "]", U2 = "\\d+", y5 = "[" + e1 + "]", H2 = "[" + L2 + "]", q2 = "[^" + Gr + z2 + U2 + e1 + L2 + k2 + "]", mh = "\\ud83c[\\udffb-\\udfff]", b5 = "(?:" + t1 + "|" + mh + ")", K2 = "[^" + Gr + "]", r1 = "(?:\\ud83c[\\udde6-\\uddff]){2}", gh = "[\\ud800-\\udbff][\\udc00-\\udfff]", jl = "[" + k2 + "]", BS = "\\u200d", FS = "(?:" + H2 + "|" + q2 + ")", hV = "(?:" + jl + "|" + q2 + ")", NS = "(?:" + hh + "(?:d|ll|m|re|s|t|ve))?", RS = "(?:" + hh + "(?:D|LL|M|RE|S|T|VE))?", OS = b5 + "?", LS = "[" + G2 + "]?", mV = "(?:" + BS + "(?:" + [K2, r1, gh].join("|") + ")" + LS + OS + ")*", gV = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", vV = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", kS = LS + OS + mV, yV = "(?:" + [y5, r1, gh].join("|") + ")" + kS, bV = "(?:" + [K2 + t1 + "?", t1, r1, gh, v5].join("|") + ")", _V = RegExp(hh, "g"), xV = RegExp(t1, "g"), _5 = RegExp(mh + "(?=" + mh + ")|" + bV + kS, "g"), SV = RegExp([
      jl + "?" + H2 + "+" + NS + "(?=" + [V2, jl, "$"].join("|") + ")",
      hV + "+" + RS + "(?=" + [V2, jl + FS, "$"].join("|") + ")",
      jl + "?" + FS + "+" + NS,
      jl + "+" + RS,
      vV,
      gV,
      U2,
      yV
    ].join("|"), "g"), CV = RegExp("[" + BS + Gr + qu + G2 + "]"), AV = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, wV = [
      "Array",
      "Buffer",
      "DataView",
      "Date",
      "Error",
      "Float32Array",
      "Float64Array",
      "Function",
      "Int8Array",
      "Int16Array",
      "Int32Array",
      "Map",
      "Math",
      "Object",
      "Promise",
      "RegExp",
      "Set",
      "String",
      "Symbol",
      "TypeError",
      "Uint8Array",
      "Uint8ClampedArray",
      "Uint16Array",
      "Uint32Array",
      "WeakMap",
      "_",
      "clearTimeout",
      "isFinite",
      "parseInt",
      "setTimeout"
    ], DV = -1, Wn = {};
    Wn[Ae] = Wn[Oe] = Wn[Ue] = Wn[Ve] = Wn[ht] = Wn[bt] = Wn[At] = Wn[Ee] = Wn[st] = !0, Wn[J] = Wn[te] = Wn[ge] = Wn[j] = Wn[me] = Wn[ee] = Wn[ae] = Wn[ce] = Wn[Ce] = Wn[De] = Wn[He] = Wn[Je] = Wn[Re] = Wn[nt] = Wn[le] = !1;
    var Hn = {};
    Hn[J] = Hn[te] = Hn[ge] = Hn[me] = Hn[j] = Hn[ee] = Hn[Ae] = Hn[Oe] = Hn[Ue] = Hn[Ve] = Hn[ht] = Hn[Ce] = Hn[De] = Hn[He] = Hn[Je] = Hn[Re] = Hn[nt] = Hn[ne] = Hn[bt] = Hn[At] = Hn[Ee] = Hn[st] = !0, Hn[ae] = Hn[ce] = Hn[le] = !1;
    var EV = {
      // Latin-1 Supplement block.
      À: "A",
      Á: "A",
      Â: "A",
      Ã: "A",
      Ä: "A",
      Å: "A",
      à: "a",
      á: "a",
      â: "a",
      ã: "a",
      ä: "a",
      å: "a",
      Ç: "C",
      ç: "c",
      Ð: "D",
      ð: "d",
      È: "E",
      É: "E",
      Ê: "E",
      Ë: "E",
      è: "e",
      é: "e",
      ê: "e",
      ë: "e",
      Ì: "I",
      Í: "I",
      Î: "I",
      Ï: "I",
      ì: "i",
      í: "i",
      î: "i",
      ï: "i",
      Ñ: "N",
      ñ: "n",
      Ò: "O",
      Ó: "O",
      Ô: "O",
      Õ: "O",
      Ö: "O",
      Ø: "O",
      ò: "o",
      ó: "o",
      ô: "o",
      õ: "o",
      ö: "o",
      ø: "o",
      Ù: "U",
      Ú: "U",
      Û: "U",
      Ü: "U",
      ù: "u",
      ú: "u",
      û: "u",
      ü: "u",
      Ý: "Y",
      ý: "y",
      ÿ: "y",
      Æ: "Ae",
      æ: "ae",
      Þ: "Th",
      þ: "th",
      ß: "ss",
      // Latin Extended-A block.
      Ā: "A",
      Ă: "A",
      Ą: "A",
      ā: "a",
      ă: "a",
      ą: "a",
      Ć: "C",
      Ĉ: "C",
      Ċ: "C",
      Č: "C",
      ć: "c",
      ĉ: "c",
      ċ: "c",
      č: "c",
      Ď: "D",
      Đ: "D",
      ď: "d",
      đ: "d",
      Ē: "E",
      Ĕ: "E",
      Ė: "E",
      Ę: "E",
      Ě: "E",
      ē: "e",
      ĕ: "e",
      ė: "e",
      ę: "e",
      ě: "e",
      Ĝ: "G",
      Ğ: "G",
      Ġ: "G",
      Ģ: "G",
      ĝ: "g",
      ğ: "g",
      ġ: "g",
      ģ: "g",
      Ĥ: "H",
      Ħ: "H",
      ĥ: "h",
      ħ: "h",
      Ĩ: "I",
      Ī: "I",
      Ĭ: "I",
      Į: "I",
      İ: "I",
      ĩ: "i",
      ī: "i",
      ĭ: "i",
      į: "i",
      ı: "i",
      Ĵ: "J",
      ĵ: "j",
      Ķ: "K",
      ķ: "k",
      ĸ: "k",
      Ĺ: "L",
      Ļ: "L",
      Ľ: "L",
      Ŀ: "L",
      Ł: "L",
      ĺ: "l",
      ļ: "l",
      ľ: "l",
      ŀ: "l",
      ł: "l",
      Ń: "N",
      Ņ: "N",
      Ň: "N",
      Ŋ: "N",
      ń: "n",
      ņ: "n",
      ň: "n",
      ŋ: "n",
      Ō: "O",
      Ŏ: "O",
      Ő: "O",
      ō: "o",
      ŏ: "o",
      ő: "o",
      Ŕ: "R",
      Ŗ: "R",
      Ř: "R",
      ŕ: "r",
      ŗ: "r",
      ř: "r",
      Ś: "S",
      Ŝ: "S",
      Ş: "S",
      Š: "S",
      ś: "s",
      ŝ: "s",
      ş: "s",
      š: "s",
      Ţ: "T",
      Ť: "T",
      Ŧ: "T",
      ţ: "t",
      ť: "t",
      ŧ: "t",
      Ũ: "U",
      Ū: "U",
      Ŭ: "U",
      Ů: "U",
      Ű: "U",
      Ų: "U",
      ũ: "u",
      ū: "u",
      ŭ: "u",
      ů: "u",
      ű: "u",
      ų: "u",
      Ŵ: "W",
      ŵ: "w",
      Ŷ: "Y",
      ŷ: "y",
      Ÿ: "Y",
      Ź: "Z",
      Ż: "Z",
      Ž: "Z",
      ź: "z",
      ż: "z",
      ž: "z",
      Ĳ: "IJ",
      ĳ: "ij",
      Œ: "Oe",
      œ: "oe",
      ŉ: "'n",
      ſ: "s"
    }, IV = {
      "&": "&amp;",
      "<": "&lt;",
      ">": "&gt;",
      '"': "&quot;",
      "'": "&#39;"
    }, TV = {
      "&amp;": "&",
      "&lt;": "<",
      "&gt;": ">",
      "&quot;": '"',
      "&#39;": "'"
    }, MV = {
      "\\": "\\",
      "'": "'",
      "\n": "n",
      "\r": "r",
      "\u2028": "u2028",
      "\u2029": "u2029"
    }, PV = parseFloat, BV = parseInt, GS = typeof o0 == "object" && o0 && o0.Object === Object && o0, FV = typeof self == "object" && self && self.Object === Object && self, Ma = GS || FV || Function("return this")(), x5 = e && !e.nodeType && e, Af = x5 && !0 && t && !t.nodeType && t, zS = Af && Af.exports === x5, S5 = zS && GS.process, As = function() {
      try {
        var Te = Af && Af.require && Af.require("util").types;
        return Te || S5 && S5.binding && S5.binding("util");
      } catch {
      }
    }(), VS = As && As.isArrayBuffer, US = As && As.isDate, HS = As && As.isMap, qS = As && As.isRegExp, KS = As && As.isSet, XS = As && As.isTypedArray;
    function Qo(Te, $e, Ye) {
      switch (Ye.length) {
        case 0:
          return Te.call($e);
        case 1:
          return Te.call($e, Ye[0]);
        case 2:
          return Te.call($e, Ye[0], Ye[1]);
        case 3:
          return Te.call($e, Ye[0], Ye[1], Ye[2]);
      }
      return Te.apply($e, Ye);
    }
    function NV(Te, $e, Ye, Mt) {
      for (var vr = -1, dn = Te == null ? 0 : Te.length; ++vr < dn; ) {
        var Ji = Te[vr];
        $e(Mt, Ji, Ye(Ji), Te);
      }
      return Mt;
    }
    function ws(Te, $e) {
      for (var Ye = -1, Mt = Te == null ? 0 : Te.length; ++Ye < Mt && $e(Te[Ye], Ye, Te) !== !1; )
        ;
      return Te;
    }
    function RV(Te, $e) {
      for (var Ye = Te == null ? 0 : Te.length; Ye-- && $e(Te[Ye], Ye, Te) !== !1; )
        ;
      return Te;
    }
    function YS(Te, $e) {
      for (var Ye = -1, Mt = Te == null ? 0 : Te.length; ++Ye < Mt; )
        if (!$e(Te[Ye], Ye, Te))
          return !1;
      return !0;
    }
    function Zl(Te, $e) {
      for (var Ye = -1, Mt = Te == null ? 0 : Te.length, vr = 0, dn = []; ++Ye < Mt; ) {
        var Ji = Te[Ye];
        $e(Ji, Ye, Te) && (dn[vr++] = Ji);
      }
      return dn;
    }
    function X2(Te, $e) {
      var Ye = Te == null ? 0 : Te.length;
      return !!Ye && n1(Te, $e, 0) > -1;
    }
    function C5(Te, $e, Ye) {
      for (var Mt = -1, vr = Te == null ? 0 : Te.length; ++Mt < vr; )
        if (Ye($e, Te[Mt]))
          return !0;
      return !1;
    }
    function $n(Te, $e) {
      for (var Ye = -1, Mt = Te == null ? 0 : Te.length, vr = Array(Mt); ++Ye < Mt; )
        vr[Ye] = $e(Te[Ye], Ye, Te);
      return vr;
    }
    function Ql(Te, $e) {
      for (var Ye = -1, Mt = $e.length, vr = Te.length; ++Ye < Mt; )
        Te[vr + Ye] = $e[Ye];
      return Te;
    }
    function A5(Te, $e, Ye, Mt) {
      var vr = -1, dn = Te == null ? 0 : Te.length;
      for (Mt && dn && (Ye = Te[++vr]); ++vr < dn; )
        Ye = $e(Ye, Te[vr], vr, Te);
      return Ye;
    }
    function OV(Te, $e, Ye, Mt) {
      var vr = Te == null ? 0 : Te.length;
      for (Mt && vr && (Ye = Te[--vr]); vr--; )
        Ye = $e(Ye, Te[vr], vr, Te);
      return Ye;
    }
    function w5(Te, $e) {
      for (var Ye = -1, Mt = Te == null ? 0 : Te.length; ++Ye < Mt; )
        if ($e(Te[Ye], Ye, Te))
          return !0;
      return !1;
    }
    var LV = D5("length");
    function kV(Te) {
      return Te.split("");
    }
    function GV(Te) {
      return Te.match(Eo) || [];
    }
    function WS(Te, $e, Ye) {
      var Mt;
      return Ye(Te, function(vr, dn, Ji) {
        if ($e(vr, dn, Ji))
          return Mt = dn, !1;
      }), Mt;
    }
    function Y2(Te, $e, Ye, Mt) {
      for (var vr = Te.length, dn = Ye + (Mt ? 1 : -1); Mt ? dn-- : ++dn < vr; )
        if ($e(Te[dn], dn, Te))
          return dn;
      return -1;
    }
    function n1(Te, $e, Ye) {
      return $e === $e ? QV(Te, $e, Ye) : Y2(Te, jS, Ye);
    }
    function zV(Te, $e, Ye, Mt) {
      for (var vr = Ye - 1, dn = Te.length; ++vr < dn; )
        if (Mt(Te[vr], $e))
          return vr;
      return -1;
    }
    function jS(Te) {
      return Te !== Te;
    }
    function ZS(Te, $e) {
      var Ye = Te == null ? 0 : Te.length;
      return Ye ? I5(Te, $e) / Ye : H;
    }
    function D5(Te) {
      return function($e) {
        return $e == null ? r : $e[Te];
      };
    }
    function E5(Te) {
      return function($e) {
        return Te == null ? r : Te[$e];
      };
    }
    function QS(Te, $e, Ye, Mt, vr) {
      return vr(Te, function(dn, Ji, Ln) {
        Ye = Mt ? (Mt = !1, dn) : $e(Ye, dn, Ji, Ln);
      }), Ye;
    }
    function VV(Te, $e) {
      var Ye = Te.length;
      for (Te.sort($e); Ye--; )
        Te[Ye] = Te[Ye].value;
      return Te;
    }
    function I5(Te, $e) {
      for (var Ye, Mt = -1, vr = Te.length; ++Mt < vr; ) {
        var dn = $e(Te[Mt]);
        dn !== r && (Ye = Ye === r ? dn : Ye + dn);
      }
      return Ye;
    }
    function T5(Te, $e) {
      for (var Ye = -1, Mt = Array(Te); ++Ye < Te; )
        Mt[Ye] = $e(Ye);
      return Mt;
    }
    function UV(Te, $e) {
      return $n($e, function(Ye) {
        return [Ye, Te[Ye]];
      });
    }
    function JS(Te) {
      return Te && Te.slice(0, rC(Te) + 1).replace(so, "");
    }
    function Jo(Te) {
      return function($e) {
        return Te($e);
      };
    }
    function M5(Te, $e) {
      return $n($e, function(Ye) {
        return Te[Ye];
      });
    }
    function vh(Te, $e) {
      return Te.has($e);
    }
    function $S(Te, $e) {
      for (var Ye = -1, Mt = Te.length; ++Ye < Mt && n1($e, Te[Ye], 0) > -1; )
        ;
      return Ye;
    }
    function eC(Te, $e) {
      for (var Ye = Te.length; Ye-- && n1($e, Te[Ye], 0) > -1; )
        ;
      return Ye;
    }
    function HV(Te, $e) {
      for (var Ye = Te.length, Mt = 0; Ye--; )
        Te[Ye] === $e && ++Mt;
      return Mt;
    }
    var qV = E5(EV), KV = E5(IV);
    function XV(Te) {
      return "\\" + MV[Te];
    }
    function YV(Te, $e) {
      return Te == null ? r : Te[$e];
    }
    function i1(Te) {
      return CV.test(Te);
    }
    function WV(Te) {
      return AV.test(Te);
    }
    function jV(Te) {
      for (var $e, Ye = []; !($e = Te.next()).done; )
        Ye.push($e.value);
      return Ye;
    }
    function P5(Te) {
      var $e = -1, Ye = Array(Te.size);
      return Te.forEach(function(Mt, vr) {
        Ye[++$e] = [vr, Mt];
      }), Ye;
    }
    function tC(Te, $e) {
      return function(Ye) {
        return Te($e(Ye));
      };
    }
    function Jl(Te, $e) {
      for (var Ye = -1, Mt = Te.length, vr = 0, dn = []; ++Ye < Mt; ) {
        var Ji = Te[Ye];
        (Ji === $e || Ji === l) && (Te[Ye] = l, dn[vr++] = Ye);
      }
      return dn;
    }
    function W2(Te) {
      var $e = -1, Ye = Array(Te.size);
      return Te.forEach(function(Mt) {
        Ye[++$e] = Mt;
      }), Ye;
    }
    function ZV(Te) {
      var $e = -1, Ye = Array(Te.size);
      return Te.forEach(function(Mt) {
        Ye[++$e] = [Mt, Mt];
      }), Ye;
    }
    function QV(Te, $e, Ye) {
      for (var Mt = Ye - 1, vr = Te.length; ++Mt < vr; )
        if (Te[Mt] === $e)
          return Mt;
      return -1;
    }
    function JV(Te, $e, Ye) {
      for (var Mt = Ye + 1; Mt--; )
        if (Te[Mt] === $e)
          return Mt;
      return Mt;
    }
    function a1(Te) {
      return i1(Te) ? eU(Te) : LV(Te);
    }
    function du(Te) {
      return i1(Te) ? tU(Te) : kV(Te);
    }
    function rC(Te) {
      for (var $e = Te.length; $e-- && On.test(Te.charAt($e)); )
        ;
      return $e;
    }
    var $V = E5(TV);
    function eU(Te) {
      for (var $e = _5.lastIndex = 0; _5.test(Te); )
        ++$e;
      return $e;
    }
    function tU(Te) {
      return Te.match(_5) || [];
    }
    function rU(Te) {
      return Te.match(SV) || [];
    }
    var nU = function Te($e) {
      $e = $e == null ? Ma : o1.defaults(Ma.Object(), $e, o1.pick(Ma, wV));
      var Ye = $e.Array, Mt = $e.Date, vr = $e.Error, dn = $e.Function, Ji = $e.Math, Ln = $e.Object, B5 = $e.RegExp, iU = $e.String, Ds = $e.TypeError, j2 = Ye.prototype, aU = dn.prototype, s1 = Ln.prototype, Z2 = $e["__core-js_shared__"], Q2 = aU.toString, Sn = s1.hasOwnProperty, oU = 0, nC = function() {
        var D = /[^.]+$/.exec(Z2 && Z2.keys && Z2.keys.IE_PROTO || "");
        return D ? "Symbol(src)_1." + D : "";
      }(), J2 = s1.toString, sU = Q2.call(Ln), uU = Ma._, cU = B5(
        "^" + Q2.call(Sn).replace(Ti, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
      ), $2 = zS ? $e.Buffer : r, $l = $e.Symbol, eg = $e.Uint8Array, iC = $2 ? $2.allocUnsafe : r, tg = tC(Ln.getPrototypeOf, Ln), aC = Ln.create, oC = s1.propertyIsEnumerable, rg = j2.splice, sC = $l ? $l.isConcatSpreadable : r, yh = $l ? $l.iterator : r, wf = $l ? $l.toStringTag : r, ng = function() {
        try {
          var D = Mf(Ln, "defineProperty");
          return D({}, "", {}), D;
        } catch {
        }
      }(), lU = $e.clearTimeout !== Ma.clearTimeout && $e.clearTimeout, dU = Mt && Mt.now !== Ma.Date.now && Mt.now, fU = $e.setTimeout !== Ma.setTimeout && $e.setTimeout, ig = Ji.ceil, ag = Ji.floor, F5 = Ln.getOwnPropertySymbols, pU = $2 ? $2.isBuffer : r, uC = $e.isFinite, hU = j2.join, mU = tC(Ln.keys, Ln), $i = Ji.max, qa = Ji.min, gU = Mt.now, vU = $e.parseInt, cC = Ji.random, yU = j2.reverse, N5 = Mf($e, "DataView"), bh = Mf($e, "Map"), R5 = Mf($e, "Promise"), u1 = Mf($e, "Set"), _h = Mf($e, "WeakMap"), xh = Mf(Ln, "create"), og = _h && new _h(), c1 = {}, bU = Pf(N5), _U = Pf(bh), xU = Pf(R5), SU = Pf(u1), CU = Pf(_h), sg = $l ? $l.prototype : r, Sh = sg ? sg.valueOf : r, lC = sg ? sg.toString : r;
      function oe(D) {
        if (bi(D) && !Cr(D) && !(D instanceof zr)) {
          if (D instanceof Es)
            return D;
          if (Sn.call(D, "__wrapped__"))
            return dA(D);
        }
        return new Es(D);
      }
      var l1 = /* @__PURE__ */ function() {
        function D() {
        }
        return function(B) {
          if (!ui(B))
            return {};
          if (aC)
            return aC(B);
          D.prototype = B;
          var k = new D();
          return D.prototype = r, k;
        };
      }();
      function ug() {
      }
      function Es(D, B) {
        this.__wrapped__ = D, this.__actions__ = [], this.__chain__ = !!B, this.__index__ = 0, this.__values__ = r;
      }
      oe.templateSettings = {
        /**
         * Used to detect `data` property values to be HTML-escaped.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        escape: Yn,
        /**
         * Used to detect code to be evaluated.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        evaluate: Rn,
        /**
         * Used to detect `data` property values to inject.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        interpolate: un,
        /**
         * Used to reference the data object in the template text.
         *
         * @memberOf _.templateSettings
         * @type {string}
         */
        variable: "",
        /**
         * Used to import variables into the compiled template.
         *
         * @memberOf _.templateSettings
         * @type {Object}
         */
        imports: {
          /**
           * A reference to the `lodash` function.
           *
           * @memberOf _.templateSettings.imports
           * @type {Function}
           */
          _: oe
        }
      }, oe.prototype = ug.prototype, oe.prototype.constructor = oe, Es.prototype = l1(ug.prototype), Es.prototype.constructor = Es;
      function zr(D) {
        this.__wrapped__ = D, this.__actions__ = [], this.__dir__ = 1, this.__filtered__ = !1, this.__iteratees__ = [], this.__takeCount__ = K, this.__views__ = [];
      }
      function AU() {
        var D = new zr(this.__wrapped__);
        return D.__actions__ = Io(this.__actions__), D.__dir__ = this.__dir__, D.__filtered__ = this.__filtered__, D.__iteratees__ = Io(this.__iteratees__), D.__takeCount__ = this.__takeCount__, D.__views__ = Io(this.__views__), D;
      }
      function wU() {
        if (this.__filtered__) {
          var D = new zr(this);
          D.__dir__ = -1, D.__filtered__ = !0;
        } else
          D = this.clone(), D.__dir__ *= -1;
        return D;
      }
      function DU() {
        var D = this.__wrapped__.value(), B = this.__dir__, k = Cr(D), q = B < 0, $ = k ? D.length : 0, ue = kH(0, $, this.__views__), ve = ue.start, we = ue.end, Be = we - ve, rt = q ? we : ve - 1, it = this.__iteratees__, dt = it.length, Ct = 0, Rt = qa(Be, this.__takeCount__);
        if (!k || !q && $ == Be && Rt == Be)
          return NC(D, this.__actions__);
        var Jt = [];
        e:
          for (; Be-- && Ct < Rt; ) {
            rt += B;
            for (var Tr = -1, $t = D[rt]; ++Tr < dt; ) {
              var Or = it[Tr], qr = Or.iteratee, ts = Or.type, fo = qr($t);
              if (ts == N)
                $t = fo;
              else if (!fo) {
                if (ts == F)
                  continue e;
                break e;
              }
            }
            Jt[Ct++] = $t;
          }
        return Jt;
      }
      zr.prototype = l1(ug.prototype), zr.prototype.constructor = zr;
      function Df(D) {
        var B = -1, k = D == null ? 0 : D.length;
        for (this.clear(); ++B < k; ) {
          var q = D[B];
          this.set(q[0], q[1]);
        }
      }
      function EU() {
        this.__data__ = xh ? xh(null) : {}, this.size = 0;
      }
      function IU(D) {
        var B = this.has(D) && delete this.__data__[D];
        return this.size -= B ? 1 : 0, B;
      }
      function TU(D) {
        var B = this.__data__;
        if (xh) {
          var k = B[D];
          return k === u ? r : k;
        }
        return Sn.call(B, D) ? B[D] : r;
      }
      function MU(D) {
        var B = this.__data__;
        return xh ? B[D] !== r : Sn.call(B, D);
      }
      function PU(D, B) {
        var k = this.__data__;
        return this.size += this.has(D) ? 0 : 1, k[D] = xh && B === r ? u : B, this;
      }
      Df.prototype.clear = EU, Df.prototype.delete = IU, Df.prototype.get = TU, Df.prototype.has = MU, Df.prototype.set = PU;
      function Bc(D) {
        var B = -1, k = D == null ? 0 : D.length;
        for (this.clear(); ++B < k; ) {
          var q = D[B];
          this.set(q[0], q[1]);
        }
      }
      function BU() {
        this.__data__ = [], this.size = 0;
      }
      function FU(D) {
        var B = this.__data__, k = cg(B, D);
        if (k < 0)
          return !1;
        var q = B.length - 1;
        return k == q ? B.pop() : rg.call(B, k, 1), --this.size, !0;
      }
      function NU(D) {
        var B = this.__data__, k = cg(B, D);
        return k < 0 ? r : B[k][1];
      }
      function RU(D) {
        return cg(this.__data__, D) > -1;
      }
      function OU(D, B) {
        var k = this.__data__, q = cg(k, D);
        return q < 0 ? (++this.size, k.push([D, B])) : k[q][1] = B, this;
      }
      Bc.prototype.clear = BU, Bc.prototype.delete = FU, Bc.prototype.get = NU, Bc.prototype.has = RU, Bc.prototype.set = OU;
      function Fc(D) {
        var B = -1, k = D == null ? 0 : D.length;
        for (this.clear(); ++B < k; ) {
          var q = D[B];
          this.set(q[0], q[1]);
        }
      }
      function LU() {
        this.size = 0, this.__data__ = {
          hash: new Df(),
          map: new (bh || Bc)(),
          string: new Df()
        };
      }
      function kU(D) {
        var B = xg(this, D).delete(D);
        return this.size -= B ? 1 : 0, B;
      }
      function GU(D) {
        return xg(this, D).get(D);
      }
      function zU(D) {
        return xg(this, D).has(D);
      }
      function VU(D, B) {
        var k = xg(this, D), q = k.size;
        return k.set(D, B), this.size += k.size == q ? 0 : 1, this;
      }
      Fc.prototype.clear = LU, Fc.prototype.delete = kU, Fc.prototype.get = GU, Fc.prototype.has = zU, Fc.prototype.set = VU;
      function Ef(D) {
        var B = -1, k = D == null ? 0 : D.length;
        for (this.__data__ = new Fc(); ++B < k; )
          this.add(D[B]);
      }
      function UU(D) {
        return this.__data__.set(D, u), this;
      }
      function HU(D) {
        return this.__data__.has(D);
      }
      Ef.prototype.add = Ef.prototype.push = UU, Ef.prototype.has = HU;
      function fu(D) {
        var B = this.__data__ = new Bc(D);
        this.size = B.size;
      }
      function qU() {
        this.__data__ = new Bc(), this.size = 0;
      }
      function KU(D) {
        var B = this.__data__, k = B.delete(D);
        return this.size = B.size, k;
      }
      function XU(D) {
        return this.__data__.get(D);
      }
      function YU(D) {
        return this.__data__.has(D);
      }
      function WU(D, B) {
        var k = this.__data__;
        if (k instanceof Bc) {
          var q = k.__data__;
          if (!bh || q.length < i - 1)
            return q.push([D, B]), this.size = ++k.size, this;
          k = this.__data__ = new Fc(q);
        }
        return k.set(D, B), this.size = k.size, this;
      }
      fu.prototype.clear = qU, fu.prototype.delete = KU, fu.prototype.get = XU, fu.prototype.has = YU, fu.prototype.set = WU;
      function dC(D, B) {
        var k = Cr(D), q = !k && Bf(D), $ = !k && !q && id(D), ue = !k && !q && !$ && h1(D), ve = k || q || $ || ue, we = ve ? T5(D.length, iU) : [], Be = we.length;
        for (var rt in D)
          (B || Sn.call(D, rt)) && !(ve && // Safari 9 has enumerable `arguments.length` in strict mode.
          (rt == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
          $ && (rt == "offset" || rt == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
          ue && (rt == "buffer" || rt == "byteLength" || rt == "byteOffset") || // Skip index properties.
          Lc(rt, Be))) && we.push(rt);
        return we;
      }
      function fC(D) {
        var B = D.length;
        return B ? D[X5(0, B - 1)] : r;
      }
      function jU(D, B) {
        return Sg(Io(D), If(B, 0, D.length));
      }
      function ZU(D) {
        return Sg(Io(D));
      }
      function O5(D, B, k) {
        (k !== r && !pu(D[B], k) || k === r && !(B in D)) && Nc(D, B, k);
      }
      function Ch(D, B, k) {
        var q = D[B];
        (!(Sn.call(D, B) && pu(q, k)) || k === r && !(B in D)) && Nc(D, B, k);
      }
      function cg(D, B) {
        for (var k = D.length; k--; )
          if (pu(D[k][0], B))
            return k;
        return -1;
      }
      function QU(D, B, k, q) {
        return ed(D, function($, ue, ve) {
          B(q, $, k($), ve);
        }), q;
      }
      function pC(D, B) {
        return D && Xu(B, ma(B), D);
      }
      function JU(D, B) {
        return D && Xu(B, Mo(B), D);
      }
      function Nc(D, B, k) {
        B == "__proto__" && ng ? ng(D, B, {
          configurable: !0,
          enumerable: !0,
          value: k,
          writable: !0
        }) : D[B] = k;
      }
      function L5(D, B) {
        for (var k = -1, q = B.length, $ = Ye(q), ue = D == null; ++k < q; )
          $[k] = ue ? r : v6(D, B[k]);
        return $;
      }
      function If(D, B, k) {
        return D === D && (k !== r && (D = D <= k ? D : k), B !== r && (D = D >= B ? D : B)), D;
      }
      function Is(D, B, k, q, $, ue) {
        var ve, we = B & d, Be = B & f, rt = B & h;
        if (k && (ve = $ ? k(D, q, $, ue) : k(D)), ve !== r)
          return ve;
        if (!ui(D))
          return D;
        var it = Cr(D);
        if (it) {
          if (ve = zH(D), !we)
            return Io(D, ve);
        } else {
          var dt = Ka(D), Ct = dt == ce || dt == de;
          if (id(D))
            return LC(D, we);
          if (dt == He || dt == J || Ct && !$) {
            if (ve = Be || Ct ? {} : rA(D), !we)
              return Be ? TH(D, JU(ve, D)) : IH(D, pC(ve, D));
          } else {
            if (!Hn[dt])
              return $ ? D : {};
            ve = VH(D, dt, we);
          }
        }
        ue || (ue = new fu());
        var Rt = ue.get(D);
        if (Rt)
          return Rt;
        ue.set(D, ve), PA(D) ? D.forEach(function($t) {
          ve.add(Is($t, B, k, $t, D, ue));
        }) : TA(D) && D.forEach(function($t, Or) {
          ve.set(Or, Is($t, B, k, Or, D, ue));
        });
        var Jt = rt ? Be ? n6 : r6 : Be ? Mo : ma, Tr = it ? r : Jt(D);
        return ws(Tr || D, function($t, Or) {
          Tr && (Or = $t, $t = D[Or]), Ch(ve, Or, Is($t, B, k, Or, D, ue));
        }), ve;
      }
      function $U(D) {
        var B = ma(D);
        return function(k) {
          return hC(k, D, B);
        };
      }
      function hC(D, B, k) {
        var q = k.length;
        if (D == null)
          return !q;
        for (D = Ln(D); q--; ) {
          var $ = k[q], ue = B[$], ve = D[$];
          if (ve === r && !($ in D) || !ue(ve))
            return !1;
        }
        return !0;
      }
      function mC(D, B, k) {
        if (typeof D != "function")
          throw new Ds(o);
        return Mh(function() {
          D.apply(r, k);
        }, B);
      }
      function Ah(D, B, k, q) {
        var $ = -1, ue = X2, ve = !0, we = D.length, Be = [], rt = B.length;
        if (!we)
          return Be;
        k && (B = $n(B, Jo(k))), q ? (ue = C5, ve = !1) : B.length >= i && (ue = vh, ve = !1, B = new Ef(B));
        e:
          for (; ++$ < we; ) {
            var it = D[$], dt = k == null ? it : k(it);
            if (it = q || it !== 0 ? it : 0, ve && dt === dt) {
              for (var Ct = rt; Ct--; )
                if (B[Ct] === dt)
                  continue e;
              Be.push(it);
            } else ue(B, dt, q) || Be.push(it);
          }
        return Be;
      }
      var ed = UC(Ku), gC = UC(G5, !0);
      function eH(D, B) {
        var k = !0;
        return ed(D, function(q, $, ue) {
          return k = !!B(q, $, ue), k;
        }), k;
      }
      function lg(D, B, k) {
        for (var q = -1, $ = D.length; ++q < $; ) {
          var ue = D[q], ve = B(ue);
          if (ve != null && (we === r ? ve === ve && !es(ve) : k(ve, we)))
            var we = ve, Be = ue;
        }
        return Be;
      }
      function tH(D, B, k, q) {
        var $ = D.length;
        for (k = Er(k), k < 0 && (k = -k > $ ? 0 : $ + k), q = q === r || q > $ ? $ : Er(q), q < 0 && (q += $), q = k > q ? 0 : FA(q); k < q; )
          D[k++] = B;
        return D;
      }
      function vC(D, B) {
        var k = [];
        return ed(D, function(q, $, ue) {
          B(q, $, ue) && k.push(q);
        }), k;
      }
      function Pa(D, B, k, q, $) {
        var ue = -1, ve = D.length;
        for (k || (k = HH), $ || ($ = []); ++ue < ve; ) {
          var we = D[ue];
          B > 0 && k(we) ? B > 1 ? Pa(we, B - 1, k, q, $) : Ql($, we) : q || ($[$.length] = we);
        }
        return $;
      }
      var k5 = HC(), yC = HC(!0);
      function Ku(D, B) {
        return D && k5(D, B, ma);
      }
      function G5(D, B) {
        return D && yC(D, B, ma);
      }
      function dg(D, B) {
        return Zl(B, function(k) {
          return kc(D[k]);
        });
      }
      function Tf(D, B) {
        B = rd(B, D);
        for (var k = 0, q = B.length; D != null && k < q; )
          D = D[Yu(B[k++])];
        return k && k == q ? D : r;
      }
      function bC(D, B, k) {
        var q = B(D);
        return Cr(D) ? q : Ql(q, k(D));
      }
      function co(D) {
        return D == null ? D === r ? re : ke : wf && wf in Ln(D) ? LH(D) : ZH(D);
      }
      function z5(D, B) {
        return D > B;
      }
      function rH(D, B) {
        return D != null && Sn.call(D, B);
      }
      function nH(D, B) {
        return D != null && B in Ln(D);
      }
      function iH(D, B, k) {
        return D >= qa(B, k) && D < $i(B, k);
      }
      function V5(D, B, k) {
        for (var q = k ? C5 : X2, $ = D[0].length, ue = D.length, ve = ue, we = Ye(ue), Be = 1 / 0, rt = []; ve--; ) {
          var it = D[ve];
          ve && B && (it = $n(it, Jo(B))), Be = qa(it.length, Be), we[ve] = !k && (B || $ >= 120 && it.length >= 120) ? new Ef(ve && it) : r;
        }
        it = D[0];
        var dt = -1, Ct = we[0];
        e:
          for (; ++dt < $ && rt.length < Be; ) {
            var Rt = it[dt], Jt = B ? B(Rt) : Rt;
            if (Rt = k || Rt !== 0 ? Rt : 0, !(Ct ? vh(Ct, Jt) : q(rt, Jt, k))) {
              for (ve = ue; --ve; ) {
                var Tr = we[ve];
                if (!(Tr ? vh(Tr, Jt) : q(D[ve], Jt, k)))
                  continue e;
              }
              Ct && Ct.push(Jt), rt.push(Rt);
            }
          }
        return rt;
      }
      function aH(D, B, k, q) {
        return Ku(D, function($, ue, ve) {
          B(q, k($), ue, ve);
        }), q;
      }
      function wh(D, B, k) {
        B = rd(B, D), D = oA(D, B);
        var q = D == null ? D : D[Yu(Ms(B))];
        return q == null ? r : Qo(q, D, k);
      }
      function _C(D) {
        return bi(D) && co(D) == J;
      }
      function oH(D) {
        return bi(D) && co(D) == ge;
      }
      function sH(D) {
        return bi(D) && co(D) == ee;
      }
      function Dh(D, B, k, q, $) {
        return D === B ? !0 : D == null || B == null || !bi(D) && !bi(B) ? D !== D && B !== B : uH(D, B, k, q, Dh, $);
      }
      function uH(D, B, k, q, $, ue) {
        var ve = Cr(D), we = Cr(B), Be = ve ? te : Ka(D), rt = we ? te : Ka(B);
        Be = Be == J ? He : Be, rt = rt == J ? He : rt;
        var it = Be == He, dt = rt == He, Ct = Be == rt;
        if (Ct && id(D)) {
          if (!id(B))
            return !1;
          ve = !0, it = !1;
        }
        if (Ct && !it)
          return ue || (ue = new fu()), ve || h1(D) ? $C(D, B, k, q, $, ue) : RH(D, B, Be, k, q, $, ue);
        if (!(k & m)) {
          var Rt = it && Sn.call(D, "__wrapped__"), Jt = dt && Sn.call(B, "__wrapped__");
          if (Rt || Jt) {
            var Tr = Rt ? D.value() : D, $t = Jt ? B.value() : B;
            return ue || (ue = new fu()), $(Tr, $t, k, q, ue);
          }
        }
        return Ct ? (ue || (ue = new fu()), OH(D, B, k, q, $, ue)) : !1;
      }
      function cH(D) {
        return bi(D) && Ka(D) == Ce;
      }
      function U5(D, B, k, q) {
        var $ = k.length, ue = $, ve = !q;
        if (D == null)
          return !ue;
        for (D = Ln(D); $--; ) {
          var we = k[$];
          if (ve && we[2] ? we[1] !== D[we[0]] : !(we[0] in D))
            return !1;
        }
        for (; ++$ < ue; ) {
          we = k[$];
          var Be = we[0], rt = D[Be], it = we[1];
          if (ve && we[2]) {
            if (rt === r && !(Be in D))
              return !1;
          } else {
            var dt = new fu();
            if (q)
              var Ct = q(rt, it, Be, D, B, dt);
            if (!(Ct === r ? Dh(it, rt, m | p, q, dt) : Ct))
              return !1;
          }
        }
        return !0;
      }
      function xC(D) {
        if (!ui(D) || KH(D))
          return !1;
        var B = kc(D) ? cU : ql;
        return B.test(Pf(D));
      }
      function lH(D) {
        return bi(D) && co(D) == Je;
      }
      function dH(D) {
        return bi(D) && Ka(D) == Re;
      }
      function fH(D) {
        return bi(D) && Ig(D.length) && !!Wn[co(D)];
      }
      function SC(D) {
        return typeof D == "function" ? D : D == null ? Po : typeof D == "object" ? Cr(D) ? wC(D[0], D[1]) : AC(D) : qA(D);
      }
      function H5(D) {
        if (!Th(D))
          return mU(D);
        var B = [];
        for (var k in Ln(D))
          Sn.call(D, k) && k != "constructor" && B.push(k);
        return B;
      }
      function pH(D) {
        if (!ui(D))
          return jH(D);
        var B = Th(D), k = [];
        for (var q in D)
          q == "constructor" && (B || !Sn.call(D, q)) || k.push(q);
        return k;
      }
      function q5(D, B) {
        return D < B;
      }
      function CC(D, B) {
        var k = -1, q = To(D) ? Ye(D.length) : [];
        return ed(D, function($, ue, ve) {
          q[++k] = B($, ue, ve);
        }), q;
      }
      function AC(D) {
        var B = a6(D);
        return B.length == 1 && B[0][2] ? iA(B[0][0], B[0][1]) : function(k) {
          return k === D || U5(k, D, B);
        };
      }
      function wC(D, B) {
        return s6(D) && nA(B) ? iA(Yu(D), B) : function(k) {
          var q = v6(k, D);
          return q === r && q === B ? y6(k, D) : Dh(B, q, m | p);
        };
      }
      function fg(D, B, k, q, $) {
        D !== B && k5(B, function(ue, ve) {
          if ($ || ($ = new fu()), ui(ue))
            hH(D, B, ve, k, fg, q, $);
          else {
            var we = q ? q(c6(D, ve), ue, ve + "", D, B, $) : r;
            we === r && (we = ue), O5(D, ve, we);
          }
        }, Mo);
      }
      function hH(D, B, k, q, $, ue, ve) {
        var we = c6(D, k), Be = c6(B, k), rt = ve.get(Be);
        if (rt) {
          O5(D, k, rt);
          return;
        }
        var it = ue ? ue(we, Be, k + "", D, B, ve) : r, dt = it === r;
        if (dt) {
          var Ct = Cr(Be), Rt = !Ct && id(Be), Jt = !Ct && !Rt && h1(Be);
          it = Be, Ct || Rt || Jt ? Cr(we) ? it = we : Bi(we) ? it = Io(we) : Rt ? (dt = !1, it = LC(Be, !0)) : Jt ? (dt = !1, it = kC(Be, !0)) : it = [] : Ph(Be) || Bf(Be) ? (it = we, Bf(we) ? it = NA(we) : (!ui(we) || kc(we)) && (it = rA(Be))) : dt = !1;
        }
        dt && (ve.set(Be, it), $(it, Be, q, ue, ve), ve.delete(Be)), O5(D, k, it);
      }
      function DC(D, B) {
        var k = D.length;
        if (k)
          return B += B < 0 ? k : 0, Lc(B, k) ? D[B] : r;
      }
      function EC(D, B, k) {
        B.length ? B = $n(B, function(ue) {
          return Cr(ue) ? function(ve) {
            return Tf(ve, ue.length === 1 ? ue[0] : ue);
          } : ue;
        }) : B = [Po];
        var q = -1;
        B = $n(B, Jo(Wt()));
        var $ = CC(D, function(ue, ve, we) {
          var Be = $n(B, function(rt) {
            return rt(ue);
          });
          return { criteria: Be, index: ++q, value: ue };
        });
        return VV($, function(ue, ve) {
          return EH(ue, ve, k);
        });
      }
      function mH(D, B) {
        return IC(D, B, function(k, q) {
          return y6(D, q);
        });
      }
      function IC(D, B, k) {
        for (var q = -1, $ = B.length, ue = {}; ++q < $; ) {
          var ve = B[q], we = Tf(D, ve);
          k(we, ve) && Eh(ue, rd(ve, D), we);
        }
        return ue;
      }
      function gH(D) {
        return function(B) {
          return Tf(B, D);
        };
      }
      function K5(D, B, k, q) {
        var $ = q ? zV : n1, ue = -1, ve = B.length, we = D;
        for (D === B && (B = Io(B)), k && (we = $n(D, Jo(k))); ++ue < ve; )
          for (var Be = 0, rt = B[ue], it = k ? k(rt) : rt; (Be = $(we, it, Be, q)) > -1; )
            we !== D && rg.call(we, Be, 1), rg.call(D, Be, 1);
        return D;
      }
      function TC(D, B) {
        for (var k = D ? B.length : 0, q = k - 1; k--; ) {
          var $ = B[k];
          if (k == q || $ !== ue) {
            var ue = $;
            Lc($) ? rg.call(D, $, 1) : j5(D, $);
          }
        }
        return D;
      }
      function X5(D, B) {
        return D + ag(cC() * (B - D + 1));
      }
      function vH(D, B, k, q) {
        for (var $ = -1, ue = $i(ig((B - D) / (k || 1)), 0), ve = Ye(ue); ue--; )
          ve[q ? ue : ++$] = D, D += k;
        return ve;
      }
      function Y5(D, B) {
        var k = "";
        if (!D || B < 1 || B > V)
          return k;
        do
          B % 2 && (k += D), B = ag(B / 2), B && (D += D);
        while (B);
        return k;
      }
      function Mr(D, B) {
        return l6(aA(D, B, Po), D + "");
      }
      function yH(D) {
        return fC(m1(D));
      }
      function bH(D, B) {
        var k = m1(D);
        return Sg(k, If(B, 0, k.length));
      }
      function Eh(D, B, k, q) {
        if (!ui(D))
          return D;
        B = rd(B, D);
        for (var $ = -1, ue = B.length, ve = ue - 1, we = D; we != null && ++$ < ue; ) {
          var Be = Yu(B[$]), rt = k;
          if (Be === "__proto__" || Be === "constructor" || Be === "prototype")
            return D;
          if ($ != ve) {
            var it = we[Be];
            rt = q ? q(it, Be, we) : r, rt === r && (rt = ui(it) ? it : Lc(B[$ + 1]) ? [] : {});
          }
          Ch(we, Be, rt), we = we[Be];
        }
        return D;
      }
      var MC = og ? function(D, B) {
        return og.set(D, B), D;
      } : Po, _H = ng ? function(D, B) {
        return ng(D, "toString", {
          configurable: !0,
          enumerable: !1,
          value: _6(B),
          writable: !0
        });
      } : Po;
      function xH(D) {
        return Sg(m1(D));
      }
      function Ts(D, B, k) {
        var q = -1, $ = D.length;
        B < 0 && (B = -B > $ ? 0 : $ + B), k = k > $ ? $ : k, k < 0 && (k += $), $ = B > k ? 0 : k - B >>> 0, B >>>= 0;
        for (var ue = Ye($); ++q < $; )
          ue[q] = D[q + B];
        return ue;
      }
      function SH(D, B) {
        var k;
        return ed(D, function(q, $, ue) {
          return k = B(q, $, ue), !k;
        }), !!k;
      }
      function pg(D, B, k) {
        var q = 0, $ = D == null ? q : D.length;
        if (typeof B == "number" && B === B && $ <= Y) {
          for (; q < $; ) {
            var ue = q + $ >>> 1, ve = D[ue];
            ve !== null && !es(ve) && (k ? ve <= B : ve < B) ? q = ue + 1 : $ = ue;
          }
          return $;
        }
        return W5(D, B, Po, k);
      }
      function W5(D, B, k, q) {
        var $ = 0, ue = D == null ? 0 : D.length;
        if (ue === 0)
          return 0;
        B = k(B);
        for (var ve = B !== B, we = B === null, Be = es(B), rt = B === r; $ < ue; ) {
          var it = ag(($ + ue) / 2), dt = k(D[it]), Ct = dt !== r, Rt = dt === null, Jt = dt === dt, Tr = es(dt);
          if (ve)
            var $t = q || Jt;
          else rt ? $t = Jt && (q || Ct) : we ? $t = Jt && Ct && (q || !Rt) : Be ? $t = Jt && Ct && !Rt && (q || !Tr) : Rt || Tr ? $t = !1 : $t = q ? dt <= B : dt < B;
          $t ? $ = it + 1 : ue = it;
        }
        return qa(ue, X);
      }
      function PC(D, B) {
        for (var k = -1, q = D.length, $ = 0, ue = []; ++k < q; ) {
          var ve = D[k], we = B ? B(ve) : ve;
          if (!k || !pu(we, Be)) {
            var Be = we;
            ue[$++] = ve === 0 ? 0 : ve;
          }
        }
        return ue;
      }
      function BC(D) {
        return typeof D == "number" ? D : es(D) ? H : +D;
      }
      function $o(D) {
        if (typeof D == "string")
          return D;
        if (Cr(D))
          return $n(D, $o) + "";
        if (es(D))
          return lC ? lC.call(D) : "";
        var B = D + "";
        return B == "0" && 1 / D == -L ? "-0" : B;
      }
      function td(D, B, k) {
        var q = -1, $ = X2, ue = D.length, ve = !0, we = [], Be = we;
        if (k)
          ve = !1, $ = C5;
        else if (ue >= i) {
          var rt = B ? null : FH(D);
          if (rt)
            return W2(rt);
          ve = !1, $ = vh, Be = new Ef();
        } else
          Be = B ? [] : we;
        e:
          for (; ++q < ue; ) {
            var it = D[q], dt = B ? B(it) : it;
            if (it = k || it !== 0 ? it : 0, ve && dt === dt) {
              for (var Ct = Be.length; Ct--; )
                if (Be[Ct] === dt)
                  continue e;
              B && Be.push(dt), we.push(it);
            } else $(Be, dt, k) || (Be !== we && Be.push(dt), we.push(it));
          }
        return we;
      }
      function j5(D, B) {
        return B = rd(B, D), D = oA(D, B), D == null || delete D[Yu(Ms(B))];
      }
      function FC(D, B, k, q) {
        return Eh(D, B, k(Tf(D, B)), q);
      }
      function hg(D, B, k, q) {
        for (var $ = D.length, ue = q ? $ : -1; (q ? ue-- : ++ue < $) && B(D[ue], ue, D); )
          ;
        return k ? Ts(D, q ? 0 : ue, q ? ue + 1 : $) : Ts(D, q ? ue + 1 : 0, q ? $ : ue);
      }
      function NC(D, B) {
        var k = D;
        return k instanceof zr && (k = k.value()), A5(B, function(q, $) {
          return $.func.apply($.thisArg, Ql([q], $.args));
        }, k);
      }
      function Z5(D, B, k) {
        var q = D.length;
        if (q < 2)
          return q ? td(D[0]) : [];
        for (var $ = -1, ue = Ye(q); ++$ < q; )
          for (var ve = D[$], we = -1; ++we < q; )
            we != $ && (ue[$] = Ah(ue[$] || ve, D[we], B, k));
        return td(Pa(ue, 1), B, k);
      }
      function RC(D, B, k) {
        for (var q = -1, $ = D.length, ue = B.length, ve = {}; ++q < $; ) {
          var we = q < ue ? B[q] : r;
          k(ve, D[q], we);
        }
        return ve;
      }
      function Q5(D) {
        return Bi(D) ? D : [];
      }
      function J5(D) {
        return typeof D == "function" ? D : Po;
      }
      function rd(D, B) {
        return Cr(D) ? D : s6(D, B) ? [D] : lA(mn(D));
      }
      var CH = Mr;
      function nd(D, B, k) {
        var q = D.length;
        return k = k === r ? q : k, !B && k >= q ? D : Ts(D, B, k);
      }
      var OC = lU || function(D) {
        return Ma.clearTimeout(D);
      };
      function LC(D, B) {
        if (B)
          return D.slice();
        var k = D.length, q = iC ? iC(k) : new D.constructor(k);
        return D.copy(q), q;
      }
      function $5(D) {
        var B = new D.constructor(D.byteLength);
        return new eg(B).set(new eg(D)), B;
      }
      function AH(D, B) {
        var k = B ? $5(D.buffer) : D.buffer;
        return new D.constructor(k, D.byteOffset, D.byteLength);
      }
      function wH(D) {
        var B = new D.constructor(D.source, Mc.exec(D));
        return B.lastIndex = D.lastIndex, B;
      }
      function DH(D) {
        return Sh ? Ln(Sh.call(D)) : {};
      }
      function kC(D, B) {
        var k = B ? $5(D.buffer) : D.buffer;
        return new D.constructor(k, D.byteOffset, D.length);
      }
      function GC(D, B) {
        if (D !== B) {
          var k = D !== r, q = D === null, $ = D === D, ue = es(D), ve = B !== r, we = B === null, Be = B === B, rt = es(B);
          if (!we && !rt && !ue && D > B || ue && ve && Be && !we && !rt || q && ve && Be || !k && Be || !$)
            return 1;
          if (!q && !ue && !rt && D < B || rt && k && $ && !q && !ue || we && k && $ || !ve && $ || !Be)
            return -1;
        }
        return 0;
      }
      function EH(D, B, k) {
        for (var q = -1, $ = D.criteria, ue = B.criteria, ve = $.length, we = k.length; ++q < ve; ) {
          var Be = GC($[q], ue[q]);
          if (Be) {
            if (q >= we)
              return Be;
            var rt = k[q];
            return Be * (rt == "desc" ? -1 : 1);
          }
        }
        return D.index - B.index;
      }
      function zC(D, B, k, q) {
        for (var $ = -1, ue = D.length, ve = k.length, we = -1, Be = B.length, rt = $i(ue - ve, 0), it = Ye(Be + rt), dt = !q; ++we < Be; )
          it[we] = B[we];
        for (; ++$ < ve; )
          (dt || $ < ue) && (it[k[$]] = D[$]);
        for (; rt--; )
          it[we++] = D[$++];
        return it;
      }
      function VC(D, B, k, q) {
        for (var $ = -1, ue = D.length, ve = -1, we = k.length, Be = -1, rt = B.length, it = $i(ue - we, 0), dt = Ye(it + rt), Ct = !q; ++$ < it; )
          dt[$] = D[$];
        for (var Rt = $; ++Be < rt; )
          dt[Rt + Be] = B[Be];
        for (; ++ve < we; )
          (Ct || $ < ue) && (dt[Rt + k[ve]] = D[$++]);
        return dt;
      }
      function Io(D, B) {
        var k = -1, q = D.length;
        for (B || (B = Ye(q)); ++k < q; )
          B[k] = D[k];
        return B;
      }
      function Xu(D, B, k, q) {
        var $ = !k;
        k || (k = {});
        for (var ue = -1, ve = B.length; ++ue < ve; ) {
          var we = B[ue], Be = q ? q(k[we], D[we], we, k, D) : r;
          Be === r && (Be = D[we]), $ ? Nc(k, we, Be) : Ch(k, we, Be);
        }
        return k;
      }
      function IH(D, B) {
        return Xu(D, o6(D), B);
      }
      function TH(D, B) {
        return Xu(D, eA(D), B);
      }
      function mg(D, B) {
        return function(k, q) {
          var $ = Cr(k) ? NV : QU, ue = B ? B() : {};
          return $(k, D, Wt(q, 2), ue);
        };
      }
      function d1(D) {
        return Mr(function(B, k) {
          var q = -1, $ = k.length, ue = $ > 1 ? k[$ - 1] : r, ve = $ > 2 ? k[2] : r;
          for (ue = D.length > 3 && typeof ue == "function" ? ($--, ue) : r, ve && lo(k[0], k[1], ve) && (ue = $ < 3 ? r : ue, $ = 1), B = Ln(B); ++q < $; ) {
            var we = k[q];
            we && D(B, we, q, ue);
          }
          return B;
        });
      }
      function UC(D, B) {
        return function(k, q) {
          if (k == null)
            return k;
          if (!To(k))
            return D(k, q);
          for (var $ = k.length, ue = B ? $ : -1, ve = Ln(k); (B ? ue-- : ++ue < $) && q(ve[ue], ue, ve) !== !1; )
            ;
          return k;
        };
      }
      function HC(D) {
        return function(B, k, q) {
          for (var $ = -1, ue = Ln(B), ve = q(B), we = ve.length; we--; ) {
            var Be = ve[D ? we : ++$];
            if (k(ue[Be], Be, ue) === !1)
              break;
          }
          return B;
        };
      }
      function MH(D, B, k) {
        var q = B & v, $ = Ih(D);
        function ue() {
          var ve = this && this !== Ma && this instanceof ue ? $ : D;
          return ve.apply(q ? k : this, arguments);
        }
        return ue;
      }
      function qC(D) {
        return function(B) {
          B = mn(B);
          var k = i1(B) ? du(B) : r, q = k ? k[0] : B.charAt(0), $ = k ? nd(k, 1).join("") : B.slice(1);
          return q[D]() + $;
        };
      }
      function f1(D) {
        return function(B) {
          return A5(UA(VA(B).replace(_V, "")), D, "");
        };
      }
      function Ih(D) {
        return function() {
          var B = arguments;
          switch (B.length) {
            case 0:
              return new D();
            case 1:
              return new D(B[0]);
            case 2:
              return new D(B[0], B[1]);
            case 3:
              return new D(B[0], B[1], B[2]);
            case 4:
              return new D(B[0], B[1], B[2], B[3]);
            case 5:
              return new D(B[0], B[1], B[2], B[3], B[4]);
            case 6:
              return new D(B[0], B[1], B[2], B[3], B[4], B[5]);
            case 7:
              return new D(B[0], B[1], B[2], B[3], B[4], B[5], B[6]);
          }
          var k = l1(D.prototype), q = D.apply(k, B);
          return ui(q) ? q : k;
        };
      }
      function PH(D, B, k) {
        var q = Ih(D);
        function $() {
          for (var ue = arguments.length, ve = Ye(ue), we = ue, Be = p1($); we--; )
            ve[we] = arguments[we];
          var rt = ue < 3 && ve[0] !== Be && ve[ue - 1] !== Be ? [] : Jl(ve, Be);
          if (ue -= rt.length, ue < k)
            return jC(
              D,
              B,
              gg,
              $.placeholder,
              r,
              ve,
              rt,
              r,
              r,
              k - ue
            );
          var it = this && this !== Ma && this instanceof $ ? q : D;
          return Qo(it, this, ve);
        }
        return $;
      }
      function KC(D) {
        return function(B, k, q) {
          var $ = Ln(B);
          if (!To(B)) {
            var ue = Wt(k, 3);
            B = ma(B), k = function(we) {
              return ue($[we], we, $);
            };
          }
          var ve = D(B, k, q);
          return ve > -1 ? $[ue ? B[ve] : ve] : r;
        };
      }
      function XC(D) {
        return Oc(function(B) {
          var k = B.length, q = k, $ = Es.prototype.thru;
          for (D && B.reverse(); q--; ) {
            var ue = B[q];
            if (typeof ue != "function")
              throw new Ds(o);
            if ($ && !ve && _g(ue) == "wrapper")
              var ve = new Es([], !0);
          }
          for (q = ve ? q : k; ++q < k; ) {
            ue = B[q];
            var we = _g(ue), Be = we == "wrapper" ? i6(ue) : r;
            Be && u6(Be[0]) && Be[1] == (C | b | _ | A) && !Be[4].length && Be[9] == 1 ? ve = ve[_g(Be[0])].apply(ve, Be[3]) : ve = ue.length == 1 && u6(ue) ? ve[we]() : ve.thru(ue);
          }
          return function() {
            var rt = arguments, it = rt[0];
            if (ve && rt.length == 1 && Cr(it))
              return ve.plant(it).value();
            for (var dt = 0, Ct = k ? B[dt].apply(this, rt) : it; ++dt < k; )
              Ct = B[dt].call(this, Ct);
            return Ct;
          };
        });
      }
      function gg(D, B, k, q, $, ue, ve, we, Be, rt) {
        var it = B & C, dt = B & v, Ct = B & g, Rt = B & (b | S), Jt = B & w, Tr = Ct ? r : Ih(D);
        function $t() {
          for (var Or = arguments.length, qr = Ye(Or), ts = Or; ts--; )
            qr[ts] = arguments[ts];
          if (Rt)
            var fo = p1($t), rs = HV(qr, fo);
          if (q && (qr = zC(qr, q, $, Rt)), ue && (qr = VC(qr, ue, ve, Rt)), Or -= rs, Rt && Or < rt) {
            var Fi = Jl(qr, fo);
            return jC(
              D,
              B,
              gg,
              $t.placeholder,
              k,
              qr,
              Fi,
              we,
              Be,
              rt - Or
            );
          }
          var hu = dt ? k : this, zc = Ct ? hu[D] : D;
          return Or = qr.length, we ? qr = QH(qr, we) : Jt && Or > 1 && qr.reverse(), it && Be < Or && (qr.length = Be), this && this !== Ma && this instanceof $t && (zc = Tr || Ih(zc)), zc.apply(hu, qr);
        }
        return $t;
      }
      function YC(D, B) {
        return function(k, q) {
          return aH(k, D, B(q), {});
        };
      }
      function vg(D, B) {
        return function(k, q) {
          var $;
          if (k === r && q === r)
            return B;
          if (k !== r && ($ = k), q !== r) {
            if ($ === r)
              return q;
            typeof k == "string" || typeof q == "string" ? (k = $o(k), q = $o(q)) : (k = BC(k), q = BC(q)), $ = D(k, q);
          }
          return $;
        };
      }
      function e6(D) {
        return Oc(function(B) {
          return B = $n(B, Jo(Wt())), Mr(function(k) {
            var q = this;
            return D(B, function($) {
              return Qo($, q, k);
            });
          });
        });
      }
      function yg(D, B) {
        B = B === r ? " " : $o(B);
        var k = B.length;
        if (k < 2)
          return k ? Y5(B, D) : B;
        var q = Y5(B, ig(D / a1(B)));
        return i1(B) ? nd(du(q), 0, D).join("") : q.slice(0, D);
      }
      function BH(D, B, k, q) {
        var $ = B & v, ue = Ih(D);
        function ve() {
          for (var we = -1, Be = arguments.length, rt = -1, it = q.length, dt = Ye(it + Be), Ct = this && this !== Ma && this instanceof ve ? ue : D; ++rt < it; )
            dt[rt] = q[rt];
          for (; Be--; )
            dt[rt++] = arguments[++we];
          return Qo(Ct, $ ? k : this, dt);
        }
        return ve;
      }
      function WC(D) {
        return function(B, k, q) {
          return q && typeof q != "number" && lo(B, k, q) && (k = q = r), B = Gc(B), k === r ? (k = B, B = 0) : k = Gc(k), q = q === r ? B < k ? 1 : -1 : Gc(q), vH(B, k, q, D);
        };
      }
      function bg(D) {
        return function(B, k) {
          return typeof B == "string" && typeof k == "string" || (B = Ps(B), k = Ps(k)), D(B, k);
        };
      }
      function jC(D, B, k, q, $, ue, ve, we, Be, rt) {
        var it = B & b, dt = it ? ve : r, Ct = it ? r : ve, Rt = it ? ue : r, Jt = it ? r : ue;
        B |= it ? _ : x, B &= ~(it ? x : _), B & y || (B &= ~(v | g));
        var Tr = [
          D,
          B,
          $,
          Rt,
          dt,
          Jt,
          Ct,
          we,
          Be,
          rt
        ], $t = k.apply(r, Tr);
        return u6(D) && sA($t, Tr), $t.placeholder = q, uA($t, D, B);
      }
      function t6(D) {
        var B = Ji[D];
        return function(k, q) {
          if (k = Ps(k), q = q == null ? 0 : qa(Er(q), 292), q && uC(k)) {
            var $ = (mn(k) + "e").split("e"), ue = B($[0] + "e" + (+$[1] + q));
            return $ = (mn(ue) + "e").split("e"), +($[0] + "e" + (+$[1] - q));
          }
          return B(k);
        };
      }
      var FH = u1 && 1 / W2(new u1([, -0]))[1] == L ? function(D) {
        return new u1(D);
      } : C6;
      function ZC(D) {
        return function(B) {
          var k = Ka(B);
          return k == Ce ? P5(B) : k == Re ? ZV(B) : UV(B, D(B));
        };
      }
      function Rc(D, B, k, q, $, ue, ve, we) {
        var Be = B & g;
        if (!Be && typeof D != "function")
          throw new Ds(o);
        var rt = q ? q.length : 0;
        if (rt || (B &= ~(_ | x), q = $ = r), ve = ve === r ? ve : $i(Er(ve), 0), we = we === r ? we : Er(we), rt -= $ ? $.length : 0, B & x) {
          var it = q, dt = $;
          q = $ = r;
        }
        var Ct = Be ? r : i6(D), Rt = [
          D,
          B,
          k,
          q,
          $,
          it,
          dt,
          ue,
          ve,
          we
        ];
        if (Ct && WH(Rt, Ct), D = Rt[0], B = Rt[1], k = Rt[2], q = Rt[3], $ = Rt[4], we = Rt[9] = Rt[9] === r ? Be ? 0 : D.length : $i(Rt[9] - rt, 0), !we && B & (b | S) && (B &= ~(b | S)), !B || B == v)
          var Jt = MH(D, B, k);
        else B == b || B == S ? Jt = PH(D, B, we) : (B == _ || B == (v | _)) && !$.length ? Jt = BH(D, B, k, q) : Jt = gg.apply(r, Rt);
        var Tr = Ct ? MC : sA;
        return uA(Tr(Jt, Rt), D, B);
      }
      function QC(D, B, k, q) {
        return D === r || pu(D, s1[k]) && !Sn.call(q, k) ? B : D;
      }
      function JC(D, B, k, q, $, ue) {
        return ui(D) && ui(B) && (ue.set(B, D), fg(D, B, r, JC, ue), ue.delete(B)), D;
      }
      function NH(D) {
        return Ph(D) ? r : D;
      }
      function $C(D, B, k, q, $, ue) {
        var ve = k & m, we = D.length, Be = B.length;
        if (we != Be && !(ve && Be > we))
          return !1;
        var rt = ue.get(D), it = ue.get(B);
        if (rt && it)
          return rt == B && it == D;
        var dt = -1, Ct = !0, Rt = k & p ? new Ef() : r;
        for (ue.set(D, B), ue.set(B, D); ++dt < we; ) {
          var Jt = D[dt], Tr = B[dt];
          if (q)
            var $t = ve ? q(Tr, Jt, dt, B, D, ue) : q(Jt, Tr, dt, D, B, ue);
          if ($t !== r) {
            if ($t)
              continue;
            Ct = !1;
            break;
          }
          if (Rt) {
            if (!w5(B, function(Or, qr) {
              if (!vh(Rt, qr) && (Jt === Or || $(Jt, Or, k, q, ue)))
                return Rt.push(qr);
            })) {
              Ct = !1;
              break;
            }
          } else if (!(Jt === Tr || $(Jt, Tr, k, q, ue))) {
            Ct = !1;
            break;
          }
        }
        return ue.delete(D), ue.delete(B), Ct;
      }
      function RH(D, B, k, q, $, ue, ve) {
        switch (k) {
          case me:
            if (D.byteLength != B.byteLength || D.byteOffset != B.byteOffset)
              return !1;
            D = D.buffer, B = B.buffer;
          case ge:
            return !(D.byteLength != B.byteLength || !ue(new eg(D), new eg(B)));
          case j:
          case ee:
          case De:
            return pu(+D, +B);
          case ae:
            return D.name == B.name && D.message == B.message;
          case Je:
          case nt:
            return D == B + "";
          case Ce:
            var we = P5;
          case Re:
            var Be = q & m;
            if (we || (we = W2), D.size != B.size && !Be)
              return !1;
            var rt = ve.get(D);
            if (rt)
              return rt == B;
            q |= p, ve.set(D, B);
            var it = $C(we(D), we(B), q, $, ue, ve);
            return ve.delete(D), it;
          case ne:
            if (Sh)
              return Sh.call(D) == Sh.call(B);
        }
        return !1;
      }
      function OH(D, B, k, q, $, ue) {
        var ve = k & m, we = r6(D), Be = we.length, rt = r6(B), it = rt.length;
        if (Be != it && !ve)
          return !1;
        for (var dt = Be; dt--; ) {
          var Ct = we[dt];
          if (!(ve ? Ct in B : Sn.call(B, Ct)))
            return !1;
        }
        var Rt = ue.get(D), Jt = ue.get(B);
        if (Rt && Jt)
          return Rt == B && Jt == D;
        var Tr = !0;
        ue.set(D, B), ue.set(B, D);
        for (var $t = ve; ++dt < Be; ) {
          Ct = we[dt];
          var Or = D[Ct], qr = B[Ct];
          if (q)
            var ts = ve ? q(qr, Or, Ct, B, D, ue) : q(Or, qr, Ct, D, B, ue);
          if (!(ts === r ? Or === qr || $(Or, qr, k, q, ue) : ts)) {
            Tr = !1;
            break;
          }
          $t || ($t = Ct == "constructor");
        }
        if (Tr && !$t) {
          var fo = D.constructor, rs = B.constructor;
          fo != rs && "constructor" in D && "constructor" in B && !(typeof fo == "function" && fo instanceof fo && typeof rs == "function" && rs instanceof rs) && (Tr = !1);
        }
        return ue.delete(D), ue.delete(B), Tr;
      }
      function Oc(D) {
        return l6(aA(D, r, hA), D + "");
      }
      function r6(D) {
        return bC(D, ma, o6);
      }
      function n6(D) {
        return bC(D, Mo, eA);
      }
      var i6 = og ? function(D) {
        return og.get(D);
      } : C6;
      function _g(D) {
        for (var B = D.name + "", k = c1[B], q = Sn.call(c1, B) ? k.length : 0; q--; ) {
          var $ = k[q], ue = $.func;
          if (ue == null || ue == D)
            return $.name;
        }
        return B;
      }
      function p1(D) {
        var B = Sn.call(oe, "placeholder") ? oe : D;
        return B.placeholder;
      }
      function Wt() {
        var D = oe.iteratee || x6;
        return D = D === x6 ? SC : D, arguments.length ? D(arguments[0], arguments[1]) : D;
      }
      function xg(D, B) {
        var k = D.__data__;
        return qH(B) ? k[typeof B == "string" ? "string" : "hash"] : k.map;
      }
      function a6(D) {
        for (var B = ma(D), k = B.length; k--; ) {
          var q = B[k], $ = D[q];
          B[k] = [q, $, nA($)];
        }
        return B;
      }
      function Mf(D, B) {
        var k = YV(D, B);
        return xC(k) ? k : r;
      }
      function LH(D) {
        var B = Sn.call(D, wf), k = D[wf];
        try {
          D[wf] = r;
          var q = !0;
        } catch {
        }
        var $ = J2.call(D);
        return q && (B ? D[wf] = k : delete D[wf]), $;
      }
      var o6 = F5 ? function(D) {
        return D == null ? [] : (D = Ln(D), Zl(F5(D), function(B) {
          return oC.call(D, B);
        }));
      } : A6, eA = F5 ? function(D) {
        for (var B = []; D; )
          Ql(B, o6(D)), D = tg(D);
        return B;
      } : A6, Ka = co;
      (N5 && Ka(new N5(new ArrayBuffer(1))) != me || bh && Ka(new bh()) != Ce || R5 && Ka(R5.resolve()) != We || u1 && Ka(new u1()) != Re || _h && Ka(new _h()) != le) && (Ka = function(D) {
        var B = co(D), k = B == He ? D.constructor : r, q = k ? Pf(k) : "";
        if (q)
          switch (q) {
            case bU:
              return me;
            case _U:
              return Ce;
            case xU:
              return We;
            case SU:
              return Re;
            case CU:
              return le;
          }
        return B;
      });
      function kH(D, B, k) {
        for (var q = -1, $ = k.length; ++q < $; ) {
          var ue = k[q], ve = ue.size;
          switch (ue.type) {
            case "drop":
              D += ve;
              break;
            case "dropRight":
              B -= ve;
              break;
            case "take":
              B = qa(B, D + ve);
              break;
            case "takeRight":
              D = $i(D, B - ve);
              break;
          }
        }
        return { start: D, end: B };
      }
      function GH(D) {
        var B = D.match(Wo);
        return B ? B[1].split(jo) : [];
      }
      function tA(D, B, k) {
        B = rd(B, D);
        for (var q = -1, $ = B.length, ue = !1; ++q < $; ) {
          var ve = Yu(B[q]);
          if (!(ue = D != null && k(D, ve)))
            break;
          D = D[ve];
        }
        return ue || ++q != $ ? ue : ($ = D == null ? 0 : D.length, !!$ && Ig($) && Lc(ve, $) && (Cr(D) || Bf(D)));
      }
      function zH(D) {
        var B = D.length, k = new D.constructor(B);
        return B && typeof D[0] == "string" && Sn.call(D, "index") && (k.index = D.index, k.input = D.input), k;
      }
      function rA(D) {
        return typeof D.constructor == "function" && !Th(D) ? l1(tg(D)) : {};
      }
      function VH(D, B, k) {
        var q = D.constructor;
        switch (B) {
          case ge:
            return $5(D);
          case j:
          case ee:
            return new q(+D);
          case me:
            return AH(D, k);
          case Ae:
          case Oe:
          case Ue:
          case Ve:
          case ht:
          case bt:
          case At:
          case Ee:
          case st:
            return kC(D, k);
          case Ce:
            return new q();
          case De:
          case nt:
            return new q(D);
          case Je:
            return wH(D);
          case Re:
            return new q();
          case ne:
            return DH(D);
        }
      }
      function UH(D, B) {
        var k = B.length;
        if (!k)
          return D;
        var q = k - 1;
        return B[q] = (k > 1 ? "& " : "") + B[q], B = B.join(k > 2 ? ", " : " "), D.replace(xn, `{
/* [wrapped with ` + B + `] */
`);
      }
      function HH(D) {
        return Cr(D) || Bf(D) || !!(sC && D && D[sC]);
      }
      function Lc(D, B) {
        var k = typeof D;
        return B = B ?? V, !!B && (k == "number" || k != "symbol" && Xl.test(D)) && D > -1 && D % 1 == 0 && D < B;
      }
      function lo(D, B, k) {
        if (!ui(k))
          return !1;
        var q = typeof B;
        return (q == "number" ? To(k) && Lc(B, k.length) : q == "string" && B in k) ? pu(k[B], D) : !1;
      }
      function s6(D, B) {
        if (Cr(D))
          return !1;
        var k = typeof D;
        return k == "number" || k == "symbol" || k == "boolean" || D == null || es(D) ? !0 : cn.test(D) || !yi.test(D) || B != null && D in Ln(B);
      }
      function qH(D) {
        var B = typeof D;
        return B == "string" || B == "number" || B == "symbol" || B == "boolean" ? D !== "__proto__" : D === null;
      }
      function u6(D) {
        var B = _g(D), k = oe[B];
        if (typeof k != "function" || !(B in zr.prototype))
          return !1;
        if (D === k)
          return !0;
        var q = i6(k);
        return !!q && D === q[0];
      }
      function KH(D) {
        return !!nC && nC in D;
      }
      var XH = Z2 ? kc : w6;
      function Th(D) {
        var B = D && D.constructor, k = typeof B == "function" && B.prototype || s1;
        return D === k;
      }
      function nA(D) {
        return D === D && !ui(D);
      }
      function iA(D, B) {
        return function(k) {
          return k == null ? !1 : k[D] === B && (B !== r || D in Ln(k));
        };
      }
      function YH(D) {
        var B = Dg(D, function(q) {
          return k.size === c && k.clear(), q;
        }), k = B.cache;
        return B;
      }
      function WH(D, B) {
        var k = D[1], q = B[1], $ = k | q, ue = $ < (v | g | C), ve = q == C && k == b || q == C && k == A && D[7].length <= B[8] || q == (C | A) && B[7].length <= B[8] && k == b;
        if (!(ue || ve))
          return D;
        q & v && (D[2] = B[2], $ |= k & v ? 0 : y);
        var we = B[3];
        if (we) {
          var Be = D[3];
          D[3] = Be ? zC(Be, we, B[4]) : we, D[4] = Be ? Jl(D[3], l) : B[4];
        }
        return we = B[5], we && (Be = D[5], D[5] = Be ? VC(Be, we, B[6]) : we, D[6] = Be ? Jl(D[5], l) : B[6]), we = B[7], we && (D[7] = we), q & C && (D[8] = D[8] == null ? B[8] : qa(D[8], B[8])), D[9] == null && (D[9] = B[9]), D[0] = B[0], D[1] = $, D;
      }
      function jH(D) {
        var B = [];
        if (D != null)
          for (var k in Ln(D))
            B.push(k);
        return B;
      }
      function ZH(D) {
        return J2.call(D);
      }
      function aA(D, B, k) {
        return B = $i(B === r ? D.length - 1 : B, 0), function() {
          for (var q = arguments, $ = -1, ue = $i(q.length - B, 0), ve = Ye(ue); ++$ < ue; )
            ve[$] = q[B + $];
          $ = -1;
          for (var we = Ye(B + 1); ++$ < B; )
            we[$] = q[$];
          return we[B] = k(ve), Qo(D, this, we);
        };
      }
      function oA(D, B) {
        return B.length < 2 ? D : Tf(D, Ts(B, 0, -1));
      }
      function QH(D, B) {
        for (var k = D.length, q = qa(B.length, k), $ = Io(D); q--; ) {
          var ue = B[q];
          D[q] = Lc(ue, k) ? $[ue] : r;
        }
        return D;
      }
      function c6(D, B) {
        if (!(B === "constructor" && typeof D[B] == "function") && B != "__proto__")
          return D[B];
      }
      var sA = cA(MC), Mh = fU || function(D, B) {
        return Ma.setTimeout(D, B);
      }, l6 = cA(_H);
      function uA(D, B, k) {
        var q = B + "";
        return l6(D, UH(q, JH(GH(q), k)));
      }
      function cA(D) {
        var B = 0, k = 0;
        return function() {
          var q = gU(), $ = T - (q - k);
          if (k = q, $ > 0) {
            if (++B >= M)
              return arguments[0];
          } else
            B = 0;
          return D.apply(r, arguments);
        };
      }
      function Sg(D, B) {
        var k = -1, q = D.length, $ = q - 1;
        for (B = B === r ? q : B; ++k < B; ) {
          var ue = X5(k, $), ve = D[ue];
          D[ue] = D[k], D[k] = ve;
        }
        return D.length = B, D;
      }
      var lA = YH(function(D) {
        var B = [];
        return D.charCodeAt(0) === 46 && B.push(""), D.replace(ln, function(k, q, $, ue) {
          B.push($ ? ue.replace(uo, "$1") : q || k);
        }), B;
      });
      function Yu(D) {
        if (typeof D == "string" || es(D))
          return D;
        var B = D + "";
        return B == "0" && 1 / D == -L ? "-0" : B;
      }
      function Pf(D) {
        if (D != null) {
          try {
            return Q2.call(D);
          } catch {
          }
          try {
            return D + "";
          } catch {
          }
        }
        return "";
      }
      function JH(D, B) {
        return ws(Q, function(k) {
          var q = "_." + k[0];
          B & k[1] && !X2(D, q) && D.push(q);
        }), D.sort();
      }
      function dA(D) {
        if (D instanceof zr)
          return D.clone();
        var B = new Es(D.__wrapped__, D.__chain__);
        return B.__actions__ = Io(D.__actions__), B.__index__ = D.__index__, B.__values__ = D.__values__, B;
      }
      function $H(D, B, k) {
        (k ? lo(D, B, k) : B === r) ? B = 1 : B = $i(Er(B), 0);
        var q = D == null ? 0 : D.length;
        if (!q || B < 1)
          return [];
        for (var $ = 0, ue = 0, ve = Ye(ig(q / B)); $ < q; )
          ve[ue++] = Ts(D, $, $ += B);
        return ve;
      }
      function eq(D) {
        for (var B = -1, k = D == null ? 0 : D.length, q = 0, $ = []; ++B < k; ) {
          var ue = D[B];
          ue && ($[q++] = ue);
        }
        return $;
      }
      function tq() {
        var D = arguments.length;
        if (!D)
          return [];
        for (var B = Ye(D - 1), k = arguments[0], q = D; q--; )
          B[q - 1] = arguments[q];
        return Ql(Cr(k) ? Io(k) : [k], Pa(B, 1));
      }
      var rq = Mr(function(D, B) {
        return Bi(D) ? Ah(D, Pa(B, 1, Bi, !0)) : [];
      }), nq = Mr(function(D, B) {
        var k = Ms(B);
        return Bi(k) && (k = r), Bi(D) ? Ah(D, Pa(B, 1, Bi, !0), Wt(k, 2)) : [];
      }), iq = Mr(function(D, B) {
        var k = Ms(B);
        return Bi(k) && (k = r), Bi(D) ? Ah(D, Pa(B, 1, Bi, !0), r, k) : [];
      });
      function aq(D, B, k) {
        var q = D == null ? 0 : D.length;
        return q ? (B = k || B === r ? 1 : Er(B), Ts(D, B < 0 ? 0 : B, q)) : [];
      }
      function oq(D, B, k) {
        var q = D == null ? 0 : D.length;
        return q ? (B = k || B === r ? 1 : Er(B), B = q - B, Ts(D, 0, B < 0 ? 0 : B)) : [];
      }
      function sq(D, B) {
        return D && D.length ? hg(D, Wt(B, 3), !0, !0) : [];
      }
      function uq(D, B) {
        return D && D.length ? hg(D, Wt(B, 3), !0) : [];
      }
      function cq(D, B, k, q) {
        var $ = D == null ? 0 : D.length;
        return $ ? (k && typeof k != "number" && lo(D, B, k) && (k = 0, q = $), tH(D, B, k, q)) : [];
      }
      function fA(D, B, k) {
        var q = D == null ? 0 : D.length;
        if (!q)
          return -1;
        var $ = k == null ? 0 : Er(k);
        return $ < 0 && ($ = $i(q + $, 0)), Y2(D, Wt(B, 3), $);
      }
      function pA(D, B, k) {
        var q = D == null ? 0 : D.length;
        if (!q)
          return -1;
        var $ = q - 1;
        return k !== r && ($ = Er(k), $ = k < 0 ? $i(q + $, 0) : qa($, q - 1)), Y2(D, Wt(B, 3), $, !0);
      }
      function hA(D) {
        var B = D == null ? 0 : D.length;
        return B ? Pa(D, 1) : [];
      }
      function lq(D) {
        var B = D == null ? 0 : D.length;
        return B ? Pa(D, L) : [];
      }
      function dq(D, B) {
        var k = D == null ? 0 : D.length;
        return k ? (B = B === r ? 1 : Er(B), Pa(D, B)) : [];
      }
      function fq(D) {
        for (var B = -1, k = D == null ? 0 : D.length, q = {}; ++B < k; ) {
          var $ = D[B];
          q[$[0]] = $[1];
        }
        return q;
      }
      function mA(D) {
        return D && D.length ? D[0] : r;
      }
      function pq(D, B, k) {
        var q = D == null ? 0 : D.length;
        if (!q)
          return -1;
        var $ = k == null ? 0 : Er(k);
        return $ < 0 && ($ = $i(q + $, 0)), n1(D, B, $);
      }
      function hq(D) {
        var B = D == null ? 0 : D.length;
        return B ? Ts(D, 0, -1) : [];
      }
      var mq = Mr(function(D) {
        var B = $n(D, Q5);
        return B.length && B[0] === D[0] ? V5(B) : [];
      }), gq = Mr(function(D) {
        var B = Ms(D), k = $n(D, Q5);
        return B === Ms(k) ? B = r : k.pop(), k.length && k[0] === D[0] ? V5(k, Wt(B, 2)) : [];
      }), vq = Mr(function(D) {
        var B = Ms(D), k = $n(D, Q5);
        return B = typeof B == "function" ? B : r, B && k.pop(), k.length && k[0] === D[0] ? V5(k, r, B) : [];
      });
      function yq(D, B) {
        return D == null ? "" : hU.call(D, B);
      }
      function Ms(D) {
        var B = D == null ? 0 : D.length;
        return B ? D[B - 1] : r;
      }
      function bq(D, B, k) {
        var q = D == null ? 0 : D.length;
        if (!q)
          return -1;
        var $ = q;
        return k !== r && ($ = Er(k), $ = $ < 0 ? $i(q + $, 0) : qa($, q - 1)), B === B ? JV(D, B, $) : Y2(D, jS, $, !0);
      }
      function _q(D, B) {
        return D && D.length ? DC(D, Er(B)) : r;
      }
      var xq = Mr(gA);
      function gA(D, B) {
        return D && D.length && B && B.length ? K5(D, B) : D;
      }
      function Sq(D, B, k) {
        return D && D.length && B && B.length ? K5(D, B, Wt(k, 2)) : D;
      }
      function Cq(D, B, k) {
        return D && D.length && B && B.length ? K5(D, B, r, k) : D;
      }
      var Aq = Oc(function(D, B) {
        var k = D == null ? 0 : D.length, q = L5(D, B);
        return TC(D, $n(B, function($) {
          return Lc($, k) ? +$ : $;
        }).sort(GC)), q;
      });
      function wq(D, B) {
        var k = [];
        if (!(D && D.length))
          return k;
        var q = -1, $ = [], ue = D.length;
        for (B = Wt(B, 3); ++q < ue; ) {
          var ve = D[q];
          B(ve, q, D) && (k.push(ve), $.push(q));
        }
        return TC(D, $), k;
      }
      function d6(D) {
        return D == null ? D : yU.call(D);
      }
      function Dq(D, B, k) {
        var q = D == null ? 0 : D.length;
        return q ? (k && typeof k != "number" && lo(D, B, k) ? (B = 0, k = q) : (B = B == null ? 0 : Er(B), k = k === r ? q : Er(k)), Ts(D, B, k)) : [];
      }
      function Eq(D, B) {
        return pg(D, B);
      }
      function Iq(D, B, k) {
        return W5(D, B, Wt(k, 2));
      }
      function Tq(D, B) {
        var k = D == null ? 0 : D.length;
        if (k) {
          var q = pg(D, B);
          if (q < k && pu(D[q], B))
            return q;
        }
        return -1;
      }
      function Mq(D, B) {
        return pg(D, B, !0);
      }
      function Pq(D, B, k) {
        return W5(D, B, Wt(k, 2), !0);
      }
      function Bq(D, B) {
        var k = D == null ? 0 : D.length;
        if (k) {
          var q = pg(D, B, !0) - 1;
          if (pu(D[q], B))
            return q;
        }
        return -1;
      }
      function Fq(D) {
        return D && D.length ? PC(D) : [];
      }
      function Nq(D, B) {
        return D && D.length ? PC(D, Wt(B, 2)) : [];
      }
      function Rq(D) {
        var B = D == null ? 0 : D.length;
        return B ? Ts(D, 1, B) : [];
      }
      function Oq(D, B, k) {
        return D && D.length ? (B = k || B === r ? 1 : Er(B), Ts(D, 0, B < 0 ? 0 : B)) : [];
      }
      function Lq(D, B, k) {
        var q = D == null ? 0 : D.length;
        return q ? (B = k || B === r ? 1 : Er(B), B = q - B, Ts(D, B < 0 ? 0 : B, q)) : [];
      }
      function kq(D, B) {
        return D && D.length ? hg(D, Wt(B, 3), !1, !0) : [];
      }
      function Gq(D, B) {
        return D && D.length ? hg(D, Wt(B, 3)) : [];
      }
      var zq = Mr(function(D) {
        return td(Pa(D, 1, Bi, !0));
      }), Vq = Mr(function(D) {
        var B = Ms(D);
        return Bi(B) && (B = r), td(Pa(D, 1, Bi, !0), Wt(B, 2));
      }), Uq = Mr(function(D) {
        var B = Ms(D);
        return B = typeof B == "function" ? B : r, td(Pa(D, 1, Bi, !0), r, B);
      });
      function Hq(D) {
        return D && D.length ? td(D) : [];
      }
      function qq(D, B) {
        return D && D.length ? td(D, Wt(B, 2)) : [];
      }
      function Kq(D, B) {
        return B = typeof B == "function" ? B : r, D && D.length ? td(D, r, B) : [];
      }
      function f6(D) {
        if (!(D && D.length))
          return [];
        var B = 0;
        return D = Zl(D, function(k) {
          if (Bi(k))
            return B = $i(k.length, B), !0;
        }), T5(B, function(k) {
          return $n(D, D5(k));
        });
      }
      function vA(D, B) {
        if (!(D && D.length))
          return [];
        var k = f6(D);
        return B == null ? k : $n(k, function(q) {
          return Qo(B, r, q);
        });
      }
      var Xq = Mr(function(D, B) {
        return Bi(D) ? Ah(D, B) : [];
      }), Yq = Mr(function(D) {
        return Z5(Zl(D, Bi));
      }), Wq = Mr(function(D) {
        var B = Ms(D);
        return Bi(B) && (B = r), Z5(Zl(D, Bi), Wt(B, 2));
      }), jq = Mr(function(D) {
        var B = Ms(D);
        return B = typeof B == "function" ? B : r, Z5(Zl(D, Bi), r, B);
      }), Zq = Mr(f6);
      function Qq(D, B) {
        return RC(D || [], B || [], Ch);
      }
      function Jq(D, B) {
        return RC(D || [], B || [], Eh);
      }
      var $q = Mr(function(D) {
        var B = D.length, k = B > 1 ? D[B - 1] : r;
        return k = typeof k == "function" ? (D.pop(), k) : r, vA(D, k);
      });
      function yA(D) {
        var B = oe(D);
        return B.__chain__ = !0, B;
      }
      function eK(D, B) {
        return B(D), D;
      }
      function Cg(D, B) {
        return B(D);
      }
      var tK = Oc(function(D) {
        var B = D.length, k = B ? D[0] : 0, q = this.__wrapped__, $ = function(ue) {
          return L5(ue, D);
        };
        return B > 1 || this.__actions__.length || !(q instanceof zr) || !Lc(k) ? this.thru($) : (q = q.slice(k, +k + (B ? 1 : 0)), q.__actions__.push({
          func: Cg,
          args: [$],
          thisArg: r
        }), new Es(q, this.__chain__).thru(function(ue) {
          return B && !ue.length && ue.push(r), ue;
        }));
      });
      function rK() {
        return yA(this);
      }
      function nK() {
        return new Es(this.value(), this.__chain__);
      }
      function iK() {
        this.__values__ === r && (this.__values__ = BA(this.value()));
        var D = this.__index__ >= this.__values__.length, B = D ? r : this.__values__[this.__index__++];
        return { done: D, value: B };
      }
      function aK() {
        return this;
      }
      function oK(D) {
        for (var B, k = this; k instanceof ug; ) {
          var q = dA(k);
          q.__index__ = 0, q.__values__ = r, B ? $.__wrapped__ = q : B = q;
          var $ = q;
          k = k.__wrapped__;
        }
        return $.__wrapped__ = D, B;
      }
      function sK() {
        var D = this.__wrapped__;
        if (D instanceof zr) {
          var B = D;
          return this.__actions__.length && (B = new zr(this)), B = B.reverse(), B.__actions__.push({
            func: Cg,
            args: [d6],
            thisArg: r
          }), new Es(B, this.__chain__);
        }
        return this.thru(d6);
      }
      function uK() {
        return NC(this.__wrapped__, this.__actions__);
      }
      var cK = mg(function(D, B, k) {
        Sn.call(D, k) ? ++D[k] : Nc(D, k, 1);
      });
      function lK(D, B, k) {
        var q = Cr(D) ? YS : eH;
        return k && lo(D, B, k) && (B = r), q(D, Wt(B, 3));
      }
      function dK(D, B) {
        var k = Cr(D) ? Zl : vC;
        return k(D, Wt(B, 3));
      }
      var fK = KC(fA), pK = KC(pA);
      function hK(D, B) {
        return Pa(Ag(D, B), 1);
      }
      function mK(D, B) {
        return Pa(Ag(D, B), L);
      }
      function gK(D, B, k) {
        return k = k === r ? 1 : Er(k), Pa(Ag(D, B), k);
      }
      function bA(D, B) {
        var k = Cr(D) ? ws : ed;
        return k(D, Wt(B, 3));
      }
      function _A(D, B) {
        var k = Cr(D) ? RV : gC;
        return k(D, Wt(B, 3));
      }
      var vK = mg(function(D, B, k) {
        Sn.call(D, k) ? D[k].push(B) : Nc(D, k, [B]);
      });
      function yK(D, B, k, q) {
        D = To(D) ? D : m1(D), k = k && !q ? Er(k) : 0;
        var $ = D.length;
        return k < 0 && (k = $i($ + k, 0)), Tg(D) ? k <= $ && D.indexOf(B, k) > -1 : !!$ && n1(D, B, k) > -1;
      }
      var bK = Mr(function(D, B, k) {
        var q = -1, $ = typeof B == "function", ue = To(D) ? Ye(D.length) : [];
        return ed(D, function(ve) {
          ue[++q] = $ ? Qo(B, ve, k) : wh(ve, B, k);
        }), ue;
      }), _K = mg(function(D, B, k) {
        Nc(D, k, B);
      });
      function Ag(D, B) {
        var k = Cr(D) ? $n : CC;
        return k(D, Wt(B, 3));
      }
      function xK(D, B, k, q) {
        return D == null ? [] : (Cr(B) || (B = B == null ? [] : [B]), k = q ? r : k, Cr(k) || (k = k == null ? [] : [k]), EC(D, B, k));
      }
      var SK = mg(function(D, B, k) {
        D[k ? 0 : 1].push(B);
      }, function() {
        return [[], []];
      });
      function CK(D, B, k) {
        var q = Cr(D) ? A5 : QS, $ = arguments.length < 3;
        return q(D, Wt(B, 4), k, $, ed);
      }
      function AK(D, B, k) {
        var q = Cr(D) ? OV : QS, $ = arguments.length < 3;
        return q(D, Wt(B, 4), k, $, gC);
      }
      function wK(D, B) {
        var k = Cr(D) ? Zl : vC;
        return k(D, Eg(Wt(B, 3)));
      }
      function DK(D) {
        var B = Cr(D) ? fC : yH;
        return B(D);
      }
      function EK(D, B, k) {
        (k ? lo(D, B, k) : B === r) ? B = 1 : B = Er(B);
        var q = Cr(D) ? jU : bH;
        return q(D, B);
      }
      function IK(D) {
        var B = Cr(D) ? ZU : xH;
        return B(D);
      }
      function TK(D) {
        if (D == null)
          return 0;
        if (To(D))
          return Tg(D) ? a1(D) : D.length;
        var B = Ka(D);
        return B == Ce || B == Re ? D.size : H5(D).length;
      }
      function MK(D, B, k) {
        var q = Cr(D) ? w5 : SH;
        return k && lo(D, B, k) && (B = r), q(D, Wt(B, 3));
      }
      var PK = Mr(function(D, B) {
        if (D == null)
          return [];
        var k = B.length;
        return k > 1 && lo(D, B[0], B[1]) ? B = [] : k > 2 && lo(B[0], B[1], B[2]) && (B = [B[0]]), EC(D, Pa(B, 1), []);
      }), wg = dU || function() {
        return Ma.Date.now();
      };
      function BK(D, B) {
        if (typeof B != "function")
          throw new Ds(o);
        return D = Er(D), function() {
          if (--D < 1)
            return B.apply(this, arguments);
        };
      }
      function xA(D, B, k) {
        return B = k ? r : B, B = D && B == null ? D.length : B, Rc(D, C, r, r, r, r, B);
      }
      function SA(D, B) {
        var k;
        if (typeof B != "function")
          throw new Ds(o);
        return D = Er(D), function() {
          return --D > 0 && (k = B.apply(this, arguments)), D <= 1 && (B = r), k;
        };
      }
      var p6 = Mr(function(D, B, k) {
        var q = v;
        if (k.length) {
          var $ = Jl(k, p1(p6));
          q |= _;
        }
        return Rc(D, q, B, k, $);
      }), CA = Mr(function(D, B, k) {
        var q = v | g;
        if (k.length) {
          var $ = Jl(k, p1(CA));
          q |= _;
        }
        return Rc(B, q, D, k, $);
      });
      function AA(D, B, k) {
        B = k ? r : B;
        var q = Rc(D, b, r, r, r, r, r, B);
        return q.placeholder = AA.placeholder, q;
      }
      function wA(D, B, k) {
        B = k ? r : B;
        var q = Rc(D, S, r, r, r, r, r, B);
        return q.placeholder = wA.placeholder, q;
      }
      function DA(D, B, k) {
        var q, $, ue, ve, we, Be, rt = 0, it = !1, dt = !1, Ct = !0;
        if (typeof D != "function")
          throw new Ds(o);
        B = Ps(B) || 0, ui(k) && (it = !!k.leading, dt = "maxWait" in k, ue = dt ? $i(Ps(k.maxWait) || 0, B) : ue, Ct = "trailing" in k ? !!k.trailing : Ct);
        function Rt(Fi) {
          var hu = q, zc = $;
          return q = $ = r, rt = Fi, ve = D.apply(zc, hu), ve;
        }
        function Jt(Fi) {
          return rt = Fi, we = Mh(Or, B), it ? Rt(Fi) : ve;
        }
        function Tr(Fi) {
          var hu = Fi - Be, zc = Fi - rt, KA = B - hu;
          return dt ? qa(KA, ue - zc) : KA;
        }
        function $t(Fi) {
          var hu = Fi - Be, zc = Fi - rt;
          return Be === r || hu >= B || hu < 0 || dt && zc >= ue;
        }
        function Or() {
          var Fi = wg();
          if ($t(Fi))
            return qr(Fi);
          we = Mh(Or, Tr(Fi));
        }
        function qr(Fi) {
          return we = r, Ct && q ? Rt(Fi) : (q = $ = r, ve);
        }
        function ts() {
          we !== r && OC(we), rt = 0, q = Be = $ = we = r;
        }
        function fo() {
          return we === r ? ve : qr(wg());
        }
        function rs() {
          var Fi = wg(), hu = $t(Fi);
          if (q = arguments, $ = this, Be = Fi, hu) {
            if (we === r)
              return Jt(Be);
            if (dt)
              return OC(we), we = Mh(Or, B), Rt(Be);
          }
          return we === r && (we = Mh(Or, B)), ve;
        }
        return rs.cancel = ts, rs.flush = fo, rs;
      }
      var FK = Mr(function(D, B) {
        return mC(D, 1, B);
      }), NK = Mr(function(D, B, k) {
        return mC(D, Ps(B) || 0, k);
      });
      function RK(D) {
        return Rc(D, w);
      }
      function Dg(D, B) {
        if (typeof D != "function" || B != null && typeof B != "function")
          throw new Ds(o);
        var k = function() {
          var q = arguments, $ = B ? B.apply(this, q) : q[0], ue = k.cache;
          if (ue.has($))
            return ue.get($);
          var ve = D.apply(this, q);
          return k.cache = ue.set($, ve) || ue, ve;
        };
        return k.cache = new (Dg.Cache || Fc)(), k;
      }
      Dg.Cache = Fc;
      function Eg(D) {
        if (typeof D != "function")
          throw new Ds(o);
        return function() {
          var B = arguments;
          switch (B.length) {
            case 0:
              return !D.call(this);
            case 1:
              return !D.call(this, B[0]);
            case 2:
              return !D.call(this, B[0], B[1]);
            case 3:
              return !D.call(this, B[0], B[1], B[2]);
          }
          return !D.apply(this, B);
        };
      }
      function OK(D) {
        return SA(2, D);
      }
      var LK = CH(function(D, B) {
        B = B.length == 1 && Cr(B[0]) ? $n(B[0], Jo(Wt())) : $n(Pa(B, 1), Jo(Wt()));
        var k = B.length;
        return Mr(function(q) {
          for (var $ = -1, ue = qa(q.length, k); ++$ < ue; )
            q[$] = B[$].call(this, q[$]);
          return Qo(D, this, q);
        });
      }), h6 = Mr(function(D, B) {
        var k = Jl(B, p1(h6));
        return Rc(D, _, r, B, k);
      }), EA = Mr(function(D, B) {
        var k = Jl(B, p1(EA));
        return Rc(D, x, r, B, k);
      }), kK = Oc(function(D, B) {
        return Rc(D, A, r, r, r, B);
      });
      function GK(D, B) {
        if (typeof D != "function")
          throw new Ds(o);
        return B = B === r ? B : Er(B), Mr(D, B);
      }
      function zK(D, B) {
        if (typeof D != "function")
          throw new Ds(o);
        return B = B == null ? 0 : $i(Er(B), 0), Mr(function(k) {
          var q = k[B], $ = nd(k, 0, B);
          return q && Ql($, q), Qo(D, this, $);
        });
      }
      function VK(D, B, k) {
        var q = !0, $ = !0;
        if (typeof D != "function")
          throw new Ds(o);
        return ui(k) && (q = "leading" in k ? !!k.leading : q, $ = "trailing" in k ? !!k.trailing : $), DA(D, B, {
          leading: q,
          maxWait: B,
          trailing: $
        });
      }
      function UK(D) {
        return xA(D, 1);
      }
      function HK(D, B) {
        return h6(J5(B), D);
      }
      function qK() {
        if (!arguments.length)
          return [];
        var D = arguments[0];
        return Cr(D) ? D : [D];
      }
      function KK(D) {
        return Is(D, h);
      }
      function XK(D, B) {
        return B = typeof B == "function" ? B : r, Is(D, h, B);
      }
      function YK(D) {
        return Is(D, d | h);
      }
      function WK(D, B) {
        return B = typeof B == "function" ? B : r, Is(D, d | h, B);
      }
      function jK(D, B) {
        return B == null || hC(D, B, ma(B));
      }
      function pu(D, B) {
        return D === B || D !== D && B !== B;
      }
      var ZK = bg(z5), QK = bg(function(D, B) {
        return D >= B;
      }), Bf = _C(/* @__PURE__ */ function() {
        return arguments;
      }()) ? _C : function(D) {
        return bi(D) && Sn.call(D, "callee") && !oC.call(D, "callee");
      }, Cr = Ye.isArray, JK = VS ? Jo(VS) : oH;
      function To(D) {
        return D != null && Ig(D.length) && !kc(D);
      }
      function Bi(D) {
        return bi(D) && To(D);
      }
      function $K(D) {
        return D === !0 || D === !1 || bi(D) && co(D) == j;
      }
      var id = pU || w6, eX = US ? Jo(US) : sH;
      function tX(D) {
        return bi(D) && D.nodeType === 1 && !Ph(D);
      }
      function rX(D) {
        if (D == null)
          return !0;
        if (To(D) && (Cr(D) || typeof D == "string" || typeof D.splice == "function" || id(D) || h1(D) || Bf(D)))
          return !D.length;
        var B = Ka(D);
        if (B == Ce || B == Re)
          return !D.size;
        if (Th(D))
          return !H5(D).length;
        for (var k in D)
          if (Sn.call(D, k))
            return !1;
        return !0;
      }
      function nX(D, B) {
        return Dh(D, B);
      }
      function iX(D, B, k) {
        k = typeof k == "function" ? k : r;
        var q = k ? k(D, B) : r;
        return q === r ? Dh(D, B, r, k) : !!q;
      }
      function m6(D) {
        if (!bi(D))
          return !1;
        var B = co(D);
        return B == ae || B == ie || typeof D.message == "string" && typeof D.name == "string" && !Ph(D);
      }
      function aX(D) {
        return typeof D == "number" && uC(D);
      }
      function kc(D) {
        if (!ui(D))
          return !1;
        var B = co(D);
        return B == ce || B == de || B == W || B == Ne;
      }
      function IA(D) {
        return typeof D == "number" && D == Er(D);
      }
      function Ig(D) {
        return typeof D == "number" && D > -1 && D % 1 == 0 && D <= V;
      }
      function ui(D) {
        var B = typeof D;
        return D != null && (B == "object" || B == "function");
      }
      function bi(D) {
        return D != null && typeof D == "object";
      }
      var TA = HS ? Jo(HS) : cH;
      function oX(D, B) {
        return D === B || U5(D, B, a6(B));
      }
      function sX(D, B, k) {
        return k = typeof k == "function" ? k : r, U5(D, B, a6(B), k);
      }
      function uX(D) {
        return MA(D) && D != +D;
      }
      function cX(D) {
        if (XH(D))
          throw new vr(a);
        return xC(D);
      }
      function lX(D) {
        return D === null;
      }
      function dX(D) {
        return D == null;
      }
      function MA(D) {
        return typeof D == "number" || bi(D) && co(D) == De;
      }
      function Ph(D) {
        if (!bi(D) || co(D) != He)
          return !1;
        var B = tg(D);
        if (B === null)
          return !0;
        var k = Sn.call(B, "constructor") && B.constructor;
        return typeof k == "function" && k instanceof k && Q2.call(k) == sU;
      }
      var g6 = qS ? Jo(qS) : lH;
      function fX(D) {
        return IA(D) && D >= -V && D <= V;
      }
      var PA = KS ? Jo(KS) : dH;
      function Tg(D) {
        return typeof D == "string" || !Cr(D) && bi(D) && co(D) == nt;
      }
      function es(D) {
        return typeof D == "symbol" || bi(D) && co(D) == ne;
      }
      var h1 = XS ? Jo(XS) : fH;
      function pX(D) {
        return D === r;
      }
      function hX(D) {
        return bi(D) && Ka(D) == le;
      }
      function mX(D) {
        return bi(D) && co(D) == fe;
      }
      var gX = bg(q5), vX = bg(function(D, B) {
        return D <= B;
      });
      function BA(D) {
        if (!D)
          return [];
        if (To(D))
          return Tg(D) ? du(D) : Io(D);
        if (yh && D[yh])
          return jV(D[yh]());
        var B = Ka(D), k = B == Ce ? P5 : B == Re ? W2 : m1;
        return k(D);
      }
      function Gc(D) {
        if (!D)
          return D === 0 ? D : 0;
        if (D = Ps(D), D === L || D === -L) {
          var B = D < 0 ? -1 : 1;
          return B * U;
        }
        return D === D ? D : 0;
      }
      function Er(D) {
        var B = Gc(D), k = B % 1;
        return B === B ? k ? B - k : B : 0;
      }
      function FA(D) {
        return D ? If(Er(D), 0, K) : 0;
      }
      function Ps(D) {
        if (typeof D == "number")
          return D;
        if (es(D))
          return H;
        if (ui(D)) {
          var B = typeof D.valueOf == "function" ? D.valueOf() : D;
          D = ui(B) ? B + "" : B;
        }
        if (typeof D != "string")
          return D === 0 ? D : +D;
        D = JS(D);
        var k = Hl.test(D);
        return k || Kl.test(D) ? BV(D.slice(2), k ? 2 : 8) : Ul.test(D) ? H : +D;
      }
      function NA(D) {
        return Xu(D, Mo(D));
      }
      function yX(D) {
        return D ? If(Er(D), -V, V) : D === 0 ? D : 0;
      }
      function mn(D) {
        return D == null ? "" : $o(D);
      }
      var bX = d1(function(D, B) {
        if (Th(B) || To(B)) {
          Xu(B, ma(B), D);
          return;
        }
        for (var k in B)
          Sn.call(B, k) && Ch(D, k, B[k]);
      }), RA = d1(function(D, B) {
        Xu(B, Mo(B), D);
      }), Mg = d1(function(D, B, k, q) {
        Xu(B, Mo(B), D, q);
      }), _X = d1(function(D, B, k, q) {
        Xu(B, ma(B), D, q);
      }), xX = Oc(L5);
      function SX(D, B) {
        var k = l1(D);
        return B == null ? k : pC(k, B);
      }
      var CX = Mr(function(D, B) {
        D = Ln(D);
        var k = -1, q = B.length, $ = q > 2 ? B[2] : r;
        for ($ && lo(B[0], B[1], $) && (q = 1); ++k < q; )
          for (var ue = B[k], ve = Mo(ue), we = -1, Be = ve.length; ++we < Be; ) {
            var rt = ve[we], it = D[rt];
            (it === r || pu(it, s1[rt]) && !Sn.call(D, rt)) && (D[rt] = ue[rt]);
          }
        return D;
      }), AX = Mr(function(D) {
        return D.push(r, JC), Qo(OA, r, D);
      });
      function wX(D, B) {
        return WS(D, Wt(B, 3), Ku);
      }
      function DX(D, B) {
        return WS(D, Wt(B, 3), G5);
      }
      function EX(D, B) {
        return D == null ? D : k5(D, Wt(B, 3), Mo);
      }
      function IX(D, B) {
        return D == null ? D : yC(D, Wt(B, 3), Mo);
      }
      function TX(D, B) {
        return D && Ku(D, Wt(B, 3));
      }
      function MX(D, B) {
        return D && G5(D, Wt(B, 3));
      }
      function PX(D) {
        return D == null ? [] : dg(D, ma(D));
      }
      function BX(D) {
        return D == null ? [] : dg(D, Mo(D));
      }
      function v6(D, B, k) {
        var q = D == null ? r : Tf(D, B);
        return q === r ? k : q;
      }
      function FX(D, B) {
        return D != null && tA(D, B, rH);
      }
      function y6(D, B) {
        return D != null && tA(D, B, nH);
      }
      var NX = YC(function(D, B, k) {
        B != null && typeof B.toString != "function" && (B = J2.call(B)), D[B] = k;
      }, _6(Po)), RX = YC(function(D, B, k) {
        B != null && typeof B.toString != "function" && (B = J2.call(B)), Sn.call(D, B) ? D[B].push(k) : D[B] = [k];
      }, Wt), OX = Mr(wh);
      function ma(D) {
        return To(D) ? dC(D) : H5(D);
      }
      function Mo(D) {
        return To(D) ? dC(D, !0) : pH(D);
      }
      function LX(D, B) {
        var k = {};
        return B = Wt(B, 3), Ku(D, function(q, $, ue) {
          Nc(k, B(q, $, ue), q);
        }), k;
      }
      function kX(D, B) {
        var k = {};
        return B = Wt(B, 3), Ku(D, function(q, $, ue) {
          Nc(k, $, B(q, $, ue));
        }), k;
      }
      var GX = d1(function(D, B, k) {
        fg(D, B, k);
      }), OA = d1(function(D, B, k, q) {
        fg(D, B, k, q);
      }), zX = Oc(function(D, B) {
        var k = {};
        if (D == null)
          return k;
        var q = !1;
        B = $n(B, function(ue) {
          return ue = rd(ue, D), q || (q = ue.length > 1), ue;
        }), Xu(D, n6(D), k), q && (k = Is(k, d | f | h, NH));
        for (var $ = B.length; $--; )
          j5(k, B[$]);
        return k;
      });
      function VX(D, B) {
        return LA(D, Eg(Wt(B)));
      }
      var UX = Oc(function(D, B) {
        return D == null ? {} : mH(D, B);
      });
      function LA(D, B) {
        if (D == null)
          return {};
        var k = $n(n6(D), function(q) {
          return [q];
        });
        return B = Wt(B), IC(D, k, function(q, $) {
          return B(q, $[0]);
        });
      }
      function HX(D, B, k) {
        B = rd(B, D);
        var q = -1, $ = B.length;
        for ($ || ($ = 1, D = r); ++q < $; ) {
          var ue = D == null ? r : D[Yu(B[q])];
          ue === r && (q = $, ue = k), D = kc(ue) ? ue.call(D) : ue;
        }
        return D;
      }
      function qX(D, B, k) {
        return D == null ? D : Eh(D, B, k);
      }
      function KX(D, B, k, q) {
        return q = typeof q == "function" ? q : r, D == null ? D : Eh(D, B, k, q);
      }
      var kA = ZC(ma), GA = ZC(Mo);
      function XX(D, B, k) {
        var q = Cr(D), $ = q || id(D) || h1(D);
        if (B = Wt(B, 4), k == null) {
          var ue = D && D.constructor;
          $ ? k = q ? new ue() : [] : ui(D) ? k = kc(ue) ? l1(tg(D)) : {} : k = {};
        }
        return ($ ? ws : Ku)(D, function(ve, we, Be) {
          return B(k, ve, we, Be);
        }), k;
      }
      function YX(D, B) {
        return D == null ? !0 : j5(D, B);
      }
      function WX(D, B, k) {
        return D == null ? D : FC(D, B, J5(k));
      }
      function jX(D, B, k, q) {
        return q = typeof q == "function" ? q : r, D == null ? D : FC(D, B, J5(k), q);
      }
      function m1(D) {
        return D == null ? [] : M5(D, ma(D));
      }
      function ZX(D) {
        return D == null ? [] : M5(D, Mo(D));
      }
      function QX(D, B, k) {
        return k === r && (k = B, B = r), k !== r && (k = Ps(k), k = k === k ? k : 0), B !== r && (B = Ps(B), B = B === B ? B : 0), If(Ps(D), B, k);
      }
      function JX(D, B, k) {
        return B = Gc(B), k === r ? (k = B, B = 0) : k = Gc(k), D = Ps(D), iH(D, B, k);
      }
      function $X(D, B, k) {
        if (k && typeof k != "boolean" && lo(D, B, k) && (B = k = r), k === r && (typeof B == "boolean" ? (k = B, B = r) : typeof D == "boolean" && (k = D, D = r)), D === r && B === r ? (D = 0, B = 1) : (D = Gc(D), B === r ? (B = D, D = 0) : B = Gc(B)), D > B) {
          var q = D;
          D = B, B = q;
        }
        if (k || D % 1 || B % 1) {
          var $ = cC();
          return qa(D + $ * (B - D + PV("1e-" + (($ + "").length - 1))), B);
        }
        return X5(D, B);
      }
      var eY = f1(function(D, B, k) {
        return B = B.toLowerCase(), D + (k ? zA(B) : B);
      });
      function zA(D) {
        return b6(mn(D).toLowerCase());
      }
      function VA(D) {
        return D = mn(D), D && D.replace($0, qV).replace(xV, "");
      }
      function tY(D, B, k) {
        D = mn(D), B = $o(B);
        var q = D.length;
        k = k === r ? q : If(Er(k), 0, q);
        var $ = k;
        return k -= B.length, k >= 0 && D.slice(k, $) == B;
      }
      function rY(D) {
        return D = mn(D), D && Jn.test(D) ? D.replace(pr, KV) : D;
      }
      function nY(D) {
        return D = mn(D), D && Mi.test(D) ? D.replace(Ti, "\\$&") : D;
      }
      var iY = f1(function(D, B, k) {
        return D + (k ? "-" : "") + B.toLowerCase();
      }), aY = f1(function(D, B, k) {
        return D + (k ? " " : "") + B.toLowerCase();
      }), oY = qC("toLowerCase");
      function sY(D, B, k) {
        D = mn(D), B = Er(B);
        var q = B ? a1(D) : 0;
        if (!B || q >= B)
          return D;
        var $ = (B - q) / 2;
        return yg(ag($), k) + D + yg(ig($), k);
      }
      function uY(D, B, k) {
        D = mn(D), B = Er(B);
        var q = B ? a1(D) : 0;
        return B && q < B ? D + yg(B - q, k) : D;
      }
      function cY(D, B, k) {
        D = mn(D), B = Er(B);
        var q = B ? a1(D) : 0;
        return B && q < B ? yg(B - q, k) + D : D;
      }
      function lY(D, B, k) {
        return k || B == null ? B = 0 : B && (B = +B), vU(mn(D).replace(so, ""), B || 0);
      }
      function dY(D, B, k) {
        return (k ? lo(D, B, k) : B === r) ? B = 1 : B = Er(B), Y5(mn(D), B);
      }
      function fY() {
        var D = arguments, B = mn(D[0]);
        return D.length < 3 ? B : B.replace(D[1], D[2]);
      }
      var pY = f1(function(D, B, k) {
        return D + (k ? "_" : "") + B.toLowerCase();
      });
      function hY(D, B, k) {
        return k && typeof k != "number" && lo(D, B, k) && (B = k = r), k = k === r ? K : k >>> 0, k ? (D = mn(D), D && (typeof B == "string" || B != null && !g6(B)) && (B = $o(B), !B && i1(D)) ? nd(du(D), 0, k) : D.split(B, k)) : [];
      }
      var mY = f1(function(D, B, k) {
        return D + (k ? " " : "") + b6(B);
      });
      function gY(D, B, k) {
        return D = mn(D), k = k == null ? 0 : If(Er(k), 0, D.length), B = $o(B), D.slice(k, k + B.length) == B;
      }
      function vY(D, B, k) {
        var q = oe.templateSettings;
        k && lo(D, B, k) && (B = r), D = mn(D), B = Mg({}, B, q, QC);
        var $ = Mg({}, B.imports, q.imports, QC), ue = ma($), ve = M5($, ue), we, Be, rt = 0, it = B.interpolate || Yl, dt = "__p += '", Ct = B5(
          (B.escape || Yl).source + "|" + it.source + "|" + (it === un ? Pi : Yl).source + "|" + (B.evaluate || Yl).source + "|$",
          "g"
        ), Rt = "//# sourceURL=" + (Sn.call(B, "sourceURL") ? (B.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++DV + "]") + `
`;
        D.replace(Ct, function($t, Or, qr, ts, fo, rs) {
          return qr || (qr = ts), dt += D.slice(rt, rs).replace(Pc, XV), Or && (we = !0, dt += `' +
__e(` + Or + `) +
'`), fo && (Be = !0, dt += `';
` + fo + `;
__p += '`), qr && (dt += `' +
((__t = (` + qr + `)) == null ? '' : __t) +
'`), rt = rs + $t.length, $t;
        }), dt += `';
`;
        var Jt = Sn.call(B, "variable") && B.variable;
        if (!Jt)
          dt = `with (obj) {
` + dt + `
}
`;
        else if (Hu.test(Jt))
          throw new vr(s);
        dt = (Be ? dt.replace(Et, "") : dt).replace(ur, "$1").replace(ir, "$1;"), dt = "function(" + (Jt || "obj") + `) {
` + (Jt ? "" : `obj || (obj = {});
`) + "var __t, __p = ''" + (we ? ", __e = _.escape" : "") + (Be ? `, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
` : `;
`) + dt + `return __p
}`;
        var Tr = HA(function() {
          return dn(ue, Rt + "return " + dt).apply(r, ve);
        });
        if (Tr.source = dt, m6(Tr))
          throw Tr;
        return Tr;
      }
      function yY(D) {
        return mn(D).toLowerCase();
      }
      function bY(D) {
        return mn(D).toUpperCase();
      }
      function _Y(D, B, k) {
        if (D = mn(D), D && (k || B === r))
          return JS(D);
        if (!D || !(B = $o(B)))
          return D;
        var q = du(D), $ = du(B), ue = $S(q, $), ve = eC(q, $) + 1;
        return nd(q, ue, ve).join("");
      }
      function xY(D, B, k) {
        if (D = mn(D), D && (k || B === r))
          return D.slice(0, rC(D) + 1);
        if (!D || !(B = $o(B)))
          return D;
        var q = du(D), $ = eC(q, du(B)) + 1;
        return nd(q, 0, $).join("");
      }
      function SY(D, B, k) {
        if (D = mn(D), D && (k || B === r))
          return D.replace(so, "");
        if (!D || !(B = $o(B)))
          return D;
        var q = du(D), $ = $S(q, du(B));
        return nd(q, $).join("");
      }
      function CY(D, B) {
        var k = I, q = P;
        if (ui(B)) {
          var $ = "separator" in B ? B.separator : $;
          k = "length" in B ? Er(B.length) : k, q = "omission" in B ? $o(B.omission) : q;
        }
        D = mn(D);
        var ue = D.length;
        if (i1(D)) {
          var ve = du(D);
          ue = ve.length;
        }
        if (k >= ue)
          return D;
        var we = k - a1(q);
        if (we < 1)
          return q;
        var Be = ve ? nd(ve, 0, we).join("") : D.slice(0, we);
        if ($ === r)
          return Be + q;
        if (ve && (we += Be.length - we), g6($)) {
          if (D.slice(we).search($)) {
            var rt, it = Be;
            for ($.global || ($ = B5($.source, mn(Mc.exec($)) + "g")), $.lastIndex = 0; rt = $.exec(it); )
              var dt = rt.index;
            Be = Be.slice(0, dt === r ? we : dt);
          }
        } else if (D.indexOf($o($), we) != we) {
          var Ct = Be.lastIndexOf($);
          Ct > -1 && (Be = Be.slice(0, Ct));
        }
        return Be + q;
      }
      function AY(D) {
        return D = mn(D), D && _n.test(D) ? D.replace(Nr, $V) : D;
      }
      var wY = f1(function(D, B, k) {
        return D + (k ? " " : "") + B.toUpperCase();
      }), b6 = qC("toUpperCase");
      function UA(D, B, k) {
        return D = mn(D), B = k ? r : B, B === r ? WV(D) ? rU(D) : GV(D) : D.match(B) || [];
      }
      var HA = Mr(function(D, B) {
        try {
          return Qo(D, r, B);
        } catch (k) {
          return m6(k) ? k : new vr(k);
        }
      }), DY = Oc(function(D, B) {
        return ws(B, function(k) {
          k = Yu(k), Nc(D, k, p6(D[k], D));
        }), D;
      });
      function EY(D) {
        var B = D == null ? 0 : D.length, k = Wt();
        return D = B ? $n(D, function(q) {
          if (typeof q[1] != "function")
            throw new Ds(o);
          return [k(q[0]), q[1]];
        }) : [], Mr(function(q) {
          for (var $ = -1; ++$ < B; ) {
            var ue = D[$];
            if (Qo(ue[0], this, q))
              return Qo(ue[1], this, q);
          }
        });
      }
      function IY(D) {
        return $U(Is(D, d));
      }
      function _6(D) {
        return function() {
          return D;
        };
      }
      function TY(D, B) {
        return D == null || D !== D ? B : D;
      }
      var MY = XC(), PY = XC(!0);
      function Po(D) {
        return D;
      }
      function x6(D) {
        return SC(typeof D == "function" ? D : Is(D, d));
      }
      function BY(D) {
        return AC(Is(D, d));
      }
      function FY(D, B) {
        return wC(D, Is(B, d));
      }
      var NY = Mr(function(D, B) {
        return function(k) {
          return wh(k, D, B);
        };
      }), RY = Mr(function(D, B) {
        return function(k) {
          return wh(D, k, B);
        };
      });
      function S6(D, B, k) {
        var q = ma(B), $ = dg(B, q);
        k == null && !(ui(B) && ($.length || !q.length)) && (k = B, B = D, D = this, $ = dg(B, ma(B)));
        var ue = !(ui(k) && "chain" in k) || !!k.chain, ve = kc(D);
        return ws($, function(we) {
          var Be = B[we];
          D[we] = Be, ve && (D.prototype[we] = function() {
            var rt = this.__chain__;
            if (ue || rt) {
              var it = D(this.__wrapped__), dt = it.__actions__ = Io(this.__actions__);
              return dt.push({ func: Be, args: arguments, thisArg: D }), it.__chain__ = rt, it;
            }
            return Be.apply(D, Ql([this.value()], arguments));
          });
        }), D;
      }
      function OY() {
        return Ma._ === this && (Ma._ = uU), this;
      }
      function C6() {
      }
      function LY(D) {
        return D = Er(D), Mr(function(B) {
          return DC(B, D);
        });
      }
      var kY = e6($n), GY = e6(YS), zY = e6(w5);
      function qA(D) {
        return s6(D) ? D5(Yu(D)) : gH(D);
      }
      function VY(D) {
        return function(B) {
          return D == null ? r : Tf(D, B);
        };
      }
      var UY = WC(), HY = WC(!0);
      function A6() {
        return [];
      }
      function w6() {
        return !1;
      }
      function qY() {
        return {};
      }
      function KY() {
        return "";
      }
      function XY() {
        return !0;
      }
      function YY(D, B) {
        if (D = Er(D), D < 1 || D > V)
          return [];
        var k = K, q = qa(D, K);
        B = Wt(B), D -= K;
        for (var $ = T5(q, B); ++k < D; )
          B(k);
        return $;
      }
      function WY(D) {
        return Cr(D) ? $n(D, Yu) : es(D) ? [D] : Io(lA(mn(D)));
      }
      function jY(D) {
        var B = ++oU;
        return mn(D) + B;
      }
      var ZY = vg(function(D, B) {
        return D + B;
      }, 0), QY = t6("ceil"), JY = vg(function(D, B) {
        return D / B;
      }, 1), $Y = t6("floor");
      function eW(D) {
        return D && D.length ? lg(D, Po, z5) : r;
      }
      function tW(D, B) {
        return D && D.length ? lg(D, Wt(B, 2), z5) : r;
      }
      function rW(D) {
        return ZS(D, Po);
      }
      function nW(D, B) {
        return ZS(D, Wt(B, 2));
      }
      function iW(D) {
        return D && D.length ? lg(D, Po, q5) : r;
      }
      function aW(D, B) {
        return D && D.length ? lg(D, Wt(B, 2), q5) : r;
      }
      var oW = vg(function(D, B) {
        return D * B;
      }, 1), sW = t6("round"), uW = vg(function(D, B) {
        return D - B;
      }, 0);
      function cW(D) {
        return D && D.length ? I5(D, Po) : 0;
      }
      function lW(D, B) {
        return D && D.length ? I5(D, Wt(B, 2)) : 0;
      }
      return oe.after = BK, oe.ary = xA, oe.assign = bX, oe.assignIn = RA, oe.assignInWith = Mg, oe.assignWith = _X, oe.at = xX, oe.before = SA, oe.bind = p6, oe.bindAll = DY, oe.bindKey = CA, oe.castArray = qK, oe.chain = yA, oe.chunk = $H, oe.compact = eq, oe.concat = tq, oe.cond = EY, oe.conforms = IY, oe.constant = _6, oe.countBy = cK, oe.create = SX, oe.curry = AA, oe.curryRight = wA, oe.debounce = DA, oe.defaults = CX, oe.defaultsDeep = AX, oe.defer = FK, oe.delay = NK, oe.difference = rq, oe.differenceBy = nq, oe.differenceWith = iq, oe.drop = aq, oe.dropRight = oq, oe.dropRightWhile = sq, oe.dropWhile = uq, oe.fill = cq, oe.filter = dK, oe.flatMap = hK, oe.flatMapDeep = mK, oe.flatMapDepth = gK, oe.flatten = hA, oe.flattenDeep = lq, oe.flattenDepth = dq, oe.flip = RK, oe.flow = MY, oe.flowRight = PY, oe.fromPairs = fq, oe.functions = PX, oe.functionsIn = BX, oe.groupBy = vK, oe.initial = hq, oe.intersection = mq, oe.intersectionBy = gq, oe.intersectionWith = vq, oe.invert = NX, oe.invertBy = RX, oe.invokeMap = bK, oe.iteratee = x6, oe.keyBy = _K, oe.keys = ma, oe.keysIn = Mo, oe.map = Ag, oe.mapKeys = LX, oe.mapValues = kX, oe.matches = BY, oe.matchesProperty = FY, oe.memoize = Dg, oe.merge = GX, oe.mergeWith = OA, oe.method = NY, oe.methodOf = RY, oe.mixin = S6, oe.negate = Eg, oe.nthArg = LY, oe.omit = zX, oe.omitBy = VX, oe.once = OK, oe.orderBy = xK, oe.over = kY, oe.overArgs = LK, oe.overEvery = GY, oe.overSome = zY, oe.partial = h6, oe.partialRight = EA, oe.partition = SK, oe.pick = UX, oe.pickBy = LA, oe.property = qA, oe.propertyOf = VY, oe.pull = xq, oe.pullAll = gA, oe.pullAllBy = Sq, oe.pullAllWith = Cq, oe.pullAt = Aq, oe.range = UY, oe.rangeRight = HY, oe.rearg = kK, oe.reject = wK, oe.remove = wq, oe.rest = GK, oe.reverse = d6, oe.sampleSize = EK, oe.set = qX, oe.setWith = KX, oe.shuffle = IK, oe.slice = Dq, oe.sortBy = PK, oe.sortedUniq = Fq, oe.sortedUniqBy = Nq, oe.split = hY, oe.spread = zK, oe.tail = Rq, oe.take = Oq, oe.takeRight = Lq, oe.takeRightWhile = kq, oe.takeWhile = Gq, oe.tap = eK, oe.throttle = VK, oe.thru = Cg, oe.toArray = BA, oe.toPairs = kA, oe.toPairsIn = GA, oe.toPath = WY, oe.toPlainObject = NA, oe.transform = XX, oe.unary = UK, oe.union = zq, oe.unionBy = Vq, oe.unionWith = Uq, oe.uniq = Hq, oe.uniqBy = qq, oe.uniqWith = Kq, oe.unset = YX, oe.unzip = f6, oe.unzipWith = vA, oe.update = WX, oe.updateWith = jX, oe.values = m1, oe.valuesIn = ZX, oe.without = Xq, oe.words = UA, oe.wrap = HK, oe.xor = Yq, oe.xorBy = Wq, oe.xorWith = jq, oe.zip = Zq, oe.zipObject = Qq, oe.zipObjectDeep = Jq, oe.zipWith = $q, oe.entries = kA, oe.entriesIn = GA, oe.extend = RA, oe.extendWith = Mg, S6(oe, oe), oe.add = ZY, oe.attempt = HA, oe.camelCase = eY, oe.capitalize = zA, oe.ceil = QY, oe.clamp = QX, oe.clone = KK, oe.cloneDeep = YK, oe.cloneDeepWith = WK, oe.cloneWith = XK, oe.conformsTo = jK, oe.deburr = VA, oe.defaultTo = TY, oe.divide = JY, oe.endsWith = tY, oe.eq = pu, oe.escape = rY, oe.escapeRegExp = nY, oe.every = lK, oe.find = fK, oe.findIndex = fA, oe.findKey = wX, oe.findLast = pK, oe.findLastIndex = pA, oe.findLastKey = DX, oe.floor = $Y, oe.forEach = bA, oe.forEachRight = _A, oe.forIn = EX, oe.forInRight = IX, oe.forOwn = TX, oe.forOwnRight = MX, oe.get = v6, oe.gt = ZK, oe.gte = QK, oe.has = FX, oe.hasIn = y6, oe.head = mA, oe.identity = Po, oe.includes = yK, oe.indexOf = pq, oe.inRange = JX, oe.invoke = OX, oe.isArguments = Bf, oe.isArray = Cr, oe.isArrayBuffer = JK, oe.isArrayLike = To, oe.isArrayLikeObject = Bi, oe.isBoolean = $K, oe.isBuffer = id, oe.isDate = eX, oe.isElement = tX, oe.isEmpty = rX, oe.isEqual = nX, oe.isEqualWith = iX, oe.isError = m6, oe.isFinite = aX, oe.isFunction = kc, oe.isInteger = IA, oe.isLength = Ig, oe.isMap = TA, oe.isMatch = oX, oe.isMatchWith = sX, oe.isNaN = uX, oe.isNative = cX, oe.isNil = dX, oe.isNull = lX, oe.isNumber = MA, oe.isObject = ui, oe.isObjectLike = bi, oe.isPlainObject = Ph, oe.isRegExp = g6, oe.isSafeInteger = fX, oe.isSet = PA, oe.isString = Tg, oe.isSymbol = es, oe.isTypedArray = h1, oe.isUndefined = pX, oe.isWeakMap = hX, oe.isWeakSet = mX, oe.join = yq, oe.kebabCase = iY, oe.last = Ms, oe.lastIndexOf = bq, oe.lowerCase = aY, oe.lowerFirst = oY, oe.lt = gX, oe.lte = vX, oe.max = eW, oe.maxBy = tW, oe.mean = rW, oe.meanBy = nW, oe.min = iW, oe.minBy = aW, oe.stubArray = A6, oe.stubFalse = w6, oe.stubObject = qY, oe.stubString = KY, oe.stubTrue = XY, oe.multiply = oW, oe.nth = _q, oe.noConflict = OY, oe.noop = C6, oe.now = wg, oe.pad = sY, oe.padEnd = uY, oe.padStart = cY, oe.parseInt = lY, oe.random = $X, oe.reduce = CK, oe.reduceRight = AK, oe.repeat = dY, oe.replace = fY, oe.result = HX, oe.round = sW, oe.runInContext = Te, oe.sample = DK, oe.size = TK, oe.snakeCase = pY, oe.some = MK, oe.sortedIndex = Eq, oe.sortedIndexBy = Iq, oe.sortedIndexOf = Tq, oe.sortedLastIndex = Mq, oe.sortedLastIndexBy = Pq, oe.sortedLastIndexOf = Bq, oe.startCase = mY, oe.startsWith = gY, oe.subtract = uW, oe.sum = cW, oe.sumBy = lW, oe.template = vY, oe.times = YY, oe.toFinite = Gc, oe.toInteger = Er, oe.toLength = FA, oe.toLower = yY, oe.toNumber = Ps, oe.toSafeInteger = yX, oe.toString = mn, oe.toUpper = bY, oe.trim = _Y, oe.trimEnd = xY, oe.trimStart = SY, oe.truncate = CY, oe.unescape = AY, oe.uniqueId = jY, oe.upperCase = wY, oe.upperFirst = b6, oe.each = bA, oe.eachRight = _A, oe.first = mA, S6(oe, function() {
        var D = {};
        return Ku(oe, function(B, k) {
          Sn.call(oe.prototype, k) || (D[k] = B);
        }), D;
      }(), { chain: !1 }), oe.VERSION = n, ws(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(D) {
        oe[D].placeholder = oe;
      }), ws(["drop", "take"], function(D, B) {
        zr.prototype[D] = function(k) {
          k = k === r ? 1 : $i(Er(k), 0);
          var q = this.__filtered__ && !B ? new zr(this) : this.clone();
          return q.__filtered__ ? q.__takeCount__ = qa(k, q.__takeCount__) : q.__views__.push({
            size: qa(k, K),
            type: D + (q.__dir__ < 0 ? "Right" : "")
          }), q;
        }, zr.prototype[D + "Right"] = function(k) {
          return this.reverse()[D](k).reverse();
        };
      }), ws(["filter", "map", "takeWhile"], function(D, B) {
        var k = B + 1, q = k == F || k == R;
        zr.prototype[D] = function($) {
          var ue = this.clone();
          return ue.__iteratees__.push({
            iteratee: Wt($, 3),
            type: k
          }), ue.__filtered__ = ue.__filtered__ || q, ue;
        };
      }), ws(["head", "last"], function(D, B) {
        var k = "take" + (B ? "Right" : "");
        zr.prototype[D] = function() {
          return this[k](1).value()[0];
        };
      }), ws(["initial", "tail"], function(D, B) {
        var k = "drop" + (B ? "" : "Right");
        zr.prototype[D] = function() {
          return this.__filtered__ ? new zr(this) : this[k](1);
        };
      }), zr.prototype.compact = function() {
        return this.filter(Po);
      }, zr.prototype.find = function(D) {
        return this.filter(D).head();
      }, zr.prototype.findLast = function(D) {
        return this.reverse().find(D);
      }, zr.prototype.invokeMap = Mr(function(D, B) {
        return typeof D == "function" ? new zr(this) : this.map(function(k) {
          return wh(k, D, B);
        });
      }), zr.prototype.reject = function(D) {
        return this.filter(Eg(Wt(D)));
      }, zr.prototype.slice = function(D, B) {
        D = Er(D);
        var k = this;
        return k.__filtered__ && (D > 0 || B < 0) ? new zr(k) : (D < 0 ? k = k.takeRight(-D) : D && (k = k.drop(D)), B !== r && (B = Er(B), k = B < 0 ? k.dropRight(-B) : k.take(B - D)), k);
      }, zr.prototype.takeRightWhile = function(D) {
        return this.reverse().takeWhile(D).reverse();
      }, zr.prototype.toArray = function() {
        return this.take(K);
      }, Ku(zr.prototype, function(D, B) {
        var k = /^(?:filter|find|map|reject)|While$/.test(B), q = /^(?:head|last)$/.test(B), $ = oe[q ? "take" + (B == "last" ? "Right" : "") : B], ue = q || /^find/.test(B);
        $ && (oe.prototype[B] = function() {
          var ve = this.__wrapped__, we = q ? [1] : arguments, Be = ve instanceof zr, rt = we[0], it = Be || Cr(ve), dt = function(Or) {
            var qr = $.apply(oe, Ql([Or], we));
            return q && Ct ? qr[0] : qr;
          };
          it && k && typeof rt == "function" && rt.length != 1 && (Be = it = !1);
          var Ct = this.__chain__, Rt = !!this.__actions__.length, Jt = ue && !Ct, Tr = Be && !Rt;
          if (!ue && it) {
            ve = Tr ? ve : new zr(this);
            var $t = D.apply(ve, we);
            return $t.__actions__.push({ func: Cg, args: [dt], thisArg: r }), new Es($t, Ct);
          }
          return Jt && Tr ? D.apply(this, we) : ($t = this.thru(dt), Jt ? q ? $t.value()[0] : $t.value() : $t);
        });
      }), ws(["pop", "push", "shift", "sort", "splice", "unshift"], function(D) {
        var B = j2[D], k = /^(?:push|sort|unshift)$/.test(D) ? "tap" : "thru", q = /^(?:pop|shift)$/.test(D);
        oe.prototype[D] = function() {
          var $ = arguments;
          if (q && !this.__chain__) {
            var ue = this.value();
            return B.apply(Cr(ue) ? ue : [], $);
          }
          return this[k](function(ve) {
            return B.apply(Cr(ve) ? ve : [], $);
          });
        };
      }), Ku(zr.prototype, function(D, B) {
        var k = oe[B];
        if (k) {
          var q = k.name + "";
          Sn.call(c1, q) || (c1[q] = []), c1[q].push({ name: B, func: k });
        }
      }), c1[gg(r, g).name] = [{
        name: "wrapper",
        func: r
      }], zr.prototype.clone = AU, zr.prototype.reverse = wU, zr.prototype.value = DU, oe.prototype.at = tK, oe.prototype.chain = rK, oe.prototype.commit = nK, oe.prototype.next = iK, oe.prototype.plant = oK, oe.prototype.reverse = sK, oe.prototype.toJSON = oe.prototype.valueOf = oe.prototype.value = uK, oe.prototype.first = oe.prototype.head, yh && (oe.prototype[yh] = aK), oe;
    }, o1 = nU();
    Af ? ((Af.exports = o1)._ = o1, x5._ = o1) : Ma._ = o1;
  }).call(o0);
})(Ay, Ay.exports);
var fge = Ay.exports;
function LB(t) {
  const e = t.map((r) => r);
  return lge(e, hS(e));
}
function pge(t, e = [0, 0, 1], r) {
  if (!r) {
    const M = OB(e, [1, 0, 0]);
    hS(M) < 1e-5 ? r = [0, 0, 1] : r = [1, 0, 0];
  }
  const n = r, i = LB(e), a = LB(n.map((M, T) => M - _4(n, i) * i[T])), o = OB(i, a);
  let s = 90, u = 90, c = 90, l, d, f;
  typeof t == "number" ? l = d = f = t : t.length === 1 ? l = d = f = t[0] : t.length === 3 ? [l, d, f] = t : [l, d, f, s, u, c] = t;
  const h = 2 * Number.EPSILON;
  let m = d0(s - 90) < h ? 0 : f3(s * op / 180), p = d0(u - 90) < h ? 0 : f3(u * op / 180), v, g;
  d0(c - 90) < h ? (v = 0, g = 1) : d0(c + 90) < h ? (v = 0, g = -1) : (v = f3(c * op / 180), g = Az(c * op / 180));
  const y = [l, 0, 0], b = [d * v, d * g, 0], S = p, _ = (m - p * v) / g, x = 1 - S * S - _ * _;
  if (x < 0) throw new Error("cz_sqr is negative, which is not possible");
  const C = v4(x), A = [f * S, f * _, f * C], w = en([y, b, A]), I = en([a, o, i]);
  return ys(w, Dz(I)).toArray();
}
function hge(t, e = !1) {
  const r = t.map((i) => hS(i)), n = [];
  for (let i = 0; i < 3; i++) {
    const a = (i + 2) % 3, o = (i + 1) % 3, s = ys(r[a], r[o]);
    let u;
    if (s > 1e-16) {
      const c = _4(t[a], t[o]) / s;
      u = 180 / op * z2e(c);
    } else
      u = 90;
    n.push(u);
  }
  if (e)
    for (let i = 0; i < n.length; i++)
      n[i] = n[i] * op / 180;
  return [...r, ...n];
}
const W1 = 5e-3;
function wy(t, e = t.length, r = []) {
  if (e === 0) return [];
  if (e === 1) return [...r, ...t.map((n) => [n])];
  if (t.length === e) return wy(t, e - 1, [t.slice()]);
  for (let n = 0; n < t.length - 1; n++)
    for (let i = n + 1; i < t.length; i++)
      r.push([t[n], t[i]]);
  return wy(t, e - 1, r);
}
function mge(t, e) {
  return t.every((r, n) => r === e[n]);
}
function kB(t) {
  return mge(t, [0, 0, 0]);
}
function gge(t) {
  const e = {
    expand: [1, 1, 1],
    atoms: [],
    lattice: void 0
  }, r = t != null && t.lattice ? S9(t == null ? void 0 : t.lattice) : void 0, n = t.atoms.map((i, a) => Dy(i, {
    lattice: r,
    order: a
  }));
  return e.lattice = r, e.atoms = n, e;
}
function vge(t) {
  if (!t.lattice)
    return t;
  const e = gge({
    lattice: t.lattice,
    atoms: t.atoms
  }), { atoms: r } = e, n = _ge(r, t.lattice);
  return e.atoms = [...e.atoms, ...n], e;
}
function yge(t) {
  const e = [], r = [];
  return t.atoms.map((n) => {
    e.push(n.element), r.push(n.xyz);
  }), {
    elements: e,
    xyzs: r,
    lattice: t.lattice
  };
}
function bge(t) {
  const e = P2(4).toArray();
  return t.forEach((r, n) => {
    e[3][n] = r;
  }), e;
}
function GB(t, e) {
  let r = [0, 0, 0];
  return t.forEach((n, i) => {
    n && (r = fl(r, ys(e[i], n)));
  }), bge(r);
}
function zB(t, e) {
  const [r, n, i] = t, a = 1 / (e[0][3] * r + e[1][3] * n + e[2][3] * i + e[3][3] || 1), o = (e[0][0] * r + e[1][0] * n + e[2][0] * i + e[3][0]) * a, s = (e[0][1] * r + e[1][1] * n + e[2][1] * i + e[3][1]) * a, u = (e[0][2] * r + e[1][2] * n + e[2][2] * i + e[3][2]) * a;
  return [o, s, u];
}
function S9(t) {
  const { a: e, b: r, c: n, alpha: i, beta: a, gamma: o, spacegroup: s } = t, u = t.matrix || pge([e, r, n, i, a, o]), c = x4(u), l = u[0], d = u[1], f = u[2], h = Mz(u);
  return {
    spacegroup: s,
    a: e,
    b: r,
    c: n,
    volume: h,
    alpha: i,
    beta: a,
    gamma: o,
    vecA: l,
    vecB: d,
    vecC: f,
    matrix: u,
    invertMatrix: c
  };
}
function Dy(t, e) {
  const { element: r } = t, { order: n, lattice: i, symmetry: a } = e || {};
  if (!t.abc && !t.xyz)
    throw new Error("createAtom: Need xyz or abc!");
  if (!i && !t.xyz)
    throw new Error("createAtom: Need xyz or lattice!");
  let o = (() => {
    const { xyz: c, abc: l } = t;
    if (!i)
      return;
    if (!l)
      return ys(c, i.invertMatrix);
    if (!a || kB(a))
      return l;
    const d = GB(a, P2(3).toArray());
    return zB(l, d);
  })(), s = (() => {
    const { xyz: c, abc: l } = t;
    if (!i)
      return c;
    if (!c)
      return ys(l, i.matrix);
    if (!a || kB(a))
      return c;
    const d = GB(a, i.matrix);
    return zB(c, d);
  })();
  return o && o.some((c) => c < 0 || c > 1) && (o = ige(o, 1)), i && (s = ys(o, i.matrix)), {
    element: r,
    xyz: s,
    abc: o,
    order: n,
    symmetry: a
  };
}
function _ge(t, e) {
  const r = [];
  return t.forEach((n, i) => {
    const { abc: a } = n;
    if (!(!a || a[0] === void 0)) {
      {
        const o = [];
        Math.abs(a[0]) <= W1 && o.push(0), Math.abs(a[1]) <= W1 && o.push(1), Math.abs(a[2]) <= W1 && o.push(2), wy(o).map((c) => [
          Number(c.includes(0)),
          Number(c.includes(1)),
          Number(c.includes(2))
        ]).forEach((c) => {
          const l = Dy(n, {
            order: i,
            lattice: e,
            symmetry: c
          });
          r.push(l);
        });
      }
      {
        const o = [];
        Math.abs(1 - a[0]) <= W1 && o.push(0), Math.abs(1 - a[1]) <= W1 && o.push(1), Math.abs(1 - a[2]) <= W1 && o.push(2), wy(o).map((c) => [
          -Number(c.includes(0)),
          -Number(c.includes(1)),
          -Number(c.includes(2))
        ]).forEach((c) => {
          const l = Dy(n, {
            order: i,
            lattice: e,
            symmetry: c
          });
          r.push(l);
        });
      }
    }
  }), r;
}
function xge(t) {
  const e = t[0], r = t[1], n = t[2], i = [0, 0, 0], a = e, o = r, s = fl(e, r), u = n, c = fl(e, n), l = fl(r, n), d = fl(fl(e, r), n);
  return [i, a, o, s, u, c, l, d];
}
function Sge(t) {
  const [e, r, n, i, a, o, s, u] = t;
  return [
    [e, r],
    [e, n],
    [r, i],
    [n, i],
    [e, a],
    [r, o],
    [n, s],
    [i, u],
    [a, o],
    [a, s],
    [o, u],
    [s, u]
  ];
}
function Cge(t) {
  const { length: e, angle: r, matrix: n, spacegroup: i = [1, "P1"], atoms: a } = t, o = {
    expand: [1, 1, 1],
    atoms: [],
    lattice: void 0
  }, s = (() => {
    const c = {
      symbol: i[1],
      no: i[0]
    };
    if (n) {
      const [g, y, b, S, _, x] = hge(n);
      return S9({
        spacegroup: c,
        matrix: n,
        a: g,
        b: y,
        c: b,
        alpha: S,
        beta: _,
        gamma: x
      });
    }
    if (!e || !r)
      return;
    const [l, d, f] = e, [h, m, p] = r;
    return S9({
      spacegroup: c,
      a: l,
      b: d,
      c: f,
      alpha: h,
      beta: m,
      gamma: p
    });
  })(), u = a.map((c, l) => {
    const d = {
      element: c.formula,
      xyz: c.cart_coord,
      abc: c.frac_coord
    };
    return Dy(d, {
      lattice: s,
      order: l
    });
  });
  return o.lattice = s, o.atoms = u, o;
}
var Pz = { exports: {} }, S4 = {}, Bz = {}, Br = {};
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t._registerNode = t.Konva = t.glob = void 0;
  const e = Math.PI / 180;
  function r() {
    return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
  }
  t.glob = typeof o0 < "u" ? o0 : typeof window < "u" ? window : typeof WorkerGlobalScope < "u" ? self : {}, t.Konva = {
    _global: t.glob,
    version: "9.3.14",
    isBrowser: r(),
    isUnminified: /param/.test((function(i) {
    }).toString()),
    dblClickWindow: 400,
    getAngle(i) {
      return t.Konva.angleDeg ? i * e : i;
    },
    enableTrace: !1,
    pointerEventsEnabled: !0,
    autoDrawEnabled: !0,
    hitOnDragEnabled: !1,
    capturePointerEventsEnabled: !1,
    _mouseListenClick: !1,
    _touchListenClick: !1,
    _pointerListenClick: !1,
    _mouseInDblClickWindow: !1,
    _touchInDblClickWindow: !1,
    _pointerInDblClickWindow: !1,
    _mouseDblClickPointerId: null,
    _touchDblClickPointerId: null,
    _pointerDblClickPointerId: null,
    _fixTextRendering: !1,
    pixelRatio: typeof window < "u" && window.devicePixelRatio || 1,
    dragDistance: 3,
    angleDeg: !0,
    showWarnings: !0,
    dragButtons: [0, 1],
    isDragging() {
      return t.Konva.DD.isDragging;
    },
    isTransforming() {
      var i;
      return (i = t.Konva.Transformer) === null || i === void 0 ? void 0 : i.isTransforming();
    },
    isDragReady() {
      return !!t.Konva.DD.node;
    },
    releaseCanvasOnDestroy: !0,
    document: t.glob.document,
    _injectGlobal(i) {
      t.glob.Konva = i;
    }
  };
  const n = (i) => {
    t.Konva[i.prototype.getClassName()] = i;
  };
  t._registerNode = n, t.Konva._injectGlobal(t.Konva);
})(Br);
var vi = {};
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t.Util = t.Transform = void 0;
  const e = Br;
  class r {
    constructor(S = [1, 0, 0, 1, 0, 0]) {
      this.dirty = !1, this.m = S && S.slice() || [1, 0, 0, 1, 0, 0];
    }
    reset() {
      this.m[0] = 1, this.m[1] = 0, this.m[2] = 0, this.m[3] = 1, this.m[4] = 0, this.m[5] = 0;
    }
    copy() {
      return new r(this.m);
    }
    copyInto(S) {
      S.m[0] = this.m[0], S.m[1] = this.m[1], S.m[2] = this.m[2], S.m[3] = this.m[3], S.m[4] = this.m[4], S.m[5] = this.m[5];
    }
    point(S) {
      var _ = this.m;
      return {
        x: _[0] * S.x + _[2] * S.y + _[4],
        y: _[1] * S.x + _[3] * S.y + _[5]
      };
    }
    translate(S, _) {
      return this.m[4] += this.m[0] * S + this.m[2] * _, this.m[5] += this.m[1] * S + this.m[3] * _, this;
    }
    scale(S, _) {
      return this.m[0] *= S, this.m[1] *= S, this.m[2] *= _, this.m[3] *= _, this;
    }
    rotate(S) {
      var _ = Math.cos(S), x = Math.sin(S), C = this.m[0] * _ + this.m[2] * x, A = this.m[1] * _ + this.m[3] * x, w = this.m[0] * -x + this.m[2] * _, I = this.m[1] * -x + this.m[3] * _;
      return this.m[0] = C, this.m[1] = A, this.m[2] = w, this.m[3] = I, this;
    }
    getTranslation() {
      return {
        x: this.m[4],
        y: this.m[5]
      };
    }
    skew(S, _) {
      var x = this.m[0] + this.m[2] * _, C = this.m[1] + this.m[3] * _, A = this.m[2] + this.m[0] * S, w = this.m[3] + this.m[1] * S;
      return this.m[0] = x, this.m[1] = C, this.m[2] = A, this.m[3] = w, this;
    }
    multiply(S) {
      var _ = this.m[0] * S.m[0] + this.m[2] * S.m[1], x = this.m[1] * S.m[0] + this.m[3] * S.m[1], C = this.m[0] * S.m[2] + this.m[2] * S.m[3], A = this.m[1] * S.m[2] + this.m[3] * S.m[3], w = this.m[0] * S.m[4] + this.m[2] * S.m[5] + this.m[4], I = this.m[1] * S.m[4] + this.m[3] * S.m[5] + this.m[5];
      return this.m[0] = _, this.m[1] = x, this.m[2] = C, this.m[3] = A, this.m[4] = w, this.m[5] = I, this;
    }
    invert() {
      var S = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]), _ = this.m[3] * S, x = -this.m[1] * S, C = -this.m[2] * S, A = this.m[0] * S, w = S * (this.m[2] * this.m[5] - this.m[3] * this.m[4]), I = S * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
      return this.m[0] = _, this.m[1] = x, this.m[2] = C, this.m[3] = A, this.m[4] = w, this.m[5] = I, this;
    }
    getMatrix() {
      return this.m;
    }
    decompose() {
      var S = this.m[0], _ = this.m[1], x = this.m[2], C = this.m[3], A = this.m[4], w = this.m[5], I = S * C - _ * x;
      let P = {
        x: A,
        y: w,
        rotation: 0,
        scaleX: 0,
        scaleY: 0,
        skewX: 0,
        skewY: 0
      };
      if (S != 0 || _ != 0) {
        var M = Math.sqrt(S * S + _ * _);
        P.rotation = _ > 0 ? Math.acos(S / M) : -Math.acos(S / M), P.scaleX = M, P.scaleY = I / M, P.skewX = (S * x + _ * C) / I, P.skewY = 0;
      } else if (x != 0 || C != 0) {
        var T = Math.sqrt(x * x + C * C);
        P.rotation = Math.PI / 2 - (C > 0 ? Math.acos(-x / T) : -Math.acos(x / T)), P.scaleX = I / T, P.scaleY = T, P.skewX = 0, P.skewY = (S * x + _ * C) / I;
      }
      return P.rotation = t.Util._getRotation(P.rotation), P;
    }
  }
  t.Transform = r;
  var n = "[object Array]", i = "[object Number]", a = "[object String]", o = "[object Boolean]", s = Math.PI / 180, u = 180 / Math.PI, c = "#", l = "", d = "0", f = "Konva warning: ", h = "Konva error: ", m = "rgb(", p = {
    aliceblue: [240, 248, 255],
    antiquewhite: [250, 235, 215],
    aqua: [0, 255, 255],
    aquamarine: [127, 255, 212],
    azure: [240, 255, 255],
    beige: [245, 245, 220],
    bisque: [255, 228, 196],
    black: [0, 0, 0],
    blanchedalmond: [255, 235, 205],
    blue: [0, 0, 255],
    blueviolet: [138, 43, 226],
    brown: [165, 42, 42],
    burlywood: [222, 184, 135],
    cadetblue: [95, 158, 160],
    chartreuse: [127, 255, 0],
    chocolate: [210, 105, 30],
    coral: [255, 127, 80],
    cornflowerblue: [100, 149, 237],
    cornsilk: [255, 248, 220],
    crimson: [220, 20, 60],
    cyan: [0, 255, 255],
    darkblue: [0, 0, 139],
    darkcyan: [0, 139, 139],
    darkgoldenrod: [184, 132, 11],
    darkgray: [169, 169, 169],
    darkgreen: [0, 100, 0],
    darkgrey: [169, 169, 169],
    darkkhaki: [189, 183, 107],
    darkmagenta: [139, 0, 139],
    darkolivegreen: [85, 107, 47],
    darkorange: [255, 140, 0],
    darkorchid: [153, 50, 204],
    darkred: [139, 0, 0],
    darksalmon: [233, 150, 122],
    darkseagreen: [143, 188, 143],
    darkslateblue: [72, 61, 139],
    darkslategray: [47, 79, 79],
    darkslategrey: [47, 79, 79],
    darkturquoise: [0, 206, 209],
    darkviolet: [148, 0, 211],
    deeppink: [255, 20, 147],
    deepskyblue: [0, 191, 255],
    dimgray: [105, 105, 105],
    dimgrey: [105, 105, 105],
    dodgerblue: [30, 144, 255],
    firebrick: [178, 34, 34],
    floralwhite: [255, 255, 240],
    forestgreen: [34, 139, 34],
    fuchsia: [255, 0, 255],
    gainsboro: [220, 220, 220],
    ghostwhite: [248, 248, 255],
    gold: [255, 215, 0],
    goldenrod: [218, 165, 32],
    gray: [128, 128, 128],
    green: [0, 128, 0],
    greenyellow: [173, 255, 47],
    grey: [128, 128, 128],
    honeydew: [240, 255, 240],
    hotpink: [255, 105, 180],
    indianred: [205, 92, 92],
    indigo: [75, 0, 130],
    ivory: [255, 255, 240],
    khaki: [240, 230, 140],
    lavender: [230, 230, 250],
    lavenderblush: [255, 240, 245],
    lawngreen: [124, 252, 0],
    lemonchiffon: [255, 250, 205],
    lightblue: [173, 216, 230],
    lightcoral: [240, 128, 128],
    lightcyan: [224, 255, 255],
    lightgoldenrodyellow: [250, 250, 210],
    lightgray: [211, 211, 211],
    lightgreen: [144, 238, 144],
    lightgrey: [211, 211, 211],
    lightpink: [255, 182, 193],
    lightsalmon: [255, 160, 122],
    lightseagreen: [32, 178, 170],
    lightskyblue: [135, 206, 250],
    lightslategray: [119, 136, 153],
    lightslategrey: [119, 136, 153],
    lightsteelblue: [176, 196, 222],
    lightyellow: [255, 255, 224],
    lime: [0, 255, 0],
    limegreen: [50, 205, 50],
    linen: [250, 240, 230],
    magenta: [255, 0, 255],
    maroon: [128, 0, 0],
    mediumaquamarine: [102, 205, 170],
    mediumblue: [0, 0, 205],
    mediumorchid: [186, 85, 211],
    mediumpurple: [147, 112, 219],
    mediumseagreen: [60, 179, 113],
    mediumslateblue: [123, 104, 238],
    mediumspringgreen: [0, 250, 154],
    mediumturquoise: [72, 209, 204],
    mediumvioletred: [199, 21, 133],
    midnightblue: [25, 25, 112],
    mintcream: [245, 255, 250],
    mistyrose: [255, 228, 225],
    moccasin: [255, 228, 181],
    navajowhite: [255, 222, 173],
    navy: [0, 0, 128],
    oldlace: [253, 245, 230],
    olive: [128, 128, 0],
    olivedrab: [107, 142, 35],
    orange: [255, 165, 0],
    orangered: [255, 69, 0],
    orchid: [218, 112, 214],
    palegoldenrod: [238, 232, 170],
    palegreen: [152, 251, 152],
    paleturquoise: [175, 238, 238],
    palevioletred: [219, 112, 147],
    papayawhip: [255, 239, 213],
    peachpuff: [255, 218, 185],
    peru: [205, 133, 63],
    pink: [255, 192, 203],
    plum: [221, 160, 203],
    powderblue: [176, 224, 230],
    purple: [128, 0, 128],
    rebeccapurple: [102, 51, 153],
    red: [255, 0, 0],
    rosybrown: [188, 143, 143],
    royalblue: [65, 105, 225],
    saddlebrown: [139, 69, 19],
    salmon: [250, 128, 114],
    sandybrown: [244, 164, 96],
    seagreen: [46, 139, 87],
    seashell: [255, 245, 238],
    sienna: [160, 82, 45],
    silver: [192, 192, 192],
    skyblue: [135, 206, 235],
    slateblue: [106, 90, 205],
    slategray: [119, 128, 144],
    slategrey: [119, 128, 144],
    snow: [255, 255, 250],
    springgreen: [0, 255, 127],
    steelblue: [70, 130, 180],
    tan: [210, 180, 140],
    teal: [0, 128, 128],
    thistle: [216, 191, 216],
    transparent: [255, 255, 255, 0],
    tomato: [255, 99, 71],
    turquoise: [64, 224, 208],
    violet: [238, 130, 238],
    wheat: [245, 222, 179],
    white: [255, 255, 255],
    whitesmoke: [245, 245, 245],
    yellow: [255, 255, 0],
    yellowgreen: [154, 205, 5]
  }, v = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/, g = [];
  const y = typeof requestAnimationFrame < "u" && requestAnimationFrame || function(b) {
    setTimeout(b, 60);
  };
  t.Util = {
    _isElement(b) {
      return !!(b && b.nodeType == 1);
    },
    _isFunction(b) {
      return !!(b && b.constructor && b.call && b.apply);
    },
    _isPlainObject(b) {
      return !!b && b.constructor === Object;
    },
    _isArray(b) {
      return Object.prototype.toString.call(b) === n;
    },
    _isNumber(b) {
      return Object.prototype.toString.call(b) === i && !isNaN(b) && isFinite(b);
    },
    _isString(b) {
      return Object.prototype.toString.call(b) === a;
    },
    _isBoolean(b) {
      return Object.prototype.toString.call(b) === o;
    },
    isObject(b) {
      return b instanceof Object;
    },
    isValidSelector(b) {
      if (typeof b != "string")
        return !1;
      var S = b[0];
      return S === "#" || S === "." || S === S.toUpperCase();
    },
    _sign(b) {
      return b === 0 || b > 0 ? 1 : -1;
    },
    requestAnimFrame(b) {
      g.push(b), g.length === 1 && y(function() {
        const S = g;
        g = [], S.forEach(function(_) {
          _();
        });
      });
    },
    createCanvasElement() {
      var b = document.createElement("canvas");
      try {
        b.style = b.style || {};
      } catch {
      }
      return b;
    },
    createImageElement() {
      return document.createElement("img");
    },
    _isInDocument(b) {
      for (; b = b.parentNode; )
        if (b == document)
          return !0;
      return !1;
    },
    _urlToImage(b, S) {
      var _ = t.Util.createImageElement();
      _.onload = function() {
        S(_);
      }, _.src = b;
    },
    _rgbToHex(b, S, _) {
      return ((1 << 24) + (b << 16) + (S << 8) + _).toString(16).slice(1);
    },
    _hexToRgb(b) {
      b = b.replace(c, l);
      var S = parseInt(b, 16);
      return {
        r: S >> 16 & 255,
        g: S >> 8 & 255,
        b: S & 255
      };
    },
    getRandomColor() {
      for (var b = (Math.random() * 16777215 << 0).toString(16); b.length < 6; )
        b = d + b;
      return c + b;
    },
    getRGB(b) {
      var S;
      return b in p ? (S = p[b], {
        r: S[0],
        g: S[1],
        b: S[2]
      }) : b[0] === c ? this._hexToRgb(b.substring(1)) : b.substr(0, 4) === m ? (S = v.exec(b.replace(/ /g, "")), {
        r: parseInt(S[1], 10),
        g: parseInt(S[2], 10),
        b: parseInt(S[3], 10)
      }) : {
        r: 0,
        g: 0,
        b: 0
      };
    },
    colorToRGBA(b) {
      return b = b || "black", t.Util._namedColorToRBA(b) || t.Util._hex3ColorToRGBA(b) || t.Util._hex4ColorToRGBA(b) || t.Util._hex6ColorToRGBA(b) || t.Util._hex8ColorToRGBA(b) || t.Util._rgbColorToRGBA(b) || t.Util._rgbaColorToRGBA(b) || t.Util._hslColorToRGBA(b);
    },
    _namedColorToRBA(b) {
      var S = p[b.toLowerCase()];
      return S ? {
        r: S[0],
        g: S[1],
        b: S[2],
        a: 1
      } : null;
    },
    _rgbColorToRGBA(b) {
      if (b.indexOf("rgb(") === 0) {
        b = b.match(/rgb\(([^)]+)\)/)[1];
        var S = b.split(/ *, */).map(Number);
        return {
          r: S[0],
          g: S[1],
          b: S[2],
          a: 1
        };
      }
    },
    _rgbaColorToRGBA(b) {
      if (b.indexOf("rgba(") === 0) {
        b = b.match(/rgba\(([^)]+)\)/)[1];
        var S = b.split(/ *, */).map((_, x) => _.slice(-1) === "%" ? x === 3 ? parseInt(_) / 100 : parseInt(_) / 100 * 255 : Number(_));
        return {
          r: S[0],
          g: S[1],
          b: S[2],
          a: S[3]
        };
      }
    },
    _hex8ColorToRGBA(b) {
      if (b[0] === "#" && b.length === 9)
        return {
          r: parseInt(b.slice(1, 3), 16),
          g: parseInt(b.slice(3, 5), 16),
          b: parseInt(b.slice(5, 7), 16),
          a: parseInt(b.slice(7, 9), 16) / 255
        };
    },
    _hex6ColorToRGBA(b) {
      if (b[0] === "#" && b.length === 7)
        return {
          r: parseInt(b.slice(1, 3), 16),
          g: parseInt(b.slice(3, 5), 16),
          b: parseInt(b.slice(5, 7), 16),
          a: 1
        };
    },
    _hex4ColorToRGBA(b) {
      if (b[0] === "#" && b.length === 5)
        return {
          r: parseInt(b[1] + b[1], 16),
          g: parseInt(b[2] + b[2], 16),
          b: parseInt(b[3] + b[3], 16),
          a: parseInt(b[4] + b[4], 16) / 255
        };
    },
    _hex3ColorToRGBA(b) {
      if (b[0] === "#" && b.length === 4)
        return {
          r: parseInt(b[1] + b[1], 16),
          g: parseInt(b[2] + b[2], 16),
          b: parseInt(b[3] + b[3], 16),
          a: 1
        };
    },
    _hslColorToRGBA(b) {
      if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(b)) {
        const [S, ..._] = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(b), x = Number(_[0]) / 360, C = Number(_[1]) / 100, A = Number(_[2]) / 100;
        let w, I, P;
        if (C === 0)
          return P = A * 255, {
            r: Math.round(P),
            g: Math.round(P),
            b: Math.round(P),
            a: 1
          };
        A < 0.5 ? w = A * (1 + C) : w = A + C - A * C;
        const M = 2 * A - w, T = [0, 0, 0];
        for (let F = 0; F < 3; F++)
          I = x + 1 / 3 * -(F - 1), I < 0 && I++, I > 1 && I--, 6 * I < 1 ? P = M + (w - M) * 6 * I : 2 * I < 1 ? P = w : 3 * I < 2 ? P = M + (w - M) * (2 / 3 - I) * 6 : P = M, T[F] = P * 255;
        return {
          r: Math.round(T[0]),
          g: Math.round(T[1]),
          b: Math.round(T[2]),
          a: 1
        };
      }
    },
    haveIntersection(b, S) {
      return !(S.x > b.x + b.width || S.x + S.width < b.x || S.y > b.y + b.height || S.y + S.height < b.y);
    },
    cloneObject(b) {
      var S = {};
      for (var _ in b)
        this._isPlainObject(b[_]) ? S[_] = this.cloneObject(b[_]) : this._isArray(b[_]) ? S[_] = this.cloneArray(b[_]) : S[_] = b[_];
      return S;
    },
    cloneArray(b) {
      return b.slice(0);
    },
    degToRad(b) {
      return b * s;
    },
    radToDeg(b) {
      return b * u;
    },
    _degToRad(b) {
      return t.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."), t.Util.degToRad(b);
    },
    _radToDeg(b) {
      return t.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."), t.Util.radToDeg(b);
    },
    _getRotation(b) {
      return e.Konva.angleDeg ? t.Util.radToDeg(b) : b;
    },
    _capitalize(b) {
      return b.charAt(0).toUpperCase() + b.slice(1);
    },
    throw(b) {
      throw new Error(h + b);
    },
    error(b) {
      console.error(h + b);
    },
    warn(b) {
      e.Konva.showWarnings && console.warn(f + b);
    },
    each(b, S) {
      for (var _ in b)
        S(_, b[_]);
    },
    _inRange(b, S, _) {
      return S <= b && b < _;
    },
    _getProjectionToSegment(b, S, _, x, C, A) {
      var w, I, P, M = (b - _) * (b - _) + (S - x) * (S - x);
      if (M == 0)
        w = b, I = S, P = (C - _) * (C - _) + (A - x) * (A - x);
      else {
        var T = ((C - b) * (_ - b) + (A - S) * (x - S)) / M;
        T < 0 ? (w = b, I = S, P = (b - C) * (b - C) + (S - A) * (S - A)) : T > 1 ? (w = _, I = x, P = (_ - C) * (_ - C) + (x - A) * (x - A)) : (w = b + T * (_ - b), I = S + T * (x - S), P = (w - C) * (w - C) + (I - A) * (I - A));
      }
      return [w, I, P];
    },
    _getProjectionToLine(b, S, _) {
      var x = t.Util.cloneObject(b), C = Number.MAX_VALUE;
      return S.forEach(function(A, w) {
        if (!(!_ && w === S.length - 1)) {
          var I = S[(w + 1) % S.length], P = t.Util._getProjectionToSegment(A.x, A.y, I.x, I.y, b.x, b.y), M = P[0], T = P[1], F = P[2];
          F < C && (x.x = M, x.y = T, C = F);
        }
      }), x;
    },
    _prepareArrayForTween(b, S, _) {
      var x, C = [], A = [];
      if (b.length > S.length) {
        var w = S;
        S = b, b = w;
      }
      for (x = 0; x < b.length; x += 2)
        C.push({
          x: b[x],
          y: b[x + 1]
        });
      for (x = 0; x < S.length; x += 2)
        A.push({
          x: S[x],
          y: S[x + 1]
        });
      var I = [];
      return A.forEach(function(P) {
        var M = t.Util._getProjectionToLine(P, C, _);
        I.push(M.x), I.push(M.y);
      }), I;
    },
    _prepareToStringify(b) {
      var S;
      b.visitedByCircularReferenceRemoval = !0;
      for (var _ in b)
        if (b.hasOwnProperty(_) && b[_] && typeof b[_] == "object") {
          if (S = Object.getOwnPropertyDescriptor(b, _), b[_].visitedByCircularReferenceRemoval || t.Util._isElement(b[_]))
            if (S.configurable)
              delete b[_];
            else
              return null;
          else if (t.Util._prepareToStringify(b[_]) === null)
            if (S.configurable)
              delete b[_];
            else
              return null;
        }
      return delete b.visitedByCircularReferenceRemoval, b;
    },
    _assign(b, S) {
      for (var _ in S)
        b[_] = S[_];
      return b;
    },
    _getFirstPointerId(b) {
      return b.touches ? b.changedTouches[0].identifier : b.pointerId || 999;
    },
    releaseCanvas(...b) {
      e.Konva.releaseCanvasOnDestroy && b.forEach((S) => {
        S.width = 0, S.height = 0;
      });
    },
    drawRoundedRectPath(b, S, _, x) {
      let C = 0, A = 0, w = 0, I = 0;
      typeof x == "number" ? C = A = w = I = Math.min(x, S / 2, _ / 2) : (C = Math.min(x[0] || 0, S / 2, _ / 2), A = Math.min(x[1] || 0, S / 2, _ / 2), I = Math.min(x[2] || 0, S / 2, _ / 2), w = Math.min(x[3] || 0, S / 2, _ / 2)), b.moveTo(C, 0), b.lineTo(S - A, 0), b.arc(S - A, A, A, Math.PI * 3 / 2, 0, !1), b.lineTo(S, _ - I), b.arc(S - I, _ - I, I, 0, Math.PI / 2, !1), b.lineTo(w, _), b.arc(w, _ - w, w, Math.PI / 2, Math.PI, !1), b.lineTo(0, C), b.arc(C, C, C, Math.PI, Math.PI * 3 / 2, !1);
    }
  };
})(vi);
var si = {}, Fr = {}, Ot = {};
Object.defineProperty(Ot, "__esModule", { value: !0 });
Ot.getComponentValidator = Ot.getBooleanValidator = Ot.getNumberArrayValidator = Ot.getFunctionValidator = Ot.getStringOrGradientValidator = Ot.getStringValidator = Ot.getNumberOrAutoValidator = Ot.getNumberOrArrayOfNumbersValidator = Ot.getNumberValidator = Ot.alphaComponent = Ot.RGBComponent = void 0;
const kl = Br, Di = vi;
function Gl(t) {
  return Di.Util._isString(t) ? '"' + t + '"' : Object.prototype.toString.call(t) === "[object Number]" || Di.Util._isBoolean(t) ? t : Object.prototype.toString.call(t);
}
function Age(t) {
  return t > 255 ? 255 : t < 0 ? 0 : Math.round(t);
}
Ot.RGBComponent = Age;
function wge(t) {
  return t > 1 ? 1 : t < 1e-4 ? 1e-4 : t;
}
Ot.alphaComponent = wge;
function Dge() {
  if (kl.Konva.isUnminified)
    return function(t, e) {
      return Di.Util._isNumber(t) || Di.Util.warn(Gl(t) + ' is a not valid value for "' + e + '" attribute. The value should be a number.'), t;
    };
}
Ot.getNumberValidator = Dge;
function Ege(t) {
  if (kl.Konva.isUnminified)
    return function(e, r) {
      let n = Di.Util._isNumber(e), i = Di.Util._isArray(e) && e.length == t;
      return !n && !i && Di.Util.warn(Gl(e) + ' is a not valid value for "' + r + '" attribute. The value should be a number or Array<number>(' + t + ")"), e;
    };
}
Ot.getNumberOrArrayOfNumbersValidator = Ege;
function Ige() {
  if (kl.Konva.isUnminified)
    return function(t, e) {
      var r = Di.Util._isNumber(t), n = t === "auto";
      return r || n || Di.Util.warn(Gl(t) + ' is a not valid value for "' + e + '" attribute. The value should be a number or "auto".'), t;
    };
}
Ot.getNumberOrAutoValidator = Ige;
function Tge() {
  if (kl.Konva.isUnminified)
    return function(t, e) {
      return Di.Util._isString(t) || Di.Util.warn(Gl(t) + ' is a not valid value for "' + e + '" attribute. The value should be a string.'), t;
    };
}
Ot.getStringValidator = Tge;
function Mge() {
  if (kl.Konva.isUnminified)
    return function(t, e) {
      const r = Di.Util._isString(t), n = Object.prototype.toString.call(t) === "[object CanvasGradient]" || t && t.addColorStop;
      return r || n || Di.Util.warn(Gl(t) + ' is a not valid value for "' + e + '" attribute. The value should be a string or a native gradient.'), t;
    };
}
Ot.getStringOrGradientValidator = Mge;
function Pge() {
  if (kl.Konva.isUnminified)
    return function(t, e) {
      return Di.Util._isFunction(t) || Di.Util.warn(Gl(t) + ' is a not valid value for "' + e + '" attribute. The value should be a function.'), t;
    };
}
Ot.getFunctionValidator = Pge;
function Bge() {
  if (kl.Konva.isUnminified)
    return function(t, e) {
      const r = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
      return r && t instanceof r || (Di.Util._isArray(t) ? t.forEach(function(n) {
        Di.Util._isNumber(n) || Di.Util.warn('"' + e + '" attribute has non numeric element ' + n + ". Make sure that all elements are numbers.");
      }) : Di.Util.warn(Gl(t) + ' is a not valid value for "' + e + '" attribute. The value should be a array of numbers.')), t;
    };
}
Ot.getNumberArrayValidator = Bge;
function Fge() {
  if (kl.Konva.isUnminified)
    return function(t, e) {
      var r = t === !0 || t === !1;
      return r || Di.Util.warn(Gl(t) + ' is a not valid value for "' + e + '" attribute. The value should be a boolean.'), t;
    };
}
Ot.getBooleanValidator = Fge;
function Nge(t) {
  if (kl.Konva.isUnminified)
    return function(e, r) {
      return e == null || Di.Util.isObject(e) || Di.Util.warn(Gl(e) + ' is a not valid value for "' + r + '" attribute. The value should be an object with properties ' + t), e;
    };
}
Ot.getComponentValidator = Nge;
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t.Factory = void 0;
  const e = vi, r = Ot;
  var n = "get", i = "set";
  t.Factory = {
    addGetterSetter(a, o, s, u, c) {
      t.Factory.addGetter(a, o, s), t.Factory.addSetter(a, o, u, c), t.Factory.addOverloadedGetterSetter(a, o);
    },
    addGetter(a, o, s) {
      var u = n + e.Util._capitalize(o);
      a.prototype[u] = a.prototype[u] || function() {
        var c = this.attrs[o];
        return c === void 0 ? s : c;
      };
    },
    addSetter(a, o, s, u) {
      var c = i + e.Util._capitalize(o);
      a.prototype[c] || t.Factory.overWriteSetter(a, o, s, u);
    },
    overWriteSetter(a, o, s, u) {
      var c = i + e.Util._capitalize(o);
      a.prototype[c] = function(l) {
        return s && l !== void 0 && l !== null && (l = s.call(this, l, o)), this._setAttr(o, l), u && u.call(this), this;
      };
    },
    addComponentsGetterSetter(a, o, s, u, c) {
      var l = s.length, d = e.Util._capitalize, f = n + d(o), h = i + d(o), m, p;
      a.prototype[f] = function() {
        var g = {};
        for (m = 0; m < l; m++)
          p = s[m], g[p] = this.getAttr(o + d(p));
        return g;
      };
      var v = (0, r.getComponentValidator)(s);
      a.prototype[h] = function(g) {
        var y = this.attrs[o], b;
        u && (g = u.call(this, g)), v && v.call(this, g, o);
        for (b in g)
          g.hasOwnProperty(b) && this._setAttr(o + d(b), g[b]);
        return g || s.forEach((S) => {
          this._setAttr(o + d(S), void 0);
        }), this._fireChangeEvent(o, y, g), c && c.call(this), this;
      }, t.Factory.addOverloadedGetterSetter(a, o);
    },
    addOverloadedGetterSetter(a, o) {
      var s = e.Util._capitalize(o), u = i + s, c = n + s;
      a.prototype[o] = function() {
        return arguments.length ? (this[u](arguments[0]), this) : this[c]();
      };
    },
    addDeprecatedGetterSetter(a, o, s, u) {
      e.Util.error("Adding deprecated " + o);
      var c = n + e.Util._capitalize(o), l = o + " property is deprecated and will be removed soon. Look at Konva change log for more information.";
      a.prototype[c] = function() {
        e.Util.error(l);
        var d = this.attrs[o];
        return d === void 0 ? s : d;
      }, t.Factory.addSetter(a, o, u, function() {
        e.Util.error(l);
      }), t.Factory.addOverloadedGetterSetter(a, o);
    },
    backCompat(a, o) {
      e.Util.each(o, function(s, u) {
        var c = a.prototype[u], l = n + e.Util._capitalize(s), d = i + e.Util._capitalize(s);
        function f() {
          c.apply(this, arguments), e.Util.error('"' + s + '" method is deprecated and will be removed soon. Use ""' + u + '" instead.');
        }
        a.prototype[s] = f, a.prototype[l] = f, a.prototype[d] = f;
      });
    },
    afterSetFilter() {
      this._filterUpToDate = !1;
    }
  };
})(Fr);
var Lu = {}, Sl = {};
Object.defineProperty(Sl, "__esModule", { value: !0 });
Sl.HitContext = Sl.SceneContext = Sl.Context = void 0;
const Fz = vi, Rge = Br;
function Oge(t) {
  var e = [], r = t.length, n = Fz.Util, i, a;
  for (i = 0; i < r; i++)
    a = t[i], n._isNumber(a) ? a = Math.round(a * 1e3) / 1e3 : n._isString(a) || (a = a + ""), e.push(a);
  return e;
}
var VB = ",", Lge = "(", kge = ")", Gge = "([", zge = "])", Vge = ";", Uge = "()", Hge = "=", UB = [
  "arc",
  "arcTo",
  "beginPath",
  "bezierCurveTo",
  "clearRect",
  "clip",
  "closePath",
  "createLinearGradient",
  "createPattern",
  "createRadialGradient",
  "drawImage",
  "ellipse",
  "fill",
  "fillText",
  "getImageData",
  "createImageData",
  "lineTo",
  "moveTo",
  "putImageData",
  "quadraticCurveTo",
  "rect",
  "roundRect",
  "restore",
  "rotate",
  "save",
  "scale",
  "setLineDash",
  "setTransform",
  "stroke",
  "strokeText",
  "transform",
  "translate"
], qge = [
  "fillStyle",
  "strokeStyle",
  "shadowColor",
  "shadowBlur",
  "shadowOffsetX",
  "shadowOffsetY",
  "letterSpacing",
  "lineCap",
  "lineDashOffset",
  "lineJoin",
  "lineWidth",
  "miterLimit",
  "direction",
  "font",
  "textAlign",
  "textBaseline",
  "globalAlpha",
  "globalCompositeOperation",
  "imageSmoothingEnabled"
];
const Kge = 100;
class C4 {
  constructor(e) {
    this.canvas = e, Rge.Konva.enableTrace && (this.traceArr = [], this._enableTrace());
  }
  fillShape(e) {
    e.fillEnabled() && this._fill(e);
  }
  _fill(e) {
  }
  strokeShape(e) {
    e.hasStroke() && this._stroke(e);
  }
  _stroke(e) {
  }
  fillStrokeShape(e) {
    e.attrs.fillAfterStrokeEnabled ? (this.strokeShape(e), this.fillShape(e)) : (this.fillShape(e), this.strokeShape(e));
  }
  getTrace(e, r) {
    var n = this.traceArr, i = n.length, a = "", o, s, u, c;
    for (o = 0; o < i; o++)
      s = n[o], u = s.method, u ? (c = s.args, a += u, e ? a += Uge : Fz.Util._isArray(c[0]) ? a += Gge + c.join(VB) + zge : (r && (c = c.map((l) => typeof l == "number" ? Math.floor(l) : l)), a += Lge + c.join(VB) + kge)) : (a += s.property, e || (a += Hge + s.val)), a += Vge;
    return a;
  }
  clearTrace() {
    this.traceArr = [];
  }
  _trace(e) {
    var r = this.traceArr, n;
    r.push(e), n = r.length, n >= Kge && r.shift();
  }
  reset() {
    var e = this.getCanvas().getPixelRatio();
    this.setTransform(1 * e, 0, 0, 1 * e, 0, 0);
  }
  getCanvas() {
    return this.canvas;
  }
  clear(e) {
    var r = this.getCanvas();
    e ? this.clearRect(e.x || 0, e.y || 0, e.width || 0, e.height || 0) : this.clearRect(0, 0, r.getWidth() / r.pixelRatio, r.getHeight() / r.pixelRatio);
  }
  _applyLineCap(e) {
    const r = e.attrs.lineCap;
    r && this.setAttr("lineCap", r);
  }
  _applyOpacity(e) {
    var r = e.getAbsoluteOpacity();
    r !== 1 && this.setAttr("globalAlpha", r);
  }
  _applyLineJoin(e) {
    const r = e.attrs.lineJoin;
    r && this.setAttr("lineJoin", r);
  }
  setAttr(e, r) {
    this._context[e] = r;
  }
  arc(e, r, n, i, a, o) {
    this._context.arc(e, r, n, i, a, o);
  }
  arcTo(e, r, n, i, a) {
    this._context.arcTo(e, r, n, i, a);
  }
  beginPath() {
    this._context.beginPath();
  }
  bezierCurveTo(e, r, n, i, a, o) {
    this._context.bezierCurveTo(e, r, n, i, a, o);
  }
  clearRect(e, r, n, i) {
    this._context.clearRect(e, r, n, i);
  }
  clip(...e) {
    this._context.clip.apply(this._context, e);
  }
  closePath() {
    this._context.closePath();
  }
  createImageData(e, r) {
    var n = arguments;
    if (n.length === 2)
      return this._context.createImageData(e, r);
    if (n.length === 1)
      return this._context.createImageData(e);
  }
  createLinearGradient(e, r, n, i) {
    return this._context.createLinearGradient(e, r, n, i);
  }
  createPattern(e, r) {
    return this._context.createPattern(e, r);
  }
  createRadialGradient(e, r, n, i, a, o) {
    return this._context.createRadialGradient(e, r, n, i, a, o);
  }
  drawImage(e, r, n, i, a, o, s, u, c) {
    var l = arguments, d = this._context;
    l.length === 3 ? d.drawImage(e, r, n) : l.length === 5 ? d.drawImage(e, r, n, i, a) : l.length === 9 && d.drawImage(e, r, n, i, a, o, s, u, c);
  }
  ellipse(e, r, n, i, a, o, s, u) {
    this._context.ellipse(e, r, n, i, a, o, s, u);
  }
  isPointInPath(e, r, n, i) {
    return n ? this._context.isPointInPath(n, e, r, i) : this._context.isPointInPath(e, r, i);
  }
  fill(...e) {
    this._context.fill.apply(this._context, e);
  }
  fillRect(e, r, n, i) {
    this._context.fillRect(e, r, n, i);
  }
  strokeRect(e, r, n, i) {
    this._context.strokeRect(e, r, n, i);
  }
  fillText(e, r, n, i) {
    i ? this._context.fillText(e, r, n, i) : this._context.fillText(e, r, n);
  }
  measureText(e) {
    return this._context.measureText(e);
  }
  getImageData(e, r, n, i) {
    return this._context.getImageData(e, r, n, i);
  }
  lineTo(e, r) {
    this._context.lineTo(e, r);
  }
  moveTo(e, r) {
    this._context.moveTo(e, r);
  }
  rect(e, r, n, i) {
    this._context.rect(e, r, n, i);
  }
  roundRect(e, r, n, i, a) {
    this._context.roundRect(e, r, n, i, a);
  }
  putImageData(e, r, n) {
    this._context.putImageData(e, r, n);
  }
  quadraticCurveTo(e, r, n, i) {
    this._context.quadraticCurveTo(e, r, n, i);
  }
  restore() {
    this._context.restore();
  }
  rotate(e) {
    this._context.rotate(e);
  }
  save() {
    this._context.save();
  }
  scale(e, r) {
    this._context.scale(e, r);
  }
  setLineDash(e) {
    this._context.setLineDash ? this._context.setLineDash(e) : "mozDash" in this._context ? this._context.mozDash = e : "webkitLineDash" in this._context && (this._context.webkitLineDash = e);
  }
  getLineDash() {
    return this._context.getLineDash();
  }
  setTransform(e, r, n, i, a, o) {
    this._context.setTransform(e, r, n, i, a, o);
  }
  stroke(e) {
    e ? this._context.stroke(e) : this._context.stroke();
  }
  strokeText(e, r, n, i) {
    this._context.strokeText(e, r, n, i);
  }
  transform(e, r, n, i, a, o) {
    this._context.transform(e, r, n, i, a, o);
  }
  translate(e, r) {
    this._context.translate(e, r);
  }
  _enableTrace() {
    var e = this, r = UB.length, n = this.setAttr, i, a, o = function(s) {
      var u = e[s], c;
      e[s] = function() {
        return a = Oge(Array.prototype.slice.call(arguments, 0)), c = u.apply(e, arguments), e._trace({
          method: s,
          args: a
        }), c;
      };
    };
    for (i = 0; i < r; i++)
      o(UB[i]);
    e.setAttr = function() {
      n.apply(e, arguments);
      var s = arguments[0], u = arguments[1];
      (s === "shadowOffsetX" || s === "shadowOffsetY" || s === "shadowBlur") && (u = u / this.canvas.getPixelRatio()), e._trace({
        property: s,
        val: u
      });
    };
  }
  _applyGlobalCompositeOperation(e) {
    const r = e.attrs.globalCompositeOperation;
    var n = !r || r === "source-over";
    n || this.setAttr("globalCompositeOperation", r);
  }
}
Sl.Context = C4;
qge.forEach(function(t) {
  Object.defineProperty(C4.prototype, t, {
    get() {
      return this._context[t];
    },
    set(e) {
      this._context[t] = e;
    }
  });
});
class Xge extends C4 {
  constructor(e, { willReadFrequently: r = !1 } = {}) {
    super(e), this._context = e._canvas.getContext("2d", {
      willReadFrequently: r
    });
  }
  _fillColor(e) {
    var r = e.fill();
    this.setAttr("fillStyle", r), e._fillFunc(this);
  }
  _fillPattern(e) {
    this.setAttr("fillStyle", e._getFillPattern()), e._fillFunc(this);
  }
  _fillLinearGradient(e) {
    var r = e._getLinearGradient();
    r && (this.setAttr("fillStyle", r), e._fillFunc(this));
  }
  _fillRadialGradient(e) {
    const r = e._getRadialGradient();
    r && (this.setAttr("fillStyle", r), e._fillFunc(this));
  }
  _fill(e) {
    const r = e.fill(), n = e.getFillPriority();
    if (r && n === "color") {
      this._fillColor(e);
      return;
    }
    const i = e.getFillPatternImage();
    if (i && n === "pattern") {
      this._fillPattern(e);
      return;
    }
    const a = e.getFillLinearGradientColorStops();
    if (a && n === "linear-gradient") {
      this._fillLinearGradient(e);
      return;
    }
    const o = e.getFillRadialGradientColorStops();
    if (o && n === "radial-gradient") {
      this._fillRadialGradient(e);
      return;
    }
    r ? this._fillColor(e) : i ? this._fillPattern(e) : a ? this._fillLinearGradient(e) : o && this._fillRadialGradient(e);
  }
  _strokeLinearGradient(e) {
    const r = e.getStrokeLinearGradientStartPoint(), n = e.getStrokeLinearGradientEndPoint(), i = e.getStrokeLinearGradientColorStops(), a = this.createLinearGradient(r.x, r.y, n.x, n.y);
    if (i) {
      for (var o = 0; o < i.length; o += 2)
        a.addColorStop(i[o], i[o + 1]);
      this.setAttr("strokeStyle", a);
    }
  }
  _stroke(e) {
    var r = e.dash(), n = e.getStrokeScaleEnabled();
    if (e.hasStroke()) {
      if (!n) {
        this.save();
        var i = this.getCanvas().getPixelRatio();
        this.setTransform(i, 0, 0, i, 0, 0);
      }
      this._applyLineCap(e), r && e.dashEnabled() && (this.setLineDash(r), this.setAttr("lineDashOffset", e.dashOffset())), this.setAttr("lineWidth", e.strokeWidth()), e.getShadowForStrokeEnabled() || this.setAttr("shadowColor", "rgba(0,0,0,0)");
      var a = e.getStrokeLinearGradientColorStops();
      a ? this._strokeLinearGradient(e) : this.setAttr("strokeStyle", e.stroke()), e._strokeFunc(this), n || this.restore();
    }
  }
  _applyShadow(e) {
    var r, n, i, a = (r = e.getShadowRGBA()) !== null && r !== void 0 ? r : "black", o = (n = e.getShadowBlur()) !== null && n !== void 0 ? n : 5, s = (i = e.getShadowOffset()) !== null && i !== void 0 ? i : {
      x: 0,
      y: 0
    }, u = e.getAbsoluteScale(), c = this.canvas.getPixelRatio(), l = u.x * c, d = u.y * c;
    this.setAttr("shadowColor", a), this.setAttr("shadowBlur", o * Math.min(Math.abs(l), Math.abs(d))), this.setAttr("shadowOffsetX", s.x * l), this.setAttr("shadowOffsetY", s.y * d);
  }
}
Sl.SceneContext = Xge;
class Yge extends C4 {
  constructor(e) {
    super(e), this._context = e._canvas.getContext("2d", {
      willReadFrequently: !0
    });
  }
  _fill(e) {
    this.save(), this.setAttr("fillStyle", e.colorKey), e._fillFuncHit(this), this.restore();
  }
  strokeShape(e) {
    e.hasHitStroke() && this._stroke(e);
  }
  _stroke(e) {
    if (e.hasHitStroke()) {
      const a = e.getStrokeScaleEnabled();
      if (!a) {
        this.save();
        var r = this.getCanvas().getPixelRatio();
        this.setTransform(r, 0, 0, r, 0, 0);
      }
      this._applyLineCap(e);
      var n = e.hitStrokeWidth(), i = n === "auto" ? e.strokeWidth() : n;
      this.setAttr("lineWidth", i), this.setAttr("strokeStyle", e.colorKey), e._strokeFuncHit(this), a || this.restore();
    }
  }
}
Sl.HitContext = Yge;
Object.defineProperty(Lu, "__esModule", { value: !0 });
Lu.HitCanvas = Lu.SceneCanvas = Lu.Canvas = void 0;
const Ey = vi, Nz = Sl, Rz = Br, Wge = Fr, jge = Ot;
var qv;
function Zge() {
  if (qv)
    return qv;
  var t = Ey.Util.createCanvasElement(), e = t.getContext("2d");
  return qv = function() {
    var r = Rz.Konva._global.devicePixelRatio || 1, n = e.webkitBackingStorePixelRatio || e.mozBackingStorePixelRatio || e.msBackingStorePixelRatio || e.oBackingStorePixelRatio || e.backingStorePixelRatio || 1;
    return r / n;
  }(), Ey.Util.releaseCanvas(t), qv;
}
class A4 {
  constructor(e) {
    this.pixelRatio = 1, this.width = 0, this.height = 0, this.isCache = !1;
    var r = e || {}, n = r.pixelRatio || Rz.Konva.pixelRatio || Zge();
    this.pixelRatio = n, this._canvas = Ey.Util.createCanvasElement(), this._canvas.style.padding = "0", this._canvas.style.margin = "0", this._canvas.style.border = "0", this._canvas.style.background = "transparent", this._canvas.style.position = "absolute", this._canvas.style.top = "0", this._canvas.style.left = "0";
  }
  getContext() {
    return this.context;
  }
  getPixelRatio() {
    return this.pixelRatio;
  }
  setPixelRatio(e) {
    var r = this.pixelRatio;
    this.pixelRatio = e, this.setSize(this.getWidth() / r, this.getHeight() / r);
  }
  setWidth(e) {
    this.width = this._canvas.width = e * this.pixelRatio, this._canvas.style.width = e + "px";
    var r = this.pixelRatio, n = this.getContext()._context;
    n.scale(r, r);
  }
  setHeight(e) {
    this.height = this._canvas.height = e * this.pixelRatio, this._canvas.style.height = e + "px";
    var r = this.pixelRatio, n = this.getContext()._context;
    n.scale(r, r);
  }
  getWidth() {
    return this.width;
  }
  getHeight() {
    return this.height;
  }
  setSize(e, r) {
    this.setWidth(e || 0), this.setHeight(r || 0);
  }
  toDataURL(e, r) {
    try {
      return this._canvas.toDataURL(e, r);
    } catch {
      try {
        return this._canvas.toDataURL();
      } catch (i) {
        return Ey.Util.error("Unable to get data URL. " + i.message + " For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."), "";
      }
    }
  }
}
Lu.Canvas = A4;
Wge.Factory.addGetterSetter(A4, "pixelRatio", void 0, (0, jge.getNumberValidator)());
class Qge extends A4 {
  constructor(e = { width: 0, height: 0, willReadFrequently: !1 }) {
    super(e), this.context = new Nz.SceneContext(this, {
      willReadFrequently: e.willReadFrequently
    }), this.setSize(e.width, e.height);
  }
}
Lu.SceneCanvas = Qge;
class Jge extends A4 {
  constructor(e = { width: 0, height: 0 }) {
    super(e), this.hitCanvas = !0, this.context = new Nz.HitContext(this), this.setSize(e.width, e.height);
  }
}
Lu.HitCanvas = Jge;
var w4 = {};
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t.DD = void 0;
  const e = Br, r = vi;
  t.DD = {
    get isDragging() {
      var n = !1;
      return t.DD._dragElements.forEach((i) => {
        i.dragStatus === "dragging" && (n = !0);
      }), n;
    },
    justDragged: !1,
    get node() {
      var n;
      return t.DD._dragElements.forEach((i) => {
        n = i.node;
      }), n;
    },
    _dragElements: /* @__PURE__ */ new Map(),
    _drag(n) {
      const i = [];
      t.DD._dragElements.forEach((a, o) => {
        const { node: s } = a, u = s.getStage();
        u.setPointersPositions(n), a.pointerId === void 0 && (a.pointerId = r.Util._getFirstPointerId(n));
        const c = u._changedPointerPositions.find((f) => f.id === a.pointerId);
        if (c) {
          if (a.dragStatus !== "dragging") {
            var l = s.dragDistance(), d = Math.max(Math.abs(c.x - a.startPointerPos.x), Math.abs(c.y - a.startPointerPos.y));
            if (d < l || (s.startDrag({ evt: n }), !s.isDragging()))
              return;
          }
          s._setDragPosition(n, a), i.push(s);
        }
      }), i.forEach((a) => {
        a.fire("dragmove", {
          type: "dragmove",
          target: a,
          evt: n
        }, !0);
      });
    },
    _endDragBefore(n) {
      const i = [];
      t.DD._dragElements.forEach((a) => {
        const { node: o } = a, s = o.getStage();
        if (n && s.setPointersPositions(n), !s._changedPointerPositions.find((l) => l.id === a.pointerId))
          return;
        (a.dragStatus === "dragging" || a.dragStatus === "stopped") && (t.DD.justDragged = !0, e.Konva._mouseListenClick = !1, e.Konva._touchListenClick = !1, e.Konva._pointerListenClick = !1, a.dragStatus = "stopped");
        const c = a.node.getLayer() || a.node instanceof e.Konva.Stage && a.node;
        c && i.indexOf(c) === -1 && i.push(c);
      }), i.forEach((a) => {
        a.draw();
      });
    },
    _endDragAfter(n) {
      t.DD._dragElements.forEach((i, a) => {
        i.dragStatus === "stopped" && i.node.fire("dragend", {
          type: "dragend",
          target: i.node,
          evt: n
        }, !0), i.dragStatus !== "dragging" && t.DD._dragElements.delete(a);
      });
    }
  }, e.Konva.isBrowser && (window.addEventListener("mouseup", t.DD._endDragBefore, !0), window.addEventListener("touchend", t.DD._endDragBefore, !0), window.addEventListener("mousemove", t.DD._drag), window.addEventListener("touchmove", t.DD._drag), window.addEventListener("mouseup", t.DD._endDragAfter, !1), window.addEventListener("touchend", t.DD._endDragAfter, !1));
})(w4);
Object.defineProperty(si, "__esModule", { value: !0 });
si.Node = void 0;
const Vr = vi, B2 = Fr, om = Lu, wd = Br, Hs = w4, Li = Ot;
var p3 = "absoluteOpacity", Kv = "allEventListeners", al = "absoluteTransform", HB = "absoluteScale", Jf = "canvas", $ge = "Change", eve = "children", tve = "konva", C9 = "listening", qB = "mouseenter", KB = "mouseleave", XB = "set", YB = "Shape", h3 = " ", WB = "stage", Ed = "transform", rve = "Stage", A9 = "visible", nve = [
  "xChange.konva",
  "yChange.konva",
  "scaleXChange.konva",
  "scaleYChange.konva",
  "skewXChange.konva",
  "skewYChange.konva",
  "rotationChange.konva",
  "offsetXChange.konva",
  "offsetYChange.konva",
  "transformsEnabledChange.konva"
].join(h3);
let ive = 1;
class fr {
  constructor(e) {
    this._id = ive++, this.eventListeners = {}, this.attrs = {}, this.index = 0, this._allEventListeners = null, this.parent = null, this._cache = /* @__PURE__ */ new Map(), this._attachedDepsListeners = /* @__PURE__ */ new Map(), this._lastPos = null, this._batchingTransformChange = !1, this._needClearTransformCache = !1, this._filterUpToDate = !1, this._isUnderCache = !1, this._dragEventId = null, this._shouldFireChangeEvents = !1, this.setAttrs(e), this._shouldFireChangeEvents = !0;
  }
  hasChildren() {
    return !1;
  }
  _clearCache(e) {
    (e === Ed || e === al) && this._cache.get(e) ? this._cache.get(e).dirty = !0 : e ? this._cache.delete(e) : this._cache.clear();
  }
  _getCache(e, r) {
    var n = this._cache.get(e), i = e === Ed || e === al, a = n === void 0 || i && n.dirty === !0;
    return a && (n = r.call(this), this._cache.set(e, n)), n;
  }
  _calculate(e, r, n) {
    if (!this._attachedDepsListeners.get(e)) {
      const i = r.map((a) => a + "Change.konva").join(h3);
      this.on(i, () => {
        this._clearCache(e);
      }), this._attachedDepsListeners.set(e, !0);
    }
    return this._getCache(e, n);
  }
  _getCanvasCache() {
    return this._cache.get(Jf);
  }
  _clearSelfAndDescendantCache(e) {
    this._clearCache(e), e === al && this.fire("absoluteTransformChange");
  }
  clearCache() {
    if (this._cache.has(Jf)) {
      const { scene: e, filter: r, hit: n } = this._cache.get(Jf);
      Vr.Util.releaseCanvas(e, r, n), this._cache.delete(Jf);
    }
    return this._clearSelfAndDescendantCache(), this._requestDraw(), this;
  }
  cache(e) {
    var r = e || {}, n = {};
    (r.x === void 0 || r.y === void 0 || r.width === void 0 || r.height === void 0) && (n = this.getClientRect({
      skipTransform: !0,
      relativeTo: this.getParent() || void 0
    }));
    var i = Math.ceil(r.width || n.width), a = Math.ceil(r.height || n.height), o = r.pixelRatio, s = r.x === void 0 ? Math.floor(n.x) : r.x, u = r.y === void 0 ? Math.floor(n.y) : r.y, c = r.offset || 0, l = r.drawBorder || !1, d = r.hitCanvasPixelRatio || 1;
    if (!i || !a) {
      Vr.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");
      return;
    }
    const f = Math.abs(Math.round(n.x) - s) > 0.5 ? 1 : 0, h = Math.abs(Math.round(n.y) - u) > 0.5 ? 1 : 0;
    i += c * 2 + f, a += c * 2 + h, s -= c, u -= c;
    var m = new om.SceneCanvas({
      pixelRatio: o,
      width: i,
      height: a
    }), p = new om.SceneCanvas({
      pixelRatio: o,
      width: 0,
      height: 0,
      willReadFrequently: !0
    }), v = new om.HitCanvas({
      pixelRatio: d,
      width: i,
      height: a
    }), g = m.getContext(), y = v.getContext();
    return v.isCache = !0, m.isCache = !0, this._cache.delete(Jf), this._filterUpToDate = !1, r.imageSmoothingEnabled === !1 && (m.getContext()._context.imageSmoothingEnabled = !1, p.getContext()._context.imageSmoothingEnabled = !1), g.save(), y.save(), g.translate(-s, -u), y.translate(-s, -u), this._isUnderCache = !0, this._clearSelfAndDescendantCache(p3), this._clearSelfAndDescendantCache(HB), this.drawScene(m, this), this.drawHit(v, this), this._isUnderCache = !1, g.restore(), y.restore(), l && (g.save(), g.beginPath(), g.rect(0, 0, i, a), g.closePath(), g.setAttr("strokeStyle", "red"), g.setAttr("lineWidth", 5), g.stroke(), g.restore()), this._cache.set(Jf, {
      scene: m,
      filter: p,
      hit: v,
      x: s,
      y: u
    }), this._requestDraw(), this;
  }
  isCached() {
    return this._cache.has(Jf);
  }
  getClientRect(e) {
    throw new Error('abstract "getClientRect" method call');
  }
  _transformedRect(e, r) {
    var n = [
      { x: e.x, y: e.y },
      { x: e.x + e.width, y: e.y },
      { x: e.x + e.width, y: e.y + e.height },
      { x: e.x, y: e.y + e.height }
    ], i = 1 / 0, a = 1 / 0, o = -1 / 0, s = -1 / 0, u = this.getAbsoluteTransform(r);
    return n.forEach(function(c) {
      var l = u.point(c);
      i === void 0 && (i = o = l.x, a = s = l.y), i = Math.min(i, l.x), a = Math.min(a, l.y), o = Math.max(o, l.x), s = Math.max(s, l.y);
    }), {
      x: i,
      y: a,
      width: o - i,
      height: s - a
    };
  }
  _drawCachedSceneCanvas(e) {
    e.save(), e._applyOpacity(this), e._applyGlobalCompositeOperation(this);
    const r = this._getCanvasCache();
    e.translate(r.x, r.y);
    var n = this._getCachedSceneCanvas(), i = n.pixelRatio;
    e.drawImage(n._canvas, 0, 0, n.width / i, n.height / i), e.restore();
  }
  _drawCachedHitCanvas(e) {
    var r = this._getCanvasCache(), n = r.hit;
    e.save(), e.translate(r.x, r.y), e.drawImage(n._canvas, 0, 0, n.width / n.pixelRatio, n.height / n.pixelRatio), e.restore();
  }
  _getCachedSceneCanvas() {
    var e = this.filters(), r = this._getCanvasCache(), n = r.scene, i = r.filter, a = i.getContext(), o, s, u, c;
    if (e) {
      if (!this._filterUpToDate) {
        var l = n.pixelRatio;
        i.setSize(n.width / n.pixelRatio, n.height / n.pixelRatio);
        try {
          for (o = e.length, a.clear(), a.drawImage(n._canvas, 0, 0, n.getWidth() / l, n.getHeight() / l), s = a.getImageData(0, 0, i.getWidth(), i.getHeight()), u = 0; u < o; u++) {
            if (c = e[u], typeof c != "function") {
              Vr.Util.error("Filter should be type of function, but got " + typeof c + " instead. Please check correct filters");
              continue;
            }
            c.call(this, s), a.putImageData(s, 0, 0);
          }
        } catch (d) {
          Vr.Util.error("Unable to apply filter. " + d.message + " This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.");
        }
        this._filterUpToDate = !0;
      }
      return i;
    }
    return n;
  }
  on(e, r) {
    if (this._cache && this._cache.delete(Kv), arguments.length === 3)
      return this._delegate.apply(this, arguments);
    var n = e.split(h3), i = n.length, a, o, s, u, c;
    for (a = 0; a < i; a++)
      o = n[a], s = o.split("."), u = s[0], c = s[1] || "", this.eventListeners[u] || (this.eventListeners[u] = []), this.eventListeners[u].push({
        name: c,
        handler: r
      });
    return this;
  }
  off(e, r) {
    var n = (e || "").split(h3), i = n.length, a, o, s, u, c, l;
    if (this._cache && this._cache.delete(Kv), !e)
      for (o in this.eventListeners)
        this._off(o);
    for (a = 0; a < i; a++)
      if (s = n[a], u = s.split("."), c = u[0], l = u[1], c)
        this.eventListeners[c] && this._off(c, l, r);
      else
        for (o in this.eventListeners)
          this._off(o, l, r);
    return this;
  }
  dispatchEvent(e) {
    var r = {
      target: this,
      type: e.type,
      evt: e
    };
    return this.fire(e.type, r), this;
  }
  addEventListener(e, r) {
    return this.on(e, function(n) {
      r.call(this, n.evt);
    }), this;
  }
  removeEventListener(e) {
    return this.off(e), this;
  }
  _delegate(e, r, n) {
    var i = this;
    this.on(e, function(a) {
      for (var o = a.target.findAncestors(r, !0, i), s = 0; s < o.length; s++)
        a = Vr.Util.cloneObject(a), a.currentTarget = o[s], n.call(o[s], a);
    });
  }
  remove() {
    return this.isDragging() && this.stopDrag(), Hs.DD._dragElements.delete(this._id), this._remove(), this;
  }
  _clearCaches() {
    this._clearSelfAndDescendantCache(al), this._clearSelfAndDescendantCache(p3), this._clearSelfAndDescendantCache(HB), this._clearSelfAndDescendantCache(WB), this._clearSelfAndDescendantCache(A9), this._clearSelfAndDescendantCache(C9);
  }
  _remove() {
    this._clearCaches();
    var e = this.getParent();
    e && e.children && (e.children.splice(this.index, 1), e._setChildrenIndices(), this.parent = null);
  }
  destroy() {
    return this.remove(), this.clearCache(), this;
  }
  getAttr(e) {
    var r = "get" + Vr.Util._capitalize(e);
    return Vr.Util._isFunction(this[r]) ? this[r]() : this.attrs[e];
  }
  getAncestors() {
    for (var e = this.getParent(), r = []; e; )
      r.push(e), e = e.getParent();
    return r;
  }
  getAttrs() {
    return this.attrs || {};
  }
  setAttrs(e) {
    return this._batchTransformChanges(() => {
      var r, n;
      if (!e)
        return this;
      for (r in e)
        r !== eve && (n = XB + Vr.Util._capitalize(r), Vr.Util._isFunction(this[n]) ? this[n](e[r]) : this._setAttr(r, e[r]));
    }), this;
  }
  isListening() {
    return this._getCache(C9, this._isListening);
  }
  _isListening(e) {
    if (!this.listening())
      return !1;
    const n = this.getParent();
    return n && n !== e && this !== e ? n._isListening(e) : !0;
  }
  isVisible() {
    return this._getCache(A9, this._isVisible);
  }
  _isVisible(e) {
    if (!this.visible())
      return !1;
    const n = this.getParent();
    return n && n !== e && this !== e ? n._isVisible(e) : !0;
  }
  shouldDrawHit(e, r = !1) {
    if (e)
      return this._isVisible(e) && this._isListening(e);
    var n = this.getLayer(), i = !1;
    Hs.DD._dragElements.forEach((o) => {
      o.dragStatus === "dragging" && (o.node.nodeType === "Stage" || o.node.getLayer() === n) && (i = !0);
    });
    var a = !r && !wd.Konva.hitOnDragEnabled && (i || wd.Konva.isTransforming());
    return this.isListening() && this.isVisible() && !a;
  }
  show() {
    return this.visible(!0), this;
  }
  hide() {
    return this.visible(!1), this;
  }
  getZIndex() {
    return this.index || 0;
  }
  getAbsoluteZIndex() {
    var e = this.getDepth(), r = this, n = 0, i, a, o, s;
    function u(l) {
      for (i = [], a = l.length, o = 0; o < a; o++)
        s = l[o], n++, s.nodeType !== YB && (i = i.concat(s.getChildren().slice())), s._id === r._id && (o = a);
      i.length > 0 && i[0].getDepth() <= e && u(i);
    }
    const c = this.getStage();
    return r.nodeType !== rve && c && u(c.getChildren()), n;
  }
  getDepth() {
    for (var e = 0, r = this.parent; r; )
      e++, r = r.parent;
    return e;
  }
  _batchTransformChanges(e) {
    this._batchingTransformChange = !0, e(), this._batchingTransformChange = !1, this._needClearTransformCache && (this._clearCache(Ed), this._clearSelfAndDescendantCache(al)), this._needClearTransformCache = !1;
  }
  setPosition(e) {
    return this._batchTransformChanges(() => {
      this.x(e.x), this.y(e.y);
    }), this;
  }
  getPosition() {
    return {
      x: this.x(),
      y: this.y()
    };
  }
  getRelativePointerPosition() {
    const e = this.getStage();
    if (!e)
      return null;
    var r = e.getPointerPosition();
    if (!r)
      return null;
    var n = this.getAbsoluteTransform().copy();
    return n.invert(), n.point(r);
  }
  getAbsolutePosition(e) {
    let r = !1, n = this.parent;
    for (; n; ) {
      if (n.isCached()) {
        r = !0;
        break;
      }
      n = n.parent;
    }
    r && !e && (e = !0);
    var i = this.getAbsoluteTransform(e).getMatrix(), a = new Vr.Transform(), o = this.offset();
    return a.m = i.slice(), a.translate(o.x, o.y), a.getTranslation();
  }
  setAbsolutePosition(e) {
    const { x: r, y: n, ...i } = this._clearTransform();
    this.attrs.x = r, this.attrs.y = n, this._clearCache(Ed);
    var a = this._getAbsoluteTransform().copy();
    return a.invert(), a.translate(e.x, e.y), e = {
      x: this.attrs.x + a.getTranslation().x,
      y: this.attrs.y + a.getTranslation().y
    }, this._setTransform(i), this.setPosition({ x: e.x, y: e.y }), this._clearCache(Ed), this._clearSelfAndDescendantCache(al), this;
  }
  _setTransform(e) {
    var r;
    for (r in e)
      this.attrs[r] = e[r];
  }
  _clearTransform() {
    var e = {
      x: this.x(),
      y: this.y(),
      rotation: this.rotation(),
      scaleX: this.scaleX(),
      scaleY: this.scaleY(),
      offsetX: this.offsetX(),
      offsetY: this.offsetY(),
      skewX: this.skewX(),
      skewY: this.skewY()
    };
    return this.attrs.x = 0, this.attrs.y = 0, this.attrs.rotation = 0, this.attrs.scaleX = 1, this.attrs.scaleY = 1, this.attrs.offsetX = 0, this.attrs.offsetY = 0, this.attrs.skewX = 0, this.attrs.skewY = 0, e;
  }
  move(e) {
    var r = e.x, n = e.y, i = this.x(), a = this.y();
    return r !== void 0 && (i += r), n !== void 0 && (a += n), this.setPosition({ x: i, y: a }), this;
  }
  _eachAncestorReverse(e, r) {
    var n = [], i = this.getParent(), a, o;
    if (!(r && r._id === this._id)) {
      for (n.unshift(this); i && (!r || i._id !== r._id); )
        n.unshift(i), i = i.parent;
      for (a = n.length, o = 0; o < a; o++)
        e(n[o]);
    }
  }
  rotate(e) {
    return this.rotation(this.rotation() + e), this;
  }
  moveToTop() {
    if (!this.parent)
      return Vr.Util.warn("Node has no parent. moveToTop function is ignored."), !1;
    var e = this.index, r = this.parent.getChildren().length;
    return e < r - 1 ? (this.parent.children.splice(e, 1), this.parent.children.push(this), this.parent._setChildrenIndices(), !0) : !1;
  }
  moveUp() {
    if (!this.parent)
      return Vr.Util.warn("Node has no parent. moveUp function is ignored."), !1;
    var e = this.index, r = this.parent.getChildren().length;
    return e < r - 1 ? (this.parent.children.splice(e, 1), this.parent.children.splice(e + 1, 0, this), this.parent._setChildrenIndices(), !0) : !1;
  }
  moveDown() {
    if (!this.parent)
      return Vr.Util.warn("Node has no parent. moveDown function is ignored."), !1;
    var e = this.index;
    return e > 0 ? (this.parent.children.splice(e, 1), this.parent.children.splice(e - 1, 0, this), this.parent._setChildrenIndices(), !0) : !1;
  }
  moveToBottom() {
    if (!this.parent)
      return Vr.Util.warn("Node has no parent. moveToBottom function is ignored."), !1;
    var e = this.index;
    return e > 0 ? (this.parent.children.splice(e, 1), this.parent.children.unshift(this), this.parent._setChildrenIndices(), !0) : !1;
  }
  setZIndex(e) {
    if (!this.parent)
      return Vr.Util.warn("Node has no parent. zIndex parameter is ignored."), this;
    (e < 0 || e >= this.parent.children.length) && Vr.Util.warn("Unexpected value " + e + " for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to " + (this.parent.children.length - 1) + ".");
    var r = this.index;
    return this.parent.children.splice(r, 1), this.parent.children.splice(e, 0, this), this.parent._setChildrenIndices(), this;
  }
  getAbsoluteOpacity() {
    return this._getCache(p3, this._getAbsoluteOpacity);
  }
  _getAbsoluteOpacity() {
    var e = this.opacity(), r = this.getParent();
    return r && !r._isUnderCache && (e *= r.getAbsoluteOpacity()), e;
  }
  moveTo(e) {
    return this.getParent() !== e && (this._remove(), e.add(this)), this;
  }
  toObject() {
    var e = this.getAttrs(), r, n, i, a, o;
    const s = {
      attrs: {},
      className: this.getClassName()
    };
    for (r in e)
      n = e[r], o = Vr.Util.isObject(n) && !Vr.Util._isPlainObject(n) && !Vr.Util._isArray(n), !o && (i = typeof this[r] == "function" && this[r], delete e[r], a = i ? i.call(this) : null, e[r] = n, a !== n && (s.attrs[r] = n));
    return Vr.Util._prepareToStringify(s);
  }
  toJSON() {
    return JSON.stringify(this.toObject());
  }
  getParent() {
    return this.parent;
  }
  findAncestors(e, r, n) {
    var i = [];
    r && this._isMatch(e) && i.push(this);
    for (var a = this.parent; a; ) {
      if (a === n)
        return i;
      a._isMatch(e) && i.push(a), a = a.parent;
    }
    return i;
  }
  isAncestorOf(e) {
    return !1;
  }
  findAncestor(e, r, n) {
    return this.findAncestors(e, r, n)[0];
  }
  _isMatch(e) {
    if (!e)
      return !1;
    if (typeof e == "function")
      return e(this);
    var r = e.replace(/ /g, "").split(","), n = r.length, i, a;
    for (i = 0; i < n; i++)
      if (a = r[i], Vr.Util.isValidSelector(a) || (Vr.Util.warn('Selector "' + a + '" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'), Vr.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'), Vr.Util.warn("Konva is awesome, right?")), a.charAt(0) === "#") {
        if (this.id() === a.slice(1))
          return !0;
      } else if (a.charAt(0) === ".") {
        if (this.hasName(a.slice(1)))
          return !0;
      } else if (this.className === a || this.nodeType === a)
        return !0;
    return !1;
  }
  getLayer() {
    var e = this.getParent();
    return e ? e.getLayer() : null;
  }
  getStage() {
    return this._getCache(WB, this._getStage);
  }
  _getStage() {
    var e = this.getParent();
    return e ? e.getStage() : null;
  }
  fire(e, r = {}, n) {
    return r.target = r.target || this, n ? this._fireAndBubble(e, r) : this._fire(e, r), this;
  }
  getAbsoluteTransform(e) {
    return e ? this._getAbsoluteTransform(e) : this._getCache(al, this._getAbsoluteTransform);
  }
  _getAbsoluteTransform(e) {
    var r;
    if (e)
      return r = new Vr.Transform(), this._eachAncestorReverse(function(i) {
        var a = i.transformsEnabled();
        a === "all" ? r.multiply(i.getTransform()) : a === "position" && r.translate(i.x() - i.offsetX(), i.y() - i.offsetY());
      }, e), r;
    r = this._cache.get(al) || new Vr.Transform(), this.parent ? this.parent.getAbsoluteTransform().copyInto(r) : r.reset();
    var n = this.transformsEnabled();
    if (n === "all")
      r.multiply(this.getTransform());
    else if (n === "position") {
      const i = this.attrs.x || 0, a = this.attrs.y || 0, o = this.attrs.offsetX || 0, s = this.attrs.offsetY || 0;
      r.translate(i - o, a - s);
    }
    return r.dirty = !1, r;
  }
  getAbsoluteScale(e) {
    for (var r = this; r; )
      r._isUnderCache && (e = r), r = r.getParent();
    const i = this.getAbsoluteTransform(e).decompose();
    return {
      x: i.scaleX,
      y: i.scaleY
    };
  }
  getAbsoluteRotation() {
    return this.getAbsoluteTransform().decompose().rotation;
  }
  getTransform() {
    return this._getCache(Ed, this._getTransform);
  }
  _getTransform() {
    var e, r, n = this._cache.get(Ed) || new Vr.Transform();
    n.reset();
    var i = this.x(), a = this.y(), o = wd.Konva.getAngle(this.rotation()), s = (e = this.attrs.scaleX) !== null && e !== void 0 ? e : 1, u = (r = this.attrs.scaleY) !== null && r !== void 0 ? r : 1, c = this.attrs.skewX || 0, l = this.attrs.skewY || 0, d = this.attrs.offsetX || 0, f = this.attrs.offsetY || 0;
    return (i !== 0 || a !== 0) && n.translate(i, a), o !== 0 && n.rotate(o), (c !== 0 || l !== 0) && n.skew(c, l), (s !== 1 || u !== 1) && n.scale(s, u), (d !== 0 || f !== 0) && n.translate(-1 * d, -1 * f), n.dirty = !1, n;
  }
  clone(e) {
    var r = Vr.Util.cloneObject(this.attrs), n, i, a, o, s;
    for (n in e)
      r[n] = e[n];
    var u = new this.constructor(r);
    for (n in this.eventListeners)
      for (i = this.eventListeners[n], a = i.length, o = 0; o < a; o++)
        s = i[o], s.name.indexOf(tve) < 0 && (u.eventListeners[n] || (u.eventListeners[n] = []), u.eventListeners[n].push(s));
    return u;
  }
  _toKonvaCanvas(e) {
    e = e || {};
    var r = this.getClientRect(), n = this.getStage(), i = e.x !== void 0 ? e.x : Math.floor(r.x), a = e.y !== void 0 ? e.y : Math.floor(r.y), o = e.pixelRatio || 1, s = new om.SceneCanvas({
      width: e.width || Math.ceil(r.width) || (n ? n.width() : 0),
      height: e.height || Math.ceil(r.height) || (n ? n.height() : 0),
      pixelRatio: o
    }), u = s.getContext();
    const c = new om.SceneCanvas({
      width: s.width / s.pixelRatio + Math.abs(i),
      height: s.height / s.pixelRatio + Math.abs(a),
      pixelRatio: s.pixelRatio
    });
    return e.imageSmoothingEnabled === !1 && (u._context.imageSmoothingEnabled = !1), u.save(), (i || a) && u.translate(-1 * i, -1 * a), this.drawScene(s, void 0, c), u.restore(), s;
  }
  toCanvas(e) {
    return this._toKonvaCanvas(e)._canvas;
  }
  toDataURL(e) {
    e = e || {};
    var r = e.mimeType || null, n = e.quality || null, i = this._toKonvaCanvas(e).toDataURL(r, n);
    return e.callback && e.callback(i), i;
  }
  toImage(e) {
    return new Promise((r, n) => {
      try {
        const i = e == null ? void 0 : e.callback;
        i && delete e.callback, Vr.Util._urlToImage(this.toDataURL(e), function(a) {
          r(a), i == null || i(a);
        });
      } catch (i) {
        n(i);
      }
    });
  }
  toBlob(e) {
    return new Promise((r, n) => {
      try {
        const i = e == null ? void 0 : e.callback;
        i && delete e.callback, this.toCanvas(e).toBlob((a) => {
          r(a), i == null || i(a);
        }, e == null ? void 0 : e.mimeType, e == null ? void 0 : e.quality);
      } catch (i) {
        n(i);
      }
    });
  }
  setSize(e) {
    return this.width(e.width), this.height(e.height), this;
  }
  getSize() {
    return {
      width: this.width(),
      height: this.height()
    };
  }
  getClassName() {
    return this.className || this.nodeType;
  }
  getType() {
    return this.nodeType;
  }
  getDragDistance() {
    return this.attrs.dragDistance !== void 0 ? this.attrs.dragDistance : this.parent ? this.parent.getDragDistance() : wd.Konva.dragDistance;
  }
  _off(e, r, n) {
    var i = this.eventListeners[e], a, o, s;
    for (a = 0; a < i.length; a++)
      if (o = i[a].name, s = i[a].handler, (o !== "konva" || r === "konva") && (!r || o === r) && (!n || n === s)) {
        if (i.splice(a, 1), i.length === 0) {
          delete this.eventListeners[e];
          break;
        }
        a--;
      }
  }
  _fireChangeEvent(e, r, n) {
    this._fire(e + $ge, {
      oldVal: r,
      newVal: n
    });
  }
  addName(e) {
    if (!this.hasName(e)) {
      var r = this.name(), n = r ? r + " " + e : e;
      this.name(n);
    }
    return this;
  }
  hasName(e) {
    if (!e)
      return !1;
    const r = this.name();
    if (!r)
      return !1;
    var n = (r || "").split(/\s/g);
    return n.indexOf(e) !== -1;
  }
  removeName(e) {
    var r = (this.name() || "").split(/\s/g), n = r.indexOf(e);
    return n !== -1 && (r.splice(n, 1), this.name(r.join(" "))), this;
  }
  setAttr(e, r) {
    var n = this[XB + Vr.Util._capitalize(e)];
    return Vr.Util._isFunction(n) ? n.call(this, r) : this._setAttr(e, r), this;
  }
  _requestDraw() {
    if (wd.Konva.autoDrawEnabled) {
      const e = this.getLayer() || this.getStage();
      e == null || e.batchDraw();
    }
  }
  _setAttr(e, r) {
    var n = this.attrs[e];
    n === r && !Vr.Util.isObject(r) || (r == null ? delete this.attrs[e] : this.attrs[e] = r, this._shouldFireChangeEvents && this._fireChangeEvent(e, n, r), this._requestDraw());
  }
  _setComponentAttr(e, r, n) {
    var i;
    n !== void 0 && (i = this.attrs[e], i || (this.attrs[e] = this.getAttr(e)), this.attrs[e][r] = n, this._fireChangeEvent(e, i, n));
  }
  _fireAndBubble(e, r, n) {
    r && this.nodeType === YB && (r.target = this);
    var i = (e === qB || e === KB) && (n && (this === n || this.isAncestorOf && this.isAncestorOf(n)) || this.nodeType === "Stage" && !n);
    if (!i) {
      this._fire(e, r);
      var a = (e === qB || e === KB) && n && n.isAncestorOf && n.isAncestorOf(this) && !n.isAncestorOf(this.parent);
      (r && !r.cancelBubble || !r) && this.parent && this.parent.isListening() && !a && (n && n.parent ? this._fireAndBubble.call(this.parent, e, r, n) : this._fireAndBubble.call(this.parent, e, r));
    }
  }
  _getProtoListeners(e) {
    var r, n, i;
    const a = (r = this._cache.get(Kv)) !== null && r !== void 0 ? r : {};
    let o = a == null ? void 0 : a[e];
    if (o === void 0) {
      o = [];
      let s = Object.getPrototypeOf(this);
      for (; s; ) {
        const u = (i = (n = s.eventListeners) === null || n === void 0 ? void 0 : n[e]) !== null && i !== void 0 ? i : [];
        o.push(...u), s = Object.getPrototypeOf(s);
      }
      a[e] = o, this._cache.set(Kv, a);
    }
    return o;
  }
  _fire(e, r) {
    r = r || {}, r.currentTarget = this, r.type = e;
    const n = this._getProtoListeners(e);
    if (n)
      for (var i = 0; i < n.length; i++)
        n[i].handler.call(this, r);
    const a = this.eventListeners[e];
    if (a)
      for (var i = 0; i < a.length; i++)
        a[i].handler.call(this, r);
  }
  draw() {
    return this.drawScene(), this.drawHit(), this;
  }
  _createDragElement(e) {
    var r = e ? e.pointerId : void 0, n = this.getStage(), i = this.getAbsolutePosition();
    if (n) {
      var a = n._getPointerById(r) || n._changedPointerPositions[0] || i;
      Hs.DD._dragElements.set(this._id, {
        node: this,
        startPointerPos: a,
        offset: {
          x: a.x - i.x,
          y: a.y - i.y
        },
        dragStatus: "ready",
        pointerId: r
      });
    }
  }
  startDrag(e, r = !0) {
    Hs.DD._dragElements.has(this._id) || this._createDragElement(e);
    const n = Hs.DD._dragElements.get(this._id);
    n.dragStatus = "dragging", this.fire("dragstart", {
      type: "dragstart",
      target: this,
      evt: e && e.evt
    }, r);
  }
  _setDragPosition(e, r) {
    const n = this.getStage()._getPointerById(r.pointerId);
    if (n) {
      var i = {
        x: n.x - r.offset.x,
        y: n.y - r.offset.y
      }, a = this.dragBoundFunc();
      if (a !== void 0) {
        const o = a.call(this, i, e);
        o ? i = o : Vr.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.");
      }
      (!this._lastPos || this._lastPos.x !== i.x || this._lastPos.y !== i.y) && (this.setAbsolutePosition(i), this._requestDraw()), this._lastPos = i;
    }
  }
  stopDrag(e) {
    const r = Hs.DD._dragElements.get(this._id);
    r && (r.dragStatus = "stopped"), Hs.DD._endDragBefore(e), Hs.DD._endDragAfter(e);
  }
  setDraggable(e) {
    this._setAttr("draggable", e), this._dragChange();
  }
  isDragging() {
    const e = Hs.DD._dragElements.get(this._id);
    return e ? e.dragStatus === "dragging" : !1;
  }
  _listenDrag() {
    this._dragCleanup(), this.on("mousedown.konva touchstart.konva", function(e) {
      var r = e.evt.button !== void 0, n = !r || wd.Konva.dragButtons.indexOf(e.evt.button) >= 0;
      if (n && !this.isDragging()) {
        var i = !1;
        Hs.DD._dragElements.forEach((a) => {
          this.isAncestorOf(a.node) && (i = !0);
        }), i || this._createDragElement(e);
      }
    });
  }
  _dragChange() {
    if (this.attrs.draggable)
      this._listenDrag();
    else {
      this._dragCleanup();
      var e = this.getStage();
      if (!e)
        return;
      const r = Hs.DD._dragElements.get(this._id), n = r && r.dragStatus === "dragging", i = r && r.dragStatus === "ready";
      n ? this.stopDrag() : i && Hs.DD._dragElements.delete(this._id);
    }
  }
  _dragCleanup() {
    this.off("mousedown.konva"), this.off("touchstart.konva");
  }
  isClientRectOnScreen(e = { x: 0, y: 0 }) {
    const r = this.getStage();
    if (!r)
      return !1;
    const n = {
      x: -e.x,
      y: -e.y,
      width: r.width() + 2 * e.x,
      height: r.height() + 2 * e.y
    };
    return Vr.Util.haveIntersection(n, this.getClientRect());
  }
  static create(e, r) {
    return Vr.Util._isString(e) && (e = JSON.parse(e)), this._createNode(e, r);
  }
  static _createNode(e, r) {
    var n = fr.prototype.getClassName.call(e), i = e.children, a, o, s;
    r && (e.attrs.container = r), wd.Konva[n] || (Vr.Util.warn('Can not find a node with class name "' + n + '". Fallback to "Shape".'), n = "Shape");
    const u = wd.Konva[n];
    if (a = new u(e.attrs), i)
      for (o = i.length, s = 0; s < o; s++)
        a.add(fr._createNode(i[s]));
    return a;
  }
}
si.Node = fr;
fr.prototype.nodeType = "Node";
fr.prototype._attrsAffectingSize = [];
fr.prototype.eventListeners = {};
fr.prototype.on.call(fr.prototype, nve, function() {
  if (this._batchingTransformChange) {
    this._needClearTransformCache = !0;
    return;
  }
  this._clearCache(Ed), this._clearSelfAndDescendantCache(al);
});
fr.prototype.on.call(fr.prototype, "visibleChange.konva", function() {
  this._clearSelfAndDescendantCache(A9);
});
fr.prototype.on.call(fr.prototype, "listeningChange.konva", function() {
  this._clearSelfAndDescendantCache(C9);
});
fr.prototype.on.call(fr.prototype, "opacityChange.konva", function() {
  this._clearSelfAndDescendantCache(p3);
});
const Un = B2.Factory.addGetterSetter;
Un(fr, "zIndex");
Un(fr, "absolutePosition");
Un(fr, "position");
Un(fr, "x", 0, (0, Li.getNumberValidator)());
Un(fr, "y", 0, (0, Li.getNumberValidator)());
Un(fr, "globalCompositeOperation", "source-over", (0, Li.getStringValidator)());
Un(fr, "opacity", 1, (0, Li.getNumberValidator)());
Un(fr, "name", "", (0, Li.getStringValidator)());
Un(fr, "id", "", (0, Li.getStringValidator)());
Un(fr, "rotation", 0, (0, Li.getNumberValidator)());
B2.Factory.addComponentsGetterSetter(fr, "scale", ["x", "y"]);
Un(fr, "scaleX", 1, (0, Li.getNumberValidator)());
Un(fr, "scaleY", 1, (0, Li.getNumberValidator)());
B2.Factory.addComponentsGetterSetter(fr, "skew", ["x", "y"]);
Un(fr, "skewX", 0, (0, Li.getNumberValidator)());
Un(fr, "skewY", 0, (0, Li.getNumberValidator)());
B2.Factory.addComponentsGetterSetter(fr, "offset", ["x", "y"]);
Un(fr, "offsetX", 0, (0, Li.getNumberValidator)());
Un(fr, "offsetY", 0, (0, Li.getNumberValidator)());
Un(fr, "dragDistance", null, (0, Li.getNumberValidator)());
Un(fr, "width", 0, (0, Li.getNumberValidator)());
Un(fr, "height", 0, (0, Li.getNumberValidator)());
Un(fr, "listening", !0, (0, Li.getBooleanValidator)());
Un(fr, "preventDefault", !0, (0, Li.getBooleanValidator)());
Un(fr, "filters", null, function(t) {
  return this._filterUpToDate = !1, t;
});
Un(fr, "visible", !0, (0, Li.getBooleanValidator)());
Un(fr, "transformsEnabled", "all", (0, Li.getStringValidator)());
Un(fr, "size");
Un(fr, "dragBoundFunc");
Un(fr, "draggable", !1, (0, Li.getBooleanValidator)());
B2.Factory.backCompat(fr, {
  rotateDeg: "rotate",
  setRotationDeg: "setRotation",
  getRotationDeg: "getRotation"
});
var K0 = {};
Object.defineProperty(K0, "__esModule", { value: !0 });
K0.Container = void 0;
const ah = Fr, Q8 = si, D4 = Ot;
class X0 extends Q8.Node {
  constructor() {
    super(...arguments), this.children = [];
  }
  getChildren(e) {
    if (!e)
      return this.children || [];
    const r = this.children || [];
    var n = [];
    return r.forEach(function(i) {
      e(i) && n.push(i);
    }), n;
  }
  hasChildren() {
    return this.getChildren().length > 0;
  }
  removeChildren() {
    return this.getChildren().forEach((e) => {
      e.parent = null, e.index = 0, e.remove();
    }), this.children = [], this._requestDraw(), this;
  }
  destroyChildren() {
    return this.getChildren().forEach((e) => {
      e.parent = null, e.index = 0, e.destroy();
    }), this.children = [], this._requestDraw(), this;
  }
  add(...e) {
    if (e.length === 0)
      return this;
    if (e.length > 1) {
      for (var r = 0; r < e.length; r++)
        this.add(e[r]);
      return this;
    }
    const n = e[0];
    return n.getParent() ? (n.moveTo(this), this) : (this._validateAdd(n), n.index = this.getChildren().length, n.parent = this, n._clearCaches(), this.getChildren().push(n), this._fire("add", {
      child: n
    }), this._requestDraw(), this);
  }
  destroy() {
    return this.hasChildren() && this.destroyChildren(), super.destroy(), this;
  }
  find(e) {
    return this._generalFind(e, !1);
  }
  findOne(e) {
    var r = this._generalFind(e, !0);
    return r.length > 0 ? r[0] : void 0;
  }
  _generalFind(e, r) {
    var n = [];
    return this._descendants((i) => {
      const a = i._isMatch(e);
      return a && n.push(i), !!(a && r);
    }), n;
  }
  _descendants(e) {
    let r = !1;
    const n = this.getChildren();
    for (const i of n) {
      if (r = e(i), r)
        return !0;
      if (i.hasChildren() && (r = i._descendants(e), r))
        return !0;
    }
    return !1;
  }
  toObject() {
    var e = Q8.Node.prototype.toObject.call(this);
    return e.children = [], this.getChildren().forEach((r) => {
      e.children.push(r.toObject());
    }), e;
  }
  isAncestorOf(e) {
    for (var r = e.getParent(); r; ) {
      if (r._id === this._id)
        return !0;
      r = r.getParent();
    }
    return !1;
  }
  clone(e) {
    var r = Q8.Node.prototype.clone.call(this, e);
    return this.getChildren().forEach(function(n) {
      r.add(n.clone());
    }), r;
  }
  getAllIntersections(e) {
    var r = [];
    return this.find("Shape").forEach((n) => {
      n.isVisible() && n.intersects(e) && r.push(n);
    }), r;
  }
  _clearSelfAndDescendantCache(e) {
    var r;
    super._clearSelfAndDescendantCache(e), !this.isCached() && ((r = this.children) === null || r === void 0 || r.forEach(function(n) {
      n._clearSelfAndDescendantCache(e);
    }));
  }
  _setChildrenIndices() {
    var e;
    (e = this.children) === null || e === void 0 || e.forEach(function(r, n) {
      r.index = n;
    }), this._requestDraw();
  }
  drawScene(e, r, n) {
    var i = this.getLayer(), a = e || i && i.getCanvas(), o = a && a.getContext(), s = this._getCanvasCache(), u = s && s.scene, c = a && a.isCache;
    if (!this.isVisible() && !c)
      return this;
    if (u) {
      o.save();
      var l = this.getAbsoluteTransform(r).getMatrix();
      o.transform(l[0], l[1], l[2], l[3], l[4], l[5]), this._drawCachedSceneCanvas(o), o.restore();
    } else
      this._drawChildren("drawScene", a, r, n);
    return this;
  }
  drawHit(e, r) {
    if (!this.shouldDrawHit(r))
      return this;
    var n = this.getLayer(), i = e || n && n.hitCanvas, a = i && i.getContext(), o = this._getCanvasCache(), s = o && o.hit;
    if (s) {
      a.save();
      var u = this.getAbsoluteTransform(r).getMatrix();
      a.transform(u[0], u[1], u[2], u[3], u[4], u[5]), this._drawCachedHitCanvas(a), a.restore();
    } else
      this._drawChildren("drawHit", i, r);
    return this;
  }
  _drawChildren(e, r, n, i) {
    var a, o = r && r.getContext(), s = this.clipWidth(), u = this.clipHeight(), c = this.clipFunc(), l = typeof s == "number" && typeof u == "number" || c;
    const d = n === this;
    if (l) {
      o.save();
      var f = this.getAbsoluteTransform(n), h = f.getMatrix();
      o.transform(h[0], h[1], h[2], h[3], h[4], h[5]), o.beginPath();
      let g;
      if (c)
        g = c.call(this, o, this);
      else {
        var m = this.clipX(), p = this.clipY();
        o.rect(m || 0, p || 0, s, u);
      }
      o.clip.apply(o, g), h = f.copy().invert().getMatrix(), o.transform(h[0], h[1], h[2], h[3], h[4], h[5]);
    }
    var v = !d && this.globalCompositeOperation() !== "source-over" && e === "drawScene";
    v && (o.save(), o._applyGlobalCompositeOperation(this)), (a = this.children) === null || a === void 0 || a.forEach(function(g) {
      g[e](r, n, i);
    }), v && o.restore(), l && o.restore();
  }
  getClientRect(e = {}) {
    var r, n = e.skipTransform, i = e.relativeTo, a, o, s, u, c = {
      x: 1 / 0,
      y: 1 / 0,
      width: 0,
      height: 0
    }, l = this;
    (r = this.children) === null || r === void 0 || r.forEach(function(p) {
      if (p.visible()) {
        var v = p.getClientRect({
          relativeTo: l,
          skipShadow: e.skipShadow,
          skipStroke: e.skipStroke
        });
        v.width === 0 && v.height === 0 || (a === void 0 ? (a = v.x, o = v.y, s = v.x + v.width, u = v.y + v.height) : (a = Math.min(a, v.x), o = Math.min(o, v.y), s = Math.max(s, v.x + v.width), u = Math.max(u, v.y + v.height)));
      }
    });
    for (var d = this.find("Shape"), f = !1, h = 0; h < d.length; h++) {
      var m = d[h];
      if (m._isVisible(this)) {
        f = !0;
        break;
      }
    }
    return f && a !== void 0 ? c = {
      x: a,
      y: o,
      width: s - a,
      height: u - o
    } : c = {
      x: 0,
      y: 0,
      width: 0,
      height: 0
    }, n ? c : this._transformedRect(c, i);
  }
}
K0.Container = X0;
ah.Factory.addComponentsGetterSetter(X0, "clip", [
  "x",
  "y",
  "width",
  "height"
]);
ah.Factory.addGetterSetter(X0, "clipX", void 0, (0, D4.getNumberValidator)());
ah.Factory.addGetterSetter(X0, "clipY", void 0, (0, D4.getNumberValidator)());
ah.Factory.addGetterSetter(X0, "clipWidth", void 0, (0, D4.getNumberValidator)());
ah.Factory.addGetterSetter(X0, "clipHeight", void 0, (0, D4.getNumberValidator)());
ah.Factory.addGetterSetter(X0, "clipFunc");
var Oz = {}, ps = {};
Object.defineProperty(ps, "__esModule", { value: !0 });
ps.releaseCapture = ps.setPointerCapture = ps.hasPointerCapture = ps.createEvent = ps.getCapturedShape = void 0;
const ave = Br, l2 = /* @__PURE__ */ new Map(), Lz = ave.Konva._global.PointerEvent !== void 0;
function ove(t) {
  return l2.get(t);
}
ps.getCapturedShape = ove;
function mS(t) {
  return {
    evt: t,
    pointerId: t.pointerId
  };
}
ps.createEvent = mS;
function sve(t, e) {
  return l2.get(t) === e;
}
ps.hasPointerCapture = sve;
function uve(t, e) {
  kz(t), e.getStage() && (l2.set(t, e), Lz && e._fire("gotpointercapture", mS(new PointerEvent("gotpointercapture"))));
}
ps.setPointerCapture = uve;
function kz(t, e) {
  const r = l2.get(t);
  if (!r)
    return;
  const n = r.getStage();
  n && n.content, l2.delete(t), Lz && r._fire("lostpointercapture", mS(new PointerEvent("lostpointercapture")));
}
ps.releaseCapture = kz;
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t.Stage = t.stages = void 0;
  const e = vi, r = Fr, n = K0, i = Br, a = Lu, o = w4, s = Br, u = ps;
  var c = "Stage", l = "string", d = "px", f = "mouseout", h = "mouseleave", m = "mouseover", p = "mouseenter", v = "mousemove", g = "mousedown", y = "mouseup", b = "pointermove", S = "pointerdown", _ = "pointerup", x = "pointercancel", C = "lostpointercapture", A = "pointerout", w = "pointerleave", I = "pointerover", P = "pointerenter", M = "contextmenu", T = "touchstart", F = "touchend", N = "touchmove", R = "touchcancel", L = "wheel", V = 5, U = [
    [p, "_pointerenter"],
    [g, "_pointerdown"],
    [v, "_pointermove"],
    [y, "_pointerup"],
    [h, "_pointerleave"],
    [T, "_pointerdown"],
    [N, "_pointermove"],
    [F, "_pointerup"],
    [R, "_pointercancel"],
    [m, "_pointerover"],
    [L, "_wheel"],
    [M, "_contextmenu"],
    [S, "_pointerdown"],
    [b, "_pointermove"],
    [_, "_pointerup"],
    [x, "_pointercancel"],
    [C, "_lostpointercapture"]
  ];
  const H = {
    mouse: {
      [A]: f,
      [w]: h,
      [I]: m,
      [P]: p,
      [b]: v,
      [S]: g,
      [_]: y,
      [x]: "mousecancel",
      pointerclick: "click",
      pointerdblclick: "dblclick"
    },
    touch: {
      [A]: "touchout",
      [w]: "touchleave",
      [I]: "touchover",
      [P]: "touchenter",
      [b]: N,
      [S]: T,
      [_]: F,
      [x]: R,
      pointerclick: "tap",
      pointerdblclick: "dbltap"
    },
    pointer: {
      [A]: A,
      [w]: w,
      [I]: I,
      [P]: P,
      [b]: b,
      [S]: S,
      [_]: _,
      [x]: x,
      pointerclick: "pointerclick",
      pointerdblclick: "pointerdblclick"
    }
  }, K = (te) => te.indexOf("pointer") >= 0 ? "pointer" : te.indexOf("touch") >= 0 ? "touch" : "mouse", X = (te) => {
    const W = K(te);
    if (W === "pointer")
      return i.Konva.pointerEventsEnabled && H.pointer;
    if (W === "touch")
      return H.touch;
    if (W === "mouse")
      return H.mouse;
  };
  function Y(te = {}) {
    return (te.clipFunc || te.clipWidth || te.clipHeight) && e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."), te;
  }
  const Q = "Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";
  t.stages = [];
  class J extends n.Container {
    constructor(W) {
      super(Y(W)), this._pointerPositions = [], this._changedPointerPositions = [], this._buildDOM(), this._bindContentEvents(), t.stages.push(this), this.on("widthChange.konva heightChange.konva", this._resizeDOM), this.on("visibleChange.konva", this._checkVisibility), this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva", () => {
        Y(this.attrs);
      }), this._checkVisibility();
    }
    _validateAdd(W) {
      const j = W.getType() === "Layer", ee = W.getType() === "FastLayer";
      j || ee || e.Util.throw("You may only add layers to the stage.");
    }
    _checkVisibility() {
      if (!this.content)
        return;
      const W = this.visible() ? "" : "none";
      this.content.style.display = W;
    }
    setContainer(W) {
      if (typeof W === l) {
        if (W.charAt(0) === ".") {
          var j = W.slice(1);
          W = document.getElementsByClassName(j)[0];
        } else {
          var ee;
          W.charAt(0) !== "#" ? ee = W : ee = W.slice(1), W = document.getElementById(ee);
        }
        if (!W)
          throw "Can not find container in document with id " + ee;
      }
      return this._setAttr("container", W), this.content && (this.content.parentElement && this.content.parentElement.removeChild(this.content), W.appendChild(this.content)), this;
    }
    shouldDrawHit() {
      return !0;
    }
    clear() {
      var W = this.children, j = W.length, ee;
      for (ee = 0; ee < j; ee++)
        W[ee].clear();
      return this;
    }
    clone(W) {
      return W || (W = {}), W.container = typeof document < "u" && document.createElement("div"), n.Container.prototype.clone.call(this, W);
    }
    destroy() {
      super.destroy();
      var W = this.content;
      W && e.Util._isInDocument(W) && this.container().removeChild(W);
      var j = t.stages.indexOf(this);
      return j > -1 && t.stages.splice(j, 1), e.Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas), this;
    }
    getPointerPosition() {
      const W = this._pointerPositions[0] || this._changedPointerPositions[0];
      return W ? {
        x: W.x,
        y: W.y
      } : (e.Util.warn(Q), null);
    }
    _getPointerById(W) {
      return this._pointerPositions.find((j) => j.id === W);
    }
    getPointersPositions() {
      return this._pointerPositions;
    }
    getStage() {
      return this;
    }
    getContent() {
      return this.content;
    }
    _toKonvaCanvas(W) {
      W = W || {}, W.x = W.x || 0, W.y = W.y || 0, W.width = W.width || this.width(), W.height = W.height || this.height();
      var j = new a.SceneCanvas({
        width: W.width,
        height: W.height,
        pixelRatio: W.pixelRatio || 1
      }), ee = j.getContext()._context, ie = this.children;
      return (W.x || W.y) && ee.translate(-1 * W.x, -1 * W.y), ie.forEach(function(ae) {
        if (ae.isVisible()) {
          var ce = ae._toKonvaCanvas(W);
          ee.drawImage(ce._canvas, W.x, W.y, ce.getWidth() / ce.getPixelRatio(), ce.getHeight() / ce.getPixelRatio());
        }
      }), j;
    }
    getIntersection(W) {
      if (!W)
        return null;
      var j = this.children, ee = j.length, ie = ee - 1, ae;
      for (ae = ie; ae >= 0; ae--) {
        const ce = j[ae].getIntersection(W);
        if (ce)
          return ce;
      }
      return null;
    }
    _resizeDOM() {
      var W = this.width(), j = this.height();
      this.content && (this.content.style.width = W + d, this.content.style.height = j + d), this.bufferCanvas.setSize(W, j), this.bufferHitCanvas.setSize(W, j), this.children.forEach((ee) => {
        ee.setSize({ width: W, height: j }), ee.draw();
      });
    }
    add(W, ...j) {
      if (arguments.length > 1) {
        for (var ee = 0; ee < arguments.length; ee++)
          this.add(arguments[ee]);
        return this;
      }
      super.add(W);
      var ie = this.children.length;
      return ie > V && e.Util.warn("The stage has " + ie + " layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."), W.setSize({ width: this.width(), height: this.height() }), W.draw(), i.Konva.isBrowser && this.content.appendChild(W.canvas._canvas), this;
    }
    getParent() {
      return null;
    }
    getLayer() {
      return null;
    }
    hasPointerCapture(W) {
      return u.hasPointerCapture(W, this);
    }
    setPointerCapture(W) {
      u.setPointerCapture(W, this);
    }
    releaseCapture(W) {
      u.releaseCapture(W, this);
    }
    getLayers() {
      return this.children;
    }
    _bindContentEvents() {
      i.Konva.isBrowser && U.forEach(([W, j]) => {
        this.content.addEventListener(W, (ee) => {
          this[j](ee);
        }, { passive: !1 });
      });
    }
    _pointerenter(W) {
      this.setPointersPositions(W);
      const j = X(W.type);
      j && this._fire(j.pointerenter, {
        evt: W,
        target: this,
        currentTarget: this
      });
    }
    _pointerover(W) {
      this.setPointersPositions(W);
      const j = X(W.type);
      j && this._fire(j.pointerover, {
        evt: W,
        target: this,
        currentTarget: this
      });
    }
    _getTargetShape(W) {
      let j = this[W + "targetShape"];
      return j && !j.getStage() && (j = null), j;
    }
    _pointerleave(W) {
      const j = X(W.type), ee = K(W.type);
      if (j) {
        this.setPointersPositions(W);
        var ie = this._getTargetShape(ee), ae = !(i.Konva.isDragging() || i.Konva.isTransforming()) || i.Konva.hitOnDragEnabled;
        ie && ae ? (ie._fireAndBubble(j.pointerout, { evt: W }), ie._fireAndBubble(j.pointerleave, { evt: W }), this._fire(j.pointerleave, {
          evt: W,
          target: this,
          currentTarget: this
        }), this[ee + "targetShape"] = null) : ae && (this._fire(j.pointerleave, {
          evt: W,
          target: this,
          currentTarget: this
        }), this._fire(j.pointerout, {
          evt: W,
          target: this,
          currentTarget: this
        })), this.pointerPos = null, this._pointerPositions = [];
      }
    }
    _pointerdown(W) {
      const j = X(W.type), ee = K(W.type);
      if (j) {
        this.setPointersPositions(W);
        var ie = !1;
        this._changedPointerPositions.forEach((ae) => {
          var ce = this.getIntersection(ae);
          if (o.DD.justDragged = !1, i.Konva["_" + ee + "ListenClick"] = !0, !ce || !ce.isListening()) {
            this[ee + "ClickStartShape"] = void 0;
            return;
          }
          i.Konva.capturePointerEventsEnabled && ce.setPointerCapture(ae.id), this[ee + "ClickStartShape"] = ce, ce._fireAndBubble(j.pointerdown, {
            evt: W,
            pointerId: ae.id
          }), ie = !0;
          const de = W.type.indexOf("touch") >= 0;
          ce.preventDefault() && W.cancelable && de && W.preventDefault();
        }), ie || this._fire(j.pointerdown, {
          evt: W,
          target: this,
          currentTarget: this,
          pointerId: this._pointerPositions[0].id
        });
      }
    }
    _pointermove(W) {
      const j = X(W.type), ee = K(W.type);
      if (!j)
        return;
      i.Konva.isDragging() && o.DD.node.preventDefault() && W.cancelable && W.preventDefault(), this.setPointersPositions(W);
      var ie = !(i.Konva.isDragging() || i.Konva.isTransforming()) || i.Konva.hitOnDragEnabled;
      if (!ie)
        return;
      var ae = {};
      let ce = !1;
      var de = this._getTargetShape(ee);
      this._changedPointerPositions.forEach((Ce) => {
        const De = u.getCapturedShape(Ce.id) || this.getIntersection(Ce), ke = Ce.id, He = { evt: W, pointerId: ke };
        var We = de !== De;
        if (We && de && (de._fireAndBubble(j.pointerout, { ...He }, De), de._fireAndBubble(j.pointerleave, { ...He }, De)), De) {
          if (ae[De._id])
            return;
          ae[De._id] = !0;
        }
        De && De.isListening() ? (ce = !0, We && (De._fireAndBubble(j.pointerover, { ...He }, de), De._fireAndBubble(j.pointerenter, { ...He }, de), this[ee + "targetShape"] = De), De._fireAndBubble(j.pointermove, { ...He })) : de && (this._fire(j.pointerover, {
          evt: W,
          target: this,
          currentTarget: this,
          pointerId: ke
        }), this[ee + "targetShape"] = null);
      }), ce || this._fire(j.pointermove, {
        evt: W,
        target: this,
        currentTarget: this,
        pointerId: this._changedPointerPositions[0].id
      });
    }
    _pointerup(W) {
      const j = X(W.type), ee = K(W.type);
      if (!j)
        return;
      this.setPointersPositions(W);
      const ie = this[ee + "ClickStartShape"], ae = this[ee + "ClickEndShape"];
      var ce = {};
      let de = !1;
      this._changedPointerPositions.forEach((Ce) => {
        const De = u.getCapturedShape(Ce.id) || this.getIntersection(Ce);
        if (De) {
          if (De.releaseCapture(Ce.id), ce[De._id])
            return;
          ce[De._id] = !0;
        }
        const ke = Ce.id, He = { evt: W, pointerId: ke };
        let We = !1;
        i.Konva["_" + ee + "InDblClickWindow"] ? (We = !0, clearTimeout(this[ee + "DblTimeout"])) : o.DD.justDragged || (i.Konva["_" + ee + "InDblClickWindow"] = !0, clearTimeout(this[ee + "DblTimeout"])), this[ee + "DblTimeout"] = setTimeout(function() {
          i.Konva["_" + ee + "InDblClickWindow"] = !1;
        }, i.Konva.dblClickWindow), De && De.isListening() ? (de = !0, this[ee + "ClickEndShape"] = De, De._fireAndBubble(j.pointerup, { ...He }), i.Konva["_" + ee + "ListenClick"] && ie && ie === De && (De._fireAndBubble(j.pointerclick, { ...He }), We && ae && ae === De && De._fireAndBubble(j.pointerdblclick, { ...He }))) : (this[ee + "ClickEndShape"] = null, i.Konva["_" + ee + "ListenClick"] && this._fire(j.pointerclick, {
          evt: W,
          target: this,
          currentTarget: this,
          pointerId: ke
        }), We && this._fire(j.pointerdblclick, {
          evt: W,
          target: this,
          currentTarget: this,
          pointerId: ke
        }));
      }), de || this._fire(j.pointerup, {
        evt: W,
        target: this,
        currentTarget: this,
        pointerId: this._changedPointerPositions[0].id
      }), i.Konva["_" + ee + "ListenClick"] = !1, W.cancelable && ee !== "touch" && W.preventDefault();
    }
    _contextmenu(W) {
      this.setPointersPositions(W);
      var j = this.getIntersection(this.getPointerPosition());
      j && j.isListening() ? j._fireAndBubble(M, { evt: W }) : this._fire(M, {
        evt: W,
        target: this,
        currentTarget: this
      });
    }
    _wheel(W) {
      this.setPointersPositions(W);
      var j = this.getIntersection(this.getPointerPosition());
      j && j.isListening() ? j._fireAndBubble(L, { evt: W }) : this._fire(L, {
        evt: W,
        target: this,
        currentTarget: this
      });
    }
    _pointercancel(W) {
      this.setPointersPositions(W);
      const j = u.getCapturedShape(W.pointerId) || this.getIntersection(this.getPointerPosition());
      j && j._fireAndBubble(_, u.createEvent(W)), u.releaseCapture(W.pointerId);
    }
    _lostpointercapture(W) {
      u.releaseCapture(W.pointerId);
    }
    setPointersPositions(W) {
      var j = this._getContentPosition(), ee = null, ie = null;
      W = W || window.event, W.touches !== void 0 ? (this._pointerPositions = [], this._changedPointerPositions = [], Array.prototype.forEach.call(W.touches, (ae) => {
        this._pointerPositions.push({
          id: ae.identifier,
          x: (ae.clientX - j.left) / j.scaleX,
          y: (ae.clientY - j.top) / j.scaleY
        });
      }), Array.prototype.forEach.call(W.changedTouches || W.touches, (ae) => {
        this._changedPointerPositions.push({
          id: ae.identifier,
          x: (ae.clientX - j.left) / j.scaleX,
          y: (ae.clientY - j.top) / j.scaleY
        });
      })) : (ee = (W.clientX - j.left) / j.scaleX, ie = (W.clientY - j.top) / j.scaleY, this.pointerPos = {
        x: ee,
        y: ie
      }, this._pointerPositions = [{ x: ee, y: ie, id: e.Util._getFirstPointerId(W) }], this._changedPointerPositions = [
        { x: ee, y: ie, id: e.Util._getFirstPointerId(W) }
      ]);
    }
    _setPointerPosition(W) {
      e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'), this.setPointersPositions(W);
    }
    _getContentPosition() {
      if (!this.content || !this.content.getBoundingClientRect)
        return {
          top: 0,
          left: 0,
          scaleX: 1,
          scaleY: 1
        };
      var W = this.content.getBoundingClientRect();
      return {
        top: W.top,
        left: W.left,
        scaleX: W.width / this.content.clientWidth || 1,
        scaleY: W.height / this.content.clientHeight || 1
      };
    }
    _buildDOM() {
      if (this.bufferCanvas = new a.SceneCanvas({
        width: this.width(),
        height: this.height()
      }), this.bufferHitCanvas = new a.HitCanvas({
        pixelRatio: 1,
        width: this.width(),
        height: this.height()
      }), !!i.Konva.isBrowser) {
        var W = this.container();
        if (!W)
          throw "Stage has no container. A container is required.";
        W.innerHTML = "", this.content = document.createElement("div"), this.content.style.position = "relative", this.content.style.userSelect = "none", this.content.className = "konvajs-content", this.content.setAttribute("role", "presentation"), W.appendChild(this.content), this._resizeDOM();
      }
    }
    cache() {
      return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."), this;
    }
    clearCache() {
      return this;
    }
    batchDraw() {
      return this.getChildren().forEach(function(W) {
        W.batchDraw();
      }), this;
    }
  }
  t.Stage = J, J.prototype.nodeType = c, (0, s._registerNode)(J), r.Factory.addGetterSetter(J, "container"), i.Konva.isBrowser && document.addEventListener("visibilitychange", () => {
    t.stages.forEach((te) => {
      te.batchDraw();
    });
  });
})(Oz);
var F2 = {}, fa = {};
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t.Shape = t.shapes = void 0;
  const e = Br, r = vi, n = Fr, i = si, a = Ot, o = Br, s = ps;
  var u = "hasShadow", c = "shadowRGBA", l = "patternImage", d = "linearGradient", f = "radialGradient";
  let h;
  function m() {
    return h || (h = r.Util.createCanvasElement().getContext("2d"), h);
  }
  t.shapes = {};
  function p(w) {
    const I = this.attrs.fillRule;
    I ? w.fill(I) : w.fill();
  }
  function v(w) {
    w.stroke();
  }
  function g(w) {
    const I = this.attrs.fillRule;
    I ? w.fill(I) : w.fill();
  }
  function y(w) {
    w.stroke();
  }
  function b() {
    this._clearCache(u);
  }
  function S() {
    this._clearCache(c);
  }
  function _() {
    this._clearCache(l);
  }
  function x() {
    this._clearCache(d);
  }
  function C() {
    this._clearCache(f);
  }
  class A extends i.Node {
    constructor(I) {
      super(I);
      let P;
      for (; P = r.Util.getRandomColor(), !(P && !(P in t.shapes)); )
        ;
      this.colorKey = P, t.shapes[P] = this;
    }
    getContext() {
      return r.Util.warn("shape.getContext() method is deprecated. Please do not use it."), this.getLayer().getContext();
    }
    getCanvas() {
      return r.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."), this.getLayer().getCanvas();
    }
    getSceneFunc() {
      return this.attrs.sceneFunc || this._sceneFunc;
    }
    getHitFunc() {
      return this.attrs.hitFunc || this._hitFunc;
    }
    hasShadow() {
      return this._getCache(u, this._hasShadow);
    }
    _hasShadow() {
      return this.shadowEnabled() && this.shadowOpacity() !== 0 && !!(this.shadowColor() || this.shadowBlur() || this.shadowOffsetX() || this.shadowOffsetY());
    }
    _getFillPattern() {
      return this._getCache(l, this.__getFillPattern);
    }
    __getFillPattern() {
      if (this.fillPatternImage()) {
        var I = m();
        const P = I.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || "repeat");
        if (P && P.setTransform) {
          const M = new r.Transform();
          M.translate(this.fillPatternX(), this.fillPatternY()), M.rotate(e.Konva.getAngle(this.fillPatternRotation())), M.scale(this.fillPatternScaleX(), this.fillPatternScaleY()), M.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
          const T = M.getMatrix(), F = typeof DOMMatrix > "u" ? {
            a: T[0],
            b: T[1],
            c: T[2],
            d: T[3],
            e: T[4],
            f: T[5]
          } : new DOMMatrix(T);
          P.setTransform(F);
        }
        return P;
      }
    }
    _getLinearGradient() {
      return this._getCache(d, this.__getLinearGradient);
    }
    __getLinearGradient() {
      var I = this.fillLinearGradientColorStops();
      if (I) {
        for (var P = m(), M = this.fillLinearGradientStartPoint(), T = this.fillLinearGradientEndPoint(), F = P.createLinearGradient(M.x, M.y, T.x, T.y), N = 0; N < I.length; N += 2)
          F.addColorStop(I[N], I[N + 1]);
        return F;
      }
    }
    _getRadialGradient() {
      return this._getCache(f, this.__getRadialGradient);
    }
    __getRadialGradient() {
      var I = this.fillRadialGradientColorStops();
      if (I) {
        for (var P = m(), M = this.fillRadialGradientStartPoint(), T = this.fillRadialGradientEndPoint(), F = P.createRadialGradient(M.x, M.y, this.fillRadialGradientStartRadius(), T.x, T.y, this.fillRadialGradientEndRadius()), N = 0; N < I.length; N += 2)
          F.addColorStop(I[N], I[N + 1]);
        return F;
      }
    }
    getShadowRGBA() {
      return this._getCache(c, this._getShadowRGBA);
    }
    _getShadowRGBA() {
      if (this.hasShadow()) {
        var I = r.Util.colorToRGBA(this.shadowColor());
        if (I)
          return "rgba(" + I.r + "," + I.g + "," + I.b + "," + I.a * (this.shadowOpacity() || 1) + ")";
      }
    }
    hasFill() {
      return this._calculate("hasFill", [
        "fillEnabled",
        "fill",
        "fillPatternImage",
        "fillLinearGradientColorStops",
        "fillRadialGradientColorStops"
      ], () => this.fillEnabled() && !!(this.fill() || this.fillPatternImage() || this.fillLinearGradientColorStops() || this.fillRadialGradientColorStops()));
    }
    hasStroke() {
      return this._calculate("hasStroke", [
        "strokeEnabled",
        "strokeWidth",
        "stroke",
        "strokeLinearGradientColorStops"
      ], () => this.strokeEnabled() && this.strokeWidth() && !!(this.stroke() || this.strokeLinearGradientColorStops()));
    }
    hasHitStroke() {
      const I = this.hitStrokeWidth();
      return I === "auto" ? this.hasStroke() : this.strokeEnabled() && !!I;
    }
    intersects(I) {
      var P = this.getStage();
      if (!P)
        return !1;
      const M = P.bufferHitCanvas;
      return M.getContext().clear(), this.drawHit(M, void 0, !0), M.context.getImageData(Math.round(I.x), Math.round(I.y), 1, 1).data[3] > 0;
    }
    destroy() {
      return i.Node.prototype.destroy.call(this), delete t.shapes[this.colorKey], delete this.colorKey, this;
    }
    _useBufferCanvas(I) {
      var P;
      if (!((P = this.attrs.perfectDrawEnabled) !== null && P !== void 0 ? P : !0))
        return !1;
      const T = I || this.hasFill(), F = this.hasStroke(), N = this.getAbsoluteOpacity() !== 1;
      if (T && F && N)
        return !0;
      const R = this.hasShadow(), L = this.shadowForStrokeEnabled();
      return !!(T && F && R && L);
    }
    setStrokeHitEnabled(I) {
      r.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."), I ? this.hitStrokeWidth("auto") : this.hitStrokeWidth(0);
    }
    getStrokeHitEnabled() {
      return this.hitStrokeWidth() !== 0;
    }
    getSelfRect() {
      var I = this.size();
      return {
        x: this._centroid ? -I.width / 2 : 0,
        y: this._centroid ? -I.height / 2 : 0,
        width: I.width,
        height: I.height
      };
    }
    getClientRect(I = {}) {
      let P = !1, M = this.getParent();
      for (; M; ) {
        if (M.isCached()) {
          P = !0;
          break;
        }
        M = M.getParent();
      }
      const T = I.skipTransform, F = I.relativeTo || P && this.getStage() || void 0, N = this.getSelfRect(), L = !I.skipStroke && this.hasStroke() && this.strokeWidth() || 0, V = N.width + L, U = N.height + L, H = !I.skipShadow && this.hasShadow(), K = H ? this.shadowOffsetX() : 0, X = H ? this.shadowOffsetY() : 0, Y = V + Math.abs(K), Q = U + Math.abs(X), J = H && this.shadowBlur() || 0, te = Y + J * 2, W = Q + J * 2, j = {
        width: te,
        height: W,
        x: -(L / 2 + J) + Math.min(K, 0) + N.x,
        y: -(L / 2 + J) + Math.min(X, 0) + N.y
      };
      return T ? j : this._transformedRect(j, F);
    }
    drawScene(I, P, M) {
      var T = this.getLayer(), F = I || T.getCanvas(), N = F.getContext(), R = this._getCanvasCache(), L = this.getSceneFunc(), V = this.hasShadow(), U, H, K = F.isCache, X = P === this;
      if (!this.isVisible() && !X)
        return this;
      if (R) {
        N.save();
        var Y = this.getAbsoluteTransform(P).getMatrix();
        return N.transform(Y[0], Y[1], Y[2], Y[3], Y[4], Y[5]), this._drawCachedSceneCanvas(N), N.restore(), this;
      }
      if (!L)
        return this;
      if (N.save(), this._useBufferCanvas() && !K) {
        U = this.getStage();
        const te = M || U.bufferCanvas;
        H = te.getContext(), H.clear(), H.save(), H._applyLineJoin(this);
        var Q = this.getAbsoluteTransform(P).getMatrix();
        H.transform(Q[0], Q[1], Q[2], Q[3], Q[4], Q[5]), L.call(this, H, this), H.restore();
        var J = te.pixelRatio;
        V && N._applyShadow(this), N._applyOpacity(this), N._applyGlobalCompositeOperation(this), N.drawImage(te._canvas, 0, 0, te.width / J, te.height / J);
      } else {
        if (N._applyLineJoin(this), !X) {
          var Q = this.getAbsoluteTransform(P).getMatrix();
          N.transform(Q[0], Q[1], Q[2], Q[3], Q[4], Q[5]), N._applyOpacity(this), N._applyGlobalCompositeOperation(this);
        }
        V && N._applyShadow(this), L.call(this, N, this);
      }
      return N.restore(), this;
    }
    drawHit(I, P, M = !1) {
      if (!this.shouldDrawHit(P, M))
        return this;
      var T = this.getLayer(), F = I || T.hitCanvas, N = F && F.getContext(), R = this.hitFunc() || this.sceneFunc(), L = this._getCanvasCache(), V = L && L.hit;
      if (this.colorKey || r.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"), V) {
        N.save();
        var U = this.getAbsoluteTransform(P).getMatrix();
        return N.transform(U[0], U[1], U[2], U[3], U[4], U[5]), this._drawCachedHitCanvas(N), N.restore(), this;
      }
      if (!R)
        return this;
      if (N.save(), N._applyLineJoin(this), !(this === P)) {
        var K = this.getAbsoluteTransform(P).getMatrix();
        N.transform(K[0], K[1], K[2], K[3], K[4], K[5]);
      }
      return R.call(this, N, this), N.restore(), this;
    }
    drawHitFromCache(I = 0) {
      var P = this._getCanvasCache(), M = this._getCachedSceneCanvas(), T = P.hit, F = T.getContext(), N = T.getWidth(), R = T.getHeight(), L, V, U, H, K, X;
      F.clear(), F.drawImage(M._canvas, 0, 0, N, R);
      try {
        for (L = F.getImageData(0, 0, N, R), V = L.data, U = V.length, H = r.Util._hexToRgb(this.colorKey), K = 0; K < U; K += 4)
          X = V[K + 3], X > I ? (V[K] = H.r, V[K + 1] = H.g, V[K + 2] = H.b, V[K + 3] = 255) : V[K + 3] = 0;
        F.putImageData(L, 0, 0);
      } catch (Y) {
        r.Util.error("Unable to draw hit graph from cached scene canvas. " + Y.message);
      }
      return this;
    }
    hasPointerCapture(I) {
      return s.hasPointerCapture(I, this);
    }
    setPointerCapture(I) {
      s.setPointerCapture(I, this);
    }
    releaseCapture(I) {
      s.releaseCapture(I, this);
    }
  }
  t.Shape = A, A.prototype._fillFunc = p, A.prototype._strokeFunc = v, A.prototype._fillFuncHit = g, A.prototype._strokeFuncHit = y, A.prototype._centroid = !1, A.prototype.nodeType = "Shape", (0, o._registerNode)(A), A.prototype.eventListeners = {}, A.prototype.on.call(A.prototype, "shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva", b), A.prototype.on.call(A.prototype, "shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva", S), A.prototype.on.call(A.prototype, "fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva", _), A.prototype.on.call(A.prototype, "fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva", x), A.prototype.on.call(A.prototype, "fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva", C), n.Factory.addGetterSetter(A, "stroke", void 0, (0, a.getStringOrGradientValidator)()), n.Factory.addGetterSetter(A, "strokeWidth", 2, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "fillAfterStrokeEnabled", !1), n.Factory.addGetterSetter(A, "hitStrokeWidth", "auto", (0, a.getNumberOrAutoValidator)()), n.Factory.addGetterSetter(A, "strokeHitEnabled", !0, (0, a.getBooleanValidator)()), n.Factory.addGetterSetter(A, "perfectDrawEnabled", !0, (0, a.getBooleanValidator)()), n.Factory.addGetterSetter(A, "shadowForStrokeEnabled", !0, (0, a.getBooleanValidator)()), n.Factory.addGetterSetter(A, "lineJoin"), n.Factory.addGetterSetter(A, "lineCap"), n.Factory.addGetterSetter(A, "sceneFunc"), n.Factory.addGetterSetter(A, "hitFunc"), n.Factory.addGetterSetter(A, "dash"), n.Factory.addGetterSetter(A, "dashOffset", 0, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "shadowColor", void 0, (0, a.getStringValidator)()), n.Factory.addGetterSetter(A, "shadowBlur", 0, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "shadowOpacity", 1, (0, a.getNumberValidator)()), n.Factory.addComponentsGetterSetter(A, "shadowOffset", ["x", "y"]), n.Factory.addGetterSetter(A, "shadowOffsetX", 0, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "shadowOffsetY", 0, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "fillPatternImage"), n.Factory.addGetterSetter(A, "fill", void 0, (0, a.getStringOrGradientValidator)()), n.Factory.addGetterSetter(A, "fillPatternX", 0, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "fillPatternY", 0, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "fillLinearGradientColorStops"), n.Factory.addGetterSetter(A, "strokeLinearGradientColorStops"), n.Factory.addGetterSetter(A, "fillRadialGradientStartRadius", 0), n.Factory.addGetterSetter(A, "fillRadialGradientEndRadius", 0), n.Factory.addGetterSetter(A, "fillRadialGradientColorStops"), n.Factory.addGetterSetter(A, "fillPatternRepeat", "repeat"), n.Factory.addGetterSetter(A, "fillEnabled", !0), n.Factory.addGetterSetter(A, "strokeEnabled", !0), n.Factory.addGetterSetter(A, "shadowEnabled", !0), n.Factory.addGetterSetter(A, "dashEnabled", !0), n.Factory.addGetterSetter(A, "strokeScaleEnabled", !0), n.Factory.addGetterSetter(A, "fillPriority", "color"), n.Factory.addComponentsGetterSetter(A, "fillPatternOffset", ["x", "y"]), n.Factory.addGetterSetter(A, "fillPatternOffsetX", 0, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "fillPatternOffsetY", 0, (0, a.getNumberValidator)()), n.Factory.addComponentsGetterSetter(A, "fillPatternScale", ["x", "y"]), n.Factory.addGetterSetter(A, "fillPatternScaleX", 1, (0, a.getNumberValidator)()), n.Factory.addGetterSetter(A, "fillPatternScaleY", 1, (0, a.getNumberValidator)()), n.Factory.addComponentsGetterSetter(A, "fillLinearGradientStartPoint", [
    "x",
    "y"
  ]), n.Factory.addComponentsGetterSetter(A, "strokeLinearGradientStartPoint", [
    "x",
    "y"
  ]), n.Factory.addGetterSetter(A, "fillLinearGradientStartPointX", 0), n.Factory.addGetterSetter(A, "strokeLinearGradientStartPointX", 0), n.Factory.addGetterSetter(A, "fillLinearGradientStartPointY", 0), n.Factory.addGetterSetter(A, "strokeLinearGradientStartPointY", 0), n.Factory.addComponentsGetterSetter(A, "fillLinearGradientEndPoint", [
    "x",
    "y"
  ]), n.Factory.addComponentsGetterSetter(A, "strokeLinearGradientEndPoint", [
    "x",
    "y"
  ]), n.Factory.addGetterSetter(A, "fillLinearGradientEndPointX", 0), n.Factory.addGetterSetter(A, "strokeLinearGradientEndPointX", 0), n.Factory.addGetterSetter(A, "fillLinearGradientEndPointY", 0), n.Factory.addGetterSetter(A, "strokeLinearGradientEndPointY", 0), n.Factory.addComponentsGetterSetter(A, "fillRadialGradientStartPoint", [
    "x",
    "y"
  ]), n.Factory.addGetterSetter(A, "fillRadialGradientStartPointX", 0), n.Factory.addGetterSetter(A, "fillRadialGradientStartPointY", 0), n.Factory.addComponentsGetterSetter(A, "fillRadialGradientEndPoint", [
    "x",
    "y"
  ]), n.Factory.addGetterSetter(A, "fillRadialGradientEndPointX", 0), n.Factory.addGetterSetter(A, "fillRadialGradientEndPointY", 0), n.Factory.addGetterSetter(A, "fillPatternRotation", 0), n.Factory.addGetterSetter(A, "fillRule", void 0, (0, a.getStringValidator)()), n.Factory.backCompat(A, {
    dashArray: "dash",
    getDashArray: "getDash",
    setDashArray: "getDash",
    drawFunc: "sceneFunc",
    getDrawFunc: "getSceneFunc",
    setDrawFunc: "setSceneFunc",
    drawHitFunc: "hitFunc",
    getDrawHitFunc: "getHitFunc",
    setDrawHitFunc: "setHitFunc"
  });
})(fa);
Object.defineProperty(F2, "__esModule", { value: !0 });
F2.Layer = void 0;
const rl = vi, J8 = K0, j1 = si, gS = Fr, jB = Lu, cve = Ot, lve = fa, dve = Br;
var fve = "#", pve = "beforeDraw", hve = "draw", Gz = [
  { x: 0, y: 0 },
  { x: -1, y: -1 },
  { x: 1, y: -1 },
  { x: 1, y: 1 },
  { x: -1, y: 1 }
], mve = Gz.length;
class oh extends J8.Container {
  constructor(e) {
    super(e), this.canvas = new jB.SceneCanvas(), this.hitCanvas = new jB.HitCanvas({
      pixelRatio: 1
    }), this._waitingForDraw = !1, this.on("visibleChange.konva", this._checkVisibility), this._checkVisibility(), this.on("imageSmoothingEnabledChange.konva", this._setSmoothEnabled), this._setSmoothEnabled();
  }
  createPNGStream() {
    return this.canvas._canvas.createPNGStream();
  }
  getCanvas() {
    return this.canvas;
  }
  getNativeCanvasElement() {
    return this.canvas._canvas;
  }
  getHitCanvas() {
    return this.hitCanvas;
  }
  getContext() {
    return this.getCanvas().getContext();
  }
  clear(e) {
    return this.getContext().clear(e), this.getHitCanvas().getContext().clear(e), this;
  }
  setZIndex(e) {
    super.setZIndex(e);
    var r = this.getStage();
    return r && r.content && (r.content.removeChild(this.getNativeCanvasElement()), e < r.children.length - 1 ? r.content.insertBefore(this.getNativeCanvasElement(), r.children[e + 1].getCanvas()._canvas) : r.content.appendChild(this.getNativeCanvasElement())), this;
  }
  moveToTop() {
    j1.Node.prototype.moveToTop.call(this);
    var e = this.getStage();
    return e && e.content && (e.content.removeChild(this.getNativeCanvasElement()), e.content.appendChild(this.getNativeCanvasElement())), !0;
  }
  moveUp() {
    var e = j1.Node.prototype.moveUp.call(this);
    if (!e)
      return !1;
    var r = this.getStage();
    return !r || !r.content ? !1 : (r.content.removeChild(this.getNativeCanvasElement()), this.index < r.children.length - 1 ? r.content.insertBefore(this.getNativeCanvasElement(), r.children[this.index + 1].getCanvas()._canvas) : r.content.appendChild(this.getNativeCanvasElement()), !0);
  }
  moveDown() {
    if (j1.Node.prototype.moveDown.call(this)) {
      var e = this.getStage();
      if (e) {
        var r = e.children;
        e.content && (e.content.removeChild(this.getNativeCanvasElement()), e.content.insertBefore(this.getNativeCanvasElement(), r[this.index + 1].getCanvas()._canvas));
      }
      return !0;
    }
    return !1;
  }
  moveToBottom() {
    if (j1.Node.prototype.moveToBottom.call(this)) {
      var e = this.getStage();
      if (e) {
        var r = e.children;
        e.content && (e.content.removeChild(this.getNativeCanvasElement()), e.content.insertBefore(this.getNativeCanvasElement(), r[1].getCanvas()._canvas));
      }
      return !0;
    }
    return !1;
  }
  getLayer() {
    return this;
  }
  remove() {
    var e = this.getNativeCanvasElement();
    return j1.Node.prototype.remove.call(this), e && e.parentNode && rl.Util._isInDocument(e) && e.parentNode.removeChild(e), this;
  }
  getStage() {
    return this.parent;
  }
  setSize({ width: e, height: r }) {
    return this.canvas.setSize(e, r), this.hitCanvas.setSize(e, r), this._setSmoothEnabled(), this;
  }
  _validateAdd(e) {
    var r = e.getType();
    r !== "Group" && r !== "Shape" && rl.Util.throw("You may only add groups and shapes to a layer.");
  }
  _toKonvaCanvas(e) {
    return e = e || {}, e.width = e.width || this.getWidth(), e.height = e.height || this.getHeight(), e.x = e.x !== void 0 ? e.x : this.x(), e.y = e.y !== void 0 ? e.y : this.y(), j1.Node.prototype._toKonvaCanvas.call(this, e);
  }
  _checkVisibility() {
    this.visible() ? this.canvas._canvas.style.display = "block" : this.canvas._canvas.style.display = "none";
  }
  _setSmoothEnabled() {
    this.getContext()._context.imageSmoothingEnabled = this.imageSmoothingEnabled();
  }
  getWidth() {
    if (this.parent)
      return this.parent.width();
  }
  setWidth() {
    rl.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
  }
  getHeight() {
    if (this.parent)
      return this.parent.height();
  }
  setHeight() {
    rl.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
  }
  batchDraw() {
    return this._waitingForDraw || (this._waitingForDraw = !0, rl.Util.requestAnimFrame(() => {
      this.draw(), this._waitingForDraw = !1;
    })), this;
  }
  getIntersection(e) {
    if (!this.isListening() || !this.isVisible())
      return null;
    for (var r = 1, n = !1; ; ) {
      for (let i = 0; i < mve; i++) {
        const a = Gz[i], o = this._getIntersection({
          x: e.x + a.x * r,
          y: e.y + a.y * r
        }), s = o.shape;
        if (s)
          return s;
        if (n = !!o.antialiased, !o.antialiased)
          break;
      }
      if (n)
        r += 1;
      else
        return null;
    }
  }
  _getIntersection(e) {
    const r = this.hitCanvas.pixelRatio, n = this.hitCanvas.context.getImageData(Math.round(e.x * r), Math.round(e.y * r), 1, 1).data, i = n[3];
    if (i === 255) {
      const a = rl.Util._rgbToHex(n[0], n[1], n[2]), o = lve.shapes[fve + a];
      return o ? {
        shape: o
      } : {
        antialiased: !0
      };
    } else if (i > 0)
      return {
        antialiased: !0
      };
    return {};
  }
  drawScene(e, r) {
    var n = this.getLayer(), i = e || n && n.getCanvas();
    return this._fire(pve, {
      node: this
    }), this.clearBeforeDraw() && i.getContext().clear(), J8.Container.prototype.drawScene.call(this, i, r), this._fire(hve, {
      node: this
    }), this;
  }
  drawHit(e, r) {
    var n = this.getLayer(), i = e || n && n.hitCanvas;
    return n && n.clearBeforeDraw() && n.getHitCanvas().getContext().clear(), J8.Container.prototype.drawHit.call(this, i, r), this;
  }
  enableHitGraph() {
    return this.hitGraphEnabled(!0), this;
  }
  disableHitGraph() {
    return this.hitGraphEnabled(!1), this;
  }
  setHitGraphEnabled(e) {
    rl.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."), this.listening(e);
  }
  getHitGraphEnabled(e) {
    return rl.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."), this.listening();
  }
  toggleHitCanvas() {
    if (!(!this.parent || !this.parent.content)) {
      var e = this.parent, r = !!this.hitCanvas._canvas.parentNode;
      r ? e.content.removeChild(this.hitCanvas._canvas) : e.content.appendChild(this.hitCanvas._canvas);
    }
  }
  destroy() {
    return rl.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas), super.destroy();
  }
}
F2.Layer = oh;
oh.prototype.nodeType = "Layer";
(0, dve._registerNode)(oh);
gS.Factory.addGetterSetter(oh, "imageSmoothingEnabled", !0);
gS.Factory.addGetterSetter(oh, "clearBeforeDraw", !0);
gS.Factory.addGetterSetter(oh, "hitGraphEnabled", !0, (0, cve.getBooleanValidator)());
var E4 = {};
Object.defineProperty(E4, "__esModule", { value: !0 });
E4.FastLayer = void 0;
const gve = vi, vve = F2, yve = Br;
class vS extends vve.Layer {
  constructor(e) {
    super(e), this.listening(!1), gve.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.');
  }
}
E4.FastLayer = vS;
vS.prototype.nodeType = "FastLayer";
(0, yve._registerNode)(vS);
var sh = {};
Object.defineProperty(sh, "__esModule", { value: !0 });
sh.Group = void 0;
const bve = vi, _ve = K0, xve = Br;
class yS extends _ve.Container {
  _validateAdd(e) {
    var r = e.getType();
    r !== "Group" && r !== "Shape" && bve.Util.throw("You may only add groups and shapes to groups.");
  }
}
sh.Group = yS;
yS.prototype.nodeType = "Group";
(0, xve._registerNode)(yS);
var uh = {};
Object.defineProperty(uh, "__esModule", { value: !0 });
uh.Animation = void 0;
const $8 = Br, ZB = vi, e_ = function() {
  return $8.glob.performance && $8.glob.performance.now ? function() {
    return $8.glob.performance.now();
  } : function() {
    return (/* @__PURE__ */ new Date()).getTime();
  };
}();
class lc {
  constructor(e, r) {
    this.id = lc.animIdCounter++, this.frame = {
      time: 0,
      timeDiff: 0,
      lastTime: e_(),
      frameRate: 0
    }, this.func = e, this.setLayers(r);
  }
  setLayers(e) {
    let r = [];
    return e && (r = Array.isArray(e) ? e : [e]), this.layers = r, this;
  }
  getLayers() {
    return this.layers;
  }
  addLayer(e) {
    const r = this.layers, n = r.length;
    for (let i = 0; i < n; i++)
      if (r[i]._id === e._id)
        return !1;
    return this.layers.push(e), !0;
  }
  isRunning() {
    const r = lc.animations, n = r.length;
    for (let i = 0; i < n; i++)
      if (r[i].id === this.id)
        return !0;
    return !1;
  }
  start() {
    return this.stop(), this.frame.timeDiff = 0, this.frame.lastTime = e_(), lc._addAnimation(this), this;
  }
  stop() {
    return lc._removeAnimation(this), this;
  }
  _updateFrameObject(e) {
    this.frame.timeDiff = e - this.frame.lastTime, this.frame.lastTime = e, this.frame.time += this.frame.timeDiff, this.frame.frameRate = 1e3 / this.frame.timeDiff;
  }
  static _addAnimation(e) {
    this.animations.push(e), this._handleAnimation();
  }
  static _removeAnimation(e) {
    const r = e.id, n = this.animations, i = n.length;
    for (let a = 0; a < i; a++)
      if (n[a].id === r) {
        this.animations.splice(a, 1);
        break;
      }
  }
  static _runFrames() {
    const e = {}, r = this.animations;
    for (let n = 0; n < r.length; n++) {
      const i = r[n], a = i.layers, o = i.func;
      i._updateFrameObject(e_());
      const s = a.length;
      let u;
      if (o ? u = o.call(i, i.frame) !== !1 : u = !0, !!u)
        for (let c = 0; c < s; c++) {
          const l = a[c];
          l._id !== void 0 && (e[l._id] = l);
        }
    }
    for (let n in e)
      e.hasOwnProperty(n) && e[n].batchDraw();
  }
  static _animationLoop() {
    const e = lc;
    e.animations.length ? (e._runFrames(), ZB.Util.requestAnimFrame(e._animationLoop)) : e.animRunning = !1;
  }
  static _handleAnimation() {
    this.animRunning || (this.animRunning = !0, ZB.Util.requestAnimFrame(this._animationLoop));
  }
}
uh.Animation = lc;
lc.animations = [];
lc.animIdCounter = 0;
lc.animRunning = !1;
var zz = {};
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t.Easings = t.Tween = void 0;
  const e = vi, r = uh, n = si, i = Br;
  var a = {
    node: 1,
    duration: 1,
    easing: 1,
    onFinish: 1,
    yoyo: 1
  }, o = 1, s = 2, u = 3, c = 0, l = ["fill", "stroke", "shadowColor"];
  class d {
    constructor(m, p, v, g, y, b, S) {
      this.prop = m, this.propFunc = p, this.begin = g, this._pos = g, this.duration = b, this._change = 0, this.prevPos = 0, this.yoyo = S, this._time = 0, this._position = 0, this._startTime = 0, this._finish = 0, this.func = v, this._change = y - this.begin, this.pause();
    }
    fire(m) {
      var p = this[m];
      p && p();
    }
    setTime(m) {
      m > this.duration ? this.yoyo ? (this._time = this.duration, this.reverse()) : this.finish() : m < 0 ? this.yoyo ? (this._time = 0, this.play()) : this.reset() : (this._time = m, this.update());
    }
    getTime() {
      return this._time;
    }
    setPosition(m) {
      this.prevPos = this._pos, this.propFunc(m), this._pos = m;
    }
    getPosition(m) {
      return m === void 0 && (m = this._time), this.func(m, this.begin, this._change, this.duration);
    }
    play() {
      this.state = s, this._startTime = this.getTimer() - this._time, this.onEnterFrame(), this.fire("onPlay");
    }
    reverse() {
      this.state = u, this._time = this.duration - this._time, this._startTime = this.getTimer() - this._time, this.onEnterFrame(), this.fire("onReverse");
    }
    seek(m) {
      this.pause(), this._time = m, this.update(), this.fire("onSeek");
    }
    reset() {
      this.pause(), this._time = 0, this.update(), this.fire("onReset");
    }
    finish() {
      this.pause(), this._time = this.duration, this.update(), this.fire("onFinish");
    }
    update() {
      this.setPosition(this.getPosition(this._time)), this.fire("onUpdate");
    }
    onEnterFrame() {
      var m = this.getTimer() - this._startTime;
      this.state === s ? this.setTime(m) : this.state === u && this.setTime(this.duration - m);
    }
    pause() {
      this.state = o, this.fire("onPause");
    }
    getTimer() {
      return (/* @__PURE__ */ new Date()).getTime();
    }
  }
  class f {
    constructor(m) {
      var p = this, v = m.node, g = v._id, y, b = m.easing || t.Easings.Linear, S = !!m.yoyo, _;
      typeof m.duration > "u" ? y = 0.3 : m.duration === 0 ? y = 1e-3 : y = m.duration, this.node = v, this._id = c++;
      var x = v.getLayer() || (v instanceof i.Konva.Stage ? v.getLayers() : null);
      x || e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."), this.anim = new r.Animation(function() {
        p.tween.onEnterFrame();
      }, x), this.tween = new d(_, function(C) {
        p._tweenFunc(C);
      }, b, 0, 1, y * 1e3, S), this._addListeners(), f.attrs[g] || (f.attrs[g] = {}), f.attrs[g][this._id] || (f.attrs[g][this._id] = {}), f.tweens[g] || (f.tweens[g] = {});
      for (_ in m)
        a[_] === void 0 && this._addAttr(_, m[_]);
      this.reset(), this.onFinish = m.onFinish, this.onReset = m.onReset, this.onUpdate = m.onUpdate;
    }
    _addAttr(m, p) {
      var v = this.node, g = v._id, y, b, S, _, x, C, A, w;
      if (S = f.tweens[g][m], S && delete f.attrs[g][S][m], y = v.getAttr(m), e.Util._isArray(p))
        if (b = [], x = Math.max(p.length, y.length), m === "points" && p.length !== y.length && (p.length > y.length ? (A = y, y = e.Util._prepareArrayForTween(y, p, v.closed())) : (C = p, p = e.Util._prepareArrayForTween(p, y, v.closed()))), m.indexOf("fill") === 0)
          for (_ = 0; _ < x; _++)
            if (_ % 2 === 0)
              b.push(p[_] - y[_]);
            else {
              var I = e.Util.colorToRGBA(y[_]);
              w = e.Util.colorToRGBA(p[_]), y[_] = I, b.push({
                r: w.r - I.r,
                g: w.g - I.g,
                b: w.b - I.b,
                a: w.a - I.a
              });
            }
        else
          for (_ = 0; _ < x; _++)
            b.push(p[_] - y[_]);
      else l.indexOf(m) !== -1 ? (y = e.Util.colorToRGBA(y), w = e.Util.colorToRGBA(p), b = {
        r: w.r - y.r,
        g: w.g - y.g,
        b: w.b - y.b,
        a: w.a - y.a
      }) : b = p - y;
      f.attrs[g][this._id][m] = {
        start: y,
        diff: b,
        end: p,
        trueEnd: C,
        trueStart: A
      }, f.tweens[g][m] = this._id;
    }
    _tweenFunc(m) {
      var p = this.node, v = f.attrs[p._id][this._id], g, y, b, S, _, x, C, A;
      for (g in v) {
        if (y = v[g], b = y.start, S = y.diff, A = y.end, e.Util._isArray(b))
          if (_ = [], C = Math.max(b.length, A.length), g.indexOf("fill") === 0)
            for (x = 0; x < C; x++)
              x % 2 === 0 ? _.push((b[x] || 0) + S[x] * m) : _.push("rgba(" + Math.round(b[x].r + S[x].r * m) + "," + Math.round(b[x].g + S[x].g * m) + "," + Math.round(b[x].b + S[x].b * m) + "," + (b[x].a + S[x].a * m) + ")");
          else
            for (x = 0; x < C; x++)
              _.push((b[x] || 0) + S[x] * m);
        else l.indexOf(g) !== -1 ? _ = "rgba(" + Math.round(b.r + S.r * m) + "," + Math.round(b.g + S.g * m) + "," + Math.round(b.b + S.b * m) + "," + (b.a + S.a * m) + ")" : _ = b + S * m;
        p.setAttr(g, _);
      }
    }
    _addListeners() {
      this.tween.onPlay = () => {
        this.anim.start();
      }, this.tween.onReverse = () => {
        this.anim.start();
      }, this.tween.onPause = () => {
        this.anim.stop();
      }, this.tween.onFinish = () => {
        var m = this.node, p = f.attrs[m._id][this._id];
        p.points && p.points.trueEnd && m.setAttr("points", p.points.trueEnd), this.onFinish && this.onFinish.call(this);
      }, this.tween.onReset = () => {
        var m = this.node, p = f.attrs[m._id][this._id];
        p.points && p.points.trueStart && m.points(p.points.trueStart), this.onReset && this.onReset();
      }, this.tween.onUpdate = () => {
        this.onUpdate && this.onUpdate.call(this);
      };
    }
    play() {
      return this.tween.play(), this;
    }
    reverse() {
      return this.tween.reverse(), this;
    }
    reset() {
      return this.tween.reset(), this;
    }
    seek(m) {
      return this.tween.seek(m * 1e3), this;
    }
    pause() {
      return this.tween.pause(), this;
    }
    finish() {
      return this.tween.finish(), this;
    }
    destroy() {
      var m = this.node._id, p = this._id, v = f.tweens[m], g;
      this.pause();
      for (g in v)
        delete f.tweens[m][g];
      delete f.attrs[m][p];
    }
  }
  t.Tween = f, f.attrs = {}, f.tweens = {}, n.Node.prototype.to = function(h) {
    var m = h.onFinish;
    h.node = this, h.onFinish = function() {
      this.destroy(), m && m();
    };
    var p = new f(h);
    p.play();
  }, t.Easings = {
    BackEaseIn(h, m, p, v) {
      var g = 1.70158;
      return p * (h /= v) * h * ((g + 1) * h - g) + m;
    },
    BackEaseOut(h, m, p, v) {
      var g = 1.70158;
      return p * ((h = h / v - 1) * h * ((g + 1) * h + g) + 1) + m;
    },
    BackEaseInOut(h, m, p, v) {
      var g = 1.70158;
      return (h /= v / 2) < 1 ? p / 2 * (h * h * (((g *= 1.525) + 1) * h - g)) + m : p / 2 * ((h -= 2) * h * (((g *= 1.525) + 1) * h + g) + 2) + m;
    },
    ElasticEaseIn(h, m, p, v, g, y) {
      var b = 0;
      return h === 0 ? m : (h /= v) === 1 ? m + p : (y || (y = v * 0.3), !g || g < Math.abs(p) ? (g = p, b = y / 4) : b = y / (2 * Math.PI) * Math.asin(p / g), -(g * Math.pow(2, 10 * (h -= 1)) * Math.sin((h * v - b) * (2 * Math.PI) / y)) + m);
    },
    ElasticEaseOut(h, m, p, v, g, y) {
      var b = 0;
      return h === 0 ? m : (h /= v) === 1 ? m + p : (y || (y = v * 0.3), !g || g < Math.abs(p) ? (g = p, b = y / 4) : b = y / (2 * Math.PI) * Math.asin(p / g), g * Math.pow(2, -10 * h) * Math.sin((h * v - b) * (2 * Math.PI) / y) + p + m);
    },
    ElasticEaseInOut(h, m, p, v, g, y) {
      var b = 0;
      return h === 0 ? m : (h /= v / 2) === 2 ? m + p : (y || (y = v * (0.3 * 1.5)), !g || g < Math.abs(p) ? (g = p, b = y / 4) : b = y / (2 * Math.PI) * Math.asin(p / g), h < 1 ? -0.5 * (g * Math.pow(2, 10 * (h -= 1)) * Math.sin((h * v - b) * (2 * Math.PI) / y)) + m : g * Math.pow(2, -10 * (h -= 1)) * Math.sin((h * v - b) * (2 * Math.PI) / y) * 0.5 + p + m);
    },
    BounceEaseOut(h, m, p, v) {
      return (h /= v) < 1 / 2.75 ? p * (7.5625 * h * h) + m : h < 2 / 2.75 ? p * (7.5625 * (h -= 1.5 / 2.75) * h + 0.75) + m : h < 2.5 / 2.75 ? p * (7.5625 * (h -= 2.25 / 2.75) * h + 0.9375) + m : p * (7.5625 * (h -= 2.625 / 2.75) * h + 0.984375) + m;
    },
    BounceEaseIn(h, m, p, v) {
      return p - t.Easings.BounceEaseOut(v - h, 0, p, v) + m;
    },
    BounceEaseInOut(h, m, p, v) {
      return h < v / 2 ? t.Easings.BounceEaseIn(h * 2, 0, p, v) * 0.5 + m : t.Easings.BounceEaseOut(h * 2 - v, 0, p, v) * 0.5 + p * 0.5 + m;
    },
    EaseIn(h, m, p, v) {
      return p * (h /= v) * h + m;
    },
    EaseOut(h, m, p, v) {
      return -p * (h /= v) * (h - 2) + m;
    },
    EaseInOut(h, m, p, v) {
      return (h /= v / 2) < 1 ? p / 2 * h * h + m : -p / 2 * (--h * (h - 2) - 1) + m;
    },
    StrongEaseIn(h, m, p, v) {
      return p * (h /= v) * h * h * h * h + m;
    },
    StrongEaseOut(h, m, p, v) {
      return p * ((h = h / v - 1) * h * h * h * h + 1) + m;
    },
    StrongEaseInOut(h, m, p, v) {
      return (h /= v / 2) < 1 ? p / 2 * h * h * h * h * h + m : p / 2 * ((h -= 2) * h * h * h * h + 2) + m;
    },
    Linear(h, m, p, v) {
      return p * h / v + m;
    }
  };
})(zz);
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t.Konva = void 0;
  const e = Br, r = vi, n = si, i = K0, a = Oz, o = F2, s = E4, u = sh, c = w4, l = fa, d = uh, f = zz, h = Sl, m = Lu;
  t.Konva = r.Util._assign(e.Konva, {
    Util: r.Util,
    Transform: r.Transform,
    Node: n.Node,
    Container: i.Container,
    Stage: a.Stage,
    stages: a.stages,
    Layer: o.Layer,
    FastLayer: s.FastLayer,
    Group: u.Group,
    DD: c.DD,
    Shape: l.Shape,
    shapes: l.shapes,
    Animation: d.Animation,
    Tween: f.Tween,
    Easings: f.Easings,
    Context: h.Context,
    Canvas: m.Canvas
  }), t.default = t.Konva;
})(Bz);
var I4 = {};
Object.defineProperty(I4, "__esModule", { value: !0 });
I4.Arc = void 0;
const T4 = Fr, Sve = fa, QB = Br, M4 = Ot, Cve = Br;
class zl extends Sve.Shape {
  _sceneFunc(e) {
    var r = QB.Konva.getAngle(this.angle()), n = this.clockwise();
    e.beginPath(), e.arc(0, 0, this.outerRadius(), 0, r, n), e.arc(0, 0, this.innerRadius(), r, 0, !n), e.closePath(), e.fillStrokeShape(this);
  }
  getWidth() {
    return this.outerRadius() * 2;
  }
  getHeight() {
    return this.outerRadius() * 2;
  }
  setWidth(e) {
    this.outerRadius(e / 2);
  }
  setHeight(e) {
    this.outerRadius(e / 2);
  }
  getSelfRect() {
    const e = this.innerRadius(), r = this.outerRadius(), n = this.clockwise(), i = QB.Konva.getAngle(n ? 360 - this.angle() : this.angle()), a = Math.cos(Math.min(i, Math.PI)), o = 1, s = Math.sin(Math.min(Math.max(Math.PI, i), 3 * Math.PI / 2)), u = Math.sin(Math.min(i, Math.PI / 2)), c = a * (a > 0 ? e : r), l = o * r, d = s * (s > 0 ? e : r), f = u * (u > 0 ? r : e);
    return {
      x: c,
      y: n ? -1 * f : d,
      width: l - c,
      height: f - d
    };
  }
}
I4.Arc = zl;
zl.prototype._centroid = !0;
zl.prototype.className = "Arc";
zl.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
(0, Cve._registerNode)(zl);
T4.Factory.addGetterSetter(zl, "innerRadius", 0, (0, M4.getNumberValidator)());
T4.Factory.addGetterSetter(zl, "outerRadius", 0, (0, M4.getNumberValidator)());
T4.Factory.addGetterSetter(zl, "angle", 0, (0, M4.getNumberValidator)());
T4.Factory.addGetterSetter(zl, "clockwise", !1, (0, M4.getBooleanValidator)());
var P4 = {}, N2 = {};
Object.defineProperty(N2, "__esModule", { value: !0 });
N2.Line = void 0;
const B4 = Fr, Ave = fa, Vz = Ot, wve = Br;
function w9(t, e, r, n, i, a, o) {
  var s = Math.sqrt(Math.pow(r - t, 2) + Math.pow(n - e, 2)), u = Math.sqrt(Math.pow(i - r, 2) + Math.pow(a - n, 2)), c = o * s / (s + u), l = o * u / (s + u), d = r - c * (i - t), f = n - c * (a - e), h = r + l * (i - t), m = n + l * (a - e);
  return [d, f, h, m];
}
function JB(t, e) {
  var r = t.length, n = [], i, a;
  for (i = 2; i < r - 2; i += 2)
    a = w9(t[i - 2], t[i - 1], t[i], t[i + 1], t[i + 2], t[i + 3], e), !isNaN(a[0]) && (n.push(a[0]), n.push(a[1]), n.push(t[i]), n.push(t[i + 1]), n.push(a[2]), n.push(a[3]));
  return n;
}
class bf extends Ave.Shape {
  constructor(e) {
    super(e), this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva", function() {
      this._clearCache("tensionPoints");
    });
  }
  _sceneFunc(e) {
    var r = this.points(), n = r.length, i = this.tension(), a = this.closed(), o = this.bezier(), s, u, c;
    if (n) {
      if (e.beginPath(), e.moveTo(r[0], r[1]), i !== 0 && n > 4) {
        for (s = this.getTensionPoints(), u = s.length, c = a ? 0 : 4, a || e.quadraticCurveTo(s[0], s[1], s[2], s[3]); c < u - 2; )
          e.bezierCurveTo(s[c++], s[c++], s[c++], s[c++], s[c++], s[c++]);
        a || e.quadraticCurveTo(s[u - 2], s[u - 1], r[n - 2], r[n - 1]);
      } else if (o)
        for (c = 2; c < n; )
          e.bezierCurveTo(r[c++], r[c++], r[c++], r[c++], r[c++], r[c++]);
      else
        for (c = 2; c < n; c += 2)
          e.lineTo(r[c], r[c + 1]);
      a ? (e.closePath(), e.fillStrokeShape(this)) : e.strokeShape(this);
    }
  }
  getTensionPoints() {
    return this._getCache("tensionPoints", this._getTensionPoints);
  }
  _getTensionPoints() {
    return this.closed() ? this._getTensionPointsClosed() : JB(this.points(), this.tension());
  }
  _getTensionPointsClosed() {
    var e = this.points(), r = e.length, n = this.tension(), i = w9(e[r - 2], e[r - 1], e[0], e[1], e[2], e[3], n), a = w9(e[r - 4], e[r - 3], e[r - 2], e[r - 1], e[0], e[1], n), o = JB(e, n), s = [i[2], i[3]].concat(o).concat([
      a[0],
      a[1],
      e[r - 2],
      e[r - 1],
      a[2],
      a[3],
      i[0],
      i[1],
      e[0],
      e[1]
    ]);
    return s;
  }
  getWidth() {
    return this.getSelfRect().width;
  }
  getHeight() {
    return this.getSelfRect().height;
  }
  getSelfRect() {
    var e = this.points();
    if (e.length < 4)
      return {
        x: e[0] || 0,
        y: e[1] || 0,
        width: 0,
        height: 0
      };
    this.tension() !== 0 ? e = [
      e[0],
      e[1],
      ...this._getTensionPoints(),
      e[e.length - 2],
      e[e.length - 1]
    ] : e = this.points();
    for (var r = e[0], n = e[0], i = e[1], a = e[1], o, s, u = 0; u < e.length / 2; u++)
      o = e[u * 2], s = e[u * 2 + 1], r = Math.min(r, o), n = Math.max(n, o), i = Math.min(i, s), a = Math.max(a, s);
    return {
      x: r,
      y: i,
      width: n - r,
      height: a - i
    };
  }
}
N2.Line = bf;
bf.prototype.className = "Line";
bf.prototype._attrsAffectingSize = ["points", "bezier", "tension"];
(0, wve._registerNode)(bf);
B4.Factory.addGetterSetter(bf, "closed", !1);
B4.Factory.addGetterSetter(bf, "bezier", !1);
B4.Factory.addGetterSetter(bf, "tension", 0, (0, Vz.getNumberValidator)());
B4.Factory.addGetterSetter(bf, "points", [], (0, Vz.getNumberArrayValidator)());
var ch = {}, Uz = {};
(function(t) {
  Object.defineProperty(t, "__esModule", { value: !0 }), t.t2length = t.getQuadraticArcLength = t.getCubicArcLength = t.binomialCoefficients = t.cValues = t.tValues = void 0, t.tValues = [
    [],
    [],
    [
      -0.5773502691896257,
      0.5773502691896257
    ],
    [
      0,
      -0.7745966692414834,
      0.7745966692414834
    ],
    [
      -0.33998104358485626,
      0.33998104358485626,
      -0.8611363115940526,
      0.8611363115940526
    ],
    [
      0,
      -0.5384693101056831,
      0.5384693101056831,
      -0.906179845938664,
      0.906179845938664
    ],
    [
      0.6612093864662645,
      -0.6612093864662645,
      -0.2386191860831969,
      0.2386191860831969,
      -0.932469514203152,
      0.932469514203152
    ],
    [
      0,
      0.4058451513773972,
      -0.4058451513773972,
      -0.7415311855993945,
      0.7415311855993945,
      -0.9491079123427585,
      0.9491079123427585
    ],
    [
      -0.1834346424956498,
      0.1834346424956498,
      -0.525532409916329,
      0.525532409916329,
      -0.7966664774136267,
      0.7966664774136267,
      -0.9602898564975363,
      0.9602898564975363
    ],
    [
      0,
      -0.8360311073266358,
      0.8360311073266358,
      -0.9681602395076261,
      0.9681602395076261,
      -0.3242534234038089,
      0.3242534234038089,
      -0.6133714327005904,
      0.6133714327005904
    ],
    [
      -0.14887433898163122,
      0.14887433898163122,
      -0.4333953941292472,
      0.4333953941292472,
      -0.6794095682990244,
      0.6794095682990244,
      -0.8650633666889845,
      0.8650633666889845,
      -0.9739065285171717,
      0.9739065285171717
    ],
    [
      0,
      -0.26954315595234496,
      0.26954315595234496,
      -0.5190961292068118,
      0.5190961292068118,
      -0.7301520055740494,
      0.7301520055740494,
      -0.8870625997680953,
      0.8870625997680953,
      -0.978228658146057,
      0.978228658146057
    ],
    [
      -0.1252334085114689,
      0.1252334085114689,
      -0.3678314989981802,
      0.3678314989981802,
      -0.5873179542866175,
      0.5873179542866175,
      -0.7699026741943047,
      0.7699026741943047,
      -0.9041172563704749,
      0.9041172563704749,
      -0.9815606342467192,
      0.9815606342467192
    ],
    [
      0,
      -0.2304583159551348,
      0.2304583159551348,
      -0.44849275103644687,
      0.44849275103644687,
      -0.6423493394403402,
      0.6423493394403402,
      -0.8015780907333099,
      0.8015780907333099,
      -0.9175983992229779,
      0.9175983992229779,
      -0.9841830547185881,
      0.9841830547185881
    ],
    [
      -0.10805494870734367,
      0.10805494870734367,
      -0.31911236892788974,
      0.31911236892788974,
      -0.5152486363581541,
      0.5152486363581541,
      -0.6872929048116855,
      0.6872929048116855,
      -0.827201315069765,
      0.827201315069765,
      -0.9284348836635735,
      0.9284348836635735,
      -0.9862838086968123,
      0.9862838086968123
    ],
    [
      0,
      -0.20119409399743451,
      0.20119409399743451,
      -0.3941513470775634,
      0.3941513470775634,
      -0.5709721726085388,
      0.5709721726085388,
      -0.7244177313601701,
      0.7244177313601701,
      -0.8482065834104272,
      0.8482065834104272,
      -0.937273392400706,
      0.937273392400706,
      -0.9879925180204854,
      0.9879925180204854
    ],
    [
      -0.09501250983763744,
      0.09501250983763744,
      -0.2816035507792589,
      0.2816035507792589,
      -0.45801677765722737,
      0.45801677765722737,
      -0.6178762444026438,
      0.6178762444026438,
      -0.755404408355003,
      0.755404408355003,
      -0.8656312023878318,
      0.8656312023878318,
      -0.9445750230732326,
      0.9445750230732326,
      -0.9894009349916499,
      0.9894009349916499
    ],
    [
      0,
      -0.17848418149584785,
      0.17848418149584785,
      -0.3512317634538763,
      0.3512317634538763,
      -0.5126905370864769,
      0.5126905370864769,
      -0.6576711592166907,
      0.6576711592166907,
      -0.7815140038968014,
      0.7815140038968014,
      -0.8802391537269859,
      0.8802391537269859,
      -0.9506755217687678,
      0.9506755217687678,
      -0.9905754753144174,
      0.9905754753144174
    ],
    [
      -0.0847750130417353,
      0.0847750130417353,
      -0.2518862256915055,
      0.2518862256915055,
      -0.41175116146284263,
      0.41175116146284263,
      -0.5597708310739475,
      0.5597708310739475,
      -0.6916870430603532,
      0.6916870430603532,
      -0.8037049589725231,
      0.8037049589725231,
      -0.8926024664975557,
      0.8926024664975557,
      -0.9558239495713977,
      0.9558239495713977,
      -0.9915651684209309,
      0.9915651684209309
    ],
    [
      0,
      -0.16035864564022537,
      0.16035864564022537,
      -0.31656409996362983,
      0.31656409996362983,
      -0.46457074137596094,
      0.46457074137596094,
      -0.600545304661681,
      0.600545304661681,
      -0.7209661773352294,
      0.7209661773352294,
      -0.8227146565371428,
      0.8227146565371428,
      -0.9031559036148179,
      0.9031559036148179,
      -0.96020815213483,
      0.96020815213483,
      -0.9924068438435844,
      0.9924068438435844
    ],
    [
      -0.07652652113349734,
      0.07652652113349734,
      -0.22778585114164507,
      0.22778585114164507,
      -0.37370608871541955,
      0.37370608871541955,
      -0.5108670019508271,
      0.5108670019508271,
      -0.636053680726515,
      0.636053680726515,
      -0.7463319064601508,
      0.7463319064601508,
      -0.8391169718222188,
      0.8391169718222188,
      -0.912234428251326,
      0.912234428251326,
      -0.9639719272779138,
      0.9639719272779138,
      -0.9931285991850949,
      0.9931285991850949
    ],
    [
      0,
      -0.1455618541608951,
      0.1455618541608951,
      -0.2880213168024011,
      0.2880213168024011,
      -0.4243421202074388,
      0.4243421202074388,
      -0.5516188358872198,
      0.5516188358872198,
      -0.6671388041974123,
      0.6671388041974123,
      -0.7684399634756779,
      0.7684399634756779,
      -0.8533633645833173,
      0.8533633645833173,
      -0.9200993341504008,
      0.9200993341504008,
      -0.9672268385663063,
      0.9672268385663063,
      -0.9937521706203895,
      0.9937521706203895
    ],
    [
      -0.06973927331972223,
      0.06973927331972223,
      -0.20786042668822127,
      0.20786042668822127,
      -0.34193582089208424,
      0.34193582089208424,
      -0.469355837986757,
      0.469355837986757,
      -0.5876404035069116,
      0.5876404035069116,
      -0.6944872631866827,
      0.6944872631866827,
      -0.7878168059792081,
      0.7878168059792081,
      -0.8658125777203002,
      0.8658125777203002,
      -0.926956772187174,
      0.926956772187174,
      -0.9700604978354287,
      0.9700604978354287,
      -0.9942945854823992,
      0.9942945854823992
    ],
    [
      0,
      -0.1332568242984661,
      0.1332568242984661,
      -0.26413568097034495,
      0.26413568097034495,
      -0.3903010380302908,
      0.3903010380302908,
      -0.5095014778460075,
      0.5095014778460075,
      -0.6196098757636461,
      0.6196098757636461,
      -0.7186613631319502,
      0.7186613631319502,
      -0.8048884016188399,
      0.8048884016188399,
      -0.8767523582704416,
      0.8767523582704416,
      -0.9329710868260161,
      0.9329710868260161,
      -0.9725424712181152,
      0.9725424712181152,
      -0.9947693349975522,
      0.9947693349975522
    ],
    [
      -0.06405689286260563,
      0.06405689286260563,
      -0.1911188674736163,
      0.1911188674736163,
      -0.3150426796961634,
      0.3150426796961634,
      -0.4337935076260451,
      0.4337935076260451,
      -0.5454214713888396,
      0.5454214713888396,
      -0.6480936519369755,
      0.6480936519369755,
      -0.7401241915785544,
      0.7401241915785544,
      -0.820001985973903,
      0.820001985973903,
      -0.8864155270044011,
      0.8864155270044011,
      -0.9382745520027328,
      0.9382745520027328,
      -0.9747285559713095,
      0.9747285559713095,
      -0.9951872199970213,
      0.9951872199970213
    ]
  ], t.cValues = [
    [],
    [],
    [1, 1],
    [
      0.8888888888888888,
      0.5555555555555556,
      0.5555555555555556
    ],
    [
      0.6521451548625461,
      0.6521451548625461,
      0.34785484513745385,
      0.34785484513745385
    ],
    [
      0.5688888888888889,
      0.47862867049936647,
      0.47862867049936647,
      0.23692688505618908,
      0.23692688505618908
    ],
    [
      0.3607615730481386,
      0.3607615730481386,
      0.46791393457269104,
      0.46791393457269104,
      0.17132449237917036,
      0.17132449237917036
    ],
    [
      0.4179591836734694,
      0.3818300505051189,
      0.3818300505051189,
      0.27970539148927664,
      0.27970539148927664,
      0.1294849661688697,
      0.1294849661688697
    ],
    [
      0.362683783378362,
      0.362683783378362,
      0.31370664587788727,
      0.31370664587788727,
      0.22238103445337448,
      0.22238103445337448,
      0.10122853629037626,
      0.10122853629037626
    ],
    [
      0.3302393550012598,
      0.1806481606948574,
      0.1806481606948574,
      0.08127438836157441,
      0.08127438836157441,
      0.31234707704000286,
      0.31234707704000286,
      0.26061069640293544,
      0.26061069640293544
    ],
    [
      0.29552422471475287,
      0.29552422471475287,
      0.26926671930999635,
      0.26926671930999635,
      0.21908636251598204,
      0.21908636251598204,
      0.1494513491505806,
      0.1494513491505806,
      0.06667134430868814,
      0.06667134430868814
    ],
    [
      0.2729250867779006,
      0.26280454451024665,
      0.26280454451024665,
      0.23319376459199048,
      0.23319376459199048,
      0.18629021092773426,
      0.18629021092773426,
      0.1255803694649046,
      0.1255803694649046,
      0.05566856711617366,
      0.05566856711617366
    ],
    [
      0.24914704581340277,
      0.24914704581340277,
      0.2334925365383548,
      0.2334925365383548,
      0.20316742672306592,
      0.20316742672306592,
      0.16007832854334622,
      0.16007832854334622,
      0.10693932599531843,
      0.10693932599531843,
      0.04717533638651183,
      0.04717533638651183
    ],
    [
      0.2325515532308739,
      0.22628318026289723,
      0.22628318026289723,
      0.2078160475368885,
      0.2078160475368885,
      0.17814598076194574,
      0.17814598076194574,
      0.13887351021978725,
      0.13887351021978725,
      0.09212149983772845,
      0.09212149983772845,
      0.04048400476531588,
      0.04048400476531588
    ],
    [
      0.2152638534631578,
      0.2152638534631578,
      0.2051984637212956,
      0.2051984637212956,
      0.18553839747793782,
      0.18553839747793782,
      0.15720316715819355,
      0.15720316715819355,
      0.12151857068790319,
      0.12151857068790319,
      0.08015808715976021,
      0.08015808715976021,
      0.03511946033175186,
      0.03511946033175186
    ],
    [
      0.2025782419255613,
      0.19843148532711158,
      0.19843148532711158,
      0.1861610000155622,
      0.1861610000155622,
      0.16626920581699392,
      0.16626920581699392,
      0.13957067792615432,
      0.13957067792615432,
      0.10715922046717194,
      0.10715922046717194,
      0.07036604748810812,
      0.07036604748810812,
      0.03075324199611727,
      0.03075324199611727
    ],
    [
      0.1894506104550685,
      0.1894506104550685,
      0.18260341504492358,
      0.18260341504492358,
      0.16915651939500254,
      0.16915651939500254,
      0.14959598881657674,
      0.14959598881657674,
      0.12462897125553388,
      0.12462897125553388,
      0.09515851168249279,
      0.09515851168249279,
      0.062253523938647894,
      0.062253523938647894,
      0.027152459411754096,
      0.027152459411754096
    ],
    [
      0.17944647035620653,
      0.17656270536699264,
      0.17656270536699264,
      0.16800410215645004,
      0.16800410215645004,
      0.15404576107681028,
      0.15404576107681028,
      0.13513636846852548,
      0.13513636846852548,
      0.11188384719340397,
      0.11188384719340397,
      0.08503614831717918,
      0.08503614831717918,
      0.0554595293739872,
      0.0554595293739872,
      0.02414830286854793,
      0.02414830286854793
    ],
    [
      0.1691423829631436,
      0.1691423829631436,
      0.16427648374583273,
      0.16427648374583273,
      0.15468467512626524,
      0.15468467512626524,
      0.14064291467065065,
      0.14064291467065065,
      0.12255520671147846,
      0.12255520671147846,
      0.10094204410628717,
      0.10094204410628717,
      0.07642573025488905,
      0.07642573025488905,
      0.0497145488949698,
      0.0497145488949698,
      0.02161601352648331,
      0.02161601352648331
    ],
    [
      0.1610544498487837,
      0.15896884339395434,
      0.15896884339395434,
      0.15276604206585967,
      0.15276604206585967,
      0.1426067021736066,
      0.1426067021736066,
      0.12875396253933621,
      0.12875396253933621,
      0.11156664554733399,
      0.11156664554733399,
      0.09149002162245,
      0.09149002162245,
      0.06904454273764123,
      0.06904454273764123,
      0.0448142267656996,
      0.0448142267656996,
      0.019461788229726478,
      0.019461788229726478
    ],
    [
      0.15275338713072584,
      0.15275338713072584,
      0.14917298647260374,
      0.14917298647260374,
      0.14209610931838204,
      0.14209610931838204,
      0.13168863844917664,
      0.13168863844917664,
      0.11819453196151841,
      0.11819453196151841,
      0.10193011981724044,
      0.10193011981724044,
      0.08327674157670475,
      0.08327674157670475,
      0.06267204833410907,
      0.06267204833410907,
      0.04060142980038694,
      0.04060142980038694,
      0.017614007139152118,
      0.017614007139152118
    ],
    [
      0.14608113364969041,
      0.14452440398997005,
      0.14452440398997005,
      0.13988739479107315,
      0.13988739479107315,
      0.13226893863333747,
      0.13226893863333747,
      0.12183141605372853,
      0.12183141605372853,
      0.10879729916714838,
      0.10879729916714838,
      0.09344442345603386,
      0.09344442345603386,
      0.0761001136283793,
      0.0761001136283793,
      0.057134425426857205,
      0.057134425426857205,
      0.036953789770852494,
      0.036953789770852494,
      0.016017228257774335,
      0.016017228257774335
    ],
    [
      0.13925187285563198,
      0.13925187285563198,
      0.13654149834601517,
      0.13654149834601517,
      0.13117350478706238,
      0.13117350478706238,
      0.12325237681051242,
      0.12325237681051242,
      0.11293229608053922,
      0.11293229608053922,
      0.10041414444288096,
      0.10041414444288096,
      0.08594160621706773,
      0.08594160621706773,
      0.06979646842452049,
      0.06979646842452049,
      0.052293335152683286,
      0.052293335152683286,
      0.03377490158481415,
      0.03377490158481415,
      0.0146279952982722,
      0.0146279952982722
    ],
    [
      0.13365457218610619,
      0.1324620394046966,
      0.1324620394046966,
      0.12890572218808216,
      0.12890572218808216,
      0.12304908430672953,
      0.12304908430672953,
      0.11499664022241136,
      0.11499664022241136,
      0.10489209146454141,
      0.10489209146454141,
      0.09291576606003515,
      0.09291576606003515,
      0.07928141177671895,
      0.07928141177671895,
      0.06423242140852585,
      0.06423242140852585,
      0.04803767173108467,
      0.04803767173108467,
      0.030988005856979445,
      0.030988005856979445,
      0.013411859487141771,
      0.013411859487141771
    ],
    [
      0.12793819534675216,
      0.12793819534675216,
      0.1258374563468283,
      0.1258374563468283,
      0.12167047292780339,
      0.12167047292780339,
      0.1155056680537256,
      0.1155056680537256,
      0.10744427011596563,
      0.10744427011596563,
      0.09761865210411388,
      0.09761865210411388,
      0.08619016153195327,
      0.08619016153195327,
      0.0733464814110803,
      0.0733464814110803,
      0.05929858491543678,
      0.05929858491543678,
      0.04427743881741981,
      0.04427743881741981,
      0.028531388628933663,
      0.028531388628933663,
      0.0123412297999872,
      0.0123412297999872
    ]
  ], t.binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
  const e = (o, s, u) => {
    let c, l, d;
    c = u / 2, l = 0;
    for (let h = 0; h < 20; h++)
      d = c * t.tValues[20][h] + c, l += t.cValues[20][h] * n(o, s, d);
    return c * l;
  };
  t.getCubicArcLength = e;
  const r = (o, s, u) => {
    u === void 0 && (u = 1);
    const c = o[0] - 2 * o[1] + o[2], l = s[0] - 2 * s[1] + s[2], d = 2 * o[1] - 2 * o[0], f = 2 * s[1] - 2 * s[0], h = 4 * (c * c + l * l), m = 4 * (c * d + l * f), p = d * d + f * f;
    if (h === 0)
      return u * Math.sqrt(Math.pow(o[2] - o[0], 2) + Math.pow(s[2] - s[0], 2));
    const v = m / (2 * h), g = p / h, y = u + v, b = g - v * v, S = y * y + b > 0 ? Math.sqrt(y * y + b) : 0, _ = v * v + b > 0 ? Math.sqrt(v * v + b) : 0, x = v + Math.sqrt(v * v + b) !== 0 ? b * Math.log(Math.abs((y + S) / (v + _))) : 0;
    return Math.sqrt(h) / 2 * (y * S - v * _ + x);
  };
  t.getQuadraticArcLength = r;
  function n(o, s, u) {
    const c = i(1, u, o), l = i(1, u, s), d = c * c + l * l;
    return Math.sqrt(d);
  }
  const i = (o, s, u) => {
    const c = u.length - 1;
    let l, d;
    if (c === 0)
      return 0;
    if (o === 0) {
      d = 0;
      for (let f = 0; f <= c; f++)
        d += t.binomialCoefficients[c][f] * Math.pow(1 - s, c - f) * Math.pow(s, f) * u[f];
      return d;
    } else {
      l = new Array(c);
      for (let f = 0; f < c; f++)
        l[f] = c * (u[f + 1] - u[f]);
      return i(o - 1, s, l);
    }
  }, a = (o, s, u) => {
    let c = 1, l = o / s, d = (o - u(l)) / s, f = 0;
    for (; c > 1e-3; ) {
      const h = u(l + d), m = Math.abs(o - h) / s;
      if (m < c)
        c = m, l += d;
      else {
        const p = u(l - d), v = Math.abs(o - p) / s;
        v < c ? (c = v, l -= d) : d /= 2;
      }
      if (f++, f > 500)
        break;
    }
    return l;
  };
  t.t2length = a;
})(Uz);
Object.defineProperty(ch, "__esModule", { value: !0 });
ch.Path = void 0;
const Dve = Fr, Eve = fa, Ive = Br, Z1 = Uz;
class ta extends Eve.Shape {
  constructor(e) {
    super(e), this.dataArray = [], this.pathLength = 0, this._readDataAttribute(), this.on("dataChange.konva", function() {
      this._readDataAttribute();
    });
  }
  _readDataAttribute() {
    this.dataArray = ta.parsePathData(this.data()), this.pathLength = ta.getPathLength(this.dataArray);
  }
  _sceneFunc(e) {
    var r = this.dataArray;
    e.beginPath();
    for (var n = !1, i = 0; i < r.length; i++) {
      var a = r[i].command, o = r[i].points;
      switch (a) {
        case "L":
          e.lineTo(o[0], o[1]);
          break;
        case "M":
          e.moveTo(o[0], o[1]);
          break;
        case "C":
          e.bezierCurveTo(o[0], o[1], o[2], o[3], o[4], o[5]);
          break;
        case "Q":
          e.quadraticCurveTo(o[0], o[1], o[2], o[3]);
          break;
        case "A":
          var s = o[0], u = o[1], c = o[2], l = o[3], d = o[4], f = o[5], h = o[6], m = o[7], p = c > l ? c : l, v = c > l ? 1 : c / l, g = c > l ? l / c : 1;
          e.translate(s, u), e.rotate(h), e.scale(v, g), e.arc(0, 0, p, d, d + f, 1 - m), e.scale(1 / v, 1 / g), e.rotate(-h), e.translate(-s, -u);
          break;
        case "z":
          n = !0, e.closePath();
          break;
      }
    }
    !n && !this.hasFill() ? e.strokeShape(this) : e.fillStrokeShape(this);
  }
  getSelfRect() {
    var e = [];
    this.dataArray.forEach(function(c) {
      if (c.command === "A") {
        var l = c.points[4], d = c.points[5], f = c.points[4] + d, h = Math.PI / 180;
        if (Math.abs(l - f) < h && (h = Math.abs(l - f)), d < 0)
          for (let m = l - h; m > f; m -= h) {
            const p = ta.getPointOnEllipticalArc(c.points[0], c.points[1], c.points[2], c.points[3], m, 0);
            e.push(p.x, p.y);
          }
        else
          for (let m = l + h; m < f; m += h) {
            const p = ta.getPointOnEllipticalArc(c.points[0], c.points[1], c.points[2], c.points[3], m, 0);
            e.push(p.x, p.y);
          }
      } else if (c.command === "C")
        for (let m = 0; m <= 1; m += 0.01) {
          const p = ta.getPointOnCubicBezier(m, c.start.x, c.start.y, c.points[0], c.points[1], c.points[2], c.points[3], c.points[4], c.points[5]);
          e.push(p.x, p.y);
        }
      else
        e = e.concat(c.points);
    });
    for (var r = e[0], n = e[0], i = e[1], a = e[1], o, s, u = 0; u < e.length / 2; u++)
      o = e[u * 2], s = e[u * 2 + 1], isNaN(o) || (r = Math.min(r, o), n = Math.max(n, o)), isNaN(s) || (i = Math.min(i, s), a = Math.max(a, s));
    return {
      x: r,
      y: i,
      width: n - r,
      height: a - i
    };
  }
  getLength() {
    return this.pathLength;
  }
  getPointAtLength(e) {
    return ta.getPointAtLengthOfDataArray(e, this.dataArray);
  }
  static getLineLength(e, r, n, i) {
    return Math.sqrt((n - e) * (n - e) + (i - r) * (i - r));
  }
  static getPathLength(e) {
    let r = 0;
    for (var n = 0; n < e.length; ++n)
      r += e[n].pathLength;
    return r;
  }
  static getPointAtLengthOfDataArray(e, r) {
    var n, i = 0, a = r.length;
    if (!a)
      return null;
    for (; i < a && e > r[i].pathLength; )
      e -= r[i].pathLength, ++i;
    if (i === a)
      return n = r[i - 1].points.slice(-2), {
        x: n[0],
        y: n[1]
      };
    if (e < 0.01)
      return n = r[i].points.slice(0, 2), {
        x: n[0],
        y: n[1]
      };
    var o = r[i], s = o.points;
    switch (o.command) {
      case "L":
        return ta.getPointOnLine(e, o.start.x, o.start.y, s[0], s[1]);
      case "C":
        return ta.getPointOnCubicBezier((0, Z1.t2length)(e, ta.getPathLength(r), (p) => (0, Z1.getCubicArcLength)([o.start.x, s[0], s[2], s[4]], [o.start.y, s[1], s[3], s[5]], p)), o.start.x, o.start.y, s[0], s[1], s[2], s[3], s[4], s[5]);
      case "Q":
        return ta.getPointOnQuadraticBezier((0, Z1.t2length)(e, ta.getPathLength(r), (p) => (0, Z1.getQuadraticArcLength)([o.start.x, s[0], s[2]], [o.start.y, s[1], s[3]], p)), o.start.x, o.start.y, s[0], s[1], s[2], s[3]);
      case "A":
        var u = s[0], c = s[1], l = s[2], d = s[3], f = s[4], h = s[5], m = s[6];
        return f += h * e / o.pathLength, ta.getPointOnEllipticalArc(u, c, l, d, f, m);
    }
    return null;
  }
  static getPointOnLine(e, r, n, i, a, o, s) {
    o = o ?? r, s = s ?? n;
    const u = this.getLineLength(r, n, i, a);
    if (u < 1e-10)
      return { x: r, y: n };
    if (i === r)
      return { x: o, y: s + (a > n ? e : -e) };
    const c = (a - n) / (i - r), l = Math.sqrt(e * e / (1 + c * c)) * (i < r ? -1 : 1), d = c * l;
    if (Math.abs(s - n - c * (o - r)) < 1e-10)
      return { x: o + l, y: s + d };
    const f = ((o - r) * (i - r) + (s - n) * (a - n)) / (u * u), h = r + f * (i - r), m = n + f * (a - n), p = this.getLineLength(o, s, h, m), v = Math.sqrt(e * e - p * p), g = Math.sqrt(v * v / (1 + c * c)) * (i < r ? -1 : 1), y = c * g;
    return { x: h + g, y: m + y };
  }
  static getPointOnCubicBezier(e, r, n, i, a, o, s, u, c) {
    function l(v) {
      return v * v * v;
    }
    function d(v) {
      return 3 * v * v * (1 - v);
    }
    function f(v) {
      return 3 * v * (1 - v) * (1 - v);
    }
    function h(v) {
      return (1 - v) * (1 - v) * (1 - v);
    }
    var m = u * l(e) + o * d(e) + i * f(e) + r * h(e), p = c * l(e) + s * d(e) + a * f(e) + n * h(e);
    return {
      x: m,
      y: p
    };
  }
  static getPointOnQuadraticBezier(e, r, n, i, a, o, s) {
    function u(h) {
      return h * h;
    }
    function c(h) {
      return 2 * h * (1 - h);
    }
    function l(h) {
      return (1 - h) * (1 - h);
    }
    var d = o * u(e) + i * c(e) + r * l(e), f = s * u(e) + a * c(e) + n * l(e);
    return {
      x: d,
      y: f
    };
  }
  static getPointOnEllipticalArc(e, r, n, i, a, o) {
    var s = Math.cos(o), u = Math.sin(o), c = {
      x: n * Math.cos(a),
      y: i * Math.sin(a)
    };
    return {
      x: e + (c.x * s - c.y * u),
      y: r + (c.x * u + c.y * s)
    };
  }
  static parsePathData(e) {
    if (!e)
      return [];
    var r = e, n = [
      "m",
      "M",
      "l",
      "L",
      "v",
      "V",
      "h",
      "H",
      "z",
      "Z",
      "c",
      "C",
      "q",
      "Q",
      "t",
      "T",
      "s",
      "S",
      "a",
      "A"
    ];
    r = r.replace(new RegExp(" ", "g"), ",");
    for (var i = 0; i < n.length; i++)
      r = r.replace(new RegExp(n[i], "g"), "|" + n[i]);
    var a = r.split("|"), o = [], s = [], u = 0, c = 0, l = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi, d;
    for (i = 1; i < a.length; i++) {
      var f = a[i], h = f.charAt(0);
      for (f = f.slice(1), s.length = 0; d = l.exec(f); )
        s.push(d[0]);
      for (var m = [], p = 0, v = s.length; p < v; p++) {
        if (s[p] === "00") {
          m.push(0, 0);
          continue;
        }
        var g = parseFloat(s[p]);
        isNaN(g) ? m.push(0) : m.push(g);
      }
      for (; m.length > 0 && !isNaN(m[0]); ) {
        var y = "", b = [], S = u, _ = c, x, C, A, w, I, P, M, T, F, N;
        switch (h) {
          case "l":
            u += m.shift(), c += m.shift(), y = "L", b.push(u, c);
            break;
          case "L":
            u = m.shift(), c = m.shift(), b.push(u, c);
            break;
          case "m":
            var R = m.shift(), L = m.shift();
            if (u += R, c += L, y = "M", o.length > 2 && o[o.length - 1].command === "z") {
              for (var V = o.length - 2; V >= 0; V--)
                if (o[V].command === "M") {
                  u = o[V].points[0] + R, c = o[V].points[1] + L;
                  break;
                }
            }
            b.push(u, c), h = "l";
            break;
          case "M":
            u = m.shift(), c = m.shift(), y = "M", b.push(u, c), h = "L";
            break;
          case "h":
            u += m.shift(), y = "L", b.push(u, c);
            break;
          case "H":
            u = m.shift(), y = "L", b.push(u, c);
            break;
          case "v":
            c += m.shift(), y = "L", b.push(u, c);
            break;
          case "V":
            c = m.shift(), y = "L", b.push(u, c);
            break;
          case "C":
            b.push(m.shift(), m.shift(), m.shift(), m.shift()), u = m.shift(), c = m.shift(), b.push(u, c);
            break;
          case "c":
            b.push(u + m.shift(), c + m.shift(), u + m.shift(), c + m.shift()), u += m.shift(), c += m.shift(), y = "C", b.push(u, c);
            break;
          case "S":
            C = u, A = c, x = o[o.length - 1], x.command === "C" && (C = u + (u - x.points[2]), A = c + (c - x.points[3])), b.push(C, A, m.shift(), m.shift()), u = m.shift(), c = m.shift(), y = "C", b.push(u, c);
            break;
          case "s":
            C = u, A = c, x = o[o.length - 1], x.command === "C" && (C = u + (u - x.points[2]), A = c + (c - x.points[3])), b.push(C, A, u + m.shift(), c + m.shift()), u += m.shift(), c += m.shift(), y = "C", b.push(u, c);
            break;
          case "Q":
            b.push(m.shift(), m.shift()), u = m.shift(), c = m.shift(), b.push(u, c);
            break;
          case "q":
            b.push(u + m.shift(), c + m.shift()), u += m.shift(), c += m.shift(), y = "Q", b.push(u, c);
            break;
          case "T":
            C = u, A = c, x = o[o.length - 1], x.command === "Q" && (C = u + (u - x.points[0]), A = c + (c - x.points[1])), u = m.shift(), c = m.shift(), y = "Q", b.push(C, A, u, c);
            break;
          case "t":
            C = u, A = c, x = o[o.length - 1], x.command === "Q" && (C = u + (u - x.points[0]), A = c + (c - x.points[1])), u += m.shift(), c += m.shift(), y = "Q", b.push(C, A, u, c);
            break;
          case "A":
            w = m.shift(), I = m.shift(), P = m.shift(), M = m.shift(), T = m.shift(), F = u, N = c, u = m.shift(), c = m.shift(), y = "A", b = this.convertEndpointToCenterParameterization(F, N, u, c, M, T, w, I, P);
            break;
          case "a":
            w = m.shift(), I = m.shift(), P = m.shift(), M = m.shift(), T = m.shift(), F = u, N = c, u += m.shift(), c += m.shift(), y = "A", b = this.convertEndpointToCenterParameterization(F, N, u, c, M, T, w, I, P);
            break;
        }
        o.push({
          command: y || h,
          points: b,
          start: {
            x: S,
            y: _
          },
          pathLength: this.calcLength(S, _, y || h, b)
        });
      }
      (h === "z" || h === "Z") && o.push({
        command: "z",
        points: [],
        start: void 0,
        pathLength: 0
      });
    }
    return o;
  }
  static calcLength(e, r, n, i) {
    var a, o, s, u, c = ta;
    switch (n) {
      case "L":
        return c.getLineLength(e, r, i[0], i[1]);
      case "C":
        return (0, Z1.getCubicArcLength)([e, i[0], i[2], i[4]], [r, i[1], i[3], i[5]], 1);
      case "Q":
        return (0, Z1.getQuadraticArcLength)([e, i[0], i[2]], [r, i[1], i[3]], 1);
      case "A":
        a = 0;
        var l = i[4], d = i[5], f = i[4] + d, h = Math.PI / 180;
        if (Math.abs(l - f) < h && (h = Math.abs(l - f)), o = c.getPointOnEllipticalArc(i[0], i[1], i[2], i[3], l, 0), d < 0)
          for (u = l - h; u > f; u -= h)
            s = c.getPointOnEllipticalArc(i[0], i[1], i[2], i[3], u, 0), a += c.getLineLength(o.x, o.y, s.x, s.y), o = s;
        else
          for (u = l + h; u < f; u += h)
            s = c.getPointOnEllipticalArc(i[0], i[1], i[2], i[3], u, 0), a += c.getLineLength(o.x, o.y, s.x, s.y), o = s;
        return s = c.getPointOnEllipticalArc(i[0], i[1], i[2], i[3], f, 0), a += c.getLineLength(o.x, o.y, s.x, s.y), a;
    }
    return 0;
  }
  static convertEndpointToCenterParameterization(e, r, n, i, a, o, s, u, c) {
    var l = c * (Math.PI / 180), d = Math.cos(l) * (e - n) / 2 + Math.sin(l) * (r - i) / 2, f = -1 * Math.sin(l) * (e - n) / 2 + Math.cos(l) * (r - i) / 2, h = d * d / (s * s) + f * f / (u * u);
    h > 1 && (s *= Math.sqrt(h), u *= Math.sqrt(h));
    var m = Math.sqrt((s * s * (u * u) - s * s * (f * f) - u * u * (d * d)) / (s * s * (f * f) + u * u * (d * d)));
    a === o && (m *= -1), isNaN(m) && (m = 0);
    var p = m * s * f / u, v = m * -u * d / s, g = (e + n) / 2 + Math.cos(l) * p - Math.sin(l) * v, y = (r + i) / 2 + Math.sin(l) * p + Math.cos(l) * v, b = function(I) {
      return Math.sqrt(I[0] * I[0] + I[1] * I[1]);
    }, S = function(I, P) {
      return (I[0] * P[0] + I[1] * P[1]) / (b(I) * b(P));
    }, _ = function(I, P) {
      return (I[0] * P[1] < I[1] * P[0] ? -1 : 1) * Math.acos(S(I, P));
    }, x = _([1, 0], [(d - p) / s, (f - v) / u]), C = [(d - p) / s, (f - v) / u], A = [(-1 * d - p) / s, (-1 * f - v) / u], w = _(C, A);
    return S(C, A) <= -1 && (w = Math.PI), S(C, A) >= 1 && (w = 0), o === 0 && w > 0 && (w = w - 2 * Math.PI), o === 1 && w < 0 && (w = w + 2 * Math.PI), [g, y, s, u, x, w, l, o];
  }
}
ch.Path = ta;
ta.prototype.className = "Path";
ta.prototype._attrsAffectingSize = ["data"];
(0, Ive._registerNode)(ta);
Dve.Factory.addGetterSetter(ta, "data");
Object.defineProperty(P4, "__esModule", { value: !0 });
P4.Arrow = void 0;
const F4 = Fr, Tve = N2, Hz = Ot, Mve = Br, $B = ch;
class Y0 extends Tve.Line {
  _sceneFunc(e) {
    super._sceneFunc(e);
    var r = Math.PI * 2, n = this.points(), i = n, a = this.tension() !== 0 && n.length > 4;
    a && (i = this.getTensionPoints());
    var o = this.pointerLength(), s = n.length, u, c;
    if (a) {
      const f = [
        i[i.length - 4],
        i[i.length - 3],
        i[i.length - 2],
        i[i.length - 1],
        n[s - 2],
        n[s - 1]
      ], h = $B.Path.calcLength(i[i.length - 4], i[i.length - 3], "C", f), m = $B.Path.getPointOnQuadraticBezier(Math.min(1, 1 - o / h), f[0], f[1], f[2], f[3], f[4], f[5]);
      u = n[s - 2] - m.x, c = n[s - 1] - m.y;
    } else
      u = n[s - 2] - n[s - 4], c = n[s - 1] - n[s - 3];
    var l = (Math.atan2(c, u) + r) % r, d = this.pointerWidth();
    this.pointerAtEnding() && (e.save(), e.beginPath(), e.translate(n[s - 2], n[s - 1]), e.rotate(l), e.moveTo(0, 0), e.lineTo(-o, d / 2), e.lineTo(-o, -d / 2), e.closePath(), e.restore(), this.__fillStroke(e)), this.pointerAtBeginning() && (e.save(), e.beginPath(), e.translate(n[0], n[1]), a ? (u = (i[0] + i[2]) / 2 - n[0], c = (i[1] + i[3]) / 2 - n[1]) : (u = n[2] - n[0], c = n[3] - n[1]), e.rotate((Math.atan2(-c, -u) + r) % r), e.moveTo(0, 0), e.lineTo(-o, d / 2), e.lineTo(-o, -d / 2), e.closePath(), e.restore(), this.__fillStroke(e));
  }
  __fillStroke(e) {
    var r = this.dashEnabled();
    r && (this.attrs.dashEnabled = !1, e.setLineDash([])), e.fillStrokeShape(this), r && (this.attrs.dashEnabled = !0);
  }
  getSelfRect() {
    const e = super.getSelfRect(), r = this.pointerWidth() / 2;
    return {
      x: e.x - r,
      y: e.y - r,
      width: e.width + r * 2,
      height: e.height + r * 2
    };
  }
}
P4.Arrow = Y0;
Y0.prototype.className = "Arrow";
(0, Mve._registerNode)(Y0);
F4.Factory.addGetterSetter(Y0, "pointerLength", 10, (0, Hz.getNumberValidator)());
F4.Factory.addGetterSetter(Y0, "pointerWidth", 10, (0, Hz.getNumberValidator)());
F4.Factory.addGetterSetter(Y0, "pointerAtBeginning", !1);
F4.Factory.addGetterSetter(Y0, "pointerAtEnding", !0);
var N4 = {};
Object.defineProperty(N4, "__esModule", { value: !0 });
N4.Circle = void 0;
const Pve = Fr, Bve = fa, Fve = Ot, Nve = Br;
class lh extends Bve.Shape {
  _sceneFunc(e) {
    e.beginPath(), e.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, !1), e.closePath(), e.fillStrokeShape(this);
  }
  getWidth() {
    return this.radius() * 2;
  }
  getHeight() {
    return this.radius() * 2;
  }
  setWidth(e) {
    this.radius() !== e / 2 && this.radius(e / 2);
  }
  setHeight(e) {
    this.radius() !== e / 2 && this.radius(e / 2);
  }
}
N4.Circle = lh;
lh.prototype._centroid = !0;
lh.prototype.className = "Circle";
lh.prototype._attrsAffectingSize = ["radius"];
(0, Nve._registerNode)(lh);
Pve.Factory.addGetterSetter(lh, "radius", 0, (0, Fve.getNumberValidator)());
var R4 = {};
Object.defineProperty(R4, "__esModule", { value: !0 });
R4.Ellipse = void 0;
const bS = Fr, Rve = fa, qz = Ot, Ove = Br;
class _f extends Rve.Shape {
  _sceneFunc(e) {
    var r = this.radiusX(), n = this.radiusY();
    e.beginPath(), e.save(), r !== n && e.scale(1, n / r), e.arc(0, 0, r, 0, Math.PI * 2, !1), e.restore(), e.closePath(), e.fillStrokeShape(this);
  }
  getWidth() {
    return this.radiusX() * 2;
  }
  getHeight() {
    return this.radiusY() * 2;
  }
  setWidth(e) {
    this.radiusX(e / 2);
  }
  setHeight(e) {
    this.radiusY(e / 2);
  }
}
R4.Ellipse = _f;
_f.prototype.className = "Ellipse";
_f.prototype._centroid = !0;
_f.prototype._attrsAffectingSize = ["radiusX", "radiusY"];
(0, Ove._registerNode)(_f);
bS.Factory.addComponentsGetterSetter(_f, "radius", ["x", "y"]);
bS.Factory.addGetterSetter(_f, "radiusX", 0, (0, qz.getNumberValidator)());
bS.Factory.addGetterSetter(_f, "radiusY", 0, (0, qz.getNumberValidator)());
var O4 = {};
Object.defineProperty(O4, "__esModule", { value: !0 });
O4.Image = void 0;
const t_ = vi, W0 = Fr, Lve = fa, kve = Br, R2 = Ot;
let Ic = class Kz extends Lve.Shape {
  constructor(e) {
    super(e), this.on("imageChange.konva", () => {
      this._setImageLoad();
    }), this._setImageLoad();
  }
  _setImageLoad() {
    const e = this.image();
    e && e.complete || e && e.readyState === 4 || e && e.addEventListener && e.addEventListener("load", () => {
      this._requestDraw();
    });
  }
  _useBufferCanvas() {
    const e = !!this.cornerRadius(), r = this.hasShadow();
    return e && r ? !0 : super._useBufferCanvas(!0);
  }
  _sceneFunc(e) {
    const r = this.getWidth(), n = this.getHeight(), i = this.cornerRadius(), a = this.attrs.image;
    let o;
    if (a) {
      const s = this.attrs.cropWidth, u = this.attrs.cropHeight;
      s && u ? o = [
        a,
        this.cropX(),
        this.cropY(),
        s,
        u,
        0,
        0,
        r,
        n
      ] : o = [a, 0, 0, r, n];
    }
    (this.hasFill() || this.hasStroke() || i) && (e.beginPath(), i ? t_.Util.drawRoundedRectPath(e, r, n, i) : e.rect(0, 0, r, n), e.closePath(), e.fillStrokeShape(this)), a && (i && e.clip(), e.drawImage.apply(e, o));
  }
  _hitFunc(e) {
    var r = this.width(), n = this.height(), i = this.cornerRadius();
    e.beginPath(), i ? t_.Util.drawRoundedRectPath(e, r, n, i) : e.rect(0, 0, r, n), e.closePath(), e.fillStrokeShape(this);
  }
  getWidth() {
    var e, r;
    return (e = this.attrs.width) !== null && e !== void 0 ? e : (r = this.image()) === null || r === void 0 ? void 0 : r.width;
  }
  getHeight() {
    var e, r;
    return (e = this.attrs.height) !== null && e !== void 0 ? e : (r = this.image()) === null || r === void 0 ? void 0 : r.height;
  }
  static fromURL(e, r, n = null) {
    var i = t_.Util.createImageElement();
    i.onload = function() {
      var a = new Kz({
        image: i
      });
      r(a);
    }, i.onerror = n, i.crossOrigin = "Anonymous", i.src = e;
  }
};
O4.Image = Ic;
Ic.prototype.className = "Image";
(0, kve._registerNode)(Ic);
W0.Factory.addGetterSetter(Ic, "cornerRadius", 0, (0, R2.getNumberOrArrayOfNumbersValidator)(4));
W0.Factory.addGetterSetter(Ic, "image");
W0.Factory.addComponentsGetterSetter(Ic, "crop", ["x", "y", "width", "height"]);
W0.Factory.addGetterSetter(Ic, "cropX", 0, (0, R2.getNumberValidator)());
W0.Factory.addGetterSetter(Ic, "cropY", 0, (0, R2.getNumberValidator)());
W0.Factory.addGetterSetter(Ic, "cropWidth", 0, (0, R2.getNumberValidator)());
W0.Factory.addGetterSetter(Ic, "cropHeight", 0, (0, R2.getNumberValidator)());
var qp = {};
Object.defineProperty(qp, "__esModule", { value: !0 });
qp.Tag = qp.Label = void 0;
const L4 = Fr, Gve = fa, zve = sh, _S = Ot, Xz = Br;
var Yz = [
  "fontFamily",
  "fontSize",
  "fontStyle",
  "padding",
  "lineHeight",
  "text",
  "width",
  "height",
  "pointerDirection",
  "pointerWidth",
  "pointerHeight"
], Vve = "Change.konva", Uve = "none", D9 = "up", E9 = "right", I9 = "down", T9 = "left", Hve = Yz.length;
class xS extends zve.Group {
  constructor(e) {
    super(e), this.on("add.konva", function(r) {
      this._addListeners(r.child), this._sync();
    });
  }
  getText() {
    return this.find("Text")[0];
  }
  getTag() {
    return this.find("Tag")[0];
  }
  _addListeners(e) {
    var r = this, n, i = function() {
      r._sync();
    };
    for (n = 0; n < Hve; n++)
      e.on(Yz[n] + Vve, i);
  }
  getWidth() {
    return this.getText().width();
  }
  getHeight() {
    return this.getText().height();
  }
  _sync() {
    var e = this.getText(), r = this.getTag(), n, i, a, o, s, u, c;
    if (e && r) {
      switch (n = e.width(), i = e.height(), a = r.pointerDirection(), o = r.pointerWidth(), c = r.pointerHeight(), s = 0, u = 0, a) {
        case D9:
          s = n / 2, u = -1 * c;
          break;
        case E9:
          s = n + o, u = i / 2;
          break;
        case I9:
          s = n / 2, u = i + c;
          break;
        case T9:
          s = -1 * o, u = i / 2;
          break;
      }
      r.setAttrs({
        x: -1 * s,
        y: -1 * u,
        width: n,
        height: i
      }), e.setAttrs({
        x: -1 * s,
        y: -1 * u
      });
    }
  }
}
qp.Label = xS;
xS.prototype.className = "Label";
(0, Xz._registerNode)(xS);
class j0 extends Gve.Shape {
  _sceneFunc(e) {
    var r = this.width(), n = this.height(), i = this.pointerDirection(), a = this.pointerWidth(), o = this.pointerHeight(), s = this.cornerRadius();
    let u = 0, c = 0, l = 0, d = 0;
    typeof s == "number" ? u = c = l = d = Math.min(s, r / 2, n / 2) : (u = Math.min(s[0] || 0, r / 2, n / 2), c = Math.min(s[1] || 0, r / 2, n / 2), d = Math.min(s[2] || 0, r / 2, n / 2), l = Math.min(s[3] || 0, r / 2, n / 2)), e.beginPath(), e.moveTo(u, 0), i === D9 && (e.lineTo((r - a) / 2, 0), e.lineTo(r / 2, -1 * o), e.lineTo((r + a) / 2, 0)), e.lineTo(r - c, 0), e.arc(r - c, c, c, Math.PI * 3 / 2, 0, !1), i === E9 && (e.lineTo(r, (n - o) / 2), e.lineTo(r + a, n / 2), e.lineTo(r, (n + o) / 2)), e.lineTo(r, n - d), e.arc(r - d, n - d, d, 0, Math.PI / 2, !1), i === I9 && (e.lineTo((r + a) / 2, n), e.lineTo(r / 2, n + o), e.lineTo((r - a) / 2, n)), e.lineTo(l, n), e.arc(l, n - l, l, Math.PI / 2, Math.PI, !1), i === T9 && (e.lineTo(0, (n + o) / 2), e.lineTo(-1 * a, n / 2), e.lineTo(0, (n - o) / 2)), e.lineTo(0, u), e.arc(u, u, u, Math.PI, Math.PI * 3 / 2, !1), e.closePath(), e.fillStrokeShape(this);
  }
  getSelfRect() {
    var e = 0, r = 0, n = this.pointerWidth(), i = this.pointerHeight(), a = this.pointerDirection(), o = this.width(), s = this.height();
    return a === D9 ? (r -= i, s += i) : a === I9 ? s += i : a === T9 ? (e -= n * 1.5, o += n) : a === E9 && (o += n * 1.5), {
      x: e,
      y: r,
      width: o,
      height: s
    };
  }
}
qp.Tag = j0;
j0.prototype.className = "Tag";
(0, Xz._registerNode)(j0);
L4.Factory.addGetterSetter(j0, "pointerDirection", Uve);
L4.Factory.addGetterSetter(j0, "pointerWidth", 0, (0, _S.getNumberValidator)());
L4.Factory.addGetterSetter(j0, "pointerHeight", 0, (0, _S.getNumberValidator)());
L4.Factory.addGetterSetter(j0, "cornerRadius", 0, (0, _S.getNumberOrArrayOfNumbersValidator)(4));
var O2 = {};
Object.defineProperty(O2, "__esModule", { value: !0 });
O2.Rect = void 0;
const qve = Fr, Kve = fa, Xve = Br, Yve = vi, Wve = Ot;
class k4 extends Kve.Shape {
  _sceneFunc(e) {
    var r = this.cornerRadius(), n = this.width(), i = this.height();
    e.beginPath(), r ? Yve.Util.drawRoundedRectPath(e, n, i, r) : e.rect(0, 0, n, i), e.closePath(), e.fillStrokeShape(this);
  }
}
O2.Rect = k4;
k4.prototype.className = "Rect";
(0, Xve._registerNode)(k4);
qve.Factory.addGetterSetter(k4, "cornerRadius", 0, (0, Wve.getNumberOrArrayOfNumbersValidator)(4));
var G4 = {};
Object.defineProperty(G4, "__esModule", { value: !0 });
G4.RegularPolygon = void 0;
const Wz = Fr, jve = fa, jz = Ot, Zve = Br;
class Z0 extends jve.Shape {
  _sceneFunc(e) {
    const r = this._getPoints();
    e.beginPath(), e.moveTo(r[0].x, r[0].y);
    for (var n = 1; n < r.length; n++)
      e.lineTo(r[n].x, r[n].y);
    e.closePath(), e.fillStrokeShape(this);
  }
  _getPoints() {
    const e = this.attrs.sides, r = this.attrs.radius || 0, n = [];
    for (var i = 0; i < e; i++)
      n.push({
        x: r * Math.sin(i * 2 * Math.PI / e),
        y: -1 * r * Math.cos(i * 2 * Math.PI / e)
      });
    return n;
  }
  getSelfRect() {
    const e = this._getPoints();
    var r = e[0].x, n = e[0].y, i = e[0].x, a = e[0].y;
    return e.forEach((o) => {
      r = Math.min(r, o.x), n = Math.max(n, o.x), i = Math.min(i, o.y), a = Math.max(a, o.y);
    }), {
      x: r,
      y: i,
      width: n - r,
      height: a - i
    };
  }
  getWidth() {
    return this.radius() * 2;
  }
  getHeight() {
    return this.radius() * 2;
  }
  setWidth(e) {
    this.radius(e / 2);
  }
  setHeight(e) {
    this.radius(e / 2);
  }
}
G4.RegularPolygon = Z0;
Z0.prototype.className = "RegularPolygon";
Z0.prototype._centroid = !0;
Z0.prototype._attrsAffectingSize = ["radius"];
(0, Zve._registerNode)(Z0);
Wz.Factory.addGetterSetter(Z0, "radius", 0, (0, jz.getNumberValidator)());
Wz.Factory.addGetterSetter(Z0, "sides", 0, (0, jz.getNumberValidator)());
var z4 = {};
Object.defineProperty(z4, "__esModule", { value: !0 });
z4.Ring = void 0;
const Zz = Fr, Qve = fa, Qz = Ot, Jve = Br;
var eF = Math.PI * 2;
class Q0 extends Qve.Shape {
  _sceneFunc(e) {
    e.beginPath(), e.arc(0, 0, this.innerRadius(), 0, eF, !1), e.moveTo(this.outerRadius(), 0), e.arc(0, 0, this.outerRadius(), eF, 0, !0), e.closePath(), e.fillStrokeShape(this);
  }
  getWidth() {
    return this.outerRadius() * 2;
  }
  getHeight() {
    return this.outerRadius() * 2;
  }
  setWidth(e) {
    this.outerRadius(e / 2);
  }
  setHeight(e) {
    this.outerRadius(e / 2);
  }
}
z4.Ring = Q0;
Q0.prototype.className = "Ring";
Q0.prototype._centroid = !0;
Q0.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
(0, Jve._registerNode)(Q0);
Zz.Factory.addGetterSetter(Q0, "innerRadius", 0, (0, Qz.getNumberValidator)());
Zz.Factory.addGetterSetter(Q0, "outerRadius", 0, (0, Qz.getNumberValidator)());
var V4 = {};
Object.defineProperty(V4, "__esModule", { value: !0 });
V4.Sprite = void 0;
const J0 = Fr, $ve = fa, e3e = uh, Jz = Ot, t3e = Br;
class Tc extends $ve.Shape {
  constructor(e) {
    super(e), this._updated = !0, this.anim = new e3e.Animation(() => {
      var r = this._updated;
      return this._updated = !1, r;
    }), this.on("animationChange.konva", function() {
      this.frameIndex(0);
    }), this.on("frameIndexChange.konva", function() {
      this._updated = !0;
    }), this.on("frameRateChange.konva", function() {
      this.anim.isRunning() && (clearInterval(this.interval), this._setInterval());
    });
  }
  _sceneFunc(e) {
    var r = this.animation(), n = this.frameIndex(), i = n * 4, a = this.animations()[r], o = this.frameOffsets(), s = a[i + 0], u = a[i + 1], c = a[i + 2], l = a[i + 3], d = this.image();
    if ((this.hasFill() || this.hasStroke()) && (e.beginPath(), e.rect(0, 0, c, l), e.closePath(), e.fillStrokeShape(this)), d)
      if (o) {
        var f = o[r], h = n * 2;
        e.drawImage(d, s, u, c, l, f[h + 0], f[h + 1], c, l);
      } else
        e.drawImage(d, s, u, c, l, 0, 0, c, l);
  }
  _hitFunc(e) {
    var r = this.animation(), n = this.frameIndex(), i = n * 4, a = this.animations()[r], o = this.frameOffsets(), s = a[i + 2], u = a[i + 3];
    if (e.beginPath(), o) {
      var c = o[r], l = n * 2;
      e.rect(c[l + 0], c[l + 1], s, u);
    } else
      e.rect(0, 0, s, u);
    e.closePath(), e.fillShape(this);
  }
  _useBufferCanvas() {
    return super._useBufferCanvas(!0);
  }
  _setInterval() {
    var e = this;
    this.interval = setInterval(function() {
      e._updateIndex();
    }, 1e3 / this.frameRate());
  }
  start() {
    if (!this.isRunning()) {
      var e = this.getLayer();
      this.anim.setLayers(e), this._setInterval(), this.anim.start();
    }
  }
  stop() {
    this.anim.stop(), clearInterval(this.interval);
  }
  isRunning() {
    return this.anim.isRunning();
  }
  _updateIndex() {
    var e = this.frameIndex(), r = this.animation(), n = this.animations(), i = n[r], a = i.length / 4;
    e < a - 1 ? this.frameIndex(e + 1) : this.frameIndex(0);
  }
}
V4.Sprite = Tc;
Tc.prototype.className = "Sprite";
(0, t3e._registerNode)(Tc);
J0.Factory.addGetterSetter(Tc, "animation");
J0.Factory.addGetterSetter(Tc, "animations");
J0.Factory.addGetterSetter(Tc, "frameOffsets");
J0.Factory.addGetterSetter(Tc, "image");
J0.Factory.addGetterSetter(Tc, "frameIndex", 0, (0, Jz.getNumberValidator)());
J0.Factory.addGetterSetter(Tc, "frameRate", 17, (0, Jz.getNumberValidator)());
J0.Factory.backCompat(Tc, {
  index: "frameIndex",
  getIndex: "getFrameIndex",
  setIndex: "setFrameIndex"
});
var U4 = {};
Object.defineProperty(U4, "__esModule", { value: !0 });
U4.Star = void 0;
const SS = Fr, r3e = fa, CS = Ot, n3e = Br;
class xf extends r3e.Shape {
  _sceneFunc(e) {
    var r = this.innerRadius(), n = this.outerRadius(), i = this.numPoints();
    e.beginPath(), e.moveTo(0, 0 - n);
    for (var a = 1; a < i * 2; a++) {
      var o = a % 2 === 0 ? n : r, s = o * Math.sin(a * Math.PI / i), u = -1 * o * Math.cos(a * Math.PI / i);
      e.lineTo(s, u);
    }
    e.closePath(), e.fillStrokeShape(this);
  }
  getWidth() {
    return this.outerRadius() * 2;
  }
  getHeight() {
    return this.outerRadius() * 2;
  }
  setWidth(e) {
    this.outerRadius(e / 2);
  }
  setHeight(e) {
    this.outerRadius(e / 2);
  }
}
U4.Star = xf;
xf.prototype.className = "Star";
xf.prototype._centroid = !0;
xf.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
(0, n3e._registerNode)(xf);
SS.Factory.addGetterSetter(xf, "numPoints", 5, (0, CS.getNumberValidator)());
SS.Factory.addGetterSetter(xf, "innerRadius", 0, (0, CS.getNumberValidator)());
SS.Factory.addGetterSetter(xf, "outerRadius", 0, (0, CS.getNumberValidator)());
var F0 = {};
Object.defineProperty(F0, "__esModule", { value: !0 });
F0.Text = F0.stringToArray = void 0;
const M9 = vi, oo = Fr, i3e = fa, r_ = Br, Sf = Ot, a3e = Br;
function $z(t) {
  return Array.from(t);
}
F0.stringToArray = $z;
var Q1 = "auto", o3e = "center", eV = "inherit", sm = "justify", s3e = "Change.konva", u3e = "2d", tF = "-", tV = "left", c3e = "text", l3e = "Text", d3e = "top", f3e = "bottom", rF = "middle", rV = "normal", p3e = "px ", Xv = " ", h3e = "right", nF = "rtl", m3e = "word", g3e = "char", iF = "none", n_ = "…", nV = [
  "direction",
  "fontFamily",
  "fontSize",
  "fontStyle",
  "fontVariant",
  "padding",
  "align",
  "verticalAlign",
  "lineHeight",
  "text",
  "width",
  "height",
  "wrap",
  "ellipsis",
  "letterSpacing"
], v3e = nV.length;
function y3e(t) {
  return t.split(",").map((e) => {
    e = e.trim();
    const r = e.indexOf(" ") >= 0, n = e.indexOf('"') >= 0 || e.indexOf("'") >= 0;
    return r && !n && (e = `"${e}"`), e;
  }).join(", ");
}
var Yv;
function i_() {
  return Yv || (Yv = M9.Util.createCanvasElement().getContext(u3e), Yv);
}
function b3e(t) {
  t.fillText(this._partialText, this._partialTextX, this._partialTextY);
}
function _3e(t) {
  t.setAttr("miterLimit", 2), t.strokeText(this._partialText, this._partialTextX, this._partialTextY);
}
function x3e(t) {
  return t = t || {}, !t.fillLinearGradientColorStops && !t.fillRadialGradientColorStops && !t.fillPatternImage && (t.fill = t.fill || "black"), t;
}
class Ii extends i3e.Shape {
  constructor(e) {
    super(x3e(e)), this._partialTextX = 0, this._partialTextY = 0;
    for (var r = 0; r < v3e; r++)
      this.on(nV[r] + s3e, this._setTextData);
    this._setTextData();
  }
  _sceneFunc(e) {
    var r = this.textArr, n = r.length;
    if (this.text()) {
      var i = this.padding(), a = this.fontSize(), o = this.lineHeight() * a, s = this.verticalAlign(), u = this.direction(), c = 0, l = this.align(), d = this.getWidth(), f = this.letterSpacing(), h = this.fill(), m = this.textDecoration(), p = m.indexOf("underline") !== -1, v = m.indexOf("line-through") !== -1, g;
      u = u === eV ? e.direction : u;
      var y = o / 2, b = rF;
      if (r_.Konva._fixTextRendering) {
        var S = this.measureSize("M");
        b = "alphabetic", y = (S.fontBoundingBoxAscent - S.fontBoundingBoxDescent) / 2 + o / 2;
      }
      var _ = 0, x = 0;
      for (u === nF && e.setAttr("direction", u), e.setAttr("font", this._getContextFont()), e.setAttr("textBaseline", b), e.setAttr("textAlign", tV), s === rF ? c = (this.getHeight() - n * o - i * 2) / 2 : s === f3e && (c = this.getHeight() - n * o - i * 2), e.translate(i, c + i), g = 0; g < n; g++) {
        var _ = 0, x = 0, C = r[g], A = C.text, w = C.width, I = C.lastInParagraph, P, M, T;
        if (e.save(), l === h3e ? _ += d - w - i * 2 : l === o3e && (_ += (d - w - i * 2) / 2), p) {
          e.save(), e.beginPath();
          let U = r_.Konva._fixTextRendering ? Math.round(a / 4) : Math.round(a / 2);
          const H = _, K = y + x + U;
          e.moveTo(H, K), P = A.split(" ").length - 1, M = P === 0, T = l === sm && !I ? d - i * 2 : w, e.lineTo(H + Math.round(T), K), e.lineWidth = a / 15;
          const X = this._getLinearGradient();
          e.strokeStyle = X || h, e.stroke(), e.restore();
        }
        if (v) {
          e.save(), e.beginPath();
          let U = r_.Konva._fixTextRendering ? -Math.round(a / 4) : 0;
          e.moveTo(_, y + x + U), P = A.split(" ").length - 1, M = P === 0, T = l === sm && I && !M ? d - i * 2 : w, e.lineTo(_ + Math.round(T), y + x + U), e.lineWidth = a / 15;
          const H = this._getLinearGradient();
          e.strokeStyle = H || h, e.stroke(), e.restore();
        }
        if (u !== nF && (f !== 0 || l === sm)) {
          P = A.split(" ").length - 1;
          for (var F = $z(A), N = 0; N < F.length; N++) {
            var R = F[N];
            R === " " && !I && l === sm && (_ += (d - i * 2 - w) / P), this._partialTextX = _, this._partialTextY = y + x, this._partialText = R, e.fillStrokeShape(this), _ += this.measureSize(R).width + f;
          }
        } else
          f !== 0 && e.setAttr("letterSpacing", `${f}px`), this._partialTextX = _, this._partialTextY = y + x, this._partialText = A, e.fillStrokeShape(this);
        e.restore(), n > 1 && (y += o);
      }
    }
  }
  _hitFunc(e) {
    var r = this.getWidth(), n = this.getHeight();
    e.beginPath(), e.rect(0, 0, r, n), e.closePath(), e.fillStrokeShape(this);
  }
  setText(e) {
    var r = M9.Util._isString(e) ? e : e == null ? "" : e + "";
    return this._setAttr(c3e, r), this;
  }
  getWidth() {
    var e = this.attrs.width === Q1 || this.attrs.width === void 0;
    return e ? this.getTextWidth() + this.padding() * 2 : this.attrs.width;
  }
  getHeight() {
    var e = this.attrs.height === Q1 || this.attrs.height === void 0;
    return e ? this.fontSize() * this.textArr.length * this.lineHeight() + this.padding() * 2 : this.attrs.height;
  }
  getTextWidth() {
    return this.textWidth;
  }
  getTextHeight() {
    return M9.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."), this.textHeight;
  }
  measureSize(e) {
    var r, n, i, a, o, s, u, c, l, d, f, h = i_(), m = this.fontSize(), p;
    h.save(), h.font = this._getContextFont(), p = h.measureText(e), h.restore();
    const v = m / 100;
    return {
      actualBoundingBoxAscent: (r = p.actualBoundingBoxAscent) !== null && r !== void 0 ? r : 71.58203125 * v,
      actualBoundingBoxDescent: (n = p.actualBoundingBoxDescent) !== null && n !== void 0 ? n : 0,
      actualBoundingBoxLeft: (i = p.actualBoundingBoxLeft) !== null && i !== void 0 ? i : -7.421875 * v,
      actualBoundingBoxRight: (a = p.actualBoundingBoxRight) !== null && a !== void 0 ? a : 75.732421875 * v,
      alphabeticBaseline: (o = p.alphabeticBaseline) !== null && o !== void 0 ? o : 0,
      emHeightAscent: (s = p.emHeightAscent) !== null && s !== void 0 ? s : 100 * v,
      emHeightDescent: (u = p.emHeightDescent) !== null && u !== void 0 ? u : -20 * v,
      fontBoundingBoxAscent: (c = p.fontBoundingBoxAscent) !== null && c !== void 0 ? c : 91 * v,
      fontBoundingBoxDescent: (l = p.fontBoundingBoxDescent) !== null && l !== void 0 ? l : 21 * v,
      hangingBaseline: (d = p.hangingBaseline) !== null && d !== void 0 ? d : 72.80000305175781 * v,
      ideographicBaseline: (f = p.ideographicBaseline) !== null && f !== void 0 ? f : -21 * v,
      width: p.width,
      height: m
    };
  }
  _getContextFont() {
    return this.fontStyle() + Xv + this.fontVariant() + Xv + (this.fontSize() + p3e) + y3e(this.fontFamily());
  }
  _addTextLine(e) {
    this.align() === sm && (e = e.trim());
    var n = this._getTextWidth(e);
    return this.textArr.push({
      text: e,
      width: n,
      lastInParagraph: !1
    });
  }
  _getTextWidth(e) {
    var r = this.letterSpacing(), n = e.length;
    return i_().measureText(e).width + (n ? r * (n - 1) : 0);
  }
  _setTextData() {
    var e = this.text().split(`
`), r = +this.fontSize(), n = 0, i = this.lineHeight() * r, a = this.attrs.width, o = this.attrs.height, s = a !== Q1 && a !== void 0, u = o !== Q1 && o !== void 0, c = this.padding(), l = a - c * 2, d = o - c * 2, f = 0, h = this.wrap(), m = h !== iF, p = h !== g3e && m, v = this.ellipsis();
    this.textArr = [], i_().font = this._getContextFont();
    for (var g = v ? this._getTextWidth(n_) : 0, y = 0, b = e.length; y < b; ++y) {
      var S = e[y], _ = this._getTextWidth(S);
      if (s && _ > l)
        for (; S.length > 0; ) {
          for (var x = 0, C = S.length, A = "", w = 0; x < C; ) {
            var I = x + C >>> 1, P = S.slice(0, I + 1), M = this._getTextWidth(P) + g;
            M <= l ? (x = I + 1, A = P, w = M) : C = I;
          }
          if (A) {
            if (p) {
              var T, F = S[A.length], N = F === Xv || F === tF;
              N && w <= l ? T = A.length : T = Math.max(A.lastIndexOf(Xv), A.lastIndexOf(tF)) + 1, T > 0 && (x = T, A = A.slice(0, x), w = this._getTextWidth(A));
            }
            A = A.trimRight(), this._addTextLine(A), n = Math.max(n, w), f += i;
            var R = this._shouldHandleEllipsis(f);
            if (R) {
              this._tryToAddEllipsisToLastLine();
              break;
            }
            if (S = S.slice(x), S = S.trimLeft(), S.length > 0 && (_ = this._getTextWidth(S), _ <= l)) {
              this._addTextLine(S), f += i, n = Math.max(n, _);
              break;
            }
          } else
            break;
        }
      else
        this._addTextLine(S), f += i, n = Math.max(n, _), this._shouldHandleEllipsis(f) && y < b - 1 && this._tryToAddEllipsisToLastLine();
      if (this.textArr[this.textArr.length - 1] && (this.textArr[this.textArr.length - 1].lastInParagraph = !0), u && f + i > d)
        break;
    }
    this.textHeight = r, this.textWidth = n;
  }
  _shouldHandleEllipsis(e) {
    var r = +this.fontSize(), n = this.lineHeight() * r, i = this.attrs.height, a = i !== Q1 && i !== void 0, o = this.padding(), s = i - o * 2, u = this.wrap(), c = u !== iF;
    return !c || a && e + n > s;
  }
  _tryToAddEllipsisToLastLine() {
    var e = this.attrs.width, r = e !== Q1 && e !== void 0, n = this.padding(), i = e - n * 2, a = this.ellipsis(), o = this.textArr[this.textArr.length - 1];
    if (!(!o || !a)) {
      if (r) {
        var s = this._getTextWidth(o.text + n_) < i;
        s || (o.text = o.text.slice(0, o.text.length - 3));
      }
      this.textArr.splice(this.textArr.length - 1, 1), this._addTextLine(o.text + n_);
    }
  }
  getStrokeScaleEnabled() {
    return !0;
  }
  _useBufferCanvas() {
    const e = this.textDecoration().indexOf("underline") !== -1 || this.textDecoration().indexOf("line-through") !== -1, r = this.hasShadow();
    return e && r ? !0 : super._useBufferCanvas();
  }
}
F0.Text = Ii;
Ii.prototype._fillFunc = b3e;
Ii.prototype._strokeFunc = _3e;
Ii.prototype.className = l3e;
Ii.prototype._attrsAffectingSize = [
  "text",
  "fontSize",
  "padding",
  "wrap",
  "lineHeight",
  "letterSpacing"
];
(0, a3e._registerNode)(Ii);
oo.Factory.overWriteSetter(Ii, "width", (0, Sf.getNumberOrAutoValidator)());
oo.Factory.overWriteSetter(Ii, "height", (0, Sf.getNumberOrAutoValidator)());
oo.Factory.addGetterSetter(Ii, "direction", eV);
oo.Factory.addGetterSetter(Ii, "fontFamily", "Arial");
oo.Factory.addGetterSetter(Ii, "fontSize", 12, (0, Sf.getNumberValidator)());
oo.Factory.addGetterSetter(Ii, "fontStyle", rV);
oo.Factory.addGetterSetter(Ii, "fontVariant", rV);
oo.Factory.addGetterSetter(Ii, "padding", 0, (0, Sf.getNumberValidator)());
oo.Factory.addGetterSetter(Ii, "align", tV);
oo.Factory.addGetterSetter(Ii, "verticalAlign", d3e);
oo.Factory.addGetterSetter(Ii, "lineHeight", 1, (0, Sf.getNumberValidator)());
oo.Factory.addGetterSetter(Ii, "wrap", m3e);
oo.Factory.addGetterSetter(Ii, "ellipsis", !1, (0, Sf.getBooleanValidator)());
oo.Factory.addGetterSetter(Ii, "letterSpacing", 0, (0, Sf.getNumberValidator)());
oo.Factory.addGetterSetter(Ii, "text", "", (0, Sf.getStringValidator)());
oo.Factory.addGetterSetter(Ii, "textDecoration", "");
var H4 = {};
Object.defineProperty(H4, "__esModule", { value: !0 });
H4.TextPath = void 0;
const a_ = vi, Uu = Fr, S3e = fa, um = ch, o_ = F0, iV = Ot, C3e = Br;
var A3e = "", aV = "normal";
function oV(t) {
  t.fillText(this.partialText, 0, 0);
}
function sV(t) {
  t.strokeText(this.partialText, 0, 0);
}
class pa extends S3e.Shape {
  constructor(e) {
    super(e), this.dummyCanvas = a_.Util.createCanvasElement(), this.dataArray = [], this._readDataAttribute(), this.on("dataChange.konva", function() {
      this._readDataAttribute(), this._setTextData();
    }), this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva", this._setTextData), this._setTextData();
  }
  _getTextPathLength() {
    return um.Path.getPathLength(this.dataArray);
  }
  _getPointAtLength(e) {
    if (!this.attrs.data)
      return null;
    const r = this.pathLength;
    return e - 1 > r ? null : um.Path.getPointAtLengthOfDataArray(e, this.dataArray);
  }
  _readDataAttribute() {
    this.dataArray = um.Path.parsePathData(this.attrs.data), this.pathLength = this._getTextPathLength();
  }
  _sceneFunc(e) {
    e.setAttr("font", this._getContextFont()), e.setAttr("textBaseline", this.textBaseline()), e.setAttr("textAlign", "left"), e.save();
    var r = this.textDecoration(), n = this.fill(), i = this.fontSize(), a = this.glyphInfo;
    r === "underline" && e.beginPath();
    for (var o = 0; o < a.length; o++) {
      e.save();
      var s = a[o].p0;
      e.translate(s.x, s.y), e.rotate(a[o].rotation), this.partialText = a[o].text, e.fillStrokeShape(this), r === "underline" && (o === 0 && e.moveTo(0, i / 2 + 1), e.lineTo(i, i / 2 + 1)), e.restore();
    }
    r === "underline" && (e.strokeStyle = n, e.lineWidth = i / 20, e.stroke()), e.restore();
  }
  _hitFunc(e) {
    e.beginPath();
    var r = this.glyphInfo;
    if (r.length >= 1) {
      var n = r[0].p0;
      e.moveTo(n.x, n.y);
    }
    for (var i = 0; i < r.length; i++) {
      var a = r[i].p1;
      e.lineTo(a.x, a.y);
    }
    e.setAttr("lineWidth", this.fontSize()), e.setAttr("strokeStyle", this.colorKey), e.stroke();
  }
  getTextWidth() {
    return this.textWidth;
  }
  getTextHeight() {
    return a_.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."), this.textHeight;
  }
  setText(e) {
    return o_.Text.prototype.setText.call(this, e);
  }
  _getContextFont() {
    return o_.Text.prototype._getContextFont.call(this);
  }
  _getTextSize(e) {
    var r = this.dummyCanvas, n = r.getContext("2d");
    n.save(), n.font = this._getContextFont();
    var i = n.measureText(e);
    return n.restore(), {
      width: i.width,
      height: parseInt(`${this.fontSize()}`, 10)
    };
  }
  _setTextData() {
    const { width: e, height: r } = this._getTextSize(this.attrs.text);
    if (this.textWidth = e, this.textHeight = r, this.glyphInfo = [], !this.attrs.data)
      return null;
    const n = this.letterSpacing(), i = this.align(), a = this.kerningFunc(), o = Math.max(this.textWidth + ((this.attrs.text || "").length - 1) * n, 0);
    let s = 0;
    i === "center" && (s = Math.max(0, this.pathLength / 2 - o / 2)), i === "right" && (s = Math.max(0, this.pathLength - o));
    const u = (0, o_.stringToArray)(this.text());
    let c = s;
    for (var l = 0; l < u.length; l++) {
      const d = this._getPointAtLength(c);
      if (!d)
        return;
      let f = this._getTextSize(u[l]).width + n;
      if (u[l] === " " && i === "justify") {
        const y = this.text().split(" ").length - 1;
        f += (this.pathLength - o) / y;
      }
      const h = this._getPointAtLength(c + f);
      if (!h)
        return;
      const m = um.Path.getLineLength(d.x, d.y, h.x, h.y);
      let p = 0;
      if (a)
        try {
          p = a(u[l - 1], u[l]) * this.fontSize();
        } catch {
          p = 0;
        }
      d.x += p, h.x += p, this.textWidth += p;
      const v = um.Path.getPointOnLine(p + m / 2, d.x, d.y, h.x, h.y), g = Math.atan2(h.y - d.y, h.x - d.x);
      this.glyphInfo.push({
        transposeX: v.x,
        transposeY: v.y,
        text: u[l],
        rotation: g,
        p0: d,
        p1: h
      }), c += f;
    }
  }
  getSelfRect() {
    if (!this.glyphInfo.length)
      return {
        x: 0,
        y: 0,
        width: 0,
        height: 0
      };
    var e = [];
    this.glyphInfo.forEach(function(l) {
      e.push(l.p0.x), e.push(l.p0.y), e.push(l.p1.x), e.push(l.p1.y);
    });
    for (var r = e[0] || 0, n = e[0] || 0, i = e[1] || 0, a = e[1] || 0, o, s, u = 0; u < e.length / 2; u++)
      o = e[u * 2], s = e[u * 2 + 1], r = Math.min(r, o), n = Math.max(n, o), i = Math.min(i, s), a = Math.max(a, s);
    var c = this.fontSize();
    return {
      x: r - c / 2,
      y: i - c / 2,
      width: n - r + c,
      height: a - i + c
    };
  }
  destroy() {
    return a_.Util.releaseCanvas(this.dummyCanvas), super.destroy();
  }
}
H4.TextPath = pa;
pa.prototype._fillFunc = oV;
pa.prototype._strokeFunc = sV;
pa.prototype._fillFuncHit = oV;
pa.prototype._strokeFuncHit = sV;
pa.prototype.className = "TextPath";
pa.prototype._attrsAffectingSize = ["text", "fontSize", "data"];
(0, C3e._registerNode)(pa);
Uu.Factory.addGetterSetter(pa, "data");
Uu.Factory.addGetterSetter(pa, "fontFamily", "Arial");
Uu.Factory.addGetterSetter(pa, "fontSize", 12, (0, iV.getNumberValidator)());
Uu.Factory.addGetterSetter(pa, "fontStyle", aV);
Uu.Factory.addGetterSetter(pa, "align", "left");
Uu.Factory.addGetterSetter(pa, "letterSpacing", 0, (0, iV.getNumberValidator)());
Uu.Factory.addGetterSetter(pa, "textBaseline", "middle");
Uu.Factory.addGetterSetter(pa, "fontVariant", aV);
Uu.Factory.addGetterSetter(pa, "text", A3e);
Uu.Factory.addGetterSetter(pa, "textDecoration", null);
Uu.Factory.addGetterSetter(pa, "kerningFunc", null);
var q4 = {};
Object.defineProperty(q4, "__esModule", { value: !0 });
q4.Transformer = void 0;
const In = vi, hn = Fr, aF = si, w3e = fa, D3e = O2, oF = sh, Cu = Br, Cf = Ot, E3e = Br;
var uV = "tr-konva", I3e = [
  "resizeEnabledChange",
  "rotateAnchorOffsetChange",
  "rotateEnabledChange",
  "enabledAnchorsChange",
  "anchorSizeChange",
  "borderEnabledChange",
  "borderStrokeChange",
  "borderStrokeWidthChange",
  "borderDashChange",
  "anchorStrokeChange",
  "anchorStrokeWidthChange",
  "anchorFillChange",
  "anchorCornerRadiusChange",
  "ignoreStrokeChange",
  "anchorStyleFuncChange"
].map((t) => t + `.${uV}`).join(" "), sF = "nodesRect", T3e = [
  "widthChange",
  "heightChange",
  "scaleXChange",
  "scaleYChange",
  "skewXChange",
  "skewYChange",
  "rotationChange",
  "offsetXChange",
  "offsetYChange",
  "transformsEnabledChange",
  "strokeWidthChange"
], M3e = {
  "top-left": -45,
  "top-center": 0,
  "top-right": 45,
  "middle-right": -90,
  "middle-left": 90,
  "bottom-left": -135,
  "bottom-center": 180,
  "bottom-right": 135
};
const P3e = "ontouchstart" in Cu.Konva._global;
function B3e(t, e, r) {
  if (t === "rotater")
    return r;
  e += In.Util.degToRad(M3e[t] || 0);
  var n = (In.Util.radToDeg(e) % 360 + 360) % 360;
  return In.Util._inRange(n, 315 + 22.5, 360) || In.Util._inRange(n, 0, 22.5) ? "ns-resize" : In.Util._inRange(n, 45 - 22.5, 45 + 22.5) ? "nesw-resize" : In.Util._inRange(n, 90 - 22.5, 90 + 22.5) ? "ew-resize" : In.Util._inRange(n, 135 - 22.5, 135 + 22.5) ? "nwse-resize" : In.Util._inRange(n, 180 - 22.5, 180 + 22.5) ? "ns-resize" : In.Util._inRange(n, 225 - 22.5, 225 + 22.5) ? "nesw-resize" : In.Util._inRange(n, 270 - 22.5, 270 + 22.5) ? "ew-resize" : In.Util._inRange(n, 315 - 22.5, 315 + 22.5) ? "nwse-resize" : (In.Util.error("Transformer has unknown angle for cursor detection: " + n), "pointer");
}
var Iy = [
  "top-left",
  "top-center",
  "top-right",
  "middle-right",
  "middle-left",
  "bottom-left",
  "bottom-center",
  "bottom-right"
], uF = 1e8;
function F3e(t) {
  return {
    x: t.x + t.width / 2 * Math.cos(t.rotation) + t.height / 2 * Math.sin(-t.rotation),
    y: t.y + t.height / 2 * Math.cos(t.rotation) + t.width / 2 * Math.sin(t.rotation)
  };
}
function cV(t, e, r) {
  const n = r.x + (t.x - r.x) * Math.cos(e) - (t.y - r.y) * Math.sin(e), i = r.y + (t.x - r.x) * Math.sin(e) + (t.y - r.y) * Math.cos(e);
  return {
    ...t,
    rotation: t.rotation + e,
    x: n,
    y: i
  };
}
function N3e(t, e) {
  const r = F3e(t);
  return cV(t, e, r);
}
function R3e(t, e, r) {
  let n = e;
  for (let i = 0; i < t.length; i++) {
    const a = Cu.Konva.getAngle(t[i]), o = Math.abs(a - e) % (Math.PI * 2);
    Math.min(o, Math.PI * 2 - o) < r && (n = a);
  }
  return n;
}
let P9 = 0;
class Xr extends oF.Group {
  constructor(e) {
    super(e), this._movingAnchorName = null, this._transforming = !1, this._createElements(), this._handleMouseMove = this._handleMouseMove.bind(this), this._handleMouseUp = this._handleMouseUp.bind(this), this.update = this.update.bind(this), this.on(I3e, this.update), this.getNode() && this.update();
  }
  attachTo(e) {
    return this.setNode(e), this;
  }
  setNode(e) {
    return In.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."), this.setNodes([e]);
  }
  getNode() {
    return this._nodes && this._nodes[0];
  }
  _getEventNamespace() {
    return uV + this._id;
  }
  setNodes(e = []) {
    this._nodes && this._nodes.length && this.detach();
    const r = e.filter((i) => i.isAncestorOf(this) ? (In.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"), !1) : !0);
    this._nodes = e = r, e.length === 1 && this.useSingleNodeRotation() ? this.rotation(e[0].getAbsoluteRotation()) : this.rotation(0), this._nodes.forEach((i) => {
      const a = () => {
        this.nodes().length === 1 && this.useSingleNodeRotation() && this.rotation(this.nodes()[0].getAbsoluteRotation()), this._resetTransformCache(), !this._transforming && !this.isDragging() && this.update();
      }, o = i._attrsAffectingSize.map((s) => s + "Change." + this._getEventNamespace()).join(" ");
      i.on(o, a), i.on(T3e.map((s) => s + `.${this._getEventNamespace()}`).join(" "), a), i.on(`absoluteTransformChange.${this._getEventNamespace()}`, a), this._proxyDrag(i);
    }), this._resetTransformCache();
    var n = !!this.findOne(".top-left");
    return n && this.update(), this;
  }
  _proxyDrag(e) {
    let r;
    e.on(`dragstart.${this._getEventNamespace()}`, (n) => {
      r = e.getAbsolutePosition(), !this.isDragging() && e !== this.findOne(".back") && this.startDrag(n, !1);
    }), e.on(`dragmove.${this._getEventNamespace()}`, (n) => {
      if (!r)
        return;
      const i = e.getAbsolutePosition(), a = i.x - r.x, o = i.y - r.y;
      this.nodes().forEach((s) => {
        if (s === e || s.isDragging())
          return;
        const u = s.getAbsolutePosition();
        s.setAbsolutePosition({
          x: u.x + a,
          y: u.y + o
        }), s.startDrag(n);
      }), r = null;
    });
  }
  getNodes() {
    return this._nodes || [];
  }
  getActiveAnchor() {
    return this._movingAnchorName;
  }
  detach() {
    this._nodes && this._nodes.forEach((e) => {
      e.off("." + this._getEventNamespace());
    }), this._nodes = [], this._resetTransformCache();
  }
  _resetTransformCache() {
    this._clearCache(sF), this._clearCache("transform"), this._clearSelfAndDescendantCache("absoluteTransform");
  }
  _getNodeRect() {
    return this._getCache(sF, this.__getNodeRect);
  }
  __getNodeShape(e, r = this.rotation(), n) {
    var i = e.getClientRect({
      skipTransform: !0,
      skipShadow: !0,
      skipStroke: this.ignoreStroke()
    }), a = e.getAbsoluteScale(n), o = e.getAbsolutePosition(n), s = i.x * a.x - e.offsetX() * a.x, u = i.y * a.y - e.offsetY() * a.y;
    const c = (Cu.Konva.getAngle(e.getAbsoluteRotation()) + Math.PI * 2) % (Math.PI * 2), l = {
      x: o.x + s * Math.cos(c) + u * Math.sin(-c),
      y: o.y + u * Math.cos(c) + s * Math.sin(c),
      width: i.width * a.x,
      height: i.height * a.y,
      rotation: c
    };
    return cV(l, -Cu.Konva.getAngle(r), {
      x: 0,
      y: 0
    });
  }
  __getNodeRect() {
    var e = this.getNode();
    if (!e)
      return {
        x: -uF,
        y: -uF,
        width: 0,
        height: 0,
        rotation: 0
      };
    const r = [];
    this.nodes().map((c) => {
      const l = c.getClientRect({
        skipTransform: !0,
        skipShadow: !0,
        skipStroke: this.ignoreStroke()
      });
      var d = [
        { x: l.x, y: l.y },
        { x: l.x + l.width, y: l.y },
        { x: l.x + l.width, y: l.y + l.height },
        { x: l.x, y: l.y + l.height }
      ], f = c.getAbsoluteTransform();
      d.forEach(function(h) {
        var m = f.point(h);
        r.push(m);
      });
    });
    const n = new In.Transform();
    n.rotate(-Cu.Konva.getAngle(this.rotation()));
    var i = 1 / 0, a = 1 / 0, o = -1 / 0, s = -1 / 0;
    r.forEach(function(c) {
      var l = n.point(c);
      i === void 0 && (i = o = l.x, a = s = l.y), i = Math.min(i, l.x), a = Math.min(a, l.y), o = Math.max(o, l.x), s = Math.max(s, l.y);
    }), n.invert();
    const u = n.point({ x: i, y: a });
    return {
      x: u.x,
      y: u.y,
      width: o - i,
      height: s - a,
      rotation: Cu.Konva.getAngle(this.rotation())
    };
  }
  getX() {
    return this._getNodeRect().x;
  }
  getY() {
    return this._getNodeRect().y;
  }
  getWidth() {
    return this._getNodeRect().width;
  }
  getHeight() {
    return this._getNodeRect().height;
  }
  _createElements() {
    this._createBack(), Iy.forEach((e) => {
      this._createAnchor(e);
    }), this._createAnchor("rotater");
  }
  _createAnchor(e) {
    var r = new D3e.Rect({
      stroke: "rgb(0, 161, 255)",
      fill: "white",
      strokeWidth: 1,
      name: e + " _anchor",
      dragDistance: 0,
      draggable: !0,
      hitStrokeWidth: P3e ? 10 : "auto"
    }), n = this;
    r.on("mousedown touchstart", function(i) {
      n._handleMouseDown(i);
    }), r.on("dragstart", (i) => {
      r.stopDrag(), i.cancelBubble = !0;
    }), r.on("dragend", (i) => {
      i.cancelBubble = !0;
    }), r.on("mouseenter", () => {
      var i = Cu.Konva.getAngle(this.rotation()), a = this.rotateAnchorCursor(), o = B3e(e, i, a);
      r.getStage().content && (r.getStage().content.style.cursor = o), this._cursorChange = !0;
    }), r.on("mouseout", () => {
      r.getStage().content && (r.getStage().content.style.cursor = ""), this._cursorChange = !1;
    }), this.add(r);
  }
  _createBack() {
    var e = new w3e.Shape({
      name: "back",
      width: 0,
      height: 0,
      draggable: !0,
      sceneFunc(r, n) {
        var i = n.getParent(), a = i.padding();
        r.beginPath(), r.rect(-a, -a, n.width() + a * 2, n.height() + a * 2), r.moveTo(n.width() / 2, -a), i.rotateEnabled() && i.rotateLineVisible() && r.lineTo(n.width() / 2, -i.rotateAnchorOffset() * In.Util._sign(n.height()) - a), r.fillStrokeShape(n);
      },
      hitFunc: (r, n) => {
        if (this.shouldOverdrawWholeArea()) {
          var i = this.padding();
          r.beginPath(), r.rect(-i, -i, n.width() + i * 2, n.height() + i * 2), r.fillStrokeShape(n);
        }
      }
    });
    this.add(e), this._proxyDrag(e), e.on("dragstart", (r) => {
      r.cancelBubble = !0;
    }), e.on("dragmove", (r) => {
      r.cancelBubble = !0;
    }), e.on("dragend", (r) => {
      r.cancelBubble = !0;
    }), this.on("dragmove", (r) => {
      this.update();
    });
  }
  _handleMouseDown(e) {
    if (!this._transforming) {
      this._movingAnchorName = e.target.name().split(" ")[0];
      var r = this._getNodeRect(), n = r.width, i = r.height, a = Math.sqrt(Math.pow(n, 2) + Math.pow(i, 2));
      this.sin = Math.abs(i / a), this.cos = Math.abs(n / a), typeof window < "u" && (window.addEventListener("mousemove", this._handleMouseMove), window.addEventListener("touchmove", this._handleMouseMove), window.addEventListener("mouseup", this._handleMouseUp, !0), window.addEventListener("touchend", this._handleMouseUp, !0)), this._transforming = !0;
      var o = e.target.getAbsolutePosition(), s = e.target.getStage().getPointerPosition();
      this._anchorDragOffset = {
        x: s.x - o.x,
        y: s.y - o.y
      }, P9++, this._fire("transformstart", { evt: e.evt, target: this.getNode() }), this._nodes.forEach((u) => {
        u._fire("transformstart", { evt: e.evt, target: u });
      });
    }
  }
  _handleMouseMove(e) {
    var r, n, i, a = this.findOne("." + this._movingAnchorName), o = a.getStage();
    o.setPointersPositions(e);
    const s = o.getPointerPosition();
    let u = {
      x: s.x - this._anchorDragOffset.x,
      y: s.y - this._anchorDragOffset.y
    };
    const c = a.getAbsolutePosition();
    this.anchorDragBoundFunc() && (u = this.anchorDragBoundFunc()(c, u, e)), a.setAbsolutePosition(u);
    const l = a.getAbsolutePosition();
    if (!(c.x === l.x && c.y === l.y)) {
      if (this._movingAnchorName === "rotater") {
        var d = this._getNodeRect();
        r = a.x() - d.width / 2, n = -a.y() + d.height / 2;
        let T = Math.atan2(-n, r) + Math.PI / 2;
        d.height < 0 && (T -= Math.PI);
        var f = Cu.Konva.getAngle(this.rotation());
        const F = f + T, N = Cu.Konva.getAngle(this.rotationSnapTolerance()), L = R3e(this.rotationSnaps(), F, N) - d.rotation, V = N3e(d, L);
        this._fitNodesInto(V, e);
        return;
      }
      var h = this.shiftBehavior(), m;
      h === "inverted" ? m = this.keepRatio() && !e.shiftKey : h === "none" ? m = this.keepRatio() : m = this.keepRatio() || e.shiftKey;
      var b = this.centeredScaling() || e.altKey;
      if (this._movingAnchorName === "top-left") {
        if (m) {
          var p = b ? {
            x: this.width() / 2,
            y: this.height() / 2
          } : {
            x: this.findOne(".bottom-right").x(),
            y: this.findOne(".bottom-right").y()
          };
          i = Math.sqrt(Math.pow(p.x - a.x(), 2) + Math.pow(p.y - a.y(), 2));
          var v = this.findOne(".top-left").x() > p.x ? -1 : 1, g = this.findOne(".top-left").y() > p.y ? -1 : 1;
          r = i * this.cos * v, n = i * this.sin * g, this.findOne(".top-left").x(p.x - r), this.findOne(".top-left").y(p.y - n);
        }
      } else if (this._movingAnchorName === "top-center")
        this.findOne(".top-left").y(a.y());
      else if (this._movingAnchorName === "top-right") {
        if (m) {
          var p = b ? {
            x: this.width() / 2,
            y: this.height() / 2
          } : {
            x: this.findOne(".bottom-left").x(),
            y: this.findOne(".bottom-left").y()
          };
          i = Math.sqrt(Math.pow(a.x() - p.x, 2) + Math.pow(p.y - a.y(), 2));
          var v = this.findOne(".top-right").x() < p.x ? -1 : 1, g = this.findOne(".top-right").y() > p.y ? -1 : 1;
          r = i * this.cos * v, n = i * this.sin * g, this.findOne(".top-right").x(p.x + r), this.findOne(".top-right").y(p.y - n);
        }
        var y = a.position();
        this.findOne(".top-left").y(y.y), this.findOne(".bottom-right").x(y.x);
      } else if (this._movingAnchorName === "middle-left")
        this.findOne(".top-left").x(a.x());
      else if (this._movingAnchorName === "middle-right")
        this.findOne(".bottom-right").x(a.x());
      else if (this._movingAnchorName === "bottom-left") {
        if (m) {
          var p = b ? {
            x: this.width() / 2,
            y: this.height() / 2
          } : {
            x: this.findOne(".top-right").x(),
            y: this.findOne(".top-right").y()
          };
          i = Math.sqrt(Math.pow(p.x - a.x(), 2) + Math.pow(a.y() - p.y, 2));
          var v = p.x < a.x() ? -1 : 1, g = a.y() < p.y ? -1 : 1;
          r = i * this.cos * v, n = i * this.sin * g, a.x(p.x - r), a.y(p.y + n);
        }
        y = a.position(), this.findOne(".top-left").x(y.x), this.findOne(".bottom-right").y(y.y);
      } else if (this._movingAnchorName === "bottom-center")
        this.findOne(".bottom-right").y(a.y());
      else if (this._movingAnchorName === "bottom-right") {
        if (m) {
          var p = b ? {
            x: this.width() / 2,
            y: this.height() / 2
          } : {
            x: this.findOne(".top-left").x(),
            y: this.findOne(".top-left").y()
          };
          i = Math.sqrt(Math.pow(a.x() - p.x, 2) + Math.pow(a.y() - p.y, 2));
          var v = this.findOne(".bottom-right").x() < p.x ? -1 : 1, g = this.findOne(".bottom-right").y() < p.y ? -1 : 1;
          r = i * this.cos * v, n = i * this.sin * g, this.findOne(".bottom-right").x(p.x + r), this.findOne(".bottom-right").y(p.y + n);
        }
      } else
        console.error(new Error("Wrong position argument of selection resizer: " + this._movingAnchorName));
      var b = this.centeredScaling() || e.altKey;
      if (b) {
        var S = this.findOne(".top-left"), _ = this.findOne(".bottom-right"), x = S.x(), C = S.y(), A = this.getWidth() - _.x(), w = this.getHeight() - _.y();
        _.move({
          x: -x,
          y: -C
        }), S.move({
          x: A,
          y: w
        });
      }
      var I = this.findOne(".top-left").getAbsolutePosition();
      r = I.x, n = I.y;
      var P = this.findOne(".bottom-right").x() - this.findOne(".top-left").x(), M = this.findOne(".bottom-right").y() - this.findOne(".top-left").y();
      this._fitNodesInto({
        x: r,
        y: n,
        width: P,
        height: M,
        rotation: Cu.Konva.getAngle(this.rotation())
      }, e);
    }
  }
  _handleMouseUp(e) {
    this._removeEvents(e);
  }
  getAbsoluteTransform() {
    return this.getTransform();
  }
  _removeEvents(e) {
    var r;
    if (this._transforming) {
      this._transforming = !1, typeof window < "u" && (window.removeEventListener("mousemove", this._handleMouseMove), window.removeEventListener("touchmove", this._handleMouseMove), window.removeEventListener("mouseup", this._handleMouseUp, !0), window.removeEventListener("touchend", this._handleMouseUp, !0));
      var n = this.getNode();
      P9--, this._fire("transformend", { evt: e, target: n }), (r = this.getLayer()) === null || r === void 0 || r.batchDraw(), n && this._nodes.forEach((i) => {
        var a;
        i._fire("transformend", { evt: e, target: i }), (a = i.getLayer()) === null || a === void 0 || a.batchDraw();
      }), this._movingAnchorName = null;
    }
  }
  _fitNodesInto(e, r) {
    var n = this._getNodeRect();
    const i = 1;
    if (In.Util._inRange(e.width, -this.padding() * 2 - i, i)) {
      this.update();
      return;
    }
    if (In.Util._inRange(e.height, -this.padding() * 2 - i, i)) {
      this.update();
      return;
    }
    var a = new In.Transform();
    if (a.rotate(Cu.Konva.getAngle(this.rotation())), this._movingAnchorName && e.width < 0 && this._movingAnchorName.indexOf("left") >= 0) {
      const f = a.point({
        x: -this.padding() * 2,
        y: 0
      });
      e.x += f.x, e.y += f.y, e.width += this.padding() * 2, this._movingAnchorName = this._movingAnchorName.replace("left", "right"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y;
    } else if (this._movingAnchorName && e.width < 0 && this._movingAnchorName.indexOf("right") >= 0) {
      const f = a.point({
        x: this.padding() * 2,
        y: 0
      });
      this._movingAnchorName = this._movingAnchorName.replace("right", "left"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, e.width += this.padding() * 2;
    }
    if (this._movingAnchorName && e.height < 0 && this._movingAnchorName.indexOf("top") >= 0) {
      const f = a.point({
        x: 0,
        y: -this.padding() * 2
      });
      e.x += f.x, e.y += f.y, this._movingAnchorName = this._movingAnchorName.replace("top", "bottom"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, e.height += this.padding() * 2;
    } else if (this._movingAnchorName && e.height < 0 && this._movingAnchorName.indexOf("bottom") >= 0) {
      const f = a.point({
        x: 0,
        y: this.padding() * 2
      });
      this._movingAnchorName = this._movingAnchorName.replace("bottom", "top"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, e.height += this.padding() * 2;
    }
    if (this.boundBoxFunc()) {
      const f = this.boundBoxFunc()(n, e);
      f ? e = f : In.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!");
    }
    const o = 1e7, s = new In.Transform();
    s.translate(n.x, n.y), s.rotate(n.rotation), s.scale(n.width / o, n.height / o);
    const u = new In.Transform(), c = e.width / o, l = e.height / o;
    this.flipEnabled() === !1 ? (u.translate(e.x, e.y), u.rotate(e.rotation), u.translate(e.width < 0 ? e.width : 0, e.height < 0 ? e.height : 0), u.scale(Math.abs(c), Math.abs(l))) : (u.translate(e.x, e.y), u.rotate(e.rotation), u.scale(c, l));
    const d = u.multiply(s.invert());
    this._nodes.forEach((f) => {
      var h;
      const m = f.getParent().getAbsoluteTransform(), p = f.getTransform().copy();
      p.translate(f.offsetX(), f.offsetY());
      const v = new In.Transform();
      v.multiply(m.copy().invert()).multiply(d).multiply(m).multiply(p);
      const g = v.decompose();
      f.setAttrs(g), (h = f.getLayer()) === null || h === void 0 || h.batchDraw();
    }), this.rotation(In.Util._getRotation(e.rotation)), this._nodes.forEach((f) => {
      this._fire("transform", { evt: r, target: f }), f._fire("transform", { evt: r, target: f });
    }), this._resetTransformCache(), this.update(), this.getLayer().batchDraw();
  }
  forceUpdate() {
    this._resetTransformCache(), this.update();
  }
  _batchChangeChild(e, r) {
    this.findOne(e).setAttrs(r);
  }
  update() {
    var e, r = this._getNodeRect();
    this.rotation(In.Util._getRotation(r.rotation));
    var n = r.width, i = r.height, a = this.enabledAnchors(), o = this.resizeEnabled(), s = this.padding(), u = this.anchorSize();
    const c = this.find("._anchor");
    c.forEach((d) => {
      d.setAttrs({
        width: u,
        height: u,
        offsetX: u / 2,
        offsetY: u / 2,
        stroke: this.anchorStroke(),
        strokeWidth: this.anchorStrokeWidth(),
        fill: this.anchorFill(),
        cornerRadius: this.anchorCornerRadius()
      });
    }), this._batchChangeChild(".top-left", {
      x: 0,
      y: 0,
      offsetX: u / 2 + s,
      offsetY: u / 2 + s,
      visible: o && a.indexOf("top-left") >= 0
    }), this._batchChangeChild(".top-center", {
      x: n / 2,
      y: 0,
      offsetY: u / 2 + s,
      visible: o && a.indexOf("top-center") >= 0
    }), this._batchChangeChild(".top-right", {
      x: n,
      y: 0,
      offsetX: u / 2 - s,
      offsetY: u / 2 + s,
      visible: o && a.indexOf("top-right") >= 0
    }), this._batchChangeChild(".middle-left", {
      x: 0,
      y: i / 2,
      offsetX: u / 2 + s,
      visible: o && a.indexOf("middle-left") >= 0
    }), this._batchChangeChild(".middle-right", {
      x: n,
      y: i / 2,
      offsetX: u / 2 - s,
      visible: o && a.indexOf("middle-right") >= 0
    }), this._batchChangeChild(".bottom-left", {
      x: 0,
      y: i,
      offsetX: u / 2 + s,
      offsetY: u / 2 - s,
      visible: o && a.indexOf("bottom-left") >= 0
    }), this._batchChangeChild(".bottom-center", {
      x: n / 2,
      y: i,
      offsetY: u / 2 - s,
      visible: o && a.indexOf("bottom-center") >= 0
    }), this._batchChangeChild(".bottom-right", {
      x: n,
      y: i,
      offsetX: u / 2 - s,
      offsetY: u / 2 - s,
      visible: o && a.indexOf("bottom-right") >= 0
    }), this._batchChangeChild(".rotater", {
      x: n / 2,
      y: -this.rotateAnchorOffset() * In.Util._sign(i) - s,
      visible: this.rotateEnabled()
    }), this._batchChangeChild(".back", {
      width: n,
      height: i,
      visible: this.borderEnabled(),
      stroke: this.borderStroke(),
      strokeWidth: this.borderStrokeWidth(),
      dash: this.borderDash(),
      x: 0,
      y: 0
    });
    const l = this.anchorStyleFunc();
    l && c.forEach((d) => {
      l(d);
    }), (e = this.getLayer()) === null || e === void 0 || e.batchDraw();
  }
  isTransforming() {
    return this._transforming;
  }
  stopTransform() {
    if (this._transforming) {
      this._removeEvents();
      var e = this.findOne("." + this._movingAnchorName);
      e && e.stopDrag();
    }
  }
  destroy() {
    return this.getStage() && this._cursorChange && this.getStage().content && (this.getStage().content.style.cursor = ""), oF.Group.prototype.destroy.call(this), this.detach(), this._removeEvents(), this;
  }
  toObject() {
    return aF.Node.prototype.toObject.call(this);
  }
  clone(e) {
    var r = aF.Node.prototype.clone.call(this, e);
    return r;
  }
  getClientRect() {
    return this.nodes().length > 0 ? super.getClientRect() : { x: 0, y: 0, width: 0, height: 0 };
  }
}
q4.Transformer = Xr;
Xr.isTransforming = () => P9 > 0;
function O3e(t) {
  return t instanceof Array || In.Util.warn("enabledAnchors value should be an array"), t instanceof Array && t.forEach(function(e) {
    Iy.indexOf(e) === -1 && In.Util.warn("Unknown anchor name: " + e + ". Available names are: " + Iy.join(", "));
  }), t || [];
}
Xr.prototype.className = "Transformer";
(0, E3e._registerNode)(Xr);
hn.Factory.addGetterSetter(Xr, "enabledAnchors", Iy, O3e);
hn.Factory.addGetterSetter(Xr, "flipEnabled", !0, (0, Cf.getBooleanValidator)());
hn.Factory.addGetterSetter(Xr, "resizeEnabled", !0);
hn.Factory.addGetterSetter(Xr, "anchorSize", 10, (0, Cf.getNumberValidator)());
hn.Factory.addGetterSetter(Xr, "rotateEnabled", !0);
hn.Factory.addGetterSetter(Xr, "rotateLineVisible", !0);
hn.Factory.addGetterSetter(Xr, "rotationSnaps", []);
hn.Factory.addGetterSetter(Xr, "rotateAnchorOffset", 50, (0, Cf.getNumberValidator)());
hn.Factory.addGetterSetter(Xr, "rotateAnchorCursor", "crosshair");
hn.Factory.addGetterSetter(Xr, "rotationSnapTolerance", 5, (0, Cf.getNumberValidator)());
hn.Factory.addGetterSetter(Xr, "borderEnabled", !0);
hn.Factory.addGetterSetter(Xr, "anchorStroke", "rgb(0, 161, 255)");
hn.Factory.addGetterSetter(Xr, "anchorStrokeWidth", 1, (0, Cf.getNumberValidator)());
hn.Factory.addGetterSetter(Xr, "anchorFill", "white");
hn.Factory.addGetterSetter(Xr, "anchorCornerRadius", 0, (0, Cf.getNumberValidator)());
hn.Factory.addGetterSetter(Xr, "borderStroke", "rgb(0, 161, 255)");
hn.Factory.addGetterSetter(Xr, "borderStrokeWidth", 1, (0, Cf.getNumberValidator)());
hn.Factory.addGetterSetter(Xr, "borderDash");
hn.Factory.addGetterSetter(Xr, "keepRatio", !0);
hn.Factory.addGetterSetter(Xr, "shiftBehavior", "default");
hn.Factory.addGetterSetter(Xr, "centeredScaling", !1);
hn.Factory.addGetterSetter(Xr, "ignoreStroke", !1);
hn.Factory.addGetterSetter(Xr, "padding", 0, (0, Cf.getNumberValidator)());
hn.Factory.addGetterSetter(Xr, "node");
hn.Factory.addGetterSetter(Xr, "nodes");
hn.Factory.addGetterSetter(Xr, "boundBoxFunc");
hn.Factory.addGetterSetter(Xr, "anchorDragBoundFunc");
hn.Factory.addGetterSetter(Xr, "anchorStyleFunc");
hn.Factory.addGetterSetter(Xr, "shouldOverdrawWholeArea", !1);
hn.Factory.addGetterSetter(Xr, "useSingleNodeRotation", !0);
hn.Factory.backCompat(Xr, {
  lineEnabled: "borderEnabled",
  rotateHandlerOffset: "rotateAnchorOffset",
  enabledHandlers: "enabledAnchors"
});
var K4 = {};
Object.defineProperty(K4, "__esModule", { value: !0 });
K4.Wedge = void 0;
const X4 = Fr, L3e = fa, k3e = Br, lV = Ot, G3e = Br;
class Vl extends L3e.Shape {
  _sceneFunc(e) {
    e.beginPath(), e.arc(0, 0, this.radius(), 0, k3e.Konva.getAngle(this.angle()), this.clockwise()), e.lineTo(0, 0), e.closePath(), e.fillStrokeShape(this);
  }
  getWidth() {
    return this.radius() * 2;
  }
  getHeight() {
    return this.radius() * 2;
  }
  setWidth(e) {
    this.radius(e / 2);
  }
  setHeight(e) {
    this.radius(e / 2);
  }
}
K4.Wedge = Vl;
Vl.prototype.className = "Wedge";
Vl.prototype._centroid = !0;
Vl.prototype._attrsAffectingSize = ["radius"];
(0, G3e._registerNode)(Vl);
X4.Factory.addGetterSetter(Vl, "radius", 0, (0, lV.getNumberValidator)());
X4.Factory.addGetterSetter(Vl, "angle", 0, (0, lV.getNumberValidator)());
X4.Factory.addGetterSetter(Vl, "clockwise", !1);
X4.Factory.backCompat(Vl, {
  angleDeg: "angle",
  getAngleDeg: "getAngle",
  setAngleDeg: "setAngle"
});
var Y4 = {};
Object.defineProperty(Y4, "__esModule", { value: !0 });
Y4.Blur = void 0;
const cF = Fr, z3e = si, V3e = Ot;
function lF() {
  this.r = 0, this.g = 0, this.b = 0, this.a = 0, this.next = null;
}
var U3e = [
  512,
  512,
  456,
  512,
  328,
  456,
  335,
  512,
  405,
  328,
  271,
  456,
  388,
  335,
  292,
  512,
  454,
  405,
  364,
  328,
  298,
  271,
  496,
  456,
  420,
  388,
  360,
  335,
  312,
  292,
  273,
  512,
  482,
  454,
  428,
  405,
  383,
  364,
  345,
  328,
  312,
  298,
  284,
  271,
  259,
  496,
  475,
  456,
  437,
  420,
  404,
  388,
  374,
  360,
  347,
  335,
  323,
  312,
  302,
  292,
  282,
  273,
  265,
  512,
  497,
  482,
  468,
  454,
  441,
  428,
  417,
  405,
  394,
  383,
  373,
  364,
  354,
  345,
  337,
  328,
  320,
  312,
  305,
  298,
  291,
  284,
  278,
  271,
  265,
  259,
  507,
  496,
  485,
  475,
  465,
  456,
  446,
  437,
  428,
  420,
  412,
  404,
  396,
  388,
  381,
  374,
  367,
  360,
  354,
  347,
  341,
  335,
  329,
  323,
  318,
  312,
  307,
  302,
  297,
  292,
  287,
  282,
  278,
  273,
  269,
  265,
  261,
  512,
  505,
  497,
  489,
  482,
  475,
  468,
  461,
  454,
  447,
  441,
  435,
  428,
  422,
  417,
  411,
  405,
  399,
  394,
  389,
  383,
  378,
  373,
  368,
  364,
  359,
  354,
  350,
  345,
  341,
  337,
  332,
  328,
  324,
  320,
  316,
  312,
  309,
  305,
  301,
  298,
  294,
  291,
  287,
  284,
  281,
  278,
  274,
  271,
  268,
  265,
  262,
  259,
  257,
  507,
  501,
  496,
  491,
  485,
  480,
  475,
  470,
  465,
  460,
  456,
  451,
  446,
  442,
  437,
  433,
  428,
  424,
  420,
  416,
  412,
  408,
  404,
  400,
  396,
  392,
  388,
  385,
  381,
  377,
  374,
  370,
  367,
  363,
  360,
  357,
  354,
  350,
  347,
  344,
  341,
  338,
  335,
  332,
  329,
  326,
  323,
  320,
  318,
  315,
  312,
  310,
  307,
  304,
  302,
  299,
  297,
  294,
  292,
  289,
  287,
  285,
  282,
  280,
  278,
  275,
  273,
  271,
  269,
  267,
  265,
  263,
  261,
  259
], H3e = [
  9,
  11,
  12,
  13,
  13,
  14,
  14,
  15,
  15,
  15,
  15,
  16,
  16,
  16,
  16,
  17,
  17,
  17,
  17,
  17,
  17,
  17,
  18,
  18,
  18,
  18,
  18,
  18,
  18,
  18,
  18,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24
];
function q3e(t, e) {
  var r = t.data, n = t.width, i = t.height, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b, S, _, x, C, A, w, I, P, M, T = e + e + 1, F = n - 1, N = i - 1, R = e + 1, L = R * (R + 1) / 2, V = new lF(), U = null, H = V, K = null, X = null, Y = U3e[e], Q = H3e[e];
  for (s = 1; s < T; s++)
    H = H.next = new lF(), s === R && (U = H);
  for (H.next = V, d = l = 0, o = 0; o < i; o++) {
    for (S = _ = x = C = f = h = m = p = 0, v = R * (A = r[l]), g = R * (w = r[l + 1]), y = R * (I = r[l + 2]), b = R * (P = r[l + 3]), f += L * A, h += L * w, m += L * I, p += L * P, H = V, s = 0; s < R; s++)
      H.r = A, H.g = w, H.b = I, H.a = P, H = H.next;
    for (s = 1; s < R; s++)
      u = l + ((F < s ? F : s) << 2), f += (H.r = A = r[u]) * (M = R - s), h += (H.g = w = r[u + 1]) * M, m += (H.b = I = r[u + 2]) * M, p += (H.a = P = r[u + 3]) * M, S += A, _ += w, x += I, C += P, H = H.next;
    for (K = V, X = U, a = 0; a < n; a++)
      r[l + 3] = P = p * Y >> Q, P !== 0 ? (P = 255 / P, r[l] = (f * Y >> Q) * P, r[l + 1] = (h * Y >> Q) * P, r[l + 2] = (m * Y >> Q) * P) : r[l] = r[l + 1] = r[l + 2] = 0, f -= v, h -= g, m -= y, p -= b, v -= K.r, g -= K.g, y -= K.b, b -= K.a, u = d + ((u = a + e + 1) < F ? u : F) << 2, S += K.r = r[u], _ += K.g = r[u + 1], x += K.b = r[u + 2], C += K.a = r[u + 3], f += S, h += _, m += x, p += C, K = K.next, v += A = X.r, g += w = X.g, y += I = X.b, b += P = X.a, S -= A, _ -= w, x -= I, C -= P, X = X.next, l += 4;
    d += n;
  }
  for (a = 0; a < n; a++) {
    for (_ = x = C = S = h = m = p = f = 0, l = a << 2, v = R * (A = r[l]), g = R * (w = r[l + 1]), y = R * (I = r[l + 2]), b = R * (P = r[l + 3]), f += L * A, h += L * w, m += L * I, p += L * P, H = V, s = 0; s < R; s++)
      H.r = A, H.g = w, H.b = I, H.a = P, H = H.next;
    for (c = n, s = 1; s <= e; s++)
      l = c + a << 2, f += (H.r = A = r[l]) * (M = R - s), h += (H.g = w = r[l + 1]) * M, m += (H.b = I = r[l + 2]) * M, p += (H.a = P = r[l + 3]) * M, S += A, _ += w, x += I, C += P, H = H.next, s < N && (c += n);
    for (l = a, K = V, X = U, o = 0; o < i; o++)
      u = l << 2, r[u + 3] = P = p * Y >> Q, P > 0 ? (P = 255 / P, r[u] = (f * Y >> Q) * P, r[u + 1] = (h * Y >> Q) * P, r[u + 2] = (m * Y >> Q) * P) : r[u] = r[u + 1] = r[u + 2] = 0, f -= v, h -= g, m -= y, p -= b, v -= K.r, g -= K.g, y -= K.b, b -= K.a, u = a + ((u = o + R) < N ? u : N) * n << 2, f += S += K.r = r[u], h += _ += K.g = r[u + 1], m += x += K.b = r[u + 2], p += C += K.a = r[u + 3], K = K.next, v += A = X.r, g += w = X.g, y += I = X.b, b += P = X.a, S -= A, _ -= w, x -= I, C -= P, X = X.next, l += n;
  }
}
const K3e = function(e) {
  var r = Math.round(this.blurRadius());
  r > 0 && q3e(e, r);
};
Y4.Blur = K3e;
cF.Factory.addGetterSetter(z3e.Node, "blurRadius", 0, (0, V3e.getNumberValidator)(), cF.Factory.afterSetFilter);
var W4 = {};
Object.defineProperty(W4, "__esModule", { value: !0 });
W4.Brighten = void 0;
const dF = Fr, X3e = si, Y3e = Ot, W3e = function(t) {
  var e = this.brightness() * 255, r = t.data, n = r.length, i;
  for (i = 0; i < n; i += 4)
    r[i] += e, r[i + 1] += e, r[i + 2] += e;
};
W4.Brighten = W3e;
dF.Factory.addGetterSetter(X3e.Node, "brightness", 0, (0, Y3e.getNumberValidator)(), dF.Factory.afterSetFilter);
var j4 = {};
Object.defineProperty(j4, "__esModule", { value: !0 });
j4.Contrast = void 0;
const fF = Fr, j3e = si, Z3e = Ot, Q3e = function(t) {
  var e = Math.pow((this.contrast() + 100) / 100, 2), r = t.data, n = r.length, i = 150, a = 150, o = 150, s;
  for (s = 0; s < n; s += 4)
    i = r[s], a = r[s + 1], o = r[s + 2], i /= 255, i -= 0.5, i *= e, i += 0.5, i *= 255, a /= 255, a -= 0.5, a *= e, a += 0.5, a *= 255, o /= 255, o -= 0.5, o *= e, o += 0.5, o *= 255, i = i < 0 ? 0 : i > 255 ? 255 : i, a = a < 0 ? 0 : a > 255 ? 255 : a, o = o < 0 ? 0 : o > 255 ? 255 : o, r[s] = i, r[s + 1] = a, r[s + 2] = o;
};
j4.Contrast = Q3e;
fF.Factory.addGetterSetter(j3e.Node, "contrast", 0, (0, Z3e.getNumberValidator)(), fF.Factory.afterSetFilter);
var Z4 = {};
Object.defineProperty(Z4, "__esModule", { value: !0 });
Z4.Emboss = void 0;
const ff = Fr, Q4 = si, J3e = vi, dV = Ot, $3e = function(t) {
  var e = this.embossStrength() * 10, r = this.embossWhiteLevel() * 255, n = this.embossDirection(), i = this.embossBlend(), a = 0, o = 0, s = t.data, u = t.width, c = t.height, l = u * 4, d = c;
  switch (n) {
    case "top-left":
      a = -1, o = -1;
      break;
    case "top":
      a = -1, o = 0;
      break;
    case "top-right":
      a = -1, o = 1;
      break;
    case "right":
      a = 0, o = 1;
      break;
    case "bottom-right":
      a = 1, o = 1;
      break;
    case "bottom":
      a = 1, o = 0;
      break;
    case "bottom-left":
      a = 1, o = -1;
      break;
    case "left":
      a = 0, o = -1;
      break;
    default:
      J3e.Util.error("Unknown emboss direction: " + n);
  }
  do {
    var f = (d - 1) * l, h = a;
    d + h < 1 && (h = 0), d + h > c && (h = 0);
    var m = (d - 1 + h) * u * 4, p = u;
    do {
      var v = f + (p - 1) * 4, g = o;
      p + g < 1 && (g = 0), p + g > u && (g = 0);
      var y = m + (p - 1 + g) * 4, b = s[v] - s[y], S = s[v + 1] - s[y + 1], _ = s[v + 2] - s[y + 2], x = b, C = x > 0 ? x : -x, A = S > 0 ? S : -S, w = _ > 0 ? _ : -_;
      if (A > C && (x = S), w > C && (x = _), x *= e, i) {
        var I = s[v] + x, P = s[v + 1] + x, M = s[v + 2] + x;
        s[v] = I > 255 ? 255 : I < 0 ? 0 : I, s[v + 1] = P > 255 ? 255 : P < 0 ? 0 : P, s[v + 2] = M > 255 ? 255 : M < 0 ? 0 : M;
      } else {
        var T = r - x;
        T < 0 ? T = 0 : T > 255 && (T = 255), s[v] = s[v + 1] = s[v + 2] = T;
      }
    } while (--p);
  } while (--d);
};
Z4.Emboss = $3e;
ff.Factory.addGetterSetter(Q4.Node, "embossStrength", 0.5, (0, dV.getNumberValidator)(), ff.Factory.afterSetFilter);
ff.Factory.addGetterSetter(Q4.Node, "embossWhiteLevel", 0.5, (0, dV.getNumberValidator)(), ff.Factory.afterSetFilter);
ff.Factory.addGetterSetter(Q4.Node, "embossDirection", "top-left", null, ff.Factory.afterSetFilter);
ff.Factory.addGetterSetter(Q4.Node, "embossBlend", !1, null, ff.Factory.afterSetFilter);
var J4 = {};
Object.defineProperty(J4, "__esModule", { value: !0 });
J4.Enhance = void 0;
const pF = Fr, eye = si, tye = Ot;
function s_(t, e, r, n, i) {
  var a = r - e, o = i - n, s;
  return a === 0 ? n + o / 2 : o === 0 ? n : (s = (t - e) / a, s = o * s + n, s);
}
const rye = function(t) {
  var e = t.data, r = e.length, n = e[0], i = n, a, o = e[1], s = o, u, c = e[2], l = c, d, f, h = this.enhance();
  if (h !== 0) {
    for (f = 0; f < r; f += 4)
      a = e[f + 0], a < n ? n = a : a > i && (i = a), u = e[f + 1], u < o ? o = u : u > s && (s = u), d = e[f + 2], d < c ? c = d : d > l && (l = d);
    i === n && (i = 255, n = 0), s === o && (s = 255, o = 0), l === c && (l = 255, c = 0);
    var m, p, v, g, y, b, S, _, x;
    for (h > 0 ? (p = i + h * (255 - i), v = n - h * (n - 0), y = s + h * (255 - s), b = o - h * (o - 0), _ = l + h * (255 - l), x = c - h * (c - 0)) : (m = (i + n) * 0.5, p = i + h * (i - m), v = n + h * (n - m), g = (s + o) * 0.5, y = s + h * (s - g), b = o + h * (o - g), S = (l + c) * 0.5, _ = l + h * (l - S), x = c + h * (c - S)), f = 0; f < r; f += 4)
      e[f + 0] = s_(e[f + 0], n, i, v, p), e[f + 1] = s_(e[f + 1], o, s, b, y), e[f + 2] = s_(e[f + 2], c, l, x, _);
  }
};
J4.Enhance = rye;
pF.Factory.addGetterSetter(eye.Node, "enhance", 0, (0, tye.getNumberValidator)(), pF.Factory.afterSetFilter);
var $4 = {};
Object.defineProperty($4, "__esModule", { value: !0 });
$4.Grayscale = void 0;
const nye = function(t) {
  var e = t.data, r = e.length, n, i;
  for (n = 0; n < r; n += 4)
    i = 0.34 * e[n] + 0.5 * e[n + 1] + 0.16 * e[n + 2], e[n] = i, e[n + 1] = i, e[n + 2] = i;
};
$4.Grayscale = nye;
var e5 = {};
Object.defineProperty(e5, "__esModule", { value: !0 });
e5.HSL = void 0;
const Kp = Fr, AS = si, wS = Ot;
Kp.Factory.addGetterSetter(AS.Node, "hue", 0, (0, wS.getNumberValidator)(), Kp.Factory.afterSetFilter);
Kp.Factory.addGetterSetter(AS.Node, "saturation", 0, (0, wS.getNumberValidator)(), Kp.Factory.afterSetFilter);
Kp.Factory.addGetterSetter(AS.Node, "luminance", 0, (0, wS.getNumberValidator)(), Kp.Factory.afterSetFilter);
const iye = function(t) {
  var e = t.data, r = e.length, n = 1, i = Math.pow(2, this.saturation()), a = Math.abs(this.hue() + 360) % 360, o = this.luminance() * 127, s, u = n * i * Math.cos(a * Math.PI / 180), c = n * i * Math.sin(a * Math.PI / 180), l = 0.299 * n + 0.701 * u + 0.167 * c, d = 0.587 * n - 0.587 * u + 0.33 * c, f = 0.114 * n - 0.114 * u - 0.497 * c, h = 0.299 * n - 0.299 * u - 0.328 * c, m = 0.587 * n + 0.413 * u + 0.035 * c, p = 0.114 * n - 0.114 * u + 0.293 * c, v = 0.299 * n - 0.3 * u + 1.25 * c, g = 0.587 * n - 0.586 * u - 1.05 * c, y = 0.114 * n + 0.886 * u - 0.2 * c, b, S, _, x;
  for (s = 0; s < r; s += 4)
    b = e[s + 0], S = e[s + 1], _ = e[s + 2], x = e[s + 3], e[s + 0] = l * b + d * S + f * _ + o, e[s + 1] = h * b + m * S + p * _ + o, e[s + 2] = v * b + g * S + y * _ + o, e[s + 3] = x;
};
e5.HSL = iye;
var t5 = {};
Object.defineProperty(t5, "__esModule", { value: !0 });
t5.HSV = void 0;
const Xp = Fr, DS = si, ES = Ot, aye = function(t) {
  var e = t.data, r = e.length, n = Math.pow(2, this.value()), i = Math.pow(2, this.saturation()), a = Math.abs(this.hue() + 360) % 360, o, s = n * i * Math.cos(a * Math.PI / 180), u = n * i * Math.sin(a * Math.PI / 180), c = 0.299 * n + 0.701 * s + 0.167 * u, l = 0.587 * n - 0.587 * s + 0.33 * u, d = 0.114 * n - 0.114 * s - 0.497 * u, f = 0.299 * n - 0.299 * s - 0.328 * u, h = 0.587 * n + 0.413 * s + 0.035 * u, m = 0.114 * n - 0.114 * s + 0.293 * u, p = 0.299 * n - 0.3 * s + 1.25 * u, v = 0.587 * n - 0.586 * s - 1.05 * u, g = 0.114 * n + 0.886 * s - 0.2 * u, y, b, S, _;
  for (o = 0; o < r; o += 4)
    y = e[o + 0], b = e[o + 1], S = e[o + 2], _ = e[o + 3], e[o + 0] = c * y + l * b + d * S, e[o + 1] = f * y + h * b + m * S, e[o + 2] = p * y + v * b + g * S, e[o + 3] = _;
};
t5.HSV = aye;
Xp.Factory.addGetterSetter(DS.Node, "hue", 0, (0, ES.getNumberValidator)(), Xp.Factory.afterSetFilter);
Xp.Factory.addGetterSetter(DS.Node, "saturation", 0, (0, ES.getNumberValidator)(), Xp.Factory.afterSetFilter);
Xp.Factory.addGetterSetter(DS.Node, "value", 0, (0, ES.getNumberValidator)(), Xp.Factory.afterSetFilter);
var r5 = {};
Object.defineProperty(r5, "__esModule", { value: !0 });
r5.Invert = void 0;
const oye = function(t) {
  var e = t.data, r = e.length, n;
  for (n = 0; n < r; n += 4)
    e[n] = 255 - e[n], e[n + 1] = 255 - e[n + 1], e[n + 2] = 255 - e[n + 2];
};
r5.Invert = oye;
var n5 = {};
Object.defineProperty(n5, "__esModule", { value: !0 });
n5.Kaleidoscope = void 0;
const Ty = Fr, fV = si, hF = vi, pV = Ot;
var sye = function(t, e, r) {
  var n = t.data, i = e.data, a = t.width, o = t.height, s = r.polarCenterX || a / 2, u = r.polarCenterY || o / 2, c, l, d, f = 0, h = 0, m = 0, p = 0, v, g = Math.sqrt(s * s + u * u);
  l = a - s, d = o - u, v = Math.sqrt(l * l + d * d), g = v > g ? v : g;
  var y = o, b = a, S, _, x = 360 / b * Math.PI / 180, C, A;
  for (_ = 0; _ < b; _ += 1)
    for (C = Math.sin(_ * x), A = Math.cos(_ * x), S = 0; S < y; S += 1)
      l = Math.floor(s + g * S / y * A), d = Math.floor(u + g * S / y * C), c = (d * a + l) * 4, f = n[c + 0], h = n[c + 1], m = n[c + 2], p = n[c + 3], c = (_ + S * a) * 4, i[c + 0] = f, i[c + 1] = h, i[c + 2] = m, i[c + 3] = p;
}, uye = function(t, e, r) {
  var n = t.data, i = e.data, a = t.width, o = t.height, s = r.polarCenterX || a / 2, u = r.polarCenterY || o / 2, c, l, d, f, h, m = 0, p = 0, v = 0, g = 0, y, b = Math.sqrt(s * s + u * u);
  l = a - s, d = o - u, y = Math.sqrt(l * l + d * d), b = y > b ? y : b;
  var S = o, _ = a, x, C, A = 0, w, I;
  for (l = 0; l < a; l += 1)
    for (d = 0; d < o; d += 1)
      f = l - s, h = d - u, x = Math.sqrt(f * f + h * h) * S / b, C = (Math.atan2(h, f) * 180 / Math.PI + 360 + A) % 360, C = C * _ / 360, w = Math.floor(C), I = Math.floor(x), c = (I * a + w) * 4, m = n[c + 0], p = n[c + 1], v = n[c + 2], g = n[c + 3], c = (d * a + l) * 4, i[c + 0] = m, i[c + 1] = p, i[c + 2] = v, i[c + 3] = g;
};
const cye = function(t) {
  var e = t.width, r = t.height, n, i, a, o, s, u, c, l, d, f, h = Math.round(this.kaleidoscopePower()), m = Math.round(this.kaleidoscopeAngle()), p = Math.floor(e * (m % 360) / 360);
  if (!(h < 1)) {
    var v = hF.Util.createCanvasElement();
    v.width = e, v.height = r;
    var g = v.getContext("2d").getImageData(0, 0, e, r);
    hF.Util.releaseCanvas(v), sye(t, g, {
      polarCenterX: e / 2,
      polarCenterY: r / 2
    });
    for (var y = e / Math.pow(2, h); y <= 8; )
      y = y * 2, h -= 1;
    y = Math.ceil(y);
    var b = y, S = 0, _ = b, x = 1;
    for (p + y > e && (S = b, _ = 0, x = -1), i = 0; i < r; i += 1)
      for (n = S; n !== _; n += x)
        a = Math.round(n + p) % e, d = (e * i + a) * 4, s = g.data[d + 0], u = g.data[d + 1], c = g.data[d + 2], l = g.data[d + 3], f = (e * i + n) * 4, g.data[f + 0] = s, g.data[f + 1] = u, g.data[f + 2] = c, g.data[f + 3] = l;
    for (i = 0; i < r; i += 1)
      for (b = Math.floor(y), o = 0; o < h; o += 1) {
        for (n = 0; n < b + 1; n += 1)
          d = (e * i + n) * 4, s = g.data[d + 0], u = g.data[d + 1], c = g.data[d + 2], l = g.data[d + 3], f = (e * i + b * 2 - n - 1) * 4, g.data[f + 0] = s, g.data[f + 1] = u, g.data[f + 2] = c, g.data[f + 3] = l;
        b *= 2;
      }
    uye(g, t, { polarRotation: 0 });
  }
};
n5.Kaleidoscope = cye;
Ty.Factory.addGetterSetter(fV.Node, "kaleidoscopePower", 2, (0, pV.getNumberValidator)(), Ty.Factory.afterSetFilter);
Ty.Factory.addGetterSetter(fV.Node, "kaleidoscopeAngle", 0, (0, pV.getNumberValidator)(), Ty.Factory.afterSetFilter);
var i5 = {};
Object.defineProperty(i5, "__esModule", { value: !0 });
i5.Mask = void 0;
const mF = Fr, lye = si, dye = Ot;
function Wv(t, e, r) {
  var n = (r * t.width + e) * 4, i = [];
  return i.push(t.data[n++], t.data[n++], t.data[n++], t.data[n++]), i;
}
function cm(t, e) {
  return Math.sqrt(Math.pow(t[0] - e[0], 2) + Math.pow(t[1] - e[1], 2) + Math.pow(t[2] - e[2], 2));
}
function fye(t) {
  for (var e = [0, 0, 0], r = 0; r < t.length; r++)
    e[0] += t[r][0], e[1] += t[r][1], e[2] += t[r][2];
  return e[0] /= t.length, e[1] /= t.length, e[2] /= t.length, e;
}
function pye(t, e) {
  var r = Wv(t, 0, 0), n = Wv(t, t.width - 1, 0), i = Wv(t, 0, t.height - 1), a = Wv(t, t.width - 1, t.height - 1), o = e || 10;
  if (cm(r, n) < o && cm(n, a) < o && cm(a, i) < o && cm(i, r) < o) {
    for (var s = fye([n, r, a, i]), u = [], c = 0; c < t.width * t.height; c++) {
      var l = cm(s, [
        t.data[c * 4],
        t.data[c * 4 + 1],
        t.data[c * 4 + 2]
      ]);
      u[c] = l < o ? 0 : 255;
    }
    return u;
  }
}
function hye(t, e) {
  for (var r = 0; r < t.width * t.height; r++)
    t.data[4 * r + 3] = e[r];
}
function mye(t, e, r) {
  for (var n = [1, 1, 1, 1, 0, 1, 1, 1, 1], i = Math.round(Math.sqrt(n.length)), a = Math.floor(i / 2), o = [], s = 0; s < r; s++)
    for (var u = 0; u < e; u++) {
      for (var c = s * e + u, l = 0, d = 0; d < i; d++)
        for (var f = 0; f < i; f++) {
          var h = s + d - a, m = u + f - a;
          if (h >= 0 && h < r && m >= 0 && m < e) {
            var p = h * e + m, v = n[d * i + f];
            l += t[p] * v;
          }
        }
      o[c] = l === 255 * 8 ? 255 : 0;
    }
  return o;
}
function gye(t, e, r) {
  for (var n = [1, 1, 1, 1, 1, 1, 1, 1, 1], i = Math.round(Math.sqrt(n.length)), a = Math.floor(i / 2), o = [], s = 0; s < r; s++)
    for (var u = 0; u < e; u++) {
      for (var c = s * e + u, l = 0, d = 0; d < i; d++)
        for (var f = 0; f < i; f++) {
          var h = s + d - a, m = u + f - a;
          if (h >= 0 && h < r && m >= 0 && m < e) {
            var p = h * e + m, v = n[d * i + f];
            l += t[p] * v;
          }
        }
      o[c] = l >= 255 * 4 ? 255 : 0;
    }
  return o;
}
function vye(t, e, r) {
  for (var n = [0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111], i = Math.round(Math.sqrt(n.length)), a = Math.floor(i / 2), o = [], s = 0; s < r; s++)
    for (var u = 0; u < e; u++) {
      for (var c = s * e + u, l = 0, d = 0; d < i; d++)
        for (var f = 0; f < i; f++) {
          var h = s + d - a, m = u + f - a;
          if (h >= 0 && h < r && m >= 0 && m < e) {
            var p = h * e + m, v = n[d * i + f];
            l += t[p] * v;
          }
        }
      o[c] = l;
    }
  return o;
}
const yye = function(t) {
  var e = this.threshold(), r = pye(t, e);
  return r && (r = mye(r, t.width, t.height), r = gye(r, t.width, t.height), r = vye(r, t.width, t.height), hye(t, r)), t;
};
i5.Mask = yye;
mF.Factory.addGetterSetter(lye.Node, "threshold", 0, (0, dye.getNumberValidator)(), mF.Factory.afterSetFilter);
var a5 = {};
Object.defineProperty(a5, "__esModule", { value: !0 });
a5.Noise = void 0;
const gF = Fr, bye = si, _ye = Ot, xye = function(t) {
  var e = this.noise() * 255, r = t.data, n = r.length, i = e / 2, a;
  for (a = 0; a < n; a += 4)
    r[a + 0] += i - 2 * i * Math.random(), r[a + 1] += i - 2 * i * Math.random(), r[a + 2] += i - 2 * i * Math.random();
};
a5.Noise = xye;
gF.Factory.addGetterSetter(bye.Node, "noise", 0.2, (0, _ye.getNumberValidator)(), gF.Factory.afterSetFilter);
var o5 = {};
Object.defineProperty(o5, "__esModule", { value: !0 });
o5.Pixelate = void 0;
const vF = Fr, Sye = vi, Cye = si, Aye = Ot, wye = function(t) {
  var e = Math.ceil(this.pixelSize()), r = t.width, n = t.height, i, a, o, s, u, c, l, d = Math.ceil(r / e), f = Math.ceil(n / e), h, m, p, v, g, y, b, S = t.data;
  if (e <= 0) {
    Sye.Util.error("pixelSize value can not be <= 0");
    return;
  }
  for (g = 0; g < d; g += 1)
    for (y = 0; y < f; y += 1) {
      for (s = 0, u = 0, c = 0, l = 0, h = g * e, m = h + e, p = y * e, v = p + e, b = 0, i = h; i < m; i += 1)
        if (!(i >= r))
          for (a = p; a < v; a += 1)
            a >= n || (o = (r * a + i) * 4, s += S[o + 0], u += S[o + 1], c += S[o + 2], l += S[o + 3], b += 1);
      for (s = s / b, u = u / b, c = c / b, l = l / b, i = h; i < m; i += 1)
        if (!(i >= r))
          for (a = p; a < v; a += 1)
            a >= n || (o = (r * a + i) * 4, S[o + 0] = s, S[o + 1] = u, S[o + 2] = c, S[o + 3] = l);
    }
};
o5.Pixelate = wye;
vF.Factory.addGetterSetter(Cye.Node, "pixelSize", 8, (0, Aye.getNumberValidator)(), vF.Factory.afterSetFilter);
var s5 = {};
Object.defineProperty(s5, "__esModule", { value: !0 });
s5.Posterize = void 0;
const yF = Fr, Dye = si, Eye = Ot, Iye = function(t) {
  var e = Math.round(this.levels() * 254) + 1, r = t.data, n = r.length, i = 255 / e, a;
  for (a = 0; a < n; a += 1)
    r[a] = Math.floor(r[a] / i) * i;
};
s5.Posterize = Iye;
yF.Factory.addGetterSetter(Dye.Node, "levels", 0.5, (0, Eye.getNumberValidator)(), yF.Factory.afterSetFilter);
var u5 = {};
Object.defineProperty(u5, "__esModule", { value: !0 });
u5.RGB = void 0;
const My = Fr, IS = si, Tye = Ot, Mye = function(t) {
  var e = t.data, r = e.length, n = this.red(), i = this.green(), a = this.blue(), o, s;
  for (o = 0; o < r; o += 4)
    s = (0.34 * e[o] + 0.5 * e[o + 1] + 0.16 * e[o + 2]) / 255, e[o] = s * n, e[o + 1] = s * i, e[o + 2] = s * a, e[o + 3] = e[o + 3];
};
u5.RGB = Mye;
My.Factory.addGetterSetter(IS.Node, "red", 0, function(t) {
  return this._filterUpToDate = !1, t > 255 ? 255 : t < 0 ? 0 : Math.round(t);
});
My.Factory.addGetterSetter(IS.Node, "green", 0, function(t) {
  return this._filterUpToDate = !1, t > 255 ? 255 : t < 0 ? 0 : Math.round(t);
});
My.Factory.addGetterSetter(IS.Node, "blue", 0, Tye.RGBComponent, My.Factory.afterSetFilter);
var c5 = {};
Object.defineProperty(c5, "__esModule", { value: !0 });
c5.RGBA = void 0;
const d2 = Fr, l5 = si, Pye = Ot, Bye = function(t) {
  var e = t.data, r = e.length, n = this.red(), i = this.green(), a = this.blue(), o = this.alpha(), s, u;
  for (s = 0; s < r; s += 4)
    u = 1 - o, e[s] = n * o + e[s] * u, e[s + 1] = i * o + e[s + 1] * u, e[s + 2] = a * o + e[s + 2] * u;
};
c5.RGBA = Bye;
d2.Factory.addGetterSetter(l5.Node, "red", 0, function(t) {
  return this._filterUpToDate = !1, t > 255 ? 255 : t < 0 ? 0 : Math.round(t);
});
d2.Factory.addGetterSetter(l5.Node, "green", 0, function(t) {
  return this._filterUpToDate = !1, t > 255 ? 255 : t < 0 ? 0 : Math.round(t);
});
d2.Factory.addGetterSetter(l5.Node, "blue", 0, Pye.RGBComponent, d2.Factory.afterSetFilter);
d2.Factory.addGetterSetter(l5.Node, "alpha", 1, function(t) {
  return this._filterUpToDate = !1, t > 1 ? 1 : t < 0 ? 0 : t;
});
var d5 = {};
Object.defineProperty(d5, "__esModule", { value: !0 });
d5.Sepia = void 0;
const Fye = function(t) {
  var e = t.data, r = e.length, n, i, a, o;
  for (n = 0; n < r; n += 4)
    i = e[n + 0], a = e[n + 1], o = e[n + 2], e[n + 0] = Math.min(255, i * 0.393 + a * 0.769 + o * 0.189), e[n + 1] = Math.min(255, i * 0.349 + a * 0.686 + o * 0.168), e[n + 2] = Math.min(255, i * 0.272 + a * 0.534 + o * 0.131);
};
d5.Sepia = Fye;
var f5 = {};
Object.defineProperty(f5, "__esModule", { value: !0 });
f5.Solarize = void 0;
const Nye = function(t) {
  var e = t.data, r = t.width, n = t.height, i = r * 4, a = n;
  do {
    var o = (a - 1) * i, s = r;
    do {
      var u = o + (s - 1) * 4, c = e[u], l = e[u + 1], d = e[u + 2];
      c > 127 && (c = 255 - c), l > 127 && (l = 255 - l), d > 127 && (d = 255 - d), e[u] = c, e[u + 1] = l, e[u + 2] = d;
    } while (--s);
  } while (--a);
};
f5.Solarize = Nye;
var p5 = {};
Object.defineProperty(p5, "__esModule", { value: !0 });
p5.Threshold = void 0;
const bF = Fr, Rye = si, Oye = Ot, Lye = function(t) {
  var e = this.threshold() * 255, r = t.data, n = r.length, i;
  for (i = 0; i < n; i += 1)
    r[i] = r[i] < e ? 0 : 255;
};
p5.Threshold = Lye;
bF.Factory.addGetterSetter(Rye.Node, "threshold", 0.5, (0, Oye.getNumberValidator)(), bF.Factory.afterSetFilter);
Object.defineProperty(S4, "__esModule", { value: !0 });
S4.Konva = void 0;
const _F = Bz, kye = I4, Gye = P4, zye = N4, Vye = R4, Uye = O4, xF = qp, Hye = N2, qye = ch, Kye = O2, Xye = G4, Yye = z4, Wye = V4, jye = U4, Zye = F0, Qye = H4, Jye = q4, $ye = K4, e4e = Y4, t4e = W4, r4e = j4, n4e = Z4, i4e = J4, a4e = $4, o4e = e5, s4e = t5, u4e = r5, c4e = n5, l4e = i5, d4e = a5, f4e = o5, p4e = s5, h4e = u5, m4e = c5, g4e = d5, v4e = f5, y4e = p5;
S4.Konva = _F.Konva.Util._assign(_F.Konva, {
  Arc: kye.Arc,
  Arrow: Gye.Arrow,
  Circle: zye.Circle,
  Ellipse: Vye.Ellipse,
  Image: Uye.Image,
  Label: xF.Label,
  Tag: xF.Tag,
  Line: Hye.Line,
  Path: qye.Path,
  Rect: Kye.Rect,
  RegularPolygon: Xye.RegularPolygon,
  Ring: Yye.Ring,
  Sprite: Wye.Sprite,
  Star: jye.Star,
  Text: Zye.Text,
  TextPath: Qye.TextPath,
  Transformer: Jye.Transformer,
  Wedge: $ye.Wedge,
  Filters: {
    Blur: e4e.Blur,
    Brighten: t4e.Brighten,
    Contrast: r4e.Contrast,
    Emboss: n4e.Emboss,
    Enhance: i4e.Enhance,
    Grayscale: a4e.Grayscale,
    HSL: o4e.HSL,
    HSV: s4e.HSV,
    Invert: u4e.Invert,
    Kaleidoscope: c4e.Kaleidoscope,
    Mask: l4e.Mask,
    Noise: d4e.Noise,
    Pixelate: f4e.Pixelate,
    Posterize: p4e.Posterize,
    RGB: h4e.RGB,
    RGBA: m4e.RGBA,
    Sepia: g4e.Sepia,
    Solarize: v4e.Solarize,
    Threshold: y4e.Threshold
  }
});
var b4e = Pz.exports;
Object.defineProperty(b4e, "__esModule", { value: !0 });
const _4e = S4;
Pz.exports = _4e.Konva;
const {
  SvelteComponent: x4e,
  append: Xt,
  attr: yn,
  create_component: H4e,
  destroy_component: q4e,
  destroy_each: B9,
  detach: dh,
  element: Pn,
  ensure_array_like: sp,
  flush: $f,
  init: S4e,
  insert: fh,
  listen: jv,
  mount_component: K4e,
  null_to_empty: jd,
  run_all: C4e,
  safe_not_equal: A4e,
  set_data: _0,
  set_style: up,
  space: ia,
  text: tu,
  transition_in: w4e,
  transition_out: D4e
} = window.__gradio__svelte__internal;
function SF(t, e, r) {
  const n = t.slice();
  return n[29] = e[r], n;
}
function CF(t, e, r) {
  const n = t.slice();
  return n[7] = e[r], n[33] = r, n;
}
function AF(t, e, r) {
  const n = t.slice();
  return n[7] = e[r], n;
}
function wF(t) {
  let e, r, n, i;
  return {
    c() {
      e = Pn("div"), r = Pn("div"), n = tu(
        /*tooltipText*/
        t[3]
      ), yn(r, "class", jd("tooltip-inner") + " svelte-141sw17"), yn(e, "class", "tooltip svelte-141sw17"), yn(e, "style", i = `top: ${/*mousePosition*/
      t[2].y - 45}px;left: ${/*mousePosition*/
      t[2].x - 8}px;`);
    },
    m(a, o) {
      fh(a, e, o), Xt(e, r), Xt(r, n);
    },
    p(a, o) {
      o[0] & /*tooltipText*/
      8 && _0(
        n,
        /*tooltipText*/
        a[3]
      ), o[0] & /*mousePosition*/
      4 && i !== (i = `top: ${/*mousePosition*/
      a[2].y - 45}px;left: ${/*mousePosition*/
      a[2].x - 8}px;`) && yn(e, "style", i);
    },
    d(a) {
      a && dh(e);
    }
  };
}
function DF(t) {
  let e, r, n, i, a, o, s, u, c, l, d, f, h = (
    /*lattice*/
    t[4].volume.toFixed(3) + ""
  ), m, p, v, g, y, b, S, _ = (
    /*lattice*/
    t[4].spacegroup.symbol + ""
  ), x, C, A = (
    /*lattice*/
    t[4].spacegroup.no + ""
  ), w, I, P = sp(["a", "b", "c"]), M = [];
  for (let N = 0; N < 3; N += 1)
    M[N] = EF(AF(t, P, N));
  let T = sp(["α", "β", "γ"]), F = [];
  for (let N = 0; N < 3; N += 1)
    F[N] = IF(CF(t, T, N));
  return {
    c() {
      e = Pn("div"), r = Pn("h6"), r.textContent = "Lattice", n = ia(), i = Pn("div"), a = Pn("div");
      for (let N = 0; N < 3; N += 1)
        M[N].c();
      o = ia(), s = Pn("div");
      for (let N = 0; N < 3; N += 1)
        F[N].c();
      u = ia(), c = Pn("div"), l = Pn("span"), l.textContent = "Volume", d = ia(), f = Pn("span"), m = tu(h), p = tu("(Å3)"), v = ia(), g = Pn("div"), y = Pn("span"), y.textContent = "Space Group", b = ia(), S = Pn("span"), x = tu(_), C = tu("("), w = tu(A), I = tu(")"), up(r, "font-weight", "600"), yn(a, "class", "lattice-params-half"), yn(s, "class", "lattice-params-half"), yn(i, "class", "lattice-params svelte-141sw17"), yn(l, "class", jd("text-color-tertiary mr-16") + " svelte-141sw17"), yn(c, "class", jd("row") + " svelte-141sw17"), up(c, "justify-content", "space-between"), up(c, "margin-top", "8px"), yn(y, "class", jd("text-color-tertiary mr-16") + " svelte-141sw17"), yn(g, "class", jd("row") + " svelte-141sw17"), up(g, "justify-content", "space-between"), yn(e, "class", "lattice-content svelte-141sw17");
    },
    m(N, R) {
      fh(N, e, R), Xt(e, r), Xt(e, n), Xt(e, i), Xt(i, a);
      for (let L = 0; L < 3; L += 1)
        M[L] && M[L].m(a, null);
      Xt(i, o), Xt(i, s);
      for (let L = 0; L < 3; L += 1)
        F[L] && F[L].m(s, null);
      Xt(e, u), Xt(e, c), Xt(c, l), Xt(c, d), Xt(c, f), Xt(f, m), Xt(f, p), Xt(e, v), Xt(e, g), Xt(g, y), Xt(g, b), Xt(g, S), Xt(S, x), Xt(S, C), Xt(S, w), Xt(S, I);
    },
    p(N, R) {
      if (R[0] & /*lattice*/
      16) {
        P = sp(["a", "b", "c"]);
        let L;
        for (L = 0; L < 3; L += 1) {
          const V = AF(N, P, L);
          M[L] ? M[L].p(V, R) : (M[L] = EF(V), M[L].c(), M[L].m(a, null));
        }
        for (; L < 3; L += 1)
          M[L].d(1);
      }
      if (R[0] & /*lattice*/
      16) {
        T = sp(["α", "β", "γ"]);
        let L;
        for (L = 0; L < 3; L += 1) {
          const V = CF(N, T, L);
          F[L] ? F[L].p(V, R) : (F[L] = IF(V), F[L].c(), F[L].m(s, null));
        }
        for (; L < 3; L += 1)
          F[L].d(1);
      }
      R[0] & /*lattice*/
      16 && h !== (h = /*lattice*/
      N[4].volume.toFixed(3) + "") && _0(m, h), R[0] & /*lattice*/
      16 && _ !== (_ = /*lattice*/
      N[4].spacegroup.symbol + "") && _0(x, _), R[0] & /*lattice*/
      16 && A !== (A = /*lattice*/
      N[4].spacegroup.no + "") && _0(w, A);
    },
    d(N) {
      N && dh(e), B9(M, N), B9(F, N);
    }
  };
}
function EF(t) {
  let e, r, n, i, a = (
    /*lattice*/
    t[4][
      /*key*/
      t[7]
    ].toFixed(3) + ""
  ), o, s, u;
  return {
    c() {
      e = Pn("div"), r = Pn("span"), r.textContent = `${/*key*/
      t[7]}`, n = ia(), i = Pn("span"), o = tu(a), s = tu("(Å)"), u = ia(), yn(r, "class", "text-color-tertiary svelte-141sw17"), up(r, "margin-right", "8px"), yn(e, "class", "lattice-params-item svelte-141sw17");
    },
    m(c, l) {
      fh(c, e, l), Xt(e, r), Xt(e, n), Xt(e, i), Xt(i, o), Xt(i, s), Xt(e, u);
    },
    p(c, l) {
      l[0] & /*lattice*/
      16 && a !== (a = /*lattice*/
      c[4][
        /*key*/
        c[7]
      ].toFixed(3) + "") && _0(o, a);
    },
    d(c) {
      c && dh(e);
    }
  };
}
function IF(t) {
  let e, r, n, i, a = (
    /*lattice*/
    t[4][["alpha", "beta", "gamma"][
      /*idx*/
      t[33]
    ]].toFixed(3) + ""
  ), o, s, u;
  return {
    c() {
      e = Pn("div"), r = Pn("span"), r.textContent = `${/*key*/
      t[7]}`, n = ia(), i = Pn("span"), o = tu(a), s = tu("°"), u = ia(), yn(r, "class", "text-color-tertiary svelte-141sw17"), up(r, "margin-right", "8px"), yn(e, "class", "lattice-params-item svelte-141sw17");
    },
    m(c, l) {
      fh(c, e, l), Xt(e, r), Xt(e, n), Xt(e, i), Xt(i, o), Xt(i, s), Xt(e, u);
    },
    p(c, l) {
      l[0] & /*lattice*/
      16 && a !== (a = /*lattice*/
      c[4][["alpha", "beta", "gamma"][
        /*idx*/
        c[33]
      ]].toFixed(3) + "") && _0(o, a);
    },
    d(c) {
      c && dh(e);
    }
  };
}
function TF(t) {
  let e, r, n, i, a = (
    /*atom*/
    t[29] + ""
  ), o, s;
  return {
    c() {
      e = Pn("div"), r = Pn("div"), i = ia(), o = tu(a), s = ia(), yn(r, "style", n = `background-color: ${MF(H3[
        /*atom*/
        t[29].toUpperCase()
      ])}`), yn(r, "class", jd("atom-model-legend-item-ball") + " svelte-141sw17"), yn(e, "class", jd("atom-model-legend-item") + " svelte-141sw17");
    },
    m(u, c) {
      fh(u, e, c), Xt(e, r), Xt(e, i), Xt(e, o), Xt(e, s);
    },
    p(u, c) {
      c[0] & /*atomList*/
      64 && n !== (n = `background-color: ${MF(H3[
        /*atom*/
        u[29].toUpperCase()
      ])}`) && yn(r, "style", n), c[0] & /*atomList*/
      64 && a !== (a = /*atom*/
      u[29] + "") && _0(o, a);
    },
    d(u) {
      u && dh(e);
    }
  };
}
function E4e(t) {
  let e, r, n, i, a, o, s, u, c, l, d, f, h, m, p, v, g, y, b = !!/*tooltipText*/
  t[3] && wF(t), S = (
    /*latticeInfoVisible*/
    t[1] && !!/*lattice*/
    t[4] && DF(t)
  ), _ = sp(
    /*atomList*/
    t[6]
  ), x = [];
  for (let A = 0; A < _.length; A += 1)
    x[A] = TF(SF(t, _, A));
  let C = I4e;
  return {
    c() {
      e = Pn("div"), r = Pn("div"), n = ia(), b && b.c(), i = ia(), S && S.c(), a = ia(), o = Pn("div");
      for (let A = 0; A < x.length; A += 1)
        x[A].c();
      s = ia(), u = Pn("div"), c = Pn("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.02 3.334l-.012 9.333M3.336 8h9.333" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path></svg>', l = ia(), d = Pn("button"), d.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>', f = ia(), h = Pn("button"), h.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>', m = ia(), yn(r, "id", `material-viewer-canvas-${/*key*/
      t[7]}`), yn(r, "style", "width: 100%;height: 100%;min-height: 240px;"), yn(o, "class", jd("atom-model-legend-container") + " svelte-141sw17"), yn(c, "class", "material-viewer-toolbar-btn svelte-141sw17"), yn(d, "class", "material-viewer-toolbar-btn svelte-141sw17"), yn(h, "class", "material-viewer-toolbar-btn svelte-141sw17"), yn(u, "class", "material-viewer-toolbar svelte-141sw17"), yn(e, "class", "material-viewer-container svelte-141sw17"), yn(e, "style", p = `height: ${/*height*/
      t[0]}px;`);
    },
    m(A, w) {
      fh(A, e, w), Xt(e, r), Xt(e, n), b && b.m(e, null), Xt(e, i), S && S.m(e, null), Xt(e, a), Xt(e, o);
      for (let I = 0; I < x.length; I += 1)
        x[I] && x[I].m(o, null);
      Xt(e, s), Xt(e, u), Xt(u, c), Xt(u, l), Xt(u, d), Xt(u, f), Xt(u, h), Xt(e, m), v = !0, g || (y = [
        jv(
          r,
          "mousemove",
          /*mousemove_handler*/
          t[13]
        ),
        jv(
          c,
          "click",
          /*click_handler*/
          t[14]
        ),
        jv(
          d,
          "click",
          /*click_handler_1*/
          t[15]
        ),
        jv(
          h,
          "click",
          /*click_handler_2*/
          t[16]
        )
      ], g = !0);
    },
    p(A, w) {
      if (/*tooltipText*/
      A[3] ? b ? b.p(A, w) : (b = wF(A), b.c(), b.m(e, i)) : b && (b.d(1), b = null), /*latticeInfoVisible*/
      A[1] && /*lattice*/
      A[4] ? S ? S.p(A, w) : (S = DF(A), S.c(), S.m(e, a)) : S && (S.d(1), S = null), w[0] & /*atomList*/
      64) {
        _ = sp(
          /*atomList*/
          A[6]
        );
        let I;
        for (I = 0; I < _.length; I += 1) {
          const P = SF(A, _, I);
          x[I] ? x[I].p(P, w) : (x[I] = TF(P), x[I].c(), x[I].m(o, null));
        }
        for (; I < x.length; I += 1)
          x[I].d(1);
        x.length = _.length;
      }
      (!v || w[0] & /*height*/
      1 && p !== (p = `height: ${/*height*/
      A[0]}px;`)) && yn(e, "style", p);
    },
    i(A) {
      v || (w4e(C), v = !0);
    },
    o(A) {
      D4e(C), v = !1;
    },
    d(A) {
      A && dh(e), b && b.d(), S && S.d(), B9(x, A), g = !1, C4e(y);
    }
  };
}
let I4e = !1;
function MF(t) {
  let e = t.toString(16);
  for (; e.length < 6; )
    e = "0" + e;
  return "#" + e;
}
function T4e(t, e, r) {
  var n = this && this.__awaiter || function(F, N, R, L) {
    function V(U) {
      return U instanceof R ? U : new R(function(H) {
        H(U);
      });
    }
    return new (R || (R = Promise))(function(U, H) {
      function K(Q) {
        try {
          Y(L.next(Q));
        } catch (J) {
          H(J);
        }
      }
      function X(Q) {
        try {
          Y(L.throw(Q));
        } catch (J) {
          H(J);
        }
      }
      function Y(Q) {
        Q.done ? U(Q.value) : V(Q.value).then(K, X);
      }
      Y((L = L.apply(F, N || [])).next());
    });
  };
  let { gradio: i } = e, { materialFile: a = "" } = e, { value: o = "" } = e, { value_is_output: s = !1 } = e, { height: u } = e, { style: c } = e, { latticeInfoVisible: l } = e;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  let d = new AG();
  const h = (() => {
    function F() {
      return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
    }
    return `${F() + F()}-${F()}-${F()}-${F()}-${F()}${F()}${F()}`;
  })();
  function m() {
    i.dispatch("change"), s || i.dispatch("input");
  }
  let p = { x: -1e3, y: -1e3 }, v = "", g, y = [];
  const b = (F, N) => n(void 0, void 0, void 0, function* () {
    if (F) {
      const R = xge(F.matrix), L = Sge(R);
      return d.managers.representation.createOther({
        data: L,
        type: Pe.CustomLines,
        params: { alpha: 1 }
      });
    }
  }), S = (F, N) => {
    var R;
    const L = {
      vecA: E.unitX,
      vecB: E.unitY,
      vecC: E.unitZ
    }, V = (() => {
      if (!F)
        return {};
      const U = F.matrix;
      return {
        vecA: E.normalize(E.zero(), E.create.apply(null, U[0])),
        vecB: E.normalize(E.zero(), E.create.apply(null, U[1])),
        vecC: E.normalize(E.zero(), E.create.apply(null, U[2]))
      };
    })();
    return (R = d == null ? void 0 : d.canvas3d) === null || R === void 0 ? void 0 : R.setProps({
      camera: {
        helper: {
          axes: {
            name: "on",
            params: Object.assign(Object.assign({}, L), V)
          }
        }
      }
    });
  };
  function _() {
    return n(this, void 0, void 0, function* () {
      if (!d.canvas3d) return;
      const F = yge(vge(Cge(JSON.parse(a)[0]))), [N] = yield d.managers.representation.createMolecular({
        format: gr.Material,
        reprType: J1.has(c) ? c : Pe.BallAndStick,
        data: F,
        theme: {
          [St.ATOM]: {
            color: { name: "material-element-symbol" }
          }
        }
      }), R = /* @__PURE__ */ new Set(), L = yield d.managers.cell.getStructure(N);
      L && (EL(L, (V) => {
        R.add(V.typeSymbol);
      }), r(6, y = new Array(...R.values())), b(F.lattice), S(F.lattice), r(4, g = F.lattice));
    });
  }
  function x() {
    r(5, d.managers.representation.showPolarHydrogenOnly = !1, d), d.createCanvas(document.getElementById(`material-viewer-canvas-${h}`)), d.managers.selection.structure.setGranularity(Kr.Atom), d.managers.events.setAllowSelect(!1), d.managers.highlight.info.subscribe((N) => {
      var R;
      if (((R = N.info) === null || R === void 0 ? void 0 : R.granularity) === Kr.Atom) {
        const { atomName: L, x: V, y: U, z: H } = N.info;
        r(3, v = `${L} (${[V, U, H].map((K) => K.toFixed(3)).join(", ")})`);
      } else
        r(3, v = "");
    }), new ResizeObserver(fge.debounce(
      () => {
        d.refresh({ fixCamera: !0 });
      },
      300
    )).observe(document.getElementById(`material-viewer-canvas-${h}`)), window.__material_viewer = d, setTimeout(() => d.refresh(), 50);
  }
  const C = setInterval(
    () => {
      var F;
      !((F = document.getElementById(`material-viewer-canvas-${h}`)) === null || F === void 0) && F.clientHeight && !d.canvas3d && (clearInterval(C), x(), _());
    },
    500
  );
  function A() {
    d.canvas3d && (d.clear(), _());
  }
  const w = () => {
    setTimeout(
      () => {
        d.refresh({ fixCamera: !0 });
      },
      0
    );
  }, I = (F) => {
    r(2, p = { x: F.offsetX, y: F.offsetY });
  }, P = () => d.managers.camera.zoomIn(), M = () => d.managers.camera.zoomOut(), T = () => d.managers.camera.reset();
  return t.$$set = (F) => {
    "gradio" in F && r(9, i = F.gradio), "materialFile" in F && r(10, a = F.materialFile), "value" in F && r(8, o = F.value), "value_is_output" in F && r(11, s = F.value_is_output), "height" in F && r(0, u = F.height), "style" in F && r(12, c = F.style), "latticeInfoVisible" in F && r(1, l = F.latticeInfoVisible);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*value*/
    256 && o === null && r(8, o = ""), t.$$.dirty[0] & /*value*/
    256 && m(), t.$$.dirty[0] & /*mousePosition*/
    4, t.$$.dirty[0] & /*tooltipText*/
    8, t.$$.dirty[0] & /*lattice*/
    16, t.$$.dirty[0] & /*materialFile*/
    1024 && A(), t.$$.dirty[0] & /*style*/
    4096 && A(), t.$$.dirty[0] & /*height*/
    1 && w();
  }, [
    u,
    l,
    p,
    v,
    g,
    d,
    y,
    h,
    o,
    i,
    a,
    s,
    c,
    I,
    P,
    M,
    T
  ];
}
class M4e extends x4e {
  constructor(e) {
    super(), S4e(
      this,
      e,
      T4e,
      E4e,
      A4e,
      {
        gradio: 9,
        materialFile: 10,
        value: 8,
        value_is_output: 11,
        height: 0,
        style: 12,
        latticeInfoVisible: 1
      },
      null,
      [-1, -1]
    );
  }
  get gradio() {
    return this.$$.ctx[9];
  }
  set gradio(e) {
    this.$$set({ gradio: e }), $f();
  }
  get materialFile() {
    return this.$$.ctx[10];
  }
  set materialFile(e) {
    this.$$set({ materialFile: e }), $f();
  }
  get value() {
    return this.$$.ctx[8];
  }
  set value(e) {
    this.$$set({ value: e }), $f();
  }
  get value_is_output() {
    return this.$$.ctx[11];
  }
  set value_is_output(e) {
    this.$$set({ value_is_output: e }), $f();
  }
  get height() {
    return this.$$.ctx[0];
  }
  set height(e) {
    this.$$set({ height: e }), $f();
  }
  get style() {
    return this.$$.ctx[12];
  }
  set style(e) {
    this.$$set({ style: e }), $f();
  }
  get latticeInfoVisible() {
    return this.$$.ctx[1];
  }
  set latticeInfoVisible(e) {
    this.$$set({ latticeInfoVisible: e }), $f();
  }
}
const {
  SvelteComponent: P4e,
  assign: B4e,
  attr: u_,
  check_outros: PF,
  create_component: TS,
  destroy_component: MS,
  detach: F9,
  element: F4e,
  empty: N4e,
  flush: _a,
  get_spread_object: R4e,
  get_spread_update: O4e,
  group_outros: BF,
  init: L4e,
  insert: N9,
  mount_component: PS,
  safe_not_equal: k4e,
  space: G4e,
  transition_in: ll,
  transition_out: f0
} = window.__gradio__svelte__internal;
function FF(t) {
  let e, r;
  const n = [
    { autoscroll: (
      /*gradio*/
      t[1].autoscroll
    ) },
    { i18n: (
      /*gradio*/
      t[1].i18n
    ) },
    /*loading_status*/
    t[8]
  ];
  let i = {};
  for (let a = 0; a < n.length; a += 1)
    i = B4e(i, n[a]);
  return e = new Bj({ props: i }), e.$on(
    "clear_status",
    /*clear_status_handler*/
    t[18]
  ), {
    c() {
      TS(e.$$.fragment);
    },
    m(a, o) {
      PS(e, a, o), r = !0;
    },
    p(a, o) {
      const s = o & /*gradio, loading_status*/
      258 ? O4e(n, [
        o & /*gradio*/
        2 && { autoscroll: (
          /*gradio*/
          a[1].autoscroll
        ) },
        o & /*gradio*/
        2 && { i18n: (
          /*gradio*/
          a[1].i18n
        ) },
        o & /*loading_status*/
        256 && R4e(
          /*loading_status*/
          a[8]
        )
      ]) : {};
      e.$set(s);
    },
    i(a) {
      r || (ll(e.$$.fragment, a), r = !0);
    },
    o(a) {
      f0(e.$$.fragment, a), r = !1;
    },
    d(a) {
      MS(e, a);
    }
  };
}
function NF(t) {
  let e, r, n, i;
  return r = new M4e({
    props: {
      gradio: (
        /*gradio*/
        t[1]
      ),
      materialFile: (
        /*materialFile*/
        t[2]
      ),
      value: (
        /*value*/
        t[0]
      ),
      value_is_output: (
        /*value_is_output*/
        t[9]
      ),
      height: (
        /*height*/
        t[10]
      ),
      style: (
        /*style*/
        t[11]
      ),
      latticeInfoVisible: (
        /*latticeInfoVisible*/
        t[12]
      )
    }
  }), {
    c() {
      e = F4e("div"), TS(r.$$.fragment), u_(e, "class", "material-viewer-index-container svelte-1d67499"), u_(e, "style", n = `height: ${/*height*/
      t[10]}px;`);
    },
    m(a, o) {
      N9(a, e, o), PS(r, e, null), i = !0;
    },
    p(a, o) {
      const s = {};
      o & /*gradio*/
      2 && (s.gradio = /*gradio*/
      a[1]), o & /*materialFile*/
      4 && (s.materialFile = /*materialFile*/
      a[2]), o & /*value*/
      1 && (s.value = /*value*/
      a[0]), o & /*value_is_output*/
      512 && (s.value_is_output = /*value_is_output*/
      a[9]), o & /*height*/
      1024 && (s.height = /*height*/
      a[10]), o & /*style*/
      2048 && (s.style = /*style*/
      a[11]), o & /*latticeInfoVisible*/
      4096 && (s.latticeInfoVisible = /*latticeInfoVisible*/
      a[12]), r.$set(s), (!i || o & /*height*/
      1024 && n !== (n = `height: ${/*height*/
      a[10]}px;`)) && u_(e, "style", n);
    },
    i(a) {
      i || (ll(r.$$.fragment, a), i = !0);
    },
    o(a) {
      f0(r.$$.fragment, a), i = !1;
    },
    d(a) {
      a && F9(e), MS(r);
    }
  };
}
function z4e(t) {
  let e, r, n, i = (
    /*loading_status*/
    t[8] && FF(t)
  ), a = (
    /*visible*/
    t[5] && NF(t)
  );
  return {
    c() {
      i && i.c(), e = G4e(), a && a.c(), r = N4e();
    },
    m(o, s) {
      i && i.m(o, s), N9(o, e, s), a && a.m(o, s), N9(o, r, s), n = !0;
    },
    p(o, s) {
      /*loading_status*/
      o[8] ? i ? (i.p(o, s), s & /*loading_status*/
      256 && ll(i, 1)) : (i = FF(o), i.c(), ll(i, 1), i.m(e.parentNode, e)) : i && (BF(), f0(i, 1, 1, () => {
        i = null;
      }), PF()), /*visible*/
      o[5] ? a ? (a.p(o, s), s & /*visible*/
      32 && ll(a, 1)) : (a = NF(o), a.c(), ll(a, 1), a.m(r.parentNode, r)) : a && (BF(), f0(a, 1, 1, () => {
        a = null;
      }), PF());
    },
    i(o) {
      n || (ll(i), ll(a), n = !0);
    },
    o(o) {
      f0(i), f0(a), n = !1;
    },
    d(o) {
      o && (F9(e), F9(r)), i && i.d(o), a && a.d(o);
    }
  };
}
function V4e(t) {
  let e, r;
  return e = new DW({
    props: {
      visible: (
        /*visible*/
        t[5]
      ),
      elem_id: (
        /*elem_id*/
        t[3]
      ),
      elem_classes: (
        /*elem_classes*/
        t[4]
      ),
      scale: (
        /*scale*/
        t[6]
      ),
      min_width: (
        /*min_width*/
        t[7]
      ),
      allow_overflow: !1,
      padding: !0,
      $$slots: { default: [z4e] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      TS(e.$$.fragment);
    },
    m(n, i) {
      PS(e, n, i), r = !0;
    },
    p(n, [i]) {
      const a = {};
      i & /*visible*/
      32 && (a.visible = /*visible*/
      n[5]), i & /*elem_id*/
      8 && (a.elem_id = /*elem_id*/
      n[3]), i & /*elem_classes*/
      16 && (a.elem_classes = /*elem_classes*/
      n[4]), i & /*scale*/
      64 && (a.scale = /*scale*/
      n[6]), i & /*min_width*/
      128 && (a.min_width = /*min_width*/
      n[7]), i & /*$$scope, height, gradio, materialFile, value, value_is_output, style, latticeInfoVisible, visible, loading_status*/
      16785191 && (a.$$scope = { dirty: i, ctx: n }), e.$set(a);
    },
    i(n) {
      r || (ll(e.$$.fragment, n), r = !0);
    },
    o(n) {
      f0(e.$$.fragment, n), r = !1;
    },
    d(n) {
      MS(e, n);
    }
  };
}
function U4e(t, e, r) {
  this && this.__awaiter;
  let { gradio: n } = e, { materialFile: i = "" } = e, { label: a = "Textbox" } = e, { elem_id: o = "" } = e, { elem_classes: s = [] } = e, { visible: u = !0 } = e, { value: c = "" } = e, { placeholder: l = "" } = e, { show_label: d } = e, { scale: f = null } = e, { min_width: h = void 0 } = e, { loading_status: m = void 0 } = e, { value_is_output: p = !1 } = e, { interactive: v } = e, { rtl: g = !1 } = e, { height: y } = e, { style: b } = e, { latticeInfoVisible: S } = e;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  function _() {
    n.dispatch("change"), p || n.dispatch("input");
  }
  const x = () => n.dispatch("clear_status", m);
  return t.$$set = (C) => {
    "gradio" in C && r(1, n = C.gradio), "materialFile" in C && r(2, i = C.materialFile), "label" in C && r(13, a = C.label), "elem_id" in C && r(3, o = C.elem_id), "elem_classes" in C && r(4, s = C.elem_classes), "visible" in C && r(5, u = C.visible), "value" in C && r(0, c = C.value), "placeholder" in C && r(14, l = C.placeholder), "show_label" in C && r(15, d = C.show_label), "scale" in C && r(6, f = C.scale), "min_width" in C && r(7, h = C.min_width), "loading_status" in C && r(8, m = C.loading_status), "value_is_output" in C && r(9, p = C.value_is_output), "interactive" in C && r(16, v = C.interactive), "rtl" in C && r(17, g = C.rtl), "height" in C && r(10, y = C.height), "style" in C && r(11, b = C.style), "latticeInfoVisible" in C && r(12, S = C.latticeInfoVisible);
  }, t.$$.update = () => {
    t.$$.dirty & /*value*/
    1 && c === null && r(0, c = ""), t.$$.dirty & /*value*/
    1 && _();
  }, [
    c,
    n,
    i,
    o,
    s,
    u,
    f,
    h,
    m,
    p,
    y,
    b,
    S,
    a,
    l,
    d,
    v,
    g,
    x
  ];
}
class X4e extends P4e {
  constructor(e) {
    super(), L4e(this, e, U4e, V4e, k4e, {
      gradio: 1,
      materialFile: 2,
      label: 13,
      elem_id: 3,
      elem_classes: 4,
      visible: 5,
      value: 0,
      placeholder: 14,
      show_label: 15,
      scale: 6,
      min_width: 7,
      loading_status: 8,
      value_is_output: 9,
      interactive: 16,
      rtl: 17,
      height: 10,
      style: 11,
      latticeInfoVisible: 12
    });
  }
  get gradio() {
    return this.$$.ctx[1];
  }
  set gradio(e) {
    this.$$set({ gradio: e }), _a();
  }
  get materialFile() {
    return this.$$.ctx[2];
  }
  set materialFile(e) {
    this.$$set({ materialFile: e }), _a();
  }
  get label() {
    return this.$$.ctx[13];
  }
  set label(e) {
    this.$$set({ label: e }), _a();
  }
  get elem_id() {
    return this.$$.ctx[3];
  }
  set elem_id(e) {
    this.$$set({ elem_id: e }), _a();
  }
  get elem_classes() {
    return this.$$.ctx[4];
  }
  set elem_classes(e) {
    this.$$set({ elem_classes: e }), _a();
  }
  get visible() {
    return this.$$.ctx[5];
  }
  set visible(e) {
    this.$$set({ visible: e }), _a();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(e) {
    this.$$set({ value: e }), _a();
  }
  get placeholder() {
    return this.$$.ctx[14];
  }
  set placeholder(e) {
    this.$$set({ placeholder: e }), _a();
  }
  get show_label() {
    return this.$$.ctx[15];
  }
  set show_label(e) {
    this.$$set({ show_label: e }), _a();
  }
  get scale() {
    return this.$$.ctx[6];
  }
  set scale(e) {
    this.$$set({ scale: e }), _a();
  }
  get min_width() {
    return this.$$.ctx[7];
  }
  set min_width(e) {
    this.$$set({ min_width: e }), _a();
  }
  get loading_status() {
    return this.$$.ctx[8];
  }
  set loading_status(e) {
    this.$$set({ loading_status: e }), _a();
  }
  get value_is_output() {
    return this.$$.ctx[9];
  }
  set value_is_output(e) {
    this.$$set({ value_is_output: e }), _a();
  }
  get interactive() {
    return this.$$.ctx[16];
  }
  set interactive(e) {
    this.$$set({ interactive: e }), _a();
  }
  get rtl() {
    return this.$$.ctx[17];
  }
  set rtl(e) {
    this.$$set({ rtl: e }), _a();
  }
  get height() {
    return this.$$.ctx[10];
  }
  set height(e) {
    this.$$set({ height: e }), _a();
  }
  get style() {
    return this.$$.ctx[11];
  }
  set style(e) {
    this.$$set({ style: e }), _a();
  }
  get latticeInfoVisible() {
    return this.$$.ctx[12];
  }
  set latticeInfoVisible(e) {
    this.$$set({ latticeInfoVisible: e }), _a();
  }
}
export {
  X4e as default
};
