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