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.} + * + */ + getUniqueValues(a, l) { + typeof l > "u" && (l = {}); + var g = this.getAtomsFromSel(l), M = {}; + for (var L in g) + if (g[L].hasOwnProperty(a)) { + var T = g[L][a]; + M[T] = !0; + } + return Object.keys(M); + } + /** + * Return pdb output of selected atoms (if atoms from pdb input) + * + * @param {AtomSelectionSpec} sel - Selection specification specifying model and atom properties to select. Default: all atoms in viewer + * @return {string} PDB string of selected atoms + */ + pdbData(a) { + for (var l = this.getAtomsFromSel(a), g = "", M = 0, L = l.length; M < L; ++M) + g += l[M].pdbline + ` +`; + return g; + } + /** + * Zoom current view by a constant factor + * + * @param {number} + * [factor] - Magnification factor. Values greater than 1 + * will zoom in, less than one will zoom out. Default 2. + * @param {number} + * [animationDuration] - an optional parameter that denotes + * the duration of a zoom animation + * @param {Boolean} [fixedPath] - if true animation is constrained to + * requested motion, overriding updates that happen during the animation + * @example + $3Dmol.get('data/4csv.pdb', function(data) { + viewer.addModel(data,'pdb'); + viewer.setStyle({cartoon:{},stick:{}}); + viewer.zoomTo() + viewer.zoom(2,1000); + viewer.render(); + }); + + */ + zoom(a = 2, l = 0, g = !1) { + var M = (this.CAMERA_Z - this.rotationGroup.position.z) / a, L = this.CAMERA_Z - M; + return l > 0 ? this.animateMotion(l, g, this.modelGroup.position, this.adjustZoomToLimits(L), this.rotationGroup.quaternion, this.lookingAt) : (this.rotationGroup.position.z = this.adjustZoomToLimits(L), this.show()), this; + } + /** + * Translate current view by x,y screen coordinates + * This pans the camera rather than translating the model. + * + * @param {number} x Relative change in view coordinates of camera + * @param {number} y Relative change in view coordinates of camera + * @param {number} + * [animationDuration] - an optional parameter that denotes + * the duration of a zoom animation + * @param {Boolean} [fixedPath] - if true animation is constrained to + * requested motion, overriding updates that happen during the animation * + * @example $3Dmol.get('data/4csv.pdb', function(data) { + viewer.addModel(data,'pdb'); + viewer.setStyle({cartoon:{},stick:{}}); + viewer.zoomTo(); + viewer.translate(200,50); + viewer.rotate(90,'z'); + viewer.render(callback); + }); + */ + translate(a, l, g = 0, M = !1) { + var L = a / this.WIDTH, T = l / this.HEIGHT, D = new f.Vector3(0, 0, -this.CAMERA_Z); + this.projector.projectVector(D, this.camera), D.x -= L, D.y -= T, this.projector.unprojectVector(D, this.camera), D.z = 0; + var R = this.lookingAt.clone().add(D); + return g > 0 ? this.animateMotion(g, M, this.modelGroup.position, this.rotationGroup.position.z, this.rotationGroup.quaternion, R) : (this.lookingAt = R, this.camera.lookAt(this.lookingAt), this.show()), this; + } + /** + * Translate current models by x,y screen coordinates + * This translates the models relative to the current view. It does + * not change the center of rotation. + * + * @param {number} x Relative change in x screen coordinate + * @param {number} y Relative change in y screen coordinate + * @param {number} + * [animationDuration] - an optional parameter that denotes + * the duration of a zoom animation + * @param {Boolean} [fixedPath] - if true animation is constrained to + * requested motion, overriding updates that happen during the animation * + * @example $3Dmol.get('data/4csv.pdb', function(data) { + viewer.addModel(data,'pdb'); + viewer.setStyle({cartoon:{},stick:{}}); + viewer.zoomTo(); + viewer.translateScene(200,50); + viewer.rotate(90,'z'); // will no longer be around model center + viewer.render(callback); + }); + */ + translateScene(a, l, g = 0, M = !1) { + var L = this.screenOffsetToModel(a, l), T = this.modelGroup.position.clone().add(L); + return g > 0 ? this.animateMotion(g, M, this.modelGroup.position, this.rotationGroup.position.z, this.rotationGroup.quaternion, this.lookingAt) : (this.modelGroup.position = T, this.show()), this; + } + /** + * Adjust slab to fully enclose selection (default everything). + * + * @param {AtomSelectionSpec} sel + * Selection specification specifying model and atom + * properties to select. Default: all atoms in viewer + */ + fitSlab(a) { + a = a || {}; + var l = this.getAtomsFromSel(a), g = (0, x.getExtent)(l), M = g[1][0] - g[0][0], L = g[1][1] - g[0][1], T = g[1][2] - g[0][2], D = Math.hypot(M, L, T); + return D < 5 && (D = 5), this.slabNear = -D / 1.9, this.slabFar = D / 2, this; + } + /** + * Re-center the viewer around the provided selection (unlike zoomTo, does not zoom). + * + * @param {AtomSelectionSpec} + * [sel] - Selection specification specifying model and atom + * properties to select. Default: all atoms in viewer + * @param {number} + * [animationDuration] - an optional parameter that denotes + * the duration of a zoom animation + * @param {Boolean} [fixedPath] - if true animation is constrained to + * requested motion, overriding updates that happen during the animation * + * @example // if the user were to pass the animationDuration value to + * // the function like so viewer.zoomTo({resn:'STI'},1000); + * // the program would center on resn 'STI' over the course + * // of 1 second(1000 milleseconds). + * // Reposition to centroid of all atoms of all models in this + * //viewer glviewer.center(); + $3Dmol.get('data/4csv.pdb', function(data) { + viewer.addModel(data,'pdb'); + viewer.setStyle({cartoon:{},stick:{}}); + viewer.center(); + viewer.render(callback); + }); + */ + center(a = {}, l = 0, g = !1) { + var M, L, T = this.getAtomsFromSel(a), D = (0, x.getExtent)(T); + (0, x.isEmptyObject)(a) ? (this.shapes.forEach((H) => { + if (H && H.boundingSphere && H.boundingSphere.center) { + var U = H.boundingSphere.center, V = H.boundingSphere.radius; + V > 0 ? (T.push(new f.Vector3(U.x + V, U.y, U.z)), T.push(new f.Vector3(U.x - V, U.y, U.z)), T.push(new f.Vector3(U.x, U.y + V, U.z)), T.push(new f.Vector3(U.x, U.y - V, U.z)), T.push(new f.Vector3(U.x, U.y, U.z + V)), T.push(new f.Vector3(U.x, U.y, U.z - V))) : T.push(U); + } + }), D = (0, x.getExtent)(T), M = T, L = D) : (M = this.getAtomsFromSel({}), L = (0, x.getExtent)(M)); + var R = new f.Vector3(D[2][0], D[2][1], D[2][2]), B = L[1][0] - L[0][0], P = L[1][1] - L[0][1], z = L[1][2] - L[0][2], F = Math.hypot(B, P, z); + F < 5 && (F = 5), this.slabNear = -F / 1.9, this.slabFar = F / 2, B = D[1][0] - D[0][0], P = D[1][1] - D[0][1], z = D[1][2] - D[0][2], F = Math.hypot(B, P, z), F < 5 && (F = 5); + for (var N = 25, $ = 0; $ < T.length; $++) + if (T[$]) { + var k = R.distanceToSquared(T[$]); + k > N && (N = k); + } + F = Math.sqrt(N) * 2; + var G = R.clone().multiplyScalar(-1); + return l > 0 ? this.animateMotion(l, g, G, this.rotationGroup.position.z, this.rotationGroup.quaternion, this.lookingAt) : (this.modelGroup.position = G, this.show()), this; + } + /** + * Zoom to center of atom selection. The slab will be set appropriately for + * the selection, unless an empty selection is provided, in which case there will be no slab. + * + * @param {Object} + * [sel] - Selection specification specifying model and atom + * properties to select. Default: all atoms in viewer + * @param {number} + * [animationDuration] - an optional parameter that denotes + * the duration of a zoom animation + * @param {Boolean} [fixedPath] - if true animation is constrained to + * requested motion, overriding updates that happen during the animation * + * @example + + + $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.Sinebow($3Dmol.getPropertyRange(viewer.selectedAtoms(),'charge')) + },{}); + + viewer.render(); + }); + viewer.zoomTo(); + }); + */ + zoomTo(a = {}, l = 0, g = !1) { + let M = this.getAtomsFromSel(a), L = (0, x.getExtent)(M), T = L; + if ((0, x.isEmptyObject)(a)) { + let U = M && M.length; + if (this.shapes.forEach((V) => { + if (V && V.boundingSphere) { + if (V.boundingSphere.box) { + let ee = V.boundingSphere.box; + M.push(new f.Vector3(ee.min.x, ee.min.y, ee.min.z)), M.push(new f.Vector3(ee.max.x, ee.max.y, ee.max.z)); + } else if (V.boundingSphere.center) { + var Q = V.boundingSphere.center, oe = V.boundingSphere.radius; + oe > 0 ? (M.push(new f.Vector3(Q.x + oe, Q.y, Q.z)), M.push(new f.Vector3(Q.x - oe, Q.y, Q.z)), M.push(new f.Vector3(Q.x, Q.y + oe, Q.z)), M.push(new f.Vector3(Q.x, Q.y - oe, Q.z)), M.push(new f.Vector3(Q.x, Q.y, Q.z + oe)), M.push(new f.Vector3(Q.x, Q.y, Q.z - oe))) : M.push(Q); + } + } + }), T = (0, x.getExtent)(M), !U) + for (let V = 0; V < 3; V++) + L[2][V] = (T[0][V] + T[1][V]) / 2; + } else { + let U = this.getAtomsFromSel({}); + T = (0, x.getExtent)(U); + } + var D = new f.Vector3(L[2][0], L[2][1], L[2][2]), R = T[1][0] - T[0][0], B = T[1][1] - T[0][1], P = T[1][2] - T[0][2], z = Math.hypot(R, B, P); + z < 5 && (z = 5), this.slabNear = -z / 1.9, this.slabFar = z / 2, Object.keys(a).length === 0 && (this.slabNear = Math.min(-z * 2, -50), this.slabFar = Math.max(z * 2, 50)); + var F = this.config.minimumZoomToDistance || 5; + R = L[1][0] - L[0][0], B = L[1][1] - L[0][1], P = L[1][2] - L[0][2], z = Math.hypot(R, B, P), z < F && (z = F); + for (var N = F * F, $ = 0; $ < M.length; $++) + if (M[$]) { + var k = D.distanceToSquared(M[$]); + k > N && (N = k); + } + z = Math.sqrt(N) * 2; + var G = D.clone().multiplyScalar(-1), H = -(z * 0.5 / Math.tan(Math.PI / 180 * this.camera.fov / 2) - this.CAMERA_Z); + return H = this.adjustZoomToLimits(H), l > 0 ? this.animateMotion(l, g, G, H, this.rotationGroup.quaternion, this.lookingAt) : (this.modelGroup.position = G, this.rotationGroup.position.z = H, this.show()), this; + } + /** + * Set slab of view (contents outside of slab are clipped). + * Must call render to update. + * + * @param {number} near near clipping plane distance + * @param {number} far far clipping plane distance + */ + setSlab(a, l) { + this.slabNear = a, this.slabFar = l; + } + /** + * Get slab of view (contents outside of slab are clipped). + * + * @return {Object} + * @property {number} near - near clipping plane distance + * @property {number} far - far clipping plane distance + */ + getSlab() { + return { near: this.slabNear, far: this.slabFar }; + } + /** + * Add label to viewer + * + * @param {string} + * text - Label text + * @param {LabelSpec} + * options - Label style specification + @param {AtomSelection} + * sel - Set position of label to center of this selection + * @param {boolean} noshow - if true, do not immediately display label - when adding multiple labels this is more efficient + * @return {Label} + * + * @example + * $3Dmol.download("pdb:2EJ0",viewer,{},function(){ + + viewer.addLabel("Aromatic", {position: {x:-6.89, y:0.75, z:0.35}, backgroundColor: 0x800080, backgroundOpacity: 0.8}); + viewer.addLabel("Label",{font:'sans-serif',fontSize:18,fontColor:'white',fontOpacity:1,borderThickness:1.0, + borderColor:'red',borderOpacity:0.5,backgroundColor:'black',backgroundOpacity:0.5, + position:{x:50.0,y:0.0,z:0.0},inFront:true,showBackground:true}); + viewer.setStyle({chain:'A'},{cross:{hidden:true}}); + viewer.setStyle({chain:'B'},{cross:{hidden:false, + linewidth:1.0, + colorscheme:'greenCarbon'}}); + viewer.setStyle({chain:'C'},{cross:{hidden:false, + linewidth:1.0, + radius:0.5}}); + viewer.setStyle({chain:'D'},{cross:{hidden:false, + linewidth:10.0}}); + viewer.setStyle({chain:'E'},{cross:{hidden:false, + linewidth:1.0, + color:'black'}}); + + viewer.render(); + + + }); + + */ + addLabel(a, l = {}, g, M = !1) { + if (g) { + var L = (0, x.getExtent)(this.getAtomsFromSel(g)); + l.position = { x: L[2][0], y: L[2][1], z: L[2][2] }; + } + var T = new E.Label(a, l); + return T.setContext(), this.modelGroup.add(T.sprite), this.labels.push(T), M || this.show(), T; + } + /** Add residue labels. This will generate one label per a + * residue within the selected atoms. The label will be at the + * centroid of the atoms and styled according to the passed style. + * The label text will be [resn][resi] + * + * @param {AtomSelectionSpec} sel + * @param {AtomStyleSpec} style + * @param {boolean} byframe - if true, create labels for every individual frame, not just current + * + * @example + $3Dmol.download("mmtf:2ll5",viewer,{},function(){ + viewer.setStyle({stick:{radius:0.15},cartoon:{}}); + viewer.addResLabels({hetflag:false}, {font: 'Arial', fontColor:'black',showBackground:false, screenOffset: {x:0,y:0}}); + viewer.zoomTo(); + viewer.render(); + }); + */ + addResLabels(a, l, g = !1) { + let M = this.labels.length; + return this.applyToModels("addResLabels", a, this, l, g), this.show(), this.labels.slice(M); + } + /** Add property labels. This will generate one label per a selected + * atom at the atom's coordinates with the property value as the label text. + * + * @param {string} prop - property name + * @param {AtomSelectionSpec} sel + * @param {AtomStyleSpec} style + * + * * @example + $3Dmol.download("cid:5291",viewer,{},function(){ + viewer.setStyle({stick: {radius:.2}}); + viewer.addPropertyLabels("index",{not:{elem:'H'}}, {fontColor:'black',font: 'sans-serif', fontSize: 28, showBackground:false,alignment:'center'}); + viewer.zoomTo(); + viewer.render(); + }); + */ + addPropertyLabels(a, l, g) { + return this.applyToModels("addPropertyLabels", a, l, this, g), this.show(), this; + } + /** + * Remove label from viewer + * + * @param {Label} label - $3Dmol label + * + * @example // Remove labels created in + $3Dmol.download("pdb:2EJ0",viewer,{},function(){ + var toremove = viewer.addLabel("Aromatic", {position: {x:-6.89, y:0.75, z:0.35}, backgroundColor: 0x800080, backgroundOpacity: 0.8}); + viewer.addLabel("Label",{font:'sans-serif',fontSize:18,fontColor:'white',fontOpacity:1,borderThickness:1.0, + borderColor:'red',borderOpacity:0.5,backgroundColor:'black',backgroundOpacity:0.5, + position:{x:50.0,y:0.0,z:0.0},inFront:true,showBackground:true}); + viewer.removeLabel(toremove); + viewer.render(); + + + }); + + */ + removeLabel(a) { + for (var l = 0; l < this.labels.length; l++) + if (this.labels[l] == a) { + this.labels.splice(l, 1), a.dispose(), this.modelGroup.remove(a.sprite); + break; + } + return this.show(), this; + } + /** + * Remove all labels from viewer + * + * @example + $3Dmol.download("pdb:1ubq",viewer,{},function(){ + + viewer.addResLabels(); + viewer.setStyle({},{stick:{}}); + viewer.render( ); //show labels + + viewer.removeAllLabels(); + viewer.render(); //hide labels + }); + */ + removeAllLabels() { + for (var a = 0; a < this.labels.length; a++) + this.labels[a] && this.labels[a].sprite && this.modelGroup.remove(this.labels[a].sprite); + return this.labels.splice(0, this.labels.length), this.show(), this; + } + // Modify label style + /** + * Modify existing label's style + * + * @param {Label} label - $3Dmol label + * @param {LabelSpec} + * stylespec - Label style specification + * @return {Label} + */ + setLabelStyle(a, l) { + return this.modelGroup.remove(a.sprite), a.dispose(), a.stylespec = l, a.setContext(), this.modelGroup.add(a.sprite), this.show(), a; + } + // Change label text + /** + * Modify existing label's text + * + * @param {Label} label - $3Dmol label + * @param {String} + * text - Label text + * @return {Label} + */ + setLabelText(a, l) { + return this.modelGroup.remove(a.sprite), a.dispose(), a.text = l, a.setContext(), this.modelGroup.add(a.sprite), this.show(), a; + } + /** + * Add shape object to viewer + * @see {GLShape} + * + * @param {ShapeSpec} shapeSpec - style specification for label + * @return {GLShape} + */ + addShape(a) { + a = a || {}; + var l = new c.GLShape(a); + return l.shapePosition = this.shapes.length, this.shapes.push(l), l; + } + /** + * Remove shape object from viewer + * + * @param {GLShape} shape - Reference to shape object to remove + */ + removeShape(a) { + if (!a) + return this; + for (a.removegl(this.modelGroup), delete this.shapes[a.shapePosition]; this.shapes.length > 0 && typeof this.shapes[this.shapes.length - 1] > "u"; ) + this.shapes.pop(); + return this; + } + /** + * Remove all shape objects from viewer + */ + removeAllShapes() { + for (var a = 0; a < this.shapes.length; a++) { + var l = this.shapes[a]; + l && l.removegl(this.modelGroup); + } + return this.shapes.splice(0, this.shapes.length), this; + } + //gets the center of the selection + getSelectionCenter(a) { + if (a.hasOwnProperty("x") && a.hasOwnProperty("y") && a.hasOwnProperty("z")) + return a; + var l = this.getAtomsFromSel(a); + if (l.length == 0) + return { x: 0, y: 0, z: 0 }; + var g = (0, x.getExtent)(l); + return { x: g[0][0] + (g[1][0] - g[0][0]) / 2, y: g[0][1] + (g[1][1] - g[0][1]) / 2, z: g[0][2] + (g[1][2] - g[0][2]) / 2 }; + } + /** + * Create and add sphere shape. This method provides a shorthand + * way to create a spherical shape object + * + * @param {SphereShapeSpec} spec - Sphere shape style specification + * @return {GLShape} + @example + + viewer.addSphere({center:{x:0,y:0,z:0},radius:10.0,color:'red'}); + + viewer.render(); + */ + addSphere(a) { + a = a || {}, a.center = this.getSelectionCenter(a.center); + var l = new c.GLShape(a); + return l.shapePosition = this.shapes.length, l.addSphere(a), this.shapes.push(l), l.finalize(), l; + } + /** + * Create and add box shape. This method provides a shorthand + * way to create a box shape object + * + * @param {BoxSpec} spec - Box shape style specification + * @return {GLShape} + @example + + viewer.addLine({color:'red',start:{x:0,y:0,z:0},end:{x:5,y:0,z:0}}); + viewer.addLine({color:'blue',start:{x:0,y:0,z:0},end:{x:0,y:5,z:0}}); + viewer.addLine({color:'green',start:{x:0,y:0,z:0},end:{x:0,y:0,z:5}}); + + viewer.addBox({center:{x:0,y:0,z:0},dimensions: {w:3,h:4,d:2},color:'magenta'}); + viewer.zoomTo(); + viewer.rotate(45, {x:1,y:1,z:1}); + viewer.render(); + */ + addBox(a = {}) { + a.corner != null && (a.corner = this.getSelectionCenter(a.corner)), a.center != null && (a.center = this.getSelectionCenter(a.center)); + var l = new c.GLShape(a); + return l.shapePosition = this.shapes.length, l.addBox(a), this.shapes.push(l), l.finalize(), l; + } + /** + * Create and add arrow shape + * + * @param {ArrowSpec} spec - Style specification + * @return {GLShape} + @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(a = {}) { + a.start = this.getSelectionCenter(a.start), a.end = this.getSelectionCenter(a.end); + var l = new c.GLShape(a); + return l.shapePosition = this.shapes.length, l.addArrow(a), this.shapes.push(l), l.finalize(), l; + } + /** + * Create and add cylinder shape + * + * @param {CylinderSpec} spec - Style specification + * @return {GLShape} + + @example + viewer.setBackgroundColor(0xffffffff); + 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(a = {}) { + a.start = this.getSelectionCenter(a.start), a.end = this.getSelectionCenter(a.end); + var l = new c.GLShape(a); + return l.shapePosition = this.shapes.length, a.dashed ? l.addDashedCylinder(a) : l.addCylinder(a), this.shapes.push(l), l.finalize(), l; + } + /** + * Create and add Curve shape + * + * @param {CurveSpec} spec - Style specification + * @return {GLShape} + + @example + viewer.addCurve({points: [{x:0.0,y:0.0,z:0.0}, {x:5.0,y:3.0,z:0.0}, {x:5.0,y:7.0,z:0.0}, {x:0.0,y:10.0,z:0.0}], + radius:0.5, + smooth: 10, + fromArrow:false, + toArrow: true, + color:'orange', + }); + viewer.addCurve({points: [{x:-1,y:0.0,z:0.0}, {x:-5.0,y:5.0,z:0.0}, {x:-2,y:10.0,z:0.0}], + radius:1, + fromArrow:true, + toArrow: false, + color:'purple', + }); + viewer.zoomTo(); + viewer.render(); + */ + addCurve(a = {}) { + var l = new c.GLShape(a); + return l.shapePosition = this.shapes.length, l.addCurve(a), this.shapes.push(l), l.finalize(), l; + } + /** + * Create and add line shape + * + * @param {LineSpec} spec - Style specification, can specify dashed, dashLength, and gapLength + * @return {GLShape} + @example + $3Dmol.download("pdb:2ABJ",viewer,{},function(){ + + viewer.setViewStyle({style:"outline"}); + viewer.setStyle({chain:'A'},{sphere:{hidden:true}}); + viewer.setStyle({chain:'D'},{sphere:{radius:3.0}}); + viewer.setStyle({chain:'G'},{sphere:{colorscheme:'greenCarbon'}}); + viewer.setStyle({chain:'J'},{sphere:{color:'blue'}}); + viewer.addLine({dashed:true,start:{x:0,y:0,z:0},end:{x:100,y:100,z:100}}); + viewer.render(); + }); + + */ + addLine(a = {}) { + a.start = this.getSelectionCenter(a.start), a.end = this.getSelectionCenter(a.end), a.wireframe = !0; + var l = new c.GLShape(a); + return l.shapePosition = this.shapes.length, a.dashed ? l = this.addLineDashed(a, l) : l.addLine(a), this.shapes.push(l), l.finalize(), l; + } + /** + * Create and add unit cell visualization. + * + * @param {GLModel|number} model - Model with unit cell information (e.g., pdb derived). If omitted uses most recently added model. + * @param {UnitCellStyleSpec} spec - visualization style + @example + + $3Dmol.get('data/1jpy.cif', function(data) { + let m = viewer.addModel(data); + viewer.addUnitCell(m, {box:{color:'purple'},alabel:'X',blabel:'Y',clabel:'Z',alabelstyle: {fontColor: 'black',backgroundColor:'white',inFront:true,fontSize:40},astyle:{color:'darkred', radius:5,midpos: -10}}); + viewer.zoomTo(); + viewer.render(); + }); + */ + addUnitCell(a, l) { + a = this.getModel(a), l = l || { alabel: "a", blabel: "b", clabel: "c" }, l.box = l.box || {}, l.astyle = l.astyle || { color: "red", radius: 0.1, midpos: -1 }, l.bstyle = l.bstyle || { color: "green", radius: 0.1, midpos: -1 }, l.cstyle = l.cstyle || { color: "blue", radius: 0.1, midpos: -1 }, l.alabelstyle = l.alabelstyle || { fontColor: "red", showBackground: !1, alignment: "center", inFront: !1 }, l.blabelstyle = l.blabelstyle || { fontColor: "green", showBackground: !1, alignment: "center", inFront: !1 }, l.clabelstyle = l.clabelstyle || { fontColor: "blue", showBackground: !1, alignment: "center", inFront: !1 }, a.unitCellObjects && this.removeUnitCell(a), a.unitCellObjects = { shapes: [], labels: [] }; + var g = a.getCrystData(), M = null; + if (g) { + if (g.matrix) + M = g.matrix; + else { + var L = g.a, T = g.b, D = g.c, R = g.alpha, B = g.beta, P = g.gamma; + R = R * Math.PI / 180, B = B * Math.PI / 180, P = P * Math.PI / 180; + var z, F, N; + z = Math.cos(B), F = (Math.cos(R) - Math.cos(B) * Math.cos(P)) / Math.sin(P), N = Math.sqrt(Math.max(0, 1 - z * z - F * F)), M = new f.Matrix3(L, T * Math.cos(P), D * z, 0, T * Math.sin(P), D * F, 0, 0, D * N); + } + var $ = [ + new f.Vector3(0, 0, 0), + new f.Vector3(1, 0, 0), + new f.Vector3(0, 1, 0), + new f.Vector3(0, 0, 1), + new f.Vector3(1, 1, 0), + new f.Vector3(0, 1, 1), + new f.Vector3(1, 0, 1), + new f.Vector3(1, 1, 1) + ]; + if (g.matrix4) + for (let G = 0; G < $.length; G++) + g.size && $[G].multiplyVectors($[G], g.size), $[G] = $[G].applyMatrix4(g.matrix4); + else + for (let G = 0; G < $.length; G++) + $[G] = $[G].applyMatrix3(M); + if (l.box && !l.box.hidden) { + l.box.wireframe = !0; + var k = new c.GLShape(l.box); + k.shapePosition = this.shapes.length, k.addLine({ start: $[0], end: $[1] }), k.addLine({ start: $[0], end: $[2] }), k.addLine({ start: $[1], end: $[4] }), k.addLine({ start: $[2], end: $[4] }), k.addLine({ start: $[0], end: $[3] }), k.addLine({ start: $[3], end: $[5] }), k.addLine({ start: $[2], end: $[5] }), k.addLine({ start: $[1], end: $[6] }), k.addLine({ start: $[4], end: $[7] }), k.addLine({ start: $[6], end: $[7] }), k.addLine({ start: $[3], end: $[6] }), k.addLine({ start: $[5], end: $[7] }), this.shapes.push(k), a.unitCellObjects.shapes.push(k), k.finalize(); + } + if (!l.astyle.hidden) { + l.astyle.start = $[0], l.astyle.end = $[1]; + let G = this.addArrow(l.astyle); + a.unitCellObjects.shapes.push(G); + } + if (!l.bstyle.hidden) { + l.bstyle.start = $[0], l.bstyle.end = $[2]; + let G = this.addArrow(l.bstyle); + a.unitCellObjects.shapes.push(G); + } + if (!l.cstyle.hidden) { + l.cstyle.start = $[0], l.cstyle.end = $[3]; + let G = this.addArrow(l.cstyle); + a.unitCellObjects.shapes.push(G); + } + if (l.alabel) { + l.alabelstyle.position = $[1]; + let G = this.addLabel(l.alabel, l.alabelstyle); + a.unitCellObjects.labels.push(G); + } + if (l.blabel) { + l.blabelstyle.position = $[2]; + let G = this.addLabel(l.blabel, l.blabelstyle); + a.unitCellObjects.labels.push(G); + } + if (l.clabel) { + l.clabelstyle.position = $[3]; + let G = this.addLabel(l.clabel, l.clabelstyle); + a.unitCellObjects.labels.push(G); + } + } + } + /** + * Remove unit cell visualization from model. + * + * @param {GLModel|number} model - Model with unit cell information (e.g., pdb derived). If omitted uses most recently added model. + @example + $3Dmol.get('data/icsd_200866.cif', function(data) { + let m = viewer.addModel(data); + viewer.setStyle({sphere:{}}) + viewer.addUnitCell(); + viewer.zoomTo(); + viewer.removeUnitCell(); + viewer.render(); + }); + */ + removeUnitCell(a) { + if (a = this.getModel(a), a.unitCellObjects) { + let l = this; + a.unitCellObjects.shapes.forEach(function(g) { + l.removeShape(g); + }), a.unitCellObjects.labels.forEach(function(g) { + l.removeLabel(g); + }); + } + delete a.unitCellObjects; + } + /** + * Replicate atoms in model to form a super cell of the specified dimensions. + * Original cell will be centered as much as possible. + * + * @param {integer} A - number of times to replicate cell in X dimension. + * @param {integer} B - number of times to replicate cell in Y dimension. If absent, X value is used. + * @param {integer} C - number of times to replicate cell in Z dimension. If absent, Y value is used. + * @param {GLModel} model - Model with unit cell information (e.g., pdb derived). If omitted uses most recently added model. + * @param {boolean} addBonds - Create bonds between unit cells based on distances. + @example + $3Dmol.get('data/icsd_200866.cif', function(data) { + let m = viewer.addModel(data); + viewer.setStyle({sphere:{scale:.25}}) + viewer.addUnitCell(); + viewer.zoomTo(); + viewer.replicateUnitCell(3,2,1,m); + viewer.render(); + }); + */ + replicateUnitCell(a = 3, l = a, g = l, M, L) { + M = this.getModel(M); + let T = M.getCrystData(); + if (T) { + const D = M.selectedAtoms({}), R = T.matrix; + let B = function(P) { + return P % 2 == 0 ? -P / 2 : Math.ceil(P / 2); + }; + for (let P = 0; P < a; P++) + for (let z = 0; z < l; z++) + for (let F = 0; F < g; F++) { + if (P == 0 && z == 0 && F == 0) + continue; + let N = new f.Vector3(B(P), B(z), B(F)); + N.applyMatrix3(R); + let $ = []; + for (let k = 0; k < D.length; k++) { + let G = {}; + for (let H in D[k]) + G[H] = D[k][H]; + G.x += N.x, G.y += N.y, G.z += N.z, $.push(G); + } + M.addAtoms($); + } + L && M.assignBonds(); + } + } + /** Add dashed line to shape */ + addLineDashed(a, l) { + a.dashLength = a.dashLength || 0.5, a.gapLength = a.gapLength || 0.5; + var g; + a.start ? g = new f.Vector3(a.start.x || 0, a.start.y || 0, a.start.z || 0) : g = new f.Vector3(0, 0, 0); + var M; + a.end ? M = new f.Vector3(a.end.x, a.end.y || 0, a.end.z || 0) : M = new f.Vector3(0, 0, 0); + var L = new f.Vector3(), T = new f.Vector3(), D = new f.Vector3(), R, B, P, z = g.clone(), F = 0; + for (L.subVectors(M, g), R = L.length(), L.normalize(), T = L.clone(), D = L.clone(), T.multiplyScalar(a.dashLength), D.multiplyScalar(a.gapLength), B = T.length(), P = D.length(); F < R; ) { + if (F + B > R) { + a.start = g, a.end = M, l.addLine(a); + break; + } + z.addVectors(g, T), a.start = g, a.end = z, l.addLine(a), g = z.clone(), F += B, z.addVectors(g, D), g = z.clone(), F += P; + } + return l.finalize(), l; + } + /** + * Add custom shape component from user supplied function + * + * @param {CustomSpec} spec - Style specification + * @return {GLShape} + @example + function triangle(viewer) { + var vertices = []; + var normals = []; + var colors = []; + var r = 20; + //triangle + vertices.push(new $3Dmol.Vector3(0,0,0)); + vertices.push(new $3Dmol.Vector3(r,0,0)); + vertices.push(new $3Dmol.Vector3(0,r,0)); + + normals.push(new $3Dmol.Vector3(0,0,1)); + normals.push(new $3Dmol.Vector3(0,0,1)); + normals.push(new $3Dmol.Vector3(0,0,1)); + + colors.push({r:1,g:0,b:0}); + colors.push({r:0,g:1,b:0}); + colors.push({r:0,g:0,b:1}); + + var faces = [ 0,1,2 ]; + + var spec = {vertexArr:vertices, normalArr: normals, faceArr:faces,color:colors}; + viewer.addCustom(spec); + } + triangle(viewer); + viewer.render(); + */ + addCustom(a) { + a = a || {}; + var l = new c.GLShape(a); + return l.shapePosition = this.shapes.length, l.addCustom(a), this.shapes.push(l), l.finalize(), l; + } + /** + * Construct isosurface from volumetric data in gaussian cube format + * @param {String} data - Input file contents + * @param {String} format - Input file format + * @param {VolumetricRendererSpec|IsoSurfaceSpec} spec - Shape style specification + * @return {GLShape} + * + * @example + + + $3Dmol.get('data/bohr.cube', function(data) { + + viewer.addVolumetricData(data, "cube", {isoval: -0.01, color: "red", opacity: 0.95}); + viewer.setStyle({cartoon:{},stick:{}}); + viewer.zoomTo(); + viewer.render(); + }); + + + */ + addVolumetricData(a, l, g = {}) { + var M = new C.VolumeData(a, l); + return g.hasOwnProperty("transferfn") ? this.addVolumetricRender(M, g) : this.addIsosurface(M, g); + } + /** + * Construct isosurface from volumetric data. This is more flexible + * than addVolumetricData, but can not be used with py3Dmol. + * @param {VolumeData} data - volumetric data + * @param {IsoSurfaceSpec} spec - Shape style specification + * @return {GLShape} + * + @example + $3Dmol.get('../test_structs/benzene-homo.cube', function(data){ + var voldata = new $3Dmol.VolumeData(data, "cube"); + viewer.addIsosurface(voldata, {isoval: 0.01, + color: "blue"}); + viewer.addIsosurface(voldata, {isoval: -0.01, + color: "red"}); + viewer.zoomTo(); + viewer.render(); + }); + */ + addIsosurface(a, l = {}, g) { + var M = new c.GLShape(l); + return M.shapePosition = this.shapes.length, M.addIsosurface(a, l, g), this.shapes.push(M), M; + } + /** + * Create volumetric renderer for volumetricData + * @param {VolumeData} data - volumetric data + * @param {VolumetricRenderSpec} spec - specification of volumetric render + * + * @return {GLShape} + * + */ + addVolumetricRender(a, l) { + l = l || {}; + var g = new A.GLVolumetricRender(a, l); + return g.shapePosition = this.shapes.length, this.shapes.push(g), g; + } + /** + * Return true if volumetric rendering is supported (WebGL 2.0 required) + * + * @return {boolean} + */ + hasVolumetricRender() { + return this.renderer.supportsVolumetric(); + } + /** + * Enable/disable fog for content far from the camera + * + * @param {boolean} fog whether to enable or disable the fog + */ + enableFog(a) { + a ? this.scene.fog = new s.Fog(this.bgColor, 100, 200) : (this.config.disableFog = !0, this.show()); + } + /** + * Sets the atomlists of all models in the viewer to specified frame. + * Shapes and labels can also be displayed by frame. + * Sets to last frame if framenum out of range + * + * @param {number} framenum - fame index to use, starts at zero + * @return {Promise} + */ + setFrame(a) { + this.viewer_frame = a; + let l = this; + return new Promise(function(g) { + var M = l.models.map(function(L) { + return L.setFrame(a, l); + }); + Promise.all(M).then(function() { + g(); + }); + }); + } + /** + * Gets the current viewer frame. + * + */ + getFrame() { + return this.viewer_frame; + } + /** + * Returns the number of frames that the model with the most frames in the viewer has + * + * @return {number} + */ + getNumFrames() { + var a = 0; + for (let l = 0; l < this.models.length; l++) + this.models[l].getNumFrames() > a && (a = this.models[l].getNumFrames()); + for (let l = 0; l < this.shapes.length; l++) + this.shapes[l].frame && this.shapes[l].frame >= a && (a = this.shapes[l].frame + 1); + for (let l = 0; l < this.labels.length; l++) + this.labels[l].frame && this.labels[l].frame >= a && (a = this.labels[l].frame + 1); + return a; + } + /** + * Animate all models in viewer from their respective frames + * @param {Object} options - can specify interval (speed of animation), loop (direction + * of looping, 'backward', 'forward' or 'backAndForth'), step interval between frames ('step'), startFrame, and reps (numer of repetitions, 0 indicates infinite loop) + * + */ + animate(a) { + this.incAnim(); + var l = 100, g = "forward", M = 0; + a = a || {}, a.interval && (l = a.interval), a.loop && (g = a.loop), a.reps && (M = a.reps); + var L = this.getNumFrames(), T = this, D = 0; + a.startFrame && (D = a.startFrame % L); + var R = 1; + a.step && (R = a.step, M /= R); + var B = 0, P = L * M, z = /* @__PURE__ */ new Date(), F, N, $ = function(k) { + z = /* @__PURE__ */ new Date(), k == "forward" ? T.setFrame(D).then(function() { + D = (D + R) % L, F(); + }) : k == "backward" ? T.setFrame(L - 1 - D).then(function() { + D = (D + R) % L, F(); + }) : T.setFrame(D).then(function() { + D += R, R *= D % (L - 1) == 0 ? -1 : 1, F(); + }); + }; + return F = function() { + if (T.render(), !T.getCanvas().isConnected) + T.stopAnimate(); + else if (++B == P || !T.isAnimated()) + N.cancel(), T.animationTimers.delete(N), T.decAnim(); + else { + var k = l - ((/* @__PURE__ */ new Date()).getTime() - z.getTime()); + k = k > 0 ? k : 0, T.animationTimers.delete(N), N = new x.PausableTimer($, k, g), T.animationTimers.add(N); + } + }, N = new x.PausableTimer($, 0, g), this.animationTimers.add(N), this; + } + /** + * Stop animation of all models in viewer + */ + stopAnimate() { + return this.animated = 0, this.animationTimers.forEach(function(a) { + a.cancel(); + }), this.animationTimers = /* @__PURE__ */ new Set(), this; + } + /** + * Pause animation of all models in viewer + */ + pauseAnimate() { + return this.animationTimers.forEach(function(a) { + a.pause(); + }), this; + } + /** + * Resume animation of all models in viewer + */ + resumeAnimate() { + return this.animationTimers.forEach(function(a) { + a.resume(); + }), this; + } + /** + * Return true if viewer is currently being animated, false otherwise + * @return {boolean} + */ + isAnimated() { + return this.animated > 0; + } + /** + * Create and add model to viewer, given molecular data and its format + * + * @param {string} data - Input data + * @param {string} format - Input format ('pdb', 'sdf', 'xyz', 'pqr', or 'mol2') + * @param {ParserOptionsSpec} options - format dependent options. Attributes depend on the input file format. + * @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.render(); + }); + viewer.zoomTo(); + }); + * + * @return {GLModel} + */ + addModel(a, l = "", g) { + g && !g.defaultcolors ? (g.defaultcolors = this.defaultcolors, g.cartoonQuality = g.cartoonQuality || this.config.cartoonQuality) : typeof g > "u" && (g = { defaultcolors: this.defaultcolors, cartoonQuality: this.config.cartoonQuality }); + var M = new u.GLModel(this.models.length, g); + return M.addMolData(a, l, g), this.models.push(M), M; + } + /** + * Given multimodel file and its format, add atom data to the viewer as separate models + * and return list of these models + * + * @param {string} data - Input data + * @param {string} format - Input format (see {@link FileFormats}) + * @return {Array} + */ + addModels(a, l, g) { + g = g || {}, g.multimodel = !0, g.frames = !0; + for (var M = u.GLModel.parseMolData(a, l, g), L = 0; L < M.length; L++) { + var T = new u.GLModel(this.models.length, this.defaultcolors); + T.setAtomDefaults(M[L]), T.addFrame(M[L]), T.setFrame(0), M.modelData && T.setModelData(M.modelData[L]), T.setDontDuplicateAtoms(!g.duplicateAssemblyAtoms), this.models.push(T); + } + return this.models; + } + /** + * Create and add model to viewer. Given multimodel file and its format, + * different atomlists are stored in model's frame + * property and model's atoms are set to the 0th frame + * + * @param {string} data - Input data + * @param {string} format - Input format (see {@link FileFormats}) + * @return {GLModel} + * + * @example + $3Dmol.get('../test_structs/multiple2.xyz', function(data){ + viewer.addModelsAsFrames(data, "xyz"); + viewer.animate({loop: "forward",reps: 1}); + viewer.setStyle({stick:{colorscheme:'magentaCarbon'}}); + viewer.zoomTo(); + viewer.render(); + }); + */ + addModelsAsFrames(a, l, g) { + g = g || {}, g.multimodel = !0, g.frames = !0; + var M = new u.GLModel(this.models.length, this.defaultcolors); + return M.addMolData(a, l, g), this.models.push(M), M; + } + /** + * Create and add model to viewer. Given multimodel file and its format, + * all atoms are added to one model + * + * @param {string} data - Input data + * @param {string} format - Input format (see {@link FileFormats}) + * @return {GLModel} + @example + + + $3Dmol.get('../test_structs/multiple.sdf', function(data){ + viewer.addAsOneMolecule(data, "sdf"); + viewer.zoomTo(); + viewer.render(); + }); + */ + addAsOneMolecule(a, l, g) { + g = g || {}, g.multimodel = !0, g.onemol = !0; + var M = new u.GLModel(this.models.length, this.defaultcolors); + return M.addMolData(a, l, g), this.models.push(M), M; + } + /** + * Delete specified model from viewer + * + * @param {GLModel|number} model + */ + removeModel(a) { + if (a = this.getModel(a), !!a) { + for (a.removegl(this.modelGroup), delete this.models[a.getID()]; this.models.length > 0 && typeof this.models[this.models.length - 1] > "u"; ) + this.models.pop(); + return this; + } + } + /** + * Delete all existing models + */ + removeAllModels() { + for (var a = 0; a < this.models.length; a++) { + var l = this.models[a]; + l && l.removegl(this.modelGroup); + } + return this.models.splice(0, this.models.length), this; + } + /** + * Export one or all of the loaded models into ChemDoodle compatible JSON. + * @param {boolean} includeStyles - Whether or not to include style information. + * @param {number} modelID - Optional parameter for which model to export. If left out, export all of them. + * @return {string} + */ + exportJSON(a, l) { + var g = {}; + return l === void 0 ? g.m = this.models.map(function(M) { + return M.toCDObject(a); + }) : g.m = [this.models[l].toCDObject()], JSON.stringify(g); + } + /** return a VRML string representation of the scene. Include VRML header information + * @return VRML + */ + exportVRML() { + var a = this.modelGroup; + this.applyToModels("removegl", this.modelGroup), this.modelGroup = new s.Object3D(), this.render(null, { supportsImposters: !1, supportsAIA: !1, regen: !0 }); + var l = `#VRML V2.0 utf8 +` + this.modelGroup.vrml() + ` +`; + return this.applyToModels("removegl", this.modelGroup), this.modelGroup = a, l; + } + /** + * Create a new model from atoms specified by sel. + * If extract, removes selected atoms from existing models + * + * @param {AtomSelectionSpec} sel - Atom selection specification + * @param {boolean=} extract - If true, remove selected atoms from existing models + * @return {GLModel} + */ + createModelFrom(a, l = !1) { + for (var g = new u.GLModel(this.models.length, this.defaultcolors), M = 0; M < this.models.length; M++) + if (this.models[M]) { + var L = this.models[M].selectedAtoms(a); + g.addAtoms(L), l && this.models[M].removeAtoms(L); + } + return this.models.push(g), g; + } + applyToModels(a, l, g, M, L, T, D) { + for (var R = this.getModelList(l), B = 0; B < R.length; B++) + R[B][a](l, g, M, L, T, D); + } + setStyle(a, l) { + return typeof l > "u" && (l = a, a = {}), this.applyToModels("setStyle", a, l, !1), this; + } + addStyle(a, l) { + return typeof l > "u" && (l = a, a = {}), this.applyToModels("setStyle", a, l, !0), this; + } + /** + * Set click-handling properties to all selected atoms. *Important*: render must be called for this to take effect. + * + * @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. The function is passed + * the selected (foremost) object, the viewer, the triggering event, the associated container, and a list + * of all intersecting objects with their distances from the viewer. + * + * @example + $3Dmol.download("cid:307900",viewer,{},function(){ + + viewer.setStyle({},{sphere:{}}); + viewer.setClickable({},true,function(atom,viewer,event,container) { + viewer.addLabel(atom.resn+":"+atom.atom,{position: atom, backgroundColor: 'darkgreen', backgroundOpacity: 0.8}); + }); + viewer.render(); + }); + */ + setClickable(a, l, g) { + return this.applyToModels("setClickable", a, l, g), this; + } + /** 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. The function has the same signature as a click handler. + * @param {function} unhover_callback - function called when the mouse moves out of the hover area + @example + $3Dmol.download("pdb:1ubq",viewer,{},function(){ + + viewer.setHoverable({},true,function(atom,viewer,event,container) { + if(!atom.label) { + atom.label = viewer.addLabel(atom.resn+":"+atom.atom,{position: atom, backgroundColor: 'mintcream', fontColor:'black'}); + } + }, + function(atom) { + if(atom.label) { + viewer.removeLabel(atom.label); + delete atom.label; + } + } + ); + viewer.setStyle({},{stick:{}}); + viewer.render(); + }); + + */ + setHoverable(a, l, g, M) { + return this.applyToModels("setHoverable", a, l, g, M), this; + } + /** enable context menu and callback 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(a, l) { + return this.applyToModels("enableContextMenu", a, l), this; + } + /** + * If atoms have dx, dy, dz properties (in some xyz files), vibrate populates each model's frame property based on parameters. + * Models 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 {ArrowSpec} arrowSpec - specification for drawing animated arrows. If color isn't specified, atom color (sphere, stick, line preference) is used. + */ + vibrate(a, l, g, M) { + return this.applyToModels("vibrate", a, l, g, this, M), this; + } + /** + * @param {AtomSelectionSpec} sel + * @param {string} prop + * @param {Gradient|string} scheme + * @param {object} range + */ + setColorByProperty(a, l, g, M) { + return this.applyToModels("setColorByProperty", a, l, g, M), this; + } + /** + * @param {AtomSelectionSpec} sel + * @param {object} colors + */ + setColorByElement(a, l) { + return this.applyToModels("setColorByElement", a, l), this; + } + /** + * + * @param {AtomSpec[]} atomlist + * @param {Array} + * extent + * @return {Array} + */ + static getAtomsWithin(a, l) { + var g = []; + for (let L = 0; L < a.length; L++) { + var M = a[L]; + typeof M > "u" || M.x < l[0][0] || M.x > l[1][0] || M.y < l[0][1] || M.y > l[1][1] || M.z < l[0][2] || M.z > l[1][2] || g.push(M); + } + return g; + } + // return volume of extent + static volume(a) { + var l = a[1][0] - a[0][0], g = a[1][1] - a[0][1], M = a[1][2] - a[0][2]; + return l * g * M; + } + // volume + /* + * Break up bounding box/atoms into smaller pieces so we can parallelize + * with webworkers and also limit the size of the working memory Returns + * a list of bounding boxes with the corresponding atoms. These extents + * are expanded by 4 angstroms on each side. + */ + /** + * + * @param {Array} + * extent + * @param {AtomSpec[]} atomlist + * @param {AtomSpec[]} atomstoshow + * @return {Array} + */ + carveUpExtent(a, l, g) { + let M = [], L = {}; + for (let z = 0, F = l.length; z < F; z++) + L[l[z].index] = z; + let T = function(z) { + let F = []; + for (let N = 0, $ = z.length; N < $; N++) + z[N].index in L && F.push(L[z[N].index]); + return F; + }, D = function(z) { + let F = []; + return F[0] = [z[0][0], z[0][1], z[0][2]], F[1] = [z[1][0], z[1][1], z[1][2]], F; + }, R = function(z) { + if (n.volume(z) < n.maxVolume) + return [z]; + var F = z[1][0] - z[0][0], N = z[1][1] - z[0][1], $ = z[1][2] - z[0][2], k; + F > N && F > $ ? k = 0 : N > F && N > $ ? k = 1 : k = 2; + var G = D(z), H = D(z), U = (z[1][k] - z[0][k]) / 2 + z[0][k]; + G[1][k] = U, H[0][k] = U; + var V = R(G), Q = R(H); + return V.concat(Q); + }, B = R(a), P = 6; + for (let z = 0, F = B.length; z < F; z++) { + let N = D(B[z]); + N[0][0] -= P, N[0][1] -= P, N[0][2] -= P, N[1][0] += P, N[1][1] += P, N[1][2] += P; + let $ = n.getAtomsWithin(l, N), k = n.getAtomsWithin(g, B[z]); + M.push({ + extent: B[z], + atoms: T($), + toshow: T(k) + }); + } + return M; + } + // create a mesh defined from the passed vertices and faces and material + // Just create a single geometry chunk - broken up whether sync or not + /** + * + * @param {AtomSpec[]} atoms + * @param {{vertices:number,faces:number}} + * VandF + * @param {MeshLambertMaterial} + * mat + * @return {Mesh} + */ + static generateSurfaceMesh(a, l, g) { + var M = new s.Geometry(!0), L = M.updateGeoGroup(0), T = []; + for (let Me = 0, Te = a.length; Me < Te; Me++) { + var D = a[Me]; + D && (typeof D.surfaceColor < "u" ? T[Me] = D.surfaceColor : D.color && (T[Me] = _.CC.color(D.color))); + } + var R = L.vertexArray, B = l.vertices; + for (let Me = 0, Te = B.length; Me < Te; Me++) { + let ae = L.vertices * 3; + R[ae] = B[Me].x, R[ae + 1] = B[Me].y, R[ae + 2] = B[Me].z, L.vertices++; + } + var P = L.colorArray; + if (g.voldata && g.volscheme) { + var z = g.volscheme, F = g.voldata, N = z.range() || [-1, 1]; + for (let Me = 0, Te = B.length; Me < Te; Me++) { + let ae = F.getVal(B[Me].x, B[Me].y, B[Me].z), pe = _.CC.color(z.valueToHex(ae, N)), we = Me * 3; + P[we] = pe.r, P[we + 1] = pe.g, P[we + 2] = pe.b; + } + } else if (T.length > 0) + for (let Me = 0, Te = B.length; Me < Te; Me++) { + let ae = B[Me].atomid, pe = Me * 3; + P[pe] = T[ae].r, P[pe + 1] = T[ae].g, P[pe + 2] = T[ae].b; + } + var $ = l.faces; + L.faceidx = $.length, M.initTypedArrays(); + var k = L.vertexArray, G = L.normalArray, H, U, V, Q; + for (let Me = 0, Te = $.length; Me < Te; Me += 3) { + var oe = $[Me], ee = $[Me + 1], ne = $[Me + 2], me = oe * 3, se = ee * 3, fe = ne * 3; + H = new f.Vector3(k[me], k[me + 1], k[me + 2]), U = new f.Vector3(k[se], k[se + 1], k[se + 2]), V = new f.Vector3(k[fe], k[fe + 1], k[fe + 2]), V.subVectors(V, U), H.subVectors(H, U), V.cross(H), Q = V, Q.normalize(), G[me] += Q.x, G[se] += Q.x, G[fe] += Q.x, G[me + 1] += Q.y, G[se + 1] += Q.y, G[fe + 1] += Q.y, G[me + 2] += Q.z, G[se + 2] += Q.z, G[fe + 2] += Q.z; + } + L.faceArray = new Uint16Array($); + var Ce = new s.Mesh(M, g); + return Ce; + } + // do same thing as worker in main thread + /** + * + * @param {SurfaceType} + * type + * @param {Array} + * expandedExtent + * @param {AtomSpec[]} + * extendedAtoms + * @param {AtomSpec[]} + * atomsToShow + * @param {AtomSpec[]} atoms + * @param {number} + * vol + * @return {Object} + */ + static generateMeshSyncHelper(a, l, g, M, L, T) { + var D = new b.ProteinSurface(); + return D.initparm(l, a !== 1, T), D.fillvoxels(L, g), D.buildboundary(), (a == b.SurfaceType.SES || a == b.SurfaceType.MS) && (D.fastdistancemap(), D.boundingatom(!1), D.fillvoxelswaals(L, g)), D.marchingcube(a), D.getFacesAndVertices(M); + } + /* + * + * @param {SurfaceStyleSpec} + * style + * @return {MeshLambertMaterial} + */ + static getMatWithStyle(a) { + var l = new s.MeshLambertMaterial(); + l.vertexColors = s.Coloring.VertexColors; + for (var g in a) + g === "color" || g === "map" || a.hasOwnProperty(g) && (l[g] = a[g]); + return a.opacity !== void 0 && (a.opacity === 1 ? l.transparent = !1 : l.transparent = !0), l; + } + /** + * Adds an explicit mesh as a surface object. + * @param {Mesh} + * mesh + * @param {Object} + * style + * @returns {number} surfid + */ + addMesh(a) { + var l = { + geo: a.geometry, + mat: a.material, + done: !0, + finished: !1 + //the rendered finishes surfaces when they are done + }, g = this.nextSurfID(); + return this.surfaces[g] = l, g; + } + //return a shallow copy of list l, e.g., for atoms so we can + //ignore superficial changes (ie surfacecolor, position) that happen + //while we're surface building + static shallowCopy(a) { + var l = []; + let g = a.length; + for (let M = 0; M < g; M++) + l[M] = (0, x.extend)({}, a[M]); + return l; + } + /** + * Add surface representation to atoms + * @param {SurfaceType|string} type - Surface type (VDW, MS, SAS, or SES) + * @param {SurfaceStyleSpec} style - optional style specification for surface material (e.g. for different coloring scheme, etc) + * @param {AtomSelectionSpec} atomsel - Show surface for atoms in this selection + * @param {AtomSelectionSpec} allsel - Use atoms in this selection to calculate surface; may be larger group than 'atomsel' + * @param {AtomSelectionSpec} focus - Optionally begin rendering surface specified atoms + * @param {function} surfacecallback - function to be called after setting the surface + * @return {Promise} promise - Returns a promise that ultimately resovles to the surfid. Returns surfid immediately if surfacecallback is specified. Returned promise has a [surfid, GLViewer, style, atomsel, allsel, focus] fields for immediate access. + */ + addSurface(a, l = {}, g = {}, M, L, T) { + let D = this.nextSurfID(), R = null, B = this, P = b.SurfaceType.VDW; + typeof a == "string" ? n.surfaceTypeMap[a.toUpperCase()] !== void 0 ? P = n.surfaceTypeMap[a] : console.log("Surface type : " + a + " is not recognized") : typeof a == "number" && (P = a); + var z = null, F = null, N = n.shallowCopy(this.getAtomsFromSel(g)); + M ? z = n.shallowCopy(this.getAtomsFromSel(M)) : z = N, (0, x.adjustVolumeStyle)(l); + var $ = !1, k; + for (k = 0; k < this.models.length; k++) + if (this.models[k]) { + var G = this.models[k].getSymmetries(); + if (G.length > 1 || G.length == 1 && !G[0].isIdentity()) { + $ = !0; + break; + } + } + var H = function(me, se, fe) { + L ? F = n.shallowCopy(B.getAtomsFromSel(L)) : F = fe; + var Ce, Me = (0, x.getExtent)(fe, !0); + if (l.map && l.map.prop) { + var Te = l.map.prop; + let Se = (0, h.getGradient)(l.map.scheme || l.map.gradient || new h.Gradient.RWB()), ze = Se.range(); + ze || (ze = (0, x.getPropertyRange)(fe, Te)), l.colorscheme = { prop: Te, gradient: Se }; + } + for (let Se = 0, ze = se.length; Se < ze; Se++) + Ce = se[Se], Ce.surfaceColor = (0, x.getColorFromStyle)(Ce, l); + var ae = n.volume(Me), pe = B.carveUpExtent(Me, se, fe); + if (F && F.length && F.length > 0) { + var we = (0, x.getExtent)(F, !0), ke = function(Se, ze) { + var He = function(K, q) { + var de = K.extent, ve = de[1][0] - de[0][0], Ie = de[1][1] - de[0][1], Re = de[1][2] - de[0][2], Z = ve - q[2][0]; + Z *= Z; + var ce = Ie - q[2][1]; + ce *= ce; + var Ae = Re - q[2][2]; + return Ae *= Ae, Z + ce + Ae; + }, We = He(Se, we), Y = He(ze, we); + return We - Y; + }; + pe.sort(ke); + } + var Ue = []; + for (let Se = 0, ze = se.length; Se < ze; Se++) + Ce = se[Se], Ue[Se] = { + x: Ce.x, + y: Ce.y, + z: Ce.z, + serial: Se, + elem: Ce.elem + }; + var Ne = !!b.syncSurface; + if (Ne) { + var Be = function(ze) { + return new Promise(function(He) { + for (var We = n.generateMeshSyncHelper(P, pe[ze].extent, pe[ze].atoms, pe[ze].toshow, Ue, ae), Y = (0, c.splitMesh)({ vertexArr: We.vertices, faceArr: We.faces }), K = 0, q = Y.length; K < q; K++) { + We = { + vertices: Y[K].vertexArr, + faces: Y[K].faceArr + }; + var de = n.generateSurfaceMesh(se, We, R); + (0, x.mergeGeos)(me.geo, de); + } + B.render(), He(); + }); + }, ue = []; + for (let Se = 0; Se < pe.length; Se++) + ue.push(Be(Se)); + return Promise.all(ue).then(function() { + return me.done = !0, Promise.resolve(D); + }); + } else { + var ye = []; + P < 0 && (P = 0); + for (let Se = 0, ze = n.numWorkers; Se < ze; Se++) { + var ge = new Worker($3Dmol.SurfaceWorker); + ye.push(ge), ge.postMessage({ + type: -1, + atoms: Ue, + volume: ae + }); + } + return new Promise(function(Se, ze) { + var He = 0, We = function() { + !ye || !ye.length || ye.forEach(function(de) { + de && de.terminate && de.terminate(); + }); + }, Y = function(de) { + for (var ve = (0, c.splitMesh)({ + vertexArr: de.data.vertices, + faceArr: de.data.faces + }), Ie = 0, Re = ve.length; Ie < Re; Ie++) { + var Z = { + vertices: ve[Ie].vertexArr, + faces: ve[Ie].faceArr + }, ce = n.generateSurfaceMesh(se, Z, R); + (0, x.mergeGeos)(me.geo, ce); + } + B.render(), He++, He == pe.length && (me.done = !0, We(), Se(D)); + }, K = function(de) { + We(), console.log(de.message + " (" + de.filename + ":" + de.lineno + ")"), ze(de); + }; + for (let de = 0; de < pe.length; de++) { + var q = ye[de % ye.length]; + q.onmessage = Y, q.onerror = K, q.postMessage({ + type: P, + expandedExtent: pe[de].extent, + extendedAtoms: pe[de].atoms, + atomsToShow: pe[de].toshow + }); + } + }); + } + }; + l = l || {}, R = n.getMatWithStyle(l); + var U = []; + U.style = l, U.atomsel = g, U.allsel = M, U.focus = L; + var V = null; + if ($) { + var Q = {}, oe = {}; + for (k = 0; k < this.models.length; k++) + Q[k] = [], oe[k] = []; + for (k = 0; k < z.length; k++) + Q[z[k].model].push(z[k]); + for (k = 0; k < N.length; k++) + oe[N[k].model].push(N[k]); + var ee = []; + for (k = 0; k < this.models.length; k++) + oe[k].length > 0 && (U.push({ + geo: new s.Geometry(!0), + mat: R, + done: !1, + finished: !1, + symmetries: this.models[k].getSymmetries() + // also webgl initialized + }), ee.push(H(U[U.length - 1], Q[k], oe[k]))); + V = Promise.all(ee); + } else + U.push({ + geo: new s.Geometry(!0), + mat: R, + done: !1, + finished: !1, + symmetries: [new f.Matrix4()] + }), V = H(U[U.length - 1], z, N); + return this.surfaces[D] = U, V.surfid = D, T && typeof T == "function" ? (V.then(function(ne) { + T(ne); + }), D) : V; + } + /** + * Set the surface material to something else, must render change + * @param {number} surf - Surface ID to apply changes to + * @param {SurfaceStyleSpec} style - new material style specification + @example + $3Dmol.get("data/9002806.cif",function(data){ + viewer.addModel(data); + viewer.setStyle({stick:{}}); + let surf = viewer.addSurface("SAS"); + surf.then(function() { + viewer.setSurfaceMaterialStyle(surf.surfid, {color:'blue',opacity:0.5}); + viewer.render(); + }); + }); + */ + setSurfaceMaterialStyle(a, l) { + if ((0, x.adjustVolumeStyle)(l), this.surfaces[a]) { + var g = this.surfaces[a]; + g.style = l; + for (var M = 0; M < g.length; M++) { + var L = g[M].mat = n.getMatWithStyle(l); + if (g[M].mat.side = s.FrontSide, l.color) { + g[M].mat.color = l.color, g[M].geo.colorsNeedUpdate = !0; + const T = _.CC.color(l.color); + g[M].geo.setColors(function() { + return T; + }); + } else if (L.voldata && L.volscheme) { + const T = L.volscheme, D = L.voldata, R = _.CC, B = T.range() || [-1, 1]; + g[M].geo.setColors(function(P, z, F) { + let N = D.getVal(P, z, F); + return R.color(T.valueToHex(N, B)); + }); + } + g[M].finished = !1; + } + } + return this; + } + /** + * Return surface object + * @param {number} surf - surface id + */ + getSurface(a) { + return this.surfaces[a]; + } + /** + * Remove surface with given ID + * @param {number} surf - surface id + */ + removeSurface(a) { + for (var l = this.surfaces[a], g = 0; g < l.length; g++) + l[g] && l[g].lastGL && (l[g].geo !== void 0 && l[g].geo.dispose(), l[g].mat !== void 0 && l[g].mat.dispose(), this.modelGroup.remove(l[g].lastGL)); + return delete this.surfaces[a], this.show(), this; + } + /** Remove all surfaces. + **/ + removeAllSurfaces() { + for (var a in this.surfaces) + if (this.surfaces.hasOwnProperty(a)) { + for (var l = this.surfaces[a], g = 0; g < l.length; g++) + l[g] && l[g].lastGL && (l[g].geo !== void 0 && l[g].geo.dispose(), l[g].mat !== void 0 && l[g].mat.dispose(), this.modelGroup.remove(l[g].lastGL)); + delete this.surfaces[a]; + } + return this.show(), this; + } + /** return Jmol moveto command to position this scene */ + jmolMoveTo() { + var a = this.modelGroup.position, l = "center { " + -a.x + " " + -a.y + " " + -a.z + " }; ", g = this.rotationGroup.quaternion; + return l += "moveto .5 quaternion { " + g.x + " " + g.y + " " + g.z + " " + g.w + " };", l; + } + /** Clear scene of all objects + * */ + clear() { + return this.removeAllSurfaces(), this.removeAllModels(), this.removeAllLabels(), this.removeAllShapes(), this.show(), this; + } + // props is a list of objects that select certain atoms and enumerate + // properties for those atoms + /** + * Add specified properties to all atoms matching input argument + * @param {Object} props, either array of atom selectors with associated props, or function that takes atom and sets its properties + * @param {AtomSelectionSpec} sel - subset of atoms to work on - model selection must be specified here + @example + $3Dmol.get('../test_structs/b.sdf', function(data){ + viewer.addModel(data,'sdf'); + let props = []; + //make the atom index a property x + for(let i = 0; i < 8; i++) { + props.push({index:i,props:{'x':i}}); + } + viewer.mapAtomProperties(props); + viewer.setStyle({sphere:{colorscheme:{gradient:'roygb',prop:'x',min:0,max:8}}}); + viewer.zoomTo(); + viewer.render(); + }); + */ + mapAtomProperties(a, l) { + l = l || {}; + var g = this.getAtomsFromSel(l); + if (typeof a == "function") + for (let T = 0, D = g.length; T < D; T++) { + let R = g[T]; + a(R); + } + else + for (let T = 0, D = g.length; T < D; T++) { + var M = g[T]; + for (let R = 0, B = a.length; R < B; R++) { + let P = a[R]; + if (P.props) + for (var L in P.props) + P.props.hasOwnProperty(L) && this.atomIsSelected(M, P) && (M.properties || (M.properties = {}), M.properties[L] = P.props[L]); + } + } + return this; + } + /** + * Synchronize this view matrix of this viewer to the passed viewer. + * When the viewpoint of this viewer changes, the other viewer will + * be set to this viewer's view. + * @param {$3Dmol.GLViewer} otherview + */ + linkViewer(a) { + return this.linkedViewers.push(a), this; + } + /** + * Return the z distance between the model and the camera + * @return {number} distance + */ + getPerceivedDistance() { + return this.CAMERA_Z - this.rotationGroup.position.z; + } + /** + * Set the distance between the model and the camera + * Essentially zooming. Useful while stereo rendering. + */ + setPerceivedDistance(a) { + this.rotationGroup.position.z = this.CAMERA_Z - a; + } + /** + * Used for setting an approx value of eyeSeparation. Created for calling by StereoViewer object + * @return {number} camera x position + */ + setAutoEyeSeparation(a, l) { + var g = this.getPerceivedDistance(); + return l || (l = 5), a || this.camera.position.x > 0 ? this.camera.position.x = g * Math.tan(Math.PI / 180 * l) : this.camera.position.x = -g * Math.tan(Math.PI / 180 * l), this.camera.lookAt(new f.Vector3(0, 0, this.rotationGroup.position.z)), this.camera.position.x; + } + /** + * Set the default cartoon quality for newly created models. Default is 5. + * Current models are not affected. + * @number quality, higher results in higher resolution renders + */ + setDefaultCartoonQuality(a) { + this.config.cartoonQuality = a; + } + } + n.numWorkers = 4, n.maxVolume = 64e3, n.surfaceTypeMap = { + VDW: b.SurfaceType.VDW, + MS: b.SurfaceType.MS, + SAS: b.SurfaceType.SAS, + SES: b.SurfaceType.SES + }; + function o(v, a) { + if (v = (0, x.getElement)(v), !!v) { + a = a || {}; + try { + var l = new n(v, a); + return l; + } catch (g) { + throw "error creating viewer: " + g; + } + } + } + function w(v, a = {}, l = {}) { + if (v = (0, x.getElement)(v), !!v) { + var g = [], M = document.createElement("canvas"); + l.rows = a.rows, l.cols = a.cols, l.control_all = a.control_all != null ? a.control_all : !1, v.appendChild(M); + try { + for (var L = 0; L < a.rows; L++) { + for (var T = [], D = 0; D < a.cols; D++) { + l.row = L, l.col = D, l.canvas = M, l.viewers = g, l.control_all = a.control_all; + var R = o(v, (0, x.extend)({}, l)); + T.push(R); + } + g.unshift(T); + } + } catch (B) { + throw "error creating viewer grid: " + B; + } + return g; + } + } + function p(v) { + var a = this; + if (v = (0, x.getElement)(v), !!v) { + var l = w(v, { rows: 1, cols: 2, control_all: !0 }); + this.glviewer1 = l[0][0], this.glviewer2 = l[0][1], this.glviewer1.setAutoEyeSeparation(!1), this.glviewer2.setAutoEyeSeparation(!0), this.glviewer1.linkViewer(this.glviewer2), this.glviewer2.linkViewer(this.glviewer1); + for (var g = Object.getOwnPropertyNames(this.glviewer1.__proto__).filter(function(L) { + return typeof a.glviewer1[L] == "function"; + }), M = 0; M < g.length; M++) + this[g[M]] = function(L) { + return function() { + var T = this.glviewer1[L].apply(this.glviewer1, arguments), D = this.glviewer2[L].apply(this.glviewer2, arguments); + return [T, D]; + }; + }(g[M]); + this.setCoordinates = function(L, T, D) { + for (var R = 0; R < L.length; R++) + L[R].setCoordinates(T, D); + }, this.surfacesFinished = function() { + return this.glviewer1.surfacesFinished() && this.glviewer2.surfacesFinished(); + }, this.isAnimated = function() { + return this.glviewer1.isAnimated() || this.glviewer2.isAnimated(); + }, this.render = function(L) { + this.glviewer1.render(), this.glviewer2.render(), L && L(this); + }, this.getCanvas = function() { + return this.glviewer1.getCanvas(); + }; + } + } + } + ), + /***/ + "./src/Gradient.ts": ( + /*!*************************!*\ + !*** ./src/Gradient.ts ***! + \*************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + CustomLinear: () => ( + /* binding */ + c + ), + /* harmony export */ + Gradient: () => ( + /* binding */ + b + ), + /* harmony export */ + GradientType: () => ( + /* binding */ + f + ), + /* harmony export */ + ROYGB: () => ( + /* binding */ + u + ), + /* harmony export */ + RWB: () => ( + /* binding */ + h + ), + /* harmony export */ + Sinebow: () => ( + /* binding */ + E + ), + /* harmony export */ + builtinGradients: () => ( + /* binding */ + C + ), + /* harmony export */ + getGradient: () => ( + /* binding */ + x + ), + /* harmony export */ + normalizeValue: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ./colors */ + "./src/colors.ts" + ); + class f { + } + function _(A, S, n) { + return S >= A ? (n < A && (n = A), n > S && (n = S), { lo: A, hi: S, val: n }) : (n > A && (n = A), n < S && (n = S), n = A - n + S, { lo: S, hi: A, val: n }); + } + function x(A) { + if (A instanceof f) + return A; + if (A.gradient !== void 0 && C[A.gradient]) { + let S = A.min === void 0 ? -1 : A.min, n = A.max === void 0 ? 1 : A.max; + return A.mid === void 0 ? A.colors === void 0 ? new C[A.gradient](S, n) : new C[A.gradient](S, n, A.colors) : new C[A.gradient](S, n, A.mid); + } + return A; + } + class h extends f { + constructor(S, n, o) { + super(), this.gradient = "RWB", this.mult = 1, this.mid = o, this.min = S, this.max = n, typeof n > "u" && Array.isArray(S) && S.length >= 2 ? (this.max = S[1], this.min = S[0]) : S && n && !Array.isArray(S) && (this.min = S, this.max = n); + } + //return range used for color mapping, null if none set + range() { + return typeof this.min < "u" && typeof this.max < "u" ? [this.min, this.max] : null; + } + //map value to hex color, range is provided + valueToHex(S, n) { + var o, w; + if (S = this.mult * S, n ? (o = n[0], w = n[1]) : (o = this.min, w = this.max), S === void 0) + return 16777215; + var p = _(o, w, S); + o = p.lo, w = p.hi, S = p.val; + var v = (w + o) / 2; + n && typeof n[2] < "u" ? v = n[2] : typeof this.mid < "u" ? v = this.mid : v = (o + w) / 2; + var a, l; + return S < v ? (a = Math.floor(255 * Math.sqrt((S - o) / (v - o))), l = 16711680 + 256 * a + a, l) : S > v ? (a = Math.floor(255 * Math.sqrt(1 - (S - v) / (w - v))), l = 65536 * a + 256 * a + 255, l) : 16777215; + } + } + class u extends f { + constructor(S, n) { + super(), this.gradient = "ROYGB", this.mult = 1, this.min = S, this.max = n, typeof n > "u" && Array.isArray(S) && S.length >= 2 ? (this.max = S[1], this.min = S[0]) : S && n && !Array.isArray(S) && (this.min = S, this.max = n); + } + //map value to hex color, range is provided + valueToHex(S, n) { + var o, w; + if (S = this.mult * S, n ? (o = n[0], w = n[1]) : (o = this.min, w = this.max), typeof S > "u") + return 16777215; + var p = _(o, w, S); + o = p.lo, w = p.hi, S = p.val; + var v = (o + w) / 2, a = (o + v) / 2, l = (v + w) / 2, g, M; + return S < a ? (g = Math.floor(255 * Math.sqrt((S - o) / (a - o))), M = 16711680 + 256 * g + 0, M) : S < v ? (g = Math.floor(255 * Math.sqrt(1 - (S - a) / (v - a))), M = 65536 * g + 65280 + 0, M) : S < l ? (g = Math.floor(255 * Math.sqrt((S - v) / (l - v))), M = 65280 + 1 * g, M) : (g = Math.floor(255 * Math.sqrt(1 - (S - l) / (w - l))), M = 0 + 256 * g + 255, M); + } + //return range used for color mapping, null if none set + range() { + return typeof this.min < "u" && typeof this.max < "u" ? [this.min, this.max] : null; + } + } + class E extends f { + constructor(S, n) { + super(), this.gradient = "Sinebow", this.mult = 1, this.min = S, this.max = n, typeof n > "u" && Array.isArray(S) && S.length >= 2 && (this.max = S[1], this.min = S[0]), n < S && (this.mult = -1, this.min *= -1, this.max *= -1); + } + //map value to hex color, range is provided + valueToHex(S, n) { + var o, w; + if (S = this.mult * S, n ? (o = n[0], w = n[1]) : (o = this.min, w = this.max), typeof S > "u") + return 16777215; + var p = b.normalizeValue(o, w, S); + o = p.lo, w = p.hi, S = p.val; + var v = (S - o) / (w - o), a = 5 * v / 6 + 0.5, l = Math.sin(Math.PI * a); + l *= l * 255; + var g = Math.sin(Math.PI * (a + 1 / 3)); + g *= g * 255; + var M = Math.sin(Math.PI * (a + 2 / 3)); + return M *= M * 255, 65536 * Math.floor(l) + 256 * Math.floor(M) + 1 * Math.floor(g); + } + //return range used for color mapping, null if none set + range() { + return typeof this.min < "u" && typeof this.max < "u" ? [this.min, this.max] : null; + } + } + class c extends f { + constructor(S, n, o) { + super(), this.gradient = "linear", this.colors = new Array(); + var w; + if (Array.isArray(S) && S.length >= 2 ? (this.max = S[1], this.min = S[0], w = n) : (this.min = S, this.max = n, w = o), w) + for (let p of w) + this.colors.push(s.CC.color(p)); + else + this.colors.push(s.CC.color(0)); + } + //return range used for color mapping, null if none set + range() { + return typeof this.min < "u" && typeof this.max < "u" ? [this.min, this.max] : null; + } + //map value to hex color, range is provided + valueToHex(S, n) { + var o, w; + if (n ? (o = n[0], w = n[1]) : (o = this.min, w = this.max), S === void 0) + return 16777215; + var p = _(o, w, S); + o = p.lo, w = p.hi, S = p.val; + let v = this.colors.length, a = (w - o) / v, l = Math.min(Math.floor((S - o) / a), v - 1), g = Math.min(l + 1, v - 1), M = (S - o - l * a) / a, L = this.colors[l], T = this.colors[g]; + return new s.Color(L.r + M * (T.r - L.r), L.g + M * (T.g - L.g), L.b + M * (T.b - L.b)).getHex(); + } + } + const C = { + rwb: h, + RWB: h, + roygb: u, + ROYGB: u, + sinebow: E, + linear: c + }; + class b extends f { + valueToHex(S, n) { + return 0; + } + range() { + return null; + } + } + b.RWB = h, b.ROYGB = u, b.Sinebow = E, b.CustomLinear = c, b.builtinGradients = C, b.normalizeValue = _, b.getGradient = x; + } + ), + /***/ + "./src/Label.ts": ( + /*!**********************!*\ + !*** ./src/Label.ts ***! + \**********************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Label: () => ( + /* binding */ + E + ), + /* harmony export */ + LabelCount: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), f = t( + /*! ./Gradient */ + "./src/Gradient.ts" + ), _ = t( + /*! ./colors */ + "./src/colors.ts" + ); + let x = 0; + function h(c, C, b, A, S, n, o) { + c.beginPath(), c.moveTo(C + n, b), c.lineTo(C + A - n, b), c.quadraticCurveTo(C + A, b, C + A, b + n), c.lineTo(C + A, b + S - n), c.quadraticCurveTo(C + A, b + S, C + A - n, b + S), c.lineTo(C + n, b + S), c.quadraticCurveTo(C, b + S, C, b + S - n), c.lineTo(C, b + n), c.quadraticCurveTo(C, b, C + n, b), c.closePath(), c.fill(), o && c.stroke(); + } + function u(c, C, b) { + var A = b; + return typeof c < "u" && (c instanceof _.Color ? A = c.scaled() : (A = _.CC.color(c), typeof A.scaled < "u" && (A = A.scaled()))), typeof C < "u" && (A.a = parseFloat(C)), A; + } + class E { + constructor(C, b) { + this.id = x++, this.stylespec = b || {}, this.canvas = document.createElement("canvas"), this.canvas.width = 134, this.canvas.height = 35, this.context = this.canvas.getContext("2d"), this.sprite = new s.Sprite(), this.text = C, this.frame = this.stylespec.frame; + } + getStyle() { + return this.stylespec; + } + setContext() { + var C = this.stylespec, b = typeof C.useScreen > "u" ? !1 : C.useScreen, A = C.showBackground; + (A === "0" || A === "false") && (A = !1), typeof A > "u" && (A = !0); + var S = C.font ? C.font : "sans-serif", n = parseInt(C.fontSize) ? parseInt(C.fontSize) : 18, o = u(C.fontColor, C.fontOpacity, { + r: 255, + g: 255, + b: 255, + a: 1 + }), w = C.padding ? C.padding : 4, p = C.borderThickness ? C.borderThickness : 0, v = u(C.backgroundColor, C.backgroundOpacity, { + r: 0, + g: 0, + b: 0, + a: 1 + }), a = u(C.borderColor, C.borderOpacity, v), l = C.position ? C.position : { + x: -10, + y: 1, + z: 1 + }, g = C.inFront !== void 0 ? C.inFront : !0; + (g === "false" || g === "0") && (g = !1); + var M = C.alignment || s.SpriteAlignment.topLeft; + typeof M == "string" && M in s.SpriteAlignment && (M = s.SpriteAlignment[M]); + var L = ""; + C.bold && (L = "bold "), this.context.font = L + n + "px " + S; + var T = this.context.measureText(this.text), D = T.width; + A || (p = 0); + var R = D + 2.5 * p + 2 * w, B = n * 1.25 + 2 * p + 2 * w; + if (C.backgroundImage) { + var P = C.backgroundImage, z = C.backgroundWidth ? C.backgroundWidth : P.width, F = C.backgroundHeight ? C.backgroundHeight : P.height; + z > R && (R = z), F > B && (B = F); + } + if (this.canvas.width = R, this.canvas.height = B, this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), L = "", C.bold && (L = "bold "), this.context.font = L + n + "px " + S, this.context.fillStyle = "rgba(" + v.r + "," + v.g + "," + v.b + "," + v.a + ")", this.context.strokeStyle = "rgba(" + a.r + "," + a.g + "," + a.b + "," + a.a + ")", C.backgroundGradient) { + let $ = this.context.createLinearGradient(0, B / 2, R, B / 2), k = f.Gradient.getGradient(C.backgroundGradient), G = k.range(), H = -1, U = 1; + G && (H = G[0], U = G[1]); + let V = U - H; + for (let Q = 0; Q < 1.01; Q += 0.1) { + let oe = u(k.valueToHex(H + V * Q)), ee = "rgba(" + oe.r + "," + oe.g + "," + oe.b + "," + oe.a + ")"; + $.addColorStop(Q, ee); + } + this.context.fillStyle = $; + } + this.context.lineWidth = p, A && h(this.context, p, p, R - 2 * p, B - 2 * p, 6, p > 0), C.backgroundImage && this.context.drawImage(P, 0, 0, R, B), this.context.fillStyle = "rgba(" + o.r + "," + o.g + "," + o.b + "," + o.a + ")", this.context.fillText(this.text, p + w, n + p + w, D); + var N = new s.Texture(this.canvas); + N.needsUpdate = !0, this.sprite.material = new s.SpriteMaterial({ + map: N, + useScreenCoordinates: b, + alignment: M, + depthTest: !g, + screenOffset: C.screenOffset || null + }), this.sprite.scale.set(1, 1, 1), this.sprite.position.set(l.x, l.y, l.z); + } + // clean up material and texture + dispose() { + this.sprite.material.map !== void 0 && this.sprite.material.map.dispose(), this.sprite.material !== void 0 && this.sprite.material.dispose(); + } + } + } + ), + /***/ + "./src/ProteinSurface4.ts": ( + /*!********************************!*\ + !*** ./src/ProteinSurface4.ts ***! + \********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + MarchingCube: () => ( + /* binding */ + u + ), + /* harmony export */ + MarchingCubeInitializer: () => ( + /* binding */ + h + ), + /* harmony export */ + PointGrid: () => ( + /* binding */ + E + ), + /* harmony export */ + ProteinSurface: () => ( + /* binding */ + c + ), + /* harmony export */ + SurfaceType: () => ( + /* binding */ + f + ), + /* harmony export */ + setSyncSurface: () => ( + /* binding */ + x + ), + /* harmony export */ + syncSurface: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), f; + (function(C) { + C[C.VDW = 1] = "VDW", C[C.MS = 2] = "MS", C[C.SAS = 3] = "SAS", C[C.SES = 4] = "SES"; + })(f || (f = {})); + var _ = !1; + function x(C) { + _ = C; + } + (window.navigator.userAgent.indexOf("MSIE ") >= 0 || window.navigator.userAgent.indexOf("Trident/") >= 0) && (_ = !0); + class h { + constructor() { + this.ISDONE = 2, this.edgeTable = new Uint32Array([ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2816, + 0, + 0, + 0, + 1792, + 0, + 3328, + 3584, + 3840, + 0, + 0, + 0, + 138, + 0, + 21, + 0, + 134, + 0, + 0, + 0, + 652, + 0, + 2067, + 3865, + 3600, + 0, + 0, + 0, + 42, + 0, + 0, + 0, + 294, + 0, + 0, + 21, + 28, + 0, + 3875, + 1049, + 3360, + 0, + 168, + 162, + 170, + 0, + 645, + 2475, + 2210, + 0, + 687, + 293, + 172, + 4010, + 3747, + 3497, + 3232, + 0, + 0, + 0, + 0, + 0, + 69, + 0, + 900, + 0, + 0, + 0, + 1792, + 138, + 131, + 1608, + 1920, + 0, + 81, + 0, + 2074, + 84, + 85, + 84, + 86, + 0, + 81, + 0, + 3676, + 330, + 1105, + 1881, + 1616, + 0, + 0, + 0, + 42, + 0, + 69, + 0, + 502, + 0, + 0, + 21, + 3580, + 138, + 2035, + 1273, + 1520, + 2816, + 104, + 2337, + 106, + 840, + 581, + 367, + 102, + 2816, + 3695, + 3429, + 3180, + 1898, + 1635, + 1385, + 1120, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3910, + 0, + 0, + 69, + 588, + 42, + 2083, + 41, + 2880, + 0, + 0, + 0, + 1722, + 0, + 2293, + 4095, + 3830, + 0, + 255, + 757, + 764, + 2538, + 2291, + 3065, + 2800, + 0, + 0, + 81, + 338, + 0, + 3925, + 1119, + 3414, + 84, + 855, + 85, + 340, + 2130, + 2899, + 89, + 2384, + 1792, + 712, + 194, + 1162, + 4036, + 3781, + 3535, + 3270, + 708, + 719, + 197, + 204, + 3018, + 2755, + 2505, + 2240, + 0, + 0, + 0, + 0, + 168, + 420, + 168, + 1958, + 162, + 162, + 676, + 2988, + 170, + 163, + 680, + 928, + 3328, + 3096, + 3328, + 3642, + 52, + 53, + 1855, + 1590, + 2340, + 2111, + 2869, + 2620, + 298, + 51, + 825, + 560, + 3584, + 3584, + 3090, + 3482, + 1668, + 1941, + 1183, + 1430, + 146, + 2975, + 2069, + 2460, + 154, + 915, + 153, + 400, + 3840, + 3592, + 3329, + 3082, + 1796, + 1541, + 1295, + 1030, + 2818, + 2575, + 2309, + 2060, + 778, + 515, + 265, + 0 + ]), this.triTable = [ + [], + [], + [], + [], + [], + [], + [], + [11, 9, 8], + [], + [], + [], + [8, 10, 9], + [], + [10, 8, 11], + [9, 11, 10], + [8, 10, 9, 8, 11, 10], + [], + [], + [], + [1, 7, 3], + [], + [4, 2, 0], + [], + [2, 1, 7], + [], + [], + [], + [2, 7, 3, 2, 9, 7], + [], + [1, 4, 11, 1, 0, 4], + [3, 8, 0, 11, 9, 4, 11, 10, 9], + [4, 11, 9, 11, 10, 9], + [], + [], + [], + [5, 3, 1], + [], + [], + [], + [2, 5, 8, 2, 1, 5], + [], + [], + [2, 4, 0], + [3, 2, 4], + [], + [0, 9, 1, 8, 10, 5, 8, 11, 10], + [3, 4, 0, 3, 10, 4], + [5, 8, 10, 8, 11, 10], + [], + [3, 5, 7], + [7, 1, 5], + [1, 7, 3, 1, 5, 7], + [], + [9, 2, 0, 9, 7, 2], + [0, 3, 8, 1, 7, 11, 1, 5, 7], + [11, 1, 7, 1, 5, 7], + [], + [9, 1, 0, 5, 3, 2, 5, 7, 3], + [8, 2, 5, 8, 0, 2], + [2, 5, 3, 5, 7, 3], + [3, 9, 1, 3, 8, 9, 7, 11, 10, 7, 10, 5], + [9, 1, 0, 10, 7, 11, 10, 5, 7], + [3, 8, 0, 7, 10, 5, 7, 11, 10], + [11, 5, 7, 11, 10, 5], + [], + [], + [], + [], + [], + [0, 6, 2], + [], + [7, 2, 9, 7, 9, 8], + [], + [], + [], + [8, 10, 9], + [7, 1, 3], + [7, 1, 0], + [6, 9, 3, 6, 10, 9], + [7, 10, 8, 10, 9, 8], + [], + [6, 0, 4], + [], + [11, 1, 4, 11, 3, 1], + [2, 4, 6], + [2, 0, 4, 2, 4, 6], + [2, 4, 6], + [1, 4, 2, 4, 6, 2], + [], + [6, 0, 4], + [], + [2, 11, 3, 6, 9, 4, 6, 10, 9], + [8, 6, 1, 8, 1, 3], + [10, 0, 6, 0, 4, 6], + [8, 0, 3, 9, 6, 10, 9, 4, 6], + [10, 4, 6, 10, 9, 4], + [], + [], + [], + [5, 3, 1], + [], + [0, 6, 2], + [], + [7, 4, 8, 5, 2, 1, 5, 6, 2], + [], + [], + [2, 4, 0], + [7, 4, 8, 2, 11, 3, 10, 5, 6], + [7, 1, 3], + [5, 6, 10, 0, 9, 1, 8, 7, 4], + [5, 6, 10, 7, 0, 3, 7, 4, 0], + [10, 5, 6, 4, 8, 7], + [9, 11, 8], + [3, 5, 6], + [0, 5, 11, 0, 11, 8], + [6, 3, 5, 3, 1, 5], + [3, 9, 6, 3, 8, 9], + [9, 6, 0, 6, 2, 0], + [0, 3, 8, 2, 5, 6, 2, 1, 5], + [1, 6, 2, 1, 5, 6], + [9, 11, 8], + [1, 0, 9, 6, 10, 5, 11, 3, 2], + [6, 10, 5, 2, 8, 0, 2, 11, 8], + [3, 2, 11, 10, 5, 6], + [10, 5, 6, 9, 3, 8, 9, 1, 3], + [0, 9, 1, 5, 6, 10], + [8, 0, 3, 10, 5, 6], + [10, 5, 6], + [], + [], + [], + [], + [], + [], + [], + [1, 10, 2, 9, 11, 6, 9, 8, 11], + [], + [], + [6, 0, 2], + [3, 6, 9, 3, 2, 6], + [3, 5, 1], + [0, 5, 1, 0, 11, 5], + [0, 3, 5], + [6, 9, 11, 9, 8, 11], + [], + [], + [], + [4, 5, 9, 7, 1, 10, 7, 3, 1], + [], + [11, 6, 7, 2, 4, 5, 2, 0, 4], + [11, 6, 7, 8, 0, 3, 1, 10, 2, 9, 4, 5], + [6, 7, 11, 1, 10, 2, 9, 4, 5], + [], + [4, 1, 0, 4, 5, 1, 6, 7, 3, 6, 3, 2], + [9, 4, 5, 0, 6, 7, 0, 2, 6], + [4, 5, 9, 6, 3, 2, 6, 7, 3], + [6, 7, 11, 5, 3, 8, 5, 1, 3], + [6, 7, 11, 4, 1, 0, 4, 5, 1], + [4, 5, 9, 3, 8, 0, 11, 6, 7], + [9, 4, 5, 7, 11, 6], + [], + [], + [0, 6, 4], + [8, 6, 4, 8, 1, 6], + [], + [0, 10, 2, 0, 9, 10, 4, 8, 11, 4, 11, 6], + [10, 2, 1, 6, 0, 3, 6, 4, 0], + [10, 2, 1, 11, 4, 8, 11, 6, 4], + [4, 2, 6], + [1, 0, 9, 2, 4, 8, 2, 6, 4], + [2, 4, 0, 2, 6, 4], + [8, 2, 4, 2, 6, 4], + [11, 4, 1, 11, 6, 4], + [0, 9, 1, 4, 11, 6, 4, 8, 11], + [3, 6, 0, 6, 4, 0], + [8, 6, 4, 8, 11, 6], + [10, 8, 9], + [6, 3, 9, 6, 7, 3], + [6, 7, 1], + [10, 7, 1, 7, 3, 1], + [7, 11, 6, 8, 10, 2, 8, 9, 10], + [11, 6, 7, 10, 0, 9, 10, 2, 0], + [2, 1, 10, 7, 11, 6, 8, 0, 3], + [1, 10, 2, 6, 7, 11], + [7, 2, 6, 7, 9, 2], + [1, 0, 9, 3, 6, 7, 3, 2, 6], + [7, 0, 6, 0, 2, 6], + [2, 7, 3, 2, 6, 7], + [7, 11, 6, 3, 9, 1, 3, 8, 9], + [9, 1, 0, 11, 6, 7], + [0, 3, 8, 11, 6, 7], + [11, 6, 7], + [], + [], + [], + [], + [5, 3, 7], + [8, 5, 2, 8, 7, 5], + [5, 3, 7], + [1, 10, 2, 5, 8, 7, 5, 9, 8], + [1, 7, 5], + [1, 7, 5], + [9, 2, 7, 9, 7, 5], + [11, 3, 2, 8, 5, 9, 8, 7, 5], + [1, 3, 7, 1, 7, 5], + [0, 7, 1, 7, 5, 1], + [9, 3, 5, 3, 7, 5], + [9, 7, 5, 9, 8, 7], + [8, 10, 11], + [3, 4, 10, 3, 10, 11], + [8, 10, 11], + [5, 9, 4, 1, 11, 3, 1, 10, 11], + [2, 4, 5], + [5, 2, 4, 2, 0, 4], + [0, 3, 8, 5, 9, 4, 10, 2, 1], + [2, 1, 10, 9, 4, 5], + [2, 8, 5, 2, 11, 8], + [3, 2, 11, 1, 4, 5, 1, 0, 4], + [9, 4, 5, 8, 2, 11, 8, 0, 2], + [11, 3, 2, 9, 4, 5], + [8, 5, 3, 5, 1, 3], + [5, 0, 4, 5, 1, 0], + [3, 8, 0, 4, 5, 9], + [9, 4, 5], + [11, 9, 10], + [11, 9, 10], + [1, 11, 4, 1, 10, 11], + [8, 7, 4, 11, 1, 10, 11, 3, 1], + [2, 7, 9, 2, 9, 10], + [4, 8, 7, 0, 10, 2, 0, 9, 10], + [2, 1, 10, 0, 7, 4, 0, 3, 7], + [10, 2, 1, 8, 7, 4], + [1, 7, 4], + [3, 2, 11, 4, 8, 7, 9, 1, 0], + [11, 4, 2, 4, 0, 2], + [2, 11, 3, 7, 4, 8], + [4, 1, 7, 1, 3, 7], + [1, 0, 9, 8, 7, 4], + [3, 4, 0, 3, 7, 4], + [8, 7, 4], + [8, 9, 10, 8, 10, 11], + [3, 9, 11, 9, 10, 11], + [0, 10, 8, 10, 11, 8], + [10, 3, 1, 10, 11, 3], + [2, 8, 10, 8, 9, 10], + [9, 2, 0, 9, 10, 2], + [8, 0, 3, 1, 10, 2], + [10, 2, 1], + [1, 11, 9, 11, 8, 9], + [11, 3, 2, 0, 9, 1], + [11, 0, 2, 11, 8, 0], + [11, 3, 2], + [8, 1, 3, 8, 9, 1], + [9, 1, 0], + [8, 0, 3], + [] + ], this.edgeTable2 = [ + 0, + 265, + 515, + 778, + 2060, + 2309, + 2575, + 2822, + 1030, + 1295, + 1541, + 1804, + 3082, + 3331, + 3593, + 3840, + 400, + 153, + 915, + 666, + 2460, + 2197, + 2975, + 2710, + 1430, + 1183, + 1941, + 1692, + 3482, + 3219, + 3993, + 3728, + 560, + 825, + 51, + 314, + 2620, + 2869, + 2111, + 2358, + 1590, + 1855, + 1077, + 1340, + 3642, + 3891, + 3129, + 3376, + 928, + 681, + 419, + 170, + 2988, + 2725, + 2479, + 2214, + 1958, + 1711, + 1445, + 1196, + 4010, + 3747, + 3497, + 3232, + 2240, + 2505, + 2755, + 3018, + 204, + 453, + 719, + 966, + 3270, + 3535, + 3781, + 4044, + 1226, + 1475, + 1737, + 1984, + 2384, + 2137, + 2899, + 2650, + 348, + 85, + 863, + 598, + 3414, + 3167, + 3925, + 3676, + 1370, + 1107, + 1881, + 1616, + 2800, + 3065, + 2291, + 2554, + 764, + 1013, + 255, + 502, + 3830, + 4095, + 3317, + 3580, + 1786, + 2035, + 1273, + 1520, + 2912, + 2665, + 2403, + 2154, + 876, + 613, + 367, + 102, + 3942, + 3695, + 3429, + 3180, + 1898, + 1635, + 1385, + 1120, + 1120, + 1385, + 1635, + 1898, + 3180, + 3429, + 3695, + 3942, + 102, + 367, + 613, + 876, + 2154, + 2403, + 2665, + 2912, + 1520, + 1273, + 2035, + 1786, + 3580, + 3317, + 4095, + 3830, + 502, + 255, + 1013, + 764, + 2554, + 2291, + 3065, + 2800, + 1616, + 1881, + 1107, + 1370, + 3676, + 3925, + 3167, + 3414, + 598, + 863, + 85, + 348, + 2650, + 2899, + 2137, + 2384, + 1984, + 1737, + 1475, + 1226, + 4044, + 3781, + 3535, + 3270, + 966, + 719, + 453, + 204, + 3018, + 2755, + 2505, + 2240, + 3232, + 3497, + 3747, + 4010, + 1196, + 1445, + 1711, + 1958, + 2214, + 2479, + 2725, + 2988, + 170, + 419, + 681, + 928, + 3376, + 3129, + 3891, + 3642, + 1340, + 1077, + 1855, + 1590, + 2358, + 2111, + 2869, + 2620, + 314, + 51, + 825, + 560, + 3728, + 3993, + 3219, + 3482, + 1692, + 1941, + 1183, + 1430, + 2710, + 2975, + 2197, + 2460, + 666, + 915, + 153, + 400, + 3840, + 3593, + 3331, + 3082, + 1804, + 1541, + 1295, + 1030, + 2822, + 2575, + 2309, + 2060, + 778, + 515, + 265, + 0 + ], this.triTable2 = [ + [], + [8, 3, 0], + [9, 0, 1], + [8, 3, 1, 8, 1, 9], + [11, 2, 3], + [11, 2, 0, 11, 0, 8], + [11, 2, 3, 0, 1, 9], + [2, 1, 11, 1, 9, 11, 11, 9, 8], + [10, 1, 2], + [8, 3, 0, 1, 2, 10], + [9, 0, 2, 9, 2, 10], + [3, 2, 8, 2, 10, 8, 8, 10, 9], + [10, 1, 3, 10, 3, 11], + [1, 0, 10, 0, 8, 10, 10, 8, 11], + [0, 3, 9, 3, 11, 9, 9, 11, 10], + [8, 10, 9, 8, 11, 10], + [8, 4, 7], + [3, 0, 4, 3, 4, 7], + [1, 9, 0, 8, 4, 7], + [9, 4, 1, 4, 7, 1, 1, 7, 3], + [2, 3, 11, 7, 8, 4], + [7, 11, 4, 11, 2, 4, 4, 2, 0], + [3, 11, 2, 4, 7, 8, 9, 0, 1], + [2, 7, 11, 2, 1, 7, 1, 4, 7, 1, 9, 4], + [10, 1, 2, 8, 4, 7], + [2, 10, 1, 0, 4, 7, 0, 7, 3], + [4, 7, 8, 0, 2, 10, 0, 10, 9], + [2, 7, 3, 2, 9, 7, 7, 9, 4, 2, 10, 9], + [8, 4, 7, 11, 10, 1, 11, 1, 3], + [11, 4, 7, 1, 4, 11, 1, 11, 10, 1, 0, 4], + [3, 8, 0, 7, 11, 4, 11, 9, 4, 11, 10, 9], + [7, 11, 4, 4, 11, 9, 11, 10, 9], + [9, 5, 4], + [3, 0, 8, 4, 9, 5], + [5, 4, 0, 5, 0, 1], + [4, 8, 5, 8, 3, 5, 5, 3, 1], + [11, 2, 3, 9, 5, 4], + [9, 5, 4, 8, 11, 2, 8, 2, 0], + [3, 11, 2, 1, 5, 4, 1, 4, 0], + [8, 5, 4, 2, 5, 8, 2, 8, 11, 2, 1, 5], + [2, 10, 1, 9, 5, 4], + [0, 8, 3, 5, 4, 9, 10, 1, 2], + [10, 5, 2, 5, 4, 2, 2, 4, 0], + [3, 4, 8, 3, 2, 4, 2, 5, 4, 2, 10, 5], + [5, 4, 9, 1, 3, 11, 1, 11, 10], + [0, 9, 1, 4, 8, 5, 8, 10, 5, 8, 11, 10], + [3, 4, 0, 3, 10, 4, 4, 10, 5, 3, 11, 10], + [4, 8, 5, 5, 8, 10, 8, 11, 10], + [9, 5, 7, 9, 7, 8], + [0, 9, 3, 9, 5, 3, 3, 5, 7], + [8, 0, 7, 0, 1, 7, 7, 1, 5], + [1, 7, 3, 1, 5, 7], + [11, 2, 3, 8, 9, 5, 8, 5, 7], + [9, 2, 0, 9, 7, 2, 2, 7, 11, 9, 5, 7], + [0, 3, 8, 2, 1, 11, 1, 7, 11, 1, 5, 7], + [2, 1, 11, 11, 1, 7, 1, 5, 7], + [1, 2, 10, 5, 7, 8, 5, 8, 9], + [9, 1, 0, 10, 5, 2, 5, 3, 2, 5, 7, 3], + [5, 2, 10, 8, 2, 5, 8, 5, 7, 8, 0, 2], + [10, 5, 2, 2, 5, 3, 5, 7, 3], + [3, 9, 1, 3, 8, 9, 7, 11, 10, 7, 10, 5], + [9, 1, 0, 10, 7, 11, 10, 5, 7], + [3, 8, 0, 7, 10, 5, 7, 11, 10], + [11, 5, 7, 11, 10, 5], + [11, 7, 6], + [0, 8, 3, 11, 7, 6], + [9, 0, 1, 11, 7, 6], + [7, 6, 11, 3, 1, 9, 3, 9, 8], + [2, 3, 7, 2, 7, 6], + [8, 7, 0, 7, 6, 0, 0, 6, 2], + [1, 9, 0, 3, 7, 6, 3, 6, 2], + [7, 6, 2, 7, 2, 9, 2, 1, 9, 7, 9, 8], + [1, 2, 10, 6, 11, 7], + [2, 10, 1, 7, 6, 11, 8, 3, 0], + [11, 7, 6, 10, 9, 0, 10, 0, 2], + [7, 6, 11, 3, 2, 8, 8, 2, 10, 8, 10, 9], + [6, 10, 7, 10, 1, 7, 7, 1, 3], + [6, 10, 1, 6, 1, 7, 7, 1, 0, 7, 0, 8], + [9, 0, 3, 6, 9, 3, 6, 10, 9, 6, 3, 7], + [6, 10, 7, 7, 10, 8, 10, 9, 8], + [8, 4, 6, 8, 6, 11], + [11, 3, 6, 3, 0, 6, 6, 0, 4], + [0, 1, 9, 4, 6, 11, 4, 11, 8], + [1, 9, 4, 11, 1, 4, 11, 3, 1, 11, 4, 6], + [3, 8, 2, 8, 4, 2, 2, 4, 6], + [2, 0, 4, 2, 4, 6], + [1, 9, 0, 3, 8, 2, 2, 8, 4, 2, 4, 6], + [9, 4, 1, 1, 4, 2, 4, 6, 2], + [10, 1, 2, 11, 8, 4, 11, 4, 6], + [10, 1, 2, 11, 3, 6, 6, 3, 0, 6, 0, 4], + [0, 2, 10, 0, 10, 9, 4, 11, 8, 4, 6, 11], + [2, 11, 3, 6, 9, 4, 6, 10, 9], + [8, 4, 6, 8, 6, 1, 6, 10, 1, 8, 1, 3], + [1, 0, 10, 10, 0, 6, 0, 4, 6], + [8, 0, 3, 9, 6, 10, 9, 4, 6], + [10, 4, 6, 10, 9, 4], + [9, 5, 4, 7, 6, 11], + [4, 9, 5, 3, 0, 8, 11, 7, 6], + [6, 11, 7, 4, 0, 1, 4, 1, 5], + [6, 11, 7, 4, 8, 5, 5, 8, 3, 5, 3, 1], + [4, 9, 5, 6, 2, 3, 6, 3, 7], + [9, 5, 4, 8, 7, 0, 0, 7, 6, 0, 6, 2], + [4, 0, 1, 4, 1, 5, 6, 3, 7, 6, 2, 3], + [7, 4, 8, 5, 2, 1, 5, 6, 2], + [6, 11, 7, 1, 2, 10, 9, 5, 4], + [11, 7, 6, 8, 3, 0, 1, 2, 10, 9, 5, 4], + [11, 7, 6, 10, 5, 2, 2, 5, 4, 2, 4, 0], + [7, 4, 8, 2, 11, 3, 10, 5, 6], + [4, 9, 5, 6, 10, 7, 7, 10, 1, 7, 1, 3], + [5, 6, 10, 0, 9, 1, 8, 7, 4], + [5, 6, 10, 7, 0, 3, 7, 4, 0], + [10, 5, 6, 4, 8, 7], + [5, 6, 9, 6, 11, 9, 9, 11, 8], + [0, 9, 5, 0, 5, 3, 3, 5, 6, 3, 6, 11], + [0, 1, 5, 0, 5, 11, 5, 6, 11, 0, 11, 8], + [11, 3, 6, 6, 3, 5, 3, 1, 5], + [9, 5, 6, 3, 9, 6, 3, 8, 9, 3, 6, 2], + [5, 6, 9, 9, 6, 0, 6, 2, 0], + [0, 3, 8, 2, 5, 6, 2, 1, 5], + [1, 6, 2, 1, 5, 6], + [1, 2, 10, 5, 6, 9, 9, 6, 11, 9, 11, 8], + [1, 0, 9, 6, 10, 5, 11, 3, 2], + [6, 10, 5, 2, 8, 0, 2, 11, 8], + [3, 2, 11, 10, 5, 6], + [10, 5, 6, 9, 3, 8, 9, 1, 3], + [0, 9, 1, 5, 6, 10], + [8, 0, 3, 10, 5, 6], + [10, 5, 6], + [10, 6, 5], + [8, 3, 0, 10, 6, 5], + [0, 1, 9, 5, 10, 6], + [10, 6, 5, 9, 8, 3, 9, 3, 1], + [3, 11, 2, 10, 6, 5], + [6, 5, 10, 2, 0, 8, 2, 8, 11], + [1, 9, 0, 6, 5, 10, 11, 2, 3], + [1, 10, 2, 5, 9, 6, 9, 11, 6, 9, 8, 11], + [1, 2, 6, 1, 6, 5], + [0, 8, 3, 2, 6, 5, 2, 5, 1], + [5, 9, 6, 9, 0, 6, 6, 0, 2], + [9, 6, 5, 3, 6, 9, 3, 9, 8, 3, 2, 6], + [11, 6, 3, 6, 5, 3, 3, 5, 1], + [0, 5, 1, 0, 11, 5, 5, 11, 6, 0, 8, 11], + [0, 5, 9, 0, 3, 5, 3, 6, 5, 3, 11, 6], + [5, 9, 6, 6, 9, 11, 9, 8, 11], + [10, 6, 5, 4, 7, 8], + [5, 10, 6, 7, 3, 0, 7, 0, 4], + [5, 10, 6, 0, 1, 9, 8, 4, 7], + [4, 5, 9, 6, 7, 10, 7, 1, 10, 7, 3, 1], + [7, 8, 4, 2, 3, 11, 10, 6, 5], + [11, 6, 7, 10, 2, 5, 2, 4, 5, 2, 0, 4], + [11, 6, 7, 8, 0, 3, 1, 10, 2, 9, 4, 5], + [6, 7, 11, 1, 10, 2, 9, 4, 5], + [7, 8, 4, 5, 1, 2, 5, 2, 6], + [4, 1, 0, 4, 5, 1, 6, 7, 3, 6, 3, 2], + [9, 4, 5, 8, 0, 7, 0, 6, 7, 0, 2, 6], + [4, 5, 9, 6, 3, 2, 6, 7, 3], + [6, 7, 11, 4, 5, 8, 5, 3, 8, 5, 1, 3], + [6, 7, 11, 4, 1, 0, 4, 5, 1], + [4, 5, 9, 3, 8, 0, 11, 6, 7], + [9, 4, 5, 7, 11, 6], + [10, 6, 4, 10, 4, 9], + [8, 3, 0, 9, 10, 6, 9, 6, 4], + [1, 10, 0, 10, 6, 0, 0, 6, 4], + [8, 6, 4, 8, 1, 6, 6, 1, 10, 8, 3, 1], + [2, 3, 11, 6, 4, 9, 6, 9, 10], + [0, 10, 2, 0, 9, 10, 4, 8, 11, 4, 11, 6], + [10, 2, 1, 11, 6, 3, 6, 0, 3, 6, 4, 0], + [10, 2, 1, 11, 4, 8, 11, 6, 4], + [9, 1, 4, 1, 2, 4, 4, 2, 6], + [1, 0, 9, 3, 2, 8, 2, 4, 8, 2, 6, 4], + [2, 4, 0, 2, 6, 4], + [3, 2, 8, 8, 2, 4, 2, 6, 4], + [1, 4, 9, 11, 4, 1, 11, 1, 3, 11, 6, 4], + [0, 9, 1, 4, 11, 6, 4, 8, 11], + [11, 6, 3, 3, 6, 0, 6, 4, 0], + [8, 6, 4, 8, 11, 6], + [6, 7, 10, 7, 8, 10, 10, 8, 9], + [9, 3, 0, 6, 3, 9, 6, 9, 10, 6, 7, 3], + [6, 1, 10, 6, 7, 1, 7, 0, 1, 7, 8, 0], + [6, 7, 10, 10, 7, 1, 7, 3, 1], + [7, 11, 6, 3, 8, 2, 8, 10, 2, 8, 9, 10], + [11, 6, 7, 10, 0, 9, 10, 2, 0], + [2, 1, 10, 7, 11, 6, 8, 0, 3], + [1, 10, 2, 6, 7, 11], + [7, 2, 6, 7, 9, 2, 2, 9, 1, 7, 8, 9], + [1, 0, 9, 3, 6, 7, 3, 2, 6], + [8, 0, 7, 7, 0, 6, 0, 2, 6], + [2, 7, 3, 2, 6, 7], + [7, 11, 6, 3, 9, 1, 3, 8, 9], + [9, 1, 0, 11, 6, 7], + [0, 3, 8, 11, 6, 7], + [11, 6, 7], + [11, 7, 5, 11, 5, 10], + [3, 0, 8, 7, 5, 10, 7, 10, 11], + [9, 0, 1, 10, 11, 7, 10, 7, 5], + [3, 1, 9, 3, 9, 8, 7, 10, 11, 7, 5, 10], + [10, 2, 5, 2, 3, 5, 5, 3, 7], + [5, 10, 2, 8, 5, 2, 8, 7, 5, 8, 2, 0], + [9, 0, 1, 10, 2, 5, 5, 2, 3, 5, 3, 7], + [1, 10, 2, 5, 8, 7, 5, 9, 8], + [2, 11, 1, 11, 7, 1, 1, 7, 5], + [0, 8, 3, 2, 11, 1, 1, 11, 7, 1, 7, 5], + [9, 0, 2, 9, 2, 7, 2, 11, 7, 9, 7, 5], + [11, 3, 2, 8, 5, 9, 8, 7, 5], + [1, 3, 7, 1, 7, 5], + [8, 7, 0, 0, 7, 1, 7, 5, 1], + [0, 3, 9, 9, 3, 5, 3, 7, 5], + [9, 7, 5, 9, 8, 7], + [4, 5, 8, 5, 10, 8, 8, 10, 11], + [3, 0, 4, 3, 4, 10, 4, 5, 10, 3, 10, 11], + [0, 1, 9, 4, 5, 8, 8, 5, 10, 8, 10, 11], + [5, 9, 4, 1, 11, 3, 1, 10, 11], + [3, 8, 4, 3, 4, 2, 2, 4, 5, 2, 5, 10], + [10, 2, 5, 5, 2, 4, 2, 0, 4], + [0, 3, 8, 5, 9, 4, 10, 2, 1], + [2, 1, 10, 9, 4, 5], + [8, 4, 5, 2, 8, 5, 2, 11, 8, 2, 5, 1], + [3, 2, 11, 1, 4, 5, 1, 0, 4], + [9, 4, 5, 8, 2, 11, 8, 0, 2], + [11, 3, 2, 9, 4, 5], + [4, 5, 8, 8, 5, 3, 5, 1, 3], + [5, 0, 4, 5, 1, 0], + [3, 8, 0, 4, 5, 9], + [9, 4, 5], + [7, 4, 11, 4, 9, 11, 11, 9, 10], + [3, 0, 8, 7, 4, 11, 11, 4, 9, 11, 9, 10], + [11, 7, 4, 1, 11, 4, 1, 10, 11, 1, 4, 0], + [8, 7, 4, 11, 1, 10, 11, 3, 1], + [2, 3, 7, 2, 7, 9, 7, 4, 9, 2, 9, 10], + [4, 8, 7, 0, 10, 2, 0, 9, 10], + [2, 1, 10, 0, 7, 4, 0, 3, 7], + [10, 2, 1, 8, 7, 4], + [2, 11, 7, 2, 7, 1, 1, 7, 4, 1, 4, 9], + [3, 2, 11, 4, 8, 7, 9, 1, 0], + [7, 4, 11, 11, 4, 2, 4, 0, 2], + [2, 11, 3, 7, 4, 8], + [9, 1, 4, 4, 1, 7, 1, 3, 7], + [1, 0, 9, 8, 7, 4], + [3, 4, 0, 3, 7, 4], + [8, 7, 4], + [8, 9, 10, 8, 10, 11], + [0, 9, 3, 3, 9, 11, 9, 10, 11], + [1, 10, 0, 0, 10, 8, 10, 11, 8], + [10, 3, 1, 10, 11, 3], + [3, 8, 2, 2, 8, 10, 8, 9, 10], + [9, 2, 0, 9, 10, 2], + [8, 0, 3, 1, 10, 2], + [10, 2, 1], + [2, 11, 1, 1, 11, 9, 11, 8, 9], + [11, 3, 2, 0, 9, 1], + [11, 0, 2, 11, 8, 0], + [11, 3, 2], + [8, 1, 3, 8, 9, 1], + [9, 1, 0], + [8, 0, 3], + [] + ]; + } + march(b, A, S, n) { + let o = !!n.fulltable, w = n.hasOwnProperty("origin") && n.origin.hasOwnProperty("x") ? n.origin : { x: 0, y: 0, z: 0 }, p = !!n.voxel, v = n.matrix, a = n.nX || 0, l = n.nY || 0, g = n.nZ || 0, M = n.scale || 1, L = null; + n.unitCube ? L = n.unitCube : L = { x: M, y: M, z: M }; + let T = new Int32Array(a * l * g), D, R; + for (D = 0, R = T.length; D < R; ++D) + T[D] = -1; + let B = function(N, $, k, G, H, U) { + let V = { x: 0, y: 0, z: 0 }, Q = !!(G & 1 << H), oe = !!(G & 1 << U), ee = H; + if (!Q && oe && (ee = U), ee & 1 && k++, ee & 2 && $++, ee & 4 && N++, v) { + let me = new s.Vector3(N, $, k); + me = me.applyMatrix4(v), V = { x: me.x, y: me.y, z: me.z }; + } else + V.x = w.x + L.x * N, V.y = w.y + L.y * $, V.z = w.z + L.z * k; + let ne = (l * N + $) * g + k; + return p ? (A.push(V), A.length - 1) : (T[ne] < 0 && (T[ne] = A.length, A.push(V)), T[ne]); + }, P = new Int32Array(12), z = o ? this.edgeTable2 : this.edgeTable, F = o ? this.triTable2 : this.triTable; + for (D = 0; D < a - 1; ++D) + for (let N = 0; N < l - 1; ++N) + for (let $ = 0; $ < g - 1; ++$) { + let k = 0; + for (let U = 0; U < 8; ++U) { + let V = (l * (D + ((U & 4) >> 2)) + N + ((U & 2) >> 1)) * g + $ + (U & 1), Q = !!(b[V] & this.ISDONE); + k |= Q << U; + } + if (k === 0 || k === 255) + continue; + let G = z[k]; + if (G === 0) + continue; + let H = F[k]; + G & 1 && (P[0] = B(D, N, $, k, 0, 1)), G & 2 && (P[1] = B(D, N, $, k, 1, 3)), G & 4 && (P[2] = B(D, N, $, k, 3, 2)), G & 8 && (P[3] = B(D, N, $, k, 2, 0)), G & 16 && (P[4] = B(D, N, $, k, 4, 5)), G & 32 && (P[5] = B(D, N, $, k, 5, 7)), G & 64 && (P[6] = B(D, N, $, k, 7, 6)), G & 128 && (P[7] = B(D, N, $, k, 6, 4)), G & 256 && (P[8] = B(D, N, $, k, 0, 4)), G & 512 && (P[9] = B(D, N, $, k, 1, 5)), G & 1024 && (P[10] = B(D, N, $, k, 3, 7)), G & 2048 && (P[11] = B(D, N, $, k, 2, 6)); + for (let U = 0; U < H.length; U += 3) { + let V = P[H[U]], Q = P[H[U + 1]], oe = P[H[U + 2]]; + p && U >= 3 && (A.push(A[V]), V = A.length - 1, A.push(A[Q]), Q = A.length - 1, A.push(A[oe]), oe = A.length - 1), S.push(V), S.push(Q), S.push(oe); + } + } + } + laplacianSmooth(b, A, S) { + let n = new Array(A.length), o, w, p, v, a; + for (o = 0, w = A.length; o < w; o++) + n[o] = { + x: 0, + y: 0, + z: 0 + }; + let l = new Array(20), g; + for (o = 0; o < 20; o++) + l[o] = new Array(A.length); + for (o = 0, w = A.length; o < w; o++) + l[0][o] = 0; + for (o = 0, w = S.length / 3; o < w; o++) { + let T = o * 3, D = o * 3 + 1, R = o * 3 + 2; + for (g = !0, p = 0, v = l[0][S[T]]; p < v; p++) + if (S[D] == l[p + 1][S[T]]) { + g = !1; + break; + } + for (g && (l[0][S[T]]++, l[l[0][S[T]]][S[T]] = S[D]), g = !0, p = 0, v = l[0][S[T]]; p < v; p++) + if (S[R] == l[p + 1][S[T]]) { + g = !1; + break; + } + for (g && (l[0][S[T]]++, l[l[0][S[T]]][S[T]] = S[R]), g = !0, p = 0, v = l[0][S[D]]; p < v; p++) + if (S[T] == l[p + 1][S[D]]) { + g = !1; + break; + } + for (g && (l[0][S[D]]++, l[l[0][S[D]]][S[D]] = S[T]), g = !0, p = 0, v = l[0][S[D]]; p < v; p++) + if (S[R] == l[p + 1][S[D]]) { + g = !1; + break; + } + for (g && (l[0][S[D]]++, l[l[0][S[D]]][S[D]] = S[R]), g = !0, p = 0; p < l[0][S[R]]; p++) + if (S[T] == l[p + 1][S[R]]) { + g = !1; + break; + } + for (g && (l[0][S[R]]++, l[l[0][S[R]]][S[R]] = S[T]), g = !0, p = 0, v = l[0][S[R]]; p < v; p++) + if (S[D] == l[p + 1][S[R]]) { + g = !1; + break; + } + g && (l[0][S[R]]++, l[l[0][S[R]]][S[R]] = S[D]); + } + let M = 1, L = 0.5; + for (a = 0; a < b; a++) { + for (o = 0, w = A.length; o < w; o++) + if (l[0][o] < 3) + n[o].x = A[o].x, n[o].y = A[o].y, n[o].z = A[o].z; + else if (l[0][o] == 3 || l[0][o] == 4) { + for (n[o].x = 0, n[o].y = 0, n[o].z = 0, p = 0, v = l[0][o]; p < v; p++) + n[o].x += A[l[p + 1][o]].x, n[o].y += A[l[p + 1][o]].y, n[o].z += A[l[p + 1][o]].z; + n[o].x += L * A[o].x, n[o].y += L * A[o].y, n[o].z += L * A[o].z, n[o].x /= L + l[0][o], n[o].y /= L + l[0][o], n[o].z /= L + l[0][o]; + } else { + for (n[o].x = 0, n[o].y = 0, n[o].z = 0, p = 0, v = l[0][o]; p < v; p++) + n[o].x += A[l[p + 1][o]].x, n[o].y += A[l[p + 1][o]].y, n[o].z += A[l[p + 1][o]].z; + n[o].x += M * A[o].x, n[o].y += M * A[o].y, n[o].z += M * A[o].z, n[o].x /= M + l[0][o], n[o].y /= M + l[0][o], n[o].z /= M + l[0][o]; + } + for (o = 0, w = A.length; o < w; o++) + A[o].x = n[o].x, A[o].y = n[o].y, A[o].z = n[o].z; + } + } + } + let u = new h(); + class E { + constructor(b, A, S) { + this.data = new Int32Array(b * A * S * 3), this.width = A, this.height = S; + } + // set position x,y,z to pt, which has ix,iy,and iz + set(b, A, S, n) { + let o = ((b * this.width + A) * this.height + S) * 3; + this.data[o] = n.ix, this.data[o + 1] = n.iy, this.data[o + 2] = n.iz; + } + // return point at x,y,z + get(b, A, S) { + let n = ((b * this.width + A) * this.height + S) * 3; + return { + ix: this.data[n], + iy: this.data[n + 1], + iz: this.data[n + 2] + }; + } + } + class c { + constructor() { + this.INOUT = 1, this.ISDONE = 2, this.ISBOUND = 4, this.ptranx = 0, this.ptrany = 0, this.ptranz = 0, this.probeRadius = 1.4, this.defaultScaleFactor = 2, this.scaleFactor = this.defaultScaleFactor, this.pHeight = 0, this.pWidth = 0, this.pLength = 0, this.cutRadius = 0, this.vpBits = null, this.vpDistance = null, this.vpAtomID = null, this.pminx = 0, this.pminy = 0, this.pminz = 0, this.pmaxx = 0, this.pmaxy = 0, this.pmaxz = 0, this.depty = {}, this.widxz = {}, this.faces = [], this.verts = [], this.vdwRadii = { + H: 1.2, + Li: 1.82, + Na: 2.27, + K: 2.75, + C: 1.7, + N: 1.55, + O: 1.52, + F: 1.47, + P: 1.8, + S: 1.8, + CL: 1.75, + BR: 1.85, + SE: 1.9, + ZN: 1.39, + CU: 1.4, + NI: 1.63, + X: 2 + }, this.nb = [ + new Int32Array([1, 0, 0]), + new Int32Array([-1, 0, 0]), + new Int32Array([0, 1, 0]), + new Int32Array([0, -1, 0]), + new Int32Array([0, 0, 1]), + new Int32Array([0, 0, -1]), + new Int32Array([1, 1, 0]), + new Int32Array([1, -1, 0]), + new Int32Array([-1, 1, 0]), + new Int32Array([-1, -1, 0]), + new Int32Array([1, 0, 1]), + new Int32Array([1, 0, -1]), + new Int32Array([-1, 0, 1]), + new Int32Array([-1, 0, -1]), + new Int32Array([0, 1, 1]), + new Int32Array([0, 1, -1]), + new Int32Array([0, -1, 1]), + new Int32Array([0, -1, -1]), + new Int32Array([1, 1, 1]), + new Int32Array([1, 1, -1]), + new Int32Array([1, -1, 1]), + new Int32Array([-1, 1, 1]), + new Int32Array([1, -1, -1]), + new Int32Array([-1, -1, 1]), + new Int32Array([-1, 1, -1]), + new Int32Array([-1, -1, -1]) + ], c.MarchingCube || (c.MarchingCube = new h()); + } + getVDWIndex(b) { + return !b.elem || typeof this.vdwRadii[b.elem] > "u" ? "X" : b.elem; + } + getFacesAndVertices(b) { + let A = {}; + for (let o = 0, w = b.length; o < w; o++) + A[b[o]] = !0; + let S = this.verts; + for (let o = 0, w = S.length; o < w; o++) + S[o].x = S[o].x / this.scaleFactor - this.ptranx, S[o].y = S[o].y / this.scaleFactor - this.ptrany, S[o].z = S[o].z / this.scaleFactor - this.ptranz; + let n = []; + for (let o = 0, w = this.faces.length; o < w; o += 3) { + let p = this.faces[o], v = this.faces[o + 1], a = this.faces[o + 2], l = S[p].atomid, g = S[v].atomid, M = S[a].atomid, L = l; + g < L && (L = g), M < L && (L = M), A[L] && p !== v && v !== a && p !== a && (n.push(p), n.push(v), n.push(a)); + } + return this.vpBits = null, this.vpDistance = null, this.vpAtomID = null, { + vertices: S, + faces: n + }; + } + initparm(b, A, S) { + S > 1e6 && (this.scaleFactor = this.defaultScaleFactor / 2); + let n = 1 / this.scaleFactor * 5.5; + this.pminx = b[0][0], this.pmaxx = b[1][0], this.pminy = b[0][1], this.pmaxy = b[1][1], this.pminz = b[0][2], this.pmaxz = b[1][2], A ? (this.pminx -= this.probeRadius + n, this.pminy -= this.probeRadius + n, this.pminz -= this.probeRadius + n, this.pmaxx += this.probeRadius + n, this.pmaxy += this.probeRadius + n, this.pmaxz += this.probeRadius + n) : (this.pminx -= n, this.pminy -= n, this.pminz -= n, this.pmaxx += n, this.pmaxy += n, this.pmaxz += n), this.pminx = Math.floor(this.pminx * this.scaleFactor) / this.scaleFactor, this.pminy = Math.floor(this.pminy * this.scaleFactor) / this.scaleFactor, this.pminz = Math.floor(this.pminz * this.scaleFactor) / this.scaleFactor, this.pmaxx = Math.ceil(this.pmaxx * this.scaleFactor) / this.scaleFactor, this.pmaxy = Math.ceil(this.pmaxy * this.scaleFactor) / this.scaleFactor, this.pmaxz = Math.ceil(this.pmaxz * this.scaleFactor) / this.scaleFactor, this.ptranx = -this.pminx, this.ptrany = -this.pminy, this.ptranz = -this.pminz, this.pLength = Math.ceil(this.scaleFactor * (this.pmaxx - this.pminx)) + 1, this.pWidth = Math.ceil(this.scaleFactor * (this.pmaxy - this.pminy)) + 1, this.pHeight = Math.ceil(this.scaleFactor * (this.pmaxz - this.pminz)) + 1, this.boundingatom(A), this.cutRadius = this.probeRadius * this.scaleFactor, this.vpBits = new Uint8Array(this.pLength * this.pWidth * this.pHeight), this.vpDistance = new Float64Array(this.pLength * this.pWidth * this.pHeight), this.vpAtomID = new Int32Array(this.pLength * this.pWidth * this.pHeight); + } + boundingatom(b) { + let A = {}; + for (const S in this.vdwRadii) { + let n = this.vdwRadii[S]; + b ? A[S] = (n + this.probeRadius) * this.scaleFactor + 0.5 : A[S] = n * this.scaleFactor + 0.5; + let o = A[S] * A[S]; + this.widxz[S] = Math.floor(A[S]) + 1, this.depty[S] = new Int32Array(this.widxz[S] * this.widxz[S]); + let w = 0; + for (let p = 0; p < this.widxz[S]; p++) + for (let v = 0; v < this.widxz[S]; v++) { + let a = p * p + v * v; + if (a > o) + this.depty[S][w] = -1; + else { + let l = Math.sqrt(o - a); + this.depty[S][w] = Math.floor(l); + } + w++; + } + } + } + fillvoxels(b, A) { + for (let S = 0, n = this.vpBits.length; S < n; S++) + this.vpBits[S] = 0, this.vpDistance[S] = -1, this.vpAtomID[S] = -1; + for (let S in A) { + let n = b[A[S]]; + n !== void 0 && this.fillAtom(n, b); + } + for (let S = 0, n = this.vpBits.length; S < n; S++) + this.vpBits[S] & this.INOUT && (this.vpBits[S] |= this.ISDONE); + } + fillAtom(b, A) { + let S = Math.floor(0.5 + this.scaleFactor * (b.x + this.ptranx)), n = Math.floor(0.5 + this.scaleFactor * (b.y + this.ptrany)), o = Math.floor(0.5 + this.scaleFactor * (b.z + this.ptranz)), w = this.getVDWIndex(b), p = 0, v = this.pWidth * this.pHeight; + for (let a = 0, l = this.widxz[w]; a < l; a++) + for (let g = 0; g < l; g++) { + if (this.depty[w][p] != -1) { + for (let M = -1; M < 2; M++) + for (let L = -1; L < 2; L++) + for (let T = -1; T < 2; T++) + if (M !== 0 && L !== 0 && T !== 0) { + let D = M * a, R = T * g; + for (let B = 0; B <= this.depty[w][p]; B++) { + let P = B * L, z = S + D, F = n + P, N = o + R; + if (z < 0 || F < 0 || N < 0 || z >= this.pLength || F >= this.pWidth || N >= this.pHeight) + continue; + let $ = z * v + F * this.pHeight + N; + if (!(this.vpBits[$] & this.INOUT)) + this.vpBits[$] |= this.INOUT, this.vpAtomID[$] = b.serial; + else { + let k = A[this.vpAtomID[$]]; + if (k.serial != b.serial) { + let G = S + D - Math.floor(0.5 + this.scaleFactor * (k.x + this.ptranx)), H = n + P - Math.floor(0.5 + this.scaleFactor * (k.y + this.ptrany)), U = o + R - Math.floor(0.5 + this.scaleFactor * (k.z + this.ptranz)); + D * D + P * P + R * R < G * G + H * H + U * U && (this.vpAtomID[$] = b.serial); + } + } + } + } + } + p++; + } + } + fillvoxelswaals(b, A) { + for (let S = 0, n = this.vpBits.length; S < n; S++) + this.vpBits[S] &= ~this.ISDONE; + for (let S in A) { + let n = b[A[S]]; + n !== void 0 && this.fillAtomWaals(n, b); + } + } + fillAtomWaals(b, A) { + let S = 0, n = Math.floor(0.5 + this.scaleFactor * (b.x + this.ptranx)), o = Math.floor(0.5 + this.scaleFactor * (b.y + this.ptrany)), w = Math.floor(0.5 + this.scaleFactor * (b.z + this.ptranz)), p = this.getVDWIndex(b), v = this.pWidth * this.pHeight; + for (let a = 0, l = this.widxz[p]; a < l; a++) + for (let g = 0; g < l; g++) { + if (this.depty[p][S] != -1) { + for (let M = -1; M < 2; M++) + for (let L = -1; L < 2; L++) + for (let T = -1; T < 2; T++) + if (M !== 0 && L !== 0 && T !== 0) { + let D = M * a, R = T * g; + for (let B = 0; B <= this.depty[p][S]; B++) { + let P = B * L, z = n + D, F = o + P, N = w + R; + if (z < 0 || F < 0 || N < 0 || z >= this.pLength || F >= this.pWidth || N >= this.pHeight) + continue; + let $ = z * v + F * this.pHeight + N; + if (!(this.vpBits[$] & this.ISDONE)) + this.vpBits[$] |= this.ISDONE, this.vpAtomID[$] = b.serial; + else { + let k = A[this.vpAtomID[$]]; + if (k.serial != b.serial) { + let G = n + D - Math.floor(0.5 + this.scaleFactor * (k.x + this.ptranx)), H = o + P - Math.floor(0.5 + this.scaleFactor * (k.y + this.ptrany)), U = w + R - Math.floor(0.5 + this.scaleFactor * (k.z + this.ptranz)); + D * D + P * P + R * R < G * G + H * H + U * U && (this.vpAtomID[$] = b.serial); + } + } + } + } + } + S++; + } + } + buildboundary() { + let b = this.pWidth * this.pHeight; + for (let A = 0; A < this.pLength; A++) + for (let S = 0; S < this.pHeight; S++) + for (let n = 0; n < this.pWidth; n++) { + let o = A * b + n * this.pHeight + S; + if (this.vpBits[o] & this.INOUT) { + let w = 0; + for (; w < 26; ) { + let p = A + this.nb[w][0], v = S + this.nb[w][2], a = n + this.nb[w][1]; + if (p > -1 && p < this.pLength && a > -1 && a < this.pWidth && v > -1 && v < this.pHeight && !(this.vpBits[p * b + a * this.pHeight + v] & this.INOUT)) { + this.vpBits[o] |= this.ISBOUND; + break; + } else + w++; + } + } + } + } + fastdistancemap() { + let b = new E(this.pLength, this.pWidth, this.pHeight), A = this.pWidth * this.pHeight, S = this.cutRadius * this.cutRadius, n = [], o = [], w; + for (let a = 0; a < this.pLength; a++) + for (let l = 0; l < this.pWidth; l++) + for (let g = 0; g < this.pHeight; g++) + if (w = a * A + l * this.pHeight + g, this.vpBits[w] &= ~this.ISDONE, this.vpBits[w] & this.INOUT && this.vpBits[w] & this.ISBOUND) { + let M = { + ix: a, + iy: l, + iz: g + }; + b.set(a, l, g, M), n.push(M), this.vpDistance[w] = 0, this.vpBits[w] |= this.ISDONE, this.vpBits[w] &= ~this.ISBOUND; + } + do { + o = this.fastoneshell(n, b), n = []; + for (let a = 0, l = o.length; a < l; a++) + w = A * o[a].ix + this.pHeight * o[a].iy + o[a].iz, this.vpBits[w] &= ~this.ISBOUND, this.vpDistance[w] <= 1.0404 * S && n.push({ + ix: o[a].ix, + iy: o[a].iy, + iz: o[a].iz + }); + } while (n.length !== 0); + n = [], o = [], b = null; + let p = this.scaleFactor - 0.5; + p < 0 && (p = 0); + let v = S - 0.5 / (0.1 + p); + for (let a = 0; a < this.pLength; a++) + for (let l = 0; l < this.pWidth; l++) + for (let g = 0; g < this.pHeight; g++) + w = a * A + l * this.pHeight + g, this.vpBits[w] &= ~this.ISBOUND, this.vpBits[w] & this.INOUT && (!(this.vpBits[w] & this.ISDONE) || this.vpBits[w] & this.ISDONE && this.vpDistance[w] >= v) && (this.vpBits[w] |= this.ISBOUND); + } + fastoneshell(b, A) { + let S, n, o, w, p, v, a, l, g, M = []; + if (b.length === 0) + return M; + let L = { + ix: -1, + iy: -1, + iz: -1 + }, T = this.pWidth * this.pHeight; + for (let D = 0, R = b.length; D < R; D++) { + S = b[D].ix, n = b[D].iy, o = b[D].iz, l = A.get(S, n, o); + for (let B = 0; B < 6; B++) + L.ix = S + this.nb[B][0], L.iy = n + this.nb[B][1], L.iz = o + this.nb[B][2], L.ix < this.pLength && L.ix > -1 && L.iy < this.pWidth && L.iy > -1 && L.iz < this.pHeight && L.iz > -1 && (g = L.ix * T + this.pHeight * L.iy + L.iz, this.vpBits[g] & this.INOUT && !(this.vpBits[g] & this.ISDONE) ? (A.set(L.ix, L.iy, o + this.nb[B][2], l), w = L.ix - l.ix, p = L.iy - l.iy, v = L.iz - l.iz, a = w * w + p * p + v * v, this.vpDistance[g] = a, this.vpBits[g] |= this.ISDONE, this.vpBits[g] |= this.ISBOUND, M.push({ + ix: L.ix, + iy: L.iy, + iz: L.iz + })) : this.vpBits[g] & this.INOUT && this.vpBits[g] & this.ISDONE && (w = L.ix - l.ix, p = L.iy - l.iy, v = L.iz - l.iz, a = w * w + p * p + v * v, a < this.vpDistance[g] && (A.set(L.ix, L.iy, L.iz, l), this.vpDistance[g] = a, this.vpBits[g] & this.ISBOUND || (this.vpBits[g] |= this.ISBOUND, M.push({ + ix: L.ix, + iy: L.iy, + iz: L.iz + }))))); + } + for (let D = 0, R = b.length; D < R; D++) { + S = b[D].ix, n = b[D].iy, o = b[D].iz, l = A.get(S, n, o); + for (let B = 6; B < 18; B++) + L.ix = S + this.nb[B][0], L.iy = n + this.nb[B][1], L.iz = o + this.nb[B][2], L.ix < this.pLength && L.ix > -1 && L.iy < this.pWidth && L.iy > -1 && L.iz < this.pHeight && L.iz > -1 && (g = L.ix * T + this.pHeight * L.iy + L.iz, this.vpBits[g] & this.INOUT && !(this.vpBits[g] & this.ISDONE) ? (A.set(L.ix, L.iy, o + this.nb[B][2], l), w = L.ix - l.ix, p = L.iy - l.iy, v = L.iz - l.iz, a = w * w + p * p + v * v, this.vpDistance[g] = a, this.vpBits[g] |= this.ISDONE, this.vpBits[g] |= this.ISBOUND, M.push({ + ix: L.ix, + iy: L.iy, + iz: L.iz + })) : this.vpBits[g] & this.INOUT && this.vpBits[g] & this.ISDONE && (w = L.ix - l.ix, p = L.iy - l.iy, v = L.iz - l.iz, a = w * w + p * p + v * v, a < this.vpDistance[g] && (A.set(L.ix, L.iy, L.iz, l), this.vpDistance[g] = a, this.vpBits[g] & this.ISBOUND || (this.vpBits[g] |= this.ISBOUND, M.push({ + ix: L.ix, + iy: L.iy, + iz: L.iz + }))))); + } + for (let D = 0, R = b.length; D < R; D++) { + S = b[D].ix, n = b[D].iy, o = b[D].iz, l = A.get(S, n, o); + for (let B = 18; B < 26; B++) + L.ix = S + this.nb[B][0], L.iy = n + this.nb[B][1], L.iz = o + this.nb[B][2], L.ix < this.pLength && L.ix > -1 && L.iy < this.pWidth && L.iy > -1 && L.iz < this.pHeight && L.iz > -1 && (g = L.ix * T + this.pHeight * L.iy + L.iz, this.vpBits[g] & this.INOUT && !(this.vpBits[g] & this.ISDONE) ? (A.set(L.ix, L.iy, o + this.nb[B][2], l), w = L.ix - l.ix, p = L.iy - l.iy, v = L.iz - l.iz, a = w * w + p * p + v * v, this.vpDistance[g] = a, this.vpBits[g] |= this.ISDONE, this.vpBits[g] |= this.ISBOUND, M.push({ + ix: L.ix, + iy: L.iy, + iz: L.iz + })) : this.vpBits[g] & this.INOUT && this.vpBits[g] & this.ISDONE && (w = L.ix - l.ix, p = L.iy - l.iy, v = L.iz - l.iz, a = w * w + p * p + v * v, a < this.vpDistance[g] && (A.set(L.ix, L.iy, L.iz, l), this.vpDistance[g] = a, this.vpBits[g] & this.ISBOUND || (this.vpBits[g] |= this.ISBOUND, M.push({ + ix: L.ix, + iy: L.iy, + iz: L.iz + }))))); + } + return M; + } + marchingcubeinit(b) { + for (let A = 0, S = this.vpBits.length; A < S; A++) + b == 1 ? this.vpBits[A] &= ~this.ISBOUND : b == 4 ? (this.vpBits[A] &= ~this.ISDONE, this.vpBits[A] & this.ISBOUND && (this.vpBits[A] |= this.ISDONE), this.vpBits[A] &= ~this.ISBOUND) : b == 2 ? this.vpBits[A] & this.ISBOUND && this.vpBits[A] & this.ISDONE ? this.vpBits[A] &= ~this.ISBOUND : this.vpBits[A] & this.ISBOUND && !(this.vpBits[A] & this.ISDONE) && (this.vpBits[A] |= this.ISDONE) : b == 3 && (this.vpBits[A] &= ~this.ISBOUND); + } + marchingcube(b) { + this.marchingcubeinit(b), this.verts = [], this.faces = [], c.MarchingCube.march(this.vpBits, this.verts, this.faces, { + smooth: 1, + nX: this.pLength, + nY: this.pWidth, + nZ: this.pHeight + }); + let A = this.pWidth * this.pHeight; + for (let S = 0, n = this.verts.length; S < n; S++) + this.verts[S].atomid = this.vpAtomID[this.verts[S].x * A + this.pHeight * this.verts[S].y + this.verts[S].z]; + c.MarchingCube.laplacianSmooth(1, this.verts, this.faces); + } + } + c.MarchingCube = new h(); + } + ), + /***/ + "./src/VolumeData.ts": ( + /*!***************************!*\ + !*** ./src/VolumeData.ts ***! + \***************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + VolumeData: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ./utilities */ + "./src/utilities.ts" + ), f = t( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), _ = t( + /*! ./parsers/VASP */ + "./src/parsers/VASP.ts" + ), x = t( + /*! ./parsers/CUBE */ + "./src/parsers/CUBE.ts" + ), h = t( + /*! pako */ + "./node_modules/pako/dist/pako.esm.mjs" + ); + class u { + constructor(c, C, b) { + if (this.unit = { + x: 1, + y: 1, + z: 1 + }, this.origin = { + x: 0, + y: 0, + z: 0 + }, this.size = { + x: 0, + y: 0, + z: 0 + }, this.data = new Float32Array([]), this.matrix = null, this.inversematrix = null, this.isbinary = /* @__PURE__ */ new Set(["ccp4", "CCP4"]), this.getCoordinates = function(w) { + var p = w / (this.size.y * this.size.z), v = w % (this.size.y * this.size.z), a = w % this.size.z; + return p *= this.unit.x, v *= this.unit.y, a *= this.unit.z, p += this.origin.x, v += this.origin.y, a += this.origin.z, { x: p, y: v, z: a }; + }, this.vasp = function(w) { + var p = w.replace(/^\s+/, "").split(/[\n\r]/), v = (0, _.VASP)(w)[0], a = v.length; + if (a == 0) { + console.log("No good formating of CHG or CHGCAR file, not atomic information provided in the file."), this.data = []; + return; + } + var l = 1.889725992, g = 0.036749309, M = parseFloat(p[1]), L; + L = p[2].replace(/^\s+/, "").split(/\s+/); + var T = new f.Vector3(parseFloat(L[0]), parseFloat(L[1]), parseFloat(L[2])).multiplyScalar(M * l); + L = p[3].replace(/^\s+/, "").split(/\s+/); + var D = new f.Vector3(parseFloat(L[0]), parseFloat(L[1]), parseFloat(L[2])).multiplyScalar(M * l); + L = p[4].replace(/^\s+/, "").split(/\s+/); + var R = new f.Vector3(parseFloat(L[0]), parseFloat(L[1]), parseFloat(L[2])).multiplyScalar(M * l), B = T.x * (D.y * R.z - R.y * D.z) - D.x * (T.y * R.z - R.y * T.z) + R.x * (T.y * D.z - D.y * T.z); + B = Math.abs(B) / Math.pow(l, 3); + var P = 1 / B; + p.splice(0, 8 + a + 1); + var z = p[0].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), F = Math.abs(parseFloat(z[0])), N = Math.abs(parseFloat(z[1])), $ = Math.abs(parseFloat(z[2])), k = this.origin = new f.Vector3(0, 0, 0); + this.size = { x: F, y: N, z: $ }, this.unit = new f.Vector3(T.x, D.y, R.z), T = T.multiplyScalar(1 / (l * F)), D = D.multiplyScalar(1 / (l * N)), R = R.multiplyScalar(1 / (l * $)), (T.y != 0 || T.z != 0 || D.x != 0 || D.z != 0 || R.x != 0 || R.y != 0) && (this.matrix = new f.Matrix4(T.x, D.x, R.x, 0, T.y, D.y, R.y, 0, T.z, D.z, R.z, 0, 0, 0, 0, 1), this.matrix = this.matrix.multiplyMatrices(this.matrix, new f.Matrix4().makeTranslation(k.x, k.y, k.z)), this.origin = new f.Vector3(0, 0, 0), this.unit = new f.Vector3(1, 1, 1)), p.splice(0, 1); + var G = p.join(" "); + G = G.replace(/^\s+/, ""); + var H = G.split(/[\s\r]+/); + H.splice(F * N * $ + 1); + for (var U = Float32Array.from(H, parseFloat), V = 0; V < U.length; V++) + U[V] = U[V] * P * g; + this.data = U; + }, this.dx = function(w) { + var p = w.split(/[\n\r]+/), v, a = /gridpositions\s+counts\s+(\d+)\s+(\d+)\s+(\d+)/, l = /^origin\s+(\S+)\s+(\S+)\s+(\S+)/, g = /^delta\s+(\S+)\s+(\S+)\s+(\S+)/, M = /data follows/, L = 0; + for (L = 0; L < p.length; L++) { + var T = p[L]; + if (v = a.exec(T)) { + var D = parseInt(v[1]), R = parseInt(v[2]), B = parseInt(v[3]); + this.size = { x: D, y: R, z: B }; + } else if (v = g.exec(T)) { + var P = parseFloat(v[1]); + if ((parseFloat(v[2]) != 0 || parseFloat(v[3]) != 0) && console.log("Non-orthogonal delta matrix not currently supported in dx format"), L += 1, T = p[L], v = g.exec(T), v == null) { + console.log("Parse error in dx delta matrix"); + return; + } + var z = parseFloat(v[2]); + if ((parseFloat(v[1]) != 0 || parseFloat(v[3]) != 0) && console.log("Non-orthogonal delta matrix not currently supported in dx format"), L += 1, T = p[L], v = g.exec(T), v == null) { + console.log("Parse error in dx delta matrix"); + return; + } + var F = parseFloat(v[3]); + (parseFloat(v[1]) != 0 || parseFloat(v[2]) != 0) && console.log("Non-orthogonal delta matrix not currently supported in dx format"), this.unit = new f.Vector3(P, z, F); + } else if (v = l.exec(T)) { + var N = parseFloat(v[1]), $ = parseFloat(v[2]), k = parseFloat(v[3]); + this.origin = new f.Vector3(N, $, k); + } else if (v = M.exec(T)) + break; + } + if (L += 1, !this.size || !this.origin || !this.unit || !this.size) { + console.log("Error parsing dx format"); + return; + } + var G = p.splice(L).join(" "), H = G.split(/[\s\r]+/); + this.data = Float32Array.from(H, parseFloat); + }, C = C.toLowerCase(), /\.gz$/.test(C)) { + C = C.replace(/\.gz$/, ""); + try { + this[C] && this.isbinary.has(C) ? (typeof c == "string" && (c = (0, s.base64ToArray)(c)), c = (0, h.inflate)(c)) : c = new TextDecoder("utf-8").decode((0, h.inflate)(c)); + } catch (w) { + console.log(w); + } + } + if (this[C] && (this.isbinary.has(C) && typeof c == "string" && (c = (0, s.base64ToArray)(c)), this[C](c)), b) { + if (b.negate) + for (let w = 0, p = this.data.length; w < p; w++) + this.data[w] = -this.data[w]; + if (b.normalize) { + var A = 0; + for (let w = 0, p = this.data.length; w < p; w++) + A += this.data[w]; + var S = A / this.data.length; + A = 0; + for (let w = 0, p = this.data.length; w < p; w++) { + var n = this.data[w] - S; + A += n * n; + } + var o = A / this.data.length; + for (let w = 0, p = this.data.length; w < p; w++) + this.data[w] = (this.data[w] - S) / o; + } + } + } + /** + * @function $3Dmol.VolumeData.getIndex + * @param {number} x,y,z - the coordinates + * @returns - index into flat array closest to provided coordinate; -1 if invalid + */ + getIndex(c, C, b) { + if (this.matrix) { + this.inversematrix == null && (this.inversematrix = new f.Matrix4().getInverse(this.matrix)); + var A = new f.Vector3(c, C, b); + A = A.applyMatrix4(this.inversematrix), c = A.x, C = A.y, b = A.z; + } else + c -= this.origin.x, C -= this.origin.y, b -= this.origin.z, c /= this.unit.x, C /= this.unit.y, b /= this.unit.z; + return c = Math.round(c), C = Math.round(C), b = Math.round(b), c < 0 || c >= this.size.x || C < 0 || C >= this.size.y || b < 0 || b >= this.size.z ? -1 : c * this.size.y * this.size.z + C * this.size.z + b; + } + /** + * @function $3Dmol.VolumeData.getVal + * @param {number} x,y,z - the coordinates + * @returns - value closest to provided coordinate; zero if coordinate invalid + */ + getVal(c, C, b) { + let A = this.getIndex(c, C, b); + return A < 0 ? 0 : this.data[A]; + } + // parse cube data + cube(c) { + var C = c.split(/\r?\n/); + if (!(C.length < 6)) { + var b = (0, x.CUBE)(c, {}).modelData[0].cryst, A = C[2].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), S = parseFloat(A[0]), n = Math.abs(S); + this.origin = b.origin, this.size = b.size, this.unit = b.unit, this.matrix = b.matrix4; + var o = 6; + S < 0 && o++; + var w = C.splice(n + o).join(" "); + w = w.replace(/^\s+/, ""); + var p = w.split(/[\s\r]+/); + this.data = Float32Array.from(p, parseFloat); + } + } + //parse cp4 files + ccp4(c) { + var C = {}; + c = new Int8Array(c); + var b = new Int32Array(c.buffer, 0, 56), A = new Float32Array(c.buffer, 0, 56), S = new DataView(c.buffer); + if (C.MAP = String.fromCharCode(S.getUint8(208), S.getUint8(209), S.getUint8(210), S.getUint8(211)), C.MACHST = [S.getUint8(212), S.getUint8(213)], C.MACHST[0] === 17 && C.MACHST[1] === 17) + for (var n = c.byteLength, o = 0; o < n; o += 4) + S.setFloat32(o, S.getFloat32(o), !0); + C.NX = b[0], C.NY = b[1], C.NZ = b[2], C.MODE = b[3], C.NXSTART = b[4], C.NYSTART = b[5], C.NZSTART = b[6], C.MX = b[7], C.MY = b[8], C.MZ = b[9], C.xlen = A[10], C.ylen = A[11], C.zlen = A[12], C.alpha = A[13], C.beta = A[14], C.gamma = A[15], C.MAPC = b[16], C.MAPR = b[17], C.MAPS = b[18], C.DMIN = A[19], C.DMAX = A[20], C.DMEAN = A[21], C.ISPG = b[22], C.NSYMBT = b[23], C.LSKFLG = b[24], C.originX = A[49], C.originY = A[50], C.originZ = A[51], C.ARMS = A[54]; + var w = C, p = [ + w.xlen, + 0, + 0 + ], v = [ + w.ylen * Math.cos(Math.PI / 180 * w.gamma), + w.ylen * Math.sin(Math.PI / 180 * w.gamma), + 0 + ], a = [ + w.zlen * Math.cos(Math.PI / 180 * w.beta), + w.zlen * (Math.cos(Math.PI / 180 * w.alpha) - Math.cos(Math.PI / 180 * w.gamma) * Math.cos(Math.PI / 180 * w.beta)) / Math.sin(Math.PI / 180 * w.gamma), + 0 + ]; + a[2] = Math.sqrt(w.zlen * w.zlen * Math.sin(Math.PI / 180 * w.beta) * Math.sin(Math.PI / 180 * w.beta) - a[1] * a[1]); + var l = [0, p, v, a], g = [0, w.MX, w.MY, w.MZ], M = [0, w.MAPC, w.MAPR, w.MAPS]; + this.matrix = new f.Matrix4(), this.matrix.set(l[M[1]][0] / g[M[1]], l[M[2]][0] / g[M[2]], l[M[3]][0] / g[M[3]], 0, l[M[1]][1] / g[M[1]], l[M[2]][1] / g[M[2]], l[M[3]][1] / g[M[3]], 0, l[M[1]][2] / g[M[1]], l[M[2]][2] / g[M[2]], l[M[3]][2] / g[M[3]], 0, 0, 0, 0, 1), this.matrix = this.matrix.multiplyMatrices(this.matrix, new f.Matrix4().makeTranslation(w.NXSTART + w.originX, w.NYSTART + w.originY, w.NZSTART + w.originZ)), this.origin = new f.Vector3(0, 0, 0), this.unit = new f.Vector3(1, 1, 1), this.size = { x: C.NX, y: C.NY, z: C.NZ }, this.dimensionorder = [C.MAPC, C.MAPR, C.MAPS]; + var L = new Float32Array(c.buffer, 1024 + C.NSYMBT), T = C.NX, D = C.NY, R = C.NZ; + this.data = new Float32Array(T * D * R); + for (let B = 0; B < T; B++) + for (let P = 0; P < D; P++) + for (let z = 0; z < R; z++) + this.data[(B * D + P) * R + z] = L[(z * D + P) * T + B]; + } + } + } + ), + /***/ + "./src/VolumetricRender.ts": ( + /*!*********************************!*\ + !*** ./src/VolumetricRender.ts ***! + \*********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + GLVolumetricRender: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ./WebGL/shapes */ + "./src/WebGL/shapes/index.ts" + ), f = t( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), _ = t( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), x = t( + /*! ./colors */ + "./src/colors.ts" + ), h = t( + /*! ./GLShape */ + "./src/GLShape.ts" + ); + class u { + static interpolateArray(c, C) { + function b(a, l, g) { + return a + (l - a) * g; + } + var A = [], S = (c.length - 1) / (C - 1); + A[0] = c[0]; + for (var n = 1; n < C - 1; n++) { + var o = n * S, w = Math.floor(o), p = Math.ceil(o), v = o - w; + A[n] = b(c[w], c[p], v); + } + return A[C - 1] = c[c.length - 1], A; + } + constructor(c, C) { + this.hidden = !1, this.boundingSphere = new s.Sphere(), this.renderedShapeObj = null, this.shapeObj = null, this.subsamples = 5, this.data = null, this.transferfunctionbuffer = [], this.min = 0, this.max = 0, C = C || {}; + var b = Object.assign([], C.transferfn); + this.subsamples = C.subsamples || 5; + let A = 256; + b.forEach(function(T) { + T.value = parseFloat(T.value); + }), b.sort(function(T, D) { + return T.value - D.value; + }), this.min = b[0].value, b.length == 0 && b.push(b[0]), this.max = b[b.length - 1].value; + var S, n, o, w, p, v, a, l, g, M; + for (let T = 0; T < b.length - 1; T++) + if (o = x.CC.color(b[T].color), w = x.CC.color(b[T + 1].color), g = b[T].opacity, M = b[T + 1].opacity, S = Math.floor((b[T].value - this.min) * A / (this.max - this.min)), n = Math.floor((b[T + 1].value - this.min) * A / (this.max - this.min)), S != n) { + p = u.interpolateArray([o.r * 255, w.r * 255], n - S), v = u.interpolateArray([o.g * 255, w.g * 255], n - S), a = u.interpolateArray([o.b * 255, w.b * 255], n - S), l = u.interpolateArray([g * 255, M * 255], n - S); + for (let D = 0; D < p.length; D++) + this.transferfunctionbuffer.push(p[D]), this.transferfunctionbuffer.push(v[D]), this.transferfunctionbuffer.push(a[D]), this.transferfunctionbuffer.push(l[D]); + } + if (this.transferfunctionbuffer = new Uint8ClampedArray(this.transferfunctionbuffer), c.matrix) { + let T = new f.Vector3(0, 0, 0), D = new f.Vector3(c.size.x, c.size.y, c.size.z), R = new f.Vector3(1, 1, 1); + T.applyMatrix4(c.matrix), D.applyMatrix4(c.matrix), R.applyMatrix4(c.matrix).sub(T), this.extent = [[T.x, T.y, T.z], [D.x, D.y, D.z]]; + for (let F = 1; F < 7; F++) + D.x = F & 1 ? c.size.x : 0, D.y = F & 2 ? c.size.y : 0, D.z = F & 4 ? c.size.z : 0, D.applyMatrix4(c.matrix), this.extent[0][0] = Math.min(this.extent[0][0], D.x), this.extent[0][1] = Math.min(this.extent[0][1], D.y), this.extent[0][2] = Math.min(this.extent[0][2], D.z), this.extent[1][0] = Math.max(this.extent[1][0], D.x), this.extent[1][1] = Math.max(this.extent[1][1], D.y), this.extent[1][2] = Math.max(this.extent[1][2], D.z); + let B = D.x - T.x, P = D.y - T.y, z = D.z - T.z; + this.maxdepth = Math.sqrt(B * B + P * P + z * z), this.minunit = Math.min(Math.min(R.x, R.y), R.z), this.texmatrix = new f.Matrix4().identity().scale({ x: c.size.x, y: c.size.y, z: c.size.z }), this.texmatrix = this.texmatrix.multiplyMatrices(c.matrix, this.texmatrix), this.texmatrix = this.texmatrix.getInverse(this.texmatrix); + } else { + this.texmatrix = new f.Matrix4().identity(); + let T = c.unit.x * c.size.x, D = c.unit.y * c.size.y, R = c.unit.z * c.size.z; + this.texmatrix.makeTranslation(-c.origin.x / T, -c.origin.y / D, -c.origin.z / R), this.texmatrix.scale({ x: 1 / T, y: 1 / D, z: 1 / R }), this.minunit = Math.min(Math.min(c.unit.x, c.unit.y), c.unit.z), this.extent = [ + [c.origin.x, c.origin.y, c.origin.z], + [c.origin.x + T, c.origin.y + D, c.origin.z + R] + ], this.maxdepth = Math.sqrt(T * T + D * D + R * R); + } + var L = new h.GLShape({}); + if (L.addBox({ + corner: { x: this.extent[0][0], y: this.extent[0][1], z: this.extent[0][2] }, + dimensions: { + w: this.extent[1][0] - this.extent[0][0], + h: this.extent[1][1] - this.extent[0][1], + d: this.extent[1][2] - this.extent[0][2] + } + }), this.geo = L.finalize(), this.boundingSphere.center = new f.Vector3((this.extent[0][0] + this.extent[1][0]) / 2, (this.extent[0][1] + this.extent[1][1]) / 2, (this.extent[0][2] + this.extent[1][2]) / 2), this.boundingSphere.radius = this.maxdepth / 2, C.coords !== void 0 && C.seldist !== void 0) { + let T = new Uint8Array(c.data.length), D = C.seldist, R = D * D; + for (let B = 0, P = C.coords.length; B < P; B++) { + let z = C.coords[B], F = z.x - D, N = z.y - D, $ = z.z - D, k = z.x + D, G = z.y + D, H = z.z + D; + if (c.getIndex(F, N, $) >= 0 || c.getIndex(k, G, H) >= 0) + for (let U = F; U < k; U += this.minunit) + for (let V = N; V < G; V += this.minunit) + for (let Q = $; Q < H; Q += this.minunit) { + let oe = c.getIndex(U, V, Q); + oe >= 0 && !T[oe] && (U - z.x) * (U - z.x) + (V - z.y) * (V - z.y) + (Q - z.z) * (Q - z.z) < R && (T[oe] = 1); + } + } + for (let B = 0, P = c.data.length; B < P; B++) + T[B] == 0 && (c.data[B] = 1 / 0); + } + this.data = c; + } + /** + * Initialize webgl objects for rendering + * @param {Object3D} group + * + */ + globj(c) { + if (this.renderedShapeObj && (c.remove(this.renderedShapeObj), this.renderedShapeObj = null), !this.hidden) { + this.shapeObj = new _.Object3D(); + var C = null, b = new _.Texture(this.data, !0), A = new _.Texture(this.transferfunctionbuffer, !1); + b.needsUpdate = !0, A.needsUpdate = !0, A.flipY = !1, C = new _.VolumetricMaterial({ + transferfn: A, + transfermin: this.min, + transfermax: this.max, + map: b, + extent: this.extent, + maxdepth: this.maxdepth, + texmatrix: this.texmatrix, + unit: this.minunit, + subsamples: this.subsamples + }); + var S = new _.Mesh(this.geo, C); + this.shapeObj.add(S), this.renderedShapeObj = this.shapeObj.clone(), c.add(this.renderedShapeObj); + } + } + removegl(c) { + this.renderedShapeObj && (this.renderedShapeObj.geometry !== void 0 && this.renderedShapeObj.geometry.dispose(), this.renderedShapeObj.material !== void 0 && this.renderedShapeObj.material.dispose(), c.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; + } + } + } + ), + /***/ + "./src/WebGL/Camera.ts": ( + /*!*****************************!*\ + !*** ./src/WebGL/Camera.ts ***! + \*****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Camera: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ./core */ + "./src/WebGL/core/index.ts" + ), f = t( + /*! ./math */ + "./src/WebGL/math/index.ts" + ); + class _ extends s.Object3D { + constructor(h = 50, u = 1, E = 0.1, c = 2e3, C = !1) { + super(), this.projectionMatrix = new f.Matrix4(), this.projectionMatrixInverse = new f.Matrix4(), this.matrixWorldInverse = new f.Matrix4(), this.fov = h, this.aspect = u, this.near = E, this.far = c; + var b = this.position.z; + this.right = b * Math.tan(Math.PI / 180 * h), this.left = -this.right, this.top = this.right / this.aspect, this.bottom = -this.top, this.ortho = !!C, this.updateProjectionMatrix(); + } + lookAt(h) { + this.matrix.lookAt(this.position, h, this.up), this.rotationAutoUpdate && (this.useQuaternion === !1 && this.rotation instanceof f.Vector3 ? this.rotation.setEulerFromRotationMatrix(this.matrix, this.eulerOrder) : console.error("Unimplemented math operation.")); + } + updateProjectionMatrix() { + this.ortho ? this.projectionMatrix.makeOrthographic(this.left, this.right, this.top, this.bottom, this.near, this.far) : this.projectionMatrix.makePerspective(this.fov, this.aspect, this.near, this.far), this.projectionMatrixInverse.getInverse(this.projectionMatrix); + } + } + } + ), + /***/ + "./src/WebGL/Fog.ts": ( + /*!**************************!*\ + !*** ./src/WebGL/Fog.ts ***! + \**************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Fog: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../colors */ + "./src/colors.ts" + ); + class f { + constructor(x, h = 1, u = 1e3) { + this.name = "", this.color = new s.Color(x), this.near = h, this.far = u; + } + clone() { + return new f(this.color.getHex(), this.near, this.far); + } + } + } + ), + /***/ + "./src/WebGL/Renderer.ts": ( + /*!*******************************!*\ + !*** ./src/WebGL/Renderer.ts ***! + \*******************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Renderer: () => ( + /* binding */ + A + ) + /* harmony export */ + }); + var s = t( + /*! ./Camera */ + "./src/WebGL/Camera.ts" + ), f = t( + /*! ./constants/Sides */ + "./src/WebGL/constants/Sides.ts" + ), _ = t( + /*! ./constants/TextureConstants */ + "./src/WebGL/constants/TextureConstants.ts" + ), x = t( + /*! ./core */ + "./src/WebGL/core/index.ts" + ), h = t( + /*! ../colors */ + "./src/colors.ts" + ), u = t( + /*! ./materials */ + "./src/WebGL/materials/index.ts" + ), E = t( + /*! ./math */ + "./src/WebGL/math/index.ts" + ), c = t( + /*! ./objects */ + "./src/WebGL/objects/index.ts" + ), C = t( + /*! ./shaders */ + "./src/WebGL/shaders/index.ts" + ), b = t( + /*! ./SpritePlugin */ + "./src/WebGL/SpritePlugin.ts" + ); + class A { + constructor(n) { + this.context = null, this.devicePixelRatio = 1, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.autoUpdateObjects = !0, this.autoUpdateScene = !0, this.info = { + memory: { + programs: 0, + geometries: 0, + textures: 0 + }, + render: { + calls: 0, + vertices: 0, + faces: 0, + points: 0 + } + }, this._programs = [], this._programs_counter = 0, this._webglversion = 1, this._currentProgram = null, this._currentMaterialId = -1, this._currentGeometryGroupHash = null, this._currentCamera = null, this._geometryGroupCounter = 0, this._oldDoubleSided = -1, this._oldFlipSided = -1, this._oldDepthTest = -1, this._oldDepthWrite = -1, this._oldPolygonOffset = null, this._oldLineWidth = null, this._viewportWidth = 0, this._viewportHeight = 0, this._currentWidth = 0, this._currentHeight = 0, this._enabledAttributes = {}, this._projScreenMatrix = new E.Matrix4(), this._vector3 = new E.Vector3(), this._worldInverse = new E.Matrix4(), this._projInverse = new E.Matrix4(), this._textureMatrix = new E.Matrix4(), this._direction = new E.Vector3(), this._lightsNeedUpdate = !0, this._lights = { + ambient: [0, 0, 0], + directional: { + length: 0, + colors: [], + positions: [] + }, + point: { + length: 0, + colors: [], + positions: [], + distances: [] + }, + spot: { + length: 0, + colors: [], + positions: [], + distances: [], + directions: [], + anglesCos: [], + exponents: [] + }, + hemi: { + length: 0, + skyColors: [], + groundColors: [], + positions: [] + } + }, this.sprites = new b.SpritePlugin(), this._screenshader = null, this._vertexattribpos = null, this._screenQuadVBO = null, this._fb = null, this._targetTexture = null, this._depthTexture = null, n = n || {}, this.row = n.row, this.col = n.col, this.rows = n.rows, this.cols = n.cols, this._canvas = n.canvas !== void 0 ? n.canvas : document.createElement("canvas"), this._precision = n.precision !== void 0 ? n.precision : "highp", this._alpha = n.alpha !== void 0 ? n.alpha : !0, this._premultipliedAlpha = n.premultipliedAlpha !== void 0 ? n.premultipliedAlpha : !0, this._antialias = n.antialias !== void 0 ? n.antialias : !1, this._stencil = n.stencil !== void 0 ? n.stencil : !0, this._preserveDrawingBuffer = n.preserveDrawingBuffer !== void 0 ? n.preserveDrawingBuffer : !1, this._clearColor = n.clearColor !== void 0 ? new h.Color(n.clearColor) : new h.Color(0), this._clearAlpha = n.clearAlpha !== void 0 ? n.clearAlpha : 0, this._outlineMaterial = new u.MeshOutlineMaterial(n.outline), this._outlineSphereImposterMaterial = new u.SphereImposterOutlineMaterial(n.outline), this._outlineStickImposterMaterial = new u.StickImposterOutlineMaterial(n.outline), this._outlineEnabled = !!n.outline, this.domElement = this._canvas, this._canvas.id = n.id, this.initGL(), this.setDefaultGLState(), this.context = this._gl, this.isWebGL1() ? this._extInstanced = this._gl.getExtension("ANGLE_instanced_arrays") : this._extInstanced = { + vertexAttribDivisorANGLE: this._gl.vertexAttribDivisor.bind(this._gl), + drawElementsInstancedANGLE: this._gl.drawElementsInstanced.bind(this._gl) + }, this._extFragDepth = this._gl.getExtension("EXT_frag_depth"), this._extFloatLinear = this._gl.getExtension("OES_texture_float_linear"), this._extColorBufferFloat = this._gl.getExtension("EXT_color_buffer_float"), this.sprites.init(this); + } + // API + supportedExtensions() { + return { + supportsAIA: !!this._extInstanced, + supportsImposters: !!this._extFragDepth || !this.isWebGL1(), + regen: !1 + }; + } + getContext() { + return this._gl; + } + isLost() { + return this._gl.isContextLost(); + } + getPrecision() { + return this._precision; + } + setClearColorHex(n, o) { + this._clearColor.setHex(n), this._clearAlpha = o, this._gl.clearColor(this._clearColor.r, this._clearColor.g, this._clearColor.b, this._clearAlpha); + } + enableOutline(n) { + this._outlineMaterial = new u.MeshOutlineMaterial(n), this._outlineSphereImposterMaterial = new u.SphereImposterOutlineMaterial(n), this._outlineStickImposterMaterial = new u.StickImposterOutlineMaterial(n), this._outlineEnabled = !0; + } + disableOutline() { + this._outlineEnabled = !1; + } + setViewport() { + if (this.rows != null && this.cols != null && this.row != null && this.col != null) { + var n = this._canvas.width / this.cols, o = this._canvas.height / this.rows; + this._viewportWidth = n, this._viewportHeight = o, this._gl.enable(this._gl.SCISSOR_TEST), this._gl.scissor(n * this.col, o * this.row, n, o), this._gl.viewport(n * this.col, o * this.row, n, o); + } + } + setSize(n, o) { + if (this.devicePixelRatio = window.devicePixelRatio !== void 0 ? window.devicePixelRatio : 1, this._antialias && this.devicePixelRatio < 2 && (this.devicePixelRatio *= 2), this.rows != null && this.cols != null && this.row != null && this.col != null) { + var w = n / this.cols, p = o / this.rows; + this._canvas.width = n * this.devicePixelRatio, this._canvas.height = o * this.devicePixelRatio, this._viewportWidth = w * this.devicePixelRatio, this._viewportHeight = p * this.devicePixelRatio, this._canvas.style.width = n + "px", this._canvas.style.height = o + "px", this.setViewport(); + } else + this._viewportWidth = this._canvas.width = n * this.devicePixelRatio, this._viewportHeight = this._canvas.height = o * this.devicePixelRatio, this._canvas.style.width = n + "px", this._canvas.style.height = o + "px", this._gl.viewport(0, 0, this._gl.drawingBufferWidth, this._gl.drawingBufferHeight); + this.initFrameBuffer(); + } + clear(n, o, w) { + var p = 0; + (n === void 0 || n) && (p |= this._gl.COLOR_BUFFER_BIT), (o === void 0 || o) && (p |= this._gl.DEPTH_BUFFER_BIT), (w === void 0 || w) && (p |= this._gl.STENCIL_BUFFER_BIT), this._gl.clear(p); + } + clearTarget(n, o, w) { + this.clear(n, o, w); + } + setMaterialFaces(n, o) { + var w = n.side === f.DoubleSide, p = n.side === f.BackSide; + n.imposter || (p = o ? !p : p), this._oldDoubleSided !== w && (w ? this._gl.disable(this._gl.CULL_FACE) : this._gl.enable(this._gl.CULL_FACE), this._oldDoubleSided = w), this._oldFlipSided !== p && (p ? this._gl.frontFace(this._gl.CW) : this._gl.frontFace(this._gl.CCW), this._oldFlipSided = p), this._gl.cullFace(this._gl.BACK); + } + setDepthTest(n) { + this._oldDepthTest !== n && (n ? this._gl.enable(this._gl.DEPTH_TEST) : this._gl.disable(this._gl.DEPTH_TEST), this._oldDepthTest = n); + } + setDepthWrite(n) { + this._oldDepthWrite !== n && (this._gl.depthMask(n), this._oldDepthWrite = n); + } + setBlending(n) { + n ? (this._gl.enable(this._gl.BLEND), this._gl.blendEquationSeparate(this._gl.FUNC_ADD, this._gl.FUNC_ADD), this._gl.blendFuncSeparate(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA)) : this._gl.disable(this._gl.BLEND); + } + // TODO: need to set up shader attributes and uniforms as attributes on + // material object after attaching prgm + // We need to attach appropriate uniform variables to material after shaders + // have been chosen + initMaterial(n, o, w, p) { + n.addEventListener("dispose", this.onMaterialDispose.bind(this)); + var v, a; + if (a = n.shaderID, a) { + var l = C.ShaderLib[a]; + n.vertexShader = l.vertexShader, n.fragmentShader = l.fragmentShader, n.uniforms = C.ShaderUtils.clone(l.uniforms); + } + v = { + wireframe: n.wireframe, + fragdepth: n.imposter, + volumetric: n.volumetric + }, n.program = this.buildProgram(n.fragmentShader, n.vertexShader, n.uniforms, v); + } + renderBuffer(n, o, w, p, v, a) { + if (p.visible) { + var l, g; + if (l = this.setProgram(n, o, w, p, a, this), !!l) { + g = l.attributes; + var M = !1, L = p.wireframe ? 1 : 0, T = v.id * 16777215 + l.id * 2 + L; + T !== this._currentGeometryGroupHash && (this._currentGeometryGroupHash = T, M = !0), M && (this.disableAttributes(), g.position >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, v.__webglVertexBuffer), this.enableAttribute(g.position), this._gl.vertexAttribPointer(g.position, 3, this._gl.FLOAT, !1, 0, 0)), g.color >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, v.__webglColorBuffer), this.enableAttribute(g.color), this._gl.vertexAttribPointer(g.color, 3, this._gl.FLOAT, !1, 0, 0)), g.normal >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, v.__webglNormalBuffer), this.enableAttribute(g.normal), this._gl.vertexAttribPointer(g.normal, 3, this._gl.FLOAT, !1, 0, 0)), g.offset >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, v.__webglOffsetBuffer), this.enableAttribute(g.offset), this._gl.vertexAttribPointer(g.offset, 3, this._gl.FLOAT, !1, 0, 0)), g.radius >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, v.__webglRadiusBuffer), this.enableAttribute(g.radius), this._gl.vertexAttribPointer(g.radius, 1, this._gl.FLOAT, !1, 0, 0))); + var D, R; + if (a instanceof c.Mesh) { + if (p.shaderID === "instanced") { + var B = p.sphere.geometryGroups[0]; + M && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, v.__webglVertexBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, B.vertexArray, this._gl.STATIC_DRAW), this._gl.bindBuffer(this._gl.ARRAY_BUFFER, v.__webglNormalBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, B.normalArray, this._gl.STATIC_DRAW), this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, v.__webglFaceBuffer), this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, B.faceArray, this._gl.STATIC_DRAW)), D = B.faceidx, this._extInstanced.vertexAttribDivisorANGLE(g.offset, 1), this._extInstanced.vertexAttribDivisorANGLE(g.radius, 1), this._extInstanced.vertexAttribDivisorANGLE(g.color, 1), this._extInstanced.drawElementsInstancedANGLE(this._gl.TRIANGLES, D, this._gl.UNSIGNED_SHORT, 0, v.radiusArray.length), this._extInstanced.vertexAttribDivisorANGLE(g.offset, 0), this._extInstanced.vertexAttribDivisorANGLE(g.radius, 0), this._extInstanced.vertexAttribDivisorANGLE(g.color, 0); + } else + p.wireframe ? (R = v.lineidx, this.setLineWidth(p.wireframeLinewidth), M && this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, v.__webglLineBuffer), this._gl.drawElements(this._gl.LINES, R, this._gl.UNSIGNED_SHORT, 0)) : (D = v.faceidx, M && this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, v.__webglFaceBuffer), this._gl.drawElements(this._gl.TRIANGLES, D, this._gl.UNSIGNED_SHORT, 0)); + this.info.render.calls++, this.info.render.vertices += D, this.info.render.faces += D / 3; + } else + a instanceof c.Line && (R = v.vertices, this.setLineWidth(p.linewidth), this._gl.drawArrays(this._gl.LINES, 0, R), this.info.render.calls++); + } + } + } + render(n, o, w) { + if (!(o instanceof s.Camera)) { + console.error("Renderer.render: camera is not an instance of Camera."); + return; + } + var p, v, a, l, g, M = n.__lights, L = n.fog; + this._currentMaterialId = -1, this._lightsNeedUpdate = !0, this.autoUpdateScene && n.updateMatrixWorld(), o.parent === void 0 && o.updateMatrixWorld(), o.matrixWorldInverse.getInverse(o.matrixWorld), this._projScreenMatrix.multiplyMatrices(o.projectionMatrix, o.matrixWorldInverse), this.autoUpdateObjects && this.initWebGLObjects(n), this.info.render.calls = 0, this.info.render.vertices = 0, this.info.render.faces = 0, this.info.render.points = 0, this._currentWidth = this._viewportWidth, this._currentHeight = this._viewportHeight, this.setViewport(), this.setFrameBuffer(), (this.autoClear || w) && (this._gl.clearColor(this._clearColor.r, this._clearColor.g, this._clearColor.b, this._clearAlpha), this.clear(this.autoClearColor, this.autoClearDepth, this.autoClearStencil)), g = n.__webglObjects; + var T = !1; + for (p = 0, v = g.length; p < v; p++) + a = g[p], l = a.object, a.render = !1, l.visible && (this.setupMatrices(l, o), this.unrollBufferMaterial(a), a.render = !0, a.volumetric && (T = !0)); + var D = null; + this.setBlending(!1), this.renderObjects(n.__webglObjects, !0, "opaque", o, M, L, !1, D), this.renderSprites(n, o, !1), this.renderObjects(n.__webglObjects, !0, "blank", o, M, L, !0, D), this.renderObjects(n.__webglObjects, !1, "transparent", o, M, L, !0, D), T && this._fb && (this.reinitFrameBuffer(), this.renderObjects(n.__webglObjects, !1, "volumetric", o, M, L, !0, D)), this.renderFrameBuffertoScreen(), this.setDepthTest(!0), this.setDepthWrite(!0), this.renderSprites(n, o, !0); + } + //reinitialize framebuffer without the depth texture attached so we can read to it + //do not allocate new textures + reinitFrameBuffer() { + this.isWebGL1() || (this._fb = this._gl.createFramebuffer(), this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._fb), this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._targetTexture, 0)); + } + //setup framebuffer for drawing into, assumes buffers already allocated + setFrameBuffer() { + if (this.isWebGL1() || !this._fb) + return; + let n = this._viewportWidth, o = this._viewportHeight; + this._gl.enable(this._gl.SCISSOR_TEST), this._gl.scissor(0, 0, n, o), this._gl.viewport(0, 0, n, o), this._gl.bindTexture(this._gl.TEXTURE_2D, this._targetTexture), this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, n, o, 0, this._gl.RGBA, this._gl.UNSIGNED_BYTE, null), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE), this._gl.bindTexture(this._gl.TEXTURE_2D, this._depthTexture), this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.DEPTH_COMPONENT32F, n, o, 0, this._gl.DEPTH_COMPONENT, this._gl.FLOAT, null), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.NEAREST), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.NEAREST), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE), this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._fb), this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._targetTexture, 0), this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.TEXTURE_2D, this._depthTexture, 0); + } + //allocate buffers for framebuffer, needs to be called with every resize + initFrameBuffer() { + if (this.isWebGL1()) + return; + let n = this._viewportWidth, o = this._viewportHeight; + this._gl.enable(this._gl.SCISSOR_TEST), this._gl.scissor(0, 0, n, o), this._gl.viewport(0, 0, n, o), this._targetTexture = this._gl.createTexture(), this._depthTexture = this._gl.createTexture(), this._fb = this._gl.createFramebuffer(); + var w = C.ShaderLib.screen; + this._screenshader = this.buildProgram(w.fragmentShader, w.vertexShader, w.uniforms, {}), this._vertexattribpos = this._gl.getAttribLocation(this._screenshader, "vertexPosition"); + var p = [ + // First triangle: + 1, + 1, + -1, + 1, + -1, + -1, + // Second triangle: + -1, + -1, + 1, + -1, + 1, + 1 + ]; + this._screenQuadVBO = this._gl.createBuffer(), this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._screenQuadVBO), this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(p), this._gl.STATIC_DRAW); + } + renderFrameBuffertoScreen() { + this.isWebGL1() || this._fb === null || (this.setViewport(), this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, null), this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT), this._gl.frontFace(this._gl.CCW), this._gl.cullFace(this._gl.BACK), this._gl.useProgram(this._screenshader), this._currentProgram = this._screenshader, this.setDepthTest(-1), this.setDepthWrite(-1), this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._screenQuadVBO), this._gl.enableVertexAttribArray(this._vertexattribpos), this._gl.vertexAttribPointer(this._vertexattribpos, 2, this._gl.FLOAT, !1, 0, 0), this._gl.activeTexture(this._gl.TEXTURE0), this._gl.bindTexture(this._gl.TEXTURE_2D, this._targetTexture), this._gl.drawArrays(this._gl.TRIANGLES, 0, 6)); + } + initWebGLObjects(n) { + if (n.__webglObjects || (n.__webglObjects = [], n.__webglObjectsImmediate = [], n.__webglSprites = [], n.__webglFlares = []), n.__objectsAdded.length) { + for (; n.__objectsAdded.length; ) + this.addObject(n.__objectsAdded[0], n), n.__objectsAdded.splice(0, 1); + this._currentGeometryGroupHash = -1; + } + for (; n.__objectsRemoved.length; ) + this.removeObject(n.__objectsRemoved[0], n), n.__objectsRemoved.splice(0, 1); + for (var o = 0, w = n.__webglObjects.length; o < w; o++) + this.updateObject(n.__webglObjects[o].object); + } + getYRatio() { + return this.rows !== void 0 && this.row !== void 0 ? this.rows : 1; + } + getXRatio() { + return this.cols !== void 0 && this.col !== void 0 ? this.cols : 1; + } + getAspect(n, o) { + (n == null || o == null) && (n = this._canvas.width, o = this._canvas.height); + var w = n / o; + if (this.rows != null && this.cols != null && this.row != null && this.col != null) { + var p = n / this.cols, v = o / this.rows; + w = p / v; + } + return w; + } + setTexture(n, o, w) { + if (n.needsUpdate) { + n.__webglInit || (n.__webglInit = !0, n.addEventListener("dispose", this.onTextureDispose.bind(this)), n.__webglTexture = this._gl.createTexture(), this.info.memory.textures++), this._gl.activeTexture(this._gl.TEXTURE0 + o); + var p = w ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D; + this._gl.bindTexture(p, n.__webglTexture), this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, n.flipY), this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, n.premultiplyAlpha), this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, n.unpackAlignment), this._gl.pixelStorei(this._gl.PACK_ALIGNMENT, n.unpackAlignment); + var v = this.paramToGL(n.format), a = this.paramToGL(n.type); + if (w) + this.setTextureParameters(this._gl.TEXTURE_3D, n), this._gl.texImage3D(this._gl.TEXTURE_3D, 0, this._gl.R32F, n.image.size.z, n.image.size.y, n.image.size.x, 0, this._gl.RED, this._gl.FLOAT, n.image.data); + else { + var l = n.image, g = l.width, M = l.height; + typeof g > "u" && (g = l.length, v == this._gl.RGBA && (g /= 4), M = 1), this.setTextureParameters(this._gl.TEXTURE_2D, n), this.isWebGL1() ? this._gl.texImage2D(this._gl.TEXTURE_2D, 0, v, v, a, n.image) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, v, g, M, 0, v, a, n.image); + } + n.needsUpdate = !1, n.onUpdate && n.onUpdate(); + } else + this._gl.activeTexture(this._gl.TEXTURE0 + o), w ? this._gl.bindTexture(this._gl.TEXTURE_3D, n.__webglTexture) : this._gl.bindTexture(this._gl.TEXTURE_2D, n.__webglTexture); + } + supportsVolumetric() { + return !this.isWebGL1(); + } + enableAttribute(n) { + this._enabledAttributes[n] || (this._gl.enableVertexAttribArray(n), this._enabledAttributes[n] = !0); + } + disableAttributes() { + for (let n in this._enabledAttributes) + this._enabledAttributes[n] && (this._gl.disableVertexAttribArray(n), this._enabledAttributes[n] = !1); + } + setPolygonOffset(n, o, w) { + this._oldPolygonOffset !== n && (n ? this._gl.enable(this._gl.POLYGON_OFFSET_FILL) : this._gl.disable(this._gl.POLYGON_OFFSET_FILL)); + } + setLineWidth(n) { + n !== this._oldLineWidth && (this._gl.lineWidth(n), this._oldLineWidth = n); + } + deallocateGeometry(n) { + if (n.__webglInit = void 0, n.__webglVertexBuffer !== void 0 && this._gl.deleteBuffer(n.__webglVertexBuffer), n.__webglColorBuffer !== void 0 && this._gl.deleteBuffer(n.__webglColorBuffer), n.geometryGroups !== void 0) + for (var o = 0, w = n.groups; o < w; o++) { + var p = n.geometryGroups[o]; + p.__webglVertexBuffer !== void 0 && this._gl.deleteBuffer(p.__webglVertexBuffer), p.__webglColorBuffer !== void 0 && this._gl.deleteBuffer(p.__webglColorBuffer), p.__webglNormalBuffer !== void 0 && this._gl.deleteBuffer(p.__webglNormalBuffer), p.__webglFaceBuffer !== void 0 && this._gl.deleteBuffer(p.__webglFaceBuffer), p.__webglLineBuffer !== void 0 && this._gl.deleteBuffer(p.__webglLineBuffer); + } + } + deallocateMaterial(n) { + var o = n.program; + if (o !== void 0) { + n.program = void 0; + var w, p, v, a = !1; + for (w = 0, p = this._programs.length; w < p; w++) + if (v = this._programs[w], v.program === o) { + v.usedTimes--, v.usedTimes === 0 && (a = !0); + break; + } + if (a === !0) { + var l = []; + for (w = 0, p = this._programs.length; w < p; w++) + v = this._programs[w], v.program !== o && l.push(v); + this._programs = l, this._gl.deleteProgram(o), this.info.memory.programs--; + } + } + } + deallocateTexture(n) { + if (n.image && n.image.__webglTextureCube) + this._gl.deleteTexture(n.image.__webglTextureCube); + else { + if (!n.__webglInit) + return; + n.__webglInit = !1, this._gl.deleteTexture(n.__webglTexture); + } + } + onGeometryDispose(n) { + var o = n.target; + o.removeEventListener("dispose", this.onGeometryDispose), this.deallocateGeometry(o), this.info.memory.geometries--; + } + onTextureDispose(n) { + var o = n.target; + o.removeEventListener("dispose", this.onTextureDispose), this.deallocateTexture(o), this.info.memory.textures--; + } + onMaterialDispose(n) { + var o = n.target; + o.removeEventListener("dispose", this.onMaterialDispose), this.deallocateMaterial(o); + } + // Compile and return shader + getShader(n, o) { + var w; + return !this.isWebGL1() && !o.startsWith("#version") && (o = o.replace(/gl_FragDepthEXT/g, "gl_FragDepth"), n == "fragment" ? o = o.replace(/varying/g, "in") : o = o.replace(/varying/g, "out"), o = o.replace(/attribute/g, "in"), o = o.replace(/texture2D/g, "texture"), o = o.replace(/\/\/DEFINEFRAGCOLOR/g, "out vec4 glFragColor;"), o = o.replace(/gl_FragColor/g, "glFragColor"), o = `#version 300 es +` + o), n === "fragment" ? w = this._gl.createShader(this._gl.FRAGMENT_SHADER) : n === "vertex" && (w = this._gl.createShader(this._gl.VERTEX_SHADER)), w == null ? null : (this._gl.shaderSource(w, o), this._gl.compileShader(w), this._gl.getShaderParameter(w, this._gl.COMPILE_STATUS) ? w : (console.error(this._gl.getShaderInfoLog(w)), console.error("could not initialize shader"), null)); + } + // Compile appropriate shaders (if necessary) from source code and attach to + // gl program. + buildProgram(n, o, w, p) { + var v, a, l, g, M = []; + M.push(n), M.push(o); + for (v in p) + M.push(v), M.push(p[v]); + for (g = M.join(), v = 0, a = this._programs.length; v < a; v++) { + var L = this._programs[v]; + if (L.code === g) + return L.usedTimes++, L.program; + } + if (this.isWebGL1() && p.volumetric) + throw new Error("Volumetric rendering requires webgl2 which is not supported by your hardware."); + if (l = this._gl.createProgram(), l == null) + return null; + var T = this._precision, D = "precision " + T + " float;", R = [ + p.volumetric ? "#version 300 es" : "", + D + ].join(` +`), B = [ + p.volumetric ? "#version 300 es" : "", + p.fragdepth && this.isWebGL1() ? "#extension GL_EXT_frag_depth: enable" : "", + p.wireframe ? "#define WIREFRAME 1" : "", + D + ].join(` +`), P = this.getShader("fragment", B + n), z = this.getShader("vertex", R + o); + z != null && this._gl.attachShader(l, z), P != null && this._gl.attachShader(l, P), this._gl.linkProgram(l), this._gl.getProgramParameter(l, this._gl.LINK_STATUS) || console.error("Could not initialize shader"), l.uniforms = {}, l.attributes = {}; + var F, N, $; + F = [ + "viewMatrix", + "modelViewMatrix", + "projectionMatrix", + "normalMatrix" + ]; + for (N in w) + F.push(N); + for ($ = 0; $ < F.length; $++) { + var k = F[$]; + l.uniforms[k] = this._gl.getUniformLocation(l, k); + } + for (F = [ + "position", + "normal", + "color", + "lineDistance", + "offset", + "radius" + ], $ = 0; $ < F.length; $++) { + var G = F[$]; + l.attributes[G] = this._gl.getAttribLocation(l, G); + } + return l.id = this._programs_counter++, this._programs.push({ + program: l, + code: g, + usedTimes: 1 + }), this.info.memory.programs = this._programs.length, l; + } + setProgram(n, o, w, p, v, a) { + if (p.needsUpdate && (p.program && this.deallocateMaterial(p), this.initMaterial(p, o, w, v), p.needsUpdate = !1), p.program == null) + return null; + var l = !1, g = p.program, M = g.uniforms, L = p.uniforms; + if (g != this._currentProgram && (this._gl.useProgram(g), this._currentProgram = g, l = !0), p.id != this._currentMaterialId && (this._currentMaterialId = p.id, l = !0), n != this._currentCamera && (this._currentCamera = n, l = !0), this._gl.uniformMatrix4fv(M.projectionMatrix, !1, n.projectionMatrix.elements), this._gl.uniformMatrix4fv(M.modelViewMatrix, !1, v._modelViewMatrix.elements), this._gl.uniformMatrix3fv(M.normalMatrix, !1, v._normalMatrix.elements), l) { + if (L.fogColor.value = w.color, L.fogNear.value = w.near, L.fogFar.value = w.far, p.shaderID.startsWith("lambert") || p.shaderID === "instanced" || p.shaderID.endsWith("imposter")) + this._gl.uniformMatrix4fv(M.viewMatrix, !1, n.matrixWorldInverse.elements), this._lightsNeedUpdate && (this.setupLights(g, o), this._lightsNeedUpdate = !1), L.directionalLightColor.value = this._lights.directional.colors, L.directionalLightDirection.value = this._lights.directional.positions; + else if (p.shaderID.endsWith("outline")) + L.outlineColor.value = p.outlineColor, L.outlineWidth.value = p.outlineWidth, L.outlinePushback.value = p.outlinePushback; + else if (p.shaderID === "volumetric") { + v._modelViewMatrix.getScale(this._direction), this._worldInverse.getInverse(v._modelViewMatrix), this._projInverse.getInverse(n.projectionMatrix), this._textureMatrix.multiplyMatrices(v.material.texmatrix, this._worldInverse), this._gl.uniformMatrix4fv(M.textmat, !1, this._textureMatrix.elements), this._gl.uniformMatrix4fv(M.projinv, !1, this._projInverse.elements); + let T = Math.min(Math.min(this._direction.x, this._direction.y), this._direction.z); + L.step.value = v.material.unit * T, L.maxdepth.value = v.material.maxdepth * T, L.transfermax.value = v.material.transfermax, L.transfermin.value = v.material.transfermin, L.subsamples.value = v.material.subsamples, a.setTexture(v.material.transferfn, 4, !1), a.setTexture(v.material.map, 3, !0), this._gl.activeTexture(this._gl.TEXTURE5), this._gl.bindTexture(this._gl.TEXTURE_2D, this._depthTexture); + } + L.opacity.value = p.opacity, this.loadMaterialUniforms(M, L); + } + return g; + } + loadMaterialUniforms(n, o) { + var w, p, v, a; + for (w in o) + n[w] && (p = o[w].type, v = o[w].value, a = n[w], p === "f" ? this._gl.uniform1f(a, v) : p === "i" ? this._gl.uniform1i(a, v) : p === "fv" ? this._gl.uniform3fv(a, v) : p === "c" ? this._gl.uniform3f(a, v.r, v.g, v.b) : p === "f4" && this._gl.uniform4f(a, v[0], v[1], v[2], v[3])); + } + // Objects adding + addObject(n, o) { + var w, p, v, a; + if (!n.__webglInit && (n.__webglInit = !0, n._modelViewMatrix = new E.Matrix4(), n._normalMatrix = new E.Matrix3(), n.geometry !== void 0 && n.geometry.__webglInit === void 0 && (n.geometry.__webglInit = !0, n.geometry.addEventListener("dispose", this.onGeometryDispose.bind(this))), n instanceof c.Mesh || n instanceof c.Line)) + for (v = n.geometry, w = 0, p = v.geometryGroups.length; w < p; w++) + a = v.geometryGroups[w], a.id = this._geometryGroupCounter++, a.__webglVertexBuffer || (n instanceof c.Mesh ? (this.createMeshBuffers(a), v.elementsNeedUpdate = !0, v.normalsNeedUpdate = !0) : n instanceof c.Line && this.createLineBuffers(a), v.verticesNeedUpdate = !0, v.colorsNeedUpdate = !0); + if (!n.__webglActive) { + if (n instanceof c.Mesh || n instanceof c.Line) + for (v = n.geometry, w = 0, p = v.geometryGroups.length; w < p; w++) + a = v.geometryGroups[w], this.addBuffer(o.__webglObjects, a, n); + else + n instanceof c.Sprite && o.__webglSprites.push(n); + n.__webglActive = !0; + } + } + updateObject(n) { + var o = n.geometry, w; + if (n instanceof c.Mesh || n instanceof c.Line) { + for (var p = 0, v = o.geometryGroups.length; p < v; p++) + w = o.geometryGroups[p], (o.verticesNeedUpdate || o.elementsNeedUpdate || o.colorsNeedUpdate || o.normalsNeedUpdate) && this.setBuffers(w, this._gl.STATIC_DRAW); + o.verticesNeedUpdate = !1, o.elementsNeedUpdate = !1, o.normalsNeedUpdate = !1, o.colorsNeedUpdate = !1, o.buffersNeedUpdate = !1; + } + } + removeObject(n, o) { + n instanceof c.Mesh || n instanceof c.Line ? this.removeInstances(o.__webglObjects, n) : n instanceof c.Sprite && this.removeInstancesDirect(o.__webglSprites, n), n.__webglActive = !1; + } + removeInstances(n, o) { + for (var w = n.length - 1; w >= 0; --w) + n[w].object === o && n.splice(w, 1); + } + removeInstancesDirect(n, o) { + for (var w = n.length - 1; w >= 0; --w) + n[w] === o && n.splice(w, 1); + } + unrollBufferMaterial(n) { + var o = n.object, w = o.material; + if (w.volumetric) + n.opaque = null, n.transparent = null, n.volumetric = w; + else if (w.transparent) { + if (n.opaque = null, n.volumetric = null, n.transparent = w, !w.wireframe) { + var p = w.clone(); + p.opacity = 0, n.blank = p; + } + } else + n.opaque = w, n.transparent = null, n.volumetric = null; + } + setBuffers(n, o) { + var w = n.vertexArray, p = n.colorArray; + if (n.__webglOffsetBuffer !== void 0 ? (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, n.__webglOffsetBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, w, o)) : (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, n.__webglVertexBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, w, o)), this._gl.bindBuffer(this._gl.ARRAY_BUFFER, n.__webglColorBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, p, o), n.normalArray && n.__webglNormalBuffer !== void 0) { + var v = n.normalArray; + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, n.__webglNormalBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, v, o); + } + if (n.radiusArray && n.__webglRadiusBuffer !== void 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, n.__webglRadiusBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, n.radiusArray, o)), n.faceArray && n.__webglFaceBuffer !== void 0) { + var a = n.faceArray; + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, n.__webglFaceBuffer), this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, a, o); + } + if (n.lineArray && n.__webglLineBuffer !== void 0) { + var l = n.lineArray; + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, n.__webglLineBuffer), this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, l, o); + } + } + // Creates appropriate gl buffers for geometry chunk + // TODO: do we need line buffer for mesh objects? + // Also, can we integrate this with createLineBuffers? + createMeshBuffers(n) { + n.radiusArray && (n.__webglRadiusBuffer = this._gl.createBuffer()), n.useOffset && (n.__webglOffsetBuffer = this._gl.createBuffer()), n.__webglVertexBuffer = this._gl.createBuffer(), n.__webglNormalBuffer = this._gl.createBuffer(), n.__webglColorBuffer = this._gl.createBuffer(), n.__webglFaceBuffer = this._gl.createBuffer(), n.__webglLineBuffer = this._gl.createBuffer(), this.info.memory.geometries++; + } + createLineBuffers(n) { + n.__webglVertexBuffer = this._gl.createBuffer(), n.__webglColorBuffer = this._gl.createBuffer(), this.info.memory.geometries++; + } + addBuffer(n, o, w) { + n.push({ + buffer: o, + object: w, + opaque: null, + transparent: null + }); + } + setupMatrices(n, o) { + n._modelViewMatrix.multiplyMatrices(o.matrixWorldInverse, n.matrixWorld), n._normalMatrix.getInverse(n._modelViewMatrix), n._normalMatrix.transpose(); + } + // Fallback filters for non-power-of-2 textures + filterFallback(n) { + return this._gl.LINEAR; + } + setTextureParameters(n, o) { + n == this._gl.TEXTURE_2D ? (this._gl.texParameteri(n, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(n, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(n, this._gl.TEXTURE_MAG_FILTER, this.filterFallback(o.magFilter)), this._gl.texParameteri(n, this._gl.TEXTURE_MIN_FILTER, this.filterFallback(o.minFilter))) : (this._gl.texParameteri(n, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(n, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(n, this._gl.TEXTURE_WRAP_R, this._gl.CLAMP_TO_EDGE), this._extColorBufferFloat && this._extFloatLinear ? (this._gl.texParameteri(n, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR), this._gl.texParameteri(n, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR)) : (this._gl.texParameteri(n, this._gl.TEXTURE_MAG_FILTER, this._gl.NEAREST), this._gl.texParameteri(n, this._gl.TEXTURE_MIN_FILTER, this._gl.NEAREST))); + } + // Map constants to WebGL constants + paramToGL(n) { + return n === _.UnsignedByteType ? this._gl.UNSIGNED_BYTE : n === _.RGBAFormat ? this._gl.RGBA : n === _.NearestFilter ? this._gl.NEAREST : 0; + } + setupLights(n, o) { + var w, p, v, a = 0, l = 0, g = 0, M, L, T = this._lights, D = T.directional.colors, R = T.directional.positions, B = 0, P = 0; + for (w = 0, p = o.length; w < p; w++) + if (v = o[w], M = v.color, L = v.intensity, v instanceof x.Light) { + if (this._direction.getPositionFromMatrix(v.matrixWorld), this._vector3.getPositionFromMatrix(v.target.matrixWorld), this._direction.sub(this._vector3), this._direction.normalize(), this._direction.x === 0 && this._direction.y === 0 && this._direction.z === 0) + continue; + R[P] = this._direction.x, R[P + 1] = this._direction.y, R[P + 2] = this._direction.z, D[P] = M.r * L, D[P + 1] = M.g * L, D[P + 2] = M.b * L, P += 3, B++; + } + T.ambient[0] = a, T.ambient[1] = l, T.ambient[2] = g, T.directional.length = B; + } + initGL() { + try { + if (!(this._gl = this._canvas.getContext("webgl2", { + alpha: this._alpha, + premultipliedAlpha: this._premultipliedAlpha, + antialias: this._antialias, + stencil: this._stencil, + preserveDrawingBuffer: this._preserveDrawingBuffer + })) && !(this._gl = this._canvas.getContext("experimental-webgl", { + alpha: this._alpha, + premultipliedAlpha: this._premultipliedAlpha, + antialias: this._antialias, + stencil: this._stencil, + preserveDrawingBuffer: this._preserveDrawingBuffer + })) && !(this._gl = this._canvas.getContext("webgl", { + alpha: this._alpha, + premultipliedAlpha: this._premultipliedAlpha, + antialias: this._antialias, + stencil: this._stencil, + preserveDrawingBuffer: this._preserveDrawingBuffer + }))) + throw "Error creating WebGL context."; + var n = this._gl.getParameter(this._gl.VERSION); + this._webglversion = parseInt(n[6]); + } catch (o) { + console.error(o); + } + } + isWebGL1() { + return this._webglversion == 1; + } + setDefaultGLState() { + this._gl.clearColor(0, 0, 0, 1), this._gl.clearDepth(1), this._gl.clearStencil(0), this._gl.enable(this._gl.DEPTH_TEST), this._gl.depthFunc(this._gl.LEQUAL), this._gl.frontFace(this._gl.CCW), this._gl.cullFace(this._gl.BACK), this._gl.enable(this._gl.CULL_FACE), this._gl.enable(this._gl.BLEND), this._gl.blendEquation(this._gl.FUNC_ADD), this._gl.blendFunc(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA), this._gl.clearColor(this._clearColor.r, this._clearColor.g, this._clearColor.b, this._clearAlpha); + } + // rendering + renderObjects(n, o, w, p, v, a, l, D) { + var M, L, T, D, R, B, P; + o ? (R = n.length - 1, B = -1, P = -1) : (R = 0, B = n.length, P = 1); + for (var z = R; z !== B; z += P) + if (M = n[z], M.render) { + if (L = M.object, T = M.buffer, D = M[w], !D) + continue; + l && this.setBlending(!0), this.setDepthTest(D.depthTest), this.setDepthWrite(D.depthWrite), this.setPolygonOffset(D.polygonOffset, D.polygonOffsetFactor, D.polygonOffsetUnits); + var F = L._modelViewMatrix.isReflected(); + this.setMaterialFaces(D, F), this.renderBuffer(p, v, a, D, T, L), (this._outlineEnabled || D.outline) && (D.shaderID == "sphereimposter" ? this.renderBuffer(p, v, a, this._outlineSphereImposterMaterial, T, L) : D.shaderID == "stickimposter" ? this.renderBuffer(p, v, a, this._outlineStickImposterMaterial, T, L) : !D.wireframe && D.shaderID !== "basic" && D.opacity !== 0 && this.renderBuffer(p, v, a, this._outlineMaterial, T, L)); + } + } + renderSprites(n, o, w) { + this._currentGeometryGroupHash = -1, this._currentProgram = null, this._currentCamera = null, this._oldDepthWrite = -1, this._oldDepthTest = -1, this._oldDoubleSided = -1, this._currentMaterialId = -1, this._oldFlipSided = -1, this._lightsNeedUpdate = !0, this.sprites.render(n, o, this._currentWidth, this._currentHeight, w), this._currentGeometryGroupHash = -1, this._currentProgram = null, this._currentCamera = null, this._oldDepthWrite = -1, this._oldDepthTest = -1, this._oldDoubleSided = -1, this._currentMaterialId = -1, this._oldFlipSided = -1; + } + } + } + ), + /***/ + "./src/WebGL/SpritePlugin.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/SpritePlugin.ts ***! + \***********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + SpritePlugin: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./shaders/index */ + "./src/WebGL/shaders/index.ts" + ); + class f { + constructor() { + this.sprite = { + vertices: null, + faces: null, + vertexBuffer: null, + elementBuffer: null, + program: null, + attributes: {}, + uniforms: null + }; + } + init(h) { + this.gl = h.context, this.renderer = h, this.precision = h.getPrecision(), this.sprite.vertices = new Float32Array(16), this.sprite.faces = new Uint16Array(6); + var u = 0; + this.sprite.vertices[u++] = -1, this.sprite.vertices[u++] = -1, this.sprite.vertices[u++] = 0, this.sprite.vertices[u++] = 0, this.sprite.vertices[u++] = 1, this.sprite.vertices[u++] = -1, this.sprite.vertices[u++] = 1, this.sprite.vertices[u++] = 0, this.sprite.vertices[u++] = 1, this.sprite.vertices[u++] = 1, this.sprite.vertices[u++] = 1, this.sprite.vertices[u++] = 1, this.sprite.vertices[u++] = -1, this.sprite.vertices[u++] = 1, this.sprite.vertices[u++] = 0, this.sprite.vertices[u++] = 1, u = 0, this.sprite.faces[u++] = 0, this.sprite.faces[u++] = 1, this.sprite.faces[u++] = 2, this.sprite.faces[u++] = 0, this.sprite.faces[u++] = 2, this.sprite.faces[u++] = 3, this.sprite.vertexBuffer = this.gl.createBuffer(), this.sprite.elementBuffer = this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.sprite.vertexBuffer), this.gl.bufferData(this.gl.ARRAY_BUFFER, this.sprite.vertices, this.gl.STATIC_DRAW), this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.sprite.elementBuffer), this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, this.sprite.faces, this.gl.STATIC_DRAW), this.sprite.program = this.createProgram( + s.ShaderLib.sprite, + this.precision || 1 + /** added default to single precision */ + ), this.sprite.attributes = {}; + const E = {}; + this.sprite.attributes.position = this.gl.getAttribLocation(this.sprite.program, "position"), this.sprite.attributes.uv = this.gl.getAttribLocation(this.sprite.program, "uv"), E.uvOffset = this.gl.getUniformLocation(this.sprite.program, "uvOffset"), E.uvScale = this.gl.getUniformLocation(this.sprite.program, "uvScale"), E.rotation = this.gl.getUniformLocation(this.sprite.program, "rotation"), E.scale = this.gl.getUniformLocation(this.sprite.program, "scale"), E.alignment = this.gl.getUniformLocation(this.sprite.program, "alignment"), E.color = this.gl.getUniformLocation(this.sprite.program, "color"), E.map = this.gl.getUniformLocation(this.sprite.program, "map"), E.opacity = this.gl.getUniformLocation(this.sprite.program, "opacity"), E.useScreenCoordinates = this.gl.getUniformLocation(this.sprite.program, "useScreenCoordinates"), E.screenPosition = this.gl.getUniformLocation(this.sprite.program, "screenPosition"), E.modelViewMatrix = this.gl.getUniformLocation(this.sprite.program, "modelViewMatrix"), E.projectionMatrix = this.gl.getUniformLocation(this.sprite.program, "projectionMatrix"), E.fogType = this.gl.getUniformLocation(this.sprite.program, "fogType"), E.fogDensity = this.gl.getUniformLocation(this.sprite.program, "fogDensity"), E.fogNear = this.gl.getUniformLocation(this.sprite.program, "fogNear"), E.fogFar = this.gl.getUniformLocation(this.sprite.program, "fogFar"), E.fogColor = this.gl.getUniformLocation(this.sprite.program, "fogColor"), E.alphaTest = this.gl.getUniformLocation(this.sprite.program, "alphaTest"), this.sprite.uniforms = E; + } + render(h, u, E, c, C) { + var b, A, S, n, o, w, p, v, a, l; + if (!this.gl) + throw new Error("WebGLRenderer not initialized"); + let g = []; + (b = h == null ? void 0 : h.__webglSprites) === null || b === void 0 || b.forEach((Q) => { + (C && Q.material.depthTest == !1 || !C && Q.material.depthTest) && g.push(Q); + }); + let M = g.length; + if (!M) + return; + const L = this.sprite.attributes, T = this.sprite.uniforms; + if (!T) + throw new Error("Uniforms not defined"); + var D = E * 0.5, R = c * 0.5; + this.gl.useProgram(this.sprite.program), this.gl.enableVertexAttribArray(L.position), this.gl.enableVertexAttribArray(L.uv), this.gl.disable(this.gl.CULL_FACE), this.gl.enable(this.gl.BLEND), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.sprite.vertexBuffer), this.gl.vertexAttribPointer(L.position, 2, this.gl.FLOAT, !1, 16, 0), this.gl.vertexAttribPointer(L.uv, 2, this.gl.FLOAT, !1, 16, 8), this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.sprite.elementBuffer), this.gl.uniformMatrix4fv(T.projectionMatrix, !1, u.projectionMatrix.elements), this.gl.activeTexture(this.gl.TEXTURE0), this.gl.uniform1i(T.map, 0); + var B = 0, P = 0, z = h.fog; + z ? (this.gl.uniform3f(T.fogColor, z.color.r, z.color.g, z.color.b), this.gl.uniform1f(T.fogNear, z.near), this.gl.uniform1f(T.fogFar, z.far), this.gl.uniform1i(T.fogType, 1), B = 1, P = 1) : (this.gl.uniform1i(T.fogType, 0), B = 0, P = 0); + var F; + let N, $, k, G, H = []; + for (F = 0; F < M; F++) + N = g[F], $ = N.material, $ && ($.depthTest == !1 && !C || !N.visible || $.opacity === 0 || ($.useScreenCoordinates ? N.z = -N.position.z : (N._modelViewMatrix.multiplyMatrices(u.matrixWorldInverse, N.matrixWorld), N.z = -N._modelViewMatrix.elements[14]))); + for (g.sort(_), F = 0; F < M; F++) + if (N = g[F], $ = N.material, !!$ && !(!N.visible || $.opacity === 0) && $.map && $.map.image && $.map.image.width) { + this.gl.uniform1f((T == null ? void 0 : T.alphaTest) || null, $.alphaTest); + var U = $.map.image.width, V = $.map.image.height; + H[0] = U * this.renderer.devicePixelRatio / E, H[1] = V * this.renderer.devicePixelRatio / c, $.useScreenCoordinates === !0 ? (this.gl.uniform1i(T.useScreenCoordinates, 1), this.gl.uniform3f(T.screenPosition, (N.position.x * this.renderer.devicePixelRatio - D) / D, (R - N.position.y * this.renderer.devicePixelRatio) / R, Math.max(0, Math.min(1, N.position.z)))) : (this.gl.uniform1i(T.useScreenCoordinates, 0), this.gl.uniformMatrix4fv(T.modelViewMatrix, !1, N._modelViewMatrix.elements)), h.fog && $.fog ? G = P : G = 0, B !== G && (this.gl.uniform1i(T.fogType, G), B = G), k = 1 / ($.scaleByViewport ? c : 1), H[0] *= k * N.scale.x, H[1] *= k * N.scale.y; + let Q = (A = $ == null ? void 0 : $.alignment) === null || A === void 0 ? void 0 : A.x, oe = (S = $ == null ? void 0 : $.alignment) === null || S === void 0 ? void 0 : S.y; + $.screenOffset && (Q = (Q || 0) + 2 * $.screenOffset.x / U, oe = (oe || 0) + 2 * $.screenOffset.y / V), this.gl.uniform2f(T.uvScale, ((n = $ == null ? void 0 : $.uvScale) === null || n === void 0 ? void 0 : n.x) || 1, ((o = $ == null ? void 0 : $.uvScale) === null || o === void 0 ? void 0 : o.y) || 1), this.gl.uniform2f(T.uvOffset, ((w = $ == null ? void 0 : $.uvOffset) === null || w === void 0 ? void 0 : w.x) || 0, ((p = $ == null ? void 0 : $.uvOffset) === null || p === void 0 ? void 0 : p.y) || 0), this.gl.uniform2f(T.alignment, Q || 0, oe || 0), this.gl.uniform1f(T.opacity, $.opacity), this.gl.uniform3f(T.color, ((v = $ == null ? void 0 : $.color) === null || v === void 0 ? void 0 : v.r) || 0, ((a = $ == null ? void 0 : $.color) === null || a === void 0 ? void 0 : a.g) || 0, ((l = $ == null ? void 0 : $.color) === null || l === void 0 ? void 0 : l.b) || 0), this.gl.uniform1f(T.rotation, N.rotation), this.gl.uniform2fv(T.scale, H), this.renderer.setDepthTest($.depthTest), this.renderer.setDepthWrite($.depthWrite), this.renderer.setTexture($.map, 0), this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0); + } + this.gl.enable(this.gl.CULL_FACE); + } + createProgram(h, u) { + if (!this.gl) + throw new Error("WebGL Rendering context not found"); + var E = this.gl.createProgram(); + if (!E) + throw new Error("Error creating webgl program"); + var c = this.gl.createShader(this.gl.FRAGMENT_SHADER), C = this.gl.createShader(this.gl.VERTEX_SHADER); + if (!c) + throw new Error("Unable to create fragment shader SpritePlugin.createProgram"); + if (!C) + throw new Error("Unable to create vertex shader SpritePlugin.createProgram"); + var b = "precision " + u + ` float; +`; + if (this.gl.shaderSource(c, b + h.fragmentShader), this.gl.shaderSource(C, b + h.vertexShader), this.gl.compileShader(c), this.gl.compileShader(C), !this.gl.getShaderParameter(c, this.gl.COMPILE_STATUS) || !this.gl.getShaderParameter(C, this.gl.COMPILE_STATUS)) + throw new Error(`Error compiling shader: + ${this.gl.getShaderInfoLog(c)} + ${this.gl.getShaderInfoLog(C)}`); + return this.gl.attachShader(E, c), this.gl.attachShader(E, C), this.gl.linkProgram(E), this.gl.getProgramParameter(E, this.gl.LINK_STATUS) || console.error("Could not initialize shader"), E; + } + } + function _(x, h) { + return x.z !== h.z ? h.z - x.z : h.id - x.id; + } + } + ), + /***/ + "./src/WebGL/constants/Coloring.ts": ( + /*!*****************************************!*\ + !*** ./src/WebGL/constants/Coloring.ts ***! + \*****************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Coloring: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + var s; + (function(f) { + f[f.NoColors = 0] = "NoColors", f[f.FaceColors = 1] = "FaceColors", f[f.VertexColors = 2] = "VertexColors"; + })(s || (s = {})); + } + ), + /***/ + "./src/WebGL/constants/Shading.ts": ( + /*!****************************************!*\ + !*** ./src/WebGL/constants/Shading.ts ***! + \****************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Shading: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + var s; + (function(f) { + f[f.NoShading = 0] = "NoShading", f[f.FlatShading = 1] = "FlatShading", f[f.SmoothShading = 2] = "SmoothShading"; + })(s || (s = {})); + } + ), + /***/ + "./src/WebGL/constants/Sides.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/constants/Sides.ts ***! + \**************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + BackSide: () => ( + /* binding */ + f + ), + /* harmony export */ + DoubleSide: () => ( + /* binding */ + _ + ), + /* harmony export */ + FrontSide: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + const s = 0, f = 1, _ = 2; + } + ), + /***/ + "./src/WebGL/constants/SpriteAlignment.ts": ( + /*!************************************************!*\ + !*** ./src/WebGL/constants/SpriteAlignment.ts ***! + \************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + SpriteAlignment: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + const f = { + topLeft: new s.Vector2(1, -1), + topCenter: new s.Vector2(0, -1), + topRight: new s.Vector2(-1, -1), + centerLeft: new s.Vector2(1, 0), + center: new s.Vector2(0, 0), + centerRight: new s.Vector2(-1, 0), + bottomLeft: new s.Vector2(1, 1), + bottomCenter: new s.Vector2(0, 1), + bottomRight: new s.Vector2(-1, 1) + }; + } + ), + /***/ + "./src/WebGL/constants/TextureConstants.ts": ( + /*!*************************************************!*\ + !*** ./src/WebGL/constants/TextureConstants.ts ***! + \*************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + ClampToEdgeWrapping: () => ( + /* binding */ + s + ), + /* harmony export */ + FloatType: () => ( + /* binding */ + u + ), + /* harmony export */ + LinearFilter: () => ( + /* binding */ + f + ), + /* harmony export */ + LinearMipMapLinearFilter: () => ( + /* binding */ + x + ), + /* harmony export */ + NearestFilter: () => ( + /* binding */ + _ + ), + /* harmony export */ + R32Format: () => ( + /* binding */ + C + ), + /* harmony export */ + RFormat: () => ( + /* binding */ + c + ), + /* harmony export */ + RGBAFormat: () => ( + /* binding */ + E + ), + /* harmony export */ + UnsignedByteType: () => ( + /* binding */ + h + ) + /* harmony export */ + }); + const s = 1001, f = 1006, _ = 1007, x = 1008, h = 1009, u = 1010, E = 1021, c = 1022, C = 1023; + } + ), + /***/ + "./src/WebGL/constants/TextureOperations.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/constants/TextureOperations.ts ***! + \**************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + TextureOperations: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + var s; + (function(f) { + f[f.MultiplyOperation = 0] = "MultiplyOperation", f[f.MixOperation = 1] = "MixOperation", f[f.AddOperation = 2] = "AddOperation"; + })(s || (s = {})); + } + ), + /***/ + "./src/WebGL/constants/index.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/constants/index.ts ***! + \**************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + BackSide: () => ( + /* reexport safe */ + f.BackSide + ), + /* harmony export */ + ClampToEdgeWrapping: () => ( + /* reexport safe */ + h.ClampToEdgeWrapping + ), + /* harmony export */ + Coloring: () => ( + /* reexport safe */ + s.Coloring + ), + /* harmony export */ + DoubleSide: () => ( + /* reexport safe */ + f.DoubleSide + ), + /* harmony export */ + FloatType: () => ( + /* reexport safe */ + h.FloatType + ), + /* harmony export */ + FrontSide: () => ( + /* reexport safe */ + f.FrontSide + ), + /* harmony export */ + LinearFilter: () => ( + /* reexport safe */ + h.LinearFilter + ), + /* harmony export */ + LinearMipMapLinearFilter: () => ( + /* reexport safe */ + h.LinearMipMapLinearFilter + ), + /* harmony export */ + NearestFilter: () => ( + /* reexport safe */ + h.NearestFilter + ), + /* harmony export */ + R32Format: () => ( + /* reexport safe */ + h.R32Format + ), + /* harmony export */ + RFormat: () => ( + /* reexport safe */ + h.RFormat + ), + /* harmony export */ + RGBAFormat: () => ( + /* reexport safe */ + h.RGBAFormat + ), + /* harmony export */ + Shading: () => ( + /* reexport safe */ + _.Shading + ), + /* harmony export */ + SpriteAlignment: () => ( + /* reexport safe */ + x.SpriteAlignment + ), + /* harmony export */ + TextureOperations: () => ( + /* reexport safe */ + u.TextureOperations + ), + /* harmony export */ + UnsignedByteType: () => ( + /* reexport safe */ + h.UnsignedByteType + ) + /* harmony export */ + }); + var s = t( + /*! ./Coloring */ + "./src/WebGL/constants/Coloring.ts" + ), f = t( + /*! ./Sides */ + "./src/WebGL/constants/Sides.ts" + ), _ = t( + /*! ./Shading */ + "./src/WebGL/constants/Shading.ts" + ), x = t( + /*! ./SpriteAlignment */ + "./src/WebGL/constants/SpriteAlignment.ts" + ), h = t( + /*! ./TextureConstants */ + "./src/WebGL/constants/TextureConstants.ts" + ), u = t( + /*! ./TextureOperations */ + "./src/WebGL/constants/TextureOperations.ts" + ); + } + ), + /***/ + "./src/WebGL/core/EventDispatcher.ts": ( + /*!*******************************************!*\ + !*** ./src/WebGL/core/EventDispatcher.ts ***! + \*******************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + EventDispatcher: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + class s { + constructor() { + this.listeners = {}; + } + dispatchEvent(_) { + var x = this.listeners[_.type]; + if (x !== void 0) { + _.target = this; + for (var h = 0, u = x.length; h < u; h++) + x[h].call(this, _); + } + } + removeEventListener(_, x) { + if (!x) + this.listeners[_] = []; + else { + var h = this.listeners[_].indexOf(x); + h !== -1 && this.listeners[_].splice(h, 1); + } + } + addEventListener(_, x) { + this.listeners[_] === void 0 && (this.listeners[_] = []), this.listeners[_].indexOf(x) === -1 && this.listeners[_].push(x); + } + } + } + ), + /***/ + "./src/WebGL/core/Geometry.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/core/Geometry.ts ***! + \************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Geometry: () => ( + /* binding */ + E + ), + /* harmony export */ + GeometryGroup: () => ( + /* binding */ + u + ), + /* harmony export */ + GeometryIDCount: () => ( + /* binding */ + c + ) + /* harmony export */ + }); + var s = t( + /*! ../materials/LineBasicMaterial */ + "./src/WebGL/materials/LineBasicMaterial.ts" + ), f = t( + /*! ./EventDispatcher */ + "./src/WebGL/core/EventDispatcher.ts" + ), _ = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), x = t( + /*! ../../colors */ + "./src/colors.ts" + ); + const h = 65535; + class u { + constructor(b = 0) { + this.vertexArray = null, this.colorArray = null, this.normalArray = null, this.radiusArray = null, this.faceArray = null, this.lineArray = null, this.vertices = 0, this.faceidx = 0, this.lineidx = 0, this.__inittedArrays = !1, this.id = b; + } + setColors(b) { + var A = this.vertexArray, S = this.colorArray; + if (!A) + throw new Error("vertex array not initialized"); + if (!S) + throw new Error("color array not initialized"); + if (A.length != S.length) { + console.log("Cannot re-color geometry group due to mismatched lengths."); + return; + } + for (var n = 0; n < A.length; n += 3) { + var o = b(A[n], A[n + 1], A[n + 2]); + o instanceof x.Color || (o = x.CC.color(o)), S[n] = o.r, S[n + 1] = o.g, S[n + 2] = o.b; + } + } + getNumVertices() { + return this.vertices; + } + getVertices() { + return this.vertexArray; + } + getCentroid() { + if (!this.vertexArray) + throw new Error("vertex array not initialized"); + for (var b = new _.Vector3(), A, S, n, o, w = 0; w < this.vertices; ++w) + A = w * 3, S = this.vertexArray[A], n = this.vertexArray[A + 1], o = this.vertexArray[A + 2], b.x += S, b.y += n, b.z += o; + return b.divideScalar(this.vertices), b; + } + //setup normals - vertex and face array must exist + setNormals() { + var b = this.faceArray, A = this.vertexArray, S = this.normalArray; + if (!(!this.vertices || !this.faceidx)) { + if (!b) + throw new Error("face array not initialized"); + if (!A) + throw new Error("vertex array not initialized"); + if (!S) + throw new Error("normal array not initialized"); + for (var n, o, w, p, v, a, l, g = 0; g < b.length / 3; ++g) + n = b[g * 3] * 3, o = b[g * 3 + 1] * 3, w = b[g * 3 + 2] * 3, p = new _.Vector3(A[n], A[n + 1], A[n + 2]), v = new _.Vector3(A[o], A[o + 1], A[o + 2]), a = new _.Vector3(A[w], A[w + 1], A[w + 2]), p.subVectors(p, v), a.subVectors(a, v), a.cross(p), l = a, l.normalize(), S[n] += l.x, S[o] += l.x, S[w] += l.x, S[n + 1] += l.y, S[o + 1] += l.y, S[w + 1] += l.y, S[n + 2] += l.z, S[o + 2] += l.z, S[w + 2] += l.z; + } + } + /* sets line index array from face arr + Note - assumes all faces are triangles (i.e. there will + be an extra diagonal for four-sided faces - user should + specify linearr for custom shape generation to show wireframe squares + as rectangles rather than two triangles) */ + setLineIndices() { + if (this.faceidx && !(this.lineArray && this.lineArray.length == this.faceidx * 2 && this.lineidx == this.faceidx * 2)) { + var b = this.faceArray, A = this.lineArray = new Uint16Array(this.faceidx * 2); + if (this.lineidx = this.faceidx * 2, !b) + throw new Error("face array not initialized"); + for (var S = 0; S < this.faceidx / 3; ++S) { + var n = S * 3, o = n * 2, w = b[n], p = b[n + 1], v = b[n + 2]; + A[o] = w, A[o + 1] = p, A[o + 2] = w, A[o + 3] = v, A[o + 4] = p, A[o + 5] = v; + } + } + } + vrml(b, A) { + var S, n, o, w, p, v, a, l, g, M, L, T, D, R, B, P = ""; + P += b + `Shape { +` + b + ` appearance Appearance { +` + b + ` material Material { +` + b + " diffuseColor " + ((S = A == null ? void 0 : A.color) === null || S === void 0 ? void 0 : S.r) + " " + ((n = A == null ? void 0 : A.color) === null || n === void 0 ? void 0 : n.g) + " " + ((o = A == null ? void 0 : A.color) === null || o === void 0 ? void 0 : o.b) + ` +`, A != null && A.transparent && (P += b + " transparency " + (1 - A.opacity) + ` +`), P += b + ` } +`, P += b + ` } +`; + var z = b; + if (b += " ", A instanceof s.LineBasicMaterial) { + P += b + `geometry IndexedLineSet { +` + b + ` colorPerVertex TRUE +` + b + ` coord Coordinate { +` + b + ` point [ +`; + let N, $, k; + for (let G = 0; G < this.vertices; ++G) { + let H = G * 3; + N = (w = this.vertexArray) === null || w === void 0 ? void 0 : w[H], $ = (p = this.vertexArray) === null || p === void 0 ? void 0 : p[H + 1], k = (v = this.vertexArray) === null || v === void 0 ? void 0 : v[H + 2], P += b + " " + N + " " + $ + " " + k + `, +`; + } + if (P += b + ` ] +`, P += b + ` } +`, this.colorArray) { + P += b + ` color Color { +` + b + ` color [ +`; + for (let G = 0; G < this.vertices; ++G) { + let H = G * 3; + N = this.colorArray[H], $ = this.colorArray[H + 1], k = this.colorArray[H + 2], P += b + " " + N + " " + $ + " " + k + `, +`; + } + P += b + ` ] +`, P += b + ` } +`; + } + P += b + ` coordIndex [ +`; + for (let G = 0; G < this.vertices; G += 2) + P += b + " " + G + ", " + (G + 1) + `, -1, +`; + P += b + ` ] +`, P += b + `} +`; + } else { + P += b + `geometry IndexedFaceSet { +` + b + ` colorPerVertex TRUE +` + b + ` normalPerVertex TRUE +` + b + ` solid FALSE +`, P += b + ` coord Coordinate { +` + b + ` point [ +`; + let N, $, k; + for (let G = 0; G < this.vertices; ++G) { + let H = G * 3; + N = (a = this.vertexArray) === null || a === void 0 ? void 0 : a[H], $ = (l = this.vertexArray) === null || l === void 0 ? void 0 : l[H + 1], k = (g = this.vertexArray) === null || g === void 0 ? void 0 : g[H + 2], P += b + " " + N + " " + $ + " " + k + `, +`; + } + P += b + ` ] +`, P += b + ` } +`, P += b + ` normal Normal { +` + b + ` vector [ +`; + for (let G = 0; G < this.vertices; ++G) { + let H = G * 3; + N = (M = this.normalArray) === null || M === void 0 ? void 0 : M[H], $ = (L = this.normalArray) === null || L === void 0 ? void 0 : L[H + 1], k = (T = this.normalArray) === null || T === void 0 ? void 0 : T[H + 2], P += b + " " + N + " " + $ + " " + k + `, +`; + } + if (P += b + ` ] +`, P += b + ` } +`, this.colorArray) { + P += b + ` color Color { +` + b + ` color [ +`; + for (let G = 0; G < this.vertices; ++G) { + let H = G * 3; + N = this.colorArray[H], $ = this.colorArray[H + 1], k = this.colorArray[H + 2], P += b + " " + N + " " + $ + " " + k + `, +`; + } + P += b + ` ] +`, P += b + ` } +`; + } + P += b + ` coordIndex [ +`; + for (var F = 0; F < this.faceidx; F += 3) + N = (D = this.faceArray) === null || D === void 0 ? void 0 : D[F], $ = (R = this.faceArray) === null || R === void 0 ? void 0 : R[F + 1], k = (B = this.faceArray) === null || B === void 0 ? void 0 : B[F + 2], P += b + " " + N + ", " + $ + ", " + k + `, -1, +`; + P += b + ` ] +`, P += b + `} +`; + } + return P += z + "}", P; + } + truncateArrayBuffers(b = !0, A = !1) { + var S = this.vertexArray, n = this.colorArray, o = this.normalArray, w = this.faceArray, p = this.lineArray, v = this.radiusArray; + this.vertexArray = (S == null ? void 0 : S.subarray(0, this.vertices * 3)) || null, this.colorArray = (n == null ? void 0 : n.subarray(0, this.vertices * 3)) || null, b ? (this.normalArray = (o == null ? void 0 : o.subarray(0, this.vertices * 3)) || null, this.faceArray = (w == null ? void 0 : w.subarray(0, this.faceidx)) || null, this.lineidx > 0 ? this.lineArray = (p == null ? void 0 : p.subarray(0, this.lineidx)) || null : this.lineArray = new Uint16Array(0)) : (this.normalArray = new Float32Array(0), this.faceArray = new Uint16Array(0), this.lineArray = new Uint16Array(0)), v && (this.radiusArray = v.subarray(0, this.vertices)), A && (this.normalArray && (this.normalArray = new Float32Array(this.normalArray)), this.faceArray && (this.faceArray = new Uint16Array(this.faceArray)), this.lineArray && (this.lineArray = new Uint16Array(this.lineArray)), this.vertexArray && (this.vertexArray = new Float32Array(this.vertexArray)), this.colorArray && (this.colorArray = new Float32Array(this.colorArray)), this.radiusArray && (this.radiusArray = new Float32Array(this.radiusArray))), this.__inittedArrays = !0; + } + } + class E extends f.EventDispatcher { + constructor(b = !1, A = !1, S = !1) { + super(), this.name = "", this.hasTangents = !1, this.dynamic = !0, this.verticesNeedUpdate = !1, this.elementsNeedUpdate = !1, this.normalsNeedUpdate = !1, this.colorsNeedUpdate = !1, this.buffersNeedUpdate = !1, this.imposter = !1, this.instanced = !1, this.geometryGroups = [], this.groups = 0, this.id = c++, this.mesh = b, this.radii = A, this.offset = S; + } + //Get geometry group to accomodate addVertices new vertices - create + // new group if necessary + updateGeoGroup(b = 0) { + var A, S = this.groups > 0 ? this.geometryGroups[this.groups - 1] : null; + return (!S || S.vertices + b > (((A = S == null ? void 0 : S.vertexArray) === null || A === void 0 ? void 0 : A.length) || 0) / 3) && (S = this.addGeoGroup()), S; + } + //return comma separated list of IndexedFace (or Line) sets from geometry groups + vrml(b, A) { + for (var S = "", n = this.geometryGroups.length, o = 0; o < n; o++) { + var w = this.geometryGroups[o]; + S += w.vrml(b, A) + `, +`; + } + return S; + } + addGeoGroup() { + var b = new u(this.geometryGroups.length); + return this.geometryGroups.push(b), this.groups = this.geometryGroups.length, b.vertexArray = new Float32Array(h * 3), b.colorArray = new Float32Array(h * 3), this.mesh && (b.normalArray = new Float32Array(h * 3), b.faceArray = new Uint16Array(h * 6), b.lineArray = new Uint16Array(h * 6)), this.radii && (b.radiusArray = new Float32Array(h)), b.useOffset = this.offset, b; + } + setUpNormals(...b) { + for (var A = 0; A < this.groups; A++) { + var S = this.geometryGroups[A]; + S.setNormals(...b); + } + } + setColors(...b) { + for (var A = this.geometryGroups.length, S = 0; S < A; S++) { + var n = this.geometryGroups[S]; + n.setColors(...b); + } + } + setUpWireframe(...b) { + for (var A = 0; A < this.groups; A++) { + var S = this.geometryGroups[A]; + S.setLineIndices(...b); + } + } + //After vertices, colors, etc are collected in regular or typed arrays, + // create typed arrays from regular arrays if they don't already exist, + initTypedArrays() { + for (var b = 0; b < this.groups; b++) { + var A = this.geometryGroups[b]; + A.__inittedArrays !== !0 && A.truncateArrayBuffers(this.mesh, !1); + } + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } + get vertices() { + for (var b = 0, A = 0; A < this.groups; A++) + b += this.geometryGroups[A].vertices; + return b; + } + } + let c = 0; + } + ), + /***/ + "./src/WebGL/core/Object3D.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/core/Object3D.ts ***! + \************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Light: () => ( + /* binding */ + u + ), + /* harmony export */ + Object3D: () => ( + /* binding */ + x + ), + /* harmony export */ + Object3DIDCount: () => ( + /* binding */ + _ + ), + /* harmony export */ + Scene: () => ( + /* binding */ + h + ) + /* harmony export */ + }); + var s = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), f = t( + /*! ../../colors */ + "./src/colors.ts" + ); + let _ = 0; + class x { + constructor() { + this.id = _++, this.name = "", this.children = [], this.position = new s.Vector3(), this.rotation = new s.Vector3(), this.matrix = new s.Matrix4(), this.matrixWorld = new s.Matrix4(), this.quaternion = new s.Quaternion(), this.eulerOrder = "XYZ", this.up = new s.Vector3(0, 1, 0), this.scale = new s.Vector3(1, 1, 1), this.matrixAutoUpdate = !0, this.matrixWorldNeedsUpdate = !0, this.rotationAutoUpdate = !0, this.useQuaternion = !1, this.visible = !0; + } + lookAt(c) { + this.matrix.lookAt(c, this.position, this.up), this.rotationAutoUpdate && (this.useQuaternion === !0 ? console.error("Unimplemented math operation.") : this.rotation instanceof s.Vector3 && this.rotation.setEulerFromRotationMatrix(this.matrix, this.eulerOrder)); + } + //add child object + add(c) { + if (c === this) { + console.error("Can't add $3Dmol.Object3D to itself"); + return; + } + c.parent = this, this.children.push(c); + for (var C = this; C.parent !== void 0; ) + C = C.parent; + C !== void 0 && C instanceof h && C.__addObject(c); + } + remove(c) { + var C = this.children.indexOf(c); + if (C !== -1) { + c.parent = void 0, this.children.splice(C, 1); + for (var b = this; b.parent !== void 0; ) + b = b.parent; + b !== void 0 && b instanceof h && b.__removeObject(c); + } + } + //convert to vrml + vrml(c) { + c || (c = " "); + var C = 2 * Math.atan2(this.quaternion.lengthxyz(), this.quaternion.w), b = 0, A = 0, S = 0; + if (C != 0) { + let w = Math.sin(C / 2); + b = this.quaternion.x / w, A = this.quaternion.y / w, S = this.quaternion.z / w; + } + var n = c + `Transform { +` + c + " center " + this.position.x + " " + this.position.y + " " + this.position.z + ` +` + c + " rotation " + b + " " + A + " " + S + " " + C + ` +` + c + ` children [ +`; + this.geometry && (n += this.geometry.vrml(c, this.material)); + for (var o = 0; o < this.children.length; o++) + n += this.children[o].vrml(c + " ") + `, +`; + return n += ` ] +`, n += "}", n; + } + updateMatrix() { + this.matrix.setPosition(this.position), this.useQuaternion === !1 && this.rotation instanceof s.Vector3 ? this.matrix.setRotationFromEuler(this.rotation, this.eulerOrder) : this.matrix.setRotationFromQuaternion(this.quaternion), (this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1) && this.matrix.scale(this.scale), this.matrixWorldNeedsUpdate = !0; + } + updateMatrixWorld(c) { + this.matrixAutoUpdate === !0 && this.updateMatrix(), (this.matrixWorldNeedsUpdate === !0 || c === !0) && (this.parent === void 0 ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1; + for (var C = 0; C < this.children.length; C++) + this.children[C].updateMatrixWorld(!0); + } + clone(c) { + c === void 0 && (c = new x()), c.name = this.name, c.up.copy(this.up), c.position.copy(this.position), c.rotation instanceof s.Vector3 && this.rotation instanceof s.Vector3 ? c.rotation.copy(this.rotation) : c.rotation = this.rotation, c.eulerOrder = this.eulerOrder, c.scale.copy(this.scale), c.rotationAutoUpdate = this.rotationAutoUpdate, c.matrix.copy(this.matrix), c.matrixWorld.copy(this.matrixWorld), c.quaternion.copy(this.quaternion), c.matrixAutoUpdate = this.matrixAutoUpdate, c.matrixWorldNeedsUpdate = this.matrixWorldNeedsUpdate, c.useQuaternion = this.useQuaternion, c.visible = this.visible; + for (var C = 0; C < this.children.length; C++) { + var b = this.children[C]; + c.add(b.clone()); + } + return c; + } + setVisible(c) { + this.visible = c; + for (var C = 0; C < this.children.length; C++) { + var b = this.children[C]; + b.setVisible(c); + } + } + } + class h extends x { + constructor() { + super(...arguments), this.fog = null, this.overrideMaterial = null, this.matrixAutoUpdate = !1, this.__objects = [], this.__lights = [], this.__objectsAdded = [], this.__objectsRemoved = []; + } + __addObject(c) { + if (c instanceof u) + this.__lights.indexOf(c) === -1 && this.__lights.push(c), c.target && c.target.parent === void 0 && this.add(c.target); + else if (this.__objects.indexOf(c) === -1) { + this.__objects.push(c), this.__objectsAdded.push(c); + var C = this.__objectsRemoved.indexOf(c); + C !== -1 && this.__objectsRemoved.splice(C, 1); + } + for (var b = 0; b < c.children.length; b++) + this.__addObject(c.children[b]); + } + __removeObject(c) { + var C; + if (c instanceof u) + C = this.__lights.indexOf(c), C !== -1 && this.__lights.splice(C, 1); + else if (C = this.__objects.indexOf(c), C !== -1) { + this.__objects.splice(C, 1), this.__objectsRemoved.push(c); + var b = this.__objectsAdded.indexOf(c); + b !== -1 && this.__objectsAdded.splice(C, 1); + } + for (var A = 0; A < c.children.length; A++) + this.__removeObject(c.children[A]); + } + } + class u extends x { + constructor(c, C = 1) { + super(), this.position = new s.Vector3(0, 1, 0), this.target = new x(), this.castShadow = !1, this.onlyShadow = !1, this.color = new f.Color(c), this.intensity = C; + } + } + } + ), + /***/ + "./src/WebGL/core/Projector.ts": ( + /*!*************************************!*\ + !*** ./src/WebGL/core/Projector.ts ***! + \*************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Projector: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + const f = new s.Matrix4(); + class _ { + static unprojectVector(h, u) { + return u.projectionMatrixInverse.getInverse(u.projectionMatrix), f.multiplyMatrices(u.matrixWorld, u.projectionMatrixInverse), h.applyProjection(f); + } + static projectVector(h, u) { + return u.matrixWorldInverse.getInverse(u.matrixWorld), f.multiplyMatrices(u.projectionMatrix, u.matrixWorldInverse), h.applyProjection(f); + } + projectVector(h, u) { + return _.projectVector(h, u); + } + unprojectVector(h, u) { + return _.unprojectVector(h, u); + } + } + } + ), + /***/ + "./src/WebGL/core/Raycaster.ts": ( + /*!*************************************!*\ + !*** ./src/WebGL/core/Raycaster.ts ***! + \*************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Raycaster: () => ( + /* binding */ + h + ), + /* harmony export */ + intersectObject: () => ( + /* binding */ + w + ) + /* harmony export */ + }); + var s = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), f = t( + /*! ../shapes */ + "./src/WebGL/shapes/index.ts" + ); + const _ = (p, v) => p.distance - v.distance, x = new s.Matrix4(); + class h { + constructor(v, a, l, g) { + this.precision = 1e-4, this.linePrecision = 0.2, this.ray = new s.Ray(v, a), this.ray.direction.lengthSq() > 0 && this.ray.direction.normalize(), this.near = g || 0, this.far = l || 1 / 0; + } + set(v, a) { + this.ray.set(v, a); + } + setFromCamera(v, a) { + a.ortho ? (this.ray.origin.set(v.x, v.y, (a.near + a.far) / (a.near - a.far)).unproject(a), this.ray.direction.set(0, 0, -1).transformDirection(a.matrixWorld)) : (this.ray.origin.setFromMatrixPosition(a.matrixWorld), this.ray.direction.set(v.x, v.y, v.z), a.projectionMatrixInverse.getInverse(a.projectionMatrix), x.multiplyMatrices(a.matrixWorld, a.projectionMatrixInverse), this.ray.direction.applyProjection(x), this.ray.direction.sub(this.ray.origin).normalize()); + } + intersectObjects(v, a) { + for (var l = [], g = 0, M = a.length; g < M; g++) + w(v, a[g], this, l); + return l.sort(_), l; + } + } + const u = (p) => Math.min(Math.max(p, -1), 1); + var E = new f.Sphere(), c = new f.Cylinder(), C = new f.Triangle(), b = new s.Vector3(), A = new s.Vector3(), S = new s.Vector3(), n = new s.Vector3(), o = new s.Vector3(); + function w(p, v, a, l) { + if (o.getPositionFromMatrix(p.matrixWorld), v.intersectionShape === void 0) + return l; + var g = v.intersectionShape, M = a.linePrecision; + M *= p.matrixWorld.getMaxScaleOnAxis(); + var L = M * M; + if (v.boundingSphere !== void 0 && v.boundingSphere instanceof f.Sphere && (E.copy(v.boundingSphere), E.applyMatrix4(p.matrixWorld), !a.ray.isIntersectionSphere(E))) + return l; + var T, D, R, B, P, z, F, N, $, k, G, H, U, V; + for (T = 0, D = g.triangle.length; T < D; T++) + if (g.triangle[T] instanceof f.Triangle) { + if (C.copy(g.triangle[T]), C.applyMatrix4(p.matrixWorld), R = C.getNormal(), B = a.ray.direction.dot(R), B >= 0 || (b.subVectors(C.a, a.ray.origin), F = R.dot(b) / B, F < 0)) + continue; + A.copy(a.ray.direction).multiplyScalar(F).add(a.ray.origin), A.sub(C.a), S.copy(C.b).sub(C.a), n.copy(C.c).sub(C.a); + var Q = S.dot(n), oe = S.lengthSq(), ee = n.lengthSq(); + if (H = (oe * A.dot(n) - Q * A.dot(S)) / (oe * ee - Q * Q), H < 0 || H > 1 || (G = (A.dot(S) - H * Q) / oe, G < 0 || G > 1 || G + H > 1)) + continue; + l.push({ clickable: v, distance: F }); + } + for (T = 0, D = g.cylinder.length; T < D; T++) + if (g.cylinder[T] instanceof f.Cylinder) { + if (c.copy(g.cylinder[T]), c.applyMatrix4(p.matrixWorld), b.subVectors(c.c1, a.ray.origin), P = b.dot(c.direction), z = b.dot(a.ray.direction), B = u(a.ray.direction.dot(c.direction)), $ = 1 - B * B, $ === 0) + continue; + U = (B * z - P) / $, V = (z - B * P) / $, A.copy(c.direction).multiplyScalar(U).add(c.c1), S.copy(a.ray.direction).multiplyScalar(V).add(a.ray.origin), N = n.subVectors(A, S).lengthSq(); + var ne = c.radius * c.radius; + if (N <= ne) { + if (k = (B * P - z) * (B * P - z) - $ * (b.lengthSq() - P * P - ne), k <= 0 ? H = F = Math.sqrt(N) : H = F = (z - B * P - Math.sqrt(k)) / $, G = B * H - P, G < 0 || G * G > c.lengthSq() || H < 0) + continue; + l.push({ clickable: v, distance: F }); + } + } + for (T = 0, D = g.line.length; T < D; T += 2) { + A.copy(g.line[T]), A.applyMatrix4(p.matrixWorld), S.copy(g.line[T + 1]), S.applyMatrix4(p.matrixWorld), n.subVectors(S, A); + var me = n.lengthSq(); + n.normalize(), b.subVectors(A, a.ray.origin); + var se = b.dot(n); + z = b.dot(a.ray.direction), B = u(a.ray.direction.dot(n)), $ = 1 - B * B, $ !== 0 && (U = (B * z - se) / $, V = (z - B * se) / $, A.add(n.multiplyScalar(U)), S.copy(a.ray.direction).multiplyScalar(V).add(a.ray.origin), N = n.subVectors(S, A).lengthSq(), N < L && U * U < me && l.push({ clickable: v, distance: V })); + } + for (T = 0, D = g.sphere.length; T < D; T++) + if (g.sphere[T] instanceof f.Sphere && (E.copy(g.sphere[T]), E.applyMatrix4(p.matrixWorld), a.ray.isIntersectionSphere(E))) { + A.subVectors(E.center, a.ray.origin); + var fe = A.dot(a.ray.direction); + if (k = fe * fe - (A.lengthSq() - E.radius * E.radius), fe < 0) + return l; + k <= 0 ? F = fe : F = fe - Math.sqrt(k), l.push({ clickable: v, distance: F }); + } + return l; + } + } + ), + /***/ + "./src/WebGL/core/Texture.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/core/Texture.ts ***! + \***********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Texture: () => ( + /* binding */ + h + ), + /* harmony export */ + TextureIdCount: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ../constants/TextureConstants */ + "./src/WebGL/constants/TextureConstants.ts" + ), f = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), _ = t( + /*! ./EventDispatcher */ + "./src/WebGL/core/EventDispatcher.ts" + ), x = t( + /*! ./UVMapping */ + "./src/WebGL/core/UVMapping.ts" + ); + class h extends _.EventDispatcher { + constructor(c, C) { + super(), this.id = u++, this.name = "", this.image = c, this.mapping = new x.UVMapping(), this.wrapS = s.ClampToEdgeWrapping, this.wrapT = s.ClampToEdgeWrapping, this.anisotropy = 1, C ? (this.format = s.RFormat, this.type = s.FloatType, this.premultiplyAlpha = !1, this.flipY = !1, this.unpackAlignment = 1, this.magFilter = s.NearestFilter, this.minFilter = s.NearestFilter) : (this.format = s.RGBAFormat, this.type = s.UnsignedByteType, this.offset = new f.Vector2(0, 0), this.repeat = new f.Vector2(1, 1), this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.magFilter = s.LinearFilter, this.minFilter = s.LinearMipMapLinearFilter), this.needsUpdate = !1, this.onUpdate = null; + } + clone(c = new h()) { + return c.image = this.image, c.mapping = this.mapping, c.wrapS = this.wrapS, c.wrapT = this.wrapT, c.magFilter = this.magFilter, c.minFilter = this.minFilter, c.anisotropy = this.anisotropy, c.format = this.format, c.type = this.type, c.offset.copy(this.offset), c.repeat.copy(this.repeat), c.premultiplyAlpha = this.premultiplyAlpha, c.flipY = this.flipY, c.unpackAlignment = this.unpackAlignment, c; + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } + } + let u = 0; + } + ), + /***/ + "./src/WebGL/core/UVMapping.ts": ( + /*!*************************************!*\ + !*** ./src/WebGL/core/UVMapping.ts ***! + \*************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + UVMapping: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + class s { + } + } + ), + /***/ + "./src/WebGL/core/index.ts": ( + /*!*********************************!*\ + !*** ./src/WebGL/core/index.ts ***! + \*********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + EventDispatcher: () => ( + /* reexport safe */ + s.EventDispatcher + ), + /* harmony export */ + Geometry: () => ( + /* reexport safe */ + f.Geometry + ), + /* harmony export */ + GeometryGroup: () => ( + /* reexport safe */ + f.GeometryGroup + ), + /* harmony export */ + GeometryIDCount: () => ( + /* reexport safe */ + f.GeometryIDCount + ), + /* harmony export */ + Light: () => ( + /* reexport safe */ + _.Light + ), + /* harmony export */ + Object3D: () => ( + /* reexport safe */ + _.Object3D + ), + /* harmony export */ + Object3DIDCount: () => ( + /* reexport safe */ + _.Object3DIDCount + ), + /* harmony export */ + Projector: () => ( + /* reexport safe */ + x.Projector + ), + /* harmony export */ + Raycaster: () => ( + /* reexport safe */ + h.Raycaster + ), + /* harmony export */ + Scene: () => ( + /* reexport safe */ + _.Scene + ), + /* harmony export */ + Texture: () => ( + /* reexport safe */ + u.Texture + ), + /* harmony export */ + TextureIdCount: () => ( + /* reexport safe */ + u.TextureIdCount + ), + /* harmony export */ + UVMapping: () => ( + /* reexport safe */ + E.UVMapping + ), + /* harmony export */ + intersectObject: () => ( + /* reexport safe */ + h.intersectObject + ) + /* harmony export */ + }); + var s = t( + /*! ./EventDispatcher */ + "./src/WebGL/core/EventDispatcher.ts" + ), f = t( + /*! ./Geometry */ + "./src/WebGL/core/Geometry.ts" + ), _ = t( + /*! ./Object3D */ + "./src/WebGL/core/Object3D.ts" + ), x = t( + /*! ./Projector */ + "./src/WebGL/core/Projector.ts" + ), h = t( + /*! ./Raycaster */ + "./src/WebGL/core/Raycaster.ts" + ), u = t( + /*! ./Texture */ + "./src/WebGL/core/Texture.ts" + ), E = t( + /*! ./UVMapping */ + "./src/WebGL/core/UVMapping.ts" + ); + } + ), + /***/ + "./src/WebGL/index.ts": ( + /*!****************************!*\ + !*** ./src/WebGL/index.ts ***! + \****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + BackSide: () => ( + /* reexport safe */ + s.BackSide + ), + /* harmony export */ + Camera: () => ( + /* reexport safe */ + c.Camera + ), + /* harmony export */ + ClampToEdgeWrapping: () => ( + /* reexport safe */ + s.ClampToEdgeWrapping + ), + /* harmony export */ + Coloring: () => ( + /* reexport safe */ + s.Coloring + ), + /* harmony export */ + Cylinder: () => ( + /* reexport safe */ + E.Cylinder + ), + /* harmony export */ + DoubleSide: () => ( + /* reexport safe */ + s.DoubleSide + ), + /* harmony export */ + EventDispatcher: () => ( + /* reexport safe */ + f.EventDispatcher + ), + /* harmony export */ + FloatType: () => ( + /* reexport safe */ + s.FloatType + ), + /* harmony export */ + Fog: () => ( + /* reexport safe */ + C.Fog + ), + /* harmony export */ + FrontSide: () => ( + /* reexport safe */ + s.FrontSide + ), + /* harmony export */ + Geometry: () => ( + /* reexport safe */ + f.Geometry + ), + /* harmony export */ + GeometryGroup: () => ( + /* reexport safe */ + f.GeometryGroup + ), + /* harmony export */ + GeometryIDCount: () => ( + /* reexport safe */ + f.GeometryIDCount + ), + /* harmony export */ + ImposterMaterial: () => ( + /* reexport safe */ + _.ImposterMaterial + ), + /* harmony export */ + InstancedMaterial: () => ( + /* reexport safe */ + _.InstancedMaterial + ), + /* harmony export */ + Light: () => ( + /* reexport safe */ + f.Light + ), + /* harmony export */ + Line: () => ( + /* reexport safe */ + h.Line + ), + /* harmony export */ + LineBasicMaterial: () => ( + /* reexport safe */ + _.LineBasicMaterial + ), + /* harmony export */ + LineStyle: () => ( + /* reexport safe */ + h.LineStyle + ), + /* harmony export */ + LinearFilter: () => ( + /* reexport safe */ + s.LinearFilter + ), + /* harmony export */ + LinearMipMapLinearFilter: () => ( + /* reexport safe */ + s.LinearMipMapLinearFilter + ), + /* harmony export */ + Material: () => ( + /* reexport safe */ + _.Material + ), + /* harmony export */ + MaterialIdCount: () => ( + /* reexport safe */ + _.MaterialIdCount + ), + /* harmony export */ + Matrix3: () => ( + /* reexport safe */ + x.Matrix3 + ), + /* harmony export */ + Matrix4: () => ( + /* reexport safe */ + x.Matrix4 + ), + /* harmony export */ + Mesh: () => ( + /* reexport safe */ + h.Mesh + ), + /* harmony export */ + MeshDoubleLambertMaterial: () => ( + /* reexport safe */ + _.MeshDoubleLambertMaterial + ), + /* harmony export */ + MeshLambertMaterial: () => ( + /* reexport safe */ + _.MeshLambertMaterial + ), + /* harmony export */ + MeshOutlineMaterial: () => ( + /* reexport safe */ + _.MeshOutlineMaterial + ), + /* harmony export */ + NearestFilter: () => ( + /* reexport safe */ + s.NearestFilter + ), + /* harmony export */ + Object3D: () => ( + /* reexport safe */ + f.Object3D + ), + /* harmony export */ + Object3DIDCount: () => ( + /* reexport safe */ + f.Object3DIDCount + ), + /* harmony export */ + Projector: () => ( + /* reexport safe */ + f.Projector + ), + /* harmony export */ + Quaternion: () => ( + /* reexport safe */ + x.Quaternion + ), + /* harmony export */ + R32Format: () => ( + /* reexport safe */ + s.R32Format + ), + /* harmony export */ + RFormat: () => ( + /* reexport safe */ + s.RFormat + ), + /* harmony export */ + RGBAFormat: () => ( + /* reexport safe */ + s.RGBAFormat + ), + /* harmony export */ + Ray: () => ( + /* reexport safe */ + x.Ray + ), + /* harmony export */ + Raycaster: () => ( + /* reexport safe */ + f.Raycaster + ), + /* harmony export */ + Renderer: () => ( + /* reexport safe */ + b.Renderer + ), + /* harmony export */ + Scene: () => ( + /* reexport safe */ + f.Scene + ), + /* harmony export */ + ShaderLib: () => ( + /* reexport safe */ + u.ShaderLib + ), + /* harmony export */ + ShaderUtils: () => ( + /* reexport safe */ + u.ShaderUtils + ), + /* harmony export */ + Shading: () => ( + /* reexport safe */ + s.Shading + ), + /* harmony export */ + Sphere: () => ( + /* reexport safe */ + E.Sphere + ), + /* harmony export */ + SphereImposterMaterial: () => ( + /* reexport safe */ + _.SphereImposterMaterial + ), + /* harmony export */ + SphereImposterOutlineMaterial: () => ( + /* reexport safe */ + _.SphereImposterOutlineMaterial + ), + /* harmony export */ + Sprite: () => ( + /* reexport safe */ + h.Sprite + ), + /* harmony export */ + SpriteAlignment: () => ( + /* reexport safe */ + s.SpriteAlignment + ), + /* harmony export */ + SpriteMaterial: () => ( + /* reexport safe */ + _.SpriteMaterial + ), + /* harmony export */ + SpritePlugin: () => ( + /* reexport safe */ + A.SpritePlugin + ), + /* harmony export */ + StickImposterMaterial: () => ( + /* reexport safe */ + _.StickImposterMaterial + ), + /* harmony export */ + StickImposterOutlineMaterial: () => ( + /* reexport safe */ + _.StickImposterOutlineMaterial + ), + /* harmony export */ + Texture: () => ( + /* reexport safe */ + f.Texture + ), + /* harmony export */ + TextureIdCount: () => ( + /* reexport safe */ + f.TextureIdCount + ), + /* harmony export */ + TextureOperations: () => ( + /* reexport safe */ + s.TextureOperations + ), + /* harmony export */ + Triangle: () => ( + /* reexport safe */ + E.Triangle + ), + /* harmony export */ + UVMapping: () => ( + /* reexport safe */ + f.UVMapping + ), + /* harmony export */ + UnsignedByteType: () => ( + /* reexport safe */ + s.UnsignedByteType + ), + /* harmony export */ + Vector2: () => ( + /* reexport safe */ + x.Vector2 + ), + /* harmony export */ + Vector3: () => ( + /* reexport safe */ + x.Vector3 + ), + /* harmony export */ + VolumetricMaterial: () => ( + /* reexport safe */ + _.VolumetricMaterial + ), + /* harmony export */ + basic: () => ( + /* reexport safe */ + u.basic + ), + /* harmony export */ + clamp: () => ( + /* reexport safe */ + x.clamp + ), + /* harmony export */ + clone: () => ( + /* reexport safe */ + u.clone + ), + /* harmony export */ + conversionMatrix3: () => ( + /* reexport safe */ + x.conversionMatrix3 + ), + /* harmony export */ + degToRad: () => ( + /* reexport safe */ + x.degToRad + ), + /* harmony export */ + instanced: () => ( + /* reexport safe */ + u.instanced + ), + /* harmony export */ + intersectObject: () => ( + /* reexport safe */ + f.intersectObject + ), + /* harmony export */ + lambert: () => ( + /* reexport safe */ + u.lambert + ), + /* harmony export */ + lambertdouble: () => ( + /* reexport safe */ + u.lambertdouble + ), + /* harmony export */ + outline: () => ( + /* reexport safe */ + u.outline + ), + /* harmony export */ + screen: () => ( + /* reexport safe */ + u.screen + ), + /* harmony export */ + screenaa: () => ( + /* reexport safe */ + u.screenaa + ), + /* harmony export */ + sphereimposter: () => ( + /* reexport safe */ + u.sphereimposter + ), + /* harmony export */ + sphereimposteroutline: () => ( + /* reexport safe */ + u.sphereimposteroutline + ), + /* harmony export */ + sprite: () => ( + /* reexport safe */ + u.sprite + ), + /* harmony export */ + stickimposter: () => ( + /* reexport safe */ + u.stickimposter + ), + /* harmony export */ + stickimposteroutline: () => ( + /* reexport safe */ + u.stickimposteroutline + ), + /* harmony export */ + volumetric: () => ( + /* reexport safe */ + u.volumetric + ) + /* harmony export */ + }); + var s = t( + /*! ./constants */ + "./src/WebGL/constants/index.ts" + ), f = t( + /*! ./core */ + "./src/WebGL/core/index.ts" + ), _ = t( + /*! ./materials */ + "./src/WebGL/materials/index.ts" + ), x = t( + /*! ./math */ + "./src/WebGL/math/index.ts" + ), h = t( + /*! ./objects */ + "./src/WebGL/objects/index.ts" + ), u = t( + /*! ./shaders */ + "./src/WebGL/shaders/index.ts" + ), E = t( + /*! ./shapes */ + "./src/WebGL/shapes/index.ts" + ), c = t( + /*! ./Camera */ + "./src/WebGL/Camera.ts" + ), C = t( + /*! ./Fog */ + "./src/WebGL/Fog.ts" + ), b = t( + /*! ./Renderer */ + "./src/WebGL/Renderer.ts" + ), A = t( + /*! ./SpritePlugin */ + "./src/WebGL/SpritePlugin.ts" + ); + } + ), + /***/ + "./src/WebGL/materials/ImposterMaterial.ts": ( + /*!*************************************************!*\ + !*** ./src/WebGL/materials/ImposterMaterial.ts ***! + \*************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + ImposterMaterial: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ./../constants/Coloring */ + "./src/WebGL/constants/Coloring.ts" + ), f = t( + /*! ./../constants/Shading */ + "./src/WebGL/constants/Shading.ts" + ), _ = t( + /*! ../../colors */ + "./src/colors.ts" + ), x = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), h = t( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class u extends h.Material { + constructor(c) { + super(), this.color = new _.Color(16777215), this.ambient = new _.Color(1048575), this.emissive = new _.Color(0), this.imposter = !0, this.wrapAround = !1, this.wrapRGB = new x.Vector3(1, 1, 1), this.map = void 0, this.lightMap = null, this.specularMap = null, this.envMap = null, this.reflectivity = 1, this.refractionRatio = 0.98, this.fog = !0, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.shading = f.Shading.SmoothShading, this.shaderID = null, this.vertexColors = s.Coloring.NoColors, this.skinning = !1, this.setValues(c); + } + clone(c = new u()) { + return super.clone.call(this, c), c.color.copy(this.color), c.ambient.copy(this.ambient), c.emissive.copy(this.emissive), c.wrapAround = this.wrapAround, c.wrapRGB.copy(this.wrapRGB), c.map = this.map, c.lightMap = this.lightMap, c.specularMap = this.specularMap, c.envMap = this.envMap, c.combine = this.combine, c.reflectivity = this.reflectivity, c.refractionRatio = this.refractionRatio, c.fog = this.fog, c.shading = this.shading, c.shaderID = this.shaderID, c.vertexColors = this.vertexColors, c.skinning = this.skinning, c.morphTargets = this.morphTargets, c.morphNormals = this.morphNormals, c; + } + } + } + ), + /***/ + "./src/WebGL/materials/InstancedMaterial.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/materials/InstancedMaterial.ts ***! + \**************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + InstancedMaterial: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ../constants/Coloring */ + "./src/WebGL/constants/Coloring.ts" + ), f = t( + /*! ../constants/Shading */ + "./src/WebGL/constants/Shading.ts" + ), _ = t( + /*! ../../colors */ + "./src/colors.ts" + ), x = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), h = t( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class u extends h.Material { + constructor(c) { + super(), this.color = new _.Color(16777215), this.ambient = new _.Color(1048575), this.emissive = new _.Color(0), this.wrapAround = !1, this.wrapRGB = new x.Vector3(1, 1, 1), this.map = void 0, this.lightMap = null, this.specularMap = null, this.envMap = null, this.reflectivity = 1, this.refractionRatio = 0.98, this.fog = !0, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.shading = f.Shading.SmoothShading, this.shaderID = "instanced", this.vertexColors = s.Coloring.NoColors, this.skinning = !1, this.sphere = null, this.setValues(c); + } + clone(c = new u()) { + return super.clone.call(this, c), c.color.copy(this.color), c.ambient.copy(this.ambient), c.emissive.copy(this.emissive), c.wrapAround = this.wrapAround, c.wrapRGB.copy(this.wrapRGB), c.map = this.map, c.lightMap = this.lightMap, c.specularMap = this.specularMap, c.envMap = this.envMap, c.combine = this.combine, c.reflectivity = this.reflectivity, c.refractionRatio = this.refractionRatio, c.fog = this.fog, c.shading = this.shading, c.shaderID = this.shaderID, c.vertexColors = this.vertexColors, c.skinning = this.skinning, c.morphTargets = this.morphTargets, c.morphNormals = this.morphNormals, c.sphere = this.sphere, c; + } + } + } + ), + /***/ + "./src/WebGL/materials/LineBasicMaterial.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/materials/LineBasicMaterial.ts ***! + \**************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + LineBasicMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../../colors */ + "./src/colors.ts" + ), f = t( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class _ extends f.Material { + constructor(h) { + super(), this.color = new s.Color(16777215), this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.vertexColors = !1, this.fog = !0, this.shaderID = "basic", this.setValues(h); + } + clone(h = new _()) { + return super.clone.call(this, h), h.color.copy(this.color), h; + } + } + } + ), + /***/ + "./src/WebGL/materials/Material.ts": ( + /*!*****************************************!*\ + !*** ./src/WebGL/materials/Material.ts ***! + \*****************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Material: () => ( + /* binding */ + h + ), + /* harmony export */ + MaterialIdCount: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ../constants/Sides */ + "./src/WebGL/constants/Sides.ts" + ), f = t( + /*! ../core */ + "./src/WebGL/core/index.ts" + ), _ = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), x = t( + /*! ../../colors */ + "./src/colors.ts" + ); + class h extends f.EventDispatcher { + constructor() { + super(...arguments), this.id = u++, this.name = "", this.side = s.FrontSide, this.opacity = 1, this.transparent = !1, this.depthTest = !0, this.depthWrite = !0, this.stencilTest = !0, this.polygonOffset = !1, this.polygonOffsetFactor = 0, this.polygonOffsetUnits = 0, this.alphaTest = 0, this.visible = !0, this.needsUpdate = !0, this.outline = !1; + } + setValues(c = {}) { + if (c !== void 0) + for (var C in c) { + var b = c[C]; + if (b === void 0) { + console.warn("$3Dmol.Material: '" + C + "' parameter is undefined."); + continue; + } + if (C in this) { + var A = this[C]; + A instanceof x.Color && b instanceof x.Color ? A.copy(b) : A instanceof x.Color ? A.set(b) : A instanceof _.Vector3 && b instanceof _.Vector3 ? A.copy(b) : this[C] = b; + } + } + } + //TODO: might want to look into blending equations + clone(c = new h()) { + return c.name = this.name, c.side = this.side, c.opacity = this.opacity, c.transparent = this.transparent, c.depthTest = this.depthTest, c.depthWrite = this.depthWrite, c.stencilTest = this.stencilTest, c.polygonOffset = this.polygonOffset, c.polygonOffsetFactor = this.polygonOffsetFactor, c.polygonOffsetUnits = this.polygonOffsetUnits, c.alphaTest = this.alphaTest, c.overdraw = this.overdraw, c.visible = this.visible, c; + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } + } + let u = 0; + } + ), + /***/ + "./src/WebGL/materials/MeshDoubleLambertMaterial.ts": ( + /*!**********************************************************!*\ + !*** ./src/WebGL/materials/MeshDoubleLambertMaterial.ts ***! + \**********************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + MeshDoubleLambertMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ./../constants/Sides */ + "./src/WebGL/constants/Sides.ts" + ), f = t( + /*! ./MeshLambertMaterial */ + "./src/WebGL/materials/MeshLambertMaterial.ts" + ); + class _ extends f.MeshLambertMaterial { + constructor(h) { + super(h), this.shaderID = "lambertdouble", this.side = s.DoubleSide, this.outline = !1; + } + clone(h = new _()) { + return super.clone.call(this, h), h; + } + } + } + ), + /***/ + "./src/WebGL/materials/MeshLambertMaterial.ts": ( + /*!****************************************************!*\ + !*** ./src/WebGL/materials/MeshLambertMaterial.ts ***! + \****************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + MeshLambertMaterial: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ./../constants/Coloring */ + "./src/WebGL/constants/Coloring.ts" + ), f = t( + /*! ./../constants/Shading */ + "./src/WebGL/constants/Shading.ts" + ), _ = t( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ), x = t( + /*! ../../colors */ + "./src/colors.ts" + ), h = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + class u extends _.Material { + constructor(c) { + super(), this.color = new x.Color(16777215), this.ambient = new x.Color(1048575), this.emissive = new x.Color(0), this.wrapAround = !1, this.wrapRGB = new h.Vector3(1, 1, 1), this.map = void 0, this.lightMap = null, this.specularMap = null, this.envMap = null, this.reflectivity = 1, this.refractionRatio = 0.98, this.fog = !0, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.shading = f.Shading.SmoothShading, this.shaderID = "lambert", this.vertexColors = s.Coloring.NoColors, this.skinning = !1, this.setValues(c); + } + clone(c = new u()) { + return super.clone.call(this, c), c.color.copy(this.color), c.ambient.copy(this.ambient), c.emissive.copy(this.emissive), c.wrapAround = this.wrapAround, c.wrapRGB.copy(this.wrapRGB), c.map = this.map, c.lightMap = this.lightMap, c.specularMap = this.specularMap, c.envMap = this.envMap, c.combine = this.combine, c.reflectivity = this.reflectivity, c.refractionRatio = this.refractionRatio, c.fog = this.fog, c.shading = this.shading, c.shaderID = this.shaderID, c.vertexColors = this.vertexColors, c.skinning = this.skinning, c.morphTargets = this.morphTargets, c.morphNormals = this.morphNormals, c; + } + } + } + ), + /***/ + "./src/WebGL/materials/MeshOutlineMaterial.ts": ( + /*!****************************************************!*\ + !*** ./src/WebGL/materials/MeshOutlineMaterial.ts ***! + \****************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + MeshOutlineMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../../colors */ + "./src/colors.ts" + ), f = t( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class _ extends f.Material { + constructor(h) { + super(), h = h || {}, this.fog = !0, this.shaderID = "outline", this.wireframe = !1, this.outlineColor = h.color || new s.Color(0, 0, 0), this.outlineWidth = h.width || 0.1, this.outlinePushback = h.pushback || 1; + } + clone(h = new _()) { + return super.clone.call(this, h), h.fog = this.fog, h.shaderID = this.shaderID, h.wireframe = this.wireframe, h; + } + } + } + ), + /***/ + "./src/WebGL/materials/SphereImposterMaterial.ts": ( + /*!*******************************************************!*\ + !*** ./src/WebGL/materials/SphereImposterMaterial.ts ***! + \*******************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + SphereImposterMaterial: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ); + class f extends s.ImposterMaterial { + constructor(x) { + super(x), this.shaderID = "sphereimposter", this.setValues(x); + } + clone(x = new f()) { + return super.clone.call(this, x), x; + } + } + } + ), + /***/ + "./src/WebGL/materials/SphereImposterOutlineMaterial.ts": ( + /*!**************************************************************!*\ + !*** ./src/WebGL/materials/SphereImposterOutlineMaterial.ts ***! + \**************************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + SphereImposterOutlineMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../../colors */ + "./src/colors.ts" + ), f = t( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ); + class _ extends f.ImposterMaterial { + constructor(h) { + super(h), h = h || {}, this.shaderID = "sphereimposteroutline", this.outlineColor = h.color || new s.Color(0, 0, 0), this.outlineWidth = h.width || 0.1, this.outlinePushback = h.pushback || 1, this.setValues(h); + } + clone(h = new _()) { + return super.clone.call(this, h), h.outlineColor = this.outlineColor, h.outlineWidth = this.outlineWidth, h.outlinePushback = this.outlinePushback, h; + } + } + } + ), + /***/ + "./src/WebGL/materials/SpriteMaterial.ts": ( + /*!***********************************************!*\ + !*** ./src/WebGL/materials/SpriteMaterial.ts ***! + \***********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + SpriteMaterial: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ../constants/SpriteAlignment */ + "./src/WebGL/constants/SpriteAlignment.ts" + ), f = t( + /*! ../core/Texture */ + "./src/WebGL/core/Texture.ts" + ), _ = t( + /*! ../../colors */ + "./src/colors.ts" + ), x = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), h = t( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class u extends h.Material { + constructor(c) { + super(), this.color = new _.Color(16777215), this.map = new f.Texture(), this.useScreenCoordinates = !0, this.fog = !1, this.uvOffset = new x.Vector2(0, 0), this.uvScale = new x.Vector2(1, 1), this.depthTest = !this.useScreenCoordinates, this.sizeAttenuation = !this.useScreenCoordinates, this.screenOffset = this.screenOffset, this.scaleByViewPort = !this.sizeAttenuation, this.alignment = s.SpriteAlignment.center.clone(), this.setValues(c), c = c || {}, c.depthTest === void 0 && (this.depthTest = !this.useScreenCoordinates), c.sizeAttenuation === void 0 && (this.sizeAttenuation = !this.useScreenCoordinates), c.scaleByViewPort === void 0 && (this.scaleByViewPort = !this.sizeAttenuation); + } + clone(c = new u()) { + return super.clone.call(this, c), c.color.copy(this.color), c.map = this.map, c.useScreenCoordinates = this.useScreenCoordinates, c.screenOffset = this.screenOffset, c.sizeAttenuation = this.sizeAttenuation, c.scaleByViewport = this.scaleByViewPort, c.alignment.copy(this.alignment), c.uvOffset.copy(this.uvOffset), c; + } + } + } + ), + /***/ + "./src/WebGL/materials/StickImposterMaterial.ts": ( + /*!******************************************************!*\ + !*** ./src/WebGL/materials/StickImposterMaterial.ts ***! + \******************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + StickImposterMaterial: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ); + class f extends s.ImposterMaterial { + constructor(x) { + super(x), this.shaderID = "stickimposter", this.setValues(x); + } + clone(x = new f()) { + return super.clone.call(this, x), x; + } + } + } + ), + /***/ + "./src/WebGL/materials/StickImposterOutlineMaterial.ts": ( + /*!*************************************************************!*\ + !*** ./src/WebGL/materials/StickImposterOutlineMaterial.ts ***! + \*************************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + StickImposterOutlineMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../../colors */ + "./src/colors.ts" + ), f = t( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ); + class _ extends f.ImposterMaterial { + constructor(h = {}) { + super(h), this.shaderID = "stickimposteroutline", this.outlineColor = new s.Color(0, 0, 0), this.outlineWidth = 0.1, this.outlinePushback = 1, h.color && (this.outlineColor = h.color), h.width && (this.outlineWidth = h.width), h.pushback && (this.outlinePushback = h.pushback), this.setValues(h); + } + clone(h = new _()) { + return super.clone.call(this, h), h.outlineColor = this.outlineColor, h.outlineWidth = this.outlineWidth, h.outlinePushback = this.outlinePushback, h; + } + } + } + ), + /***/ + "./src/WebGL/materials/VolumetricMaterial.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/materials/VolumetricMaterial.ts ***! + \***************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + VolumetricMaterial: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ../constants/Sides */ + "./src/WebGL/constants/Sides.ts" + ), f = t( + /*! ../../colors */ + "./src/colors.ts" + ), _ = t( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class x extends _.Material { + constructor(u) { + super(), this.transparent = !1, this.volumetric = !0, this.color = new f.Color(16777215), this.transferfn = null, this.map = void 0, this.extent = [], this.maxdepth = 100, this.unit = 0, this.texmatrix = null, this.transfermin = -1, this.transfermax = 1, this.subsamples = 5, this.shaderID = "volumetric", this.side = s.FrontSide, this.setValues(u); + } + clone(u = new x()) { + return super.clone.call(this, u), u.transparent = this.transparent, u.volumetric = this.volumetric, u.color = this.color, u.transferfn = this.transferfn, u.map = this.map, u.extent = this.extent, u.maxdepth = this.maxdepth, u.unit = this.unit, u.texmatrix = this.texmatrix, u.transfermin = this.transfermin, u.transfermax = this.transfermax, u.subsamples = this.subsamples, u.shaderID = this.shaderID, u.side = this.side, u; + } + } + } + ), + /***/ + "./src/WebGL/materials/index.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/materials/index.ts ***! + \**************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + ImposterMaterial: () => ( + /* reexport safe */ + s.ImposterMaterial + ), + /* harmony export */ + InstancedMaterial: () => ( + /* reexport safe */ + f.InstancedMaterial + ), + /* harmony export */ + LineBasicMaterial: () => ( + /* reexport safe */ + _.LineBasicMaterial + ), + /* harmony export */ + Material: () => ( + /* reexport safe */ + x.Material + ), + /* harmony export */ + MaterialIdCount: () => ( + /* reexport safe */ + x.MaterialIdCount + ), + /* harmony export */ + MeshDoubleLambertMaterial: () => ( + /* reexport safe */ + h.MeshDoubleLambertMaterial + ), + /* harmony export */ + MeshLambertMaterial: () => ( + /* reexport safe */ + u.MeshLambertMaterial + ), + /* harmony export */ + MeshOutlineMaterial: () => ( + /* reexport safe */ + E.MeshOutlineMaterial + ), + /* harmony export */ + SphereImposterMaterial: () => ( + /* reexport safe */ + c.SphereImposterMaterial + ), + /* harmony export */ + SphereImposterOutlineMaterial: () => ( + /* reexport safe */ + C.SphereImposterOutlineMaterial + ), + /* harmony export */ + SpriteMaterial: () => ( + /* reexport safe */ + b.SpriteMaterial + ), + /* harmony export */ + StickImposterMaterial: () => ( + /* reexport safe */ + A.StickImposterMaterial + ), + /* harmony export */ + StickImposterOutlineMaterial: () => ( + /* reexport safe */ + S.StickImposterOutlineMaterial + ), + /* harmony export */ + VolumetricMaterial: () => ( + /* reexport safe */ + n.VolumetricMaterial + ) + /* harmony export */ + }); + var s = t( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ), f = t( + /*! ./InstancedMaterial */ + "./src/WebGL/materials/InstancedMaterial.ts" + ), _ = t( + /*! ./LineBasicMaterial */ + "./src/WebGL/materials/LineBasicMaterial.ts" + ), x = t( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ), h = t( + /*! ./MeshDoubleLambertMaterial */ + "./src/WebGL/materials/MeshDoubleLambertMaterial.ts" + ), u = t( + /*! ./MeshLambertMaterial */ + "./src/WebGL/materials/MeshLambertMaterial.ts" + ), E = t( + /*! ./MeshOutlineMaterial */ + "./src/WebGL/materials/MeshOutlineMaterial.ts" + ), c = t( + /*! ./SphereImposterMaterial */ + "./src/WebGL/materials/SphereImposterMaterial.ts" + ), C = t( + /*! ./SphereImposterOutlineMaterial */ + "./src/WebGL/materials/SphereImposterOutlineMaterial.ts" + ), b = t( + /*! ./SpriteMaterial */ + "./src/WebGL/materials/SpriteMaterial.ts" + ), A = t( + /*! ./StickImposterMaterial */ + "./src/WebGL/materials/StickImposterMaterial.ts" + ), S = t( + /*! ./StickImposterOutlineMaterial */ + "./src/WebGL/materials/StickImposterOutlineMaterial.ts" + ), n = t( + /*! ./VolumetricMaterial */ + "./src/WebGL/materials/VolumetricMaterial.ts" + ); + } + ), + /***/ + "./src/WebGL/math/Quaternion.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/math/Quaternion.ts ***! + \**************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Quaternion: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + class s { + constructor(_, x, h, u) { + this.x = _ || 0, this.y = x || 0, this.z = h || 0, this.w = u !== void 0 ? u : 1; + } + set(_, x, h, u) { + return this.x = _, this.y = x, this.z = h, this.w = u, this; + } + copy(_) { + return this.x = _.x, this.y = _.y, this.z = _.z, this.w = _.w, this; + } + conjugate() { + return this.x *= -1, this.y *= -1, this.z *= -1, this; + } + inverse() { + return this.conjugate().normalize(); + } + length() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); + } + lengthxyz() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + } + normalize() { + let _ = this.length(); + return _ === 0 ? (this.x = 0, this.y = 0, this.z = 0, this.w = 1) : (_ = 1 / _, this.x *= _, this.y *= _, this.z *= _, this.w *= _), this; + } + multiply(_) { + return this.multiplyQuaternions(this, _); + } + multiplyScalar(_) { + return this.x *= _, this.y *= _, this.z *= _, this.w *= _, this; + } + multiplyQuaternions(_, x) { + const h = _.x, u = _.y, E = _.z, c = _.w, C = x.x, b = x.y, A = x.z, S = x.w; + return this.x = h * S + c * C + u * A - E * b, this.y = u * S + c * b + E * C - h * A, this.z = E * S + c * A + h * b - u * C, this.w = c * S - h * C - u * b - E * A, this; + } + sub(_) { + return this.x -= _.x, this.y -= _.y, this.z -= _.z, this.w -= _.w, this; + } + clone() { + return new s(this.x, this.y, this.z, this.w); + } + setFromEuler(_) { + const x = Math.cos(_.x / 2), h = Math.cos(_.y / 2), u = Math.cos(_.z / 2), E = Math.sin(_.x / 2), c = Math.sin(_.y / 2), C = Math.sin(_.z / 2); + return this.x = E * h * u + x * c * C, this.y = x * c * u - E * h * C, this.z = x * h * C + E * c * u, this.w = x * h * u - E * c * C, this; + } + } + } + ), + /***/ + "./src/WebGL/math/Vector2.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/math/Vector2.ts ***! + \***********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Vector2: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + class s { + constructor(_, x) { + this.x = _ || 0, this.y = x || 0; + } + set(_, x) { + return this.x = _, this.y = x, this; + } + subVectors(_, x) { + return this.x = _.x - x.x, this.y = _.y - x.y, this; + } + copy(_) { + return this.x = _.x, this.y = _.y, this; + } + clone() { + return new s(this.x, this.y); + } + } + } + ), + /***/ + "./src/WebGL/math/index.ts": ( + /*!*********************************!*\ + !*** ./src/WebGL/math/index.ts ***! + \*********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Matrix3: () => ( + /* reexport safe */ + u.Matrix3 + ), + /* harmony export */ + Matrix4: () => ( + /* reexport safe */ + u.Matrix4 + ), + /* harmony export */ + Quaternion: () => ( + /* reexport safe */ + s.Quaternion + ), + /* harmony export */ + Ray: () => ( + /* reexport safe */ + u.Ray + ), + /* harmony export */ + Vector2: () => ( + /* reexport safe */ + f.Vector2 + ), + /* harmony export */ + Vector3: () => ( + /* reexport safe */ + u.Vector3 + ), + /* harmony export */ + clamp: () => ( + /* reexport safe */ + _.clamp + ), + /* harmony export */ + conversionMatrix3: () => ( + /* reexport safe */ + x.conversionMatrix3 + ), + /* harmony export */ + degToRad: () => ( + /* reexport safe */ + h.degToRad + ) + /* harmony export */ + }); + var s = t( + /*! ./Quaternion */ + "./src/WebGL/math/Quaternion.ts" + ), f = t( + /*! ./Vector2 */ + "./src/WebGL/math/Vector2.ts" + ), _ = t( + /*! ./utils/clamp */ + "./src/WebGL/math/utils/clamp.ts" + ), x = t( + /*! ./utils/conversionMatrix3 */ + "./src/WebGL/math/utils/conversionMatrix3.ts" + ), h = t( + /*! ./utils/degToRad */ + "./src/WebGL/math/utils/degToRad.ts" + ), u = t( + /*! ./math */ + "./src/WebGL/math/math.ts" + ); + } + ), + /***/ + "./src/WebGL/math/math.ts": ( + /*!********************************!*\ + !*** ./src/WebGL/math/math.ts ***! + \********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Matrix3: () => ( + /* binding */ + b + ), + /* harmony export */ + Matrix4: () => ( + /* binding */ + c + ), + /* harmony export */ + Ray: () => ( + /* binding */ + A + ), + /* harmony export */ + Vector3: () => ( + /* binding */ + C + ) + /* harmony export */ + }); + var s = t( + /*! ./utils/degToRad */ + "./src/WebGL/math/utils/degToRad.ts" + ), f = t( + /*! ./utils/clamp */ + "./src/WebGL/math/utils/clamp.ts" + ), _, x, h, u, E; + class c { + constructor(n = 1, o = 0, w = 0, p = 0, v = 0, a = 1, l = 0, g = 0, M = 0, L = 0, T = 1, D = 0, R = 0, B = 0, P = 0, z = 1) { + typeof n < "u" && typeof n != "number" ? this.elements = new Float32Array(n) : (this.elements = new Float32Array(16), this.elements[0] = n, this.elements[4] = o, this.elements[8] = w, this.elements[12] = p, this.elements[1] = v, this.elements[5] = a, this.elements[9] = l, this.elements[13] = g, this.elements[2] = M, this.elements[6] = L, this.elements[10] = T, this.elements[14] = D, this.elements[3] = R, this.elements[7] = B, this.elements[11] = P, this.elements[15] = z); + } + // eslint-disable-next-line no-unused-vars, class-methods-use-this + makeScale(n, o, w) { + throw new Error("Method not implemented."); + } + set(n, o, w, p, v, a, l, g, M, L, T, D, R, B, P, z) { + const F = this.elements; + return F[0] = n, F[4] = o, F[8] = w, F[12] = p, F[1] = v, F[5] = a, F[9] = l, F[13] = g, F[2] = M, F[6] = L, F[10] = T, F[14] = D, F[3] = R, F[7] = B, F[11] = P, F[15] = z, this; + } + identity() { + return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; + } + copy(n) { + const o = n.elements; + return this.set(o[0], o[4], o[8], o[12], o[1], o[5], o[9], o[13], o[2], o[6], o[10], o[14], o[3], o[7], o[11], o[15]), this; + } + matrix3FromTopLeft() { + const n = this.elements; + return new b(n[0], n[4], n[8], n[1], n[5], n[9], n[2], n[6], n[10]); + } + setRotationFromEuler(n, o) { + const w = this.elements, { x: p, y: v, z: a } = n, l = Math.cos(p), g = Math.sin(p), M = Math.cos(v), L = Math.sin(v), T = Math.cos(a), D = Math.sin(a); + if (o === void 0 || o === "XYZ") { + const R = l * T, B = l * D, P = g * T, z = g * D; + w[0] = M * T, w[4] = -M * D, w[8] = L, w[1] = B + P * L, w[5] = R - z * L, w[9] = -g * M, w[2] = z - R * L, w[6] = P + B * L, w[10] = l * M; + } else + console.error(`Error with matrix4 setRotationFromEuler. Order: ${o}`); + return this; + } + setRotationFromQuaternion(n) { + const o = this.elements, { x: w, y: p, z: v, w: a } = n, l = w + w, g = p + p, M = v + v, L = w * l, T = w * g, D = w * M, R = p * g, B = p * M, P = v * M, z = a * l, F = a * g, N = a * M; + return o[0] = 1 - (R + P), o[4] = T - N, o[8] = D + F, o[1] = T + N, o[5] = 1 - (L + P), o[9] = B - z, o[2] = D - F, o[6] = B + z, o[10] = 1 - (L + R), this; + } + multiplyMatrices(n, o) { + const w = n.elements, p = o.elements, v = this.elements, a = w[0], l = w[4], g = w[8], M = w[12], L = w[1], T = w[5], D = w[9], R = w[13], B = w[2], P = w[6], z = w[10], F = w[14], N = w[3], $ = w[7], k = w[11], G = w[15], H = p[0], U = p[4], V = p[8], Q = p[12], oe = p[1], ee = p[5], ne = p[9], me = p[13], se = p[2], fe = p[6], Ce = p[10], Me = p[14], Te = p[3], ae = p[7], pe = p[11], we = p[15]; + return v[0] = a * H + l * oe + g * se + M * Te, v[4] = a * U + l * ee + g * fe + M * ae, v[8] = a * V + l * ne + g * Ce + M * pe, v[12] = a * Q + l * me + g * Me + M * we, v[1] = L * H + T * oe + D * se + R * Te, v[5] = L * U + T * ee + D * fe + R * ae, v[9] = L * V + T * ne + D * Ce + R * pe, v[13] = L * Q + T * me + D * Me + R * we, v[2] = B * H + P * oe + z * se + F * Te, v[6] = B * U + P * ee + z * fe + F * ae, v[10] = B * V + P * ne + z * Ce + F * pe, v[14] = B * Q + P * me + z * Me + F * we, v[3] = N * H + $ * oe + k * se + G * Te, v[7] = N * U + $ * ee + k * fe + G * ae, v[11] = N * V + $ * ne + k * Ce + G * pe, v[15] = N * Q + $ * me + k * Me + G * we, this; + } + multiplyScalar(n) { + const o = this.elements; + return o[0] *= n, o[4] *= n, o[8] *= n, o[12] *= n, o[1] *= n, o[5] *= n, o[9] *= n, o[13] *= n, o[2] *= n, o[6] *= n, o[10] *= n, o[14] *= n, o[3] *= n, o[7] *= n, o[11] *= n, o[15] *= n, this; + } + makeTranslation(n, o, w) { + return this.set(1, 0, 0, n, 0, 1, 0, o, 0, 0, 1, w, 0, 0, 0, 1), this; + } + // snap values close to integers to their integer value + // useful and identifying identity matrices + snap(n) { + const o = Math.pow(10, 4), w = this.elements; + for (let p = 0; p < 16; p++) { + const v = Math.round(w[p]); + v === Math.round(w[p] * o) / o && (w[p] = v); + } + return this; + } + transpose() { + const n = this.elements; + let o; + return o = n[1], n[1] = n[4], n[4] = o, o = n[2], n[2] = n[8], n[8] = o, o = n[6], n[6] = n[9], n[9] = o, o = n[3], n[3] = n[12], n[12] = o, o = n[7], n[7] = n[13], n[13] = o, o = n[11], n[11] = n[14], n[14] = o, this; + } + setPosition(n) { + const o = this.elements; + return o[12] = n.x, o[13] = n.y, o[14] = n.z, this; + } + translate(n) { + const o = this.elements; + return o[12] += n.x, o[13] += n.y, o[14] += n.z, this; + } + getInverse(n, o) { + const w = this.elements, p = n.elements, v = p[0], a = p[4], l = p[8], g = p[12], M = p[1], L = p[5], T = p[9], D = p[13], R = p[2], B = p[6], P = p[10], z = p[14], F = p[3], N = p[7], $ = p[11], k = p[15]; + w[0] = T * z * N - D * P * N + D * B * $ - L * z * $ - T * B * k + L * P * k, w[4] = g * P * N - l * z * N - g * B * $ + a * z * $ + l * B * k - a * P * k, w[8] = l * D * N - g * T * N + g * L * $ - a * D * $ - l * L * k + a * T * k, w[12] = g * T * B - l * D * B - g * L * P + a * D * P + l * L * z - a * T * z, w[1] = D * P * F - T * z * F - D * R * $ + M * z * $ + T * R * k - M * P * k, w[5] = l * z * F - g * P * F + g * R * $ - v * z * $ - l * R * k + v * P * k, w[9] = g * T * F - l * D * F - g * M * $ + v * D * $ + l * M * k - v * T * k, w[13] = l * D * R - g * T * R + g * M * P - v * D * P - l * M * z + v * T * z, w[2] = L * z * F - D * B * F + D * R * N - M * z * N - L * R * k + M * B * k, w[6] = g * B * F - a * z * F - g * R * N + v * z * N + a * R * k - v * B * k, w[10] = a * D * F - g * L * F + g * M * N - v * D * N - a * M * k + v * L * k, w[14] = g * L * R - a * D * R - g * M * B + v * D * B + a * M * z - v * L * z, w[3] = T * B * F - L * P * F - T * R * N + M * P * N + L * R * $ - M * B * $, w[7] = a * P * F - l * B * F + l * R * N - v * P * N - a * R * $ + v * B * $, w[11] = l * L * F - a * T * F - l * M * N + v * T * N + a * M * $ - v * L * $, w[15] = a * T * R - l * L * R + l * M * B - v * T * B - a * M * P + v * L * P; + const G = v * w[0] + M * w[4] + R * w[8] + F * w[12]; + if (G === 0) { + const H = "Matrix4.getInverse(): can't invert matrix, determinant is 0"; + if (o) + throw new Error(H); + return console.warn(H), this.identity(), this; + } + return this.multiplyScalar(1 / G), this; + } + isReflected() { + const n = this.elements, o = n[0], w = n[4], p = n[8], v = n[1], a = n[5], l = n[9], g = n[2], M = n[6], L = n[10]; + return o * a * L + // +aei + v * M * p + // +bfg + g * w * l - // +cdh + g * a * p - // -ceg + v * w * L - // -bdi + o * M * l < 0; + } + scale(n) { + const o = this.elements, { x: w } = n, { y: p } = n, { z: v } = n; + return o[0] *= w, o[4] *= p, o[8] *= v, o[1] *= w, o[5] *= p, o[9] *= v, o[2] *= w, o[6] *= p, o[10] *= v, o[3] *= w, o[7] *= p, o[11] *= v, this; + } + getMaxScaleOnAxis() { + const n = this.elements, o = n[0] * n[0] + n[1] * n[1] + n[2] * n[2], w = n[4] * n[4] + n[5] * n[5] + n[6] * n[6], p = n[8] * n[8] + n[9] * n[9] + n[10] * n[10]; + return Math.sqrt(Math.max(o, Math.max(w, p))); + } + makeFrustum(n, o, w, p, v, a) { + const l = this.elements, g = 2 * v / (o - n), M = 2 * v / (p - w), L = (o + n) / (o - n), T = (p + w) / (p - w), D = -(a + v) / (a - v), R = -2 * a * v / (a - v); + return l[0] = g, l[4] = 0, l[8] = L, l[12] = 0, l[1] = 0, l[5] = M, l[9] = T, l[13] = 0, l[2] = 0, l[6] = 0, l[10] = D, l[14] = R, l[3] = 0, l[7] = 0, l[11] = -1, l[15] = 0, this; + } + makePerspective(n, o, w, p) { + const v = w * Math.tan((0, s.degToRad)(n * 0.5)), a = -v, l = a * o, g = v * o; + return this.makeFrustum(l, g, a, v, w, p); + } + makeOrthographic(n, o, w, p, v, a) { + const l = this.elements, g = 1 / (o - n), M = 1 / (w - p), L = 1 / (a - v), T = (o + n) * g, D = (w + p) * M, R = (a + v) * L; + return l[0] = 2 * g, l[4] = 0, l[8] = 0, l[12] = -T, l[1] = 0, l[5] = 2 * M, l[9] = 0, l[13] = -D, l[2] = 0, l[6] = 0, l[10] = -2 * L, l[14] = -R, l[3] = 0, l[7] = 0, l[11] = 0, l[15] = 1, this; + } + isEqual(n) { + const o = n.elements, w = this.elements; + return w[0] === o[0] && w[4] === o[4] && w[8] === o[8] && w[12] === o[12] && w[1] === o[1] && w[5] === o[5] && w[9] === o[9] && w[13] === o[13] && w[2] === o[2] && w[6] === o[6] && w[10] === o[10] && w[14] === o[14] && w[3] === o[3] && w[7] === o[7] && w[11] === o[11] && w[15] === o[15]; + } + clone() { + const n = this.elements; + return new c(n[0], n[4], n[8], n[12], n[1], n[5], n[9], n[13], n[2], n[6], n[10], n[14], n[3], n[7], n[11], n[15]); + } + isIdentity() { + const n = this.elements; + return n[0] === 1 && n[4] === 0 && n[8] === 0 && n[12] === 0 && n[1] === 0 && n[5] === 1 && n[9] === 0 && n[13] === 0 && n[2] === 0 && n[6] === 0 && n[10] === 1 && n[14] === 0 && n[3] === 0 && n[7] === 0 && n[11] === 0 && n[15] === 1; + } + // return true if elements are with digits of identity + isNearlyIdentity(n) { + return this.clone().snap(n).isIdentity(); + } + getScale(n) { + const o = this.elements; + return n = n || new C(), h.set(o[0], o[1], o[2]), u.set(o[4], o[5], o[6]), E.set(o[8], o[9], o[10]), n.x = h.length(), n.y = u.length(), n.z = E.length(), n; + } + lookAt(n, o, w) { + const p = this.elements; + return E.subVectors(n, o).normalize(), E.length() === 0 && (E.z = 1), h.crossVectors(w, E).normalize(), h.length() === 0 && (E.x += 1e-4, h.crossVectors(w, E).normalize()), u.crossVectors(E, h), p[0] = h.x, p[4] = u.x, p[8] = E.x, p[1] = h.y, p[5] = u.y, p[9] = E.y, p[2] = h.z, p[6] = u.z, p[10] = E.z, this; + } + compose(n, o, w) { + const p = this.elements; + return _.identity(), _.setRotationFromQuaternion(o), x.makeScale(w.x, w.y, w.z), this.multiplyMatrices(_, x), p[12] = n.x, p[13] = n.y, p[14] = n.z, this; + } + } + _ = new c(), x = new c(); + class C { + constructor(n, o, w) { + this.x = n || 0, this.y = o || 0, this.z = w || 0, this.atomid = void 0; + } + set(n, o, w) { + return this.x = n, this.y = o, this.z = w, this; + } + copy(n) { + return this.x = n.x, this.y = n.y, this.z = n.z, this; + } + add(n) { + return this.x += n.x, this.y += n.y, this.z += n.z, this; + } + addVectors(n, o) { + return this.x = n.x + o.x, this.y = n.y + o.y, this.z = n.z + o.z, this; + } + multiplyVectors(n, o) { + return this.x = n.x * o.x, this.y = n.y * o.y, this.z = n.z * o.z, this; + } + sub(n) { + return this.x -= n.x, this.y -= n.y, this.z -= n.z, this; + } + subVectors(n, o) { + return this.x = n.x - o.x, this.y = n.y - o.y, this.z = n.z - o.z, this; + } + multiplyScalar(n) { + return this.x *= n, this.y *= n, this.z *= n, this; + } + divideScalar(n) { + return n !== 0 ? (this.x /= n, this.y /= n, this.z /= n) : (this.x = 0, this.y = 0, this.z = 0), this; + } + // accumulate maximum + max(n) { + return this.x = Math.max(this.x, n.x), this.y = Math.max(this.y, n.y), this.z = Math.max(this.z, n.z), this; + } + // accumulate min + min(n) { + return this.x = Math.min(this.x, n.x), this.y = Math.min(this.y, n.y), this.z = Math.min(this.z, n.z), this; + } + distanceTo(n) { + return Math.sqrt(this.distanceToSquared(n)); + } + distanceToSquared(n) { + const o = this.x - n.x, w = this.y - n.y, p = this.z - n.z; + return o * o + w * w + p * p; + } + applyMatrix3(n) { + const { x: o } = this, { y: w } = this, { z: p } = this, v = n.elements; + return this.x = v[0] * o + v[3] * w + v[6] * p, this.y = v[1] * o + v[4] * w + v[7] * p, this.z = v[2] * o + v[5] * w + v[8] * p, this; + } + applyMatrix4(n) { + const { x: o } = this, { y: w } = this, { z: p } = this, v = n.elements; + return this.x = v[0] * o + v[4] * w + v[8] * p + v[12], this.y = v[1] * o + v[5] * w + v[9] * p + v[13], this.z = v[2] * o + v[6] * w + v[10] * p + v[14], this; + } + applyProjection(n) { + const { x: o } = this, { y: w } = this, { z: p } = this, v = n.elements, a = v[3] * o + v[7] * w + v[11] * p + v[15]; + return this.x = (v[0] * o + v[4] * w + v[8] * p + v[12]) / a, this.y = (v[1] * o + v[5] * w + v[9] * p + v[13]) / a, this.z = (v[2] * o + v[6] * w + v[10] * p + v[14]) / a, this; + } + applyQuaternion(n) { + const { x: o } = this, { y: w } = this, { z: p } = this, v = n.x, a = n.y, l = n.z, g = n.w, M = {}; + M.x = 2 * (w * l - p * a), M.y = 2 * (p * v - o * l), M.z = 2 * (o * a - w * v); + const L = {}; + return L.x = M.y * l - M.z * a, L.y = M.z * v - M.x * l, L.z = M.x * a - M.y * v, this.x = o + g * M.x + L.x, this.y = w + g * M.y + L.y, this.z = p + g * M.z + L.z, this; + } + negate() { + return this.multiplyScalar(-1); + } + dot(n) { + return this.x * n.x + this.y * n.y + this.z * n.z; + } + length() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + } + lengthSq() { + return this.x * this.x + this.y * this.y + this.z * this.z; + } + normalize() { + return this.divideScalar(this.length()); + } + cross(n) { + const { x: o } = this, { y: w } = this, { z: p } = this; + return this.x = w * n.z - p * n.y, this.y = p * n.x - o * n.z, this.z = o * n.y - w * n.x, this; + } + crossVectors(n, o) { + return this.x = n.y * o.z - n.z * o.y, this.y = n.z * o.x - n.x * o.z, this.z = n.x * o.y - n.y * o.x, this; + } + equals(n) { + return this.x == n.x && this.y == n.y && this.z == n.z; + } + getPositionFromMatrix(n) { + return this.x = n.elements[12], this.y = n.elements[13], this.z = n.elements[14], this; + } + setEulerFromRotationMatrix(n, o) { + const w = n.elements, p = w[0], v = w[4], a = w[8], l = w[5], g = w[9], M = w[6], L = w[10]; + return o === void 0 || o === "XYZ" ? (this.y = Math.asin((0, f.clamp)(a, -1, 1)), Math.abs(a) < 0.99999 ? (this.x = Math.atan2(-g, L), this.z = Math.atan2(-v, p)) : (this.x = Math.atan2(M, l), this.z = 0)) : console.error(`Error with vector's setEulerFromRotationMatrix: Unknown order: ${o}`), this; + } + rotateAboutVector(n, o) { + n.normalize(); + const w = Math.cos(o), p = Math.sin(o), v = this.clone().multiplyScalar(w), a = n.clone().cross(this).multiplyScalar(p), l = n.clone().multiplyScalar(n.clone().dot(this)).multiplyScalar(1 - w), g = v.add(a).add(l); + return this.x = g.x, this.y = g.y, this.z = g.z, this; + } + setFromMatrixPosition(n) { + const o = n.elements; + return this.x = o[12], this.y = o[13], this.z = o[14], this; + } + // unproject is defined after Matrix4 + transformDirection(n) { + const { x: o } = this, { y: w } = this, { z: p } = this, v = n.elements; + return this.x = v[0] * o + v[4] * w + v[8] * p, this.y = v[1] * o + v[5] * w + v[9] * p, this.z = v[2] * o + v[6] * w + v[10] * p, this.normalize(); + } + clone() { + return new C(this.x, this.y, this.z); + } + unproject(n) { + const o = _; + return o.multiplyMatrices(n.matrixWorld, o.getInverse(n.projectionMatrix)), this.applyMatrix4(o); + } + } + h = new C(), u = new C(), E = new C(); + class b { + constructor(n = 1, o = 0, w = 0, p = 0, v = 1, a = 0, l = 0, g = 0, M = 1) { + this.elements = new Float32Array(9), this.set(n, o, w, p, v, a, l, g, M); + } + set(n, o, w, p, v, a, l, g, M) { + const L = this.elements; + return L[0] = n, L[3] = o, L[6] = w, L[1] = p, L[4] = v, L[7] = a, L[2] = l, L[5] = g, L[8] = M, this; + } + identity() { + return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this; + } + copy(n) { + const o = n.elements; + this.set(o[0], o[3], o[6], o[1], o[4], o[7], o[2], o[5], o[8]); + } + multiplyScalar(n) { + const o = this.elements; + return o[0] *= n, o[3] *= n, o[6] *= n, o[1] *= n, o[4] *= n, o[7] *= n, o[2] *= n, o[5] *= n, o[8] *= n, this; + } + getInverse3(n) { + const o = n.elements, w = this.elements; + w[0] = o[4] * o[8] - o[5] * o[7], w[3] = o[6] * o[5] - o[3] * o[8], w[6] = o[3] * o[7] - o[6] * o[4], w[1] = o[7] * o[2] - o[1] * o[8], w[4] = o[0] * o[8] - o[6] * o[2], w[7] = o[1] * o[6] - o[0] * o[7], w[2] = o[1] * o[5] - o[2] * o[4], w[5] = o[2] * o[3] - o[0] * o[5], w[8] = o[0] * o[4] - o[1] * o[3]; + const p = o[0] * w[0] + o[3] * w[1] + o[6] * w[2]; + return this.multiplyScalar(1 / p), this; + } + getInverse(n, o) { + const w = n.elements, p = this.elements; + p[0] = w[10] * w[5] - w[6] * w[9], p[1] = -w[10] * w[1] + w[2] * w[9], p[2] = w[6] * w[1] - w[2] * w[5], p[3] = -w[10] * w[4] + w[6] * w[8], p[4] = w[10] * w[0] - w[2] * w[8], p[5] = -w[6] * w[0] + w[2] * w[4], p[6] = w[9] * w[4] - w[5] * w[8], p[7] = -w[9] * w[0] + w[1] * w[8], p[8] = w[5] * w[0] - w[1] * w[4]; + const v = w[0] * p[0] + w[1] * p[3] + w[2] * p[6]; + if (v === 0) { + const a = "Matrix3.getInverse(): can't invert matrix, determinant is 0"; + if (o) + throw new Error(a); + return console.warn(a), this.identity(), this; + } + return this.multiplyScalar(1 / v), this; + } + // https://en.wikipedia.org/wiki/Determinant + getDeterminant() { + const n = this.elements; + return n[0] * n[4] * n[8] + // +aei + n[1] * n[5] * n[6] + // +bfg + n[2] * n[3] * n[7] - // +cdh + n[2] * n[4] * n[6] - // -ceg + n[1] * n[3] * n[8] - // -bdi + n[0] * n[5] * n[7]; + } + transpose() { + let n; + const o = this.elements; + return n = o[1], o[1] = o[3], o[3] = n, n = o[2], o[2] = o[6], o[6] = n, n = o[5], o[5] = o[7], o[7] = n, this; + } + clone() { + const n = this.elements; + return new b(n[0], n[3], n[6], n[1], n[4], n[7], n[2], n[5], n[8]); + } + getMatrix4() { + const n = this.elements; + return new c(n[0], n[3], n[6], 0, n[1], n[4], n[7], 0, n[2], n[5], n[8], 0); + } + } + class A { + constructor(n, o) { + this.origin = n !== void 0 ? n : new C(), this.direction = o !== void 0 ? o : new C(); + } + set(n, o) { + return this.origin.copy(n), this.direction.copy(o), this; + } + copy(n) { + return this.origin.copy(n.origin), this.direction.copy(n.direction), this; + } + at(n, o) { + return (o || new C()).copy(this.direction).multiplyScalar(n).add(this.origin); + } + recast(n) { + const o = h; + return this.origin.copy(this.at(n, o)), this; + } + closestPointToPoint(n, o) { + const w = o || new C(); + w.subVectors(n, this.origin); + const p = w.dot(this.direction); + return w.copy(this.direction).multiplyScalar(p).add(this.origin); + } + distanceToPoint(n) { + const o = h, w = o.subVectors(n, this.origin).dot(this.direction); + return o.copy(this.direction).multiplyScalar(w).add(this.origin), o.distanceTo(n); + } + // eslint-disable-next-line class-methods-use-this + isIntersectionCylinder() { + } + isIntersectionSphere(n) { + return this.distanceToPoint(n.center) <= n.radius; + } + isIntersectionPlane(n) { + return n.normal.dot(this.direction) !== 0 || n.distanceToPoint(this.origin) === 0; + } + distanceToPlane(n) { + const o = n.normal.dot(this.direction); + return o === 0 ? n.distanceToPoint(this.origin) === 0 ? 0 : void 0 : -(this.origin.dot(n.normal) + n.constant) / o; + } + intersectPlane(n, o) { + const w = this.distanceToPlane(n); + if (w !== void 0) + return this.at(w, o); + } + applyMatrix4(n) { + return this.direction.add(this.origin).applyMatrix4(n), this.origin.applyMatrix4(n), this.direction.sub(this.origin), this; + } + clone() { + return new A().copy(this); + } + } + } + ), + /***/ + "./src/WebGL/math/utils/clamp.ts": ( + /*!***************************************!*\ + !*** ./src/WebGL/math/utils/clamp.ts ***! + \***************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + clamp: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + function s(f, _, x) { + return Math.min(Math.max(f, _), x); + } + } + ), + /***/ + "./src/WebGL/math/utils/conversionMatrix3.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/math/utils/conversionMatrix3.ts ***! + \***************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + conversionMatrix3: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../math */ + "./src/WebGL/math/math.ts" + ); + function f(_, x, h, u, E, c) { + u = u * Math.PI / 180, E = E * Math.PI / 180, c = c * Math.PI / 180; + const C = (w) => w * w, b = Math.cos(u), A = Math.cos(E), S = Math.cos(c), n = Math.sin(c); + return new s.Matrix3(_, x * S, h * A, 0, x * n, h * (b - A * S) / n, 0, 0, h * Math.sqrt(1 - C(b) - C(A) - C(S) + 2 * b * A * S) / n); + } + } + ), + /***/ + "./src/WebGL/math/utils/degToRad.ts": ( + /*!******************************************!*\ + !*** ./src/WebGL/math/utils/degToRad.ts ***! + \******************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + degToRad: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + const s = Math.PI / 180; + function f(_) { + return _ * s; + } + } + ), + /***/ + "./src/WebGL/objects/Line.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/objects/Line.ts ***! + \***********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Line: () => ( + /* binding */ + x + ), + /* harmony export */ + LineStyle: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../materials */ + "./src/WebGL/materials/index.ts" + ), f = t( + /*! ../core */ + "./src/WebGL/core/index.ts" + ), _; + (function(h) { + h[h.LineStrip = 0] = "LineStrip", h[h.LinePieces = 1] = "LinePieces"; + })(_ || (_ = {})); + class x extends f.Object3D { + constructor(u, E = new s.LineBasicMaterial({ + color: Math.random() * 16777215 + }), c = _.LineStrip) { + super(), this.geometry = u, this.material = E, this.type = c; + } + clone(u = new x(this.geometry, this.material, this.type)) { + return super.clone.call(this, u), u; + } + } + } + ), + /***/ + "./src/WebGL/objects/Mesh.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/objects/Mesh.ts ***! + \***********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Mesh: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../core */ + "./src/WebGL/core/index.ts" + ); + class f extends s.Object3D { + constructor(x, h) { + super(), this.geometry = x, this.material = h; + } + clone(x) { + return x === void 0 && (x = new f(this.geometry, this.material)), super.clone.call(this, x), x; + } + } + } + ), + /***/ + "./src/WebGL/objects/Sprite.ts": ( + /*!*************************************!*\ + !*** ./src/WebGL/objects/Sprite.ts ***! + \*************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Sprite: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../materials */ + "./src/WebGL/materials/index.ts" + ), f = t( + /*! ../core */ + "./src/WebGL/core/index.ts" + ); + class _ extends f.Object3D { + constructor(h = new s.SpriteMaterial()) { + super(), this.material = h, this.rotation3d = this.rotation, this.rotation = 0; + } + updateMatrix() { + this.matrix.setPosition(this.position), this.rotation3d.set(0, 0, this.rotation), this.matrix.setRotationFromEuler(this.rotation3d), (this.scale.x !== 1 || this.scale.y !== 1) && this.matrix.scale(this.scale), this.matrixWorldNeedsUpdate = !0; + } + clone(h = new _(this.material)) { + return f.Object3D.prototype.clone.call(this, h), h; + } + } + } + ), + /***/ + "./src/WebGL/objects/index.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/objects/index.ts ***! + \************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Line: () => ( + /* reexport safe */ + s.Line + ), + /* harmony export */ + LineStyle: () => ( + /* reexport safe */ + s.LineStyle + ), + /* harmony export */ + Mesh: () => ( + /* reexport safe */ + f.Mesh + ), + /* harmony export */ + Sprite: () => ( + /* reexport safe */ + _.Sprite + ) + /* harmony export */ + }); + var s = t( + /*! ./Line */ + "./src/WebGL/objects/Line.ts" + ), f = t( + /*! ./Mesh */ + "./src/WebGL/objects/Mesh.ts" + ), _ = t( + /*! ./Sprite */ + "./src/WebGL/objects/Sprite.ts" + ); + } + ), + /***/ + "./src/WebGL/shaders/ShaderType.ts": ( + /*!*****************************************!*\ + !*** ./src/WebGL/shaders/ShaderType.ts ***! + \*****************************************/ + /***/ + (r, e, t) => { + t.r(e); + } + ), + /***/ + "./src/WebGL/shaders/index.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/shaders/index.ts ***! + \************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + ShaderLib: () => ( + /* reexport safe */ + s.ShaderLib + ), + /* harmony export */ + ShaderUtils: () => ( + /* reexport safe */ + f.ShaderUtils + ), + /* harmony export */ + basic: () => ( + /* reexport safe */ + s.basic + ), + /* harmony export */ + clone: () => ( + /* reexport safe */ + f.clone + ), + /* harmony export */ + instanced: () => ( + /* reexport safe */ + s.instanced + ), + /* harmony export */ + lambert: () => ( + /* reexport safe */ + s.lambert + ), + /* harmony export */ + lambertdouble: () => ( + /* reexport safe */ + s.lambertdouble + ), + /* harmony export */ + outline: () => ( + /* reexport safe */ + s.outline + ), + /* harmony export */ + screen: () => ( + /* reexport safe */ + s.screen + ), + /* harmony export */ + screenaa: () => ( + /* reexport safe */ + s.screenaa + ), + /* harmony export */ + sphereimposter: () => ( + /* reexport safe */ + s.sphereimposter + ), + /* harmony export */ + sphereimposteroutline: () => ( + /* reexport safe */ + s.sphereimposteroutline + ), + /* harmony export */ + sprite: () => ( + /* reexport safe */ + s.sprite + ), + /* harmony export */ + stickimposter: () => ( + /* reexport safe */ + s.stickimposter + ), + /* harmony export */ + stickimposteroutline: () => ( + /* reexport safe */ + s.stickimposteroutline + ), + /* harmony export */ + volumetric: () => ( + /* reexport safe */ + s.volumetric + ) + /* harmony export */ + }); + var s = t( + /*! ./lib */ + "./src/WebGL/shaders/lib/index.ts" + ), f = t( + /*! ./utils */ + "./src/WebGL/shaders/utils/index.ts" + ); + t( + /*! ./ShaderType */ + "./src/WebGL/shaders/ShaderType.ts" + ); + } + ), + /***/ + "./src/WebGL/shaders/lib/basic/index.ts": ( + /*!**********************************************!*\ + !*** ./src/WebGL/shaders/lib/basic/index.ts ***! + \**********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + basic: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/basic/uniforms.ts" + ), f = t( + /*! ./basic.frag */ + "./src/WebGL/shaders/lib/basic/basic.frag" + ), _ = t( + /*! ./basic.vert */ + "./src/WebGL/shaders/lib/basic/basic.vert" + ); + const x = { + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/basic/uniforms.ts": ( + /*!*************************************************!*\ + !*** ./src/WebGL/shaders/lib/basic/uniforms.ts ***! + \*************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/index.ts": ( + /*!****************************************!*\ + !*** ./src/WebGL/shaders/lib/index.ts ***! + \****************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + ShaderLib: () => ( + /* binding */ + o + ), + /* harmony export */ + basic: () => ( + /* reexport safe */ + s.basic + ), + /* harmony export */ + instanced: () => ( + /* reexport safe */ + f.instanced + ), + /* harmony export */ + lambert: () => ( + /* reexport safe */ + _.lambert + ), + /* harmony export */ + lambertdouble: () => ( + /* reexport safe */ + x.lambertdouble + ), + /* harmony export */ + outline: () => ( + /* reexport safe */ + h.outline + ), + /* harmony export */ + screen: () => ( + /* reexport safe */ + u.screen + ), + /* harmony export */ + screenaa: () => ( + /* reexport safe */ + E.screenaa + ), + /* harmony export */ + sphereimposter: () => ( + /* reexport safe */ + c.sphereimposter + ), + /* harmony export */ + sphereimposteroutline: () => ( + /* reexport safe */ + C.sphereimposteroutline + ), + /* harmony export */ + sprite: () => ( + /* reexport safe */ + b.sprite + ), + /* harmony export */ + stickimposter: () => ( + /* reexport safe */ + A.stickimposter + ), + /* harmony export */ + stickimposteroutline: () => ( + /* reexport safe */ + S.stickimposteroutline + ), + /* harmony export */ + volumetric: () => ( + /* reexport safe */ + n.volumetric + ) + /* harmony export */ + }); + var s = t( + /*! ./basic */ + "./src/WebGL/shaders/lib/basic/index.ts" + ), f = t( + /*! ./instanced */ + "./src/WebGL/shaders/lib/instanced/index.ts" + ), _ = t( + /*! ./lambert */ + "./src/WebGL/shaders/lib/lambert/index.ts" + ), x = t( + /*! ./lambertdouble */ + "./src/WebGL/shaders/lib/lambertdouble/index.ts" + ), h = t( + /*! ./outline */ + "./src/WebGL/shaders/lib/outline/index.ts" + ), u = t( + /*! ./screen */ + "./src/WebGL/shaders/lib/screen/index.ts" + ), E = t( + /*! ./screenaa */ + "./src/WebGL/shaders/lib/screenaa/index.ts" + ), c = t( + /*! ./sphereimposter */ + "./src/WebGL/shaders/lib/sphereimposter/index.ts" + ), C = t( + /*! ./sphereimposteroutline */ + "./src/WebGL/shaders/lib/sphereimposteroutline/index.ts" + ), b = t( + /*! ./sprite */ + "./src/WebGL/shaders/lib/sprite/index.ts" + ), A = t( + /*! ./stickimposter */ + "./src/WebGL/shaders/lib/stickimposter/index.ts" + ), S = t( + /*! ./stickimposteroutline */ + "./src/WebGL/shaders/lib/stickimposteroutline/index.ts" + ), n = t( + /*! ./volumetric */ + "./src/WebGL/shaders/lib/volumetric/index.ts" + ); + const o = { + basic: s.basic, + instanced: f.instanced, + lambert: _.lambert, + lambertdouble: x.lambertdouble, + outline: h.outline, + screen: u.screen, + screenaa: E.screenaa, + sphereimposter: c.sphereimposter, + sphereimposteroutline: C.sphereimposteroutline, + sprite: b.sprite, + stickimposter: A.stickimposter, + stickimposteroutline: S.stickimposteroutline, + volumetric: n.volumetric + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/instanced/index.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/shaders/lib/instanced/index.ts ***! + \**************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + instanced: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/instanced/uniforms.ts" + ), f = t( + /*! ./instanced.frag */ + "./src/WebGL/shaders/lib/instanced/instanced.frag" + ), _ = t( + /*! ./instanced.vert */ + "./src/WebGL/shaders/lib/instanced/instanced.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/instanced/uniforms.ts": ( + /*!*****************************************************!*\ + !*** ./src/WebGL/shaders/lib/instanced/uniforms.ts ***! + \*****************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + directionalLightColor: { type: "fv", value: [] }, + directionalLightDirection: { type: "fv", value: [] } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/lambert/index.ts": ( + /*!************************************************!*\ + !*** ./src/WebGL/shaders/lib/lambert/index.ts ***! + \************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + lambert: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/lambert/uniforms.ts" + ), f = t( + /*! ./lambert.frag */ + "./src/WebGL/shaders/lib/lambert/lambert.frag" + ), _ = t( + /*! ./lambert.vert */ + "./src/WebGL/shaders/lib/lambert/lambert.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/lambert/uniforms.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/shaders/lib/lambert/uniforms.ts ***! + \***************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + directionalLightColor: { type: "fv", value: [] }, + directionalLightDirection: { type: "fv", value: [] } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/lambertdouble/index.ts": ( + /*!******************************************************!*\ + !*** ./src/WebGL/shaders/lib/lambertdouble/index.ts ***! + \******************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + lambertdouble: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/lambertdouble/uniforms.ts" + ), f = t( + /*! ./lambertdouble.frag */ + "./src/WebGL/shaders/lib/lambertdouble/lambertdouble.frag" + ), _ = t( + /*! ./lambertdouble.vert */ + "./src/WebGL/shaders/lib/lambertdouble/lambertdouble.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/lambertdouble/uniforms.ts": ( + /*!*********************************************************!*\ + !*** ./src/WebGL/shaders/lib/lambertdouble/uniforms.ts ***! + \*********************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + directionalLightColor: { type: "fv", value: [] }, + directionalLightDirection: { type: "fv", value: [] } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/outline/index.ts": ( + /*!************************************************!*\ + !*** ./src/WebGL/shaders/lib/outline/index.ts ***! + \************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + outline: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/outline/uniforms.ts" + ), f = t( + /*! ./outline.frag */ + "./src/WebGL/shaders/lib/outline/outline.frag" + ), _ = t( + /*! ./outline.vert */ + "./src/WebGL/shaders/lib/outline/outline.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/outline/uniforms.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/shaders/lib/outline/uniforms.ts ***! + \***************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + outlineColor: { type: "c", value: new s.Color(0, 0, 0) }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + outlineWidth: { type: "f", value: 0.1 }, + outlinePushback: { type: "f", value: 1 } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/screen/index.ts": ( + /*!***********************************************!*\ + !*** ./src/WebGL/shaders/lib/screen/index.ts ***! + \***********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + screen: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/screen/uniforms.ts" + ), f = t( + /*! ./screen.frag */ + "./src/WebGL/shaders/lib/screen/screen.frag" + ), _ = t( + /*! ./screen.vert */ + "./src/WebGL/shaders/lib/screen/screen.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/screen/uniforms.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/shaders/lib/screen/uniforms.ts ***! + \**************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + const s = {}; + } + ), + /***/ + "./src/WebGL/shaders/lib/screenaa/index.ts": ( + /*!*************************************************!*\ + !*** ./src/WebGL/shaders/lib/screenaa/index.ts ***! + \*************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + screenaa: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/screenaa/uniforms.ts" + ), f = t( + /*! ./screenaa.frag */ + "./src/WebGL/shaders/lib/screenaa/screenaa.frag" + ), _ = t( + /*! ./screenaa.vert */ + "./src/WebGL/shaders/lib/screenaa/screenaa.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/screenaa/uniforms.ts": ( + /*!****************************************************!*\ + !*** ./src/WebGL/shaders/lib/screenaa/uniforms.ts ***! + \****************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + const s = {}; + } + ), + /***/ + "./src/WebGL/shaders/lib/sphereimposter/index.ts": ( + /*!*******************************************************!*\ + !*** ./src/WebGL/shaders/lib/sphereimposter/index.ts ***! + \*******************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + sphereimposter: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/sphereimposter/uniforms.ts" + ), f = t( + /*! ./sphereimposter.frag */ + "./src/WebGL/shaders/lib/sphereimposter/sphereimposter.frag" + ), _ = t( + /*! ./sphereimposter.vert */ + "./src/WebGL/shaders/lib/sphereimposter/sphereimposter.vert" + ); + const x = { + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/sphereimposter/uniforms.ts": ( + /*!**********************************************************!*\ + !*** ./src/WebGL/shaders/lib/sphereimposter/uniforms.ts ***! + \**********************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + directionalLightColor: { type: "fv", value: [] }, + directionalLightDirection: { type: "fv", value: [] } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/sphereimposteroutline/index.ts": ( + /*!**************************************************************!*\ + !*** ./src/WebGL/shaders/lib/sphereimposteroutline/index.ts ***! + \**************************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + sphereimposteroutline: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts" + ), f = t( + /*! ./sphereimposteroutline.frag */ + "./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.frag" + ), _ = t( + /*! ./sphereimposteroutline.vert */ + "./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts": ( + /*!*****************************************************************!*\ + !*** ./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts ***! + \*****************************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + outlineColor: { type: "c", value: new s.Color(0, 0, 0) }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + outlineWidth: { type: "f", value: 0.1 }, + outlinePushback: { type: "f", value: 1 } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/sprite/index.ts": ( + /*!***********************************************!*\ + !*** ./src/WebGL/shaders/lib/sprite/index.ts ***! + \***********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + sprite: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/sprite/uniforms.ts" + ), f = t( + /*! ./sprite.frag */ + "./src/WebGL/shaders/lib/sprite/sprite.frag" + ), _ = t( + /*! ./sprite.vert */ + "./src/WebGL/shaders/lib/sprite/sprite.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/sprite/uniforms.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/shaders/lib/sprite/uniforms.ts ***! + \**************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + const s = {}; + } + ), + /***/ + "./src/WebGL/shaders/lib/stickimposter/index.ts": ( + /*!******************************************************!*\ + !*** ./src/WebGL/shaders/lib/stickimposter/index.ts ***! + \******************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + stickimposter: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/stickimposter/uniforms.ts" + ), f = t( + /*! ../../utils/stickimposterFragmentShader.partial.frag */ + "./src/WebGL/shaders/utils/stickimposterFragmentShader.partial.frag" + ), _ = t( + /*! ./stickimposter.partial.frag */ + "./src/WebGL/shaders/lib/stickimposter/stickimposter.partial.frag" + ), x = t( + /*! ./stickimposter.vert */ + "./src/WebGL/shaders/lib/stickimposter/stickimposter.vert" + ); + const u = { + fragmentShader: [f.default, _.default].join(` +`).replace("#define GLSLIFY 1", ""), + vertexShader: x.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/stickimposter/uniforms.ts": ( + /*!*********************************************************!*\ + !*** ./src/WebGL/shaders/lib/stickimposter/uniforms.ts ***! + \*********************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + directionalLightColor: { type: "fv", value: [] }, + directionalLightDirection: { type: "fv", value: [] } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/stickimposteroutline/index.ts": ( + /*!*************************************************************!*\ + !*** ./src/WebGL/shaders/lib/stickimposteroutline/index.ts ***! + \*************************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + stickimposteroutline: () => ( + /* binding */ + h + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts" + ), f = t( + /*! ../../utils/stickimposterFragmentShader.partial.frag */ + "./src/WebGL/shaders/utils/stickimposterFragmentShader.partial.frag" + ), _ = t( + /*! ./stickimposteroutline.vert */ + "./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.vert" + ); + const h = { + fragmentShader: (f.default + "gl_FragColor = vec4(color,1.0);}").replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts": ( + /*!****************************************************************!*\ + !*** ./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts ***! + \****************************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + outlineColor: { type: "c", value: new s.Color(0, 0, 0) }, + outlineWidth: { type: "f", value: 0.1 }, + outlinePushback: { type: "f", value: 1 } + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/volumetric/index.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/shaders/lib/volumetric/index.ts ***! + \***************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + volumetric: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/volumetric/uniforms.ts" + ), f = t( + /*! ./volumetric.frag */ + "./src/WebGL/shaders/lib/volumetric/volumetric.frag" + ), _ = t( + /*! ./volumetric.vert */ + "./src/WebGL/shaders/lib/volumetric/volumetric.vert" + ); + const x = { + fragmentShader: f.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: s.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/volumetric/uniforms.ts": ( + /*!******************************************************!*\ + !*** ./src/WebGL/shaders/lib/volumetric/uniforms.ts ***! + \******************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + uniforms: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const f = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new s.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + data: { type: "i", value: 3 }, + colormap: { type: "i", value: 4 }, + depthmap: { type: "i", value: 5 }, + step: { type: "f", value: 1 }, + maxdepth: { type: "f", value: 100 }, + subsamples: { type: "f", value: 5 }, + textmat: { type: "mat4", value: [] }, + projinv: { type: "mat4", value: [] }, + transfermin: { type: "f", value: -0.2 }, + transfermax: { type: "f", value: 0.2 } + }; + } + ), + /***/ + "./src/WebGL/shaders/utils/clone.ts": ( + /*!******************************************!*\ + !*** ./src/WebGL/shaders/utils/clone.ts ***! + \******************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + clone: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../../colors */ + "./src/colors.ts" + ); + function f(_) { + let x = {}; + for (const u in _) { + x[u] = {}, x[u].type = _[u].type; + var h = _[u].value; + h instanceof s.Color ? x[u].value = h.clone() : typeof h == "number" ? x[u].value = h : h instanceof Array ? x[u].value = [] : console.error("Error copying shader uniforms from ShaderLib: unknown type for uniform"); + } + return x; + } + } + ), + /***/ + "./src/WebGL/shaders/utils/index.ts": ( + /*!******************************************!*\ + !*** ./src/WebGL/shaders/utils/index.ts ***! + \******************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + ShaderUtils: () => ( + /* binding */ + _ + ), + /* harmony export */ + clone: () => ( + /* reexport safe */ + s.clone + ) + /* harmony export */ + }); + var s = t( + /*! ./clone */ + "./src/WebGL/shaders/utils/clone.ts" + ), f = t( + /*! ./stickimposterFragmentShader.partial.frag */ + "./src/WebGL/shaders/utils/stickimposterFragmentShader.partial.frag" + ); + const _ = { + clone: s.clone, + stickimposterFragmentShader: f.default + }; + } + ), + /***/ + "./src/WebGL/shapes/Cylinder.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/shapes/Cylinder.ts ***! + \**************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Cylinder: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + let f = new s.Vector3(); + class _ { + constructor(h = new s.Vector3(), u = new s.Vector3(), E = 0) { + this.c1 = h, this.c2 = u, this.radius = E, this.direction = new s.Vector3().subVectors(this.c2, this.c1).normalize(); + } + copy(h) { + return this.c1.copy(h.c1), this.c2.copy(h.c2), this.direction.copy(h.direction), this.radius = h.radius, this; + } + lengthSq() { + return f.subVectors(this.c2, this.c1).lengthSq(); + } + applyMatrix4(h) { + return this.direction.add(this.c1).applyMatrix4(h), this.c1.applyMatrix4(h), this.c2.applyMatrix4(h), this.direction.sub(this.c1).normalize(), this.radius = this.radius * h.getMaxScaleOnAxis(), this; + } + } + } + ), + /***/ + "./src/WebGL/shapes/Sphere.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/shapes/Sphere.ts ***! + \************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Sphere: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + class f { + constructor(x = { x: 0, y: 0, z: 0 }, h = 0) { + this.center = new s.Vector3(x.x, x.y, x.z), this.radius = h; + } + set(x, h) { + return this.center.copy(x), this.radius = h, this; + } + copy(x) { + return this.center.copy(x.center), this.radius = x.radius, this; + } + applyMatrix4(x) { + return this.center.applyMatrix4(x), this.radius = this.radius * x.getMaxScaleOnAxis(), this; + } + translate(x) { + return this.center.add(x), this; + } + equals(x) { + return x.center.equals(this.center) && x.radius === this.radius; + } + clone() { + return new f().copy(this); + } + } + } + ), + /***/ + "./src/WebGL/shapes/Triangle.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/shapes/Triangle.ts ***! + \**************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Triangle: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + const f = new s.Vector3(); + class _ { + constructor(h = new s.Vector3(), u = new s.Vector3(), E = new s.Vector3()) { + this.a = h, this.b = u, this.c = E; + } + copy(h) { + return this.a.copy(h.a), this.b.copy(h.b), this.c.copy(h.c), this; + } + applyMatrix4(h) { + return this.a.applyMatrix4(h), this.b.applyMatrix4(h), this.c.applyMatrix4(h), this; + } + getNormal() { + var h = this.a.clone(); + return h.sub(this.b), f.subVectors(this.c, this.b), h.cross(f), h.normalize(), h; + } + } + } + ), + /***/ + "./src/WebGL/shapes/index.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/shapes/index.ts ***! + \***********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Cylinder: () => ( + /* reexport safe */ + f.Cylinder + ), + /* harmony export */ + Sphere: () => ( + /* reexport safe */ + s.Sphere + ), + /* harmony export */ + Triangle: () => ( + /* reexport safe */ + _.Triangle + ) + /* harmony export */ + }); + var s = t( + /*! ./Sphere */ + "./src/WebGL/shapes/Sphere.ts" + ), f = t( + /*! ./Cylinder */ + "./src/WebGL/shapes/Cylinder.ts" + ), _ = t( + /*! ./Triangle */ + "./src/WebGL/shapes/Triangle.ts" + ); + } + ), + /***/ + "./src/autoload.ts": ( + /*!*************************!*\ + !*** ./src/autoload.ts ***! + \*************************/ + /***/ + (__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, { + /* harmony export */ + autoinit: () => ( + /* binding */ + autoinit + ), + /* harmony export */ + autoload: () => ( + /* binding */ + autoload + ), + /* harmony export */ + processing_autoinit: () => ( + /* binding */ + processing_autoinit + ), + /* harmony export */ + viewers: () => ( + /* binding */ + viewers + ) + /* harmony export */ + }); + var _GLViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( + /*! ./GLViewer */ + "./src/GLViewer.ts" + ), _ProteinSurface4__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( + /*! ./ProteinSurface4 */ + "./src/ProteinSurface4.ts" + ), _utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( + /*! ./utilities */ + "./src/utilities.ts" + ), _colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__( + /*! ./colors */ + "./src/colors.ts" + ), autoinit = !1, processing_autoinit = !1, viewers = {}; + function autoload(viewer, callback) { + var i, dataname, type; + if (document.querySelector(".viewer_3Dmoljs") != null && (autoinit = !0), autoinit) { + processing_autoinit = !0, viewer = viewer ?? null; + var nviewers = 0; + document.querySelectorAll(".viewer_3Dmoljs").forEach((viewerdiv) => { + var datauri = [], datatypes = [], uri = ""; + viewerdiv.style.position == "static" && (viewerdiv.style.position = "relative"); + var UI = null; + if (type = null, viewerdiv.dataset.pdb) + datauri.push("https://files.rcsb.org/view/" + viewerdiv.dataset.pdb + ".pdb"), datatypes.push("pdb"); + else if (viewerdiv.dataset.cid) + datatypes.push("sdf"), datauri.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/" + viewerdiv.dataset.cid + "/SDF?record_type=3d"); + else if (viewerdiv.dataset.href || viewerdiv.dataset.url) { + viewerdiv.dataset.href ? uri = viewerdiv.dataset.href : uri = viewerdiv.dataset.url, datauri.push(uri), type = uri.substring(uri.lastIndexOf(".") + 1), datatypes.push(type); + var molName = uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf(".")); + molName == "/" && (molName = uri.substring(uri.lastIndexOf("/") + 1)), viewerdiv.dataset[datatypes[datatypes.length - 1]] = molName; + } + var divdata = viewerdiv.dataset; + for (i in divdata) + i.substring(0, 3) === "pdb" && i !== "pdb" ? (datauri.push("https://files.rcsb.org/view/" + divdata[i] + ".pdb"), datatypes.push("pdb")) : i.substring(0, 4) === "href" && i !== "href" ? (uri = divdata[i], datauri.push(uri), datatypes.push(uri.substring(uri.lastIndexOf(".") + 1))) : i.substring(0, 3) === "cid" && i !== "cid" && (datauri.push("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/" + divdata[i] + "/SDF?record_type=3d"), datatypes.push("sdf")); + var options = {}; + viewerdiv.dataset.options && (options = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(viewerdiv.dataset.options)); + var bgcolor = _colors__WEBPACK_IMPORTED_MODULE_3__.CC.color(viewerdiv.dataset.backgroundcolor), bgalpha = viewerdiv.dataset.backgroundalpha; + bgalpha = bgalpha == null ? 1 : parseFloat(bgalpha); + var style = { line: {} }; + viewerdiv.dataset.style && (style = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(viewerdiv.dataset.style)); + var select = {}; + viewerdiv.dataset.select && (select = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(viewerdiv.dataset.select)); + var selectstylelist = [], surfaces = [], labels = [], zoomto = {}, spin = null, d = viewerdiv.dataset, stylere = /style(.+)/, surfre = /surface(.*)/, reslabre = /labelres(.*)/, keys = []; + for (dataname in d) + Object.prototype.hasOwnProperty.call(d, dataname) && keys.push(dataname); + for (keys.sort(), i = 0; i < keys.length; i++) { + dataname = keys[i]; + var m = stylere.exec(dataname), selname, newsel, styleobj; + m && (selname = "select" + m[1], newsel = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[selname]), styleobj = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname]), selectstylelist.push([newsel, styleobj])), m = surfre.exec(dataname), m && (selname = "select" + m[1], newsel = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[selname]), styleobj = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname]), surfaces.push([newsel, styleobj])), m = reslabre.exec(dataname), m && (selname = "select" + m[1], newsel = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[selname]), styleobj = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname]), labels.push([newsel, styleobj])), dataname == "zoomto" && (zoomto = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname])), dataname == "spin" && (spin = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(d[dataname])); + } + var applyStyles = function(r) { + for (r.setStyle(select, style), UI && UI.createSelectionAndStyle(select, style), i = 0; i < selectstylelist.length; i++) { + let e = selectstylelist[i][0] || {}, t = selectstylelist[i][1] || { line: {} }; + r.setStyle(e, t), UI && UI.createSelectionAndStyle(select, style); + } + for (i = 0; i < surfaces.length; i++) { + let e = surfaces[i][0] || {}, t = surfaces[i][1] || {}; + UI ? r.addSurface(_ProteinSurface4__WEBPACK_IMPORTED_MODULE_1__.SurfaceType.VDW, t, e, e).then((f) => { + UI.loadSurface("VDW", e, t, f); + }) : r.addSurface(_ProteinSurface4__WEBPACK_IMPORTED_MODULE_1__.SurfaceType.VDW, t, e, e); + } + for (i = 0; i < labels.length; i++) { + let e = labels[i][0] || {}, t = labels[i][1] || {}; + r.addResLabels(e, t); + } + r.render(), r.zoomTo(zoomto), spin && r.spin(spin.axis, spin.speed); + }, glviewer = viewer; + try { + var config = (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.specStringToObject)(viewerdiv.dataset.config) || {}; + config.backgroundColor === void 0 && (config.backgroundColor = bgcolor), config.backgroundAlpha === void 0 && (config.backgroundAlpha = bgalpha), glviewer == null ? glviewer = viewers[viewerdiv.id || nviewers++] = (0, _GLViewer__WEBPACK_IMPORTED_MODULE_0__.createViewer)(viewerdiv, config) : (glviewer.setBackgroundColor(bgcolor, bgalpha), glviewer.setConfig(config), UI && UI.initiateUI()), viewerdiv.dataset.ui && $3Dmol.StateManager && (UI = new $3Dmol.StateManager(glviewer)); + } catch (r) { + console.log(r), viewerdiv.textContent = "WebGL appears to be disabled."; + } + if (datauri.length != 0) { + let i = 0; + var process = function(moldata) { + uri = datauri[i]; + var type = viewerdiv.dataset.type || viewerdiv.dataset.datatype || datatypes[i]; + if (glviewer.addModel(moldata, type, options), UI) { + var modelName = viewerdiv.dataset[datatypes[i]]; + UI.setModelTitle(modelName); + } + if (i += 1, i < datauri.length) + (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.get)(datauri[i]).then(process); + else { + if (applyStyles(glviewer), viewerdiv.dataset.callback) { + var runres = eval(viewerdiv.dataset.callback); + typeof runres == "function" && runres(glviewer); + } + processing_autoinit = !1, callback && callback(glviewer); + } + }; + (0, _utilities__WEBPACK_IMPORTED_MODULE_2__.get)(datauri[0]).then(process); + } else { + if (viewerdiv.dataset.element) { + var moldataid = "#" + viewerdiv.dataset.element, molelem = document.querySelector(moldataid), moldata = molelem ? molelem.textContent : ""; + type = viewerdiv.dataset.type || viewerdiv.dataset.datatype, glviewer.addModel(moldata, type, options); + } + if (applyStyles(glviewer), viewerdiv.dataset.callback) { + var runres = eval(viewerdiv.dataset.callback); + typeof runres == "function" && runres(glviewer); + } + processing_autoinit = !1, callback && callback(glviewer); + } + }); + } + } + document.onreadystatechange = () => { + document.readyState === "complete" && autoload(); + }; + } + ), + /***/ + "./src/colors.ts": ( + /*!***********************!*\ + !*** ./src/colors.ts ***! + \***********************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + CC: () => ( + /* binding */ + f + ), + /* harmony export */ + Color: () => ( + /* binding */ + s + ), + /* harmony export */ + builtinColorSchemes: () => ( + /* binding */ + C + ), + /* harmony export */ + chains: () => ( + /* binding */ + c + ), + /* harmony export */ + elementColors: () => ( + /* binding */ + u + ), + /* harmony export */ + htmlColors: () => ( + /* binding */ + _ + ), + /* harmony export */ + residues: () => ( + /* binding */ + E + ), + /* harmony export */ + ssColors: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + class s { + constructor(A, S, n) { + return this.r = 0, this.g = 0, this.b = 0, arguments.length > 1 && typeof A == "number" ? (this.r = A || 0, this.g = S || 0, this.b = n || 0, this) : this.set(A || 0); + } + set(A) { + return A instanceof s ? A.clone() : (typeof A == "number" ? this.setHex(A) : typeof A == "object" && (this.r = (A == null ? void 0 : A.r) || 0, this.g = (A == null ? void 0 : A.g) || 0, this.b = (A == null ? void 0 : A.b) || 0), this); + } + setHex(A) { + return A = Math.floor(A), this.r = (A >> 16 & 255) / 255, this.g = (A >> 8 & 255) / 255, this.b = (A & 255) / 255, this; + } + getHex() { + var A = Math.round(this.r * 255), S = Math.round(this.g * 255), n = Math.round(this.b * 255); + return A << 16 | S << 8 | n; + } + clone() { + return new s(this.r, this.g, this.b); + } + copy(A) { + return this.r = A.r, this.g = A.g, this.b = A.b, this; + } + //return object that represents color components from 0 to 255 + scaled() { + var A = {}; + return A.r = Math.round(this.r * 255), A.g = Math.round(this.g * 255), A.b = Math.round(this.b * 255), A.a = 1, A; + } + } + class f { + static color(A) { + if (!A) + return f.cache[0]; + if (A instanceof s) + return A; + if (typeof A == "number" && typeof f.cache[A] < "u") + return f.cache[A]; + if (A && Array.isArray(A)) + return A.map(f.color); + let S = f.getHex(A), n = new s(S); + return f.cache[S] = n, n; + } + static getHex(A) { + var S; + if (Array.isArray(A)) + return A.map(f.getHex); + if (typeof A == "string") { + let n = A; + if (!isNaN(parseInt(n))) + return parseInt(n); + if (n = n.trim(), n.length == 4 && n[0] == "#" && (n = "#" + n[1] + n[1] + n[2] + n[2] + n[3] + n[3]), n.length == 7 && n[0] == "#") + return parseInt(n.substring(1), 16); + let o = f.rgbRegEx.exec(n); + if (o) { + o[1] != "" && console.log("WARNING: Opacity value in rgba ignored. Specify separately as opacity attribute."); + let w = 0; + for (let p = 2; p < 5; p++) { + w *= 256; + let v = o[p].endsWith("%") ? 255 * parseFloat(o[p]) / 100 : parseFloat(o[p]); + w += Math.round(v); + } + return w; + } + return ((S = window == null ? void 0 : window.$3Dmol) === null || S === void 0 ? void 0 : S.htmlColors[A.toLowerCase()]) || 0; + } + return A; + } + } + f.rgbRegEx = /rgb(a?)\(\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)/i, f.cache = { 0: new s(0) }; + const _ = { + aliceblue: 15792383, + antiquewhite: 16444375, + aqua: 65535, + aquamarine: 8388564, + azure: 15794175, + beige: 16119260, + bisque: 16770244, + black: 0, + blanchedalmond: 16772045, + blue: 255, + blueviolet: 9055202, + brown: 10824234, + burlywood: 14596231, + cadetblue: 6266528, + chartreuse: 8388352, + chocolate: 13789470, + coral: 16744272, + cornflowerblue: 6591981, + cornsilk: 16775388, + crimson: 14423100, + cyan: 65535, + darkblue: 139, + darkcyan: 35723, + darkgoldenrod: 12092939, + darkgray: 11119017, + darkgrey: 11119017, + darkgreen: 25600, + darkkhaki: 12433259, + darkmagenta: 9109643, + darkolivegreen: 5597999, + darkorange: 16747520, + darkorchid: 10040012, + darkred: 9109504, + darksalmon: 15308410, + darkseagreen: 9419919, + darkslateblue: 4734347, + darkslategray: 3100495, + darkslategrey: 3100495, + darkturquoise: 52945, + darkviolet: 9699539, + deeppink: 16716947, + deepskyblue: 49151, + dimgray: 6908265, + dimgrey: 6908265, + dodgerblue: 2003199, + firebrick: 11674146, + floralwhite: 16775920, + forestgreen: 2263842, + fuchsia: 16711935, + gainsboro: 14474460, + ghostwhite: 16316671, + gold: 16766720, + goldenrod: 14329120, + gray: 8421504, + grey: 8421504, + green: 32768, + greenyellow: 11403055, + honeydew: 15794160, + hotpink: 16738740, + indianred: 13458524, + indigo: 4915330, + ivory: 16777200, + khaki: 15787660, + lavender: 15132410, + lavenderblush: 16773365, + lawngreen: 8190976, + lemonchiffon: 16775885, + lightblue: 11393254, + lightcoral: 15761536, + lightcyan: 14745599, + lightgoldenrodyellow: 16448210, + lightgray: 13882323, + lightgrey: 13882323, + lightgreen: 9498256, + lightpink: 16758465, + lightsalmon: 16752762, + lightseagreen: 2142890, + lightskyblue: 8900346, + lightslategray: 7833753, + lightslategrey: 7833753, + lightsteelblue: 11584734, + lightyellow: 16777184, + lime: 65280, + limegreen: 3329330, + linen: 16445670, + magenta: 16711935, + maroon: 8388608, + mediumaquamarine: 6737322, + mediumblue: 205, + mediumorchid: 12211667, + mediumpurple: 9662683, + mediumseagreen: 3978097, + mediumslateblue: 8087790, + mediumspringgreen: 64154, + mediumturquoise: 4772300, + mediumvioletred: 13047173, + midnightblue: 1644912, + mintcream: 16121850, + mistyrose: 16770273, + moccasin: 16770229, + navajowhite: 16768685, + navy: 128, + oldlace: 16643558, + olive: 8421376, + olivedrab: 7048739, + orange: 16753920, + orangered: 16729344, + orchid: 14315734, + palegoldenrod: 15657130, + palegreen: 10025880, + paleturquoise: 11529966, + palevioletred: 14381203, + papayawhip: 16773077, + peachpuff: 16767673, + peru: 13468991, + pink: 16761035, + plum: 14524637, + powderblue: 11591910, + purple: 8388736, + rebeccapurple: 6697881, + red: 16711680, + rosybrown: 12357519, + royalblue: 4286945, + saddlebrown: 9127187, + salmon: 16416882, + sandybrown: 16032864, + seagreen: 3050327, + seashell: 16774638, + sienna: 10506797, + silver: 12632256, + skyblue: 8900331, + slateblue: 6970061, + slategray: 7372944, + slategrey: 7372944, + snow: 16775930, + springgreen: 65407, + steelblue: 4620980, + tan: 13808780, + teal: 32896, + thistle: 14204888, + tomato: 16737095, + turquoise: 4251856, + violet: 15631086, + wheat: 16113331, + white: 16777215, + whitesmoke: 16119285, + yellow: 16776960, + yellowgreen: 10145074 + }, x = { + //names are in helix-sheet-coil order + pyMol: { h: 16711680, s: 16776960, c: 65280 }, + Jmol: { h: 16711808, s: 16762880, c: 16777215 } + }, h = { + H: 16777215, + He: 16761035, + HE: 16761035, + Li: 11674146, + LI: 11674146, + B: 65280, + C: 13158600, + N: 9408511, + O: 15728640, + F: 14329120, + Na: 255, + NA: 255, + Mg: 2263842, + MG: 2263842, + Al: 8421520, + AL: 8421520, + Si: 14329120, + SI: 14329120, + P: 16753920, + S: 16762930, + Cl: 65280, + CL: 65280, + Ca: 8421520, + CA: 8421520, + Ti: 8421520, + TI: 8421520, + Cr: 8421520, + CR: 8421520, + Mn: 8421520, + MN: 8421520, + Fe: 16753920, + FE: 16753920, + Ni: 10824234, + NI: 10824234, + Cu: 10824234, + CU: 10824234, + Zn: 10824234, + ZN: 10824234, + Br: 10824234, + BR: 10824234, + Ag: 8421520, + AG: 8421520, + I: 10494192, + Ba: 16753920, + BA: 16753920, + Au: 14329120, + AU: 14329120 + }, u = { + defaultColor: 16716947, + /** Jmol-like element colors*/ + Jmol: { + H: 16777215, + He: 14286847, + HE: 14286847, + Li: 13402367, + LI: 13402367, + Be: 12779264, + BE: 12779264, + B: 16758197, + C: 9474192, + N: 3166456, + O: 16715021, + F: 9494608, + Ne: 11789301, + NE: 11789301, + Na: 11230450, + NA: 11230450, + Mg: 9109248, + MG: 9109248, + Al: 12560038, + AL: 12560038, + Si: 1578e4, + SI: 1578e4, + P: 16744448, + S: 16777008, + Cl: 2093087, + CL: 2093087, + Ar: 8442339, + AR: 8442339, + K: 9388244, + Ca: 4062976, + CA: 4062976, + Sc: 15132390, + SC: 15132390, + Ti: 12567239, + TI: 12567239, + V: 10921643, + Cr: 9083335, + CR: 9083335, + Mn: 10255047, + MN: 10255047, + Fe: 14706227, + FE: 14706227, + Co: 15765664, + CO: 15765664, + Ni: 5296208, + NI: 5296208, + Cu: 13140019, + CU: 13140019, + Zn: 8224944, + ZN: 8224944, + Ga: 12750735, + GA: 12750735, + Ge: 6721423, + GE: 6721423, + As: 12419299, + AS: 12419299, + Se: 16752896, + SE: 16752896, + Br: 10889513, + BR: 10889513, + Kr: 6076625, + KR: 6076625, + Rb: 7351984, + RB: 7351984, + Sr: 65280, + SR: 65280, + Y: 9764863, + Zr: 9756896, + ZR: 9756896, + Nb: 7586505, + NB: 7586505, + Mo: 5551541, + MO: 5551541, + Tc: 3907230, + TC: 3907230, + Ru: 2396047, + RU: 2396047, + Rh: 687500, + RH: 687500, + Pd: 27013, + PD: 27013, + Ag: 12632256, + AG: 12632256, + Cd: 16767375, + CD: 16767375, + In: 10909043, + IN: 10909043, + Sn: 6717568, + SN: 6717568, + Sb: 10380213, + SB: 10380213, + Te: 13924864, + TE: 13924864, + I: 9699476, + Xe: 4366e3, + XE: 4366e3, + Cs: 5707663, + CS: 5707663, + Ba: 51456, + BA: 51456, + La: 7394559, + LA: 7394559, + Ce: 16777159, + CE: 16777159, + Pr: 14286791, + PR: 14286791, + Nd: 13107143, + ND: 13107143, + Pm: 10747847, + PM: 10747847, + Sm: 9437127, + SM: 9437127, + Eu: 6422471, + EU: 6422471, + Gd: 4587463, + GD: 4587463, + Tb: 3211207, + TB: 3211207, + Dy: 2097095, + DY: 2097095, + Ho: 65436, + HO: 65436, + Er: 58997, + ER: 58997, + Tm: 54354, + TM: 54354, + Yb: 48952, + YB: 48952, + Lu: 43812, + LU: 43812, + Hf: 5096191, + HF: 5096191, + Ta: 5089023, + TA: 5089023, + W: 2200790, + Re: 2522539, + RE: 2522539, + Os: 2516630, + OS: 2516630, + Ir: 1528967, + IR: 1528967, + Pt: 13684960, + PT: 13684960, + Au: 16765219, + AU: 16765219, + Hg: 12105936, + HG: 12105936, + Tl: 10900557, + TL: 10900557, + Pb: 5724513, + PB: 5724513, + Bi: 10375093, + BI: 10375093, + Po: 11230208, + PO: 11230208, + At: 7688005, + AT: 7688005, + Rn: 4358806, + RN: 4358806, + Fr: 4325478, + FR: 4325478, + Ra: 32e3, + RA: 32e3, + Ac: 7384058, + AC: 7384058, + Th: 47871, + TH: 47871, + Pa: 41471, + PA: 41471, + U: 36863, + Np: 33023, + NP: 33023, + Pu: 27647, + PU: 27647, + Am: 5528818, + AM: 5528818, + Cm: 7888099, + CM: 7888099, + Bk: 9064419, + BK: 9064419, + Cf: 10565332, + CF: 10565332, + Es: 11739092, + ES: 11739092, + Fm: 11739066, + FM: 11739066, + Md: 11734438, + MD: 11734438, + No: 12389767, + NO: 12389767, + Lr: 13041766, + LR: 13041766, + Rf: 13369433, + RF: 13369433, + Db: 13697103, + DB: 13697103, + Sg: 14221381, + SG: 14221381, + Bh: 14680120, + BH: 14680120, + Hs: 15073326, + HS: 15073326, + Mt: 15400998, + MT: 15400998 + }, + /** rasmol-like element colors */ + rasmol: h, + defaultColors: Object.assign({}, h), + greenCarbon: Object.assign(Object.assign({}, h), { C: 65280 }), + cyanCarbon: Object.assign(Object.assign({}, h), { C: 65535 }), + magentaCarbon: Object.assign(Object.assign({}, h), { C: 16711935 }), + yellowCarbon: Object.assign(Object.assign({}, h), { C: 16776960 }), + whiteCarbon: Object.assign(Object.assign({}, h), { C: 16777215 }), + orangeCarbon: Object.assign(Object.assign({}, h), { C: 16753920 }), + purpleCarbon: Object.assign(Object.assign({}, h), { C: 8388736 }), + blueCarbon: Object.assign(Object.assign({}, h), { C: 255 }) + }, E = { + /** @property standard amino acid color scheme*/ + amino: { + ALA: 13158600, + ARG: 1334015, + ASN: 56540, + ASP: 15075850, + CYS: 15132160, + GLN: 56540, + GLU: 15075850, + GLY: 15461355, + HIS: 8553170, + ILE: 1016335, + LEU: 1016335, + LYS: 1334015, + MET: 15132160, + PHE: 3289770, + PRO: 14456450, + SER: 16422400, + THR: 16422400, + TRP: 11819700, + TYR: 3289770, + VAL: 1016335, + ASX: 16738740, + GLX: 16738740 + }, + /** @property shapely amino acid color scheme*/ + shapely: { + ALA: 9240460, + ARG: 124, + ASN: 16743536, + ASP: 10485826, + CYS: 16777072, + GLN: 16731212, + GLU: 6684672, + GLY: 16777215, + HIS: 7368959, + ILE: 19456, + LEU: 4546117, + LYS: 4671416, + MET: 12099650, + PHE: 5459026, + PRO: 5395026, + SER: 16740418, + THR: 12078080, + TRP: 5195264, + TYR: 9203788, + VAL: 16747775, + ASX: 16711935, + GLX: 16711935 + }, + /** @property nucleic acid color scheme*/ + nucleic: { + A: 10526975, + G: 16740464, + I: 8454143, + C: 16747595, + T: 10551200, + U: 16744576 + } + }, c = { + /** @property chain based standard color scheme */ + atom: { + A: 12636415, + B: 11599792, + C: 16761032, + D: 16777088, + E: 16761087, + F: 11596016, + G: 16765040, + H: 15761536, + I: 16113331, + J: 49151, + K: 13458524, + L: 6737322, + M: 10145074, + N: 15631086, + O: 52945, + P: 65407, + Q: 3978097, + R: 139, + S: 12433259, + T: 25600, + U: 8388608, + V: 8421376, + W: 8388736, + X: 32896, + Y: 12092939, + Z: 11674146 + }, + /** @property hetatm color scheme */ + hetatm: { + A: 9478351, + B: 8441752, + C: 13602992, + D: 13619056, + E: 13603023, + F: 8437952, + G: 13607008, + H: 12603504, + I: 12955267, + J: 42959, + K: 11881548, + L: 5682578, + M: 9090346, + N: 12481214, + O: 46753, + P: 53103, + Q: 3447649, + R: 187, + S: 10854235, + T: 37888, + U: 11534336, + V: 11579392, + W: 11534512, + X: 45232, + Y: 15250963, + Z: 12726834 + } + }, C = { + /** secondary structure pymol */ + ssPyMol: { prop: "ss", map: x.pyMol }, + ssJmol: { prop: "ss", map: x.Jmol }, + Jmol: { prop: "elem", map: u.Jmol }, + amino: { prop: "resn", map: E.amino }, + shapely: { prop: "resn", map: E.shapely }, + nucleic: { prop: "resn", map: E.nucleic }, + chain: { prop: "chain", map: c.atom }, + rasmol: { prop: "elem", map: u.rasmol }, + default: { prop: "elem", map: u.defaultColors }, + greenCarbon: { prop: "elem", map: u.greenCarbon }, + chainHetatm: { prop: "chain", map: c.hetatm }, + cyanCarbon: { prop: "elem", map: u.cyanCarbon }, + magentaCarbon: { prop: "elem", map: u.magentaCarbon }, + purpleCarbon: { prop: "elem", map: u.purpleCarbon }, + whiteCarbon: { prop: "elem", map: u.whiteCarbon }, + orangeCarbon: { prop: "elem", map: u.orangeCarbon }, + yellowCarbon: { prop: "elem", map: u.yellowCarbon }, + blueCarbon: { prop: "elem", map: u.blueCarbon } + }; + } + ), + /***/ + "./src/glcartoon.ts": ( + /*!**************************!*\ + !*** ./src/glcartoon.ts ***! + \**************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + drawCartoon: () => ( + /* binding */ + B + ), + /* harmony export */ + subdivide_spline: () => ( + /* binding */ + c + ) + /* harmony export */ + }); + var s = t( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), f = t( + /*! ./WebGL/shapes */ + "./src/WebGL/shapes/index.ts" + ), _ = t( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), x = t( + /*! ./Gradient */ + "./src/Gradient.ts" + ), h = t( + /*! ./colors */ + "./src/colors.ts" + ), u = t( + /*! ./GLDraw */ + "./src/GLDraw.ts" + ), E = t( + /*! ./utilities */ + "./src/utilities.ts" + ); + function c(P, z) { + var F = [], N = P; + N = [], N.push(P[0]); + var $, k, G, H, U, V, Q, oe, ee; + for ($ = 1, k = P.length - 1; $ < k; $++) + if (U = P[$], V = P[$ + 1], U.smoothen) { + var ne = new s.Vector3((U.x + V.x) / 2, (U.y + V.y) / 2, (U.z + V.z) / 2); + ne.atom = U.atom, N.push(ne); + } else + N.push(U); + for (N.push(P[P.length - 1]), $ = -1, G = N.length; $ <= G - 3; $++) + if (H = N[$ === -1 ? 0 : $], U = N[$ + 1], V = N[$ + 2], Q = N[$ === G - 3 ? G - 1 : $ + 3], oe = new s.Vector3().subVectors(V, H).multiplyScalar(0.5), ee = new s.Vector3().subVectors(Q, U).multiplyScalar(0.5), !V.skip) + for (var me = 0; me < z; me++) { + var se = 1 / z * me, fe = U.x + se * oe.x + se * se * (-3 * U.x + 3 * V.x - 2 * oe.x - ee.x) + se * se * se * (2 * U.x - 2 * V.x + oe.x + ee.x), Ce = U.y + se * oe.y + se * se * (-3 * U.y + 3 * V.y - 2 * oe.y - ee.y) + se * se * se * (2 * U.y - 2 * V.y + oe.y + ee.y), Me = U.z + se * oe.z + se * se * (-3 * U.z + 3 * V.z - 2 * oe.z - ee.z) + se * se * se * (2 * U.z - 2 * V.z + oe.z + ee.z), Te = new s.Vector3(fe, Ce, Me); + me < z / 2 ? Te.atom = U.atom : Te.atom = V.atom, F.push(Te); + } + return F.push(N[N.length - 1]), F; + } + const C = 0.5, b = 1.3, A = 0.8, S = 0.4, n = 0.4; + function o(P, z, F, N) { + for (var $, k, G, H, U = 0, V = z.length; U < V; U++) { + H = Math.round(U * (N.length - 1) / V), G = h.CC.color(N[H]); + var Q = P.updateGeoGroup(2), oe = Q.vertexArray, ee = Q.colorArray, ne = Q.faceArray; + $ = Q.vertices, k = $ * 3, oe[k] = z[U].x, oe[k + 1] = z[U].y, oe[k + 2] = z[U].z, oe[k + 3] = F[U].x, oe[k + 4] = F[U].y, oe[k + 5] = F[U].z; + for (var me = 0; me < 6; ++me) + ee[k + 3 * me] = G.r, ee[k + 1 + 3 * me] = G.g, ee[k + 2 + 3 * me] = G.b; + if (U > 0) { + var se = [$, $ + 1, $ - 1, $ - 2], fe = Q.faceidx; + ne[fe] = se[0], ne[fe + 1] = se[1], ne[fe + 2] = se[3], ne[fe + 3] = se[1], ne[fe + 4] = se[2], ne[fe + 5] = se[3], Q.faceidx += 6; + } + Q.vertices += 2; + } + } + function w(P, z, F, N, $, k, G) { + var H, U, V, Q; + if (V = z.length, V < 2 || z[0].length < 2) + return; + for (H = 0; H < V; H++) + z[H] = c(z[H], N); + if (Q = z[0].length, !$) + return o(P, z[0], z[V - 1], F); + var oe, ee, ne, me, se, fe, Ce = [], Me = [], Te = []; + for (U = 0; U < V; U++) + Ce.push(0.25 + 1.5 * Math.sqrt((V - 1) * U - Math.pow(U, 2)) / (V - 1)), Me.push(0.5), Te.push(2 * (Math.pow(U / V, 2) - U / V) + 0.6); + var ae = []; + for (U = 0; U < V * 2 - 1; U++) + ae[U] = [U, U + 1, U + 1 - 2 * V, U - 2 * V]; + ae[V * 2 - 1] = [ + U, + U + 1 - 2 * V, + U + 1 - 4 * V, + U - 2 * V + ]; + var pe, we, ke, Ue, Ne, Be, ue, ye, ge, Se; + let ze = P.updateGeoGroup(); + for (H = 0; H < Q; H++) { + let K = P.groups, q = !1; + ze = P.updateGeoGroup(2 * V), K != P.groups && H > 0 && (H = H - 1, q = !0), Be = Math.round(H * (F.length - 1) / Q), Ne = h.CC.color(F[Be]), se = ne, fe = me, ne = [], me = [], oe = [], z[0][H].atom !== void 0 && (Ue = z[0][H].atom, G === "oval" ? ee = Ce : G === "rectangle" ? ee = Me : G === "parabola" && (ee = Te)), ee || (ee = Me); + var He, We; + for (U = 0; U < V; U++) + H < Q - 1 ? He = z[U][H + 1].clone().sub(z[U][H]) : He = z[U][H - 1].clone().sub(z[U][H]).negate(), U < V - 1 ? We = z[U + 1][H].clone().sub(z[U][H]) : We = z[U - 1][H].clone().sub(z[U][H]).negate(), oe[U] = We.cross(He).normalize().multiplyScalar($ * ee[U]); + for (U = 0; U < V; U++) + ne[U] = z[U][H].clone().add(oe[U].clone().negate()); + for (U = 0; U < V; U++) + me[U] = z[U][H].clone().add(oe[U]); + for (ue = ze.vertexArray, ye = ze.colorArray, ge = ze.faceArray, pe = ze.vertices, we = pe * 3, U = 0; U < V; U++) + ue[we + 3 * U + 0] = ne[U].x, ue[we + 3 * U + 1] = ne[U].y, ue[we + 3 * U + 2] = ne[U].z; + for (U = 0; U < V; U++) + ue[we + 3 * U + 0 + 3 * V] = me[V - 1 - U].x, ue[we + 3 * U + 1 + 3 * V] = me[V - 1 - U].y, ue[we + 3 * U + 2 + 3 * V] = me[V - 1 - U].z; + for (U = 0; U < 2 * V; ++U) + ye[we + 3 * U + 0] = Ne.r, ye[we + 3 * U + 1] = Ne.g, ye[we + 3 * U + 2] = Ne.b; + if (H > 0 && !q) { + for (U = 0; U < V * 2; U++) + Se = [ + pe + ae[U][0], + pe + ae[U][1], + pe + ae[U][2], + pe + ae[U][3] + ], ke = ze.faceidx, ge[ke] = Se[0], ge[ke + 1] = Se[1], ge[ke + 2] = Se[3], ge[ke + 3] = Se[1], ge[ke + 4] = Se[2], ge[ke + 5] = Se[3], ze.faceidx += 6; + if (Ue.clickable || Ue.hoverable) { + var Y = []; + Y.push(new f.Triangle(se[0], ne[0], ne[V - 1])), Y.push(new f.Triangle(se[0], ne[V - 1], se[V - 1])), Y.push(new f.Triangle(se[V - 1], ne[V - 1], me[V - 1])), Y.push(new f.Triangle(se[V - 1], me[V - 1], fe[V - 1])), Y.push(new f.Triangle(me[0], fe[0], fe[V - 1])), Y.push(new f.Triangle(me[V - 1], me[0], fe[V - 1])), Y.push(new f.Triangle(ne[0], se[0], fe[0])), Y.push(new f.Triangle(me[0], ne[0], fe[0])); + for (U in Y) + Ue.intersectionShape.triangle.push(Y[U]); + } + } + ze.vertices += 2 * V; + } + for (ue = ze.vertexArray, ye = ze.colorArray, ge = ze.faceArray, pe = ze.vertices, we = pe * 3, ke = ze.faceidx, H = 0; H < V - 1; H++) + Se = [H, H + 1, 2 * V - 2 - H, 2 * V - 1 - H], ke = ze.faceidx, ge[ke] = Se[0], ge[ke + 1] = Se[1], ge[ke + 2] = Se[3], ge[ke + 3] = Se[1], ge[ke + 4] = Se[2], ge[ke + 5] = Se[3], ze.faceidx += 6; + for (H = 0; H < V - 1; H++) + Se = [ + pe - 1 - H, + pe - 2 - H, + pe - 2 * V + H + 1, + pe - 2 * V + H + ], ke = ze.faceidx, ge[ke] = Se[0], ge[ke + 1] = Se[1], ge[ke + 2] = Se[3], ge[ke + 3] = Se[1], ge[ke + 4] = Se[2], ge[ke + 5] = Se[3], ze.faceidx += 6; + } + function p(P, z, F, N, $, k) { + if (!(z.length < 2)) { + var G, H; + if (G = z[0], H = z[z.length - 1], G = c(G, N), H = c(H, N), !$) + return o(P, G, H, F); + var U = [], V, Q, oe, ee, ne, me = [ + [0, 2, -6, -8], + [-4, -2, 6, 4], + [7, -1, -5, 3], + [-3, 5, 1, -7] + ], se, fe, Ce, Me, Te, ae, pe, we, ke, Ue, Ne, Be, ue, ye, ge, Se, ze; + for (we = 0, ke = G.length; we < ke; we++) { + if (Te = Math.round(we * (F.length - 1) / ke), Me = h.CC.color(F[Te]), U.push(Q = G[we]), U.push(Q), U.push(oe = H[we]), U.push(oe), we < ke - 1) { + var He = G[we + 1].clone().sub(G[we]), We = H[we].clone().sub(G[we]); + V = We.cross(He).normalize().multiplyScalar($); + } + for (U.push(ee = G[we].clone().add(V)), U.push(ee), U.push(ne = H[we].clone().add(V)), U.push(ne), Q.atom !== void 0 && (ae = Q.atom), ye = P.updateGeoGroup(8), ge = ye.vertexArray, Se = ye.colorArray, ze = ye.faceArray, se = ye.vertices, fe = se * 3, ge[fe] = Q.x, ge[fe + 1] = Q.y, ge[fe + 2] = Q.z, ge[fe + 3] = Q.x, ge[fe + 4] = Q.y, ge[fe + 5] = Q.z, ge[fe + 6] = oe.x, ge[fe + 7] = oe.y, ge[fe + 8] = oe.z, ge[fe + 9] = oe.x, ge[fe + 10] = oe.y, ge[fe + 11] = oe.z, ge[fe + 12] = ee.x, ge[fe + 13] = ee.y, ge[fe + 14] = ee.z, ge[fe + 15] = ee.x, ge[fe + 16] = ee.y, ge[fe + 17] = ee.z, ge[fe + 18] = ne.x, ge[fe + 19] = ne.y, ge[fe + 20] = ne.z, ge[fe + 21] = ne.x, ge[fe + 22] = ne.y, ge[fe + 23] = ne.z, Ue = 0; Ue < 8; ++Ue) + Se[fe + 3 * Ue] = Me.r, Se[fe + 1 + 3 * Ue] = Me.g, Se[fe + 2 + 3 * Ue] = Me.b; + if (we > 0) { + var Y = pe !== void 0 && ae !== void 0 && pe.serial !== ae.serial; + for (Ue = 0; Ue < 4; Ue++) { + var K = [ + se + me[Ue][0], + se + me[Ue][1], + se + me[Ue][2], + se + me[Ue][3] + ]; + if (Ce = ye.faceidx, ze[Ce] = K[0], ze[Ce + 1] = K[1], ze[Ce + 2] = K[3], ze[Ce + 3] = K[1], ze[Ce + 4] = K[2], ze[Ce + 5] = K[3], ye.faceidx += 6, ae.clickable || pe.clickable || ae.hoverable || pe.hoverable) { + var q = U[K[3]].clone(), de = U[K[0]].clone(), ve = U[K[2]].clone(), Ie = U[K[1]].clone(); + if (q.atom = U[K[3]].atom || null, ve.atom = U[K[2]].atom || null, de.atom = U[K[0]].atom || null, Ie.atom = U[K[1]].atom || null, Y) { + var Re = q.clone().add(de).multiplyScalar(0.5), Z = ve.clone().add(Ie).multiplyScalar(0.5), ce = q.clone().add(Ie).multiplyScalar(0.5); + Ue % 2 === 0 ? ((pe.clickable || pe.hoverable) && (Ne = new f.Triangle(Re, ce, q), Be = new f.Triangle(Z, ve, ce), ue = new f.Triangle(ce, ve, q), pe.intersectionShape.triangle.push(Ne), pe.intersectionShape.triangle.push(Be), pe.intersectionShape.triangle.push(ue)), (ae.clickable || ae.hoverable) && (Ne = new f.Triangle(de, Ie, ce), Be = new f.Triangle(Ie, Z, ce), ue = new f.Triangle(de, ce, Re), ae.intersectionShape.triangle.push(Ne), ae.intersectionShape.triangle.push(Be), ae.intersectionShape.triangle.push(ue))) : ((ae.clickable || ae.hoverable) && (Ne = new f.Triangle(Re, ce, q), Be = new f.Triangle(Z, ve, ce), ue = new f.Triangle(ce, ve, q), ae.intersectionShape.triangle.push(Ne), ae.intersectionShape.triangle.push(Be), ae.intersectionShape.triangle.push(ue)), (pe.clickable || pe.hoverable) && (Ne = new f.Triangle(de, Ie, ce), Be = new f.Triangle(Ie, Z, ce), ue = new f.Triangle(de, ce, Re), pe.intersectionShape.triangle.push(Ne), pe.intersectionShape.triangle.push(Be), pe.intersectionShape.triangle.push(ue))); + } else + (ae.clickable || ae.hoverable) && (Ne = new f.Triangle(de, Ie, q), Be = new f.Triangle(Ie, ve, q), ae.intersectionShape.triangle.push(Ne), ae.intersectionShape.triangle.push(Be)); + } + } + } + ye.vertices += 8, pe = ae; + } + var Ae = U.length - 8; + for (ye = P.updateGeoGroup(8), ge = ye.vertexArray, Se = ye.colorArray, ze = ye.faceArray, se = ye.vertices, fe = se * 3, Ce = ye.faceidx, we = 0; we < 4; we++) { + U.push(U[we * 2]), U.push(U[Ae + we * 2]); + var Fe = U[we * 2], he = U[Ae + we * 2]; + ge[fe + 6 * we] = Fe.x, ge[fe + 1 + 6 * we] = Fe.y, ge[fe + 2 + 6 * we] = Fe.z, ge[fe + 3 + 6 * we] = he.x, ge[fe + 4 + 6 * we] = he.y, ge[fe + 5 + 6 * we] = he.z, Se[fe + 6 * we] = Me.r, Se[fe + 1 + 6 * we] = Me.g, Se[fe + 2 + 6 * we] = Me.b, Se[fe + 3 + 6 * we] = Me.r, Se[fe + 4 + 6 * we] = Me.g, Se[fe + 5 + 6 * we] = Me.b; + } + Ae += 8, Ne = [se, se + 2, se + 6, se + 4], Be = [se + 1, se + 5, se + 7, se + 3], ze[Ce] = Ne[0], ze[Ce + 1] = Ne[1], ze[Ce + 2] = Ne[3], ze[Ce + 3] = Ne[1], ze[Ce + 4] = Ne[2], ze[Ce + 5] = Ne[3], ze[Ce + 6] = Be[0], ze[Ce + 7] = Be[1], ze[Ce + 8] = Be[3], ze[Ce + 9] = Be[1], ze[Ce + 10] = Be[2], ze[Ce + 11] = Be[3], ye.faceidx += 12, ye.vertices += 8; + } + } + function v(P, z, F, N, $, k, G) { + (!G || G === "default") && (G = "rectangle"), G === "edged" ? p(P, z, F, N, $) : (G === "rectangle" || G === "oval" || G === "parabola") && w(P, z, F, N, $, k, G); + } + function a(P) { + return P && P.elem === "C" && P.atom === "CA"; + } + function l(P, z) { + if (P && z && P.chain === z.chain) { + if (!P.hetflag && !z.hetflag && P.reschain === z.reschain && (P.resi === z.resi || P.resi === z.resi - 1)) + return !0; + if (P.resi < z.resi) { + var F = P.x - z.x, N = P.y - z.y, $ = P.z - z.z, k = F * F + N * N + $ * $; + if (P.atom == "CA" && z.atom == "CA" && k < 16) + return !0; + if ((P.atom == "P" || z.atom == "P") && k < 64) + return !0; + } + } + return !1; + } + function g(P, z, F, N, $) { + if (!(z == null || z.vertices == 0)) { + $ && (z.initTypedArrays(), z.setUpNormals()); + var k = new _.MeshDoubleLambertMaterial(); + k.vertexColors = _.Coloring.FaceColors, typeof F == "number" && F >= 0 && F < 1 && (k.transparent = !0, k.opacity = F), k.outline = N; + var G = new _.Mesh(z, k); + P.add(G); + } + } + function M(P, z, F, N, $, k, G, H, U) { + var V, Q, oe, ee, ne, me; + if (!(!N || !$ || !G)) { + var se = $.sub(N); + se.normalize(); + var fe = H[U]; + for (Q = U + 1; Q < H.length && (fe = H[Q], fe.atom != G.atom); Q++) + ; + if (fe = fe ? new s.Vector3(fe.x, fe.y, fe.z) : new s.Vector3(0, 0, 0), fe.sub(N), G.ss === "arrow start") { + var Ce = fe.clone().multiplyScalar(0.3).cross($); + N.add(Ce); + var Me = fe.clone().cross(se).normalize(); + se.rotateAboutVector(Me, 0.43); + } + for (G.style.cartoon.ribbon ? V = G.style.cartoon.thickness || S : G.style.cartoon.width ? V = G.style.cartoon.width : G.ss === "c" ? G.atom === "P" ? V = A : V = C : G.ss === "arrow start" ? (V = b, ne = !0) : G.ss === "arrow end" || G.ss === "h" && G.style.cartoon.tubes || G.ss === "tube start" ? V = C : V = b, k != null && se.dot(k) < 0 && se.negate(), se.multiplyScalar(V), Q = 0; Q < z; Q++) + oe = -1 + Q * 2 / (z - 1), ee = new s.Vector3(N.x + oe * se.x, N.y + oe * se.y, N.z + oe * se.z), ee.atom = G, F && G.ss === "s" && (ee.smoothen = !0), P[Q].push(ee); + if (ne) + for (se.multiplyScalar(2), Q = 0; Q < z; Q++) + oe = -1 + Q * 2 / (z - 1), ee = new s.Vector3(N.x + oe * se.x, N.y + oe * se.y, N.z + oe * se.z), ee.atom = G, ee.smoothen = !1, ee.skip = !0, P[Q].push(ee); + return me = G.style.cartoon.style || "default", P.style ? P.style != me && (console.log("Warning: a cartoon chain's strand-style is ambiguous"), P.style = "default") : P.style = me, (G.ss === "arrow start" || G.ss === "arrow end") && (G.ss = "s"), ne; + } + } + const L = { + C: !0, + CA: !0, + O: !0, + P: !0, + OP2: !0, + O2P: !0, + "O5'": !0, + "O3'": !0, + "C5'": !0, + "C2'": !0, + "O5*": !0, + "O3*": !0, + "C5*": !0, + "C2*": !0, + N1: !0, + N3: !0 + }, T = { DA: !0, DG: !0, A: !0, G: !0 }, D = { DT: !0, DC: !0, U: !0, C: !0, T: !0 }, R = { DA: !0, DG: !0, A: !0, G: !0, DT: !0, DC: !0, U: !0, C: !0, T: !0 }; + function B(P, z, F, N = 10) { + let $ = N, k = N; + var G, H, U, V, Q, oe, ee, ne, me, se, fe, Ce, Me, Te, ae, pe, we, ke, Ue = new _.Geometry(!0), Ne = new _.Geometry(!0), Be = [], ue = [], ye = 1, ge = !1, Se = {}; + for (var ze in x.Gradient.builtinGradients) + x.Gradient.builtinGradients.hasOwnProperty(ze) && (Se[ze] = new x.Gradient.builtinGradients[ze](F[1], F[0])); + var He = function(j, $e) { + return F && $e.color === "spectrum" ? $e.colorscheme in Se ? Se[$e.colorscheme].valueToHex(j.resi) : Se.sinebow.valueToHex(j.resi) : (0, E.getColorFromStyle)(j, $e).getHex(); + }; + for (ne = 0; ne < $; ne++) + ue[ne] = []; + var We = !1, Y = !1, K = []; + for (ne in z) { + if (V = z[ne], V.elem === "C" && V.atom === "CA") { + var q = l(U, V); + q && V.ss === "s" ? We = !0 : We && (U && H && U.style.cartoon.arrows && H.style.cartoon.arrows && (U.ss = "arrow end", H.ss = "arrow start"), We = !1), q && (U.ss === "h" || U.ss == "tube start") && U.style.cartoon.tubes ? !Y && U.ss != "tube start" && V.style.cartoon.tubes && (V.ss = "tube start", Y = !0) : Y && (U.ss === "tube start" ? U.ss = "tube end" : H && H.style.cartoon.tubes && (H.ss = "tube end"), Y = !1), H = U, U = V; + } + V && V.atom in L && K.push(V); + } + Y && U.style.cartoon.tubes && (U.ss = "tube end", Y = !1); + var de = function(j) { + ue[0].length > 0 && v(Ne, ue, Be, k, ee, ye, ue.style); + var $e = [], Ve = null; + if (j) { + for (ne = 0; ne < $; ne++) + $e[ne] = ue[ne][ue[ne].length - 1]; + Ve = Be[Be.length - 1]; + } + for (ue = [], ne = 0; ne < $; ne++) + ue[ne] = []; + if (Be = [], j) { + for (ne = 0; ne < $; ne++) + ue[ne].push($e[ne]); + Be.push(Ve); + } + g(P, Ne, ye, ge, !0), g(P, Ue, ye, ge, !1), Ne = new _.Geometry(!0), Ue = new _.Geometry(!0); + }; + U = void 0; + for (var ve = 0; ve < K.length; ve++) { + V = K[ve]; + var Ie = V.resn.trim(), Re = Ie in R; + if (ye = 1, G = V.style.cartoon, U && U.style.cartoon && (ye = U.style.cartoon.opacity), U && U.style.cartoon && U.style.cartoon.outline && (ge = U.style.cartoon.outline), U && U.style.cartoon && (!V.style.cartoon || U.style.cartoon.opacity != V.style.cartoon.opacity) && de(U.chain == V.chain), G.style === "trace") { + if (!V.hetflag) { + if (V.elem === "C" && V.atom === "CA" || Re && V.atom === "P" || V.atom === "BB") { + if (oe = He(V, G), (0, E.isNumeric)(G.thickness) ? ee = G.thickness : ee = S, l(U, V)) + if (oe == Q) { + var Z = h.CC.color(oe); + u.GLDraw.drawCylinder(Ue, U, V, ee, Z, 2, 2); + } else { + var ce = new s.Vector3().addVectors(U, V).multiplyScalar(0.5), Ae = h.CC.color(Q), Fe = h.CC.color(oe); + u.GLDraw.drawCylinder(Ue, U, ce, ee, Ae, 2, 0), u.GLDraw.drawCylinder(Ue, ce, V, ee, Fe, 0, 2); + } + if ((V.clickable === !0 || V.hoverable) && V.intersectionShape !== void 0) { + var he = new s.Vector3(V.x, V.y, V.z); + V.intersectionShape.sphere.push(new f.Sphere(he, ee)); + } + U = V, Q = oe; + } + } + } else { + if (a(V) || Re && (V.atom === "P" || V.atom.indexOf("O5") == 0)) { + if (ke) + if (V.ss === "tube end") + ke = !1, we = new s.Vector3(V.x, V.y, V.z), u.GLDraw.drawCylinder(Ue, pe, we, 2, h.CC.color(Q), 1, 1), V.ss = "h"; + else if (U.chain != V.chain || U.ss === "tube end") + ke = !1, U.ss = "h", we = new s.Vector3(U.x, U.y, U.z), u.GLDraw.drawCylinder(Ue, pe, we, 2, h.CC.color(Q), 1, 1); + else + continue; + if (U && (!l(U, V) || U.ss === "tube start")) { + for (U.ss === "tube start" && (ke = !0, pe = new s.Vector3(U.x, U.y, U.z), U.ss = "h"), ae && (Ce ? Te = new s.Vector3().addVectors(U, Ce).multiplyScalar(0.5) : Te = new s.Vector3(U.x, U.y, U.z), u.GLDraw.drawCylinder(Ue, Te, ae, n, h.CC.color(ae.color), 0, 2), M(ue, $, !0, Ce, Me, fe, U, K, ve), Be.push(oe), Te = null, ae = null), ue[0].length > 0 && v(Ne, ue, Be, k, ee, ye, ue.style), ue = [], ne = 0; ne < $; ne++) + ue[ne] = []; + Be = []; + } + if (U === void 0 || U.rescode != V.rescode || U.resi != V.resi) { + if (ae) { + Te = new s.Vector3().addVectors(U, V).multiplyScalar(0.5); + var Oe = Te.clone().sub(ae).multiplyScalar(0.02); + Te.add(Oe), u.GLDraw.drawCylinder(Ue, Te, ae, n, h.CC.color(ae.color), 0, 2), Te = null, ae = null; + } + oe = He(V, G), Be.push(oe), (0, E.isNumeric)(G.thickness) ? ee = G.thickness : ee = S, U = V, me = new s.Vector3(U.x, U.y, U.z), me.resi = U.resi, Q = oe; + } + (V.clickable === !0 || V.hoverable === !0) && (V.intersectionShape === void 0 || V.intersectionShape.triangle === void 0) && (V.intersectionShape = { + sphere: null, + cylinder: [], + line: [], + triangle: [] + }); + } else + a(U) && V.atom === "O" || Re && U.atom === "P" && (V.atom === "OP2" || V.atom === "O2P") || Re && U.atom.indexOf("O5") == 0 && V.atom.indexOf("C5") == 0 ? (se = new s.Vector3(V.x, V.y, V.z), se.resi = V.resi, (V.atom === "OP2" || V.atom === "O2P") && (Me = new s.Vector3(V.x, V.y, V.z))) : Re && V.atom.indexOf("O3") == 0 ? Ce = new s.Vector3(V.x, V.y, V.z) : (V.atom === "N1" && Ie in T || V.atom === "N3" && Ie in D) && (ae = new s.Vector3(V.x, V.y, V.z), ae.color = (0, E.getColorFromStyle)(V, G).getHex()); + se && me && se.resi === me.resi && (M(ue, $, !0, me, se, fe, U, K, ve), fe = se, me = null, se = null, Be.push(oe)); + } + } + ae && (Ce ? Te = new s.Vector3().addVectors(U, Ce).multiplyScalar(0.5) : Te = new s.Vector3(U.x, U.y, U.z), u.GLDraw.drawCylinder(Ue, Te, ae, n, h.CC.color(ae.color), 0, 2), M(ue, $, !0, Ce, Me, fe, U, K, ve), Be.push(oe)), de(!1); + } + } + ), + /***/ + "./src/index.ts": ( + /*!**********************!*\ + !*** ./src/index.ts ***! + \**********************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + CAP: () => ( + /* reexport safe */ + n.CAP + ), + /* harmony export */ + CC: () => ( + /* reexport safe */ + f.CC + ), + /* harmony export */ + Color: () => ( + /* reexport safe */ + f.Color + ), + /* harmony export */ + CustomLinear: () => ( + /* reexport safe */ + s.CustomLinear + ), + /* harmony export */ + Cylinder: () => ( + /* reexport safe */ + E.Cylinder + ), + /* harmony export */ + GLDraw: () => ( + /* reexport safe */ + n.GLDraw + ), + /* harmony export */ + GLModel: () => ( + /* reexport safe */ + w.GLModel + ), + /* harmony export */ + GLShape: () => ( + /* reexport safe */ + S.GLShape + ), + /* harmony export */ + GLViewer: () => ( + /* reexport safe */ + p.GLViewer + ), + /* harmony export */ + GLVolumetricRender: () => ( + /* reexport safe */ + A.GLVolumetricRender + ), + /* harmony export */ + Gradient: () => ( + /* reexport safe */ + s.Gradient + ), + /* harmony export */ + GradientType: () => ( + /* reexport safe */ + s.GradientType + ), + /* harmony export */ + Label: () => ( + /* reexport safe */ + _.Label + ), + /* harmony export */ + LabelCount: () => ( + /* reexport safe */ + _.LabelCount + ), + /* harmony export */ + MarchingCube: () => ( + /* reexport safe */ + C.MarchingCube + ), + /* harmony export */ + MarchingCubeInitializer: () => ( + /* reexport safe */ + C.MarchingCubeInitializer + ), + /* harmony export */ + Matrix3: () => ( + /* reexport safe */ + u.Matrix3 + ), + /* harmony export */ + Matrix4: () => ( + /* reexport safe */ + u.Matrix4 + ), + /* harmony export */ + Parsers: () => ( + /* reexport safe */ + h.Parsers + ), + /* harmony export */ + PausableTimer: () => ( + /* reexport safe */ + c.PausableTimer + ), + /* harmony export */ + PointGrid: () => ( + /* reexport safe */ + C.PointGrid + ), + /* harmony export */ + ProteinSurface: () => ( + /* reexport safe */ + C.ProteinSurface + ), + /* harmony export */ + Quaternion: () => ( + /* reexport safe */ + u.Quaternion + ), + /* harmony export */ + ROYGB: () => ( + /* reexport safe */ + s.ROYGB + ), + /* harmony export */ + RWB: () => ( + /* reexport safe */ + s.RWB + ), + /* harmony export */ + Ray: () => ( + /* reexport safe */ + u.Ray + ), + /* harmony export */ + Sinebow: () => ( + /* reexport safe */ + s.Sinebow + ), + /* harmony export */ + Sphere: () => ( + /* reexport safe */ + E.Sphere + ), + /* harmony export */ + SurfaceType: () => ( + /* reexport safe */ + C.SurfaceType + ), + /* harmony export */ + Triangle: () => ( + /* reexport safe */ + E.Triangle + ), + /* harmony export */ + Vector2: () => ( + /* reexport safe */ + u.Vector2 + ), + /* harmony export */ + Vector3: () => ( + /* reexport safe */ + u.Vector3 + ), + /* harmony export */ + VolumeData: () => ( + /* reexport safe */ + b.VolumeData + ), + /* harmony export */ + adjustVolumeStyle: () => ( + /* reexport safe */ + c.adjustVolumeStyle + ), + /* harmony export */ + applyPartialCharges: () => ( + /* reexport safe */ + x.applyPartialCharges + ), + /* harmony export */ + autoinit: () => ( + /* reexport safe */ + v.autoinit + ), + /* harmony export */ + autoload: () => ( + /* reexport safe */ + v.autoload + ), + /* harmony export */ + base64ToArray: () => ( + /* reexport safe */ + c.base64ToArray + ), + /* harmony export */ + bondLength: () => ( + /* reexport safe */ + h.bondLength + ), + /* harmony export */ + builtinColorSchemes: () => ( + /* reexport safe */ + f.builtinColorSchemes + ), + /* harmony export */ + builtinGradients: () => ( + /* reexport safe */ + s.builtinGradients + ), + /* harmony export */ + chains: () => ( + /* reexport safe */ + f.chains + ), + /* harmony export */ + clamp: () => ( + /* reexport safe */ + u.clamp + ), + /* harmony export */ + conversionMatrix3: () => ( + /* reexport safe */ + u.conversionMatrix3 + ), + /* harmony export */ + createStereoViewer: () => ( + /* reexport safe */ + p.createStereoViewer + ), + /* harmony export */ + createViewer: () => ( + /* reexport safe */ + p.createViewer + ), + /* harmony export */ + createViewerGrid: () => ( + /* reexport safe */ + p.createViewerGrid + ), + /* harmony export */ + deepCopy: () => ( + /* reexport safe */ + c.deepCopy + ), + /* harmony export */ + degToRad: () => ( + /* reexport safe */ + u.degToRad + ), + /* harmony export */ + download: () => ( + /* reexport safe */ + c.download + ), + /* harmony export */ + drawCartoon: () => ( + /* reexport safe */ + o.drawCartoon + ), + /* harmony export */ + elementColors: () => ( + /* reexport safe */ + f.elementColors + ), + /* harmony export */ + extend: () => ( + /* reexport safe */ + c.extend + ), + /* harmony export */ + get: () => ( + /* reexport safe */ + c.get + ), + /* harmony export */ + getAtomProperty: () => ( + /* reexport safe */ + c.getAtomProperty + ), + /* harmony export */ + getColorFromStyle: () => ( + /* reexport safe */ + c.getColorFromStyle + ), + /* harmony export */ + getElement: () => ( + /* reexport safe */ + c.getElement + ), + /* harmony export */ + getExtent: () => ( + /* reexport safe */ + c.getExtent + ), + /* harmony export */ + getGradient: () => ( + /* reexport safe */ + s.getGradient + ), + /* harmony export */ + getPropertyRange: () => ( + /* reexport safe */ + c.getPropertyRange + ), + /* harmony export */ + getbin: () => ( + /* reexport safe */ + c.getbin + ), + /* harmony export */ + htmlColors: () => ( + /* reexport safe */ + f.htmlColors + ), + /* harmony export */ + isEmptyObject: () => ( + /* reexport safe */ + c.isEmptyObject + ), + /* harmony export */ + isNumeric: () => ( + /* reexport safe */ + c.isNumeric + ), + /* harmony export */ + makeFunction: () => ( + /* reexport safe */ + c.makeFunction + ), + /* harmony export */ + mergeGeos: () => ( + /* reexport safe */ + c.mergeGeos + ), + /* harmony export */ + normalizeValue: () => ( + /* reexport safe */ + s.normalizeValue + ), + /* harmony export */ + partialCharges: () => ( + /* reexport safe */ + x.partialCharges + ), + /* harmony export */ + processing_autoinit: () => ( + /* reexport safe */ + v.processing_autoinit + ), + /* harmony export */ + residues: () => ( + /* reexport safe */ + f.residues + ), + /* harmony export */ + setBondLength: () => ( + /* reexport safe */ + h.setBondLength + ), + /* harmony export */ + setSyncSurface: () => ( + /* reexport safe */ + C.setSyncSurface + ), + /* harmony export */ + specStringToObject: () => ( + /* reexport safe */ + c.specStringToObject + ), + /* harmony export */ + splitMesh: () => ( + /* reexport safe */ + S.splitMesh + ), + /* harmony export */ + ssColors: () => ( + /* reexport safe */ + f.ssColors + ), + /* harmony export */ + subdivide_spline: () => ( + /* reexport safe */ + o.subdivide_spline + ), + /* harmony export */ + syncSurface: () => ( + /* reexport safe */ + C.syncSurface + ), + /* harmony export */ + viewers: () => ( + /* reexport safe */ + v.viewers + ) + /* harmony export */ + }); + var s = t( + /*! ./Gradient */ + "./src/Gradient.ts" + ), f = t( + /*! ./colors */ + "./src/colors.ts" + ), _ = t( + /*! ./Label */ + "./src/Label.ts" + ), x = t( + /*! ./partialCharges */ + "./src/partialCharges.ts" + ), h = t( + /*! ./parsers */ + "./src/parsers/index.ts" + ), u = t( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), E = t( + /*! ./WebGL/shapes */ + "./src/WebGL/shapes/index.ts" + ), c = t( + /*! ./utilities */ + "./src/utilities.ts" + ), C = t( + /*! ./ProteinSurface4 */ + "./src/ProteinSurface4.ts" + ), b = t( + /*! ./VolumeData */ + "./src/VolumeData.ts" + ), A = t( + /*! ./VolumetricRender */ + "./src/VolumetricRender.ts" + ), S = t( + /*! ./GLShape */ + "./src/GLShape.ts" + ), n = t( + /*! ./GLDraw */ + "./src/GLDraw.ts" + ), o = t( + /*! ./glcartoon */ + "./src/glcartoon.ts" + ), w = t( + /*! ./GLModel */ + "./src/GLModel.ts" + ), p = t( + /*! ./GLViewer */ + "./src/GLViewer.ts" + ), v = t( + /*! ./autoload */ + "./src/autoload.ts" + ); + t( + /*! ./specs */ + "./src/specs.ts" + ), window && (window.$3Dmol = e); + } + ), + /***/ + "./src/parsers/CDJSON.ts": ( + /*!*******************************!*\ + !*** ./src/parsers/CDJSON.ts ***! + \*******************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + CDJSON: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + function s(f, _) { + var x = [[]]; + typeof f == "string" && (f = JSON.parse(f)); + for (var h = f.m, u = h[0].a, E = h[0].b, c = h[0].s, C = _ !== void 0 && _.parseStyle !== void 0 ? _.parseStyle : c !== void 0, b = x[x.length - 1].length, A = 0; A < u.length; A++) { + var S = u[A], n = {}; + n.id = S.i, n.x = S.x, n.y = S.y, n.z = S.z || 0, n.bonds = [], n.bondOrder = []; + var o = S.l || "C"; + n.elem = o[0].toUpperCase() + o.substring(1).toLowerCase(), n.serial = x[x.length - 1].length, C && (n.style = c[S.s || 0]), x[x.length - 1].push(n); + } + for (let w = 0; w < E.length; w++) { + let p = E[w], v = p.b + b, a = p.e + b, l = p.o || 1, g = x[x.length - 1][v], M = x[x.length - 1][a]; + g.bonds.push(a), g.bondOrder.push(l), M.bonds.push(v), M.bondOrder.push(l); + } + return x; + } + } + ), + /***/ + "./src/parsers/CIF.ts": ( + /*!****************************!*\ + !*** ./src/parsers/CIF.ts ***! + \****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + CIF: () => ( + /* binding */ + h + ) + /* harmony export */ + }); + var s = t( + /*! ./utils/assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ), f = t( + /*! ./utils/computeSecondaryStructure */ + "./src/parsers/utils/computeSecondaryStructure.ts" + ), _ = t( + /*! ./utils/processSymmetries */ + "./src/parsers/utils/processSymmetries.ts" + ), x = t( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ); + function h(u, E = {}) { + var c = [], C = !E.doAssembly, b = c.modelData = [], A = E.assignBonds === void 0 ? !0 : E.assignBonds, S = function(K, q, de, ve) { + return new x.Vector3(q, de, ve).applyMatrix3(K); + }; + function n(K, q) { + for (var de = [], ve = 0, Ie = 0; Ie < K.length; ) { + for (; K.substring(Ie, Ie + q.length) !== q && Ie < K.length; ) { + if (K[Ie] === "'") + for (Ie++; Ie < K.length && K[Ie] !== "'"; ) + Ie++; + else if (K[Ie] === '"') + for (Ie++; Ie < K.length && K[Ie] !== '"'; ) + Ie++; + Ie++; + } + de.push(K.substring(ve, Ie)), ve = Ie = Ie + q.length; + } + return de; + } + var o = u.split(/\r?\n|\r/), w = [], p = !1; + for (let K = 0; K < o.length; K++) { + var v = o[K].split("#")[0]; + if (p ? v[0] === ";" && (p = !1) : v[0] === ";" && (p = !0), p || v !== "") { + if (!p && (v = v.trim(), v[0] === "_")) { + var a = v.split(/\s/)[0].indexOf("."); + if (a > -1) { + let q = v.split(""); + q[a] = "_", v = q.join(""), v = v.substring(0, a) + "_" + v.substring(a + 1); + } + } + w.push(v); + } + } + for (var l = 0; l < w.length; ) { + for (; !w[l].startsWith("data_") || w[l] === "data_global"; ) + l++; + l++; + for (var g = {}; l < w.length && !w[l].startsWith("data_"); ) + if (w[l][0] === void 0) + l++; + else if (w[l][0] === "_") { + var M = w[l].split(/\s/)[0].toLowerCase(), L = g[M] = g[M] || [], T = w[l].substring(w[l].indexOf(M) + M.length); + if (T === "") + if (l++, w[l][0] === ";") { + var D = w[l].substring(1); + for (l++; w[l] !== ";"; ) + D = D + ` +` + w[l], l++; + L.push(D); + } else + L.push(w[l]); + else + L.push(T.trim()); + l++; + } else if (w[l].substring(0, 5) === "loop_") { + l++; + for (var R = []; w[l] === "" || w[l][0] === "_"; ) { + if (w[l] !== "") { + let K = w[l].split(/\s/)[0].toLowerCase(), q = g[K] = g[K] || []; + R.push(q); + } + l++; + } + for (var B = 0; l < w.length && w[l][0] !== "_" && !w[l].startsWith("loop_") && !w[l].startsWith("data_"); ) { + let K = n(w[l], " "); + for (var P = 0; P < K.length; P++) + K[P] !== "" && (R[B].push(K[P]), B = (B + 1) % R.length); + l++; + } + } else + l++; + b.push({ symmetries: [] }), c.push([]); + var z = g._atom_site_id !== void 0 ? g._atom_site_id.length : g._atom_site_label.length, F; + if (g._cell_length_a !== void 0) { + var N = parseFloat(g._cell_length_a), $ = parseFloat(g._cell_length_b), k = parseFloat(g._cell_length_c), G = parseFloat(g._cell_angle_alpha) || 90, H = parseFloat(g._cell_angle_beta) || 90, U = parseFloat(g._cell_angle_gamma) || 90; + F = (0, x.conversionMatrix3)(N, $, k, G, H, U), b[b.length - 1].cryst = { + a: N, + b: $, + c: k, + alpha: G, + beta: H, + gamma: U + }; + } + for (var V = 0; V < z; V++) + if (!(g._atom_site_group_pdb !== void 0 && g._atom_site_group_pdb[V] === "TER")) { + var Q = {}; + if (g._atom_site_cartn_x !== void 0) + Q.x = parseFloat(g._atom_site_cartn_x[V]), Q.y = parseFloat(g._atom_site_cartn_y[V]), Q.z = parseFloat(g._atom_site_cartn_z[V]); + else { + var oe = S(F, parseFloat(g._atom_site_fract_x[V]), parseFloat(g._atom_site_fract_y[V]), parseFloat(g._atom_site_fract_z[V])); + Q.x = oe.x, Q.y = oe.y, Q.z = oe.z; + } + Q.chain = g._atom_site_auth_asym_id ? g._atom_site_auth_asym_id[V] : void 0, Q.resi = g._atom_site_auth_seq_id ? parseInt(g._atom_site_auth_seq_id[V]) : void 0, Q.resn = g._atom_site_auth_comp_id ? g._atom_site_auth_comp_id[V].trim() : void 0, Q.atom = g._atom_site_auth_atom_id ? g._atom_site_auth_atom_id[V].replace(/"/gm, "") : void 0, Q.hetflag = !g._atom_site_group_pdb || g._atom_site_group_pdb[V] === "HETA" || g._atom_site_group_pdb[V] === "HETATM"; + var ee = "X"; + g._atom_site_type_symbol ? ee = g._atom_site_type_symbol[V].replace(/\(?\+?\d+.*/, "") : g._atom_site_label && (ee = g._atom_site_label[V].split("_")[0].replace(/\(?\d+.*/, "")), Q.elem = ee[0].toUpperCase() + ee.substring(1, 2).toLowerCase(), Q.bonds = [], Q.ss = "c", Q.serial = V, Q.bondOrder = [], Q.properties = {}, c[c.length - 1].push(Q); + } + if (g._pdbx_struct_oper_list_id !== void 0 && !C) + for (let K = 0; K < g._pdbx_struct_oper_list_id.length; K++) { + var ne = parseFloat(g["_pdbx_struct_oper_list_matrix[1][1]"][K]), me = parseFloat(g["_pdbx_struct_oper_list_matrix[1][2]"][K]), se = parseFloat(g["_pdbx_struct_oper_list_matrix[1][3]"][K]), fe = parseFloat(g["_pdbx_struct_oper_list_vector[1]"][K]), Ce = parseFloat(g["_pdbx_struct_oper_list_matrix[2][1]"][K]), Me = parseFloat(g["_pdbx_struct_oper_list_matrix[2][2]"][K]), Te = parseFloat(g["_pdbx_struct_oper_list_matrix[2][3]"][K]), ae = parseFloat(g["_pdbx_struct_oper_list_vector[2]"][K]), pe = parseFloat(g["_pdbx_struct_oper_list_matrix[3][1]"][K]), we = parseFloat(g["_pdbx_struct_oper_list_matrix[3][2]"][K]), ke = parseFloat(g["_pdbx_struct_oper_list_matrix[3][3]"][K]), Ue = parseFloat(g["_pdbx_struct_oper_list_vector[3]"][K]), Ne = new x.Matrix4(ne, me, se, fe, Ce, Me, Te, ae, pe, we, ke, Ue); + b[b.length - 1].symmetries.push(Ne); + } + var Be = function(K) { + var q = K.match("-"); + K = K.replace(/[-xyz]/g, ""); + var de = K.split("/"), ve, Ie; + return de[1] === void 0 ? Ie = 1 : Ie = parseInt(de[1]), de[0] === "" ? ve = 1 : ve = parseInt(de[0]), ve / Ie * (q ? -1 : 1); + }; + if (g._symmetry_equiv_pos_as_xyz !== void 0 && !C) + for (var ue = 0; ue < g._symmetry_equiv_pos_as_xyz.length; ue++) { + var ye = g._symmetry_equiv_pos_as_xyz[ue].replace(/["' ]/g, ""), ge = ye.split(",").map(function(q) { + return q.replace(/-/g, "+-"); + }); + let K = new x.Matrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + for (let q = 0; q < 3; q++) { + var Se = ge[q].split("+"); + for (let de = 0; de < Se.length; de++) { + var ze = Se[de]; + if (ze !== "") { + var He = Be(ze); + ze.match("x") ? K.elements[q + 0] = He : ze.match("y") ? K.elements[q + 4] = He : ze.match("z") ? K.elements[q + 8] = He : K.elements[q + 12] = He; + } + } + } + var We = F.getMatrix4(), Y = new x.Matrix4().getInverse(We, !0); + K = new x.Matrix4().multiplyMatrices(K, Y), K = new x.Matrix4().multiplyMatrices(We, K), b[b.length - 1].symmetries.push(K); + } + } + for (let K = 0; K < c.length; K++) + A && (0, s.assignBonds)(c[K]), (0, f.computeSecondaryStructure)(c[K], E.hbondCutoff), (0, _.processSymmetries)(b[K].symmetries, c[K], E, b[K].cryst), E.duplicateAssemblyAtoms && !E.dontConnectDuplicatedAtoms && A && (0, s.assignBonds)(c[K]); + return c; + } + } + ), + /***/ + "./src/parsers/CUBE.ts": ( + /*!*****************************!*\ + !*** ./src/parsers/CUBE.ts ***! + \*****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + CUBE: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ), f = t( + /*! ./utils/assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ), _ = t( + /*! ./utils/anumToSymbol */ + "./src/parsers/utils/anumToSymbol.ts" + ); + function x(h, u) { + u = u || {}; + var E = [[]], c = h.split(/\r?\n/), C = u.assignBonds === void 0 ? !0 : u.assignBonds; + if (c.length < 6) + return E; + var b = c[2].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), A = Math.abs(parseFloat(b[0])); + let S = {}; + var n = S.origin = new s.Vector3(parseFloat(b[1]), parseFloat(b[2]), parseFloat(b[3])); + b = c[3].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), b = c[3].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var o = b[0] > 0 ? 0.529177 : 1; + n.multiplyScalar(o); + var w = Math.abs(b[0]), p = new s.Vector3(parseFloat(b[1]), parseFloat(b[2]), parseFloat(b[3])).multiplyScalar(o); + b = c[4].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var v = Math.abs(b[0]), a = new s.Vector3(parseFloat(b[1]), parseFloat(b[2]), parseFloat(b[3])).multiplyScalar(o); + b = c[5].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var l = Math.abs(b[0]), g = new s.Vector3(parseFloat(b[1]), parseFloat(b[2]), parseFloat(b[3])).multiplyScalar(o); + if (S.size = { x: w, y: v, z: l }, S.unit = new s.Vector3(p.x, a.y, g.z), p.y != 0 || p.z != 0 || a.x != 0 || a.z != 0 || g.x != 0 || g.y != 0) { + S.matrix4 = new s.Matrix4(p.x, a.x, g.x, 0, p.y, a.y, g.y, 0, p.z, a.z, g.z, 0, 0, 0, 0, 1); + let P = new s.Matrix4().makeTranslation(n.x, n.y, n.z); + S.matrix4 = S.matrix4.multiplyMatrices(P, S.matrix4), S.matrix = S.matrix4.matrix3FromTopLeft(), S.origin = new s.Vector3(0, 0, 0), S.unit = new s.Vector3(1, 1, 1); + } + E.modelData = [{ cryst: S }], c = c.splice(6, A); + for (var M = E[E.length - 1].length, L = M + c.length, T = M; T < L; ++T) { + var D = {}; + D.serial = T; + var R = c[T - M], B = R.replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + D.elem = _.anumToSymbol[B[0]], D.x = parseFloat(B[2]) * o, D.y = parseFloat(B[3]) * o, D.z = parseFloat(B[4]) * o, D.hetflag = !0, D.bonds = [], D.bondOrder = [], D.properties = {}, E[E.length - 1].push(D); + } + if (C) + for (let P = 0; P < E.length; P++) + (0, f.assignBonds)(E[P]); + return E; + } + } + ), + /***/ + "./src/parsers/GRO.ts": ( + /*!****************************!*\ + !*** ./src/parsers/GRO.ts ***! + \****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + GRO: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ./utils/assignPDBBonds */ + "./src/parsers/utils/assignPDBBonds.ts" + ), f = t( + /*! ./utils/atomNameToElem */ + "./src/parsers/utils/atomNameToElem.ts" + ); + function _(x) { + for (var h = [], u = x.split(/\r?\n|\r/); u.length > 0 && !(u.length < 3); ) { + var E = parseInt(u[1]); + if (isNaN(E) || E <= 0 || u.length < E + 3) + break; + var c = []; + h.push(c); + for (var C = 2, b = c.length, A = b + E, S = b; S < A; S++) { + var n = u[C++], o = {}; + o.serial = S, o.atom = n.slice(10, 15).trim(), o.elem = (0, f.atomNameToElem)(o.atom, !0), o.x = 10 * parseFloat(n.slice(20, 28)), o.y = 10 * parseFloat(n.slice(28, 36)), o.z = 10 * parseFloat(n.slice(36, 44)), o.resi = parseInt(n.slice(0, 5)), o.resn = n.slice(5, 10).trim(), o.bonds = [], o.bondOrder = [], o.properties = {}, n.length > 44 && (o.dx = 10 * parseFloat(n.slice(44, 52)), o.dy = 10 * parseFloat(n.slice(52, 60)), o.dz = 10 * parseFloat(n.slice(60, 68))), c[S] = o; + } + if (u.length <= C + 3) { + var w = u[C++], p = w.trim().split(/\s+/); + if (p.length == 3) { + for (var v = 0; v < 3; v++) + p[v] = parseFloat(p[v]) * 10; + h.box = p; + } + } + u.splice(0, ++C); + } + for (let a = 0; a < h.length; a++) + (0, s.assignPDBBonds)(h[a]); + return h; + } + } + ), + /***/ + "./src/parsers/LAMMPSTRJ.ts": ( + /*!**********************************!*\ + !*** ./src/parsers/LAMMPSTRJ.ts ***! + \**********************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + LAMMPSTRJ: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./utils/assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ); + function f(_, x) { + for (var h = [], u = { + id: "serial", + type: "atom", + element: "elem", + q: "charge", + radius: "radius", + x: "x", + xu: "x", + xs: "x", + xsu: "x", + y: "y", + yu: "y", + ys: "y", + ysu: "y", + z: "z", + zu: "z", + zs: "z", + zsu: "z" + }, E = _.split(/\r?\n|\r/), c = 0, C = 0, b = 0; b < E.length - 9; ) { + for (var A = b; A < E.length; A++) + if (E[A].match(/ITEM: NUMBER OF ATOMS/) && (C = parseInt(E[A + 1])), E[A].match(/ITEM: ATOMS/)) { + c = A + 1; + break; + } + var S = E[c - 1].replace("ITEM: ATOMS ", "").split(" "); + h.push([]); + for (let l = c; l < c + C; l++) { + for (var n = {}, o = {}, w = E[l].split(" "), p = 0; p < w.length; p++) { + var v = u[S[p]]; + v != null && (v == "serial" ? n[v] = parseInt(w[p]) : v == "x" || v == "y" || v === "z" ? n[v] = parseFloat(w[p]) : v == "charge" || v == "radius" ? o[v] = parseFloat(w[p]) : n[v] = w[p]), n.properties = o, n.bonds = [], n.bondOrder = []; + } + h[h.length - 1][l - c] = n; + } + b = c + C - 1; + } + if (x.assignBonds) + for (var a = 0; a < h.length; a++) + (0, s.assignBonds)(h[a]); + return h; + } + } + ), + /***/ + "./src/parsers/MMTF.ts": ( + /*!*****************************!*\ + !*** ./src/parsers/MMTF.ts ***! + \*****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + MMTFparser: () => ( + /* binding */ + C + ) + /* harmony export */ + }); + var s = t( + /*! ../utilities */ + "./src/utilities.ts" + ), f = t( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ), _ = t( + /*! ./utils/computeSecondaryStructure */ + "./src/parsers/utils/computeSecondaryStructure.ts" + ), x = t( + /*! ./utils/processSymmetries */ + "./src/parsers/utils/processSymmetries.ts" + ), h = t( + /*! ./src/vendor/mmtf.js */ + "./src/vendor/mmtf.js" + ), u = function(b) { + return String.fromCharCode.apply(null, b).replace(/\0/g, ""); + }, E = function(b) { + return b == 0 || b == 2 || b == 4 ? "h" : b == 3 ? "s" : "c"; + }; + let c = /* @__PURE__ */ new Set([ + "D-SACCHARIDE", + "D-SACCHARIDE 1,4 AND 1,4 LINKING", + "D-SACCHARIDE 1,4 AND 1,6 LINKING", + "L-SACCHARIDE", + "L-SACCHARIDE 1,4 AND 1,4 LINKING", + "L-SACCHARIDE 1,4 AND 1,6 LINKING", + "NON-POLYMER", + "OTHER", + "PEPTIDE-LIKE", + "SACCHARIDE" + ]); + function C(b, A) { + var S = !A.keepH, n = A.altLoc ? A.altLoc : "A", o = !!A.noSecondaryStructure, w = !A.noComputeSecondaryStructure, p = !A.doAssembly, v = A.assemblyIndex ? A.assemblyIndex : 0; + typeof b == "string" ? b = (0, s.base64ToArray)(b) : b = new Uint8Array(b); + var a = h.decode(b), l = [[]], g = l.modelData = [], M = 0, L = 0, T = 0, D = a.secStructList, R = a.bFactorList, B = a.altLocList, P = a.occupancyList, z = a.bondAtomList, F = a.bondOrderList, N = a.numModels; + if (N == 0) + return l; + A.multimodel || (N = 1); + var $, k, G, H, U, V, Q = []; + if (!p && a.bioAssemblyList && a.bioAssemblyList.length > 0) { + var oe = a.bioAssemblyList[v].transformList; + for ($ = 0, V = oe.length; $ < V; $++) { + var ee = new f.Matrix4(oe[$].matrix); + ee.transpose(), Q.push(ee); + } + } + var ne = null; + if (a.unitCell) { + var me = a.unitCell; + ne = { a: me[0], b: me[1], c: me[2], alpha: me[3], beta: me[4], gamma: me[5] }; + } + let se = []; + a.entityList.forEach((Ee) => { + Ee.chainIndexList.forEach((X) => { + se[X] = Ee.type == "polymer"; + }); + }); + var fe = 0; + for (U = 0; U < N; U++) { + var Ce = a.chainsPerModel[U], Me = l[l.length - 1], Te = []; + for (g.push({ symmetries: Q, cryst: ne }), $ = 0; $ < Ce; ++$) { + var ae = a.groupsPerChain[M], pe = u(a.chainIdList.subarray(M * 4, M * 4 + 4)); + a.chainNameList && (pe = u(a.chainNameList.subarray(M * 4, M * 4 + 4))); + var we = L, ke = ""; + for (k = 0; k < ae; ++k) { + var Ue = a.groupList[a.groupTypeList[L]], Ne = Ue.atomNameList.length, Be = 0, ue = !1, ye = !1; + if (D) { + Be = D[L]; + var ge = E(Be); + (L == 0 || ge != ke) && (ue = !0), ke = ge; + var Se = L + 1; + (Se >= D.length || E(D[Se] != ge)) && (ye = !0); + } + var ze = a.groupIdList[L], He = Ue.groupName; + let Ee = Ue.chemCompType; + var We = T; + let X = c.has(Ee) || !se[M]; + for (G = 0; G < Ne; ++G) { + var Y = Ue.elementList[G]; + if (S && Y == "H") { + T += 1; + continue; + } + var K = ""; + R && (K = R[T]); + var q = ""; + B && B[T] && (q = String.fromCharCode(B[T])); + var de = ""; + if (P && (de = P[T]), q != "" && q != n && n != "*") { + T += 1; + continue; + } + var ve = a.atomIdList[T], Ie = Ue.atomNameList[G], Re = 0; + Ue.atomChargeList && (Re = Ue.atomChargeList[G]); + var Z = a.xCoordList[T], ce = a.yCoordList[T], Ae = a.zCoordList[T]; + Te[T] = Me.length, Me.push({ + resn: He, + x: Z, + y: ce, + z: Ae, + elem: Y, + hetflag: X, + chain: pe, + resi: ze, + icode: q, + rescode: ze + (q != " " ? "^" + q : ""), + // resi + // and + // icode + serial: ve, + altLoc: q, + index: T, + atom: Ie, + bonds: [], + ss: E(Be), + ssbegin: ue, + ssend: ye, + bondOrder: [], + properties: { charge: Re, occupancy: de }, + b: K + }), T += 1; + } + var Fe = Ue.bondAtomList; + for (G = 0, H = Ue.bondOrderList.length; G < H; ++G) { + var he = We + Fe[G * 2], Oe = We + Fe[G * 2 + 1], j = Ue.bondOrderList[G], $e = Te[he], Ve = Te[Oe], I = Me[$e], be = Me[Ve]; + I && be && (I.bonds.push(Ve), I.bondOrder.push(j), be.bonds.push($e), be.bondOrder.push(j)); + } + L += 1; + } + for (L = we, k = 0; k < ae; ++k) + L += 1; + M += 1; + } + if (z) + for (let Ee = fe, X = z.length; Ee < X; Ee += 2) { + let le = z[Ee], Le = z[Ee + 1], Ze = F ? F[Ee / 2] : 1; + if (le >= T) { + fe = Ee; + break; + } + let Ke = Te[le], je = Te[Le], Je = Me[Ke], Lt = Me[je]; + Je && Lt && (Je.bonds.push(je), Je.bondOrder.push(Ze), Lt.bonds.push(Ke), Lt.bondOrder.push(Ze)); + } + A.multimodel && (A.onemol || l.push([])); + } + if (!p) + for (let Ee = 0; Ee < l.length; Ee++) + (0, x.processSymmetries)(g[Ee].symmetries, l[Ee], A, g[Ee].cryst); + return w && !o && (0, _.computeSecondaryStructure)(l, A.hbondCutoff), l; + } + } + ), + /***/ + "./src/parsers/MOL2.ts": ( + /*!*****************************!*\ + !*** ./src/parsers/MOL2.ts ***! + \*****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + MOL2: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + let s = { + "C.1": "C", + C1: "C", + "C.2": "C", + C2: "C", + "C.3": "C", + C3: "C", + "C.ar": "C", + Car: "C", + "C.cat": "C", + Ccat: "C", + "H.spc": "H", + Hspc: "H", + "H.t3p": "H", + Ht3p: "H", + "N.1": "N", + N1: "N", + "N.2": "N", + N2: "N", + "N.3": "N", + N3: "N", + "N.4": "N", + N4: "N", + "N.am": "N", + Nam: "N", + "N.ar": "N", + Nar: "N", + "N.p13": "N", + Np13: "N", + "O.2": "O", + O2: "O", + "O.3": "O", + O3: "O", + "O.co2": "O", + Oco2: "O", + "O.spc": "O", + Ospc: "O", + "O.t3p": "O", + Ot3p: "O", + "P.3": "P", + P3: "P", + "S.2": "S", + S2: "S", + "S.3": "S", + S3: "S", + "S.o": "S", + So: "S", + "S.o2": "S", + So2: "S" + }; + function f(_, x) { + var h = [[]], u = !1; + typeof x.keepH < "u" && (u = !x.keepH); + var E = _.search(/@MOLECULE/), c = _.search(/@ATOM/); + if (E == -1 || c == -1) + return h; + for (var C = _.substring(E).split(/\r?\n|\r/); C.length > 0; ) { + var b = [], A = C[2].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), S = parseInt(A[0]), n = 0; + A.length > 1 && (n = parseInt(A[1])); + var o = 4, w; + for (w = 3; w < C.length; w++) + if (C[w] == "@ATOM") { + o = w + 1; + break; + } + var p = h[h.length - 1].length, v = p + S, a; + for (w = p; w < v; w++) { + a = C[o++], A = a.replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var l = {}, g = A[5]; + if (s[g] !== void 0 ? g = s[g] : (g = g.split(".")[0], g = g[0].toUpperCase() + g.substring(1).toLowerCase()), l.atom = A[1], l.elem = g, !(l.elem == "H" && u)) { + var M = h[h.length - 1].length, L = parseInt(A[0]); + l.serial = L, l.x = parseFloat(A[2]), l.y = parseFloat(A[3]), l.z = parseFloat(A[4]), l.atom = A[5]; + var T = parseFloat(A[8]); + l.index = M, l.bonds = [], l.bondOrder = [], l.properties = { + charge: T, + partialCharge: T + }, b[L] = M, h[h.length - 1].push(l); + } + } + for (var D = !1; o < C.length; ) + if (C[o++] == "@BOND") { + D = !0; + break; + } + if (D && n) + for (w = 0; w < n; w++) { + a = C[o++], A = a.replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var R = parseInt(A[1]), B = h[h.length - 1][b[R]], P = parseInt(A[2]), z = h[h.length - 1][b[P]], F = parseInt(A[3]); + isNaN(F) && (F = 1), B !== void 0 && z !== void 0 && (B.bonds.push(b[P]), B.bondOrder.push(F), z.bonds.push(b[R]), z.bondOrder.push(F)); + } + if (x.multimodel) { + x.onemol || h.push([]), C.splice(0, o), _ = C.join(` +`); + continue; + } else + break; + } + return h; + } + } + ), + /***/ + "./src/parsers/PDB.ts": ( + /*!****************************!*\ + !*** ./src/parsers/PDB.ts ***! + \****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + PDB: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./utils/getSinglePDB */ + "./src/parsers/utils/getSinglePDB.ts" + ); + function f(_, x) { + x = x || {}; + var h = [], u = {}; + h.modelData = []; + for (var E = _.split(/\r?\n|\r/); E.length > 0; ) { + var c = (0, s.getSinglePDB)(E, x, u), C = c[0], b = c[1]; + if (E = c[2], C.length != 0) { + if (x.multimodel && x.onemol && h.length > 0) + for (var A = h[0].length, S = 0; S < C.length; S++) { + var n = C[S]; + n.index = S; + for (var o = 0; o < n.bonds.length; o++) + n.bonds[o] += A; + h[0].push(n); + } + else + h.modelData.push(b), h.push(C); + if (!x.multimodel) + break; + } + } + return h; + } + } + ), + /***/ + "./src/parsers/PQR.ts": ( + /*!****************************!*\ + !*** ./src/parsers/PQR.ts ***! + \****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + PQR: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ./utils/assignPDBBonds */ + "./src/parsers/utils/assignPDBBonds.ts" + ), f = t( + /*! ./utils/computeSecondaryStructure */ + "./src/parsers/utils/computeSecondaryStructure.ts" + ); + function _(x, h) { + var u = [[]], E = !h.noSecondaryStructure; + u.modelData = [{ symmetries: [] }]; + var c = [], C = x.split(/\r?\n|\r/), b; + for (let D = 0; D < C.length; D++) { + b = C[D].replace(/^\s*/, ""); + var A = b.substring(0, 6); + if (A.indexOf("END") == 0) + if (h.multimodel) { + h.onemol || u.push([]); + continue; + } else + break; + else if (A == "ATOM " || A == "HETATM") { + var S; + let R = parseInt(b.substring(6, 11)), B = b.substring(12, 16).replace(/ /g, ""), P = b.substring(17, 20).trim(), z = b.substring(21, 22), F = parseInt(b.substring(22, 26)); + var n = b.substring(30).trim().split(/\s+/), o = parseFloat(n[0]), w = parseFloat(n[1]), p = parseFloat(n[2]), v = parseFloat(n[3]), a = parseFloat(n[4]), l = B[0]; + B.length > 1 && B[1].toUpperCase() != B[1] && (l = B.substring(0, 2)), b[0] == "H" ? S = !0 : S = !1, c[R] = u[u.length - 1].length, u[u.length - 1].push({ + resn: P, + x: o, + y: w, + z: p, + elem: l, + hetflag: S, + chain: z, + resi: F, + serial: R, + atom: B, + bonds: [], + ss: "c", + bondOrder: [], + properties: { + charge: v, + partialCharge: v, + radius: a + }, + pdbline: b + }); + } else if (A == "CONECT") { + var g = parseInt(b.substring(6, 11)), M = u[u.length - 1][c[g]]; + for (let R = 0; R < 4; R++) { + var L = parseInt(b.substring([11, 16, 21, 26][R], [11, 16, 21, 26][R] + 5)), T = u[u.length - 1][c[L]]; + M !== void 0 && T !== void 0 && (M.bonds.push(c[L]), M.bondOrder.push(1)); + } + } + } + for (let D = 0; D < u.length; D++) + (0, s.assignPDBBonds)(u[D]), E && (0, f.computeSecondaryStructure)(u[D], h.hbondCutoff); + return u; + } + } + ), + /***/ + "./src/parsers/PRMTOP.ts": ( + /*!*******************************!*\ + !*** ./src/parsers/PRMTOP.ts ***! + \*******************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + PRMTOP: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + function s(f) { + var _ = [], x, h = 0, u = f.split(/\r?\n|\r/); + if (u.length > 0 && u[0].includes("VERSION")) { + var E = u.filter(function(o) { + return o.includes("POINTERS") || o.includes("ATOM_NAME") || o.includes("CHARGE") || o.includes("RADII") || o.includes("BONDS_INC_HYDROGEN") || o.includes("BONDS_WITHOUT_HYDROGEN"); + }), c = S("POINTERS"); + if (c == -1) + return []; + var C = n(c), b = parseInt(u[c + 1].slice(0, C[1])); + if (isNaN(b) || b <= 0) + return []; + if (c = S("ATOM_NAME"), c == -1) + return []; + C = n(c); + var A = C[0]; + for (let o = 0; o < b / C[0]; o++) { + o == parseInt(b / C[0]) && (A = b % C[0]); + for (let w = 0; w < A; w++) { + let p = {}, v = { charge: "", radii: "" }; + p.serial = h, p.x = 0, p.y = 0, p.z = 0, p.atom = u[c + 1].slice(C[1] * w, C[1] * (w + 1)), p.elem = u[c + 1].slice(C[1] * w, C[1] * w + 1), p.properties = v, p.bonds = [], p.bondOrder = [], _.push(p), h++; + } + c++; + } + if (c = S("CHARGE"), c != -1) { + C = n(c), h = 0, A = C[0]; + for (let o = 0; o < b / C[0]; o++) { + o == parseInt(b / C[0]) && (A = b % C[0]); + for (let w = 0; w < A; w++) + _[h].properties.charge = parseFloat(u[c + 1].slice(C[1] * w, C[1] * (w + 1))), h++; + c++; + } + } + if (c = S("RADII"), c != -1) { + C = n(c), h = 0, A = C[0]; + for (let o = 0; o < b / C[0]; o++) { + o == parseInt(b / C[0]) && (A = b % C[0]); + for (let w = 0; w < A; w++) + _[h].properties.radii = parseFloat(u[c + 1].slice(C[1] * w, C[1] * (w + 1))), h++; + c++; + } + } + if (c = S("BONDS_WITHOUT_HYDROGEN"), c != -1) + for (C = n(c), h = 0, A = C[0], c = c + 1; !u[c].match(/^%FLAG/); ) { + u[c + 1].match(/^%FLAG/) && (A = b % C[0]); + for (let o = 0; o < A; o++) + h % 3 == 0 ? x = parseInt(u[c].slice(C[1] * o, C[1] * (o + 1)) / 3) : h % 3 == 1 && _[x].bonds.push(parseInt(u[c].slice(C[1] * o, C[1] * (o + 1)) / 3)), h++; + c++; + } + if (c = S("BONDS_INC_HYDROGEN"), c != -1) + for (C = n(c), h = 0, A = C[0], c = c + 1; !u[c].match(/^%FLAG/); ) { + u[c + 1].match(/^%FLAG/) && (A = b % C[0]); + for (let o = 0; o < A; o++) + h % 3 == 0 ? x = parseInt(u[c].slice(C[1] * o, C[1] * (o + 1)) / 3) : h % 3 == 1 && _[x].bonds.push(parseInt(u[c].slice(C[1] * o, C[1] * (o + 1)) / 3)), h++; + c++; + } + } else + return []; + function S(o) { + var w = u.indexOf(E.filter(function(p) { + return p.includes(o); + })[0]); + if (Number.isInteger(w) && w > 0) { + for (; !u[w].includes("FORMAT"); ) + w++; + return w; + } else + return -1; + } + function n(o) { + var w = u[o].match(/\((\d*)\S*/), p = u[o].match(/[a-zA-Z](\d*)\)\s*/); + return p == null && (p = u[o].match(/[a-zA-Z](\d*)\.\d*\)\s*/)), [w[1], p[1]]; + } + return [_]; + } + } + ), + /***/ + "./src/parsers/SDF.ts": ( + /*!****************************!*\ + !*** ./src/parsers/SDF.ts ***! + \****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + SDF: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = function(x, h) { + var u = [[]], E = !1; + for (typeof h.keepH < "u" && (E = !h.keepH); x.length > 0 && !(x.length < 4); ) { + var c = parseInt(x[3].substring(0, 3)); + if (isNaN(c) || c <= 0) + break; + var C = parseInt(x[3].substring(3, 6)), b = 4; + if (x.length < 4 + c + C) + break; + var A = [], S = u[u.length - 1].length, n = S + c, o, w; + for (o = S; o < n; o++, b++) { + w = x[b]; + var p = {}, v = w.substring(31, 34).replace(/ /g, ""); + p.atom = p.elem = v[0].toUpperCase() + v.substring(1).toLowerCase(), (p.elem !== "H" || !E) && (p.serial = o, A[o] = u[u.length - 1].length, p.x = parseFloat(w.substring(0, 10)), p.y = parseFloat(w.substring(10, 20)), p.z = parseFloat(w.substring(20, 30)), p.hetflag = !0, p.bonds = [], p.bondOrder = [], p.properties = {}, p.index = u[u.length - 1].length, u[u.length - 1].push(p)); + } + for (o = 0; o < C; o++, b++) { + w = x[b]; + var a = A[parseInt(w.substring(0, 3)) - 1 + S], l = A[parseInt(w.substring(3, 6)) - 1 + S], g = parseFloat(w.substring(6)); + typeof a < "u" && typeof l < "u" && (u[u.length - 1][a].bonds.push(l), u[u.length - 1][a].bondOrder.push(g), u[u.length - 1][l].bonds.push(a), u[u.length - 1][l].bondOrder.push(g)); + } + if (h.multimodel) { + for (h.onemol || u.push([]); x[b] !== "$$$$" && b < x.length; ) + b++; + x.splice(0, ++b); + } else + break; + } + return u; + }, f = function(x, h) { + var u = [[]], E = !1; + for (typeof h.keepH < "u" && (E = !h.keepH); x.length > 0 && !(x.length < 8 || !x[4].startsWith("M V30 BEGIN CTAB") || !x[5].startsWith("M V30 COUNTS") || x[5].length < 14); ) { + var c = x[5].substring(13).match(/\S+/g); + if (c.length < 2) + break; + var C = parseInt(c[0]); + if (isNaN(C) || C <= 0) + break; + var b = parseInt(c[1]), A = 7; + if (x.length < 8 + C + b) + break; + var S = [], n = u[u.length - 1].length, o = n + C, w, p; + for (w = n; w < o; w++, A++) { + p = x[A]; + var v = p.substring(6).match(/\S+/g); + if (v.length > 4) { + var a = {}, l = v[1].replace(/ /g, ""); + a.atom = a.elem = l[0].toUpperCase() + l.substring(1).toLowerCase(), (a.elem !== "H" || !E) && (a.serial = w, S[w] = u[u.length - 1].length, a.x = parseFloat(v[2]), a.y = parseFloat(v[3]), a.z = parseFloat(v[4]), a.hetflag = !0, a.bonds = [], a.bondOrder = [], a.properties = {}, a.index = u[u.length - 1].length, u[u.length - 1].push(a)); + } + } + if (x[A] === "M V30 END ATOM") + A++; + else + break; + if (b !== 0 && x[A] === "M V30 BEGIN BOND") + A++; + else + break; + for (w = 0; w < b; w++, A++) { + p = x[A]; + var g = p.substring(6).match(/\S+/g); + if (g.length > 3) { + var M = S[parseInt(g[2]) - 1 + n], L = S[parseInt(g[3]) - 1 + n], T = parseFloat(g[1]); + typeof M < "u" && typeof L < "u" && (u[u.length - 1][M].bonds.push(L), u[u.length - 1][M].bondOrder.push(T), u[u.length - 1][L].bonds.push(M), u[u.length - 1][L].bondOrder.push(T)); + } + } + if (h.multimodel) { + for (h.onemol || u.push([]); x[A] !== "$$$$" && A < x.length; ) + A++; + x.splice(0, ++A); + } else + break; + } + return u; + }; + function _(x, h) { + var u = "V2000", E = x.split(/\r?\n|\r/); + return E.length > 3 && E[3].length > 38 && (u = E[3].substring(34, 39)), u === "V2000" ? s(E, h) : u === "V3000" ? f(E, h) : [[""]]; + } + } + ), + /***/ + "./src/parsers/VASP.ts": ( + /*!*****************************!*\ + !*** ./src/parsers/VASP.ts ***! + \*****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + VASP: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ); + function f(_) { + var x = [[]], h = {}, u = _.replace(/^\s+/, "").split(/\r?\n/); + if (u.length < 3) + return x; + if (u[1].match(/\d+/)) + h.length = parseFloat(u[1]); + else + return console.log("Warning: second line of the vasp structure file must be a number"), x; + if (h.length < 0) + return console.log("Warning: Vasp implementation for negative lattice lengths is not yet available"), x; + h.xVec = new Float32Array(u[2].replace(/^\s+/, "").split(/\s+/)), h.yVec = new Float32Array(u[3].replace(/^\s+/, "").split(/\s+/)), h.zVec = new Float32Array(u[4].replace(/^\s+/, "").split(/\s+/)); + var E = new s.Matrix3(h.xVec[0], h.xVec[1], h.xVec[2], h.yVec[0], h.yVec[1], h.yVec[2], h.zVec[0], h.zVec[1], h.zVec[2]); + E.multiplyScalar(h.length), x.modelData = [{ symmetries: [], cryst: { matrix: E } }]; + var c = u[5].replace(/\s+/, "").replace(/\s+$/, "").split(/\s+/), C = new Int16Array(u[6].replace(/^\s+/, "").split(/\s+/)), b = u[7].replace(/\s+/, ""); + if (b.match(/C/)) + b = "cartesian"; + else if (b.match(/D/)) + b = "direct"; + else + return console.log("Warning: Unknown vasp mode in POSCAR file: mode must be either C(artesian) or D(irect)"), x; + if (c.length != C.length) + return console.log("Warning: declaration of atomary species wrong:"), console.log(c), console.log(C), x; + u.splice(0, 8); + for (var A = 0, S = 0, n = c.length; S < n; S++) { + for (var o = c[S], w = 0, p = C[S]; w < p; w++) { + var v = new Float32Array(u[A + w].replace(/^\s+/, "").split(/\s+/)), a = {}; + a.elem = o, b == "cartesian" ? (a.x = h.length * v[0], a.y = h.length * v[1], a.z = h.length * v[2]) : (a.x = h.length * (v[0] * h.xVec[0] + v[1] * h.yVec[0] + v[2] * h.zVec[0]), a.y = h.length * (v[0] * h.xVec[1] + v[1] * h.yVec[1] + v[2] * h.zVec[1]), a.z = h.length * (v[0] * h.xVec[2] + v[1] * h.yVec[2] + v[2] * h.zVec[2])), a.bonds = [], x[0].push(a); + } + A += C[S]; + } + return x; + } + } + ), + /***/ + "./src/parsers/XYZ.ts": ( + /*!****************************!*\ + !*** ./src/parsers/XYZ.ts ***! + \****************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + XYZ: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var s = t( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ), f = t( + /*! ./utils/assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ); + function _(x, h) { + h = h || {}; + for (var u = [[]], E = h.assignBonds === void 0 ? !0 : h.assignBonds, c = x.split(/\r?\n|\r/); c.length > 0 && !(c.length < 3); ) { + var C = parseInt(c[0]); + if (isNaN(C) || C <= 0 || c.length < C + 2) + break; + var b = /Lattice\s*=\s*["\{\}]([^"\{\}]+)["\{\}]\s*/gi, A = b.exec(c[1]); + if (A != null && A.length > 1) { + var S = new Float32Array(A[1].split(/\s+/)), n = new s.Matrix3(S[0], S[3], S[6], S[1], S[4], S[7], S[2], S[5], S[8]); + u.modelData = [{ cryst: { matrix: n } }]; + } + for (var o = 2, w = u[u.length - 1].length, p = w + C, v = w; v < p; v++) { + var a = c[o++], l = a.replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), g = {}; + g.serial = v; + var M = l[0]; + g.atom = g.elem = M[0].toUpperCase() + M.substring(1, 2).toLowerCase(), g.x = parseFloat(l[1]), g.y = parseFloat(l[2]), g.z = parseFloat(l[3]), g.hetflag = !0, g.bonds = [], g.bondOrder = [], g.properties = {}, u[u.length - 1][v] = g, l.length >= 7 && (g.dx = parseFloat(l[4]), g.dy = parseFloat(l[5]), g.dz = parseFloat(l[6])); + } + if (h.multimodel) + u.push([]), c.splice(0, o); + else + break; + } + if (E) + for (let T = 0; T < u.length; T++) + (0, f.assignBonds)(u[T]); + if (h.onemol) { + var L = u; + u = [], u.push(L[0]); + for (let T = 1; T < L.length; T++) { + let D = u[0].length; + for (let R = 0; R < L[T].length; R++) { + let B = L[T][R]; + for (let P = 0; P < B.bonds.length; P++) + B.bonds[P] = B.bonds[P] + D; + B.index = u[0].length, B.serial = u[0].length, u[0].push(B); + } + } + } + return u; + } + } + ), + /***/ + "./src/parsers/index.ts": ( + /*!******************************!*\ + !*** ./src/parsers/index.ts ***! + \******************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Parsers: () => ( + /* binding */ + w + ), + /* harmony export */ + bondLength: () => ( + /* reexport safe */ + o.bondLength + ), + /* harmony export */ + setBondLength: () => ( + /* reexport safe */ + o.setBondLength + ) + /* harmony export */ + }); + var s = t( + /*! ./VASP */ + "./src/parsers/VASP.ts" + ), f = t( + /*! ./CUBE */ + "./src/parsers/CUBE.ts" + ), _ = t( + /*! ./XYZ */ + "./src/parsers/XYZ.ts" + ), x = t( + /*! ./SDF */ + "./src/parsers/SDF.ts" + ), h = t( + /*! ./CDJSON */ + "./src/parsers/CDJSON.ts" + ), u = t( + /*! ./CIF */ + "./src/parsers/CIF.ts" + ), E = t( + /*! ./MOL2 */ + "./src/parsers/MOL2.ts" + ), c = t( + /*! ./PDB */ + "./src/parsers/PDB.ts" + ), C = t( + /*! ./PQR */ + "./src/parsers/PQR.ts" + ), b = t( + /*! ./MMTF */ + "./src/parsers/MMTF.ts" + ), A = t( + /*! ./PRMTOP */ + "./src/parsers/PRMTOP.ts" + ), S = t( + /*! ./GRO */ + "./src/parsers/GRO.ts" + ), n = t( + /*! ./LAMMPSTRJ */ + "./src/parsers/LAMMPSTRJ.ts" + ), o = t( + /*! ./utils/bondLength */ + "./src/parsers/utils/bondLength.ts" + ); + const w = { + vasp: s.VASP, + VASP: s.VASP, + cube: f.CUBE, + CUBE: f.CUBE, + xyz: _.XYZ, + XYZ: _.XYZ, + sdf: x.SDF, + SDF: x.SDF, + json: h.CDJSON, + cdjson: h.CDJSON, + CDJSON: h.CDJSON, + mcif: u.CIF, + cif: u.CIF, + CIF: u.CIF, + mol2: E.MOL2, + MOL2: E.MOL2, + pdb: c.PDB, + PDB: c.PDB, + pdbqt: c.PDB, + PDBQT: c.PDB, + pqr: C.PQR, + PQR: C.PQR, + mmtf: b.MMTFparser, + MMTF: b.MMTFparser, + prmtop: A.PRMTOP, + PRMTOP: A.PRMTOP, + gro: S.GRO, + GRO: S.GRO, + lammpstrj: n.LAMMPSTRJ, + LAMMPSTRJ: n.LAMMPSTRJ + }; + } + ), + /***/ + "./src/parsers/utils/anumToSymbol.ts": ( + /*!*******************************************!*\ + !*** ./src/parsers/utils/anumToSymbol.ts ***! + \*******************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + anumToSymbol: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + const s = { + 1: "H", + 2: "He", + 3: "Li", + 4: "Be", + 5: "B", + 6: "C", + 7: "N", + 8: "O", + 9: "F", + 10: "Ne", + 11: "Na", + 12: "Mg", + 13: "Al", + 14: "Si", + 15: "P", + 16: "S", + 17: "Cl", + 18: "Ar", + 19: "K", + 20: "Ca", + 21: "Sc", + 22: "Ti", + 23: "V", + 24: "Cr", + 25: "Mn", + 26: "Fe", + 27: "Co", + 28: "Ni", + 29: "Cu", + 30: "Zn", + 31: "Ga", + 32: "Ge", + 33: "As", + 34: "Se", + 35: "Br", + 36: "Kr", + 37: "Rb", + 38: "Sr", + 39: "Y", + 40: "Zr", + 41: "Nb", + 42: "Mo", + 43: "Tc", + 44: "Ru", + 45: "Rh", + 46: "Pd", + 47: "Ag", + 48: "Cd", + 49: "In", + 50: "Sn", + 51: "Sb", + 52: "Te", + 53: "I", + 54: "Xe", + 55: "Cs", + 56: "Ba", + 71: "Lu", + 72: "Hf", + 73: "Ta", + 74: "W", + 75: "Re", + 76: "Os", + 77: "Ir", + 78: "Pt", + 79: "Au", + 80: "Hg", + 81: "Tl", + 82: "Pb", + 83: "Bi", + 84: "Po", + 85: "At", + 86: "Rn", + 87: "Fr", + 88: "Ra", + 104: "Rf", + 105: "Db", + 106: "Sg", + 107: "Bh", + 108: "Hs", + 109: "Mt", + 110: "Ds", + 111: "Rg", + 112: "Cn", + 113: "Nh", + 114: "Fl", + 115: "Mc", + 116: "Lv", + 117: "Ts", + 118: "Og", + 57: "La", + 58: "Ce", + 59: "Pr", + 60: "Nd", + 61: "Pm", + 62: "Sm", + 63: "Eu", + 64: "Gd", + 65: "Tb", + 66: "Dy", + 67: "Ho", + 68: "Er", + 69: "Tm", + 70: "Yb", + 89: "Ac", + 90: "Th", + 91: "Pa", + 92: "U", + 93: "Np", + 94: "Pu", + 95: "Am", + 96: "Cm", + 97: "Bk", + 98: "Cf", + 99: "Es", + 100: "Fm", + 101: "Md", + 102: "No" + }; + } + ), + /***/ + "./src/parsers/utils/areConnected.ts": ( + /*!*******************************************!*\ + !*** ./src/parsers/utils/areConnected.ts ***! + \*******************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + areConnected: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./bondLength */ + "./src/parsers/utils/bondLength.ts" + ); + function f(_, x) { + var h = (0, s.bondLength)(_.elem) + (0, s.bondLength)(x.elem); + h += 0.25, h *= h; + var u = _.x - x.x; + if (u *= u, u > h) + return !1; + var E = _.y - x.y; + if (E *= E, E > h) + return !1; + var c = _.z - x.z; + if (c *= c, c > h) + return !1; + var C = u + E + c; + return isNaN(C) || C < 0.5 || C > h ? !1 : !(_.altLoc != x.altLoc && _.altLoc != " " && x.altLoc != " "); + } + } + ), + /***/ + "./src/parsers/utils/assignBackboneHBonds.ts": ( + /*!***************************************************!*\ + !*** ./src/parsers/utils/assignBackboneHBonds.ts ***! + \***************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + assignBackboneHBonds: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + function s(f, _) { + let x = _ || 3.2, h = x * x, u = []; + for (let o = 0, w = f.length; o < w; o++) { + f[o].index = o; + var E = f[o]; + !E.hetflag && (E.atom === "N" || E.atom === "O") && (u.push(E), E.hbondOther = null, E.hbondDistanceSq = Number.POSITIVE_INFINITY); + } + u.sort(function(o, w) { + return o.z - w.z; + }); + for (let o = 0, w = u.length; o < w; o++) { + var c = u[o]; + for (let p = o + 1; p < w; p++) { + var C = u[p], b = C.z - c.z; + if (b > x) + break; + if (C.atom != c.atom) { + var A = Math.abs(C.y - c.y); + if (!(A > x)) { + var S = Math.abs(C.x - c.x); + if (!(S > x)) { + var n = S * S + A * A + b * b; + n > h || C.chain == c.chain && Math.abs(C.resi - c.resi) < 4 || (n < c.hbondDistanceSq && (c.hbondOther = C, c.hbondDistanceSq = n), n < C.hbondDistanceSq && (C.hbondOther = c, C.hbondDistanceSq = n)); + } + } + } + } + } + } + } + ), + /***/ + "./src/parsers/utils/assignBonds.ts": ( + /*!******************************************!*\ + !*** ./src/parsers/utils/assignBonds.ts ***! + \******************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + assignBonds: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./areConnected */ + "./src/parsers/utils/areConnected.ts" + ); + function f(_) { + for (var x = 0, h = _.length; x < h; x++) + _[x].index || (_[x].index = x); + for (var u = {}, E = 4.95, c = 0; c < _.length; c++) { + var C = _[c], b = Math.floor(C.x / E), A = Math.floor(C.y / E), S = Math.floor(C.z / E); + u[b] || (u[b] = {}), u[b][A] || (u[b][A] = {}), u[b][A][S] || (u[b][A][S] = []), u[b][A][S].push(C); + } + var n = function(w, p) { + for (var v = 0; v < w.length; v++) + for (var a = w[v], l = 0; l < p.length; l++) { + var g = p[l]; + if ((0, s.areConnected)(a, g)) { + var M = a.bonds.indexOf(g.index), L = g.bonds.indexOf(a.index); + M == -1 && L == -1 ? (a.bonds.push(g.index), a.bondOrder.push(1), g.bonds.push(a.index), g.bondOrder.push(1)) : M == -1 ? (a.bonds.push(g.index), a.bondOrder.push(g.bondOrder[L])) : L == -1 && (g.bonds.push(a.index), g.bondOrder.push(a.bondOrder[M])); + } + } + }, o = [ + { x: 0, y: 0, z: 1 }, + { x: 0, y: 1, z: -1 }, + { x: 0, y: 1, z: 0 }, + { x: 0, y: 1, z: 1 }, + { x: 1, y: -1, z: -1 }, + { x: 1, y: -1, z: 0 }, + { x: 1, y: -1, z: 1 }, + { x: 1, y: 0, z: -1 }, + { x: 1, y: 0, z: 0 }, + { x: 1, y: 0, z: 1 }, + { x: 1, y: 1, z: -1 }, + { x: 1, y: 1, z: 0 }, + { x: 1, y: 1, z: 1 } + ]; + for (let w in u) { + let p = parseInt(w); + for (let v in u[p]) { + let a = parseInt(v); + for (let l in u[p][a]) { + let g = parseInt(l), M = u[p][a][g]; + for (let L = 0; L < M.length; L++) { + let T = M[L]; + for (let D = L + 1; D < M.length; D++) { + let R = M[D]; + (0, s.areConnected)(T, R) && T.bonds.indexOf(R.index) == -1 && (T.bonds.push(R.index), T.bondOrder.push(1), R.bonds.push(T.index), R.bondOrder.push(1)); + } + } + for (let L = 0; L < o.length; L++) { + let T = o[L]; + if (!u[p + T.x] || !u[p + T.x][a + T.y] || !u[p + T.x][a + T.y][g + T.z]) + continue; + let D = u[p + T.x][a + T.y][g + T.z]; + n(M, D); + } + } + } + } + } + } + ), + /***/ + "./src/parsers/utils/assignPDBBonds.ts": ( + /*!*********************************************!*\ + !*** ./src/parsers/utils/assignPDBBonds.ts ***! + \*********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + assignPDBBonds: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var s = t( + /*! ./areConnected */ + "./src/parsers/utils/areConnected.ts" + ), f = t( + /*! ./assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ), _ = t( + /*! ./standardResidues */ + "./src/parsers/utils/standardResidues.ts" + ); + function x(h) { + var u = [], E = [], c, C; + for (c = 0, C = h.length; c < C; c++) { + var b = h[c]; + b.index = c, b.hetflag || !_.standardResidues.has(b.resn) ? E.push(b) : u.push(b); + } + (0, f.assignBonds)(E), u.sort(function(v, a) { + return v.chain != a.chain ? v.chain < a.chain ? -1 : 1 : v.resi - a.resi; + }); + var A = -1, S = -1, n; + for (c = 0, C = u.length; c < C; c++) { + var o = u[c]; + o.resi !== A && (A = o.resi, n || S++, n = !1), o.reschain = S; + for (var w = c + 1; w < u.length; w++) { + var p = u[w]; + if (p.chain != o.chain || p.resi - o.resi > 1) + break; + (0, s.areConnected)(o, p) && (o.bonds.indexOf(p.index) === -1 && (o.bonds.push(p.index), o.bondOrder.push(1), p.bonds.push(o.index), p.bondOrder.push(1)), o.resi !== p.resi && (n = !0)); + } + } + } + } + ), + /***/ + "./src/parsers/utils/atomNameToElem.ts": ( + /*!*********************************************!*\ + !*** ./src/parsers/utils/atomNameToElem.ts ***! + \*********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + atomNameToElem: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./bondLength */ + "./src/parsers/utils/bondLength.ts" + ); + function f(_, x) { + var h = _.replace(/ /g, ""); + return h.length > 0 && h[0] == "H" && h != "Hg" && h != "He" && h != "Hf" && h != "Hs" && h != "Ho" && (h = "H"), h.length > 1 && (h = h[0].toUpperCase() + h.substring(1).toLowerCase(), typeof s.bondTable[h] > "u" ? h = h[0] : x && (h == "Ca" || h == "Cd") && (h = "C")), h; + } + } + ), + /***/ + "./src/parsers/utils/bondLength.ts": ( + /*!*****************************************!*\ + !*** ./src/parsers/utils/bondLength.ts ***! + \*****************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + bondLength: () => ( + /* binding */ + f + ), + /* harmony export */ + bondTable: () => ( + /* binding */ + s + ), + /* harmony export */ + setBondLength: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + let s = { + H: 0.37, + He: 0.32, + Li: 1.34, + Be: 0.9, + B: 0.82, + C: 0.77, + N: 0.75, + O: 0.73, + F: 0.71, + Ne: 0.69, + Na: 1.54, + Mg: 1.3, + Al: 1.18, + Si: 1.11, + P: 1.06, + S: 1.02, + Cl: 0.99, + Ar: 0.97, + K: 1.96, + Ca: 1.74, + Sc: 1.44, + Ti: 1.56, + V: 1.25, + /* Cr */ + Mn: 1.39, + Fe: 1.25, + Co: 1.26, + Ni: 1.21, + Cu: 1.38, + Zn: 1.31, + Ga: 1.26, + Ge: 1.22, + /* As */ + Se: 1.16, + Br: 1.14, + Kr: 1.1, + Rb: 2.11, + Sr: 1.92, + Y: 1.62, + Zr: 1.48, + Nb: 1.37, + Mo: 1.45, + Tc: 1.56, + Ru: 1.26, + Rh: 1.35, + Pd: 1.31, + Ag: 1.53, + Cd: 1.48, + In: 1.44, + Sn: 1.41, + Sb: 1.38, + Te: 1.35, + I: 1.33, + Xe: 1.3, + Cs: 2.25, + Ba: 1.98, + Lu: 1.6, + Hf: 1.5, + Ta: 1.38, + W: 1.46, + Re: 1.59, + Os: 1.44, + Ir: 1.37, + Pt: 1.28, + Au: 1.44, + Hg: 1.49, + Tl: 1.48, + Pb: 1.47, + Bi: 1.46, + /* Po */ + /* At */ + Rn: 1.45 + // None of the bottom row or any of the Lanthanides have bond lengths + }; + function f(x) { + return s[x] || 1.6; + } + function _(x, h) { + h < 0 && (h = 0), s[x] = h; + } + } + ), + /***/ + "./src/parsers/utils/computeSecondaryStructure.ts": ( + /*!********************************************************!*\ + !*** ./src/parsers/utils/computeSecondaryStructure.ts ***! + \********************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + computeSecondaryStructure: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ./assignBackboneHBonds */ + "./src/parsers/utils/assignBackboneHBonds.ts" + ); + function f(_, x) { + (0, s.assignBackboneHBonds)(_, x); + var h = {}, u, E, c, C, b, A; + for (u = 0, E = _.length; u < E; u++) + if (b = _[u], typeof h[b.chain] > "u" && (h[b.chain] = []), isFinite(b.hbondDistanceSq)) { + var S = b.hbondOther; + typeof h[S.chain] > "u" && (h[S.chain] = []), Math.abs(S.resi - b.resi) === 4 && (h[b.chain][b.resi] = "h"); + } + for (c in h) + for (C = 1; C < h[c].length - 1; C++) { + var n = h[c][C - 1], o = h[c][C + 1]; + A = h[c][C], n == "h" && n == o && A != n && (h[c][C] = n); + } + for (u = 0, E = _.length; u < E; u++) + b = _[u], isFinite(b.hbondDistanceSq) && h[b.chain][b.resi] != "h" && b.ss != "h" && (h[b.chain][b.resi] = "maybesheet"); + for (let w = 0, p = _.length; w < p; w++) + if (b = _[w], isFinite(b.hbondDistanceSq) && h[b.chain][b.resi] == "maybesheet") { + let v = b.hbondOther, a = h[v.chain][v.resi]; + (a == "maybesheet" || a == "s") && (h[b.chain][b.resi] = "s", h[v.chain][v.resi] = "s"); + } + for (let w in h) { + for (let p = 1; p < h[w].length - 1; p++) { + let v = h[w][p - 1], a = h[w][p + 1]; + A = h[w][p], v == "s" && v == a && A != v && (h[w][p] = v); + } + for (let p = 0; p < h[w].length; p++) { + let v = h[w][p]; + (v == "h" || v == "s") && h[w][p - 1] != v && h[w][p + 1] != v && delete h[w][p]; + } + } + for (u = 0, E = _.length; u < E; u++) + b = _[u], A = h[b.chain][b.resi], delete b.hbondOther, delete b.hbondDistanceSq, !(typeof A > "u" || A == "maybesheet") && (b.ss = A, h[b.chain][b.resi - 1] != A && (b.ssbegin = !0), h[b.chain][b.resi + 1] != A && (b.ssend = !0)); + } + } + ), + /***/ + "./src/parsers/utils/getSinglePDB.ts": ( + /*!*******************************************!*\ + !*** ./src/parsers/utils/getSinglePDB.ts ***! + \*******************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + getSinglePDB: () => ( + /* binding */ + C + ) + /* harmony export */ + }); + var s = t( + /*! ../../WebGL */ + "./src/WebGL/index.ts" + ), f = t( + /*! ./atomNameToElem */ + "./src/parsers/utils/atomNameToElem.ts" + ), _ = t( + /*! ./bondLength */ + "./src/parsers/utils/bondLength.ts" + ), x = t( + /*! ./computeSecondaryStructure */ + "./src/parsers/utils/computeSecondaryStructure.ts" + ), h = t( + /*! ./isEmpty */ + "./src/parsers/utils/isEmpty.ts" + ), u = t( + /*! ./processSymmetries */ + "./src/parsers/utils/processSymmetries.ts" + ), E = t( + /*! ./assignPDBBonds */ + "./src/parsers/utils/assignPDBBonds.ts" + ), c = t( + /*! ./validateBonds */ + "./src/parsers/utils/validateBonds.ts" + ); + function C(b, A, S) { + var n = [], o = A.assignBonds === void 0 ? !0 : A.assignBonds, w = !A.keepH, p = !!A.noSecondaryStructure, v = !A.noComputeSecondaryStructure, a = !A.doAssembly, l = A.altLoc ? A.altLoc : "A", g = { symmetries: [] }, M, L = [], T = [], D, R = {}; + for (let He = 0; He < b.length; He++) { + D = b[He].replace(/^\s*/, ""); + var B = D.substring(0, 6), P, z, F; + if (B.indexOf("END") == 0) { + if (L = b.slice(He + 1), B == "END") + for (var N in S) + S.hasOwnProperty(N) && delete S[N]; + break; + } else if (B == "ATOM " || B == "HETATM") { + var $, k, G, H, U, V, Q, oe, ee, ne, me, se; + if (me = D.substring(16, 17), me != " " && me != l && l != "*" || (ne = parseInt(D.substring(6, 11)), M = D.substring(12, 16).replace(/ /g, ""), $ = D.substring(17, 20).replace(/ /g, ""), k = D.substring(21, 22), G = parseInt(D.substring(22, 26)), H = D.substring(26, 27), U = parseFloat(D.substring(30, 38)), V = parseFloat(D.substring(38, 46)), Q = parseFloat(D.substring(46, 54)), se = parseFloat(D.substring(60, 68)), ee = D.substring(76, 78).replace(/ /g, ""), ee === "" || typeof _.bondTable[ee] > "u" ? ee = (0, f.atomNameToElem)(D.substring(12, 14), D[0] == "A") : ee = ee[0].toUpperCase() + ee.substring(1).toLowerCase(), ee == "H" && w)) + continue; + B[0] == "H" ? oe = !0 : oe = !1, T[ne] = n.length, n.push({ + resn: $, + x: U, + y: V, + z: Q, + elem: ee, + hetflag: oe, + altLoc: me, + chain: k, + resi: G, + icode: H, + rescode: G + (H != " " ? "^" + H : ""), + // resi + // and + // icode + serial: ne, + atom: M, + bonds: [], + ss: "c", + bondOrder: [], + properties: {}, + b: se, + pdbline: D + }); + } else if (B == "SHEET ") { + P = D.substring(21, 22), z = parseInt(D.substring(22, 26)), F = parseInt(D.substring(33, 37)), P in S || (S[P] = {}), S[P][z] = "s1"; + for (var fe = z + 1; fe < F; fe++) + S[P][fe] = "s"; + S[P][F] = "s2"; + } else if (B == "CONECT") { + var Ce = parseInt(D.substring(6, 11)), Me = T[Ce], Te = n[Me], ae = [11, 16, 21, 26]; + for (let We = 0; We < 4; We++) { + var pe = parseInt(D.substring(ae[We], ae[We] + 5)), we = T[pe]; + let Y = Me + ":" + we; + var ke = n[we]; + if (Te !== void 0 && ke !== void 0) + if (!R[Y]) + R[Y] = 1, (Te.bonds.length == 0 || Te.bonds[Te.bonds.length - 1] != we) && (Te.bonds.push(we), Te.bondOrder.push(1)); + else { + R[Y] += 1; + for (let K = 0; K < Te.bonds.length; K++) + if (Te.bonds[K] == we) { + var Ue = R[Y]; + Ue >= 4 ? Te.bondOrder[K] = 1 : Te.bondOrder[K] = Ue; + } + } + } + } else if (B == "HELIX ") { + P = D.substring(19, 20), z = parseInt(D.substring(21, 25)), F = parseInt(D.substring(33, 37)), P in S || (S[P] = {}), S[P][z] = "h1"; + for (let We = z + 1; We < F; We++) + S[P][We] = "h"; + S[P][F] = "h2"; + } else if (!a && B == "REMARK" && D.substring(13, 18) == "BIOMT") { + var Ne, Be = new s.Matrix4(); + for (Ne = 1; Ne <= 3; Ne++) + if (D = b[He].replace(/^\s*/, ""), parseInt(D.substring(18, 19)) == Ne) + Be.elements[Ne - 1] = parseFloat(D.substring(23, 33)), Be.elements[Ne - 1 + 4] = parseFloat(D.substring(33, 43)), Be.elements[Ne - 1 + 8] = parseFloat(D.substring(43, 53)), Be.elements[Ne - 1 + 12] = parseFloat(D.substring(53)), He++; + else + for (; D.substring(13, 18) == "BIOMT"; ) + He++, D = b[He].replace(/^\s*/, ""); + Be.elements[3] = 0, Be.elements[7] = 0, Be.elements[11] = 0, Be.elements[15] = 1, g.symmetries.push(Be), He--; + } else if (B == "CRYST1") { + let We, Y, K, q, de, ve; + We = parseFloat(D.substring(7, 15)), Y = parseFloat(D.substring(16, 24)), K = parseFloat(D.substring(25, 33)), q = parseFloat(D.substring(34, 40)), de = parseFloat(D.substring(41, 47)), ve = parseFloat(D.substring(48, 54)), g.cryst = { + a: We, + b: Y, + c: K, + alpha: q, + beta: de, + gamma: ve + }; + } else if (B == "ANISOU") { + let We = parseInt(D.substring(6, 11)); + var ue = T[We], ye = n[ue]; + if (ye) { + var ge = D.substring(30).trim().split(/\s+/), Se = { + u11: parseInt(ge[0]), + u22: parseInt(ge[1]), + u33: parseInt(ge[2]), + u12: parseInt(ge[3]), + u13: parseInt(ge[4]), + u23: parseInt(ge[5]) + }; + ye.uMat = Se; + } + } + } + if ((0, c.validateBonds)(n, T), o && (0, E.assignPDBBonds)(n), a || (0, u.processSymmetries)(g.symmetries, n, A, g.cryst), v && !p && (0, x.computeSecondaryStructure)(n, A.hbondCutoff), !(0, h.isEmpty)(S)) { + for (let He = 0; He < n.length; He++) + if (M = n[He], M !== void 0 && M.chain in S && M.resi in S[M.chain]) { + var ze = S[M.chain][M.resi]; + M.ss = ze[0], ze.length > 1 && (ze[1] == "1" ? M.ssbegin = !0 : ze[1] == "2" && (M.ssend = !0)); + } + } + return [n, g, L]; + } + } + ), + /***/ + "./src/parsers/utils/isEmpty.ts": ( + /*!**************************************!*\ + !*** ./src/parsers/utils/isEmpty.ts ***! + \**************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + isEmpty: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + function s(f) { + var _; + for (_ in f) + return !1; + return !0; + } + } + ), + /***/ + "./src/parsers/utils/processSymmetries.ts": ( + /*!************************************************!*\ + !*** ./src/parsers/utils/processSymmetries.ts ***! + \************************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + processSymmetries: () => ( + /* binding */ + f + ) + /* harmony export */ + }); + var s = t( + /*! ../../WebGL */ + "./src/WebGL/index.ts" + ); + function f(_, x, h, u) { + var E = !h.duplicateAssemblyAtoms, c = x.length, C = c, b, A, S; + let n = -1; + if (h.normalizeAssembly && u) { + let l = (0, s.conversionMatrix3)(u.a, u.b, u.c, u.alpha, u.beta, u.gamma), g = new s.Matrix3(); + for (g.getInverse3(l), b = 0; b < _.length; b++) { + let M = new s.Vector3(0, 0, 0); + for (S = 0; S < c; S++) { + let R = new s.Vector3(x[S].x, x[S].y, x[S].z); + R.applyMatrix4(_[b]), R.applyMatrix3(g), M.add(R); + } + M.divideScalar(c); + const L = [M.x, M.y, M.z]; + let T = [0, 0, 0]; + for (let R = 0; R < 3; R++) { + for (; L[R] < -1e-3; ) + L[R] += 1, T[R] += 1; + for (; L[R] > 1.001; ) + L[R] -= 1, T[R] -= 1; + } + const D = new s.Vector3(T[0], T[1], T[2]); + D.applyMatrix3(l), _[b].isNearlyIdentity() && D.lengthSq() > 1e-3 && (n = b), _[b].translate(D); + } + } + if (E) { + if (_.length > 1) + for (b = 0; b < x.length; b++) { + var v = []; + for (A = 0; A < _.length; A++) + if (!_[A].isNearlyIdentity()) { + var a = new s.Vector3(); + a.set(x[b].x, x[b].y, x[b].z), a.applyMatrix4(_[A]), v.push(a); + } + x[b].symmetries = v; + } + } else { + for (S = 0; S < c; S++) + x[S].sym = -1; + for (b = 0; b < _.length; b++) + if (!_[b].isNearlyIdentity() && n != b) { + let l = new s.Vector3(); + for (S = 0; S < c; S++) { + var o = []; + for (A = 0; A < x[S].bonds.length; A++) + o.push(x[S].bonds[A] + C); + l.set(x[S].x, x[S].y, x[S].z), l.applyMatrix4(_[b]); + var w = {}; + for (var p in x[S]) + w[p] = x[S][p]; + w.x = l.x, w.y = l.y, w.z = l.z, w.bonds = o, w.sym = b, w.index = x.length, x.push(w); + } + C = x.length; + } else + for (S = 0; S < c; S++) + x[S].sym = b; + if (n >= 0) { + let l = new s.Vector3(); + for (S = 0; S < c; S++) + l.set(x[S].x, x[S].y, x[S].z), l.applyMatrix4(_[n]), x[S].x = l.x, x[S].y = l.y, x[S].z = l.z; + } + _.length = 0; + } + } + } + ), + /***/ + "./src/parsers/utils/standardResidues.ts": ( + /*!***********************************************!*\ + !*** ./src/parsers/utils/standardResidues.ts ***! + \***********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + standardResidues: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + const s = /* @__PURE__ */ new Set([ + "ABU", + "ACD", + "ALA", + "ALB", + "ALI", + "ARG", + "AR0", + "ASN", + "ASP", + "ASX", + "BAS", + "CYS", + "CYH", + "CYX", + "CSS", + "CSH", + "GLN", + "GLU", + "GLX", + "GLY", + "HIS", + "HIE", + "HID", + "HIP", + "HYP", + "ILE", + "ILU", + "LEU", + "LYS", + "MET", + "PCA", + "PGA", + "PHE", + "PR0", + "PRO", + "PRZ", + "SER", + "THR", + "TRP", + "TYR", + "VAL", + "A", + "1MA", + "C", + "5MC", + "OMC", + "G", + "1MG", + "2MG", + "M2G", + "7MG", + "OMG", + "YG", + "I", + "T", + "U", + "+U", + "H2U", + "5MU", + "PSU", + "ACE", + "F0R", + "H2O", + "HOH", + "WAT" + ]); + } + ), + /***/ + "./src/parsers/utils/validateBonds.ts": ( + /*!********************************************!*\ + !*** ./src/parsers/utils/validateBonds.ts ***! + \********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + validateBonds: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + function s(f, _) { + for (var x = 0, h = f.length; x < h; x++) + for (var u = f[x], E = 0; E < u.bonds.length; E++) { + var c = u.bonds[E], C = f[c], b = _[u.serial]; + if (C && b) { + var A = C.bonds.indexOf(b); + A < 0 && (C.bonds.push(b), C.bondOrder.push(u.bondOrder[E])); + } + } + } + } + ), + /***/ + "./src/partialCharges.ts": ( + /*!*******************************!*\ + !*** ./src/partialCharges.ts ***! + \*******************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + applyPartialCharges: () => ( + /* binding */ + f + ), + /* harmony export */ + partialCharges: () => ( + /* binding */ + s + ) + /* harmony export */ + }); + const s = { + "ALA:N": -0.15, + "ALA:CA": 0.1, + "ALA:CB": 0, + "ALA:C": 0.6, + "ALA:O": -0.55, + "ARG:N": -0.15, + "ARG:CA": 0.1, + "ARG:CB": 0, + "ARG:CG": 0, + "ARG:CD": 0.1, + "ARG:NE": -0.1, + "ARG:CZ": 0.5, + "ARG:NH1": 0.25, + "ARG:NH2": 0.25, + "ARG:C": 0.6, + "ARG:O": -0.55, + "ASN:N": -0.15, + "ASN:CA": 0.1, + "ASN:CB": 0, + "ASN:CG": 0.55, + "ASN:OD1": -0.55, + "ASN:ND2": 0, + "ASN:C": 0.6, + "ASN:O": -0.55, + "ASP:N": -0.15, + "ASP:CA": 0.1, + "ASP:CB": 0, + "ASP:CG": 0.14, + "ASP:OD1": -0.57, + "ASP:OD2": -0.57, + "ASP:C": 0.6, + "ASP:O": -0.55, + "CYS:N": -0.15, + "CYS:CA": 0.1, + "CYS:CB": 0.19, + "CYS:SG": -0.19, + "CYS:C": 0.6, + "CYS:O": -0.55, + "GLN:N": -0.15, + "GLN:CA": 0.1, + "GLN:CB": 0, + "GLN:CG": 0, + "GLN:CD": 0.55, + "GLN:OE1": -0.55, + "GLN:NE2": 0, + "GLN:C": 0.6, + "GLN:O": -0.55, + "GLU:N": -0.15, + "GLU:CA": 0.1, + "GLU:CB": 0, + "GLU:CG": 0, + "GLU:CD": 0.14, + "GLU:OE1": -0.57, + "GLU:OE2": -0.57, + "GLU:C": 0.6, + "GLU:O": -0.55, + "GLY:N": -0.15, + "GLY:CA": 0.1, + "GLY:C": 0.6, + "GLY:O": -0.55, + "HIS:N": -0.15, + "HIS:CA": 0.1, + "HIS:CB": 0, + "HIS:CG": 0.1, + "HIS:ND1": -0.1, + "HIS:CD2": 0.1, + "HIS:NE2": -0.4, + "HIS:CE1": 0.3, + "HIS:C": 0.6, + "HIS:O": -0.55, + "ILE:N": -0.15, + "ILE:CA": 0.1, + "ILE:CB": 0, + "ILE:CG2": 0, + "ILE:CG1": 0, + "ILE:CD": 0, + "ILE:C": 0.6, + "ILE:O": -0.55, + "LEU:N": -0.15, + "LEU:CA": 0.1, + "LEU:CB": 0, + "LEU:CG": 0, + "LEU:CD1": 0, + "LEU:CD2": 0, + "LEU:C": 0.6, + "LEU:O": -0.55, + "LYS:N": -0.15, + "LYS:CA": 0.1, + "LYS:CB": 0, + "LYS:CG": 0, + "LYS:CD": 0, + "LYS:CE": 0.25, + "LYS:NZ": 0.75, + "LYS:C": 0.6, + "LYS:O": -0.55, + "MET:N": -0.15, + "MET:CA": 0.1, + "MET:CB": 0, + "MET:CG": 0.06, + "MET:SD": -0.12, + "MET:CE": 0.06, + "MET:C": 0.6, + "MET:O": -0.55, + "PHE:N": -0.15, + "PHE:CA": 0.1, + "PHE:CB": 0, + "PHE:CG": 0, + "PHE:CD1": 0, + "PHE:CD2": 0, + "PHE:CE1": 0, + "PHE:CE2": 0, + "PHE:CZ": 0, + "PHE:C": 0.6, + "PHE:O": -0.55, + "PRO:N": -0.25, + "PRO:CD": 0.1, + "PRO:CA": 0.1, + "PRO:CB": 0, + "PRO:CG": 0, + "PRO:C": 0.6, + "PRO:O": -0.55, + "SER:N": -0.15, + "SER:CA": 0.1, + "SER:CB": 0.25, + "SER:OG": -0.25, + "SER:C": 0.6, + "SER:O": -0.55, + "THR:N": -0.15, + "THR:CA": 0.1, + "THR:CB": 0.25, + "THR:OG1": -0.25, + "THR:CG2": 0, + "THR:C": 0.6, + "THR:O": -0.55, + "TRP:N": -0.15, + "TRP:CA": 0.1, + "TRP:CB": 0, + "TRP:CG": -0.03, + "TRP:CD2": 0.1, + "TRP:CE2": -0.04, + "TRP:CE3": -0.03, + "TRP:CD1": 0.06, + "TRP:NE1": -0.06, + "TRP:CZ2": 0, + "TRP:CZ3": 0, + "TRP:CH2": 0, + "TRP:C": 0.6, + "TRP:O": -0.55, + "TYR:N": -0.15, + "TYR:CA": 0.1, + "TYR:CB": 0, + "TYR:CG": 0, + "TYR:CD1": 0, + "TYR:CE1": 0, + "TYR:CD2": 0, + "TYR:CE2": 0, + "TYR:CZ": 0.25, + "TYR:OH": -0.25, + "TYR:C": 0.6, + "TYR:O": -0.55, + "VAL:N": -0.15, + "VAL:CA": 0.1, + "VAL:CB": 0, + "VAL:CG1": 0, + "VAL:CG2": 0, + "VAL:C": 0.6, + "VAL:O": -0.55 + }; + function f(_, x) { + if ((!x || typeof _.partialCharge > "u") && _.resn && _.atom) { + var h = _.resn + ":" + _.atom; + _.properties.partialCharge = s[h]; + } + } + } + ), + /***/ + "./src/specs.ts": ( + /*!**********************!*\ + !*** ./src/specs.ts ***! + \**********************/ + /***/ + (r, e, t) => { + t.r(e); + } + ), + /***/ + "./src/utilities.ts": ( + /*!**************************!*\ + !*** ./src/utilities.ts ***! + \**************************/ + /***/ + (__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, { + /* harmony export */ + PausableTimer: () => ( + /* binding */ + PausableTimer + ), + /* harmony export */ + adjustVolumeStyle: () => ( + /* binding */ + adjustVolumeStyle + ), + /* harmony export */ + base64ToArray: () => ( + /* binding */ + base64ToArray + ), + /* harmony export */ + deepCopy: () => ( + /* binding */ + deepCopy + ), + /* harmony export */ + download: () => ( + /* binding */ + download + ), + /* harmony export */ + extend: () => ( + /* binding */ + extend + ), + /* harmony export */ + get: () => ( + /* binding */ + get + ), + /* harmony export */ + getAtomProperty: () => ( + /* binding */ + getAtomProperty + ), + /* harmony export */ + getColorFromStyle: () => ( + /* binding */ + getColorFromStyle + ), + /* harmony export */ + getElement: () => ( + /* binding */ + getElement + ), + /* harmony export */ + getExtent: () => ( + /* binding */ + getExtent + ), + /* harmony export */ + getPropertyRange: () => ( + /* binding */ + getPropertyRange + ), + /* harmony export */ + getbin: () => ( + /* binding */ + getbin + ), + /* harmony export */ + isEmptyObject: () => ( + /* binding */ + isEmptyObject + ), + /* harmony export */ + isNumeric: () => ( + /* binding */ + isNumeric + ), + /* harmony export */ + makeFunction: () => ( + /* binding */ + makeFunction + ), + /* harmony export */ + mergeGeos: () => ( + /* binding */ + mergeGeos + ), + /* harmony export */ + specStringToObject: () => ( + /* binding */ + specStringToObject + ) + /* harmony export */ + }); + var _Gradient__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__( + /*! ./Gradient */ + "./src/Gradient.ts" + ), _VolumeData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__( + /*! ./VolumeData */ + "./src/VolumeData.ts" + ), _colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__( + /*! ./colors */ + "./src/colors.ts" + ); + function extend(r, e) { + for (var t in e) + e.hasOwnProperty(t) && e[t] !== void 0 && (r[t] = e[t]); + return r; + } + function deepCopy(r) { + let e, t, s; + if (r == null) + return {}; + if (typeof r != "object" || r === null) + return r; + e = Array.isArray(r) ? [] : {}; + for (s in r) + t = r[s], e[s] = deepCopy(t); + return e; + } + function isNumeric(r) { + var e = typeof r; + return (e === "number" || e === "string") && !isNaN(r - parseFloat(r)); + } + function isEmptyObject(r) { + var e; + for (e in r) + return !1; + return !0; + } + function makeFunction(callback) { + return callback && typeof callback == "string" && (callback = eval("(" + callback + ")")), callback && typeof callback != "function" ? null : callback; + } + function adjustVolumeStyle(r) { + r && (r.volformat && !(r.voldata instanceof _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData) && (r.voldata = new _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData(r.voldata, r.volformat)), r.volscheme && (r.volscheme = _Gradient__WEBPACK_IMPORTED_MODULE_0__.Gradient.getGradient(r.volscheme))); + } + function getExtent(r, e) { + var t, s, f, _, x, h, u, E, c, C, b = !e; + if (t = s = f = 9999, _ = x = h = -9999, u = E = c = C = 0, r.length === 0) + return [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; + for (var A = 0; A < r.length; A++) { + var S = r[A]; + if (!(typeof S > "u" || !isFinite(S.x) || !isFinite(S.y) || !isFinite(S.z)) && (C++, u += S.x, E += S.y, c += S.z, t = t < S.x ? t : S.x, s = s < S.y ? s : S.y, f = f < S.z ? f : S.z, _ = _ > S.x ? _ : S.x, x = x > S.y ? x : S.y, h = h > S.z ? h : S.z, S.symmetries && b)) + for (var n = 0; n < S.symmetries.length; n++) + C++, u += S.symmetries[n].x, E += S.symmetries[n].y, c += S.symmetries[n].z, t = t < S.symmetries[n].x ? t : S.symmetries[n].x, s = s < S.symmetries[n].y ? s : S.symmetries[n].y, f = f < S.symmetries[n].z ? f : S.symmetries[n].z, _ = _ > S.symmetries[n].x ? _ : S.symmetries[n].x, x = x > S.symmetries[n].y ? x : S.symmetries[n].y, h = h > S.symmetries[n].z ? h : S.symmetries[n].z; + } + return [ + [t, s, f], + [_, x, h], + [u / C, E / C, c / C] + ]; + } + function getPropertyRange(r, e) { + for (var t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, f = 0, _ = r.length; f < _; f++) { + var x = r[f], h = getAtomProperty(x, e); + h != null && (h < t && (t = h), h > s && (s = h)); + } + return !isFinite(t) && !isFinite(s) ? t = s = 0 : isFinite(t) ? isFinite(s) || (s = t) : t = s, [t, s]; + } + class PausableTimer { + constructor(e, t, s) { + this.total_time_run = 0, this.fn = e, this.arg = s, this.countdown = t, this.start_time = (/* @__PURE__ */ new Date()).getTime(), this.ident = setTimeout(e, t, s); + } + cancel() { + clearTimeout(this.ident); + } + pause() { + clearTimeout(this.ident), this.total_time_run = (/* @__PURE__ */ new Date()).getTime() - this.start_time; + } + resume() { + this.ident = setTimeout(this.fn, Math.max(0, this.countdown - this.total_time_run), this.arg); + } + } + function base64ToArray(r) { + for (var e = window.atob(r), t = e.length, s = new Uint8Array(t), f = 0; f < t; f++) + s[f] = e.charCodeAt(f); + return s; + } + function getAtomProperty(r, e) { + var t = null; + return r.properties && typeof r.properties[e] < "u" ? t = r.properties[e] : typeof r[e] < "u" && (t = r[e]), t; + } + function mergeGeos(r, e) { + var t = e.geometry; + t !== void 0 && r.geometryGroups.push(t.geometryGroups[0]); + } + function specStringToObject(r) { + if (typeof r == "object") + return r; + if (typeof r > "u" || r == null) + return r; + try { + return JSON.parse(r); + } catch { + } + r = r.replace(/%7E/g, "~"); + var e = function(b) { + return isNumeric(b) ? Math.floor(parseFloat(b)) == parseInt(b) || b.indexOf(".") >= 0 ? parseFloat(b) : parseInt(b) : b === "true" ? !0 : b === "false" ? !1 : b; + }, t = {}; + if (r === "all") + return t; + for (var s = r.split(";"), f = 0; f < s.length; f++) { + var _ = s[f].split(":"), x = _[0], h = {}, u = _[1]; + if (u) + if (u = u.replace(/~/g, "="), u.indexOf("=") !== -1) + for (var E = u.split(","), c = 0; c < E.length; c++) { + var C = E[c].split("=", 2); + h[C[0]] = e(C[1]); + } + else + u.indexOf(",") !== -1 ? h = u.split(",") : h = e(u); + t[x] = h; + } + return t; + } + function checkStatus(r) { + if (!r.ok) + throw new Error(`HTTP ${r.status} - ${r.statusText}`); + return r; + } + function get(r, e) { + var t = fetch(r).then(checkStatus).then((s) => s.text()); + return e ? t.then(e) : t; + } + function getbin(r, e, t, s) { + var f; + return t == "POST" ? f = fetch(r, { method: "POST", body: s }).then((_) => checkStatus(_)).then((_) => _.arrayBuffer()) : f = fetch(r).then((_) => checkStatus(_)).then((_) => _.arrayBuffer()), e ? f.then(e) : f; + } + function download(r, e, t, s) { + var f = "", _ = "", x = "", h = "", u = null, E = e.addModel(); + if (r.indexOf(":") < 0 && (r.length == 4 ? r = "pdb:" + r : isNaN(r) ? r = "url:" + r : r = "cid:" + r), r.substring(0, 5) === "mmtf:") + _ = t && t.pdbUri ? t.pdbUri : "https://mmtf.rcsb.org/v1.0/full/", r = r.substring(5).toUpperCase(), h = _ + r, t && typeof t.noComputeSecondaryStructure > "u" && (t.noComputeSecondaryStructure = !0), u = new Promise(function(C) { + getbin(h).then(function(b) { + E.addMolData(b, "mmtf", t), e.zoomTo(), e.render(), C(E); + }, function() { + console.log("fetch of " + h + " failed."); + }); + }); + else { + if (r.substring(0, 4) === "pdb:") { + if (f = "mmtf", t && t.format && (f = t.format), t && typeof t.noComputeSecondaryStructure > "u" && (t.noComputeSecondaryStructure = !0), r = r.substring(4).toUpperCase(), !r.match(/^[1-9][A-Za-z0-9]{3}$/)) { + alert("Wrong PDB ID"); + return; + } + f == "mmtf" ? (x = t && t.mmtfUri ? t.mmtfUri : "https://mmtf.rcsb.org/v1.0/full/", h = x + r.toUpperCase()) : (_ = t && t.pdbUri ? t.pdbUri : "https://files.rcsb.org/view/", h = _ + r + "." + f); + } else if (r.substring(0, 4) == "cid:") { + if (f = "sdf", r = r.substring(4), !r.match(/^[0-9]+$/)) { + alert("Wrong Compound ID"); + return; + } + h = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/" + r + "/SDF?record_type=3d"; + } else + r.substring(0, 4) == "url:" && (h = r.substring(4), f = h); + var c = function(C) { + E.addMolData(C, f, t), e.zoomTo(), e.render(); + }; + u = new Promise(function(C) { + f == "mmtf" ? getbin(h).then(function(b) { + c(b), C(E); + }).catch(function() { + _ = t && t.pdbUri ? t.pdbUri : "https://files.rcsb.org/view/", h = _ + r + ".pdb", f = "pdb", console.log("falling back to pdb format"), get(h).then(function(b) { + c(b), C(E); + }).catch(function(b) { + c(""), C(E), console.log("fetch of " + h + " failed: " + b.statusText); + }); + }) : get(h).then(function(b) { + c(b), C(E); + }).catch(function(b) { + c(""), C(E), console.log("fetch of " + h + " failed: " + b.statusText); + }); + }); + } + return s ? (u.then(function(C) { + s(C); + }), E) : u; + } + function getColorFromStyle(r, e) { + let t = e.colorscheme; + if (typeof _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[t] < "u") + t = _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[t]; + else if (typeof t == "string" && t.endsWith("Carbon")) { + let x = t.substring(0, t.lastIndexOf("Carbon")).toLowerCase(); + if (typeof _colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[x] < "u") { + let h = Object.assign({}, _colors__WEBPACK_IMPORTED_MODULE_2__.elementColors.defaultColors); + h.C = _colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[x], _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[t] = { prop: "elem", map: h }, t = _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[t]; + } + } + let s = r.color; + if (typeof e.color < "u" && e.color != "spectrum" && (s = e.color), typeof t < "u") { + let x, h; + if (typeof _colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[t] < "u") + t = _colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[t], typeof t[r[t.prop]] < "u" && (s = t.map[r[t.prop]]); + else if (typeof t[r[t.prop]] < "u") + s = t.map[r[t.prop]]; + else if (typeof t.prop < "u" && typeof t.gradient < "u") { + x = t.prop; + var f = t.gradient; + typeof _Gradient__WEBPACK_IMPORTED_MODULE_0__.builtinGradients[f] < "u" && (f = new _Gradient__WEBPACK_IMPORTED_MODULE_0__.builtinGradients[f](t.min, t.max, t.mid ? t.mid : t.colors)); + let u = f.range() || [-1, 1]; + h = getAtomProperty(r, x), h != null && (s = f.valueToHex(h, u)); + } else + typeof t.prop < "u" && typeof t.map < "u" ? (x = t.prop, h = getAtomProperty(r, x), typeof t.map[h] < "u" && (s = t.map[h])) : typeof e.colorscheme[r.elem] < "u" ? s = e.colorscheme[r.elem] : console.log("Could not interpret colorscheme " + t); + } else + typeof e.colorfunc < "u" && (s = e.colorfunc(r)); + return _colors__WEBPACK_IMPORTED_MODULE_2__.CC.color(s); + } + function getElement(r) { + let e = r; + return typeof r == "string" ? e = document.querySelector("#" + r) : typeof r == "object" && r.get && (e = r.get(0)), e; + } + } + ), + /***/ + "./node_modules/upng-js/UPNG.js": ( + /*!**************************************!*\ + !*** ./node_modules/upng-js/UPNG.js ***! + \**************************************/ + /***/ + (r, e, t) => { + (function() { + var s = {}, f; + r.exports = s, f = t( + /*! pako */ + "./node_modules/upng-js/node_modules/pako/index.js" + ), function(_, x) { + _.toRGBA8 = function(h) { + var u = h.width, E = h.height; + if (h.tabs.acTL == null) + return [_.toRGBA8.decodeImage(h.data, u, E, h).buffer]; + var c = []; + h.frames[0].data == null && (h.frames[0].data = h.data); + for (var C, b = new Uint8Array(u * E * 4), A = 0; A < h.frames.length; A++) { + var S = h.frames[A], n = S.rect.x, o = S.rect.y, w = S.rect.width, p = S.rect.height, v = _.toRGBA8.decodeImage(S.data, w, p, h); + if (A == 0 ? C = v : S.blend == 0 ? _._copyTile(v, w, p, C, u, E, n, o, 0) : S.blend == 1 && _._copyTile(v, w, p, C, u, E, n, o, 1), c.push(C.buffer), C = C.slice(0), S.dispose != 0) { + if (S.dispose == 1) + _._copyTile(b, w, p, C, u, E, n, o, 0); + else if (S.dispose == 2) { + for (var a = A - 1; h.frames[a].dispose == 2; ) + a--; + C = new Uint8Array(c[a]).slice(0); + } + } + } + return c; + }, _.toRGBA8.decodeImage = function(h, u, E, c) { + var C = u * E, b = _.decode._getBPP(c), A = Math.ceil(u * b / 8), S = new Uint8Array(C * 4), n = new Uint32Array(S.buffer), o = c.ctype, w = c.depth, p = _._bin.readUshort; + if (o == 6) { + var v = C << 2; + if (w == 8) + for (var a = 0; a < v; a++) + S[a] = h[a]; + if (w == 16) + for (var a = 0; a < v; a++) + S[a] = h[a << 1]; + } else if (o == 2) { + var l = c.tabs.tRNS, g = -1, M = -1, L = -1; + if (l && (g = l[0], M = l[1], L = l[2]), w == 8) + for (var a = 0; a < C; a++) { + var T = a << 2, D = a * 3; + S[T] = h[D], S[T + 1] = h[D + 1], S[T + 2] = h[D + 2], S[T + 3] = 255, g != -1 && h[D] == g && h[D + 1] == M && h[D + 2] == L && (S[T + 3] = 0); + } + if (w == 16) + for (var a = 0; a < C; a++) { + var T = a << 2, D = a * 6; + S[T] = h[D], S[T + 1] = h[D + 2], S[T + 2] = h[D + 4], S[T + 3] = 255, g != -1 && p(h, D) == g && p(h, D + 2) == M && p(h, D + 4) == L && (S[T + 3] = 0); + } + } else if (o == 3) { + var R = c.tabs.PLTE, B = c.tabs.tRNS, P = B ? B.length : 0; + if (w == 1) + for (var z = 0; z < E; z++) + for (var F = z * A, N = z * u, a = 0; a < u; a++) { + var T = N + a << 2, $ = h[F + (a >> 3)] >> 7 - ((a & 7) << 0) & 1, k = 3 * $; + S[T] = R[k], S[T + 1] = R[k + 1], S[T + 2] = R[k + 2], S[T + 3] = $ < P ? B[$] : 255; + } + if (w == 2) + for (var z = 0; z < E; z++) + for (var F = z * A, N = z * u, a = 0; a < u; a++) { + var T = N + a << 2, $ = h[F + (a >> 2)] >> 6 - ((a & 3) << 1) & 3, k = 3 * $; + S[T] = R[k], S[T + 1] = R[k + 1], S[T + 2] = R[k + 2], S[T + 3] = $ < P ? B[$] : 255; + } + if (w == 4) + for (var z = 0; z < E; z++) + for (var F = z * A, N = z * u, a = 0; a < u; a++) { + var T = N + a << 2, $ = h[F + (a >> 1)] >> 4 - ((a & 1) << 2) & 15, k = 3 * $; + S[T] = R[k], S[T + 1] = R[k + 1], S[T + 2] = R[k + 2], S[T + 3] = $ < P ? B[$] : 255; + } + if (w == 8) + for (var a = 0; a < C; a++) { + var T = a << 2, $ = h[a], k = 3 * $; + S[T] = R[k], S[T + 1] = R[k + 1], S[T + 2] = R[k + 2], S[T + 3] = $ < P ? B[$] : 255; + } + } else if (o == 4) { + if (w == 8) + for (var a = 0; a < C; a++) { + var T = a << 2, G = a << 1, H = h[G]; + S[T] = H, S[T + 1] = H, S[T + 2] = H, S[T + 3] = h[G + 1]; + } + if (w == 16) + for (var a = 0; a < C; a++) { + var T = a << 2, G = a << 2, H = h[G]; + S[T] = H, S[T + 1] = H, S[T + 2] = H, S[T + 3] = h[G + 2]; + } + } else if (o == 0) { + var g = c.tabs.tRNS ? c.tabs.tRNS : -1; + if (w == 1) + for (var a = 0; a < C; a++) { + var H = 255 * (h[a >> 3] >> 7 - (a & 7) & 1), U = H == g * 255 ? 0 : 255; + n[a] = U << 24 | H << 16 | H << 8 | H; + } + if (w == 2) + for (var a = 0; a < C; a++) { + var H = 85 * (h[a >> 2] >> 6 - ((a & 3) << 1) & 3), U = H == g * 85 ? 0 : 255; + n[a] = U << 24 | H << 16 | H << 8 | H; + } + if (w == 4) + for (var a = 0; a < C; a++) { + var H = 17 * (h[a >> 1] >> 4 - ((a & 1) << 2) & 15), U = H == g * 17 ? 0 : 255; + n[a] = U << 24 | H << 16 | H << 8 | H; + } + if (w == 8) + for (var a = 0; a < C; a++) { + var H = h[a], U = H == g ? 0 : 255; + n[a] = U << 24 | H << 16 | H << 8 | H; + } + if (w == 16) + for (var a = 0; a < C; a++) { + var H = h[a << 1], U = p(h, a << 1) == g ? 0 : 255; + n[a] = U << 24 | H << 16 | H << 8 | H; + } + } + return S; + }, _.decode = function(h) { + for (var u = new Uint8Array(h), E = 8, c = _._bin, C = c.readUshort, b = c.readUint, A = { tabs: {}, frames: [] }, S = new Uint8Array(u.length), n = 0, o, w = 0, p = [137, 80, 78, 71, 13, 10, 26, 10], v = 0; v < 8; v++) + if (u[v] != p[v]) + throw "The input is not a PNG file!"; + for (; E < u.length; ) { + var a = c.readUint(u, E); + E += 4; + var l = c.readASCII(u, E, 4); + if (E += 4, l == "IHDR") + _.decode._IHDR(u, E, A); + else if (l == "IDAT") { + for (var v = 0; v < a; v++) + S[n + v] = u[E + v]; + n += a; + } else if (l == "acTL") + A.tabs[l] = { num_frames: b(u, E), num_plays: b(u, E + 4) }, o = new Uint8Array(u.length); + else if (l == "fcTL") { + if (w != 0) { + var g = A.frames[A.frames.length - 1]; + g.data = _.decode._decompress(A, o.slice(0, w), g.rect.width, g.rect.height), w = 0; + } + var M = { x: b(u, E + 12), y: b(u, E + 16), width: b(u, E + 4), height: b(u, E + 8) }, L = C(u, E + 22); + L = C(u, E + 20) / (L == 0 ? 100 : L); + var T = { rect: M, delay: Math.round(L * 1e3), dispose: u[E + 24], blend: u[E + 25] }; + A.frames.push(T); + } else if (l == "fdAT") { + for (var v = 0; v < a - 4; v++) + o[w + v] = u[E + v + 4]; + w += a - 4; + } else if (l == "pHYs") + A.tabs[l] = [c.readUint(u, E), c.readUint(u, E + 4), u[E + 8]]; + else if (l == "cHRM") { + A.tabs[l] = []; + for (var v = 0; v < 8; v++) + A.tabs[l].push(c.readUint(u, E + v * 4)); + } else if (l == "tEXt") { + A.tabs[l] == null && (A.tabs[l] = {}); + var D = c.nextZero(u, E), R = c.readASCII(u, E, D - E), B = c.readASCII(u, D + 1, E + a - D - 1); + A.tabs[l][R] = B; + } else if (l == "iTXt") { + A.tabs[l] == null && (A.tabs[l] = {}); + var D = 0, P = E; + D = c.nextZero(u, P); + var R = c.readASCII(u, P, D - P); + P = D + 1, u[P], u[P + 1], P += 2, D = c.nextZero(u, P), c.readASCII(u, P, D - P), P = D + 1, D = c.nextZero(u, P), c.readUTF8(u, P, D - P), P = D + 1; + var B = c.readUTF8(u, P, a - (P - E)); + A.tabs[l][R] = B; + } else if (l == "PLTE") + A.tabs[l] = c.readBytes(u, E, a); + else if (l == "hIST") { + var z = A.tabs.PLTE.length / 3; + A.tabs[l] = []; + for (var v = 0; v < z; v++) + A.tabs[l].push(C(u, E + v * 2)); + } else if (l == "tRNS") + A.ctype == 3 ? A.tabs[l] = c.readBytes(u, E, a) : A.ctype == 0 ? A.tabs[l] = C(u, E) : A.ctype == 2 && (A.tabs[l] = [C(u, E), C(u, E + 2), C(u, E + 4)]); + else if (l == "gAMA") + A.tabs[l] = c.readUint(u, E) / 1e5; + else if (l == "sRGB") + A.tabs[l] = u[E]; + else if (l == "bKGD") + A.ctype == 0 || A.ctype == 4 ? A.tabs[l] = [C(u, E)] : A.ctype == 2 || A.ctype == 6 ? A.tabs[l] = [C(u, E), C(u, E + 2), C(u, E + 4)] : A.ctype == 3 && (A.tabs[l] = u[E]); + else if (l == "IEND") { + if (w != 0) { + var g = A.frames[A.frames.length - 1]; + g.data = _.decode._decompress(A, o.slice(0, w), g.rect.width, g.rect.height), w = 0; + } + A.data = _.decode._decompress(A, S, A.width, A.height); + break; + } + E += a, c.readUint(u, E), E += 4; + } + return delete A.compress, delete A.interlace, delete A.filter, A; + }, _.decode._decompress = function(h, u, E, c) { + return h.compress == 0 && (u = _.decode._inflate(u)), h.interlace == 0 ? u = _.decode._filterZero(u, h, 0, E, c) : h.interlace == 1 && (u = _.decode._readInterlace(u, h)), u; + }, _.decode._inflate = function(h) { + return x.inflate(h); + }, _.decode._readInterlace = function(h, u) { + for (var E = u.width, c = u.height, C = _.decode._getBPP(u), b = C >> 3, A = Math.ceil(E * C / 8), S = new Uint8Array(c * A), n = 0, o = [0, 0, 4, 0, 2, 0, 1], w = [0, 4, 0, 2, 0, 1, 0], p = [8, 8, 8, 4, 4, 2, 2], v = [8, 8, 4, 4, 2, 2, 1], a = 0; a < 7; ) { + for (var l = p[a], g = v[a], M = 0, L = 0, T = o[a]; T < c; ) + T += l, L++; + for (var D = w[a]; D < E; ) + D += g, M++; + var R = Math.ceil(M * C / 8); + _.decode._filterZero(h, u, n, M, L); + for (var B = 0, P = o[a]; P < c; ) { + for (var z = w[a], F = n + B * R << 3; z < E; ) { + if (C == 1) { + var N = h[F >> 3]; + N = N >> 7 - (F & 7) & 1, S[P * A + (z >> 3)] |= N << 7 - ((z & 3) << 0); + } + if (C == 2) { + var N = h[F >> 3]; + N = N >> 6 - (F & 7) & 3, S[P * A + (z >> 2)] |= N << 6 - ((z & 3) << 1); + } + if (C == 4) { + var N = h[F >> 3]; + N = N >> 4 - (F & 7) & 15, S[P * A + (z >> 1)] |= N << 4 - ((z & 1) << 2); + } + if (C >= 8) + for (var $ = P * A + z * b, k = 0; k < b; k++) + S[$ + k] = h[(F >> 3) + k]; + F += C, z += g; + } + B++, P += l; + } + M * L != 0 && (n += L * (1 + R)), a = a + 1; + } + return S; + }, _.decode._getBPP = function(h) { + var u = [1, null, 3, 1, 2, null, 4][h.ctype]; + return u * h.depth; + }, _.decode._filterZero = function(h, u, E, c, C) { + var b = _.decode._getBPP(u), A = Math.ceil(c * b / 8), S = _.decode._paeth; + b = Math.ceil(b / 8); + for (var n = 0; n < C; n++) { + var o = E + n * A, w = o + n + 1, p = h[w - 1]; + if (p == 0) + for (var v = 0; v < A; v++) + h[o + v] = h[w + v]; + else if (p == 1) { + for (var v = 0; v < b; v++) + h[o + v] = h[w + v]; + for (var v = b; v < A; v++) + h[o + v] = h[w + v] + h[o + v - b] & 255; + } else if (n == 0) { + for (var v = 0; v < b; v++) + h[o + v] = h[w + v]; + if (p == 2) + for (var v = b; v < A; v++) + h[o + v] = h[w + v] & 255; + if (p == 3) + for (var v = b; v < A; v++) + h[o + v] = h[w + v] + (h[o + v - b] >> 1) & 255; + if (p == 4) + for (var v = b; v < A; v++) + h[o + v] = h[w + v] + S(h[o + v - b], 0, 0) & 255; + } else { + if (p == 2) + for (var v = 0; v < A; v++) + h[o + v] = h[w + v] + h[o + v - A] & 255; + if (p == 3) { + for (var v = 0; v < b; v++) + h[o + v] = h[w + v] + (h[o + v - A] >> 1) & 255; + for (var v = b; v < A; v++) + h[o + v] = h[w + v] + (h[o + v - A] + h[o + v - b] >> 1) & 255; + } + if (p == 4) { + for (var v = 0; v < b; v++) + h[o + v] = h[w + v] + S(0, h[o + v - A], 0) & 255; + for (var v = b; v < A; v++) + h[o + v] = h[w + v] + S(h[o + v - b], h[o + v - A], h[o + v - b - A]) & 255; + } + } + } + return h; + }, _.decode._paeth = function(h, u, E) { + var c = h + u - E, C = Math.abs(c - h), b = Math.abs(c - u), A = Math.abs(c - E); + return C <= b && C <= A ? h : b <= A ? u : E; + }, _.decode._IHDR = function(h, u, E) { + var c = _._bin; + E.width = c.readUint(h, u), u += 4, E.height = c.readUint(h, u), u += 4, E.depth = h[u], u++, E.ctype = h[u], u++, E.compress = h[u], u++, E.filter = h[u], u++, E.interlace = h[u], u++; + }, _._bin = { + nextZero: function(h, u) { + for (; h[u] != 0; ) + u++; + return u; + }, + readUshort: function(h, u) { + return h[u] << 8 | h[u + 1]; + }, + writeUshort: function(h, u, E) { + h[u] = E >> 8 & 255, h[u + 1] = E & 255; + }, + readUint: function(h, u) { + return h[u] * 16777216 + (h[u + 1] << 16 | h[u + 2] << 8 | h[u + 3]); + }, + writeUint: function(h, u, E) { + h[u] = E >> 24 & 255, h[u + 1] = E >> 16 & 255, h[u + 2] = E >> 8 & 255, h[u + 3] = E & 255; + }, + readASCII: function(h, u, E) { + for (var c = "", C = 0; C < E; C++) + c += String.fromCharCode(h[u + C]); + return c; + }, + writeASCII: function(h, u, E) { + for (var c = 0; c < E.length; c++) + h[u + c] = E.charCodeAt(c); + }, + readBytes: function(h, u, E) { + for (var c = [], C = 0; C < E; C++) + c.push(h[u + C]); + return c; + }, + pad: function(h) { + return h.length < 2 ? "0" + h : h; + }, + readUTF8: function(h, u, E) { + for (var c = "", C, b = 0; b < E; b++) + c += "%" + _._bin.pad(h[u + b].toString(16)); + try { + C = decodeURIComponent(c); + } catch { + return _._bin.readASCII(h, u, E); + } + return C; + } + }, _._copyTile = function(h, u, E, c, C, b, A, S, n) { + for (var o = Math.min(u, C), w = Math.min(E, b), p = 0, v = 0, a = 0; a < w; a++) + for (var l = 0; l < o; l++) + if (A >= 0 && S >= 0 ? (p = a * u + l << 2, v = (S + a) * C + A + l << 2) : (p = (-S + a) * u - A + l << 2, v = a * C + l << 2), n == 0) + c[v] = h[p], c[v + 1] = h[p + 1], c[v + 2] = h[p + 2], c[v + 3] = h[p + 3]; + else if (n == 1) { + var g = h[p + 3] * 0.00392156862745098, M = h[p] * g, L = h[p + 1] * g, T = h[p + 2] * g, D = c[v + 3] * (1 / 255), R = c[v] * D, B = c[v + 1] * D, P = c[v + 2] * D, z = 1 - g, F = g + D * z, N = F == 0 ? 0 : 1 / F; + c[v + 3] = 255 * F, c[v + 0] = (M + R * z) * N, c[v + 1] = (L + B * z) * N, c[v + 2] = (T + P * z) * N; + } else if (n == 2) { + var g = h[p + 3], M = h[p], L = h[p + 1], T = h[p + 2], D = c[v + 3], R = c[v], B = c[v + 1], P = c[v + 2]; + g == D && M == R && L == B && T == P ? (c[v] = 0, c[v + 1] = 0, c[v + 2] = 0, c[v + 3] = 0) : (c[v] = M, c[v + 1] = L, c[v + 2] = T, c[v + 3] = g); + } else if (n == 3) { + var g = h[p + 3], M = h[p], L = h[p + 1], T = h[p + 2], D = c[v + 3], R = c[v], B = c[v + 1], P = c[v + 2]; + if (g == D && M == R && L == B && T == P) + continue; + if (g < 220 && D > 20) + return !1; + } + return !0; + }, _.encode = function(h, u, E, c, C, b) { + c == null && (c = 0), b == null && (b = !1); + for (var A = new Uint8Array(h[0].byteLength * h.length + 100), S = [137, 80, 78, 71, 13, 10, 26, 10], n = 0; n < 8; n++) + A[n] = S[n]; + var o = 8, w = _._bin, p = _.crc.crc, v = w.writeUint, a = w.writeUshort, l = w.writeASCII, g = _.encode.compressPNG(h, u, E, c, b); + v(A, o, 13), o += 4, l(A, o, "IHDR"), o += 4, v(A, o, u), o += 4, v(A, o, E), o += 4, A[o] = g.depth, o++, A[o] = g.ctype, o++, A[o] = 0, o++, A[o] = 0, o++, A[o] = 0, o++, v(A, o, p(A, o - 17, 17)), o += 4, v(A, o, 1), o += 4, l(A, o, "sRGB"), o += 4, A[o] = 1, o++, v(A, o, p(A, o - 5, 5)), o += 4; + var M = h.length > 1; + if (M && (v(A, o, 8), o += 4, l(A, o, "acTL"), o += 4, v(A, o, h.length), o += 4, v(A, o, 0), o += 4, v(A, o, p(A, o - 12, 12)), o += 4), g.ctype == 3) { + var L = g.plte.length; + v(A, o, L * 3), o += 4, l(A, o, "PLTE"), o += 4; + for (var n = 0; n < L; n++) { + var T = n * 3, D = g.plte[n], R = D & 255, B = D >> 8 & 255, P = D >> 16 & 255; + A[o + T + 0] = R, A[o + T + 1] = B, A[o + T + 2] = P; + } + if (o += L * 3, v(A, o, p(A, o - L * 3 - 4, L * 3 + 4)), o += 4, g.gotAlpha) { + v(A, o, L), o += 4, l(A, o, "tRNS"), o += 4; + for (var n = 0; n < L; n++) + A[o + n] = g.plte[n] >> 24 & 255; + o += L, v(A, o, p(A, o - L - 4, L + 4)), o += 4; + } + } + for (var z = 0, F = 0; F < g.frames.length; F++) { + var N = g.frames[F]; + M && (v(A, o, 26), o += 4, l(A, o, "fcTL"), o += 4, v(A, o, z++), o += 4, v(A, o, N.rect.width), o += 4, v(A, o, N.rect.height), o += 4, v(A, o, N.rect.x), o += 4, v(A, o, N.rect.y), o += 4, a(A, o, C[F]), o += 2, a(A, o, 1e3), o += 2, A[o] = N.dispose, o++, A[o] = N.blend, o++, v(A, o, p(A, o - 30, 30)), o += 4); + var $ = N.cimg, L = $.length; + v(A, o, L + (F == 0 ? 0 : 4)), o += 4; + var k = o; + l(A, o, F == 0 ? "IDAT" : "fdAT"), o += 4, F != 0 && (v(A, o, z++), o += 4); + for (var n = 0; n < L; n++) + A[o + n] = $[n]; + o += L, v(A, o, p(A, k, o - k)), o += 4; + } + return v(A, o, 0), o += 4, l(A, o, "IEND"), o += 4, v(A, o, p(A, o - 4, 4)), o += 4, A.buffer.slice(0, o); + }, _.encode.compressPNG = function(h, u, E, c, C) { + for (var b = _.encode.compress(h, u, E, c, !1, C), A = 0; A < h.length; A++) { + var S = b.frames[A]; + S.rect.width; + var n = S.rect.height, o = S.bpl, w = S.bpp, p = new Uint8Array(n * o + n); + S.cimg = _.encode._filterZero(S.img, n, w, o, p); + } + return b; + }, _.encode.compress = function(h, u, E, c, C, b) { + b == null && (b = !1); + for (var A = 6, S = 8, n = 4, o = 255, w = 0; w < h.length; w++) + for (var p = new Uint8Array(h[w]), v = p.length, a = 0; a < v; a += 4) + o &= p[a + 3]; + var l = o != 255, g = {}, M = []; + if (h.length != 0 && (g[0] = 0, M.push(0), c != 0 && c--), c != 0) { + var L = _.quantize(h, c, C); + h = L.bufs; + for (var a = 0; a < L.plte.length; a++) { + var T = L.plte[a].est.rgba; + g[T] == null && (g[T] = M.length, M.push(T)); + } + } else + for (var w = 0; w < h.length; w++) + for (var D = new Uint32Array(h[w]), v = D.length, a = 0; a < v; a++) { + var T = D[a]; + if ((a < u || T != D[a - 1] && T != D[a - u]) && g[T] == null && (g[T] = M.length, M.push(T), M.length >= 300)) + break; + } + var R = l ? C : !1, B = M.length; + B <= 256 && b == !1 && (B <= 2 ? S = 1 : B <= 4 ? S = 2 : B <= 16 ? S = 4 : S = 8, C && (S = 8), l = !0); + for (var P = [], w = 0; w < h.length; w++) { + var z = new Uint8Array(h[w]), F = new Uint32Array(z.buffer), N = 0, $ = 0, k = u, G = E, H = 0; + if (w != 0 && !R) { + for (var U = C || w == 1 || P[P.length - 2].dispose == 2 ? 1 : 2, V = 0, Q = 1e9, oe = 0; oe < U; oe++) { + for (var ae = new Uint8Array(h[w - 1 - oe]), ee = new Uint32Array(h[w - 1 - oe]), ne = u, me = E, se = -1, fe = -1, Ce = 0; Ce < E; Ce++) + for (var Me = 0; Me < u; Me++) { + var a = Ce * u + Me; + F[a] != ee[a] && (Me < ne && (ne = Me), Me > se && (se = Me), Ce < me && (me = Ce), Ce > fe && (fe = Ce)); + } + var Te = se == -1 ? 1 : (se - ne + 1) * (fe - me + 1); + Te < Q && (Q = Te, V = oe, se == -1 ? (N = $ = 0, k = G = 1) : (N = ne, $ = me, k = se - ne + 1, G = fe - me + 1)); + } + var ae = new Uint8Array(h[w - 1 - V]); + V == 1 && (P[P.length - 1].dispose = 2); + var pe = new Uint8Array(k * G * 4); + new Uint32Array(pe.buffer), _._copyTile(ae, u, E, pe, k, G, -N, -$, 0), _._copyTile(z, u, E, pe, k, G, -N, -$, 3) ? (_._copyTile(z, u, E, pe, k, G, -N, -$, 2), H = 1) : (_._copyTile(z, u, E, pe, k, G, -N, -$, 0), H = 0), z = pe, F = new Uint32Array(z.buffer); + } + var we = 4 * k; + if (B <= 256 && b == !1) { + we = Math.ceil(S * k / 8); + for (var pe = new Uint8Array(we * G), Ce = 0; Ce < G; Ce++) { + var a = Ce * we, ke = Ce * k; + if (S == 8) + for (var Me = 0; Me < k; Me++) + pe[a + Me] = g[F[ke + Me]]; + else if (S == 4) + for (var Me = 0; Me < k; Me++) + pe[a + (Me >> 1)] |= g[F[ke + Me]] << 4 - (Me & 1) * 4; + else if (S == 2) + for (var Me = 0; Me < k; Me++) + pe[a + (Me >> 2)] |= g[F[ke + Me]] << 6 - (Me & 3) * 2; + else if (S == 1) + for (var Me = 0; Me < k; Me++) + pe[a + (Me >> 3)] |= g[F[ke + Me]] << 7 - (Me & 7) * 1; + } + z = pe, A = 3, n = 1; + } else if (l == !1 && h.length == 1) { + for (var pe = new Uint8Array(k * G * 3), Ue = k * G, a = 0; a < Ue; a++) { + var Ne = a * 3, Be = a * 4; + pe[Ne] = z[Be], pe[Ne + 1] = z[Be + 1], pe[Ne + 2] = z[Be + 2]; + } + z = pe, A = 2, n = 3, we = 3 * k; + } + P.push({ rect: { x: N, y: $, width: k, height: G }, img: z, bpl: we, bpp: n, blend: H, dispose: R ? 1 : 0 }); + } + return { ctype: A, depth: S, plte: M, gotAlpha: l, frames: P }; + }, _.encode._filterZero = function(h, u, E, c, C) { + for (var b = [], A = 0; A < 5; A++) + if (!(u * c > 5e5 && (A == 2 || A == 3 || A == 4))) { + for (var S = 0; S < u; S++) + _.encode._filterLine(C, h, S, c, E, A); + if (b.push(x.deflate(C)), E == 1) + break; + } + for (var n, o = 1e9, w = 0; w < b.length; w++) + b[w].length < o && (n = w, o = b[w].length); + return b[n]; + }, _.encode._filterLine = function(h, u, E, c, C, b) { + var A = E * c, S = A + E, n = _.decode._paeth; + if (h[S] = b, S++, b == 0) + for (var o = 0; o < c; o++) + h[S + o] = u[A + o]; + else if (b == 1) { + for (var o = 0; o < C; o++) + h[S + o] = u[A + o]; + for (var o = C; o < c; o++) + h[S + o] = u[A + o] - u[A + o - C] + 256 & 255; + } else if (E == 0) { + for (var o = 0; o < C; o++) + h[S + o] = u[A + o]; + if (b == 2) + for (var o = C; o < c; o++) + h[S + o] = u[A + o]; + if (b == 3) + for (var o = C; o < c; o++) + h[S + o] = u[A + o] - (u[A + o - C] >> 1) + 256 & 255; + if (b == 4) + for (var o = C; o < c; o++) + h[S + o] = u[A + o] - n(u[A + o - C], 0, 0) + 256 & 255; + } else { + if (b == 2) + for (var o = 0; o < c; o++) + h[S + o] = u[A + o] + 256 - u[A + o - c] & 255; + if (b == 3) { + for (var o = 0; o < C; o++) + h[S + o] = u[A + o] + 256 - (u[A + o - c] >> 1) & 255; + for (var o = C; o < c; o++) + h[S + o] = u[A + o] + 256 - (u[A + o - c] + u[A + o - C] >> 1) & 255; + } + if (b == 4) { + for (var o = 0; o < C; o++) + h[S + o] = u[A + o] + 256 - n(0, u[A + o - c], 0) & 255; + for (var o = C; o < c; o++) + h[S + o] = u[A + o] + 256 - n(u[A + o - C], u[A + o - c], u[A + o - C - c]) & 255; + } + } + }, _.crc = { + table: function() { + for (var h = new Uint32Array(256), u = 0; u < 256; u++) { + for (var E = u, c = 0; c < 8; c++) + E & 1 ? E = 3988292384 ^ E >>> 1 : E = E >>> 1; + h[u] = E; + } + return h; + }(), + update: function(h, u, E, c) { + for (var C = 0; C < c; C++) + h = _.crc.table[(h ^ u[E + C]) & 255] ^ h >>> 8; + return h; + }, + crc: function(h, u, E) { + return _.crc.update(4294967295, h, u, E) ^ 4294967295; + } + }, _.quantize = function(h, u, E) { + for (var c = [], C = 0, b = 0; b < h.length; b++) + c.push(_.encode.alphaMul(new Uint8Array(h[b]), E)), C += h[b].byteLength; + for (var A = new Uint8Array(C), S = new Uint32Array(A.buffer), n = 0, b = 0; b < c.length; b++) { + for (var o = c[b], w = o.length, p = 0; p < w; p++) + A[n + p] = o[p]; + n += w; + } + var v = { i0: 0, i1: A.length, bst: null, est: null, tdst: 0, left: null, right: null }; + v.bst = _.quantize.stats(A, v.i0, v.i1), v.est = _.quantize.estats(v.bst); + for (var a = [v]; a.length < u; ) { + for (var l = 0, g = 0, b = 0; b < a.length; b++) + a[b].est.L > l && (l = a[b].est.L, g = b); + if (l < 1e-3) + break; + var M = a[g], L = _.quantize.splitPixels(A, S, M.i0, M.i1, M.est.e, M.est.eMq255), T = { i0: M.i0, i1: L, bst: null, est: null, tdst: 0, left: null, right: null }; + T.bst = _.quantize.stats(A, T.i0, T.i1), T.est = _.quantize.estats(T.bst); + var D = { i0: L, i1: M.i1, bst: null, est: null, tdst: 0, left: null, right: null }; + D.bst = { R: [], m: [], N: M.bst.N - T.bst.N }; + for (var b = 0; b < 16; b++) + D.bst.R[b] = M.bst.R[b] - T.bst.R[b]; + for (var b = 0; b < 4; b++) + D.bst.m[b] = M.bst.m[b] - T.bst.m[b]; + D.est = _.quantize.estats(D.bst), M.left = T, M.right = D, a[g] = T, a.push(D); + } + a.sort(function(U, V) { + return V.bst.N - U.bst.N; + }); + for (var R = 0; R < c.length; R++) { + for (var B = _.quantize.planeDst, P = new Uint8Array(c[R].buffer), z = new Uint32Array(c[R].buffer), F = P.length, b = 0; b < F; b += 4) { + for (var N = P[b] * 0.00392156862745098, $ = P[b + 1] * (1 / 255), k = P[b + 2] * (1 / 255), G = P[b + 3] * (1 / 255), H = v; H.left; ) + H = B(H.est, N, $, k, G) <= 0 ? H.left : H.right; + z[b >> 2] = H.est.rgba; + } + c[R] = z.buffer; + } + return { bufs: c, plte: a }; + }, _.quantize.getNearest = function(h, u, E, c, C) { + if (h.left == null) + return h.tdst = _.quantize.dist(h.est.q, u, E, c, C), h; + var b = _.quantize.planeDst(h.est, u, E, c, C), A = h.left, S = h.right; + b > 0 && (A = h.right, S = h.left); + var n = _.quantize.getNearest(A, u, E, c, C); + if (n.tdst <= b * b) + return n; + var o = _.quantize.getNearest(S, u, E, c, C); + return o.tdst < n.tdst ? o : n; + }, _.quantize.planeDst = function(h, u, E, c, C) { + var b = h.e; + return b[0] * u + b[1] * E + b[2] * c + b[3] * C - h.eMq; + }, _.quantize.dist = function(h, u, E, c, C) { + var b = u - h[0], A = E - h[1], S = c - h[2], n = C - h[3]; + return b * b + A * A + S * S + n * n; + }, _.quantize.splitPixels = function(h, u, E, c, C, b) { + var A = _.quantize.vecDot; + for (c -= 4; E < c; ) { + for (; A(h, E, C) <= b; ) + E += 4; + for (; A(h, c, C) > b; ) + c -= 4; + if (E >= c) + break; + var S = u[E >> 2]; + u[E >> 2] = u[c >> 2], u[c >> 2] = S, E += 4, c -= 4; + } + for (; A(h, E, C) > b; ) + E -= 4; + return E + 4; + }, _.quantize.vecDot = function(h, u, E) { + return h[u] * E[0] + h[u + 1] * E[1] + h[u + 2] * E[2] + h[u + 3] * E[3]; + }, _.quantize.stats = function(h, u, E) { + for (var c = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], C = [0, 0, 0, 0], b = E - u >> 2, A = u; A < E; A += 4) { + var S = h[A] * 0.00392156862745098, n = h[A + 1] * (1 / 255), o = h[A + 2] * (1 / 255), w = h[A + 3] * (1 / 255); + C[0] += S, C[1] += n, C[2] += o, C[3] += w, c[0] += S * S, c[1] += S * n, c[2] += S * o, c[3] += S * w, c[5] += n * n, c[6] += n * o, c[7] += n * w, c[10] += o * o, c[11] += o * w, c[15] += w * w; + } + return c[4] = c[1], c[8] = c[2], c[12] = c[3], c[9] = c[6], c[13] = c[7], c[14] = c[11], { R: c, m: C, N: b }; + }, _.quantize.estats = function(h) { + var u = h.R, E = h.m, c = h.N, C = E[0], b = E[1], A = E[2], S = E[3], n = c == 0 ? 0 : 1 / c, o = [ + u[0] - C * C * n, + u[1] - C * b * n, + u[2] - C * A * n, + u[3] - C * S * n, + u[4] - b * C * n, + u[5] - b * b * n, + u[6] - b * A * n, + u[7] - b * S * n, + u[8] - A * C * n, + u[9] - A * b * n, + u[10] - A * A * n, + u[11] - A * S * n, + u[12] - S * C * n, + u[13] - S * b * n, + u[14] - S * A * n, + u[15] - S * S * n + ], w = o, p = _.M4, v = [0.5, 0.5, 0.5, 0.5], a = 0, l = 0; + if (c != 0) + for (var g = 0; g < 10 && (v = p.multVec(w, v), l = Math.sqrt(p.dot(v, v)), v = p.sml(1 / l, v), !(Math.abs(l - a) < 1e-9)); g++) + a = l; + var M = [C * n, b * n, A * n, S * n], L = p.dot(p.sml(255, M), v), T = M[3] < 1e-3 ? 0 : 1 / M[3]; + return { + Cov: o, + q: M, + e: v, + L: a, + eMq255: L, + eMq: p.dot(v, M), + rgba: (Math.round(255 * M[3]) << 24 | Math.round(255 * M[2] * T) << 16 | Math.round(255 * M[1] * T) << 8 | Math.round(255 * M[0] * T) << 0) >>> 0 + }; + }, _.M4 = { + multVec: function(h, u) { + return [ + h[0] * u[0] + h[1] * u[1] + h[2] * u[2] + h[3] * u[3], + h[4] * u[0] + h[5] * u[1] + h[6] * u[2] + h[7] * u[3], + h[8] * u[0] + h[9] * u[1] + h[10] * u[2] + h[11] * u[3], + h[12] * u[0] + h[13] * u[1] + h[14] * u[2] + h[15] * u[3] + ]; + }, + dot: function(h, u) { + return h[0] * u[0] + h[1] * u[1] + h[2] * u[2] + h[3] * u[3]; + }, + sml: function(h, u) { + return [h * u[0], h * u[1], h * u[2], h * u[3]]; + } + }, _.encode.alphaMul = function(h, u) { + for (var E = new Uint8Array(h.length), c = h.length >> 2, C = 0; C < c; C++) { + var b = C << 2, A = h[b + 3]; + u && (A = A < 128 ? 0 : 255); + var S = A * (1 / 255); + E[b + 0] = h[b + 0] * S, E[b + 1] = h[b + 1] * S, E[b + 2] = h[b + 2] * S, E[b + 3] = A; + } + return E; + }; + }(s, f); + })(); + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/index.js": ( + /*!*********************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/index.js ***! + \*********************************************************/ + /***/ + (r, e, t) => { + var s = t( + /*! ./lib/utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ).assign, f = t( + /*! ./lib/deflate */ + "./node_modules/upng-js/node_modules/pako/lib/deflate.js" + ), _ = t( + /*! ./lib/inflate */ + "./node_modules/upng-js/node_modules/pako/lib/inflate.js" + ), x = t( + /*! ./lib/zlib/constants */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js" + ), h = {}; + s(h, f, _, x), r.exports = h; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/deflate.js": ( + /*!***************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/deflate.js ***! + \***************************************************************/ + /***/ + (r, e, t) => { + var s = t( + /*! ./zlib/deflate */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js" + ), f = t( + /*! ./utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), _ = t( + /*! ./utils/strings */ + "./node_modules/upng-js/node_modules/pako/lib/utils/strings.js" + ), x = t( + /*! ./zlib/messages */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js" + ), h = t( + /*! ./zlib/zstream */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js" + ), u = Object.prototype.toString, E = 0, c = 4, C = 0, b = 1, A = 2, S = -1, n = 0, o = 8; + function w(l) { + if (!(this instanceof w)) + return new w(l); + this.options = f.assign({ + level: S, + method: o, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: n, + to: "" + }, l || {}); + var g = this.options; + g.raw && g.windowBits > 0 ? g.windowBits = -g.windowBits : g.gzip && g.windowBits > 0 && g.windowBits < 16 && (g.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new h(), this.strm.avail_out = 0; + var M = s.deflateInit2( + this.strm, + g.level, + g.method, + g.windowBits, + g.memLevel, + g.strategy + ); + if (M !== C) + throw new Error(x[M]); + if (g.header && s.deflateSetHeader(this.strm, g.header), g.dictionary) { + var L; + if (typeof g.dictionary == "string" ? L = _.string2buf(g.dictionary) : u.call(g.dictionary) === "[object ArrayBuffer]" ? L = new Uint8Array(g.dictionary) : L = g.dictionary, M = s.deflateSetDictionary(this.strm, L), M !== C) + throw new Error(x[M]); + this._dict_set = !0; + } + } + w.prototype.push = function(l, g) { + var M = this.strm, L = this.options.chunkSize, T, D; + if (this.ended) + return !1; + D = g === ~~g ? g : g === !0 ? c : E, typeof l == "string" ? M.input = _.string2buf(l) : u.call(l) === "[object ArrayBuffer]" ? M.input = new Uint8Array(l) : M.input = l, M.next_in = 0, M.avail_in = M.input.length; + do { + if (M.avail_out === 0 && (M.output = new f.Buf8(L), M.next_out = 0, M.avail_out = L), T = s.deflate(M, D), T !== b && T !== C) + return this.onEnd(T), this.ended = !0, !1; + (M.avail_out === 0 || M.avail_in === 0 && (D === c || D === A)) && (this.options.to === "string" ? this.onData(_.buf2binstring(f.shrinkBuf(M.output, M.next_out))) : this.onData(f.shrinkBuf(M.output, M.next_out))); + } while ((M.avail_in > 0 || M.avail_out === 0) && T !== b); + return D === c ? (T = s.deflateEnd(this.strm), this.onEnd(T), this.ended = !0, T === C) : (D === A && (this.onEnd(C), M.avail_out = 0), !0); + }, w.prototype.onData = function(l) { + this.chunks.push(l); + }, w.prototype.onEnd = function(l) { + l === C && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = f.flattenChunks(this.chunks)), this.chunks = [], this.err = l, this.msg = this.strm.msg; + }; + function p(l, g) { + var M = new w(g); + if (M.push(l, !0), M.err) + throw M.msg || x[M.err]; + return M.result; + } + function v(l, g) { + return g = g || {}, g.raw = !0, p(l, g); + } + function a(l, g) { + return g = g || {}, g.gzip = !0, p(l, g); + } + e.Deflate = w, e.deflate = p, e.deflateRaw = v, e.gzip = a; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/inflate.js": ( + /*!***************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/inflate.js ***! + \***************************************************************/ + /***/ + (r, e, t) => { + var s = t( + /*! ./zlib/inflate */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inflate.js" + ), f = t( + /*! ./utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), _ = t( + /*! ./utils/strings */ + "./node_modules/upng-js/node_modules/pako/lib/utils/strings.js" + ), x = t( + /*! ./zlib/constants */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js" + ), h = t( + /*! ./zlib/messages */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js" + ), u = t( + /*! ./zlib/zstream */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js" + ), E = t( + /*! ./zlib/gzheader */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/gzheader.js" + ), c = Object.prototype.toString; + function C(S) { + if (!(this instanceof C)) + return new C(S); + this.options = f.assign({ + chunkSize: 16384, + windowBits: 0, + to: "" + }, S || {}); + var n = this.options; + n.raw && n.windowBits >= 0 && n.windowBits < 16 && (n.windowBits = -n.windowBits, n.windowBits === 0 && (n.windowBits = -15)), n.windowBits >= 0 && n.windowBits < 16 && !(S && S.windowBits) && (n.windowBits += 32), n.windowBits > 15 && n.windowBits < 48 && (n.windowBits & 15 || (n.windowBits |= 15)), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new u(), this.strm.avail_out = 0; + var o = s.inflateInit2( + this.strm, + n.windowBits + ); + if (o !== x.Z_OK) + throw new Error(h[o]); + if (this.header = new E(), s.inflateGetHeader(this.strm, this.header), n.dictionary && (typeof n.dictionary == "string" ? n.dictionary = _.string2buf(n.dictionary) : c.call(n.dictionary) === "[object ArrayBuffer]" && (n.dictionary = new Uint8Array(n.dictionary)), n.raw && (o = s.inflateSetDictionary(this.strm, n.dictionary), o !== x.Z_OK))) + throw new Error(h[o]); + } + C.prototype.push = function(S, n) { + var o = this.strm, w = this.options.chunkSize, p = this.options.dictionary, v, a, l, g, M, L = !1; + if (this.ended) + return !1; + a = n === ~~n ? n : n === !0 ? x.Z_FINISH : x.Z_NO_FLUSH, typeof S == "string" ? o.input = _.binstring2buf(S) : c.call(S) === "[object ArrayBuffer]" ? o.input = new Uint8Array(S) : o.input = S, o.next_in = 0, o.avail_in = o.input.length; + do { + if (o.avail_out === 0 && (o.output = new f.Buf8(w), o.next_out = 0, o.avail_out = w), v = s.inflate(o, x.Z_NO_FLUSH), v === x.Z_NEED_DICT && p && (v = s.inflateSetDictionary(this.strm, p)), v === x.Z_BUF_ERROR && L === !0 && (v = x.Z_OK, L = !1), v !== x.Z_STREAM_END && v !== x.Z_OK) + return this.onEnd(v), this.ended = !0, !1; + o.next_out && (o.avail_out === 0 || v === x.Z_STREAM_END || o.avail_in === 0 && (a === x.Z_FINISH || a === x.Z_SYNC_FLUSH)) && (this.options.to === "string" ? (l = _.utf8border(o.output, o.next_out), g = o.next_out - l, M = _.buf2string(o.output, l), o.next_out = g, o.avail_out = w - g, g && f.arraySet(o.output, o.output, l, g, 0), this.onData(M)) : this.onData(f.shrinkBuf(o.output, o.next_out))), o.avail_in === 0 && o.avail_out === 0 && (L = !0); + } while ((o.avail_in > 0 || o.avail_out === 0) && v !== x.Z_STREAM_END); + return v === x.Z_STREAM_END && (a = x.Z_FINISH), a === x.Z_FINISH ? (v = s.inflateEnd(this.strm), this.onEnd(v), this.ended = !0, v === x.Z_OK) : (a === x.Z_SYNC_FLUSH && (this.onEnd(x.Z_OK), o.avail_out = 0), !0); + }, C.prototype.onData = function(S) { + this.chunks.push(S); + }, C.prototype.onEnd = function(S) { + S === x.Z_OK && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = f.flattenChunks(this.chunks)), this.chunks = [], this.err = S, this.msg = this.strm.msg; + }; + function b(S, n) { + var o = new C(n); + if (o.push(S, !0), o.err) + throw o.msg || h[o.err]; + return o.result; + } + function A(S, n) { + return n = n || {}, n.raw = !0, b(S, n); + } + e.Inflate = C, e.inflate = b, e.inflateRaw = A, e.ungzip = b; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/utils/common.js ***! + \********************************************************************/ + /***/ + (r, e) => { + var t = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Int32Array < "u"; + function s(x, h) { + return Object.prototype.hasOwnProperty.call(x, h); + } + e.assign = function(x) { + for (var h = Array.prototype.slice.call(arguments, 1); h.length; ) { + var u = h.shift(); + if (u) { + if (typeof u != "object") + throw new TypeError(u + "must be non-object"); + for (var E in u) + s(u, E) && (x[E] = u[E]); + } + } + return x; + }, e.shrinkBuf = function(x, h) { + return x.length === h ? x : x.subarray ? x.subarray(0, h) : (x.length = h, x); + }; + var f = { + arraySet: function(x, h, u, E, c) { + if (h.subarray && x.subarray) { + x.set(h.subarray(u, u + E), c); + return; + } + for (var C = 0; C < E; C++) + x[c + C] = h[u + C]; + }, + // Join array of chunks to single array. + flattenChunks: function(x) { + var h, u, E, c, C, b; + for (E = 0, h = 0, u = x.length; h < u; h++) + E += x[h].length; + for (b = new Uint8Array(E), c = 0, h = 0, u = x.length; h < u; h++) + C = x[h], b.set(C, c), c += C.length; + return b; + } + }, _ = { + arraySet: function(x, h, u, E, c) { + for (var C = 0; C < E; C++) + x[c + C] = h[u + C]; + }, + // Join array of chunks to single array. + flattenChunks: function(x) { + return [].concat.apply([], x); + } + }; + e.setTyped = function(x) { + x ? (e.Buf8 = Uint8Array, e.Buf16 = Uint16Array, e.Buf32 = Int32Array, e.assign(e, f)) : (e.Buf8 = Array, e.Buf16 = Array, e.Buf32 = Array, e.assign(e, _)); + }, e.setTyped(t); + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/utils/strings.js": ( + /*!*********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/utils/strings.js ***! + \*********************************************************************/ + /***/ + (r, e, t) => { + var s = t( + /*! ./common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), f = !0, _ = !0; + try { + String.fromCharCode.apply(null, [0]); + } catch { + f = !1; + } + try { + String.fromCharCode.apply(null, new Uint8Array(1)); + } catch { + _ = !1; + } + for (var x = new s.Buf8(256), h = 0; h < 256; h++) + x[h] = h >= 252 ? 6 : h >= 248 ? 5 : h >= 240 ? 4 : h >= 224 ? 3 : h >= 192 ? 2 : 1; + x[254] = x[254] = 1, e.string2buf = function(E) { + var c, C, b, A, S, n = E.length, o = 0; + for (A = 0; A < n; A++) + C = E.charCodeAt(A), (C & 64512) === 55296 && A + 1 < n && (b = E.charCodeAt(A + 1), (b & 64512) === 56320 && (C = 65536 + (C - 55296 << 10) + (b - 56320), A++)), o += C < 128 ? 1 : C < 2048 ? 2 : C < 65536 ? 3 : 4; + for (c = new s.Buf8(o), S = 0, A = 0; S < o; A++) + C = E.charCodeAt(A), (C & 64512) === 55296 && A + 1 < n && (b = E.charCodeAt(A + 1), (b & 64512) === 56320 && (C = 65536 + (C - 55296 << 10) + (b - 56320), A++)), C < 128 ? c[S++] = C : C < 2048 ? (c[S++] = 192 | C >>> 6, c[S++] = 128 | C & 63) : C < 65536 ? (c[S++] = 224 | C >>> 12, c[S++] = 128 | C >>> 6 & 63, c[S++] = 128 | C & 63) : (c[S++] = 240 | C >>> 18, c[S++] = 128 | C >>> 12 & 63, c[S++] = 128 | C >>> 6 & 63, c[S++] = 128 | C & 63); + return c; + }; + function u(E, c) { + if (c < 65534 && (E.subarray && _ || !E.subarray && f)) + return String.fromCharCode.apply(null, s.shrinkBuf(E, c)); + for (var C = "", b = 0; b < c; b++) + C += String.fromCharCode(E[b]); + return C; + } + e.buf2binstring = function(E) { + return u(E, E.length); + }, e.binstring2buf = function(E) { + for (var c = new s.Buf8(E.length), C = 0, b = c.length; C < b; C++) + c[C] = E.charCodeAt(C); + return c; + }, e.buf2string = function(E, c) { + var C, b, A, S, n = c || E.length, o = new Array(n * 2); + for (b = 0, C = 0; C < n; ) { + if (A = E[C++], A < 128) { + o[b++] = A; + continue; + } + if (S = x[A], S > 4) { + o[b++] = 65533, C += S - 1; + continue; + } + for (A &= S === 2 ? 31 : S === 3 ? 15 : 7; S > 1 && C < n; ) + A = A << 6 | E[C++] & 63, S--; + if (S > 1) { + o[b++] = 65533; + continue; + } + A < 65536 ? o[b++] = A : (A -= 65536, o[b++] = 55296 | A >> 10 & 1023, o[b++] = 56320 | A & 1023); + } + return u(o, b); + }, e.utf8border = function(E, c) { + var C; + for (c = c || E.length, c > E.length && (c = E.length), C = c - 1; C >= 0 && (E[C] & 192) === 128; ) + C--; + return C < 0 || C === 0 ? c : C + x[E[C]] > c ? C : c; + }; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js ***! + \********************************************************************/ + /***/ + (r) => { + function e(t, s, f, _) { + for (var x = t & 65535 | 0, h = t >>> 16 & 65535 | 0, u = 0; f !== 0; ) { + u = f > 2e3 ? 2e3 : f, f -= u; + do + x = x + s[_++] | 0, h = h + x | 0; + while (--u); + x %= 65521, h %= 65521; + } + return x | h << 16 | 0; + } + r.exports = e; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js": ( + /*!**********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js ***! + \**********************************************************************/ + /***/ + (r) => { + r.exports = { + /* Allowed flush values; see deflate() and inflate() below for details */ + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + /* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + //Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + //Z_VERSION_ERROR: -6, + /* compression levels */ + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + /* Possible values of the data_type field (though see inflate()) */ + Z_BINARY: 0, + Z_TEXT: 1, + //Z_ASCII: 1, // = Z_TEXT (deprecated) + Z_UNKNOWN: 2, + /* The deflate compression method */ + Z_DEFLATED: 8 + //Z_NULL: null // Use -1 or null inline, depending on var type + }; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js": ( + /*!******************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js ***! + \******************************************************************/ + /***/ + (r) => { + function e() { + for (var f, _ = [], x = 0; x < 256; x++) { + f = x; + for (var h = 0; h < 8; h++) + f = f & 1 ? 3988292384 ^ f >>> 1 : f >>> 1; + _[x] = f; + } + return _; + } + var t = e(); + function s(f, _, x, h) { + var u = t, E = h + x; + f ^= -1; + for (var c = h; c < E; c++) + f = f >>> 8 ^ u[(f ^ _[c]) & 255]; + return f ^ -1; + } + r.exports = s; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js ***! + \********************************************************************/ + /***/ + (r, e, t) => { + var s = t( + /*! ../utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), f = t( + /*! ./trees */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/trees.js" + ), _ = t( + /*! ./adler32 */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js" + ), x = t( + /*! ./crc32 */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js" + ), h = t( + /*! ./messages */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js" + ), u = 0, E = 1, c = 3, C = 4, b = 5, A = 0, S = 1, n = -2, o = -3, w = -5, p = -1, v = 1, a = 2, l = 3, g = 4, M = 0, L = 2, T = 8, D = 9, R = 15, B = 8, P = 29, z = 256, F = z + 1 + P, N = 30, $ = 19, k = 2 * F + 1, G = 15, H = 3, U = 258, V = U + H + 1, Q = 32, oe = 42, ee = 69, ne = 73, me = 91, se = 103, fe = 113, Ce = 666, Me = 1, Te = 2, ae = 3, pe = 4, we = 3; + function ke(I, be) { + return I.msg = h[be], be; + } + function Ue(I) { + return (I << 1) - (I > 4 ? 9 : 0); + } + function Ne(I) { + for (var be = I.length; --be >= 0; ) + I[be] = 0; + } + function Be(I) { + var be = I.state, Ee = be.pending; + Ee > I.avail_out && (Ee = I.avail_out), Ee !== 0 && (s.arraySet(I.output, be.pending_buf, be.pending_out, Ee, I.next_out), I.next_out += Ee, be.pending_out += Ee, I.total_out += Ee, I.avail_out -= Ee, be.pending -= Ee, be.pending === 0 && (be.pending_out = 0)); + } + function ue(I, be) { + f._tr_flush_block(I, I.block_start >= 0 ? I.block_start : -1, I.strstart - I.block_start, be), I.block_start = I.strstart, Be(I.strm); + } + function ye(I, be) { + I.pending_buf[I.pending++] = be; + } + function ge(I, be) { + I.pending_buf[I.pending++] = be >>> 8 & 255, I.pending_buf[I.pending++] = be & 255; + } + function Se(I, be, Ee, X) { + var le = I.avail_in; + return le > X && (le = X), le === 0 ? 0 : (I.avail_in -= le, s.arraySet(be, I.input, I.next_in, le, Ee), I.state.wrap === 1 ? I.adler = _(I.adler, be, le, Ee) : I.state.wrap === 2 && (I.adler = x(I.adler, be, le, Ee)), I.next_in += le, I.total_in += le, le); + } + function ze(I, be) { + var Ee = I.max_chain_length, X = I.strstart, le, Le, Ze = I.prev_length, Ke = I.nice_match, je = I.strstart > I.w_size - V ? I.strstart - (I.w_size - V) : 0, Je = I.window, Lt = I.w_mask, rt = I.prev, it = I.strstart + U, tt = Je[X + Ze - 1], Et = Je[X + Ze]; + I.prev_length >= I.good_match && (Ee >>= 2), Ke > I.lookahead && (Ke = I.lookahead); + do + if (le = be, !(Je[le + Ze] !== Et || Je[le + Ze - 1] !== tt || Je[le] !== Je[X] || Je[++le] !== Je[X + 1])) { + X += 2, le++; + do + ; + while (Je[++X] === Je[++le] && Je[++X] === Je[++le] && Je[++X] === Je[++le] && Je[++X] === Je[++le] && Je[++X] === Je[++le] && Je[++X] === Je[++le] && Je[++X] === Je[++le] && Je[++X] === Je[++le] && X < it); + if (Le = U - (it - X), X = it - U, Le > Ze) { + if (I.match_start = be, Ze = Le, Le >= Ke) + break; + tt = Je[X + Ze - 1], Et = Je[X + Ze]; + } + } + while ((be = rt[be & Lt]) > je && --Ee !== 0); + return Ze <= I.lookahead ? Ze : I.lookahead; + } + function He(I) { + var be = I.w_size, Ee, X, le, Le, Ze; + do { + if (Le = I.window_size - I.lookahead - I.strstart, I.strstart >= be + (be - V)) { + s.arraySet(I.window, I.window, be, be, 0), I.match_start -= be, I.strstart -= be, I.block_start -= be, X = I.hash_size, Ee = X; + do + le = I.head[--Ee], I.head[Ee] = le >= be ? le - be : 0; + while (--X); + X = be, Ee = X; + do + le = I.prev[--Ee], I.prev[Ee] = le >= be ? le - be : 0; + while (--X); + Le += be; + } + if (I.strm.avail_in === 0) + break; + if (X = Se(I.strm, I.window, I.strstart + I.lookahead, Le), I.lookahead += X, I.lookahead + I.insert >= H) + for (Ze = I.strstart - I.insert, I.ins_h = I.window[Ze], I.ins_h = (I.ins_h << I.hash_shift ^ I.window[Ze + 1]) & I.hash_mask; I.insert && (I.ins_h = (I.ins_h << I.hash_shift ^ I.window[Ze + H - 1]) & I.hash_mask, I.prev[Ze & I.w_mask] = I.head[I.ins_h], I.head[I.ins_h] = Ze, Ze++, I.insert--, !(I.lookahead + I.insert < H)); ) + ; + } while (I.lookahead < V && I.strm.avail_in !== 0); + } + function We(I, be) { + var Ee = 65535; + for (Ee > I.pending_buf_size - 5 && (Ee = I.pending_buf_size - 5); ; ) { + if (I.lookahead <= 1) { + if (He(I), I.lookahead === 0 && be === u) + return Me; + if (I.lookahead === 0) + break; + } + I.strstart += I.lookahead, I.lookahead = 0; + var X = I.block_start + Ee; + if ((I.strstart === 0 || I.strstart >= X) && (I.lookahead = I.strstart - X, I.strstart = X, ue(I, !1), I.strm.avail_out === 0) || I.strstart - I.block_start >= I.w_size - V && (ue(I, !1), I.strm.avail_out === 0)) + return Me; + } + return I.insert = 0, be === C ? (ue(I, !0), I.strm.avail_out === 0 ? ae : pe) : (I.strstart > I.block_start && (ue(I, !1), I.strm.avail_out === 0), Me); + } + function Y(I, be) { + for (var Ee, X; ; ) { + if (I.lookahead < V) { + if (He(I), I.lookahead < V && be === u) + return Me; + if (I.lookahead === 0) + break; + } + if (Ee = 0, I.lookahead >= H && (I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + H - 1]) & I.hash_mask, Ee = I.prev[I.strstart & I.w_mask] = I.head[I.ins_h], I.head[I.ins_h] = I.strstart), Ee !== 0 && I.strstart - Ee <= I.w_size - V && (I.match_length = ze(I, Ee)), I.match_length >= H) + if (X = f._tr_tally(I, I.strstart - I.match_start, I.match_length - H), I.lookahead -= I.match_length, I.match_length <= I.max_lazy_match && I.lookahead >= H) { + I.match_length--; + do + I.strstart++, I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + H - 1]) & I.hash_mask, Ee = I.prev[I.strstart & I.w_mask] = I.head[I.ins_h], I.head[I.ins_h] = I.strstart; + while (--I.match_length !== 0); + I.strstart++; + } else + I.strstart += I.match_length, I.match_length = 0, I.ins_h = I.window[I.strstart], I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + 1]) & I.hash_mask; + else + X = f._tr_tally(I, 0, I.window[I.strstart]), I.lookahead--, I.strstart++; + if (X && (ue(I, !1), I.strm.avail_out === 0)) + return Me; + } + return I.insert = I.strstart < H - 1 ? I.strstart : H - 1, be === C ? (ue(I, !0), I.strm.avail_out === 0 ? ae : pe) : I.last_lit && (ue(I, !1), I.strm.avail_out === 0) ? Me : Te; + } + function K(I, be) { + for (var Ee, X, le; ; ) { + if (I.lookahead < V) { + if (He(I), I.lookahead < V && be === u) + return Me; + if (I.lookahead === 0) + break; + } + if (Ee = 0, I.lookahead >= H && (I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + H - 1]) & I.hash_mask, Ee = I.prev[I.strstart & I.w_mask] = I.head[I.ins_h], I.head[I.ins_h] = I.strstart), I.prev_length = I.match_length, I.prev_match = I.match_start, I.match_length = H - 1, Ee !== 0 && I.prev_length < I.max_lazy_match && I.strstart - Ee <= I.w_size - V && (I.match_length = ze(I, Ee), I.match_length <= 5 && (I.strategy === v || I.match_length === H && I.strstart - I.match_start > 4096) && (I.match_length = H - 1)), I.prev_length >= H && I.match_length <= I.prev_length) { + le = I.strstart + I.lookahead - H, X = f._tr_tally(I, I.strstart - 1 - I.prev_match, I.prev_length - H), I.lookahead -= I.prev_length - 1, I.prev_length -= 2; + do + ++I.strstart <= le && (I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + H - 1]) & I.hash_mask, Ee = I.prev[I.strstart & I.w_mask] = I.head[I.ins_h], I.head[I.ins_h] = I.strstart); + while (--I.prev_length !== 0); + if (I.match_available = 0, I.match_length = H - 1, I.strstart++, X && (ue(I, !1), I.strm.avail_out === 0)) + return Me; + } else if (I.match_available) { + if (X = f._tr_tally(I, 0, I.window[I.strstart - 1]), X && ue(I, !1), I.strstart++, I.lookahead--, I.strm.avail_out === 0) + return Me; + } else + I.match_available = 1, I.strstart++, I.lookahead--; + } + return I.match_available && (X = f._tr_tally(I, 0, I.window[I.strstart - 1]), I.match_available = 0), I.insert = I.strstart < H - 1 ? I.strstart : H - 1, be === C ? (ue(I, !0), I.strm.avail_out === 0 ? ae : pe) : I.last_lit && (ue(I, !1), I.strm.avail_out === 0) ? Me : Te; + } + function q(I, be) { + for (var Ee, X, le, Le, Ze = I.window; ; ) { + if (I.lookahead <= U) { + if (He(I), I.lookahead <= U && be === u) + return Me; + if (I.lookahead === 0) + break; + } + if (I.match_length = 0, I.lookahead >= H && I.strstart > 0 && (le = I.strstart - 1, X = Ze[le], X === Ze[++le] && X === Ze[++le] && X === Ze[++le])) { + Le = I.strstart + U; + do + ; + while (X === Ze[++le] && X === Ze[++le] && X === Ze[++le] && X === Ze[++le] && X === Ze[++le] && X === Ze[++le] && X === Ze[++le] && X === Ze[++le] && le < Le); + I.match_length = U - (Le - le), I.match_length > I.lookahead && (I.match_length = I.lookahead); + } + if (I.match_length >= H ? (Ee = f._tr_tally(I, 1, I.match_length - H), I.lookahead -= I.match_length, I.strstart += I.match_length, I.match_length = 0) : (Ee = f._tr_tally(I, 0, I.window[I.strstart]), I.lookahead--, I.strstart++), Ee && (ue(I, !1), I.strm.avail_out === 0)) + return Me; + } + return I.insert = 0, be === C ? (ue(I, !0), I.strm.avail_out === 0 ? ae : pe) : I.last_lit && (ue(I, !1), I.strm.avail_out === 0) ? Me : Te; + } + function de(I, be) { + for (var Ee; ; ) { + if (I.lookahead === 0 && (He(I), I.lookahead === 0)) { + if (be === u) + return Me; + break; + } + if (I.match_length = 0, Ee = f._tr_tally(I, 0, I.window[I.strstart]), I.lookahead--, I.strstart++, Ee && (ue(I, !1), I.strm.avail_out === 0)) + return Me; + } + return I.insert = 0, be === C ? (ue(I, !0), I.strm.avail_out === 0 ? ae : pe) : I.last_lit && (ue(I, !1), I.strm.avail_out === 0) ? Me : Te; + } + function ve(I, be, Ee, X, le) { + this.good_length = I, this.max_lazy = be, this.nice_length = Ee, this.max_chain = X, this.func = le; + } + var Ie; + Ie = [ + /* good lazy nice chain */ + new ve(0, 0, 0, 0, We), + /* 0 store only */ + new ve(4, 4, 8, 4, Y), + /* 1 max speed, no lazy matches */ + new ve(4, 5, 16, 8, Y), + /* 2 */ + new ve(4, 6, 32, 32, Y), + /* 3 */ + new ve(4, 4, 16, 16, K), + /* 4 lazy matches */ + new ve(8, 16, 32, 32, K), + /* 5 */ + new ve(8, 16, 128, 128, K), + /* 6 */ + new ve(8, 32, 128, 256, K), + /* 7 */ + new ve(32, 128, 258, 1024, K), + /* 8 */ + new ve(32, 258, 258, 4096, K) + /* 9 max compression */ + ]; + function Re(I) { + I.window_size = 2 * I.w_size, Ne(I.head), I.max_lazy_match = Ie[I.level].max_lazy, I.good_match = Ie[I.level].good_length, I.nice_match = Ie[I.level].nice_length, I.max_chain_length = Ie[I.level].max_chain, I.strstart = 0, I.block_start = 0, I.lookahead = 0, I.insert = 0, I.match_length = I.prev_length = H - 1, I.match_available = 0, I.ins_h = 0; + } + function Z() { + this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = T, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new s.Buf16(k * 2), this.dyn_dtree = new s.Buf16((2 * N + 1) * 2), this.bl_tree = new s.Buf16((2 * $ + 1) * 2), Ne(this.dyn_ltree), Ne(this.dyn_dtree), Ne(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new s.Buf16(G + 1), this.heap = new s.Buf16(2 * F + 1), Ne(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new s.Buf16(2 * F + 1), Ne(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; + } + function ce(I) { + var be; + return !I || !I.state ? ke(I, n) : (I.total_in = I.total_out = 0, I.data_type = L, be = I.state, be.pending = 0, be.pending_out = 0, be.wrap < 0 && (be.wrap = -be.wrap), be.status = be.wrap ? oe : fe, I.adler = be.wrap === 2 ? 0 : 1, be.last_flush = u, f._tr_init(be), A); + } + function Ae(I) { + var be = ce(I); + return be === A && Re(I.state), be; + } + function Fe(I, be) { + return !I || !I.state || I.state.wrap !== 2 ? n : (I.state.gzhead = be, A); + } + function he(I, be, Ee, X, le, Le) { + if (!I) + return n; + var Ze = 1; + if (be === p && (be = 6), X < 0 ? (Ze = 0, X = -X) : X > 15 && (Ze = 2, X -= 16), le < 1 || le > D || Ee !== T || X < 8 || X > 15 || be < 0 || be > 9 || Le < 0 || Le > g) + return ke(I, n); + X === 8 && (X = 9); + var Ke = new Z(); + return I.state = Ke, Ke.strm = I, Ke.wrap = Ze, Ke.gzhead = null, Ke.w_bits = X, Ke.w_size = 1 << Ke.w_bits, Ke.w_mask = Ke.w_size - 1, Ke.hash_bits = le + 7, Ke.hash_size = 1 << Ke.hash_bits, Ke.hash_mask = Ke.hash_size - 1, Ke.hash_shift = ~~((Ke.hash_bits + H - 1) / H), Ke.window = new s.Buf8(Ke.w_size * 2), Ke.head = new s.Buf16(Ke.hash_size), Ke.prev = new s.Buf16(Ke.w_size), Ke.lit_bufsize = 1 << le + 6, Ke.pending_buf_size = Ke.lit_bufsize * 4, Ke.pending_buf = new s.Buf8(Ke.pending_buf_size), Ke.d_buf = 1 * Ke.lit_bufsize, Ke.l_buf = 3 * Ke.lit_bufsize, Ke.level = be, Ke.strategy = Le, Ke.method = Ee, Ae(I); + } + function Oe(I, be) { + return he(I, be, T, R, B, M); + } + function j(I, be) { + var Ee, X, le, Le; + if (!I || !I.state || be > b || be < 0) + return I ? ke(I, n) : n; + if (X = I.state, !I.output || !I.input && I.avail_in !== 0 || X.status === Ce && be !== C) + return ke(I, I.avail_out === 0 ? w : n); + if (X.strm = I, Ee = X.last_flush, X.last_flush = be, X.status === oe) + if (X.wrap === 2) + I.adler = 0, ye(X, 31), ye(X, 139), ye(X, 8), X.gzhead ? (ye( + X, + (X.gzhead.text ? 1 : 0) + (X.gzhead.hcrc ? 2 : 0) + (X.gzhead.extra ? 4 : 0) + (X.gzhead.name ? 8 : 0) + (X.gzhead.comment ? 16 : 0) + ), ye(X, X.gzhead.time & 255), ye(X, X.gzhead.time >> 8 & 255), ye(X, X.gzhead.time >> 16 & 255), ye(X, X.gzhead.time >> 24 & 255), ye(X, X.level === 9 ? 2 : X.strategy >= a || X.level < 2 ? 4 : 0), ye(X, X.gzhead.os & 255), X.gzhead.extra && X.gzhead.extra.length && (ye(X, X.gzhead.extra.length & 255), ye(X, X.gzhead.extra.length >> 8 & 255)), X.gzhead.hcrc && (I.adler = x(I.adler, X.pending_buf, X.pending, 0)), X.gzindex = 0, X.status = ee) : (ye(X, 0), ye(X, 0), ye(X, 0), ye(X, 0), ye(X, 0), ye(X, X.level === 9 ? 2 : X.strategy >= a || X.level < 2 ? 4 : 0), ye(X, we), X.status = fe); + else { + var Ze = T + (X.w_bits - 8 << 4) << 8, Ke = -1; + X.strategy >= a || X.level < 2 ? Ke = 0 : X.level < 6 ? Ke = 1 : X.level === 6 ? Ke = 2 : Ke = 3, Ze |= Ke << 6, X.strstart !== 0 && (Ze |= Q), Ze += 31 - Ze % 31, X.status = fe, ge(X, Ze), X.strstart !== 0 && (ge(X, I.adler >>> 16), ge(X, I.adler & 65535)), I.adler = 1; + } + if (X.status === ee) + if (X.gzhead.extra) { + for (le = X.pending; X.gzindex < (X.gzhead.extra.length & 65535) && !(X.pending === X.pending_buf_size && (X.gzhead.hcrc && X.pending > le && (I.adler = x(I.adler, X.pending_buf, X.pending - le, le)), Be(I), le = X.pending, X.pending === X.pending_buf_size)); ) + ye(X, X.gzhead.extra[X.gzindex] & 255), X.gzindex++; + X.gzhead.hcrc && X.pending > le && (I.adler = x(I.adler, X.pending_buf, X.pending - le, le)), X.gzindex === X.gzhead.extra.length && (X.gzindex = 0, X.status = ne); + } else + X.status = ne; + if (X.status === ne) + if (X.gzhead.name) { + le = X.pending; + do { + if (X.pending === X.pending_buf_size && (X.gzhead.hcrc && X.pending > le && (I.adler = x(I.adler, X.pending_buf, X.pending - le, le)), Be(I), le = X.pending, X.pending === X.pending_buf_size)) { + Le = 1; + break; + } + X.gzindex < X.gzhead.name.length ? Le = X.gzhead.name.charCodeAt(X.gzindex++) & 255 : Le = 0, ye(X, Le); + } while (Le !== 0); + X.gzhead.hcrc && X.pending > le && (I.adler = x(I.adler, X.pending_buf, X.pending - le, le)), Le === 0 && (X.gzindex = 0, X.status = me); + } else + X.status = me; + if (X.status === me) + if (X.gzhead.comment) { + le = X.pending; + do { + if (X.pending === X.pending_buf_size && (X.gzhead.hcrc && X.pending > le && (I.adler = x(I.adler, X.pending_buf, X.pending - le, le)), Be(I), le = X.pending, X.pending === X.pending_buf_size)) { + Le = 1; + break; + } + X.gzindex < X.gzhead.comment.length ? Le = X.gzhead.comment.charCodeAt(X.gzindex++) & 255 : Le = 0, ye(X, Le); + } while (Le !== 0); + X.gzhead.hcrc && X.pending > le && (I.adler = x(I.adler, X.pending_buf, X.pending - le, le)), Le === 0 && (X.status = se); + } else + X.status = se; + if (X.status === se && (X.gzhead.hcrc ? (X.pending + 2 > X.pending_buf_size && Be(I), X.pending + 2 <= X.pending_buf_size && (ye(X, I.adler & 255), ye(X, I.adler >> 8 & 255), I.adler = 0, X.status = fe)) : X.status = fe), X.pending !== 0) { + if (Be(I), I.avail_out === 0) + return X.last_flush = -1, A; + } else if (I.avail_in === 0 && Ue(be) <= Ue(Ee) && be !== C) + return ke(I, w); + if (X.status === Ce && I.avail_in !== 0) + return ke(I, w); + if (I.avail_in !== 0 || X.lookahead !== 0 || be !== u && X.status !== Ce) { + var je = X.strategy === a ? de(X, be) : X.strategy === l ? q(X, be) : Ie[X.level].func(X, be); + if ((je === ae || je === pe) && (X.status = Ce), je === Me || je === ae) + return I.avail_out === 0 && (X.last_flush = -1), A; + if (je === Te && (be === E ? f._tr_align(X) : be !== b && (f._tr_stored_block(X, 0, 0, !1), be === c && (Ne(X.head), X.lookahead === 0 && (X.strstart = 0, X.block_start = 0, X.insert = 0))), Be(I), I.avail_out === 0)) + return X.last_flush = -1, A; + } + return be !== C ? A : X.wrap <= 0 ? S : (X.wrap === 2 ? (ye(X, I.adler & 255), ye(X, I.adler >> 8 & 255), ye(X, I.adler >> 16 & 255), ye(X, I.adler >> 24 & 255), ye(X, I.total_in & 255), ye(X, I.total_in >> 8 & 255), ye(X, I.total_in >> 16 & 255), ye(X, I.total_in >> 24 & 255)) : (ge(X, I.adler >>> 16), ge(X, I.adler & 65535)), Be(I), X.wrap > 0 && (X.wrap = -X.wrap), X.pending !== 0 ? A : S); + } + function $e(I) { + var be; + return !I || !I.state ? n : (be = I.state.status, be !== oe && be !== ee && be !== ne && be !== me && be !== se && be !== fe && be !== Ce ? ke(I, n) : (I.state = null, be === fe ? ke(I, o) : A)); + } + function Ve(I, be) { + var Ee = be.length, X, le, Le, Ze, Ke, je, Je, Lt; + if (!I || !I.state || (X = I.state, Ze = X.wrap, Ze === 2 || Ze === 1 && X.status !== oe || X.lookahead)) + return n; + for (Ze === 1 && (I.adler = _(I.adler, be, Ee, 0)), X.wrap = 0, Ee >= X.w_size && (Ze === 0 && (Ne(X.head), X.strstart = 0, X.block_start = 0, X.insert = 0), Lt = new s.Buf8(X.w_size), s.arraySet(Lt, be, Ee - X.w_size, X.w_size, 0), be = Lt, Ee = X.w_size), Ke = I.avail_in, je = I.next_in, Je = I.input, I.avail_in = Ee, I.next_in = 0, I.input = be, He(X); X.lookahead >= H; ) { + le = X.strstart, Le = X.lookahead - (H - 1); + do + X.ins_h = (X.ins_h << X.hash_shift ^ X.window[le + H - 1]) & X.hash_mask, X.prev[le & X.w_mask] = X.head[X.ins_h], X.head[X.ins_h] = le, le++; + while (--Le); + X.strstart = le, X.lookahead = H - 1, He(X); + } + return X.strstart += X.lookahead, X.block_start = X.strstart, X.insert = X.lookahead, X.lookahead = 0, X.match_length = X.prev_length = H - 1, X.match_available = 0, I.next_in = je, I.input = Je, I.avail_in = Ke, X.wrap = Ze, A; + } + e.deflateInit = Oe, e.deflateInit2 = he, e.deflateReset = Ae, e.deflateResetKeep = ce, e.deflateSetHeader = Fe, e.deflate = j, e.deflateEnd = $e, e.deflateSetDictionary = Ve, e.deflateInfo = "pako deflate (from Nodeca project)"; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/gzheader.js": ( + /*!*********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/gzheader.js ***! + \*********************************************************************/ + /***/ + (r) => { + function e() { + this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; + } + r.exports = e; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js ***! + \********************************************************************/ + /***/ + (r) => { + var e = 30, t = 12; + r.exports = function(f, _) { + var x, h, u, E, c, C, b, A, S, n, o, w, p, v, a, l, g, M, L, T, D, R, B, P, z; + x = f.state, h = f.next_in, P = f.input, u = h + (f.avail_in - 5), E = f.next_out, z = f.output, c = E - (_ - f.avail_out), C = E + (f.avail_out - 257), b = x.dmax, A = x.wsize, S = x.whave, n = x.wnext, o = x.window, w = x.hold, p = x.bits, v = x.lencode, a = x.distcode, l = (1 << x.lenbits) - 1, g = (1 << x.distbits) - 1; + e: + do { + p < 15 && (w += P[h++] << p, p += 8, w += P[h++] << p, p += 8), M = v[w & l]; + t: + for (; ; ) { + if (L = M >>> 24, w >>>= L, p -= L, L = M >>> 16 & 255, L === 0) + z[E++] = M & 65535; + else if (L & 16) { + T = M & 65535, L &= 15, L && (p < L && (w += P[h++] << p, p += 8), T += w & (1 << L) - 1, w >>>= L, p -= L), p < 15 && (w += P[h++] << p, p += 8, w += P[h++] << p, p += 8), M = a[w & g]; + r: + for (; ; ) { + if (L = M >>> 24, w >>>= L, p -= L, L = M >>> 16 & 255, L & 16) { + if (D = M & 65535, L &= 15, p < L && (w += P[h++] << p, p += 8, p < L && (w += P[h++] << p, p += 8)), D += w & (1 << L) - 1, D > b) { + f.msg = "invalid distance too far back", x.mode = e; + break e; + } + if (w >>>= L, p -= L, L = E - c, D > L) { + if (L = D - L, L > S && x.sane) { + f.msg = "invalid distance too far back", x.mode = e; + break e; + } + if (R = 0, B = o, n === 0) { + if (R += A - L, L < T) { + T -= L; + do + z[E++] = o[R++]; + while (--L); + R = E - D, B = z; + } + } else if (n < L) { + if (R += A + n - L, L -= n, L < T) { + T -= L; + do + z[E++] = o[R++]; + while (--L); + if (R = 0, n < T) { + L = n, T -= L; + do + z[E++] = o[R++]; + while (--L); + R = E - D, B = z; + } + } + } else if (R += n - L, L < T) { + T -= L; + do + z[E++] = o[R++]; + while (--L); + R = E - D, B = z; + } + for (; T > 2; ) + z[E++] = B[R++], z[E++] = B[R++], z[E++] = B[R++], T -= 3; + T && (z[E++] = B[R++], T > 1 && (z[E++] = B[R++])); + } else { + R = E - D; + do + z[E++] = z[R++], z[E++] = z[R++], z[E++] = z[R++], T -= 3; + while (T > 2); + T && (z[E++] = z[R++], T > 1 && (z[E++] = z[R++])); + } + } else if (L & 64) { + f.msg = "invalid distance code", x.mode = e; + break e; + } else { + M = a[(M & 65535) + (w & (1 << L) - 1)]; + continue r; + } + break; + } + } else if (L & 64) + if (L & 32) { + x.mode = t; + break e; + } else { + f.msg = "invalid literal/length code", x.mode = e; + break e; + } + else { + M = v[(M & 65535) + (w & (1 << L) - 1)]; + continue t; + } + break; + } + } while (h < u && E < C); + T = p >> 3, h -= T, p -= T << 3, w &= (1 << p) - 1, f.next_in = h, f.next_out = E, f.avail_in = h < u ? 5 + (u - h) : 5 - (h - u), f.avail_out = E < C ? 257 + (C - E) : 257 - (E - C), x.hold = w, x.bits = p; + }; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inflate.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/inflate.js ***! + \********************************************************************/ + /***/ + (r, e, t) => { + var s = t( + /*! ../utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), f = t( + /*! ./adler32 */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js" + ), _ = t( + /*! ./crc32 */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js" + ), x = t( + /*! ./inffast */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js" + ), h = t( + /*! ./inftrees */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inftrees.js" + ), u = 0, E = 1, c = 2, C = 4, b = 5, A = 6, S = 0, n = 1, o = 2, w = -2, p = -3, v = -4, a = -5, l = 8, g = 1, M = 2, L = 3, T = 4, D = 5, R = 6, B = 7, P = 8, z = 9, F = 10, N = 11, $ = 12, k = 13, G = 14, H = 15, U = 16, V = 17, Q = 18, oe = 19, ee = 20, ne = 21, me = 22, se = 23, fe = 24, Ce = 25, Me = 26, Te = 27, ae = 28, pe = 29, we = 30, ke = 31, Ue = 32, Ne = 852, Be = 592, ue = 15, ye = ue; + function ge(he) { + return (he >>> 24 & 255) + (he >>> 8 & 65280) + ((he & 65280) << 8) + ((he & 255) << 24); + } + function Se() { + this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new s.Buf16(320), this.work = new s.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; + } + function ze(he) { + var Oe; + return !he || !he.state ? w : (Oe = he.state, he.total_in = he.total_out = Oe.total = 0, he.msg = "", Oe.wrap && (he.adler = Oe.wrap & 1), Oe.mode = g, Oe.last = 0, Oe.havedict = 0, Oe.dmax = 32768, Oe.head = null, Oe.hold = 0, Oe.bits = 0, Oe.lencode = Oe.lendyn = new s.Buf32(Ne), Oe.distcode = Oe.distdyn = new s.Buf32(Be), Oe.sane = 1, Oe.back = -1, S); + } + function He(he) { + var Oe; + return !he || !he.state ? w : (Oe = he.state, Oe.wsize = 0, Oe.whave = 0, Oe.wnext = 0, ze(he)); + } + function We(he, Oe) { + var j, $e; + return !he || !he.state || ($e = he.state, Oe < 0 ? (j = 0, Oe = -Oe) : (j = (Oe >> 4) + 1, Oe < 48 && (Oe &= 15)), Oe && (Oe < 8 || Oe > 15)) ? w : ($e.window !== null && $e.wbits !== Oe && ($e.window = null), $e.wrap = j, $e.wbits = Oe, He(he)); + } + function Y(he, Oe) { + var j, $e; + return he ? ($e = new Se(), he.state = $e, $e.window = null, j = We(he, Oe), j !== S && (he.state = null), j) : w; + } + function K(he) { + return Y(he, ye); + } + var q = !0, de, ve; + function Ie(he) { + if (q) { + var Oe; + for (de = new s.Buf32(512), ve = new s.Buf32(32), Oe = 0; Oe < 144; ) + he.lens[Oe++] = 8; + for (; Oe < 256; ) + he.lens[Oe++] = 9; + for (; Oe < 280; ) + he.lens[Oe++] = 7; + for (; Oe < 288; ) + he.lens[Oe++] = 8; + for (h(E, he.lens, 0, 288, de, 0, he.work, { bits: 9 }), Oe = 0; Oe < 32; ) + he.lens[Oe++] = 5; + h(c, he.lens, 0, 32, ve, 0, he.work, { bits: 5 }), q = !1; + } + he.lencode = de, he.lenbits = 9, he.distcode = ve, he.distbits = 5; + } + function Re(he, Oe, j, $e) { + var Ve, I = he.state; + return I.window === null && (I.wsize = 1 << I.wbits, I.wnext = 0, I.whave = 0, I.window = new s.Buf8(I.wsize)), $e >= I.wsize ? (s.arraySet(I.window, Oe, j - I.wsize, I.wsize, 0), I.wnext = 0, I.whave = I.wsize) : (Ve = I.wsize - I.wnext, Ve > $e && (Ve = $e), s.arraySet(I.window, Oe, j - $e, Ve, I.wnext), $e -= Ve, $e ? (s.arraySet(I.window, Oe, j - $e, $e, 0), I.wnext = $e, I.whave = I.wsize) : (I.wnext += Ve, I.wnext === I.wsize && (I.wnext = 0), I.whave < I.wsize && (I.whave += Ve))), 0; + } + function Z(he, Oe) { + var j, $e, Ve, I, be, Ee, X, le, Le, Ze, Ke, je, Je, Lt, rt = 0, it, tt, Et, lt, wt, Pt, vt, bt, mt = new s.Buf8(4), Tt, Ot, Ft = ( + /* permutation of code lengths */ + [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15] + ); + if (!he || !he.state || !he.output || !he.input && he.avail_in !== 0) + return w; + j = he.state, j.mode === $ && (j.mode = k), be = he.next_out, Ve = he.output, X = he.avail_out, I = he.next_in, $e = he.input, Ee = he.avail_in, le = j.hold, Le = j.bits, Ze = Ee, Ke = X, bt = S; + e: + for (; ; ) + switch (j.mode) { + case g: + if (j.wrap === 0) { + j.mode = k; + break; + } + for (; Le < 16; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (j.wrap & 2 && le === 35615) { + j.check = 0, mt[0] = le & 255, mt[1] = le >>> 8 & 255, j.check = _(j.check, mt, 2, 0), le = 0, Le = 0, j.mode = M; + break; + } + if (j.flags = 0, j.head && (j.head.done = !1), !(j.wrap & 1) || /* check if zlib header allowed */ + (((le & 255) << 8) + (le >> 8)) % 31) { + he.msg = "incorrect header check", j.mode = we; + break; + } + if ((le & 15) !== l) { + he.msg = "unknown compression method", j.mode = we; + break; + } + if (le >>>= 4, Le -= 4, vt = (le & 15) + 8, j.wbits === 0) + j.wbits = vt; + else if (vt > j.wbits) { + he.msg = "invalid window size", j.mode = we; + break; + } + j.dmax = 1 << vt, he.adler = j.check = 1, j.mode = le & 512 ? F : $, le = 0, Le = 0; + break; + case M: + for (; Le < 16; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (j.flags = le, (j.flags & 255) !== l) { + he.msg = "unknown compression method", j.mode = we; + break; + } + if (j.flags & 57344) { + he.msg = "unknown header flags set", j.mode = we; + break; + } + j.head && (j.head.text = le >> 8 & 1), j.flags & 512 && (mt[0] = le & 255, mt[1] = le >>> 8 & 255, j.check = _(j.check, mt, 2, 0)), le = 0, Le = 0, j.mode = L; + case L: + for (; Le < 32; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + j.head && (j.head.time = le), j.flags & 512 && (mt[0] = le & 255, mt[1] = le >>> 8 & 255, mt[2] = le >>> 16 & 255, mt[3] = le >>> 24 & 255, j.check = _(j.check, mt, 4, 0)), le = 0, Le = 0, j.mode = T; + case T: + for (; Le < 16; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + j.head && (j.head.xflags = le & 255, j.head.os = le >> 8), j.flags & 512 && (mt[0] = le & 255, mt[1] = le >>> 8 & 255, j.check = _(j.check, mt, 2, 0)), le = 0, Le = 0, j.mode = D; + case D: + if (j.flags & 1024) { + for (; Le < 16; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + j.length = le, j.head && (j.head.extra_len = le), j.flags & 512 && (mt[0] = le & 255, mt[1] = le >>> 8 & 255, j.check = _(j.check, mt, 2, 0)), le = 0, Le = 0; + } else + j.head && (j.head.extra = null); + j.mode = R; + case R: + if (j.flags & 1024 && (je = j.length, je > Ee && (je = Ee), je && (j.head && (vt = j.head.extra_len - j.length, j.head.extra || (j.head.extra = new Array(j.head.extra_len)), s.arraySet( + j.head.extra, + $e, + I, + // extra field is limited to 65536 bytes + // - no need for additional size check + je, + /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ + vt + )), j.flags & 512 && (j.check = _(j.check, $e, je, I)), Ee -= je, I += je, j.length -= je), j.length)) + break e; + j.length = 0, j.mode = B; + case B: + if (j.flags & 2048) { + if (Ee === 0) + break e; + je = 0; + do + vt = $e[I + je++], j.head && vt && j.length < 65536 && (j.head.name += String.fromCharCode(vt)); + while (vt && je < Ee); + if (j.flags & 512 && (j.check = _(j.check, $e, je, I)), Ee -= je, I += je, vt) + break e; + } else + j.head && (j.head.name = null); + j.length = 0, j.mode = P; + case P: + if (j.flags & 4096) { + if (Ee === 0) + break e; + je = 0; + do + vt = $e[I + je++], j.head && vt && j.length < 65536 && (j.head.comment += String.fromCharCode(vt)); + while (vt && je < Ee); + if (j.flags & 512 && (j.check = _(j.check, $e, je, I)), Ee -= je, I += je, vt) + break e; + } else + j.head && (j.head.comment = null); + j.mode = z; + case z: + if (j.flags & 512) { + for (; Le < 16; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (le !== (j.check & 65535)) { + he.msg = "header crc mismatch", j.mode = we; + break; + } + le = 0, Le = 0; + } + j.head && (j.head.hcrc = j.flags >> 9 & 1, j.head.done = !0), he.adler = j.check = 0, j.mode = $; + break; + case F: + for (; Le < 32; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + he.adler = j.check = ge(le), le = 0, Le = 0, j.mode = N; + case N: + if (j.havedict === 0) + return he.next_out = be, he.avail_out = X, he.next_in = I, he.avail_in = Ee, j.hold = le, j.bits = Le, o; + he.adler = j.check = 1, j.mode = $; + case $: + if (Oe === b || Oe === A) + break e; + case k: + if (j.last) { + le >>>= Le & 7, Le -= Le & 7, j.mode = Te; + break; + } + for (; Le < 3; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + switch (j.last = le & 1, le >>>= 1, Le -= 1, le & 3) { + case 0: + j.mode = G; + break; + case 1: + if (Ie(j), j.mode = ee, Oe === A) { + le >>>= 2, Le -= 2; + break e; + } + break; + case 2: + j.mode = V; + break; + case 3: + he.msg = "invalid block type", j.mode = we; + } + le >>>= 2, Le -= 2; + break; + case G: + for (le >>>= Le & 7, Le -= Le & 7; Le < 32; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if ((le & 65535) !== (le >>> 16 ^ 65535)) { + he.msg = "invalid stored block lengths", j.mode = we; + break; + } + if (j.length = le & 65535, le = 0, Le = 0, j.mode = H, Oe === A) + break e; + case H: + j.mode = U; + case U: + if (je = j.length, je) { + if (je > Ee && (je = Ee), je > X && (je = X), je === 0) + break e; + s.arraySet(Ve, $e, I, je, be), Ee -= je, I += je, X -= je, be += je, j.length -= je; + break; + } + j.mode = $; + break; + case V: + for (; Le < 14; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (j.nlen = (le & 31) + 257, le >>>= 5, Le -= 5, j.ndist = (le & 31) + 1, le >>>= 5, Le -= 5, j.ncode = (le & 15) + 4, le >>>= 4, Le -= 4, j.nlen > 286 || j.ndist > 30) { + he.msg = "too many length or distance symbols", j.mode = we; + break; + } + j.have = 0, j.mode = Q; + case Q: + for (; j.have < j.ncode; ) { + for (; Le < 3; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + j.lens[Ft[j.have++]] = le & 7, le >>>= 3, Le -= 3; + } + for (; j.have < 19; ) + j.lens[Ft[j.have++]] = 0; + if (j.lencode = j.lendyn, j.lenbits = 7, Tt = { bits: j.lenbits }, bt = h(u, j.lens, 0, 19, j.lencode, 0, j.work, Tt), j.lenbits = Tt.bits, bt) { + he.msg = "invalid code lengths set", j.mode = we; + break; + } + j.have = 0, j.mode = oe; + case oe: + for (; j.have < j.nlen + j.ndist; ) { + for (; rt = j.lencode[le & (1 << j.lenbits) - 1], it = rt >>> 24, tt = rt >>> 16 & 255, Et = rt & 65535, !(it <= Le); ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (Et < 16) + le >>>= it, Le -= it, j.lens[j.have++] = Et; + else { + if (Et === 16) { + for (Ot = it + 2; Le < Ot; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (le >>>= it, Le -= it, j.have === 0) { + he.msg = "invalid bit length repeat", j.mode = we; + break; + } + vt = j.lens[j.have - 1], je = 3 + (le & 3), le >>>= 2, Le -= 2; + } else if (Et === 17) { + for (Ot = it + 3; Le < Ot; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + le >>>= it, Le -= it, vt = 0, je = 3 + (le & 7), le >>>= 3, Le -= 3; + } else { + for (Ot = it + 7; Le < Ot; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + le >>>= it, Le -= it, vt = 0, je = 11 + (le & 127), le >>>= 7, Le -= 7; + } + if (j.have + je > j.nlen + j.ndist) { + he.msg = "invalid bit length repeat", j.mode = we; + break; + } + for (; je--; ) + j.lens[j.have++] = vt; + } + } + if (j.mode === we) + break; + if (j.lens[256] === 0) { + he.msg = "invalid code -- missing end-of-block", j.mode = we; + break; + } + if (j.lenbits = 9, Tt = { bits: j.lenbits }, bt = h(E, j.lens, 0, j.nlen, j.lencode, 0, j.work, Tt), j.lenbits = Tt.bits, bt) { + he.msg = "invalid literal/lengths set", j.mode = we; + break; + } + if (j.distbits = 6, j.distcode = j.distdyn, Tt = { bits: j.distbits }, bt = h(c, j.lens, j.nlen, j.ndist, j.distcode, 0, j.work, Tt), j.distbits = Tt.bits, bt) { + he.msg = "invalid distances set", j.mode = we; + break; + } + if (j.mode = ee, Oe === A) + break e; + case ee: + j.mode = ne; + case ne: + if (Ee >= 6 && X >= 258) { + he.next_out = be, he.avail_out = X, he.next_in = I, he.avail_in = Ee, j.hold = le, j.bits = Le, x(he, Ke), be = he.next_out, Ve = he.output, X = he.avail_out, I = he.next_in, $e = he.input, Ee = he.avail_in, le = j.hold, Le = j.bits, j.mode === $ && (j.back = -1); + break; + } + for (j.back = 0; rt = j.lencode[le & (1 << j.lenbits) - 1], it = rt >>> 24, tt = rt >>> 16 & 255, Et = rt & 65535, !(it <= Le); ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (tt && !(tt & 240)) { + for (lt = it, wt = tt, Pt = Et; rt = j.lencode[Pt + ((le & (1 << lt + wt) - 1) >> lt)], it = rt >>> 24, tt = rt >>> 16 & 255, Et = rt & 65535, !(lt + it <= Le); ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + le >>>= lt, Le -= lt, j.back += lt; + } + if (le >>>= it, Le -= it, j.back += it, j.length = Et, tt === 0) { + j.mode = Me; + break; + } + if (tt & 32) { + j.back = -1, j.mode = $; + break; + } + if (tt & 64) { + he.msg = "invalid literal/length code", j.mode = we; + break; + } + j.extra = tt & 15, j.mode = me; + case me: + if (j.extra) { + for (Ot = j.extra; Le < Ot; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + j.length += le & (1 << j.extra) - 1, le >>>= j.extra, Le -= j.extra, j.back += j.extra; + } + j.was = j.length, j.mode = se; + case se: + for (; rt = j.distcode[le & (1 << j.distbits) - 1], it = rt >>> 24, tt = rt >>> 16 & 255, Et = rt & 65535, !(it <= Le); ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (!(tt & 240)) { + for (lt = it, wt = tt, Pt = Et; rt = j.distcode[Pt + ((le & (1 << lt + wt) - 1) >> lt)], it = rt >>> 24, tt = rt >>> 16 & 255, Et = rt & 65535, !(lt + it <= Le); ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + le >>>= lt, Le -= lt, j.back += lt; + } + if (le >>>= it, Le -= it, j.back += it, tt & 64) { + he.msg = "invalid distance code", j.mode = we; + break; + } + j.offset = Et, j.extra = tt & 15, j.mode = fe; + case fe: + if (j.extra) { + for (Ot = j.extra; Le < Ot; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + j.offset += le & (1 << j.extra) - 1, le >>>= j.extra, Le -= j.extra, j.back += j.extra; + } + if (j.offset > j.dmax) { + he.msg = "invalid distance too far back", j.mode = we; + break; + } + j.mode = Ce; + case Ce: + if (X === 0) + break e; + if (je = Ke - X, j.offset > je) { + if (je = j.offset - je, je > j.whave && j.sane) { + he.msg = "invalid distance too far back", j.mode = we; + break; + } + je > j.wnext ? (je -= j.wnext, Je = j.wsize - je) : Je = j.wnext - je, je > j.length && (je = j.length), Lt = j.window; + } else + Lt = Ve, Je = be - j.offset, je = j.length; + je > X && (je = X), X -= je, j.length -= je; + do + Ve[be++] = Lt[Je++]; + while (--je); + j.length === 0 && (j.mode = ne); + break; + case Me: + if (X === 0) + break e; + Ve[be++] = j.length, X--, j.mode = ne; + break; + case Te: + if (j.wrap) { + for (; Le < 32; ) { + if (Ee === 0) + break e; + Ee--, le |= $e[I++] << Le, Le += 8; + } + if (Ke -= X, he.total_out += Ke, j.total += Ke, Ke && (he.adler = j.check = /*UPDATE(state.check, put - _out, _out);*/ + j.flags ? _(j.check, Ve, Ke, be - Ke) : f(j.check, Ve, Ke, be - Ke)), Ke = X, (j.flags ? le : ge(le)) !== j.check) { + he.msg = "incorrect data check", j.mode = we; + break; + } + le = 0, Le = 0; + } + j.mode = ae; + case ae: + if (j.wrap && j.flags) { + for (; Le < 32; ) { + if (Ee === 0) + break e; + Ee--, le += $e[I++] << Le, Le += 8; + } + if (le !== (j.total & 4294967295)) { + he.msg = "incorrect length check", j.mode = we; + break; + } + le = 0, Le = 0; + } + j.mode = pe; + case pe: + bt = n; + break e; + case we: + bt = p; + break e; + case ke: + return v; + case Ue: + default: + return w; + } + return he.next_out = be, he.avail_out = X, he.next_in = I, he.avail_in = Ee, j.hold = le, j.bits = Le, (j.wsize || Ke !== he.avail_out && j.mode < we && (j.mode < Te || Oe !== C)) && Re(he, he.output, he.next_out, Ke - he.avail_out), Ze -= he.avail_in, Ke -= he.avail_out, he.total_in += Ze, he.total_out += Ke, j.total += Ke, j.wrap && Ke && (he.adler = j.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ + j.flags ? _(j.check, Ve, Ke, he.next_out - Ke) : f(j.check, Ve, Ke, he.next_out - Ke)), he.data_type = j.bits + (j.last ? 64 : 0) + (j.mode === $ ? 128 : 0) + (j.mode === ee || j.mode === H ? 256 : 0), (Ze === 0 && Ke === 0 || Oe === C) && bt === S && (bt = a), bt; + } + function ce(he) { + if (!he || !he.state) + return w; + var Oe = he.state; + return Oe.window && (Oe.window = null), he.state = null, S; + } + function Ae(he, Oe) { + var j; + return !he || !he.state || (j = he.state, !(j.wrap & 2)) ? w : (j.head = Oe, Oe.done = !1, S); + } + function Fe(he, Oe) { + var j = Oe.length, $e, Ve, I; + return !he || !he.state || ($e = he.state, $e.wrap !== 0 && $e.mode !== N) ? w : $e.mode === N && (Ve = 1, Ve = f(Ve, Oe, j, 0), Ve !== $e.check) ? p : (I = Re(he, Oe, j, j), I ? ($e.mode = ke, v) : ($e.havedict = 1, S)); + } + e.inflateReset = He, e.inflateReset2 = We, e.inflateResetKeep = ze, e.inflateInit = K, e.inflateInit2 = Y, e.inflate = Z, e.inflateEnd = ce, e.inflateGetHeader = Ae, e.inflateSetDictionary = Fe, e.inflateInfo = "pako inflate (from Nodeca project)"; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inftrees.js": ( + /*!*********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/inftrees.js ***! + \*********************************************************************/ + /***/ + (r, e, t) => { + var s = t( + /*! ../utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), f = 15, _ = 852, x = 592, h = 0, u = 1, E = 2, c = [ + /* Length codes 257..285 base */ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 13, + 15, + 17, + 19, + 23, + 27, + 31, + 35, + 43, + 51, + 59, + 67, + 83, + 99, + 115, + 131, + 163, + 195, + 227, + 258, + 0, + 0 + ], C = [ + /* Length codes 257..285 extra */ + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 17, + 17, + 17, + 17, + 18, + 18, + 18, + 18, + 19, + 19, + 19, + 19, + 20, + 20, + 20, + 20, + 21, + 21, + 21, + 21, + 16, + 72, + 78 + ], b = [ + /* Distance codes 0..29 base */ + 1, + 2, + 3, + 4, + 5, + 7, + 9, + 13, + 17, + 25, + 33, + 49, + 65, + 97, + 129, + 193, + 257, + 385, + 513, + 769, + 1025, + 1537, + 2049, + 3073, + 4097, + 6145, + 8193, + 12289, + 16385, + 24577, + 0, + 0 + ], A = [ + /* Distance codes 0..29 extra */ + 16, + 16, + 16, + 16, + 17, + 17, + 18, + 18, + 19, + 19, + 20, + 20, + 21, + 21, + 22, + 22, + 23, + 23, + 24, + 24, + 25, + 25, + 26, + 26, + 27, + 27, + 28, + 28, + 29, + 29, + 64, + 64 + ]; + r.exports = function(n, o, w, p, v, a, l, g) { + var M = g.bits, L = 0, T = 0, D = 0, R = 0, B = 0, P = 0, z = 0, F = 0, N = 0, $ = 0, k, G, H, U, V, Q = null, oe = 0, ee, ne = new s.Buf16(f + 1), me = new s.Buf16(f + 1), se = null, fe = 0, Ce, Me, Te; + for (L = 0; L <= f; L++) + ne[L] = 0; + for (T = 0; T < p; T++) + ne[o[w + T]]++; + for (B = M, R = f; R >= 1 && ne[R] === 0; R--) + ; + if (B > R && (B = R), R === 0) + return v[a++] = 20971520, v[a++] = 20971520, g.bits = 1, 0; + for (D = 1; D < R && ne[D] === 0; D++) + ; + for (B < D && (B = D), F = 1, L = 1; L <= f; L++) + if (F <<= 1, F -= ne[L], F < 0) + return -1; + if (F > 0 && (n === h || R !== 1)) + return -1; + for (me[1] = 0, L = 1; L < f; L++) + me[L + 1] = me[L] + ne[L]; + for (T = 0; T < p; T++) + o[w + T] !== 0 && (l[me[o[w + T]]++] = T); + if (n === h ? (Q = se = l, ee = 19) : n === u ? (Q = c, oe -= 257, se = C, fe -= 257, ee = 256) : (Q = b, se = A, ee = -1), $ = 0, T = 0, L = D, V = a, P = B, z = 0, H = -1, N = 1 << B, U = N - 1, n === u && N > _ || n === E && N > x) + return 1; + for (; ; ) { + Ce = L - z, l[T] < ee ? (Me = 0, Te = l[T]) : l[T] > ee ? (Me = se[fe + l[T]], Te = Q[oe + l[T]]) : (Me = 96, Te = 0), k = 1 << L - z, G = 1 << P, D = G; + do + G -= k, v[V + ($ >> z) + G] = Ce << 24 | Me << 16 | Te | 0; + while (G !== 0); + for (k = 1 << L - 1; $ & k; ) + k >>= 1; + if (k !== 0 ? ($ &= k - 1, $ += k) : $ = 0, T++, --ne[L] === 0) { + if (L === R) + break; + L = o[w + l[T]]; + } + if (L > B && ($ & U) !== H) { + for (z === 0 && (z = B), V += D, P = L - z, F = 1 << P; P + z < R && (F -= ne[P + z], !(F <= 0)); ) + P++, F <<= 1; + if (N += 1 << P, n === u && N > _ || n === E && N > x) + return 1; + H = $ & U, v[H] = B << 24 | P << 16 | V - a | 0; + } + } + return $ !== 0 && (v[V + $] = L - z << 24 | 4194304 | 0), g.bits = B, 0; + }; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js": ( + /*!*********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js ***! + \*********************************************************************/ + /***/ + (r) => { + r.exports = { + 2: "need dictionary", + /* Z_NEED_DICT 2 */ + 1: "stream end", + /* Z_STREAM_END 1 */ + 0: "", + /* Z_OK 0 */ + "-1": "file error", + /* Z_ERRNO (-1) */ + "-2": "stream error", + /* Z_STREAM_ERROR (-2) */ + "-3": "data error", + /* Z_DATA_ERROR (-3) */ + "-4": "insufficient memory", + /* Z_MEM_ERROR (-4) */ + "-5": "buffer error", + /* Z_BUF_ERROR (-5) */ + "-6": "incompatible version" + /* Z_VERSION_ERROR (-6) */ + }; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/trees.js": ( + /*!******************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/trees.js ***! + \******************************************************************/ + /***/ + (r, e, t) => { + var s = t( + /*! ../utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), f = 4, _ = 0, x = 1, h = 2; + function u(Z) { + for (var ce = Z.length; --ce >= 0; ) + Z[ce] = 0; + } + var E = 0, c = 1, C = 2, b = 3, A = 258, S = 29, n = 256, o = n + 1 + S, w = 30, p = 19, v = 2 * o + 1, a = 15, l = 16, g = 7, M = 256, L = 16, T = 17, D = 18, R = ( + /* extra bits for each length code */ + [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0] + ), B = ( + /* extra bits for each distance code */ + [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13] + ), P = ( + /* extra bits for each bit length code */ + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7] + ), z = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], F = 512, N = new Array((o + 2) * 2); + u(N); + var $ = new Array(w * 2); + u($); + var k = new Array(F); + u(k); + var G = new Array(A - b + 1); + u(G); + var H = new Array(S); + u(H); + var U = new Array(w); + u(U); + function V(Z, ce, Ae, Fe, he) { + this.static_tree = Z, this.extra_bits = ce, this.extra_base = Ae, this.elems = Fe, this.max_length = he, this.has_stree = Z && Z.length; + } + var Q, oe, ee; + function ne(Z, ce) { + this.dyn_tree = Z, this.max_code = 0, this.stat_desc = ce; + } + function me(Z) { + return Z < 256 ? k[Z] : k[256 + (Z >>> 7)]; + } + function se(Z, ce) { + Z.pending_buf[Z.pending++] = ce & 255, Z.pending_buf[Z.pending++] = ce >>> 8 & 255; + } + function fe(Z, ce, Ae) { + Z.bi_valid > l - Ae ? (Z.bi_buf |= ce << Z.bi_valid & 65535, se(Z, Z.bi_buf), Z.bi_buf = ce >> l - Z.bi_valid, Z.bi_valid += Ae - l) : (Z.bi_buf |= ce << Z.bi_valid & 65535, Z.bi_valid += Ae); + } + function Ce(Z, ce, Ae) { + fe( + Z, + Ae[ce * 2], + Ae[ce * 2 + 1] + /*.Len*/ + ); + } + function Me(Z, ce) { + var Ae = 0; + do + Ae |= Z & 1, Z >>>= 1, Ae <<= 1; + while (--ce > 0); + return Ae >>> 1; + } + function Te(Z) { + Z.bi_valid === 16 ? (se(Z, Z.bi_buf), Z.bi_buf = 0, Z.bi_valid = 0) : Z.bi_valid >= 8 && (Z.pending_buf[Z.pending++] = Z.bi_buf & 255, Z.bi_buf >>= 8, Z.bi_valid -= 8); + } + function ae(Z, ce) { + var Ae = ce.dyn_tree, Fe = ce.max_code, he = ce.stat_desc.static_tree, Oe = ce.stat_desc.has_stree, j = ce.stat_desc.extra_bits, $e = ce.stat_desc.extra_base, Ve = ce.stat_desc.max_length, I, be, Ee, X, le, Le, Ze = 0; + for (X = 0; X <= a; X++) + Z.bl_count[X] = 0; + for (Ae[Z.heap[Z.heap_max] * 2 + 1] = 0, I = Z.heap_max + 1; I < v; I++) + be = Z.heap[I], X = Ae[Ae[be * 2 + 1] * 2 + 1] + 1, X > Ve && (X = Ve, Ze++), Ae[be * 2 + 1] = X, !(be > Fe) && (Z.bl_count[X]++, le = 0, be >= $e && (le = j[be - $e]), Le = Ae[be * 2], Z.opt_len += Le * (X + le), Oe && (Z.static_len += Le * (he[be * 2 + 1] + le))); + if (Ze !== 0) { + do { + for (X = Ve - 1; Z.bl_count[X] === 0; ) + X--; + Z.bl_count[X]--, Z.bl_count[X + 1] += 2, Z.bl_count[Ve]--, Ze -= 2; + } while (Ze > 0); + for (X = Ve; X !== 0; X--) + for (be = Z.bl_count[X]; be !== 0; ) + Ee = Z.heap[--I], !(Ee > Fe) && (Ae[Ee * 2 + 1] !== X && (Z.opt_len += (X - Ae[Ee * 2 + 1]) * Ae[Ee * 2], Ae[Ee * 2 + 1] = X), be--); + } + } + function pe(Z, ce, Ae) { + var Fe = new Array(a + 1), he = 0, Oe, j; + for (Oe = 1; Oe <= a; Oe++) + Fe[Oe] = he = he + Ae[Oe - 1] << 1; + for (j = 0; j <= ce; j++) { + var $e = Z[j * 2 + 1]; + $e !== 0 && (Z[j * 2] = Me(Fe[$e]++, $e)); + } + } + function we() { + var Z, ce, Ae, Fe, he, Oe = new Array(a + 1); + for (Ae = 0, Fe = 0; Fe < S - 1; Fe++) + for (H[Fe] = Ae, Z = 0; Z < 1 << R[Fe]; Z++) + G[Ae++] = Fe; + for (G[Ae - 1] = Fe, he = 0, Fe = 0; Fe < 16; Fe++) + for (U[Fe] = he, Z = 0; Z < 1 << B[Fe]; Z++) + k[he++] = Fe; + for (he >>= 7; Fe < w; Fe++) + for (U[Fe] = he << 7, Z = 0; Z < 1 << B[Fe] - 7; Z++) + k[256 + he++] = Fe; + for (ce = 0; ce <= a; ce++) + Oe[ce] = 0; + for (Z = 0; Z <= 143; ) + N[Z * 2 + 1] = 8, Z++, Oe[8]++; + for (; Z <= 255; ) + N[Z * 2 + 1] = 9, Z++, Oe[9]++; + for (; Z <= 279; ) + N[Z * 2 + 1] = 7, Z++, Oe[7]++; + for (; Z <= 287; ) + N[Z * 2 + 1] = 8, Z++, Oe[8]++; + for (pe(N, o + 1, Oe), Z = 0; Z < w; Z++) + $[Z * 2 + 1] = 5, $[Z * 2] = Me(Z, 5); + Q = new V(N, R, n + 1, o, a), oe = new V($, B, 0, w, a), ee = new V(new Array(0), P, 0, p, g); + } + function ke(Z) { + var ce; + for (ce = 0; ce < o; ce++) + Z.dyn_ltree[ce * 2] = 0; + for (ce = 0; ce < w; ce++) + Z.dyn_dtree[ce * 2] = 0; + for (ce = 0; ce < p; ce++) + Z.bl_tree[ce * 2] = 0; + Z.dyn_ltree[M * 2] = 1, Z.opt_len = Z.static_len = 0, Z.last_lit = Z.matches = 0; + } + function Ue(Z) { + Z.bi_valid > 8 ? se(Z, Z.bi_buf) : Z.bi_valid > 0 && (Z.pending_buf[Z.pending++] = Z.bi_buf), Z.bi_buf = 0, Z.bi_valid = 0; + } + function Ne(Z, ce, Ae, Fe) { + Ue(Z), Fe && (se(Z, Ae), se(Z, ~Ae)), s.arraySet(Z.pending_buf, Z.window, ce, Ae, Z.pending), Z.pending += Ae; + } + function Be(Z, ce, Ae, Fe) { + var he = ce * 2, Oe = Ae * 2; + return Z[he] < Z[Oe] || Z[he] === Z[Oe] && Fe[ce] <= Fe[Ae]; + } + function ue(Z, ce, Ae) { + for (var Fe = Z.heap[Ae], he = Ae << 1; he <= Z.heap_len && (he < Z.heap_len && Be(ce, Z.heap[he + 1], Z.heap[he], Z.depth) && he++, !Be(ce, Fe, Z.heap[he], Z.depth)); ) + Z.heap[Ae] = Z.heap[he], Ae = he, he <<= 1; + Z.heap[Ae] = Fe; + } + function ye(Z, ce, Ae) { + var Fe, he, Oe = 0, j, $e; + if (Z.last_lit !== 0) + do + Fe = Z.pending_buf[Z.d_buf + Oe * 2] << 8 | Z.pending_buf[Z.d_buf + Oe * 2 + 1], he = Z.pending_buf[Z.l_buf + Oe], Oe++, Fe === 0 ? Ce(Z, he, ce) : (j = G[he], Ce(Z, j + n + 1, ce), $e = R[j], $e !== 0 && (he -= H[j], fe(Z, he, $e)), Fe--, j = me(Fe), Ce(Z, j, Ae), $e = B[j], $e !== 0 && (Fe -= U[j], fe(Z, Fe, $e))); + while (Oe < Z.last_lit); + Ce(Z, M, ce); + } + function ge(Z, ce) { + var Ae = ce.dyn_tree, Fe = ce.stat_desc.static_tree, he = ce.stat_desc.has_stree, Oe = ce.stat_desc.elems, j, $e, Ve = -1, I; + for (Z.heap_len = 0, Z.heap_max = v, j = 0; j < Oe; j++) + Ae[j * 2] !== 0 ? (Z.heap[++Z.heap_len] = Ve = j, Z.depth[j] = 0) : Ae[j * 2 + 1] = 0; + for (; Z.heap_len < 2; ) + I = Z.heap[++Z.heap_len] = Ve < 2 ? ++Ve : 0, Ae[I * 2] = 1, Z.depth[I] = 0, Z.opt_len--, he && (Z.static_len -= Fe[I * 2 + 1]); + for (ce.max_code = Ve, j = Z.heap_len >> 1; j >= 1; j--) + ue(Z, Ae, j); + I = Oe; + do + j = Z.heap[ + 1 + /*SMALLEST*/ + ], Z.heap[ + 1 + /*SMALLEST*/ + ] = Z.heap[Z.heap_len--], ue( + Z, + Ae, + 1 + /*SMALLEST*/ + ), $e = Z.heap[ + 1 + /*SMALLEST*/ + ], Z.heap[--Z.heap_max] = j, Z.heap[--Z.heap_max] = $e, Ae[I * 2] = Ae[j * 2] + Ae[$e * 2], Z.depth[I] = (Z.depth[j] >= Z.depth[$e] ? Z.depth[j] : Z.depth[$e]) + 1, Ae[j * 2 + 1] = Ae[$e * 2 + 1] = I, Z.heap[ + 1 + /*SMALLEST*/ + ] = I++, ue( + Z, + Ae, + 1 + /*SMALLEST*/ + ); + while (Z.heap_len >= 2); + Z.heap[--Z.heap_max] = Z.heap[ + 1 + /*SMALLEST*/ + ], ae(Z, ce), pe(Ae, Ve, Z.bl_count); + } + function Se(Z, ce, Ae) { + var Fe, he = -1, Oe, j = ce[0 * 2 + 1], $e = 0, Ve = 7, I = 4; + for (j === 0 && (Ve = 138, I = 3), ce[(Ae + 1) * 2 + 1] = 65535, Fe = 0; Fe <= Ae; Fe++) + Oe = j, j = ce[(Fe + 1) * 2 + 1], !(++$e < Ve && Oe === j) && ($e < I ? Z.bl_tree[Oe * 2] += $e : Oe !== 0 ? (Oe !== he && Z.bl_tree[Oe * 2]++, Z.bl_tree[L * 2]++) : $e <= 10 ? Z.bl_tree[T * 2]++ : Z.bl_tree[D * 2]++, $e = 0, he = Oe, j === 0 ? (Ve = 138, I = 3) : Oe === j ? (Ve = 6, I = 3) : (Ve = 7, I = 4)); + } + function ze(Z, ce, Ae) { + var Fe, he = -1, Oe, j = ce[0 * 2 + 1], $e = 0, Ve = 7, I = 4; + for (j === 0 && (Ve = 138, I = 3), Fe = 0; Fe <= Ae; Fe++) + if (Oe = j, j = ce[(Fe + 1) * 2 + 1], !(++$e < Ve && Oe === j)) { + if ($e < I) + do + Ce(Z, Oe, Z.bl_tree); + while (--$e !== 0); + else + Oe !== 0 ? (Oe !== he && (Ce(Z, Oe, Z.bl_tree), $e--), Ce(Z, L, Z.bl_tree), fe(Z, $e - 3, 2)) : $e <= 10 ? (Ce(Z, T, Z.bl_tree), fe(Z, $e - 3, 3)) : (Ce(Z, D, Z.bl_tree), fe(Z, $e - 11, 7)); + $e = 0, he = Oe, j === 0 ? (Ve = 138, I = 3) : Oe === j ? (Ve = 6, I = 3) : (Ve = 7, I = 4); + } + } + function He(Z) { + var ce; + for (Se(Z, Z.dyn_ltree, Z.l_desc.max_code), Se(Z, Z.dyn_dtree, Z.d_desc.max_code), ge(Z, Z.bl_desc), ce = p - 1; ce >= 3 && Z.bl_tree[z[ce] * 2 + 1] === 0; ce--) + ; + return Z.opt_len += 3 * (ce + 1) + 5 + 5 + 4, ce; + } + function We(Z, ce, Ae, Fe) { + var he; + for (fe(Z, ce - 257, 5), fe(Z, Ae - 1, 5), fe(Z, Fe - 4, 4), he = 0; he < Fe; he++) + fe(Z, Z.bl_tree[z[he] * 2 + 1], 3); + ze(Z, Z.dyn_ltree, ce - 1), ze(Z, Z.dyn_dtree, Ae - 1); + } + function Y(Z) { + var ce = 4093624447, Ae; + for (Ae = 0; Ae <= 31; Ae++, ce >>>= 1) + if (ce & 1 && Z.dyn_ltree[Ae * 2] !== 0) + return _; + if (Z.dyn_ltree[18] !== 0 || Z.dyn_ltree[20] !== 0 || Z.dyn_ltree[26] !== 0) + return x; + for (Ae = 32; Ae < n; Ae++) + if (Z.dyn_ltree[Ae * 2] !== 0) + return x; + return _; + } + var K = !1; + function q(Z) { + K || (we(), K = !0), Z.l_desc = new ne(Z.dyn_ltree, Q), Z.d_desc = new ne(Z.dyn_dtree, oe), Z.bl_desc = new ne(Z.bl_tree, ee), Z.bi_buf = 0, Z.bi_valid = 0, ke(Z); + } + function de(Z, ce, Ae, Fe) { + fe(Z, (E << 1) + (Fe ? 1 : 0), 3), Ne(Z, ce, Ae, !0); + } + function ve(Z) { + fe(Z, c << 1, 3), Ce(Z, M, N), Te(Z); + } + function Ie(Z, ce, Ae, Fe) { + var he, Oe, j = 0; + Z.level > 0 ? (Z.strm.data_type === h && (Z.strm.data_type = Y(Z)), ge(Z, Z.l_desc), ge(Z, Z.d_desc), j = He(Z), he = Z.opt_len + 3 + 7 >>> 3, Oe = Z.static_len + 3 + 7 >>> 3, Oe <= he && (he = Oe)) : he = Oe = Ae + 5, Ae + 4 <= he && ce !== -1 ? de(Z, ce, Ae, Fe) : Z.strategy === f || Oe === he ? (fe(Z, (c << 1) + (Fe ? 1 : 0), 3), ye(Z, N, $)) : (fe(Z, (C << 1) + (Fe ? 1 : 0), 3), We(Z, Z.l_desc.max_code + 1, Z.d_desc.max_code + 1, j + 1), ye(Z, Z.dyn_ltree, Z.dyn_dtree)), ke(Z), Fe && Ue(Z); + } + function Re(Z, ce, Ae) { + return Z.pending_buf[Z.d_buf + Z.last_lit * 2] = ce >>> 8 & 255, Z.pending_buf[Z.d_buf + Z.last_lit * 2 + 1] = ce & 255, Z.pending_buf[Z.l_buf + Z.last_lit] = Ae & 255, Z.last_lit++, ce === 0 ? Z.dyn_ltree[Ae * 2]++ : (Z.matches++, ce--, Z.dyn_ltree[(G[Ae] + n + 1) * 2]++, Z.dyn_dtree[me(ce) * 2]++), Z.last_lit === Z.lit_bufsize - 1; + } + e._tr_init = q, e._tr_stored_block = de, e._tr_flush_block = Ie, e._tr_tally = Re, e._tr_align = ve; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js ***! + \********************************************************************/ + /***/ + (r) => { + function e() { + this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; + } + r.exports = e; + } + ), + /***/ + "./src/SurfaceWorker.js": ( + /*!******************************!*\ + !*** ./src/SurfaceWorker.js ***! + \******************************/ + /***/ + () => { + $3Dmol.workerString = (function() { + self.onmessage = function(r) { + var e = r.data, t = e.type; + if (t < 0) + self.atomData = e.atoms, self.volume = e.volume, self.ps = new ProteinSurface(); + else { + var s = self.ps; + s.initparm(e.expandedExtent, t != 1, self.volume), s.fillvoxels(self.atomData, e.extendedAtoms), s.buildboundary(), (t === 4 || t === 2) && (s.fastdistancemap(), s.boundingatom(!1), s.fillvoxelswaals(self.atomData, e.extendedAtoms)), s.marchingcube(t); + var f = s.getFacesAndVertices(e.atomsToShow); + self.postMessage(f); + } + }; + }).toString().replace(/(^.*?\{|\}$)/g, ""), $3Dmol.workerString += `; +function _classCallCheck() {};`, $3Dmol.workerString += `; +` + $3Dmol.Vector3.toString(), $3Dmol.workerString += `; +` + $3Dmol.MarchingCubeInitializer.toString() + `; + +`, $3Dmol.workerString += `; +` + $3Dmol.PointGrid.toString() + `; +`, $3Dmol.workerString += `; +var ProteinSurface = ` + $3Dmol.ProteinSurface.toString() + `; +`, $3Dmol.SurfaceWorker = window.URL ? window.URL.createObjectURL(new Blob([$3Dmol.workerString], { type: "text/javascript" })) : void 0; + } + ), + /***/ + "./src/exporter.js": ( + /*!*************************!*\ + !*** ./src/exporter.js ***! + \*************************/ + /***/ + (r) => { + typeof r.exports == "object" && (r.exports = window.$3Dmol); + } + ), + /***/ + "./src/vendor/mmtf.js": ( + /*!****************************!*\ + !*** ./src/vendor/mmtf.js ***! + \****************************/ + /***/ + function(r, e) { + (function(t, s) { + s(e); + })(this, function(t) { + function s(Y, K, q) { + for (var de = (Y.byteLength, 0), ve = q.length; ve > de; de++) { + var Ie = q.charCodeAt(de); + if (128 > Ie) + Y.setUint8(K++, Ie >>> 0 & 127 | 0); + else if (2048 > Ie) + Y.setUint8(K++, Ie >>> 6 & 31 | 192), Y.setUint8(K++, Ie >>> 0 & 63 | 128); + else if (65536 > Ie) + Y.setUint8(K++, Ie >>> 12 & 15 | 224), Y.setUint8(K++, Ie >>> 6 & 63 | 128), Y.setUint8(K++, Ie >>> 0 & 63 | 128); + else { + if (!(1114112 > Ie)) + throw new Error("bad codepoint " + Ie); + Y.setUint8(K++, Ie >>> 18 & 7 | 240), Y.setUint8(K++, Ie >>> 12 & 63 | 128), Y.setUint8(K++, Ie >>> 6 & 63 | 128), Y.setUint8(K++, Ie >>> 0 & 63 | 128); + } + } + } + function f(Y) { + for (var K = 0, q = 0, de = Y.length; de > q; q++) { + var ve = Y.charCodeAt(q); + if (128 > ve) + K += 1; + else if (2048 > ve) + K += 2; + else if (65536 > ve) + K += 3; + else { + if (!(1114112 > ve)) + throw new Error("bad codepoint " + ve); + K += 4; + } + } + return K; + } + function _(Y, K, q) { + var de = typeof Y; + if (de === "string") { + var ve = f(Y); + if (32 > ve) + return K.setUint8(q, 160 | ve), s(K, q + 1, Y), 1 + ve; + if (256 > ve) + return K.setUint8(q, 217), K.setUint8(q + 1, ve), s(K, q + 2, Y), 2 + ve; + if (65536 > ve) + return K.setUint8(q, 218), K.setUint16(q + 1, ve), s(K, q + 3, Y), 3 + ve; + if (4294967296 > ve) + return K.setUint8(q, 219), K.setUint32(q + 1, ve), s(K, q + 5, Y), 5 + ve; + } + if (Y instanceof Uint8Array) { + var ve = Y.byteLength, Ie = new Uint8Array(K.buffer); + if (256 > ve) + return K.setUint8(q, 196), K.setUint8(q + 1, ve), Ie.set(Y, q + 2), 2 + ve; + if (65536 > ve) + return K.setUint8(q, 197), K.setUint16(q + 1, ve), Ie.set(Y, q + 3), 3 + ve; + if (4294967296 > ve) + return K.setUint8(q, 198), K.setUint32(q + 1, ve), Ie.set(Y, q + 5), 5 + ve; + } + if (de === "number") { + if (!isFinite(Y)) + throw new Error("Number not finite: " + Y); + if (Math.floor(Y) !== Y) + return K.setUint8(q, 203), K.setFloat64(q + 1, Y), 9; + if (Y >= 0) { + if (128 > Y) + return K.setUint8(q, Y), 1; + if (256 > Y) + return K.setUint8(q, 204), K.setUint8(q + 1, Y), 2; + if (65536 > Y) + return K.setUint8(q, 205), K.setUint16(q + 1, Y), 3; + if (4294967296 > Y) + return K.setUint8(q, 206), K.setUint32(q + 1, Y), 5; + throw new Error("Number too big 0x" + Y.toString(16)); + } + if (Y >= -32) + return K.setInt8(q, Y), 1; + if (Y >= -128) + return K.setUint8(q, 208), K.setInt8(q + 1, Y), 2; + if (Y >= -32768) + return K.setUint8(q, 209), K.setInt16(q + 1, Y), 3; + if (Y >= -2147483648) + return K.setUint8(q, 210), K.setInt32(q + 1, Y), 5; + throw new Error("Number too small -0x" + (-Y).toString(16).substr(1)); + } + if (Y === null) + return K.setUint8(q, 192), 1; + if (de === "boolean") + return K.setUint8(q, Y ? 195 : 194), 1; + if (de === "object") { + var ve, ce = 0, Re = Array.isArray(Y); + if (Re) + ve = Y.length; + else { + var Z = Object.keys(Y); + ve = Z.length; + } + var ce; + if (16 > ve ? (K.setUint8(q, ve | (Re ? 144 : 128)), ce = 1) : 65536 > ve ? (K.setUint8(q, Re ? 220 : 222), K.setUint16(q + 1, ve), ce = 3) : 4294967296 > ve && (K.setUint8(q, Re ? 221 : 223), K.setUint32(q + 1, ve), ce = 5), Re) + for (var Ae = 0; ve > Ae; Ae++) + ce += _(Y[Ae], K, q + ce); + else + for (var Ae = 0; ve > Ae; Ae++) { + var Fe = Z[Ae]; + ce += _(Fe, K, q + ce), ce += _(Y[Fe], K, q + ce); + } + return ce; + } + throw new Error("Unknown type " + de); + } + function x(Y) { + var K = typeof Y; + if (K === "string") { + var q = f(Y); + if (32 > q) + return 1 + q; + if (256 > q) + return 2 + q; + if (65536 > q) + return 3 + q; + if (4294967296 > q) + return 5 + q; + } + if (Y instanceof Uint8Array) { + var q = Y.byteLength; + if (256 > q) + return 2 + q; + if (65536 > q) + return 3 + q; + if (4294967296 > q) + return 5 + q; + } + if (K === "number") { + if (Math.floor(Y) !== Y) + return 9; + if (Y >= 0) { + if (128 > Y) + return 1; + if (256 > Y) + return 2; + if (65536 > Y) + return 3; + if (4294967296 > Y) + return 5; + throw new Error("Number too big 0x" + Y.toString(16)); + } + if (Y >= -32) + return 1; + if (Y >= -128) + return 2; + if (Y >= -32768) + return 3; + if (Y >= -2147483648) + return 5; + throw new Error("Number too small -0x" + Y.toString(16).substr(1)); + } + if (K === "boolean" || Y === null) + return 1; + if (K === "object") { + var q, de = 0; + if (Array.isArray(Y)) { + q = Y.length; + for (var ve = 0; q > ve; ve++) + de += x(Y[ve]); + } else { + var Ie = Object.keys(Y); + q = Ie.length; + for (var ve = 0; q > ve; ve++) { + var Re = Ie[ve]; + de += x(Re) + x(Y[Re]); + } + } + if (16 > q) + return 1 + de; + if (65536 > q) + return 3 + de; + if (4294967296 > q) + return 5 + de; + throw new Error("Array or object too long 0x" + q.toString(16)); + } + throw new Error("Unknown type " + K); + } + function h(Y) { + var K = new ArrayBuffer(x(Y)), q = new DataView(K); + return _(Y, q, 0), new Uint8Array(K); + } + function u(Y, K, q) { + return K ? new Y(K.buffer, K.byteOffset, K.byteLength / (q || 1)) : void 0; + } + function E(Y) { + return u(DataView, Y); + } + function c(Y) { + return u(Uint8Array, Y); + } + function C(Y) { + return u(Int8Array, Y); + } + function b(Y) { + return u(Int32Array, Y, 4); + } + function A(Y) { + return u(Float32Array, Y, 4); + } + function S(Y, K) { + var q = Y.length / 2; + K || (K = new Int16Array(q)); + for (var de = 0, ve = 0; q > de; ++de, ve += 2) + K[de] = Y[ve] << 8 ^ Y[ve + 1] << 0; + return K; + } + function n(Y, K) { + var q = Y.length; + K || (K = new Uint8Array(2 * q)); + for (var de = E(K), ve = 0; q > ve; ++ve) + de.setInt16(2 * ve, Y[ve]); + return c(K); + } + function o(Y, K) { + var q = Y.length / 4; + K || (K = new Int32Array(q)); + for (var de = 0, ve = 0; q > de; ++de, ve += 4) + K[de] = Y[ve] << 24 ^ Y[ve + 1] << 16 ^ Y[ve + 2] << 8 ^ Y[ve + 3] << 0; + return K; + } + function w(Y, K) { + var q = Y.length; + K || (K = new Uint8Array(4 * q)); + for (var de = E(K), ve = 0; q > ve; ++ve) + de.setInt32(4 * ve, Y[ve]); + return c(K); + } + function p(Y, K) { + var q = Y.length; + K || (K = new Float32Array(q / 4)); + for (var de = E(K), ve = E(Y), Ie = 0, Re = 0, Z = q / 4; Z > Ie; ++Ie, Re += 4) + de.setFloat32(Re, ve.getFloat32(Re), !0); + return K; + } + function v(Y, K, q) { + var de = Y.length, ve = 1 / K; + q || (q = new Float32Array(de)); + for (var Ie = 0; de > Ie; ++Ie) + q[Ie] = Y[Ie] * ve; + return q; + } + function a(Y, K, q) { + var de = Y.length; + q || (q = new Int32Array(de)); + for (var ve = 0; de > ve; ++ve) + q[ve] = Math.round(Y[ve] * K); + return q; + } + function l(Y, K) { + var q, de; + if (!K) { + var ve = 0; + for (q = 0, de = Y.length; de > q; q += 2) + ve += Y[q + 1]; + K = new Y.constructor(ve); + } + var Ie = 0; + for (q = 0, de = Y.length; de > q; q += 2) + for (var Re = Y[q], Z = Y[q + 1], ce = 0; Z > ce; ++ce) + K[Ie] = Re, ++Ie; + return K; + } + function g(Y) { + if (Y.length === 0) + return new Int32Array(); + var K, q, de = 2; + for (K = 1, q = Y.length; q > K; ++K) + Y[K - 1] !== Y[K] && (de += 2); + var ve = new Int32Array(de), Ie = 0, Re = 1; + for (K = 1, q = Y.length; q > K; ++K) + Y[K - 1] !== Y[K] ? (ve[Ie] = Y[K - 1], ve[Ie + 1] = Re, Re = 1, Ie += 2) : ++Re; + return ve[Ie] = Y[Y.length - 1], ve[Ie + 1] = Re, ve; + } + function M(Y, K) { + var q = Y.length; + K || (K = new Y.constructor(q)), q && (K[0] = Y[0]); + for (var de = 1; q > de; ++de) + K[de] = Y[de] + K[de - 1]; + return K; + } + function L(Y, K) { + var q = Y.length; + K || (K = new Y.constructor(q)), K[0] = Y[0]; + for (var de = 1; q > de; ++de) + K[de] = Y[de] - Y[de - 1]; + return K; + } + function T(Y, K) { + var q, de, ve = Y instanceof Int8Array ? 127 : 32767, Ie = -ve - 1, Re = Y.length; + if (!K) { + var Z = 0; + for (q = 0; Re > q; ++q) + Y[q] < ve && Y[q] > Ie && ++Z; + K = new Int32Array(Z); + } + for (q = 0, de = 0; Re > q; ) { + for (var ce = 0; Y[q] === ve || Y[q] === Ie; ) + ce += Y[q], ++q; + ce += Y[q], ++q, K[de] = ce, ++de; + } + return K; + } + function D(Y, K) { + var q, de = K ? 127 : 32767, ve = -de - 1, Ie = Y.length, Re = 0; + for (q = 0; Ie > q; ++q) { + var Z = Y[q]; + Z === 0 ? ++Re : Z > 0 ? (Re += Math.ceil(Z / de), Z % de === 0 && (Re += 1)) : (Re += Math.ceil(Z / ve), Z % ve === 0 && (Re += 1)); + } + var ce = K ? new Int8Array(Re) : new Int16Array(Re), Ae = 0; + for (q = 0; Ie > q; ++q) { + var Z = Y[q]; + if (Z >= 0) + for (; Z >= de; ) + ce[Ae] = de, ++Ae, Z -= de; + else + for (; ve >= Z; ) + ce[Ae] = ve, ++Ae, Z -= ve; + ce[Ae] = Z, ++Ae; + } + return ce; + } + function R(Y, K) { + return M(l(Y), K); + } + function B(Y) { + return g(L(Y)); + } + function P(Y, K, q) { + return v(l(Y, b(q)), K, q); + } + function z(Y, K) { + return g(a(Y, K)); + } + function F(Y, K, q) { + return v(M(Y, b(q)), K, q); + } + function N(Y, K, q) { + return L(a(Y, K), q); + } + function $(Y, K, q) { + return v(T(Y, b(q)), K, q); + } + function k(Y, K, q) { + var de = T(Y, b(q)); + return F(de, K, A(de)); + } + function G(Y, K, q) { + return D(N(Y, K), q); + } + function H(Ie) { + var K = E(Ie), q = K.getInt32(0), de = K.getInt32(4), ve = Ie.subarray(8, 12), Ie = Ie.subarray(12); + return [q, Ie, de, ve]; + } + function U(Y, K, q, de) { + var ve = new ArrayBuffer(12 + de.byteLength), Ie = new Uint8Array(ve), Re = new DataView(ve); + return Re.setInt32(0, Y), Re.setInt32(4, K), q && Ie.set(q, 8), Ie.set(de, 12), Ie; + } + function V(Y) { + var K = Y.length, q = c(Y); + return U(2, K, void 0, q); + } + function Q(Y) { + var K = Y.length, q = w(Y); + return U(4, K, void 0, q); + } + function oe(Y, K) { + var q = Y.length / K, de = w([K]), ve = c(Y); + return U(5, q, de, ve); + } + function ee(Y) { + var K = Y.length, q = w(g(Y)); + return U(6, K, void 0, q); + } + function ne(Y) { + var K = Y.length, q = w(B(Y)); + return U(8, K, void 0, q); + } + function me(Y, K) { + var q = Y.length, de = w([K]), ve = w(z(Y, K)); + return U(9, q, de, ve); + } + function se(Y, K) { + var q = Y.length, de = w([K]), ve = n(G(Y, K)); + return U(10, q, de, ve); + } + function fe(Y) { + var K = {}; + return ue.forEach(function(q) { + Y[q] !== void 0 && (K[q] = Y[q]); + }), Y.bondAtomList && (K.bondAtomList = Q(Y.bondAtomList)), Y.bondOrderList && (K.bondOrderList = V(Y.bondOrderList)), K.xCoordList = se(Y.xCoordList, 1e3), K.yCoordList = se(Y.yCoordList, 1e3), K.zCoordList = se(Y.zCoordList, 1e3), Y.bFactorList && (K.bFactorList = se(Y.bFactorList, 100)), Y.atomIdList && (K.atomIdList = ne(Y.atomIdList)), Y.altLocList && (K.altLocList = ee(Y.altLocList)), Y.occupancyList && (K.occupancyList = me(Y.occupancyList, 100)), K.groupIdList = ne(Y.groupIdList), K.groupTypeList = Q(Y.groupTypeList), Y.secStructList && (K.secStructList = V(Y.secStructList)), Y.insCodeList && (K.insCodeList = ee(Y.insCodeList)), Y.sequenceIndexList && (K.sequenceIndexList = ne(Y.sequenceIndexList)), K.chainIdList = oe(Y.chainIdList, 4), Y.chainNameList && (K.chainNameList = oe(Y.chainNameList, 4)), K; + } + function Ce(Y) { + function K(ce) { + for (var Ae = {}, Fe = 0; ce > Fe; Fe++) { + var he = Ie(); + Ae[he] = Ie(); + } + return Ae; + } + function q(ce) { + var Ae = Y.subarray(Re, Re + ce); + return Re += ce, Ae; + } + function de(ce) { + var Ae = Y.subarray(Re, Re + ce); + Re += ce; + var Fe = 65535; + if (ce > Fe) { + for (var he = [], Oe = 0; Oe < Ae.length; Oe += Fe) + he.push(String.fromCharCode.apply(null, Ae.subarray(Oe, Oe + Fe))); + return he.join(""); + } + return String.fromCharCode.apply(null, Ae); + } + function ve(ce) { + for (var Ae = new Array(ce), Fe = 0; ce > Fe; Fe++) + Ae[Fe] = Ie(); + return Ae; + } + function Ie() { + var ce, Ae, Fe = Y[Re]; + if (!(128 & Fe)) + return Re++, Fe; + if ((240 & Fe) === 128) + return Ae = 15 & Fe, Re++, K(Ae); + if ((240 & Fe) === 144) + return Ae = 15 & Fe, Re++, ve(Ae); + if ((224 & Fe) === 160) + return Ae = 31 & Fe, Re++, de(Ae); + if ((224 & Fe) === 224) + return ce = Z.getInt8(Re), Re++, ce; + switch (Fe) { + case 192: + return Re++, null; + case 194: + return Re++, !1; + case 195: + return Re++, !0; + case 196: + return Ae = Z.getUint8(Re + 1), Re += 2, q(Ae); + case 197: + return Ae = Z.getUint16(Re + 1), Re += 3, q(Ae); + case 198: + return Ae = Z.getUint32(Re + 1), Re += 5, q(Ae); + case 202: + return ce = Z.getFloat32(Re + 1), Re += 5, ce; + case 203: + return ce = Z.getFloat64(Re + 1), Re += 9, ce; + case 204: + return ce = Y[Re + 1], Re += 2, ce; + case 205: + return ce = Z.getUint16(Re + 1), Re += 3, ce; + case 206: + return ce = Z.getUint32(Re + 1), Re += 5, ce; + case 208: + return ce = Z.getInt8(Re + 1), Re += 2, ce; + case 209: + return ce = Z.getInt16(Re + 1), Re += 3, ce; + case 210: + return ce = Z.getInt32(Re + 1), Re += 5, ce; + case 217: + return Ae = Z.getUint8(Re + 1), Re += 2, de(Ae); + case 218: + return Ae = Z.getUint16(Re + 1), Re += 3, de(Ae); + case 219: + return Ae = Z.getUint32(Re + 1), Re += 5, de(Ae); + case 220: + return Ae = Z.getUint16(Re + 1), Re += 3, ve(Ae); + case 221: + return Ae = Z.getUint32(Re + 1), Re += 5, ve(Ae); + case 222: + return Ae = Z.getUint16(Re + 1), Re += 3, K(Ae); + case 223: + return Ae = Z.getUint32(Re + 1), Re += 5, K(Ae); + } + throw new Error("Unknown type 0x" + Fe.toString(16)); + } + var Re = 0, Z = new DataView(Y.buffer); + return Ie(); + } + function Me(Y, K, q, de) { + switch (Y) { + case 1: + return p(K); + case 2: + return C(K); + case 3: + return S(K); + case 4: + return o(K); + case 5: + return c(K); + case 6: + return l(o(K), new Uint8Array(q)); + case 7: + return l(o(K)); + case 8: + return R(o(K)); + case 9: + return P(o(K), o(de)[0]); + case 10: + return k(S(K), o(de)[0]); + case 11: + return v(S(K), o(de)[0]); + case 12: + return $(S(K), o(de)[0]); + case 13: + return $(C(K), o(de)[0]); + case 14: + return T(S(K)); + case 15: + return T(C(K)); + } + } + function Te(Y, K) { + K = K || {}; + var q = K.ignoreFields, de = {}; + return ge.forEach(function(ve) { + var Ie = q ? q.indexOf(ve) !== -1 : !1, Re = Y[ve]; + Ie || Re === void 0 || (Re instanceof Uint8Array ? de[ve] = Me.apply(null, H(Re)) : de[ve] = Re); + }), de; + } + function ae(Y) { + return String.fromCharCode.apply(null, Y).replace(/\0/g, ""); + } + function pe(Y, K, q) { + q = q || {}; + var de, ve, Ie, Re, Z, ce, Ae = q.firstModelOnly, Fe = K.onModel, he = K.onChain, Oe = K.onGroup, j = K.onAtom, $e = K.onBond, Ve = 0, I = 0, be = 0, Ee = 0, X = 0, le = -1, Le = Y.chainNameList, Ze = Y.secStructList, Ke = Y.insCodeList, je = Y.sequenceIndexList, Je = Y.atomIdList, Lt = Y.bFactorList, rt = Y.altLocList, it = Y.occupancyList, tt = Y.bondAtomList, Et = Y.bondOrderList; + for (de = 0, ve = Y.chainsPerModel.length; ve > de && !(Ae && Ve > 0); ++de) { + var lt = Y.chainsPerModel[Ve]; + for (Fe && Fe({ chainCount: lt, modelIndex: Ve }), Ie = 0; lt > Ie; ++Ie) { + var wt = Y.groupsPerChain[I]; + if (he) { + var Pt = ae(Y.chainIdList.subarray(4 * I, 4 * I + 4)), vt = null; + Le && (vt = ae(Le.subarray(4 * I, 4 * I + 4))), he({ groupCount: wt, chainIndex: I, modelIndex: Ve, chainId: Pt, chainName: vt }); + } + for (Re = 0; wt > Re; ++Re) { + var bt = Y.groupList[Y.groupTypeList[be]], mt = bt.atomNameList.length; + if (Oe) { + var Tt = null; + Ze && (Tt = Ze[be]); + var Ot = null; + Y.insCodeList && (Ot = String.fromCharCode(Ke[be])); + var Ft = null; + je && (Ft = je[be]), Oe({ atomCount: mt, groupIndex: be, chainIndex: I, modelIndex: Ve, groupId: Y.groupIdList[be], groupType: Y.groupTypeList[be], groupName: bt.groupName, singleLetterCode: bt.singleLetterCode, chemCompType: bt.chemCompType, secStruct: Tt, insCode: Ot, sequenceIndex: Ft }); + } + for (Z = 0; mt > Z; ++Z) { + if (j) { + var Qt = null; + Je && (Qt = Je[Ee]); + var kt = null; + Lt && (kt = Lt[Ee]); + var Jt = null; + rt && (Jt = String.fromCharCode(rt[Ee])); + var qt = null; + it && (qt = it[Ee]), j({ atomIndex: Ee, groupIndex: be, chainIndex: I, modelIndex: Ve, atomId: Qt, element: bt.elementList[Z], atomName: bt.atomNameList[Z], formalCharge: bt.formalChargeList[Z], xCoord: Y.xCoordList[Ee], yCoord: Y.yCoordList[Ee], zCoord: Y.zCoordList[Ee], bFactor: kt, altLoc: Jt, occupancy: qt }); + } + Ee += 1; + } + if ($e) { + var er = bt.bondAtomList; + for (Z = 0, ce = bt.bondOrderList.length; ce > Z; ++Z) + $e({ atomIndex1: Ee - mt + er[2 * Z], atomIndex2: Ee - mt + er[2 * Z + 1], bondOrder: bt.bondOrderList[Z] }); + } + be += 1; + } + I += 1; + } + if (X = le + 1, le = Ee - 1, $e && tt) + for (Z = 0, ce = tt.length; ce > Z; Z += 2) { + var Ht = tt[Z], tr = tt[Z + 1]; + (Ht >= X && le >= Ht || tr >= X && le >= tr) && $e({ atomIndex1: Ht, atomIndex2: tr, bondOrder: Et ? Et[Z / 2] : null }); + } + Ve += 1; + } + } + function we(Y) { + return h(fe(Y)); + } + function ke(Y, K) { + Y instanceof ArrayBuffer && (Y = new Uint8Array(Y)); + var q; + return q = Y instanceof Uint8Array ? Ce(Y) : Y, Te(q, K); + } + function Ue(Y, K, q, de) { + function ve() { + try { + var Re = ke(Ie.response); + q(Re); + } catch (Z) { + de(Z); + } + } + var Ie = new XMLHttpRequest(); + Ie.addEventListener("load", ve, !0), Ie.addEventListener("error", de, !0), Ie.responseType = "arraybuffer", Ie.open("GET", K + Y.toUpperCase()), Ie.send(); + } + function Ne(Y, K, q) { + Ue(Y, He, K, q); + } + function Be(Y, K, q) { + Ue(Y, We, K, q); + } + var ue = ["mmtfVersion", "mmtfProducer", "unitCell", "spaceGroup", "structureId", "title", "depositionDate", "releaseDate", "experimentalMethods", "resolution", "rFree", "rWork", "bioAssemblyList", "ncsOperatorList", "entityList", "groupList", "numBonds", "numAtoms", "numGroups", "numChains", "numModels", "groupsPerChain", "chainsPerModel"], ye = ["xCoordList", "yCoordList", "zCoordList", "groupIdList", "groupTypeList", "chainIdList", "bFactorList", "atomIdList", "altLocList", "occupancyList", "secStructList", "insCodeList", "sequenceIndexList", "chainNameList", "bondAtomList", "bondOrderList"], ge = ue.concat(ye), Se = "v1.0.1", ze = "//mmtf.rcsb.org/v1.0/", He = ze + "full/", We = ze + "reduced/"; + t.encode = we, t.decode = ke, t.traverse = pe, t.fetch = Ne, t.fetchReduced = Be, t.version = Se, t.fetchUrl = He, t.fetchReducedUrl = We, t.encodeMsgpack = h, t.encodeMmtf = fe, t.decodeMsgpack = Ce, t.decodeMmtf = Te; + }); + } + ), + /***/ + "./node_modules/pako/dist/pako.esm.mjs": ( + /*!*********************************************!*\ + !*** ./node_modules/pako/dist/pako.esm.mjs ***! + \*********************************************/ + /***/ + (r, e, t) => { + t.r(e), t.d(e, { + /* harmony export */ + Deflate: () => ( + /* binding */ + Ki + ), + /* harmony export */ + Inflate: () => ( + /* binding */ + Qi + ), + /* harmony export */ + constants: () => ( + /* binding */ + tn + ), + /* harmony export */ + default: () => ( + /* binding */ + Ks + ), + /* harmony export */ + deflate: () => ( + /* binding */ + Zi + ), + /* harmony export */ + deflateRaw: () => ( + /* binding */ + Yi + ), + /* harmony export */ + gzip: () => ( + /* binding */ + Xi + ), + /* harmony export */ + inflate: () => ( + /* binding */ + Ji + ), + /* harmony export */ + inflateRaw: () => ( + /* binding */ + qi + ), + /* harmony export */ + ungzip: () => ( + /* binding */ + en + ) + /* harmony export */ + }); + /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */ + const s = 4, f = 0, _ = 1, x = 2; + function h(y) { + let W = y.length; + for (; --W >= 0; ) + y[W] = 0; + } + const u = 0, E = 1, c = 2, C = 3, b = 258, A = 29, S = 256, n = S + 1 + A, o = 30, w = 19, p = 2 * n + 1, v = 15, a = 16, l = 7, g = 256, M = 16, L = 17, T = 18, D = ( + /* extra bits for each length code */ + new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]) + ), R = ( + /* extra bits for each distance code */ + new Uint8Array([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) + ), B = ( + /* extra bits for each bit length code */ + new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]) + ), P = new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), z = 512, F = new Array((n + 2) * 2); + h(F); + const N = new Array(o * 2); + h(N); + const $ = new Array(z); + h($); + const k = new Array(b - C + 1); + h(k); + const G = new Array(A); + h(G); + const H = new Array(o); + h(H); + function U(y, W, O, J, ie) { + this.static_tree = y, this.extra_bits = W, this.extra_base = O, this.elems = J, this.max_length = ie, this.has_stree = y && y.length; + } + let V, Q, oe; + function ee(y, W) { + this.dyn_tree = y, this.max_code = 0, this.stat_desc = W; + } + const ne = (y) => y < 256 ? $[y] : $[256 + (y >>> 7)], me = (y, W) => { + y.pending_buf[y.pending++] = W & 255, y.pending_buf[y.pending++] = W >>> 8 & 255; + }, se = (y, W, O) => { + y.bi_valid > a - O ? (y.bi_buf |= W << y.bi_valid & 65535, me(y, y.bi_buf), y.bi_buf = W >> a - y.bi_valid, y.bi_valid += O - a) : (y.bi_buf |= W << y.bi_valid & 65535, y.bi_valid += O); + }, fe = (y, W, O) => { + se( + y, + O[W * 2], + O[W * 2 + 1] + /*.Len*/ + ); + }, Ce = (y, W) => { + let O = 0; + do + O |= y & 1, y >>>= 1, O <<= 1; + while (--W > 0); + return O >>> 1; + }, Me = (y) => { + y.bi_valid === 16 ? (me(y, y.bi_buf), y.bi_buf = 0, y.bi_valid = 0) : y.bi_valid >= 8 && (y.pending_buf[y.pending++] = y.bi_buf & 255, y.bi_buf >>= 8, y.bi_valid -= 8); + }, Te = (y, W) => { + const O = W.dyn_tree, J = W.max_code, ie = W.stat_desc.static_tree, te = W.stat_desc.has_stree, De = W.stat_desc.extra_bits, xe = W.stat_desc.extra_base, Qe = W.stat_desc.max_length; + let _e, Pe, ut, Xe, Ge, qe, Ct = 0; + for (Xe = 0; Xe <= v; Xe++) + y.bl_count[Xe] = 0; + for (O[y.heap[y.heap_max] * 2 + 1] = 0, _e = y.heap_max + 1; _e < p; _e++) + Pe = y.heap[_e], Xe = O[O[Pe * 2 + 1] * 2 + 1] + 1, Xe > Qe && (Xe = Qe, Ct++), O[Pe * 2 + 1] = Xe, !(Pe > J) && (y.bl_count[Xe]++, Ge = 0, Pe >= xe && (Ge = De[Pe - xe]), qe = O[Pe * 2], y.opt_len += qe * (Xe + Ge), te && (y.static_len += qe * (ie[Pe * 2 + 1] + Ge))); + if (Ct !== 0) { + do { + for (Xe = Qe - 1; y.bl_count[Xe] === 0; ) + Xe--; + y.bl_count[Xe]--, y.bl_count[Xe + 1] += 2, y.bl_count[Qe]--, Ct -= 2; + } while (Ct > 0); + for (Xe = Qe; Xe !== 0; Xe--) + for (Pe = y.bl_count[Xe]; Pe !== 0; ) + ut = y.heap[--_e], !(ut > J) && (O[ut * 2 + 1] !== Xe && (y.opt_len += (Xe - O[ut * 2 + 1]) * O[ut * 2], O[ut * 2 + 1] = Xe), Pe--); + } + }, ae = (y, W, O) => { + const J = new Array(v + 1); + let ie = 0, te, De; + for (te = 1; te <= v; te++) + ie = ie + O[te - 1] << 1, J[te] = ie; + for (De = 0; De <= W; De++) { + let xe = y[De * 2 + 1]; + xe !== 0 && (y[De * 2] = Ce(J[xe]++, xe)); + } + }, pe = () => { + let y, W, O, J, ie; + const te = new Array(v + 1); + for (O = 0, J = 0; J < A - 1; J++) + for (G[J] = O, y = 0; y < 1 << D[J]; y++) + k[O++] = J; + for (k[O - 1] = J, ie = 0, J = 0; J < 16; J++) + for (H[J] = ie, y = 0; y < 1 << R[J]; y++) + $[ie++] = J; + for (ie >>= 7; J < o; J++) + for (H[J] = ie << 7, y = 0; y < 1 << R[J] - 7; y++) + $[256 + ie++] = J; + for (W = 0; W <= v; W++) + te[W] = 0; + for (y = 0; y <= 143; ) + F[y * 2 + 1] = 8, y++, te[8]++; + for (; y <= 255; ) + F[y * 2 + 1] = 9, y++, te[9]++; + for (; y <= 279; ) + F[y * 2 + 1] = 7, y++, te[7]++; + for (; y <= 287; ) + F[y * 2 + 1] = 8, y++, te[8]++; + for (ae(F, n + 1, te), y = 0; y < o; y++) + N[y * 2 + 1] = 5, N[y * 2] = Ce(y, 5); + V = new U(F, D, S + 1, n, v), Q = new U(N, R, 0, o, v), oe = new U(new Array(0), B, 0, w, l); + }, we = (y) => { + let W; + for (W = 0; W < n; W++) + y.dyn_ltree[W * 2] = 0; + for (W = 0; W < o; W++) + y.dyn_dtree[W * 2] = 0; + for (W = 0; W < w; W++) + y.bl_tree[W * 2] = 0; + y.dyn_ltree[g * 2] = 1, y.opt_len = y.static_len = 0, y.sym_next = y.matches = 0; + }, ke = (y) => { + y.bi_valid > 8 ? me(y, y.bi_buf) : y.bi_valid > 0 && (y.pending_buf[y.pending++] = y.bi_buf), y.bi_buf = 0, y.bi_valid = 0; + }, Ue = (y, W, O, J) => { + const ie = W * 2, te = O * 2; + return y[ie] < y[te] || y[ie] === y[te] && J[W] <= J[O]; + }, Ne = (y, W, O) => { + const J = y.heap[O]; + let ie = O << 1; + for (; ie <= y.heap_len && (ie < y.heap_len && Ue(W, y.heap[ie + 1], y.heap[ie], y.depth) && ie++, !Ue(W, J, y.heap[ie], y.depth)); ) + y.heap[O] = y.heap[ie], O = ie, ie <<= 1; + y.heap[O] = J; + }, Be = (y, W, O) => { + let J, ie, te = 0, De, xe; + if (y.sym_next !== 0) + do + J = y.pending_buf[y.sym_buf + te++] & 255, J += (y.pending_buf[y.sym_buf + te++] & 255) << 8, ie = y.pending_buf[y.sym_buf + te++], J === 0 ? fe(y, ie, W) : (De = k[ie], fe(y, De + S + 1, W), xe = D[De], xe !== 0 && (ie -= G[De], se(y, ie, xe)), J--, De = ne(J), fe(y, De, O), xe = R[De], xe !== 0 && (J -= H[De], se(y, J, xe))); + while (te < y.sym_next); + fe(y, g, W); + }, ue = (y, W) => { + const O = W.dyn_tree, J = W.stat_desc.static_tree, ie = W.stat_desc.has_stree, te = W.stat_desc.elems; + let De, xe, Qe = -1, _e; + for (y.heap_len = 0, y.heap_max = p, De = 0; De < te; De++) + O[De * 2] !== 0 ? (y.heap[++y.heap_len] = Qe = De, y.depth[De] = 0) : O[De * 2 + 1] = 0; + for (; y.heap_len < 2; ) + _e = y.heap[++y.heap_len] = Qe < 2 ? ++Qe : 0, O[_e * 2] = 1, y.depth[_e] = 0, y.opt_len--, ie && (y.static_len -= J[_e * 2 + 1]); + for (W.max_code = Qe, De = y.heap_len >> 1; De >= 1; De--) + Ne(y, O, De); + _e = te; + do + De = y.heap[ + 1 + /*SMALLEST*/ + ], y.heap[ + 1 + /*SMALLEST*/ + ] = y.heap[y.heap_len--], Ne( + y, + O, + 1 + /*SMALLEST*/ + ), xe = y.heap[ + 1 + /*SMALLEST*/ + ], y.heap[--y.heap_max] = De, y.heap[--y.heap_max] = xe, O[_e * 2] = O[De * 2] + O[xe * 2], y.depth[_e] = (y.depth[De] >= y.depth[xe] ? y.depth[De] : y.depth[xe]) + 1, O[De * 2 + 1] = O[xe * 2 + 1] = _e, y.heap[ + 1 + /*SMALLEST*/ + ] = _e++, Ne( + y, + O, + 1 + /*SMALLEST*/ + ); + while (y.heap_len >= 2); + y.heap[--y.heap_max] = y.heap[ + 1 + /*SMALLEST*/ + ], Te(y, W), ae(O, Qe, y.bl_count); + }, ye = (y, W, O) => { + let J, ie = -1, te, De = W[0 * 2 + 1], xe = 0, Qe = 7, _e = 4; + for (De === 0 && (Qe = 138, _e = 3), W[(O + 1) * 2 + 1] = 65535, J = 0; J <= O; J++) + te = De, De = W[(J + 1) * 2 + 1], !(++xe < Qe && te === De) && (xe < _e ? y.bl_tree[te * 2] += xe : te !== 0 ? (te !== ie && y.bl_tree[te * 2]++, y.bl_tree[M * 2]++) : xe <= 10 ? y.bl_tree[L * 2]++ : y.bl_tree[T * 2]++, xe = 0, ie = te, De === 0 ? (Qe = 138, _e = 3) : te === De ? (Qe = 6, _e = 3) : (Qe = 7, _e = 4)); + }, ge = (y, W, O) => { + let J, ie = -1, te, De = W[0 * 2 + 1], xe = 0, Qe = 7, _e = 4; + for (De === 0 && (Qe = 138, _e = 3), J = 0; J <= O; J++) + if (te = De, De = W[(J + 1) * 2 + 1], !(++xe < Qe && te === De)) { + if (xe < _e) + do + fe(y, te, y.bl_tree); + while (--xe !== 0); + else + te !== 0 ? (te !== ie && (fe(y, te, y.bl_tree), xe--), fe(y, M, y.bl_tree), se(y, xe - 3, 2)) : xe <= 10 ? (fe(y, L, y.bl_tree), se(y, xe - 3, 3)) : (fe(y, T, y.bl_tree), se(y, xe - 11, 7)); + xe = 0, ie = te, De === 0 ? (Qe = 138, _e = 3) : te === De ? (Qe = 6, _e = 3) : (Qe = 7, _e = 4); + } + }, Se = (y) => { + let W; + for (ye(y, y.dyn_ltree, y.l_desc.max_code), ye(y, y.dyn_dtree, y.d_desc.max_code), ue(y, y.bl_desc), W = w - 1; W >= 3 && y.bl_tree[P[W] * 2 + 1] === 0; W--) + ; + return y.opt_len += 3 * (W + 1) + 5 + 5 + 4, W; + }, ze = (y, W, O, J) => { + let ie; + for (se(y, W - 257, 5), se(y, O - 1, 5), se(y, J - 4, 4), ie = 0; ie < J; ie++) + se(y, y.bl_tree[P[ie] * 2 + 1], 3); + ge(y, y.dyn_ltree, W - 1), ge(y, y.dyn_dtree, O - 1); + }, He = (y) => { + let W = 4093624447, O; + for (O = 0; O <= 31; O++, W >>>= 1) + if (W & 1 && y.dyn_ltree[O * 2] !== 0) + return f; + if (y.dyn_ltree[9 * 2] !== 0 || y.dyn_ltree[10 * 2] !== 0 || y.dyn_ltree[13 * 2] !== 0) + return _; + for (O = 32; O < S; O++) + if (y.dyn_ltree[O * 2] !== 0) + return _; + return f; + }; + let We = !1; + const Y = (y) => { + We || (pe(), We = !0), y.l_desc = new ee(y.dyn_ltree, V), y.d_desc = new ee(y.dyn_dtree, Q), y.bl_desc = new ee(y.bl_tree, oe), y.bi_buf = 0, y.bi_valid = 0, we(y); + }, K = (y, W, O, J) => { + se(y, (u << 1) + (J ? 1 : 0), 3), ke(y), me(y, O), me(y, ~O), O && y.pending_buf.set(y.window.subarray(W, W + O), y.pending), y.pending += O; + }, q = (y) => { + se(y, E << 1, 3), fe(y, g, F), Me(y); + }, de = (y, W, O, J) => { + let ie, te, De = 0; + y.level > 0 ? (y.strm.data_type === x && (y.strm.data_type = He(y)), ue(y, y.l_desc), ue(y, y.d_desc), De = Se(y), ie = y.opt_len + 3 + 7 >>> 3, te = y.static_len + 3 + 7 >>> 3, te <= ie && (ie = te)) : ie = te = O + 5, O + 4 <= ie && W !== -1 ? K(y, W, O, J) : y.strategy === s || te === ie ? (se(y, (E << 1) + (J ? 1 : 0), 3), Be(y, F, N)) : (se(y, (c << 1) + (J ? 1 : 0), 3), ze(y, y.l_desc.max_code + 1, y.d_desc.max_code + 1, De + 1), Be(y, y.dyn_ltree, y.dyn_dtree)), we(y), J && ke(y); + }, ve = (y, W, O) => (y.pending_buf[y.sym_buf + y.sym_next++] = W, y.pending_buf[y.sym_buf + y.sym_next++] = W >> 8, y.pending_buf[y.sym_buf + y.sym_next++] = O, W === 0 ? y.dyn_ltree[O * 2]++ : (y.matches++, W--, y.dyn_ltree[(k[O] + S + 1) * 2]++, y.dyn_dtree[ne(W) * 2]++), y.sym_next === y.sym_end); + var Ie = Y, Re = K, Z = de, ce = ve, Ae = q, Fe = { + _tr_init: Ie, + _tr_stored_block: Re, + _tr_flush_block: Z, + _tr_tally: ce, + _tr_align: Ae + }, Oe = (y, W, O, J) => { + let ie = y & 65535 | 0, te = y >>> 16 & 65535 | 0, De = 0; + for (; O !== 0; ) { + De = O > 2e3 ? 2e3 : O, O -= De; + do + ie = ie + W[J++] | 0, te = te + ie | 0; + while (--De); + ie %= 65521, te %= 65521; + } + return ie | te << 16 | 0; + }; + const j = () => { + let y, W = []; + for (var O = 0; O < 256; O++) { + y = O; + for (var J = 0; J < 8; J++) + y = y & 1 ? 3988292384 ^ y >>> 1 : y >>> 1; + W[O] = y; + } + return W; + }, $e = new Uint32Array(j()); + var I = (y, W, O, J) => { + const ie = $e, te = J + O; + y ^= -1; + for (let De = J; De < te; De++) + y = y >>> 8 ^ ie[(y ^ W[De]) & 255]; + return y ^ -1; + }, be = { + 2: "need dictionary", + /* Z_NEED_DICT 2 */ + 1: "stream end", + /* Z_STREAM_END 1 */ + 0: "", + /* Z_OK 0 */ + "-1": "file error", + /* Z_ERRNO (-1) */ + "-2": "stream error", + /* Z_STREAM_ERROR (-2) */ + "-3": "data error", + /* Z_DATA_ERROR (-3) */ + "-4": "insufficient memory", + /* Z_MEM_ERROR (-4) */ + "-5": "buffer error", + /* Z_BUF_ERROR (-5) */ + "-6": "incompatible version" + /* Z_VERSION_ERROR (-6) */ + }, Ee = { + /* Allowed flush values; see deflate() and inflate() below for details */ + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + /* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + //Z_VERSION_ERROR: -6, + /* compression levels */ + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + /* Possible values of the data_type field (though see inflate()) */ + Z_BINARY: 0, + Z_TEXT: 1, + //Z_ASCII: 1, // = Z_TEXT (deprecated) + Z_UNKNOWN: 2, + /* The deflate compression method */ + Z_DEFLATED: 8 + //Z_NULL: null // Use -1 or null inline, depending on var type + }; + const { _tr_init: X, _tr_stored_block: le, _tr_flush_block: Le, _tr_tally: Ze, _tr_align: Ke } = Fe, { + Z_NO_FLUSH: je, + Z_PARTIAL_FLUSH: Je, + Z_FULL_FLUSH: Lt, + Z_FINISH: rt, + Z_BLOCK: it, + Z_OK: tt, + Z_STREAM_END: Et, + Z_STREAM_ERROR: lt, + Z_DATA_ERROR: wt, + Z_BUF_ERROR: Pt, + Z_DEFAULT_COMPRESSION: vt, + Z_FILTERED: bt, + Z_HUFFMAN_ONLY: mt, + Z_RLE: Tt, + Z_FIXED: Ot, + Z_DEFAULT_STRATEGY: Ft, + Z_UNKNOWN: Qt, + Z_DEFLATED: kt + } = Ee, Jt = 9, qt = 15, er = 8, Ht = 29, lr = 256 + 1 + Ht, Or = 30, Dr = 19, Pr = 2 * lr + 1, Ir = 15, at = 3, Bt = 258, pt = Bt + at + 1, yt = 32, At = 42, rr = 57, Rr = 69, $r = 73, Br = 91, zr = 103, Vt = 113, hr = 666, Dt = 1, ir = 2, jt = 3, nr = 4, nn = 3, Kt = (y, W) => (y.msg = be[W], W), Xr = (y) => y * 2 - (y > 4 ? 9 : 0), Gt = (y) => { + let W = y.length; + for (; --W >= 0; ) + y[W] = 0; + }, sn = (y) => { + let W, O, J, ie = y.w_size; + W = y.hash_size, J = W; + do + O = y.head[--J], y.head[J] = O >= ie ? O - ie : 0; + while (--W); + W = ie, J = W; + do + O = y.prev[--J], y.prev[J] = O >= ie ? O - ie : 0; + while (--W); + }; + let Wt = (y, W, O) => (W << y.hash_shift ^ O) & y.hash_mask; + const It = (y) => { + const W = y.state; + let O = W.pending; + O > y.avail_out && (O = y.avail_out), O !== 0 && (y.output.set(W.pending_buf.subarray(W.pending_out, W.pending_out + O), y.next_out), y.next_out += O, W.pending_out += O, y.total_out += O, y.avail_out -= O, W.pending -= O, W.pending === 0 && (W.pending_out = 0)); + }, Rt = (y, W) => { + Le(y, y.block_start >= 0 ? y.block_start : -1, y.strstart - y.block_start, W), y.block_start = y.strstart, It(y.strm); + }, dt = (y, W) => { + y.pending_buf[y.pending++] = W; + }, fr = (y, W) => { + y.pending_buf[y.pending++] = W >>> 8 & 255, y.pending_buf[y.pending++] = W & 255; + }, Fr = (y, W, O, J) => { + let ie = y.avail_in; + return ie > J && (ie = J), ie === 0 ? 0 : (y.avail_in -= ie, W.set(y.input.subarray(y.next_in, y.next_in + ie), O), y.state.wrap === 1 ? y.adler = Oe(y.adler, W, ie, O) : y.state.wrap === 2 && (y.adler = I(y.adler, W, ie, O)), y.next_in += ie, y.total_in += ie, ie); + }, Qr = (y, W) => { + let O = y.max_chain_length, J = y.strstart, ie, te, De = y.prev_length, xe = y.nice_match; + const Qe = y.strstart > y.w_size - pt ? y.strstart - (y.w_size - pt) : 0, _e = y.window, Pe = y.w_mask, ut = y.prev, Xe = y.strstart + Bt; + let Ge = _e[J + De - 1], qe = _e[J + De]; + y.prev_length >= y.good_match && (O >>= 2), xe > y.lookahead && (xe = y.lookahead); + do + if (ie = W, !(_e[ie + De] !== qe || _e[ie + De - 1] !== Ge || _e[ie] !== _e[J] || _e[++ie] !== _e[J + 1])) { + J += 2, ie++; + do + ; + while (_e[++J] === _e[++ie] && _e[++J] === _e[++ie] && _e[++J] === _e[++ie] && _e[++J] === _e[++ie] && _e[++J] === _e[++ie] && _e[++J] === _e[++ie] && _e[++J] === _e[++ie] && _e[++J] === _e[++ie] && J < Xe); + if (te = Bt - (Xe - J), J = Xe - Bt, te > De) { + if (y.match_start = W, De = te, te >= xe) + break; + Ge = _e[J + De - 1], qe = _e[J + De]; + } + } + while ((W = ut[W & Pe]) > Qe && --O !== 0); + return De <= y.lookahead ? De : y.lookahead; + }, sr = (y) => { + const W = y.w_size; + let O, J, ie; + do { + if (J = y.window_size - y.lookahead - y.strstart, y.strstart >= W + (W - pt) && (y.window.set(y.window.subarray(W, W + W - J), 0), y.match_start -= W, y.strstart -= W, y.block_start -= W, y.insert > y.strstart && (y.insert = y.strstart), sn(y), J += W), y.strm.avail_in === 0) + break; + if (O = Fr(y.strm, y.window, y.strstart + y.lookahead, J), y.lookahead += O, y.lookahead + y.insert >= at) + for (ie = y.strstart - y.insert, y.ins_h = y.window[ie], y.ins_h = Wt(y, y.ins_h, y.window[ie + 1]); y.insert && (y.ins_h = Wt(y, y.ins_h, y.window[ie + at - 1]), y.prev[ie & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = ie, ie++, y.insert--, !(y.lookahead + y.insert < at)); ) + ; + } while (y.lookahead < pt && y.strm.avail_in !== 0); + }, Jr = (y, W) => { + let O = y.pending_buf_size - 5 > y.w_size ? y.w_size : y.pending_buf_size - 5, J, ie, te, De = 0, xe = y.strm.avail_in; + do { + if (J = 65535, te = y.bi_valid + 42 >> 3, y.strm.avail_out < te || (te = y.strm.avail_out - te, ie = y.strstart - y.block_start, J > ie + y.strm.avail_in && (J = ie + y.strm.avail_in), J > te && (J = te), J < O && (J === 0 && W !== rt || W === je || J !== ie + y.strm.avail_in))) + break; + De = W === rt && J === ie + y.strm.avail_in ? 1 : 0, le(y, 0, 0, De), y.pending_buf[y.pending - 4] = J, y.pending_buf[y.pending - 3] = J >> 8, y.pending_buf[y.pending - 2] = ~J, y.pending_buf[y.pending - 1] = ~J >> 8, It(y.strm), ie && (ie > J && (ie = J), y.strm.output.set(y.window.subarray(y.block_start, y.block_start + ie), y.strm.next_out), y.strm.next_out += ie, y.strm.avail_out -= ie, y.strm.total_out += ie, y.block_start += ie, J -= ie), J && (Fr(y.strm, y.strm.output, y.strm.next_out, J), y.strm.next_out += J, y.strm.avail_out -= J, y.strm.total_out += J); + } while (De === 0); + return xe -= y.strm.avail_in, xe && (xe >= y.w_size ? (y.matches = 2, y.window.set(y.strm.input.subarray(y.strm.next_in - y.w_size, y.strm.next_in), 0), y.strstart = y.w_size, y.insert = y.strstart) : (y.window_size - y.strstart <= xe && (y.strstart -= y.w_size, y.window.set(y.window.subarray(y.w_size, y.w_size + y.strstart), 0), y.matches < 2 && y.matches++, y.insert > y.strstart && (y.insert = y.strstart)), y.window.set(y.strm.input.subarray(y.strm.next_in - xe, y.strm.next_in), y.strstart), y.strstart += xe, y.insert += xe > y.w_size - y.insert ? y.w_size - y.insert : xe), y.block_start = y.strstart), y.high_water < y.strstart && (y.high_water = y.strstart), De ? nr : W !== je && W !== rt && y.strm.avail_in === 0 && y.strstart === y.block_start ? ir : (te = y.window_size - y.strstart, y.strm.avail_in > te && y.block_start >= y.w_size && (y.block_start -= y.w_size, y.strstart -= y.w_size, y.window.set(y.window.subarray(y.w_size, y.w_size + y.strstart), 0), y.matches < 2 && y.matches++, te += y.w_size, y.insert > y.strstart && (y.insert = y.strstart)), te > y.strm.avail_in && (te = y.strm.avail_in), te && (Fr(y.strm, y.window, y.strstart, te), y.strstart += te, y.insert += te > y.w_size - y.insert ? y.w_size - y.insert : te), y.high_water < y.strstart && (y.high_water = y.strstart), te = y.bi_valid + 42 >> 3, te = y.pending_buf_size - te > 65535 ? 65535 : y.pending_buf_size - te, O = te > y.w_size ? y.w_size : te, ie = y.strstart - y.block_start, (ie >= O || (ie || W === rt) && W !== je && y.strm.avail_in === 0 && ie <= te) && (J = ie > te ? te : ie, De = W === rt && y.strm.avail_in === 0 && J === ie ? 1 : 0, le(y, y.block_start, J, De), y.block_start += J, It(y.strm)), De ? jt : Dt); + }, kr = (y, W) => { + let O, J; + for (; ; ) { + if (y.lookahead < pt) { + if (sr(y), y.lookahead < pt && W === je) + return Dt; + if (y.lookahead === 0) + break; + } + if (O = 0, y.lookahead >= at && (y.ins_h = Wt(y, y.ins_h, y.window[y.strstart + at - 1]), O = y.prev[y.strstart & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = y.strstart), O !== 0 && y.strstart - O <= y.w_size - pt && (y.match_length = Qr(y, O)), y.match_length >= at) + if (J = Ze(y, y.strstart - y.match_start, y.match_length - at), y.lookahead -= y.match_length, y.match_length <= y.max_lazy_match && y.lookahead >= at) { + y.match_length--; + do + y.strstart++, y.ins_h = Wt(y, y.ins_h, y.window[y.strstart + at - 1]), O = y.prev[y.strstart & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = y.strstart; + while (--y.match_length !== 0); + y.strstart++; + } else + y.strstart += y.match_length, y.match_length = 0, y.ins_h = y.window[y.strstart], y.ins_h = Wt(y, y.ins_h, y.window[y.strstart + 1]); + else + J = Ze(y, 0, y.window[y.strstart]), y.lookahead--, y.strstart++; + if (J && (Rt(y, !1), y.strm.avail_out === 0)) + return Dt; + } + return y.insert = y.strstart < at - 1 ? y.strstart : at - 1, W === rt ? (Rt(y, !0), y.strm.avail_out === 0 ? jt : nr) : y.sym_next && (Rt(y, !1), y.strm.avail_out === 0) ? Dt : ir; + }, ar = (y, W) => { + let O, J, ie; + for (; ; ) { + if (y.lookahead < pt) { + if (sr(y), y.lookahead < pt && W === je) + return Dt; + if (y.lookahead === 0) + break; + } + if (O = 0, y.lookahead >= at && (y.ins_h = Wt(y, y.ins_h, y.window[y.strstart + at - 1]), O = y.prev[y.strstart & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = y.strstart), y.prev_length = y.match_length, y.prev_match = y.match_start, y.match_length = at - 1, O !== 0 && y.prev_length < y.max_lazy_match && y.strstart - O <= y.w_size - pt && (y.match_length = Qr(y, O), y.match_length <= 5 && (y.strategy === bt || y.match_length === at && y.strstart - y.match_start > 4096) && (y.match_length = at - 1)), y.prev_length >= at && y.match_length <= y.prev_length) { + ie = y.strstart + y.lookahead - at, J = Ze(y, y.strstart - 1 - y.prev_match, y.prev_length - at), y.lookahead -= y.prev_length - 1, y.prev_length -= 2; + do + ++y.strstart <= ie && (y.ins_h = Wt(y, y.ins_h, y.window[y.strstart + at - 1]), O = y.prev[y.strstart & y.w_mask] = y.head[y.ins_h], y.head[y.ins_h] = y.strstart); + while (--y.prev_length !== 0); + if (y.match_available = 0, y.match_length = at - 1, y.strstart++, J && (Rt(y, !1), y.strm.avail_out === 0)) + return Dt; + } else if (y.match_available) { + if (J = Ze(y, 0, y.window[y.strstart - 1]), J && Rt(y, !1), y.strstart++, y.lookahead--, y.strm.avail_out === 0) + return Dt; + } else + y.match_available = 1, y.strstart++, y.lookahead--; + } + return y.match_available && (J = Ze(y, 0, y.window[y.strstart - 1]), y.match_available = 0), y.insert = y.strstart < at - 1 ? y.strstart : at - 1, W === rt ? (Rt(y, !0), y.strm.avail_out === 0 ? jt : nr) : y.sym_next && (Rt(y, !1), y.strm.avail_out === 0) ? Dt : ir; + }, an = (y, W) => { + let O, J, ie, te; + const De = y.window; + for (; ; ) { + if (y.lookahead <= Bt) { + if (sr(y), y.lookahead <= Bt && W === je) + return Dt; + if (y.lookahead === 0) + break; + } + if (y.match_length = 0, y.lookahead >= at && y.strstart > 0 && (ie = y.strstart - 1, J = De[ie], J === De[++ie] && J === De[++ie] && J === De[++ie])) { + te = y.strstart + Bt; + do + ; + while (J === De[++ie] && J === De[++ie] && J === De[++ie] && J === De[++ie] && J === De[++ie] && J === De[++ie] && J === De[++ie] && J === De[++ie] && ie < te); + y.match_length = Bt - (te - ie), y.match_length > y.lookahead && (y.match_length = y.lookahead); + } + if (y.match_length >= at ? (O = Ze(y, 1, y.match_length - at), y.lookahead -= y.match_length, y.strstart += y.match_length, y.match_length = 0) : (O = Ze(y, 0, y.window[y.strstart]), y.lookahead--, y.strstart++), O && (Rt(y, !1), y.strm.avail_out === 0)) + return Dt; + } + return y.insert = 0, W === rt ? (Rt(y, !0), y.strm.avail_out === 0 ? jt : nr) : y.sym_next && (Rt(y, !1), y.strm.avail_out === 0) ? Dt : ir; + }, on = (y, W) => { + let O; + for (; ; ) { + if (y.lookahead === 0 && (sr(y), y.lookahead === 0)) { + if (W === je) + return Dt; + break; + } + if (y.match_length = 0, O = Ze(y, 0, y.window[y.strstart]), y.lookahead--, y.strstart++, O && (Rt(y, !1), y.strm.avail_out === 0)) + return Dt; + } + return y.insert = 0, W === rt ? (Rt(y, !0), y.strm.avail_out === 0 ? jt : nr) : y.sym_next && (Rt(y, !1), y.strm.avail_out === 0) ? Dt : ir; + }; + function zt(y, W, O, J, ie) { + this.good_length = y, this.max_lazy = W, this.nice_length = O, this.max_chain = J, this.func = ie; + } + const cr = [ + /* good lazy nice chain */ + new zt(0, 0, 0, 0, Jr), + /* 0 store only */ + new zt(4, 4, 8, 4, kr), + /* 1 max speed, no lazy matches */ + new zt(4, 5, 16, 8, kr), + /* 2 */ + new zt(4, 6, 32, 32, kr), + /* 3 */ + new zt(4, 4, 16, 16, ar), + /* 4 lazy matches */ + new zt(8, 16, 32, 32, ar), + /* 5 */ + new zt(8, 16, 128, 128, ar), + /* 6 */ + new zt(8, 32, 128, 256, ar), + /* 7 */ + new zt(32, 128, 258, 1024, ar), + /* 8 */ + new zt(32, 258, 258, 4096, ar) + /* 9 max compression */ + ], ln = (y) => { + y.window_size = 2 * y.w_size, Gt(y.head), y.max_lazy_match = cr[y.level].max_lazy, y.good_match = cr[y.level].good_length, y.nice_match = cr[y.level].nice_length, y.max_chain_length = cr[y.level].max_chain, y.strstart = 0, y.block_start = 0, y.lookahead = 0, y.insert = 0, y.match_length = y.prev_length = at - 1, y.match_available = 0, y.ins_h = 0; + }; + function hn() { + this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = kt, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new Uint16Array(Pr * 2), this.dyn_dtree = new Uint16Array((2 * Or + 1) * 2), this.bl_tree = new Uint16Array((2 * Dr + 1) * 2), Gt(this.dyn_ltree), Gt(this.dyn_dtree), Gt(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new Uint16Array(Ir + 1), this.heap = new Uint16Array(2 * lr + 1), Gt(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new Uint16Array(2 * lr + 1), Gt(this.depth), this.sym_buf = 0, this.lit_bufsize = 0, this.sym_next = 0, this.sym_end = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; + } + const ur = (y) => { + if (!y) + return 1; + const W = y.state; + return !W || W.strm !== y || W.status !== At && //#ifdef GZIP + W.status !== rr && //#endif + W.status !== Rr && W.status !== $r && W.status !== Br && W.status !== zr && W.status !== Vt && W.status !== hr ? 1 : 0; + }, qr = (y) => { + if (ur(y)) + return Kt(y, lt); + y.total_in = y.total_out = 0, y.data_type = Qt; + const W = y.state; + return W.pending = 0, W.pending_out = 0, W.wrap < 0 && (W.wrap = -W.wrap), W.status = //#ifdef GZIP + W.wrap === 2 ? rr : ( + //#endif + W.wrap ? At : Vt + ), y.adler = W.wrap === 2 ? 0 : 1, W.last_flush = -2, X(W), tt; + }, ei = (y) => { + const W = qr(y); + return W === tt && ln(y.state), W; + }, cn = (y, W) => ur(y) || y.state.wrap !== 2 ? lt : (y.state.gzhead = W, tt), ti = (y, W, O, J, ie, te) => { + if (!y) + return lt; + let De = 1; + if (W === vt && (W = 6), J < 0 ? (De = 0, J = -J) : J > 15 && (De = 2, J -= 16), ie < 1 || ie > Jt || O !== kt || J < 8 || J > 15 || W < 0 || W > 9 || te < 0 || te > Ot || J === 8 && De !== 1) + return Kt(y, lt); + J === 8 && (J = 9); + const xe = new hn(); + return y.state = xe, xe.strm = y, xe.status = At, xe.wrap = De, xe.gzhead = null, xe.w_bits = J, xe.w_size = 1 << xe.w_bits, xe.w_mask = xe.w_size - 1, xe.hash_bits = ie + 7, xe.hash_size = 1 << xe.hash_bits, xe.hash_mask = xe.hash_size - 1, xe.hash_shift = ~~((xe.hash_bits + at - 1) / at), xe.window = new Uint8Array(xe.w_size * 2), xe.head = new Uint16Array(xe.hash_size), xe.prev = new Uint16Array(xe.w_size), xe.lit_bufsize = 1 << ie + 6, xe.pending_buf_size = xe.lit_bufsize * 4, xe.pending_buf = new Uint8Array(xe.pending_buf_size), xe.sym_buf = xe.lit_bufsize, xe.sym_end = (xe.lit_bufsize - 1) * 3, xe.level = W, xe.strategy = te, xe.method = O, ei(y); + }, un = (y, W) => ti(y, W, kt, qt, er, Ft), dn = (y, W) => { + if (ur(y) || W > it || W < 0) + return y ? Kt(y, lt) : lt; + const O = y.state; + if (!y.output || y.avail_in !== 0 && !y.input || O.status === hr && W !== rt) + return Kt(y, y.avail_out === 0 ? Pt : lt); + const J = O.last_flush; + if (O.last_flush = W, O.pending !== 0) { + if (It(y), y.avail_out === 0) + return O.last_flush = -1, tt; + } else if (y.avail_in === 0 && Xr(W) <= Xr(J) && W !== rt) + return Kt(y, Pt); + if (O.status === hr && y.avail_in !== 0) + return Kt(y, Pt); + if (O.status === At && O.wrap === 0 && (O.status = Vt), O.status === At) { + let ie = kt + (O.w_bits - 8 << 4) << 8, te = -1; + if (O.strategy >= mt || O.level < 2 ? te = 0 : O.level < 6 ? te = 1 : O.level === 6 ? te = 2 : te = 3, ie |= te << 6, O.strstart !== 0 && (ie |= yt), ie += 31 - ie % 31, fr(O, ie), O.strstart !== 0 && (fr(O, y.adler >>> 16), fr(O, y.adler & 65535)), y.adler = 1, O.status = Vt, It(y), O.pending !== 0) + return O.last_flush = -1, tt; + } + if (O.status === rr) { + if (y.adler = 0, dt(O, 31), dt(O, 139), dt(O, 8), O.gzhead) + dt( + O, + (O.gzhead.text ? 1 : 0) + (O.gzhead.hcrc ? 2 : 0) + (O.gzhead.extra ? 4 : 0) + (O.gzhead.name ? 8 : 0) + (O.gzhead.comment ? 16 : 0) + ), dt(O, O.gzhead.time & 255), dt(O, O.gzhead.time >> 8 & 255), dt(O, O.gzhead.time >> 16 & 255), dt(O, O.gzhead.time >> 24 & 255), dt(O, O.level === 9 ? 2 : O.strategy >= mt || O.level < 2 ? 4 : 0), dt(O, O.gzhead.os & 255), O.gzhead.extra && O.gzhead.extra.length && (dt(O, O.gzhead.extra.length & 255), dt(O, O.gzhead.extra.length >> 8 & 255)), O.gzhead.hcrc && (y.adler = I(y.adler, O.pending_buf, O.pending, 0)), O.gzindex = 0, O.status = Rr; + else if (dt(O, 0), dt(O, 0), dt(O, 0), dt(O, 0), dt(O, 0), dt(O, O.level === 9 ? 2 : O.strategy >= mt || O.level < 2 ? 4 : 0), dt(O, nn), O.status = Vt, It(y), O.pending !== 0) + return O.last_flush = -1, tt; + } + if (O.status === Rr) { + if (O.gzhead.extra) { + let ie = O.pending, te = (O.gzhead.extra.length & 65535) - O.gzindex; + for (; O.pending + te > O.pending_buf_size; ) { + let xe = O.pending_buf_size - O.pending; + if (O.pending_buf.set(O.gzhead.extra.subarray(O.gzindex, O.gzindex + xe), O.pending), O.pending = O.pending_buf_size, O.gzhead.hcrc && O.pending > ie && (y.adler = I(y.adler, O.pending_buf, O.pending - ie, ie)), O.gzindex += xe, It(y), O.pending !== 0) + return O.last_flush = -1, tt; + ie = 0, te -= xe; + } + let De = new Uint8Array(O.gzhead.extra); + O.pending_buf.set(De.subarray(O.gzindex, O.gzindex + te), O.pending), O.pending += te, O.gzhead.hcrc && O.pending > ie && (y.adler = I(y.adler, O.pending_buf, O.pending - ie, ie)), O.gzindex = 0; + } + O.status = $r; + } + if (O.status === $r) { + if (O.gzhead.name) { + let ie = O.pending, te; + do { + if (O.pending === O.pending_buf_size) { + if (O.gzhead.hcrc && O.pending > ie && (y.adler = I(y.adler, O.pending_buf, O.pending - ie, ie)), It(y), O.pending !== 0) + return O.last_flush = -1, tt; + ie = 0; + } + O.gzindex < O.gzhead.name.length ? te = O.gzhead.name.charCodeAt(O.gzindex++) & 255 : te = 0, dt(O, te); + } while (te !== 0); + O.gzhead.hcrc && O.pending > ie && (y.adler = I(y.adler, O.pending_buf, O.pending - ie, ie)), O.gzindex = 0; + } + O.status = Br; + } + if (O.status === Br) { + if (O.gzhead.comment) { + let ie = O.pending, te; + do { + if (O.pending === O.pending_buf_size) { + if (O.gzhead.hcrc && O.pending > ie && (y.adler = I(y.adler, O.pending_buf, O.pending - ie, ie)), It(y), O.pending !== 0) + return O.last_flush = -1, tt; + ie = 0; + } + O.gzindex < O.gzhead.comment.length ? te = O.gzhead.comment.charCodeAt(O.gzindex++) & 255 : te = 0, dt(O, te); + } while (te !== 0); + O.gzhead.hcrc && O.pending > ie && (y.adler = I(y.adler, O.pending_buf, O.pending - ie, ie)); + } + O.status = zr; + } + if (O.status === zr) { + if (O.gzhead.hcrc) { + if (O.pending + 2 > O.pending_buf_size && (It(y), O.pending !== 0)) + return O.last_flush = -1, tt; + dt(O, y.adler & 255), dt(O, y.adler >> 8 & 255), y.adler = 0; + } + if (O.status = Vt, It(y), O.pending !== 0) + return O.last_flush = -1, tt; + } + if (y.avail_in !== 0 || O.lookahead !== 0 || W !== je && O.status !== hr) { + let ie = O.level === 0 ? Jr(O, W) : O.strategy === mt ? on(O, W) : O.strategy === Tt ? an(O, W) : cr[O.level].func(O, W); + if ((ie === jt || ie === nr) && (O.status = hr), ie === Dt || ie === jt) + return y.avail_out === 0 && (O.last_flush = -1), tt; + if (ie === ir && (W === Je ? Ke(O) : W !== it && (le(O, 0, 0, !1), W === Lt && (Gt(O.head), O.lookahead === 0 && (O.strstart = 0, O.block_start = 0, O.insert = 0))), It(y), y.avail_out === 0)) + return O.last_flush = -1, tt; + } + return W !== rt ? tt : O.wrap <= 0 ? Et : (O.wrap === 2 ? (dt(O, y.adler & 255), dt(O, y.adler >> 8 & 255), dt(O, y.adler >> 16 & 255), dt(O, y.adler >> 24 & 255), dt(O, y.total_in & 255), dt(O, y.total_in >> 8 & 255), dt(O, y.total_in >> 16 & 255), dt(O, y.total_in >> 24 & 255)) : (fr(O, y.adler >>> 16), fr(O, y.adler & 65535)), It(y), O.wrap > 0 && (O.wrap = -O.wrap), O.pending !== 0 ? tt : Et); + }, _n = (y) => { + if (ur(y)) + return lt; + const W = y.state.status; + return y.state = null, W === Vt ? Kt(y, wt) : tt; + }, pn = (y, W) => { + let O = W.length; + if (ur(y)) + return lt; + const J = y.state, ie = J.wrap; + if (ie === 2 || ie === 1 && J.status !== At || J.lookahead) + return lt; + if (ie === 1 && (y.adler = Oe(y.adler, W, O, 0)), J.wrap = 0, O >= J.w_size) { + ie === 0 && (Gt(J.head), J.strstart = 0, J.block_start = 0, J.insert = 0); + let Qe = new Uint8Array(J.w_size); + Qe.set(W.subarray(O - J.w_size, O), 0), W = Qe, O = J.w_size; + } + const te = y.avail_in, De = y.next_in, xe = y.input; + for (y.avail_in = O, y.next_in = 0, y.input = W, sr(J); J.lookahead >= at; ) { + let Qe = J.strstart, _e = J.lookahead - (at - 1); + do + J.ins_h = Wt(J, J.ins_h, J.window[Qe + at - 1]), J.prev[Qe & J.w_mask] = J.head[J.ins_h], J.head[J.ins_h] = Qe, Qe++; + while (--_e); + J.strstart = Qe, J.lookahead = at - 1, sr(J); + } + return J.strstart += J.lookahead, J.block_start = J.strstart, J.insert = J.lookahead, J.lookahead = 0, J.match_length = J.prev_length = at - 1, J.match_available = 0, y.next_in = De, y.input = xe, y.avail_in = te, J.wrap = ie, tt; + }; + var gn = un, mn = ti, vn = ei, bn = qr, yn = cn, xn = dn, En = _n, wn = pn, An = "pako deflate (from Nodeca project)", dr = { + deflateInit: gn, + deflateInit2: mn, + deflateReset: vn, + deflateResetKeep: bn, + deflateSetHeader: yn, + deflate: xn, + deflateEnd: En, + deflateSetDictionary: wn, + deflateInfo: An + }; + const Mn = (y, W) => Object.prototype.hasOwnProperty.call(y, W); + var Cn = function(y) { + const W = Array.prototype.slice.call(arguments, 1); + for (; W.length; ) { + const O = W.shift(); + if (O) { + if (typeof O != "object") + throw new TypeError(O + "must be non-object"); + for (const J in O) + Mn(O, J) && (y[J] = O[J]); + } + } + return y; + }, Ln = (y) => { + let W = 0; + for (let J = 0, ie = y.length; J < ie; J++) + W += y[J].length; + const O = new Uint8Array(W); + for (let J = 0, ie = 0, te = y.length; J < te; J++) { + let De = y[J]; + O.set(De, ie), ie += De.length; + } + return O; + }, yr = { + assign: Cn, + flattenChunks: Ln + }; + let ri = !0; + try { + String.fromCharCode.apply(null, new Uint8Array(1)); + } catch { + ri = !1; + } + const _r = new Uint8Array(256); + for (let y = 0; y < 256; y++) + _r[y] = y >= 252 ? 6 : y >= 248 ? 5 : y >= 240 ? 4 : y >= 224 ? 3 : y >= 192 ? 2 : 1; + _r[254] = _r[254] = 1; + var Sn = (y) => { + if (typeof TextEncoder == "function" && TextEncoder.prototype.encode) + return new TextEncoder().encode(y); + let W, O, J, ie, te, De = y.length, xe = 0; + for (ie = 0; ie < De; ie++) + O = y.charCodeAt(ie), (O & 64512) === 55296 && ie + 1 < De && (J = y.charCodeAt(ie + 1), (J & 64512) === 56320 && (O = 65536 + (O - 55296 << 10) + (J - 56320), ie++)), xe += O < 128 ? 1 : O < 2048 ? 2 : O < 65536 ? 3 : 4; + for (W = new Uint8Array(xe), te = 0, ie = 0; te < xe; ie++) + O = y.charCodeAt(ie), (O & 64512) === 55296 && ie + 1 < De && (J = y.charCodeAt(ie + 1), (J & 64512) === 56320 && (O = 65536 + (O - 55296 << 10) + (J - 56320), ie++)), O < 128 ? W[te++] = O : O < 2048 ? (W[te++] = 192 | O >>> 6, W[te++] = 128 | O & 63) : O < 65536 ? (W[te++] = 224 | O >>> 12, W[te++] = 128 | O >>> 6 & 63, W[te++] = 128 | O & 63) : (W[te++] = 240 | O >>> 18, W[te++] = 128 | O >>> 12 & 63, W[te++] = 128 | O >>> 6 & 63, W[te++] = 128 | O & 63); + return W; + }; + const Tn = (y, W) => { + if (W < 65534 && y.subarray && ri) + return String.fromCharCode.apply(null, y.length === W ? y : y.subarray(0, W)); + let O = ""; + for (let J = 0; J < W; J++) + O += String.fromCharCode(y[J]); + return O; + }; + var On = (y, W) => { + const O = W || y.length; + if (typeof TextDecoder == "function" && TextDecoder.prototype.decode) + return new TextDecoder().decode(y.subarray(0, W)); + let J, ie; + const te = new Array(O * 2); + for (ie = 0, J = 0; J < O; ) { + let De = y[J++]; + if (De < 128) { + te[ie++] = De; + continue; + } + let xe = _r[De]; + if (xe > 4) { + te[ie++] = 65533, J += xe - 1; + continue; + } + for (De &= xe === 2 ? 31 : xe === 3 ? 15 : 7; xe > 1 && J < O; ) + De = De << 6 | y[J++] & 63, xe--; + if (xe > 1) { + te[ie++] = 65533; + continue; + } + De < 65536 ? te[ie++] = De : (De -= 65536, te[ie++] = 55296 | De >> 10 & 1023, te[ie++] = 56320 | De & 1023); + } + return Tn(te, ie); + }, Dn = (y, W) => { + W = W || y.length, W > y.length && (W = y.length); + let O = W - 1; + for (; O >= 0 && (y[O] & 192) === 128; ) + O--; + return O < 0 || O === 0 ? W : O + _r[y[O]] > W ? O : W; + }, pr = { + string2buf: Sn, + buf2string: On, + utf8border: Dn + }; + function Pn() { + this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; + } + var ii = Pn; + const ni = Object.prototype.toString, { + Z_NO_FLUSH: In, + Z_SYNC_FLUSH: Rn, + Z_FULL_FLUSH: $n, + Z_FINISH: Bn, + Z_OK: xr, + Z_STREAM_END: zn, + Z_DEFAULT_COMPRESSION: Fn, + Z_DEFAULT_STRATEGY: kn, + Z_DEFLATED: Un + } = Ee; + function gr(y) { + this.options = yr.assign({ + level: Fn, + method: Un, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: kn + }, y || {}); + let W = this.options; + W.raw && W.windowBits > 0 ? W.windowBits = -W.windowBits : W.gzip && W.windowBits > 0 && W.windowBits < 16 && (W.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new ii(), this.strm.avail_out = 0; + let O = dr.deflateInit2( + this.strm, + W.level, + W.method, + W.windowBits, + W.memLevel, + W.strategy + ); + if (O !== xr) + throw new Error(be[O]); + if (W.header && dr.deflateSetHeader(this.strm, W.header), W.dictionary) { + let J; + if (typeof W.dictionary == "string" ? J = pr.string2buf(W.dictionary) : ni.call(W.dictionary) === "[object ArrayBuffer]" ? J = new Uint8Array(W.dictionary) : J = W.dictionary, O = dr.deflateSetDictionary(this.strm, J), O !== xr) + throw new Error(be[O]); + this._dict_set = !0; + } + } + gr.prototype.push = function(y, W) { + const O = this.strm, J = this.options.chunkSize; + let ie, te; + if (this.ended) + return !1; + for (W === ~~W ? te = W : te = W === !0 ? Bn : In, typeof y == "string" ? O.input = pr.string2buf(y) : ni.call(y) === "[object ArrayBuffer]" ? O.input = new Uint8Array(y) : O.input = y, O.next_in = 0, O.avail_in = O.input.length; ; ) { + if (O.avail_out === 0 && (O.output = new Uint8Array(J), O.next_out = 0, O.avail_out = J), (te === Rn || te === $n) && O.avail_out <= 6) { + this.onData(O.output.subarray(0, O.next_out)), O.avail_out = 0; + continue; + } + if (ie = dr.deflate(O, te), ie === zn) + return O.next_out > 0 && this.onData(O.output.subarray(0, O.next_out)), ie = dr.deflateEnd(this.strm), this.onEnd(ie), this.ended = !0, ie === xr; + if (O.avail_out === 0) { + this.onData(O.output); + continue; + } + if (te > 0 && O.next_out > 0) { + this.onData(O.output.subarray(0, O.next_out)), O.avail_out = 0; + continue; + } + if (O.avail_in === 0) + break; + } + return !0; + }, gr.prototype.onData = function(y) { + this.chunks.push(y); + }, gr.prototype.onEnd = function(y) { + y === xr && (this.result = yr.flattenChunks(this.chunks)), this.chunks = [], this.err = y, this.msg = this.strm.msg; + }; + function Ur(y, W) { + const O = new gr(W); + if (O.push(y, !0), O.err) + throw O.msg || be[O.err]; + return O.result; + } + function Nn(y, W) { + return W = W || {}, W.raw = !0, Ur(y, W); + } + function Gn(y, W) { + return W = W || {}, W.gzip = !0, Ur(y, W); + } + var Wn = gr, Hn = Ur, Vn = Nn, jn = Gn, Kn = Ee, Zn = { + Deflate: Wn, + deflate: Hn, + deflateRaw: Vn, + gzip: jn, + constants: Kn + }; + const Er = 16209, Yn = 16191; + var Xn = function(W, O) { + let J, ie, te, De, xe, Qe, _e, Pe, ut, Xe, Ge, qe, Ct, ft, st, gt, ot, Ye, _t, St, et, xt, ct, nt; + const ht = W.state; + J = W.next_in, ct = W.input, ie = J + (W.avail_in - 5), te = W.next_out, nt = W.output, De = te - (O - W.avail_out), xe = te + (W.avail_out - 257), Qe = ht.dmax, _e = ht.wsize, Pe = ht.whave, ut = ht.wnext, Xe = ht.window, Ge = ht.hold, qe = ht.bits, Ct = ht.lencode, ft = ht.distcode, st = (1 << ht.lenbits) - 1, gt = (1 << ht.distbits) - 1; + e: + do { + qe < 15 && (Ge += ct[J++] << qe, qe += 8, Ge += ct[J++] << qe, qe += 8), ot = Ct[Ge & st]; + t: + for (; ; ) { + if (Ye = ot >>> 24, Ge >>>= Ye, qe -= Ye, Ye = ot >>> 16 & 255, Ye === 0) + nt[te++] = ot & 65535; + else if (Ye & 16) { + _t = ot & 65535, Ye &= 15, Ye && (qe < Ye && (Ge += ct[J++] << qe, qe += 8), _t += Ge & (1 << Ye) - 1, Ge >>>= Ye, qe -= Ye), qe < 15 && (Ge += ct[J++] << qe, qe += 8, Ge += ct[J++] << qe, qe += 8), ot = ft[Ge & gt]; + r: + for (; ; ) { + if (Ye = ot >>> 24, Ge >>>= Ye, qe -= Ye, Ye = ot >>> 16 & 255, Ye & 16) { + if (St = ot & 65535, Ye &= 15, qe < Ye && (Ge += ct[J++] << qe, qe += 8, qe < Ye && (Ge += ct[J++] << qe, qe += 8)), St += Ge & (1 << Ye) - 1, St > Qe) { + W.msg = "invalid distance too far back", ht.mode = Er; + break e; + } + if (Ge >>>= Ye, qe -= Ye, Ye = te - De, St > Ye) { + if (Ye = St - Ye, Ye > Pe && ht.sane) { + W.msg = "invalid distance too far back", ht.mode = Er; + break e; + } + if (et = 0, xt = Xe, ut === 0) { + if (et += _e - Ye, Ye < _t) { + _t -= Ye; + do + nt[te++] = Xe[et++]; + while (--Ye); + et = te - St, xt = nt; + } + } else if (ut < Ye) { + if (et += _e + ut - Ye, Ye -= ut, Ye < _t) { + _t -= Ye; + do + nt[te++] = Xe[et++]; + while (--Ye); + if (et = 0, ut < _t) { + Ye = ut, _t -= Ye; + do + nt[te++] = Xe[et++]; + while (--Ye); + et = te - St, xt = nt; + } + } + } else if (et += ut - Ye, Ye < _t) { + _t -= Ye; + do + nt[te++] = Xe[et++]; + while (--Ye); + et = te - St, xt = nt; + } + for (; _t > 2; ) + nt[te++] = xt[et++], nt[te++] = xt[et++], nt[te++] = xt[et++], _t -= 3; + _t && (nt[te++] = xt[et++], _t > 1 && (nt[te++] = xt[et++])); + } else { + et = te - St; + do + nt[te++] = nt[et++], nt[te++] = nt[et++], nt[te++] = nt[et++], _t -= 3; + while (_t > 2); + _t && (nt[te++] = nt[et++], _t > 1 && (nt[te++] = nt[et++])); + } + } else if (Ye & 64) { + W.msg = "invalid distance code", ht.mode = Er; + break e; + } else { + ot = ft[(ot & 65535) + (Ge & (1 << Ye) - 1)]; + continue r; + } + break; + } + } else if (Ye & 64) + if (Ye & 32) { + ht.mode = Yn; + break e; + } else { + W.msg = "invalid literal/length code", ht.mode = Er; + break e; + } + else { + ot = Ct[(ot & 65535) + (Ge & (1 << Ye) - 1)]; + continue t; + } + break; + } + } while (J < ie && te < xe); + _t = qe >> 3, J -= _t, qe -= _t << 3, Ge &= (1 << qe) - 1, W.next_in = J, W.next_out = te, W.avail_in = J < ie ? 5 + (ie - J) : 5 - (J - ie), W.avail_out = te < xe ? 257 + (xe - te) : 257 - (te - xe), ht.hold = Ge, ht.bits = qe; + }; + const or = 15, si = 852, ai = 592, oi = 0, Nr = 1, li = 2, Qn = new Uint16Array([ + /* Length codes 257..285 base */ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 13, + 15, + 17, + 19, + 23, + 27, + 31, + 35, + 43, + 51, + 59, + 67, + 83, + 99, + 115, + 131, + 163, + 195, + 227, + 258, + 0, + 0 + ]), Jn = new Uint8Array([ + /* Length codes 257..285 extra */ + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 17, + 17, + 17, + 17, + 18, + 18, + 18, + 18, + 19, + 19, + 19, + 19, + 20, + 20, + 20, + 20, + 21, + 21, + 21, + 21, + 16, + 72, + 78 + ]), qn = new Uint16Array([ + /* Distance codes 0..29 base */ + 1, + 2, + 3, + 4, + 5, + 7, + 9, + 13, + 17, + 25, + 33, + 49, + 65, + 97, + 129, + 193, + 257, + 385, + 513, + 769, + 1025, + 1537, + 2049, + 3073, + 4097, + 6145, + 8193, + 12289, + 16385, + 24577, + 0, + 0 + ]), es = new Uint8Array([ + /* Distance codes 0..29 extra */ + 16, + 16, + 16, + 16, + 17, + 17, + 18, + 18, + 19, + 19, + 20, + 20, + 21, + 21, + 22, + 22, + 23, + 23, + 24, + 24, + 25, + 25, + 26, + 26, + 27, + 27, + 28, + 28, + 29, + 29, + 64, + 64 + ]); + var mr = (y, W, O, J, ie, te, De, xe) => { + const Qe = xe.bits; + let _e = 0, Pe = 0, ut = 0, Xe = 0, Ge = 0, qe = 0, Ct = 0, ft = 0, st = 0, gt = 0, ot, Ye, _t, St, et, xt = null, ct; + const nt = new Uint16Array(or + 1), ht = new Uint16Array(or + 1); + let Xt = null, rn, Sr, Tr; + for (_e = 0; _e <= or; _e++) + nt[_e] = 0; + for (Pe = 0; Pe < J; Pe++) + nt[W[O + Pe]]++; + for (Ge = Qe, Xe = or; Xe >= 1 && nt[Xe] === 0; Xe--) + ; + if (Ge > Xe && (Ge = Xe), Xe === 0) + return ie[te++] = 1 << 24 | 64 << 16 | 0, ie[te++] = 1 << 24 | 64 << 16 | 0, xe.bits = 1, 0; + for (ut = 1; ut < Xe && nt[ut] === 0; ut++) + ; + for (Ge < ut && (Ge = ut), ft = 1, _e = 1; _e <= or; _e++) + if (ft <<= 1, ft -= nt[_e], ft < 0) + return -1; + if (ft > 0 && (y === oi || Xe !== 1)) + return -1; + for (ht[1] = 0, _e = 1; _e < or; _e++) + ht[_e + 1] = ht[_e] + nt[_e]; + for (Pe = 0; Pe < J; Pe++) + W[O + Pe] !== 0 && (De[ht[W[O + Pe]]++] = Pe); + if (y === oi ? (xt = Xt = De, ct = 20) : y === Nr ? (xt = Qn, Xt = Jn, ct = 257) : (xt = qn, Xt = es, ct = 0), gt = 0, Pe = 0, _e = ut, et = te, qe = Ge, Ct = 0, _t = -1, st = 1 << Ge, St = st - 1, y === Nr && st > si || y === li && st > ai) + return 1; + for (; ; ) { + rn = _e - Ct, De[Pe] + 1 < ct ? (Sr = 0, Tr = De[Pe]) : De[Pe] >= ct ? (Sr = Xt[De[Pe] - ct], Tr = xt[De[Pe] - ct]) : (Sr = 32 + 64, Tr = 0), ot = 1 << _e - Ct, Ye = 1 << qe, ut = Ye; + do + Ye -= ot, ie[et + (gt >> Ct) + Ye] = rn << 24 | Sr << 16 | Tr | 0; + while (Ye !== 0); + for (ot = 1 << _e - 1; gt & ot; ) + ot >>= 1; + if (ot !== 0 ? (gt &= ot - 1, gt += ot) : gt = 0, Pe++, --nt[_e] === 0) { + if (_e === Xe) + break; + _e = W[O + De[Pe]]; + } + if (_e > Ge && (gt & St) !== _t) { + for (Ct === 0 && (Ct = Ge), et += ut, qe = _e - Ct, ft = 1 << qe; qe + Ct < Xe && (ft -= nt[qe + Ct], !(ft <= 0)); ) + qe++, ft <<= 1; + if (st += 1 << qe, y === Nr && st > si || y === li && st > ai) + return 1; + _t = gt & St, ie[_t] = Ge << 24 | qe << 16 | et - te | 0; + } + } + return gt !== 0 && (ie[et + gt] = _e - Ct << 24 | 64 << 16 | 0), xe.bits = Ge, 0; + }; + const ts = 0, hi = 1, fi = 2, { + Z_FINISH: ci, + Z_BLOCK: rs, + Z_TREES: wr, + Z_OK: Zt, + Z_STREAM_END: is, + Z_NEED_DICT: ns, + Z_STREAM_ERROR: $t, + Z_DATA_ERROR: ui, + Z_MEM_ERROR: di, + Z_BUF_ERROR: ss, + Z_DEFLATED: _i + } = Ee, Ar = 16180, pi = 16181, gi = 16182, mi = 16183, vi = 16184, bi = 16185, yi = 16186, xi = 16187, Ei = 16188, wi = 16189, Mr = 16190, Ut = 16191, Gr = 16192, Ai = 16193, Wr = 16194, Mi = 16195, Ci = 16196, Li = 16197, Si = 16198, Cr = 16199, Lr = 16200, Ti = 16201, Oi = 16202, Di = 16203, Pi = 16204, Ii = 16205, Hr = 16206, Ri = 16207, $i = 16208, Mt = 16209, Bi = 16210, zi = 16211, as = 852, os = 592, ls = 15, Fi = (y) => (y >>> 24 & 255) + (y >>> 8 & 65280) + ((y & 65280) << 8) + ((y & 255) << 24); + function hs() { + this.strm = null, this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; + } + const Yt = (y) => { + if (!y) + return 1; + const W = y.state; + return !W || W.strm !== y || W.mode < Ar || W.mode > zi ? 1 : 0; + }, ki = (y) => { + if (Yt(y)) + return $t; + const W = y.state; + return y.total_in = y.total_out = W.total = 0, y.msg = "", W.wrap && (y.adler = W.wrap & 1), W.mode = Ar, W.last = 0, W.havedict = 0, W.flags = -1, W.dmax = 32768, W.head = null, W.hold = 0, W.bits = 0, W.lencode = W.lendyn = new Int32Array(as), W.distcode = W.distdyn = new Int32Array(os), W.sane = 1, W.back = -1, Zt; + }, Ui = (y) => { + if (Yt(y)) + return $t; + const W = y.state; + return W.wsize = 0, W.whave = 0, W.wnext = 0, ki(y); + }, Ni = (y, W) => { + let O; + if (Yt(y)) + return $t; + const J = y.state; + return W < 0 ? (O = 0, W = -W) : (O = (W >> 4) + 5, W < 48 && (W &= 15)), W && (W < 8 || W > 15) ? $t : (J.window !== null && J.wbits !== W && (J.window = null), J.wrap = O, J.wbits = W, Ui(y)); + }, Gi = (y, W) => { + if (!y) + return $t; + const O = new hs(); + y.state = O, O.strm = y, O.window = null, O.mode = Ar; + const J = Ni(y, W); + return J !== Zt && (y.state = null), J; + }, fs = (y) => Gi(y, ls); + let Wi = !0, Vr, jr; + const cs = (y) => { + if (Wi) { + Vr = new Int32Array(512), jr = new Int32Array(32); + let W = 0; + for (; W < 144; ) + y.lens[W++] = 8; + for (; W < 256; ) + y.lens[W++] = 9; + for (; W < 280; ) + y.lens[W++] = 7; + for (; W < 288; ) + y.lens[W++] = 8; + for (mr(hi, y.lens, 0, 288, Vr, 0, y.work, { bits: 9 }), W = 0; W < 32; ) + y.lens[W++] = 5; + mr(fi, y.lens, 0, 32, jr, 0, y.work, { bits: 5 }), Wi = !1; + } + y.lencode = Vr, y.lenbits = 9, y.distcode = jr, y.distbits = 5; + }, Hi = (y, W, O, J) => { + let ie; + const te = y.state; + return te.window === null && (te.wsize = 1 << te.wbits, te.wnext = 0, te.whave = 0, te.window = new Uint8Array(te.wsize)), J >= te.wsize ? (te.window.set(W.subarray(O - te.wsize, O), 0), te.wnext = 0, te.whave = te.wsize) : (ie = te.wsize - te.wnext, ie > J && (ie = J), te.window.set(W.subarray(O - J, O - J + ie), te.wnext), J -= ie, J ? (te.window.set(W.subarray(O - J, O), 0), te.wnext = J, te.whave = te.wsize) : (te.wnext += ie, te.wnext === te.wsize && (te.wnext = 0), te.whave < te.wsize && (te.whave += ie))), 0; + }, us = (y, W) => { + let O, J, ie, te, De, xe, Qe, _e, Pe, ut, Xe, Ge, qe, Ct, ft = 0, st, gt, ot, Ye, _t, St, et, xt; + const ct = new Uint8Array(4); + let nt, ht; + const Xt = ( + /* permutation of code lengths */ + new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]) + ); + if (Yt(y) || !y.output || !y.input && y.avail_in !== 0) + return $t; + O = y.state, O.mode === Ut && (O.mode = Gr), De = y.next_out, ie = y.output, Qe = y.avail_out, te = y.next_in, J = y.input, xe = y.avail_in, _e = O.hold, Pe = O.bits, ut = xe, Xe = Qe, xt = Zt; + e: + for (; ; ) + switch (O.mode) { + case Ar: + if (O.wrap === 0) { + O.mode = Gr; + break; + } + for (; Pe < 16; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (O.wrap & 2 && _e === 35615) { + O.wbits === 0 && (O.wbits = 15), O.check = 0, ct[0] = _e & 255, ct[1] = _e >>> 8 & 255, O.check = I(O.check, ct, 2, 0), _e = 0, Pe = 0, O.mode = pi; + break; + } + if (O.head && (O.head.done = !1), !(O.wrap & 1) || /* check if zlib header allowed */ + (((_e & 255) << 8) + (_e >> 8)) % 31) { + y.msg = "incorrect header check", O.mode = Mt; + break; + } + if ((_e & 15) !== _i) { + y.msg = "unknown compression method", O.mode = Mt; + break; + } + if (_e >>>= 4, Pe -= 4, et = (_e & 15) + 8, O.wbits === 0 && (O.wbits = et), et > 15 || et > O.wbits) { + y.msg = "invalid window size", O.mode = Mt; + break; + } + O.dmax = 1 << O.wbits, O.flags = 0, y.adler = O.check = 1, O.mode = _e & 512 ? wi : Ut, _e = 0, Pe = 0; + break; + case pi: + for (; Pe < 16; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (O.flags = _e, (O.flags & 255) !== _i) { + y.msg = "unknown compression method", O.mode = Mt; + break; + } + if (O.flags & 57344) { + y.msg = "unknown header flags set", O.mode = Mt; + break; + } + O.head && (O.head.text = _e >> 8 & 1), O.flags & 512 && O.wrap & 4 && (ct[0] = _e & 255, ct[1] = _e >>> 8 & 255, O.check = I(O.check, ct, 2, 0)), _e = 0, Pe = 0, O.mode = gi; + case gi: + for (; Pe < 32; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + O.head && (O.head.time = _e), O.flags & 512 && O.wrap & 4 && (ct[0] = _e & 255, ct[1] = _e >>> 8 & 255, ct[2] = _e >>> 16 & 255, ct[3] = _e >>> 24 & 255, O.check = I(O.check, ct, 4, 0)), _e = 0, Pe = 0, O.mode = mi; + case mi: + for (; Pe < 16; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + O.head && (O.head.xflags = _e & 255, O.head.os = _e >> 8), O.flags & 512 && O.wrap & 4 && (ct[0] = _e & 255, ct[1] = _e >>> 8 & 255, O.check = I(O.check, ct, 2, 0)), _e = 0, Pe = 0, O.mode = vi; + case vi: + if (O.flags & 1024) { + for (; Pe < 16; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + O.length = _e, O.head && (O.head.extra_len = _e), O.flags & 512 && O.wrap & 4 && (ct[0] = _e & 255, ct[1] = _e >>> 8 & 255, O.check = I(O.check, ct, 2, 0)), _e = 0, Pe = 0; + } else + O.head && (O.head.extra = null); + O.mode = bi; + case bi: + if (O.flags & 1024 && (Ge = O.length, Ge > xe && (Ge = xe), Ge && (O.head && (et = O.head.extra_len - O.length, O.head.extra || (O.head.extra = new Uint8Array(O.head.extra_len)), O.head.extra.set( + J.subarray( + te, + // extra field is limited to 65536 bytes + // - no need for additional size check + te + Ge + ), + /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ + et + )), O.flags & 512 && O.wrap & 4 && (O.check = I(O.check, J, Ge, te)), xe -= Ge, te += Ge, O.length -= Ge), O.length)) + break e; + O.length = 0, O.mode = yi; + case yi: + if (O.flags & 2048) { + if (xe === 0) + break e; + Ge = 0; + do + et = J[te + Ge++], O.head && et && O.length < 65536 && (O.head.name += String.fromCharCode(et)); + while (et && Ge < xe); + if (O.flags & 512 && O.wrap & 4 && (O.check = I(O.check, J, Ge, te)), xe -= Ge, te += Ge, et) + break e; + } else + O.head && (O.head.name = null); + O.length = 0, O.mode = xi; + case xi: + if (O.flags & 4096) { + if (xe === 0) + break e; + Ge = 0; + do + et = J[te + Ge++], O.head && et && O.length < 65536 && (O.head.comment += String.fromCharCode(et)); + while (et && Ge < xe); + if (O.flags & 512 && O.wrap & 4 && (O.check = I(O.check, J, Ge, te)), xe -= Ge, te += Ge, et) + break e; + } else + O.head && (O.head.comment = null); + O.mode = Ei; + case Ei: + if (O.flags & 512) { + for (; Pe < 16; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (O.wrap & 4 && _e !== (O.check & 65535)) { + y.msg = "header crc mismatch", O.mode = Mt; + break; + } + _e = 0, Pe = 0; + } + O.head && (O.head.hcrc = O.flags >> 9 & 1, O.head.done = !0), y.adler = O.check = 0, O.mode = Ut; + break; + case wi: + for (; Pe < 32; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + y.adler = O.check = Fi(_e), _e = 0, Pe = 0, O.mode = Mr; + case Mr: + if (O.havedict === 0) + return y.next_out = De, y.avail_out = Qe, y.next_in = te, y.avail_in = xe, O.hold = _e, O.bits = Pe, ns; + y.adler = O.check = 1, O.mode = Ut; + case Ut: + if (W === rs || W === wr) + break e; + case Gr: + if (O.last) { + _e >>>= Pe & 7, Pe -= Pe & 7, O.mode = Hr; + break; + } + for (; Pe < 3; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + switch (O.last = _e & 1, _e >>>= 1, Pe -= 1, _e & 3) { + case 0: + O.mode = Ai; + break; + case 1: + if (cs(O), O.mode = Cr, W === wr) { + _e >>>= 2, Pe -= 2; + break e; + } + break; + case 2: + O.mode = Ci; + break; + case 3: + y.msg = "invalid block type", O.mode = Mt; + } + _e >>>= 2, Pe -= 2; + break; + case Ai: + for (_e >>>= Pe & 7, Pe -= Pe & 7; Pe < 32; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if ((_e & 65535) !== (_e >>> 16 ^ 65535)) { + y.msg = "invalid stored block lengths", O.mode = Mt; + break; + } + if (O.length = _e & 65535, _e = 0, Pe = 0, O.mode = Wr, W === wr) + break e; + case Wr: + O.mode = Mi; + case Mi: + if (Ge = O.length, Ge) { + if (Ge > xe && (Ge = xe), Ge > Qe && (Ge = Qe), Ge === 0) + break e; + ie.set(J.subarray(te, te + Ge), De), xe -= Ge, te += Ge, Qe -= Ge, De += Ge, O.length -= Ge; + break; + } + O.mode = Ut; + break; + case Ci: + for (; Pe < 14; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (O.nlen = (_e & 31) + 257, _e >>>= 5, Pe -= 5, O.ndist = (_e & 31) + 1, _e >>>= 5, Pe -= 5, O.ncode = (_e & 15) + 4, _e >>>= 4, Pe -= 4, O.nlen > 286 || O.ndist > 30) { + y.msg = "too many length or distance symbols", O.mode = Mt; + break; + } + O.have = 0, O.mode = Li; + case Li: + for (; O.have < O.ncode; ) { + for (; Pe < 3; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + O.lens[Xt[O.have++]] = _e & 7, _e >>>= 3, Pe -= 3; + } + for (; O.have < 19; ) + O.lens[Xt[O.have++]] = 0; + if (O.lencode = O.lendyn, O.lenbits = 7, nt = { bits: O.lenbits }, xt = mr(ts, O.lens, 0, 19, O.lencode, 0, O.work, nt), O.lenbits = nt.bits, xt) { + y.msg = "invalid code lengths set", O.mode = Mt; + break; + } + O.have = 0, O.mode = Si; + case Si: + for (; O.have < O.nlen + O.ndist; ) { + for (; ft = O.lencode[_e & (1 << O.lenbits) - 1], st = ft >>> 24, gt = ft >>> 16 & 255, ot = ft & 65535, !(st <= Pe); ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (ot < 16) + _e >>>= st, Pe -= st, O.lens[O.have++] = ot; + else { + if (ot === 16) { + for (ht = st + 2; Pe < ht; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (_e >>>= st, Pe -= st, O.have === 0) { + y.msg = "invalid bit length repeat", O.mode = Mt; + break; + } + et = O.lens[O.have - 1], Ge = 3 + (_e & 3), _e >>>= 2, Pe -= 2; + } else if (ot === 17) { + for (ht = st + 3; Pe < ht; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + _e >>>= st, Pe -= st, et = 0, Ge = 3 + (_e & 7), _e >>>= 3, Pe -= 3; + } else { + for (ht = st + 7; Pe < ht; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + _e >>>= st, Pe -= st, et = 0, Ge = 11 + (_e & 127), _e >>>= 7, Pe -= 7; + } + if (O.have + Ge > O.nlen + O.ndist) { + y.msg = "invalid bit length repeat", O.mode = Mt; + break; + } + for (; Ge--; ) + O.lens[O.have++] = et; + } + } + if (O.mode === Mt) + break; + if (O.lens[256] === 0) { + y.msg = "invalid code -- missing end-of-block", O.mode = Mt; + break; + } + if (O.lenbits = 9, nt = { bits: O.lenbits }, xt = mr(hi, O.lens, 0, O.nlen, O.lencode, 0, O.work, nt), O.lenbits = nt.bits, xt) { + y.msg = "invalid literal/lengths set", O.mode = Mt; + break; + } + if (O.distbits = 6, O.distcode = O.distdyn, nt = { bits: O.distbits }, xt = mr(fi, O.lens, O.nlen, O.ndist, O.distcode, 0, O.work, nt), O.distbits = nt.bits, xt) { + y.msg = "invalid distances set", O.mode = Mt; + break; + } + if (O.mode = Cr, W === wr) + break e; + case Cr: + O.mode = Lr; + case Lr: + if (xe >= 6 && Qe >= 258) { + y.next_out = De, y.avail_out = Qe, y.next_in = te, y.avail_in = xe, O.hold = _e, O.bits = Pe, Xn(y, Xe), De = y.next_out, ie = y.output, Qe = y.avail_out, te = y.next_in, J = y.input, xe = y.avail_in, _e = O.hold, Pe = O.bits, O.mode === Ut && (O.back = -1); + break; + } + for (O.back = 0; ft = O.lencode[_e & (1 << O.lenbits) - 1], st = ft >>> 24, gt = ft >>> 16 & 255, ot = ft & 65535, !(st <= Pe); ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (gt && !(gt & 240)) { + for (Ye = st, _t = gt, St = ot; ft = O.lencode[St + ((_e & (1 << Ye + _t) - 1) >> Ye)], st = ft >>> 24, gt = ft >>> 16 & 255, ot = ft & 65535, !(Ye + st <= Pe); ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + _e >>>= Ye, Pe -= Ye, O.back += Ye; + } + if (_e >>>= st, Pe -= st, O.back += st, O.length = ot, gt === 0) { + O.mode = Ii; + break; + } + if (gt & 32) { + O.back = -1, O.mode = Ut; + break; + } + if (gt & 64) { + y.msg = "invalid literal/length code", O.mode = Mt; + break; + } + O.extra = gt & 15, O.mode = Ti; + case Ti: + if (O.extra) { + for (ht = O.extra; Pe < ht; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + O.length += _e & (1 << O.extra) - 1, _e >>>= O.extra, Pe -= O.extra, O.back += O.extra; + } + O.was = O.length, O.mode = Oi; + case Oi: + for (; ft = O.distcode[_e & (1 << O.distbits) - 1], st = ft >>> 24, gt = ft >>> 16 & 255, ot = ft & 65535, !(st <= Pe); ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (!(gt & 240)) { + for (Ye = st, _t = gt, St = ot; ft = O.distcode[St + ((_e & (1 << Ye + _t) - 1) >> Ye)], st = ft >>> 24, gt = ft >>> 16 & 255, ot = ft & 65535, !(Ye + st <= Pe); ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + _e >>>= Ye, Pe -= Ye, O.back += Ye; + } + if (_e >>>= st, Pe -= st, O.back += st, gt & 64) { + y.msg = "invalid distance code", O.mode = Mt; + break; + } + O.offset = ot, O.extra = gt & 15, O.mode = Di; + case Di: + if (O.extra) { + for (ht = O.extra; Pe < ht; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + O.offset += _e & (1 << O.extra) - 1, _e >>>= O.extra, Pe -= O.extra, O.back += O.extra; + } + if (O.offset > O.dmax) { + y.msg = "invalid distance too far back", O.mode = Mt; + break; + } + O.mode = Pi; + case Pi: + if (Qe === 0) + break e; + if (Ge = Xe - Qe, O.offset > Ge) { + if (Ge = O.offset - Ge, Ge > O.whave && O.sane) { + y.msg = "invalid distance too far back", O.mode = Mt; + break; + } + Ge > O.wnext ? (Ge -= O.wnext, qe = O.wsize - Ge) : qe = O.wnext - Ge, Ge > O.length && (Ge = O.length), Ct = O.window; + } else + Ct = ie, qe = De - O.offset, Ge = O.length; + Ge > Qe && (Ge = Qe), Qe -= Ge, O.length -= Ge; + do + ie[De++] = Ct[qe++]; + while (--Ge); + O.length === 0 && (O.mode = Lr); + break; + case Ii: + if (Qe === 0) + break e; + ie[De++] = O.length, Qe--, O.mode = Lr; + break; + case Hr: + if (O.wrap) { + for (; Pe < 32; ) { + if (xe === 0) + break e; + xe--, _e |= J[te++] << Pe, Pe += 8; + } + if (Xe -= Qe, y.total_out += Xe, O.total += Xe, O.wrap & 4 && Xe && (y.adler = O.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/ + O.flags ? I(O.check, ie, Xe, De - Xe) : Oe(O.check, ie, Xe, De - Xe)), Xe = Qe, O.wrap & 4 && (O.flags ? _e : Fi(_e)) !== O.check) { + y.msg = "incorrect data check", O.mode = Mt; + break; + } + _e = 0, Pe = 0; + } + O.mode = Ri; + case Ri: + if (O.wrap && O.flags) { + for (; Pe < 32; ) { + if (xe === 0) + break e; + xe--, _e += J[te++] << Pe, Pe += 8; + } + if (O.wrap & 4 && _e !== (O.total & 4294967295)) { + y.msg = "incorrect length check", O.mode = Mt; + break; + } + _e = 0, Pe = 0; + } + O.mode = $i; + case $i: + xt = is; + break e; + case Mt: + xt = ui; + break e; + case Bi: + return di; + case zi: + default: + return $t; + } + return y.next_out = De, y.avail_out = Qe, y.next_in = te, y.avail_in = xe, O.hold = _e, O.bits = Pe, (O.wsize || Xe !== y.avail_out && O.mode < Mt && (O.mode < Hr || W !== ci)) && Hi(y, y.output, y.next_out, Xe - y.avail_out), ut -= y.avail_in, Xe -= y.avail_out, y.total_in += ut, y.total_out += Xe, O.total += Xe, O.wrap & 4 && Xe && (y.adler = O.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/ + O.flags ? I(O.check, ie, Xe, y.next_out - Xe) : Oe(O.check, ie, Xe, y.next_out - Xe)), y.data_type = O.bits + (O.last ? 64 : 0) + (O.mode === Ut ? 128 : 0) + (O.mode === Cr || O.mode === Wr ? 256 : 0), (ut === 0 && Xe === 0 || W === ci) && xt === Zt && (xt = ss), xt; + }, ds = (y) => { + if (Yt(y)) + return $t; + let W = y.state; + return W.window && (W.window = null), y.state = null, Zt; + }, _s = (y, W) => { + if (Yt(y)) + return $t; + const O = y.state; + return O.wrap & 2 ? (O.head = W, W.done = !1, Zt) : $t; + }, ps = (y, W) => { + const O = W.length; + let J, ie, te; + return Yt(y) || (J = y.state, J.wrap !== 0 && J.mode !== Mr) ? $t : J.mode === Mr && (ie = 1, ie = Oe(ie, W, O, 0), ie !== J.check) ? ui : (te = Hi(y, W, O, O), te ? (J.mode = Bi, di) : (J.havedict = 1, Zt)); + }; + var gs = Ui, ms = Ni, vs = ki, bs = fs, ys = Gi, xs = us, Es = ds, ws = _s, As = ps, Ms = "pako inflate (from Nodeca project)", Nt = { + inflateReset: gs, + inflateReset2: ms, + inflateResetKeep: vs, + inflateInit: bs, + inflateInit2: ys, + inflate: xs, + inflateEnd: Es, + inflateGetHeader: ws, + inflateSetDictionary: As, + inflateInfo: Ms + }; + function Cs() { + this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; + } + var Ls = Cs; + const Vi = Object.prototype.toString, { + Z_NO_FLUSH: Ss, + Z_FINISH: Ts, + Z_OK: vr, + Z_STREAM_END: Kr, + Z_NEED_DICT: Zr, + Z_STREAM_ERROR: Os, + Z_DATA_ERROR: ji, + Z_MEM_ERROR: Ds + } = Ee; + function br(y) { + this.options = yr.assign({ + chunkSize: 65536, + windowBits: 15, + to: "" + }, y || {}); + const W = this.options; + W.raw && W.windowBits >= 0 && W.windowBits < 16 && (W.windowBits = -W.windowBits, W.windowBits === 0 && (W.windowBits = -15)), W.windowBits >= 0 && W.windowBits < 16 && !(y && y.windowBits) && (W.windowBits += 32), W.windowBits > 15 && W.windowBits < 48 && (W.windowBits & 15 || (W.windowBits |= 15)), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new ii(), this.strm.avail_out = 0; + let O = Nt.inflateInit2( + this.strm, + W.windowBits + ); + if (O !== vr) + throw new Error(be[O]); + if (this.header = new Ls(), Nt.inflateGetHeader(this.strm, this.header), W.dictionary && (typeof W.dictionary == "string" ? W.dictionary = pr.string2buf(W.dictionary) : Vi.call(W.dictionary) === "[object ArrayBuffer]" && (W.dictionary = new Uint8Array(W.dictionary)), W.raw && (O = Nt.inflateSetDictionary(this.strm, W.dictionary), O !== vr))) + throw new Error(be[O]); + } + br.prototype.push = function(y, W) { + const O = this.strm, J = this.options.chunkSize, ie = this.options.dictionary; + let te, De, xe; + if (this.ended) + return !1; + for (W === ~~W ? De = W : De = W === !0 ? Ts : Ss, Vi.call(y) === "[object ArrayBuffer]" ? O.input = new Uint8Array(y) : O.input = y, O.next_in = 0, O.avail_in = O.input.length; ; ) { + for (O.avail_out === 0 && (O.output = new Uint8Array(J), O.next_out = 0, O.avail_out = J), te = Nt.inflate(O, De), te === Zr && ie && (te = Nt.inflateSetDictionary(O, ie), te === vr ? te = Nt.inflate(O, De) : te === ji && (te = Zr)); O.avail_in > 0 && te === Kr && O.state.wrap > 0 && y[O.next_in] !== 0; ) + Nt.inflateReset(O), te = Nt.inflate(O, De); + switch (te) { + case Os: + case ji: + case Zr: + case Ds: + return this.onEnd(te), this.ended = !0, !1; + } + if (xe = O.avail_out, O.next_out && (O.avail_out === 0 || te === Kr)) + if (this.options.to === "string") { + let Qe = pr.utf8border(O.output, O.next_out), _e = O.next_out - Qe, Pe = pr.buf2string(O.output, Qe); + O.next_out = _e, O.avail_out = J - _e, _e && O.output.set(O.output.subarray(Qe, Qe + _e), 0), this.onData(Pe); + } else + this.onData(O.output.length === O.next_out ? O.output : O.output.subarray(0, O.next_out)); + if (!(te === vr && xe === 0)) { + if (te === Kr) + return te = Nt.inflateEnd(this.strm), this.onEnd(te), this.ended = !0, !0; + if (O.avail_in === 0) + break; + } + } + return !0; + }, br.prototype.onData = function(y) { + this.chunks.push(y); + }, br.prototype.onEnd = function(y) { + y === vr && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = yr.flattenChunks(this.chunks)), this.chunks = [], this.err = y, this.msg = this.strm.msg; + }; + function Yr(y, W) { + const O = new br(W); + if (O.push(y), O.err) + throw O.msg || be[O.err]; + return O.result; + } + function Ps(y, W) { + return W = W || {}, W.raw = !0, Yr(y, W); + } + var Is = br, Rs = Yr, $s = Ps, Bs = Yr, zs = Ee, Fs = { + Inflate: Is, + inflate: Rs, + inflateRaw: $s, + ungzip: Bs, + constants: zs + }; + const { Deflate: ks, deflate: Us, deflateRaw: Ns, gzip: Gs } = Zn, { Inflate: Ws, inflate: Hs, inflateRaw: Vs, ungzip: js } = Fs; + var Ki = ks, Zi = Us, Yi = Ns, Xi = Gs, Qi = Ws, Ji = Hs, qi = Vs, en = js, tn = Ee, Ks = { + Deflate: Ki, + deflate: Zi, + deflateRaw: Yi, + gzip: Xi, + Inflate: Qi, + inflate: Ji, + inflateRaw: qi, + ungzip: en, + constants: tn + }; + } + ) + /******/ + }, __webpack_module_cache__ = {}; + function __webpack_require__(r) { + var e = __webpack_module_cache__[r]; + if (e !== void 0) + return e.exports; + var t = __webpack_module_cache__[r] = { + /******/ + // no module.id needed + /******/ + // no module.loaded needed + /******/ + exports: {} + /******/ + }; + return __webpack_modules__[r].call(t.exports, t, t.exports, __webpack_require__), t.exports; + } + __webpack_require__.n = (r) => { + var e = r && r.__esModule ? ( + /******/ + () => r.default + ) : ( + /******/ + () => r + ); + return __webpack_require__.d(e, { a: e }), e; + }, __webpack_require__.d = (r, e) => { + for (var t in e) + __webpack_require__.o(e, t) && !__webpack_require__.o(r, t) && Object.defineProperty(r, t, { enumerable: !0, get: e[t] }); + }, __webpack_require__.o = (r, e) => Object.prototype.hasOwnProperty.call(r, e), __webpack_require__.r = (r) => { + typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(r, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(r, "__esModule", { value: !0 }); + }, __webpack_require__("./src/index.ts"), __webpack_require__("./src/SurfaceWorker.js"); + var __webpack_exports__ = __webpack_require__("./src/exporter.js"); + return __webpack_exports__; + })() + )); +})(_3Dmol$1); +var _3DmolExports = _3Dmol$1.exports; +const _3Dmol = /* @__PURE__ */ getDefaultExportFromCjs(_3DmolExports), MolecularViewer_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$a, + add_render_callback, + append: append$8, + attr: attr$8, + binding_callbacks: binding_callbacks$3, + create_in_transition, + destroy_each: destroy_each$2, + detach: detach$a, + element: element$7, + ensure_array_like: ensure_array_like$2, + init: init$a, + insert: insert$a, + listen: listen$2, + noop: noop$6, + null_to_empty, + run_all: run_all$3, + safe_not_equal: safe_not_equal$b, + select_option, + select_value, + set_data: set_data$3, + set_input_value: set_input_value$1, + set_style: set_style$3, + space: space$7, + svg_element: svg_element$3, + text: text$3, + toggle_class: toggle_class$5, + transition_in: transition_in$7 +} = window.__gradio__svelte__internal, { onMount: onMount$1 } = window.__gradio__svelte__internal; +function get_each_context$2(r, e, t) { + const s = r.slice(); + return s[53] = e[t], s[54] = e, s[55] = t, s; +} +function get_each_context_1$1(r, e, t) { + const s = r.slice(); + return s[56] = e[t], s[58] = t, s; +} +function get_each_context_2(r, e, t) { + const s = r.slice(); + return s[59] = e[t], s[60] = e, s[61] = t, s; +} +function get_each_context_3(r, e, t) { + const s = r.slice(); + return s[62] = e[t], s; +} +function create_if_block_8$1(r) { + let e, t, s, f, _, x, h, u, E, c, C, b, A, S, n, o, w, p, v, a, l, g, M, L, T, D, R, B, P; + return { + c() { + e = element$7("div"), t = element$7("div"), s = element$7("div"), f = element$7("span"), f.textContent = " ", _ = element$7("span"), x = text$3("Very high ("), h = text$3( + /*confidenceLabel*/ + r[2] + ), u = text$3(" > 90)"), E = space$7(), c = element$7("div"), C = element$7("span"), C.textContent = " ", b = element$7("span"), A = text$3("Confident (90 > "), S = text$3( + /*confidenceLabel*/ + r[2] + ), n = text$3(" > 70)"), o = space$7(), w = element$7("div"), p = element$7("span"), p.textContent = " ", v = element$7("span"), a = text$3("Low (70 > "), l = text$3( + /*confidenceLabel*/ + r[2] + ), g = text$3(" > 50)"), M = space$7(), L = element$7("div"), T = element$7("span"), T.textContent = " ", D = element$7("span"), R = text$3("Very low ("), B = text$3( + /*confidenceLabel*/ + r[2] + ), P = text$3(" < 50)"), attr$8(f, "class", "w-4 h-4 svelte-1ib1ln5"), set_style$3(f, "background-color", "rgb(0, 83, 214)"), attr$8(_, "class", "legendlabel svelte-1ib1ln5"), attr$8(s, "class", "flex space-x-1 py-1 items-center svelte-1ib1ln5"), attr$8(C, "class", "w-4 h-4 svelte-1ib1ln5"), set_style$3(C, "background-color", "rgb(101, 203, 243)"), attr$8(b, "class", "legendlabel svelte-1ib1ln5"), attr$8(c, "class", "flex space-x-1 py-1 items-center svelte-1ib1ln5"), attr$8(p, "class", "w-4 h-4 svelte-1ib1ln5"), set_style$3(p, "background-color", "rgb(255, 219, 19)"), attr$8(v, "class", "legendlabel svelte-1ib1ln5"), attr$8(w, "class", "flex space-x-1 py-1 items-center svelte-1ib1ln5"), attr$8(T, "class", "w-4 h-4 svelte-1ib1ln5"), set_style$3(T, "background-color", "rgb(255, 125, 69)"), attr$8(D, "class", "legendlabel svelte-1ib1ln5"), attr$8(L, "class", "flex space-x-1 py-1 items-center svelte-1ib1ln5"), attr$8(t, "class", "flex text-sm items-center space-x-2 justify-center svelte-1ib1ln5"), attr$8(e, "class", "absolute bottom-0 left-0 z-50 p-2 -mb-2 w-full bg-white svelte-1ib1ln5"); + }, + m(z, F) { + insert$a(z, e, F), append$8(e, t), append$8(t, s), append$8(s, f), append$8(s, _), append$8(_, x), append$8(_, h), append$8(_, u), append$8(t, E), append$8(t, c), append$8(c, C), append$8(c, b), append$8(b, A), append$8(b, S), append$8(b, n), append$8(t, o), append$8(t, w), append$8(w, p), append$8(w, v), append$8(v, a), append$8(v, l), append$8(v, g), append$8(t, M), append$8(t, L), append$8(L, T), append$8(L, D), append$8(D, R), append$8(D, B), append$8(D, P); + }, + p(z, F) { + F[0] & /*confidenceLabel*/ + 4 && set_data$3( + h, + /*confidenceLabel*/ + z[2] + ), F[0] & /*confidenceLabel*/ + 4 && set_data$3( + S, + /*confidenceLabel*/ + z[2] + ), F[0] & /*confidenceLabel*/ + 4 && set_data$3( + l, + /*confidenceLabel*/ + z[2] + ), F[0] & /*confidenceLabel*/ + 4 && set_data$3( + B, + /*confidenceLabel*/ + z[2] + ); + }, + d(z) { + z && detach$a(e); + } + }; +} +function create_if_block_6$1(r) { + let e; + function t(_, x) { + return ( + /*isAnimated*/ + _[10] ? create_else_block$5 : create_if_block_7$1 + ); + } + let s = t(r), f = s(r); + return { + c() { + e = element$7("div"), f.c(), attr$8(e, "class", "absolute z-50 bottom-0 right-0 mr-2 flex divide-x border border-gray-200 mb-2 rounded items-center justify-center svelte-1ib1ln5"); + }, + m(_, x) { + insert$a(_, e, x), f.m(e, null); + }, + p(_, x) { + s === (s = t(_)) && f ? f.p(_, x) : (f.d(1), f = s(_), f && (f.c(), f.m(e, null))); + }, + d(_) { + _ && detach$a(e), f.d(); + } + }; +} +function create_else_block$5(r) { + let e, t, s; + return { + c() { + e = element$7("button"), e.innerHTML = '', attr$8(e, "class", "p-2 svelte-1ib1ln5"), attr$8(e, "title", "Pause"); + }, + m(f, _) { + insert$a(f, e, _), t || (s = listen$2( + e, + "click", + /*toggleAnimation*/ + r[19] + ), t = !0); + }, + p: noop$6, + d(f) { + f && detach$a(e), t = !1, s(); + } + }; +} +function create_if_block_7$1(r) { + let e, t, s; + return { + c() { + e = element$7("button"), e.innerHTML = '', attr$8(e, "class", "p-2 svelte-1ib1ln5"), attr$8(e, "title", "Play"); + }, + m(f, _) { + insert$a(f, e, _), t || (s = listen$2( + e, + "click", + /*toggleAnimation*/ + r[19] + ), t = !0); + }, + p: noop$6, + d(f) { + f && detach$a(e), t = !1, s(); + } + }; +} +function create_if_block_2$1(r) { + let e, t, s, f, _, x, h, u, E, c, C, b, A, S, n, o, w, p = ensure_array_like$2(Object.keys( + /*config*/ + r[0] + )), v = []; + for (let a = 0; a < p.length; a += 1) + v[a] = create_each_block_2(get_each_context_2(r, p, a)); + return { + c() { + e = element$7("div"), t = element$7("div"), s = element$7("h5"), s.textContent = "Settings", f = space$7(), _ = element$7("button"), _.innerHTML = ' Close menu', x = space$7(); + for (let a = 0; a < v.length; a += 1) + v[a].c(); + h = space$7(), u = element$7("div"), E = element$7("div"), c = element$7("label"), c.textContent = "Label atoms on hover", C = space$7(), b = element$7("label"), A = element$7("input"), S = space$7(), n = element$7("div"), attr$8(s, "id", "settings-drawer-label"), attr$8(s, "class", "inline-flex items-center mb-4 text-base font-semibold text-gray-500 dark:text-gray-400 svelte-1ib1ln5"), attr$8(_, "type", "button"), attr$8(_, "data-drawer-hide", "drawer-example"), attr$8(_, "aria-controls", "drawer-example"), attr$8(_, "class", "text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 absolute top-2.5 right-2.5 inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white svelte-1ib1ln5"), attr$8(t, "class", "p-4 svelte-1ib1ln5"), attr$8(c, "class", "text-sm font-medium text-gray-600 dark:text-gray-400 w-1/2 svelte-1ib1ln5"), attr$8(A, "type", "checkbox"), attr$8(A, "class", "sr-only peer svelte-1ib1ln5"), attr$8(n, "class", "w-11 h-6 bg-gray-200 rounded-full peer dark:bg-gray-700 peer-focus:ring-4 peer-focus:ring-orange-300 dark:peer-focus:ring-orange-800 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-orange-400 svelte-1ib1ln5"), attr$8(b, "class", "relative inline-flex items-center mr-5 cursor-pointer text-center justify-center svelte-1ib1ln5"), attr$8(E, "class", "flex items-center border-t border-b border-gray-200 bg-white px-4 py-2 space-x-2 svelte-1ib1ln5"), attr$8(u, "class", "bg-white svelte-1ib1ln5"), attr$8(e, "id", "settings-drawer"), attr$8(e, "class", "absolute top-0 right-0 z-50 h-full overflow-y-auto transition-transform bg-gray-100 w-80 dark:bg-gray-800 svelte-1ib1ln5"), attr$8(e, "tabindex", "-1"), attr$8(e, "aria-labelledby", "settings-drawer-label"); + }, + m(a, l) { + insert$a(a, e, l), append$8(e, t), append$8(t, s), append$8(t, f), append$8(t, _), append$8(e, x); + for (let g = 0; g < v.length; g += 1) + v[g] && v[g].m(e, null); + append$8(e, h), append$8(e, u), append$8(u, E), append$8(E, c), append$8(E, C), append$8(E, b), append$8(b, A), set_input_value$1( + A, + /*labelHover*/ + r[5] + ), append$8(b, S), append$8(b, n), o || (w = [ + listen$2( + _, + "click", + /*toggleOffCanvas*/ + r[14] + ), + listen$2( + A, + "change", + /*input_change_handler_1*/ + r[25] + ) + ], o = !0); + }, + p(a, l) { + if (l[0] & /*config, settings*/ + 4097) { + p = ensure_array_like$2(Object.keys( + /*config*/ + a[0] + )); + let g; + for (g = 0; g < p.length; g += 1) { + const M = get_each_context_2(a, p, g); + v[g] ? v[g].p(M, l) : (v[g] = create_each_block_2(M), v[g].c(), v[g].m(e, h)); + } + for (; g < v.length; g += 1) + v[g].d(1); + v.length = p.length; + } + l[0] & /*labelHover*/ + 32 && set_input_value$1( + A, + /*labelHover*/ + a[5] + ); + }, + d(a) { + a && detach$a(e), destroy_each$2(v, a), o = !1, run_all$3(w); + } + }; +} +function create_if_block_5$1(r) { + let e, t, s, f, _, x; + function h() { + r[22].call( + t, + /*setting*/ + r[59] + ); + } + return { + c() { + e = element$7("label"), t = element$7("input"), s = space$7(), f = element$7("div"), attr$8(t, "type", "checkbox"), t.__value = "", set_input_value$1(t, t.__value), attr$8(t, "class", "sr-only peer svelte-1ib1ln5"), attr$8(f, "class", "w-11 h-6 bg-gray-200 rounded-full peer dark:bg-gray-700 peer-focus:ring-4 peer-focus:ring-orange-300 dark:peer-focus:ring-orange-800 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-orange-400 svelte-1ib1ln5"), attr$8(e, "class", "relative inline-flex items-center mr-5 cursor-pointer text-center justify-center svelte-1ib1ln5"); + }, + m(u, E) { + insert$a(u, e, E), append$8(e, t), t.checked = /*config*/ + r[0][ + /*setting*/ + r[59] + ], append$8(e, s), append$8(e, f), _ || (x = listen$2(t, "change", h), _ = !0); + }, + p(u, E) { + r = u, E[0] & /*config, settings*/ + 4097 && (t.checked = /*config*/ + r[0][ + /*setting*/ + r[59] + ]); + }, + d(u) { + u && detach$a(e), _ = !1, x(); + } + }; +} +function create_if_block_4$1(r) { + let e, t, s, f, _, x, h, u, E = ( + /*config*/ + r[0][ + /*setting*/ + r[59] + ] + "" + ), c, C, b; + function A() { + return ( + /*change_handler*/ + r[23]( + /*setting*/ + r[59] + ) + ); + } + return { + c() { + e = element$7("div"), t = element$7("input"), h = space$7(), u = element$7("span"), c = text$3(E), attr$8(t, "id", "medium-range"), attr$8(t, "type", "range"), t.value = s = /*config*/ + r[0][ + /*setting*/ + r[59] + ], attr$8(t, "min", f = /*settings*/ + r[12][ + /*setting*/ + r[59] + ].min), attr$8(t, "max", _ = /*settings*/ + r[12][ + /*setting*/ + r[59] + ].max), attr$8(t, "step", x = /*settings*/ + r[12][ + /*setting*/ + r[59] + ].step), attr$8(t, "class", "w-2/3 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700 svelte-1ib1ln5"), attr$8(u, "class", "w-1/3 text-center text-sm font-medium text-gray-600 dark:text-gray-400 svelte-1ib1ln5"), attr$8(e, "class", "flex items-center svelte-1ib1ln5"); + }, + m(S, n) { + insert$a(S, e, n), append$8(e, t), append$8(e, h), append$8(e, u), append$8(u, c), C || (b = listen$2(t, "change", A), C = !0); + }, + p(S, n) { + r = S, n[0] & /*config, settings*/ + 4097 && s !== (s = /*config*/ + r[0][ + /*setting*/ + r[59] + ]) && (t.value = s), n[0] & /*config, settings*/ + 4097 && f !== (f = /*settings*/ + r[12][ + /*setting*/ + r[59] + ].min) && attr$8(t, "min", f), n[0] & /*config, settings*/ + 4097 && _ !== (_ = /*settings*/ + r[12][ + /*setting*/ + r[59] + ].max) && attr$8(t, "max", _), n[0] & /*config, settings*/ + 4097 && x !== (x = /*settings*/ + r[12][ + /*setting*/ + r[59] + ].step) && attr$8(t, "step", x), n[0] & /*config*/ + 1 && E !== (E = /*config*/ + r[0][ + /*setting*/ + r[59] + ] + "") && set_data$3(c, E); + }, + d(S) { + S && detach$a(e), C = !1, b(); + } + }; +} +function create_if_block_3$1(r) { + let e, t, s, f, _, x, h, u, E = ensure_array_like$2( + /*settings*/ + r[12][ + /*setting*/ + r[59] + ].options + ), c = []; + for (let b = 0; b < E.length; b += 1) + c[b] = create_each_block_3(get_each_context_3(r, E, b)); + function C() { + r[24].call( + _, + /*setting*/ + r[59] + ); + } + return { + c() { + e = element$7("label"), t = text$3("Select style"), f = space$7(), _ = element$7("select"); + for (let b = 0; b < c.length; b += 1) + c[b].c(); + attr$8(e, "for", s = /*setting*/ + r[59]), attr$8(e, "class", "sr-only svelte-1ib1ln5"), attr$8(_, "id", x = /*setting*/ + r[59]), attr$8(_, "class", "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 svelte-1ib1ln5"), /*config*/ + r[0][ + /*setting*/ + r[59] + ] === void 0 && add_render_callback(C); + }, + m(b, A) { + insert$a(b, e, A), append$8(e, t), insert$a(b, f, A), insert$a(b, _, A); + for (let S = 0; S < c.length; S += 1) + c[S] && c[S].m(_, null); + select_option( + _, + /*config*/ + r[0][ + /*setting*/ + r[59] + ], + !0 + ), h || (u = listen$2(_, "change", C), h = !0); + }, + p(b, A) { + if (r = b, A[0] & /*config, settings*/ + 4097 && s !== (s = /*setting*/ + r[59]) && attr$8(e, "for", s), A[0] & /*settings, config*/ + 4097) { + E = ensure_array_like$2( + /*settings*/ + r[12][ + /*setting*/ + r[59] + ].options + ); + let S; + for (S = 0; S < E.length; S += 1) { + const n = get_each_context_3(r, E, S); + c[S] ? c[S].p(n, A) : (c[S] = create_each_block_3(n), c[S].c(), c[S].m(_, null)); + } + for (; S < c.length; S += 1) + c[S].d(1); + c.length = E.length; + } + A[0] & /*config, settings*/ + 4097 && x !== (x = /*setting*/ + r[59]) && attr$8(_, "id", x), A[0] & /*config, settings*/ + 4097 && select_option( + _, + /*config*/ + r[0][ + /*setting*/ + r[59] + ] + ); + }, + d(b) { + b && (detach$a(e), detach$a(f), detach$a(_)), destroy_each$2(c, b), h = !1, u(); + } + }; +} +function create_each_block_3(r) { + let e, t = ( + /*option*/ + r[62] + "" + ), s, f, _; + return { + c() { + e = element$7("option"), s = text$3(t), e.__value = f = /*option*/ + r[62], set_input_value$1(e, e.__value), e.selected = _ = /*option*/ + r[62] == /*config*/ + r[0][ + /*setting*/ + r[59] + ], attr$8(e, "class", "svelte-1ib1ln5"); + }, + m(x, h) { + insert$a(x, e, h), append$8(e, s); + }, + p(x, h) { + h[0] & /*config*/ + 1 && t !== (t = /*option*/ + x[62] + "") && set_data$3(s, t), h[0] & /*config, settings*/ + 4097 && f !== (f = /*option*/ + x[62]) && (e.__value = f, set_input_value$1(e, e.__value)), h[0] & /*config, settings*/ + 4097 && _ !== (_ = /*option*/ + x[62] == /*config*/ + x[0][ + /*setting*/ + x[59] + ]) && (e.selected = _); + }, + d(x) { + x && detach$a(e); + } + }; +} +function create_each_block_2(r) { + let e, t, s, f = ( + /*setting*/ + r[59] + "" + ), _, x, h, u, E, c = ( + /*settings*/ + r[12][ + /*setting*/ + r[59] + ].type == "toggle" && create_if_block_5$1(r) + ), C = ( + /*settings*/ + r[12][ + /*setting*/ + r[59] + ].type == "range" && create_if_block_4$1(r) + ), b = ( + /*settings*/ + r[12][ + /*setting*/ + r[59] + ].type == "select" && create_if_block_3$1(r) + ); + return { + c() { + e = element$7("div"), t = element$7("div"), s = element$7("label"), _ = text$3(f), h = space$7(), c && c.c(), u = space$7(), C && C.c(), E = space$7(), b && b.c(), attr$8(s, "for", x = /*setting*/ + r[59]), attr$8(s, "class", "text-sm font-medium text-gray-600 dark:text-gray-400 w-1/2 svelte-1ib1ln5"), attr$8(t, "class", "flex items-center border-t border-b border-gray-200 bg-white px-4 py-2 space-x-2 svelte-1ib1ln5"), attr$8(e, "class", "flex flex-col mb-4 divide-y svelte-1ib1ln5"); + }, + m(A, S) { + insert$a(A, e, S), append$8(e, t), append$8(t, s), append$8(s, _), append$8(t, h), c && c.m(t, null), append$8(t, u), C && C.m(t, null), append$8(t, E), b && b.m(t, null); + }, + p(A, S) { + S[0] & /*config*/ + 1 && f !== (f = /*setting*/ + A[59] + "") && set_data$3(_, f), S[0] & /*config, settings*/ + 4097 && x !== (x = /*setting*/ + A[59]) && attr$8(s, "for", x), /*settings*/ + A[12][ + /*setting*/ + A[59] + ].type == "toggle" ? c ? c.p(A, S) : (c = create_if_block_5$1(A), c.c(), c.m(t, u)) : c && (c.d(1), c = null), /*settings*/ + A[12][ + /*setting*/ + A[59] + ].type == "range" ? C ? C.p(A, S) : (C = create_if_block_4$1(A), C.c(), C.m(t, E)) : C && (C.d(1), C = null), /*settings*/ + A[12][ + /*setting*/ + A[59] + ].type == "select" ? b ? b.p(A, S) : (b = create_if_block_3$1(A), b.c(), b.m(t, null)) : b && (b.d(1), b = null); + }, + d(A) { + A && detach$a(e), c && c.d(), C && C.d(), b && b.d(); + } + }; +} +function create_if_block$6(r) { + let e, t, s, f, _, x, h, u, E, c, C = ensure_array_like$2( + /*representations*/ + r[1] + ), b = []; + for (let A = 0; A < C.length; A += 1) + b[A] = create_each_block$2(get_each_context$2(r, C, A)); + return { + c() { + e = element$7("div"), t = element$7("div"), s = element$7("h5"), s.textContent = "Representations", f = space$7(), _ = element$7("button"), _.innerHTML = ' Close menu', x = space$7(); + for (let A = 0; A < b.length; A += 1) + b[A].c(); + h = space$7(), u = element$7("button"), u.innerHTML = '
Add representation
', attr$8(s, "id", "drawer-label"), attr$8(s, "class", "inline-flex items-center mb-4 text-base font-semibold text-gray-500 dark:text-gray-400 svelte-1ib1ln5"), attr$8(_, "type", "button"), attr$8(_, "data-drawer-hide", "drawer-example"), attr$8(_, "aria-controls", "drawer-example"), attr$8(_, "class", "text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 absolute top-2.5 right-2.5 inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white svelte-1ib1ln5"), attr$8(t, "class", "p-4 svelte-1ib1ln5"), attr$8(u, "class", "w-full flex text-orange-600 justify-center my-2 text-sm space-x-2 items-center hover:text-gray-600 cursor-pointer svelte-1ib1ln5"), attr$8(e, "id", "drawer-example"), attr$8(e, "class", "absolute top-0 right-0 z-50 h-full overflow-y-auto transition-transform bg-gray-100 w-80 dark:bg-gray-800 border-l border-gray-200 svelte-1ib1ln5"), attr$8(e, "tabindex", "-1"), attr$8(e, "aria-labelledby", "drawer-label"); + }, + m(A, S) { + insert$a(A, e, S), append$8(e, t), append$8(t, s), append$8(t, f), append$8(t, _), append$8(e, x); + for (let n = 0; n < b.length; n += 1) + b[n] && b[n].m(e, null); + append$8(e, h), append$8(e, u), E || (c = [ + listen$2( + _, + "click", + /*toggleOffCanvasReps*/ + r[15] + ), + listen$2( + u, + "click", + /*insertRep*/ + r[17] + ) + ], E = !0); + }, + p(A, S) { + if (S[0] & /*representations, moldata, resetZoom, deleteRep*/ + 327690) { + C = ensure_array_like$2( + /*representations*/ + A[1] + ); + let n; + for (n = 0; n < C.length; n += 1) { + const o = get_each_context$2(A, C, n); + b[n] ? b[n].p(o, S) : (b[n] = create_each_block$2(o), b[n].c(), b[n].m(e, h)); + } + for (; n < b.length; n += 1) + b[n].d(1); + b.length = C.length; + } + }, + d(A) { + A && detach$a(e), destroy_each$2(b, A), E = !1, run_all$3(c); + } + }; +} +function create_if_block_1$5(r) { + let e, t, s, f, _, x, h, u, E, c, C, b, A, S, n, o, w, p, v, a, l, g, M, L, T, D, R, B, P, z, F, N, $, k, G, H, U, V, Q, oe, ee, ne, me, se, fe, Ce, Me, 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, be, Ee, X, le, Le, Ze, Ke, je, Je, Lt, rt, it, tt, Et, lt = ensure_array_like$2( + /*moldata*/ + r[3] + ), wt = []; + for (let pt = 0; pt < lt.length; pt += 1) + wt[pt] = create_each_block_1$1(get_each_context_1$1(r, lt, pt)); + function Pt() { + r[29].call( + s, + /*each_value*/ + r[54], + /*index*/ + r[55] + ); + } + function vt() { + r[30].call( + _, + /*each_value*/ + r[54], + /*index*/ + r[55] + ); + } + function bt() { + r[31].call( + u, + /*each_value*/ + r[54], + /*index*/ + r[55] + ); + } + function mt() { + r[32].call( + c, + /*each_value*/ + r[54], + /*index*/ + r[55] + ); + } + function Tt() { + r[33].call( + n, + /*each_value*/ + r[54], + /*index*/ + r[55] + ); + } + function Ot(...pt) { + return ( + /*change_handler_1*/ + r[34]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55], + ...pt + ) + ); + } + function Ft() { + r[35].call( + B, + /*each_value*/ + r[54], + /*index*/ + r[55] + ); + } + function Qt() { + r[36].call( + U, + /*each_value*/ + r[54], + /*index*/ + r[55] + ); + } + function kt() { + r[37].call( + fe, + /*each_value*/ + r[54], + /*index*/ + r[55] + ); + } + function Jt() { + return ( + /*click_handler_3*/ + r[38]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function qt() { + return ( + /*click_handler_4*/ + r[39]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function er() { + return ( + /*click_handler_5*/ + r[40]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function Ht() { + return ( + /*click_handler_6*/ + r[41]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function tr() { + return ( + /*click_handler_7*/ + r[42]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function lr() { + return ( + /*click_handler_8*/ + r[43]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function Or() { + return ( + /*click_handler_9*/ + r[44]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function Dr() { + return ( + /*click_handler_10*/ + r[45]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function Pr() { + return ( + /*click_handler_11*/ + r[46]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function Ir() { + return ( + /*click_handler_12*/ + r[47]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function at() { + return ( + /*click_handler_13*/ + r[48]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function Bt() { + return ( + /*click_handler_14*/ + r[49]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + return { + c() { + e = element$7("div"), t = element$7("div"), s = element$7("select"); + for (let pt = 0; pt < wt.length; pt += 1) + wt[pt].c(); + f = space$7(), _ = element$7("input"), x = space$7(), h = element$7("div"), u = element$7("input"), E = space$7(), c = element$7("input"), C = space$7(), b = element$7("div"), A = element$7("label"), A.textContent = "Select style", S = space$7(), n = element$7("select"), o = element$7("option"), o.textContent = "Stick", w = element$7("option"), w.textContent = "Cartoon", p = element$7("option"), p.textContent = "Surface", v = text$3(`$ + `), a = element$7("option"), a.textContent = "Sphere", l = space$7(), g = element$7("div"), M = element$7("div"), M.textContent = "Expand selection", L = space$7(), T = element$7("input"), R = space$7(), B = element$7("input"), P = space$7(), z = element$7("div"), z.textContent = "Å", F = space$7(), N = element$7("div"), $ = element$7("div"), k = element$7("span"), k.textContent = "Full residue", G = space$7(), H = element$7("label"), U = element$7("input"), V = space$7(), Q = element$7("div"), oe = space$7(), ee = element$7("div"), ne = element$7("span"), ne.textContent = "Only sidechain", me = space$7(), se = element$7("label"), fe = element$7("input"), Ce = space$7(), Me = element$7("div"), Te = space$7(), ae = element$7("div"), pe = element$7("button"), ke = space$7(), Ue = element$7("button"), Be = space$7(), ue = element$7("button"), ge = space$7(), Se = element$7("button"), He = space$7(), We = element$7("button"), K = space$7(), q = element$7("button"), ve = space$7(), Ie = element$7("button"), Z = space$7(), ce = element$7("div"), Ae = element$7("button"), Fe = text$3("AlphaFold"), Oe = space$7(), j = element$7("button"), $e = text$3("PyMol"), I = space$7(), be = element$7("button"), Ee = text$3("Jmol"), le = space$7(), Le = element$7("button"), Ze = text$3("Chain"), je = space$7(), Je = element$7("button"), Lt = text$3("Spectrum"), attr$8(s, "id", "style"), attr$8(s, "class", "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 svelte-1ib1ln5"), /*rep*/ + r[53].model === void 0 && add_render_callback(Pt), attr$8(_, "type", "text"), attr$8(_, "id", "chain"), attr$8(_, "class", "w-1/2 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 svelte-1ib1ln5"), attr$8(_, "placeholder", "Chain"), attr$8(t, "class", "p-1 flex space-x-1 svelte-1ib1ln5"), attr$8(u, "type", "text"), attr$8(u, "id", "chain"), attr$8(u, "class", "w-1/2 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 svelte-1ib1ln5"), attr$8(u, "placeholder", "Resname"), attr$8(c, "type", "text"), attr$8(c, "id", "residue_range"), attr$8(c, "class", "w-full bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 svelte-1ib1ln5"), attr$8(c, "placeholder", "Residue range"), attr$8(h, "class", "p-1 flex space-x-1 svelte-1ib1ln5"), attr$8(A, "for", "countries"), attr$8(A, "class", "block mb-2 text-sm w-1/3 font-medium text-gray-600 dark:text-white svelte-1ib1ln5"), o.__value = "stick", set_input_value$1(o, o.__value), attr$8(o, "class", "svelte-1ib1ln5"), w.__value = "cartoon", set_input_value$1(w, w.__value), attr$8(w, "class", "svelte-1ib1ln5"), p.__value = "surface", set_input_value$1(p, p.__value), attr$8(p, "class", "svelte-1ib1ln5"), a.__value = "sphere", set_input_value$1(a, a.__value), attr$8(a, "class", "svelte-1ib1ln5"), attr$8(n, "id", "style"), attr$8(n, "class", "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 svelte-1ib1ln5"), /*rep*/ + r[53].style === void 0 && add_render_callback(Tt), attr$8(b, "class", "p-1 flex space-x-1 items-center svelte-1ib1ln5"), attr$8(M, "class", " svelte-1ib1ln5"), attr$8(T, "id", "around"), attr$8(T, "type", "range"), T.value = D = /*rep*/ + r[53].around, attr$8(T, "min", "0"), attr$8(T, "max", "10"), attr$8(T, "step", "0.5"), attr$8(T, "class", "h-2 w-1/3 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700 svelte-1ib1ln5"), attr$8(B, "type", "text"), attr$8(B, "class", "w-8 svelte-1ib1ln5"), attr$8(z, "class", "svelte-1ib1ln5"), attr$8(g, "class", "flex p-1 items-center text-gray-700 space-x-1 text-sm svelte-1ib1ln5"), attr$8(k, "class", "svelte-1ib1ln5"), attr$8(U, "type", "checkbox"), U.__value = "", set_input_value$1(U, U.__value), attr$8(U, "class", "sr-only peer svelte-1ib1ln5"), attr$8(Q, "class", "w-11 h-6 bg-gray-200 rounded-full peer dark:bg-gray-700 peer-focus:ring-4 peer-focus:ring-orange-300 dark:peer-focus:ring-orange-800 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-orange-400 svelte-1ib1ln5"), attr$8(H, "class", "relative inline-flex items-center mr-5 cursor-pointer text-center svelte-1ib1ln5"), attr$8($, "class", "flex space-x-1 w-1/2 svelte-1ib1ln5"), attr$8(ne, "class", "svelte-1ib1ln5"), attr$8(fe, "type", "checkbox"), fe.__value = "", set_input_value$1(fe, fe.__value), attr$8(fe, "class", "sr-only peer svelte-1ib1ln5"), attr$8(Me, "class", "w-11 h-6 bg-gray-200 rounded-full peer dark:bg-gray-700 peer-focus:ring-4 peer-focus:ring-orange-300 dark:peer-focus:ring-orange-800 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-orange-400 svelte-1ib1ln5"), attr$8(se, "class", "relative inline-flex items-center mr-5 cursor-pointer text-center svelte-1ib1ln5"), attr$8(ee, "class", "flex space-x-1 w-1/2 svelte-1ib1ln5"), attr$8(N, "class", "flex p-1 items-center text-gray-700 space-x-1 text-sm svelte-1ib1ln5"), attr$8(pe, "class", we = null_to_empty( + /*rep*/ + r[53].color === "orangeCarbon" ? "bg-orange-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-orange-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5"), attr$8(Ue, "class", Ne = null_to_empty( + /*rep*/ + r[53].color === "redCarbon" ? "bg-red-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-red-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5"), attr$8(ue, "class", ye = null_to_empty( + /*rep*/ + r[53].color === "blackCarbon" ? "bg-black rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-black rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5"), attr$8(Se, "class", ze = null_to_empty( + /*rep*/ + r[53].color === "blueCarbon" ? "bg-blue-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-blue-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5"), attr$8(We, "class", Y = null_to_empty( + /*rep*/ + r[53].color === "grayCarbon" ? "bg-gray-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-gray-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5"), attr$8(q, "class", de = null_to_empty( + /*rep*/ + r[53].color === "greenCarbon" ? "bg-green-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-green-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5"), attr$8(Ie, "class", Re = null_to_empty( + /*rep*/ + r[53].color === "cyanCarbon" ? "bg-cyan-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-cyan-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5"), attr$8(ae, "class", "flex space-x-2 mt-2 svelte-1ib1ln5"), attr$8(Ae, "class", he = null_to_empty( + /*rep*/ + r[53].color === "alphafold" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5"), attr$8(j, "class", Ve = null_to_empty( + /*rep*/ + r[53].color === "default" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5"), attr$8(be, "class", X = null_to_empty( + /*rep*/ + r[53].color === "Jmol" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5"), attr$8(Le, "class", Ke = null_to_empty( + /*rep*/ + r[53].color === "chain" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5"), attr$8(Je, "class", rt = null_to_empty( + /*rep*/ + r[53].color === "spectrum" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5"), attr$8(ce, "class", "flex space-x-2 py-2 text-sm svelte-1ib1ln5"), attr$8(e, "class", "svelte-1ib1ln5"); + }, + m(pt, yt) { + insert$a(pt, e, yt), append$8(e, t), append$8(t, s); + for (let At = 0; At < wt.length; At += 1) + wt[At] && wt[At].m(s, null); + select_option( + s, + /*rep*/ + r[53].model, + !0 + ), append$8(t, f), append$8(t, _), set_input_value$1( + _, + /*rep*/ + r[53].chain + ), append$8(e, x), append$8(e, h), append$8(h, u), set_input_value$1( + u, + /*rep*/ + r[53].resname + ), append$8(h, E), append$8(h, c), set_input_value$1( + c, + /*rep*/ + r[53].residue_range + ), append$8(e, C), append$8(e, b), append$8(b, A), append$8(b, S), append$8(b, n), append$8(n, o), append$8(n, w), append$8(n, p), append$8(n, v), append$8(n, a), select_option( + n, + /*rep*/ + r[53].style, + !0 + ), append$8(e, l), append$8(e, g), append$8(g, M), append$8(g, L), append$8(g, T), append$8(g, R), append$8(g, B), set_input_value$1( + B, + /*rep*/ + r[53].around + ), append$8(g, P), append$8(g, z), append$8(e, F), append$8(e, N), append$8(N, $), append$8($, k), append$8($, G), append$8($, H), append$8(H, U), U.checked = /*rep*/ + r[53].byres, append$8(H, V), append$8(H, Q), append$8(N, oe), append$8(N, ee), append$8(ee, ne), append$8(ee, me), append$8(ee, se), append$8(se, fe), fe.checked = /*rep*/ + r[53].sidechain, append$8(se, Ce), append$8(se, Me), append$8(e, Te), append$8(e, ae), append$8(ae, pe), append$8(ae, ke), append$8(ae, Ue), append$8(ae, Be), append$8(ae, ue), append$8(ae, ge), append$8(ae, Se), append$8(ae, He), append$8(ae, We), append$8(ae, K), append$8(ae, q), append$8(ae, ve), append$8(ae, Ie), append$8(e, Z), append$8(e, ce), append$8(ce, Ae), append$8(Ae, Fe), append$8(ce, Oe), append$8(ce, j), append$8(j, $e), append$8(ce, I), append$8(ce, be), append$8(be, Ee), append$8(ce, le), append$8(ce, Le), append$8(Le, Ze), append$8(ce, je), append$8(ce, Je), append$8(Je, Lt), tt || (Et = [ + listen$2(s, "change", Pt), + listen$2(_, "input", vt), + listen$2(u, "input", bt), + listen$2(c, "input", mt), + listen$2(n, "change", Tt), + listen$2(T, "change", Ot), + listen$2(B, "input", Ft), + listen$2(U, "change", Qt), + listen$2(fe, "change", kt), + listen$2(pe, "click", Jt), + listen$2(Ue, "click", qt), + listen$2(ue, "click", er), + listen$2(Se, "click", Ht), + listen$2(We, "click", tr), + listen$2(q, "click", lr), + listen$2(Ie, "click", Or), + listen$2(Ae, "click", Dr), + listen$2(j, "click", Pr), + listen$2(be, "click", Ir), + listen$2(Le, "click", at), + listen$2(Je, "click", Bt) + ], tt = !0); + }, + p(pt, yt) { + if (r = pt, yt[0] & /*moldata*/ + 8) { + lt = ensure_array_like$2( + /*moldata*/ + r[3] + ); + let At; + for (At = 0; At < lt.length; At += 1) { + const rr = get_each_context_1$1(r, lt, At); + wt[At] ? wt[At].p(rr, yt) : (wt[At] = create_each_block_1$1(rr), wt[At].c(), wt[At].m(s, null)); + } + for (; At < wt.length; At += 1) + wt[At].d(1); + wt.length = lt.length; + } + yt[0] & /*representations*/ + 2 && select_option( + s, + /*rep*/ + r[53].model + ), yt[0] & /*representations*/ + 2 && _.value !== /*rep*/ + r[53].chain && set_input_value$1( + _, + /*rep*/ + r[53].chain + ), yt[0] & /*representations*/ + 2 && u.value !== /*rep*/ + r[53].resname && set_input_value$1( + u, + /*rep*/ + r[53].resname + ), yt[0] & /*representations*/ + 2 && c.value !== /*rep*/ + r[53].residue_range && set_input_value$1( + c, + /*rep*/ + r[53].residue_range + ), yt[0] & /*representations*/ + 2 && select_option( + n, + /*rep*/ + r[53].style + ), yt[0] & /*representations*/ + 2 && D !== (D = /*rep*/ + r[53].around) && (T.value = D), yt[0] & /*representations*/ + 2 && B.value !== /*rep*/ + r[53].around && set_input_value$1( + B, + /*rep*/ + r[53].around + ), yt[0] & /*representations*/ + 2 && (U.checked = /*rep*/ + r[53].byres), yt[0] & /*representations*/ + 2 && (fe.checked = /*rep*/ + r[53].sidechain), yt[0] & /*representations*/ + 2 && we !== (we = null_to_empty( + /*rep*/ + r[53].color === "orangeCarbon" ? "bg-orange-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-orange-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5") && attr$8(pe, "class", we), yt[0] & /*representations*/ + 2 && Ne !== (Ne = null_to_empty( + /*rep*/ + r[53].color === "redCarbon" ? "bg-red-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-red-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5") && attr$8(Ue, "class", Ne), yt[0] & /*representations*/ + 2 && ye !== (ye = null_to_empty( + /*rep*/ + r[53].color === "blackCarbon" ? "bg-black rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-black rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5") && attr$8(ue, "class", ye), yt[0] & /*representations*/ + 2 && ze !== (ze = null_to_empty( + /*rep*/ + r[53].color === "blueCarbon" ? "bg-blue-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-blue-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5") && attr$8(Se, "class", ze), yt[0] & /*representations*/ + 2 && Y !== (Y = null_to_empty( + /*rep*/ + r[53].color === "grayCarbon" ? "bg-gray-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-gray-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5") && attr$8(We, "class", Y), yt[0] & /*representations*/ + 2 && de !== (de = null_to_empty( + /*rep*/ + r[53].color === "greenCarbon" ? "bg-green-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-green-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5") && attr$8(q, "class", de), yt[0] & /*representations*/ + 2 && Re !== (Re = null_to_empty( + /*rep*/ + r[53].color === "cyanCarbon" ? "bg-cyan-600 rounded-full w-8 h-8 border-4 border-gray-300 cursor-pointer" : "bg-cyan-600 rounded-full w-8 h-8 border-4 border-white cursor-pointer" + ) + " svelte-1ib1ln5") && attr$8(Ie, "class", Re), yt[0] & /*representations*/ + 2 && he !== (he = null_to_empty( + /*rep*/ + r[53].color === "alphafold" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5") && attr$8(Ae, "class", he), yt[0] & /*representations*/ + 2 && Ve !== (Ve = null_to_empty( + /*rep*/ + r[53].color === "default" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5") && attr$8(j, "class", Ve), yt[0] & /*representations*/ + 2 && X !== (X = null_to_empty( + /*rep*/ + r[53].color === "Jmol" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5") && attr$8(be, "class", X), yt[0] & /*representations*/ + 2 && Ke !== (Ke = null_to_empty( + /*rep*/ + r[53].color === "chain" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5") && attr$8(Le, "class", Ke), yt[0] & /*representations*/ + 2 && rt !== (rt = null_to_empty( + /*rep*/ + r[53].color === "spectrum" ? "rounded-lg p-1 border border-gray-400 cursor-pointer bg-gray-200" : "rounded-lg p-1 border border-gray-200 cursor-pointer bg-white" + ) + " svelte-1ib1ln5") && attr$8(Je, "class", rt); + }, + i(pt) { + pt && (it || add_render_callback(() => { + it = create_in_transition(e, fade, {}), it.start(); + })); + }, + o: noop$6, + d(pt) { + pt && detach$a(e), destroy_each$2(wt, pt), tt = !1, run_all$3(Et); + } + }; +} +function create_each_block_1$1(r) { + let e, t = ( + /*mol*/ + r[56].name + "" + ), s, f, _; + return { + c() { + e = element$7("option"), s = text$3(t), f = text$3(" #"), _ = text$3( + /*i*/ + r[58] + ), e.__value = /*i*/ + r[58], set_input_value$1(e, e.__value), attr$8(e, "class", "svelte-1ib1ln5"); + }, + m(x, h) { + insert$a(x, e, h), append$8(e, s), append$8(e, f), append$8(e, _); + }, + p(x, h) { + h[0] & /*moldata*/ + 8 && t !== (t = /*mol*/ + x[56].name + "") && set_data$3(s, t); + }, + d(x) { + x && detach$a(e); + } + }; +} +function create_each_block$2(r) { + let e, t, s, f, _, x, h, u, E, c, C, b, A, S, n, o; + function w() { + return ( + /*click_handler*/ + r[26]( + /*rep*/ + r[53], + /*each_value*/ + r[54], + /*index*/ + r[55] + ) + ); + } + function p() { + return ( + /*click_handler_1*/ + r[27]( + /*index*/ + r[55] + ) + ); + } + function v() { + return ( + /*click_handler_2*/ + r[28]( + /*rep*/ + r[53] + ) + ); + } + let a = ( + /*rep*/ + r[53].visible && create_if_block_1$5(r) + ); + return { + c() { + e = element$7("div"), t = element$7("div"), s = element$7("div"), f = element$7("button"), _ = svg_element$3("svg"), x = svg_element$3("path"), u = space$7(), E = element$7("span"), E.textContent = `Representation #${/*index*/ + r[55]}`, c = space$7(), C = element$7("button"), C.innerHTML = '', b = space$7(), A = element$7("button"), A.innerHTML = '', S = space$7(), a && a.c(), attr$8(x, "stroke-linecap", "round"), attr$8(x, "stroke-linejoin", "round"), attr$8(x, "d", "M8.25 4.5l7.5 7.5-7.5 7.5"), attr$8(x, "class", "svelte-1ib1ln5"), attr$8(_, "xmlns", "http://www.w3.org/2000/svg"), attr$8(_, "fill", "none"), attr$8(_, "viewBox", "0 0 24 24"), attr$8(_, "stroke-width", "1.5"), attr$8(_, "stroke", "currentColor"), attr$8(_, "class", h = null_to_empty( + /*rep*/ + r[53].visible ? "transform rotate-90 w-5 h-5 " : "w-5 h-5 " + ) + " svelte-1ib1ln5"), attr$8(E, "class", "svelte-1ib1ln5"), attr$8(f, "class", "flex items-center space-x-2 svelte-1ib1ln5"), attr$8(C, "class", "svelte-1ib1ln5"), attr$8(A, "title", "zoom to selection"), attr$8(A, "class", "svelte-1ib1ln5"), attr$8(s, "class", "flex space-x-2 items-center cursor-pointer p-1 svelte-1ib1ln5"), attr$8(t, "class", " svelte-1ib1ln5"), attr$8(e, "class", "bg-white border-b border-t border-gray-200 py-4 px-2 svelte-1ib1ln5"); + }, + m(l, g) { + insert$a(l, e, g), append$8(e, t), append$8(t, s), append$8(s, f), append$8(f, _), append$8(_, x), append$8(f, u), append$8(f, E), append$8(s, c), append$8(s, C), append$8(s, b), append$8(s, A), append$8(t, S), a && a.m(t, null), n || (o = [ + listen$2(f, "click", w), + listen$2(C, "click", p), + listen$2(A, "click", v) + ], n = !0); + }, + p(l, g) { + r = l, g[0] & /*representations*/ + 2 && h !== (h = null_to_empty( + /*rep*/ + r[53].visible ? "transform rotate-90 w-5 h-5 " : "w-5 h-5 " + ) + " svelte-1ib1ln5") && attr$8(_, "class", h), /*rep*/ + r[53].visible ? a ? (a.p(r, g), g[0] & /*representations*/ + 2 && transition_in$7(a, 1)) : (a = create_if_block_1$5(r), a.c(), transition_in$7(a, 1), a.m(t, null)) : a && (a.d(1), a = null); + }, + d(l) { + l && detach$a(e), a && a.d(), n = !1, run_all$3(o); + } + }; +} +function create_fragment$a(r) { + let e, t, s, f, _, x, h, u, E, c, C, b, A, S, n, o, w, p, v, a, l, g, M = ( + /*anyColorAlphaFold*/ + r[11] && create_if_block_8$1(r) + ), L = ( + /*hasFrames*/ + r[9] && create_if_block_6$1(r) + ), T = ( + /*showOffCanvas*/ + r[7] && create_if_block_2$1(r) + ), D = ( + /*showOffCanvasReps*/ + r[8] && create_if_block$6(r) + ); + return { + c() { + e = element$7("div"), t = element$7("div"), s = element$7("div"), f = element$7("div"), _ = element$7("button"), _.innerHTML = '', x = space$7(), h = element$7("button"), h.innerHTML = '', u = space$7(), E = element$7("button"), E.innerHTML = '', c = space$7(), M && M.c(), C = space$7(), L && L.c(), b = space$7(), A = element$7("div"), S = element$7("button"), S.innerHTML = '', n = space$7(), o = element$7("span"), o.textContent = "Cite 3dmol.js as Rego & Koes, doi:10/gb5g5n", w = space$7(), p = element$7("div"), v = space$7(), T && T.c(), a = space$7(), D && D.c(), attr$8(_, "class", "p-2 svelte-1ib1ln5"), attr$8(_, "title", "Reset View"), attr$8(h, "class", "p-2 svelte-1ib1ln5"), attr$8(h, "title", "Settings"), attr$8(E, "class", "p-2 svelte-1ib1ln5"), attr$8(E, "title", "Representations"), attr$8(f, "class", "absolute z-50 top-0 right-0 mr-2 flex flex-col divide-y border border-gray-200 mt-2 rounded items-center justify-center bg-white dark:bg-gray-800 svelte-1ib1ln5"), attr$8(S, "class", "p-1 svelte-1ib1ln5"), attr$8(S, "title", "How to cite 3Dmol.js"), attr$8(o, "class", "absolute -top-1 left-6 w-max rounded bg-gray-900 px-2 py-1 text-sm font-medium text-gray-50 opacity-0 shadow transition-opacity svelte-1ib1ln5"), toggle_class$5( + o, + "opacity-100", + /*showCiteTooltip*/ + r[6] + ), attr$8(A, "class", "absolute z-50 bottom-0 left-0 ml-2 flex divide-x mb-2 rounded items-center justify-center svelte-1ib1ln5"), attr$8(p, "class", "viewer w-full h-full z-10 svelte-1ib1ln5"), attr$8(s, "class", "gr-block gr-box relative w-full overflow-hidden svelte-1ib1ln5"), attr$8(t, "class", "overflow-hidden flex gap-px w-full h-full flex-wrap svelte-1ib1ln5"), attr$8(e, "class", "bg-white w-full minh svelte-1ib1ln5"); + }, + m(R, B) { + insert$a(R, e, B), append$8(e, t), append$8(t, s), append$8(s, f), append$8(f, _), append$8(f, x), append$8(f, h), append$8(f, u), append$8(f, E), append$8(s, c), M && M.m(s, null), append$8(s, C), L && L.m(s, null), append$8(s, b), append$8(s, A), append$8(A, S), append$8(A, n), append$8(A, o), append$8(s, w), append$8(s, p), r[21](p), append$8(s, v), T && T.m(s, null), append$8(s, a), D && D.m(s, null), l || (g = [ + listen$2( + _, + "click", + /*resetZoom*/ + r[18] + ), + listen$2( + h, + "click", + /*toggleOffCanvas*/ + r[14] + ), + listen$2( + E, + "click", + /*toggleOffCanvasReps*/ + r[15] + ), + listen$2( + S, + "click", + /*toggleCiteTooltip*/ + r[13] + ) + ], l = !0); + }, + p(R, B) { + /*anyColorAlphaFold*/ + R[11] ? M ? M.p(R, B) : (M = create_if_block_8$1(R), M.c(), M.m(s, C)) : M && (M.d(1), M = null), /*hasFrames*/ + R[9] ? L ? L.p(R, B) : (L = create_if_block_6$1(R), L.c(), L.m(s, b)) : L && (L.d(1), L = null), B[0] & /*showCiteTooltip*/ + 64 && toggle_class$5( + o, + "opacity-100", + /*showCiteTooltip*/ + R[6] + ), /*showOffCanvas*/ + R[7] ? T ? T.p(R, B) : (T = create_if_block_2$1(R), T.c(), T.m(s, a)) : T && (T.d(1), T = null), /*showOffCanvasReps*/ + R[8] ? D ? D.p(R, B) : (D = create_if_block$6(R), D.c(), D.m(s, null)) : D && (D.d(1), D = null); + }, + i: noop$6, + o: noop$6, + d(R) { + R && detach$a(e), M && M.d(), L && L.d(), r[21](null), T && T.d(), D && D.d(), l = !1, run_all$3(g); + } + }; +} +function fade(r, { delay: e = 0, duration: t = 50 }) { + const s = +getComputedStyle(r).opacity; + return { + delay: e, + duration: t, + css: (f) => `opacity: ${f * s}` + }; +} +function instance$9(r, e, t) { + let s = _3Dmol, f, { confidenceLabel: _ = null } = e, { moldata: x = null } = e, h = { + backgroundColor: { + type: "select", + options: ["white", "black", "gray", "lightgray", "beige", "orange"] + }, + orthographic: { type: "toggle" }, + disableFog: { type: "toggle" } + }, { config: u = {} } = e, E = !0, c = !1; + function C() { + t(6, c = !c); + } + let { representations: b = [] } = e, A = !1, S = !1; + function n() { + t(7, A = !A); + } + function o() { + t(8, S = !S); + } + function w(ue) { + b.splice(ue, 1), t(1, b); + } + function p() { + b.push({ + model: 0, + chain: "", + resname: "", + style: "cartoon", + color: "grayCarbon", + residue_range: "", + around: 0, + byres: !1, + visible: !0 + }), t(1, b); + } + let v = function(ue) { + return ue.b < 50 ? "OrangeRed" : ue.b < 70 ? "Gold" : ue.b < 90 ? "MediumTurquoise" : "Blue"; + }, a; + function l(ue) { + if (ue.type != null) + a.zoomTo(); + else { + let ye = { model: ue.model }; + ue.chain !== "" && (ye.chain = ue.chain), ue.residue_range !== "" && (ye.resi = ue.residue_range), ue.resname !== "" && (ye.resn = ue.resname), a.zoomTo(ye); + } + } + function g(ue) { + a !== void 0 && (a.setStyle(), a.removeAllSurfaces(), ue.forEach((ye) => { + let ge; + ye.color === "alphafold" ? ge = { colorfunc: v } : ye.color == "spectrum" ? ge = { color: "spectrum" } : ge = { colorscheme: ye.color }; + let Se = { model: ye.model }; + if (ye.chain !== "" && (Se.chain = ye.chain), ye.residue_range !== "" && (Se.resi = ye.residue_range), ye.resname !== "" && (Se.resn = ye.resname), Se.byres = ye.byres, ye.around !== 0 && (Se.expand = ye.around), ye.sidechain && (Se = { + and: [Se, { atom: ["N", "C", "O"], invert: !0 }] + }), ye.style === "surface") + ge.opacity = 0.8, a.addSurface(s.SurfaceType.VDW, ge, Se); + else + try { + a.getModel(Se.model) != null && a.addStyle(Se, { [ye.style]: ge }); + } catch (ze) { + console.log(ze); + } + }), a.render()); + } + onMount$1(() => { + let ue = { ...u, cartoonQuality: 7 }; + t(20, a = s.createViewer(f, ue)); + let ye = []; + b.forEach((ge) => { + ye.some((Se) => Se.model === ge.model && Se.chain === ge.chain && Se.resname === ge.resname && Se.style === ge.style && Se.color === ge.color && Se.residue_range === ge.residue_range && Se.around === ge.around && Se.byres === ge.byres && Se.sidechain === ge.sidechain) || ye.push(ge); + }), t(1, b = ye), x.length > 0 && x.forEach((ge) => { + ge.asFrames ? a.addModelsAsFrames(ge.data, ge.format) : a.addModel(ge.data, ge.format); + }), g(b), a.zoomTo(), a.render(), a.zoom(0.8, 2e3), b.forEach((ge) => { + ge.color === "alphafold" && t(11, T = !0); + }), E && a.setHoverable( + {}, + !0, + function(ge, Se, ze, He) { + if (!ge.label) { + let We; + T ? We = ge.resn + ":" + ge.resi + ":" + ge.atom + " (" + _ + " " + ge.b + ")" : We = ge.resn + ":" + ge.resi + ":" + ge.atom, ge.label = Se.addLabel(We, { + position: ge, + backgroundColor: "#ffffff", + borderColor: "#dddddd", + fontColor: "black" + }); + } + }, + function(ge, Se) { + ge.label && (Se.removeLabel(ge.label), delete ge.label); + } + ); + }); + let M = !1, L = !1, T = !1; + function D() { + console.log(a.isAnimated()), L ? a.pauseAnimate() : a.animate({ loop: "forward", reps: 0 }), a.render(), console.log(a.isAnimated()), t(10, L = !L); + } + function R(ue) { + binding_callbacks$3[ue ? "unshift" : "push"](() => { + f = ue, t(4, f); + }); + } + function B(ue) { + u[ue] = this.checked, t(0, u), t(12, h); + } + const P = (ue) => { + t(0, u[ue] = event.target.value, u); + }; + function z(ue) { + u[ue] = select_value(this), t(0, u), t(12, h); + } + function F() { + E = this.value, t(5, E); + } + const N = (ue, ye, ge) => t(1, ye[ge].visible = !ue.visible, b), $ = (ue) => w(ue), k = (ue) => l(ue); + function G(ue, ye) { + ue[ye].model = select_value(this), t(1, b); + } + function H(ue, ye) { + ue[ye].chain = this.value, t(1, b); + } + function U(ue, ye) { + ue[ye].resname = this.value, t(1, b); + } + function V(ue, ye) { + ue[ye].residue_range = this.value, t(1, b); + } + function Q(ue, ye) { + ue[ye].style = select_value(this), t(1, b); + } + const oe = (ue, ye, ge, Se) => { + t(1, ye[ge].around = Se.target.value, b); + }; + function ee(ue, ye) { + ue[ye].around = this.value, t(1, b); + } + function ne(ue, ye) { + ue[ye].byres = this.checked, t(1, b); + } + function me(ue, ye) { + ue[ye].sidechain = this.checked, t(1, b); + } + const se = (ue, ye, ge) => t(1, ye[ge].color = "orangeCarbon", b), fe = (ue, ye, ge) => t(1, ye[ge].color = "redCarbon", b), Ce = (ue, ye, ge) => t(1, ye[ge].color = "blackCarbon", b), Me = (ue, ye, ge) => t(1, ye[ge].color = "blueCarbon", b), Te = (ue, ye, ge) => t(1, ye[ge].color = "grayCarbon", b), ae = (ue, ye, ge) => t(1, ye[ge].color = "greenCarbon", b), pe = (ue, ye, ge) => t(1, ye[ge].color = "cyanCarbon", b), we = (ue, ye, ge) => t(1, ye[ge].color = "alphafold", b), ke = (ue, ye, ge) => t(1, ye[ge].color = "default", b), Ue = (ue, ye, ge) => t(1, ye[ge].color = "Jmol", b), Ne = (ue, ye, ge) => t(1, ye[ge].color = "chain", b), Be = (ue, ye, ge) => t(1, ye[ge].color = "spectrum", b); + return r.$$set = (ue) => { + "confidenceLabel" in ue && t(2, _ = ue.confidenceLabel), "moldata" in ue && t(3, x = ue.moldata), "config" in ue && t(0, u = ue.config), "representations" in ue && t(1, b = ue.representations); + }, r.$$.update = () => { + r.$$.dirty[0] & /*view, config*/ + 1048577 && a != null && (a.setBackgroundColor(u.backgroundColor), a.enableFog(!u.disableFog), a.setCameraParameters({ orthographic: u.orthographic })), r.$$.dirty[0] & /*representations*/ + 2 && g(b), r.$$.dirty[0] & /*moldata*/ + 8 && x.forEach((ue) => { + ue.asFrames && t(9, M = !0); + }), r.$$.dirty[0] & /*representations*/ + 2 && (t(11, T = !1), b.forEach((ue) => { + ue.color === "alphafold" && t(11, T = !0); + })); + }, [ + u, + b, + _, + x, + f, + E, + c, + A, + S, + M, + L, + T, + h, + C, + n, + o, + w, + p, + l, + D, + a, + R, + B, + P, + z, + F, + N, + $, + k, + G, + H, + U, + V, + Q, + oe, + ee, + ne, + me, + se, + fe, + Ce, + Me, + Te, + ae, + pe, + we, + ke, + Ue, + Ne, + Be + ]; +} +class MolecularViewer extends SvelteComponent$a { + constructor(e) { + super(), init$a( + this, + e, + instance$9, + create_fragment$a, + safe_not_equal$b, + { + confidenceLabel: 2, + moldata: 3, + config: 0, + representations: 1 + }, + null, + [-1, -1, -1] + ); + } +} +const { + SvelteComponent: SvelteComponent$9, + bubble: bubble$2, + check_outros: check_outros$5, + create_component: create_component$5, + destroy_component: destroy_component$5, + detach: detach$9, + empty: empty$3, + group_outros: group_outros$5, + init: init$9, + insert: insert$9, + mount_component: mount_component$5, + safe_not_equal: safe_not_equal$a, + space: space$6, + transition_in: transition_in$6, + transition_out: transition_out$6 +} = window.__gradio__svelte__internal; +function create_else_block$4(r) { + let e, t; + return e = new Empty({ + props: { + unpadded_box: !0, + size: "large", + $$slots: { default: [create_default_slot$2] }, + $$scope: { ctx: r } + } + }), { + c() { + create_component$5(e.$$.fragment); + }, + m(s, f) { + mount_component$5(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f & /*$$scope*/ + 4096 && (_.$$scope = { dirty: f, ctx: s }), e.$set(_); + }, + i(s) { + t || (transition_in$6(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out$6(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component$5(e, s); + } + }; +} +function create_if_block$5(r) { + let e, t, s, f; + e = new FilePreview({ + props: { + i18n: ( + /*i18n*/ + r[5] + ), + selectable: ( + /*selectable*/ + r[3] + ), + value: ( + /*value*/ + r[0] + ), + height: ( + /*height*/ + r[4] + ) + } + }), e.$on( + "select", + /*select_handler*/ + r[11] + ); + let _ = ( + /*moldata*/ + r[9] != null && create_if_block_1$4(r) + ); + return { + c() { + create_component$5(e.$$.fragment), t = space$6(), _ && _.c(), s = empty$3(); + }, + m(x, h) { + mount_component$5(e, x, h), insert$9(x, t, h), _ && _.m(x, h), insert$9(x, s, h), f = !0; + }, + p(x, h) { + const u = {}; + h & /*i18n*/ + 32 && (u.i18n = /*i18n*/ + x[5]), h & /*selectable*/ + 8 && (u.selectable = /*selectable*/ + x[3]), h & /*value*/ + 1 && (u.value = /*value*/ + x[0]), h & /*height*/ + 16 && (u.height = /*height*/ + x[4]), e.$set(u), /*moldata*/ + x[9] != null ? _ ? (_.p(x, h), h & /*moldata*/ + 512 && transition_in$6(_, 1)) : (_ = create_if_block_1$4(x), _.c(), transition_in$6(_, 1), _.m(s.parentNode, s)) : _ && (group_outros$5(), transition_out$6(_, 1, 1, () => { + _ = null; + }), check_outros$5()); + }, + i(x) { + f || (transition_in$6(e.$$.fragment, x), transition_in$6(_), f = !0); + }, + o(x) { + transition_out$6(e.$$.fragment, x), transition_out$6(_), f = !1; + }, + d(x) { + x && (detach$9(t), detach$9(s)), destroy_component$5(e, x), _ && _.d(x); + } + }; +} +function create_default_slot$2(r) { + let e, t; + return e = new File$1({}), { + c() { + create_component$5(e.$$.fragment); + }, + m(s, f) { + mount_component$5(e, s, f), t = !0; + }, + i(s) { + t || (transition_in$6(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out$6(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component$5(e, s); + } + }; +} +function create_if_block_1$4(r) { + let e, t; + return e = new MolecularViewer({ + props: { + moldata: ( + /*moldata*/ + r[9] + ), + config: ( + /*config*/ + r[6] + ), + confidenceLabel: ( + /*confidenceLabel*/ + r[7] + ), + representations: ( + /*representations*/ + r[8] + ) + } + }), { + c() { + create_component$5(e.$$.fragment); + }, + m(s, f) { + mount_component$5(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f & /*moldata*/ + 512 && (_.moldata = /*moldata*/ + s[9]), f & /*config*/ + 64 && (_.config = /*config*/ + s[6]), f & /*confidenceLabel*/ + 128 && (_.confidenceLabel = /*confidenceLabel*/ + s[7]), f & /*representations*/ + 256 && (_.representations = /*representations*/ + s[8]), e.$set(_); + }, + i(s) { + t || (transition_in$6(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out$6(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component$5(e, s); + } + }; +} +function create_fragment$9(r) { + let e, t, s, f, _, x; + e = new BlockLabel({ + props: { + show_label: ( + /*show_label*/ + r[2] + ), + float: ( + /*value*/ + r[0] === null + ), + Icon: File$1, + label: ( + /*label*/ + r[1] || "File" + ) + } + }); + const h = [create_if_block$5, create_else_block$4], u = []; + function E(c, C) { + return ( + /*value*/ + c[0] ? 0 : 1 + ); + } + return s = E(r), f = u[s] = h[s](r), { + c() { + create_component$5(e.$$.fragment), t = space$6(), f.c(), _ = empty$3(); + }, + m(c, C) { + mount_component$5(e, c, C), insert$9(c, t, C), u[s].m(c, C), insert$9(c, _, C), x = !0; + }, + p(c, [C]) { + const b = {}; + C & /*show_label*/ + 4 && (b.show_label = /*show_label*/ + c[2]), C & /*value*/ + 1 && (b.float = /*value*/ + c[0] === null), C & /*label*/ + 2 && (b.label = /*label*/ + c[1] || "File"), e.$set(b); + let A = s; + s = E(c), s === A ? u[s].p(c, C) : (group_outros$5(), transition_out$6(u[A], 1, 1, () => { + u[A] = null; + }), check_outros$5(), f = u[s], f ? f.p(c, C) : (f = u[s] = h[s](c), f.c()), transition_in$6(f, 1), f.m(_.parentNode, _)); + }, + i(c) { + x || (transition_in$6(e.$$.fragment, c), transition_in$6(f), x = !0); + }, + o(c) { + transition_out$6(e.$$.fragment, c), transition_out$6(f), x = !1; + }, + d(c) { + c && (detach$9(t), detach$9(_)), destroy_component$5(e, c), u[s].d(c); + } + }; +} +function instance$8(r, e, t) { + let { value: s = null } = e, { label: f } = e, { show_label: _ = !0 } = e, { selectable: x = !1 } = e, { height: h = void 0 } = e, { i18n: u } = e, { config: E = {} } = e, { confidenceLabel: c = "" } = e, { representations: C = [] } = e, { moldata: b = null } = e, { errors: A = [] } = e; + function S(n) { + bubble$2.call(this, r, n); + } + return r.$$set = (n) => { + "value" in n && t(0, s = n.value), "label" in n && t(1, f = n.label), "show_label" in n && t(2, _ = n.show_label), "selectable" in n && t(3, x = n.selectable), "height" in n && t(4, h = n.height), "i18n" in n && t(5, u = n.i18n), "config" in n && t(6, E = n.config), "confidenceLabel" in n && t(7, c = n.confidenceLabel), "representations" in n && t(8, C = n.representations), "moldata" in n && t(9, b = n.moldata), "errors" in n && t(10, A = n.errors); + }, [ + s, + f, + _, + x, + h, + u, + E, + c, + C, + b, + A, + S + ]; +} +class File_1 extends SvelteComponent$9 { + constructor(e) { + super(), init$9(this, e, instance$8, create_fragment$9, safe_not_equal$a, { + value: 0, + label: 1, + show_label: 2, + selectable: 3, + height: 4, + i18n: 5, + config: 6, + confidenceLabel: 7, + representations: 8, + moldata: 9, + errors: 10 + }); + } +} +var fn = new Intl.Collator(0, { numeric: 1 }).compare; +function semiver(r, e, t) { + return r = r.split("."), e = e.split("."), fn(r[0], e[0]) || fn(r[1], e[1]) || (e[2] = e.slice(2).join("."), t = /[.-]/.test(r[2] = r.slice(2).join(".")), t == /[.-]/.test(e[2]) ? fn(r[2], e[2]) : t ? -1 : 1); +} +function resolve_root(r, e, t) { + return e.startsWith("http://") || e.startsWith("https://") ? t ? r : e : r + e; +} +function determine_protocol(r) { + if (r.startsWith("http")) { + const { protocol: e, host: t } = new URL(r); + return t.endsWith("hf.space") ? { + ws_protocol: "wss", + host: t, + http_protocol: e + } : { + ws_protocol: e === "https:" ? "wss" : "ws", + http_protocol: e, + host: t + }; + } else if (r.startsWith("file:")) + return { + ws_protocol: "ws", + http_protocol: "http:", + host: "lite.local" + // Special fake hostname only used for this case. This matches the hostname allowed in `is_self_host()` in `js/wasm/network/host.ts`. + }; + return { + ws_protocol: "wss", + http_protocol: "https:", + host: r + }; +} +const RE_SPACE_NAME = /^[^\/]*\/[^\/]*$/, RE_SPACE_DOMAIN = /.*hf\.space\/{0,1}$/; +async function process_endpoint(r, e) { + const t = {}; + e && (t.Authorization = `Bearer ${e}`); + const s = r.trim(); + if (RE_SPACE_NAME.test(s)) + try { + const f = await fetch( + `https://huggingface.co/api/spaces/${s}/host`, + { headers: t } + ); + if (f.status !== 200) + throw new Error("Space metadata could not be loaded."); + const _ = (await f.json()).host; + return { + space_id: r, + ...determine_protocol(_) + }; + } catch (f) { + throw new Error("Space metadata could not be loaded." + f.message); + } + if (RE_SPACE_DOMAIN.test(s)) { + const { ws_protocol: f, http_protocol: _, host: x } = determine_protocol(s); + return { + space_id: x.replace(".hf.space", ""), + ws_protocol: f, + http_protocol: _, + host: x + }; + } + return { + space_id: !1, + ...determine_protocol(s) + }; +} +function map_names_to_ids(r) { + let e = {}; + return r.forEach(({ api_name: t }, s) => { + t && (e[t] = s); + }), e; +} +const RE_DISABLED_DISCUSSION = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/; +async function discussions_enabled(r) { + try { + const t = (await fetch( + `https://huggingface.co/api/spaces/${r}/discussions`, + { + method: "HEAD" + } + )).headers.get("x-error-message"); + return !(t && RE_DISABLED_DISCUSSION.test(t)); + } catch { + return !1; + } +} +function normalise_file(r, e, t) { + if (r == null) + return null; + if (Array.isArray(r)) { + const s = []; + for (const f of r) + f == null ? s.push(null) : s.push(normalise_file(f, e, t)); + return s; + } + return r.is_stream ? t == null ? new FileData({ + ...r, + url: e + "/stream/" + r.path + }) : new FileData({ + ...r, + url: "/proxy=" + t + "stream/" + r.path + }) : new FileData({ + ...r, + url: get_fetchable_url_or_file(r.path, e, t) + }); +} +function is_url(r) { + try { + const e = new URL(r); + return e.protocol === "http:" || e.protocol === "https:"; + } catch { + return !1; + } +} +function get_fetchable_url_or_file(r, e, t) { + return r == null ? t ? `/proxy=${t}file=` : `${e}/file=` : is_url(r) ? r : t ? `/proxy=${t}file=${r}` : `${e}/file=${r}`; +} +async function upload(r, e, t = upload_files) { + let s = (Array.isArray(r) ? r : [r]).map( + (f) => f.blob + ); + return await Promise.all( + await t(e, s).then( + async (f) => { + if (f.error) + throw new Error(f.error); + return f.files ? f.files.map((_, x) => { + const h = new FileData({ ...r[x], path: _ }); + return normalise_file(h, e, null); + }) : []; + } + ) + ); +} +async function prepare_files(r, e) { + return r.map( + (t, s) => new FileData({ + path: t.name, + orig_name: t.name, + blob: t, + size: t.size, + mime_type: t.type, + is_stream: e + }) + ); +} +class FileData { + constructor({ + path: e, + url: t, + orig_name: s, + size: f, + blob: _, + is_stream: x, + mime_type: h, + alt_text: u + }) { + this.path = e, this.url = t, this.orig_name = s, this.size = f, this.blob = t ? void 0 : _, this.is_stream = x, this.mime_type = h, this.alt_text = u; + } +} +const QUEUE_FULL_MSG = "This application is too busy. Keep trying!", BROKEN_CONNECTION_MSG = "Connection errored out."; +let NodeBlob; +function api_factory(r, e) { + return { post_data: t, upload_files: s, client: f, handle_blob: _ }; + async function t(x, h, u) { + const E = { "Content-Type": "application/json" }; + u && (E.Authorization = `Bearer ${u}`); + try { + var c = await r(x, { + method: "POST", + body: JSON.stringify(h), + headers: E + }); + } catch { + return [{ error: BROKEN_CONNECTION_MSG }, 500]; + } + return [await c.json(), c.status]; + } + async function s(x, h, u) { + const E = {}; + u && (E.Authorization = `Bearer ${u}`); + const c = 1e3, C = []; + for (let A = 0; A < h.length; A += c) { + const S = h.slice(A, A + c), n = new FormData(); + S.forEach((w) => { + n.append("files", w); + }); + try { + var b = await r(`${x}/upload`, { + method: "POST", + body: n, + headers: E + }); + } catch { + return { error: BROKEN_CONNECTION_MSG }; + } + const o = await b.json(); + C.push(...o); + } + return { files: C }; + } + async function f(x, h = { normalise_files: !0 }) { + return new Promise(async (u) => { + const { status_callback: E, hf_token: c, normalise_files: C } = h, b = { + predict: D, + submit: R, + view_api: P, + component_server: B + }, A = C ?? !0; + if ((typeof window > "u" || !("WebSocket" in window)) && !global.Websocket) { + const z = await import("./wrapper-98f94c21-f7f71f53.js"); + NodeBlob = (await import("./__vite-browser-external-2447137e.js")).Blob, global.WebSocket = z.WebSocket; + } + const { ws_protocol: S, http_protocol: n, host: o, space_id: w } = await process_endpoint(x, c), p = Math.random().toString(36).substring(2), v = {}; + let a, l = {}, g = !1; + c && w && (g = await get_jwt(w, c)); + async function M(z) { + if (a = z, l = map_names_to_ids((z == null ? void 0 : z.dependencies) || []), a.auth_required) + return { + config: a, + ...b + }; + try { + L = await P(a); + } catch (F) { + console.error(`Could not get api details: ${F.message}`); + } + return { + config: a, + ...b + }; + } + let L; + async function T(z) { + if (E && E(z), z.status === "running") + try { + a = await resolve_config( + r, + `${n}//${o}`, + c + ); + const F = await M(a); + u(F); + } catch (F) { + console.error(F), E && E({ + status: "error", + message: "Could not load this space.", + load_status: "error", + detail: "NOT_FOUND" + }); + } + } + try { + a = await resolve_config( + r, + `${n}//${o}`, + c + ); + const z = await M(a); + u(z); + } catch (z) { + console.error(z), w ? check_space_status( + w, + RE_SPACE_NAME.test(w) ? "space_name" : "subdomain", + T + ) : E && E({ + status: "error", + message: "Could not load this space.", + load_status: "error", + detail: "NOT_FOUND" + }); + } + function D(z, F, N) { + let $ = !1, k = !1, G; + if (typeof z == "number") + G = a.dependencies[z]; + else { + const H = z.replace(/^\//, ""); + G = a.dependencies[l[H]]; + } + if (G.types.continuous) + throw new Error( + "Cannot call predict on this function as it may run forever. Use submit instead" + ); + return new Promise((H, U) => { + const V = R(z, F, N); + let Q; + V.on("data", (oe) => { + k && (V.destroy(), H(oe)), $ = !0, Q = oe; + }).on("status", (oe) => { + oe.stage === "error" && U(oe), oe.stage === "complete" && (k = !0, $ && (V.destroy(), H(Q))); + }); + }); + } + function R(z, F, N) { + let $, k; + if (typeof z == "number") + $ = z, k = L.unnamed_endpoints[$]; + else { + const ae = z.replace(/^\//, ""); + $ = l[ae], k = L.named_endpoints[z.trim()]; + } + if (typeof $ != "number") + throw new Error( + "There is no endpoint matching that name of fn_index matching that number." + ); + let G, H, U = a.protocol ?? "sse"; + const V = typeof z == "number" ? "/predict" : z; + let Q, oe = null, ee = !1; + const ne = {}; + let me = ""; + typeof window < "u" && (me = new URLSearchParams(window.location.search).toString()), _( + `${n}//${resolve_root(o, a.path, !0)}`, + F, + k, + c + ).then((ae) => { + if (Q = { data: ae || [], event_data: N, fn_index: $ }, skip_queue($, a)) + se({ + type: "status", + endpoint: V, + stage: "pending", + queue: !1, + fn_index: $, + time: /* @__PURE__ */ new Date() + }), t( + `${n}//${resolve_root(o, a.path, !0)}/run${V.startsWith("/") ? V : `/${V}`}${me ? "?" + me : ""}`, + { + ...Q, + session_hash: p + }, + c + ).then(([we, ke]) => { + const Ue = A ? transform_output( + we.data, + k, + a.root, + a.root_url + ) : we.data; + ke == 200 ? (se({ + type: "data", + endpoint: V, + fn_index: $, + data: Ue, + time: /* @__PURE__ */ new Date() + }), se({ + type: "status", + endpoint: V, + fn_index: $, + stage: "complete", + eta: we.average_duration, + queue: !1, + time: /* @__PURE__ */ new Date() + })) : se({ + type: "status", + stage: "error", + endpoint: V, + fn_index: $, + message: we.error, + queue: !1, + time: /* @__PURE__ */ new Date() + }); + }).catch((we) => { + se({ + type: "status", + stage: "error", + message: we.message, + endpoint: V, + fn_index: $, + queue: !1, + time: /* @__PURE__ */ new Date() + }); + }); + else if (U == "ws") { + se({ + type: "status", + stage: "pending", + queue: !0, + endpoint: V, + fn_index: $, + time: /* @__PURE__ */ new Date() + }); + let we = new URL(`${S}://${resolve_root( + o, + a.path, + !0 + )} + /queue/join${me ? "?" + me : ""}`); + g && we.searchParams.set("__sign", g), G = e(we), G.onclose = (ke) => { + ke.wasClean || se({ + type: "status", + stage: "error", + broken: !0, + message: BROKEN_CONNECTION_MSG, + queue: !0, + endpoint: V, + fn_index: $, + time: /* @__PURE__ */ new Date() + }); + }, G.onmessage = function(ke) { + const Ue = JSON.parse(ke.data), { type: Ne, status: Be, data: ue } = handle_message( + Ue, + v[$] + ); + if (Ne === "update" && Be && !ee) + se({ + type: "status", + endpoint: V, + fn_index: $, + time: /* @__PURE__ */ new Date(), + ...Be + }), Be.stage === "error" && G.close(); + else if (Ne === "hash") { + G.send(JSON.stringify({ fn_index: $, session_hash: p })); + return; + } else + Ne === "data" ? G.send(JSON.stringify({ ...Q, session_hash: p })) : Ne === "complete" ? ee = Be : Ne === "log" ? se({ + type: "log", + log: ue.log, + level: ue.level, + endpoint: V, + fn_index: $ + }) : Ne === "generating" && se({ + type: "status", + time: /* @__PURE__ */ new Date(), + ...Be, + stage: Be == null ? void 0 : Be.stage, + queue: !0, + endpoint: V, + fn_index: $ + }); + ue && (se({ + type: "data", + time: /* @__PURE__ */ new Date(), + data: A ? transform_output( + ue.data, + k, + a.root, + a.root_url + ) : ue.data, + endpoint: V, + fn_index: $ + }), ee && (se({ + type: "status", + time: /* @__PURE__ */ new Date(), + ...ee, + stage: Be == null ? void 0 : Be.stage, + queue: !0, + endpoint: V, + fn_index: $ + }), G.close())); + }, semiver(a.version || "2.0.0", "3.6") < 0 && addEventListener( + "open", + () => G.send(JSON.stringify({ hash: p })) + ); + } else { + se({ + type: "status", + stage: "pending", + queue: !0, + endpoint: V, + fn_index: $, + time: /* @__PURE__ */ new Date() + }); + var pe = new URLSearchParams({ + fn_index: $.toString(), + session_hash: p + }).toString(); + let we = new URL( + `${n}//${resolve_root( + o, + a.path, + !0 + )}/queue/join?${pe}` + ); + H = new EventSource(we), H.onmessage = async function(ke) { + const Ue = JSON.parse(ke.data), { type: Ne, status: Be, data: ue } = handle_message( + Ue, + v[$] + ); + if (Ne === "update" && Be && !ee) + se({ + type: "status", + endpoint: V, + fn_index: $, + time: /* @__PURE__ */ new Date(), + ...Be + }), Be.stage === "error" && H.close(); + else if (Ne === "data") { + oe = Ue.event_id; + let [ye, ge] = await t( + `${n}//${resolve_root( + o, + a.path, + !0 + )}/queue/data`, + { + ...Q, + session_hash: p, + event_id: oe + }, + c + ); + ge !== 200 && (se({ + type: "status", + stage: "error", + message: BROKEN_CONNECTION_MSG, + queue: !0, + endpoint: V, + fn_index: $, + time: /* @__PURE__ */ new Date() + }), H.close()); + } else + Ne === "complete" ? ee = Be : Ne === "log" ? se({ + type: "log", + log: ue.log, + level: ue.level, + endpoint: V, + fn_index: $ + }) : Ne === "generating" && se({ + type: "status", + time: /* @__PURE__ */ new Date(), + ...Be, + stage: Be == null ? void 0 : Be.stage, + queue: !0, + endpoint: V, + fn_index: $ + }); + ue && (se({ + type: "data", + time: /* @__PURE__ */ new Date(), + data: A ? transform_output( + ue.data, + k, + a.root, + a.root_url + ) : ue.data, + endpoint: V, + fn_index: $ + }), ee && (se({ + type: "status", + time: /* @__PURE__ */ new Date(), + ...ee, + stage: Be == null ? void 0 : Be.stage, + queue: !0, + endpoint: V, + fn_index: $ + }), H.close())); + }; + } + }); + function se(ae) { + const we = ne[ae.type] || []; + we == null || we.forEach((ke) => ke(ae)); + } + function fe(ae, pe) { + const we = ne, ke = we[ae] || []; + return we[ae] = ke, ke == null || ke.push(pe), { on: fe, off: Ce, cancel: Me, destroy: Te }; + } + function Ce(ae, pe) { + const we = ne; + let ke = we[ae] || []; + return ke = ke == null ? void 0 : ke.filter((Ue) => Ue !== pe), we[ae] = ke, { on: fe, off: Ce, cancel: Me, destroy: Te }; + } + async function Me() { + const ae = { + stage: "complete", + queue: !1, + time: /* @__PURE__ */ new Date() + }; + ee = ae, se({ + ...ae, + type: "status", + endpoint: V, + fn_index: $ + }); + let pe = {}; + U === "ws" ? (G && G.readyState === 0 ? G.addEventListener("open", () => { + G.close(); + }) : G.close(), pe = { fn_index: $, session_hash: p }) : (H.close(), pe = { event_id: oe }); + try { + await r( + `${n}//${resolve_root( + o, + a.path, + !0 + )}/reset`, + { + headers: { "Content-Type": "application/json" }, + method: "POST", + body: JSON.stringify(pe) + } + ); + } catch { + console.warn( + "The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable." + ); + } + } + function Te() { + for (const ae in ne) + ne[ae].forEach((pe) => { + Ce(ae, pe); + }); + } + return { + on: fe, + off: Ce, + cancel: Me, + destroy: Te + }; + } + async function B(z, F, N) { + var $; + const k = { "Content-Type": "application/json" }; + c && (k.Authorization = `Bearer ${c}`); + let G, H = a.components.find( + (Q) => Q.id === z + ); + ($ = H == null ? void 0 : H.props) != null && $.root_url ? G = H.props.root_url : G = `${n}//${resolve_root( + o, + a.path, + !0 + )}/`; + const U = await r( + `${G}component_server/`, + { + method: "POST", + body: JSON.stringify({ + data: N, + component_id: z, + fn_name: F, + session_hash: p + }), + headers: k + } + ); + if (!U.ok) + throw new Error( + "Could not connect to component server: " + U.statusText + ); + return await U.json(); + } + async function P(z) { + if (L) + return L; + const F = { "Content-Type": "application/json" }; + c && (F.Authorization = `Bearer ${c}`); + let N; + if (semiver(z.version || "2.0.0", "3.30") < 0 ? N = await r( + "https://gradio-space-api-fetcher-v2.hf.space/api", + { + method: "POST", + body: JSON.stringify({ + serialize: !1, + config: JSON.stringify(z) + }), + headers: F + } + ) : N = await r(`${z.root}/info`, { + headers: F + }), !N.ok) + throw new Error(BROKEN_CONNECTION_MSG); + let $ = await N.json(); + return "api" in $ && ($ = $.api), $.named_endpoints["/predict"] && !$.unnamed_endpoints[0] && ($.unnamed_endpoints[0] = $.named_endpoints["/predict"]), transform_api_info($, z, l); + } + }); + } + async function _(x, h, u, E) { + const c = await walk_and_store_blobs( + h, + void 0, + [], + !0, + u + ); + return Promise.all( + c.map(async ({ path: C, blob: b, type: A }) => { + if (b) { + const S = (await s(x, [b], E)).files[0]; + return { path: C, file_url: S, type: A, name: b == null ? void 0 : b.name }; + } + return { path: C, type: A }; + }) + ).then((C) => (C.forEach(({ path: b, file_url: A, type: S, name: n }) => { + if (S === "Gallery") + update_object(h, A, b); + else if (A) { + const o = new FileData({ path: A, orig_name: n }); + update_object(h, o, b); + } + }), h)); + } +} +const { post_data, upload_files, client, handle_blob } = api_factory( + fetch, + (...r) => new WebSocket(...r) +); +function transform_output(r, e, t, s) { + return r.map((f, _) => { + var x, h, u, E; + return ((h = (x = e == null ? void 0 : e.returns) == null ? void 0 : x[_]) == null ? void 0 : h.component) === "File" ? normalise_file(f, t, s) : ((E = (u = e == null ? void 0 : e.returns) == null ? void 0 : u[_]) == null ? void 0 : E.component) === "Gallery" ? f.map((c) => Array.isArray(c) ? [normalise_file(c[0], t, s), c[1]] : [normalise_file(c, t, s), null]) : typeof f == "object" && f.path ? normalise_file(f, t, s) : f; + }); +} +function get_type(r, e, t, s) { + switch (r.type) { + case "string": + return "string"; + case "boolean": + return "boolean"; + case "number": + return "number"; + } + if (t === "JSONSerializable" || t === "StringSerializable") + return "any"; + if (t === "ListStringSerializable") + return "string[]"; + if (e === "Image") + return s === "parameter" ? "Blob | File | Buffer" : "string"; + if (t === "FileSerializable") + return (r == null ? void 0 : r.type) === "array" ? s === "parameter" ? "(Blob | File | Buffer)[]" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]" : s === "parameter" ? "Blob | File | Buffer" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}"; + if (t === "GallerySerializable") + return s === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : "[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]"; +} +function get_description(r, e) { + return e === "GallerySerializable" ? "array of [file, label] tuples" : e === "ListStringSerializable" ? "array of strings" : e === "FileSerializable" ? "array of files or single file" : r.description; +} +function transform_api_info(r, e, t) { + const s = { + named_endpoints: {}, + unnamed_endpoints: {} + }; + for (const f in r) { + const _ = r[f]; + for (const x in _) { + const h = e.dependencies[x] ? x : t[x.replace("/", "")], u = _[x]; + s[f][x] = {}, s[f][x].parameters = {}, s[f][x].returns = {}, s[f][x].type = e.dependencies[h].types, s[f][x].parameters = u.parameters.map( + ({ label: E, component: c, type: C, serializer: b }) => ({ + label: E, + component: c, + type: get_type(C, c, b, "parameter"), + description: get_description(C, b) + }) + ), s[f][x].returns = u.returns.map( + ({ label: E, component: c, type: C, serializer: b }) => ({ + label: E, + component: c, + type: get_type(C, c, b, "return"), + description: get_description(C, b) + }) + ); + } + } + return s; +} +async function get_jwt(r, e) { + try { + return (await (await fetch(`https://huggingface.co/api/spaces/${r}/jwt`, { + headers: { + Authorization: `Bearer ${e}` + } + })).json()).token || !1; + } catch (t) { + return console.error(t), !1; + } +} +function update_object(r, e, t) { + for (; t.length > 1; ) + r = r[t.shift()]; + r[t.shift()] = e; +} +async function walk_and_store_blobs(r, e = void 0, t = [], s = !1, f = void 0) { + if (Array.isArray(r)) { + let _ = []; + return await Promise.all( + r.map(async (x, h) => { + var u; + let E = t.slice(); + E.push(h); + const c = await walk_and_store_blobs( + r[h], + s ? ((u = f == null ? void 0 : f.parameters[h]) == null ? void 0 : u.component) || void 0 : e, + E, + !1, + f + ); + _ = _.concat(c); + }) + ), _; + } else { + if (globalThis.Buffer && r instanceof globalThis.Buffer) + return [ + { + path: t, + blob: e === "Image" ? !1 : new NodeBlob([r]), + type: e + } + ]; + if (typeof r == "object") { + let _ = []; + for (let x in r) + if (r.hasOwnProperty(x)) { + let h = t.slice(); + h.push(x), _ = _.concat( + await walk_and_store_blobs( + r[x], + void 0, + h, + !1, + f + ) + ); + } + return _; + } + } + return []; +} +function skip_queue(r, e) { + var t, s, f, _; + return !(((s = (t = e == null ? void 0 : e.dependencies) == null ? void 0 : t[r]) == null ? void 0 : s.queue) === null ? e.enable_queue : (_ = (f = e == null ? void 0 : e.dependencies) == null ? void 0 : f[r]) != null && _.queue) || !1; +} +async function resolve_config(r, e, t) { + const s = {}; + if (t && (s.Authorization = `Bearer ${t}`), typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode) { + const f = window.gradio_config.root, _ = window.gradio_config; + return _.root = resolve_root(e, _.root, !1), { ..._, path: f }; + } else if (e) { + let f = await r(`${e}/config`, { + headers: s + }); + if (f.status === 200) { + const _ = await f.json(); + return _.path = _.path ?? "", _.root = e, _; + } + throw new Error("Could not get config."); + } + throw new Error("No config or app endpoint found"); +} +async function check_space_status(r, e, t) { + let s = e === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${r}` : `https://huggingface.co/api/spaces/${r}`, f, _; + try { + if (f = await fetch(s), _ = f.status, _ !== 200) + throw new Error(); + f = await f.json(); + } catch { + t({ + status: "error", + load_status: "error", + message: "Could not get space status", + detail: "NOT_FOUND" + }); + return; + } + if (!f || _ !== 200) + return; + const { + runtime: { stage: x }, + id: h + } = f; + switch (x) { + case "STOPPED": + case "SLEEPING": + t({ + status: "sleeping", + load_status: "pending", + message: "Space is asleep. Waking it up...", + detail: x + }), setTimeout(() => { + check_space_status(r, e, t); + }, 1e3); + break; + case "PAUSED": + t({ + status: "paused", + load_status: "error", + message: "This space has been paused by the author. If you would like to try this demo, consider duplicating the space.", + detail: x, + discussions_enabled: await discussions_enabled(h) + }); + break; + case "RUNNING": + case "RUNNING_BUILDING": + t({ + status: "running", + load_status: "complete", + message: "", + detail: x + }); + break; + case "BUILDING": + t({ + status: "building", + load_status: "pending", + message: "Space is building...", + detail: x + }), setTimeout(() => { + check_space_status(r, e, t); + }, 1e3); + break; + default: + t({ + status: "space_error", + load_status: "error", + message: "This space is experiencing an issue.", + detail: x, + discussions_enabled: await discussions_enabled(h) + }); + break; + } +} +function handle_message(r, e) { + switch (r.msg) { + case "send_data": + return { type: "data" }; + case "send_hash": + return { type: "hash" }; + case "queue_full": + return { + type: "update", + status: { + queue: !0, + message: QUEUE_FULL_MSG, + stage: "error", + code: r.code, + success: r.success + } + }; + case "estimation": + return { + type: "update", + status: { + queue: !0, + stage: e || "pending", + code: r.code, + size: r.queue_size, + position: r.rank, + eta: r.rank_eta, + success: r.success + } + }; + case "progress": + return { + type: "update", + status: { + queue: !0, + stage: "pending", + code: r.code, + progress_data: r.progress_data, + success: r.success + } + }; + case "log": + return { type: "log", data: r }; + case "process_generating": + return { + type: "generating", + status: { + queue: !0, + message: r.success ? null : r.output.error, + stage: r.success ? "generating" : "error", + code: r.code, + progress_data: r.progress_data, + eta: r.average_duration + }, + data: r.success ? r.output : null + }; + case "process_completed": + return "error" in r.output ? { + type: "update", + status: { + queue: !0, + message: r.output.error, + stage: "error", + code: r.code, + success: r.success + } + } : { + type: "complete", + status: { + queue: !0, + message: r.success ? void 0 : r.output.error, + stage: r.success ? "complete" : "error", + code: r.code, + progress_data: r.progress_data, + eta: r.output.average_duration + }, + data: r.success ? r.output : null + }; + case "process_starts": + return { + type: "update", + status: { + queue: !0, + stage: "pending", + code: r.code, + size: r.rank, + position: 0, + success: r.success + } + }; + } + return { type: "none", status: { stage: "error", queue: !0 } }; +} +function noop$5() { +} +function run(r) { + return r(); +} +function run_all$2(r) { + r.forEach(run); +} +function is_function(r) { + return typeof r == "function"; +} +function safe_not_equal$9(r, e) { + return r != r ? e == e : r !== e || r && typeof r == "object" || typeof r == "function"; +} +function subscribe(r, ...e) { + if (r == null) { + for (const s of e) + s(void 0); + return noop$5; + } + const t = r.subscribe(...e); + return t.unsubscribe ? () => t.unsubscribe() : t; +} +const is_client = typeof window < "u"; +let now = is_client ? () => window.performance.now() : () => Date.now(), raf = is_client ? (r) => requestAnimationFrame(r) : noop$5; +const tasks = /* @__PURE__ */ new Set(); +function run_tasks(r) { + tasks.forEach((e) => { + e.c(r) || (tasks.delete(e), e.f()); + }), tasks.size !== 0 && raf(run_tasks); +} +function loop(r) { + let e; + return tasks.size === 0 && raf(run_tasks), { + promise: new Promise((t) => { + tasks.add(e = { c: r, f: t }); + }), + abort() { + tasks.delete(e); + } + }; +} +const subscriber_queue = []; +function readable(r, e) { + return { + subscribe: writable(r, e).subscribe + }; +} +function writable(r, e = noop$5) { + let t; + const s = /* @__PURE__ */ new Set(); + function f(h) { + if (safe_not_equal$9(r, h) && (r = h, t)) { + const u = !subscriber_queue.length; + for (const E of s) + E[1](), subscriber_queue.push(E, r); + if (u) { + for (let E = 0; E < subscriber_queue.length; E += 2) + subscriber_queue[E][0](subscriber_queue[E + 1]); + subscriber_queue.length = 0; + } + } + } + function _(h) { + f(h(r)); + } + function x(h, u = noop$5) { + const E = [h, u]; + return s.add(E), s.size === 1 && (t = e(f, _) || noop$5), h(r), () => { + s.delete(E), s.size === 0 && t && (t(), t = null); + }; + } + return { set: f, update: _, subscribe: x }; +} +function derived(r, e, t) { + const s = !Array.isArray(r), f = s ? [r] : r; + if (!f.every(Boolean)) + throw new Error("derived() expects stores as input, got a falsy value"); + const _ = e.length < 2; + return readable(t, (x, h) => { + let u = !1; + const E = []; + let c = 0, C = noop$5; + const b = () => { + if (c) + return; + C(); + const S = e(s ? E[0] : E, x, h); + _ ? x(S) : C = is_function(S) ? S : noop$5; + }, A = f.map( + (S, n) => subscribe( + S, + (o) => { + E[n] = o, c &= ~(1 << n), u && b(); + }, + () => { + c |= 1 << n; + } + ) + ); + return u = !0, b(), function() { + run_all$2(A), C(), u = !1; + }; + }); +} +function is_date(r) { + return Object.prototype.toString.call(r) === "[object Date]"; +} +function tick_spring(r, e, t, s) { + if (typeof t == "number" || is_date(t)) { + const f = s - t, _ = (t - e) / (r.dt || 1 / 60), x = r.opts.stiffness * f, h = r.opts.damping * _, u = (x - h) * r.inv_mass, E = (_ + u) * r.dt; + return Math.abs(E) < r.opts.precision && Math.abs(f) < r.opts.precision ? s : (r.settled = !1, is_date(t) ? new Date(t.getTime() + E) : t + E); + } else { + if (Array.isArray(t)) + return t.map( + (f, _) => tick_spring(r, e[_], t[_], s[_]) + ); + if (typeof t == "object") { + const f = {}; + for (const _ in t) + f[_] = tick_spring(r, e[_], t[_], s[_]); + return f; + } else + throw new Error(`Cannot spring ${typeof t} values`); + } +} +function spring(r, e = {}) { + const t = writable(r), { stiffness: s = 0.15, damping: f = 0.8, precision: _ = 0.01 } = e; + let x, h, u, E = r, c = r, C = 1, b = 0, A = !1; + function S(o, w = {}) { + c = o; + const p = u = {}; + return r == null || w.hard || n.stiffness >= 1 && n.damping >= 1 ? (A = !0, x = now(), E = o, t.set(r = c), Promise.resolve()) : (w.soft && (b = 1 / ((w.soft === !0 ? 0.5 : +w.soft) * 60), C = 0), h || (x = now(), A = !1, h = loop((v) => { + if (A) + return A = !1, h = null, !1; + C = Math.min(C + b, 1); + const a = { + inv_mass: C, + opts: n, + settled: !0, + dt: (v - x) * 60 / 1e3 + }, l = tick_spring(a, E, r, c); + return x = v, E = r, t.set(r = l), a.settled && (h = null), !a.settled; + })), new Promise((v) => { + h.promise.then(() => { + p === u && v(); + }); + })); + } + const n = { + set: S, + update: (o, w) => S(o(c, r), w), + subscribe: t.subscribe, + stiffness: s, + damping: f, + precision: _ + }; + return n; +} +var isMergeableObject = function r(e) { + return isNonNullObject(e) && !isSpecial(e); +}; +function isNonNullObject(r) { + return !!r && typeof r == "object"; +} +function isSpecial(r) { + var e = Object.prototype.toString.call(r); + return e === "[object RegExp]" || e === "[object Date]" || isReactElement(r); +} +var canUseSymbol = typeof Symbol == "function" && Symbol.for, REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103; +function isReactElement(r) { + return r.$$typeof === REACT_ELEMENT_TYPE; +} +function emptyTarget(r) { + return Array.isArray(r) ? [] : {}; +} +function cloneUnlessOtherwiseSpecified(r, e) { + return e.clone !== !1 && e.isMergeableObject(r) ? deepmerge(emptyTarget(r), r, e) : r; +} +function defaultArrayMerge(r, e, t) { + return r.concat(e).map(function(s) { + return cloneUnlessOtherwiseSpecified(s, t); + }); +} +function getMergeFunction(r, e) { + if (!e.customMerge) + return deepmerge; + var t = e.customMerge(r); + return typeof t == "function" ? t : deepmerge; +} +function getEnumerableOwnPropertySymbols(r) { + return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(r).filter(function(e) { + return Object.propertyIsEnumerable.call(r, e); + }) : []; +} +function getKeys(r) { + return Object.keys(r).concat(getEnumerableOwnPropertySymbols(r)); +} +function propertyIsOnObject(r, e) { + try { + return e in r; + } catch { + return !1; + } +} +function propertyIsUnsafe(r, e) { + return propertyIsOnObject(r, e) && !(Object.hasOwnProperty.call(r, e) && Object.propertyIsEnumerable.call(r, e)); +} +function mergeObject(r, e, t) { + var s = {}; + return t.isMergeableObject(r) && getKeys(r).forEach(function(f) { + s[f] = cloneUnlessOtherwiseSpecified(r[f], t); + }), getKeys(e).forEach(function(f) { + propertyIsUnsafe(r, f) || (propertyIsOnObject(r, f) && t.isMergeableObject(e[f]) ? s[f] = getMergeFunction(f, t)(r[f], e[f], t) : s[f] = cloneUnlessOtherwiseSpecified(e[f], t)); + }), s; +} +function deepmerge(r, e, t) { + t = t || {}, t.arrayMerge = t.arrayMerge || defaultArrayMerge, t.isMergeableObject = t.isMergeableObject || isMergeableObject, t.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; + var s = Array.isArray(e), f = Array.isArray(r), _ = s === f; + return _ ? s ? t.arrayMerge(r, e, t) : mergeObject(r, e, t) : cloneUnlessOtherwiseSpecified(e, t); +} +deepmerge.all = function r(e, t) { + if (!Array.isArray(e)) + throw new Error("first argument should be an array"); + return e.reduce(function(s, f) { + return deepmerge(s, f, t); + }, {}); +}; +var deepmerge_1 = deepmerge, cjs = deepmerge_1; +const deepmerge$1 = /* @__PURE__ */ getDefaultExportFromCjs(cjs); +var extendStatics = function(r, e) { + return extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, s) { + t.__proto__ = s; + } || function(t, s) { + for (var f in s) + Object.prototype.hasOwnProperty.call(s, f) && (t[f] = s[f]); + }, extendStatics(r, e); +}; +function __extends(r, e) { + if (typeof e != "function" && e !== null) + throw new TypeError("Class extends value " + String(e) + " is not a constructor or null"); + extendStatics(r, e); + function t() { + this.constructor = r; + } + r.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t()); +} +var __assign = function() { + return __assign = Object.assign || function(e) { + for (var t, s = 1, f = arguments.length; s < f; s++) { + t = arguments[s]; + for (var _ in t) + Object.prototype.hasOwnProperty.call(t, _) && (e[_] = t[_]); + } + return e; + }, __assign.apply(this, arguments); +}; +function __spreadArray(r, e, t) { + if (t || arguments.length === 2) + for (var s = 0, f = e.length, _; s < f; s++) + (_ || !(s in e)) && (_ || (_ = Array.prototype.slice.call(e, 0, s)), _[s] = e[s]); + return r.concat(_ || Array.prototype.slice.call(e)); +} +typeof SuppressedError == "function" && SuppressedError; +var ErrorKind; +(function(r) { + r[r.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE", r[r.EMPTY_ARGUMENT = 2] = "EMPTY_ARGUMENT", r[r.MALFORMED_ARGUMENT = 3] = "MALFORMED_ARGUMENT", r[r.EXPECT_ARGUMENT_TYPE = 4] = "EXPECT_ARGUMENT_TYPE", r[r.INVALID_ARGUMENT_TYPE = 5] = "INVALID_ARGUMENT_TYPE", r[r.EXPECT_ARGUMENT_STYLE = 6] = "EXPECT_ARGUMENT_STYLE", r[r.INVALID_NUMBER_SKELETON = 7] = "INVALID_NUMBER_SKELETON", r[r.INVALID_DATE_TIME_SKELETON = 8] = "INVALID_DATE_TIME_SKELETON", r[r.EXPECT_NUMBER_SKELETON = 9] = "EXPECT_NUMBER_SKELETON", r[r.EXPECT_DATE_TIME_SKELETON = 10] = "EXPECT_DATE_TIME_SKELETON", r[r.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE", r[r.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS", r[r.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE", r[r.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE", r[r.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR", r[r.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR", r[r.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT", r[r.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT", r[r.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR", r[r.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR", r[r.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR", r[r.MISSING_OTHER_CLAUSE = 22] = "MISSING_OTHER_CLAUSE", r[r.INVALID_TAG = 23] = "INVALID_TAG", r[r.INVALID_TAG_NAME = 25] = "INVALID_TAG_NAME", r[r.UNMATCHED_CLOSING_TAG = 26] = "UNMATCHED_CLOSING_TAG", r[r.UNCLOSED_TAG = 27] = "UNCLOSED_TAG"; +})(ErrorKind || (ErrorKind = {})); +var TYPE; +(function(r) { + r[r.literal = 0] = "literal", r[r.argument = 1] = "argument", r[r.number = 2] = "number", r[r.date = 3] = "date", r[r.time = 4] = "time", r[r.select = 5] = "select", r[r.plural = 6] = "plural", r[r.pound = 7] = "pound", r[r.tag = 8] = "tag"; +})(TYPE || (TYPE = {})); +var SKELETON_TYPE; +(function(r) { + r[r.number = 0] = "number", r[r.dateTime = 1] = "dateTime"; +})(SKELETON_TYPE || (SKELETON_TYPE = {})); +function isLiteralElement(r) { + return r.type === TYPE.literal; +} +function isArgumentElement(r) { + return r.type === TYPE.argument; +} +function isNumberElement(r) { + return r.type === TYPE.number; +} +function isDateElement(r) { + return r.type === TYPE.date; +} +function isTimeElement(r) { + return r.type === TYPE.time; +} +function isSelectElement(r) { + return r.type === TYPE.select; +} +function isPluralElement(r) { + return r.type === TYPE.plural; +} +function isPoundElement(r) { + return r.type === TYPE.pound; +} +function isTagElement(r) { + return r.type === TYPE.tag; +} +function isNumberSkeleton(r) { + return !!(r && typeof r == "object" && r.type === SKELETON_TYPE.number); +} +function isDateTimeSkeleton(r) { + return !!(r && typeof r == "object" && r.type === SKELETON_TYPE.dateTime); +} +var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g; +function parseDateTimeSkeleton(r) { + var e = {}; + return r.replace(DATE_TIME_REGEX, function(t) { + var s = t.length; + switch (t[0]) { + case "G": + e.era = s === 4 ? "long" : s === 5 ? "narrow" : "short"; + break; + case "y": + e.year = s === 2 ? "2-digit" : "numeric"; + break; + case "Y": + case "u": + case "U": + case "r": + throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead"); + case "q": + case "Q": + throw new RangeError("`q/Q` (quarter) patterns are not supported"); + case "M": + case "L": + e.month = ["numeric", "2-digit", "short", "long", "narrow"][s - 1]; + break; + case "w": + case "W": + throw new RangeError("`w/W` (week) patterns are not supported"); + case "d": + e.day = ["numeric", "2-digit"][s - 1]; + break; + case "D": + case "F": + case "g": + throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead"); + case "E": + e.weekday = s === 4 ? "short" : s === 5 ? "narrow" : "short"; + break; + case "e": + if (s < 4) + throw new RangeError("`e..eee` (weekday) patterns are not supported"); + e.weekday = ["short", "long", "narrow", "short"][s - 4]; + break; + case "c": + if (s < 4) + throw new RangeError("`c..ccc` (weekday) patterns are not supported"); + e.weekday = ["short", "long", "narrow", "short"][s - 4]; + break; + case "a": + e.hour12 = !0; + break; + case "b": + case "B": + throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead"); + case "h": + e.hourCycle = "h12", e.hour = ["numeric", "2-digit"][s - 1]; + break; + case "H": + e.hourCycle = "h23", e.hour = ["numeric", "2-digit"][s - 1]; + break; + case "K": + e.hourCycle = "h11", e.hour = ["numeric", "2-digit"][s - 1]; + break; + case "k": + e.hourCycle = "h24", e.hour = ["numeric", "2-digit"][s - 1]; + break; + case "j": + case "J": + case "C": + throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead"); + case "m": + e.minute = ["numeric", "2-digit"][s - 1]; + break; + case "s": + e.second = ["numeric", "2-digit"][s - 1]; + break; + case "S": + case "A": + throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead"); + case "z": + e.timeZoneName = s < 4 ? "short" : "long"; + break; + case "Z": + case "O": + case "v": + case "V": + case "X": + case "x": + throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead"); + } + return ""; + }), e; +} +var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i; +function parseNumberSkeletonFromString(r) { + if (r.length === 0) + throw new Error("Number skeleton cannot be empty"); + for (var e = r.split(WHITE_SPACE_REGEX).filter(function(b) { + return b.length > 0; + }), t = [], s = 0, f = e; s < f.length; s++) { + var _ = f[s], x = _.split("/"); + if (x.length === 0) + throw new Error("Invalid number skeleton"); + for (var h = x[0], u = x.slice(1), E = 0, c = u; E < c.length; E++) { + var C = c[E]; + if (C.length === 0) + throw new Error("Invalid number skeleton"); + } + t.push({ stem: h, options: u }); + } + return t; +} +function icuUnitToEcma(r) { + return r.replace(/^(.*?)-/, ""); +} +var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g, INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g, CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/; +function parseSignificantPrecision(r) { + var e = {}; + return r[r.length - 1] === "r" ? e.roundingPriority = "morePrecision" : r[r.length - 1] === "s" && (e.roundingPriority = "lessPrecision"), r.replace(SIGNIFICANT_PRECISION_REGEX, function(t, s, f) { + return typeof f != "string" ? (e.minimumSignificantDigits = s.length, e.maximumSignificantDigits = s.length) : f === "+" ? e.minimumSignificantDigits = s.length : s[0] === "#" ? e.maximumSignificantDigits = s.length : (e.minimumSignificantDigits = s.length, e.maximumSignificantDigits = s.length + (typeof f == "string" ? f.length : 0)), ""; + }), e; +} +function parseSign(r) { + switch (r) { + case "sign-auto": + return { + signDisplay: "auto" + }; + case "sign-accounting": + case "()": + return { + currencySign: "accounting" + }; + case "sign-always": + case "+!": + return { + signDisplay: "always" + }; + case "sign-accounting-always": + case "()!": + return { + signDisplay: "always", + currencySign: "accounting" + }; + case "sign-except-zero": + case "+?": + return { + signDisplay: "exceptZero" + }; + case "sign-accounting-except-zero": + case "()?": + return { + signDisplay: "exceptZero", + currencySign: "accounting" + }; + case "sign-never": + case "+_": + return { + signDisplay: "never" + }; + } +} +function parseConciseScientificAndEngineeringStem(r) { + var e; + if (r[0] === "E" && r[1] === "E" ? (e = { + notation: "engineering" + }, r = r.slice(2)) : r[0] === "E" && (e = { + notation: "scientific" + }, r = r.slice(1)), e) { + var t = r.slice(0, 2); + if (t === "+!" ? (e.signDisplay = "always", r = r.slice(2)) : t === "+?" && (e.signDisplay = "exceptZero", r = r.slice(2)), !CONCISE_INTEGER_WIDTH_REGEX.test(r)) + throw new Error("Malformed concise eng/scientific notation"); + e.minimumIntegerDigits = r.length; + } + return e; +} +function parseNotationOptions(r) { + var e = {}, t = parseSign(r); + return t || e; +} +function parseNumberSkeleton(r) { + for (var e = {}, t = 0, s = r; t < s.length; t++) { + var f = s[t]; + switch (f.stem) { + case "percent": + case "%": + e.style = "percent"; + continue; + case "%x100": + e.style = "percent", e.scale = 100; + continue; + case "currency": + e.style = "currency", e.currency = f.options[0]; + continue; + case "group-off": + case ",_": + e.useGrouping = !1; + continue; + case "precision-integer": + case ".": + e.maximumFractionDigits = 0; + continue; + case "measure-unit": + case "unit": + e.style = "unit", e.unit = icuUnitToEcma(f.options[0]); + continue; + case "compact-short": + case "K": + e.notation = "compact", e.compactDisplay = "short"; + continue; + case "compact-long": + case "KK": + e.notation = "compact", e.compactDisplay = "long"; + continue; + case "scientific": + e = __assign(__assign(__assign({}, e), { notation: "scientific" }), f.options.reduce(function(u, E) { + return __assign(__assign({}, u), parseNotationOptions(E)); + }, {})); + continue; + case "engineering": + e = __assign(__assign(__assign({}, e), { notation: "engineering" }), f.options.reduce(function(u, E) { + return __assign(__assign({}, u), parseNotationOptions(E)); + }, {})); + continue; + case "notation-simple": + e.notation = "standard"; + continue; + case "unit-width-narrow": + e.currencyDisplay = "narrowSymbol", e.unitDisplay = "narrow"; + continue; + case "unit-width-short": + e.currencyDisplay = "code", e.unitDisplay = "short"; + continue; + case "unit-width-full-name": + e.currencyDisplay = "name", e.unitDisplay = "long"; + continue; + case "unit-width-iso-code": + e.currencyDisplay = "symbol"; + continue; + case "scale": + e.scale = parseFloat(f.options[0]); + continue; + case "integer-width": + if (f.options.length > 1) + throw new RangeError("integer-width stems only accept a single optional option"); + f.options[0].replace(INTEGER_WIDTH_REGEX, function(u, E, c, C, b, A) { + if (E) + e.minimumIntegerDigits = c.length; + else { + if (C && b) + throw new Error("We currently do not support maximum integer digits"); + if (A) + throw new Error("We currently do not support exact integer digits"); + } + return ""; + }); + continue; + } + if (CONCISE_INTEGER_WIDTH_REGEX.test(f.stem)) { + e.minimumIntegerDigits = f.stem.length; + continue; + } + if (FRACTION_PRECISION_REGEX.test(f.stem)) { + if (f.options.length > 1) + throw new RangeError("Fraction-precision stems only accept a single optional option"); + f.stem.replace(FRACTION_PRECISION_REGEX, function(u, E, c, C, b, A) { + return c === "*" ? e.minimumFractionDigits = E.length : C && C[0] === "#" ? e.maximumFractionDigits = C.length : b && A ? (e.minimumFractionDigits = b.length, e.maximumFractionDigits = b.length + A.length) : (e.minimumFractionDigits = E.length, e.maximumFractionDigits = E.length), ""; + }); + var _ = f.options[0]; + _ === "w" ? e = __assign(__assign({}, e), { trailingZeroDisplay: "stripIfInteger" }) : _ && (e = __assign(__assign({}, e), parseSignificantPrecision(_))); + continue; + } + if (SIGNIFICANT_PRECISION_REGEX.test(f.stem)) { + e = __assign(__assign({}, e), parseSignificantPrecision(f.stem)); + continue; + } + var x = parseSign(f.stem); + x && (e = __assign(__assign({}, e), x)); + var h = parseConciseScientificAndEngineeringStem(f.stem); + h && (e = __assign(__assign({}, e), h)); + } + return e; +} +var timeData = { + AX: [ + "H" + ], + BQ: [ + "H" + ], + CP: [ + "H" + ], + CZ: [ + "H" + ], + DK: [ + "H" + ], + FI: [ + "H" + ], + ID: [ + "H" + ], + IS: [ + "H" + ], + ML: [ + "H" + ], + NE: [ + "H" + ], + RU: [ + "H" + ], + SE: [ + "H" + ], + SJ: [ + "H" + ], + SK: [ + "H" + ], + AS: [ + "h", + "H" + ], + BT: [ + "h", + "H" + ], + DJ: [ + "h", + "H" + ], + ER: [ + "h", + "H" + ], + GH: [ + "h", + "H" + ], + IN: [ + "h", + "H" + ], + LS: [ + "h", + "H" + ], + PG: [ + "h", + "H" + ], + PW: [ + "h", + "H" + ], + SO: [ + "h", + "H" + ], + TO: [ + "h", + "H" + ], + VU: [ + "h", + "H" + ], + WS: [ + "h", + "H" + ], + "001": [ + "H", + "h" + ], + AL: [ + "h", + "H", + "hB" + ], + TD: [ + "h", + "H", + "hB" + ], + "ca-ES": [ + "H", + "h", + "hB" + ], + CF: [ + "H", + "h", + "hB" + ], + CM: [ + "H", + "h", + "hB" + ], + "fr-CA": [ + "H", + "h", + "hB" + ], + "gl-ES": [ + "H", + "h", + "hB" + ], + "it-CH": [ + "H", + "h", + "hB" + ], + "it-IT": [ + "H", + "h", + "hB" + ], + LU: [ + "H", + "h", + "hB" + ], + NP: [ + "H", + "h", + "hB" + ], + PF: [ + "H", + "h", + "hB" + ], + SC: [ + "H", + "h", + "hB" + ], + SM: [ + "H", + "h", + "hB" + ], + SN: [ + "H", + "h", + "hB" + ], + TF: [ + "H", + "h", + "hB" + ], + VA: [ + "H", + "h", + "hB" + ], + CY: [ + "h", + "H", + "hb", + "hB" + ], + GR: [ + "h", + "H", + "hb", + "hB" + ], + CO: [ + "h", + "H", + "hB", + "hb" + ], + DO: [ + "h", + "H", + "hB", + "hb" + ], + KP: [ + "h", + "H", + "hB", + "hb" + ], + KR: [ + "h", + "H", + "hB", + "hb" + ], + NA: [ + "h", + "H", + "hB", + "hb" + ], + PA: [ + "h", + "H", + "hB", + "hb" + ], + PR: [ + "h", + "H", + "hB", + "hb" + ], + VE: [ + "h", + "H", + "hB", + "hb" + ], + AC: [ + "H", + "h", + "hb", + "hB" + ], + AI: [ + "H", + "h", + "hb", + "hB" + ], + BW: [ + "H", + "h", + "hb", + "hB" + ], + BZ: [ + "H", + "h", + "hb", + "hB" + ], + CC: [ + "H", + "h", + "hb", + "hB" + ], + CK: [ + "H", + "h", + "hb", + "hB" + ], + CX: [ + "H", + "h", + "hb", + "hB" + ], + DG: [ + "H", + "h", + "hb", + "hB" + ], + FK: [ + "H", + "h", + "hb", + "hB" + ], + GB: [ + "H", + "h", + "hb", + "hB" + ], + GG: [ + "H", + "h", + "hb", + "hB" + ], + GI: [ + "H", + "h", + "hb", + "hB" + ], + IE: [ + "H", + "h", + "hb", + "hB" + ], + IM: [ + "H", + "h", + "hb", + "hB" + ], + IO: [ + "H", + "h", + "hb", + "hB" + ], + JE: [ + "H", + "h", + "hb", + "hB" + ], + LT: [ + "H", + "h", + "hb", + "hB" + ], + MK: [ + "H", + "h", + "hb", + "hB" + ], + MN: [ + "H", + "h", + "hb", + "hB" + ], + MS: [ + "H", + "h", + "hb", + "hB" + ], + NF: [ + "H", + "h", + "hb", + "hB" + ], + NG: [ + "H", + "h", + "hb", + "hB" + ], + NR: [ + "H", + "h", + "hb", + "hB" + ], + NU: [ + "H", + "h", + "hb", + "hB" + ], + PN: [ + "H", + "h", + "hb", + "hB" + ], + SH: [ + "H", + "h", + "hb", + "hB" + ], + SX: [ + "H", + "h", + "hb", + "hB" + ], + TA: [ + "H", + "h", + "hb", + "hB" + ], + ZA: [ + "H", + "h", + "hb", + "hB" + ], + "af-ZA": [ + "H", + "h", + "hB", + "hb" + ], + AR: [ + "H", + "h", + "hB", + "hb" + ], + CL: [ + "H", + "h", + "hB", + "hb" + ], + CR: [ + "H", + "h", + "hB", + "hb" + ], + CU: [ + "H", + "h", + "hB", + "hb" + ], + EA: [ + "H", + "h", + "hB", + "hb" + ], + "es-BO": [ + "H", + "h", + "hB", + "hb" + ], + "es-BR": [ + "H", + "h", + "hB", + "hb" + ], + "es-EC": [ + "H", + "h", + "hB", + "hb" + ], + "es-ES": [ + "H", + "h", + "hB", + "hb" + ], + "es-GQ": [ + "H", + "h", + "hB", + "hb" + ], + "es-PE": [ + "H", + "h", + "hB", + "hb" + ], + GT: [ + "H", + "h", + "hB", + "hb" + ], + HN: [ + "H", + "h", + "hB", + "hb" + ], + IC: [ + "H", + "h", + "hB", + "hb" + ], + KG: [ + "H", + "h", + "hB", + "hb" + ], + KM: [ + "H", + "h", + "hB", + "hb" + ], + LK: [ + "H", + "h", + "hB", + "hb" + ], + MA: [ + "H", + "h", + "hB", + "hb" + ], + MX: [ + "H", + "h", + "hB", + "hb" + ], + NI: [ + "H", + "h", + "hB", + "hb" + ], + PY: [ + "H", + "h", + "hB", + "hb" + ], + SV: [ + "H", + "h", + "hB", + "hb" + ], + UY: [ + "H", + "h", + "hB", + "hb" + ], + JP: [ + "H", + "h", + "K" + ], + AD: [ + "H", + "hB" + ], + AM: [ + "H", + "hB" + ], + AO: [ + "H", + "hB" + ], + AT: [ + "H", + "hB" + ], + AW: [ + "H", + "hB" + ], + BE: [ + "H", + "hB" + ], + BF: [ + "H", + "hB" + ], + BJ: [ + "H", + "hB" + ], + BL: [ + "H", + "hB" + ], + BR: [ + "H", + "hB" + ], + CG: [ + "H", + "hB" + ], + CI: [ + "H", + "hB" + ], + CV: [ + "H", + "hB" + ], + DE: [ + "H", + "hB" + ], + EE: [ + "H", + "hB" + ], + FR: [ + "H", + "hB" + ], + GA: [ + "H", + "hB" + ], + GF: [ + "H", + "hB" + ], + GN: [ + "H", + "hB" + ], + GP: [ + "H", + "hB" + ], + GW: [ + "H", + "hB" + ], + HR: [ + "H", + "hB" + ], + IL: [ + "H", + "hB" + ], + IT: [ + "H", + "hB" + ], + KZ: [ + "H", + "hB" + ], + MC: [ + "H", + "hB" + ], + MD: [ + "H", + "hB" + ], + MF: [ + "H", + "hB" + ], + MQ: [ + "H", + "hB" + ], + MZ: [ + "H", + "hB" + ], + NC: [ + "H", + "hB" + ], + NL: [ + "H", + "hB" + ], + PM: [ + "H", + "hB" + ], + PT: [ + "H", + "hB" + ], + RE: [ + "H", + "hB" + ], + RO: [ + "H", + "hB" + ], + SI: [ + "H", + "hB" + ], + SR: [ + "H", + "hB" + ], + ST: [ + "H", + "hB" + ], + TG: [ + "H", + "hB" + ], + TR: [ + "H", + "hB" + ], + WF: [ + "H", + "hB" + ], + YT: [ + "H", + "hB" + ], + BD: [ + "h", + "hB", + "H" + ], + PK: [ + "h", + "hB", + "H" + ], + AZ: [ + "H", + "hB", + "h" + ], + BA: [ + "H", + "hB", + "h" + ], + BG: [ + "H", + "hB", + "h" + ], + CH: [ + "H", + "hB", + "h" + ], + GE: [ + "H", + "hB", + "h" + ], + LI: [ + "H", + "hB", + "h" + ], + ME: [ + "H", + "hB", + "h" + ], + RS: [ + "H", + "hB", + "h" + ], + UA: [ + "H", + "hB", + "h" + ], + UZ: [ + "H", + "hB", + "h" + ], + XK: [ + "H", + "hB", + "h" + ], + AG: [ + "h", + "hb", + "H", + "hB" + ], + AU: [ + "h", + "hb", + "H", + "hB" + ], + BB: [ + "h", + "hb", + "H", + "hB" + ], + BM: [ + "h", + "hb", + "H", + "hB" + ], + BS: [ + "h", + "hb", + "H", + "hB" + ], + CA: [ + "h", + "hb", + "H", + "hB" + ], + DM: [ + "h", + "hb", + "H", + "hB" + ], + "en-001": [ + "h", + "hb", + "H", + "hB" + ], + FJ: [ + "h", + "hb", + "H", + "hB" + ], + FM: [ + "h", + "hb", + "H", + "hB" + ], + GD: [ + "h", + "hb", + "H", + "hB" + ], + GM: [ + "h", + "hb", + "H", + "hB" + ], + GU: [ + "h", + "hb", + "H", + "hB" + ], + GY: [ + "h", + "hb", + "H", + "hB" + ], + JM: [ + "h", + "hb", + "H", + "hB" + ], + KI: [ + "h", + "hb", + "H", + "hB" + ], + KN: [ + "h", + "hb", + "H", + "hB" + ], + KY: [ + "h", + "hb", + "H", + "hB" + ], + LC: [ + "h", + "hb", + "H", + "hB" + ], + LR: [ + "h", + "hb", + "H", + "hB" + ], + MH: [ + "h", + "hb", + "H", + "hB" + ], + MP: [ + "h", + "hb", + "H", + "hB" + ], + MW: [ + "h", + "hb", + "H", + "hB" + ], + NZ: [ + "h", + "hb", + "H", + "hB" + ], + SB: [ + "h", + "hb", + "H", + "hB" + ], + SG: [ + "h", + "hb", + "H", + "hB" + ], + SL: [ + "h", + "hb", + "H", + "hB" + ], + SS: [ + "h", + "hb", + "H", + "hB" + ], + SZ: [ + "h", + "hb", + "H", + "hB" + ], + TC: [ + "h", + "hb", + "H", + "hB" + ], + TT: [ + "h", + "hb", + "H", + "hB" + ], + UM: [ + "h", + "hb", + "H", + "hB" + ], + US: [ + "h", + "hb", + "H", + "hB" + ], + VC: [ + "h", + "hb", + "H", + "hB" + ], + VG: [ + "h", + "hb", + "H", + "hB" + ], + VI: [ + "h", + "hb", + "H", + "hB" + ], + ZM: [ + "h", + "hb", + "H", + "hB" + ], + BO: [ + "H", + "hB", + "h", + "hb" + ], + EC: [ + "H", + "hB", + "h", + "hb" + ], + ES: [ + "H", + "hB", + "h", + "hb" + ], + GQ: [ + "H", + "hB", + "h", + "hb" + ], + PE: [ + "H", + "hB", + "h", + "hb" + ], + AE: [ + "h", + "hB", + "hb", + "H" + ], + "ar-001": [ + "h", + "hB", + "hb", + "H" + ], + BH: [ + "h", + "hB", + "hb", + "H" + ], + DZ: [ + "h", + "hB", + "hb", + "H" + ], + EG: [ + "h", + "hB", + "hb", + "H" + ], + EH: [ + "h", + "hB", + "hb", + "H" + ], + HK: [ + "h", + "hB", + "hb", + "H" + ], + IQ: [ + "h", + "hB", + "hb", + "H" + ], + JO: [ + "h", + "hB", + "hb", + "H" + ], + KW: [ + "h", + "hB", + "hb", + "H" + ], + LB: [ + "h", + "hB", + "hb", + "H" + ], + LY: [ + "h", + "hB", + "hb", + "H" + ], + MO: [ + "h", + "hB", + "hb", + "H" + ], + MR: [ + "h", + "hB", + "hb", + "H" + ], + OM: [ + "h", + "hB", + "hb", + "H" + ], + PH: [ + "h", + "hB", + "hb", + "H" + ], + PS: [ + "h", + "hB", + "hb", + "H" + ], + QA: [ + "h", + "hB", + "hb", + "H" + ], + SA: [ + "h", + "hB", + "hb", + "H" + ], + SD: [ + "h", + "hB", + "hb", + "H" + ], + SY: [ + "h", + "hB", + "hb", + "H" + ], + TN: [ + "h", + "hB", + "hb", + "H" + ], + YE: [ + "h", + "hB", + "hb", + "H" + ], + AF: [ + "H", + "hb", + "hB", + "h" + ], + LA: [ + "H", + "hb", + "hB", + "h" + ], + CN: [ + "H", + "hB", + "hb", + "h" + ], + LV: [ + "H", + "hB", + "hb", + "h" + ], + TL: [ + "H", + "hB", + "hb", + "h" + ], + "zu-ZA": [ + "H", + "hB", + "hb", + "h" + ], + CD: [ + "hB", + "H" + ], + IR: [ + "hB", + "H" + ], + "hi-IN": [ + "hB", + "h", + "H" + ], + "kn-IN": [ + "hB", + "h", + "H" + ], + "ml-IN": [ + "hB", + "h", + "H" + ], + "te-IN": [ + "hB", + "h", + "H" + ], + KH: [ + "hB", + "h", + "H", + "hb" + ], + "ta-IN": [ + "hB", + "h", + "hb", + "H" + ], + BN: [ + "hb", + "hB", + "h", + "H" + ], + MY: [ + "hb", + "hB", + "h", + "H" + ], + ET: [ + "hB", + "hb", + "h", + "H" + ], + "gu-IN": [ + "hB", + "hb", + "h", + "H" + ], + "mr-IN": [ + "hB", + "hb", + "h", + "H" + ], + "pa-IN": [ + "hB", + "hb", + "h", + "H" + ], + TW: [ + "hB", + "hb", + "h", + "H" + ], + KE: [ + "hB", + "hb", + "H", + "h" + ], + MM: [ + "hB", + "hb", + "H", + "h" + ], + TZ: [ + "hB", + "hb", + "H", + "h" + ], + UG: [ + "hB", + "hb", + "H", + "h" + ] +}; +function getBestPattern(r, e) { + for (var t = "", s = 0; s < r.length; s++) { + var f = r.charAt(s); + if (f === "j") { + for (var _ = 0; s + 1 < r.length && r.charAt(s + 1) === f; ) + _++, s++; + var x = 1 + (_ & 1), h = _ < 2 ? 1 : 3 + (_ >> 1), u = "a", E = getDefaultHourSymbolFromLocale(e); + for ((E == "H" || E == "k") && (h = 0); h-- > 0; ) + t += u; + for (; x-- > 0; ) + t = E + t; + } else + f === "J" ? t += "H" : t += f; + } + return t; +} +function getDefaultHourSymbolFromLocale(r) { + var e = r.hourCycle; + if (e === void 0 && // @ts-ignore hourCycle(s) is not identified yet + r.hourCycles && // @ts-ignore + r.hourCycles.length && (e = r.hourCycles[0]), e) + switch (e) { + case "h24": + return "k"; + case "h23": + return "H"; + case "h12": + return "h"; + case "h11": + return "K"; + default: + throw new Error("Invalid hourCycle"); + } + var t = r.language, s; + t !== "root" && (s = r.maximize().region); + var f = timeData[s || ""] || timeData[t || ""] || timeData["".concat(t, "-001")] || timeData["001"]; + return f[0]; +} +var _a, SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*")), SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$")); +function createLocation(r, e) { + return { start: r, end: e }; +} +var hasNativeStartsWith = !!String.prototype.startsWith, hasNativeFromCodePoint = !!String.fromCodePoint, hasNativeFromEntries = !!Object.fromEntries, hasNativeCodePointAt = !!String.prototype.codePointAt, hasTrimStart = !!String.prototype.trimStart, hasTrimEnd = !!String.prototype.trimEnd, hasNativeIsSafeInteger = !!Number.isSafeInteger, isSafeInteger = hasNativeIsSafeInteger ? Number.isSafeInteger : function(r) { + return typeof r == "number" && isFinite(r) && Math.floor(r) === r && Math.abs(r) <= 9007199254740991; +}, REGEX_SUPPORTS_U_AND_Y = !0; +try { + var re = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu"); + REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec("a")) === null || _a === void 0 ? void 0 : _a[0]) === "a"; +} catch (r) { + REGEX_SUPPORTS_U_AND_Y = !1; +} +var startsWith = hasNativeStartsWith ? ( + // Native + function r(e, t, s) { + return e.startsWith(t, s); + } +) : ( + // For IE11 + function r(e, t, s) { + return e.slice(s, s + t.length) === t; + } +), fromCodePoint = hasNativeFromCodePoint ? String.fromCodePoint : ( + // IE11 + function r() { + for (var e = [], t = 0; t < arguments.length; t++) + e[t] = arguments[t]; + for (var s = "", f = e.length, _ = 0, x; f > _; ) { + if (x = e[_++], x > 1114111) + throw RangeError(x + " is not a valid code point"); + s += x < 65536 ? String.fromCharCode(x) : String.fromCharCode(((x -= 65536) >> 10) + 55296, x % 1024 + 56320); + } + return s; + } +), fromEntries = ( + // native + hasNativeFromEntries ? Object.fromEntries : ( + // Ponyfill + function r(e) { + for (var t = {}, s = 0, f = e; s < f.length; s++) { + var _ = f[s], x = _[0], h = _[1]; + t[x] = h; + } + return t; + } + ) +), codePointAt = hasNativeCodePointAt ? ( + // Native + function r(e, t) { + return e.codePointAt(t); + } +) : ( + // IE 11 + function r(e, t) { + var s = e.length; + if (!(t < 0 || t >= s)) { + var f = e.charCodeAt(t), _; + return f < 55296 || f > 56319 || t + 1 === s || (_ = e.charCodeAt(t + 1)) < 56320 || _ > 57343 ? f : (f - 55296 << 10) + (_ - 56320) + 65536; + } + } +), trimStart = hasTrimStart ? ( + // Native + function r(e) { + return e.trimStart(); + } +) : ( + // Ponyfill + function r(e) { + return e.replace(SPACE_SEPARATOR_START_REGEX, ""); + } +), trimEnd = hasTrimEnd ? ( + // Native + function r(e) { + return e.trimEnd(); + } +) : ( + // Ponyfill + function r(e) { + return e.replace(SPACE_SEPARATOR_END_REGEX, ""); + } +); +function RE(r, e) { + return new RegExp(r, e); +} +var matchIdentifierAtIndex; +if (REGEX_SUPPORTS_U_AND_Y) { + var IDENTIFIER_PREFIX_RE_1 = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu"); + matchIdentifierAtIndex = function(e, t) { + var s; + IDENTIFIER_PREFIX_RE_1.lastIndex = t; + var f = IDENTIFIER_PREFIX_RE_1.exec(e); + return (s = f[1]) !== null && s !== void 0 ? s : ""; + }; +} else + matchIdentifierAtIndex = function(e, t) { + for (var s = []; ; ) { + var f = codePointAt(e, t); + if (f === void 0 || _isWhiteSpace(f) || _isPatternSyntax(f)) + break; + s.push(f), t += f >= 65536 ? 2 : 1; + } + return fromCodePoint.apply(void 0, s); + }; +var Parser = ( + /** @class */ + function() { + function r(e, t) { + t === void 0 && (t = {}), this.message = e, this.position = { offset: 0, line: 1, column: 1 }, this.ignoreTag = !!t.ignoreTag, this.locale = t.locale, this.requiresOtherClause = !!t.requiresOtherClause, this.shouldParseSkeletons = !!t.shouldParseSkeletons; + } + return r.prototype.parse = function() { + if (this.offset() !== 0) + throw Error("parser can only be used once"); + return this.parseMessage(0, "", !1); + }, r.prototype.parseMessage = function(e, t, s) { + for (var f = []; !this.isEOF(); ) { + var _ = this.char(); + if (_ === 123) { + var x = this.parseArgument(e, s); + if (x.err) + return x; + f.push(x.val); + } else { + if (_ === 125 && e > 0) + break; + if (_ === 35 && (t === "plural" || t === "selectordinal")) { + var h = this.clonePosition(); + this.bump(), f.push({ + type: TYPE.pound, + location: createLocation(h, this.clonePosition()) + }); + } else if (_ === 60 && !this.ignoreTag && this.peek() === 47) { + if (s) + break; + return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition())); + } else if (_ === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) { + var x = this.parseTag(e, t); + if (x.err) + return x; + f.push(x.val); + } else { + var x = this.parseLiteral(e, t); + if (x.err) + return x; + f.push(x.val); + } + } + } + return { val: f, err: null }; + }, r.prototype.parseTag = function(e, t) { + var s = this.clonePosition(); + this.bump(); + var f = this.parseTagName(); + if (this.bumpSpace(), this.bumpIf("/>")) + return { + val: { + type: TYPE.literal, + value: "<".concat(f, "/>"), + location: createLocation(s, this.clonePosition()) + }, + err: null + }; + if (this.bumpIf(">")) { + var _ = this.parseMessage(e + 1, t, !0); + if (_.err) + return _; + var x = _.val, h = this.clonePosition(); + if (this.bumpIf("") ? { + val: { + type: TYPE.tag, + value: f, + children: x, + location: createLocation(s, this.clonePosition()) + }, + err: null + } : this.error(ErrorKind.INVALID_TAG, createLocation(h, this.clonePosition()))); + } else + return this.error(ErrorKind.UNCLOSED_TAG, createLocation(s, this.clonePosition())); + } else + return this.error(ErrorKind.INVALID_TAG, createLocation(s, this.clonePosition())); + }, r.prototype.parseTagName = function() { + var e = this.offset(); + for (this.bump(); !this.isEOF() && _isPotentialElementNameChar(this.char()); ) + this.bump(); + return this.message.slice(e, this.offset()); + }, r.prototype.parseLiteral = function(e, t) { + for (var s = this.clonePosition(), f = ""; ; ) { + var _ = this.tryParseQuote(t); + if (_) { + f += _; + continue; + } + var x = this.tryParseUnquoted(e, t); + if (x) { + f += x; + continue; + } + var h = this.tryParseLeftAngleBracket(); + if (h) { + f += h; + continue; + } + break; + } + var u = createLocation(s, this.clonePosition()); + return { + val: { type: TYPE.literal, value: f, location: u }, + err: null + }; + }, r.prototype.tryParseLeftAngleBracket = function() { + return !this.isEOF() && this.char() === 60 && (this.ignoreTag || // If at the opening tag or closing tag position, bail. + !_isAlphaOrSlash(this.peek() || 0)) ? (this.bump(), "<") : null; + }, r.prototype.tryParseQuote = function(e) { + if (this.isEOF() || this.char() !== 39) + return null; + switch (this.peek()) { + case 39: + return this.bump(), this.bump(), "'"; + case 123: + case 60: + case 62: + case 125: + break; + case 35: + if (e === "plural" || e === "selectordinal") + break; + return null; + default: + return null; + } + this.bump(); + var t = [this.char()]; + for (this.bump(); !this.isEOF(); ) { + var s = this.char(); + if (s === 39) + if (this.peek() === 39) + t.push(39), this.bump(); + else { + this.bump(); + break; + } + else + t.push(s); + this.bump(); + } + return fromCodePoint.apply(void 0, t); + }, r.prototype.tryParseUnquoted = function(e, t) { + if (this.isEOF()) + return null; + var s = this.char(); + return s === 60 || s === 123 || s === 35 && (t === "plural" || t === "selectordinal") || s === 125 && e > 0 ? null : (this.bump(), fromCodePoint(s)); + }, r.prototype.parseArgument = function(e, t) { + var s = this.clonePosition(); + if (this.bump(), this.bumpSpace(), this.isEOF()) + return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(s, this.clonePosition())); + if (this.char() === 125) + return this.bump(), this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(s, this.clonePosition())); + var f = this.parseIdentifierIfPossible().value; + if (!f) + return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(s, this.clonePosition())); + if (this.bumpSpace(), this.isEOF()) + return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(s, this.clonePosition())); + switch (this.char()) { + case 125: + return this.bump(), { + val: { + type: TYPE.argument, + // value does not include the opening and closing braces. + value: f, + location: createLocation(s, this.clonePosition()) + }, + err: null + }; + case 44: + return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(s, this.clonePosition())) : this.parseArgumentOptions(e, t, f, s); + default: + return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(s, this.clonePosition())); + } + }, r.prototype.parseIdentifierIfPossible = function() { + var e = this.clonePosition(), t = this.offset(), s = matchIdentifierAtIndex(this.message, t), f = t + s.length; + this.bumpTo(f); + var _ = this.clonePosition(), x = createLocation(e, _); + return { value: s, location: x }; + }, r.prototype.parseArgumentOptions = function(e, t, s, f) { + var _, x = this.clonePosition(), h = this.parseIdentifierIfPossible().value, u = this.clonePosition(); + switch (h) { + case "": + return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(x, u)); + case "number": + case "date": + case "time": { + this.bumpSpace(); + var E = null; + if (this.bumpIf(",")) { + this.bumpSpace(); + var c = this.clonePosition(), C = this.parseSimpleArgStyleIfPossible(); + if (C.err) + return C; + var b = trimEnd(C.val); + if (b.length === 0) + return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition())); + var A = createLocation(c, this.clonePosition()); + E = { style: b, styleLocation: A }; + } + var S = this.tryParseArgumentClose(f); + if (S.err) + return S; + var n = createLocation(f, this.clonePosition()); + if (E && startsWith(E == null ? void 0 : E.style, "::", 0)) { + var o = trimStart(E.style.slice(2)); + if (h === "number") { + var C = this.parseNumberSkeletonFromString(o, E.styleLocation); + return C.err ? C : { + val: { type: TYPE.number, value: s, location: n, style: C.val }, + err: null + }; + } else { + if (o.length === 0) + return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, n); + var w = o; + this.locale && (w = getBestPattern(o, this.locale)); + var b = { + type: SKELETON_TYPE.dateTime, + pattern: w, + location: E.styleLocation, + parsedOptions: this.shouldParseSkeletons ? parseDateTimeSkeleton(w) : {} + }, p = h === "date" ? TYPE.date : TYPE.time; + return { + val: { type: p, value: s, location: n, style: b }, + err: null + }; + } + } + return { + val: { + type: h === "number" ? TYPE.number : h === "date" ? TYPE.date : TYPE.time, + value: s, + location: n, + style: (_ = E == null ? void 0 : E.style) !== null && _ !== void 0 ? _ : null + }, + err: null + }; + } + case "plural": + case "selectordinal": + case "select": { + var v = this.clonePosition(); + if (this.bumpSpace(), !this.bumpIf(",")) + return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(v, __assign({}, v))); + this.bumpSpace(); + var a = this.parseIdentifierIfPossible(), l = 0; + if (h !== "select" && a.value === "offset") { + if (!this.bumpIf(":")) + return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition())); + this.bumpSpace(); + var C = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE); + if (C.err) + return C; + this.bumpSpace(), a = this.parseIdentifierIfPossible(), l = C.val; + } + var g = this.tryParsePluralOrSelectOptions(e, h, t, a); + if (g.err) + return g; + var S = this.tryParseArgumentClose(f); + if (S.err) + return S; + var M = createLocation(f, this.clonePosition()); + return h === "select" ? { + val: { + type: TYPE.select, + value: s, + options: fromEntries(g.val), + location: M + }, + err: null + } : { + val: { + type: TYPE.plural, + value: s, + options: fromEntries(g.val), + offset: l, + pluralType: h === "plural" ? "cardinal" : "ordinal", + location: M + }, + err: null + }; + } + default: + return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(x, u)); + } + }, r.prototype.tryParseArgumentClose = function(e) { + return this.isEOF() || this.char() !== 125 ? this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(e, this.clonePosition())) : (this.bump(), { val: !0, err: null }); + }, r.prototype.parseSimpleArgStyleIfPossible = function() { + for (var e = 0, t = this.clonePosition(); !this.isEOF(); ) { + var s = this.char(); + switch (s) { + case 39: { + this.bump(); + var f = this.clonePosition(); + if (!this.bumpUntil("'")) + return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(f, this.clonePosition())); + this.bump(); + break; + } + case 123: { + e += 1, this.bump(); + break; + } + case 125: { + if (e > 0) + e -= 1; + else + return { + val: this.message.slice(t.offset, this.offset()), + err: null + }; + break; + } + default: + this.bump(); + break; + } + } + return { + val: this.message.slice(t.offset, this.offset()), + err: null + }; + }, r.prototype.parseNumberSkeletonFromString = function(e, t) { + var s = []; + try { + s = parseNumberSkeletonFromString(e); + } catch { + return this.error(ErrorKind.INVALID_NUMBER_SKELETON, t); + } + return { + val: { + type: SKELETON_TYPE.number, + tokens: s, + location: t, + parsedOptions: this.shouldParseSkeletons ? parseNumberSkeleton(s) : {} + }, + err: null + }; + }, r.prototype.tryParsePluralOrSelectOptions = function(e, t, s, f) { + for (var _, x = !1, h = [], u = /* @__PURE__ */ new Set(), E = f.value, c = f.location; ; ) { + if (E.length === 0) { + var C = this.clonePosition(); + if (t !== "select" && this.bumpIf("=")) { + var b = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR); + if (b.err) + return b; + c = createLocation(C, this.clonePosition()), E = this.message.slice(C.offset, this.offset()); + } else + break; + } + if (u.has(E)) + return this.error(t === "select" ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, c); + E === "other" && (x = !0), this.bumpSpace(); + var A = this.clonePosition(); + if (!this.bumpIf("{")) + return this.error(t === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition())); + var S = this.parseMessage(e + 1, t, s); + if (S.err) + return S; + var n = this.tryParseArgumentClose(A); + if (n.err) + return n; + h.push([ + E, + { + value: S.val, + location: createLocation(A, this.clonePosition()) + } + ]), u.add(E), this.bumpSpace(), _ = this.parseIdentifierIfPossible(), E = _.value, c = _.location; + } + return h.length === 0 ? this.error(t === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !x ? this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition())) : { val: h, err: null }; + }, r.prototype.tryParseDecimalInteger = function(e, t) { + var s = 1, f = this.clonePosition(); + this.bumpIf("+") || this.bumpIf("-") && (s = -1); + for (var _ = !1, x = 0; !this.isEOF(); ) { + var h = this.char(); + if (h >= 48 && h <= 57) + _ = !0, x = x * 10 + (h - 48), this.bump(); + else + break; + } + var u = createLocation(f, this.clonePosition()); + return _ ? (x *= s, isSafeInteger(x) ? { val: x, err: null } : this.error(t, u)) : this.error(e, u); + }, r.prototype.offset = function() { + return this.position.offset; + }, r.prototype.isEOF = function() { + return this.offset() === this.message.length; + }, r.prototype.clonePosition = function() { + return { + offset: this.position.offset, + line: this.position.line, + column: this.position.column + }; + }, r.prototype.char = function() { + var e = this.position.offset; + if (e >= this.message.length) + throw Error("out of bound"); + var t = codePointAt(this.message, e); + if (t === void 0) + throw Error("Offset ".concat(e, " is at invalid UTF-16 code unit boundary")); + return t; + }, r.prototype.error = function(e, t) { + return { + val: null, + err: { + kind: e, + message: this.message, + location: t + } + }; + }, r.prototype.bump = function() { + if (!this.isEOF()) { + var e = this.char(); + e === 10 ? (this.position.line += 1, this.position.column = 1, this.position.offset += 1) : (this.position.column += 1, this.position.offset += e < 65536 ? 1 : 2); + } + }, r.prototype.bumpIf = function(e) { + if (startsWith(this.message, e, this.offset())) { + for (var t = 0; t < e.length; t++) + this.bump(); + return !0; + } + return !1; + }, r.prototype.bumpUntil = function(e) { + var t = this.offset(), s = this.message.indexOf(e, t); + return s >= 0 ? (this.bumpTo(s), !0) : (this.bumpTo(this.message.length), !1); + }, r.prototype.bumpTo = function(e) { + if (this.offset() > e) + throw Error("targetOffset ".concat(e, " must be greater than or equal to the current offset ").concat(this.offset())); + for (e = Math.min(e, this.message.length); ; ) { + var t = this.offset(); + if (t === e) + break; + if (t > e) + throw Error("targetOffset ".concat(e, " is at invalid UTF-16 code unit boundary")); + if (this.bump(), this.isEOF()) + break; + } + }, r.prototype.bumpSpace = function() { + for (; !this.isEOF() && _isWhiteSpace(this.char()); ) + this.bump(); + }, r.prototype.peek = function() { + if (this.isEOF()) + return null; + var e = this.char(), t = this.offset(), s = this.message.charCodeAt(t + (e >= 65536 ? 2 : 1)); + return s ?? null; + }, r; + }() +); +function _isAlpha(r) { + return r >= 97 && r <= 122 || r >= 65 && r <= 90; +} +function _isAlphaOrSlash(r) { + return _isAlpha(r) || r === 47; +} +function _isPotentialElementNameChar(r) { + return r === 45 || r === 46 || r >= 48 && r <= 57 || r === 95 || r >= 97 && r <= 122 || r >= 65 && r <= 90 || r == 183 || r >= 192 && r <= 214 || r >= 216 && r <= 246 || r >= 248 && r <= 893 || r >= 895 && r <= 8191 || r >= 8204 && r <= 8205 || r >= 8255 && r <= 8256 || r >= 8304 && r <= 8591 || r >= 11264 && r <= 12271 || r >= 12289 && r <= 55295 || r >= 63744 && r <= 64975 || r >= 65008 && r <= 65533 || r >= 65536 && r <= 983039; +} +function _isWhiteSpace(r) { + return r >= 9 && r <= 13 || r === 32 || r === 133 || r >= 8206 && r <= 8207 || r === 8232 || r === 8233; +} +function _isPatternSyntax(r) { + return r >= 33 && r <= 35 || r === 36 || r >= 37 && r <= 39 || r === 40 || r === 41 || r === 42 || r === 43 || r === 44 || r === 45 || r >= 46 && r <= 47 || r >= 58 && r <= 59 || r >= 60 && r <= 62 || r >= 63 && r <= 64 || r === 91 || r === 92 || r === 93 || r === 94 || r === 96 || r === 123 || r === 124 || r === 125 || r === 126 || r === 161 || r >= 162 && r <= 165 || r === 166 || r === 167 || r === 169 || r === 171 || r === 172 || r === 174 || r === 176 || r === 177 || r === 182 || r === 187 || r === 191 || r === 215 || r === 247 || r >= 8208 && r <= 8213 || r >= 8214 && r <= 8215 || r === 8216 || r === 8217 || r === 8218 || r >= 8219 && r <= 8220 || r === 8221 || r === 8222 || r === 8223 || r >= 8224 && r <= 8231 || r >= 8240 && r <= 8248 || r === 8249 || r === 8250 || r >= 8251 && r <= 8254 || r >= 8257 && r <= 8259 || r === 8260 || r === 8261 || r === 8262 || r >= 8263 && r <= 8273 || r === 8274 || r === 8275 || r >= 8277 && r <= 8286 || r >= 8592 && r <= 8596 || r >= 8597 && r <= 8601 || r >= 8602 && r <= 8603 || r >= 8604 && r <= 8607 || r === 8608 || r >= 8609 && r <= 8610 || r === 8611 || r >= 8612 && r <= 8613 || r === 8614 || r >= 8615 && r <= 8621 || r === 8622 || r >= 8623 && r <= 8653 || r >= 8654 && r <= 8655 || r >= 8656 && r <= 8657 || r === 8658 || r === 8659 || r === 8660 || r >= 8661 && r <= 8691 || r >= 8692 && r <= 8959 || r >= 8960 && r <= 8967 || r === 8968 || r === 8969 || r === 8970 || r === 8971 || r >= 8972 && r <= 8991 || r >= 8992 && r <= 8993 || r >= 8994 && r <= 9e3 || r === 9001 || r === 9002 || r >= 9003 && r <= 9083 || r === 9084 || r >= 9085 && r <= 9114 || r >= 9115 && r <= 9139 || r >= 9140 && r <= 9179 || r >= 9180 && r <= 9185 || r >= 9186 && r <= 9254 || r >= 9255 && r <= 9279 || r >= 9280 && r <= 9290 || r >= 9291 && r <= 9311 || r >= 9472 && r <= 9654 || r === 9655 || r >= 9656 && r <= 9664 || r === 9665 || r >= 9666 && r <= 9719 || r >= 9720 && r <= 9727 || r >= 9728 && r <= 9838 || r === 9839 || r >= 9840 && r <= 10087 || r === 10088 || r === 10089 || r === 10090 || r === 10091 || r === 10092 || r === 10093 || r === 10094 || r === 10095 || r === 10096 || r === 10097 || r === 10098 || r === 10099 || r === 10100 || r === 10101 || r >= 10132 && r <= 10175 || r >= 10176 && r <= 10180 || r === 10181 || r === 10182 || r >= 10183 && r <= 10213 || r === 10214 || r === 10215 || r === 10216 || r === 10217 || r === 10218 || r === 10219 || r === 10220 || r === 10221 || r === 10222 || r === 10223 || r >= 10224 && r <= 10239 || r >= 10240 && r <= 10495 || r >= 10496 && r <= 10626 || r === 10627 || r === 10628 || r === 10629 || r === 10630 || r === 10631 || r === 10632 || r === 10633 || r === 10634 || r === 10635 || r === 10636 || r === 10637 || r === 10638 || r === 10639 || r === 10640 || r === 10641 || r === 10642 || r === 10643 || r === 10644 || r === 10645 || r === 10646 || r === 10647 || r === 10648 || r >= 10649 && r <= 10711 || r === 10712 || r === 10713 || r === 10714 || r === 10715 || r >= 10716 && r <= 10747 || r === 10748 || r === 10749 || r >= 10750 && r <= 11007 || r >= 11008 && r <= 11055 || r >= 11056 && r <= 11076 || r >= 11077 && r <= 11078 || r >= 11079 && r <= 11084 || r >= 11085 && r <= 11123 || r >= 11124 && r <= 11125 || r >= 11126 && r <= 11157 || r === 11158 || r >= 11159 && r <= 11263 || r >= 11776 && r <= 11777 || r === 11778 || r === 11779 || r === 11780 || r === 11781 || r >= 11782 && r <= 11784 || r === 11785 || r === 11786 || r === 11787 || r === 11788 || r === 11789 || r >= 11790 && r <= 11798 || r === 11799 || r >= 11800 && r <= 11801 || r === 11802 || r === 11803 || r === 11804 || r === 11805 || r >= 11806 && r <= 11807 || r === 11808 || r === 11809 || r === 11810 || r === 11811 || r === 11812 || r === 11813 || r === 11814 || r === 11815 || r === 11816 || r === 11817 || r >= 11818 && r <= 11822 || r === 11823 || r >= 11824 && r <= 11833 || r >= 11834 && r <= 11835 || r >= 11836 && r <= 11839 || r === 11840 || r === 11841 || r === 11842 || r >= 11843 && r <= 11855 || r >= 11856 && r <= 11857 || r === 11858 || r >= 11859 && r <= 11903 || r >= 12289 && r <= 12291 || r === 12296 || r === 12297 || r === 12298 || r === 12299 || r === 12300 || r === 12301 || r === 12302 || r === 12303 || r === 12304 || r === 12305 || r >= 12306 && r <= 12307 || r === 12308 || r === 12309 || r === 12310 || r === 12311 || r === 12312 || r === 12313 || r === 12314 || r === 12315 || r === 12316 || r === 12317 || r >= 12318 && r <= 12319 || r === 12320 || r === 12336 || r === 64830 || r === 64831 || r >= 65093 && r <= 65094; +} +function pruneLocation(r) { + r.forEach(function(e) { + if (delete e.location, isSelectElement(e) || isPluralElement(e)) + for (var t in e.options) + delete e.options[t].location, pruneLocation(e.options[t].value); + else + isNumberElement(e) && isNumberSkeleton(e.style) || (isDateElement(e) || isTimeElement(e)) && isDateTimeSkeleton(e.style) ? delete e.style.location : isTagElement(e) && pruneLocation(e.children); + }); +} +function parse(r, e) { + e === void 0 && (e = {}), e = __assign({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, e); + var t = new Parser(r, e).parse(); + if (t.err) { + var s = SyntaxError(ErrorKind[t.err.kind]); + throw s.location = t.err.location, s.originalMessage = t.err.message, s; + } + return e != null && e.captureLocation || pruneLocation(t.val), t.val; +} +function memoize(r, e) { + var t = e && e.cache ? e.cache : cacheDefault, s = e && e.serializer ? e.serializer : serializerDefault, f = e && e.strategy ? e.strategy : strategyDefault; + return f(r, { + cache: t, + serializer: s + }); +} +function isPrimitive(r) { + return r == null || typeof r == "number" || typeof r == "boolean"; +} +function monadic(r, e, t, s) { + var f = isPrimitive(s) ? s : t(s), _ = e.get(f); + return typeof _ > "u" && (_ = r.call(this, s), e.set(f, _)), _; +} +function variadic(r, e, t) { + var s = Array.prototype.slice.call(arguments, 3), f = t(s), _ = e.get(f); + return typeof _ > "u" && (_ = r.apply(this, s), e.set(f, _)), _; +} +function assemble(r, e, t, s, f) { + return t.bind(e, r, s, f); +} +function strategyDefault(r, e) { + var t = r.length === 1 ? monadic : variadic; + return assemble(r, this, t, e.cache.create(), e.serializer); +} +function strategyVariadic(r, e) { + return assemble(r, this, variadic, e.cache.create(), e.serializer); +} +function strategyMonadic(r, e) { + return assemble(r, this, monadic, e.cache.create(), e.serializer); +} +var serializerDefault = function() { + return JSON.stringify(arguments); +}; +function ObjectWithoutPrototypeCache() { + this.cache = /* @__PURE__ */ Object.create(null); +} +ObjectWithoutPrototypeCache.prototype.get = function(r) { + return this.cache[r]; +}; +ObjectWithoutPrototypeCache.prototype.set = function(r, e) { + this.cache[r] = e; +}; +var cacheDefault = { + create: function r() { + return new ObjectWithoutPrototypeCache(); + } +}, strategies = { + variadic: strategyVariadic, + monadic: strategyMonadic +}, ErrorCode; +(function(r) { + r.MISSING_VALUE = "MISSING_VALUE", r.INVALID_VALUE = "INVALID_VALUE", r.MISSING_INTL_API = "MISSING_INTL_API"; +})(ErrorCode || (ErrorCode = {})); +var FormatError = ( + /** @class */ + function(r) { + __extends(e, r); + function e(t, s, f) { + var _ = r.call(this, t) || this; + return _.code = s, _.originalMessage = f, _; + } + return e.prototype.toString = function() { + return "[formatjs Error: ".concat(this.code, "] ").concat(this.message); + }, e; + }(Error) +), InvalidValueError = ( + /** @class */ + function(r) { + __extends(e, r); + function e(t, s, f, _) { + return r.call(this, 'Invalid values for "'.concat(t, '": "').concat(s, '". Options are "').concat(Object.keys(f).join('", "'), '"'), ErrorCode.INVALID_VALUE, _) || this; + } + return e; + }(FormatError) +), InvalidValueTypeError = ( + /** @class */ + function(r) { + __extends(e, r); + function e(t, s, f) { + return r.call(this, 'Value for "'.concat(t, '" must be of type ').concat(s), ErrorCode.INVALID_VALUE, f) || this; + } + return e; + }(FormatError) +), MissingValueError = ( + /** @class */ + function(r) { + __extends(e, r); + function e(t, s) { + return r.call(this, 'The intl string context variable "'.concat(t, '" was not provided to the string "').concat(s, '"'), ErrorCode.MISSING_VALUE, s) || this; + } + return e; + }(FormatError) +), PART_TYPE; +(function(r) { + r[r.literal = 0] = "literal", r[r.object = 1] = "object"; +})(PART_TYPE || (PART_TYPE = {})); +function mergeLiteral(r) { + return r.length < 2 ? r : r.reduce(function(e, t) { + var s = e[e.length - 1]; + return !s || s.type !== PART_TYPE.literal || t.type !== PART_TYPE.literal ? e.push(t) : s.value += t.value, e; + }, []); +} +function isFormatXMLElementFn(r) { + return typeof r == "function"; +} +function formatToParts(r, e, t, s, f, _, x) { + if (r.length === 1 && isLiteralElement(r[0])) + return [ + { + type: PART_TYPE.literal, + value: r[0].value + } + ]; + for (var h = [], u = 0, E = r; u < E.length; u++) { + var c = E[u]; + if (isLiteralElement(c)) { + h.push({ + type: PART_TYPE.literal, + value: c.value + }); + continue; + } + if (isPoundElement(c)) { + typeof _ == "number" && h.push({ + type: PART_TYPE.literal, + value: t.getNumberFormat(e).format(_) + }); + continue; + } + var C = c.value; + if (!(f && C in f)) + throw new MissingValueError(C, x); + var b = f[C]; + if (isArgumentElement(c)) { + (!b || typeof b == "string" || typeof b == "number") && (b = typeof b == "string" || typeof b == "number" ? String(b) : ""), h.push({ + type: typeof b == "string" ? PART_TYPE.literal : PART_TYPE.object, + value: b + }); + continue; + } + if (isDateElement(c)) { + var A = typeof c.style == "string" ? s.date[c.style] : isDateTimeSkeleton(c.style) ? c.style.parsedOptions : void 0; + h.push({ + type: PART_TYPE.literal, + value: t.getDateTimeFormat(e, A).format(b) + }); + continue; + } + if (isTimeElement(c)) { + var A = typeof c.style == "string" ? s.time[c.style] : isDateTimeSkeleton(c.style) ? c.style.parsedOptions : s.time.medium; + h.push({ + type: PART_TYPE.literal, + value: t.getDateTimeFormat(e, A).format(b) + }); + continue; + } + if (isNumberElement(c)) { + var A = typeof c.style == "string" ? s.number[c.style] : isNumberSkeleton(c.style) ? c.style.parsedOptions : void 0; + A && A.scale && (b = b * (A.scale || 1)), h.push({ + type: PART_TYPE.literal, + value: t.getNumberFormat(e, A).format(b) + }); + continue; + } + if (isTagElement(c)) { + var S = c.children, n = c.value, o = f[n]; + if (!isFormatXMLElementFn(o)) + throw new InvalidValueTypeError(n, "function", x); + var w = formatToParts(S, e, t, s, f, _), p = o(w.map(function(l) { + return l.value; + })); + Array.isArray(p) || (p = [p]), h.push.apply(h, p.map(function(l) { + return { + type: typeof l == "string" ? PART_TYPE.literal : PART_TYPE.object, + value: l + }; + })); + } + if (isSelectElement(c)) { + var v = c.options[b] || c.options.other; + if (!v) + throw new InvalidValueError(c.value, b, Object.keys(c.options), x); + h.push.apply(h, formatToParts(v.value, e, t, s, f)); + continue; + } + if (isPluralElement(c)) { + var v = c.options["=".concat(b)]; + if (!v) { + if (!Intl.PluralRules) + throw new FormatError(`Intl.PluralRules is not available in this environment. +Try polyfilling it using "@formatjs/intl-pluralrules" +`, ErrorCode.MISSING_INTL_API, x); + var a = t.getPluralRules(e, { type: c.pluralType }).select(b - (c.offset || 0)); + v = c.options[a] || c.options.other; + } + if (!v) + throw new InvalidValueError(c.value, b, Object.keys(c.options), x); + h.push.apply(h, formatToParts(v.value, e, t, s, f, b - (c.offset || 0))); + continue; + } + } + return mergeLiteral(h); +} +function mergeConfig(r, e) { + return e ? __assign(__assign(__assign({}, r || {}), e || {}), Object.keys(r).reduce(function(t, s) { + return t[s] = __assign(__assign({}, r[s]), e[s] || {}), t; + }, {})) : r; +} +function mergeConfigs(r, e) { + return e ? Object.keys(r).reduce(function(t, s) { + return t[s] = mergeConfig(r[s], e[s]), t; + }, __assign({}, r)) : r; +} +function createFastMemoizeCache(r) { + return { + create: function() { + return { + get: function(e) { + return r[e]; + }, + set: function(e, t) { + r[e] = t; + } + }; + } + }; +} +function createDefaultFormatters(r) { + return r === void 0 && (r = { + number: {}, + dateTime: {}, + pluralRules: {} + }), { + getNumberFormat: memoize(function() { + for (var e, t = [], s = 0; s < arguments.length; s++) + t[s] = arguments[s]; + return new ((e = Intl.NumberFormat).bind.apply(e, __spreadArray([void 0], t, !1)))(); + }, { + cache: createFastMemoizeCache(r.number), + strategy: strategies.variadic + }), + getDateTimeFormat: memoize(function() { + for (var e, t = [], s = 0; s < arguments.length; s++) + t[s] = arguments[s]; + return new ((e = Intl.DateTimeFormat).bind.apply(e, __spreadArray([void 0], t, !1)))(); + }, { + cache: createFastMemoizeCache(r.dateTime), + strategy: strategies.variadic + }), + getPluralRules: memoize(function() { + for (var e, t = [], s = 0; s < arguments.length; s++) + t[s] = arguments[s]; + return new ((e = Intl.PluralRules).bind.apply(e, __spreadArray([void 0], t, !1)))(); + }, { + cache: createFastMemoizeCache(r.pluralRules), + strategy: strategies.variadic + }) + }; +} +var IntlMessageFormat = ( + /** @class */ + function() { + function r(e, t, s, f) { + var _ = this; + if (t === void 0 && (t = r.defaultLocale), this.formatterCache = { + number: {}, + dateTime: {}, + pluralRules: {} + }, this.format = function(x) { + var h = _.formatToParts(x); + if (h.length === 1) + return h[0].value; + var u = h.reduce(function(E, c) { + return !E.length || c.type !== PART_TYPE.literal || typeof E[E.length - 1] != "string" ? E.push(c.value) : E[E.length - 1] += c.value, E; + }, []); + return u.length <= 1 ? u[0] || "" : u; + }, this.formatToParts = function(x) { + return formatToParts(_.ast, _.locales, _.formatters, _.formats, x, void 0, _.message); + }, this.resolvedOptions = function() { + return { + locale: _.resolvedLocale.toString() + }; + }, this.getAst = function() { + return _.ast; + }, this.locales = t, this.resolvedLocale = r.resolveLocale(t), typeof e == "string") { + if (this.message = e, !r.__parse) + throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`"); + this.ast = r.__parse(e, { + ignoreTag: f == null ? void 0 : f.ignoreTag, + locale: this.resolvedLocale + }); + } else + this.ast = e; + if (!Array.isArray(this.ast)) + throw new TypeError("A message must be provided as a String or AST."); + this.formats = mergeConfigs(r.formats, s), this.formatters = f && f.formatters || createDefaultFormatters(this.formatterCache); + } + return Object.defineProperty(r, "defaultLocale", { + get: function() { + return r.memoizedDefaultLocale || (r.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale), r.memoizedDefaultLocale; + }, + enumerable: !1, + configurable: !0 + }), r.memoizedDefaultLocale = null, r.resolveLocale = function(e) { + var t = Intl.NumberFormat.supportedLocalesOf(e); + return t.length > 0 ? new Intl.Locale(t[0]) : new Intl.Locale(typeof e == "string" ? e : e[0]); + }, r.__parse = parse, r.formats = { + number: { + integer: { + maximumFractionDigits: 0 + }, + currency: { + style: "currency" + }, + percent: { + style: "percent" + } + }, + date: { + short: { + month: "numeric", + day: "numeric", + year: "2-digit" + }, + medium: { + month: "short", + day: "numeric", + year: "numeric" + }, + long: { + month: "long", + day: "numeric", + year: "numeric" + }, + full: { + weekday: "long", + month: "long", + day: "numeric", + year: "numeric" + } + }, + time: { + short: { + hour: "numeric", + minute: "numeric" + }, + medium: { + hour: "numeric", + minute: "numeric", + second: "numeric" + }, + long: { + hour: "numeric", + minute: "numeric", + second: "numeric", + timeZoneName: "short" + }, + full: { + hour: "numeric", + minute: "numeric", + second: "numeric", + timeZoneName: "short" + } + } + }, r; + }() +); +function delve(r, e) { + if (e == null) + return; + if (e in r) + return r[e]; + const t = e.split("."); + let s = r; + for (let f = 0; f < t.length; f++) + if (typeof s == "object") { + if (f > 0) { + const _ = t.slice(f, t.length).join("."); + if (_ in s) { + s = s[_]; + break; + } + } + s = s[t[f]]; + } else + s = void 0; + return s; +} +const lookupCache = {}, addToCache = (r, e, t) => t && (e in lookupCache || (lookupCache[e] = {}), r in lookupCache[e] || (lookupCache[e][r] = t), t), lookup = (r, e) => { + if (e == null) + return; + if (e in lookupCache && r in lookupCache[e]) + return lookupCache[e][r]; + const t = getPossibleLocales(e); + for (let s = 0; s < t.length; s++) { + const f = t[s], _ = getMessageFromDictionary(f, r); + if (_) + return addToCache(r, e, _); + } +}; +let dictionary; +const $dictionary = writable({}); +function getLocaleDictionary(r) { + return dictionary[r] || null; +} +function hasLocaleDictionary(r) { + return r in dictionary; +} +function getMessageFromDictionary(r, e) { + if (!hasLocaleDictionary(r)) + return null; + const t = getLocaleDictionary(r); + return delve(t, e); +} +function getClosestAvailableLocale(r) { + if (r == null) + return; + const e = getPossibleLocales(r); + for (let t = 0; t < e.length; t++) { + const s = e[t]; + if (hasLocaleDictionary(s)) + return s; + } +} +function addMessages(r, ...e) { + delete lookupCache[r], $dictionary.update((t) => (t[r] = deepmerge$1.all([t[r] || {}, ...e]), t)); +} +derived( + [$dictionary], + ([r]) => Object.keys(r) +); +$dictionary.subscribe((r) => dictionary = r); +const queue = {}; +function removeLoaderFromQueue(r, e) { + queue[r].delete(e), queue[r].size === 0 && delete queue[r]; +} +function getLocaleQueue(r) { + return queue[r]; +} +function getLocalesQueues(r) { + return getPossibleLocales(r).map((e) => { + const t = getLocaleQueue(e); + return [e, t ? [...t] : []]; + }).filter(([, e]) => e.length > 0); +} +function hasLocaleQueue(r) { + return r == null ? !1 : getPossibleLocales(r).some( + (e) => { + var t; + return (t = getLocaleQueue(e)) == null ? void 0 : t.size; + } + ); +} +function loadLocaleQueue(r, e) { + return Promise.all( + e.map((s) => (removeLoaderFromQueue(r, s), s().then((f) => f.default || f))) + ).then((s) => addMessages(r, ...s)); +} +const activeFlushes = {}; +function flush$1(r) { + if (!hasLocaleQueue(r)) + return r in activeFlushes ? activeFlushes[r] : Promise.resolve(); + const e = getLocalesQueues(r); + return activeFlushes[r] = Promise.all( + e.map( + ([t, s]) => loadLocaleQueue(t, s) + ) + ).then(() => { + if (hasLocaleQueue(r)) + return flush$1(r); + delete activeFlushes[r]; + }), activeFlushes[r]; +} +const defaultFormats = { + number: { + scientific: { notation: "scientific" }, + engineering: { notation: "engineering" }, + compactLong: { notation: "compact", compactDisplay: "long" }, + compactShort: { notation: "compact", compactDisplay: "short" } + }, + date: { + short: { month: "numeric", day: "numeric", year: "2-digit" }, + medium: { month: "short", day: "numeric", year: "numeric" }, + long: { month: "long", day: "numeric", year: "numeric" }, + full: { weekday: "long", month: "long", day: "numeric", year: "numeric" } + }, + time: { + short: { hour: "numeric", minute: "numeric" }, + medium: { hour: "numeric", minute: "numeric", second: "numeric" }, + long: { + hour: "numeric", + minute: "numeric", + second: "numeric", + timeZoneName: "short" + }, + full: { + hour: "numeric", + minute: "numeric", + second: "numeric", + timeZoneName: "short" + } + } +}, defaultOptions = { + fallbackLocale: null, + loadingDelay: 200, + formats: defaultFormats, + warnOnMissingMessages: !0, + handleMissingMessage: void 0, + ignoreTag: !0 +}, options = defaultOptions; +function getOptions() { + return options; +} +const $isLoading = writable(!1); +var __defProp$1 = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropSymbols$1 = Object.getOwnPropertySymbols, __hasOwnProp$1 = Object.prototype.hasOwnProperty, __propIsEnum$1 = Object.prototype.propertyIsEnumerable, __defNormalProp$1 = (r, e, t) => e in r ? __defProp$1(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, __spreadValues$1 = (r, e) => { + for (var t in e || (e = {})) + __hasOwnProp$1.call(e, t) && __defNormalProp$1(r, t, e[t]); + if (__getOwnPropSymbols$1) + for (var t of __getOwnPropSymbols$1(e)) + __propIsEnum$1.call(e, t) && __defNormalProp$1(r, t, e[t]); + return r; +}, __spreadProps = (r, e) => __defProps(r, __getOwnPropDescs(e)); +let current; +const internalLocale = writable(null); +function getSubLocales(r) { + return r.split("-").map((e, t, s) => s.slice(0, t + 1).join("-")).reverse(); +} +function getPossibleLocales(r, e = getOptions().fallbackLocale) { + const t = getSubLocales(r); + return e ? [.../* @__PURE__ */ new Set([...t, ...getSubLocales(e)])] : t; +} +function getCurrentLocale() { + return current ?? void 0; +} +internalLocale.subscribe((r) => { + current = r ?? void 0, typeof window < "u" && r != null && document.documentElement.setAttribute("lang", r); +}); +const set = (r) => { + if (r && getClosestAvailableLocale(r) && hasLocaleQueue(r)) { + const { loadingDelay: e } = getOptions(); + let t; + return typeof window < "u" && getCurrentLocale() != null && e ? t = window.setTimeout( + () => $isLoading.set(!0), + e + ) : $isLoading.set(!0), flush$1(r).then(() => { + internalLocale.set(r); + }).finally(() => { + clearTimeout(t), $isLoading.set(!1); + }); + } + return internalLocale.set(r); +}, $locale = __spreadProps(__spreadValues$1({}, internalLocale), { + set +}), monadicMemoize = (r) => { + const e = /* @__PURE__ */ Object.create(null); + return (s) => { + const f = JSON.stringify(s); + return f in e ? e[f] : e[f] = r(s); + }; +}; +var __defProp = Object.defineProperty, __getOwnPropSymbols = Object.getOwnPropertySymbols, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable, __defNormalProp = (r, e, t) => e in r ? __defProp(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, __spreadValues = (r, e) => { + for (var t in e || (e = {})) + __hasOwnProp.call(e, t) && __defNormalProp(r, t, e[t]); + if (__getOwnPropSymbols) + for (var t of __getOwnPropSymbols(e)) + __propIsEnum.call(e, t) && __defNormalProp(r, t, e[t]); + return r; +}, __objRest = (r, e) => { + var t = {}; + for (var s in r) + __hasOwnProp.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]); + if (r != null && __getOwnPropSymbols) + for (var s of __getOwnPropSymbols(r)) + e.indexOf(s) < 0 && __propIsEnum.call(r, s) && (t[s] = r[s]); + return t; +}; +const getIntlFormatterOptions = (r, e) => { + const { formats: t } = getOptions(); + if (r in t && e in t[r]) + return t[r][e]; + throw new Error(`[svelte-i18n] Unknown "${e}" ${r} format.`); +}, createNumberFormatter = monadicMemoize( + (r) => { + var e = r, { locale: t, format: s } = e, f = __objRest(e, ["locale", "format"]); + if (t == null) + throw new Error('[svelte-i18n] A "locale" must be set to format numbers'); + return s && (f = getIntlFormatterOptions("number", s)), new Intl.NumberFormat(t, f); + } +), createDateFormatter = monadicMemoize( + (r) => { + var e = r, { locale: t, format: s } = e, f = __objRest(e, ["locale", "format"]); + if (t == null) + throw new Error('[svelte-i18n] A "locale" must be set to format dates'); + return s ? f = getIntlFormatterOptions("date", s) : Object.keys(f).length === 0 && (f = getIntlFormatterOptions("date", "short")), new Intl.DateTimeFormat(t, f); + } +), createTimeFormatter = monadicMemoize( + (r) => { + var e = r, { locale: t, format: s } = e, f = __objRest(e, ["locale", "format"]); + if (t == null) + throw new Error( + '[svelte-i18n] A "locale" must be set to format time values' + ); + return s ? f = getIntlFormatterOptions("time", s) : Object.keys(f).length === 0 && (f = getIntlFormatterOptions("time", "short")), new Intl.DateTimeFormat(t, f); + } +), getNumberFormatter = (r = {}) => { + var e = r, { + locale: t = getCurrentLocale() + } = e, s = __objRest(e, [ + "locale" + ]); + return createNumberFormatter(__spreadValues({ locale: t }, s)); +}, getDateFormatter = (r = {}) => { + var e = r, { + locale: t = getCurrentLocale() + } = e, s = __objRest(e, [ + "locale" + ]); + return createDateFormatter(__spreadValues({ locale: t }, s)); +}, getTimeFormatter = (r = {}) => { + var e = r, { + locale: t = getCurrentLocale() + } = e, s = __objRest(e, [ + "locale" + ]); + return createTimeFormatter(__spreadValues({ locale: t }, s)); +}, getMessageFormatter = monadicMemoize( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + (r, e = getCurrentLocale()) => new IntlMessageFormat(r, e, getOptions().formats, { + ignoreTag: getOptions().ignoreTag + }) +), formatMessage = (r, e = {}) => { + var t, s, f, _; + let x = e; + typeof r == "object" && (x = r, r = x.id); + const { + values: h, + locale: u = getCurrentLocale(), + default: E + } = x; + if (u == null) + throw new Error( + "[svelte-i18n] Cannot format a message without first setting the initial locale." + ); + let c = lookup(r, u); + if (!c) + c = (_ = (f = (s = (t = getOptions()).handleMissingMessage) == null ? void 0 : s.call(t, { locale: u, id: r, defaultValue: E })) != null ? f : E) != null ? _ : r; + else if (typeof c != "string") + return console.warn( + `[svelte-i18n] Message with id "${r}" must be of type "string", found: "${typeof c}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.` + ), c; + if (!h) + return c; + let C = c; + try { + C = getMessageFormatter(c, u).format(h); + } catch (b) { + b instanceof Error && console.warn( + `[svelte-i18n] Message "${r}" has syntax error:`, + b.message + ); + } + return C; +}, formatTime = (r, e) => getTimeFormatter(e).format(r), formatDate = (r, e) => getDateFormatter(e).format(r), formatNumber = (r, e) => getNumberFormatter(e).format(r), getJSON = (r, e = getCurrentLocale()) => lookup(r, e); +derived([$locale, $dictionary], () => formatMessage); +derived([$locale], () => formatTime); +derived([$locale], () => formatDate); +derived([$locale], () => formatNumber); +derived([$locale, $dictionary], () => getJSON); +const Upload_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$8, + append: append$7, + attr: attr$7, + binding_callbacks: binding_callbacks$2, + bubble: bubble$1, + create_slot: create_slot$2, + detach: detach$8, + element: element$6, + get_all_dirty_from_scope: get_all_dirty_from_scope$2, + get_slot_changes: get_slot_changes$2, + init: init$8, + insert: insert$8, + listen: listen$1, + prevent_default, + run_all: run_all$1, + safe_not_equal: safe_not_equal$8, + space: space$5, + stop_propagation, + toggle_class: toggle_class$4, + transition_in: transition_in$5, + transition_out: transition_out$5, + update_slot_base: update_slot_base$2 +} = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$3, tick: tick$3, getContext: getContext$1 } = window.__gradio__svelte__internal; +function create_fragment$8(r) { + let e, t, s, f, _, x, h, u, E; + const c = ( + /*#slots*/ + r[16].default + ), C = create_slot$2( + c, + r, + /*$$scope*/ + r[15], + null + ); + return { + c() { + e = element$6("button"), C && C.c(), t = space$5(), s = element$6("input"), attr$7(s, "type", "file"), attr$7( + s, + "accept", + /*filetype*/ + r[0] + ), s.multiple = f = /*file_count*/ + r[4] === "multiple" || void 0, attr$7(s, "webkitdirectory", _ = /*file_count*/ + r[4] === "directory" || void 0), attr$7(s, "mozdirectory", x = /*file_count*/ + r[4] === "directory" || void 0), attr$7(s, "class", "svelte-18dlsnh"), attr$7(e, "class", "svelte-18dlsnh"), toggle_class$4( + e, + "hidden", + /*hidden*/ + r[5] + ), toggle_class$4( + e, + "center", + /*center*/ + r[2] + ), toggle_class$4( + e, + "boundedheight", + /*boundedheight*/ + r[1] + ), toggle_class$4( + e, + "flex", + /*flex*/ + r[3] + ); + }, + m(b, A) { + insert$8(b, e, A), C && C.m(e, null), append$7(e, t), append$7(e, s), r[24](s), h = !0, u || (E = [ + listen$1( + s, + "change", + /*load_files_from_upload*/ + r[9] + ), + listen$1(e, "drag", stop_propagation(prevent_default( + /*drag_handler*/ + r[17] + ))), + listen$1(e, "dragstart", stop_propagation(prevent_default( + /*dragstart_handler*/ + r[18] + ))), + listen$1(e, "dragend", stop_propagation(prevent_default( + /*dragend_handler*/ + r[19] + ))), + listen$1(e, "dragover", stop_propagation(prevent_default( + /*dragover_handler*/ + r[20] + ))), + listen$1(e, "dragenter", stop_propagation(prevent_default( + /*dragenter_handler*/ + r[21] + ))), + listen$1(e, "dragleave", stop_propagation(prevent_default( + /*dragleave_handler*/ + r[22] + ))), + listen$1(e, "drop", stop_propagation(prevent_default( + /*drop_handler*/ + r[23] + ))), + listen$1( + e, + "click", + /*open_file_upload*/ + r[6] + ), + listen$1( + e, + "drop", + /*loadFilesFromDrop*/ + r[10] + ), + listen$1( + e, + "dragenter", + /*updateDragging*/ + r[8] + ), + listen$1( + e, + "dragleave", + /*updateDragging*/ + r[8] + ) + ], u = !0); + }, + p(b, [A]) { + C && C.p && (!h || A & /*$$scope*/ + 32768) && update_slot_base$2( + C, + c, + b, + /*$$scope*/ + b[15], + h ? get_slot_changes$2( + c, + /*$$scope*/ + b[15], + A, + null + ) : get_all_dirty_from_scope$2( + /*$$scope*/ + b[15] + ), + null + ), (!h || A & /*filetype*/ + 1) && attr$7( + s, + "accept", + /*filetype*/ + b[0] + ), (!h || A & /*file_count*/ + 16 && f !== (f = /*file_count*/ + b[4] === "multiple" || void 0)) && (s.multiple = f), (!h || A & /*file_count*/ + 16 && _ !== (_ = /*file_count*/ + b[4] === "directory" || void 0)) && attr$7(s, "webkitdirectory", _), (!h || A & /*file_count*/ + 16 && x !== (x = /*file_count*/ + b[4] === "directory" || void 0)) && attr$7(s, "mozdirectory", x), (!h || A & /*hidden*/ + 32) && toggle_class$4( + e, + "hidden", + /*hidden*/ + b[5] + ), (!h || A & /*center*/ + 4) && toggle_class$4( + e, + "center", + /*center*/ + b[2] + ), (!h || A & /*boundedheight*/ + 2) && toggle_class$4( + e, + "boundedheight", + /*boundedheight*/ + b[1] + ), (!h || A & /*flex*/ + 8) && toggle_class$4( + e, + "flex", + /*flex*/ + b[3] + ); + }, + i(b) { + h || (transition_in$5(C, b), h = !0); + }, + o(b) { + transition_out$5(C, b), h = !1; + }, + d(b) { + b && detach$8(e), C && C.d(b), r[24](null), u = !1, run_all$1(E); + } + }; +} +function _optionalChain(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 is_valid_mimetype(r, e) { + return !r || r === "*" ? !0 : r.endsWith("/*") ? e.startsWith(r.slice(0, -1)) : r === e; +} +function instance$7(r, e, t) { + let { $$slots: s = {}, $$scope: f } = e, { filetype: _ = null } = e, { dragging: x = !1 } = e, { boundedheight: h = !0 } = e, { center: u = !0 } = e, { flex: E = !0 } = e, { file_count: c = "single" } = e, { disable_click: C = !1 } = e, { root: b } = e, { hidden: A = !1 } = e; + const S = getContext$1("upload_files"); + let n; + const o = createEventDispatcher$3(); + function w() { + t(11, x = !x); + } + function p() { + C || (t(7, n.value = "", n), n.click()); + } + async function v(F) { + await tick$3(); + const N = await upload(F, b, S); + return o("load", c === "single" ? _optionalChain([N, "optionalAccess", ($) => $[0]]) : N), N || []; + } + async function a(F) { + if (!F.length) + return; + let N = F.map((k) => new File([k], k.name)), $ = await prepare_files(N); + return await v($); + } + async function l(F) { + const N = F.target; + N.files && await a(Array.from(N.files)); + } + async function g(F) { + if (t(11, x = !1), !_optionalChain([F, "access", ($) => $.dataTransfer, "optionalAccess", ($) => $.files])) + return; + const N = Array.from(F.dataTransfer.files).filter(($) => is_valid_mimetype(_, $.type) ? !0 : (o("error", `Invalid file type only ${_} allowed.`), !1)); + await a(N); + } + function M(F) { + bubble$1.call(this, r, F); + } + function L(F) { + bubble$1.call(this, r, F); + } + function T(F) { + bubble$1.call(this, r, F); + } + function D(F) { + bubble$1.call(this, r, F); + } + function R(F) { + bubble$1.call(this, r, F); + } + function B(F) { + bubble$1.call(this, r, F); + } + function P(F) { + bubble$1.call(this, r, F); + } + function z(F) { + binding_callbacks$2[F ? "unshift" : "push"](() => { + n = F, t(7, n); + }); + } + return r.$$set = (F) => { + "filetype" in F && t(0, _ = F.filetype), "dragging" in F && t(11, x = F.dragging), "boundedheight" in F && t(1, h = F.boundedheight), "center" in F && t(2, u = F.center), "flex" in F && t(3, E = F.flex), "file_count" in F && t(4, c = F.file_count), "disable_click" in F && t(12, C = F.disable_click), "root" in F && t(13, b = F.root), "hidden" in F && t(5, A = F.hidden), "$$scope" in F && t(15, f = F.$$scope); + }, [ + _, + h, + u, + E, + c, + A, + p, + n, + w, + l, + g, + x, + C, + b, + a, + f, + s, + M, + L, + T, + D, + R, + B, + P, + z + ]; +} +class Upload extends SvelteComponent$8 { + constructor(e) { + super(), init$8(this, e, instance$7, create_fragment$8, safe_not_equal$8, { + filetype: 0, + dragging: 11, + boundedheight: 1, + center: 2, + flex: 3, + file_count: 4, + disable_click: 12, + root: 13, + hidden: 5, + open_file_upload: 6, + load_files: 14 + }); + } + get open_file_upload() { + return this.$$.ctx[6]; + } + get load_files() { + return this.$$.ctx[14]; + } +} +const ModifyUpload_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$7, + append: append$6, + attr: attr$6, + check_outros: check_outros$4, + create_component: create_component$4, + destroy_component: destroy_component$4, + detach: detach$7, + element: element$5, + group_outros: group_outros$4, + init: init$7, + insert: insert$7, + mount_component: mount_component$4, + safe_not_equal: safe_not_equal$7, + set_style: set_style$2, + space: space$4, + toggle_class: toggle_class$3, + transition_in: transition_in$4, + transition_out: transition_out$4 +} = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$2 } = window.__gradio__svelte__internal; +function create_if_block_1$3(r) { + let e, t; + return e = new IconButton({ + props: { + Icon: Edit, + label: ( + /*i18n*/ + r[3]("common.edit") + ) + } + }), e.$on( + "click", + /*click_handler*/ + r[5] + ), { + c() { + create_component$4(e.$$.fragment); + }, + m(s, f) { + mount_component$4(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f & /*i18n*/ + 8 && (_.label = /*i18n*/ + s[3]("common.edit")), e.$set(_); + }, + i(s) { + t || (transition_in$4(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out$4(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component$4(e, s); + } + }; +} +function create_if_block$4(r) { + let e, t; + return e = new IconButton({ + props: { + Icon: Undo, + label: ( + /*i18n*/ + r[3]("common.undo") + ) + } + }), e.$on( + "click", + /*click_handler_1*/ + r[6] + ), { + c() { + create_component$4(e.$$.fragment); + }, + m(s, f) { + mount_component$4(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f & /*i18n*/ + 8 && (_.label = /*i18n*/ + s[3]("common.undo")), e.$set(_); + }, + i(s) { + t || (transition_in$4(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out$4(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component$4(e, s); + } + }; +} +function create_fragment$7(r) { + let e, t, s, f, _, x = ( + /*editable*/ + r[0] && create_if_block_1$3(r) + ), h = ( + /*undoable*/ + r[1] && create_if_block$4(r) + ); + return f = new IconButton({ + props: { + Icon: Clear, + label: ( + /*i18n*/ + r[3]("common.clear") + ) + } + }), f.$on( + "click", + /*click_handler_2*/ + r[7] + ), { + c() { + e = element$5("div"), x && x.c(), t = space$4(), h && h.c(), s = space$4(), create_component$4(f.$$.fragment), attr$6(e, "class", "svelte-1wj0ocy"), toggle_class$3(e, "not-absolute", !/*absolute*/ + r[2]), set_style$2( + e, + "position", + /*absolute*/ + r[2] ? "absolute" : "static" + ); + }, + m(u, E) { + insert$7(u, e, E), x && x.m(e, null), append$6(e, t), h && h.m(e, null), append$6(e, s), mount_component$4(f, e, null), _ = !0; + }, + p(u, [E]) { + /*editable*/ + u[0] ? x ? (x.p(u, E), E & /*editable*/ + 1 && transition_in$4(x, 1)) : (x = create_if_block_1$3(u), x.c(), transition_in$4(x, 1), x.m(e, t)) : x && (group_outros$4(), transition_out$4(x, 1, 1, () => { + x = null; + }), check_outros$4()), /*undoable*/ + u[1] ? h ? (h.p(u, E), E & /*undoable*/ + 2 && transition_in$4(h, 1)) : (h = create_if_block$4(u), h.c(), transition_in$4(h, 1), h.m(e, s)) : h && (group_outros$4(), transition_out$4(h, 1, 1, () => { + h = null; + }), check_outros$4()); + const c = {}; + E & /*i18n*/ + 8 && (c.label = /*i18n*/ + u[3]("common.clear")), f.$set(c), (!_ || E & /*absolute*/ + 4) && toggle_class$3(e, "not-absolute", !/*absolute*/ + u[2]), E & /*absolute*/ + 4 && set_style$2( + e, + "position", + /*absolute*/ + u[2] ? "absolute" : "static" + ); + }, + i(u) { + _ || (transition_in$4(x), transition_in$4(h), transition_in$4(f.$$.fragment, u), _ = !0); + }, + o(u) { + transition_out$4(x), transition_out$4(h), transition_out$4(f.$$.fragment, u), _ = !1; + }, + d(u) { + u && detach$7(e), x && x.d(), h && h.d(), destroy_component$4(f); + } + }; +} +function instance$6(r, e, t) { + let { editable: s = !1 } = e, { undoable: f = !1 } = e, { absolute: _ = !0 } = e, { i18n: x } = e; + const h = createEventDispatcher$2(), u = () => h("edit"), E = () => h("undo"), c = (C) => { + h("clear"), C.stopPropagation(); + }; + return r.$$set = (C) => { + "editable" in C && t(0, s = C.editable), "undoable" in C && t(1, f = C.undoable), "absolute" in C && t(2, _ = C.absolute), "i18n" in C && t(3, x = C.i18n); + }, [ + s, + f, + _, + x, + h, + u, + E, + c + ]; +} +class ModifyUpload extends SvelteComponent$7 { + constructor(e) { + super(), init$7(this, e, instance$6, create_fragment$7, safe_not_equal$7, { + editable: 0, + undoable: 1, + absolute: 2, + i18n: 3 + }); + } +} +const { + SvelteComponent: SvelteComponent$6, + append: append$5, + attr: attr$5, + detach: detach$6, + init: init$6, + insert: insert$6, + noop: noop$4, + safe_not_equal: safe_not_equal$6, + svg_element: svg_element$2 +} = window.__gradio__svelte__internal; +function create_fragment$6(r) { + let e, t, s, f, _, x, h, u, E, c, C, b; + return { + c() { + e = svg_element$2("svg"), t = svg_element$2("defs"), s = svg_element$2("linearGradient"), f = svg_element$2("stop"), _ = svg_element$2("stop"), x = svg_element$2("stop"), h = svg_element$2("g"), u = svg_element$2("g"), E = svg_element$2("path"), c = svg_element$2("animateTransform"), C = svg_element$2("circle"), b = svg_element$2("animateTransform"), attr$5(f, "stop-color", "#FF7C00"), attr$5(f, "stop-opacity", "0"), attr$5(f, "offset", "0%"), attr$5(_, "stop-color", "#FF7C00"), attr$5(_, "stop-opacity", ".631"), attr$5(_, "offset", "63.146%"), attr$5(x, "stop-color", "#FF7C00"), attr$5(x, "offset", "100%"), attr$5(s, "x1", "8.042%"), attr$5(s, "y1", "0%"), attr$5(s, "x2", "65.682%"), attr$5(s, "y2", "23.865%"), attr$5(s, "id", "a"), attr$5(c, "attributeName", "transform"), attr$5(c, "type", "rotate"), attr$5(c, "from", "0 18 18"), attr$5(c, "to", "360 18 18"), attr$5(c, "dur", "0.9s"), attr$5(c, "repeatCount", "indefinite"), attr$5(E, "d", "M36 18c0-9.94-8.06-18-18-18"), attr$5(E, "id", "Oval-2"), attr$5(E, "stroke", "url(#a)"), attr$5(E, "stroke-width", "2"), attr$5(b, "attributeName", "transform"), attr$5(b, "type", "rotate"), attr$5(b, "from", "0 18 18"), attr$5(b, "to", "360 18 18"), attr$5(b, "dur", "0.9s"), attr$5(b, "repeatCount", "indefinite"), attr$5(C, "fill", "#FFf"), attr$5(C, "cx", "36"), attr$5(C, "cy", "18"), attr$5(C, "r", "1"), attr$5(u, "transform", "translate(1 1)"), attr$5(h, "fill", "none"), attr$5(h, "fill-rule", "evenodd"), attr$5(e, "width", "20"), attr$5(e, "height", "20 "), attr$5(e, "viewBox", "0 0 38 38"), attr$5(e, "xmlns", "http://www.w3.org/2000/svg"); + }, + m(A, S) { + insert$6(A, e, S), append$5(e, t), append$5(t, s), append$5(s, f), append$5(s, _), append$5(s, x), append$5(e, h), append$5(h, u), append$5(u, E), append$5(E, c), append$5(u, C), append$5(C, b); + }, + p: noop$4, + i: noop$4, + o: noop$4, + d(A) { + A && detach$6(e); + } + }; +} +class Loading_spinner extends SvelteComponent$6 { + constructor(e) { + super(), init$6(this, e, null, create_fragment$6, safe_not_equal$6, {}); + } +} +const FileRetrieval_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$5, + append: append$4, + attr: attr$4, + check_outros: check_outros$3, + create_component: create_component$3, + destroy_component: destroy_component$3, + detach: detach$5, + element: element$4, + group_outros: group_outros$3, + init: init$5, + insert: insert$5, + listen, + mount_component: mount_component$3, + noop: noop$3, + run_all, + safe_not_equal: safe_not_equal$5, + set_input_value, + space: space$3, + transition_in: transition_in$3, + transition_out: transition_out$3 +} = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$1, tick: tick$2, getContext } = window.__gradio__svelte__internal; +function create_else_block$3(r) { + let e; + return { + c() { + e = element$4("span"), e.textContent = "Fetch"; + }, + m(t, s) { + insert$5(t, e, s); + }, + i: noop$3, + o: noop$3, + d(t) { + t && detach$5(e); + } + }; +} +function create_if_block$3(r) { + let e, t; + return e = new Loading_spinner({}), { + c() { + create_component$3(e.$$.fragment); + }, + m(s, f) { + mount_component$3(e, s, f), t = !0; + }, + i(s) { + t || (transition_in$3(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out$3(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component$3(e, s); + } + }; +} +function create_fragment$5(r) { + let e, t, s, f, _, x, h, u, E, c, C, b, A, S, n, o, w, p; + const v = [create_if_block$3, create_else_block$3], a = []; + function l(g, M) { + return ( + /*loading*/ + g[1] ? 0 : 1 + ); + } + return b = l(r), A = a[b] = v[b](r), { + c() { + e = element$4("div"), t = element$4("div"), s = element$4("input"), f = space$3(), _ = element$4("select"), x = element$4("option"), x.textContent = "PDB Assym. Unit", h = element$4("option"), h.textContent = "PDB BioAssembly", u = element$4("option"), u.textContent = "AlphaFold DB", E = element$4("option"), E.textContent = "ESMFold DB", c = space$3(), C = element$4("button"), A.c(), S = space$3(), n = element$4("span"), n.textContent = "- or -", attr$4(s, "type", "text"), attr$4( + s, + "placeholder", + /*placeholder*/ + r[2] + ), attr$4(s, "class", "wfull inp svelte-18kpwjt"), x.__value = "pdb_assym", set_input_value(x, x.__value), h.__value = "pdb_bioass", set_input_value(h, h.__value), u.__value = "af", set_input_value(u, u.__value), E.__value = "esm", set_input_value(E, E.__value), attr$4(_, "name", ""), attr$4(_, "id", ""), attr$4(_, "class", "select svelte-18kpwjt"), attr$4(t, "class", "flex input wfull svelte-18kpwjt"), attr$4(C, "class", "btn text-center svelte-18kpwjt"), attr$4(e, "class", "flex mt-2 svelte-18kpwjt"), attr$4(n, "class", "or py svelte-18kpwjt"); + }, + m(g, M) { + insert$5(g, e, M), append$4(e, t), append$4(t, s), set_input_value( + s, + /*textInput*/ + r[3] + ), append$4(t, f), append$4(t, _), append$4(_, x), append$4(_, h), append$4(_, u), append$4(_, E), append$4(e, c), append$4(e, C), a[b].m(C, null), insert$5(g, S, M), insert$5(g, n, M), o = !0, w || (p = [ + listen( + s, + "input", + /*input_input_handler*/ + r[8] + ), + listen( + s, + "keydown", + /*isEnterPressed*/ + r[6] + ), + listen( + _, + "change", + /*handleSelect*/ + r[5] + ), + listen( + C, + "click", + /*click_handler*/ + r[9] + ) + ], w = !0); + }, + p(g, [M]) { + (!o || M & /*placeholder*/ + 4) && attr$4( + s, + "placeholder", + /*placeholder*/ + g[2] + ), M & /*textInput*/ + 8 && s.value !== /*textInput*/ + g[3] && set_input_value( + s, + /*textInput*/ + g[3] + ); + let L = b; + b = l(g), b !== L && (group_outros$3(), transition_out$3(a[L], 1, 1, () => { + a[L] = null; + }), check_outros$3(), A = a[b], A || (A = a[b] = v[b](g), A.c()), transition_in$3(A, 1), A.m(C, null)); + }, + i(g) { + o || (transition_in$3(A), o = !0); + }, + o(g) { + transition_out$3(A), o = !1; + }, + d(g) { + g && (detach$5(e), detach$5(S), detach$5(n)), a[b].d(), w = !1, run_all(p); + } + }; +} +function instance$5(r, e, t) { + let s; + const f = createEventDispatcher$1(); + let { root: _ } = e; + const x = getContext("upload_files"); + async function h(p) { + await tick$2(), s = await upload(p, _, x), s[0].orig_name = p.name, s[0].size = p.size, f("load", s); + } + let u = !1; + async function E(p, v) { + let a = { + pdb_assym: { + url: "https://files.rcsb.org/view/", + ext: ".pdb" + }, + pdb_bioass: { + url: "https://files.rcsb.org/view/", + ext: ".pdb1" + }, + af: { + url: "https://alphafold.ebi.ac.uk/files/AF-", + ext: "-F1-model_v4.pdb" + }, + esm: { + url: "https://api.esmatlas.com/fetchPredictedStructure/", + ext: ".pdb" + } + }, l = a[v].url, g = a[v].ext; + t(1, u = !0); + let M = null; + try { + M = await fetch(l + p + g).then((T) => { + if (t(1, u = !1), T.status == 200) { + let D = T.blob(); + return D.name = p + g, D; + } else + f("notfound"); + }); + } catch { + t(1, u = !1), f("notfound"); + } + let L = { + name: p + ".pdb", + size: M.size, + data: "", + blob: M + }; + await h(L); + } + let c = "pdb_assym", C = "", b = ""; + function A(p) { + t(0, c = p.target.value); + } + let S = { + pdb_assym: "Enter PDB identifier", + pdb_bioass: "Enter PDB identifier", + af: "Enter UniProt identifier", + esm: "Enter MGnify protein identifier" + }; + function n(p) { + p.key === "Enter" && E(b, c); + } + function o() { + b = this.value, t(3, b); + } + const w = () => E(b, c); + return r.$$set = (p) => { + "root" in p && t(7, _ = p.root); + }, r.$$.update = () => { + r.$$.dirty & /*selectedValue*/ + 1 && t(2, C = S[c]); + }, [ + c, + u, + C, + b, + E, + A, + n, + _, + o, + w + ]; +} +class FileRetrieval extends SvelteComponent$5 { + constructor(e) { + super(), init$5(this, e, instance$5, create_fragment$5, safe_not_equal$5, { root: 7 }); + } +} +const { + SvelteComponent: SvelteComponent$4, + add_flush_callback, + bind, + binding_callbacks: binding_callbacks$1, + bubble, + check_outros: check_outros$2, + create_component: create_component$2, + create_slot: create_slot$1, + destroy_component: destroy_component$2, + detach: detach$4, + empty: empty$2, + get_all_dirty_from_scope: get_all_dirty_from_scope$1, + get_slot_changes: get_slot_changes$1, + group_outros: group_outros$2, + init: init$4, + insert: insert$4, + mount_component: mount_component$2, + safe_not_equal: safe_not_equal$4, + space: space$2, + transition_in: transition_in$2, + transition_out: transition_out$2, + update_slot_base: update_slot_base$1 +} = window.__gradio__svelte__internal, { createEventDispatcher, tick: tick$1 } = window.__gradio__svelte__internal; +function create_else_block$2(r) { + let e, t, s, f, _; + e = new FileRetrieval({ props: { root: ( + /*root*/ + r[5] + ) } }), e.$on( + "load", + /*handle_upload*/ + r[14] + ), e.$on( + "notfound", + /*notfound_handler*/ + r[20] + ); + function x(u) { + r[21](u); + } + let h = { + filetype: ( + /*accept_file_types*/ + r[13] + ), + file_count: ( + /*file_count*/ + r[3] + ), + root: ( + /*root*/ + r[5] + ), + $$slots: { default: [create_default_slot$1] }, + $$scope: { ctx: r } + }; + return ( + /*dragging*/ + r[12] !== void 0 && (h.dragging = /*dragging*/ + r[12]), s = new Upload({ props: h }), binding_callbacks$1.push(() => bind(s, "dragging", x)), s.$on( + "load", + /*handle_upload*/ + r[14] + ), { + c() { + create_component$2(e.$$.fragment), t = space$2(), create_component$2(s.$$.fragment); + }, + m(u, E) { + mount_component$2(e, u, E), insert$4(u, t, E), mount_component$2(s, u, E), _ = !0; + }, + p(u, E) { + const c = {}; + E & /*root*/ + 32 && (c.root = /*root*/ + u[5]), e.$set(c); + const C = {}; + E & /*accept_file_types*/ + 8192 && (C.filetype = /*accept_file_types*/ + u[13]), E & /*file_count*/ + 8 && (C.file_count = /*file_count*/ + u[3]), E & /*root*/ + 32 && (C.root = /*root*/ + u[5]), E & /*$$scope*/ + 4194304 && (C.$$scope = { dirty: E, ctx: u }), !f && E & /*dragging*/ + 4096 && (f = !0, C.dragging = /*dragging*/ + u[12], add_flush_callback(() => f = !1)), s.$set(C); + }, + i(u) { + _ || (transition_in$2(e.$$.fragment, u), transition_in$2(s.$$.fragment, u), _ = !0); + }, + o(u) { + transition_out$2(e.$$.fragment, u), transition_out$2(s.$$.fragment, u), _ = !1; + }, + d(u) { + u && detach$4(t), destroy_component$2(e, u), destroy_component$2(s, u); + } + } + ); +} +function create_if_block$2(r) { + let e, t, s, f, _, x; + e = new ModifyUpload({ + props: { i18n: ( + /*i18n*/ + r[7] + ), absolute: !0 } + }), e.$on( + "clear", + /*handle_clear*/ + r[15] + ), s = new FilePreview({ + props: { + i18n: ( + /*i18n*/ + r[7] + ), + selectable: ( + /*selectable*/ + r[4] + ), + value: ( + /*value*/ + r[0] + ), + height: ( + /*height*/ + r[6] + ) + } + }), s.$on( + "select", + /*select_handler*/ + r[19] + ); + let h = ( + /*moldata*/ + r[11] != null && create_if_block_1$2(r) + ); + return { + c() { + create_component$2(e.$$.fragment), t = space$2(), create_component$2(s.$$.fragment), f = space$2(), h && h.c(), _ = empty$2(); + }, + m(u, E) { + mount_component$2(e, u, E), insert$4(u, t, E), mount_component$2(s, u, E), insert$4(u, f, E), h && h.m(u, E), insert$4(u, _, E), x = !0; + }, + p(u, E) { + const c = {}; + E & /*i18n*/ + 128 && (c.i18n = /*i18n*/ + u[7]), e.$set(c); + const C = {}; + E & /*i18n*/ + 128 && (C.i18n = /*i18n*/ + u[7]), E & /*selectable*/ + 16 && (C.selectable = /*selectable*/ + u[4]), E & /*value*/ + 1 && (C.value = /*value*/ + u[0]), E & /*height*/ + 64 && (C.height = /*height*/ + u[6]), s.$set(C), /*moldata*/ + u[11] != null ? h ? (h.p(u, E), E & /*moldata*/ + 2048 && transition_in$2(h, 1)) : (h = create_if_block_1$2(u), h.c(), transition_in$2(h, 1), h.m(_.parentNode, _)) : h && (group_outros$2(), transition_out$2(h, 1, 1, () => { + h = null; + }), check_outros$2()); + }, + i(u) { + x || (transition_in$2(e.$$.fragment, u), transition_in$2(s.$$.fragment, u), transition_in$2(h), x = !0); + }, + o(u) { + transition_out$2(e.$$.fragment, u), transition_out$2(s.$$.fragment, u), transition_out$2(h), x = !1; + }, + d(u) { + u && (detach$4(t), detach$4(f), detach$4(_)), destroy_component$2(e, u), destroy_component$2(s, u), h && h.d(u); + } + }; +} +function create_default_slot$1(r) { + let e; + const t = ( + /*#slots*/ + r[18].default + ), s = create_slot$1( + t, + r, + /*$$scope*/ + r[22], + null + ); + return { + c() { + s && s.c(); + }, + m(f, _) { + s && s.m(f, _), e = !0; + }, + p(f, _) { + s && s.p && (!e || _ & /*$$scope*/ + 4194304) && update_slot_base$1( + s, + t, + f, + /*$$scope*/ + f[22], + e ? get_slot_changes$1( + t, + /*$$scope*/ + f[22], + _, + null + ) : get_all_dirty_from_scope$1( + /*$$scope*/ + f[22] + ), + null + ); + }, + i(f) { + e || (transition_in$2(s, f), e = !0); + }, + o(f) { + transition_out$2(s, f), e = !1; + }, + d(f) { + s && s.d(f); + } + }; +} +function create_if_block_1$2(r) { + let e, t; + return e = new MolecularViewer({ + props: { + moldata: ( + /*moldata*/ + r[11] + ), + config: ( + /*config*/ + r[8] + ), + confidenceLabel: ( + /*confidenceLabel*/ + r[9] + ), + representations: ( + /*representations*/ + r[10] + ) + } + }), { + c() { + create_component$2(e.$$.fragment); + }, + m(s, f) { + mount_component$2(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f & /*moldata*/ + 2048 && (_.moldata = /*moldata*/ + s[11]), f & /*config*/ + 256 && (_.config = /*config*/ + s[8]), f & /*confidenceLabel*/ + 512 && (_.confidenceLabel = /*confidenceLabel*/ + s[9]), f & /*representations*/ + 1024 && (_.representations = /*representations*/ + s[10]), e.$set(_); + }, + i(s) { + t || (transition_in$2(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out$2(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component$2(e, s); + } + }; +} +function create_fragment$4(r) { + let e, t, s, f, _, x; + e = new BlockLabel({ + props: { + show_label: ( + /*show_label*/ + r[2] + ), + Icon: File$1, + float: ( + /*value*/ + r[0] === null + ), + label: ( + /*label*/ + r[1] || "File" + ) + } + }); + const h = [create_if_block$2, create_else_block$2], u = []; + function E(c, C) { + return ( + /*value*/ + c[0] ? 0 : 1 + ); + } + return s = E(r), f = u[s] = h[s](r), { + c() { + create_component$2(e.$$.fragment), t = space$2(), f.c(), _ = empty$2(); + }, + m(c, C) { + mount_component$2(e, c, C), insert$4(c, t, C), u[s].m(c, C), insert$4(c, _, C), x = !0; + }, + p(c, [C]) { + const b = {}; + C & /*show_label*/ + 4 && (b.show_label = /*show_label*/ + c[2]), C & /*value*/ + 1 && (b.float = /*value*/ + c[0] === null), C & /*label*/ + 2 && (b.label = /*label*/ + c[1] || "File"), e.$set(b); + let A = s; + s = E(c), s === A ? u[s].p(c, C) : (group_outros$2(), transition_out$2(u[A], 1, 1, () => { + u[A] = null; + }), check_outros$2(), f = u[s], f ? f.p(c, C) : (f = u[s] = h[s](c), f.c()), transition_in$2(f, 1), f.m(_.parentNode, _)); + }, + i(c) { + x || (transition_in$2(e.$$.fragment, c), transition_in$2(f), x = !0); + }, + o(c) { + transition_out$2(e.$$.fragment, c), transition_out$2(f), x = !1; + }, + d(c) { + c && (detach$4(t), detach$4(_)), destroy_component$2(e, c), u[s].d(c); + } + }; +} +function instance$4(r, e, t) { + let { $$slots: s = {}, $$scope: f } = e, { value: _ } = e, { label: x } = e, { show_label: h = !0 } = e, { file_count: u = "single" } = e, { file_types: E = null } = e, { selectable: c = !1 } = e, { root: C } = e, { height: b = void 0 } = e, { i18n: A } = e, { config: S = {} } = e, { confidenceLabel: n = "" } = e, { representations: o = [] } = e, { moldata: w = null } = e; + async function p({ detail: D }) { + t(0, _ = D), await tick$1(), a("change", _), a("upload", D); + } + function v() { + t(0, _ = null), a("change", null), a("clear"); + } + const a = createEventDispatcher(); + let l; + E == null ? l = null : (E = E.map((D) => D.startsWith(".") ? D : D + "/*"), l = E.join(", ")); + let g = !1; + function M(D) { + bubble.call(this, r, D); + } + const L = () => a("notfound"); + function T(D) { + g = D, t(12, g); + } + return r.$$set = (D) => { + "value" in D && t(0, _ = D.value), "label" in D && t(1, x = D.label), "show_label" in D && t(2, h = D.show_label), "file_count" in D && t(3, u = D.file_count), "file_types" in D && t(17, E = D.file_types), "selectable" in D && t(4, c = D.selectable), "root" in D && t(5, C = D.root), "height" in D && t(6, b = D.height), "i18n" in D && t(7, A = D.i18n), "config" in D && t(8, S = D.config), "confidenceLabel" in D && t(9, n = D.confidenceLabel), "representations" in D && t(10, o = D.representations), "moldata" in D && t(11, w = D.moldata), "$$scope" in D && t(22, f = D.$$scope); + }, r.$$.update = () => { + r.$$.dirty & /*dragging*/ + 4096 && a("drag", g); + }, [ + _, + x, + h, + u, + c, + C, + b, + A, + S, + n, + o, + w, + g, + l, + p, + v, + a, + E, + s, + M, + L, + T, + f + ]; +} +class FileUpload extends SvelteComponent$4 { + constructor(e) { + super(), init$4(this, e, instance$4, create_fragment$4, safe_not_equal$4, { + value: 0, + label: 1, + show_label: 2, + file_count: 3, + file_types: 17, + selectable: 4, + root: 5, + height: 6, + i18n: 7, + config: 8, + confidenceLabel: 9, + representations: 10, + moldata: 11 + }); + } +} +function pretty_si(r) { + let e = ["", "k", "M", "G", "T", "P", "E", "Z"], t = 0; + for (; r > 1e3 && t < e.length - 1; ) + r /= 1e3, t++; + let s = e[t]; + return (Number.isInteger(r) ? r : r.toFixed(1)) + s; +} +const Loader_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$3, + append: append$3, + attr: attr$3, + component_subscribe, + detach: detach$3, + element: element$3, + init: init$3, + insert: insert$3, + noop: noop$2, + safe_not_equal: safe_not_equal$3, + set_style: set_style$1, + svg_element: svg_element$1, + toggle_class: toggle_class$2 +} = window.__gradio__svelte__internal, { onMount } = window.__gradio__svelte__internal; +function create_fragment$3(r) { + let e, t, s, f, _, x, h, u, E, c, C, b; + return { + c() { + e = element$3("div"), t = svg_element$1("svg"), s = svg_element$1("g"), f = svg_element$1("path"), _ = svg_element$1("path"), x = svg_element$1("path"), h = svg_element$1("path"), u = svg_element$1("g"), E = svg_element$1("path"), c = svg_element$1("path"), C = svg_element$1("path"), b = svg_element$1("path"), attr$3(f, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), attr$3(f, "fill", "#FF7C00"), attr$3(f, "fill-opacity", "0.4"), attr$3(f, "class", "svelte-43sxxs"), attr$3(_, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), attr$3(_, "fill", "#FF7C00"), attr$3(_, "class", "svelte-43sxxs"), attr$3(x, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), attr$3(x, "fill", "#FF7C00"), attr$3(x, "fill-opacity", "0.4"), attr$3(x, "class", "svelte-43sxxs"), attr$3(h, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), attr$3(h, "fill", "#FF7C00"), attr$3(h, "class", "svelte-43sxxs"), set_style$1(s, "transform", "translate(" + /*$top*/ + r[1][0] + "px, " + /*$top*/ + r[1][1] + "px)"), attr$3(E, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), attr$3(E, "fill", "#FF7C00"), attr$3(E, "fill-opacity", "0.4"), attr$3(E, "class", "svelte-43sxxs"), attr$3(c, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), attr$3(c, "fill", "#FF7C00"), attr$3(c, "class", "svelte-43sxxs"), attr$3(C, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), attr$3(C, "fill", "#FF7C00"), attr$3(C, "fill-opacity", "0.4"), attr$3(C, "class", "svelte-43sxxs"), attr$3(b, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), attr$3(b, "fill", "#FF7C00"), attr$3(b, "class", "svelte-43sxxs"), set_style$1(u, "transform", "translate(" + /*$bottom*/ + r[2][0] + "px, " + /*$bottom*/ + r[2][1] + "px)"), attr$3(t, "viewBox", "-1200 -1200 3000 3000"), attr$3(t, "fill", "none"), attr$3(t, "xmlns", "http://www.w3.org/2000/svg"), attr$3(t, "class", "svelte-43sxxs"), attr$3(e, "class", "svelte-43sxxs"), toggle_class$2( + e, + "margin", + /*margin*/ + r[0] + ); + }, + m(A, S) { + insert$3(A, e, S), append$3(e, t), append$3(t, s), append$3(s, f), append$3(s, _), append$3(s, x), append$3(s, h), append$3(t, u), append$3(u, E), append$3(u, c), append$3(u, C), append$3(u, b); + }, + p(A, [S]) { + S & /*$top*/ + 2 && set_style$1(s, "transform", "translate(" + /*$top*/ + A[1][0] + "px, " + /*$top*/ + A[1][1] + "px)"), S & /*$bottom*/ + 4 && set_style$1(u, "transform", "translate(" + /*$bottom*/ + A[2][0] + "px, " + /*$bottom*/ + A[2][1] + "px)"), S & /*margin*/ + 1 && toggle_class$2( + e, + "margin", + /*margin*/ + A[0] + ); + }, + i: noop$2, + o: noop$2, + d(A) { + A && detach$3(e); + } + }; +} +function instance$3(r, e, t) { + let s, f, { margin: _ = !0 } = e; + const x = spring([0, 0]); + component_subscribe(r, x, (b) => t(1, s = b)); + const h = spring([0, 0]); + component_subscribe(r, h, (b) => t(2, f = b)); + let u; + async function E() { + await Promise.all([x.set([125, 140]), h.set([-125, -140])]), await Promise.all([x.set([-125, 140]), h.set([125, -140])]), await Promise.all([x.set([-125, 0]), h.set([125, -0])]), await Promise.all([x.set([125, 0]), h.set([-125, 0])]); + } + async function c() { + await E(), u || c(); + } + async function C() { + await Promise.all([x.set([125, 0]), h.set([-125, 0])]), c(); + } + return onMount(() => (C(), () => u = !0)), r.$$set = (b) => { + "margin" in b && t(0, _ = b.margin); + }, [_, s, f, x, h]; +} +class Loader extends SvelteComponent$3 { + constructor(e) { + super(), init$3(this, e, instance$3, create_fragment$3, safe_not_equal$3, { margin: 0 }); + } +} +const index_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$2, + append: append$2, + attr: attr$2, + binding_callbacks, + check_outros: check_outros$1, + create_component: create_component$1, + create_slot, + destroy_component: destroy_component$1, + destroy_each: destroy_each$1, + detach: detach$2, + element: element$2, + empty: empty$1, + ensure_array_like: ensure_array_like$1, + get_all_dirty_from_scope, + get_slot_changes, + group_outros: group_outros$1, + init: init$2, + insert: insert$2, + mount_component: mount_component$1, + noop: noop$1, + safe_not_equal: safe_not_equal$2, + set_data: set_data$2, + set_style, + space: space$1, + text: text$2, + toggle_class: toggle_class$1, + transition_in: transition_in$1, + transition_out: transition_out$1, + update_slot_base +} = window.__gradio__svelte__internal, { tick } = window.__gradio__svelte__internal, { onDestroy } = window.__gradio__svelte__internal, get_error_slot_changes = (r) => ({}), get_error_slot_context = (r) => ({}); +function get_each_context$1(r, e, t) { + const s = r.slice(); + return s[38] = e[t], s[40] = t, s; +} +function get_each_context_1(r, e, t) { + const s = r.slice(); + return s[38] = e[t], s; +} +function create_if_block_17(r) { + let e, t = ( + /*i18n*/ + r[1]("common.error") + "" + ), s, f, _; + const x = ( + /*#slots*/ + r[29].error + ), h = create_slot( + x, + r, + /*$$scope*/ + r[28], + get_error_slot_context + ); + return { + c() { + e = element$2("span"), s = text$2(t), f = space$1(), h && h.c(), attr$2(e, "class", "error svelte-14miwb5"); + }, + m(u, E) { + insert$2(u, e, E), append$2(e, s), insert$2(u, f, E), h && h.m(u, E), _ = !0; + }, + p(u, E) { + (!_ || E[0] & /*i18n*/ + 2) && t !== (t = /*i18n*/ + u[1]("common.error") + "") && set_data$2(s, t), h && h.p && (!_ || E[0] & /*$$scope*/ + 268435456) && update_slot_base( + h, + x, + u, + /*$$scope*/ + u[28], + _ ? get_slot_changes( + x, + /*$$scope*/ + u[28], + E, + get_error_slot_changes + ) : get_all_dirty_from_scope( + /*$$scope*/ + u[28] + ), + get_error_slot_context + ); + }, + i(u) { + _ || (transition_in$1(h, u), _ = !0); + }, + o(u) { + transition_out$1(h, u), _ = !1; + }, + d(u) { + u && (detach$2(e), detach$2(f)), h && h.d(u); + } + }; +} +function create_if_block$1(r) { + let e, t, s, f, _, x, h, u, E, c = ( + /*variant*/ + r[8] === "default" && /*show_eta_bar*/ + r[18] && /*show_progress*/ + r[6] === "full" && create_if_block_16(r) + ); + function C(v, a) { + if ( + /*progress*/ + v[7] + ) + return create_if_block_11; + if ( + /*queue_position*/ + v[2] !== null && /*queue_size*/ + v[3] !== void 0 && /*queue_position*/ + v[2] >= 0 + ) + return create_if_block_14; + if ( + /*queue_position*/ + v[2] === 0 + ) + return create_if_block_15; + } + let b = C(r), A = b && b(r), S = ( + /*timer*/ + r[5] && create_if_block_10(r) + ); + const n = [create_if_block_2, create_if_block_9], o = []; + function w(v, a) { + return ( + /*last_progress_level*/ + v[15] != null ? 0 : ( + /*show_progress*/ + v[6] === "full" ? 1 : -1 + ) + ); + } + ~(_ = w(r)) && (x = o[_] = n[_](r)); + let p = !/*timer*/ + r[5] && create_if_block_1$1(r); + return { + c() { + c && c.c(), e = space$1(), t = element$2("div"), A && A.c(), s = space$1(), S && S.c(), f = space$1(), x && x.c(), h = space$1(), p && p.c(), u = empty$1(), attr$2(t, "class", "progress-text svelte-14miwb5"), toggle_class$1( + t, + "meta-text-center", + /*variant*/ + r[8] === "center" + ), toggle_class$1( + t, + "meta-text", + /*variant*/ + r[8] === "default" + ); + }, + m(v, a) { + c && c.m(v, a), insert$2(v, e, a), insert$2(v, t, a), A && A.m(t, null), append$2(t, s), S && S.m(t, null), insert$2(v, f, a), ~_ && o[_].m(v, a), insert$2(v, h, a), p && p.m(v, a), insert$2(v, u, a), E = !0; + }, + p(v, a) { + /*variant*/ + v[8] === "default" && /*show_eta_bar*/ + v[18] && /*show_progress*/ + v[6] === "full" ? c ? c.p(v, a) : (c = create_if_block_16(v), c.c(), c.m(e.parentNode, e)) : c && (c.d(1), c = null), b === (b = C(v)) && A ? A.p(v, a) : (A && A.d(1), A = b && b(v), A && (A.c(), A.m(t, s))), /*timer*/ + v[5] ? S ? S.p(v, a) : (S = create_if_block_10(v), S.c(), S.m(t, null)) : S && (S.d(1), S = null), (!E || a[0] & /*variant*/ + 256) && toggle_class$1( + t, + "meta-text-center", + /*variant*/ + v[8] === "center" + ), (!E || a[0] & /*variant*/ + 256) && toggle_class$1( + t, + "meta-text", + /*variant*/ + v[8] === "default" + ); + let l = _; + _ = w(v), _ === l ? ~_ && o[_].p(v, a) : (x && (group_outros$1(), transition_out$1(o[l], 1, 1, () => { + o[l] = null; + }), check_outros$1()), ~_ ? (x = o[_], x ? x.p(v, a) : (x = o[_] = n[_](v), x.c()), transition_in$1(x, 1), x.m(h.parentNode, h)) : x = null), /*timer*/ + v[5] ? p && (p.d(1), p = null) : p ? p.p(v, a) : (p = create_if_block_1$1(v), p.c(), p.m(u.parentNode, u)); + }, + i(v) { + E || (transition_in$1(x), E = !0); + }, + o(v) { + transition_out$1(x), E = !1; + }, + d(v) { + v && (detach$2(e), detach$2(t), detach$2(f), detach$2(h), detach$2(u)), c && c.d(v), A && A.d(), S && S.d(), ~_ && o[_].d(v), p && p.d(v); + } + }; +} +function create_if_block_16(r) { + let e, t = `translateX(${/*eta_level*/ + (r[17] || 0) * 100 - 100}%)`; + return { + c() { + e = element$2("div"), attr$2(e, "class", "eta-bar svelte-14miwb5"), set_style(e, "transform", t); + }, + m(s, f) { + insert$2(s, e, f); + }, + p(s, f) { + f[0] & /*eta_level*/ + 131072 && t !== (t = `translateX(${/*eta_level*/ + (s[17] || 0) * 100 - 100}%)`) && set_style(e, "transform", t); + }, + d(s) { + s && detach$2(e); + } + }; +} +function create_if_block_15(r) { + let e; + return { + c() { + e = text$2("processing |"); + }, + m(t, s) { + insert$2(t, e, s); + }, + p: noop$1, + d(t) { + t && detach$2(e); + } + }; +} +function create_if_block_14(r) { + let e, t = ( + /*queue_position*/ + r[2] + 1 + "" + ), s, f, _, x; + return { + c() { + e = text$2("queue: "), s = text$2(t), f = text$2("/"), _ = text$2( + /*queue_size*/ + r[3] + ), x = text$2(" |"); + }, + m(h, u) { + insert$2(h, e, u), insert$2(h, s, u), insert$2(h, f, u), insert$2(h, _, u), insert$2(h, x, u); + }, + p(h, u) { + u[0] & /*queue_position*/ + 4 && t !== (t = /*queue_position*/ + h[2] + 1 + "") && set_data$2(s, t), u[0] & /*queue_size*/ + 8 && set_data$2( + _, + /*queue_size*/ + h[3] + ); + }, + d(h) { + h && (detach$2(e), detach$2(s), detach$2(f), detach$2(_), detach$2(x)); + } + }; +} +function create_if_block_11(r) { + let e, t = ensure_array_like$1( + /*progress*/ + r[7] + ), s = []; + for (let f = 0; f < t.length; f += 1) + s[f] = create_each_block_1(get_each_context_1(r, t, f)); + return { + c() { + for (let f = 0; f < s.length; f += 1) + s[f].c(); + e = empty$1(); + }, + m(f, _) { + for (let x = 0; x < s.length; x += 1) + s[x] && s[x].m(f, _); + insert$2(f, e, _); + }, + p(f, _) { + if (_[0] & /*progress*/ + 128) { + t = ensure_array_like$1( + /*progress*/ + f[7] + ); + let x; + for (x = 0; x < t.length; x += 1) { + const h = get_each_context_1(f, t, x); + s[x] ? s[x].p(h, _) : (s[x] = create_each_block_1(h), s[x].c(), s[x].m(e.parentNode, e)); + } + for (; x < s.length; x += 1) + s[x].d(1); + s.length = t.length; + } + }, + d(f) { + f && detach$2(e), destroy_each$1(s, f); + } + }; +} +function create_if_block_12(r) { + let e, t = ( + /*p*/ + r[38].unit + "" + ), s, f, _ = " ", x; + function h(c, C) { + return ( + /*p*/ + c[38].length != null ? create_if_block_13 : create_else_block$1 + ); + } + let u = h(r), E = u(r); + return { + c() { + E.c(), e = space$1(), s = text$2(t), f = text$2(" | "), x = text$2(_); + }, + m(c, C) { + E.m(c, C), insert$2(c, e, C), insert$2(c, s, C), insert$2(c, f, C), insert$2(c, x, C); + }, + p(c, C) { + u === (u = h(c)) && E ? E.p(c, C) : (E.d(1), E = u(c), E && (E.c(), E.m(e.parentNode, e))), C[0] & /*progress*/ + 128 && t !== (t = /*p*/ + c[38].unit + "") && set_data$2(s, t); + }, + d(c) { + c && (detach$2(e), detach$2(s), detach$2(f), detach$2(x)), E.d(c); + } + }; +} +function create_else_block$1(r) { + let e = pretty_si( + /*p*/ + r[38].index || 0 + ) + "", t; + return { + c() { + t = text$2(e); + }, + m(s, f) { + insert$2(s, t, f); + }, + p(s, f) { + f[0] & /*progress*/ + 128 && e !== (e = pretty_si( + /*p*/ + s[38].index || 0 + ) + "") && set_data$2(t, e); + }, + d(s) { + s && detach$2(t); + } + }; +} +function create_if_block_13(r) { + let e = pretty_si( + /*p*/ + r[38].index || 0 + ) + "", t, s, f = pretty_si( + /*p*/ + r[38].length + ) + "", _; + return { + c() { + t = text$2(e), s = text$2("/"), _ = text$2(f); + }, + m(x, h) { + insert$2(x, t, h), insert$2(x, s, h), insert$2(x, _, h); + }, + p(x, h) { + h[0] & /*progress*/ + 128 && e !== (e = pretty_si( + /*p*/ + x[38].index || 0 + ) + "") && set_data$2(t, e), h[0] & /*progress*/ + 128 && f !== (f = pretty_si( + /*p*/ + x[38].length + ) + "") && set_data$2(_, f); + }, + d(x) { + x && (detach$2(t), detach$2(s), detach$2(_)); + } + }; +} +function create_each_block_1(r) { + let e, t = ( + /*p*/ + r[38].index != null && create_if_block_12(r) + ); + return { + c() { + t && t.c(), e = empty$1(); + }, + m(s, f) { + t && t.m(s, f), insert$2(s, e, f); + }, + p(s, f) { + /*p*/ + s[38].index != null ? t ? t.p(s, f) : (t = create_if_block_12(s), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null); + }, + d(s) { + s && detach$2(e), t && t.d(s); + } + }; +} +function create_if_block_10(r) { + let e, t = ( + /*eta*/ + r[0] ? `/${/*formatted_eta*/ + r[19]}` : "" + ), s, f; + return { + c() { + e = text$2( + /*formatted_timer*/ + r[20] + ), s = text$2(t), f = text$2("s"); + }, + m(_, x) { + insert$2(_, e, x), insert$2(_, s, x), insert$2(_, f, x); + }, + p(_, x) { + x[0] & /*formatted_timer*/ + 1048576 && set_data$2( + e, + /*formatted_timer*/ + _[20] + ), x[0] & /*eta, formatted_eta*/ + 524289 && t !== (t = /*eta*/ + _[0] ? `/${/*formatted_eta*/ + _[19]}` : "") && set_data$2(s, t); + }, + d(_) { + _ && (detach$2(e), detach$2(s), detach$2(f)); + } + }; +} +function create_if_block_9(r) { + let e, t; + return e = new Loader({ + props: { margin: ( + /*variant*/ + r[8] === "default" + ) } + }), { + c() { + create_component$1(e.$$.fragment); + }, + m(s, f) { + mount_component$1(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f[0] & /*variant*/ + 256 && (_.margin = /*variant*/ + s[8] === "default"), e.$set(_); + }, + i(s) { + t || (transition_in$1(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out$1(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component$1(e, s); + } + }; +} +function create_if_block_2(r) { + let e, t, s, f, _, x = `${/*last_progress_level*/ + r[15] * 100}%`, h = ( + /*progress*/ + r[7] != null && create_if_block_3(r) + ); + return { + c() { + e = element$2("div"), t = element$2("div"), h && h.c(), s = space$1(), f = element$2("div"), _ = element$2("div"), attr$2(t, "class", "progress-level-inner svelte-14miwb5"), attr$2(_, "class", "progress-bar svelte-14miwb5"), set_style(_, "width", x), attr$2(f, "class", "progress-bar-wrap svelte-14miwb5"), attr$2(e, "class", "progress-level svelte-14miwb5"); + }, + m(u, E) { + insert$2(u, e, E), append$2(e, t), h && h.m(t, null), append$2(e, s), append$2(e, f), append$2(f, _), r[30](_); + }, + p(u, E) { + /*progress*/ + u[7] != null ? h ? h.p(u, E) : (h = create_if_block_3(u), h.c(), h.m(t, null)) : h && (h.d(1), h = null), E[0] & /*last_progress_level*/ + 32768 && x !== (x = `${/*last_progress_level*/ + u[15] * 100}%`) && set_style(_, "width", x); + }, + i: noop$1, + o: noop$1, + d(u) { + u && detach$2(e), h && h.d(), r[30](null); + } + }; +} +function create_if_block_3(r) { + let e, t = ensure_array_like$1( + /*progress*/ + r[7] + ), s = []; + for (let f = 0; f < t.length; f += 1) + s[f] = create_each_block$1(get_each_context$1(r, t, f)); + return { + c() { + for (let f = 0; f < s.length; f += 1) + s[f].c(); + e = empty$1(); + }, + m(f, _) { + for (let x = 0; x < s.length; x += 1) + s[x] && s[x].m(f, _); + insert$2(f, e, _); + }, + p(f, _) { + if (_[0] & /*progress_level, progress*/ + 16512) { + t = ensure_array_like$1( + /*progress*/ + f[7] + ); + let x; + for (x = 0; x < t.length; x += 1) { + const h = get_each_context$1(f, t, x); + s[x] ? s[x].p(h, _) : (s[x] = create_each_block$1(h), s[x].c(), s[x].m(e.parentNode, e)); + } + for (; x < s.length; x += 1) + s[x].d(1); + s.length = t.length; + } + }, + d(f) { + f && detach$2(e), destroy_each$1(s, f); + } + }; +} +function create_if_block_4(r) { + let e, t, s, f, _ = ( + /*i*/ + r[40] !== 0 && create_if_block_8() + ), x = ( + /*p*/ + r[38].desc != null && create_if_block_7(r) + ), h = ( + /*p*/ + r[38].desc != null && /*progress_level*/ + r[14] && /*progress_level*/ + r[14][ + /*i*/ + r[40] + ] != null && create_if_block_6() + ), u = ( + /*progress_level*/ + r[14] != null && create_if_block_5(r) + ); + return { + c() { + _ && _.c(), e = space$1(), x && x.c(), t = space$1(), h && h.c(), s = space$1(), u && u.c(), f = empty$1(); + }, + m(E, c) { + _ && _.m(E, c), insert$2(E, e, c), x && x.m(E, c), insert$2(E, t, c), h && h.m(E, c), insert$2(E, s, c), u && u.m(E, c), insert$2(E, f, c); + }, + p(E, c) { + /*p*/ + E[38].desc != null ? x ? x.p(E, c) : (x = create_if_block_7(E), x.c(), x.m(t.parentNode, t)) : x && (x.d(1), x = null), /*p*/ + E[38].desc != null && /*progress_level*/ + E[14] && /*progress_level*/ + E[14][ + /*i*/ + E[40] + ] != null ? h || (h = create_if_block_6(), h.c(), h.m(s.parentNode, s)) : h && (h.d(1), h = null), /*progress_level*/ + E[14] != null ? u ? u.p(E, c) : (u = create_if_block_5(E), u.c(), u.m(f.parentNode, f)) : u && (u.d(1), u = null); + }, + d(E) { + E && (detach$2(e), detach$2(t), detach$2(s), detach$2(f)), _ && _.d(E), x && x.d(E), h && h.d(E), u && u.d(E); + } + }; +} +function create_if_block_8(r) { + let e; + return { + c() { + e = text$2(" /"); + }, + m(t, s) { + insert$2(t, e, s); + }, + d(t) { + t && detach$2(e); + } + }; +} +function create_if_block_7(r) { + let e = ( + /*p*/ + r[38].desc + "" + ), t; + return { + c() { + t = text$2(e); + }, + m(s, f) { + insert$2(s, t, f); + }, + p(s, f) { + f[0] & /*progress*/ + 128 && e !== (e = /*p*/ + s[38].desc + "") && set_data$2(t, e); + }, + d(s) { + s && detach$2(t); + } + }; +} +function create_if_block_6(r) { + let e; + return { + c() { + e = text$2("-"); + }, + m(t, s) { + insert$2(t, e, s); + }, + d(t) { + t && detach$2(e); + } + }; +} +function create_if_block_5(r) { + let e = (100 * /*progress_level*/ + (r[14][ + /*i*/ + r[40] + ] || 0)).toFixed(1) + "", t, s; + return { + c() { + t = text$2(e), s = text$2("%"); + }, + m(f, _) { + insert$2(f, t, _), insert$2(f, s, _); + }, + p(f, _) { + _[0] & /*progress_level*/ + 16384 && e !== (e = (100 * /*progress_level*/ + (f[14][ + /*i*/ + f[40] + ] || 0)).toFixed(1) + "") && set_data$2(t, e); + }, + d(f) { + f && (detach$2(t), detach$2(s)); + } + }; +} +function create_each_block$1(r) { + let e, t = ( + /*p*/ + (r[38].desc != null || /*progress_level*/ + r[14] && /*progress_level*/ + r[14][ + /*i*/ + r[40] + ] != null) && create_if_block_4(r) + ); + return { + c() { + t && t.c(), e = empty$1(); + }, + m(s, f) { + t && t.m(s, f), insert$2(s, e, f); + }, + p(s, f) { + /*p*/ + s[38].desc != null || /*progress_level*/ + s[14] && /*progress_level*/ + s[14][ + /*i*/ + s[40] + ] != null ? t ? t.p(s, f) : (t = create_if_block_4(s), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null); + }, + d(s) { + s && detach$2(e), t && t.d(s); + } + }; +} +function create_if_block_1$1(r) { + let e, t; + return { + c() { + e = element$2("p"), t = text$2( + /*loading_text*/ + r[9] + ), attr$2(e, "class", "loading svelte-14miwb5"); + }, + m(s, f) { + insert$2(s, e, f), append$2(e, t); + }, + p(s, f) { + f[0] & /*loading_text*/ + 512 && set_data$2( + t, + /*loading_text*/ + s[9] + ); + }, + d(s) { + s && detach$2(e); + } + }; +} +function create_fragment$2(r) { + let e, t, s, f, _; + const x = [create_if_block$1, create_if_block_17], h = []; + function u(E, c) { + return ( + /*status*/ + E[4] === "pending" ? 0 : ( + /*status*/ + E[4] === "error" ? 1 : -1 + ) + ); + } + return ~(t = u(r)) && (s = h[t] = x[t](r)), { + c() { + e = element$2("div"), s && s.c(), attr$2(e, "class", f = "wrap " + /*variant*/ + r[8] + " " + /*show_progress*/ + r[6] + " svelte-14miwb5"), toggle_class$1(e, "hide", !/*status*/ + r[4] || /*status*/ + r[4] === "complete" || /*show_progress*/ + r[6] === "hidden"), toggle_class$1( + e, + "translucent", + /*variant*/ + r[8] === "center" && /*status*/ + (r[4] === "pending" || /*status*/ + r[4] === "error") || /*translucent*/ + r[11] || /*show_progress*/ + r[6] === "minimal" + ), toggle_class$1( + e, + "generating", + /*status*/ + r[4] === "generating" + ), toggle_class$1( + e, + "border", + /*border*/ + r[12] + ), set_style( + e, + "position", + /*absolute*/ + r[10] ? "absolute" : "static" + ), set_style( + e, + "padding", + /*absolute*/ + r[10] ? "0" : "var(--size-8) 0" + ); + }, + m(E, c) { + insert$2(E, e, c), ~t && h[t].m(e, null), r[31](e), _ = !0; + }, + p(E, c) { + let C = t; + t = u(E), t === C ? ~t && h[t].p(E, c) : (s && (group_outros$1(), transition_out$1(h[C], 1, 1, () => { + h[C] = null; + }), check_outros$1()), ~t ? (s = h[t], s ? s.p(E, c) : (s = h[t] = x[t](E), s.c()), transition_in$1(s, 1), s.m(e, null)) : s = null), (!_ || c[0] & /*variant, show_progress*/ + 320 && f !== (f = "wrap " + /*variant*/ + E[8] + " " + /*show_progress*/ + E[6] + " svelte-14miwb5")) && attr$2(e, "class", f), (!_ || c[0] & /*variant, show_progress, status, show_progress*/ + 336) && toggle_class$1(e, "hide", !/*status*/ + E[4] || /*status*/ + E[4] === "complete" || /*show_progress*/ + E[6] === "hidden"), (!_ || c[0] & /*variant, show_progress, variant, status, translucent, show_progress*/ + 2384) && toggle_class$1( + e, + "translucent", + /*variant*/ + E[8] === "center" && /*status*/ + (E[4] === "pending" || /*status*/ + E[4] === "error") || /*translucent*/ + E[11] || /*show_progress*/ + E[6] === "minimal" + ), (!_ || c[0] & /*variant, show_progress, status*/ + 336) && toggle_class$1( + e, + "generating", + /*status*/ + E[4] === "generating" + ), (!_ || c[0] & /*variant, show_progress, border*/ + 4416) && toggle_class$1( + e, + "border", + /*border*/ + E[12] + ), c[0] & /*absolute*/ + 1024 && set_style( + e, + "position", + /*absolute*/ + E[10] ? "absolute" : "static" + ), c[0] & /*absolute*/ + 1024 && set_style( + e, + "padding", + /*absolute*/ + E[10] ? "0" : "var(--size-8) 0" + ); + }, + i(E) { + _ || (transition_in$1(s), _ = !0); + }, + o(E) { + transition_out$1(s), _ = !1; + }, + d(E) { + E && detach$2(e), ~t && h[t].d(), r[31](null); + } + }; +} +let items = [], called = !1; +async function scroll_into_view(r, e = !0) { + if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && e !== !0)) { + if (items.push(r), !called) + called = !0; + else + return; + await tick(), requestAnimationFrame(() => { + let t = [0, 0]; + for (let s = 0; s < items.length; s++) { + const _ = items[s].getBoundingClientRect(); + (s === 0 || _.top + window.scrollY <= t[0]) && (t[0] = _.top + window.scrollY, t[1] = s); + } + window.scrollTo({ top: t[0] - 20, behavior: "smooth" }), called = !1, items = []; + }); + } +} +function instance$2(r, e, t) { + let s, { $$slots: f = {}, $$scope: _ } = e, { i18n: x } = e, { eta: h = null } = e, { queue: u = !1 } = e, { queue_position: E } = e, { queue_size: c } = e, { status: C } = e, { scroll_to_output: b = !1 } = e, { timer: A = !0 } = e, { show_progress: S = "full" } = e, { message: n = null } = e, { progress: o = null } = e, { variant: w = "default" } = e, { loading_text: p = "Loading..." } = e, { absolute: v = !0 } = e, { translucent: a = !1 } = e, { border: l = !1 } = e, { autoscroll: g } = e, M, L = !1, T = 0, D = 0, R = null, B = 0, P = null, z, F = null, N = !0; + const $ = () => { + t(25, T = performance.now()), t(26, D = 0), L = !0, k(); + }; + function k() { + requestAnimationFrame(() => { + t(26, D = (performance.now() - T) / 1e3), L && k(); + }); + } + function G() { + t(26, D = 0), L && (L = !1); + } + onDestroy(() => { + L && G(); + }); + let H = null; + function U(Q) { + binding_callbacks[Q ? "unshift" : "push"](() => { + F = Q, t(16, F), t(7, o), t(14, P), t(15, z); + }); + } + function V(Q) { + binding_callbacks[Q ? "unshift" : "push"](() => { + M = Q, t(13, M); + }); + } + return r.$$set = (Q) => { + "i18n" in Q && t(1, x = Q.i18n), "eta" in Q && t(0, h = Q.eta), "queue" in Q && t(21, u = Q.queue), "queue_position" in Q && t(2, E = Q.queue_position), "queue_size" in Q && t(3, c = Q.queue_size), "status" in Q && t(4, C = Q.status), "scroll_to_output" in Q && t(22, b = Q.scroll_to_output), "timer" in Q && t(5, A = Q.timer), "show_progress" in Q && t(6, S = Q.show_progress), "message" in Q && t(23, n = Q.message), "progress" in Q && t(7, o = Q.progress), "variant" in Q && t(8, w = Q.variant), "loading_text" in Q && t(9, p = Q.loading_text), "absolute" in Q && t(10, v = Q.absolute), "translucent" in Q && t(11, a = Q.translucent), "border" in Q && t(12, l = Q.border), "autoscroll" in Q && t(24, g = Q.autoscroll), "$$scope" in Q && t(28, _ = Q.$$scope); + }, r.$$.update = () => { + r.$$.dirty[0] & /*eta, old_eta, queue, timer_start*/ + 169869313 && (h === null ? t(0, h = R) : u && t(0, h = (performance.now() - T) / 1e3 + h), h != null && (t(19, H = h.toFixed(1)), t(27, R = h))), r.$$.dirty[0] & /*eta, timer_diff*/ + 67108865 && t(17, B = h === null || h <= 0 || !D ? null : Math.min(D / h, 1)), r.$$.dirty[0] & /*progress*/ + 128 && o != null && t(18, N = !1), r.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/ + 114816 && (o != null ? t(14, P = o.map((Q) => { + if (Q.index != null && Q.length != null) + return Q.index / Q.length; + if (Q.progress != null) + return Q.progress; + })) : t(14, P = null), P ? (t(15, z = P[P.length - 1]), F && (z === 0 ? t(16, F.style.transition = "0", F) : t(16, F.style.transition = "150ms", F))) : t(15, z = void 0)), r.$$.dirty[0] & /*status*/ + 16 && (C === "pending" ? $() : G()), r.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/ + 20979728 && M && b && (C === "pending" || C === "complete") && scroll_into_view(M, g), r.$$.dirty[0] & /*status, message*/ + 8388624, r.$$.dirty[0] & /*timer_diff*/ + 67108864 && t(20, s = D.toFixed(1)); + }, [ + h, + x, + E, + c, + C, + A, + S, + o, + w, + p, + v, + a, + l, + M, + P, + z, + F, + B, + N, + H, + s, + u, + b, + n, + g, + T, + D, + R, + _, + f, + U, + V + ]; +} +class Static extends SvelteComponent$2 { + constructor(e) { + super(), init$2( + this, + e, + instance$2, + create_fragment$2, + safe_not_equal$2, + { + i18n: 1, + eta: 0, + queue: 21, + queue_position: 2, + queue_size: 3, + status: 4, + scroll_to_output: 22, + timer: 5, + show_progress: 6, + message: 23, + progress: 7, + variant: 8, + loading_text: 9, + absolute: 10, + translucent: 11, + border: 12, + autoscroll: 24 + }, + null, + [-1, -1] + ); + } +} +const ToastContent_svelte_svelte_type_style_lang = "", Toast_svelte_svelte_type_style_lang = "", Example_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$1, + append: append$1, + attr: attr$1, + detach: detach$1, + element: element$1, + init: init$1, + insert: insert$1, + noop, + safe_not_equal: safe_not_equal$1, + set_data: set_data$1, + text: text$1, + toggle_class +} = window.__gradio__svelte__internal; +function create_fragment$1(r) { + let e, t = (Array.isArray( + /*value*/ + r[0] + ) ? ( + /*value*/ + r[0].join(", ") + ) : ( + /*value*/ + r[0] + )) + "", s; + return { + c() { + e = element$1("div"), s = text$1(t), attr$1(e, "class", "svelte-1hgn91n"), toggle_class( + e, + "table", + /*type*/ + r[1] === "table" + ), toggle_class( + e, + "gallery", + /*type*/ + r[1] === "gallery" + ), toggle_class( + e, + "selected", + /*selected*/ + r[2] + ); + }, + m(f, _) { + insert$1(f, e, _), append$1(e, s); + }, + p(f, [_]) { + _ & /*value*/ + 1 && t !== (t = (Array.isArray( + /*value*/ + f[0] + ) ? ( + /*value*/ + f[0].join(", ") + ) : ( + /*value*/ + f[0] + )) + "") && set_data$1(s, t), _ & /*type*/ + 2 && toggle_class( + e, + "table", + /*type*/ + f[1] === "table" + ), _ & /*type*/ + 2 && toggle_class( + e, + "gallery", + /*type*/ + f[1] === "gallery" + ), _ & /*selected*/ + 4 && toggle_class( + e, + "selected", + /*selected*/ + f[2] + ); + }, + i: noop, + o: noop, + d(f) { + f && detach$1(e); + } + }; +} +function instance$1(r, e, t) { + let { value: s } = e, { type: f } = e, { selected: _ = !1 } = e; + return r.$$set = (x) => { + "value" in x && t(0, s = x.value), "type" in x && t(1, f = x.type), "selected" in x && t(2, _ = x.selected); + }, [s, f, _]; +} +class Example extends SvelteComponent$1 { + constructor(e) { + super(), init$1(this, e, instance$1, create_fragment$1, safe_not_equal$1, { value: 0, type: 1, selected: 2 }); + } +} +const Index_svelte_svelte_type_style_lang = "", { + SvelteComponent, + append, + assign, + attr, + check_outros, + create_component, + destroy_component, + destroy_each, + detach, + element, + empty, + ensure_array_like, + flush, + get_spread_object, + get_spread_update, + group_outros, + init, + insert, + mount_component, + safe_not_equal, + set_data, + space, + svg_element, + text, + transition_in, + transition_out +} = window.__gradio__svelte__internal; +function get_each_context(r, e, t) { + const s = r.slice(); + return s[39] = e[t], s; +} +function create_else_block(r) { + let e, t; + return e = new FileUpload({ + props: { + label: ( + /*label*/ + r[6] + ), + show_label: ( + /*show_label*/ + r[7] + ), + value: ( + /*_value*/ + r[21] + ), + file_count: ( + /*file_count*/ + r[17] + ), + file_types: ( + /*file_types*/ + r[18] + ), + selectable: ( + /*_selectable*/ + r[11] + ), + root: ( + /*root*/ + r[5] + ), + height: ( + /*height*/ + r[8] + ), + representations: ( + /*representations*/ + r[23] + ), + config: ( + /*config*/ + r[9] + ), + confidenceLabel: ( + /*confidenceLabel*/ + r[10] + ), + moldata: ( + /*moldata*/ + r[19] + ), + i18n: ( + /*gradio*/ + r[16].i18n + ), + $$slots: { default: [create_default_slot_1] }, + $$scope: { ctx: r } + } + }), e.$on( + "change", + /*change_handler*/ + r[29] + ), e.$on( + "drag", + /*drag_handler*/ + r[30] + ), e.$on( + "clear", + /*clear_handler*/ + r[31] + ), e.$on( + "select", + /*select_handler_1*/ + r[32] + ), e.$on( + "notfound", + /*notfound_handler*/ + r[33] + ), e.$on( + "upload", + /*upload_handler*/ + r[34] + ), { + c() { + create_component(e.$$.fragment); + }, + m(s, f) { + mount_component(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f[0] & /*label*/ + 64 && (_.label = /*label*/ + s[6]), f[0] & /*show_label*/ + 128 && (_.show_label = /*show_label*/ + s[7]), f[0] & /*_value*/ + 2097152 && (_.value = /*_value*/ + s[21]), f[0] & /*file_count*/ + 131072 && (_.file_count = /*file_count*/ + s[17]), f[0] & /*file_types*/ + 262144 && (_.file_types = /*file_types*/ + s[18]), f[0] & /*_selectable*/ + 2048 && (_.selectable = /*_selectable*/ + s[11]), f[0] & /*root*/ + 32 && (_.root = /*root*/ + s[5]), f[0] & /*height*/ + 256 && (_.height = /*height*/ + s[8]), f[0] & /*config*/ + 512 && (_.config = /*config*/ + s[9]), f[0] & /*confidenceLabel*/ + 1024 && (_.confidenceLabel = /*confidenceLabel*/ + s[10]), f[0] & /*moldata*/ + 524288 && (_.moldata = /*moldata*/ + s[19]), f[0] & /*gradio*/ + 65536 && (_.i18n = /*gradio*/ + s[16].i18n), f[0] & /*gradio*/ + 65536 | f[1] & /*$$scope*/ + 2048 && (_.$$scope = { dirty: f, ctx: s }), e.$set(_); + }, + i(s) { + t || (transition_in(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component(e, s); + } + }; +} +function create_if_block_1(r) { + let e, t; + return e = new File_1({ + props: { + selectable: ( + /*_selectable*/ + r[11] + ), + value: ( + /*_value*/ + r[21] + ), + label: ( + /*label*/ + r[6] + ), + show_label: ( + /*show_label*/ + r[7] + ), + height: ( + /*height*/ + r[8] + ), + representations: ( + /*representations*/ + r[23] + ), + config: ( + /*config*/ + r[9] + ), + confidenceLabel: ( + /*confidenceLabel*/ + r[10] + ), + moldata: ( + /*moldata*/ + r[19] + ), + errors: ( + /*errors*/ + r[20] + ), + i18n: ( + /*gradio*/ + r[16].i18n + ) + } + }), e.$on( + "select", + /*select_handler*/ + r[28] + ), { + c() { + create_component(e.$$.fragment); + }, + m(s, f) { + mount_component(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f[0] & /*_selectable*/ + 2048 && (_.selectable = /*_selectable*/ + s[11]), f[0] & /*_value*/ + 2097152 && (_.value = /*_value*/ + s[21]), f[0] & /*label*/ + 64 && (_.label = /*label*/ + s[6]), f[0] & /*show_label*/ + 128 && (_.show_label = /*show_label*/ + s[7]), f[0] & /*height*/ + 256 && (_.height = /*height*/ + s[8]), f[0] & /*config*/ + 512 && (_.config = /*config*/ + s[9]), f[0] & /*confidenceLabel*/ + 1024 && (_.confidenceLabel = /*confidenceLabel*/ + s[10]), f[0] & /*moldata*/ + 524288 && (_.moldata = /*moldata*/ + s[19]), f[0] & /*errors*/ + 1048576 && (_.errors = /*errors*/ + s[20]), f[0] & /*gradio*/ + 65536 && (_.i18n = /*gradio*/ + s[16].i18n), e.$set(_); + }, + i(s) { + t || (transition_in(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component(e, s); + } + }; +} +function create_default_slot_1(r) { + let e, t; + return e = new UploadText({ + props: { + i18n: ( + /*gradio*/ + r[16].i18n + ), + type: "file" + } + }), { + c() { + create_component(e.$$.fragment); + }, + m(s, f) { + mount_component(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f[0] & /*gradio*/ + 65536 && (_.i18n = /*gradio*/ + s[16].i18n), e.$set(_); + }, + i(s) { + t || (transition_in(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component(e, s); + } + }; +} +function create_if_block(r) { + let e, t, s, f, _, x, h, u, E, c, C = ensure_array_like( + /*errors*/ + r[20] + ), b = []; + for (let A = 0; A < C.length; A += 1) + b[A] = create_each_block(get_each_context(r, C, A)); + return { + c() { + e = element("div"), t = svg_element("svg"), s = svg_element("path"), f = space(), _ = element("span"), _.textContent = "Error in the representations", x = space(), h = element("div"), u = element("span"), u.textContent = "Couldn't display Molecule. Fix the following problems:", E = space(), c = element("ul"); + for (let A = 0; A < b.length; A += 1) + b[A].c(); + attr(s, "stroke-linecap", "round"), attr(s, "stroke-linejoin", "round"), attr(s, "d", "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"), attr(t, "class", "flex-shrink-0 inline w-4 h-4 mr-3 mt-[2px] svelte-1j3z0by"), attr(t, "xmlns", "http://www.w3.org/2000/svg"), attr(t, "fill", "none"), attr(t, "viewBox", "0 0 24 24"), attr(t, "stroke-width", "1.5"), attr(t, "stroke", "currentColor"), attr(_, "class", "sr-only svelte-1j3z0by"), attr(u, "class", "font-medium svelte-1j3z0by"), attr(c, "class", "mt-1.5 ml-4 list-disc list-inside svelte-1j3z0by"), attr(e, "class", "flex m-2 p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400 svelte-1j3z0by"), attr(e, "role", "alert"); + }, + m(A, S) { + insert(A, e, S), append(e, t), append(t, s), append(e, f), append(e, _), append(e, x), append(e, h), append(h, u), append(h, E), append(h, c); + for (let n = 0; n < b.length; n += 1) + b[n] && b[n].m(c, null); + }, + p(A, S) { + if (S[0] & /*errors*/ + 1048576) { + C = ensure_array_like( + /*errors*/ + A[20] + ); + let n; + for (n = 0; n < C.length; n += 1) { + const o = get_each_context(A, C, n); + b[n] ? b[n].p(o, S) : (b[n] = create_each_block(o), b[n].c(), b[n].m(c, null)); + } + for (; n < b.length; n += 1) + b[n].d(1); + b.length = C.length; + } + }, + d(A) { + A && detach(e), destroy_each(b, A); + } + }; +} +function create_each_block(r) { + let e, t = ( + /*error*/ + r[39] + "" + ), s; + return { + c() { + e = element("li"), s = text(t); + }, + m(f, _) { + insert(f, e, _), append(e, s); + }, + p(f, _) { + _[0] & /*errors*/ + 1048576 && t !== (t = /*error*/ + f[39] + "") && set_data(s, t); + }, + d(f) { + f && detach(e); + } + }; +} +function create_default_slot(r) { + var S; + let e, t, s, f, _, x, h; + const u = [ + { + autoscroll: ( + /*gradio*/ + r[16].autoscroll + ) + }, + { i18n: ( + /*gradio*/ + r[16].i18n + ) }, + /*loading_status*/ + r[12], + { + status: ( + /*loading_status*/ + ((S = r[12]) == null ? void 0 : S.status) || "complete" + ) + } + ]; + let E = {}; + for (let n = 0; n < u.length; n += 1) + E = assign(E, u[n]); + e = new Static({ props: E }); + const c = [create_if_block_1, create_else_block], C = []; + function b(n, o) { + return ( + /*interactive*/ + n[4] ? 1 : 0 + ); + } + s = b(r), f = C[s] = c[s](r); + let A = ( + /*errors*/ + r[20].length > 0 && /*_value*/ + r[21] !== null && create_if_block(r) + ); + return { + c() { + create_component(e.$$.fragment), t = space(), f.c(), _ = space(), A && A.c(), x = empty(); + }, + m(n, o) { + mount_component(e, n, o), insert(n, t, o), C[s].m(n, o), insert(n, _, o), A && A.m(n, o), insert(n, x, o), h = !0; + }, + p(n, o) { + var v; + const w = o[0] & /*gradio, loading_status*/ + 69632 ? get_spread_update(u, [ + o[0] & /*gradio*/ + 65536 && { + autoscroll: ( + /*gradio*/ + n[16].autoscroll + ) + }, + o[0] & /*gradio*/ + 65536 && { i18n: ( + /*gradio*/ + n[16].i18n + ) }, + o[0] & /*loading_status*/ + 4096 && get_spread_object( + /*loading_status*/ + n[12] + ), + o[0] & /*loading_status*/ + 4096 && { + status: ( + /*loading_status*/ + ((v = n[12]) == null ? void 0 : v.status) || "complete" + ) + } + ]) : {}; + e.$set(w); + let p = s; + s = b(n), s === p ? C[s].p(n, o) : (group_outros(), transition_out(C[p], 1, 1, () => { + C[p] = null; + }), check_outros(), f = C[s], f ? f.p(n, o) : (f = C[s] = c[s](n), f.c()), transition_in(f, 1), f.m(_.parentNode, _)), /*errors*/ + n[20].length > 0 && /*_value*/ + n[21] !== null ? A ? A.p(n, o) : (A = create_if_block(n), A.c(), A.m(x.parentNode, x)) : A && (A.d(1), A = null); + }, + i(n) { + h || (transition_in(e.$$.fragment, n), transition_in(f), h = !0); + }, + o(n) { + transition_out(e.$$.fragment, n), transition_out(f), h = !1; + }, + d(n) { + n && (detach(t), detach(_), detach(x)), destroy_component(e, n), C[s].d(n), A && A.d(n); + } + }; +} +function create_fragment(r) { + let e, t; + return e = new Block({ + props: { + visible: ( + /*visible*/ + r[3] + ), + variant: ( + /*value*/ + r[0] === null ? "dashed" : "solid" + ), + border_mode: ( + /*dragging*/ + r[22] ? "focus" : "base" + ), + padding: !1, + elem_id: ( + /*elem_id*/ + r[1] + ), + elem_classes: ( + /*elem_classes*/ + r[2] + ), + container: ( + /*container*/ + r[13] + ), + scale: ( + /*scale*/ + r[14] + ), + min_width: ( + /*min_width*/ + r[15] + ), + allow_overflow: !1, + $$slots: { default: [create_default_slot] }, + $$scope: { ctx: r } + } + }), { + c() { + create_component(e.$$.fragment); + }, + m(s, f) { + mount_component(e, s, f), t = !0; + }, + p(s, f) { + const _ = {}; + f[0] & /*visible*/ + 8 && (_.visible = /*visible*/ + s[3]), f[0] & /*value*/ + 1 && (_.variant = /*value*/ + s[0] === null ? "dashed" : "solid"), f[0] & /*dragging*/ + 4194304 && (_.border_mode = /*dragging*/ + s[22] ? "focus" : "base"), f[0] & /*elem_id*/ + 2 && (_.elem_id = /*elem_id*/ + s[1]), f[0] & /*elem_classes*/ + 4 && (_.elem_classes = /*elem_classes*/ + s[2]), f[0] & /*container*/ + 8192 && (_.container = /*container*/ + s[13]), f[0] & /*scale*/ + 16384 && (_.scale = /*scale*/ + s[14]), f[0] & /*min_width*/ + 32768 && (_.min_width = /*min_width*/ + s[15]), f[0] & /*errors, _value, _selectable, label, show_label, height, config, confidenceLabel, moldata, gradio, interactive, file_count, file_types, root, value, dragging, loading_status*/ + 8331249 | f[1] & /*$$scope*/ + 2048 && (_.$$scope = { dirty: f, ctx: s }), e.$set(_); + }, + i(s) { + t || (transition_in(e.$$.fragment, s), t = !0); + }, + o(s) { + transition_out(e.$$.fragment, s), t = !1; + }, + d(s) { + destroy_component(e, s); + } + }; +} +async function fetchFileContent(r) { + return await (await fetch(r)).text(); +} +function instance(r, e, t) { + let s, { elem_id: f = "" } = e, { elem_classes: _ = [] } = e, { visible: x = !0 } = e, { value: h } = e, { interactive: u } = e, { root: E } = e, { label: c } = e, { show_label: C } = e, { height: b = void 0 } = e, { reps: A = [] } = e, { config: S = {} } = e, { confidenceLabel: n = "" } = e, { proxy_url: o } = e, { _selectable: w = !1 } = e, { loading_status: p } = e, { container: v = !0 } = e, { scale: a = null } = e, { min_width: l = void 0 } = e, { gradio: g } = e, { file_count: M } = e, { file_types: L = ["file"] } = e, T = s, D = !1, R = { + model: { type: Number, default: 0 }, + chain: { type: String, default: "" }, + resname: { type: String, default: "" }, + style: { + type: String, + default: "cartoon", + choices: ["cartoon", "stick", "sphere", "surface"] + }, + color: { + type: String, + default: "whiteCarbon", + choices: [ + "whiteCarbon", + "orangeCarbon", + "redCarbon", + "blackCarbon", + "blueCarbon", + "grayCarbon", + "greenCarbon", + "cyanCarbon", + "alphafold", + "default", + "Jmol", + "chain", + "spectrum" + ] + }, + residue_range: { type: String, default: "" }, + around: { type: Number, default: 0 }, + byres: { type: Boolean, default: !1 }, + visible: { type: Boolean, default: !0 } + }, B = null, P = ["pdb", "sdf", "mol2"], z = []; + async function F(ee) { + if (ee == null) + return []; + if (Array.isArray(ee)) { + let ne = []; + for (const me of ee) { + let se = me.orig_name.split(".").pop(); + if (!P.includes(se)) { + z.push(`Invalid file extension for ${me.orig_name}. Expected one of ${P.join(", ")}, got ${se}`), t(19, B = null); + continue; + } + ne.push({ + data: await fetchFileContent(me.url), + name: me.orig_name, + format: se, + asFrames: !1 + }); + } + t(19, B = ne); + } else if (typeof ee == "object" && ee !== null) { + let ne = ee.orig_name.split(".").pop(); + if (!P.includes(ne)) + z.push(`Invalid file extension for ${ee.orig_name}. Expected one of ${P.join(", ")}, got ${ne}`), t(19, B = null); + else { + let me = await fetchFileContent(ee.url); + t(19, B = [ + { + data: me, + name: ee.orig_name, + format: "pdb", + asFrames: !1 + } + ]); + } + } else + t(19, B = null); + } + let N = 0, $ = []; + const k = ({ detail: ee }) => g.dispatch("select", ee), G = ({ detail: ee }) => { + t(20, z = []), t(0, h = ee); + }, H = ({ detail: ee }) => t(22, D = ee), U = () => g.dispatch("clear"), V = ({ detail: ee }) => g.dispatch("select", ee), Q = () => g.dispatch("error", "identifier not found in database, check spelling"), oe = () => g.dispatch("upload"); + return r.$$set = (ee) => { + "elem_id" in ee && t(1, f = ee.elem_id), "elem_classes" in ee && t(2, _ = ee.elem_classes), "visible" in ee && t(3, x = ee.visible), "value" in ee && t(0, h = ee.value), "interactive" in ee && t(4, u = ee.interactive), "root" in ee && t(5, E = ee.root), "label" in ee && t(6, c = ee.label), "show_label" in ee && t(7, C = ee.show_label), "height" in ee && t(8, b = ee.height), "reps" in ee && t(24, A = ee.reps), "config" in ee && t(9, S = ee.config), "confidenceLabel" in ee && t(10, n = ee.confidenceLabel), "proxy_url" in ee && t(25, o = ee.proxy_url), "_selectable" in ee && t(11, w = ee._selectable), "loading_status" in ee && t(12, p = ee.loading_status), "container" in ee && t(13, v = ee.container), "scale" in ee && t(14, a = ee.scale), "min_width" in ee && t(15, l = ee.min_width), "gradio" in ee && t(16, g = ee.gradio), "file_count" in ee && t(17, M = ee.file_count), "file_types" in ee && t(18, L = ee.file_types); + }, r.$$.update = () => { + r.$$.dirty[0] & /*value, root, proxy_url*/ + 33554465 && t(21, s = normalise_file(h, E, o)), r.$$.dirty[0] & /*old_value, _value, gradio*/ + 69271552 && JSON.stringify(T) !== JSON.stringify(s) && (g.dispatch("change"), t(26, T = s), console.log("value change", s)), r.$$.dirty[0] & /*moldata*/ + 524288 && t(27, N = B ? B.length : 0), r.$$.dirty[0] & /*reps, errors, lenMoldata*/ + 152043520 && (A.forEach((ee) => { + for (const [ne, me] of Object.entries(R)) + ee[ne] === void 0 && (ee[ne] = me.default), ee[ne].constructor != me.type && z.push(`Invalid type for ${ne} in reps. Expected ${me.type}, got ${typeof ee[ne]}`); + }), A.forEach((ee) => { + ee.model <= N && $.push(ee); + })), r.$$.dirty[0] & /*_value*/ + 2097152 && F(s); + }, [ + h, + f, + _, + x, + u, + E, + c, + C, + b, + S, + n, + w, + p, + v, + a, + l, + g, + M, + L, + B, + z, + s, + D, + $, + A, + o, + T, + N, + k, + G, + H, + U, + V, + Q, + oe + ]; +} +class Index extends SvelteComponent { + constructor(e) { + super(), init( + this, + e, + instance, + create_fragment, + safe_not_equal, + { + elem_id: 1, + elem_classes: 2, + visible: 3, + value: 0, + interactive: 4, + root: 5, + label: 6, + show_label: 7, + height: 8, + reps: 24, + config: 9, + confidenceLabel: 10, + proxy_url: 25, + _selectable: 11, + loading_status: 12, + container: 13, + scale: 14, + min_width: 15, + gradio: 16, + file_count: 17, + file_types: 18 + }, + null, + [-1, -1] + ); + } + get elem_id() { + return this.$$.ctx[1]; + } + set elem_id(e) { + this.$$set({ elem_id: e }), flush(); + } + get elem_classes() { + return this.$$.ctx[2]; + } + set elem_classes(e) { + this.$$set({ elem_classes: e }), flush(); + } + get visible() { + return this.$$.ctx[3]; + } + set visible(e) { + this.$$set({ visible: e }), flush(); + } + get value() { + return this.$$.ctx[0]; + } + set value(e) { + this.$$set({ value: e }), flush(); + } + get interactive() { + return this.$$.ctx[4]; + } + set interactive(e) { + this.$$set({ interactive: e }), flush(); + } + get root() { + return this.$$.ctx[5]; + } + set root(e) { + this.$$set({ root: e }), flush(); + } + get label() { + return this.$$.ctx[6]; + } + set label(e) { + this.$$set({ label: e }), flush(); + } + get show_label() { + return this.$$.ctx[7]; + } + set show_label(e) { + this.$$set({ show_label: e }), flush(); + } + get height() { + return this.$$.ctx[8]; + } + set height(e) { + this.$$set({ height: e }), flush(); + } + get reps() { + return this.$$.ctx[24]; + } + set reps(e) { + this.$$set({ reps: e }), flush(); + } + get config() { + return this.$$.ctx[9]; + } + set config(e) { + this.$$set({ config: e }), flush(); + } + get confidenceLabel() { + return this.$$.ctx[10]; + } + set confidenceLabel(e) { + this.$$set({ confidenceLabel: e }), flush(); + } + get proxy_url() { + return this.$$.ctx[25]; + } + set proxy_url(e) { + this.$$set({ proxy_url: e }), flush(); + } + get _selectable() { + return this.$$.ctx[11]; + } + set _selectable(e) { + this.$$set({ _selectable: e }), flush(); + } + get loading_status() { + return this.$$.ctx[12]; + } + set loading_status(e) { + this.$$set({ loading_status: e }), flush(); + } + get container() { + return this.$$.ctx[13]; + } + set container(e) { + this.$$set({ container: e }), flush(); + } + get scale() { + return this.$$.ctx[14]; + } + set scale(e) { + this.$$set({ scale: e }), flush(); + } + get min_width() { + return this.$$.ctx[15]; + } + set min_width(e) { + this.$$set({ min_width: e }), flush(); + } + get gradio() { + return this.$$.ctx[16]; + } + set gradio(e) { + this.$$set({ gradio: e }), flush(); + } + get file_count() { + return this.$$.ctx[17]; + } + set file_count(e) { + this.$$set({ file_count: e }), flush(); + } + get file_types() { + return this.$$.ctx[18]; + } + set file_types(e) { + this.$$set({ file_types: e }), flush(); + } +} +export { + Example as BaseExample, + File_1 as BaseFile, + FileUpload as BaseFileUpload, + FilePreview, + Index as default +};