"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[9321],{59321:(e,t,n)=>{n.r(t),n.d(t,{default:()=>p});var a=n(66204),i=n(35421),r=n(90872),o=n(29520),l=n(39780),s=n(70539),c=n(46338),d=n(62301),g=n(7146),h=n(45627),m=n(99247);const{parseCigar:y}=h.MismatchParser;function u(e){return Math.floor(e)}function w(e,t){let n=0,a=0;for(let i=0;i<e.length;i++){const r=+e[i],o=e[i+1],l=Math.min(r,t-n);if(n>=t)break;"I"===o?a+=r:"D"===o?n+=l:"M"===o&&(a+=l,n+=l)}return[n,a]}const f=(0,n(38684).ZL)()({padding:{margin:10,border:"1px solid #ccc"}});function p({model:e,feature:t,handleClose:n}){const{classes:h}=f(),p=-1===t.get("strand"),[b,k]=(0,a.useState)(p),[v,S]=(0,a.useState)("1000");return a.createElement(i.Dialog,{open:!0,title:"Launch synteny view",onClose:n},a.createElement(o.Z,null,p?a.createElement(l.Z,{className:h.padding,control:a.createElement(s.Z,{checked:b,onChange:e=>k(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,a.createElement(c.Z,{label:"Add window size in bp",value:v,onChange:e=>S(e.target.value)})),a.createElement(d.Z,null,a.createElement(g.Z,{variant:"contained",onClick:()=>{(async()=>{try{await async function({feature:e,windowSize:t,model:n,horizontallyFlip:a}){const i=(0,r.getSession)(n),o=(0,r.getContainingTrack)(n),l=(0,r.getContainingView)(n).dynamicBlocks.contentBlocks[0],s=e.get("CIGAR"),c=e.get("strand"),d=l.start,g=l.end,h=e.get("start"),f=e.get("end"),p=e.get("mate"),b=p.start,k=p.end,v=p.assemblyName,S=p.refName,C=l.assemblyName,$=l.refName;let L,E,M,T;if(s){const e=y(s),[t,n]=w(e,d-h),[a,i]=w(e,g-h),r=-1===c?-1:1;M=h+t,T=h+a,L=(-1===c?k:b)+n*r,E=(-1===c?k:b)+i*r}else M=h,T=f,L=b,E=k;const Z=o.configuration.trackId,z=i.addView("LinearSyntenyView",{type:"LinearSyntenyView",views:[{id:`${Math.random()}`,type:"LinearGenomeView",hideHeader:!0},{id:`${Math.random()}`,type:"LinearGenomeView",hideHeader:!0}],tracks:[{configuration:Z,type:"SyntenyTrack",displays:[{type:"LinearSyntenyDisplay",configuration:`${Z}-LinearSyntenyDisplay`}]}]}),N=`${$}:${u(M-t)}-${u(T+t)}`,V=Math.min(L,E),D=Math.max(L,E),_=`${S}:${u(V-t)}-${u(D+t)}${a?"[rev]":""}`;await(0,m.when)((()=>void 0!==z.width)),await Promise.all([z.views[0].navToLocString(N,C),z.views[1].navToLocString(_,v)])}({feature:t,windowSize:+v,horizontallyFlip:b,model:e})}catch(t){(0,r.getSession)(e).notify(`${t}`,"error")}})(),n()}},"Submit"),a.createElement(g.Z,{variant:"contained",color:"secondary",onClick:()=>n()},"Cancel")))}}}]);
//# sourceMappingURL=9321.496b8818.chunk.js.map