diff --git "a/src/backend/gradio_molecule3d/templates/component/index.js" "b/src/backend/gradio_molecule3d/templates/component/index.js"
new file mode 100644--- /dev/null
+++ "b/src/backend/gradio_molecule3d/templates/component/index.js"
@@ -0,0 +1,34060 @@
+const Block_svelte_svelte_type_style_lang = "", {
+ SvelteComponent: SvelteComponent$l,
+ assign: assign$1,
+ create_slot: create_slot$4,
+ detach: detach$l,
+ element: element$d,
+ get_all_dirty_from_scope: get_all_dirty_from_scope$4,
+ get_slot_changes: get_slot_changes$4,
+ get_spread_update: get_spread_update$1,
+ init: init$l,
+ insert: insert$l,
+ safe_not_equal: safe_not_equal$m,
+ set_dynamic_element_data,
+ set_style: set_style$6,
+ toggle_class: toggle_class$b,
+ transition_in: transition_in$c,
+ transition_out: transition_out$b,
+ update_slot_base: update_slot_base$4
+} = window.__gradio__svelte__internal;
+function create_dynamic_element(r) {
+ let e, t, s;
+ const f = (
+ /*#slots*/
+ r[17].default
+ ), _ = create_slot$4(
+ f,
+ r,
+ /*$$scope*/
+ r[16],
+ null
+ );
+ let x = [
+ { "data-testid": (
+ /*test_id*/
+ r[7]
+ ) },
+ { id: (
+ /*elem_id*/
+ r[2]
+ ) },
+ {
+ class: t = "block " + /*elem_classes*/
+ r[3].join(" ") + " svelte-1t38q2d"
+ }
+ ], h = {};
+ for (let u = 0; u < x.length; u += 1)
+ h = assign$1(h, x[u]);
+ return {
+ c() {
+ e = element$d(
+ /*tag*/
+ r[14]
+ ), _ && _.c(), set_dynamic_element_data(
+ /*tag*/
+ r[14]
+ )(e, h), toggle_class$b(
+ e,
+ "hidden",
+ /*visible*/
+ r[10] === !1
+ ), toggle_class$b(
+ e,
+ "padded",
+ /*padding*/
+ r[6]
+ ), toggle_class$b(
+ e,
+ "border_focus",
+ /*border_mode*/
+ r[5] === "focus"
+ ), toggle_class$b(e, "hide-container", !/*explicit_call*/
+ r[8] && !/*container*/
+ r[9]), set_style$6(e, "height", typeof /*height*/
+ r[0] == "number" ? (
+ /*height*/
+ r[0] + "px"
+ ) : void 0), set_style$6(e, "width", typeof /*width*/
+ r[1] == "number" ? `calc(min(${/*width*/
+ r[1]}px, 100%))` : void 0), set_style$6(
+ e,
+ "border-style",
+ /*variant*/
+ r[4]
+ ), set_style$6(
+ e,
+ "overflow",
+ /*allow_overflow*/
+ r[11] ? "visible" : "hidden"
+ ), set_style$6(
+ e,
+ "flex-grow",
+ /*scale*/
+ r[12]
+ ), set_style$6(e, "min-width", `calc(min(${/*min_width*/
+ r[13]}px, 100%))`), set_style$6(e, "border-width", "var(--block-border-width)");
+ },
+ m(u, E) {
+ insert$l(u, e, E), _ && _.m(e, null), s = !0;
+ },
+ p(u, E) {
+ _ && _.p && (!s || E & /*$$scope*/
+ 65536) && update_slot_base$4(
+ _,
+ f,
+ u,
+ /*$$scope*/
+ u[16],
+ s ? get_slot_changes$4(
+ f,
+ /*$$scope*/
+ u[16],
+ E,
+ null
+ ) : get_all_dirty_from_scope$4(
+ /*$$scope*/
+ u[16]
+ ),
+ null
+ ), set_dynamic_element_data(
+ /*tag*/
+ u[14]
+ )(e, h = get_spread_update$1(x, [
+ (!s || E & /*test_id*/
+ 128) && { "data-testid": (
+ /*test_id*/
+ u[7]
+ ) },
+ (!s || E & /*elem_id*/
+ 4) && { id: (
+ /*elem_id*/
+ u[2]
+ ) },
+ (!s || E & /*elem_classes*/
+ 8 && t !== (t = "block " + /*elem_classes*/
+ u[3].join(" ") + " svelte-1t38q2d")) && { class: t }
+ ])), toggle_class$b(
+ e,
+ "hidden",
+ /*visible*/
+ u[10] === !1
+ ), toggle_class$b(
+ e,
+ "padded",
+ /*padding*/
+ u[6]
+ ), toggle_class$b(
+ e,
+ "border_focus",
+ /*border_mode*/
+ u[5] === "focus"
+ ), toggle_class$b(e, "hide-container", !/*explicit_call*/
+ u[8] && !/*container*/
+ u[9]), E & /*height*/
+ 1 && set_style$6(e, "height", typeof /*height*/
+ u[0] == "number" ? (
+ /*height*/
+ u[0] + "px"
+ ) : void 0), E & /*width*/
+ 2 && set_style$6(e, "width", typeof /*width*/
+ u[1] == "number" ? `calc(min(${/*width*/
+ u[1]}px, 100%))` : void 0), E & /*variant*/
+ 16 && set_style$6(
+ e,
+ "border-style",
+ /*variant*/
+ u[4]
+ ), E & /*allow_overflow*/
+ 2048 && set_style$6(
+ e,
+ "overflow",
+ /*allow_overflow*/
+ u[11] ? "visible" : "hidden"
+ ), E & /*scale*/
+ 4096 && set_style$6(
+ e,
+ "flex-grow",
+ /*scale*/
+ u[12]
+ ), E & /*min_width*/
+ 8192 && set_style$6(e, "min-width", `calc(min(${/*min_width*/
+ u[13]}px, 100%))`);
+ },
+ i(u) {
+ s || (transition_in$c(_, u), s = !0);
+ },
+ o(u) {
+ transition_out$b(_, u), s = !1;
+ },
+ d(u) {
+ u && detach$l(e), _ && _.d(u);
+ }
+ };
+}
+function create_fragment$l(r) {
+ let e, t = (
+ /*tag*/
+ r[14] && create_dynamic_element(r)
+ );
+ return {
+ c() {
+ t && t.c();
+ },
+ m(s, f) {
+ t && t.m(s, f), e = !0;
+ },
+ p(s, [f]) {
+ /*tag*/
+ s[14] && t.p(s, f);
+ },
+ i(s) {
+ e || (transition_in$c(t, s), e = !0);
+ },
+ o(s) {
+ transition_out$b(t, s), e = !1;
+ },
+ d(s) {
+ t && t.d(s);
+ }
+ };
+}
+function instance$f(r, e, t) {
+ let { $$slots: s = {}, $$scope: f } = e, { height: _ = void 0 } = e, { width: x = void 0 } = e, { elem_id: h = "" } = e, { elem_classes: u = [] } = e, { variant: E = "solid" } = e, { border_mode: c = "base" } = e, { padding: C = !0 } = e, { type: b = "normal" } = e, { test_id: A = void 0 } = e, { explicit_call: S = !1 } = e, { container: n = !0 } = e, { visible: o = !0 } = e, { allow_overflow: w = !0 } = e, { scale: p = null } = e, { min_width: v = 0 } = e, a = b === "fieldset" ? "fieldset" : "div";
+ return r.$$set = (l) => {
+ "height" in l && t(0, _ = l.height), "width" in l && t(1, x = l.width), "elem_id" in l && t(2, h = l.elem_id), "elem_classes" in l && t(3, u = l.elem_classes), "variant" in l && t(4, E = l.variant), "border_mode" in l && t(5, c = l.border_mode), "padding" in l && t(6, C = l.padding), "type" in l && t(15, b = l.type), "test_id" in l && t(7, A = l.test_id), "explicit_call" in l && t(8, S = l.explicit_call), "container" in l && t(9, n = l.container), "visible" in l && t(10, o = l.visible), "allow_overflow" in l && t(11, w = l.allow_overflow), "scale" in l && t(12, p = l.scale), "min_width" in l && t(13, v = l.min_width), "$$scope" in l && t(16, f = l.$$scope);
+ }, [
+ _,
+ x,
+ h,
+ u,
+ E,
+ c,
+ C,
+ A,
+ S,
+ n,
+ o,
+ w,
+ p,
+ v,
+ a,
+ b,
+ f,
+ s
+ ];
+}
+class Block extends SvelteComponent$l {
+ constructor(e) {
+ super(), init$l(this, e, instance$f, create_fragment$l, safe_not_equal$m, {
+ height: 0,
+ width: 1,
+ elem_id: 2,
+ elem_classes: 3,
+ variant: 4,
+ border_mode: 5,
+ padding: 6,
+ type: 15,
+ test_id: 7,
+ explicit_call: 8,
+ container: 9,
+ visible: 10,
+ allow_overflow: 11,
+ scale: 12,
+ min_width: 13
+ });
+ }
+}
+const Info_svelte_svelte_type_style_lang = "", BlockTitle_svelte_svelte_type_style_lang = "", BlockLabel_svelte_svelte_type_style_lang = "", {
+ SvelteComponent: SvelteComponent$k,
+ append: append$i,
+ attr: attr$i,
+ create_component: create_component$8,
+ destroy_component: destroy_component$8,
+ detach: detach$k,
+ element: element$c,
+ init: init$k,
+ insert: insert$k,
+ mount_component: mount_component$8,
+ safe_not_equal: safe_not_equal$l,
+ set_data: set_data$7,
+ space: space$b,
+ text: text$7,
+ toggle_class: toggle_class$a,
+ transition_in: transition_in$b,
+ transition_out: transition_out$a
+} = window.__gradio__svelte__internal;
+function create_fragment$k(r) {
+ let e, t, s, f, _, x;
+ return s = new /*Icon*/
+ r[1]({}), {
+ c() {
+ e = element$c("label"), t = element$c("span"), create_component$8(s.$$.fragment), f = space$b(), _ = text$7(
+ /*label*/
+ r[0]
+ ), attr$i(t, "class", "svelte-9gxdi0"), attr$i(e, "for", ""), attr$i(e, "data-testid", "block-label"), attr$i(e, "class", "svelte-9gxdi0"), toggle_class$a(e, "hide", !/*show_label*/
+ r[2]), toggle_class$a(e, "sr-only", !/*show_label*/
+ r[2]), toggle_class$a(
+ e,
+ "float",
+ /*float*/
+ r[4]
+ ), toggle_class$a(
+ e,
+ "hide-label",
+ /*disable*/
+ r[3]
+ );
+ },
+ m(h, u) {
+ insert$k(h, e, u), append$i(e, t), mount_component$8(s, t, null), append$i(e, f), append$i(e, _), x = !0;
+ },
+ p(h, [u]) {
+ (!x || u & /*label*/
+ 1) && set_data$7(
+ _,
+ /*label*/
+ h[0]
+ ), (!x || u & /*show_label*/
+ 4) && toggle_class$a(e, "hide", !/*show_label*/
+ h[2]), (!x || u & /*show_label*/
+ 4) && toggle_class$a(e, "sr-only", !/*show_label*/
+ h[2]), (!x || u & /*float*/
+ 16) && toggle_class$a(
+ e,
+ "float",
+ /*float*/
+ h[4]
+ ), (!x || u & /*disable*/
+ 8) && toggle_class$a(
+ e,
+ "hide-label",
+ /*disable*/
+ h[3]
+ );
+ },
+ i(h) {
+ x || (transition_in$b(s.$$.fragment, h), x = !0);
+ },
+ o(h) {
+ transition_out$a(s.$$.fragment, h), x = !1;
+ },
+ d(h) {
+ h && detach$k(e), destroy_component$8(s);
+ }
+ };
+}
+function instance$e(r, e, t) {
+ let { label: s = null } = e, { Icon: f } = e, { show_label: _ = !0 } = e, { disable: x = !1 } = e, { float: h = !0 } = e;
+ return r.$$set = (u) => {
+ "label" in u && t(0, s = u.label), "Icon" in u && t(1, f = u.Icon), "show_label" in u && t(2, _ = u.show_label), "disable" in u && t(3, x = u.disable), "float" in u && t(4, h = u.float);
+ }, [s, f, _, x, h];
+}
+class BlockLabel extends SvelteComponent$k {
+ constructor(e) {
+ super(), init$k(this, e, instance$e, create_fragment$k, safe_not_equal$l, {
+ label: 0,
+ Icon: 1,
+ show_label: 2,
+ disable: 3,
+ float: 4
+ });
+ }
+}
+const IconButton_svelte_svelte_type_style_lang = "", {
+ SvelteComponent: SvelteComponent$j,
+ append: append$h,
+ attr: attr$h,
+ bubble: bubble$3,
+ create_component: create_component$7,
+ destroy_component: destroy_component$7,
+ detach: detach$j,
+ element: element$b,
+ init: init$j,
+ insert: insert$j,
+ listen: listen$4,
+ mount_component: mount_component$7,
+ safe_not_equal: safe_not_equal$k,
+ set_data: set_data$6,
+ space: space$a,
+ text: text$6,
+ toggle_class: toggle_class$9,
+ transition_in: transition_in$a,
+ transition_out: transition_out$9
+} = window.__gradio__svelte__internal;
+function create_if_block$9(r) {
+ let e, t;
+ return {
+ c() {
+ e = element$b("span"), t = text$6(
+ /*label*/
+ r[1]
+ ), attr$h(e, "class", "svelte-xtz2g8");
+ },
+ m(s, f) {
+ insert$j(s, e, f), append$h(e, t);
+ },
+ p(s, f) {
+ f & /*label*/
+ 2 && set_data$6(
+ t,
+ /*label*/
+ s[1]
+ );
+ },
+ d(s) {
+ s && detach$j(e);
+ }
+ };
+}
+function create_fragment$j(r) {
+ let e, t, s, f, _, x, h, u = (
+ /*show_label*/
+ r[2] && create_if_block$9(r)
+ );
+ return f = new /*Icon*/
+ r[0]({}), {
+ c() {
+ e = element$b("button"), u && u.c(), t = space$a(), s = element$b("div"), create_component$7(f.$$.fragment), attr$h(s, "class", "svelte-xtz2g8"), toggle_class$9(
+ s,
+ "small",
+ /*size*/
+ r[4] === "small"
+ ), toggle_class$9(
+ s,
+ "large",
+ /*size*/
+ r[4] === "large"
+ ), attr$h(
+ e,
+ "aria-label",
+ /*label*/
+ r[1]
+ ), attr$h(
+ e,
+ "title",
+ /*label*/
+ r[1]
+ ), attr$h(e, "class", "svelte-xtz2g8"), toggle_class$9(
+ e,
+ "pending",
+ /*pending*/
+ r[3]
+ ), toggle_class$9(
+ e,
+ "padded",
+ /*padded*/
+ r[5]
+ );
+ },
+ m(E, c) {
+ insert$j(E, e, c), u && u.m(e, null), append$h(e, t), append$h(e, s), mount_component$7(f, s, null), _ = !0, x || (h = listen$4(
+ e,
+ "click",
+ /*click_handler*/
+ r[6]
+ ), x = !0);
+ },
+ p(E, [c]) {
+ /*show_label*/
+ E[2] ? u ? u.p(E, c) : (u = create_if_block$9(E), u.c(), u.m(e, t)) : u && (u.d(1), u = null), (!_ || c & /*size*/
+ 16) && toggle_class$9(
+ s,
+ "small",
+ /*size*/
+ E[4] === "small"
+ ), (!_ || c & /*size*/
+ 16) && toggle_class$9(
+ s,
+ "large",
+ /*size*/
+ E[4] === "large"
+ ), (!_ || c & /*label*/
+ 2) && attr$h(
+ e,
+ "aria-label",
+ /*label*/
+ E[1]
+ ), (!_ || c & /*label*/
+ 2) && attr$h(
+ e,
+ "title",
+ /*label*/
+ E[1]
+ ), (!_ || c & /*pending*/
+ 8) && toggle_class$9(
+ e,
+ "pending",
+ /*pending*/
+ E[3]
+ ), (!_ || c & /*padded*/
+ 32) && toggle_class$9(
+ e,
+ "padded",
+ /*padded*/
+ E[5]
+ );
+ },
+ i(E) {
+ _ || (transition_in$a(f.$$.fragment, E), _ = !0);
+ },
+ o(E) {
+ transition_out$9(f.$$.fragment, E), _ = !1;
+ },
+ d(E) {
+ E && detach$j(e), u && u.d(), destroy_component$7(f), x = !1, h();
+ }
+ };
+}
+function instance$d(r, e, t) {
+ let { Icon: s } = e, { label: f = "" } = e, { show_label: _ = !1 } = e, { pending: x = !1 } = e, { size: h = "small" } = e, { padded: u = !0 } = e;
+ function E(c) {
+ bubble$3.call(this, r, c);
+ }
+ return r.$$set = (c) => {
+ "Icon" in c && t(0, s = c.Icon), "label" in c && t(1, f = c.label), "show_label" in c && t(2, _ = c.show_label), "pending" in c && t(3, x = c.pending), "size" in c && t(4, h = c.size), "padded" in c && t(5, u = c.padded);
+ }, [s, f, _, x, h, u, E];
+}
+class IconButton extends SvelteComponent$j {
+ constructor(e) {
+ super(), init$j(this, e, instance$d, create_fragment$j, safe_not_equal$k, {
+ Icon: 0,
+ label: 1,
+ show_label: 2,
+ pending: 3,
+ size: 4,
+ padded: 5
+ });
+ }
+}
+const Empty_svelte_svelte_type_style_lang = "", {
+ SvelteComponent: SvelteComponent$i,
+ append: append$g,
+ attr: attr$g,
+ binding_callbacks: binding_callbacks$4,
+ create_slot: create_slot$3,
+ detach: detach$i,
+ element: element$a,
+ get_all_dirty_from_scope: get_all_dirty_from_scope$3,
+ get_slot_changes: get_slot_changes$3,
+ init: init$i,
+ insert: insert$i,
+ safe_not_equal: safe_not_equal$j,
+ toggle_class: toggle_class$8,
+ transition_in: transition_in$9,
+ transition_out: transition_out$8,
+ update_slot_base: update_slot_base$3
+} = window.__gradio__svelte__internal;
+function create_fragment$i(r) {
+ let e, t, s;
+ const f = (
+ /*#slots*/
+ r[5].default
+ ), _ = create_slot$3(
+ f,
+ r,
+ /*$$scope*/
+ r[4],
+ null
+ );
+ return {
+ c() {
+ e = element$a("div"), t = element$a("div"), _ && _.c(), attr$g(t, "class", "icon svelte-3w3rth"), attr$g(e, "class", "empty svelte-3w3rth"), attr$g(e, "aria-label", "Empty value"), toggle_class$8(
+ e,
+ "small",
+ /*size*/
+ r[0] === "small"
+ ), toggle_class$8(
+ e,
+ "large",
+ /*size*/
+ r[0] === "large"
+ ), toggle_class$8(
+ e,
+ "unpadded_box",
+ /*unpadded_box*/
+ r[1]
+ ), toggle_class$8(
+ e,
+ "small_parent",
+ /*parent_height*/
+ r[3]
+ );
+ },
+ m(x, h) {
+ insert$i(x, e, h), append$g(e, t), _ && _.m(t, null), r[6](e), s = !0;
+ },
+ p(x, [h]) {
+ _ && _.p && (!s || h & /*$$scope*/
+ 16) && update_slot_base$3(
+ _,
+ f,
+ x,
+ /*$$scope*/
+ x[4],
+ s ? get_slot_changes$3(
+ f,
+ /*$$scope*/
+ x[4],
+ h,
+ null
+ ) : get_all_dirty_from_scope$3(
+ /*$$scope*/
+ x[4]
+ ),
+ null
+ ), (!s || h & /*size*/
+ 1) && toggle_class$8(
+ e,
+ "small",
+ /*size*/
+ x[0] === "small"
+ ), (!s || h & /*size*/
+ 1) && toggle_class$8(
+ e,
+ "large",
+ /*size*/
+ x[0] === "large"
+ ), (!s || h & /*unpadded_box*/
+ 2) && toggle_class$8(
+ e,
+ "unpadded_box",
+ /*unpadded_box*/
+ x[1]
+ ), (!s || h & /*parent_height*/
+ 8) && toggle_class$8(
+ e,
+ "small_parent",
+ /*parent_height*/
+ x[3]
+ );
+ },
+ i(x) {
+ s || (transition_in$9(_, x), s = !0);
+ },
+ o(x) {
+ transition_out$8(_, x), s = !1;
+ },
+ d(x) {
+ x && detach$i(e), _ && _.d(x), r[6](null);
+ }
+ };
+}
+function _optionalChain$1(r) {
+ let e, t = r[0], s = 1;
+ for (; s < r.length; ) {
+ const f = r[s], _ = r[s + 1];
+ if (s += 2, (f === "optionalAccess" || f === "optionalCall") && t == null)
+ return;
+ f === "access" || f === "optionalAccess" ? (e = t, t = _(t)) : (f === "call" || f === "optionalCall") && (t = _((...x) => t.call(e, ...x)), e = void 0);
+ }
+ return t;
+}
+function instance$c(r, e, t) {
+ let s, { $$slots: f = {}, $$scope: _ } = e, { size: x = "small" } = e, { unpadded_box: h = !1 } = e, u;
+ function E(C) {
+ if (!C)
+ return !1;
+ const { height: b } = C.getBoundingClientRect(), { height: A } = _optionalChain$1([
+ C,
+ "access",
+ (S) => S.parentElement,
+ "optionalAccess",
+ (S) => S.getBoundingClientRect,
+ "call",
+ (S) => S()
+ ]) || { height: b };
+ return b > A + 2;
+ }
+ function c(C) {
+ binding_callbacks$4[C ? "unshift" : "push"](() => {
+ u = C, t(2, u);
+ });
+ }
+ return r.$$set = (C) => {
+ "size" in C && t(0, x = C.size), "unpadded_box" in C && t(1, h = C.unpadded_box), "$$scope" in C && t(4, _ = C.$$scope);
+ }, r.$$.update = () => {
+ r.$$.dirty & /*el*/
+ 4 && t(3, s = E(u));
+ }, [x, h, u, s, _, f, c];
+}
+class Empty extends SvelteComponent$i {
+ constructor(e) {
+ super(), init$i(this, e, instance$c, create_fragment$i, safe_not_equal$j, { size: 0, unpadded_box: 1 });
+ }
+}
+const {
+ SvelteComponent: SvelteComponent$h,
+ append: append$f,
+ attr: attr$f,
+ detach: detach$h,
+ init: init$h,
+ insert: insert$h,
+ noop: noop$c,
+ safe_not_equal: safe_not_equal$i,
+ set_style: set_style$5,
+ svg_element: svg_element$8
+} = window.__gradio__svelte__internal;
+function create_fragment$h(r) {
+ let e, t, s, f;
+ return {
+ c() {
+ e = svg_element$8("svg"), t = svg_element$8("g"), s = svg_element$8("path"), f = svg_element$8("path"), attr$f(s, "d", "M18,6L6.087,17.913"), set_style$5(s, "fill", "none"), set_style$5(s, "fill-rule", "nonzero"), set_style$5(s, "stroke-width", "2px"), attr$f(t, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), attr$f(f, "d", "M4.364,4.364L19.636,19.636"), set_style$5(f, "fill", "none"), set_style$5(f, "fill-rule", "nonzero"), set_style$5(f, "stroke-width", "2px"), attr$f(e, "width", "100%"), attr$f(e, "height", "100%"), attr$f(e, "viewBox", "0 0 24 24"), attr$f(e, "version", "1.1"), attr$f(e, "xmlns", "http://www.w3.org/2000/svg"), attr$f(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), attr$f(e, "xml:space", "preserve"), attr$f(e, "stroke", "currentColor"), set_style$5(e, "fill-rule", "evenodd"), set_style$5(e, "clip-rule", "evenodd"), set_style$5(e, "stroke-linecap", "round"), set_style$5(e, "stroke-linejoin", "round");
+ },
+ m(_, x) {
+ insert$h(_, e, x), append$f(e, t), append$f(t, s), append$f(e, f);
+ },
+ p: noop$c,
+ i: noop$c,
+ o: noop$c,
+ d(_) {
+ _ && detach$h(e);
+ }
+ };
+}
+class Clear extends SvelteComponent$h {
+ constructor(e) {
+ super(), init$h(this, e, null, create_fragment$h, safe_not_equal$i, {});
+ }
+}
+const DropdownArrow_svelte_svelte_type_style_lang = "", {
+ SvelteComponent: SvelteComponent$g,
+ append: append$e,
+ attr: attr$e,
+ detach: detach$g,
+ init: init$g,
+ insert: insert$g,
+ noop: noop$b,
+ safe_not_equal: safe_not_equal$h,
+ svg_element: svg_element$7
+} = window.__gradio__svelte__internal;
+function create_fragment$g(r) {
+ let e, t;
+ return {
+ c() {
+ e = svg_element$7("svg"), t = svg_element$7("path"), attr$e(t, "d", "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"), attr$e(e, "xmlns", "http://www.w3.org/2000/svg"), attr$e(e, "width", "100%"), attr$e(e, "height", "100%"), attr$e(e, "viewBox", "0 0 24 24"), attr$e(e, "fill", "none"), attr$e(e, "stroke", "currentColor"), attr$e(e, "stroke-width", "1.5"), attr$e(e, "stroke-linecap", "round"), attr$e(e, "stroke-linejoin", "round"), attr$e(e, "class", "feather feather-edit-2");
+ },
+ m(s, f) {
+ insert$g(s, e, f), append$e(e, t);
+ },
+ p: noop$b,
+ i: noop$b,
+ o: noop$b,
+ d(s) {
+ s && detach$g(e);
+ }
+ };
+}
+class Edit extends SvelteComponent$g {
+ constructor(e) {
+ super(), init$g(this, e, null, create_fragment$g, safe_not_equal$h, {});
+ }
+}
+const {
+ SvelteComponent: SvelteComponent$f,
+ append: append$d,
+ attr: attr$d,
+ detach: detach$f,
+ init: init$f,
+ insert: insert$f,
+ noop: noop$a,
+ safe_not_equal: safe_not_equal$g,
+ svg_element: svg_element$6
+} = window.__gradio__svelte__internal;
+function create_fragment$f(r) {
+ let e, t, s;
+ return {
+ c() {
+ e = svg_element$6("svg"), t = svg_element$6("path"), s = svg_element$6("polyline"), attr$d(t, "d", "M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"), attr$d(s, "points", "13 2 13 9 20 9"), attr$d(e, "xmlns", "http://www.w3.org/2000/svg"), attr$d(e, "width", "100%"), attr$d(e, "height", "100%"), attr$d(e, "viewBox", "0 0 24 24"), attr$d(e, "fill", "none"), attr$d(e, "stroke", "currentColor"), attr$d(e, "stroke-width", "1.5"), attr$d(e, "stroke-linecap", "round"), attr$d(e, "stroke-linejoin", "round"), attr$d(e, "class", "feather feather-file");
+ },
+ m(f, _) {
+ insert$f(f, e, _), append$d(e, t), append$d(e, s);
+ },
+ p: noop$a,
+ i: noop$a,
+ o: noop$a,
+ d(f) {
+ f && detach$f(e);
+ }
+ };
+}
+let File$1 = class extends SvelteComponent$f {
+ constructor(e) {
+ super(), init$f(this, e, null, create_fragment$f, safe_not_equal$g, {});
+ }
+};
+const {
+ SvelteComponent: SvelteComponent$e,
+ append: append$c,
+ attr: attr$c,
+ detach: detach$e,
+ init: init$e,
+ insert: insert$e,
+ noop: noop$9,
+ safe_not_equal: safe_not_equal$f,
+ svg_element: svg_element$5
+} = window.__gradio__svelte__internal;
+function create_fragment$e(r) {
+ let e, t, s;
+ return {
+ c() {
+ e = svg_element$5("svg"), t = svg_element$5("polyline"), s = svg_element$5("path"), attr$c(t, "points", "1 4 1 10 7 10"), attr$c(s, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), attr$c(e, "xmlns", "http://www.w3.org/2000/svg"), attr$c(e, "width", "100%"), attr$c(e, "height", "100%"), attr$c(e, "viewBox", "0 0 24 24"), attr$c(e, "fill", "none"), attr$c(e, "stroke", "currentColor"), attr$c(e, "stroke-width", "2"), attr$c(e, "stroke-linecap", "round"), attr$c(e, "stroke-linejoin", "round"), attr$c(e, "class", "feather feather-rotate-ccw");
+ },
+ m(f, _) {
+ insert$e(f, e, _), append$c(e, t), append$c(e, s);
+ },
+ p: noop$9,
+ i: noop$9,
+ o: noop$9,
+ d(f) {
+ f && detach$e(e);
+ }
+ };
+}
+class Undo extends SvelteComponent$e {
+ constructor(e) {
+ super(), init$e(this, e, null, create_fragment$e, safe_not_equal$f, {});
+ }
+}
+const {
+ SvelteComponent: SvelteComponent$d,
+ append: append$b,
+ attr: attr$b,
+ detach: detach$d,
+ init: init$d,
+ insert: insert$d,
+ noop: noop$8,
+ safe_not_equal: safe_not_equal$e,
+ svg_element: svg_element$4
+} = window.__gradio__svelte__internal;
+function create_fragment$d(r) {
+ let e, t, s, f;
+ return {
+ c() {
+ e = svg_element$4("svg"), t = svg_element$4("path"), s = svg_element$4("polyline"), f = svg_element$4("line"), attr$b(t, "d", "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"), attr$b(s, "points", "17 8 12 3 7 8"), attr$b(f, "x1", "12"), attr$b(f, "y1", "3"), attr$b(f, "x2", "12"), attr$b(f, "y2", "15"), attr$b(e, "xmlns", "http://www.w3.org/2000/svg"), attr$b(e, "width", "90%"), attr$b(e, "height", "90%"), attr$b(e, "viewBox", "0 0 24 24"), attr$b(e, "fill", "none"), attr$b(e, "stroke", "currentColor"), attr$b(e, "stroke-width", "2"), attr$b(e, "stroke-linecap", "round"), attr$b(e, "stroke-linejoin", "round"), attr$b(e, "class", "feather feather-upload");
+ },
+ m(_, x) {
+ insert$d(_, e, x), append$b(e, t), append$b(e, s), append$b(e, f);
+ },
+ p: noop$8,
+ i: noop$8,
+ o: noop$8,
+ d(_) {
+ _ && detach$d(e);
+ }
+ };
+}
+let Upload$1 = class extends SvelteComponent$d {
+ constructor(e) {
+ super(), init$d(this, e, null, create_fragment$d, safe_not_equal$e, {});
+ }
+};
+const color_values = [
+ { 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 }
+], tw_colors = {
+ 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"
+ }
+};
+color_values.reduce(
+ (r, { color: e, primary: t, secondary: s }) => ({
+ ...r,
+ [e]: {
+ primary: tw_colors[e][t],
+ secondary: tw_colors[e][s]
+ }
+ }),
+ {}
+);
+const UploadText_svelte_svelte_type_style_lang = "", {
+ SvelteComponent: SvelteComponent$c,
+ append: append$a,
+ attr: attr$a,
+ create_component: create_component$6,
+ destroy_component: destroy_component$6,
+ detach: detach$c,
+ element: element$9,
+ init: init$c,
+ insert: insert$c,
+ mount_component: mount_component$6,
+ safe_not_equal: safe_not_equal$d,
+ set_data: set_data$5,
+ space: space$9,
+ text: text$5,
+ toggle_class: toggle_class$7,
+ transition_in: transition_in$8,
+ transition_out: transition_out$7
+} = window.__gradio__svelte__internal;
+function create_if_block$8(r) {
+ let e, t, s = (
+ /*i18n*/
+ r[1]("common.or") + ""
+ ), f, _, x, h = (
+ /*message*/
+ (r[2] || /*i18n*/
+ r[1]("upload_text.click_to_upload")) + ""
+ ), u;
+ return {
+ c() {
+ e = element$9("span"), t = text$5("- "), f = text$5(s), _ = text$5(" -"), x = space$9(), u = text$5(h), attr$a(e, "class", "or svelte-kzcjhc");
+ },
+ m(E, c) {
+ insert$c(E, e, c), append$a(e, t), append$a(e, f), append$a(e, _), insert$c(E, x, c), insert$c(E, u, c);
+ },
+ p(E, c) {
+ c & /*i18n*/
+ 2 && s !== (s = /*i18n*/
+ E[1]("common.or") + "") && set_data$5(f, s), c & /*message, i18n*/
+ 6 && h !== (h = /*message*/
+ (E[2] || /*i18n*/
+ E[1]("upload_text.click_to_upload")) + "") && set_data$5(u, h);
+ },
+ d(E) {
+ E && (detach$c(e), detach$c(x), detach$c(u));
+ }
+ };
+}
+function create_fragment$c(r) {
+ let e, t, s, f, _ = (
+ /*i18n*/
+ r[1](
+ /*defs*/
+ r[5][
+ /*type*/
+ r[0]
+ ] || /*defs*/
+ r[5].file
+ ) + ""
+ ), x, h, u;
+ s = new Upload$1({});
+ let E = (
+ /*mode*/
+ r[3] !== "short" && create_if_block$8(r)
+ );
+ return {
+ c() {
+ e = element$9("div"), t = element$9("span"), create_component$6(s.$$.fragment), f = space$9(), x = text$5(_), h = space$9(), E && E.c(), attr$a(t, "class", "icon-wrap svelte-kzcjhc"), toggle_class$7(
+ t,
+ "hovered",
+ /*hovered*/
+ r[4]
+ ), attr$a(e, "class", "wrap svelte-kzcjhc");
+ },
+ m(c, C) {
+ insert$c(c, e, C), append$a(e, t), mount_component$6(s, t, null), append$a(e, f), append$a(e, x), append$a(e, h), E && E.m(e, null), u = !0;
+ },
+ p(c, [C]) {
+ (!u || C & /*hovered*/
+ 16) && toggle_class$7(
+ t,
+ "hovered",
+ /*hovered*/
+ c[4]
+ ), (!u || C & /*i18n, type*/
+ 3) && _ !== (_ = /*i18n*/
+ c[1](
+ /*defs*/
+ c[5][
+ /*type*/
+ c[0]
+ ] || /*defs*/
+ c[5].file
+ ) + "") && set_data$5(x, _), /*mode*/
+ c[3] !== "short" ? E ? E.p(c, C) : (E = create_if_block$8(c), E.c(), E.m(e, null)) : E && (E.d(1), E = null);
+ },
+ i(c) {
+ u || (transition_in$8(s.$$.fragment, c), u = !0);
+ },
+ o(c) {
+ transition_out$7(s.$$.fragment, c), u = !1;
+ },
+ d(c) {
+ c && detach$c(e), destroy_component$6(s), E && E.d();
+ }
+ };
+}
+function instance$b(r, e, t) {
+ let { type: s = "file" } = e, { i18n: f } = e, { message: _ = void 0 } = e, { mode: x = "full" } = e, { hovered: h = !1 } = e;
+ const u = {
+ image: "upload_text.drop_image",
+ video: "upload_text.drop_video",
+ audio: "upload_text.drop_audio",
+ file: "upload_text.drop_file",
+ csv: "upload_text.drop_csv"
+ };
+ return r.$$set = (E) => {
+ "type" in E && t(0, s = E.type), "i18n" in E && t(1, f = E.i18n), "message" in E && t(2, _ = E.message), "mode" in E && t(3, x = E.mode), "hovered" in E && t(4, h = E.hovered);
+ }, [s, f, _, x, h, u];
+}
+class UploadText extends SvelteComponent$c {
+ constructor(e) {
+ super(), init$c(this, e, instance$b, create_fragment$c, safe_not_equal$d, {
+ type: 0,
+ i18n: 1,
+ message: 2,
+ mode: 3,
+ hovered: 4
+ });
+ }
+}
+const Toolbar_svelte_svelte_type_style_lang = "", prettyBytes = (r) => {
+ let e = ["B", "KB", "MB", "GB", "PB"], t = 0;
+ for (; r > 1024; )
+ r /= 1024, t++;
+ let s = e[t];
+ return r.toFixed(1) + " " + s;
+}, display_file_name = (r) => {
+ var e;
+ e = r.orig_name;
+ const t = 30;
+ if (e.length > t) {
+ const s = e.substring(0, t), f = e.lastIndexOf(".");
+ if (f !== -1) {
+ const _ = e.slice(f);
+ return `${s}..${_}`;
+ }
+ return s;
+ }
+ return e;
+}, display_file_size = (r) => {
+ var e = 0;
+ if (Array.isArray(r))
+ for (var t of r)
+ t.size !== void 0 && (e += t.size);
+ else
+ e = r.size || 0;
+ return prettyBytes(e);
+}, FilePreview_svelte_svelte_type_style_lang = "", {
+ HtmlTag,
+ SvelteComponent: SvelteComponent$b,
+ append: append$9,
+ attr: attr$9,
+ destroy_each: destroy_each$3,
+ detach: detach$b,
+ element: element$8,
+ ensure_array_like: ensure_array_like$3,
+ init: init$b,
+ insert: insert$b,
+ listen: listen$3,
+ noop: noop$7,
+ safe_not_equal: safe_not_equal$c,
+ set_data: set_data$4,
+ set_style: set_style$4,
+ space: space$8,
+ text: text$4,
+ toggle_class: toggle_class$6
+} = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$4 } = window.__gradio__svelte__internal;
+function get_each_context$3(r, e, t) {
+ const s = r.slice();
+ return s[6] = e[t], s[8] = t, s;
+}
+function create_else_block$6(r) {
+ let e = (
+ /*i18n*/
+ r[3]("file.uploading") + ""
+ ), t;
+ return {
+ c() {
+ t = text$4(e);
+ },
+ m(s, f) {
+ insert$b(s, t, f);
+ },
+ p(s, f) {
+ f & /*i18n*/
+ 8 && e !== (e = /*i18n*/
+ s[3]("file.uploading") + "") && set_data$4(t, e);
+ },
+ d(s) {
+ s && detach$b(t);
+ }
+ };
+}
+function create_if_block$7(r) {
+ let e, t, s = display_file_size(
+ /*file*/
+ r[6]
+ ) + "", f, _, x;
+ return {
+ c() {
+ e = element$8("a"), t = new HtmlTag(!1), f = text$4(" ⇣"), t.a = f, attr$9(e, "href", _ = /*file*/
+ r[6].url), attr$9(e, "target", "_blank"), attr$9(e, "download", x = window.__is_colab__ ? null : (
+ /*file*/
+ r[6].orig_name
+ )), attr$9(e, "class", "svelte-usqupg");
+ },
+ m(h, u) {
+ insert$b(h, e, u), t.m(s, e), append$9(e, f);
+ },
+ p(h, u) {
+ u & /*value*/
+ 1 && s !== (s = display_file_size(
+ /*file*/
+ h[6]
+ ) + "") && t.p(s), u & /*value*/
+ 1 && _ !== (_ = /*file*/
+ h[6].url) && attr$9(e, "href", _), u & /*value*/
+ 1 && x !== (x = window.__is_colab__ ? null : (
+ /*file*/
+ h[6].orig_name
+ )) && attr$9(e, "download", x);
+ },
+ d(h) {
+ h && detach$b(e);
+ }
+ };
+}
+function create_each_block$3(r) {
+ let e, t, s = display_file_name(
+ /*file*/
+ r[6]
+ ) + "", f, _, x, h, u, E;
+ function c(S, n) {
+ return (
+ /*file*/
+ S[6].url ? create_if_block$7 : create_else_block$6
+ );
+ }
+ let C = c(r), b = C(r);
+ function A() {
+ return (
+ /*click_handler*/
+ r[5](
+ /*file*/
+ r[6],
+ /*i*/
+ r[8]
+ )
+ );
+ }
+ return {
+ c() {
+ e = element$8("tr"), t = element$8("td"), f = text$4(s), _ = space$8(), x = element$8("td"), b.c(), h = space$8(), attr$9(t, "class", "svelte-usqupg"), attr$9(x, "class", "download svelte-usqupg"), attr$9(e, "class", "file svelte-usqupg"), toggle_class$6(
+ e,
+ "selectable",
+ /*selectable*/
+ r[1]
+ );
+ },
+ m(S, n) {
+ insert$b(S, e, n), append$9(e, t), append$9(t, f), append$9(e, _), append$9(e, x), b.m(x, null), append$9(e, h), u || (E = listen$3(e, "click", A), u = !0);
+ },
+ p(S, n) {
+ r = S, n & /*value*/
+ 1 && s !== (s = display_file_name(
+ /*file*/
+ r[6]
+ ) + "") && set_data$4(f, s), C === (C = c(r)) && b ? b.p(r, n) : (b.d(1), b = C(r), b && (b.c(), b.m(x, null))), n & /*selectable*/
+ 2 && toggle_class$6(
+ e,
+ "selectable",
+ /*selectable*/
+ r[1]
+ );
+ },
+ d(S) {
+ S && detach$b(e), b.d(), u = !1, E();
+ }
+ };
+}
+function create_fragment$b(r) {
+ let e, t, s, f = ensure_array_like$3(Array.isArray(
+ /*value*/
+ r[0]
+ ) ? (
+ /*value*/
+ r[0]
+ ) : [
+ /*value*/
+ r[0]
+ ]), _ = [];
+ for (let x = 0; x < f.length; x += 1)
+ _[x] = create_each_block$3(get_each_context$3(r, f, x));
+ return {
+ c() {
+ e = element$8("div"), t = element$8("table"), s = element$8("tbody");
+ for (let x = 0; x < _.length; x += 1)
+ _[x].c();
+ attr$9(s, "class", "svelte-usqupg"), attr$9(t, "class", "file-preview svelte-usqupg"), attr$9(e, "class", "file-preview-holder svelte-usqupg"), set_style$4(e, "max-height", typeof /*height*/
+ r[2] === void 0 ? "auto" : (
+ /*height*/
+ r[2] + "px"
+ ));
+ },
+ m(x, h) {
+ insert$b(x, e, h), append$9(e, t), append$9(t, s);
+ for (let u = 0; u < _.length; u += 1)
+ _[u] && _[u].m(s, null);
+ },
+ p(x, [h]) {
+ if (h & /*selectable, dispatch, Array, value, window, i18n*/
+ 27) {
+ f = ensure_array_like$3(Array.isArray(
+ /*value*/
+ x[0]
+ ) ? (
+ /*value*/
+ x[0]
+ ) : [
+ /*value*/
+ x[0]
+ ]);
+ let u;
+ for (u = 0; u < f.length; u += 1) {
+ const E = get_each_context$3(x, f, u);
+ _[u] ? _[u].p(E, h) : (_[u] = create_each_block$3(E), _[u].c(), _[u].m(s, null));
+ }
+ for (; u < _.length; u += 1)
+ _[u].d(1);
+ _.length = f.length;
+ }
+ h & /*height*/
+ 4 && set_style$4(e, "max-height", typeof /*height*/
+ x[2] === void 0 ? "auto" : (
+ /*height*/
+ x[2] + "px"
+ ));
+ },
+ i: noop$7,
+ o: noop$7,
+ d(x) {
+ x && detach$b(e), destroy_each$3(_, x);
+ }
+ };
+}
+function instance$a(r, e, t) {
+ const s = createEventDispatcher$4();
+ let { value: f } = e, { selectable: _ = !1 } = e, { height: x = void 0 } = e, { i18n: h } = e;
+ const u = (E, c) => s("select", { value: E.orig_name, index: c });
+ return r.$$set = (E) => {
+ "value" in E && t(0, f = E.value), "selectable" in E && t(1, _ = E.selectable), "height" in E && t(2, x = E.height), "i18n" in E && t(3, h = E.i18n);
+ }, [f, _, x, h, s, u];
+}
+class FilePreview extends SvelteComponent$b {
+ constructor(e) {
+ super(), init$b(this, e, instance$a, create_fragment$b, safe_not_equal$c, {
+ value: 0,
+ selectable: 1,
+ height: 2,
+ i18n: 3
+ });
+ }
+}
+var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
+function getDefaultExportFromCjs(r) {
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
+}
+var _3Dmol$1 = { exports: {} };
+/*!
+ * 3dmol v2.0.6
+ * JavaScript/TypeScript molecular visualization library
+ * Author: David Koes and contributors
+ */
+(function(module, exports) {
+ (function(e, t) {
+ module.exports = t();
+ })(commonjsGlobal, () => (
+ /******/
+ (() => {
+ var __webpack_modules__ = {
+ /***/
+ "./node_modules/iobuffer/lib-esm/IOBuffer.js": (
+ /*!***************************************************!*\
+ !*** ./node_modules/iobuffer/lib-esm/IOBuffer.js ***!
+ \***************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ IOBuffer: () => (
+ /* binding */
+ h
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! ./text */
+ "./node_modules/iobuffer/lib-esm/text.browser.js"
+ );
+ const f = 1024 * 8, _ = (() => {
+ const u = new Uint8Array(4), E = new Uint32Array(u.buffer);
+ return !((E[0] = 1) & u[0]);
+ })(), x = {
+ int8: globalThis.Int8Array,
+ uint8: globalThis.Uint8Array,
+ int16: globalThis.Int16Array,
+ uint16: globalThis.Uint16Array,
+ int32: globalThis.Int32Array,
+ uint32: globalThis.Uint32Array,
+ uint64: globalThis.BigUint64Array,
+ int64: globalThis.BigInt64Array,
+ float32: globalThis.Float32Array,
+ float64: globalThis.Float64Array
+ };
+ class h {
+ /**
+ * @param data - The data to construct the IOBuffer with.
+ * If data is a number, it will be the new buffer's length
+ * If data is `undefined`, the buffer will be initialized with a default length of 8Kb
+ * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
+ * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
+ * @param options
+ */
+ constructor(E = f, c = {}) {
+ let C = !1;
+ typeof E == "number" ? E = new ArrayBuffer(E) : (C = !0, this.lastWrittenByte = E.byteLength);
+ const b = c.offset ? c.offset >>> 0 : 0, A = E.byteLength - b;
+ let S = b;
+ (ArrayBuffer.isView(E) || E instanceof h) && (E.byteLength !== E.buffer.byteLength && (S = E.byteOffset + b), E = E.buffer), C ? this.lastWrittenByte = A : this.lastWrittenByte = 0, this.buffer = E, this.length = A, this.byteLength = A, this.byteOffset = S, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, S, A), this._mark = 0, this._marks = [];
+ }
+ /**
+ * Checks if the memory allocated to the buffer is sufficient to store more
+ * bytes after the offset.
+ * @param byteLength - The needed memory in bytes.
+ * @returns `true` if there is sufficient space and `false` otherwise.
+ */
+ available(E = 1) {
+ return this.offset + E <= this.length;
+ }
+ /**
+ * Check if little-endian mode is used for reading and writing multi-byte
+ * values.
+ * @returns `true` if little-endian mode is used, `false` otherwise.
+ */
+ isLittleEndian() {
+ return this.littleEndian;
+ }
+ /**
+ * Set little-endian mode for reading and writing multi-byte values.
+ */
+ setLittleEndian() {
+ return this.littleEndian = !0, this;
+ }
+ /**
+ * Check if big-endian mode is used for reading and writing multi-byte values.
+ * @returns `true` if big-endian mode is used, `false` otherwise.
+ */
+ isBigEndian() {
+ return !this.littleEndian;
+ }
+ /**
+ * Switches to big-endian mode for reading and writing multi-byte values.
+ */
+ setBigEndian() {
+ return this.littleEndian = !1, this;
+ }
+ /**
+ * Move the pointer n bytes forward.
+ * @param n - Number of bytes to skip.
+ */
+ skip(E = 1) {
+ return this.offset += E, this;
+ }
+ /**
+ * Move the pointer n bytes backward.
+ * @param n - Number of bytes to move back.
+ */
+ back(E = 1) {
+ return this.offset -= E, this;
+ }
+ /**
+ * Move the pointer to the given offset.
+ * @param offset
+ */
+ seek(E) {
+ return this.offset = E, this;
+ }
+ /**
+ * Store the current pointer offset.
+ * @see {@link IOBuffer#reset}
+ */
+ mark() {
+ return this._mark = this.offset, this;
+ }
+ /**
+ * Move the pointer back to the last pointer offset set by mark.
+ * @see {@link IOBuffer#mark}
+ */
+ reset() {
+ return this.offset = this._mark, this;
+ }
+ /**
+ * Push the current pointer offset to the mark stack.
+ * @see {@link IOBuffer#popMark}
+ */
+ pushMark() {
+ return this._marks.push(this.offset), this;
+ }
+ /**
+ * Pop the last pointer offset from the mark stack, and set the current
+ * pointer offset to the popped value.
+ * @see {@link IOBuffer#pushMark}
+ */
+ popMark() {
+ const E = this._marks.pop();
+ if (E === void 0)
+ throw new Error("Mark stack empty");
+ return this.seek(E), this;
+ }
+ /**
+ * Move the pointer offset back to 0.
+ */
+ rewind() {
+ return this.offset = 0, this;
+ }
+ /**
+ * Make sure the buffer has sufficient memory to write a given byteLength at
+ * the current pointer offset.
+ * If the buffer's memory is insufficient, this method will create a new
+ * buffer (a copy) with a length that is twice (byteLength + current offset).
+ * @param byteLength
+ */
+ ensureAvailable(E = 1) {
+ if (!this.available(E)) {
+ const C = (this.offset + E) * 2, b = new Uint8Array(C);
+ b.set(new Uint8Array(this.buffer)), this.buffer = b.buffer, this.length = this.byteLength = C, this._data = new DataView(this.buffer);
+ }
+ return this;
+ }
+ /**
+ * Read a byte and return false if the byte's value is 0, or true otherwise.
+ * Moves pointer forward by one byte.
+ */
+ readBoolean() {
+ return this.readUint8() !== 0;
+ }
+ /**
+ * Read a signed 8-bit integer and move pointer forward by 1 byte.
+ */
+ readInt8() {
+ return this._data.getInt8(this.offset++);
+ }
+ /**
+ * Read an unsigned 8-bit integer and move pointer forward by 1 byte.
+ */
+ readUint8() {
+ return this._data.getUint8(this.offset++);
+ }
+ /**
+ * Alias for {@link IOBuffer#readUint8}.
+ */
+ readByte() {
+ return this.readUint8();
+ }
+ /**
+ * Read `n` bytes and move pointer forward by `n` bytes.
+ */
+ readBytes(E = 1) {
+ return this.readArray(E, "uint8");
+ }
+ /**
+ * Creates an array of corresponding to the type `type` and size `size`.
+ * For example type `uint8` will create a `Uint8Array`.
+ * @param size - size of the resulting array
+ * @param type - number type of elements to read
+ */
+ readArray(E, c) {
+ const C = x[c].BYTES_PER_ELEMENT * E, b = this.byteOffset + this.offset, A = this.buffer.slice(b, b + C);
+ if (this.littleEndian === _ && c !== "uint8" && c !== "int8") {
+ const n = new Uint8Array(this.buffer.slice(b, b + C));
+ n.reverse();
+ const o = new x[c](n.buffer);
+ return this.offset += C, o.reverse(), o;
+ }
+ const S = new x[c](A);
+ return this.offset += C, S;
+ }
+ /**
+ * Read a 16-bit signed integer and move pointer forward by 2 bytes.
+ */
+ readInt16() {
+ const E = this._data.getInt16(this.offset, this.littleEndian);
+ return this.offset += 2, E;
+ }
+ /**
+ * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
+ */
+ readUint16() {
+ const E = this._data.getUint16(this.offset, this.littleEndian);
+ return this.offset += 2, E;
+ }
+ /**
+ * Read a 32-bit signed integer and move pointer forward by 4 bytes.
+ */
+ readInt32() {
+ const E = this._data.getInt32(this.offset, this.littleEndian);
+ return this.offset += 4, E;
+ }
+ /**
+ * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
+ */
+ readUint32() {
+ const E = this._data.getUint32(this.offset, this.littleEndian);
+ return this.offset += 4, E;
+ }
+ /**
+ * Read a 32-bit floating number and move pointer forward by 4 bytes.
+ */
+ readFloat32() {
+ const E = this._data.getFloat32(this.offset, this.littleEndian);
+ return this.offset += 4, E;
+ }
+ /**
+ * Read a 64-bit floating number and move pointer forward by 8 bytes.
+ */
+ readFloat64() {
+ const E = this._data.getFloat64(this.offset, this.littleEndian);
+ return this.offset += 8, E;
+ }
+ /**
+ * Read a 64-bit signed integer number and move pointer forward by 8 bytes.
+ */
+ readBigInt64() {
+ const E = this._data.getBigInt64(this.offset, this.littleEndian);
+ return this.offset += 8, E;
+ }
+ /**
+ * Read a 64-bit unsigned integer number and move pointer forward by 8 bytes.
+ */
+ readBigUint64() {
+ const E = this._data.getBigUint64(this.offset, this.littleEndian);
+ return this.offset += 8, E;
+ }
+ /**
+ * Read a 1-byte ASCII character and move pointer forward by 1 byte.
+ */
+ readChar() {
+ return String.fromCharCode(this.readInt8());
+ }
+ /**
+ * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
+ */
+ readChars(E = 1) {
+ let c = "";
+ for (let C = 0; C < E; C++)
+ c += this.readChar();
+ return c;
+ }
+ /**
+ * Read the next `n` bytes, return a UTF-8 decoded string and move pointer
+ * forward by `n` bytes.
+ */
+ readUtf8(E = 1) {
+ return (0, s.decode)(this.readBytes(E));
+ }
+ /**
+ * Read the next `n` bytes, return a string decoded with `encoding` and move pointer
+ * forward by `n` bytes.
+ * If no encoding is passed, the function is equivalent to @see {@link IOBuffer#readUtf8}
+ */
+ decodeText(E = 1, c = "utf-8") {
+ return (0, s.decode)(this.readBytes(E), c);
+ }
+ /**
+ * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
+ * forward by 1 byte.
+ */
+ writeBoolean(E) {
+ return this.writeUint8(E ? 255 : 0), this;
+ }
+ /**
+ * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
+ */
+ writeInt8(E) {
+ return this.ensureAvailable(1), this._data.setInt8(this.offset++, E), this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as an 8-bit unsigned integer and move pointer forward by 1
+ * byte.
+ */
+ writeUint8(E) {
+ return this.ensureAvailable(1), this._data.setUint8(this.offset++, E), this._updateLastWrittenByte(), this;
+ }
+ /**
+ * An alias for {@link IOBuffer#writeUint8}.
+ */
+ writeByte(E) {
+ return this.writeUint8(E);
+ }
+ /**
+ * Write all elements of `bytes` as uint8 values and move pointer forward by
+ * `bytes.length` bytes.
+ */
+ writeBytes(E) {
+ this.ensureAvailable(E.length);
+ for (let c = 0; c < E.length; c++)
+ this._data.setUint8(this.offset++, E[c]);
+ return this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as a 16-bit signed integer and move pointer forward by 2
+ * bytes.
+ */
+ writeInt16(E) {
+ return this.ensureAvailable(2), this._data.setInt16(this.offset, E, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as a 16-bit unsigned integer and move pointer forward by 2
+ * bytes.
+ */
+ writeUint16(E) {
+ return this.ensureAvailable(2), this._data.setUint16(this.offset, E, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as a 32-bit signed integer and move pointer forward by 4
+ * bytes.
+ */
+ writeInt32(E) {
+ return this.ensureAvailable(4), this._data.setInt32(this.offset, E, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as a 32-bit unsigned integer and move pointer forward by 4
+ * bytes.
+ */
+ writeUint32(E) {
+ return this.ensureAvailable(4), this._data.setUint32(this.offset, E, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as a 32-bit floating number and move pointer forward by 4
+ * bytes.
+ */
+ writeFloat32(E) {
+ return this.ensureAvailable(4), this._data.setFloat32(this.offset, E, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as a 64-bit floating number and move pointer forward by 8
+ * bytes.
+ */
+ writeFloat64(E) {
+ return this.ensureAvailable(8), this._data.setFloat64(this.offset, E, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as a 64-bit signed bigint and move pointer forward by 8
+ * bytes.
+ */
+ writeBigInt64(E) {
+ return this.ensureAvailable(8), this._data.setBigInt64(this.offset, E, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write `value` as a 64-bit unsigned bigint and move pointer forward by 8
+ * bytes.
+ */
+ writeBigUint64(E) {
+ return this.ensureAvailable(8), this._data.setBigUint64(this.offset, E, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this;
+ }
+ /**
+ * Write the charCode of `str`'s first character as an 8-bit unsigned integer
+ * and move pointer forward by 1 byte.
+ */
+ writeChar(E) {
+ return this.writeUint8(E.charCodeAt(0));
+ }
+ /**
+ * Write the charCodes of all `str`'s characters as 8-bit unsigned integers
+ * and move pointer forward by `str.length` bytes.
+ */
+ writeChars(E) {
+ for (let c = 0; c < E.length; c++)
+ this.writeUint8(E.charCodeAt(c));
+ return this;
+ }
+ /**
+ * UTF-8 encode and write `str` to the current pointer offset and move pointer
+ * forward according to the encoded length.
+ */
+ writeUtf8(E) {
+ return this.writeBytes((0, s.encode)(E));
+ }
+ /**
+ * Export a Uint8Array view of the internal buffer.
+ * The view starts at the byte offset and its length
+ * is calculated to stop at the last written byte or the original length.
+ */
+ toArray() {
+ return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
+ }
+ /**
+ * Update the last written byte offset
+ * @private
+ */
+ _updateLastWrittenByte() {
+ this.offset > this.lastWrittenByte && (this.lastWrittenByte = this.offset);
+ }
+ }
+ }
+ ),
+ /***/
+ "./node_modules/iobuffer/lib-esm/text-encoding-polyfill.js": (
+ /*!*****************************************************************!*\
+ !*** ./node_modules/iobuffer/lib-esm/text-encoding-polyfill.js ***!
+ \*****************************************************************/
+ /***/
+ function() {
+ (function(r) {
+ if (r.TextEncoder && r.TextDecoder)
+ return !1;
+ function e(s = "utf-8") {
+ if (s !== "utf-8")
+ throw new RangeError(`Failed to construct 'TextEncoder': The encoding label provided ('${s}') is invalid.`);
+ }
+ Object.defineProperty(e.prototype, "encoding", {
+ value: "utf-8"
+ }), e.prototype.encode = function(s, f = { stream: !1 }) {
+ if (f.stream)
+ throw new Error("Failed to encode: the 'stream' option is unsupported.");
+ let _ = 0;
+ const x = s.length;
+ let h = 0, u = Math.max(32, x + (x >> 1) + 7), E = new Uint8Array(u >> 3 << 3);
+ for (; _ < x; ) {
+ let c = s.charCodeAt(_++);
+ if (c >= 55296 && c <= 56319) {
+ if (_ < x) {
+ const C = s.charCodeAt(_);
+ (C & 64512) === 56320 && (++_, c = ((c & 1023) << 10) + (C & 1023) + 65536);
+ }
+ if (c >= 55296 && c <= 56319)
+ continue;
+ }
+ if (h + 4 > E.length) {
+ u += 8, u *= 1 + _ / s.length * 2, u = u >> 3 << 3;
+ const C = new Uint8Array(u);
+ C.set(E), E = C;
+ }
+ if (c & 4294967168)
+ if (!(c & 4294965248))
+ E[h++] = c >> 6 & 31 | 192;
+ else if (!(c & 4294901760))
+ E[h++] = c >> 12 & 15 | 224, E[h++] = c >> 6 & 63 | 128;
+ else if (!(c & 4292870144))
+ E[h++] = c >> 18 & 7 | 240, E[h++] = c >> 12 & 63 | 128, E[h++] = c >> 6 & 63 | 128;
+ else
+ continue;
+ else {
+ E[h++] = c;
+ continue;
+ }
+ E[h++] = c & 63 | 128;
+ }
+ return E.slice(0, h);
+ };
+ function t(s = "utf-8", f = { fatal: !1 }) {
+ if (s !== "utf-8")
+ throw new RangeError(`Failed to construct 'TextDecoder': The encoding label provided ('${s}') is invalid.`);
+ if (f.fatal)
+ throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");
+ }
+ Object.defineProperty(t.prototype, "encoding", {
+ value: "utf-8"
+ }), Object.defineProperty(t.prototype, "fatal", { value: !1 }), Object.defineProperty(t.prototype, "ignoreBOM", {
+ value: !1
+ }), t.prototype.decode = function(s, f = { stream: !1 }) {
+ if (f.stream)
+ throw new Error("Failed to decode: the 'stream' option is unsupported.");
+ const _ = new Uint8Array(s);
+ let x = 0;
+ const h = _.length, u = [];
+ for (; x < h; ) {
+ const E = _[x++];
+ if (E === 0)
+ break;
+ if (!(E & 128))
+ u.push(E);
+ else if ((E & 224) === 192) {
+ const c = _[x++] & 63;
+ u.push((E & 31) << 6 | c);
+ } else if ((E & 240) === 224) {
+ const c = _[x++] & 63, C = _[x++] & 63;
+ u.push((E & 31) << 12 | c << 6 | C);
+ } else if ((E & 248) === 240) {
+ const c = _[x++] & 63, C = _[x++] & 63, b = _[x++] & 63;
+ let A = (E & 7) << 18 | c << 12 | C << 6 | b;
+ A > 65535 && (A -= 65536, u.push(A >>> 10 & 1023 | 55296), A = 56320 | A & 1023), u.push(A);
+ }
+ }
+ return String.fromCharCode.apply(null, u);
+ }, r.TextEncoder = e, r.TextDecoder = t;
+ })(typeof window < "u" ? window : typeof self < "u" ? self : this);
+ }
+ ),
+ /***/
+ "./node_modules/iobuffer/lib-esm/text.browser.js": (
+ /*!*******************************************************!*\
+ !*** ./node_modules/iobuffer/lib-esm/text.browser.js ***!
+ \*******************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ decode: () => (
+ /* binding */
+ s
+ ),
+ /* harmony export */
+ encode: () => (
+ /* binding */
+ _
+ )
+ /* harmony export */
+ }), t(
+ /*! ./text-encoding-polyfill */
+ "./node_modules/iobuffer/lib-esm/text-encoding-polyfill.js"
+ );
+ function s(x, h = "utf8") {
+ return new TextDecoder(h).decode(x);
+ }
+ const f = new TextEncoder();
+ function _(x) {
+ return f.encode(x);
+ }
+ }
+ ),
+ /***/
+ "./node_modules/netcdfjs/lib-esm/data.js": (
+ /*!***********************************************!*\
+ !*** ./node_modules/netcdfjs/lib-esm/data.js ***!
+ \***********************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ nonRecord: () => (
+ /* binding */
+ f
+ ),
+ /* harmony export */
+ record: () => (
+ /* binding */
+ _
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! ./types */
+ "./node_modules/netcdfjs/lib-esm/types.js"
+ );
+ function f(x, h) {
+ const u = (0, s.str2num)(h.type), E = h.size / (0, s.num2bytes)(u), c = new Array(E);
+ for (let C = 0; C < E; C++)
+ c[C] = (0, s.readType)(x, u, 1);
+ return c;
+ }
+ function _(x, h, u) {
+ const E = (0, s.str2num)(h.type), c = h.size ? h.size / (0, s.num2bytes)(E) : 1, C = u.length, b = new Array(C), A = u.recordStep;
+ if (A)
+ for (let S = 0; S < C; S++) {
+ const n = x.offset;
+ b[S] = (0, s.readType)(x, E, c), x.seek(n + A);
+ }
+ else
+ throw new Error("recordDimension.recordStep is undefined");
+ return b;
+ }
+ }
+ ),
+ /***/
+ "./node_modules/netcdfjs/lib-esm/header.js": (
+ /*!*************************************************!*\
+ !*** ./node_modules/netcdfjs/lib-esm/header.js ***!
+ \*************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ header: () => (
+ /* binding */
+ c
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! ./types */
+ "./node_modules/netcdfjs/lib-esm/types.js"
+ ), f = t(
+ /*! ./utils */
+ "./node_modules/netcdfjs/lib-esm/utils.js"
+ );
+ const _ = 0, x = 10, h = 11, u = 12, E = 0;
+ function c(S, n) {
+ const o = { version: n }, w = {
+ length: S.readUint32()
+ }, p = C(S);
+ Array.isArray(p) || (w.id = p.recordId, w.name = p.recordName, o.dimensions = p.dimensions), o.globalAttributes = b(S);
+ const v = A(S, w == null ? void 0 : w.id, n);
+ return Array.isArray(v) || (o.variables = v.variables, w.recordStep = v.recordStep), o.recordDimension = w, o;
+ }
+ function C(S) {
+ const n = {};
+ let o, w;
+ const p = S.readUint32();
+ let v;
+ if (p === _)
+ return (0, f.notNetcdf)(S.readUint32() !== _, "wrong empty tag for list of dimensions"), [];
+ {
+ (0, f.notNetcdf)(p !== x, "wrong tag for list of dimensions");
+ const a = S.readUint32();
+ v = new Array(a);
+ for (let l = 0; l < a; l++) {
+ const g = (0, f.readName)(S), M = S.readUint32();
+ M === E && (o = l, w = g), v[l] = {
+ name: g,
+ size: M
+ };
+ }
+ }
+ return o !== void 0 && (n.recordId = o), w !== void 0 && (n.recordName = w), n.dimensions = v, n;
+ }
+ function b(S) {
+ const n = S.readUint32();
+ let o;
+ if (n === _)
+ return (0, f.notNetcdf)(S.readUint32() !== _, "wrong empty tag for list of attributes"), [];
+ {
+ (0, f.notNetcdf)(n !== u, "wrong tag for list of attributes");
+ const w = S.readUint32();
+ o = new Array(w);
+ for (let p = 0; p < w; p++) {
+ const v = (0, f.readName)(S), a = S.readUint32();
+ (0, f.notNetcdf)(a < 1 || a > 6, `non valid type ${a}`);
+ const l = S.readUint32(), g = (0, s.readType)(S, a, l);
+ (0, f.padding)(S), o[p] = {
+ name: v,
+ type: (0, s.num2str)(a),
+ value: g
+ };
+ }
+ }
+ return o;
+ }
+ function A(S, n, o) {
+ const w = S.readUint32();
+ let p = 0, v;
+ if (w === _)
+ return (0, f.notNetcdf)(S.readUint32() !== _, "wrong empty tag for list of variables"), [];
+ {
+ (0, f.notNetcdf)(w !== h, "wrong tag for list of variables");
+ const a = S.readUint32();
+ v = new Array(a);
+ for (let l = 0; l < a; l++) {
+ const g = (0, f.readName)(S), M = S.readUint32(), L = new Array(M);
+ for (let z = 0; z < M; z++)
+ L[z] = S.readUint32();
+ const T = b(S), D = S.readUint32();
+ (0, f.notNetcdf)(D < 1 && D > 6, `non valid type ${D}`);
+ const R = S.readUint32();
+ let B = S.readUint32();
+ o === 2 && ((0, f.notNetcdf)(B > 0, "offsets larger than 4GB not supported"), B = S.readUint32());
+ let P = !1;
+ typeof n < "u" && L[0] === n && (p += R, P = !0), v[l] = {
+ name: g,
+ dimensions: L,
+ attributes: T,
+ type: (0, s.num2str)(D),
+ size: R,
+ offset: B,
+ record: P
+ };
+ }
+ }
+ return {
+ variables: v,
+ recordStep: p
+ };
+ }
+ }
+ ),
+ /***/
+ "./node_modules/netcdfjs/lib-esm/index.js": (
+ /*!************************************************!*\
+ !*** ./node_modules/netcdfjs/lib-esm/index.js ***!
+ \************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ NetCDFReader: () => (
+ /* reexport safe */
+ s.NetCDFReader
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! ./parser */
+ "./node_modules/netcdfjs/lib-esm/parser.js"
+ );
+ }
+ ),
+ /***/
+ "./node_modules/netcdfjs/lib-esm/parser.js": (
+ /*!*************************************************!*\
+ !*** ./node_modules/netcdfjs/lib-esm/parser.js ***!
+ \*************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ NetCDFReader: () => (
+ /* binding */
+ u
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! iobuffer */
+ "./node_modules/iobuffer/lib-esm/IOBuffer.js"
+ ), f = t(
+ /*! ./data */
+ "./node_modules/netcdfjs/lib-esm/data.js"
+ ), _ = t(
+ /*! ./header */
+ "./node_modules/netcdfjs/lib-esm/header.js"
+ ), x = t(
+ /*! ./toString */
+ "./node_modules/netcdfjs/lib-esm/toString.js"
+ ), h = t(
+ /*! ./utils */
+ "./node_modules/netcdfjs/lib-esm/utils.js"
+ );
+ class u {
+ constructor(c) {
+ this.toString = x.toString;
+ const C = new s.IOBuffer(c);
+ C.setBigEndian(), (0, h.notNetcdf)(C.readChars(3) !== "CDF", "should start with CDF");
+ const b = C.readByte();
+ (0, h.notNetcdf)(b > 2, "unknown version"), this.header = (0, _.header)(C, b), this.buffer = C;
+ }
+ /**
+ * @return - Version for the NetCDF format
+ */
+ get version() {
+ return this.header.version === 1 ? "classic format" : "64-bit offset format";
+ }
+ /**
+ * @return {object} - Metadata for the record dimension
+ * * `length`: Number of elements in the record dimension
+ * * `id`: Id number in the list of dimensions for the record dimension
+ * * `name`: String with the name of the record dimension
+ * * `recordStep`: Number with the record variables step size
+ */
+ get recordDimension() {
+ return this.header.recordDimension;
+ }
+ /**
+ * @return - Array - List of dimensions with:
+ * * `name`: String with the name of the dimension
+ * * `size`: Number with the size of the dimension
+ */
+ get dimensions() {
+ return this.header.dimensions;
+ }
+ /**
+ * @return - Array - List of global attributes with:
+ * * `name`: String with the name of the attribute
+ * * `type`: String with the type of the attribute
+ * * `value`: A number or string with the value of the attribute
+ */
+ get globalAttributes() {
+ return this.header.globalAttributes;
+ }
+ /**
+ * Returns the value of an attribute
+ * @param - AttributeName
+ * @return - Value of the attributeName or null
+ */
+ getAttribute(c) {
+ const C = this.globalAttributes.find((b) => b.name === c);
+ return C ? C.value : null;
+ }
+ /**
+ * Returns the value of a variable as a string
+ * @param - variableName
+ * @return - Value of the variable as a string or null
+ */
+ getDataVariableAsString(c) {
+ const C = this.getDataVariable(c);
+ return C ? C.join("") : null;
+ }
+ get variables() {
+ return this.header.variables;
+ }
+ /**
+ * Retrieves the data for a given variable
+ * @param variableName - Name of the variable to search or variable object
+ * @return The variable values
+ */
+ getDataVariable(c) {
+ let C;
+ if (typeof c == "string" ? C = this.header.variables.find((b) => b.name === c) : C = c, C === void 0)
+ throw new Error("Not a valid NetCDF v3.x file: variable not found");
+ return this.buffer.seek(C.offset), C.record ? (0, f.record)(this.buffer, C, this.header.recordDimension) : (0, f.nonRecord)(this.buffer, C);
+ }
+ /**
+ * Check if a dataVariable exists
+ * @param variableName - Name of the variable to find
+ * @return boolean
+ */
+ dataVariableExists(c) {
+ return this.header.variables.find((b) => b.name === c) !== void 0;
+ }
+ /**
+ * Check if an attribute exists
+ * @param attributeName - Name of the attribute to find
+ * @return boolean
+ */
+ attributeExists(c) {
+ return this.globalAttributes.find((b) => b.name === c) !== void 0;
+ }
+ }
+ }
+ ),
+ /***/
+ "./node_modules/netcdfjs/lib-esm/toString.js": (
+ /*!***************************************************!*\
+ !*** ./node_modules/netcdfjs/lib-esm/toString.js ***!
+ \***************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ toString: () => (
+ /* binding */
+ s
+ )
+ /* harmony export */
+ });
+ function s() {
+ const f = [];
+ f.push("DIMENSIONS");
+ for (const x of this.dimensions)
+ f.push(` ${x.name.padEnd(30)} = size: ${x.size}`);
+ f.push(""), f.push("GLOBAL ATTRIBUTES");
+ for (const x of this.globalAttributes)
+ f.push(` ${x.name.padEnd(30)} = ${x.value}`);
+ const _ = JSON.parse(JSON.stringify(this.variables));
+ f.push(""), f.push("VARIABLES:");
+ for (const x of _) {
+ x.value = this.getDataVariable(x);
+ let h = JSON.stringify(x.value);
+ h.length > 50 && (h = h.substring(0, 50)), isNaN(x.value.length) || (h += ` (length: ${x.value.length})`), f.push(` ${x.name.padEnd(30)} = ${h}`);
+ }
+ return f.join(`
+`);
+ }
+ }
+ ),
+ /***/
+ "./node_modules/netcdfjs/lib-esm/types.js": (
+ /*!************************************************!*\
+ !*** ./node_modules/netcdfjs/lib-esm/types.js ***!
+ \************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ num2bytes: () => (
+ /* binding */
+ _
+ ),
+ /* harmony export */
+ num2str: () => (
+ /* binding */
+ f
+ ),
+ /* harmony export */
+ readType: () => (
+ /* binding */
+ u
+ ),
+ /* harmony export */
+ str2num: () => (
+ /* binding */
+ x
+ )
+ /* harmony export */
+ });
+ const s = {
+ BYTE: 1,
+ CHAR: 2,
+ SHORT: 3,
+ INT: 4,
+ FLOAT: 5,
+ DOUBLE: 6
+ };
+ function f(c) {
+ switch (Number(c)) {
+ case s.BYTE:
+ return "byte";
+ case s.CHAR:
+ return "char";
+ case s.SHORT:
+ return "short";
+ case s.INT:
+ return "int";
+ case s.FLOAT:
+ return "float";
+ case s.DOUBLE:
+ return "double";
+ default:
+ return "undefined";
+ }
+ }
+ function _(c) {
+ switch (Number(c)) {
+ case s.BYTE:
+ return 1;
+ case s.CHAR:
+ return 1;
+ case s.SHORT:
+ return 2;
+ case s.INT:
+ return 4;
+ case s.FLOAT:
+ return 4;
+ case s.DOUBLE:
+ return 8;
+ default:
+ return -1;
+ }
+ }
+ function x(c) {
+ switch (String(c)) {
+ case "byte":
+ return s.BYTE;
+ case "char":
+ return s.CHAR;
+ case "short":
+ return s.SHORT;
+ case "int":
+ return s.INT;
+ case "float":
+ return s.FLOAT;
+ case "double":
+ return s.DOUBLE;
+ default:
+ return -1;
+ }
+ }
+ function h(c, C) {
+ if (c !== 1) {
+ const b = new Array(c);
+ for (let A = 0; A < c; A++)
+ b[A] = C();
+ return b;
+ } else
+ return C();
+ }
+ function u(c, C, b) {
+ switch (C) {
+ case s.BYTE:
+ return Array.from(c.readBytes(b));
+ case s.CHAR:
+ return E(c.readChars(b));
+ case s.SHORT:
+ return h(b, c.readInt16.bind(c));
+ case s.INT:
+ return h(b, c.readInt32.bind(c));
+ case s.FLOAT:
+ return h(b, c.readFloat32.bind(c));
+ case s.DOUBLE:
+ return h(b, c.readFloat64.bind(c));
+ default:
+ throw new Error(`non valid type ${C}`);
+ }
+ }
+ function E(c) {
+ return c.charCodeAt(c.length - 1) === 0 ? c.substring(0, c.length - 1) : c;
+ }
+ }
+ ),
+ /***/
+ "./node_modules/netcdfjs/lib-esm/utils.js": (
+ /*!************************************************!*\
+ !*** ./node_modules/netcdfjs/lib-esm/utils.js ***!
+ \************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ notNetcdf: () => (
+ /* binding */
+ s
+ ),
+ /* harmony export */
+ padding: () => (
+ /* binding */
+ f
+ ),
+ /* harmony export */
+ readName: () => (
+ /* binding */
+ _
+ )
+ /* harmony export */
+ });
+ function s(x, h) {
+ if (x)
+ throw new TypeError(`Not a valid NetCDF v3.x file: ${h}`);
+ }
+ function f(x) {
+ x.offset % 4 !== 0 && x.skip(4 - x.offset % 4);
+ }
+ function _(x) {
+ const h = x.readUint32(), u = x.readChars(h);
+ return f(x), u;
+ }
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/basic/basic.frag": (
+ /*!************************************************!*\
+ !*** ./src/WebGL/shaders/lib/basic/basic.frag ***!
+ \************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform mat4 viewMatrix;
+uniform float opacity;
+uniform vec3 fogColor;
+uniform float fogNear;
+uniform float fogFar;
+varying vec3 vColor;
+//DEFINEFRAGCOLOR
+void main() {
+ gl_FragColor = vec4( vColor, opacity );
+ float depth = gl_FragCoord.z / gl_FragCoord.w;
+ float fogFactor = smoothstep( fogNear, fogFar, depth );
+ gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
+}`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/basic/basic.vert": (
+ /*!************************************************!*\
+ !*** ./src/WebGL/shaders/lib/basic/basic.vert ***!
+ \************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform mat4 viewMatrix;
+uniform mat3 normalMatrix;
+
+attribute vec3 position;
+attribute vec3 color;
+
+varying vec3 vColor;
+
+void main() {
+
+ vColor = color;
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+ gl_Position = projectionMatrix * mvPosition;
+
+}`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/instanced/instanced.frag": (
+ /*!********************************************************!*\
+ !*** ./src/WebGL/shaders/lib/instanced/instanced.frag ***!
+ \********************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform mat4 viewMatrix;
+uniform float opacity;
+
+uniform vec3 fogColor;
+uniform float fogNear;
+uniform float fogFar;
+
+varying vec3 vLightFront;
+varying vec3 vColor;
+//DEFINEFRAGCOLOR
+
+void main() {
+
+ gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
+
+ #ifndef WIREFRAME
+ gl_FragColor.xyz *= vLightFront;
+ #endif
+
+ gl_FragColor = gl_FragColor * vec4( vColor, opacity );
+ float depth = gl_FragCoord.z / gl_FragCoord.w;
+
+ float fogFactor = smoothstep( fogNear, fogFar, depth );
+
+ gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
+
+}
+
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/instanced/instanced.vert": (
+ /*!********************************************************!*\
+ !*** ./src/WebGL/shaders/lib/instanced/instanced.vert ***!
+ \********************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform mat4 viewMatrix;
+uniform mat3 normalMatrix;
+uniform vec3 directionalLightColor[ 1 ];
+uniform vec3 directionalLightDirection[ 1 ];
+
+attribute vec3 offset;
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec3 color;
+attribute float radius;
+
+varying vec3 vColor;
+varying vec3 vLightFront;
+
+void main() {
+
+ vColor = color;
+
+ vec3 objectNormal = normal;
+ vec3 transformedNormal = normalMatrix * objectNormal;
+ vec4 mvPosition = modelViewMatrix * vec4( position * radius + offset, 1.0 );
+
+ vLightFront = vec3( 0.0 );
+
+ transformedNormal = normalize( transformedNormal );
+
+ vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
+ vec3 dirVector = normalize( lDirection.xyz );
+ float dotProduct = dot( transformedNormal, dirVector );
+ vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
+
+ vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;
+
+ gl_Position = projectionMatrix * mvPosition;
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/lambert/lambert.frag": (
+ /*!****************************************************!*\
+ !*** ./src/WebGL/shaders/lib/lambert/lambert.frag ***!
+ \****************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform mat4 viewMatrix;
+uniform float opacity;
+
+uniform vec3 fogColor;
+uniform float fogNear;
+uniform float fogFar;
+
+varying vec3 vLightFront;
+varying vec3 vColor;
+//DEFINEFRAGCOLOR
+
+void main() {
+
+ gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
+
+ #ifndef WIREFRAME
+ gl_FragColor.xyz *= vLightFront;
+ #endif
+
+ gl_FragColor = gl_FragColor * vec4( vColor, opacity );
+ float depth = gl_FragCoord.z / gl_FragCoord.w;
+
+ float fogFactor = smoothstep( fogNear, fogFar, depth );
+
+ gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
+
+}`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/lambert/lambert.vert": (
+ /*!****************************************************!*\
+ !*** ./src/WebGL/shaders/lib/lambert/lambert.vert ***!
+ \****************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform mat4 viewMatrix;
+uniform mat3 normalMatrix;
+uniform vec3 directionalLightColor[ 1 ];
+uniform vec3 directionalLightDirection[ 1 ];
+
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec3 color;
+
+varying vec3 vColor;
+varying vec3 vLightFront;
+
+void main() {
+
+ vColor = color;
+
+ vec3 objectNormal = normal;
+ vec3 transformedNormal = normalMatrix * objectNormal;
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+
+ vLightFront = vec3( 0.0 );
+
+ transformedNormal = normalize( transformedNormal );
+
+ vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
+ vec3 dirVector = normalize( lDirection.xyz );
+ float dotProduct = dot( transformedNormal, dirVector );
+ vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
+
+ vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;
+
+ gl_Position = projectionMatrix * mvPosition;
+}`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/lambertdouble/lambertdouble.frag": (
+ /*!****************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/lambertdouble/lambertdouble.frag ***!
+ \****************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform mat4 viewMatrix;
+uniform float opacity;
+
+uniform vec3 fogColor;
+uniform float fogNear;
+uniform float fogFar;
+
+varying vec3 vLightFront;
+varying vec3 vLightBack;
+
+varying vec3 vColor;
+//DEFINEFRAGCOLOR
+
+void main() {
+
+ gl_FragColor = vec4( vec3 ( 1.0 ), opacity );
+
+ #ifndef WIREFRAME
+ if ( gl_FrontFacing )
+ gl_FragColor.xyz *= vLightFront;
+ else
+ gl_FragColor.xyz *= vLightBack;
+ #endif
+
+ gl_FragColor = gl_FragColor * vec4( vColor, opacity );
+ float depth = gl_FragCoord.z / gl_FragCoord.w;
+
+ float fogFactor = smoothstep( fogNear, fogFar, depth );
+
+ gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
+
+}
+
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/lambertdouble/lambertdouble.vert": (
+ /*!****************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/lambertdouble/lambertdouble.vert ***!
+ \****************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform mat4 viewMatrix;
+uniform mat3 normalMatrix;
+uniform vec3 directionalLightColor[ 1 ];
+uniform vec3 directionalLightDirection[ 1 ];
+
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec3 color;
+
+varying vec3 vColor;
+varying vec3 vLightFront;
+varying vec3 vLightBack;
+
+void main() {
+
+ vColor = color;
+
+ vec3 objectNormal = normal;
+ vec3 transformedNormal = normalMatrix * objectNormal;
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+
+ vLightFront = vec3( 0.0 );
+ vLightBack = vec3( 0.0 );
+
+ transformedNormal = normalize( transformedNormal );
+
+ vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
+ vec3 dirVector = normalize( lDirection.xyz );
+ float dotProduct = dot( transformedNormal, dirVector );
+ vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
+ vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );
+
+ vLightFront += directionalLightColor[ 0 ] * directionalLightWeighting;
+ vLightBack += directionalLightColor[ 0 ] * directionalLightWeightingBack;
+
+ gl_Position = projectionMatrix * mvPosition;
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/outline/outline.frag": (
+ /*!****************************************************!*\
+ !*** ./src/WebGL/shaders/lib/outline/outline.frag ***!
+ \****************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform float opacity;
+uniform vec3 outlineColor;
+uniform vec3 fogColor;
+uniform float fogNear;
+uniform float fogFar;
+//DEFINEFRAGCOLOR
+
+void main() {
+ gl_FragColor = vec4( outlineColor, 1 );
+}
+
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/outline/outline.vert": (
+ /*!****************************************************!*\
+ !*** ./src/WebGL/shaders/lib/outline/outline.vert ***!
+ \****************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform float outlineWidth;
+uniform float outlinePushback;
+
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec3 color;
+
+void main() {
+
+ vec4 norm = modelViewMatrix*vec4(normalize(normal),0.0);
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+ mvPosition.xy += norm.xy*outlineWidth;
+ gl_Position = projectionMatrix * mvPosition;
+ mvPosition.z -= outlinePushback; //go backwards in model space
+ vec4 pushpos = projectionMatrix*mvPosition; //project to get z in projection space, I'm probably missing some simple math to do the same thing..
+ gl_Position.z = gl_Position.w*pushpos.z/pushpos.w;
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/screen/screen.frag": (
+ /*!**************************************************!*\
+ !*** ./src/WebGL/shaders/lib/screen/screen.frag ***!
+ \**************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform sampler2D colormap;
+varying highp vec2 vTexCoords;
+uniform vec2 dimensions;
+//DEFINEFRAGCOLOR
+void main (void) {
+ gl_FragColor = texture2D(colormap, vTexCoords);
+}
+ `;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/screen/screen.vert": (
+ /*!**************************************************!*\
+ !*** ./src/WebGL/shaders/lib/screen/screen.vert ***!
+ \**************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `attribute vec2 vertexPosition;
+varying highp vec2 vTexCoords;
+const vec2 scale = vec2(0.5, 0.5);
+
+void main() {
+ vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range
+ gl_Position = vec4(vertexPosition, 0.0, 1.0);
+}
+ `;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/screenaa/screenaa.frag": (
+ /*!******************************************************!*\
+ !*** ./src/WebGL/shaders/lib/screenaa/screenaa.frag ***!
+ \******************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform sampler2D colormap;
+varying highp vec2 vTexCoords;
+uniform vec2 dimensions;
+
+// Basic FXAA implementation based on the code on geeks3d.com
+#define FXAA_REDUCE_MIN (1.0/ 128.0)
+#define FXAA_REDUCE_MUL (1.0 / 8.0)
+#define FXAA_SPAN_MAX 8.0
+
+vec4 applyFXAA(vec2 fragCoord, sampler2D tex)
+{
+ vec4 color;
+ vec2 inverseVP = vec2(1.0 / dimensions.x, 1.0 / dimensions.y);
+ vec3 rgbNW = texture2D(tex, fragCoord + vec2(-1.0, -1.0) * inverseVP).xyz;
+ vec3 rgbNE = texture2D(tex, fragCoord + vec2(1.0, -1.0) * inverseVP).xyz;
+ vec3 rgbSW = texture2D(tex, fragCoord + vec2(-1.0, 1.0) * inverseVP).xyz;
+ vec3 rgbSE = texture2D(tex, fragCoord + vec2(1.0, 1.0) * inverseVP).xyz;
+ vec3 rgbM = texture2D(tex, fragCoord * inverseVP).xyz;
+ vec3 luma = vec3(0.299, 0.587, 0.114);
+ float lumaNW = dot(rgbNW, luma);
+ float lumaNE = dot(rgbNE, luma);
+ float lumaSW = dot(rgbSW, luma);
+ float lumaSE = dot(rgbSE, luma);
+ float lumaM = dot(rgbM, luma);
+ float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
+ float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
+
+ vec2 dir;
+ dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
+ dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
+
+ float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
+ (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
+
+ float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
+ dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
+ max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
+ dir * rcpDirMin)) * inverseVP;
+
+ vec3 rgbA = 0.5 * (
+ texture2D(tex, fragCoord + dir * (1.0 / 3.0 - 0.5)).xyz +
+ texture2D(tex, fragCoord + dir * (2.0 / 3.0 - 0.5)).xyz);
+ vec3 rgbB = rgbA * 0.5 + 0.25 * (
+ texture2D(tex, fragCoord + dir * -0.5).xyz +
+ texture2D(tex, fragCoord + dir * 0.5).xyz);
+
+ float lumaB = dot(rgbB, luma);
+ if ((lumaB < lumaMin) || (lumaB > lumaMax))
+ color = vec4(rgbA, 1.0);
+ else
+ color = vec4(rgbB, 1.0);
+ return color;
+}
+//DEFINEFRAGCOLOR
+void main (void) {
+ gl_FragColor = applyFXAA(vTexCoords, colormap);
+}
+ `;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/screenaa/screenaa.vert": (
+ /*!******************************************************!*\
+ !*** ./src/WebGL/shaders/lib/screenaa/screenaa.vert ***!
+ \******************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `attribute vec2 vertexPosition;
+varying highp vec2 vTexCoords;
+const vec2 scale = vec2(0.5, 0.5);
+
+void main() {
+ vTexCoords = vertexPosition * scale + scale; // scale vertex attribute to [0,1] range
+ gl_Position = vec4(vertexPosition, 0.0, 1.0);
+}
+ `;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/sphereimposter/sphereimposter.frag": (
+ /*!******************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/sphereimposter/sphereimposter.frag ***!
+ \******************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+uniform mat4 viewMatrix;
+uniform float opacity;
+uniform mat4 projectionMatrix;
+
+uniform vec3 fogColor;
+uniform float fogNear;
+uniform float fogFar;
+uniform float uDepth;
+uniform vec3 directionalLightColor[ 1 ];
+
+varying vec3 vColor;
+varying vec2 mapping;
+varying float rval;
+varying vec3 vLight;
+varying vec3 center;
+
+//DEFINEFRAGCOLOR
+
+void main() {
+ float lensqr = dot(mapping,mapping);
+ float rsqr = rval*rval;
+ if(lensqr > rsqr)
+ discard;
+ float z = sqrt(rsqr-lensqr);
+ vec3 cameraPos = center+ vec3(mapping.x,mapping.y,z);
+ vec4 clipPos = projectionMatrix * vec4(cameraPos, 1.0);
+ float ndcDepth = clipPos.z / clipPos.w;
+ gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
+ vec3 norm = normalize(vec3(mapping.x,mapping.y,z));
+ float dotProduct = dot( norm, vLight );
+ vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
+ vec3 vLight = directionalLightColor[ 0 ] * directionalLightWeighting;
+ gl_FragColor = vec4(vLight*vColor, opacity*opacity );
+ float fogFactor = smoothstep( fogNear, fogFar, gl_FragDepthEXT/gl_FragCoord.w );
+ gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
+
+
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/sphereimposter/sphereimposter.vert": (
+ /*!******************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/sphereimposter/sphereimposter.vert ***!
+ \******************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform mat4 viewMatrix;
+uniform mat3 normalMatrix;
+uniform vec3 directionalLightColor[ 1 ];
+uniform vec3 directionalLightDirection[ 1 ];
+
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec3 color;
+
+varying vec2 mapping;
+varying vec3 vColor;
+varying float rval;
+varying vec3 vLight;
+varying vec3 center;
+
+void main() {
+
+ vColor = color;
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+ center = mvPosition.xyz;
+ vec4 projPosition = projectionMatrix * mvPosition;
+ vec4 adjust = projectionMatrix* vec4(normal,0.0); adjust.z = 0.0; adjust.w = 0.0;
+ vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
+ vLight = normalize( lDirection.xyz );
+ mapping = normal.xy;
+ rval = abs(normal.x);
+ gl_Position = projPosition+adjust;
+
+}
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.frag": (
+ /*!********************************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.frag ***!
+ \********************************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform float opacity;
+uniform vec3 outlineColor;
+uniform vec3 fogColor;
+uniform float fogNear;
+uniform float fogFar;
+uniform mat4 projectionMatrix;
+varying vec2 mapping;
+varying float rval;
+varying vec3 center;
+
+uniform float outlinePushback;
+
+//DEFINEFRAGCOLOR
+
+void main() {
+ float lensqr = dot(mapping,mapping);
+ float rsqr = rval*rval;
+ if(lensqr > rsqr)
+ discard;
+ float z = sqrt(rsqr-lensqr);
+ vec3 cameraPos = center+ vec3(mapping.x,mapping.y,z-outlinePushback);
+ vec4 clipPos = projectionMatrix * vec4(cameraPos, 1.0);
+ float ndcDepth = clipPos.z / clipPos.w;
+ gl_FragDepthEXT = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
+ gl_FragColor = vec4(outlineColor, 1 );
+}
+
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.vert": (
+ /*!********************************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.vert ***!
+ \********************************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform float outlineWidth;
+uniform float outlinePushback;
+
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec3 color;
+
+varying vec2 mapping;
+varying float rval;
+varying vec3 center;
+
+void main() {
+
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+ center = mvPosition.xyz;
+ vec4 projPosition = projectionMatrix * mvPosition;
+ vec2 norm = normal.xy + vec2(sign(normal.x)*outlineWidth,sign(normal.y)*outlineWidth);
+ vec4 adjust = projectionMatrix* vec4(norm,normal.z,0.0); adjust.z = 0.0; adjust.w = 0.0;
+ mapping = norm.xy;
+ rval = abs(norm.x);
+ gl_Position = projPosition+adjust;
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/sprite/sprite.frag": (
+ /*!**************************************************!*\
+ !*** ./src/WebGL/shaders/lib/sprite/sprite.frag ***!
+ \**************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform vec3 color;
+uniform sampler2D map;
+uniform float opacity;
+
+uniform int fogType;
+uniform vec3 fogColor;
+uniform float fogDensity;
+uniform float fogNear;
+uniform float fogFar;
+uniform float alphaTest;
+
+varying vec2 vUV;
+//DEFINEFRAGCOLOR
+
+void main() {
+
+ vec4 texture = texture2D(map, vUV);
+
+ if (texture.a < alphaTest) discard;
+
+ gl_FragColor = vec4(color * texture.xyz, texture.a * opacity);
+
+ if (fogType > 0) {
+
+ float depth = gl_FragCoord.z / gl_FragCoord.w;
+ float fogFactor = 0.0;
+
+ if (fogType == 1) {
+ fogFactor = smoothstep(fogNear, fogFar, depth);
+ }
+
+ else {
+ const float LOG2 = 1.442695;
+ float fogFactor = exp2(- fogDensity * fogDensity * depth * depth * LOG2);
+ fogFactor = 1.0 - clamp(fogFactor, 0.0, 1.0);
+ }
+
+ gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w), fogFactor);
+
+ }
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/sprite/sprite.vert": (
+ /*!**************************************************!*\
+ !*** ./src/WebGL/shaders/lib/sprite/sprite.vert ***!
+ \**************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform int useScreenCoordinates;
+uniform vec3 screenPosition;
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform float rotation;
+uniform vec2 scale;
+uniform vec2 alignment;
+uniform vec2 uvOffset;
+uniform vec2 uvScale;
+
+attribute vec2 position;
+attribute vec2 uv;
+
+varying vec2 vUV;
+
+void main() {
+
+ vUV = uvOffset + uv * uvScale;
+
+ vec2 alignedPosition = position + alignment;
+
+ vec2 rotatedPosition;
+ rotatedPosition.x = ( cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y ) * scale.x;
+ rotatedPosition.y = ( sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y ) * scale.y;
+
+ vec4 finalPosition;
+
+ if(useScreenCoordinates != 0) {
+ finalPosition = vec4(screenPosition.xy + rotatedPosition, screenPosition.z, 1.0);
+ }
+
+ else {
+ finalPosition = projectionMatrix * modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); finalPosition /= finalPosition.w;
+ finalPosition.xy += rotatedPosition;
+ }
+
+ gl_Position = finalPosition;
+
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/stickimposter/stickimposter.partial.frag": (
+ /*!************************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/stickimposter/stickimposter.partial.frag ***!
+ \************************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = ` float dotProduct = dot( norm, vLight );
+ vec3 light = vec3( max( dotProduct, 0.0 ) );
+ gl_FragColor = vec4(light*color, opacity*opacity );
+ float fogFactor = smoothstep( fogNear, fogFar, depth );
+ gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
+}`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/stickimposter/stickimposter.vert": (
+ /*!****************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/stickimposter/stickimposter.vert ***!
+ \****************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform mat4 viewMatrix;
+uniform mat3 normalMatrix;
+uniform vec3 directionalLightColor[ 1 ];
+uniform vec3 directionalLightDirection[ 1 ];
+
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec3 color;
+attribute float radius;
+
+varying vec3 vColor;
+varying vec3 vLight;
+varying vec3 cposition;
+varying vec3 p1;
+varying vec3 p2;
+varying float r;
+
+void main() {
+
+ vColor = color; vColor.z = abs(vColor.z); //z indicates which vertex and so would vary
+ r = abs(radius);
+ vec4 to = modelViewMatrix*vec4(normal, 1.0); //normal is other point of cylinder
+ vec4 pt = modelViewMatrix*vec4(position, 1.0);
+ vec4 mvPosition = pt;
+ p1 = pt.xyz; p2 = to.xyz;
+ vec3 norm = to.xyz-pt.xyz;
+ float mult = 1.1; //slop to account for perspective of sphere
+ if(length(p1) > length(p2)) { //billboard at level of closest point
+ mvPosition = to;
+ }
+ vec3 n = normalize(mvPosition.xyz);
+//intersect with the plane defined by the camera looking at the billboard point
+ if(color.z >= 0.0) { //p1
+ if(projectionMatrix[3][3] == 0.0) { //perspective
+ vec3 pnorm = normalize(p1);
+ float t = dot(mvPosition.xyz-p1,n)/dot(pnorm,n);
+ mvPosition.xyz = p1+t*pnorm;
+ } else { //orthographic
+ mvPosition.xyz = p1;
+ }
+ } else {
+ if(projectionMatrix[3][3] == 0.0) { //perspective
+ vec3 pnorm = normalize(p2);
+ float t = dot(mvPosition.xyz-p2,n)/dot(pnorm,n);
+ mvPosition.xyz = p2+t*pnorm;
+ } else { //orthographic
+ mvPosition.xyz = p2;
+ }
+ mult *= -1.0;
+ }
+ vec3 cr = normalize(cross(mvPosition.xyz,norm))*radius;
+ vec3 doublecr = normalize(cross(mvPosition.xyz,cr))*radius;
+ mvPosition.xyz += mult*(cr + doublecr).xyz;
+ cposition = mvPosition.xyz;
+ gl_Position = projectionMatrix * mvPosition;
+ vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );
+ vLight = normalize( lDirection.xyz )*directionalLightColor[0]; //not really sure this is right, but color is always white so..
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.vert": (
+ /*!******************************************************************************!*\
+ !*** ./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.vert ***!
+ \******************************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+
+uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform mat4 viewMatrix;
+uniform mat3 normalMatrix;
+uniform vec3 directionalLightColor[ 1 ];
+uniform vec3 directionalLightDirection[ 1 ];
+uniform vec3 outlineColor;
+uniform float outlineWidth;
+uniform float outlinePushback;
+
+
+attribute vec3 position;
+attribute vec3 normal;
+attribute vec3 color;
+attribute float radius;
+
+varying vec3 vColor;
+varying vec3 vLight;
+varying vec3 cposition;
+varying vec3 p1;
+varying vec3 p2;
+varying float r;
+
+void main() {
+
+ vColor = outlineColor;
+ float rad = radius+sign(radius)*outlineWidth;
+ r = abs(rad);
+ vec4 to = modelViewMatrix*vec4(normal, 1.0); //normal is other point of cylinder
+ vec4 pt = modelViewMatrix*vec4(position, 1.0);
+//pushback
+ to.xyz += normalize(to.xyz)*outlinePushback;
+ pt.xyz += normalize(pt.xyz)*outlinePushback;
+
+ vec4 mvPosition = pt;
+ p1 = pt.xyz; p2 = to.xyz;
+ vec3 norm = to.xyz-pt.xyz;
+ float mult = 1.1; //slop to account for perspective of sphere
+ if(length(p1) > length(p2)) { //billboard at level of closest point
+ mvPosition = to;
+ }
+ vec3 n = normalize(mvPosition.xyz);
+//intersect with the plane defined by the camera looking at the billboard point
+ if(color.z >= 0.0) { //p1
+ vec3 pnorm = normalize(p1);
+ float t = dot(mvPosition.xyz-p1,n)/dot(pnorm,n);
+ mvPosition.xyz = p1+t*pnorm;
+ } else {
+ vec3 pnorm = normalize(p2);
+ float t = dot(mvPosition.xyz-p2,n)/dot(pnorm,n);
+ mvPosition.xyz = p2+t*pnorm;
+ mult *= -1.0;
+ }
+ vec3 cr = normalize(cross(mvPosition.xyz,norm))*rad;
+ vec3 doublecr = normalize(cross(mvPosition.xyz,cr))*rad;
+ mvPosition.xy += mult*(cr + doublecr).xy;
+ cposition = mvPosition.xyz;
+ gl_Position = projectionMatrix * mvPosition;
+ vLight = vec3(1.0,1.0,1.0);
+}
+
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/volumetric/volumetric.frag": (
+ /*!**********************************************************!*\
+ !*** ./src/WebGL/shaders/lib/volumetric/volumetric.frag ***!
+ \**********************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `
+uniform highp sampler3D data;
+uniform highp sampler2D colormap;
+uniform highp sampler2D depthmap;
+
+
+uniform mat4 textmat;
+uniform mat4 projinv;
+uniform mat4 projectionMatrix;
+
+uniform float step;
+uniform float subsamples;
+uniform float maxdepth;
+uniform float transfermin;
+uniform float transfermax;
+in vec4 mvPosition;
+out vec4 color;
+void main(void) {
+
+ vec4 pos = mvPosition;
+ bool seengood = false;
+ float i = 0.0;
+ color = vec4(1,1,1,0);
+ float increment = 1.0/subsamples;
+ float maxsteps = (maxdepth*subsamples/step);
+//there's probably a better way to do this..
+//calculate farthest possible point in model coordinates
+ vec4 maxpos = vec4(pos.x,pos.y,pos.z-maxdepth,1.0);
+// convert to projection
+ maxpos = projectionMatrix*maxpos;
+ vec4 startp = projectionMatrix*pos;
+// homogonize
+ maxpos /= maxpos.w;
+ startp /= startp.w;
+//take x,y from start and z from max
+ maxpos = vec4(startp.x,startp.y,maxpos.z,1.0);
+//convert back to model space
+ maxpos = projinv*maxpos;
+ maxpos /= maxpos.w;
+ float incr = step/subsamples;
+//get depth from depthmap
+//startp is apparently [-1,1]
+ vec2 tpos = startp.xy/2.0+0.5;
+ float depth = texture(depthmap, tpos).r;
+//compute vector between start and end
+ vec4 direction = maxpos-pos;
+ for( i = 0.0; i <= maxsteps; i++) {
+ vec4 pt = (pos+(i/maxsteps)*direction);
+ vec4 ppt = projectionMatrix*pt;
+ float ptdepth = ppt.z/ppt.w;
+ ptdepth = ((gl_DepthRange.diff * ptdepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
+ if(ptdepth > depth) break;
+ pt = textmat*pt;
+// pt /= pt.w;
+ if(pt.x >= -0.01 && pt.y >= -0.01 && pt.z >= -0.01 && pt.x <= 1.01 && pt.y <= 1.01 && pt.z <= 1.01) {
+ seengood = true;
+ } else if(seengood) {
+ break;
+ }
+ if( pt.x < -0.01 || pt.x > 1.01 || pt.y < -0.01 || pt.y > 1.01 || pt.z < -0.01 || pt.z > 1.01 ){
+ color.a = 0.0;
+ continue;
+ }
+ else {
+ float val = texture(data, pt.zyx).r;
+ if(isinf(val)) continue; //masked out
+ float cval = (val-transfermin)/(transfermax-transfermin); //scale to texture 0-1 range
+ vec4 val_color = texture(colormap, vec2(cval,0.5));
+ color.rgb = color.rgb*color.a + (1.0-color.a)*val_color.a*val_color.rgb;
+ color.a += (1.0 - color.a) * val_color.a;
+ if(color.a > 0.0) color.rgb /= color.a;
+// color = vec4(pt.x, pt.y, pt.z, 1.0);
+ }
+// color = vec4(pt.x, pt.y, pt.z, 0.0)
+ }
+}
+
+ `;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/lib/volumetric/volumetric.vert": (
+ /*!**********************************************************!*\
+ !*** ./src/WebGL/shaders/lib/volumetric/volumetric.vert ***!
+ \**********************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform mat4 modelViewMatrix;
+uniform mat4 projectionMatrix;
+uniform mat4 viewMatrix;
+
+in vec3 position;
+out vec4 mvPosition;
+void main() {
+
+ mvPosition = modelViewMatrix * vec4( position, 1.0 );
+ gl_Position = projectionMatrix*mvPosition;
+}
+`;
+ }
+ ),
+ /***/
+ "./src/WebGL/shaders/utils/stickimposterFragmentShader.partial.frag": (
+ /*!**************************************************************************!*\
+ !*** ./src/WebGL/shaders/utils/stickimposterFragmentShader.partial.frag ***!
+ \**************************************************************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ default: () => s
+ /* harmony export */
+ });
+ const s = `uniform float opacity;
+uniform mat4 projectionMatrix;
+
+uniform vec3 fogColor;
+uniform float fogNear;
+uniform float fogFar;
+
+varying vec3 vLight;
+varying vec3 vColor;
+varying vec3 cposition;
+varying vec3 p1;
+varying vec3 p2;
+varying float r;
+
+//DEFINEFRAGCOLOR
+
+//cylinder-ray intersection testing taken from http://mrl.nyu.edu/~dzorin/cg05/lecture12.pdf
+//also useful: http://stackoverflow.com/questions/9595300/cylinder-impostor-in-glsl
+//with a bit more care (caps) this could be a general cylinder imposter (see also outline)
+void main() {
+ vec3 color = abs(vColor);
+ vec3 pos = cposition;
+ vec3 p = pos; //ray point
+ vec3 v = vec3(0.0,0.0,-1.0); //ray normal - orthographic
+ if(projectionMatrix[3][3] == 0.0) v = normalize(pos); //ray normal - perspective
+ vec3 pa = p1; //cyl start
+ vec3 va = normalize(p2-p1); //cyl norm
+ vec3 tmp1 = v-(dot(v,va)*va);
+ vec3 deltap = p-pa;
+ float A = dot(tmp1,tmp1);
+ if(A == 0.0) discard;
+ vec3 tmp2 = deltap-(dot(deltap,va)*va);
+ float B = 2.0*dot(tmp1, tmp2);
+ float C = dot(tmp2,tmp2)-r*r;
+//quadratic equation!
+ float det = (B*B) - (4.0*A*C);
+ if(det < 0.0) discard;
+ float sqrtDet = sqrt(det);
+ float posT = (-B+sqrtDet)/(2.0*A);
+ float negT = (-B-sqrtDet)/(2.0*A);
+ float intersectionT = min(posT,negT);
+ vec3 qi = p+v*intersectionT;
+ float dotp1 = dot(va,qi-p1);
+ float dotp2 = dot(va,qi-p2);
+ vec3 norm;
+ if( dotp1 < 0.0 || dotp2 > 0.0) { //(p-c)^2 + 2(p-c)vt +v^2+t^2 - r^2 = 0
+ vec3 cp;
+ if( dotp1 < 0.0) {
+// if(vColor.x < 0.0 ) discard; //color sign bit indicates if we should cap or not
+ cp = p1;
+ } else {
+// if(vColor.y < 0.0 ) discard;
+ cp = p2;
+ }
+ vec3 diff = p-cp;
+ A = dot(v,v);
+ B = dot(diff,v)*2.0;
+ C = dot(diff,diff)-r*r;
+ det = (B*B) - (4.0*C);
+ if(det < 0.0) discard;
+ sqrtDet = sqrt(det);
+ posT = (-B+sqrtDet)/(2.0);
+ negT = (-B-sqrtDet)/(2.0);
+ float t = min(posT,negT);
+ qi = p+v*t;
+ norm = normalize(qi-cp);
+ } else {
+ norm = normalize(qi-(dotp1*va + p1));
+ }
+ vec4 clipPos = projectionMatrix * vec4(qi, 1.0);
+ float ndcDepth = clipPos.z / clipPos.w;
+ float depth = ((gl_DepthRange.diff * ndcDepth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
+ gl_FragDepthEXT = depth;`;
+ }
+ ),
+ /***/
+ "./src/GLDraw.ts": (
+ /*!***********************!*\
+ !*** ./src/GLDraw.ts ***!
+ \***********************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ CAP: () => (
+ /* binding */
+ f
+ ),
+ /* harmony export */
+ GLDraw: () => (
+ /* binding */
+ _
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! ./WebGL/math */
+ "./src/WebGL/math/index.ts"
+ ), f;
+ (function(x) {
+ x[x.NONE = 0] = "NONE", x[x.FLAT = 1] = "FLAT", x[x.ROUND = 2] = "ROUND";
+ })(f || (f = {}));
+ var _;
+ (function(x) {
+ function h(n, o, w) {
+ var p = Math.hypot(n, o), v, a, l, g, M;
+ p < 1e-4 ? (a = 0, l = 1) : (a = -n / p, l = o / p), o = -a * n + l * o, v = Math.hypot(o, w), v < 1e-4 ? (g = 0, M = 1) : (g = w / v, M = o / v);
+ var L = new Float32Array(9);
+ return L[0] = l, L[1] = a, L[2] = 0, L[3] = -a * M, L[4] = l * M, L[5] = g, L[6] = a * g, L[7] = -l * g, L[8] = M, L;
+ }
+ class u {
+ constructor() {
+ this.cache = {};
+ let o = [], w = 4, p = Math.pow(2, w), v = 2, a = Math.pow(2, v), l = p / a, g;
+ for (o[0] = new s.Vector3(-1, 0, 0), o[l] = new s.Vector3(0, 0, 1), o[l * 2] = new s.Vector3(1, 0, 0), o[l * 3] = new s.Vector3(0, 0, -1), v = 3; v <= w; v++) {
+ for (a = Math.pow(2, v - 1), l = p / a, g = 0; g < a - 1; g++)
+ o[l / 2 + g * l] = o[g * l].clone().add(o[(g + 1) * l]).normalize();
+ g = a - 1, o[l / 2 + g * l] = o[g * l].clone().add(o[0]).normalize();
+ }
+ this.basisVectors = o;
+ }
+ getVerticesForRadius(o, w, p) {
+ if (typeof this.cache < "u" && this.cache[o] !== void 0 && this.cache[o][w + p] !== void 0)
+ return this.cache[o][w + p];
+ for (var v = this.basisVectors.length, a = [], l = [], g, M = 0; M < v; M++)
+ a.push(this.basisVectors[M].clone().multiplyScalar(o)), a.push(this.basisVectors[M].clone().multiplyScalar(o)), g = this.basisVectors[M].clone().normalize(), l.push(g), l.push(g);
+ var L = [], T = 10, D = v, R = 0, B = Math.PI * 2, P = 0, z = Math.PI, F, N, $ = !1, k = !1;
+ for (N = 0; N <= T; N++) {
+ $ = N === 0 || N === T, k = N === T / 2;
+ var G = [], H = [];
+ for (F = 0; F <= D; F++) {
+ if (k) {
+ var U = F < D ? 2 * F : 0;
+ H.push(U + 1), G.push(U);
+ continue;
+ }
+ var V = F / D, Q = N / T;
+ if (!$ || F === 0)
+ if (F < D) {
+ var oe = new s.Vector3();
+ oe.x = -o * Math.cos(R + V * B) * Math.sin(P + Q * z), w == 1 ? oe.y = 0 : oe.y = o * Math.cos(P + Q * z), oe.z = o * Math.sin(R + V * B) * Math.sin(P + Q * z), Math.abs(oe.x) < 1e-5 && (oe.x = 0), Math.abs(oe.y) < 1e-5 && (oe.y = 0), Math.abs(oe.z) < 1e-5 && (oe.z = 0), w == f.FLAT ? (g = new s.Vector3(0, Math.cos(P + Q * z), 0), g.normalize()) : (g = new s.Vector3(oe.x, oe.y, oe.z), g.normalize()), a.push(oe), l.push(g), G.push(a.length - 1);
+ } else
+ G.push(a.length - D);
+ else
+ $ && G.push(a.length - 1);
+ }
+ k && L.push(H), L.push(G);
+ }
+ var ee = {
+ vertices: a,
+ normals: l,
+ verticesRows: L,
+ w: D,
+ h: T
+ };
+ return o in this.cache || (this.cache[o] = {}), this.cache[o][w + p] = ee, ee;
+ }
+ }
+ var E = new u();
+ function c(n, o, w, p, v, a = 0, l = 0) {
+ if (!(!o || !w)) {
+ var g = l || a;
+ v = v || { r: 0, g: 0, b: 0 };
+ var M = h(w.x - o.x, w.y - o.y, w.z - o.z), L = E.getVerticesForRadius(p, l, "to"), T = L.w, D = L.h, R = g ? D * T + 2 : 2 * T, B = n.updateGeoGroup(R), P = L.vertices, z = L.normals, F = L.verticesRows, N = F[D / 2], $ = F[D / 2 + 1], k = B.vertices, G, H, U, V, Q, oe, ee = B.vertexArray, ne = B.normalArray, me = B.colorArray, se = B.faceArray;
+ for (U = 0; U < T; ++U) {
+ var fe = 2 * U;
+ V = M[0] * P[fe].x + M[3] * P[fe].y + M[6] * P[fe].z, Q = M[1] * P[fe].x + M[4] * P[fe].y + M[7] * P[fe].z, oe = M[5] * P[fe].y + M[8] * P[fe].z, G = 3 * (k + fe), H = B.faceidx, ee[G] = V + o.x, ee[G + 1] = Q + o.y, ee[G + 2] = oe + o.z, ee[G + 3] = V + w.x, ee[G + 4] = Q + w.y, ee[G + 5] = oe + w.z, ne[G] = V, ne[G + 3] = V, ne[G + 1] = Q, ne[G + 4] = Q, ne[G + 2] = oe, ne[G + 5] = oe, me[G] = v.r, me[G + 3] = v.r, me[G + 1] = v.g, me[G + 4] = v.g, me[G + 2] = v.b, me[G + 5] = v.b, se[H] = $[U] + k, se[H + 1] = $[U + 1] + k, se[H + 2] = N[U] + k, se[H + 3] = N[U] + k, se[H + 4] = $[U + 1] + k, se[H + 5] = N[U + 1] + k, B.faceidx += 6;
+ }
+ if (g) {
+ var Ce = l ? 0 : D / 2, Me = a ? D + 1 : D / 2 + 1, Te, ae, pe, we, ke, Ue, Ne, Be, ue, ye, ge, Se, ze, He, We, Y, K, q, de, ve, Ie, Re, Z, ce, Ae, Fe, he, Oe, j, $e, Ve, I;
+ for (Q = Ce; Q < Me; Q++)
+ if (Q !== D / 2) {
+ var be = Q <= D / 2 ? w : o, Ee = E.getVerticesForRadius(p, l, "to"), X = E.getVerticesForRadius(p, a, "from");
+ for (be === w ? (P = Ee.vertices, z = Ee.normals, F = Ee.verticesRows) : be == o && (P = X.vertices, z = X.normals, F = X.verticesRows), V = 0; V < T; V++)
+ H = B.faceidx, Te = F[Q][V + 1], j = (Te + k) * 3, ae = F[Q][V], $e = (ae + k) * 3, pe = F[Q + 1][V], Ve = (pe + k) * 3, we = F[Q + 1][V + 1], I = (we + k) * 3, ke = M[0] * P[Te].x + M[3] * P[Te].y + M[6] * P[Te].z, Ue = M[0] * P[ae].x + M[3] * P[ae].y + M[6] * P[ae].z, Ne = M[0] * P[pe].x + M[3] * P[pe].y + M[6] * P[pe].z, Be = M[0] * P[we].x + M[3] * P[we].y + M[6] * P[we].z, ue = M[1] * P[Te].x + M[4] * P[Te].y + M[7] * P[Te].z, ye = M[1] * P[ae].x + M[4] * P[ae].y + M[7] * P[ae].z, ge = M[1] * P[pe].x + M[4] * P[pe].y + M[7] * P[pe].z, Se = M[1] * P[we].x + M[4] * P[we].y + M[7] * P[we].z, ze = M[5] * P[Te].y + M[8] * P[Te].z, He = M[5] * P[ae].y + M[8] * P[ae].z, We = M[5] * P[pe].y + M[8] * P[pe].z, Y = M[5] * P[we].y + M[8] * P[we].z, ee[j] = ke + be.x, ee[$e] = Ue + be.x, ee[Ve] = Ne + be.x, ee[I] = Be + be.x, ee[j + 1] = ue + be.y, ee[$e + 1] = ye + be.y, ee[Ve + 1] = ge + be.y, ee[I + 1] = Se + be.y, ee[j + 2] = ze + be.z, ee[$e + 2] = He + be.z, ee[Ve + 2] = We + be.z, ee[I + 2] = Y + be.z, me[j] = v.r, me[$e] = v.r, me[Ve] = v.r, me[I] = v.r, me[j + 1] = v.g, me[$e + 1] = v.g, me[Ve + 1] = v.g, me[I + 1] = v.g, me[j + 2] = v.b, me[$e + 2] = v.b, me[Ve + 2] = v.b, me[I + 2] = v.b, K = M[0] * z[Te].x + M[3] * z[Te].y + M[6] * z[Te].z, q = M[0] * z[ae].x + M[3] * z[ae].y + M[6] * z[ae].z, de = M[0] * z[pe].x + M[3] * z[pe].y + M[6] * z[pe].z, ve = M[0] * z[we].x + M[3] * z[we].y + M[6] * z[we].z, Ie = M[1] * z[Te].x + M[4] * z[Te].y + M[7] * z[Te].z, Re = M[1] * z[ae].x + M[4] * z[ae].y + M[7] * z[ae].z, Z = M[1] * z[pe].x + M[4] * z[pe].y + M[7] * z[pe].z, ce = M[1] * z[we].x + M[4] * z[we].y + M[7] * z[we].z, Ae = M[5] * z[Te].y + M[8] * z[Te].z, Fe = M[5] * z[ae].y + M[8] * z[ae].z, he = M[5] * z[pe].y + M[8] * z[pe].z, Oe = M[5] * z[we].y + M[8] * z[we].z, Q === 0 ? (ne[j] = K, ne[Ve] = de, ne[I] = ve, ne[j + 1] = Ie, ne[Ve + 1] = Z, ne[I + 1] = ce, ne[j + 2] = Ae, ne[Ve + 2] = he, ne[I + 2] = Oe, se[H] = Te + k, se[H + 1] = pe + k, se[H + 2] = we + k, B.faceidx += 3) : Q === Me - 1 ? (ne[j] = K, ne[$e] = q, ne[Ve] = de, ne[j + 1] = Ie, ne[$e + 1] = Re, ne[Ve + 1] = Z, ne[j + 2] = Ae, ne[$e + 2] = Fe, ne[Ve + 2] = he, se[H] = Te + k, se[H + 1] = ae + k, se[H + 2] = pe + k, B.faceidx += 3) : (ne[j] = K, ne[$e] = q, ne[I] = ve, ne[j + 1] = Ie, ne[$e + 1] = Re, ne[I + 1] = ce, ne[j + 2] = Ae, ne[$e + 2] = Fe, ne[I + 2] = Oe, ne[$e] = q, ne[Ve] = de, ne[I] = ve, ne[$e + 1] = Re, ne[Ve + 1] = Z, ne[I + 1] = ce, ne[$e + 2] = Fe, ne[Ve + 2] = he, ne[I + 2] = Oe, se[H] = Te + k, se[H + 1] = ae + k, se[H + 2] = we + k, se[H + 3] = ae + k, se[H + 4] = pe + k, se[H + 5] = we + k, B.faceidx += 6);
+ }
+ }
+ B.vertices += R;
+ }
+ }
+ x.drawCylinder = c;
+ function C(n, o, w, p, v) {
+ if (!o || !w)
+ return;
+ v = v || { r: 0, g: 0, b: 0 };
+ let a = new s.Vector3(w.x - o.x, w.y - o.y, w.z - o.z);
+ var l = h(a.x, a.y, a.z);
+ a = a.normalize();
+ var g = E.basisVectors.length, M = E.basisVectors, L = g + 2, T = n.updateGeoGroup(L), D = T.vertices, R, B, P, z, F, N, $ = T.vertexArray, k = T.normalArray, G = T.colorArray, H = T.faceArray;
+ for (R = D * 3, $[R] = o.x, $[R + 1] = o.y, $[R + 2] = o.z, k[R] = -a.x, k[R + 1] = -a.y, k[R + 2] = -a.z, G[R] = v.r, G[R + 1] = v.g, G[R + 2] = v.b, $[R + 3] = w.x, $[R + 4] = w.y, $[R + 5] = w.z, k[R + 3] = a.x, k[R + 4] = a.y, k[R + 5] = a.z, G[R + 3] = v.r, G[R + 4] = v.g, G[R + 5] = v.b, R += 6, P = 0; P < g; ++P) {
+ var U = M[P].clone();
+ U.multiplyScalar(p), z = l[0] * U.x + l[3] * U.y + l[6] * U.z, F = l[1] * U.x + l[4] * U.y + l[7] * U.z, N = l[5] * U.y + l[8] * U.z, $[R] = z + o.x, $[R + 1] = F + o.y, $[R + 2] = N + o.z, k[R] = z, k[R + 1] = F, k[R + 2] = N, G[R] = v.r, G[R + 1] = v.g, G[R + 2] = v.b, R += 3;
+ }
+ for (T.vertices += g + 2, B = T.faceidx, P = 0; P < g; P++) {
+ var V = D + 2 + P, Q = D + 2 + (P + 1) % g;
+ H[B] = V, H[B + 1] = Q, H[B + 2] = D, B += 3, H[B] = V, H[B + 1] = Q, H[B + 2] = D + 1, B += 3;
+ }
+ T.faceidx += 6 * g;
+ }
+ x.drawCone = C;
+ class b {
+ constructor() {
+ this.cache = /* @__PURE__ */ new Map();
+ }
+ getVerticesForRadius(o, w) {
+ w = w || 2, this.cache.has(w) || this.cache.set(w, /* @__PURE__ */ new Map());
+ let p = this.cache.get(w);
+ if (p.has(o))
+ return p.get(o);
+ var v = {
+ vertices: [],
+ verticesRows: [],
+ normals: []
+ }, a = 16 * w, l = 10 * w;
+ o < 1 && (a = 10 * w, l = 8 * w);
+ var g = 0, M = Math.PI * 2, L = 0, T = Math.PI, D, R;
+ for (R = 0; R <= l; R++) {
+ let P = [];
+ for (D = 0; D <= a; D++) {
+ let z = D / a, F = R / l, N = -o * Math.cos(g + z * M) * Math.sin(L + F * T), $ = o * Math.cos(L + F * T), k = o * Math.sin(g + z * M) * Math.sin(L + F * T);
+ var B = new s.Vector3(N, $, k);
+ B.normalize(), v.vertices.push({ x: N, y: $, z: k }), v.normals.push(B), P.push(v.vertices.length - 1);
+ }
+ v.verticesRows.push(P);
+ }
+ return p.set(o, v), v;
+ }
+ }
+ var A = new b();
+ function S(n, o, w, p, v) {
+ var a = A.getVerticesForRadius(w, v), l = a.vertices, g = a.normals, M = n.updateGeoGroup(l.length), L = M.vertices, T = M.vertexArray, D = M.colorArray, R = M.faceArray, B = M.lineArray, P = M.normalArray;
+ for (let N = 0, $ = l.length; N < $; ++N) {
+ let k = 3 * (L + N), G = l[N];
+ T[k] = G.x + o.x, T[k + 1] = G.y + o.y, T[k + 2] = G.z + o.z, D[k] = p.r, D[k + 1] = p.g, D[k + 2] = p.b;
+ }
+ M.vertices += l.length;
+ let z = a.verticesRows, F = z.length - 1;
+ for (let N = 0; N < F; N++) {
+ let $ = z[N].length - 1;
+ for (let k = 0; k < $; k++) {
+ let G = M.faceidx, H = M.lineidx, U = z[N][k + 1] + L, V = U * 3, Q = z[N][k] + L, oe = Q * 3, ee = z[N + 1][k] + L, ne = ee * 3, me = z[N + 1][k + 1] + L, se = me * 3, fe = g[U - L], Ce = g[Q - L], Me = g[ee - L], Te = g[me - L];
+ Math.abs(l[U - L].y) === w ? (P[V] = fe.x, P[ne] = Me.x, P[se] = Te.x, P[V + 1] = fe.y, P[ne + 1] = Me.y, P[se + 1] = Te.y, P[V + 2] = fe.z, P[ne + 2] = Me.z, P[se + 2] = Te.z, R[G] = U, R[G + 1] = ee, R[G + 2] = me, B[H] = U, B[H + 1] = ee, B[H + 2] = U, B[H + 3] = me, B[H + 4] = ee, B[H + 5] = me, M.faceidx += 3, M.lineidx += 6) : Math.abs(l[ee - L].y) === w ? (P[V] = fe.x, P[oe] = Ce.x, P[ne] = Me.x, P[V + 1] = fe.y, P[oe + 1] = Ce.y, P[ne + 1] = Me.y, P[V + 2] = fe.z, P[oe + 2] = Ce.z, P[ne + 2] = Me.z, R[G] = U, R[G + 1] = Q, R[G + 2] = ee, B[H] = U, B[H + 1] = Q, B[H + 2] = U, B[H + 3] = ee, B[H + 4] = Q, B[H + 5] = ee, M.faceidx += 3, M.lineidx += 6) : (P[V] = fe.x, P[oe] = Ce.x, P[se] = Te.x, P[V + 1] = fe.y, P[oe + 1] = Ce.y, P[se + 1] = Te.y, P[V + 2] = fe.z, P[oe + 2] = Ce.z, P[se + 2] = Te.z, P[oe] = Ce.x, P[ne] = Me.x, P[se] = Te.x, P[oe + 1] = Ce.y, P[ne + 1] = Me.y, P[se + 1] = Te.y, P[oe + 2] = Ce.z, P[ne + 2] = Me.z, P[se + 2] = Te.z, R[G] = U, R[G + 1] = Q, R[G + 2] = me, R[G + 3] = Q, R[G + 4] = ee, R[G + 5] = me, B[H] = U, B[H + 1] = Q, B[H + 2] = U, B[H + 3] = me, B[H + 4] = Q, B[H + 5] = ee, B[H + 6] = ee, B[H + 7] = me, M.faceidx += 6, M.lineidx += 8);
+ }
+ }
+ }
+ x.drawSphere = S;
+ })(_ || (_ = {}));
+ }
+ ),
+ /***/
+ "./src/GLModel.ts": (
+ /*!************************!*\
+ !*** ./src/GLModel.ts ***!
+ \************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ GLModel: () => (
+ /* binding */
+ o
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! ./WebGL */
+ "./src/WebGL/index.ts"
+ ), f = t(
+ /*! ./WebGL/shapes */
+ "./src/WebGL/shapes/index.ts"
+ ), _ = t(
+ /*! ./WebGL/math */
+ "./src/WebGL/math/index.ts"
+ ), x = t(
+ /*! ./colors */
+ "./src/colors.ts"
+ ), h = t(
+ /*! ./GLDraw */
+ "./src/GLDraw.ts"
+ ), u = t(
+ /*! ./glcartoon */
+ "./src/glcartoon.ts"
+ ), E = t(
+ /*! ./utilities */
+ "./src/utilities.ts"
+ ), c = t(
+ /*! ./Gradient */
+ "./src/Gradient.ts"
+ ), C = t(
+ /*! ./parsers */
+ "./src/parsers/index.ts"
+ ), b = t(
+ /*! netcdfjs */
+ "./node_modules/netcdfjs/lib-esm/index.js"
+ ), A = t(
+ /*! pako */
+ "./node_modules/pako/dist/pako.esm.mjs"
+ ), S = t(
+ /*! ./parsers/utils/assignBonds */
+ "./src/parsers/utils/assignBonds.ts"
+ );
+ function n(w) {
+ let p;
+ return typeof w == "string" ? p = new TextEncoder().encode(w) : p = new Uint8Array(w), (0, A.inflate)(p, {
+ to: "string"
+ });
+ }
+ class o {
+ // class functions
+ // return true if a and b represent the same style
+ static sameObj(p, v) {
+ return p && v ? JSON.stringify(p) == JSON.stringify(v) : p == v;
+ }
+ constructor(p, v) {
+ this.atoms = [], this.frames = [], this.box = null, this.atomdfs = null, this.id = 0, this.hidden = !1, this.molObj = null, this.renderedMolObj = null, this.lastColors = null, this.modelData = {}, this.modelDatas = null, this.idMatrix = new _.Matrix4(), this.dontDuplicateAtoms = !0, this.defaultColor = x.elementColors.defaultColor, this.defaultStickRadius = 0.25, this.options = v || {}, this.ElementColors = this.options.defaultcolors ? this.options.defaultcolors : x.elementColors.defaultColors, this.defaultSphereRadius = this.options.defaultSphereRadius ? this.options.defaultSphereRadius : 1.5, this.defaultCartoonQuality = this.options.cartoonQuality ? this.options.cartoonQuality : 10, this.id = p;
+ }
+ // return proper radius for atom given style
+ /**
+ *
+ * @param {AtomSpec} atom
+ * @param {atomstyle} style
+ * @return {number}
+ *
+ */
+ getRadiusFromStyle(p, v) {
+ var a = this.defaultSphereRadius;
+ if (typeof v.radius < "u")
+ a = v.radius;
+ else if (o.vdwRadii[p.elem])
+ a = o.vdwRadii[p.elem];
+ else if (p.elem.length > 1) {
+ let l = p.elem;
+ l = l[0].toUpperCase() + l[1].toLowerCase(), o.vdwRadii[l] && (a = o.vdwRadii[l]);
+ }
+ return typeof v.scale < "u" && (a *= v.scale), a;
+ }
+ // cross drawing
+ /**
+ *
+ * @param {AtomSpec} atom
+ * @param {Record} geos
+ */
+ drawAtomCross(p, v) {
+ if (p.style.cross) {
+ var a = p.style.cross;
+ if (!a.hidden) {
+ var l = a.linewidth || o.defaultlineWidth;
+ v[l] || (v[l] = new s.Geometry());
+ var g = v[l].updateGeoGroup(6), M = this.getRadiusFromStyle(p, a), L = [
+ [M, 0, 0],
+ [-M, 0, 0],
+ [0, M, 0],
+ [0, -M, 0],
+ [0, 0, M],
+ [0, 0, -M]
+ ], T = p.clickable || p.hoverable;
+ T && p.intersectionShape === void 0 && (p.intersectionShape = { sphere: [], cylinder: [], line: [] });
+ for (var D = (0, E.getColorFromStyle)(p, a), R = g.vertexArray, B = g.colorArray, P = 0; P < 6; P++) {
+ var z = g.vertices * 3;
+ if (g.vertices++, R[z] = p.x + L[P][0], R[z + 1] = p.y + L[P][1], R[z + 2] = p.z + L[P][2], B[z] = D.r, B[z + 1] = D.g, B[z + 2] = D.b, T) {
+ var F = new _.Vector3(L[P][0], L[P][1], L[P][2]);
+ F.multiplyScalar(0.1), F.set(F.x + p.x, F.y + p.y, F.z + p.z), p.intersectionShape.line.push(F);
+ }
+ }
+ }
+ }
+ }
+ getGoodCross(p, v, a, l) {
+ for (var g = null, M = -1, L = 0, T = p.bonds.length; L < T; L++)
+ if (p.bonds[L] != v.index) {
+ let R = p.bonds[L], B = this.atoms[R], z = new _.Vector3(B.x, B.y, B.z).clone();
+ z.sub(a);
+ let F = z.clone();
+ F.cross(l);
+ var D = F.lengthSq();
+ if (D > M && (M = D, g = F, M > 0.1))
+ return g;
+ }
+ return g;
+ }
+ //from atom, return a normalized vector v that is orthogonal and along which
+ //it is appropraite to draw multiple bonds
+ getSideBondV(p, v, a) {
+ var l, g, M, L, T, D = new _.Vector3(p.x, p.y, p.z), R = new _.Vector3(v.x, v.y, v.z), B = R.clone(), P = null;
+ if (B.sub(D), p.bonds.length === 1)
+ v.bonds.length === 1 ? (P = B.clone(), Math.abs(P.x) > 1e-4 ? P.y += 1 : P.x += 1) : (l = (a + 1) % v.bonds.length, g = v.bonds[l], M = this.atoms[g], L = new _.Vector3(M.x, M.y, M.z), T = L.clone(), T.sub(D), P = T.clone(), P.cross(B));
+ else if (P = this.getGoodCross(p, v, D, B), P.lengthSq() < 0.01) {
+ var z = this.getGoodCross(v, p, D, B);
+ z != null && (P = z);
+ }
+ return P.lengthSq() < 0.01 && (P = B.clone(), Math.abs(P.x) > 1e-4 ? P.y += 1 : P.x += 1), P.cross(B), P.normalize(), P;
+ }
+ addLine(p, v, a, l, g, M) {
+ p[a] = l.x, p[a + 1] = l.y, p[a + 2] = l.z, v[a] = M.r, v[a + 1] = M.g, v[a + 2] = M.b, p[a + 3] = g.x, p[a + 4] = g.y, p[a + 5] = g.z, v[a + 3] = M.r, v[a + 4] = M.g, v[a + 5] = M.b;
+ }
+ // bonds - both atoms must match bond style
+ // standardize on only drawing for lowest to highest
+ /**
+ *
+ * @param {AtomSpec}
+ * atom
+ * @param {AtomSpec[]} atoms
+ * @param {Record} geos
+ */
+ drawBondLines(p, v, a) {
+ if (p.style.line) {
+ var l = p.style.line;
+ if (!l.hidden) {
+ var g, M, L, T, D = l.linewidth || o.defaultlineWidth;
+ a[D] || (a[D] = new s.Geometry());
+ for (var R = a[D].updateGeoGroup(6 * p.bonds.length), B = R.vertexArray, P = R.colorArray, z = 0; z < p.bonds.length; z++) {
+ var F = p.bonds[z], N = v[F];
+ if (N.style.line && !(p.index >= N.index)) {
+ var $ = new _.Vector3(p.x, p.y, p.z), k = new _.Vector3(N.x, N.y, N.z), G = $.clone().add(k).multiplyScalar(0.5), H = !1, U = p.clickable || p.hoverable, V = N.clickable || N.hoverable;
+ (U || V) && (U && (p.intersectionShape === void 0 && (p.intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }), p.intersectionShape.line.push($), p.intersectionShape.line.push(G)), V && (N.intersectionShape === void 0 && (N.intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }), N.intersectionShape.line.push(G), N.intersectionShape.line.push(k)));
+ var Q = (0, E.getColorFromStyle)(p, p.style.line), oe = (0, E.getColorFromStyle)(N, N.style.line);
+ if (p.bondStyles && p.bondStyles[z]) {
+ var ee = p.bondStyles[z];
+ if (!ee.iswire)
+ continue;
+ ee.singleBond && (H = !0), typeof ee.color1 < "u" && (Q = x.CC.color(ee.color1)), typeof ee.color2 < "u" && (oe = x.CC.color(ee.color2));
+ }
+ var ne = R.vertices * 3, me, se;
+ if (p.bondOrder[z] > 1 && p.bondOrder[z] < 4 && !H) {
+ var fe = this.getSideBondV(p, N, z), Ce = k.clone();
+ Ce.sub($), p.bondOrder[z] == 2 ? (fe.multiplyScalar(0.1), g = $.clone(), g.add(fe), M = $.clone(), M.sub(fe), L = g.clone(), L.add(Ce), T = M.clone(), T.add(Ce), Q == oe ? (R.vertices += 4, this.addLine(B, P, ne, g, L, Q), this.addLine(B, P, ne + 6, M, T, Q)) : (R.vertices += 8, Ce.multiplyScalar(0.5), me = g.clone(), me.add(Ce), se = M.clone(), se.add(Ce), this.addLine(B, P, ne, g, me, Q), this.addLine(B, P, ne + 6, me, L, oe), this.addLine(B, P, ne + 12, M, se, Q), this.addLine(B, P, ne + 18, se, T, oe))) : p.bondOrder[z] == 3 && (fe.multiplyScalar(0.1), g = $.clone(), g.add(fe), M = $.clone(), M.sub(fe), L = g.clone(), L.add(Ce), T = M.clone(), T.add(Ce), Q == oe ? (R.vertices += 6, this.addLine(B, P, ne, $, k, Q), this.addLine(B, P, ne + 6, g, L, Q), this.addLine(B, P, ne + 12, M, T, Q)) : (R.vertices += 12, Ce.multiplyScalar(0.5), me = g.clone(), me.add(Ce), se = M.clone(), se.add(Ce), this.addLine(B, P, ne, $, G, Q), this.addLine(B, P, ne + 6, G, k, oe), this.addLine(B, P, ne + 12, g, me, Q), this.addLine(B, P, ne + 18, me, L, oe), this.addLine(B, P, ne + 24, M, se, Q), this.addLine(B, P, ne + 30, se, T, oe)));
+ } else
+ Q == oe ? (R.vertices += 2, this.addLine(B, P, ne, $, k, Q)) : (R.vertices += 4, this.addLine(B, P, ne, $, G, Q), this.addLine(B, P, ne + 6, G, k, oe));
+ }
+ }
+ }
+ }
+ }
+ //sphere drawing
+ //See also: drawCylinder
+ /**
+ *
+ * @param {AtomSpec} atom
+ * @param {Geometry} geo
+ */
+ drawAtomSphere(p, v) {
+ if (p.style.sphere) {
+ var a = p.style.sphere;
+ if (!a.hidden) {
+ var l = (0, E.getColorFromStyle)(p, a), g = this.getRadiusFromStyle(p, a);
+ if ((p.clickable === !0 || p.hoverable) && p.intersectionShape !== void 0) {
+ var M = new _.Vector3(p.x, p.y, p.z);
+ p.intersectionShape.sphere.push(new f.Sphere(M, g));
+ }
+ h.GLDraw.drawSphere(v, p, g, l);
+ }
+ }
+ }
+ /** Register atom shaped click handlers */
+ drawAtomClickSphere(p) {
+ if (p.style.clicksphere) {
+ var v = p.style.clicksphere;
+ if (!v.hidden) {
+ var a = this.getRadiusFromStyle(p, v);
+ if ((p.clickable === !0 || p.hoverable) && p.intersectionShape !== void 0) {
+ var l = new _.Vector3(p.x, p.y, p.z);
+ p.intersectionShape.sphere.push(new f.Sphere(l, a));
+ }
+ }
+ }
+ }
+ drawAtomInstanced(p, v) {
+ if (p.style.sphere) {
+ var a = p.style.sphere;
+ if (!a.hidden) {
+ var l = this.getRadiusFromStyle(p, a), g = (0, E.getColorFromStyle)(p, a), M = v.updateGeoGroup(1), L = M.vertices, T = L * 3, D = M.vertexArray, R = M.colorArray, B = M.radiusArray;
+ if (D[T] = p.x, D[T + 1] = p.y, D[T + 2] = p.z, R[T] = g.r, R[T + 1] = g.g, R[T + 2] = g.b, B[L] = l, (p.clickable === !0 || p.hoverable) && p.intersectionShape !== void 0) {
+ var P = new _.Vector3(p.x, p.y, p.z);
+ p.intersectionShape.sphere.push(new f.Sphere(P, l));
+ }
+ M.vertices += 1;
+ }
+ }
+ }
+ drawSphereImposter(p, v, a, l) {
+ var g = p.updateGeoGroup(4), M, L = g.vertices, T = L * 3, D = g.vertexArray, R = g.colorArray;
+ for (M = 0; M < 4; M++)
+ D[T + 3 * M] = v.x, D[T + 3 * M + 1] = v.y, D[T + 3 * M + 2] = v.z;
+ var B = g.normalArray;
+ for (M = 0; M < 4; M++)
+ R[T + 3 * M] = l.r, R[T + 3 * M + 1] = l.g, R[T + 3 * M + 2] = l.b;
+ B[T + 0] = -a, B[T + 1] = a, B[T + 2] = 0, B[T + 3] = -a, B[T + 4] = -a, B[T + 5] = 0, B[T + 6] = a, B[T + 7] = -a, B[T + 8] = 0, B[T + 9] = a, B[T + 10] = a, B[T + 11] = 0, g.vertices += 4;
+ var P = g.faceArray, z = g.faceidx;
+ P[z + 0] = L, P[z + 1] = L + 1, P[z + 2] = L + 2, P[z + 3] = L + 2, P[z + 4] = L + 3, P[z + 5] = L, g.faceidx += 6;
+ }
+ //dkoes - code for sphere imposters
+ drawAtomImposter(p, v) {
+ if (p.style.sphere) {
+ var a = p.style.sphere;
+ if (!a.hidden) {
+ var l = this.getRadiusFromStyle(p, a), g = (0, E.getColorFromStyle)(p, a);
+ if ((p.clickable === !0 || p.hoverable) && p.intersectionShape !== void 0) {
+ var M = new _.Vector3(p.x, p.y, p.z);
+ p.intersectionShape.sphere.push(new f.Sphere(M, l));
+ }
+ this.drawSphereImposter(v, p, l, g);
+ }
+ }
+ }
+ static drawStickImposter(p, v, a, l, g) {
+ for (var M = p.updateGeoGroup(4), L = M.vertices, T = L * 3, D = M.vertexArray, R = M.colorArray, B = M.radiusArray, P = M.normalArray, z = g.r, F = g.g, N = g.b, $ = function(V) {
+ var Q = -V;
+ return Q == 0 && (Q = -1e-4), Q;
+ }, k = T, G = 0; G < 4; G++)
+ D[k] = v.x, P[k] = a.x, R[k] = z, k++, D[k] = v.y, P[k] = a.y, R[k] = F, k++, D[k] = v.z, P[k] = a.z, G < 2 ? R[k] = N : R[k] = $(N), k++;
+ M.vertices += 4, B[L] = -l, B[L + 1] = l, B[L + 2] = -l, B[L + 3] = l;
+ var H = M.faceArray, U = M.faceidx;
+ H[U + 0] = L, H[U + 1] = L + 1, H[U + 2] = L + 2, H[U + 3] = L + 2, H[U + 4] = L + 3, H[U + 5] = L, M.faceidx += 6;
+ }
+ // draws cylinders and small spheres (at bond radius)
+ drawBondSticks(p, v, a) {
+ if (p.style.stick) {
+ var l = p.style.stick;
+ if (!l.hidden) {
+ var g = l.radius || this.defaultStickRadius, M = l.doubleBondScaling || 0.4, L = l.tripleBondScaling || 0.25, T = g, D = l.singleBonds || !1, R = 0, B = 0, P, z, F, N, $, k, G, H, U, V, Q, oe = (0, E.getColorFromStyle)(p, l), ee, ne, me;
+ !p.capDrawn && p.bonds.length < 4 && (R = 2);
+ var se = h.GLDraw.drawCylinder;
+ for (a.imposter && (se = o.drawStickImposter), F = 0; F < p.bonds.length; F++) {
+ var fe = p.bonds[F], Ce = v[fe];
+ if (ee = ne = me = null, p.index < Ce.index) {
+ var Me = Ce.style;
+ if (!Me.stick || Me.stick.hidden)
+ continue;
+ var Te = (0, E.getColorFromStyle)(Ce, Me.stick);
+ if (T = g, N = D, p.bondStyles && p.bondStyles[F]) {
+ if ($ = p.bondStyles[F], $.iswire)
+ continue;
+ $.radius && (T = $.radius), $.singleBond && (N = !0), typeof $.color1 < "u" && (oe = x.CC.color($.color1)), typeof $.color2 < "u" && (Te = x.CC.color($.color2));
+ }
+ var ae = new _.Vector3(p.x, p.y, p.z), pe = new _.Vector3(Ce.x, Ce.y, Ce.z);
+ if (p.bondOrder[F] <= 1 || N || p.bondOrder[F] > 3) {
+ if (p.bondOrder[F] < 1 && (T *= p.bondOrder[F]), !Ce.capDrawn && Ce.bonds.length < 4 && (B = 2), oe != Te ? (ee = new _.Vector3().addVectors(ae, pe).multiplyScalar(0.5), se(a, ae, ee, T, oe, R, 0), se(a, ee, pe, T, Te, 0, B)) : se(a, ae, pe, T, oe, R, B), P = p.clickable || p.hoverable, z = Ce.clickable || Ce.hoverable, P || z) {
+ if (ee || (ee = new _.Vector3().addVectors(ae, pe).multiplyScalar(0.5)), P) {
+ var we = new f.Cylinder(ae, ee, T), ke = new f.Sphere(ae, T);
+ p.intersectionShape.cylinder.push(we), p.intersectionShape.sphere.push(ke);
+ }
+ if (z) {
+ var Ue = new f.Cylinder(pe, ee, T), Ne = new f.Sphere(pe, T);
+ Ce.intersectionShape.cylinder.push(Ue), Ce.intersectionShape.sphere.push(Ne);
+ }
+ }
+ } else if (p.bondOrder[F] > 1) {
+ var Be = 0, ue = 0;
+ T != g && (Be = 2, ue = 2);
+ var ye = pe.clone(), ge = null;
+ ye.sub(ae);
+ var Se, ze, He, We, Y;
+ ge = this.getSideBondV(p, Ce, F), p.bondOrder[F] == 2 ? (Se = T * M, ge.multiplyScalar(Se * 1.5), ze = ae.clone(), ze.add(ge), He = ae.clone(), He.sub(ge), We = ze.clone(), We.add(ye), Y = He.clone(), Y.add(ye), oe != Te ? (ee = new _.Vector3().addVectors(ze, We).multiplyScalar(0.5), ne = new _.Vector3().addVectors(He, Y).multiplyScalar(0.5), se(a, ze, ee, Se, oe, Be, 0), se(a, ee, We, Se, Te, 0, ue), se(a, He, ne, Se, oe, Be, 0), se(a, ne, Y, Se, Te, 0, ue)) : (se(a, ze, We, Se, oe, Be, ue), se(a, He, Y, Se, oe, Be, ue)), P = p.clickable || p.hoverable, z = Ce.clickable || Ce.hoverable, (P || z) && (ee || (ee = new _.Vector3().addVectors(ze, We).multiplyScalar(0.5)), ne || (ne = new _.Vector3().addVectors(He, Y).multiplyScalar(0.5)), P && (k = new f.Cylinder(ze, ee, Se), G = new f.Cylinder(He, ne, Se), p.intersectionShape.cylinder.push(k), p.intersectionShape.cylinder.push(G)), z && (U = new f.Cylinder(We, ee, Se), V = new f.Cylinder(Y, ne, Se), Ce.intersectionShape.cylinder.push(U), Ce.intersectionShape.cylinder.push(V)))) : p.bondOrder[F] == 3 && (Se = T * L, ge.cross(ye), ge.normalize(), ge.multiplyScalar(Se * 3), ze = ae.clone(), ze.add(ge), He = ae.clone(), He.sub(ge), We = ze.clone(), We.add(ye), Y = He.clone(), Y.add(ye), oe != Te ? (ee = new _.Vector3().addVectors(ze, We).multiplyScalar(0.5), ne = new _.Vector3().addVectors(He, Y).multiplyScalar(0.5), me = new _.Vector3().addVectors(ae, pe).multiplyScalar(0.5), se(a, ze, ee, Se, oe, Be, 0), se(a, ee, We, Se, Te, 0, ue), se(a, ae, me, Se, oe, R, 0), se(a, me, pe, Se, Te, 0, B), se(a, He, ne, Se, oe, Be, 0), se(a, ne, Y, Se, Te, 0, ue)) : (se(a, ze, We, Se, oe, Be, ue), se(a, ae, pe, Se, oe, R, B), se(a, He, Y, Se, oe, Be, ue)), P = p.clickable || p.hoverable, z = Ce.clickable || Ce.hoverable, (P || z) && (ee || (ee = new _.Vector3().addVectors(ze, We).multiplyScalar(0.5)), ne || (ne = new _.Vector3().addVectors(He, Y).multiplyScalar(0.5)), me || (me = new _.Vector3().addVectors(ae, pe).multiplyScalar(0.5)), P && (k = new f.Cylinder(ze.clone(), ee.clone(), Se), G = new f.Cylinder(He.clone(), ne.clone(), Se), H = new f.Cylinder(ae.clone(), me.clone(), Se), p.intersectionShape.cylinder.push(k), p.intersectionShape.cylinder.push(G), p.intersectionShape.cylinder.push(H)), z && (U = new f.Cylinder(We.clone(), ee.clone(), Se), V = new f.Cylinder(Y.clone(), ne.clone(), Se), Q = new f.Cylinder(pe.clone(), me.clone(), Se), Ce.intersectionShape.cylinder.push(U), Ce.intersectionShape.cylinder.push(V), Ce.intersectionShape.cylinder.push(Q))));
+ }
+ }
+ }
+ var K = !1, q = 0, de = !1;
+ for (F = 0; F < p.bonds.length; F++)
+ N = D, p.bondStyles && p.bondStyles[F] && ($ = p.bondStyles[F], $.singleBond && (N = !0), $.radius && $.radius != g && (de = !0)), (N || p.bondOrder[F] == 1) && q++;
+ de ? q > 0 && (K = !0) : q == 0 && (p.bonds.length > 0 || l.showNonBonded) && (K = !0), K && (T = g, a.imposter ? this.drawSphereImposter(a.sphereGeometry, p, T, oe) : h.GLDraw.drawSphere(a, p, T, oe));
+ }
+ }
+ }
+ // go through all the atoms and regenerate their geometries
+ // we try to have one geometry for each style since this is much much
+ // faster
+ // at some point we should optimize this to avoid unnecessary
+ // recalculation
+ /** param {AtomSpec[]} atoms */
+ createMolObj(p, v) {
+ v = v || {};
+ var a = new s.Object3D(), l = [], g = {}, M = {}, L = this.drawAtomSphere, T = null, D = null;
+ v.supportsImposters ? (L = this.drawAtomImposter, T = new s.Geometry(!0), T.imposter = !0, D = new s.Geometry(!0, !0), D.imposter = !0, D.sphereGeometry = new s.Geometry(!0), D.sphereGeometry.imposter = !0, D.drawnCaps = {}) : v.supportsAIA ? (L = this.drawAtomInstanced, T = new s.Geometry(!1, !0, !0), T.instanced = !0, D = new s.Geometry(!0)) : (T = new s.Geometry(!0), D = new s.Geometry(!0));
+ var R, B, P, z, F = {}, N = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY];
+ for (R = 0, P = p.length; R < P; R++) {
+ var $ = p[R];
+ if ($ && $.style) {
+ ($.clickable || $.hoverable) && $.intersectionShape === void 0 && ($.intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }), z = { line: void 0, cross: void 0, stick: void 0, sphere: void 0 };
+ for (B in z)
+ $.style[B] ? $.style[B].opacity ? z[B] = parseFloat($.style[B].opacity) : z[B] = 1 : z[B] = void 0, F[B] ? z[B] != null && F[B] != z[B] && (console.log("Warning: " + B + " opacity is ambiguous"), F[B] = 1) : F[B] = z[B];
+ L.call(this, $, T), this.drawAtomClickSphere($), this.drawAtomCross($, M), this.drawBondLines($, p, g), this.drawBondSticks($, p, D), typeof $.style.cartoon < "u" && !$.style.cartoon.hidden && ($.style.cartoon.color === "spectrum" && typeof $.resi == "number" && !$.hetflag && ($.resi < N[0] && (N[0] = $.resi), $.resi > N[1] && (N[1] = $.resi)), l.push($));
+ }
+ }
+ if (l.length > 0 && (0, u.drawCartoon)(a, l, N, this.defaultCartoonQuality), T && T.vertices > 0) {
+ T.initTypedArrays();
+ var k = null, G = null;
+ T.imposter ? k = new s.SphereImposterMaterial({
+ ambient: 0,
+ vertexColors: !0,
+ reflectivity: 0
+ }) : T.instanced ? (G = new s.Geometry(!0), h.GLDraw.drawSphere(G, { x: 0, y: 0, z: 0 }, 1, new x.Color(0.5, 0.5, 0.5)), G.initTypedArrays(), k = new s.InstancedMaterial({
+ sphereMaterial: new s.MeshLambertMaterial({
+ ambient: 0,
+ vertexColors: !0,
+ reflectivity: 0
+ }),
+ sphere: G
+ })) : k = new s.MeshLambertMaterial({
+ ambient: 0,
+ vertexColors: !0,
+ reflectivity: 0
+ }), F.sphere < 1 && F.sphere >= 0 && (k.transparent = !0, k.opacity = F.sphere), G = new s.Mesh(T, k), a.add(G);
+ }
+ if (D.vertices > 0) {
+ var H = null, U = null, V = D.sphereGeometry;
+ (!V || typeof V.vertices > "u" || V.vertices == 0) && (V = null), D.initTypedArrays(), V && V.initTypedArrays();
+ var Q = { ambient: 0, vertexColors: !0, reflectivity: 0 };
+ D.imposter ? (H = new s.StickImposterMaterial(Q), U = new s.SphereImposterMaterial(Q)) : (H = new s.MeshLambertMaterial(Q), U = new s.MeshLambertMaterial(Q), H.wireframe && (D.setUpWireframe(), V && V.setUpWireframe())), F.stick < 1 && F.stick >= 0 && (H.transparent = !0, H.opacity = F.stick, U.transparent = !0, U.opacity = F.stick);
+ var oe = new s.Mesh(D, H);
+ if (a.add(oe), V) {
+ var ee = new s.Mesh(V, U);
+ a.add(ee);
+ }
+ }
+ var ne;
+ for (R in g)
+ if (g.hasOwnProperty(R)) {
+ ne = R;
+ var me = new s.LineBasicMaterial({
+ linewidth: ne,
+ vertexColors: !0
+ });
+ F.line < 1 && F.line >= 0 && (me.transparent = !0, me.opacity = F.line), g[R].initTypedArrays();
+ var se = new s.Line(g[R], me, s.LineStyle.LinePieces);
+ a.add(se);
+ }
+ for (R in M)
+ if (M.hasOwnProperty(R)) {
+ ne = R;
+ var fe = new s.LineBasicMaterial({
+ linewidth: ne,
+ vertexColors: !0
+ });
+ F.cross < 1 && F.cross >= 0 && (fe.transparent = !0, fe.opacity = F.cross), M[R].initTypedArrays();
+ var Ce = new s.Line(M[R], fe, s.LineStyle.LinePieces);
+ a.add(Ce);
+ }
+ if (this.dontDuplicateAtoms && this.modelData.symmetries && this.modelData.symmetries.length > 0) {
+ var Me = new s.Object3D(), Te;
+ for (Te = 0; Te < this.modelData.symmetries.length; Te++) {
+ var ae = new s.Object3D();
+ ae = a.clone(), ae.matrix.copy(this.modelData.symmetries[Te]), ae.matrixAutoUpdate = !1, Me.add(ae);
+ }
+ return Me;
+ }
+ return a;
+ }
+ /**
+ * Return object representing internal state of
+ * the model appropriate for passing to setInternalState
+ *
+ */
+ getInternalState() {
+ return {
+ atoms: this.atoms,
+ frames: this.frames
+ };
+ }
+ /**
+ * Overwrite the internal model state with the passed state.
+ *
+ */
+ setInternalState(p) {
+ this.atoms = p.atoms, this.frames = p.frames, this.molObj = null;
+ }
+ /**
+ * Returns crystallographic information if present.
+ *
+ *
+ */
+ getCrystData() {
+ if (this.modelData.cryst) {
+ if (!this.modelData.cryst.matrix) {
+ const p = this.modelData.cryst;
+ this.modelData.cryst.matrix = (0, _.conversionMatrix3)(p.a, p.b, p.c, p.alpha, p.beta, p.gamma);
+ }
+ return this.modelData.cryst;
+ } else
+ return null;
+ }
+ /**
+ * Set crystallographic information using three angles and three lengths
+ *
+ * @param {number} a - length of unit cell side
+ * @param {number} b - length of unit cell side
+ * @param {number} c - length of unit cell side
+ * @param {number} alpha - unit cell angle in degrees (default 90)
+ * @param {number} beta - unit cell angle in degrees (default 90)
+ * @param {number} gamma - unit cell angle in degrees (default 90)
+
+ */
+ setCrystData(p, v, a, l, g, M) {
+ p = p || 1, v = v || 1, a = a || 1, l = l || 90, g = g || 90, M = M || 90;
+ const L = (0, _.conversionMatrix3)(p, v, a, l, g, M);
+ this.modelData.cryst = {
+ a: p,
+ b: v,
+ c: a,
+ alpha: l,
+ beta: g,
+ gamma: M,
+ matrix: L
+ };
+ }
+ /**
+ * Set the crystallographic matrix to the given matrix.
+ *
+ * This function removes `a`, `b`, `c`, `alpha`, `beta`, `gamma` from
+ * the crystal data.
+ *
+ * @param {Matrix3} matrix - unit cell matrix
+ */
+ setCrystMatrix(p) {
+ p = p || new _.Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), this.modelData.cryst = {
+ matrix: p
+ };
+ }
+ /**
+ * Returns list of rotational/translational matrices if there is BIOMT data
+ * Otherwise returns a list of just the ID matrix
+ *
+ * @return {Array}
+ *
+ */
+ getSymmetries() {
+ return typeof this.modelData.symmetries > "u" && (this.modelData.symmetries = [this.idMatrix]), this.modelData.symmetries;
+ }
+ /**
+ * Sets symmetries based on specified matrices in list
+ *
+ * @param {Array} list
+ *
+ */
+ setSymmetries(p) {
+ typeof p > "u" ? this.modelData.symmetries = [this.idMatrix] : this.modelData.symmetries = p;
+ }
+ /**
+ * Returns model id number
+ *
+ * @return {number} Model ID
+ */
+ getID() {
+ return this.id;
+ }
+ /**
+ * Returns model's frames property, a list of atom lists
+ *
+ * @return {number}
+ */
+ getNumFrames() {
+ return this.frames.numFrames != null ? this.frames.numFrames : this.frames.length;
+ }
+ adjustCoord(p, v, a, l) {
+ var g = v - p;
+ return g < -a ? v + l : g > a ? v - l : v;
+ }
+ //go over current atoms in depth first order and ensure that connected
+ //attoms aren't split across the box
+ adjustCoordinatesToBox() {
+ if (this.box && this.atomdfs)
+ for (var p = this.box[0], v = this.box[1], a = this.box[2], l = p * 0.9, g = v * 0.9, M = a * 0.9, L = 0; L < this.atomdfs.length; L++)
+ for (var T = this.atomdfs[L], D = 1; D < T.length; D++) {
+ var R = this.atoms[T[D][0]], B = this.atoms[T[D][1]];
+ R.x = this.adjustCoord(B.x, R.x, l, p), R.y = this.adjustCoord(B.y, R.y, g, v), R.z = this.adjustCoord(B.z, R.z, M, a);
+ }
+ }
+ /**
+ * Sets model's atomlist to specified frame
+ * Sets to last frame if framenum out of range
+ *
+ * @param {number} framenum - model's atoms are set to this index in frames list
+ * @return {Promise}
+ */
+ setFrame(p, v) {
+ var a = this.getNumFrames();
+ let l = this;
+ return new Promise(function(g, M) {
+ if (a == 0 && g(), (p < 0 || p >= a) && (p = a - 1), l.frames.url != null) {
+ var L = l.frames.url;
+ (0, E.getbin)(L + "/traj/frame/" + p + "/" + l.frames.path, void 0, "POST", void 0).then(function(T) {
+ for (var D = new Float32Array(T, 44), R = 0, B = 0; B < l.atoms.length; B++)
+ l.atoms[B].x = D[R++], l.atoms[B].y = D[R++], l.atoms[B].z = D[R++];
+ l.box && l.atomdfs && l.adjustCoordinatesToBox(), g();
+ }).catch(M);
+ } else
+ l.atoms = l.frames[p], g();
+ l.molObj = null, l.modelDatas && p < l.modelDatas.length && (l.modelData = l.modelDatas[p], l.unitCellObjects && v && (v.removeUnitCell(l), v.addUnitCell(l)));
+ });
+ }
+ /**
+ * Add atoms as frames of model
+ *
+ * @param {AtomSpec[]} atoms - atoms to be added
+ */
+ addFrame(p) {
+ this.frames.push(p);
+ }
+ /**
+ * If model atoms have dx, dy, dz properties (in some xyz files), vibrate populates the model's frame property based on parameters.
+ * Model can then be animated
+ *
+ * @param {number} numFrames - number of frames to be created, default to 10
+ * @param {number} amplitude - amplitude of distortion, default to 1 (full)
+ * @param {boolean} bothWays - if true, extend both in positive and negative directions by numFrames
+ * @param {GLViewer} viewer - required if arrowSpec is provided
+ * @param {ArrowSpec} arrowSpec - specification for drawing animated arrows. If color isn't specified, atom color (sphere, stick, line preference) is used.
+ *@example
+
+ $3Dmol.download("pdb:4UAA",viewer,{},function(){
+ viewer.setStyle({},{stick:{}});
+ viewer.vibrate(10, 1);
+ viewer.animate({loop: "forward",reps: 1});
+
+ viewer.zoomTo();
+ viewer.render();
+ });
+ */
+ vibrate(p = 10, v = 1, a = !1, l, g) {
+ var M = 0, L = p;
+ a && (M = -p, L = p), this.frames !== void 0 && this.frames.origIndex !== void 0 ? this.setFrame(this.frames.origIndex) : this.setFrame(0), M < L && (this.frames = []), a && (this.frames.origIndex = p);
+ for (var T = M; T < L; T++) {
+ var D = [], R = this.frames.length;
+ if (T == 0 && !g) {
+ this.frames.push(this.atoms);
+ continue;
+ }
+ for (var B = 0; B < this.atoms.length; B++) {
+ var P = (0, E.getAtomProperty)(this.atoms[B], "dx"), z = (0, E.getAtomProperty)(this.atoms[B], "dy"), F = (0, E.getAtomProperty)(this.atoms[B], "dz"), N = new _.Vector3(P, z, F), $ = new _.Vector3(this.atoms[B].x, this.atoms[B].y, this.atoms[B].z), k = T * v / p;
+ N.multiplyScalar(k), $.add(N);
+ var G = {};
+ for (var H in this.atoms[B])
+ G[H] = this.atoms[B][H];
+ if (G.x = $.x, G.y = $.y, G.z = $.z, D.push(G), l && g) {
+ var U = (0, E.extend)({}, g), V = new _.Vector3(P, z, F);
+ if (V.multiplyScalar(v), V.add($), U.start = $, U.end = V, U.frame = R, !U.color) {
+ var Q = G.style.sphere;
+ Q || (Q = G.style.stick), Q || (Q = G.style.line), U.color = (0, E.getColorFromStyle)(G, Q);
+ }
+ l.addArrow(U);
+ }
+ }
+ this.frames.push(D);
+ }
+ }
+ // set default style and colors for atoms
+ setAtomDefaults(p) {
+ for (let v = 0; v < p.length; v++) {
+ let a = p[v];
+ a && (a.style = a.style || (0, E.deepCopy)(o.defaultAtomStyle), a.color = a.color || this.ElementColors[a.elem] || this.defaultColor, a.model = this.id, (a.clickable || a.hoverable) && (a.intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }));
+ }
+ }
+ /** add atoms to this model from molecular data string
+ *
+ * @param {string|ArrayBuffer} data - atom structure file input data string, for gzipped input use ArrayBuffer
+ * @param {string} format - input file string format (e.g 'pdb', 'sdf', 'sdf.gz', etc.)
+ * @param {ParserOptionsSpec} options - format dependent options. Attributes depend on the input format
+ */
+ addMolData(p, v, a = {}) {
+ var l = o.parseMolData(p, v, a);
+ this.dontDuplicateAtoms = !a.duplicateAssemblyAtoms;
+ var g = l.modelData;
+ if (g && (Array.isArray(g) ? (this.modelData = g[0], a.frames && (this.modelDatas = g)) : this.modelData = g), l.box ? this.box = l.box : this.box = null, this.frames.length == 0) {
+ for (let L = 0; L < l.length; L++)
+ l[L].length != 0 && this.frames.push(l[L]);
+ this.frames[0] && (this.atoms = this.frames[0]);
+ } else if (a.frames)
+ for (let L = 0; L < l.length; L++)
+ this.frames.push(l[L]);
+ else
+ for (var M = 0; M < l.length; M++)
+ this.addAtoms(l[M]);
+ for (let L = 0; L < this.frames.length; L++)
+ this.setAtomDefaults(this.frames[L]);
+ a.vibrate && a.vibrate.frames && a.vibrate.amplitude && this.vibrate(a.vibrate.frames, a.vibrate.amplitude), a.style && this.setStyle({}, a.style);
+ }
+ setDontDuplicateAtoms(p) {
+ this.dontDuplicateAtoms = p;
+ }
+ setModelData(p) {
+ this.modelData = p;
+ }
+ //return true if atom value matches property val
+ propertyMatches(p, v) {
+ if (p == v)
+ return !0;
+ if (typeof v == "string" && typeof p == "number") {
+ var a = v.match(/(-?\d+)\s*-\s*(-?\d+)/);
+ if (a) {
+ var l = parseInt(a[1]), g = parseInt(a[2]);
+ if (a && p >= l && p <= g)
+ return !0;
+ }
+ }
+ return !1;
+ }
+ // make a deep copy of a selection object and create caches of expensive
+ // selections. We create a copy so caches are not attached to user
+ // supplied objects where the user might change them invalidating the cache.
+ // This does not support arbitrary
+ // javascript objects, but support enough for eveything that is
+ // used in selections: number, string, boolean, functions; as well
+ // as arrays and nested objects with values of the aformentioned
+ // types.
+ static deepCopyAndCache(p, v) {
+ if (typeof p != "object" || p == null || p.__cache_created)
+ return p;
+ const a = {};
+ for (const l in p) {
+ const g = p[l];
+ if (Array.isArray(g)) {
+ a[l] = [];
+ for (let M = 0; M < g.length; M++)
+ a[l].push(o.deepCopyAndCache(g[M], v));
+ } else
+ typeof g == "object" && l != "properties" && l != "model" ? a[l] = o.deepCopyAndCache(g, v) : a[l] = g;
+ if (l == "and" || l == "or") {
+ const M = [];
+ for (const L of a[l]) {
+ const T = /* @__PURE__ */ new Set();
+ for (const D of v.selectedAtoms(L))
+ T.add(D.index);
+ M.push(T);
+ }
+ if (l == "and") {
+ const L = function(D, R) {
+ const B = /* @__PURE__ */ new Set();
+ for (const P of R)
+ D.has(P) && B.add(P);
+ return B;
+ };
+ let T = new Set(M[0]);
+ for (const D of M.splice(1))
+ T = L(T, D);
+ a[l].__cached_results = T;
+ } else if (l == "or") {
+ const L = /* @__PURE__ */ new Set();
+ for (const T of M)
+ for (const D of T)
+ L.add(D);
+ a[l].__cached_results = L;
+ }
+ }
+ }
+ return a.__cache_created = !0, a;
+ }
+ /** given a selection specification, return true if atom is selected.
+ * Does not support context-aware selectors like expand/within/byres.
+ *
+ * @param {AtomSpec} atom
+ * @param {AtomSelectionSpec} sel
+ * @return {boolean}
+ */
+ atomIsSelected(p, v) {
+ if (typeof v > "u")
+ return !0;
+ var a = !!v.invert, l = !0;
+ for (var g in v)
+ if (g == "and" || g == "or" || g == "not") {
+ if (g == "not") {
+ if (this.atomIsSelected(p, v[g])) {
+ l = !1;
+ break;
+ }
+ } else if (v[g].__cached_results === void 0 && (v = o.deepCopyAndCache(v, this)), l = v[g].__cached_results.has(p.index), !l)
+ break;
+ } else if (g === "predicate") {
+ if (!v.predicate(p)) {
+ l = !1;
+ break;
+ }
+ } else if (g == "properties" && p[g]) {
+ for (var M in v.properties)
+ if (!M.startsWith("__cache")) {
+ if (typeof p.properties[M] > "u") {
+ l = !1;
+ break;
+ }
+ if (p.properties[M] != v.properties[M]) {
+ l = !1;
+ break;
+ }
+ }
+ } else if (v.hasOwnProperty(g) && !o.ignoredKeys.has(g) && !g.startsWith("__cache")) {
+ if (typeof p[g] > "u") {
+ l = !1;
+ break;
+ }
+ var L = !1;
+ if (g === "bonds") {
+ var T = v[g];
+ if (T != p.bonds.length) {
+ l = !1;
+ break;
+ }
+ } else if (Array.isArray(v[g])) {
+ var D = v[g], R = p[g];
+ for (let B = 0; B < D.length; B++)
+ if (this.propertyMatches(R, D[B])) {
+ L = !0;
+ break;
+ }
+ if (!L) {
+ l = !1;
+ break;
+ }
+ } else {
+ let B = v[g];
+ if (!this.propertyMatches(p[g], B)) {
+ l = !1;
+ break;
+ }
+ }
+ }
+ return a ? !l : l;
+ }
+ static squaredDistance(p, v) {
+ var a = v.x - p.x, l = v.y - p.y, g = v.z - p.z;
+ return a * a + l * l + g * g;
+ }
+ /** returns a list of atoms in the expanded bounding box, but not in the current one
+ *
+ * Bounding box:
+ *
+ * [ [ xmin, ymin, zmin ],
+ * [ xmax, ymax, zmax ],
+ * [ xctr, yctr, zctr ] ]
+ *
+ **/
+ expandAtomList(p, v) {
+ if (v <= 0)
+ return p;
+ for (var a = (0, E.getExtent)(p, void 0), l = [[], [], []], g = 0; g < 3; g++)
+ l[0][g] = a[0][g] - v, l[1][g] = a[1][g] + v, l[2][g] = a[2][g];
+ var M = [];
+ for (let R = 0; R < this.atoms.length; R++) {
+ var L = this.atoms[R].x, T = this.atoms[R].y, D = this.atoms[R].z;
+ L >= l[0][0] && L <= l[1][0] && T >= l[0][1] && T <= l[1][1] && D >= l[0][2] && D <= l[1][2] && (L >= a[0][0] && L <= a[1][0] && T >= a[0][1] && T <= a[1][1] && D >= a[0][2] && D <= a[1][2] || M.push(this.atoms[R]));
+ }
+ return M;
+ }
+ static getFloat(p) {
+ return typeof p == "number" ? p : parseFloat(p);
+ }
+ /** return list of atoms selected by sel, this is specific to glmodel
+ *
+ * @param {AtomSelectionSpec} sel
+ * @return {Object[]}
+ * @example
+ $3Dmol.download("pdb:4wwy",viewer,{},function(){
+ var atoms = viewer.selectedAtoms({chain:'A'});
+ for(var i = 0, n = atoms.length; i < n; i++) {
+ atoms[i].b = 0.0;
+ }
+ viewer.setStyle({cartoon:{colorscheme:{prop:'b',gradient: 'roygb',min:0,max:30}}});
+ viewer.render();
+ });
+ */
+ selectedAtoms(p, v) {
+ var a = [];
+ p = o.deepCopyAndCache(p || {}, this), v || (v = this.atoms);
+ for (var l = v.length, g = 0; g < l; g++) {
+ var M = v[g];
+ M && this.atomIsSelected(M, p) && a.push(M);
+ }
+ if (p.hasOwnProperty("expand")) {
+ const G = o.getFloat(p.expand);
+ let H = this.expandAtomList(a, G), U = a.length;
+ const V = G * G;
+ for (let Q = 0; Q < H.length; Q++)
+ for (let oe = 0; oe < U; oe++) {
+ var L = o.squaredDistance(H[Q], a[oe]);
+ L < V && L > 0 && a.push(H[Q]);
+ }
+ }
+ if (p.hasOwnProperty("within") && p.within.hasOwnProperty("sel") && p.within.hasOwnProperty("distance")) {
+ var T = this.selectedAtoms(p.within.sel, this.atoms), D = {};
+ const G = o.getFloat(p.within.distance), H = G * G;
+ for (let U = 0; U < T.length; U++)
+ for (let V = 0; V < a.length; V++) {
+ let Q = o.squaredDistance(T[U], a[V]);
+ Q < H && Q > 0 && (D[V] = 1);
+ }
+ var R = [];
+ if (p.within.invert)
+ for (let U = 0; U < a.length; U++)
+ D[U] || R.push(a[U]);
+ else
+ for (let U in D)
+ R.push(a[U]);
+ a = R;
+ }
+ if (p.hasOwnProperty("byres")) {
+ var B = {}, P = [], z = [];
+ for (let G = 0; G < a.length; G++) {
+ let H = a[G];
+ var F = H.chain, N = H.resi;
+ if (B[F] === void 0 && (B[F] = {}), H.hasOwnProperty("resi") && B[F][N] === void 0) {
+ for (B[F][N] = !0, z.push(H); z.length > 0; )
+ if (H = z.pop(), F = H.chain, N = H.resi, P[H.index] === void 0) {
+ P[H.index] = !0;
+ for (var $ = 0; $ < H.bonds.length; $++) {
+ var k = this.atoms[H.bonds[$]];
+ P[k.index] === void 0 && k.hasOwnProperty("resi") && k.chain == F && k.resi == N && (z.push(k), a.push(k));
+ }
+ }
+ }
+ }
+ }
+ return a;
+ }
+ /** Add list of new atoms to model. Adjusts bonds appropriately.
+ *
+ * @param {AtomSpec[]} newatoms
+ * @example
+ * var atoms = [{elem: 'C', x: 0, y: 0, z: 0, bonds: [1,2], bondOrder: [1,2]}, {elem: 'O', x: -1.5, y: 0, z: 0, bonds: [0]},{elem: 'O', x: 1.5, y: 0, z: 0, bonds: [0], bondOrder: [2]}];
+
+ viewer.setBackgroundColor(0xffffffff);
+ var m = viewer.addModel();
+ m.addAtoms(atoms);
+ m.setStyle({},{stick:{}});
+ viewer.zoomTo();
+ viewer.render();
+ */
+ addAtoms(p) {
+ this.molObj = null;
+ var v = this.atoms.length, a = [], l;
+ for (l = 0; l < p.length; l++)
+ typeof p[l].index > "u" && (p[l].index = l), typeof p[l].serial > "u" && (p[l].serial = l), a[p[l].index] = v + l;
+ for (l = 0; l < p.length; l++) {
+ var g = p[l], M = a[g.index], L = (0, E.extend)({}, g);
+ L.index = M, L.bonds = [], L.bondOrder = [], L.model = this.id, L.style = L.style || (0, E.deepCopy)(o.defaultAtomStyle), typeof L.color > "u" && (L.color = this.ElementColors[L.elem] || this.defaultColor);
+ for (var T = g.bonds ? g.bonds.length : 0, D = 0; D < T; D++) {
+ var R = a[g.bonds[D]];
+ typeof R < "u" && (L.bonds.push(R), L.bondOrder.push(g.bondOrder ? g.bondOrder[D] : 1));
+ }
+ this.atoms.push(L);
+ }
+ }
+ /** Assign bonds based on atomic coordinates.
+ * This currently uses a primitive distance-based algorithm that does not
+ * consider valence constraints and will only create single bonds.
+ */
+ assignBonds() {
+ (0, S.assignBonds)(this.atoms);
+ }
+ /** Remove specified atoms from model
+ *
+ * @param {AtomSpec[]} badatoms - list of atoms
+ */
+ removeAtoms(p) {
+ this.molObj = null;
+ var v = [], a;
+ for (a = 0; a < p.length; a++)
+ v[p[a].index] = !0;
+ var l = [];
+ for (a = 0; a < this.atoms.length; a++) {
+ var g = this.atoms[a];
+ v[g.index] || l.push(g);
+ }
+ this.atoms = [], this.addAtoms(l);
+ }
+ /** Set atom style of selected atoms
+ *
+ * @param {AtomSelectionSpec} sel
+ * @param {AtomStyleSpec} style
+ * @param {boolean} add - if true, add to current style, don't replace
+ @example
+ $3Dmol.download("pdb:4UB9",viewer,{},function(){
+ viewer.setBackgroundColor(0xffffffff);
+
+ viewer.setStyle({chain:'A'},{line:{hidden:true,colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.Sinebow($3Dmol.getPropertyRange(viewer.selectedAtoms(),'b'))}}});
+ viewer.setStyle({chain:'B'},{line:{colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.Sinebow($3Dmol.getPropertyRange(viewer.selectedAtoms(),'b'))}}});
+ viewer.setStyle({chain:'C'},{cross:{hidden:true,colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.Sinebow($3Dmol.getPropertyRange(viewer.selectedAtoms(),'b'))}}});
+ viewer.setStyle({chain:'D'},{cross:{colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.RWB($3Dmol.getPropertyRange(viewer.selectedAtoms(),'b'))}}});
+ viewer.setStyle({chain:'E'},{cross:{radius:2.0,colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.RWB($3Dmol.getPropertyRange(viewer.selectedAtoms(),'b'))}}});
+ viewer.setStyle({chain:'F'},{stick:{hidden:true,colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.RWB($3Dmol.getPropertyRange(viewer.selectedAtoms(),'b'))}}});
+ viewer.setStyle({chain:'G'},{stick:{radius:0.8,colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.ROYGB($3Dmol.getPropertyRange(viewer.selectedAtoms(),'b'))}}});
+ viewer.setStyle({chain:'H'},{stick:{singleBonds:true,colorscheme:{prop:'b',gradient: new $3Dmol.Gradient.ROYGB($3Dmol.getPropertyRange(viewer.selectedAtoms(),'b'))}}});
+ viewer.render();
+ });
+ */
+ setStyle(p, v, a) {
+ typeof v > "u" && typeof a > "u" && (v = p, p = {}), p = p, typeof v == "string" && (v = (0, E.specStringToObject)(v));
+ var l = !1, g = this, M = function(T) {
+ var D = g.selectedAtoms(p, T);
+ for (let R = 0; R < T.length; R++)
+ T[R] && (T[R].capDrawn = !1);
+ for (let R = 0; R < D.length; R++) {
+ l = !0, (D[R].clickable || D[R].hoverable) && (D[R].intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }), a || (D[R].style = {});
+ for (let B in v)
+ v.hasOwnProperty(B) && (D[R].style[B] = D[R].style[B] || {}, Object.assign(D[R].style[B], v[B]));
+ }
+ };
+ if (p.frame !== void 0 && p.frame < this.frames.length) {
+ let T = p.frame;
+ T < 0 && (T = this.frames.length + T), M(this.frames[T]);
+ } else {
+ M(this.atoms);
+ for (var L = 0; L < this.frames.length; L++)
+ this.frames[L] !== this.atoms && M(this.frames[L]);
+ }
+ l && (this.molObj = null);
+ }
+ /** Set clickable and callback of selected atoms
+ *
+ * @param {AtomSelectionSpec} sel - atom selection to apply clickable settings to
+ * @param {boolean} clickable - whether click-handling is enabled for the selection
+ * @param {function} callback - function called when an atom in the selection is clicked
+
+ */
+ setClickable(p, v, a) {
+ if (v = !!v, a = (0, E.makeFunction)(a), a === null) {
+ console.log("Callback is not a function");
+ return;
+ }
+ var l = this.selectedAtoms(p, this.atoms), g = l.length;
+ for (let M = 0; M < g; M++)
+ l[M].intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }, l[M].clickable = v, a && (l[M].callback = a);
+ g > 0 && (this.molObj = null);
+ }
+ /** Set hoverable and callback of selected atoms
+ *
+ * @param {AtomSelectionSpec} sel - atom selection to apply hoverable settings to
+ * @param {boolean} hoverable - whether hover-handling is enabled for the selection
+ * @param {function} hover_callback - function called when an atom in the selection is hovered over
+ * @param {function} unhover_callback - function called when the mouse moves out of the hover area
+ */
+ setHoverable(p, v, a, l) {
+ if (v = !!v, a = (0, E.makeFunction)(a), l = (0, E.makeFunction)(l), a === null) {
+ console.log("Hover_callback is not a function");
+ return;
+ }
+ if (l === null) {
+ console.log("Unhover_callback is not a function");
+ return;
+ }
+ var g = this.selectedAtoms(p, this.atoms), M = g.length;
+ for (let L = 0; L < M; L++)
+ g[L].intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }, g[L].hoverable = v, a && (g[L].hover_callback = a), l && (g[L].unhover_callback = l);
+ M > 0 && (this.molObj = null);
+ }
+ /** enable context menu of selected atoms
+ *
+ * @param {AtomSelectionSpec} sel - atom selection to apply hoverable settings to
+ * @param {boolean} contextMenuEnabled - whether contextMenu-handling is enabled for the selection
+ */
+ enableContextMenu(p, v) {
+ v = !!v;
+ var a, l = this.selectedAtoms(p, this.atoms), g = l.length;
+ for (a = 0; a < g; a++)
+ l[a].intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }, l[a].contextMenuEnabled = v;
+ g > 0 && (this.molObj = null);
+ }
+ /** given a mapping from element to color, set atom colors
+ *
+ * @param {AtomSelectionSpec} sel
+ * @param {object} colors
+ */
+ setColorByElement(p, v) {
+ if (!(this.molObj !== null && o.sameObj(v, this.lastColors))) {
+ this.lastColors = v;
+ var a = this.selectedAtoms(p, a);
+ a.length > 0 && (this.molObj = null);
+ for (var l = 0; l < a.length; l++) {
+ var g = a[l];
+ typeof v[g.elem] < "u" && (g.color = v[g.elem]);
+ }
+ }
+ }
+ /**
+ * @param {AtomSelectionSpec} sel
+ * @param {string} prop
+ * @param {Gradient|string} scheme
+ */
+ setColorByProperty(p, v, a, l) {
+ var g, M, L = this.selectedAtoms(p, L);
+ for (this.lastColors = null, L.length > 0 && (this.molObj = null), typeof a == "string" && typeof c.Gradient.builtinGradients[a] < "u" && (a = new c.Gradient.builtinGradients[a]()), a = a, l || (l = a.range()), l || (l = (0, E.getPropertyRange)(L, v)), g = 0; g < L.length; g++) {
+ M = L[g];
+ var T = (0, E.getAtomProperty)(M, v);
+ T != null && (M.color = a.valueToHex(parseFloat(M.properties[v]), l));
+ }
+ }
+ /**
+ * @deprecated use setStyle and colorfunc attribute
+ * @param {AtomSelectionSpec} sel - selection object
+ * @param {function} func - function to be used to set the color
+ @example
+ $3Dmol.download("pdb:4UAA",viewer,{},function(){
+ viewer.setBackgroundColor(0xffffffff);
+ var colorAsSnake = function(atom) {
+ return atom.resi % 2 ? 'white': 'green'
+ };
+
+ viewer.setStyle( {}, { cartoon: {colorfunc: colorAsSnake }});
+
+ viewer.render();
+ });
+
+ */
+ setColorByFunction(p, v) {
+ var a = this.selectedAtoms(p, a);
+ if (typeof v == "function") {
+ this.lastColors = null, a.length > 0 && (this.molObj = null);
+ for (let l = 0; l < a.length; l++) {
+ let g = a[l];
+ g.color = v(g);
+ }
+ }
+ }
+ /** Convert the model into an object in the format of a ChemDoodle JSON model.
+ *
+ * @param {boolean} whether or not to include style information. Defaults to false.
+ * @return {Object}
+ */
+ toCDObject(p = !1) {
+ var v = { a: [], b: [] };
+ p && (v.s = []);
+ for (let l = 0; l < this.atoms.length; l++) {
+ let g = {}, M = this.atoms[l];
+ if (g.x = M.x, g.y = M.y, g.z = M.z, M.elem != "C" && (g.l = M.elem), p) {
+ for (var a = 0; a < v.s.length && JSON.stringify(M.style) !== JSON.stringify(v.s[a]); )
+ a++;
+ a === v.s.length && v.s.push(M.style), a !== 0 && (g.s = a);
+ }
+ v.a.push(g);
+ for (let L = 0; L < M.bonds.length; L++) {
+ let T = l, D = M.bonds[L];
+ if (T >= D)
+ continue;
+ let R = {
+ b: T,
+ e: D
+ }, B = M.bondOrder[L];
+ B != 1 && (R.o = B), v.b.push(R);
+ }
+ }
+ return v;
+ }
+ /** manage the globj for this model in the possed modelGroup - if it has to be regenerated, remove and add
+ *
+ * @param {Object3D} group
+ * @param Object options
+ */
+ globj(p, v) {
+ (this.molObj === null || v.regen) && (this.molObj = this.createMolObj(this.atoms, v), this.renderedMolObj && (p.remove(this.renderedMolObj), this.renderedMolObj = null), this.renderedMolObj = this.molObj.clone(), this.hidden && (this.renderedMolObj.setVisible(!1), this.molObj.setVisible(!1)), p.add(this.renderedMolObj));
+ }
+ /** return a VRML string representation of the model. Does not include VRML header information
+ * @return VRML
+ */
+ exportVRML() {
+ var p = this.createMolObj(this.atoms, { supportsImposters: !1, supportsAIA: !1 });
+ return p.vrml();
+ }
+ /** Remove any renderable mol object from scene
+ *
+ * @param {Object3D} group
+ */
+ removegl(p) {
+ this.renderedMolObj && (this.renderedMolObj.geometry !== void 0 && this.renderedMolObj.geometry.dispose(), this.renderedMolObj.material !== void 0 && this.renderedMolObj.material.dispose(), p.remove(this.renderedMolObj), this.renderedMolObj = null), this.molObj = null;
+ }
+ /**
+ * Don't show this model in future renderings. Keep all styles and state
+ * so it can be efficiencly shown again.
+ *
+ * * @see GLModel#show
+
+ * @example
+ $3Dmol.download("pdb:3ucr",viewer,{},function(){
+ viewer.setStyle({},{stick:{}});
+ viewer.getModel().hide();
+ viewer.render();
+ });
+ */
+ hide() {
+ this.hidden = !0, this.renderedMolObj && this.renderedMolObj.setVisible(!1), this.molObj && this.molObj.setVisible(!1);
+ }
+ /**
+ * Unhide a hidden model
+ * @see GLModel#hide
+ * @example
+ $3Dmol.download("pdb:3ucr",viewer,{},function(){
+ viewer.setStyle({},{stick:{}});
+ viewer.getModel().hide();
+ viewer.render( )
+ viewer.getModel().show()
+ viewer.render();
+ });
+ */
+ show() {
+ this.hidden = !1, this.renderedMolObj && this.renderedMolObj.setVisible(!0), this.molObj && this.molObj.setVisible(!0);
+ }
+ /** Create labels for atoms that show the value of the passed property.
+ *
+ * @param {String} prop - property name
+ * @param {AtomSelectionSpec} sel
+ * @param {GLViewer} viewer
+ * @param {LabelSpec} options
+ */
+ addPropertyLabels(p, v, a, l) {
+ for (var g = this.selectedAtoms(v, g), M = (0, E.deepCopy)(l), L = 0; L < g.length; L++) {
+ var T = g[L], D = null;
+ typeof T[p] < "u" ? D = String(T[p]) : typeof T.properties[p] < "u" && (D = String(T.properties[p])), D != null && (M.position = T, a.addLabel(D, M));
+ }
+ }
+ /** Create labels for residues of selected atoms.
+ * Will create a single label at the center of mass of all atoms
+ * with the same chain,resn, and resi.
+ *
+ * @param {AtomSelectionSpec} sel
+ * @param {GLViewer} viewer
+ * @param {LabelSpec} options
+ * @param {boolean} byframe - if true, create labels for every individual frame, not just current; frames must be loaded already
+ */
+ addResLabels(p, v, a, l = !1) {
+ var g = [], M = function(T, D) {
+ for (var R = T.selectedAtoms(p, R), B = {}, P = 0; P < R.length; P++) {
+ var z = R[P], F = z.chain, N = z.resn, $ = z.resi, k = N + "" + $;
+ B[F] || (B[F] = {}), B[F][k] || (B[F][k] = []), B[F][k].push(z);
+ }
+ var G = (0, E.deepCopy)(a);
+ for (let U in B)
+ if (B.hasOwnProperty(U)) {
+ var H = B[U];
+ for (let V in H)
+ if (H.hasOwnProperty(V)) {
+ let Q = H[V], oe = new _.Vector3(0, 0, 0);
+ for (let ne = 0; ne < Q.length; ne++) {
+ let me = Q[ne];
+ oe.x += me.x, oe.y += me.y, oe.z += me.z;
+ }
+ oe.divideScalar(Q.length), G.position = oe, G.frame = D;
+ let ee = v.addLabel(V, G, void 0, !0);
+ g.push(ee);
+ }
+ }
+ };
+ if (l) {
+ var L = this.getNumFrames();
+ let T = this.atoms;
+ for (let D = 0; D < L; D++)
+ this.frames[D] && (this.atoms = this.frames[D], M(this, D));
+ this.atoms = T;
+ } else
+ M(this);
+ return g;
+ }
+ //recurse over the current atoms to establish a depth first order
+ setupDFS() {
+ this.atomdfs = [];
+ var p = this, v = new Int8Array(this.atoms.length);
+ v.fill(0);
+ for (var a = function(L, T, D) {
+ D.push([L, T]);
+ var R = p.atoms[L];
+ v[L] = 1;
+ for (var B = 0; B < R.bonds.length; B++) {
+ var P = R.bonds[B];
+ p.atoms[P] && !v[P] && a(P, L, D);
+ }
+ }, l = 0; l < this.atoms.length; l++) {
+ var g = this.atoms[l];
+ if (g && !v[l]) {
+ var M = [];
+ a(l, -1, M), this.atomdfs.push(M);
+ }
+ }
+ }
+ /**
+ * Set coordinates from remote trajectory file.
+ * @param {string} url - contains the url where mdsrv has been hosted
+ * @param {string} path - contains the path of the file (/filename)
+ * @return {Promise}
+ */
+ setCoordinatesFromURL(p, v) {
+ this.frames = [];
+ var a = this;
+ return this.box && this.setupDFS(), p.startsWith("http") || (p = "http://" + p), (0, E.get)(p + "/traj/numframes/" + v, function(l) {
+ if (!isNaN(parseInt(l)))
+ return a.frames.push(a.atoms), a.frames.numFrames = l, a.frames.url = p, a.frames.path = v, a.setFrame(0);
+ });
+ }
+ /**
+ * Set coordinates for the atoms from provided trajectory file.
+ * @param {string|ArrayBuffer} str - contains the data of the file
+ * @param {string} format - contains the format of the file (mdcrd, inpcrd, pdb, netcdf, or array). Arrays should be TxNx3 where T is the number of timesteps and N the number of atoms.
+ @example
+ let m = viewer.addModel() //create an empty model
+ m.addAtoms([{x:0,y:0,z:0,elem:'C'},{x:2,y:0,z:0,elem:'C'}]) //provide a list of dictionaries representing the atoms
+ viewer.setStyle({'sphere':{}})
+ m.setCoordinates([[[0.0, 0.0, 0.0], [2.0, 0.0, 0.0]], [[0.0, 0.0, 0.0], [2.8888888359069824, 0.0, 0.0]], [[0.0, 0.0, 0.0], [3.777777671813965, 0.0, 0.0]], [[0.0, 0.0, 0.0], [4.666666507720947, 0.0, 0.0]], [[0.0, 0.0, 0.0], [5.55555534362793, 0.0, 0.0]], [[0.0, 0.0, 0.0], [6.44444465637207, 0.0, 0.0]], [[0.0, 0.0, 0.0], [7.333333492279053, 0.0, 0.0]], [[0.0, 0.0, 0.0], [8.222222328186035, 0.0, 0.0]], [[0.0, 0.0, 0.0], [9.11111068725586, 0.0, 0.0]], [[0.0, 0.0, 0.0], [10.0, 0.0, 0.0]]],'array');
+ viewer.animate({loop: "forward",reps: 1});
+ viewer.zoomTo();
+ viewer.zoom(0.5);
+ viewer.render();
+ */
+ setCoordinates(p, v) {
+ if (v = v || "", !p)
+ return [];
+ if (/\.gz$/.test(v)) {
+ v = v.replace(/\.gz$/, "");
+ try {
+ p = n(p);
+ } catch (B) {
+ console.log(B);
+ }
+ }
+ var a = { mdcrd: "", inpcrd: "", pdb: "", netcdf: "", array: "" };
+ if (a.hasOwnProperty(v)) {
+ this.frames = [];
+ for (var l = this.atoms.length, g = o.parseCrd(p, v), M = 0; M < g.length; ) {
+ for (var L = [], T = 0; T < l; T++) {
+ var D = {};
+ for (var R in this.atoms[T])
+ D[R] = this.atoms[T][R];
+ L[T] = D, L[T].x = g[M++], L[T].y = g[M++], L[T].z = g[M++];
+ }
+ this.frames.push(L);
+ }
+ return this.atoms = this.frames[0], this.frames;
+ }
+ return [];
+ }
+ /**
+ * add atomSpecs to validAtomSelectionSpecs
+ * @deprecated
+ * @param {Array} customAtomSpecs - array of strings that can be used as atomSelectionSpecs
+ * this is to prevent the 'Unknown Selector x' message on the console for the strings passed.
+ * These messages are no longer generated as, in theory, typescript will catch problems at compile time.
+ * In practice, there may still be issues at run-time but we don't check for them...
+ *
+ * What we should do is use something like https://github.com/woutervh-/typescript-is to do runtime
+ * type checking, but it currently doesn't work with our types...
+ */
+ addAtomSpecs(p) {
+ }
+ static parseCrd(p, v) {
+ var a = [], l = 0;
+ if (v == "pdb")
+ for (var g = p.indexOf(`
+ATOM`); g != -1; ) {
+ for (; p.slice(g, g + 5) == `
+ATOM` || p.slice(g, g + 7) == `
+HETATM`; )
+ a[l++] = parseFloat(p.slice(g + 31, g + 39)), a[l++] = parseFloat(p.slice(g + 39, g + 47)), a[l++] = parseFloat(p.slice(g + 47, g + 55)), g = p.indexOf(`
+`, g + 54), p.slice(g, g + 4) == `
+TER` && (g = p.indexOf(`
+`, g + 5));
+ g = p.indexOf(`
+ATOM`, g);
+ }
+ else if (v == "netcdf") {
+ var M = new b.NetCDFReader(p);
+ a = [].concat.apply([], M.getDataVariable("coordinates"));
+ } else {
+ if (v == "array" || Array.isArray(p))
+ return p.flat(2);
+ {
+ let L = p.indexOf(`
+`);
+ v == "inpcrd" && (L = p.indexOf(`
+`, L + 1)), p = p.slice(L + 1), a = p.match(/\S+/g).map(parseFloat);
+ }
+ }
+ return a;
+ }
+ static parseMolData(p, v = "", a) {
+ if (!p)
+ return [];
+ if (/\.gz$/.test(v)) {
+ v = v.replace(/\.gz$/, "");
+ try {
+ p = n(p);
+ } catch (M) {
+ console.log(M);
+ }
+ }
+ typeof C.Parsers[v] > "u" && (v = v.split(".").pop(), typeof C.Parsers[v] > "u" && (console.log("Unknown format: " + v), p instanceof Uint8Array ? v = "mmtf" : p.match(/^@MOLECULE/gm) ? v = "mol2" : p.match(/^data_/gm) && p.match(/^loop_/gm) ? v = "cif" : p.match(/^HETATM/gm) || p.match(/^ATOM/gm) ? v = "pdb" : p.match(/ITEM: TIMESTEP/gm) ? v = "lammpstrj" : p.match(/^.*\n.*\n.\s*(\d+)\s+(\d+)/gm) ? v = "sdf" : p.match(/^%VERSION\s+VERSION_STAMP/gm) ? v = "prmtop" : v = "xyz", console.log("Best guess: " + v)));
+ var l = C.Parsers[v], g = l(p, a);
+ return g;
+ }
+ }
+ o.defaultAtomStyle = {
+ line: {}
+ }, o.defaultlineWidth = 1, o.vdwRadii = {
+ H: 1.2,
+ He: 1.4,
+ Li: 1.82,
+ Be: 1.53,
+ B: 1.92,
+ C: 1.7,
+ N: 1.55,
+ O: 1.52,
+ F: 1.47,
+ Ne: 1.54,
+ Na: 2.27,
+ Mg: 1.73,
+ Al: 1.84,
+ Si: 2.1,
+ P: 1.8,
+ S: 1.8,
+ Cl: 1.75,
+ Ar: 1.88,
+ K: 2.75,
+ Ca: 2.31,
+ Ni: 1.63,
+ Cu: 1.4,
+ Zn: 1.39,
+ Ga: 1.87,
+ Ge: 2.11,
+ As: 1.85,
+ Se: 1.9,
+ Br: 1.85,
+ Kr: 2.02,
+ Rb: 3.03,
+ Sr: 2.49,
+ Pd: 1.63,
+ Ag: 1.72,
+ Cd: 1.58,
+ In: 1.93,
+ Sn: 2.17,
+ Sb: 2.06,
+ Te: 2.06,
+ I: 1.98,
+ Xe: 2.16,
+ Cs: 3.43,
+ Ba: 2.68,
+ Pt: 1.75,
+ Au: 1.66,
+ Hg: 1.55,
+ Tl: 1.96,
+ Pb: 2.02,
+ Bi: 2.07,
+ Po: 1.97,
+ At: 2.02,
+ Rn: 2.2,
+ Fr: 3.48,
+ Ra: 2.83,
+ U: 1.86
+ }, o.ignoredKeys = /* @__PURE__ */ new Set(["props", "invert", "model", "frame", "byres", "expand", "within", "and", "or", "not"]);
+ }
+ ),
+ /***/
+ "./src/GLShape.ts": (
+ /*!************************!*\
+ !*** ./src/GLShape.ts ***!
+ \************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ GLShape: () => (
+ /* binding */
+ b
+ ),
+ /* harmony export */
+ splitMesh: () => (
+ /* binding */
+ A
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! ./WebGL */
+ "./src/WebGL/index.ts"
+ ), f = t(
+ /*! ./WebGL/shapes */
+ "./src/WebGL/shapes/index.ts"
+ ), _ = t(
+ /*! ./WebGL/math */
+ "./src/WebGL/math/index.ts"
+ ), x = t(
+ /*! ./colors */
+ "./src/colors.ts"
+ ), h = t(
+ /*! ./ProteinSurface4 */
+ "./src/ProteinSurface4.ts"
+ ), u = t(
+ /*! ./VolumeData */
+ "./src/VolumeData.ts"
+ ), E = t(
+ /*! ./GLDraw */
+ "./src/GLDraw.ts"
+ ), c = t(
+ /*! ./glcartoon */
+ "./src/glcartoon.ts"
+ ), C = t(
+ /*! ./utilities */
+ "./src/utilities.ts"
+ );
+ class b {
+ static finalizeGeo(n) {
+ var o = n.updateGeoGroup(0);
+ o.vertices > 0 && o.truncateArrayBuffers(!0, !0);
+ }
+ /*
+ *
+ * @param {Geometry}
+ * geo
+ * @param {Color | colorlike} color
+ */
+ static updateColor(n, o) {
+ o = o || x.CC.color(o), n.colorsNeedUpdate = !0;
+ var w, p, v;
+ o.constructor !== Array && (w = o.r, p = o.g, v = o.b);
+ for (let a in n.geometryGroups) {
+ let l = n.geometryGroups[a], g = l.colorArray;
+ for (let M = 0, L = l.vertices; M < L; ++M) {
+ if (o.constructor === Array) {
+ let T = o[M];
+ w = T.r, p = T.g, v = T.b;
+ }
+ g[M * 3] = w, g[M * 3 + 1] = p, g[M * 3 + 2] = v;
+ }
+ }
+ }
+ /*
+ * @param {GLShape}
+ * shape
+ * @param {geometryGroup}
+ * geoGroup
+ * @param {ArrowSpec}
+ * spec
+ */
+ static drawArrow(n, o, w) {
+ var p = w.start, v = w.end, a = w.radius, l = w.radiusRatio, g = w.mid, M = w.midpos;
+ if (!(p && v))
+ return;
+ var L = o.updateGeoGroup(51), T = new _.Vector3(v.x, v.y, v.z).sub(p);
+ if (M) {
+ let he = T.length();
+ M > 0 ? g = M / he : g = (he + M) / he;
+ }
+ T.multiplyScalar(g);
+ var D = new _.Vector3(p.x, p.y, p.z).add(T), R = T.clone().negate();
+ let B = new _.Vector3(p.x, p.y, p.z);
+ n.intersectionShape.cylinder.push(new f.Cylinder(B, D.clone(), a)), n.intersectionShape.sphere.push(new f.Sphere(B, a));
+ var P = [];
+ P[0] = T.clone(), Math.abs(P[0].x) > 1e-4 ? P[0].y += 1 : P[0].x += 1, P[0].cross(T), P[0].normalize(), P[4] = P[0].clone(), P[4].crossVectors(P[0], T), P[4].normalize(), P[8] = P[0].clone().negate(), P[12] = P[4].clone().negate(), P[2] = P[0].clone().add(P[4]).normalize(), P[6] = P[4].clone().add(P[8]).normalize(), P[10] = P[8].clone().add(P[12]).normalize(), P[14] = P[12].clone().add(P[0]).normalize(), P[1] = P[0].clone().add(P[2]).normalize(), P[3] = P[2].clone().add(P[4]).normalize(), P[5] = P[4].clone().add(P[6]).normalize(), P[7] = P[6].clone().add(P[8]).normalize(), P[9] = P[8].clone().add(P[10]).normalize(), P[11] = P[10].clone().add(P[12]).normalize(), P[13] = P[12].clone().add(P[14]).normalize(), P[15] = P[14].clone().add(P[0]).normalize();
+ var z = L.vertices, F = L.vertexArray, N = L.faceArray, $ = L.normalArray, k = L.lineArray, G, H, U;
+ for (H = 0, U = P.length; H < U; ++H) {
+ G = 3 * (z + 3 * H);
+ var V = P[H].clone().multiplyScalar(a).add(p), Q = P[H].clone().multiplyScalar(a).add(D), oe = P[H].clone().multiplyScalar(a * l).add(D);
+ if (F[G] = V.x, F[G + 1] = V.y, F[G + 2] = V.z, F[G + 3] = Q.x, F[G + 4] = Q.y, F[G + 5] = Q.z, F[G + 6] = oe.x, F[G + 7] = oe.y, F[G + 8] = oe.z, H > 0) {
+ var ee = F[G - 3], ne = F[G - 2], me = F[G - 1], se = new _.Vector3(ee, ne, me), fe = new _.Vector3(v.x, v.y, v.z), Ce = D.clone(), Me = new _.Vector3(oe.x, oe.y, oe.z);
+ n.intersectionShape.triangle.push(new f.Triangle(Me, fe, se)), n.intersectionShape.triangle.push(new f.Triangle(se.clone(), Ce, Me.clone()));
+ }
+ }
+ L.vertices += 48, G = L.vertices * 3, F[G] = p.x, F[G + 1] = p.y, F[G + 2] = p.z, F[G + 3] = D.x, F[G + 4] = D.y, F[G + 5] = D.z, F[G + 6] = v.x, F[G + 7] = v.y, F[G + 8] = v.z, L.vertices += 3;
+ var Te, ae, pe, we, ke, Ue, Ne, Be, ue, ye, ge, Se, ze, He, We, Y, K, q, de, ve = L.vertices - 3, Ie = L.vertices - 2, Re = L.vertices - 1, Z = ve * 3, ce = Ie * 3, Ae = Re * 3;
+ for (H = 0, U = P.length - 1; H < U; ++H) {
+ var Fe = z + 3 * H;
+ G = Fe * 3, ae = L.faceidx, pe = L.lineidx, we = Fe, ye = we * 3, ke = Fe + 1, ge = ke * 3, Ue = Fe + 2, Se = Ue * 3, Ne = Fe + 4, ze = Ne * 3, Be = Fe + 5, He = Be * 3, ue = Fe + 3, We = ue * 3, Y = K = P[H], q = de = P[H + 1], $[ye] = Y.x, $[ge] = K.x, $[We] = de.x, $[ye + 1] = Y.y, $[ge + 1] = K.y, $[We + 1] = de.y, $[ye + 2] = Y.z, $[ge + 2] = K.z, $[We + 2] = de.z, $[ge] = K.x, $[ze] = q.x, $[We] = de.x, $[ge + 1] = K.y, $[ze + 1] = q.y, $[We + 1] = de.y, $[ge + 2] = K.z, $[ze + 2] = q.z, $[We + 2] = de.z, $[Se] = K.x, $[He] = q.x, $[Se + 1] = K.y, $[He + 1] = q.y, $[Se + 2] = K.z, $[He + 2] = q.z, N[ae] = we, N[ae + 1] = ke, N[ae + 2] = ue, N[ae + 3] = ke, N[ae + 4] = Ne, N[ae + 5] = ue, N[ae + 6] = we, N[ae + 7] = ue, N[ae + 8] = ve, N[ae + 9] = Ue, N[ae + 10] = Ie, N[ae + 11] = Be, N[ae + 12] = Ue, N[ae + 13] = Re, N[ae + 14] = Be, k[pe] = we, k[pe + 1] = ke, k[pe + 2] = we, k[pe + 3] = ue, k[pe + 4] = Ne, k[pe + 5] = ue, k[pe + 6] = we, k[pe + 7] = ue, k[pe + 8] = Ue, k[pe + 9] = ke, k[pe + 10] = Ue, k[pe + 11] = Be, k[pe + 12] = Ne, k[pe + 13] = Be, k[pe + 14] = Ue, k[pe + 15] = Re, k[pe + 16] = Ue, k[pe + 17] = Be, k[pe + 18] = Re, k[pe + 19] = Be, L.faceidx += 15, L.lineidx += 20;
+ }
+ Te = [
+ z + 45,
+ z + 46,
+ z + 1,
+ z,
+ z + 47,
+ z + 2
+ ], ae = L.faceidx, pe = L.lineidx, we = Te[0], ye = we * 3, ke = Te[1], ge = ke * 3, Ue = Te[4], Se = Ue * 3, Ne = Te[2], ze = Ne * 3, Be = Te[5], He = Be * 3, ue = Te[3], We = ue * 3, Y = K = P[15], q = de = P[0], $[ye] = Y.x, $[ge] = K.x, $[We] = de.x, $[ye + 1] = Y.y, $[ge + 1] = K.y, $[We + 1] = de.y, $[ye + 2] = Y.z, $[ge + 2] = K.z, $[We + 2] = de.z, $[ge] = K.x, $[ze] = q.x, $[We] = de.x, $[ge + 1] = K.y, $[ze + 1] = q.y, $[We + 1] = de.y, $[ge + 2] = K.z, $[ze + 2] = q.z, $[We + 2] = de.z, $[Se] = K.x, $[He] = q.x, $[Se + 1] = K.y, $[He + 1] = q.y, $[Se + 2] = K.z, $[He + 2] = q.z, T.normalize(), R.normalize(), $[Z] = R.x, $[ce] = $[Ae] = T.x, $[Z + 1] = R.y, $[ce + 1] = $[Ae + 1] = T.y, $[Z + 2] = R.z, $[ce + 2] = $[Ae + 2] = T.z, N[ae] = we, N[ae + 1] = ke, N[ae + 2] = ue, N[ae + 3] = ke, N[ae + 4] = Ne, N[ae + 5] = ue, N[ae + 6] = we, N[ae + 7] = ue, N[ae + 8] = ve, N[ae + 9] = Ue, N[ae + 10] = Ie, N[ae + 11] = Be, N[ae + 12] = Ue, N[ae + 13] = Re, N[ae + 14] = Be, k[pe] = we, k[pe + 1] = ke, k[pe + 2] = we, k[pe + 3] = ue, k[pe + 4] = Ne, k[pe + 5] = ue, k[pe + 6] = we, k[pe + 7] = ue, k[pe + 8] = Ue, k[pe + 9] = ke, k[pe + 10] = Ue, k[pe + 11] = Be, k[pe + 12] = Ne, k[pe + 13] = Be, k[pe + 14] = Ue, k[pe + 15] = Re, k[pe + 16] = Ue, k[pe + 17] = Be, k[pe + 18] = Re, k[pe + 19] = Be, L.faceidx += 15, L.lineidx += 20;
+ }
+ // Update a bounding sphere's position and radius
+ // from list of centroids and new points
+ /*
+ * @param {Sphere}
+ * sphere
+ * @param {Object}
+ * components, centroid of all objects in shape
+ * @param {Array}
+ * points, flat array of all points in shape
+ * @param {int} numPoints, number of valid poitns in points
+ */
+ static updateBoundingFromPoints(n, o, w, p) {
+ n.center.set(0, 0, 0);
+ let v = 1 / 0, a = 1 / 0, l = 1 / 0, g = -1 / 0, M = -1 / 0, L = -1 / 0;
+ n.box && (v = n.box.min.x, g = n.box.max.x, a = n.box.min.y, M = n.box.max.y, l = n.box.min.z, L = n.box.max.z);
+ for (let B = 0, P = p; B < P; B++) {
+ var T = w[B * 3], D = w[B * 3 + 1], R = w[B * 3 + 2];
+ T < v && (v = T), D < a && (a = D), R < l && (l = R), T > g && (g = T), D > M && (M = D), R > L && (L = R);
+ }
+ n.center.set((g + v) / 2, (M + a) / 2, (L + l) / 2), n.radius = n.center.distanceTo({ x: g, y: M, z: L }), n.box = { min: { x: v, y: a, z: l }, max: { x: g, y: M, z: L } };
+ }
+ //helper function for adding an appropriately sized mesh
+ static addCustomGeo(n, o, w, p, v) {
+ var a = o.addGeoGroup(), l = w.vertexArr, g = w.normalArr, M = w.faceArr;
+ a.vertices = l.length, a.faceidx = M.length;
+ var L, T, D, R, B, P, z, F, N, $ = a.vertexArray, k = a.colorArray;
+ for (p.constructor !== Array && (F = p.r, N = p.g, R = p.b), P = 0, z = a.vertices; P < z; ++P)
+ L = P * 3, T = l[P], $[L] = T.x, $[L + 1] = T.y, $[L + 2] = T.z, p.constructor === Array && (B = p[P], F = B.r, N = B.g, R = B.b), k[L] = F, k[L + 1] = N, k[L + 2] = R;
+ if (v)
+ for (P = 0, z = a.faceidx / 3; P < z; ++P) {
+ L = P * 3, D = M[L], R = M[L + 1], B = M[L + 2];
+ var G = new _.Vector3(), H = new _.Vector3(), U = new _.Vector3();
+ n.intersectionShape.triangle.push(new f.Triangle(G.copy(l[D]), H.copy(l[R]), U.copy(l[B])));
+ }
+ if (v) {
+ var V = new _.Vector3(0, 0, 0), Q = 0;
+ for (let ne = 0; ne < o.geometryGroups.length; ne++)
+ V.add(o.geometryGroups[ne].getCentroid()), Q++;
+ V.divideScalar(Q), b.updateBoundingFromPoints(n.boundingSphere, { centroid: V }, $, a.vertices);
+ }
+ if (a.faceArray = new Uint16Array(M), a.truncateArrayBuffers(!0, !0), g.length < a.vertices)
+ a.setNormals();
+ else {
+ var oe = a.normalArray = new Float32Array(a.vertices * 3), ee;
+ for (P = 0, z = a.vertices; P < z; ++P)
+ L = P * 3, ee = g[P], oe[L] = ee.x, oe[L + 1] = ee.y, oe[L + 2] = ee.z;
+ }
+ a.setLineIndices(), a.lineidx = a.lineArray.length;
+ }
+ /*
+ *
+ * @param {$3Dmol.GLShape}
+ * shape
+ * @param {ShapeSpec}
+ * stylespec
+ * @returns {undefined}
+ */
+ static updateFromStyle(n, o) {
+ typeof o.color < "u" ? (n.color = o.color || new x.Color(), o.color instanceof x.Color || (n.color = x.CC.color(o.color))) : n.color = x.CC.color(0), n.wireframe = !!o.wireframe, n.opacity = o.alpha ? (0, _.clamp)(o.alpha, 0, 1) : 1, typeof o.opacity < "u" && (n.opacity = (0, _.clamp)(o.opacity, 0, 1)), n.side = o.side !== void 0 ? o.side : s.DoubleSide, n.linewidth = typeof o.linewidth > "u" ? 1 : o.linewidth, n.clickable = !!o.clickable, n.callback = (0, C.makeFunction)(o.callback), n.hoverable = !!o.hoverable, n.hover_callback = (0, C.makeFunction)(o.hover_callback), n.unhover_callback = (0, C.makeFunction)(o.unhover_callback), n.hidden = o.hidden, n.frame = o.frame;
+ }
+ /**
+ * Custom renderable shape
+ *
+ * @constructor
+ *
+ * @param {ShapeSpec} stylespec
+ */
+ constructor(n) {
+ this.color = 16777215, this.hidden = !1, this.wireframe = !1, this.opacity = 1, this.linewidth = 1, this.clickable = !1, this.hoverable = !1, this.side = s.DoubleSide, this.stylespec = n || {}, this.boundingSphere = new f.Sphere(), this.intersectionShape = {
+ sphere: [],
+ cylinder: [],
+ line: [],
+ triangle: []
+ }, b.updateFromStyle(this, this.stylespec), this.components = [], this.shapeObj = null, this.renderedShapeObj = null, this.geo = new s.Geometry(!0), this.linegeo = new s.Geometry(!0);
+ }
+ /** Update shape with new style specification
+ * @param {ShapeSpec} newspec
+ @example
+ let sphere = viewer.addSphere({center:{x:0,y:0,z:0},radius:10.0,color:'red'});
+ sphere.updateStyle({color:'yellow',opacity:0.5});
+ viewer.render();
+ */
+ updateStyle(n) {
+ for (var o in n)
+ this.stylespec[o] = n[o];
+ if (b.updateFromStyle(this, this.stylespec), n.voldata && n.volscheme) {
+ (0, C.adjustVolumeStyle)(n);
+ const w = n.volscheme, p = n.voldata, v = x.CC, a = w.range() || [-1, 1];
+ this.geo.setColors(function(l, g, M) {
+ let L = p.getVal(l, g, M);
+ return v.color(w.valueToHex(L, a));
+ }), delete this.color;
+ }
+ }
+ /**
+ * Creates a custom shape from supplied vertex and face arrays
+ * @param {CustomShapeSpec} customSpec
+ */
+ addCustom(n) {
+ n.vertexArr = n.vertexArr || [], n.faceArr = n.faceArr || [], n.normalArr = n.normalArr || [], b.drawCustom(this, this.geo, n);
+ }
+ /**
+ * Creates a sphere shape
+ * @param {SphereSpec} sphereSpec
+ @example
+ viewer.addSphere({center:{x:0,y:0,z:0},radius:10.0,color:'red'});
+
+ viewer.render();
+ */
+ addSphere(n) {
+ n.center || (n.center = new _.Vector3(0, 0, 0)), n.radius = n.radius ? (0, _.clamp)(n.radius, 0, 1 / 0) : 1.5, n.color = x.CC.color(n.color), this.intersectionShape.sphere.push(new f.Sphere(n.center, n.radius)), E.GLDraw.drawSphere(this.geo, n.center, n.radius, n.color, n.quality), this.components.push({
+ centroid: new _.Vector3(n.center.x, n.center.y, n.center.z)
+ });
+ var o = this.geo.updateGeoGroup(0);
+ b.updateBoundingFromPoints(this.boundingSphere, this.components, o.vertexArray, o.vertices);
+ }
+ /**
+ * Creates a box
+ * @param {BoxSpec} boxSpec
+ @example
+ var shape = viewer.addShape({color:'red'});
+ shape.addBox({corner: {x:1,y:2,z:0}, dimensions: {w: 4, h: 2, d: 6}});
+ shape.addBox({corner: {x:-5,y:-3,z:0},
+ dimensions: { w: {x:1,y:1,z:0},
+ h: {x:-1,y:1,z:0},
+ d: {x:0,y:0,z:1} }});
+ viewer.zoomTo();
+ viewer.rotate(30);
+ viewer.render();
+ */
+ addBox(n) {
+ var o = n.dimensions || { w: 1, h: 1, d: 1 }, w;
+ typeof o.w == "number" ? w = { x: o.w, y: 0, z: 0 } : w = o.w;
+ var p;
+ typeof o.h == "number" ? p = { x: 0, y: o.h, z: 0 } : p = o.h;
+ var v;
+ typeof o.d == "number" ? v = { x: 0, y: 0, z: o.d } : v = o.d;
+ var a = n.corner;
+ a == null && (n.center !== void 0 ? a = {
+ x: n.center.x - 0.5 * (w.x + p.x + v.x),
+ y: n.center.y - 0.5 * (w.y + p.y + v.y),
+ z: n.center.z - 0.5 * (w.z + p.z + v.z)
+ } : a = { x: 0, y: 0, z: 0 });
+ var l = [
+ { x: a.x, y: a.y, z: a.z },
+ { x: a.x + w.x, y: a.y + w.y, z: a.z + w.z },
+ { x: a.x + p.x, y: a.y + p.y, z: a.z + p.z },
+ { x: a.x + w.x + p.x, y: a.y + w.y + p.y, z: a.z + w.z + p.z },
+ { x: a.x + v.x, y: a.y + v.y, z: a.z + v.z },
+ { x: a.x + w.x + v.x, y: a.y + w.y + v.y, z: a.z + w.z + v.z },
+ { x: a.x + p.x + v.x, y: a.y + p.y + v.y, z: a.z + p.z + v.z },
+ { x: a.x + w.x + p.x + v.x, y: a.y + w.y + p.y + v.y, z: a.z + w.z + p.z + v.z }
+ ], g = [], M = [];
+ g.splice(g.length, 0, l[0], l[1], l[2], l[3]), M.splice(M.length, 0, 0, 2, 1, 1, 2, 3);
+ var L = 4;
+ g.splice(g.length, 0, l[2], l[3], l[6], l[7]), M.splice(M.length, 0, L + 0, L + 2, L + 1, L + 1, L + 2, L + 3), L += 4, g.splice(g.length, 0, l[4], l[5], l[0], l[1]), M.splice(M.length, 0, L + 0, L + 2, L + 1, L + 1, L + 2, L + 3), L += 4, g.splice(g.length, 0, l[6], l[7], l[4], l[5]), M.splice(M.length, 0, L + 0, L + 2, L + 1, L + 1, L + 2, L + 3), L += 4, g.splice(g.length, 0, l[3], l[1], l[7], l[5]), M.splice(M.length, 0, L + 0, L + 2, L + 1, L + 1, L + 2, L + 3), L += 4, g.splice(g.length, 0, l[2], l[6], l[0], l[4]), M.splice(M.length, 0, L + 0, L + 2, L + 1, L + 1, L + 2, L + 3), L += 4;
+ var T = (0, C.extend)({}, n);
+ T.vertexArr = g, T.faceArr = M, T.normalArr = [], b.drawCustom(this, this.geo, T);
+ var D = new _.Vector3();
+ this.components.push({
+ centroid: D.addVectors(l[0], l[7]).multiplyScalar(0.5)
+ });
+ var R = this.geo.updateGeoGroup(0);
+ b.updateBoundingFromPoints(this.boundingSphere, this.components, R.vertexArray, R.vertices);
+ }
+ /**
+ * Creates a cylinder shape
+ * @param {CylinderSpec} cylinderSpec
+ @example
+ viewer.addCylinder({start:{x:0.0,y:0.0,z:0.0},
+ end:{x:10.0,y:0.0,z:0.0},
+ radius:1.0,
+ fromCap:1,
+ toCap:2,
+ color:'red',
+ hoverable:true,
+ clickable:true,
+ callback:function(){ this.color.setHex(0x00FFFF00);viewer.render( );},
+ hover_callback: function(){ viewer.render( );},
+ unhover_callback: function(){ this.color.setHex(0xFF000000);viewer.render( );}
+ });
+ viewer.addCylinder({start:{x:0.0,y:2.0,z:0.0},
+ end:{x:0.0,y:10.0,z:0.0},
+ radius:0.5,
+ fromCap:false,
+ toCap:true,
+ color:'teal'});
+ viewer.addCylinder({start:{x:15.0,y:0.0,z:0.0},
+ end:{x:20.0,y:0.0,z:0.0},
+ radius:1.0,
+ color:'black',
+ fromCap:false,
+ toCap:false});
+ viewer.render();
+ */
+ addCylinder(n) {
+ var o, w;
+ n.start ? o = new _.Vector3(n.start.x || 0, n.start.y || 0, n.start.z || 0) : o = new _.Vector3(0, 0, 0), n.end ? (w = new _.Vector3(n.end.x, n.end.y || 0, n.end.z || 0), typeof w.x > "u" && (w.x = 3)) : w = new _.Vector3(0, 0, 0);
+ var p = n.radius || 0.1, v = x.CC.color(n.color);
+ this.intersectionShape.cylinder.push(new f.Cylinder(o, w, p)), E.GLDraw.drawCylinder(this.geo, o, w, p, v, n.fromCap, n.toCap);
+ var a = new _.Vector3();
+ this.components.push({
+ centroid: a.addVectors(o, w).multiplyScalar(0.5)
+ });
+ var l = this.geo.updateGeoGroup(0);
+ b.updateBoundingFromPoints(this.boundingSphere, this.components, l.vertexArray, l.vertices);
+ }
+ /**
+ * Creates a dashed cylinder shape
+ * @param {CylinderSpec} cylinderSpec
+ */
+ addDashedCylinder(n) {
+ n.dashLength = n.dashLength || 0.25, n.gapLength = n.gapLength || 0.25;
+ var o;
+ n.start ? o = new _.Vector3(n.start.x || 0, n.start.y || 0, n.start.z || 0) : o = new _.Vector3(0, 0, 0);
+ var w;
+ n.end ? (w = new _.Vector3(n.end.x, n.end.y || 0, n.end.z || 0), typeof w.x > "u" && (w.x = 3)) : w = new _.Vector3(3, 0, 0);
+ for (var p = n.radius || 0.1, v = x.CC.color(n.color), a = Math.sqrt(Math.pow(o.x - w.x, 2) + Math.pow(o.y - w.y, 2) + Math.pow(o.z - w.z, 2)), l = a / (n.gapLength + n.dashLength), g = new _.Vector3(n.start.x || 0, n.start.y || 0, n.start.z || 0), M = new _.Vector3(n.end.x, n.end.y || 0, n.end.z || 0), L = new _.Vector3((w.x - o.x) / (a / n.gapLength), (w.y - o.y) / (a / n.gapLength), (w.z - o.z) / (a / n.gapLength)), T = new _.Vector3((w.x - o.x) / (a / n.dashLength), (w.y - o.y) / (a / n.dashLength), (w.z - o.z) / (a / n.dashLength)), D = 0; D < l; D++)
+ M = new _.Vector3(g.x + T.x, g.y + T.y, g.z + T.z), this.intersectionShape.cylinder.push(new f.Cylinder(g, M, p)), E.GLDraw.drawCylinder(this.geo, g, M, p, v, n.fromCap, n.toCap), g = new _.Vector3(M.x + L.x, M.y + L.y, M.z + L.z);
+ var R = new _.Vector3();
+ this.components.push({
+ centroid: R.addVectors(o, w).multiplyScalar(0.5)
+ });
+ var B = this.geo.updateGeoGroup(0);
+ b.updateBoundingFromPoints(this.boundingSphere, this.components, B.vertexArray, B.vertices);
+ }
+ /**
+ * Creates a curved shape
+ * @param {CurveSpec} curveSpec
+ */
+ addCurve(n) {
+ n.points = n.points || [], n.smooth = n.smooth || 10, typeof n.fromCap > "u" && (n.fromCap = 2), typeof n.toCap > "u" && (n.toCap = 2);
+ var o = (0, c.subdivide_spline)(n.points, n.smooth);
+ if (o.length < 3) {
+ console.log("Too few points in addCurve");
+ return;
+ }
+ var w = n.radius || 0.1, p = x.CC.color(n.color), v = 0, a = o.length - 1, l = o[0].distanceTo(o[1]), g = Math.ceil(2 * w / l);
+ if (n.toArrow) {
+ a -= g;
+ let D = {
+ start: o[a],
+ end: o[o.length - 1],
+ radius: w,
+ color: p,
+ mid: 1e-4
+ };
+ this.addArrow(D);
+ }
+ if (n.fromArrow) {
+ v += g;
+ let D = {
+ start: o[v],
+ end: o[0],
+ radius: w,
+ color: p,
+ mid: 1e-4
+ };
+ this.addArrow(D);
+ }
+ for (var M = Math.ceil(o.length / 2), L = { radius: w, color: p, fromCap: 2, toCap: 2 }, T = v; T < a; T++)
+ L.start = o[T], L.end = o[T + 1], L.fromCap = 2, L.toCap = 2, T < M ? (L.fromCap = 2, L.toCap = 0) : T > M ? (L.fromCap = 0, L.toCap = 2) : (L.fromCap = 2, L.toCap = 2), this.addCylinder(L);
+ }
+ /**
+ * Creates a line shape
+ * @param {LineSpec} lineSpec
+ @example
+ $3Dmol.download("pdb:2ABJ",viewer,{},function(){
+ viewer.addLine({dashed:true,start:{x:0,y:0,z:0},end:{x:100,y:100,z:100}});
+ viewer.render(callback);
+ });
+
+ */
+ addLine(n) {
+ var o, w;
+ n.start ? o = new _.Vector3(n.start.x || 0, n.start.y || 0, n.start.z || 0) : o = new _.Vector3(0, 0, 0), n.end ? (w = new _.Vector3(n.end.x, n.end.y || 0, n.end.z || 0), typeof w.x > "u" && (w.x = 3)) : w = new _.Vector3(3, 0, 0);
+ var p = this.geo.updateGeoGroup(2), v = p.vertices, a = v * 3, l = p.vertexArray;
+ l[a] = o.x, l[a + 1] = o.y, l[a + 2] = o.z, l[a + 3] = w.x, l[a + 4] = w.y, l[a + 5] = w.z, p.vertices += 2;
+ var g = p.lineArray, M = p.lineidx;
+ g[M] = v, g[M + 1] = v + 1, p.lineidx += 2;
+ var L = new _.Vector3();
+ this.components.push({
+ centroid: L.addVectors(o, w).multiplyScalar(0.5)
+ }), p = this.geo.updateGeoGroup(0), b.updateBoundingFromPoints(this.boundingSphere, this.components, p.vertexArray, p.vertices);
+ }
+ /**
+ * Creates an arrow shape
+ * @param {ArrowSpec} arrowSpec
+ @example
+ $3Dmol.download("pdb:4DM7",viewer,{},function(){
+ viewer.setBackgroundColor(0xffffffff);
+ viewer.addArrow({
+ start: {x:-10.0, y:0.0, z:0.0},
+ end: {x:0.0, y:-10.0, z:0.0},
+ radius: 1.0,
+ radiusRadio:1.0,
+ mid:1.0,
+ clickable:true,
+ callback:function(){
+ this.color.setHex(0xFF0000FF);
+ viewer.render( );
+ }
+ });
+ viewer.render();
+ });
+ */
+ addArrow(n) {
+ if (n.start ? n.start = new _.Vector3(n.start.x || 0, n.start.y || 0, n.start.z || 0) : n.start = new _.Vector3(0, 0, 0), n.dir instanceof _.Vector3 && typeof n.length == "number") {
+ var o = n.dir.clone().multiplyScalar(n.length).add(n.start);
+ n.end = o;
+ } else
+ n.end ? (n.end = new _.Vector3(n.end.x, n.end.y || 0, n.end.z || 0), typeof n.end.x > "u" && (n.end.x = 3)) : n.end = new _.Vector3(3, 0, 0);
+ n.radius = n.radius || 0.1, n.radiusRatio = n.radiusRatio || 1.618034, n.mid = 0 < n.mid && n.mid < 1 ? n.mid : 0.618034, b.drawArrow(this, this.geo, n);
+ var w = new _.Vector3();
+ this.components.push({
+ centroid: w.addVectors(n.start, n.end).multiplyScalar(0.5)
+ });
+ var p = this.geo.updateGeoGroup(0);
+ b.updateBoundingFromPoints(this.boundingSphere, this.components, p.vertexArray, p.vertices);
+ }
+ static distance_from(n, o) {
+ return Math.sqrt(Math.pow(n.x - o.x, 2) + Math.pow(n.y - o.y, 2) + Math.pow(n.z - o.z, 2));
+ }
+ static inSelectedRegion(n, o, w) {
+ for (var p = 0; p < o.length; p++)
+ if (b.distance_from(o[p], n) <= w)
+ return !0;
+ return !1;
+ }
+ /**
+ * Create isosurface from voluemetric data.
+ * @param {VolumeData} data - volumetric input data
+ * @param {IsoSurfaceSpec} isoSpec - volumetric data shape specification
+ * @example //the user can specify a selected region for the isosurface
+ $.get('../test_structs/benzene-homo.cube', function(data){
+ var voldata = new $3Dmol.VolumeData(data, "cube");
+ viewer.addIsosurface(voldata, {isoval: 0.01,
+ color: "blue",
+ alpha: 0.5,
+ smoothness: 10});
+ viewer.addIsosurface(voldata, {isoval: -0.01,
+ color: "red",
+ smoothness: 5,
+ opacity:0.5,
+ wireframe:true,
+ clickable:true,
+ callback:
+ function() {
+ this.opacity = 0.0;
+ viewer.render( );
+ }});
+ viewer.setStyle({}, {stick:{}});
+ viewer.zoomTo();
+ viewer.render();
+ });
+ */
+ addIsosurface(n, o, w) {
+ var p = o.isoval !== void 0 && typeof o.isoval == "number" ? o.isoval : 0, v = !!o.voxel, a = o.smoothness === void 0 ? 1 : o.smoothness, l = n.size.x, g = n.size.y, M = n.size.z, L = new Int16Array(l * g * M), T = n.data, D, R;
+ for (D = 0, R = L.length; D < R; ++D)
+ L[D] = -1;
+ var B = new Uint8Array(l * g * M);
+ for (D = 0, R = T.length; D < R; ++D) {
+ var P = p >= 0 ? T[D] - p : p - T[D];
+ P > 0 && (B[D] |= b.ISDONE);
+ }
+ var z = [], F = [];
+ h.MarchingCube.march(B, z, F, {
+ fulltable: !0,
+ voxel: v,
+ unitCube: n.unit,
+ origin: n.origin,
+ matrix: n.matrix,
+ nX: l,
+ nY: g,
+ nZ: M
+ }), !v && a > 0 && h.MarchingCube.laplacianSmooth(a, z, F);
+ var N = [], $ = [], k = [];
+ if (o.selectedRegion && o.coords === void 0 && (o.coords = o.selectedRegion), o.coords !== void 0) {
+ var G = o.coords[0].x, H = o.coords[0].y, U = o.coords[0].z, V = o.coords[0].x, Q = o.coords[0].y, oe = o.coords[0].z;
+ for (let ae = 0; ae < o.coords.length; ae++)
+ o.coords[ae].x > G ? G = o.coords[ae].x : o.coords[ae].x < V && (V = o.coords[ae].x), o.coords[ae].y > H ? H = o.coords[ae].y : o.coords[ae].y < Q && (Q = o.coords[ae].y), o.coords[ae].z > U ? U = o.coords[ae].z : o.coords[ae].z < oe && (oe = o.coords[ae].z);
+ var ee = 2;
+ o.radius !== void 0 && (ee = o.radius), o.selectedOffset !== void 0 && (ee = o.selectedOffset), o.seldist !== void 0 && (ee = o.seldist), V -= ee, G += ee, Q -= ee, H += ee, oe -= ee, U += ee;
+ for (let ae = 0; ae < z.length; ae++)
+ z[ae].x > V && z[ae].x < G && z[ae].y > Q && z[ae].y < H && z[ae].z > oe && z[ae].z < U && b.inSelectedRegion(z[ae], o.coords, ee) ? (N.push($.length), $.push(z[ae])) : N.push(-1);
+ for (let ae = 0; ae + 2 < F.length; ae += 3)
+ N[F[ae]] !== -1 && N[F[ae + 1]] !== -1 && N[F[ae + 2]] !== -1 && (k.push(F[ae] - (F[ae] - N[F[ae]])), k.push(F[ae + 1] - (F[ae + 1] - N[F[ae + 1]])), k.push(F[ae + 2] - (F[ae + 2] - N[F[ae + 2]])));
+ z = $, F = k;
+ }
+ b.drawCustom(this, this.geo, {
+ vertexArr: z,
+ faceArr: F,
+ normalArr: [],
+ clickable: o.clickable,
+ hoverable: o.hoverable
+ }), this.updateStyle(o);
+ var ne = new _.Vector3(n.origin.x, n.origin.y, n.origin.z), me = new _.Vector3(n.size.x * n.unit.x, n.size.y * n.unit.y, n.size.z * n.unit.z), se = new _.Vector3(0, 0, 0), fe = ne.clone(), Ce = ne.clone().add(me);
+ for (let ae = 0; ae < z.length; ae++)
+ se.add(z[ae]), fe.max(z[ae]), Ce.min(z[ae]);
+ se.divideScalar(z.length);
+ var Me = se.distanceTo(Ce), Te = se.distanceTo(fe);
+ this.boundingSphere.center = se, this.boundingSphere.radius = Math.max(Me, Te), typeof w == "function" && w();
+ }
+ /**
+ * @deprecated Use addIsosurface instead
+ * Creates custom shape from volumetric data
+ * @param {string} data - Volumetric input data
+ * @param {string} fmt - Input data format (e.g. 'cube' for cube file format)
+ * @param {IsoSurfaceSpec} isoSpec - Volumetric data shape specification
+ */
+ addVolumetricData(n, o, w) {
+ n = new u.VolumeData(n, o), this.addIsosurface(n, w);
+ }
+ //for internal use, truncate buffers to save memory
+ finalize() {
+ return b.finalizeGeo(this.geo), this.geo.initTypedArrays(), this.geo;
+ }
+ /*
+ * Initialize webgl objects for rendering
+ * @param {$3Dmol.Object3D} group
+ *
+ */
+ globj(n) {
+ if (this.renderedShapeObj && (n.remove(this.renderedShapeObj), this.renderedShapeObj = null), !this.hidden) {
+ b.finalizeGeo(this.geo), this.geo.initTypedArrays(), this.wireframe && this.geo.setUpWireframe(), typeof this.color < "u" && b.updateColor(this.geo, this.color), this.shapeObj = new s.Object3D();
+ var o = null;
+ this.side == s.DoubleSide ? o = new s.MeshDoubleLambertMaterial({
+ wireframe: this.wireframe,
+ side: this.side,
+ transparent: this.opacity < 1,
+ opacity: this.opacity,
+ wireframeLinewidth: this.linewidth,
+ vertexColors: s.Coloring.VertexColors
+ }) : o = new s.MeshLambertMaterial({
+ wireframe: this.wireframe,
+ side: this.side,
+ transparent: this.opacity < 1,
+ opacity: this.opacity,
+ wireframeLinewidth: this.linewidth,
+ vertexColors: s.Coloring.VertexColors
+ });
+ var w = new s.Mesh(this.geo, o);
+ this.shapeObj.add(w);
+ var p = new s.LineBasicMaterial({
+ linewidth: this.linewidth,
+ color: this.color
+ }), v = new s.Line(this.linegeo, p, s.LineStyle.LinePieces);
+ this.shapeObj.add(v), this.renderedShapeObj = this.shapeObj.clone(), n.add(this.renderedShapeObj);
+ }
+ }
+ removegl(n) {
+ this.renderedShapeObj && (this.renderedShapeObj.geometry !== void 0 && this.renderedShapeObj.geometry.dispose(), this.renderedShapeObj.material !== void 0 && this.renderedShapeObj.material.dispose(), n.remove(this.renderedShapeObj), this.renderedShapeObj = null), this.shapeObj = null;
+ }
+ get position() {
+ return this.boundingSphere.center;
+ }
+ get x() {
+ return this.boundingSphere.center.x;
+ }
+ get y() {
+ return this.boundingSphere.center.y;
+ }
+ get z() {
+ return this.boundingSphere.center.z;
+ }
+ }
+ b.ISDONE = 2, b.drawCustom = function(S, n, o) {
+ var w = o, p = w.vertexArr, v = w.faceArr;
+ (p.length === 0 || v.length === 0) && console.warn("Error adding custom shape component: No vertices and/or face indices supplied!");
+ var a = o.color;
+ typeof a > "u" && (a = S.color), a = x.CC.color(a);
+ for (var l = A(w), g = 0, M = l.length; g < M; g++)
+ b.addCustomGeo(S, n, l[g], l[g].colorArr ? l[g].colorArr : a, o.clickable);
+ };
+ function A(S) {
+ var n = 64e3;
+ if (S.vertexArr.length < n)
+ return [S];
+ var o = [{ vertexArr: [], normalArr: [], faceArr: [] }];
+ S.colorArr && (o.colorArr = []);
+ var w = [], p = [], v = 0, a = S.faceArr;
+ for (let g = 0, M = a.length; g < M; g += 3) {
+ let L = o[v];
+ for (let T = 0; T < 3; T++) {
+ var l = a[g + T];
+ w[l] !== v && (w[l] = v, p[l] = L.vertexArr.length, L.vertexArr.push(S.vertexArr[l]), S.normalArr && S.normalArr[l] && L.normalArr.push(S.normalArr[l]), S.colorArr && S.colorArr[l] && L.colorArr.push(S.colorArr[l])), L.faceArr.push(p[l]);
+ }
+ L.vertexArr.length >= n && (o.push({ vertexArr: [], normalArr: [], faceArr: [] }), S.colorArr && (o.colorArr = []), v++);
+ }
+ return o;
+ }
+ }
+ ),
+ /***/
+ "./src/GLViewer.ts": (
+ /*!*************************!*\
+ !*** ./src/GLViewer.ts ***!
+ \*************************/
+ /***/
+ (r, e, t) => {
+ t.r(e), t.d(e, {
+ /* harmony export */
+ GLViewer: () => (
+ /* binding */
+ n
+ ),
+ /* harmony export */
+ createStereoViewer: () => (
+ /* binding */
+ p
+ ),
+ /* harmony export */
+ createViewer: () => (
+ /* binding */
+ o
+ ),
+ /* harmony export */
+ createViewerGrid: () => (
+ /* binding */
+ w
+ )
+ /* harmony export */
+ });
+ var s = t(
+ /*! ./WebGL */
+ "./src/WebGL/index.ts"
+ ), f = t(
+ /*! ./WebGL/math */
+ "./src/WebGL/math/index.ts"
+ ), _ = t(
+ /*! ./colors */
+ "./src/colors.ts"
+ ), x = t(
+ /*! ./utilities */
+ "./src/utilities.ts"
+ ), h = t(
+ /*! ./Gradient */
+ "./src/Gradient.ts"
+ ), u = t(
+ /*! ./GLModel */
+ "./src/GLModel.ts"
+ ), E = t(
+ /*! ./Label */
+ "./src/Label.ts"
+ ), c = t(
+ /*! ./GLShape */
+ "./src/GLShape.ts"
+ ), C = t(
+ /*! ./VolumeData */
+ "./src/VolumeData.ts"
+ ), b = t(
+ /*! ./ProteinSurface4 */
+ "./src/ProteinSurface4.ts"
+ ), A = t(
+ /*! ./VolumetricRender */
+ "./src/VolumetricRender.ts"
+ ), S = t(
+ /*! upng-js */
+ "./node_modules/upng-js/UPNG.js"
+ );
+ class n {
+ //reimplement jquery getwidth/height
+ getRect() {
+ let a = this.container, l = a.getBoundingClientRect();
+ if (l.width == 0 && l.height == 0 && a.style.display === "none") {
+ let g = a.style.position, M = a.style.visibility;
+ a.style.display = "block", a.style.visibility = "hidden", a.style.position = "absolute", l = a.getBoundingClientRect(), a.style.display = "none", a.style.visibility = M, a.style.position = g;
+ }
+ return l;
+ }
+ getWidth() {
+ return this.getRect().width;
+ }
+ getHeight() {
+ return this.getRect().height;
+ }
+ setupRenderer() {
+ this.renderer = new s.Renderer({
+ antialias: this.config.antialias,
+ preserveDrawingBuffer: !0,
+ premultipliedAlpha: !1,
+ id: this.config.id,
+ row: this.config.row,
+ col: this.config.col,
+ rows: this.config.rows,
+ cols: this.config.cols,
+ canvas: this.config.canvas,
+ //cannot initialize with zero size
+ containerWidth: this.WIDTH || 1,
+ containerHeight: this.HEIGHT || 1
+ }), this.renderer.domElement.style.width = "100%", this.renderer.domElement.style.height = "100%", this.renderer.domElement.style.padding = "0", this.renderer.domElement.style.position = "absolute", this.renderer.domElement.style.top = "0px", this.renderer.domElement.style.left = "0px", this.renderer.domElement.style.zIndex = "0";
+ }
+ initializeScene() {
+ this.scene = new s.Scene(), this.scene.fog = new s.Fog(this.bgColor, 100, 200), this.modelGroup = new s.Object3D(), this.rotationGroup = new s.Object3D(), this.rotationGroup.useQuaternion = !0, this.rotationGroup.quaternion = new f.Quaternion(0, 0, 0, 1), this.rotationGroup.add(this.modelGroup), this.scene.add(this.rotationGroup);
+ var a = new s.Light(16777215);
+ a.position = new f.Vector3(0.2, 0.2, 1).normalize(), a.intensity = 1, this.scene.add(a);
+ }
+ initContainer(a) {
+ this.container = a, this.WIDTH = this.getWidth(), this.HEIGHT = this.getHeight(), this.ASPECT = this.renderer.getAspect(this.WIDTH, this.HEIGHT), this.renderer.setSize(this.WIDTH, this.HEIGHT), this.container.append(this.renderer.domElement), this.glDOM = this.renderer.domElement, this.nomouse || (this.glDOM.addEventListener("mousedown", this._handleMouseDown.bind(this), { passive: !1 }), this.glDOM.addEventListener("touchstart", this._handleMouseDown.bind(this), { passive: !1 }), this.glDOM.addEventListener("wheel", this._handleMouseScroll.bind(this), { passive: !1 }), this.glDOM.addEventListener("mousemove", this._handleMouseMove.bind(this), { passive: !1 }), this.glDOM.addEventListener("touchmove", this._handleMouseMove.bind(this), { passive: !1 }), this.glDOM.addEventListener("contextmenu", this._handleContextMenu.bind(this), { passive: !1 }));
+ }
+ decAnim() {
+ this.animated--, this.animated < 0 && (this.animated = 0);
+ }
+ incAnim() {
+ this.animated++;
+ }
+ nextSurfID() {
+ var a = 0;
+ for (let g in this.surfaces)
+ if (this.surfaces.hasOwnProperty(g)) {
+ var l = parseInt(g);
+ isNaN(l) || l > a && (a = l);
+ }
+ return a + 1;
+ }
+ setSlabAndFog() {
+ let a = this.camera.position.z - this.rotationGroup.position.z;
+ a < 1 && (a = 1), this.camera.near = a + this.slabNear, this.camera.near < 1 && (this.camera.near = 1), this.camera.far = a + this.slabFar, this.camera.near + 1 > this.camera.far && (this.camera.far = this.camera.near + 1), this.camera.fov = this.fov, this.camera.right = a * Math.tan(Math.PI / 180 * this.fov), this.camera.left = -this.camera.right, this.camera.top = this.camera.right / this.ASPECT, this.camera.bottom = -this.camera.top, this.camera.updateProjectionMatrix(), this.scene.fog.near = this.camera.near + this.fogStart * (this.camera.far - this.camera.near), this.scene.fog.far = this.camera.far, this.config.disableFog && (this.scene.fog.near = this.scene.fog.far);
+ }
+ // display scene
+ //if nolink is set/true, don't propagate changes to linked viewers
+ show(a) {
+ if (this.renderer.setViewport(), !!this.scene && (this.setSlabAndFog(), this.renderer.render(this.scene, this.camera), this.viewChangeCallback && this.viewChangeCallback(this._viewer.getView()), !a && this.linkedViewers.length > 0))
+ for (var l = this._viewer.getView(), g = 0; g < this.linkedViewers.length; g++) {
+ var M = this.linkedViewers[g];
+ M.setView(l, !0);
+ }
+ }
+ //regenerate the list of clickables
+ //also updates hoverables
+ updateClickables() {
+ this.clickables.splice(0, this.clickables.length), this.hoverables.splice(0, this.hoverables.length), this.contextMenuEnabledAtoms.splice(0, this.contextMenuEnabledAtoms.length);
+ for (let a = 0, l = this.models.length; a < l; a++) {
+ let g = this.models[a];
+ if (g) {
+ let M = g.selectedAtoms({
+ clickable: !0
+ }), L = g.selectedAtoms({
+ hoverable: !0
+ }), T = g.selectedAtoms({ contextMenuEnabled: !0 });
+ for (let D = 0; D < L.length; D++)
+ this.hoverables.push(L[D]);
+ for (let D = 0; D < M.length; D++)
+ this.clickables.push(M[D]);
+ for (let D = 0; D < T.length; D++)
+ this.contextMenuEnabledAtoms.push(T[D]);
+ }
+ }
+ for (let a = 0, l = this.shapes.length; a < l; a++) {
+ let g = this.shapes[a];
+ g && g.clickable && this.clickables.push(g), g && g.hoverable && this.hoverables.push(g);
+ }
+ }
+ // Checks for selection intersects on mousedown
+ handleClickSelection(a, l, g) {
+ let M = this.targetedObjects(a, l, this.clickables);
+ if (M.length) {
+ var L = M[0].clickable;
+ L.callback !== void 0 && (typeof L.callback != "function" && (L.callback = (0, x.makeFunction)(L.callback)), typeof L.callback == "function" && L.callback(L, this._viewer, g, this.container, M));
+ }
+ }
+ //return offset of container
+ canvasOffset() {
+ let a = this.glDOM, l = a.getBoundingClientRect(), g = a.ownerDocument, M = g.documentElement, L = g.defaultView;
+ return {
+ top: l.top + L.pageYOffset - M.clientTop,
+ left: l.left + L.pageXOffset - M.clientLeft
+ };
+ }
+ //set current_hover to sel (which can be null), calling appropraite callbacks
+ setHover(a, l, g) {
+ this.current_hover != a && (this.current_hover && (typeof this.current_hover.unhover_callback != "function" && (this.current_hover.unhover_callback = (0, x.makeFunction)(this.current_hover.unhover_callback)), this.current_hover.unhover_callback(this.current_hover, this._viewer, l, this.container, g)), this.current_hover = a, a && a.hover_callback !== void 0 && (typeof a.hover_callback != "function" && (a.hover_callback = (0, x.makeFunction)(a.hover_callback)), typeof a.hover_callback == "function" && a.hover_callback(a, this._viewer, l, this.container, g)));
+ }
+ //checks for selection intersects on hover
+ handleHoverSelection(a, l, g) {
+ if (this.hoverables.length == 0)
+ return;
+ let M = this.targetedObjects(a, l, this.hoverables);
+ if (M.length) {
+ var L = M[0].clickable;
+ this.setHover(L, g, M), this.current_hover = L;
+ } else
+ this.setHover(null);
+ }
+ //sees if the mouse is still on the object that invoked a hover event and if not then the unhover callback is called
+ handleHoverContinue(a, l) {
+ let g = this.targetedObjects(a, l, this.hoverables);
+ (g.length == 0 || g[0] === void 0) && this.setHover(null), g[0] !== void 0 && g[0].clickable !== this.current_hover && this.setHover(null);
+ }
+ /**
+ * Determine if a positioned event is "close enough" to mouseStart to be considered a click.
+ * With a mouse, the position should be exact, but allow a slight delta for a touch interface.
+ * @param {Event} event
+ * @param {{ allowTolerance, tolerance: number }} options
+ */
+ closeEnoughForClick(a, { allowTolerance: l = a.targetTouches, tolerance: g = 5 } = {}) {
+ const M = this.getX(a), L = this.getY(a);
+ if (l) {
+ const T = Math.abs(M - this.mouseStartX), D = Math.abs(L - this.mouseStartY);
+ return T <= g && D <= g;
+ } else
+ return M === this.mouseStartX && L === this.mouseStartY;
+ }
+ calcTouchDistance(a) {
+ var l = a.targetTouches[0].pageX - a.targetTouches[1].pageX, g = a.targetTouches[0].pageY - a.targetTouches[1].pageY;
+ return Math.hypot(l, g);
+ }
+ //check targetTouches as well
+ getX(a) {
+ var l = a.pageX;
+ return l == null && (l = a.pageX), a.targetTouches && a.targetTouches[0] ? l = a.targetTouches[0].pageX : a.changedTouches && a.changedTouches[0] && (l = a.changedTouches[0].pageX), l;
+ }
+ getY(a) {
+ var l = a.pageY;
+ return l == null && (l = a.pageY), a.targetTouches && a.targetTouches[0] ? l = a.targetTouches[0].pageY : a.changedTouches && a.changedTouches[0] && (l = a.changedTouches[0].pageY), l;
+ }
+ //for grid viewers, return true if point is in this viewer
+ isInViewer(a, l) {
+ if (this.viewers != null) {
+ var g = this.WIDTH / this.cols, M = this.HEIGHT / this.rows, L = this.canvasOffset(), T = a - L.left, D = l - L.top, R = this.rows - Math.floor(D / M) - 1, B = Math.floor(T / g);
+ if (R != this.row || B != this.col)
+ return !1;
+ }
+ return !0;
+ }
+ //if the user has specify zoom limits, readjust to fit within them
+ //also, make sure we don't go past CAMERA_Z
+ adjustZoomToLimits(a) {
+ if (this.config.lowerZoomLimit && this.config.lowerZoomLimit > 0) {
+ let l = this.CAMERA_Z - this.config.lowerZoomLimit;
+ a > l && (a = l);
+ }
+ if (this.config.upperZoomLimit && this.config.upperZoomLimit > 0) {
+ let l = this.CAMERA_Z - this.config.upperZoomLimit;
+ a < l && (a = l);
+ }
+ return a > this.CAMERA_Z - 1 && (a = this.CAMERA_Z - 1), a;
+ }
+ //interpolate between two normalized quaternions (t between 0 and 1)
+ //https://en.wikipedia.org/wiki/Slerp
+ static slerp(a, l, g) {
+ if (g == 1)
+ return l.clone();
+ if (g == 0)
+ return a.clone();
+ let M = a.x * l.x + a.y * l.y + a.z * l.z + a.w * l.w;
+ if (M > 0.9995) {
+ let z = new f.Quaternion(a.x + g * (l.x - a.x), a.y + g * (l.y - a.y), a.z + g * (l.z - a.z), a.w + g * (l.w - a.w));
+ return z.normalize(), z;
+ }
+ M < 0 && (l = l.clone().multiplyScalar(-1), M = -M), M > 1 ? M = 1 : M < -1 && (M = -1);
+ var L = Math.acos(M), T = L * g, D = l.clone();
+ D.sub(a.clone().multiplyScalar(M)), D.normalize();
+ var R = Math.cos(T), B = Math.sin(T), P = new f.Quaternion(a.x * R + D.x * B, a.y * R + D.y * B, a.z * R + D.z * B, a.w * R + D.w * B);
+ return P.normalize(), P;
+ }
+ /* @param {Object} element HTML element within which to create viewer
+ * @param {ViewerSpec} config Object containing optional configuration for the viewer
+ */
+ constructor(a, l = {}) {
+ this.nomouse = !1, this.glDOM = null, this.models = [], this.surfaces = {}, this.shapes = [], this.labels = [], this.clickables = [], this.hoverables = [], this.contextMenuEnabledAtoms = [], this.current_hover = null, this.hoverDuration = 500, this.viewer_frame = 0, this.viewChangeCallback = null, this.stateChangeCallback = null, this.NEAR = 1, this.FAR = 800, this.CAMERA_Z = 150, this.fov = 20, this.linkedViewers = [], this.renderer = null, this.control_all = !1, this.scene = null, this.rotationGroup = null, this.modelGroup = null, this.fogStart = 0.4, this.slabNear = -50, this.slabFar = 50, this.cq = new f.Quaternion(0, 0, 0, 1), this.dq = new f.Quaternion(0, 0, 0, 1), this.animated = 0, this.animationTimers = /* @__PURE__ */ new Set(), this.isDragging = !1, this.mouseStartX = 0, this.mouseStartY = 0, this.touchDistanceStart = 0, this.touchHold = !1, this.currentModelPos = 0, this.cz = 0, this.cslabNear = 0, this.cslabFar = 0, this.userContextMenuHandler = null, this.config = l, this.callback = this.config.callback, this.defaultcolors = this.config.defaultcolors, this.defaultcolors || (this.defaultcolors = _.elementColors.defaultColors), this.nomouse = this.config.nomouse, this.bgColor = 0, this.config.backgroundColor = this.config.backgroundColor || "#ffffff", typeof this.config.backgroundColor < "u" && (this.bgColor = _.CC.color(this.config.backgroundColor).getHex()), this.config.backgroundAlpha = this.config.backgroundAlpha == null ? 1 : this.config.backgroundAlpha, this.camerax = 0, typeof this.config.camerax < "u" && (this.camerax = parseFloat(this.config.camerax)), this._viewer = this, this.container = a, this.config.hoverDuration != null && (this.hoverDuration = this.config.hoverDuration), this.config.antialias === void 0 && (this.config.antialias = !0), this.config.cartoonQuality === void 0 && (this.config.cartoonQuality = 10), this.WIDTH = this.getWidth(), this.HEIGHT = this.getHeight(), this.setupRenderer(), this.row = this.config.row == null ? 0 : this.config.row, this.col = this.config.col == null ? 0 : this.config.col, this.cols = this.config.cols, this.rows = this.config.rows, this.viewers = this.config.viewers, this.control_all = this.config.control_all, this.ASPECT = this.renderer.getAspect(this.WIDTH, this.HEIGHT), this.camera = new s.Camera(this.fov, this.ASPECT, this.NEAR, this.FAR, this.config.orthographic), this.camera.position = new f.Vector3(this.camerax, 0, this.CAMERA_Z), this.lookingAt = new f.Vector3(), this.camera.lookAt(this.lookingAt), this.raycaster = new s.Raycaster(new f.Vector3(0, 0, 0), new f.Vector3(0, 0, 0)), this.projector = new s.Projector(), this.initializeScene(), this.renderer.setClearColorHex(this.bgColor, this.config.backgroundAlpha), this.scene.fog.color = _.CC.color(this.bgColor), document.body.addEventListener("mouseup", this._handleMouseUp.bind(this)), document.body.addEventListener("touchend", this._handleMouseUp.bind(this)), this.initContainer(this.container), this.config.style && this.setViewStyle(this.config), window.addEventListener("resize", this.resize.bind(this)), typeof window.ResizeObserver < "u" && (this.divwatcher = new window.ResizeObserver(this.resize.bind(this)), this.divwatcher.observe(this.container));
+ try {
+ typeof this.callback == "function" && this.callback(this);
+ } catch (g) {
+ console.log("error with glviewer callback: " + g);
+ }
+ }
+ /**
+ * Return a list of objects that intersect that at the specified viewer position.
+ *
+ * @param x - x position in screen coordinates
+ * @param y - y position in screen coordinates
+ * @param {Object[]} - list of objects or selection object specifying what object to check for targeting
+ */
+ targetedObjects(a, l, g) {
+ var M = {
+ x: a,
+ y: l,
+ z: -1
+ };
+ return Array.isArray(g) || (g = this.selectedAtoms(g)), g.length == 0 ? [] : (this.raycaster.setFromCamera(M, this.camera), this.raycaster.intersectObjects(this.modelGroup, g));
+ }
+ /** Convert model coordinates to screen coordinates.
+ * @param {object | list} - an object or list of objects with x,y,z attributes (e.g. an atom)
+ * @return {object | list} - and object or list of {x: screenX, y: screenY}
+ */
+ modelToScreen(a) {
+ let l = !1;
+ Array.isArray(a) || (a = [a], l = !0);
+ let g = this.renderer.getXRatio(), M = this.renderer.getYRatio(), L = this.col, T = this.row, D = L * (this.WIDTH / g), R = (M - T - 1) * (this.HEIGHT / M), B = [], P = this.canvasOffset();
+ return a.forEach((z) => {
+ let F = new f.Vector3(z.x, z.y, z.z);
+ F.applyMatrix4(this.modelGroup.matrixWorld), this.projector.projectVector(F, this.camera);
+ let N = this.WIDTH / g * (F.x + 1) / 2 + P.left + D, $ = -(this.HEIGHT / M) * (F.y - 1) / 2 + P.top + R;
+ B.push({ x: N, y: $ });
+ }), l && (B = B[0]), B;
+ }
+ /**
+ * For a given screen (x,y) displacement return model displacement
+ * @param{x} x displacement in screen coordinates
+ * @param{y} y displacement in screen corodinates
+ * @param{modelz} z coordinate in model coordinates to compute offset for, default is model axis
+ */
+ screenOffsetToModel(a, l, g) {
+ var M = a / this.WIDTH, L = l / this.HEIGHT, T = g === void 0 ? this.rotationGroup.position.z : g, D = this.rotationGroup.quaternion, R = new f.Vector3(0, 0, T);
+ return this.projector.projectVector(R, this.camera), R.x += M * 2, R.y -= L * 2, this.projector.unprojectVector(R, this.camera), R.z = 0, R.applyQuaternion(D), R;
+ }
+ /**
+ * Distance from screen coordinate to model coordinate assuming screen point
+ * is projected to the same depth as model coordinate
+ * @param{screen} xy screen coordinate
+ * @param{model} xyz model coordinate
+ */
+ screenToModelDistance(a, l) {
+ let g = this.canvasOffset(), M = new f.Vector3(l.x, l.y, l.z);
+ M.applyMatrix4(this.modelGroup.matrixWorld);
+ let L = M.clone();
+ this.projector.projectVector(M, this.camera);
+ let T = new f.Vector3((a.x - g.left) * 2 / this.WIDTH - 1, (a.y - g.top) * 2 / -this.HEIGHT + 1, M.z);
+ return this.projector.unprojectVector(T, this.camera), T.distanceTo(L);
+ }
+ /**
+ * Set a callback to call when the view has potentially changed.
+ *
+ */
+ setViewChangeCallback(a) {
+ (typeof a == "function" || a == null) && (this.viewChangeCallback = a);
+ }
+ /**
+ * Set a callback to call when the view has potentially changed.
+ *
+ */
+ setStateChangeCallback(a) {
+ (typeof a == "function" || a == null) && (this.stateChangeCallback = a);
+ }
+ /**
+ * Return configuration of viewer
+ */
+ getConfig() {
+ return this.config;
+ }
+ /**
+ * Set the configuration object. Note that some setting may only
+ * have an effect at viewer creation time.
+ */
+ setConfig(a) {
+ this.config = a;
+ }
+ /**
+ * Return object representing internal state of
+ * the viewer appropriate for passing to setInternalState
+ *
+ */
+ getInternalState() {
+ var a = { models: [], surfaces: [], shapes: [], labels: [] };
+ for (let l = 0; l < this.models.length; l++)
+ this.models[l] && (a.models[l] = this.models[l].getInternalState());
+ return a;
+ }
+ /**
+ * Overwrite internal state of the viewer with passed object
+ * which should come from getInternalState.
+ *
+ */
+ setInternalState(a) {
+ this.clear();
+ var l = a.models;
+ for (let g = 0; g < l.length; g++)
+ l[g] && (this.models[g] = new u.GLModel(g), this.models[g].setInternalState(l[g]));
+ this.render();
+ }
+ /**
+ * Set lower and upper limit stops for zoom.
+ *
+ * @param {lower} - limit on zoom in (positive number). Default 0.
+ * @param {upper} - limit on zoom out (positive number). Default infinite.
+ * @example
+ $3Dmol.get("data/set1_122_complex.mol2", function(moldata) {
+ var m = viewer.addModel(moldata);
+ viewer.setStyle({stick:{colorscheme:"Jmol"}});
+ viewer.setZoomLimits(100,200);
+ viewer.zoomTo();
+ viewer.zoom(10); //will not zoom all the way
+ viewer.render();
+ });
+ */
+ setZoomLimits(a, l) {
+ typeof a < "u" && (this.config.lowerZoomLimit = a), l && (this.config.upperZoomLimit = l), this.rotationGroup.position.z = this.adjustZoomToLimits(this.rotationGroup.position.z), this.show();
+ }
+ /**
+ * Set camera parameters (distance to the origin and field of view)
+ *
+ * @param {parameters} - new camera parameters, with possible fields
+ * being fov for the field of view, z for the
+ * distance to the origin, and orthographic (boolean)
+ * for kind of projection (default false).
+ * @example
+ $3Dmol.get("data/set1_122_complex.mol2", function(data) {
+ var m = viewer.addModel(data);
+ viewer.setStyle({stick:{}});
+ viewer.zoomTo();
+ viewer.setCameraParameters({ fov: 10 , z: 300 });
+ viewer.render();
+ });
+ */
+ setCameraParameters(a) {
+ a.fov !== void 0 && (this.fov = a.fov, this.camera.fov = this.fov), a.z !== void 0 && (this.CAMERA_Z = a.z, this.camera.z = this.CAMERA_Z), a.orthographic !== void 0 && (this.camera.ortho = a.orthographic);
+ }
+ _handleMouseDown(a) {
+ if (a.preventDefault(), !this.scene)
+ return;
+ var l = this.getX(a), g = this.getY(a);
+ if (l === void 0)
+ return;
+ this.isDragging = !0, this.mouseButton = a.which, this.mouseStartX = l, this.mouseStartY = g, this.touchHold = !0, this.touchDistanceStart = 0, a.targetTouches && a.targetTouches.length == 2 && (this.touchDistanceStart = this.calcTouchDistance(a)), this.cq = this.rotationGroup.quaternion.clone(), this.cz = this.rotationGroup.position.z, this.currentModelPos = this.modelGroup.position.clone(), this.cslabNear = this.slabNear, this.cslabFar = this.slabFar;
+ let M = this;
+ setTimeout(function() {
+ a.targetTouches && M.touchHold == !0 && (M.glDOM = M.renderer.domElement, M.glDOM.dispatchEvent(new Event("contextmenu")));
+ }, 1e3);
+ }
+ _handleMouseUp(a) {
+ if (this.touchHold = !1, this.isDragging && this.scene) {
+ var l = this.getX(a), g = this.getY(a);
+ if (this.closeEnoughForClick(a) && this.isInViewer(l, g)) {
+ let M = this.mouseXY(l, g);
+ this.handleClickSelection(M.x, M.y, a);
+ }
+ }
+ this.isDragging = !1;
+ }
+ _handleMouseScroll(a) {
+ if (a.preventDefault(), !!this.scene) {
+ var l = this.getX(a), g = this.getY(a);
+ if (l !== void 0 && !(!this.control_all && !this.isInViewer(l, g))) {
+ var M = (this.CAMERA_Z - this.rotationGroup.position.z) * 0.85, L = 1;
+ if (a.ctrlKey && (L = -1), a.detail)
+ this.rotationGroup.position.z += L * M * a.detail / 10;
+ else if (a.wheelDelta) {
+ let T = a.wheelDelta * 600 / (a.wheelDelta + 600);
+ this.rotationGroup.position.z -= L * M * T / 400;
+ }
+ this.rotationGroup.position.z = this.adjustZoomToLimits(this.rotationGroup.position.z), this.show();
+ }
+ }
+ }
+ /**
+ * Return image URI of viewer contents (base64 encoded). *
+ */
+ pngURI() {
+ return this.getCanvas().toDataURL("image/png");
+ }
+ /**
+ * Return a promise that resolves to an animated PNG image URI of
+ viewer contents (base64 encoded) for nframes of viewer changes.
+ * @return {Promise}
+ */
+ apngURI(a) {
+ let l = this;
+ return a = a || 1, new Promise(function(g) {
+ let M = 0, L = l.viewChangeCallback, T = [], D = [], R = Date.now();
+ l.viewChangeCallback = function() {
+ D.push(Date.now() - R), R = Date.now(), T.push(new Promise((B) => {
+ l.getCanvas().toBlob(function(P) {
+ P.arrayBuffer().then(B);
+ }, "image/png");
+ })), M += 1, M == a && (l.viewChangeCallback = L, Promise.all(T).then((B) => {
+ let P = [];
+ for (let G = 0; G < B.length; G++) {
+ let H = (0, S.decode)(B[G]);
+ P.push((0, S.toRGBA8)(H)[0]);
+ }
+ let z = l.getCanvas().width, F = l.getCanvas().height, N = (0, S.encode)(P, z, F, 0, D), $ = new Blob([N], { type: "image/png" }), k = new FileReader();
+ k.onload = function(G) {
+ g(G.target.result);
+ }, k.readAsDataURL($);
+ }));
+ };
+ });
+ }
+ /**
+ * Return underlying canvas element.
+ */
+ getCanvas() {
+ return this.glDOM;
+ }
+ /**
+ * Return renderer element.
+ */
+ getRenderer() {
+ return this.renderer;
+ }
+ /**
+ * Set the duration of the hover delay
+ *
+ * @param {number}
+ * [hoverDuration] - an optional parameter that denotes
+ * the duration of the hover delay (in milliseconds) before the hover action is called
+ *
+ */
+ setHoverDuration(a) {
+ this.hoverDuration = a;
+ }
+ mouseXY(a, l) {
+ let g = this.canvasOffset(), M = this.renderer.getXRatio(), L = this.renderer.getYRatio(), T = this.col, D = this.row, R = T * (this.WIDTH / M), B = (L - D - 1) * (this.HEIGHT / L), P = (a - g.left - R) / (this.WIDTH / M) * 2 - 1, z = -((l - g.top - B) / (this.HEIGHT / L)) * 2 + 1;
+ return { x: P, y: z };
+ }
+ _handleMouseMove(a) {
+ clearTimeout(this.hoverTimeout), a.preventDefault();
+ let l = this.getX(a), g = this.getY(a);
+ if (l === void 0)
+ return;
+ let M = this.renderer.getXRatio(), L = this.renderer.getYRatio(), T = this.mouseXY(l, g), D = this;
+ this.current_hover !== null && this.handleHoverContinue(T.x, T.y);
+ var R = 0;
+ if (!(!this.control_all && !this.isInViewer(l, g)) && this.scene && (this.hoverables.length > 0 && (this.hoverTimeout = setTimeout(function() {
+ D.handleHoverSelection(T.x, T.y, a);
+ }, this.hoverDuration)), !!this.isDragging)) {
+ var B = (l - this.mouseStartX) / this.WIDTH, P = (g - this.mouseStartY) / this.HEIGHT;
+ if (this.touchDistanceStart != 0 && a.targetTouches && a.targetTouches.length == 2) {
+ var z = this.calcTouchDistance(a);
+ R = 2, P = (z - this.touchDistanceStart) * 2 / (this.WIDTH + this.HEIGHT);
+ } else
+ a.targetTouches && a.targetTouches.length == 3 && (R = 1);
+ B *= M, P *= L;
+ var F = Math.hypot(B, P), N;
+ if (R == 3 || this.mouseButton == 3 && a.ctrlKey)
+ this.slabNear = this.cslabNear + B * 100, this.slabFar = this.cslabFar - P * 100;
+ else if (R == 2 || this.mouseButton == 3 || a.shiftKey)
+ N = (this.CAMERA_Z - this.rotationGroup.position.z) * 0.85, N < 80 && (N = 80), this.rotationGroup.position.z = this.cz + P * N, this.rotationGroup.position.z = this.adjustZoomToLimits(this.rotationGroup.position.z);
+ else if (R == 1 || this.mouseButton == 2 || a.ctrlKey) {
+ var $ = this.screenOffsetToModel(M * (l - this.mouseStartX), L * (g - this.mouseStartY));
+ this.modelGroup.position.addVectors(this.currentModelPos, $);
+ } else if ((R === 0 || this.mouseButton == 1) && F !== 0) {
+ var k = Math.sin(F * Math.PI) / F;
+ this.dq.x = Math.cos(F * Math.PI), this.dq.y = 0, this.dq.z = k * B, this.dq.w = -k * P, this.rotationGroup.quaternion.set(1, 0, 0, 0), this.rotationGroup.quaternion.multiply(this.dq), this.rotationGroup.quaternion.multiply(this.cq);
+ }
+ this.show();
+ }
+ }
+ _handleContextMenu(a) {
+ a.preventDefault();
+ var l = this.getX(a), g = this.getY(a);
+ if (!(l != this.mouseStartX || g != this.mouseStartY)) {
+ var T = this.mouseStartX, D = this.mouseStartY, L = this.canvasOffset();
+ let R = this.mouseXY(T, D), B = R.x, P = R.y, z = this.targetedObjects(B, P, this.contextMenuEnabledAtoms);
+ var M = null;
+ z.length && (M = z[0].clickable);
+ var L = this.canvasOffset(), T = this.mouseStartX - L.left, D = this.mouseStartY - L.top;
+ this.userContextMenuHandler && this.userContextMenuHandler(M, T, D, z);
+ }
+ }
+ /**
+ * Change the viewer's container element
+ * Also useful if the original container element was removed from the DOM.
+ *
+ * @param {Object | string} element
+ * Either HTML element or string identifier. Defaults to the element used to initialize the viewer.
+
+ */
+ setContainer(a) {
+ let l = (0, x.getElement)(a) || this.container;
+ return this.initContainer(l), this;
+ }
+ /**
+ * Set the background color (default white)
+ *
+ * @param {number}
+ * hex Hexcode specified background color, or standard color spec
+ * @param {number}
+ * a Alpha level (default 1.0)
+ *
+ * @example
+ *
+ * viewer.setBackgroundColor(0x000000);
+
+
+ *
+ */
+ setBackgroundColor(a, l) {
+ (typeof l > "u" || l < 0 || l > 1) && (l = 1);
+ var g = _.CC.color(a);
+ return this.scene.fog.color = g, this.bgColor = g.getHex(), this.renderer.setClearColorHex(g.getHex(), l), this.show(), this;
+ }
+ /**
+ * Set view projection scheme. Either orthographic or perspective.
+ * Default is perspective. Orthographic can also be enabled on viewer creation
+ * by setting orthographic to true in the config object.
+ *
+ *
+ * @example
+ viewer.setViewStyle({style:"outline"});
+ $3Dmol.get('data/1fas.pqr', function(data){
+ viewer.addModel(data, "pqr");
+ $3Dmol.get("data/1fas.cube",function(volumedata){
+ viewer.addSurface($3Dmol.SurfaceType.VDW, {opacity:0.85,voldata: new $3Dmol.VolumeData(volumedata, "cube"), volscheme: new $3Dmol.Gradient.RWB(-10,10)},{});
+ });
+ viewer.zoomTo();
+
+ viewer.setProjection("orthographic");
+ viewer.render(callback);
+ });
+ *
+ */
+ setProjection(a) {
+ this.camera.ortho = a === "orthographic", this.setSlabAndFog();
+ }
+ /**
+ * Set global view styles.
+ *
+ * @example
+ * viewer.setViewStyle({style:"outline"});
+ $3Dmol.get('data/1fas.pqr', function(data){
+ viewer.addModel(data, "pqr");
+ $3Dmol.get("data/1fas.cube",function(volumedata){
+ viewer.addSurface($3Dmol.SurfaceType.VDW, {opacity:0.85,voldata: new $3Dmol.VolumeData(volumedata, "cube"), volscheme: new $3Dmol.Gradient.RWB(-10,10)},{});
+ });
+ viewer.zoomTo();
+ viewer.render(callback);
+ });
+ *
+ */
+ setViewStyle(a) {
+ if (a.style === "outline") {
+ var l = {};
+ a.color && (l.color = _.CC.color(a.color)), a.width && (l.width = a.width), this.renderer.enableOutline(l);
+ } else
+ this.renderer.disableOutline();
+ return this;
+ }
+ updateSize() {
+ this.renderer.setSize(this.WIDTH, this.HEIGHT), this.ASPECT = this.renderer.getAspect(this.WIDTH, this.HEIGHT), this.renderer.setSize(this.WIDTH, this.HEIGHT), this.camera.aspect = this.ASPECT, this.camera.updateProjectionMatrix();
+ }
+ /**
+ * Set viewer width independently of the HTML container. This is probably not what you want.
+ *
+ * @param {number} w Width in pixels
+ */
+ setWidth(a) {
+ return this.WIDTH = a || this.WIDTH, this.updateSize(), this;
+ }
+ /**
+ * Set viewer height independently of the HTML container. This is probably not what you want.
+ *
+ * @param {number} h Height in pixels
+ */
+ setHeight(a) {
+ return this.HEIGHT = a || this.HEIGHT, this.updateSize(), this;
+ }
+ /**
+ * Resize viewer according to containing HTML element's dimensions
+ *
+ */
+ resize() {
+ this.WIDTH = this.getWidth(), this.HEIGHT = this.getHeight();
+ let a = !1;
+ if (this.renderer.isLost() && this.WIDTH > 0 && this.HEIGHT > 0 && (this.container.querySelector("canvas").remove(), this.setupRenderer(), this.initContainer(this.container), a = !0), this.WIDTH == 0 || this.HEIGHT == 0 ? this.animated && this._viewer.pauseAnimate() : this.animated && this._viewer.resumeAnimate(), this.updateSize(), a) {
+ let l = this.renderer.supportedExtensions();
+ l.regen = !0, this._viewer.render(null, l);
+ } else
+ this.show();
+ return this;
+ }
+ /**
+ * Return specified model
+ *
+ * @param {number}
+ * [id=last model id] - Retrieve model with specified id
+ * @default Returns last model added to viewer or null if there are no models
+ * @return {GLModel}
+ *
+ * @example // Retrieve reference to first GLModel added var m =
+ * $3Dmol.download("pdb:1UBQ",viewer,{},function(m1){
+ $3Dmol.download("pdb:1UBI", viewer,{}, function(m2) {
+ viewer.zoomTo();
+ m1.setStyle({cartoon: {color:'green'}});
+ //could use m2 here as well
+ viewer.getModel().setStyle({cartoon: {color:'blue'}});
+ viewer.render();
+ })
+ });
+ */
+ getModel(a) {
+ return a === void 0 ? this.models.length == 0 ? null : this.models[this.models.length - 1] : a instanceof u.GLModel ? a : a in this.models ? this.models[a] : this.models.length == 0 ? null : this.models[this.models.length - 1];
+ }
+ /**
+ * Continuously rotate a scene around the specified axis.
+ *
+ * Call `spin(false)` to stop spinning.
+ *
+ * @param {string|boolean|Array} axis
+ * [axis] - Axis ("x", "y", "z", "vx", "vy", or "vz") to rotate around.
+ * Default "y". View relative (rather than model relative) axes are prefixed with v.
+ * @param {number} speed
+ * [speed] - Speed multiplier for spinning the viewer. 1 is default and a negative
+ * value reverses the direction of the spin.
+ *
+ */
+ spin(a, l = 1) {
+ if (clearInterval(this.spinInterval), typeof a > "u" && (a = "y"), typeof a == "boolean")
+ if (a)
+ a = "y";
+ else
+ return;
+ Array.isArray(a) && (a = { x: a[0], y: a[1], z: a[2] });
+ var g = this;
+ this.spinInterval = setInterval(function() {
+ !g.getCanvas().isConnected && g.renderer.isLost() && clearInterval(g.spinInterval), g.rotate(1 * l, a);
+ }, 25);
+ }
+ //animate motion between current position and passed position
+ // can set some parameters to null
+ //if fixed is true will enforce the request animation, otherwise
+ //does relative updates
+ //positions objects have modelggroup position, rotation group position.z,
+ //and rotationgroup quaternion
+ //return array includes final position, but not current
+ //the returned array includes an animate method
+ animateMotion(a, l, g, M, L, T) {
+ var D = 20, R = Math.ceil(a / D);
+ R < 1 && (R = 1), this.incAnim();
+ var B = {
+ mpos: this.modelGroup.position.clone(),
+ rz: this.rotationGroup.position.z,
+ rot: this.rotationGroup.quaternion.clone(),
+ cam: this.lookingAt.clone()
+ };
+ if (l) {
+ let F = new Array(R);
+ for (let G = 0; G < R; G++) {
+ let H = (G + 1) / R, U = { mpos: B.mpos, rz: B.rz, rot: B.rot };
+ U.mpos = g.clone().sub(B.mpos).multiplyScalar(H).add(B.mpos), U.rz = B.rz + H * (M - B.rz), U.rot = n.slerp(B.rot, L, H), U.cam = T.clone().sub(B.cam).multiplyScalar(H).add(B.cam), F[G] = U;
+ }
+ let N = 0, $ = this, k = function() {
+ var G = F[N];
+ N += 1, $.modelGroup.position = G.mpos, $.rotationGroup.position.z = G.rz, $.rotationGroup.quaternion = G.rot, $.camera.lookAt(G.cam), N < F.length ? setTimeout(k, D) : $.decAnim(), $.show();
+ };
+ setTimeout(k, D);
+ } else {
+ var P = {};
+ let F = 1 / R;
+ if (g && (P.mpos = g.clone().sub(B.mpos).multiplyScalar(F)), typeof M < "u" && M != null && (P.rz = F * (M - B.rz)), L) {
+ var z = n.slerp(B.rot, L, F);
+ P.rot = B.rot.clone().inverse().multiply(z);
+ }
+ T && (P.cam = T.clone().sub(B.cam).multiplyScalar(F));
+ let N = 0, $ = this, k = function() {
+ N += 1, P.mpos && $.modelGroup.position.add(P.mpos), P.rz && ($.rotationGroup.position.z += P.rz), P.rot && $.rotationGroup.quaternion.multiply(P.rot), P.cam && ($.lookingAt.add(P.cam), $.camera.lookAt($.lookingAt)), N < R ? setTimeout(k, D) : $.decAnim(), $.show();
+ };
+ setTimeout(k, D);
+ }
+ }
+ /**
+ * Rotate scene by angle degrees around axis
+ *
+ * @param {number}
+ * [angle] - Angle, in degrees, to rotate by.
+ * @param {string}
+ * [axis] - Axis ("x", "y", "z", "vx", "vy", or "vz") to rotate around.
+ * Default "y". View relative (rather than model relative) axes are prefixed with v.
+ * Axis can also be specified as a vector.
+ * @param {number}
+ * [animationDuration] - an optional parameter that denotes
+ * the duration of the rotation animation. Default 0 (no animation)
+ * @param {boolean} [fixedPath] - if true animation is constrained to
+ * requested motion, overriding updates that happen during the animation *
+ * @example $3Dmol.download('cid:4000', viewer, {}, function() {
+ viewer.setStyle({stick:{}});
+ viewer.zoomTo();
+ viewer.rotate(90,'y',1);
+ viewer.render(callback);
+ });
+
+ *
+ */
+ rotate(a, l = "y", g = 0, M = !1) {
+ if (l == "x" ? l = { x: 1, y: 0, z: 0 } : l == "y" ? l = { x: 0, y: 1, z: 0 } : l == "z" && (l = { x: 0, y: 0, z: 1 }), l == "vx" ? l = { vx: 1, vy: 0, vz: 0 } : l == "vy" ? l = { vx: 0, vy: 1, vz: 0 } : l == "vz" && (l = { vx: 0, vy: 0, vz: 1 }), typeof l.vx < "u") {
+ var L = new f.Vector3(l.vx, l.vy, l.vz);
+ L.applyQuaternion(this.rotationGroup.quaternion), l = { x: L.x, y: L.y, z: L.z };
+ }
+ var T = function(P) {
+ var z = Math.sin(P / 2), F = Math.cos(P / 2), N = 0, $ = 0, k = 0;
+ return N = l.x * z, $ = l.y * z, k = l.z * z, new f.Quaternion(N, $, k, F).normalize();
+ }, D = Math.PI * a / 180, R = T(D);
+ if (g) {
+ var B = new f.Quaternion().copy(this.rotationGroup.quaternion).multiply(R);
+ this.animateMotion(g, M, this.modelGroup.position, this.rotationGroup.position.z, B, this.lookingAt);
+ } else
+ this.rotationGroup.quaternion.multiply(R), this.show();
+ return this;
+ }
+ surfacesFinished() {
+ for (var a in this.surfaces)
+ if (!this.surfaces[a][0].done)
+ return !1;
+ return !0;
+ }
+ /** Returns an array representing the current viewpoint.
+ * Translation, zoom, and rotation quaternion.
+ * @returns {Array.} [ pos.x, pos.y, pos.z, rotationGroup.position.z, q.x, q.y, q.z, q.w ]
+ * */
+ getView() {
+ if (!this.modelGroup)
+ return [0, 0, 0, 0, 0, 0, 0, 1];
+ var a = this.modelGroup.position, l = this.rotationGroup.quaternion;
+ return [
+ a.x,
+ a.y,
+ a.z,
+ this.rotationGroup.position.z,
+ l.x,
+ l.y,
+ l.z,
+ l.w
+ ];
+ }
+ /** Sets the view to the specified translation, zoom, and rotation.
+ *
+ * @param {Array.} arg Array formatted identically to the return value of getView */
+ setView(a, l) {
+ return a === void 0 || !(a instanceof Array || a.length !== 8) ? this : !this.modelGroup || !this.rotationGroup ? this : (this.modelGroup.position.x = a[0], this.modelGroup.position.y = a[1], this.modelGroup.position.z = a[2], this.rotationGroup.position.z = a[3], this.rotationGroup.quaternion.x = a[4], this.rotationGroup.quaternion.y = a[5], this.rotationGroup.quaternion.z = a[6], this.rotationGroup.quaternion.w = a[7], typeof a[8] < "u" && (this.rotationGroup.position.x = a[8], this.rotationGroup.position.y = a[9]), this.show(l), this);
+ }
+ // apply styles, models, etc in viewer
+ /**
+ * Render current state of viewer, after
+ * adding/removing models, applying styles, etc.
+ *
+ */
+ render(a, l) {
+ this.renderer.setViewport(), this.updateClickables();
+ var g = this.getView();
+ this.stateChangeCallback && this.stateChangeCallback(this.getInternalState());
+ var M, L;
+ for (l || (l = this.renderer.supportedExtensions()), M = 0; M < this.models.length; M++)
+ this.models[M] && this.models[M].globj(this.modelGroup, l);
+ for (M = 0; M < this.shapes.length; M++)
+ this.shapes[M] && (typeof this.shapes[M].frame > "u" || this.viewer_frame < 0 || this.shapes[M].frame < 0 || this.shapes[M].frame == this.viewer_frame ? this.shapes[M].globj(this.modelGroup, l) : this.shapes[M].removegl(this.modelGroup));
+ for (M = 0; M < this.labels.length; M++)
+ this.labels[M] && typeof this.labels[M].frame < "u" && this.labels[M].frame >= 0 && (this.modelGroup.remove(this.labels[M].sprite), (this.viewer_frame < 0 || this.labels[M].frame == this.viewer_frame) && this.modelGroup.add(this.labels[M].sprite));
+ for (M in this.surfaces)
+ if (this.surfaces.hasOwnProperty(M)) {
+ var T = this.surfaces[M];
+ for (L = 0; L < T.length; L++)
+ if (T.hasOwnProperty(L)) {
+ var D = T[L].geo;
+ if (!T[L].finished || l.regen) {
+ D.verticesNeedUpdate = !0, D.elementsNeedUpdate = !0, D.normalsNeedUpdate = !0, D.colorsNeedUpdate = !0, D.buffersNeedUpdate = !0, D.boundingSphere = null, T[L].done && (T[L].finished = !0), T[L].lastGL && this.modelGroup.remove(T[L].lastGL);
+ var R = null;
+ if (T[L].mat instanceof s.LineBasicMaterial ? R = new s.Line(D, T[L].mat) : R = new s.Mesh(D, T[L].mat), T[L].mat.transparent && T[L].mat.opacity == 0 ? R.visible = !1 : R.visible = !0, T[L].symmetries.length > 1 || T[L].symmetries.length == 1 && !T[L].symmetries[L].isIdentity()) {
+ var B, P = new s.Object3D();
+ for (B = 0; B < T[L].symmetries.length; B++) {
+ var z = R.clone();
+ z.matrix = T[L].symmetries[B], z.matrixAutoUpdate = !1, P.add(z);
+ }
+ T[L].lastGL = P, this.modelGroup.add(P);
+ } else
+ T[L].lastGL = R, this.modelGroup.add(R);
+ }
+ }
+ }
+ return this.setView(g), typeof a == "function" && a(this), this;
+ }
+ /* @param {AtomSelectionSpec|any} sel
+ * @return list of models specified by sel
+ */
+ getModelList(a) {
+ let l = [];
+ if (typeof a > "u" || typeof a.model > "u")
+ for (let M = 0; M < this.models.length; M++)
+ this.models[M] && l.push(this.models[M]);
+ else {
+ let M = a.model;
+ Array.isArray(M) || (M = [M]);
+ for (let L = 0; L < M.length; L++)
+ if (typeof M[L] == "number") {
+ var g = M[L];
+ g < 0 && (g += this.models.length), l.push(this.models[g]);
+ } else
+ l.push(M[L]);
+ }
+ return l;
+ }
+ /**
+ *
+ * @param {AtomSelectionSpec}
+ * sel
+ * @return {AtomSpec[]}
+ */
+ getAtomsFromSel(a) {
+ var l = [];
+ typeof a > "u" && (a = {});
+ var g = this.getModelList(a);
+ for (let M = 0; M < g.length; M++)
+ l = l.concat(g[M].selectedAtoms(a));
+ return l;
+ }
+ /**
+ *
+ * @param {AtomSpec}
+ * atom
+ * @param {AtomSelectionSpec}
+ * sel
+ * @return {boolean}
+ */
+ atomIsSelected(a, l) {
+ typeof l > "u" && (l = {});
+ for (var g = this.getModelList(l), M = 0; M < g.length; M++)
+ if (g[M].atomIsSelected(a, l))
+ return !0;
+ return !1;
+ }
+ /** return list of atoms selected by sel
+ *
+ * @param {AtomSelectionSpec} sel
+ * @return {AtomSpec[]}
+ */
+ selectedAtoms(a) {
+ return this.getAtomsFromSel(a);
+ }
+ /**
+ * Returns valid values for the specified attribute in the given selection
+ * @param {string} attribute
+ * @param {AtomSelectionSpec} sel
+ * @return {Array.