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