"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[4806],{74806:(e,a,i)=>{i.r(a),i.d(a,{default:()=>D});var s=i(7552),t=i(67112),n=i(99546),l=i(76218),r=i(61282),o=i(93062),d=i(10240),p=i(30698),c=i(69092),u=i(68446),y=i(36422),g=i(80256),h=i(91476),f=i(69500);const D=(0,u.observer)(function(e){const{model:a,handleClose:i}=e,[u,D]=(0,s.useState)(""),[m,k]=(0,s.useState)(),[$,v]=(0,s.useState)(!1),[A,C]=(0,s.useState)(),x=/^[A-Za-z][A-Za-z0-9]$/.exec(u),L=2===u.length&&!x,j=(0,n.useDebounce)(u,1e3),[b,w]=(0,s.useState)("");return(0,s.useEffect)(()=>{(async()=>{try{if(!L){C(void 0),v(!0);const e=await(0,g.X)({self:a,tag:j,blocks:(0,n.getContainingView)(a).staticBlocks});k(e)}}catch(e){console.error(e),C(e)}finally{v(!1)}})()},[a,L,j]),(0,f.jsxs)(t.Dialog,{open:!0,onClose:i,title:"Group by",children:[(0,f.jsxs)(l.A,{children:[(0,f.jsx)(r.A,{children:'NOTE: this will create new session tracks with the "filter by" set to the values chosen here rather than affecting the current track state'}),(0,f.jsxs)(o.A,{fullWidth:!0,value:b,onChange:e=>{w(e.target.value)},label:"Group by...",select:!0,children:[(0,f.jsx)(d.A,{value:"strand",children:"Strand"}),(0,f.jsx)(d.A,{value:"tag",children:"Tag"})]}),"tag"===b?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(r.A,{color:"textSecondary",children:"Examples: HP for haplotype, RG for read group, etc."}),(0,f.jsx)(o.A,{value:u,onChange:e=>{D(e.target.value)},placeholder:"Enter tag name",error:L,helperText:L?"Not a valid tag":"",autoComplete:"off","data-testid":"group-tag-name",slotProps:{htmlInput:{maxLength:2,"data-testid":"group-tag-name-input"}}}),A?(0,f.jsx)(t.ErrorMessage,{error:A}):$?(0,f.jsx)(t.LoadingEllipses,{title:"Loading unique tags"}):m?(0,f.jsxs)("div",{children:[(0,f.jsxs)("div",{children:["Found unique ",u," values:"]}),(0,f.jsx)("div",{children:m.join(", ")})]}):null]}):null]}),(0,f.jsxs)(p.A,{children:[(0,f.jsx)(c.A,{variant:"contained",color:"primary",type:"submit",disabled:!m,autoFocus:!0,onClick:()=>{const e=(0,n.getContainingTrack)(a),s=structuredClone((0,y.getSnapshot)(e.configuration)),t=(0,n.getSession)(a),l=(0,n.getContainingView)(a);if("tag"===b){if(m){const e=[...m,void 0];for(const a of e){const e=`${s.trackId}-${u}:${a}-${+Date.now()}-sessionTrack`;t.addTrackConf({...s,trackId:e,name:`${s.name} (${u}:${a})`,displays:[{displayId:`${e}-LinearAlignmentsDisplay`,type:"LinearAlignmentsDisplay",pileupDisplay:{displayId:`${e}-LinearAlignmentsDisplay-LinearPileupDisplay`,type:"LinearPileupDisplay",filterBy:{...h.JD,tagFilter:{tag:u,value:a}}}}]}),l.showTrack(e)}}}else if("strand"===b){const e=`${s.trackId}-${u}:(-)-${+Date.now()}-sessionTrack`,a=`${s.trackId}-${u}:(+)-${+Date.now()}-sessionTrack`;t.addTrackConf({...s,trackId:e,name:`${s.name} (-)`,displays:[{displayId:`${e}-LinearAlignmentsDisplay`,type:"LinearAlignmentsDisplay",pileupDisplay:{displayId:`${e}-LinearAlignmentsDisplay-LinearPileupDisplay`,type:"LinearPileupDisplay",filterBy:h.CQ}},{displayId:`${e}-LinearSNPCoverageDisplay`,type:"LinearSNPCoverageDisplay",filterBy:h.CQ}]}),t.addTrackConf({...s,trackId:a,name:`${s.name} (+)`,displays:[{displayId:`${a}-LinearAlignmentsDisplay`,type:"LinearAlignmentsDisplay",pileupDisplay:{displayId:`${a}-LinearAlignmentsDisplay-LinearPileupDisplay`,type:"LinearPileupDisplay",filterBy:h.Ar}},{displayId:`${a}-LinearSNPCoverageDisplay`,type:"LinearSNPCoverageDisplay",filterBy:h.Ar}]}),l.showTrack(e),l.showTrack(a)}i()},children:"Submit"}),(0,f.jsx)(c.A,{variant:"contained",color:"secondary",onClick:()=>{i()},children:"Cancel"})]})]})})}}]);
//# sourceMappingURL=4806.a75455c0.chunk.js.map