wgts-report 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/wgts-report.js +3 -3
- package/dist/index.html +2 -2
- package/package.json +1 -1
|
@@ -248,8 +248,8 @@ Error generating stack: `+a.message+`
|
|
|
248
248
|
*
|
|
249
249
|
* This source code is licensed under the ISC license.
|
|
250
250
|
* See the LICENSE file in the root directory of this source tree.
|
|
251
|
-
*/const iC=He("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function uC(l){if(l.value===null)return l.text??"";switch(l.key){case"coverage":return`${Math.round(l.value)}×`;case"tmb":return l.value<.01?l.value.toPrecision(2):l.value.toFixed(2);default:return l.value.toFixed(2)}}function sC(l){return l.status==="failed"?"Failed":l.status==="skipped"?"Not in this mode":"Not run"}const oC=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",year:"numeric"});function rC(l){if(!l)return"";const i=new Date(l);return Number.isNaN(i.getTime())?"":oC.format(i)}function Qd(l,i){return l.startsWith(`${i}_`)?l.slice(i.length+1):l}function bd(l){return l==null?"–":l.toFixed(2)}const Zv={missense_variant:"Missense",stop_gained:"Nonsense",stop_lost:"Stop lost",start_lost:"Start lost",frameshift_variant:"Frameshift",inframe_deletion:"In-frame deletion",inframe_insertion:"In-frame insertion",splice_acceptor_variant:"Splice acceptor",splice_donor_variant:"Splice donor",splice_region_variant:"Splice region",synonymous_variant:"Synonymous",intron_variant:"Intronic",upstream_gene_variant:"Upstream",downstream_gene_variant:"Downstream","5_prime_UTR_variant":"5′ UTR","3_prime_UTR_variant":"3′ UTR"};function cC(l,i){const u=(l??i??"").split("&")[0];if(!u)return"–";if(Zv[u])return Zv[u];const s=u.replace(/_/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}function fC(l,i){return`chr${l}:${i.toLocaleString("en-US")}`}const Gn=[["1",249250621],["2",243199373],["3",198022430],["4",191154276],["5",180915260],["6",171115067],["7",159138663],["8",146364022],["9",141213431],["10",135534747],["11",135006516],["12",133851895],["13",115169878],["14",107349540],["15",102531392],["16",90354753],["17",81195210],["18",78077248],["19",59128983],["20",63025520],["21",48129895],["22",51304566],["X",155270560]],Cd=.0025,dC=Gn.reduce((l,[,i])=>l+i,0),hC=1-Cd*Gn.length,Wo=(()=>{const l={};let i=Cd/2;for(const[u,s]of Gn){const c=s/dC*hC;l[u]=[i,i+c],i+=c+Cd}return l})(),Kv=Object.fromEntries(Gn);function Xo(l,i){const u=l.replace(/^chr/,""),s=Wo[u];if(!s)return null;const c=Math.min(Math.max(i,0),Kv[u]);return s[0]+c/Kv[u]*(s[1]-s[0])}function Jv(l,i,u,s){const c=s*2*Math.PI-Math.PI/2;return[l+u*Math.cos(c),i+u*Math.sin(c)]}function Qf(l,i,u,s,c){const[f,h]=Jv(l,i,u,s),[m,v]=Jv(l,i,u,c),x=c-s>.5?1:0;return`M${f.toFixed(2)},${h.toFixed(2)} A${u},${u} 0 ${x} 1 ${m.toFixed(2)},${v.toFixed(2)}`}function Iv(l,i="start"){let u=null;for(const f of Gn){const[h,m]=f,[v,x]=Wo[h];if(l<v&&i==="end"&&u)return{chrom:u[0],pos:u[1]};if(l<=x)return{chrom:h,pos:Math.round(Math.max(0,(l-v)/(x-v))*m)};u=f}const[s,c]=Gn[Gn.length-1];return{chrom:s,pos:c}}function Wu(l,i){const u=i>=1e6?0:i>=1e5?1:2;return`${(l/1e6).toFixed(u)} Mb`}const gC={hero:{box:220,ring:78,ringW:10,gain:93,gainW:7,amp:94,ampW:13,loss:63,lossW:7,drv:50,drvW:9},switcher:{box:48,ring:16,ringW:4.5,gain:21,gainW:3,amp:21,ampW:4.5,loss:11,lossW:3,drv:0,drvW:0},mini:{box:20,ring:7,ringW:2.6,gain:7,gainW:2.6,amp:7,ampW:2.6,loss:7,lossW:2.6,drv:0,drvW:0}},Pv=.004,Wv=.003;function mC(l,i,u){const s=Xo(l,i),c=Xo(l,u);return s===null||c===null?null:c-s<Pv?[s,s+Pv]:[s,c]}function Yf(l){return l.length<=1?l[0]??"":`${l.slice(0,-1).join(", ")} and ${l[l.length-1]}`}function pC(l,i,u){return l===1?`one ${i}`:`${l} ${u}`}function e0(l){const u=[["amp","amplification","amplifications"],["gain","gain","gains"],["loss","loss","losses"]].flatMap(([h,m,v])=>{const x=l.events.filter(j=>j.kind===h);if(x.length===0)return[];const y=[...new Set(x.map(j=>j.chrom))],S=y.length>6?[...y.slice(0,6),`${y.length-6} more`]:y,b=y.length===1?`chromosome ${y[0]}`:`chromosomes ${Yf(S)}`,N=h==="amp"&&x.length===1&&x[0].total_cn!==null?` (${Math.round(x[0].total_cn)} copies)`:"";return[`${pC(x.length,m,v)} on ${b}${N}`]}),s=u.length?Yf(u):`no copy-number changes against ${l.baseline} copies`,c=[...new Set(l.drivers.map(h=>h.gene).filter(h=>!!h))].sort(),f=c.length?`Drivers in ${Yf(c)}.`:"No drivers.";return`${s.charAt(0).toUpperCase()}${s.slice(1)}. ${f}`}function er({fingerprint:l,size:i,title:u,subtitle:s,className:c}){const f=gC[i],h=f.box/2,m=(l==null?void 0:l.events)??[],v=(l==null?void 0:l.drivers)??[],x=l?`Genome fingerprint: ${e0(l)}`:"No copy-number data";return g.jsxs("svg",{viewBox:`0 0 ${f.box} ${f.box}`,role:i==="mini"?void 0:"img","aria-label":i==="mini"?void 0:x,"aria-hidden":i==="mini"?!0:void 0,className:c,children:[g.jsxs("g",{fill:"none",strokeLinecap:"butt",children:[Object.entries(Wo).map(([y,[S,b]])=>g.jsx("path",{className:"r-neu",strokeWidth:f.ringW,d:Qf(h,h,f.ring,S,b)},y)),m.map((y,S)=>{const b=mC(y.chrom,y.start,y.end);if(!b)return null;const N=y.kind==="loss"?f.loss:y.kind==="amp"?f.amp:f.gain,j=y.kind==="loss"?f.lossW:y.kind==="amp"?f.ampW:f.gainW;return g.jsx("path",{className:`r-${y.kind}`,strokeWidth:j,d:Qf(h,h,N,b[0],b[1])},`${y.chrom}-${y.start}-${S}`)}),f.drvW>0&&v.map((y,S)=>{const b=Xo(y.chrom,y.pos);return b===null?null:g.jsx("path",{className:"r-drv",strokeWidth:f.drvW,d:Qf(h,h,f.drv,b-Wv/2,b+Wv/2)},`${y.gene}-${y.pos}-${S}`)})]}),i==="hero"&&u&&g.jsxs(g.Fragment,{children:[g.jsx("text",{className:"t-ink",x:h,y:h-2,textAnchor:"middle",fontSize:"24",fontWeight:"800",children:u}),s&&g.jsx("text",{className:"t-faint",x:h,y:h+18,textAnchor:"middle",fontSize:"12",fontWeight:"600",children:s})]})]})}const vC={"DNA|WG":{label:"WGS",icon:Io},"RNA|WT":{label:"RNA",icon:Bb}};function ey({children:l}){return g.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l})}function yC({sex:l}){const i=l==null?void 0:l.toUpperCase();return i==="MALE"?g.jsxs(ey,{children:[g.jsx("circle",{cx:"12",cy:"9",r:"4.5"}),g.jsx("path",{d:"M7.6 8.2c.5-2.9 2.4-4.7 4.6-4.7 2.6 0 4.4 1.7 4.4 4.3-2.2.1-4.2-.6-5.6-2.1"}),g.jsx("path",{d:"M3.5 21a8.5 7.5 0 0 1 17 0"}),g.jsx("path",{d:"m10 15.6 2 2.2 2-2.2"})]}):i==="FEMALE"?g.jsxs(ey,{children:[g.jsx("circle",{cx:"12",cy:"9.2",r:"3.4"}),g.jsx("path",{d:"M6.3 14.2C4.6 9 6.6 2.8 12 2.8s7.4 6.2 5.7 11.4"}),g.jsx("path",{d:"M5 21.2a7 6.3 0 0 1 14 0"})]}):g.jsx(Wy,{size:16,"aria-hidden":!0})}const t0="wgts-patient-root";function SC(l,i){const u=l.getBoundingClientRect(),s=l.closest(".topbar"),c=s==null?void 0:s.parentElement,f=s&&c?c.getBoundingClientRect().top-s.getBoundingClientRect().top:0;return{x:u.left-i.left+u.width/2,y:u.top+f-i.top+u.height/2}}const n0=8;function kf(l,i,u,s){const c=u>=l.x?1:-1,f=Math.min(n0,Math.abs(u-l.x)/2,(i-l.y-14)/2);return[`M${l.x},${l.y+14}`,`V${i-f}`,`Q${l.x},${i} ${l.x+c*f},${i}`,`H${u-c*f}`,`Q${u},${i} ${u},${i+f}`,`V${s}`].join(" ")}function xC(l,i,u){const s=u.x>i.x?1:-1,c=Math.min(n0,Math.abs(u.x-i.x)/2,(i.top-l)/2);return[`M${i.x},${i.top}`,`V${l+c}`,`Q${i.x},${l} ${i.x+s*c},${l}`,`H${u.x-s*c}`,`Q${u.x},${l} ${u.x},${l+c}`,`V${u.top}`].join(" ")}function bC(l,i,u){const s=i.left+i.width/2,c=u.left+u.width/2,f=l-7,m=(l-31-.25*f)/.75;return`M${s},${f} C${s},${m} ${c},${m} ${c},${f}`}function CC(l,i){var s,c;const u=l.samples.find(f=>f.id===i);for(const f of(u==null?void 0:u.experiments)??[]){const h=(s=l.experiments[f])==null?void 0:s.normal,m=h?(c=l.experiments[h])==null?void 0:c.sample:void 0;if(m&&m!==i)return m}return null}function EC({data:l,sampleId:i,fingerprint:u,onSample:s}){const c=O.useRef(null),[f,h]=O.useState(null),[m,v]=O.useState(!1);O.useEffect(()=>{if(!f||m)return;const C=requestAnimationFrame(()=>v(!0));return()=>cancelAnimationFrame(C)},[f,m]);const x=new Set(l.failures.map(C=>C.sample)),y=O.useRef(i),[S,b]=O.useState(null);O.useEffect(()=>{if(y.current===i)return;const C=y.current;y.current=i,b(U=>({from:C,to:i,n:((U==null?void 0:U.n)??0)+1}))},[i]);const N=CC(l,i);O.useLayoutEffect(()=>{const C=c.current;if(!C)return;const U=()=>{const $=C.getBoundingClientRect(),F=document.getElementById(t0);if(!F)return;const te=Array.from(C.querySelectorAll("[data-sample]")).map(de=>{const ge=de.getBoundingClientRect();return{id:de.dataset.sample,x:ge.left-$.left+22,left:ge.left-$.left,width:ge.width,top:ge.top-$.top,bottom:ge.bottom-$.top}}),k=SC(F,$),Z=Math.min(...te.map(de=>de.top));h({root:k,trunk:Z-12,tabs:te})};if(U(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(U);return q.observe(C),()=>q.disconnect()},[l,i]);const j=f==null?void 0:f.tabs.find(C=>C.id===i),D=N?f==null?void 0:f.tabs.find(C=>C.id===N):void 0,w=S?f==null?void 0:f.tabs.find(C=>C.id===S.from):void 0;return g.jsxs("div",{ref:c,className:"ltabs",children:[f&&g.jsxs("svg",{className:"ltabs-links","aria-hidden":!0,children:[f.tabs.map(C=>g.jsx("path",{d:kf(f.root,f.trunk,C.x,C.top)},C.id)),j&&g.jsxs(g.Fragment,{children:[g.jsx("path",{className:"ltabs-haze","data-moving":m,style:{d:`path("${kf(f.root,f.trunk,j.x,j.top)}")`}}),g.jsx("path",{className:"ltabs-on","data-moving":m,style:{d:`path("${kf(f.root,f.trunk,j.x,j.top)}")`}}),w&&S&&S.to===j.id&&g.jsx("path",{className:"ltabs-bead",pathLength:1,d:xC(f.trunk,w,j)},`bead-${S.n}`)]}),j&&D&&g.jsxs("g",{className:"ltabs-match",children:[g.jsx("path",{d:bC(f.trunk,j,D)}),g.jsx("text",{x:(j.left+j.width/2+D.left+D.width/2)/2,y:f.trunk-27,children:"matched normal"})]})]}),j&&g.jsx("span",{className:"ltabs-thumb","data-moving":m,"aria-hidden":!0,style:{width:j.width,height:j.bottom-j.top,transform:`translate(${j.left}px, ${j.top}px)`}}),g.jsx("div",{className:"ltabs-row",role:"tablist","aria-label":"Samples",children:l.samples.map(C=>{const U=C.id===i,q=u==null?void 0:u.samples.find(F=>F.sample===C.id),$=C.experiments.map(F=>({id:F,...l.experiments[F]})).filter(F=>F.technique);return g.jsxs("button",{type:"button",role:"tab","data-sample":C.id,"aria-selected":U,className:"ltab",onClick:()=>s(C.id),children:[g.jsxs("span",{className:"ltab-name",children:[C.category==="TUMOR"?g.jsx(er,{fingerprint:q,size:"mini",className:"h-[18px] w-[18px] flex-none"}):g.jsx(Iy,{size:15,"aria-hidden":!0,className:"flex-none"}),Qd(C.id,l.individual.id)," ",C.category==="TUMOR"?"tumour":"normal",x.has(C.id)&&g.jsx("span",{className:"ltab-warn",title:"A module failed for this sample","aria-label":"A module failed"})]}),g.jsxs("span",{className:"ltab-exps",children:[$.length===0&&g.jsx("span",{children:"No experiments"}),$.map(F=>{const te=vC[F.technique],k=(te==null?void 0:te.icon)??Io;return g.jsxs("span",{title:F.id,children:[g.jsx(k,{size:12,"aria-hidden":!0}),(te==null?void 0:te.label)??F.technique]},F.id)})]})]},C.id)})})]})}function wC({data:l,sampleId:i,fingerprint:u,onSample:s}){return g.jsx("div",{className:"ctabs",role:"tablist","aria-label":"Samples",children:l.samples.map(c=>{const f=u==null?void 0:u.samples.find(h=>h.sample===c.id);return g.jsxs("button",{type:"button",role:"tab","aria-selected":c.id===i,className:"ctab",onClick:()=>s(c.id),children:[c.category==="TUMOR"?g.jsx(er,{fingerprint:f,size:"mini",className:"h-[16px] w-[16px] flex-none"}):g.jsx(Iy,{size:14,"aria-hidden":!0,className:"flex-none"}),Qd(c.id,l.individual.id)," ",c.category==="TUMOR"?"tumour":"normal"]},c.id)})})}function l0({individualId:l,subtitle:i,patientIcon:u,compact:s,showCompact:c=!1}){const[f,h]=O.useState(!1),[m,v]=O.useState(!1);O.useEffect(()=>{const y=()=>v(window.scrollY>4);return y(),window.addEventListener("scroll",y,{passive:!0}),()=>window.removeEventListener("scroll",y)},[]);async function x(){try{await navigator.clipboard.writeText(window.location.href),h(!0),window.setTimeout(()=>h(!1),1600)}catch{window.prompt("Copy this link",window.location.href)}}return g.jsxs("div",{className:"topbar flex flex-wrap items-center justify-between gap-x-4 gap-y-3 px-8 pt-4 pb-3.5","data-scrolled":m,children:[g.jsxs("nav",{"aria-label":"Breadcrumb",className:"flex min-w-0 items-center gap-2 text-[13.5px]",children:[g.jsx(Ob,{to:"/",style:{color:"var(--muted)",textDecoration:"none"},children:"Patients"}),l&&g.jsxs(g.Fragment,{children:[g.jsx(Fd,{size:14,"aria-hidden":!0,style:{color:"var(--chev)"}}),u&&g.jsx("span",{id:t0,className:"ltabs-icon",children:u}),g.jsx("h1",{className:"m-0 text-[20px] font-semibold tracking-tight",style:{color:"var(--ink)"},children:l}),i&&g.jsx("span",{className:"ml-1.5 truncate text-[13.5px]",style:{color:"var(--muted)"},children:i})]})]}),g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.jsxs("div",{className:"field w-[300px] max-w-full",title:"Not available yet",children:[g.jsx(Po,{size:16,"aria-hidden":!0,style:{color:"var(--chev)"}}),g.jsx("label",{className:"sr-only",htmlFor:"search",children:"Search"}),g.jsx("input",{id:"search",placeholder:"Search genes, variants, analyses",disabled:!0})]}),g.jsx("button",{type:"button",className:"sc-btn sc-b2",disabled:!0,title:"Not available yet",children:"Compare versions"}),g.jsx("button",{type:"button",className:"sc-ib","aria-label":"Copy a link to this view",onClick:x,children:g.jsx(eC,{size:16,"aria-hidden":!0})}),g.jsx("button",{type:"button",className:"sc-ib","aria-label":"Export tables",disabled:!0,title:"Not available yet",children:g.jsx(Jb,{size:16,"aria-hidden":!0})}),g.jsx("span",{"aria-live":"polite",className:"text-xs",style:{color:"var(--muted)"},children:f?"Link copied":""})]}),s&&g.jsx("div",{className:"topbar-compact","data-open":c,inert:!c,"aria-hidden":!c,children:g.jsx("div",{children:s})})]})}class tr extends Error{}class a0 extends Error{}function RC(){try{return localStorage.getItem(xd)}catch{return null}}function i0(l){try{l?localStorage.setItem(xd,l):localStorage.removeItem(xd)}catch{}}function u0(){const l=RC();return{Accept:"application/json",...l?{Authorization:`Token ${l}`}:{}}}async function Ii(l,i={}){const u=new URLSearchParams;for(const[f,h]of Object.entries(i))h&&u.set(f,h);const s=u.toString(),c=await fetch(`${Fn.apiHost}/wgts/api/${l}${s?`?${s}`:""}`,{headers:u0()});if(c.status===401)throw new tr;if(c.status===403){const f=await c.json().catch(()=>({}));throw new a0(f.detail??"You may not see this patient's results.")}if(!c.ok)throw new Error(`The dashboard API answered ${c.status}.`);return await c.json()}async function _C(l){if(!(await fetch(`${Fn.apiHost}/api/v1/auth/`,{headers:{Accept:"application/json",Authorization:`Token ${l}`}})).ok)throw new Error("Isabl did not accept that token.");i0(l)}async function TC(l,i){const u=await fetch(`${Fn.apiHost}/api/v1/rest-auth/login/`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({username:l,password:i})});if(!u.ok)throw new Error("Isabl did not accept that username and password.");const s=await u.json();i0(s.key)}async function NC(l){const i=new URLSearchParams(l?{q:l}:{}).toString(),u=await fetch(`${Fn.apiHost}/wgts/api/individuals/${i?`?${i}`:""}`,{headers:u0()});if(u.status===401)throw new tr;if(!u.ok)throw new Error(`The dashboard API answered ${u.status}.`);return(await u.json()).results}const s0={drivers:"gene",coding:"position",all:"position"},MC=[10,25,50,100];function ty(){return{scope:"drivers",page:1,pageSize:25,sort:s0.drivers,q:"",effects:[],flags:[],range:null,ffpe:!1}}function o0(l){return(l.q.trim()?1:0)+l.effects.length+l.flags.length+(l.range?1:0)}function OC(l){const i={scope:l.scope,page:String(l.page),page_size:String(l.pageSize),sort:l.sort,q:l.q.trim()||void 0,effects:l.effects.join(",")||void 0,flags:l.flags.join(",")||void 0,ffpe:l.ffpe?"all":void 0};return l.range&&(i[`${l.range.measure}_min`]=String(l.range.low),i[`${l.range.measure}_max`]=String(l.range.high)),i}const r0={missense:"Missense",truncating:"Truncating",splice:"Splice",inframe:"In-frame",synonymous:"Synonymous",other:"Other"},c0={hotspot:"Hotspot",in_dmp:"In DMP",oncogene:"Oncogene",tsg:"Tumour suppressor"};function jC(l){return`${l.chrom}:${l.pos}:${l.ref}>${l.alt}`}const AC=/^(?:chr)?([0-9]{1,2}|[XYxy]):([0-9,]+)(?:-([0-9,]+))?$/;function zC(l){return AC.test(l.trim())}function DC(l,i,u){return`chr${l}:${i.toLocaleString("en-US")}-${u.toLocaleString("en-US")}`}const UC={GENOMIC_EXACT:"exact match",GENOMIC_POS:"same position",CODON:"same codon",GENE:"same gene"};function HC(l){var f;if(!l)return null;const i=l.split(";"),u=(f=l.match(/SOM=(\d+)/))==null?void 0:f[1],s=UC[i[0]];return!u&&!s?l:[u?`${Number(u).toLocaleString("en-US")} somatic ${u==="1"?"sample":"samples"}`:"",s].filter(Boolean).join(", ")}function VC(l){const i=l==null?void 0:l.match(/^(\d+)\/(\d+)$/);return i?`${i[1]} of ${i[2]} ${i[2]==="1"?"copy":"copies"}`:l}function LC(l){return l.oncogene&&l.tsg?"Oncogene and TSG":l.oncogene?"Oncogene":l.tsg?"TSG":null}const qa=(l,i)=>!(i instanceof tr)&&l<2;function qC(l,i){return Va({queryKey:["individual",l,i??null],queryFn:()=>Ii(`individuals/${encodeURIComponent(l)}/`,{version:i}),retry:qa})}function BC(l,i,u){return Va({queryKey:["metrics",l,i,u??null],queryFn:()=>Ii(`individuals/${encodeURIComponent(l)}/metrics/`,{sample:i,version:u}),enabled:!!i,retry:qa})}function GC(l,i){return Va({queryKey:["fingerprint",l,i??null],queryFn:()=>Ii(`individuals/${encodeURIComponent(l)}/fingerprint/`,{version:i}),retry:qa})}const Yd=(l,i)=>`individuals/${encodeURIComponent(l)}/${i}/`;function FC(l,i,u){return Va({queryKey:["cn",l,i,u??null],queryFn:()=>Ii(Yd(l,"cn"),{sample:i,version:u}),enabled:!!i,retry:qa})}function $C(l,i,u,s,c){return Va({queryKey:["ccf",l,i,u,s,c??null],queryFn:()=>Ii(Yd(l,"ccf"),{sample:i,measure:u,version:c,ffpe:s?"all":void 0}),enabled:!!i,retry:qa})}function QC(l,i,u,s){return Va({queryKey:["variants",l,i,u,s??null],queryFn:()=>Ii(Yd(l,"variants"),{sample:i,version:s,...OC(u)}),enabled:!!i,placeholderData:Ny,retry:qa})}function YC(l,i){return Va({queryKey:["patients",l],queryFn:()=>NC(l),enabled:i,staleTime:6e4,placeholderData:Ny,retry:qa})}const f0="wgts-recent-patients",kC=6;function d0(){try{const l=JSON.parse(localStorage.getItem(f0)??"[]");return Array.isArray(l)?l.filter(i=>typeof i=="string"):[]}catch{return[]}}function XC(l){try{localStorage.setItem(f0,JSON.stringify([l,...d0().filter(i=>i!==l)].slice(0,kC)))}catch{}}const ZC=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function h0({current:l}){const i=Jo(),[u,s]=O.useState(""),[c,f]=O.useState(!1),[h,m]=O.useState(0),v=O.useRef(null),x=O.useId(),y=O.useDeferredValue(u.trim()),S=YC(y,c&&y.length>0);O.useEffect(()=>{const C=U=>{var q;U.key.toLowerCase()==="k"&&(U.metaKey||U.ctrlKey)&&(U.preventDefault(),(q=v.current)==null||q.focus())};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const b=y?(S.data??[]).map(C=>({id:C.individual,meta:C.individual===l?"On this page":`${C.samples} ${C.samples===1?"sample":"samples"}, report ${C.report_version}`})):d0().filter(C=>C!==l).map(C=>({id:C,meta:"Opened recently",recent:!0})),N=y&&b.length===0&&!S.isFetching?{id:y,meta:"No dashboard found; open anyway"}:null,j=N?[...b,N]:b,D=c&&(j.length>0||y&&S.isFetching),w=C=>{var U;s(""),f(!1),(U=v.current)==null||U.blur(),C!==l&&i(`/${encodeURIComponent(C)}`)};return g.jsxs("div",{className:"psearch","data-open":!!D,children:[g.jsxs("div",{className:"psearch-field",children:[g.jsx(Po,{size:15,"aria-hidden":!0}),g.jsx("input",{ref:v,role:"combobox","aria-expanded":!!D,"aria-controls":x,"aria-activedescendant":D&&j[h]?`${x}-${h}`:void 0,"aria-label":"Search patients",placeholder:"Search patients",value:u,onFocus:()=>f(!0),onBlur:()=>f(!1),onChange:C=>{s(C.target.value),m(0),f(!0)},onKeyDown:C=>{var U;C.key==="ArrowDown"?(C.preventDefault(),m(q=>Math.min(q+1,j.length-1))):C.key==="ArrowUp"?(C.preventDefault(),m(q=>Math.max(q-1,0))):C.key==="Enter"&&j[h]?(C.preventDefault(),w(j[h].id)):C.key==="Escape"&&(s(""),(U=v.current)==null||U.blur())}}),g.jsx("kbd",{className:"kbd","aria-hidden":!0,children:ZC?"⌘K":"Ctrl K"})]}),D&&g.jsxs("ul",{id:x,role:"listbox",className:"psearch-list","aria-label":"Patients",children:[!y&&g.jsx("li",{className:"psearch-head",children:"Recent"}),j.map((C,U)=>g.jsxs("li",{id:`${x}-${U}`,role:"option","aria-selected":U===h,className:"psearch-option",onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>m(U),onClick:()=>w(C.id),children:[C.recent?g.jsx(Ib,{size:14,"aria-hidden":!0}):g.jsx(Wy,{size:14,"aria-hidden":!0}),g.jsxs("span",{className:"flex min-w-0 flex-col",children:[g.jsx("span",{className:"truncate",children:C.id}),g.jsx("span",{className:"psearch-meta",children:C.meta})]}),U===h&&g.jsx(Zb,{size:13,"aria-hidden":!0,className:"ml-auto flex-none opacity-50"})]},C.id)),y&&j.length===0&&g.jsx("li",{className:"psearch-head",children:"Searching…"})]})]})}function KC(){const l=Jo(),[i,u]=O.useState("");return g.jsxs("div",{className:`wgts ${Fn.theme}`,children:[g.jsxs("aside",{className:"side","aria-label":"Navigation",children:[g.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[g.jsx(Io,{size:24,strokeWidth:1.9,style:{color:"var(--menu-hi)"},"aria-hidden":!0}),g.jsx("span",{className:"text-base font-semibold tracking-tight",style:{color:"var(--menu-brand)"},children:"WGTS Reports"})]}),g.jsx(h0,{current:""})]}),g.jsxs("div",{className:"page",children:[g.jsx(l0,{}),g.jsxs("main",{className:"flex flex-col gap-4 px-8 pt-8 pb-10",children:[g.jsx("h1",{className:"m-0 text-[28px] font-semibold tracking-tight",children:"Open a patient"}),g.jsx("p",{className:"m-0 max-w-[60ch] text-[14.5px]",style:{color:"var(--ink-2)"},children:"Enter an individual's system id to see its WGTS report as live charts and tables."}),g.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:s=>{s.preventDefault(),i.trim()&&l(`/${i.trim()}`)},children:[g.jsxs("div",{className:"field w-[340px] max-w-full",children:[g.jsx(Po,{size:16,"aria-hidden":!0,style:{color:"var(--chev)"}}),g.jsx("label",{className:"sr-only",htmlFor:"open-id",children:"Individual id"}),g.jsx("input",{id:"open-id",placeholder:"IID_H000001",value:i,onChange:s=>u(s.target.value)})]}),g.jsx("button",{type:"submit",className:"sc-btn sc-b1",disabled:!i.trim(),children:"Open"})]})]})]})]})}function Ed(l){const i=l.toUpperCase();return i.startsWith("BATTENBERG")||i.startsWith("CNV_")?"cn":i.startsWith("ANNOT_SNVS")||i.startsWith("ANNOT_INDELS")||i.startsWith("FFPERASE")?"mut":i.startsWith("MSISENSOR")?"msi":"other"}function Ki(l){return`fam-${Ed(l)}`}function g0(l){return l.pk?`${l.app} #${l.pk}`:l.app}function wt(l){return`${l.app}#${l.pk??""}`}const JC=[{label:"Overview",icon:Wb,ready:!0},{label:"Copy number",icon:Vb,ready:!1},{label:"Mutations",icon:tC,ready:!1},{label:"Structural variants",icon:lC,ready:!1},{label:"Signatures and HRD",icon:Gb,ready:!1},{label:"RNA",icon:aC,ready:!1},{label:"Germline",icon:nC,ready:!1},{label:"Quality",icon:Yb,ready:!1}];function IC({individualId:l,sampleCount:i,mode:u,fingerprint:s,analyses:c,onPage:f,sampleLabel:h,picked:m,onPick:v}){const[x,y]=O.useState(!1),S=["cn","mut","msi","other"],b=(w,C)=>S.indexOf(Ed(w.app))-S.indexOf(Ed(C.app))||w.app.localeCompare(C.app),N=c.filter(w=>w.role==="input"),j=N.filter(w=>f.has(wt(w))).sort(b),D=[...N.filter(w=>!f.has(wt(w))).sort(b),...c.filter(w=>w.role==="cohort")];return g.jsxs("aside",{className:"side","aria-label":"Patient navigation",children:[g.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[g.jsx(Io,{size:24,strokeWidth:1.9,style:{color:"var(--menu-hi)"},"aria-hidden":!0}),g.jsx("span",{className:"text-base font-semibold tracking-tight",style:{color:"var(--menu-brand)"},children:"WGTS Reports"})]}),g.jsx(h0,{current:l}),g.jsxs("nav",{"aria-label":"Patient sections",className:"flex flex-col gap-0.5",children:[g.jsxs("div",{className:"side-patient",children:[g.jsx(er,{fingerprint:s,size:"switcher",className:"h-10 w-10 flex-none"}),g.jsxs("span",{className:"flex min-w-0 flex-col gap-px",children:[g.jsx("span",{className:"truncate text-[13.5px] font-semibold",style:{color:"var(--menu-strong)"},children:l}),g.jsxs("span",{className:"text-xs",style:{color:"var(--menu-muted)"},children:[i," samples",u?`, ${u}`:""]})]})]}),JC.map(({label:w,icon:C,ready:U})=>g.jsxs("button",{type:"button",className:"sc-nav","aria-current":U?"page":void 0,disabled:!U,title:U?void 0:"Not available yet",children:[g.jsx(C,{size:18,"aria-hidden":!0}),w]},w))]}),g.jsxs("section",{"aria-label":"Analyses on this page",className:"flex flex-col gap-0.5",children:[g.jsx("span",{className:"side-label",children:"Analyses on this page"}),j.length===0&&g.jsxs("span",{className:"px-3 text-xs",style:{color:"var(--menu-muted)"},children:["Nothing on this page reads an analysis for ",h||"this sample","."]}),j.map(w=>{const C=wt(w),U=w.state==="failed",q=w.modules.filter($=>$.status==="failed");return g.jsxs("button",{type:"button",className:`tb-src${U?" fail":""}`,"aria-pressed":m===C,title:U?q.map($=>`${$.label} failed`).join("; "):"Show what it feeds",onClick:()=>v(m===C?null:C),children:[U?g.jsx(Py,{size:12,strokeWidth:2.6,"aria-hidden":!0,style:{color:"var(--fail-d)",margin:"0 -2px"}}):g.jsx("span",{className:`tb-dot ${Ki(w.app)}`,"aria-hidden":!0}),g.jsxs("span",{className:"truncate",children:[w.app," ",w.version??""]}),U&&g.jsx("span",{className:"sr-only",children:", failed"}),g.jsx("span",{className:"tb-n",children:w.pk?`#${w.pk}`:""})]},C)}),D.length>0&&g.jsxs(g.Fragment,{children:[g.jsxs("button",{type:"button",className:"tb-src","aria-expanded":x,onClick:()=>y(w=>!w),children:[g.jsx("span",{className:"tb-dot fam-other","aria-hidden":!0}),x?"Hide":"Show"," ",D.length," more for ",h||"this sample"]}),x&&D.map(w=>g.jsxs("span",{className:"tb-src",style:{cursor:"default"},children:[g.jsx("span",{className:`tb-dot ${Ki(w.app)}`,"aria-hidden":!0}),g.jsx("span",{className:"truncate",children:w.role==="cohort"?`${w.app}${w.project?`, project ${w.project}`:""}`:`${w.app} ${w.version??""}`}),g.jsx("span",{className:"tb-n",children:w.pk?`#${w.pk}`:""})]},wt(w)))]}),g.jsx("span",{className:"px-3 pt-2 text-xs leading-normal",style:{color:"var(--menu-muted)"},children:"Pick one to see what it feeds."})]}),g.jsx("div",{className:"flex-auto"})]})}function _a({envelope:l}){const i=l.status==="error",u=i?Qb:kb;return g.jsxs("div",{className:"flex items-start gap-2.5 text-sm",style:{color:"var(--ink-2)"},children:[g.jsx(u,{size:18,"aria-hidden":!0,style:{color:i?"var(--warn-ink)":"var(--chev)",flex:"none"}}),g.jsxs("div",{className:"flex flex-col gap-1",children:[g.jsx("span",{className:"font-semibold",style:{color:"var(--ink)"},children:i?"This panel could not be read":"Nothing to show here"}),l.warnings.map(s=>g.jsx("span",{children:s},s))]})]})}const wd={summary:{title:"Genome fingerprint and summary",intro:"A one-glance portrait of the selected tumour: its copy-number changes and driver mutations drawn as a ring, a sentence describing them, and the headline measurements of the sample.",sections:[{heading:"The fingerprint ring",paragraphs:["The ring is the whole genome. Chromosome 1 starts at the top and the ring runs clockwise through chromosome 22 to X, each chromosome's arc in proportion to its length (GRCh37).","Copy-number changes are called against the tumour's baseline, its ploidy rounded to whole copies. Very short changes are drawn at a minimum length so they stay visible."],terms:[["Gains (outer track, orange)","Regions with at least one copy more than the baseline."],["Amplifications (outer track, darker and thicker)","Regions with three or more copies above the baseline."],["Losses (inner track, blue)","Regions with at least one copy fewer than the baseline."],["Drivers (black ticks)","Where the tumour's likely driver mutations sit (see the Mutations card for how they are flagged)."]]},{heading:"The sentence",paragraphs:["Written from the same data as the ring: how many amplifications, gains and losses there are and on which chromosomes, and which genes carry driver mutations."]},{heading:"The measurements",paragraphs:["Each tile shows a value, a small picture of where it sits on its scale when it has a natural one, and the analysis it came from. A tile with no value says why: the analysis was not run, it failed, or it does not apply to this kind of report (tumour-only reports have no matched normal)."],terms:[["Purity","The estimated fraction of cells in the sample that are tumour cells, from 0 to 1. The ring fills to the value."],["Ploidy","The tumour's average number of copies across the genome. The scale runs from 1 to 6 copies; the tall tick marks 2, a diploid genome."],["Coverage","The median sequencing depth of the tumour across the genome, in reads (×)."],["TMB per Mb","Tumour mutational burden: somatic SNVs and indels per megabase of genome. The report computes it from the counts of the SNV and indel calls. The scale is logarithmic, 0.01 to 100."],["MSI score","The MSIsensor score: the percentage of microsatellite sites that look unstable in the tumour."],["FGA","Fraction of the genome altered: the share of the genome whose copy number differs from the baseline, from 0 to 1. It is read from the project-wide Battenberg tables."]]},{heading:"Linking back to the analyses",paragraphs:[`Every value names its analysis, with version and Isabl id. Picking an analysis in the side menu's "Analyses on this page" highlights the tiles and cards it feeds.`]}]},copyNumber:{title:"Copy number",intro:"How many copies of each part of the genome the tumour carries, segment by segment, from chromosome 1 to X.",sections:[{heading:"What is drawn",paragraphs:['Each horizontal stroke is one segment: a stretch of the genome with a constant copy number. Its height is the number of copies, from 0 up to 8; anything higher is drawn at the top and the axis reads "8+". Alternating grey bands mark the chromosomes, named along the bottom.',`The dashed line is the baseline: the tumour's ploidy rounded to whole copies (labelled, for example, "2 copies"). Segments are coloured by how they compare with it.`],terms:[["Grey","Neutral: the same number of copies as the baseline."],["Orange","Gain: at least one copy more than the baseline."],["Dark orange","Amplification: three or more copies above the baseline."],["Blue","Loss: at least one copy fewer than the baseline."]]},{heading:"Total or allele-specific",paragraphs:["Total shows all copies together. Allele-specific, when the analysis provides it, splits each segment into its major allele (the more common parental copy, dark) and minor allele (light). Where the two are equal they are drawn slightly apart so both stay visible. A minor allele of 0 means one parent's copy is lost there (loss of heterozygosity)."]},{heading:"Driver genes",paragraphs:["Triangles along the top mark the genes with likely driver mutations, one per gene; hover for its protein changes."]},{heading:"Reading and moving around",terms:[["Hover a segment","Its call, copies (major + minor), coordinates and, when available, log2 ratio."],["Click a segment","Lists the mutations inside it in the Mutations card."],["Click a driver","Finds that gene in the Mutations card."],["Pinch, or Ctrl and scroll","Zooms around the pointer. Plain scrolling always scrolls the page."],["Drag","Pans a zoomed view."],["Double-click a chromosome","Zooms to fill the view with it; the axis then counts megabases."],["Slider and reset","The slider under the plot shows and moves the window; the button by the title returns to the whole genome."],["Hover a mutation in the table","Marks it here, with a ring on the segment it sits on and its copy number."]]},{heading:"Tumour-only reports",paragraphs:["Without a matched normal there is no ploidy estimate, so segments come from CNVkit and are called against two copies. Allele-specific copy numbers are not available."]}]},mutations:{title:"Mutations",intro:"The tumour's somatic SNVs and indels that passed the callers' filters: how they are distributed across cancer cells, and a searchable, filterable table of every call.",sections:[{heading:"Which mutations",terms:[["Drivers","Likely drivers flagged by the report: coding mutations that match OncoKB or COSMIC driver annotations (the exact protein change, or a damaging consequence in a known cancer gene), plus known hotspots the callers missed and the report recovered from the tumour's reads."],["Coding","Mutations whose effect changes a protein, by the report's list of coding effects."],["All","Every PASS SNV and indel."]],paragraphs:["The counts beside each choice follow the search and filters, so they always say what you would see."]},{heading:"FFPE samples",paragraphs:["Formalin-fixed (FFPE) tissue damages DNA in ways that look like mutations, mostly C>T changes at low allele fractions. For an FFPE sample, FFPERASE scores each SNV and indel for how likely it is to be such an artifact, and the report counts only the calls scored at or below its threshold (quoted beside the table). Its SNV, indel and coding totals and the TMB leave the rest out.",`The report marks each call it leaves out, and the dashboard follows that mark: the Coding and All counts, the table and the curve leave those calls out, and the card's subtitle says so. Drivers are all listed, as in the report, and any the filter would remove carry an "FFPE filtered" tag. "Show filtered calls", under FFPE filter beside the table, brings the removed calls back, tagged the same way.`]},{heading:"Cancer cell fraction and variant allele fraction",paragraphs:["The curve across the top is a smoothed histogram of every PASS mutation; driver mutations are labelled on it. Switch between the two measures:"],terms:[["CCF",'Cancer cell fraction: the estimated share of cancer cells carrying the mutation, corrected for purity and copy number. Around 1 (the "clonal" mark) means nearly every cancer cell has it, which suggests it arose early; clearly below 1 means a subclone. Estimates can land somewhat above 1. Shown from 0 to 2.'],["VAF","Variant allele fraction: the share of sequencing reads at the position that carry the mutation, from 0 to 1. Raw, not corrected for purity or copy number. Tumour-only reports open on VAF, since CCF needs a matched normal."]]},{heading:"Filtering by the curve",paragraphs:["Drag across the curve to keep only mutations in that CCF or VAF range; drivers outside it fade. The range appears with the other filters and can be removed there, or by clicking the curve."]},{heading:"The table",terms:[["Gene and position","The gene, and the mutation's chromosome and position (GRCh37)."],["Change","The protein change, with the cDNA change beneath."],["Effect","What the mutation does to the gene, from the VEP consequence (or the report's effect). Truncating effects are in bold."],["VAF and CCF bars","The value with a bar for quick comparison; the CCF bar's tick marks 1, clonal."],["Driver","Flagged as a likely driver (shown when the table is not already limited to drivers)."],["Hotspot","The exact protein change is a known recurrent cancer hotspot."],["In DMP","The same mutation was also found by the patient's clinical MSK-IMPACT (DMP) sequencing."],["FFPE filtered","FFPE samples only: the report's FFPE artifact filter leaves this call out of its counts (see FFPE samples)."]]},{heading:"Opening a row",terms:[["Variant","SNV or indel, with the reference and alternate bases."],["Reads","Reads supporting the mutation out of all reads at the position, when the caller reports them."],["Normal VAF","The mutation's allele fraction in the matched normal; near 0 for a somatic mutation."],["Mutant copies","How many copies of that part of the genome carry the mutation, out of all copies there."],["Consequence","The full VEP consequence."],["COSMIC","How many samples in COSMIC carry it, and how closely they match (exact change, same position, codon or gene)."],["Expression","The gene's expression in the tumour's RNA, in transcripts per million, when RNA was sequenced."],["Gene role","Whether the gene is a known oncogene or tumour suppressor gene (TSG)."],["Show on copy number","Zooms the Copy number card to the mutation's chromosome and marks it."]]},{heading:"Searching and filtering",paragraphs:["Search takes a gene, a protein or cDNA change, a COSMIC term, or a locus such as chr12:25,398,284 or a range such as chr8:1-50,000,000. Press / anywhere on the page to jump to it. Each filter's count is how many rows you would get by ticking it, given everything else."],terms:[["Missense","One amino acid replaced by another."],["Truncating","Stop gained or lost, start lost, or a frameshift."],["Splice","Changes a splice site or splice region."],["In-frame","Inserts or deletes amino acids without shifting the reading frame."],["Synonymous","Changes the DNA but not the amino acid."],["Other","Everything else, such as intronic, UTR or upstream changes."]]}]}},PC={summary:{BATTENBERG:"Tumour purity and ploidy, and the copy-number segments the ring's gains and losses are called from.","BATTENBERG cohort":"Project-wide Battenberg tables, which hold the FGA value and the cohort it is compared with.",CNV_UNMATCHED:"Copy-number segments of a tumour-only report (CNVkit), which the ring's gains and losses are called from.",MOSDEPTH:"The median sequencing coverage.",MSISENSOR:"The MSI score.",MSISENSOR_UNMATCHED:"The MSI score of a tumour-only report.",ANNOT_SNVS:"Somatic SNV calls: their count goes into TMB, and driver SNVs are marked on the ring.",ANNOT_INDELS:"Somatic indel calls: their count goes into TMB, and driver indels are marked on the ring.",ANNOT_SNVS_UNMATCHED:"Tumour-only SNV calls: their count goes into TMB, and driver SNVs are marked on the ring.",ANNOT_INDELS_UNMATCHED:"Tumour-only indel calls: their count goes into TMB, and driver indels are marked on the ring.",WGSPOST:"Cancer cell fractions of the mutations, read together with the driver calls marked on the ring."},copyNumber:{BATTENBERG:"Every segment drawn: total copies, major and minor allele copies, and the ploidy the baseline is rounded from.","BATTENBERG cohort":"Project-wide Battenberg tables the report reads alongside this run; they hold the FGA, and are not drawn here.",CNV_UNMATCHED:"The segments of a tumour-only report (CNVkit), drawn against two copies."},mutations:{ANNOT_SNVS:"The tumour's PASS somatic SNVs and their annotation: gene, protein and cDNA change, effect, VAF, read counts, normal VAF and COSMIC.",ANNOT_INDELS:"The tumour's PASS somatic indels and their annotation, as for SNVs.",ANNOT_SNVS_UNMATCHED:"Tumour-only SNV calls and their annotation.",ANNOT_INDELS_UNMATCHED:"Tumour-only indel calls and their annotation.",WGSPOST:"Each mutation's cancer cell fraction (CCF) and how many copies carry it.",BATTENBERG:"Ploidy, which fills in the copy count where WGSPOST has none, and purity, which gives a CCF to hotspots recovered from the tumour's reads.",FFPERASE_SNVS:"FFPE samples: each SNV's artifact score. Calls scoring above the report's threshold are left out of the counts.",FFPERASE_INDELS:"FFPE samples: each indel's artifact score. Calls scoring above the report's threshold are left out of the counts."}};function WC(l,i){const u=i.role==="cohort"||i.app.endsWith("Project Application"),s=i.app.replace(/ Project Application$/,""),c=PC[l];return(u?c[`${s} cohort`]:c[s])??(u?"A project-wide run the report reads for comparison with the cohort.":"An analysis the report reads to build this card.")}function eE({topic:l,lineage:i,subject:u,onClose:s}){const c=wd[l],f=O.useId(),h=O.useRef(null),m=i.filter(C=>C.role!=="cohort"&&!C.app.endsWith("Project Application")),v=i.filter(C=>!m.includes(C)),x=O.useRef(s);x.current=s,O.useEffect(()=>{var F;const C=document.activeElement;(F=h.current)==null||F.focus();const U=document.documentElement,q=U.style.overflow;U.style.overflow="hidden";const $=te=>{te.key==="Escape"&&x.current()};return document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$),U.style.overflow=q,C==null||C.focus()}},[]);const y=[...c.sections.map(C=>C.heading),"Sources"],S=y.map((C,U)=>`${f}-s${U}`),[b,N]=O.useState(0),j=O.useRef(null);O.useEffect(()=>{const C=j.current;if(!C)return;const U=()=>{const q=C.getBoundingClientRect().top+24;let $=0;S.forEach((F,te)=>{const k=document.getElementById(F);k&&k.getBoundingClientRect().top<=q&&($=te)}),C.scrollTop+C.clientHeight>=C.scrollHeight-4&&($=S.length-1),N($)};return U(),C.addEventListener("scroll",U,{passive:!0}),()=>C.removeEventListener("scroll",U)},[]);const D=C=>{var q;const U=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;(q=document.getElementById(S[C]))==null||q.scrollIntoView({behavior:U?"auto":"smooth",block:"start"})},w=C=>g.jsxs("li",{className:"info-source",children:[g.jsx("span",{className:`tb-dot ${Ki(C.app)}`,"aria-hidden":!0}),g.jsxs("span",{className:"info-source-text",children:[C.pk?g.jsxs("a",{className:"info-source-name info-source-link",href:Ky(C.pk),target:"_blank",rel:"noopener noreferrer",title:"Open this analysis in Isabl",children:[g.jsxs("span",{className:"mono",children:[C.app,C.version?` ${C.version}`:""]}),g.jsxs("span",{className:"mono info-source-pk",children:["#",C.pk]}),g.jsx(Lb,{size:13,"aria-hidden":!0,className:"info-source-arrow"})]}):g.jsxs("span",{className:"info-source-name",children:[g.jsxs("span",{className:"mono",children:[C.app,C.version?` ${C.version}`:""]}),C.project?g.jsxs("span",{className:"info-source-pk",children:["project ",C.project]}):null]}),g.jsx("span",{className:"info-source-role",children:WC(l,C)})]})]},wt(C));return N2.createPortal(g.jsx("div",{className:`info-backdrop ${Fn.theme}`,onMouseDown:C=>C.target===C.currentTarget&&s(),children:g.jsxs("div",{className:"info-dialog",role:"dialog","aria-modal":"true","aria-labelledby":f,children:[g.jsx("button",{ref:h,type:"button",className:"info-close","aria-label":"Close",onClick:s,children:g.jsx($d,{size:18,"aria-hidden":!0})}),g.jsxs("nav",{className:"info-rail","aria-label":"Contents",children:[g.jsx("span",{className:"info-kicker",children:u??"About"}),g.jsx("h2",{id:f,children:c.title}),g.jsx("ol",{children:y.map((C,U)=>g.jsx("li",{children:g.jsx("button",{type:"button","aria-current":U===b?"true":void 0,onClick:()=>D(U),children:C})},C))})]}),g.jsxs("div",{ref:j,className:"info-main",children:[g.jsx("p",{className:"info-intro",children:c.intro}),c.sections.map((C,U)=>{var q;return g.jsxs("section",{id:S[U],className:"info-section",children:[g.jsx("h3",{children:C.heading}),(q=C.paragraphs)==null?void 0:q.map($=>g.jsx("p",{children:$},$)),C.terms&&g.jsx("dl",{children:C.terms.map(([$,F])=>g.jsxs("div",{children:[g.jsx("dt",{children:$}),g.jsx("dd",{children:F})]},$))})]},C.heading)}),g.jsxs("section",{id:S[S.length-1],className:"info-section","aria-label":"Sources",children:[g.jsx("h3",{children:"Sources"}),g.jsx("p",{children:"The analyses this card reads, with their version and Isabl id, and what each one is responsible for."}),i.length===0&&g.jsx("p",{children:"No analyses recorded for this card."}),g.jsx("ul",{className:"info-sources",children:m.map(w)}),v.length>0&&g.jsxs(g.Fragment,{children:[g.jsx("h4",{children:"Cohort runs"}),g.jsx("ul",{className:"info-sources",children:v.map(w)})]})]})]})]})}),document.body)}function m0({topic:l,lineage:i,subject:u}){const[s,c]=O.useState(!1);return g.jsxs(g.Fragment,{children:[g.jsx("button",{type:"button",className:"sc-ib sm info-trigger","aria-label":`About ${wd[l].title.toLowerCase()}`,title:`About ${wd[l].title.toLowerCase()}`,"aria-haspopup":"dialog",onClick:()=>c(!0),children:g.jsx(Pb,{size:15,"aria-hidden":!0})}),s&&g.jsx(eE,{topic:l,lineage:i,subject:u,onClose:()=>c(!1)})]})}function tE({lineage:l,children:i}){const[u,s]=O.useState(!1),c=l.filter(h=>h.role!=="cohort"),f=l.filter(h=>h.role==="cohort");return g.jsxs("div",{className:"sc-cf",children:[i,i&&g.jsx("span",{className:"flex-auto"}),l.length>0&&g.jsx("span",{className:"text-xs",style:{color:"var(--muted)"},children:"Sources"}),c.map(h=>h.pk?g.jsxs("a",{className:"sc-src sc-src-link",href:Ky(h.pk),target:"_blank",rel:"noopener noreferrer",title:"Open this analysis in Isabl",children:[g.jsx("span",{className:`tb-dot ${Ki(h.app)}`,"aria-hidden":!0}),h.app," ",h.version??""," #",h.pk]},wt(h)):g.jsxs("span",{className:"sc-src",children:[g.jsx("span",{className:`tb-dot ${Ki(h.app)}`,"aria-hidden":!0}),h.app," ",h.version??""]},wt(h))),f.length>0&&g.jsxs("button",{type:"button",className:"sc-src",style:{border:0,cursor:"pointer"},"aria-expanded":u,onClick:()=>s(h=>!h),children:[u?"Hide":"+"," ",f.length," cohort ",f.length===1?"run":"runs"]}),u&&f.map(h=>g.jsxs("span",{className:"sc-src",children:[g.jsx("span",{className:"tb-dot fam-other","aria-hidden":!0}),h.app,h.project?`, project ${h.project}`:""," ",h.pk?`#${h.pk}`:""]},wt(h)))]})}function p0(...l){const i=new Map;for(const u of l.flat())u&&!i.has(wt(u))&&i.set(wt(u),u);return[...i.values()]}const v0=O.forwardRef(function({title:i,subtitle:u,controls:s,lineage:c,picked:f,footer:h,className:m="",info:v,children:x},y){const S=!!f&&c.some(b=>wt(b)===f);return g.jsxs("section",{ref:y,className:`sc-card flex flex-col ${m}`,"data-picked":S,"aria-label":i,children:[g.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2.5 px-5 pt-4 pb-1",children:[g.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[g.jsx("h2",{className:"m-0 text-base font-semibold",children:i}),u&&g.jsx("span",{className:"text-[13px]",style:{color:"var(--muted)"},children:u})]}),(s||v)&&g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s,v&&g.jsx(m0,{topic:v,lineage:c,subject:typeof u=="string"?u:void 0})]})]}),g.jsx("div",{className:"min-w-0 flex-auto",children:x}),(c.length>0||h)&&g.jsx(tE,{lineage:c,children:h})]})});function kd({label:l,envelope:i,loading:u,skeletonHeight:s=160,children:c}){return g.jsxs(g.Fragment,{children:[u&&!i&&g.jsx("div",{className:"px-5 py-3",children:g.jsx("div",{className:"skeleton",style:{height:s},"aria-label":`Loading ${l}`})}),i&&i.status!=="ok"&&g.jsx("div",{className:"px-5 py-4",children:g.jsx(_a,{envelope:i})}),(i==null?void 0:i.status)==="ok"&&i.data!==null&&c(i.data),(i==null?void 0:i.status)==="ok"&&i.warnings.length>0&&g.jsx("div",{className:"px-5 pb-1 text-xs",style:{color:"var(--warn-ink)"},children:i.warnings.join(" ")})]})}function nE({title:l,subtitle:i,controls:u,envelope:s,loading:c,picked:f,skeletonHeight:h=160,footer:m,className:v="",info:x,children:y}){return g.jsx(v0,{title:l,subtitle:i,controls:u,lineage:(s==null?void 0:s.lineage)??[],picked:f,footer:m,className:v,info:x,children:g.jsx(kd,{label:l,envelope:s,loading:c,skeletonHeight:h,children:y})})}function lE(l,i){const[u,s]=O.useState(null),[c,f]=O.useState(!1);return O.useLayoutEffect(()=>{const h=l.current;if(!h)return;const m=()=>{const x=h.querySelector('[aria-pressed="true"]');s(x?{x:x.offsetLeft,y:x.offsetTop,width:x.offsetWidth,height:x.offsetHeight}:null)};if(m(),typeof ResizeObserver>"u")return;const v=new ResizeObserver(m);v.observe(h);for(const x of Array.from(h.children))v.observe(x);return()=>v.disconnect()},[l,i]),O.useEffect(()=>{if(u&&!c){const h=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(h)}},[u,c]),{thumb:u,moving:c}}function nr({label:l,options:i,value:u,onChange:s,className:c=""}){const f=O.useRef(null),{thumb:h,moving:m}=lE(f,u);return g.jsxs("div",{ref:f,className:`sc-track ${c}`,role:"group","aria-label":l,children:[h&&g.jsx("span",{className:"sc-thumb","data-moving":m,"aria-hidden":!0,style:{width:h.width,height:h.height,transform:`translate(${h.x}px, ${h.y}px)`}}),i.map(v=>g.jsx("button",{type:"button",className:"sc-seg","aria-pressed":v.value===u,disabled:v.disabled,title:v.title,onClick:()=>s(v.value),children:v.label},v.value))]})}function aE(l){var u;const i=[];return l.mode==="unmatched"&&i.push("Tumour only"),l.individual.germline_consent&&i.push("Germline consented"),(u=l.individual.dmp_id)!=null&&u.startsWith("P-")&&i.push("DMP linked"),i}function iE({data:l,fingerprint:i,sampleId:u,onSample:s,onVersion:c}){const f=l.report;return g.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-10 gap-y-5",children:[g.jsx(EC,{data:l,sampleId:u,fingerprint:i,onSample:s}),g.jsxs("div",{className:"flex flex-col items-start gap-2.5 pt-1 lg:items-end",children:[g.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[g.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--muted)"},children:"Report version"}),g.jsx(nr,{label:"Report version",value:f.version,onChange:c,options:l.versions.map(h=>({value:h.version,label:h.version}))})]}),g.jsxs("span",{className:"mono text-[11.5px]",style:{color:"var(--muted)"},children:["WGTS_REPORT ",f.analysis?`run #${f.analysis}`:"run indexed by hand",f.built?`, built ${rC(f.built)}`:""]}),g.jsx("div",{className:"flex flex-wrap gap-2",children:aE(l).map(h=>g.jsx("span",{className:"sc-chip",children:h},h))})]})]})}const Rd=["purity","ploidy","coverage","tmb","msi","fga"];function uE({value:l}){const u=2*Math.PI*13,s=Math.min(Math.max(l,0),1);return g.jsxs("svg",{viewBox:"0 0 34 34",className:"kpi-glyph h-[34px] w-[34px]","aria-hidden":!0,children:[g.jsx("circle",{cx:"17",cy:"17",r:13,fill:"none",strokeWidth:"4",className:"kpi-track"}),g.jsx("circle",{cx:"17",cy:"17",r:13,fill:"none",strokeWidth:"4",strokeLinecap:"round",className:"kpi-fill",strokeDasharray:`${s*u} ${u}`,transform:"rotate(-90 17 17)"})]})}function ny({value:l,min:i,max:u,ticks:s,reference:c}){const f=h=>4+(Math.min(Math.max(h,i),u)-i)/(u-i)*64;return g.jsxs("svg",{viewBox:"0 0 72 20",className:"kpi-glyph h-[18px] w-[60px]","aria-hidden":!0,children:[g.jsx("line",{x1:"4",x2:"68",y1:"12",y2:"12",className:"kpi-track",strokeWidth:"2",strokeLinecap:"round"}),s.map(h=>g.jsx("line",{x1:f(h),x2:f(h),y1:h===c?5:9,y2:"15",className:"kpi-tick",strokeWidth:h===c?1.5:1},h)),g.jsx("circle",{cx:f(l),cy:"12",r:"4.5",className:"kpi-dot",strokeWidth:"2"})]})}function sE({metric:l}){const i=l.value;if(i===null)return null;switch(l.key){case"purity":case"fga":return g.jsx(uE,{value:i});case"ploidy":return g.jsx(ny,{value:i,min:1,max:6,ticks:[1,2,3,4,5,6],reference:2});case"tmb":return g.jsx(ny,{value:Math.log10(Math.max(i,.01)),min:-2,max:2,ticks:[-2,-1,0,1,2]});default:return null}}const oE={purity:"Share of tumour cells, 0 to 1",fga:"Share of the genome altered, 0 to 1",ploidy:"On a scale of 1 to 6 copies; the tall tick marks 2",tmb:"On a log scale from 0.01 to 100 mutations per Mb"};function rE({metric:l,picked:i}){const u=l.value===null&&!l.text,s=!!i&&l.sources.some(c=>wt(c)===i);return g.jsxs("div",{className:"kpi","data-picked":s,title:oE[l.key],children:[g.jsxs("span",{className:"kpi-top",children:[g.jsx("span",{className:"kpi-label",children:l.label}),g.jsx(sE,{metric:l})]}),g.jsx("span",{className:"kpi-value","data-empty":u,children:u?sC(l):uC(l)}),l.sources.length>0?g.jsx("span",{className:"flex flex-col gap-0.5",children:l.sources.map(c=>g.jsxs("span",{className:"kpi-src",children:[g.jsx("span",{className:`tb-dot ${Ki(c.app)}`,"aria-hidden":!0}),g.jsx("span",{className:"min-w-0",children:g0(c)})]},wt(c)))}):g.jsx("span",{className:"kpi-src",children:l.etl?`from ${l.etl}`:"no source"})]})}function cE({sampleLabel:l,fingerprint:i,metrics:u,picked:s,lineage:c=[]}){var h;const f=(((h=u==null?void 0:u.data)==null?void 0:h.metrics)??[]).filter(m=>Rd.includes(m.key));return g.jsxs("section",{className:"sc-card relative flex flex-wrap items-center gap-x-8 gap-y-5 px-6 py-5","aria-label":`Genome fingerprint and summary of ${l}`,children:[g.jsx("span",{className:"absolute top-3 right-3",children:g.jsx(m0,{topic:"summary",lineage:c,subject:l})}),g.jsx(er,{fingerprint:i,size:"hero",title:l.split(" ")[0],subtitle:"tumour",className:"h-[210px] w-[210px] max-w-full flex-none"}),g.jsxs("div",{className:"flex min-w-0 flex-[1_1_230px] flex-col gap-3",children:[g.jsxs("h2",{className:"m-0 text-lg font-semibold tracking-tight",children:["Genome fingerprint of ",l]}),g.jsx("p",{className:"m-0 max-w-[46ch] text-[14.5px] leading-relaxed",style:{color:"var(--ink-2)"},children:i?e0(i):"No copy-number data for this sample."}),g.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5 text-[12.5px]",style:{color:"var(--ink-2)"},children:[g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-[5px] w-3.5 rounded-[3px]",style:{background:"var(--gain)"}}),"Gains, outer track"]}),g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-[5px] w-3.5 rounded-[3px]",style:{background:"var(--loss)"}}),"Losses, inner track"]}),g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-3 w-[5px] rounded-sm",style:{background:"var(--ink)"}}),"Drivers"]})]}),g.jsx("span",{className:"text-[12.5px]",style:{color:"var(--muted)"},children:"Chromosome 1 starts at the top and the ring runs clockwise to X."})]}),g.jsxs("div",{className:"kpi-grid min-w-0 flex-[1.4_1_420px]",children:[u===void 0&&Rd.map(m=>g.jsx("div",{className:"kpi","aria-hidden":!0,children:g.jsx("div",{className:"skeleton h-[70px]"})},m)),u&&u.status!=="ok"&&g.jsx("div",{className:"col-span-full",children:g.jsx(_a,{envelope:u})}),f.map(m=>g.jsx(rE,{metric:m,picked:s},m.key))]})]})}function fE({sampleLabel:l,failures:i,analyses:u}){return i.length===0?null:g.jsx("div",{className:"flex flex-col gap-2.5",children:i.map(s=>{const c=u.filter(f=>f.modules.some(h=>h.etl===s.etl&&h.status==="failed"));return g.jsxs("div",{className:"sc-card flex flex-wrap items-center gap-x-4 gap-y-3 px-[18px] py-3.5",role:"status",children:[g.jsx("span",{className:"grid h-9 w-9 flex-none place-items-center rounded-[10px]",style:{background:"var(--warn-soft)",color:"var(--warn-ink)"},children:g.jsx(Py,{size:18,"aria-hidden":!0})}),g.jsxs("div",{className:"flex min-w-0 flex-[1_1_360px] flex-col gap-0.5",children:[g.jsxs("span",{className:"text-[14.5px] font-semibold",children:[s.label," failed for ",l]}),g.jsx("span",{className:"text-[13.5px]",style:{color:"var(--ink-2)"},children:s.message.split(`
|
|
252
|
-
`)[0]}),c.length>0&&g.jsxs("span",{className:"mono text-[11.5px]",style:{color:"var(--muted)"},children:["Reading ",c.map(g0).join(", ")]})]})]},`${s.etl}-${s.node}`)})})}function dE({onSignedIn:l}){const[i,u]=O.useState("password"),[s,c]=O.useState(""),[f,h]=O.useState(""),[m,v]=O.useState(""),[x,y]=O.useState(null),[S,b]=O.useState(!1),N=i==="password"?!!s&&!!f:!!m.trim();return g.jsxs("form",{className:"sc-card mx-auto mt-16 flex w-[380px] max-w-full flex-col gap-3 p-6",onSubmit:async j=>{j.preventDefault(),b(!0),y(null);try{i==="password"?await TC(s,f):await _C(m.trim()),l()}catch(D){y(D.message)}finally{b(!1)}},children:[g.jsx("h1",{className:"m-0 text-lg font-semibold",children:"Sign in to Isabl"}),g.jsx("p",{className:"m-0 text-sm",style:{color:"var(--ink-2)"},children:"The WGTS dashboard uses your Isabl account."}),i==="password"?g.jsxs(g.Fragment,{children:[g.jsxs("label",{className:"flex flex-col gap-1 text-[13px] font-semibold",htmlFor:"username",children:["Username",g.jsx("span",{className:"field",children:g.jsx("input",{id:"username",autoComplete:"username",value:s,onChange:j=>c(j.target.value)})})]}),g.jsxs("label",{className:"flex flex-col gap-1 text-[13px] font-semibold",htmlFor:"password",children:["Password",g.jsx("span",{className:"field",children:g.jsx("input",{id:"password",type:"password",autoComplete:"current-password",value:f,onChange:j=>h(j.target.value)})})]})]}):g.jsxs("label",{className:"flex flex-col gap-1 text-[13px] font-semibold",htmlFor:"token",children:["API token",g.jsx("span",{className:"field",children:g.jsx("input",{id:"token",type:"password",autoComplete:"off",spellCheck:!1,value:m,onChange:j=>v(j.target.value)})}),g.jsx("span",{className:"text-xs font-normal",style:{color:"var(--muted)"},children:"The token the Isabl CLI uses. Admins find it under Auth Token in Django admin."})]}),x&&g.jsx("p",{className:"m-0 text-sm",style:{color:"var(--warn-ink)"},role:"alert",children:x}),g.jsx("button",{type:"submit",className:"sc-btn sc-b1",disabled:S||!N,children:S?"Signing in":"Sign in"}),g.jsx("button",{type:"button",className:"self-start border-0 bg-transparent p-0 text-[13px] font-semibold",style:{color:"var(--link)",cursor:"pointer"},onClick:()=>{u(i==="password"?"token":"password"),y(null)},children:i==="password"?"Use an API token instead":"Use a username and password instead"})]})}const hE="modulepreload",gE=function(l){return"https://cdn.jsdelivr.net/npm/wgts-report@0.1.1/dist/"+l},ly={},mE=function(i,u,s){let c=Promise.resolve();if(u&&u.length>0){let h=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(S=>({status:"fulfilled",value:S}),S=>({status:"rejected",reason:S}))))};document.getElementsByTagName("link");const m=document.querySelector("meta[property=csp-nonce]"),v=(m==null?void 0:m.nonce)||(m==null?void 0:m.getAttribute("nonce"));c=h(u.map(x=>{if(x=gE(x),x in ly)return;ly[x]=!0;const y=x.endsWith(".css"),S=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${x}"]${S}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":hE,y||(b.as="script"),b.crossOrigin="",b.href=x,v&&b.setAttribute("nonce",v),document.head.appendChild(b),y)return new Promise((N,j)=>{b.addEventListener("load",N),b.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${x}`)))})}))}function f(h){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=h,window.dispatchEvent(m),!m.defaultPrevented)throw h}return c.then(h=>{for(const m of h||[])m.status==="rejected"&&f(m.reason);return i().catch(f)})},Ye={ink:"#18181b",ink2:"#52525b",muted:"#6e6e76",faint:"#71717a",card:"#ffffff",head:"#fafafb",line:"#e8e8ec",grid:"#f0f0f3",axis:"#d4d4d8",band:"#fafafb",cn2:"#dcdce1",guide:"#ececf0",gain:"#e8590c",gainStrong:"#c2410c",loss:"#1c7ed6",neutral:"#52525b",major:"#52525b",minor:"#a1a1aa",accent:"#6e5ad8",accentSoft:"#f3f1fd",ccfLine:"#6e5ad8",ccfFill:"#8e7fe6",dot:"#5a46c8",font:"Manrope, system-ui, sans-serif",mono:"JetBrains Mono, ui-monospace, monospace",reducedMotion:!1};function pE(l){if(!l||typeof getComputedStyle>"u")return Ye;const i=getComputedStyle(l),u=(s,c)=>i.getPropertyValue(s).trim()||c;return{ink:u("--ink",Ye.ink),ink2:u("--ink-2",Ye.ink2),muted:u("--muted",Ye.muted),faint:u("--faint",Ye.faint),card:u("--card",Ye.card),head:u("--head",Ye.head),line:u("--line",Ye.line),grid:u("--grid",Ye.grid),axis:u("--axis",Ye.axis),band:u("--band",Ye.band),cn2:u("--cn2",Ye.cn2),guide:u("--guide",Ye.guide),gain:u("--gain",Ye.gain),gainStrong:u("--gain-strong",Ye.gainStrong),loss:u("--loss",Ye.loss),neutral:u("--neutral",Ye.neutral),major:u("--ink-2",Ye.major),minor:u("--chev",Ye.minor),accent:u("--focus",Ye.accent),accentSoft:u("--hi-soft",Ye.accentSoft),ccfLine:u("--ccf-line",Ye.ccfLine),ccfFill:u("--ccf-fill",Ye.ccfFill),dot:u("--dot",Ye.dot),font:u("--font",Ye.font),mono:u("--mono",Ye.mono),reducedMotion:typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}}function y0(l){return{confine:!0,backgroundColor:l.card,borderColor:l.line,borderWidth:1,padding:[10,12],textStyle:{color:l.ink,fontFamily:l.font,fontSize:12.5},extraCssText:"border-radius: 12px; box-shadow: 0 12px 32px -12px rgba(16,16,20,0.28);"}}function zi(l,i){const u=l.replace("#","");if(u.length!==6)return l;const[s,c,f]=[0,2,4].map(h=>parseInt(u.slice(h,h+2),16));return`rgba(${s}, ${c}, ${f}, ${i})`}const S0=()=>mE(()=>import("./EChart-BmUw3Vgc.js"),[]),vE=O.lazy(S0);function yE(){S0()}function x0(l){return g.jsx(O.Suspense,{fallback:g.jsx("div",{className:"skeleton",style:{height:l.height},"aria-hidden":!0}),children:g.jsx(vE,{...l})})}function b0(){const l=O.useRef(null),[i,u]=O.useState(null);return O.useLayoutEffect(()=>u(pE(l.current)),[]),[l,i]}function C0({top:l,distance:i=5,gap:u=6,rowGap:s=3}={}){let c=[],f=-1;return h=>{h.dataIndex<=f&&(c=[]),f=h.dataIndex;const{labelRect:m,rect:v}=h;let x=c.findIndex(j=>j+u<=m.x);x===-1&&(x=c.push(0)-1),c[x]=m.x+m.width;const y=m.height+s,S=l===void 0?v.y-i-m.height-x*y:l+x*y,b=m.x+m.width/2,N=S+m.height+2;return{y:S,align:"center",verticalAlign:"top",labelLinePoints:[[b,N],[b,Math.max(N,v.y-3)]]}}}const mt=1e3,E0=.35,SE=8,_d=.1;function Zo(l,i){return(Xo(l,i)??0)*mt}function Il(l){const[i,u]=Wo[l.replace(/^chr/,"")];return[i*mt,u*mt]}function xE(l,i,u){const[s,c]=l,f=Math.min(mt,Math.max(E0,(c-s)*u)),h=Math.min(Math.max(i-(i-s)/(c-s)*f,0),mt-f);return[h,h+f]}function bE(l,i){const u=l[1]-l[0],s=Math.min(Math.max(l[0]+i,0),mt-u);return[s,s+u]}function CE(l){for(const[i]of Gn){const[u,s]=Il(i);if(l>=u&&l<=s)return i}return null}function w0(l,i){const u=l.segments.flatMap(c=>i==="total"?[c.total_cn]:[c.major_cn,c.minor_cn]),s=Math.max(...u.map(c=>c??0));return Math.min(SE,Math.max(l.baseline+2,Math.ceil(s)))}function EE(l){const i=10**Math.floor(Math.log10(l)),u=l/i;return(u<1.5?1:u<3.5?2:u<7.5?5:10)*i}function R0(l,i,u=5){const s=Gn.filter(([b])=>{const[N,j]=Il(b);return j>l&&N<i});if(s.length!==1)return s.map(([b])=>{const[N,j]=Il(b);return{value:(N+j)/2,label:b}});const[c,f]=s[0],[h,m]=Il(c),v=(Math.max(l,h)-h)/(m-h)*f,x=(Math.min(i,m)-h)/(m-h)*f,y=EE(Math.max(x-v,1)/u),S=[];for(let b=Math.ceil(v/y)*y;b<=x;b+=y)S.push({value:h+b/f*(m-h),label:Wu(b,y)});return S}function _0(l,i){const u=new Map(l.map(s=>[s.value,s.label]));return{customValues:l.map(s=>s.value),formatter:s=>u.get(s)??"",hideOverlap:!0,color:i.faint,fontFamily:i.mono,fontSize:10.5,margin:10}}function wE(l,i){if(l<=.5&&i>=mt-.5)return null;const u=Iv(l/mt,"start"),s=Iv(i/mt,"end");if(u.chrom===s.chrom){const c=(s.pos-u.pos)/10;return`chr${u.chrom}: ${Wu(u.pos,c).replace(" Mb","")}–${Wu(s.pos,c)}`}return`chr${u.chrom}:${Wu(u.pos,1e6)} – chr${s.chrom}:${Wu(s.pos,1e6)}`}const RE={neutral:"Neutral",gain:"Gain",amp:"Amplification",loss:"Loss"},ay=["neutral","gain","amp","loss"];function _E(l,i){const u=`chr${l.chrom}:${l.start.toLocaleString("en-US")}–${l.end.toLocaleString("en-US")}`,s=l.major_cn!==null&&l.minor_cn!==null?` (${l.major_cn} + ${l.minor_cn})`:"",c=l.log2!==null?`, log2 ratio ${l.log2.toFixed(2)}`:"";return`<span style="font-weight:600">${RE[l.call??"neutral"]}</span>, ${l.total_cn??"?"} copies${s}<div style="font-family:var(--mono);font-size:11.5px;margin-top:3px">${u}${c}</div><div style="opacity:.7;font-size:11.5px;margin-top:5px">${i}</div>`}function TE(l){const i=new Map;for(const u of l){const s=u.gene??"?",c=i.get(s)??{gene:s,x:Zo(u.chrom,u.pos),changes:[]};u.protein_change&&c.changes.push(u.protein_change),i.set(s,c)}return[...i.values()].map(u=>({...u,changes:u.changes.join(", ")})).sort((u,s)=>u.x-s.x)}function NE(l,i,u,s=[]){const c=w0(l,i),f=l.segments.some(y=>Math.max(y.total_cn??0,y.major_cn??0)>c),h={neutral:u.minor,gain:u.gain,amp:u.gainStrong,loss:u.loss},m=(y,S=0)=>l.segments.flatMap((b,N)=>{const j=y(b);if(j===null)return[];const D=ay.indexOf(b.call??"neutral");return[[Zo(b.chrom,b.start),Zo(b.chrom,b.end),Math.min(j,c)+S,D,N]]}),v=(y,S,b,N)=>({type:"custom",id:y,name:S,data:b,encode:{x:[0,1],y:2},clip:!0,z:6,renderItem:(j,D)=>{const w=D.coord([D.value(0),D.value(2)]),C=D.coord([D.value(1),D.value(2)]),U=ay[D.value(3)],q=Math.max(C[0]-w[0],U==="neutral"?2:7),$={x1:w[0],y1:w[1],x2:w[0]+q,y2:w[1]};return{type:"group",children:[{type:"line",shape:$,style:{stroke:"rgba(0,0,0,0)",lineWidth:16}},{type:"line",shape:$,style:{stroke:N??h[U],lineWidth:5,lineCap:"round"},emphasis:{style:{lineWidth:8}}}]}},tooltip:{formatter:j=>_E(l.segments[j.data[4]],"Click to list the mutations in this segment")}}),x=[{id:"bands",type:"line",data:[[0,0]],symbol:"none",silent:!0,lineStyle:{opacity:0},markArea:{silent:!0,data:Gn.filter((y,S)=>S%2===0).map(([y])=>[{xAxis:Il(y)[0],itemStyle:{color:u.band}},{xAxis:Il(y)[1]}])},markLine:{silent:!0,symbol:"none",animation:!1,lineStyle:{color:u.axis,type:[5,4],width:1.25},label:{show:!0,position:"insideStartTop",formatter:`${l.baseline} copies`,color:u.faint,fontSize:10.5},data:[{yAxis:l.baseline}]}}];return i==="total"?x.push(v("cn-total","Copy number",m(y=>y.total_cn))):(x.push(v("cn-major","Major allele",m(y=>y.major_cn,_d),u.major)),x.push(v("cn-minor","Minor allele",m(y=>y.minor_cn,-_d),u.minor))),x.push({id:"drivers",type:"scatter",name:"Drivers",data:TE(s).map(y=>({value:[y.x,c],name:y.gene,protein:y.changes})),symbol:"triangle",symbolRotate:180,symbolSize:9,symbolOffset:[0,-11],itemStyle:{opacity:1,color:u.ink},cursor:"pointer",label:{show:!0,formatter:"{b}",position:"top",distance:3,color:u.ink2,fontSize:10.5,fontWeight:600,fontStyle:"italic"},labelLine:{show:!0,lineStyle:{color:u.axis,width:1}},labelLayout:C0({distance:3,rowGap:1}),emphasis:{scale:1.4},tooltip:{formatter:y=>`<span style="font-weight:600"><i>${y.name}</i></span> ${y.data.protein}<div style="opacity:.7;font-size:11.5px;margin-top:5px">Driver. Click to find it in the table</div>`},z:7}),x.push({id:"focus",type:"scatter",data:[],silent:!0,animation:!1,symbolSize:12,itemStyle:{opacity:1,color:u.card,borderColor:u.ink,borderWidth:2.5},label:{show:!0,position:"right",distance:8,color:u.ink,backgroundColor:u.card,borderColor:u.line,borderWidth:1,borderRadius:6,padding:[3,6],rich:{gene:{fontWeight:600,fontStyle:"italic",fontSize:11.5,color:u.ink},copies:{fontSize:11.5,color:u.muted,padding:[0,0,0,4]}}},markLine:{silent:!0,symbol:"none",animation:!1,lineStyle:{color:u.ink,type:"solid",width:1.25,opacity:.4},label:{show:!1},data:[]},z:8}),{animation:!u.reducedMotion,animationDuration:450,textStyle:{fontFamily:u.font},grid:{left:34,right:16,top:s.length?46:16,bottom:54},xAxis:{type:"value",min:0,max:mt,axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!1},axisLabel:_0(R0(0,mt),u)},yAxis:{type:"value",min:0,max:c,interval:1,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:u.faint,fontFamily:u.mono,fontSize:11,formatter:y=>y===c&&f?`${y}+`:`${y}`},splitLine:{lineStyle:{color:u.grid}}},tooltip:{trigger:"item",...y0(u)},dataZoom:[{type:"slider",xAxisIndex:0,filterMode:"none",height:10,bottom:6,borderColor:"transparent",backgroundColor:u.grid,fillerColor:zi(u.accent,.16),dataBackground:{lineStyle:{opacity:0},areaStyle:{opacity:0}},selectedDataBackground:{lineStyle:{opacity:0},areaStyle:{opacity:0}},handleIcon:"path://M2,0 h2 a2,2 0 0 1 2,2 v12 a2,2 0 0 1 -2,2 h-2 a2,2 0 0 1 -2,-2 v-12 a2,2 0 0 1 2,-2 z",handleSize:"140%",handleStyle:{color:u.card,borderColor:u.axis,borderWidth:1},moveHandleSize:0,showDetail:!1,brushSelect:!1,minValueSpan:E0}],series:x}}function ME(l,i,u){const s=i.replace(/^chr/,"");return l.segments.find(c=>c.chrom===s&&c.start<=u&&u<=c.end)}function OE(l,i,u){if(!l)return{series:[{id:"focus",data:[],markLine:{data:[]}}]};const s=w0(i,u),c=ME(i,l.chrom,l.pos),f=c?u==="total"?c.total_cn:c.major_cn:null,h=Zo(l.chrom,l.pos),m=Math.min(f??i.baseline,s)+(u==="allele"&&f!==null?_d:0),v=(c==null?void 0:c.total_cn)!==null&&(c==null?void 0:c.total_cn)!==void 0?`{copies|${c.total_cn} copies}`:"";return{series:[{id:"focus",data:[{value:[h,m],label:{formatter:`{gene|${l.gene??"?"}}${v}`}}],markLine:{data:[[{coord:[h,0]},{coord:[h,s]}]]}}]}}function Di(l,[i,u]){l==null||l.dispatchAction({type:"dataZoom",startValue:i,endValue:u})}function jE(l){var u;const i=((u=l.batch)==null?void 0:u[0])??l;return i.startValue!==void 0&&i.endValue!==void 0?[i.startValue,i.endValue]:i.start!==void 0&&i.end!==void 0?[i.start/100*mt,i.end/100*mt]:null}function AE({data:l,mode:i,drivers:u,focus:s,locate:c,chartRef:f,onWindow:h,onSegment:m,onGene:v}){const[x,y]=b0(),S=O.useRef([0,mt]),b=O.useMemo(()=>y?NE(l,i,y,u):null,[l,i,y,u]),N=O.useMemo(()=>OE(s,l,i),[s,l,i]),j=O.useMemo(()=>({datazoom:C=>{const U=jE(C),q=f.current;if(!U||!q||!y)return;S.current=U;const $=R0(...U,Math.max(2,Math.round(q.getWidth()/150)));q.setOption({xAxis:{axisLabel:_0($,y)}},{lazyUpdate:!0}),h(U)},click:C=>{var U;C.seriesId==="drivers"&&C.name?v(C.name):(U=C.seriesId)!=null&&U.startsWith("cn-")&&m(l.segments[C.data[4]])}}),[f,y,l,h,m,v]),D=O.useCallback(C=>{f.current=C;const U=C.getZr(),q=C.getDom(),$=I=>C.containPixel({gridIndex:0},I),F=I=>C.convertFromPixel({gridIndex:0},I)[0],te=I=>{const je=[I.offsetX,I.offsetY];if(!$(je))return;const ut=CE(F(je));ut&&Di(C,Il(ut))},k=I=>{if(!I.ctrlKey)return;const je=q.getBoundingClientRect(),ut=[I.clientX-je.left,I.clientY-je.top];if(!$(ut))return;I.preventDefault();const ke=Math.max(-50,Math.min(50,I.deltaY));Di(C,xE(S.current,F(ut),Math.exp(ke*.01)))};let Z=null;const de=I=>{Z=S.current[1]-S.current[0]<mt-.5&&$([I.offsetX,I.offsetY])?{pixel:I.offsetX,view:S.current}:null},ge=I=>{if(!Z)return;const je=F([I.offsetX,0])-F([Z.pixel,0]);Di(C,bE(Z.view,-je))},xe=()=>{Z=null};return U.on("dblclick",te),U.on("mousedown",de),U.on("mousemove",ge),U.on("mouseup",xe),U.on("globalout",xe),q.addEventListener("wheel",k,{passive:!1}),()=>{U.off("dblclick",te),U.off("mousedown",de),U.off("mousemove",ge),U.off("mouseup",xe),U.off("globalout",xe),q.removeEventListener("wheel",k),f.current=null}},[f]),w=O.useCallback(C=>{const[U,q]=S.current;(U>0||q<mt)&&Di(C,[U,q])},[]);return O.useEffect(()=>{c&&Di(f.current,Il(c.chrom))},[c,f]),g.jsx("div",{ref:x,className:"px-2 pt-1",children:b&&g.jsx(x0,{option:b,overlay:N,height:268,ariaLabel:`Copy number of ${l.sample} across the genome, against ${l.baseline} copies.`,onEvents:j,onReady:D,onDrawn:w})})}function Ju({color:l,label:i}){return g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-1 w-3.5 rounded-sm",style:{background:l}}),i]})}function zE({envelope:l,loading:i,picked:u,sampleLabel:s,drivers:c,focus:f,locate:h,onSegment:m,onGene:v}){var w;const[x,y]=O.useState("total"),[S,b]=O.useState([0,mt]),N=O.useRef(null),j=((w=l==null?void 0:l.data)==null?void 0:w.allele_specific)??!1,D=wE(...S);return g.jsx(nE,{title:"Copy number",subtitle:`Copy number across the genome, ${s}`,info:"copyNumber",envelope:l,loading:i,picked:u,skeletonHeight:250,controls:g.jsxs(g.Fragment,{children:[D&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"mono text-xs",style:{color:"var(--ink-2)"},"aria-live":"polite",children:D}),g.jsx("button",{type:"button",className:"sc-ib sm","aria-label":"Show the whole genome",title:"Show the whole genome",onClick:()=>Di(N.current,[0,mt]),children:g.jsx(iC,{size:15,"aria-hidden":!0})})]}),g.jsx(nr,{label:"Copy number view",value:j?x:"total",onChange:y,options:[{value:"total",label:"Total"},{value:"allele",label:"Allele-specific",disabled:!j}]})]}),footer:g.jsxs("span",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[12.5px]",style:{color:"var(--ink-2)"},children:[x==="total"||!j?g.jsxs(g.Fragment,{children:[g.jsx(Ju,{color:"var(--gain)",label:"Gain"}),g.jsx(Ju,{color:"var(--gain-strong)",label:"Amplification"}),g.jsx(Ju,{color:"var(--loss)",label:"Loss"})]}):g.jsxs(g.Fragment,{children:[g.jsx(Ju,{color:"var(--ink-2)",label:"Major allele"}),g.jsx(Ju,{color:"var(--chev)",label:"Minor allele"})]}),g.jsx("span",{style:{color:"var(--faint)"},children:"Pinch or Ctrl-scroll to zoom, drag to pan. Double-click a chromosome to fill the view."})]}),children:C=>g.jsx(AE,{data:C,mode:j?x:"total",drivers:c,focus:f,locate:h,chartRef:N,onWindow:b,onSegment:m,onGene:v})})}function T0(l){const[i,u]=l.range;return[[i,0],...l.bins.map(s=>[(s.x0+s.x1)/2,s.n]),[u,0]]}function N0(l,i){for(let u=1;u<l.length;u++){const[s,c]=l[u-1],[f,h]=l[u];if(i<=f)return f===s?h:c+(i-s)/(f-s)*(h-c)}return l[l.length-1][1]}function M0(l){return l==="ccf"?"CCF":"VAF"}function Td(l,i){return Math.min(Math.max(i,l.range[0]),l.range[1])}const DE=1;function UE(l,i){const u=T0(l),s=M0(l.measure);return{animation:!i.reducedMotion,animationDuration:650,animationEasing:"cubicOut",textStyle:{fontFamily:i.font},grid:{left:16,right:22,top:44,bottom:40},xAxis:{type:"value",min:l.range[0],max:l.range[1],interval:l.measure==="ccf"?.25:.1,axisLine:{lineStyle:{color:i.axis}},axisTick:{show:!1},axisLabel:{color:i.faint,fontFamily:i.mono,fontSize:10.5,lineHeight:14,formatter:c=>l.measure==="ccf"?c===1?`1.0
|
|
251
|
+
*/const iC=He("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function uC(l){if(l.value===null)return l.text??"";switch(l.key){case"coverage":return`${Math.round(l.value)}×`;case"tmb":return l.value<.01?l.value.toPrecision(2):l.value.toFixed(2);default:return l.value.toFixed(2)}}function sC(l){return l.status==="failed"?"Failed":l.status==="skipped"?"Not in this mode":"Not run"}const oC=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",year:"numeric"});function rC(l){if(!l)return"";const i=new Date(l);return Number.isNaN(i.getTime())?"":oC.format(i)}function Qd(l,i){return l.startsWith(`${i}_`)?l.slice(i.length+1):l}function bd(l){return l==null?"–":l.toFixed(2)}const Zv={missense_variant:"Missense",stop_gained:"Nonsense",stop_lost:"Stop lost",start_lost:"Start lost",frameshift_variant:"Frameshift",inframe_deletion:"In-frame deletion",inframe_insertion:"In-frame insertion",splice_acceptor_variant:"Splice acceptor",splice_donor_variant:"Splice donor",splice_region_variant:"Splice region",synonymous_variant:"Synonymous",intron_variant:"Intronic",upstream_gene_variant:"Upstream",downstream_gene_variant:"Downstream","5_prime_UTR_variant":"5′ UTR","3_prime_UTR_variant":"3′ UTR"};function cC(l,i){const u=(l??i??"").split("&")[0];if(!u)return"–";if(Zv[u])return Zv[u];const s=u.replace(/_/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}function fC(l,i){return`chr${l}:${i.toLocaleString("en-US")}`}const Gn=[["1",249250621],["2",243199373],["3",198022430],["4",191154276],["5",180915260],["6",171115067],["7",159138663],["8",146364022],["9",141213431],["10",135534747],["11",135006516],["12",133851895],["13",115169878],["14",107349540],["15",102531392],["16",90354753],["17",81195210],["18",78077248],["19",59128983],["20",63025520],["21",48129895],["22",51304566],["X",155270560]],Cd=.0025,dC=Gn.reduce((l,[,i])=>l+i,0),hC=1-Cd*Gn.length,Wo=(()=>{const l={};let i=Cd/2;for(const[u,s]of Gn){const c=s/dC*hC;l[u]=[i,i+c],i+=c+Cd}return l})(),Kv=Object.fromEntries(Gn);function Xo(l,i){const u=l.replace(/^chr/,""),s=Wo[u];if(!s)return null;const c=Math.min(Math.max(i,0),Kv[u]);return s[0]+c/Kv[u]*(s[1]-s[0])}function Jv(l,i,u,s){const c=s*2*Math.PI-Math.PI/2;return[l+u*Math.cos(c),i+u*Math.sin(c)]}function Qf(l,i,u,s,c){const[f,h]=Jv(l,i,u,s),[m,v]=Jv(l,i,u,c),x=c-s>.5?1:0;return`M${f.toFixed(2)},${h.toFixed(2)} A${u},${u} 0 ${x} 1 ${m.toFixed(2)},${v.toFixed(2)}`}function Iv(l,i="start"){let u=null;for(const f of Gn){const[h,m]=f,[v,x]=Wo[h];if(l<v&&i==="end"&&u)return{chrom:u[0],pos:u[1]};if(l<=x)return{chrom:h,pos:Math.round(Math.max(0,(l-v)/(x-v))*m)};u=f}const[s,c]=Gn[Gn.length-1];return{chrom:s,pos:c}}function Wu(l,i){const u=i>=1e6?0:i>=1e5?1:2;return`${(l/1e6).toFixed(u)} Mb`}const gC={hero:{box:220,ring:78,ringW:10,gain:93,gainW:7,amp:94,ampW:13,loss:63,lossW:7,drv:50,drvW:9},switcher:{box:48,ring:16,ringW:4.5,gain:21,gainW:3,amp:21,ampW:4.5,loss:11,lossW:3,drv:0,drvW:0},mini:{box:20,ring:7,ringW:2.6,gain:7,gainW:2.6,amp:7,ampW:2.6,loss:7,lossW:2.6,drv:0,drvW:0}},Pv=.004,Wv=.003;function mC(l,i,u){const s=Xo(l,i),c=Xo(l,u);return s===null||c===null?null:c-s<Pv?[s,s+Pv]:[s,c]}function Yf(l){return l.length<=1?l[0]??"":`${l.slice(0,-1).join(", ")} and ${l[l.length-1]}`}function pC(l,i,u){return l===1?`one ${i}`:`${l} ${u}`}function e0(l){const u=[["amp","amplification","amplifications"],["gain","gain","gains"],["loss","loss","losses"]].flatMap(([h,m,v])=>{const x=l.events.filter(j=>j.kind===h);if(x.length===0)return[];const y=[...new Set(x.map(j=>j.chrom))],S=y.length>6?[...y.slice(0,6),`${y.length-6} more`]:y,b=y.length===1?`chromosome ${y[0]}`:`chromosomes ${Yf(S)}`,N=h==="amp"&&x.length===1&&x[0].total_cn!==null?` (${Math.round(x[0].total_cn)} copies)`:"";return[`${pC(x.length,m,v)} on ${b}${N}`]}),s=u.length?Yf(u):`no copy-number changes against ${l.baseline} copies`,c=[...new Set(l.drivers.map(h=>h.gene).filter(h=>!!h))].sort(),f=c.length?`Drivers in ${Yf(c)}.`:"No drivers.";return`${s.charAt(0).toUpperCase()}${s.slice(1)}. ${f}`}function er({fingerprint:l,size:i,title:u,subtitle:s,className:c}){const f=gC[i],h=f.box/2,m=(l==null?void 0:l.events)??[],v=(l==null?void 0:l.drivers)??[],x=l?`Genome fingerprint: ${e0(l)}`:"No copy-number data";return g.jsxs("svg",{viewBox:`0 0 ${f.box} ${f.box}`,role:i==="mini"?void 0:"img","aria-label":i==="mini"?void 0:x,"aria-hidden":i==="mini"?!0:void 0,className:c,children:[g.jsxs("g",{fill:"none",strokeLinecap:"butt",children:[Object.entries(Wo).map(([y,[S,b]])=>g.jsx("path",{className:"r-neu",strokeWidth:f.ringW,d:Qf(h,h,f.ring,S,b)},y)),m.map((y,S)=>{const b=mC(y.chrom,y.start,y.end);if(!b)return null;const N=y.kind==="loss"?f.loss:y.kind==="amp"?f.amp:f.gain,j=y.kind==="loss"?f.lossW:y.kind==="amp"?f.ampW:f.gainW;return g.jsx("path",{className:`r-${y.kind}`,strokeWidth:j,d:Qf(h,h,N,b[0],b[1])},`${y.chrom}-${y.start}-${S}`)}),f.drvW>0&&v.map((y,S)=>{const b=Xo(y.chrom,y.pos);return b===null?null:g.jsx("path",{className:"r-drv",strokeWidth:f.drvW,d:Qf(h,h,f.drv,b-Wv/2,b+Wv/2)},`${y.gene}-${y.pos}-${S}`)})]}),i==="hero"&&u&&g.jsxs(g.Fragment,{children:[g.jsx("text",{className:"t-ink",x:h,y:h-2,textAnchor:"middle",fontSize:"24",fontWeight:"800",children:u}),s&&g.jsx("text",{className:"t-faint",x:h,y:h+18,textAnchor:"middle",fontSize:"12",fontWeight:"600",children:s})]})]})}const vC={"DNA|WG":{label:"WGS",icon:Io},"RNA|WT":{label:"RNA",icon:Bb}};function ey({children:l}){return g.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:l})}function yC({sex:l}){const i=l==null?void 0:l.toUpperCase();return i==="MALE"?g.jsxs(ey,{children:[g.jsx("circle",{cx:"12",cy:"9",r:"4.5"}),g.jsx("path",{d:"M7.6 8.2c.5-2.9 2.4-4.7 4.6-4.7 2.6 0 4.4 1.7 4.4 4.3-2.2.1-4.2-.6-5.6-2.1"}),g.jsx("path",{d:"M3.5 21a8.5 7.5 0 0 1 17 0"}),g.jsx("path",{d:"m10 15.6 2 2.2 2-2.2"})]}):i==="FEMALE"?g.jsxs(ey,{children:[g.jsx("circle",{cx:"12",cy:"9.2",r:"3.4"}),g.jsx("path",{d:"M6.3 14.2C4.6 9 6.6 2.8 12 2.8s7.4 6.2 5.7 11.4"}),g.jsx("path",{d:"M5 21.2a7 6.3 0 0 1 14 0"})]}):g.jsx(Wy,{size:16,"aria-hidden":!0})}const t0="wgts-patient-root";function SC(l,i){const u=l.getBoundingClientRect(),s=l.closest(".topbar"),c=s==null?void 0:s.parentElement,f=s&&c?c.getBoundingClientRect().top-s.getBoundingClientRect().top:0;return{x:u.left-i.left+u.width/2,y:u.top+f-i.top+u.height/2}}const n0=8;function kf(l,i,u,s){const c=u>=l.x?1:-1,f=Math.min(n0,Math.abs(u-l.x)/2,(i-l.y-14)/2);return[`M${l.x},${l.y+14}`,`V${i-f}`,`Q${l.x},${i} ${l.x+c*f},${i}`,`H${u-c*f}`,`Q${u},${i} ${u},${i+f}`,`V${s}`].join(" ")}function xC(l,i,u){const s=u.x>i.x?1:-1,c=Math.min(n0,Math.abs(u.x-i.x)/2,(i.top-l)/2);return[`M${i.x},${i.top}`,`V${l+c}`,`Q${i.x},${l} ${i.x+s*c},${l}`,`H${u.x-s*c}`,`Q${u.x},${l} ${u.x},${l+c}`,`V${u.top}`].join(" ")}function bC(l,i,u){const s=i.left+i.width/2,c=u.left+u.width/2,f=l-7,m=(l-31-.25*f)/.75;return`M${s},${f} C${s},${m} ${c},${m} ${c},${f}`}function CC(l,i){var s,c;const u=l.samples.find(f=>f.id===i);for(const f of(u==null?void 0:u.experiments)??[]){const h=(s=l.experiments[f])==null?void 0:s.normal,m=h?(c=l.experiments[h])==null?void 0:c.sample:void 0;if(m&&m!==i)return m}return null}function EC({data:l,sampleId:i,fingerprint:u,onSample:s}){const c=O.useRef(null),[f,h]=O.useState(null),[m,v]=O.useState(!1);O.useEffect(()=>{if(!f||m)return;const C=requestAnimationFrame(()=>v(!0));return()=>cancelAnimationFrame(C)},[f,m]);const x=new Set(l.failures.map(C=>C.sample)),y=O.useRef(i),[S,b]=O.useState(null);O.useEffect(()=>{if(y.current===i)return;const C=y.current;y.current=i,b(U=>({from:C,to:i,n:((U==null?void 0:U.n)??0)+1}))},[i]);const N=CC(l,i);O.useLayoutEffect(()=>{const C=c.current;if(!C)return;const U=()=>{const $=C.getBoundingClientRect(),F=document.getElementById(t0);if(!F)return;const te=Array.from(C.querySelectorAll("[data-sample]")).map(de=>{const ge=de.getBoundingClientRect();return{id:de.dataset.sample,x:ge.left-$.left+22,left:ge.left-$.left,width:ge.width,top:ge.top-$.top,bottom:ge.bottom-$.top}}),k=SC(F,$),Z=Math.min(...te.map(de=>de.top));h({root:k,trunk:Z-12,tabs:te})};if(U(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(U);return q.observe(C),()=>q.disconnect()},[l,i]);const j=f==null?void 0:f.tabs.find(C=>C.id===i),D=N?f==null?void 0:f.tabs.find(C=>C.id===N):void 0,w=S?f==null?void 0:f.tabs.find(C=>C.id===S.from):void 0;return g.jsxs("div",{ref:c,className:"ltabs",children:[f&&g.jsxs("svg",{className:"ltabs-links","aria-hidden":!0,children:[f.tabs.map(C=>g.jsx("path",{d:kf(f.root,f.trunk,C.x,C.top)},C.id)),j&&g.jsxs(g.Fragment,{children:[g.jsx("path",{className:"ltabs-haze","data-moving":m,style:{d:`path("${kf(f.root,f.trunk,j.x,j.top)}")`}}),g.jsx("path",{className:"ltabs-on","data-moving":m,style:{d:`path("${kf(f.root,f.trunk,j.x,j.top)}")`}}),w&&S&&S.to===j.id&&g.jsx("path",{className:"ltabs-bead",pathLength:1,d:xC(f.trunk,w,j)},`bead-${S.n}`)]}),j&&D&&g.jsxs("g",{className:"ltabs-match",children:[g.jsx("path",{d:bC(f.trunk,j,D)}),g.jsx("text",{x:(j.left+j.width/2+D.left+D.width/2)/2,y:f.trunk-27,children:"matched normal"})]})]}),j&&g.jsx("span",{className:"ltabs-thumb","data-moving":m,"aria-hidden":!0,style:{width:j.width,height:j.bottom-j.top,transform:`translate(${j.left}px, ${j.top}px)`}}),g.jsx("div",{className:"ltabs-row",role:"tablist","aria-label":"Samples",children:l.samples.map(C=>{const U=C.id===i,q=u==null?void 0:u.samples.find(F=>F.sample===C.id),$=C.experiments.map(F=>({id:F,...l.experiments[F]})).filter(F=>F.technique);return g.jsxs("button",{type:"button",role:"tab","data-sample":C.id,"aria-selected":U,className:"ltab",onClick:()=>s(C.id),children:[g.jsxs("span",{className:"ltab-name",children:[C.category==="TUMOR"?g.jsx(er,{fingerprint:q,size:"mini",className:"h-[18px] w-[18px] flex-none"}):g.jsx(Iy,{size:15,"aria-hidden":!0,className:"flex-none"}),Qd(C.id,l.individual.id)," ",C.category==="TUMOR"?"tumour":"normal",x.has(C.id)&&g.jsx("span",{className:"ltab-warn",title:"A module failed for this sample","aria-label":"A module failed"})]}),g.jsxs("span",{className:"ltab-exps",children:[$.length===0&&g.jsx("span",{children:"No experiments"}),$.map(F=>{const te=vC[F.technique],k=(te==null?void 0:te.icon)??Io;return g.jsxs("span",{title:F.id,children:[g.jsx(k,{size:12,"aria-hidden":!0}),(te==null?void 0:te.label)??F.technique]},F.id)})]})]},C.id)})})]})}function wC({data:l,sampleId:i,fingerprint:u,onSample:s}){return g.jsx("div",{className:"ctabs",role:"tablist","aria-label":"Samples",children:l.samples.map(c=>{const f=u==null?void 0:u.samples.find(h=>h.sample===c.id);return g.jsxs("button",{type:"button",role:"tab","aria-selected":c.id===i,className:"ctab",onClick:()=>s(c.id),children:[c.category==="TUMOR"?g.jsx(er,{fingerprint:f,size:"mini",className:"h-[16px] w-[16px] flex-none"}):g.jsx(Iy,{size:14,"aria-hidden":!0,className:"flex-none"}),Qd(c.id,l.individual.id)," ",c.category==="TUMOR"?"tumour":"normal"]},c.id)})})}function l0({individualId:l,subtitle:i,patientIcon:u,compact:s,showCompact:c=!1}){const[f,h]=O.useState(!1),[m,v]=O.useState(!1);O.useEffect(()=>{const y=()=>v(window.scrollY>4);return y(),window.addEventListener("scroll",y,{passive:!0}),()=>window.removeEventListener("scroll",y)},[]);async function x(){try{await navigator.clipboard.writeText(window.location.href),h(!0),window.setTimeout(()=>h(!1),1600)}catch{window.prompt("Copy this link",window.location.href)}}return g.jsxs("div",{className:"topbar flex flex-wrap items-center justify-between gap-x-4 gap-y-3 px-8 pt-4 pb-3.5","data-scrolled":m,children:[g.jsxs("nav",{"aria-label":"Breadcrumb",className:"flex min-w-0 items-center gap-2 text-[13.5px]",children:[g.jsx(Ob,{to:"/",style:{color:"var(--muted)",textDecoration:"none"},children:"Patients"}),l&&g.jsxs(g.Fragment,{children:[g.jsx(Fd,{size:14,"aria-hidden":!0,style:{color:"var(--chev)"}}),u&&g.jsx("span",{id:t0,className:"ltabs-icon",children:u}),g.jsx("h1",{className:"m-0 text-[20px] font-semibold tracking-tight",style:{color:"var(--ink)"},children:l}),i&&g.jsx("span",{className:"ml-1.5 truncate text-[13.5px]",style:{color:"var(--muted)"},children:i})]})]}),g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.jsxs("div",{className:"field w-[300px] max-w-full",title:"Not available yet",children:[g.jsx(Po,{size:16,"aria-hidden":!0,style:{color:"var(--chev)"}}),g.jsx("label",{className:"sr-only",htmlFor:"search",children:"Search"}),g.jsx("input",{id:"search",placeholder:"Search genes, variants, analyses",disabled:!0})]}),g.jsx("button",{type:"button",className:"sc-btn sc-b2",disabled:!0,title:"Not available yet",children:"Compare versions"}),g.jsx("button",{type:"button",className:"sc-ib","aria-label":"Copy a link to this view",onClick:x,children:g.jsx(eC,{size:16,"aria-hidden":!0})}),g.jsx("button",{type:"button",className:"sc-ib","aria-label":"Export tables",disabled:!0,title:"Not available yet",children:g.jsx(Jb,{size:16,"aria-hidden":!0})}),g.jsx("span",{"aria-live":"polite",className:"text-xs",style:{color:"var(--muted)"},children:f?"Link copied":""})]}),s&&g.jsx("div",{className:"topbar-compact","data-open":c,inert:!c,"aria-hidden":!c,children:g.jsx("div",{children:s})})]})}class tr extends Error{}class a0 extends Error{}function RC(){try{return localStorage.getItem(xd)}catch{return null}}function i0(l){try{l?localStorage.setItem(xd,l):localStorage.removeItem(xd)}catch{}}function u0(){const l=RC();return{Accept:"application/json",...l?{Authorization:`Token ${l}`}:{}}}async function Ii(l,i={}){const u=new URLSearchParams;for(const[f,h]of Object.entries(i))h&&u.set(f,h);const s=u.toString(),c=await fetch(`${Fn.apiHost}/wgts/api/${l}${s?`?${s}`:""}`,{headers:u0()});if(c.status===401)throw new tr;if(c.status===403){const f=await c.json().catch(()=>({}));throw new a0(f.detail??"You may not see this patient's results.")}if(!c.ok)throw new Error(`The dashboard API answered ${c.status}.`);return await c.json()}async function _C(l){if(!(await fetch(`${Fn.apiHost}/api/v1/auth/`,{headers:{Accept:"application/json",Authorization:`Token ${l}`}})).ok)throw new Error("Isabl did not accept that token.");i0(l)}async function TC(l,i){const u=await fetch(`${Fn.apiHost}/api/v1/rest-auth/login/`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({username:l,password:i})});if(!u.ok)throw new Error("Isabl did not accept that username and password.");const s=await u.json();i0(s.key)}async function NC(l){const i=new URLSearchParams(l?{q:l}:{}).toString(),u=await fetch(`${Fn.apiHost}/wgts/api/individuals/${i?`?${i}`:""}`,{headers:u0()});if(u.status===401)throw new tr;if(!u.ok)throw new Error(`The dashboard API answered ${u.status}.`);return(await u.json()).results}const s0={drivers:"gene",coding:"position",all:"position"},MC=[10,25,50,100];function ty(){return{scope:"drivers",page:1,pageSize:25,sort:s0.drivers,q:"",effects:[],flags:[],range:null,ffpe:!1}}function o0(l){return(l.q.trim()?1:0)+l.effects.length+l.flags.length+(l.range?1:0)}function OC(l){const i={scope:l.scope,page:String(l.page),page_size:String(l.pageSize),sort:l.sort,q:l.q.trim()||void 0,effects:l.effects.join(",")||void 0,flags:l.flags.join(",")||void 0,ffpe:l.ffpe?"all":void 0};return l.range&&(i[`${l.range.measure}_min`]=String(l.range.low),i[`${l.range.measure}_max`]=String(l.range.high)),i}const r0={missense:"Missense",truncating:"Truncating",splice:"Splice",inframe:"In-frame",synonymous:"Synonymous",other:"Other"},c0={hotspot:"Hotspot",in_dmp:"In DMP",oncogene:"Oncogene",tsg:"Tumour suppressor"};function jC(l){return`${l.chrom}:${l.pos}:${l.ref}>${l.alt}`}const AC=/^(?:chr)?([0-9]{1,2}|[XYxy]):([0-9,]+)(?:-([0-9,]+))?$/;function zC(l){return AC.test(l.trim())}function DC(l,i,u){return`chr${l}:${i.toLocaleString("en-US")}-${u.toLocaleString("en-US")}`}const UC={GENOMIC_EXACT:"exact match",GENOMIC_POS:"same position",CODON:"same codon",GENE:"same gene"};function HC(l){var f;if(!l)return null;const i=l.split(";"),u=(f=l.match(/SOM=(\d+)/))==null?void 0:f[1],s=UC[i[0]];return!u&&!s?l:[u?`${Number(u).toLocaleString("en-US")} somatic ${u==="1"?"sample":"samples"}`:"",s].filter(Boolean).join(", ")}function VC(l){const i=l==null?void 0:l.match(/^(\d+)\/(\d+)$/);return i?`${i[1]} of ${i[2]} ${i[2]==="1"?"copy":"copies"}`:l}function LC(l){return l.oncogene&&l.tsg?"Oncogene and TSG":l.oncogene?"Oncogene":l.tsg?"TSG":null}const qa=(l,i)=>!(i instanceof tr)&&l<2;function qC(l,i){return Va({queryKey:["individual",l,i??null],queryFn:()=>Ii(`individuals/${encodeURIComponent(l)}/`,{version:i}),retry:qa})}function BC(l,i,u){return Va({queryKey:["metrics",l,i,u??null],queryFn:()=>Ii(`individuals/${encodeURIComponent(l)}/metrics/`,{sample:i,version:u}),enabled:!!i,retry:qa})}function GC(l,i){return Va({queryKey:["fingerprint",l,i??null],queryFn:()=>Ii(`individuals/${encodeURIComponent(l)}/fingerprint/`,{version:i}),retry:qa})}const Yd=(l,i)=>`individuals/${encodeURIComponent(l)}/${i}/`;function FC(l,i,u){return Va({queryKey:["cn",l,i,u??null],queryFn:()=>Ii(Yd(l,"cn"),{sample:i,version:u}),enabled:!!i,retry:qa})}function $C(l,i,u,s,c){return Va({queryKey:["ccf",l,i,u,s,c??null],queryFn:()=>Ii(Yd(l,"ccf"),{sample:i,measure:u,version:c,ffpe:s?"all":void 0}),enabled:!!i,retry:qa})}function QC(l,i,u,s){return Va({queryKey:["variants",l,i,u,s??null],queryFn:()=>Ii(Yd(l,"variants"),{sample:i,version:s,...OC(u)}),enabled:!!i,placeholderData:Ny,retry:qa})}function YC(l,i){return Va({queryKey:["patients",l],queryFn:()=>NC(l),enabled:i,staleTime:6e4,placeholderData:Ny,retry:qa})}const f0="wgts-recent-patients",kC=6;function d0(){try{const l=JSON.parse(localStorage.getItem(f0)??"[]");return Array.isArray(l)?l.filter(i=>typeof i=="string"):[]}catch{return[]}}function XC(l){try{localStorage.setItem(f0,JSON.stringify([l,...d0().filter(i=>i!==l)].slice(0,kC)))}catch{}}const ZC=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function h0({current:l}){const i=Jo(),[u,s]=O.useState(""),[c,f]=O.useState(!1),[h,m]=O.useState(0),v=O.useRef(null),x=O.useId(),y=O.useDeferredValue(u.trim()),S=YC(y,c&&y.length>0);O.useEffect(()=>{const C=U=>{var q;U.key.toLowerCase()==="k"&&(U.metaKey||U.ctrlKey)&&(U.preventDefault(),(q=v.current)==null||q.focus())};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const b=y?(S.data??[]).map(C=>({id:C.individual,meta:C.individual===l?"On this page":`${C.samples} ${C.samples===1?"sample":"samples"}, report ${C.report_version}`})):d0().filter(C=>C!==l).map(C=>({id:C,meta:"Opened recently",recent:!0})),N=y&&b.length===0&&!S.isFetching?{id:y,meta:"No dashboard found; open anyway"}:null,j=N?[...b,N]:b,D=c&&(j.length>0||y&&S.isFetching),w=C=>{var U;s(""),f(!1),(U=v.current)==null||U.blur(),C!==l&&i(`/${encodeURIComponent(C)}`)};return g.jsxs("div",{className:"psearch","data-open":!!D,children:[g.jsxs("div",{className:"psearch-field",children:[g.jsx(Po,{size:15,"aria-hidden":!0}),g.jsx("input",{ref:v,role:"combobox","aria-expanded":!!D,"aria-controls":x,"aria-activedescendant":D&&j[h]?`${x}-${h}`:void 0,"aria-label":"Search patients",placeholder:"Search patients",value:u,onFocus:()=>f(!0),onBlur:()=>f(!1),onChange:C=>{s(C.target.value),m(0),f(!0)},onKeyDown:C=>{var U;C.key==="ArrowDown"?(C.preventDefault(),m(q=>Math.min(q+1,j.length-1))):C.key==="ArrowUp"?(C.preventDefault(),m(q=>Math.max(q-1,0))):C.key==="Enter"&&j[h]?(C.preventDefault(),w(j[h].id)):C.key==="Escape"&&(s(""),(U=v.current)==null||U.blur())}}),g.jsx("kbd",{className:"kbd","aria-hidden":!0,children:ZC?"⌘K":"Ctrl K"})]}),D&&g.jsxs("ul",{id:x,role:"listbox",className:"psearch-list","aria-label":"Patients",children:[!y&&g.jsx("li",{className:"psearch-head",children:"Recent"}),j.map((C,U)=>g.jsxs("li",{id:`${x}-${U}`,role:"option","aria-selected":U===h,className:"psearch-option",onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>m(U),onClick:()=>w(C.id),children:[C.recent?g.jsx(Ib,{size:14,"aria-hidden":!0}):g.jsx(Wy,{size:14,"aria-hidden":!0}),g.jsxs("span",{className:"flex min-w-0 flex-col",children:[g.jsx("span",{className:"truncate",children:C.id}),g.jsx("span",{className:"psearch-meta",children:C.meta})]}),U===h&&g.jsx(Zb,{size:13,"aria-hidden":!0,className:"ml-auto flex-none opacity-50"})]},C.id)),y&&j.length===0&&g.jsx("li",{className:"psearch-head",children:"Searching…"})]})]})}function KC(){const l=Jo(),[i,u]=O.useState("");return g.jsxs("div",{className:`wgts ${Fn.theme}`,children:[g.jsxs("aside",{className:"side","aria-label":"Navigation",children:[g.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[g.jsx(Io,{size:24,strokeWidth:1.9,style:{color:"var(--menu-hi)"},"aria-hidden":!0}),g.jsx("span",{className:"text-base font-semibold tracking-tight",style:{color:"var(--menu-brand)"},children:"WGTS Reports"})]}),g.jsx(h0,{current:""})]}),g.jsxs("div",{className:"page",children:[g.jsx(l0,{}),g.jsxs("main",{className:"flex flex-col gap-4 px-8 pt-8 pb-10",children:[g.jsx("h1",{className:"m-0 text-[28px] font-semibold tracking-tight",children:"Open a patient"}),g.jsx("p",{className:"m-0 max-w-[60ch] text-[14.5px]",style:{color:"var(--ink-2)"},children:"Enter an individual's system id to see its WGTS report as live charts and tables."}),g.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:s=>{s.preventDefault(),i.trim()&&l(`/${i.trim()}`)},children:[g.jsxs("div",{className:"field w-[340px] max-w-full",children:[g.jsx(Po,{size:16,"aria-hidden":!0,style:{color:"var(--chev)"}}),g.jsx("label",{className:"sr-only",htmlFor:"open-id",children:"Individual id"}),g.jsx("input",{id:"open-id",placeholder:"IID_H000001",value:i,onChange:s=>u(s.target.value)})]}),g.jsx("button",{type:"submit",className:"sc-btn sc-b1",disabled:!i.trim(),children:"Open"})]})]})]})]})}function Ed(l){const i=l.toUpperCase();return i.startsWith("BATTENBERG")||i.startsWith("CNV_")?"cn":i.startsWith("ANNOT_SNVS")||i.startsWith("ANNOT_INDELS")||i.startsWith("FFPERASE")?"mut":i.startsWith("MSISENSOR")?"msi":"other"}function Ki(l){return`fam-${Ed(l)}`}function g0(l){return l.pk?`${l.app} #${l.pk}`:l.app}function wt(l){return`${l.app}#${l.pk??""}`}const JC=[{label:"Overview",icon:Wb,ready:!0},{label:"Copy number",icon:Vb,ready:!1},{label:"Mutations",icon:tC,ready:!1},{label:"Structural variants",icon:lC,ready:!1},{label:"Signatures and HRD",icon:Gb,ready:!1},{label:"RNA",icon:aC,ready:!1},{label:"Germline",icon:nC,ready:!1},{label:"Quality",icon:Yb,ready:!1}];function IC({individualId:l,sampleCount:i,mode:u,fingerprint:s,analyses:c,onPage:f,sampleLabel:h,picked:m,onPick:v}){const[x,y]=O.useState(!1),S=["cn","mut","msi","other"],b=(w,C)=>S.indexOf(Ed(w.app))-S.indexOf(Ed(C.app))||w.app.localeCompare(C.app),N=c.filter(w=>w.role==="input"),j=N.filter(w=>f.has(wt(w))).sort(b),D=[...N.filter(w=>!f.has(wt(w))).sort(b),...c.filter(w=>w.role==="cohort")];return g.jsxs("aside",{className:"side","aria-label":"Patient navigation",children:[g.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[g.jsx(Io,{size:24,strokeWidth:1.9,style:{color:"var(--menu-hi)"},"aria-hidden":!0}),g.jsx("span",{className:"text-base font-semibold tracking-tight",style:{color:"var(--menu-brand)"},children:"WGTS Reports"})]}),g.jsx(h0,{current:l}),g.jsxs("nav",{"aria-label":"Patient sections",className:"flex flex-col gap-0.5",children:[g.jsxs("div",{className:"side-patient",children:[g.jsx(er,{fingerprint:s,size:"switcher",className:"h-10 w-10 flex-none"}),g.jsxs("span",{className:"flex min-w-0 flex-col gap-px",children:[g.jsx("span",{className:"truncate text-[13.5px] font-semibold",style:{color:"var(--menu-strong)"},children:l}),g.jsxs("span",{className:"text-xs",style:{color:"var(--menu-muted)"},children:[i," samples",u?`, ${u}`:""]})]})]}),JC.map(({label:w,icon:C,ready:U})=>g.jsxs("button",{type:"button",className:"sc-nav","aria-current":U?"page":void 0,disabled:!U,title:U?void 0:"Not available yet",children:[g.jsx(C,{size:18,"aria-hidden":!0}),w]},w))]}),g.jsxs("section",{"aria-label":"Analyses on this page",className:"flex flex-col gap-0.5",children:[g.jsx("span",{className:"side-label",children:"Analyses on this page"}),j.length===0&&g.jsxs("span",{className:"px-3 text-xs",style:{color:"var(--menu-muted)"},children:["Nothing on this page reads an analysis for ",h||"this sample","."]}),j.map(w=>{const C=wt(w),U=w.state==="failed",q=w.modules.filter($=>$.status==="failed");return g.jsxs("button",{type:"button",className:`tb-src${U?" fail":""}`,"aria-pressed":m===C,title:U?q.map($=>`${$.label} failed`).join("; "):"Show what it feeds",onClick:()=>v(m===C?null:C),children:[U?g.jsx(Py,{size:12,strokeWidth:2.6,"aria-hidden":!0,style:{color:"var(--fail-d)",margin:"0 -2px"}}):g.jsx("span",{className:`tb-dot ${Ki(w.app)}`,"aria-hidden":!0}),g.jsxs("span",{className:"truncate",children:[w.app," ",w.version??""]}),U&&g.jsx("span",{className:"sr-only",children:", failed"}),g.jsx("span",{className:"tb-n",children:w.pk?`#${w.pk}`:""})]},C)}),D.length>0&&g.jsxs(g.Fragment,{children:[g.jsxs("button",{type:"button",className:"tb-src","aria-expanded":x,onClick:()=>y(w=>!w),children:[g.jsx("span",{className:"tb-dot fam-other","aria-hidden":!0}),x?"Hide":"Show"," ",D.length," more for ",h||"this sample"]}),x&&D.map(w=>g.jsxs("span",{className:"tb-src",style:{cursor:"default"},children:[g.jsx("span",{className:`tb-dot ${Ki(w.app)}`,"aria-hidden":!0}),g.jsx("span",{className:"truncate",children:w.role==="cohort"?`${w.app}${w.project?`, project ${w.project}`:""}`:`${w.app} ${w.version??""}`}),g.jsx("span",{className:"tb-n",children:w.pk?`#${w.pk}`:""})]},wt(w)))]}),g.jsx("span",{className:"px-3 pt-2 text-xs leading-normal",style:{color:"var(--menu-muted)"},children:"Pick one to see what it feeds."})]}),g.jsx("div",{className:"flex-auto"})]})}function _a({envelope:l}){const i=l.status==="error",u=i?Qb:kb;return g.jsxs("div",{className:"flex items-start gap-2.5 text-sm",style:{color:"var(--ink-2)"},children:[g.jsx(u,{size:18,"aria-hidden":!0,style:{color:i?"var(--warn-ink)":"var(--chev)",flex:"none"}}),g.jsxs("div",{className:"flex flex-col gap-1",children:[g.jsx("span",{className:"font-semibold",style:{color:"var(--ink)"},children:i?"This panel could not be read":"Nothing to show here"}),l.warnings.map(s=>g.jsx("span",{children:s},s))]})]})}const wd={summary:{title:"Genome fingerprint and summary",intro:"A one-glance portrait of the selected tumour: its copy-number changes and driver mutations drawn as a ring, a sentence describing them, and the headline measurements of the sample.",sections:[{heading:"The fingerprint ring",paragraphs:["The ring is the whole genome. Chromosome 1 starts at the top and the ring runs clockwise through chromosome 22 to X, each chromosome's arc in proportion to its length (GRCh37).","Copy-number changes are called against the tumour's baseline, its ploidy rounded to whole copies. Very short changes are drawn at a minimum length so they stay visible."],terms:[["Gains (outer track, orange)","Regions with at least one copy more than the baseline."],["Amplifications (outer track, darker and thicker)","Regions with three or more copies above the baseline."],["Losses (inner track, blue)","Regions with at least one copy fewer than the baseline."],["Drivers (black ticks)","Where the tumour's likely driver mutations sit (see the Mutations card for how they are flagged)."]]},{heading:"The sentence",paragraphs:["Written from the same data as the ring: how many amplifications, gains and losses there are and on which chromosomes, and which genes carry driver mutations."]},{heading:"The measurements",paragraphs:["Each tile shows a value, a small picture of where it sits on its scale when it has a natural one, and the analysis it came from. A tile with no value says why: the analysis was not run, it failed, or it does not apply to this kind of report (tumour-only reports have no matched normal)."],terms:[["Purity","The estimated fraction of cells in the sample that are tumour cells, from 0 to 1. The ring fills to the value."],["Ploidy","The tumour's average number of copies across the genome. The scale runs from 1 to 6 copies; the tall tick marks 2, a diploid genome."],["Coverage","The median sequencing depth of the tumour across the genome, in reads (×)."],["TMB per Mb","Tumour mutational burden: somatic SNVs and indels per megabase of genome. The report computes it from the counts of the SNV and indel calls. The scale is logarithmic, 0.01 to 100."],["MSI score","The MSIsensor score: the percentage of microsatellite sites that look unstable in the tumour."],["FGA","Fraction of the genome altered: the share of the genome whose copy number differs from the baseline, from 0 to 1. It is read from the project-wide Battenberg tables."]]},{heading:"Linking back to the analyses",paragraphs:[`Every value names its analysis, with version and Isabl id. Picking an analysis in the side menu's "Analyses on this page" highlights the tiles and cards it feeds.`]}]},copyNumber:{title:"Copy number",intro:"How many copies of each part of the genome the tumour carries, segment by segment, from chromosome 1 to X.",sections:[{heading:"What is drawn",paragraphs:['Each horizontal stroke is one segment: a stretch of the genome with a constant copy number. Its height is the number of copies, from 0 up to 8; anything higher is drawn at the top and the axis reads "8+". Alternating grey bands mark the chromosomes, named along the bottom.',`The dashed line is the baseline: the tumour's ploidy rounded to whole copies (labelled, for example, "2 copies"). Segments are coloured by how they compare with it.`],terms:[["Grey","Neutral: the same number of copies as the baseline."],["Orange","Gain: at least one copy more than the baseline."],["Dark orange","Amplification: three or more copies above the baseline."],["Blue","Loss: at least one copy fewer than the baseline."]]},{heading:"Total or allele-specific",paragraphs:["Total shows all copies together. Allele-specific, when the analysis provides it, splits each segment into its major allele (the more common parental copy, dark) and minor allele (light). Where the two are equal they are drawn slightly apart so both stay visible. A minor allele of 0 means one parent's copy is lost there (loss of heterozygosity)."]},{heading:"Driver genes",paragraphs:["Triangles along the top mark the genes with likely driver mutations, one per gene; hover for its protein changes."]},{heading:"Reading and moving around",terms:[["Hover a segment","Its call, copies (major + minor), coordinates and, when available, log2 ratio."],["Click a segment","Lists the mutations inside it in the Mutations card."],["Click a driver","Finds that gene in the Mutations card."],["Pinch, or Ctrl and scroll","Zooms around the pointer. Plain scrolling always scrolls the page."],["Drag","Pans a zoomed view."],["Double-click a chromosome","Zooms to fill the view with it; the axis then counts megabases."],["Slider and reset","The slider under the plot shows and moves the window; the button by the title returns to the whole genome."],["Hover a mutation in the table","Marks it here, with a ring on the segment it sits on and its copy number."]]},{heading:"Tumour-only reports",paragraphs:["Without a matched normal there is no ploidy estimate, so segments come from CNVkit and are called against two copies. Allele-specific copy numbers are not available."]}]},mutations:{title:"Mutations",intro:"The tumour's somatic SNVs and indels that passed the callers' filters: how they are distributed across cancer cells, and a searchable, filterable table of every call.",sections:[{heading:"Which mutations",terms:[["Drivers","Likely drivers flagged by the report: coding mutations that match OncoKB or COSMIC driver annotations (the exact protein change, or a damaging consequence in a known cancer gene), plus known hotspots the callers missed and the report recovered from the tumour's reads."],["Coding","Mutations whose effect changes a protein, by the report's list of coding effects."],["All","Every PASS SNV and indel."]],paragraphs:["The counts beside each choice follow the search and filters, so they always say what you would see."]},{heading:"FFPE samples",paragraphs:["Formalin-fixed (FFPE) tissue damages DNA in ways that look like mutations, mostly C>T changes at low allele fractions. For an FFPE sample, FFPERASE scores each SNV and indel for how likely it is to be such an artifact, and the report counts only the calls scored at or below its threshold (quoted beside the table). Its SNV, indel and coding totals and the TMB leave the rest out.",`The report marks each call it leaves out, and the dashboard follows that mark: the Coding and All counts, the table and the curve leave those calls out, and the card's subtitle says so. Drivers are all listed, as in the report, and any the filter would remove carry an "FFPE filtered" tag. "Show filtered calls", under FFPE filter beside the table, brings the removed calls back, tagged the same way.`]},{heading:"Cancer cell fraction and variant allele fraction",paragraphs:["The curve across the top is a smoothed histogram of every PASS mutation; driver mutations are labelled on it. Switch between the two measures:"],terms:[["CCF",'Cancer cell fraction: the estimated share of cancer cells carrying the mutation, corrected for purity and copy number. Around 1 (the "clonal" mark) means nearly every cancer cell has it, which suggests it arose early; clearly below 1 means a subclone. Estimates can land somewhat above 1. Shown from 0 to 2.'],["VAF","Variant allele fraction: the share of sequencing reads at the position that carry the mutation, from 0 to 1. Raw, not corrected for purity or copy number. Tumour-only reports open on VAF, since CCF needs a matched normal."]]},{heading:"Filtering by the curve",paragraphs:["Drag across the curve to keep only mutations in that CCF or VAF range; drivers outside it fade. The range appears with the other filters and can be removed there, or by clicking the curve."]},{heading:"The table",terms:[["Gene and position","The gene, and the mutation's chromosome and position (GRCh37)."],["Change","The protein change, with the cDNA change beneath."],["Effect","What the mutation does to the gene, from the VEP consequence (or the report's effect). Truncating effects are in bold."],["VAF and CCF bars","The value with a bar for quick comparison; the CCF bar's tick marks 1, clonal."],["Driver","Flagged as a likely driver (shown when the table is not already limited to drivers)."],["Hotspot","The exact protein change is a known recurrent cancer hotspot."],["In DMP","The same mutation was also found by the patient's clinical MSK-IMPACT (DMP) sequencing."],["FFPE filtered","FFPE samples only: the report's FFPE artifact filter leaves this call out of its counts (see FFPE samples)."]]},{heading:"Opening a row",terms:[["Variant","SNV or indel, with the reference and alternate bases."],["Reads","Reads supporting the mutation out of all reads at the position. Only hotspots the report recovered from the tumour's reads have them; the callers' tables give no single count."],["Normal VAF","The mutation's allele fraction in the matched normal; near 0 for a somatic mutation."],["Mutant copies","How many copies of that part of the genome carry the mutation, out of all copies there."],["Consequence","The full VEP consequence."],["COSMIC","How many samples in COSMIC carry it, and how closely they match (exact change, same position, codon or gene)."],["Expression","The gene's expression in the tumour's RNA, in transcripts per million, when RNA was sequenced."],["Gene role","Whether the gene is a known oncogene or tumour suppressor gene (TSG)."],["Show on copy number","Zooms the Copy number card to the mutation's chromosome and marks it."]]},{heading:"Searching and filtering",paragraphs:["Search takes a gene, a protein or cDNA change, a COSMIC term, or a locus such as chr12:25,398,284 or a range such as chr8:1-50,000,000. Press / anywhere on the page to jump to it. Each filter's count is how many rows you would get by ticking it, given everything else."],terms:[["Missense","One amino acid replaced by another."],["Truncating","Stop gained or lost, start lost, or a frameshift."],["Splice","Changes a splice site or splice region."],["In-frame","Inserts or deletes amino acids without shifting the reading frame."],["Synonymous","Changes the DNA but not the amino acid."],["Other","Everything else, such as intronic, UTR or upstream changes."]]}]}},PC={summary:{BATTENBERG:"Tumour purity and ploidy, and the copy-number segments the ring's gains and losses are called from.","BATTENBERG cohort":"Project-wide Battenberg tables, which hold the FGA value and the cohort it is compared with.",CNV_UNMATCHED:"Copy-number segments of a tumour-only report (CNVkit), which the ring's gains and losses are called from.",MOSDEPTH:"The median sequencing coverage.",MSISENSOR:"The MSI score.",MSISENSOR_UNMATCHED:"The MSI score of a tumour-only report.",ANNOT_SNVS:"Somatic SNV calls: their count goes into TMB, and driver SNVs are marked on the ring.",ANNOT_INDELS:"Somatic indel calls: their count goes into TMB, and driver indels are marked on the ring.",ANNOT_SNVS_UNMATCHED:"Tumour-only SNV calls: their count goes into TMB, and driver SNVs are marked on the ring.",ANNOT_INDELS_UNMATCHED:"Tumour-only indel calls: their count goes into TMB, and driver indels are marked on the ring.",WGSPOST:"Cancer cell fractions of the mutations, read together with the driver calls marked on the ring."},copyNumber:{BATTENBERG:"Every segment drawn: total copies, major and minor allele copies, and the ploidy the baseline is rounded from.","BATTENBERG cohort":"Project-wide Battenberg tables the report reads alongside this run; they hold the FGA, and are not drawn here.",CNV_UNMATCHED:"The segments of a tumour-only report (CNVkit), drawn against two copies."},mutations:{ANNOT_SNVS:"The tumour's PASS somatic SNVs and their annotation: gene, protein and cDNA change, effect, VAF, read counts, normal VAF and COSMIC.",ANNOT_INDELS:"The tumour's PASS somatic indels and their annotation, as for SNVs.",ANNOT_SNVS_UNMATCHED:"Tumour-only SNV calls and their annotation.",ANNOT_INDELS_UNMATCHED:"Tumour-only indel calls and their annotation.",WGSPOST:"Each mutation's cancer cell fraction (CCF) and how many copies carry it.",BATTENBERG:"Ploidy, which fills in the copy count where WGSPOST has none, and purity, which gives a CCF to hotspots recovered from the tumour's reads.",FFPERASE_SNVS:"FFPE samples: each SNV's artifact score. Calls scoring above the report's threshold are left out of the counts.",FFPERASE_INDELS:"FFPE samples: each indel's artifact score. Calls scoring above the report's threshold are left out of the counts."}};function WC(l,i){const u=i.role==="cohort"||i.app.endsWith("Project Application"),s=i.app.replace(/ Project Application$/,""),c=PC[l];return(u?c[`${s} cohort`]:c[s])??(u?"A project-wide run the report reads for comparison with the cohort.":"An analysis the report reads to build this card.")}function eE({topic:l,lineage:i,subject:u,onClose:s}){const c=wd[l],f=O.useId(),h=O.useRef(null),m=i.filter(C=>C.role!=="cohort"&&!C.app.endsWith("Project Application")),v=i.filter(C=>!m.includes(C)),x=O.useRef(s);x.current=s,O.useEffect(()=>{var F;const C=document.activeElement;(F=h.current)==null||F.focus();const U=document.documentElement,q=U.style.overflow;U.style.overflow="hidden";const $=te=>{te.key==="Escape"&&x.current()};return document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$),U.style.overflow=q,C==null||C.focus()}},[]);const y=[...c.sections.map(C=>C.heading),"Sources"],S=y.map((C,U)=>`${f}-s${U}`),[b,N]=O.useState(0),j=O.useRef(null);O.useEffect(()=>{const C=j.current;if(!C)return;const U=()=>{const q=C.getBoundingClientRect().top+24;let $=0;S.forEach((F,te)=>{const k=document.getElementById(F);k&&k.getBoundingClientRect().top<=q&&($=te)}),C.scrollTop+C.clientHeight>=C.scrollHeight-4&&($=S.length-1),N($)};return U(),C.addEventListener("scroll",U,{passive:!0}),()=>C.removeEventListener("scroll",U)},[]);const D=C=>{var q;const U=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;(q=document.getElementById(S[C]))==null||q.scrollIntoView({behavior:U?"auto":"smooth",block:"start"})},w=C=>g.jsxs("li",{className:"info-source",children:[g.jsx("span",{className:`tb-dot ${Ki(C.app)}`,"aria-hidden":!0}),g.jsxs("span",{className:"info-source-text",children:[C.pk?g.jsxs("a",{className:"info-source-name info-source-link",href:Ky(C.pk),target:"_blank",rel:"noopener noreferrer",title:"Open this analysis in Isabl",children:[g.jsxs("span",{className:"mono",children:[C.app,C.version?` ${C.version}`:""]}),g.jsxs("span",{className:"mono info-source-pk",children:["#",C.pk]}),g.jsx(Lb,{size:13,"aria-hidden":!0,className:"info-source-arrow"})]}):g.jsxs("span",{className:"info-source-name",children:[g.jsxs("span",{className:"mono",children:[C.app,C.version?` ${C.version}`:""]}),C.project?g.jsxs("span",{className:"info-source-pk",children:["project ",C.project]}):null]}),g.jsx("span",{className:"info-source-role",children:WC(l,C)})]})]},wt(C));return N2.createPortal(g.jsx("div",{className:`info-backdrop ${Fn.theme}`,onMouseDown:C=>C.target===C.currentTarget&&s(),children:g.jsxs("div",{className:"info-dialog",role:"dialog","aria-modal":"true","aria-labelledby":f,children:[g.jsx("button",{ref:h,type:"button",className:"info-close","aria-label":"Close",onClick:s,children:g.jsx($d,{size:18,"aria-hidden":!0})}),g.jsxs("nav",{className:"info-rail","aria-label":"Contents",children:[g.jsx("span",{className:"info-kicker",children:u??"About"}),g.jsx("h2",{id:f,children:c.title}),g.jsx("ol",{children:y.map((C,U)=>g.jsx("li",{children:g.jsx("button",{type:"button","aria-current":U===b?"true":void 0,onClick:()=>D(U),children:C})},C))})]}),g.jsxs("div",{ref:j,className:"info-main",children:[g.jsx("p",{className:"info-intro",children:c.intro}),c.sections.map((C,U)=>{var q;return g.jsxs("section",{id:S[U],className:"info-section",children:[g.jsx("h3",{children:C.heading}),(q=C.paragraphs)==null?void 0:q.map($=>g.jsx("p",{children:$},$)),C.terms&&g.jsx("dl",{children:C.terms.map(([$,F])=>g.jsxs("div",{children:[g.jsx("dt",{children:$}),g.jsx("dd",{children:F})]},$))})]},C.heading)}),g.jsxs("section",{id:S[S.length-1],className:"info-section","aria-label":"Sources",children:[g.jsx("h3",{children:"Sources"}),g.jsx("p",{children:"The analyses this card reads, with their version and Isabl id, and what each one is responsible for."}),i.length===0&&g.jsx("p",{children:"No analyses recorded for this card."}),g.jsx("ul",{className:"info-sources",children:m.map(w)}),v.length>0&&g.jsxs(g.Fragment,{children:[g.jsx("h4",{children:"Cohort runs"}),g.jsx("ul",{className:"info-sources",children:v.map(w)})]})]})]})]})}),document.body)}function m0({topic:l,lineage:i,subject:u}){const[s,c]=O.useState(!1);return g.jsxs(g.Fragment,{children:[g.jsx("button",{type:"button",className:"sc-ib sm info-trigger","aria-label":`About ${wd[l].title.toLowerCase()}`,title:`About ${wd[l].title.toLowerCase()}`,"aria-haspopup":"dialog",onClick:()=>c(!0),children:g.jsx(Pb,{size:15,"aria-hidden":!0})}),s&&g.jsx(eE,{topic:l,lineage:i,subject:u,onClose:()=>c(!1)})]})}function tE({lineage:l,children:i}){const[u,s]=O.useState(!1),c=l.filter(h=>h.role!=="cohort"),f=l.filter(h=>h.role==="cohort");return g.jsxs("div",{className:"sc-cf",children:[i,i&&g.jsx("span",{className:"flex-auto"}),l.length>0&&g.jsx("span",{className:"text-xs",style:{color:"var(--muted)"},children:"Sources"}),c.map(h=>h.pk?g.jsxs("a",{className:"sc-src sc-src-link",href:Ky(h.pk),target:"_blank",rel:"noopener noreferrer",title:"Open this analysis in Isabl",children:[g.jsx("span",{className:`tb-dot ${Ki(h.app)}`,"aria-hidden":!0}),h.app," ",h.version??""," #",h.pk]},wt(h)):g.jsxs("span",{className:"sc-src",children:[g.jsx("span",{className:`tb-dot ${Ki(h.app)}`,"aria-hidden":!0}),h.app," ",h.version??""]},wt(h))),f.length>0&&g.jsxs("button",{type:"button",className:"sc-src",style:{border:0,cursor:"pointer"},"aria-expanded":u,onClick:()=>s(h=>!h),children:[u?"Hide":"+"," ",f.length," cohort ",f.length===1?"run":"runs"]}),u&&f.map(h=>g.jsxs("span",{className:"sc-src",children:[g.jsx("span",{className:"tb-dot fam-other","aria-hidden":!0}),h.app,h.project?`, project ${h.project}`:""," ",h.pk?`#${h.pk}`:""]},wt(h)))]})}function p0(...l){const i=new Map;for(const u of l.flat())u&&!i.has(wt(u))&&i.set(wt(u),u);return[...i.values()]}const v0=O.forwardRef(function({title:i,subtitle:u,controls:s,lineage:c,picked:f,footer:h,className:m="",info:v,children:x},y){const S=!!f&&c.some(b=>wt(b)===f);return g.jsxs("section",{ref:y,className:`sc-card flex flex-col ${m}`,"data-picked":S,"aria-label":i,children:[g.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2.5 px-5 pt-4 pb-1",children:[g.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[g.jsx("h2",{className:"m-0 text-base font-semibold",children:i}),u&&g.jsx("span",{className:"text-[13px]",style:{color:"var(--muted)"},children:u})]}),(s||v)&&g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s,v&&g.jsx(m0,{topic:v,lineage:c,subject:typeof u=="string"?u:void 0})]})]}),g.jsx("div",{className:"min-w-0 flex-auto",children:x}),(c.length>0||h)&&g.jsx(tE,{lineage:c,children:h})]})});function kd({label:l,envelope:i,loading:u,skeletonHeight:s=160,children:c}){return g.jsxs(g.Fragment,{children:[u&&!i&&g.jsx("div",{className:"px-5 py-3",children:g.jsx("div",{className:"skeleton",style:{height:s},"aria-label":`Loading ${l}`})}),i&&i.status!=="ok"&&g.jsx("div",{className:"px-5 py-4",children:g.jsx(_a,{envelope:i})}),(i==null?void 0:i.status)==="ok"&&i.data!==null&&c(i.data),(i==null?void 0:i.status)==="ok"&&i.warnings.length>0&&g.jsx("div",{className:"px-5 pb-1 text-xs",style:{color:"var(--warn-ink)"},children:i.warnings.join(" ")})]})}function nE({title:l,subtitle:i,controls:u,envelope:s,loading:c,picked:f,skeletonHeight:h=160,footer:m,className:v="",info:x,children:y}){return g.jsx(v0,{title:l,subtitle:i,controls:u,lineage:(s==null?void 0:s.lineage)??[],picked:f,footer:m,className:v,info:x,children:g.jsx(kd,{label:l,envelope:s,loading:c,skeletonHeight:h,children:y})})}function lE(l,i){const[u,s]=O.useState(null),[c,f]=O.useState(!1);return O.useLayoutEffect(()=>{const h=l.current;if(!h)return;const m=()=>{const x=h.querySelector('[aria-pressed="true"]');s(x?{x:x.offsetLeft,y:x.offsetTop,width:x.offsetWidth,height:x.offsetHeight}:null)};if(m(),typeof ResizeObserver>"u")return;const v=new ResizeObserver(m);v.observe(h);for(const x of Array.from(h.children))v.observe(x);return()=>v.disconnect()},[l,i]),O.useEffect(()=>{if(u&&!c){const h=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(h)}},[u,c]),{thumb:u,moving:c}}function nr({label:l,options:i,value:u,onChange:s,className:c=""}){const f=O.useRef(null),{thumb:h,moving:m}=lE(f,u);return g.jsxs("div",{ref:f,className:`sc-track ${c}`,role:"group","aria-label":l,children:[h&&g.jsx("span",{className:"sc-thumb","data-moving":m,"aria-hidden":!0,style:{width:h.width,height:h.height,transform:`translate(${h.x}px, ${h.y}px)`}}),i.map(v=>g.jsx("button",{type:"button",className:"sc-seg","aria-pressed":v.value===u,disabled:v.disabled,title:v.title,onClick:()=>s(v.value),children:v.label},v.value))]})}function aE(l){var u;const i=[];return l.mode==="unmatched"&&i.push("Tumour only"),l.individual.germline_consent&&i.push("Germline consented"),(u=l.individual.dmp_id)!=null&&u.startsWith("P-")&&i.push("DMP linked"),i}function iE({data:l,fingerprint:i,sampleId:u,onSample:s,onVersion:c}){const f=l.report;return g.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-10 gap-y-5",children:[g.jsx(EC,{data:l,sampleId:u,fingerprint:i,onSample:s}),g.jsxs("div",{className:"flex flex-col items-start gap-2.5 pt-1 lg:items-end",children:[g.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[g.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--muted)"},children:"Report version"}),g.jsx(nr,{label:"Report version",value:f.version,onChange:c,options:l.versions.map(h=>({value:h.version,label:h.version}))})]}),g.jsxs("span",{className:"mono text-[11.5px]",style:{color:"var(--muted)"},children:["WGTS_REPORT ",f.analysis?`run #${f.analysis}`:"run indexed by hand",f.built?`, built ${rC(f.built)}`:""]}),g.jsx("div",{className:"flex flex-wrap gap-2",children:aE(l).map(h=>g.jsx("span",{className:"sc-chip",children:h},h))})]})]})}const Rd=["purity","ploidy","coverage","tmb","msi","fga"];function uE({value:l}){const u=2*Math.PI*13,s=Math.min(Math.max(l,0),1);return g.jsxs("svg",{viewBox:"0 0 34 34",className:"kpi-glyph h-[34px] w-[34px]","aria-hidden":!0,children:[g.jsx("circle",{cx:"17",cy:"17",r:13,fill:"none",strokeWidth:"4",className:"kpi-track"}),g.jsx("circle",{cx:"17",cy:"17",r:13,fill:"none",strokeWidth:"4",strokeLinecap:"round",className:"kpi-fill",strokeDasharray:`${s*u} ${u}`,transform:"rotate(-90 17 17)"})]})}function ny({value:l,min:i,max:u,ticks:s,reference:c}){const f=h=>4+(Math.min(Math.max(h,i),u)-i)/(u-i)*64;return g.jsxs("svg",{viewBox:"0 0 72 20",className:"kpi-glyph h-[18px] w-[60px]","aria-hidden":!0,children:[g.jsx("line",{x1:"4",x2:"68",y1:"12",y2:"12",className:"kpi-track",strokeWidth:"2",strokeLinecap:"round"}),s.map(h=>g.jsx("line",{x1:f(h),x2:f(h),y1:h===c?5:9,y2:"15",className:"kpi-tick",strokeWidth:h===c?1.5:1},h)),g.jsx("circle",{cx:f(l),cy:"12",r:"4.5",className:"kpi-dot",strokeWidth:"2"})]})}function sE({metric:l}){const i=l.value;if(i===null)return null;switch(l.key){case"purity":case"fga":return g.jsx(uE,{value:i});case"ploidy":return g.jsx(ny,{value:i,min:1,max:6,ticks:[1,2,3,4,5,6],reference:2});case"tmb":return g.jsx(ny,{value:Math.log10(Math.max(i,.01)),min:-2,max:2,ticks:[-2,-1,0,1,2]});default:return null}}const oE={purity:"Share of tumour cells, 0 to 1",fga:"Share of the genome altered, 0 to 1",ploidy:"On a scale of 1 to 6 copies; the tall tick marks 2",tmb:"On a log scale from 0.01 to 100 mutations per Mb"};function rE({metric:l,picked:i}){const u=l.value===null&&!l.text,s=!!i&&l.sources.some(c=>wt(c)===i);return g.jsxs("div",{className:"kpi","data-picked":s,title:oE[l.key],children:[g.jsxs("span",{className:"kpi-top",children:[g.jsx("span",{className:"kpi-label",children:l.label}),g.jsx(sE,{metric:l})]}),g.jsx("span",{className:"kpi-value","data-empty":u,children:u?sC(l):uC(l)}),l.sources.length>0?g.jsx("span",{className:"flex flex-col gap-0.5",children:l.sources.map(c=>g.jsxs("span",{className:"kpi-src",children:[g.jsx("span",{className:`tb-dot ${Ki(c.app)}`,"aria-hidden":!0}),g.jsx("span",{className:"min-w-0",children:g0(c)})]},wt(c)))}):g.jsx("span",{className:"kpi-src",children:l.etl?`from ${l.etl}`:"no source"})]})}function cE({sampleLabel:l,fingerprint:i,metrics:u,picked:s,lineage:c=[]}){var h;const f=(((h=u==null?void 0:u.data)==null?void 0:h.metrics)??[]).filter(m=>Rd.includes(m.key));return g.jsxs("section",{className:"sc-card relative flex flex-wrap items-center gap-x-8 gap-y-5 px-6 py-5","aria-label":`Genome fingerprint and summary of ${l}`,children:[g.jsx("span",{className:"absolute top-3 right-3",children:g.jsx(m0,{topic:"summary",lineage:c,subject:l})}),g.jsx(er,{fingerprint:i,size:"hero",title:l.split(" ")[0],subtitle:"tumour",className:"h-[210px] w-[210px] max-w-full flex-none"}),g.jsxs("div",{className:"flex min-w-0 flex-[1_1_230px] flex-col gap-3",children:[g.jsxs("h2",{className:"m-0 text-lg font-semibold tracking-tight",children:["Genome fingerprint of ",l]}),g.jsx("p",{className:"m-0 max-w-[46ch] text-[14.5px] leading-relaxed",style:{color:"var(--ink-2)"},children:i?e0(i):"No copy-number data for this sample."}),g.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5 text-[12.5px]",style:{color:"var(--ink-2)"},children:[g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-[5px] w-3.5 rounded-[3px]",style:{background:"var(--gain)"}}),"Gains, outer track"]}),g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-[5px] w-3.5 rounded-[3px]",style:{background:"var(--loss)"}}),"Losses, inner track"]}),g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-3 w-[5px] rounded-sm",style:{background:"var(--ink)"}}),"Drivers"]})]}),g.jsx("span",{className:"text-[12.5px]",style:{color:"var(--muted)"},children:"Chromosome 1 starts at the top and the ring runs clockwise to X."})]}),g.jsxs("div",{className:"kpi-grid min-w-0 flex-[1.4_1_420px]",children:[u===void 0&&Rd.map(m=>g.jsx("div",{className:"kpi","aria-hidden":!0,children:g.jsx("div",{className:"skeleton h-[70px]"})},m)),u&&u.status!=="ok"&&g.jsx("div",{className:"col-span-full",children:g.jsx(_a,{envelope:u})}),f.map(m=>g.jsx(rE,{metric:m,picked:s},m.key))]})]})}function fE({sampleLabel:l,failures:i,analyses:u}){return i.length===0?null:g.jsx("div",{className:"flex flex-col gap-2.5",children:i.map(s=>{const c=u.filter(f=>f.modules.some(h=>h.etl===s.etl&&h.status==="failed"));return g.jsxs("div",{className:"sc-card flex flex-wrap items-center gap-x-4 gap-y-3 px-[18px] py-3.5",role:"status",children:[g.jsx("span",{className:"grid h-9 w-9 flex-none place-items-center rounded-[10px]",style:{background:"var(--warn-soft)",color:"var(--warn-ink)"},children:g.jsx(Py,{size:18,"aria-hidden":!0})}),g.jsxs("div",{className:"flex min-w-0 flex-[1_1_360px] flex-col gap-0.5",children:[g.jsxs("span",{className:"text-[14.5px] font-semibold",children:[s.label," failed for ",l]}),g.jsx("span",{className:"text-[13.5px]",style:{color:"var(--ink-2)"},children:s.message.split(`
|
|
252
|
+
`)[0]}),c.length>0&&g.jsxs("span",{className:"mono text-[11.5px]",style:{color:"var(--muted)"},children:["Reading ",c.map(g0).join(", ")]})]})]},`${s.etl}-${s.node}`)})})}function dE({onSignedIn:l}){const[i,u]=O.useState("password"),[s,c]=O.useState(""),[f,h]=O.useState(""),[m,v]=O.useState(""),[x,y]=O.useState(null),[S,b]=O.useState(!1),N=i==="password"?!!s&&!!f:!!m.trim();return g.jsxs("form",{className:"sc-card mx-auto mt-16 flex w-[380px] max-w-full flex-col gap-3 p-6",onSubmit:async j=>{j.preventDefault(),b(!0),y(null);try{i==="password"?await TC(s,f):await _C(m.trim()),l()}catch(D){y(D.message)}finally{b(!1)}},children:[g.jsx("h1",{className:"m-0 text-lg font-semibold",children:"Sign in to Isabl"}),g.jsx("p",{className:"m-0 text-sm",style:{color:"var(--ink-2)"},children:"The WGTS dashboard uses your Isabl account."}),i==="password"?g.jsxs(g.Fragment,{children:[g.jsxs("label",{className:"flex flex-col gap-1 text-[13px] font-semibold",htmlFor:"username",children:["Username",g.jsx("span",{className:"field",children:g.jsx("input",{id:"username",autoComplete:"username",value:s,onChange:j=>c(j.target.value)})})]}),g.jsxs("label",{className:"flex flex-col gap-1 text-[13px] font-semibold",htmlFor:"password",children:["Password",g.jsx("span",{className:"field",children:g.jsx("input",{id:"password",type:"password",autoComplete:"current-password",value:f,onChange:j=>h(j.target.value)})})]})]}):g.jsxs("label",{className:"flex flex-col gap-1 text-[13px] font-semibold",htmlFor:"token",children:["API token",g.jsx("span",{className:"field",children:g.jsx("input",{id:"token",type:"password",autoComplete:"off",spellCheck:!1,value:m,onChange:j=>v(j.target.value)})}),g.jsx("span",{className:"text-xs font-normal",style:{color:"var(--muted)"},children:"The token the Isabl CLI uses. Admins find it under Auth Token in Django admin."})]}),x&&g.jsx("p",{className:"m-0 text-sm",style:{color:"var(--warn-ink)"},role:"alert",children:x}),g.jsx("button",{type:"submit",className:"sc-btn sc-b1",disabled:S||!N,children:S?"Signing in":"Sign in"}),g.jsx("button",{type:"button",className:"self-start border-0 bg-transparent p-0 text-[13px] font-semibold",style:{color:"var(--link)",cursor:"pointer"},onClick:()=>{u(i==="password"?"token":"password"),y(null)},children:i==="password"?"Use an API token instead":"Use a username and password instead"})]})}const hE="modulepreload",gE=function(l){return"https://cdn.jsdelivr.net/npm/wgts-report@0.1.2/dist/"+l},ly={},mE=function(i,u,s){let c=Promise.resolve();if(u&&u.length>0){let h=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(S=>({status:"fulfilled",value:S}),S=>({status:"rejected",reason:S}))))};document.getElementsByTagName("link");const m=document.querySelector("meta[property=csp-nonce]"),v=(m==null?void 0:m.nonce)||(m==null?void 0:m.getAttribute("nonce"));c=h(u.map(x=>{if(x=gE(x),x in ly)return;ly[x]=!0;const y=x.endsWith(".css"),S=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${x}"]${S}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":hE,y||(b.as="script"),b.crossOrigin="",b.href=x,v&&b.setAttribute("nonce",v),document.head.appendChild(b),y)return new Promise((N,j)=>{b.addEventListener("load",N),b.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${x}`)))})}))}function f(h){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=h,window.dispatchEvent(m),!m.defaultPrevented)throw h}return c.then(h=>{for(const m of h||[])m.status==="rejected"&&f(m.reason);return i().catch(f)})},Ye={ink:"#18181b",ink2:"#52525b",muted:"#6e6e76",faint:"#71717a",card:"#ffffff",head:"#fafafb",line:"#e8e8ec",grid:"#f0f0f3",axis:"#d4d4d8",band:"#fafafb",cn2:"#dcdce1",guide:"#ececf0",gain:"#e8590c",gainStrong:"#c2410c",loss:"#1c7ed6",neutral:"#52525b",major:"#52525b",minor:"#a1a1aa",accent:"#6e5ad8",accentSoft:"#f3f1fd",ccfLine:"#6e5ad8",ccfFill:"#8e7fe6",dot:"#5a46c8",font:"Manrope, system-ui, sans-serif",mono:"JetBrains Mono, ui-monospace, monospace",reducedMotion:!1};function pE(l){if(!l||typeof getComputedStyle>"u")return Ye;const i=getComputedStyle(l),u=(s,c)=>i.getPropertyValue(s).trim()||c;return{ink:u("--ink",Ye.ink),ink2:u("--ink-2",Ye.ink2),muted:u("--muted",Ye.muted),faint:u("--faint",Ye.faint),card:u("--card",Ye.card),head:u("--head",Ye.head),line:u("--line",Ye.line),grid:u("--grid",Ye.grid),axis:u("--axis",Ye.axis),band:u("--band",Ye.band),cn2:u("--cn2",Ye.cn2),guide:u("--guide",Ye.guide),gain:u("--gain",Ye.gain),gainStrong:u("--gain-strong",Ye.gainStrong),loss:u("--loss",Ye.loss),neutral:u("--neutral",Ye.neutral),major:u("--ink-2",Ye.major),minor:u("--chev",Ye.minor),accent:u("--focus",Ye.accent),accentSoft:u("--hi-soft",Ye.accentSoft),ccfLine:u("--ccf-line",Ye.ccfLine),ccfFill:u("--ccf-fill",Ye.ccfFill),dot:u("--dot",Ye.dot),font:u("--font",Ye.font),mono:u("--mono",Ye.mono),reducedMotion:typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches}}function y0(l){return{confine:!0,backgroundColor:l.card,borderColor:l.line,borderWidth:1,padding:[10,12],textStyle:{color:l.ink,fontFamily:l.font,fontSize:12.5},extraCssText:"border-radius: 12px; box-shadow: 0 12px 32px -12px rgba(16,16,20,0.28);"}}function zi(l,i){const u=l.replace("#","");if(u.length!==6)return l;const[s,c,f]=[0,2,4].map(h=>parseInt(u.slice(h,h+2),16));return`rgba(${s}, ${c}, ${f}, ${i})`}const S0=()=>mE(()=>import("./EChart-BmUw3Vgc.js"),[]),vE=O.lazy(S0);function yE(){S0()}function x0(l){return g.jsx(O.Suspense,{fallback:g.jsx("div",{className:"skeleton",style:{height:l.height},"aria-hidden":!0}),children:g.jsx(vE,{...l})})}function b0(){const l=O.useRef(null),[i,u]=O.useState(null);return O.useLayoutEffect(()=>u(pE(l.current)),[]),[l,i]}function C0({top:l,distance:i=5,gap:u=6,rowGap:s=3}={}){let c=[],f=-1;return h=>{h.dataIndex<=f&&(c=[]),f=h.dataIndex;const{labelRect:m,rect:v}=h;let x=c.findIndex(j=>j+u<=m.x);x===-1&&(x=c.push(0)-1),c[x]=m.x+m.width;const y=m.height+s,S=l===void 0?v.y-i-m.height-x*y:l+x*y,b=m.x+m.width/2,N=S+m.height+2;return{y:S,align:"center",verticalAlign:"top",labelLinePoints:[[b,N],[b,Math.max(N,v.y-3)]]}}}const mt=1e3,E0=.35,SE=8,_d=.1;function Zo(l,i){return(Xo(l,i)??0)*mt}function Il(l){const[i,u]=Wo[l.replace(/^chr/,"")];return[i*mt,u*mt]}function xE(l,i,u){const[s,c]=l,f=Math.min(mt,Math.max(E0,(c-s)*u)),h=Math.min(Math.max(i-(i-s)/(c-s)*f,0),mt-f);return[h,h+f]}function bE(l,i){const u=l[1]-l[0],s=Math.min(Math.max(l[0]+i,0),mt-u);return[s,s+u]}function CE(l){for(const[i]of Gn){const[u,s]=Il(i);if(l>=u&&l<=s)return i}return null}function w0(l,i){const u=l.segments.flatMap(c=>i==="total"?[c.total_cn]:[c.major_cn,c.minor_cn]),s=Math.max(...u.map(c=>c??0));return Math.min(SE,Math.max(l.baseline+2,Math.ceil(s)))}function EE(l){const i=10**Math.floor(Math.log10(l)),u=l/i;return(u<1.5?1:u<3.5?2:u<7.5?5:10)*i}function R0(l,i,u=5){const s=Gn.filter(([b])=>{const[N,j]=Il(b);return j>l&&N<i});if(s.length!==1)return s.map(([b])=>{const[N,j]=Il(b);return{value:(N+j)/2,label:b}});const[c,f]=s[0],[h,m]=Il(c),v=(Math.max(l,h)-h)/(m-h)*f,x=(Math.min(i,m)-h)/(m-h)*f,y=EE(Math.max(x-v,1)/u),S=[];for(let b=Math.ceil(v/y)*y;b<=x;b+=y)S.push({value:h+b/f*(m-h),label:Wu(b,y)});return S}function _0(l,i){const u=new Map(l.map(s=>[s.value,s.label]));return{customValues:l.map(s=>s.value),formatter:s=>u.get(s)??"",hideOverlap:!0,color:i.faint,fontFamily:i.mono,fontSize:10.5,margin:10}}function wE(l,i){if(l<=.5&&i>=mt-.5)return null;const u=Iv(l/mt,"start"),s=Iv(i/mt,"end");if(u.chrom===s.chrom){const c=(s.pos-u.pos)/10;return`chr${u.chrom}: ${Wu(u.pos,c).replace(" Mb","")}–${Wu(s.pos,c)}`}return`chr${u.chrom}:${Wu(u.pos,1e6)} – chr${s.chrom}:${Wu(s.pos,1e6)}`}const RE={neutral:"Neutral",gain:"Gain",amp:"Amplification",loss:"Loss"},ay=["neutral","gain","amp","loss"];function _E(l,i){const u=`chr${l.chrom}:${l.start.toLocaleString("en-US")}–${l.end.toLocaleString("en-US")}`,s=l.major_cn!==null&&l.minor_cn!==null?` (${l.major_cn} + ${l.minor_cn})`:"",c=l.log2!==null?`, log2 ratio ${l.log2.toFixed(2)}`:"";return`<span style="font-weight:600">${RE[l.call??"neutral"]}</span>, ${l.total_cn??"?"} copies${s}<div style="font-family:var(--mono);font-size:11.5px;margin-top:3px">${u}${c}</div><div style="opacity:.7;font-size:11.5px;margin-top:5px">${i}</div>`}function TE(l){const i=new Map;for(const u of l){const s=u.gene??"?",c=i.get(s)??{gene:s,x:Zo(u.chrom,u.pos),changes:[]};u.protein_change&&c.changes.push(u.protein_change),i.set(s,c)}return[...i.values()].map(u=>({...u,changes:u.changes.join(", ")})).sort((u,s)=>u.x-s.x)}function NE(l,i,u,s=[]){const c=w0(l,i),f=l.segments.some(y=>Math.max(y.total_cn??0,y.major_cn??0)>c),h={neutral:u.minor,gain:u.gain,amp:u.gainStrong,loss:u.loss},m=(y,S=0)=>l.segments.flatMap((b,N)=>{const j=y(b);if(j===null)return[];const D=ay.indexOf(b.call??"neutral");return[[Zo(b.chrom,b.start),Zo(b.chrom,b.end),Math.min(j,c)+S,D,N]]}),v=(y,S,b,N)=>({type:"custom",id:y,name:S,data:b,encode:{x:[0,1],y:2},clip:!0,z:6,renderItem:(j,D)=>{const w=D.coord([D.value(0),D.value(2)]),C=D.coord([D.value(1),D.value(2)]),U=ay[D.value(3)],q=Math.max(C[0]-w[0],U==="neutral"?2:7),$={x1:w[0],y1:w[1],x2:w[0]+q,y2:w[1]};return{type:"group",children:[{type:"line",shape:$,style:{stroke:"rgba(0,0,0,0)",lineWidth:16}},{type:"line",shape:$,style:{stroke:N??h[U],lineWidth:5,lineCap:"round"},emphasis:{style:{lineWidth:8}}}]}},tooltip:{formatter:j=>_E(l.segments[j.data[4]],"Click to list the mutations in this segment")}}),x=[{id:"bands",type:"line",data:[[0,0]],symbol:"none",silent:!0,lineStyle:{opacity:0},markArea:{silent:!0,data:Gn.filter((y,S)=>S%2===0).map(([y])=>[{xAxis:Il(y)[0],itemStyle:{color:u.band}},{xAxis:Il(y)[1]}])},markLine:{silent:!0,symbol:"none",animation:!1,lineStyle:{color:u.axis,type:[5,4],width:1.25},label:{show:!0,position:"insideStartTop",formatter:`${l.baseline} copies`,color:u.faint,fontSize:10.5},data:[{yAxis:l.baseline}]}}];return i==="total"?x.push(v("cn-total","Copy number",m(y=>y.total_cn))):(x.push(v("cn-major","Major allele",m(y=>y.major_cn,_d),u.major)),x.push(v("cn-minor","Minor allele",m(y=>y.minor_cn,-_d),u.minor))),x.push({id:"drivers",type:"scatter",name:"Drivers",data:TE(s).map(y=>({value:[y.x,c],name:y.gene,protein:y.changes})),symbol:"triangle",symbolRotate:180,symbolSize:9,symbolOffset:[0,-11],itemStyle:{opacity:1,color:u.ink},cursor:"pointer",label:{show:!0,formatter:"{b}",position:"top",distance:3,color:u.ink2,fontSize:10.5,fontWeight:600,fontStyle:"italic"},labelLine:{show:!0,lineStyle:{color:u.axis,width:1}},labelLayout:C0({distance:3,rowGap:1}),emphasis:{scale:1.4},tooltip:{formatter:y=>`<span style="font-weight:600"><i>${y.name}</i></span> ${y.data.protein}<div style="opacity:.7;font-size:11.5px;margin-top:5px">Driver. Click to find it in the table</div>`},z:7}),x.push({id:"focus",type:"scatter",data:[],silent:!0,animation:!1,symbolSize:12,itemStyle:{opacity:1,color:u.card,borderColor:u.ink,borderWidth:2.5},label:{show:!0,position:"right",distance:8,color:u.ink,backgroundColor:u.card,borderColor:u.line,borderWidth:1,borderRadius:6,padding:[3,6],rich:{gene:{fontWeight:600,fontStyle:"italic",fontSize:11.5,color:u.ink},copies:{fontSize:11.5,color:u.muted,padding:[0,0,0,4]}}},markLine:{silent:!0,symbol:"none",animation:!1,lineStyle:{color:u.ink,type:"solid",width:1.25,opacity:.4},label:{show:!1},data:[]},z:8}),{animation:!u.reducedMotion,animationDuration:450,textStyle:{fontFamily:u.font},grid:{left:34,right:16,top:s.length?46:16,bottom:54},xAxis:{type:"value",min:0,max:mt,axisLine:{show:!1},axisTick:{show:!1},splitLine:{show:!1},axisLabel:_0(R0(0,mt),u)},yAxis:{type:"value",min:0,max:c,interval:1,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{color:u.faint,fontFamily:u.mono,fontSize:11,formatter:y=>y===c&&f?`${y}+`:`${y}`},splitLine:{lineStyle:{color:u.grid}}},tooltip:{trigger:"item",...y0(u)},dataZoom:[{type:"slider",xAxisIndex:0,filterMode:"none",height:10,bottom:6,borderColor:"transparent",backgroundColor:u.grid,fillerColor:zi(u.accent,.16),dataBackground:{lineStyle:{opacity:0},areaStyle:{opacity:0}},selectedDataBackground:{lineStyle:{opacity:0},areaStyle:{opacity:0}},handleIcon:"path://M2,0 h2 a2,2 0 0 1 2,2 v12 a2,2 0 0 1 -2,2 h-2 a2,2 0 0 1 -2,-2 v-12 a2,2 0 0 1 2,-2 z",handleSize:"140%",handleStyle:{color:u.card,borderColor:u.axis,borderWidth:1},moveHandleSize:0,showDetail:!1,brushSelect:!1,minValueSpan:E0}],series:x}}function ME(l,i,u){const s=i.replace(/^chr/,"");return l.segments.find(c=>c.chrom===s&&c.start<=u&&u<=c.end)}function OE(l,i,u){if(!l)return{series:[{id:"focus",data:[],markLine:{data:[]}}]};const s=w0(i,u),c=ME(i,l.chrom,l.pos),f=c?u==="total"?c.total_cn:c.major_cn:null,h=Zo(l.chrom,l.pos),m=Math.min(f??i.baseline,s)+(u==="allele"&&f!==null?_d:0),v=(c==null?void 0:c.total_cn)!==null&&(c==null?void 0:c.total_cn)!==void 0?`{copies|${c.total_cn} copies}`:"";return{series:[{id:"focus",data:[{value:[h,m],label:{formatter:`{gene|${l.gene??"?"}}${v}`}}],markLine:{data:[[{coord:[h,0]},{coord:[h,s]}]]}}]}}function Di(l,[i,u]){l==null||l.dispatchAction({type:"dataZoom",startValue:i,endValue:u})}function jE(l){var u;const i=((u=l.batch)==null?void 0:u[0])??l;return i.startValue!==void 0&&i.endValue!==void 0?[i.startValue,i.endValue]:i.start!==void 0&&i.end!==void 0?[i.start/100*mt,i.end/100*mt]:null}function AE({data:l,mode:i,drivers:u,focus:s,locate:c,chartRef:f,onWindow:h,onSegment:m,onGene:v}){const[x,y]=b0(),S=O.useRef([0,mt]),b=O.useMemo(()=>y?NE(l,i,y,u):null,[l,i,y,u]),N=O.useMemo(()=>OE(s,l,i),[s,l,i]),j=O.useMemo(()=>({datazoom:C=>{const U=jE(C),q=f.current;if(!U||!q||!y)return;S.current=U;const $=R0(...U,Math.max(2,Math.round(q.getWidth()/150)));q.setOption({xAxis:{axisLabel:_0($,y)}},{lazyUpdate:!0}),h(U)},click:C=>{var U;C.seriesId==="drivers"&&C.name?v(C.name):(U=C.seriesId)!=null&&U.startsWith("cn-")&&m(l.segments[C.data[4]])}}),[f,y,l,h,m,v]),D=O.useCallback(C=>{f.current=C;const U=C.getZr(),q=C.getDom(),$=I=>C.containPixel({gridIndex:0},I),F=I=>C.convertFromPixel({gridIndex:0},I)[0],te=I=>{const je=[I.offsetX,I.offsetY];if(!$(je))return;const ut=CE(F(je));ut&&Di(C,Il(ut))},k=I=>{if(!I.ctrlKey)return;const je=q.getBoundingClientRect(),ut=[I.clientX-je.left,I.clientY-je.top];if(!$(ut))return;I.preventDefault();const ke=Math.max(-50,Math.min(50,I.deltaY));Di(C,xE(S.current,F(ut),Math.exp(ke*.01)))};let Z=null;const de=I=>{Z=S.current[1]-S.current[0]<mt-.5&&$([I.offsetX,I.offsetY])?{pixel:I.offsetX,view:S.current}:null},ge=I=>{if(!Z)return;const je=F([I.offsetX,0])-F([Z.pixel,0]);Di(C,bE(Z.view,-je))},xe=()=>{Z=null};return U.on("dblclick",te),U.on("mousedown",de),U.on("mousemove",ge),U.on("mouseup",xe),U.on("globalout",xe),q.addEventListener("wheel",k,{passive:!1}),()=>{U.off("dblclick",te),U.off("mousedown",de),U.off("mousemove",ge),U.off("mouseup",xe),U.off("globalout",xe),q.removeEventListener("wheel",k),f.current=null}},[f]),w=O.useCallback(C=>{const[U,q]=S.current;(U>0||q<mt)&&Di(C,[U,q])},[]);return O.useEffect(()=>{c&&Di(f.current,Il(c.chrom))},[c,f]),g.jsx("div",{ref:x,className:"px-2 pt-1",children:b&&g.jsx(x0,{option:b,overlay:N,height:268,ariaLabel:`Copy number of ${l.sample} across the genome, against ${l.baseline} copies.`,onEvents:j,onReady:D,onDrawn:w})})}function Ju({color:l,label:i}){return g.jsxs("span",{className:"flex items-center gap-1.5",children:[g.jsx("span",{className:"h-1 w-3.5 rounded-sm",style:{background:l}}),i]})}function zE({envelope:l,loading:i,picked:u,sampleLabel:s,drivers:c,focus:f,locate:h,onSegment:m,onGene:v}){var w;const[x,y]=O.useState("total"),[S,b]=O.useState([0,mt]),N=O.useRef(null),j=((w=l==null?void 0:l.data)==null?void 0:w.allele_specific)??!1,D=wE(...S);return g.jsx(nE,{title:"Copy number",subtitle:`Copy number across the genome, ${s}`,info:"copyNumber",envelope:l,loading:i,picked:u,skeletonHeight:250,controls:g.jsxs(g.Fragment,{children:[D&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"mono text-xs",style:{color:"var(--ink-2)"},"aria-live":"polite",children:D}),g.jsx("button",{type:"button",className:"sc-ib sm","aria-label":"Show the whole genome",title:"Show the whole genome",onClick:()=>Di(N.current,[0,mt]),children:g.jsx(iC,{size:15,"aria-hidden":!0})})]}),g.jsx(nr,{label:"Copy number view",value:j?x:"total",onChange:y,options:[{value:"total",label:"Total"},{value:"allele",label:"Allele-specific",disabled:!j}]})]}),footer:g.jsxs("span",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[12.5px]",style:{color:"var(--ink-2)"},children:[x==="total"||!j?g.jsxs(g.Fragment,{children:[g.jsx(Ju,{color:"var(--gain)",label:"Gain"}),g.jsx(Ju,{color:"var(--gain-strong)",label:"Amplification"}),g.jsx(Ju,{color:"var(--loss)",label:"Loss"})]}):g.jsxs(g.Fragment,{children:[g.jsx(Ju,{color:"var(--ink-2)",label:"Major allele"}),g.jsx(Ju,{color:"var(--chev)",label:"Minor allele"})]}),g.jsx("span",{style:{color:"var(--faint)"},children:"Pinch or Ctrl-scroll to zoom, drag to pan. Double-click a chromosome to fill the view."})]}),children:C=>g.jsx(AE,{data:C,mode:j?x:"total",drivers:c,focus:f,locate:h,chartRef:N,onWindow:b,onSegment:m,onGene:v})})}function T0(l){const[i,u]=l.range;return[[i,0],...l.bins.map(s=>[(s.x0+s.x1)/2,s.n]),[u,0]]}function N0(l,i){for(let u=1;u<l.length;u++){const[s,c]=l[u-1],[f,h]=l[u];if(i<=f)return f===s?h:c+(i-s)/(f-s)*(h-c)}return l[l.length-1][1]}function M0(l){return l==="ccf"?"CCF":"VAF"}function Td(l,i){return Math.min(Math.max(i,l.range[0]),l.range[1])}const DE=1;function UE(l,i){const u=T0(l),s=M0(l.measure);return{animation:!i.reducedMotion,animationDuration:650,animationEasing:"cubicOut",textStyle:{fontFamily:i.font},grid:{left:16,right:22,top:44,bottom:40},xAxis:{type:"value",min:l.range[0],max:l.range[1],interval:l.measure==="ccf"?.25:.1,axisLine:{lineStyle:{color:i.axis}},axisTick:{show:!1},axisLabel:{color:i.faint,fontFamily:i.mono,fontSize:10.5,lineHeight:14,formatter:c=>l.measure==="ccf"?c===1?`1.0
|
|
253
253
|
{clonal|clonal}`:c.toFixed(2).replace(/0$/,""):c.toFixed(1),rich:{clonal:{color:i.faint,fontFamily:i.font,fontSize:10.5}}},splitLine:{show:!0,lineStyle:{color:i.grid}}},yAxis:{type:"value",show:!1,max:c=>Math.max(1,c.max)*1.25},tooltip:{trigger:"item",...y0(i)},brush:{xAxisIndex:0,seriesIndex:[DE],brushType:"lineX",brushMode:"single",transformable:!0,removeOnClick:!0,brushStyle:{color:zi(i.accent,.08),borderColor:zi(i.accent,.55),borderWidth:1},outOfBrush:{colorAlpha:.25},throttleType:"debounce",throttleDelay:120},series:[{id:"density",type:"line",name:s,data:u,smooth:.45,symbol:"none",silent:!0,lineStyle:{width:2.25,color:i.ccfLine},areaStyle:{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:zi(i.ccfFill,.26)},{offset:1,color:zi(i.ccfFill,.02)}]}},markLine:l.measure==="ccf"?{silent:!0,symbol:"none",animation:!1,lineStyle:{color:i.axis,type:[4,4],width:1.25},label:{show:!1},data:[{xAxis:1}]}:void 0},{id:"drivers",type:"scatter",name:"Drivers",data:[...l.drivers].sort((c,f)=>c.value-f.value).map(c=>({value:[Td(l,c.value),N0(u,Td(l,c.value))],name:c.gene??"?",protein:c.protein_change,actual:c.value})),symbolSize:10,cursor:"pointer",itemStyle:{opacity:1,color:i.dot,borderColor:i.card,borderWidth:2.5,shadowBlur:6,shadowColor:zi(i.dot,.3)},emphasis:{scale:1.5},label:{show:!0,formatter:"{b}",position:"top",distance:10,color:i.ink,fontWeight:600,fontStyle:"italic",fontSize:11.5},labelLine:{show:!0,lineStyle:{color:i.axis,width:1}},labelLayout:C0({top:4}),tooltip:{formatter:c=>`<span style="font-weight:600"><i>${c.name}</i></span> ${c.data.protein??""}<div style="margin-top:3px">${s} <span style="font-weight:600">${c.data.actual.toFixed(2)}</span></div><div style="opacity:.7;font-size:11.5px;margin-top:5px">Driver. Click to find it in the table</div>`},z:4},{id:"focus",type:"scatter",data:[],silent:!0,symbolSize:13,itemStyle:{opacity:1,color:i.card,borderColor:i.ink,borderWidth:2.5},label:{show:!0,position:"right",distance:8,color:i.ink,fontSize:11,fontWeight:600,backgroundColor:i.card,borderColor:i.line,borderWidth:1,borderRadius:6,padding:[3,6]},markLine:{silent:!0,symbol:"none",animation:!1,lineStyle:{color:i.ink,type:"solid",width:1.25,opacity:.45},label:{show:!1},data:[]},animation:!1,z:6}]}}function HE(l,i){const u=i?l.measure==="ccf"?i.ccf:i.vaf:null;if(u==null)return{series:[{id:"focus",data:[],markLine:{data:[]}}]};const s=Td(l,u),c=N0(T0(l),s);return{series:[{id:"focus",data:[{value:[s,c],label:{formatter:`${(i==null?void 0:i.gene)??"?"} ${u.toFixed(2)}`}}],markLine:{data:[[{coord:[s,0]},{coord:[s,c]}]]}}]}}function iy(l,i){l.dispatchAction({type:"takeGlobalCursor",key:"brush",brushOption:{brushType:"lineX",brushMode:"single"}}),l.dispatchAction({type:"brush",areas:i?[{brushType:"lineX",xAxisIndex:0,coordRange:i}]:[]})}const uy=l=>Math.round(l*100)/100;function VE({data:l,range:i,focus:u,onRange:s,onGene:c}){const[f,h]=b0(),m=O.useRef(null),v=O.useRef(i);v.current=i;const x=O.useMemo(()=>h?UE(l,h):null,[l,h]),y=O.useMemo(()=>HE(l,u),[l,u]),S=O.useMemo(()=>({brushEnd:D=>{const w=D.areas[0];if(!w)return s(null);const[C,U]=w.coordRange;s(U-C<.005?null:[uy(C),uy(U)])},click:D=>{D.seriesId==="drivers"&&D.name&&c(D.name)}}),[s,c]),b=O.useCallback(D=>(m.current=D,()=>{m.current=null}),[]),N=O.useCallback(D=>iy(D,v.current),[]);O.useEffect(()=>{m.current&&iy(m.current,i)},[i]);const j=M0(l.measure);return g.jsx("div",{ref:f,className:"strip-chart",children:x&&g.jsx(x0,{option:x,overlay:y,height:196,ariaLabel:`${j} of ${l.total} variants in ${l.sample}${l.drivers.length?`, with ${l.drivers.map(D=>`${D.gene} at ${D.value.toFixed(2)}`).join(", ")}`:""}.`,onEvents:S,onReady:b,onDrawn:N})})}function LE({envelope:l,loading:i,measure:u,onMeasure:s,range:c,focus:f,onRange:h,onGene:m}){const v=u==="ccf"?"Cancer cell fraction":"Variant allele fraction",x=(l==null?void 0:l.status)==="ok"?l.data:null;return g.jsxs("div",{className:"strip",children:[g.jsxs("div",{className:"strip-head",children:[g.jsx("span",{className:"text-[13px] font-semibold",children:v}),x&&g.jsxs("span",{className:"text-[12.5px]",style:{color:"var(--muted)"},children:[x.median!==null?`Median ${x.median.toFixed(2)}. `:"","Drag across the plot to filter the table."]}),g.jsx("span",{className:"flex-auto"}),g.jsx(nr,{label:"Measure",value:u,onChange:s,options:[{value:"ccf",label:"CCF"},{value:"vaf",label:"VAF"}]})]}),g.jsx(kd,{label:v,envelope:l,loading:i,skeletonHeight:180,children:y=>g.jsx(VE,{data:y,range:c,focus:f,onRange:h,onGene:m})})]})}const qE=Object.keys(r0),BE=Object.keys(c0);function sy(l,i){return l.includes(i)?l.filter(u=>u!==i):[...l,i]}function Xf({label:l,count:i,active:u,onClick:s}){return g.jsxs("button",{type:"button",className:"facet","aria-pressed":u,"data-empty":!u&&i===0,onClick:s,children:[g.jsx("span",{className:"facet-check","aria-hidden":!0,children:u&&g.jsx(Fb,{size:11,strokeWidth:3})}),g.jsx("span",{className:"truncate",children:l}),g.jsx("span",{className:"facet-n",children:i===void 0?"":i.toLocaleString("en-US")})]})}function GE({table:l,data:i,onChange:u}){const s=i==null?void 0:i.facets.effects,c=i==null?void 0:i.facets.flags,f=l.range;return g.jsxs("aside",{className:"facets","aria-label":"Filters",children:[g.jsxs("div",{className:"facet-group",role:"group","aria-label":"Effect",children:[g.jsx("span",{className:"facet-title",children:"Effect"}),qE.map(h=>g.jsx(Xf,{label:r0[h],count:s==null?void 0:s[h],active:l.effects.includes(h),onClick:()=>u({effects:sy(l.effects,h)})},h))]}),g.jsxs("div",{className:"facet-group",role:"group","aria-label":"Flags",children:[g.jsx("span",{className:"facet-title",children:"Flags"}),BE.map(h=>g.jsx(Xf,{label:c0[h],count:c==null?void 0:c[h],active:l.flags.includes(h),onClick:()=>u({flags:sy(l.flags,h)})},h))]}),(i==null?void 0:i.ffpe)&&g.jsxs("div",{className:"facet-group",role:"group","aria-label":"FFPE filter",children:[g.jsx("span",{className:"facet-title",children:"FFPE filter"}),g.jsx(Xf,{label:"Show filtered calls",count:i.ffpe.removed,active:l.ffpe,onClick:()=>u({ffpe:!l.ffpe})}),g.jsx("span",{className:"facet-note",children:i.ffpe.threshold!==null?`As in the report, calls FFPERASE scores above ${i.ffpe.threshold} are left out of the counts.`:"As in the report, calls its FFPE filter removes are left out of the counts."})]}),f&&g.jsxs("div",{className:"facet-group",role:"group","aria-label":"Range",children:[g.jsxs("span",{className:"facet-title",children:[f.measure==="ccf"?"CCF":"VAF"," range"]}),g.jsxs("span",{className:"facet-range",children:[g.jsxs("span",{className:"mono",children:[f.low.toFixed(2)," – ",f.high.toFixed(2)]}),g.jsx("button",{type:"button",className:"sc-ib xs","aria-label":"Remove the range",title:"Remove the range",onClick:()=>u({range:null}),children:g.jsx($d,{size:13,"aria-hidden":!0})})]})]}),o0(l)>0&&g.jsx("button",{type:"button",className:"facet-clear",onClick:()=>u({q:"",effects:[],flags:[],range:null}),children:"Clear all filters"})]})}function FE({value:l,onChange:i}){const[u,s]=O.useState(l),c=O.useRef(null),f=O.useRef(i);f.current=i,O.useEffect(()=>s(l),[l]),O.useEffect(()=>{if(u===l)return;const m=window.setTimeout(()=>f.current(u),250);return()=>window.clearTimeout(m)},[u,l]),O.useEffect(()=>{const m=v=>{var x,y,S;v.key!=="/"||v.metaKey||v.ctrlKey||v.altKey||(y=(x=v.target)==null?void 0:x.closest)!=null&&y.call(x,"input, textarea, select, [contenteditable]")||(v.preventDefault(),(S=c.current)==null||S.focus())};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[]);const h=()=>{s(""),i("")};return g.jsxs("div",{className:"field search-field",children:[g.jsx(Po,{size:15,"aria-hidden":!0,style:{color:"var(--chev)"}}),g.jsx("input",{ref:c,type:"search","aria-label":"Search mutations",placeholder:"Search gene, change or locus",value:u,onChange:m=>s(m.target.value),onKeyDown:m=>{m.key==="Escape"&&h(),m.key==="Enter"&&i(u)}}),u?g.jsx("button",{type:"button",className:"search-clear","aria-label":"Clear the search",onClick:h,children:g.jsx($d,{size:14,"aria-hidden":!0})}):g.jsx("kbd",{className:"kbd","aria-hidden":!0,children:"/"})]})}/**
|
|
254
254
|
* table-core
|
|
255
255
|
*
|
|
@@ -271,4 +271,4 @@ Error generating stack: `+a.message+`
|
|
|
271
271
|
* LICENSE.md file in the root directory of this source tree.
|
|
272
272
|
*
|
|
273
273
|
* @license MIT
|
|
274
|
-
*/function cy(l,i){return l?Aw(l)?O.createElement(l,i):l:null}function Aw(l){return zw(l)||typeof l=="function"||Dw(l)}function zw(l){return typeof l=="function"&&(()=>{const i=Object.getPrototypeOf(l);return i.prototype&&i.prototype.isReactComponent})()}function Dw(l){return typeof l=="object"&&typeof l.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(l.$$typeof.description)}function Uw(l){const i={state:{},onStateChange:()=>{},renderFallbackValue:null,...l},[u]=O.useState(()=>({current:Nw(i)})),[s,c]=O.useState(()=>u.current.initialState);return u.current.setOptions(f=>({...f,...l,state:{...s,...l.state},onStateChange:h=>{c(h),l.onStateChange==null||l.onStateChange(h)}})),u.current}function td({text:l,query:i}){const u=i.trim();if(!u||zC(u))return g.jsx(g.Fragment,{children:l});const s=[],c=l.toLowerCase(),f=u.toLowerCase();let h=0;for(let m=c.indexOf(f);m!==-1;m=c.indexOf(f,h))m>h&&s.push(l.slice(h,m)),s.push(g.jsx("mark",{children:l.slice(m,m+u.length)},m)),h=m+u.length;return s.push(l.slice(h)),g.jsx(g.Fragment,{children:s})}function fy({value:l,max:i,clonal:u}){return l===null?g.jsx("span",{style:{color:"var(--chev)"},children:"–"}):g.jsxs("span",{className:"vbar",children:[g.jsx("span",{className:"vbar-n",children:bd(l)}),g.jsxs("span",{className:"vbar-track","aria-hidden":!0,children:[g.jsx("span",{className:"vbar-fill",style:{width:`${Math.min(l/i,1)*100}%`}}),u&&g.jsx("span",{className:"vbar-tick",style:{left:`${1/i*100}%`}})]})]})}function Hw({variant:l,showDriver:i}){return g.jsxs("span",{className:"flex flex-wrap gap-1.5",children:[i&&l.is_driver&&g.jsx("span",{className:"sc-pill p-neu",children:"Driver"}),l.hotspot&&g.jsx("span",{className:"sc-pill p-hot",children:"Hotspot"}),l.in_dmp&&g.jsx("span",{className:"sc-pill p-dmp",children:"In DMP"}),l.ffpe_removed&&g.jsx("span",{className:"sc-pill p-ffpe",title:"Left out of the report's counts by its FFPE artifact filter",children:"FFPE filtered"})]})}function Vw(l){return`${l.ref}>${l.alt}`}function Lw({variant:l,onLocate:i}){const[u,s]=O.useState(!1),c=`chr${l.chrom}:${l.pos}`,f=[["Variant",`${l.kind==="snv"?"SNV":l.kind==="indel"?"Indel":l.kind}, ${Vw(l)}`],["Reads",l.depth!==null?`${l.alt_reads??"?"} of ${l.depth}`:"–"],["Normal VAF",bd(l.normal_vaf)],["Mutant copies",VC(l.mut_alleles)??"–"],["Consequence",(l.consequence??l.effect??"–").replace(/&/g,", ")],["COSMIC",HC(l.cosmic)??"–"],...l.ffpe_score!==null||l.ffpe_removed?[["FFPE artifact score",l.ffpe_score!==null?bd(l.ffpe_score):"Not scored"]]:[],["Expression",l.gene_tpm!==null?`${l.gene_tpm.toFixed(1)} TPM`:"–"],["Gene role",LC(l)??"–"]];return g.jsxs("div",{className:"vt-detail-body",children:[g.jsx("dl",{className:"vt-facts",children:f.map(([h,m])=>g.jsxs("div",{children:[g.jsx("dt",{children:h}),g.jsx("dd",{children:m})]},h))}),g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.jsxs("button",{type:"button",className:"sc-btn sc-b2 sm",onClick:()=>i(l),children:[g.jsx(Kb,{size:14,"aria-hidden":!0}),"Show on copy number"]}),g.jsxs("button",{type:"button",className:"sc-btn sc-b2 sm",onClick:async()=>{try{await navigator.clipboard.writeText(c),s(!0),window.setTimeout(()=>s(!1),1500)}catch{window.prompt("Copy this locus",c)}},children:[g.jsx(Xb,{size:14,"aria-hidden":!0}),u?"Copied":"Copy locus"]})]})]})}function qw({data:l,pageSize:i,onPage:u,onPageSize:s}){const c=Math.max(1,Math.ceil(l.total/l.page_size)),f=(l.page-1)*l.page_size+1,h=Math.min(l.page*l.page_size,l.total),m=v=>v.toLocaleString("en-US");return g.jsxs("div",{className:"pager",children:[g.jsx("span",{children:l.total===0?"No mutations":`${m(f)}–${m(h)} of ${m(l.total)}`}),g.jsxs("span",{className:"flex items-center gap-4",children:[g.jsxs("label",{className:"flex items-center gap-2",children:["Rows",g.jsx("select",{value:i,onChange:v=>s(Number(v.target.value)),children:MC.map(v=>g.jsx("option",{value:v,children:v},v))})]}),g.jsxs("span",{children:["Page ",m(l.page)," of ",m(c)]}),g.jsxs("span",{className:"flex gap-1",children:[g.jsx("button",{type:"button",className:"sc-ib sm","aria-label":"Previous page",disabled:l.page<=1,onClick:()=>u(l.page-1),children:g.jsx($b,{size:15,"aria-hidden":!0})}),g.jsx("button",{type:"button",className:"sc-ib sm","aria-label":"Next page",disabled:l.page>=c,onClick:()=>u(l.page+1),children:g.jsx(Fd,{size:15,"aria-hidden":!0})})]})]})]})}function Bw({sort:l,current:i,onSort:u}){const s=i.replace(/^-/,"")===l.key,c=i.startsWith("-"),f=s?c?l.key:`-${l.key}`:l.descFirst?`-${l.key}`:l.key;return g.jsxs("button",{type:"button",className:"vt-sort","data-active":s,onClick:()=>u(f),title:`Sort by ${l.label.toLowerCase()}`,children:[l.label,s&&c?g.jsx(Xv,{size:12,"aria-hidden":!0}):s?g.jsx(qb,{size:12,"aria-hidden":!0}):g.jsx(Xv,{size:12,"aria-hidden":!0,className:"vt-sort-idle"})]})}function Gw({data:l,table:i,fetching:u,showCcf:s,onTable:c,onHover:f,onLocate:h}){const[m,v]=O.useState({}),x=i.q,y=i.scope!=="drivers",S=O.useMemo(()=>[{id:"expand",header:()=>g.jsx("span",{className:"sr-only",children:"Details"}),meta:{className:"pin vt-x"},cell:({row:w})=>g.jsx("button",{type:"button",className:"vt-expand","aria-expanded":w.getIsExpanded(),"aria-label":`Details of ${w.original.gene??"this mutation"} ${w.original.protein_change??""}`.trim(),onClick:C=>{C.stopPropagation(),w.toggleExpanded()},onFocus:()=>f(w.original),children:g.jsx(Fd,{size:14,"aria-hidden":!0})})},{id:"gene",header:"Gene",meta:{className:"pin vt-g",sorts:[{key:"gene",label:"Gene"},{key:"position",label:"Position"}]},cell:({row:{original:w}})=>g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"vt-gene",children:g.jsx(td,{text:w.gene??"–",query:x})}),g.jsx("span",{className:"vt-sub mono",children:fC(w.chrom,w.pos)})]})},{id:"change",header:"Change",cell:({row:{original:w}})=>g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"mono block text-[12.5px] font-medium",children:g.jsx(td,{text:w.protein_change??"–",query:x})}),w.cdna_change&&g.jsx("span",{className:"vt-sub mono",children:g.jsx(td,{text:w.cdna_change,query:x})})]})},{id:"effect",header:"Effect",meta:{sorts:[{key:"effect",label:"Effect"}]},cell:({row:{original:w}})=>g.jsx("span",{className:w.effect_class==="truncating"?"font-semibold":void 0,children:cC(w.consequence,w.effect)})},{id:"vaf",header:"VAF",meta:{className:"n",sorts:[{key:"vaf",label:"VAF",descFirst:!0}]},cell:({row:{original:w}})=>g.jsx(fy,{value:w.vaf,max:1})},...s?[{id:"ccf",header:"CCF",meta:{className:"n",sorts:[{key:"ccf",label:"CCF",descFirst:!0}]},cell:({row:{original:w}})=>g.jsx(fy,{value:w.ccf,max:1.25,clonal:!0})}]:[],{id:"flags",header:"Flags",cell:({row:{original:w}})=>g.jsx(Hw,{variant:w,showDriver:y})}],[x,y,s,f]),b=Uw({data:l.rows,columns:S,getRowId:jC,getCoreRowModel:Mw(),getExpandedRowModel:Ow(),getRowCanExpand:()=>!0,manualPagination:!0,state:{expanded:m},onExpandedChange:v}),N=i.sort.replace(/^-/,""),j=b.getVisibleLeafColumns().length,D=o0(i)>0;return g.jsxs("div",{className:"flex min-w-0 flex-col",children:[g.jsxs("div",{className:"vt-scroll",onMouseLeave:()=>f(null),"aria-busy":u,children:[u&&g.jsx("div",{className:"vt-progress","aria-hidden":!0}),g.jsxs("table",{className:"vt",children:[g.jsx("thead",{children:b.getHeaderGroups().map(w=>g.jsx("tr",{children:w.headers.map(C=>{var $;const U=C.column.columnDef.meta,q=($=U==null?void 0:U.sorts)==null?void 0:$.some(F=>F.key===N);return g.jsx("th",{className:U==null?void 0:U.className,"aria-sort":q?i.sort.startsWith("-")?"descending":"ascending":void 0,children:U!=null&&U.sorts?g.jsx("span",{className:"vt-sorts",children:U.sorts.map(F=>g.jsx(Bw,{sort:F,current:i.sort,onSort:te=>c({sort:te})},F.key))}):cy(C.column.columnDef.header,C.getContext())},C.id)})},w.id))}),g.jsxs("tbody",{children:[b.getRowModel().rows.map(w=>g.jsxs(O.Fragment,{children:[g.jsx("tr",{className:"vt-row","data-expanded":w.getIsExpanded(),onClick:()=>w.toggleExpanded(),onMouseEnter:()=>f(w.original),children:w.getVisibleCells().map(C=>{var U;return g.jsx("td",{className:(U=C.column.columnDef.meta)==null?void 0:U.className,children:cy(C.column.columnDef.cell,C.getContext())},C.id)})}),w.getIsExpanded()&&g.jsx("tr",{className:"vt-detail",children:g.jsx("td",{colSpan:j,children:g.jsx(Lw,{variant:w.original,onLocate:h})})})]},w.id)),l.rows.length===0&&g.jsx("tr",{children:g.jsx("td",{colSpan:j,children:g.jsx("div",{className:"vt-empty",children:D?g.jsxs(g.Fragment,{children:["No mutations match these filters.",g.jsx("button",{type:"button",className:"sc-btn sc-b2 sm",onClick:()=>c({q:"",effects:[],flags:[],range:null}),children:"Clear all filters"})]}):`No ${i.scope==="all"?"":`${i.scope} `}mutations in this sample.`})})})]})]})]}),g.jsx(qw,{data:l,pageSize:i.pageSize,onPage:w=>c({page:w}),onPageSize:w=>c({pageSize:w})})]})}const Fw=O.forwardRef(function({variants:i,variantsLoading:u,variantsFetching:s,density:c,densityLoading:f,picked:h,measure:m,onMeasure:v,table:x,onTable:y,hovered:S,onHover:b,onLocate:N,showCcf:j},D){var te,k;const w=(i==null?void 0:i.status)==="ok"?i.data??void 0:void 0,C=w==null?void 0:w.counts,U=(c==null?void 0:c.status)==="ok"?(te=c.data)==null?void 0:te.total:void 0,q=(c==null?void 0:c.status)==="ok"?(k=c.data)==null?void 0:k.ffpe:null,$=Z=>Z===void 0?"":Z.toLocaleString("en-US"),F=x.range&&x.range.measure===m?[x.range.low,x.range.high]:null;return g.jsxs(v0,{ref:D,title:"Mutations",subtitle:U!==void 0?`${$(U)} PASS SNVs and indels${q&&!q.shown?", after the FFPE filter":""}`:void 0,lineage:p0(c==null?void 0:c.lineage,i==null?void 0:i.lineage),picked:h,className:"mut",info:"mutations",controls:g.jsxs(g.Fragment,{children:[g.jsx(FE,{value:x.q,onChange:Z=>y({q:Z})}),g.jsx(nr,{label:"Which mutations",value:x.scope,onChange:Z=>y({scope:Z,sort:s0[Z]}),options:[{value:"drivers",label:g.jsxs(g.Fragment,{children:["Drivers",g.jsx("span",{className:"seg-n",children:$(C==null?void 0:C.drivers)})]})},{value:"coding",label:g.jsxs(g.Fragment,{children:["Coding",g.jsx("span",{className:"seg-n",children:$(C==null?void 0:C.coding)})]})},{value:"all",label:g.jsxs(g.Fragment,{children:["All",g.jsx("span",{className:"seg-n",children:$(C==null?void 0:C.all)})]})}]})]}),children:[g.jsx(LE,{envelope:c,loading:f,measure:m,onMeasure:v,range:F,focus:S,onRange:Z=>{!Z&&!x.range||y({range:Z?{measure:m,low:Z[0],high:Z[1]}:null})},onGene:Z=>y({q:Z})}),w&&i&&i.warnings.length>0&&g.jsx("div",{className:"px-5 py-2 text-xs",role:"note",style:{color:"var(--warn-ink)"},children:i.warnings.join(" ")}),w?g.jsxs("div",{className:"mut-body",children:[g.jsx(GE,{table:x,data:w,onChange:y}),g.jsx(Gw,{data:w,table:x,fetching:s,showCcf:j,onTable:y,onHover:b,onLocate:N})]}):g.jsx("div",{className:"mut-rule",children:g.jsx(kd,{label:"mutations",envelope:i,loading:u,skeletonHeight:240,children:()=>null})})]})});function $w(l){var s;const i=l.samples.filter(c=>c.category==="TUMOR");return(s=i.find(c=>Object.values(c.datasets??{}).some(f=>Object.values(f).includes("ok")))??i[0]??l.samples[0])==null?void 0:s.id}const Qw=[];function Yw(l){const i=O.useRef(!1);return O.useEffect(()=>{let u=0;const s=()=>{i.current=!0,window.clearTimeout(u),u=window.setTimeout(()=>i.current=!1,150)};return window.addEventListener("scroll",s,{passive:!0}),()=>{window.removeEventListener("scroll",s),window.clearTimeout(u)}},[]),O.useCallback(u=>{(u===null||!i.current)&&l(u)},[l])}function kw(l){var u,s;const i=(s=(u=l==null?void 0:l.samples.find(c=>{var f;return(f=c.disease)==null?void 0:f.name}))==null?void 0:u.disease)==null?void 0:s.name;return i?i.charAt(0)+i.slice(1).toLowerCase():void 0}function nd(l,i){const u=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;l==null||l.scrollIntoView({behavior:u?"auto":"smooth",block:i})}function Xw(){var Yt,fl,pn,ea,ta,Yn,Ba,na,Ga,Pi,vn,Fa,$a;const{individual:l=""}=lb(),[i,u]=Ab(),s=i.get("version")??void 0,[c,f]=O.useState(null),[h,m]=O.useState(null),[v,x]=O.useState(ty),[y,S]=O.useState(null),b=Yw(S),[N,j]=O.useState(null),D=O.useRef(null),[w,C]=O.useState(null),[U,q]=O.useState(!0),$=O.useRef(null),F=wy();O.useEffect(yE,[]),O.useEffect(()=>{const P=w;if(!P||typeof IntersectionObserver>"u")return;const ct=new IntersectionObserver(([an])=>q(an.isIntersecting),{rootMargin:"-72px 0px 0px 0px",threshold:0});return ct.observe(P),()=>ct.disconnect()},[w]),O.useEffect(()=>XC(l),[l]);const te=O.useCallback(P=>x(ct=>({...ct,page:1,...P})),[]),k=O.useCallback(P=>{te({q:DC(P.chrom,P.start,P.end),scope:"all",sort:"position"}),nd($.current,"start")},[te]),Z=O.useCallback(P=>{te({q:P}),nd($.current,"start")},[te]),de=O.useCallback(P=>{j({chrom:P.chrom,pos:P.pos,gene:P.gene,nonce:Date.now()}),nd(D.current,"center")},[]),ge=qC(l,s),xe=ge.data,I=(xe==null?void 0:xe.status)==="ok"?xe.data??void 0:void 0,je=i.get("sample")??(I?$w(I):void 0),ut=I==null?void 0:I.samples.find(P=>P.id===je),ke=(ut==null?void 0:ut.category)==="TUMOR"?je:void 0,X=h??((I==null?void 0:I.mode)==="unmatched"?"vaf":"ccf"),ue=BC(l,I?je:void 0,s),ie=GC(l,s),Oe=FC(l,ke,s),be=$C(l,ke,X,v.ffpe,s),st=QC(l,ke,v,s),Rt=(fl=(Yt=ie.data)==null?void 0:Yt.data)==null?void 0:fl.samples.find(P=>P.sample===je),$n=O.useMemo(()=>(Rt==null?void 0:Rt.drivers)??Qw,[Rt]),T=O.useMemo(()=>y?{chrom:y.chrom,pos:y.pos,gene:y.gene}:N,[y,N]),Q=O.useRef(null),[ee,le]=O.useState(null),Ce=[ue,Oe,be,st,ie].some(P=>P.isFetching);O.useEffect(()=>{if(!ee||ee.sample!==je||Ce)return;const P=Q.current,ct=P==null?void 0:P.querySelector("main"),an=P==null?void 0:P.querySelector(".topbar");if(!P||!ct||!an||!w)return le(null);const Wi=P.getBoundingClientRect().top+window.scrollY,eu=Math.max(Wi+an.offsetHeight+ct.offsetHeight,window.innerHeight),ar=w.getBoundingClientRect().bottom+window.scrollY-an.offsetHeight+2,ir=Math.max(0,Math.min(ar,eu-window.innerHeight)),_t=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollTo({top:ir,behavior:_t?"auto":"smooth"});const ur=window.setTimeout(()=>le(null),_t?0:520);return()=>window.clearTimeout(ur)},[ee,je,Ce,w]),O.useEffect(()=>{if(!ee)return;const P=window.setTimeout(()=>le(null),4e3);return()=>window.clearTimeout(P)},[ee]);const Ne=P=>{var ct;P!==je&&(le({sample:P,height:document.documentElement.scrollHeight-(((ct=Q.current)==null?void 0:ct.getBoundingClientRect().top)??0)-window.scrollY}),_e("sample",P))},_e=(P,ct)=>{const an=new URLSearchParams(i);an.set(P,ct),u(an,{replace:!1}),f(null),x(ty()),S(null),j(null)},ne=[ge,ue,ie,Oe,be,st].map(P=>P.error);if(ne.some(P=>P instanceof tr))return g.jsx("div",{className:`wgts ${Fn.theme}`,children:g.jsx("main",{className:"page",children:g.jsx(dE,{onSignedIn:()=>F.invalidateQueries()})})});const oe=ne.find(P=>P instanceof a0),Ot=ut&&I?Qd(ut.id,I.individual.id):"",cl=I&&je&&I.analyses[je]||[],Qn=(I==null?void 0:I.failures.filter(P=>P.sample===je))??[],ln=new Set(cl.map(wt)),We=new Set,Ae=P=>P==null?void 0:P.forEach(ct=>ln.has(wt(ct))&&We.add(wt(ct)));for(const P of((ea=(pn=ue.data)==null?void 0:pn.data)==null?void 0:ea.metrics)??[])Rd.includes(P.key)&&Ae(P.sources);Ae((ta=ie.data)==null?void 0:ta.lineage),Ae((Yn=Oe.data)==null?void 0:Yn.lineage),Ae((Ba=be.data)==null?void 0:Ba.lineage),Ae((na=st.data)==null?void 0:na.lineage);for(const P of cl)P.state==="failed"&&Qn.length>0&&We.add(wt(P));return g.jsxs("div",{className:`wgts ${Fn.theme}`,children:[g.jsx(IC,{individualId:l,sampleCount:(I==null?void 0:I.samples.length)??0,mode:I==null?void 0:I.mode,fingerprint:Rt,analyses:cl,onPage:We,sampleLabel:Ot,picked:c,onPick:f}),g.jsxs("div",{ref:Q,className:"page",style:ee?{minHeight:ee.height}:void 0,children:[g.jsx(l0,{individualId:l,subtitle:[kw(I),(Ga=I==null?void 0:I.individual.sex)==null?void 0:Ga.toLowerCase()].filter(Boolean).join(", ")||void 0,patientIcon:I?g.jsx(yC,{sex:I.individual.sex}):void 0,compact:I&&je?g.jsx(wC,{data:I,sampleId:je,fingerprint:((Pi=ie.data)==null?void 0:Pi.data)??void 0,onSample:Ne}):void 0,showCompact:!U}),g.jsxs("main",{className:"flex flex-col gap-5 px-8 pt-[18px] pb-10",children:[ge.isPending&&g.jsx("div",{className:"skeleton h-24","aria-label":"Loading the patient"}),oe&&g.jsx("div",{className:"sc-card px-6 py-5",children:g.jsx(_a,{envelope:{status:"error",data:null,lineage:[],warnings:[oe.message]}})}),ge.isError&&!oe&&g.jsx("div",{className:"sc-card px-6 py-5",children:g.jsx(_a,{envelope:{status:"error",data:null,lineage:[],warnings:[ge.error.message]}})}),xe&&xe.status!=="ok"&&g.jsx("div",{className:"sc-card px-6 py-5",children:g.jsx(_a,{envelope:xe})}),(xe==null?void 0:xe.status)==="ok"&&xe.warnings.length>0&&g.jsx("div",{className:"sc-card px-6 py-4",children:g.jsx(_a,{envelope:{...xe,status:"missing"}})}),I&&je&&g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:C,children:g.jsx(iE,{data:I,fingerprint:((vn=ie.data)==null?void 0:vn.data)??void 0,sampleId:je,onSample:P=>_e("sample",P),onVersion:P=>_e("version",P)})}),g.jsx(fE,{sampleLabel:Ot,failures:Qn,analyses:cl}),ke?g.jsxs(g.Fragment,{children:[g.jsx(cE,{sampleLabel:`${Ot} tumour`,fingerprint:Rt,metrics:ue.data,picked:c,lineage:p0((Fa=ue.data)==null?void 0:Fa.lineage,($a=ie.data)==null?void 0:$a.lineage)}),g.jsx("div",{ref:D,children:g.jsx(zE,{envelope:Oe.data,loading:Oe.isPending,picked:c,sampleLabel:Ot,drivers:$n,focus:T,locate:N,onSegment:k,onGene:Z})}),g.jsx(Fw,{ref:$,variants:st.data,variantsLoading:st.isPending,variantsFetching:st.isFetching&&st.isPlaceholderData,density:be.data,densityLoading:be.isPending,picked:c,measure:X,onMeasure:P=>{m(P),v.range&&v.range.measure!==P&&te({range:null})},table:v,onTable:te,hovered:y,onHover:b,onLocate:de,showCcf:I.mode!=="unmatched"})]}):g.jsx("div",{className:"sc-card px-6 py-5",children:g.jsx(_a,{envelope:{status:"missing",data:null,lineage:[],warnings:[`${Ot} is a normal sample. Its germline and quality panels arrive with those sections.`]}})})]})]})]})]})}const Zw=new p2({defaultOptions:{queries:{staleTime:6e4,refetchOnWindowFocus:!1}}});function Kw(){return g.jsx(Qx,{client:Zw,children:g.jsx(Tb,{basename:Fn.basePath,children:g.jsxs(Sb,{children:[g.jsx(pd,{path:"/",element:g.jsx(KC,{})}),g.jsx(pd,{path:"/:individual",element:g.jsx(Xw,{})})]})})})}$x.createRoot(document.getElementById("root")).render(g.jsx(O.StrictMode,{children:g.jsx(Kw,{})}));export{g as j,O as r};
|
|
274
|
+
*/function cy(l,i){return l?Aw(l)?O.createElement(l,i):l:null}function Aw(l){return zw(l)||typeof l=="function"||Dw(l)}function zw(l){return typeof l=="function"&&(()=>{const i=Object.getPrototypeOf(l);return i.prototype&&i.prototype.isReactComponent})()}function Dw(l){return typeof l=="object"&&typeof l.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(l.$$typeof.description)}function Uw(l){const i={state:{},onStateChange:()=>{},renderFallbackValue:null,...l},[u]=O.useState(()=>({current:Nw(i)})),[s,c]=O.useState(()=>u.current.initialState);return u.current.setOptions(f=>({...f,...l,state:{...s,...l.state},onStateChange:h=>{c(h),l.onStateChange==null||l.onStateChange(h)}})),u.current}function td({text:l,query:i}){const u=i.trim();if(!u||zC(u))return g.jsx(g.Fragment,{children:l});const s=[],c=l.toLowerCase(),f=u.toLowerCase();let h=0;for(let m=c.indexOf(f);m!==-1;m=c.indexOf(f,h))m>h&&s.push(l.slice(h,m)),s.push(g.jsx("mark",{children:l.slice(m,m+u.length)},m)),h=m+u.length;return s.push(l.slice(h)),g.jsx(g.Fragment,{children:s})}function fy({value:l,max:i,clonal:u}){return l===null?g.jsx("span",{style:{color:"var(--chev)"},children:"–"}):g.jsxs("span",{className:"vbar",children:[g.jsx("span",{className:"vbar-n",children:bd(l)}),g.jsxs("span",{className:"vbar-track","aria-hidden":!0,children:[g.jsx("span",{className:"vbar-fill",style:{width:`${Math.min(l/i,1)*100}%`}}),u&&g.jsx("span",{className:"vbar-tick",style:{left:`${1/i*100}%`}})]})]})}function Hw({variant:l,showDriver:i}){return g.jsxs("span",{className:"flex flex-wrap gap-1.5",children:[i&&l.is_driver&&g.jsx("span",{className:"sc-pill p-neu",children:"Driver"}),l.hotspot&&g.jsx("span",{className:"sc-pill p-hot",children:"Hotspot"}),l.in_dmp&&g.jsx("span",{className:"sc-pill p-dmp",children:"In DMP"}),l.ffpe_removed&&g.jsx("span",{className:"sc-pill p-ffpe",title:"Left out of the report's counts by its FFPE artifact filter",children:"FFPE filtered"})]})}function Vw(l){return`${l.ref}>${l.alt}`}function Lw({variant:l,onLocate:i}){const[u,s]=O.useState(!1),c=`chr${l.chrom}:${l.pos}`,f=[["Variant",`${l.kind==="snv"?"SNV":l.kind==="indel"?"Indel":l.kind}, ${Vw(l)}`],...l.depth!==null?[["Reads",`${l.alt_reads??"?"} of ${l.depth}`]]:[],["Normal VAF",bd(l.normal_vaf)],["Mutant copies",VC(l.mut_alleles)??"–"],["Consequence",(l.consequence??l.effect??"–").replace(/&/g,", ")],["COSMIC",HC(l.cosmic)??"–"],...l.ffpe_score!==null||l.ffpe_removed?[["FFPE artifact score",l.ffpe_score!==null?bd(l.ffpe_score):"Not scored"]]:[],["Expression",l.gene_tpm!==null?`${l.gene_tpm.toFixed(1)} TPM`:"–"],["Gene role",LC(l)??"–"]];return g.jsxs("div",{className:"vt-detail-body",children:[g.jsx("dl",{className:"vt-facts",children:f.map(([h,m])=>g.jsxs("div",{children:[g.jsx("dt",{children:h}),g.jsx("dd",{children:m})]},h))}),g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.jsxs("button",{type:"button",className:"sc-btn sc-b2 sm",onClick:()=>i(l),children:[g.jsx(Kb,{size:14,"aria-hidden":!0}),"Show on copy number"]}),g.jsxs("button",{type:"button",className:"sc-btn sc-b2 sm",onClick:async()=>{try{await navigator.clipboard.writeText(c),s(!0),window.setTimeout(()=>s(!1),1500)}catch{window.prompt("Copy this locus",c)}},children:[g.jsx(Xb,{size:14,"aria-hidden":!0}),u?"Copied":"Copy locus"]})]})]})}function qw({data:l,pageSize:i,onPage:u,onPageSize:s}){const c=Math.max(1,Math.ceil(l.total/l.page_size)),f=(l.page-1)*l.page_size+1,h=Math.min(l.page*l.page_size,l.total),m=v=>v.toLocaleString("en-US");return g.jsxs("div",{className:"pager",children:[g.jsx("span",{children:l.total===0?"No mutations":`${m(f)}–${m(h)} of ${m(l.total)}`}),g.jsxs("span",{className:"flex items-center gap-4",children:[g.jsxs("label",{className:"flex items-center gap-2",children:["Rows",g.jsx("select",{value:i,onChange:v=>s(Number(v.target.value)),children:MC.map(v=>g.jsx("option",{value:v,children:v},v))})]}),g.jsxs("span",{children:["Page ",m(l.page)," of ",m(c)]}),g.jsxs("span",{className:"flex gap-1",children:[g.jsx("button",{type:"button",className:"sc-ib sm","aria-label":"Previous page",disabled:l.page<=1,onClick:()=>u(l.page-1),children:g.jsx($b,{size:15,"aria-hidden":!0})}),g.jsx("button",{type:"button",className:"sc-ib sm","aria-label":"Next page",disabled:l.page>=c,onClick:()=>u(l.page+1),children:g.jsx(Fd,{size:15,"aria-hidden":!0})})]})]})]})}function Bw({sort:l,current:i,onSort:u}){const s=i.replace(/^-/,"")===l.key,c=i.startsWith("-"),f=s?c?l.key:`-${l.key}`:l.descFirst?`-${l.key}`:l.key;return g.jsxs("button",{type:"button",className:"vt-sort","data-active":s,onClick:()=>u(f),title:`Sort by ${l.label.toLowerCase()}`,children:[l.label,s&&c?g.jsx(Xv,{size:12,"aria-hidden":!0}):s?g.jsx(qb,{size:12,"aria-hidden":!0}):g.jsx(Xv,{size:12,"aria-hidden":!0,className:"vt-sort-idle"})]})}function Gw({data:l,table:i,fetching:u,showCcf:s,onTable:c,onHover:f,onLocate:h}){const[m,v]=O.useState({}),x=i.q,y=i.scope!=="drivers",S=O.useMemo(()=>[{id:"expand",header:()=>g.jsx("span",{className:"sr-only",children:"Details"}),meta:{className:"pin vt-x"},cell:({row:w})=>g.jsx("button",{type:"button",className:"vt-expand","aria-expanded":w.getIsExpanded(),"aria-label":`Details of ${w.original.gene??"this mutation"} ${w.original.protein_change??""}`.trim(),onClick:C=>{C.stopPropagation(),w.toggleExpanded()},onFocus:()=>f(w.original),children:g.jsx(Fd,{size:14,"aria-hidden":!0})})},{id:"gene",header:"Gene",meta:{className:"pin vt-g",sorts:[{key:"gene",label:"Gene"},{key:"position",label:"Position"}]},cell:({row:{original:w}})=>g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"vt-gene",children:g.jsx(td,{text:w.gene??"–",query:x})}),g.jsx("span",{className:"vt-sub mono",children:fC(w.chrom,w.pos)})]})},{id:"change",header:"Change",cell:({row:{original:w}})=>g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"mono block text-[12.5px] font-medium",children:g.jsx(td,{text:w.protein_change??"–",query:x})}),w.cdna_change&&g.jsx("span",{className:"vt-sub mono",children:g.jsx(td,{text:w.cdna_change,query:x})})]})},{id:"effect",header:"Effect",meta:{sorts:[{key:"effect",label:"Effect"}]},cell:({row:{original:w}})=>g.jsx("span",{className:w.effect_class==="truncating"?"font-semibold":void 0,children:cC(w.consequence,w.effect)})},{id:"vaf",header:"VAF",meta:{className:"n",sorts:[{key:"vaf",label:"VAF",descFirst:!0}]},cell:({row:{original:w}})=>g.jsx(fy,{value:w.vaf,max:1})},...s?[{id:"ccf",header:"CCF",meta:{className:"n",sorts:[{key:"ccf",label:"CCF",descFirst:!0}]},cell:({row:{original:w}})=>g.jsx(fy,{value:w.ccf,max:1.25,clonal:!0})}]:[],{id:"flags",header:"Flags",cell:({row:{original:w}})=>g.jsx(Hw,{variant:w,showDriver:y})}],[x,y,s,f]),b=Uw({data:l.rows,columns:S,getRowId:jC,getCoreRowModel:Mw(),getExpandedRowModel:Ow(),getRowCanExpand:()=>!0,manualPagination:!0,state:{expanded:m},onExpandedChange:v}),N=i.sort.replace(/^-/,""),j=b.getVisibleLeafColumns().length,D=o0(i)>0;return g.jsxs("div",{className:"flex min-w-0 flex-col",children:[g.jsxs("div",{className:"vt-scroll",onMouseLeave:()=>f(null),"aria-busy":u,children:[u&&g.jsx("div",{className:"vt-progress","aria-hidden":!0}),g.jsxs("table",{className:"vt",children:[g.jsx("thead",{children:b.getHeaderGroups().map(w=>g.jsx("tr",{children:w.headers.map(C=>{var $;const U=C.column.columnDef.meta,q=($=U==null?void 0:U.sorts)==null?void 0:$.some(F=>F.key===N);return g.jsx("th",{className:U==null?void 0:U.className,"aria-sort":q?i.sort.startsWith("-")?"descending":"ascending":void 0,children:U!=null&&U.sorts?g.jsx("span",{className:"vt-sorts",children:U.sorts.map(F=>g.jsx(Bw,{sort:F,current:i.sort,onSort:te=>c({sort:te})},F.key))}):cy(C.column.columnDef.header,C.getContext())},C.id)})},w.id))}),g.jsxs("tbody",{children:[b.getRowModel().rows.map(w=>g.jsxs(O.Fragment,{children:[g.jsx("tr",{className:"vt-row","data-expanded":w.getIsExpanded(),onClick:()=>w.toggleExpanded(),onMouseEnter:()=>f(w.original),children:w.getVisibleCells().map(C=>{var U;return g.jsx("td",{className:(U=C.column.columnDef.meta)==null?void 0:U.className,children:cy(C.column.columnDef.cell,C.getContext())},C.id)})}),w.getIsExpanded()&&g.jsx("tr",{className:"vt-detail",children:g.jsx("td",{colSpan:j,children:g.jsx(Lw,{variant:w.original,onLocate:h})})})]},w.id)),l.rows.length===0&&g.jsx("tr",{children:g.jsx("td",{colSpan:j,children:g.jsx("div",{className:"vt-empty",children:D?g.jsxs(g.Fragment,{children:["No mutations match these filters.",g.jsx("button",{type:"button",className:"sc-btn sc-b2 sm",onClick:()=>c({q:"",effects:[],flags:[],range:null}),children:"Clear all filters"})]}):`No ${i.scope==="all"?"":`${i.scope} `}mutations in this sample.`})})})]})]})]}),g.jsx(qw,{data:l,pageSize:i.pageSize,onPage:w=>c({page:w}),onPageSize:w=>c({pageSize:w})})]})}const Fw=O.forwardRef(function({variants:i,variantsLoading:u,variantsFetching:s,density:c,densityLoading:f,picked:h,measure:m,onMeasure:v,table:x,onTable:y,hovered:S,onHover:b,onLocate:N,showCcf:j},D){var te,k;const w=(i==null?void 0:i.status)==="ok"?i.data??void 0:void 0,C=w==null?void 0:w.counts,U=(c==null?void 0:c.status)==="ok"?(te=c.data)==null?void 0:te.total:void 0,q=(c==null?void 0:c.status)==="ok"?(k=c.data)==null?void 0:k.ffpe:null,$=Z=>Z===void 0?"":Z.toLocaleString("en-US"),F=x.range&&x.range.measure===m?[x.range.low,x.range.high]:null;return g.jsxs(v0,{ref:D,title:"Mutations",subtitle:U!==void 0?`${$(U)} PASS SNVs and indels${q&&!q.shown?", after the FFPE filter":""}`:void 0,lineage:p0(c==null?void 0:c.lineage,i==null?void 0:i.lineage),picked:h,className:"mut",info:"mutations",controls:g.jsxs(g.Fragment,{children:[g.jsx(FE,{value:x.q,onChange:Z=>y({q:Z})}),g.jsx(nr,{label:"Which mutations",value:x.scope,onChange:Z=>y({scope:Z,sort:s0[Z]}),options:[{value:"drivers",label:g.jsxs(g.Fragment,{children:["Drivers",g.jsx("span",{className:"seg-n",children:$(C==null?void 0:C.drivers)})]})},{value:"coding",label:g.jsxs(g.Fragment,{children:["Coding",g.jsx("span",{className:"seg-n",children:$(C==null?void 0:C.coding)})]})},{value:"all",label:g.jsxs(g.Fragment,{children:["All",g.jsx("span",{className:"seg-n",children:$(C==null?void 0:C.all)})]})}]})]}),children:[g.jsx(LE,{envelope:c,loading:f,measure:m,onMeasure:v,range:F,focus:S,onRange:Z=>{!Z&&!x.range||y({range:Z?{measure:m,low:Z[0],high:Z[1]}:null})},onGene:Z=>y({q:Z})}),w&&i&&i.warnings.length>0&&g.jsx("div",{className:"px-5 py-2 text-xs",role:"note",style:{color:"var(--warn-ink)"},children:i.warnings.join(" ")}),w?g.jsxs("div",{className:"mut-body",children:[g.jsx(GE,{table:x,data:w,onChange:y}),g.jsx(Gw,{data:w,table:x,fetching:s,showCcf:j,onTable:y,onHover:b,onLocate:N})]}):g.jsx("div",{className:"mut-rule",children:g.jsx(kd,{label:"mutations",envelope:i,loading:u,skeletonHeight:240,children:()=>null})})]})});function $w(l){var s;const i=l.samples.filter(c=>c.category==="TUMOR");return(s=i.find(c=>Object.values(c.datasets??{}).some(f=>Object.values(f).includes("ok")))??i[0]??l.samples[0])==null?void 0:s.id}const Qw=[];function Yw(l){const i=O.useRef(!1);return O.useEffect(()=>{let u=0;const s=()=>{i.current=!0,window.clearTimeout(u),u=window.setTimeout(()=>i.current=!1,150)};return window.addEventListener("scroll",s,{passive:!0}),()=>{window.removeEventListener("scroll",s),window.clearTimeout(u)}},[]),O.useCallback(u=>{(u===null||!i.current)&&l(u)},[l])}function kw(l){var u,s;const i=(s=(u=l==null?void 0:l.samples.find(c=>{var f;return(f=c.disease)==null?void 0:f.name}))==null?void 0:u.disease)==null?void 0:s.name;return i?i.charAt(0)+i.slice(1).toLowerCase():void 0}function nd(l,i){const u=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;l==null||l.scrollIntoView({behavior:u?"auto":"smooth",block:i})}function Xw(){var Yt,fl,pn,ea,ta,Yn,Ba,na,Ga,Pi,vn,Fa,$a;const{individual:l=""}=lb(),[i,u]=Ab(),s=i.get("version")??void 0,[c,f]=O.useState(null),[h,m]=O.useState(null),[v,x]=O.useState(ty),[y,S]=O.useState(null),b=Yw(S),[N,j]=O.useState(null),D=O.useRef(null),[w,C]=O.useState(null),[U,q]=O.useState(!0),$=O.useRef(null),F=wy();O.useEffect(yE,[]),O.useEffect(()=>{const P=w;if(!P||typeof IntersectionObserver>"u")return;const ct=new IntersectionObserver(([an])=>q(an.isIntersecting),{rootMargin:"-72px 0px 0px 0px",threshold:0});return ct.observe(P),()=>ct.disconnect()},[w]),O.useEffect(()=>XC(l),[l]);const te=O.useCallback(P=>x(ct=>({...ct,page:1,...P})),[]),k=O.useCallback(P=>{te({q:DC(P.chrom,P.start,P.end),scope:"all",sort:"position"}),nd($.current,"start")},[te]),Z=O.useCallback(P=>{te({q:P}),nd($.current,"start")},[te]),de=O.useCallback(P=>{j({chrom:P.chrom,pos:P.pos,gene:P.gene,nonce:Date.now()}),nd(D.current,"center")},[]),ge=qC(l,s),xe=ge.data,I=(xe==null?void 0:xe.status)==="ok"?xe.data??void 0:void 0,je=i.get("sample")??(I?$w(I):void 0),ut=I==null?void 0:I.samples.find(P=>P.id===je),ke=(ut==null?void 0:ut.category)==="TUMOR"?je:void 0,X=h??((I==null?void 0:I.mode)==="unmatched"?"vaf":"ccf"),ue=BC(l,I?je:void 0,s),ie=GC(l,s),Oe=FC(l,ke,s),be=$C(l,ke,X,v.ffpe,s),st=QC(l,ke,v,s),Rt=(fl=(Yt=ie.data)==null?void 0:Yt.data)==null?void 0:fl.samples.find(P=>P.sample===je),$n=O.useMemo(()=>(Rt==null?void 0:Rt.drivers)??Qw,[Rt]),T=O.useMemo(()=>y?{chrom:y.chrom,pos:y.pos,gene:y.gene}:N,[y,N]),Q=O.useRef(null),[ee,le]=O.useState(null),Ce=[ue,Oe,be,st,ie].some(P=>P.isFetching);O.useEffect(()=>{if(!ee||ee.sample!==je||Ce)return;const P=Q.current,ct=P==null?void 0:P.querySelector("main"),an=P==null?void 0:P.querySelector(".topbar");if(!P||!ct||!an||!w)return le(null);const Wi=P.getBoundingClientRect().top+window.scrollY,eu=Math.max(Wi+an.offsetHeight+ct.offsetHeight,window.innerHeight),ar=w.getBoundingClientRect().bottom+window.scrollY-an.offsetHeight+2,ir=Math.max(0,Math.min(ar,eu-window.innerHeight)),_t=typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches;window.scrollTo({top:ir,behavior:_t?"auto":"smooth"});const ur=window.setTimeout(()=>le(null),_t?0:520);return()=>window.clearTimeout(ur)},[ee,je,Ce,w]),O.useEffect(()=>{if(!ee)return;const P=window.setTimeout(()=>le(null),4e3);return()=>window.clearTimeout(P)},[ee]);const Ne=P=>{var ct;P!==je&&(le({sample:P,height:document.documentElement.scrollHeight-(((ct=Q.current)==null?void 0:ct.getBoundingClientRect().top)??0)-window.scrollY}),_e("sample",P))},_e=(P,ct)=>{const an=new URLSearchParams(i);an.set(P,ct),u(an,{replace:!1}),f(null),x(ty()),S(null),j(null)},ne=[ge,ue,ie,Oe,be,st].map(P=>P.error);if(ne.some(P=>P instanceof tr))return g.jsx("div",{className:`wgts ${Fn.theme}`,children:g.jsx("main",{className:"page",children:g.jsx(dE,{onSignedIn:()=>F.invalidateQueries()})})});const oe=ne.find(P=>P instanceof a0),Ot=ut&&I?Qd(ut.id,I.individual.id):"",cl=I&&je&&I.analyses[je]||[],Qn=(I==null?void 0:I.failures.filter(P=>P.sample===je))??[],ln=new Set(cl.map(wt)),We=new Set,Ae=P=>P==null?void 0:P.forEach(ct=>ln.has(wt(ct))&&We.add(wt(ct)));for(const P of((ea=(pn=ue.data)==null?void 0:pn.data)==null?void 0:ea.metrics)??[])Rd.includes(P.key)&&Ae(P.sources);Ae((ta=ie.data)==null?void 0:ta.lineage),Ae((Yn=Oe.data)==null?void 0:Yn.lineage),Ae((Ba=be.data)==null?void 0:Ba.lineage),Ae((na=st.data)==null?void 0:na.lineage);for(const P of cl)P.state==="failed"&&Qn.length>0&&We.add(wt(P));return g.jsxs("div",{className:`wgts ${Fn.theme}`,children:[g.jsx(IC,{individualId:l,sampleCount:(I==null?void 0:I.samples.length)??0,mode:I==null?void 0:I.mode,fingerprint:Rt,analyses:cl,onPage:We,sampleLabel:Ot,picked:c,onPick:f}),g.jsxs("div",{ref:Q,className:"page",style:ee?{minHeight:ee.height}:void 0,children:[g.jsx(l0,{individualId:l,subtitle:[kw(I),(Ga=I==null?void 0:I.individual.sex)==null?void 0:Ga.toLowerCase()].filter(Boolean).join(", ")||void 0,patientIcon:I?g.jsx(yC,{sex:I.individual.sex}):void 0,compact:I&&je?g.jsx(wC,{data:I,sampleId:je,fingerprint:((Pi=ie.data)==null?void 0:Pi.data)??void 0,onSample:Ne}):void 0,showCompact:!U}),g.jsxs("main",{className:"flex flex-col gap-5 px-8 pt-[18px] pb-10",children:[ge.isPending&&g.jsx("div",{className:"skeleton h-24","aria-label":"Loading the patient"}),oe&&g.jsx("div",{className:"sc-card px-6 py-5",children:g.jsx(_a,{envelope:{status:"error",data:null,lineage:[],warnings:[oe.message]}})}),ge.isError&&!oe&&g.jsx("div",{className:"sc-card px-6 py-5",children:g.jsx(_a,{envelope:{status:"error",data:null,lineage:[],warnings:[ge.error.message]}})}),xe&&xe.status!=="ok"&&g.jsx("div",{className:"sc-card px-6 py-5",children:g.jsx(_a,{envelope:xe})}),(xe==null?void 0:xe.status)==="ok"&&xe.warnings.length>0&&g.jsx("div",{className:"sc-card px-6 py-4",children:g.jsx(_a,{envelope:{...xe,status:"missing"}})}),I&&je&&g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:C,children:g.jsx(iE,{data:I,fingerprint:((vn=ie.data)==null?void 0:vn.data)??void 0,sampleId:je,onSample:P=>_e("sample",P),onVersion:P=>_e("version",P)})}),g.jsx(fE,{sampleLabel:Ot,failures:Qn,analyses:cl}),ke?g.jsxs(g.Fragment,{children:[g.jsx(cE,{sampleLabel:`${Ot} tumour`,fingerprint:Rt,metrics:ue.data,picked:c,lineage:p0((Fa=ue.data)==null?void 0:Fa.lineage,($a=ie.data)==null?void 0:$a.lineage)}),g.jsx("div",{ref:D,children:g.jsx(zE,{envelope:Oe.data,loading:Oe.isPending,picked:c,sampleLabel:Ot,drivers:$n,focus:T,locate:N,onSegment:k,onGene:Z})}),g.jsx(Fw,{ref:$,variants:st.data,variantsLoading:st.isPending,variantsFetching:st.isFetching&&st.isPlaceholderData,density:be.data,densityLoading:be.isPending,picked:c,measure:X,onMeasure:P=>{m(P),v.range&&v.range.measure!==P&&te({range:null})},table:v,onTable:te,hovered:y,onHover:b,onLocate:de,showCcf:I.mode!=="unmatched"})]}):g.jsx("div",{className:"sc-card px-6 py-5",children:g.jsx(_a,{envelope:{status:"missing",data:null,lineage:[],warnings:[`${Ot} is a normal sample. Its germline and quality panels arrive with those sections.`]}})})]})]})]})]})}const Zw=new p2({defaultOptions:{queries:{staleTime:6e4,refetchOnWindowFocus:!1}}});function Kw(){return g.jsx(Qx,{client:Zw,children:g.jsx(Tb,{basename:Fn.basePath,children:g.jsxs(Sb,{children:[g.jsx(pd,{path:"/",element:g.jsx(KC,{})}),g.jsx(pd,{path:"/:individual",element:g.jsx(Xw,{})})]})})})}$x.createRoot(document.getElementById("root")).render(g.jsx(O.StrictMode,{children:g.jsx(Kw,{})}));export{g as j,O as r};
|
package/dist/index.html
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
// isabl_ui's dev server, so source links open there.
|
|
16
16
|
window.$isabl = { basePath: "/wgts", isablUiUrl: "http://localhost:5173" };
|
|
17
17
|
</script>
|
|
18
|
-
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/wgts-report@0.1.
|
|
19
|
-
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/wgts-report@0.1.
|
|
18
|
+
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/wgts-report@0.1.2/dist/assets/wgts-report.js"></script>
|
|
19
|
+
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/wgts-report@0.1.2/dist/assets/wgts-report.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|
|
22
22
|
<div id="root"></div>
|