diff --git "a/src/backend/gradio_cofoldinginput/templates/component/index.js" "b/src/backend/gradio_cofoldinginput/templates/component/index.js" new file mode 100644--- /dev/null +++ "b/src/backend/gradio_cofoldinginput/templates/component/index.js" @@ -0,0 +1,29316 @@ +const Block_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$f, + assign: assign$1, + create_slot: create_slot$3, + detach: detach$f, + element: element$c, + get_all_dirty_from_scope: get_all_dirty_from_scope$3, + get_slot_changes: get_slot_changes$3, + get_spread_update: get_spread_update$1, + init: init$f, + insert: insert$f, + safe_not_equal: safe_not_equal$g, + set_dynamic_element_data, + set_style: set_style$3, + toggle_class: toggle_class$7, + transition_in: transition_in$7, + transition_out: transition_out$7, + update_slot_base: update_slot_base$3 +} = window.__gradio__svelte__internal; +function create_dynamic_element(y) { + let s, e, l; + const g = ( + /*#slots*/ + y[18].default + ), _ = create_slot$3( + g, + y, + /*$$scope*/ + y[17], + null + ); + let x = [ + { "data-testid": ( + /*test_id*/ + y[7] + ) }, + { id: ( + /*elem_id*/ + y[2] + ) }, + { + class: e = "block " + /*elem_classes*/ + y[3].join(" ") + " svelte-1t38q2d" + } + ], o = {}; + for (let p = 0; p < x.length; p += 1) + o = assign$1(o, x[p]); + return { + c() { + s = element$c( + /*tag*/ + y[14] + ), _ && _.c(), set_dynamic_element_data( + /*tag*/ + y[14] + )(s, o), toggle_class$7( + s, + "hidden", + /*visible*/ + y[10] === !1 + ), toggle_class$7( + s, + "padded", + /*padding*/ + y[6] + ), toggle_class$7( + s, + "border_focus", + /*border_mode*/ + y[5] === "focus" + ), toggle_class$7(s, "hide-container", !/*explicit_call*/ + y[8] && !/*container*/ + y[9]), set_style$3( + s, + "height", + /*get_dimension*/ + y[15]( + /*height*/ + y[0] + ) + ), set_style$3(s, "width", typeof /*width*/ + y[1] == "number" ? `calc(min(${/*width*/ + y[1]}px, 100%))` : ( + /*get_dimension*/ + y[15]( + /*width*/ + y[1] + ) + )), set_style$3( + s, + "border-style", + /*variant*/ + y[4] + ), set_style$3( + s, + "overflow", + /*allow_overflow*/ + y[11] ? "visible" : "hidden" + ), set_style$3( + s, + "flex-grow", + /*scale*/ + y[12] + ), set_style$3(s, "min-width", `calc(min(${/*min_width*/ + y[13]}px, 100%))`), set_style$3(s, "border-width", "var(--block-border-width)"); + }, + m(p, E) { + insert$f(p, s, E), _ && _.m(s, null), l = !0; + }, + p(p, E) { + _ && _.p && (!l || E & /*$$scope*/ + 131072) && update_slot_base$3( + _, + g, + p, + /*$$scope*/ + p[17], + l ? get_slot_changes$3( + g, + /*$$scope*/ + p[17], + E, + null + ) : get_all_dirty_from_scope$3( + /*$$scope*/ + p[17] + ), + null + ), set_dynamic_element_data( + /*tag*/ + p[14] + )(s, o = get_spread_update$1(x, [ + (!l || E & /*test_id*/ + 128) && { "data-testid": ( + /*test_id*/ + p[7] + ) }, + (!l || E & /*elem_id*/ + 4) && { id: ( + /*elem_id*/ + p[2] + ) }, + (!l || E & /*elem_classes*/ + 8 && e !== (e = "block " + /*elem_classes*/ + p[3].join(" ") + " svelte-1t38q2d")) && { class: e } + ])), toggle_class$7( + s, + "hidden", + /*visible*/ + p[10] === !1 + ), toggle_class$7( + s, + "padded", + /*padding*/ + p[6] + ), toggle_class$7( + s, + "border_focus", + /*border_mode*/ + p[5] === "focus" + ), toggle_class$7(s, "hide-container", !/*explicit_call*/ + p[8] && !/*container*/ + p[9]), E & /*height*/ + 1 && set_style$3( + s, + "height", + /*get_dimension*/ + p[15]( + /*height*/ + p[0] + ) + ), E & /*width*/ + 2 && set_style$3(s, "width", typeof /*width*/ + p[1] == "number" ? `calc(min(${/*width*/ + p[1]}px, 100%))` : ( + /*get_dimension*/ + p[15]( + /*width*/ + p[1] + ) + )), E & /*variant*/ + 16 && set_style$3( + s, + "border-style", + /*variant*/ + p[4] + ), E & /*allow_overflow*/ + 2048 && set_style$3( + s, + "overflow", + /*allow_overflow*/ + p[11] ? "visible" : "hidden" + ), E & /*scale*/ + 4096 && set_style$3( + s, + "flex-grow", + /*scale*/ + p[12] + ), E & /*min_width*/ + 8192 && set_style$3(s, "min-width", `calc(min(${/*min_width*/ + p[13]}px, 100%))`); + }, + i(p) { + l || (transition_in$7(_, p), l = !0); + }, + o(p) { + transition_out$7(_, p), l = !1; + }, + d(p) { + p && detach$f(s), _ && _.d(p); + } + }; +} +function create_fragment$f(y) { + let s, e = ( + /*tag*/ + y[14] && create_dynamic_element(y) + ); + return { + c() { + e && e.c(); + }, + m(l, g) { + e && e.m(l, g), s = !0; + }, + p(l, [g]) { + /*tag*/ + l[14] && e.p(l, g); + }, + i(l) { + s || (transition_in$7(e, l), s = !0); + }, + o(l) { + transition_out$7(e, l), s = !1; + }, + d(l) { + e && e.d(l); + } + }; +} +function instance$d(y, s, e) { + let { $$slots: l = {}, $$scope: g } = s, { height: _ = void 0 } = s, { width: x = void 0 } = s, { elem_id: o = "" } = s, { elem_classes: p = [] } = s, { variant: E = "solid" } = s, { border_mode: u = "base" } = s, { padding: A = !0 } = s, { type: C = "normal" } = s, { test_id: L = void 0 } = s, { explicit_call: D = !1 } = s, { container: r = !0 } = s, { visible: n = !0 } = s, { allow_overflow: b = !0 } = s, { scale: f = null } = s, { min_width: c = 0 } = s, t = C === "fieldset" ? "fieldset" : "div"; + const a = (h) => { + if (h !== void 0) { + if (typeof h == "number") + return h + "px"; + if (typeof h == "string") + return h; + } + }; + return y.$$set = (h) => { + "height" in h && e(0, _ = h.height), "width" in h && e(1, x = h.width), "elem_id" in h && e(2, o = h.elem_id), "elem_classes" in h && e(3, p = h.elem_classes), "variant" in h && e(4, E = h.variant), "border_mode" in h && e(5, u = h.border_mode), "padding" in h && e(6, A = h.padding), "type" in h && e(16, C = h.type), "test_id" in h && e(7, L = h.test_id), "explicit_call" in h && e(8, D = h.explicit_call), "container" in h && e(9, r = h.container), "visible" in h && e(10, n = h.visible), "allow_overflow" in h && e(11, b = h.allow_overflow), "scale" in h && e(12, f = h.scale), "min_width" in h && e(13, c = h.min_width), "$$scope" in h && e(17, g = h.$$scope); + }, [ + _, + x, + o, + p, + E, + u, + A, + L, + D, + r, + n, + b, + f, + c, + t, + a, + C, + g, + l + ]; +} +class Block extends SvelteComponent$f { + constructor(s) { + super(), init$f(this, s, instance$d, create_fragment$f, safe_not_equal$g, { + height: 0, + width: 1, + elem_id: 2, + elem_classes: 3, + variant: 4, + border_mode: 5, + padding: 6, + type: 16, + test_id: 7, + explicit_call: 8, + container: 9, + visible: 10, + allow_overflow: 11, + scale: 12, + min_width: 13 + }); + } +} +const Info_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$e, + attr: attr$d, + create_slot: create_slot$2, + detach: detach$e, + element: element$b, + get_all_dirty_from_scope: get_all_dirty_from_scope$2, + get_slot_changes: get_slot_changes$2, + init: init$e, + insert: insert$e, + safe_not_equal: safe_not_equal$f, + transition_in: transition_in$6, + transition_out: transition_out$6, + update_slot_base: update_slot_base$2 +} = window.__gradio__svelte__internal; +function create_fragment$e(y) { + let s, e; + const l = ( + /*#slots*/ + y[1].default + ), g = create_slot$2( + l, + y, + /*$$scope*/ + y[0], + null + ); + return { + c() { + s = element$b("div"), g && g.c(), attr$d(s, "class", "svelte-1hnfib2"); + }, + m(_, x) { + insert$e(_, s, x), g && g.m(s, null), e = !0; + }, + p(_, [x]) { + g && g.p && (!e || x & /*$$scope*/ + 1) && update_slot_base$2( + g, + l, + _, + /*$$scope*/ + _[0], + e ? get_slot_changes$2( + l, + /*$$scope*/ + _[0], + x, + null + ) : get_all_dirty_from_scope$2( + /*$$scope*/ + _[0] + ), + null + ); + }, + i(_) { + e || (transition_in$6(g, _), e = !0); + }, + o(_) { + transition_out$6(g, _), e = !1; + }, + d(_) { + _ && detach$e(s), g && g.d(_); + } + }; +} +function instance$c(y, s, e) { + let { $$slots: l = {}, $$scope: g } = s; + return y.$$set = (_) => { + "$$scope" in _ && e(0, g = _.$$scope); + }, [g, l]; +} +class Info extends SvelteComponent$e { + constructor(s) { + super(), init$e(this, s, instance$c, create_fragment$e, safe_not_equal$f, {}); + } +} +const BlockTitle_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$d, + attr: attr$c, + check_outros: check_outros$5, + create_component: create_component$5, + create_slot: create_slot$1, + destroy_component: destroy_component$5, + detach: detach$d, + element: element$a, + empty: empty$4, + get_all_dirty_from_scope: get_all_dirty_from_scope$1, + get_slot_changes: get_slot_changes$1, + group_outros: group_outros$5, + init: init$d, + insert: insert$d, + mount_component: mount_component$5, + safe_not_equal: safe_not_equal$e, + set_data: set_data$6, + space: space$9, + text: text$8, + toggle_class: toggle_class$6, + transition_in: transition_in$5, + transition_out: transition_out$5, + update_slot_base: update_slot_base$1 +} = window.__gradio__svelte__internal; +function create_if_block$7(y) { + let s, e; + return s = new Info({ + props: { + $$slots: { default: [create_default_slot$2] }, + $$scope: { ctx: y } + } + }), { + c() { + create_component$5(s.$$.fragment); + }, + m(l, g) { + mount_component$5(s, l, g), e = !0; + }, + p(l, g) { + const _ = {}; + g & /*$$scope, info*/ + 10 && (_.$$scope = { dirty: g, ctx: l }), s.$set(_); + }, + i(l) { + e || (transition_in$5(s.$$.fragment, l), e = !0); + }, + o(l) { + transition_out$5(s.$$.fragment, l), e = !1; + }, + d(l) { + destroy_component$5(s, l); + } + }; +} +function create_default_slot$2(y) { + let s; + return { + c() { + s = text$8( + /*info*/ + y[1] + ); + }, + m(e, l) { + insert$d(e, s, l); + }, + p(e, l) { + l & /*info*/ + 2 && set_data$6( + s, + /*info*/ + e[1] + ); + }, + d(e) { + e && detach$d(s); + } + }; +} +function create_fragment$d(y) { + let s, e, l, g; + const _ = ( + /*#slots*/ + y[2].default + ), x = create_slot$1( + _, + y, + /*$$scope*/ + y[3], + null + ); + let o = ( + /*info*/ + y[1] && create_if_block$7(y) + ); + return { + c() { + s = element$a("span"), x && x.c(), e = space$9(), o && o.c(), l = empty$4(), attr$c(s, "data-testid", "block-info"), attr$c(s, "class", "svelte-22c38v"), toggle_class$6(s, "sr-only", !/*show_label*/ + y[0]), toggle_class$6(s, "hide", !/*show_label*/ + y[0]), toggle_class$6( + s, + "has-info", + /*info*/ + y[1] != null + ); + }, + m(p, E) { + insert$d(p, s, E), x && x.m(s, null), insert$d(p, e, E), o && o.m(p, E), insert$d(p, l, E), g = !0; + }, + p(p, [E]) { + x && x.p && (!g || E & /*$$scope*/ + 8) && update_slot_base$1( + x, + _, + p, + /*$$scope*/ + p[3], + g ? get_slot_changes$1( + _, + /*$$scope*/ + p[3], + E, + null + ) : get_all_dirty_from_scope$1( + /*$$scope*/ + p[3] + ), + null + ), (!g || E & /*show_label*/ + 1) && toggle_class$6(s, "sr-only", !/*show_label*/ + p[0]), (!g || E & /*show_label*/ + 1) && toggle_class$6(s, "hide", !/*show_label*/ + p[0]), (!g || E & /*info*/ + 2) && toggle_class$6( + s, + "has-info", + /*info*/ + p[1] != null + ), /*info*/ + p[1] ? o ? (o.p(p, E), E & /*info*/ + 2 && transition_in$5(o, 1)) : (o = create_if_block$7(p), o.c(), transition_in$5(o, 1), o.m(l.parentNode, l)) : o && (group_outros$5(), transition_out$5(o, 1, 1, () => { + o = null; + }), check_outros$5()); + }, + i(p) { + g || (transition_in$5(x, p), transition_in$5(o), g = !0); + }, + o(p) { + transition_out$5(x, p), transition_out$5(o), g = !1; + }, + d(p) { + p && (detach$d(s), detach$d(e), detach$d(l)), x && x.d(p), o && o.d(p); + } + }; +} +function instance$b(y, s, e) { + let { $$slots: l = {}, $$scope: g } = s, { show_label: _ = !0 } = s, { info: x = void 0 } = s; + return y.$$set = (o) => { + "show_label" in o && e(0, _ = o.show_label), "info" in o && e(1, x = o.info), "$$scope" in o && e(3, g = o.$$scope); + }, [_, x, l, g]; +} +class BlockTitle extends SvelteComponent$d { + constructor(s) { + super(), init$d(this, s, instance$b, create_fragment$d, safe_not_equal$e, { show_label: 0, info: 1 }); + } +} +const BlockLabel_svelte_svelte_type_style_lang = "", IconButton_svelte_svelte_type_style_lang = "", Empty_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$c, + append: append$a, + attr: attr$b, + detach: detach$c, + init: init$c, + insert: insert$c, + noop: noop$c, + safe_not_equal: safe_not_equal$d, + svg_element: svg_element$3 +} = window.__gradio__svelte__internal; +function create_fragment$c(y) { + let s, e; + return { + c() { + s = svg_element$3("svg"), e = svg_element$3("polyline"), attr$b(e, "points", "20 6 9 17 4 12"), attr$b(s, "xmlns", "http://www.w3.org/2000/svg"), attr$b(s, "viewBox", "2 0 20 20"), attr$b(s, "fill", "none"), attr$b(s, "stroke", "currentColor"), attr$b(s, "stroke-width", "3"), attr$b(s, "stroke-linecap", "round"), attr$b(s, "stroke-linejoin", "round"); + }, + m(l, g) { + insert$c(l, s, g), append$a(s, e); + }, + p: noop$c, + i: noop$c, + o: noop$c, + d(l) { + l && detach$c(s); + } + }; +} +class Check extends SvelteComponent$c { + constructor(s) { + super(), init$c(this, s, null, create_fragment$c, safe_not_equal$d, {}); + } +} +const { + SvelteComponent: SvelteComponent$b, + append: append$9, + attr: attr$a, + detach: detach$b, + init: init$b, + insert: insert$b, + noop: noop$b, + safe_not_equal: safe_not_equal$c, + svg_element: svg_element$2 +} = window.__gradio__svelte__internal; +function create_fragment$b(y) { + let s, e, l; + return { + c() { + s = svg_element$2("svg"), e = svg_element$2("path"), l = svg_element$2("path"), attr$a(e, "fill", "currentColor"), attr$a(e, "d", "M28 10v18H10V10h18m0-2H10a2 2 0 0 0-2 2v18a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2Z"), attr$a(l, "fill", "currentColor"), attr$a(l, "d", "M4 18H2V4a2 2 0 0 1 2-2h14v2H4Z"), attr$a(s, "xmlns", "http://www.w3.org/2000/svg"), attr$a(s, "viewBox", "0 0 33 33"), attr$a(s, "color", "currentColor"); + }, + m(g, _) { + insert$b(g, s, _), append$9(s, e), append$9(s, l); + }, + p: noop$b, + i: noop$b, + o: noop$b, + d(g) { + g && detach$b(s); + } + }; +} +class Copy extends SvelteComponent$b { + constructor(s) { + super(), init$b(this, s, null, create_fragment$b, safe_not_equal$c, {}); + } +} +const DropdownArrow_svelte_svelte_type_style_lang = "", 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( + (y, { color: s, primary: e, secondary: l }) => ({ + ...y, + [s]: { + primary: tw_colors[s][e], + secondary: tw_colors[s][l] + } + }), + {} +); +const UploadText_svelte_svelte_type_style_lang = "", Toolbar_svelte_svelte_type_style_lang = "", SelectSource_svelte_svelte_type_style_lang = "", Button_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$a, + append: append$8, + attr: attr$9, + detach: detach$a, + element: element$9, + init: init$a, + insert: insert$a, + listen: listen$4, + noop: noop$a, + run_all: run_all$4, + safe_not_equal: safe_not_equal$b, + space: space$8 +} = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$5 } = window.__gradio__svelte__internal; +function create_if_block$6(y) { + let s, e, l; + return { + c() { + s = element$9("button"), s.innerHTML = ' Covalent modifcation', attr$9(s, "class", "flex items-center space-x-2 block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white svelte-8wrmgx"); + }, + m(g, _) { + insert$a(g, s, _), e || (l = listen$4( + s, + "click", + /*click_handler_3*/ + y[7] + ), e = !0); + }, + p: noop$a, + d(g) { + g && detach$a(s), e = !1, l(); + } + }; +} +function create_fragment$a(y) { + let s, e, l, g, _, x, o, p, E, u, A = ( + /*displayCovMod*/ + y[0] && create_if_block$6(y) + ); + return { + c() { + s = element$9("div"), e = element$9("div"), l = element$9("button"), l.innerHTML = ' Protein', g = space$8(), _ = element$9("button"), _.innerHTML = ' Nucleic acid', x = space$8(), o = element$9("button"), o.innerHTML = ' Small molecule', p = space$8(), A && A.c(), attr$9(l, "class", "flex items-center space-x-2 block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white svelte-8wrmgx"), attr$9(_, "class", "flex items-center space-x-2 block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white svelte-8wrmgx"), attr$9(o, "class", "flex items-center space-x-2 block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white svelte-8wrmgx"), attr$9(e, "class", "flex justify-center mt-2 svelte-8wrmgx"), attr$9(s, "class", "svelte-8wrmgx"); + }, + m(C, L) { + insert$a(C, s, L), append$8(s, e), append$8(e, l), append$8(e, g), append$8(e, _), append$8(e, x), append$8(e, o), append$8(e, p), A && A.m(e, null), E || (u = [ + listen$4( + l, + "click", + /*click_handler*/ + y[4] + ), + listen$4( + _, + "click", + /*click_handler_1*/ + y[5] + ), + listen$4( + o, + "click", + /*click_handler_2*/ + y[6] + ) + ], E = !0); + }, + p(C, [L]) { + /*displayCovMod*/ + C[0] ? A ? A.p(C, L) : (A = create_if_block$6(C), A.c(), A.m(e, null)) : A && (A.d(1), A = null); + }, + i: noop$a, + o: noop$a, + d(C) { + C && detach$a(s), A && A.d(), E = !1, run_all$4(u); + } + }; +} +function instance$a(y, s, e) { + const l = createEventDispatcher$5(); + let { vals: g = [] } = s; + function _(C) { + l("addNewChain", { type: C }); + } + function x() { + l("addCovalentModification"); + } + let o = !1; + const p = () => { + _("protein"); + }, E = () => { + _("DNA"); + }, u = () => { + _("ligand"); + }, A = () => { + x(); + }; + return y.$$set = (C) => { + "vals" in C && e(3, g = C.vals); + }, y.$$.update = () => { + y.$$.dirty & /*vals*/ + 8 && e(0, o = g.filter((C) => C.class === "protein" && C.sequence.length > 0).length > 0 && g.filter((C) => C.class === "ligand" && C.sdf != "").length > 0); + }, [ + o, + _, + x, + g, + p, + E, + u, + A + ]; +} +class Button extends SvelteComponent$a { + constructor(s) { + super(), init$a(this, s, instance$a, create_fragment$a, safe_not_equal$b, { vals: 3 }); + } +} +const SearchInput_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$9, + append: append$7, + attr: attr$8, + detach: detach$9, + element: element$8, + init: init$9, + insert: insert$9, + listen: listen$3, + noop: noop$9, + prevent_default, + run_all: run_all$3, + safe_not_equal: safe_not_equal$a, + space: space$7, + text: text$7 +} = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$4 } = window.__gradio__svelte__internal; +function create_fragment$9(y) { + let s, e, l, g, _, x = ( + /*databases*/ + y[1][ + /*currentSel*/ + y[3] + ] + "" + ), o, p, E, u, A, C, L, D, r, n; + return { + c() { + s = element$8("form"), e = element$8("div"), l = element$8("label"), l.textContent = "Search", g = space$7(), _ = element$8("button"), o = text$7(x), p = space$7(), E = element$8("div"), E.innerHTML = '', u = space$7(), A = element$8("div"), C = element$8("input"), L = space$7(), D = element$8("button"), D.innerHTML = ' Search', attr$8(l, "for", "search-dropdown"), attr$8(l, "class", "mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white svelte-8wrmgx"), attr$8(_, "id", "dropdown-button"), attr$8(_, "data-dropdown-toggle", "dropdown"), attr$8(_, "class", "flex-shrink-0 z-10 inline-flex items-center py-2.5 px-4 text-sm font-medium text-center text-gray-900 bg-gray-100 border border-gray-300 rounded-s-lg hover:bg-gray-200 focus:ring-4 focus:outline-none focus:ring-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:focus:ring-gray-700 dark:text-white dark:border-gray-600 svelte-8wrmgx"), attr$8(_, "type", "button"), attr$8(E, "id", "dropdown"), attr$8(E, "class", "z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 svelte-8wrmgx"), attr$8(C, "type", "search"), attr$8(C, "id", "search-dropdown"), attr$8(C, "class", "block p-2.5 w-full z-20 text-sm text-gray-900 bg-gray-50 rounded-e-lg border-s-gray-50 border-s-2 border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-s-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:border-blue-500 svelte-8wrmgx"), attr$8( + C, + "placeholder", + /*placeholder*/ + y[2][ + /*currentSel*/ + y[3] + ] + ), attr$8(D, "type", "submit"), attr$8(D, "class", "absolute top-0 end-0 p-2.5 text-sm font-medium h-full text-white bg-blue-700 rounded-e-lg border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 svelte-8wrmgx"), attr$8(A, "class", "relative w-full svelte-8wrmgx"), attr$8(e, "class", "flex svelte-8wrmgx"), attr$8(s, "class", "max-w-lg mx-auto mb-2 my-2 svelte-8wrmgx"); + }, + m(b, f) { + insert$9(b, s, f), append$7(s, e), append$7(e, l), append$7(e, g), append$7(e, _), append$7(_, o), append$7(e, p), append$7(e, E), append$7(e, u), append$7(e, A), append$7(A, C), append$7(A, L), append$7(A, D), r || (n = [ + listen$3( + C, + "input", + /*input_handler*/ + y[7] + ), + listen$3(D, "click", prevent_default( + /*triggerFetch*/ + y[4] + )) + ], r = !0); + }, + p: noop$9, + i: noop$9, + o: noop$9, + d(b) { + b && detach$9(s), r = !1, run_all$3(n); + } + }; +} +function instance$9(y, s, e) { + const l = createEventDispatcher$4(); + let { database: g = "rcsb-bioass" } = s, { index: _ = 0 } = s, x = { + "rcsb-3ligand": "RCSB 3-Letter Codes", + pubchem: "Pubchem", + "rcsb-bioass": "RCSB BioAssembly" + }, o = { + "rcsb-3ligand": "e.g HEM, ZN, K, GOL ...", + pubchem: "molecule name", + "rcsb-bioass": "4 Letter PDB Code" + }, p = g, E = ""; + function u() { + l("triggerFetch", { + text: E, + database: p, + index: _ + }); + } + const A = (C) => e(0, E = C.target.value); + return y.$$set = (C) => { + "database" in C && e(5, g = C.database), "index" in C && e(6, _ = C.index); + }, [ + E, + x, + o, + p, + u, + g, + _, + A + ]; +} +class SearchInput extends SvelteComponent$9 { + constructor(s) { + super(), init$9(this, s, instance$9, create_fragment$9, safe_not_equal$a, { database: 5, index: 6 }); + } +} +const Sequence_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$8, + append: append$6, + attr: attr$7, + destroy_each: destroy_each$2, + detach: detach$8, + element: element$7, + ensure_array_like: ensure_array_like$2, + init: init$8, + insert: insert$8, + noop: noop$8, + safe_not_equal: safe_not_equal$9, + set_style: set_style$2, + space: space$6, + text: text$6 +} = window.__gradio__svelte__internal; +function get_each_context$2(y, s, e) { + const l = y.slice(); + return l[3] = s[e], l[5] = e, l; +} +function get_each_context_1$2(y, s, e) { + const l = y.slice(); + return l[6] = s[e], l[8] = e, l; +} +function create_each_block_1$2(y) { + let s, e, l = ( + /*letter*/ + y[6] + "" + ), g; + return { + c() { + s = element$7("span"), e = element$7("div"), g = text$6(l), attr$7(e, "class", "inline-block p-0.5 svelte-hhspdt"), attr$7(e, "title", "residue " + /*chunk_ids*/ + y[1][ + /*i*/ + y[5] + ][ + /*j*/ + y[8] + ]), attr$7(s, "class", "p-0.1 text-center w-full inline hover:font-bold cursor-pointer item-selectable ds-selectable svelte-hhspdt"), set_style$2(s, "font-family", "monospace"); + }, + m(_, x) { + insert$8(_, s, x), append$6(s, e), append$6(e, g); + }, + p: noop$8, + d(_) { + _ && detach$8(s); + } + }; +} +function create_each_block$2(y) { + let s, e, l = ensure_array_like$2( + /*chunk*/ + y[3] + ), g = []; + for (let _ = 0; _ < l.length; _ += 1) + g[_] = create_each_block_1$2(get_each_context_1$2(y, l, _)); + return { + c() { + s = element$7("div"); + for (let _ = 0; _ < g.length; _ += 1) + g[_].c(); + e = space$6(), attr$7(s, "class", "sequence__chunk svelte-hhspdt"); + }, + m(_, x) { + insert$8(_, s, x); + for (let o = 0; o < g.length; o += 1) + g[o] && g[o].m(s, null); + append$6(s, e); + }, + p(_, x) { + if (x & /*chunk_ids, chunked_seq*/ + 3) { + l = ensure_array_like$2( + /*chunk*/ + _[3] + ); + let o; + for (o = 0; o < l.length; o += 1) { + const p = get_each_context_1$2(_, l, o); + g[o] ? g[o].p(p, x) : (g[o] = create_each_block_1$2(p), g[o].c(), g[o].m(s, e)); + } + for (; o < g.length; o += 1) + g[o].d(1); + g.length = l.length; + } + }, + d(_) { + _ && detach$8(s), destroy_each$2(g, _); + } + }; +} +function create_fragment$8(y) { + let s, e = ensure_array_like$2( + /*chunked_seq*/ + y[0] + ), l = []; + for (let g = 0; g < e.length; g += 1) + l[g] = create_each_block$2(get_each_context$2(y, e, g)); + return { + c() { + s = element$7("div"); + for (let g = 0; g < l.length; g += 1) + l[g].c(); + attr$7(s, "class", "sequence_container text-xs svelte-hhspdt"); + }, + m(g, _) { + insert$8(g, s, _); + for (let x = 0; x < l.length; x += 1) + l[x] && l[x].m(s, null); + }, + p(g, [_]) { + if (_ & /*chunked_seq, chunk_ids*/ + 3) { + e = ensure_array_like$2( + /*chunked_seq*/ + g[0] + ); + let x; + for (x = 0; x < e.length; x += 1) { + const o = get_each_context$2(g, e, x); + l[x] ? l[x].p(o, _) : (l[x] = create_each_block$2(o), l[x].c(), l[x].m(s, null)); + } + for (; x < l.length; x += 1) + l[x].d(1); + l.length = e.length; + } + }, + i: noop$8, + o: noop$8, + d(g) { + g && detach$8(s), destroy_each$2(l, g); + } + }; +} +function instance$8(y, s, e) { + let { seq: l = "" } = s, g = l.match(/.{1,10}/g), _ = g.map((x, o) => x.split("").map((p, E) => o * 10 + E + 1)); + return y.$$set = (x) => { + "seq" in x && e(2, l = x.seq); + }, [g, _, l]; +} +class Sequence extends SvelteComponent$8 { + constructor(s) { + super(), init$8(this, s, instance$8, create_fragment$8, safe_not_equal$9, { seq: 2 }); + } +} +var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function getDefaultExportFromCjs(y) { + return y && y.__esModule && Object.prototype.hasOwnProperty.call(y, "default") ? y.default : y; +} +var _3Dmol = { exports: {} }; +/*! + * 3dmol v2.1.0 + * JavaScript/TypeScript molecular visualization library + * Author: David Koes and contributors + */ +(function(module, exports) { + (function(s, e) { + module.exports = e(); + })(commonjsGlobal, () => ( + /******/ + (() => { + var __webpack_modules__ = { + /***/ + "./node_modules/iobuffer/lib-esm/IOBuffer.js": ( + /*!***************************************************!*\ + !*** ./node_modules/iobuffer/lib-esm/IOBuffer.js ***! + \***************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + IOBuffer: () => ( + /* binding */ + o + ) + /* harmony export */ + }); + var l = e( + /*! ./text */ + "./node_modules/iobuffer/lib-esm/text.browser.js" + ); + const g = 1024 * 8, _ = (() => { + const p = new Uint8Array(4), E = new Uint32Array(p.buffer); + return !((E[0] = 1) & p[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 o { + /** + * @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 = g, u = {}) { + let A = !1; + typeof E == "number" ? E = new ArrayBuffer(E) : (A = !0, this.lastWrittenByte = E.byteLength); + const C = u.offset ? u.offset >>> 0 : 0, L = E.byteLength - C; + let D = C; + (ArrayBuffer.isView(E) || E instanceof o) && (E.byteLength !== E.buffer.byteLength && (D = E.byteOffset + C), E = E.buffer), A ? this.lastWrittenByte = L : this.lastWrittenByte = 0, this.buffer = E, this.length = L, this.byteLength = L, this.byteOffset = D, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, D, L), 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 A = (this.offset + E) * 2, C = new Uint8Array(A); + C.set(new Uint8Array(this.buffer)), this.buffer = C.buffer, this.length = this.byteLength = A, 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, u) { + const A = x[u].BYTES_PER_ELEMENT * E, C = this.byteOffset + this.offset, L = this.buffer.slice(C, C + A); + if (this.littleEndian === _ && u !== "uint8" && u !== "int8") { + const r = new Uint8Array(this.buffer.slice(C, C + A)); + r.reverse(); + const n = new x[u](r.buffer); + return this.offset += A, n.reverse(), n; + } + const D = new x[u](L); + return this.offset += A, D; + } + /** + * 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 u = ""; + for (let A = 0; A < E; A++) + u += this.readChar(); + return u; + } + /** + * Read the next `n` bytes, return a UTF-8 decoded string and move pointer + * forward by `n` bytes. + */ + readUtf8(E = 1) { + return (0, l.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, u = "utf-8") { + return (0, l.decode)(this.readBytes(E), u); + } + /** + * 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 u = 0; u < E.length; u++) + this._data.setUint8(this.offset++, E[u]); + 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 u = 0; u < E.length; u++) + this.writeUint8(E.charCodeAt(u)); + 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, l.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(y) { + if (y.TextEncoder && y.TextDecoder) + return !1; + function s(l = "utf-8") { + if (l !== "utf-8") + throw new RangeError(`Failed to construct 'TextEncoder': The encoding label provided ('${l}') is invalid.`); + } + Object.defineProperty(s.prototype, "encoding", { + value: "utf-8" + }), s.prototype.encode = function(l, g = { stream: !1 }) { + if (g.stream) + throw new Error("Failed to encode: the 'stream' option is unsupported."); + let _ = 0; + const x = l.length; + let o = 0, p = Math.max(32, x + (x >> 1) + 7), E = new Uint8Array(p >> 3 << 3); + for (; _ < x; ) { + let u = l.charCodeAt(_++); + if (u >= 55296 && u <= 56319) { + if (_ < x) { + const A = l.charCodeAt(_); + (A & 64512) === 56320 && (++_, u = ((u & 1023) << 10) + (A & 1023) + 65536); + } + if (u >= 55296 && u <= 56319) + continue; + } + if (o + 4 > E.length) { + p += 8, p *= 1 + _ / l.length * 2, p = p >> 3 << 3; + const A = new Uint8Array(p); + A.set(E), E = A; + } + if (u & 4294967168) + if (!(u & 4294965248)) + E[o++] = u >> 6 & 31 | 192; + else if (!(u & 4294901760)) + E[o++] = u >> 12 & 15 | 224, E[o++] = u >> 6 & 63 | 128; + else if (!(u & 4292870144)) + E[o++] = u >> 18 & 7 | 240, E[o++] = u >> 12 & 63 | 128, E[o++] = u >> 6 & 63 | 128; + else + continue; + else { + E[o++] = u; + continue; + } + E[o++] = u & 63 | 128; + } + return E.slice(0, o); + }; + function e(l = "utf-8", g = { fatal: !1 }) { + if (l !== "utf-8") + throw new RangeError(`Failed to construct 'TextDecoder': The encoding label provided ('${l}') is invalid.`); + if (g.fatal) + throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported."); + } + Object.defineProperty(e.prototype, "encoding", { + value: "utf-8" + }), Object.defineProperty(e.prototype, "fatal", { value: !1 }), Object.defineProperty(e.prototype, "ignoreBOM", { + value: !1 + }), e.prototype.decode = function(l, g = { stream: !1 }) { + if (g.stream) + throw new Error("Failed to decode: the 'stream' option is unsupported."); + const _ = new Uint8Array(l); + let x = 0; + const o = _.length, p = []; + for (; x < o; ) { + const E = _[x++]; + if (E === 0) + break; + if (!(E & 128)) + p.push(E); + else if ((E & 224) === 192) { + const u = _[x++] & 63; + p.push((E & 31) << 6 | u); + } else if ((E & 240) === 224) { + const u = _[x++] & 63, A = _[x++] & 63; + p.push((E & 31) << 12 | u << 6 | A); + } else if ((E & 248) === 240) { + const u = _[x++] & 63, A = _[x++] & 63, C = _[x++] & 63; + let L = (E & 7) << 18 | u << 12 | A << 6 | C; + L > 65535 && (L -= 65536, p.push(L >>> 10 & 1023 | 55296), L = 56320 | L & 1023), p.push(L); + } + } + return String.fromCharCode.apply(null, p); + }, y.TextEncoder = s, y.TextDecoder = e; + })(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 ***! + \*******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + decode: () => ( + /* binding */ + l + ), + /* harmony export */ + encode: () => ( + /* binding */ + _ + ) + /* harmony export */ + }), e( + /*! ./text-encoding-polyfill */ + "./node_modules/iobuffer/lib-esm/text-encoding-polyfill.js" + ); + function l(x, o = "utf8") { + return new TextDecoder(o).decode(x); + } + const g = new TextEncoder(); + function _(x) { + return g.encode(x); + } + } + ), + /***/ + "./node_modules/netcdfjs/lib-esm/data.js": ( + /*!***********************************************!*\ + !*** ./node_modules/netcdfjs/lib-esm/data.js ***! + \***********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + nonRecord: () => ( + /* binding */ + g + ), + /* harmony export */ + record: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./types */ + "./node_modules/netcdfjs/lib-esm/types.js" + ); + function g(x, o) { + const p = (0, l.str2num)(o.type), E = o.size / (0, l.num2bytes)(p), u = new Array(E); + for (let A = 0; A < E; A++) + u[A] = (0, l.readType)(x, p, 1); + return u; + } + function _(x, o, p) { + const E = (0, l.str2num)(o.type), u = o.size ? o.size / (0, l.num2bytes)(E) : 1, A = p.length, C = new Array(A), L = p.recordStep; + if (L) + for (let D = 0; D < A; D++) { + const r = x.offset; + C[D] = (0, l.readType)(x, E, u), x.seek(r + L); + } + else + throw new Error("recordDimension.recordStep is undefined"); + return C; + } + } + ), + /***/ + "./node_modules/netcdfjs/lib-esm/header.js": ( + /*!*************************************************!*\ + !*** ./node_modules/netcdfjs/lib-esm/header.js ***! + \*************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + header: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var l = e( + /*! ./types */ + "./node_modules/netcdfjs/lib-esm/types.js" + ), g = e( + /*! ./utils */ + "./node_modules/netcdfjs/lib-esm/utils.js" + ); + const _ = 0, x = 10, o = 11, p = 12, E = 0; + function u(D, r) { + const n = { version: r }, b = { + length: D.readUint32() + }, f = A(D); + Array.isArray(f) || (b.id = f.recordId, b.name = f.recordName, n.dimensions = f.dimensions), n.globalAttributes = C(D); + const c = L(D, b == null ? void 0 : b.id, r); + return Array.isArray(c) || (n.variables = c.variables, b.recordStep = c.recordStep), n.recordDimension = b, n; + } + function A(D) { + const r = {}; + let n, b; + const f = D.readUint32(); + let c; + if (f === _) + return (0, g.notNetcdf)(D.readUint32() !== _, "wrong empty tag for list of dimensions"), []; + { + (0, g.notNetcdf)(f !== x, "wrong tag for list of dimensions"); + const t = D.readUint32(); + c = new Array(t); + for (let a = 0; a < t; a++) { + const h = (0, g.readName)(D), M = D.readUint32(); + M === E && (n = a, b = h), c[a] = { + name: h, + size: M + }; + } + } + return n !== void 0 && (r.recordId = n), b !== void 0 && (r.recordName = b), r.dimensions = c, r; + } + function C(D) { + const r = D.readUint32(); + let n; + if (r === _) + return (0, g.notNetcdf)(D.readUint32() !== _, "wrong empty tag for list of attributes"), []; + { + (0, g.notNetcdf)(r !== p, "wrong tag for list of attributes"); + const b = D.readUint32(); + n = new Array(b); + for (let f = 0; f < b; f++) { + const c = (0, g.readName)(D), t = D.readUint32(); + (0, g.notNetcdf)(t < 1 || t > 6, `non valid type ${t}`); + const a = D.readUint32(), h = (0, l.readType)(D, t, a); + (0, g.padding)(D), n[f] = { + name: c, + type: (0, l.num2str)(t), + value: h + }; + } + } + return n; + } + function L(D, r, n) { + const b = D.readUint32(); + let f = 0, c; + if (b === _) + return (0, g.notNetcdf)(D.readUint32() !== _, "wrong empty tag for list of variables"), []; + { + (0, g.notNetcdf)(b !== o, "wrong tag for list of variables"); + const t = D.readUint32(); + c = new Array(t); + for (let a = 0; a < t; a++) { + const h = (0, g.readName)(D), M = D.readUint32(), w = new Array(M); + for (let B = 0; B < M; B++) + w[B] = D.readUint32(); + const S = C(D), T = D.readUint32(); + (0, g.notNetcdf)(T < 1 && T > 6, `non valid type ${T}`); + const R = D.readUint32(); + let z = D.readUint32(); + n === 2 && ((0, g.notNetcdf)(z > 0, "offsets larger than 4GB not supported"), z = D.readUint32()); + let P = !1; + typeof r < "u" && w[0] === r && (f += R, P = !0), c[a] = { + name: h, + dimensions: w, + attributes: S, + type: (0, l.num2str)(T), + size: R, + offset: z, + record: P + }; + } + } + return { + variables: c, + recordStep: f + }; + } + } + ), + /***/ + "./node_modules/netcdfjs/lib-esm/index.js": ( + /*!************************************************!*\ + !*** ./node_modules/netcdfjs/lib-esm/index.js ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + NetCDFReader: () => ( + /* reexport safe */ + l.NetCDFReader + ) + /* harmony export */ + }); + var l = e( + /*! ./parser */ + "./node_modules/netcdfjs/lib-esm/parser.js" + ); + } + ), + /***/ + "./node_modules/netcdfjs/lib-esm/parser.js": ( + /*!*************************************************!*\ + !*** ./node_modules/netcdfjs/lib-esm/parser.js ***! + \*************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + NetCDFReader: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! iobuffer */ + "./node_modules/iobuffer/lib-esm/IOBuffer.js" + ), g = e( + /*! ./data */ + "./node_modules/netcdfjs/lib-esm/data.js" + ), _ = e( + /*! ./header */ + "./node_modules/netcdfjs/lib-esm/header.js" + ), x = e( + /*! ./toString */ + "./node_modules/netcdfjs/lib-esm/toString.js" + ), o = e( + /*! ./utils */ + "./node_modules/netcdfjs/lib-esm/utils.js" + ); + class p { + constructor(u) { + this.toString = x.toString; + const A = new l.IOBuffer(u); + A.setBigEndian(), (0, o.notNetcdf)(A.readChars(3) !== "CDF", "should start with CDF"); + const C = A.readByte(); + (0, o.notNetcdf)(C > 2, "unknown version"), this.header = (0, _.header)(A, C), this.buffer = A; + } + /** + * @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(u) { + const A = this.globalAttributes.find((C) => C.name === u); + return A ? A.value : null; + } + /** + * Returns the value of a variable as a string + * @param - variableName + * @return - Value of the variable as a string or null + */ + getDataVariableAsString(u) { + const A = this.getDataVariable(u); + return A ? A.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(u) { + let A; + if (typeof u == "string" ? A = this.header.variables.find((C) => C.name === u) : A = u, A === void 0) + throw new Error("Not a valid NetCDF v3.x file: variable not found"); + return this.buffer.seek(A.offset), A.record ? (0, g.record)(this.buffer, A, this.header.recordDimension) : (0, g.nonRecord)(this.buffer, A); + } + /** + * Check if a dataVariable exists + * @param variableName - Name of the variable to find + * @return boolean + */ + dataVariableExists(u) { + return this.header.variables.find((C) => C.name === u) !== void 0; + } + /** + * Check if an attribute exists + * @param attributeName - Name of the attribute to find + * @return boolean + */ + attributeExists(u) { + return this.globalAttributes.find((C) => C.name === u) !== void 0; + } + } + } + ), + /***/ + "./node_modules/netcdfjs/lib-esm/toString.js": ( + /*!***************************************************!*\ + !*** ./node_modules/netcdfjs/lib-esm/toString.js ***! + \***************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + toString: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + function l() { + const g = []; + g.push("DIMENSIONS"); + for (const x of this.dimensions) + g.push(` ${x.name.padEnd(30)} = size: ${x.size}`); + g.push(""), g.push("GLOBAL ATTRIBUTES"); + for (const x of this.globalAttributes) + g.push(` ${x.name.padEnd(30)} = ${x.value}`); + const _ = JSON.parse(JSON.stringify(this.variables)); + g.push(""), g.push("VARIABLES:"); + for (const x of _) { + x.value = this.getDataVariable(x); + let o = JSON.stringify(x.value); + o.length > 50 && (o = o.substring(0, 50)), isNaN(x.value.length) || (o += ` (length: ${x.value.length})`), g.push(` ${x.name.padEnd(30)} = ${o}`); + } + return g.join(` +`); + } + } + ), + /***/ + "./node_modules/netcdfjs/lib-esm/types.js": ( + /*!************************************************!*\ + !*** ./node_modules/netcdfjs/lib-esm/types.js ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + num2bytes: () => ( + /* binding */ + _ + ), + /* harmony export */ + num2str: () => ( + /* binding */ + g + ), + /* harmony export */ + readType: () => ( + /* binding */ + p + ), + /* harmony export */ + str2num: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + const l = { + BYTE: 1, + CHAR: 2, + SHORT: 3, + INT: 4, + FLOAT: 5, + DOUBLE: 6 + }; + function g(u) { + switch (Number(u)) { + case l.BYTE: + return "byte"; + case l.CHAR: + return "char"; + case l.SHORT: + return "short"; + case l.INT: + return "int"; + case l.FLOAT: + return "float"; + case l.DOUBLE: + return "double"; + default: + return "undefined"; + } + } + function _(u) { + switch (Number(u)) { + case l.BYTE: + return 1; + case l.CHAR: + return 1; + case l.SHORT: + return 2; + case l.INT: + return 4; + case l.FLOAT: + return 4; + case l.DOUBLE: + return 8; + default: + return -1; + } + } + function x(u) { + switch (String(u)) { + case "byte": + return l.BYTE; + case "char": + return l.CHAR; + case "short": + return l.SHORT; + case "int": + return l.INT; + case "float": + return l.FLOAT; + case "double": + return l.DOUBLE; + default: + return -1; + } + } + function o(u, A) { + if (u !== 1) { + const C = new Array(u); + for (let L = 0; L < u; L++) + C[L] = A(); + return C; + } else + return A(); + } + function p(u, A, C) { + switch (A) { + case l.BYTE: + return Array.from(u.readBytes(C)); + case l.CHAR: + return E(u.readChars(C)); + case l.SHORT: + return o(C, u.readInt16.bind(u)); + case l.INT: + return o(C, u.readInt32.bind(u)); + case l.FLOAT: + return o(C, u.readFloat32.bind(u)); + case l.DOUBLE: + return o(C, u.readFloat64.bind(u)); + default: + throw new Error(`non valid type ${A}`); + } + } + function E(u) { + return u.charCodeAt(u.length - 1) === 0 ? u.substring(0, u.length - 1) : u; + } + } + ), + /***/ + "./node_modules/netcdfjs/lib-esm/utils.js": ( + /*!************************************************!*\ + !*** ./node_modules/netcdfjs/lib-esm/utils.js ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + notNetcdf: () => ( + /* binding */ + l + ), + /* harmony export */ + padding: () => ( + /* binding */ + g + ), + /* harmony export */ + readName: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + function l(x, o) { + if (x) + throw new TypeError(`Not a valid NetCDF v3.x file: ${o}`); + } + function g(x) { + x.offset % 4 !== 0 && x.skip(4 - x.offset % 4); + } + function _(x) { + const o = x.readUint32(), p = x.readChars(o); + return g(x), p; + } + } + ), + /***/ + "./src/WebGL/shaders/lib/basic/basic.frag": ( + /*!************************************************!*\ + !*** ./src/WebGL/shaders/lib/basic/basic.frag ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \****************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \****************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` +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 ***! + \****************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \****************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \****************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \****************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \******************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` +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 ***! + \******************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \********************************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \********************************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \************************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` 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 ***! + \****************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \******************************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` + +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 ***! + \**********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = ` +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 ***! + \**********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \**************************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + default: () => l + /* harmony export */ + }); + const l = `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 ***! + \***********************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + CAP: () => ( + /* binding */ + g + ), + /* harmony export */ + GLDraw: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), g; + (function(x) { + x[x.NONE = 0] = "NONE", x[x.FLAT = 1] = "FLAT", x[x.ROUND = 2] = "ROUND"; + })(g || (g = {})); + var _; + (function(x) { + function o(r, n, b) { + var f = Math.hypot(r, n), c, t, a, h, M; + f < 1e-4 ? (t = 0, a = 1) : (t = -r / f, a = n / f), n = -t * r + a * n, c = Math.hypot(n, b), c < 1e-4 ? (h = 0, M = 1) : (h = b / c, M = n / c); + var w = new Float32Array(9); + return w[0] = a, w[1] = t, w[2] = 0, w[3] = -t * M, w[4] = a * M, w[5] = h, w[6] = t * h, w[7] = -a * h, w[8] = M, w; + } + class p { + constructor() { + this.cache = {}; + let n = [], b = 4, f = Math.pow(2, b), c = 2, t = Math.pow(2, c), a = f / t, h; + for (n[0] = new l.Vector3(-1, 0, 0), n[a] = new l.Vector3(0, 0, 1), n[a * 2] = new l.Vector3(1, 0, 0), n[a * 3] = new l.Vector3(0, 0, -1), c = 3; c <= b; c++) { + for (t = Math.pow(2, c - 1), a = f / t, h = 0; h < t - 1; h++) + n[a / 2 + h * a] = n[h * a].clone().add(n[(h + 1) * a]).normalize(); + h = t - 1, n[a / 2 + h * a] = n[h * a].clone().add(n[0]).normalize(); + } + this.basisVectors = n; + } + getVerticesForRadius(n, b, f) { + if (typeof this.cache < "u" && this.cache[n] !== void 0 && this.cache[n][b + f] !== void 0) + return this.cache[n][b + f]; + for (var c = this.basisVectors.length, t = [], a = [], h, M = 0; M < c; M++) + t.push(this.basisVectors[M].clone().multiplyScalar(n)), t.push(this.basisVectors[M].clone().multiplyScalar(n)), h = this.basisVectors[M].clone().normalize(), a.push(h), a.push(h); + var w = [], S = 10, T = c, R = 0, z = Math.PI * 2, P = 0, B = Math.PI, U, F, $ = !1, W = !1; + for (F = 0; F <= S; F++) { + $ = F === 0 || F === S, W = F === S / 2; + var N = [], G = []; + for (U = 0; U <= T; U++) { + if (W) { + var k = U < T ? 2 * U : 0; + G.push(k + 1), N.push(k); + continue; + } + var j = U / T, Q = F / S; + if (!$ || U === 0) + if (U < T) { + var ie = new l.Vector3(); + ie.x = -n * Math.cos(R + j * z) * Math.sin(P + Q * B), b == 1 ? ie.y = 0 : ie.y = n * Math.cos(P + Q * B), ie.z = n * Math.sin(R + j * z) * Math.sin(P + Q * B), Math.abs(ie.x) < 1e-5 && (ie.x = 0), Math.abs(ie.y) < 1e-5 && (ie.y = 0), Math.abs(ie.z) < 1e-5 && (ie.z = 0), b == g.FLAT ? (h = new l.Vector3(0, Math.cos(P + Q * B), 0), h.normalize()) : (h = new l.Vector3(ie.x, ie.y, ie.z), h.normalize()), t.push(ie), a.push(h), N.push(t.length - 1); + } else + N.push(t.length - T); + else + $ && N.push(t.length - 1); + } + W && w.push(G), w.push(N); + } + var pe = { + vertices: t, + normals: a, + verticesRows: w, + w: T, + h: S + }; + return n in this.cache || (this.cache[n] = {}), this.cache[n][b + f] = pe, pe; + } + } + var E = new p(); + function u(r, n, b, f, c, t = 0, a = 0) { + if (!n || !b) + return; + let h = function(Ee) { + if (typeof Ee == "string") { + let He = Ee; + return He.toLowerCase() == "flat" ? g.FLAT : He.toLowerCase() == "round" ? g.ROUND : g.NONE; + } else + return Ee; + }; + t = h(t), a = h(a); + var M = a || t; + c = c || { r: 0, g: 0, b: 0 }; + var w = o(b.x - n.x, b.y - n.y, b.z - n.z), S = E.getVerticesForRadius(f, a, "to"), T = S.w, R = S.h, z = M ? R * T + 2 : 2 * T, P = r.updateGeoGroup(z), B = S.vertices, U = S.normals, F = S.verticesRows, $ = F[R / 2], W = F[R / 2 + 1], N = P.vertices, G, k, j, Q, ie, pe, he = P.vertexArray, ue = P.normalArray, se = P.colorArray, ae = P.faceArray; + for (j = 0; j < T; ++j) { + var we = 2 * j; + Q = w[0] * B[we].x + w[3] * B[we].y + w[6] * B[we].z, ie = w[1] * B[we].x + w[4] * B[we].y + w[7] * B[we].z, pe = w[5] * B[we].y + w[8] * B[we].z, G = 3 * (N + we), k = P.faceidx, he[G] = Q + n.x, he[G + 1] = ie + n.y, he[G + 2] = pe + n.z, he[G + 3] = Q + b.x, he[G + 4] = ie + b.y, he[G + 5] = pe + b.z, ue[G] = Q, ue[G + 3] = Q, ue[G + 1] = ie, ue[G + 4] = ie, ue[G + 2] = pe, ue[G + 5] = pe, se[G] = c.r, se[G + 3] = c.r, se[G + 1] = c.g, se[G + 4] = c.g, se[G + 2] = c.b, se[G + 5] = c.b, ae[k] = W[j] + N, ae[k + 1] = W[j + 1] + N, ae[k + 2] = $[j] + N, ae[k + 3] = $[j] + N, ae[k + 4] = W[j + 1] + N, ae[k + 5] = $[j + 1] + N, P.faceidx += 6; + } + if (M) { + var xe = a ? 0 : R / 2, Ie = t ? R + 1 : R / 2 + 1, oe, ve, re, Se, ze, Ge, $e, Re, Be, ke, We, Te, je, Fe, X, Z, q, fe, _e, Me, Ae, H, ce, ye, Pe, le, De, K, Oe, Ne, I, me; + for (ie = xe; ie < Ie; ie++) + if (ie !== R / 2) { + var ge = ie <= R / 2 ? b : n, Y = E.getVerticesForRadius(f, a, "to"), ne = E.getVerticesForRadius(f, t, "from"); + for (ge === b ? (B = Y.vertices, U = Y.normals, F = Y.verticesRows) : ge == n && (B = ne.vertices, U = ne.normals, F = ne.verticesRows), Q = 0; Q < T; Q++) + k = P.faceidx, oe = F[ie][Q + 1], Oe = (oe + N) * 3, ve = F[ie][Q], Ne = (ve + N) * 3, re = F[ie + 1][Q], I = (re + N) * 3, Se = F[ie + 1][Q + 1], me = (Se + N) * 3, ze = w[0] * B[oe].x + w[3] * B[oe].y + w[6] * B[oe].z, Ge = w[0] * B[ve].x + w[3] * B[ve].y + w[6] * B[ve].z, $e = w[0] * B[re].x + w[3] * B[re].y + w[6] * B[re].z, Re = w[0] * B[Se].x + w[3] * B[Se].y + w[6] * B[Se].z, Be = w[1] * B[oe].x + w[4] * B[oe].y + w[7] * B[oe].z, ke = w[1] * B[ve].x + w[4] * B[ve].y + w[7] * B[ve].z, We = w[1] * B[re].x + w[4] * B[re].y + w[7] * B[re].z, Te = w[1] * B[Se].x + w[4] * B[Se].y + w[7] * B[Se].z, je = w[5] * B[oe].y + w[8] * B[oe].z, Fe = w[5] * B[ve].y + w[8] * B[ve].z, X = w[5] * B[re].y + w[8] * B[re].z, Z = w[5] * B[Se].y + w[8] * B[Se].z, he[Oe] = ze + ge.x, he[Ne] = Ge + ge.x, he[I] = $e + ge.x, he[me] = Re + ge.x, he[Oe + 1] = Be + ge.y, he[Ne + 1] = ke + ge.y, he[I + 1] = We + ge.y, he[me + 1] = Te + ge.y, he[Oe + 2] = je + ge.z, he[Ne + 2] = Fe + ge.z, he[I + 2] = X + ge.z, he[me + 2] = Z + ge.z, se[Oe] = c.r, se[Ne] = c.r, se[I] = c.r, se[me] = c.r, se[Oe + 1] = c.g, se[Ne + 1] = c.g, se[I + 1] = c.g, se[me + 1] = c.g, se[Oe + 2] = c.b, se[Ne + 2] = c.b, se[I + 2] = c.b, se[me + 2] = c.b, q = w[0] * U[oe].x + w[3] * U[oe].y + w[6] * U[oe].z, fe = w[0] * U[ve].x + w[3] * U[ve].y + w[6] * U[ve].z, _e = w[0] * U[re].x + w[3] * U[re].y + w[6] * U[re].z, Me = w[0] * U[Se].x + w[3] * U[Se].y + w[6] * U[Se].z, Ae = w[1] * U[oe].x + w[4] * U[oe].y + w[7] * U[oe].z, H = w[1] * U[ve].x + w[4] * U[ve].y + w[7] * U[ve].z, ce = w[1] * U[re].x + w[4] * U[re].y + w[7] * U[re].z, ye = w[1] * U[Se].x + w[4] * U[Se].y + w[7] * U[Se].z, Pe = w[5] * U[oe].y + w[8] * U[oe].z, le = w[5] * U[ve].y + w[8] * U[ve].z, De = w[5] * U[re].y + w[8] * U[re].z, K = w[5] * U[Se].y + w[8] * U[Se].z, ie === 0 ? (ue[Oe] = q, ue[I] = _e, ue[me] = Me, ue[Oe + 1] = Ae, ue[I + 1] = ce, ue[me + 1] = ye, ue[Oe + 2] = Pe, ue[I + 2] = De, ue[me + 2] = K, ae[k] = oe + N, ae[k + 1] = re + N, ae[k + 2] = Se + N, P.faceidx += 3) : ie === Ie - 1 ? (ue[Oe] = q, ue[Ne] = fe, ue[I] = _e, ue[Oe + 1] = Ae, ue[Ne + 1] = H, ue[I + 1] = ce, ue[Oe + 2] = Pe, ue[Ne + 2] = le, ue[I + 2] = De, ae[k] = oe + N, ae[k + 1] = ve + N, ae[k + 2] = re + N, P.faceidx += 3) : (ue[Oe] = q, ue[Ne] = fe, ue[me] = Me, ue[Oe + 1] = Ae, ue[Ne + 1] = H, ue[me + 1] = ye, ue[Oe + 2] = Pe, ue[Ne + 2] = le, ue[me + 2] = K, ue[Ne] = fe, ue[I] = _e, ue[me] = Me, ue[Ne + 1] = H, ue[I + 1] = ce, ue[me + 1] = ye, ue[Ne + 2] = le, ue[I + 2] = De, ue[me + 2] = K, ae[k] = oe + N, ae[k + 1] = ve + N, ae[k + 2] = Se + N, ae[k + 3] = ve + N, ae[k + 4] = re + N, ae[k + 5] = Se + N, P.faceidx += 6); + } + } + P.vertices += z; + } + x.drawCylinder = u; + function A(r, n, b, f, c) { + if (!n || !b) + return; + c = c || { r: 0, g: 0, b: 0 }; + let t = new l.Vector3(b.x - n.x, b.y - n.y, b.z - n.z); + var a = o(t.x, t.y, t.z); + t = t.normalize(); + var h = E.basisVectors.length, M = E.basisVectors, w = h + 2, S = r.updateGeoGroup(w), T = S.vertices, R, z, P, B, U, F, $ = S.vertexArray, W = S.normalArray, N = S.colorArray, G = S.faceArray; + for (R = T * 3, $[R] = n.x, $[R + 1] = n.y, $[R + 2] = n.z, W[R] = -t.x, W[R + 1] = -t.y, W[R + 2] = -t.z, N[R] = c.r, N[R + 1] = c.g, N[R + 2] = c.b, $[R + 3] = b.x, $[R + 4] = b.y, $[R + 5] = b.z, W[R + 3] = t.x, W[R + 4] = t.y, W[R + 5] = t.z, N[R + 3] = c.r, N[R + 4] = c.g, N[R + 5] = c.b, R += 6, P = 0; P < h; ++P) { + var k = M[P].clone(); + k.multiplyScalar(f), B = a[0] * k.x + a[3] * k.y + a[6] * k.z, U = a[1] * k.x + a[4] * k.y + a[7] * k.z, F = a[5] * k.y + a[8] * k.z, $[R] = B + n.x, $[R + 1] = U + n.y, $[R + 2] = F + n.z, W[R] = B, W[R + 1] = U, W[R + 2] = F, N[R] = c.r, N[R + 1] = c.g, N[R + 2] = c.b, R += 3; + } + for (S.vertices += h + 2, z = S.faceidx, P = 0; P < h; P++) { + var j = T + 2 + P, Q = T + 2 + (P + 1) % h; + G[z] = j, G[z + 1] = Q, G[z + 2] = T, z += 3, G[z] = j, G[z + 1] = Q, G[z + 2] = T + 1, z += 3; + } + S.faceidx += 6 * h; + } + x.drawCone = A; + class C { + constructor() { + this.cache = /* @__PURE__ */ new Map(); + } + getVerticesForRadius(n, b) { + b = b || 2, this.cache.has(b) || this.cache.set(b, /* @__PURE__ */ new Map()); + let f = this.cache.get(b); + if (f.has(n)) + return f.get(n); + var c = { + vertices: [], + verticesRows: [], + normals: [] + }, t = 16 * b, a = 10 * b; + n < 1 && (t = 10 * b, a = 8 * b); + var h = 0, M = Math.PI * 2, w = 0, S = Math.PI, T, R; + for (R = 0; R <= a; R++) { + let P = []; + for (T = 0; T <= t; T++) { + let B = T / t, U = R / a, F = -n * Math.cos(h + B * M) * Math.sin(w + U * S), $ = n * Math.cos(w + U * S), W = n * Math.sin(h + B * M) * Math.sin(w + U * S); + var z = new l.Vector3(F, $, W); + z.normalize(), c.vertices.push({ x: F, y: $, z: W }), c.normals.push(z), P.push(c.vertices.length - 1); + } + c.verticesRows.push(P); + } + return f.set(n, c), c; + } + } + var L = new C(); + function D(r, n, b, f, c) { + var t = L.getVerticesForRadius(b, c), a = t.vertices, h = t.normals, M = r.updateGeoGroup(a.length), w = M.vertices, S = M.vertexArray, T = M.colorArray, R = M.faceArray, z = M.lineArray, P = M.normalArray; + for (let F = 0, $ = a.length; F < $; ++F) { + let W = 3 * (w + F), N = a[F]; + S[W] = N.x + n.x, S[W + 1] = N.y + n.y, S[W + 2] = N.z + n.z, T[W] = f.r, T[W + 1] = f.g, T[W + 2] = f.b; + } + M.vertices += a.length; + let B = t.verticesRows, U = B.length - 1; + for (let F = 0; F < U; F++) { + let $ = B[F].length - 1; + for (let W = 0; W < $; W++) { + let N = M.faceidx, G = M.lineidx, k = B[F][W + 1] + w, j = k * 3, Q = B[F][W] + w, ie = Q * 3, pe = B[F + 1][W] + w, he = pe * 3, ue = B[F + 1][W + 1] + w, se = ue * 3, ae = h[k - w], we = h[Q - w], xe = h[pe - w], Ie = h[ue - w]; + Math.abs(a[k - w].y) === b ? (P[j] = ae.x, P[he] = xe.x, P[se] = Ie.x, P[j + 1] = ae.y, P[he + 1] = xe.y, P[se + 1] = Ie.y, P[j + 2] = ae.z, P[he + 2] = xe.z, P[se + 2] = Ie.z, R[N] = k, R[N + 1] = pe, R[N + 2] = ue, z[G] = k, z[G + 1] = pe, z[G + 2] = k, z[G + 3] = ue, z[G + 4] = pe, z[G + 5] = ue, M.faceidx += 3, M.lineidx += 6) : Math.abs(a[pe - w].y) === b ? (P[j] = ae.x, P[ie] = we.x, P[he] = xe.x, P[j + 1] = ae.y, P[ie + 1] = we.y, P[he + 1] = xe.y, P[j + 2] = ae.z, P[ie + 2] = we.z, P[he + 2] = xe.z, R[N] = k, R[N + 1] = Q, R[N + 2] = pe, z[G] = k, z[G + 1] = Q, z[G + 2] = k, z[G + 3] = pe, z[G + 4] = Q, z[G + 5] = pe, M.faceidx += 3, M.lineidx += 6) : (P[j] = ae.x, P[ie] = we.x, P[se] = Ie.x, P[j + 1] = ae.y, P[ie + 1] = we.y, P[se + 1] = Ie.y, P[j + 2] = ae.z, P[ie + 2] = we.z, P[se + 2] = Ie.z, P[ie] = we.x, P[he] = xe.x, P[se] = Ie.x, P[ie + 1] = we.y, P[he + 1] = xe.y, P[se + 1] = Ie.y, P[ie + 2] = we.z, P[he + 2] = xe.z, P[se + 2] = Ie.z, R[N] = k, R[N + 1] = Q, R[N + 2] = ue, R[N + 3] = Q, R[N + 4] = pe, R[N + 5] = ue, z[G] = k, z[G + 1] = Q, z[G + 2] = k, z[G + 3] = ue, z[G + 4] = Q, z[G + 5] = pe, z[G + 6] = pe, z[G + 7] = ue, M.faceidx += 6, M.lineidx += 8); + } + } + } + x.drawSphere = D; + })(_ || (_ = {})); + } + ), + /***/ + "./src/GLModel.ts": ( + /*!************************!*\ + !*** ./src/GLModel.ts ***! + \************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + GLModel: () => ( + /* binding */ + n + ) + /* harmony export */ + }); + var l = e( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), g = e( + /*! ./WebGL/shapes */ + "./src/WebGL/shapes/index.ts" + ), _ = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), x = e( + /*! ./colors */ + "./src/colors.ts" + ), o = e( + /*! ./GLDraw */ + "./src/GLDraw.ts" + ), p = e( + /*! ./glcartoon */ + "./src/glcartoon.ts" + ), E = e( + /*! ./utilities */ + "./src/utilities.ts" + ), u = e( + /*! ./Gradient */ + "./src/Gradient.ts" + ), A = e( + /*! ./parsers */ + "./src/parsers/index.ts" + ), C = e( + /*! netcdfjs */ + "./node_modules/netcdfjs/lib-esm/index.js" + ), L = e( + /*! pako */ + "./node_modules/pako/dist/pako.esm.mjs" + ), D = e( + /*! ./parsers/utils/assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ); + function r(b) { + let f; + return typeof b == "string" ? f = new TextEncoder().encode(b) : f = new Uint8Array(b), (0, L.inflate)(f, { + to: "string" + }); + } + class n { + // class functions + // return true if a and b represent the same style + static sameObj(f, c) { + return f && c ? JSON.stringify(f) == JSON.stringify(c) : f == c; + } + constructor(f, c) { + 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 = c || {}, 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 = f; + } + // return proper radius for atom given style + /** + * + * @param {AtomSpec} atom + * @param {atomstyle} style + * @return {number} + * + */ + getRadiusFromStyle(f, c) { + var t = this.defaultSphereRadius; + if (typeof c.radius < "u") + t = c.radius; + else if (n.vdwRadii[f.elem]) + t = n.vdwRadii[f.elem]; + else if (f.elem.length > 1) { + let a = f.elem; + a = a[0].toUpperCase() + a[1].toLowerCase(), n.vdwRadii[a] && (t = n.vdwRadii[a]); + } + return typeof c.scale < "u" && (t *= c.scale), t; + } + // cross drawing + /** + * + * @param {AtomSpec} atom + * @param {Record} geos + */ + drawAtomCross(f, c) { + if (f.style.cross) { + var t = f.style.cross; + if (!t.hidden) { + var a = t.linewidth || n.defaultlineWidth; + c[a] || (c[a] = new l.Geometry()); + var h = c[a].updateGeoGroup(6), M = this.getRadiusFromStyle(f, t), w = [ + [M, 0, 0], + [-M, 0, 0], + [0, M, 0], + [0, -M, 0], + [0, 0, M], + [0, 0, -M] + ], S = f.clickable || f.hoverable; + S && f.intersectionShape === void 0 && (f.intersectionShape = { sphere: [], cylinder: [], line: [] }); + for (var T = (0, E.getColorFromStyle)(f, t), R = h.vertexArray, z = h.colorArray, P = 0; P < 6; P++) { + var B = h.vertices * 3; + if (h.vertices++, R[B] = f.x + w[P][0], R[B + 1] = f.y + w[P][1], R[B + 2] = f.z + w[P][2], z[B] = T.r, z[B + 1] = T.g, z[B + 2] = T.b, S) { + var U = new _.Vector3(w[P][0], w[P][1], w[P][2]); + U.multiplyScalar(0.1), U.set(U.x + f.x, U.y + f.y, U.z + f.z), f.intersectionShape.line.push(U); + } + } + } + } + } + getGoodCross(f, c, t, a) { + for (var h = null, M = -1, w = 0, S = f.bonds.length; w < S; w++) + if (f.bonds[w] != c.index) { + let R = f.bonds[w], z = this.atoms[R], B = new _.Vector3(z.x, z.y, z.z).clone(); + B.sub(t); + let U = B.clone(); + U.cross(a); + var T = U.lengthSq(); + if (T > M && (M = T, h = U, M > 0.1)) + return h; + } + return h; + } + //from atom, return a normalized vector v that is orthogonal and along which + //it is appropraite to draw multiple bonds + getSideBondV(f, c, t) { + var a, h, M, w, S, T = new _.Vector3(f.x, f.y, f.z), R = new _.Vector3(c.x, c.y, c.z), z = R.clone(), P = null; + if (z.sub(T), f.bonds.length === 1) + c.bonds.length === 1 ? (P = z.clone(), Math.abs(P.x) > 1e-4 ? P.y += 1 : P.x += 1) : (a = (t + 1) % c.bonds.length, h = c.bonds[a], M = this.atoms[h], M.index == f.index && (a = (a + 1) % c.bonds.length, h = c.bonds[a], M = this.atoms[h]), w = new _.Vector3(M.x, M.y, M.z), S = w.clone(), S.sub(T), P = S.clone(), P.cross(z)); + else if (P = this.getGoodCross(f, c, T, z), P.lengthSq() < 0.01) { + var B = this.getGoodCross(c, f, T, z); + B != null && (P = B); + } + return P.lengthSq() < 0.01 && (P = z.clone(), Math.abs(P.x) > 1e-4 ? P.y += 1 : P.x += 1), P.cross(z), P.normalize(), P; + } + addLine(f, c, t, a, h, M) { + f[t] = a.x, f[t + 1] = a.y, f[t + 2] = a.z, c[t] = M.r, c[t + 1] = M.g, c[t + 2] = M.b, f[t + 3] = h.x, f[t + 4] = h.y, f[t + 5] = h.z, c[t + 3] = M.r, c[t + 4] = M.g, c[t + 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(f, c, t) { + if (f.style.line) { + var a = f.style.line; + if (!a.hidden) { + var h, M, w, S, T = a.linewidth || n.defaultlineWidth; + t[T] || (t[T] = new l.Geometry()); + for (var R = t[T].updateGeoGroup(6 * f.bonds.length), z = R.vertexArray, P = R.colorArray, B = 0; B < f.bonds.length; B++) { + var U = f.bonds[B], F = c[U]; + if (F.style.line && !(f.index >= F.index)) { + var $ = new _.Vector3(f.x, f.y, f.z), W = new _.Vector3(F.x, F.y, F.z), N = $.clone().add(W).multiplyScalar(0.5), G = !1, k = f.clickable || f.hoverable, j = F.clickable || F.hoverable; + (k || j) && (k && (f.intersectionShape === void 0 && (f.intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }), f.intersectionShape.line.push($), f.intersectionShape.line.push(N)), j && (F.intersectionShape === void 0 && (F.intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }), F.intersectionShape.line.push(N), F.intersectionShape.line.push(W))); + var Q = (0, E.getColorFromStyle)(f, f.style.line), ie = (0, E.getColorFromStyle)(F, F.style.line); + if (f.bondStyles && f.bondStyles[B]) { + var pe = f.bondStyles[B]; + if (!pe.iswire) + continue; + pe.singleBond && (G = !0), typeof pe.color1 < "u" && (Q = x.CC.color(pe.color1)), typeof pe.color2 < "u" && (ie = x.CC.color(pe.color2)); + } + var he = R.vertices * 3, ue, se; + if (f.bondOrder[B] > 1 && f.bondOrder[B] < 4 && !G) { + var ae = this.getSideBondV(f, F, B), we = W.clone(); + we.sub($), f.bondOrder[B] == 2 ? (ae.multiplyScalar(0.1), h = $.clone(), h.add(ae), M = $.clone(), M.sub(ae), w = h.clone(), w.add(we), S = M.clone(), S.add(we), Q == ie ? (R.vertices += 4, this.addLine(z, P, he, h, w, Q), this.addLine(z, P, he + 6, M, S, Q)) : (R.vertices += 8, we.multiplyScalar(0.5), ue = h.clone(), ue.add(we), se = M.clone(), se.add(we), this.addLine(z, P, he, h, ue, Q), this.addLine(z, P, he + 6, ue, w, ie), this.addLine(z, P, he + 12, M, se, Q), this.addLine(z, P, he + 18, se, S, ie))) : f.bondOrder[B] == 3 && (ae.multiplyScalar(0.1), h = $.clone(), h.add(ae), M = $.clone(), M.sub(ae), w = h.clone(), w.add(we), S = M.clone(), S.add(we), Q == ie ? (R.vertices += 6, this.addLine(z, P, he, $, W, Q), this.addLine(z, P, he + 6, h, w, Q), this.addLine(z, P, he + 12, M, S, Q)) : (R.vertices += 12, we.multiplyScalar(0.5), ue = h.clone(), ue.add(we), se = M.clone(), se.add(we), this.addLine(z, P, he, $, N, Q), this.addLine(z, P, he + 6, N, W, ie), this.addLine(z, P, he + 12, h, ue, Q), this.addLine(z, P, he + 18, ue, w, ie), this.addLine(z, P, he + 24, M, se, Q), this.addLine(z, P, he + 30, se, S, ie))); + } else + Q == ie ? (R.vertices += 2, this.addLine(z, P, he, $, W, Q)) : (R.vertices += 4, this.addLine(z, P, he, $, N, Q), this.addLine(z, P, he + 6, N, W, ie)); + } + } + } + } + } + //sphere drawing + //See also: drawCylinder + /** + * + * @param {AtomSpec} atom + * @param {Geometry} geo + */ + drawAtomSphere(f, c) { + if (f.style.sphere) { + var t = f.style.sphere; + if (!t.hidden) { + var a = (0, E.getColorFromStyle)(f, t), h = this.getRadiusFromStyle(f, t); + if ((f.clickable === !0 || f.hoverable) && f.intersectionShape !== void 0) { + var M = new _.Vector3(f.x, f.y, f.z); + f.intersectionShape.sphere.push(new g.Sphere(M, h)); + } + o.GLDraw.drawSphere(c, f, h, a); + } + } + } + /** Register atom shaped click handlers */ + drawAtomClickSphere(f) { + if (f.style.clicksphere) { + var c = f.style.clicksphere; + if (!c.hidden) { + var t = this.getRadiusFromStyle(f, c); + if ((f.clickable === !0 || f.hoverable) && f.intersectionShape !== void 0) { + var a = new _.Vector3(f.x, f.y, f.z); + f.intersectionShape.sphere.push(new g.Sphere(a, t)); + } + } + } + } + drawAtomInstanced(f, c) { + if (f.style.sphere) { + var t = f.style.sphere; + if (!t.hidden) { + var a = this.getRadiusFromStyle(f, t), h = (0, E.getColorFromStyle)(f, t), M = c.updateGeoGroup(1), w = M.vertices, S = w * 3, T = M.vertexArray, R = M.colorArray, z = M.radiusArray; + if (T[S] = f.x, T[S + 1] = f.y, T[S + 2] = f.z, R[S] = h.r, R[S + 1] = h.g, R[S + 2] = h.b, z[w] = a, (f.clickable === !0 || f.hoverable) && f.intersectionShape !== void 0) { + var P = new _.Vector3(f.x, f.y, f.z); + f.intersectionShape.sphere.push(new g.Sphere(P, a)); + } + M.vertices += 1; + } + } + } + drawSphereImposter(f, c, t, a) { + var h = f.updateGeoGroup(4), M, w = h.vertices, S = w * 3, T = h.vertexArray, R = h.colorArray; + for (M = 0; M < 4; M++) + T[S + 3 * M] = c.x, T[S + 3 * M + 1] = c.y, T[S + 3 * M + 2] = c.z; + var z = h.normalArray; + for (M = 0; M < 4; M++) + R[S + 3 * M] = a.r, R[S + 3 * M + 1] = a.g, R[S + 3 * M + 2] = a.b; + z[S + 0] = -t, z[S + 1] = t, z[S + 2] = 0, z[S + 3] = -t, z[S + 4] = -t, z[S + 5] = 0, z[S + 6] = t, z[S + 7] = -t, z[S + 8] = 0, z[S + 9] = t, z[S + 10] = t, z[S + 11] = 0, h.vertices += 4; + var P = h.faceArray, B = h.faceidx; + P[B + 0] = w, P[B + 1] = w + 1, P[B + 2] = w + 2, P[B + 3] = w + 2, P[B + 4] = w + 3, P[B + 5] = w, h.faceidx += 6; + } + //dkoes - code for sphere imposters + drawAtomImposter(f, c) { + if (f.style.sphere) { + var t = f.style.sphere; + if (!t.hidden) { + var a = this.getRadiusFromStyle(f, t), h = (0, E.getColorFromStyle)(f, t); + if ((f.clickable === !0 || f.hoverable) && f.intersectionShape !== void 0) { + var M = new _.Vector3(f.x, f.y, f.z); + f.intersectionShape.sphere.push(new g.Sphere(M, a)); + } + this.drawSphereImposter(c, f, a, h); + } + } + } + calculateDashes(f, c, t, a, h) { + var M = Math.sqrt(Math.pow(f.x - c.x, 2) + Math.pow(f.y - c.y, 2) + Math.pow(f.z - c.z, 2)); + t = Math.max(t, 0), h = Math.max(h, 0) + 2 * t, a = Math.max(a, 1e-3), a + h > M && (a = M, h = 0); + var w = Math.floor((M - a) / (a + h)) + 1, S = w * a; + h = (M - S) / w; + for (var T, R = new _.Vector3(f.x, f.y, f.z), z = new _.Vector3((c.x - f.x) / (M / h), (c.y - f.y) / (M / h), (c.z - f.z) / (M / h)), P = new _.Vector3((c.x - f.x) / (M / a), (c.y - f.y) / (M / a), (c.z - f.z) / (M / a)), B = [], U = 0; U < w; U++) + T = new _.Vector3(R.x + P.x, R.y + P.y, R.z + P.z), B.push({ from: R, to: T }), R = new _.Vector3(T.x + z.x, T.y + z.y, T.z + z.z); + return B; + } + static drawStickImposter(f, c, t, a, h, M = 0, w = 0) { + for (var S = f.updateGeoGroup(4), T = S.vertices, R = T * 3, z = S.vertexArray, P = S.colorArray, B = S.radiusArray, U = S.normalArray, F = h.r, $ = h.g, W = h.b, N = function(ie) { + var pe = -ie; + return pe == 0 && (pe = -1e-4), pe; + }, G = R, k = 0; k < 4; k++) + z[G] = c.x, U[G] = t.x, P[G] = F, G++, z[G] = c.y, U[G] = t.y, P[G] = $, G++, z[G] = c.z, U[G] = t.z, k < 2 ? P[G] = W : P[G] = N(W), G++; + S.vertices += 4, B[T] = -a, B[T + 1] = a, B[T + 2] = -a, B[T + 3] = a; + var j = S.faceArray, Q = S.faceidx; + j[Q + 0] = T, j[Q + 1] = T + 1, j[Q + 2] = T + 2, j[Q + 3] = T + 2, j[Q + 4] = T + 3, j[Q + 5] = T, S.faceidx += 6; + } + // draws cylinders and small spheres (at bond radius) + drawBondSticks(f, c, t) { + var a, h; + if (f.style.stick) { + var M = f.style.stick; + if (!M.hidden) { + var w = M.radius || this.defaultStickRadius, S = M.doubleBondScaling || 0.4, T = M.tripleBondScaling || 0.25, R = ((a = M.dashedBondConfig) === null || a === void 0 ? void 0 : a.dashLength) || 0.1, z = ((h = M.dashedBondConfig) === null || h === void 0 ? void 0 : h.gapLength) || 0.25, P = w, B = M.singleBonds || !1, U = M.dashedBonds || !1, F = 0, $ = 0, W, N, G, k, j, Q, ie, pe, he, ue, se, ae = (0, E.getColorFromStyle)(f, M), we, xe, Ie; + !f.capDrawn && f.bonds.length < 4 && (F = 2); + var oe = (Pe) => { + var le = t.imposter ? n.drawStickImposter : o.GLDraw.drawCylinder; + return !U && Pe >= 1 ? le : (De, K, Oe, Ne, I, me = 0, ge = 0, Y = 0.1, ne = 0.25) => { + var Ee = this.calculateDashes(K, Oe, Ne, Y, ne); + Ee.forEach((He) => { + le(De, He.from, He.to, Ne, I, me, ge); + }); + }; + }; + for (G = 0; G < f.bonds.length; G++) { + var ve = oe(f.bondOrder[G]), re = f.bonds[G], Se = c[re]; + if (we = xe = Ie = null, f.index < Se.index) { + var ze = Se.style; + if (!ze.stick || ze.stick.hidden) + continue; + var Ge = (0, E.getColorFromStyle)(Se, ze.stick); + if (P = w, k = B, f.bondStyles && f.bondStyles[G]) { + if (j = f.bondStyles[G], j.iswire) + continue; + j.radius && (P = j.radius), j.singleBond && (k = !0), typeof j.color1 < "u" && (ae = x.CC.color(j.color1)), typeof j.color2 < "u" && (Ge = x.CC.color(j.color2)); + } + var $e = new _.Vector3(f.x, f.y, f.z), Re = new _.Vector3(Se.x, Se.y, Se.z); + if (f.bondOrder[G] <= 1 || k || f.bondOrder[G] > 3) { + if (f.bondOrder[G] < 1 && (P *= f.bondOrder[G]), !Se.capDrawn && Se.bonds.length < 4 && ($ = 2), ae != Ge ? (we = new _.Vector3().addVectors($e, Re).multiplyScalar(0.5), ve(t, $e, we, P, ae, F, 0, R, z), ve(t, we, Re, P, Ge, 0, $, R, z)) : ve(t, $e, Re, P, ae, F, $, R, z), W = f.clickable || f.hoverable, N = Se.clickable || Se.hoverable, W || N) { + if (we || (we = new _.Vector3().addVectors($e, Re).multiplyScalar(0.5)), W) { + var Be = new g.Cylinder($e, we, P), ke = new g.Sphere($e, P); + f.intersectionShape.cylinder.push(Be), f.intersectionShape.sphere.push(ke); + } + if (N) { + var We = new g.Cylinder(Re, we, P), Te = new g.Sphere(Re, P); + Se.intersectionShape.cylinder.push(We), Se.intersectionShape.sphere.push(Te); + } + } + } else if (f.bondOrder[G] > 1) { + var je = 0, Fe = 0; + P != w && (je = 2, Fe = 2); + var X = Re.clone(), Z = null; + X.sub($e); + var q, fe, _e, Me, Ae; + Z = this.getSideBondV(f, Se, G), f.bondOrder[G] == 2 ? (q = P * S, Z.multiplyScalar(q * 1.5), fe = $e.clone(), fe.add(Z), _e = $e.clone(), _e.sub(Z), Me = fe.clone(), Me.add(X), Ae = _e.clone(), Ae.add(X), ae != Ge ? (we = new _.Vector3().addVectors(fe, Me).multiplyScalar(0.5), xe = new _.Vector3().addVectors(_e, Ae).multiplyScalar(0.5), ve(t, fe, we, q, ae, je, 0), ve(t, we, Me, q, Ge, 0, Fe), ve(t, _e, xe, q, ae, je, 0), ve(t, xe, Ae, q, Ge, 0, Fe)) : (ve(t, fe, Me, q, ae, je, Fe), ve(t, _e, Ae, q, ae, je, Fe)), W = f.clickable || f.hoverable, N = Se.clickable || Se.hoverable, (W || N) && (we || (we = new _.Vector3().addVectors(fe, Me).multiplyScalar(0.5)), xe || (xe = new _.Vector3().addVectors(_e, Ae).multiplyScalar(0.5)), W && (Q = new g.Cylinder(fe, we, q), ie = new g.Cylinder(_e, xe, q), f.intersectionShape.cylinder.push(Q), f.intersectionShape.cylinder.push(ie)), N && (he = new g.Cylinder(Me, we, q), ue = new g.Cylinder(Ae, xe, q), Se.intersectionShape.cylinder.push(he), Se.intersectionShape.cylinder.push(ue)))) : f.bondOrder[G] == 3 && (q = P * T, Z.cross(X), Z.normalize(), Z.multiplyScalar(q * 3), fe = $e.clone(), fe.add(Z), _e = $e.clone(), _e.sub(Z), Me = fe.clone(), Me.add(X), Ae = _e.clone(), Ae.add(X), ae != Ge ? (we = new _.Vector3().addVectors(fe, Me).multiplyScalar(0.5), xe = new _.Vector3().addVectors(_e, Ae).multiplyScalar(0.5), Ie = new _.Vector3().addVectors($e, Re).multiplyScalar(0.5), ve(t, fe, we, q, ae, je, 0), ve(t, we, Me, q, Ge, 0, Fe), ve(t, $e, Ie, q, ae, F, 0), ve(t, Ie, Re, q, Ge, 0, $), ve(t, _e, xe, q, ae, je, 0), ve(t, xe, Ae, q, Ge, 0, Fe)) : (ve(t, fe, Me, q, ae, je, Fe), ve(t, $e, Re, q, ae, F, $), ve(t, _e, Ae, q, ae, je, Fe)), W = f.clickable || f.hoverable, N = Se.clickable || Se.hoverable, (W || N) && (we || (we = new _.Vector3().addVectors(fe, Me).multiplyScalar(0.5)), xe || (xe = new _.Vector3().addVectors(_e, Ae).multiplyScalar(0.5)), Ie || (Ie = new _.Vector3().addVectors($e, Re).multiplyScalar(0.5)), W && (Q = new g.Cylinder(fe.clone(), we.clone(), q), ie = new g.Cylinder(_e.clone(), xe.clone(), q), pe = new g.Cylinder($e.clone(), Ie.clone(), q), f.intersectionShape.cylinder.push(Q), f.intersectionShape.cylinder.push(ie), f.intersectionShape.cylinder.push(pe)), N && (he = new g.Cylinder(Me.clone(), we.clone(), q), ue = new g.Cylinder(Ae.clone(), xe.clone(), q), se = new g.Cylinder(Re.clone(), Ie.clone(), q), Se.intersectionShape.cylinder.push(he), Se.intersectionShape.cylinder.push(ue), Se.intersectionShape.cylinder.push(se)))); + } + } + } + var H = !1, ce = 0, ye = !1; + for (G = 0; G < f.bonds.length; G++) + k = B, f.bondStyles && f.bondStyles[G] && (j = f.bondStyles[G], j.singleBond && (k = !0), j.radius && j.radius != w && (ye = !0)), (k || f.bondOrder[G] == 1) && ce++; + ye ? ce > 0 && (H = !0) : ce == 0 && (f.bonds.length > 0 || M.showNonBonded) && (H = !0), H && (P = w, t.imposter ? this.drawSphereImposter(t.sphereGeometry, f, P, ae) : o.GLDraw.drawSphere(t, f, P, ae)); + } + } + } + // 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(f, c) { + c = c || {}; + var t = new l.Object3D(), a = [], h = {}, M = {}, w = this.drawAtomSphere, S = null, T = null; + c.supportsImposters ? (w = this.drawAtomImposter, S = new l.Geometry(!0), S.imposter = !0, T = new l.Geometry(!0, !0), T.imposter = !0, T.sphereGeometry = new l.Geometry(!0), T.sphereGeometry.imposter = !0, T.drawnCaps = {}) : c.supportsAIA ? (w = this.drawAtomInstanced, S = new l.Geometry(!1, !0, !0), S.instanced = !0, T = new l.Geometry(!0)) : (S = new l.Geometry(!0), T = new l.Geometry(!0)); + var R, z, P, B, U = {}, F = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]; + for (R = 0, P = f.length; R < P; R++) { + var $ = f[R]; + if ($ && $.style) { + ($.clickable || $.hoverable) && $.intersectionShape === void 0 && ($.intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }), B = { line: void 0, cross: void 0, stick: void 0, sphere: void 0 }; + for (z in B) + $.style[z] ? $.style[z].opacity ? B[z] = parseFloat($.style[z].opacity) : B[z] = 1 : B[z] = void 0, U[z] ? B[z] != null && U[z] != B[z] && (console.log("Warning: " + z + " opacity is ambiguous"), U[z] = 1) : U[z] = B[z]; + w.call(this, $, S), this.drawAtomClickSphere($), this.drawAtomCross($, M), this.drawBondLines($, f, h), this.drawBondSticks($, f, T), typeof $.style.cartoon < "u" && !$.style.cartoon.hidden && ($.style.cartoon.color === "spectrum" && typeof $.resi == "number" && !$.hetflag && ($.resi < F[0] && (F[0] = $.resi), $.resi > F[1] && (F[1] = $.resi)), a.push($)); + } + } + if (a.length > 0 && (0, p.drawCartoon)(t, a, F, this.defaultCartoonQuality), S && S.vertices > 0) { + S.initTypedArrays(); + var W = null, N = null; + S.imposter ? W = new l.SphereImposterMaterial({ + ambient: 0, + vertexColors: !0, + reflectivity: 0 + }) : S.instanced ? (N = new l.Geometry(!0), o.GLDraw.drawSphere(N, { x: 0, y: 0, z: 0 }, 1, new x.Color(0.5, 0.5, 0.5)), N.initTypedArrays(), W = new l.InstancedMaterial({ + sphereMaterial: new l.MeshLambertMaterial({ + ambient: 0, + vertexColors: !0, + reflectivity: 0 + }), + sphere: N + })) : W = new l.MeshLambertMaterial({ + ambient: 0, + vertexColors: !0, + reflectivity: 0 + }), U.sphere < 1 && U.sphere >= 0 && (W.transparent = !0, W.opacity = U.sphere), N = new l.Mesh(S, W), t.add(N); + } + if (T.vertices > 0) { + var G = null, k = null, j = T.sphereGeometry; + (!j || typeof j.vertices > "u" || j.vertices == 0) && (j = null), T.initTypedArrays(), j && j.initTypedArrays(); + var Q = { ambient: 0, vertexColors: !0, reflectivity: 0 }; + T.imposter ? (G = new l.StickImposterMaterial(Q), k = new l.SphereImposterMaterial(Q)) : (G = new l.MeshLambertMaterial(Q), k = new l.MeshLambertMaterial(Q), G.wireframe && (T.setUpWireframe(), j && j.setUpWireframe())), U.stick < 1 && U.stick >= 0 && (G.transparent = !0, G.opacity = U.stick, k.transparent = !0, k.opacity = U.stick); + var ie = new l.Mesh(T, G); + if (t.add(ie), j) { + var pe = new l.Mesh(j, k); + t.add(pe); + } + } + var he; + for (R in h) + if (h.hasOwnProperty(R)) { + he = R; + var ue = new l.LineBasicMaterial({ + linewidth: he, + vertexColors: !0 + }); + U.line < 1 && U.line >= 0 && (ue.transparent = !0, ue.opacity = U.line), h[R].initTypedArrays(); + var se = new l.Line(h[R], ue, l.LineStyle.LinePieces); + t.add(se); + } + for (R in M) + if (M.hasOwnProperty(R)) { + he = R; + var ae = new l.LineBasicMaterial({ + linewidth: he, + vertexColors: !0 + }); + U.cross < 1 && U.cross >= 0 && (ae.transparent = !0, ae.opacity = U.cross), M[R].initTypedArrays(); + var we = new l.Line(M[R], ae, l.LineStyle.LinePieces); + t.add(we); + } + if (this.dontDuplicateAtoms && this.modelData.symmetries && this.modelData.symmetries.length > 0) { + var xe = new l.Object3D(), Ie; + for (Ie = 0; Ie < this.modelData.symmetries.length; Ie++) { + var oe = new l.Object3D(); + oe = t.clone(), oe.matrix.copy(this.modelData.symmetries[Ie]), oe.matrixAutoUpdate = !1, xe.add(oe); + } + return xe; + } + return t; + } + /** + * 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(f) { + this.atoms = f.atoms, this.frames = f.frames, this.molObj = null; + } + /** + * Returns crystallographic information if present. + * + * + */ + getCrystData() { + if (this.modelData.cryst) { + if (!this.modelData.cryst.matrix) { + const f = this.modelData.cryst; + this.modelData.cryst.matrix = (0, _.conversionMatrix3)(f.a, f.b, f.c, f.alpha, f.beta, f.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(f, c, t, a, h, M) { + f = f || 1, c = c || 1, t = t || 1, a = a || 90, h = h || 90, M = M || 90; + const w = (0, _.conversionMatrix3)(f, c, t, a, h, M); + this.modelData.cryst = { + a: f, + b: c, + c: t, + alpha: a, + beta: h, + gamma: M, + matrix: w + }; + } + /** + * 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(f) { + f = f || new _.Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), this.modelData.cryst = { + matrix: f + }; + } + /** + * 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(f) { + typeof f > "u" ? this.modelData.symmetries = [this.idMatrix] : this.modelData.symmetries = f; + } + /** + * 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(f, c, t, a) { + var h = c - f; + return h < -t ? c + a : h > t ? c - a : c; + } + //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 f = this.box[0], c = this.box[1], t = this.box[2], a = f * 0.9, h = c * 0.9, M = t * 0.9, w = 0; w < this.atomdfs.length; w++) + for (var S = this.atomdfs[w], T = 1; T < S.length; T++) { + var R = this.atoms[S[T][0]], z = this.atoms[S[T][1]]; + R.x = this.adjustCoord(z.x, R.x, a, f), R.y = this.adjustCoord(z.y, R.y, h, c), R.z = this.adjustCoord(z.z, R.z, M, t); + } + } + /** + * 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(f, c) { + var t = this.getNumFrames(); + let a = this; + return new Promise(function(h, M) { + if (t == 0 && h(), (f < 0 || f >= t) && (f = t - 1), a.frames.url != null) { + var w = a.frames.url; + (0, E.getbin)(w + "/traj/frame/" + f + "/" + a.frames.path, void 0, "POST", void 0).then(function(S) { + for (var T = new Float32Array(S, 44), R = 0, z = 0; z < a.atoms.length; z++) + a.atoms[z].x = T[R++], a.atoms[z].y = T[R++], a.atoms[z].z = T[R++]; + a.box && a.atomdfs && a.adjustCoordinatesToBox(), h(); + }).catch(M); + } else + a.atoms = a.frames[f], h(); + a.molObj = null, a.modelDatas && f < a.modelDatas.length && (a.modelData = a.modelDatas[f], a.unitCellObjects && c && (c.removeUnitCell(a), c.addUnitCell(a))); + }); + } + /** + * Add atoms as frames of model + * + * @param {AtomSpec[]} atoms - atoms to be added + */ + addFrame(f) { + this.frames.push(f); + } + /** + * 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(f = 10, c = 1, t = !1, a, h) { + var M = 0, w = f; + t && (M = -f, w = f), this.frames !== void 0 && this.frames.origIndex !== void 0 ? this.setFrame(this.frames.origIndex) : this.setFrame(0), M < w && (this.frames = []), t && (this.frames.origIndex = f); + for (var S = M; S < w; S++) { + var T = [], R = this.frames.length; + if (S == 0 && !h) { + this.frames.push(this.atoms); + continue; + } + for (var z = 0; z < this.atoms.length; z++) { + var P = (0, E.getAtomProperty)(this.atoms[z], "dx"), B = (0, E.getAtomProperty)(this.atoms[z], "dy"), U = (0, E.getAtomProperty)(this.atoms[z], "dz"), F = new _.Vector3(P, B, U), $ = new _.Vector3(this.atoms[z].x, this.atoms[z].y, this.atoms[z].z), W = S * c / f; + F.multiplyScalar(W), $.add(F); + var N = {}; + for (var G in this.atoms[z]) + N[G] = this.atoms[z][G]; + if (N.x = $.x, N.y = $.y, N.z = $.z, T.push(N), a && h) { + var k = (0, E.extend)({}, h), j = new _.Vector3(P, B, U); + if (j.multiplyScalar(c), j.add($), k.start = $, k.end = j, k.frame = R, !k.color) { + var Q = N.style.sphere; + Q || (Q = N.style.stick), Q || (Q = N.style.line), k.color = (0, E.getColorFromStyle)(N, Q); + } + a.addArrow(k); + } + } + this.frames.push(T); + } + } + // set default style and colors for atoms + setAtomDefaults(f) { + for (let c = 0; c < f.length; c++) { + let t = f[c]; + t && (t.style = t.style || (0, E.deepCopy)(n.defaultAtomStyle), t.color = t.color || this.ElementColors[t.elem] || this.defaultColor, t.model = this.id, (t.clickable || t.hoverable) && (t.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(f, c, t = {}) { + var a = n.parseMolData(f, c, t); + this.dontDuplicateAtoms = !t.duplicateAssemblyAtoms; + var h = a.modelData; + if (h && (Array.isArray(h) ? (this.modelData = h[0], t.frames && (this.modelDatas = h)) : this.modelData = h), a.box ? this.box = a.box : this.box = null, this.frames.length == 0) { + for (let w = 0; w < a.length; w++) + a[w].length != 0 && this.frames.push(a[w]); + this.frames[0] && (this.atoms = this.frames[0]); + } else if (t.frames) + for (let w = 0; w < a.length; w++) + this.frames.push(a[w]); + else + for (var M = 0; M < a.length; M++) + this.addAtoms(a[M]); + for (let w = 0; w < this.frames.length; w++) + this.setAtomDefaults(this.frames[w]); + t.vibrate && t.vibrate.frames && t.vibrate.amplitude && this.vibrate(t.vibrate.frames, t.vibrate.amplitude), t.style && this.setStyle({}, t.style); + } + setDontDuplicateAtoms(f) { + this.dontDuplicateAtoms = f; + } + setModelData(f) { + this.modelData = f; + } + //return true if atom value matches property val + propertyMatches(f, c) { + if (f == c) + return !0; + if (typeof c == "string" && typeof f == "number") { + var t = c.match(/(-?\d+)\s*-\s*(-?\d+)/); + if (t) { + var a = parseInt(t[1]), h = parseInt(t[2]); + if (t && f >= a && f <= h) + 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(f, c) { + if (typeof f != "object" || f == null || f.__cache_created) + return f; + const t = {}; + for (const a in f) { + const h = f[a]; + if (Array.isArray(h)) { + t[a] = []; + for (let M = 0; M < h.length; M++) + t[a].push(n.deepCopyAndCache(h[M], c)); + } else + typeof h == "object" && a != "properties" && a != "model" ? t[a] = n.deepCopyAndCache(h, c) : t[a] = h; + if (a == "and" || a == "or") { + const M = []; + for (const w of t[a]) { + const S = /* @__PURE__ */ new Set(); + for (const T of c.selectedAtoms(w)) + S.add(T.index); + M.push(S); + } + if (a == "and") { + const w = function(T, R) { + const z = /* @__PURE__ */ new Set(); + for (const P of R) + T.has(P) && z.add(P); + return z; + }; + let S = new Set(M[0]); + for (const T of M.splice(1)) + S = w(S, T); + t[a].__cached_results = S; + } else if (a == "or") { + const w = /* @__PURE__ */ new Set(); + for (const S of M) + for (const T of S) + w.add(T); + t[a].__cached_results = w; + } + } + } + return t.__cache_created = !0, t; + } + /** 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(f, c) { + if (typeof c > "u") + return !0; + var t = !!c.invert, a = !0; + for (var h in c) + if (h == "and" || h == "or" || h == "not") { + if (h == "not") { + if (this.atomIsSelected(f, c[h])) { + a = !1; + break; + } + } else if (c[h].__cached_results === void 0 && (c = n.deepCopyAndCache(c, this)), a = c[h].__cached_results.has(f.index), !a) + break; + } else if (h === "predicate") { + if (!c.predicate(f)) { + a = !1; + break; + } + } else if (h == "properties" && f[h]) { + for (var M in c.properties) + if (!M.startsWith("__cache")) { + if (typeof f.properties[M] > "u") { + a = !1; + break; + } + if (f.properties[M] != c.properties[M]) { + a = !1; + break; + } + } + } else if (c.hasOwnProperty(h) && !n.ignoredKeys.has(h) && !h.startsWith("__cache")) { + if (typeof f[h] > "u") { + a = !1; + break; + } + var w = !1; + if (h === "bonds") { + var S = c[h]; + if (S != f.bonds.length) { + a = !1; + break; + } + } else if (Array.isArray(c[h])) { + var T = c[h], R = f[h]; + for (let z = 0; z < T.length; z++) + if (this.propertyMatches(R, T[z])) { + w = !0; + break; + } + if (!w) { + a = !1; + break; + } + } else { + let z = c[h]; + if (!this.propertyMatches(f[h], z)) { + a = !1; + break; + } + } + } + return t ? !a : a; + } + static squaredDistance(f, c) { + var t = c.x - f.x, a = c.y - f.y, h = c.z - f.z; + return t * t + a * a + h * h; + } + /** 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(f, c) { + if (c <= 0) + return f; + for (var t = (0, E.getExtent)(f, void 0), a = [[], [], []], h = 0; h < 3; h++) + a[0][h] = t[0][h] - c, a[1][h] = t[1][h] + c, a[2][h] = t[2][h]; + var M = []; + for (let R = 0; R < this.atoms.length; R++) { + var w = this.atoms[R].x, S = this.atoms[R].y, T = this.atoms[R].z; + w >= a[0][0] && w <= a[1][0] && S >= a[0][1] && S <= a[1][1] && T >= a[0][2] && T <= a[1][2] && (w >= t[0][0] && w <= t[1][0] && S >= t[0][1] && S <= t[1][1] && T >= t[0][2] && T <= t[1][2] || M.push(this.atoms[R])); + } + return M; + } + static getFloat(f) { + return typeof f == "number" ? f : parseFloat(f); + } + /** 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(f, c) { + var t = []; + f = n.deepCopyAndCache(f || {}, this), c || (c = this.atoms); + for (var a = c.length, h = 0; h < a; h++) { + var M = c[h]; + M && this.atomIsSelected(M, f) && t.push(M); + } + if (f.hasOwnProperty("expand")) { + const N = n.getFloat(f.expand); + let G = this.expandAtomList(t, N), k = t.length; + const j = N * N; + for (let Q = 0; Q < G.length; Q++) + for (let ie = 0; ie < k; ie++) { + var w = n.squaredDistance(G[Q], t[ie]); + w < j && w > 0 && t.push(G[Q]); + } + } + if (f.hasOwnProperty("within") && f.within.hasOwnProperty("sel") && f.within.hasOwnProperty("distance")) { + var S = this.selectedAtoms(f.within.sel, this.atoms), T = {}; + const N = n.getFloat(f.within.distance), G = N * N; + for (let k = 0; k < S.length; k++) + for (let j = 0; j < t.length; j++) { + let Q = n.squaredDistance(S[k], t[j]); + Q < G && Q > 0 && (T[j] = 1); + } + var R = []; + if (f.within.invert) + for (let k = 0; k < t.length; k++) + T[k] || R.push(t[k]); + else + for (let k in T) + R.push(t[k]); + t = R; + } + if (f.hasOwnProperty("byres")) { + var z = {}, P = [], B = []; + for (let N = 0; N < t.length; N++) { + let G = t[N]; + var U = G.chain, F = G.resi; + if (z[U] === void 0 && (z[U] = {}), G.hasOwnProperty("resi") && z[U][F] === void 0) { + for (z[U][F] = !0, B.push(G); B.length > 0; ) + if (G = B.pop(), U = G.chain, F = G.resi, P[G.index] === void 0) { + P[G.index] = !0; + for (var $ = 0; $ < G.bonds.length; $++) { + var W = this.atoms[G.bonds[$]]; + P[W.index] === void 0 && W.hasOwnProperty("resi") && W.chain == U && W.resi == F && (B.push(W), t.push(W)); + } + } + } + } + } + return t; + } + /** 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(f) { + this.molObj = null; + var c = this.atoms.length, t = [], a; + for (a = 0; a < f.length; a++) + typeof f[a].index > "u" && (f[a].index = a), typeof f[a].serial > "u" && (f[a].serial = a), t[f[a].index] = c + a; + for (a = 0; a < f.length; a++) { + var h = f[a], M = t[h.index], w = (0, E.extend)({}, h); + w.index = M, w.bonds = [], w.bondOrder = [], w.model = this.id, w.style = w.style || (0, E.deepCopy)(n.defaultAtomStyle), typeof w.color > "u" && (w.color = this.ElementColors[w.elem] || this.defaultColor); + for (var S = h.bonds ? h.bonds.length : 0, T = 0; T < S; T++) { + var R = t[h.bonds[T]]; + typeof R < "u" && (w.bonds.push(R), w.bondOrder.push(h.bondOrder ? h.bondOrder[T] : 1)); + } + this.atoms.push(w); + } + } + /** 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, D.assignBonds)(this.atoms, { assignBonds: !0 }); + } + /** Remove specified atoms from model + * + * @param {AtomSpec[]} badatoms - list of atoms + */ + removeAtoms(f) { + this.molObj = null; + var c = [], t; + for (t = 0; t < f.length; t++) + c[f[t].index] = !0; + var a = []; + for (t = 0; t < this.atoms.length; t++) { + var h = this.atoms[t]; + c[h.index] || a.push(h); + } + this.atoms = [], this.addAtoms(a); + } + /** 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(f, c, t) { + typeof c > "u" && typeof t > "u" && (c = f, f = {}), f = f, typeof c == "string" && (c = (0, E.specStringToObject)(c)); + var a = !1, h = this, M = function(S) { + var T = h.selectedAtoms(f, S); + for (let R = 0; R < S.length; R++) + S[R] && (S[R].capDrawn = !1); + for (let R = 0; R < T.length; R++) { + a = !0, (T[R].clickable || T[R].hoverable) && (T[R].intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }), t || (T[R].style = {}); + for (let z in c) + c.hasOwnProperty(z) && (T[R].style[z] = T[R].style[z] || {}, Object.assign(T[R].style[z], c[z])); + } + }; + if (f.frame !== void 0 && f.frame < this.frames.length) { + let S = f.frame; + S < 0 && (S = this.frames.length + S), M(this.frames[S]); + } else { + M(this.atoms); + for (var w = 0; w < this.frames.length; w++) + this.frames[w] !== this.atoms && M(this.frames[w]); + } + a && (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(f, c, t) { + if (c = !!c, t = (0, E.makeFunction)(t), t === null) { + console.log("Callback is not a function"); + return; + } + var a = this.selectedAtoms(f, this.atoms), h = a.length; + for (let M = 0; M < h; M++) + a[M].intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }, a[M].clickable = c, t && (a[M].callback = t); + h > 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(f, c, t, a) { + if (c = !!c, t = (0, E.makeFunction)(t), a = (0, E.makeFunction)(a), t === null) { + console.log("Hover_callback is not a function"); + return; + } + if (a === null) { + console.log("Unhover_callback is not a function"); + return; + } + var h = this.selectedAtoms(f, this.atoms), M = h.length; + for (let w = 0; w < M; w++) + h[w].intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }, h[w].hoverable = c, t && (h[w].hover_callback = t), a && (h[w].unhover_callback = a); + 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(f, c) { + c = !!c; + var t, a = this.selectedAtoms(f, this.atoms), h = a.length; + for (t = 0; t < h; t++) + a[t].intersectionShape = { sphere: [], cylinder: [], line: [], triangle: [] }, a[t].contextMenuEnabled = c; + h > 0 && (this.molObj = null); + } + /** given a mapping from element to color, set atom colors + * + * @param {AtomSelectionSpec} sel + * @param {object} colors + */ + setColorByElement(f, c) { + if (!(this.molObj !== null && n.sameObj(c, this.lastColors))) { + this.lastColors = c; + var t = this.selectedAtoms(f, t); + t.length > 0 && (this.molObj = null); + for (var a = 0; a < t.length; a++) { + var h = t[a]; + typeof c[h.elem] < "u" && (h.color = c[h.elem]); + } + } + } + /** + * @param {AtomSelectionSpec} sel + * @param {string} prop + * @param {Gradient|string} scheme + */ + setColorByProperty(f, c, t, a) { + var h, M, w = this.selectedAtoms(f, w); + for (this.lastColors = null, w.length > 0 && (this.molObj = null), typeof t == "string" && typeof u.Gradient.builtinGradients[t] < "u" && (t = new u.Gradient.builtinGradients[t]()), t = t, a || (a = t.range()), a || (a = (0, E.getPropertyRange)(w, c)), h = 0; h < w.length; h++) { + M = w[h]; + var S = (0, E.getAtomProperty)(M, c); + S != null && (M.color = t.valueToHex(parseFloat(M.properties[c]), a)); + } + } + /** + * @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(f, c) { + var t = this.selectedAtoms(f, t); + if (typeof c == "function") { + this.lastColors = null, t.length > 0 && (this.molObj = null); + for (let a = 0; a < t.length; a++) { + let h = t[a]; + h.color = c(h); + } + } + } + /** 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(f = !1) { + var c = { a: [], b: [] }; + f && (c.s = []); + for (let a = 0; a < this.atoms.length; a++) { + let h = {}, M = this.atoms[a]; + if (h.x = M.x, h.y = M.y, h.z = M.z, M.elem != "C" && (h.l = M.elem), f) { + for (var t = 0; t < c.s.length && JSON.stringify(M.style) !== JSON.stringify(c.s[t]); ) + t++; + t === c.s.length && c.s.push(M.style), t !== 0 && (h.s = t); + } + c.a.push(h); + for (let w = 0; w < M.bonds.length; w++) { + let S = a, T = M.bonds[w]; + if (S >= T) + continue; + let R = { + b: S, + e: T + }, z = M.bondOrder[w]; + z != 1 && (R.o = z), c.b.push(R); + } + } + return c; + } + /** 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(f, c) { + (this.molObj === null || c.regen) && (this.molObj = this.createMolObj(this.atoms, c), this.renderedMolObj && (f.remove(this.renderedMolObj), this.renderedMolObj = null), this.renderedMolObj = this.molObj.clone(), this.hidden && (this.renderedMolObj.setVisible(!1), this.molObj.setVisible(!1)), f.add(this.renderedMolObj)); + } + /** return a VRML string representation of the model. Does not include VRML header information + * @return VRML + */ + exportVRML() { + var f = this.createMolObj(this.atoms, { supportsImposters: !1, supportsAIA: !1 }); + return f.vrml(); + } + /** Remove any renderable mol object from scene + * + * @param {Object3D} group + */ + removegl(f) { + this.renderedMolObj && (this.renderedMolObj.geometry !== void 0 && this.renderedMolObj.geometry.dispose(), this.renderedMolObj.material !== void 0 && this.renderedMolObj.material.dispose(), f.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(f, c, t, a) { + for (var h = this.selectedAtoms(c, h), M = (0, E.deepCopy)(a), w = 0; w < h.length; w++) { + var S = h[w], T = null; + typeof S[f] < "u" ? T = String(S[f]) : typeof S.properties[f] < "u" && (T = String(S.properties[f])), T != null && (M.position = S, t.addLabel(T, 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(f, c, t, a = !1) { + var h = [], M = function(S, T) { + for (var R = S.selectedAtoms(f, R), z = {}, P = 0; P < R.length; P++) { + var B = R[P], U = B.chain, F = B.resn, $ = B.resi, W = F + "" + $; + z[U] || (z[U] = {}), z[U][W] || (z[U][W] = []), z[U][W].push(B); + } + var N = (0, E.deepCopy)(t); + for (let k in z) + if (z.hasOwnProperty(k)) { + var G = z[k]; + for (let j in G) + if (G.hasOwnProperty(j)) { + let Q = G[j], ie = new _.Vector3(0, 0, 0); + for (let he = 0; he < Q.length; he++) { + let ue = Q[he]; + ie.x += ue.x, ie.y += ue.y, ie.z += ue.z; + } + ie.divideScalar(Q.length), N.position = ie, N.frame = T; + let pe = c.addLabel(j, N, void 0, !0); + h.push(pe); + } + } + }; + if (a) { + var w = this.getNumFrames(); + let S = this.atoms; + for (let T = 0; T < w; T++) + this.frames[T] && (this.atoms = this.frames[T], M(this, T)); + this.atoms = S; + } else + M(this); + return h; + } + //recurse over the current atoms to establish a depth first order + setupDFS() { + this.atomdfs = []; + var f = this, c = new Int8Array(this.atoms.length); + c.fill(0); + for (var t = function(w, S, T) { + T.push([w, S]); + var R = f.atoms[w]; + c[w] = 1; + for (var z = 0; z < R.bonds.length; z++) { + var P = R.bonds[z]; + f.atoms[P] && !c[P] && t(P, w, T); + } + }, a = 0; a < this.atoms.length; a++) { + var h = this.atoms[a]; + if (h && !c[a]) { + var M = []; + t(a, -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(f, c) { + this.frames = []; + var t = this; + return this.box && this.setupDFS(), f.startsWith("http") || (f = "http://" + f), (0, E.get)(f + "/traj/numframes/" + c, function(a) { + if (!isNaN(parseInt(a))) + return t.frames.push(t.atoms), t.frames.numFrames = a, t.frames.url = f, t.frames.path = c, t.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(f, c) { + if (c = c || "", !f) + return []; + if (/\.gz$/.test(c)) { + c = c.replace(/\.gz$/, ""); + try { + f = r(f); + } catch (z) { + console.log(z); + } + } + var t = { mdcrd: "", inpcrd: "", pdb: "", netcdf: "", array: "" }; + if (t.hasOwnProperty(c)) { + this.frames = []; + for (var a = this.atoms.length, h = n.parseCrd(f, c), M = 0; M < h.length; ) { + for (var w = [], S = 0; S < a; S++) { + var T = {}; + for (var R in this.atoms[S]) + T[R] = this.atoms[S][R]; + w[S] = T, w[S].x = h[M++], w[S].y = h[M++], w[S].z = h[M++]; + } + this.frames.push(w); + } + 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(f) { + } + static parseCrd(f, c) { + var t = [], a = 0; + if (c == "pdb") + for (var h = f.indexOf(` +ATOM`); h != -1; ) { + for (; f.slice(h, h + 5) == ` +ATOM` || f.slice(h, h + 7) == ` +HETATM`; ) + t[a++] = parseFloat(f.slice(h + 31, h + 39)), t[a++] = parseFloat(f.slice(h + 39, h + 47)), t[a++] = parseFloat(f.slice(h + 47, h + 55)), h = f.indexOf(` +`, h + 54), f.slice(h, h + 4) == ` +TER` && (h = f.indexOf(` +`, h + 5)); + h = f.indexOf(` +ATOM`, h); + } + else if (c == "netcdf") { + var M = new C.NetCDFReader(f); + t = [].concat.apply([], M.getDataVariable("coordinates")); + } else { + if (c == "array" || Array.isArray(f)) + return f.flat(2); + { + let w = f.indexOf(` +`); + c == "inpcrd" && (w = f.indexOf(` +`, w + 1)), f = f.slice(w + 1), t = f.match(/\S+/g).map(parseFloat); + } + } + return t; + } + static parseMolData(f, c = "", t) { + if (!f) + return []; + if (/\.gz$/.test(c)) { + c = c.replace(/\.gz$/, ""); + try { + f = r(f); + } catch (M) { + console.log(M); + } + } + typeof A.Parsers[c] > "u" && (c = c.split(".").pop(), typeof A.Parsers[c] > "u" && (console.log("Unknown format: " + c), f instanceof Uint8Array ? c = "mmtf" : f.match(/^@MOLECULE/gm) ? c = "mol2" : f.match(/^data_/gm) && f.match(/^loop_/gm) ? c = "cif" : f.match(/^HETATM/gm) || f.match(/^ATOM/gm) ? c = "pdb" : f.match(/ITEM: TIMESTEP/gm) ? c = "lammpstrj" : f.match(/^.*\n.*\n.\s*(\d+)\s+(\d+)/gm) ? c = "sdf" : f.match(/^%VERSION\s+VERSION_STAMP/gm) ? c = "prmtop" : c = "xyz", console.log("Best guess: " + c))); + var a = A.Parsers[c], h = a(f, t); + return h; + } + } + n.defaultAtomStyle = { + line: {} + }, n.defaultlineWidth = 1, n.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 + }, n.ignoredKeys = /* @__PURE__ */ new Set(["props", "invert", "model", "frame", "byres", "expand", "within", "and", "or", "not"]); + } + ), + /***/ + "./src/GLShape.ts": ( + /*!************************!*\ + !*** ./src/GLShape.ts ***! + \************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + GLShape: () => ( + /* binding */ + C + ), + /* harmony export */ + splitMesh: () => ( + /* binding */ + L + ) + /* harmony export */ + }); + var l = e( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), g = e( + /*! ./WebGL/shapes */ + "./src/WebGL/shapes/index.ts" + ), _ = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), x = e( + /*! ./colors */ + "./src/colors.ts" + ), o = e( + /*! ./ProteinSurface4 */ + "./src/ProteinSurface4.ts" + ), p = e( + /*! ./VolumeData */ + "./src/VolumeData.ts" + ), E = e( + /*! ./GLDraw */ + "./src/GLDraw.ts" + ), u = e( + /*! ./glcartoon */ + "./src/glcartoon.ts" + ), A = e( + /*! ./utilities */ + "./src/utilities.ts" + ); + class C { + static finalizeGeo(r) { + var n = r.updateGeoGroup(0); + n.vertices > 0 && n.truncateArrayBuffers(!0, !0); + } + /* + * + * @param {Geometry} + * geo + * @param {Color | colorlike} color + */ + static updateColor(r, n) { + n = n || x.CC.color(n), r.colorsNeedUpdate = !0; + var b, f, c; + n.constructor !== Array && (b = n.r, f = n.g, c = n.b); + for (let t in r.geometryGroups) { + let a = r.geometryGroups[t], h = a.colorArray; + for (let M = 0, w = a.vertices; M < w; ++M) { + if (n.constructor === Array) { + let S = n[M]; + b = S.r, f = S.g, c = S.b; + } + h[M * 3] = b, h[M * 3 + 1] = f, h[M * 3 + 2] = c; + } + } + } + /* + * @param {GLShape} + * shape + * @param {geometryGroup} + * geoGroup + * @param {ArrowSpec} + * spec + */ + static drawArrow(r, n, b) { + var f = b.start, c = b.end, t = b.radius, a = b.radiusRatio, h = b.mid, M = b.midpos; + if (!(f && c)) + return; + var w = n.updateGeoGroup(51), S = new _.Vector3(c.x, c.y, c.z).sub(f); + if (M) { + let le = S.length(); + M > 0 ? h = M / le : h = (le + M) / le; + } + S.multiplyScalar(h); + var T = new _.Vector3(f.x, f.y, f.z).add(S), R = S.clone().negate(); + let z = new _.Vector3(f.x, f.y, f.z); + r.intersectionShape.cylinder.push(new g.Cylinder(z, T.clone(), t)), r.intersectionShape.sphere.push(new g.Sphere(z, t)); + var P = []; + P[0] = S.clone(), Math.abs(P[0].x) > 1e-4 ? P[0].y += 1 : P[0].x += 1, P[0].cross(S), P[0].normalize(), P[4] = P[0].clone(), P[4].crossVectors(P[0], S), 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 B = w.vertices, U = w.vertexArray, F = w.faceArray, $ = w.normalArray, W = w.lineArray, N, G, k; + for (G = 0, k = P.length; G < k; ++G) { + N = 3 * (B + 3 * G); + var j = P[G].clone().multiplyScalar(t).add(f), Q = P[G].clone().multiplyScalar(t).add(T), ie = P[G].clone().multiplyScalar(t * a).add(T); + if (U[N] = j.x, U[N + 1] = j.y, U[N + 2] = j.z, U[N + 3] = Q.x, U[N + 4] = Q.y, U[N + 5] = Q.z, U[N + 6] = ie.x, U[N + 7] = ie.y, U[N + 8] = ie.z, G > 0) { + var pe = U[N - 3], he = U[N - 2], ue = U[N - 1], se = new _.Vector3(pe, he, ue), ae = new _.Vector3(c.x, c.y, c.z), we = T.clone(), xe = new _.Vector3(ie.x, ie.y, ie.z); + r.intersectionShape.triangle.push(new g.Triangle(xe, ae, se)), r.intersectionShape.triangle.push(new g.Triangle(se.clone(), we, xe.clone())); + } + } + w.vertices += 48, N = w.vertices * 3, U[N] = f.x, U[N + 1] = f.y, U[N + 2] = f.z, U[N + 3] = T.x, U[N + 4] = T.y, U[N + 5] = T.z, U[N + 6] = c.x, U[N + 7] = c.y, U[N + 8] = c.z, w.vertices += 3; + var Ie, oe, ve, re, Se, ze, Ge, $e, Re, Be, ke, We, Te, je, Fe, X, Z, q, fe, _e = w.vertices - 3, Me = w.vertices - 2, Ae = w.vertices - 1, H = _e * 3, ce = Me * 3, ye = Ae * 3; + for (G = 0, k = P.length - 1; G < k; ++G) { + var Pe = B + 3 * G; + N = Pe * 3, oe = w.faceidx, ve = w.lineidx, re = Pe, Be = re * 3, Se = Pe + 1, ke = Se * 3, ze = Pe + 2, We = ze * 3, Ge = Pe + 4, Te = Ge * 3, $e = Pe + 5, je = $e * 3, Re = Pe + 3, Fe = Re * 3, X = Z = P[G], q = fe = P[G + 1], $[Be] = X.x, $[ke] = Z.x, $[Fe] = fe.x, $[Be + 1] = X.y, $[ke + 1] = Z.y, $[Fe + 1] = fe.y, $[Be + 2] = X.z, $[ke + 2] = Z.z, $[Fe + 2] = fe.z, $[ke] = Z.x, $[Te] = q.x, $[Fe] = fe.x, $[ke + 1] = Z.y, $[Te + 1] = q.y, $[Fe + 1] = fe.y, $[ke + 2] = Z.z, $[Te + 2] = q.z, $[Fe + 2] = fe.z, $[We] = Z.x, $[je] = q.x, $[We + 1] = Z.y, $[je + 1] = q.y, $[We + 2] = Z.z, $[je + 2] = q.z, F[oe] = re, F[oe + 1] = Se, F[oe + 2] = Re, F[oe + 3] = Se, F[oe + 4] = Ge, F[oe + 5] = Re, F[oe + 6] = re, F[oe + 7] = Re, F[oe + 8] = _e, F[oe + 9] = ze, F[oe + 10] = Me, F[oe + 11] = $e, F[oe + 12] = ze, F[oe + 13] = Ae, F[oe + 14] = $e, W[ve] = re, W[ve + 1] = Se, W[ve + 2] = re, W[ve + 3] = Re, W[ve + 4] = Ge, W[ve + 5] = Re, W[ve + 6] = re, W[ve + 7] = Re, W[ve + 8] = ze, W[ve + 9] = Se, W[ve + 10] = ze, W[ve + 11] = $e, W[ve + 12] = Ge, W[ve + 13] = $e, W[ve + 14] = ze, W[ve + 15] = Ae, W[ve + 16] = ze, W[ve + 17] = $e, W[ve + 18] = Ae, W[ve + 19] = $e, w.faceidx += 15, w.lineidx += 20; + } + Ie = [ + B + 45, + B + 46, + B + 1, + B, + B + 47, + B + 2 + ], oe = w.faceidx, ve = w.lineidx, re = Ie[0], Be = re * 3, Se = Ie[1], ke = Se * 3, ze = Ie[4], We = ze * 3, Ge = Ie[2], Te = Ge * 3, $e = Ie[5], je = $e * 3, Re = Ie[3], Fe = Re * 3, X = Z = P[15], q = fe = P[0], $[Be] = X.x, $[ke] = Z.x, $[Fe] = fe.x, $[Be + 1] = X.y, $[ke + 1] = Z.y, $[Fe + 1] = fe.y, $[Be + 2] = X.z, $[ke + 2] = Z.z, $[Fe + 2] = fe.z, $[ke] = Z.x, $[Te] = q.x, $[Fe] = fe.x, $[ke + 1] = Z.y, $[Te + 1] = q.y, $[Fe + 1] = fe.y, $[ke + 2] = Z.z, $[Te + 2] = q.z, $[Fe + 2] = fe.z, $[We] = Z.x, $[je] = q.x, $[We + 1] = Z.y, $[je + 1] = q.y, $[We + 2] = Z.z, $[je + 2] = q.z, S.normalize(), R.normalize(), $[H] = R.x, $[ce] = $[ye] = S.x, $[H + 1] = R.y, $[ce + 1] = $[ye + 1] = S.y, $[H + 2] = R.z, $[ce + 2] = $[ye + 2] = S.z, F[oe] = re, F[oe + 1] = Se, F[oe + 2] = Re, F[oe + 3] = Se, F[oe + 4] = Ge, F[oe + 5] = Re, F[oe + 6] = re, F[oe + 7] = Re, F[oe + 8] = _e, F[oe + 9] = ze, F[oe + 10] = Me, F[oe + 11] = $e, F[oe + 12] = ze, F[oe + 13] = Ae, F[oe + 14] = $e, W[ve] = re, W[ve + 1] = Se, W[ve + 2] = re, W[ve + 3] = Re, W[ve + 4] = Ge, W[ve + 5] = Re, W[ve + 6] = re, W[ve + 7] = Re, W[ve + 8] = ze, W[ve + 9] = Se, W[ve + 10] = ze, W[ve + 11] = $e, W[ve + 12] = Ge, W[ve + 13] = $e, W[ve + 14] = ze, W[ve + 15] = Ae, W[ve + 16] = ze, W[ve + 17] = $e, W[ve + 18] = Ae, W[ve + 19] = $e, w.faceidx += 15, w.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(r, n, b, f) { + r.center.set(0, 0, 0); + let c = 1 / 0, t = 1 / 0, a = 1 / 0, h = -1 / 0, M = -1 / 0, w = -1 / 0; + r.box && (c = r.box.min.x, h = r.box.max.x, t = r.box.min.y, M = r.box.max.y, a = r.box.min.z, w = r.box.max.z); + for (let z = 0, P = f; z < P; z++) { + var S = b[z * 3], T = b[z * 3 + 1], R = b[z * 3 + 2]; + S < c && (c = S), T < t && (t = T), R < a && (a = R), S > h && (h = S), T > M && (M = T), R > w && (w = R); + } + r.center.set((h + c) / 2, (M + t) / 2, (w + a) / 2), r.radius = r.center.distanceTo({ x: h, y: M, z: w }), r.box = { min: { x: c, y: t, z: a }, max: { x: h, y: M, z: w } }; + } + //helper function for adding an appropriately sized mesh + static addCustomGeo(r, n, b, f, c) { + var t = n.addGeoGroup(), a = b.vertexArr, h = b.normalArr, M = b.faceArr; + t.vertices = a.length, t.faceidx = M.length; + var w, S, T, R, z, P, B, U, F, $ = t.vertexArray, W = t.colorArray; + for (f.constructor !== Array && (U = f.r, F = f.g, R = f.b), P = 0, B = t.vertices; P < B; ++P) + w = P * 3, S = a[P], $[w] = S.x, $[w + 1] = S.y, $[w + 2] = S.z, f.constructor === Array && (z = f[P], U = z.r, F = z.g, R = z.b), W[w] = U, W[w + 1] = F, W[w + 2] = R; + if (c) + for (P = 0, B = t.faceidx / 3; P < B; ++P) { + w = P * 3, T = M[w], R = M[w + 1], z = M[w + 2]; + var N = new _.Vector3(), G = new _.Vector3(), k = new _.Vector3(); + r.intersectionShape.triangle.push(new g.Triangle(N.copy(a[T]), G.copy(a[R]), k.copy(a[z]))); + } + if (c) { + var j = new _.Vector3(0, 0, 0), Q = 0; + for (let he = 0; he < n.geometryGroups.length; he++) + j.add(n.geometryGroups[he].getCentroid()), Q++; + j.divideScalar(Q), C.updateBoundingFromPoints(r.boundingSphere, { centroid: j }, $, t.vertices); + } + if (t.faceArray = new Uint16Array(M), t.truncateArrayBuffers(!0, !0), h.length < t.vertices) + t.setNormals(); + else { + var ie = t.normalArray = new Float32Array(t.vertices * 3), pe; + for (P = 0, B = t.vertices; P < B; ++P) + w = P * 3, pe = h[P], ie[w] = pe.x, ie[w + 1] = pe.y, ie[w + 2] = pe.z; + } + t.setLineIndices(), t.lineidx = t.lineArray.length; + } + /* + * + * @param {$3Dmol.GLShape} + * shape + * @param {ShapeSpec} + * stylespec + * @returns {undefined} + */ + static updateFromStyle(r, n) { + typeof n.color < "u" ? (r.color = n.color || new x.Color(), n.color instanceof x.Color || (r.color = x.CC.color(n.color))) : r.color = x.CC.color(0), r.wireframe = !!n.wireframe, r.opacity = n.alpha ? (0, _.clamp)(n.alpha, 0, 1) : 1, typeof n.opacity < "u" && (r.opacity = (0, _.clamp)(n.opacity, 0, 1)), r.side = n.side !== void 0 ? n.side : l.DoubleSide, r.linewidth = typeof n.linewidth > "u" ? 1 : n.linewidth, r.clickable = !!n.clickable, r.callback = (0, A.makeFunction)(n.callback), r.hoverable = !!n.hoverable, r.hover_callback = (0, A.makeFunction)(n.hover_callback), r.unhover_callback = (0, A.makeFunction)(n.unhover_callback), r.hidden = n.hidden, r.frame = n.frame; + } + /** + * Custom renderable shape + * + * @constructor + * + * @param {ShapeSpec} stylespec + */ + constructor(r) { + this.color = 16777215, this.hidden = !1, this.wireframe = !1, this.opacity = 1, this.linewidth = 1, this.clickable = !1, this.hoverable = !1, this.side = l.DoubleSide, this.stylespec = r || {}, this.boundingSphere = new g.Sphere(), this.intersectionShape = { + sphere: [], + cylinder: [], + line: [], + triangle: [] + }, C.updateFromStyle(this, this.stylespec), this.components = [], this.shapeObj = null, this.renderedShapeObj = null, this.geo = new l.Geometry(!0), this.linegeo = new l.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(r) { + for (var n in r) + this.stylespec[n] = r[n]; + if (C.updateFromStyle(this, this.stylespec), r.voldata && r.volscheme) { + (0, A.adjustVolumeStyle)(r); + const b = r.volscheme, f = r.voldata, c = x.CC, t = b.range() || [-1, 1]; + this.geo.setColors(function(a, h, M) { + let w = f.getVal(a, h, M); + return c.color(b.valueToHex(w, t)); + }), delete this.color; + } + } + /** + * Creates a custom shape from supplied vertex and face arrays + * @param {CustomShapeSpec} customSpec + */ + addCustom(r) { + r.vertexArr = r.vertexArr || [], r.faceArr = r.faceArr || [], r.normalArr = r.normalArr || [], C.drawCustom(this, this.geo, r); + } + /** + * 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(r) { + r.center || (r.center = new _.Vector3(0, 0, 0)), r.radius = r.radius ? (0, _.clamp)(r.radius, 0, 1 / 0) : 1.5, r.color = x.CC.color(r.color), this.intersectionShape.sphere.push(new g.Sphere(r.center, r.radius)), E.GLDraw.drawSphere(this.geo, r.center, r.radius, r.color, r.quality), this.components.push({ + centroid: new _.Vector3(r.center.x, r.center.y, r.center.z) + }); + var n = this.geo.updateGeoGroup(0); + C.updateBoundingFromPoints(this.boundingSphere, this.components, n.vertexArray, n.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(r) { + var n = r.dimensions || { w: 1, h: 1, d: 1 }, b; + typeof n.w == "number" ? b = { x: n.w, y: 0, z: 0 } : b = n.w; + var f; + typeof n.h == "number" ? f = { x: 0, y: n.h, z: 0 } : f = n.h; + var c; + typeof n.d == "number" ? c = { x: 0, y: 0, z: n.d } : c = n.d; + var t = r.corner; + t == null && (r.center !== void 0 ? t = { + x: r.center.x - 0.5 * (b.x + f.x + c.x), + y: r.center.y - 0.5 * (b.y + f.y + c.y), + z: r.center.z - 0.5 * (b.z + f.z + c.z) + } : t = { x: 0, y: 0, z: 0 }); + var a = [ + { x: t.x, y: t.y, z: t.z }, + { x: t.x + b.x, y: t.y + b.y, z: t.z + b.z }, + { x: t.x + f.x, y: t.y + f.y, z: t.z + f.z }, + { x: t.x + b.x + f.x, y: t.y + b.y + f.y, z: t.z + b.z + f.z }, + { x: t.x + c.x, y: t.y + c.y, z: t.z + c.z }, + { x: t.x + b.x + c.x, y: t.y + b.y + c.y, z: t.z + b.z + c.z }, + { x: t.x + f.x + c.x, y: t.y + f.y + c.y, z: t.z + f.z + c.z }, + { x: t.x + b.x + f.x + c.x, y: t.y + b.y + f.y + c.y, z: t.z + b.z + f.z + c.z } + ], h = [], M = []; + h.splice(h.length, 0, a[0], a[1], a[2], a[3]), M.splice(M.length, 0, 0, 2, 1, 1, 2, 3); + var w = 4; + h.splice(h.length, 0, a[2], a[3], a[6], a[7]), M.splice(M.length, 0, w + 0, w + 2, w + 1, w + 1, w + 2, w + 3), w += 4, h.splice(h.length, 0, a[4], a[5], a[0], a[1]), M.splice(M.length, 0, w + 0, w + 2, w + 1, w + 1, w + 2, w + 3), w += 4, h.splice(h.length, 0, a[6], a[7], a[4], a[5]), M.splice(M.length, 0, w + 0, w + 2, w + 1, w + 1, w + 2, w + 3), w += 4, h.splice(h.length, 0, a[3], a[1], a[7], a[5]), M.splice(M.length, 0, w + 0, w + 2, w + 1, w + 1, w + 2, w + 3), w += 4, h.splice(h.length, 0, a[2], a[6], a[0], a[4]), M.splice(M.length, 0, w + 0, w + 2, w + 1, w + 1, w + 2, w + 3), w += 4; + var S = (0, A.extend)({}, r); + S.vertexArr = h, S.faceArr = M, S.normalArr = [], C.drawCustom(this, this.geo, S); + var T = new _.Vector3(); + this.components.push({ + centroid: T.addVectors(a[0], a[7]).multiplyScalar(0.5) + }); + var R = this.geo.updateGeoGroup(0); + C.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(r) { + var n, b; + r.start ? n = new _.Vector3(r.start.x || 0, r.start.y || 0, r.start.z || 0) : n = new _.Vector3(0, 0, 0), r.end ? (b = new _.Vector3(r.end.x, r.end.y || 0, r.end.z || 0), typeof b.x > "u" && (b.x = 3)) : b = new _.Vector3(0, 0, 0); + var f = r.radius || 0.1, c = x.CC.color(r.color); + this.intersectionShape.cylinder.push(new g.Cylinder(n, b, f)), E.GLDraw.drawCylinder(this.geo, n, b, f, c, r.fromCap, r.toCap); + var t = new _.Vector3(); + this.components.push({ + centroid: t.addVectors(n, b).multiplyScalar(0.5) + }); + var a = this.geo.updateGeoGroup(0); + C.updateBoundingFromPoints(this.boundingSphere, this.components, a.vertexArray, a.vertices); + } + /** + * Creates a dashed cylinder shape + * @param {CylinderSpec} cylinderSpec + */ + addDashedCylinder(r) { + r.dashLength = r.dashLength || 0.25, r.gapLength = r.gapLength || 0.25; + var n; + r.start ? n = new _.Vector3(r.start.x || 0, r.start.y || 0, r.start.z || 0) : n = new _.Vector3(0, 0, 0); + var b; + r.end ? (b = new _.Vector3(r.end.x, r.end.y || 0, r.end.z || 0), typeof b.x > "u" && (b.x = 3)) : b = new _.Vector3(3, 0, 0); + for (var f = r.radius || 0.1, c = x.CC.color(r.color), t = Math.sqrt(Math.pow(n.x - b.x, 2) + Math.pow(n.y - b.y, 2) + Math.pow(n.z - b.z, 2)), a = t / (r.gapLength + r.dashLength), h = new _.Vector3(r.start.x || 0, r.start.y || 0, r.start.z || 0), M = new _.Vector3(r.end.x, r.end.y || 0, r.end.z || 0), w = new _.Vector3((b.x - n.x) / (t / r.gapLength), (b.y - n.y) / (t / r.gapLength), (b.z - n.z) / (t / r.gapLength)), S = new _.Vector3((b.x - n.x) / (t / r.dashLength), (b.y - n.y) / (t / r.dashLength), (b.z - n.z) / (t / r.dashLength)), T = 0; T < a; T++) + M = new _.Vector3(h.x + S.x, h.y + S.y, h.z + S.z), this.intersectionShape.cylinder.push(new g.Cylinder(h, M, f)), E.GLDraw.drawCylinder(this.geo, h, M, f, c, r.fromCap, r.toCap), h = new _.Vector3(M.x + w.x, M.y + w.y, M.z + w.z); + var R = new _.Vector3(); + this.components.push({ + centroid: R.addVectors(n, b).multiplyScalar(0.5) + }); + var z = this.geo.updateGeoGroup(0); + C.updateBoundingFromPoints(this.boundingSphere, this.components, z.vertexArray, z.vertices); + } + /** + * Creates a curved shape + * @param {CurveSpec} curveSpec + */ + addCurve(r) { + r.points = r.points || [], r.smooth = r.smooth || 10, typeof r.fromCap > "u" && (r.fromCap = 2), typeof r.toCap > "u" && (r.toCap = 2); + var n = (0, u.subdivide_spline)(r.points, r.smooth); + if (n.length < 3) { + console.log("Too few points in addCurve"); + return; + } + var b = r.radius || 0.1, f = x.CC.color(r.color), c = 0, t = n.length - 1, a = n[0].distanceTo(n[1]), h = Math.ceil(2 * b / a); + if (r.toArrow) { + t -= h; + let T = { + start: n[t], + end: n[n.length - 1], + radius: b, + color: f, + mid: 1e-4 + }; + this.addArrow(T); + } + if (r.fromArrow) { + c += h; + let T = { + start: n[c], + end: n[0], + radius: b, + color: f, + mid: 1e-4 + }; + this.addArrow(T); + } + for (var M = Math.ceil(n.length / 2), w = { radius: b, color: f, fromCap: 2, toCap: 2 }, S = c; S < t; S++) + w.start = n[S], w.end = n[S + 1], w.fromCap = 2, w.toCap = 2, S < M ? (w.fromCap = 2, w.toCap = 0) : S > M ? (w.fromCap = 0, w.toCap = 2) : (w.fromCap = 2, w.toCap = 2), this.addCylinder(w); + } + /** + * 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(r) { + var n, b; + r.start ? n = new _.Vector3(r.start.x || 0, r.start.y || 0, r.start.z || 0) : n = new _.Vector3(0, 0, 0), r.end ? (b = new _.Vector3(r.end.x, r.end.y || 0, r.end.z || 0), typeof b.x > "u" && (b.x = 3)) : b = new _.Vector3(3, 0, 0); + var f = this.geo.updateGeoGroup(2), c = f.vertices, t = c * 3, a = f.vertexArray; + a[t] = n.x, a[t + 1] = n.y, a[t + 2] = n.z, a[t + 3] = b.x, a[t + 4] = b.y, a[t + 5] = b.z, f.vertices += 2; + var h = f.lineArray, M = f.lineidx; + h[M] = c, h[M + 1] = c + 1, f.lineidx += 2; + var w = new _.Vector3(); + this.components.push({ + centroid: w.addVectors(n, b).multiplyScalar(0.5) + }), f = this.geo.updateGeoGroup(0), C.updateBoundingFromPoints(this.boundingSphere, this.components, f.vertexArray, f.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(r) { + if (r.start ? r.start = new _.Vector3(r.start.x || 0, r.start.y || 0, r.start.z || 0) : r.start = new _.Vector3(0, 0, 0), r.dir instanceof _.Vector3 && typeof r.length == "number") { + var n = r.dir.clone().multiplyScalar(r.length).add(r.start); + r.end = n; + } else + r.end ? (r.end = new _.Vector3(r.end.x, r.end.y || 0, r.end.z || 0), typeof r.end.x > "u" && (r.end.x = 3)) : r.end = new _.Vector3(3, 0, 0); + r.radius = r.radius || 0.1, r.radiusRatio = r.radiusRatio || 1.618034, r.mid = 0 < r.mid && r.mid < 1 ? r.mid : 0.618034, C.drawArrow(this, this.geo, r); + var b = new _.Vector3(); + this.components.push({ + centroid: b.addVectors(r.start, r.end).multiplyScalar(0.5) + }); + var f = this.geo.updateGeoGroup(0); + C.updateBoundingFromPoints(this.boundingSphere, this.components, f.vertexArray, f.vertices); + } + static distance_from(r, n) { + return Math.sqrt(Math.pow(r.x - n.x, 2) + Math.pow(r.y - n.y, 2) + Math.pow(r.z - n.z, 2)); + } + static inSelectedRegion(r, n, b) { + for (var f = 0; f < n.length; f++) + if (C.distance_from(n[f], r) <= b) + 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(r, n, b) { + var f = n.isoval !== void 0 && typeof n.isoval == "number" ? n.isoval : 0, c = !!n.voxel, t = n.smoothness === void 0 ? 1 : n.smoothness, a = r.size.x, h = r.size.y, M = r.size.z, w = new Int16Array(a * h * M), S = r.data, T, R; + for (T = 0, R = w.length; T < R; ++T) + w[T] = -1; + var z = new Uint8Array(a * h * M); + for (T = 0, R = S.length; T < R; ++T) { + var P = f >= 0 ? S[T] - f : f - S[T]; + P > 0 && (z[T] |= C.ISDONE); + } + var B = [], U = []; + o.MarchingCube.march(z, B, U, { + fulltable: !0, + voxel: c, + unitCube: r.unit, + origin: r.origin, + matrix: r.matrix, + nX: a, + nY: h, + nZ: M + }), !c && t > 0 && o.MarchingCube.laplacianSmooth(t, B, U); + var F = [], $ = [], W = []; + if (n.selectedRegion && n.coords === void 0 && (n.coords = n.selectedRegion), n.coords !== void 0) { + var N = n.coords[0].x, G = n.coords[0].y, k = n.coords[0].z, j = n.coords[0].x, Q = n.coords[0].y, ie = n.coords[0].z; + for (let oe = 0; oe < n.coords.length; oe++) + n.coords[oe].x > N ? N = n.coords[oe].x : n.coords[oe].x < j && (j = n.coords[oe].x), n.coords[oe].y > G ? G = n.coords[oe].y : n.coords[oe].y < Q && (Q = n.coords[oe].y), n.coords[oe].z > k ? k = n.coords[oe].z : n.coords[oe].z < ie && (ie = n.coords[oe].z); + var pe = 2; + n.radius !== void 0 && (pe = n.radius), n.selectedOffset !== void 0 && (pe = n.selectedOffset), n.seldist !== void 0 && (pe = n.seldist), j -= pe, N += pe, Q -= pe, G += pe, ie -= pe, k += pe; + for (let oe = 0; oe < B.length; oe++) + B[oe].x > j && B[oe].x < N && B[oe].y > Q && B[oe].y < G && B[oe].z > ie && B[oe].z < k && C.inSelectedRegion(B[oe], n.coords, pe) ? (F.push($.length), $.push(B[oe])) : F.push(-1); + for (let oe = 0; oe + 2 < U.length; oe += 3) + F[U[oe]] !== -1 && F[U[oe + 1]] !== -1 && F[U[oe + 2]] !== -1 && (W.push(U[oe] - (U[oe] - F[U[oe]])), W.push(U[oe + 1] - (U[oe + 1] - F[U[oe + 1]])), W.push(U[oe + 2] - (U[oe + 2] - F[U[oe + 2]]))); + B = $, U = W; + } + C.drawCustom(this, this.geo, { + vertexArr: B, + faceArr: U, + normalArr: [], + clickable: n.clickable, + hoverable: n.hoverable + }), this.updateStyle(n); + var he = new _.Vector3(r.origin.x, r.origin.y, r.origin.z), ue = new _.Vector3(r.size.x * r.unit.x, r.size.y * r.unit.y, r.size.z * r.unit.z), se = new _.Vector3(0, 0, 0), ae = he.clone(), we = he.clone().add(ue); + for (let oe = 0; oe < B.length; oe++) + se.add(B[oe]), ae.max(B[oe]), we.min(B[oe]); + se.divideScalar(B.length); + var xe = se.distanceTo(we), Ie = se.distanceTo(ae); + this.boundingSphere.center = se, this.boundingSphere.radius = Math.max(xe, Ie), typeof b == "function" && b(); + } + /** + * @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(r, n, b) { + r = new p.VolumeData(r, n), this.addIsosurface(r, b); + } + //for internal use, truncate buffers to save memory + finalize() { + return C.finalizeGeo(this.geo), this.geo.initTypedArrays(), this.geo; + } + /* + * Initialize webgl objects for rendering + * @param {$3Dmol.Object3D} group + * + */ + globj(r) { + if (this.renderedShapeObj && (r.remove(this.renderedShapeObj), this.renderedShapeObj = null), !this.hidden) { + C.finalizeGeo(this.geo), this.geo.initTypedArrays(), this.wireframe && this.geo.setUpWireframe(), typeof this.color < "u" && C.updateColor(this.geo, this.color), this.shapeObj = new l.Object3D(); + var n = null; + this.side == l.DoubleSide ? n = new l.MeshDoubleLambertMaterial({ + wireframe: this.wireframe, + side: this.side, + transparent: this.opacity < 1, + opacity: this.opacity, + wireframeLinewidth: this.linewidth, + vertexColors: l.Coloring.VertexColors + }) : n = new l.MeshLambertMaterial({ + wireframe: this.wireframe, + side: this.side, + transparent: this.opacity < 1, + opacity: this.opacity, + wireframeLinewidth: this.linewidth, + vertexColors: l.Coloring.VertexColors + }); + var b = new l.Mesh(this.geo, n); + this.shapeObj.add(b); + var f = new l.LineBasicMaterial({ + linewidth: this.linewidth, + color: this.color + }), c = new l.Line(this.linegeo, f, l.LineStyle.LinePieces); + this.shapeObj.add(c), this.renderedShapeObj = this.shapeObj.clone(), r.add(this.renderedShapeObj); + } + } + removegl(r) { + this.renderedShapeObj && (this.renderedShapeObj.geometry !== void 0 && this.renderedShapeObj.geometry.dispose(), this.renderedShapeObj.material !== void 0 && this.renderedShapeObj.material.dispose(), r.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; + } + } + C.ISDONE = 2, C.drawCustom = function(D, r, n) { + var b = n, f = b.vertexArr, c = b.faceArr; + (f.length === 0 || c.length === 0) && console.warn("Error adding custom shape component: No vertices and/or face indices supplied!"); + var t = n.color; + typeof t > "u" && (t = D.color), t = x.CC.color(t); + for (var a = L(b), h = 0, M = a.length; h < M; h++) + C.addCustomGeo(D, r, a[h], a[h].colorArr ? a[h].colorArr : t, n.clickable); + }; + function L(D) { + var r = 64e3; + if (D.vertexArr.length < r) + return [D]; + var n = [{ vertexArr: [], normalArr: [], faceArr: [] }]; + D.colorArr && (n.colorArr = []); + var b = [], f = [], c = 0, t = D.faceArr; + for (let h = 0, M = t.length; h < M; h += 3) { + let w = n[c]; + for (let S = 0; S < 3; S++) { + var a = t[h + S]; + b[a] !== c && (b[a] = c, f[a] = w.vertexArr.length, w.vertexArr.push(D.vertexArr[a]), D.normalArr && D.normalArr[a] && w.normalArr.push(D.normalArr[a]), D.colorArr && D.colorArr[a] && w.colorArr.push(D.colorArr[a])), w.faceArr.push(f[a]); + } + w.vertexArr.length >= r && (n.push({ vertexArr: [], normalArr: [], faceArr: [] }), D.colorArr && (n.colorArr = []), c++); + } + return n; + } + } + ), + /***/ + "./src/GLViewer.ts": ( + /*!*************************!*\ + !*** ./src/GLViewer.ts ***! + \*************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + GLViewer: () => ( + /* binding */ + r + ), + /* harmony export */ + createStereoViewer: () => ( + /* binding */ + f + ), + /* harmony export */ + createViewer: () => ( + /* binding */ + n + ), + /* harmony export */ + createViewerGrid: () => ( + /* binding */ + b + ) + /* harmony export */ + }); + var l = e( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), g = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), _ = e( + /*! ./colors */ + "./src/colors.ts" + ), x = e( + /*! ./utilities */ + "./src/utilities.ts" + ), o = e( + /*! ./Gradient */ + "./src/Gradient.ts" + ), p = e( + /*! ./GLModel */ + "./src/GLModel.ts" + ), E = e( + /*! ./Label */ + "./src/Label.ts" + ), u = e( + /*! ./GLShape */ + "./src/GLShape.ts" + ), A = e( + /*! ./VolumeData */ + "./src/VolumeData.ts" + ), C = e( + /*! ./ProteinSurface4 */ + "./src/ProteinSurface4.ts" + ), L = e( + /*! ./VolumetricRender */ + "./src/VolumetricRender.ts" + ), D = e( + /*! upng-js */ + "./node_modules/upng-js/UPNG.js" + ); + class r { + //reimplement jquery getwidth/height + getRect() { + let t = this.container, a = t.getBoundingClientRect(); + if (a.width == 0 && a.height == 0 && t.style.display === "none") { + let h = t.style.position, M = t.style.visibility; + t.style.display = "block", t.style.visibility = "hidden", t.style.position = "absolute", a = t.getBoundingClientRect(), t.style.display = "none", t.style.visibility = M, t.style.position = h; + } + return a; + } + getWidth() { + return this.getRect().width; + } + getHeight() { + return this.getRect().height; + } + setupRenderer() { + this.renderer = new l.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 l.Scene(), this.scene.fog = new l.Fog(this.bgColor, 100, 200), this.modelGroup = new l.Object3D(), this.rotationGroup = new l.Object3D(), this.rotationGroup.useQuaternion = !0, this.rotationGroup.quaternion = new g.Quaternion(0, 0, 0, 1), this.rotationGroup.add(this.modelGroup), this.scene.add(this.rotationGroup); + var t = new l.Light(16777215); + t.position = new g.Vector3(0.2, 0.2, 1).normalize(), t.intensity = 1, this.scene.add(t); + } + initContainer(t) { + this.container = t, 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 t = 0; + for (let h in this.surfaces) + if (this.surfaces.hasOwnProperty(h)) { + var a = parseInt(h); + isNaN(a) || a > t && (t = a); + } + return t + 1; + } + setSlabAndFog() { + let t = this.camera.position.z - this.rotationGroup.position.z; + t < 1 && (t = 1), this.camera.near = t + this.slabNear, this.camera.near < 1 && (this.camera.near = 1), this.camera.far = t + this.slabFar, this.camera.near + 1 > this.camera.far && (this.camera.far = this.camera.near + 1), this.camera.fov = this.fov, this.camera.right = t * 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(t) { + if (this.renderer.setViewport(), !!this.scene && (this.setSlabAndFog(), this.renderer.render(this.scene, this.camera), this.viewChangeCallback && this.viewChangeCallback(this._viewer.getView()), !t && this.linkedViewers.length > 0)) + for (var a = this._viewer.getView(), h = 0; h < this.linkedViewers.length; h++) { + var M = this.linkedViewers[h]; + M.setView(a, !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 t = 0, a = this.models.length; t < a; t++) { + let h = this.models[t]; + if (h) { + let M = h.selectedAtoms({ + clickable: !0 + }), w = h.selectedAtoms({ + hoverable: !0 + }), S = h.selectedAtoms({ contextMenuEnabled: !0 }); + for (let T = 0; T < w.length; T++) + this.hoverables.push(w[T]); + for (let T = 0; T < M.length; T++) + this.clickables.push(M[T]); + for (let T = 0; T < S.length; T++) + this.contextMenuEnabledAtoms.push(S[T]); + } + } + for (let t = 0, a = this.shapes.length; t < a; t++) { + let h = this.shapes[t]; + h && h.clickable && this.clickables.push(h), h && h.hoverable && this.hoverables.push(h); + } + } + // Checks for selection intersects on mousedown + handleClickSelection(t, a, h) { + let M = this.targetedObjects(t, a, this.clickables); + if (M.length) { + var w = M[0].clickable; + w.callback !== void 0 && (typeof w.callback != "function" && (w.callback = (0, x.makeFunction)(w.callback)), typeof w.callback == "function" && w.callback(w, this._viewer, h, this.container, M)); + } + } + //return offset of container + canvasOffset() { + let t = this.glDOM, a = t.getBoundingClientRect(), h = t.ownerDocument, M = h.documentElement, w = h.defaultView; + return { + top: a.top + w.pageYOffset - M.clientTop, + left: a.left + w.pageXOffset - M.clientLeft + }; + } + //set current_hover to sel (which can be null), calling appropraite callbacks + setHover(t, a, h) { + this.current_hover != t && (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, a, this.container, h)), this.current_hover = t, t && t.hover_callback !== void 0 && (typeof t.hover_callback != "function" && (t.hover_callback = (0, x.makeFunction)(t.hover_callback)), typeof t.hover_callback == "function" && t.hover_callback(t, this._viewer, a, this.container, h))); + } + //checks for selection intersects on hover + handleHoverSelection(t, a, h) { + if (this.hoverables.length == 0) + return; + let M = this.targetedObjects(t, a, this.hoverables); + if (M.length) { + var w = M[0].clickable; + this.setHover(w, h, M), this.current_hover = w; + } 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(t, a) { + let h = this.targetedObjects(t, a, this.hoverables); + (h.length == 0 || h[0] === void 0) && this.setHover(null), h[0] !== void 0 && h[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(t, { allowTolerance: a = t.targetTouches, tolerance: h = 5 } = {}) { + const M = this.getX(t), w = this.getY(t); + if (a) { + const S = Math.abs(M - this.mouseStartX), T = Math.abs(w - this.mouseStartY); + return S <= h && T <= h; + } else + return M === this.mouseStartX && w === this.mouseStartY; + } + calcTouchDistance(t) { + var a = t.targetTouches[0].pageX - t.targetTouches[1].pageX, h = t.targetTouches[0].pageY - t.targetTouches[1].pageY; + return Math.hypot(a, h); + } + //check targetTouches as well + getX(t) { + var a = t.pageX; + return a == null && (a = t.pageX), t.targetTouches && t.targetTouches[0] ? a = t.targetTouches[0].pageX : t.changedTouches && t.changedTouches[0] && (a = t.changedTouches[0].pageX), a; + } + getY(t) { + var a = t.pageY; + return a == null && (a = t.pageY), t.targetTouches && t.targetTouches[0] ? a = t.targetTouches[0].pageY : t.changedTouches && t.changedTouches[0] && (a = t.changedTouches[0].pageY), a; + } + //for grid viewers, return true if point is in this viewer + isInViewer(t, a) { + if (this.viewers != null) { + var h = this.WIDTH / this.cols, M = this.HEIGHT / this.rows, w = this.canvasOffset(), S = t - w.left, T = a - w.top, R = this.rows - Math.floor(T / M) - 1, z = Math.floor(S / h); + if (R != this.row || z != 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(t) { + if (this.config.lowerZoomLimit && this.config.lowerZoomLimit > 0) { + let a = this.CAMERA_Z - this.config.lowerZoomLimit; + t > a && (t = a); + } + if (this.config.upperZoomLimit && this.config.upperZoomLimit > 0) { + let a = this.CAMERA_Z - this.config.upperZoomLimit; + t < a && (t = a); + } + return t > this.CAMERA_Z - 1 && (t = this.CAMERA_Z - 1), t; + } + //interpolate between two normalized quaternions (t between 0 and 1) + //https://en.wikipedia.org/wiki/Slerp + static slerp(t, a, h) { + if (h == 1) + return a.clone(); + if (h == 0) + return t.clone(); + let M = t.x * a.x + t.y * a.y + t.z * a.z + t.w * a.w; + if (M > 0.9995) { + let B = new g.Quaternion(t.x + h * (a.x - t.x), t.y + h * (a.y - t.y), t.z + h * (a.z - t.z), t.w + h * (a.w - t.w)); + return B.normalize(), B; + } + M < 0 && (a = a.clone().multiplyScalar(-1), M = -M), M > 1 ? M = 1 : M < -1 && (M = -1); + var w = Math.acos(M), S = w * h, T = a.clone(); + T.sub(t.clone().multiplyScalar(M)), T.normalize(); + var R = Math.cos(S), z = Math.sin(S), P = new g.Quaternion(t.x * R + T.x * z, t.y * R + T.y * z, t.z * R + T.z * z, t.w * R + T.w * z); + 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(t, a = {}) { + 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 g.Quaternion(0, 0, 0, 1), this.dq = new g.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 = a, 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 = t, 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 l.Camera(this.fov, this.ASPECT, this.NEAR, this.FAR, this.config.orthographic), this.camera.position = new g.Vector3(this.camerax, 0, this.CAMERA_Z), this.lookingAt = new g.Vector3(), this.camera.lookAt(this.lookingAt), this.raycaster = new l.Raycaster(new g.Vector3(0, 0, 0), new g.Vector3(0, 0, 0)), this.projector = new l.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 (h) { + console.log("error with glviewer callback: " + h); + } + } + /** + * 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(t, a, h) { + var M = { + x: t, + y: a, + z: -1 + }; + return Array.isArray(h) || (h = this.selectedAtoms(h)), h.length == 0 ? [] : (this.raycaster.setFromCamera(M, this.camera), this.raycaster.intersectObjects(this.modelGroup, h)); + } + /** 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(t) { + let a = !1; + Array.isArray(t) || (t = [t], a = !0); + let h = this.renderer.getXRatio(), M = this.renderer.getYRatio(), w = this.col, S = this.row, T = w * (this.WIDTH / h), R = (M - S - 1) * (this.HEIGHT / M), z = [], P = this.canvasOffset(); + return t.forEach((B) => { + let U = new g.Vector3(B.x, B.y, B.z); + U.applyMatrix4(this.modelGroup.matrixWorld), this.projector.projectVector(U, this.camera); + let F = this.WIDTH / h * (U.x + 1) / 2 + P.left + T, $ = -(this.HEIGHT / M) * (U.y - 1) / 2 + P.top + R; + z.push({ x: F, y: $ }); + }), a && (z = z[0]), z; + } + /** + * 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(t, a, h) { + var M = t / this.WIDTH, w = a / this.HEIGHT, S = h === void 0 ? this.rotationGroup.position.z : h, T = this.rotationGroup.quaternion, R = new g.Vector3(0, 0, S); + return this.projector.projectVector(R, this.camera), R.x += M * 2, R.y -= w * 2, this.projector.unprojectVector(R, this.camera), R.z = 0, R.applyQuaternion(T), 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(t, a) { + let h = this.canvasOffset(), M = new g.Vector3(a.x, a.y, a.z); + M.applyMatrix4(this.modelGroup.matrixWorld); + let w = M.clone(); + this.projector.projectVector(M, this.camera); + let S = new g.Vector3((t.x - h.left) * 2 / this.WIDTH - 1, (t.y - h.top) * 2 / -this.HEIGHT + 1, M.z); + return this.projector.unprojectVector(S, this.camera), S.distanceTo(w); + } + /** + * Set a callback to call when the view has potentially changed. + * + */ + setViewChangeCallback(t) { + (typeof t == "function" || t == null) && (this.viewChangeCallback = t); + } + /** + * Set a callback to call when the view has potentially changed. + * + */ + setStateChangeCallback(t) { + (typeof t == "function" || t == null) && (this.stateChangeCallback = t); + } + /** + * 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(t) { + this.config = t; + } + /** + * Return object representing internal state of + * the viewer appropriate for passing to setInternalState + * + */ + getInternalState() { + var t = { models: [], surfaces: [], shapes: [], labels: [] }; + for (let a = 0; a < this.models.length; a++) + this.models[a] && (t.models[a] = this.models[a].getInternalState()); + return t; + } + /** + * Overwrite internal state of the viewer with passed object + * which should come from getInternalState. + * + */ + setInternalState(t) { + this.clear(); + var a = t.models; + for (let h = 0; h < a.length; h++) + a[h] && (this.models[h] = new p.GLModel(h), this.models[h].setInternalState(a[h])); + 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(t, a) { + typeof t < "u" && (this.config.lowerZoomLimit = t), a && (this.config.upperZoomLimit = a), 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(t) { + t.fov !== void 0 && (this.fov = t.fov, this.camera.fov = this.fov), t.z !== void 0 && (this.CAMERA_Z = t.z, this.camera.z = this.CAMERA_Z), t.orthographic !== void 0 && (this.camera.ortho = t.orthographic); + } + _handleMouseDown(t) { + if (t.preventDefault(), !this.scene) + return; + var a = this.getX(t), h = this.getY(t); + if (a === void 0) + return; + this.isDragging = !0, this.mouseButton = t.which, this.mouseStartX = a, this.mouseStartY = h, this.touchHold = !0, this.touchDistanceStart = 0, t.targetTouches && t.targetTouches.length == 2 && (this.touchDistanceStart = this.calcTouchDistance(t)), 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() { + t.targetTouches && M.touchHold == !0 && (M.glDOM = M.renderer.domElement, M.glDOM.dispatchEvent(new Event("contextmenu"))); + }, 1e3); + } + _handleMouseUp(t) { + if (this.touchHold = !1, this.isDragging && this.scene) { + var a = this.getX(t), h = this.getY(t); + if (this.closeEnoughForClick(t) && this.isInViewer(a, h)) { + let M = this.mouseXY(a, h); + this.handleClickSelection(M.x, M.y, t); + } + } + this.isDragging = !1; + } + _handleMouseScroll(t) { + if (t.preventDefault(), !!this.scene) { + var a = this.getX(t), h = this.getY(t); + if (a !== void 0 && !(!this.control_all && !this.isInViewer(a, h))) { + var M = (this.CAMERA_Z - this.rotationGroup.position.z) * 0.85, w = 1; + if (t.ctrlKey && (w = -1), t.detail) + this.rotationGroup.position.z += w * M * t.detail / 10; + else if (t.wheelDelta) { + let S = t.wheelDelta * 600 / (t.wheelDelta + 600); + this.rotationGroup.position.z -= w * M * S / 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(t) { + let a = this; + return t = t || 1, new Promise(function(h) { + let M = 0, w = a.viewChangeCallback, S = [], T = [], R = Date.now(); + a.viewChangeCallback = function() { + T.push(Date.now() - R), R = Date.now(), S.push(new Promise((z) => { + a.getCanvas().toBlob(function(P) { + P.arrayBuffer().then(z); + }, "image/png"); + })), M += 1, M == t && (a.viewChangeCallback = w, Promise.all(S).then((z) => { + let P = []; + for (let N = 0; N < z.length; N++) { + let G = (0, D.decode)(z[N]); + P.push((0, D.toRGBA8)(G)[0]); + } + let B = a.getCanvas().width, U = a.getCanvas().height, F = (0, D.encode)(P, B, U, 0, T), $ = new Blob([F], { type: "image/png" }), W = new FileReader(); + W.onload = function(N) { + h(N.target.result); + }, W.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(t) { + this.hoverDuration = t; + } + mouseXY(t, a) { + let h = this.canvasOffset(), M = this.renderer.getXRatio(), w = this.renderer.getYRatio(), S = this.col, T = this.row, R = S * (this.WIDTH / M), z = (w - T - 1) * (this.HEIGHT / w), P = (t - h.left - R) / (this.WIDTH / M) * 2 - 1, B = -((a - h.top - z) / (this.HEIGHT / w)) * 2 + 1; + return { x: P, y: B }; + } + _handleMouseMove(t) { + clearTimeout(this.hoverTimeout), t.preventDefault(); + let a = this.getX(t), h = this.getY(t); + if (a === void 0) + return; + let M = this.renderer.getXRatio(), w = this.renderer.getYRatio(), S = this.mouseXY(a, h), T = this; + this.current_hover !== null && this.handleHoverContinue(S.x, S.y); + var R = 0; + if (!(!this.control_all && !this.isInViewer(a, h)) && this.scene && (this.hoverables.length > 0 && (this.hoverTimeout = setTimeout(function() { + T.handleHoverSelection(S.x, S.y, t); + }, this.hoverDuration)), !!this.isDragging)) { + var z = (a - this.mouseStartX) / this.WIDTH, P = (h - this.mouseStartY) / this.HEIGHT; + if (this.touchDistanceStart != 0 && t.targetTouches && t.targetTouches.length == 2) { + var B = this.calcTouchDistance(t); + R = 2, P = (B - this.touchDistanceStart) * 2 / (this.WIDTH + this.HEIGHT); + } else + t.targetTouches && t.targetTouches.length == 3 && (R = 1); + z *= M, P *= w; + var U = Math.hypot(z, P), F; + if (R == 3 || this.mouseButton == 3 && t.ctrlKey) + this.slabNear = this.cslabNear + z * 100, this.slabFar = this.cslabFar - P * 100; + else if (R == 2 || this.mouseButton == 3 || t.shiftKey) + F = (this.CAMERA_Z - this.rotationGroup.position.z) * 0.85, F < 80 && (F = 80), this.rotationGroup.position.z = this.cz + P * F, this.rotationGroup.position.z = this.adjustZoomToLimits(this.rotationGroup.position.z); + else if (R == 1 || this.mouseButton == 2 || t.ctrlKey) { + var $ = this.screenOffsetToModel(M * (a - this.mouseStartX), w * (h - this.mouseStartY)); + this.modelGroup.position.addVectors(this.currentModelPos, $); + } else if ((R === 0 || this.mouseButton == 1) && U !== 0) { + var W = Math.sin(U * Math.PI) / U; + this.dq.x = Math.cos(U * Math.PI), this.dq.y = 0, this.dq.z = W * z, this.dq.w = -W * P, this.rotationGroup.quaternion.set(1, 0, 0, 0), this.rotationGroup.quaternion.multiply(this.dq), this.rotationGroup.quaternion.multiply(this.cq); + } + this.show(); + } + } + _handleContextMenu(t) { + t.preventDefault(); + var a = this.getX(t), h = this.getY(t); + if (!(a != this.mouseStartX || h != this.mouseStartY)) { + var S = this.mouseStartX, T = this.mouseStartY, w = this.canvasOffset(); + let R = this.mouseXY(S, T), z = R.x, P = R.y, B = this.targetedObjects(z, P, this.contextMenuEnabledAtoms); + var M = null; + B.length && (M = B[0].clickable); + var w = this.canvasOffset(), S = this.mouseStartX - w.left, T = this.mouseStartY - w.top; + this.userContextMenuHandler && this.userContextMenuHandler(M, S, T, B); + } + } + /** + * 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(t) { + let a = (0, x.getElement)(t) || this.container; + return this.initContainer(a), 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(t, a) { + (typeof a > "u" || a < 0 || a > 1) && (a = 1); + var h = _.CC.color(t); + return this.scene.fog.color = h, this.bgColor = h.getHex(), this.renderer.setClearColorHex(h.getHex(), a), 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(t) { + this.camera.ortho = t === "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(t) { + if (t.style === "outline") { + var a = {}; + t.color && (a.color = _.CC.color(t.color)), t.width && (a.width = t.width), this.renderer.enableOutline(a); + } 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(t) { + return this.WIDTH = t || 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(t) { + return this.HEIGHT = t || this.HEIGHT, this.updateSize(), this; + } + /** + * Resize viewer according to containing HTML element's dimensions + * + */ + resize() { + this.WIDTH = this.getWidth(), this.HEIGHT = this.getHeight(); + let t = !1; + if (this.renderer.isLost() && this.WIDTH > 0 && this.HEIGHT > 0) { + let a = !1, h = this.container.querySelector("canvas"); + h && h != this.renderer.getCanvas() ? this.config.canvas = h : (h.remove(), this.config && this.config.canvas != null && (delete this.config.canvas, a = !0)), this.setupRenderer(), this.initContainer(this.container), t = !0, a && (this.config.canvas = this.renderer.getCanvas()); + } + if (this.WIDTH == 0 || this.HEIGHT == 0 ? this.animated && this._viewer.pauseAnimate() : this.animated && this._viewer.resumeAnimate(), this.updateSize(), t) { + let a = this.renderer.supportedExtensions(); + if (a.regen = !0, this.viewers) + for (let h = 0, M = this.viewers.length; h < M; h++) + for (let w = 0, S = this.viewers[h].length; w < S; w++) + this.viewers[h][w].render(null, a); + this._viewer.render(null, a); + } 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(t) { + return t === void 0 ? this.models.length == 0 ? null : this.models[this.models.length - 1] : t instanceof p.GLModel ? t : t in this.models ? this.models[t] : 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(t, a = 1) { + if (clearInterval(this.spinInterval), typeof t > "u" && (t = "y"), typeof t == "boolean") + if (t) + t = "y"; + else + return; + Array.isArray(t) && (t = { x: t[0], y: t[1], z: t[2] }); + var h = this; + this.spinInterval = setInterval(function() { + !h.getCanvas().isConnected && h.renderer.isLost() && clearInterval(h.spinInterval), h.rotate(1 * a, t); + }, 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(t, a, h, M, w, S) { + var T = 20, R = Math.ceil(t / T); + R < 1 && (R = 1), this.incAnim(); + var z = { + mpos: this.modelGroup.position.clone(), + rz: this.rotationGroup.position.z, + rot: this.rotationGroup.quaternion.clone(), + cam: this.lookingAt.clone() + }; + if (a) { + let U = new Array(R); + for (let N = 0; N < R; N++) { + let G = (N + 1) / R, k = { mpos: z.mpos, rz: z.rz, rot: z.rot }; + k.mpos = h.clone().sub(z.mpos).multiplyScalar(G).add(z.mpos), k.rz = z.rz + G * (M - z.rz), k.rot = r.slerp(z.rot, w, G), k.cam = S.clone().sub(z.cam).multiplyScalar(G).add(z.cam), U[N] = k; + } + let F = 0, $ = this, W = function() { + var N = U[F]; + F += 1, $.modelGroup.position = N.mpos, $.rotationGroup.position.z = N.rz, $.rotationGroup.quaternion = N.rot, $.camera.lookAt(N.cam), F < U.length ? setTimeout(W, T) : $.decAnim(), $.show(); + }; + setTimeout(W, T); + } else { + var P = {}; + let U = 1 / R; + if (h && (P.mpos = h.clone().sub(z.mpos).multiplyScalar(U)), typeof M < "u" && M != null && (P.rz = U * (M - z.rz)), w) { + var B = r.slerp(z.rot, w, U); + P.rot = z.rot.clone().inverse().multiply(B); + } + S && (P.cam = S.clone().sub(z.cam).multiplyScalar(U)); + let F = 0, $ = this, W = function() { + F += 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)), F < R ? setTimeout(W, T) : $.decAnim(), $.show(); + }; + setTimeout(W, T); + } + } + /** + * 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(t, a = "y", h = 0, M = !1) { + if (a == "x" ? a = { x: 1, y: 0, z: 0 } : a == "y" ? a = { x: 0, y: 1, z: 0 } : a == "z" && (a = { x: 0, y: 0, z: 1 }), a == "vx" ? a = { vx: 1, vy: 0, vz: 0 } : a == "vy" ? a = { vx: 0, vy: 1, vz: 0 } : a == "vz" && (a = { vx: 0, vy: 0, vz: 1 }), typeof a.vx < "u") { + var w = new g.Vector3(a.vx, a.vy, a.vz); + w.applyQuaternion(this.rotationGroup.quaternion), a = { x: w.x, y: w.y, z: w.z }; + } + var S = function(P) { + var B = Math.sin(P / 2), U = Math.cos(P / 2), F = 0, $ = 0, W = 0; + return F = a.x * B, $ = a.y * B, W = a.z * B, new g.Quaternion(F, $, W, U).normalize(); + }, T = Math.PI * t / 180, R = S(T); + if (h) { + var z = new g.Quaternion().copy(this.rotationGroup.quaternion).multiply(R); + this.animateMotion(h, M, this.modelGroup.position, this.rotationGroup.position.z, z, this.lookingAt); + } else + this.rotationGroup.quaternion.multiply(R), this.show(); + return this; + } + surfacesFinished() { + for (var t in this.surfaces) + if (!this.surfaces[t][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 t = this.modelGroup.position, a = this.rotationGroup.quaternion; + return [ + t.x, + t.y, + t.z, + this.rotationGroup.position.z, + a.x, + a.y, + a.z, + a.w + ]; + } + /** Sets the view to the specified translation, zoom, and rotation. + * + * @param {Array.} arg Array formatted identically to the return value of getView */ + setView(t, a) { + return t === void 0 || !(t instanceof Array || t.length !== 8) ? this : !this.modelGroup || !this.rotationGroup ? this : (this.modelGroup.position.x = t[0], this.modelGroup.position.y = t[1], this.modelGroup.position.z = t[2], this.rotationGroup.position.z = t[3], this.rotationGroup.quaternion.x = t[4], this.rotationGroup.quaternion.y = t[5], this.rotationGroup.quaternion.z = t[6], this.rotationGroup.quaternion.w = t[7], typeof t[8] < "u" && (this.rotationGroup.position.x = t[8], this.rotationGroup.position.y = t[9]), this.show(a), this); + } + // apply styles, models, etc in viewer + /** + * Render current state of viewer, after + * adding/removing models, applying styles, etc. + * + */ + render(t, a) { + this.renderer.setViewport(), this.updateClickables(); + var h = this.getView(); + this.stateChangeCallback && this.stateChangeCallback(this.getInternalState()); + var M, w; + for (a || (a = this.renderer.supportedExtensions()), M = 0; M < this.models.length; M++) + this.models[M] && this.models[M].globj(this.modelGroup, a); + 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, a) : this.shapes[M].removegl(this.modelGroup)); + for (M = 0; M < this.labels.length; M++) + a.regen && (this.labels[M].dispose(), this.modelGroup.remove(this.labels[M].sprite), this.labels[M].setContext(), this.modelGroup.add(this.labels[M].sprite)), 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 S = this.surfaces[M]; + for (w = 0; w < S.length; w++) + if (S.hasOwnProperty(w)) { + var T = S[w].geo; + if (!S[w].finished || a.regen) { + T.verticesNeedUpdate = !0, T.elementsNeedUpdate = !0, T.normalsNeedUpdate = !0, T.colorsNeedUpdate = !0, T.buffersNeedUpdate = !0, T.boundingSphere = null, S[w].mat.needsUpdate = !0, S[w].done && (S[w].finished = !0), S[w].lastGL && this.modelGroup.remove(S[w].lastGL); + var R = null; + if (S[w].mat instanceof l.LineBasicMaterial ? R = new l.Line(T, S[w].mat) : R = new l.Mesh(T, S[w].mat), S[w].mat.transparent && S[w].mat.opacity == 0 ? R.visible = !1 : R.visible = !0, S[w].symmetries.length > 1 || S[w].symmetries.length == 1 && !S[w].symmetries[w].isIdentity()) { + var z, P = new l.Object3D(); + for (z = 0; z < S[w].symmetries.length; z++) { + var B = R.clone(); + B.matrix = S[w].symmetries[z], B.matrixAutoUpdate = !1, P.add(B); + } + S[w].lastGL = P, this.modelGroup.add(P); + } else + S[w].lastGL = R, this.modelGroup.add(R); + } + } + } + return this.setView(h), typeof t == "function" && t(this), this; + } + /* @param {AtomSelectionSpec|any} sel + * @return list of models specified by sel + */ + getModelList(t) { + let a = []; + if (typeof t > "u" || typeof t.model > "u") + for (let M = 0; M < this.models.length; M++) + this.models[M] && a.push(this.models[M]); + else { + let M = t.model; + Array.isArray(M) || (M = [M]); + for (let w = 0; w < M.length; w++) + if (typeof M[w] == "number") { + var h = M[w]; + h < 0 && (h += this.models.length), a.push(this.models[h]); + } else + a.push(M[w]); + } + return a; + } + /** + * + * @param {AtomSelectionSpec} + * sel + * @return {AtomSpec[]} + */ + getAtomsFromSel(t) { + var a = []; + typeof t > "u" && (t = {}); + var h = this.getModelList(t); + for (let M = 0; M < h.length; M++) + a = a.concat(h[M].selectedAtoms(t)); + return a; + } + /** + * + * @param {AtomSpec} + * atom + * @param {AtomSelectionSpec} + * sel + * @return {boolean} + */ + atomIsSelected(t, a) { + typeof a > "u" && (a = {}); + for (var h = this.getModelList(a), M = 0; M < h.length; M++) + if (h[M].atomIsSelected(t, a)) + return !0; + return !1; + } + /** return list of atoms selected by sel + * + * @param {AtomSelectionSpec} sel + * @return {AtomSpec[]} + */ + selectedAtoms(t) { + return this.getAtomsFromSel(t); + } + /** + * Returns valid values for the specified attribute in the given selection + * @param {string} attribute + * @param {AtomSelectionSpec} sel + * @return {Array.} + * + */ + getUniqueValues(t, a) { + typeof a > "u" && (a = {}); + var h = this.getAtomsFromSel(a), M = {}; + for (var w in h) + if (h[w].hasOwnProperty(t)) { + var S = h[w][t]; + M[S] = !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(t) { + for (var a = this.getAtomsFromSel(t), h = "", M = 0, w = a.length; M < w; ++M) + h += a[M].pdbline + ` +`; + return h; + } + /** + * 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(t = 2, a = 0, h = !1) { + var M = (this.CAMERA_Z - this.rotationGroup.position.z) / t, w = this.CAMERA_Z - M; + return a > 0 ? this.animateMotion(a, h, this.modelGroup.position, this.adjustZoomToLimits(w), this.rotationGroup.quaternion, this.lookingAt) : (this.rotationGroup.position.z = this.adjustZoomToLimits(w), 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(t, a, h = 0, M = !1) { + var w = t / this.WIDTH, S = a / this.HEIGHT, T = new g.Vector3(0, 0, -this.CAMERA_Z); + this.projector.projectVector(T, this.camera), T.x -= w, T.y -= S, this.projector.unprojectVector(T, this.camera), T.z = 0; + var R = this.lookingAt.clone().add(T); + return h > 0 ? this.animateMotion(h, 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(t, a, h = 0, M = !1) { + var w = this.screenOffsetToModel(t, a), S = this.modelGroup.position.clone().add(w); + return h > 0 ? this.animateMotion(h, M, this.modelGroup.position, this.rotationGroup.position.z, this.rotationGroup.quaternion, this.lookingAt) : (this.modelGroup.position = S, 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(t) { + t = t || {}; + var a = this.getAtomsFromSel(t), h = (0, x.getExtent)(a), M = h[1][0] - h[0][0], w = h[1][1] - h[0][1], S = h[1][2] - h[0][2], T = Math.hypot(M, w, S); + return T < 5 && (T = 5), this.slabNear = -T / 1.9, this.slabFar = T / 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(t = {}, a = 0, h = !1) { + var M, w, S = this.getAtomsFromSel(t), T = (0, x.getExtent)(S); + (0, x.isEmptyObject)(t) ? (this.shapes.forEach((G) => { + if (G && G.boundingSphere && G.boundingSphere.center) { + var k = G.boundingSphere.center, j = G.boundingSphere.radius; + j > 0 ? (S.push(new g.Vector3(k.x + j, k.y, k.z)), S.push(new g.Vector3(k.x - j, k.y, k.z)), S.push(new g.Vector3(k.x, k.y + j, k.z)), S.push(new g.Vector3(k.x, k.y - j, k.z)), S.push(new g.Vector3(k.x, k.y, k.z + j)), S.push(new g.Vector3(k.x, k.y, k.z - j))) : S.push(k); + } + }), T = (0, x.getExtent)(S), M = S, w = T) : (M = this.getAtomsFromSel({}), w = (0, x.getExtent)(M)); + var R = new g.Vector3(T[2][0], T[2][1], T[2][2]), z = w[1][0] - w[0][0], P = w[1][1] - w[0][1], B = w[1][2] - w[0][2], U = Math.hypot(z, P, B); + U < 5 && (U = 5), this.slabNear = -U / 1.9, this.slabFar = U / 2, z = T[1][0] - T[0][0], P = T[1][1] - T[0][1], B = T[1][2] - T[0][2], U = Math.hypot(z, P, B), U < 5 && (U = 5); + for (var F = 25, $ = 0; $ < S.length; $++) + if (S[$]) { + var W = R.distanceToSquared(S[$]); + W > F && (F = W); + } + U = Math.sqrt(F) * 2; + var N = R.clone().multiplyScalar(-1); + return a > 0 ? this.animateMotion(a, h, N, this.rotationGroup.position.z, this.rotationGroup.quaternion, this.lookingAt) : (this.modelGroup.position = N, 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(t = {}, a = 0, h = !1) { + let M = this.getAtomsFromSel(t), w = (0, x.getExtent)(M), S = w; + if ((0, x.isEmptyObject)(t)) { + let k = M && M.length; + if (this.shapes.forEach((j) => { + if (j && j.boundingSphere) { + if (j.boundingSphere.box) { + let pe = j.boundingSphere.box; + M.push(new g.Vector3(pe.min.x, pe.min.y, pe.min.z)), M.push(new g.Vector3(pe.max.x, pe.max.y, pe.max.z)); + } else if (j.boundingSphere.center) { + var Q = j.boundingSphere.center, ie = j.boundingSphere.radius; + ie > 0 ? (M.push(new g.Vector3(Q.x + ie, Q.y, Q.z)), M.push(new g.Vector3(Q.x - ie, Q.y, Q.z)), M.push(new g.Vector3(Q.x, Q.y + ie, Q.z)), M.push(new g.Vector3(Q.x, Q.y - ie, Q.z)), M.push(new g.Vector3(Q.x, Q.y, Q.z + ie)), M.push(new g.Vector3(Q.x, Q.y, Q.z - ie))) : M.push(Q); + } + } + }), S = (0, x.getExtent)(M), !k) + for (let j = 0; j < 3; j++) + w[2][j] = (S[0][j] + S[1][j]) / 2; + } else { + let k = this.getAtomsFromSel({}); + S = (0, x.getExtent)(k); + } + var T = new g.Vector3(w[2][0], w[2][1], w[2][2]), R = S[1][0] - S[0][0], z = S[1][1] - S[0][1], P = S[1][2] - S[0][2], B = Math.hypot(R, z, P); + B < 5 && (B = 5), this.slabNear = -B / 1.9, this.slabFar = B / 2, Object.keys(t).length === 0 && (this.slabNear = Math.min(-B * 2, -50), this.slabFar = Math.max(B * 2, 50)); + var U = this.config.minimumZoomToDistance || 5; + R = w[1][0] - w[0][0], z = w[1][1] - w[0][1], P = w[1][2] - w[0][2], B = Math.hypot(R, z, P), B < U && (B = U); + for (var F = U * U, $ = 0; $ < M.length; $++) + if (M[$]) { + var W = T.distanceToSquared(M[$]); + W > F && (F = W); + } + B = Math.sqrt(F) * 2; + var N = T.clone().multiplyScalar(-1), G = -(B * 0.5 / Math.tan(Math.PI / 180 * this.camera.fov / 2) - this.CAMERA_Z); + return G = this.adjustZoomToLimits(G), a > 0 ? this.animateMotion(a, h, N, G, this.rotationGroup.quaternion, this.lookingAt) : (this.modelGroup.position = N, this.rotationGroup.position.z = G, 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(t, a) { + this.slabNear = t, this.slabFar = a; + } + /** + * 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(t, a = {}, h, M = !1) { + if (h) { + var w = (0, x.getExtent)(this.getAtomsFromSel(h)); + a.position = { x: w[2][0], y: w[2][1], z: w[2][2] }; + } + var S = new E.Label(t, a); + return S.setContext(), this.modelGroup.add(S.sprite), this.labels.push(S), M || this.show(), S; + } + /** 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(t, a, h = !1) { + let M = this.labels.length; + return this.applyToModels("addResLabels", t, this, a, h), 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(t, a, h) { + return this.applyToModels("addPropertyLabels", t, a, this, h), 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(t) { + for (var a = 0; a < this.labels.length; a++) + if (this.labels[a] == t) { + this.labels.splice(a, 1), t.dispose(), this.modelGroup.remove(t.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 t = 0; t < this.labels.length; t++) + this.labels[t] && this.labels[t].sprite && this.modelGroup.remove(this.labels[t].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(t, a) { + return this.modelGroup.remove(t.sprite), t.dispose(), t.stylespec = a, t.setContext(), this.modelGroup.add(t.sprite), this.show(), t; + } + // Change label text + /** + * Modify existing label's text + * + * @param {Label} label - $3Dmol label + * @param {String} + * text - Label text + * @return {Label} + */ + setLabelText(t, a) { + return this.modelGroup.remove(t.sprite), t.dispose(), t.text = a, t.setContext(), this.modelGroup.add(t.sprite), this.show(), t; + } + /** + * Add shape object to viewer + * @see {GLShape} + * + * @param {ShapeSpec} shapeSpec - style specification for label + * @return {GLShape} + */ + addShape(t) { + t = t || {}; + var a = new u.GLShape(t); + return a.shapePosition = this.shapes.length, this.shapes.push(a), a; + } + /** + * Remove shape object from viewer + * + * @param {GLShape} shape - Reference to shape object to remove + */ + removeShape(t) { + if (!t) + return this; + for (t.removegl(this.modelGroup), delete this.shapes[t.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 t = 0; t < this.shapes.length; t++) { + var a = this.shapes[t]; + a && a.removegl(this.modelGroup); + } + return this.shapes.splice(0, this.shapes.length), this; + } + //gets the center of the selection + getSelectionCenter(t) { + if (t.hasOwnProperty("x") && t.hasOwnProperty("y") && t.hasOwnProperty("z")) + return t; + var a = this.getAtomsFromSel(t); + if (a.length == 0) + return { x: 0, y: 0, z: 0 }; + var h = (0, x.getExtent)(a); + return { x: h[0][0] + (h[1][0] - h[0][0]) / 2, y: h[0][1] + (h[1][1] - h[0][1]) / 2, z: h[0][2] + (h[1][2] - h[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(t) { + t = t || {}, t.center = this.getSelectionCenter(t.center); + var a = new u.GLShape(t); + return a.shapePosition = this.shapes.length, a.addSphere(t), this.shapes.push(a), a.finalize(), a; + } + /** + * 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(t = {}) { + t.corner != null && (t.corner = this.getSelectionCenter(t.corner)), t.center != null && (t.center = this.getSelectionCenter(t.center)); + var a = new u.GLShape(t); + return a.shapePosition = this.shapes.length, a.addBox(t), this.shapes.push(a), a.finalize(), a; + } + /** + * 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(t = {}) { + t.start = this.getSelectionCenter(t.start), t.end = this.getSelectionCenter(t.end); + var a = new u.GLShape(t); + return a.shapePosition = this.shapes.length, a.addArrow(t), this.shapes.push(a), a.finalize(), a; + } + /** + * 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(t = {}) { + t.start = this.getSelectionCenter(t.start), t.end = this.getSelectionCenter(t.end); + var a = new u.GLShape(t); + return a.shapePosition = this.shapes.length, t.dashed ? a.addDashedCylinder(t) : a.addCylinder(t), this.shapes.push(a), a.finalize(), a; + } + /** + * 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(t = {}) { + var a = new u.GLShape(t); + return a.shapePosition = this.shapes.length, a.addCurve(t), this.shapes.push(a), a.finalize(), a; + } + /** + * 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(t = {}) { + t.start = this.getSelectionCenter(t.start), t.end = this.getSelectionCenter(t.end), t.wireframe = !0; + var a = new u.GLShape(t); + return a.shapePosition = this.shapes.length, t.dashed ? a = this.addLineDashed(t, a) : a.addLine(t), this.shapes.push(a), a.finalize(), a; + } + /** + * 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(t, a) { + t = this.getModel(t), a = a || { alabel: "a", blabel: "b", clabel: "c" }, a.box = a.box || {}, a.astyle = a.astyle || { color: "red", radius: 0.1, midpos: -1 }, a.bstyle = a.bstyle || { color: "green", radius: 0.1, midpos: -1 }, a.cstyle = a.cstyle || { color: "blue", radius: 0.1, midpos: -1 }, a.alabelstyle = a.alabelstyle || { fontColor: "red", showBackground: !1, alignment: "center", inFront: !1 }, a.blabelstyle = a.blabelstyle || { fontColor: "green", showBackground: !1, alignment: "center", inFront: !1 }, a.clabelstyle = a.clabelstyle || { fontColor: "blue", showBackground: !1, alignment: "center", inFront: !1 }, t.unitCellObjects && this.removeUnitCell(t), t.unitCellObjects = { shapes: [], labels: [] }; + var h = t.getCrystData(), M = null; + if (h) { + if (h.matrix) + M = h.matrix; + else { + var w = h.a, S = h.b, T = h.c, R = h.alpha, z = h.beta, P = h.gamma; + R = R * Math.PI / 180, z = z * Math.PI / 180, P = P * Math.PI / 180; + var B, U, F; + B = Math.cos(z), U = (Math.cos(R) - Math.cos(z) * Math.cos(P)) / Math.sin(P), F = Math.sqrt(Math.max(0, 1 - B * B - U * U)), M = new g.Matrix3(w, S * Math.cos(P), T * B, 0, S * Math.sin(P), T * U, 0, 0, T * F); + } + var $ = [ + new g.Vector3(0, 0, 0), + new g.Vector3(1, 0, 0), + new g.Vector3(0, 1, 0), + new g.Vector3(0, 0, 1), + new g.Vector3(1, 1, 0), + new g.Vector3(0, 1, 1), + new g.Vector3(1, 0, 1), + new g.Vector3(1, 1, 1) + ]; + if (h.matrix4) + for (let N = 0; N < $.length; N++) + h.size && $[N].multiplyVectors($[N], h.size), $[N] = $[N].applyMatrix4(h.matrix4); + else + for (let N = 0; N < $.length; N++) + $[N] = $[N].applyMatrix3(M); + if (a.box && !a.box.hidden) { + a.box.wireframe = !0; + var W = new u.GLShape(a.box); + W.shapePosition = this.shapes.length, W.addLine({ start: $[0], end: $[1] }), W.addLine({ start: $[0], end: $[2] }), W.addLine({ start: $[1], end: $[4] }), W.addLine({ start: $[2], end: $[4] }), W.addLine({ start: $[0], end: $[3] }), W.addLine({ start: $[3], end: $[5] }), W.addLine({ start: $[2], end: $[5] }), W.addLine({ start: $[1], end: $[6] }), W.addLine({ start: $[4], end: $[7] }), W.addLine({ start: $[6], end: $[7] }), W.addLine({ start: $[3], end: $[6] }), W.addLine({ start: $[5], end: $[7] }), this.shapes.push(W), t.unitCellObjects.shapes.push(W), W.finalize(); + } + if (!a.astyle.hidden) { + a.astyle.start = $[0], a.astyle.end = $[1]; + let N = this.addArrow(a.astyle); + t.unitCellObjects.shapes.push(N); + } + if (!a.bstyle.hidden) { + a.bstyle.start = $[0], a.bstyle.end = $[2]; + let N = this.addArrow(a.bstyle); + t.unitCellObjects.shapes.push(N); + } + if (!a.cstyle.hidden) { + a.cstyle.start = $[0], a.cstyle.end = $[3]; + let N = this.addArrow(a.cstyle); + t.unitCellObjects.shapes.push(N); + } + if (a.alabel) { + a.alabelstyle.position = $[1]; + let N = this.addLabel(a.alabel, a.alabelstyle); + t.unitCellObjects.labels.push(N); + } + if (a.blabel) { + a.blabelstyle.position = $[2]; + let N = this.addLabel(a.blabel, a.blabelstyle); + t.unitCellObjects.labels.push(N); + } + if (a.clabel) { + a.clabelstyle.position = $[3]; + let N = this.addLabel(a.clabel, a.clabelstyle); + t.unitCellObjects.labels.push(N); + } + } + } + /** + * 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(t) { + if (t = this.getModel(t), t.unitCellObjects) { + let a = this; + t.unitCellObjects.shapes.forEach(function(h) { + a.removeShape(h); + }), t.unitCellObjects.labels.forEach(function(h) { + a.removeLabel(h); + }); + } + delete t.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. + * @param {boolean} prune - Keep only atoms that are within the original unit cell (i.e., on edges). Alternatively, call replicateUnitCell(1). + @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(t = 3, a = t, h = a, M, w, S) { + M = this.getModel(M); + let T = M.getCrystData(); + if (T) { + const R = M.selectedAtoms({}), z = T.matrix; + let P = function(U) { + return U % 2 == 0 ? -U / 2 : Math.ceil(U / 2); + }; + t <= 1 && a <= 1 && h <= 1 && (S = !0, t = a = h = 3); + let B = function(U, F, $) { + return !1; + }; + if (S) { + const U = new g.Matrix3().getInverse3(z); + B = function(F, $, W) { + let N = new g.Vector3(F, $, W).applyMatrix3(U); + return !(N.x > -1e-4 && N.x < 1.0001 && N.y > -1e-4 && N.y < 1.0001 && N.z > -1e-4 && N.z < 1.0001); + }; + } + for (let U = 0; U < t; U++) + for (let F = 0; F < a; F++) + for (let $ = 0; $ < h; $++) { + if (U == 0 && F == 0 && $ == 0) + continue; + let W = new g.Vector3(P(U), P(F), P($)); + W.applyMatrix3(z); + let N = []; + for (let G = 0; G < R.length; G++) { + let k = R[G].x + W.x, j = R[G].y + W.y, Q = R[G].z + W.z; + if (B(k, j, Q)) + continue; + let ie = {}; + for (let pe in R[G]) + ie[pe] = R[G][pe]; + ie.x = k, ie.y = j, ie.z = Q, N.push(ie); + } + M.addAtoms(N); + } + w && M.assignBonds(); + } + } + /** Add dashed line to shape */ + addLineDashed(t, a) { + t.dashLength = t.dashLength || 0.5, t.gapLength = t.gapLength || 0.5; + var h; + t.start ? h = new g.Vector3(t.start.x || 0, t.start.y || 0, t.start.z || 0) : h = new g.Vector3(0, 0, 0); + var M; + t.end ? M = new g.Vector3(t.end.x, t.end.y || 0, t.end.z || 0) : M = new g.Vector3(0, 0, 0); + var w = new g.Vector3(), S = new g.Vector3(), T = new g.Vector3(), R, z, P, B = h.clone(), U = 0; + for (w.subVectors(M, h), R = w.length(), w.normalize(), S = w.clone(), T = w.clone(), S.multiplyScalar(t.dashLength), T.multiplyScalar(t.gapLength), z = S.length(), P = T.length(); U < R; ) { + if (U + z > R) { + t.start = h, t.end = M, a.addLine(t); + break; + } + B.addVectors(h, S), t.start = h, t.end = B, a.addLine(t), h = B.clone(), U += z, B.addVectors(h, T), h = B.clone(), U += P; + } + return a.finalize(), a; + } + /** + * 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(t) { + t = t || {}; + var a = new u.GLShape(t); + return a.shapePosition = this.shapes.length, a.addCustom(t), this.shapes.push(a), a.finalize(), a; + } + /** + * 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(t, a, h = {}) { + var M = new A.VolumeData(t, a); + return h.hasOwnProperty("transferfn") ? this.addVolumetricRender(M, h) : this.addIsosurface(M, h); + } + /** + * 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(t, a = {}, h) { + var M = new u.GLShape(a); + return M.shapePosition = this.shapes.length, M.addIsosurface(t, a, h), 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(t, a) { + a = a || {}; + var h = new L.GLVolumetricRender(t, a); + return h.shapePosition = this.shapes.length, this.shapes.push(h), h; + } + /** + * 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(t) { + t ? this.scene.fog = new l.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(t) { + this.viewer_frame = t; + let a = this; + return new Promise(function(h) { + var M = a.models.map(function(w) { + return w.setFrame(t, a); + }); + Promise.all(M).then(function() { + h(); + }); + }); + } + /** + * 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 t = 0; + for (let a = 0; a < this.models.length; a++) + this.models[a].getNumFrames() > t && (t = this.models[a].getNumFrames()); + for (let a = 0; a < this.shapes.length; a++) + this.shapes[a].frame && this.shapes[a].frame >= t && (t = this.shapes[a].frame + 1); + for (let a = 0; a < this.labels.length; a++) + this.labels[a].frame && this.labels[a].frame >= t && (t = this.labels[a].frame + 1); + return t; + } + /** + * 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(t) { + this.incAnim(); + var a = 100, h = "forward", M = 0; + t = t || {}, t.interval && (a = t.interval), t.loop && (h = t.loop), t.reps && (M = t.reps); + var w = this.getNumFrames(), S = this, T = 0; + t.startFrame && (T = t.startFrame % w); + var R = 1; + t.step && (R = t.step, M /= R); + var z = 0, P = w * M, B = /* @__PURE__ */ new Date(), U, F, $ = function(W) { + B = /* @__PURE__ */ new Date(), W == "forward" ? S.setFrame(T).then(function() { + T = (T + R) % w, U(); + }) : W == "backward" ? S.setFrame(w - 1 - T).then(function() { + T = (T + R) % w, U(); + }) : S.setFrame(T).then(function() { + T += R, R *= T % (w - 1) == 0 ? -1 : 1, U(); + }); + }; + return U = function() { + if (S.render(), !S.getCanvas().isConnected) + S.stopAnimate(); + else if (++z == P || !S.isAnimated()) + F.cancel(), S.animationTimers.delete(F), S.decAnim(); + else { + var W = a - ((/* @__PURE__ */ new Date()).getTime() - B.getTime()); + W = W > 0 ? W : 0, S.animationTimers.delete(F), F = new x.PausableTimer($, W, h), S.animationTimers.add(F); + } + }, F = new x.PausableTimer($, 0, h), this.animationTimers.add(F), this; + } + /** + * Stop animation of all models in viewer + */ + stopAnimate() { + return this.animated = 0, this.animationTimers.forEach(function(t) { + t.cancel(); + }), this.animationTimers = /* @__PURE__ */ new Set(), this; + } + /** + * Pause animation of all models in viewer + */ + pauseAnimate() { + return this.animationTimers.forEach(function(t) { + t.pause(); + }), this; + } + /** + * Resume animation of all models in viewer + */ + resumeAnimate() { + return this.animationTimers.forEach(function(t) { + t.resume(); + }), this; + } + /** + * Return true if viewer is currently being animated, false otherwise + * @return {boolean} + */ + isAnimated() { + return this.animated > 0; + } + //setup options dict + getModelOpt(t) { + return t && !t.defaultcolors ? (t.defaultcolors = this.defaultcolors, t.cartoonQuality = t.cartoonQuality || this.config.cartoonQuality) : typeof t > "u" && (t = { defaultcolors: this.defaultcolors, cartoonQuality: this.config.cartoonQuality }), t; + } + /** + * 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(t, a = "", h) { + h = this.getModelOpt(h); + var M = new p.GLModel(this.models.length, h); + return M.addMolData(t, a, h), 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(t, a, h) { + h = this.getModelOpt(h), h.multimodel = !0, h.frames = !0; + for (var M = p.GLModel.parseMolData(t, a, h), w = 0; w < M.length; w++) { + var S = new p.GLModel(this.models.length, h); + S.setAtomDefaults(M[w]), S.addFrame(M[w]), S.setFrame(0), M.modelData && S.setModelData(M.modelData[w]), S.setDontDuplicateAtoms(!h.duplicateAssemblyAtoms), this.models.push(S); + } + 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(t, a, h) { + h = this.getModelOpt(h), h.multimodel = !0, h.frames = !0; + var M = new p.GLModel(this.models.length, h); + return M.addMolData(t, a, h), 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(t, a, h) { + h = this.getModelOpt(h), h.multimodel = !0, h.onemol = !0; + var M = new p.GLModel(this.models.length, h); + return M.addMolData(t, a, h), this.models.push(M), M; + } + /** + * Delete specified model from viewer + * + * @param {GLModel|number} model + */ + removeModel(t) { + if (t = this.getModel(t), !!t) { + for (t.removegl(this.modelGroup), delete this.models[t.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 t = 0; t < this.models.length; t++) { + var a = this.models[t]; + a && a.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(t, a) { + var h = {}; + return a === void 0 ? h.m = this.models.map(function(M) { + return M.toCDObject(t); + }) : h.m = [this.models[a].toCDObject()], JSON.stringify(h); + } + /** return a VRML string representation of the scene. Include VRML header information + * @return VRML + */ + exportVRML() { + var t = this.modelGroup; + this.applyToModels("removegl", this.modelGroup), this.modelGroup = new l.Object3D(), this.render(null, { supportsImposters: !1, supportsAIA: !1, regen: !0 }); + var a = `#VRML V2.0 utf8 +` + this.modelGroup.vrml() + ` +`; + return this.applyToModels("removegl", this.modelGroup), this.modelGroup = t, a; + } + /** + * 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(t, a = !1) { + for (var h = new p.GLModel(this.models.length, this.defaultcolors), M = 0; M < this.models.length; M++) + if (this.models[M]) { + var w = this.models[M].selectedAtoms(t); + h.addAtoms(w), a && this.models[M].removeAtoms(w); + } + return this.models.push(h), h; + } + applyToModels(t, a, h, M, w, S, T) { + for (var R = this.getModelList(a), z = 0; z < R.length; z++) + R[z][t](a, h, M, w, S, T); + } + setStyle(t, a) { + return typeof a > "u" && (a = t, t = {}), this.applyToModels("setStyle", t, a, !1), this; + } + addStyle(t, a) { + return typeof a > "u" && (a = t, t = {}), this.applyToModels("setStyle", t, a, !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(t, a, h) { + return this.applyToModels("setClickable", t, a, h), 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(t, a, h, M) { + return this.applyToModels("setHoverable", t, a, h, 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(t, a) { + return this.applyToModels("enableContextMenu", t, a), 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(t, a, h, M) { + return this.applyToModels("vibrate", t, a, h, this, M), this; + } + /** + * @param {AtomSelectionSpec} sel + * @param {string} prop + * @param {Gradient|string} scheme + * @param {object} range + */ + setColorByProperty(t, a, h, M) { + return this.applyToModels("setColorByProperty", t, a, h, M), this; + } + /** + * @param {AtomSelectionSpec} sel + * @param {object} colors + */ + setColorByElement(t, a) { + return this.applyToModels("setColorByElement", t, a), this; + } + /** + * + * @param {AtomSpec[]} atomlist + * @param {Array} + * extent + * @return {Array} + */ + static getAtomsWithin(t, a) { + var h = []; + for (let w = 0; w < t.length; w++) { + var M = t[w]; + typeof M > "u" || M.x < a[0][0] || M.x > a[1][0] || M.y < a[0][1] || M.y > a[1][1] || M.z < a[0][2] || M.z > a[1][2] || h.push(M); + } + return h; + } + // return volume of extent + static volume(t) { + var a = t[1][0] - t[0][0], h = t[1][1] - t[0][1], M = t[1][2] - t[0][2]; + return a * h * 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(t, a, h) { + let M = [], w = {}; + for (let B = 0, U = a.length; B < U; B++) + w[a[B].index] = B; + let S = function(B) { + let U = []; + for (let F = 0, $ = B.length; F < $; F++) + B[F].index in w && U.push(w[B[F].index]); + return U; + }, T = function(B) { + let U = []; + return U[0] = [B[0][0], B[0][1], B[0][2]], U[1] = [B[1][0], B[1][1], B[1][2]], U; + }, R = function(B) { + if (r.volume(B) < r.maxVolume) + return [B]; + var U = B[1][0] - B[0][0], F = B[1][1] - B[0][1], $ = B[1][2] - B[0][2], W; + U > F && U > $ ? W = 0 : F > U && F > $ ? W = 1 : W = 2; + var N = T(B), G = T(B), k = (B[1][W] - B[0][W]) / 2 + B[0][W]; + N[1][W] = k, G[0][W] = k; + var j = R(N), Q = R(G); + return j.concat(Q); + }, z = R(t), P = 6; + for (let B = 0, U = z.length; B < U; B++) { + let F = T(z[B]); + F[0][0] -= P, F[0][1] -= P, F[0][2] -= P, F[1][0] += P, F[1][1] += P, F[1][2] += P; + let $ = r.getAtomsWithin(a, F), W = r.getAtomsWithin(h, z[B]); + M.push({ + extent: z[B], + atoms: S($), + toshow: S(W) + }); + } + 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(t, a, h) { + var M = new l.Geometry(!0), w = M.updateGeoGroup(0), S = []; + for (let xe = 0, Ie = t.length; xe < Ie; xe++) { + var T = t[xe]; + T && (typeof T.surfaceColor < "u" ? S[xe] = T.surfaceColor : T.color && (S[xe] = _.CC.color(T.color))); + } + var R = w.vertexArray, z = a.vertices; + for (let xe = 0, Ie = z.length; xe < Ie; xe++) { + let oe = w.vertices * 3; + R[oe] = z[xe].x, R[oe + 1] = z[xe].y, R[oe + 2] = z[xe].z, w.vertices++; + } + var P = w.colorArray; + if (h.voldata && h.volscheme) { + var B = h.volscheme, U = h.voldata, F = B.range() || [-1, 1]; + for (let xe = 0, Ie = z.length; xe < Ie; xe++) { + let oe = U.getVal(z[xe].x, z[xe].y, z[xe].z), ve = _.CC.color(B.valueToHex(oe, F)), re = xe * 3; + P[re] = ve.r, P[re + 1] = ve.g, P[re + 2] = ve.b; + } + } else if (S.length > 0) + for (let xe = 0, Ie = z.length; xe < Ie; xe++) { + let oe = z[xe].atomid, ve = xe * 3; + P[ve] = S[oe].r, P[ve + 1] = S[oe].g, P[ve + 2] = S[oe].b; + } + var $ = a.faces; + w.faceidx = $.length, M.initTypedArrays(); + var W = w.vertexArray, N = w.normalArray, G, k, j, Q; + for (let xe = 0, Ie = $.length; xe < Ie; xe += 3) { + var ie = $[xe], pe = $[xe + 1], he = $[xe + 2], ue = ie * 3, se = pe * 3, ae = he * 3; + G = new g.Vector3(W[ue], W[ue + 1], W[ue + 2]), k = new g.Vector3(W[se], W[se + 1], W[se + 2]), j = new g.Vector3(W[ae], W[ae + 1], W[ae + 2]), j.subVectors(j, k), G.subVectors(G, k), j.cross(G), Q = j, Q.normalize(), N[ue] += Q.x, N[se] += Q.x, N[ae] += Q.x, N[ue + 1] += Q.y, N[se + 1] += Q.y, N[ae + 1] += Q.y, N[ue + 2] += Q.z, N[se + 2] += Q.z, N[ae + 2] += Q.z; + } + w.faceArray = new Uint16Array($); + var we = new l.Mesh(M, h); + return we; + } + // 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(t, a, h, M, w, S) { + var T = new C.ProteinSurface(); + return T.initparm(a, t !== 1, S), T.fillvoxels(w, h), T.buildboundary(), (t == C.SurfaceType.SES || t == C.SurfaceType.MS) && (T.fastdistancemap(), T.boundingatom(!1), T.fillvoxelswaals(w, h)), T.marchingcube(t), T.getFacesAndVertices(M); + } + /* + * + * @param {SurfaceStyleSpec} + * style + * @return {MeshLambertMaterial} + */ + static getMatWithStyle(t) { + var a = new l.MeshLambertMaterial(); + a.vertexColors = l.Coloring.VertexColors; + for (var h in t) + h === "color" || h === "map" || t.hasOwnProperty(h) && (a[h] = t[h]); + return t.opacity !== void 0 && (t.opacity === 1 ? a.transparent = !1 : a.transparent = !0), a; + } + /** + * Adds an explicit mesh as a surface object. + * @param {Mesh} + * mesh + * @param {Object} + * style + * @returns {number} surfid + */ + addMesh(t) { + var a = { + geo: t.geometry, + mat: t.material, + done: !0, + finished: !1 + //the rendered finishes surfaces when they are done + }, h = this.nextSurfID(); + return this.surfaces[h] = a, h; + } + //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(t) { + var a = []; + let h = t.length; + for (let M = 0; M < h; M++) + a[M] = (0, x.extend)({}, t[M]); + return a; + } + /** + * 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(t, a = {}, h = {}, M, w, S) { + let T = this.nextSurfID(), R = null, z = this, P = C.SurfaceType.VDW; + typeof t == "string" ? r.surfaceTypeMap[t.toUpperCase()] !== void 0 ? P = r.surfaceTypeMap[t] : console.log("Surface type : " + t + " is not recognized") : typeof t == "number" && (P = t); + var B = null, U = null, F = r.shallowCopy(this.getAtomsFromSel(h)); + M ? B = r.shallowCopy(this.getAtomsFromSel(M)) : B = F, (0, x.adjustVolumeStyle)(a); + var $ = !1, W; + for (W = 0; W < this.models.length; W++) + if (this.models[W]) { + var N = this.models[W].getSymmetries(); + if (N.length > 1 || N.length == 1 && !N[0].isIdentity()) { + $ = !0; + break; + } + } + var G = function(ue, se, ae) { + w ? U = r.shallowCopy(z.getAtomsFromSel(w)) : U = ae; + var we, xe = (0, x.getExtent)(ae, !0); + if (a.map && a.map.prop) { + var Ie = a.map.prop; + let We = (0, o.getGradient)(a.map.scheme || a.map.gradient || new o.Gradient.RWB()), Te = We.range(); + Te || (Te = (0, x.getPropertyRange)(ae, Ie)), a.colorscheme = { prop: Ie, gradient: We }; + } + for (let We = 0, Te = se.length; We < Te; We++) + we = se[We], we.surfaceColor = (0, x.getColorFromStyle)(we, a); + var oe = r.volume(xe), ve = z.carveUpExtent(xe, se, ae); + if (U && U.length && U.length > 0) { + var re = (0, x.getExtent)(U, !0), Se = function(We, Te) { + var je = function(Z, q) { + var fe = Z.extent, _e = fe[1][0] - fe[0][0], Me = fe[1][1] - fe[0][1], Ae = fe[1][2] - fe[0][2], H = _e - q[2][0]; + H *= H; + var ce = Me - q[2][1]; + ce *= ce; + var ye = Ae - q[2][2]; + return ye *= ye, H + ce + ye; + }, Fe = je(We, re), X = je(Te, re); + return Fe - X; + }; + ve.sort(Se); + } + var ze = []; + for (let We = 0, Te = se.length; We < Te; We++) + we = se[We], ze[We] = { + x: we.x, + y: we.y, + z: we.z, + serial: We, + elem: we.elem + }; + var Ge = !!C.syncSurface; + if (Ge) { + var $e = function(Te) { + return new Promise(function(je) { + for (var Fe = r.generateMeshSyncHelper(P, ve[Te].extent, ve[Te].atoms, ve[Te].toshow, ze, oe), X = (0, u.splitMesh)({ vertexArr: Fe.vertices, faceArr: Fe.faces }), Z = 0, q = X.length; Z < q; Z++) { + Fe = { + vertices: X[Z].vertexArr, + faces: X[Z].faceArr + }; + var fe = r.generateSurfaceMesh(se, Fe, R); + (0, x.mergeGeos)(ue.geo, fe); + } + z.render(), je(); + }); + }, Re = []; + for (let We = 0; We < ve.length; We++) + Re.push($e(We)); + return Promise.all(Re).then(function() { + return ue.done = !0, Promise.resolve(T); + }); + } else { + var Be = []; + P < 0 && (P = 0); + for (let We = 0, Te = r.numWorkers; We < Te; We++) { + var ke = new Worker($3Dmol.SurfaceWorker); + Be.push(ke), ke.postMessage({ + type: -1, + atoms: ze, + volume: oe + }); + } + return new Promise(function(We, Te) { + var je = 0, Fe = function() { + !Be || !Be.length || Be.forEach(function(fe) { + fe && fe.terminate && fe.terminate(); + }); + }, X = function(fe) { + for (var _e = (0, u.splitMesh)({ + vertexArr: fe.data.vertices, + faceArr: fe.data.faces + }), Me = 0, Ae = _e.length; Me < Ae; Me++) { + var H = { + vertices: _e[Me].vertexArr, + faces: _e[Me].faceArr + }, ce = r.generateSurfaceMesh(se, H, R); + (0, x.mergeGeos)(ue.geo, ce); + } + z.render(), je++, je == ve.length && (ue.done = !0, Fe(), We(T)); + }, Z = function(fe) { + Fe(), console.log(fe.message + " (" + fe.filename + ":" + fe.lineno + ")"), Te(fe); + }; + for (let fe = 0; fe < ve.length; fe++) { + var q = Be[fe % Be.length]; + q.onmessage = X, q.onerror = Z, q.postMessage({ + type: P, + expandedExtent: ve[fe].extent, + extendedAtoms: ve[fe].atoms, + atomsToShow: ve[fe].toshow + }); + } + }); + } + }; + a = a || {}, R = r.getMatWithStyle(a); + var k = []; + k.style = a, k.atomsel = h, k.allsel = M, k.focus = w; + var j = null; + if ($) { + var Q = {}, ie = {}; + for (W = 0; W < this.models.length; W++) + Q[W] = [], ie[W] = []; + for (W = 0; W < B.length; W++) + Q[B[W].model].push(B[W]); + for (W = 0; W < F.length; W++) + ie[F[W].model].push(F[W]); + var pe = []; + for (W = 0; W < this.models.length; W++) + ie[W].length > 0 && (k.push({ + geo: new l.Geometry(!0), + mat: R, + done: !1, + finished: !1, + symmetries: this.models[W].getSymmetries() + // also webgl initialized + }), pe.push(G(k[k.length - 1], Q[W], ie[W]))); + j = Promise.all(pe); + } else + k.push({ + geo: new l.Geometry(!0), + mat: R, + done: !1, + finished: !1, + symmetries: [new g.Matrix4()] + }), j = G(k[k.length - 1], B, F); + return this.surfaces[T] = k, j.surfid = T, S && typeof S == "function" ? (j.then(function(he) { + S(he); + }), T) : j; + } + /** + * 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(t, a) { + if ((0, x.adjustVolumeStyle)(a), this.surfaces[t]) { + var h = this.surfaces[t]; + h.style = a; + for (var M = 0; M < h.length; M++) { + var w = h[M].mat = r.getMatWithStyle(a); + if (h[M].mat.side = l.FrontSide, a.color) { + h[M].mat.color = a.color, h[M].geo.colorsNeedUpdate = !0; + const S = _.CC.color(a.color); + h[M].geo.setColors(function() { + return S; + }); + } else if (w.voldata && w.volscheme) { + const S = w.volscheme, T = w.voldata, R = _.CC, z = S.range() || [-1, 1]; + h[M].geo.setColors(function(P, B, U) { + let F = T.getVal(P, B, U); + return R.color(S.valueToHex(F, z)); + }); + } + h[M].finished = !1; + } + } + return this; + } + /** + * Return surface object + * @param {number} surf - surface id + */ + getSurface(t) { + return this.surfaces[t]; + } + /** + * Remove surface with given ID + * @param {number} surf - surface id + */ + removeSurface(t) { + for (var a = this.surfaces[t], h = 0; h < a.length; h++) + a[h] && a[h].lastGL && (a[h].geo !== void 0 && a[h].geo.dispose(), a[h].mat !== void 0 && a[h].mat.dispose(), this.modelGroup.remove(a[h].lastGL)); + return delete this.surfaces[t], this.show(), this; + } + /** Remove all surfaces. + **/ + removeAllSurfaces() { + for (var t in this.surfaces) + if (this.surfaces.hasOwnProperty(t)) { + for (var a = this.surfaces[t], h = 0; h < a.length; h++) + a[h] && a[h].lastGL && (a[h].geo !== void 0 && a[h].geo.dispose(), a[h].mat !== void 0 && a[h].mat.dispose(), this.modelGroup.remove(a[h].lastGL)); + delete this.surfaces[t]; + } + return this.show(), this; + } + /** return Jmol moveto command to position this scene */ + jmolMoveTo() { + var t = this.modelGroup.position, a = "center { " + -t.x + " " + -t.y + " " + -t.z + " }; ", h = this.rotationGroup.quaternion; + return a += "moveto .5 quaternion { " + h.x + " " + h.y + " " + h.z + " " + h.w + " };", a; + } + /** 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(t, a) { + a = a || {}; + var h = this.getAtomsFromSel(a); + if (typeof t == "function") + for (let S = 0, T = h.length; S < T; S++) { + let R = h[S]; + t(R); + } + else + for (let S = 0, T = h.length; S < T; S++) { + var M = h[S]; + for (let R = 0, z = t.length; R < z; R++) { + let P = t[R]; + if (P.props) + for (var w in P.props) + P.props.hasOwnProperty(w) && this.atomIsSelected(M, P) && (M.properties || (M.properties = {}), M.properties[w] = P.props[w]); + } + } + 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(t) { + return this.linkedViewers.push(t), 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(t) { + this.rotationGroup.position.z = this.CAMERA_Z - t; + } + /** + * Used for setting an approx value of eyeSeparation. Created for calling by StereoViewer object + * @return {number} camera x position + */ + setAutoEyeSeparation(t, a) { + var h = this.getPerceivedDistance(); + return a || (a = 5), t || this.camera.position.x > 0 ? this.camera.position.x = h * Math.tan(Math.PI / 180 * a) : this.camera.position.x = -h * Math.tan(Math.PI / 180 * a), this.camera.lookAt(new g.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(t) { + this.config.cartoonQuality = t; + } + } + r.numWorkers = 4, r.maxVolume = 64e3, r.surfaceTypeMap = { + VDW: C.SurfaceType.VDW, + MS: C.SurfaceType.MS, + SAS: C.SurfaceType.SAS, + SES: C.SurfaceType.SES + }; + function n(c, t) { + if (c = (0, x.getElement)(c), !!c) { + t = t || {}; + try { + var a = new r(c, t); + return a; + } catch (h) { + throw "error creating viewer: " + h; + } + } + } + function b(c, t = {}, a = {}) { + if (c = (0, x.getElement)(c), !!c) { + var h = [], M = document.createElement("canvas"); + a.rows = t.rows, a.cols = t.cols, a.control_all = t.control_all != null ? t.control_all : !1, c.appendChild(M); + try { + for (var w = 0; w < t.rows; w++) { + for (var S = [], T = 0; T < t.cols; T++) { + a.row = w, a.col = T, a.canvas = M, a.viewers = h, a.control_all = t.control_all; + var R = n(c, (0, x.extend)({}, a)); + S.push(R); + } + h.unshift(S); + } + } catch (z) { + throw "error creating viewer grid: " + z; + } + return h; + } + } + function f(c) { + var t = this; + if (c = (0, x.getElement)(c), !!c) { + var a = b(c, { rows: 1, cols: 2, control_all: !0 }); + this.glviewer1 = a[0][0], this.glviewer2 = a[0][1], this.glviewer1.setAutoEyeSeparation(!1), this.glviewer2.setAutoEyeSeparation(!0), this.glviewer1.linkViewer(this.glviewer2), this.glviewer2.linkViewer(this.glviewer1); + for (var h = Object.getOwnPropertyNames(this.glviewer1.__proto__).filter(function(w) { + return typeof t.glviewer1[w] == "function"; + }), M = 0; M < h.length; M++) + this[h[M]] = /* @__PURE__ */ function(w) { + return function() { + var S = this.glviewer1[w].apply(this.glviewer1, arguments), T = this.glviewer2[w].apply(this.glviewer2, arguments); + return [S, T]; + }; + }(h[M]); + this.setCoordinates = function(w, S, T) { + for (var R = 0; R < w.length; R++) + w[R].setCoordinates(S, T); + }, this.surfacesFinished = function() { + return this.glviewer1.surfacesFinished() && this.glviewer2.surfacesFinished(); + }, this.isAnimated = function() { + return this.glviewer1.isAnimated() || this.glviewer2.isAnimated(); + }, this.render = function(w) { + this.glviewer1.render(), this.glviewer2.render(), w && w(this); + }, this.getCanvas = function() { + return this.glviewer1.getCanvas(); + }; + } + } + } + ), + /***/ + "./src/Gradient.ts": ( + /*!*************************!*\ + !*** ./src/Gradient.ts ***! + \*************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + CustomLinear: () => ( + /* binding */ + u + ), + /* harmony export */ + Gradient: () => ( + /* binding */ + C + ), + /* harmony export */ + GradientType: () => ( + /* binding */ + g + ), + /* harmony export */ + ROYGB: () => ( + /* binding */ + p + ), + /* harmony export */ + RWB: () => ( + /* binding */ + o + ), + /* harmony export */ + Sinebow: () => ( + /* binding */ + E + ), + /* harmony export */ + builtinGradients: () => ( + /* binding */ + A + ), + /* harmony export */ + getGradient: () => ( + /* binding */ + x + ), + /* harmony export */ + normalizeValue: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./colors */ + "./src/colors.ts" + ); + class g { + } + function _(L, D, r) { + return D >= L ? (r < L && (r = L), r > D && (r = D), { lo: L, hi: D, val: r }) : (r > L && (r = L), r < D && (r = D), r = L - r + D, { lo: D, hi: L, val: r }); + } + function x(L) { + if (L instanceof g) + return L; + if (L.gradient !== void 0 && A[L.gradient]) { + let D = L.min === void 0 ? -1 : L.min, r = L.max === void 0 ? 1 : L.max; + return L.mid === void 0 ? L.colors === void 0 ? new A[L.gradient](D, r) : new A[L.gradient](D, r, L.colors) : new A[L.gradient](D, r, L.mid); + } + return L; + } + class o extends g { + constructor(D, r, n) { + super(), this.gradient = "RWB", this.mult = 1, this.mid = n, this.min = D, this.max = r, typeof r > "u" && Array.isArray(D) && D.length >= 2 ? (this.max = D[1], this.min = D[0]) : D && r && !Array.isArray(D) && (this.min = D, this.max = r); + } + //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(D, r) { + var n, b; + if (D = this.mult * D, r ? (n = r[0], b = r[1]) : (n = this.min, b = this.max), D === void 0) + return 16777215; + var f = _(n, b, D); + n = f.lo, b = f.hi, D = f.val; + var c = (b + n) / 2; + r && typeof r[2] < "u" ? c = r[2] : typeof this.mid < "u" ? c = this.mid : c = (n + b) / 2; + var t, a; + return D < c ? (t = Math.floor(255 * Math.sqrt((D - n) / (c - n))), a = 16711680 + 256 * t + t, a) : D > c ? (t = Math.floor(255 * Math.sqrt(1 - (D - c) / (b - c))), a = 65536 * t + 256 * t + 255, a) : 16777215; + } + } + class p extends g { + constructor(D, r) { + super(), this.gradient = "ROYGB", this.mult = 1, this.min = D, this.max = r, typeof r > "u" && Array.isArray(D) && D.length >= 2 ? (this.max = D[1], this.min = D[0]) : D && r && !Array.isArray(D) && (this.min = D, this.max = r); + } + //map value to hex color, range is provided + valueToHex(D, r) { + var n, b; + if (D = this.mult * D, r ? (n = r[0], b = r[1]) : (n = this.min, b = this.max), typeof D > "u") + return 16777215; + var f = _(n, b, D); + n = f.lo, b = f.hi, D = f.val; + var c = (n + b) / 2, t = (n + c) / 2, a = (c + b) / 2, h, M; + return D < t ? (h = Math.floor(255 * Math.sqrt((D - n) / (t - n))), M = 16711680 + 256 * h + 0, M) : D < c ? (h = Math.floor(255 * Math.sqrt(1 - (D - t) / (c - t))), M = 65536 * h + 65280 + 0, M) : D < a ? (h = Math.floor(255 * Math.sqrt((D - c) / (a - c))), M = 65280 + 1 * h, M) : (h = Math.floor(255 * Math.sqrt(1 - (D - a) / (b - a))), M = 0 + 256 * h + 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 g { + constructor(D, r) { + super(), this.gradient = "Sinebow", this.mult = 1, this.min = D, this.max = r, typeof r > "u" && Array.isArray(D) && D.length >= 2 && (this.max = D[1], this.min = D[0]), r < D && (this.mult = -1, this.min *= -1, this.max *= -1); + } + //map value to hex color, range is provided + valueToHex(D, r) { + var n, b; + if (D = this.mult * D, r ? (n = r[0], b = r[1]) : (n = this.min, b = this.max), typeof D > "u") + return 16777215; + var f = C.normalizeValue(n, b, D); + n = f.lo, b = f.hi, D = f.val; + var c = (D - n) / (b - n), t = 5 * c / 6 + 0.5, a = Math.sin(Math.PI * t); + a *= a * 255; + var h = Math.sin(Math.PI * (t + 1 / 3)); + h *= h * 255; + var M = Math.sin(Math.PI * (t + 2 / 3)); + return M *= M * 255, 65536 * Math.floor(a) + 256 * Math.floor(M) + 1 * Math.floor(h); + } + //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 u extends g { + constructor(D, r, n) { + super(), this.gradient = "linear", this.colors = new Array(); + var b; + if (Array.isArray(D) && D.length >= 2 ? (this.max = D[1], this.min = D[0], b = r) : (this.min = D, this.max = r, b = n), b) + for (let f of b) + this.colors.push(l.CC.color(f)); + else + this.colors.push(l.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(D, r) { + var n, b; + if (r ? (n = r[0], b = r[1]) : (n = this.min, b = this.max), D === void 0) + return 16777215; + var f = _(n, b, D); + n = f.lo, b = f.hi, D = f.val; + let c = this.colors.length, t = (b - n) / c, a = Math.min(Math.floor((D - n) / t), c - 1), h = Math.min(a + 1, c - 1), M = (D - n - a * t) / t, w = this.colors[a], S = this.colors[h]; + return new l.Color(w.r + M * (S.r - w.r), w.g + M * (S.g - w.g), w.b + M * (S.b - w.b)).getHex(); + } + } + const A = { + rwb: o, + RWB: o, + roygb: p, + ROYGB: p, + sinebow: E, + linear: u + }; + class C extends g { + valueToHex(D, r) { + return 0; + } + range() { + return null; + } + } + C.RWB = o, C.ROYGB = p, C.Sinebow = E, C.CustomLinear = u, C.builtinGradients = A, C.normalizeValue = _, C.getGradient = x; + } + ), + /***/ + "./src/Label.ts": ( + /*!**********************!*\ + !*** ./src/Label.ts ***! + \**********************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Label: () => ( + /* binding */ + E + ), + /* harmony export */ + LabelCount: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), g = e( + /*! ./Gradient */ + "./src/Gradient.ts" + ), _ = e( + /*! ./colors */ + "./src/colors.ts" + ); + let x = 0; + function o(u, A, C, L, D, r, n) { + u.beginPath(), u.moveTo(A + r, C), u.lineTo(A + L - r, C), u.quadraticCurveTo(A + L, C, A + L, C + r), u.lineTo(A + L, C + D - r), u.quadraticCurveTo(A + L, C + D, A + L - r, C + D), u.lineTo(A + r, C + D), u.quadraticCurveTo(A, C + D, A, C + D - r), u.lineTo(A, C + r), u.quadraticCurveTo(A, C, A + r, C), u.closePath(), u.fill(), n && u.stroke(); + } + function p(u, A, C) { + var L = C; + return typeof u < "u" && (u instanceof _.Color ? L = u.scaled() : (L = _.CC.color(u), typeof L.scaled < "u" && (L = L.scaled()))), typeof A < "u" && (L.a = parseFloat(A)), L; + } + class E { + constructor(A, C) { + this.id = x++, this.stylespec = C || {}, this.canvas = document.createElement("canvas"), this.canvas.width = 134, this.canvas.height = 35, this.context = this.canvas.getContext("2d"), this.sprite = new l.Sprite(), this.text = A, this.frame = this.stylespec.frame; + } + getStyle() { + return this.stylespec; + } + setContext() { + var A = this.stylespec, C = typeof A.useScreen > "u" ? !1 : A.useScreen, L = A.showBackground; + (L === "0" || L === "false") && (L = !1), typeof L > "u" && (L = !0); + var D = A.font ? A.font : "sans-serif", r = parseInt(A.fontSize) ? parseInt(A.fontSize) : 18, n = p(A.fontColor, A.fontOpacity, { + r: 255, + g: 255, + b: 255, + a: 1 + }), b = A.padding ? A.padding : 4, f = A.borderThickness ? A.borderThickness : 0, c = p(A.backgroundColor, A.backgroundOpacity, { + r: 0, + g: 0, + b: 0, + a: 1 + }), t = p(A.borderColor, A.borderOpacity, c), a = A.position ? A.position : { + x: -10, + y: 1, + z: 1 + }, h = A.inFront !== void 0 ? A.inFront : !0; + (h === "false" || h === "0") && (h = !1); + var M = A.alignment || l.SpriteAlignment.topLeft; + typeof M == "string" && M in l.SpriteAlignment && (M = l.SpriteAlignment[M]); + var w = ""; + A.bold && (w = "bold "), this.context.font = w + r + "px " + D; + var S = this.context.measureText(this.text), T = S.width; + L || (f = 0); + var R = T + 2.5 * f + 2 * b, z = r * 1.25 + 2 * f + 2 * b; + if (A.backgroundImage) { + var P = A.backgroundImage, B = A.backgroundWidth ? A.backgroundWidth : P.width, U = A.backgroundHeight ? A.backgroundHeight : P.height; + B > R && (R = B), U > z && (z = U); + } + if (this.canvas.width = R, this.canvas.height = z, this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), w = "", A.bold && (w = "bold "), this.context.font = w + r + "px " + D, this.context.fillStyle = "rgba(" + c.r + "," + c.g + "," + c.b + "," + c.a + ")", this.context.strokeStyle = "rgba(" + t.r + "," + t.g + "," + t.b + "," + t.a + ")", A.backgroundGradient) { + let $ = this.context.createLinearGradient(0, z / 2, R, z / 2), W = g.Gradient.getGradient(A.backgroundGradient), N = W.range(), G = -1, k = 1; + N && (G = N[0], k = N[1]); + let j = k - G; + for (let Q = 0; Q < 1.01; Q += 0.1) { + let ie = p(W.valueToHex(G + j * Q)), pe = "rgba(" + ie.r + "," + ie.g + "," + ie.b + "," + ie.a + ")"; + $.addColorStop(Q, pe); + } + this.context.fillStyle = $; + } + this.context.lineWidth = f, L && o(this.context, f, f, R - 2 * f, z - 2 * f, 6, f > 0), A.backgroundImage && this.context.drawImage(P, 0, 0, R, z), this.context.fillStyle = "rgba(" + n.r + "," + n.g + "," + n.b + "," + n.a + ")", this.context.fillText(this.text, f + b, r + f + b, T); + var F = new l.Texture(this.canvas); + F.needsUpdate = !0, this.sprite.material = new l.SpriteMaterial({ + map: F, + useScreenCoordinates: C, + alignment: M, + depthTest: !h, + screenOffset: A.screenOffset || null + }), this.sprite.scale.set(1, 1, 1), this.sprite.position.set(a.x, a.y, a.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 ***! + \********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + MarchingCube: () => ( + /* binding */ + p + ), + /* harmony export */ + MarchingCubeInitializer: () => ( + /* binding */ + o + ), + /* harmony export */ + PointGrid: () => ( + /* binding */ + E + ), + /* harmony export */ + ProteinSurface: () => ( + /* binding */ + u + ), + /* harmony export */ + SurfaceType: () => ( + /* binding */ + g + ), + /* harmony export */ + setSyncSurface: () => ( + /* binding */ + x + ), + /* harmony export */ + syncSurface: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), g; + (function(A) { + A[A.VDW = 1] = "VDW", A[A.MS = 2] = "MS", A[A.SAS = 3] = "SAS", A[A.SES = 4] = "SES"; + })(g || (g = {})); + var _ = !1; + function x(A) { + _ = A; + } + (window.navigator.userAgent.indexOf("MSIE ") >= 0 || window.navigator.userAgent.indexOf("Trident/") >= 0) && (_ = !0); + class o { + 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(C, L, D, r) { + let n = !!r.fulltable, b = r.hasOwnProperty("origin") && r.origin.hasOwnProperty("x") ? r.origin : { x: 0, y: 0, z: 0 }, f = !!r.voxel, c = r.matrix, t = r.nX || 0, a = r.nY || 0, h = r.nZ || 0, M = r.scale || 1, w = null; + r.unitCube ? w = r.unitCube : w = { x: M, y: M, z: M }; + let S = new Int32Array(t * a * h), T, R; + for (T = 0, R = S.length; T < R; ++T) + S[T] = -1; + let z = function(F, $, W, N, G, k) { + let j = { x: 0, y: 0, z: 0 }, Q = !!(N & 1 << G), ie = !!(N & 1 << k), pe = G; + if (!Q && ie && (pe = k), pe & 1 && W++, pe & 2 && $++, pe & 4 && F++, c) { + let ue = new l.Vector3(F, $, W); + ue = ue.applyMatrix4(c), j = { x: ue.x, y: ue.y, z: ue.z }; + } else + j.x = b.x + w.x * F, j.y = b.y + w.y * $, j.z = b.z + w.z * W; + let he = (a * F + $) * h + W; + return f ? (L.push(j), L.length - 1) : (S[he] < 0 && (S[he] = L.length, L.push(j)), S[he]); + }, P = new Int32Array(12), B = n ? this.edgeTable2 : this.edgeTable, U = n ? this.triTable2 : this.triTable; + for (T = 0; T < t - 1; ++T) + for (let F = 0; F < a - 1; ++F) + for (let $ = 0; $ < h - 1; ++$) { + let W = 0; + for (let k = 0; k < 8; ++k) { + let j = (a * (T + ((k & 4) >> 2)) + F + ((k & 2) >> 1)) * h + $ + (k & 1), Q = !!(C[j] & this.ISDONE); + W |= Q << k; + } + if (W === 0 || W === 255) + continue; + let N = B[W]; + if (N === 0) + continue; + let G = U[W]; + N & 1 && (P[0] = z(T, F, $, W, 0, 1)), N & 2 && (P[1] = z(T, F, $, W, 1, 3)), N & 4 && (P[2] = z(T, F, $, W, 3, 2)), N & 8 && (P[3] = z(T, F, $, W, 2, 0)), N & 16 && (P[4] = z(T, F, $, W, 4, 5)), N & 32 && (P[5] = z(T, F, $, W, 5, 7)), N & 64 && (P[6] = z(T, F, $, W, 7, 6)), N & 128 && (P[7] = z(T, F, $, W, 6, 4)), N & 256 && (P[8] = z(T, F, $, W, 0, 4)), N & 512 && (P[9] = z(T, F, $, W, 1, 5)), N & 1024 && (P[10] = z(T, F, $, W, 3, 7)), N & 2048 && (P[11] = z(T, F, $, W, 2, 6)); + for (let k = 0; k < G.length; k += 3) { + let j = P[G[k]], Q = P[G[k + 1]], ie = P[G[k + 2]]; + f && k >= 3 && (L.push(L[j]), j = L.length - 1, L.push(L[Q]), Q = L.length - 1, L.push(L[ie]), ie = L.length - 1), D.push(j), D.push(Q), D.push(ie); + } + } + } + laplacianSmooth(C, L, D) { + let r = new Array(L.length), n, b, f, c, t; + for (n = 0, b = L.length; n < b; n++) + r[n] = { + x: 0, + y: 0, + z: 0 + }; + let a = new Array(20), h; + for (n = 0; n < 20; n++) + a[n] = new Array(L.length); + for (n = 0, b = L.length; n < b; n++) + a[0][n] = 0; + for (n = 0, b = D.length / 3; n < b; n++) { + let S = n * 3, T = n * 3 + 1, R = n * 3 + 2; + for (h = !0, f = 0, c = a[0][D[S]]; f < c; f++) + if (D[T] == a[f + 1][D[S]]) { + h = !1; + break; + } + for (h && (a[0][D[S]]++, a[a[0][D[S]]][D[S]] = D[T]), h = !0, f = 0, c = a[0][D[S]]; f < c; f++) + if (D[R] == a[f + 1][D[S]]) { + h = !1; + break; + } + for (h && (a[0][D[S]]++, a[a[0][D[S]]][D[S]] = D[R]), h = !0, f = 0, c = a[0][D[T]]; f < c; f++) + if (D[S] == a[f + 1][D[T]]) { + h = !1; + break; + } + for (h && (a[0][D[T]]++, a[a[0][D[T]]][D[T]] = D[S]), h = !0, f = 0, c = a[0][D[T]]; f < c; f++) + if (D[R] == a[f + 1][D[T]]) { + h = !1; + break; + } + for (h && (a[0][D[T]]++, a[a[0][D[T]]][D[T]] = D[R]), h = !0, f = 0; f < a[0][D[R]]; f++) + if (D[S] == a[f + 1][D[R]]) { + h = !1; + break; + } + for (h && (a[0][D[R]]++, a[a[0][D[R]]][D[R]] = D[S]), h = !0, f = 0, c = a[0][D[R]]; f < c; f++) + if (D[T] == a[f + 1][D[R]]) { + h = !1; + break; + } + h && (a[0][D[R]]++, a[a[0][D[R]]][D[R]] = D[T]); + } + let M = 1, w = 0.5; + for (t = 0; t < C; t++) { + for (n = 0, b = L.length; n < b; n++) + if (a[0][n] < 3) + r[n].x = L[n].x, r[n].y = L[n].y, r[n].z = L[n].z; + else if (a[0][n] == 3 || a[0][n] == 4) { + for (r[n].x = 0, r[n].y = 0, r[n].z = 0, f = 0, c = a[0][n]; f < c; f++) + r[n].x += L[a[f + 1][n]].x, r[n].y += L[a[f + 1][n]].y, r[n].z += L[a[f + 1][n]].z; + r[n].x += w * L[n].x, r[n].y += w * L[n].y, r[n].z += w * L[n].z, r[n].x /= w + a[0][n], r[n].y /= w + a[0][n], r[n].z /= w + a[0][n]; + } else { + for (r[n].x = 0, r[n].y = 0, r[n].z = 0, f = 0, c = a[0][n]; f < c; f++) + r[n].x += L[a[f + 1][n]].x, r[n].y += L[a[f + 1][n]].y, r[n].z += L[a[f + 1][n]].z; + r[n].x += M * L[n].x, r[n].y += M * L[n].y, r[n].z += M * L[n].z, r[n].x /= M + a[0][n], r[n].y /= M + a[0][n], r[n].z /= M + a[0][n]; + } + for (n = 0, b = L.length; n < b; n++) + L[n].x = r[n].x, L[n].y = r[n].y, L[n].z = r[n].z; + } + } + } + let p = new o(); + class E { + constructor(C, L, D) { + this.data = new Int32Array(C * L * D * 3), this.width = L, this.height = D; + } + // set position x,y,z to pt, which has ix,iy,and iz + set(C, L, D, r) { + let n = ((C * this.width + L) * this.height + D) * 3; + this.data[n] = r.ix, this.data[n + 1] = r.iy, this.data[n + 2] = r.iz; + } + // return point at x,y,z + get(C, L, D) { + let r = ((C * this.width + L) * this.height + D) * 3; + return { + ix: this.data[r], + iy: this.data[r + 1], + iz: this.data[r + 2] + }; + } + } + class u { + 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]) + ], u.MarchingCube || (u.MarchingCube = new o()); + } + getVDWIndex(C) { + return !C.elem || typeof this.vdwRadii[C.elem] > "u" ? "X" : C.elem; + } + getFacesAndVertices(C) { + let L = {}; + for (let n = 0, b = C.length; n < b; n++) + L[C[n]] = !0; + let D = this.verts; + for (let n = 0, b = D.length; n < b; n++) + D[n].x = D[n].x / this.scaleFactor - this.ptranx, D[n].y = D[n].y / this.scaleFactor - this.ptrany, D[n].z = D[n].z / this.scaleFactor - this.ptranz; + let r = []; + for (let n = 0, b = this.faces.length; n < b; n += 3) { + let f = this.faces[n], c = this.faces[n + 1], t = this.faces[n + 2], a = D[f].atomid, h = D[c].atomid, M = D[t].atomid, w = a; + h < w && (w = h), M < w && (w = M), L[w] && f !== c && c !== t && f !== t && (r.push(f), r.push(c), r.push(t)); + } + return this.vpBits = null, this.vpDistance = null, this.vpAtomID = null, { + vertices: D, + faces: r + }; + } + initparm(C, L, D) { + D > 1e6 && (this.scaleFactor = this.defaultScaleFactor / 2); + let r = 1 / this.scaleFactor * 5.5; + this.pminx = C[0][0], this.pmaxx = C[1][0], this.pminy = C[0][1], this.pmaxy = C[1][1], this.pminz = C[0][2], this.pmaxz = C[1][2], L ? (this.pminx -= this.probeRadius + r, this.pminy -= this.probeRadius + r, this.pminz -= this.probeRadius + r, this.pmaxx += this.probeRadius + r, this.pmaxy += this.probeRadius + r, this.pmaxz += this.probeRadius + r) : (this.pminx -= r, this.pminy -= r, this.pminz -= r, this.pmaxx += r, this.pmaxy += r, this.pmaxz += r), 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(L), 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(C) { + let L = {}; + for (const D in this.vdwRadii) { + let r = this.vdwRadii[D]; + C ? L[D] = (r + this.probeRadius) * this.scaleFactor + 0.5 : L[D] = r * this.scaleFactor + 0.5; + let n = L[D] * L[D]; + this.widxz[D] = Math.floor(L[D]) + 1, this.depty[D] = new Int32Array(this.widxz[D] * this.widxz[D]); + let b = 0; + for (let f = 0; f < this.widxz[D]; f++) + for (let c = 0; c < this.widxz[D]; c++) { + let t = f * f + c * c; + if (t > n) + this.depty[D][b] = -1; + else { + let a = Math.sqrt(n - t); + this.depty[D][b] = Math.floor(a); + } + b++; + } + } + } + fillvoxels(C, L) { + for (let D = 0, r = this.vpBits.length; D < r; D++) + this.vpBits[D] = 0, this.vpDistance[D] = -1, this.vpAtomID[D] = -1; + for (let D in L) { + let r = C[L[D]]; + r !== void 0 && this.fillAtom(r, C); + } + for (let D = 0, r = this.vpBits.length; D < r; D++) + this.vpBits[D] & this.INOUT && (this.vpBits[D] |= this.ISDONE); + } + fillAtom(C, L) { + let D = Math.floor(0.5 + this.scaleFactor * (C.x + this.ptranx)), r = Math.floor(0.5 + this.scaleFactor * (C.y + this.ptrany)), n = Math.floor(0.5 + this.scaleFactor * (C.z + this.ptranz)), b = this.getVDWIndex(C), f = 0, c = this.pWidth * this.pHeight; + for (let t = 0, a = this.widxz[b]; t < a; t++) + for (let h = 0; h < a; h++) { + if (this.depty[b][f] != -1) { + for (let M = -1; M < 2; M++) + for (let w = -1; w < 2; w++) + for (let S = -1; S < 2; S++) + if (M !== 0 && w !== 0 && S !== 0) { + let T = M * t, R = S * h; + for (let z = 0; z <= this.depty[b][f]; z++) { + let P = z * w, B = D + T, U = r + P, F = n + R; + if (B < 0 || U < 0 || F < 0 || B >= this.pLength || U >= this.pWidth || F >= this.pHeight) + continue; + let $ = B * c + U * this.pHeight + F; + if (!(this.vpBits[$] & this.INOUT)) + this.vpBits[$] |= this.INOUT, this.vpAtomID[$] = C.serial; + else { + let W = L[this.vpAtomID[$]]; + if (W.serial != C.serial) { + let N = D + T - Math.floor(0.5 + this.scaleFactor * (W.x + this.ptranx)), G = r + P - Math.floor(0.5 + this.scaleFactor * (W.y + this.ptrany)), k = n + R - Math.floor(0.5 + this.scaleFactor * (W.z + this.ptranz)); + T * T + P * P + R * R < N * N + G * G + k * k && (this.vpAtomID[$] = C.serial); + } + } + } + } + } + f++; + } + } + fillvoxelswaals(C, L) { + for (let D = 0, r = this.vpBits.length; D < r; D++) + this.vpBits[D] &= ~this.ISDONE; + for (let D in L) { + let r = C[L[D]]; + r !== void 0 && this.fillAtomWaals(r, C); + } + } + fillAtomWaals(C, L) { + let D = 0, r = Math.floor(0.5 + this.scaleFactor * (C.x + this.ptranx)), n = Math.floor(0.5 + this.scaleFactor * (C.y + this.ptrany)), b = Math.floor(0.5 + this.scaleFactor * (C.z + this.ptranz)), f = this.getVDWIndex(C), c = this.pWidth * this.pHeight; + for (let t = 0, a = this.widxz[f]; t < a; t++) + for (let h = 0; h < a; h++) { + if (this.depty[f][D] != -1) { + for (let M = -1; M < 2; M++) + for (let w = -1; w < 2; w++) + for (let S = -1; S < 2; S++) + if (M !== 0 && w !== 0 && S !== 0) { + let T = M * t, R = S * h; + for (let z = 0; z <= this.depty[f][D]; z++) { + let P = z * w, B = r + T, U = n + P, F = b + R; + if (B < 0 || U < 0 || F < 0 || B >= this.pLength || U >= this.pWidth || F >= this.pHeight) + continue; + let $ = B * c + U * this.pHeight + F; + if (!(this.vpBits[$] & this.ISDONE)) + this.vpBits[$] |= this.ISDONE, this.vpAtomID[$] = C.serial; + else { + let W = L[this.vpAtomID[$]]; + if (W.serial != C.serial) { + let N = r + T - Math.floor(0.5 + this.scaleFactor * (W.x + this.ptranx)), G = n + P - Math.floor(0.5 + this.scaleFactor * (W.y + this.ptrany)), k = b + R - Math.floor(0.5 + this.scaleFactor * (W.z + this.ptranz)); + T * T + P * P + R * R < N * N + G * G + k * k && (this.vpAtomID[$] = C.serial); + } + } + } + } + } + D++; + } + } + buildboundary() { + let C = this.pWidth * this.pHeight; + for (let L = 0; L < this.pLength; L++) + for (let D = 0; D < this.pHeight; D++) + for (let r = 0; r < this.pWidth; r++) { + let n = L * C + r * this.pHeight + D; + if (this.vpBits[n] & this.INOUT) { + let b = 0; + for (; b < 26; ) { + let f = L + this.nb[b][0], c = D + this.nb[b][2], t = r + this.nb[b][1]; + if (f > -1 && f < this.pLength && t > -1 && t < this.pWidth && c > -1 && c < this.pHeight && !(this.vpBits[f * C + t * this.pHeight + c] & this.INOUT)) { + this.vpBits[n] |= this.ISBOUND; + break; + } else + b++; + } + } + } + } + fastdistancemap() { + let C = new E(this.pLength, this.pWidth, this.pHeight), L = this.pWidth * this.pHeight, D = this.cutRadius * this.cutRadius, r = [], n = [], b; + for (let t = 0; t < this.pLength; t++) + for (let a = 0; a < this.pWidth; a++) + for (let h = 0; h < this.pHeight; h++) + if (b = t * L + a * this.pHeight + h, this.vpBits[b] &= ~this.ISDONE, this.vpBits[b] & this.INOUT && this.vpBits[b] & this.ISBOUND) { + let M = { + ix: t, + iy: a, + iz: h + }; + C.set(t, a, h, M), r.push(M), this.vpDistance[b] = 0, this.vpBits[b] |= this.ISDONE, this.vpBits[b] &= ~this.ISBOUND; + } + do { + n = this.fastoneshell(r, C), r = []; + for (let t = 0, a = n.length; t < a; t++) + b = L * n[t].ix + this.pHeight * n[t].iy + n[t].iz, this.vpBits[b] &= ~this.ISBOUND, this.vpDistance[b] <= 1.0404 * D && r.push({ + ix: n[t].ix, + iy: n[t].iy, + iz: n[t].iz + }); + } while (r.length !== 0); + r = [], n = [], C = null; + let f = this.scaleFactor - 0.5; + f < 0 && (f = 0); + let c = D - 0.5 / (0.1 + f); + for (let t = 0; t < this.pLength; t++) + for (let a = 0; a < this.pWidth; a++) + for (let h = 0; h < this.pHeight; h++) + b = t * L + a * this.pHeight + h, this.vpBits[b] &= ~this.ISBOUND, this.vpBits[b] & this.INOUT && (!(this.vpBits[b] & this.ISDONE) || this.vpBits[b] & this.ISDONE && this.vpDistance[b] >= c) && (this.vpBits[b] |= this.ISBOUND); + } + fastoneshell(C, L) { + let D, r, n, b, f, c, t, a, h, M = []; + if (C.length === 0) + return M; + let w = { + ix: -1, + iy: -1, + iz: -1 + }, S = this.pWidth * this.pHeight; + for (let T = 0, R = C.length; T < R; T++) { + D = C[T].ix, r = C[T].iy, n = C[T].iz, a = L.get(D, r, n); + for (let z = 0; z < 6; z++) + w.ix = D + this.nb[z][0], w.iy = r + this.nb[z][1], w.iz = n + this.nb[z][2], w.ix < this.pLength && w.ix > -1 && w.iy < this.pWidth && w.iy > -1 && w.iz < this.pHeight && w.iz > -1 && (h = w.ix * S + this.pHeight * w.iy + w.iz, this.vpBits[h] & this.INOUT && !(this.vpBits[h] & this.ISDONE) ? (L.set(w.ix, w.iy, n + this.nb[z][2], a), b = w.ix - a.ix, f = w.iy - a.iy, c = w.iz - a.iz, t = b * b + f * f + c * c, this.vpDistance[h] = t, this.vpBits[h] |= this.ISDONE, this.vpBits[h] |= this.ISBOUND, M.push({ + ix: w.ix, + iy: w.iy, + iz: w.iz + })) : this.vpBits[h] & this.INOUT && this.vpBits[h] & this.ISDONE && (b = w.ix - a.ix, f = w.iy - a.iy, c = w.iz - a.iz, t = b * b + f * f + c * c, t < this.vpDistance[h] && (L.set(w.ix, w.iy, w.iz, a), this.vpDistance[h] = t, this.vpBits[h] & this.ISBOUND || (this.vpBits[h] |= this.ISBOUND, M.push({ + ix: w.ix, + iy: w.iy, + iz: w.iz + }))))); + } + for (let T = 0, R = C.length; T < R; T++) { + D = C[T].ix, r = C[T].iy, n = C[T].iz, a = L.get(D, r, n); + for (let z = 6; z < 18; z++) + w.ix = D + this.nb[z][0], w.iy = r + this.nb[z][1], w.iz = n + this.nb[z][2], w.ix < this.pLength && w.ix > -1 && w.iy < this.pWidth && w.iy > -1 && w.iz < this.pHeight && w.iz > -1 && (h = w.ix * S + this.pHeight * w.iy + w.iz, this.vpBits[h] & this.INOUT && !(this.vpBits[h] & this.ISDONE) ? (L.set(w.ix, w.iy, n + this.nb[z][2], a), b = w.ix - a.ix, f = w.iy - a.iy, c = w.iz - a.iz, t = b * b + f * f + c * c, this.vpDistance[h] = t, this.vpBits[h] |= this.ISDONE, this.vpBits[h] |= this.ISBOUND, M.push({ + ix: w.ix, + iy: w.iy, + iz: w.iz + })) : this.vpBits[h] & this.INOUT && this.vpBits[h] & this.ISDONE && (b = w.ix - a.ix, f = w.iy - a.iy, c = w.iz - a.iz, t = b * b + f * f + c * c, t < this.vpDistance[h] && (L.set(w.ix, w.iy, w.iz, a), this.vpDistance[h] = t, this.vpBits[h] & this.ISBOUND || (this.vpBits[h] |= this.ISBOUND, M.push({ + ix: w.ix, + iy: w.iy, + iz: w.iz + }))))); + } + for (let T = 0, R = C.length; T < R; T++) { + D = C[T].ix, r = C[T].iy, n = C[T].iz, a = L.get(D, r, n); + for (let z = 18; z < 26; z++) + w.ix = D + this.nb[z][0], w.iy = r + this.nb[z][1], w.iz = n + this.nb[z][2], w.ix < this.pLength && w.ix > -1 && w.iy < this.pWidth && w.iy > -1 && w.iz < this.pHeight && w.iz > -1 && (h = w.ix * S + this.pHeight * w.iy + w.iz, this.vpBits[h] & this.INOUT && !(this.vpBits[h] & this.ISDONE) ? (L.set(w.ix, w.iy, n + this.nb[z][2], a), b = w.ix - a.ix, f = w.iy - a.iy, c = w.iz - a.iz, t = b * b + f * f + c * c, this.vpDistance[h] = t, this.vpBits[h] |= this.ISDONE, this.vpBits[h] |= this.ISBOUND, M.push({ + ix: w.ix, + iy: w.iy, + iz: w.iz + })) : this.vpBits[h] & this.INOUT && this.vpBits[h] & this.ISDONE && (b = w.ix - a.ix, f = w.iy - a.iy, c = w.iz - a.iz, t = b * b + f * f + c * c, t < this.vpDistance[h] && (L.set(w.ix, w.iy, w.iz, a), this.vpDistance[h] = t, this.vpBits[h] & this.ISBOUND || (this.vpBits[h] |= this.ISBOUND, M.push({ + ix: w.ix, + iy: w.iy, + iz: w.iz + }))))); + } + return M; + } + marchingcubeinit(C) { + for (let L = 0, D = this.vpBits.length; L < D; L++) + C == 1 ? this.vpBits[L] &= ~this.ISBOUND : C == 4 ? (this.vpBits[L] &= ~this.ISDONE, this.vpBits[L] & this.ISBOUND && (this.vpBits[L] |= this.ISDONE), this.vpBits[L] &= ~this.ISBOUND) : C == 2 ? this.vpBits[L] & this.ISBOUND && this.vpBits[L] & this.ISDONE ? this.vpBits[L] &= ~this.ISBOUND : this.vpBits[L] & this.ISBOUND && !(this.vpBits[L] & this.ISDONE) && (this.vpBits[L] |= this.ISDONE) : C == 3 && (this.vpBits[L] &= ~this.ISBOUND); + } + marchingcube(C) { + this.marchingcubeinit(C), this.verts = [], this.faces = [], u.MarchingCube.march(this.vpBits, this.verts, this.faces, { + smooth: 1, + nX: this.pLength, + nY: this.pWidth, + nZ: this.pHeight + }); + let L = this.pWidth * this.pHeight; + for (let D = 0, r = this.verts.length; D < r; D++) + this.verts[D].atomid = this.vpAtomID[this.verts[D].x * L + this.pHeight * this.verts[D].y + this.verts[D].z]; + u.MarchingCube.laplacianSmooth(1, this.verts, this.faces); + } + } + u.MarchingCube = new o(); + } + ), + /***/ + "./src/VolumeData.ts": ( + /*!***************************!*\ + !*** ./src/VolumeData.ts ***! + \***************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + VolumeData: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ./utilities */ + "./src/utilities.ts" + ), g = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), _ = e( + /*! ./parsers/VASP */ + "./src/parsers/VASP.ts" + ), x = e( + /*! ./parsers/CUBE */ + "./src/parsers/CUBE.ts" + ), o = e( + /*! pako */ + "./node_modules/pako/dist/pako.esm.mjs" + ); + class p { + constructor(u, A, C) { + 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(b) { + var f = b / (this.size.y * this.size.z), c = b % (this.size.y * this.size.z), t = b % this.size.z; + return f *= this.unit.x, c *= this.unit.y, t *= this.unit.z, f += this.origin.x, c += this.origin.y, t += this.origin.z, { x: f, y: c, z: t }; + }, this.vasp = function(b) { + var f = b.replace(/^\s+/, "").split(/[\n\r]/), c = (0, _.VASP)(b)[0], t = c.length; + if (t == 0) { + console.log("No good formating of CHG or CHGCAR file, not atomic information provided in the file."), this.data = []; + return; + } + var a = 1.889725992, h = 0.036749309, M = parseFloat(f[1]), w; + w = f[2].replace(/^\s+/, "").split(/\s+/); + var S = new g.Vector3(parseFloat(w[0]), parseFloat(w[1]), parseFloat(w[2])).multiplyScalar(M * a); + w = f[3].replace(/^\s+/, "").split(/\s+/); + var T = new g.Vector3(parseFloat(w[0]), parseFloat(w[1]), parseFloat(w[2])).multiplyScalar(M * a); + w = f[4].replace(/^\s+/, "").split(/\s+/); + var R = new g.Vector3(parseFloat(w[0]), parseFloat(w[1]), parseFloat(w[2])).multiplyScalar(M * a), z = S.x * (T.y * R.z - R.y * T.z) - T.x * (S.y * R.z - R.y * S.z) + R.x * (S.y * T.z - T.y * S.z); + z = Math.abs(z) / Math.pow(a, 3); + var P = 1 / z; + f.splice(0, 8 + t + 1); + var B = f[0].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), U = Math.abs(parseFloat(B[0])), F = Math.abs(parseFloat(B[1])), $ = Math.abs(parseFloat(B[2])), W = this.origin = new g.Vector3(0, 0, 0); + this.size = { x: U, y: F, z: $ }, this.unit = new g.Vector3(S.x, T.y, R.z), S = S.multiplyScalar(1 / (a * U)), T = T.multiplyScalar(1 / (a * F)), R = R.multiplyScalar(1 / (a * $)), (S.y != 0 || S.z != 0 || T.x != 0 || T.z != 0 || R.x != 0 || R.y != 0) && (this.matrix = new g.Matrix4(S.x, T.x, R.x, 0, S.y, T.y, R.y, 0, S.z, T.z, R.z, 0, 0, 0, 0, 1), this.matrix = this.matrix.multiplyMatrices(this.matrix, new g.Matrix4().makeTranslation(W.x, W.y, W.z)), this.origin = new g.Vector3(0, 0, 0), this.unit = new g.Vector3(1, 1, 1)), f.splice(0, 1); + var N = f.join(" "); + N = N.replace(/^\s+/, ""); + var G = N.split(/[\s\r]+/); + G.splice(U * F * $ + 1); + for (var k = Float32Array.from(G, parseFloat), j = 0; j < k.length; j++) + k[j] = k[j] * P * h; + this.data = k; + }, this.dx = function(b) { + var f = b.split(/[\n\r]+/), c, t = /gridpositions\s+counts\s+(\d+)\s+(\d+)\s+(\d+)/, a = /^origin\s+(\S+)\s+(\S+)\s+(\S+)/, h = /^delta\s+(\S+)\s+(\S+)\s+(\S+)/, M = /data follows/, w = 0; + for (w = 0; w < f.length; w++) { + var S = f[w]; + if (c = t.exec(S)) { + var T = parseInt(c[1]), R = parseInt(c[2]), z = parseInt(c[3]); + this.size = { x: T, y: R, z }; + } else if (c = h.exec(S)) { + var P = parseFloat(c[1]); + if ((parseFloat(c[2]) != 0 || parseFloat(c[3]) != 0) && console.log("Non-orthogonal delta matrix not currently supported in dx format"), w += 1, S = f[w], c = h.exec(S), c == null) { + console.log("Parse error in dx delta matrix"); + return; + } + var B = parseFloat(c[2]); + if ((parseFloat(c[1]) != 0 || parseFloat(c[3]) != 0) && console.log("Non-orthogonal delta matrix not currently supported in dx format"), w += 1, S = f[w], c = h.exec(S), c == null) { + console.log("Parse error in dx delta matrix"); + return; + } + var U = parseFloat(c[3]); + (parseFloat(c[1]) != 0 || parseFloat(c[2]) != 0) && console.log("Non-orthogonal delta matrix not currently supported in dx format"), this.unit = new g.Vector3(P, B, U); + } else if (c = a.exec(S)) { + var F = parseFloat(c[1]), $ = parseFloat(c[2]), W = parseFloat(c[3]); + this.origin = new g.Vector3(F, $, W); + } else if (c = M.exec(S)) + break; + } + if (w += 1, !this.size || !this.origin || !this.unit || !this.size) { + console.log("Error parsing dx format"); + return; + } + var N = f.splice(w).join(" "), G = N.split(/[\s\r]+/); + this.data = Float32Array.from(G, parseFloat); + }, A = A.toLowerCase(), /\.gz$/.test(A)) { + A = A.replace(/\.gz$/, ""); + try { + this[A] && this.isbinary.has(A) ? (typeof u == "string" && (u = (0, l.base64ToArray)(u)), u = (0, o.inflate)(u)) : u = new TextDecoder("utf-8").decode((0, o.inflate)(u)); + } catch (b) { + console.log(b); + } + } + if (this[A] && (this.isbinary.has(A) && typeof u == "string" && (u = (0, l.base64ToArray)(u)), this[A](u)), C) { + if (C.negate) + for (let b = 0, f = this.data.length; b < f; b++) + this.data[b] = -this.data[b]; + if (C.normalize) { + var L = 0; + for (let b = 0, f = this.data.length; b < f; b++) + L += this.data[b]; + var D = L / this.data.length; + L = 0; + for (let b = 0, f = this.data.length; b < f; b++) { + var r = this.data[b] - D; + L += r * r; + } + var n = L / this.data.length; + for (let b = 0, f = this.data.length; b < f; b++) + this.data[b] = (this.data[b] - D) / n; + } + } + } + /** + * @function $3Dmol.VolumeData.getIndex + * @param {number} x,y,z - the coordinates + * @returns - index into flat array closest to provided coordinate; -1 if invalid + */ + getIndex(u, A, C) { + if (this.matrix) { + this.inversematrix == null && (this.inversematrix = new g.Matrix4().getInverse(this.matrix)); + var L = new g.Vector3(u, A, C); + L = L.applyMatrix4(this.inversematrix), u = L.x, A = L.y, C = L.z; + } else + u -= this.origin.x, A -= this.origin.y, C -= this.origin.z, u /= this.unit.x, A /= this.unit.y, C /= this.unit.z; + return u = Math.round(u), A = Math.round(A), C = Math.round(C), u < 0 || u >= this.size.x || A < 0 || A >= this.size.y || C < 0 || C >= this.size.z ? -1 : u * this.size.y * this.size.z + A * this.size.z + C; + } + /** + * @function $3Dmol.VolumeData.getVal + * @param {number} x,y,z - the coordinates + * @returns - value closest to provided coordinate; zero if coordinate invalid + */ + getVal(u, A, C) { + let L = this.getIndex(u, A, C); + return L < 0 ? 0 : this.data[L]; + } + // parse cube data + cube(u) { + var A = u.split(/\r?\n/); + if (!(A.length < 6)) { + var C = (0, x.CUBE)(u, {}).modelData[0].cryst, L = A[2].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), D = parseFloat(L[0]), r = Math.abs(D); + this.origin = C.origin, this.size = C.size, this.unit = C.unit, this.matrix = C.matrix4; + var n = 6; + D < 0 && n++; + var b = A.splice(r + n).join(" "); + b = b.replace(/^\s+/, ""); + var f = b.split(/[\s\r]+/); + this.data = Float32Array.from(f, parseFloat); + } + } + //parse cp4 files + ccp4(u) { + var A = {}; + u = new Int8Array(u); + var C = new Int32Array(u.buffer, 0, 56), L = new Float32Array(u.buffer, 0, 56), D = new DataView(u.buffer); + if (A.MAP = String.fromCharCode(D.getUint8(208), D.getUint8(209), D.getUint8(210), D.getUint8(211)), A.MACHST = [D.getUint8(212), D.getUint8(213)], A.MACHST[0] === 17 && A.MACHST[1] === 17) + for (var r = u.byteLength, n = 0; n < r; n += 4) + D.setFloat32(n, D.getFloat32(n), !0); + A.NX = C[0], A.NY = C[1], A.NZ = C[2], A.MODE = C[3], A.NXSTART = C[4], A.NYSTART = C[5], A.NZSTART = C[6], A.MX = C[7], A.MY = C[8], A.MZ = C[9], A.xlen = L[10], A.ylen = L[11], A.zlen = L[12], A.alpha = L[13], A.beta = L[14], A.gamma = L[15], A.MAPC = C[16], A.MAPR = C[17], A.MAPS = C[18], A.DMIN = L[19], A.DMAX = L[20], A.DMEAN = L[21], A.ISPG = C[22], A.NSYMBT = C[23], A.LSKFLG = C[24], A.originX = L[49], A.originY = L[50], A.originZ = L[51], A.ARMS = L[54]; + var b = A, f = [ + b.xlen, + 0, + 0 + ], c = [ + b.ylen * Math.cos(Math.PI / 180 * b.gamma), + b.ylen * Math.sin(Math.PI / 180 * b.gamma), + 0 + ], t = [ + b.zlen * Math.cos(Math.PI / 180 * b.beta), + b.zlen * (Math.cos(Math.PI / 180 * b.alpha) - Math.cos(Math.PI / 180 * b.gamma) * Math.cos(Math.PI / 180 * b.beta)) / Math.sin(Math.PI / 180 * b.gamma), + 0 + ]; + t[2] = Math.sqrt(b.zlen * b.zlen * Math.sin(Math.PI / 180 * b.beta) * Math.sin(Math.PI / 180 * b.beta) - t[1] * t[1]); + var a = [0, f, c, t], h = [0, b.MX, b.MY, b.MZ], M = [0, b.MAPC, b.MAPR, b.MAPS]; + this.matrix = new g.Matrix4(), this.matrix.set(a[M[1]][0] / h[M[1]], a[M[2]][0] / h[M[2]], a[M[3]][0] / h[M[3]], 0, a[M[1]][1] / h[M[1]], a[M[2]][1] / h[M[2]], a[M[3]][1] / h[M[3]], 0, a[M[1]][2] / h[M[1]], a[M[2]][2] / h[M[2]], a[M[3]][2] / h[M[3]], 0, 0, 0, 0, 1), this.matrix = this.matrix.multiplyMatrices(this.matrix, new g.Matrix4().makeTranslation(b.NXSTART + b.originX, b.NYSTART + b.originY, b.NZSTART + b.originZ)), this.origin = new g.Vector3(0, 0, 0), this.unit = new g.Vector3(1, 1, 1), this.size = { x: A.NX, y: A.NY, z: A.NZ }, this.dimensionorder = [A.MAPC, A.MAPR, A.MAPS]; + var w = new Float32Array(u.buffer, 1024 + A.NSYMBT), S = A.NX, T = A.NY, R = A.NZ; + this.data = new Float32Array(S * T * R); + for (let z = 0; z < S; z++) + for (let P = 0; P < T; P++) + for (let B = 0; B < R; B++) + this.data[(z * T + P) * R + B] = w[(B * T + P) * S + z]; + } + } + } + ), + /***/ + "./src/VolumetricRender.ts": ( + /*!*********************************!*\ + !*** ./src/VolumetricRender.ts ***! + \*********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + GLVolumetricRender: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ./WebGL/shapes */ + "./src/WebGL/shapes/index.ts" + ), g = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), _ = e( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), x = e( + /*! ./colors */ + "./src/colors.ts" + ), o = e( + /*! ./GLShape */ + "./src/GLShape.ts" + ); + class p { + static interpolateArray(u, A) { + function C(t, a, h) { + return t + (a - t) * h; + } + var L = [], D = (u.length - 1) / (A - 1); + L[0] = u[0]; + for (var r = 1; r < A - 1; r++) { + var n = r * D, b = Math.floor(n), f = Math.ceil(n), c = n - b; + L[r] = C(u[b], u[f], c); + } + return L[A - 1] = u[u.length - 1], L; + } + constructor(u, A) { + this.hidden = !1, this.boundingSphere = new l.Sphere(), this.renderedShapeObj = null, this.shapeObj = null, this.subsamples = 5, this.data = null, this.transferfunctionbuffer = [], this.min = 0, this.max = 0, A = A || {}; + var C = Object.assign([], A.transferfn); + this.subsamples = A.subsamples || 5; + let L = 256; + C.forEach(function(S) { + S.value = parseFloat(S.value); + }), C.sort(function(S, T) { + return S.value - T.value; + }), this.min = C[0].value, C.length == 0 && C.push(C[0]), this.max = C[C.length - 1].value; + var D, r, n, b, f, c, t, a, h, M; + for (let S = 0; S < C.length - 1; S++) + if (n = x.CC.color(C[S].color), b = x.CC.color(C[S + 1].color), h = C[S].opacity, M = C[S + 1].opacity, D = Math.floor((C[S].value - this.min) * L / (this.max - this.min)), r = Math.floor((C[S + 1].value - this.min) * L / (this.max - this.min)), D != r) { + f = p.interpolateArray([n.r * 255, b.r * 255], r - D), c = p.interpolateArray([n.g * 255, b.g * 255], r - D), t = p.interpolateArray([n.b * 255, b.b * 255], r - D), a = p.interpolateArray([h * 255, M * 255], r - D); + for (let T = 0; T < f.length; T++) + this.transferfunctionbuffer.push(f[T]), this.transferfunctionbuffer.push(c[T]), this.transferfunctionbuffer.push(t[T]), this.transferfunctionbuffer.push(a[T]); + } + if (this.transferfunctionbuffer = new Uint8ClampedArray(this.transferfunctionbuffer), u.matrix) { + let S = new g.Vector3(0, 0, 0), T = new g.Vector3(u.size.x, u.size.y, u.size.z), R = new g.Vector3(1, 1, 1); + S.applyMatrix4(u.matrix), T.applyMatrix4(u.matrix), R.applyMatrix4(u.matrix).sub(S), this.extent = [[S.x, S.y, S.z], [T.x, T.y, T.z]]; + for (let U = 1; U < 7; U++) + T.x = U & 1 ? u.size.x : 0, T.y = U & 2 ? u.size.y : 0, T.z = U & 4 ? u.size.z : 0, T.applyMatrix4(u.matrix), this.extent[0][0] = Math.min(this.extent[0][0], T.x), this.extent[0][1] = Math.min(this.extent[0][1], T.y), this.extent[0][2] = Math.min(this.extent[0][2], T.z), this.extent[1][0] = Math.max(this.extent[1][0], T.x), this.extent[1][1] = Math.max(this.extent[1][1], T.y), this.extent[1][2] = Math.max(this.extent[1][2], T.z); + let z = T.x - S.x, P = T.y - S.y, B = T.z - S.z; + this.maxdepth = Math.sqrt(z * z + P * P + B * B), this.minunit = Math.min(Math.min(R.x, R.y), R.z), this.texmatrix = new g.Matrix4().identity().scale({ x: u.size.x, y: u.size.y, z: u.size.z }), this.texmatrix = this.texmatrix.multiplyMatrices(u.matrix, this.texmatrix), this.texmatrix = this.texmatrix.getInverse(this.texmatrix); + } else { + this.texmatrix = new g.Matrix4().identity(); + let S = u.unit.x * u.size.x, T = u.unit.y * u.size.y, R = u.unit.z * u.size.z; + this.texmatrix.makeTranslation(-u.origin.x / S, -u.origin.y / T, -u.origin.z / R), this.texmatrix.scale({ x: 1 / S, y: 1 / T, z: 1 / R }), this.minunit = Math.min(Math.min(u.unit.x, u.unit.y), u.unit.z), this.extent = [ + [u.origin.x, u.origin.y, u.origin.z], + [u.origin.x + S, u.origin.y + T, u.origin.z + R] + ], this.maxdepth = Math.sqrt(S * S + T * T + R * R); + } + var w = new o.GLShape({}); + if (w.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 = w.finalize(), this.boundingSphere.center = new g.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, A.coords !== void 0 && A.seldist !== void 0) { + let S = new Uint8Array(u.data.length), T = A.seldist, R = T * T; + for (let z = 0, P = A.coords.length; z < P; z++) { + let B = A.coords[z], U = B.x - T, F = B.y - T, $ = B.z - T, W = B.x + T, N = B.y + T, G = B.z + T; + if (u.getIndex(U, F, $) >= 0 || u.getIndex(W, N, G) >= 0) + for (let k = U; k < W; k += this.minunit) + for (let j = F; j < N; j += this.minunit) + for (let Q = $; Q < G; Q += this.minunit) { + let ie = u.getIndex(k, j, Q); + ie >= 0 && !S[ie] && (k - B.x) * (k - B.x) + (j - B.y) * (j - B.y) + (Q - B.z) * (Q - B.z) < R && (S[ie] = 1); + } + } + for (let z = 0, P = u.data.length; z < P; z++) + S[z] == 0 && (u.data[z] = 1 / 0); + } + this.data = u; + } + /** + * Initialize webgl objects for rendering + * @param {Object3D} group + * + */ + globj(u) { + if (this.renderedShapeObj && (u.remove(this.renderedShapeObj), this.renderedShapeObj = null), !this.hidden) { + this.shapeObj = new _.Object3D(); + var A = null, C = new _.Texture(this.data, !0), L = new _.Texture(this.transferfunctionbuffer, !1); + C.needsUpdate = !0, L.needsUpdate = !0, L.flipY = !1, A = new _.VolumetricMaterial({ + transferfn: L, + transfermin: this.min, + transfermax: this.max, + map: C, + extent: this.extent, + maxdepth: this.maxdepth, + texmatrix: this.texmatrix, + unit: this.minunit, + subsamples: this.subsamples + }); + var D = new _.Mesh(this.geo, A); + this.shapeObj.add(D), this.renderedShapeObj = this.shapeObj.clone(), u.add(this.renderedShapeObj); + } + } + removegl(u) { + this.renderedShapeObj && (this.renderedShapeObj.geometry !== void 0 && this.renderedShapeObj.geometry.dispose(), this.renderedShapeObj.material !== void 0 && this.renderedShapeObj.material.dispose(), u.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 ***! + \*****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Camera: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./core */ + "./src/WebGL/core/index.ts" + ), g = e( + /*! ./math */ + "./src/WebGL/math/index.ts" + ); + class _ extends l.Object3D { + constructor(o = 50, p = 1, E = 0.1, u = 2e3, A = !1) { + super(), this.projectionMatrix = new g.Matrix4(), this.projectionMatrixInverse = new g.Matrix4(), this.matrixWorldInverse = new g.Matrix4(), this.fov = o, this.aspect = p, this.near = E, this.far = u; + var C = this.position.z; + this.right = C * Math.tan(Math.PI / 180 * o), this.left = -this.right, this.top = this.right / this.aspect, this.bottom = -this.top, this.ortho = !!A, this.updateProjectionMatrix(); + } + lookAt(o) { + this.matrix.lookAt(this.position, o, this.up), this.rotationAutoUpdate && (this.useQuaternion === !1 && this.rotation instanceof g.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 ***! + \**************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Fog: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../colors */ + "./src/colors.ts" + ); + class g { + constructor(x, o = 1, p = 1e3) { + this.name = "", this.color = new l.Color(x), this.near = o, this.far = p; + } + clone() { + return new g(this.color.getHex(), this.near, this.far); + } + } + } + ), + /***/ + "./src/WebGL/Renderer.ts": ( + /*!*******************************!*\ + !*** ./src/WebGL/Renderer.ts ***! + \*******************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Renderer: () => ( + /* binding */ + L + ) + /* harmony export */ + }); + var l = e( + /*! ./Camera */ + "./src/WebGL/Camera.ts" + ), g = e( + /*! ./constants/Sides */ + "./src/WebGL/constants/Sides.ts" + ), _ = e( + /*! ./constants/TextureConstants */ + "./src/WebGL/constants/TextureConstants.ts" + ), x = e( + /*! ./core */ + "./src/WebGL/core/index.ts" + ), o = e( + /*! ../colors */ + "./src/colors.ts" + ), p = e( + /*! ./materials */ + "./src/WebGL/materials/index.ts" + ), E = e( + /*! ./math */ + "./src/WebGL/math/index.ts" + ), u = e( + /*! ./objects */ + "./src/WebGL/objects/index.ts" + ), A = e( + /*! ./shaders */ + "./src/WebGL/shaders/index.ts" + ), C = e( + /*! ./SpritePlugin */ + "./src/WebGL/SpritePlugin.ts" + ); + class L { + constructor(r) { + 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 C.SpritePlugin(), this._screenshader = null, this._vertexattribpos = null, this._screenQuadVBO = null, this._fb = null, this._targetTexture = null, this._depthTexture = null, r = r || {}, this.row = r.row, this.col = r.col, this.rows = r.rows, this.cols = r.cols, this._canvas = r.canvas !== void 0 ? r.canvas : document.createElement("canvas"), this._precision = r.precision !== void 0 ? r.precision : "highp", this._alpha = r.alpha !== void 0 ? r.alpha : !0, this._premultipliedAlpha = r.premultipliedAlpha !== void 0 ? r.premultipliedAlpha : !0, this._antialias = r.antialias !== void 0 ? r.antialias : !1, this._stencil = r.stencil !== void 0 ? r.stencil : !0, this._preserveDrawingBuffer = r.preserveDrawingBuffer !== void 0 ? r.preserveDrawingBuffer : !1, this._clearColor = r.clearColor !== void 0 ? new o.Color(r.clearColor) : new o.Color(0), this._clearAlpha = r.clearAlpha !== void 0 ? r.clearAlpha : 0, this._outlineMaterial = new p.MeshOutlineMaterial(r.outline), this._outlineSphereImposterMaterial = new p.SphereImposterOutlineMaterial(r.outline), this._outlineStickImposterMaterial = new p.StickImposterOutlineMaterial(r.outline), this._outlineEnabled = !!r.outline, this.domElement = this._canvas, this._canvas.id = r.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; + } + getCanvas() { + return this._canvas; + } + isLost() { + return this._gl.isContextLost(); + } + getPrecision() { + return this._precision; + } + setClearColorHex(r, n) { + this._clearColor.setHex(r), this._clearAlpha = n, this._gl.clearColor(this._clearColor.r, this._clearColor.g, this._clearColor.b, this._clearAlpha); + } + enableOutline(r) { + this._outlineMaterial = new p.MeshOutlineMaterial(r), this._outlineSphereImposterMaterial = new p.SphereImposterOutlineMaterial(r), this._outlineStickImposterMaterial = new p.StickImposterOutlineMaterial(r), this._outlineEnabled = !0; + } + disableOutline() { + this._outlineEnabled = !1; + } + setViewport() { + if (this.rows != null && this.cols != null && this.row != null && this.col != null) { + var r = this._canvas.width / this.cols, n = this._canvas.height / this.rows; + this._viewportWidth = r, this._viewportHeight = n, this._gl.enable(this._gl.SCISSOR_TEST), this._gl.scissor(r * this.col, n * this.row, r, n), this._gl.viewport(r * this.col, n * this.row, r, n); + } + } + setSize(r, n) { + 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 b = r / this.cols, f = n / this.rows; + this._canvas.width = r * this.devicePixelRatio, this._canvas.height = n * this.devicePixelRatio, this._viewportWidth = b * this.devicePixelRatio, this._viewportHeight = f * this.devicePixelRatio, this._canvas.style.width = r + "px", this._canvas.style.height = n + "px", this.setViewport(); + } else + this._viewportWidth = this._canvas.width = r * this.devicePixelRatio, this._viewportHeight = this._canvas.height = n * this.devicePixelRatio, this._canvas.style.width = r + "px", this._canvas.style.height = n + "px", this._gl.viewport(0, 0, this._gl.drawingBufferWidth, this._gl.drawingBufferHeight); + this.initFrameBuffer(); + } + clear(r, n, b) { + var f = 0; + (r === void 0 || r) && (f |= this._gl.COLOR_BUFFER_BIT), (n === void 0 || n) && (f |= this._gl.DEPTH_BUFFER_BIT), (b === void 0 || b) && (f |= this._gl.STENCIL_BUFFER_BIT), this._gl.clear(f); + } + clearTarget(r, n, b) { + this.clear(r, n, b); + } + setMaterialFaces(r, n) { + var b = r.side === g.DoubleSide, f = r.side === g.BackSide; + r.imposter || (f = n ? !f : f), this._oldDoubleSided !== b && (b ? this._gl.disable(this._gl.CULL_FACE) : this._gl.enable(this._gl.CULL_FACE), this._oldDoubleSided = b), this._oldFlipSided !== f && (f ? this._gl.frontFace(this._gl.CW) : this._gl.frontFace(this._gl.CCW), this._oldFlipSided = f), this._gl.cullFace(this._gl.BACK); + } + setDepthTest(r) { + this._oldDepthTest !== r && (r ? this._gl.enable(this._gl.DEPTH_TEST) : this._gl.disable(this._gl.DEPTH_TEST), this._oldDepthTest = r); + } + setDepthWrite(r) { + this._oldDepthWrite !== r && (this._gl.depthMask(r), this._oldDepthWrite = r); + } + setBlending(r) { + r ? (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(r, n, b, f) { + r.addEventListener("dispose", this.onMaterialDispose.bind(this)); + var c, t; + if (t = r.shaderID, t) { + var a = A.ShaderLib[t]; + r.vertexShader = a.vertexShader, r.fragmentShader = a.fragmentShader, r.uniforms = A.ShaderUtils.clone(a.uniforms); + } + c = { + wireframe: r.wireframe, + fragdepth: r.imposter, + volumetric: r.volumetric + }, r.program = this.buildProgram(r.fragmentShader, r.vertexShader, r.uniforms, c); + } + renderBuffer(r, n, b, f, c, t) { + if (f.visible) { + var a, h; + if (a = this.setProgram(r, n, b, f, t, this), !!a) { + h = a.attributes; + var M = !1, w = f.wireframe ? 1 : 0, S = c.id * 16777215 + a.id * 2 + w; + S !== this._currentGeometryGroupHash && (this._currentGeometryGroupHash = S, M = !0), M && (this.disableAttributes(), h.position >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, c.__webglVertexBuffer), this.enableAttribute(h.position), this._gl.vertexAttribPointer(h.position, 3, this._gl.FLOAT, !1, 0, 0)), h.color >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, c.__webglColorBuffer), this.enableAttribute(h.color), this._gl.vertexAttribPointer(h.color, 3, this._gl.FLOAT, !1, 0, 0)), h.normal >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, c.__webglNormalBuffer), this.enableAttribute(h.normal), this._gl.vertexAttribPointer(h.normal, 3, this._gl.FLOAT, !1, 0, 0)), h.offset >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, c.__webglOffsetBuffer), this.enableAttribute(h.offset), this._gl.vertexAttribPointer(h.offset, 3, this._gl.FLOAT, !1, 0, 0)), h.radius >= 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, c.__webglRadiusBuffer), this.enableAttribute(h.radius), this._gl.vertexAttribPointer(h.radius, 1, this._gl.FLOAT, !1, 0, 0))); + var T, R; + if (t instanceof u.Mesh) { + if (f.shaderID === "instanced") { + var z = f.sphere.geometryGroups[0]; + M && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, c.__webglVertexBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, z.vertexArray, this._gl.STATIC_DRAW), this._gl.bindBuffer(this._gl.ARRAY_BUFFER, c.__webglNormalBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, z.normalArray, this._gl.STATIC_DRAW), this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, c.__webglFaceBuffer), this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, z.faceArray, this._gl.STATIC_DRAW)), T = z.faceidx, this._extInstanced.vertexAttribDivisorANGLE(h.offset, 1), this._extInstanced.vertexAttribDivisorANGLE(h.radius, 1), this._extInstanced.vertexAttribDivisorANGLE(h.color, 1), this._extInstanced.drawElementsInstancedANGLE(this._gl.TRIANGLES, T, this._gl.UNSIGNED_SHORT, 0, c.radiusArray.length), this._extInstanced.vertexAttribDivisorANGLE(h.offset, 0), this._extInstanced.vertexAttribDivisorANGLE(h.radius, 0), this._extInstanced.vertexAttribDivisorANGLE(h.color, 0); + } else + f.wireframe ? (R = c.lineidx, this.setLineWidth(f.wireframeLinewidth), M && this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, c.__webglLineBuffer), this._gl.drawElements(this._gl.LINES, R, this._gl.UNSIGNED_SHORT, 0)) : (T = c.faceidx, M && this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, c.__webglFaceBuffer), this._gl.drawElements(this._gl.TRIANGLES, T, this._gl.UNSIGNED_SHORT, 0)); + this.info.render.calls++, this.info.render.vertices += T, this.info.render.faces += T / 3; + } else + t instanceof u.Line && (R = c.vertices, this.setLineWidth(f.linewidth), this._gl.drawArrays(this._gl.LINES, 0, R), this.info.render.calls++); + } + } + } + render(r, n, b) { + if (!(n instanceof l.Camera)) { + console.error("Renderer.render: camera is not an instance of Camera."); + return; + } + var f, c, t, a, h, M = r.__lights, w = r.fog; + this._currentMaterialId = -1, this._lightsNeedUpdate = !0, this.autoUpdateScene && r.updateMatrixWorld(), n.parent === void 0 && n.updateMatrixWorld(), n.matrixWorldInverse.getInverse(n.matrixWorld), this._projScreenMatrix.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this.autoUpdateObjects && this.initWebGLObjects(r), 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 || b) && (this._gl.clearColor(this._clearColor.r, this._clearColor.g, this._clearColor.b, this._clearAlpha), this.clear(this.autoClearColor, this.autoClearDepth, this.autoClearStencil)), h = r.__webglObjects; + var S = !1; + for (f = 0, c = h.length; f < c; f++) + t = h[f], a = t.object, t.render = !1, a.visible && (this.setupMatrices(a, n), this.unrollBufferMaterial(t), t.render = !0, t.volumetric && (S = !0)); + var T = null; + this.setBlending(!1), this.renderObjects(r.__webglObjects, !0, "opaque", n, M, w, !1, T), this.renderSprites(r, n, !1), this.renderObjects(r.__webglObjects, !0, "blank", n, M, w, !0, T), this.renderObjects(r.__webglObjects, !1, "transparent", n, M, w, !0, T), S && this._fb && (this.reinitFrameBuffer(), this.renderObjects(r.__webglObjects, !1, "volumetric", n, M, w, !0, T)), this.renderFrameBuffertoScreen(), this.setDepthTest(!0), this.setDepthWrite(!0), this.renderSprites(r, n, !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 r = this._viewportWidth, n = this._viewportHeight; + this._gl.enable(this._gl.SCISSOR_TEST), this._gl.scissor(0, 0, r, n), this._gl.viewport(0, 0, r, n), this._gl.bindTexture(this._gl.TEXTURE_2D, this._targetTexture), this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, r, n, 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, r, n, 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 r = this._viewportWidth, n = this._viewportHeight; + this._gl.enable(this._gl.SCISSOR_TEST), this._gl.scissor(0, 0, r, n), this._gl.viewport(0, 0, r, n), this._targetTexture = this._gl.createTexture(), this._depthTexture = this._gl.createTexture(), this._fb = this._gl.createFramebuffer(); + var b = A.ShaderLib.screen; + this._screenshader = this.buildProgram(b.fragmentShader, b.vertexShader, b.uniforms, {}), this._vertexattribpos = this._gl.getAttribLocation(this._screenshader, "vertexPosition"); + var f = [ + // 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(f), 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(r) { + if (r.__webglObjects || (r.__webglObjects = [], r.__webglObjectsImmediate = [], r.__webglSprites = [], r.__webglFlares = []), r.__objectsAdded.length) { + for (; r.__objectsAdded.length; ) + this.addObject(r.__objectsAdded[0], r), r.__objectsAdded.splice(0, 1); + this._currentGeometryGroupHash = -1; + } + for (; r.__objectsRemoved.length; ) + this.removeObject(r.__objectsRemoved[0], r), r.__objectsRemoved.splice(0, 1); + for (var n = 0, b = r.__webglObjects.length; n < b; n++) + this.updateObject(r.__webglObjects[n].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(r, n) { + (r == null || n == null) && (r = this._canvas.width, n = this._canvas.height); + var b = r / n; + if (this.rows != null && this.cols != null && this.row != null && this.col != null) { + var f = r / this.cols, c = n / this.rows; + b = f / c; + } + return b; + } + setTexture(r, n, b) { + if (r.needsUpdate) { + r.__webglInit || (r.__webglInit = !0, r.addEventListener("dispose", this.onTextureDispose.bind(this)), r.__webglTexture = this._gl.createTexture(), this.info.memory.textures++), this._gl.activeTexture(this._gl.TEXTURE0 + n); + var f = b ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D; + this._gl.bindTexture(f, r.__webglTexture), this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, r.flipY), this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r.premultiplyAlpha), this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, r.unpackAlignment), this._gl.pixelStorei(this._gl.PACK_ALIGNMENT, r.unpackAlignment); + var c = this.paramToGL(r.format), t = this.paramToGL(r.type); + if (b) + this.setTextureParameters(this._gl.TEXTURE_3D, r), this._gl.texImage3D(this._gl.TEXTURE_3D, 0, this._gl.R32F, r.image.size.z, r.image.size.y, r.image.size.x, 0, this._gl.RED, this._gl.FLOAT, r.image.data); + else { + var a = r.image, h = a.width, M = a.height; + typeof h > "u" && (h = a.length, c == this._gl.RGBA && (h /= 4), M = 1), this.setTextureParameters(this._gl.TEXTURE_2D, r), this.isWebGL1() ? this._gl.texImage2D(this._gl.TEXTURE_2D, 0, c, c, t, r.image) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, c, h, M, 0, c, t, r.image); + } + r.needsUpdate = !1, r.onUpdate && r.onUpdate(); + } else + this._gl.activeTexture(this._gl.TEXTURE0 + n), b ? this._gl.bindTexture(this._gl.TEXTURE_3D, r.__webglTexture) : this._gl.bindTexture(this._gl.TEXTURE_2D, r.__webglTexture); + } + supportsVolumetric() { + return !this.isWebGL1(); + } + enableAttribute(r) { + this._enabledAttributes[r] || (this._gl.enableVertexAttribArray(r), this._enabledAttributes[r] = !0); + } + disableAttributes() { + for (let r in this._enabledAttributes) + this._enabledAttributes[r] && (this._gl.disableVertexAttribArray(r), this._enabledAttributes[r] = !1); + } + setPolygonOffset(r, n, b) { + this._oldPolygonOffset !== r && (r ? this._gl.enable(this._gl.POLYGON_OFFSET_FILL) : this._gl.disable(this._gl.POLYGON_OFFSET_FILL)); + } + setLineWidth(r) { + r !== this._oldLineWidth && (this._gl.lineWidth(r), this._oldLineWidth = r); + } + deallocateGeometry(r) { + if (r.__webglInit = void 0, r.__webglVertexBuffer !== void 0 && this._gl.deleteBuffer(r.__webglVertexBuffer), r.__webglColorBuffer !== void 0 && this._gl.deleteBuffer(r.__webglColorBuffer), r.geometryGroups !== void 0) + for (var n = 0, b = r.groups; n < b; n++) { + var f = r.geometryGroups[n]; + f.__webglVertexBuffer !== void 0 && this._gl.deleteBuffer(f.__webglVertexBuffer), f.__webglColorBuffer !== void 0 && this._gl.deleteBuffer(f.__webglColorBuffer), f.__webglNormalBuffer !== void 0 && this._gl.deleteBuffer(f.__webglNormalBuffer), f.__webglFaceBuffer !== void 0 && this._gl.deleteBuffer(f.__webglFaceBuffer), f.__webglLineBuffer !== void 0 && this._gl.deleteBuffer(f.__webglLineBuffer); + } + } + deallocateMaterial(r) { + var n = r.program; + if (n !== void 0) { + r.program = void 0; + var b, f, c, t = !1; + for (b = 0, f = this._programs.length; b < f; b++) + if (c = this._programs[b], c.program === n) { + c.usedTimes--, c.usedTimes === 0 && (t = !0); + break; + } + if (t === !0) { + var a = []; + for (b = 0, f = this._programs.length; b < f; b++) + c = this._programs[b], c.program !== n && a.push(c); + this._programs = a, this._gl.deleteProgram(n), this.info.memory.programs--; + } + } + } + deallocateTexture(r) { + if (r.image && r.image.__webglTextureCube) + this._gl.deleteTexture(r.image.__webglTextureCube); + else { + if (!r.__webglInit) + return; + r.__webglInit = !1, this._gl.deleteTexture(r.__webglTexture); + } + } + onGeometryDispose(r) { + var n = r.target; + n.removeEventListener("dispose", this.onGeometryDispose), this.deallocateGeometry(n), this.info.memory.geometries--; + } + onTextureDispose(r) { + var n = r.target; + n.removeEventListener("dispose", this.onTextureDispose), this.deallocateTexture(n), this.info.memory.textures--; + } + onMaterialDispose(r) { + var n = r.target; + n.removeEventListener("dispose", this.onMaterialDispose), this.deallocateMaterial(n); + } + // Compile and return shader + getShader(r, n) { + var b; + return !this.isWebGL1() && !n.startsWith("#version") && (n = n.replace(/gl_FragDepthEXT/g, "gl_FragDepth"), r == "fragment" ? n = n.replace(/varying/g, "in") : n = n.replace(/varying/g, "out"), n = n.replace(/attribute/g, "in"), n = n.replace(/texture2D/g, "texture"), n = n.replace(/\/\/DEFINEFRAGCOLOR/g, "out vec4 glFragColor;"), n = n.replace(/gl_FragColor/g, "glFragColor"), n = `#version 300 es +` + n), r === "fragment" ? b = this._gl.createShader(this._gl.FRAGMENT_SHADER) : r === "vertex" && (b = this._gl.createShader(this._gl.VERTEX_SHADER)), b == null ? null : (this._gl.shaderSource(b, n), this._gl.compileShader(b), this._gl.getShaderParameter(b, this._gl.COMPILE_STATUS) ? b : (console.error(this._gl.getShaderInfoLog(b)), console.error("could not initialize shader"), null)); + } + // Compile appropriate shaders (if necessary) from source code and attach to + // gl program. + buildProgram(r, n, b, f) { + var c, t, a, h, M = []; + M.push(r), M.push(n); + for (c in f) + M.push(c), M.push(f[c]); + for (h = M.join(), c = 0, t = this._programs.length; c < t; c++) { + var w = this._programs[c]; + if (w.code === h) + return w.usedTimes++, w.program; + } + if (this.isWebGL1() && f.volumetric) + throw new Error("Volumetric rendering requires webgl2 which is not supported by your hardware."); + if (a = this._gl.createProgram(), a == null) + return null; + var S = this._precision, T = "precision " + S + " float;", R = [ + f.volumetric ? "#version 300 es" : "", + T + ].join(` +`), z = [ + f.volumetric ? "#version 300 es" : "", + f.fragdepth && this.isWebGL1() ? "#extension GL_EXT_frag_depth: enable" : "", + f.wireframe ? "#define WIREFRAME 1" : "", + T + ].join(` +`), P = this.getShader("fragment", z + r), B = this.getShader("vertex", R + n); + B != null && this._gl.attachShader(a, B), P != null && this._gl.attachShader(a, P), this._gl.linkProgram(a), this._gl.getProgramParameter(a, this._gl.LINK_STATUS) || console.error("Could not initialize shader"), a.uniforms = {}, a.attributes = {}; + var U, F, $; + U = [ + "viewMatrix", + "modelViewMatrix", + "projectionMatrix", + "normalMatrix" + ]; + for (F in b) + U.push(F); + for ($ = 0; $ < U.length; $++) { + var W = U[$]; + a.uniforms[W] = this._gl.getUniformLocation(a, W); + } + for (U = [ + "position", + "normal", + "color", + "lineDistance", + "offset", + "radius" + ], $ = 0; $ < U.length; $++) { + var N = U[$]; + a.attributes[N] = this._gl.getAttribLocation(a, N); + } + return a.id = this._programs_counter++, this._programs.push({ + program: a, + code: h, + usedTimes: 1 + }), this.info.memory.programs = this._programs.length, a; + } + setProgram(r, n, b, f, c, t) { + if (f.needsUpdate && (f.program && this.deallocateMaterial(f), this.initMaterial(f, n, b, c), f.needsUpdate = !1), f.program == null) + return null; + var a = !1, h = f.program, M = h.uniforms, w = f.uniforms; + if (h != this._currentProgram && (this._gl.useProgram(h), this._currentProgram = h, a = !0), f.id != this._currentMaterialId && (this._currentMaterialId = f.id, a = !0), r != this._currentCamera && (this._currentCamera = r, a = !0), this._gl.uniformMatrix4fv(M.projectionMatrix, !1, r.projectionMatrix.elements), this._gl.uniformMatrix4fv(M.modelViewMatrix, !1, c._modelViewMatrix.elements), this._gl.uniformMatrix3fv(M.normalMatrix, !1, c._normalMatrix.elements), a) { + if (w.fogColor.value = b.color, w.fogNear.value = b.near, w.fogFar.value = b.far, f.shaderID.startsWith("lambert") || f.shaderID === "instanced" || f.shaderID.endsWith("imposter")) + this._gl.uniformMatrix4fv(M.viewMatrix, !1, r.matrixWorldInverse.elements), this._lightsNeedUpdate && (this.setupLights(h, n), this._lightsNeedUpdate = !1), w.directionalLightColor.value = this._lights.directional.colors, w.directionalLightDirection.value = this._lights.directional.positions; + else if (f.shaderID.endsWith("outline")) + w.outlineColor.value = f.outlineColor, w.outlineWidth.value = f.outlineWidth, w.outlinePushback.value = f.outlinePushback; + else if (f.shaderID === "volumetric") { + c._modelViewMatrix.getScale(this._direction), this._worldInverse.getInverse(c._modelViewMatrix), this._projInverse.getInverse(r.projectionMatrix), this._textureMatrix.multiplyMatrices(c.material.texmatrix, this._worldInverse), this._gl.uniformMatrix4fv(M.textmat, !1, this._textureMatrix.elements), this._gl.uniformMatrix4fv(M.projinv, !1, this._projInverse.elements); + let S = Math.min(Math.min(this._direction.x, this._direction.y), this._direction.z); + w.step.value = c.material.unit * S, w.maxdepth.value = c.material.maxdepth * S, w.transfermax.value = c.material.transfermax, w.transfermin.value = c.material.transfermin, w.subsamples.value = c.material.subsamples, t.setTexture(c.material.transferfn, 4, !1), t.setTexture(c.material.map, 3, !0), this._gl.activeTexture(this._gl.TEXTURE5), this._gl.bindTexture(this._gl.TEXTURE_2D, this._depthTexture); + } + w.opacity.value = f.opacity, this.loadMaterialUniforms(M, w); + } + return h; + } + loadMaterialUniforms(r, n) { + var b, f, c, t; + for (b in n) + r[b] && (f = n[b].type, c = n[b].value, t = r[b], f === "f" ? this._gl.uniform1f(t, c) : f === "i" ? this._gl.uniform1i(t, c) : f === "fv" ? this._gl.uniform3fv(t, c) : f === "c" ? this._gl.uniform3f(t, c.r, c.g, c.b) : f === "f4" && this._gl.uniform4f(t, c[0], c[1], c[2], c[3])); + } + // Objects adding + addObject(r, n) { + var b, f, c, t; + if (!r.__webglInit && (r.__webglInit = !0, r._modelViewMatrix = new E.Matrix4(), r._normalMatrix = new E.Matrix3(), r.geometry !== void 0 && r.geometry.__webglInit === void 0 && (r.geometry.__webglInit = !0, r.geometry.addEventListener("dispose", this.onGeometryDispose.bind(this))), r instanceof u.Mesh || r instanceof u.Line)) + for (c = r.geometry, b = 0, f = c.geometryGroups.length; b < f; b++) + t = c.geometryGroups[b], t.id = this._geometryGroupCounter++, t.__webglVertexBuffer || (r instanceof u.Mesh ? (this.createMeshBuffers(t), c.elementsNeedUpdate = !0, c.normalsNeedUpdate = !0) : r instanceof u.Line && this.createLineBuffers(t), c.verticesNeedUpdate = !0, c.colorsNeedUpdate = !0); + if (!r.__webglActive) { + if (r instanceof u.Mesh || r instanceof u.Line) + for (c = r.geometry, b = 0, f = c.geometryGroups.length; b < f; b++) + t = c.geometryGroups[b], this.addBuffer(n.__webglObjects, t, r); + else + r instanceof u.Sprite && n.__webglSprites.push(r); + r.__webglActive = !0; + } + } + updateObject(r) { + var n = r.geometry, b; + if (r instanceof u.Mesh || r instanceof u.Line) { + for (var f = 0, c = n.geometryGroups.length; f < c; f++) + b = n.geometryGroups[f], (n.verticesNeedUpdate || n.elementsNeedUpdate || n.colorsNeedUpdate || n.normalsNeedUpdate) && this.setBuffers(b, this._gl.STATIC_DRAW); + n.verticesNeedUpdate = !1, n.elementsNeedUpdate = !1, n.normalsNeedUpdate = !1, n.colorsNeedUpdate = !1, n.buffersNeedUpdate = !1; + } + } + removeObject(r, n) { + r instanceof u.Mesh || r instanceof u.Line ? this.removeInstances(n.__webglObjects, r) : r instanceof u.Sprite && this.removeInstancesDirect(n.__webglSprites, r), r.__webglActive = !1; + } + removeInstances(r, n) { + for (var b = r.length - 1; b >= 0; --b) + r[b].object === n && r.splice(b, 1); + } + removeInstancesDirect(r, n) { + for (var b = r.length - 1; b >= 0; --b) + r[b] === n && r.splice(b, 1); + } + unrollBufferMaterial(r) { + var n = r.object, b = n.material; + if (b.volumetric) + r.opaque = null, r.transparent = null, r.volumetric = b; + else if (b.transparent) { + if (r.opaque = null, r.volumetric = null, r.transparent = b, !b.wireframe) { + var f = b.clone(); + f.opacity = 0, r.blank = f; + } + } else + r.opaque = b, r.transparent = null, r.volumetric = null; + } + setBuffers(r, n) { + var b = r.vertexArray, f = r.colorArray; + if (r.__webglOffsetBuffer !== void 0 ? (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, r.__webglOffsetBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, b, n)) : (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, r.__webglVertexBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, b, n)), this._gl.bindBuffer(this._gl.ARRAY_BUFFER, r.__webglColorBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, f, n), r.normalArray && r.__webglNormalBuffer !== void 0) { + var c = r.normalArray; + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, r.__webglNormalBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, c, n); + } + if (r.radiusArray && r.__webglRadiusBuffer !== void 0 && (this._gl.bindBuffer(this._gl.ARRAY_BUFFER, r.__webglRadiusBuffer), this._gl.bufferData(this._gl.ARRAY_BUFFER, r.radiusArray, n)), r.faceArray && r.__webglFaceBuffer !== void 0) { + var t = r.faceArray; + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, r.__webglFaceBuffer), this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, t, n); + } + if (r.lineArray && r.__webglLineBuffer !== void 0) { + var a = r.lineArray; + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, r.__webglLineBuffer), this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, a, n); + } + } + // Creates appropriate gl buffers for geometry chunk + // TODO: do we need line buffer for mesh objects? + // Also, can we integrate this with createLineBuffers? + createMeshBuffers(r) { + r.radiusArray && (r.__webglRadiusBuffer = this._gl.createBuffer()), r.useOffset && (r.__webglOffsetBuffer = this._gl.createBuffer()), r.__webglVertexBuffer = this._gl.createBuffer(), r.__webglNormalBuffer = this._gl.createBuffer(), r.__webglColorBuffer = this._gl.createBuffer(), r.__webglFaceBuffer = this._gl.createBuffer(), r.__webglLineBuffer = this._gl.createBuffer(), this.info.memory.geometries++; + } + createLineBuffers(r) { + r.__webglVertexBuffer = this._gl.createBuffer(), r.__webglColorBuffer = this._gl.createBuffer(), this.info.memory.geometries++; + } + addBuffer(r, n, b) { + r.push({ + buffer: n, + object: b, + opaque: null, + transparent: null + }); + } + setupMatrices(r, n) { + r._modelViewMatrix.multiplyMatrices(n.matrixWorldInverse, r.matrixWorld), r._normalMatrix.getInverse(r._modelViewMatrix), r._normalMatrix.transpose(); + } + // Fallback filters for non-power-of-2 textures + filterFallback(r) { + return this._gl.LINEAR; + } + setTextureParameters(r, n) { + r == this._gl.TEXTURE_2D ? (this._gl.texParameteri(r, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(r, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(r, this._gl.TEXTURE_MAG_FILTER, this.filterFallback(n.magFilter)), this._gl.texParameteri(r, this._gl.TEXTURE_MIN_FILTER, this.filterFallback(n.minFilter))) : (this._gl.texParameteri(r, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(r, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(r, this._gl.TEXTURE_WRAP_R, this._gl.CLAMP_TO_EDGE), this._extColorBufferFloat && this._extFloatLinear ? (this._gl.texParameteri(r, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR), this._gl.texParameteri(r, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR)) : (this._gl.texParameteri(r, this._gl.TEXTURE_MAG_FILTER, this._gl.NEAREST), this._gl.texParameteri(r, this._gl.TEXTURE_MIN_FILTER, this._gl.NEAREST))); + } + // Map constants to WebGL constants + paramToGL(r) { + return r === _.UnsignedByteType ? this._gl.UNSIGNED_BYTE : r === _.RGBAFormat ? this._gl.RGBA : r === _.NearestFilter ? this._gl.NEAREST : 0; + } + setupLights(r, n) { + var b, f, c, t = 0, a = 0, h = 0, M, w, S = this._lights, T = S.directional.colors, R = S.directional.positions, z = 0, P = 0; + for (b = 0, f = n.length; b < f; b++) + if (c = n[b], M = c.color, w = c.intensity, c instanceof x.Light) { + if (this._direction.getPositionFromMatrix(c.matrixWorld), this._vector3.getPositionFromMatrix(c.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, T[P] = M.r * w, T[P + 1] = M.g * w, T[P + 2] = M.b * w, P += 3, z++; + } + S.ambient[0] = t, S.ambient[1] = a, S.ambient[2] = h, S.directional.length = z; + } + 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 r = this._gl.getParameter(this._gl.VERSION); + this._webglversion = parseInt(r[6]); + } catch (n) { + console.error(n); + } + } + 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(r, n, b, f, c, t, a, T) { + var M, w, S, T, R, z, P; + n ? (R = r.length - 1, z = -1, P = -1) : (R = 0, z = r.length, P = 1); + for (var B = R; B !== z; B += P) + if (M = r[B], M.render) { + if (w = M.object, S = M.buffer, T = M[b], !T) + continue; + a && this.setBlending(!0), this.setDepthTest(T.depthTest), this.setDepthWrite(T.depthWrite), this.setPolygonOffset(T.polygonOffset, T.polygonOffsetFactor, T.polygonOffsetUnits); + var U = w._modelViewMatrix.isReflected(); + this.setMaterialFaces(T, U), this.renderBuffer(f, c, t, T, S, w), (this._outlineEnabled || T.outline) && (T.shaderID == "sphereimposter" ? this.renderBuffer(f, c, t, this._outlineSphereImposterMaterial, S, w) : T.shaderID == "stickimposter" ? this.renderBuffer(f, c, t, this._outlineStickImposterMaterial, S, w) : !T.wireframe && T.shaderID !== "basic" && T.opacity !== 0 && this.renderBuffer(f, c, t, this._outlineMaterial, S, w)); + } + } + renderSprites(r, n, b) { + 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(r, n, this._currentWidth, this._currentHeight, b), 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 ***! + \***********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + SpritePlugin: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ./shaders/index */ + "./src/WebGL/shaders/index.ts" + ); + class g { + constructor() { + this.sprite = { + vertices: null, + faces: null, + vertexBuffer: null, + elementBuffer: null, + program: null, + attributes: {}, + uniforms: null + }; + } + init(o) { + this.gl = o.context, this.renderer = o, this.precision = o.getPrecision(), this.sprite.vertices = new Float32Array(16), this.sprite.faces = new Uint16Array(6); + var p = 0; + this.sprite.vertices[p++] = -1, this.sprite.vertices[p++] = -1, this.sprite.vertices[p++] = 0, this.sprite.vertices[p++] = 0, this.sprite.vertices[p++] = 1, this.sprite.vertices[p++] = -1, this.sprite.vertices[p++] = 1, this.sprite.vertices[p++] = 0, this.sprite.vertices[p++] = 1, this.sprite.vertices[p++] = 1, this.sprite.vertices[p++] = 1, this.sprite.vertices[p++] = 1, this.sprite.vertices[p++] = -1, this.sprite.vertices[p++] = 1, this.sprite.vertices[p++] = 0, this.sprite.vertices[p++] = 1, p = 0, this.sprite.faces[p++] = 0, this.sprite.faces[p++] = 1, this.sprite.faces[p++] = 2, this.sprite.faces[p++] = 0, this.sprite.faces[p++] = 2, this.sprite.faces[p++] = 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( + l.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(o, p, E, u, A) { + var C, L, D, r, n, b, f, c, t, a; + if (!this.gl) + throw new Error("WebGLRenderer not initialized"); + let h = []; + (C = o == null ? void 0 : o.__webglSprites) === null || C === void 0 || C.forEach((Q) => { + (A && Q.material.depthTest == !1 || !A && Q.material.depthTest) && h.push(Q); + }); + let M = h.length; + if (!M) + return; + const w = this.sprite.attributes, S = this.sprite.uniforms; + if (!S) + throw new Error("Uniforms not defined"); + var T = E * 0.5, R = u * 0.5; + this.gl.useProgram(this.sprite.program), this.gl.enableVertexAttribArray(w.position), this.gl.enableVertexAttribArray(w.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(w.position, 2, this.gl.FLOAT, !1, 16, 0), this.gl.vertexAttribPointer(w.uv, 2, this.gl.FLOAT, !1, 16, 8), this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.sprite.elementBuffer), this.gl.uniformMatrix4fv(S.projectionMatrix, !1, p.projectionMatrix.elements), this.gl.activeTexture(this.gl.TEXTURE0), this.gl.uniform1i(S.map, 0); + var z = 0, P = 0, B = o.fog; + B ? (this.gl.uniform3f(S.fogColor, B.color.r, B.color.g, B.color.b), this.gl.uniform1f(S.fogNear, B.near), this.gl.uniform1f(S.fogFar, B.far), this.gl.uniform1i(S.fogType, 1), z = 1, P = 1) : (this.gl.uniform1i(S.fogType, 0), z = 0, P = 0); + var U; + let F, $, W, N, G = []; + for (U = 0; U < M; U++) + F = h[U], $ = F.material, $ && ($.depthTest == !1 && !A || !F.visible || $.opacity === 0 || ($.useScreenCoordinates ? F.z = -F.position.z : (F._modelViewMatrix.multiplyMatrices(p.matrixWorldInverse, F.matrixWorld), F.z = -F._modelViewMatrix.elements[14]))); + for (h.sort(_), U = 0; U < M; U++) + if (F = h[U], $ = F.material, !!$ && !(!F.visible || $.opacity === 0) && $.map && $.map.image && $.map.image.width) { + this.gl.uniform1f((S == null ? void 0 : S.alphaTest) || null, $.alphaTest); + var k = $.map.image.width, j = $.map.image.height; + G[0] = k * this.renderer.devicePixelRatio / E, G[1] = j * this.renderer.devicePixelRatio / u, $.useScreenCoordinates === !0 ? (this.gl.uniform1i(S.useScreenCoordinates, 1), this.gl.uniform3f(S.screenPosition, (F.position.x * this.renderer.devicePixelRatio - T) / T, (R - F.position.y * this.renderer.devicePixelRatio) / R, Math.max(0, Math.min(1, F.position.z)))) : (this.gl.uniform1i(S.useScreenCoordinates, 0), this.gl.uniformMatrix4fv(S.modelViewMatrix, !1, F._modelViewMatrix.elements)), o.fog && $.fog ? N = P : N = 0, z !== N && (this.gl.uniform1i(S.fogType, N), z = N), W = 1 / ($.scaleByViewport ? u : 1), G[0] *= W * F.scale.x, G[1] *= W * F.scale.y; + let Q = (L = $ == null ? void 0 : $.alignment) === null || L === void 0 ? void 0 : L.x, ie = (D = $ == null ? void 0 : $.alignment) === null || D === void 0 ? void 0 : D.y; + $.screenOffset && (Q = (Q || 0) + 2 * $.screenOffset.x / k, ie = (ie || 0) + 2 * $.screenOffset.y / j), this.gl.uniform2f(S.uvScale, ((r = $ == null ? void 0 : $.uvScale) === null || r === void 0 ? void 0 : r.x) || 1, ((n = $ == null ? void 0 : $.uvScale) === null || n === void 0 ? void 0 : n.y) || 1), this.gl.uniform2f(S.uvOffset, ((b = $ == null ? void 0 : $.uvOffset) === null || b === void 0 ? void 0 : b.x) || 0, ((f = $ == null ? void 0 : $.uvOffset) === null || f === void 0 ? void 0 : f.y) || 0), this.gl.uniform2f(S.alignment, Q || 0, ie || 0), this.gl.uniform1f(S.opacity, $.opacity), this.gl.uniform3f(S.color, ((c = $ == null ? void 0 : $.color) === null || c === void 0 ? void 0 : c.r) || 0, ((t = $ == null ? void 0 : $.color) === null || t === void 0 ? void 0 : t.g) || 0, ((a = $ == null ? void 0 : $.color) === null || a === void 0 ? void 0 : a.b) || 0), this.gl.uniform1f(S.rotation, F.rotation), this.gl.uniform2fv(S.scale, G), 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(o, p) { + 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 u = this.gl.createShader(this.gl.FRAGMENT_SHADER), A = this.gl.createShader(this.gl.VERTEX_SHADER); + if (!u) + throw new Error("Unable to create fragment shader SpritePlugin.createProgram"); + if (!A) + throw new Error("Unable to create vertex shader SpritePlugin.createProgram"); + var C = "precision " + p + ` float; +`; + if (this.gl.shaderSource(u, C + o.fragmentShader), this.gl.shaderSource(A, C + o.vertexShader), this.gl.compileShader(u), this.gl.compileShader(A), !this.gl.getShaderParameter(u, this.gl.COMPILE_STATUS) || !this.gl.getShaderParameter(A, this.gl.COMPILE_STATUS)) + throw new Error(`Error compiling shader: + ${this.gl.getShaderInfoLog(u)} + ${this.gl.getShaderInfoLog(A)}`); + return this.gl.attachShader(E, u), this.gl.attachShader(E, A), this.gl.linkProgram(E), this.gl.getProgramParameter(E, this.gl.LINK_STATUS) || console.error("Could not initialize shader"), E; + } + } + function _(x, o) { + return x.z !== o.z ? o.z - x.z : o.id - x.id; + } + } + ), + /***/ + "./src/WebGL/constants/Coloring.ts": ( + /*!*****************************************!*\ + !*** ./src/WebGL/constants/Coloring.ts ***! + \*****************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Coloring: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + var l; + (function(g) { + g[g.NoColors = 0] = "NoColors", g[g.FaceColors = 1] = "FaceColors", g[g.VertexColors = 2] = "VertexColors"; + })(l || (l = {})); + } + ), + /***/ + "./src/WebGL/constants/Shading.ts": ( + /*!****************************************!*\ + !*** ./src/WebGL/constants/Shading.ts ***! + \****************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Shading: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + var l; + (function(g) { + g[g.NoShading = 0] = "NoShading", g[g.FlatShading = 1] = "FlatShading", g[g.SmoothShading = 2] = "SmoothShading"; + })(l || (l = {})); + } + ), + /***/ + "./src/WebGL/constants/Sides.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/constants/Sides.ts ***! + \**************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + BackSide: () => ( + /* binding */ + g + ), + /* harmony export */ + DoubleSide: () => ( + /* binding */ + _ + ), + /* harmony export */ + FrontSide: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + const l = 0, g = 1, _ = 2; + } + ), + /***/ + "./src/WebGL/constants/SpriteAlignment.ts": ( + /*!************************************************!*\ + !*** ./src/WebGL/constants/SpriteAlignment.ts ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + SpriteAlignment: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + const g = { + topLeft: new l.Vector2(1, -1), + topCenter: new l.Vector2(0, -1), + topRight: new l.Vector2(-1, -1), + centerLeft: new l.Vector2(1, 0), + center: new l.Vector2(0, 0), + centerRight: new l.Vector2(-1, 0), + bottomLeft: new l.Vector2(1, 1), + bottomCenter: new l.Vector2(0, 1), + bottomRight: new l.Vector2(-1, 1) + }; + } + ), + /***/ + "./src/WebGL/constants/TextureConstants.ts": ( + /*!*************************************************!*\ + !*** ./src/WebGL/constants/TextureConstants.ts ***! + \*************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + ClampToEdgeWrapping: () => ( + /* binding */ + l + ), + /* harmony export */ + FloatType: () => ( + /* binding */ + p + ), + /* harmony export */ + LinearFilter: () => ( + /* binding */ + g + ), + /* harmony export */ + LinearMipMapLinearFilter: () => ( + /* binding */ + x + ), + /* harmony export */ + NearestFilter: () => ( + /* binding */ + _ + ), + /* harmony export */ + R32Format: () => ( + /* binding */ + A + ), + /* harmony export */ + RFormat: () => ( + /* binding */ + u + ), + /* harmony export */ + RGBAFormat: () => ( + /* binding */ + E + ), + /* harmony export */ + UnsignedByteType: () => ( + /* binding */ + o + ) + /* harmony export */ + }); + const l = 1001, g = 1006, _ = 1007, x = 1008, o = 1009, p = 1010, E = 1021, u = 1022, A = 1023; + } + ), + /***/ + "./src/WebGL/constants/TextureOperations.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/constants/TextureOperations.ts ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + TextureOperations: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + var l; + (function(g) { + g[g.MultiplyOperation = 0] = "MultiplyOperation", g[g.MixOperation = 1] = "MixOperation", g[g.AddOperation = 2] = "AddOperation"; + })(l || (l = {})); + } + ), + /***/ + "./src/WebGL/constants/index.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/constants/index.ts ***! + \**************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + BackSide: () => ( + /* reexport safe */ + g.BackSide + ), + /* harmony export */ + ClampToEdgeWrapping: () => ( + /* reexport safe */ + o.ClampToEdgeWrapping + ), + /* harmony export */ + Coloring: () => ( + /* reexport safe */ + l.Coloring + ), + /* harmony export */ + DoubleSide: () => ( + /* reexport safe */ + g.DoubleSide + ), + /* harmony export */ + FloatType: () => ( + /* reexport safe */ + o.FloatType + ), + /* harmony export */ + FrontSide: () => ( + /* reexport safe */ + g.FrontSide + ), + /* harmony export */ + LinearFilter: () => ( + /* reexport safe */ + o.LinearFilter + ), + /* harmony export */ + LinearMipMapLinearFilter: () => ( + /* reexport safe */ + o.LinearMipMapLinearFilter + ), + /* harmony export */ + NearestFilter: () => ( + /* reexport safe */ + o.NearestFilter + ), + /* harmony export */ + R32Format: () => ( + /* reexport safe */ + o.R32Format + ), + /* harmony export */ + RFormat: () => ( + /* reexport safe */ + o.RFormat + ), + /* harmony export */ + RGBAFormat: () => ( + /* reexport safe */ + o.RGBAFormat + ), + /* harmony export */ + Shading: () => ( + /* reexport safe */ + _.Shading + ), + /* harmony export */ + SpriteAlignment: () => ( + /* reexport safe */ + x.SpriteAlignment + ), + /* harmony export */ + TextureOperations: () => ( + /* reexport safe */ + p.TextureOperations + ), + /* harmony export */ + UnsignedByteType: () => ( + /* reexport safe */ + o.UnsignedByteType + ) + /* harmony export */ + }); + var l = e( + /*! ./Coloring */ + "./src/WebGL/constants/Coloring.ts" + ), g = e( + /*! ./Sides */ + "./src/WebGL/constants/Sides.ts" + ), _ = e( + /*! ./Shading */ + "./src/WebGL/constants/Shading.ts" + ), x = e( + /*! ./SpriteAlignment */ + "./src/WebGL/constants/SpriteAlignment.ts" + ), o = e( + /*! ./TextureConstants */ + "./src/WebGL/constants/TextureConstants.ts" + ), p = e( + /*! ./TextureOperations */ + "./src/WebGL/constants/TextureOperations.ts" + ); + } + ), + /***/ + "./src/WebGL/core/EventDispatcher.ts": ( + /*!*******************************************!*\ + !*** ./src/WebGL/core/EventDispatcher.ts ***! + \*******************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + EventDispatcher: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + class l { + constructor() { + this.listeners = {}; + } + dispatchEvent(_) { + var x = this.listeners[_.type]; + if (x !== void 0) { + _.target = this; + for (var o = 0, p = x.length; o < p; o++) + x[o].call(this, _); + } + } + removeEventListener(_, x) { + if (!x) + this.listeners[_] = []; + else { + var o = this.listeners[_].indexOf(x); + o !== -1 && this.listeners[_].splice(o, 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 ***! + \************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Geometry: () => ( + /* binding */ + E + ), + /* harmony export */ + GeometryGroup: () => ( + /* binding */ + p + ), + /* harmony export */ + GeometryIDCount: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var l = e( + /*! ../materials/LineBasicMaterial */ + "./src/WebGL/materials/LineBasicMaterial.ts" + ), g = e( + /*! ./EventDispatcher */ + "./src/WebGL/core/EventDispatcher.ts" + ), _ = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), x = e( + /*! ../../colors */ + "./src/colors.ts" + ); + const o = 65535; + class p { + constructor(C = 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 = C; + } + setColors(C) { + var L = this.vertexArray, D = this.colorArray; + if (!L) + throw new Error("vertex array not initialized"); + if (!D) + throw new Error("color array not initialized"); + if (L.length != D.length) { + console.log("Cannot re-color geometry group due to mismatched lengths."); + return; + } + for (var r = 0; r < L.length; r += 3) { + var n = C(L[r], L[r + 1], L[r + 2]); + n instanceof x.Color || (n = x.CC.color(n)), D[r] = n.r, D[r + 1] = n.g, D[r + 2] = n.b; + } + } + getNumVertices() { + return this.vertices; + } + getVertices() { + return this.vertexArray; + } + getCentroid() { + if (!this.vertexArray) + throw new Error("vertex array not initialized"); + for (var C = new _.Vector3(), L, D, r, n, b = 0; b < this.vertices; ++b) + L = b * 3, D = this.vertexArray[L], r = this.vertexArray[L + 1], n = this.vertexArray[L + 2], C.x += D, C.y += r, C.z += n; + return C.divideScalar(this.vertices), C; + } + //setup normals - vertex and face array must exist + setNormals() { + var C = this.faceArray, L = this.vertexArray, D = this.normalArray; + if (!(!this.vertices || !this.faceidx)) { + if (!C) + throw new Error("face array not initialized"); + if (!L) + throw new Error("vertex array not initialized"); + if (!D) + throw new Error("normal array not initialized"); + for (var r, n, b, f, c, t, a, h = 0; h < C.length / 3; ++h) + r = C[h * 3] * 3, n = C[h * 3 + 1] * 3, b = C[h * 3 + 2] * 3, f = new _.Vector3(L[r], L[r + 1], L[r + 2]), c = new _.Vector3(L[n], L[n + 1], L[n + 2]), t = new _.Vector3(L[b], L[b + 1], L[b + 2]), f.subVectors(f, c), t.subVectors(t, c), t.cross(f), a = t, a.normalize(), D[r] += a.x, D[n] += a.x, D[b] += a.x, D[r + 1] += a.y, D[n + 1] += a.y, D[b + 1] += a.y, D[r + 2] += a.z, D[n + 2] += a.z, D[b + 2] += a.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 C = this.faceArray, L = this.lineArray = new Uint16Array(this.faceidx * 2); + if (this.lineidx = this.faceidx * 2, !C) + throw new Error("face array not initialized"); + for (var D = 0; D < this.faceidx / 3; ++D) { + var r = D * 3, n = r * 2, b = C[r], f = C[r + 1], c = C[r + 2]; + L[n] = b, L[n + 1] = f, L[n + 2] = b, L[n + 3] = c, L[n + 4] = f, L[n + 5] = c; + } + } + } + vrml(C, L) { + var D, r, n, b, f, c, t, a, h, M, w, S, T, R, z, P, B, U, F = ""; + if (F += C + `Shape { +` + C + ` appearance Appearance { +` + C + ` material Material { +` + C + " diffuseColor " + ((D = L == null ? void 0 : L.color) === null || D === void 0 ? void 0 : D.r) + " " + ((r = L == null ? void 0 : L.color) === null || r === void 0 ? void 0 : r.g) + " " + ((n = L == null ? void 0 : L.color) === null || n === void 0 ? void 0 : n.b) + ` +`, L.wireframe && this.colorArray) { + let W = this.colorArray; + F += C + " emissiveColor " + W[0] + " " + W[1] + " " + W[2] + ` +`; + } + L != null && L.transparent && (F += C + " transparency " + (1 - L.opacity) + ` +`), F += C + ` } +`, F += C + ` } +`; + var $ = C; + if (C += " ", L instanceof l.LineBasicMaterial || L.wireframe) { + F += C + `geometry IndexedLineSet { +` + C + ` colorPerVertex TRUE +` + C + ` coord Coordinate { +` + C + ` point [ +`; + let W, N, G; + for (let k = 0; k < this.vertices; ++k) { + let j = k * 3; + W = (b = this.vertexArray) === null || b === void 0 ? void 0 : b[j], N = (f = this.vertexArray) === null || f === void 0 ? void 0 : f[j + 1], G = (c = this.vertexArray) === null || c === void 0 ? void 0 : c[j + 2], F += C + " " + W + " " + N + " " + G + `, +`; + } + if (F += C + ` ] +`, F += C + ` } +`, this.colorArray && !L.wireframe) { + F += C + ` color Color { +` + C + ` color [ +`; + for (let k = 0; k < this.vertices; ++k) { + let j = k * 3; + W = this.colorArray[j], N = this.colorArray[j + 1], G = this.colorArray[j + 2], F += C + " " + W + " " + N + " " + G + `, +`; + } + F += C + ` ] +`, F += C + ` } +`; + } + if (F += C + ` coordIndex [ +`, L.wireframe && this.faceArray) + for (let k = 0; k < this.faceidx; k += 3) + W = (t = this.faceArray) === null || t === void 0 ? void 0 : t[k], N = (a = this.faceArray) === null || a === void 0 ? void 0 : a[k + 1], G = (h = this.faceArray) === null || h === void 0 ? void 0 : h[k + 2], F += C + " " + W + ", " + N + ", " + G + `, -1, +`; + else + for (let k = 0; k < this.vertices - 1; k += 2) + F += C + " " + k + ", " + (k + 1) + `, -1, +`; + F += C + ` ] +`, F += C + `} +`; + } else { + F += C + `geometry IndexedFaceSet { +` + C + ` colorPerVertex TRUE +` + C + ` normalPerVertex TRUE +` + C + ` solid FALSE +`, F += C + ` coord Coordinate { +` + C + ` point [ +`; + let W, N, G; + for (let k = 0; k < this.vertices; ++k) { + let j = k * 3; + W = (M = this.vertexArray) === null || M === void 0 ? void 0 : M[j], N = (w = this.vertexArray) === null || w === void 0 ? void 0 : w[j + 1], G = (S = this.vertexArray) === null || S === void 0 ? void 0 : S[j + 2], F += C + " " + W + " " + N + " " + G + `, +`; + } + F += C + ` ] +`, F += C + ` } +`, F += C + ` normal Normal { +` + C + ` vector [ +`; + for (let k = 0; k < this.vertices; ++k) { + let j = k * 3; + W = (T = this.normalArray) === null || T === void 0 ? void 0 : T[j], N = (R = this.normalArray) === null || R === void 0 ? void 0 : R[j + 1], G = (z = this.normalArray) === null || z === void 0 ? void 0 : z[j + 2], F += C + " " + W + " " + N + " " + G + `, +`; + } + if (F += C + ` ] +`, F += C + ` } +`, this.colorArray) { + F += C + ` color Color { +` + C + ` color [ +`; + for (let k = 0; k < this.vertices; ++k) { + let j = k * 3; + W = this.colorArray[j], N = this.colorArray[j + 1], G = this.colorArray[j + 2], F += C + " " + W + " " + N + " " + G + `, +`; + } + F += C + ` ] +`, F += C + ` } +`; + } + F += C + ` coordIndex [ +`; + for (let k = 0; k < this.faceidx; k += 3) + W = (P = this.faceArray) === null || P === void 0 ? void 0 : P[k], N = (B = this.faceArray) === null || B === void 0 ? void 0 : B[k + 1], G = (U = this.faceArray) === null || U === void 0 ? void 0 : U[k + 2], F += C + " " + W + ", " + N + ", " + G + `, -1, +`; + F += C + ` ] +`, F += C + `} +`; + } + return F += $ + "}", F; + } + truncateArrayBuffers(C = !0, L = !1) { + var D = this.vertexArray, r = this.colorArray, n = this.normalArray, b = this.faceArray, f = this.lineArray, c = this.radiusArray; + this.vertexArray = (D == null ? void 0 : D.subarray(0, this.vertices * 3)) || null, this.colorArray = (r == null ? void 0 : r.subarray(0, this.vertices * 3)) || null, C ? (this.normalArray = (n == null ? void 0 : n.subarray(0, this.vertices * 3)) || null, this.faceArray = (b == null ? void 0 : b.subarray(0, this.faceidx)) || null, this.lineidx > 0 ? this.lineArray = (f == null ? void 0 : f.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)), c && (this.radiusArray = c.subarray(0, this.vertices)), L && (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 g.EventDispatcher { + constructor(C = !1, L = !1, D = !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 = u++, this.mesh = C, this.radii = L, this.offset = D; + } + //Get geometry group to accomodate addVertices new vertices - create + // new group if necessary + updateGeoGroup(C = 0) { + var L, D = this.groups > 0 ? this.geometryGroups[this.groups - 1] : null; + return (!D || D.vertices + C > (((L = D == null ? void 0 : D.vertexArray) === null || L === void 0 ? void 0 : L.length) || 0) / 3) && (D = this.addGeoGroup()), D; + } + //return comma separated list of IndexedFace (or Line) sets from geometry groups + vrml(C, L) { + for (var D = "", r = this.geometryGroups.length, n = 0; n < r; n++) { + var b = this.geometryGroups[n]; + D += b.vrml(C, L) + `, +`; + } + return D; + } + addGeoGroup() { + var C = new p(this.geometryGroups.length); + return this.geometryGroups.push(C), this.groups = this.geometryGroups.length, C.vertexArray = new Float32Array(o * 3), C.colorArray = new Float32Array(o * 3), this.mesh && (C.normalArray = new Float32Array(o * 3), C.faceArray = new Uint16Array(o * 6), C.lineArray = new Uint16Array(o * 6)), this.radii && (C.radiusArray = new Float32Array(o)), C.useOffset = this.offset, C; + } + setUpNormals(...C) { + for (var L = 0; L < this.groups; L++) { + var D = this.geometryGroups[L]; + D.setNormals(...C); + } + } + setColors(...C) { + for (var L = this.geometryGroups.length, D = 0; D < L; D++) { + var r = this.geometryGroups[D]; + r.setColors(...C); + } + } + setUpWireframe(...C) { + for (var L = 0; L < this.groups; L++) { + var D = this.geometryGroups[L]; + D.setLineIndices(...C); + } + } + //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 C = 0; C < this.groups; C++) { + var L = this.geometryGroups[C]; + L.__inittedArrays !== !0 && L.truncateArrayBuffers(this.mesh, !1); + } + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } + get vertices() { + for (var C = 0, L = 0; L < this.groups; L++) + C += this.geometryGroups[L].vertices; + return C; + } + } + let u = 0; + } + ), + /***/ + "./src/WebGL/core/Object3D.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/core/Object3D.ts ***! + \************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Light: () => ( + /* binding */ + p + ), + /* harmony export */ + Object3D: () => ( + /* binding */ + x + ), + /* harmony export */ + Object3DIDCount: () => ( + /* binding */ + _ + ), + /* harmony export */ + Scene: () => ( + /* binding */ + o + ) + /* harmony export */ + }); + var l = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), g = e( + /*! ../../colors */ + "./src/colors.ts" + ); + let _ = 0; + class x { + constructor() { + this.id = _++, this.name = "", this.children = [], this.position = new l.Vector3(), this.rotation = new l.Vector3(), this.matrix = new l.Matrix4(), this.matrixWorld = new l.Matrix4(), this.quaternion = new l.Quaternion(), this.eulerOrder = "XYZ", this.up = new l.Vector3(0, 1, 0), this.scale = new l.Vector3(1, 1, 1), this.matrixAutoUpdate = !0, this.matrixWorldNeedsUpdate = !0, this.rotationAutoUpdate = !0, this.useQuaternion = !1, this.visible = !0; + } + lookAt(u) { + this.matrix.lookAt(u, this.position, this.up), this.rotationAutoUpdate && (this.useQuaternion === !0 ? console.error("Unimplemented math operation.") : this.rotation instanceof l.Vector3 && this.rotation.setEulerFromRotationMatrix(this.matrix, this.eulerOrder)); + } + //add child object + add(u) { + if (u === this) { + console.error("Can't add $3Dmol.Object3D to itself"); + return; + } + u.parent = this, this.children.push(u); + for (var A = this; A.parent !== void 0; ) + A = A.parent; + A !== void 0 && A instanceof o && A.__addObject(u); + } + remove(u) { + var A = this.children.indexOf(u); + if (A !== -1) { + u.parent = void 0, this.children.splice(A, 1); + for (var C = this; C.parent !== void 0; ) + C = C.parent; + C !== void 0 && C instanceof o && C.__removeObject(u); + } + } + //convert to vrml + vrml(u) { + u || (u = " "); + var A = 2 * Math.atan2(this.quaternion.lengthxyz(), this.quaternion.w), C = 0, L = 0, D = 0; + if (A != 0) { + let b = Math.sin(A / 2); + C = this.quaternion.x / b, L = this.quaternion.y / b, D = this.quaternion.z / b; + } + var r = u + `Transform { +` + u + " center " + this.position.x + " " + this.position.y + " " + this.position.z + ` +` + u + " rotation " + C + " " + L + " " + D + " " + A + ` +` + u + ` children [ +`; + this.geometry && (r += this.geometry.vrml(u, this.material)); + for (var n = 0; n < this.children.length; n++) + r += this.children[n].vrml(u + " ") + `, +`; + return r += ` ] +`, r += "}", r; + } + updateMatrix() { + this.matrix.setPosition(this.position), this.useQuaternion === !1 && this.rotation instanceof l.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(u) { + this.matrixAutoUpdate === !0 && this.updateMatrix(), (this.matrixWorldNeedsUpdate === !0 || u === !0) && (this.parent === void 0 ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1; + for (var A = 0; A < this.children.length; A++) + this.children[A].updateMatrixWorld(!0); + } + clone(u) { + u === void 0 && (u = new x()), u.name = this.name, u.up.copy(this.up), u.position.copy(this.position), u.rotation instanceof l.Vector3 && this.rotation instanceof l.Vector3 ? u.rotation.copy(this.rotation) : u.rotation = this.rotation, u.eulerOrder = this.eulerOrder, u.scale.copy(this.scale), u.rotationAutoUpdate = this.rotationAutoUpdate, u.matrix.copy(this.matrix), u.matrixWorld.copy(this.matrixWorld), u.quaternion.copy(this.quaternion), u.matrixAutoUpdate = this.matrixAutoUpdate, u.matrixWorldNeedsUpdate = this.matrixWorldNeedsUpdate, u.useQuaternion = this.useQuaternion, u.visible = this.visible; + for (var A = 0; A < this.children.length; A++) { + var C = this.children[A]; + u.add(C.clone()); + } + return u; + } + setVisible(u) { + this.visible = u; + for (var A = 0; A < this.children.length; A++) { + var C = this.children[A]; + C.setVisible(u); + } + } + } + class o extends x { + constructor() { + super(...arguments), this.fog = null, this.overrideMaterial = null, this.matrixAutoUpdate = !1, this.__objects = [], this.__lights = [], this.__objectsAdded = [], this.__objectsRemoved = []; + } + __addObject(u) { + if (u instanceof p) + this.__lights.indexOf(u) === -1 && this.__lights.push(u), u.target && u.target.parent === void 0 && this.add(u.target); + else if (this.__objects.indexOf(u) === -1) { + this.__objects.push(u), this.__objectsAdded.push(u); + var A = this.__objectsRemoved.indexOf(u); + A !== -1 && this.__objectsRemoved.splice(A, 1); + } + for (var C = 0; C < u.children.length; C++) + this.__addObject(u.children[C]); + } + __removeObject(u) { + var A; + if (u instanceof p) + A = this.__lights.indexOf(u), A !== -1 && this.__lights.splice(A, 1); + else if (A = this.__objects.indexOf(u), A !== -1) { + this.__objects.splice(A, 1), this.__objectsRemoved.push(u); + var C = this.__objectsAdded.indexOf(u); + C !== -1 && this.__objectsAdded.splice(A, 1); + } + for (var L = 0; L < u.children.length; L++) + this.__removeObject(u.children[L]); + } + } + class p extends x { + constructor(u, A = 1) { + super(), this.position = new l.Vector3(0, 1, 0), this.target = new x(), this.castShadow = !1, this.onlyShadow = !1, this.color = new g.Color(u), this.intensity = A; + } + } + } + ), + /***/ + "./src/WebGL/core/Projector.ts": ( + /*!*************************************!*\ + !*** ./src/WebGL/core/Projector.ts ***! + \*************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Projector: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + const g = new l.Matrix4(); + class _ { + static unprojectVector(o, p) { + return p.projectionMatrixInverse.getInverse(p.projectionMatrix), g.multiplyMatrices(p.matrixWorld, p.projectionMatrixInverse), o.applyProjection(g); + } + static projectVector(o, p) { + return p.matrixWorldInverse.getInverse(p.matrixWorld), g.multiplyMatrices(p.projectionMatrix, p.matrixWorldInverse), o.applyProjection(g); + } + projectVector(o, p) { + return _.projectVector(o, p); + } + unprojectVector(o, p) { + return _.unprojectVector(o, p); + } + } + } + ), + /***/ + "./src/WebGL/core/Raycaster.ts": ( + /*!*************************************!*\ + !*** ./src/WebGL/core/Raycaster.ts ***! + \*************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Raycaster: () => ( + /* binding */ + o + ), + /* harmony export */ + intersectObject: () => ( + /* binding */ + b + ) + /* harmony export */ + }); + var l = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), g = e( + /*! ../shapes */ + "./src/WebGL/shapes/index.ts" + ); + const _ = (f, c) => f.distance - c.distance, x = new l.Matrix4(); + class o { + constructor(c, t, a, h) { + this.precision = 1e-4, this.linePrecision = 0.2, this.ray = new l.Ray(c, t), this.ray.direction.lengthSq() > 0 && this.ray.direction.normalize(), this.near = h || 0, this.far = a || 1 / 0; + } + set(c, t) { + this.ray.set(c, t); + } + setFromCamera(c, t) { + t.ortho ? (this.ray.origin.set(c.x, c.y, (t.near + t.far) / (t.near - t.far)).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld)) : (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(c.x, c.y, c.z), t.projectionMatrixInverse.getInverse(t.projectionMatrix), x.multiplyMatrices(t.matrixWorld, t.projectionMatrixInverse), this.ray.direction.applyProjection(x), this.ray.direction.sub(this.ray.origin).normalize()); + } + intersectObjects(c, t) { + for (var a = [], h = 0, M = t.length; h < M; h++) + b(c, t[h], this, a); + return a.sort(_), a; + } + } + const p = (f) => Math.min(Math.max(f, -1), 1); + var E = new g.Sphere(), u = new g.Cylinder(), A = new g.Triangle(), C = new l.Vector3(), L = new l.Vector3(), D = new l.Vector3(), r = new l.Vector3(), n = new l.Vector3(); + function b(f, c, t, a) { + if (n.getPositionFromMatrix(f.matrixWorld), c.intersectionShape === void 0) + return a; + var h = c.intersectionShape, M = t.linePrecision; + M *= f.matrixWorld.getMaxScaleOnAxis(); + var w = M * M; + if (c.boundingSphere !== void 0 && c.boundingSphere instanceof g.Sphere && (E.copy(c.boundingSphere), E.applyMatrix4(f.matrixWorld), !t.ray.isIntersectionSphere(E))) + return a; + var S, T, R, z, P, B, U, F, $, W, N, G, k, j; + for (S = 0, T = h.triangle.length; S < T; S++) + if (h.triangle[S] instanceof g.Triangle) { + if (A.copy(h.triangle[S]), A.applyMatrix4(f.matrixWorld), R = A.getNormal(), z = t.ray.direction.dot(R), z >= 0 || (C.subVectors(A.a, t.ray.origin), U = R.dot(C) / z, U < 0)) + continue; + L.copy(t.ray.direction).multiplyScalar(U).add(t.ray.origin), L.sub(A.a), D.copy(A.b).sub(A.a), r.copy(A.c).sub(A.a); + var Q = D.dot(r), ie = D.lengthSq(), pe = r.lengthSq(); + if (G = (ie * L.dot(r) - Q * L.dot(D)) / (ie * pe - Q * Q), G < 0 || G > 1 || (N = (L.dot(D) - G * Q) / ie, N < 0 || N > 1 || N + G > 1)) + continue; + a.push({ clickable: c, distance: U }); + } + for (S = 0, T = h.cylinder.length; S < T; S++) + if (h.cylinder[S] instanceof g.Cylinder) { + if (u.copy(h.cylinder[S]), u.applyMatrix4(f.matrixWorld), C.subVectors(u.c1, t.ray.origin), P = C.dot(u.direction), B = C.dot(t.ray.direction), z = p(t.ray.direction.dot(u.direction)), $ = 1 - z * z, $ === 0) + continue; + k = (z * B - P) / $, j = (B - z * P) / $, L.copy(u.direction).multiplyScalar(k).add(u.c1), D.copy(t.ray.direction).multiplyScalar(j).add(t.ray.origin), F = r.subVectors(L, D).lengthSq(); + var he = u.radius * u.radius; + if (F <= he) { + if (W = (z * P - B) * (z * P - B) - $ * (C.lengthSq() - P * P - he), W <= 0 ? G = U = Math.sqrt(F) : G = U = (B - z * P - Math.sqrt(W)) / $, N = z * G - P, N < 0 || N * N > u.lengthSq() || G < 0) + continue; + a.push({ clickable: c, distance: U }); + } + } + for (S = 0, T = h.line.length; S < T; S += 2) { + L.copy(h.line[S]), L.applyMatrix4(f.matrixWorld), D.copy(h.line[S + 1]), D.applyMatrix4(f.matrixWorld), r.subVectors(D, L); + var ue = r.lengthSq(); + r.normalize(), C.subVectors(L, t.ray.origin); + var se = C.dot(r); + B = C.dot(t.ray.direction), z = p(t.ray.direction.dot(r)), $ = 1 - z * z, $ !== 0 && (k = (z * B - se) / $, j = (B - z * se) / $, L.add(r.multiplyScalar(k)), D.copy(t.ray.direction).multiplyScalar(j).add(t.ray.origin), F = r.subVectors(D, L).lengthSq(), F < w && k * k < ue && a.push({ clickable: c, distance: j })); + } + for (S = 0, T = h.sphere.length; S < T; S++) + if (h.sphere[S] instanceof g.Sphere && (E.copy(h.sphere[S]), E.applyMatrix4(f.matrixWorld), t.ray.isIntersectionSphere(E))) { + L.subVectors(E.center, t.ray.origin); + var ae = L.dot(t.ray.direction); + if (W = ae * ae - (L.lengthSq() - E.radius * E.radius), ae < 0) + return a; + W <= 0 ? U = ae : U = ae - Math.sqrt(W), a.push({ clickable: c, distance: U }); + } + return a; + } + } + ), + /***/ + "./src/WebGL/core/Texture.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/core/Texture.ts ***! + \***********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Texture: () => ( + /* binding */ + o + ), + /* harmony export */ + TextureIdCount: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ../constants/TextureConstants */ + "./src/WebGL/constants/TextureConstants.ts" + ), g = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), _ = e( + /*! ./EventDispatcher */ + "./src/WebGL/core/EventDispatcher.ts" + ), x = e( + /*! ./UVMapping */ + "./src/WebGL/core/UVMapping.ts" + ); + class o extends _.EventDispatcher { + constructor(u, A) { + super(), this.id = p++, this.name = "", this.image = u, this.mapping = new x.UVMapping(), this.wrapS = l.ClampToEdgeWrapping, this.wrapT = l.ClampToEdgeWrapping, this.anisotropy = 1, A ? (this.format = l.RFormat, this.type = l.FloatType, this.premultiplyAlpha = !1, this.flipY = !1, this.unpackAlignment = 1, this.magFilter = l.NearestFilter, this.minFilter = l.NearestFilter) : (this.format = l.RGBAFormat, this.type = l.UnsignedByteType, this.offset = new g.Vector2(0, 0), this.repeat = new g.Vector2(1, 1), this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.magFilter = l.LinearFilter, this.minFilter = l.LinearMipMapLinearFilter), this.needsUpdate = !1, this.onUpdate = null; + } + clone(u = new o()) { + return u.image = this.image, u.mapping = this.mapping, u.wrapS = this.wrapS, u.wrapT = this.wrapT, u.magFilter = this.magFilter, u.minFilter = this.minFilter, u.anisotropy = this.anisotropy, u.format = this.format, u.type = this.type, u.offset.copy(this.offset), u.repeat.copy(this.repeat), u.premultiplyAlpha = this.premultiplyAlpha, u.flipY = this.flipY, u.unpackAlignment = this.unpackAlignment, u; + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } + } + let p = 0; + } + ), + /***/ + "./src/WebGL/core/UVMapping.ts": ( + /*!*************************************!*\ + !*** ./src/WebGL/core/UVMapping.ts ***! + \*************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + UVMapping: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + class l { + } + } + ), + /***/ + "./src/WebGL/core/index.ts": ( + /*!*********************************!*\ + !*** ./src/WebGL/core/index.ts ***! + \*********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + EventDispatcher: () => ( + /* reexport safe */ + l.EventDispatcher + ), + /* harmony export */ + Geometry: () => ( + /* reexport safe */ + g.Geometry + ), + /* harmony export */ + GeometryGroup: () => ( + /* reexport safe */ + g.GeometryGroup + ), + /* harmony export */ + GeometryIDCount: () => ( + /* reexport safe */ + g.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 */ + o.Raycaster + ), + /* harmony export */ + Scene: () => ( + /* reexport safe */ + _.Scene + ), + /* harmony export */ + Texture: () => ( + /* reexport safe */ + p.Texture + ), + /* harmony export */ + TextureIdCount: () => ( + /* reexport safe */ + p.TextureIdCount + ), + /* harmony export */ + UVMapping: () => ( + /* reexport safe */ + E.UVMapping + ), + /* harmony export */ + intersectObject: () => ( + /* reexport safe */ + o.intersectObject + ) + /* harmony export */ + }); + var l = e( + /*! ./EventDispatcher */ + "./src/WebGL/core/EventDispatcher.ts" + ), g = e( + /*! ./Geometry */ + "./src/WebGL/core/Geometry.ts" + ), _ = e( + /*! ./Object3D */ + "./src/WebGL/core/Object3D.ts" + ), x = e( + /*! ./Projector */ + "./src/WebGL/core/Projector.ts" + ), o = e( + /*! ./Raycaster */ + "./src/WebGL/core/Raycaster.ts" + ), p = e( + /*! ./Texture */ + "./src/WebGL/core/Texture.ts" + ), E = e( + /*! ./UVMapping */ + "./src/WebGL/core/UVMapping.ts" + ); + } + ), + /***/ + "./src/WebGL/index.ts": ( + /*!****************************!*\ + !*** ./src/WebGL/index.ts ***! + \****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + BackSide: () => ( + /* reexport safe */ + l.BackSide + ), + /* harmony export */ + Camera: () => ( + /* reexport safe */ + u.Camera + ), + /* harmony export */ + ClampToEdgeWrapping: () => ( + /* reexport safe */ + l.ClampToEdgeWrapping + ), + /* harmony export */ + Coloring: () => ( + /* reexport safe */ + l.Coloring + ), + /* harmony export */ + Cylinder: () => ( + /* reexport safe */ + E.Cylinder + ), + /* harmony export */ + DoubleSide: () => ( + /* reexport safe */ + l.DoubleSide + ), + /* harmony export */ + EventDispatcher: () => ( + /* reexport safe */ + g.EventDispatcher + ), + /* harmony export */ + FloatType: () => ( + /* reexport safe */ + l.FloatType + ), + /* harmony export */ + Fog: () => ( + /* reexport safe */ + A.Fog + ), + /* harmony export */ + FrontSide: () => ( + /* reexport safe */ + l.FrontSide + ), + /* harmony export */ + Geometry: () => ( + /* reexport safe */ + g.Geometry + ), + /* harmony export */ + GeometryGroup: () => ( + /* reexport safe */ + g.GeometryGroup + ), + /* harmony export */ + GeometryIDCount: () => ( + /* reexport safe */ + g.GeometryIDCount + ), + /* harmony export */ + ImposterMaterial: () => ( + /* reexport safe */ + _.ImposterMaterial + ), + /* harmony export */ + InstancedMaterial: () => ( + /* reexport safe */ + _.InstancedMaterial + ), + /* harmony export */ + Light: () => ( + /* reexport safe */ + g.Light + ), + /* harmony export */ + Line: () => ( + /* reexport safe */ + o.Line + ), + /* harmony export */ + LineBasicMaterial: () => ( + /* reexport safe */ + _.LineBasicMaterial + ), + /* harmony export */ + LineStyle: () => ( + /* reexport safe */ + o.LineStyle + ), + /* harmony export */ + LinearFilter: () => ( + /* reexport safe */ + l.LinearFilter + ), + /* harmony export */ + LinearMipMapLinearFilter: () => ( + /* reexport safe */ + l.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 */ + o.Mesh + ), + /* harmony export */ + MeshDoubleLambertMaterial: () => ( + /* reexport safe */ + _.MeshDoubleLambertMaterial + ), + /* harmony export */ + MeshLambertMaterial: () => ( + /* reexport safe */ + _.MeshLambertMaterial + ), + /* harmony export */ + MeshOutlineMaterial: () => ( + /* reexport safe */ + _.MeshOutlineMaterial + ), + /* harmony export */ + NearestFilter: () => ( + /* reexport safe */ + l.NearestFilter + ), + /* harmony export */ + Object3D: () => ( + /* reexport safe */ + g.Object3D + ), + /* harmony export */ + Object3DIDCount: () => ( + /* reexport safe */ + g.Object3DIDCount + ), + /* harmony export */ + Projector: () => ( + /* reexport safe */ + g.Projector + ), + /* harmony export */ + Quaternion: () => ( + /* reexport safe */ + x.Quaternion + ), + /* harmony export */ + R32Format: () => ( + /* reexport safe */ + l.R32Format + ), + /* harmony export */ + RFormat: () => ( + /* reexport safe */ + l.RFormat + ), + /* harmony export */ + RGBAFormat: () => ( + /* reexport safe */ + l.RGBAFormat + ), + /* harmony export */ + Ray: () => ( + /* reexport safe */ + x.Ray + ), + /* harmony export */ + Raycaster: () => ( + /* reexport safe */ + g.Raycaster + ), + /* harmony export */ + Renderer: () => ( + /* reexport safe */ + C.Renderer + ), + /* harmony export */ + Scene: () => ( + /* reexport safe */ + g.Scene + ), + /* harmony export */ + ShaderLib: () => ( + /* reexport safe */ + p.ShaderLib + ), + /* harmony export */ + ShaderUtils: () => ( + /* reexport safe */ + p.ShaderUtils + ), + /* harmony export */ + Shading: () => ( + /* reexport safe */ + l.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 */ + o.Sprite + ), + /* harmony export */ + SpriteAlignment: () => ( + /* reexport safe */ + l.SpriteAlignment + ), + /* harmony export */ + SpriteMaterial: () => ( + /* reexport safe */ + _.SpriteMaterial + ), + /* harmony export */ + SpritePlugin: () => ( + /* reexport safe */ + L.SpritePlugin + ), + /* harmony export */ + StickImposterMaterial: () => ( + /* reexport safe */ + _.StickImposterMaterial + ), + /* harmony export */ + StickImposterOutlineMaterial: () => ( + /* reexport safe */ + _.StickImposterOutlineMaterial + ), + /* harmony export */ + Texture: () => ( + /* reexport safe */ + g.Texture + ), + /* harmony export */ + TextureIdCount: () => ( + /* reexport safe */ + g.TextureIdCount + ), + /* harmony export */ + TextureOperations: () => ( + /* reexport safe */ + l.TextureOperations + ), + /* harmony export */ + Triangle: () => ( + /* reexport safe */ + E.Triangle + ), + /* harmony export */ + UVMapping: () => ( + /* reexport safe */ + g.UVMapping + ), + /* harmony export */ + UnsignedByteType: () => ( + /* reexport safe */ + l.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 */ + p.basic + ), + /* harmony export */ + clamp: () => ( + /* reexport safe */ + x.clamp + ), + /* harmony export */ + clone: () => ( + /* reexport safe */ + p.clone + ), + /* harmony export */ + conversionMatrix3: () => ( + /* reexport safe */ + x.conversionMatrix3 + ), + /* harmony export */ + degToRad: () => ( + /* reexport safe */ + x.degToRad + ), + /* harmony export */ + instanced: () => ( + /* reexport safe */ + p.instanced + ), + /* harmony export */ + intersectObject: () => ( + /* reexport safe */ + g.intersectObject + ), + /* harmony export */ + lambert: () => ( + /* reexport safe */ + p.lambert + ), + /* harmony export */ + lambertdouble: () => ( + /* reexport safe */ + p.lambertdouble + ), + /* harmony export */ + outline: () => ( + /* reexport safe */ + p.outline + ), + /* harmony export */ + screen: () => ( + /* reexport safe */ + p.screen + ), + /* harmony export */ + screenaa: () => ( + /* reexport safe */ + p.screenaa + ), + /* harmony export */ + sphereimposter: () => ( + /* reexport safe */ + p.sphereimposter + ), + /* harmony export */ + sphereimposteroutline: () => ( + /* reexport safe */ + p.sphereimposteroutline + ), + /* harmony export */ + sprite: () => ( + /* reexport safe */ + p.sprite + ), + /* harmony export */ + stickimposter: () => ( + /* reexport safe */ + p.stickimposter + ), + /* harmony export */ + stickimposteroutline: () => ( + /* reexport safe */ + p.stickimposteroutline + ), + /* harmony export */ + volumetric: () => ( + /* reexport safe */ + p.volumetric + ) + /* harmony export */ + }); + var l = e( + /*! ./constants */ + "./src/WebGL/constants/index.ts" + ), g = e( + /*! ./core */ + "./src/WebGL/core/index.ts" + ), _ = e( + /*! ./materials */ + "./src/WebGL/materials/index.ts" + ), x = e( + /*! ./math */ + "./src/WebGL/math/index.ts" + ), o = e( + /*! ./objects */ + "./src/WebGL/objects/index.ts" + ), p = e( + /*! ./shaders */ + "./src/WebGL/shaders/index.ts" + ), E = e( + /*! ./shapes */ + "./src/WebGL/shapes/index.ts" + ), u = e( + /*! ./Camera */ + "./src/WebGL/Camera.ts" + ), A = e( + /*! ./Fog */ + "./src/WebGL/Fog.ts" + ), C = e( + /*! ./Renderer */ + "./src/WebGL/Renderer.ts" + ), L = e( + /*! ./SpritePlugin */ + "./src/WebGL/SpritePlugin.ts" + ); + } + ), + /***/ + "./src/WebGL/materials/ImposterMaterial.ts": ( + /*!*************************************************!*\ + !*** ./src/WebGL/materials/ImposterMaterial.ts ***! + \*************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + ImposterMaterial: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ./../constants/Coloring */ + "./src/WebGL/constants/Coloring.ts" + ), g = e( + /*! ./../constants/Shading */ + "./src/WebGL/constants/Shading.ts" + ), _ = e( + /*! ../../colors */ + "./src/colors.ts" + ), x = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), o = e( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class p extends o.Material { + constructor(u) { + 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 = g.Shading.SmoothShading, this.shaderID = null, this.vertexColors = l.Coloring.NoColors, this.skinning = !1, this.setValues(u); + } + clone(u = new p()) { + return super.clone.call(this, u), u.color.copy(this.color), u.ambient.copy(this.ambient), u.emissive.copy(this.emissive), u.wrapAround = this.wrapAround, u.wrapRGB.copy(this.wrapRGB), u.map = this.map, u.lightMap = this.lightMap, u.specularMap = this.specularMap, u.envMap = this.envMap, u.combine = this.combine, u.reflectivity = this.reflectivity, u.refractionRatio = this.refractionRatio, u.fog = this.fog, u.shading = this.shading, u.shaderID = this.shaderID, u.vertexColors = this.vertexColors, u.skinning = this.skinning, u.morphTargets = this.morphTargets, u.morphNormals = this.morphNormals, u; + } + } + } + ), + /***/ + "./src/WebGL/materials/InstancedMaterial.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/materials/InstancedMaterial.ts ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + InstancedMaterial: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ../constants/Coloring */ + "./src/WebGL/constants/Coloring.ts" + ), g = e( + /*! ../constants/Shading */ + "./src/WebGL/constants/Shading.ts" + ), _ = e( + /*! ../../colors */ + "./src/colors.ts" + ), x = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), o = e( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class p extends o.Material { + constructor(u) { + 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 = g.Shading.SmoothShading, this.shaderID = "instanced", this.vertexColors = l.Coloring.NoColors, this.skinning = !1, this.sphere = null, this.setValues(u); + } + clone(u = new p()) { + return super.clone.call(this, u), u.color.copy(this.color), u.ambient.copy(this.ambient), u.emissive.copy(this.emissive), u.wrapAround = this.wrapAround, u.wrapRGB.copy(this.wrapRGB), u.map = this.map, u.lightMap = this.lightMap, u.specularMap = this.specularMap, u.envMap = this.envMap, u.combine = this.combine, u.reflectivity = this.reflectivity, u.refractionRatio = this.refractionRatio, u.fog = this.fog, u.shading = this.shading, u.shaderID = this.shaderID, u.vertexColors = this.vertexColors, u.skinning = this.skinning, u.morphTargets = this.morphTargets, u.morphNormals = this.morphNormals, u.sphere = this.sphere, u; + } + } + } + ), + /***/ + "./src/WebGL/materials/LineBasicMaterial.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/materials/LineBasicMaterial.ts ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + LineBasicMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../../colors */ + "./src/colors.ts" + ), g = e( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class _ extends g.Material { + constructor(o) { + super(), this.color = new l.Color(16777215), this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.vertexColors = !1, this.fog = !0, this.shaderID = "basic", this.setValues(o); + } + clone(o = new _()) { + return super.clone.call(this, o), o.color.copy(this.color), o; + } + } + } + ), + /***/ + "./src/WebGL/materials/Material.ts": ( + /*!*****************************************!*\ + !*** ./src/WebGL/materials/Material.ts ***! + \*****************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Material: () => ( + /* binding */ + o + ), + /* harmony export */ + MaterialIdCount: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ../constants/Sides */ + "./src/WebGL/constants/Sides.ts" + ), g = e( + /*! ../core */ + "./src/WebGL/core/index.ts" + ), _ = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), x = e( + /*! ../../colors */ + "./src/colors.ts" + ); + class o extends g.EventDispatcher { + constructor() { + super(...arguments), this.id = p++, this.name = "", this.side = l.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, this.wireframe = !1; + } + setValues(u = {}) { + if (u !== void 0) + for (var A in u) { + var C = u[A]; + if (C === void 0) { + console.warn("$3Dmol.Material: '" + A + "' parameter is undefined."); + continue; + } + if (A in this) { + var L = this[A]; + L instanceof x.Color && C instanceof x.Color ? L.copy(C) : L instanceof x.Color ? L.set(C) : L instanceof _.Vector3 && C instanceof _.Vector3 ? L.copy(C) : this[A] = C; + } + } + } + //TODO: might want to look into blending equations + clone(u = new o()) { + return u.name = this.name, u.side = this.side, u.opacity = this.opacity, u.transparent = this.transparent, u.depthTest = this.depthTest, u.depthWrite = this.depthWrite, u.stencilTest = this.stencilTest, u.polygonOffset = this.polygonOffset, u.polygonOffsetFactor = this.polygonOffsetFactor, u.polygonOffsetUnits = this.polygonOffsetUnits, u.alphaTest = this.alphaTest, u.overdraw = this.overdraw, u.visible = this.visible, u; + } + dispose() { + this.dispatchEvent({ type: "dispose" }); + } + } + let p = 0; + } + ), + /***/ + "./src/WebGL/materials/MeshDoubleLambertMaterial.ts": ( + /*!**********************************************************!*\ + !*** ./src/WebGL/materials/MeshDoubleLambertMaterial.ts ***! + \**********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + MeshDoubleLambertMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./../constants/Sides */ + "./src/WebGL/constants/Sides.ts" + ), g = e( + /*! ./MeshLambertMaterial */ + "./src/WebGL/materials/MeshLambertMaterial.ts" + ); + class _ extends g.MeshLambertMaterial { + constructor(o) { + super(o), this.shaderID = "lambertdouble", this.side = l.DoubleSide, this.outline = !1; + } + clone(o = new _()) { + return super.clone.call(this, o), o; + } + } + } + ), + /***/ + "./src/WebGL/materials/MeshLambertMaterial.ts": ( + /*!****************************************************!*\ + !*** ./src/WebGL/materials/MeshLambertMaterial.ts ***! + \****************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + MeshLambertMaterial: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ./../constants/Coloring */ + "./src/WebGL/constants/Coloring.ts" + ), g = e( + /*! ./../constants/Shading */ + "./src/WebGL/constants/Shading.ts" + ), _ = e( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ), x = e( + /*! ../../colors */ + "./src/colors.ts" + ), o = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + class p extends _.Material { + constructor(u) { + 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 o.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 = g.Shading.SmoothShading, this.shaderID = "lambert", this.vertexColors = l.Coloring.NoColors, this.skinning = !1, this.setValues(u); + } + clone(u = new p()) { + return super.clone.call(this, u), u.color.copy(this.color), u.ambient.copy(this.ambient), u.emissive.copy(this.emissive), u.wrapAround = this.wrapAround, u.wrapRGB.copy(this.wrapRGB), u.map = this.map, u.lightMap = this.lightMap, u.specularMap = this.specularMap, u.envMap = this.envMap, u.combine = this.combine, u.reflectivity = this.reflectivity, u.refractionRatio = this.refractionRatio, u.fog = this.fog, u.shading = this.shading, u.shaderID = this.shaderID, u.vertexColors = this.vertexColors, u.skinning = this.skinning, u.morphTargets = this.morphTargets, u.morphNormals = this.morphNormals, u; + } + } + } + ), + /***/ + "./src/WebGL/materials/MeshOutlineMaterial.ts": ( + /*!****************************************************!*\ + !*** ./src/WebGL/materials/MeshOutlineMaterial.ts ***! + \****************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + MeshOutlineMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../../colors */ + "./src/colors.ts" + ), g = e( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class _ extends g.Material { + constructor(o) { + super(), o = o || {}, this.fog = !0, this.shaderID = "outline", this.wireframe = !1, this.outlineColor = o.color || new l.Color(0, 0, 0), this.outlineWidth = o.width || 0.1, this.outlinePushback = o.pushback || 1; + } + clone(o = new _()) { + return super.clone.call(this, o), o.fog = this.fog, o.shaderID = this.shaderID, o.wireframe = this.wireframe, o; + } + } + } + ), + /***/ + "./src/WebGL/materials/SphereImposterMaterial.ts": ( + /*!*******************************************************!*\ + !*** ./src/WebGL/materials/SphereImposterMaterial.ts ***! + \*******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + SphereImposterMaterial: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ); + class g extends l.ImposterMaterial { + constructor(x) { + super(x), this.shaderID = "sphereimposter", this.setValues(x); + } + clone(x = new g()) { + return super.clone.call(this, x), x; + } + } + } + ), + /***/ + "./src/WebGL/materials/SphereImposterOutlineMaterial.ts": ( + /*!**************************************************************!*\ + !*** ./src/WebGL/materials/SphereImposterOutlineMaterial.ts ***! + \**************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + SphereImposterOutlineMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../../colors */ + "./src/colors.ts" + ), g = e( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ); + class _ extends g.ImposterMaterial { + constructor(o) { + super(o), o = o || {}, this.shaderID = "sphereimposteroutline", this.outlineColor = o.color || new l.Color(0, 0, 0), this.outlineWidth = o.width || 0.1, this.outlinePushback = o.pushback || 1, this.setValues(o); + } + clone(o = new _()) { + return super.clone.call(this, o), o.outlineColor = this.outlineColor, o.outlineWidth = this.outlineWidth, o.outlinePushback = this.outlinePushback, o; + } + } + } + ), + /***/ + "./src/WebGL/materials/SpriteMaterial.ts": ( + /*!***********************************************!*\ + !*** ./src/WebGL/materials/SpriteMaterial.ts ***! + \***********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + SpriteMaterial: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ../constants/SpriteAlignment */ + "./src/WebGL/constants/SpriteAlignment.ts" + ), g = e( + /*! ../core/Texture */ + "./src/WebGL/core/Texture.ts" + ), _ = e( + /*! ../../colors */ + "./src/colors.ts" + ), x = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ), o = e( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class p extends o.Material { + constructor(u) { + super(), this.color = new _.Color(16777215), this.map = new g.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 = l.SpriteAlignment.center.clone(), this.setValues(u), u = u || {}, u.depthTest === void 0 && (this.depthTest = !this.useScreenCoordinates), u.sizeAttenuation === void 0 && (this.sizeAttenuation = !this.useScreenCoordinates), u.scaleByViewPort === void 0 && (this.scaleByViewPort = !this.sizeAttenuation); + } + clone(u = new p()) { + return super.clone.call(this, u), u.color.copy(this.color), u.map = this.map, u.useScreenCoordinates = this.useScreenCoordinates, u.screenOffset = this.screenOffset, u.sizeAttenuation = this.sizeAttenuation, u.scaleByViewport = this.scaleByViewPort, u.alignment.copy(this.alignment), u.uvOffset.copy(this.uvOffset), u; + } + } + } + ), + /***/ + "./src/WebGL/materials/StickImposterMaterial.ts": ( + /*!******************************************************!*\ + !*** ./src/WebGL/materials/StickImposterMaterial.ts ***! + \******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + StickImposterMaterial: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ); + class g extends l.ImposterMaterial { + constructor(x) { + super(x), this.shaderID = "stickimposter", this.setValues(x); + } + clone(x = new g()) { + return super.clone.call(this, x), x; + } + } + } + ), + /***/ + "./src/WebGL/materials/StickImposterOutlineMaterial.ts": ( + /*!*************************************************************!*\ + !*** ./src/WebGL/materials/StickImposterOutlineMaterial.ts ***! + \*************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + StickImposterOutlineMaterial: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../../colors */ + "./src/colors.ts" + ), g = e( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ); + class _ extends g.ImposterMaterial { + constructor(o = {}) { + super(o), this.shaderID = "stickimposteroutline", this.outlineColor = new l.Color(0, 0, 0), this.outlineWidth = 0.1, this.outlinePushback = 1, o.color && (this.outlineColor = o.color), o.width && (this.outlineWidth = o.width), o.pushback && (this.outlinePushback = o.pushback), this.setValues(o); + } + clone(o = new _()) { + return super.clone.call(this, o), o.outlineColor = this.outlineColor, o.outlineWidth = this.outlineWidth, o.outlinePushback = this.outlinePushback, o; + } + } + } + ), + /***/ + "./src/WebGL/materials/VolumetricMaterial.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/materials/VolumetricMaterial.ts ***! + \***************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + VolumetricMaterial: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ../constants/Sides */ + "./src/WebGL/constants/Sides.ts" + ), g = e( + /*! ../../colors */ + "./src/colors.ts" + ), _ = e( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ); + class x extends _.Material { + constructor(p) { + super(), this.transparent = !1, this.volumetric = !0, this.color = new g.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 = l.FrontSide, this.setValues(p); + } + clone(p = new x()) { + return super.clone.call(this, p), p.transparent = this.transparent, p.volumetric = this.volumetric, p.color = this.color, p.transferfn = this.transferfn, p.map = this.map, p.extent = this.extent, p.maxdepth = this.maxdepth, p.unit = this.unit, p.texmatrix = this.texmatrix, p.transfermin = this.transfermin, p.transfermax = this.transfermax, p.subsamples = this.subsamples, p.shaderID = this.shaderID, p.side = this.side, p; + } + } + } + ), + /***/ + "./src/WebGL/materials/index.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/materials/index.ts ***! + \**************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + ImposterMaterial: () => ( + /* reexport safe */ + l.ImposterMaterial + ), + /* harmony export */ + InstancedMaterial: () => ( + /* reexport safe */ + g.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 */ + o.MeshDoubleLambertMaterial + ), + /* harmony export */ + MeshLambertMaterial: () => ( + /* reexport safe */ + p.MeshLambertMaterial + ), + /* harmony export */ + MeshOutlineMaterial: () => ( + /* reexport safe */ + E.MeshOutlineMaterial + ), + /* harmony export */ + SphereImposterMaterial: () => ( + /* reexport safe */ + u.SphereImposterMaterial + ), + /* harmony export */ + SphereImposterOutlineMaterial: () => ( + /* reexport safe */ + A.SphereImposterOutlineMaterial + ), + /* harmony export */ + SpriteMaterial: () => ( + /* reexport safe */ + C.SpriteMaterial + ), + /* harmony export */ + StickImposterMaterial: () => ( + /* reexport safe */ + L.StickImposterMaterial + ), + /* harmony export */ + StickImposterOutlineMaterial: () => ( + /* reexport safe */ + D.StickImposterOutlineMaterial + ), + /* harmony export */ + VolumetricMaterial: () => ( + /* reexport safe */ + r.VolumetricMaterial + ) + /* harmony export */ + }); + var l = e( + /*! ./ImposterMaterial */ + "./src/WebGL/materials/ImposterMaterial.ts" + ), g = e( + /*! ./InstancedMaterial */ + "./src/WebGL/materials/InstancedMaterial.ts" + ), _ = e( + /*! ./LineBasicMaterial */ + "./src/WebGL/materials/LineBasicMaterial.ts" + ), x = e( + /*! ./Material */ + "./src/WebGL/materials/Material.ts" + ), o = e( + /*! ./MeshDoubleLambertMaterial */ + "./src/WebGL/materials/MeshDoubleLambertMaterial.ts" + ), p = e( + /*! ./MeshLambertMaterial */ + "./src/WebGL/materials/MeshLambertMaterial.ts" + ), E = e( + /*! ./MeshOutlineMaterial */ + "./src/WebGL/materials/MeshOutlineMaterial.ts" + ), u = e( + /*! ./SphereImposterMaterial */ + "./src/WebGL/materials/SphereImposterMaterial.ts" + ), A = e( + /*! ./SphereImposterOutlineMaterial */ + "./src/WebGL/materials/SphereImposterOutlineMaterial.ts" + ), C = e( + /*! ./SpriteMaterial */ + "./src/WebGL/materials/SpriteMaterial.ts" + ), L = e( + /*! ./StickImposterMaterial */ + "./src/WebGL/materials/StickImposterMaterial.ts" + ), D = e( + /*! ./StickImposterOutlineMaterial */ + "./src/WebGL/materials/StickImposterOutlineMaterial.ts" + ), r = e( + /*! ./VolumetricMaterial */ + "./src/WebGL/materials/VolumetricMaterial.ts" + ); + } + ), + /***/ + "./src/WebGL/math/Quaternion.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/math/Quaternion.ts ***! + \**************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Quaternion: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + class l { + constructor(_, x, o, p) { + this.x = _ || 0, this.y = x || 0, this.z = o || 0, this.w = p !== void 0 ? p : 1; + } + set(_, x, o, p) { + return this.x = _, this.y = x, this.z = o, this.w = p, 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 o = _.x, p = _.y, E = _.z, u = _.w, A = x.x, C = x.y, L = x.z, D = x.w; + return this.x = o * D + u * A + p * L - E * C, this.y = p * D + u * C + E * A - o * L, this.z = E * D + u * L + o * C - p * A, this.w = u * D - o * A - p * C - E * L, this; + } + sub(_) { + return this.x -= _.x, this.y -= _.y, this.z -= _.z, this.w -= _.w, this; + } + clone() { + return new l(this.x, this.y, this.z, this.w); + } + setFromEuler(_) { + const x = Math.cos(_.x / 2), o = Math.cos(_.y / 2), p = Math.cos(_.z / 2), E = Math.sin(_.x / 2), u = Math.sin(_.y / 2), A = Math.sin(_.z / 2); + return this.x = E * o * p + x * u * A, this.y = x * u * p - E * o * A, this.z = x * o * A + E * u * p, this.w = x * o * p - E * u * A, this; + } + } + } + ), + /***/ + "./src/WebGL/math/Vector2.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/math/Vector2.ts ***! + \***********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Vector2: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + class l { + 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 l(this.x, this.y); + } + } + } + ), + /***/ + "./src/WebGL/math/index.ts": ( + /*!*********************************!*\ + !*** ./src/WebGL/math/index.ts ***! + \*********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Matrix3: () => ( + /* reexport safe */ + p.Matrix3 + ), + /* harmony export */ + Matrix4: () => ( + /* reexport safe */ + p.Matrix4 + ), + /* harmony export */ + Quaternion: () => ( + /* reexport safe */ + l.Quaternion + ), + /* harmony export */ + Ray: () => ( + /* reexport safe */ + p.Ray + ), + /* harmony export */ + Vector2: () => ( + /* reexport safe */ + g.Vector2 + ), + /* harmony export */ + Vector3: () => ( + /* reexport safe */ + p.Vector3 + ), + /* harmony export */ + clamp: () => ( + /* reexport safe */ + _.clamp + ), + /* harmony export */ + conversionMatrix3: () => ( + /* reexport safe */ + x.conversionMatrix3 + ), + /* harmony export */ + degToRad: () => ( + /* reexport safe */ + o.degToRad + ) + /* harmony export */ + }); + var l = e( + /*! ./Quaternion */ + "./src/WebGL/math/Quaternion.ts" + ), g = e( + /*! ./Vector2 */ + "./src/WebGL/math/Vector2.ts" + ), _ = e( + /*! ./utils/clamp */ + "./src/WebGL/math/utils/clamp.ts" + ), x = e( + /*! ./utils/conversionMatrix3 */ + "./src/WebGL/math/utils/conversionMatrix3.ts" + ), o = e( + /*! ./utils/degToRad */ + "./src/WebGL/math/utils/degToRad.ts" + ), p = e( + /*! ./math */ + "./src/WebGL/math/math.ts" + ); + } + ), + /***/ + "./src/WebGL/math/math.ts": ( + /*!********************************!*\ + !*** ./src/WebGL/math/math.ts ***! + \********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Matrix3: () => ( + /* binding */ + C + ), + /* harmony export */ + Matrix4: () => ( + /* binding */ + u + ), + /* harmony export */ + Ray: () => ( + /* binding */ + L + ), + /* harmony export */ + Vector3: () => ( + /* binding */ + A + ) + /* harmony export */ + }); + var l = e( + /*! ./utils/degToRad */ + "./src/WebGL/math/utils/degToRad.ts" + ), g = e( + /*! ./utils/clamp */ + "./src/WebGL/math/utils/clamp.ts" + ), _, x, o, p, E; + class u { + constructor(r = 1, n = 0, b = 0, f = 0, c = 0, t = 1, a = 0, h = 0, M = 0, w = 0, S = 1, T = 0, R = 0, z = 0, P = 0, B = 1) { + typeof r < "u" && typeof r != "number" ? this.elements = new Float32Array(r) : (this.elements = new Float32Array(16), this.elements[0] = r, this.elements[4] = n, this.elements[8] = b, this.elements[12] = f, this.elements[1] = c, this.elements[5] = t, this.elements[9] = a, this.elements[13] = h, this.elements[2] = M, this.elements[6] = w, this.elements[10] = S, this.elements[14] = T, this.elements[3] = R, this.elements[7] = z, this.elements[11] = P, this.elements[15] = B); + } + // eslint-disable-next-line no-unused-vars, class-methods-use-this + makeScale(r, n, b) { + throw new Error("Method not implemented."); + } + set(r, n, b, f, c, t, a, h, M, w, S, T, R, z, P, B) { + const U = this.elements; + return U[0] = r, U[4] = n, U[8] = b, U[12] = f, U[1] = c, U[5] = t, U[9] = a, U[13] = h, U[2] = M, U[6] = w, U[10] = S, U[14] = T, U[3] = R, U[7] = z, U[11] = P, U[15] = B, this; + } + identity() { + return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; + } + copy(r) { + const n = r.elements; + return this.set(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]), this; + } + matrix3FromTopLeft() { + const r = this.elements; + return new C(r[0], r[4], r[8], r[1], r[5], r[9], r[2], r[6], r[10]); + } + setRotationFromEuler(r, n) { + const b = this.elements, { x: f, y: c, z: t } = r, a = Math.cos(f), h = Math.sin(f), M = Math.cos(c), w = Math.sin(c), S = Math.cos(t), T = Math.sin(t); + if (n === void 0 || n === "XYZ") { + const R = a * S, z = a * T, P = h * S, B = h * T; + b[0] = M * S, b[4] = -M * T, b[8] = w, b[1] = z + P * w, b[5] = R - B * w, b[9] = -h * M, b[2] = B - R * w, b[6] = P + z * w, b[10] = a * M; + } else + console.error(`Error with matrix4 setRotationFromEuler. Order: ${n}`); + return this; + } + setRotationFromQuaternion(r) { + const n = this.elements, { x: b, y: f, z: c, w: t } = r, a = b + b, h = f + f, M = c + c, w = b * a, S = b * h, T = b * M, R = f * h, z = f * M, P = c * M, B = t * a, U = t * h, F = t * M; + return n[0] = 1 - (R + P), n[4] = S - F, n[8] = T + U, n[1] = S + F, n[5] = 1 - (w + P), n[9] = z - B, n[2] = T - U, n[6] = z + B, n[10] = 1 - (w + R), this; + } + multiplyMatrices(r, n) { + const b = r.elements, f = n.elements, c = this.elements, t = b[0], a = b[4], h = b[8], M = b[12], w = b[1], S = b[5], T = b[9], R = b[13], z = b[2], P = b[6], B = b[10], U = b[14], F = b[3], $ = b[7], W = b[11], N = b[15], G = f[0], k = f[4], j = f[8], Q = f[12], ie = f[1], pe = f[5], he = f[9], ue = f[13], se = f[2], ae = f[6], we = f[10], xe = f[14], Ie = f[3], oe = f[7], ve = f[11], re = f[15]; + return c[0] = t * G + a * ie + h * se + M * Ie, c[4] = t * k + a * pe + h * ae + M * oe, c[8] = t * j + a * he + h * we + M * ve, c[12] = t * Q + a * ue + h * xe + M * re, c[1] = w * G + S * ie + T * se + R * Ie, c[5] = w * k + S * pe + T * ae + R * oe, c[9] = w * j + S * he + T * we + R * ve, c[13] = w * Q + S * ue + T * xe + R * re, c[2] = z * G + P * ie + B * se + U * Ie, c[6] = z * k + P * pe + B * ae + U * oe, c[10] = z * j + P * he + B * we + U * ve, c[14] = z * Q + P * ue + B * xe + U * re, c[3] = F * G + $ * ie + W * se + N * Ie, c[7] = F * k + $ * pe + W * ae + N * oe, c[11] = F * j + $ * he + W * we + N * ve, c[15] = F * Q + $ * ue + W * xe + N * re, this; + } + multiplyScalar(r) { + const n = this.elements; + return n[0] *= r, n[4] *= r, n[8] *= r, n[12] *= r, n[1] *= r, n[5] *= r, n[9] *= r, n[13] *= r, n[2] *= r, n[6] *= r, n[10] *= r, n[14] *= r, n[3] *= r, n[7] *= r, n[11] *= r, n[15] *= r, this; + } + makeTranslation(r, n, b) { + return this.set(1, 0, 0, r, 0, 1, 0, n, 0, 0, 1, b, 0, 0, 0, 1), this; + } + // snap values close to integers to their integer value + // useful and identifying identity matrices + snap(r) { + const n = Math.pow(10, 4), b = this.elements; + for (let f = 0; f < 16; f++) { + const c = Math.round(b[f]); + c === Math.round(b[f] * n) / n && (b[f] = c); + } + return this; + } + transpose() { + const r = this.elements; + let n; + return n = r[1], r[1] = r[4], r[4] = n, n = r[2], r[2] = r[8], r[8] = n, n = r[6], r[6] = r[9], r[9] = n, n = r[3], r[3] = r[12], r[12] = n, n = r[7], r[7] = r[13], r[13] = n, n = r[11], r[11] = r[14], r[14] = n, this; + } + setPosition(r) { + const n = this.elements; + return n[12] = r.x, n[13] = r.y, n[14] = r.z, this; + } + translate(r) { + const n = this.elements; + return n[12] += r.x, n[13] += r.y, n[14] += r.z, this; + } + getInverse(r, n) { + const b = this.elements, f = r.elements, c = f[0], t = f[4], a = f[8], h = f[12], M = f[1], w = f[5], S = f[9], T = f[13], R = f[2], z = f[6], P = f[10], B = f[14], U = f[3], F = f[7], $ = f[11], W = f[15]; + b[0] = S * B * F - T * P * F + T * z * $ - w * B * $ - S * z * W + w * P * W, b[4] = h * P * F - a * B * F - h * z * $ + t * B * $ + a * z * W - t * P * W, b[8] = a * T * F - h * S * F + h * w * $ - t * T * $ - a * w * W + t * S * W, b[12] = h * S * z - a * T * z - h * w * P + t * T * P + a * w * B - t * S * B, b[1] = T * P * U - S * B * U - T * R * $ + M * B * $ + S * R * W - M * P * W, b[5] = a * B * U - h * P * U + h * R * $ - c * B * $ - a * R * W + c * P * W, b[9] = h * S * U - a * T * U - h * M * $ + c * T * $ + a * M * W - c * S * W, b[13] = a * T * R - h * S * R + h * M * P - c * T * P - a * M * B + c * S * B, b[2] = w * B * U - T * z * U + T * R * F - M * B * F - w * R * W + M * z * W, b[6] = h * z * U - t * B * U - h * R * F + c * B * F + t * R * W - c * z * W, b[10] = t * T * U - h * w * U + h * M * F - c * T * F - t * M * W + c * w * W, b[14] = h * w * R - t * T * R - h * M * z + c * T * z + t * M * B - c * w * B, b[3] = S * z * U - w * P * U - S * R * F + M * P * F + w * R * $ - M * z * $, b[7] = t * P * U - a * z * U + a * R * F - c * P * F - t * R * $ + c * z * $, b[11] = a * w * U - t * S * U - a * M * F + c * S * F + t * M * $ - c * w * $, b[15] = t * S * R - a * w * R + a * M * z - c * S * z - t * M * P + c * w * P; + const N = c * b[0] + M * b[4] + R * b[8] + U * b[12]; + if (N === 0) { + const G = "Matrix4.getInverse(): can't invert matrix, determinant is 0"; + if (n) + throw new Error(G); + return console.warn(G), this.identity(), this; + } + return this.multiplyScalar(1 / N), this; + } + isReflected() { + const r = this.elements, n = r[0], b = r[4], f = r[8], c = r[1], t = r[5], a = r[9], h = r[2], M = r[6], w = r[10]; + return n * t * w + // +aei + c * M * f + // +bfg + h * b * a - // +cdh + h * t * f - // -ceg + c * b * w - // -bdi + n * M * a < 0; + } + scale(r) { + const n = this.elements, { x: b } = r, { y: f } = r, { z: c } = r; + return n[0] *= b, n[4] *= f, n[8] *= c, n[1] *= b, n[5] *= f, n[9] *= c, n[2] *= b, n[6] *= f, n[10] *= c, n[3] *= b, n[7] *= f, n[11] *= c, this; + } + getMaxScaleOnAxis() { + const r = this.elements, n = r[0] * r[0] + r[1] * r[1] + r[2] * r[2], b = r[4] * r[4] + r[5] * r[5] + r[6] * r[6], f = r[8] * r[8] + r[9] * r[9] + r[10] * r[10]; + return Math.sqrt(Math.max(n, Math.max(b, f))); + } + makeFrustum(r, n, b, f, c, t) { + const a = this.elements, h = 2 * c / (n - r), M = 2 * c / (f - b), w = (n + r) / (n - r), S = (f + b) / (f - b), T = -(t + c) / (t - c), R = -2 * t * c / (t - c); + return a[0] = h, a[4] = 0, a[8] = w, a[12] = 0, a[1] = 0, a[5] = M, a[9] = S, a[13] = 0, a[2] = 0, a[6] = 0, a[10] = T, a[14] = R, a[3] = 0, a[7] = 0, a[11] = -1, a[15] = 0, this; + } + makePerspective(r, n, b, f) { + const c = b * Math.tan((0, l.degToRad)(r * 0.5)), t = -c, a = t * n, h = c * n; + return this.makeFrustum(a, h, t, c, b, f); + } + makeOrthographic(r, n, b, f, c, t) { + const a = this.elements, h = 1 / (n - r), M = 1 / (b - f), w = 1 / (t - c), S = (n + r) * h, T = (b + f) * M, R = (t + c) * w; + return a[0] = 2 * h, a[4] = 0, a[8] = 0, a[12] = -S, a[1] = 0, a[5] = 2 * M, a[9] = 0, a[13] = -T, a[2] = 0, a[6] = 0, a[10] = -2 * w, a[14] = -R, a[3] = 0, a[7] = 0, a[11] = 0, a[15] = 1, this; + } + isEqual(r) { + const n = r.elements, b = this.elements; + return b[0] === n[0] && b[4] === n[4] && b[8] === n[8] && b[12] === n[12] && b[1] === n[1] && b[5] === n[5] && b[9] === n[9] && b[13] === n[13] && b[2] === n[2] && b[6] === n[6] && b[10] === n[10] && b[14] === n[14] && b[3] === n[3] && b[7] === n[7] && b[11] === n[11] && b[15] === n[15]; + } + clone() { + const r = this.elements; + return new u(r[0], r[4], r[8], r[12], r[1], r[5], r[9], r[13], r[2], r[6], r[10], r[14], r[3], r[7], r[11], r[15]); + } + isIdentity() { + const r = this.elements; + return r[0] === 1 && r[4] === 0 && r[8] === 0 && r[12] === 0 && r[1] === 0 && r[5] === 1 && r[9] === 0 && r[13] === 0 && r[2] === 0 && r[6] === 0 && r[10] === 1 && r[14] === 0 && r[3] === 0 && r[7] === 0 && r[11] === 0 && r[15] === 1; + } + // return true if elements are with digits of identity + isNearlyIdentity(r) { + return this.clone().snap(r).isIdentity(); + } + getScale(r) { + const n = this.elements; + return r = r || new A(), o.set(n[0], n[1], n[2]), p.set(n[4], n[5], n[6]), E.set(n[8], n[9], n[10]), r.x = o.length(), r.y = p.length(), r.z = E.length(), r; + } + lookAt(r, n, b) { + const f = this.elements; + return E.subVectors(r, n).normalize(), E.length() === 0 && (E.z = 1), o.crossVectors(b, E).normalize(), o.length() === 0 && (E.x += 1e-4, o.crossVectors(b, E).normalize()), p.crossVectors(E, o), f[0] = o.x, f[4] = p.x, f[8] = E.x, f[1] = o.y, f[5] = p.y, f[9] = E.y, f[2] = o.z, f[6] = p.z, f[10] = E.z, this; + } + compose(r, n, b) { + const f = this.elements; + return _.identity(), _.setRotationFromQuaternion(n), x.makeScale(b.x, b.y, b.z), this.multiplyMatrices(_, x), f[12] = r.x, f[13] = r.y, f[14] = r.z, this; + } + } + _ = new u(), x = new u(); + class A { + constructor(r, n, b) { + this.x = r || 0, this.y = n || 0, this.z = b || 0, this.atomid = void 0; + } + set(r, n, b) { + return this.x = r, this.y = n, this.z = b, this; + } + copy(r) { + return this.x = r.x, this.y = r.y, this.z = r.z, this; + } + add(r) { + return this.x += r.x, this.y += r.y, this.z += r.z, this; + } + addVectors(r, n) { + return this.x = r.x + n.x, this.y = r.y + n.y, this.z = r.z + n.z, this; + } + multiplyVectors(r, n) { + return this.x = r.x * n.x, this.y = r.y * n.y, this.z = r.z * n.z, this; + } + sub(r) { + return this.x -= r.x, this.y -= r.y, this.z -= r.z, this; + } + subVectors(r, n) { + return this.x = r.x - n.x, this.y = r.y - n.y, this.z = r.z - n.z, this; + } + multiplyScalar(r) { + return this.x *= r, this.y *= r, this.z *= r, this; + } + divideScalar(r) { + return r !== 0 ? (this.x /= r, this.y /= r, this.z /= r) : (this.x = 0, this.y = 0, this.z = 0), this; + } + // accumulate maximum + max(r) { + return this.x = Math.max(this.x, r.x), this.y = Math.max(this.y, r.y), this.z = Math.max(this.z, r.z), this; + } + // accumulate min + min(r) { + return this.x = Math.min(this.x, r.x), this.y = Math.min(this.y, r.y), this.z = Math.min(this.z, r.z), this; + } + distanceTo(r) { + return Math.sqrt(this.distanceToSquared(r)); + } + distanceToSquared(r) { + const n = this.x - r.x, b = this.y - r.y, f = this.z - r.z; + return n * n + b * b + f * f; + } + applyMatrix3(r) { + const { x: n } = this, { y: b } = this, { z: f } = this, c = r.elements; + return this.x = c[0] * n + c[3] * b + c[6] * f, this.y = c[1] * n + c[4] * b + c[7] * f, this.z = c[2] * n + c[5] * b + c[8] * f, this; + } + applyMatrix4(r) { + const { x: n } = this, { y: b } = this, { z: f } = this, c = r.elements; + return this.x = c[0] * n + c[4] * b + c[8] * f + c[12], this.y = c[1] * n + c[5] * b + c[9] * f + c[13], this.z = c[2] * n + c[6] * b + c[10] * f + c[14], this; + } + applyProjection(r) { + const { x: n } = this, { y: b } = this, { z: f } = this, c = r.elements, t = c[3] * n + c[7] * b + c[11] * f + c[15]; + return this.x = (c[0] * n + c[4] * b + c[8] * f + c[12]) / t, this.y = (c[1] * n + c[5] * b + c[9] * f + c[13]) / t, this.z = (c[2] * n + c[6] * b + c[10] * f + c[14]) / t, this; + } + applyQuaternion(r) { + const { x: n } = this, { y: b } = this, { z: f } = this, c = r.x, t = r.y, a = r.z, h = r.w, M = {}; + M.x = 2 * (b * a - f * t), M.y = 2 * (f * c - n * a), M.z = 2 * (n * t - b * c); + const w = {}; + return w.x = M.y * a - M.z * t, w.y = M.z * c - M.x * a, w.z = M.x * t - M.y * c, this.x = n + h * M.x + w.x, this.y = b + h * M.y + w.y, this.z = f + h * M.z + w.z, this; + } + negate() { + return this.multiplyScalar(-1); + } + dot(r) { + return this.x * r.x + this.y * r.y + this.z * r.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(r) { + const { x: n } = this, { y: b } = this, { z: f } = this; + return this.x = b * r.z - f * r.y, this.y = f * r.x - n * r.z, this.z = n * r.y - b * r.x, this; + } + crossVectors(r, n) { + return this.x = r.y * n.z - r.z * n.y, this.y = r.z * n.x - r.x * n.z, this.z = r.x * n.y - r.y * n.x, this; + } + equals(r) { + return this.x == r.x && this.y == r.y && this.z == r.z; + } + getPositionFromMatrix(r) { + return this.x = r.elements[12], this.y = r.elements[13], this.z = r.elements[14], this; + } + setEulerFromRotationMatrix(r, n) { + const b = r.elements, f = b[0], c = b[4], t = b[8], a = b[5], h = b[9], M = b[6], w = b[10]; + return n === void 0 || n === "XYZ" ? (this.y = Math.asin((0, g.clamp)(t, -1, 1)), Math.abs(t) < 0.99999 ? (this.x = Math.atan2(-h, w), this.z = Math.atan2(-c, f)) : (this.x = Math.atan2(M, a), this.z = 0)) : console.error(`Error with vector's setEulerFromRotationMatrix: Unknown order: ${n}`), this; + } + rotateAboutVector(r, n) { + r.normalize(); + const b = Math.cos(n), f = Math.sin(n), c = this.clone().multiplyScalar(b), t = r.clone().cross(this).multiplyScalar(f), a = r.clone().multiplyScalar(r.clone().dot(this)).multiplyScalar(1 - b), h = c.add(t).add(a); + return this.x = h.x, this.y = h.y, this.z = h.z, this; + } + setFromMatrixPosition(r) { + const n = r.elements; + return this.x = n[12], this.y = n[13], this.z = n[14], this; + } + // unproject is defined after Matrix4 + transformDirection(r) { + const { x: n } = this, { y: b } = this, { z: f } = this, c = r.elements; + return this.x = c[0] * n + c[4] * b + c[8] * f, this.y = c[1] * n + c[5] * b + c[9] * f, this.z = c[2] * n + c[6] * b + c[10] * f, this.normalize(); + } + clone() { + return new A(this.x, this.y, this.z); + } + unproject(r) { + const n = _; + return n.multiplyMatrices(r.matrixWorld, n.getInverse(r.projectionMatrix)), this.applyMatrix4(n); + } + } + o = new A(), p = new A(), E = new A(); + class C { + constructor(r = 1, n = 0, b = 0, f = 0, c = 1, t = 0, a = 0, h = 0, M = 1) { + this.elements = new Float32Array(9), this.set(r, n, b, f, c, t, a, h, M); + } + set(r, n, b, f, c, t, a, h, M) { + const w = this.elements; + return w[0] = r, w[3] = n, w[6] = b, w[1] = f, w[4] = c, w[7] = t, w[2] = a, w[5] = h, w[8] = M, this; + } + identity() { + return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this; + } + copy(r) { + const n = r.elements; + this.set(n[0], n[3], n[6], n[1], n[4], n[7], n[2], n[5], n[8]); + } + multiplyScalar(r) { + const n = this.elements; + return n[0] *= r, n[3] *= r, n[6] *= r, n[1] *= r, n[4] *= r, n[7] *= r, n[2] *= r, n[5] *= r, n[8] *= r, this; + } + getInverse3(r) { + const n = r.elements, b = this.elements; + b[0] = n[4] * n[8] - n[5] * n[7], b[3] = n[6] * n[5] - n[3] * n[8], b[6] = n[3] * n[7] - n[6] * n[4], b[1] = n[7] * n[2] - n[1] * n[8], b[4] = n[0] * n[8] - n[6] * n[2], b[7] = n[1] * n[6] - n[0] * n[7], b[2] = n[1] * n[5] - n[2] * n[4], b[5] = n[2] * n[3] - n[0] * n[5], b[8] = n[0] * n[4] - n[1] * n[3]; + const f = n[0] * b[0] + n[3] * b[1] + n[6] * b[2]; + return this.multiplyScalar(1 / f), this; + } + getInverse(r, n) { + const b = r.elements, f = this.elements; + f[0] = b[10] * b[5] - b[6] * b[9], f[1] = -b[10] * b[1] + b[2] * b[9], f[2] = b[6] * b[1] - b[2] * b[5], f[3] = -b[10] * b[4] + b[6] * b[8], f[4] = b[10] * b[0] - b[2] * b[8], f[5] = -b[6] * b[0] + b[2] * b[4], f[6] = b[9] * b[4] - b[5] * b[8], f[7] = -b[9] * b[0] + b[1] * b[8], f[8] = b[5] * b[0] - b[1] * b[4]; + const c = b[0] * f[0] + b[1] * f[3] + b[2] * f[6]; + if (c === 0) { + const t = "Matrix3.getInverse(): can't invert matrix, determinant is 0"; + if (n) + throw new Error(t); + return console.warn(t), this.identity(), this; + } + return this.multiplyScalar(1 / c), this; + } + // https://en.wikipedia.org/wiki/Determinant + getDeterminant() { + const r = this.elements; + return r[0] * r[4] * r[8] + // +aei + r[1] * r[5] * r[6] + // +bfg + r[2] * r[3] * r[7] - // +cdh + r[2] * r[4] * r[6] - // -ceg + r[1] * r[3] * r[8] - // -bdi + r[0] * r[5] * r[7]; + } + transpose() { + let r; + const n = this.elements; + return r = n[1], n[1] = n[3], n[3] = r, r = n[2], n[2] = n[6], n[6] = r, r = n[5], n[5] = n[7], n[7] = r, this; + } + clone() { + const r = this.elements; + return new C(r[0], r[3], r[6], r[1], r[4], r[7], r[2], r[5], r[8]); + } + getMatrix4() { + const r = this.elements; + return new u(r[0], r[3], r[6], 0, r[1], r[4], r[7], 0, r[2], r[5], r[8], 0); + } + } + class L { + constructor(r, n) { + this.origin = r !== void 0 ? r : new A(), this.direction = n !== void 0 ? n : new A(); + } + set(r, n) { + return this.origin.copy(r), this.direction.copy(n), this; + } + copy(r) { + return this.origin.copy(r.origin), this.direction.copy(r.direction), this; + } + at(r, n) { + return (n || new A()).copy(this.direction).multiplyScalar(r).add(this.origin); + } + recast(r) { + const n = o; + return this.origin.copy(this.at(r, n)), this; + } + closestPointToPoint(r, n) { + const b = n || new A(); + b.subVectors(r, this.origin); + const f = b.dot(this.direction); + return b.copy(this.direction).multiplyScalar(f).add(this.origin); + } + distanceToPoint(r) { + const n = o, b = n.subVectors(r, this.origin).dot(this.direction); + return n.copy(this.direction).multiplyScalar(b).add(this.origin), n.distanceTo(r); + } + // eslint-disable-next-line class-methods-use-this + isIntersectionCylinder() { + } + isIntersectionSphere(r) { + return this.distanceToPoint(r.center) <= r.radius; + } + isIntersectionPlane(r) { + return r.normal.dot(this.direction) !== 0 || r.distanceToPoint(this.origin) === 0; + } + distanceToPlane(r) { + const n = r.normal.dot(this.direction); + return n === 0 ? r.distanceToPoint(this.origin) === 0 ? 0 : void 0 : -(this.origin.dot(r.normal) + r.constant) / n; + } + intersectPlane(r, n) { + const b = this.distanceToPlane(r); + if (b !== void 0) + return this.at(b, n); + } + applyMatrix4(r) { + return this.direction.add(this.origin).applyMatrix4(r), this.origin.applyMatrix4(r), this.direction.sub(this.origin), this; + } + clone() { + return new L().copy(this); + } + } + } + ), + /***/ + "./src/WebGL/math/utils/clamp.ts": ( + /*!***************************************!*\ + !*** ./src/WebGL/math/utils/clamp.ts ***! + \***************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + clamp: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + function l(g, _, x) { + return Math.min(Math.max(g, _), x); + } + } + ), + /***/ + "./src/WebGL/math/utils/conversionMatrix3.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/math/utils/conversionMatrix3.ts ***! + \***************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + conversionMatrix3: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../math */ + "./src/WebGL/math/math.ts" + ); + function g(_, x, o, p, E, u) { + p = p * Math.PI / 180, E = E * Math.PI / 180, u = u * Math.PI / 180; + const A = (b) => b * b, C = Math.cos(p), L = Math.cos(E), D = Math.cos(u), r = Math.sin(u); + return new l.Matrix3(_, x * D, o * L, 0, x * r, o * (C - L * D) / r, 0, 0, o * Math.sqrt(1 - A(C) - A(L) - A(D) + 2 * C * L * D) / r); + } + } + ), + /***/ + "./src/WebGL/math/utils/degToRad.ts": ( + /*!******************************************!*\ + !*** ./src/WebGL/math/utils/degToRad.ts ***! + \******************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + degToRad: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + const l = Math.PI / 180; + function g(_) { + return _ * l; + } + } + ), + /***/ + "./src/WebGL/objects/Line.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/objects/Line.ts ***! + \***********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Line: () => ( + /* binding */ + x + ), + /* harmony export */ + LineStyle: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../materials */ + "./src/WebGL/materials/index.ts" + ), g = e( + /*! ../core */ + "./src/WebGL/core/index.ts" + ), _; + (function(o) { + o[o.LineStrip = 0] = "LineStrip", o[o.LinePieces = 1] = "LinePieces"; + })(_ || (_ = {})); + class x extends g.Object3D { + constructor(p, E = new l.LineBasicMaterial({ + color: Math.random() * 16777215 + }), u = _.LineStrip) { + super(), this.geometry = p, this.material = E, this.type = u; + } + clone(p = new x(this.geometry, this.material, this.type)) { + return super.clone.call(this, p), p; + } + } + } + ), + /***/ + "./src/WebGL/objects/Mesh.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/objects/Mesh.ts ***! + \***********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Mesh: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../core */ + "./src/WebGL/core/index.ts" + ); + class g extends l.Object3D { + constructor(x, o) { + super(), this.geometry = x, this.material = o; + } + clone(x) { + return x === void 0 && (x = new g(this.geometry, this.material)), super.clone.call(this, x), x; + } + } + } + ), + /***/ + "./src/WebGL/objects/Sprite.ts": ( + /*!*************************************!*\ + !*** ./src/WebGL/objects/Sprite.ts ***! + \*************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Sprite: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../materials */ + "./src/WebGL/materials/index.ts" + ), g = e( + /*! ../core */ + "./src/WebGL/core/index.ts" + ); + class _ extends g.Object3D { + constructor(o = new l.SpriteMaterial()) { + super(), this.material = o, 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(o = new _(this.material)) { + return g.Object3D.prototype.clone.call(this, o), o; + } + } + } + ), + /***/ + "./src/WebGL/objects/index.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/objects/index.ts ***! + \************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Line: () => ( + /* reexport safe */ + l.Line + ), + /* harmony export */ + LineStyle: () => ( + /* reexport safe */ + l.LineStyle + ), + /* harmony export */ + Mesh: () => ( + /* reexport safe */ + g.Mesh + ), + /* harmony export */ + Sprite: () => ( + /* reexport safe */ + _.Sprite + ) + /* harmony export */ + }); + var l = e( + /*! ./Line */ + "./src/WebGL/objects/Line.ts" + ), g = e( + /*! ./Mesh */ + "./src/WebGL/objects/Mesh.ts" + ), _ = e( + /*! ./Sprite */ + "./src/WebGL/objects/Sprite.ts" + ); + } + ), + /***/ + "./src/WebGL/shaders/ShaderType.ts": ( + /*!*****************************************!*\ + !*** ./src/WebGL/shaders/ShaderType.ts ***! + \*****************************************/ + /***/ + (y, s, e) => { + e.r(s); + } + ), + /***/ + "./src/WebGL/shaders/index.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/shaders/index.ts ***! + \************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + ShaderLib: () => ( + /* reexport safe */ + l.ShaderLib + ), + /* harmony export */ + ShaderUtils: () => ( + /* reexport safe */ + g.ShaderUtils + ), + /* harmony export */ + basic: () => ( + /* reexport safe */ + l.basic + ), + /* harmony export */ + clone: () => ( + /* reexport safe */ + g.clone + ), + /* harmony export */ + instanced: () => ( + /* reexport safe */ + l.instanced + ), + /* harmony export */ + lambert: () => ( + /* reexport safe */ + l.lambert + ), + /* harmony export */ + lambertdouble: () => ( + /* reexport safe */ + l.lambertdouble + ), + /* harmony export */ + outline: () => ( + /* reexport safe */ + l.outline + ), + /* harmony export */ + screen: () => ( + /* reexport safe */ + l.screen + ), + /* harmony export */ + screenaa: () => ( + /* reexport safe */ + l.screenaa + ), + /* harmony export */ + sphereimposter: () => ( + /* reexport safe */ + l.sphereimposter + ), + /* harmony export */ + sphereimposteroutline: () => ( + /* reexport safe */ + l.sphereimposteroutline + ), + /* harmony export */ + sprite: () => ( + /* reexport safe */ + l.sprite + ), + /* harmony export */ + stickimposter: () => ( + /* reexport safe */ + l.stickimposter + ), + /* harmony export */ + stickimposteroutline: () => ( + /* reexport safe */ + l.stickimposteroutline + ), + /* harmony export */ + volumetric: () => ( + /* reexport safe */ + l.volumetric + ) + /* harmony export */ + }); + var l = e( + /*! ./lib */ + "./src/WebGL/shaders/lib/index.ts" + ), g = e( + /*! ./utils */ + "./src/WebGL/shaders/utils/index.ts" + ); + e( + /*! ./ShaderType */ + "./src/WebGL/shaders/ShaderType.ts" + ); + } + ), + /***/ + "./src/WebGL/shaders/lib/basic/index.ts": ( + /*!**********************************************!*\ + !*** ./src/WebGL/shaders/lib/basic/index.ts ***! + \**********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + basic: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/basic/uniforms.ts" + ), g = e( + /*! ./basic.frag */ + "./src/WebGL/shaders/lib/basic/basic.frag" + ), _ = e( + /*! ./basic.vert */ + "./src/WebGL/shaders/lib/basic/basic.vert" + ); + const x = { + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/basic/uniforms.ts": ( + /*!*************************************************!*\ + !*** ./src/WebGL/shaders/lib/basic/uniforms.ts ***! + \*************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new l.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 ***! + \****************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + ShaderLib: () => ( + /* binding */ + n + ), + /* harmony export */ + basic: () => ( + /* reexport safe */ + l.basic + ), + /* harmony export */ + instanced: () => ( + /* reexport safe */ + g.instanced + ), + /* harmony export */ + lambert: () => ( + /* reexport safe */ + _.lambert + ), + /* harmony export */ + lambertdouble: () => ( + /* reexport safe */ + x.lambertdouble + ), + /* harmony export */ + outline: () => ( + /* reexport safe */ + o.outline + ), + /* harmony export */ + screen: () => ( + /* reexport safe */ + p.screen + ), + /* harmony export */ + screenaa: () => ( + /* reexport safe */ + E.screenaa + ), + /* harmony export */ + sphereimposter: () => ( + /* reexport safe */ + u.sphereimposter + ), + /* harmony export */ + sphereimposteroutline: () => ( + /* reexport safe */ + A.sphereimposteroutline + ), + /* harmony export */ + sprite: () => ( + /* reexport safe */ + C.sprite + ), + /* harmony export */ + stickimposter: () => ( + /* reexport safe */ + L.stickimposter + ), + /* harmony export */ + stickimposteroutline: () => ( + /* reexport safe */ + D.stickimposteroutline + ), + /* harmony export */ + volumetric: () => ( + /* reexport safe */ + r.volumetric + ) + /* harmony export */ + }); + var l = e( + /*! ./basic */ + "./src/WebGL/shaders/lib/basic/index.ts" + ), g = e( + /*! ./instanced */ + "./src/WebGL/shaders/lib/instanced/index.ts" + ), _ = e( + /*! ./lambert */ + "./src/WebGL/shaders/lib/lambert/index.ts" + ), x = e( + /*! ./lambertdouble */ + "./src/WebGL/shaders/lib/lambertdouble/index.ts" + ), o = e( + /*! ./outline */ + "./src/WebGL/shaders/lib/outline/index.ts" + ), p = e( + /*! ./screen */ + "./src/WebGL/shaders/lib/screen/index.ts" + ), E = e( + /*! ./screenaa */ + "./src/WebGL/shaders/lib/screenaa/index.ts" + ), u = e( + /*! ./sphereimposter */ + "./src/WebGL/shaders/lib/sphereimposter/index.ts" + ), A = e( + /*! ./sphereimposteroutline */ + "./src/WebGL/shaders/lib/sphereimposteroutline/index.ts" + ), C = e( + /*! ./sprite */ + "./src/WebGL/shaders/lib/sprite/index.ts" + ), L = e( + /*! ./stickimposter */ + "./src/WebGL/shaders/lib/stickimposter/index.ts" + ), D = e( + /*! ./stickimposteroutline */ + "./src/WebGL/shaders/lib/stickimposteroutline/index.ts" + ), r = e( + /*! ./volumetric */ + "./src/WebGL/shaders/lib/volumetric/index.ts" + ); + const n = { + basic: l.basic, + instanced: g.instanced, + lambert: _.lambert, + lambertdouble: x.lambertdouble, + outline: o.outline, + screen: p.screen, + screenaa: E.screenaa, + sphereimposter: u.sphereimposter, + sphereimposteroutline: A.sphereimposteroutline, + sprite: C.sprite, + stickimposter: L.stickimposter, + stickimposteroutline: D.stickimposteroutline, + volumetric: r.volumetric + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/instanced/index.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/shaders/lib/instanced/index.ts ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + instanced: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/instanced/uniforms.ts" + ), g = e( + /*! ./instanced.frag */ + "./src/WebGL/shaders/lib/instanced/instanced.frag" + ), _ = e( + /*! ./instanced.vert */ + "./src/WebGL/shaders/lib/instanced/instanced.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/instanced/uniforms.ts": ( + /*!*****************************************************!*\ + !*** ./src/WebGL/shaders/lib/instanced/uniforms.ts ***! + \*****************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new l.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 ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + lambert: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/lambert/uniforms.ts" + ), g = e( + /*! ./lambert.frag */ + "./src/WebGL/shaders/lib/lambert/lambert.frag" + ), _ = e( + /*! ./lambert.vert */ + "./src/WebGL/shaders/lib/lambert/lambert.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/lambert/uniforms.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/shaders/lib/lambert/uniforms.ts ***! + \***************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new l.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 ***! + \******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + lambertdouble: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/lambertdouble/uniforms.ts" + ), g = e( + /*! ./lambertdouble.frag */ + "./src/WebGL/shaders/lib/lambertdouble/lambertdouble.frag" + ), _ = e( + /*! ./lambertdouble.vert */ + "./src/WebGL/shaders/lib/lambertdouble/lambertdouble.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/lambertdouble/uniforms.ts": ( + /*!*********************************************************!*\ + !*** ./src/WebGL/shaders/lib/lambertdouble/uniforms.ts ***! + \*********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new l.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 ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + outline: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/outline/uniforms.ts" + ), g = e( + /*! ./outline.frag */ + "./src/WebGL/shaders/lib/outline/outline.frag" + ), _ = e( + /*! ./outline.vert */ + "./src/WebGL/shaders/lib/outline/outline.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/outline/uniforms.ts": ( + /*!***************************************************!*\ + !*** ./src/WebGL/shaders/lib/outline/uniforms.ts ***! + \***************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + outlineColor: { type: "c", value: new l.Color(0, 0, 0) }, + fogColor: { type: "c", value: new l.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 ***! + \***********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + screen: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/screen/uniforms.ts" + ), g = e( + /*! ./screen.frag */ + "./src/WebGL/shaders/lib/screen/screen.frag" + ), _ = e( + /*! ./screen.vert */ + "./src/WebGL/shaders/lib/screen/screen.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/screen/uniforms.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/shaders/lib/screen/uniforms.ts ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + const l = {}; + } + ), + /***/ + "./src/WebGL/shaders/lib/screenaa/index.ts": ( + /*!*************************************************!*\ + !*** ./src/WebGL/shaders/lib/screenaa/index.ts ***! + \*************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + screenaa: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/screenaa/uniforms.ts" + ), g = e( + /*! ./screenaa.frag */ + "./src/WebGL/shaders/lib/screenaa/screenaa.frag" + ), _ = e( + /*! ./screenaa.vert */ + "./src/WebGL/shaders/lib/screenaa/screenaa.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/screenaa/uniforms.ts": ( + /*!****************************************************!*\ + !*** ./src/WebGL/shaders/lib/screenaa/uniforms.ts ***! + \****************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + const l = {}; + } + ), + /***/ + "./src/WebGL/shaders/lib/sphereimposter/index.ts": ( + /*!*******************************************************!*\ + !*** ./src/WebGL/shaders/lib/sphereimposter/index.ts ***! + \*******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + sphereimposter: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/sphereimposter/uniforms.ts" + ), g = e( + /*! ./sphereimposter.frag */ + "./src/WebGL/shaders/lib/sphereimposter/sphereimposter.frag" + ), _ = e( + /*! ./sphereimposter.vert */ + "./src/WebGL/shaders/lib/sphereimposter/sphereimposter.vert" + ); + const x = { + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/sphereimposter/uniforms.ts": ( + /*!**********************************************************!*\ + !*** ./src/WebGL/shaders/lib/sphereimposter/uniforms.ts ***! + \**********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new l.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 ***! + \**************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + sphereimposteroutline: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts" + ), g = e( + /*! ./sphereimposteroutline.frag */ + "./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.frag" + ), _ = e( + /*! ./sphereimposteroutline.vert */ + "./src/WebGL/shaders/lib/sphereimposteroutline/sphereimposteroutline.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts": ( + /*!*****************************************************************!*\ + !*** ./src/WebGL/shaders/lib/sphereimposteroutline/uniforms.ts ***! + \*****************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + outlineColor: { type: "c", value: new l.Color(0, 0, 0) }, + fogColor: { type: "c", value: new l.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 ***! + \***********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + sprite: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/sprite/uniforms.ts" + ), g = e( + /*! ./sprite.frag */ + "./src/WebGL/shaders/lib/sprite/sprite.frag" + ), _ = e( + /*! ./sprite.vert */ + "./src/WebGL/shaders/lib/sprite/sprite.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/sprite/uniforms.ts": ( + /*!**************************************************!*\ + !*** ./src/WebGL/shaders/lib/sprite/uniforms.ts ***! + \**************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + const l = {}; + } + ), + /***/ + "./src/WebGL/shaders/lib/stickimposter/index.ts": ( + /*!******************************************************!*\ + !*** ./src/WebGL/shaders/lib/stickimposter/index.ts ***! + \******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + stickimposter: () => ( + /* binding */ + p + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/stickimposter/uniforms.ts" + ), g = e( + /*! ../../utils/stickimposterFragmentShader.partial.frag */ + "./src/WebGL/shaders/utils/stickimposterFragmentShader.partial.frag" + ), _ = e( + /*! ./stickimposter.partial.frag */ + "./src/WebGL/shaders/lib/stickimposter/stickimposter.partial.frag" + ), x = e( + /*! ./stickimposter.vert */ + "./src/WebGL/shaders/lib/stickimposter/stickimposter.vert" + ); + const p = { + fragmentShader: [g.default, _.default].join(` +`).replace("#define GLSLIFY 1", ""), + vertexShader: x.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/stickimposter/uniforms.ts": ( + /*!*********************************************************!*\ + !*** ./src/WebGL/shaders/lib/stickimposter/uniforms.ts ***! + \*********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new l.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 ***! + \*************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + stickimposteroutline: () => ( + /* binding */ + o + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts" + ), g = e( + /*! ../../utils/stickimposterFragmentShader.partial.frag */ + "./src/WebGL/shaders/utils/stickimposterFragmentShader.partial.frag" + ), _ = e( + /*! ./stickimposteroutline.vert */ + "./src/WebGL/shaders/lib/stickimposteroutline/stickimposteroutline.vert" + ); + const o = { + fragmentShader: (g.default + "gl_FragColor = vec4(color,1.0);}").replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts": ( + /*!****************************************************************!*\ + !*** ./src/WebGL/shaders/lib/stickimposteroutline/uniforms.ts ***! + \****************************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new l.Color(1, 1, 1) }, + fogNear: { type: "f", value: 1 }, + fogFar: { type: "f", value: 2e3 }, + outlineColor: { type: "c", value: new l.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 ***! + \***************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + volumetric: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./uniforms */ + "./src/WebGL/shaders/lib/volumetric/uniforms.ts" + ), g = e( + /*! ./volumetric.frag */ + "./src/WebGL/shaders/lib/volumetric/volumetric.frag" + ), _ = e( + /*! ./volumetric.vert */ + "./src/WebGL/shaders/lib/volumetric/volumetric.vert" + ); + const x = { + fragmentShader: g.default.replace("#define GLSLIFY 1", ""), + vertexShader: _.default.replace("#define GLSLIFY 1", ""), + uniforms: l.uniforms + }; + } + ), + /***/ + "./src/WebGL/shaders/lib/volumetric/uniforms.ts": ( + /*!******************************************************!*\ + !*** ./src/WebGL/shaders/lib/volumetric/uniforms.ts ***! + \******************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + uniforms: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../../colors */ + "./src/colors.ts" + ); + const g = { + opacity: { type: "f", value: 1 }, + fogColor: { type: "c", value: new l.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 ***! + \******************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + clone: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../../colors */ + "./src/colors.ts" + ); + function g(_) { + let x = {}; + for (const p in _) { + x[p] = {}, x[p].type = _[p].type; + var o = _[p].value; + o instanceof l.Color ? x[p].value = o.clone() : typeof o == "number" ? x[p].value = o : o instanceof Array ? x[p].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 ***! + \******************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + ShaderUtils: () => ( + /* binding */ + _ + ), + /* harmony export */ + clone: () => ( + /* reexport safe */ + l.clone + ) + /* harmony export */ + }); + var l = e( + /*! ./clone */ + "./src/WebGL/shaders/utils/clone.ts" + ), g = e( + /*! ./stickimposterFragmentShader.partial.frag */ + "./src/WebGL/shaders/utils/stickimposterFragmentShader.partial.frag" + ); + const _ = { + clone: l.clone, + stickimposterFragmentShader: g.default + }; + } + ), + /***/ + "./src/WebGL/shapes/Cylinder.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/shapes/Cylinder.ts ***! + \**************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Cylinder: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + let g = new l.Vector3(); + class _ { + constructor(o = new l.Vector3(), p = new l.Vector3(), E = 0) { + this.c1 = o, this.c2 = p, this.radius = E, this.direction = new l.Vector3().subVectors(this.c2, this.c1).normalize(); + } + copy(o) { + return this.c1.copy(o.c1), this.c2.copy(o.c2), this.direction.copy(o.direction), this.radius = o.radius, this; + } + lengthSq() { + return g.subVectors(this.c2, this.c1).lengthSq(); + } + applyMatrix4(o) { + return this.direction.add(this.c1).applyMatrix4(o), this.c1.applyMatrix4(o), this.c2.applyMatrix4(o), this.direction.sub(this.c1).normalize(), this.radius = this.radius * o.getMaxScaleOnAxis(), this; + } + } + } + ), + /***/ + "./src/WebGL/shapes/Sphere.ts": ( + /*!************************************!*\ + !*** ./src/WebGL/shapes/Sphere.ts ***! + \************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Sphere: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + class g { + constructor(x = { x: 0, y: 0, z: 0 }, o = 0) { + this.center = new l.Vector3(x.x, x.y, x.z), this.radius = o; + } + set(x, o) { + return this.center.copy(x), this.radius = o, 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 g().copy(this); + } + } + } + ), + /***/ + "./src/WebGL/shapes/Triangle.ts": ( + /*!**************************************!*\ + !*** ./src/WebGL/shapes/Triangle.ts ***! + \**************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Triangle: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../math */ + "./src/WebGL/math/index.ts" + ); + const g = new l.Vector3(); + class _ { + constructor(o = new l.Vector3(), p = new l.Vector3(), E = new l.Vector3()) { + this.a = o, this.b = p, this.c = E; + } + copy(o) { + return this.a.copy(o.a), this.b.copy(o.b), this.c.copy(o.c), this; + } + applyMatrix4(o) { + return this.a.applyMatrix4(o), this.b.applyMatrix4(o), this.c.applyMatrix4(o), this; + } + getNormal() { + var o = this.a.clone(); + return o.sub(this.b), g.subVectors(this.c, this.b), o.cross(g), o.normalize(), o; + } + } + } + ), + /***/ + "./src/WebGL/shapes/index.ts": ( + /*!***********************************!*\ + !*** ./src/WebGL/shapes/index.ts ***! + \***********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Cylinder: () => ( + /* reexport safe */ + g.Cylinder + ), + /* harmony export */ + Sphere: () => ( + /* reexport safe */ + l.Sphere + ), + /* harmony export */ + Triangle: () => ( + /* reexport safe */ + _.Triangle + ) + /* harmony export */ + }); + var l = e( + /*! ./Sphere */ + "./src/WebGL/shapes/Sphere.ts" + ), g = e( + /*! ./Cylinder */ + "./src/WebGL/shapes/Cylinder.ts" + ), _ = e( + /*! ./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(y) { + for (y.setStyle(select, style), UI && UI.createSelectionAndStyle(select, style), i = 0; i < selectstylelist.length; i++) { + let s = selectstylelist[i][0] || {}, e = selectstylelist[i][1] || { line: {} }; + y.setStyle(s, e), UI && UI.createSelectionAndStyle(select, style); + } + for (i = 0; i < surfaces.length; i++) { + let s = surfaces[i][0] || {}, e = surfaces[i][1] || {}; + UI ? y.addSurface(_ProteinSurface4__WEBPACK_IMPORTED_MODULE_1__.SurfaceType.VDW, e, s, s).then((g) => { + UI.loadSurface("VDW", s, e, g); + }) : y.addSurface(_ProteinSurface4__WEBPACK_IMPORTED_MODULE_1__.SurfaceType.VDW, e, s, s); + } + for (i = 0; i < labels.length; i++) { + let s = labels[i][0] || {}, e = labels[i][1] || {}; + y.addResLabels(s, e); + } + y.render(), y.zoomTo(zoomto), spin && y.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 (y) { + console.log(y), 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 ***! + \***********************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + CC: () => ( + /* binding */ + g + ), + /* harmony export */ + Color: () => ( + /* binding */ + l + ), + /* harmony export */ + builtinColorSchemes: () => ( + /* binding */ + A + ), + /* harmony export */ + chains: () => ( + /* binding */ + u + ), + /* harmony export */ + elementColors: () => ( + /* binding */ + p + ), + /* harmony export */ + htmlColors: () => ( + /* binding */ + _ + ), + /* harmony export */ + residues: () => ( + /* binding */ + E + ), + /* harmony export */ + ssColors: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + class l { + constructor(L, D, r) { + return this.r = 0, this.g = 0, this.b = 0, arguments.length > 1 && typeof L == "number" ? (this.r = L || 0, this.g = D || 0, this.b = r || 0, this) : this.set(L || 0); + } + set(L) { + return L instanceof l ? L.clone() : (typeof L == "number" ? this.setHex(L) : typeof L == "object" && (this.r = (L == null ? void 0 : L.r) || 0, this.g = (L == null ? void 0 : L.g) || 0, this.b = (L == null ? void 0 : L.b) || 0), this); + } + setHex(L) { + return L = Math.floor(L), this.r = (L >> 16 & 255) / 255, this.g = (L >> 8 & 255) / 255, this.b = (L & 255) / 255, this; + } + getHex() { + var L = Math.round(this.r * 255), D = Math.round(this.g * 255), r = Math.round(this.b * 255); + return L << 16 | D << 8 | r; + } + clone() { + return new l(this.r, this.g, this.b); + } + copy(L) { + return this.r = L.r, this.g = L.g, this.b = L.b, this; + } + //return object that represents color components from 0 to 255 + scaled() { + var L = {}; + return L.r = Math.round(this.r * 255), L.g = Math.round(this.g * 255), L.b = Math.round(this.b * 255), L.a = 1, L; + } + } + class g { + static color(L) { + if (!L) + return g.cache[0]; + if (L instanceof l) + return L; + if (typeof L == "number" && typeof g.cache[L] < "u") + return g.cache[L]; + if (L && Array.isArray(L)) + return L.map(g.color); + let D = g.getHex(L), r = new l(D); + return g.cache[D] = r, r; + } + static getHex(L) { + var D; + if (Array.isArray(L)) + return L.map(g.getHex); + if (typeof L == "string") { + let r = L; + if (!isNaN(parseInt(r))) + return parseInt(r); + if (r = r.trim(), r.length == 4 && r[0] == "#" && (r = "#" + r[1] + r[1] + r[2] + r[2] + r[3] + r[3]), r.length == 7 && r[0] == "#") + return parseInt(r.substring(1), 16); + let n = g.rgbRegEx.exec(r); + if (n) { + n[1] != "" && console.log("WARNING: Opacity value in rgba ignored. Specify separately as opacity attribute."); + let b = 0; + for (let f = 2; f < 5; f++) { + b *= 256; + let c = n[f].endsWith("%") ? 255 * parseFloat(n[f]) / 100 : parseFloat(n[f]); + b += Math.round(c); + } + return b; + } + return ((D = window == null ? void 0 : window.$3Dmol) === null || D === void 0 ? void 0 : D.htmlColors[L.toLowerCase()]) || 0; + } + return L; + } + } + g.rgbRegEx = /rgb(a?)\(\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)\s*,\s*([^ ,\)\t]+)/i, g.cache = { 0: new l(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 } + }, o = { + 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 + }, p = { + 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: o, + defaultColors: Object.assign({}, o), + greenCarbon: Object.assign(Object.assign({}, o), { C: 65280 }), + cyanCarbon: Object.assign(Object.assign({}, o), { C: 65535 }), + magentaCarbon: Object.assign(Object.assign({}, o), { C: 16711935 }), + yellowCarbon: Object.assign(Object.assign({}, o), { C: 16776960 }), + whiteCarbon: Object.assign(Object.assign({}, o), { C: 16777215 }), + orangeCarbon: Object.assign(Object.assign({}, o), { C: 16753920 }), + purpleCarbon: Object.assign(Object.assign({}, o), { C: 8388736 }), + blueCarbon: Object.assign(Object.assign({}, o), { 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 + } + }, u = { + /** @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 + } + }, A = { + /** secondary structure pymol */ + ssPyMol: { prop: "ss", map: x.pyMol }, + ssJmol: { prop: "ss", map: x.Jmol }, + Jmol: { prop: "elem", map: p.Jmol }, + amino: { prop: "resn", map: E.amino }, + shapely: { prop: "resn", map: E.shapely }, + nucleic: { prop: "resn", map: E.nucleic }, + chain: { prop: "chain", map: u.atom }, + rasmol: { prop: "elem", map: p.rasmol }, + default: { prop: "elem", map: p.defaultColors }, + greenCarbon: { prop: "elem", map: p.greenCarbon }, + chainHetatm: { prop: "chain", map: u.hetatm }, + cyanCarbon: { prop: "elem", map: p.cyanCarbon }, + magentaCarbon: { prop: "elem", map: p.magentaCarbon }, + purpleCarbon: { prop: "elem", map: p.purpleCarbon }, + whiteCarbon: { prop: "elem", map: p.whiteCarbon }, + orangeCarbon: { prop: "elem", map: p.orangeCarbon }, + yellowCarbon: { prop: "elem", map: p.yellowCarbon }, + blueCarbon: { prop: "elem", map: p.blueCarbon } + }; + } + ), + /***/ + "./src/glcartoon.ts": ( + /*!**************************!*\ + !*** ./src/glcartoon.ts ***! + \**************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + drawCartoon: () => ( + /* binding */ + z + ), + /* harmony export */ + subdivide_spline: () => ( + /* binding */ + u + ) + /* harmony export */ + }); + var l = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), g = e( + /*! ./WebGL/shapes */ + "./src/WebGL/shapes/index.ts" + ), _ = e( + /*! ./WebGL */ + "./src/WebGL/index.ts" + ), x = e( + /*! ./Gradient */ + "./src/Gradient.ts" + ), o = e( + /*! ./colors */ + "./src/colors.ts" + ), p = e( + /*! ./GLDraw */ + "./src/GLDraw.ts" + ), E = e( + /*! ./utilities */ + "./src/utilities.ts" + ); + function u(P, B) { + var U = [], F = P; + F = [], F.push(P[0]); + var $, W, N, G, k, j, Q, ie, pe; + for ($ = 1, W = P.length - 1; $ < W; $++) + if (k = P[$], j = P[$ + 1], k.smoothen) { + var he = new l.Vector3((k.x + j.x) / 2, (k.y + j.y) / 2, (k.z + j.z) / 2); + he.atom = k.atom, F.push(he); + } else + F.push(k); + for (F.push(P[P.length - 1]), $ = -1, N = F.length; $ <= N - 3; $++) + if (G = F[$ === -1 ? 0 : $], k = F[$ + 1], j = F[$ + 2], Q = F[$ === N - 3 ? N - 1 : $ + 3], ie = new l.Vector3().subVectors(j, G).multiplyScalar(0.5), pe = new l.Vector3().subVectors(Q, k).multiplyScalar(0.5), !j.skip) + for (var ue = 0; ue < B; ue++) { + var se = 1 / B * ue, ae = k.x + se * ie.x + se * se * (-3 * k.x + 3 * j.x - 2 * ie.x - pe.x) + se * se * se * (2 * k.x - 2 * j.x + ie.x + pe.x), we = k.y + se * ie.y + se * se * (-3 * k.y + 3 * j.y - 2 * ie.y - pe.y) + se * se * se * (2 * k.y - 2 * j.y + ie.y + pe.y), xe = k.z + se * ie.z + se * se * (-3 * k.z + 3 * j.z - 2 * ie.z - pe.z) + se * se * se * (2 * k.z - 2 * j.z + ie.z + pe.z), Ie = new l.Vector3(ae, we, xe); + ue < B / 2 ? Ie.atom = k.atom : Ie.atom = j.atom, U.push(Ie); + } + return U.push(F[F.length - 1]), U; + } + const A = 0.5, C = 1.3, L = 0.8, D = 0.4, r = 0.4; + function n(P, B, U, F) { + for (var $, W, N, G, k = 0, j = B.length; k < j; k++) { + G = Math.round(k * (F.length - 1) / j), N = o.CC.color(F[G]); + var Q = P.updateGeoGroup(2), ie = Q.vertexArray, pe = Q.colorArray, he = Q.faceArray; + $ = Q.vertices, W = $ * 3, ie[W] = B[k].x, ie[W + 1] = B[k].y, ie[W + 2] = B[k].z, ie[W + 3] = U[k].x, ie[W + 4] = U[k].y, ie[W + 5] = U[k].z; + for (var ue = 0; ue < 6; ++ue) + pe[W + 3 * ue] = N.r, pe[W + 1 + 3 * ue] = N.g, pe[W + 2 + 3 * ue] = N.b; + if (k > 0) { + var se = [$, $ + 1, $ - 1, $ - 2], ae = Q.faceidx; + he[ae] = se[0], he[ae + 1] = se[1], he[ae + 2] = se[3], he[ae + 3] = se[1], he[ae + 4] = se[2], he[ae + 5] = se[3], Q.faceidx += 6; + } + Q.vertices += 2; + } + } + function b(P, B, U, F, $, W, N) { + var G, k, j, Q; + if (j = B.length, j < 2 || B[0].length < 2) + return; + for (G = 0; G < j; G++) + B[G] = u(B[G], F); + if (Q = B[0].length, !$) + return n(P, B[0], B[j - 1], U); + var ie, pe, he, ue, se, ae, we = [], xe = [], Ie = []; + for (k = 0; k < j; k++) + we.push(0.25 + 1.5 * Math.sqrt((j - 1) * k - Math.pow(k, 2)) / (j - 1)), xe.push(0.5), Ie.push(2 * (Math.pow(k / j, 2) - k / j) + 0.6); + var oe = []; + for (k = 0; k < j * 2 - 1; k++) + oe[k] = [k, k + 1, k + 1 - 2 * j, k - 2 * j]; + oe[j * 2 - 1] = [ + k, + k + 1 - 2 * j, + k + 1 - 4 * j, + k - 2 * j + ]; + var ve, re, Se, ze, Ge, $e, Re, Be, ke, We; + let Te = P.updateGeoGroup(); + for (G = 0; G < Q; G++) { + let Z = P.groups, q = !1; + Te = P.updateGeoGroup(2 * j), Z != P.groups && G > 0 && (G = G - 1, q = !0), $e = Math.round(G * (U.length - 1) / Q), Ge = o.CC.color(U[$e]), se = he, ae = ue, he = [], ue = [], ie = [], B[0][G].atom !== void 0 && (ze = B[0][G].atom, N === "oval" ? pe = we : N === "rectangle" ? pe = xe : N === "parabola" && (pe = Ie)), pe || (pe = xe); + var je, Fe; + for (k = 0; k < j; k++) + G < Q - 1 ? je = B[k][G + 1].clone().sub(B[k][G]) : je = B[k][G - 1].clone().sub(B[k][G]).negate(), k < j - 1 ? Fe = B[k + 1][G].clone().sub(B[k][G]) : Fe = B[k - 1][G].clone().sub(B[k][G]).negate(), ie[k] = Fe.cross(je).normalize().multiplyScalar($ * pe[k]); + for (k = 0; k < j; k++) + he[k] = B[k][G].clone().add(ie[k].clone().negate()); + for (k = 0; k < j; k++) + ue[k] = B[k][G].clone().add(ie[k]); + for (Re = Te.vertexArray, Be = Te.colorArray, ke = Te.faceArray, ve = Te.vertices, re = ve * 3, k = 0; k < j; k++) + Re[re + 3 * k + 0] = he[k].x, Re[re + 3 * k + 1] = he[k].y, Re[re + 3 * k + 2] = he[k].z; + for (k = 0; k < j; k++) + Re[re + 3 * k + 0 + 3 * j] = ue[j - 1 - k].x, Re[re + 3 * k + 1 + 3 * j] = ue[j - 1 - k].y, Re[re + 3 * k + 2 + 3 * j] = ue[j - 1 - k].z; + for (k = 0; k < 2 * j; ++k) + Be[re + 3 * k + 0] = Ge.r, Be[re + 3 * k + 1] = Ge.g, Be[re + 3 * k + 2] = Ge.b; + if (G > 0 && !q) { + for (k = 0; k < j * 2; k++) + We = [ + ve + oe[k][0], + ve + oe[k][1], + ve + oe[k][2], + ve + oe[k][3] + ], Se = Te.faceidx, ke[Se] = We[0], ke[Se + 1] = We[1], ke[Se + 2] = We[3], ke[Se + 3] = We[1], ke[Se + 4] = We[2], ke[Se + 5] = We[3], Te.faceidx += 6; + if (ze.clickable || ze.hoverable) { + var X = []; + X.push(new g.Triangle(se[0], he[0], he[j - 1])), X.push(new g.Triangle(se[0], he[j - 1], se[j - 1])), X.push(new g.Triangle(se[j - 1], he[j - 1], ue[j - 1])), X.push(new g.Triangle(se[j - 1], ue[j - 1], ae[j - 1])), X.push(new g.Triangle(ue[0], ae[0], ae[j - 1])), X.push(new g.Triangle(ue[j - 1], ue[0], ae[j - 1])), X.push(new g.Triangle(he[0], se[0], ae[0])), X.push(new g.Triangle(ue[0], he[0], ae[0])); + for (k in X) + ze.intersectionShape.triangle.push(X[k]); + } + } + Te.vertices += 2 * j; + } + for (Re = Te.vertexArray, Be = Te.colorArray, ke = Te.faceArray, ve = Te.vertices, re = ve * 3, Se = Te.faceidx, G = 0; G < j - 1; G++) + We = [G, G + 1, 2 * j - 2 - G, 2 * j - 1 - G], Se = Te.faceidx, ke[Se] = We[0], ke[Se + 1] = We[1], ke[Se + 2] = We[3], ke[Se + 3] = We[1], ke[Se + 4] = We[2], ke[Se + 5] = We[3], Te.faceidx += 6; + for (G = 0; G < j - 1; G++) + We = [ + ve - 1 - G, + ve - 2 - G, + ve - 2 * j + G + 1, + ve - 2 * j + G + ], Se = Te.faceidx, ke[Se] = We[0], ke[Se + 1] = We[1], ke[Se + 2] = We[3], ke[Se + 3] = We[1], ke[Se + 4] = We[2], ke[Se + 5] = We[3], Te.faceidx += 6; + } + function f(P, B, U, F, $, W) { + if (!(B.length < 2)) { + var N, G; + if (N = B[0], G = B[B.length - 1], N = u(N, F), G = u(G, F), !$) + return n(P, N, G, U); + var k = [], j, Q, ie, pe, he, ue = [ + [0, 2, -6, -8], + [-4, -2, 6, 4], + [7, -1, -5, 3], + [-3, 5, 1, -7] + ], se, ae, we, xe, Ie, oe, ve, re, Se, ze, Ge, $e, Re, Be, ke, We, Te; + for (re = 0, Se = N.length; re < Se; re++) { + if (Ie = Math.round(re * (U.length - 1) / Se), xe = o.CC.color(U[Ie]), k.push(Q = N[re]), k.push(Q), k.push(ie = G[re]), k.push(ie), re < Se - 1) { + var je = N[re + 1].clone().sub(N[re]), Fe = G[re].clone().sub(N[re]); + j = Fe.cross(je).normalize().multiplyScalar($); + } + for (k.push(pe = N[re].clone().add(j)), k.push(pe), k.push(he = G[re].clone().add(j)), k.push(he), Q.atom !== void 0 && (oe = Q.atom), Be = P.updateGeoGroup(8), ke = Be.vertexArray, We = Be.colorArray, Te = Be.faceArray, se = Be.vertices, ae = se * 3, ke[ae] = Q.x, ke[ae + 1] = Q.y, ke[ae + 2] = Q.z, ke[ae + 3] = Q.x, ke[ae + 4] = Q.y, ke[ae + 5] = Q.z, ke[ae + 6] = ie.x, ke[ae + 7] = ie.y, ke[ae + 8] = ie.z, ke[ae + 9] = ie.x, ke[ae + 10] = ie.y, ke[ae + 11] = ie.z, ke[ae + 12] = pe.x, ke[ae + 13] = pe.y, ke[ae + 14] = pe.z, ke[ae + 15] = pe.x, ke[ae + 16] = pe.y, ke[ae + 17] = pe.z, ke[ae + 18] = he.x, ke[ae + 19] = he.y, ke[ae + 20] = he.z, ke[ae + 21] = he.x, ke[ae + 22] = he.y, ke[ae + 23] = he.z, ze = 0; ze < 8; ++ze) + We[ae + 3 * ze] = xe.r, We[ae + 1 + 3 * ze] = xe.g, We[ae + 2 + 3 * ze] = xe.b; + if (re > 0) { + var X = ve !== void 0 && oe !== void 0 && ve.serial !== oe.serial; + for (ze = 0; ze < 4; ze++) { + var Z = [ + se + ue[ze][0], + se + ue[ze][1], + se + ue[ze][2], + se + ue[ze][3] + ]; + if (we = Be.faceidx, Te[we] = Z[0], Te[we + 1] = Z[1], Te[we + 2] = Z[3], Te[we + 3] = Z[1], Te[we + 4] = Z[2], Te[we + 5] = Z[3], Be.faceidx += 6, oe.clickable || ve.clickable || oe.hoverable || ve.hoverable) { + var q = k[Z[3]].clone(), fe = k[Z[0]].clone(), _e = k[Z[2]].clone(), Me = k[Z[1]].clone(); + if (q.atom = k[Z[3]].atom || null, _e.atom = k[Z[2]].atom || null, fe.atom = k[Z[0]].atom || null, Me.atom = k[Z[1]].atom || null, X) { + var Ae = q.clone().add(fe).multiplyScalar(0.5), H = _e.clone().add(Me).multiplyScalar(0.5), ce = q.clone().add(Me).multiplyScalar(0.5); + ze % 2 === 0 ? ((ve.clickable || ve.hoverable) && (Ge = new g.Triangle(Ae, ce, q), $e = new g.Triangle(H, _e, ce), Re = new g.Triangle(ce, _e, q), ve.intersectionShape.triangle.push(Ge), ve.intersectionShape.triangle.push($e), ve.intersectionShape.triangle.push(Re)), (oe.clickable || oe.hoverable) && (Ge = new g.Triangle(fe, Me, ce), $e = new g.Triangle(Me, H, ce), Re = new g.Triangle(fe, ce, Ae), oe.intersectionShape.triangle.push(Ge), oe.intersectionShape.triangle.push($e), oe.intersectionShape.triangle.push(Re))) : ((oe.clickable || oe.hoverable) && (Ge = new g.Triangle(Ae, ce, q), $e = new g.Triangle(H, _e, ce), Re = new g.Triangle(ce, _e, q), oe.intersectionShape.triangle.push(Ge), oe.intersectionShape.triangle.push($e), oe.intersectionShape.triangle.push(Re)), (ve.clickable || ve.hoverable) && (Ge = new g.Triangle(fe, Me, ce), $e = new g.Triangle(Me, H, ce), Re = new g.Triangle(fe, ce, Ae), ve.intersectionShape.triangle.push(Ge), ve.intersectionShape.triangle.push($e), ve.intersectionShape.triangle.push(Re))); + } else + (oe.clickable || oe.hoverable) && (Ge = new g.Triangle(fe, Me, q), $e = new g.Triangle(Me, _e, q), oe.intersectionShape.triangle.push(Ge), oe.intersectionShape.triangle.push($e)); + } + } + } + Be.vertices += 8, ve = oe; + } + var ye = k.length - 8; + for (Be = P.updateGeoGroup(8), ke = Be.vertexArray, We = Be.colorArray, Te = Be.faceArray, se = Be.vertices, ae = se * 3, we = Be.faceidx, re = 0; re < 4; re++) { + k.push(k[re * 2]), k.push(k[ye + re * 2]); + var Pe = k[re * 2], le = k[ye + re * 2]; + ke[ae + 6 * re] = Pe.x, ke[ae + 1 + 6 * re] = Pe.y, ke[ae + 2 + 6 * re] = Pe.z, ke[ae + 3 + 6 * re] = le.x, ke[ae + 4 + 6 * re] = le.y, ke[ae + 5 + 6 * re] = le.z, We[ae + 6 * re] = xe.r, We[ae + 1 + 6 * re] = xe.g, We[ae + 2 + 6 * re] = xe.b, We[ae + 3 + 6 * re] = xe.r, We[ae + 4 + 6 * re] = xe.g, We[ae + 5 + 6 * re] = xe.b; + } + ye += 8, Ge = [se, se + 2, se + 6, se + 4], $e = [se + 1, se + 5, se + 7, se + 3], Te[we] = Ge[0], Te[we + 1] = Ge[1], Te[we + 2] = Ge[3], Te[we + 3] = Ge[1], Te[we + 4] = Ge[2], Te[we + 5] = Ge[3], Te[we + 6] = $e[0], Te[we + 7] = $e[1], Te[we + 8] = $e[3], Te[we + 9] = $e[1], Te[we + 10] = $e[2], Te[we + 11] = $e[3], Be.faceidx += 12, Be.vertices += 8; + } + } + function c(P, B, U, F, $, W, N) { + (!N || N === "default") && (N = "rectangle"), N === "edged" ? f(P, B, U, F, $) : (N === "rectangle" || N === "oval" || N === "parabola") && b(P, B, U, F, $, W, N); + } + function t(P) { + return P && P.elem === "C" && P.atom === "CA"; + } + function a(P, B) { + if (P && B && P.chain === B.chain) { + if (!P.hetflag && !B.hetflag && P.reschain === B.reschain && (P.resi === B.resi || P.resi === B.resi - 1)) + return !0; + if (P.resi < B.resi) { + var U = P.x - B.x, F = P.y - B.y, $ = P.z - B.z, W = U * U + F * F + $ * $; + if (P.atom == "CA" && B.atom == "CA" && W < 16) + return !0; + if ((P.atom == "P" || B.atom == "P") && W < 64) + return !0; + } + } + return !1; + } + function h(P, B, U, F, $) { + if (!(B == null || B.vertices == 0)) { + $ && (B.initTypedArrays(), B.setUpNormals()); + var W = new _.MeshDoubleLambertMaterial(); + W.vertexColors = _.Coloring.FaceColors, typeof U == "number" && U >= 0 && U < 1 && (W.transparent = !0, W.opacity = U), W.outline = F; + var N = new _.Mesh(B, W); + P.add(N); + } + } + function M(P, B, U, F, $, W, N, G, k) { + var j, Q, ie, pe, he, ue; + if (!(!F || !$ || !N)) { + var se = $.sub(F); + se.normalize(); + var ae = G[k]; + for (Q = k + 1; Q < G.length && (ae = G[Q], ae.atom != N.atom); Q++) + ; + if (ae = ae ? new l.Vector3(ae.x, ae.y, ae.z) : new l.Vector3(0, 0, 0), ae.sub(F), N.ss === "arrow start") { + var we = ae.clone().multiplyScalar(0.3).cross($); + F.add(we); + var xe = ae.clone().cross(se).normalize(); + se.rotateAboutVector(xe, 0.43); + } + for (N.style.cartoon.ribbon ? j = N.style.cartoon.thickness || D : N.style.cartoon.width ? j = N.style.cartoon.width : N.ss === "c" ? N.atom === "P" ? j = L : j = A : N.ss === "arrow start" ? (j = C, he = !0) : N.ss === "arrow end" || N.ss === "h" && N.style.cartoon.tubes || N.ss === "tube start" ? j = A : j = C, W != null && se.dot(W) < 0 && se.negate(), se.multiplyScalar(j), Q = 0; Q < B; Q++) + ie = -1 + Q * 2 / (B - 1), pe = new l.Vector3(F.x + ie * se.x, F.y + ie * se.y, F.z + ie * se.z), pe.atom = N, U && N.ss === "s" && (pe.smoothen = !0), P[Q].push(pe); + if (he) + for (se.multiplyScalar(2), Q = 0; Q < B; Q++) + ie = -1 + Q * 2 / (B - 1), pe = new l.Vector3(F.x + ie * se.x, F.y + ie * se.y, F.z + ie * se.z), pe.atom = N, pe.smoothen = !1, pe.skip = !0, P[Q].push(pe); + return ue = N.style.cartoon.style || "default", P.style ? P.style != ue && (console.log("Warning: a cartoon chain's strand-style is ambiguous"), P.style = "default") : P.style = ue, (N.ss === "arrow start" || N.ss === "arrow end") && (N.ss = "s"), he; + } + } + const w = { + 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 + }, S = { DA: !0, DG: !0, A: !0, G: !0 }, T = { 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 z(P, B, U, F = 10) { + let $ = F, W = F; + var N, G, k, j, Q, ie, pe, he, ue, se, ae, we, xe, Ie, oe, ve, re, Se, ze = new _.Geometry(!0), Ge = new _.Geometry(!0), $e = [], Re = [], Be = 1, ke = !1, We = {}; + for (var Te in x.Gradient.builtinGradients) + x.Gradient.builtinGradients.hasOwnProperty(Te) && (We[Te] = new x.Gradient.builtinGradients[Te](U[1], U[0])); + var je = function(K, Oe) { + return U && Oe.color === "spectrum" ? Oe.colorscheme in We ? We[Oe.colorscheme].valueToHex(K.resi) : We.sinebow.valueToHex(K.resi) : (0, E.getColorFromStyle)(K, Oe).getHex(); + }; + for (he = 0; he < $; he++) + Re[he] = []; + var Fe = !1, X = !1, Z = []; + for (he in B) { + if (j = B[he], j.elem === "C" && j.atom === "CA") { + var q = a(k, j); + q && j.ss === "s" ? Fe = !0 : Fe && (k && G && k.style.cartoon.arrows && G.style.cartoon.arrows && (k.ss = "arrow end", G.ss = "arrow start"), Fe = !1), q && (k.ss === "h" || k.ss == "tube start") && k.style.cartoon.tubes ? !X && k.ss != "tube start" && j.style.cartoon.tubes && (j.ss = "tube start", X = !0) : X && (k.ss === "tube start" ? k.ss = "tube end" : G && G.style.cartoon.tubes && (G.ss = "tube end"), X = !1), G = k, k = j; + } + j && j.atom in w && Z.push(j); + } + X && k.style.cartoon.tubes && (k.ss = "tube end", X = !1); + var fe = function(K) { + Re[0].length > 0 && c(Ge, Re, $e, W, pe, Be, Re.style); + var Oe = [], Ne = null; + if (K) { + for (he = 0; he < $; he++) + Oe[he] = Re[he][Re[he].length - 1]; + Ne = $e[$e.length - 1]; + } + for (Re = [], he = 0; he < $; he++) + Re[he] = []; + if ($e = [], K) { + for (he = 0; he < $; he++) + Re[he].push(Oe[he]); + $e.push(Ne); + } + h(P, Ge, Be, ke, !0), h(P, ze, Be, ke, !1), Ge = new _.Geometry(!0), ze = new _.Geometry(!0); + }; + k = void 0; + for (var _e = 0; _e < Z.length; _e++) { + j = Z[_e]; + var Me = j.resn.trim(), Ae = Me in R; + if (Be = 1, N = j.style.cartoon, k && k.style.cartoon && (Be = k.style.cartoon.opacity), k && k.style.cartoon && k.style.cartoon.outline && (ke = k.style.cartoon.outline), k && k.style.cartoon && (!j.style.cartoon || k.style.cartoon.opacity != j.style.cartoon.opacity) && fe(k.chain == j.chain), N.style === "trace") { + if (!j.hetflag) { + if (j.elem === "C" && j.atom === "CA" || Ae && j.atom === "P" || j.atom === "BB") { + if (ie = je(j, N), (0, E.isNumeric)(N.thickness) ? pe = N.thickness : pe = D, a(k, j)) + if (ie == Q) { + var H = o.CC.color(ie); + p.GLDraw.drawCylinder(ze, k, j, pe, H, 2, 2); + } else { + var ce = new l.Vector3().addVectors(k, j).multiplyScalar(0.5), ye = o.CC.color(Q), Pe = o.CC.color(ie); + p.GLDraw.drawCylinder(ze, k, ce, pe, ye, 2, 0), p.GLDraw.drawCylinder(ze, ce, j, pe, Pe, 0, 2); + } + if ((j.clickable === !0 || j.hoverable) && j.intersectionShape !== void 0) { + var le = new l.Vector3(j.x, j.y, j.z); + j.intersectionShape.sphere.push(new g.Sphere(le, pe)); + } + k = j, Q = ie; + } + } + } else { + if (t(j) || Ae && (j.atom === "P" || j.atom.indexOf("O5") == 0)) { + if (Se) + if (j.ss === "tube end") + Se = !1, re = new l.Vector3(j.x, j.y, j.z), p.GLDraw.drawCylinder(ze, ve, re, 2, o.CC.color(Q), 1, 1), j.ss = "h"; + else if (k.chain != j.chain || k.ss === "tube end") + Se = !1, k.ss = "h", re = new l.Vector3(k.x, k.y, k.z), p.GLDraw.drawCylinder(ze, ve, re, 2, o.CC.color(Q), 1, 1); + else + continue; + if (k && (!a(k, j) || k.ss === "tube start")) { + for (k.ss === "tube start" && (Se = !0, ve = new l.Vector3(k.x, k.y, k.z), k.ss = "h"), oe && (we ? Ie = new l.Vector3().addVectors(k, we).multiplyScalar(0.5) : Ie = new l.Vector3(k.x, k.y, k.z), p.GLDraw.drawCylinder(ze, Ie, oe, r, o.CC.color(oe.color), 0, 2), M(Re, $, !0, we, xe, ae, k, Z, _e), $e.push(ie), Ie = null, oe = null), Re[0].length > 0 && c(Ge, Re, $e, W, pe, Be, Re.style), Re = [], he = 0; he < $; he++) + Re[he] = []; + $e = []; + } + if (k === void 0 || k.rescode != j.rescode || k.resi != j.resi) { + if (oe && k != null) { + Ie = new l.Vector3().addVectors(k, j).multiplyScalar(0.5); + var De = Ie.clone().sub(oe).multiplyScalar(0.02); + Ie.add(De), p.GLDraw.drawCylinder(ze, Ie, oe, r, o.CC.color(oe.color), 0, 2), Ie = null, oe = null; + } + ie = je(j, N), $e.push(ie), (0, E.isNumeric)(N.thickness) ? pe = N.thickness : pe = D, k = j, ue = new l.Vector3(k.x, k.y, k.z), ue.resi = k.resi, Q = ie; + } + (j.clickable === !0 || j.hoverable === !0) && (j.intersectionShape === void 0 || j.intersectionShape.triangle === void 0) && (j.intersectionShape = { + sphere: null, + cylinder: [], + line: [], + triangle: [] + }); + } else + k != null && (t(k) && j.atom === "O" || Ae && k.atom === "P" && (j.atom === "OP2" || j.atom === "O2P") || Ae && k.atom.indexOf("O5") == 0 && j.atom.indexOf("C5") == 0) ? (se = new l.Vector3(j.x, j.y, j.z), se.resi = j.resi, (j.atom === "OP2" || j.atom === "O2P") && (xe = new l.Vector3(j.x, j.y, j.z))) : Ae && j.atom.indexOf("O3") == 0 ? we = new l.Vector3(j.x, j.y, j.z) : (j.atom === "N1" && Me in S || j.atom === "N3" && Me in T) && (oe = new l.Vector3(j.x, j.y, j.z), oe.color = (0, E.getColorFromStyle)(j, N).getHex()); + se && ue && se.resi === ue.resi && (M(Re, $, !0, ue, se, ae, k, Z, _e), ae = se, ue = null, se = null, $e.push(ie)); + } + } + oe && (we ? Ie = new l.Vector3().addVectors(k, we).multiplyScalar(0.5) : Ie = new l.Vector3(k.x, k.y, k.z), p.GLDraw.drawCylinder(ze, Ie, oe, r, o.CC.color(oe.color), 0, 2), M(Re, $, !0, we, xe, ae, k, Z, _e), $e.push(ie)), fe(!1); + } + } + ), + /***/ + "./src/index.ts": ( + /*!**********************!*\ + !*** ./src/index.ts ***! + \**********************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + CAP: () => ( + /* reexport safe */ + r.CAP + ), + /* harmony export */ + CC: () => ( + /* reexport safe */ + g.CC + ), + /* harmony export */ + Color: () => ( + /* reexport safe */ + g.Color + ), + /* harmony export */ + CustomLinear: () => ( + /* reexport safe */ + l.CustomLinear + ), + /* harmony export */ + Cylinder: () => ( + /* reexport safe */ + E.Cylinder + ), + /* harmony export */ + GLDraw: () => ( + /* reexport safe */ + r.GLDraw + ), + /* harmony export */ + GLModel: () => ( + /* reexport safe */ + b.GLModel + ), + /* harmony export */ + GLShape: () => ( + /* reexport safe */ + D.GLShape + ), + /* harmony export */ + GLViewer: () => ( + /* reexport safe */ + f.GLViewer + ), + /* harmony export */ + GLVolumetricRender: () => ( + /* reexport safe */ + L.GLVolumetricRender + ), + /* harmony export */ + Gradient: () => ( + /* reexport safe */ + l.Gradient + ), + /* harmony export */ + GradientType: () => ( + /* reexport safe */ + l.GradientType + ), + /* harmony export */ + Label: () => ( + /* reexport safe */ + _.Label + ), + /* harmony export */ + LabelCount: () => ( + /* reexport safe */ + _.LabelCount + ), + /* harmony export */ + MarchingCube: () => ( + /* reexport safe */ + A.MarchingCube + ), + /* harmony export */ + MarchingCubeInitializer: () => ( + /* reexport safe */ + A.MarchingCubeInitializer + ), + /* harmony export */ + Matrix3: () => ( + /* reexport safe */ + p.Matrix3 + ), + /* harmony export */ + Matrix4: () => ( + /* reexport safe */ + p.Matrix4 + ), + /* harmony export */ + Parsers: () => ( + /* reexport safe */ + o.Parsers + ), + /* harmony export */ + PausableTimer: () => ( + /* reexport safe */ + u.PausableTimer + ), + /* harmony export */ + PointGrid: () => ( + /* reexport safe */ + A.PointGrid + ), + /* harmony export */ + ProteinSurface: () => ( + /* reexport safe */ + A.ProteinSurface + ), + /* harmony export */ + Quaternion: () => ( + /* reexport safe */ + p.Quaternion + ), + /* harmony export */ + ROYGB: () => ( + /* reexport safe */ + l.ROYGB + ), + /* harmony export */ + RWB: () => ( + /* reexport safe */ + l.RWB + ), + /* harmony export */ + Ray: () => ( + /* reexport safe */ + p.Ray + ), + /* harmony export */ + Sinebow: () => ( + /* reexport safe */ + l.Sinebow + ), + /* harmony export */ + Sphere: () => ( + /* reexport safe */ + E.Sphere + ), + /* harmony export */ + SurfaceType: () => ( + /* reexport safe */ + A.SurfaceType + ), + /* harmony export */ + Triangle: () => ( + /* reexport safe */ + E.Triangle + ), + /* harmony export */ + Vector2: () => ( + /* reexport safe */ + p.Vector2 + ), + /* harmony export */ + Vector3: () => ( + /* reexport safe */ + p.Vector3 + ), + /* harmony export */ + VolumeData: () => ( + /* reexport safe */ + C.VolumeData + ), + /* harmony export */ + adjustVolumeStyle: () => ( + /* reexport safe */ + u.adjustVolumeStyle + ), + /* harmony export */ + applyPartialCharges: () => ( + /* reexport safe */ + x.applyPartialCharges + ), + /* harmony export */ + autoinit: () => ( + /* reexport safe */ + c.autoinit + ), + /* harmony export */ + autoload: () => ( + /* reexport safe */ + c.autoload + ), + /* harmony export */ + base64ToArray: () => ( + /* reexport safe */ + u.base64ToArray + ), + /* harmony export */ + bondLength: () => ( + /* reexport safe */ + o.bondLength + ), + /* harmony export */ + builtinColorSchemes: () => ( + /* reexport safe */ + g.builtinColorSchemes + ), + /* harmony export */ + builtinGradients: () => ( + /* reexport safe */ + l.builtinGradients + ), + /* harmony export */ + chains: () => ( + /* reexport safe */ + g.chains + ), + /* harmony export */ + clamp: () => ( + /* reexport safe */ + p.clamp + ), + /* harmony export */ + conversionMatrix3: () => ( + /* reexport safe */ + p.conversionMatrix3 + ), + /* harmony export */ + createStereoViewer: () => ( + /* reexport safe */ + f.createStereoViewer + ), + /* harmony export */ + createViewer: () => ( + /* reexport safe */ + f.createViewer + ), + /* harmony export */ + createViewerGrid: () => ( + /* reexport safe */ + f.createViewerGrid + ), + /* harmony export */ + deepCopy: () => ( + /* reexport safe */ + u.deepCopy + ), + /* harmony export */ + degToRad: () => ( + /* reexport safe */ + p.degToRad + ), + /* harmony export */ + download: () => ( + /* reexport safe */ + u.download + ), + /* harmony export */ + drawCartoon: () => ( + /* reexport safe */ + n.drawCartoon + ), + /* harmony export */ + elementColors: () => ( + /* reexport safe */ + g.elementColors + ), + /* harmony export */ + extend: () => ( + /* reexport safe */ + u.extend + ), + /* harmony export */ + get: () => ( + /* reexport safe */ + u.get + ), + /* harmony export */ + getAtomProperty: () => ( + /* reexport safe */ + u.getAtomProperty + ), + /* harmony export */ + getColorFromStyle: () => ( + /* reexport safe */ + u.getColorFromStyle + ), + /* harmony export */ + getElement: () => ( + /* reexport safe */ + u.getElement + ), + /* harmony export */ + getExtent: () => ( + /* reexport safe */ + u.getExtent + ), + /* harmony export */ + getGradient: () => ( + /* reexport safe */ + l.getGradient + ), + /* harmony export */ + getPropertyRange: () => ( + /* reexport safe */ + u.getPropertyRange + ), + /* harmony export */ + getbin: () => ( + /* reexport safe */ + u.getbin + ), + /* harmony export */ + htmlColors: () => ( + /* reexport safe */ + g.htmlColors + ), + /* harmony export */ + isEmptyObject: () => ( + /* reexport safe */ + u.isEmptyObject + ), + /* harmony export */ + isNumeric: () => ( + /* reexport safe */ + u.isNumeric + ), + /* harmony export */ + makeFunction: () => ( + /* reexport safe */ + u.makeFunction + ), + /* harmony export */ + mergeGeos: () => ( + /* reexport safe */ + u.mergeGeos + ), + /* harmony export */ + normalizeValue: () => ( + /* reexport safe */ + l.normalizeValue + ), + /* harmony export */ + partialCharges: () => ( + /* reexport safe */ + x.partialCharges + ), + /* harmony export */ + processing_autoinit: () => ( + /* reexport safe */ + c.processing_autoinit + ), + /* harmony export */ + residues: () => ( + /* reexport safe */ + g.residues + ), + /* harmony export */ + setBondLength: () => ( + /* reexport safe */ + o.setBondLength + ), + /* harmony export */ + setSyncSurface: () => ( + /* reexport safe */ + A.setSyncSurface + ), + /* harmony export */ + specStringToObject: () => ( + /* reexport safe */ + u.specStringToObject + ), + /* harmony export */ + splitMesh: () => ( + /* reexport safe */ + D.splitMesh + ), + /* harmony export */ + ssColors: () => ( + /* reexport safe */ + g.ssColors + ), + /* harmony export */ + subdivide_spline: () => ( + /* reexport safe */ + n.subdivide_spline + ), + /* harmony export */ + syncSurface: () => ( + /* reexport safe */ + A.syncSurface + ), + /* harmony export */ + viewers: () => ( + /* reexport safe */ + c.viewers + ) + /* harmony export */ + }); + var l = e( + /*! ./Gradient */ + "./src/Gradient.ts" + ), g = e( + /*! ./colors */ + "./src/colors.ts" + ), _ = e( + /*! ./Label */ + "./src/Label.ts" + ), x = e( + /*! ./partialCharges */ + "./src/partialCharges.ts" + ), o = e( + /*! ./parsers */ + "./src/parsers/index.ts" + ), p = e( + /*! ./WebGL/math */ + "./src/WebGL/math/index.ts" + ), E = e( + /*! ./WebGL/shapes */ + "./src/WebGL/shapes/index.ts" + ), u = e( + /*! ./utilities */ + "./src/utilities.ts" + ), A = e( + /*! ./ProteinSurface4 */ + "./src/ProteinSurface4.ts" + ), C = e( + /*! ./VolumeData */ + "./src/VolumeData.ts" + ), L = e( + /*! ./VolumetricRender */ + "./src/VolumetricRender.ts" + ), D = e( + /*! ./GLShape */ + "./src/GLShape.ts" + ), r = e( + /*! ./GLDraw */ + "./src/GLDraw.ts" + ), n = e( + /*! ./glcartoon */ + "./src/glcartoon.ts" + ), b = e( + /*! ./GLModel */ + "./src/GLModel.ts" + ), f = e( + /*! ./GLViewer */ + "./src/GLViewer.ts" + ), c = e( + /*! ./autoload */ + "./src/autoload.ts" + ); + e( + /*! ./specs */ + "./src/specs.ts" + ), window && (window.$3Dmol = s); + } + ), + /***/ + "./src/parsers/CDJSON.ts": ( + /*!*******************************!*\ + !*** ./src/parsers/CDJSON.ts ***! + \*******************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + CDJSON: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + function l(g, _) { + var x = [[]]; + typeof g == "string" && (g = JSON.parse(g)); + for (var o = g.m, p = o[0].a, E = o[0].b, u = o[0].s, A = _ !== void 0 && _.parseStyle !== void 0 ? _.parseStyle : u !== void 0, C = x[x.length - 1].length, L = 0; L < p.length; L++) { + var D = p[L], r = {}; + r.id = D.i, r.x = D.x, r.y = D.y, r.z = D.z || 0, r.bonds = [], r.bondOrder = []; + var n = D.l || "C"; + r.elem = n[0].toUpperCase() + n.substring(1).toLowerCase(), r.serial = x[x.length - 1].length, A && (r.style = u[D.s || 0]), x[x.length - 1].push(r); + } + for (let b = 0; b < E.length; b++) { + let f = E[b], c = f.b + C, t = f.e + C, a = f.o || 1, h = x[x.length - 1][c], M = x[x.length - 1][t]; + h.bonds.push(t), h.bondOrder.push(a), M.bonds.push(c), M.bondOrder.push(a); + } + return x; + } + } + ), + /***/ + "./src/parsers/CIF.ts": ( + /*!****************************!*\ + !*** ./src/parsers/CIF.ts ***! + \****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + CIF: () => ( + /* binding */ + o + ) + /* harmony export */ + }); + var l = e( + /*! ./utils/computeSecondaryStructure */ + "./src/parsers/utils/computeSecondaryStructure.ts" + ), g = e( + /*! ./utils/processSymmetries */ + "./src/parsers/utils/processSymmetries.ts" + ), _ = e( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ), x = e( + /*! ./utils/assignPDBBonds */ + "./src/parsers/utils/assignPDBBonds.ts" + ); + function o(p, E = {}) { + var u = [], A = !E.doAssembly, C = u.modelData = [], L = E.assignBonds === void 0 ? !0 : E.assignBonds, D = function(Z, q, fe, _e) { + return new _.Vector3(q, fe, _e).applyMatrix3(Z); + }; + function r(Z, q) { + for (var fe = [], _e = 0, Me = 0; Me < Z.length; ) { + for (; Z.substring(Me, Me + q.length) !== q && Me < Z.length; ) + if (Z[Me] === "'") { + for (Me++; Me < Z.length && Z[Me] !== "'"; ) + Me++; + for (; Z.substring(Me, Me + q.length) !== q && Me < Z.length; ) + Me++; + } else if (Z[Me] === '"') { + for (Me++; Me < Z.length && Z[Me] !== '"'; ) + Me++; + Me++; + } else + Me++; + fe.push(Z.substring(_e, Me)), _e = Me = Me + q.length; + } + return fe; + } + var n = p.split(/\r?\n|\r/), b = [], f = !1; + for (let Z = 0; Z < n.length; Z++) { + var c = n[Z].split("#")[0]; + if (f ? c[0] === ";" && (f = !1) : c[0] === ";" && (f = !0), f || c !== "") { + if (!f && (c = c.trim(), c[0] === "_")) { + var t = c.split(/\s/)[0].indexOf("."); + if (t > -1) { + let q = c.split(""); + q[t] = "_", c = q.join(""), c = c.substring(0, t) + "_" + c.substring(t + 1); + } + } + b.push(c); + } + } + for (var a = 0; a < b.length; ) { + for (; !b[a].startsWith("data_") || b[a] === "data_global"; ) + a++; + a++; + for (var h = {}; a < b.length && !b[a].startsWith("data_"); ) + if (b[a][0] === void 0) + a++; + else if (b[a][0] === "_") { + var M = b[a].split(/\s/)[0].toLowerCase(), w = h[M] = h[M] || [], S = b[a].substring(b[a].indexOf(M) + M.length); + if (S === "") + if (a++, b[a][0] === ";") { + var T = b[a].substring(1); + for (a++; b[a] !== ";"; ) + T = T + ` +` + b[a], a++; + w.push(T); + } else + w.push(b[a]); + else + w.push(S.trim()); + a++; + } else if (b[a].substring(0, 5) === "loop_") { + a++; + for (var R = []; b[a] === "" || b[a][0] === "_"; ) { + if (b[a] !== "") { + let Z = b[a].split(/\s/)[0].toLowerCase(), q = h[Z] = h[Z] || []; + R.push(q); + } + a++; + } + for (var z = 0; a < b.length && b[a][0] !== "_" && !b[a].startsWith("loop_") && !b[a].startsWith("data_"); ) { + let Z = r(b[a], " "); + for (var P = 0; P < Z.length; P++) + Z[P] !== "" && (R[z].push(Z[P]), z = (z + 1) % R.length); + a++; + } + } else + a++; + C.push({ symmetries: [] }), u.push([]); + var B = h._atom_site_id !== void 0 ? h._atom_site_id.length : h._atom_site_label.length, U; + if (h._cell_length_a !== void 0) { + var F = parseFloat(h._cell_length_a), $ = parseFloat(h._cell_length_b), W = parseFloat(h._cell_length_c), N = parseFloat(h._cell_angle_alpha) || 90, G = parseFloat(h._cell_angle_beta) || 90, k = parseFloat(h._cell_angle_gamma) || 90; + U = (0, _.conversionMatrix3)(F, $, W, N, G, k), C[C.length - 1].cryst = { + a: F, + b: $, + c: W, + alpha: N, + beta: G, + gamma: k + }; + } + for (var j = 0; j < B; j++) + if (!(h._atom_site_group_pdb !== void 0 && h._atom_site_group_pdb[j] === "TER")) { + var Q = {}; + if (h._atom_site_cartn_x !== void 0) + Q.x = parseFloat(h._atom_site_cartn_x[j]), Q.y = parseFloat(h._atom_site_cartn_y[j]), Q.z = parseFloat(h._atom_site_cartn_z[j]); + else { + var ie = D(U, parseFloat(h._atom_site_fract_x[j]), parseFloat(h._atom_site_fract_y[j]), parseFloat(h._atom_site_fract_z[j])); + Q.x = ie.x, Q.y = ie.y, Q.z = ie.z; + } + Q.chain = h._atom_site_auth_asym_id ? h._atom_site_auth_asym_id[j] : h._atom_site_label_asym_id ? h._atom_site_label_asym_id[j] : void 0, Q.resi = h._atom_site_auth_seq_id ? parseInt(h._atom_site_auth_seq_id[j]) : h._atom_site_label_seq_id ? h._atom_site_label_seq_id[j] : void 0, Q.resn = h._atom_site_auth_comp_id ? h._atom_site_auth_comp_id[j].trim() : h._atom_site_label_comp_id ? h._atom_site_label_comp_id[j].trim() : void 0, Q.atom = h._atom_site_auth_atom_id ? h._atom_site_auth_atom_id[j].replace(/"/gm, "") : h._atom_site_label_atom_id ? h._atom_site_label_atom_id[j].replace(/"/gm, "") : void 0, Q.hetflag = !h._atom_site_group_pdb || h._atom_site_group_pdb[j] === "HETA" || h._atom_site_group_pdb[j] === "HETATM"; + var pe = "X"; + h._atom_site_type_symbol ? pe = h._atom_site_type_symbol[j].replace(/\(?\+?\d+.*/, "") : h._atom_site_label && (pe = h._atom_site_label[j].split("_")[0].replace(/\(?\d+.*/, "")), Q.elem = pe[0].toUpperCase() + pe.substring(1, 2).toLowerCase(), Q.bonds = [], Q.ss = "c", Q.serial = j, Q.bondOrder = [], Q.properties = {}, u[u.length - 1].push(Q); + } + if (h._pdbx_struct_oper_list_id !== void 0 && !A) + for (let Z = 0; Z < h._pdbx_struct_oper_list_id.length; Z++) { + var he = parseFloat(h["_pdbx_struct_oper_list_matrix[1][1]"][Z]), ue = parseFloat(h["_pdbx_struct_oper_list_matrix[1][2]"][Z]), se = parseFloat(h["_pdbx_struct_oper_list_matrix[1][3]"][Z]), ae = parseFloat(h["_pdbx_struct_oper_list_vector[1]"][Z]), we = parseFloat(h["_pdbx_struct_oper_list_matrix[2][1]"][Z]), xe = parseFloat(h["_pdbx_struct_oper_list_matrix[2][2]"][Z]), Ie = parseFloat(h["_pdbx_struct_oper_list_matrix[2][3]"][Z]), oe = parseFloat(h["_pdbx_struct_oper_list_vector[2]"][Z]), ve = parseFloat(h["_pdbx_struct_oper_list_matrix[3][1]"][Z]), re = parseFloat(h["_pdbx_struct_oper_list_matrix[3][2]"][Z]), Se = parseFloat(h["_pdbx_struct_oper_list_matrix[3][3]"][Z]), ze = parseFloat(h["_pdbx_struct_oper_list_vector[3]"][Z]), Ge = new _.Matrix4(he, ue, se, ae, we, xe, Ie, oe, ve, re, Se, ze); + C[C.length - 1].symmetries.push(Ge); + } + var $e = function(Z) { + var q = Z.match("-"); + Z = Z.replace(/[-xyz]/g, ""); + var fe = Z.split("/"), _e, Me; + return fe[1] === void 0 ? Me = 1 : Me = parseInt(fe[1]), fe[0] === "" ? _e = 1 : _e = parseInt(fe[0]), _e / Me * (q ? -1 : 1); + }; + if (h._symmetry_equiv_pos_as_xyz !== void 0 && !A) + for (var Re = 0; Re < h._symmetry_equiv_pos_as_xyz.length; Re++) { + var Be = h._symmetry_equiv_pos_as_xyz[Re].replace(/["' ]/g, ""), ke = Be.split(",").map(function(q) { + return q.replace(/-/g, "+-"); + }); + let Z = new _.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 We = ke[q].split("+"); + for (let fe = 0; fe < We.length; fe++) { + var Te = We[fe]; + if (Te !== "") { + var je = $e(Te); + Te.match("x") ? Z.elements[q + 0] = je : Te.match("y") ? Z.elements[q + 4] = je : Te.match("z") ? Z.elements[q + 8] = je : Z.elements[q + 12] = je; + } + } + } + var Fe = U.getMatrix4(), X = new _.Matrix4().getInverse(Fe, !0); + Z = new _.Matrix4().multiplyMatrices(Z, X), Z = new _.Matrix4().multiplyMatrices(Fe, Z), C[C.length - 1].symmetries.push(Z); + } + } + for (let Z = 0; Z < u.length; Z++) + L && !(E.duplicateAssemblyAtoms && !E.dontConnectDuplicatedAtoms) && (0, x.assignPDBBonds)(u[Z], E), (0, l.computeSecondaryStructure)(u[Z], E.hbondCutoff), (0, g.processSymmetries)(C[Z].symmetries, u[Z], E, C[Z].cryst), E.duplicateAssemblyAtoms && !E.dontConnectDuplicatedAtoms && L && (0, x.assignPDBBonds)(u[Z], E); + return u; + } + } + ), + /***/ + "./src/parsers/CUBE.ts": ( + /*!*****************************!*\ + !*** ./src/parsers/CUBE.ts ***! + \*****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + CUBE: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ), g = e( + /*! ./utils/assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ), _ = e( + /*! ./utils/anumToSymbol */ + "./src/parsers/utils/anumToSymbol.ts" + ); + function x(o, p) { + p = p || {}; + var E = [[]], u = o.split(/\r?\n/), A = p.assignBonds === void 0 ? !0 : p.assignBonds; + if (u.length < 6) + return E; + var C = u[2].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), L = Math.abs(parseFloat(C[0])); + let D = {}; + var r = D.origin = new l.Vector3(parseFloat(C[1]), parseFloat(C[2]), parseFloat(C[3])); + C = u[3].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), C = u[3].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var n = C[0] > 0 ? 0.529177 : 1; + r.multiplyScalar(n); + var b = Math.abs(C[0]), f = new l.Vector3(parseFloat(C[1]), parseFloat(C[2]), parseFloat(C[3])).multiplyScalar(n); + C = u[4].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var c = Math.abs(C[0]), t = new l.Vector3(parseFloat(C[1]), parseFloat(C[2]), parseFloat(C[3])).multiplyScalar(n); + C = u[5].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var a = Math.abs(C[0]), h = new l.Vector3(parseFloat(C[1]), parseFloat(C[2]), parseFloat(C[3])).multiplyScalar(n); + if (D.size = { x: b, y: c, z: a }, D.unit = new l.Vector3(f.x, t.y, h.z), f.y != 0 || f.z != 0 || t.x != 0 || t.z != 0 || h.x != 0 || h.y != 0) { + D.matrix4 = new l.Matrix4(f.x, t.x, h.x, 0, f.y, t.y, h.y, 0, f.z, t.z, h.z, 0, 0, 0, 0, 1); + let P = new l.Matrix4().makeTranslation(r.x, r.y, r.z); + D.matrix4 = D.matrix4.multiplyMatrices(P, D.matrix4), D.matrix = D.matrix4.matrix3FromTopLeft(), D.origin = new l.Vector3(0, 0, 0), D.unit = new l.Vector3(1, 1, 1); + } + E.modelData = [{ cryst: D }], u = u.splice(6, L); + for (var M = E[E.length - 1].length, w = M + u.length, S = M; S < w; ++S) { + var T = {}; + T.serial = S; + var R = u[S - M], z = R.replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + T.elem = _.anumToSymbol[z[0]], T.x = parseFloat(z[2]) * n, T.y = parseFloat(z[3]) * n, T.z = parseFloat(z[4]) * n, T.hetflag = !0, T.bonds = [], T.bondOrder = [], T.properties = {}, E[E.length - 1].push(T); + } + if (A) + for (let P = 0; P < E.length; P++) + (0, g.assignBonds)(E[P], p); + return E; + } + } + ), + /***/ + "./src/parsers/GRO.ts": ( + /*!****************************!*\ + !*** ./src/parsers/GRO.ts ***! + \****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + GRO: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./utils/assignPDBBonds */ + "./src/parsers/utils/assignPDBBonds.ts" + ), g = e( + /*! ./utils/atomNameToElem */ + "./src/parsers/utils/atomNameToElem.ts" + ); + function _(x, o) { + for (var p = [], E = x.split(/\r?\n|\r/); E.length > 0 && !(E.length < 3); ) { + var u = parseInt(E[1]); + if (isNaN(u) || u <= 0 || E.length < u + 3) + break; + var A = []; + p.push(A); + for (var C = 2, L = A.length, D = L + u, r = L; r < D; r++) { + var n = E[C++], b = {}; + b.serial = r, b.atom = n.slice(10, 15).trim(), b.elem = (0, g.atomNameToElem)(b.atom, !0), b.x = 10 * parseFloat(n.slice(20, 28)), b.y = 10 * parseFloat(n.slice(28, 36)), b.z = 10 * parseFloat(n.slice(36, 44)), b.resi = parseInt(n.slice(0, 5)), b.resn = n.slice(5, 10).trim(), b.bonds = [], b.bondOrder = [], b.properties = {}, n.length > 44 && (b.dx = 10 * parseFloat(n.slice(44, 52)), b.dy = 10 * parseFloat(n.slice(52, 60)), b.dz = 10 * parseFloat(n.slice(60, 68))), A[r] = b; + } + if (E.length <= C + 3) { + var f = E[C++], c = f.trim().split(/\s+/); + if (c.length == 3) { + for (var t = 0; t < 3; t++) + c[t] = parseFloat(c[t]) * 10; + p.box = c; + } + } + E.splice(0, ++C); + } + for (let a = 0; a < p.length; a++) + (0, l.assignPDBBonds)(p[a], o); + return p; + } + } + ), + /***/ + "./src/parsers/LAMMPSTRJ.ts": ( + /*!**********************************!*\ + !*** ./src/parsers/LAMMPSTRJ.ts ***! + \**********************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + LAMMPSTRJ: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ./utils/assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ); + function g(_, x) { + for (var o = [], p = { + 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/), u = 0, A = 0, C = 0; C < E.length - 9; ) { + for (var L = C; L < E.length; L++) + if (E[L].match(/ITEM: NUMBER OF ATOMS/) && (A = parseInt(E[L + 1])), E[L].match(/ITEM: ATOMS/)) { + u = L + 1; + break; + } + var D = E[u - 1].replace("ITEM: ATOMS ", "").split(" "); + o.push([]); + for (let a = u; a < u + A; a++) { + for (var r = {}, n = {}, b = E[a].split(" "), f = 0; f < b.length; f++) { + var c = p[D[f]]; + c != null && (c == "serial" ? r[c] = parseInt(b[f]) : c == "x" || c == "y" || c === "z" ? r[c] = parseFloat(b[f]) : c == "charge" || c == "radius" ? n[c] = parseFloat(b[f]) : r[c] = b[f]), r.properties = n, r.bonds = [], r.bondOrder = []; + } + o[o.length - 1][a - u] = r; + } + C = u + A - 1; + } + if (x.assignBonds) + for (var t = 0; t < o.length; t++) + (0, l.assignBonds)(o[t], x); + return o; + } + } + ), + /***/ + "./src/parsers/MMTF.ts": ( + /*!*****************************!*\ + !*** ./src/parsers/MMTF.ts ***! + \*****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + MMTFparser: () => ( + /* binding */ + A + ) + /* harmony export */ + }); + var l = e( + /*! ../utilities */ + "./src/utilities.ts" + ), g = e( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ), _ = e( + /*! ./utils/computeSecondaryStructure */ + "./src/parsers/utils/computeSecondaryStructure.ts" + ), x = e( + /*! ./utils/processSymmetries */ + "./src/parsers/utils/processSymmetries.ts" + ), o = e( + /*! ./src/vendor/mmtf.js */ + "./src/vendor/mmtf.js" + ), p = function(C) { + return String.fromCharCode.apply(null, C).replace(/\0/g, ""); + }, E = function(C) { + return C == 0 || C == 2 || C == 4 ? "h" : C == 3 ? "s" : "c"; + }; + let u = /* @__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 A(C, L) { + var D = !L.keepH, r = L.altLoc ? L.altLoc : "A", n = !!L.noSecondaryStructure, b = !L.noComputeSecondaryStructure, f = !L.doAssembly, c = L.assemblyIndex ? L.assemblyIndex : 0; + typeof C == "string" ? C = (0, l.base64ToArray)(C) : C = new Uint8Array(C); + var t = o.decode(C), a = [[]], h = a.modelData = [], M = 0, w = 0, S = 0, T = t.secStructList, R = t.bFactorList, z = t.altLocList, P = t.occupancyList, B = t.bondAtomList, U = t.bondOrderList, F = t.numModels; + if (F == 0) + return a; + L.multimodel || (F = 1); + var $, W, N, G, k, j, Q = []; + if (!f && t.bioAssemblyList && t.bioAssemblyList.length > 0) { + var ie = t.bioAssemblyList[c].transformList; + for ($ = 0, j = ie.length; $ < j; $++) { + var pe = new g.Matrix4(ie[$].matrix); + pe.transpose(), Q.push(pe); + } + } + var he = null; + if (t.unitCell) { + var ue = t.unitCell; + he = { a: ue[0], b: ue[1], c: ue[2], alpha: ue[3], beta: ue[4], gamma: ue[5] }; + } + let se = []; + t.entityList.forEach((ge) => { + ge.chainIndexList.forEach((Y) => { + se[Y] = ge.type == "polymer"; + }); + }); + var ae = 0; + for (k = 0; k < F; k++) { + var we = t.chainsPerModel[k], xe = a[a.length - 1], Ie = []; + for (h.push({ symmetries: Q, cryst: he }), $ = 0; $ < we; ++$) { + var oe = t.groupsPerChain[M], ve = p(t.chainIdList.subarray(M * 4, M * 4 + 4)); + t.chainNameList && (ve = p(t.chainNameList.subarray(M * 4, M * 4 + 4))); + var re = w, Se = ""; + for (W = 0; W < oe; ++W) { + var ze = t.groupList[t.groupTypeList[w]], Ge = ze.atomNameList.length, $e = 0, Re = !1, Be = !1; + if (T) { + $e = T[w]; + var ke = E($e); + (w == 0 || ke != Se) && (Re = !0), Se = ke; + var We = w + 1; + (We >= T.length || E(T[We] != ke)) && (Be = !0); + } + var Te = t.groupIdList[w], je = ze.groupName; + let ge = ze.chemCompType; + var Fe = S; + let Y = u.has(ge) || !se[M]; + for (N = 0; N < Ge; ++N) { + var X = ze.elementList[N]; + if (D && X == "H") { + S += 1; + continue; + } + var Z = ""; + R && (Z = R[S]); + var q = ""; + z && z[S] && (q = String.fromCharCode(z[S])); + var fe = ""; + if (P && (fe = P[S]), q != "" && q != r && r != "*") { + S += 1; + continue; + } + var _e = t.atomIdList[S], Me = ze.atomNameList[N], Ae = 0; + ze.atomChargeList && (Ae = ze.atomChargeList[N]); + var H = t.xCoordList[S], ce = t.yCoordList[S], ye = t.zCoordList[S]; + Ie[S] = xe.length, xe.push({ + resn: je, + x: H, + y: ce, + z: ye, + elem: X, + hetflag: Y, + chain: ve, + resi: Te, + icode: q, + rescode: Te + (q != " " ? "^" + q : ""), + // resi + // and + // icode + serial: _e, + altLoc: q, + index: S, + atom: Me, + bonds: [], + ss: E($e), + ssbegin: Re, + ssend: Be, + bondOrder: [], + properties: { charge: Ae, occupancy: fe }, + b: Z + }), S += 1; + } + var Pe = ze.bondAtomList; + for (N = 0, G = ze.bondOrderList.length; N < G; ++N) { + var le = Fe + Pe[N * 2], De = Fe + Pe[N * 2 + 1], K = ze.bondOrderList[N], Oe = Ie[le], Ne = Ie[De], I = xe[Oe], me = xe[Ne]; + I && me && (I.bonds.push(Ne), I.bondOrder.push(K), me.bonds.push(Oe), me.bondOrder.push(K)); + } + w += 1; + } + for (w = re, W = 0; W < oe; ++W) + w += 1; + M += 1; + } + if (B) + for (let ge = ae, Y = B.length; ge < Y; ge += 2) { + let ne = B[ge], Ee = B[ge + 1], He = U ? U[ge / 2] : 1; + if (ne >= S) { + ae = ge; + break; + } + let Ke = Ie[ne], Ve = Ie[Ee], qe = xe[Ke], wt = xe[Ve]; + qe && wt && (qe.bonds.push(Ve), qe.bondOrder.push(He), wt.bonds.push(Ke), wt.bondOrder.push(He)); + } + L.multimodel && (L.onemol || a.push([])); + } + if (!f) + for (let ge = 0; ge < a.length; ge++) + (0, x.processSymmetries)(h[ge].symmetries, a[ge], L, h[ge].cryst); + return b && !n && (0, _.computeSecondaryStructure)(a, L.hbondCutoff), a; + } + } + ), + /***/ + "./src/parsers/MOL2.ts": ( + /*!*****************************!*\ + !*** ./src/parsers/MOL2.ts ***! + \*****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + MOL2: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + let l = { + "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 g(_, x) { + var o = [[]], p = !1; + typeof x.keepH < "u" && (p = !x.keepH); + var E = _.search(/@MOLECULE/), u = _.search(/@ATOM/); + if (E == -1 || u == -1) + return o; + for (var A = _.substring(E).split(/\r?\n|\r/); A.length > 0; ) { + var C = [], L = A[2].replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), D = parseInt(L[0]), r = 0; + L.length > 1 && (r = parseInt(L[1])); + var n = 4, b; + for (b = 3; b < A.length; b++) + if (A[b] == "@ATOM") { + n = b + 1; + break; + } + var f = o[o.length - 1].length, c = f + D, t; + for (b = f; b < c; b++) { + t = A[n++], L = t.replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var a = {}, h = L[5]; + if (l[h] !== void 0 ? h = l[h] : (h = h.split(".")[0], h = h[0].toUpperCase() + h.substring(1).toLowerCase()), a.atom = L[1], a.elem = h, !(a.elem == "H" && p)) { + var M = o[o.length - 1].length, w = parseInt(L[0]); + a.serial = w, a.x = parseFloat(L[2]), a.y = parseFloat(L[3]), a.z = parseFloat(L[4]), a.atom = L[5]; + var S = parseFloat(L[8]); + a.index = M, a.bonds = [], a.bondOrder = [], a.properties = { + charge: S, + partialCharge: S + }, C[w] = M, o[o.length - 1].push(a); + } + } + for (var T = !1; n < A.length; ) + if (A[n++] == "@BOND") { + T = !0; + break; + } + if (T && r) + for (b = 0; b < r; b++) { + t = A[n++], L = t.replace(/^\s+/, "").replace(/\s+/g, " ").split(" "); + var R = parseInt(L[1]), z = o[o.length - 1][C[R]], P = parseInt(L[2]), B = o[o.length - 1][C[P]], U = parseInt(L[3]); + isNaN(U) && (U = 1), z !== void 0 && B !== void 0 && (z.bonds.push(C[P]), z.bondOrder.push(U), B.bonds.push(C[R]), B.bondOrder.push(U)); + } + if (x.multimodel) { + x.onemol || o.push([]), A.splice(0, n), _ = A.join(` +`); + continue; + } else + break; + } + return o; + } + } + ), + /***/ + "./src/parsers/PDB.ts": ( + /*!****************************!*\ + !*** ./src/parsers/PDB.ts ***! + \****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + PDB: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ./utils/getSinglePDB */ + "./src/parsers/utils/getSinglePDB.ts" + ); + function g(_, x) { + x = x || {}; + var o = [], p = {}; + o.modelData = []; + for (var E = _.split(/\r?\n|\r/); E.length > 0; ) { + var u = (0, l.getSinglePDB)(E, x, p), A = u[0], C = u[1]; + if (E = u[2], A.length != 0) { + if (x.multimodel && x.onemol && o.length > 0) + for (var L = o[0].length, D = 0; D < A.length; D++) { + var r = A[D]; + r.index = D; + for (var n = 0; n < r.bonds.length; n++) + r.bonds[n] += L; + o[0].push(r); + } + else + o.modelData.push(C), o.push(A); + if (!x.multimodel) + break; + } + } + return o; + } + } + ), + /***/ + "./src/parsers/PQR.ts": ( + /*!****************************!*\ + !*** ./src/parsers/PQR.ts ***! + \****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + PQR: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./utils/assignPDBBonds */ + "./src/parsers/utils/assignPDBBonds.ts" + ), g = e( + /*! ./utils/computeSecondaryStructure */ + "./src/parsers/utils/computeSecondaryStructure.ts" + ); + function _(x, o) { + var p = [[]], E = !o.noSecondaryStructure; + p.modelData = [{ symmetries: [] }]; + var u = [], A = x.split(/\r?\n|\r/), C; + for (let T = 0; T < A.length; T++) { + C = A[T].replace(/^\s*/, ""); + var L = C.substring(0, 6); + if (L.indexOf("END") == 0) + if (o.multimodel) { + o.onemol || p.push([]); + continue; + } else + break; + else if (L == "ATOM " || L == "HETATM") { + var D; + let R = parseInt(C.substring(6, 11)), z = C.substring(12, 16).replace(/ /g, ""), P = C.substring(17, 20).trim(), B = C.substring(21, 22), U = parseInt(C.substring(22, 26)); + var r = C.substring(30).trim().split(/\s+/), n = parseFloat(r[0]), b = parseFloat(r[1]), f = parseFloat(r[2]), c = parseFloat(r[3]), t = parseFloat(r[4]), a = z[0]; + z.length > 1 && z[1].toUpperCase() != z[1] && (a = z.substring(0, 2)), C[0] == "H" ? D = !0 : D = !1, u[R] = p[p.length - 1].length, p[p.length - 1].push({ + resn: P, + x: n, + y: b, + z: f, + elem: a, + hetflag: D, + chain: B, + resi: U, + serial: R, + atom: z, + bonds: [], + ss: "c", + bondOrder: [], + properties: { + charge: c, + partialCharge: c, + radius: t + }, + pdbline: C + }); + } else if (L == "CONECT") { + var h = parseInt(C.substring(6, 11)), M = p[p.length - 1][u[h]]; + for (let R = 0; R < 4; R++) { + var w = parseInt(C.substring([11, 16, 21, 26][R], [11, 16, 21, 26][R] + 5)), S = p[p.length - 1][u[w]]; + M !== void 0 && S !== void 0 && (M.bonds.push(u[w]), M.bondOrder.push(1)); + } + } + } + for (let T = 0; T < p.length; T++) + (0, l.assignPDBBonds)(p[T], o), E && (0, g.computeSecondaryStructure)(p[T], o.hbondCutoff); + return p; + } + } + ), + /***/ + "./src/parsers/PRMTOP.ts": ( + /*!*******************************!*\ + !*** ./src/parsers/PRMTOP.ts ***! + \*******************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + PRMTOP: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + function l(g) { + var _ = [], x, o = 0, p = g.split(/\r?\n|\r/); + if (p.length > 0 && p[0].includes("VERSION")) { + var E = p.filter(function(n) { + return n.includes("POINTERS") || n.includes("ATOM_NAME") || n.includes("CHARGE") || n.includes("RADII") || n.includes("BONDS_INC_HYDROGEN") || n.includes("BONDS_WITHOUT_HYDROGEN"); + }), u = D("POINTERS"); + if (u == -1) + return []; + var A = r(u), C = parseInt(p[u + 1].slice(0, A[1])); + if (isNaN(C) || C <= 0) + return []; + if (u = D("ATOM_NAME"), u == -1) + return []; + A = r(u); + var L = A[0]; + for (let n = 0; n < C / A[0]; n++) { + n == parseInt(C / A[0]) && (L = C % A[0]); + for (let b = 0; b < L; b++) { + let f = {}, c = { charge: "", radii: "" }; + f.serial = o, f.x = 0, f.y = 0, f.z = 0, f.atom = p[u + 1].slice(A[1] * b, A[1] * (b + 1)), f.elem = p[u + 1].slice(A[1] * b, A[1] * b + 1), f.properties = c, f.bonds = [], f.bondOrder = [], _.push(f), o++; + } + u++; + } + if (u = D("CHARGE"), u != -1) { + A = r(u), o = 0, L = A[0]; + for (let n = 0; n < C / A[0]; n++) { + n == parseInt(C / A[0]) && (L = C % A[0]); + for (let b = 0; b < L; b++) + _[o].properties.charge = parseFloat(p[u + 1].slice(A[1] * b, A[1] * (b + 1))), o++; + u++; + } + } + if (u = D("RADII"), u != -1) { + A = r(u), o = 0, L = A[0]; + for (let n = 0; n < C / A[0]; n++) { + n == parseInt(C / A[0]) && (L = C % A[0]); + for (let b = 0; b < L; b++) + _[o].properties.radii = parseFloat(p[u + 1].slice(A[1] * b, A[1] * (b + 1))), o++; + u++; + } + } + if (u = D("BONDS_WITHOUT_HYDROGEN"), u != -1) + for (A = r(u), o = 0, L = A[0], u = u + 1; !p[u].match(/^%FLAG/); ) { + p[u + 1].match(/^%FLAG/) && (L = C % A[0]); + for (let n = 0; n < L; n++) + o % 3 == 0 ? x = parseInt(p[u].slice(A[1] * n, A[1] * (n + 1)) / 3) : o % 3 == 1 && _[x].bonds.push(parseInt(p[u].slice(A[1] * n, A[1] * (n + 1)) / 3)), o++; + u++; + } + if (u = D("BONDS_INC_HYDROGEN"), u != -1) + for (A = r(u), o = 0, L = A[0], u = u + 1; !p[u].match(/^%FLAG/); ) { + p[u + 1].match(/^%FLAG/) && (L = C % A[0]); + for (let n = 0; n < L; n++) + o % 3 == 0 ? x = parseInt(p[u].slice(A[1] * n, A[1] * (n + 1)) / 3) : o % 3 == 1 && _[x].bonds.push(parseInt(p[u].slice(A[1] * n, A[1] * (n + 1)) / 3)), o++; + u++; + } + } else + return []; + function D(n) { + var b = p.indexOf(E.filter(function(f) { + return f.includes(n); + })[0]); + if (Number.isInteger(b) && b > 0) { + for (; !p[b].includes("FORMAT"); ) + b++; + return b; + } else + return -1; + } + function r(n) { + var b = p[n].match(/\((\d*)\S*/), f = p[n].match(/[a-zA-Z](\d*)\)\s*/); + return f == null && (f = p[n].match(/[a-zA-Z](\d*)\.\d*\)\s*/)), [b[1], f[1]]; + } + return [_]; + } + } + ), + /***/ + "./src/parsers/SDF.ts": ( + /*!****************************!*\ + !*** ./src/parsers/SDF.ts ***! + \****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + SDF: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = function(x, o) { + var p = [[]], E = !1; + for (typeof o.keepH < "u" && (E = !o.keepH); x.length > 0 && !(x.length < 4); ) { + var u = parseInt(x[3].substring(0, 3)); + if (isNaN(u) || u <= 0) + break; + var A = parseInt(x[3].substring(3, 6)), C = 4; + if (x.length < 4 + u + A) + break; + var L = [], D = p[p.length - 1].length, r = D + u, n, b; + for (n = D; n < r; n++, C++) { + b = x[C]; + var f = {}, c = b.substring(31, 34).replace(/ /g, ""); + f.atom = f.elem = c[0].toUpperCase() + c.substring(1).toLowerCase(), (f.elem !== "H" || !E) && (f.serial = n, L[n] = p[p.length - 1].length, f.x = parseFloat(b.substring(0, 10)), f.y = parseFloat(b.substring(10, 20)), f.z = parseFloat(b.substring(20, 30)), f.hetflag = !0, f.bonds = [], f.bondOrder = [], f.properties = {}, f.index = p[p.length - 1].length, p[p.length - 1].push(f)); + } + for (n = 0; n < A; n++, C++) { + b = x[C]; + var t = L[parseInt(b.substring(0, 3)) - 1 + D], a = L[parseInt(b.substring(3, 6)) - 1 + D], h = parseFloat(b.substring(6)); + typeof t < "u" && typeof a < "u" && (p[p.length - 1][t].bonds.push(a), p[p.length - 1][t].bondOrder.push(h), p[p.length - 1][a].bonds.push(t), p[p.length - 1][a].bondOrder.push(h)); + } + if (o.multimodel) { + for (o.onemol || p.push([]); x[C] !== "$$$$" && C < x.length; ) + C++; + x.splice(0, ++C); + } else + break; + } + return p; + }, g = function(x, o) { + var p = [[]], E = !1; + for (typeof o.keepH < "u" && (E = !o.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 u = x[5].substring(13).match(/\S+/g); + if (u.length < 2) + break; + var A = parseInt(u[0]); + if (isNaN(A) || A <= 0) + break; + var C = parseInt(u[1]), L = 7; + if (x.length < 8 + A + C) + break; + var D = [], r = p[p.length - 1].length, n = r + A, b, f; + for (b = r; b < n; b++, L++) { + f = x[L]; + var c = f.substring(6).match(/\S+/g); + if (c.length > 4) { + var t = {}, a = c[1].replace(/ /g, ""); + t.atom = t.elem = a[0].toUpperCase() + a.substring(1).toLowerCase(), (t.elem !== "H" || !E) && (t.serial = b, D[b] = p[p.length - 1].length, t.x = parseFloat(c[2]), t.y = parseFloat(c[3]), t.z = parseFloat(c[4]), t.hetflag = !0, t.bonds = [], t.bondOrder = [], t.properties = {}, t.index = p[p.length - 1].length, p[p.length - 1].push(t)); + } + } + if (x[L] === "M V30 END ATOM") + L++; + else + break; + if (C !== 0 && x[L] === "M V30 BEGIN BOND") + L++; + else + break; + for (b = 0; b < C; b++, L++) { + f = x[L]; + var h = f.substring(6).match(/\S+/g); + if (h.length > 3) { + var M = D[parseInt(h[2]) - 1 + r], w = D[parseInt(h[3]) - 1 + r], S = parseFloat(h[1]); + typeof M < "u" && typeof w < "u" && (p[p.length - 1][M].bonds.push(w), p[p.length - 1][M].bondOrder.push(S), p[p.length - 1][w].bonds.push(M), p[p.length - 1][w].bondOrder.push(S)); + } + } + if (o.multimodel) { + for (o.onemol || p.push([]); x[L] !== "$$$$" && L < x.length; ) + L++; + x.splice(0, ++L); + } else + break; + } + return p; + }; + function _(x, o) { + var p = "V2000", E = x.split(/\r?\n|\r/); + return E.length > 3 && E[3].length > 38 && (p = E[3].substring(34, 39)), p === "V2000" ? l(E, o) : p === "V3000" ? g(E, o) : [[""]]; + } + } + ), + /***/ + "./src/parsers/VASP.ts": ( + /*!*****************************!*\ + !*** ./src/parsers/VASP.ts ***! + \*****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + VASP: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ); + function g(_) { + var x = [[]], o = {}, p = _.replace(/^\s+/, "").split(/\r?\n/); + if (p.length < 3) + return x; + if (p[1].match(/\d+/)) + o.length = parseFloat(p[1]); + else + return console.log("Warning: second line of the vasp structure file must be a number"), x; + if (o.length < 0) + return console.log("Warning: Vasp implementation for negative lattice lengths is not yet available"), x; + o.xVec = new Float32Array(p[2].replace(/^\s+/, "").split(/\s+/)), o.yVec = new Float32Array(p[3].replace(/^\s+/, "").split(/\s+/)), o.zVec = new Float32Array(p[4].replace(/^\s+/, "").split(/\s+/)); + var E = new l.Matrix3(o.xVec[0], o.xVec[1], o.xVec[2], o.yVec[0], o.yVec[1], o.yVec[2], o.zVec[0], o.zVec[1], o.zVec[2]); + E.multiplyScalar(o.length), x.modelData = [{ symmetries: [], cryst: { matrix: E } }]; + var u = p[5].replace(/\s+/, "").replace(/\s+$/, "").split(/\s+/), A = new Int16Array(p[6].replace(/^\s+/, "").split(/\s+/)), C = p[7].replace(/\s+/, ""); + if (C.match(/C/)) + C = "cartesian"; + else if (C.match(/D/)) + C = "direct"; + else + return console.log("Warning: Unknown vasp mode in POSCAR file: mode must be either C(artesian) or D(irect)"), x; + if (u.length != A.length) + return console.log("Warning: declaration of atomary species wrong:"), console.log(u), console.log(A), x; + p.splice(0, 8); + for (var L = 0, D = 0, r = u.length; D < r; D++) { + for (var n = u[D], b = 0, f = A[D]; b < f; b++) { + var c = new Float32Array(p[L + b].replace(/^\s+/, "").split(/\s+/)), t = {}; + t.elem = n, C == "cartesian" ? (t.x = o.length * c[0], t.y = o.length * c[1], t.z = o.length * c[2]) : (t.x = o.length * (c[0] * o.xVec[0] + c[1] * o.yVec[0] + c[2] * o.zVec[0]), t.y = o.length * (c[0] * o.xVec[1] + c[1] * o.yVec[1] + c[2] * o.zVec[1]), t.z = o.length * (c[0] * o.xVec[2] + c[1] * o.yVec[2] + c[2] * o.zVec[2])), t.bonds = [], x[0].push(t); + } + L += A[D]; + } + return x; + } + } + ), + /***/ + "./src/parsers/XYZ.ts": ( + /*!****************************!*\ + !*** ./src/parsers/XYZ.ts ***! + \****************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + XYZ: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ../WebGL */ + "./src/WebGL/index.ts" + ), g = e( + /*! ./utils/assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ); + function _(x, o) { + o = o || {}; + for (var p = [[]], E = o.assignBonds === void 0 ? !0 : o.assignBonds, u = x.split(/\r?\n|\r/); u.length > 0 && !(u.length < 3); ) { + var A = parseInt(u[0]); + if (isNaN(A) || A <= 0 || u.length < A + 2) + break; + var C = /Lattice\s*=\s*["\{\}]([^"\{\}]+)["\{\}]\s*/gi, L = C.exec(u[1]); + if (L != null && L.length > 1) { + var D = new Float32Array(L[1].split(/\s+/)), r = new l.Matrix3(D[0], D[3], D[6], D[1], D[4], D[7], D[2], D[5], D[8]); + p.modelData = [{ cryst: { matrix: r } }]; + } + for (var n = 2, b = p[p.length - 1].length, f = b + A, c = b; c < f; c++) { + var t = u[n++], a = t.replace(/^\s+/, "").replace(/\s+/g, " ").split(" "), h = {}; + h.serial = c; + var M = a[0]; + h.atom = h.elem = M[0].toUpperCase() + M.substring(1, 2).toLowerCase(), h.x = parseFloat(a[1]), h.y = parseFloat(a[2]), h.z = parseFloat(a[3]), h.hetflag = !0, h.bonds = [], h.bondOrder = [], h.properties = {}, p[p.length - 1][c] = h, a.length >= 7 && (h.dx = parseFloat(a[4]), h.dy = parseFloat(a[5]), h.dz = parseFloat(a[6])); + } + if (o.multimodel) + p.push([]), u.splice(0, n); + else + break; + } + if (E) + for (let S = 0; S < p.length; S++) + (0, g.assignBonds)(p[S], o); + if (o.onemol) { + var w = p; + p = [], p.push(w[0]); + for (let S = 1; S < w.length; S++) { + let T = p[0].length; + for (let R = 0; R < w[S].length; R++) { + let z = w[S][R]; + for (let P = 0; P < z.bonds.length; P++) + z.bonds[P] = z.bonds[P] + T; + z.index = p[0].length, z.serial = p[0].length, p[0].push(z); + } + } + } + return p; + } + } + ), + /***/ + "./src/parsers/index.ts": ( + /*!******************************!*\ + !*** ./src/parsers/index.ts ***! + \******************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Parsers: () => ( + /* binding */ + b + ), + /* harmony export */ + bondLength: () => ( + /* reexport safe */ + n.bondLength + ), + /* harmony export */ + setBondLength: () => ( + /* reexport safe */ + n.setBondLength + ) + /* harmony export */ + }); + var l = e( + /*! ./VASP */ + "./src/parsers/VASP.ts" + ), g = e( + /*! ./CUBE */ + "./src/parsers/CUBE.ts" + ), _ = e( + /*! ./XYZ */ + "./src/parsers/XYZ.ts" + ), x = e( + /*! ./SDF */ + "./src/parsers/SDF.ts" + ), o = e( + /*! ./CDJSON */ + "./src/parsers/CDJSON.ts" + ), p = e( + /*! ./CIF */ + "./src/parsers/CIF.ts" + ), E = e( + /*! ./MOL2 */ + "./src/parsers/MOL2.ts" + ), u = e( + /*! ./PDB */ + "./src/parsers/PDB.ts" + ), A = e( + /*! ./PQR */ + "./src/parsers/PQR.ts" + ), C = e( + /*! ./MMTF */ + "./src/parsers/MMTF.ts" + ), L = e( + /*! ./PRMTOP */ + "./src/parsers/PRMTOP.ts" + ), D = e( + /*! ./GRO */ + "./src/parsers/GRO.ts" + ), r = e( + /*! ./LAMMPSTRJ */ + "./src/parsers/LAMMPSTRJ.ts" + ), n = e( + /*! ./utils/bondLength */ + "./src/parsers/utils/bondLength.ts" + ); + const b = { + vasp: l.VASP, + VASP: l.VASP, + cube: g.CUBE, + CUBE: g.CUBE, + xyz: _.XYZ, + XYZ: _.XYZ, + sdf: x.SDF, + SDF: x.SDF, + json: o.CDJSON, + cdjson: o.CDJSON, + CDJSON: o.CDJSON, + mcif: p.CIF, + cif: p.CIF, + CIF: p.CIF, + mol2: E.MOL2, + MOL2: E.MOL2, + pdb: u.PDB, + PDB: u.PDB, + pdbqt: u.PDB, + PDBQT: u.PDB, + pqr: A.PQR, + PQR: A.PQR, + mmtf: C.MMTFparser, + MMTF: C.MMTFparser, + prmtop: L.PRMTOP, + PRMTOP: L.PRMTOP, + gro: D.GRO, + GRO: D.GRO, + lammpstrj: r.LAMMPSTRJ, + LAMMPSTRJ: r.LAMMPSTRJ + }; + } + ), + /***/ + "./src/parsers/utils/anumToSymbol.ts": ( + /*!*******************************************!*\ + !*** ./src/parsers/utils/anumToSymbol.ts ***! + \*******************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + anumToSymbol: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + const l = { + 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 ***! + \*******************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + areConnected: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + var l = e( + /*! ./bondLength */ + "./src/parsers/utils/bondLength.ts" + ); + const g = /* @__PURE__ */ new Set(["Na", "K", "Ca", "Mg", "Mn", "Sr"]); + function _(x, o, p) { + if (p && p.unboundCations && (g.has(x.elem) || g.has(o.elem))) + return !1; + let E = (0, l.bondLength)(x.elem) + (0, l.bondLength)(o.elem); + E += 0.25, E *= E; + let u = x.x - o.x; + if (u *= u, u > E) + return !1; + let A = x.y - o.y; + if (A *= A, A > E) + return !1; + let C = x.z - o.z; + if (C *= C, C > E) + return !1; + const L = u + A + C; + return !(isNaN(L) || L < 0.5 || L > E || x.altLoc !== o.altLoc && x.altLoc !== " " && o.altLoc !== " "); + } + } + ), + /***/ + "./src/parsers/utils/assignBackboneHBonds.ts": ( + /*!***************************************************!*\ + !*** ./src/parsers/utils/assignBackboneHBonds.ts ***! + \***************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + assignBackboneHBonds: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + function l(g, _) { + const x = _ || 3.2, o = x * x, p = []; + for (let E = 0, u = g.length; E < u; E++) { + g[E].index = E; + const A = g[E]; + !A.hetflag && (A.atom === "N" || A.atom === "O") && (p.push(A), A.hbondOther = null, A.hbondDistanceSq = Number.POSITIVE_INFINITY); + } + p.sort(function(E, u) { + return E.z - u.z; + }); + for (let E = 0, u = p.length; E < u; E++) { + const A = p[E]; + for (let C = E + 1; C < u; C++) { + const L = p[C], D = L.z - A.z; + if (D > x) + break; + if (L.atom == A.atom) + continue; + const r = Math.abs(L.y - A.y); + if (r > x) + continue; + const n = Math.abs(L.x - A.x); + if (n > x) + continue; + const b = n * n + r * r + D * D; + b > o || L.chain == A.chain && Math.abs(L.resi - A.resi) < 4 || (b < A.hbondDistanceSq && (A.hbondOther = L, A.hbondDistanceSq = b), b < L.hbondDistanceSq && (L.hbondOther = A, L.hbondDistanceSq = b)); + } + } + } + } + ), + /***/ + "./src/parsers/utils/assignBonds.ts": ( + /*!******************************************!*\ + !*** ./src/parsers/utils/assignBonds.ts ***! + \******************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + assignBonds: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./areConnected */ + "./src/parsers/utils/areConnected.ts" + ); + const g = [ + { 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 } + ], _ = 4.95; + function x(o, p) { + for (let A = 0, C = o.length; A < C; A++) + o[A].index || (o[A].index = A); + const E = { + x: { + y: { + z: [] + } + } + }; + for (let A = 0; A < o.length; A++) { + const C = o[A], L = Math.floor(C.x / _), D = Math.floor(C.y / _), r = Math.floor(C.z / _); + E[L] || (E[L] = {}), E[L][D] || (E[L][D] = {}), E[L][D][r] || (E[L][D][r] = []), E[L][D][r].push(C); + } + function u(A, C) { + for (let L = 0; L < A.length; L++) { + const D = A[L]; + for (let r = 0; r < C.length; r++) { + const n = C[r]; + if ((0, l.areConnected)(D, n, p)) { + const b = D.bonds.indexOf(n.index), f = n.bonds.indexOf(D.index); + b === -1 && f === -1 ? (D.bonds.push(n.index), D.bondOrder.push(1), n.bonds.push(D.index), n.bondOrder.push(1)) : b === -1 ? (D.bonds.push(n.index), D.bondOrder.push(n.bondOrder[f])) : f === -1 && (n.bonds.push(D.index), n.bondOrder.push(D.bondOrder[b])); + } + } + } + } + for (let A in E) { + const C = parseInt(A); + for (let L in E[C]) { + const D = parseInt(L); + for (let r in E[C][D]) { + const n = parseInt(r), b = E[C][D][n]; + for (let f = 0; f < b.length; f++) { + const c = b[f]; + for (let t = f + 1; t < b.length; t++) { + const a = b[t]; + (0, l.areConnected)(c, a, p) && c.bonds.indexOf(a.index) == -1 && (c.bonds.push(a.index), c.bondOrder.push(1), a.bonds.push(c.index), a.bondOrder.push(1)); + } + } + for (let f = 0; f < g.length; f++) { + const c = g[f]; + if (!E[C + c.x] || !E[C + c.x][D + c.y] || !E[C + c.x][D + c.y][n + c.z]) + continue; + const t = E[C + c.x][D + c.y][n + c.z]; + u(b, t); + } + } + } + } + } + } + ), + /***/ + "./src/parsers/utils/assignPDBBonds.ts": ( + /*!*********************************************!*\ + !*** ./src/parsers/utils/assignPDBBonds.ts ***! + \*********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + assignPDBBonds: () => ( + /* binding */ + x + ) + /* harmony export */ + }); + var l = e( + /*! ./areConnected */ + "./src/parsers/utils/areConnected.ts" + ), g = e( + /*! ./assignBonds */ + "./src/parsers/utils/assignBonds.ts" + ), _ = e( + /*! ./standardResidues */ + "./src/parsers/utils/standardResidues.ts" + ); + function x(o, p) { + const E = [], u = []; + for (let D = 0, r = o.length; D < r; D++) { + const n = o[D]; + n.index = D, n.hetflag || !_.standardResidues.has(n.resn) ? u.push(n) : E.push(n); + } + (0, g.assignBonds)(u, p), E.sort(function(D, r) { + return D.chain !== r.chain ? D.chain < r.chain ? -1 : 1 : D.resi - r.resi; + }); + let A = -1, C = -1, L; + for (let D = 0, r = E.length; D < r; D++) { + const n = E[D]; + n.resi !== A && (A = n.resi, L || C++, L = !1), n.reschain = C; + for (let b = D + 1; b < E.length; b++) { + const f = E[b]; + if (f.chain !== n.chain || f.resi - n.resi > 1) + break; + (0, l.areConnected)(n, f, p) && (n.bonds.indexOf(f.index) === -1 && (n.bonds.push(f.index), n.bondOrder.push(1), f.bonds.push(n.index), f.bondOrder.push(1)), n.resi !== f.resi && (L = !0)); + } + } + } + } + ), + /***/ + "./src/parsers/utils/atomNameToElem.ts": ( + /*!*********************************************!*\ + !*** ./src/parsers/utils/atomNameToElem.ts ***! + \*********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + atomNameToElem: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ./bondLength */ + "./src/parsers/utils/bondLength.ts" + ); + function g(_, x) { + let o = _.replace(/ /g, ""); + return o.length > 0 && o[0] === "H" && o !== "Hg" && o !== "He" && o !== "Hf" && o !== "Hs" && o !== "Ho" && (o = "H"), o.length > 1 && (o = o[0].toUpperCase() + o.substring(1).toLowerCase(), l.bondTable[o] === void 0 ? o = o[0] : x && (o === "Ca" || o === "Cd") && (o = "C")), o; + } + } + ), + /***/ + "./src/parsers/utils/bondLength.ts": ( + /*!*****************************************!*\ + !*** ./src/parsers/utils/bondLength.ts ***! + \*****************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + bondLength: () => ( + /* binding */ + g + ), + /* harmony export */ + bondTable: () => ( + /* binding */ + l + ), + /* harmony export */ + setBondLength: () => ( + /* binding */ + _ + ) + /* harmony export */ + }); + let l = { + 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 g(x) { + return l[x] || 1.6; + } + function _(x, o) { + o < 0 && (o = 0), l[x] = o; + } + } + ), + /***/ + "./src/parsers/utils/computeSecondaryStructure.ts": ( + /*!********************************************************!*\ + !*** ./src/parsers/utils/computeSecondaryStructure.ts ***! + \********************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + computeSecondaryStructure: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ./assignBackboneHBonds */ + "./src/parsers/utils/assignBackboneHBonds.ts" + ); + function g(_, x) { + (0, l.assignBackboneHBonds)(_, x); + const o = {}; + let p, E, u, A, C, L; + for (p = 0, E = _.length; p < E; p++) + if (C = _[p], o[C.chain] === void 0 && (o[C.chain] = []), isFinite(C.hbondDistanceSq)) { + const D = C.hbondOther; + o[D.chain] === void 0 && (o[D.chain] = []), Math.abs(D.resi - C.resi) === 4 && (o[C.chain][C.resi] = "h"); + } + for (u in o) + for (A = 1; A < o[u].length - 1; A++) { + const D = o[u][A - 1], r = o[u][A + 1]; + L = o[u][A], D == "h" && D == r && L != D && (o[u][A] = D); + } + for (p = 0, E = _.length; p < E; p++) + C = _[p], isFinite(C.hbondDistanceSq) && o[C.chain][C.resi] != "h" && C.ss !== "h" && (o[C.chain][C.resi] = "maybesheet"); + for (let D = 0, r = _.length; D < r; D++) + if (C = _[D], isFinite(C.hbondDistanceSq) && o[C.chain][C.resi] == "maybesheet") { + let n = C.hbondOther, b = o[n.chain][n.resi]; + (b == "maybesheet" || b == "s") && (o[C.chain][C.resi] = "s", o[n.chain][n.resi] = "s"); + } + for (let D in o) { + for (let r = 1; r < o[D].length - 1; r++) { + const n = o[D][r - 1], b = o[D][r + 1]; + L = o[D][r], n == "s" && n == b && L != n && (o[D][r] = n); + } + for (let r = 0; r < o[D].length; r++) { + const n = o[D][r]; + (n == "h" || n == "s") && o[D][r - 1] != n && o[D][r + 1] != n && delete o[D][r]; + } + } + for (p = 0, E = _.length; p < E; p++) + C = _[p], L = o[C.chain][C.resi], delete C.hbondOther, delete C.hbondDistanceSq, !(L === void 0 || L === "maybesheet") && (C.ss = L, o[C.chain][C.resi - 1] != L && (C.ssbegin = !0), o[C.chain][C.resi + 1] != L && (C.ssend = !0)); + } + } + ), + /***/ + "./src/parsers/utils/getSinglePDB.ts": ( + /*!*******************************************!*\ + !*** ./src/parsers/utils/getSinglePDB.ts ***! + \*******************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + getSinglePDB: () => ( + /* binding */ + A + ) + /* harmony export */ + }); + var l = e( + /*! ../../WebGL */ + "./src/WebGL/index.ts" + ), g = e( + /*! ./atomNameToElem */ + "./src/parsers/utils/atomNameToElem.ts" + ), _ = e( + /*! ./bondLength */ + "./src/parsers/utils/bondLength.ts" + ), x = e( + /*! ./computeSecondaryStructure */ + "./src/parsers/utils/computeSecondaryStructure.ts" + ), o = e( + /*! ./isEmpty */ + "./src/parsers/utils/isEmpty.ts" + ), p = e( + /*! ./processSymmetries */ + "./src/parsers/utils/processSymmetries.ts" + ), E = e( + /*! ./assignPDBBonds */ + "./src/parsers/utils/assignPDBBonds.ts" + ), u = e( + /*! ./validateBonds */ + "./src/parsers/utils/validateBonds.ts" + ); + function A(C, L, D) { + const r = [], n = L.assignBonds === void 0 ? !0 : L.assignBonds, b = !L.keepH, f = !!L.noSecondaryStructure, c = !L.noComputeSecondaryStructure, t = !L.doAssembly, a = L.altLoc ? L.altLoc : "A", h = { symmetries: [], cryst: void 0 }; + let M, w = []; + const S = []; + let T; + const R = {}; + for (let z = 0; z < C.length; z++) { + T = C[z].replace(/^\s*/, ""); + const P = T.substring(0, 6); + let B, U, F; + if (P.indexOf("END") === 0) { + if (w = C.slice(z + 1), P === "END") + for (const $ in D) + D.hasOwnProperty($) && delete D[$]; + break; + } else if (P === "ATOM " || P === "HETATM") { + let $, W, N, G, k, j, Q, ie, pe, he, ue, se; + if (ue = T.substring(16, 17), ue !== " " && ue !== a && a !== "*" || (he = parseInt(T.substring(6, 11)), M = T.substring(12, 16).replace(/ /g, ""), $ = T.substring(17, 20).replace(/ /g, ""), W = T.substring(21, 22), N = parseInt(T.substring(22, 26)), G = T.substring(26, 27), k = parseFloat(T.substring(30, 38)), j = parseFloat(T.substring(38, 46)), Q = parseFloat(T.substring(46, 54)), se = parseFloat(T.substring(60, 68)), pe = T.substring(76, 78).replace(/ /g, ""), pe === "" || _.bondTable[pe] === void 0 ? pe = (0, g.atomNameToElem)(T.substring(12, 14), T[0] == "A") : pe = pe[0].toUpperCase() + pe.substring(1).toLowerCase(), pe === "H" && b)) + continue; + P[0] == "H" ? ie = !0 : ie = !1, S[he] = r.length, r.push({ + resn: $, + x: k, + y: j, + z: Q, + elem: pe, + hetflag: ie, + altLoc: ue, + chain: W, + resi: N, + icode: G, + rescode: N + (G !== " " ? "^" + G : ""), + // resi + // and + // icode + serial: he, + atom: M, + bonds: [], + ss: "c", + bondOrder: [], + properties: {}, + b: se, + pdbline: T + }); + } else if (P === "SHEET ") { + B = T.substring(21, 22), U = parseInt(T.substring(22, 26)), F = parseInt(T.substring(33, 37)), B in D || (D[B] = {}), D[B][U] = "s1"; + for (let $ = U + 1; $ < F; $++) + D[B][$] = "s"; + D[B][F] = "s2"; + } else if (P === "CONECT") { + const $ = parseInt(T.substring(6, 11)), W = S[$], N = r[W], G = [11, 16, 21, 26]; + for (let k = 0; k < 4; k++) { + const j = parseInt(T.substring(G[k], G[k] + 5)), Q = S[j]; + let ie = W + ":" + Q; + const pe = r[Q]; + if (N !== void 0 && pe !== void 0) + if (!R[ie]) + R[ie] = 1, (N.bonds.length == 0 || N.bonds[N.bonds.length - 1] !== Q) && (N.bonds.push(Q), N.bondOrder.push(1)); + else { + R[ie] += 1; + for (let he = 0; he < N.bonds.length; he++) + if (N.bonds[he] == Q) { + const ue = R[ie]; + ue >= 4 ? N.bondOrder[he] = 1 : N.bondOrder[he] = ue; + } + } + } + } else if (P === "HELIX ") { + B = T.substring(19, 20), U = parseInt(T.substring(21, 25)), F = parseInt(T.substring(33, 37)), B in D || (D[B] = {}), D[B][U] = "h1"; + for (let $ = U + 1; $ < F; $++) + D[B][$] = "h"; + D[B][F] = "h2"; + } else if (!t && P === "REMARK" && T.substring(13, 18) === "BIOMT") { + let $, W = new l.Matrix4(); + for ($ = 1; $ <= 3; $++) + if (T = C[z].replace(/^\s*/, ""), parseInt(T.substring(18, 19)) == $) + W.elements[$ - 1] = parseFloat(T.substring(23, 33)), W.elements[$ - 1 + 4] = parseFloat(T.substring(33, 43)), W.elements[$ - 1 + 8] = parseFloat(T.substring(43, 53)), W.elements[$ - 1 + 12] = parseFloat(T.substring(53)), z++; + else + for (; T.substring(13, 18) === "BIOMT"; ) + z++, T = C[z].replace(/^\s*/, ""); + W.elements[3] = 0, W.elements[7] = 0, W.elements[11] = 0, W.elements[15] = 1, h.symmetries.push(W), z--; + } else if (P === "CRYST1") { + let $, W, N, G, k, j; + $ = parseFloat(T.substring(7, 15)), W = parseFloat(T.substring(16, 24)), N = parseFloat(T.substring(25, 33)), G = parseFloat(T.substring(34, 40)), k = parseFloat(T.substring(41, 47)), j = parseFloat(T.substring(48, 54)), h.cryst = { + a: $, + b: W, + c: N, + alpha: G, + beta: k, + gamma: j + }; + } else if (P === "ANISOU") { + const $ = parseInt(T.substring(6, 11)), W = S[$], N = r[W]; + if (N) { + const G = T.substring(30).trim().split(/\s+/), k = { + u11: parseInt(G[0]), + u22: parseInt(G[1]), + u33: parseInt(G[2]), + u12: parseInt(G[3]), + u13: parseInt(G[4]), + u23: parseInt(G[5]) + }; + N.uMat = k; + } + } + } + if ((0, u.validateBonds)(r, S), n && (0, E.assignPDBBonds)(r, L), t || (0, p.processSymmetries)(h.symmetries, r, L, h.cryst), c && !f && (0, x.computeSecondaryStructure)(r, L.hbondCutoff), !(0, o.isEmpty)(D)) + for (let z = 0; z < r.length; z++) { + const P = r[z]; + if (P !== void 0 && P.chain in D && P.resi in D[P.chain]) { + const B = D[P.chain][P.resi]; + P.ss = B[0], B.length > 1 && (B[1] == "1" ? P.ssbegin = !0 : B[1] == "2" && (P.ssend = !0)); + } + } + return [r, h, w]; + } + } + ), + /***/ + "./src/parsers/utils/isEmpty.ts": ( + /*!**************************************!*\ + !*** ./src/parsers/utils/isEmpty.ts ***! + \**************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + isEmpty: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + function l(g) { + for (const _ in g) + return !1; + return !0; + } + } + ), + /***/ + "./src/parsers/utils/processSymmetries.ts": ( + /*!************************************************!*\ + !*** ./src/parsers/utils/processSymmetries.ts ***! + \************************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + processSymmetries: () => ( + /* binding */ + g + ) + /* harmony export */ + }); + var l = e( + /*! ../../WebGL */ + "./src/WebGL/index.ts" + ); + function g(_, x, o, p) { + const E = !o.duplicateAssemblyAtoms, u = x.length; + let A = u, C = -1, L = null, D = null; + (o.normalizeAssembly || o.wrapAtoms) && p && (L = (0, l.conversionMatrix3)(p.a, p.b, p.c, p.alpha, p.beta, p.gamma), D = new l.Matrix3(), D.getInverse3(L)); + let r = function(f) { + let c = f.clone().applyMatrix3(D); + const t = [c.x, c.y, c.z], a = [0, 0, 0]; + for (let M = 0; M < 3; M++) { + for (; t[M] < -1e-3; ) + t[M] += 1, a[M] += 1; + for (; t[M] > 1.001; ) + t[M] -= 1, a[M] -= 1; + } + const h = new l.Vector3(a[0], a[1], a[2]); + return h.applyMatrix3(L), h; + }; + if (o.normalizeAssembly && p) + for (let f = 0; f < _.length; f++) { + const c = new l.Vector3(0, 0, 0); + for (let a = 0; a < u; a++) { + const h = new l.Vector3(x[a].x, x[a].y, x[a].z); + h.applyMatrix4(_[f]), c.add(h); + } + c.divideScalar(u); + const t = r(c); + _[f].isNearlyIdentity() && t.lengthSq() > 1e-3 && (C = f), _[f].translate(t); + } + if (E) { + if (_.length > 1) + for (let f = 0; f < x.length; f++) { + var n = []; + for (let c = 0; c < _.length; c++) + if (!_[c].isNearlyIdentity()) { + var b = new l.Vector3(); + b.set(x[f].x, x[f].y, x[f].z), b.applyMatrix4(_[c]), n.push(b); + } + x[f].symmetries = n; + } + } else { + for (let f = 0; f < u; f++) + x[f].sym = -1; + for (let f = 0; f < _.length; f++) + if (!_[f].isNearlyIdentity() && C != f) { + let c = new l.Vector3(); + for (let t = 0; t < u; t++) { + const a = []; + for (let M = 0; M < x[t].bonds.length; M++) + a.push(x[t].bonds[M] + A); + if (c.set(x[t].x, x[t].y, x[t].z), c.applyMatrix4(_[f]), o.wrapAtoms && p) { + let M = r(c); + c.add(M); + } + const h = {}; + for (const M in x[t]) + h[M] = x[t][M]; + h.x = c.x, h.y = c.y, h.z = c.z, h.bonds = a, h.sym = f, h.index = x.length, x.push(h); + } + A = x.length; + } else + for (let c = 0; c < u; c++) + x[c].sym = f; + if (o.wrapAtoms && p) { + let f = new l.Vector3(); + for (let c = 0; c < u; c++) { + f.set(x[c].x, x[c].y, x[c].z); + let t = r(f); + f.add(t), x[c].x = f.x, x[c].y = f.y, x[c].z = f.z; + } + } + if (C >= 0) { + const f = new l.Vector3(); + for (let c = 0; c < u; c++) + f.set(x[c].x, x[c].y, x[c].z), f.applyMatrix4(_[C]), x[c].x = f.x, x[c].y = f.y, x[c].z = f.z; + } + _.length = 0; + } + } + } + ), + /***/ + "./src/parsers/utils/standardResidues.ts": ( + /*!***********************************************!*\ + !*** ./src/parsers/utils/standardResidues.ts ***! + \***********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + standardResidues: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + const l = /* @__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 ***! + \********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + validateBonds: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + function l(g, _) { + for (let x = 0, o = g.length; x < o; x++) { + const p = g[x]; + for (let E = 0; E < p.bonds.length; E++) { + const u = p.bonds[E], A = g[u], C = _[p.serial]; + A && C && A.bonds.indexOf(C) < 0 && (A.bonds.push(C), A.bondOrder.push(p.bondOrder[E])); + } + } + } + } + ), + /***/ + "./src/partialCharges.ts": ( + /*!*******************************!*\ + !*** ./src/partialCharges.ts ***! + \*******************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + applyPartialCharges: () => ( + /* binding */ + g + ), + /* harmony export */ + partialCharges: () => ( + /* binding */ + l + ) + /* harmony export */ + }); + const l = { + "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 g(_, x) { + if ((!x || typeof _.partialCharge > "u") && _.resn && _.atom) { + var o = _.resn + ":" + _.atom; + _.properties.partialCharge = l[o]; + } + } + } + ), + /***/ + "./src/specs.ts": ( + /*!**********************!*\ + !*** ./src/specs.ts ***! + \**********************/ + /***/ + (y, s, e) => { + e.r(s); + } + ), + /***/ + "./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(y, s) { + for (var e in s) + s.hasOwnProperty(e) && s[e] !== void 0 && (y[e] = s[e]); + return y; + } + function deepCopy(y) { + let s, e, l; + if (y == null) + return {}; + if (typeof y != "object" || y === null) + return y; + s = Array.isArray(y) ? [] : {}; + for (l in y) + e = y[l], s[l] = deepCopy(e); + return s; + } + function isNumeric(y) { + var s = typeof y; + return (s === "number" || s === "string") && !isNaN(y - parseFloat(y)); + } + function isEmptyObject(y) { + var s; + for (s in y) + return !1; + return !0; + } + function makeFunction(callback) { + return callback && typeof callback == "string" && (callback = eval("(" + callback + ")")), callback && typeof callback != "function" ? null : callback; + } + function adjustVolumeStyle(y) { + y && (y.volformat && !(y.voldata instanceof _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData) && (y.voldata = new _VolumeData__WEBPACK_IMPORTED_MODULE_1__.VolumeData(y.voldata, y.volformat)), y.volscheme && (y.volscheme = _Gradient__WEBPACK_IMPORTED_MODULE_0__.Gradient.getGradient(y.volscheme))); + } + function getExtent(y, s) { + var e, l, g, _, x, o, p, E, u, A, C = !s; + if (e = l = g = 9999, _ = x = o = -9999, p = E = u = A = 0, y.length === 0) + return [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; + for (var L = 0; L < y.length; L++) { + var D = y[L]; + if (!(typeof D > "u" || !isFinite(D.x) || !isFinite(D.y) || !isFinite(D.z)) && (A++, p += D.x, E += D.y, u += D.z, e = e < D.x ? e : D.x, l = l < D.y ? l : D.y, g = g < D.z ? g : D.z, _ = _ > D.x ? _ : D.x, x = x > D.y ? x : D.y, o = o > D.z ? o : D.z, D.symmetries && C)) + for (var r = 0; r < D.symmetries.length; r++) + A++, p += D.symmetries[r].x, E += D.symmetries[r].y, u += D.symmetries[r].z, e = e < D.symmetries[r].x ? e : D.symmetries[r].x, l = l < D.symmetries[r].y ? l : D.symmetries[r].y, g = g < D.symmetries[r].z ? g : D.symmetries[r].z, _ = _ > D.symmetries[r].x ? _ : D.symmetries[r].x, x = x > D.symmetries[r].y ? x : D.symmetries[r].y, o = o > D.symmetries[r].z ? o : D.symmetries[r].z; + } + return [ + [e, l, g], + [_, x, o], + [p / A, E / A, u / A] + ]; + } + function getPropertyRange(y, s) { + for (var e = Number.POSITIVE_INFINITY, l = Number.NEGATIVE_INFINITY, g = 0, _ = y.length; g < _; g++) { + var x = y[g], o = getAtomProperty(x, s); + o != null && (o < e && (e = o), o > l && (l = o)); + } + return !isFinite(e) && !isFinite(l) ? e = l = 0 : isFinite(e) ? isFinite(l) || (l = e) : e = l, [e, l]; + } + class PausableTimer { + constructor(s, e, l) { + this.total_time_run = 0, this.fn = s, this.arg = l, this.countdown = e, this.start_time = (/* @__PURE__ */ new Date()).getTime(), this.ident = setTimeout(s, e, l); + } + 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(y) { + for (var s = window.atob(y), e = s.length, l = new Uint8Array(e), g = 0; g < e; g++) + l[g] = s.charCodeAt(g); + return l; + } + function getAtomProperty(y, s) { + var e = null; + return y.properties && typeof y.properties[s] < "u" ? e = y.properties[s] : typeof y[s] < "u" && (e = y[s]), e; + } + function mergeGeos(y, s) { + var e = s.geometry; + e !== void 0 && y.geometryGroups.push(e.geometryGroups[0]); + } + function specStringToObject(y) { + if (typeof y == "object") + return y; + if (typeof y > "u" || y == null) + return y; + try { + return JSON.parse(y); + } catch { + } + y = y.replace(/%7E/g, "~"); + var s = function(C) { + return isNumeric(C) ? Math.floor(parseFloat(C)) == parseInt(C) || C.indexOf(".") >= 0 ? parseFloat(C) : parseInt(C) : C === "true" ? !0 : C === "false" ? !1 : C; + }, e = {}; + if (y === "all") + return e; + for (var l = y.split(";"), g = 0; g < l.length; g++) { + var _ = l[g].split(":"), x = _[0], o = {}, p = _[1]; + if (p) + if (p = p.replace(/~/g, "="), p.indexOf("=") !== -1) + for (var E = p.split(","), u = 0; u < E.length; u++) { + var A = E[u].split("=", 2); + o[A[0]] = s(A[1]); + } + else + p.indexOf(",") !== -1 ? o = p.split(",") : o = s(p); + e[x] = o; + } + return e; + } + function checkStatus(y) { + if (!y.ok) + throw new Error(`HTTP ${y.status} - ${y.statusText}`); + return y; + } + function get(y, s) { + var e = fetch(y).then(checkStatus).then((l) => l.text()); + return s ? e.then(s) : e; + } + function getbin(y, s, e, l) { + var g; + return e == "POST" ? g = fetch(y, { method: "POST", body: l }).then((_) => checkStatus(_)).then((_) => _.arrayBuffer()) : g = fetch(y).then((_) => checkStatus(_)).then((_) => _.arrayBuffer()), s ? g.then(s) : g; + } + function download(y, s, e, l) { + var g = "", _ = "", x = "", o = "", p = null, E = s.addModel(); + if (y.indexOf(":") < 0 && (y.length == 4 ? y = "pdb:" + y : isNaN(y) ? y = "url:" + y : y = "cid:" + y), y.substring(0, 5) === "mmtf:") + _ = e && e.pdbUri ? e.pdbUri : "https://mmtf.rcsb.org/v1.0/full/", y = y.substring(5).toUpperCase(), o = _ + y, e && typeof e.noComputeSecondaryStructure > "u" && (e.noComputeSecondaryStructure = !0), p = new Promise(function(A) { + getbin(o).then(function(C) { + E.addMolData(C, "mmtf", e), s.zoomTo(), s.render(), A(E); + }, function() { + console.log("fetch of " + o + " failed."); + }); + }); + else { + if (y.substring(0, 4) === "pdb:") { + if (g = "mmtf", e && e.format && (g = e.format), e && typeof e.noComputeSecondaryStructure > "u" && (e.noComputeSecondaryStructure = !0), y = y.substring(4).toUpperCase(), !y.match(/^[1-9][A-Za-z0-9]{3}$/)) { + alert("Wrong PDB ID"); + return; + } + g == "mmtf" ? (x = e && e.mmtfUri ? e.mmtfUri : "https://mmtf.rcsb.org/v1.0/full/", o = x + y.toUpperCase()) : (_ = e && e.pdbUri ? e.pdbUri : "https://files.rcsb.org/view/", o = _ + y + "." + g); + } else if (y.substring(0, 4) == "cid:") { + if (g = "sdf", y = y.substring(4), !y.match(/^[0-9]+$/)) { + alert("Wrong Compound ID"); + return; + } + o = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/" + y + "/SDF?record_type=3d"; + } else + y.substring(0, 4) == "url:" && (o = y.substring(4), g = o); + var u = function(A) { + E.addMolData(A, g, e), s.zoomTo(), s.render(); + }; + p = new Promise(function(A) { + g == "mmtf" ? getbin(o).then(function(C) { + u(C), A(E); + }).catch(function() { + _ = e && e.pdbUri ? e.pdbUri : "https://files.rcsb.org/view/", o = _ + y + ".pdb", g = "pdb", console.log("falling back to pdb format"), get(o).then(function(C) { + u(C), A(E); + }).catch(function(C) { + u(""), A(E), console.log("fetch of " + o + " failed: " + C.statusText); + }); + }) : get(o).then(function(C) { + u(C), A(E); + }).catch(function(C) { + u(""), A(E), console.log("fetch of " + o + " failed: " + C.statusText); + }); + }); + } + return l ? (p.then(function(A) { + l(A); + }), E) : p; + } + function getColorFromStyle(y, s) { + let e = s.colorscheme; + if (typeof _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[e] < "u") + e = _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[e]; + else if (typeof e == "string" && e.endsWith("Carbon")) { + let x = e.substring(0, e.lastIndexOf("Carbon")).toLowerCase(); + if (typeof _colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[x] < "u") { + let o = Object.assign({}, _colors__WEBPACK_IMPORTED_MODULE_2__.elementColors.defaultColors); + o.C = _colors__WEBPACK_IMPORTED_MODULE_2__.htmlColors[x], _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[e] = { prop: "elem", map: o }, e = _colors__WEBPACK_IMPORTED_MODULE_2__.builtinColorSchemes[e]; + } + } + let l = y.color; + if (typeof s.color < "u" && s.color != "spectrum" && (l = s.color), typeof e < "u") { + let x, o; + if (typeof _colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[e] < "u") + e = _colors__WEBPACK_IMPORTED_MODULE_2__.elementColors[e], typeof e[y[e.prop]] < "u" && (l = e.map[y[e.prop]]); + else if (typeof e[y[e.prop]] < "u") + l = e.map[y[e.prop]]; + else if (typeof e.prop < "u" && typeof e.gradient < "u") { + x = e.prop; + var g = e.gradient; + typeof _Gradient__WEBPACK_IMPORTED_MODULE_0__.builtinGradients[g] < "u" && (g = new _Gradient__WEBPACK_IMPORTED_MODULE_0__.builtinGradients[g](e.min, e.max, e.mid ? e.mid : e.colors)); + let p = g.range() || [-1, 1]; + o = getAtomProperty(y, x), o != null && (l = g.valueToHex(o, p)); + } else + typeof e.prop < "u" && typeof e.map < "u" ? (x = e.prop, o = getAtomProperty(y, x), typeof e.map[o] < "u" && (l = e.map[o])) : typeof s.colorscheme[y.elem] < "u" ? l = s.colorscheme[y.elem] : console.log("Could not interpret colorscheme " + e); + } else + typeof s.colorfunc < "u" && (l = s.colorfunc(y)); + return _colors__WEBPACK_IMPORTED_MODULE_2__.CC.color(l); + } + function getElement(y) { + let s = y; + return typeof y == "string" ? s = document.querySelector("#" + y) : typeof y == "object" && y.get && (s = y.get(0)), s; + } + } + ), + /***/ + "./node_modules/upng-js/UPNG.js": ( + /*!**************************************!*\ + !*** ./node_modules/upng-js/UPNG.js ***! + \**************************************/ + /***/ + (y, s, e) => { + (function() { + var l = {}, g; + y.exports = l, g = e( + /*! pako */ + "./node_modules/upng-js/node_modules/pako/index.js" + ), function(_, x) { + _.toRGBA8 = function(o) { + var p = o.width, E = o.height; + if (o.tabs.acTL == null) + return [_.toRGBA8.decodeImage(o.data, p, E, o).buffer]; + var u = []; + o.frames[0].data == null && (o.frames[0].data = o.data); + for (var A, C = new Uint8Array(p * E * 4), L = 0; L < o.frames.length; L++) { + var D = o.frames[L], r = D.rect.x, n = D.rect.y, b = D.rect.width, f = D.rect.height, c = _.toRGBA8.decodeImage(D.data, b, f, o); + if (L == 0 ? A = c : D.blend == 0 ? _._copyTile(c, b, f, A, p, E, r, n, 0) : D.blend == 1 && _._copyTile(c, b, f, A, p, E, r, n, 1), u.push(A.buffer), A = A.slice(0), D.dispose != 0) { + if (D.dispose == 1) + _._copyTile(C, b, f, A, p, E, r, n, 0); + else if (D.dispose == 2) { + for (var t = L - 1; o.frames[t].dispose == 2; ) + t--; + A = new Uint8Array(u[t]).slice(0); + } + } + } + return u; + }, _.toRGBA8.decodeImage = function(o, p, E, u) { + var A = p * E, C = _.decode._getBPP(u), L = Math.ceil(p * C / 8), D = new Uint8Array(A * 4), r = new Uint32Array(D.buffer), n = u.ctype, b = u.depth, f = _._bin.readUshort; + if (n == 6) { + var c = A << 2; + if (b == 8) + for (var t = 0; t < c; t++) + D[t] = o[t]; + if (b == 16) + for (var t = 0; t < c; t++) + D[t] = o[t << 1]; + } else if (n == 2) { + var a = u.tabs.tRNS, h = -1, M = -1, w = -1; + if (a && (h = a[0], M = a[1], w = a[2]), b == 8) + for (var t = 0; t < A; t++) { + var S = t << 2, T = t * 3; + D[S] = o[T], D[S + 1] = o[T + 1], D[S + 2] = o[T + 2], D[S + 3] = 255, h != -1 && o[T] == h && o[T + 1] == M && o[T + 2] == w && (D[S + 3] = 0); + } + if (b == 16) + for (var t = 0; t < A; t++) { + var S = t << 2, T = t * 6; + D[S] = o[T], D[S + 1] = o[T + 2], D[S + 2] = o[T + 4], D[S + 3] = 255, h != -1 && f(o, T) == h && f(o, T + 2) == M && f(o, T + 4) == w && (D[S + 3] = 0); + } + } else if (n == 3) { + var R = u.tabs.PLTE, z = u.tabs.tRNS, P = z ? z.length : 0; + if (b == 1) + for (var B = 0; B < E; B++) + for (var U = B * L, F = B * p, t = 0; t < p; t++) { + var S = F + t << 2, $ = o[U + (t >> 3)] >> 7 - ((t & 7) << 0) & 1, W = 3 * $; + D[S] = R[W], D[S + 1] = R[W + 1], D[S + 2] = R[W + 2], D[S + 3] = $ < P ? z[$] : 255; + } + if (b == 2) + for (var B = 0; B < E; B++) + for (var U = B * L, F = B * p, t = 0; t < p; t++) { + var S = F + t << 2, $ = o[U + (t >> 2)] >> 6 - ((t & 3) << 1) & 3, W = 3 * $; + D[S] = R[W], D[S + 1] = R[W + 1], D[S + 2] = R[W + 2], D[S + 3] = $ < P ? z[$] : 255; + } + if (b == 4) + for (var B = 0; B < E; B++) + for (var U = B * L, F = B * p, t = 0; t < p; t++) { + var S = F + t << 2, $ = o[U + (t >> 1)] >> 4 - ((t & 1) << 2) & 15, W = 3 * $; + D[S] = R[W], D[S + 1] = R[W + 1], D[S + 2] = R[W + 2], D[S + 3] = $ < P ? z[$] : 255; + } + if (b == 8) + for (var t = 0; t < A; t++) { + var S = t << 2, $ = o[t], W = 3 * $; + D[S] = R[W], D[S + 1] = R[W + 1], D[S + 2] = R[W + 2], D[S + 3] = $ < P ? z[$] : 255; + } + } else if (n == 4) { + if (b == 8) + for (var t = 0; t < A; t++) { + var S = t << 2, N = t << 1, G = o[N]; + D[S] = G, D[S + 1] = G, D[S + 2] = G, D[S + 3] = o[N + 1]; + } + if (b == 16) + for (var t = 0; t < A; t++) { + var S = t << 2, N = t << 2, G = o[N]; + D[S] = G, D[S + 1] = G, D[S + 2] = G, D[S + 3] = o[N + 2]; + } + } else if (n == 0) { + var h = u.tabs.tRNS ? u.tabs.tRNS : -1; + if (b == 1) + for (var t = 0; t < A; t++) { + var G = 255 * (o[t >> 3] >> 7 - (t & 7) & 1), k = G == h * 255 ? 0 : 255; + r[t] = k << 24 | G << 16 | G << 8 | G; + } + if (b == 2) + for (var t = 0; t < A; t++) { + var G = 85 * (o[t >> 2] >> 6 - ((t & 3) << 1) & 3), k = G == h * 85 ? 0 : 255; + r[t] = k << 24 | G << 16 | G << 8 | G; + } + if (b == 4) + for (var t = 0; t < A; t++) { + var G = 17 * (o[t >> 1] >> 4 - ((t & 1) << 2) & 15), k = G == h * 17 ? 0 : 255; + r[t] = k << 24 | G << 16 | G << 8 | G; + } + if (b == 8) + for (var t = 0; t < A; t++) { + var G = o[t], k = G == h ? 0 : 255; + r[t] = k << 24 | G << 16 | G << 8 | G; + } + if (b == 16) + for (var t = 0; t < A; t++) { + var G = o[t << 1], k = f(o, t << 1) == h ? 0 : 255; + r[t] = k << 24 | G << 16 | G << 8 | G; + } + } + return D; + }, _.decode = function(o) { + for (var p = new Uint8Array(o), E = 8, u = _._bin, A = u.readUshort, C = u.readUint, L = { tabs: {}, frames: [] }, D = new Uint8Array(p.length), r = 0, n, b = 0, f = [137, 80, 78, 71, 13, 10, 26, 10], c = 0; c < 8; c++) + if (p[c] != f[c]) + throw "The input is not a PNG file!"; + for (; E < p.length; ) { + var t = u.readUint(p, E); + E += 4; + var a = u.readASCII(p, E, 4); + if (E += 4, a == "IHDR") + _.decode._IHDR(p, E, L); + else if (a == "IDAT") { + for (var c = 0; c < t; c++) + D[r + c] = p[E + c]; + r += t; + } else if (a == "acTL") + L.tabs[a] = { num_frames: C(p, E), num_plays: C(p, E + 4) }, n = new Uint8Array(p.length); + else if (a == "fcTL") { + if (b != 0) { + var h = L.frames[L.frames.length - 1]; + h.data = _.decode._decompress(L, n.slice(0, b), h.rect.width, h.rect.height), b = 0; + } + var M = { x: C(p, E + 12), y: C(p, E + 16), width: C(p, E + 4), height: C(p, E + 8) }, w = A(p, E + 22); + w = A(p, E + 20) / (w == 0 ? 100 : w); + var S = { rect: M, delay: Math.round(w * 1e3), dispose: p[E + 24], blend: p[E + 25] }; + L.frames.push(S); + } else if (a == "fdAT") { + for (var c = 0; c < t - 4; c++) + n[b + c] = p[E + c + 4]; + b += t - 4; + } else if (a == "pHYs") + L.tabs[a] = [u.readUint(p, E), u.readUint(p, E + 4), p[E + 8]]; + else if (a == "cHRM") { + L.tabs[a] = []; + for (var c = 0; c < 8; c++) + L.tabs[a].push(u.readUint(p, E + c * 4)); + } else if (a == "tEXt") { + L.tabs[a] == null && (L.tabs[a] = {}); + var T = u.nextZero(p, E), R = u.readASCII(p, E, T - E), z = u.readASCII(p, T + 1, E + t - T - 1); + L.tabs[a][R] = z; + } else if (a == "iTXt") { + L.tabs[a] == null && (L.tabs[a] = {}); + var T = 0, P = E; + T = u.nextZero(p, P); + var R = u.readASCII(p, P, T - P); + P = T + 1, p[P], p[P + 1], P += 2, T = u.nextZero(p, P), u.readASCII(p, P, T - P), P = T + 1, T = u.nextZero(p, P), u.readUTF8(p, P, T - P), P = T + 1; + var z = u.readUTF8(p, P, t - (P - E)); + L.tabs[a][R] = z; + } else if (a == "PLTE") + L.tabs[a] = u.readBytes(p, E, t); + else if (a == "hIST") { + var B = L.tabs.PLTE.length / 3; + L.tabs[a] = []; + for (var c = 0; c < B; c++) + L.tabs[a].push(A(p, E + c * 2)); + } else if (a == "tRNS") + L.ctype == 3 ? L.tabs[a] = u.readBytes(p, E, t) : L.ctype == 0 ? L.tabs[a] = A(p, E) : L.ctype == 2 && (L.tabs[a] = [A(p, E), A(p, E + 2), A(p, E + 4)]); + else if (a == "gAMA") + L.tabs[a] = u.readUint(p, E) / 1e5; + else if (a == "sRGB") + L.tabs[a] = p[E]; + else if (a == "bKGD") + L.ctype == 0 || L.ctype == 4 ? L.tabs[a] = [A(p, E)] : L.ctype == 2 || L.ctype == 6 ? L.tabs[a] = [A(p, E), A(p, E + 2), A(p, E + 4)] : L.ctype == 3 && (L.tabs[a] = p[E]); + else if (a == "IEND") { + if (b != 0) { + var h = L.frames[L.frames.length - 1]; + h.data = _.decode._decompress(L, n.slice(0, b), h.rect.width, h.rect.height), b = 0; + } + L.data = _.decode._decompress(L, D, L.width, L.height); + break; + } + E += t, u.readUint(p, E), E += 4; + } + return delete L.compress, delete L.interlace, delete L.filter, L; + }, _.decode._decompress = function(o, p, E, u) { + return o.compress == 0 && (p = _.decode._inflate(p)), o.interlace == 0 ? p = _.decode._filterZero(p, o, 0, E, u) : o.interlace == 1 && (p = _.decode._readInterlace(p, o)), p; + }, _.decode._inflate = function(o) { + return x.inflate(o); + }, _.decode._readInterlace = function(o, p) { + for (var E = p.width, u = p.height, A = _.decode._getBPP(p), C = A >> 3, L = Math.ceil(E * A / 8), D = new Uint8Array(u * L), r = 0, n = [0, 0, 4, 0, 2, 0, 1], b = [0, 4, 0, 2, 0, 1, 0], f = [8, 8, 8, 4, 4, 2, 2], c = [8, 8, 4, 4, 2, 2, 1], t = 0; t < 7; ) { + for (var a = f[t], h = c[t], M = 0, w = 0, S = n[t]; S < u; ) + S += a, w++; + for (var T = b[t]; T < E; ) + T += h, M++; + var R = Math.ceil(M * A / 8); + _.decode._filterZero(o, p, r, M, w); + for (var z = 0, P = n[t]; P < u; ) { + for (var B = b[t], U = r + z * R << 3; B < E; ) { + if (A == 1) { + var F = o[U >> 3]; + F = F >> 7 - (U & 7) & 1, D[P * L + (B >> 3)] |= F << 7 - ((B & 3) << 0); + } + if (A == 2) { + var F = o[U >> 3]; + F = F >> 6 - (U & 7) & 3, D[P * L + (B >> 2)] |= F << 6 - ((B & 3) << 1); + } + if (A == 4) { + var F = o[U >> 3]; + F = F >> 4 - (U & 7) & 15, D[P * L + (B >> 1)] |= F << 4 - ((B & 1) << 2); + } + if (A >= 8) + for (var $ = P * L + B * C, W = 0; W < C; W++) + D[$ + W] = o[(U >> 3) + W]; + U += A, B += h; + } + z++, P += a; + } + M * w != 0 && (r += w * (1 + R)), t = t + 1; + } + return D; + }, _.decode._getBPP = function(o) { + var p = [1, null, 3, 1, 2, null, 4][o.ctype]; + return p * o.depth; + }, _.decode._filterZero = function(o, p, E, u, A) { + var C = _.decode._getBPP(p), L = Math.ceil(u * C / 8), D = _.decode._paeth; + C = Math.ceil(C / 8); + for (var r = 0; r < A; r++) { + var n = E + r * L, b = n + r + 1, f = o[b - 1]; + if (f == 0) + for (var c = 0; c < L; c++) + o[n + c] = o[b + c]; + else if (f == 1) { + for (var c = 0; c < C; c++) + o[n + c] = o[b + c]; + for (var c = C; c < L; c++) + o[n + c] = o[b + c] + o[n + c - C] & 255; + } else if (r == 0) { + for (var c = 0; c < C; c++) + o[n + c] = o[b + c]; + if (f == 2) + for (var c = C; c < L; c++) + o[n + c] = o[b + c] & 255; + if (f == 3) + for (var c = C; c < L; c++) + o[n + c] = o[b + c] + (o[n + c - C] >> 1) & 255; + if (f == 4) + for (var c = C; c < L; c++) + o[n + c] = o[b + c] + D(o[n + c - C], 0, 0) & 255; + } else { + if (f == 2) + for (var c = 0; c < L; c++) + o[n + c] = o[b + c] + o[n + c - L] & 255; + if (f == 3) { + for (var c = 0; c < C; c++) + o[n + c] = o[b + c] + (o[n + c - L] >> 1) & 255; + for (var c = C; c < L; c++) + o[n + c] = o[b + c] + (o[n + c - L] + o[n + c - C] >> 1) & 255; + } + if (f == 4) { + for (var c = 0; c < C; c++) + o[n + c] = o[b + c] + D(0, o[n + c - L], 0) & 255; + for (var c = C; c < L; c++) + o[n + c] = o[b + c] + D(o[n + c - C], o[n + c - L], o[n + c - C - L]) & 255; + } + } + } + return o; + }, _.decode._paeth = function(o, p, E) { + var u = o + p - E, A = Math.abs(u - o), C = Math.abs(u - p), L = Math.abs(u - E); + return A <= C && A <= L ? o : C <= L ? p : E; + }, _.decode._IHDR = function(o, p, E) { + var u = _._bin; + E.width = u.readUint(o, p), p += 4, E.height = u.readUint(o, p), p += 4, E.depth = o[p], p++, E.ctype = o[p], p++, E.compress = o[p], p++, E.filter = o[p], p++, E.interlace = o[p], p++; + }, _._bin = { + nextZero: function(o, p) { + for (; o[p] != 0; ) + p++; + return p; + }, + readUshort: function(o, p) { + return o[p] << 8 | o[p + 1]; + }, + writeUshort: function(o, p, E) { + o[p] = E >> 8 & 255, o[p + 1] = E & 255; + }, + readUint: function(o, p) { + return o[p] * 16777216 + (o[p + 1] << 16 | o[p + 2] << 8 | o[p + 3]); + }, + writeUint: function(o, p, E) { + o[p] = E >> 24 & 255, o[p + 1] = E >> 16 & 255, o[p + 2] = E >> 8 & 255, o[p + 3] = E & 255; + }, + readASCII: function(o, p, E) { + for (var u = "", A = 0; A < E; A++) + u += String.fromCharCode(o[p + A]); + return u; + }, + writeASCII: function(o, p, E) { + for (var u = 0; u < E.length; u++) + o[p + u] = E.charCodeAt(u); + }, + readBytes: function(o, p, E) { + for (var u = [], A = 0; A < E; A++) + u.push(o[p + A]); + return u; + }, + pad: function(o) { + return o.length < 2 ? "0" + o : o; + }, + readUTF8: function(o, p, E) { + for (var u = "", A, C = 0; C < E; C++) + u += "%" + _._bin.pad(o[p + C].toString(16)); + try { + A = decodeURIComponent(u); + } catch { + return _._bin.readASCII(o, p, E); + } + return A; + } + }, _._copyTile = function(o, p, E, u, A, C, L, D, r) { + for (var n = Math.min(p, A), b = Math.min(E, C), f = 0, c = 0, t = 0; t < b; t++) + for (var a = 0; a < n; a++) + if (L >= 0 && D >= 0 ? (f = t * p + a << 2, c = (D + t) * A + L + a << 2) : (f = (-D + t) * p - L + a << 2, c = t * A + a << 2), r == 0) + u[c] = o[f], u[c + 1] = o[f + 1], u[c + 2] = o[f + 2], u[c + 3] = o[f + 3]; + else if (r == 1) { + var h = o[f + 3] * 0.00392156862745098, M = o[f] * h, w = o[f + 1] * h, S = o[f + 2] * h, T = u[c + 3] * (1 / 255), R = u[c] * T, z = u[c + 1] * T, P = u[c + 2] * T, B = 1 - h, U = h + T * B, F = U == 0 ? 0 : 1 / U; + u[c + 3] = 255 * U, u[c + 0] = (M + R * B) * F, u[c + 1] = (w + z * B) * F, u[c + 2] = (S + P * B) * F; + } else if (r == 2) { + var h = o[f + 3], M = o[f], w = o[f + 1], S = o[f + 2], T = u[c + 3], R = u[c], z = u[c + 1], P = u[c + 2]; + h == T && M == R && w == z && S == P ? (u[c] = 0, u[c + 1] = 0, u[c + 2] = 0, u[c + 3] = 0) : (u[c] = M, u[c + 1] = w, u[c + 2] = S, u[c + 3] = h); + } else if (r == 3) { + var h = o[f + 3], M = o[f], w = o[f + 1], S = o[f + 2], T = u[c + 3], R = u[c], z = u[c + 1], P = u[c + 2]; + if (h == T && M == R && w == z && S == P) + continue; + if (h < 220 && T > 20) + return !1; + } + return !0; + }, _.encode = function(o, p, E, u, A, C) { + u == null && (u = 0), C == null && (C = !1); + for (var L = new Uint8Array(o[0].byteLength * o.length + 100), D = [137, 80, 78, 71, 13, 10, 26, 10], r = 0; r < 8; r++) + L[r] = D[r]; + var n = 8, b = _._bin, f = _.crc.crc, c = b.writeUint, t = b.writeUshort, a = b.writeASCII, h = _.encode.compressPNG(o, p, E, u, C); + c(L, n, 13), n += 4, a(L, n, "IHDR"), n += 4, c(L, n, p), n += 4, c(L, n, E), n += 4, L[n] = h.depth, n++, L[n] = h.ctype, n++, L[n] = 0, n++, L[n] = 0, n++, L[n] = 0, n++, c(L, n, f(L, n - 17, 17)), n += 4, c(L, n, 1), n += 4, a(L, n, "sRGB"), n += 4, L[n] = 1, n++, c(L, n, f(L, n - 5, 5)), n += 4; + var M = o.length > 1; + if (M && (c(L, n, 8), n += 4, a(L, n, "acTL"), n += 4, c(L, n, o.length), n += 4, c(L, n, 0), n += 4, c(L, n, f(L, n - 12, 12)), n += 4), h.ctype == 3) { + var w = h.plte.length; + c(L, n, w * 3), n += 4, a(L, n, "PLTE"), n += 4; + for (var r = 0; r < w; r++) { + var S = r * 3, T = h.plte[r], R = T & 255, z = T >> 8 & 255, P = T >> 16 & 255; + L[n + S + 0] = R, L[n + S + 1] = z, L[n + S + 2] = P; + } + if (n += w * 3, c(L, n, f(L, n - w * 3 - 4, w * 3 + 4)), n += 4, h.gotAlpha) { + c(L, n, w), n += 4, a(L, n, "tRNS"), n += 4; + for (var r = 0; r < w; r++) + L[n + r] = h.plte[r] >> 24 & 255; + n += w, c(L, n, f(L, n - w - 4, w + 4)), n += 4; + } + } + for (var B = 0, U = 0; U < h.frames.length; U++) { + var F = h.frames[U]; + M && (c(L, n, 26), n += 4, a(L, n, "fcTL"), n += 4, c(L, n, B++), n += 4, c(L, n, F.rect.width), n += 4, c(L, n, F.rect.height), n += 4, c(L, n, F.rect.x), n += 4, c(L, n, F.rect.y), n += 4, t(L, n, A[U]), n += 2, t(L, n, 1e3), n += 2, L[n] = F.dispose, n++, L[n] = F.blend, n++, c(L, n, f(L, n - 30, 30)), n += 4); + var $ = F.cimg, w = $.length; + c(L, n, w + (U == 0 ? 0 : 4)), n += 4; + var W = n; + a(L, n, U == 0 ? "IDAT" : "fdAT"), n += 4, U != 0 && (c(L, n, B++), n += 4); + for (var r = 0; r < w; r++) + L[n + r] = $[r]; + n += w, c(L, n, f(L, W, n - W)), n += 4; + } + return c(L, n, 0), n += 4, a(L, n, "IEND"), n += 4, c(L, n, f(L, n - 4, 4)), n += 4, L.buffer.slice(0, n); + }, _.encode.compressPNG = function(o, p, E, u, A) { + for (var C = _.encode.compress(o, p, E, u, !1, A), L = 0; L < o.length; L++) { + var D = C.frames[L]; + D.rect.width; + var r = D.rect.height, n = D.bpl, b = D.bpp, f = new Uint8Array(r * n + r); + D.cimg = _.encode._filterZero(D.img, r, b, n, f); + } + return C; + }, _.encode.compress = function(o, p, E, u, A, C) { + C == null && (C = !1); + for (var L = 6, D = 8, r = 4, n = 255, b = 0; b < o.length; b++) + for (var f = new Uint8Array(o[b]), c = f.length, t = 0; t < c; t += 4) + n &= f[t + 3]; + var a = n != 255, h = {}, M = []; + if (o.length != 0 && (h[0] = 0, M.push(0), u != 0 && u--), u != 0) { + var w = _.quantize(o, u, A); + o = w.bufs; + for (var t = 0; t < w.plte.length; t++) { + var S = w.plte[t].est.rgba; + h[S] == null && (h[S] = M.length, M.push(S)); + } + } else + for (var b = 0; b < o.length; b++) + for (var T = new Uint32Array(o[b]), c = T.length, t = 0; t < c; t++) { + var S = T[t]; + if ((t < p || S != T[t - 1] && S != T[t - p]) && h[S] == null && (h[S] = M.length, M.push(S), M.length >= 300)) + break; + } + var R = a ? A : !1, z = M.length; + z <= 256 && C == !1 && (z <= 2 ? D = 1 : z <= 4 ? D = 2 : z <= 16 ? D = 4 : D = 8, A && (D = 8), a = !0); + for (var P = [], b = 0; b < o.length; b++) { + var B = new Uint8Array(o[b]), U = new Uint32Array(B.buffer), F = 0, $ = 0, W = p, N = E, G = 0; + if (b != 0 && !R) { + for (var k = A || b == 1 || P[P.length - 2].dispose == 2 ? 1 : 2, j = 0, Q = 1e9, ie = 0; ie < k; ie++) { + for (var oe = new Uint8Array(o[b - 1 - ie]), pe = new Uint32Array(o[b - 1 - ie]), he = p, ue = E, se = -1, ae = -1, we = 0; we < E; we++) + for (var xe = 0; xe < p; xe++) { + var t = we * p + xe; + U[t] != pe[t] && (xe < he && (he = xe), xe > se && (se = xe), we < ue && (ue = we), we > ae && (ae = we)); + } + var Ie = se == -1 ? 1 : (se - he + 1) * (ae - ue + 1); + Ie < Q && (Q = Ie, j = ie, se == -1 ? (F = $ = 0, W = N = 1) : (F = he, $ = ue, W = se - he + 1, N = ae - ue + 1)); + } + var oe = new Uint8Array(o[b - 1 - j]); + j == 1 && (P[P.length - 1].dispose = 2); + var ve = new Uint8Array(W * N * 4); + new Uint32Array(ve.buffer), _._copyTile(oe, p, E, ve, W, N, -F, -$, 0), _._copyTile(B, p, E, ve, W, N, -F, -$, 3) ? (_._copyTile(B, p, E, ve, W, N, -F, -$, 2), G = 1) : (_._copyTile(B, p, E, ve, W, N, -F, -$, 0), G = 0), B = ve, U = new Uint32Array(B.buffer); + } + var re = 4 * W; + if (z <= 256 && C == !1) { + re = Math.ceil(D * W / 8); + for (var ve = new Uint8Array(re * N), we = 0; we < N; we++) { + var t = we * re, Se = we * W; + if (D == 8) + for (var xe = 0; xe < W; xe++) + ve[t + xe] = h[U[Se + xe]]; + else if (D == 4) + for (var xe = 0; xe < W; xe++) + ve[t + (xe >> 1)] |= h[U[Se + xe]] << 4 - (xe & 1) * 4; + else if (D == 2) + for (var xe = 0; xe < W; xe++) + ve[t + (xe >> 2)] |= h[U[Se + xe]] << 6 - (xe & 3) * 2; + else if (D == 1) + for (var xe = 0; xe < W; xe++) + ve[t + (xe >> 3)] |= h[U[Se + xe]] << 7 - (xe & 7) * 1; + } + B = ve, L = 3, r = 1; + } else if (a == !1 && o.length == 1) { + for (var ve = new Uint8Array(W * N * 3), ze = W * N, t = 0; t < ze; t++) { + var Ge = t * 3, $e = t * 4; + ve[Ge] = B[$e], ve[Ge + 1] = B[$e + 1], ve[Ge + 2] = B[$e + 2]; + } + B = ve, L = 2, r = 3, re = 3 * W; + } + P.push({ rect: { x: F, y: $, width: W, height: N }, img: B, bpl: re, bpp: r, blend: G, dispose: R ? 1 : 0 }); + } + return { ctype: L, depth: D, plte: M, gotAlpha: a, frames: P }; + }, _.encode._filterZero = function(o, p, E, u, A) { + for (var C = [], L = 0; L < 5; L++) + if (!(p * u > 5e5 && (L == 2 || L == 3 || L == 4))) { + for (var D = 0; D < p; D++) + _.encode._filterLine(A, o, D, u, E, L); + if (C.push(x.deflate(A)), E == 1) + break; + } + for (var r, n = 1e9, b = 0; b < C.length; b++) + C[b].length < n && (r = b, n = C[b].length); + return C[r]; + }, _.encode._filterLine = function(o, p, E, u, A, C) { + var L = E * u, D = L + E, r = _.decode._paeth; + if (o[D] = C, D++, C == 0) + for (var n = 0; n < u; n++) + o[D + n] = p[L + n]; + else if (C == 1) { + for (var n = 0; n < A; n++) + o[D + n] = p[L + n]; + for (var n = A; n < u; n++) + o[D + n] = p[L + n] - p[L + n - A] + 256 & 255; + } else if (E == 0) { + for (var n = 0; n < A; n++) + o[D + n] = p[L + n]; + if (C == 2) + for (var n = A; n < u; n++) + o[D + n] = p[L + n]; + if (C == 3) + for (var n = A; n < u; n++) + o[D + n] = p[L + n] - (p[L + n - A] >> 1) + 256 & 255; + if (C == 4) + for (var n = A; n < u; n++) + o[D + n] = p[L + n] - r(p[L + n - A], 0, 0) + 256 & 255; + } else { + if (C == 2) + for (var n = 0; n < u; n++) + o[D + n] = p[L + n] + 256 - p[L + n - u] & 255; + if (C == 3) { + for (var n = 0; n < A; n++) + o[D + n] = p[L + n] + 256 - (p[L + n - u] >> 1) & 255; + for (var n = A; n < u; n++) + o[D + n] = p[L + n] + 256 - (p[L + n - u] + p[L + n - A] >> 1) & 255; + } + if (C == 4) { + for (var n = 0; n < A; n++) + o[D + n] = p[L + n] + 256 - r(0, p[L + n - u], 0) & 255; + for (var n = A; n < u; n++) + o[D + n] = p[L + n] + 256 - r(p[L + n - A], p[L + n - u], p[L + n - A - u]) & 255; + } + } + }, _.crc = { + table: function() { + for (var o = new Uint32Array(256), p = 0; p < 256; p++) { + for (var E = p, u = 0; u < 8; u++) + E & 1 ? E = 3988292384 ^ E >>> 1 : E = E >>> 1; + o[p] = E; + } + return o; + }(), + update: function(o, p, E, u) { + for (var A = 0; A < u; A++) + o = _.crc.table[(o ^ p[E + A]) & 255] ^ o >>> 8; + return o; + }, + crc: function(o, p, E) { + return _.crc.update(4294967295, o, p, E) ^ 4294967295; + } + }, _.quantize = function(o, p, E) { + for (var u = [], A = 0, C = 0; C < o.length; C++) + u.push(_.encode.alphaMul(new Uint8Array(o[C]), E)), A += o[C].byteLength; + for (var L = new Uint8Array(A), D = new Uint32Array(L.buffer), r = 0, C = 0; C < u.length; C++) { + for (var n = u[C], b = n.length, f = 0; f < b; f++) + L[r + f] = n[f]; + r += b; + } + var c = { i0: 0, i1: L.length, bst: null, est: null, tdst: 0, left: null, right: null }; + c.bst = _.quantize.stats(L, c.i0, c.i1), c.est = _.quantize.estats(c.bst); + for (var t = [c]; t.length < p; ) { + for (var a = 0, h = 0, C = 0; C < t.length; C++) + t[C].est.L > a && (a = t[C].est.L, h = C); + if (a < 1e-3) + break; + var M = t[h], w = _.quantize.splitPixels(L, D, M.i0, M.i1, M.est.e, M.est.eMq255), S = { i0: M.i0, i1: w, bst: null, est: null, tdst: 0, left: null, right: null }; + S.bst = _.quantize.stats(L, S.i0, S.i1), S.est = _.quantize.estats(S.bst); + var T = { i0: w, i1: M.i1, bst: null, est: null, tdst: 0, left: null, right: null }; + T.bst = { R: [], m: [], N: M.bst.N - S.bst.N }; + for (var C = 0; C < 16; C++) + T.bst.R[C] = M.bst.R[C] - S.bst.R[C]; + for (var C = 0; C < 4; C++) + T.bst.m[C] = M.bst.m[C] - S.bst.m[C]; + T.est = _.quantize.estats(T.bst), M.left = S, M.right = T, t[h] = S, t.push(T); + } + t.sort(function(k, j) { + return j.bst.N - k.bst.N; + }); + for (var R = 0; R < u.length; R++) { + for (var z = _.quantize.planeDst, P = new Uint8Array(u[R].buffer), B = new Uint32Array(u[R].buffer), U = P.length, C = 0; C < U; C += 4) { + for (var F = P[C] * 0.00392156862745098, $ = P[C + 1] * (1 / 255), W = P[C + 2] * (1 / 255), N = P[C + 3] * (1 / 255), G = c; G.left; ) + G = z(G.est, F, $, W, N) <= 0 ? G.left : G.right; + B[C >> 2] = G.est.rgba; + } + u[R] = B.buffer; + } + return { bufs: u, plte: t }; + }, _.quantize.getNearest = function(o, p, E, u, A) { + if (o.left == null) + return o.tdst = _.quantize.dist(o.est.q, p, E, u, A), o; + var C = _.quantize.planeDst(o.est, p, E, u, A), L = o.left, D = o.right; + C > 0 && (L = o.right, D = o.left); + var r = _.quantize.getNearest(L, p, E, u, A); + if (r.tdst <= C * C) + return r; + var n = _.quantize.getNearest(D, p, E, u, A); + return n.tdst < r.tdst ? n : r; + }, _.quantize.planeDst = function(o, p, E, u, A) { + var C = o.e; + return C[0] * p + C[1] * E + C[2] * u + C[3] * A - o.eMq; + }, _.quantize.dist = function(o, p, E, u, A) { + var C = p - o[0], L = E - o[1], D = u - o[2], r = A - o[3]; + return C * C + L * L + D * D + r * r; + }, _.quantize.splitPixels = function(o, p, E, u, A, C) { + var L = _.quantize.vecDot; + for (u -= 4; E < u; ) { + for (; L(o, E, A) <= C; ) + E += 4; + for (; L(o, u, A) > C; ) + u -= 4; + if (E >= u) + break; + var D = p[E >> 2]; + p[E >> 2] = p[u >> 2], p[u >> 2] = D, E += 4, u -= 4; + } + for (; L(o, E, A) > C; ) + E -= 4; + return E + 4; + }, _.quantize.vecDot = function(o, p, E) { + return o[p] * E[0] + o[p + 1] * E[1] + o[p + 2] * E[2] + o[p + 3] * E[3]; + }, _.quantize.stats = function(o, p, E) { + for (var u = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], A = [0, 0, 0, 0], C = E - p >> 2, L = p; L < E; L += 4) { + var D = o[L] * 0.00392156862745098, r = o[L + 1] * (1 / 255), n = o[L + 2] * (1 / 255), b = o[L + 3] * (1 / 255); + A[0] += D, A[1] += r, A[2] += n, A[3] += b, u[0] += D * D, u[1] += D * r, u[2] += D * n, u[3] += D * b, u[5] += r * r, u[6] += r * n, u[7] += r * b, u[10] += n * n, u[11] += n * b, u[15] += b * b; + } + return u[4] = u[1], u[8] = u[2], u[12] = u[3], u[9] = u[6], u[13] = u[7], u[14] = u[11], { R: u, m: A, N: C }; + }, _.quantize.estats = function(o) { + var p = o.R, E = o.m, u = o.N, A = E[0], C = E[1], L = E[2], D = E[3], r = u == 0 ? 0 : 1 / u, n = [ + p[0] - A * A * r, + p[1] - A * C * r, + p[2] - A * L * r, + p[3] - A * D * r, + p[4] - C * A * r, + p[5] - C * C * r, + p[6] - C * L * r, + p[7] - C * D * r, + p[8] - L * A * r, + p[9] - L * C * r, + p[10] - L * L * r, + p[11] - L * D * r, + p[12] - D * A * r, + p[13] - D * C * r, + p[14] - D * L * r, + p[15] - D * D * r + ], b = n, f = _.M4, c = [0.5, 0.5, 0.5, 0.5], t = 0, a = 0; + if (u != 0) + for (var h = 0; h < 10 && (c = f.multVec(b, c), a = Math.sqrt(f.dot(c, c)), c = f.sml(1 / a, c), !(Math.abs(a - t) < 1e-9)); h++) + t = a; + var M = [A * r, C * r, L * r, D * r], w = f.dot(f.sml(255, M), c), S = M[3] < 1e-3 ? 0 : 1 / M[3]; + return { + Cov: n, + q: M, + e: c, + L: t, + eMq255: w, + eMq: f.dot(c, M), + rgba: (Math.round(255 * M[3]) << 24 | Math.round(255 * M[2] * S) << 16 | Math.round(255 * M[1] * S) << 8 | Math.round(255 * M[0] * S) << 0) >>> 0 + }; + }, _.M4 = { + multVec: function(o, p) { + return [ + o[0] * p[0] + o[1] * p[1] + o[2] * p[2] + o[3] * p[3], + o[4] * p[0] + o[5] * p[1] + o[6] * p[2] + o[7] * p[3], + o[8] * p[0] + o[9] * p[1] + o[10] * p[2] + o[11] * p[3], + o[12] * p[0] + o[13] * p[1] + o[14] * p[2] + o[15] * p[3] + ]; + }, + dot: function(o, p) { + return o[0] * p[0] + o[1] * p[1] + o[2] * p[2] + o[3] * p[3]; + }, + sml: function(o, p) { + return [o * p[0], o * p[1], o * p[2], o * p[3]]; + } + }, _.encode.alphaMul = function(o, p) { + for (var E = new Uint8Array(o.length), u = o.length >> 2, A = 0; A < u; A++) { + var C = A << 2, L = o[C + 3]; + p && (L = L < 128 ? 0 : 255); + var D = L * (1 / 255); + E[C + 0] = o[C + 0] * D, E[C + 1] = o[C + 1] * D, E[C + 2] = o[C + 2] * D, E[C + 3] = L; + } + return E; + }; + }(l, g); + })(); + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/index.js": ( + /*!*********************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/index.js ***! + \*********************************************************/ + /***/ + (y, s, e) => { + var l = e( + /*! ./lib/utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ).assign, g = e( + /*! ./lib/deflate */ + "./node_modules/upng-js/node_modules/pako/lib/deflate.js" + ), _ = e( + /*! ./lib/inflate */ + "./node_modules/upng-js/node_modules/pako/lib/inflate.js" + ), x = e( + /*! ./lib/zlib/constants */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js" + ), o = {}; + l(o, g, _, x), y.exports = o; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/deflate.js": ( + /*!***************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/deflate.js ***! + \***************************************************************/ + /***/ + (y, s, e) => { + var l = e( + /*! ./zlib/deflate */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js" + ), g = e( + /*! ./utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), _ = e( + /*! ./utils/strings */ + "./node_modules/upng-js/node_modules/pako/lib/utils/strings.js" + ), x = e( + /*! ./zlib/messages */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js" + ), o = e( + /*! ./zlib/zstream */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js" + ), p = Object.prototype.toString, E = 0, u = 4, A = 0, C = 1, L = 2, D = -1, r = 0, n = 8; + function b(a) { + if (!(this instanceof b)) + return new b(a); + this.options = g.assign({ + level: D, + method: n, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: r, + to: "" + }, a || {}); + var h = this.options; + h.raw && h.windowBits > 0 ? h.windowBits = -h.windowBits : h.gzip && h.windowBits > 0 && h.windowBits < 16 && (h.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new o(), this.strm.avail_out = 0; + var M = l.deflateInit2( + this.strm, + h.level, + h.method, + h.windowBits, + h.memLevel, + h.strategy + ); + if (M !== A) + throw new Error(x[M]); + if (h.header && l.deflateSetHeader(this.strm, h.header), h.dictionary) { + var w; + if (typeof h.dictionary == "string" ? w = _.string2buf(h.dictionary) : p.call(h.dictionary) === "[object ArrayBuffer]" ? w = new Uint8Array(h.dictionary) : w = h.dictionary, M = l.deflateSetDictionary(this.strm, w), M !== A) + throw new Error(x[M]); + this._dict_set = !0; + } + } + b.prototype.push = function(a, h) { + var M = this.strm, w = this.options.chunkSize, S, T; + if (this.ended) + return !1; + T = h === ~~h ? h : h === !0 ? u : E, typeof a == "string" ? M.input = _.string2buf(a) : p.call(a) === "[object ArrayBuffer]" ? M.input = new Uint8Array(a) : M.input = a, M.next_in = 0, M.avail_in = M.input.length; + do { + if (M.avail_out === 0 && (M.output = new g.Buf8(w), M.next_out = 0, M.avail_out = w), S = l.deflate(M, T), S !== C && S !== A) + return this.onEnd(S), this.ended = !0, !1; + (M.avail_out === 0 || M.avail_in === 0 && (T === u || T === L)) && (this.options.to === "string" ? this.onData(_.buf2binstring(g.shrinkBuf(M.output, M.next_out))) : this.onData(g.shrinkBuf(M.output, M.next_out))); + } while ((M.avail_in > 0 || M.avail_out === 0) && S !== C); + return T === u ? (S = l.deflateEnd(this.strm), this.onEnd(S), this.ended = !0, S === A) : (T === L && (this.onEnd(A), M.avail_out = 0), !0); + }, b.prototype.onData = function(a) { + this.chunks.push(a); + }, b.prototype.onEnd = function(a) { + a === A && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = g.flattenChunks(this.chunks)), this.chunks = [], this.err = a, this.msg = this.strm.msg; + }; + function f(a, h) { + var M = new b(h); + if (M.push(a, !0), M.err) + throw M.msg || x[M.err]; + return M.result; + } + function c(a, h) { + return h = h || {}, h.raw = !0, f(a, h); + } + function t(a, h) { + return h = h || {}, h.gzip = !0, f(a, h); + } + s.Deflate = b, s.deflate = f, s.deflateRaw = c, s.gzip = t; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/inflate.js": ( + /*!***************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/inflate.js ***! + \***************************************************************/ + /***/ + (y, s, e) => { + var l = e( + /*! ./zlib/inflate */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inflate.js" + ), g = e( + /*! ./utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), _ = e( + /*! ./utils/strings */ + "./node_modules/upng-js/node_modules/pako/lib/utils/strings.js" + ), x = e( + /*! ./zlib/constants */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js" + ), o = e( + /*! ./zlib/messages */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js" + ), p = e( + /*! ./zlib/zstream */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js" + ), E = e( + /*! ./zlib/gzheader */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/gzheader.js" + ), u = Object.prototype.toString; + function A(D) { + if (!(this instanceof A)) + return new A(D); + this.options = g.assign({ + chunkSize: 16384, + windowBits: 0, + to: "" + }, D || {}); + var r = this.options; + r.raw && r.windowBits >= 0 && r.windowBits < 16 && (r.windowBits = -r.windowBits, r.windowBits === 0 && (r.windowBits = -15)), r.windowBits >= 0 && r.windowBits < 16 && !(D && D.windowBits) && (r.windowBits += 32), r.windowBits > 15 && r.windowBits < 48 && (r.windowBits & 15 || (r.windowBits |= 15)), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new p(), this.strm.avail_out = 0; + var n = l.inflateInit2( + this.strm, + r.windowBits + ); + if (n !== x.Z_OK) + throw new Error(o[n]); + if (this.header = new E(), l.inflateGetHeader(this.strm, this.header), r.dictionary && (typeof r.dictionary == "string" ? r.dictionary = _.string2buf(r.dictionary) : u.call(r.dictionary) === "[object ArrayBuffer]" && (r.dictionary = new Uint8Array(r.dictionary)), r.raw && (n = l.inflateSetDictionary(this.strm, r.dictionary), n !== x.Z_OK))) + throw new Error(o[n]); + } + A.prototype.push = function(D, r) { + var n = this.strm, b = this.options.chunkSize, f = this.options.dictionary, c, t, a, h, M, w = !1; + if (this.ended) + return !1; + t = r === ~~r ? r : r === !0 ? x.Z_FINISH : x.Z_NO_FLUSH, typeof D == "string" ? n.input = _.binstring2buf(D) : u.call(D) === "[object ArrayBuffer]" ? n.input = new Uint8Array(D) : n.input = D, n.next_in = 0, n.avail_in = n.input.length; + do { + if (n.avail_out === 0 && (n.output = new g.Buf8(b), n.next_out = 0, n.avail_out = b), c = l.inflate(n, x.Z_NO_FLUSH), c === x.Z_NEED_DICT && f && (c = l.inflateSetDictionary(this.strm, f)), c === x.Z_BUF_ERROR && w === !0 && (c = x.Z_OK, w = !1), c !== x.Z_STREAM_END && c !== x.Z_OK) + return this.onEnd(c), this.ended = !0, !1; + n.next_out && (n.avail_out === 0 || c === x.Z_STREAM_END || n.avail_in === 0 && (t === x.Z_FINISH || t === x.Z_SYNC_FLUSH)) && (this.options.to === "string" ? (a = _.utf8border(n.output, n.next_out), h = n.next_out - a, M = _.buf2string(n.output, a), n.next_out = h, n.avail_out = b - h, h && g.arraySet(n.output, n.output, a, h, 0), this.onData(M)) : this.onData(g.shrinkBuf(n.output, n.next_out))), n.avail_in === 0 && n.avail_out === 0 && (w = !0); + } while ((n.avail_in > 0 || n.avail_out === 0) && c !== x.Z_STREAM_END); + return c === x.Z_STREAM_END && (t = x.Z_FINISH), t === x.Z_FINISH ? (c = l.inflateEnd(this.strm), this.onEnd(c), this.ended = !0, c === x.Z_OK) : (t === x.Z_SYNC_FLUSH && (this.onEnd(x.Z_OK), n.avail_out = 0), !0); + }, A.prototype.onData = function(D) { + this.chunks.push(D); + }, A.prototype.onEnd = function(D) { + D === x.Z_OK && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = g.flattenChunks(this.chunks)), this.chunks = [], this.err = D, this.msg = this.strm.msg; + }; + function C(D, r) { + var n = new A(r); + if (n.push(D, !0), n.err) + throw n.msg || o[n.err]; + return n.result; + } + function L(D, r) { + return r = r || {}, r.raw = !0, C(D, r); + } + s.Inflate = A, s.inflate = C, s.inflateRaw = L, s.ungzip = C; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/utils/common.js ***! + \********************************************************************/ + /***/ + (y, s) => { + var e = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Int32Array < "u"; + function l(x, o) { + return Object.prototype.hasOwnProperty.call(x, o); + } + s.assign = function(x) { + for (var o = Array.prototype.slice.call(arguments, 1); o.length; ) { + var p = o.shift(); + if (p) { + if (typeof p != "object") + throw new TypeError(p + "must be non-object"); + for (var E in p) + l(p, E) && (x[E] = p[E]); + } + } + return x; + }, s.shrinkBuf = function(x, o) { + return x.length === o ? x : x.subarray ? x.subarray(0, o) : (x.length = o, x); + }; + var g = { + arraySet: function(x, o, p, E, u) { + if (o.subarray && x.subarray) { + x.set(o.subarray(p, p + E), u); + return; + } + for (var A = 0; A < E; A++) + x[u + A] = o[p + A]; + }, + // Join array of chunks to single array. + flattenChunks: function(x) { + var o, p, E, u, A, C; + for (E = 0, o = 0, p = x.length; o < p; o++) + E += x[o].length; + for (C = new Uint8Array(E), u = 0, o = 0, p = x.length; o < p; o++) + A = x[o], C.set(A, u), u += A.length; + return C; + } + }, _ = { + arraySet: function(x, o, p, E, u) { + for (var A = 0; A < E; A++) + x[u + A] = o[p + A]; + }, + // Join array of chunks to single array. + flattenChunks: function(x) { + return [].concat.apply([], x); + } + }; + s.setTyped = function(x) { + x ? (s.Buf8 = Uint8Array, s.Buf16 = Uint16Array, s.Buf32 = Int32Array, s.assign(s, g)) : (s.Buf8 = Array, s.Buf16 = Array, s.Buf32 = Array, s.assign(s, _)); + }, s.setTyped(e); + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/utils/strings.js": ( + /*!*********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/utils/strings.js ***! + \*********************************************************************/ + /***/ + (y, s, e) => { + var l = e( + /*! ./common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), g = !0, _ = !0; + try { + String.fromCharCode.apply(null, [0]); + } catch { + g = !1; + } + try { + String.fromCharCode.apply(null, new Uint8Array(1)); + } catch { + _ = !1; + } + for (var x = new l.Buf8(256), o = 0; o < 256; o++) + x[o] = o >= 252 ? 6 : o >= 248 ? 5 : o >= 240 ? 4 : o >= 224 ? 3 : o >= 192 ? 2 : 1; + x[254] = x[254] = 1, s.string2buf = function(E) { + var u, A, C, L, D, r = E.length, n = 0; + for (L = 0; L < r; L++) + A = E.charCodeAt(L), (A & 64512) === 55296 && L + 1 < r && (C = E.charCodeAt(L + 1), (C & 64512) === 56320 && (A = 65536 + (A - 55296 << 10) + (C - 56320), L++)), n += A < 128 ? 1 : A < 2048 ? 2 : A < 65536 ? 3 : 4; + for (u = new l.Buf8(n), D = 0, L = 0; D < n; L++) + A = E.charCodeAt(L), (A & 64512) === 55296 && L + 1 < r && (C = E.charCodeAt(L + 1), (C & 64512) === 56320 && (A = 65536 + (A - 55296 << 10) + (C - 56320), L++)), A < 128 ? u[D++] = A : A < 2048 ? (u[D++] = 192 | A >>> 6, u[D++] = 128 | A & 63) : A < 65536 ? (u[D++] = 224 | A >>> 12, u[D++] = 128 | A >>> 6 & 63, u[D++] = 128 | A & 63) : (u[D++] = 240 | A >>> 18, u[D++] = 128 | A >>> 12 & 63, u[D++] = 128 | A >>> 6 & 63, u[D++] = 128 | A & 63); + return u; + }; + function p(E, u) { + if (u < 65534 && (E.subarray && _ || !E.subarray && g)) + return String.fromCharCode.apply(null, l.shrinkBuf(E, u)); + for (var A = "", C = 0; C < u; C++) + A += String.fromCharCode(E[C]); + return A; + } + s.buf2binstring = function(E) { + return p(E, E.length); + }, s.binstring2buf = function(E) { + for (var u = new l.Buf8(E.length), A = 0, C = u.length; A < C; A++) + u[A] = E.charCodeAt(A); + return u; + }, s.buf2string = function(E, u) { + var A, C, L, D, r = u || E.length, n = new Array(r * 2); + for (C = 0, A = 0; A < r; ) { + if (L = E[A++], L < 128) { + n[C++] = L; + continue; + } + if (D = x[L], D > 4) { + n[C++] = 65533, A += D - 1; + continue; + } + for (L &= D === 2 ? 31 : D === 3 ? 15 : 7; D > 1 && A < r; ) + L = L << 6 | E[A++] & 63, D--; + if (D > 1) { + n[C++] = 65533; + continue; + } + L < 65536 ? n[C++] = L : (L -= 65536, n[C++] = 55296 | L >> 10 & 1023, n[C++] = 56320 | L & 1023); + } + return p(n, C); + }, s.utf8border = function(E, u) { + var A; + for (u = u || E.length, u > E.length && (u = E.length), A = u - 1; A >= 0 && (E[A] & 192) === 128; ) + A--; + return A < 0 || A === 0 ? u : A + x[E[A]] > u ? A : u; + }; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js ***! + \********************************************************************/ + /***/ + (y) => { + function s(e, l, g, _) { + for (var x = e & 65535 | 0, o = e >>> 16 & 65535 | 0, p = 0; g !== 0; ) { + p = g > 2e3 ? 2e3 : g, g -= p; + do + x = x + l[_++] | 0, o = o + x | 0; + while (--p); + x %= 65521, o %= 65521; + } + return x | o << 16 | 0; + } + y.exports = s; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js": ( + /*!**********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/constants.js ***! + \**********************************************************************/ + /***/ + (y) => { + y.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 ***! + \******************************************************************/ + /***/ + (y) => { + function s() { + for (var g, _ = [], x = 0; x < 256; x++) { + g = x; + for (var o = 0; o < 8; o++) + g = g & 1 ? 3988292384 ^ g >>> 1 : g >>> 1; + _[x] = g; + } + return _; + } + var e = s(); + function l(g, _, x, o) { + var p = e, E = o + x; + g ^= -1; + for (var u = o; u < E; u++) + g = g >>> 8 ^ p[(g ^ _[u]) & 255]; + return g ^ -1; + } + y.exports = l; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/deflate.js ***! + \********************************************************************/ + /***/ + (y, s, e) => { + var l = e( + /*! ../utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), g = e( + /*! ./trees */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/trees.js" + ), _ = e( + /*! ./adler32 */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js" + ), x = e( + /*! ./crc32 */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js" + ), o = e( + /*! ./messages */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js" + ), p = 0, E = 1, u = 3, A = 4, C = 5, L = 0, D = 1, r = -2, n = -3, b = -5, f = -1, c = 1, t = 2, a = 3, h = 4, M = 0, w = 2, S = 8, T = 9, R = 15, z = 8, P = 29, B = 256, U = B + 1 + P, F = 30, $ = 19, W = 2 * U + 1, N = 15, G = 3, k = 258, j = k + G + 1, Q = 32, ie = 42, pe = 69, he = 73, ue = 91, se = 103, ae = 113, we = 666, xe = 1, Ie = 2, oe = 3, ve = 4, re = 3; + function Se(I, me) { + return I.msg = o[me], me; + } + function ze(I) { + return (I << 1) - (I > 4 ? 9 : 0); + } + function Ge(I) { + for (var me = I.length; --me >= 0; ) + I[me] = 0; + } + function $e(I) { + var me = I.state, ge = me.pending; + ge > I.avail_out && (ge = I.avail_out), ge !== 0 && (l.arraySet(I.output, me.pending_buf, me.pending_out, ge, I.next_out), I.next_out += ge, me.pending_out += ge, I.total_out += ge, I.avail_out -= ge, me.pending -= ge, me.pending === 0 && (me.pending_out = 0)); + } + function Re(I, me) { + g._tr_flush_block(I, I.block_start >= 0 ? I.block_start : -1, I.strstart - I.block_start, me), I.block_start = I.strstart, $e(I.strm); + } + function Be(I, me) { + I.pending_buf[I.pending++] = me; + } + function ke(I, me) { + I.pending_buf[I.pending++] = me >>> 8 & 255, I.pending_buf[I.pending++] = me & 255; + } + function We(I, me, ge, Y) { + var ne = I.avail_in; + return ne > Y && (ne = Y), ne === 0 ? 0 : (I.avail_in -= ne, l.arraySet(me, I.input, I.next_in, ne, ge), I.state.wrap === 1 ? I.adler = _(I.adler, me, ne, ge) : I.state.wrap === 2 && (I.adler = x(I.adler, me, ne, ge)), I.next_in += ne, I.total_in += ne, ne); + } + function Te(I, me) { + var ge = I.max_chain_length, Y = I.strstart, ne, Ee, He = I.prev_length, Ke = I.nice_match, Ve = I.strstart > I.w_size - j ? I.strstart - (I.w_size - j) : 0, qe = I.window, wt = I.w_mask, nt = I.prev, rt = I.strstart + k, tt = qe[Y + He - 1], yt = qe[Y + He]; + I.prev_length >= I.good_match && (ge >>= 2), Ke > I.lookahead && (Ke = I.lookahead); + do + if (ne = me, !(qe[ne + He] !== yt || qe[ne + He - 1] !== tt || qe[ne] !== qe[Y] || qe[++ne] !== qe[Y + 1])) { + Y += 2, ne++; + do + ; + while (qe[++Y] === qe[++ne] && qe[++Y] === qe[++ne] && qe[++Y] === qe[++ne] && qe[++Y] === qe[++ne] && qe[++Y] === qe[++ne] && qe[++Y] === qe[++ne] && qe[++Y] === qe[++ne] && qe[++Y] === qe[++ne] && Y < rt); + if (Ee = k - (rt - Y), Y = rt - k, Ee > He) { + if (I.match_start = me, He = Ee, Ee >= Ke) + break; + tt = qe[Y + He - 1], yt = qe[Y + He]; + } + } + while ((me = nt[me & wt]) > Ve && --ge !== 0); + return He <= I.lookahead ? He : I.lookahead; + } + function je(I) { + var me = I.w_size, ge, Y, ne, Ee, He; + do { + if (Ee = I.window_size - I.lookahead - I.strstart, I.strstart >= me + (me - j)) { + l.arraySet(I.window, I.window, me, me, 0), I.match_start -= me, I.strstart -= me, I.block_start -= me, Y = I.hash_size, ge = Y; + do + ne = I.head[--ge], I.head[ge] = ne >= me ? ne - me : 0; + while (--Y); + Y = me, ge = Y; + do + ne = I.prev[--ge], I.prev[ge] = ne >= me ? ne - me : 0; + while (--Y); + Ee += me; + } + if (I.strm.avail_in === 0) + break; + if (Y = We(I.strm, I.window, I.strstart + I.lookahead, Ee), I.lookahead += Y, I.lookahead + I.insert >= G) + for (He = I.strstart - I.insert, I.ins_h = I.window[He], I.ins_h = (I.ins_h << I.hash_shift ^ I.window[He + 1]) & I.hash_mask; I.insert && (I.ins_h = (I.ins_h << I.hash_shift ^ I.window[He + G - 1]) & I.hash_mask, I.prev[He & I.w_mask] = I.head[I.ins_h], I.head[I.ins_h] = He, He++, I.insert--, !(I.lookahead + I.insert < G)); ) + ; + } while (I.lookahead < j && I.strm.avail_in !== 0); + } + function Fe(I, me) { + var ge = 65535; + for (ge > I.pending_buf_size - 5 && (ge = I.pending_buf_size - 5); ; ) { + if (I.lookahead <= 1) { + if (je(I), I.lookahead === 0 && me === p) + return xe; + if (I.lookahead === 0) + break; + } + I.strstart += I.lookahead, I.lookahead = 0; + var Y = I.block_start + ge; + if ((I.strstart === 0 || I.strstart >= Y) && (I.lookahead = I.strstart - Y, I.strstart = Y, Re(I, !1), I.strm.avail_out === 0) || I.strstart - I.block_start >= I.w_size - j && (Re(I, !1), I.strm.avail_out === 0)) + return xe; + } + return I.insert = 0, me === A ? (Re(I, !0), I.strm.avail_out === 0 ? oe : ve) : (I.strstart > I.block_start && (Re(I, !1), I.strm.avail_out === 0), xe); + } + function X(I, me) { + for (var ge, Y; ; ) { + if (I.lookahead < j) { + if (je(I), I.lookahead < j && me === p) + return xe; + if (I.lookahead === 0) + break; + } + if (ge = 0, I.lookahead >= G && (I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + G - 1]) & I.hash_mask, ge = I.prev[I.strstart & I.w_mask] = I.head[I.ins_h], I.head[I.ins_h] = I.strstart), ge !== 0 && I.strstart - ge <= I.w_size - j && (I.match_length = Te(I, ge)), I.match_length >= G) + if (Y = g._tr_tally(I, I.strstart - I.match_start, I.match_length - G), I.lookahead -= I.match_length, I.match_length <= I.max_lazy_match && I.lookahead >= G) { + I.match_length--; + do + I.strstart++, I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + G - 1]) & I.hash_mask, ge = 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 + Y = g._tr_tally(I, 0, I.window[I.strstart]), I.lookahead--, I.strstart++; + if (Y && (Re(I, !1), I.strm.avail_out === 0)) + return xe; + } + return I.insert = I.strstart < G - 1 ? I.strstart : G - 1, me === A ? (Re(I, !0), I.strm.avail_out === 0 ? oe : ve) : I.last_lit && (Re(I, !1), I.strm.avail_out === 0) ? xe : Ie; + } + function Z(I, me) { + for (var ge, Y, ne; ; ) { + if (I.lookahead < j) { + if (je(I), I.lookahead < j && me === p) + return xe; + if (I.lookahead === 0) + break; + } + if (ge = 0, I.lookahead >= G && (I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + G - 1]) & I.hash_mask, ge = 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 = G - 1, ge !== 0 && I.prev_length < I.max_lazy_match && I.strstart - ge <= I.w_size - j && (I.match_length = Te(I, ge), I.match_length <= 5 && (I.strategy === c || I.match_length === G && I.strstart - I.match_start > 4096) && (I.match_length = G - 1)), I.prev_length >= G && I.match_length <= I.prev_length) { + ne = I.strstart + I.lookahead - G, Y = g._tr_tally(I, I.strstart - 1 - I.prev_match, I.prev_length - G), I.lookahead -= I.prev_length - 1, I.prev_length -= 2; + do + ++I.strstart <= ne && (I.ins_h = (I.ins_h << I.hash_shift ^ I.window[I.strstart + G - 1]) & I.hash_mask, ge = 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 = G - 1, I.strstart++, Y && (Re(I, !1), I.strm.avail_out === 0)) + return xe; + } else if (I.match_available) { + if (Y = g._tr_tally(I, 0, I.window[I.strstart - 1]), Y && Re(I, !1), I.strstart++, I.lookahead--, I.strm.avail_out === 0) + return xe; + } else + I.match_available = 1, I.strstart++, I.lookahead--; + } + return I.match_available && (Y = g._tr_tally(I, 0, I.window[I.strstart - 1]), I.match_available = 0), I.insert = I.strstart < G - 1 ? I.strstart : G - 1, me === A ? (Re(I, !0), I.strm.avail_out === 0 ? oe : ve) : I.last_lit && (Re(I, !1), I.strm.avail_out === 0) ? xe : Ie; + } + function q(I, me) { + for (var ge, Y, ne, Ee, He = I.window; ; ) { + if (I.lookahead <= k) { + if (je(I), I.lookahead <= k && me === p) + return xe; + if (I.lookahead === 0) + break; + } + if (I.match_length = 0, I.lookahead >= G && I.strstart > 0 && (ne = I.strstart - 1, Y = He[ne], Y === He[++ne] && Y === He[++ne] && Y === He[++ne])) { + Ee = I.strstart + k; + do + ; + while (Y === He[++ne] && Y === He[++ne] && Y === He[++ne] && Y === He[++ne] && Y === He[++ne] && Y === He[++ne] && Y === He[++ne] && Y === He[++ne] && ne < Ee); + I.match_length = k - (Ee - ne), I.match_length > I.lookahead && (I.match_length = I.lookahead); + } + if (I.match_length >= G ? (ge = g._tr_tally(I, 1, I.match_length - G), I.lookahead -= I.match_length, I.strstart += I.match_length, I.match_length = 0) : (ge = g._tr_tally(I, 0, I.window[I.strstart]), I.lookahead--, I.strstart++), ge && (Re(I, !1), I.strm.avail_out === 0)) + return xe; + } + return I.insert = 0, me === A ? (Re(I, !0), I.strm.avail_out === 0 ? oe : ve) : I.last_lit && (Re(I, !1), I.strm.avail_out === 0) ? xe : Ie; + } + function fe(I, me) { + for (var ge; ; ) { + if (I.lookahead === 0 && (je(I), I.lookahead === 0)) { + if (me === p) + return xe; + break; + } + if (I.match_length = 0, ge = g._tr_tally(I, 0, I.window[I.strstart]), I.lookahead--, I.strstart++, ge && (Re(I, !1), I.strm.avail_out === 0)) + return xe; + } + return I.insert = 0, me === A ? (Re(I, !0), I.strm.avail_out === 0 ? oe : ve) : I.last_lit && (Re(I, !1), I.strm.avail_out === 0) ? xe : Ie; + } + function _e(I, me, ge, Y, ne) { + this.good_length = I, this.max_lazy = me, this.nice_length = ge, this.max_chain = Y, this.func = ne; + } + var Me; + Me = [ + /* good lazy nice chain */ + new _e(0, 0, 0, 0, Fe), + /* 0 store only */ + new _e(4, 4, 8, 4, X), + /* 1 max speed, no lazy matches */ + new _e(4, 5, 16, 8, X), + /* 2 */ + new _e(4, 6, 32, 32, X), + /* 3 */ + new _e(4, 4, 16, 16, Z), + /* 4 lazy matches */ + new _e(8, 16, 32, 32, Z), + /* 5 */ + new _e(8, 16, 128, 128, Z), + /* 6 */ + new _e(8, 32, 128, 256, Z), + /* 7 */ + new _e(32, 128, 258, 1024, Z), + /* 8 */ + new _e(32, 258, 258, 4096, Z) + /* 9 max compression */ + ]; + function Ae(I) { + I.window_size = 2 * I.w_size, Ge(I.head), I.max_lazy_match = Me[I.level].max_lazy, I.good_match = Me[I.level].good_length, I.nice_match = Me[I.level].nice_length, I.max_chain_length = Me[I.level].max_chain, I.strstart = 0, I.block_start = 0, I.lookahead = 0, I.insert = 0, I.match_length = I.prev_length = G - 1, I.match_available = 0, I.ins_h = 0; + } + function H() { + 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 = S, 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 l.Buf16(W * 2), this.dyn_dtree = new l.Buf16((2 * F + 1) * 2), this.bl_tree = new l.Buf16((2 * $ + 1) * 2), Ge(this.dyn_ltree), Ge(this.dyn_dtree), Ge(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new l.Buf16(N + 1), this.heap = new l.Buf16(2 * U + 1), Ge(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new l.Buf16(2 * U + 1), Ge(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 me; + return !I || !I.state ? Se(I, r) : (I.total_in = I.total_out = 0, I.data_type = w, me = I.state, me.pending = 0, me.pending_out = 0, me.wrap < 0 && (me.wrap = -me.wrap), me.status = me.wrap ? ie : ae, I.adler = me.wrap === 2 ? 0 : 1, me.last_flush = p, g._tr_init(me), L); + } + function ye(I) { + var me = ce(I); + return me === L && Ae(I.state), me; + } + function Pe(I, me) { + return !I || !I.state || I.state.wrap !== 2 ? r : (I.state.gzhead = me, L); + } + function le(I, me, ge, Y, ne, Ee) { + if (!I) + return r; + var He = 1; + if (me === f && (me = 6), Y < 0 ? (He = 0, Y = -Y) : Y > 15 && (He = 2, Y -= 16), ne < 1 || ne > T || ge !== S || Y < 8 || Y > 15 || me < 0 || me > 9 || Ee < 0 || Ee > h) + return Se(I, r); + Y === 8 && (Y = 9); + var Ke = new H(); + return I.state = Ke, Ke.strm = I, Ke.wrap = He, Ke.gzhead = null, Ke.w_bits = Y, Ke.w_size = 1 << Ke.w_bits, Ke.w_mask = Ke.w_size - 1, Ke.hash_bits = ne + 7, Ke.hash_size = 1 << Ke.hash_bits, Ke.hash_mask = Ke.hash_size - 1, Ke.hash_shift = ~~((Ke.hash_bits + G - 1) / G), Ke.window = new l.Buf8(Ke.w_size * 2), Ke.head = new l.Buf16(Ke.hash_size), Ke.prev = new l.Buf16(Ke.w_size), Ke.lit_bufsize = 1 << ne + 6, Ke.pending_buf_size = Ke.lit_bufsize * 4, Ke.pending_buf = new l.Buf8(Ke.pending_buf_size), Ke.d_buf = 1 * Ke.lit_bufsize, Ke.l_buf = 3 * Ke.lit_bufsize, Ke.level = me, Ke.strategy = Ee, Ke.method = ge, ye(I); + } + function De(I, me) { + return le(I, me, S, R, z, M); + } + function K(I, me) { + var ge, Y, ne, Ee; + if (!I || !I.state || me > C || me < 0) + return I ? Se(I, r) : r; + if (Y = I.state, !I.output || !I.input && I.avail_in !== 0 || Y.status === we && me !== A) + return Se(I, I.avail_out === 0 ? b : r); + if (Y.strm = I, ge = Y.last_flush, Y.last_flush = me, Y.status === ie) + if (Y.wrap === 2) + I.adler = 0, Be(Y, 31), Be(Y, 139), Be(Y, 8), Y.gzhead ? (Be( + Y, + (Y.gzhead.text ? 1 : 0) + (Y.gzhead.hcrc ? 2 : 0) + (Y.gzhead.extra ? 4 : 0) + (Y.gzhead.name ? 8 : 0) + (Y.gzhead.comment ? 16 : 0) + ), Be(Y, Y.gzhead.time & 255), Be(Y, Y.gzhead.time >> 8 & 255), Be(Y, Y.gzhead.time >> 16 & 255), Be(Y, Y.gzhead.time >> 24 & 255), Be(Y, Y.level === 9 ? 2 : Y.strategy >= t || Y.level < 2 ? 4 : 0), Be(Y, Y.gzhead.os & 255), Y.gzhead.extra && Y.gzhead.extra.length && (Be(Y, Y.gzhead.extra.length & 255), Be(Y, Y.gzhead.extra.length >> 8 & 255)), Y.gzhead.hcrc && (I.adler = x(I.adler, Y.pending_buf, Y.pending, 0)), Y.gzindex = 0, Y.status = pe) : (Be(Y, 0), Be(Y, 0), Be(Y, 0), Be(Y, 0), Be(Y, 0), Be(Y, Y.level === 9 ? 2 : Y.strategy >= t || Y.level < 2 ? 4 : 0), Be(Y, re), Y.status = ae); + else { + var He = S + (Y.w_bits - 8 << 4) << 8, Ke = -1; + Y.strategy >= t || Y.level < 2 ? Ke = 0 : Y.level < 6 ? Ke = 1 : Y.level === 6 ? Ke = 2 : Ke = 3, He |= Ke << 6, Y.strstart !== 0 && (He |= Q), He += 31 - He % 31, Y.status = ae, ke(Y, He), Y.strstart !== 0 && (ke(Y, I.adler >>> 16), ke(Y, I.adler & 65535)), I.adler = 1; + } + if (Y.status === pe) + if (Y.gzhead.extra) { + for (ne = Y.pending; Y.gzindex < (Y.gzhead.extra.length & 65535) && !(Y.pending === Y.pending_buf_size && (Y.gzhead.hcrc && Y.pending > ne && (I.adler = x(I.adler, Y.pending_buf, Y.pending - ne, ne)), $e(I), ne = Y.pending, Y.pending === Y.pending_buf_size)); ) + Be(Y, Y.gzhead.extra[Y.gzindex] & 255), Y.gzindex++; + Y.gzhead.hcrc && Y.pending > ne && (I.adler = x(I.adler, Y.pending_buf, Y.pending - ne, ne)), Y.gzindex === Y.gzhead.extra.length && (Y.gzindex = 0, Y.status = he); + } else + Y.status = he; + if (Y.status === he) + if (Y.gzhead.name) { + ne = Y.pending; + do { + if (Y.pending === Y.pending_buf_size && (Y.gzhead.hcrc && Y.pending > ne && (I.adler = x(I.adler, Y.pending_buf, Y.pending - ne, ne)), $e(I), ne = Y.pending, Y.pending === Y.pending_buf_size)) { + Ee = 1; + break; + } + Y.gzindex < Y.gzhead.name.length ? Ee = Y.gzhead.name.charCodeAt(Y.gzindex++) & 255 : Ee = 0, Be(Y, Ee); + } while (Ee !== 0); + Y.gzhead.hcrc && Y.pending > ne && (I.adler = x(I.adler, Y.pending_buf, Y.pending - ne, ne)), Ee === 0 && (Y.gzindex = 0, Y.status = ue); + } else + Y.status = ue; + if (Y.status === ue) + if (Y.gzhead.comment) { + ne = Y.pending; + do { + if (Y.pending === Y.pending_buf_size && (Y.gzhead.hcrc && Y.pending > ne && (I.adler = x(I.adler, Y.pending_buf, Y.pending - ne, ne)), $e(I), ne = Y.pending, Y.pending === Y.pending_buf_size)) { + Ee = 1; + break; + } + Y.gzindex < Y.gzhead.comment.length ? Ee = Y.gzhead.comment.charCodeAt(Y.gzindex++) & 255 : Ee = 0, Be(Y, Ee); + } while (Ee !== 0); + Y.gzhead.hcrc && Y.pending > ne && (I.adler = x(I.adler, Y.pending_buf, Y.pending - ne, ne)), Ee === 0 && (Y.status = se); + } else + Y.status = se; + if (Y.status === se && (Y.gzhead.hcrc ? (Y.pending + 2 > Y.pending_buf_size && $e(I), Y.pending + 2 <= Y.pending_buf_size && (Be(Y, I.adler & 255), Be(Y, I.adler >> 8 & 255), I.adler = 0, Y.status = ae)) : Y.status = ae), Y.pending !== 0) { + if ($e(I), I.avail_out === 0) + return Y.last_flush = -1, L; + } else if (I.avail_in === 0 && ze(me) <= ze(ge) && me !== A) + return Se(I, b); + if (Y.status === we && I.avail_in !== 0) + return Se(I, b); + if (I.avail_in !== 0 || Y.lookahead !== 0 || me !== p && Y.status !== we) { + var Ve = Y.strategy === t ? fe(Y, me) : Y.strategy === a ? q(Y, me) : Me[Y.level].func(Y, me); + if ((Ve === oe || Ve === ve) && (Y.status = we), Ve === xe || Ve === oe) + return I.avail_out === 0 && (Y.last_flush = -1), L; + if (Ve === Ie && (me === E ? g._tr_align(Y) : me !== C && (g._tr_stored_block(Y, 0, 0, !1), me === u && (Ge(Y.head), Y.lookahead === 0 && (Y.strstart = 0, Y.block_start = 0, Y.insert = 0))), $e(I), I.avail_out === 0)) + return Y.last_flush = -1, L; + } + return me !== A ? L : Y.wrap <= 0 ? D : (Y.wrap === 2 ? (Be(Y, I.adler & 255), Be(Y, I.adler >> 8 & 255), Be(Y, I.adler >> 16 & 255), Be(Y, I.adler >> 24 & 255), Be(Y, I.total_in & 255), Be(Y, I.total_in >> 8 & 255), Be(Y, I.total_in >> 16 & 255), Be(Y, I.total_in >> 24 & 255)) : (ke(Y, I.adler >>> 16), ke(Y, I.adler & 65535)), $e(I), Y.wrap > 0 && (Y.wrap = -Y.wrap), Y.pending !== 0 ? L : D); + } + function Oe(I) { + var me; + return !I || !I.state ? r : (me = I.state.status, me !== ie && me !== pe && me !== he && me !== ue && me !== se && me !== ae && me !== we ? Se(I, r) : (I.state = null, me === ae ? Se(I, n) : L)); + } + function Ne(I, me) { + var ge = me.length, Y, ne, Ee, He, Ke, Ve, qe, wt; + if (!I || !I.state || (Y = I.state, He = Y.wrap, He === 2 || He === 1 && Y.status !== ie || Y.lookahead)) + return r; + for (He === 1 && (I.adler = _(I.adler, me, ge, 0)), Y.wrap = 0, ge >= Y.w_size && (He === 0 && (Ge(Y.head), Y.strstart = 0, Y.block_start = 0, Y.insert = 0), wt = new l.Buf8(Y.w_size), l.arraySet(wt, me, ge - Y.w_size, Y.w_size, 0), me = wt, ge = Y.w_size), Ke = I.avail_in, Ve = I.next_in, qe = I.input, I.avail_in = ge, I.next_in = 0, I.input = me, je(Y); Y.lookahead >= G; ) { + ne = Y.strstart, Ee = Y.lookahead - (G - 1); + do + Y.ins_h = (Y.ins_h << Y.hash_shift ^ Y.window[ne + G - 1]) & Y.hash_mask, Y.prev[ne & Y.w_mask] = Y.head[Y.ins_h], Y.head[Y.ins_h] = ne, ne++; + while (--Ee); + Y.strstart = ne, Y.lookahead = G - 1, je(Y); + } + return Y.strstart += Y.lookahead, Y.block_start = Y.strstart, Y.insert = Y.lookahead, Y.lookahead = 0, Y.match_length = Y.prev_length = G - 1, Y.match_available = 0, I.next_in = Ve, I.input = qe, I.avail_in = Ke, Y.wrap = He, L; + } + s.deflateInit = De, s.deflateInit2 = le, s.deflateReset = ye, s.deflateResetKeep = ce, s.deflateSetHeader = Pe, s.deflate = K, s.deflateEnd = Oe, s.deflateSetDictionary = Ne, s.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 ***! + \*********************************************************************/ + /***/ + (y) => { + function s() { + 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; + } + y.exports = s; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js ***! + \********************************************************************/ + /***/ + (y) => { + var s = 30, e = 12; + y.exports = function(g, _) { + var x, o, p, E, u, A, C, L, D, r, n, b, f, c, t, a, h, M, w, S, T, R, z, P, B; + x = g.state, o = g.next_in, P = g.input, p = o + (g.avail_in - 5), E = g.next_out, B = g.output, u = E - (_ - g.avail_out), A = E + (g.avail_out - 257), C = x.dmax, L = x.wsize, D = x.whave, r = x.wnext, n = x.window, b = x.hold, f = x.bits, c = x.lencode, t = x.distcode, a = (1 << x.lenbits) - 1, h = (1 << x.distbits) - 1; + e: + do { + f < 15 && (b += P[o++] << f, f += 8, b += P[o++] << f, f += 8), M = c[b & a]; + t: + for (; ; ) { + if (w = M >>> 24, b >>>= w, f -= w, w = M >>> 16 & 255, w === 0) + B[E++] = M & 65535; + else if (w & 16) { + S = M & 65535, w &= 15, w && (f < w && (b += P[o++] << f, f += 8), S += b & (1 << w) - 1, b >>>= w, f -= w), f < 15 && (b += P[o++] << f, f += 8, b += P[o++] << f, f += 8), M = t[b & h]; + i: + for (; ; ) { + if (w = M >>> 24, b >>>= w, f -= w, w = M >>> 16 & 255, w & 16) { + if (T = M & 65535, w &= 15, f < w && (b += P[o++] << f, f += 8, f < w && (b += P[o++] << f, f += 8)), T += b & (1 << w) - 1, T > C) { + g.msg = "invalid distance too far back", x.mode = s; + break e; + } + if (b >>>= w, f -= w, w = E - u, T > w) { + if (w = T - w, w > D && x.sane) { + g.msg = "invalid distance too far back", x.mode = s; + break e; + } + if (R = 0, z = n, r === 0) { + if (R += L - w, w < S) { + S -= w; + do + B[E++] = n[R++]; + while (--w); + R = E - T, z = B; + } + } else if (r < w) { + if (R += L + r - w, w -= r, w < S) { + S -= w; + do + B[E++] = n[R++]; + while (--w); + if (R = 0, r < S) { + w = r, S -= w; + do + B[E++] = n[R++]; + while (--w); + R = E - T, z = B; + } + } + } else if (R += r - w, w < S) { + S -= w; + do + B[E++] = n[R++]; + while (--w); + R = E - T, z = B; + } + for (; S > 2; ) + B[E++] = z[R++], B[E++] = z[R++], B[E++] = z[R++], S -= 3; + S && (B[E++] = z[R++], S > 1 && (B[E++] = z[R++])); + } else { + R = E - T; + do + B[E++] = B[R++], B[E++] = B[R++], B[E++] = B[R++], S -= 3; + while (S > 2); + S && (B[E++] = B[R++], S > 1 && (B[E++] = B[R++])); + } + } else if (w & 64) { + g.msg = "invalid distance code", x.mode = s; + break e; + } else { + M = t[(M & 65535) + (b & (1 << w) - 1)]; + continue i; + } + break; + } + } else if (w & 64) + if (w & 32) { + x.mode = e; + break e; + } else { + g.msg = "invalid literal/length code", x.mode = s; + break e; + } + else { + M = c[(M & 65535) + (b & (1 << w) - 1)]; + continue t; + } + break; + } + } while (o < p && E < A); + S = f >> 3, o -= S, f -= S << 3, b &= (1 << f) - 1, g.next_in = o, g.next_out = E, g.avail_in = o < p ? 5 + (p - o) : 5 - (o - p), g.avail_out = E < A ? 257 + (A - E) : 257 - (E - A), x.hold = b, x.bits = f; + }; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inflate.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/inflate.js ***! + \********************************************************************/ + /***/ + (y, s, e) => { + var l = e( + /*! ../utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), g = e( + /*! ./adler32 */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/adler32.js" + ), _ = e( + /*! ./crc32 */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/crc32.js" + ), x = e( + /*! ./inffast */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inffast.js" + ), o = e( + /*! ./inftrees */ + "./node_modules/upng-js/node_modules/pako/lib/zlib/inftrees.js" + ), p = 0, E = 1, u = 2, A = 4, C = 5, L = 6, D = 0, r = 1, n = 2, b = -2, f = -3, c = -4, t = -5, a = 8, h = 1, M = 2, w = 3, S = 4, T = 5, R = 6, z = 7, P = 8, B = 9, U = 10, F = 11, $ = 12, W = 13, N = 14, G = 15, k = 16, j = 17, Q = 18, ie = 19, pe = 20, he = 21, ue = 22, se = 23, ae = 24, we = 25, xe = 26, Ie = 27, oe = 28, ve = 29, re = 30, Se = 31, ze = 32, Ge = 852, $e = 592, Re = 15, Be = Re; + function ke(le) { + return (le >>> 24 & 255) + (le >>> 8 & 65280) + ((le & 65280) << 8) + ((le & 255) << 24); + } + function We() { + 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 l.Buf16(320), this.work = new l.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; + } + function Te(le) { + var De; + return !le || !le.state ? b : (De = le.state, le.total_in = le.total_out = De.total = 0, le.msg = "", De.wrap && (le.adler = De.wrap & 1), De.mode = h, De.last = 0, De.havedict = 0, De.dmax = 32768, De.head = null, De.hold = 0, De.bits = 0, De.lencode = De.lendyn = new l.Buf32(Ge), De.distcode = De.distdyn = new l.Buf32($e), De.sane = 1, De.back = -1, D); + } + function je(le) { + var De; + return !le || !le.state ? b : (De = le.state, De.wsize = 0, De.whave = 0, De.wnext = 0, Te(le)); + } + function Fe(le, De) { + var K, Oe; + return !le || !le.state || (Oe = le.state, De < 0 ? (K = 0, De = -De) : (K = (De >> 4) + 1, De < 48 && (De &= 15)), De && (De < 8 || De > 15)) ? b : (Oe.window !== null && Oe.wbits !== De && (Oe.window = null), Oe.wrap = K, Oe.wbits = De, je(le)); + } + function X(le, De) { + var K, Oe; + return le ? (Oe = new We(), le.state = Oe, Oe.window = null, K = Fe(le, De), K !== D && (le.state = null), K) : b; + } + function Z(le) { + return X(le, Be); + } + var q = !0, fe, _e; + function Me(le) { + if (q) { + var De; + for (fe = new l.Buf32(512), _e = new l.Buf32(32), De = 0; De < 144; ) + le.lens[De++] = 8; + for (; De < 256; ) + le.lens[De++] = 9; + for (; De < 280; ) + le.lens[De++] = 7; + for (; De < 288; ) + le.lens[De++] = 8; + for (o(E, le.lens, 0, 288, fe, 0, le.work, { bits: 9 }), De = 0; De < 32; ) + le.lens[De++] = 5; + o(u, le.lens, 0, 32, _e, 0, le.work, { bits: 5 }), q = !1; + } + le.lencode = fe, le.lenbits = 9, le.distcode = _e, le.distbits = 5; + } + function Ae(le, De, K, Oe) { + var Ne, I = le.state; + return I.window === null && (I.wsize = 1 << I.wbits, I.wnext = 0, I.whave = 0, I.window = new l.Buf8(I.wsize)), Oe >= I.wsize ? (l.arraySet(I.window, De, K - I.wsize, I.wsize, 0), I.wnext = 0, I.whave = I.wsize) : (Ne = I.wsize - I.wnext, Ne > Oe && (Ne = Oe), l.arraySet(I.window, De, K - Oe, Ne, I.wnext), Oe -= Ne, Oe ? (l.arraySet(I.window, De, K - Oe, Oe, 0), I.wnext = Oe, I.whave = I.wsize) : (I.wnext += Ne, I.wnext === I.wsize && (I.wnext = 0), I.whave < I.wsize && (I.whave += Ne))), 0; + } + function H(le, De) { + var K, Oe, Ne, I, me, ge, Y, ne, Ee, He, Ke, Ve, qe, wt, nt = 0, rt, tt, yt, _t, It, Ot, vt, mt, gt = new l.Buf8(4), Ct, Mt, 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 (!le || !le.state || !le.output || !le.input && le.avail_in !== 0) + return b; + K = le.state, K.mode === $ && (K.mode = W), me = le.next_out, Ne = le.output, Y = le.avail_out, I = le.next_in, Oe = le.input, ge = le.avail_in, ne = K.hold, Ee = K.bits, He = ge, Ke = Y, mt = D; + e: + for (; ; ) + switch (K.mode) { + case h: + if (K.wrap === 0) { + K.mode = W; + break; + } + for (; Ee < 16; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (K.wrap & 2 && ne === 35615) { + K.check = 0, gt[0] = ne & 255, gt[1] = ne >>> 8 & 255, K.check = _(K.check, gt, 2, 0), ne = 0, Ee = 0, K.mode = M; + break; + } + if (K.flags = 0, K.head && (K.head.done = !1), !(K.wrap & 1) || /* check if zlib header allowed */ + (((ne & 255) << 8) + (ne >> 8)) % 31) { + le.msg = "incorrect header check", K.mode = re; + break; + } + if ((ne & 15) !== a) { + le.msg = "unknown compression method", K.mode = re; + break; + } + if (ne >>>= 4, Ee -= 4, vt = (ne & 15) + 8, K.wbits === 0) + K.wbits = vt; + else if (vt > K.wbits) { + le.msg = "invalid window size", K.mode = re; + break; + } + K.dmax = 1 << vt, le.adler = K.check = 1, K.mode = ne & 512 ? U : $, ne = 0, Ee = 0; + break; + case M: + for (; Ee < 16; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (K.flags = ne, (K.flags & 255) !== a) { + le.msg = "unknown compression method", K.mode = re; + break; + } + if (K.flags & 57344) { + le.msg = "unknown header flags set", K.mode = re; + break; + } + K.head && (K.head.text = ne >> 8 & 1), K.flags & 512 && (gt[0] = ne & 255, gt[1] = ne >>> 8 & 255, K.check = _(K.check, gt, 2, 0)), ne = 0, Ee = 0, K.mode = w; + case w: + for (; Ee < 32; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + K.head && (K.head.time = ne), K.flags & 512 && (gt[0] = ne & 255, gt[1] = ne >>> 8 & 255, gt[2] = ne >>> 16 & 255, gt[3] = ne >>> 24 & 255, K.check = _(K.check, gt, 4, 0)), ne = 0, Ee = 0, K.mode = S; + case S: + for (; Ee < 16; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + K.head && (K.head.xflags = ne & 255, K.head.os = ne >> 8), K.flags & 512 && (gt[0] = ne & 255, gt[1] = ne >>> 8 & 255, K.check = _(K.check, gt, 2, 0)), ne = 0, Ee = 0, K.mode = T; + case T: + if (K.flags & 1024) { + for (; Ee < 16; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + K.length = ne, K.head && (K.head.extra_len = ne), K.flags & 512 && (gt[0] = ne & 255, gt[1] = ne >>> 8 & 255, K.check = _(K.check, gt, 2, 0)), ne = 0, Ee = 0; + } else + K.head && (K.head.extra = null); + K.mode = R; + case R: + if (K.flags & 1024 && (Ve = K.length, Ve > ge && (Ve = ge), Ve && (K.head && (vt = K.head.extra_len - K.length, K.head.extra || (K.head.extra = new Array(K.head.extra_len)), l.arraySet( + K.head.extra, + Oe, + I, + // extra field is limited to 65536 bytes + // - no need for additional size check + Ve, + /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ + vt + )), K.flags & 512 && (K.check = _(K.check, Oe, Ve, I)), ge -= Ve, I += Ve, K.length -= Ve), K.length)) + break e; + K.length = 0, K.mode = z; + case z: + if (K.flags & 2048) { + if (ge === 0) + break e; + Ve = 0; + do + vt = Oe[I + Ve++], K.head && vt && K.length < 65536 && (K.head.name += String.fromCharCode(vt)); + while (vt && Ve < ge); + if (K.flags & 512 && (K.check = _(K.check, Oe, Ve, I)), ge -= Ve, I += Ve, vt) + break e; + } else + K.head && (K.head.name = null); + K.length = 0, K.mode = P; + case P: + if (K.flags & 4096) { + if (ge === 0) + break e; + Ve = 0; + do + vt = Oe[I + Ve++], K.head && vt && K.length < 65536 && (K.head.comment += String.fromCharCode(vt)); + while (vt && Ve < ge); + if (K.flags & 512 && (K.check = _(K.check, Oe, Ve, I)), ge -= Ve, I += Ve, vt) + break e; + } else + K.head && (K.head.comment = null); + K.mode = B; + case B: + if (K.flags & 512) { + for (; Ee < 16; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (ne !== (K.check & 65535)) { + le.msg = "header crc mismatch", K.mode = re; + break; + } + ne = 0, Ee = 0; + } + K.head && (K.head.hcrc = K.flags >> 9 & 1, K.head.done = !0), le.adler = K.check = 0, K.mode = $; + break; + case U: + for (; Ee < 32; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + le.adler = K.check = ke(ne), ne = 0, Ee = 0, K.mode = F; + case F: + if (K.havedict === 0) + return le.next_out = me, le.avail_out = Y, le.next_in = I, le.avail_in = ge, K.hold = ne, K.bits = Ee, n; + le.adler = K.check = 1, K.mode = $; + case $: + if (De === C || De === L) + break e; + case W: + if (K.last) { + ne >>>= Ee & 7, Ee -= Ee & 7, K.mode = Ie; + break; + } + for (; Ee < 3; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + switch (K.last = ne & 1, ne >>>= 1, Ee -= 1, ne & 3) { + case 0: + K.mode = N; + break; + case 1: + if (Me(K), K.mode = pe, De === L) { + ne >>>= 2, Ee -= 2; + break e; + } + break; + case 2: + K.mode = j; + break; + case 3: + le.msg = "invalid block type", K.mode = re; + } + ne >>>= 2, Ee -= 2; + break; + case N: + for (ne >>>= Ee & 7, Ee -= Ee & 7; Ee < 32; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if ((ne & 65535) !== (ne >>> 16 ^ 65535)) { + le.msg = "invalid stored block lengths", K.mode = re; + break; + } + if (K.length = ne & 65535, ne = 0, Ee = 0, K.mode = G, De === L) + break e; + case G: + K.mode = k; + case k: + if (Ve = K.length, Ve) { + if (Ve > ge && (Ve = ge), Ve > Y && (Ve = Y), Ve === 0) + break e; + l.arraySet(Ne, Oe, I, Ve, me), ge -= Ve, I += Ve, Y -= Ve, me += Ve, K.length -= Ve; + break; + } + K.mode = $; + break; + case j: + for (; Ee < 14; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (K.nlen = (ne & 31) + 257, ne >>>= 5, Ee -= 5, K.ndist = (ne & 31) + 1, ne >>>= 5, Ee -= 5, K.ncode = (ne & 15) + 4, ne >>>= 4, Ee -= 4, K.nlen > 286 || K.ndist > 30) { + le.msg = "too many length or distance symbols", K.mode = re; + break; + } + K.have = 0, K.mode = Q; + case Q: + for (; K.have < K.ncode; ) { + for (; Ee < 3; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + K.lens[Ft[K.have++]] = ne & 7, ne >>>= 3, Ee -= 3; + } + for (; K.have < 19; ) + K.lens[Ft[K.have++]] = 0; + if (K.lencode = K.lendyn, K.lenbits = 7, Ct = { bits: K.lenbits }, mt = o(p, K.lens, 0, 19, K.lencode, 0, K.work, Ct), K.lenbits = Ct.bits, mt) { + le.msg = "invalid code lengths set", K.mode = re; + break; + } + K.have = 0, K.mode = ie; + case ie: + for (; K.have < K.nlen + K.ndist; ) { + for (; nt = K.lencode[ne & (1 << K.lenbits) - 1], rt = nt >>> 24, tt = nt >>> 16 & 255, yt = nt & 65535, !(rt <= Ee); ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (yt < 16) + ne >>>= rt, Ee -= rt, K.lens[K.have++] = yt; + else { + if (yt === 16) { + for (Mt = rt + 2; Ee < Mt; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (ne >>>= rt, Ee -= rt, K.have === 0) { + le.msg = "invalid bit length repeat", K.mode = re; + break; + } + vt = K.lens[K.have - 1], Ve = 3 + (ne & 3), ne >>>= 2, Ee -= 2; + } else if (yt === 17) { + for (Mt = rt + 3; Ee < Mt; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + ne >>>= rt, Ee -= rt, vt = 0, Ve = 3 + (ne & 7), ne >>>= 3, Ee -= 3; + } else { + for (Mt = rt + 7; Ee < Mt; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + ne >>>= rt, Ee -= rt, vt = 0, Ve = 11 + (ne & 127), ne >>>= 7, Ee -= 7; + } + if (K.have + Ve > K.nlen + K.ndist) { + le.msg = "invalid bit length repeat", K.mode = re; + break; + } + for (; Ve--; ) + K.lens[K.have++] = vt; + } + } + if (K.mode === re) + break; + if (K.lens[256] === 0) { + le.msg = "invalid code -- missing end-of-block", K.mode = re; + break; + } + if (K.lenbits = 9, Ct = { bits: K.lenbits }, mt = o(E, K.lens, 0, K.nlen, K.lencode, 0, K.work, Ct), K.lenbits = Ct.bits, mt) { + le.msg = "invalid literal/lengths set", K.mode = re; + break; + } + if (K.distbits = 6, K.distcode = K.distdyn, Ct = { bits: K.distbits }, mt = o(u, K.lens, K.nlen, K.ndist, K.distcode, 0, K.work, Ct), K.distbits = Ct.bits, mt) { + le.msg = "invalid distances set", K.mode = re; + break; + } + if (K.mode = pe, De === L) + break e; + case pe: + K.mode = he; + case he: + if (ge >= 6 && Y >= 258) { + le.next_out = me, le.avail_out = Y, le.next_in = I, le.avail_in = ge, K.hold = ne, K.bits = Ee, x(le, Ke), me = le.next_out, Ne = le.output, Y = le.avail_out, I = le.next_in, Oe = le.input, ge = le.avail_in, ne = K.hold, Ee = K.bits, K.mode === $ && (K.back = -1); + break; + } + for (K.back = 0; nt = K.lencode[ne & (1 << K.lenbits) - 1], rt = nt >>> 24, tt = nt >>> 16 & 255, yt = nt & 65535, !(rt <= Ee); ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (tt && !(tt & 240)) { + for (_t = rt, It = tt, Ot = yt; nt = K.lencode[Ot + ((ne & (1 << _t + It) - 1) >> _t)], rt = nt >>> 24, tt = nt >>> 16 & 255, yt = nt & 65535, !(_t + rt <= Ee); ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + ne >>>= _t, Ee -= _t, K.back += _t; + } + if (ne >>>= rt, Ee -= rt, K.back += rt, K.length = yt, tt === 0) { + K.mode = xe; + break; + } + if (tt & 32) { + K.back = -1, K.mode = $; + break; + } + if (tt & 64) { + le.msg = "invalid literal/length code", K.mode = re; + break; + } + K.extra = tt & 15, K.mode = ue; + case ue: + if (K.extra) { + for (Mt = K.extra; Ee < Mt; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + K.length += ne & (1 << K.extra) - 1, ne >>>= K.extra, Ee -= K.extra, K.back += K.extra; + } + K.was = K.length, K.mode = se; + case se: + for (; nt = K.distcode[ne & (1 << K.distbits) - 1], rt = nt >>> 24, tt = nt >>> 16 & 255, yt = nt & 65535, !(rt <= Ee); ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (!(tt & 240)) { + for (_t = rt, It = tt, Ot = yt; nt = K.distcode[Ot + ((ne & (1 << _t + It) - 1) >> _t)], rt = nt >>> 24, tt = nt >>> 16 & 255, yt = nt & 65535, !(_t + rt <= Ee); ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + ne >>>= _t, Ee -= _t, K.back += _t; + } + if (ne >>>= rt, Ee -= rt, K.back += rt, tt & 64) { + le.msg = "invalid distance code", K.mode = re; + break; + } + K.offset = yt, K.extra = tt & 15, K.mode = ae; + case ae: + if (K.extra) { + for (Mt = K.extra; Ee < Mt; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + K.offset += ne & (1 << K.extra) - 1, ne >>>= K.extra, Ee -= K.extra, K.back += K.extra; + } + if (K.offset > K.dmax) { + le.msg = "invalid distance too far back", K.mode = re; + break; + } + K.mode = we; + case we: + if (Y === 0) + break e; + if (Ve = Ke - Y, K.offset > Ve) { + if (Ve = K.offset - Ve, Ve > K.whave && K.sane) { + le.msg = "invalid distance too far back", K.mode = re; + break; + } + Ve > K.wnext ? (Ve -= K.wnext, qe = K.wsize - Ve) : qe = K.wnext - Ve, Ve > K.length && (Ve = K.length), wt = K.window; + } else + wt = Ne, qe = me - K.offset, Ve = K.length; + Ve > Y && (Ve = Y), Y -= Ve, K.length -= Ve; + do + Ne[me++] = wt[qe++]; + while (--Ve); + K.length === 0 && (K.mode = he); + break; + case xe: + if (Y === 0) + break e; + Ne[me++] = K.length, Y--, K.mode = he; + break; + case Ie: + if (K.wrap) { + for (; Ee < 32; ) { + if (ge === 0) + break e; + ge--, ne |= Oe[I++] << Ee, Ee += 8; + } + if (Ke -= Y, le.total_out += Ke, K.total += Ke, Ke && (le.adler = K.check = /*UPDATE(state.check, put - _out, _out);*/ + K.flags ? _(K.check, Ne, Ke, me - Ke) : g(K.check, Ne, Ke, me - Ke)), Ke = Y, (K.flags ? ne : ke(ne)) !== K.check) { + le.msg = "incorrect data check", K.mode = re; + break; + } + ne = 0, Ee = 0; + } + K.mode = oe; + case oe: + if (K.wrap && K.flags) { + for (; Ee < 32; ) { + if (ge === 0) + break e; + ge--, ne += Oe[I++] << Ee, Ee += 8; + } + if (ne !== (K.total & 4294967295)) { + le.msg = "incorrect length check", K.mode = re; + break; + } + ne = 0, Ee = 0; + } + K.mode = ve; + case ve: + mt = r; + break e; + case re: + mt = f; + break e; + case Se: + return c; + case ze: + default: + return b; + } + return le.next_out = me, le.avail_out = Y, le.next_in = I, le.avail_in = ge, K.hold = ne, K.bits = Ee, (K.wsize || Ke !== le.avail_out && K.mode < re && (K.mode < Ie || De !== A)) && Ae(le, le.output, le.next_out, Ke - le.avail_out), He -= le.avail_in, Ke -= le.avail_out, le.total_in += He, le.total_out += Ke, K.total += Ke, K.wrap && Ke && (le.adler = K.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ + K.flags ? _(K.check, Ne, Ke, le.next_out - Ke) : g(K.check, Ne, Ke, le.next_out - Ke)), le.data_type = K.bits + (K.last ? 64 : 0) + (K.mode === $ ? 128 : 0) + (K.mode === pe || K.mode === G ? 256 : 0), (He === 0 && Ke === 0 || De === A) && mt === D && (mt = t), mt; + } + function ce(le) { + if (!le || !le.state) + return b; + var De = le.state; + return De.window && (De.window = null), le.state = null, D; + } + function ye(le, De) { + var K; + return !le || !le.state || (K = le.state, !(K.wrap & 2)) ? b : (K.head = De, De.done = !1, D); + } + function Pe(le, De) { + var K = De.length, Oe, Ne, I; + return !le || !le.state || (Oe = le.state, Oe.wrap !== 0 && Oe.mode !== F) ? b : Oe.mode === F && (Ne = 1, Ne = g(Ne, De, K, 0), Ne !== Oe.check) ? f : (I = Ae(le, De, K, K), I ? (Oe.mode = Se, c) : (Oe.havedict = 1, D)); + } + s.inflateReset = je, s.inflateReset2 = Fe, s.inflateResetKeep = Te, s.inflateInit = Z, s.inflateInit2 = X, s.inflate = H, s.inflateEnd = ce, s.inflateGetHeader = ye, s.inflateSetDictionary = Pe, s.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 ***! + \*********************************************************************/ + /***/ + (y, s, e) => { + var l = e( + /*! ../utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), g = 15, _ = 852, x = 592, o = 0, p = 1, E = 2, u = [ + /* 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 + ], A = [ + /* 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 + ], C = [ + /* 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 + ], L = [ + /* 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 + ]; + y.exports = function(r, n, b, f, c, t, a, h) { + var M = h.bits, w = 0, S = 0, T = 0, R = 0, z = 0, P = 0, B = 0, U = 0, F = 0, $ = 0, W, N, G, k, j, Q = null, ie = 0, pe, he = new l.Buf16(g + 1), ue = new l.Buf16(g + 1), se = null, ae = 0, we, xe, Ie; + for (w = 0; w <= g; w++) + he[w] = 0; + for (S = 0; S < f; S++) + he[n[b + S]]++; + for (z = M, R = g; R >= 1 && he[R] === 0; R--) + ; + if (z > R && (z = R), R === 0) + return c[t++] = 20971520, c[t++] = 20971520, h.bits = 1, 0; + for (T = 1; T < R && he[T] === 0; T++) + ; + for (z < T && (z = T), U = 1, w = 1; w <= g; w++) + if (U <<= 1, U -= he[w], U < 0) + return -1; + if (U > 0 && (r === o || R !== 1)) + return -1; + for (ue[1] = 0, w = 1; w < g; w++) + ue[w + 1] = ue[w] + he[w]; + for (S = 0; S < f; S++) + n[b + S] !== 0 && (a[ue[n[b + S]]++] = S); + if (r === o ? (Q = se = a, pe = 19) : r === p ? (Q = u, ie -= 257, se = A, ae -= 257, pe = 256) : (Q = C, se = L, pe = -1), $ = 0, S = 0, w = T, j = t, P = z, B = 0, G = -1, F = 1 << z, k = F - 1, r === p && F > _ || r === E && F > x) + return 1; + for (; ; ) { + we = w - B, a[S] < pe ? (xe = 0, Ie = a[S]) : a[S] > pe ? (xe = se[ae + a[S]], Ie = Q[ie + a[S]]) : (xe = 96, Ie = 0), W = 1 << w - B, N = 1 << P, T = N; + do + N -= W, c[j + ($ >> B) + N] = we << 24 | xe << 16 | Ie | 0; + while (N !== 0); + for (W = 1 << w - 1; $ & W; ) + W >>= 1; + if (W !== 0 ? ($ &= W - 1, $ += W) : $ = 0, S++, --he[w] === 0) { + if (w === R) + break; + w = n[b + a[S]]; + } + if (w > z && ($ & k) !== G) { + for (B === 0 && (B = z), j += T, P = w - B, U = 1 << P; P + B < R && (U -= he[P + B], !(U <= 0)); ) + P++, U <<= 1; + if (F += 1 << P, r === p && F > _ || r === E && F > x) + return 1; + G = $ & k, c[G] = z << 24 | P << 16 | j - t | 0; + } + } + return $ !== 0 && (c[j + $] = w - B << 24 | 4194304 | 0), h.bits = z, 0; + }; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js": ( + /*!*********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/messages.js ***! + \*********************************************************************/ + /***/ + (y) => { + y.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 ***! + \******************************************************************/ + /***/ + (y, s, e) => { + var l = e( + /*! ../utils/common */ + "./node_modules/upng-js/node_modules/pako/lib/utils/common.js" + ), g = 4, _ = 0, x = 1, o = 2; + function p(H) { + for (var ce = H.length; --ce >= 0; ) + H[ce] = 0; + } + var E = 0, u = 1, A = 2, C = 3, L = 258, D = 29, r = 256, n = r + 1 + D, b = 30, f = 19, c = 2 * n + 1, t = 15, a = 16, h = 7, M = 256, w = 16, S = 17, T = 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] + ), z = ( + /* 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] + ), B = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], U = 512, F = new Array((n + 2) * 2); + p(F); + var $ = new Array(b * 2); + p($); + var W = new Array(U); + p(W); + var N = new Array(L - C + 1); + p(N); + var G = new Array(D); + p(G); + var k = new Array(b); + p(k); + function j(H, ce, ye, Pe, le) { + this.static_tree = H, this.extra_bits = ce, this.extra_base = ye, this.elems = Pe, this.max_length = le, this.has_stree = H && H.length; + } + var Q, ie, pe; + function he(H, ce) { + this.dyn_tree = H, this.max_code = 0, this.stat_desc = ce; + } + function ue(H) { + return H < 256 ? W[H] : W[256 + (H >>> 7)]; + } + function se(H, ce) { + H.pending_buf[H.pending++] = ce & 255, H.pending_buf[H.pending++] = ce >>> 8 & 255; + } + function ae(H, ce, ye) { + H.bi_valid > a - ye ? (H.bi_buf |= ce << H.bi_valid & 65535, se(H, H.bi_buf), H.bi_buf = ce >> a - H.bi_valid, H.bi_valid += ye - a) : (H.bi_buf |= ce << H.bi_valid & 65535, H.bi_valid += ye); + } + function we(H, ce, ye) { + ae( + H, + ye[ce * 2], + ye[ce * 2 + 1] + /*.Len*/ + ); + } + function xe(H, ce) { + var ye = 0; + do + ye |= H & 1, H >>>= 1, ye <<= 1; + while (--ce > 0); + return ye >>> 1; + } + function Ie(H) { + H.bi_valid === 16 ? (se(H, H.bi_buf), H.bi_buf = 0, H.bi_valid = 0) : H.bi_valid >= 8 && (H.pending_buf[H.pending++] = H.bi_buf & 255, H.bi_buf >>= 8, H.bi_valid -= 8); + } + function oe(H, ce) { + var ye = ce.dyn_tree, Pe = ce.max_code, le = ce.stat_desc.static_tree, De = ce.stat_desc.has_stree, K = ce.stat_desc.extra_bits, Oe = ce.stat_desc.extra_base, Ne = ce.stat_desc.max_length, I, me, ge, Y, ne, Ee, He = 0; + for (Y = 0; Y <= t; Y++) + H.bl_count[Y] = 0; + for (ye[H.heap[H.heap_max] * 2 + 1] = 0, I = H.heap_max + 1; I < c; I++) + me = H.heap[I], Y = ye[ye[me * 2 + 1] * 2 + 1] + 1, Y > Ne && (Y = Ne, He++), ye[me * 2 + 1] = Y, !(me > Pe) && (H.bl_count[Y]++, ne = 0, me >= Oe && (ne = K[me - Oe]), Ee = ye[me * 2], H.opt_len += Ee * (Y + ne), De && (H.static_len += Ee * (le[me * 2 + 1] + ne))); + if (He !== 0) { + do { + for (Y = Ne - 1; H.bl_count[Y] === 0; ) + Y--; + H.bl_count[Y]--, H.bl_count[Y + 1] += 2, H.bl_count[Ne]--, He -= 2; + } while (He > 0); + for (Y = Ne; Y !== 0; Y--) + for (me = H.bl_count[Y]; me !== 0; ) + ge = H.heap[--I], !(ge > Pe) && (ye[ge * 2 + 1] !== Y && (H.opt_len += (Y - ye[ge * 2 + 1]) * ye[ge * 2], ye[ge * 2 + 1] = Y), me--); + } + } + function ve(H, ce, ye) { + var Pe = new Array(t + 1), le = 0, De, K; + for (De = 1; De <= t; De++) + Pe[De] = le = le + ye[De - 1] << 1; + for (K = 0; K <= ce; K++) { + var Oe = H[K * 2 + 1]; + Oe !== 0 && (H[K * 2] = xe(Pe[Oe]++, Oe)); + } + } + function re() { + var H, ce, ye, Pe, le, De = new Array(t + 1); + for (ye = 0, Pe = 0; Pe < D - 1; Pe++) + for (G[Pe] = ye, H = 0; H < 1 << R[Pe]; H++) + N[ye++] = Pe; + for (N[ye - 1] = Pe, le = 0, Pe = 0; Pe < 16; Pe++) + for (k[Pe] = le, H = 0; H < 1 << z[Pe]; H++) + W[le++] = Pe; + for (le >>= 7; Pe < b; Pe++) + for (k[Pe] = le << 7, H = 0; H < 1 << z[Pe] - 7; H++) + W[256 + le++] = Pe; + for (ce = 0; ce <= t; ce++) + De[ce] = 0; + for (H = 0; H <= 143; ) + F[H * 2 + 1] = 8, H++, De[8]++; + for (; H <= 255; ) + F[H * 2 + 1] = 9, H++, De[9]++; + for (; H <= 279; ) + F[H * 2 + 1] = 7, H++, De[7]++; + for (; H <= 287; ) + F[H * 2 + 1] = 8, H++, De[8]++; + for (ve(F, n + 1, De), H = 0; H < b; H++) + $[H * 2 + 1] = 5, $[H * 2] = xe(H, 5); + Q = new j(F, R, r + 1, n, t), ie = new j($, z, 0, b, t), pe = new j(new Array(0), P, 0, f, h); + } + function Se(H) { + var ce; + for (ce = 0; ce < n; ce++) + H.dyn_ltree[ce * 2] = 0; + for (ce = 0; ce < b; ce++) + H.dyn_dtree[ce * 2] = 0; + for (ce = 0; ce < f; ce++) + H.bl_tree[ce * 2] = 0; + H.dyn_ltree[M * 2] = 1, H.opt_len = H.static_len = 0, H.last_lit = H.matches = 0; + } + function ze(H) { + H.bi_valid > 8 ? se(H, H.bi_buf) : H.bi_valid > 0 && (H.pending_buf[H.pending++] = H.bi_buf), H.bi_buf = 0, H.bi_valid = 0; + } + function Ge(H, ce, ye, Pe) { + ze(H), Pe && (se(H, ye), se(H, ~ye)), l.arraySet(H.pending_buf, H.window, ce, ye, H.pending), H.pending += ye; + } + function $e(H, ce, ye, Pe) { + var le = ce * 2, De = ye * 2; + return H[le] < H[De] || H[le] === H[De] && Pe[ce] <= Pe[ye]; + } + function Re(H, ce, ye) { + for (var Pe = H.heap[ye], le = ye << 1; le <= H.heap_len && (le < H.heap_len && $e(ce, H.heap[le + 1], H.heap[le], H.depth) && le++, !$e(ce, Pe, H.heap[le], H.depth)); ) + H.heap[ye] = H.heap[le], ye = le, le <<= 1; + H.heap[ye] = Pe; + } + function Be(H, ce, ye) { + var Pe, le, De = 0, K, Oe; + if (H.last_lit !== 0) + do + Pe = H.pending_buf[H.d_buf + De * 2] << 8 | H.pending_buf[H.d_buf + De * 2 + 1], le = H.pending_buf[H.l_buf + De], De++, Pe === 0 ? we(H, le, ce) : (K = N[le], we(H, K + r + 1, ce), Oe = R[K], Oe !== 0 && (le -= G[K], ae(H, le, Oe)), Pe--, K = ue(Pe), we(H, K, ye), Oe = z[K], Oe !== 0 && (Pe -= k[K], ae(H, Pe, Oe))); + while (De < H.last_lit); + we(H, M, ce); + } + function ke(H, ce) { + var ye = ce.dyn_tree, Pe = ce.stat_desc.static_tree, le = ce.stat_desc.has_stree, De = ce.stat_desc.elems, K, Oe, Ne = -1, I; + for (H.heap_len = 0, H.heap_max = c, K = 0; K < De; K++) + ye[K * 2] !== 0 ? (H.heap[++H.heap_len] = Ne = K, H.depth[K] = 0) : ye[K * 2 + 1] = 0; + for (; H.heap_len < 2; ) + I = H.heap[++H.heap_len] = Ne < 2 ? ++Ne : 0, ye[I * 2] = 1, H.depth[I] = 0, H.opt_len--, le && (H.static_len -= Pe[I * 2 + 1]); + for (ce.max_code = Ne, K = H.heap_len >> 1; K >= 1; K--) + Re(H, ye, K); + I = De; + do + K = H.heap[ + 1 + /*SMALLEST*/ + ], H.heap[ + 1 + /*SMALLEST*/ + ] = H.heap[H.heap_len--], Re( + H, + ye, + 1 + /*SMALLEST*/ + ), Oe = H.heap[ + 1 + /*SMALLEST*/ + ], H.heap[--H.heap_max] = K, H.heap[--H.heap_max] = Oe, ye[I * 2] = ye[K * 2] + ye[Oe * 2], H.depth[I] = (H.depth[K] >= H.depth[Oe] ? H.depth[K] : H.depth[Oe]) + 1, ye[K * 2 + 1] = ye[Oe * 2 + 1] = I, H.heap[ + 1 + /*SMALLEST*/ + ] = I++, Re( + H, + ye, + 1 + /*SMALLEST*/ + ); + while (H.heap_len >= 2); + H.heap[--H.heap_max] = H.heap[ + 1 + /*SMALLEST*/ + ], oe(H, ce), ve(ye, Ne, H.bl_count); + } + function We(H, ce, ye) { + var Pe, le = -1, De, K = ce[0 * 2 + 1], Oe = 0, Ne = 7, I = 4; + for (K === 0 && (Ne = 138, I = 3), ce[(ye + 1) * 2 + 1] = 65535, Pe = 0; Pe <= ye; Pe++) + De = K, K = ce[(Pe + 1) * 2 + 1], !(++Oe < Ne && De === K) && (Oe < I ? H.bl_tree[De * 2] += Oe : De !== 0 ? (De !== le && H.bl_tree[De * 2]++, H.bl_tree[w * 2]++) : Oe <= 10 ? H.bl_tree[S * 2]++ : H.bl_tree[T * 2]++, Oe = 0, le = De, K === 0 ? (Ne = 138, I = 3) : De === K ? (Ne = 6, I = 3) : (Ne = 7, I = 4)); + } + function Te(H, ce, ye) { + var Pe, le = -1, De, K = ce[0 * 2 + 1], Oe = 0, Ne = 7, I = 4; + for (K === 0 && (Ne = 138, I = 3), Pe = 0; Pe <= ye; Pe++) + if (De = K, K = ce[(Pe + 1) * 2 + 1], !(++Oe < Ne && De === K)) { + if (Oe < I) + do + we(H, De, H.bl_tree); + while (--Oe !== 0); + else + De !== 0 ? (De !== le && (we(H, De, H.bl_tree), Oe--), we(H, w, H.bl_tree), ae(H, Oe - 3, 2)) : Oe <= 10 ? (we(H, S, H.bl_tree), ae(H, Oe - 3, 3)) : (we(H, T, H.bl_tree), ae(H, Oe - 11, 7)); + Oe = 0, le = De, K === 0 ? (Ne = 138, I = 3) : De === K ? (Ne = 6, I = 3) : (Ne = 7, I = 4); + } + } + function je(H) { + var ce; + for (We(H, H.dyn_ltree, H.l_desc.max_code), We(H, H.dyn_dtree, H.d_desc.max_code), ke(H, H.bl_desc), ce = f - 1; ce >= 3 && H.bl_tree[B[ce] * 2 + 1] === 0; ce--) + ; + return H.opt_len += 3 * (ce + 1) + 5 + 5 + 4, ce; + } + function Fe(H, ce, ye, Pe) { + var le; + for (ae(H, ce - 257, 5), ae(H, ye - 1, 5), ae(H, Pe - 4, 4), le = 0; le < Pe; le++) + ae(H, H.bl_tree[B[le] * 2 + 1], 3); + Te(H, H.dyn_ltree, ce - 1), Te(H, H.dyn_dtree, ye - 1); + } + function X(H) { + var ce = 4093624447, ye; + for (ye = 0; ye <= 31; ye++, ce >>>= 1) + if (ce & 1 && H.dyn_ltree[ye * 2] !== 0) + return _; + if (H.dyn_ltree[18] !== 0 || H.dyn_ltree[20] !== 0 || H.dyn_ltree[26] !== 0) + return x; + for (ye = 32; ye < r; ye++) + if (H.dyn_ltree[ye * 2] !== 0) + return x; + return _; + } + var Z = !1; + function q(H) { + Z || (re(), Z = !0), H.l_desc = new he(H.dyn_ltree, Q), H.d_desc = new he(H.dyn_dtree, ie), H.bl_desc = new he(H.bl_tree, pe), H.bi_buf = 0, H.bi_valid = 0, Se(H); + } + function fe(H, ce, ye, Pe) { + ae(H, (E << 1) + (Pe ? 1 : 0), 3), Ge(H, ce, ye, !0); + } + function _e(H) { + ae(H, u << 1, 3), we(H, M, F), Ie(H); + } + function Me(H, ce, ye, Pe) { + var le, De, K = 0; + H.level > 0 ? (H.strm.data_type === o && (H.strm.data_type = X(H)), ke(H, H.l_desc), ke(H, H.d_desc), K = je(H), le = H.opt_len + 3 + 7 >>> 3, De = H.static_len + 3 + 7 >>> 3, De <= le && (le = De)) : le = De = ye + 5, ye + 4 <= le && ce !== -1 ? fe(H, ce, ye, Pe) : H.strategy === g || De === le ? (ae(H, (u << 1) + (Pe ? 1 : 0), 3), Be(H, F, $)) : (ae(H, (A << 1) + (Pe ? 1 : 0), 3), Fe(H, H.l_desc.max_code + 1, H.d_desc.max_code + 1, K + 1), Be(H, H.dyn_ltree, H.dyn_dtree)), Se(H), Pe && ze(H); + } + function Ae(H, ce, ye) { + return H.pending_buf[H.d_buf + H.last_lit * 2] = ce >>> 8 & 255, H.pending_buf[H.d_buf + H.last_lit * 2 + 1] = ce & 255, H.pending_buf[H.l_buf + H.last_lit] = ye & 255, H.last_lit++, ce === 0 ? H.dyn_ltree[ye * 2]++ : (H.matches++, ce--, H.dyn_ltree[(N[ye] + r + 1) * 2]++, H.dyn_dtree[ue(ce) * 2]++), H.last_lit === H.lit_bufsize - 1; + } + s._tr_init = q, s._tr_stored_block = fe, s._tr_flush_block = Me, s._tr_tally = Ae, s._tr_align = _e; + } + ), + /***/ + "./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js": ( + /*!********************************************************************!*\ + !*** ./node_modules/upng-js/node_modules/pako/lib/zlib/zstream.js ***! + \********************************************************************/ + /***/ + (y) => { + function s() { + 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; + } + y.exports = s; + } + ), + /***/ + "./src/SurfaceWorker.js": ( + /*!******************************!*\ + !*** ./src/SurfaceWorker.js ***! + \******************************/ + /***/ + () => { + $3Dmol.workerString = (function() { + self.onmessage = function(y) { + var s = y.data, e = s.type; + if (e < 0) + self.atomData = s.atoms, self.volume = s.volume, self.ps = new ProteinSurface(); + else { + var l = self.ps; + l.initparm(s.expandedExtent, e != 1, self.volume), l.fillvoxels(self.atomData, s.extendedAtoms), l.buildboundary(), (e === 4 || e === 2) && (l.fastdistancemap(), l.boundingatom(!1), l.fillvoxelswaals(self.atomData, s.extendedAtoms)), l.marchingcube(e); + var g = l.getFacesAndVertices(s.atomsToShow); + self.postMessage(g); + } + }; + }).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 ***! + \*************************/ + /***/ + (y) => { + typeof y.exports == "object" && (y.exports = window.$3Dmol); + } + ), + /***/ + "./src/vendor/mmtf.js": ( + /*!****************************!*\ + !*** ./src/vendor/mmtf.js ***! + \****************************/ + /***/ + function(y, s) { + (function(e, l) { + l(s); + })(this, function(e) { + function l(X, Z, q) { + for (var fe = (X.byteLength, 0), _e = q.length; _e > fe; fe++) { + var Me = q.charCodeAt(fe); + if (128 > Me) + X.setUint8(Z++, Me >>> 0 & 127 | 0); + else if (2048 > Me) + X.setUint8(Z++, Me >>> 6 & 31 | 192), X.setUint8(Z++, Me >>> 0 & 63 | 128); + else if (65536 > Me) + X.setUint8(Z++, Me >>> 12 & 15 | 224), X.setUint8(Z++, Me >>> 6 & 63 | 128), X.setUint8(Z++, Me >>> 0 & 63 | 128); + else { + if (!(1114112 > Me)) + throw new Error("bad codepoint " + Me); + X.setUint8(Z++, Me >>> 18 & 7 | 240), X.setUint8(Z++, Me >>> 12 & 63 | 128), X.setUint8(Z++, Me >>> 6 & 63 | 128), X.setUint8(Z++, Me >>> 0 & 63 | 128); + } + } + } + function g(X) { + for (var Z = 0, q = 0, fe = X.length; fe > q; q++) { + var _e = X.charCodeAt(q); + if (128 > _e) + Z += 1; + else if (2048 > _e) + Z += 2; + else if (65536 > _e) + Z += 3; + else { + if (!(1114112 > _e)) + throw new Error("bad codepoint " + _e); + Z += 4; + } + } + return Z; + } + function _(X, Z, q) { + var fe = typeof X; + if (fe === "string") { + var _e = g(X); + if (32 > _e) + return Z.setUint8(q, 160 | _e), l(Z, q + 1, X), 1 + _e; + if (256 > _e) + return Z.setUint8(q, 217), Z.setUint8(q + 1, _e), l(Z, q + 2, X), 2 + _e; + if (65536 > _e) + return Z.setUint8(q, 218), Z.setUint16(q + 1, _e), l(Z, q + 3, X), 3 + _e; + if (4294967296 > _e) + return Z.setUint8(q, 219), Z.setUint32(q + 1, _e), l(Z, q + 5, X), 5 + _e; + } + if (X instanceof Uint8Array) { + var _e = X.byteLength, Me = new Uint8Array(Z.buffer); + if (256 > _e) + return Z.setUint8(q, 196), Z.setUint8(q + 1, _e), Me.set(X, q + 2), 2 + _e; + if (65536 > _e) + return Z.setUint8(q, 197), Z.setUint16(q + 1, _e), Me.set(X, q + 3), 3 + _e; + if (4294967296 > _e) + return Z.setUint8(q, 198), Z.setUint32(q + 1, _e), Me.set(X, q + 5), 5 + _e; + } + if (fe === "number") { + if (!isFinite(X)) + throw new Error("Number not finite: " + X); + if (Math.floor(X) !== X) + return Z.setUint8(q, 203), Z.setFloat64(q + 1, X), 9; + if (X >= 0) { + if (128 > X) + return Z.setUint8(q, X), 1; + if (256 > X) + return Z.setUint8(q, 204), Z.setUint8(q + 1, X), 2; + if (65536 > X) + return Z.setUint8(q, 205), Z.setUint16(q + 1, X), 3; + if (4294967296 > X) + return Z.setUint8(q, 206), Z.setUint32(q + 1, X), 5; + throw new Error("Number too big 0x" + X.toString(16)); + } + if (X >= -32) + return Z.setInt8(q, X), 1; + if (X >= -128) + return Z.setUint8(q, 208), Z.setInt8(q + 1, X), 2; + if (X >= -32768) + return Z.setUint8(q, 209), Z.setInt16(q + 1, X), 3; + if (X >= -2147483648) + return Z.setUint8(q, 210), Z.setInt32(q + 1, X), 5; + throw new Error("Number too small -0x" + (-X).toString(16).substr(1)); + } + if (X === null) + return Z.setUint8(q, 192), 1; + if (fe === "boolean") + return Z.setUint8(q, X ? 195 : 194), 1; + if (fe === "object") { + var _e, ce = 0, Ae = Array.isArray(X); + if (Ae) + _e = X.length; + else { + var H = Object.keys(X); + _e = H.length; + } + var ce; + if (16 > _e ? (Z.setUint8(q, _e | (Ae ? 144 : 128)), ce = 1) : 65536 > _e ? (Z.setUint8(q, Ae ? 220 : 222), Z.setUint16(q + 1, _e), ce = 3) : 4294967296 > _e && (Z.setUint8(q, Ae ? 221 : 223), Z.setUint32(q + 1, _e), ce = 5), Ae) + for (var ye = 0; _e > ye; ye++) + ce += _(X[ye], Z, q + ce); + else + for (var ye = 0; _e > ye; ye++) { + var Pe = H[ye]; + ce += _(Pe, Z, q + ce), ce += _(X[Pe], Z, q + ce); + } + return ce; + } + throw new Error("Unknown type " + fe); + } + function x(X) { + var Z = typeof X; + if (Z === "string") { + var q = g(X); + 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 (X instanceof Uint8Array) { + var q = X.byteLength; + if (256 > q) + return 2 + q; + if (65536 > q) + return 3 + q; + if (4294967296 > q) + return 5 + q; + } + if (Z === "number") { + if (Math.floor(X) !== X) + return 9; + if (X >= 0) { + if (128 > X) + return 1; + if (256 > X) + return 2; + if (65536 > X) + return 3; + if (4294967296 > X) + return 5; + throw new Error("Number too big 0x" + X.toString(16)); + } + if (X >= -32) + return 1; + if (X >= -128) + return 2; + if (X >= -32768) + return 3; + if (X >= -2147483648) + return 5; + throw new Error("Number too small -0x" + X.toString(16).substr(1)); + } + if (Z === "boolean" || X === null) + return 1; + if (Z === "object") { + var q, fe = 0; + if (Array.isArray(X)) { + q = X.length; + for (var _e = 0; q > _e; _e++) + fe += x(X[_e]); + } else { + var Me = Object.keys(X); + q = Me.length; + for (var _e = 0; q > _e; _e++) { + var Ae = Me[_e]; + fe += x(Ae) + x(X[Ae]); + } + } + if (16 > q) + return 1 + fe; + if (65536 > q) + return 3 + fe; + if (4294967296 > q) + return 5 + fe; + throw new Error("Array or object too long 0x" + q.toString(16)); + } + throw new Error("Unknown type " + Z); + } + function o(X) { + var Z = new ArrayBuffer(x(X)), q = new DataView(Z); + return _(X, q, 0), new Uint8Array(Z); + } + function p(X, Z, q) { + return Z ? new X(Z.buffer, Z.byteOffset, Z.byteLength / (q || 1)) : void 0; + } + function E(X) { + return p(DataView, X); + } + function u(X) { + return p(Uint8Array, X); + } + function A(X) { + return p(Int8Array, X); + } + function C(X) { + return p(Int32Array, X, 4); + } + function L(X) { + return p(Float32Array, X, 4); + } + function D(X, Z) { + var q = X.length / 2; + Z || (Z = new Int16Array(q)); + for (var fe = 0, _e = 0; q > fe; ++fe, _e += 2) + Z[fe] = X[_e] << 8 ^ X[_e + 1] << 0; + return Z; + } + function r(X, Z) { + var q = X.length; + Z || (Z = new Uint8Array(2 * q)); + for (var fe = E(Z), _e = 0; q > _e; ++_e) + fe.setInt16(2 * _e, X[_e]); + return u(Z); + } + function n(X, Z) { + var q = X.length / 4; + Z || (Z = new Int32Array(q)); + for (var fe = 0, _e = 0; q > fe; ++fe, _e += 4) + Z[fe] = X[_e] << 24 ^ X[_e + 1] << 16 ^ X[_e + 2] << 8 ^ X[_e + 3] << 0; + return Z; + } + function b(X, Z) { + var q = X.length; + Z || (Z = new Uint8Array(4 * q)); + for (var fe = E(Z), _e = 0; q > _e; ++_e) + fe.setInt32(4 * _e, X[_e]); + return u(Z); + } + function f(X, Z) { + var q = X.length; + Z || (Z = new Float32Array(q / 4)); + for (var fe = E(Z), _e = E(X), Me = 0, Ae = 0, H = q / 4; H > Me; ++Me, Ae += 4) + fe.setFloat32(Ae, _e.getFloat32(Ae), !0); + return Z; + } + function c(X, Z, q) { + var fe = X.length, _e = 1 / Z; + q || (q = new Float32Array(fe)); + for (var Me = 0; fe > Me; ++Me) + q[Me] = X[Me] * _e; + return q; + } + function t(X, Z, q) { + var fe = X.length; + q || (q = new Int32Array(fe)); + for (var _e = 0; fe > _e; ++_e) + q[_e] = Math.round(X[_e] * Z); + return q; + } + function a(X, Z) { + var q, fe; + if (!Z) { + var _e = 0; + for (q = 0, fe = X.length; fe > q; q += 2) + _e += X[q + 1]; + Z = new X.constructor(_e); + } + var Me = 0; + for (q = 0, fe = X.length; fe > q; q += 2) + for (var Ae = X[q], H = X[q + 1], ce = 0; H > ce; ++ce) + Z[Me] = Ae, ++Me; + return Z; + } + function h(X) { + if (X.length === 0) + return new Int32Array(); + var Z, q, fe = 2; + for (Z = 1, q = X.length; q > Z; ++Z) + X[Z - 1] !== X[Z] && (fe += 2); + var _e = new Int32Array(fe), Me = 0, Ae = 1; + for (Z = 1, q = X.length; q > Z; ++Z) + X[Z - 1] !== X[Z] ? (_e[Me] = X[Z - 1], _e[Me + 1] = Ae, Ae = 1, Me += 2) : ++Ae; + return _e[Me] = X[X.length - 1], _e[Me + 1] = Ae, _e; + } + function M(X, Z) { + var q = X.length; + Z || (Z = new X.constructor(q)), q && (Z[0] = X[0]); + for (var fe = 1; q > fe; ++fe) + Z[fe] = X[fe] + Z[fe - 1]; + return Z; + } + function w(X, Z) { + var q = X.length; + Z || (Z = new X.constructor(q)), Z[0] = X[0]; + for (var fe = 1; q > fe; ++fe) + Z[fe] = X[fe] - X[fe - 1]; + return Z; + } + function S(X, Z) { + var q, fe, _e = X instanceof Int8Array ? 127 : 32767, Me = -_e - 1, Ae = X.length; + if (!Z) { + var H = 0; + for (q = 0; Ae > q; ++q) + X[q] < _e && X[q] > Me && ++H; + Z = new Int32Array(H); + } + for (q = 0, fe = 0; Ae > q; ) { + for (var ce = 0; X[q] === _e || X[q] === Me; ) + ce += X[q], ++q; + ce += X[q], ++q, Z[fe] = ce, ++fe; + } + return Z; + } + function T(X, Z) { + var q, fe = Z ? 127 : 32767, _e = -fe - 1, Me = X.length, Ae = 0; + for (q = 0; Me > q; ++q) { + var H = X[q]; + H === 0 ? ++Ae : H > 0 ? (Ae += Math.ceil(H / fe), H % fe === 0 && (Ae += 1)) : (Ae += Math.ceil(H / _e), H % _e === 0 && (Ae += 1)); + } + var ce = Z ? new Int8Array(Ae) : new Int16Array(Ae), ye = 0; + for (q = 0; Me > q; ++q) { + var H = X[q]; + if (H >= 0) + for (; H >= fe; ) + ce[ye] = fe, ++ye, H -= fe; + else + for (; _e >= H; ) + ce[ye] = _e, ++ye, H -= _e; + ce[ye] = H, ++ye; + } + return ce; + } + function R(X, Z) { + return M(a(X), Z); + } + function z(X) { + return h(w(X)); + } + function P(X, Z, q) { + return c(a(X, C(q)), Z, q); + } + function B(X, Z) { + return h(t(X, Z)); + } + function U(X, Z, q) { + return c(M(X, C(q)), Z, q); + } + function F(X, Z, q) { + return w(t(X, Z), q); + } + function $(X, Z, q) { + return c(S(X, C(q)), Z, q); + } + function W(X, Z, q) { + var fe = S(X, C(q)); + return U(fe, Z, L(fe)); + } + function N(X, Z, q) { + return T(F(X, Z), q); + } + function G(Me) { + var Z = E(Me), q = Z.getInt32(0), fe = Z.getInt32(4), _e = Me.subarray(8, 12), Me = Me.subarray(12); + return [q, Me, fe, _e]; + } + function k(X, Z, q, fe) { + var _e = new ArrayBuffer(12 + fe.byteLength), Me = new Uint8Array(_e), Ae = new DataView(_e); + return Ae.setInt32(0, X), Ae.setInt32(4, Z), q && Me.set(q, 8), Me.set(fe, 12), Me; + } + function j(X) { + var Z = X.length, q = u(X); + return k(2, Z, void 0, q); + } + function Q(X) { + var Z = X.length, q = b(X); + return k(4, Z, void 0, q); + } + function ie(X, Z) { + var q = X.length / Z, fe = b([Z]), _e = u(X); + return k(5, q, fe, _e); + } + function pe(X) { + var Z = X.length, q = b(h(X)); + return k(6, Z, void 0, q); + } + function he(X) { + var Z = X.length, q = b(z(X)); + return k(8, Z, void 0, q); + } + function ue(X, Z) { + var q = X.length, fe = b([Z]), _e = b(B(X, Z)); + return k(9, q, fe, _e); + } + function se(X, Z) { + var q = X.length, fe = b([Z]), _e = r(N(X, Z)); + return k(10, q, fe, _e); + } + function ae(X) { + var Z = {}; + return Re.forEach(function(q) { + X[q] !== void 0 && (Z[q] = X[q]); + }), X.bondAtomList && (Z.bondAtomList = Q(X.bondAtomList)), X.bondOrderList && (Z.bondOrderList = j(X.bondOrderList)), Z.xCoordList = se(X.xCoordList, 1e3), Z.yCoordList = se(X.yCoordList, 1e3), Z.zCoordList = se(X.zCoordList, 1e3), X.bFactorList && (Z.bFactorList = se(X.bFactorList, 100)), X.atomIdList && (Z.atomIdList = he(X.atomIdList)), X.altLocList && (Z.altLocList = pe(X.altLocList)), X.occupancyList && (Z.occupancyList = ue(X.occupancyList, 100)), Z.groupIdList = he(X.groupIdList), Z.groupTypeList = Q(X.groupTypeList), X.secStructList && (Z.secStructList = j(X.secStructList)), X.insCodeList && (Z.insCodeList = pe(X.insCodeList)), X.sequenceIndexList && (Z.sequenceIndexList = he(X.sequenceIndexList)), Z.chainIdList = ie(X.chainIdList, 4), X.chainNameList && (Z.chainNameList = ie(X.chainNameList, 4)), Z; + } + function we(X) { + function Z(ce) { + for (var ye = {}, Pe = 0; ce > Pe; Pe++) { + var le = Me(); + ye[le] = Me(); + } + return ye; + } + function q(ce) { + var ye = X.subarray(Ae, Ae + ce); + return Ae += ce, ye; + } + function fe(ce) { + var ye = X.subarray(Ae, Ae + ce); + Ae += ce; + var Pe = 65535; + if (ce > Pe) { + for (var le = [], De = 0; De < ye.length; De += Pe) + le.push(String.fromCharCode.apply(null, ye.subarray(De, De + Pe))); + return le.join(""); + } + return String.fromCharCode.apply(null, ye); + } + function _e(ce) { + for (var ye = new Array(ce), Pe = 0; ce > Pe; Pe++) + ye[Pe] = Me(); + return ye; + } + function Me() { + var ce, ye, Pe = X[Ae]; + if (!(128 & Pe)) + return Ae++, Pe; + if ((240 & Pe) === 128) + return ye = 15 & Pe, Ae++, Z(ye); + if ((240 & Pe) === 144) + return ye = 15 & Pe, Ae++, _e(ye); + if ((224 & Pe) === 160) + return ye = 31 & Pe, Ae++, fe(ye); + if ((224 & Pe) === 224) + return ce = H.getInt8(Ae), Ae++, ce; + switch (Pe) { + case 192: + return Ae++, null; + case 194: + return Ae++, !1; + case 195: + return Ae++, !0; + case 196: + return ye = H.getUint8(Ae + 1), Ae += 2, q(ye); + case 197: + return ye = H.getUint16(Ae + 1), Ae += 3, q(ye); + case 198: + return ye = H.getUint32(Ae + 1), Ae += 5, q(ye); + case 202: + return ce = H.getFloat32(Ae + 1), Ae += 5, ce; + case 203: + return ce = H.getFloat64(Ae + 1), Ae += 9, ce; + case 204: + return ce = X[Ae + 1], Ae += 2, ce; + case 205: + return ce = H.getUint16(Ae + 1), Ae += 3, ce; + case 206: + return ce = H.getUint32(Ae + 1), Ae += 5, ce; + case 208: + return ce = H.getInt8(Ae + 1), Ae += 2, ce; + case 209: + return ce = H.getInt16(Ae + 1), Ae += 3, ce; + case 210: + return ce = H.getInt32(Ae + 1), Ae += 5, ce; + case 217: + return ye = H.getUint8(Ae + 1), Ae += 2, fe(ye); + case 218: + return ye = H.getUint16(Ae + 1), Ae += 3, fe(ye); + case 219: + return ye = H.getUint32(Ae + 1), Ae += 5, fe(ye); + case 220: + return ye = H.getUint16(Ae + 1), Ae += 3, _e(ye); + case 221: + return ye = H.getUint32(Ae + 1), Ae += 5, _e(ye); + case 222: + return ye = H.getUint16(Ae + 1), Ae += 3, Z(ye); + case 223: + return ye = H.getUint32(Ae + 1), Ae += 5, Z(ye); + } + throw new Error("Unknown type 0x" + Pe.toString(16)); + } + var Ae = 0, H = new DataView(X.buffer); + return Me(); + } + function xe(X, Z, q, fe) { + switch (X) { + case 1: + return f(Z); + case 2: + return A(Z); + case 3: + return D(Z); + case 4: + return n(Z); + case 5: + return u(Z); + case 6: + return a(n(Z), new Uint8Array(q)); + case 7: + return a(n(Z)); + case 8: + return R(n(Z)); + case 9: + return P(n(Z), n(fe)[0]); + case 10: + return W(D(Z), n(fe)[0]); + case 11: + return c(D(Z), n(fe)[0]); + case 12: + return $(D(Z), n(fe)[0]); + case 13: + return $(A(Z), n(fe)[0]); + case 14: + return S(D(Z)); + case 15: + return S(A(Z)); + } + } + function Ie(X, Z) { + Z = Z || {}; + var q = Z.ignoreFields, fe = {}; + return ke.forEach(function(_e) { + var Me = q ? q.indexOf(_e) !== -1 : !1, Ae = X[_e]; + Me || Ae === void 0 || (Ae instanceof Uint8Array ? fe[_e] = xe.apply(null, G(Ae)) : fe[_e] = Ae); + }), fe; + } + function oe(X) { + return String.fromCharCode.apply(null, X).replace(/\0/g, ""); + } + function ve(X, Z, q) { + q = q || {}; + var fe, _e, Me, Ae, H, ce, ye = q.firstModelOnly, Pe = Z.onModel, le = Z.onChain, De = Z.onGroup, K = Z.onAtom, Oe = Z.onBond, Ne = 0, I = 0, me = 0, ge = 0, Y = 0, ne = -1, Ee = X.chainNameList, He = X.secStructList, Ke = X.insCodeList, Ve = X.sequenceIndexList, qe = X.atomIdList, wt = X.bFactorList, nt = X.altLocList, rt = X.occupancyList, tt = X.bondAtomList, yt = X.bondOrderList; + for (fe = 0, _e = X.chainsPerModel.length; _e > fe && !(ye && Ne > 0); ++fe) { + var _t = X.chainsPerModel[Ne]; + for (Pe && Pe({ chainCount: _t, modelIndex: Ne }), Me = 0; _t > Me; ++Me) { + var It = X.groupsPerChain[I]; + if (le) { + var Ot = oe(X.chainIdList.subarray(4 * I, 4 * I + 4)), vt = null; + Ee && (vt = oe(Ee.subarray(4 * I, 4 * I + 4))), le({ groupCount: It, chainIndex: I, modelIndex: Ne, chainId: Ot, chainName: vt }); + } + for (Ae = 0; It > Ae; ++Ae) { + var mt = X.groupList[X.groupTypeList[me]], gt = mt.atomNameList.length; + if (De) { + var Ct = null; + He && (Ct = He[me]); + var Mt = null; + X.insCodeList && (Mt = String.fromCharCode(Ke[me])); + var Ft = null; + Ve && (Ft = Ve[me]), De({ atomCount: gt, groupIndex: me, chainIndex: I, modelIndex: Ne, groupId: X.groupIdList[me], groupType: X.groupTypeList[me], groupName: mt.groupName, singleLetterCode: mt.singleLetterCode, chemCompType: mt.chemCompType, secStruct: Ct, insCode: Mt, sequenceIndex: Ft }); + } + for (H = 0; gt > H; ++H) { + if (K) { + var hi = null; + qe && (hi = qe[ge]); + var Ut = null; + wt && (Ut = wt[ge]); + var di = null; + nt && (di = String.fromCharCode(nt[ge])); + var ci = null; + rt && (ci = rt[ge]), K({ atomIndex: ge, groupIndex: me, chainIndex: I, modelIndex: Ne, atomId: hi, element: mt.elementList[H], atomName: mt.atomNameList[H], formalCharge: mt.formalChargeList[H], xCoord: X.xCoordList[ge], yCoord: X.yCoordList[ge], zCoord: X.zCoordList[ge], bFactor: Ut, altLoc: di, occupancy: ci }); + } + ge += 1; + } + if (Oe) { + var ui = mt.bondAtomList; + for (H = 0, ce = mt.bondOrderList.length; ce > H; ++H) + Oe({ atomIndex1: ge - gt + ui[2 * H], atomIndex2: ge - gt + ui[2 * H + 1], bondOrder: mt.bondOrderList[H] }); + } + me += 1; + } + I += 1; + } + if (Y = ne + 1, ne = ge - 1, Oe && tt) + for (H = 0, ce = tt.length; ce > H; H += 2) { + var _i = tt[H], gi = tt[H + 1]; + (_i >= Y && ne >= _i || gi >= Y && ne >= gi) && Oe({ atomIndex1: _i, atomIndex2: gi, bondOrder: yt ? yt[H / 2] : null }); + } + Ne += 1; + } + } + function re(X) { + return o(ae(X)); + } + function Se(X, Z) { + X instanceof ArrayBuffer && (X = new Uint8Array(X)); + var q; + return q = X instanceof Uint8Array ? we(X) : X, Ie(q, Z); + } + function ze(X, Z, q, fe) { + function _e() { + try { + var Ae = Se(Me.response); + q(Ae); + } catch (H) { + fe(H); + } + } + var Me = new XMLHttpRequest(); + Me.addEventListener("load", _e, !0), Me.addEventListener("error", fe, !0), Me.responseType = "arraybuffer", Me.open("GET", Z + X.toUpperCase()), Me.send(); + } + function Ge(X, Z, q) { + ze(X, je, Z, q); + } + function $e(X, Z, q) { + ze(X, Fe, Z, q); + } + var Re = ["mmtfVersion", "mmtfProducer", "unitCell", "spaceGroup", "structureId", "title", "depositionDate", "releaseDate", "experimentalMethods", "resolution", "rFree", "rWork", "bioAssemblyList", "ncsOperatorList", "entityList", "groupList", "numBonds", "numAtoms", "numGroups", "numChains", "numModels", "groupsPerChain", "chainsPerModel"], Be = ["xCoordList", "yCoordList", "zCoordList", "groupIdList", "groupTypeList", "chainIdList", "bFactorList", "atomIdList", "altLocList", "occupancyList", "secStructList", "insCodeList", "sequenceIndexList", "chainNameList", "bondAtomList", "bondOrderList"], ke = Re.concat(Be), We = "v1.0.1", Te = "//mmtf.rcsb.org/v1.0/", je = Te + "full/", Fe = Te + "reduced/"; + e.encode = re, e.decode = Se, e.traverse = ve, e.fetch = Ge, e.fetchReduced = $e, e.version = We, e.fetchUrl = je, e.fetchReducedUrl = Fe, e.encodeMsgpack = o, e.encodeMmtf = ae, e.decodeMsgpack = we, e.decodeMmtf = Ie; + }); + } + ), + /***/ + "./node_modules/pako/dist/pako.esm.mjs": ( + /*!*********************************************!*\ + !*** ./node_modules/pako/dist/pako.esm.mjs ***! + \*********************************************/ + /***/ + (y, s, e) => { + e.r(s), e.d(s, { + /* harmony export */ + Deflate: () => ( + /* binding */ + Wr + ), + /* harmony export */ + Inflate: () => ( + /* binding */ + jr + ), + /* harmony export */ + constants: () => ( + /* binding */ + Yr + ), + /* harmony export */ + default: () => ( + /* binding */ + js + ), + /* harmony export */ + deflate: () => ( + /* binding */ + Gr + ), + /* harmony export */ + deflateRaw: () => ( + /* binding */ + Nr + ), + /* harmony export */ + gzip: () => ( + /* binding */ + Vr + ), + /* harmony export */ + inflate: () => ( + /* binding */ + Hr + ), + /* harmony export */ + inflateRaw: () => ( + /* binding */ + Kr + ), + /* harmony export */ + ungzip: () => ( + /* binding */ + Zr + ) + /* harmony export */ + }); + /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */ + const l = 4, g = 0, _ = 1, x = 2; + function o(v) { + let V = v.length; + for (; --V >= 0; ) + v[V] = 0; + } + const p = 0, E = 1, u = 2, A = 3, C = 258, L = 29, D = 256, r = D + 1 + L, n = 30, b = 19, f = 2 * r + 1, c = 15, t = 16, a = 7, h = 256, M = 16, w = 17, S = 18, T = ( + /* 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]) + ), z = ( + /* 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]), B = 512, U = new Array((r + 2) * 2); + o(U); + const F = new Array(n * 2); + o(F); + const $ = new Array(B); + o($); + const W = new Array(C - A + 1); + o(W); + const N = new Array(L); + o(N); + const G = new Array(n); + o(G); + function k(v, V, O, J, te) { + this.static_tree = v, this.extra_bits = V, this.extra_base = O, this.elems = J, this.max_length = te, this.has_stree = v && v.length; + } + let j, Q, ie; + function pe(v, V) { + this.dyn_tree = v, this.max_code = 0, this.stat_desc = V; + } + const he = (v) => v < 256 ? $[v] : $[256 + (v >>> 7)], ue = (v, V) => { + v.pending_buf[v.pending++] = V & 255, v.pending_buf[v.pending++] = V >>> 8 & 255; + }, se = (v, V, O) => { + v.bi_valid > t - O ? (v.bi_buf |= V << v.bi_valid & 65535, ue(v, v.bi_buf), v.bi_buf = V >> t - v.bi_valid, v.bi_valid += O - t) : (v.bi_buf |= V << v.bi_valid & 65535, v.bi_valid += O); + }, ae = (v, V, O) => { + se( + v, + O[V * 2], + O[V * 2 + 1] + /*.Len*/ + ); + }, we = (v, V) => { + let O = 0; + do + O |= v & 1, v >>>= 1, O <<= 1; + while (--V > 0); + return O >>> 1; + }, xe = (v) => { + v.bi_valid === 16 ? (ue(v, v.bi_buf), v.bi_buf = 0, v.bi_valid = 0) : v.bi_valid >= 8 && (v.pending_buf[v.pending++] = v.bi_buf & 255, v.bi_buf >>= 8, v.bi_valid -= 8); + }, Ie = (v, V) => { + const O = V.dyn_tree, J = V.max_code, te = V.stat_desc.static_tree, ee = V.stat_desc.has_stree, Ce = V.stat_desc.extra_bits, be = V.stat_desc.extra_base, Xe = V.stat_desc.max_length; + let de, Le, ht, Ye, Ue, Qe, xt = 0; + for (Ye = 0; Ye <= c; Ye++) + v.bl_count[Ye] = 0; + for (O[v.heap[v.heap_max] * 2 + 1] = 0, de = v.heap_max + 1; de < f; de++) + Le = v.heap[de], Ye = O[O[Le * 2 + 1] * 2 + 1] + 1, Ye > Xe && (Ye = Xe, xt++), O[Le * 2 + 1] = Ye, !(Le > J) && (v.bl_count[Ye]++, Ue = 0, Le >= be && (Ue = Ce[Le - be]), Qe = O[Le * 2], v.opt_len += Qe * (Ye + Ue), ee && (v.static_len += Qe * (te[Le * 2 + 1] + Ue))); + if (xt !== 0) { + do { + for (Ye = Xe - 1; v.bl_count[Ye] === 0; ) + Ye--; + v.bl_count[Ye]--, v.bl_count[Ye + 1] += 2, v.bl_count[Xe]--, xt -= 2; + } while (xt > 0); + for (Ye = Xe; Ye !== 0; Ye--) + for (Le = v.bl_count[Ye]; Le !== 0; ) + ht = v.heap[--de], !(ht > J) && (O[ht * 2 + 1] !== Ye && (v.opt_len += (Ye - O[ht * 2 + 1]) * O[ht * 2], O[ht * 2 + 1] = Ye), Le--); + } + }, oe = (v, V, O) => { + const J = new Array(c + 1); + let te = 0, ee, Ce; + for (ee = 1; ee <= c; ee++) + te = te + O[ee - 1] << 1, J[ee] = te; + for (Ce = 0; Ce <= V; Ce++) { + let be = v[Ce * 2 + 1]; + be !== 0 && (v[Ce * 2] = we(J[be]++, be)); + } + }, ve = () => { + let v, V, O, J, te; + const ee = new Array(c + 1); + for (O = 0, J = 0; J < L - 1; J++) + for (N[J] = O, v = 0; v < 1 << T[J]; v++) + W[O++] = J; + for (W[O - 1] = J, te = 0, J = 0; J < 16; J++) + for (G[J] = te, v = 0; v < 1 << R[J]; v++) + $[te++] = J; + for (te >>= 7; J < n; J++) + for (G[J] = te << 7, v = 0; v < 1 << R[J] - 7; v++) + $[256 + te++] = J; + for (V = 0; V <= c; V++) + ee[V] = 0; + for (v = 0; v <= 143; ) + U[v * 2 + 1] = 8, v++, ee[8]++; + for (; v <= 255; ) + U[v * 2 + 1] = 9, v++, ee[9]++; + for (; v <= 279; ) + U[v * 2 + 1] = 7, v++, ee[7]++; + for (; v <= 287; ) + U[v * 2 + 1] = 8, v++, ee[8]++; + for (oe(U, r + 1, ee), v = 0; v < n; v++) + F[v * 2 + 1] = 5, F[v * 2] = we(v, 5); + j = new k(U, T, D + 1, r, c), Q = new k(F, R, 0, n, c), ie = new k(new Array(0), z, 0, b, a); + }, re = (v) => { + let V; + for (V = 0; V < r; V++) + v.dyn_ltree[V * 2] = 0; + for (V = 0; V < n; V++) + v.dyn_dtree[V * 2] = 0; + for (V = 0; V < b; V++) + v.bl_tree[V * 2] = 0; + v.dyn_ltree[h * 2] = 1, v.opt_len = v.static_len = 0, v.sym_next = v.matches = 0; + }, Se = (v) => { + v.bi_valid > 8 ? ue(v, v.bi_buf) : v.bi_valid > 0 && (v.pending_buf[v.pending++] = v.bi_buf), v.bi_buf = 0, v.bi_valid = 0; + }, ze = (v, V, O, J) => { + const te = V * 2, ee = O * 2; + return v[te] < v[ee] || v[te] === v[ee] && J[V] <= J[O]; + }, Ge = (v, V, O) => { + const J = v.heap[O]; + let te = O << 1; + for (; te <= v.heap_len && (te < v.heap_len && ze(V, v.heap[te + 1], v.heap[te], v.depth) && te++, !ze(V, J, v.heap[te], v.depth)); ) + v.heap[O] = v.heap[te], O = te, te <<= 1; + v.heap[O] = J; + }, $e = (v, V, O) => { + let J, te, ee = 0, Ce, be; + if (v.sym_next !== 0) + do + J = v.pending_buf[v.sym_buf + ee++] & 255, J += (v.pending_buf[v.sym_buf + ee++] & 255) << 8, te = v.pending_buf[v.sym_buf + ee++], J === 0 ? ae(v, te, V) : (Ce = W[te], ae(v, Ce + D + 1, V), be = T[Ce], be !== 0 && (te -= N[Ce], se(v, te, be)), J--, Ce = he(J), ae(v, Ce, O), be = R[Ce], be !== 0 && (J -= G[Ce], se(v, J, be))); + while (ee < v.sym_next); + ae(v, h, V); + }, Re = (v, V) => { + const O = V.dyn_tree, J = V.stat_desc.static_tree, te = V.stat_desc.has_stree, ee = V.stat_desc.elems; + let Ce, be, Xe = -1, de; + for (v.heap_len = 0, v.heap_max = f, Ce = 0; Ce < ee; Ce++) + O[Ce * 2] !== 0 ? (v.heap[++v.heap_len] = Xe = Ce, v.depth[Ce] = 0) : O[Ce * 2 + 1] = 0; + for (; v.heap_len < 2; ) + de = v.heap[++v.heap_len] = Xe < 2 ? ++Xe : 0, O[de * 2] = 1, v.depth[de] = 0, v.opt_len--, te && (v.static_len -= J[de * 2 + 1]); + for (V.max_code = Xe, Ce = v.heap_len >> 1; Ce >= 1; Ce--) + Ge(v, O, Ce); + de = ee; + do + Ce = v.heap[ + 1 + /*SMALLEST*/ + ], v.heap[ + 1 + /*SMALLEST*/ + ] = v.heap[v.heap_len--], Ge( + v, + O, + 1 + /*SMALLEST*/ + ), be = v.heap[ + 1 + /*SMALLEST*/ + ], v.heap[--v.heap_max] = Ce, v.heap[--v.heap_max] = be, O[de * 2] = O[Ce * 2] + O[be * 2], v.depth[de] = (v.depth[Ce] >= v.depth[be] ? v.depth[Ce] : v.depth[be]) + 1, O[Ce * 2 + 1] = O[be * 2 + 1] = de, v.heap[ + 1 + /*SMALLEST*/ + ] = de++, Ge( + v, + O, + 1 + /*SMALLEST*/ + ); + while (v.heap_len >= 2); + v.heap[--v.heap_max] = v.heap[ + 1 + /*SMALLEST*/ + ], Ie(v, V), oe(O, Xe, v.bl_count); + }, Be = (v, V, O) => { + let J, te = -1, ee, Ce = V[0 * 2 + 1], be = 0, Xe = 7, de = 4; + for (Ce === 0 && (Xe = 138, de = 3), V[(O + 1) * 2 + 1] = 65535, J = 0; J <= O; J++) + ee = Ce, Ce = V[(J + 1) * 2 + 1], !(++be < Xe && ee === Ce) && (be < de ? v.bl_tree[ee * 2] += be : ee !== 0 ? (ee !== te && v.bl_tree[ee * 2]++, v.bl_tree[M * 2]++) : be <= 10 ? v.bl_tree[w * 2]++ : v.bl_tree[S * 2]++, be = 0, te = ee, Ce === 0 ? (Xe = 138, de = 3) : ee === Ce ? (Xe = 6, de = 3) : (Xe = 7, de = 4)); + }, ke = (v, V, O) => { + let J, te = -1, ee, Ce = V[0 * 2 + 1], be = 0, Xe = 7, de = 4; + for (Ce === 0 && (Xe = 138, de = 3), J = 0; J <= O; J++) + if (ee = Ce, Ce = V[(J + 1) * 2 + 1], !(++be < Xe && ee === Ce)) { + if (be < de) + do + ae(v, ee, v.bl_tree); + while (--be !== 0); + else + ee !== 0 ? (ee !== te && (ae(v, ee, v.bl_tree), be--), ae(v, M, v.bl_tree), se(v, be - 3, 2)) : be <= 10 ? (ae(v, w, v.bl_tree), se(v, be - 3, 3)) : (ae(v, S, v.bl_tree), se(v, be - 11, 7)); + be = 0, te = ee, Ce === 0 ? (Xe = 138, de = 3) : ee === Ce ? (Xe = 6, de = 3) : (Xe = 7, de = 4); + } + }, We = (v) => { + let V; + for (Be(v, v.dyn_ltree, v.l_desc.max_code), Be(v, v.dyn_dtree, v.d_desc.max_code), Re(v, v.bl_desc), V = b - 1; V >= 3 && v.bl_tree[P[V] * 2 + 1] === 0; V--) + ; + return v.opt_len += 3 * (V + 1) + 5 + 5 + 4, V; + }, Te = (v, V, O, J) => { + let te; + for (se(v, V - 257, 5), se(v, O - 1, 5), se(v, J - 4, 4), te = 0; te < J; te++) + se(v, v.bl_tree[P[te] * 2 + 1], 3); + ke(v, v.dyn_ltree, V - 1), ke(v, v.dyn_dtree, O - 1); + }, je = (v) => { + let V = 4093624447, O; + for (O = 0; O <= 31; O++, V >>>= 1) + if (V & 1 && v.dyn_ltree[O * 2] !== 0) + return g; + if (v.dyn_ltree[9 * 2] !== 0 || v.dyn_ltree[10 * 2] !== 0 || v.dyn_ltree[13 * 2] !== 0) + return _; + for (O = 32; O < D; O++) + if (v.dyn_ltree[O * 2] !== 0) + return _; + return g; + }; + let Fe = !1; + const X = (v) => { + Fe || (ve(), Fe = !0), v.l_desc = new pe(v.dyn_ltree, j), v.d_desc = new pe(v.dyn_dtree, Q), v.bl_desc = new pe(v.bl_tree, ie), v.bi_buf = 0, v.bi_valid = 0, re(v); + }, Z = (v, V, O, J) => { + se(v, (p << 1) + (J ? 1 : 0), 3), Se(v), ue(v, O), ue(v, ~O), O && v.pending_buf.set(v.window.subarray(V, V + O), v.pending), v.pending += O; + }, q = (v) => { + se(v, E << 1, 3), ae(v, h, U), xe(v); + }, fe = (v, V, O, J) => { + let te, ee, Ce = 0; + v.level > 0 ? (v.strm.data_type === x && (v.strm.data_type = je(v)), Re(v, v.l_desc), Re(v, v.d_desc), Ce = We(v), te = v.opt_len + 3 + 7 >>> 3, ee = v.static_len + 3 + 7 >>> 3, ee <= te && (te = ee)) : te = ee = O + 5, O + 4 <= te && V !== -1 ? Z(v, V, O, J) : v.strategy === l || ee === te ? (se(v, (E << 1) + (J ? 1 : 0), 3), $e(v, U, F)) : (se(v, (u << 1) + (J ? 1 : 0), 3), Te(v, v.l_desc.max_code + 1, v.d_desc.max_code + 1, Ce + 1), $e(v, v.dyn_ltree, v.dyn_dtree)), re(v), J && Se(v); + }, _e = (v, V, O) => (v.pending_buf[v.sym_buf + v.sym_next++] = V, v.pending_buf[v.sym_buf + v.sym_next++] = V >> 8, v.pending_buf[v.sym_buf + v.sym_next++] = O, V === 0 ? v.dyn_ltree[O * 2]++ : (v.matches++, V--, v.dyn_ltree[(W[O] + D + 1) * 2]++, v.dyn_dtree[he(V) * 2]++), v.sym_next === v.sym_end); + var Me = X, Ae = Z, H = fe, ce = _e, ye = q, Pe = { + _tr_init: Me, + _tr_stored_block: Ae, + _tr_flush_block: H, + _tr_tally: ce, + _tr_align: ye + }, De = (v, V, O, J) => { + let te = v & 65535 | 0, ee = v >>> 16 & 65535 | 0, Ce = 0; + for (; O !== 0; ) { + Ce = O > 2e3 ? 2e3 : O, O -= Ce; + do + te = te + V[J++] | 0, ee = ee + te | 0; + while (--Ce); + te %= 65521, ee %= 65521; + } + return te | ee << 16 | 0; + }; + const K = () => { + let v, V = []; + for (var O = 0; O < 256; O++) { + v = O; + for (var J = 0; J < 8; J++) + v = v & 1 ? 3988292384 ^ v >>> 1 : v >>> 1; + V[O] = v; + } + return V; + }, Oe = new Uint32Array(K()); + var I = (v, V, O, J) => { + const te = Oe, ee = J + O; + v ^= -1; + for (let Ce = J; Ce < ee; Ce++) + v = v >>> 8 ^ te[(v ^ V[Ce]) & 255]; + return v ^ -1; + }, me = { + 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) */ + }, ge = { + /* 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: Y, _tr_stored_block: ne, _tr_flush_block: Ee, _tr_tally: He, _tr_align: Ke } = Pe, { + Z_NO_FLUSH: Ve, + Z_PARTIAL_FLUSH: qe, + Z_FULL_FLUSH: wt, + Z_FINISH: nt, + Z_BLOCK: rt, + Z_OK: tt, + Z_STREAM_END: yt, + Z_STREAM_ERROR: _t, + Z_DATA_ERROR: It, + Z_BUF_ERROR: Ot, + Z_DEFAULT_COMPRESSION: vt, + Z_FILTERED: mt, + Z_HUFFMAN_ONLY: gt, + Z_RLE: Ct, + Z_FIXED: Mt, + Z_DEFAULT_STRATEGY: Ft, + Z_UNKNOWN: hi, + Z_DEFLATED: Ut + } = ge, di = 9, ci = 15, ui = 8, Ci = 256 + 1 + 29, Qr = 30, Jr = 19, qr = 2 * Ci + 1, en = 15, at = 3, $t = 258, Tt = $t + at + 1, tn = 32, Kt = 42, Li = 57, Di = 69, Si = 73, Oi = 91, Ti = 103, Wt = 113, qt = 666, At = 1, Zt = 2, Gt = 3, Yt = 4, rn = 3, Nt = (v, V) => (v.msg = me[V], V), Vi = (v) => v * 2 - (v > 4 ? 9 : 0), Bt = (v) => { + let V = v.length; + for (; --V >= 0; ) + v[V] = 0; + }, nn = (v) => { + let V, O, J, te = v.w_size; + V = v.hash_size, J = V; + do + O = v.head[--J], v.head[J] = O >= te ? O - te : 0; + while (--V); + V = te, J = V; + do + O = v.prev[--J], v.prev[J] = O >= te ? O - te : 0; + while (--V); + }; + let kt = (v, V, O) => (V << v.hash_shift ^ O) & v.hash_mask; + const Lt = (v) => { + const V = v.state; + let O = V.pending; + O > v.avail_out && (O = v.avail_out), O !== 0 && (v.output.set(V.pending_buf.subarray(V.pending_out, V.pending_out + O), v.next_out), v.next_out += O, V.pending_out += O, v.total_out += O, v.avail_out -= O, V.pending -= O, V.pending === 0 && (V.pending_out = 0)); + }, Dt = (v, V) => { + Ee(v, v.block_start >= 0 ? v.block_start : -1, v.strstart - v.block_start, V), v.block_start = v.strstart, Lt(v.strm); + }, dt = (v, V) => { + v.pending_buf[v.pending++] = V; + }, ei = (v, V) => { + v.pending_buf[v.pending++] = V >>> 8 & 255, v.pending_buf[v.pending++] = V & 255; + }, Pi = (v, V, O, J) => { + let te = v.avail_in; + return te > J && (te = J), te === 0 ? 0 : (v.avail_in -= te, V.set(v.input.subarray(v.next_in, v.next_in + te), O), v.state.wrap === 1 ? v.adler = De(v.adler, V, te, O) : v.state.wrap === 2 && (v.adler = I(v.adler, V, te, O)), v.next_in += te, v.total_in += te, te); + }, ji = (v, V) => { + let O = v.max_chain_length, J = v.strstart, te, ee, Ce = v.prev_length, be = v.nice_match; + const Xe = v.strstart > v.w_size - Tt ? v.strstart - (v.w_size - Tt) : 0, de = v.window, Le = v.w_mask, ht = v.prev, Ye = v.strstart + $t; + let Ue = de[J + Ce - 1], Qe = de[J + Ce]; + v.prev_length >= v.good_match && (O >>= 2), be > v.lookahead && (be = v.lookahead); + do + if (te = V, !(de[te + Ce] !== Qe || de[te + Ce - 1] !== Ue || de[te] !== de[J] || de[++te] !== de[J + 1])) { + J += 2, te++; + do + ; + while (de[++J] === de[++te] && de[++J] === de[++te] && de[++J] === de[++te] && de[++J] === de[++te] && de[++J] === de[++te] && de[++J] === de[++te] && de[++J] === de[++te] && de[++J] === de[++te] && J < Ye); + if (ee = $t - (Ye - J), J = Ye - $t, ee > Ce) { + if (v.match_start = V, Ce = ee, ee >= be) + break; + Ue = de[J + Ce - 1], Qe = de[J + Ce]; + } + } + while ((V = ht[V & Le]) > Xe && --O !== 0); + return Ce <= v.lookahead ? Ce : v.lookahead; + }, Xt = (v) => { + const V = v.w_size; + let O, J, te; + do { + if (J = v.window_size - v.lookahead - v.strstart, v.strstart >= V + (V - Tt) && (v.window.set(v.window.subarray(V, V + V - J), 0), v.match_start -= V, v.strstart -= V, v.block_start -= V, v.insert > v.strstart && (v.insert = v.strstart), nn(v), J += V), v.strm.avail_in === 0) + break; + if (O = Pi(v.strm, v.window, v.strstart + v.lookahead, J), v.lookahead += O, v.lookahead + v.insert >= at) + for (te = v.strstart - v.insert, v.ins_h = v.window[te], v.ins_h = kt(v, v.ins_h, v.window[te + 1]); v.insert && (v.ins_h = kt(v, v.ins_h, v.window[te + at - 1]), v.prev[te & v.w_mask] = v.head[v.ins_h], v.head[v.ins_h] = te, te++, v.insert--, !(v.lookahead + v.insert < at)); ) + ; + } while (v.lookahead < Tt && v.strm.avail_in !== 0); + }, Hi = (v, V) => { + let O = v.pending_buf_size - 5 > v.w_size ? v.w_size : v.pending_buf_size - 5, J, te, ee, Ce = 0, be = v.strm.avail_in; + do { + if (J = 65535, ee = v.bi_valid + 42 >> 3, v.strm.avail_out < ee || (ee = v.strm.avail_out - ee, te = v.strstart - v.block_start, J > te + v.strm.avail_in && (J = te + v.strm.avail_in), J > ee && (J = ee), J < O && (J === 0 && V !== nt || V === Ve || J !== te + v.strm.avail_in))) + break; + Ce = V === nt && J === te + v.strm.avail_in ? 1 : 0, ne(v, 0, 0, Ce), v.pending_buf[v.pending - 4] = J, v.pending_buf[v.pending - 3] = J >> 8, v.pending_buf[v.pending - 2] = ~J, v.pending_buf[v.pending - 1] = ~J >> 8, Lt(v.strm), te && (te > J && (te = J), v.strm.output.set(v.window.subarray(v.block_start, v.block_start + te), v.strm.next_out), v.strm.next_out += te, v.strm.avail_out -= te, v.strm.total_out += te, v.block_start += te, J -= te), J && (Pi(v.strm, v.strm.output, v.strm.next_out, J), v.strm.next_out += J, v.strm.avail_out -= J, v.strm.total_out += J); + } while (Ce === 0); + return be -= v.strm.avail_in, be && (be >= v.w_size ? (v.matches = 2, v.window.set(v.strm.input.subarray(v.strm.next_in - v.w_size, v.strm.next_in), 0), v.strstart = v.w_size, v.insert = v.strstart) : (v.window_size - v.strstart <= be && (v.strstart -= v.w_size, v.window.set(v.window.subarray(v.w_size, v.w_size + v.strstart), 0), v.matches < 2 && v.matches++, v.insert > v.strstart && (v.insert = v.strstart)), v.window.set(v.strm.input.subarray(v.strm.next_in - be, v.strm.next_in), v.strstart), v.strstart += be, v.insert += be > v.w_size - v.insert ? v.w_size - v.insert : be), v.block_start = v.strstart), v.high_water < v.strstart && (v.high_water = v.strstart), Ce ? Yt : V !== Ve && V !== nt && v.strm.avail_in === 0 && v.strstart === v.block_start ? Zt : (ee = v.window_size - v.strstart, v.strm.avail_in > ee && v.block_start >= v.w_size && (v.block_start -= v.w_size, v.strstart -= v.w_size, v.window.set(v.window.subarray(v.w_size, v.w_size + v.strstart), 0), v.matches < 2 && v.matches++, ee += v.w_size, v.insert > v.strstart && (v.insert = v.strstart)), ee > v.strm.avail_in && (ee = v.strm.avail_in), ee && (Pi(v.strm, v.window, v.strstart, ee), v.strstart += ee, v.insert += ee > v.w_size - v.insert ? v.w_size - v.insert : ee), v.high_water < v.strstart && (v.high_water = v.strstart), ee = v.bi_valid + 42 >> 3, ee = v.pending_buf_size - ee > 65535 ? 65535 : v.pending_buf_size - ee, O = ee > v.w_size ? v.w_size : ee, te = v.strstart - v.block_start, (te >= O || (te || V === nt) && V !== Ve && v.strm.avail_in === 0 && te <= ee) && (J = te > ee ? ee : te, Ce = V === nt && v.strm.avail_in === 0 && J === te ? 1 : 0, ne(v, v.block_start, J, Ce), v.block_start += J, Lt(v.strm)), Ce ? Gt : At); + }, Ii = (v, V) => { + let O, J; + for (; ; ) { + if (v.lookahead < Tt) { + if (Xt(v), v.lookahead < Tt && V === Ve) + return At; + if (v.lookahead === 0) + break; + } + if (O = 0, v.lookahead >= at && (v.ins_h = kt(v, v.ins_h, v.window[v.strstart + at - 1]), O = v.prev[v.strstart & v.w_mask] = v.head[v.ins_h], v.head[v.ins_h] = v.strstart), O !== 0 && v.strstart - O <= v.w_size - Tt && (v.match_length = ji(v, O)), v.match_length >= at) + if (J = He(v, v.strstart - v.match_start, v.match_length - at), v.lookahead -= v.match_length, v.match_length <= v.max_lazy_match && v.lookahead >= at) { + v.match_length--; + do + v.strstart++, v.ins_h = kt(v, v.ins_h, v.window[v.strstart + at - 1]), O = v.prev[v.strstart & v.w_mask] = v.head[v.ins_h], v.head[v.ins_h] = v.strstart; + while (--v.match_length !== 0); + v.strstart++; + } else + v.strstart += v.match_length, v.match_length = 0, v.ins_h = v.window[v.strstart], v.ins_h = kt(v, v.ins_h, v.window[v.strstart + 1]); + else + J = He(v, 0, v.window[v.strstart]), v.lookahead--, v.strstart++; + if (J && (Dt(v, !1), v.strm.avail_out === 0)) + return At; + } + return v.insert = v.strstart < at - 1 ? v.strstart : at - 1, V === nt ? (Dt(v, !0), v.strm.avail_out === 0 ? Gt : Yt) : v.sym_next && (Dt(v, !1), v.strm.avail_out === 0) ? At : Zt; + }, Qt = (v, V) => { + let O, J, te; + for (; ; ) { + if (v.lookahead < Tt) { + if (Xt(v), v.lookahead < Tt && V === Ve) + return At; + if (v.lookahead === 0) + break; + } + if (O = 0, v.lookahead >= at && (v.ins_h = kt(v, v.ins_h, v.window[v.strstart + at - 1]), O = v.prev[v.strstart & v.w_mask] = v.head[v.ins_h], v.head[v.ins_h] = v.strstart), v.prev_length = v.match_length, v.prev_match = v.match_start, v.match_length = at - 1, O !== 0 && v.prev_length < v.max_lazy_match && v.strstart - O <= v.w_size - Tt && (v.match_length = ji(v, O), v.match_length <= 5 && (v.strategy === mt || v.match_length === at && v.strstart - v.match_start > 4096) && (v.match_length = at - 1)), v.prev_length >= at && v.match_length <= v.prev_length) { + te = v.strstart + v.lookahead - at, J = He(v, v.strstart - 1 - v.prev_match, v.prev_length - at), v.lookahead -= v.prev_length - 1, v.prev_length -= 2; + do + ++v.strstart <= te && (v.ins_h = kt(v, v.ins_h, v.window[v.strstart + at - 1]), O = v.prev[v.strstart & v.w_mask] = v.head[v.ins_h], v.head[v.ins_h] = v.strstart); + while (--v.prev_length !== 0); + if (v.match_available = 0, v.match_length = at - 1, v.strstart++, J && (Dt(v, !1), v.strm.avail_out === 0)) + return At; + } else if (v.match_available) { + if (J = He(v, 0, v.window[v.strstart - 1]), J && Dt(v, !1), v.strstart++, v.lookahead--, v.strm.avail_out === 0) + return At; + } else + v.match_available = 1, v.strstart++, v.lookahead--; + } + return v.match_available && (J = He(v, 0, v.window[v.strstart - 1]), v.match_available = 0), v.insert = v.strstart < at - 1 ? v.strstart : at - 1, V === nt ? (Dt(v, !0), v.strm.avail_out === 0 ? Gt : Yt) : v.sym_next && (Dt(v, !1), v.strm.avail_out === 0) ? At : Zt; + }, sn = (v, V) => { + let O, J, te, ee; + const Ce = v.window; + for (; ; ) { + if (v.lookahead <= $t) { + if (Xt(v), v.lookahead <= $t && V === Ve) + return At; + if (v.lookahead === 0) + break; + } + if (v.match_length = 0, v.lookahead >= at && v.strstart > 0 && (te = v.strstart - 1, J = Ce[te], J === Ce[++te] && J === Ce[++te] && J === Ce[++te])) { + ee = v.strstart + $t; + do + ; + while (J === Ce[++te] && J === Ce[++te] && J === Ce[++te] && J === Ce[++te] && J === Ce[++te] && J === Ce[++te] && J === Ce[++te] && J === Ce[++te] && te < ee); + v.match_length = $t - (ee - te), v.match_length > v.lookahead && (v.match_length = v.lookahead); + } + if (v.match_length >= at ? (O = He(v, 1, v.match_length - at), v.lookahead -= v.match_length, v.strstart += v.match_length, v.match_length = 0) : (O = He(v, 0, v.window[v.strstart]), v.lookahead--, v.strstart++), O && (Dt(v, !1), v.strm.avail_out === 0)) + return At; + } + return v.insert = 0, V === nt ? (Dt(v, !0), v.strm.avail_out === 0 ? Gt : Yt) : v.sym_next && (Dt(v, !1), v.strm.avail_out === 0) ? At : Zt; + }, an = (v, V) => { + let O; + for (; ; ) { + if (v.lookahead === 0 && (Xt(v), v.lookahead === 0)) { + if (V === Ve) + return At; + break; + } + if (v.match_length = 0, O = He(v, 0, v.window[v.strstart]), v.lookahead--, v.strstart++, O && (Dt(v, !1), v.strm.avail_out === 0)) + return At; + } + return v.insert = 0, V === nt ? (Dt(v, !0), v.strm.avail_out === 0 ? Gt : Yt) : v.sym_next && (Dt(v, !1), v.strm.avail_out === 0) ? At : Zt; + }; + function Pt(v, V, O, J, te) { + this.good_length = v, this.max_lazy = V, this.nice_length = O, this.max_chain = J, this.func = te; + } + const ti = [ + /* good lazy nice chain */ + new Pt(0, 0, 0, 0, Hi), + /* 0 store only */ + new Pt(4, 4, 8, 4, Ii), + /* 1 max speed, no lazy matches */ + new Pt(4, 5, 16, 8, Ii), + /* 2 */ + new Pt(4, 6, 32, 32, Ii), + /* 3 */ + new Pt(4, 4, 16, 16, Qt), + /* 4 lazy matches */ + new Pt(8, 16, 32, 32, Qt), + /* 5 */ + new Pt(8, 16, 128, 128, Qt), + /* 6 */ + new Pt(8, 32, 128, 256, Qt), + /* 7 */ + new Pt(32, 128, 258, 1024, Qt), + /* 8 */ + new Pt(32, 258, 258, 4096, Qt) + /* 9 max compression */ + ], ln = (v) => { + v.window_size = 2 * v.w_size, Bt(v.head), v.max_lazy_match = ti[v.level].max_lazy, v.good_match = ti[v.level].good_length, v.nice_match = ti[v.level].nice_length, v.max_chain_length = ti[v.level].max_chain, v.strstart = 0, v.block_start = 0, v.lookahead = 0, v.insert = 0, v.match_length = v.prev_length = at - 1, v.match_available = 0, v.ins_h = 0; + }; + function on() { + 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 = Ut, 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(qr * 2), this.dyn_dtree = new Uint16Array((2 * Qr + 1) * 2), this.bl_tree = new Uint16Array((2 * Jr + 1) * 2), Bt(this.dyn_ltree), Bt(this.dyn_dtree), Bt(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new Uint16Array(en + 1), this.heap = new Uint16Array(2 * Ci + 1), Bt(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new Uint16Array(2 * Ci + 1), Bt(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 ii = (v) => { + if (!v) + return 1; + const V = v.state; + return !V || V.strm !== v || V.status !== Kt && //#ifdef GZIP + V.status !== Li && //#endif + V.status !== Di && V.status !== Si && V.status !== Oi && V.status !== Ti && V.status !== Wt && V.status !== qt ? 1 : 0; + }, Ki = (v) => { + if (ii(v)) + return Nt(v, _t); + v.total_in = v.total_out = 0, v.data_type = hi; + const V = v.state; + return V.pending = 0, V.pending_out = 0, V.wrap < 0 && (V.wrap = -V.wrap), V.status = //#ifdef GZIP + V.wrap === 2 ? Li : ( + //#endif + V.wrap ? Kt : Wt + ), v.adler = V.wrap === 2 ? 0 : 1, V.last_flush = -2, Y(V), tt; + }, Zi = (v) => { + const V = Ki(v); + return V === tt && ln(v.state), V; + }, fn = (v, V) => ii(v) || v.state.wrap !== 2 ? _t : (v.state.gzhead = V, tt), Yi = (v, V, O, J, te, ee) => { + if (!v) + return _t; + let Ce = 1; + if (V === vt && (V = 6), J < 0 ? (Ce = 0, J = -J) : J > 15 && (Ce = 2, J -= 16), te < 1 || te > di || O !== Ut || J < 8 || J > 15 || V < 0 || V > 9 || ee < 0 || ee > Mt || J === 8 && Ce !== 1) + return Nt(v, _t); + J === 8 && (J = 9); + const be = new on(); + return v.state = be, be.strm = v, be.status = Kt, be.wrap = Ce, be.gzhead = null, be.w_bits = J, be.w_size = 1 << be.w_bits, be.w_mask = be.w_size - 1, be.hash_bits = te + 7, be.hash_size = 1 << be.hash_bits, be.hash_mask = be.hash_size - 1, be.hash_shift = ~~((be.hash_bits + at - 1) / at), be.window = new Uint8Array(be.w_size * 2), be.head = new Uint16Array(be.hash_size), be.prev = new Uint16Array(be.w_size), be.lit_bufsize = 1 << te + 6, be.pending_buf_size = be.lit_bufsize * 4, be.pending_buf = new Uint8Array(be.pending_buf_size), be.sym_buf = be.lit_bufsize, be.sym_end = (be.lit_bufsize - 1) * 3, be.level = V, be.strategy = ee, be.method = O, Zi(v); + }, hn = (v, V) => Yi(v, V, Ut, ci, ui, Ft), dn = (v, V) => { + if (ii(v) || V > rt || V < 0) + return v ? Nt(v, _t) : _t; + const O = v.state; + if (!v.output || v.avail_in !== 0 && !v.input || O.status === qt && V !== nt) + return Nt(v, v.avail_out === 0 ? Ot : _t); + const J = O.last_flush; + if (O.last_flush = V, O.pending !== 0) { + if (Lt(v), v.avail_out === 0) + return O.last_flush = -1, tt; + } else if (v.avail_in === 0 && Vi(V) <= Vi(J) && V !== nt) + return Nt(v, Ot); + if (O.status === qt && v.avail_in !== 0) + return Nt(v, Ot); + if (O.status === Kt && O.wrap === 0 && (O.status = Wt), O.status === Kt) { + let te = Ut + (O.w_bits - 8 << 4) << 8, ee = -1; + if (O.strategy >= gt || O.level < 2 ? ee = 0 : O.level < 6 ? ee = 1 : O.level === 6 ? ee = 2 : ee = 3, te |= ee << 6, O.strstart !== 0 && (te |= tn), te += 31 - te % 31, ei(O, te), O.strstart !== 0 && (ei(O, v.adler >>> 16), ei(O, v.adler & 65535)), v.adler = 1, O.status = Wt, Lt(v), O.pending !== 0) + return O.last_flush = -1, tt; + } + if (O.status === Li) { + if (v.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 >= gt || 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 && (v.adler = I(v.adler, O.pending_buf, O.pending, 0)), O.gzindex = 0, O.status = Di; + 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 >= gt || O.level < 2 ? 4 : 0), dt(O, rn), O.status = Wt, Lt(v), O.pending !== 0) + return O.last_flush = -1, tt; + } + if (O.status === Di) { + if (O.gzhead.extra) { + let te = O.pending, ee = (O.gzhead.extra.length & 65535) - O.gzindex; + for (; O.pending + ee > O.pending_buf_size; ) { + let be = O.pending_buf_size - O.pending; + if (O.pending_buf.set(O.gzhead.extra.subarray(O.gzindex, O.gzindex + be), O.pending), O.pending = O.pending_buf_size, O.gzhead.hcrc && O.pending > te && (v.adler = I(v.adler, O.pending_buf, O.pending - te, te)), O.gzindex += be, Lt(v), O.pending !== 0) + return O.last_flush = -1, tt; + te = 0, ee -= be; + } + let Ce = new Uint8Array(O.gzhead.extra); + O.pending_buf.set(Ce.subarray(O.gzindex, O.gzindex + ee), O.pending), O.pending += ee, O.gzhead.hcrc && O.pending > te && (v.adler = I(v.adler, O.pending_buf, O.pending - te, te)), O.gzindex = 0; + } + O.status = Si; + } + if (O.status === Si) { + if (O.gzhead.name) { + let te = O.pending, ee; + do { + if (O.pending === O.pending_buf_size) { + if (O.gzhead.hcrc && O.pending > te && (v.adler = I(v.adler, O.pending_buf, O.pending - te, te)), Lt(v), O.pending !== 0) + return O.last_flush = -1, tt; + te = 0; + } + O.gzindex < O.gzhead.name.length ? ee = O.gzhead.name.charCodeAt(O.gzindex++) & 255 : ee = 0, dt(O, ee); + } while (ee !== 0); + O.gzhead.hcrc && O.pending > te && (v.adler = I(v.adler, O.pending_buf, O.pending - te, te)), O.gzindex = 0; + } + O.status = Oi; + } + if (O.status === Oi) { + if (O.gzhead.comment) { + let te = O.pending, ee; + do { + if (O.pending === O.pending_buf_size) { + if (O.gzhead.hcrc && O.pending > te && (v.adler = I(v.adler, O.pending_buf, O.pending - te, te)), Lt(v), O.pending !== 0) + return O.last_flush = -1, tt; + te = 0; + } + O.gzindex < O.gzhead.comment.length ? ee = O.gzhead.comment.charCodeAt(O.gzindex++) & 255 : ee = 0, dt(O, ee); + } while (ee !== 0); + O.gzhead.hcrc && O.pending > te && (v.adler = I(v.adler, O.pending_buf, O.pending - te, te)); + } + O.status = Ti; + } + if (O.status === Ti) { + if (O.gzhead.hcrc) { + if (O.pending + 2 > O.pending_buf_size && (Lt(v), O.pending !== 0)) + return O.last_flush = -1, tt; + dt(O, v.adler & 255), dt(O, v.adler >> 8 & 255), v.adler = 0; + } + if (O.status = Wt, Lt(v), O.pending !== 0) + return O.last_flush = -1, tt; + } + if (v.avail_in !== 0 || O.lookahead !== 0 || V !== Ve && O.status !== qt) { + let te = O.level === 0 ? Hi(O, V) : O.strategy === gt ? an(O, V) : O.strategy === Ct ? sn(O, V) : ti[O.level].func(O, V); + if ((te === Gt || te === Yt) && (O.status = qt), te === At || te === Gt) + return v.avail_out === 0 && (O.last_flush = -1), tt; + if (te === Zt && (V === qe ? Ke(O) : V !== rt && (ne(O, 0, 0, !1), V === wt && (Bt(O.head), O.lookahead === 0 && (O.strstart = 0, O.block_start = 0, O.insert = 0))), Lt(v), v.avail_out === 0)) + return O.last_flush = -1, tt; + } + return V !== nt ? tt : O.wrap <= 0 ? yt : (O.wrap === 2 ? (dt(O, v.adler & 255), dt(O, v.adler >> 8 & 255), dt(O, v.adler >> 16 & 255), dt(O, v.adler >> 24 & 255), dt(O, v.total_in & 255), dt(O, v.total_in >> 8 & 255), dt(O, v.total_in >> 16 & 255), dt(O, v.total_in >> 24 & 255)) : (ei(O, v.adler >>> 16), ei(O, v.adler & 65535)), Lt(v), O.wrap > 0 && (O.wrap = -O.wrap), O.pending !== 0 ? tt : yt); + }, cn = (v) => { + if (ii(v)) + return _t; + const V = v.state.status; + return v.state = null, V === Wt ? Nt(v, It) : tt; + }, un = (v, V) => { + let O = V.length; + if (ii(v)) + return _t; + const J = v.state, te = J.wrap; + if (te === 2 || te === 1 && J.status !== Kt || J.lookahead) + return _t; + if (te === 1 && (v.adler = De(v.adler, V, O, 0)), J.wrap = 0, O >= J.w_size) { + te === 0 && (Bt(J.head), J.strstart = 0, J.block_start = 0, J.insert = 0); + let Xe = new Uint8Array(J.w_size); + Xe.set(V.subarray(O - J.w_size, O), 0), V = Xe, O = J.w_size; + } + const ee = v.avail_in, Ce = v.next_in, be = v.input; + for (v.avail_in = O, v.next_in = 0, v.input = V, Xt(J); J.lookahead >= at; ) { + let Xe = J.strstart, de = J.lookahead - (at - 1); + do + J.ins_h = kt(J, J.ins_h, J.window[Xe + at - 1]), J.prev[Xe & J.w_mask] = J.head[J.ins_h], J.head[J.ins_h] = Xe, Xe++; + while (--de); + J.strstart = Xe, J.lookahead = at - 1, Xt(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, v.next_in = Ce, v.input = be, v.avail_in = ee, J.wrap = te, tt; + }; + var _n = hn, gn = Yi, pn = Zi, vn = Ki, mn = fn, bn = dn, xn = cn, yn = un, wn = "pako deflate (from Nodeca project)", ri = { + deflateInit: _n, + deflateInit2: gn, + deflateReset: pn, + deflateResetKeep: vn, + deflateSetHeader: mn, + deflate: bn, + deflateEnd: xn, + deflateSetDictionary: yn, + deflateInfo: wn + }; + const En = (v, V) => Object.prototype.hasOwnProperty.call(v, V); + var Mn = function(v) { + const V = Array.prototype.slice.call(arguments, 1); + for (; V.length; ) { + const O = V.shift(); + if (O) { + if (typeof O != "object") + throw new TypeError(O + "must be non-object"); + for (const J in O) + En(O, J) && (v[J] = O[J]); + } + } + return v; + }, An = (v) => { + let V = 0; + for (let J = 0, te = v.length; J < te; J++) + V += v[J].length; + const O = new Uint8Array(V); + for (let J = 0, te = 0, ee = v.length; J < ee; J++) { + let Ce = v[J]; + O.set(Ce, te), te += Ce.length; + } + return O; + }, pi = { + assign: Mn, + flattenChunks: An + }; + let Xi = !0; + try { + String.fromCharCode.apply(null, new Uint8Array(1)); + } catch { + Xi = !1; + } + const ni = new Uint8Array(256); + for (let v = 0; v < 256; v++) + ni[v] = v >= 252 ? 6 : v >= 248 ? 5 : v >= 240 ? 4 : v >= 224 ? 3 : v >= 192 ? 2 : 1; + ni[254] = ni[254] = 1; + var Cn = (v) => { + if (typeof TextEncoder == "function" && TextEncoder.prototype.encode) + return new TextEncoder().encode(v); + let V, O, J, te, ee, Ce = v.length, be = 0; + for (te = 0; te < Ce; te++) + O = v.charCodeAt(te), (O & 64512) === 55296 && te + 1 < Ce && (J = v.charCodeAt(te + 1), (J & 64512) === 56320 && (O = 65536 + (O - 55296 << 10) + (J - 56320), te++)), be += O < 128 ? 1 : O < 2048 ? 2 : O < 65536 ? 3 : 4; + for (V = new Uint8Array(be), ee = 0, te = 0; ee < be; te++) + O = v.charCodeAt(te), (O & 64512) === 55296 && te + 1 < Ce && (J = v.charCodeAt(te + 1), (J & 64512) === 56320 && (O = 65536 + (O - 55296 << 10) + (J - 56320), te++)), O < 128 ? V[ee++] = O : O < 2048 ? (V[ee++] = 192 | O >>> 6, V[ee++] = 128 | O & 63) : O < 65536 ? (V[ee++] = 224 | O >>> 12, V[ee++] = 128 | O >>> 6 & 63, V[ee++] = 128 | O & 63) : (V[ee++] = 240 | O >>> 18, V[ee++] = 128 | O >>> 12 & 63, V[ee++] = 128 | O >>> 6 & 63, V[ee++] = 128 | O & 63); + return V; + }; + const Ln = (v, V) => { + if (V < 65534 && v.subarray && Xi) + return String.fromCharCode.apply(null, v.length === V ? v : v.subarray(0, V)); + let O = ""; + for (let J = 0; J < V; J++) + O += String.fromCharCode(v[J]); + return O; + }; + var Dn = (v, V) => { + const O = V || v.length; + if (typeof TextDecoder == "function" && TextDecoder.prototype.decode) + return new TextDecoder().decode(v.subarray(0, V)); + let J, te; + const ee = new Array(O * 2); + for (te = 0, J = 0; J < O; ) { + let Ce = v[J++]; + if (Ce < 128) { + ee[te++] = Ce; + continue; + } + let be = ni[Ce]; + if (be > 4) { + ee[te++] = 65533, J += be - 1; + continue; + } + for (Ce &= be === 2 ? 31 : be === 3 ? 15 : 7; be > 1 && J < O; ) + Ce = Ce << 6 | v[J++] & 63, be--; + if (be > 1) { + ee[te++] = 65533; + continue; + } + Ce < 65536 ? ee[te++] = Ce : (Ce -= 65536, ee[te++] = 55296 | Ce >> 10 & 1023, ee[te++] = 56320 | Ce & 1023); + } + return Ln(ee, te); + }, Sn = (v, V) => { + V = V || v.length, V > v.length && (V = v.length); + let O = V - 1; + for (; O >= 0 && (v[O] & 192) === 128; ) + O--; + return O < 0 || O === 0 ? V : O + ni[v[O]] > V ? O : V; + }, si = { + string2buf: Cn, + buf2string: Dn, + utf8border: Sn + }; + function On() { + 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 Qi = On; + const Ji = Object.prototype.toString, { + Z_NO_FLUSH: Tn, + Z_SYNC_FLUSH: Pn, + Z_FULL_FLUSH: In, + Z_FINISH: Rn, + Z_OK: vi, + Z_STREAM_END: zn, + Z_DEFAULT_COMPRESSION: $n, + Z_DEFAULT_STRATEGY: Bn, + Z_DEFLATED: kn + } = ge; + function ai(v) { + this.options = pi.assign({ + level: $n, + method: kn, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: Bn + }, v || {}); + let V = this.options; + V.raw && V.windowBits > 0 ? V.windowBits = -V.windowBits : V.gzip && V.windowBits > 0 && V.windowBits < 16 && (V.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new Qi(), this.strm.avail_out = 0; + let O = ri.deflateInit2( + this.strm, + V.level, + V.method, + V.windowBits, + V.memLevel, + V.strategy + ); + if (O !== vi) + throw new Error(me[O]); + if (V.header && ri.deflateSetHeader(this.strm, V.header), V.dictionary) { + let J; + if (typeof V.dictionary == "string" ? J = si.string2buf(V.dictionary) : Ji.call(V.dictionary) === "[object ArrayBuffer]" ? J = new Uint8Array(V.dictionary) : J = V.dictionary, O = ri.deflateSetDictionary(this.strm, J), O !== vi) + throw new Error(me[O]); + this._dict_set = !0; + } + } + ai.prototype.push = function(v, V) { + const O = this.strm, J = this.options.chunkSize; + let te, ee; + if (this.ended) + return !1; + for (V === ~~V ? ee = V : ee = V === !0 ? Rn : Tn, typeof v == "string" ? O.input = si.string2buf(v) : Ji.call(v) === "[object ArrayBuffer]" ? O.input = new Uint8Array(v) : O.input = v, 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), (ee === Pn || ee === In) && O.avail_out <= 6) { + this.onData(O.output.subarray(0, O.next_out)), O.avail_out = 0; + continue; + } + if (te = ri.deflate(O, ee), te === zn) + return O.next_out > 0 && this.onData(O.output.subarray(0, O.next_out)), te = ri.deflateEnd(this.strm), this.onEnd(te), this.ended = !0, te === vi; + if (O.avail_out === 0) { + this.onData(O.output); + continue; + } + if (ee > 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; + }, ai.prototype.onData = function(v) { + this.chunks.push(v); + }, ai.prototype.onEnd = function(v) { + v === vi && (this.result = pi.flattenChunks(this.chunks)), this.chunks = [], this.err = v, this.msg = this.strm.msg; + }; + function Ri(v, V) { + const O = new ai(V); + if (O.push(v, !0), O.err) + throw O.msg || me[O.err]; + return O.result; + } + function Fn(v, V) { + return V = V || {}, V.raw = !0, Ri(v, V); + } + function Un(v, V) { + return V = V || {}, V.gzip = !0, Ri(v, V); + } + var Wn = ai, Gn = Ri, Nn = Fn, Vn = Un, jn = ge, Hn = { + Deflate: Wn, + deflate: Gn, + deflateRaw: Nn, + gzip: Vn, + constants: jn + }; + const mi = 16209, Kn = 16191; + var Zn = function(V, O) { + let J, te, ee, Ce, be, Xe, de, Le, ht, Ye, Ue, Qe, xt, ot, it, ut, st, Ze, ct, Et, Je, pt, ft, et; + const lt = V.state; + J = V.next_in, ft = V.input, te = J + (V.avail_in - 5), ee = V.next_out, et = V.output, Ce = ee - (O - V.avail_out), be = ee + (V.avail_out - 257), Xe = lt.dmax, de = lt.wsize, Le = lt.whave, ht = lt.wnext, Ye = lt.window, Ue = lt.hold, Qe = lt.bits, xt = lt.lencode, ot = lt.distcode, it = (1 << lt.lenbits) - 1, ut = (1 << lt.distbits) - 1; + e: + do { + Qe < 15 && (Ue += ft[J++] << Qe, Qe += 8, Ue += ft[J++] << Qe, Qe += 8), st = xt[Ue & it]; + t: + for (; ; ) { + if (Ze = st >>> 24, Ue >>>= Ze, Qe -= Ze, Ze = st >>> 16 & 255, Ze === 0) + et[ee++] = st & 65535; + else if (Ze & 16) { + ct = st & 65535, Ze &= 15, Ze && (Qe < Ze && (Ue += ft[J++] << Qe, Qe += 8), ct += Ue & (1 << Ze) - 1, Ue >>>= Ze, Qe -= Ze), Qe < 15 && (Ue += ft[J++] << Qe, Qe += 8, Ue += ft[J++] << Qe, Qe += 8), st = ot[Ue & ut]; + i: + for (; ; ) { + if (Ze = st >>> 24, Ue >>>= Ze, Qe -= Ze, Ze = st >>> 16 & 255, Ze & 16) { + if (Et = st & 65535, Ze &= 15, Qe < Ze && (Ue += ft[J++] << Qe, Qe += 8, Qe < Ze && (Ue += ft[J++] << Qe, Qe += 8)), Et += Ue & (1 << Ze) - 1, Et > Xe) { + V.msg = "invalid distance too far back", lt.mode = mi; + break e; + } + if (Ue >>>= Ze, Qe -= Ze, Ze = ee - Ce, Et > Ze) { + if (Ze = Et - Ze, Ze > Le && lt.sane) { + V.msg = "invalid distance too far back", lt.mode = mi; + break e; + } + if (Je = 0, pt = Ye, ht === 0) { + if (Je += de - Ze, Ze < ct) { + ct -= Ze; + do + et[ee++] = Ye[Je++]; + while (--Ze); + Je = ee - Et, pt = et; + } + } else if (ht < Ze) { + if (Je += de + ht - Ze, Ze -= ht, Ze < ct) { + ct -= Ze; + do + et[ee++] = Ye[Je++]; + while (--Ze); + if (Je = 0, ht < ct) { + Ze = ht, ct -= Ze; + do + et[ee++] = Ye[Je++]; + while (--Ze); + Je = ee - Et, pt = et; + } + } + } else if (Je += ht - Ze, Ze < ct) { + ct -= Ze; + do + et[ee++] = Ye[Je++]; + while (--Ze); + Je = ee - Et, pt = et; + } + for (; ct > 2; ) + et[ee++] = pt[Je++], et[ee++] = pt[Je++], et[ee++] = pt[Je++], ct -= 3; + ct && (et[ee++] = pt[Je++], ct > 1 && (et[ee++] = pt[Je++])); + } else { + Je = ee - Et; + do + et[ee++] = et[Je++], et[ee++] = et[Je++], et[ee++] = et[Je++], ct -= 3; + while (ct > 2); + ct && (et[ee++] = et[Je++], ct > 1 && (et[ee++] = et[Je++])); + } + } else if (Ze & 64) { + V.msg = "invalid distance code", lt.mode = mi; + break e; + } else { + st = ot[(st & 65535) + (Ue & (1 << Ze) - 1)]; + continue i; + } + break; + } + } else if (Ze & 64) + if (Ze & 32) { + lt.mode = Kn; + break e; + } else { + V.msg = "invalid literal/length code", lt.mode = mi; + break e; + } + else { + st = xt[(st & 65535) + (Ue & (1 << Ze) - 1)]; + continue t; + } + break; + } + } while (J < te && ee < be); + ct = Qe >> 3, J -= ct, Qe -= ct << 3, Ue &= (1 << Qe) - 1, V.next_in = J, V.next_out = ee, V.avail_in = J < te ? 5 + (te - J) : 5 - (J - te), V.avail_out = ee < be ? 257 + (be - ee) : 257 - (ee - be), lt.hold = Ue, lt.bits = Qe; + }; + const Jt = 15, qi = 852, er = 592, tr = 0, zi = 1, ir = 2, Yn = 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 + ]), Xn = 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 + ]), Jn = 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 li = (v, V, O, J, te, ee, Ce, be) => { + const Xe = be.bits; + let de = 0, Le = 0, ht = 0, Ye = 0, Ue = 0, Qe = 0, xt = 0, ot = 0, it = 0, ut = 0, st, Ze, ct, Et, Je, pt = null, ft; + const et = new Uint16Array(Jt + 1), lt = new Uint16Array(Jt + 1); + let Ht = null, Xr, Mi, Ai; + for (de = 0; de <= Jt; de++) + et[de] = 0; + for (Le = 0; Le < J; Le++) + et[V[O + Le]]++; + for (Ue = Xe, Ye = Jt; Ye >= 1 && et[Ye] === 0; Ye--) + ; + if (Ue > Ye && (Ue = Ye), Ye === 0) + return te[ee++] = 1 << 24 | 64 << 16 | 0, te[ee++] = 1 << 24 | 64 << 16 | 0, be.bits = 1, 0; + for (ht = 1; ht < Ye && et[ht] === 0; ht++) + ; + for (Ue < ht && (Ue = ht), ot = 1, de = 1; de <= Jt; de++) + if (ot <<= 1, ot -= et[de], ot < 0) + return -1; + if (ot > 0 && (v === tr || Ye !== 1)) + return -1; + for (lt[1] = 0, de = 1; de < Jt; de++) + lt[de + 1] = lt[de] + et[de]; + for (Le = 0; Le < J; Le++) + V[O + Le] !== 0 && (Ce[lt[V[O + Le]]++] = Le); + if (v === tr ? (pt = Ht = Ce, ft = 20) : v === zi ? (pt = Yn, Ht = Xn, ft = 257) : (pt = Qn, Ht = Jn, ft = 0), ut = 0, Le = 0, de = ht, Je = ee, Qe = Ue, xt = 0, ct = -1, it = 1 << Ue, Et = it - 1, v === zi && it > qi || v === ir && it > er) + return 1; + for (; ; ) { + Xr = de - xt, Ce[Le] + 1 < ft ? (Mi = 0, Ai = Ce[Le]) : Ce[Le] >= ft ? (Mi = Ht[Ce[Le] - ft], Ai = pt[Ce[Le] - ft]) : (Mi = 96, Ai = 0), st = 1 << de - xt, Ze = 1 << Qe, ht = Ze; + do + Ze -= st, te[Je + (ut >> xt) + Ze] = Xr << 24 | Mi << 16 | Ai | 0; + while (Ze !== 0); + for (st = 1 << de - 1; ut & st; ) + st >>= 1; + if (st !== 0 ? (ut &= st - 1, ut += st) : ut = 0, Le++, --et[de] === 0) { + if (de === Ye) + break; + de = V[O + Ce[Le]]; + } + if (de > Ue && (ut & Et) !== ct) { + for (xt === 0 && (xt = Ue), Je += ht, Qe = de - xt, ot = 1 << Qe; Qe + xt < Ye && (ot -= et[Qe + xt], !(ot <= 0)); ) + Qe++, ot <<= 1; + if (it += 1 << Qe, v === zi && it > qi || v === ir && it > er) + return 1; + ct = ut & Et, te[ct] = Ue << 24 | Qe << 16 | Je - ee | 0; + } + } + return ut !== 0 && (te[Je + ut] = de - xt << 24 | 64 << 16 | 0), be.bits = Ue, 0; + }; + const qn = 0, rr = 1, nr = 2, { + Z_FINISH: sr, + Z_BLOCK: es, + Z_TREES: bi, + Z_OK: Vt, + Z_STREAM_END: ts, + Z_NEED_DICT: is, + Z_STREAM_ERROR: St, + Z_DATA_ERROR: ar, + Z_MEM_ERROR: lr, + Z_BUF_ERROR: rs, + Z_DEFLATED: or + } = ge, xi = 16180, fr = 16181, hr = 16182, dr = 16183, cr = 16184, ur = 16185, _r = 16186, gr = 16187, pr = 16188, vr = 16189, yi = 16190, Rt = 16191, $i = 16192, mr = 16193, Bi = 16194, br = 16195, xr = 16196, yr = 16197, wr = 16198, wi = 16199, Ei = 16200, Er = 16201, Mr = 16202, Ar = 16203, Cr = 16204, Lr = 16205, ki = 16206, Dr = 16207, Sr = 16208, bt = 16209, Or = 16210, Tr = 16211, ns = 852, ss = 592, as = 15, Pr = (v) => (v >>> 24 & 255) + (v >>> 8 & 65280) + ((v & 65280) << 8) + ((v & 255) << 24); + function ls() { + 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 jt = (v) => { + if (!v) + return 1; + const V = v.state; + return !V || V.strm !== v || V.mode < xi || V.mode > Tr ? 1 : 0; + }, Ir = (v) => { + if (jt(v)) + return St; + const V = v.state; + return v.total_in = v.total_out = V.total = 0, v.msg = "", V.wrap && (v.adler = V.wrap & 1), V.mode = xi, V.last = 0, V.havedict = 0, V.flags = -1, V.dmax = 32768, V.head = null, V.hold = 0, V.bits = 0, V.lencode = V.lendyn = new Int32Array(ns), V.distcode = V.distdyn = new Int32Array(ss), V.sane = 1, V.back = -1, Vt; + }, Rr = (v) => { + if (jt(v)) + return St; + const V = v.state; + return V.wsize = 0, V.whave = 0, V.wnext = 0, Ir(v); + }, zr = (v, V) => { + let O; + if (jt(v)) + return St; + const J = v.state; + return V < 0 ? (O = 0, V = -V) : (O = (V >> 4) + 5, V < 48 && (V &= 15)), V && (V < 8 || V > 15) ? St : (J.window !== null && J.wbits !== V && (J.window = null), J.wrap = O, J.wbits = V, Rr(v)); + }, $r = (v, V) => { + if (!v) + return St; + const O = new ls(); + v.state = O, O.strm = v, O.window = null, O.mode = xi; + const J = zr(v, V); + return J !== Vt && (v.state = null), J; + }, os = (v) => $r(v, as); + let Br = !0, Fi, Ui; + const fs = (v) => { + if (Br) { + Fi = new Int32Array(512), Ui = new Int32Array(32); + let V = 0; + for (; V < 144; ) + v.lens[V++] = 8; + for (; V < 256; ) + v.lens[V++] = 9; + for (; V < 280; ) + v.lens[V++] = 7; + for (; V < 288; ) + v.lens[V++] = 8; + for (li(rr, v.lens, 0, 288, Fi, 0, v.work, { bits: 9 }), V = 0; V < 32; ) + v.lens[V++] = 5; + li(nr, v.lens, 0, 32, Ui, 0, v.work, { bits: 5 }), Br = !1; + } + v.lencode = Fi, v.lenbits = 9, v.distcode = Ui, v.distbits = 5; + }, kr = (v, V, O, J) => { + let te; + const ee = v.state; + return ee.window === null && (ee.wsize = 1 << ee.wbits, ee.wnext = 0, ee.whave = 0, ee.window = new Uint8Array(ee.wsize)), J >= ee.wsize ? (ee.window.set(V.subarray(O - ee.wsize, O), 0), ee.wnext = 0, ee.whave = ee.wsize) : (te = ee.wsize - ee.wnext, te > J && (te = J), ee.window.set(V.subarray(O - J, O - J + te), ee.wnext), J -= te, J ? (ee.window.set(V.subarray(O - J, O), 0), ee.wnext = J, ee.whave = ee.wsize) : (ee.wnext += te, ee.wnext === ee.wsize && (ee.wnext = 0), ee.whave < ee.wsize && (ee.whave += te))), 0; + }, hs = (v, V) => { + let O, J, te, ee, Ce, be, Xe, de, Le, ht, Ye, Ue, Qe, xt, ot = 0, it, ut, st, Ze, ct, Et, Je, pt; + const ft = new Uint8Array(4); + let et, lt; + const Ht = ( + /* 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 (jt(v) || !v.output || !v.input && v.avail_in !== 0) + return St; + O = v.state, O.mode === Rt && (O.mode = $i), Ce = v.next_out, te = v.output, Xe = v.avail_out, ee = v.next_in, J = v.input, be = v.avail_in, de = O.hold, Le = O.bits, ht = be, Ye = Xe, pt = Vt; + e: + for (; ; ) + switch (O.mode) { + case xi: + if (O.wrap === 0) { + O.mode = $i; + break; + } + for (; Le < 16; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (O.wrap & 2 && de === 35615) { + O.wbits === 0 && (O.wbits = 15), O.check = 0, ft[0] = de & 255, ft[1] = de >>> 8 & 255, O.check = I(O.check, ft, 2, 0), de = 0, Le = 0, O.mode = fr; + break; + } + if (O.head && (O.head.done = !1), !(O.wrap & 1) || /* check if zlib header allowed */ + (((de & 255) << 8) + (de >> 8)) % 31) { + v.msg = "incorrect header check", O.mode = bt; + break; + } + if ((de & 15) !== or) { + v.msg = "unknown compression method", O.mode = bt; + break; + } + if (de >>>= 4, Le -= 4, Je = (de & 15) + 8, O.wbits === 0 && (O.wbits = Je), Je > 15 || Je > O.wbits) { + v.msg = "invalid window size", O.mode = bt; + break; + } + O.dmax = 1 << O.wbits, O.flags = 0, v.adler = O.check = 1, O.mode = de & 512 ? vr : Rt, de = 0, Le = 0; + break; + case fr: + for (; Le < 16; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (O.flags = de, (O.flags & 255) !== or) { + v.msg = "unknown compression method", O.mode = bt; + break; + } + if (O.flags & 57344) { + v.msg = "unknown header flags set", O.mode = bt; + break; + } + O.head && (O.head.text = de >> 8 & 1), O.flags & 512 && O.wrap & 4 && (ft[0] = de & 255, ft[1] = de >>> 8 & 255, O.check = I(O.check, ft, 2, 0)), de = 0, Le = 0, O.mode = hr; + case hr: + for (; Le < 32; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + O.head && (O.head.time = de), O.flags & 512 && O.wrap & 4 && (ft[0] = de & 255, ft[1] = de >>> 8 & 255, ft[2] = de >>> 16 & 255, ft[3] = de >>> 24 & 255, O.check = I(O.check, ft, 4, 0)), de = 0, Le = 0, O.mode = dr; + case dr: + for (; Le < 16; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + O.head && (O.head.xflags = de & 255, O.head.os = de >> 8), O.flags & 512 && O.wrap & 4 && (ft[0] = de & 255, ft[1] = de >>> 8 & 255, O.check = I(O.check, ft, 2, 0)), de = 0, Le = 0, O.mode = cr; + case cr: + if (O.flags & 1024) { + for (; Le < 16; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + O.length = de, O.head && (O.head.extra_len = de), O.flags & 512 && O.wrap & 4 && (ft[0] = de & 255, ft[1] = de >>> 8 & 255, O.check = I(O.check, ft, 2, 0)), de = 0, Le = 0; + } else + O.head && (O.head.extra = null); + O.mode = ur; + case ur: + if (O.flags & 1024 && (Ue = O.length, Ue > be && (Ue = be), Ue && (O.head && (Je = O.head.extra_len - O.length, O.head.extra || (O.head.extra = new Uint8Array(O.head.extra_len)), O.head.extra.set( + J.subarray( + ee, + // extra field is limited to 65536 bytes + // - no need for additional size check + ee + Ue + ), + /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ + Je + )), O.flags & 512 && O.wrap & 4 && (O.check = I(O.check, J, Ue, ee)), be -= Ue, ee += Ue, O.length -= Ue), O.length)) + break e; + O.length = 0, O.mode = _r; + case _r: + if (O.flags & 2048) { + if (be === 0) + break e; + Ue = 0; + do + Je = J[ee + Ue++], O.head && Je && O.length < 65536 && (O.head.name += String.fromCharCode(Je)); + while (Je && Ue < be); + if (O.flags & 512 && O.wrap & 4 && (O.check = I(O.check, J, Ue, ee)), be -= Ue, ee += Ue, Je) + break e; + } else + O.head && (O.head.name = null); + O.length = 0, O.mode = gr; + case gr: + if (O.flags & 4096) { + if (be === 0) + break e; + Ue = 0; + do + Je = J[ee + Ue++], O.head && Je && O.length < 65536 && (O.head.comment += String.fromCharCode(Je)); + while (Je && Ue < be); + if (O.flags & 512 && O.wrap & 4 && (O.check = I(O.check, J, Ue, ee)), be -= Ue, ee += Ue, Je) + break e; + } else + O.head && (O.head.comment = null); + O.mode = pr; + case pr: + if (O.flags & 512) { + for (; Le < 16; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (O.wrap & 4 && de !== (O.check & 65535)) { + v.msg = "header crc mismatch", O.mode = bt; + break; + } + de = 0, Le = 0; + } + O.head && (O.head.hcrc = O.flags >> 9 & 1, O.head.done = !0), v.adler = O.check = 0, O.mode = Rt; + break; + case vr: + for (; Le < 32; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + v.adler = O.check = Pr(de), de = 0, Le = 0, O.mode = yi; + case yi: + if (O.havedict === 0) + return v.next_out = Ce, v.avail_out = Xe, v.next_in = ee, v.avail_in = be, O.hold = de, O.bits = Le, is; + v.adler = O.check = 1, O.mode = Rt; + case Rt: + if (V === es || V === bi) + break e; + case $i: + if (O.last) { + de >>>= Le & 7, Le -= Le & 7, O.mode = ki; + break; + } + for (; Le < 3; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + switch (O.last = de & 1, de >>>= 1, Le -= 1, de & 3) { + case 0: + O.mode = mr; + break; + case 1: + if (fs(O), O.mode = wi, V === bi) { + de >>>= 2, Le -= 2; + break e; + } + break; + case 2: + O.mode = xr; + break; + case 3: + v.msg = "invalid block type", O.mode = bt; + } + de >>>= 2, Le -= 2; + break; + case mr: + for (de >>>= Le & 7, Le -= Le & 7; Le < 32; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if ((de & 65535) !== (de >>> 16 ^ 65535)) { + v.msg = "invalid stored block lengths", O.mode = bt; + break; + } + if (O.length = de & 65535, de = 0, Le = 0, O.mode = Bi, V === bi) + break e; + case Bi: + O.mode = br; + case br: + if (Ue = O.length, Ue) { + if (Ue > be && (Ue = be), Ue > Xe && (Ue = Xe), Ue === 0) + break e; + te.set(J.subarray(ee, ee + Ue), Ce), be -= Ue, ee += Ue, Xe -= Ue, Ce += Ue, O.length -= Ue; + break; + } + O.mode = Rt; + break; + case xr: + for (; Le < 14; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (O.nlen = (de & 31) + 257, de >>>= 5, Le -= 5, O.ndist = (de & 31) + 1, de >>>= 5, Le -= 5, O.ncode = (de & 15) + 4, de >>>= 4, Le -= 4, O.nlen > 286 || O.ndist > 30) { + v.msg = "too many length or distance symbols", O.mode = bt; + break; + } + O.have = 0, O.mode = yr; + case yr: + for (; O.have < O.ncode; ) { + for (; Le < 3; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + O.lens[Ht[O.have++]] = de & 7, de >>>= 3, Le -= 3; + } + for (; O.have < 19; ) + O.lens[Ht[O.have++]] = 0; + if (O.lencode = O.lendyn, O.lenbits = 7, et = { bits: O.lenbits }, pt = li(qn, O.lens, 0, 19, O.lencode, 0, O.work, et), O.lenbits = et.bits, pt) { + v.msg = "invalid code lengths set", O.mode = bt; + break; + } + O.have = 0, O.mode = wr; + case wr: + for (; O.have < O.nlen + O.ndist; ) { + for (; ot = O.lencode[de & (1 << O.lenbits) - 1], it = ot >>> 24, ut = ot >>> 16 & 255, st = ot & 65535, !(it <= Le); ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (st < 16) + de >>>= it, Le -= it, O.lens[O.have++] = st; + else { + if (st === 16) { + for (lt = it + 2; Le < lt; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (de >>>= it, Le -= it, O.have === 0) { + v.msg = "invalid bit length repeat", O.mode = bt; + break; + } + Je = O.lens[O.have - 1], Ue = 3 + (de & 3), de >>>= 2, Le -= 2; + } else if (st === 17) { + for (lt = it + 3; Le < lt; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + de >>>= it, Le -= it, Je = 0, Ue = 3 + (de & 7), de >>>= 3, Le -= 3; + } else { + for (lt = it + 7; Le < lt; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + de >>>= it, Le -= it, Je = 0, Ue = 11 + (de & 127), de >>>= 7, Le -= 7; + } + if (O.have + Ue > O.nlen + O.ndist) { + v.msg = "invalid bit length repeat", O.mode = bt; + break; + } + for (; Ue--; ) + O.lens[O.have++] = Je; + } + } + if (O.mode === bt) + break; + if (O.lens[256] === 0) { + v.msg = "invalid code -- missing end-of-block", O.mode = bt; + break; + } + if (O.lenbits = 9, et = { bits: O.lenbits }, pt = li(rr, O.lens, 0, O.nlen, O.lencode, 0, O.work, et), O.lenbits = et.bits, pt) { + v.msg = "invalid literal/lengths set", O.mode = bt; + break; + } + if (O.distbits = 6, O.distcode = O.distdyn, et = { bits: O.distbits }, pt = li(nr, O.lens, O.nlen, O.ndist, O.distcode, 0, O.work, et), O.distbits = et.bits, pt) { + v.msg = "invalid distances set", O.mode = bt; + break; + } + if (O.mode = wi, V === bi) + break e; + case wi: + O.mode = Ei; + case Ei: + if (be >= 6 && Xe >= 258) { + v.next_out = Ce, v.avail_out = Xe, v.next_in = ee, v.avail_in = be, O.hold = de, O.bits = Le, Zn(v, Ye), Ce = v.next_out, te = v.output, Xe = v.avail_out, ee = v.next_in, J = v.input, be = v.avail_in, de = O.hold, Le = O.bits, O.mode === Rt && (O.back = -1); + break; + } + for (O.back = 0; ot = O.lencode[de & (1 << O.lenbits) - 1], it = ot >>> 24, ut = ot >>> 16 & 255, st = ot & 65535, !(it <= Le); ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (ut && !(ut & 240)) { + for (Ze = it, ct = ut, Et = st; ot = O.lencode[Et + ((de & (1 << Ze + ct) - 1) >> Ze)], it = ot >>> 24, ut = ot >>> 16 & 255, st = ot & 65535, !(Ze + it <= Le); ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + de >>>= Ze, Le -= Ze, O.back += Ze; + } + if (de >>>= it, Le -= it, O.back += it, O.length = st, ut === 0) { + O.mode = Lr; + break; + } + if (ut & 32) { + O.back = -1, O.mode = Rt; + break; + } + if (ut & 64) { + v.msg = "invalid literal/length code", O.mode = bt; + break; + } + O.extra = ut & 15, O.mode = Er; + case Er: + if (O.extra) { + for (lt = O.extra; Le < lt; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + O.length += de & (1 << O.extra) - 1, de >>>= O.extra, Le -= O.extra, O.back += O.extra; + } + O.was = O.length, O.mode = Mr; + case Mr: + for (; ot = O.distcode[de & (1 << O.distbits) - 1], it = ot >>> 24, ut = ot >>> 16 & 255, st = ot & 65535, !(it <= Le); ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (!(ut & 240)) { + for (Ze = it, ct = ut, Et = st; ot = O.distcode[Et + ((de & (1 << Ze + ct) - 1) >> Ze)], it = ot >>> 24, ut = ot >>> 16 & 255, st = ot & 65535, !(Ze + it <= Le); ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + de >>>= Ze, Le -= Ze, O.back += Ze; + } + if (de >>>= it, Le -= it, O.back += it, ut & 64) { + v.msg = "invalid distance code", O.mode = bt; + break; + } + O.offset = st, O.extra = ut & 15, O.mode = Ar; + case Ar: + if (O.extra) { + for (lt = O.extra; Le < lt; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + O.offset += de & (1 << O.extra) - 1, de >>>= O.extra, Le -= O.extra, O.back += O.extra; + } + if (O.offset > O.dmax) { + v.msg = "invalid distance too far back", O.mode = bt; + break; + } + O.mode = Cr; + case Cr: + if (Xe === 0) + break e; + if (Ue = Ye - Xe, O.offset > Ue) { + if (Ue = O.offset - Ue, Ue > O.whave && O.sane) { + v.msg = "invalid distance too far back", O.mode = bt; + break; + } + Ue > O.wnext ? (Ue -= O.wnext, Qe = O.wsize - Ue) : Qe = O.wnext - Ue, Ue > O.length && (Ue = O.length), xt = O.window; + } else + xt = te, Qe = Ce - O.offset, Ue = O.length; + Ue > Xe && (Ue = Xe), Xe -= Ue, O.length -= Ue; + do + te[Ce++] = xt[Qe++]; + while (--Ue); + O.length === 0 && (O.mode = Ei); + break; + case Lr: + if (Xe === 0) + break e; + te[Ce++] = O.length, Xe--, O.mode = Ei; + break; + case ki: + if (O.wrap) { + for (; Le < 32; ) { + if (be === 0) + break e; + be--, de |= J[ee++] << Le, Le += 8; + } + if (Ye -= Xe, v.total_out += Ye, O.total += Ye, O.wrap & 4 && Ye && (v.adler = O.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/ + O.flags ? I(O.check, te, Ye, Ce - Ye) : De(O.check, te, Ye, Ce - Ye)), Ye = Xe, O.wrap & 4 && (O.flags ? de : Pr(de)) !== O.check) { + v.msg = "incorrect data check", O.mode = bt; + break; + } + de = 0, Le = 0; + } + O.mode = Dr; + case Dr: + if (O.wrap && O.flags) { + for (; Le < 32; ) { + if (be === 0) + break e; + be--, de += J[ee++] << Le, Le += 8; + } + if (O.wrap & 4 && de !== (O.total & 4294967295)) { + v.msg = "incorrect length check", O.mode = bt; + break; + } + de = 0, Le = 0; + } + O.mode = Sr; + case Sr: + pt = ts; + break e; + case bt: + pt = ar; + break e; + case Or: + return lr; + case Tr: + default: + return St; + } + return v.next_out = Ce, v.avail_out = Xe, v.next_in = ee, v.avail_in = be, O.hold = de, O.bits = Le, (O.wsize || Ye !== v.avail_out && O.mode < bt && (O.mode < ki || V !== sr)) && kr(v, v.output, v.next_out, Ye - v.avail_out), ht -= v.avail_in, Ye -= v.avail_out, v.total_in += ht, v.total_out += Ye, O.total += Ye, O.wrap & 4 && Ye && (v.adler = O.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/ + O.flags ? I(O.check, te, Ye, v.next_out - Ye) : De(O.check, te, Ye, v.next_out - Ye)), v.data_type = O.bits + (O.last ? 64 : 0) + (O.mode === Rt ? 128 : 0) + (O.mode === wi || O.mode === Bi ? 256 : 0), (ht === 0 && Ye === 0 || V === sr) && pt === Vt && (pt = rs), pt; + }, ds = (v) => { + if (jt(v)) + return St; + let V = v.state; + return V.window && (V.window = null), v.state = null, Vt; + }, cs = (v, V) => { + if (jt(v)) + return St; + const O = v.state; + return O.wrap & 2 ? (O.head = V, V.done = !1, Vt) : St; + }, us = (v, V) => { + const O = V.length; + let J, te, ee; + return jt(v) || (J = v.state, J.wrap !== 0 && J.mode !== yi) ? St : J.mode === yi && (te = 1, te = De(te, V, O, 0), te !== J.check) ? ar : (ee = kr(v, V, O, O), ee ? (J.mode = Or, lr) : (J.havedict = 1, Vt)); + }; + var _s = Rr, gs = zr, ps = Ir, vs = os, ms = $r, bs = hs, xs = ds, ys = cs, ws = us, Es = "pako inflate (from Nodeca project)", zt = { + inflateReset: _s, + inflateReset2: gs, + inflateResetKeep: ps, + inflateInit: vs, + inflateInit2: ms, + inflate: bs, + inflateEnd: xs, + inflateGetHeader: ys, + inflateSetDictionary: ws, + inflateInfo: Es + }; + function Ms() { + 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 As = Ms; + const Fr = Object.prototype.toString, { + Z_NO_FLUSH: Cs, + Z_FINISH: Ls, + Z_OK: oi, + Z_STREAM_END: Wi, + Z_NEED_DICT: Gi, + Z_STREAM_ERROR: Ds, + Z_DATA_ERROR: Ur, + Z_MEM_ERROR: Ss + } = ge; + function fi(v) { + this.options = pi.assign({ + chunkSize: 65536, + windowBits: 15, + to: "" + }, v || {}); + const V = this.options; + V.raw && V.windowBits >= 0 && V.windowBits < 16 && (V.windowBits = -V.windowBits, V.windowBits === 0 && (V.windowBits = -15)), V.windowBits >= 0 && V.windowBits < 16 && !(v && v.windowBits) && (V.windowBits += 32), V.windowBits > 15 && V.windowBits < 48 && (V.windowBits & 15 || (V.windowBits |= 15)), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new Qi(), this.strm.avail_out = 0; + let O = zt.inflateInit2( + this.strm, + V.windowBits + ); + if (O !== oi) + throw new Error(me[O]); + if (this.header = new As(), zt.inflateGetHeader(this.strm, this.header), V.dictionary && (typeof V.dictionary == "string" ? V.dictionary = si.string2buf(V.dictionary) : Fr.call(V.dictionary) === "[object ArrayBuffer]" && (V.dictionary = new Uint8Array(V.dictionary)), V.raw && (O = zt.inflateSetDictionary(this.strm, V.dictionary), O !== oi))) + throw new Error(me[O]); + } + fi.prototype.push = function(v, V) { + const O = this.strm, J = this.options.chunkSize, te = this.options.dictionary; + let ee, Ce, be; + if (this.ended) + return !1; + for (V === ~~V ? Ce = V : Ce = V === !0 ? Ls : Cs, Fr.call(v) === "[object ArrayBuffer]" ? O.input = new Uint8Array(v) : O.input = v, 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), ee = zt.inflate(O, Ce), ee === Gi && te && (ee = zt.inflateSetDictionary(O, te), ee === oi ? ee = zt.inflate(O, Ce) : ee === Ur && (ee = Gi)); O.avail_in > 0 && ee === Wi && O.state.wrap > 0 && v[O.next_in] !== 0; ) + zt.inflateReset(O), ee = zt.inflate(O, Ce); + switch (ee) { + case Ds: + case Ur: + case Gi: + case Ss: + return this.onEnd(ee), this.ended = !0, !1; + } + if (be = O.avail_out, O.next_out && (O.avail_out === 0 || ee === Wi)) + if (this.options.to === "string") { + let Xe = si.utf8border(O.output, O.next_out), de = O.next_out - Xe, Le = si.buf2string(O.output, Xe); + O.next_out = de, O.avail_out = J - de, de && O.output.set(O.output.subarray(Xe, Xe + de), 0), this.onData(Le); + } else + this.onData(O.output.length === O.next_out ? O.output : O.output.subarray(0, O.next_out)); + if (!(ee === oi && be === 0)) { + if (ee === Wi) + return ee = zt.inflateEnd(this.strm), this.onEnd(ee), this.ended = !0, !0; + if (O.avail_in === 0) + break; + } + } + return !0; + }, fi.prototype.onData = function(v) { + this.chunks.push(v); + }, fi.prototype.onEnd = function(v) { + v === oi && (this.options.to === "string" ? this.result = this.chunks.join("") : this.result = pi.flattenChunks(this.chunks)), this.chunks = [], this.err = v, this.msg = this.strm.msg; + }; + function Ni(v, V) { + const O = new fi(V); + if (O.push(v), O.err) + throw O.msg || me[O.err]; + return O.result; + } + function Os(v, V) { + return V = V || {}, V.raw = !0, Ni(v, V); + } + var Ts = fi, Ps = Ni, Is = Os, Rs = Ni, zs = ge, $s = { + Inflate: Ts, + inflate: Ps, + inflateRaw: Is, + ungzip: Rs, + constants: zs + }; + const { Deflate: Bs, deflate: ks, deflateRaw: Fs, gzip: Us } = Hn, { Inflate: Ws, inflate: Gs, inflateRaw: Ns, ungzip: Vs } = $s; + var Wr = Bs, Gr = ks, Nr = Fs, Vr = Us, jr = Ws, Hr = Gs, Kr = Ns, Zr = Vs, Yr = ge, js = { + Deflate: Wr, + deflate: Gr, + deflateRaw: Nr, + gzip: Vr, + Inflate: jr, + inflate: Hr, + inflateRaw: Kr, + ungzip: Zr, + constants: Yr + }; + } + ) + /******/ + }, __webpack_module_cache__ = {}; + function __webpack_require__(y) { + var s = __webpack_module_cache__[y]; + if (s !== void 0) + return s.exports; + var e = __webpack_module_cache__[y] = { + /******/ + // no module.id needed + /******/ + // no module.loaded needed + /******/ + exports: {} + /******/ + }; + return __webpack_modules__[y].call(e.exports, e, e.exports, __webpack_require__), e.exports; + } + __webpack_require__.n = (y) => { + var s = y && y.__esModule ? ( + /******/ + () => y.default + ) : ( + /******/ + () => y + ); + return __webpack_require__.d(s, { a: s }), s; + }, __webpack_require__.d = (y, s) => { + for (var e in s) + __webpack_require__.o(s, e) && !__webpack_require__.o(y, e) && Object.defineProperty(y, e, { enumerable: !0, get: s[e] }); + }, __webpack_require__.o = (y, s) => Object.prototype.hasOwnProperty.call(y, s), __webpack_require__.r = (y) => { + typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(y, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(y, "__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); +var _3DmolExports = _3Dmol.exports; +const Dmol = /* @__PURE__ */ getDefaultExportFromCjs(_3DmolExports), Molecule_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$7, + append: append$5, + attr: attr$6, + binding_callbacks: binding_callbacks$4, + detach: detach$7, + element: element$6, + init: init$7, + insert: insert$7, + listen: listen$2, + noop: noop$7, + run_all: run_all$2, + safe_not_equal: safe_not_equal$8, + set_data: set_data$5, + space: space$5, + text: text$5, + toggle_class: toggle_class$5 +} = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$3, afterUpdate: afterUpdate$2 } = window.__gradio__svelte__internal; +function create_if_block$5(y) { + let s, e, l, g, _, x, o, p, E, u, A, C, L, D, r, n, b, f, c, t, a, h, M, w, S; + function T(F, $) { + return ( + /*attachmentIndex*/ + F[1] !== null ? create_if_block_2$3 : create_else_block_1$2 + ); + } + let R = T(y), z = R(y); + function P(F, $) { + return ( + /*deleteIndexes*/ + F[2].length > 0 ? create_if_block_1$4 : create_else_block$4 + ); + } + let B = P(y), U = B(y); + return { + c() { + s = element$6("div"), s.textContent = "Covalent Modification", e = space$5(), l = element$6("div"), l.innerHTML = ' click on atoms in viewer to select them', g = space$5(), _ = element$6("div"), x = element$6("button"), x.innerHTML = ' Attachment atom', o = space$5(), p = element$6("button"), p.innerHTML = ' Atoms to delete', E = space$5(), u = element$6("div"), A = element$6("table"), C = element$6("thead"), C.innerHTML = ' index', L = space$5(), D = element$6("tbody"), r = element$6("tr"), n = element$6("th"), n.textContent = "Attachment atom", b = space$5(), f = element$6("td"), z.c(), c = space$5(), t = element$6("tr"), a = element$6("th"), a.textContent = "Deleted atoms", h = space$5(), M = element$6("td"), U.c(), attr$6(s, "class", "w-full text-center text-lg mb-2 svelte-1jhdl43"), attr$6(l, "class", "flex items-center space-x-2 justify-center mb-2 text-xs svelte-1jhdl43"), attr$6(x, "class", "w-1/2 flex items-center rounded-l-full px-4 py-2 transition-colors duration-300 ease-in hover:text-orange-600 focus:text-orange-600 focus:outline-none svelte-1jhdl43"), attr$6(x, "id", "attach"), toggle_class$5( + x, + "active", + /*mode*/ + y[3] === "attach" + ), attr$6(p, "class", "w-1/2 flex items-center rounded-r-full px-4 py-2 transition-colors duration-300 ease-in hover:text-orange-600 focus:text-orange-600 focus:outline-none svelte-1jhdl43"), attr$6(p, "id", "delete"), toggle_class$5( + p, + "active", + /*mode*/ + y[3] === "delete" + ), attr$6(_, "class", "flex rounded-full border-2 border-gray-200 bg-gray-200 text-sm leading-none text-gray-500 svelte-1jhdl43"), attr$6(C, "class", "text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400 svelte-1jhdl43"), attr$6(n, "scope", "row"), attr$6(n, "class", "px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white text-right svelte-1jhdl43"), attr$6(f, "class", "px-6 py-4 font-mono svelte-1jhdl43"), attr$6(r, "class", "bg-white border-b dark:bg-gray-800 dark:border-gray-700 svelte-1jhdl43"), attr$6(a, "scope", "row"), attr$6(a, "class", "px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white text-right svelte-1jhdl43"), attr$6(M, "class", "px-6 py-4 font-mono svelte-1jhdl43"), attr$6(t, "class", "bg-white dark:bg-gray-800 svelte-1jhdl43"), attr$6(D, "class", "svelte-1jhdl43"), attr$6(A, "class", "w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 svelte-1jhdl43"), attr$6(u, "class", "relative overflow-x-auto mt-3 svelte-1jhdl43"); + }, + m(F, $) { + insert$7(F, s, $), insert$7(F, e, $), insert$7(F, l, $), insert$7(F, g, $), insert$7(F, _, $), append$5(_, x), append$5(_, o), append$5(_, p), insert$7(F, E, $), insert$7(F, u, $), append$5(u, A), append$5(A, C), append$5(A, L), append$5(A, D), append$5(D, r), append$5(r, n), append$5(r, b), append$5(r, f), z.m(f, null), append$5(D, c), append$5(D, t), append$5(t, a), append$5(t, h), append$5(t, M), U.m(M, null), w || (S = [ + listen$2( + x, + "click", + /*click_handler*/ + y[7] + ), + listen$2( + p, + "click", + /*click_handler_1*/ + y[8] + ) + ], w = !0); + }, + p(F, $) { + $ & /*mode*/ + 8 && toggle_class$5( + x, + "active", + /*mode*/ + F[3] === "attach" + ), $ & /*mode*/ + 8 && toggle_class$5( + p, + "active", + /*mode*/ + F[3] === "delete" + ), R === (R = T(F)) && z ? z.p(F, $) : (z.d(1), z = R(F), z && (z.c(), z.m(f, null))), B === (B = P(F)) && U ? U.p(F, $) : (U.d(1), U = B(F), U && (U.c(), U.m(M, null))); + }, + d(F) { + F && (detach$7(s), detach$7(e), detach$7(l), detach$7(g), detach$7(_), detach$7(E), detach$7(u)), z.d(), U.d(), w = !1, run_all$2(S); + } + }; +} +function create_else_block_1$2(y) { + let s; + return { + c() { + s = text$5("not selected"); + }, + m(e, l) { + insert$7(e, s, l); + }, + p: noop$7, + d(e) { + e && detach$7(s); + } + }; +} +function create_if_block_2$3(y) { + let s; + return { + c() { + s = text$5( + /*attachmentIndex*/ + y[1] + ); + }, + m(e, l) { + insert$7(e, s, l); + }, + p(e, l) { + l & /*attachmentIndex*/ + 2 && set_data$5( + s, + /*attachmentIndex*/ + e[1] + ); + }, + d(e) { + e && detach$7(s); + } + }; +} +function create_else_block$4(y) { + let s; + return { + c() { + s = text$5("no atoms are deleted"); + }, + m(e, l) { + insert$7(e, s, l); + }, + p: noop$7, + d(e) { + e && detach$7(s); + } + }; +} +function create_if_block_1$4(y) { + let s = ( + /*deleteIndexes*/ + y[2].join(", ") + "" + ), e; + return { + c() { + e = text$5(s); + }, + m(l, g) { + insert$7(l, e, g); + }, + p(l, g) { + g & /*deleteIndexes*/ + 4 && s !== (s = /*deleteIndexes*/ + l[2].join(", ") + "") && set_data$5(e, s); + }, + d(l) { + l && detach$7(e); + } + }; +} +function create_fragment$7(y) { + let s, e, l, g, _, x = ( + /*showCovMod*/ + y[0] > -1 && create_if_block$5(y) + ); + return { + c() { + s = element$6("div"), e = element$6("div"), l = element$6("div"), g = space$5(), _ = element$6("div"), x && x.c(), attr$6(l, "class", "mol-canvas svelte-1jhdl43"), attr$6(e, "class", "relative svelte-1jhdl43"), attr$6(_, "class", "flex flex-col justify-center svelte-1jhdl43"), attr$6(s, "class", "mol-wrapper svelte-1jhdl43"); + }, + m(o, p) { + insert$7(o, s, p), append$5(s, e), append$5(e, l), y[6](l), append$5(s, g), append$5(s, _), x && x.m(_, null); + }, + p(o, [p]) { + /*showCovMod*/ + o[0] > -1 ? x ? x.p(o, p) : (x = create_if_block$5(o), x.c(), x.m(_, null)) : x && (x.d(1), x = null); + }, + i: noop$7, + o: noop$7, + d(o) { + o && detach$7(s), y[6](null), x && x.d(); + } + }; +} +function instance$7(y, s, e) { + const l = createEventDispatcher$3(); + let g = null, _ = [], x = "attach"; + function o(r) { + r.setStyle({ stick: {} }), u > -1 && (g !== null && r.addStyle({ index: g }, { sphere: { color: "blue", scale: 0.5 } }), r.addStyle({ index: _ }, { sphere: { color: "red", scale: 0.5 } }), l("updateMol", { + attachmentIndex: g, + deleteIndexes: _, + index: u, + mol: r.exportJSON() + })); + } + function p(r, n) { + let b = Dmol.createViewer(n, {}); + return b.addModel(r, "sdf"), o(b), b.setBackgroundColor("white"), b.zoomTo(), b.getModel(0).setClickable({}, !0, function(f, c, t, a) { + u > -1 && (x === "attach" ? e(1, g = f.serial) : (_.includes(f.serial) ? e(2, _ = _.filter((h) => h !== f.serial)) : _.push(f.serial), e(2, _), o(c))); + }), b.render(), b; + } + let { molvalue: E = "" } = s, { showCovMod: u = -1 } = s, A = null; + afterUpdate$2(() => { + p(E, A); + }); + function C(r) { + binding_callbacks$4[r ? "unshift" : "push"](() => { + A = r, e(4, A); + }); + } + const L = () => e(3, x = "attach"), D = () => e(3, x = "delete"); + return y.$$set = (r) => { + "molvalue" in r && e(5, E = r.molvalue), "showCovMod" in r && e(0, u = r.showCovMod); + }, [ + u, + g, + _, + x, + A, + E, + C, + L, + D + ]; +} +class Molecule extends SvelteComponent$7 { + constructor(s) { + super(), init$7(this, s, instance$7, create_fragment$7, safe_not_equal$8, { molvalue: 5, showCovMod: 0 }); + } +} +const Accordion_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$6, + add_render_callback: add_render_callback$2, + append: append$4, + attr: attr$5, + check_outros: check_outros$4, + create_component: create_component$4, + destroy_component: destroy_component$4, + destroy_each: destroy_each$1, + detach: detach$6, + element: element$5, + empty: empty$3, + ensure_array_like: ensure_array_like$1, + group_outros: group_outros$4, + init: init$6, + insert: insert$6, + listen: listen$1, + mount_component: mount_component$4, + noop: noop$6, + run_all: run_all$1, + safe_not_equal: safe_not_equal$7, + select_option, + select_value, + set_data: set_data$4, + set_input_value: set_input_value$1, + space: space$4, + svg_element: svg_element$1, + text: text$4, + toggle_class: toggle_class$4, + transition_in: transition_in$4, + transition_out: transition_out$4 +} = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$2 } = window.__gradio__svelte__internal; +function get_each_context$1(y, s, e) { + const l = y.slice(); + return l[33] = s[e], l[34] = s, l[35] = e, l; +} +function get_each_context_1$1(y, s, e) { + const l = y.slice(); + return l[36] = s[e], l; +} +function get_each_context_2(y, s, e) { + const l = y.slice(); + return l[39] = s[e], l; +} +function get_each_context_3(y, s, e) { + const l = y.slice(); + return l[36] = s[e], l; +} +function get_each_context_4(y, s, e) { + const l = y.slice(); + return l[44] = s[e], l[45] = s, l[35] = e, l; +} +function get_each_context_5(y, s, e) { + const l = y.slice(); + return l[46] = s[e], l; +} +function create_if_block_11$1(y) { + let s, e; + function l(x, o) { + return o[0] & /*vals*/ + 1 && (s = null), s == null && (s = !!/*metals*/ + x[8].includes( + /*item*/ + x[44].name + )), s ? create_if_block_12$1 : create_else_block_2; + } + let g = l(y, [-1, -1]), _ = g(y); + return { + c() { + _.c(), e = empty$3(); + }, + m(x, o) { + _.m(x, o), insert$6(x, e, o); + }, + p(x, o) { + g === (g = l(x, o)) && _ ? _.p(x, o) : (_.d(1), _ = g(x), _ && (_.c(), _.m(e.parentNode, e))); + }, + d(x) { + x && detach$6(e), _.d(x); + } + }; +} +function create_else_block_2(y) { + let s = ( + /*item*/ + y[44].smiles + "" + ), e; + return { + c() { + e = text$4(s); + }, + m(l, g) { + insert$6(l, e, g); + }, + p(l, g) { + g[0] & /*vals*/ + 1 && s !== (s = /*item*/ + l[44].smiles + "") && set_data$4(e, s); + }, + d(l) { + l && detach$6(e); + } + }; +} +function create_if_block_12$1(y) { + let s = ( + /*item*/ + y[44].name + "" + ), e; + return { + c() { + e = text$4(s); + }, + m(l, g) { + insert$6(l, e, g); + }, + p(l, g) { + g[0] & /*vals*/ + 1 && s !== (s = /*item*/ + l[44].name + "") && set_data$4(e, s); + }, + d(l) { + l && detach$6(e); + } + }; +} +function create_if_block_8$1(y) { + let s, e, l, g, _, x; + const o = [create_if_block_9$1, create_if_block_10$1], p = []; + function E(u, A) { + return A[0] & /*vals*/ + 1 && (l = null), l == null && (l = !!["DNA", "RNA", "protein"].includes( + /*item*/ + u[44].class + )), l ? 0 : ( + /*item*/ + u[44].class === "ligand" ? 1 : -1 + ); + } + return ~(g = E(y, [-1, -1])) && (_ = p[g] = o[g](y)), { + c() { + s = element$5("div"), e = element$5("div"), _ && _.c(), attr$5(e, "class", "p-5 border border-t-0 border-gray-200 dark:border-gray-700 dark:bg-gray-900 svelte-fryf3t"), attr$5(s, "id", `accordion-collapse-body-${/*i*/ + y[35]}`), attr$5(s, "aria-labelledby", `accordion-collapse-heading-${/*i*/ + y[35]}`), attr$5(s, "class", "svelte-fryf3t"); + }, + m(u, A) { + insert$6(u, s, A), append$4(s, e), ~g && p[g].m(e, null), x = !0; + }, + p(u, A) { + let C = g; + g = E(u, A), g === C ? ~g && p[g].p(u, A) : (_ && (group_outros$4(), transition_out$4(p[C], 1, 1, () => { + p[C] = null; + }), check_outros$4()), ~g ? (_ = p[g], _ ? _.p(u, A) : (_ = p[g] = o[g](u), _.c()), transition_in$4(_, 1), _.m(e, null)) : _ = null); + }, + i(u) { + x || (transition_in$4(_), x = !0); + }, + o(u) { + transition_out$4(_), x = !1; + }, + d(u) { + u && detach$6(s), ~g && p[g].d(); + } + }; +} +function create_if_block_10$1(y) { + let s, e, l, g, _, x, o, p, E, u, A, C, L, D, r, n, b, f, c, t; + function a(...S) { + return ( + /*input_handler_1*/ + y[16]( + /*i*/ + y[35], + ...S + ) + ); + } + x = new SearchInput({ + props: { + database: "rcsb-3ligand", + index: ( + /*i*/ + y[35] + ) + } + }), x.$on( + "triggerFetch", + /*handleMessage*/ + y[12] + ); + function h(...S) { + return ( + /*input_handler_2*/ + y[17]( + /*i*/ + y[35], + ...S + ) + ); + } + let M = ensure_array_like$1( + /*metals*/ + y[8] + ), w = []; + for (let S = 0; S < M.length; S += 1) + w[S] = create_each_block_5(get_each_context_5(y, M, S)); + return { + c() { + s = element$5("textarea"), l = space$4(), g = element$5("div"), g.textContent = "- or -", _ = space$4(), create_component$4(x.$$.fragment), o = space$4(), p = element$5("div"), p.textContent = "- or -", E = space$4(), u = element$5("textarea"), C = space$4(), L = element$5("div"), L.textContent = "- or -", D = space$4(), r = element$5("div"), r.textContent = "Metal ion", n = space$4(), b = element$5("div"); + for (let S = 0; S < w.length; S += 1) + w[S].c(); + attr$5(s, "rows", "1"), attr$5(s, "class", "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 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-fryf3t"), attr$5(s, "placeholder", "SMILES like CCC ..."), s.value = e = /*item*/ + y[44].smiles, attr$5(g, "class", "text-center text-gray-400 w-full my-2 svelte-fryf3t"), attr$5(p, "class", "text-center text-gray-400 w-full my-2 svelte-fryf3t"), attr$5(u, "rows", "3"), attr$5(u, "class", "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 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-fryf3t"), attr$5(u, "placeholder", "SDF format 3D molecule ..."), u.value = A = /*item*/ + y[44].sdf, attr$5(L, "class", "text-center text-gray-400 w-full my-2 svelte-fryf3t"), attr$5(r, "class", "text-center text-gray-600 font-bold mb-2 svelte-fryf3t"), attr$5(b, "class", "flex justify-center space-x-2 svelte-fryf3t"); + }, + m(S, T) { + insert$6(S, s, T), insert$6(S, l, T), insert$6(S, g, T), insert$6(S, _, T), mount_component$4(x, S, T), insert$6(S, o, T), insert$6(S, p, T), insert$6(S, E, T), insert$6(S, u, T), insert$6(S, C, T), insert$6(S, L, T), insert$6(S, D, T), insert$6(S, r, T), insert$6(S, n, T), insert$6(S, b, T); + for (let R = 0; R < w.length; R += 1) + w[R] && w[R].m(b, null); + f = !0, c || (t = [ + listen$1(s, "input", a), + listen$1(u, "input", h) + ], c = !0); + }, + p(S, T) { + if (y = S, (!f || T[0] & /*vals*/ + 1 && e !== (e = /*item*/ + y[44].smiles)) && (s.value = e), (!f || T[0] & /*vals*/ + 1 && A !== (A = /*item*/ + y[44].sdf)) && (u.value = A), T[0] & /*vals, metals, dispatch*/ + 289) { + M = ensure_array_like$1( + /*metals*/ + y[8] + ); + let R; + for (R = 0; R < M.length; R += 1) { + const z = get_each_context_5(y, M, R); + w[R] ? w[R].p(z, T) : (w[R] = create_each_block_5(z), w[R].c(), w[R].m(b, null)); + } + for (; R < w.length; R += 1) + w[R].d(1); + w.length = M.length; + } + }, + i(S) { + f || (transition_in$4(x.$$.fragment, S), f = !0); + }, + o(S) { + transition_out$4(x.$$.fragment, S), f = !1; + }, + d(S) { + S && (detach$6(s), detach$6(l), detach$6(g), detach$6(_), detach$6(o), detach$6(p), detach$6(E), detach$6(u), detach$6(C), detach$6(L), detach$6(D), detach$6(r), detach$6(n), detach$6(b)), destroy_component$4(x, S), destroy_each$1(w, S), c = !1, run_all$1(t); + } + }; +} +function create_if_block_9$1(y) { + let s, e, l, g; + function _(...x) { + return ( + /*input_handler*/ + y[15]( + /*i*/ + y[35], + ...x + ) + ); + } + return { + c() { + s = element$5("textarea"), attr$5(s, "id", "message"), attr$5(s, "rows", "4"), attr$5(s, "class", "block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 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-fryf3t"), attr$5(s, "placeholder", "MSAVGH..."), s.value = e = /*item*/ + y[44].sequence; + }, + m(x, o) { + insert$6(x, s, o), l || (g = listen$1(s, "input", _), l = !0); + }, + p(x, o) { + y = x, o[0] & /*vals*/ + 1 && e !== (e = /*item*/ + y[44].sequence) && (s.value = e); + }, + i: noop$6, + o: noop$6, + d(x) { + x && detach$6(s), l = !1, g(); + } + }; +} +function create_each_block_5(y) { + let s, e, l, g, _; + function x() { + return ( + /*click_handler_2*/ + y[18]( + /*metal*/ + y[46], + /*i*/ + y[35] + ) + ); + } + return { + c() { + s = element$5("button"), e = element$5("span"), e.textContent = `${/*metal*/ + y[46]}`, l = space$4(), attr$5(e, "class", "font-medium text-gray-600 dark:text-gray-300 svelte-fryf3t"), attr$5(s, "class", "relative inline-flex items-center justify-center w-10 h-10 overflow-hidden rounded-full dark:bg-gray-600 svelte-fryf3t"), toggle_class$4( + s, + "bg-blue-200", + /*item*/ + y[44].name === /*metal*/ + y[46] + ), toggle_class$4( + s, + "bg-violet-100", + /*item*/ + y[44].name !== /*metal*/ + y[46] + ); + }, + m(o, p) { + insert$6(o, s, p), append$4(s, e), append$4(s, l), g || (_ = listen$1(s, "click", x), g = !0); + }, + p(o, p) { + y = o, p[0] & /*vals, metals*/ + 257 && toggle_class$4( + s, + "bg-blue-200", + /*item*/ + y[44].name === /*metal*/ + y[46] + ), p[0] & /*vals, metals*/ + 257 && toggle_class$4( + s, + "bg-violet-100", + /*item*/ + y[44].name !== /*metal*/ + y[46] + ); + }, + d(o) { + o && detach$6(s), g = !1, _(); + } + }; +} +function create_if_block_3$2(y) { + let s, e, l, g, _; + const x = [create_if_block_4$2, create_if_block_6$1], o = []; + function p(E, u) { + return u[0] & /*vals*/ + 1 && (s = null), s == null && (s = !!["DNA", "RNA", "protein"].includes( + /*item*/ + E[44].class + )), s ? 0 : ( + /*item*/ + E[44].class === "ligand" ? 1 : -1 + ); + } + return ~(e = p(y, [-1, -1])) && (l = o[e] = x[e](y)), { + c() { + l && l.c(), g = empty$3(); + }, + m(E, u) { + ~e && o[e].m(E, u), insert$6(E, g, u), _ = !0; + }, + p(E, u) { + let A = e; + e = p(E, u), e === A ? ~e && o[e].p(E, u) : (l && (group_outros$4(), transition_out$4(o[A], 1, 1, () => { + o[A] = null; + }), check_outros$4()), ~e ? (l = o[e], l ? l.p(E, u) : (l = o[e] = x[e](E), l.c()), transition_in$4(l, 1), l.m(g.parentNode, g)) : l = null); + }, + i(E) { + _ || (transition_in$4(l), _ = !0); + }, + o(E) { + transition_out$4(l), _ = !1; + }, + d(E) { + E && detach$6(g), ~e && o[e].d(E); + } + }; +} +function create_if_block_6$1(y) { + let s, e, l = ( + /*item*/ + y[44].sdf !== "" && create_if_block_7$1(y) + ); + return { + c() { + l && l.c(), s = empty$3(); + }, + m(g, _) { + l && l.m(g, _), insert$6(g, s, _), e = !0; + }, + p(g, _) { + /*item*/ + g[44].sdf !== "" ? l ? (l.p(g, _), _[0] & /*vals*/ + 1 && transition_in$4(l, 1)) : (l = create_if_block_7$1(g), l.c(), transition_in$4(l, 1), l.m(s.parentNode, s)) : l && (group_outros$4(), transition_out$4(l, 1, 1, () => { + l = null; + }), check_outros$4()); + }, + i(g) { + e || (transition_in$4(l), e = !0); + }, + o(g) { + transition_out$4(l), e = !1; + }, + d(g) { + g && detach$6(s), l && l.d(g); + } + }; +} +function create_if_block_4$2(y) { + let s, e, l, g = ( + /*item*/ + y[44].sequence !== "" && create_if_block_5$2(y) + ); + return { + c() { + s = element$5("div"), e = element$5("div"), g && g.c(), attr$5(e, "class", "p-5 border border-t-0 border-gray-200 dark:border-gray-700 svelte-fryf3t"), toggle_class$4( + e, + "border-b-0", + /*i*/ + y[35] != /*vals*/ + y[0].length - 1 + ), attr$5(s, "id", `accordion-collapse-body-${/*i*/ + y[35]}`), attr$5(s, "aria-labelledby", `accordion-collapse-heading-${/*i*/ + y[35]}`), attr$5(s, "class", "svelte-fryf3t"); + }, + m(_, x) { + insert$6(_, s, x), append$4(s, e), g && g.m(e, null), l = !0; + }, + p(_, x) { + /*item*/ + _[44].sequence !== "" ? g ? (g.p(_, x), x[0] & /*vals*/ + 1 && transition_in$4(g, 1)) : (g = create_if_block_5$2(_), g.c(), transition_in$4(g, 1), g.m(e, null)) : g && (group_outros$4(), transition_out$4(g, 1, 1, () => { + g = null; + }), check_outros$4()), (!l || x[0] & /*vals*/ + 1) && toggle_class$4( + e, + "border-b-0", + /*i*/ + _[35] != /*vals*/ + _[0].length - 1 + ); + }, + i(_) { + l || (transition_in$4(g), l = !0); + }, + o(_) { + transition_out$4(g), l = !1; + }, + d(_) { + _ && detach$6(s), g && g.d(); + } + }; +} +function create_if_block_7$1(y) { + let s, e, l, g; + return l = new Molecule({ + props: { + molvalue: ( + /*item*/ + y[44].sdf + ), + showCovMod: ( + /*showCovModVals*/ + y[2][ + /*i*/ + y[35] + ] + ) + } + }), l.$on( + "updateMol", + /*updateMol*/ + y[11] + ), { + c() { + s = element$5("div"), e = element$5("div"), create_component$4(l.$$.fragment), attr$5(e, "class", "relative svelte-fryf3t"), attr$5(s, "class", "p-5 border border-t-0 border-gray-200 dark:border-gray-700 svelte-fryf3t"), toggle_class$4( + s, + "border-b-0", + /*i*/ + y[35] != /*vals*/ + y[0].length - 1 + ); + }, + m(_, x) { + insert$6(_, s, x), append$4(s, e), mount_component$4(l, e, null), g = !0; + }, + p(_, x) { + const o = {}; + x[0] & /*vals*/ + 1 && (o.molvalue = /*item*/ + _[44].sdf), x[0] & /*showCovModVals*/ + 4 && (o.showCovMod = /*showCovModVals*/ + _[2][ + /*i*/ + _[35] + ]), l.$set(o), (!g || x[0] & /*vals*/ + 1) && toggle_class$4( + s, + "border-b-0", + /*i*/ + _[35] != /*vals*/ + _[0].length - 1 + ); + }, + i(_) { + g || (transition_in$4(l.$$.fragment, _), g = !0); + }, + o(_) { + transition_out$4(l.$$.fragment, _), g = !1; + }, + d(_) { + _ && detach$6(s), destroy_component$4(l); + } + }; +} +function create_if_block_5$2(y) { + let s, e; + return s = new Sequence({ + props: { seq: ( + /*item*/ + y[44].sequence + ) } + }), { + c() { + create_component$4(s.$$.fragment); + }, + m(l, g) { + mount_component$4(s, l, g), e = !0; + }, + p(l, g) { + const _ = {}; + g[0] & /*vals*/ + 1 && (_.seq = /*item*/ + l[44].sequence), s.$set(_); + }, + i(l) { + e || (transition_in$4(s.$$.fragment, l), e = !0); + }, + o(l) { + transition_out$4(s.$$.fragment, l), e = !1; + }, + d(l) { + destroy_component$4(s, l); + } + }; +} +function create_each_block_4(y) { + let s, e, l, g, _ = ( + /*item*/ + y[44].chain + "" + ), x, o, p, E, u = ( + /*labels*/ + y[6][ + /*item*/ + y[44].class + ] + "" + ), A, C, L, D, r, n, b, f, c, t, a, h, M, w, S, T, R, z = !/*item*/ + y[44].open && /*item*/ + y[44].class === "ligand" && create_if_block_11$1(y); + function P(...$) { + return ( + /*click_handler*/ + y[13]( + /*i*/ + y[35], + ...$ + ) + ); + } + function B() { + return ( + /*click_handler_1*/ + y[14]( + /*item*/ + y[44], + /*each_value_4*/ + y[45], + /*i*/ + y[35] + ) + ); + } + let U = ( + /*item*/ + y[44].open && create_if_block_8$1(y) + ), F = !/*item*/ + y[44].open && create_if_block_3$2(y); + return { + c() { + s = element$5("h2"), e = element$5("button"), l = element$5("div"), g = element$5("span"), x = text$4(_), p = space$4(), E = element$5("span"), A = text$4(u), C = space$4(), L = element$5("span"), z && z.c(), D = space$4(), r = element$5("div"), n = svg_element$1("svg"), b = svg_element$1("path"), f = space$4(), c = svg_element$1("svg"), t = svg_element$1("path"), h = space$4(), U && U.c(), M = space$4(), F && F.c(), w = empty$3(), attr$5(g, "class", o = "inline-flex items-center justify-center p-1 px-2 text-xs font-semibold rounded-full " + /*colorCode*/ + y[7][ + /*item*/ + y[44].class + ] + " svelte-fryf3t"), attr$5(E, "class", "svelte-fryf3t"), attr$5(L, "class", "px-2 text-gray-800 font-bold svelte-fryf3t"), attr$5(l, "class", "svelte-fryf3t"), attr$5(b, "stroke-linecap", "round"), attr$5(b, "stroke-linejoin", "round"), attr$5(b, "d", "M6 18 18 6M6 6l12 12"), attr$5(b, "class", "svelte-fryf3t"), attr$5(n, "data-slot", "icon"), attr$5(n, "fill", "none"), attr$5(n, "stroke-width", "3"), attr$5(n, "stroke", "currentColor"), attr$5(n, "viewBox", "0 0 24 24"), attr$5(n, "xmlns", "http://www.w3.org/2000/svg"), attr$5(n, "aria-hidden", "true"), attr$5(n, "class", "w-4 h-4 text-red-800 svelte-fryf3t"), attr$5(t, "stroke", "currentColor"), attr$5(t, "stroke-linecap", "round"), attr$5(t, "stroke-linejoin", "round"), attr$5(t, "stroke-width", "2"), attr$5(t, "d", "M9 5 5 1 1 5"), attr$5(t, "class", "svelte-fryf3t"), attr$5(c, "data-accordion-icon", ""), attr$5(c, "class", "w-3 h-3 shrink-0 svelte-fryf3t"), attr$5(c, "aria-hidden", "true"), attr$5(c, "xmlns", "http://www.w3.org/2000/svg"), attr$5(c, "fill", "none"), attr$5(c, "viewBox", "0 0 10 6"), toggle_class$4( + c, + "rotate-180", + /*item*/ + y[44].open + ), toggle_class$4(c, "-rotate-90", !/*item*/ + y[44].open), attr$5(r, "class", "flex items-center space-x-2 svelte-fryf3t"), attr$5(e, "type", "button"), attr$5(e, "class", "flex items-center justify-between w-full p-5 font-medium rtl:text-right text-gray-500 border border-gray-200 dark:border-gray-700 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 gap-3 svelte-fryf3t"), attr$5(e, "data-accordion-target", `#accordion-collapse-body-${/*i*/ + y[35]}`), attr$5(e, "aria-expanded", a = /*item*/ + y[44].open), attr$5(e, "aria-controls", `accordion-collapse-body-${/*i*/ + y[35]}`), toggle_class$4( + e, + "rounded-t-xl", + /*i*/ + y[35] === 0 + ), toggle_class$4( + e, + "rounded-b-xl", + /*i*/ + y[35] == /*vals*/ + y[0].length - 1 + ), toggle_class$4( + e, + "border-b-0", + /*i*/ + y[35] != /*vals*/ + y[0].length - 1 + ), attr$5(s, "id", `accordion-collapse-heading-${/*i*/ + y[35]}`), attr$5(s, "class", "svelte-fryf3t"); + }, + m($, W) { + insert$6($, s, W), append$4(s, e), append$4(e, l), append$4(l, g), append$4(g, x), append$4(l, p), append$4(l, E), append$4(E, A), append$4(l, C), append$4(l, L), z && z.m(L, null), append$4(e, D), append$4(e, r), append$4(r, n), append$4(n, b), append$4(r, f), append$4(r, c), append$4(c, t), insert$6($, h, W), U && U.m($, W), insert$6($, M, W), F && F.m($, W), insert$6($, w, W), S = !0, T || (R = [ + listen$1(n, "click", P), + listen$1(e, "click", B) + ], T = !0); + }, + p($, W) { + y = $, (!S || W[0] & /*vals*/ + 1) && _ !== (_ = /*item*/ + y[44].chain + "") && set_data$4(x, _), (!S || W[0] & /*vals*/ + 1 && o !== (o = "inline-flex items-center justify-center p-1 px-2 text-xs font-semibold rounded-full " + /*colorCode*/ + y[7][ + /*item*/ + y[44].class + ] + " svelte-fryf3t")) && attr$5(g, "class", o), (!S || W[0] & /*vals*/ + 1) && u !== (u = /*labels*/ + y[6][ + /*item*/ + y[44].class + ] + "") && set_data$4(A, u), !/*item*/ + y[44].open && /*item*/ + y[44].class === "ligand" ? z ? z.p(y, W) : (z = create_if_block_11$1(y), z.c(), z.m(L, null)) : z && (z.d(1), z = null), (!S || W[0] & /*vals*/ + 1) && toggle_class$4( + c, + "rotate-180", + /*item*/ + y[44].open + ), (!S || W[0] & /*vals*/ + 1) && toggle_class$4(c, "-rotate-90", !/*item*/ + y[44].open), (!S || W[0] & /*vals*/ + 1 && a !== (a = /*item*/ + y[44].open)) && attr$5(e, "aria-expanded", a), (!S || W[0] & /*vals*/ + 1) && toggle_class$4( + e, + "rounded-b-xl", + /*i*/ + y[35] == /*vals*/ + y[0].length - 1 + ), (!S || W[0] & /*vals*/ + 1) && toggle_class$4( + e, + "border-b-0", + /*i*/ + y[35] != /*vals*/ + y[0].length - 1 + ), /*item*/ + y[44].open ? U ? (U.p(y, W), W[0] & /*vals*/ + 1 && transition_in$4(U, 1)) : (U = create_if_block_8$1(y), U.c(), transition_in$4(U, 1), U.m(M.parentNode, M)) : U && (group_outros$4(), transition_out$4(U, 1, 1, () => { + U = null; + }), check_outros$4()), /*item*/ + y[44].open ? F && (group_outros$4(), transition_out$4(F, 1, 1, () => { + F = null; + }), check_outros$4()) : F ? (F.p(y, W), W[0] & /*vals*/ + 1 && transition_in$4(F, 1)) : (F = create_if_block_3$2(y), F.c(), transition_in$4(F, 1), F.m(w.parentNode, w)); + }, + i($) { + S || (transition_in$4(U), transition_in$4(F), S = !0); + }, + o($) { + transition_out$4(U), transition_out$4(F), S = !1; + }, + d($) { + $ && (detach$6(s), detach$6(h), detach$6(M), detach$6(w)), z && z.d(), U && U.d($), F && F.d($), T = !1, run_all$1(R); + } + }; +} +function create_if_block$4(y) { + let s, e, l, g = ensure_array_like$1( + /*covMods*/ + y[1] + ), _ = []; + for (let x = 0; x < g.length; x += 1) + _[x] = create_each_block$1(get_each_context$1(y, g, x)); + return { + c() { + s = element$5("h4"), s.textContent = "Covalent Modification", e = space$4(); + for (let x = 0; x < _.length; x += 1) + _[x].c(); + l = empty$3(), attr$5(s, "class", "text-center font-bold text-xl svelte-fryf3t"); + }, + m(x, o) { + insert$6(x, s, o), insert$6(x, e, o); + for (let p = 0; p < _.length; p += 1) + _[p] && _[p].m(x, o); + insert$6(x, l, o); + }, + p(x, o) { + if (o[0] & /*dispatch, covMods, ligandChains, getResAtoms, getResname, proteinChains*/ + 1594) { + g = ensure_array_like$1( + /*covMods*/ + x[1] + ); + let p; + for (p = 0; p < g.length; p += 1) { + const E = get_each_context$1(x, g, p); + _[p] ? _[p].p(E, o) : (_[p] = create_each_block$1(E), _[p].c(), _[p].m(l.parentNode, l)); + } + for (; p < _.length; p += 1) + _[p].d(1); + _.length = g.length; + } + }, + d(x) { + x && (detach$6(s), detach$6(e), detach$6(l)), destroy_each$1(_, x); + } + }; +} +function create_each_block_3(y) { + let s, e = ( + /*chain*/ + y[36] + "" + ), l, g; + return { + c() { + s = element$5("option"), l = text$4(e), s.__value = g = /*chain*/ + y[36], set_input_value$1(s, s.__value), attr$5(s, "class", "svelte-fryf3t"); + }, + m(_, x) { + insert$6(_, s, x), append$4(s, l); + }, + p(_, x) { + x[0] & /*proteinChains*/ + 8 && e !== (e = /*chain*/ + _[36] + "") && set_data$4(l, e), x[0] & /*proteinChains*/ + 8 && g !== (g = /*chain*/ + _[36]) && (s.__value = g, set_input_value$1(s, s.__value)); + }, + d(_) { + _ && detach$6(s); + } + }; +} +function create_else_block_1$1(y) { + let s; + return { + c() { + s = element$5("option"), s.disabled = !0, s.__value = "", set_input_value$1(s, s.__value), attr$5(s, "class", "svelte-fryf3t"); + }, + m(e, l) { + insert$6(e, s, l); + }, + p: noop$6, + d(e) { + e && detach$6(s); + } + }; +} +function create_if_block_2$2(y) { + let s, e = ensure_array_like$1( + /*getResAtoms*/ + y[9]( + /*covMod*/ + y[33] + ) + ), l = []; + for (let g = 0; g < e.length; g += 1) + l[g] = create_each_block_2(get_each_context_2(y, e, g)); + return { + c() { + for (let g = 0; g < l.length; g += 1) + l[g].c(); + s = empty$3(); + }, + m(g, _) { + for (let x = 0; x < l.length; x += 1) + l[x] && l[x].m(g, _); + insert$6(g, s, _); + }, + p(g, _) { + if (_[0] & /*getResAtoms, covMods, getResname*/ + 1538) { + e = ensure_array_like$1( + /*getResAtoms*/ + g[9]( + /*covMod*/ + g[33] + ) + ); + let x; + for (x = 0; x < e.length; x += 1) { + const o = get_each_context_2(g, e, x); + l[x] ? l[x].p(o, _) : (l[x] = create_each_block_2(o), l[x].c(), l[x].m(s.parentNode, s)); + } + for (; x < l.length; x += 1) + l[x].d(1); + l.length = e.length; + } + }, + d(g) { + g && detach$6(s), destroy_each$1(l, g); + } + }; +} +function create_each_block_2(y) { + let s, e, l = ( + /*getResname*/ + y[10]( + /*covMod*/ + y[33] + ) + "" + ), g, _, x = ( + /*atom*/ + y[39] + "" + ), o, p; + return { + c() { + s = text$4(`} + `), e = element$5("option"), g = text$4(l), _ = text$4(":"), o = text$4(x), e.__value = p = /*atom*/ + y[39], set_input_value$1(e, e.__value), attr$5(e, "class", "svelte-fryf3t"); + }, + m(E, u) { + insert$6(E, s, u), insert$6(E, e, u), append$4(e, g), append$4(e, _), append$4(e, o); + }, + p(E, u) { + u[0] & /*covMods*/ + 2 && l !== (l = /*getResname*/ + E[10]( + /*covMod*/ + E[33] + ) + "") && set_data$4(g, l), u[0] & /*covMods*/ + 2 && x !== (x = /*atom*/ + E[39] + "") && set_data$4(o, x), u[0] & /*covMods, proteinChains*/ + 10 && p !== (p = /*atom*/ + E[39]) && (e.__value = p, set_input_value$1(e, e.__value)); + }, + d(E) { + E && (detach$6(s), detach$6(e)); + } + }; +} +function create_each_block_1$1(y) { + let s, e = ( + /*chain*/ + y[36] + "" + ), l, g, _; + return { + c() { + s = element$5("option"), l = text$4(e), s.__value = g = /*chain*/ + y[36], set_input_value$1(s, s.__value), s.selected = _ = /*chain*/ + y[36] === /*covMod*/ + y[33].ligand, attr$5(s, "class", "svelte-fryf3t"); + }, + m(x, o) { + insert$6(x, s, o), append$4(s, l); + }, + p(x, o) { + o[0] & /*ligandChains*/ + 16 && e !== (e = /*chain*/ + x[36] + "") && set_data$4(l, e), o[0] & /*ligandChains*/ + 16 && g !== (g = /*chain*/ + x[36]) && (s.__value = g, set_input_value$1(s, s.__value)), o[0] & /*ligandChains, covMods, proteinChains*/ + 26 && _ !== (_ = /*chain*/ + x[36] === /*covMod*/ + x[33].ligand) && (s.selected = _); + }, + d(x) { + x && detach$6(s); + } + }; +} +function create_else_block$3(y) { + let s; + return { + c() { + s = element$5("p"), s.textContent = "click on atom", attr$5(s, "class", "font-mono svelte-fryf3t"); + }, + m(e, l) { + insert$6(e, s, l); + }, + p: noop$6, + d(e) { + e && detach$6(s); + } + }; +} +function create_if_block_1$3(y) { + let s, e, l = ( + /*covMod*/ + y[33].attachmentIndex + "" + ), g; + return { + c() { + s = element$5("p"), e = text$4("index "), g = text$4(l), attr$5(s, "class", "font-mono svelte-fryf3t"); + }, + m(_, x) { + insert$6(_, s, x), append$4(s, e), append$4(s, g); + }, + p(_, x) { + x[0] & /*covMods*/ + 2 && l !== (l = /*covMod*/ + _[33].attachmentIndex + "") && set_data$4(g, l); + }, + d(_) { + _ && detach$6(s); + } + }; +} +function create_each_block$1(y) { + let s, e, l, g, _, x, o, p, E, u, A, C, L, D, r, n, b, f, c, t, a, h, M, w, S, T, R, z, P, B, U, F, $, W, N, G, k, j, Q, ie, pe, he, ue = ensure_array_like$1( + /*proteinChains*/ + y[3] + ), se = []; + for (let Te = 0; Te < ue.length; Te += 1) + se[Te] = create_each_block_3(get_each_context_3(y, ue, Te)); + function ae() { + y[19].call( + E, + /*i*/ + y[35] + ); + } + function we(...Te) { + return ( + /*input_handler_3*/ + y[21]( + /*i*/ + y[35], + ...Te + ) + ); + } + function xe(Te, je) { + return ( + /*covMod*/ + Te[33].residue != "" ? create_if_block_2$2 : create_else_block_1$1 + ); + } + let Ie = xe(y), oe = Ie(y); + function ve() { + y[22].call( + D, + /*i*/ + y[35] + ); + } + function re() { + y[24].call( + n, + /*i*/ + y[35] + ); + } + let Se = ensure_array_like$1( + /*ligandChains*/ + y[4] + ), ze = []; + for (let Te = 0; Te < Se.length; Te += 1) + ze[Te] = create_each_block_1$1(get_each_context_1$1(y, Se, Te)); + function Ge() { + y[26].call( + z, + /*i*/ + y[35] + ); + } + function $e(Te, je) { + return ( + /*covMod*/ + Te[33].attachmentIndex ? create_if_block_1$3 : create_else_block$3 + ); + } + let Re = $e(y), Be = Re(y); + function ke() { + y[28].call( + F, + /*i*/ + y[35] + ); + } + function We(...Te) { + return ( + /*click_handler_3*/ + y[30]( + /*i*/ + y[35], + ...Te + ) + ); + } + return { + c() { + s = element$5("div"), e = element$5("div"), l = element$5("div"), g = element$5("div"), g.innerHTML = 'Protein', _ = space$4(), x = element$5("div"), x.innerHTML = 'Chain Residue Atom Chirality', o = space$4(), p = element$5("div"), E = element$5("select"); + for (let Te = 0; Te < se.length; Te += 1) + se[Te].c(); + u = space$4(), A = element$5("input"), L = space$4(), D = element$5("select"), oe.c(), r = space$4(), n = element$5("select"), b = element$5("option"), b.textContent = "no chirality defined", f = element$5("option"), f.textContent = "CW", c = element$5("option"), c.textContent = "CCW", t = space$4(), a = element$5("div"), h = element$5("div"), M = element$5("div"), M.innerHTML = 'Small molecule', w = space$4(), S = element$5("div"), S.innerHTML = 'Chain Atom index Chirality', T = space$4(), R = element$5("div"), z = element$5("select"); + for (let Te = 0; Te < ze.length; Te += 1) + ze[Te].c(); + P = space$4(), B = element$5("div"), Be.c(), U = space$4(), F = element$5("select"), $ = element$5("option"), $.textContent = "no chirality defined", W = element$5("option"), W.textContent = "CW", N = element$5("option"), N.textContent = "CCW", G = space$4(), k = element$5("div"), j = svg_element$1("svg"), Q = svg_element$1("path"), ie = space$4(), attr$5(g, "class", "flex justify-center svelte-fryf3t"), attr$5(x, "class", "grid grid-cols-4 font-bold svelte-fryf3t"), attr$5(E, "name", ""), attr$5(E, "id", ""), attr$5(E, "class", "svelte-fryf3t"), /*covMods*/ + y[1][ + /*i*/ + y[35] + ].protein === void 0 && add_render_callback$2(ae), attr$5(A, "type", "text"), attr$5(A, "placeholder", "residue "), attr$5(A, "class", "px-3 svelte-fryf3t"), A.value = C = /*covMod*/ + y[33].residue, attr$5(D, "name", ""), attr$5(D, "id", ""), attr$5(D, "class", "svelte-fryf3t"), /*covMods*/ + y[1][ + /*i*/ + y[35] + ].atom === void 0 && add_render_callback$2(ve), b.__value = "", set_input_value$1(b, b.__value), attr$5(b, "class", "svelte-fryf3t"), f.__value = "CW", set_input_value$1(f, f.__value), attr$5(f, "class", "svelte-fryf3t"), c.__value = "CCW", set_input_value$1(c, c.__value), attr$5(c, "class", "svelte-fryf3t"), attr$5(n, "name", ""), attr$5(n, "id", ""), attr$5(n, "class", "svelte-fryf3t"), /*covMods*/ + y[1][ + /*i*/ + y[35] + ].protein_symmetry === void 0 && add_render_callback$2(re), attr$5(p, "class", "grid grid-cols-4 svelte-fryf3t"), attr$5(l, "class", "w-3/5 flex-col px-2 svelte-fryf3t"), attr$5(M, "class", "flex justify-center svelte-fryf3t"), attr$5(S, "class", "grid grid-cols-3 font-bold svelte-fryf3t"), attr$5(z, "name", ""), attr$5(z, "id", ""), attr$5(z, "title", "click on atom in structure"), attr$5(z, "class", "svelte-fryf3t"), /*covMods*/ + y[1][ + /*i*/ + y[35] + ].ligand === void 0 && add_render_callback$2(Ge), attr$5(B, "class", "svelte-fryf3t"), $.__value = "", set_input_value$1($, $.__value), attr$5($, "class", "svelte-fryf3t"), W.__value = "CW", set_input_value$1(W, W.__value), attr$5(W, "class", "svelte-fryf3t"), N.__value = "CCW", set_input_value$1(N, N.__value), attr$5(N, "class", "svelte-fryf3t"), attr$5(F, "name", ""), attr$5(F, "id", ""), attr$5(F, "class", "svelte-fryf3t"), /*covMods*/ + y[1][ + /*i*/ + y[35] + ].ligand_symmetry === void 0 && add_render_callback$2(ke), attr$5(R, "class", "grid grid-cols-3 svelte-fryf3t"), attr$5(h, "class", "flex-col p-1 svelte-fryf3t"), attr$5(a, "class", "w-2/5 px-2 svelte-fryf3t"), attr$5(e, "class", "flex divide-x rounded border p-1 svelte-fryf3t"), attr$5(Q, "stroke-linecap", "round"), attr$5(Q, "stroke-linejoin", "round"), attr$5(Q, "d", "M6 18 18 6M6 6l12 12"), attr$5(Q, "class", "svelte-fryf3t"), attr$5(j, "data-slot", "icon"), attr$5(j, "fill", "none"), attr$5(j, "stroke-width", "2"), attr$5(j, "stroke", "currentColor"), attr$5(j, "viewBox", "0 0 24 24"), attr$5(j, "xmlns", "http://www.w3.org/2000/svg"), attr$5(j, "aria-hidden", "true"), attr$5(j, "class", "w-8 h-8 text-red-800 cursor-pointer svelte-fryf3t"), attr$5(k, "class", "flex items-center p-2 svelte-fryf3t"), attr$5(s, "class", "flex p-10 svelte-fryf3t"); + }, + m(Te, je) { + insert$6(Te, s, je), append$4(s, e), append$4(e, l), append$4(l, g), append$4(l, _), append$4(l, x), append$4(l, o), append$4(l, p), append$4(p, E); + for (let Fe = 0; Fe < se.length; Fe += 1) + se[Fe] && se[Fe].m(E, null); + select_option( + E, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].protein, + !0 + ), append$4(p, u), append$4(p, A), append$4(p, L), append$4(p, D), oe.m(D, null), select_option( + D, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].atom, + !0 + ), append$4(p, r), append$4(p, n), append$4(n, b), append$4(n, f), append$4(n, c), select_option( + n, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].protein_symmetry, + !0 + ), append$4(e, t), append$4(e, a), append$4(a, h), append$4(h, M), append$4(h, w), append$4(h, S), append$4(h, T), append$4(h, R), append$4(R, z); + for (let Fe = 0; Fe < ze.length; Fe += 1) + ze[Fe] && ze[Fe].m(z, null); + select_option( + z, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].ligand, + !0 + ), append$4(R, P), append$4(R, B), Be.m(B, null), append$4(R, U), append$4(R, F), append$4(F, $), append$4(F, W), append$4(F, N), select_option( + F, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].ligand_symmetry, + !0 + ), append$4(s, G), append$4(s, k), append$4(k, j), append$4(j, Q), append$4(s, ie), pe || (he = [ + listen$1(E, "change", ae), + listen$1( + E, + "change", + /*change_handler*/ + y[20] + ), + listen$1(A, "input", we), + listen$1(D, "change", ve), + listen$1( + D, + "change", + /*change_handler_1*/ + y[23] + ), + listen$1(n, "change", re), + listen$1( + n, + "change", + /*change_handler_2*/ + y[25] + ), + listen$1(z, "change", Ge), + listen$1( + z, + "change", + /*change_handler_3*/ + y[27] + ), + listen$1(F, "change", ke), + listen$1( + F, + "change", + /*change_handler_4*/ + y[29] + ), + listen$1(j, "click", We) + ], pe = !0); + }, + p(Te, je) { + if (y = Te, je[0] & /*proteinChains*/ + 8) { + ue = ensure_array_like$1( + /*proteinChains*/ + y[3] + ); + let Fe; + for (Fe = 0; Fe < ue.length; Fe += 1) { + const X = get_each_context_3(y, ue, Fe); + se[Fe] ? se[Fe].p(X, je) : (se[Fe] = create_each_block_3(X), se[Fe].c(), se[Fe].m(E, null)); + } + for (; Fe < se.length; Fe += 1) + se[Fe].d(1); + se.length = ue.length; + } + if (je[0] & /*covMods, proteinChains*/ + 10 && select_option( + E, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].protein + ), je[0] & /*covMods, proteinChains*/ + 10 && C !== (C = /*covMod*/ + y[33].residue) && A.value !== C && (A.value = C), Ie === (Ie = xe(y)) && oe ? oe.p(y, je) : (oe.d(1), oe = Ie(y), oe && (oe.c(), oe.m(D, null))), je[0] & /*covMods, proteinChains*/ + 10 && select_option( + D, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].atom + ), je[0] & /*covMods, proteinChains*/ + 10 && select_option( + n, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].protein_symmetry + ), je[0] & /*ligandChains, covMods*/ + 18) { + Se = ensure_array_like$1( + /*ligandChains*/ + y[4] + ); + let Fe; + for (Fe = 0; Fe < Se.length; Fe += 1) { + const X = get_each_context_1$1(y, Se, Fe); + ze[Fe] ? ze[Fe].p(X, je) : (ze[Fe] = create_each_block_1$1(X), ze[Fe].c(), ze[Fe].m(z, null)); + } + for (; Fe < ze.length; Fe += 1) + ze[Fe].d(1); + ze.length = Se.length; + } + je[0] & /*covMods, proteinChains*/ + 10 && select_option( + z, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].ligand + ), Re === (Re = $e(y)) && Be ? Be.p(y, je) : (Be.d(1), Be = Re(y), Be && (Be.c(), Be.m(B, null))), je[0] & /*covMods, proteinChains*/ + 10 && select_option( + F, + /*covMods*/ + y[1][ + /*i*/ + y[35] + ].ligand_symmetry + ); + }, + d(Te) { + Te && detach$6(s), destroy_each$1(se, Te), oe.d(), destroy_each$1(ze, Te), Be.d(), pe = !1, run_all$1(he); + } + }; +} +function create_fragment$6(y) { + let s, e, l, g, _ = ensure_array_like$1( + /*vals*/ + y[0] + ), x = []; + for (let E = 0; E < _.length; E += 1) + x[E] = create_each_block_4(get_each_context_4(y, _, E)); + const o = (E) => transition_out$4(x[E], 1, 1, () => { + x[E] = null; + }); + let p = ( + /*covMods*/ + y[1].length > 0 && create_if_block$4(y) + ); + return { + c() { + s = element$5("div"); + for (let E = 0; E < x.length; E += 1) + x[E].c(); + e = space$4(), l = element$5("div"), p && p.c(), attr$5(l, "class", "p-5 border border-t-0 border-gray-200 dark:border-gray-700 svelte-fryf3t"), attr$5(s, "id", "accordion-collapse"), attr$5(s, "data-accordion", "collapse"), attr$5(s, "class", "svelte-fryf3t"); + }, + m(E, u) { + insert$6(E, s, u); + for (let A = 0; A < x.length; A += 1) + x[A] && x[A].m(s, null); + append$4(s, e), append$4(s, l), p && p.m(l, null), g = !0; + }, + p(E, u) { + if (u[0] & /*vals, showCovModVals, updateMol, dispatch, metals, handleMessage, labels, colorCode*/ + 6629) { + _ = ensure_array_like$1( + /*vals*/ + E[0] + ); + let A; + for (A = 0; A < _.length; A += 1) { + const C = get_each_context_4(E, _, A); + x[A] ? (x[A].p(C, u), transition_in$4(x[A], 1)) : (x[A] = create_each_block_4(C), x[A].c(), transition_in$4(x[A], 1), x[A].m(s, e)); + } + for (group_outros$4(), A = _.length; A < x.length; A += 1) + o(A); + check_outros$4(); + } + /*covMods*/ + E[1].length > 0 ? p ? p.p(E, u) : (p = create_if_block$4(E), p.c(), p.m(l, null)) : p && (p.d(1), p = null); + }, + i(E) { + if (!g) { + for (let u = 0; u < _.length; u += 1) + transition_in$4(x[u]); + g = !0; + } + }, + o(E) { + x = x.filter(Boolean); + for (let u = 0; u < x.length; u += 1) + transition_out$4(x[u]); + g = !1; + }, + d(E) { + E && detach$6(s), destroy_each$1(x, E), p && p.d(); + } + }; +} +function instance$6(y, s, e) { + const l = createEventDispatcher$2(); + let { vals: g = [] } = s, { covMods: _ = [] } = s, x = [], o = { + DNA: "NA sequence", + RNA: "NA sequence", + protein: "Protein sequence", + ligand: "Small molecule" + }, p = { + DNA: "bg-green-200 text-blue-800", + RNA: "bg-green-200 text-blue-800", + protein: "bg-blue-200 text-blue-800", + ligand: "bg-orange-200 text-blue-800" + }, E = ["ZN", "MG", "CA", "FE", "NA", "K", "CL", "CU", "MN", "CO", "NI"], u = [], A = [], C = { + A: ["C", "CA", "CB", "N", "O"], + R: ["C", "CA", "CB", "CG", "CD", "CZ", "N", "NE", "O", "NH1", "NH2"], + D: ["C", "CA", "CB", "CG", "N", "O", "OD1", "OD2"], + N: ["C", "CA", "CB", "CG", "N", "ND2", "O", "OD1"], + C: ["C", "CA", "CB", "N", "O", "SG"], + E: ["C", "CA", "CB", "CG", "CD", "N", "O", "OE1", "OE2"], + N: ["C", "CA", "CB", "CG", "CD", "N", "NE2", "O", "OE1"], + G: ["C", "CA", "N", "O"], + H: ["C", "CA", "CB", "CG", "CD2", "CE1", "N", "ND1", "NE2", "O"], + I: ["C", "CA", "CB", "CG1", "CG2", "CD1", "N", "O"], + L: ["C", "CA", "CB", "CG", "CD1", "CD2", "N", "O"], + K: ["C", "CA", "CB", "CG", "CD", "CE", "N", "NZ", "O"], + M: ["C", "CA", "CB", "CG", "CE", "N", "O", "SD"], + F: ["C", "CA", "CB", "CG", "CD1", "CD2", "CE1", "CE2", "CZ", "N", "O"], + P: ["C", "CA", "CB", "CG", "CD", "N", "O"], + S: ["C", "CA", "CB", "N", "O", "OG"], + T: ["C", "CA", "CB", "CG2", "N", "O", "OG1"], + W: [ + "C", + "CA", + "CB", + "CG", + "CD1", + "CD2", + "CE2", + "CE3", + "CZ2", + "CZ3", + "CH2", + "N", + "NE1", + "O" + ], + Y: ["C", "CA", "CB", "CG", "CD1", "CD2", "CE1", "CE2", "CZ", "N", "O", "OH"], + V: ["C", "CA", "CB", "CG1", "CG2", "N", "O"] + }, L = { + H: "HIS", + A: "ALA", + R: "ARG", + N: "ASN", + D: "ASP", + C: "CYS", + E: "GLU", + Q: "GLN", + G: "GLY", + H: "HIS", + I: "ILE", + L: "LEU", + K: "LYS", + M: "MET", + F: "PHE", + P: "PRO", + S: "SER", + T: "THR", + W: "TRP", + Y: "TYR", + V: "VAL" + }; + function D(G) { + let k = g.find((Q) => Q.chain === G.protein).sequence; + if (k.length < G.residue) + return alert("Residue number is too high"), []; + let j = k[G.residue - 1]; + return C[j]; + } + function r(G) { + let j = g.find((Q) => Q.chain === G.protein).sequence[G.residue - 1]; + return L[j]; + } + function n(G) { + let k = G.detail.index; + e(1, _[k].mol = G.detail.mol, _), e(1, _[k].attachmentIndex = G.detail.attachmentIndex, _), e(1, _[k].deleteIndexes = G.detail.deleteIndexes, _), l("updateCovMod", _); + } + function b(G) { + fetch(`https://files.rcsb.org/ligands/download/${G.detail.text}_ideal.sdf`).then((k) => { + if (!k.ok) + throw new Error("Network response was not ok"); + return k.text(); + }).then((k) => { + l("updateVals", { + sdf: k, + index: G.detail.index, + close: !0 + }); + }).catch((k) => { + alert("Error fetching sdf file"); + }); + } + const f = (G, k) => { + l("removeVal", G); + }, c = (G, k, j) => e(0, k[j].open = !G.open, g), t = (G, k) => { + l("updateVals", { sequence: k.target.value, index: G }); + }, a = (G, k) => { + l("updateVals", { smiles: k.target.value, index: G }); + }, h = (G, k) => { + l("updateVals", { sdf: k.target.value, index: G }); + }, M = (G, k) => l("updateVals", { name: G, index: k }); + function w(G) { + _[G].protein = select_value(this), e(1, _), e(3, u), e(0, g); + } + const S = () => l("updateCovMod", _), T = (G, k) => { + e(1, _[G].residue = k.target.value, _), l("updateCovMod", _); + }; + function R(G) { + _[G].atom = select_value(this), e(1, _), e(3, u), e(0, g); + } + const z = () => l("updateCovMod", _); + function P(G) { + _[G].protein_symmetry = select_value(this), e(1, _), e(3, u), e(0, g); + } + const B = () => l("updateCovMod", _); + function U(G) { + _[G].ligand = select_value(this), e(1, _), e(3, u), e(0, g); + } + const F = () => l("updateCovMod", _); + function $(G) { + _[G].ligand_symmetry = select_value(this), e(1, _), e(3, u), e(0, g); + } + const W = () => l("updateCovMod", _), N = (G, k) => { + l("removeCovMod", G); + }; + return y.$$set = (G) => { + "vals" in G && e(0, g = G.vals), "covMods" in G && e(1, _ = G.covMods); + }, y.$$.update = () => { + y.$$.dirty[0] & /*covMods, vals*/ + 3 && _ && e(2, x = g.map((G) => _.findIndex((k) => k.ligand === G.chain))), y.$$.dirty[0] & /*vals*/ + 1 && e(3, u = g.filter((G) => G.class === "protein").map((G) => G.chain)), y.$$.dirty[0] & /*vals*/ + 1 && e(4, A = g.filter((G) => G.class === "ligand").map((G) => G.chain)); + }, [ + g, + _, + x, + u, + A, + l, + o, + p, + E, + D, + r, + n, + b, + f, + c, + t, + a, + h, + M, + w, + S, + T, + R, + z, + P, + B, + U, + F, + $, + W, + N + ]; +} +class Accordion extends SvelteComponent$6 { + constructor(s) { + super(), init$6(this, s, instance$6, create_fragment$6, safe_not_equal$7, { vals: 0, covMods: 1 }, null, [-1, -1]); + } +} +const SequenceInput_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$5, + attr: attr$4, + check_outros: check_outros$3, + create_component: create_component$3, + destroy_component: destroy_component$3, + detach: detach$5, + element: element$4, + empty: empty$2, + flush: flush$1, + group_outros: group_outros$3, + init: init$5, + insert: insert$5, + mount_component: mount_component$3, + noop: noop$5, + safe_not_equal: safe_not_equal$6, + space: space$3, + transition_in: transition_in$3, + transition_out: transition_out$3 +} = window.__gradio__svelte__internal, { tick: tick$2 } = window.__gradio__svelte__internal, { createEventDispatcher: createEventDispatcher$1, onMount: onMount$3, afterUpdate: afterUpdate$1 } = window.__gradio__svelte__internal; +function create_if_block$3(y) { + let s, e, l, g; + const _ = [create_if_block_1$2, create_else_block$2], x = []; + function o(p, E) { + return ( + /*vals*/ + p[0].length > 0 ? 0 : 1 + ); + } + return s = o(y), e = x[s] = _[s](y), { + c() { + e.c(), l = empty$2(); + }, + m(p, E) { + x[s].m(p, E), insert$5(p, l, E), g = !0; + }, + p(p, E) { + let u = s; + s = o(p), s === u ? x[s].p(p, E) : (group_outros$3(), transition_out$3(x[u], 1, 1, () => { + x[u] = null; + }), check_outros$3(), e = x[s], e ? e.p(p, E) : (e = x[s] = _[s](p), e.c()), transition_in$3(e, 1), e.m(l.parentNode, l)); + }, + i(p) { + g || (transition_in$3(e), g = !0); + }, + o(p) { + transition_out$3(e), g = !1; + }, + d(p) { + p && detach$5(l), x[s].d(p); + } + }; +} +function create_else_block$2(y) { + let s, e, l, g, _, x, o, p; + return _ = new SearchInput({ props: { database: "rcsb-bioass" } }), _.$on( + "triggerFetch", + /*handleMessage*/ + y[2] + ), { + c() { + s = element$4("div"), s.textContent = "Empty input", e = space$3(), l = element$4("div"), l.textContent = "You can import a protein from the PDB", g = space$3(), create_component$3(_.$$.fragment), x = space$3(), o = element$4("div"), o.textContent = "- or create the input from scratch -", attr$4(s, "class", "my-8 text-center text-gray-600 svelte-13zuw1o"), attr$4(l, "class", "text-center text-gray-400 svelte-13zuw1o"), attr$4(o, "class", "text-center text-gray-400 w-full my-2 svelte-13zuw1o"); + }, + m(E, u) { + insert$5(E, s, u), insert$5(E, e, u), insert$5(E, l, u), insert$5(E, g, u), mount_component$3(_, E, u), insert$5(E, x, u), insert$5(E, o, u), p = !0; + }, + p: noop$5, + i(E) { + p || (transition_in$3(_.$$.fragment, E), p = !0); + }, + o(E) { + transition_out$3(_.$$.fragment, E), p = !1; + }, + d(E) { + E && (detach$5(s), detach$5(e), detach$5(l), detach$5(g), detach$5(x), detach$5(o)), destroy_component$3(_, E); + } + }; +} +function create_if_block_1$2(y) { + let s, e; + return s = new Accordion({ + props: { + vals: ( + /*vals*/ + y[0] + ), + covMods: ( + /*covMods*/ + y[1] + ) + } + }), s.$on( + "updateVals", + /*update*/ + y[3] + ), s.$on( + "removeVal", + /*remove*/ + y[5] + ), s.$on( + "removeCovMod", + /*removeCovMod*/ + y[7] + ), s.$on( + "updateCovMod", + /*syncCovMod*/ + y[8] + ), { + c() { + create_component$3(s.$$.fragment); + }, + m(l, g) { + mount_component$3(s, l, g), e = !0; + }, + p(l, g) { + const _ = {}; + g & /*vals*/ + 1 && (_.vals = /*vals*/ + l[0]), g & /*covMods*/ + 2 && (_.covMods = /*covMods*/ + l[1]), s.$set(_); + }, + i(l) { + e || (transition_in$3(s.$$.fragment, l), e = !0); + }, + o(l) { + transition_out$3(s.$$.fragment, l), e = !1; + }, + d(l) { + destroy_component$3(s, l); + } + }; +} +function create_fragment$5(y) { + let s, e, l, g = ( + /*vals*/ + y[0] != null && create_if_block$3(y) + ); + return e = new Button({ props: { vals: ( + /*vals*/ + y[0] + ) } }), e.$on( + "addNewChain", + /*insertChain*/ + y[4] + ), e.$on( + "addCovalentModification", + /*addCovMod*/ + y[6] + ), { + c() { + g && g.c(), s = space$3(), create_component$3(e.$$.fragment); + }, + m(_, x) { + g && g.m(_, x), insert$5(_, s, x), mount_component$3(e, _, x), l = !0; + }, + p(_, [x]) { + /*vals*/ + _[0] != null ? g ? (g.p(_, x), x & /*vals*/ + 1 && transition_in$3(g, 1)) : (g = create_if_block$3(_), g.c(), transition_in$3(g, 1), g.m(s.parentNode, s)) : g && (group_outros$3(), transition_out$3(g, 1, 1, () => { + g = null; + }), check_outros$3()); + const o = {}; + x & /*vals*/ + 1 && (o.vals = /*vals*/ + _[0]), e.$set(o); + }, + i(_) { + l || (transition_in$3(g), transition_in$3(e.$$.fragment, _), l = !0); + }, + o(_) { + transition_out$3(g), transition_out$3(e.$$.fragment, _), l = !1; + }, + d(_) { + _ && detach$5(s), g && g.d(_), destroy_component$3(e, _); + } + }; +} +async function getSDF(y) { + return await fetch(`https://files.rcsb.org/ligands/download/${y}_ideal.sdf`).then((e) => { + if (!e.ok) + throw new Error("Network response was not ok"); + return e.text(); + }).catch((e) => { + alert("Error fetching sdf file"); + }); +} +function nextChainTemp(y) { + if (y == "") + return "A"; + let s = ""; + return y == "Z" ? s = "AA" : y.length > 1 && y.slice(-1) === "Z" ? s = String.fromCharCode(y.charCodeAt(0) + 1) + "A" : s = y.slice(0, -1) + String.fromCharCode(y.slice(-1).charCodeAt(0) + 1), s; +} +async function fetchMolecules(y) { + const s = `https://www.ebi.ac.uk/pdbe/api/pdb/entry/molecules/${y}`; + try { + const e = await fetch(s); + if (!e.ok) + throw new Error(`Error fetching molecules for PDB ID ${y}: ${e.statusText}`); + return await e.json(); + } catch (e) { + console.error("Error fetching molecules:", e); + } +} +async function fetchXmlText(y) { + try { + const s = await fetch(y); + if (!s.ok) + throw new Error(`Error fetching XML: ${s.statusText}`); + return await s.text(); + } catch (s) { + console.error("Error fetching XML:", s); + } +} +function parseAssembly(y) { + const s = { + id: y.getAttribute("id"), + composition: y.getAttribute("composition"), + molecularWeight: y.getAttribute("molecular_weight"), + name: y.getAttribute("name") + }, e = []; + return y.querySelectorAll("entity").forEach((l) => { + e.push({ + chainIds: l.getAttribute("chain_ids"), + class: l.getAttribute("class"), + count: l.getAttribute("count"), + entityId: Number(l.getAttribute("entity_id")) + // Added entityId + }); + }), s.entities = e, s; +} +function extractEntityInfo(y, s) { + if (y.class === "DNA" || y.class === "RNA" || y.class === "protein") { + const e = s.find((l) => l.entity_id === y.entityId); + if (e) + return e.sequence; + } else { + const e = s.find((l) => l.entity_id === y.entityId); + if (e) + return e.chem_comp_ids[0]; + } +} +function importBioAssembly(y) { + const s = fetchMolecules(y).then((_) => _).catch((_) => { + console.error("Error:", _); + }), e = `https://www.ebi.ac.uk/pdbe/static/entry/${y}-assembly.xml`, l = fetchXmlText(e).then((_) => { + const x = []; + return new DOMParser().parseFromString(_, "text/xml").querySelectorAll("assembly").forEach((u) => { + x.push(parseAssembly(u)); + }), x; + }); + return Promise.all([s, l]).then(([_, x]) => { + let o = []; + return x[0].entities.forEach((E) => { + const u = extractEntityInfo(E, _[y]); + o.push({ + class: E.class, + entityInfo: u, + count: E.count + }); + }), o; + }); +} +function instance$5(y, s, e) { + let { value: l = { chains: [], covMods: [] } } = s; + const g = createEventDispatcher$1(); + let _ = ["ZN", "MG", "CA", "FE", "NA", "K", "CL", "CU", "MN", "CO", "NI"]; + async function x(n) { + let b = n.detail.text; + b = b.toLowerCase(); + let f = await importBioAssembly(b), c = [], t = ""; + await Promise.all(f.map(async (a) => { + if (["DNA", "RNA", "protein"].includes(a.class)) + for (let h = 0; h < a.count; h++) + t = nextChainTemp(t), c.push({ + class: a.class, + name: "", + smiles: "", + sdf: "", + sequence: a.entityInfo, + open: !1, + chain: t + }), await tick$2(); + else if (a.class === "ligand") { + let h = "", M = ""; + _.includes(a.entityInfo) ? h = a.entityInfo : M = await getSDF(a.entityInfo); + for (let w = 0; w < a.count; w++) + t = nextChainTemp(t), c.push({ + class: a.class, + name: h, + smiles: "", + sdf: M, + sequence: "", + open: !1, + chain: t + }); + await tick$2(); + } + })), e(0, o = c), g("updateVals", o); + } + let o = [], p = []; + function E(n) { + n.detail.sequence !== void 0 && e(0, o[n.detail.index].sequence = n.detail.sequence, o), n.detail.name !== void 0 && (e(0, o[n.detail.index].name = n.detail.name, o), e(0, o[n.detail.index].open = n.detail.open, o), e(0, o[n.detail.index].sdf = "", o), e(0, o[n.detail.index].smiles = "", o)), n.detail.smiles !== void 0 && (e(0, o[n.detail.index].smiles = n.detail.smiles, o), e(0, o[n.detail.index].sdf = "", o), e(0, o[n.detail.index].name = "", o)), n.detail.sdf !== void 0 && (n.detail.close == !0 && e(0, o[n.detail.index].open = !1, o), e(0, o[n.detail.index].sdf = n.detail.sdf, o), e(0, o[n.detail.index].name = "", o), e(0, o[n.detail.index].smiles = "", o)), g("updateVals", o); + } + function u() { + let n = "A"; + for (let f of o) + f.chain > n && (n = f.chain); + let b = ""; + if (n < "Z") + b = String.fromCharCode(n.charCodeAt(0) + 1); + else { + let f = n.slice(-1); + f < "Z" ? b = n.slice(0, -1) + String.fromCharCode(f.charCodeAt(0) + 1) : b = n + "A"; + } + return b; + } + function A(n) { + let b = u(); + o.push({ + class: n.detail.type, + name: "", + smiles: "", + sdf: "", + sequence: "", + open: !0, + chain: b + }), e(0, o); + } + function C(n) { + o.splice(n.detail, 1), e(0, o); + } + function L(n) { + let b = o.find((t) => t.class === "protein").chain; + if (b === void 0) { + alert("Please add a protein chain first"); + return; + } + let f = o.find((t) => t.class === "ligand").chain; + if (f === void 0) { + alert("Please add a ligand chain first"); + return; + } + let c = { + protein: b, + residue: "1", + atom: "N", + protein_symmetry: "CW", + ligand: f, + attachmentIndex: 1, + deleteIndexes: [], + ligand_symmetry: "CW" + }; + p.push(c), e(1, p), e(0, o), g("updateCovMod", p); + } + function D(n) { + p.splice(n.detail, 1), e(1, p); + } + function r(n) { + e(1, p = n.detail), g("updateCovMod", p); + } + return onMount$3(async () => { + e(0, o = l.chains), e(1, p = l.covMods); + }), y.$$set = (n) => { + "value" in n && e(9, l = n.value); + }, [ + o, + p, + x, + E, + A, + C, + L, + D, + r, + l + ]; +} +class SequenceInput extends SvelteComponent$5 { + constructor(s) { + super(), init$5(this, s, instance$5, create_fragment$5, safe_not_equal$6, { value: 9 }); + } + get value() { + return this.$$.ctx[9]; + } + set value(s) { + this.$$set({ value: s }), flush$1(); + } +} +function pretty_si(y) { + let s = ["", "k", "M", "G", "T", "P", "E", "Z"], e = 0; + for (; y > 1e3 && e < s.length - 1; ) + y /= 1e3, e++; + let l = s[e]; + return (Number.isInteger(y) ? y : y.toFixed(1)) + l; +} +function noop$4() { +} +const identity = (y) => y; +function safe_not_equal$5(y, s) { + return y != y ? s == s : y !== s || y && typeof y == "object" || typeof y == "function"; +} +const is_client = typeof window < "u"; +let now = is_client ? () => window.performance.now() : () => Date.now(), raf = is_client ? (y) => requestAnimationFrame(y) : noop$4; +const tasks = /* @__PURE__ */ new Set(); +function run_tasks(y) { + tasks.forEach((s) => { + s.c(y) || (tasks.delete(s), s.f()); + }), tasks.size !== 0 && raf(run_tasks); +} +function loop(y) { + let s; + return tasks.size === 0 && raf(run_tasks), { + promise: new Promise((e) => { + tasks.add(s = { c: y, f: e }); + }), + abort() { + tasks.delete(s); + } + }; +} +function fade(y, { delay: s = 0, duration: e = 400, easing: l = identity } = {}) { + const g = +getComputedStyle(y).opacity; + return { + delay: s, + duration: e, + easing: l, + css: (_) => `opacity: ${_ * g}` + }; +} +const subscriber_queue = []; +function writable(y, s = noop$4) { + let e; + const l = /* @__PURE__ */ new Set(); + function g(o) { + if (safe_not_equal$5(y, o) && (y = o, e)) { + const p = !subscriber_queue.length; + for (const E of l) + E[1](), subscriber_queue.push(E, y); + if (p) { + for (let E = 0; E < subscriber_queue.length; E += 2) + subscriber_queue[E][0](subscriber_queue[E + 1]); + subscriber_queue.length = 0; + } + } + } + function _(o) { + g(o(y)); + } + function x(o, p = noop$4) { + const E = [o, p]; + return l.add(E), l.size === 1 && (e = s(g, _) || noop$4), o(y), () => { + l.delete(E), l.size === 0 && e && (e(), e = null); + }; + } + return { set: g, update: _, subscribe: x }; +} +function is_date(y) { + return Object.prototype.toString.call(y) === "[object Date]"; +} +function tick_spring(y, s, e, l) { + if (typeof e == "number" || is_date(e)) { + const g = l - e, _ = (e - s) / (y.dt || 1 / 60), x = y.opts.stiffness * g, o = y.opts.damping * _, p = (x - o) * y.inv_mass, E = (_ + p) * y.dt; + return Math.abs(E) < y.opts.precision && Math.abs(g) < y.opts.precision ? l : (y.settled = !1, is_date(e) ? new Date(e.getTime() + E) : e + E); + } else { + if (Array.isArray(e)) + return e.map( + (g, _) => tick_spring(y, s[_], e[_], l[_]) + ); + if (typeof e == "object") { + const g = {}; + for (const _ in e) + g[_] = tick_spring(y, s[_], e[_], l[_]); + return g; + } else + throw new Error(`Cannot spring ${typeof e} values`); + } +} +function spring(y, s = {}) { + const e = writable(y), { stiffness: l = 0.15, damping: g = 0.8, precision: _ = 0.01 } = s; + let x, o, p, E = y, u = y, A = 1, C = 0, L = !1; + function D(n, b = {}) { + u = n; + const f = p = {}; + return y == null || b.hard || r.stiffness >= 1 && r.damping >= 1 ? (L = !0, x = now(), E = n, e.set(y = u), Promise.resolve()) : (b.soft && (C = 1 / ((b.soft === !0 ? 0.5 : +b.soft) * 60), A = 0), o || (x = now(), L = !1, o = loop((c) => { + if (L) + return L = !1, o = null, !1; + A = Math.min(A + C, 1); + const t = { + inv_mass: A, + opts: r, + settled: !0, + dt: (c - x) * 60 / 1e3 + }, a = tick_spring(t, E, y, u); + return x = c, E = y, e.set(y = a), t.settled && (o = null), !t.settled; + })), new Promise((c) => { + o.promise.then(() => { + f === p && c(); + }); + })); + } + const r = { + set: D, + update: (n, b) => D(n(u, y), b), + subscribe: e.subscribe, + stiffness: l, + damping: g, + precision: _ + }; + return r; +} +const Loader_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$4, + append: append$3, + attr: attr$3, + component_subscribe, + detach: detach$4, + element: element$3, + init: init$4, + insert: insert$4, + noop: noop$3, + safe_not_equal: safe_not_equal$4, + set_style: set_style$1, + svg_element, + toggle_class: toggle_class$3 +} = window.__gradio__svelte__internal, { onMount: onMount$2 } = window.__gradio__svelte__internal; +function create_fragment$4(y) { + let s, e, l, g, _, x, o, p, E, u, A, C; + return { + c() { + s = element$3("div"), e = svg_element("svg"), l = svg_element("g"), g = svg_element("path"), _ = svg_element("path"), x = svg_element("path"), o = svg_element("path"), p = svg_element("g"), E = svg_element("path"), u = svg_element("path"), A = svg_element("path"), C = svg_element("path"), attr$3(g, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), attr$3(g, "fill", "#FF7C00"), attr$3(g, "fill-opacity", "0.4"), attr$3(g, "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(o, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), attr$3(o, "fill", "#FF7C00"), attr$3(o, "class", "svelte-43sxxs"), set_style$1(l, "transform", "translate(" + /*$top*/ + y[1][0] + "px, " + /*$top*/ + y[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(u, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), attr$3(u, "fill", "#FF7C00"), attr$3(u, "class", "svelte-43sxxs"), attr$3(A, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), attr$3(A, "fill", "#FF7C00"), attr$3(A, "fill-opacity", "0.4"), attr$3(A, "class", "svelte-43sxxs"), attr$3(C, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), attr$3(C, "fill", "#FF7C00"), attr$3(C, "class", "svelte-43sxxs"), set_style$1(p, "transform", "translate(" + /*$bottom*/ + y[2][0] + "px, " + /*$bottom*/ + y[2][1] + "px)"), attr$3(e, "viewBox", "-1200 -1200 3000 3000"), attr$3(e, "fill", "none"), attr$3(e, "xmlns", "http://www.w3.org/2000/svg"), attr$3(e, "class", "svelte-43sxxs"), attr$3(s, "class", "svelte-43sxxs"), toggle_class$3( + s, + "margin", + /*margin*/ + y[0] + ); + }, + m(L, D) { + insert$4(L, s, D), append$3(s, e), append$3(e, l), append$3(l, g), append$3(l, _), append$3(l, x), append$3(l, o), append$3(e, p), append$3(p, E), append$3(p, u), append$3(p, A), append$3(p, C); + }, + p(L, [D]) { + D & /*$top*/ + 2 && set_style$1(l, "transform", "translate(" + /*$top*/ + L[1][0] + "px, " + /*$top*/ + L[1][1] + "px)"), D & /*$bottom*/ + 4 && set_style$1(p, "transform", "translate(" + /*$bottom*/ + L[2][0] + "px, " + /*$bottom*/ + L[2][1] + "px)"), D & /*margin*/ + 1 && toggle_class$3( + s, + "margin", + /*margin*/ + L[0] + ); + }, + i: noop$3, + o: noop$3, + d(L) { + L && detach$4(s); + } + }; +} +function instance$4(y, s, e) { + let l, g, { margin: _ = !0 } = s; + const x = spring([0, 0]); + component_subscribe(y, x, (C) => e(1, l = C)); + const o = spring([0, 0]); + component_subscribe(y, o, (C) => e(2, g = C)); + let p; + async function E() { + await Promise.all([x.set([125, 140]), o.set([-125, -140])]), await Promise.all([x.set([-125, 140]), o.set([125, -140])]), await Promise.all([x.set([-125, 0]), o.set([125, -0])]), await Promise.all([x.set([125, 0]), o.set([-125, 0])]); + } + async function u() { + await E(), p || u(); + } + async function A() { + await Promise.all([x.set([125, 0]), o.set([-125, 0])]), u(); + } + return onMount$2(() => (A(), () => p = !0)), y.$$set = (C) => { + "margin" in C && e(0, _ = C.margin); + }, [_, l, g, x, o]; +} +class Loader extends SvelteComponent$4 { + constructor(s) { + super(), init$4(this, s, instance$4, create_fragment$4, safe_not_equal$4, { margin: 0 }); + } +} +const index_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$3, + append: append$2, + attr: attr$2, + binding_callbacks: binding_callbacks$3, + check_outros: check_outros$2, + create_component: create_component$2, + create_slot, + destroy_component: destroy_component$2, + destroy_each, + detach: detach$3, + element: element$2, + empty: empty$1, + ensure_array_like, + get_all_dirty_from_scope, + get_slot_changes, + group_outros: group_outros$2, + init: init$3, + insert: insert$3, + mount_component: mount_component$2, + noop: noop$2, + safe_not_equal: safe_not_equal$3, + set_data: set_data$3, + set_style, + space: space$2, + text: text$3, + toggle_class: toggle_class$2, + transition_in: transition_in$2, + transition_out: transition_out$2, + update_slot_base +} = window.__gradio__svelte__internal, { tick: tick$1 } = window.__gradio__svelte__internal, { onDestroy } = window.__gradio__svelte__internal, get_error_slot_changes = (y) => ({}), get_error_slot_context = (y) => ({}); +function get_each_context(y, s, e) { + const l = y.slice(); + return l[38] = s[e], l[40] = e, l; +} +function get_each_context_1(y, s, e) { + const l = y.slice(); + return l[38] = s[e], l; +} +function create_if_block_17(y) { + let s, e = ( + /*i18n*/ + y[1]("common.error") + "" + ), l, g, _; + const x = ( + /*#slots*/ + y[29].error + ), o = create_slot( + x, + y, + /*$$scope*/ + y[28], + get_error_slot_context + ); + return { + c() { + s = element$2("span"), l = text$3(e), g = space$2(), o && o.c(), attr$2(s, "class", "error svelte-1yserjw"); + }, + m(p, E) { + insert$3(p, s, E), append$2(s, l), insert$3(p, g, E), o && o.m(p, E), _ = !0; + }, + p(p, E) { + (!_ || E[0] & /*i18n*/ + 2) && e !== (e = /*i18n*/ + p[1]("common.error") + "") && set_data$3(l, e), o && o.p && (!_ || E[0] & /*$$scope*/ + 268435456) && update_slot_base( + o, + x, + p, + /*$$scope*/ + p[28], + _ ? get_slot_changes( + x, + /*$$scope*/ + p[28], + E, + get_error_slot_changes + ) : get_all_dirty_from_scope( + /*$$scope*/ + p[28] + ), + get_error_slot_context + ); + }, + i(p) { + _ || (transition_in$2(o, p), _ = !0); + }, + o(p) { + transition_out$2(o, p), _ = !1; + }, + d(p) { + p && (detach$3(s), detach$3(g)), o && o.d(p); + } + }; +} +function create_if_block$2(y) { + let s, e, l, g, _, x, o, p, E, u = ( + /*variant*/ + y[8] === "default" && /*show_eta_bar*/ + y[18] && /*show_progress*/ + y[6] === "full" && create_if_block_16(y) + ); + function A(c, t) { + if ( + /*progress*/ + c[7] + ) + return create_if_block_11; + if ( + /*queue_position*/ + c[2] !== null && /*queue_size*/ + c[3] !== void 0 && /*queue_position*/ + c[2] >= 0 + ) + return create_if_block_14; + if ( + /*queue_position*/ + c[2] === 0 + ) + return create_if_block_15; + } + let C = A(y), L = C && C(y), D = ( + /*timer*/ + y[5] && create_if_block_10(y) + ); + const r = [create_if_block_2$1, create_if_block_9], n = []; + function b(c, t) { + return ( + /*last_progress_level*/ + c[15] != null ? 0 : ( + /*show_progress*/ + c[6] === "full" ? 1 : -1 + ) + ); + } + ~(_ = b(y)) && (x = n[_] = r[_](y)); + let f = !/*timer*/ + y[5] && create_if_block_1$1(y); + return { + c() { + u && u.c(), s = space$2(), e = element$2("div"), L && L.c(), l = space$2(), D && D.c(), g = space$2(), x && x.c(), o = space$2(), f && f.c(), p = empty$1(), attr$2(e, "class", "progress-text svelte-1yserjw"), toggle_class$2( + e, + "meta-text-center", + /*variant*/ + y[8] === "center" + ), toggle_class$2( + e, + "meta-text", + /*variant*/ + y[8] === "default" + ); + }, + m(c, t) { + u && u.m(c, t), insert$3(c, s, t), insert$3(c, e, t), L && L.m(e, null), append$2(e, l), D && D.m(e, null), insert$3(c, g, t), ~_ && n[_].m(c, t), insert$3(c, o, t), f && f.m(c, t), insert$3(c, p, t), E = !0; + }, + p(c, t) { + /*variant*/ + c[8] === "default" && /*show_eta_bar*/ + c[18] && /*show_progress*/ + c[6] === "full" ? u ? u.p(c, t) : (u = create_if_block_16(c), u.c(), u.m(s.parentNode, s)) : u && (u.d(1), u = null), C === (C = A(c)) && L ? L.p(c, t) : (L && L.d(1), L = C && C(c), L && (L.c(), L.m(e, l))), /*timer*/ + c[5] ? D ? D.p(c, t) : (D = create_if_block_10(c), D.c(), D.m(e, null)) : D && (D.d(1), D = null), (!E || t[0] & /*variant*/ + 256) && toggle_class$2( + e, + "meta-text-center", + /*variant*/ + c[8] === "center" + ), (!E || t[0] & /*variant*/ + 256) && toggle_class$2( + e, + "meta-text", + /*variant*/ + c[8] === "default" + ); + let a = _; + _ = b(c), _ === a ? ~_ && n[_].p(c, t) : (x && (group_outros$2(), transition_out$2(n[a], 1, 1, () => { + n[a] = null; + }), check_outros$2()), ~_ ? (x = n[_], x ? x.p(c, t) : (x = n[_] = r[_](c), x.c()), transition_in$2(x, 1), x.m(o.parentNode, o)) : x = null), /*timer*/ + c[5] ? f && (f.d(1), f = null) : f ? f.p(c, t) : (f = create_if_block_1$1(c), f.c(), f.m(p.parentNode, p)); + }, + i(c) { + E || (transition_in$2(x), E = !0); + }, + o(c) { + transition_out$2(x), E = !1; + }, + d(c) { + c && (detach$3(s), detach$3(e), detach$3(g), detach$3(o), detach$3(p)), u && u.d(c), L && L.d(), D && D.d(), ~_ && n[_].d(c), f && f.d(c); + } + }; +} +function create_if_block_16(y) { + let s, e = `translateX(${/*eta_level*/ + (y[17] || 0) * 100 - 100}%)`; + return { + c() { + s = element$2("div"), attr$2(s, "class", "eta-bar svelte-1yserjw"), set_style(s, "transform", e); + }, + m(l, g) { + insert$3(l, s, g); + }, + p(l, g) { + g[0] & /*eta_level*/ + 131072 && e !== (e = `translateX(${/*eta_level*/ + (l[17] || 0) * 100 - 100}%)`) && set_style(s, "transform", e); + }, + d(l) { + l && detach$3(s); + } + }; +} +function create_if_block_15(y) { + let s; + return { + c() { + s = text$3("processing |"); + }, + m(e, l) { + insert$3(e, s, l); + }, + p: noop$2, + d(e) { + e && detach$3(s); + } + }; +} +function create_if_block_14(y) { + let s, e = ( + /*queue_position*/ + y[2] + 1 + "" + ), l, g, _, x; + return { + c() { + s = text$3("queue: "), l = text$3(e), g = text$3("/"), _ = text$3( + /*queue_size*/ + y[3] + ), x = text$3(" |"); + }, + m(o, p) { + insert$3(o, s, p), insert$3(o, l, p), insert$3(o, g, p), insert$3(o, _, p), insert$3(o, x, p); + }, + p(o, p) { + p[0] & /*queue_position*/ + 4 && e !== (e = /*queue_position*/ + o[2] + 1 + "") && set_data$3(l, e), p[0] & /*queue_size*/ + 8 && set_data$3( + _, + /*queue_size*/ + o[3] + ); + }, + d(o) { + o && (detach$3(s), detach$3(l), detach$3(g), detach$3(_), detach$3(x)); + } + }; +} +function create_if_block_11(y) { + let s, e = ensure_array_like( + /*progress*/ + y[7] + ), l = []; + for (let g = 0; g < e.length; g += 1) + l[g] = create_each_block_1(get_each_context_1(y, e, g)); + return { + c() { + for (let g = 0; g < l.length; g += 1) + l[g].c(); + s = empty$1(); + }, + m(g, _) { + for (let x = 0; x < l.length; x += 1) + l[x] && l[x].m(g, _); + insert$3(g, s, _); + }, + p(g, _) { + if (_[0] & /*progress*/ + 128) { + e = ensure_array_like( + /*progress*/ + g[7] + ); + let x; + for (x = 0; x < e.length; x += 1) { + const o = get_each_context_1(g, e, x); + l[x] ? l[x].p(o, _) : (l[x] = create_each_block_1(o), l[x].c(), l[x].m(s.parentNode, s)); + } + for (; x < l.length; x += 1) + l[x].d(1); + l.length = e.length; + } + }, + d(g) { + g && detach$3(s), destroy_each(l, g); + } + }; +} +function create_if_block_12(y) { + let s, e = ( + /*p*/ + y[38].unit + "" + ), l, g, _ = " ", x; + function o(u, A) { + return ( + /*p*/ + u[38].length != null ? create_if_block_13 : create_else_block$1 + ); + } + let p = o(y), E = p(y); + return { + c() { + E.c(), s = space$2(), l = text$3(e), g = text$3(" | "), x = text$3(_); + }, + m(u, A) { + E.m(u, A), insert$3(u, s, A), insert$3(u, l, A), insert$3(u, g, A), insert$3(u, x, A); + }, + p(u, A) { + p === (p = o(u)) && E ? E.p(u, A) : (E.d(1), E = p(u), E && (E.c(), E.m(s.parentNode, s))), A[0] & /*progress*/ + 128 && e !== (e = /*p*/ + u[38].unit + "") && set_data$3(l, e); + }, + d(u) { + u && (detach$3(s), detach$3(l), detach$3(g), detach$3(x)), E.d(u); + } + }; +} +function create_else_block$1(y) { + let s = pretty_si( + /*p*/ + y[38].index || 0 + ) + "", e; + return { + c() { + e = text$3(s); + }, + m(l, g) { + insert$3(l, e, g); + }, + p(l, g) { + g[0] & /*progress*/ + 128 && s !== (s = pretty_si( + /*p*/ + l[38].index || 0 + ) + "") && set_data$3(e, s); + }, + d(l) { + l && detach$3(e); + } + }; +} +function create_if_block_13(y) { + let s = pretty_si( + /*p*/ + y[38].index || 0 + ) + "", e, l, g = pretty_si( + /*p*/ + y[38].length + ) + "", _; + return { + c() { + e = text$3(s), l = text$3("/"), _ = text$3(g); + }, + m(x, o) { + insert$3(x, e, o), insert$3(x, l, o), insert$3(x, _, o); + }, + p(x, o) { + o[0] & /*progress*/ + 128 && s !== (s = pretty_si( + /*p*/ + x[38].index || 0 + ) + "") && set_data$3(e, s), o[0] & /*progress*/ + 128 && g !== (g = pretty_si( + /*p*/ + x[38].length + ) + "") && set_data$3(_, g); + }, + d(x) { + x && (detach$3(e), detach$3(l), detach$3(_)); + } + }; +} +function create_each_block_1(y) { + let s, e = ( + /*p*/ + y[38].index != null && create_if_block_12(y) + ); + return { + c() { + e && e.c(), s = empty$1(); + }, + m(l, g) { + e && e.m(l, g), insert$3(l, s, g); + }, + p(l, g) { + /*p*/ + l[38].index != null ? e ? e.p(l, g) : (e = create_if_block_12(l), e.c(), e.m(s.parentNode, s)) : e && (e.d(1), e = null); + }, + d(l) { + l && detach$3(s), e && e.d(l); + } + }; +} +function create_if_block_10(y) { + let s, e = ( + /*eta*/ + y[0] ? `/${/*formatted_eta*/ + y[19]}` : "" + ), l, g; + return { + c() { + s = text$3( + /*formatted_timer*/ + y[20] + ), l = text$3(e), g = text$3("s"); + }, + m(_, x) { + insert$3(_, s, x), insert$3(_, l, x), insert$3(_, g, x); + }, + p(_, x) { + x[0] & /*formatted_timer*/ + 1048576 && set_data$3( + s, + /*formatted_timer*/ + _[20] + ), x[0] & /*eta, formatted_eta*/ + 524289 && e !== (e = /*eta*/ + _[0] ? `/${/*formatted_eta*/ + _[19]}` : "") && set_data$3(l, e); + }, + d(_) { + _ && (detach$3(s), detach$3(l), detach$3(g)); + } + }; +} +function create_if_block_9(y) { + let s, e; + return s = new Loader({ + props: { margin: ( + /*variant*/ + y[8] === "default" + ) } + }), { + c() { + create_component$2(s.$$.fragment); + }, + m(l, g) { + mount_component$2(s, l, g), e = !0; + }, + p(l, g) { + const _ = {}; + g[0] & /*variant*/ + 256 && (_.margin = /*variant*/ + l[8] === "default"), s.$set(_); + }, + i(l) { + e || (transition_in$2(s.$$.fragment, l), e = !0); + }, + o(l) { + transition_out$2(s.$$.fragment, l), e = !1; + }, + d(l) { + destroy_component$2(s, l); + } + }; +} +function create_if_block_2$1(y) { + let s, e, l, g, _, x = `${/*last_progress_level*/ + y[15] * 100}%`, o = ( + /*progress*/ + y[7] != null && create_if_block_3$1(y) + ); + return { + c() { + s = element$2("div"), e = element$2("div"), o && o.c(), l = space$2(), g = element$2("div"), _ = element$2("div"), attr$2(e, "class", "progress-level-inner svelte-1yserjw"), attr$2(_, "class", "progress-bar svelte-1yserjw"), set_style(_, "width", x), attr$2(g, "class", "progress-bar-wrap svelte-1yserjw"), attr$2(s, "class", "progress-level svelte-1yserjw"); + }, + m(p, E) { + insert$3(p, s, E), append$2(s, e), o && o.m(e, null), append$2(s, l), append$2(s, g), append$2(g, _), y[30](_); + }, + p(p, E) { + /*progress*/ + p[7] != null ? o ? o.p(p, E) : (o = create_if_block_3$1(p), o.c(), o.m(e, null)) : o && (o.d(1), o = null), E[0] & /*last_progress_level*/ + 32768 && x !== (x = `${/*last_progress_level*/ + p[15] * 100}%`) && set_style(_, "width", x); + }, + i: noop$2, + o: noop$2, + d(p) { + p && detach$3(s), o && o.d(), y[30](null); + } + }; +} +function create_if_block_3$1(y) { + let s, e = ensure_array_like( + /*progress*/ + y[7] + ), l = []; + for (let g = 0; g < e.length; g += 1) + l[g] = create_each_block(get_each_context(y, e, g)); + return { + c() { + for (let g = 0; g < l.length; g += 1) + l[g].c(); + s = empty$1(); + }, + m(g, _) { + for (let x = 0; x < l.length; x += 1) + l[x] && l[x].m(g, _); + insert$3(g, s, _); + }, + p(g, _) { + if (_[0] & /*progress_level, progress*/ + 16512) { + e = ensure_array_like( + /*progress*/ + g[7] + ); + let x; + for (x = 0; x < e.length; x += 1) { + const o = get_each_context(g, e, x); + l[x] ? l[x].p(o, _) : (l[x] = create_each_block(o), l[x].c(), l[x].m(s.parentNode, s)); + } + for (; x < l.length; x += 1) + l[x].d(1); + l.length = e.length; + } + }, + d(g) { + g && detach$3(s), destroy_each(l, g); + } + }; +} +function create_if_block_4$1(y) { + let s, e, l, g, _ = ( + /*i*/ + y[40] !== 0 && create_if_block_8() + ), x = ( + /*p*/ + y[38].desc != null && create_if_block_7(y) + ), o = ( + /*p*/ + y[38].desc != null && /*progress_level*/ + y[14] && /*progress_level*/ + y[14][ + /*i*/ + y[40] + ] != null && create_if_block_6() + ), p = ( + /*progress_level*/ + y[14] != null && create_if_block_5$1(y) + ); + return { + c() { + _ && _.c(), s = space$2(), x && x.c(), e = space$2(), o && o.c(), l = space$2(), p && p.c(), g = empty$1(); + }, + m(E, u) { + _ && _.m(E, u), insert$3(E, s, u), x && x.m(E, u), insert$3(E, e, u), o && o.m(E, u), insert$3(E, l, u), p && p.m(E, u), insert$3(E, g, u); + }, + p(E, u) { + /*p*/ + E[38].desc != null ? x ? x.p(E, u) : (x = create_if_block_7(E), x.c(), x.m(e.parentNode, e)) : x && (x.d(1), x = null), /*p*/ + E[38].desc != null && /*progress_level*/ + E[14] && /*progress_level*/ + E[14][ + /*i*/ + E[40] + ] != null ? o || (o = create_if_block_6(), o.c(), o.m(l.parentNode, l)) : o && (o.d(1), o = null), /*progress_level*/ + E[14] != null ? p ? p.p(E, u) : (p = create_if_block_5$1(E), p.c(), p.m(g.parentNode, g)) : p && (p.d(1), p = null); + }, + d(E) { + E && (detach$3(s), detach$3(e), detach$3(l), detach$3(g)), _ && _.d(E), x && x.d(E), o && o.d(E), p && p.d(E); + } + }; +} +function create_if_block_8(y) { + let s; + return { + c() { + s = text$3(" /"); + }, + m(e, l) { + insert$3(e, s, l); + }, + d(e) { + e && detach$3(s); + } + }; +} +function create_if_block_7(y) { + let s = ( + /*p*/ + y[38].desc + "" + ), e; + return { + c() { + e = text$3(s); + }, + m(l, g) { + insert$3(l, e, g); + }, + p(l, g) { + g[0] & /*progress*/ + 128 && s !== (s = /*p*/ + l[38].desc + "") && set_data$3(e, s); + }, + d(l) { + l && detach$3(e); + } + }; +} +function create_if_block_6(y) { + let s; + return { + c() { + s = text$3("-"); + }, + m(e, l) { + insert$3(e, s, l); + }, + d(e) { + e && detach$3(s); + } + }; +} +function create_if_block_5$1(y) { + let s = (100 * /*progress_level*/ + (y[14][ + /*i*/ + y[40] + ] || 0)).toFixed(1) + "", e, l; + return { + c() { + e = text$3(s), l = text$3("%"); + }, + m(g, _) { + insert$3(g, e, _), insert$3(g, l, _); + }, + p(g, _) { + _[0] & /*progress_level*/ + 16384 && s !== (s = (100 * /*progress_level*/ + (g[14][ + /*i*/ + g[40] + ] || 0)).toFixed(1) + "") && set_data$3(e, s); + }, + d(g) { + g && (detach$3(e), detach$3(l)); + } + }; +} +function create_each_block(y) { + let s, e = ( + /*p*/ + (y[38].desc != null || /*progress_level*/ + y[14] && /*progress_level*/ + y[14][ + /*i*/ + y[40] + ] != null) && create_if_block_4$1(y) + ); + return { + c() { + e && e.c(), s = empty$1(); + }, + m(l, g) { + e && e.m(l, g), insert$3(l, s, g); + }, + p(l, g) { + /*p*/ + l[38].desc != null || /*progress_level*/ + l[14] && /*progress_level*/ + l[14][ + /*i*/ + l[40] + ] != null ? e ? e.p(l, g) : (e = create_if_block_4$1(l), e.c(), e.m(s.parentNode, s)) : e && (e.d(1), e = null); + }, + d(l) { + l && detach$3(s), e && e.d(l); + } + }; +} +function create_if_block_1$1(y) { + let s, e; + return { + c() { + s = element$2("p"), e = text$3( + /*loading_text*/ + y[9] + ), attr$2(s, "class", "loading svelte-1yserjw"); + }, + m(l, g) { + insert$3(l, s, g), append$2(s, e); + }, + p(l, g) { + g[0] & /*loading_text*/ + 512 && set_data$3( + e, + /*loading_text*/ + l[9] + ); + }, + d(l) { + l && detach$3(s); + } + }; +} +function create_fragment$3(y) { + let s, e, l, g, _; + const x = [create_if_block$2, create_if_block_17], o = []; + function p(E, u) { + return ( + /*status*/ + E[4] === "pending" ? 0 : ( + /*status*/ + E[4] === "error" ? 1 : -1 + ) + ); + } + return ~(e = p(y)) && (l = o[e] = x[e](y)), { + c() { + s = element$2("div"), l && l.c(), attr$2(s, "class", g = "wrap " + /*variant*/ + y[8] + " " + /*show_progress*/ + y[6] + " svelte-1yserjw"), toggle_class$2(s, "hide", !/*status*/ + y[4] || /*status*/ + y[4] === "complete" || /*show_progress*/ + y[6] === "hidden"), toggle_class$2( + s, + "translucent", + /*variant*/ + y[8] === "center" && /*status*/ + (y[4] === "pending" || /*status*/ + y[4] === "error") || /*translucent*/ + y[11] || /*show_progress*/ + y[6] === "minimal" + ), toggle_class$2( + s, + "generating", + /*status*/ + y[4] === "generating" + ), toggle_class$2( + s, + "border", + /*border*/ + y[12] + ), set_style( + s, + "position", + /*absolute*/ + y[10] ? "absolute" : "static" + ), set_style( + s, + "padding", + /*absolute*/ + y[10] ? "0" : "var(--size-8) 0" + ); + }, + m(E, u) { + insert$3(E, s, u), ~e && o[e].m(s, null), y[31](s), _ = !0; + }, + p(E, u) { + let A = e; + e = p(E), e === A ? ~e && o[e].p(E, u) : (l && (group_outros$2(), transition_out$2(o[A], 1, 1, () => { + o[A] = null; + }), check_outros$2()), ~e ? (l = o[e], l ? l.p(E, u) : (l = o[e] = x[e](E), l.c()), transition_in$2(l, 1), l.m(s, null)) : l = null), (!_ || u[0] & /*variant, show_progress*/ + 320 && g !== (g = "wrap " + /*variant*/ + E[8] + " " + /*show_progress*/ + E[6] + " svelte-1yserjw")) && attr$2(s, "class", g), (!_ || u[0] & /*variant, show_progress, status, show_progress*/ + 336) && toggle_class$2(s, "hide", !/*status*/ + E[4] || /*status*/ + E[4] === "complete" || /*show_progress*/ + E[6] === "hidden"), (!_ || u[0] & /*variant, show_progress, variant, status, translucent, show_progress*/ + 2384) && toggle_class$2( + s, + "translucent", + /*variant*/ + E[8] === "center" && /*status*/ + (E[4] === "pending" || /*status*/ + E[4] === "error") || /*translucent*/ + E[11] || /*show_progress*/ + E[6] === "minimal" + ), (!_ || u[0] & /*variant, show_progress, status*/ + 336) && toggle_class$2( + s, + "generating", + /*status*/ + E[4] === "generating" + ), (!_ || u[0] & /*variant, show_progress, border*/ + 4416) && toggle_class$2( + s, + "border", + /*border*/ + E[12] + ), u[0] & /*absolute*/ + 1024 && set_style( + s, + "position", + /*absolute*/ + E[10] ? "absolute" : "static" + ), u[0] & /*absolute*/ + 1024 && set_style( + s, + "padding", + /*absolute*/ + E[10] ? "0" : "var(--size-8) 0" + ); + }, + i(E) { + _ || (transition_in$2(l), _ = !0); + }, + o(E) { + transition_out$2(l), _ = !1; + }, + d(E) { + E && detach$3(s), ~e && o[e].d(), y[31](null); + } + }; +} +let items = [], called = !1; +async function scroll_into_view(y, s = !0) { + if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && s !== !0)) { + if (items.push(y), !called) + called = !0; + else + return; + await tick$1(), requestAnimationFrame(() => { + let e = [0, 0]; + for (let l = 0; l < items.length; l++) { + const _ = items[l].getBoundingClientRect(); + (l === 0 || _.top + window.scrollY <= e[0]) && (e[0] = _.top + window.scrollY, e[1] = l); + } + window.scrollTo({ top: e[0] - 20, behavior: "smooth" }), called = !1, items = []; + }); + } +} +function instance$3(y, s, e) { + let l, { $$slots: g = {}, $$scope: _ } = s, { i18n: x } = s, { eta: o = null } = s, { queue_position: p } = s, { queue_size: E } = s, { status: u } = s, { scroll_to_output: A = !1 } = s, { timer: C = !0 } = s, { show_progress: L = "full" } = s, { message: D = null } = s, { progress: r = null } = s, { variant: n = "default" } = s, { loading_text: b = "Loading..." } = s, { absolute: f = !0 } = s, { translucent: c = !1 } = s, { border: t = !1 } = s, { autoscroll: a } = s, h, M = !1, w = 0, S = 0, T = null, R = null, z = 0, P = null, B, U = null, F = !0; + const $ = () => { + e(0, o = e(26, T = e(19, G = null))), e(24, w = performance.now()), e(25, S = 0), M = !0, W(); + }; + function W() { + requestAnimationFrame(() => { + e(25, S = (performance.now() - w) / 1e3), M && W(); + }); + } + function N() { + e(25, S = 0), e(0, o = e(26, T = e(19, G = null))), M && (M = !1); + } + onDestroy(() => { + M && N(); + }); + let G = null; + function k(Q) { + binding_callbacks$3[Q ? "unshift" : "push"](() => { + U = Q, e(16, U), e(7, r), e(14, P), e(15, B); + }); + } + function j(Q) { + binding_callbacks$3[Q ? "unshift" : "push"](() => { + h = Q, e(13, h); + }); + } + return y.$$set = (Q) => { + "i18n" in Q && e(1, x = Q.i18n), "eta" in Q && e(0, o = Q.eta), "queue_position" in Q && e(2, p = Q.queue_position), "queue_size" in Q && e(3, E = Q.queue_size), "status" in Q && e(4, u = Q.status), "scroll_to_output" in Q && e(21, A = Q.scroll_to_output), "timer" in Q && e(5, C = Q.timer), "show_progress" in Q && e(6, L = Q.show_progress), "message" in Q && e(22, D = Q.message), "progress" in Q && e(7, r = Q.progress), "variant" in Q && e(8, n = Q.variant), "loading_text" in Q && e(9, b = Q.loading_text), "absolute" in Q && e(10, f = Q.absolute), "translucent" in Q && e(11, c = Q.translucent), "border" in Q && e(12, t = Q.border), "autoscroll" in Q && e(23, a = Q.autoscroll), "$$scope" in Q && e(28, _ = Q.$$scope); + }, y.$$.update = () => { + y.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/ + 218103809 && (o === null && e(0, o = T), o != null && T !== o && (e(27, R = (performance.now() - w) / 1e3 + o), e(19, G = R.toFixed(1)), e(26, T = o))), y.$$.dirty[0] & /*eta_from_start, timer_diff*/ + 167772160 && e(17, z = R === null || R <= 0 || !S ? null : Math.min(S / R, 1)), y.$$.dirty[0] & /*progress*/ + 128 && r != null && e(18, F = !1), y.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/ + 114816 && (r != null ? e(14, P = r.map((Q) => { + if (Q.index != null && Q.length != null) + return Q.index / Q.length; + if (Q.progress != null) + return Q.progress; + })) : e(14, P = null), P ? (e(15, B = P[P.length - 1]), U && (B === 0 ? e(16, U.style.transition = "0", U) : e(16, U.style.transition = "150ms", U))) : e(15, B = void 0)), y.$$.dirty[0] & /*status*/ + 16 && (u === "pending" ? $() : N()), y.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/ + 10493968 && h && A && (u === "pending" || u === "complete") && scroll_into_view(h, a), y.$$.dirty[0] & /*status, message*/ + 4194320, y.$$.dirty[0] & /*timer_diff*/ + 33554432 && e(20, l = S.toFixed(1)); + }, [ + o, + x, + p, + E, + u, + C, + L, + r, + n, + b, + f, + c, + t, + h, + P, + B, + U, + z, + F, + G, + l, + A, + D, + a, + w, + S, + T, + R, + _, + g, + k, + j + ]; +} +class Static extends SvelteComponent$3 { + constructor(s) { + super(), init$3( + this, + s, + instance$3, + create_fragment$3, + safe_not_equal$3, + { + i18n: 1, + eta: 0, + queue_position: 2, + queue_size: 3, + status: 4, + scroll_to_output: 21, + timer: 5, + show_progress: 6, + message: 22, + progress: 7, + variant: 8, + loading_text: 9, + absolute: 10, + translucent: 11, + border: 12, + autoscroll: 23 + }, + null, + [-1, -1] + ); + } +} +const ToastContent_svelte_svelte_type_style_lang = "", Toast_svelte_svelte_type_style_lang = "", Example_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$2, + add_iframe_resize_listener, + add_render_callback: add_render_callback$1, + append: append$1, + attr: attr$1, + binding_callbacks: binding_callbacks$2, + detach: detach$2, + element: element$1, + init: init$2, + insert: insert$2, + noop: noop$1, + safe_not_equal: safe_not_equal$2, + set_data: set_data$2, + text: text$2, + toggle_class: toggle_class$1 +} = window.__gradio__svelte__internal, { onMount: onMount$1 } = window.__gradio__svelte__internal; +function create_fragment$2(y) { + let s, e = ( + /*value*/ + (y[0] ? ( + /*value*/ + y[0] + ) : "") + "" + ), l, g; + return { + c() { + s = element$1("div"), l = text$2(e), attr$1(s, "class", "svelte-84cxb8"), add_render_callback$1(() => ( + /*div_elementresize_handler*/ + y[5].call(s) + )), toggle_class$1( + s, + "table", + /*type*/ + y[1] === "table" + ), toggle_class$1( + s, + "gallery", + /*type*/ + y[1] === "gallery" + ), toggle_class$1( + s, + "selected", + /*selected*/ + y[2] + ); + }, + m(_, x) { + insert$2(_, s, x), append$1(s, l), g = add_iframe_resize_listener( + s, + /*div_elementresize_handler*/ + y[5].bind(s) + ), y[6](s); + }, + p(_, [x]) { + x & /*value*/ + 1 && e !== (e = /*value*/ + (_[0] ? ( + /*value*/ + _[0] + ) : "") + "") && set_data$2(l, e), x & /*type*/ + 2 && toggle_class$1( + s, + "table", + /*type*/ + _[1] === "table" + ), x & /*type*/ + 2 && toggle_class$1( + s, + "gallery", + /*type*/ + _[1] === "gallery" + ), x & /*selected*/ + 4 && toggle_class$1( + s, + "selected", + /*selected*/ + _[2] + ); + }, + i: noop$1, + o: noop$1, + d(_) { + _ && detach$2(s), g(), y[6](null); + } + }; +} +function instance$2(y, s, e) { + let { value: l } = s, { type: g } = s, { selected: _ = !1 } = s, x, o; + function p(A, C) { + !A || !C || (o.style.setProperty("--local-text-width", `${C < 150 ? C : 200}px`), e(4, o.style.whiteSpace = "unset", o)); + } + onMount$1(() => { + p(o, x); + }); + function E() { + x = this.clientWidth, e(3, x); + } + function u(A) { + binding_callbacks$2[A ? "unshift" : "push"](() => { + o = A, e(4, o); + }); + } + return y.$$set = (A) => { + "value" in A && e(0, l = A.value), "type" in A && e(1, g = A.type), "selected" in A && e(2, _ = A.selected); + }, [l, g, _, x, o, E, u]; +} +class Example extends SvelteComponent$2 { + constructor(s) { + super(), init$2(this, s, instance$2, create_fragment$2, safe_not_equal$2, { value: 0, type: 1, selected: 2 }); + } +} +const Textbox_svelte_svelte_type_style_lang = "", { + SvelteComponent: SvelteComponent$1, + action_destroyer, + add_render_callback, + append, + attr, + binding_callbacks: binding_callbacks$1, + bubble, + check_outros: check_outros$1, + create_component: create_component$1, + create_in_transition, + destroy_component: destroy_component$1, + detach: detach$1, + element, + empty, + group_outros: group_outros$1, + init: init$1, + insert: insert$1, + is_function, + listen, + mount_component: mount_component$1, + noop, + run_all, + safe_not_equal: safe_not_equal$1, + set_data: set_data$1, + set_input_value, + space: space$1, + text: text$1, + toggle_class, + transition_in: transition_in$1, + transition_out: transition_out$1 +} = window.__gradio__svelte__internal, { beforeUpdate, afterUpdate, createEventDispatcher, tick } = window.__gradio__svelte__internal; +function create_default_slot$1(y) { + let s; + return { + c() { + s = text$1( + /*label*/ + y[3] + ); + }, + m(e, l) { + insert$1(e, s, l); + }, + p(e, l) { + l[0] & /*label*/ + 8 && set_data$1( + s, + /*label*/ + e[3] + ); + }, + d(e) { + e && detach$1(s); + } + }; +} +function create_else_block(y) { + let s, e, l, g, _, x, o, p, E = ( + /*show_label*/ + y[6] && /*show_copy_button*/ + y[10] && create_if_block_4(y) + ); + return { + c() { + E && E.c(), s = space$1(), e = element("textarea"), attr(e, "data-testid", "textbox"), attr(e, "class", "scroll-hide svelte-18tqgac"), attr(e, "dir", l = /*rtl*/ + y[11] ? "rtl" : "ltr"), attr( + e, + "placeholder", + /*placeholder*/ + y[2] + ), attr( + e, + "rows", + /*lines*/ + y[1] + ), e.disabled = /*disabled*/ + y[5], e.autofocus = /*autofocus*/ + y[12], attr(e, "style", g = /*text_align*/ + y[13] ? "text-align: " + /*text_align*/ + y[13] : ""); + }, + m(u, A) { + E && E.m(u, A), insert$1(u, s, A), insert$1(u, e, A), set_input_value( + e, + /*value*/ + y[0] + ), y[38](e), x = !0, /*autofocus*/ + y[12] && e.focus(), o || (p = [ + action_destroyer(_ = /*text_area_resize*/ + y[20].call( + null, + e, + /*value*/ + y[0] + )), + listen( + e, + "input", + /*textarea_input_handler*/ + y[37] + ), + listen( + e, + "keypress", + /*handle_keypress*/ + y[18] + ), + listen( + e, + "blur", + /*blur_handler_3*/ + y[29] + ), + listen( + e, + "select", + /*handle_select*/ + y[17] + ), + listen( + e, + "focus", + /*focus_handler_3*/ + y[30] + ), + listen( + e, + "scroll", + /*handle_scroll*/ + y[19] + ) + ], o = !0); + }, + p(u, A) { + /*show_label*/ + u[6] && /*show_copy_button*/ + u[10] ? E ? (E.p(u, A), A[0] & /*show_label, show_copy_button*/ + 1088 && transition_in$1(E, 1)) : (E = create_if_block_4(u), E.c(), transition_in$1(E, 1), E.m(s.parentNode, s)) : E && (group_outros$1(), transition_out$1(E, 1, 1, () => { + E = null; + }), check_outros$1()), (!x || A[0] & /*rtl*/ + 2048 && l !== (l = /*rtl*/ + u[11] ? "rtl" : "ltr")) && attr(e, "dir", l), (!x || A[0] & /*placeholder*/ + 4) && attr( + e, + "placeholder", + /*placeholder*/ + u[2] + ), (!x || A[0] & /*lines*/ + 2) && attr( + e, + "rows", + /*lines*/ + u[1] + ), (!x || A[0] & /*disabled*/ + 32) && (e.disabled = /*disabled*/ + u[5]), (!x || A[0] & /*autofocus*/ + 4096) && (e.autofocus = /*autofocus*/ + u[12]), (!x || A[0] & /*text_align*/ + 8192 && g !== (g = /*text_align*/ + u[13] ? "text-align: " + /*text_align*/ + u[13] : "")) && attr(e, "style", g), _ && is_function(_.update) && A[0] & /*value*/ + 1 && _.update.call( + null, + /*value*/ + u[0] + ), A[0] & /*value*/ + 1 && set_input_value( + e, + /*value*/ + u[0] + ); + }, + i(u) { + x || (transition_in$1(E), x = !0); + }, + o(u) { + transition_out$1(E), x = !1; + }, + d(u) { + u && (detach$1(s), detach$1(e)), E && E.d(u), y[38](null), o = !1, run_all(p); + } + }; +} +function create_if_block$1(y) { + let s; + function e(_, x) { + if ( + /*type*/ + _[9] === "text" + ) + return create_if_block_1; + if ( + /*type*/ + _[9] === "password" + ) + return create_if_block_2; + if ( + /*type*/ + _[9] === "email" + ) + return create_if_block_3; + } + let l = e(y), g = l && l(y); + return { + c() { + g && g.c(), s = empty(); + }, + m(_, x) { + g && g.m(_, x), insert$1(_, s, x); + }, + p(_, x) { + l === (l = e(_)) && g ? g.p(_, x) : (g && g.d(1), g = l && l(_), g && (g.c(), g.m(s.parentNode, s))); + }, + i: noop, + o: noop, + d(_) { + _ && detach$1(s), g && g.d(_); + } + }; +} +function create_if_block_4(y) { + let s, e, l, g; + const _ = [create_if_block_5, create_else_block_1], x = []; + function o(p, E) { + return ( + /*copied*/ + p[15] ? 0 : 1 + ); + } + return s = o(y), e = x[s] = _[s](y), { + c() { + e.c(), l = empty(); + }, + m(p, E) { + x[s].m(p, E), insert$1(p, l, E), g = !0; + }, + p(p, E) { + let u = s; + s = o(p), s === u ? x[s].p(p, E) : (group_outros$1(), transition_out$1(x[u], 1, 1, () => { + x[u] = null; + }), check_outros$1(), e = x[s], e ? e.p(p, E) : (e = x[s] = _[s](p), e.c()), transition_in$1(e, 1), e.m(l.parentNode, l)); + }, + i(p) { + g || (transition_in$1(e), g = !0); + }, + o(p) { + transition_out$1(e), g = !1; + }, + d(p) { + p && detach$1(l), x[s].d(p); + } + }; +} +function create_else_block_1(y) { + let s, e, l, g, _; + return e = new Copy({}), { + c() { + s = element("button"), create_component$1(e.$$.fragment), attr(s, "aria-label", "Copy"), attr(s, "aria-roledescription", "Copy text"), attr(s, "class", "svelte-18tqgac"); + }, + m(x, o) { + insert$1(x, s, o), mount_component$1(e, s, null), l = !0, g || (_ = listen( + s, + "click", + /*handle_copy*/ + y[16] + ), g = !0); + }, + p: noop, + i(x) { + l || (transition_in$1(e.$$.fragment, x), l = !0); + }, + o(x) { + transition_out$1(e.$$.fragment, x), l = !1; + }, + d(x) { + x && detach$1(s), destroy_component$1(e), g = !1, _(); + } + }; +} +function create_if_block_5(y) { + let s, e, l, g; + return e = new Check({}), { + c() { + s = element("button"), create_component$1(e.$$.fragment), attr(s, "aria-label", "Copied"), attr(s, "aria-roledescription", "Text copied"), attr(s, "class", "svelte-18tqgac"); + }, + m(_, x) { + insert$1(_, s, x), mount_component$1(e, s, null), g = !0; + }, + p: noop, + i(_) { + g || (transition_in$1(e.$$.fragment, _), _ && (l || add_render_callback(() => { + l = create_in_transition(s, fade, { duration: 300 }), l.start(); + })), g = !0); + }, + o(_) { + transition_out$1(e.$$.fragment, _), g = !1; + }, + d(_) { + _ && detach$1(s), destroy_component$1(e); + } + }; +} +function create_if_block_3(y) { + let s, e, l; + return { + c() { + s = element("input"), attr(s, "data-testid", "textbox"), attr(s, "type", "email"), attr(s, "class", "scroll-hide svelte-18tqgac"), attr( + s, + "placeholder", + /*placeholder*/ + y[2] + ), s.disabled = /*disabled*/ + y[5], s.autofocus = /*autofocus*/ + y[12], attr(s, "autocomplete", "email"); + }, + m(g, _) { + insert$1(g, s, _), set_input_value( + s, + /*value*/ + y[0] + ), y[36](s), /*autofocus*/ + y[12] && s.focus(), e || (l = [ + listen( + s, + "input", + /*input_input_handler_2*/ + y[35] + ), + listen( + s, + "keypress", + /*handle_keypress*/ + y[18] + ), + listen( + s, + "blur", + /*blur_handler_2*/ + y[27] + ), + listen( + s, + "select", + /*handle_select*/ + y[17] + ), + listen( + s, + "focus", + /*focus_handler_2*/ + y[28] + ) + ], e = !0); + }, + p(g, _) { + _[0] & /*placeholder*/ + 4 && attr( + s, + "placeholder", + /*placeholder*/ + g[2] + ), _[0] & /*disabled*/ + 32 && (s.disabled = /*disabled*/ + g[5]), _[0] & /*autofocus*/ + 4096 && (s.autofocus = /*autofocus*/ + g[12]), _[0] & /*value*/ + 1 && s.value !== /*value*/ + g[0] && set_input_value( + s, + /*value*/ + g[0] + ); + }, + d(g) { + g && detach$1(s), y[36](null), e = !1, run_all(l); + } + }; +} +function create_if_block_2(y) { + let s, e, l; + return { + c() { + s = element("input"), attr(s, "data-testid", "password"), attr(s, "type", "password"), attr(s, "class", "scroll-hide svelte-18tqgac"), attr( + s, + "placeholder", + /*placeholder*/ + y[2] + ), s.disabled = /*disabled*/ + y[5], s.autofocus = /*autofocus*/ + y[12], attr(s, "autocomplete", ""); + }, + m(g, _) { + insert$1(g, s, _), set_input_value( + s, + /*value*/ + y[0] + ), y[34](s), /*autofocus*/ + y[12] && s.focus(), e || (l = [ + listen( + s, + "input", + /*input_input_handler_1*/ + y[33] + ), + listen( + s, + "keypress", + /*handle_keypress*/ + y[18] + ), + listen( + s, + "blur", + /*blur_handler_1*/ + y[25] + ), + listen( + s, + "select", + /*handle_select*/ + y[17] + ), + listen( + s, + "focus", + /*focus_handler_1*/ + y[26] + ) + ], e = !0); + }, + p(g, _) { + _[0] & /*placeholder*/ + 4 && attr( + s, + "placeholder", + /*placeholder*/ + g[2] + ), _[0] & /*disabled*/ + 32 && (s.disabled = /*disabled*/ + g[5]), _[0] & /*autofocus*/ + 4096 && (s.autofocus = /*autofocus*/ + g[12]), _[0] & /*value*/ + 1 && s.value !== /*value*/ + g[0] && set_input_value( + s, + /*value*/ + g[0] + ); + }, + d(g) { + g && detach$1(s), y[34](null), e = !1, run_all(l); + } + }; +} +function create_if_block_1(y) { + let s, e, l, g, _; + return { + c() { + s = element("input"), attr(s, "data-testid", "textbox"), attr(s, "type", "text"), attr(s, "class", "scroll-hide svelte-18tqgac"), attr(s, "dir", e = /*rtl*/ + y[11] ? "rtl" : "ltr"), attr( + s, + "placeholder", + /*placeholder*/ + y[2] + ), s.disabled = /*disabled*/ + y[5], s.autofocus = /*autofocus*/ + y[12], attr(s, "style", l = /*text_align*/ + y[13] ? "text-align: " + /*text_align*/ + y[13] : ""); + }, + m(x, o) { + insert$1(x, s, o), set_input_value( + s, + /*value*/ + y[0] + ), y[32](s), /*autofocus*/ + y[12] && s.focus(), g || (_ = [ + listen( + s, + "input", + /*input_input_handler*/ + y[31] + ), + listen( + s, + "keypress", + /*handle_keypress*/ + y[18] + ), + listen( + s, + "blur", + /*blur_handler*/ + y[23] + ), + listen( + s, + "select", + /*handle_select*/ + y[17] + ), + listen( + s, + "focus", + /*focus_handler*/ + y[24] + ) + ], g = !0); + }, + p(x, o) { + o[0] & /*rtl*/ + 2048 && e !== (e = /*rtl*/ + x[11] ? "rtl" : "ltr") && attr(s, "dir", e), o[0] & /*placeholder*/ + 4 && attr( + s, + "placeholder", + /*placeholder*/ + x[2] + ), o[0] & /*disabled*/ + 32 && (s.disabled = /*disabled*/ + x[5]), o[0] & /*autofocus*/ + 4096 && (s.autofocus = /*autofocus*/ + x[12]), o[0] & /*text_align*/ + 8192 && l !== (l = /*text_align*/ + x[13] ? "text-align: " + /*text_align*/ + x[13] : "") && attr(s, "style", l), o[0] & /*value*/ + 1 && s.value !== /*value*/ + x[0] && set_input_value( + s, + /*value*/ + x[0] + ); + }, + d(x) { + x && detach$1(s), y[32](null), g = !1, run_all(_); + } + }; +} +function create_fragment$1(y) { + let s, e, l, g, _, x; + e = new BlockTitle({ + props: { + show_label: ( + /*show_label*/ + y[6] + ), + info: ( + /*info*/ + y[4] + ), + $$slots: { default: [create_default_slot$1] }, + $$scope: { ctx: y } + } + }); + const o = [create_if_block$1, create_else_block], p = []; + function E(u, A) { + return ( + /*lines*/ + u[1] === 1 && /*max_lines*/ + u[8] === 1 ? 0 : 1 + ); + } + return g = E(y), _ = p[g] = o[g](y), { + c() { + s = element("label"), create_component$1(e.$$.fragment), l = space$1(), _.c(), attr(s, "class", "svelte-18tqgac"), toggle_class( + s, + "container", + /*container*/ + y[7] + ); + }, + m(u, A) { + insert$1(u, s, A), mount_component$1(e, s, null), append(s, l), p[g].m(s, null), x = !0; + }, + p(u, A) { + const C = {}; + A[0] & /*show_label*/ + 64 && (C.show_label = /*show_label*/ + u[6]), A[0] & /*info*/ + 16 && (C.info = /*info*/ + u[4]), A[0] & /*label*/ + 8 | A[1] & /*$$scope*/ + 131072 && (C.$$scope = { dirty: A, ctx: u }), e.$set(C); + let L = g; + g = E(u), g === L ? p[g].p(u, A) : (group_outros$1(), transition_out$1(p[L], 1, 1, () => { + p[L] = null; + }), check_outros$1(), _ = p[g], _ ? _.p(u, A) : (_ = p[g] = o[g](u), _.c()), transition_in$1(_, 1), _.m(s, null)), (!x || A[0] & /*container*/ + 128) && toggle_class( + s, + "container", + /*container*/ + u[7] + ); + }, + i(u) { + x || (transition_in$1(e.$$.fragment, u), transition_in$1(_), x = !0); + }, + o(u) { + transition_out$1(e.$$.fragment, u), transition_out$1(_), x = !1; + }, + d(u) { + u && detach$1(s), destroy_component$1(e), p[g].d(); + } + }; +} +function instance$1(y, s, e) { + let { value: l = "" } = s, { value_is_output: g = !1 } = s, { lines: _ = 1 } = s, { placeholder: x = "Type here..." } = s, { label: o } = s, { info: p = void 0 } = s, { disabled: E = !1 } = s, { show_label: u = !0 } = s, { container: A = !0 } = s, { max_lines: C } = s, { type: L = "text" } = s, { show_copy_button: D = !1 } = s, { rtl: r = !1 } = s, { autofocus: n = !1 } = s, { text_align: b = void 0 } = s, { autoscroll: f = !0 } = s, c, t = !1, a, h, M = 0, w = !1; + const S = createEventDispatcher(); + beforeUpdate(() => { + h = c && c.offsetHeight + c.scrollTop > c.scrollHeight - 100; + }); + const T = () => { + h && f && !w && c.scrollTo(0, c.scrollHeight); + }; + function R() { + S("change", l), g || S("input"); + } + afterUpdate(() => { + n && c.focus(), h && f && T(), e(21, g = !1); + }); + async function z() { + "clipboard" in navigator && (await navigator.clipboard.writeText(l), P()); + } + function P() { + e(15, t = !0), a && clearTimeout(a), a = setTimeout( + () => { + e(15, t = !1); + }, + 1e3 + ); + } + function B(re) { + const Se = re.target, ze = Se.value, Ge = [Se.selectionStart, Se.selectionEnd]; + S("select", { value: ze.substring(...Ge), index: Ge }); + } + async function U(re) { + await tick(), (re.key === "Enter" && re.shiftKey && _ > 1 || re.key === "Enter" && !re.shiftKey && _ === 1 && C >= 1) && (re.preventDefault(), S("submit")); + } + function F(re) { + const Se = re.target, ze = Se.scrollTop; + ze < M && (w = !0), M = ze; + const Ge = Se.scrollHeight - Se.clientHeight; + ze >= Ge && (w = !1); + } + async function $(re) { + if (await tick(), _ === C) + return; + let Se = C === void 0 ? !1 : C === void 0 ? 21 * 11 : 21 * (C + 1), ze = 21 * (_ + 1); + const Ge = re.target; + Ge.style.height = "1px"; + let $e; + Se && Ge.scrollHeight > Se ? $e = Se : Ge.scrollHeight < ze ? $e = ze : $e = Ge.scrollHeight, Ge.style.height = `${$e}px`; + } + function W(re, Se) { + if (_ !== C && (re.style.overflowY = "scroll", re.addEventListener("input", $), !!Se.trim())) + return $({ target: re }), { + destroy: () => re.removeEventListener("input", $) + }; + } + function N(re) { + bubble.call(this, y, re); + } + function G(re) { + bubble.call(this, y, re); + } + function k(re) { + bubble.call(this, y, re); + } + function j(re) { + bubble.call(this, y, re); + } + function Q(re) { + bubble.call(this, y, re); + } + function ie(re) { + bubble.call(this, y, re); + } + function pe(re) { + bubble.call(this, y, re); + } + function he(re) { + bubble.call(this, y, re); + } + function ue() { + l = this.value, e(0, l); + } + function se(re) { + binding_callbacks$1[re ? "unshift" : "push"](() => { + c = re, e(14, c); + }); + } + function ae() { + l = this.value, e(0, l); + } + function we(re) { + binding_callbacks$1[re ? "unshift" : "push"](() => { + c = re, e(14, c); + }); + } + function xe() { + l = this.value, e(0, l); + } + function Ie(re) { + binding_callbacks$1[re ? "unshift" : "push"](() => { + c = re, e(14, c); + }); + } + function oe() { + l = this.value, e(0, l); + } + function ve(re) { + binding_callbacks$1[re ? "unshift" : "push"](() => { + c = re, e(14, c); + }); + } + return y.$$set = (re) => { + "value" in re && e(0, l = re.value), "value_is_output" in re && e(21, g = re.value_is_output), "lines" in re && e(1, _ = re.lines), "placeholder" in re && e(2, x = re.placeholder), "label" in re && e(3, o = re.label), "info" in re && e(4, p = re.info), "disabled" in re && e(5, E = re.disabled), "show_label" in re && e(6, u = re.show_label), "container" in re && e(7, A = re.container), "max_lines" in re && e(8, C = re.max_lines), "type" in re && e(9, L = re.type), "show_copy_button" in re && e(10, D = re.show_copy_button), "rtl" in re && e(11, r = re.rtl), "autofocus" in re && e(12, n = re.autofocus), "text_align" in re && e(13, b = re.text_align), "autoscroll" in re && e(22, f = re.autoscroll); + }, y.$$.update = () => { + y.$$.dirty[0] & /*value*/ + 1 && l === null && e(0, l = ""), y.$$.dirty[0] & /*value, el, lines, max_lines*/ + 16643 && c && _ !== C && $({ target: c }), y.$$.dirty[0] & /*value*/ + 1 && R(); + }, [ + l, + _, + x, + o, + p, + E, + u, + A, + C, + L, + D, + r, + n, + b, + c, + t, + z, + B, + U, + F, + W, + g, + f, + N, + G, + k, + j, + Q, + ie, + pe, + he, + ue, + se, + ae, + we, + xe, + Ie, + oe, + ve + ]; +} +class Textbox extends SvelteComponent$1 { + constructor(s) { + super(), init$1( + this, + s, + instance$1, + create_fragment$1, + safe_not_equal$1, + { + value: 0, + value_is_output: 21, + lines: 1, + placeholder: 2, + label: 3, + info: 4, + disabled: 5, + show_label: 6, + container: 7, + max_lines: 8, + type: 9, + show_copy_button: 10, + rtl: 11, + autofocus: 12, + text_align: 13, + autoscroll: 22 + }, + null, + [-1, -1] + ); + } +} +const { + SvelteComponent, + add_flush_callback, + assign, + bind, + binding_callbacks, + check_outros, + create_component, + destroy_component, + detach, + flush, + get_spread_object, + get_spread_update, + group_outros, + init, + insert, + mount_component, + safe_not_equal, + set_data, + space, + text, + transition_in, + transition_out +} = window.__gradio__svelte__internal, { onMount } = window.__gradio__svelte__internal; +function create_if_block(y) { + let s, e; + const l = [ + { autoscroll: ( + /*gradio*/ + y[1].autoscroll + ) }, + { i18n: ( + /*gradio*/ + y[1].i18n + ) }, + /*loading_status*/ + y[11] + ]; + let g = {}; + for (let _ = 0; _ < l.length; _ += 1) + g = assign(g, l[_]); + return s = new Static({ props: g }), { + c() { + create_component(s.$$.fragment); + }, + m(_, x) { + mount_component(s, _, x), e = !0; + }, + p(_, x) { + const o = x & /*gradio, loading_status*/ + 2050 ? get_spread_update(l, [ + x & /*gradio*/ + 2 && { autoscroll: ( + /*gradio*/ + _[1].autoscroll + ) }, + x & /*gradio*/ + 2 && { i18n: ( + /*gradio*/ + _[1].i18n + ) }, + x & /*loading_status*/ + 2048 && get_spread_object( + /*loading_status*/ + _[11] + ) + ]) : {}; + s.$set(o); + }, + i(_) { + e || (transition_in(s.$$.fragment, _), e = !0); + }, + o(_) { + transition_out(s.$$.fragment, _), e = !1; + }, + d(_) { + destroy_component(s, _); + } + }; +} +function create_default_slot_1(y) { + let s; + return { + c() { + s = text( + /*label*/ + y[2] + ); + }, + m(e, l) { + insert(e, s, l); + }, + p(e, l) { + l & /*label*/ + 4 && set_data( + s, + /*label*/ + e[2] + ); + }, + d(e) { + e && detach(s); + } + }; +} +function create_default_slot(y) { + let s, e, l, g, _, x, o = ( + /*loading_status*/ + y[11] && create_if_block(y) + ); + e = new BlockTitle({ + props: { + show_label: ( + /*show_label*/ + y[7] + ), + info: ( + /*info*/ + y[3] + ), + $$slots: { default: [create_default_slot_1] }, + $$scope: { ctx: y } + } + }); + function p(u) { + y[14](u); + } + let E = {}; + return ( + /*value*/ + y[0] !== void 0 && (E.value = /*value*/ + y[0]), g = new SequenceInput({ props: E }), binding_callbacks.push(() => bind(g, "value", p)), g.$on( + "updateVals", + /*syncValue*/ + y[12] + ), g.$on( + "updateCovMod", + /*syncCovMod*/ + y[13] + ), { + c() { + o && o.c(), s = space(), create_component(e.$$.fragment), l = space(), create_component(g.$$.fragment); + }, + m(u, A) { + o && o.m(u, A), insert(u, s, A), mount_component(e, u, A), insert(u, l, A), mount_component(g, u, A), x = !0; + }, + p(u, A) { + /*loading_status*/ + u[11] ? o ? (o.p(u, A), A & /*loading_status*/ + 2048 && transition_in(o, 1)) : (o = create_if_block(u), o.c(), transition_in(o, 1), o.m(s.parentNode, s)) : o && (group_outros(), transition_out(o, 1, 1, () => { + o = null; + }), check_outros()); + const C = {}; + A & /*show_label*/ + 128 && (C.show_label = /*show_label*/ + u[7]), A & /*info*/ + 8 && (C.info = /*info*/ + u[3]), A & /*$$scope, label*/ + 32772 && (C.$$scope = { dirty: A, ctx: u }), e.$set(C); + const L = {}; + !_ && A & /*value*/ + 1 && (_ = !0, L.value = /*value*/ + u[0], add_flush_callback(() => _ = !1)), g.$set(L); + }, + i(u) { + x || (transition_in(o), transition_in(e.$$.fragment, u), transition_in(g.$$.fragment, u), x = !0); + }, + o(u) { + transition_out(o), transition_out(e.$$.fragment, u), transition_out(g.$$.fragment, u), x = !1; + }, + d(u) { + u && (detach(s), detach(l)), o && o.d(u), destroy_component(e, u), destroy_component(g, u); + } + } + ); +} +function create_fragment(y) { + let s, e; + return s = new Block({ + props: { + visible: ( + /*visible*/ + y[6] + ), + elem_id: ( + /*elem_id*/ + y[4] + ), + elem_classes: ( + /*elem_classes*/ + y[5] + ), + scale: ( + /*scale*/ + y[9] + ), + min_width: ( + /*min_width*/ + y[10] + ), + allow_overflow: !1, + padding: ( + /*container*/ + y[8] + ), + $$slots: { default: [create_default_slot] }, + $$scope: { ctx: y } + } + }), { + c() { + create_component(s.$$.fragment); + }, + m(l, g) { + mount_component(s, l, g), e = !0; + }, + p(l, [g]) { + const _ = {}; + g & /*visible*/ + 64 && (_.visible = /*visible*/ + l[6]), g & /*elem_id*/ + 16 && (_.elem_id = /*elem_id*/ + l[4]), g & /*elem_classes*/ + 32 && (_.elem_classes = /*elem_classes*/ + l[5]), g & /*scale*/ + 512 && (_.scale = /*scale*/ + l[9]), g & /*min_width*/ + 1024 && (_.min_width = /*min_width*/ + l[10]), g & /*container*/ + 256 && (_.padding = /*container*/ + l[8]), g & /*$$scope, value, show_label, info, label, gradio, loading_status*/ + 34959 && (_.$$scope = { dirty: g, ctx: l }), s.$set(_); + }, + i(l) { + e || (transition_in(s.$$.fragment, l), e = !0); + }, + o(l) { + transition_out(s.$$.fragment, l), e = !1; + }, + d(l) { + destroy_component(s, l); + } + }; +} +function instance(y, s, e) { + let { gradio: l } = s, { label: g = "CofoldingInput" } = s, { info: _ = void 0 } = s, { elem_id: x = "" } = s, { elem_classes: o = [] } = s, { visible: p = !0 } = s, { value: E = { chains: [], covMods: [] } } = s, { show_label: u } = s, { container: A = !0 } = s, { scale: C = null } = s, { min_width: L = void 0 } = s, { loading_status: D = void 0 } = s; + function r(f) { + let c = f.detail.map((t) => Object.fromEntries(Object.entries(t).filter(([a, h]) => a !== "open" && h !== ""))); + e(0, E.chains = c, E); + } + function n(f) { + e(0, E.covMods = f.detail, E); + } + onMount(() => { + }); + function b(f) { + E = f, e(0, E); + } + return y.$$set = (f) => { + "gradio" in f && e(1, l = f.gradio), "label" in f && e(2, g = f.label), "info" in f && e(3, _ = f.info), "elem_id" in f && e(4, x = f.elem_id), "elem_classes" in f && e(5, o = f.elem_classes), "visible" in f && e(6, p = f.visible), "value" in f && e(0, E = f.value), "show_label" in f && e(7, u = f.show_label), "container" in f && e(8, A = f.container), "scale" in f && e(9, C = f.scale), "min_width" in f && e(10, L = f.min_width), "loading_status" in f && e(11, D = f.loading_status); + }, [ + E, + l, + g, + _, + x, + o, + p, + u, + A, + C, + L, + D, + r, + n, + b + ]; +} +class Index extends SvelteComponent { + constructor(s) { + super(), init(this, s, instance, create_fragment, safe_not_equal, { + gradio: 1, + label: 2, + info: 3, + elem_id: 4, + elem_classes: 5, + visible: 6, + value: 0, + show_label: 7, + container: 8, + scale: 9, + min_width: 10, + loading_status: 11 + }); + } + get gradio() { + return this.$$.ctx[1]; + } + set gradio(s) { + this.$$set({ gradio: s }), flush(); + } + get label() { + return this.$$.ctx[2]; + } + set label(s) { + this.$$set({ label: s }), flush(); + } + get info() { + return this.$$.ctx[3]; + } + set info(s) { + this.$$set({ info: s }), flush(); + } + get elem_id() { + return this.$$.ctx[4]; + } + set elem_id(s) { + this.$$set({ elem_id: s }), flush(); + } + get elem_classes() { + return this.$$.ctx[5]; + } + set elem_classes(s) { + this.$$set({ elem_classes: s }), flush(); + } + get visible() { + return this.$$.ctx[6]; + } + set visible(s) { + this.$$set({ visible: s }), flush(); + } + get value() { + return this.$$.ctx[0]; + } + set value(s) { + this.$$set({ value: s }), flush(); + } + get show_label() { + return this.$$.ctx[7]; + } + set show_label(s) { + this.$$set({ show_label: s }), flush(); + } + get container() { + return this.$$.ctx[8]; + } + set container(s) { + this.$$set({ container: s }), flush(); + } + get scale() { + return this.$$.ctx[9]; + } + set scale(s) { + this.$$set({ scale: s }), flush(); + } + get min_width() { + return this.$$.ctx[10]; + } + set min_width(s) { + this.$$set({ min_width: s }), flush(); + } + get loading_status() { + return this.$$.ctx[11]; + } + set loading_status(s) { + this.$$set({ loading_status: s }), flush(); + } +} +export { + Example as BaseExample, + Textbox as BaseTextbox, + Index as default +};