"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[4439],{24439:function(e,t,n){n.r(t),n.d(t,{default:function(){return R}});var r=n(32723),o=n(96234),s=n(34795),a=n(96902),c=n(91188),l=n(52809),i=n(35388),u=n(80691),f=n(78888),d=n(66519),h=n(52),p=n(80367),b=n(32114),m=n(99688),g=n(44536),v=n(4782),x=n(64837),Z=n(99836),w=n(21051),j=n.n(w),C=n(90659),k=n(95802);var y=n(23642),S=n(14393),q=n(29938),A=(0,c.ZL)()({dialogContent:{width:"80em"},textAreaFont:{fontFamily:"Courier New"}});function N(e,t,n){return E.apply(this,arguments)}function E(){return(E=(0,s.Z)((0,r.Z)().mark((function e(t,n,o){var s,a,c,l,i,u,f,d,h;return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(0,k.getSession)(t),a=t.leftOffset,c=t.rightOffset,a&&c){e.next=4;break}throw new Error("no offsets on model to use for range");case 4:if(a.assemblyName===c.assemblyName){e.next=6;break}throw new Error("not able to fetch sequences from multiple assemblies");case 6:if(l=s.rpcManager,i=s.assemblyManager,u=a.assemblyName||c.assemblyName||"",f=i.get(u)){e.next=11;break}throw new Error("assembly ".concat(u," not found"));case 11:return d=(0,Z.getConf)(f,["sequence","adapter"]),h="getSequence",e.abrupt("return",l.call(h,"CoreGetFeatures",{adapterConfig:d,regions:n,sessionId:h,signal:o}));case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var R=(0,v.observer)((function(e){var t=e.model,n=e.handleClose,c=A().classes,v=(0,k.getSession)(t),Z=(0,a.useState)(),w=(0,o.Z)(Z,2),E=w[0],R=w[1],F=(0,a.useState)(),O=(0,o.Z)(F,2),_=O[0],I=O[1],L=(0,a.useState)(!1),M=(0,o.Z)(L,2),z=M[0],H=M[1],T=(0,a.useState)(!1),B=(0,o.Z)(T,2),D=B[0],G=B[1],W=(0,a.useState)(!1),P=(0,o.Z)(W,2),V=P[0],$=P[1],J=t.leftOffset,K=t.rightOffset,Q=Boolean(void 0===_);(0,a.useEffect)((function(){var e=!0,n=new AbortController;return(0,s.Z)((0,r.Z)().mark((function o(){var s,a;return(0,r.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,0!==(s=t.getSelectedRegions(J,K)).length){r.next=4;break}throw new Error("Selected region is out of bounds");case 4:return r.next=6,N(t,s,n.signal);case 6:a=r.sent,e&&I(a),r.next=14;break;case 10:r.prev=10,r.t0=r.catch(0),console.error(r.t0),e&&R(r.t0);case 14:case"end":return r.stop()}}),o,null,[[0,10]])})))(),function(){n.abort(),e=!1}}),[t,v,J,K]);var U=_?_.filter((function(e){return!!e})).map((function(e){var t,n=e.get("seq"),r=e.get("refName"),o=e.get("start")+1,s=e.get("end"),a="".concat(r,":").concat(o,"-").concat(s);if((null===(t=n)||void 0===t?void 0:t.length)!==s-o+1)throw new Error("".concat(a," returned ").concat(n.length.toLocaleString()," bases, but should have returned ").concat((s-o).toLocaleString()));return z&&(n=(0,k.reverse)(n)),V&&(n=(0,k.complement)(n)),{header:a+(z?"-rev":"")+(V?"-comp":""),seq:n}})).map((function(e){return">".concat(e.header,"\n").concat(e.seq.replace(/(.{1,80})/g,"$1\n").trimEnd())})).join("\n"):"",X=!!U&&U.length>1e6;return(0,q.jsxs)(C.Dialog,{maxWidth:"xl",open:!0,onClose:function(){n(),t.setOffsets()},title:"Reference sequence",children:[(0,q.jsxs)(l.Z,{children:[E?(0,q.jsx)(i.Z,{color:"error",children:"".concat(E)}):Q?(0,q.jsxs)(u.Z,{children:["Retrieving reference sequence...",(0,q.jsx)(f.Z,{style:{marginLeft:10},size:20,disableShrink:!0})]}):null,(0,q.jsx)(d.Z,{"data-testid":"rubberband-sequence",variant:"outlined",multiline:!0,minRows:5,maxRows:10,disabled:X,className:c.dialogContent,fullWidth:!0,value:X?"Reference sequence too large to display, use the download FASTA button":U,InputProps:{readOnly:!0,classes:{input:c.textAreaFont}}}),(0,q.jsxs)(h.Z,{children:[(0,q.jsx)(p.Z,{control:(0,q.jsx)(b.Z,{value:z,onChange:function(e){return H(e.target.checked)}}),label:"Reverse sequence"}),(0,q.jsx)(p.Z,{control:(0,q.jsx)(b.Z,{value:V,onChange:function(e){return $(e.target.checked)}}),label:"Complement sequence"})]}),(0,q.jsx)(i.Z,{style:{margin:10},children:'Note: Check both boxes for the "reverse complement"'})]}),(0,q.jsxs)(m.Z,{children:[(0,q.jsx)(g.Z,{onClick:function(){j()(U),G(!0),setTimeout((function(){return G(!1)}),500)},disabled:Q||!!E||X,color:"primary",startIcon:(0,q.jsx)(y.pt,{}),children:D?"Copied":"Copy to clipboard"}),(0,q.jsx)(g.Z,{onClick:function(){(0,x.saveAs)(new Blob([U||""],{type:"text/x-fasta;charset=utf-8"}),"jbrowse_ref_seq.fa")},disabled:Q||!!E,color:"primary",startIcon:(0,q.jsx)(S.Z,{}),children:"Download FASTA"}),(0,q.jsx)(g.Z,{onClick:n,variant:"contained",children:"Close"})]})]})}))},14393:function(e,t,n){var r=n(71600);t.Z=void 0;var o=r(n(7152)),s=n(29938),a=(0,o.default)((0,s.jsx)("path",{d:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"}),"GetApp");t.Z=a}}]);
//# sourceMappingURL=4439.0ab844cb.chunk.js.map