"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[4806],{74806:(e,t,a)=>{a.r(t),a.d(t,{default:()=>p});var n=a(7552),l=a(68446),o=a(29499),r=a(36715),s=a(33371),c=a(32808),i=a(1343),u=a(58507),d=a(5401),g=a(49823),f=a(36422),m=a(99546),h=a(20561);const p=(0,l.observer)((function(e){const{model:t,handleClose:a}=e,[l,p]=(0,n.useState)(""),[b,E]=(0,n.useState)(),[k,v]=(0,n.useState)(!1),[y,w]=(0,n.useState)(),[C,S]=(0,n.useState)(!0),A=/^[A-Za-z][A-Za-z0-9]$/.exec(l),T=2===l.length&&!A,$=(0,m.useDebounce)(l,1e3);return(0,n.useEffect)((()=>{(async()=>{try{if(!T){w(void 0),v(!0);const e=await(0,h.s_)({self:t,tag:$,blocks:(0,m.getContainingView)(t).staticBlocks});E(e)}}catch(e){console.error(e),w(e)}finally{v(!1)}})()}),[t,T,$]),n.createElement(g.Dialog,{open:!0,onClose:a,title:"Group by tag"},n.createElement(o.A,null,n.createElement(r.A,null,"Set the tag to group by. NOTE: this will make a set of fully functional subtracks with the filter by by default set to the values of the tag that are visible in the current view"),n.createElement(r.A,{color:"textSecondary"},"Examples: HP for haplotype, RG for read group, etc."),n.createElement(s.A,{control:n.createElement(c.A,{checked:C,onChange:()=>{S(!C)}}),label:"Make a new subtrack for undefined values of tag as well?"}),n.createElement(i.A,{value:l,onChange:e=>{p(e.target.value)},placeholder:"Enter tag name",inputProps:{maxLength:2,"data-testid":"group-tag-name-input"},error:T,helperText:T?"Not a valid tag":"",autoComplete:"off","data-testid":"group-tag-name"}),y?n.createElement(g.ErrorMessage,{error:y}):k?n.createElement(g.LoadingEllipses,{title:"Loading unique tags"}):b?n.createElement("div",null,n.createElement("div",null,"Found unique ",l," values:"),n.createElement("div",null,b.join(", "))):null),n.createElement(u.A,null,n.createElement(d.A,{variant:"contained",color:"primary",type:"submit",disabled:!b,autoFocus:!0,onClick:()=>{const e=(0,m.getContainingTrack)(t),n=(o=(0,f.getSnapshot)(e.configuration),JSON.parse(JSON.stringify(o)));var o;const r=(0,m.getSession)(t);if(b){const e=[...b];C&&e.push(void 0);for(const a of e){const e=r.addTrackConf({...n,trackId:`${n.trackId}-${l}:${a}-${+Date.now()}-sessionTrack`,name:`${n.name} ${l}:${a}`,displays:void 0});(0,m.getContainingView)(t).showTrack(e.trackId).displays[0].setFilterBy({flagInclude:0,flagExclude:1540,tagFilter:{tag:l,value:a}})}}a()}},"Submit"),n.createElement(d.A,{variant:"contained",color:"secondary",onClick:()=>{a()}},"Cancel")))}))}}]);
//# sourceMappingURL=4806.7e497d7a.chunk.js.map