"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[7192],{37192:(e,t,o)=>{o.d(t,{makeImage:()=>b});var n=o(68584),s=o(67112),r=o(99546),a=o(11210),c=o(91476);const i=7,l=4.5,f=7,h={C:"G",G:"C",A:"T",T:"A"},p=.6;async function b(e,t){const{features:o,regions:b,bpPerPx:y,colorBy:d,displayCrossHatches:k,visibleModifications:u={},scaleOpts:g,height:m,theme:v,config:T,ticks:D,stopToken:C}=t,S=(0,s.createJBrowseTheme)(v),w=b[0],O=(w.end-w.start)/y,j=a.Oy,M=m-2*j,_={...g,range:[0,M]},P=(0,a.X_)(_),R=(0,a.X_)({..._,range:[0,M/2],scaleType:"linear"}),x=(0,a.$z)(g.scaleType),N=(0,a.$z)("linear"),A=(0,n.readConfObject)(T,"indicatorThreshold"),W=(0,n.readConfObject)(T,"showInterbaseCounts"),E=(0,n.readConfObject)(T,"showArcs"),G=(0,n.readConfObject)(T,"showInterbaseIndicators"),I=e=>M-(P(e)||0)+j,$=e=>I(x)-I(e),z=e=>M-(R(e)||0)+j,B=e=>z(N)-z(e),{bases:X,softclip:H,hardclip:J,insertion:U}=S.palette,q={A:X.A.main,C:X.C.main,G:X.G.main,T:X.T.main,insertion:U,softclip:H,hardclip:J,total:(0,n.readConfObject)(T,"color"),mod_NONE:"blue",cpg_meth:"red",cpg_unmeth:"blue"};e.fillStyle=q.total,(0,r.forEachWithStopTokenCheck)(o.values(),C,t=>{if("skip"===t.get("type"))return;const[o,n]=(0,r.featureSpanPx)(t,w,y),s=n-o+p,a=t.get("score");e.fillRect(o,I(a),s,$(a))});let F=0;const K=w.reversed?1/y:0,L="modifications"===d.type,Q="methylation"===d.type,V=d.modifications?.isolatedModification;if((0,r.forEachWithStopTokenCheck)(o.values(),C,t=>{if("skip"===t.get("type"))return;const[o,n]=(0,r.featureSpanPx)(t,w,y),s=t.get("snpinfo"),a=Math.max(n-o,1),p=t.get("score");if(L){let t=0;const n=s.refbase?.toUpperCase(),{nonmods:r,mods:i,snps:l,ref:f}=s;for(const i of Object.keys(r).sort().reverse()){const r=u[i.replace("nonmod_","")]||u[i.replace("mod_","")];if(!r){console.warn(`${i} not known yet`);continue}if(V&&r.type!==V)continue;const b=h[r.base],y="N"===r.base?p:(l[r.base]?.entryDepth||0)+(l[b]?.entryDepth||0)+(n===r.base?f[1]:0)+(n===b?f[-1]:0),d="N"===r.base?p:(l[r.base]?.entryDepth||0)+(l[b]?.entryDepth||0)+(n===r.base?f.entryDepth:0)+(n===b?f.entryDepth:0),{entryDepth:k,avgProbability:g=0}=s.nonmods[i],m=d/p*(k/y),v="blue",T=(0,c.yr)(v,g),D=$(p),C=I(p)+D;e.fillStyle=T,e.fillRect(Math.round(o),C-(t+m*D),a,m*D),t+=m*D}for(const s of Object.keys(i).sort().reverse()){const r=u[s.replace("mod_","")];if(!r){console.warn(`${s} not known yet`);continue}if(V&&r.type!==V)continue;const b=h[r.base],y="N"===r.base?p:(l[r.base]?.entryDepth||0)+(l[b]?.entryDepth||0)+(n===r.base?f[1]:0)+(n===b?f[-1]:0),d="N"===r.base?p:(l[r.base]?.entryDepth||0)+(l[b]?.entryDepth||0)+(n===r.base?f.entryDepth:0)+(n===b?f.entryDepth:0),{entryDepth:k,avgProbability:g=0}=i[s],m=d/p*(k/y),v=r.color||"black",T=(0,c.yr)(v,g),D=$(p),C=I(p)+D;e.fillStyle=T,e.fillRect(Math.round(o),C-(t+m*D),a,m*D),t+=m*D}}else if(Q){const{depth:t,nonmods:n,mods:r}=s;let c=0;for(const n of Object.keys(r).sort().reverse()){const{entryDepth:s}=r[n],i=$(p),l=I(p)+i;e.fillStyle=q[n]||"black",e.fillRect(Math.round(o),l-(s+c)/t*i,a,s/t*i),c+=s}for(const s of Object.keys(n).sort().reverse()){const{entryDepth:r}=n[s],i=$(p),l=I(p)+i;e.fillStyle=q[s]||"black",e.fillRect(Math.round(o),l-(r+c)/t*i,a,r/t*i),c+=r}}else{const{depth:t,snps:n}=s;let r=0;for(const s of Object.keys(n).sort().reverse()){const{entryDepth:c}=n[s],i=$(p),l=I(p)+i;e.fillStyle=q[s]||"black",e.fillRect(Math.round(o),l-(c+r)/t*i,a,c/t*i),r+=c}}const b=Object.keys(s.noncov);if(W){let t=0;for(const n of b){const{entryDepth:r}=s.noncov[n],a=.6;e.fillStyle=q[n],e.fillRect(o-a+K,l+B(t),2*a,B(r)),t+=r}}if(G){let t=0,n=0,r="";for(const e of b){const{entryDepth:o}=s.noncov[e];t+=o,o>n&&(n=o,r=e)}const a=Math.max(p,F);if(t>a*A&&a>f){e.fillStyle=q[r],e.beginPath();const t=o+K;e.moveTo(t-i/2,0),e.lineTo(t+i/2,0),e.lineTo(t,l),e.fill()}}F=p}),E&&(0,r.forEachWithStopTokenCheck)(o.values(),C,t=>{if("skip"!==t.get("type"))return;const o=t.get("start"),n=t.get("end"),[s,a]=(0,r.bpSpanPx)(o,n,w,y);e.beginPath();const c=t.get("effectiveStrand");e.strokeStyle=1===c?"rgba(255,200,200,0.7)":-1===c?"rgba(200,200,255,0.7)":"rgba(200,200,200,0.7)",e.lineWidth=Math.log(t.get("score")+1),e.moveTo(s,M-2*j),e.bezierCurveTo(s,0,a,0,a,M-2*j),e.stroke()}),k){e.lineWidth=1,e.strokeStyle="rgba(140,140,140,0.8)";for(const t of D.values)e.beginPath(),e.moveTo(0,Math.round(I(t))),e.lineTo(O,Math.round(I(t))),e.stroke()}}}}]);
//# sourceMappingURL=7192.abed1105.chunk.js.map