"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[9978],{21016:(e,t,n)=>{n.d(t,{K:()=>i,W:()=>l});var o=n(87485),a=n(46879);function l(e,t,n,a,l,i=!0){if(e===l)return i?"#ccc":"";{let e;if(t&&(e=(0,o.M)(`hsl(200,50%,${80-t/l*50}%)`)),n){const t=`hsla(0,100%,20%,${n/l})`;e=e?e.mix(t):(0,o.M)(t)}if(a){const t=`hsl(50,50%,50%,${a/l})`;e=e?e.mix(t):(0,o.M)(t)}return e?.toHex()||"black"}}function i(e,t,n,l,i,r,f="",s,c=1){t.fillStyle=1!==c?(0,o.M)(e).alpha(c).toHex():e,"inversion"===f?1===s?(t.beginPath(),t.moveTo(n-a.f2,l-a.f2),t.lineTo(n-a.f2,l+r+a.f2),t.lineTo(n+i+a.f2,l+r/2),t.closePath(),t.fill()):(t.beginPath(),t.moveTo(n+i+a.f2,l-a.f2),t.lineTo(n+i+a.f2,l+r+a.f2),t.lineTo(n-a.f2,l+r/2),t.closePath(),t.fill()):t.fillRect(n-a.f2,l-a.f2,i+a.f2,r+a.f2)}},40171:(e,t,n)=>{n.d(t,{E:()=>r});var o=n(40898),a=n(87485),l=n(46879),i=n(42268);function r(e,t,n,r,f,s,c,u,h=!0,g=1){const d=void 0!==u?function(e,t,n,o=!0){return+e[t]?(0,i.qH)(+n)||"black":o?"#ccc":void 0}(e,c,u,h):function(e,t,n=!0){const a=+e[t];return a?o.set1[a-1]||"black":n?"#ccc":void 0}(e,c,h);return d&&(t.fillStyle=1!==g?(0,a.M)(d).alpha(g).toHex():d,t.fillRect(n-l.f2,r-l.f2,f+l.f2,s+l.f2)),d}},42268:(e,t,n)=>{function o(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n);return a(10*t)}function a(e){return`hsl(${e%255}, 50%, 50%)`}n.d(t,{XL:()=>o,qH:()=>a})},46879:(e,t,n)=>{n.d(t,{f2:()=>o});const o=.3},99978:(e,t,n)=>{n.d(t,{makeImageData:()=>u});var o=n(99546),a=n(37347),l=n(22593),i=n.n(l),r=n(46879),f=n(21016),s=n(40171),c=n(85497);async function u(e,t){const{scrollTop:n,minorAlleleFrequencyFilter:l,sources:u,rowHeight:h,features:g,regions:d,bpPerPx:m,renderingMode:p,stopToken:b,lengthCutoffFilter:k,referenceDrawingMode:w}=t,x=d[0],{statusCallback:M=()=>{}}=t;(0,a.SW)(b);const v=await(0,o.updateStatus)("Calculating stats",M,(()=>(0,c.Cg)({stopToken:b,features:g.values(),minorAlleleFrequencyFilter:l,lengthCutoffFilter:k})));(0,a.SW)(b);const T=new(i());return await(0,o.updateStatus)("Drawing variants",M,(()=>{(0,o.forEachWithStopTokenCheck)(v,b,(({mostFrequentAlt:t,feature:a})=>{const[l,i]=(0,o.featureSpanPx)(a,x,m),c=a.get("end")-a.get("start"),g=Math.max(Math.round(i-l),2),d=a.get("genotypes");let b=-n;const k=u.length;if("phased"===p)for(let t=0;t<k;t++){const{name:n,HP:o}=u[t],i=d[n],f=Math.floor(l),c=Math.max(h,1);if(i)if(i.includes("|")){const t=i.split("|");(0,s.E)(t,e,f,b,g,c,o,void 0,"draw"===w)&&T.insert({minX:f,maxX:f+g,minY:b,maxY:b+c,genotype:i,name:n,featureId:a.id()})}else e.fillStyle="black",e.fillRect(f-r.f2,b-r.f2,g+r.f2,c+r.f2);b+=h}else{const n={};for(let o=0;o<k;o++){const{name:i}=u[o],r=d[i],s=Math.floor(l),m=Math.max(h,1);if(r){let o=n[r];if(void 0===o){let e=0,a=0,l=0,i=0;const s=r.split(/[/|]/),c=s.length;for(let n=0;n<c;n++){const o=s[n];o===t?e++:"0"===o?i++:"."===o?a++:l++}o=(0,f.W)(i,e,l,a,c,"draw"===w),n[r]=o}o&&((0,f.K)(o,e,s,b,g,m,a.get("type"),a.get("strand"),c>5?.75:1),T.insert({minX:s,maxX:s+g,minY:b,maxY:b+m,genotype:r,name:i,featureId:a.id()}))}b+=h}}}))})),{rbush:T.toJSON(),featureGenotypeMap:Object.fromEntries(v.map((({feature:e})=>[e.id(),{alt:e.get("ALT"),ref:e.get("REF"),name:e.get("name"),description:e.get("description"),length:e.get("end")-e.get("start")}])))}}}}]);
//# sourceMappingURL=9978.c8dbc6f0.chunk.js.map