"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[9321],{59321:(e,n,t)=>{t.r(n),t.d(n,{default:()=>k});var a=t(41867),i=t(35421),o=t(90872),c=t(47409),r=t(96614),s=t(83171),l=t(49133),d=t(27768),h=t(23801),g=t(45627),y=t(85815);const{parseCigar:w}=g.MismatchParser;function u(e){return Math.floor(e)}function m(e,n){let t=0,a=0;for(let i=0;i<e.length;i++){const o=+e[i],c=e[i+1],r=Math.min(o,n-t);if(t>=n)break;"I"===c?a+=o:"D"===c?t+=r:"M"===c&&(a+=r,t+=r)}return[t,a]}var f=t(47192),p=t(80838);const v=(0,f.ZL)()({padding:{margin:10,border:"1px solid #ccc"}});function k(e){let{model:n,feature:t,handleClose:g}=e;const{classes:f}=v(),k=-1===t.get("strand"),[b,S]=(0,a.useState)(k),[C,j]=(0,a.useState)("1000");return(0,p.jsxs)(i.Dialog,{open:!0,title:"Launch synteny view",onClose:g,children:[(0,p.jsxs)(c.Z,{children:[k?(0,p.jsx)(r.Z,{className:f.padding,control:(0,p.jsx)(s.Z,{checked:b,onChange:e=>S(e.target.checked)}),label:"Note: The feature is inverted in orientation on the target sequence. This will result in the lower panel having genomic coordinates decreasing left to right. Horizontally flip?"}):null,(0,p.jsx)(l.Z,{label:"Add window size in bp",value:C,onChange:e=>j(e.target.value)})]}),(0,p.jsxs)(d.Z,{children:[(0,p.jsx)(h.Z,{variant:"contained",onClick:()=>{(async()=>{try{await async function(e){let{feature:n,windowSize:t,model:a,horizontallyFlip:i}=e;const c=(0,o.getSession)(a),r=(0,o.getContainingTrack)(a),s=(0,o.getContainingView)(a).dynamicBlocks.contentBlocks[0],l=n.get("CIGAR"),d=n.get("strand"),h=s.start,g=s.end,f=n.get("start"),p=n.get("end"),v=n.get("mate"),k=v.start,b=v.end,S=v.assemblyName,C=v.refName,j=s.assemblyName,x=s.refName;let L,M,Z,z;if(l){const e=w(l),[n,t]=m(e,h-f),[a,i]=m(e,g-f),o=-1===d?-1:1;Z=f+n,z=f+a,L=(-1===d?b:k)+t*o,M=(-1===d?b:k)+i*o}else Z=f,z=p,L=k,M=b;const N=r.configuration.trackId,T=c.addView("LinearSyntenyView",{type:"LinearSyntenyView",views:[{id:"".concat(Math.random()),type:"LinearGenomeView",hideHeader:!0},{id:"".concat(Math.random()),type:"LinearGenomeView",hideHeader:!0}],tracks:[{configuration:N,type:"SyntenyTrack",displays:[{type:"LinearSyntenyDisplay",configuration:"".concat(N,"-LinearSyntenyDisplay")}]}]}),V="".concat(x,":").concat(u(Z-t),"-").concat(u(z+t)),D=Math.min(L,M),_=Math.max(L,M),G="".concat(C,":").concat(u(D-t),"-").concat(u(_+t)).concat(i?"[rev]":"");await(0,y.when)((()=>void 0!==T.width)),await Promise.all([T.views[0].navToLocString(V,j),T.views[1].navToLocString(G,S)])}({feature:t,windowSize:+C,horizontallyFlip:b,model:n})}catch(e){(0,o.getSession)(n).notify("".concat(e),"error")}})(),g()},children:"Submit"}),(0,p.jsx)(h.Z,{variant:"contained",color:"secondary",onClick:()=>g(),children:"Cancel"})]})]})}}}]);
//# sourceMappingURL=9321.a119158d.chunk.js.map