"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[1752],{31752:(e,t,a)=>{a.d(t,{drawDotplot:()=>u});var o=a(68584),r=a(67112),s=a(95095),n=a(27087),f=a(36422);const{parseCigar:c}=n.aF,l="fell outside of range due to CIGAR string",i="(less than min coordinate of feature)",d="(greater than max coordinate of feature)",g=1;function h(e,t,a,o=1){e.beginPath(),e.arc(t,a,o/2,0,2*Math.PI),e.fill()}async function u(e,t){const{config:a,views:n,height:u,drawCigar:m,theme:p}=t,b=(0,o.readConfObject)(a,"color"),$=(0,o.readConfObject)(a,"posColor"),k=(0,o.readConfObject)(a,"negColor"),C=(0,o.readConfObject)(a,"colorBy"),w=(0,o.readConfObject)(a,"lineWidth"),P=(0,o.readConfObject)(a,"thresholds"),B=(0,o.readConfObject)(a,"thresholdsPalette"),y=a.color.isCallback,N=n[0],j=n[1],v=N.dynamicBlocks.contentBlocks[0]?.offsetPx,x=j.dynamicBlocks.contentBlocks[0]?.offsetPx,O=[];e.lineWidth=w;const{bpPerPx:T}=N,{bpPerPx:M}=j;function I(e,t,a,o){const r=o.get("strand")||1;if(-1===r&&([a,t]=[t,a]),e<t-g){let e=o.get("start"),a=o.get("end");const s=o.get("refName");return-1===r&&([a,e]=[e,a]),O.push({message:`feature at (X ${s}:${e}-${a}) ${l} ${i}`,effect:"clipped the feature"}),t}if(e>a+g){const e=o.get("strand")||1,t=1===e?o.get("start"):o.get("end"),r=1===e?o.get("end"):o.get("start"),s=o.get("refName");return O.push({message:`feature at (X ${s}:${t}-${r}) ${l} ${d}`,effect:"clipped the feature"}),a}return e}function S(e,t,a,o){if(e<t-g){const e=o.get("mate"),{refName:a,start:r,end:s}=e;return O.push({message:`feature at (Y ${a}:${r}-${s}) ${l} ${i}`,effect:"clipped the feature"}),t}if(e>a+g){const e=o.get("mate"),{refName:t,start:r,end:s}=e;return O.push({message:`feature at (Y ${t}:${r}-${s}) ${l} ${d}`,effect:"clipped the feature"}),a}return e}const X={...(0,f.getSnapshot)(N),staticBlocks:N.staticBlocks,width:N.width},_={...(0,f.getSnapshot)(j),staticBlocks:j.staticBlocks,width:j.width},Q=(0,r.createJBrowseTheme)(p);for(const t of N.features||[]){const r=t.get("strand")||1,n=1===r?t.get("start"):t.get("end"),f=1===r?t.get("end"):t.get("start"),l=t.get("refName"),i=t.get("mate"),d=i.refName;let g="black";if("identity"===C){const e=t.get("identity");for(let t=0;t<P.length;t++)if(e>+P[t]){g=B[t]||"black";break}}else"meanQueryIdentity"===C?g=`hsl(${200*t.get("meanScore")},100%,40%)`:"mappingQuality"===C?g=`hsl(${t.get("mappingQual")},100%,40%)`:"strand"===C?g=-1===r?k:$:"default"===C&&(g=y?(0,o.readConfObject)(a,"color",{feature:t}):"#f0f"===b?Q.palette.text.primary:b);e.fillStyle=g,e.strokeStyle=g;const p=(0,s.eB)({self:X,refName:l,coord:n}),N=(0,s.eB)({self:X,refName:l,coord:f}),j=(0,s.eB)({self:_,refName:d,coord:i.start}),Y=(0,s.eB)({self:_,refName:d,coord:i.end});if(void 0!==p&&void 0!==N&&void 0!==j&&void 0!==Y){const a=p.offsetPx-v,o=N.offsetPx-v,s=j.offsetPx-x,n=Y.offsetPx-x;if(Math.abs(a-o)<=4&&Math.abs(s-n)<=4)h(e,a,u-s,w);else{let f=a,l=s;const i=t.get("CIGAR");if(m&&i){const d=c(i);e.beginPath(),e.moveTo(f,u-l);let g=f,h=f;for(let c=0;c<d.length;c+=2){const i=+d[c],m=d[c+1];"M"===m||"="===m||"X"===m?(f+=i/T*r,l+=i/M):"D"===m||"N"===m?f+=i/T*r:"I"===m&&(l+=i/M),f=I(f,a,o,t),l=S(l,s,n,t),(Math.abs(f-g)>.5||Math.abs(l-h)>.5)&&(e.lineTo(f,u-l),g=f,h=l)}e.stroke()}else e.beginPath(),e.moveTo(a,u-s),e.lineTo(o,u-n),e.stroke()}}else O.length<=5&&(void 0===p||void 0===N?O.push({message:`feature at (X ${l}:${n}-${f}) not plotted, fell outside of range`,effect:"feature not rendered"}):O.push({message:`feature at (Y ${d}:${i.start}-${i.end}) not plotted, fell outside of range`,effect:"feature not rendered"}))}return{warnings:O}}}}]);
//# sourceMappingURL=1752.f0738a07.chunk.js.map