const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ArcTooltip-C_3QYB2A.js","assets/index-Bm2SqMk3.js","assets/index-B32Lr0K5.css"])))=>i.map(i=>d[i]);
import{aQ as F,u as v,a as x,_ as T,o as M,v as V,R as d}from"./index-Bm2SqMk3.js";function A(e,t){var n,i,r,s;const a=t?F(t):void 0,u=e.get("start");let l=e.get("end");const f=e.get("strand"),c=e.get("mate"),m=e.get("refName");let p,k=0,E=0,N=0,b=0;if(["<TRA","<DEL","<INV","<INS","<DUP","<CNV"].some(o=>t==null?void 0:t.startsWith(o))){const o=e.get("INFO"),g=(i=(n=o==null?void 0:o.END)===null||n===void 0?void 0:n[0])!==null&&i!==void 0?i:l;p=(s=(r=o==null?void 0:o.CHR2)===null||r===void 0?void 0:r[0])!==null&&s!==void 0?s:m,k=g,E=g-1,l=u+1}else if(a!=null&&a.MatePosition){const o=a.MatePosition.split(":");b=a.MateDirection==="left"?1:-1,N=a.Join==="left"?-1:1,k=+o[1],E=+o[1]-1,p=o[0]}return{k1:{refName:m,start:u,end:l,strand:f,mateDirection:b},k2:c??{refName:p||"unknown",end:k,start:E,mateDirection:N}}}function W(e,t){var n;const{k1:i,k2:r}=A(e,t);return[e.get("name"),e.get("id"),v.assembleLocString(i),v.assembleLocString(r),(n=e.get("INFO"))===null||n===void 0?void 0:n.SVTYPE,t].filter(s=>!!s).join(" - ")}const I=x.lazy(()=>T(()=>import("./ArcTooltip-C_3QYB2A.js"),__vite__mapDeps([0,1,2]))),O=M(function({model:e,feature:t,alt:n,assembly:i,view:r}){var s,a;const[u,l]=x.useState(!1),{height:f}=e,{k1:c,k2:m}=A(t,n),p=x.useRef(null),k=V.getConf(e,"color",{feature:t,alt:n}),E=i.getCanonicalRefName(c.refName)||c.refName,N=i.getCanonicalRefName(m.refName)||m.refName,b=c.start,S=m.start,o=(s=r.bpToPx({refName:E,coord:b}))===null||s===void 0?void 0:s.offsetPx,g=(a=r.bpToPx({refName:N,coord:S}))===null||a===void 0?void 0:a.offsetPx;if(o!==void 0&&g!==void 0){const R=(g-o)/2,D=Math.abs(R),C=Math.min(f,D),$=o-r.offsetPx,w=g-r.offsetPx,P=$,h=w,_=u?"black":k,y=3;return D>1?d.createElement(d.Fragment,null,d.createElement("path",{d:`M ${P} 0 C ${P} ${C}, ${h} ${C}, ${h} 0`,ref:p,...v.getStrokeProps(_),strokeWidth:y,onMouseOut:()=>{l(!1)},onMouseOver:()=>{l(!0)},onClick:()=>{e.selectFeature(t)},fill:"none",pointerEvents:"stroke"}),c.mateDirection?d.createElement("line",{...v.getStrokeProps(_),strokeWidth:y,onMouseOut:()=>{l(!1)},onMouseOver:()=>{l(!0)},onClick:()=>{e.selectFeature(t)},x1:P,x2:P+c.mateDirection*20,y1:1.5,y2:1.5}):null,m.mateDirection?d.createElement("line",{...v.getStrokeProps(_),strokeWidth:y,onMouseOut:()=>{l(!1)},onMouseOver:()=>{l(!0)},onClick:()=>{e.selectFeature(t)},x1:h,x2:h+m.mateDirection*20,y1:1.5,y2:1.5}):null,u?d.createElement(x.Suspense,{fallback:null},d.createElement(I,{contents:W(t,n)})):null):null}return null}),L=M(function({model:e,exportSVG:t,children:n}){const{height:i}=e,r=v.getContainingView(e),s=Math.round(r.dynamicBlocks.totalWidthPx);return t?n:d.createElement("svg",{width:s,height:i},n)}),B=M(function({model:e,exportSVG:t}){const n=v.getContainingView(e),i=v.getSession(e),{assemblyManager:r}=i,{features:s}=e,a=r.get(n.assemblyNames[0]);return a?d.createElement(L,{model:e,exportSVG:t},s==null?void 0:s.map(u=>{var l;const f=u.get("ALT");return(l=f==null?void 0:f.map(c=>d.createElement(O,{key:`${u.id()}-${c}`,session:i,feature:u,alt:c,view:n,model:e,assembly:a})))!==null&&l!==void 0?l:d.createElement(O,{key:u.id(),session:i,feature:u,view:n,model:e,assembly:a})})):null});export{B as A};
