"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[3301],{33301:(e,n,t)=>{t.r(n),t.d(n,{default:()=>p});var a=t(7552),i=t(67112),o=t(76218),r=t(7946),s=t(22762),l=t(93062),c=t(30698),d=t(69092),h=t(75785),g=t(27087);const{parseCigar:y}=g.aF;function u(e,n){let t=0,a=0;for(let i=0;i<e.length;i++){const o=+e[i],r=e[i+1],s=Math.min(o,n-t);if(t>=n)break;"I"===r?a+=o:"D"===r?t+=s:"M"!==r&&"="!==r&&"X"!==r||(a+=s,t+=s)}return[t,a]}var w=t(69500);const f=(0,h.n9)()({padding:{margin:10,border:"1px solid #ccc"}});function p({session:e,view:n,feature:t,trackId:h,handleClose:g}){const{classes:p}=f(),m=-1===t.get("strand"),v=!!t.get("CIGAR"),[b,k]=(0,a.useState)(m),[C,A]=(0,a.useState)("1000"),[S,j]=(0,a.useState)(!0);return(0,w.jsxs)(i.Dialog,{open:!0,title:"Launch synteny view",onClose:g,children:[(0,w.jsxs)(o.A,{children:[n&&v?(0,w.jsx)(r.A,{className:p.padding,control:(0,w.jsx)(s.A,{checked:S,onChange:e=>{j(e.target.checked)}}),label:"Use CIGAR string to navigate the current visible to the target"}):null,m?(0,w.jsx)(r.A,{className:p.padding,control:(0,w.jsx)(s.A,{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,(0,w.jsx)(l.A,{label:"Add window size in bp",value:C,onChange:e=>{A(e.target.value)}})]}),(0,w.jsxs)(c.A,{children:[(0,w.jsx)(d.A,{variant:"contained",onClick:()=>{(async()=>{try{await async function({feature:e,windowSize:n,session:t,trackId:a,region:i,horizontallyFlip:o}){const r=e.get("CIGAR"),s=e.get("strand"),l=e.get("refName"),c=e.get("assemblyName"),d=e.get("start"),h=e.get("end"),g=e.get("mate"),w=g.start,f=g.end,p=g.assemblyName,m=g.refName;let v,b,k,C;if(i&&r){const e=i.start,n=i.end,t=y(r),[a,o]=u(t,e-d),[l,c]=u(t,n-d),h=-1===s?-1:1;k=d+a,C=d+l,v=(-1===s?f:w)+o*h,b=(-1===s?f:w)+c*h}else k=d,C=h,v=w,b=f;const A=t.addView("LinearSyntenyView",{type:"LinearSyntenyView",views:[{type:"LinearGenomeView",hideHeader:!0},{type:"LinearGenomeView",hideHeader:!0}],tracks:[{configuration:a,type:"SyntenyTrack",displays:[{type:"LinearSyntenyDisplay",configuration:`${a}-LinearSyntenyDisplay`}]}]}),S=`${l}:${Math.floor(k-n)}-${Math.floor(C+n)}`,j=Math.min(v,b),x=Math.max(v,b),L=`${m}:${Math.floor(j-n)}-${Math.floor(x+n)}${o?"[rev]":""}`;await Promise.all([A.views[0].navToLocString(S,c),A.views[1].navToLocString(L,p)])}({feature:t,windowSize:+C,horizontallyFlip:b,trackId:h,session:e,region:S?n?.dynamicBlocks.contentBlocks[0]:void 0})}catch(n){console.error(n),e.notifyError(`${n}`,n)}})(),g()},children:"Submit"}),(0,w.jsx)(d.A,{variant:"contained",color:"secondary",onClick:()=>{g()},children:"Cancel"})]})]})}}}]);
//# sourceMappingURL=3301.ed5c5d57.chunk.js.map