"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[3523],{59985:(e,t,s)=>{s.d(t,{A:()=>o});var n=s(29772),r=s(69500);const o=(0,n.A)((0,r.jsx)("path",{d:"M19 9h-4V3H9v6H5l7 7zM5 18v2h14v-2z"}),"GetApp")},83523:(e,t,s)=>{s.r(t),s.d(t,{default:()=>y});var n=s(7552),r=s(67112),o=s(99546),a=s(8328),l=s(59985),i=s(76218),c=s(93062),d=s(36866),u=s(7946),h=s(22762),f=s(61282),g=s(30698),m=s(69092),b=s(31409),p=s.n(b),w=s(45465),x=s(68446),A=s(75785),j=s(68584),C=s(69500);const v=(0,A.n9)()({dialogContent:{width:"80em"},textAreaFont:{fontFamily:"Courier New"},ml:{marginLeft:10}}),y=(0,x.observer)(function({model:e,handleClose:t}){const{classes:s}=v(),[b,x]=(0,n.useState)(),[A,y]=(0,n.useState)(),[S,q]=(0,n.useState)(!1),[k,$]=(0,n.useState)(!1),[E,N]=(0,n.useState)(!1),{leftOffset:R,rightOffset:F}=e,O=void 0===A;(0,n.useEffect)(()=>{const t=new AbortController;return(async()=>{try{const t=e.getSelectedRegions(R,F);if(0===t.length)throw new Error("Selected region is out of bounds");y(await async function(e,t){const s=(0,o.getSession)(e),{leftOffset:n,rightOffset:r}=e;if(!n||!r)throw new Error("no offsets on model to use for range");if(new Set(t.map(e=>e.assemblyName)).size>1)throw new Error("not able to fetch sequences from multiple assemblies currently");const{rpcManager:a,assemblyManager:l}=s,i=n.assemblyName||r.assemblyName||"",c=l.get(i);if(!c)throw new Error(`assembly ${i} not found`);const d=(0,j.getConf)(c,["sequence","adapter"]),u="getSequence";return a.call(u,"CoreGetFeatures",{adapterConfig:d,regions:t,sessionId:u})}(e,t))}catch(e){console.error(e),x(e)}})(),()=>{t.abort()}},[e,R,F]);const _=A?A.map(e=>{let t=e.get("seq");const s=e.get("refName"),n=e.get("start")+1,r=e.get("end"),a=`${s}:${n}-${r}`;if(t?.length!==r-n+1)throw new Error(`${a} returned ${t.length.toLocaleString()} bases, but should have returned ${(r-n).toLocaleString()}`);return S&&(t=(0,o.reverse)(t)),E&&(t=(0,o.complement)(t)),{header:a+(S?"-rev":"")+(E?"-comp":""),seq:t}}).map(e=>{return`>${e.header}\n${t=e.seq,t.replaceAll(/(.{1,80})/g,"$1\n").trimEnd()}`;var t}).join("\n"):"",M=!!_&&_.length>1e6;return(0,C.jsxs)(r.Dialog,{maxWidth:"xl",open:!0,onClose:()=>{t(),e.setOffsets()},title:"Reference sequence",children:[(0,C.jsxs)(i.A,{children:[b?(0,C.jsx)(r.ErrorMessage,{error:b}):O?(0,C.jsx)(r.LoadingEllipses,{message:"Retrieving sequences"}):null,(0,C.jsx)(c.A,{"data-testid":"rubberband-sequence",variant:"outlined",multiline:!0,minRows:5,maxRows:10,disabled:M,className:s.dialogContent,fullWidth:!0,value:M?"Reference sequence too large to display, use the download FASTA button":_,slotProps:{input:{readOnly:!0,classes:{input:s.textAreaFont}}}}),(0,C.jsxs)(d.A,{children:[(0,C.jsx)(u.A,{control:(0,C.jsx)(h.A,{value:S,onChange:e=>{q(e.target.checked)}}),label:"Reverse sequence"}),(0,C.jsx)(u.A,{control:(0,C.jsx)(h.A,{value:E,onChange:e=>{N(e.target.checked)}}),label:"Complement sequence"})]}),(0,C.jsx)(f.A,{style:{margin:10},children:'Note: Check both boxes for the "reverse complement"'})]}),(0,C.jsxs)(g.A,{children:[(0,C.jsx)(m.A,{onClick:()=>{p()(_),$(!0),setTimeout(()=>{$(!1)},500)},disabled:O||!!b||M,color:"primary",startIcon:(0,C.jsx)(a.A,{}),children:k?"Copied":"Copy to clipboard"}),(0,C.jsx)(m.A,{onClick:()=>{(0,w.saveAs)(new Blob([_||""],{type:"text/x-fasta;charset=utf-8"}),"jbrowse_ref_seq.fa")},disabled:O||!!b,color:"primary",startIcon:(0,C.jsx)(l.A,{}),children:"Download FASTA"}),(0,C.jsx)(m.A,{onClick:t,variant:"contained",children:"Close"})]})]})})}}]);
//# sourceMappingURL=3523.a8c76bdb.chunk.js.map