UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

119 lines (118 loc) 5.16 kB
import { jsx as t, jsxs as E, Fragment as O } from "react/jsx-runtime"; import { D as P } from "./Dialog-CefajdC9.js"; import { bz as U, u as b, s as f, a as h, o as v, m as S, t as k, D as R, B as A, b0 as w } from "./JBrowsePanel-uJIA-L6s.js"; import { useState as d, useEffect as M } from "react"; import { g as I } from "./index-dFotuATn.js"; import { B as x } from "./BaseCard-CrWzwjYv.js"; var F = U(); const y = /* @__PURE__ */ I(F); function $({ config: e }) { const [r, o] = d(), [s, a] = d(), c = b.getSession(e), { rpcManager: m } = c; M(() => { (async () => { try { const i = f.readConfObject(e, "adapter"), l = await m.call(e.trackId, "CoreGetInfo", { adapterConfig: i }); a(l); } catch (i) { console.error(i), o(i); } })(); }, [e, m]); const p = typeof s == "string" ? { header: `<pre>${s.replaceAll("<", "&lt;").replaceAll(">", "&gt;")}</pre>` } : s || {}; return t(x, { title: "File info", children: r ? t(h.ErrorMessage, { error: r }) : s === void 0 ? t(h.LoadingEllipses, { message: "Loading file data" }) : t(y, { attributes: p }) }); } const N = 1e4, B = S()((e) => ({ container: { minWidth: 800 }, refNames: { maxHeight: 300, overflow: "auto", flexGrow: 1, background: e.palette.background.default } })), L = v(function({ config: e, onClose: r }) { const { classes: o } = B(), [s, a] = d(), [c, m] = d(), [p, i] = d(!1), { rpcManager: l } = b.getSession(e); M(() => { (async () => { try { const n = await Promise.all([...new Set(k.getConfAssemblyNames(e))].map(async (u) => { const D = f.readConfObject(e, "adapter"); return [ u, await l.call(e.trackId, "CoreGetRefNames", { adapterConfig: D, regions: [ { assemblyName: u } ] }) ]; })); m(Object.fromEntries(n)); } catch (n) { console.error(n), a(n); } })(); }, [e, l]); const g = c ? Object.entries(c) : [], C = g.flatMap(([n, u]) => [ `--- ${n} ---`, ...u.slice(0, N), u.length > N ? ` Too many refNames to show in browser for ${n}, use "Copy ref names" button to copy to clipboard` : "" ]).filter((n) => !!n).join(` `); return t(h.Dialog, { open: !0, title: "Reference sequence names used in track", onClose: r, maxWidth: "xl", children: t(R, { className: o.container, children: s ? t(h.ErrorMessage, { error: s }) : c === void 0 ? t(h.LoadingEllipses, { message: "Loading refNames" }) : E(O, { children: [t(A, { variant: "contained", onClick: () => { w(g.flatMap(([n, u]) => [ `--- ${n} ---`, ...u ]).filter((n) => !!n).join(` `)), i(!0), setTimeout(() => { i(!1); }, 1e3); }, children: p ? "Copied to clipboard!" : "Copy ref names" }), t("pre", { className: o.refNames, children: C })] }) }) }); }), T = S()({ content: { minWidth: 800 }, button: { float: "right" } }); function j(e, r) { for (const o in e) o === r ? delete e[o] : typeof e[o] == "object" && j(e[o], r); return e; } const W = v(function({ config: e }) { const [r, o] = d(!1), s = f.readConfObject(e), a = b.getSession(e), { classes: c } = T(), [m, p] = d(!1), i = f.getConf(a, ["formatAbout", "hideUris"]) || f.readConfObject(e, ["formatAbout", "hideUris"]), { pluginManager: l } = b.getEnv(a), g = l.evaluateExtensionPoint("Core-customizeAbout", { config: { ...s, ...f.getConf(a, ["formatAbout", "config"], { config: s }), ...f.readConfObject(e, ["formatAbout", "config"], { config: s }) } }, { session: a, config: e }), C = l.evaluateExtensionPoint("Core-extraAboutPanel", null, { session: a, config: e }); return E("div", { className: c.content, children: [E(x, { title: "Configuration", children: [i ? null : E("span", { className: c.button, children: [t(A, { variant: "contained", color: "secondary", onClick: () => { p(!0); }, children: "Show ref names" }), t(A, { variant: "contained", onClick: () => { const n = j(structuredClone(s), "baseUri"); w(JSON.stringify(n, null, 2)), o(!0), setTimeout(() => { o(!1); }, 1e3); }, children: r ? "Copied to clipboard!" : "Copy config" })] }), t(y, { attributes: g.config, omit: ["displays", "baseUri", "refNames", "formatAbout", "metadata"], hideUris: i })] }), g.config.metadata ? t(x, { title: "Metadata", children: t(y, { attributes: g.config.metadata, omit: ["displays", "baseUri", "refNames", "formatAbout"], hideUris: i }) }) : null, C ? t(x, { title: C.name, children: t(C.Component, { config: e }) }) : null, t($, { config: e }), m ? t(L, { config: e, onClose: () => { p(!1); } }) : null] }); }); function X({ config: e, handleClose: r }) { const o = b.getSession(e), s = k.getTrackName(e, o), { pluginManager: a } = b.getEnv(o), c = a.evaluateExtensionPoint("Core-replaceAbout", W, { session: o, config: e }); return t(P, { open: !0, onClose: r, title: s, maxWidth: "xl", children: t(c, { config: e }) }); } export { X as default }; //# sourceMappingURL=AboutDialog-jJslwcfu.js.map