@genome-spy/core 0.22.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/view/scaleResolution.js +21 -0
package/dist/index.js
CHANGED
|
@@ -140,7 +140,7 @@ if(scale<1.0){if(uSqueeze){vec2 scaleFadeExtent=vec2(3.0,6.0)/size;if(scale<scal
|
|
|
140
140
|
* All rights reserved.
|
|
141
141
|
*
|
|
142
142
|
* BSD-3-Clause License: https://github.com/vega/vega-lite/blob/master/LICENSE
|
|
143
|
-
*/const Ow="locus",Gw="index";var Uw=5;function Hw(t){const e=t.type;return!t.bins&&(e===bn||e===br||e===wr)}function $0(t){return Re(t)&&![qe,Gw,Ow].includes(t)}function eh(t){return t||{warn:(e,...n)=>console.warn(e,...n)}}var Qw=li(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma","zoom","fp64","name"]);function th(t,e,n){n=eh(n);for(const r in t)if(!Qw[r]){if(r==="padding"&&$0(e.type))continue;me(e[r])?e[r](t[r]):n.warn("Unsupported scale property: "+r)}qw(e,t,Kw(e,t,Ww(e,t,n)))}function jw(t,e){const n=Vw(t),r=U(n);if(!r)throw new Error("Unknown scale type: "+n);const i=r();return th(t,i,e),i}function Vw(t){var e=t.type,n="",r;return e===qe?qe+"-"+bn:(Yw(t)&&(r=t.rawDomain?t.rawDomain.length:t.domain?t.domain.length+ +(t.domainMid!=null):0,n=r===2?qe+"-":r===3?wn+"-":""),(n+e||bn).toLowerCase())}function Yw(t){const e=t.type;return Re(e)&&e!==Nl&&e!==zl&&(t.scheme||t.range&&t.range.length&&t.range.every(q))}function Ww(t,e,n){if(!t.domain)return 0;n=eh(n);var r=Xw(t,e.domainRaw,n);if(r>-1)return r;var i=e.domain,o=t.type,s=e.zero||e.zero===void 0&&Hw(t),a,u;return i?($0(o)&&e.padding&&i[0]!==Oe(i)&&(i=Zw(o,i,e.range,e.padding,e.exponent,e.constant)),(s||e.domainMin!=null||e.domainMax!=null||e.domainMid!=null)&&(a=(i=i.slice()).length-1||1,s&&(i[0]>0&&(i[0]=0),i[a]<0&&(i[a]=0)),e.domainMin!=null&&(i[0]=e.domainMin),e.domainMax!=null&&(i[a]=e.domainMax),e.domainMid!=null&&(u=e.domainMid,(u<i[0]||u>i[a])&&n.warn("Scale domainMid exceeds domain min or max.",u),i.splice(a,0,u))),t.domain(nh(o,i,n)),o===Ys&&t.unknown(e.domainImplicit?hs:void 0),e.nice&&t.nice&&t.nice(e.nice!==!0&&J0(t,e.nice)||null),i.length):0}function Xw(t,e,n){return e?(t.domain(nh(t.type,e,n)),e.length):-1}function Zw(t,e,n,r,i,o){var s=Math.abs(Oe(n)-n[0]),a=s/(s-2*r),u=t===vt?Au(e,null,a):t===wr?Io(e,null,a,.5):t===br?Io(e,null,a,i||1):t===Oi?rd(e,null,a,o||1):mu(e,null,a);return e=e.slice(),e[0]=u[0],e[e.length-1]=u[1],e}function nh(t,e,n){if(Vl(t)){var r=Math.abs(e.reduce(function(i,o){return i+(o<0?-1:o>0?1:0)},0));r!==e.length&&n.warn("Log scale domain includes zero: "+ci(e))}return e}function Kw(t,e,n){let r=e.bins;if(r&&!Te(r)){const i=(r.start==null||r.stop==null)&&t.domain(),o=r.start==null?i[0]:r.start,s=r.stop==null?Oe(i):r.stop,a=r.step;a||K("Scale bins parameter missing step property."),r=Zn(o,s+a,a)}return r?t.bins=r:t.bins&&delete t.bins,t.type===Xs&&(r?!e.domain&&!e.domainRaw&&(t.domain(r),n=r.length):t.bins=t.domain()),n}function qw(t,e,n){var r=t.type,i=e.round||!1,o=e.range;if(e.rangeStep!=null)o=Jw(r,e,n);else if(e.scheme&&(o=_w(r,e,n),me(o))){if(t.interpolator)return t.interpolator(o);K(`Scale type ${r} does not support interpolating color schemes.`)}if(o&&Ui(r))return t.interpolator(Hi(Wa(o,e.reverse),e.interpolate,e.interpolateGamma));o&&e.interpolate&&t.interpolate?t.interpolate(Yl(e.interpolate,e.interpolateGamma)):me(t.round)?t.round(i):me(t.rangeRound)&&t.interpolate(i?xr:bt),o&&t.range(Wa(o,e.reverse))}function Jw(t,e,n){t!==Ul&&t!==Ws&&K("Only band and point scales support rangeStep.");var r=(e.paddingOuter!=null?e.paddingOuter:e.padding)||0,i=t===Ws?1:(e.paddingInner!=null?e.paddingInner:e.padding)||0;return[0,e.rangeStep*js(n,i,r)]}function _w(t,e,n){var r=e.schemeExtent,i,o;return Te(e.scheme)?o=Hi(e.scheme,e.interpolate,e.interpolateGamma):(i=e.scheme.toLowerCase(),o=Ks(i),o||K(`Unrecognized scheme name: ${e.scheme}`)),n=t===Gl?n+1:t===Xs?n-1:t===Vs||t===Ol?+e.schemeCount||Uw:n,Ui(t)?rh(o,r,e.reverse):me(o)?aA(rh(o,r),n):t===Ys?o:o.slice(0,n)}function rh(t,e,n){return me(t)&&(e||n)?sA(t,Wa(e||[0,1],n)):t}function Wa(t,e){return e?t.slice().reverse():t}const ih=ae(",d");function $w(t,e){return t.chrom+":"+ih(Math.floor(t.pos+1))+"-"+(t.chrom!=e.chrom?e.chrom+":":"")+ih(Math.ceil(e.pos))}const ev="https://genomespy.app/data/genomes/";class tv{constructor(e){if(this.config=e,!this.config.contigs&&typeof this.config.name!="string")throw new Error("No name has been defined for the genome assembly!");this.chromosomes=[],this.cumulativeChromPositions=new Map,this.chromosomesByName=new Map,this.startByIndex=[],this.totalSize=0,this.config.contigs&&this.setChromSizes(this.config.contigs)}get name(){return this.config.name}async load(e){if(!this.config.contigs){this.config.baseUrl?this.baseUrl=/^http(s)?/.test(this.config.baseUrl)?this.config.baseUrl:e+"/"+this.config.baseUrl:this.baseUrl=ev;try{this.setChromSizes(nv(await Ei({baseURL:this.baseUrl}).load(`${this.config.name}/${this.name}.chrom.sizes`)))}catch(n){throw new Error(`Could not load chrom sizes: ${n.message}`)}}}setChromSizes(e){let n=0;this.startByIndex=[0];for(let r=0;r<e.length;r++){this.startByIndex.push(n);const i=e[r].size,o=Se(F({},e[r]),{continuousStart:n,continuousEnd:n+i,continuousInterval:[n,n+i],index:r,number:r+1,odd:!(r&1)});this.chromosomes.push(o);const s=o.name.replace(/^chr/i,"");for(const a of["chr"+s,"CHR"+s,"Chr"+s,o.number,""+o.number,s,o.name])this.cumulativeChromPositions.set(a,n),this.chromosomesByName.set(a,o);n+=o.size}this.totalSize=n}getExtent(){return[0,this.totalSize]}toContinuous(e,n){let r=this.cumulativeChromPositions.get(e);if(r===void 0)throw new Error("Unknown chromosome/contig: "+e);return r+ +n}toChromosome(e){if(e>=this.totalSize)return;e=Math.floor(e);const n=cn(this.startByIndex,e)-1;if(n>0&&n<=this.chromosomes.length)return this.chromosomes[n-1]}toChromosomal(e){const n=this.toChromosome(e);if(!!n)return{chrom:n.name,pos:Math.floor(e)-n.continuousStart}}getChromosome(e){return this.chromosomesByName.get(e)}formatInterval(e){return $w(...this.toChromosomalInterval(e))}toChromosomalInterval(e){const n=this.toChromosomal(e[0]+.5),r=this.toChromosomal(e[1]-.5);return r.pos+=1,[n,r]}toContinuousInterval(e){var i,o,s;let[n,r]=e;return r||(r=n),[this.toContinuous(n.chrom,(i=n.pos)!=null?i:0),this.toContinuous(r.chrom,(s=r.pos)!=null?s:(o=this.chromosomesByName.get(r.chrom))==null?void 0:o.size)]}parseInterval(e){const n=e.match(/^(chr[0-9A-Z]+)(?::([0-9,]+)(?:-(?:(chr[0-9A-Z]+):)?([0-9,]+))?)?$/);if(n){const r=n[1];if(n.slice(2).every(a=>a===void 0)){const a=this.getChromosome(r);return a?[a.continuousStart,a.continuousEnd]:void 0}const i=n[3]||r,o=parseInt(n[2].replace(/,/g,"")),s=n[4]!==void 0?parseInt(n[4].replace(/,/g,"")):o;return[this.toContinuous(r,o-1),this.toContinuous(i,s)]}}}function nv(t){return vd(t).filter(e=>/^chr[0-9A-Z]+$/.test(e[0])).map(([e,n])=>({name:e,size:parseInt(n)}))}function oh(t){return ze(t)&&"chrom"in t}function rv(t){return t.every(oh)}class Kr extends Array{constructor(){super(),this.type=void 0}extend(e){return this}extendAll(e){if(e instanceof Kr&&e.type!=this.type)throw new Error(`Cannot combine different types of domains: ${this.type} and ${e.type}`);for(const n of e)this.extend(n);return this}extendAllWithAccessor(e,n){for(const r of e)this.extend(n(r));return this}}class Xa extends Kr{constructor(){super(),this.type="quantitative"}extend(e){return e==null||Number.isNaN(e)?this:(e=+e,this.length?e<this[0]?this[0]=e:e>this[1]&&(this[1]=e):(this.push(e),this.push(e)),this)}}class sh extends Kr{constructor(){super(),this.type="ordinal",this.uniqueValues=new Set}extend(e){return e==null||Number.isNaN(e)?this:(this.uniqueValues.has(e)||(this.uniqueValues.add(e),this.push(e)),this)}}class ah extends sh{constructor(){super(),this.type="nominal"}}class iv extends Kr{constructor(e){super();let n=0;for(let r=1;r<e.length;r++)n+=Math.sign(e[r]-e[r-1]);if(Math.abs(n)!=e.length-1)throw new Error("Piecewise domain must be strictly increasing or decreasing: "+JSON.stringify(e));e.forEach(r=>this.push(r))}extend(e){if(this.includes(e))return this;throw new Error("Piecewise domains are immutable and cannot be unioned!")}}const uh={quantitative:Xa,index:Xa,locus:Xa,nominal:ah,ordinal:sh};function ch(t,e){if(t=="quantitative"&&ov(e)){const n=new iv(e);return n.type=t,n}else if(uh[t]){const n=new uh[t];return n.type=t,e&&n.extendAll(e),n}throw new Error("Unknown type: "+t)}function ov(t){return t&&t.length>0&&t.length!=2&&t.every(e=>typeof e=="number")}function sv(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}const lh="quantitative",fh="ordinal",hh="nominal",dh="locus",av="index";class uv{constructor(e){this.channel=e,this.members=[],this.type=null,this._zoomExtent=void 0,this._domainListeners=new Set,this.name=void 0,this._scale=void 0}addEventListener(e,n){if(e!="domain")throw new Error("Unsupported event type: "+e);this._domainListeners.add(n)}removeEventListener(e,n){if(e!="domain")throw new Error("Unsupported event type: "+e);this._domainListeners.delete(n)}_notifyDomainListeners(){for(const e of this._domainListeners.values())e({type:"domain",scaleResolution:this})}pushUnitView(e,n){var s;const r=oa(e,n),i=r.type,o=(s=r==null?void 0:r.scale)==null?void 0:s.name;if(o){if(this.name!==void 0&&o!=this.name)throw new Error(`Shared scales have conflicting names: "${o}" vs. "${this.name}"!`);this.name=o}if(!this.type)this.type=i;else if(i!==this.type&&!Nr(n))throw new Error(`Can not use shared scale for different data types: ${this.type} vs. ${i}. Use "resolve: independent" for channel ${this.channel}`);this.members.push({view:e,channel:n})}isExplicitDomain(){return!!this.getConfiguredDomain()}_getMergedScaleProps(){return kn(this,"mergedScaleProps",()=>{const e=this.members.map(n=>oa(n.view,n.channel).scale).filter(n=>n!==void 0);return vo(e,"scale",["domain"])})}getScaleProps(){return kn(this,"scaleProps",()=>{var i,o;const e=this._getMergedScaleProps();if(e===null||e.type=="null")return{type:"null"};const n=F(F({},this._getDefaultScaleProperties(this.type)),e);n.type||(n.type=cv(this.channel,this.type));const r=this.getInitialDomain();return r&&r.length>0?n.domain=r:Zt(n.type)&&(n.domain=new ah),!n.domain&&n.domainMid!==void 0&&(n.domain=[(i=n.domainMin)!=null?i:0,(o=n.domainMax)!=null?o:1]),this.channel=="y"&&Zt(n.type)&&n.reverse==null&&(n.reverse=!0),n.range&&n.scheme&&delete n.scheme,!("zoom"in n)&&["index","locus"].includes(n.type)&&(n.zoom=!0),lv(n,this.channel),n})}getInitialDomain(){var e;return(e=this.getConfiguredDomain())!=null?e:this.type==dh?this.getGenome().getExtent():this.getDataDomain()}getConfiguredDomain(){return this._reduceDomains(e=>Nr(e.channel)?void 0:e.view.getConfiguredDomain(e.channel))}getDataDomain(){return this._reduceDomains(e=>Nr(e.channel)?void 0:e.view.extractDataDomain(e.channel))}reconfigure(){if(this._scale&&this._scale.type!="null"){N0(this,"scaleProps");const e=this.getScaleProps();th(e,this._scale),Re(this._scale.type)&&(this._zoomExtent=this._getZoomExtent())}}getScale(){if(this._scale)return this._scale;const e=this.getScaleProps(),n=jw(e);return this._scale=n,Zg(n)&&n.genome(this.getGenome()),Re(n.type)&&(this._zoomExtent=this._getZoomExtent()),n}getDomain(){return this.getScale().domain()}getComplexDomain(){var e,n;return(n=(e=this.getGenome())==null?void 0:e.toChromosomalInterval(this.getDomain()))!=null?n:this.getDomain()}isZoomed(){return this.isZoomable()&&Kl(this.getInitialDomain(),this.getDomain())}isZoomable(){if(!ff(this.channel))return!1;const e=this.getScale().type;return["linear","locus","index","log","pow","sqrt"].includes(e)?!!this.getScaleProps().zoom:!1}zoom(e,n,r){if(!this.isZoomable())return!1;const i=this.getScale(),o=i.domain();let s=[...o],a=i.invert(n);switch(this.getScaleProps().reverse&&(r=-r),"align"in i&&(a+=i.align()),i.type){case"linear":case"index":case"locus":s=ed(s,r||0),s=mu(s,a,e);break;case"log":s=td(s,r||0),s=Au(s,a,e);break;case"pow":case"sqrt":{const u=i;s=nd(s,r||0,u.exponent()),s=Io(s,a,e,u.exponent());break}default:throw new Error("Zooming is not implemented for: "+i.type)}return this._zoomExtent&&(s=id(s,this._zoomExtent[0],this._zoomExtent[1])),[0,1].some(u=>s[u]!=o[u])?(i.domain(s),this._notifyDomainListeners(),!0):!1}async zoomTo(e,n=!1){var a;if(ai(n)&&(n=n?700:0),!this.isZoomable())throw new Error("Not a zoomable scale!");const r=this.fromComplexInterval(e),i=(a=this.members[0])==null?void 0:a.view.context.animator,o=this.getScale(),s=o.domain();if(n>0&&s.length==2){const u=s[1]-s[0],c=s[0]+u/2,f=r[1]-r[0],l=r[0]+f/2,h=fl([c,0,u],[l,0,f]).rho(.7);await i.transition({duration:n/1e3*h.duration,easingFunction:sv,onUpdate:p=>{const[d,,g]=h(p);o.domain([d-g/2,d+g/2]),this._notifyDomainListeners()}}),o.domain(r),this._notifyDomainListeners()}else o.domain(r),i==null||i.requestRender(),this._notifyDomainListeners()}getZoomLevel(){return this.isZoomable()?ui(this._zoomExtent)/ui(this.getScale().domain()):1}_getZoomExtent(){const e=this.getScaleProps(),n=e.zoom;if(fv(n)&&Te(n.extent))return this.fromComplexInterval(n.extent);if(n)return e.type=="locus"?this.getGenome().getExtent():this._scale.domain()}_getDefaultScaleProperties(e){const n=this.channel,r={};return this.isExplicitDomain()&&(r.zero=!1),kr(n)?r.nice=!this.isExplicitDomain():_t(n)?r.scheme=e==hh?"tableau10":e==fh?"blues":"viridis":Zi(n)?r.range=df(n):n=="size"?r.range=[0,400]:n=="angle"&&(r.range=[0,360]),r}getGenome(){var n;if(this.type!=="locus")return;const e=(n=this.members[0].view.context.genomeStore)==null?void 0:n.getGenome();if(!e)throw new Error("No genome has been defined!");return e}invertToComplex(e){const n=this.getScale();if("invert"in n){const r=n.invert(e);return this.toComplex(r)}else throw new Error("The scale does not support inverting!")}toComplex(e){const n=this.getGenome();return n?n.toChromosomal(e):e}fromComplex(e){return oh(e)?this.getGenome().toContinuous(e.chrom,e.pos):e}fromComplexInterval(e){return this.type==="locus"&&rv(e)?this.getGenome().toContinuousInterval(e):e}_getViewPaths(){return this.members.map(e=>e.view.getPathString()).join(", ")}_reduceDomains(e){const n=this.members.map(e).filter(r=>!!r);if(n.length)return n.reduce((r,i)=>r.extendAll(i))}}function cv(t,e){if(e==av||e==dh){if(ff(t))return e;throw new Error(`${t} does not support ${e} data type. Only positional channels do.`)}const n={x:["band","band","linear"],y:["band","band","linear"],size:[void 0,"point","linear"],opacity:[void 0,"point","linear"],fillOpacity:[void 0,"point","linear"],strokeOpacity:[void 0,"point","linear"],color:["ordinal","ordinal","linear"],fill:["ordinal","ordinal","linear"],stroke:["ordinal","ordinal","linear"],strokeWidth:[void 0,void 0,"linear"],shape:["ordinal","ordinal",void 0],dx:[void 0,void 0,"null"],dy:[void 0,void 0,"null"],angle:[void 0,void 0,"linear"]},i=["uniqueId","facetIndex","semanticScore","search","text","sample"].includes(t)?"null":n[t]?n[t][[hh,fh,lh].indexOf(e)]:e==lh?"linear":"ordinal";if(i===void 0)throw new Error(`Channel "${t}" is not compatible with "${e}" data type. Use of a proper scale may be needed.`);return i}function lv(t,e){kr(e)&&t.type!=="ordinal"&&(t.range=[0,1]),e=="opacity"&&Re(t.type)&&(t.clamp=!0)}function fv(t){return ze(t)}function Za(...t){for(const e of t)if(e!==void 0)return e}class hv{constructor(e){this.channel=e,this.members=[]}get scaleResolution(){var e;return(e=Cn(this.members))==null?void 0:e.view.getScaleResolution(this.channel)}pushUnitView(e,n){const r=e.getScaleResolution(this.channel);if(!r)throw new Error("Cannot find a scale resolution!");if(this.scaleResolution&&r!==this.scaleResolution)throw new Error("Shared axes must have a shared scale!");this.members.push({view:e,channel:n})}getAxisProps(){return kn(this,"axisProps",()=>{const e=this.members.map(n=>{const r=n.view.mark.encoding[n.channel];return"axis"in r&&r.axis});return e.length>0&&e.some(n=>n===null)?null:vo(e.filter(n=>n!==void 0),"axis",["title"])})}getTitle(){const e=o=>{var a;const s=oa(o.view,o.channel);if(!Qe(s))return{member:o,explicitTitle:Za((a=s.axis)==null?void 0:a.title,s.title),implicitTitle:Za(Pr(s)?s.field:void 0,sa(s)?s.expr:void 0)}},n=this.members.map(e),r=n.filter(o=>{var s;if(Nr(o.member.channel)&&!o.explicitTitle){const a=En(o.member.channel);return((s=n.find(u=>u.member.view==o.member.view&&u.member.channel==a))==null?void 0:s.explicitTitle)===void 0}return!0}),i=new Set(r.map(o=>Za(o.explicitTitle,o.implicitTitle)).filter(q));return i.size?[...i].join(", "):null}}class ph extends K0{constructor(e,n,r,i){super(e,n,r,i),this.spec=e}}class on extends Nn{constructor(e,n,r,i){super(e,n,r,i),this.spec=e,this.children=(e.layer||[]).map((o,s)=>{if(eu(o)||$a(o))return n.createView(o,this,"layer"+s);throw new Error("LayerView accepts only unit or layer specs as children!")})}*[Symbol.iterator](){for(const e of this.children)yield e}render(e,n,r={}){if(!!this.isVisible()){e.pushView(this,n);for(const i of this.children)i.render(e,n,r);e.popView(this)}}propagateInteractionEvent(e){this.handleInteractionEvent(void 0,e,!0),this.children.length&&this.children.at(-1).propagateInteractionEvent(e),!e.stopped&&this.handleInteractionEvent(void 0,e,!1)}}class gh{constructor(e,n){this.n=e,this.maxCols=n!=null?n:1/0}get nRows(){return this.maxCols==1/0?1:Math.ceil(this.n/this.maxCols)}get nCols(){return Math.min(this.n,this.maxCols)}get rowIndices(){const e=[],n=this.nCols,r=this.nRows;for(let i=0;i<r;i++){const o=[];e.push(o);for(let s=0;s<n;s++){const a=i*n+s;a<this.n&&o.push(a)}}return e}get colIndices(){const e=[],n=this.nCols,r=this.nRows;for(let i=0;i<n;i++){const o=[];e.push(o);for(let s=0;s<r;s++){const a=s*n+i;a<this.n&&o.push(a)}}return e}getCellIndex(e,n){let r=0;if(this.maxCols==1/0)r=n==0?e:void 0;else{if(e>=this.maxCols)return;r=n*this.nCols+e}return r<this.n?r:void 0}getCellCoords(e){if(!(e<0||e>=this.n))return[e%this.nCols,Math.floor(e/this.nCols)]}}function ft(t){return()=>t}const ht=class{static create(e,n,r,i){return new ht(ft(e),ft(n),ft(r),ft(i))}_offset(e,n){const r=this["_"+e];if(n===0)return r;switch(typeof n){case"number":return()=>r()+n;case"function":return()=>r()+n();default:throw new Error("Not a number of function")}}_passThrough(e){return this._offset(e,0)}constructor(e,n,r,i){this._x=e,this._y=n,this._width=r,this._height=i}get x(){return this._x()}get y(){return this._y()}get width(){return this._width()}get height(){return this._height()}get x2(){return this._x()+this._width()}get y2(){return this._y()+this._height()}equals(e){return e?this===e||this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height:!1}modify(e){if(!Object.keys(e).length)return this;const n=r=>{const i=e[r];return typeof i=="number"?ft(i):typeof i=="function"?i:this._passThrough(r)};return new ht(n("x"),n("y"),n("width"),n("height"))}translate(e,n){return e===0&&n===0?this:new ht(this._offset("x",e),this._offset("y",n),this._passThrough("width"),this._passThrough("height"))}translateBy(e){return this.translate(e.x,e.y)}expand(e,n=1){return e.left==0&&e.top==0&&e.right==0&&e.bottom==0?this:new ht(e.left?this._offset("x",-e.left*n):this._passThrough("x"),e.top?this._offset("y",-e.top*n):this._passThrough("y"),e.width?this._offset("width",e.width*n):this._passThrough("width"),e.height?this._offset("height",e.height*n):this._passThrough("height"))}shrink(e){return this.expand(e,-1)}intersect(e){return this===e?this:new ht(()=>Math.max(this.x,e.x),()=>Math.max(this.y,e.y),()=>Math.min(this.x2,e.x2)-Math.max(this.x,e.x),()=>Math.min(this.y2,e.y2)-Math.max(this.y,e.y))}isDefined(){return this.width>=0&&this.height>=0}flatten(){return new ht(ft(this.x),ft(this.y),ft(this.width),ft(this.height))}containsPoint(e,n){return e>=this.x&&e<this.x2&&n>=this.y&&n<this.y2}normalizePoint(e,n){return{x:(e-this.x)/this.width,y:(n-this.y)/this.height}}toString(){return`Rectangle: x: ${this.x}, y: ${this.y}, width: ${this.width}, height: ${this.height}`}};let On=ht;Vh(On,"ZERO",ht.create(0,0,0,0));function dv(t,e,n){return n=(n-t)/(e-t),n=Math.max(0,Math.min(1,n)),n*n*(3-2*n)}class Gn extends _{get identifier(){}handle(e){throw new Error("Source does not handle incoming data!")}async load(){}}function mh(t){var n,r;const e=F({},t.format);if((n=e.type)!=null||(e.type=Av(t)&&pv(t.url)),(r=e.parse)!=null||(e.parse="auto"),!e.type)throw new Error("Format for the data source was not defined and it could not be inferred: "+JSON.stringify(t));return e}function pv(t){var e;if(Array.isArray(t)&&(t=t[0]),t)return(e=t.match(/\.(csv|tsv|json)/))==null?void 0:e[1]}const Co=t=>typeof t!="object"?gv:mv,gv=t=>({data:t}),mv=t=>t;function Av(t){return"url"in t}function xv(t){return"dynamicCallbackSource"in t}class Ah extends Gn{constructor(e){super(),this.callback=e}loadSynchronously(){if(!this.callback)return;const e=this.callback();if(!e||typeof e[Symbol.iterator]!="function")throw new Error("Dynamic data callback didn't return iterable data!");this.reset(),this.beginBatch({type:"file"});let n;for(const r of e)n||(n=Co(r)),this._propagate(n(r));this.complete()}async load(){this.loadSynchronously()}}const xh="chromosome_ticks_and_labels",yh={x:"width",y:"height"};function Ka(t){return t=="x"?"y":"x"}const qa={x:["bottom","top"],y:["left","right"]},bh=Object.fromEntries(Object.entries(qa).map(([t,e])=>e.map(n=>[n,t])).flat(1));function sn(t){return bh[t]}class yv extends on{constructor(e,n,r,i){const o=n=="locus",s=F(F(F({},o?vv:wh),wv(n,e)),e);if(super(o?Cv(s):vh(s),r,i,`axis_${e.orient}`),this.axisProps=s,this.axisUpdateRequested=!0,this._addBroadcastHandler("layout",()=>{this.axisUpdateRequested=!0}),this.previousScaleDomain=[],this.axisLength=void 0,this.ticks=[],this.tickSource=new Ah(()=>this.ticks),o){const a=sn(this.axisProps.orient),u=this.getScaleResolution(a).getGenome();this.findChildByName(xh).getDynamicDataSource=()=>new Ah(()=>u.chromosomes)}this.blockEncodingInheritance=!0}getOrient(){return this.axisProps.orient}getSize(){const e={px:this.getPerpendicularSize()},n={grow:1};return bh[this.axisProps.orient]=="x"?new rn(n,e):new rn(e,n)}getPerpendicularSize(){return Ja(this.axisProps)}getDynamicDataSource(){return this.tickSource}_updateAxisData(){const e=sn(this.axisProps.orient),n=this.getScaleResolution(e).getScale(),r=n.domain();if(Kl(r,this.previousScaleDomain)&&!this.axisUpdateRequested)return;this.previousScaleDomain=r;const i=this.ticks,o=bv(this.axisProps,n,this.axisLength,i);o!==i&&(this.ticks=o,this.tickSource.loadSynchronously()),this.axisUpdateRequested=!1}onBeforeRender(){super.onBeforeRender(),this._updateAxisData()}render(e,n,r={}){!this.isVisible()||(this.axisLength=n[yh[sn(this.getOrient())]],super.render(e,n,r))}isPickingSupported(){return!1}}function Ja(t){const e=sn(t.orient);let n=t.ticks&&t.tickSize||0;return t.labels&&(n+=t.labelPadding,e=="x"?n+=t.labelFontSize:n+=30),t.title&&(n+=t.titlePadding+t.titleFontSize),n=Math.min(t.maxExtent||1/0,Math.max(t.minExtent||0,n)),n}function bv(t,e,n,r=[]){const i=a=>25+60*dv(100,700,a);let o=Ae(t.tickCount)?t.tickCount:Math.round(n/i(n));o=J0(e,o,t.tickMinStep);const s=t.values?_0(e,t.values,o):Tw(e,o);if(hA(s,r,a=>a,a=>a.value))return r;{const a=Lw(e,o,t.format);return s.map(u=>({value:u,label:a(u)}))}}const wh={values:null,minExtent:20,maxExtent:1/0,offset:0,domain:!0,domainWidth:1,domainColor:"gray",domainDash:null,domainDashOffset:0,domainCap:"square",ticks:!0,tickSize:5,tickWidth:1,tickColor:"gray",tickDash:null,tickDashOffset:0,tickCap:"square",tickCount:null,tickMinStep:null,labels:!0,labelAlign:"center",labelBaseline:"middle",labelPadding:4,labelFontSize:10,labelLimit:180,labelColor:"black",format:null,titleColor:"black",titleFont:"sans-serif",titleFontSize:10,titlePadding:3};function wv(t,e){var a;const n=e.orient,r=t=="nominal"||t=="ordinal";let i="center",o="middle",s=(a=e.labelAngle)!=null?a:(n=="top"||n=="bottom")&&r?-90:0;switch(n){case"left":i="right";break;case"right":i="left";break;case"top":case"bottom":Math.abs(s)>30?(i=s>0==(n=="bottom")?"left":"right",o="middle"):o=n=="top"?"alphabetic":"top";break}return{labelAlign:i,labelAngle:s,labelBaseline:o}}function vh(t){const e=Se(F({},t),{extent:Ja(t)}),n=sn(e.orient),r=Ka(n),i=e.orient=="bottom"||e.orient=="right"?1:-1,o=e.orient=="bottom"||e.orient=="left"?1:0,s=()=>({name:"domain",data:{values:[0]},mark:{type:"rule",clip:!1,strokeDash:e.domainDash,strokeCap:e.domainCap,color:e.domainColor,[r]:o,size:e.domainWidth}}),a=()=>({name:"labels",mark:{type:"text",clip:!1,align:e.labelAlign,angle:e.labelAngle,baseline:e.labelBaseline,[r+"Offset"]:(e.tickSize+e.labelPadding)*i,[r]:o,size:e.labelFontSize,color:e.labelColor,minBufferSize:1500},encoding:{[n]:{field:"value",type:"quantitative"},text:{field:"label"}}}),u=()=>({name:"ticks",mark:{type:"rule",clip:!1,strokeDash:e.tickDash,strokeCap:e.tickCap,color:e.tickColor,size:e.tickWidth,minBufferSize:300},encoding:{[r]:{value:o},[r+"2"]:{value:o-e.tickSize/e.extent*(o?1:-1)}}}),c=()=>({name:"title",data:{values:[0]},mark:{type:"text",clip:!1,align:"center",baseline:e.orient=="bottom"?"bottom":"top",angle:[0,90,0,-90][["top","right","bottom","left"].indexOf(e.orient)],text:e.title,color:e.titleColor,[n]:.5,[r]:1-o}}),f=()=>{const h={name:"ticks_and_labels",encoding:{[n]:{field:"value",type:"quantitative"}},layer:[]};return e.ticks&&h.layer.push(u()),e.labels&&h.layer.push(a()),h},l={[yh[Ka(sn(e.orient))]]:e.extent,data:{dynamicCallbackSource:!0},layer:[]};return e.domain&&l.layer.push(s()),(e.ticks||e.labels)&&l.layer.push(f()),e.title&&l.layer.push(c()),l}const vv=Se(F({},wh),{chromTicks:!0,chromTickSize:18,chromTickWidth:1,chromTickColor:"#989898",chromTickDash:[4,2],chromTickDashOffset:1,chromLabels:!0,chromLabelFontSize:13,chromLabelFontWeight:"normal",chromLabelFontStyle:"normal",chromLabelColor:"black",chromLabelAlign:"left",chromLabelPadding:7});function Cv(t){const e=Se(F({},t),{extent:Ja(t)}),n=sn(e.orient),r=Ka(n),i=e.orient=="bottom"||e.orient=="left"?1:0,o=()=>({name:"chromosome_ticks",mark:{type:"rule",strokeDash:t.chromTickDash,strokeDashOffset:t.chromTickDashOffset,[r]:i,[r+"2"]:i-e.chromTickSize/e.extent*(i?1:-1),color:t.chromTickColor,size:e.chromTickWidth}}),s=()=>{let c;switch(e.orient){case"top":c={y:0,angle:0,paddingX:4,dy:-e.chromLabelPadding,viewportEdgeFadeWidthLeft:20,viewportEdgeFadeWidthRight:20,viewportEdgeFadeDistanceRight:-10,viewportEdgeFadeDistanceLeft:-20};break;case"bottom":c={y:1,angle:0,paddingX:4,dy:e.chromLabelPadding+e.chromLabelFontSize*.73,viewportEdgeFadeWidthLeft:20,viewportEdgeFadeWidthRight:20,viewportEdgeFadeDistanceRight:-10,viewportEdgeFadeDistanceLeft:-20};break;case"left":c={x:1,angle:-90,paddingY:4,dy:-e.chromLabelPadding,viewportEdgeFadeWidthBottom:20,viewportEdgeFadeWidthTop:20,viewportEdgeFadeDistanceBottom:-20,viewportEdgeFadeDistanceTop:-10};break;case"right":c={x:0,angle:90,align:"right",paddingY:4,dy:-e.chromLabelPadding};break;default:c={}}return{name:"chromosome_labels",mark:F({type:"text",size:e.chromLabelFontSize,font:e.chromLabelFont,fontWeight:e.chromLabelFontWeight,fontStyle:e.chromLabelFontStyle,color:e.chromLabelColor,align:t.chromLabelAlign,baseline:"alphabetic",clip:!1},c),encoding:{[n+"2"]:{field:"continuousEnd",type:"locus"},text:{field:"name"}}}};let a;switch(e.orient){case"bottom":case"top":a={};break;case"left":a={labelAngle:-90,labelAlign:"center",labelPadding:6};break;case"right":a={labelAngle:90,labelAlign:"center",labelPadding:6};break;default:a={}}const u=vh(F(F({},t),a));if(t.chromTicks||t.chromLabels){const c={name:xh,data:{dynamicCallbackSource:!0},encoding:{[n]:{field:"continuousStart",type:"locus",band:0}},layer:[]};if(t.chromTicks&&c.layer.push(o()),t.chromLabels){c.layer.push(s());let f;u.layer.filter(l=>l.name=="ticks_and_labels").forEach(l=>l.layer.filter(h=>h.name=="labels").forEach(h=>{f=h.mark})),f&&(e.orient=="top"||e.orient=="bottom"?(f.viewportEdgeFadeWidthLeft=30,f.viewportEdgeFadeDistanceLeft=40):(f.viewportEdgeFadeWidthBottom=30,f.viewportEdgeFadeDistanceBottom=40))}u.layer.push(c)}return u}const Ch={anchor:"middle",frame:"group",offset:10,orient:"top",align:void 0,angle:0,baseline:"alphabetic",dx:0,dy:0,color:void 0,font:void 0,fontSize:12,fontStyle:"normal",fontWeight:"normal"},Ev={orient:"left",anchor:"middle",align:"right",baseline:"middle",angle:0,fontSize:12},Sv={orient:"top",anchor:"start",align:"left",baseline:"top",offset:-10,dx:10,fontSize:12},Dv={start:0,middle:.5,end:1},Bv={start:"left",middle:"center",end:"right"};function Fv(t){var c,f,l;if(!t)return;const e=q(t)?{text:t}:t;if(!e.text||e.orient=="none")return;const n=(c={"track-title":Ev,overlay:Sv}[e.style])!=null?c:{},r=F(F(F({},Ch),n),e);let i={},o={x:0,y:0};const s=Dv[(f=r.anchor)!=null?f:"middle"];switch(r.orient){case"top":o={x:s,y:1},i={baseline:"alphabetic",angle:0};break;case"right":o={x:1,y:1-s},i={baseline:"alphabetic",angle:90};break;case"bottom":o={x:s,y:0},i={baseline:"top",angle:0};break;case"left":o={x:0,y:s},i={baseline:"alphabetic",angle:-90};break}const a=F(F(F(F({},Ch),i),n),e),u={xOffset:0,yOffset:0};switch(r.orient){case"top":u.yOffset=-a.offset;break;case"right":u.xOffset=a.offset;break;case"bottom":u.yOffset=a.offset;break;case"left":u.xOffset=-a.offset;break}return{configurableVisibility:!1,data:{values:[{}]},mark:Se(F(F({type:"text",tooltip:null,clip:!1},o),u),{text:a.text,align:(l=a.align)!=null?l:Bv[a.anchor],angle:a.angle,baseline:a.baseline,dx:a.dx,dy:a.dy,color:a.color,font:a.font,size:a.fontSize,fontStyle:a.fontStyle,fontWeight:a.fontWeight})}}function Mv(t,e,n,r){if(t.type=="wheel"){t.uiEvent.preventDefault();const i=t.uiEvent,o=i.deltaMode?120:1;let{x:s,y:a}=t.point;if(r){const u=r.mark.encoders;u.x&&!u.x2&&(s=+u.x(r.datum)*e.width+e.x),u.y&&!u.y2&&(a=(1-+u.y(r.datum))*e.height+e.y)}Math.abs(i.deltaX)<Math.abs(i.deltaY)?n({x:s,y:a,xDelta:0,yDelta:0,zDelta:i.deltaY*o/300}):n({x:s,y:a,xDelta:-i.deltaX*o,yDelta:0,zDelta:0})}else if(t.type=="mousedown"&&t.uiEvent.button===0){const i=t.uiEvent;i.preventDefault();let o=i;const s=u=>{n({x:o.clientX,y:o.clientY,xDelta:u.clientX-o.clientX,yDelta:u.clientY-o.clientY,zDelta:0}),o=u},a=u=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",a)};document.addEventListener("mouseup",a,!1),document.addEventListener("mousemove",s,!1)}}class Eh extends Nn{constructor(n,r,i,o,s){var a;super(n,r,i,o);ge(this,Jr);ge(this,tt);ge(this,So);ge(this,Do);ge(this,an);ge(this,_r);ge(this,$r);ge(this,ei);ge(this,Bo);ge(this,Un,1/0);ge(this,Hn,10);ge(this,Ne,[]);ge(this,Qn,0);this.spec=n,ti(this,Hn,(a=n.spacing)!=null?a:10),ti(this,Un,s),ti(this,Ne,[]),this.wrappingFacet=!1,this._createChildren()}_createChildren(){}appendChild(n){var r;(r=n.parent)!=null||(n.parent=this),Z(this,Ne).push(ce(this,Jr,lu).call(this,n)),Yh(this,Qn)._++}setChildren(n){for(const r of n)this.appendChild(r)}replaceChild(n,r){const i=Z(this,Ne).findIndex(o=>o.view==n);if(i>=0)Z(this,Ne)[i]=ce(this,Jr,lu).call(this,r);else throw new Error("Not my child view!")}get children(){return Z(this,Ne).map(n=>n.view)}get childCount(){return Z(this,Ne).length}onScalesResolved(){super.onScalesResolved(),ce(this,Do,Xh).call(this)}*[Symbol.iterator](){for(const n of Z(this,Ne)){n.background&&(yield n.background);for(const r of Object.values(n.axes))r&&(yield r);yield n.view,n.title&&(yield n.title)}}getOverhang(){const n=ce(this,an,ni).call(this,"column"),r=ce(this,an,ni).call(this,"row");return!n.length||!r.length?Ye.zero():new Ye(r.at(0).axisBefore,n.at(-1).axisAfter,r.at(-1).axisAfter,n.at(0).axisBefore)}getSize(){return this._cache("size",()=>new rn(ce(this,$r,hu).call(this,"column"),ce(this,$r,hu).call(this,"row")).subtractPadding(this.getOverhang()).addPadding(this.getPadding()))}render(n,r,i={}){var c;if(!this.isVisible())return;r=r.shrink(this.getPadding()),n.pushView(this,r);const o={devicePixelRatio:this.context.glHelper.dpr},s=W0(ce(this,_r,fu).call(this,"column"),r.width,o),a=W0(ce(this,_r,fu).call(this,"row"),r.height,o),u=new gh(Z(this,tt,Tt).length,(c=Z(this,Un))!=null?c:1/0);for(const[f,l]of Z(this,tt,Tt).entries()){const{view:h,axes:p,background:d,title:g}=l,[A,m]=u.getCellCoords(f),b=s[ce(this,ei,du).call(this,"column",A)],y=a[ce(this,ei,du).call(this,"row",m)],v=h.getSize(),E=h.getPadding().subtract(h.getOverhang()),C=b.location+E.left,B=y.location+E.top,L=(v.width.grow?b.size:v.width.px)-E.width,R=(v.height.grow?y.size:v.height.px)-E.height,Q=new On(()=>r.x+C,()=>r.y+B,()=>L,()=>R);l.coords=Q,d==null||d.render(n,Q,i);const T=Pv(h);T&&h.render(n,Q,i);for(const[Ce,se]of Object.entries(p)){const Be=se.axisProps;let nt;const Fe=se.getPerpendicularSize();Ce=="bottom"?nt=Q.translate(0,Q.height+Be.offset).modify({height:Fe}):Ce=="top"?nt=Q.translate(0,-Fe-Be.offset).modify({height:Fe}):Ce=="left"?nt=Q.translate(-Fe-Be.offset,0).modify({width:Fe}):Ce=="right"&&(nt=Q.translate(Q.width+Be.offset,0).modify({width:Fe})),se.render(n,nt)}T||h.render(n,Q,i),g==null||g.render(n,Q,Se(F({},i),{clipRect:void 0}))}n.popView(this)}propagateInteractionEvent(n){if(this.handleInteractionEvent(void 0,n,!0),n.stopped)return;const r=Z(this,tt,Tt).find(o=>o.coords.containsPoint(n.point.x,n.point.y)),i=r==null?void 0:r.view;i&&(i.propagateInteractionEvent(n),(i instanceof ve||i instanceof on)&&Mv(n,r.coords,o=>ce(this,Bo,Zh).call(this,r.coords,r.view,o),this.context.getCurrentHover())),!n.stopped&&this.handleInteractionEvent(void 0,n,!1)}getDefaultResolution(n,r){return"independent"}}Un=new WeakMap,Hn=new WeakMap,Ne=new WeakMap,Qn=new WeakMap,Jr=new WeakSet,lu=function(n){var i;const r={view:n,background:void 0,axes:{},coords:On.ZERO};if(n instanceof ve||n instanceof on){const o=(i=n.spec)==null?void 0:i.view;if((o==null?void 0:o.fill)||(o==null?void 0:o.stroke)){const a=new ve(Iv(o),this.context,n,"background"+Z(this,Qn));a.blockEncodingInheritance=!0,r.background=a}const s=Fv(n.spec.title);if(s){const a=new ve(s,this.context,n,"title"+Z(this,Qn));a.blockEncodingInheritance=!0,r.title=a}}return r},tt=new WeakSet,Tt=function(){return Z(this,Ne).filter(n=>n.view.isVisible())},So=new WeakSet,Wh=function(){var n;return new gh(Z(this,tt,Tt).length,(n=Z(this,Un))!=null?n:1/0)},Do=new WeakSet,Xh=function(){if(Object.keys(this.resolutions.axis).length)throw new Error("ConcatView does not (currently) support shared axes!");for(const n of Z(this,Ne)){const{view:r,axes:i}=n,o=(s,a,u)=>{var f;const c=s.getAxisProps();if(c!==null){if(!c.orient){for(const l of qa[a])if(!i[l]){c.orient=l;break}if(!c.orient)throw new Error("No slots available for an axis! Perhaps a LayerView has more than two children?")}if((f=c.title)!=null||(c.title=s.getTitle()),!qa[a].includes(c.orient))throw new Error(`Invalid axis orientation "${c.orient}" on channel "${a}"!`);if(i[c.orient])throw new Error(`An axis with the orient "${c.orient}" already exists!`);i[c.orient]=new yv(c,s.scaleResolution.type,this.context,u)}};if(r instanceof ve||r instanceof on)for(const s of["x","y"]){const a=r.resolutions.axis[s];!a||o(a,s,r)}if(r instanceof on){for(const s of r.children)for(const[a,u]of Object.entries(s.resolutions.axis)){const c=u.getAxisProps();c&&c.orient&&o(u,a,s)}for(const s of r.children)for(const[a,u]of Object.entries(s.resolutions.axis)){const c=u.getAxisProps();c&&!c.orient&&o(u,a,s)}}}},an=new WeakSet,ni=function(n){const r=n=="column"?["left","right"]:["top","bottom"],i=n=="column"?"width":"height",o=(s,a)=>s.map(u=>{const c=Z(this,tt,Tt)[u].axes[r[a]];if(c)return Math.max(c.getPerpendicularSize()+c.axisProps.offset,0);const f=Z(this,tt,Tt)[u].view.getOverhang();return n=="column"?a?f.right:f.left:a?f.bottom:f.top}).reduce((u,c)=>Math.max(u,c),0);return Z(this,So,Wh)[n=="column"?"colIndices":"rowIndices"].map(s=>({axisBefore:o(s,0),axisAfter:o(s,1),view:Cw(s.map(a=>Z(this,tt,Tt)[a].view.getSize()[i]))}))},_r=new WeakSet,fu=function(n){const r=ce(this,an,ni).call(this,n),i=[];i.push(Xr);for(const[o,s]of r.entries())o>0&&i.push({px:Z(this,Hn),grow:0}),(o==0||this.wrappingFacet)&&i.push(Xr),i.push({px:s.axisBefore,grow:0}),i.push(s.view),i.push({px:s.axisAfter,grow:0}),(o==r.length-1||this.wrappingFacet)&&i.push(Xr);return i},$r=new WeakSet,hu=function(n){var s,a;let r=0,i=0;const o=ce(this,an,ni).call(this,n);for(const[u,c]of o.entries())u>0&&(i+=Z(this,Hn)),(u==0||this.wrappingFacet)&&(i+=0),i+=c.axisBefore,i+=(s=c.view.px)!=null?s:0,r+=(a=c.view.grow)!=null?a:0,i+=c.axisAfter,(u==o.length-1||this.wrappingFacet)&&(i+=0);return{px:i,grow:r}},ei=new WeakSet,du=function(n,r){return n=="row"&&this.wrappingFacet?1+6*r+2:2+4*r+1},Bo=new WeakSet,Zh=function(n,r,i){for(const[o,s]of Object.entries(Tv(r))){if(s.size<=0)continue;const a=n.normalizePoint(i.x,i.y),u=n.normalizePoint(i.x+i.xDelta,i.y+i.yDelta),c={x:u.x-a.x,y:u.y-a.y};for(const f of s)f.zoom(2**i.zDelta,o=="y"?1-a[o]:a[o],o=="x"?c.x:-c.y)}this.context.animator.requestRender()};function Iv(t){return{configurableVisibility:!1,data:{values:[{}]},mark:Se(F({fill:null,strokeWidth:1,fillOpacity:t.fill?1:0},t),{type:"rect",clip:!1,tooltip:null})}}function Tv(t){const e={x:new Set,y:new Set};return t.visit(n=>{for(const[r,i]of Object.entries(e)){const o=n.getScaleResolution(r);o&&o.isZoomable()&&i.add(o)}}),e}function Pv(t){let e=!0;return t.visit(n=>{n instanceof ve&&e&&(e=n.mark.properties.clip)}),e}class _a extends Eh{constructor(e,n,r,i){super(e,n,r,i,nu(e)?e.columns:tu(e)?1:1/0),this.spec=e}_createChildren(){const e=this.spec,n=nu(e)?e.concat:tu(e)?e.vconcat:e.hconcat;this.setChildren(n.map((r,i)=>this.context.createView(r,this,"grid"+i)))}}class Lv{constructor(){this.types=[];const e=n=>(r,i,o,s)=>{var a;return new n(r,i,o,(a=r.name)!=null?a:s)};this.addViewType(Rv,e(ph)),this.addViewType(eu,e(on)),this.addViewType($a,e(ve)),this.addViewType(tu,e(_a)),this.addViewType(kv,e(_a)),this.addViewType(nu,e(_a))}addViewType(e,n){this.types.push({specGuard:e,factory:n})}createView(e,n,r,i){const o=this.types.find(s=>s.specGuard(e));if(o)return o.factory(e,n,r,i!=null?i:"unnamed");throw new Error("Invalid spec, cannot figure out the view type from the properties: "+JSON.stringify([...Object.keys(e)]))}isViewSpec(e){const n=this.types.filter(r=>r.specGuard(e));if(n.length>1)throw new Error("Ambiguous spec. Cannot create a view!");return n.length==1}}function $a(t){return"mark"in t&&(q(t.mark)||ze(t.mark))}function eu(t){return"layer"in t&&ze(t.layer)}function Sh(t){return t&&($a(t)||eu(t))&&"aggregateSamples"in t}function Rv(t){return"import"in t}function tu(t){return"vconcat"in t&&Te(t.vconcat)}function kv(t){return"hconcat"in t&&Te(t.hconcat)}function nu(t){return"concat"in t&&Te(t.concat)}const Nv={point:cw,rect:nw,rule:hw,link:mw,text:vw};class ve extends Nn{constructor(e,n,r,i){super(e,n,r,i),this.spec=e;const o=Nv[this.getMarkType()];if(o)this.mark=new o(this);else throw new Error(`No such mark: ${this.getMarkType()}`);this.sampleAggregateViews=[],this._initializeAggregateViews(),this.coords=void 0}*[Symbol.iterator](){for(const e of this.sampleAggregateViews)yield e}replaceChild(e,n){const r=this.sampleAggregateViews.indexOf(e);if(r>=0)this.sampleAggregateViews[r]=n;else throw new Error("Not my child view!")}render(e,n,r={}){!this.isVisible()||(this.coords=n,e.pushView(this,n),e.renderMark(this.mark,r),e.popView(this))}getMarkType(){return typeof this.spec.mark=="object"?this.spec.mark.type:this.spec.mark}resolve(e){var r;const n=this.mark.encoding;for(const[i,o]of Object.entries(n)){if(!ke(o))continue;let s=En((r=o.resolutionChannel)!=null?r:i);if(e=="axis"&&!kr(s))continue;let a=this;for(;a.parent instanceof Nn&&["shared","excluded"].includes(a.parent.getConfiguredOrDefaultResolution(s,e))&&a.getConfiguredOrDefaultResolution(s,e)!="excluded";)a=a.parent;a.resolutions[e][s]||(a.resolutions[e][s]=e=="scale"?new uv(s):new hv(s)),kr(i)?a.resolutions[e][s].pushUnitView(this,i):e=="scale"&&a.resolutions[e][s].pushUnitView(this,i)}}getAccessor(e){return this._cache("accessor/"+e,()=>{const n=this.mark.encoding;if(n&&n[e])return this.context.accessorFactory.createAccessor(n[e])})}getFacetAccessor(e){const n=this.getAccessor("sample");return n||super.getFacetAccessor(this)}getCollector(){return this.context.dataFlow.findCollectorByKey(this)}_validateDomainQuery(e){if(Nr(e))throw new Error(`getDomain(${e}), must only be called for primary channels!`);const n=this.mark.encoding[e];if(!ke(n))throw new Error("The channel has no scale, cannot get domain!");return n}getConfiguredDomain(e){var i,o;const n=this._validateDomainQuery(e),r=n&&n.scale&&n.scale.domain;if(r){const s=this.getScaleResolution((i=n.resolutionChannel)!=null?i:e);return ch((o=n.type)!=null?o:"nominal",s.fromComplexInterval(r))}}extractDataDomain(e){var a;const r=(a=this._validateDomainQuery(e).type)!=null?a:"nominal",i=u=>{let c;const f=this.mark.encoding[u];if(f){const l=this.context.accessorFactory.createAccessor(f);if(l)if(c=ch(r),l.constant)c.extend(l({}));else{const h=this.getCollector();h!=null&&h.completed&&h.visitData(p=>c.extend(l(p)))}}return c};let o=i(e);const s=aa[e];if(s){const u=i(s);u&&o.extendAll(u)}return o}getZoomLevel(){const e=n=>{var r,i;return(i=(r=this.getScaleResolution(n))==null?void 0:r.getZoomLevel())!=null?i:1};return Rr.map(e).reduce((n,r)=>n*r,1)}_initializeAggregateViews(){var e,n;if(Sh(this.spec))for(const r of this.spec.aggregateSamples){const i=(e=r.transform)!=null?e:[];i.length&&Cn(i).type!="collect"&&i.push({type:"collect"}),i.push({type:"mergeFacets"}),r.transform=i,r.encoding=Se(F({},(n=r.encoding)!=null?n:{}),{sample:null});const o=this.context.createView(r,this,"summaryView");o.getFacetFields=s=>{},this.sampleAggregateViews.push(o)}}propagateInteractionEvent(e){e.target=this}getDefaultResolution(e,n){return e=="x"?"shared":"independent"}}function*ru(t,e=[]){for(const[n,r]of t.entries())if(r instanceof Map)for(const i of ru(r,[...e,n]))yield i;else yield[[...e,n],r]}class iu extends _{constructor(e){super(),this.params=e!=null?e:{type:"collect"},this.observers=[],this.facetBatches=void 0,this._init()}_init(){this._data=[],this.facetBatches=new Rt([],JSON.stringify),this.facetBatches.set(void 0,this._data)}reset(){super.reset(),this._init()}handle(e){this._data.push(e)}beginBatch(e){sw(e)&&(this._data=[],this.facetBatches.set(Je(e.facetId),this._data))}complete(){var i,o;const e=(i=this.params)==null?void 0:i.sort,n=e?xu(e.field,e.order):void 0,r=s=>{n&&s.sort(n)};if((o=this.params.groupby)!=null&&o.length){if(this.facetBatches.size>1)throw new Error("TODO: Support faceted data!");const s=this.params.groupby.map(u=>j(u)),a=hi(this._data,...s);this.facetBatches.clear();for(const[u,c]of ru(a))this.facetBatches.set(u,c)}for(const s of this.facetBatches.values())r(s);if(this.children.length)for(const[s,a]of this.facetBatches.entries()){if(s){const u={type:"facet",facetId:s};for(const c of this.children)c.beginBatch(u)}for(const u of a)this._propagate(u)}super.complete();for(const s of this.observers)s(this)}getData(){switch(this._checkStatus(),this.facetBatches.size){case 0:return[];case 1:return[...this.facetBatches.values()][0];default:{const e=this.facetBatches;return{[Symbol.iterator]:function*(){for(const r of e.values())for(let i=0;i<r.length;i++)yield r[i]}}}}}visitData(e){this._checkStatus();for(const n of this.facetBatches.values())for(let r=0;r<n.length;r++)e(n[r])}getItemCount(){let e=0;for(const n of this.facetBatches.values())e+=n.length;return e}_checkStatus(){if(!this.completed)throw new Error("Data propagation is not completed! No data are available.")}}class Eo{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(e,n){let r=this.length++;for(;r>0;){const i=r-1>>1,o=this.values[i];if(n>=o)break;this.ids[r]=this.ids[i],this.values[r]=o,r=i}this.ids[r]=e,this.values[r]=n}pop(){if(this.length===0)return;const e=this.ids[0];if(this.length--,this.length>0){const n=this.ids[0]=this.ids[this.length],r=this.values[0]=this.values[this.length],i=this.length>>1;let o=0;for(;o<i;){let s=(o<<1)+1;const a=s+1;let u=this.ids[s],c=this.values[s];const f=this.values[a];if(a<this.length&&f<c&&(s=a,u=this.ids[a],c=f),c>=r)break;this.ids[o]=u,this.values[o]=c,o=s}this.ids[o]=n,this.values[o]=r}return e}peek(){if(this.length!==0)return this.ids[0]}peekValue(){if(this.length!==0)return this.values[0]}shrink(){this.ids.length=this.values.length=this.length}}class zv extends _{get behavior(){return lt}constructor(e){super(),this.params=e,this.startAccessor=j(e.start),this.endAccessor=j(e.end),this.chromAccessor=e.chrom?j(e.chrom):n=>{},this.weightAccessor=e.weight?j(e.weight):n=>1,this.as={coverage:e.as||"coverage",start:e.asStart||e.start,end:e.asEnd||e.end,chrom:e.asChrom||e.chrom},this.createSegment=new Function("start","end","coverage","chrom","return {"+Object.entries(this.as).filter(([n,r])=>r).map(([n,r])=>`${JSON.stringify(r)}: ${n}`).join(", ")+"};"),this.ends=new Eo}reset(){super.reset(),this.initialize()}initialize(){const e=this.as.coverage,n=this.as.end,r=this.as.chrom,i=this.startAccessor,o=this.endAccessor,s=this.chromAccessor,a=this.weightAccessor;let u,c,f,l=0,h;const p=this.ends;p.clear();const d=(A,m,b)=>{if(A==m)return;let y=!1;u&&(u[e]===b?(u[n]=m,y=!0):u[e]!=0&&this._propagate(u)),y||(u=this.createSegment(A,m,b,f))},g=()=>{let A;for(;(A=p.peekValue())!==void 0;)d(h,A,l),h=A,l-=p.pop();h=void 0,u&&(this._propagate(u),u=void 0)};this.handle=A=>{const m=i(A);let b;for(;(b=p.peekValue())!==void 0&&b<m;)d(h,b,l),h=b,l-=p.pop();if(r){let v=s(A);v!==c&&(g(),f=v,c=f)}h!==void 0&&d(h,m,l),h=m;const y=a(A);l+=y,p.push(y,o(A))},this.complete=()=>{g(),super.complete()}}}function Ov(t,e,n=0,r=t.length){const i=new Eo,o=r-n;let s;for(s=0;s<e&&s<o;s++)i.push(s,t[n+s]);for(;s<o;s++){const c=t[n+s];c>=i.peekValue()&&(i.push(s,c),i.pop())}const a=[];let u;for(;(u=i.pop())!==void 0;)a.push(n+u);return a.reverse()}class Gv{constructor(e,n=-1/0,r=1/0){this.maxSize=e,this.lowerLimit=n,this.upperLimit=r;const i=this.maxSize*2+1;this.lowerLimits=new Float64Array(i),this.upperLimits=new Float64Array(i),this.lowerChildren=new Int32Array(i),this.upperChildren=new Int32Array(i),this.reset()}reset(){this.lowerLimits.fill(0),this.upperLimits.fill(0),this.lowerChildren.fill(0),this.upperChildren.fill(0),this.n=1,this.lowerLimits[0]=this.lowerLimit,this.upperLimits[0]=this.upperLimit}_findSlot(e,n,r=0){if(e>=this.lowerLimits[r]&&n<=this.upperLimits[r]){const i=this.lowerChildren[r];if(i){const o=this._findSlot(e,n,i);return o>=0?o:this._findSlot(e,n,this.upperChildren[r])}else return r}else return-1}reserve(e,n){if(n-e<=0)throw new Error("Cannot reserve an empty or negative-size slot!");if(this.n+1>this.lowerLimits.length)return!1;const r=this._findSlot(e,n);if(r<0)return!1;const i=this.n++,o=this.n++;return this.lowerLimits[i]=this.lowerLimits[r],this.upperLimits[i]=e,this.lowerLimits[o]=n,this.upperLimits[o]=this.upperLimits[r],this.lowerChildren[r]=i,this.upperChildren[r]=o,!0}}class Uv extends _{constructor(e,n){var i,o;if(super(),this.params=e,this._data=[],this.channel=(i=e.channel)!=null?i:"x",!["x","y"].includes(this.channel))throw new Error("Invalid channel: "+this.channel);this.posAccessor=j(this.params.pos),this.posBisector=fi(this.posAccessor),this.scoreAccessor=j(this.params.score),this.widthAccessor=j(this.params.width),this.laneAccessor=this.params.lane?j(this.params.lane):s=>0,this.padding=(o=this.params.padding)!=null?o:0,this.reservationMaps=new Map,this.resolution=n.getScaleResolution(this.channel);const r=()=>this._filterAndPropagate();this.schedule=()=>n.context.animator.requestTransition(r),this.resolution.addEventListener("domain",s=>this.schedule()),n._addBroadcastHandler("layoutComputed",()=>this.schedule())}complete(){const e=this.posAccessor;this._data.sort((n,r)=>e(n)-e(r)),this._scores=this._data.map(this.scoreAccessor);for(const n of new Set(this._data.map(this.laneAccessor)))this.reservationMaps.set(n,new Gv(200));this.schedule(),super.complete()}_filterAndPropagate(){var s;super.reset();const e=this.resolution.getScale(),n=(s=this.resolution.members[0].view.coords)==null?void 0:s[this.channel=="x"?"width":"height"];if(!n)return;for(const a of this.reservationMaps.values())a.reset();const r=e.domain(),i=70,o=Ov(this._scores,i,this.posBisector.left(this._data,r[0]),this.posBisector.right(this._data,r[1]));for(const a of o){const u=this._data[a],c=e(this.posAccessor(u))*n,f=this.widthAccessor(u)/2+this.padding;this.reservationMaps.get(this.laneAccessor(u)).reserve(c-f,c+f)&&this._propagate(u)}super.complete()}reset(){super.reset(),this._data=[],this.groups=new Map}handle(e){this._data.push(e)}}class Hv extends _{constructor(e){super(),this.params=e,this.predicate=void 0}initialize(){this.predicate=ia(this.params.expr,this.getGlobalObject())}handle(e){this.predicate(e)&&this._propagate(e)}}const Qv="0".charCodeAt(0);function*jv(t,e=","){const n=e.charCodeAt(0);let r=0;for(let i=0;i<t.length;i++){const o=t.charCodeAt(i);o==n?(yield r,r=0):r=r*10+o-Qv}yield r}class Vv extends _{get behavior(){return lt}constructor(e){var s,a;super();const n=j((s=e.exons)!=null?s:"exons"),r=j((a=e.start)!=null?a:"start"),[i,o]=e.as||["exonStart","exonEnd"];this.handle=u=>{let c=r(u),f=c,l=!0;const h=n(u);for(const p of jv(h)){if(l)f=c+p;else{c=f+p;const d=Object.assign({},u);d[i]=f,d[o]=c,this._propagate(d)}l=!l}}}}class Yv extends _{get behavior(){return lt}constructor(e){super();const n=Je(e.field).map(o=>j(o)),r=Je(e.separator),i=Je(e.as||e.field);if(n.length!==r.length||n.length!==i.length)throw new Error(`Lengths of "separator" (${r.length}), "fields" (${n.length}), and "as" (${i.length}) do not match!`);this.handle=o=>{if(n.some(u=>!u(o)))return;const s=n.map((u,c)=>u(o).split(r[c]));Wv(s,o);const a=s[0].length;for(let u=0;u<a;u++){const c=Object.assign({},o);for(let f=0;f<n.length;f++)c[i[f]]=s[f][u];this._propagate(c)}}}}function Wv(t,e){const n=t.map(r=>r.length);if(!n.every(r=>r==n[0]))throw new Error("Mismatching number of elements in the fields to be split: "+JSON.stringify(e))}class Xv extends _{get behavior(){return It}constructor(e){super(),this.params=e,this.as=e.as,this.fn=void 0}initialize(){this.fn=ia(this.params.expr,this.getGlobalObject())}handle(e){e[this.as]=this.fn(e),this._propagate(e)}}class Dh extends _{get behavior(){return It}constructor(e,n){var d;super();const r=(d=e.channel)!=null?d:"x";if(!["x","y"].includes(r))throw new Error("Invalid channel: "+r);const i=n.getScaleResolution(r).getGenome();if(!i)throw new Error("LinearizeGenomicCoordinate transform requires a locus scale!");const o=j(e.chrom),s=Je(e.pos).map(g=>j(g)),a=Je(e.as);if(s.length!=a.length)throw new Error('The number of "pos" and "as" elements must be equal!');const u=Je(e.offset);let c;if(u.length==0)c=new Array(s.length).fill(0);else if(u.length==1)c=new Array(s.length).fill(u[0]);else if(u.length==s.length)c=u;else throw new Error(`Invalid "offset" parameter: ${JSON.stringify(e.offset)}!`);const f=new Function("datum","chromOffset","posAccessors",a.map((g,A)=>`datum[${JSON.stringify(g)}] = chromOffset + +posAccessors[${A}](datum) - ${c[A]};`).join(`
|
|
143
|
+
*/const Ow="locus",Gw="index";var Uw=5;function Hw(t){const e=t.type;return!t.bins&&(e===bn||e===br||e===wr)}function $0(t){return Re(t)&&![qe,Gw,Ow].includes(t)}function eh(t){return t||{warn:(e,...n)=>console.warn(e,...n)}}var Qw=li(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma","zoom","fp64","name"]);function th(t,e,n){n=eh(n);for(const r in t)if(!Qw[r]){if(r==="padding"&&$0(e.type))continue;me(e[r])?e[r](t[r]):n.warn("Unsupported scale property: "+r)}qw(e,t,Kw(e,t,Ww(e,t,n)))}function jw(t,e){const n=Vw(t),r=U(n);if(!r)throw new Error("Unknown scale type: "+n);const i=r();return th(t,i,e),i}function Vw(t){var e=t.type,n="",r;return e===qe?qe+"-"+bn:(Yw(t)&&(r=t.rawDomain?t.rawDomain.length:t.domain?t.domain.length+ +(t.domainMid!=null):0,n=r===2?qe+"-":r===3?wn+"-":""),(n+e||bn).toLowerCase())}function Yw(t){const e=t.type;return Re(e)&&e!==Nl&&e!==zl&&(t.scheme||t.range&&t.range.length&&t.range.every(q))}function Ww(t,e,n){if(!t.domain)return 0;n=eh(n);var r=Xw(t,e.domainRaw,n);if(r>-1)return r;var i=e.domain,o=t.type,s=e.zero||e.zero===void 0&&Hw(t),a,u;return i?($0(o)&&e.padding&&i[0]!==Oe(i)&&(i=Zw(o,i,e.range,e.padding,e.exponent,e.constant)),(s||e.domainMin!=null||e.domainMax!=null||e.domainMid!=null)&&(a=(i=i.slice()).length-1||1,s&&(i[0]>0&&(i[0]=0),i[a]<0&&(i[a]=0)),e.domainMin!=null&&(i[0]=e.domainMin),e.domainMax!=null&&(i[a]=e.domainMax),e.domainMid!=null&&(u=e.domainMid,(u<i[0]||u>i[a])&&n.warn("Scale domainMid exceeds domain min or max.",u),i.splice(a,0,u))),t.domain(nh(o,i,n)),o===Ys&&t.unknown(e.domainImplicit?hs:void 0),e.nice&&t.nice&&t.nice(e.nice!==!0&&J0(t,e.nice)||null),i.length):0}function Xw(t,e,n){return e?(t.domain(nh(t.type,e,n)),e.length):-1}function Zw(t,e,n,r,i,o){var s=Math.abs(Oe(n)-n[0]),a=s/(s-2*r),u=t===vt?Au(e,null,a):t===wr?Io(e,null,a,.5):t===br?Io(e,null,a,i||1):t===Oi?rd(e,null,a,o||1):mu(e,null,a);return e=e.slice(),e[0]=u[0],e[e.length-1]=u[1],e}function nh(t,e,n){if(Vl(t)){var r=Math.abs(e.reduce(function(i,o){return i+(o<0?-1:o>0?1:0)},0));r!==e.length&&n.warn("Log scale domain includes zero: "+ci(e))}return e}function Kw(t,e,n){let r=e.bins;if(r&&!Te(r)){const i=(r.start==null||r.stop==null)&&t.domain(),o=r.start==null?i[0]:r.start,s=r.stop==null?Oe(i):r.stop,a=r.step;a||K("Scale bins parameter missing step property."),r=Zn(o,s+a,a)}return r?t.bins=r:t.bins&&delete t.bins,t.type===Xs&&(r?!e.domain&&!e.domainRaw&&(t.domain(r),n=r.length):t.bins=t.domain()),n}function qw(t,e,n){var r=t.type,i=e.round||!1,o=e.range;if(e.rangeStep!=null)o=Jw(r,e,n);else if(e.scheme&&(o=_w(r,e,n),me(o))){if(t.interpolator)return t.interpolator(o);K(`Scale type ${r} does not support interpolating color schemes.`)}if(o&&Ui(r))return t.interpolator(Hi(Wa(o,e.reverse),e.interpolate,e.interpolateGamma));o&&e.interpolate&&t.interpolate?t.interpolate(Yl(e.interpolate,e.interpolateGamma)):me(t.round)?t.round(i):me(t.rangeRound)&&t.interpolate(i?xr:bt),o&&t.range(Wa(o,e.reverse))}function Jw(t,e,n){t!==Ul&&t!==Ws&&K("Only band and point scales support rangeStep.");var r=(e.paddingOuter!=null?e.paddingOuter:e.padding)||0,i=t===Ws?1:(e.paddingInner!=null?e.paddingInner:e.padding)||0;return[0,e.rangeStep*js(n,i,r)]}function _w(t,e,n){var r=e.schemeExtent,i,o;return Te(e.scheme)?o=Hi(e.scheme,e.interpolate,e.interpolateGamma):(i=e.scheme.toLowerCase(),o=Ks(i),o||K(`Unrecognized scheme name: ${e.scheme}`)),n=t===Gl?n+1:t===Xs?n-1:t===Vs||t===Ol?+e.schemeCount||Uw:n,Ui(t)?rh(o,r,e.reverse):me(o)?aA(rh(o,r),n):t===Ys?o:o.slice(0,n)}function rh(t,e,n){return me(t)&&(e||n)?sA(t,Wa(e||[0,1],n)):t}function Wa(t,e){return e?t.slice().reverse():t}const ih=ae(",d");function $w(t,e){return t.chrom+":"+ih(Math.floor(t.pos+1))+"-"+(t.chrom!=e.chrom?e.chrom+":":"")+ih(Math.ceil(e.pos))}const ev="https://genomespy.app/data/genomes/";class tv{constructor(e){if(this.config=e,!this.config.contigs&&typeof this.config.name!="string")throw new Error("No name has been defined for the genome assembly!");this.chromosomes=[],this.cumulativeChromPositions=new Map,this.chromosomesByName=new Map,this.startByIndex=[],this.totalSize=0,this.config.contigs&&this.setChromSizes(this.config.contigs)}get name(){return this.config.name}async load(e){if(!this.config.contigs){this.config.baseUrl?this.baseUrl=/^http(s)?/.test(this.config.baseUrl)?this.config.baseUrl:e+"/"+this.config.baseUrl:this.baseUrl=ev;try{this.setChromSizes(nv(await Ei({baseURL:this.baseUrl}).load(`${this.config.name}/${this.name}.chrom.sizes`)))}catch(n){throw new Error(`Could not load chrom sizes: ${n.message}`)}}}setChromSizes(e){let n=0;this.startByIndex=[0];for(let r=0;r<e.length;r++){this.startByIndex.push(n);const i=e[r].size,o=Se(F({},e[r]),{continuousStart:n,continuousEnd:n+i,continuousInterval:[n,n+i],index:r,number:r+1,odd:!(r&1)});this.chromosomes.push(o);const s=o.name.replace(/^chr/i,"");for(const a of["chr"+s,"CHR"+s,"Chr"+s,o.number,""+o.number,s,o.name])this.cumulativeChromPositions.set(a,n),this.chromosomesByName.set(a,o);n+=o.size}this.totalSize=n}getExtent(){return[0,this.totalSize]}toContinuous(e,n){let r=this.cumulativeChromPositions.get(e);if(r===void 0)throw new Error("Unknown chromosome/contig: "+e);return r+ +n}toChromosome(e){if(e>=this.totalSize)return;e=Math.floor(e);const n=cn(this.startByIndex,e)-1;if(n>0&&n<=this.chromosomes.length)return this.chromosomes[n-1]}toChromosomal(e){const n=this.toChromosome(e);if(!!n)return{chrom:n.name,pos:Math.floor(e)-n.continuousStart}}getChromosome(e){return this.chromosomesByName.get(e)}formatInterval(e){return $w(...this.toChromosomalInterval(e))}toChromosomalInterval(e){const n=this.toChromosomal(e[0]+.5),r=this.toChromosomal(e[1]-.5);return r.pos+=1,[n,r]}toContinuousInterval(e){var i,o,s;let[n,r]=e;return r||(r=n),[this.toContinuous(n.chrom,(i=n.pos)!=null?i:0),this.toContinuous(r.chrom,(s=r.pos)!=null?s:(o=this.chromosomesByName.get(r.chrom))==null?void 0:o.size)]}parseInterval(e){const n=e.match(/^(chr[0-9A-Z]+)(?::([0-9,]+)(?:-(?:(chr[0-9A-Z]+):)?([0-9,]+))?)?$/);if(n){const r=n[1];if(n.slice(2).every(a=>a===void 0)){const a=this.getChromosome(r);return a?[a.continuousStart,a.continuousEnd]:void 0}const i=n[3]||r,o=parseInt(n[2].replace(/,/g,"")),s=n[4]!==void 0?parseInt(n[4].replace(/,/g,"")):o;return[this.toContinuous(r,o-1),this.toContinuous(i,s)]}}}function nv(t){return vd(t).filter(e=>/^chr[0-9A-Z]+$/.test(e[0])).map(([e,n])=>({name:e,size:parseInt(n)}))}function oh(t){return ze(t)&&"chrom"in t}function rv(t){return t.every(oh)}class Kr extends Array{constructor(){super(),this.type=void 0}extend(e){return this}extendAll(e){if(e instanceof Kr&&e.type!=this.type)throw new Error(`Cannot combine different types of domains: ${this.type} and ${e.type}`);for(const n of e)this.extend(n);return this}extendAllWithAccessor(e,n){for(const r of e)this.extend(n(r));return this}}class Xa extends Kr{constructor(){super(),this.type="quantitative"}extend(e){return e==null||Number.isNaN(e)?this:(e=+e,this.length?e<this[0]?this[0]=e:e>this[1]&&(this[1]=e):(this.push(e),this.push(e)),this)}}class sh extends Kr{constructor(){super(),this.type="ordinal",this.uniqueValues=new Set}extend(e){return e==null||Number.isNaN(e)?this:(this.uniqueValues.has(e)||(this.uniqueValues.add(e),this.push(e)),this)}}class ah extends sh{constructor(){super(),this.type="nominal"}}class iv extends Kr{constructor(e){super();let n=0;for(let r=1;r<e.length;r++)n+=Math.sign(e[r]-e[r-1]);if(Math.abs(n)!=e.length-1)throw new Error("Piecewise domain must be strictly increasing or decreasing: "+JSON.stringify(e));e.forEach(r=>this.push(r))}extend(e){if(this.includes(e))return this;throw new Error("Piecewise domains are immutable and cannot be unioned!")}}const uh={quantitative:Xa,index:Xa,locus:Xa,nominal:ah,ordinal:sh};function ch(t,e){if(t=="quantitative"&&ov(e)){const n=new iv(e);return n.type=t,n}else if(uh[t]){const n=new uh[t];return n.type=t,e&&n.extendAll(e),n}throw new Error("Unknown type: "+t)}function ov(t){return t&&t.length>0&&t.length!=2&&t.every(e=>typeof e=="number")}function sv(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}const lh="quantitative",fh="ordinal",hh="nominal",dh="locus",av="index";class uv{constructor(e){this.channel=e,this.members=[],this.type=null,this._zoomExtent=void 0,this._domainListeners=new Set,this.name=void 0,this._scale=void 0}addEventListener(e,n){if(e!="domain")throw new Error("Unsupported event type: "+e);this._domainListeners.add(n)}removeEventListener(e,n){if(e!="domain")throw new Error("Unsupported event type: "+e);this._domainListeners.delete(n)}_notifyDomainListeners(){for(const e of this._domainListeners.values())e({type:"domain",scaleResolution:this})}pushUnitView(e,n){var s;const r=oa(e,n),i=r.type,o=(s=r==null?void 0:r.scale)==null?void 0:s.name;if(o){if(this.name!==void 0&&o!=this.name)throw new Error(`Shared scales have conflicting names: "${o}" vs. "${this.name}"!`);this.name=o}if(!this.type)this.type=i;else if(i!==this.type&&!Nr(n))throw new Error(`Can not use shared scale for different data types: ${this.type} vs. ${i}. Use "resolve: independent" for channel ${this.channel}`);this.members.push({view:e,channel:n})}isExplicitDomain(){return!!this.getConfiguredDomain()}_getMergedScaleProps(){return kn(this,"mergedScaleProps",()=>{const e=this.members.map(n=>oa(n.view,n.channel).scale).filter(n=>n!==void 0);return vo(e,"scale",["domain"])})}getScaleProps(){return kn(this,"scaleProps",()=>{var i,o;const e=this._getMergedScaleProps();if(e===null||e.type=="null")return{type:"null"};const n=F(F({},this._getDefaultScaleProperties(this.type)),e);n.type||(n.type=cv(this.channel,this.type));const r=this.getInitialDomain();return r&&r.length>0?n.domain=r:Zt(n.type)&&(n.domain=new ah),!n.domain&&n.domainMid!==void 0&&(n.domain=[(i=n.domainMin)!=null?i:0,(o=n.domainMax)!=null?o:1]),this.channel=="y"&&Zt(n.type)&&n.reverse==null&&(n.reverse=!0),n.range&&n.scheme&&delete n.scheme,!("zoom"in n)&&["index","locus"].includes(n.type)&&(n.zoom=!0),lv(n,this.channel),n})}getInitialDomain(){var e;return(e=this.getConfiguredDomain())!=null?e:this.type==dh?this.getGenome().getExtent():this.getDataDomain()}getConfiguredDomain(){return this._reduceDomains(e=>Nr(e.channel)?void 0:e.view.getConfiguredDomain(e.channel))}getDataDomain(){return this._reduceDomains(e=>Nr(e.channel)?void 0:e.view.extractDataDomain(e.channel))}reconfigure(){if(this._scale&&this._scale.type!="null"){N0(this,"scaleProps");const e=this.getScaleProps();th(e,this._scale),Re(this._scale.type)&&(this._zoomExtent=this._getZoomExtent())}}getScale(){if(this._scale)return this._scale;const e=this.getScaleProps(),n=jw(e);return this._scale=n,Zg(n)&&n.genome(this.getGenome()),Re(n.type)&&(this._zoomExtent=this._getZoomExtent()),n}getDomain(){return this.getScale().domain()}getComplexDomain(){var e,n;return(n=(e=this.getGenome())==null?void 0:e.toChromosomalInterval(this.getDomain()))!=null?n:this.getDomain()}isZoomed(){return this.isZoomable()&&Kl(this.getInitialDomain(),this.getDomain())}isZoomable(){if(!ff(this.channel))return!1;const e=this.getScale().type;return["linear","locus","index","log","pow","sqrt"].includes(e)?!!this.getScaleProps().zoom:!1}zoom(e,n,r){if(!this.isZoomable())return!1;const i=this.getScale(),o=i.domain();let s=[...o],a=i.invert(n);switch(this.getScaleProps().reverse&&(r=-r),"align"in i&&(a+=i.align()),i.type){case"linear":case"index":case"locus":s=ed(s,r||0),s=mu(s,a,e);break;case"log":s=td(s,r||0),s=Au(s,a,e);break;case"pow":case"sqrt":{const u=i;s=nd(s,r||0,u.exponent()),s=Io(s,a,e,u.exponent());break}default:throw new Error("Zooming is not implemented for: "+i.type)}return this._zoomExtent&&(s=id(s,this._zoomExtent[0],this._zoomExtent[1])),[0,1].some(u=>s[u]!=o[u])?(i.domain(s),this._notifyDomainListeners(),!0):!1}async zoomTo(e,n=!1){var a;if(ai(n)&&(n=n?700:0),!this.isZoomable())throw new Error("Not a zoomable scale!");const r=this.fromComplexInterval(e),i=(a=this.members[0])==null?void 0:a.view.context.animator,o=this.getScale(),s=o.domain();if(n>0&&s.length==2){const u=s[1]-s[0],c=s[0]+u/2,f=r[1]-r[0],l=r[0]+f/2,h=fl([c,0,u],[l,0,f]).rho(.7);await i.transition({duration:n/1e3*h.duration,easingFunction:sv,onUpdate:p=>{const[d,,g]=h(p);o.domain([d-g/2,d+g/2]),this._notifyDomainListeners()}}),o.domain(r),this._notifyDomainListeners()}else o.domain(r),i==null||i.requestRender(),this._notifyDomainListeners()}resetZoom(){if(!this.isZoomable())throw new Error("Not a zoomable scale!");const e=this.getDomain(),n=this.getInitialDomain();return[0,1].some(r=>n[r]!=e[r])?(this._scale.domain(n),this._notifyDomainListeners(),!0):!1}getZoomLevel(){return this.isZoomable()?ui(this._zoomExtent)/ui(this.getScale().domain()):1}_getZoomExtent(){const e=this.getScaleProps(),n=e.zoom;if(fv(n)&&Te(n.extent))return this.fromComplexInterval(n.extent);if(n)return e.type=="locus"?this.getGenome().getExtent():this._scale.domain()}_getDefaultScaleProperties(e){const n=this.channel,r={};return this.isExplicitDomain()&&(r.zero=!1),kr(n)?r.nice=!this.isExplicitDomain():_t(n)?r.scheme=e==hh?"tableau10":e==fh?"blues":"viridis":Zi(n)?r.range=df(n):n=="size"?r.range=[0,400]:n=="angle"&&(r.range=[0,360]),r}getGenome(){var n;if(this.type!=="locus")return;const e=(n=this.members[0].view.context.genomeStore)==null?void 0:n.getGenome();if(!e)throw new Error("No genome has been defined!");return e}invertToComplex(e){const n=this.getScale();if("invert"in n){const r=n.invert(e);return this.toComplex(r)}else throw new Error("The scale does not support inverting!")}toComplex(e){const n=this.getGenome();return n?n.toChromosomal(e):e}fromComplex(e){return oh(e)?this.getGenome().toContinuous(e.chrom,e.pos):e}fromComplexInterval(e){return this.type==="locus"&&rv(e)?this.getGenome().toContinuousInterval(e):e}_getViewPaths(){return this.members.map(e=>e.view.getPathString()).join(", ")}_reduceDomains(e){const n=this.members.map(e).filter(r=>!!r);if(n.length)return n.reduce((r,i)=>r.extendAll(i))}}function cv(t,e){if(e==av||e==dh){if(ff(t))return e;throw new Error(`${t} does not support ${e} data type. Only positional channels do.`)}const n={x:["band","band","linear"],y:["band","band","linear"],size:[void 0,"point","linear"],opacity:[void 0,"point","linear"],fillOpacity:[void 0,"point","linear"],strokeOpacity:[void 0,"point","linear"],color:["ordinal","ordinal","linear"],fill:["ordinal","ordinal","linear"],stroke:["ordinal","ordinal","linear"],strokeWidth:[void 0,void 0,"linear"],shape:["ordinal","ordinal",void 0],dx:[void 0,void 0,"null"],dy:[void 0,void 0,"null"],angle:[void 0,void 0,"linear"]},i=["uniqueId","facetIndex","semanticScore","search","text","sample"].includes(t)?"null":n[t]?n[t][[hh,fh,lh].indexOf(e)]:e==lh?"linear":"ordinal";if(i===void 0)throw new Error(`Channel "${t}" is not compatible with "${e}" data type. Use of a proper scale may be needed.`);return i}function lv(t,e){kr(e)&&t.type!=="ordinal"&&(t.range=[0,1]),e=="opacity"&&Re(t.type)&&(t.clamp=!0)}function fv(t){return ze(t)}function Za(...t){for(const e of t)if(e!==void 0)return e}class hv{constructor(e){this.channel=e,this.members=[]}get scaleResolution(){var e;return(e=Cn(this.members))==null?void 0:e.view.getScaleResolution(this.channel)}pushUnitView(e,n){const r=e.getScaleResolution(this.channel);if(!r)throw new Error("Cannot find a scale resolution!");if(this.scaleResolution&&r!==this.scaleResolution)throw new Error("Shared axes must have a shared scale!");this.members.push({view:e,channel:n})}getAxisProps(){return kn(this,"axisProps",()=>{const e=this.members.map(n=>{const r=n.view.mark.encoding[n.channel];return"axis"in r&&r.axis});return e.length>0&&e.some(n=>n===null)?null:vo(e.filter(n=>n!==void 0),"axis",["title"])})}getTitle(){const e=o=>{var a;const s=oa(o.view,o.channel);if(!Qe(s))return{member:o,explicitTitle:Za((a=s.axis)==null?void 0:a.title,s.title),implicitTitle:Za(Pr(s)?s.field:void 0,sa(s)?s.expr:void 0)}},n=this.members.map(e),r=n.filter(o=>{var s;if(Nr(o.member.channel)&&!o.explicitTitle){const a=En(o.member.channel);return((s=n.find(u=>u.member.view==o.member.view&&u.member.channel==a))==null?void 0:s.explicitTitle)===void 0}return!0}),i=new Set(r.map(o=>Za(o.explicitTitle,o.implicitTitle)).filter(q));return i.size?[...i].join(", "):null}}class ph extends K0{constructor(e,n,r,i){super(e,n,r,i),this.spec=e}}class on extends Nn{constructor(e,n,r,i){super(e,n,r,i),this.spec=e,this.children=(e.layer||[]).map((o,s)=>{if(eu(o)||$a(o))return n.createView(o,this,"layer"+s);throw new Error("LayerView accepts only unit or layer specs as children!")})}*[Symbol.iterator](){for(const e of this.children)yield e}render(e,n,r={}){if(!!this.isVisible()){e.pushView(this,n);for(const i of this.children)i.render(e,n,r);e.popView(this)}}propagateInteractionEvent(e){this.handleInteractionEvent(void 0,e,!0),this.children.length&&this.children.at(-1).propagateInteractionEvent(e),!e.stopped&&this.handleInteractionEvent(void 0,e,!1)}}class gh{constructor(e,n){this.n=e,this.maxCols=n!=null?n:1/0}get nRows(){return this.maxCols==1/0?1:Math.ceil(this.n/this.maxCols)}get nCols(){return Math.min(this.n,this.maxCols)}get rowIndices(){const e=[],n=this.nCols,r=this.nRows;for(let i=0;i<r;i++){const o=[];e.push(o);for(let s=0;s<n;s++){const a=i*n+s;a<this.n&&o.push(a)}}return e}get colIndices(){const e=[],n=this.nCols,r=this.nRows;for(let i=0;i<n;i++){const o=[];e.push(o);for(let s=0;s<r;s++){const a=s*n+i;a<this.n&&o.push(a)}}return e}getCellIndex(e,n){let r=0;if(this.maxCols==1/0)r=n==0?e:void 0;else{if(e>=this.maxCols)return;r=n*this.nCols+e}return r<this.n?r:void 0}getCellCoords(e){if(!(e<0||e>=this.n))return[e%this.nCols,Math.floor(e/this.nCols)]}}function ft(t){return()=>t}const ht=class{static create(e,n,r,i){return new ht(ft(e),ft(n),ft(r),ft(i))}_offset(e,n){const r=this["_"+e];if(n===0)return r;switch(typeof n){case"number":return()=>r()+n;case"function":return()=>r()+n();default:throw new Error("Not a number of function")}}_passThrough(e){return this._offset(e,0)}constructor(e,n,r,i){this._x=e,this._y=n,this._width=r,this._height=i}get x(){return this._x()}get y(){return this._y()}get width(){return this._width()}get height(){return this._height()}get x2(){return this._x()+this._width()}get y2(){return this._y()+this._height()}equals(e){return e?this===e||this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height:!1}modify(e){if(!Object.keys(e).length)return this;const n=r=>{const i=e[r];return typeof i=="number"?ft(i):typeof i=="function"?i:this._passThrough(r)};return new ht(n("x"),n("y"),n("width"),n("height"))}translate(e,n){return e===0&&n===0?this:new ht(this._offset("x",e),this._offset("y",n),this._passThrough("width"),this._passThrough("height"))}translateBy(e){return this.translate(e.x,e.y)}expand(e,n=1){return e.left==0&&e.top==0&&e.right==0&&e.bottom==0?this:new ht(e.left?this._offset("x",-e.left*n):this._passThrough("x"),e.top?this._offset("y",-e.top*n):this._passThrough("y"),e.width?this._offset("width",e.width*n):this._passThrough("width"),e.height?this._offset("height",e.height*n):this._passThrough("height"))}shrink(e){return this.expand(e,-1)}intersect(e){return this===e?this:new ht(()=>Math.max(this.x,e.x),()=>Math.max(this.y,e.y),()=>Math.min(this.x2,e.x2)-Math.max(this.x,e.x),()=>Math.min(this.y2,e.y2)-Math.max(this.y,e.y))}isDefined(){return this.width>=0&&this.height>=0}flatten(){return new ht(ft(this.x),ft(this.y),ft(this.width),ft(this.height))}containsPoint(e,n){return e>=this.x&&e<this.x2&&n>=this.y&&n<this.y2}normalizePoint(e,n){return{x:(e-this.x)/this.width,y:(n-this.y)/this.height}}toString(){return`Rectangle: x: ${this.x}, y: ${this.y}, width: ${this.width}, height: ${this.height}`}};let On=ht;Vh(On,"ZERO",ht.create(0,0,0,0));function dv(t,e,n){return n=(n-t)/(e-t),n=Math.max(0,Math.min(1,n)),n*n*(3-2*n)}class Gn extends _{get identifier(){}handle(e){throw new Error("Source does not handle incoming data!")}async load(){}}function mh(t){var n,r;const e=F({},t.format);if((n=e.type)!=null||(e.type=Av(t)&&pv(t.url)),(r=e.parse)!=null||(e.parse="auto"),!e.type)throw new Error("Format for the data source was not defined and it could not be inferred: "+JSON.stringify(t));return e}function pv(t){var e;if(Array.isArray(t)&&(t=t[0]),t)return(e=t.match(/\.(csv|tsv|json)/))==null?void 0:e[1]}const Co=t=>typeof t!="object"?gv:mv,gv=t=>({data:t}),mv=t=>t;function Av(t){return"url"in t}function xv(t){return"dynamicCallbackSource"in t}class Ah extends Gn{constructor(e){super(),this.callback=e}loadSynchronously(){if(!this.callback)return;const e=this.callback();if(!e||typeof e[Symbol.iterator]!="function")throw new Error("Dynamic data callback didn't return iterable data!");this.reset(),this.beginBatch({type:"file"});let n;for(const r of e)n||(n=Co(r)),this._propagate(n(r));this.complete()}async load(){this.loadSynchronously()}}const xh="chromosome_ticks_and_labels",yh={x:"width",y:"height"};function Ka(t){return t=="x"?"y":"x"}const qa={x:["bottom","top"],y:["left","right"]},bh=Object.fromEntries(Object.entries(qa).map(([t,e])=>e.map(n=>[n,t])).flat(1));function sn(t){return bh[t]}class yv extends on{constructor(e,n,r,i){const o=n=="locus",s=F(F(F({},o?vv:wh),wv(n,e)),e);if(super(o?Cv(s):vh(s),r,i,`axis_${e.orient}`),this.axisProps=s,this.axisUpdateRequested=!0,this._addBroadcastHandler("layout",()=>{this.axisUpdateRequested=!0}),this.previousScaleDomain=[],this.axisLength=void 0,this.ticks=[],this.tickSource=new Ah(()=>this.ticks),o){const a=sn(this.axisProps.orient),u=this.getScaleResolution(a).getGenome();this.findChildByName(xh).getDynamicDataSource=()=>new Ah(()=>u.chromosomes)}this.blockEncodingInheritance=!0}getOrient(){return this.axisProps.orient}getSize(){const e={px:this.getPerpendicularSize()},n={grow:1};return bh[this.axisProps.orient]=="x"?new rn(n,e):new rn(e,n)}getPerpendicularSize(){return Ja(this.axisProps)}getDynamicDataSource(){return this.tickSource}_updateAxisData(){const e=sn(this.axisProps.orient),n=this.getScaleResolution(e).getScale(),r=n.domain();if(Kl(r,this.previousScaleDomain)&&!this.axisUpdateRequested)return;this.previousScaleDomain=r;const i=this.ticks,o=bv(this.axisProps,n,this.axisLength,i);o!==i&&(this.ticks=o,this.tickSource.loadSynchronously()),this.axisUpdateRequested=!1}onBeforeRender(){super.onBeforeRender(),this._updateAxisData()}render(e,n,r={}){!this.isVisible()||(this.axisLength=n[yh[sn(this.getOrient())]],super.render(e,n,r))}isPickingSupported(){return!1}}function Ja(t){const e=sn(t.orient);let n=t.ticks&&t.tickSize||0;return t.labels&&(n+=t.labelPadding,e=="x"?n+=t.labelFontSize:n+=30),t.title&&(n+=t.titlePadding+t.titleFontSize),n=Math.min(t.maxExtent||1/0,Math.max(t.minExtent||0,n)),n}function bv(t,e,n,r=[]){const i=a=>25+60*dv(100,700,a);let o=Ae(t.tickCount)?t.tickCount:Math.round(n/i(n));o=J0(e,o,t.tickMinStep);const s=t.values?_0(e,t.values,o):Tw(e,o);if(hA(s,r,a=>a,a=>a.value))return r;{const a=Lw(e,o,t.format);return s.map(u=>({value:u,label:a(u)}))}}const wh={values:null,minExtent:20,maxExtent:1/0,offset:0,domain:!0,domainWidth:1,domainColor:"gray",domainDash:null,domainDashOffset:0,domainCap:"square",ticks:!0,tickSize:5,tickWidth:1,tickColor:"gray",tickDash:null,tickDashOffset:0,tickCap:"square",tickCount:null,tickMinStep:null,labels:!0,labelAlign:"center",labelBaseline:"middle",labelPadding:4,labelFontSize:10,labelLimit:180,labelColor:"black",format:null,titleColor:"black",titleFont:"sans-serif",titleFontSize:10,titlePadding:3};function wv(t,e){var a;const n=e.orient,r=t=="nominal"||t=="ordinal";let i="center",o="middle",s=(a=e.labelAngle)!=null?a:(n=="top"||n=="bottom")&&r?-90:0;switch(n){case"left":i="right";break;case"right":i="left";break;case"top":case"bottom":Math.abs(s)>30?(i=s>0==(n=="bottom")?"left":"right",o="middle"):o=n=="top"?"alphabetic":"top";break}return{labelAlign:i,labelAngle:s,labelBaseline:o}}function vh(t){const e=Se(F({},t),{extent:Ja(t)}),n=sn(e.orient),r=Ka(n),i=e.orient=="bottom"||e.orient=="right"?1:-1,o=e.orient=="bottom"||e.orient=="left"?1:0,s=()=>({name:"domain",data:{values:[0]},mark:{type:"rule",clip:!1,strokeDash:e.domainDash,strokeCap:e.domainCap,color:e.domainColor,[r]:o,size:e.domainWidth}}),a=()=>({name:"labels",mark:{type:"text",clip:!1,align:e.labelAlign,angle:e.labelAngle,baseline:e.labelBaseline,[r+"Offset"]:(e.tickSize+e.labelPadding)*i,[r]:o,size:e.labelFontSize,color:e.labelColor,minBufferSize:1500},encoding:{[n]:{field:"value",type:"quantitative"},text:{field:"label"}}}),u=()=>({name:"ticks",mark:{type:"rule",clip:!1,strokeDash:e.tickDash,strokeCap:e.tickCap,color:e.tickColor,size:e.tickWidth,minBufferSize:300},encoding:{[r]:{value:o},[r+"2"]:{value:o-e.tickSize/e.extent*(o?1:-1)}}}),c=()=>({name:"title",data:{values:[0]},mark:{type:"text",clip:!1,align:"center",baseline:e.orient=="bottom"?"bottom":"top",angle:[0,90,0,-90][["top","right","bottom","left"].indexOf(e.orient)],text:e.title,color:e.titleColor,[n]:.5,[r]:1-o}}),f=()=>{const h={name:"ticks_and_labels",encoding:{[n]:{field:"value",type:"quantitative"}},layer:[]};return e.ticks&&h.layer.push(u()),e.labels&&h.layer.push(a()),h},l={[yh[Ka(sn(e.orient))]]:e.extent,data:{dynamicCallbackSource:!0},layer:[]};return e.domain&&l.layer.push(s()),(e.ticks||e.labels)&&l.layer.push(f()),e.title&&l.layer.push(c()),l}const vv=Se(F({},wh),{chromTicks:!0,chromTickSize:18,chromTickWidth:1,chromTickColor:"#989898",chromTickDash:[4,2],chromTickDashOffset:1,chromLabels:!0,chromLabelFontSize:13,chromLabelFontWeight:"normal",chromLabelFontStyle:"normal",chromLabelColor:"black",chromLabelAlign:"left",chromLabelPadding:7});function Cv(t){const e=Se(F({},t),{extent:Ja(t)}),n=sn(e.orient),r=Ka(n),i=e.orient=="bottom"||e.orient=="left"?1:0,o=()=>({name:"chromosome_ticks",mark:{type:"rule",strokeDash:t.chromTickDash,strokeDashOffset:t.chromTickDashOffset,[r]:i,[r+"2"]:i-e.chromTickSize/e.extent*(i?1:-1),color:t.chromTickColor,size:e.chromTickWidth}}),s=()=>{let c;switch(e.orient){case"top":c={y:0,angle:0,paddingX:4,dy:-e.chromLabelPadding,viewportEdgeFadeWidthLeft:20,viewportEdgeFadeWidthRight:20,viewportEdgeFadeDistanceRight:-10,viewportEdgeFadeDistanceLeft:-20};break;case"bottom":c={y:1,angle:0,paddingX:4,dy:e.chromLabelPadding+e.chromLabelFontSize*.73,viewportEdgeFadeWidthLeft:20,viewportEdgeFadeWidthRight:20,viewportEdgeFadeDistanceRight:-10,viewportEdgeFadeDistanceLeft:-20};break;case"left":c={x:1,angle:-90,paddingY:4,dy:-e.chromLabelPadding,viewportEdgeFadeWidthBottom:20,viewportEdgeFadeWidthTop:20,viewportEdgeFadeDistanceBottom:-20,viewportEdgeFadeDistanceTop:-10};break;case"right":c={x:0,angle:90,align:"right",paddingY:4,dy:-e.chromLabelPadding};break;default:c={}}return{name:"chromosome_labels",mark:F({type:"text",size:e.chromLabelFontSize,font:e.chromLabelFont,fontWeight:e.chromLabelFontWeight,fontStyle:e.chromLabelFontStyle,color:e.chromLabelColor,align:t.chromLabelAlign,baseline:"alphabetic",clip:!1},c),encoding:{[n+"2"]:{field:"continuousEnd",type:"locus"},text:{field:"name"}}}};let a;switch(e.orient){case"bottom":case"top":a={};break;case"left":a={labelAngle:-90,labelAlign:"center",labelPadding:6};break;case"right":a={labelAngle:90,labelAlign:"center",labelPadding:6};break;default:a={}}const u=vh(F(F({},t),a));if(t.chromTicks||t.chromLabels){const c={name:xh,data:{dynamicCallbackSource:!0},encoding:{[n]:{field:"continuousStart",type:"locus",band:0}},layer:[]};if(t.chromTicks&&c.layer.push(o()),t.chromLabels){c.layer.push(s());let f;u.layer.filter(l=>l.name=="ticks_and_labels").forEach(l=>l.layer.filter(h=>h.name=="labels").forEach(h=>{f=h.mark})),f&&(e.orient=="top"||e.orient=="bottom"?(f.viewportEdgeFadeWidthLeft=30,f.viewportEdgeFadeDistanceLeft=40):(f.viewportEdgeFadeWidthBottom=30,f.viewportEdgeFadeDistanceBottom=40))}u.layer.push(c)}return u}const Ch={anchor:"middle",frame:"group",offset:10,orient:"top",align:void 0,angle:0,baseline:"alphabetic",dx:0,dy:0,color:void 0,font:void 0,fontSize:12,fontStyle:"normal",fontWeight:"normal"},Ev={orient:"left",anchor:"middle",align:"right",baseline:"middle",angle:0,fontSize:12},Sv={orient:"top",anchor:"start",align:"left",baseline:"top",offset:-10,dx:10,fontSize:12},Dv={start:0,middle:.5,end:1},Bv={start:"left",middle:"center",end:"right"};function Fv(t){var c,f,l;if(!t)return;const e=q(t)?{text:t}:t;if(!e.text||e.orient=="none")return;const n=(c={"track-title":Ev,overlay:Sv}[e.style])!=null?c:{},r=F(F(F({},Ch),n),e);let i={},o={x:0,y:0};const s=Dv[(f=r.anchor)!=null?f:"middle"];switch(r.orient){case"top":o={x:s,y:1},i={baseline:"alphabetic",angle:0};break;case"right":o={x:1,y:1-s},i={baseline:"alphabetic",angle:90};break;case"bottom":o={x:s,y:0},i={baseline:"top",angle:0};break;case"left":o={x:0,y:s},i={baseline:"alphabetic",angle:-90};break}const a=F(F(F(F({},Ch),i),n),e),u={xOffset:0,yOffset:0};switch(r.orient){case"top":u.yOffset=-a.offset;break;case"right":u.xOffset=a.offset;break;case"bottom":u.yOffset=a.offset;break;case"left":u.xOffset=-a.offset;break}return{configurableVisibility:!1,data:{values:[{}]},mark:Se(F(F({type:"text",tooltip:null,clip:!1},o),u),{text:a.text,align:(l=a.align)!=null?l:Bv[a.anchor],angle:a.angle,baseline:a.baseline,dx:a.dx,dy:a.dy,color:a.color,font:a.font,size:a.fontSize,fontStyle:a.fontStyle,fontWeight:a.fontWeight})}}function Mv(t,e,n,r){if(t.type=="wheel"){t.uiEvent.preventDefault();const i=t.uiEvent,o=i.deltaMode?120:1;let{x:s,y:a}=t.point;if(r){const u=r.mark.encoders;u.x&&!u.x2&&(s=+u.x(r.datum)*e.width+e.x),u.y&&!u.y2&&(a=(1-+u.y(r.datum))*e.height+e.y)}Math.abs(i.deltaX)<Math.abs(i.deltaY)?n({x:s,y:a,xDelta:0,yDelta:0,zDelta:i.deltaY*o/300}):n({x:s,y:a,xDelta:-i.deltaX*o,yDelta:0,zDelta:0})}else if(t.type=="mousedown"&&t.uiEvent.button===0){const i=t.uiEvent;i.preventDefault();let o=i;const s=u=>{n({x:o.clientX,y:o.clientY,xDelta:u.clientX-o.clientX,yDelta:u.clientY-o.clientY,zDelta:0}),o=u},a=u=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",a)};document.addEventListener("mouseup",a,!1),document.addEventListener("mousemove",s,!1)}}class Eh extends Nn{constructor(n,r,i,o,s){var a;super(n,r,i,o);ge(this,Jr);ge(this,tt);ge(this,So);ge(this,Do);ge(this,an);ge(this,_r);ge(this,$r);ge(this,ei);ge(this,Bo);ge(this,Un,1/0);ge(this,Hn,10);ge(this,Ne,[]);ge(this,Qn,0);this.spec=n,ti(this,Hn,(a=n.spacing)!=null?a:10),ti(this,Un,s),ti(this,Ne,[]),this.wrappingFacet=!1,this._createChildren()}_createChildren(){}appendChild(n){var r;(r=n.parent)!=null||(n.parent=this),Z(this,Ne).push(ce(this,Jr,lu).call(this,n)),Yh(this,Qn)._++}setChildren(n){for(const r of n)this.appendChild(r)}replaceChild(n,r){const i=Z(this,Ne).findIndex(o=>o.view==n);if(i>=0)Z(this,Ne)[i]=ce(this,Jr,lu).call(this,r);else throw new Error("Not my child view!")}get children(){return Z(this,Ne).map(n=>n.view)}get childCount(){return Z(this,Ne).length}onScalesResolved(){super.onScalesResolved(),ce(this,Do,Xh).call(this)}*[Symbol.iterator](){for(const n of Z(this,Ne)){n.background&&(yield n.background);for(const r of Object.values(n.axes))r&&(yield r);yield n.view,n.title&&(yield n.title)}}getOverhang(){const n=ce(this,an,ni).call(this,"column"),r=ce(this,an,ni).call(this,"row");return!n.length||!r.length?Ye.zero():new Ye(r.at(0).axisBefore,n.at(-1).axisAfter,r.at(-1).axisAfter,n.at(0).axisBefore)}getSize(){return this._cache("size",()=>new rn(ce(this,$r,hu).call(this,"column"),ce(this,$r,hu).call(this,"row")).subtractPadding(this.getOverhang()).addPadding(this.getPadding()))}render(n,r,i={}){var c;if(!this.isVisible())return;r=r.shrink(this.getPadding()),n.pushView(this,r);const o={devicePixelRatio:this.context.glHelper.dpr},s=W0(ce(this,_r,fu).call(this,"column"),r.width,o),a=W0(ce(this,_r,fu).call(this,"row"),r.height,o),u=new gh(Z(this,tt,Tt).length,(c=Z(this,Un))!=null?c:1/0);for(const[f,l]of Z(this,tt,Tt).entries()){const{view:h,axes:p,background:d,title:g}=l,[A,m]=u.getCellCoords(f),b=s[ce(this,ei,du).call(this,"column",A)],y=a[ce(this,ei,du).call(this,"row",m)],v=h.getSize(),E=h.getPadding().subtract(h.getOverhang()),C=b.location+E.left,B=y.location+E.top,L=(v.width.grow?b.size:v.width.px)-E.width,R=(v.height.grow?y.size:v.height.px)-E.height,Q=new On(()=>r.x+C,()=>r.y+B,()=>L,()=>R);l.coords=Q,d==null||d.render(n,Q,i);const T=Pv(h);T&&h.render(n,Q,i);for(const[Ce,se]of Object.entries(p)){const Be=se.axisProps;let nt;const Fe=se.getPerpendicularSize();Ce=="bottom"?nt=Q.translate(0,Q.height+Be.offset).modify({height:Fe}):Ce=="top"?nt=Q.translate(0,-Fe-Be.offset).modify({height:Fe}):Ce=="left"?nt=Q.translate(-Fe-Be.offset,0).modify({width:Fe}):Ce=="right"&&(nt=Q.translate(Q.width+Be.offset,0).modify({width:Fe})),se.render(n,nt)}T||h.render(n,Q,i),g==null||g.render(n,Q,Se(F({},i),{clipRect:void 0}))}n.popView(this)}propagateInteractionEvent(n){if(this.handleInteractionEvent(void 0,n,!0),n.stopped)return;const r=Z(this,tt,Tt).find(o=>o.coords.containsPoint(n.point.x,n.point.y)),i=r==null?void 0:r.view;i&&(i.propagateInteractionEvent(n),(i instanceof ve||i instanceof on)&&Mv(n,r.coords,o=>ce(this,Bo,Zh).call(this,r.coords,r.view,o),this.context.getCurrentHover())),!n.stopped&&this.handleInteractionEvent(void 0,n,!1)}getDefaultResolution(n,r){return"independent"}}Un=new WeakMap,Hn=new WeakMap,Ne=new WeakMap,Qn=new WeakMap,Jr=new WeakSet,lu=function(n){var i;const r={view:n,background:void 0,axes:{},coords:On.ZERO};if(n instanceof ve||n instanceof on){const o=(i=n.spec)==null?void 0:i.view;if((o==null?void 0:o.fill)||(o==null?void 0:o.stroke)){const a=new ve(Iv(o),this.context,n,"background"+Z(this,Qn));a.blockEncodingInheritance=!0,r.background=a}const s=Fv(n.spec.title);if(s){const a=new ve(s,this.context,n,"title"+Z(this,Qn));a.blockEncodingInheritance=!0,r.title=a}}return r},tt=new WeakSet,Tt=function(){return Z(this,Ne).filter(n=>n.view.isVisible())},So=new WeakSet,Wh=function(){var n;return new gh(Z(this,tt,Tt).length,(n=Z(this,Un))!=null?n:1/0)},Do=new WeakSet,Xh=function(){if(Object.keys(this.resolutions.axis).length)throw new Error("ConcatView does not (currently) support shared axes!");for(const n of Z(this,Ne)){const{view:r,axes:i}=n,o=(s,a,u)=>{var f;const c=s.getAxisProps();if(c!==null){if(!c.orient){for(const l of qa[a])if(!i[l]){c.orient=l;break}if(!c.orient)throw new Error("No slots available for an axis! Perhaps a LayerView has more than two children?")}if((f=c.title)!=null||(c.title=s.getTitle()),!qa[a].includes(c.orient))throw new Error(`Invalid axis orientation "${c.orient}" on channel "${a}"!`);if(i[c.orient])throw new Error(`An axis with the orient "${c.orient}" already exists!`);i[c.orient]=new yv(c,s.scaleResolution.type,this.context,u)}};if(r instanceof ve||r instanceof on)for(const s of["x","y"]){const a=r.resolutions.axis[s];!a||o(a,s,r)}if(r instanceof on){for(const s of r.children)for(const[a,u]of Object.entries(s.resolutions.axis)){const c=u.getAxisProps();c&&c.orient&&o(u,a,s)}for(const s of r.children)for(const[a,u]of Object.entries(s.resolutions.axis)){const c=u.getAxisProps();c&&!c.orient&&o(u,a,s)}}}},an=new WeakSet,ni=function(n){const r=n=="column"?["left","right"]:["top","bottom"],i=n=="column"?"width":"height",o=(s,a)=>s.map(u=>{const c=Z(this,tt,Tt)[u].axes[r[a]];if(c)return Math.max(c.getPerpendicularSize()+c.axisProps.offset,0);const f=Z(this,tt,Tt)[u].view.getOverhang();return n=="column"?a?f.right:f.left:a?f.bottom:f.top}).reduce((u,c)=>Math.max(u,c),0);return Z(this,So,Wh)[n=="column"?"colIndices":"rowIndices"].map(s=>({axisBefore:o(s,0),axisAfter:o(s,1),view:Cw(s.map(a=>Z(this,tt,Tt)[a].view.getSize()[i]))}))},_r=new WeakSet,fu=function(n){const r=ce(this,an,ni).call(this,n),i=[];i.push(Xr);for(const[o,s]of r.entries())o>0&&i.push({px:Z(this,Hn),grow:0}),(o==0||this.wrappingFacet)&&i.push(Xr),i.push({px:s.axisBefore,grow:0}),i.push(s.view),i.push({px:s.axisAfter,grow:0}),(o==r.length-1||this.wrappingFacet)&&i.push(Xr);return i},$r=new WeakSet,hu=function(n){var s,a;let r=0,i=0;const o=ce(this,an,ni).call(this,n);for(const[u,c]of o.entries())u>0&&(i+=Z(this,Hn)),(u==0||this.wrappingFacet)&&(i+=0),i+=c.axisBefore,i+=(s=c.view.px)!=null?s:0,r+=(a=c.view.grow)!=null?a:0,i+=c.axisAfter,(u==o.length-1||this.wrappingFacet)&&(i+=0);return{px:i,grow:r}},ei=new WeakSet,du=function(n,r){return n=="row"&&this.wrappingFacet?1+6*r+2:2+4*r+1},Bo=new WeakSet,Zh=function(n,r,i){for(const[o,s]of Object.entries(Tv(r))){if(s.size<=0)continue;const a=n.normalizePoint(i.x,i.y),u=n.normalizePoint(i.x+i.xDelta,i.y+i.yDelta),c={x:u.x-a.x,y:u.y-a.y};for(const f of s)f.zoom(2**i.zDelta,o=="y"?1-a[o]:a[o],o=="x"?c.x:-c.y)}this.context.animator.requestRender()};function Iv(t){return{configurableVisibility:!1,data:{values:[{}]},mark:Se(F({fill:null,strokeWidth:1,fillOpacity:t.fill?1:0},t),{type:"rect",clip:!1,tooltip:null})}}function Tv(t){const e={x:new Set,y:new Set};return t.visit(n=>{for(const[r,i]of Object.entries(e)){const o=n.getScaleResolution(r);o&&o.isZoomable()&&i.add(o)}}),e}function Pv(t){let e=!0;return t.visit(n=>{n instanceof ve&&e&&(e=n.mark.properties.clip)}),e}class _a extends Eh{constructor(e,n,r,i){super(e,n,r,i,nu(e)?e.columns:tu(e)?1:1/0),this.spec=e}_createChildren(){const e=this.spec,n=nu(e)?e.concat:tu(e)?e.vconcat:e.hconcat;this.setChildren(n.map((r,i)=>this.context.createView(r,this,"grid"+i)))}}class Lv{constructor(){this.types=[];const e=n=>(r,i,o,s)=>{var a;return new n(r,i,o,(a=r.name)!=null?a:s)};this.addViewType(Rv,e(ph)),this.addViewType(eu,e(on)),this.addViewType($a,e(ve)),this.addViewType(tu,e(_a)),this.addViewType(kv,e(_a)),this.addViewType(nu,e(_a))}addViewType(e,n){this.types.push({specGuard:e,factory:n})}createView(e,n,r,i){const o=this.types.find(s=>s.specGuard(e));if(o)return o.factory(e,n,r,i!=null?i:"unnamed");throw new Error("Invalid spec, cannot figure out the view type from the properties: "+JSON.stringify([...Object.keys(e)]))}isViewSpec(e){const n=this.types.filter(r=>r.specGuard(e));if(n.length>1)throw new Error("Ambiguous spec. Cannot create a view!");return n.length==1}}function $a(t){return"mark"in t&&(q(t.mark)||ze(t.mark))}function eu(t){return"layer"in t&&ze(t.layer)}function Sh(t){return t&&($a(t)||eu(t))&&"aggregateSamples"in t}function Rv(t){return"import"in t}function tu(t){return"vconcat"in t&&Te(t.vconcat)}function kv(t){return"hconcat"in t&&Te(t.hconcat)}function nu(t){return"concat"in t&&Te(t.concat)}const Nv={point:cw,rect:nw,rule:hw,link:mw,text:vw};class ve extends Nn{constructor(e,n,r,i){super(e,n,r,i),this.spec=e;const o=Nv[this.getMarkType()];if(o)this.mark=new o(this);else throw new Error(`No such mark: ${this.getMarkType()}`);this.sampleAggregateViews=[],this._initializeAggregateViews(),this.coords=void 0}*[Symbol.iterator](){for(const e of this.sampleAggregateViews)yield e}replaceChild(e,n){const r=this.sampleAggregateViews.indexOf(e);if(r>=0)this.sampleAggregateViews[r]=n;else throw new Error("Not my child view!")}render(e,n,r={}){!this.isVisible()||(this.coords=n,e.pushView(this,n),e.renderMark(this.mark,r),e.popView(this))}getMarkType(){return typeof this.spec.mark=="object"?this.spec.mark.type:this.spec.mark}resolve(e){var r;const n=this.mark.encoding;for(const[i,o]of Object.entries(n)){if(!ke(o))continue;let s=En((r=o.resolutionChannel)!=null?r:i);if(e=="axis"&&!kr(s))continue;let a=this;for(;a.parent instanceof Nn&&["shared","excluded"].includes(a.parent.getConfiguredOrDefaultResolution(s,e))&&a.getConfiguredOrDefaultResolution(s,e)!="excluded";)a=a.parent;a.resolutions[e][s]||(a.resolutions[e][s]=e=="scale"?new uv(s):new hv(s)),kr(i)?a.resolutions[e][s].pushUnitView(this,i):e=="scale"&&a.resolutions[e][s].pushUnitView(this,i)}}getAccessor(e){return this._cache("accessor/"+e,()=>{const n=this.mark.encoding;if(n&&n[e])return this.context.accessorFactory.createAccessor(n[e])})}getFacetAccessor(e){const n=this.getAccessor("sample");return n||super.getFacetAccessor(this)}getCollector(){return this.context.dataFlow.findCollectorByKey(this)}_validateDomainQuery(e){if(Nr(e))throw new Error(`getDomain(${e}), must only be called for primary channels!`);const n=this.mark.encoding[e];if(!ke(n))throw new Error("The channel has no scale, cannot get domain!");return n}getConfiguredDomain(e){var i,o;const n=this._validateDomainQuery(e),r=n&&n.scale&&n.scale.domain;if(r){const s=this.getScaleResolution((i=n.resolutionChannel)!=null?i:e);return ch((o=n.type)!=null?o:"nominal",s.fromComplexInterval(r))}}extractDataDomain(e){var a;const r=(a=this._validateDomainQuery(e).type)!=null?a:"nominal",i=u=>{let c;const f=this.mark.encoding[u];if(f){const l=this.context.accessorFactory.createAccessor(f);if(l)if(c=ch(r),l.constant)c.extend(l({}));else{const h=this.getCollector();h!=null&&h.completed&&h.visitData(p=>c.extend(l(p)))}}return c};let o=i(e);const s=aa[e];if(s){const u=i(s);u&&o.extendAll(u)}return o}getZoomLevel(){const e=n=>{var r,i;return(i=(r=this.getScaleResolution(n))==null?void 0:r.getZoomLevel())!=null?i:1};return Rr.map(e).reduce((n,r)=>n*r,1)}_initializeAggregateViews(){var e,n;if(Sh(this.spec))for(const r of this.spec.aggregateSamples){const i=(e=r.transform)!=null?e:[];i.length&&Cn(i).type!="collect"&&i.push({type:"collect"}),i.push({type:"mergeFacets"}),r.transform=i,r.encoding=Se(F({},(n=r.encoding)!=null?n:{}),{sample:null});const o=this.context.createView(r,this,"summaryView");o.getFacetFields=s=>{},this.sampleAggregateViews.push(o)}}propagateInteractionEvent(e){e.target=this}getDefaultResolution(e,n){return e=="x"?"shared":"independent"}}function*ru(t,e=[]){for(const[n,r]of t.entries())if(r instanceof Map)for(const i of ru(r,[...e,n]))yield i;else yield[[...e,n],r]}class iu extends _{constructor(e){super(),this.params=e!=null?e:{type:"collect"},this.observers=[],this.facetBatches=void 0,this._init()}_init(){this._data=[],this.facetBatches=new Rt([],JSON.stringify),this.facetBatches.set(void 0,this._data)}reset(){super.reset(),this._init()}handle(e){this._data.push(e)}beginBatch(e){sw(e)&&(this._data=[],this.facetBatches.set(Je(e.facetId),this._data))}complete(){var i,o;const e=(i=this.params)==null?void 0:i.sort,n=e?xu(e.field,e.order):void 0,r=s=>{n&&s.sort(n)};if((o=this.params.groupby)!=null&&o.length){if(this.facetBatches.size>1)throw new Error("TODO: Support faceted data!");const s=this.params.groupby.map(u=>j(u)),a=hi(this._data,...s);this.facetBatches.clear();for(const[u,c]of ru(a))this.facetBatches.set(u,c)}for(const s of this.facetBatches.values())r(s);if(this.children.length)for(const[s,a]of this.facetBatches.entries()){if(s){const u={type:"facet",facetId:s};for(const c of this.children)c.beginBatch(u)}for(const u of a)this._propagate(u)}super.complete();for(const s of this.observers)s(this)}getData(){switch(this._checkStatus(),this.facetBatches.size){case 0:return[];case 1:return[...this.facetBatches.values()][0];default:{const e=this.facetBatches;return{[Symbol.iterator]:function*(){for(const r of e.values())for(let i=0;i<r.length;i++)yield r[i]}}}}}visitData(e){this._checkStatus();for(const n of this.facetBatches.values())for(let r=0;r<n.length;r++)e(n[r])}getItemCount(){let e=0;for(const n of this.facetBatches.values())e+=n.length;return e}_checkStatus(){if(!this.completed)throw new Error("Data propagation is not completed! No data are available.")}}class Eo{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(e,n){let r=this.length++;for(;r>0;){const i=r-1>>1,o=this.values[i];if(n>=o)break;this.ids[r]=this.ids[i],this.values[r]=o,r=i}this.ids[r]=e,this.values[r]=n}pop(){if(this.length===0)return;const e=this.ids[0];if(this.length--,this.length>0){const n=this.ids[0]=this.ids[this.length],r=this.values[0]=this.values[this.length],i=this.length>>1;let o=0;for(;o<i;){let s=(o<<1)+1;const a=s+1;let u=this.ids[s],c=this.values[s];const f=this.values[a];if(a<this.length&&f<c&&(s=a,u=this.ids[a],c=f),c>=r)break;this.ids[o]=u,this.values[o]=c,o=s}this.ids[o]=n,this.values[o]=r}return e}peek(){if(this.length!==0)return this.ids[0]}peekValue(){if(this.length!==0)return this.values[0]}shrink(){this.ids.length=this.values.length=this.length}}class zv extends _{get behavior(){return lt}constructor(e){super(),this.params=e,this.startAccessor=j(e.start),this.endAccessor=j(e.end),this.chromAccessor=e.chrom?j(e.chrom):n=>{},this.weightAccessor=e.weight?j(e.weight):n=>1,this.as={coverage:e.as||"coverage",start:e.asStart||e.start,end:e.asEnd||e.end,chrom:e.asChrom||e.chrom},this.createSegment=new Function("start","end","coverage","chrom","return {"+Object.entries(this.as).filter(([n,r])=>r).map(([n,r])=>`${JSON.stringify(r)}: ${n}`).join(", ")+"};"),this.ends=new Eo}reset(){super.reset(),this.initialize()}initialize(){const e=this.as.coverage,n=this.as.end,r=this.as.chrom,i=this.startAccessor,o=this.endAccessor,s=this.chromAccessor,a=this.weightAccessor;let u,c,f,l=0,h;const p=this.ends;p.clear();const d=(A,m,b)=>{if(A==m)return;let y=!1;u&&(u[e]===b?(u[n]=m,y=!0):u[e]!=0&&this._propagate(u)),y||(u=this.createSegment(A,m,b,f))},g=()=>{let A;for(;(A=p.peekValue())!==void 0;)d(h,A,l),h=A,l-=p.pop();h=void 0,u&&(this._propagate(u),u=void 0)};this.handle=A=>{const m=i(A);let b;for(;(b=p.peekValue())!==void 0&&b<m;)d(h,b,l),h=b,l-=p.pop();if(r){let v=s(A);v!==c&&(g(),f=v,c=f)}h!==void 0&&d(h,m,l),h=m;const y=a(A);l+=y,p.push(y,o(A))},this.complete=()=>{g(),super.complete()}}}function Ov(t,e,n=0,r=t.length){const i=new Eo,o=r-n;let s;for(s=0;s<e&&s<o;s++)i.push(s,t[n+s]);for(;s<o;s++){const c=t[n+s];c>=i.peekValue()&&(i.push(s,c),i.pop())}const a=[];let u;for(;(u=i.pop())!==void 0;)a.push(n+u);return a.reverse()}class Gv{constructor(e,n=-1/0,r=1/0){this.maxSize=e,this.lowerLimit=n,this.upperLimit=r;const i=this.maxSize*2+1;this.lowerLimits=new Float64Array(i),this.upperLimits=new Float64Array(i),this.lowerChildren=new Int32Array(i),this.upperChildren=new Int32Array(i),this.reset()}reset(){this.lowerLimits.fill(0),this.upperLimits.fill(0),this.lowerChildren.fill(0),this.upperChildren.fill(0),this.n=1,this.lowerLimits[0]=this.lowerLimit,this.upperLimits[0]=this.upperLimit}_findSlot(e,n,r=0){if(e>=this.lowerLimits[r]&&n<=this.upperLimits[r]){const i=this.lowerChildren[r];if(i){const o=this._findSlot(e,n,i);return o>=0?o:this._findSlot(e,n,this.upperChildren[r])}else return r}else return-1}reserve(e,n){if(n-e<=0)throw new Error("Cannot reserve an empty or negative-size slot!");if(this.n+1>this.lowerLimits.length)return!1;const r=this._findSlot(e,n);if(r<0)return!1;const i=this.n++,o=this.n++;return this.lowerLimits[i]=this.lowerLimits[r],this.upperLimits[i]=e,this.lowerLimits[o]=n,this.upperLimits[o]=this.upperLimits[r],this.lowerChildren[r]=i,this.upperChildren[r]=o,!0}}class Uv extends _{constructor(e,n){var i,o;if(super(),this.params=e,this._data=[],this.channel=(i=e.channel)!=null?i:"x",!["x","y"].includes(this.channel))throw new Error("Invalid channel: "+this.channel);this.posAccessor=j(this.params.pos),this.posBisector=fi(this.posAccessor),this.scoreAccessor=j(this.params.score),this.widthAccessor=j(this.params.width),this.laneAccessor=this.params.lane?j(this.params.lane):s=>0,this.padding=(o=this.params.padding)!=null?o:0,this.reservationMaps=new Map,this.resolution=n.getScaleResolution(this.channel);const r=()=>this._filterAndPropagate();this.schedule=()=>n.context.animator.requestTransition(r),this.resolution.addEventListener("domain",s=>this.schedule()),n._addBroadcastHandler("layoutComputed",()=>this.schedule())}complete(){const e=this.posAccessor;this._data.sort((n,r)=>e(n)-e(r)),this._scores=this._data.map(this.scoreAccessor);for(const n of new Set(this._data.map(this.laneAccessor)))this.reservationMaps.set(n,new Gv(200));this.schedule(),super.complete()}_filterAndPropagate(){var s;super.reset();const e=this.resolution.getScale(),n=(s=this.resolution.members[0].view.coords)==null?void 0:s[this.channel=="x"?"width":"height"];if(!n)return;for(const a of this.reservationMaps.values())a.reset();const r=e.domain(),i=70,o=Ov(this._scores,i,this.posBisector.left(this._data,r[0]),this.posBisector.right(this._data,r[1]));for(const a of o){const u=this._data[a],c=e(this.posAccessor(u))*n,f=this.widthAccessor(u)/2+this.padding;this.reservationMaps.get(this.laneAccessor(u)).reserve(c-f,c+f)&&this._propagate(u)}super.complete()}reset(){super.reset(),this._data=[],this.groups=new Map}handle(e){this._data.push(e)}}class Hv extends _{constructor(e){super(),this.params=e,this.predicate=void 0}initialize(){this.predicate=ia(this.params.expr,this.getGlobalObject())}handle(e){this.predicate(e)&&this._propagate(e)}}const Qv="0".charCodeAt(0);function*jv(t,e=","){const n=e.charCodeAt(0);let r=0;for(let i=0;i<t.length;i++){const o=t.charCodeAt(i);o==n?(yield r,r=0):r=r*10+o-Qv}yield r}class Vv extends _{get behavior(){return lt}constructor(e){var s,a;super();const n=j((s=e.exons)!=null?s:"exons"),r=j((a=e.start)!=null?a:"start"),[i,o]=e.as||["exonStart","exonEnd"];this.handle=u=>{let c=r(u),f=c,l=!0;const h=n(u);for(const p of jv(h)){if(l)f=c+p;else{c=f+p;const d=Object.assign({},u);d[i]=f,d[o]=c,this._propagate(d)}l=!l}}}}class Yv extends _{get behavior(){return lt}constructor(e){super();const n=Je(e.field).map(o=>j(o)),r=Je(e.separator),i=Je(e.as||e.field);if(n.length!==r.length||n.length!==i.length)throw new Error(`Lengths of "separator" (${r.length}), "fields" (${n.length}), and "as" (${i.length}) do not match!`);this.handle=o=>{if(n.some(u=>!u(o)))return;const s=n.map((u,c)=>u(o).split(r[c]));Wv(s,o);const a=s[0].length;for(let u=0;u<a;u++){const c=Object.assign({},o);for(let f=0;f<n.length;f++)c[i[f]]=s[f][u];this._propagate(c)}}}}function Wv(t,e){const n=t.map(r=>r.length);if(!n.every(r=>r==n[0]))throw new Error("Mismatching number of elements in the fields to be split: "+JSON.stringify(e))}class Xv extends _{get behavior(){return It}constructor(e){super(),this.params=e,this.as=e.as,this.fn=void 0}initialize(){this.fn=ia(this.params.expr,this.getGlobalObject())}handle(e){e[this.as]=this.fn(e),this._propagate(e)}}class Dh extends _{get behavior(){return It}constructor(e,n){var d;super();const r=(d=e.channel)!=null?d:"x";if(!["x","y"].includes(r))throw new Error("Invalid channel: "+r);const i=n.getScaleResolution(r).getGenome();if(!i)throw new Error("LinearizeGenomicCoordinate transform requires a locus scale!");const o=j(e.chrom),s=Je(e.pos).map(g=>j(g)),a=Je(e.as);if(s.length!=a.length)throw new Error('The number of "pos" and "as" elements must be equal!');const u=Je(e.offset);let c;if(u.length==0)c=new Array(s.length).fill(0);else if(u.length==1)c=new Array(s.length).fill(u[0]);else if(u.length==s.length)c=u;else throw new Error(`Invalid "offset" parameter: ${JSON.stringify(e.offset)}!`);const f=new Function("datum","chromOffset","posAccessors",a.map((g,A)=>`datum[${JSON.stringify(g)}] = chromOffset + +posAccessors[${A}](datum) - ${c[A]};`).join(`
|
|
144
144
|
`));let l,h=0;const p=g=>{if(g!==l){if(h=i.cumulativeChromPositions.get(g),h===void 0)throw new Error("Unknown chromosome/contig: "+g);l=g}return h};this.handle=g=>{f(g,p(o(g)),s),this._propagate(g)}}}var Bh={pages:["Lato-Regular.png"],chars:[{id:87,width:53,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:43.491,chnl:15,x:0,y:0,page:0},{id:124,width:17,height:50,xoffset:0,yoffset:-32.193000000000005,xadvance:10.521,chnl:15,x:0,y:42,page:0},{id:40,width:20,height:49,xoffset:0,yoffset:-32.571000000000005,xadvance:11.214,chnl:15,x:0,y:94,page:0},{id:41,width:19,height:49,xoffset:0,yoffset:-32.571000000000005,xadvance:11.214,chnl:15,x:0,y:145,page:0},{id:36,width:32,height:49,xoffset:0,yoffset:-34.419000000000004,xadvance:24.360000000000003,chnl:15,x:0,y:196,page:0},{id:125,width:21,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.642000000000001,chnl:15,x:0,y:247,page:0},{id:91,width:22,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.852,chnl:15,x:0,y:297,page:0},{id:93,width:19,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.852,chnl:15,x:0,y:347,page:0},{id:123,width:21,height:48,xoffset:0,yoffset:-32.193000000000005,xadvance:12.642000000000001,chnl:15,x:0,y:397,page:0},{id:106,width:19,height:48,xoffset:0,yoffset:-30.639000000000003,xadvance:10.08,chnl:15,x:0,y:447,page:0},{id:81,width:43,height:47,xoffset:0,yoffset:-30.429000000000002,xadvance:33.621,chnl:15,x:21,y:447,page:0},{id:77,width:45,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:38.997,chnl:15,x:66,y:447,page:0},{id:64,width:43,height:44,xoffset:0,yoffset:-28.539,xadvance:35.133,chnl:15,x:23,y:397,page:0},{id:92,width:28,height:43,xoffset:0,yoffset:-30.933000000000003,xadvance:18.984,chnl:15,x:68,y:397,page:0},{id:47,width:28,height:43,xoffset:0,yoffset:-30.933000000000003,xadvance:18.984,chnl:15,x:98,y:397,page:0},{id:109,width:42,height:32,xoffset:0,yoffset:-21.609,xadvance:34.545,chnl:15,x:113,y:447,page:0},{id:119,width:42,height:31,xoffset:0,yoffset:-21.315,xadvance:32.991,chnl:15,x:157,y:447,page:0},{id:42,width:25,height:42,xoffset:0,yoffset:-31.626,xadvance:17.85,chnl:15,x:128,y:397,page:0},{id:37,width:42,height:41,xoffset:0,yoffset:-30.387,xadvance:33.663000000000004,chnl:15,x:155,y:397,page:0},{id:79,width:42,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:33.621,chnl:15,x:199,y:397,page:0},{id:102,width:24,height:41,xoffset:0,yoffset:-30.534000000000002,xadvance:14.721,chnl:15,x:243,y:397,page:0},{id:100,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.520000000000003,chnl:15,x:269,y:397,page:0},{id:98,width:32,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.520000000000003,chnl:15,x:302,y:397,page:0},{id:56,width:32,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:336,y:397,page:0},{id:38,width:40,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:29.904000000000003,chnl:15,x:370,y:397,page:0},{id:108,width:17,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:9.912,chnl:15,x:412,y:397,page:0},{id:107,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:21.336000000000002,chnl:15,x:431,y:397,page:0},{id:48,width:33,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:464,y:397,page:0},{id:71,width:38,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:30.681,chnl:15,x:21,y:347,page:0},{id:83,width:31,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:22.785,chnl:15,x:61,y:347,page:0},{id:63,width:27,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:18.795,chnl:15,x:94,y:347,page:0},{id:105,width:18,height:41,xoffset:0,yoffset:-30.639000000000003,xadvance:10.08,chnl:15,x:123,y:347,page:0},{id:51,width:32,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:143,y:347,page:0},{id:104,width:31,height:41,xoffset:0,yoffset:-30.933000000000003,xadvance:23.436,chnl:15,x:177,y:347,page:0},{id:67,width:37,height:41,xoffset:0,yoffset:-30.429000000000002,xadvance:28.056,chnl:15,x:210,y:347,page:0},{id:88,width:37,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.258000000000003,chnl:15,x:249,y:347,page:0},{id:68,width:40,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:31.941000000000003,chnl:15,x:288,y:347,page:0},{id:70,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:23.751,chnl:15,x:330,y:347,page:0},{id:34,width:23,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:15.561000000000002,chnl:15,x:364,y:347,page:0},{id:72,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:32.067,chnl:15,x:389,y:347,page:0},{id:73,width:18,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:11.760000000000002,chnl:15,x:429,y:347,page:0},{id:74,width:24,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:17.745,chnl:15,x:449,y:347,page:0},{id:75,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.825000000000003,chnl:15,x:24,y:297,page:0},{id:76,width:31,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:21.567,chnl:15,x:475,y:347,page:0},{id:66,width:35,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:27.153000000000002,chnl:15,x:64,y:297,page:0},{id:78,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:32.067,chnl:15,x:101,y:297,page:0},{id:33,width:18,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:11.298,chnl:15,x:141,y:297,page:0},{id:80,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:25.221,chnl:15,x:161,y:297,page:0},{id:65,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:28.434,chnl:15,x:197,y:297,page:0},{id:82,width:36,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:26.313000000000002,chnl:15,x:237,y:297,page:0},{id:35,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:275,y:297,page:0},{id:84,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.801000000000002,chnl:15,x:310,y:297,page:0},{id:85,width:37,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:30.891000000000002,chnl:15,x:346,y:297,page:0},{id:86,width:38,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:28.434,chnl:15,x:385,y:297,page:0},{id:39,width:16,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:8.568000000000001,chnl:15,x:425,y:297,page:0},{id:69,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.255000000000003,chnl:15,x:443,y:297,page:0},{id:89,width:36,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:26.208000000000002,chnl:15,x:23,y:247,page:0},{id:90,width:34,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:25.284000000000002,chnl:15,x:477,y:297,page:0},{id:49,width:31,height:40,xoffset:0,yoffset:-30.156000000000002,xadvance:24.360000000000003,chnl:15,x:61,y:247,page:0},{id:50,width:32,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:94,y:247,page:0},{id:57,width:32,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:24.360000000000003,chnl:15,x:128,y:247,page:0},{id:94,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:162,y:247,page:0},{id:96,width:21,height:40,xoffset:0,yoffset:-30.429000000000002,xadvance:16.8,chnl:15,x:196,y:247,page:0},{id:55,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:219,y:247,page:0},{id:54,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:254,y:247,page:0},{id:53,width:32,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:289,y:247,page:0},{id:52,width:33,height:40,xoffset:0,yoffset:-30.093000000000004,xadvance:24.360000000000003,chnl:15,x:323,y:247,page:0},{id:103,width:31,height:39,xoffset:0,yoffset:-21.630000000000003,xadvance:21.84,chnl:15,x:358,y:247,page:0},{id:112,width:32,height:39,xoffset:0,yoffset:-21.651,xadvance:23.541,chnl:15,x:391,y:247,page:0},{id:113,width:31,height:39,xoffset:0,yoffset:-21.651,xadvance:23.520000000000003,chnl:15,x:425,y:247,page:0},{id:116,width:25,height:39,xoffset:0,yoffset:-28.182000000000002,xadvance:15.057,chnl:15,x:458,y:247,page:0},{id:121,width:31,height:38,xoffset:0,yoffset:-21.273,xadvance:21.651,chnl:15,x:34,y:196,page:0},{id:59,width:18,height:36,xoffset:0,yoffset:-20.706,xadvance:10.983,chnl:15,x:485,y:247,page:0},{id:43,width:32,height:34,xoffset:0,yoffset:-24.486,xadvance:24.360000000000003,chnl:15,x:67,y:196,page:0},{id:60,width:30,height:33,xoffset:0,yoffset:-23.331000000000003,xadvance:24.360000000000003,chnl:15,x:101,y:196,page:0},{id:62,width:31,height:33,xoffset:0,yoffset:-23.331000000000003,xadvance:24.360000000000003,chnl:15,x:133,y:196,page:0},{id:117,width:30,height:32,xoffset:0,yoffset:-21.273,xadvance:23.415000000000003,chnl:15,x:166,y:196,page:0},{id:99,width:29,height:32,xoffset:0,yoffset:-21.609,xadvance:20.055,chnl:15,x:198,y:196,page:0},{id:110,width:31,height:32,xoffset:0,yoffset:-21.609,xadvance:23.436,chnl:15,x:229,y:196,page:0},{id:111,width:32,height:32,xoffset:0,yoffset:-21.609,xadvance:23.814,chnl:15,x:262,y:196,page:0},{id:126,width:32,height:26,xoffset:0,yoffset:-16.128,xadvance:24.360000000000003,chnl:15,x:201,y:447,page:0},{id:101,width:31,height:32,xoffset:0,yoffset:-21.609,xadvance:22.176000000000002,chnl:15,x:296,y:196,page:0},{id:114,width:25,height:32,xoffset:0,yoffset:-21.651,xadvance:15.288,chnl:15,x:329,y:196,page:0},{id:115,width:27,height:32,xoffset:0,yoffset:-21.609,xadvance:18.186,chnl:15,x:356,y:196,page:0},{id:97,width:28,height:32,xoffset:0,yoffset:-21.651,xadvance:20.874000000000002,chnl:15,x:385,y:196,page:0},{id:118,width:31,height:31,xoffset:0,yoffset:-21.273,xadvance:21.672,chnl:15,x:415,y:196,page:0},{id:61,width:31,height:29,xoffset:0,yoffset:-19.089000000000002,xadvance:24.360000000000003,chnl:15,x:448,y:196,page:0},{id:120,width:30,height:31,xoffset:0,yoffset:-21.273,xadvance:20.916,chnl:15,x:21,y:145,page:0},{id:58,width:18,height:31,xoffset:0,yoffset:-20.706,xadvance:10.5,chnl:15,x:53,y:145,page:0},{id:122,width:28,height:31,xoffset:0,yoffset:-21.273,xadvance:18.984,chnl:15,x:73,y:145,page:0},{id:95,width:28,height:16,xoffset:0,yoffset:0,xadvance:19.278000000000002,chnl:15,x:235,y:447,page:0},{id:45,width:23,height:24,xoffset:0,yoffset:-14.175,xadvance:15.603000000000002,chnl:15,x:481,y:196,page:0},{id:44,width:17,height:21,xoffset:0,yoffset:-4.956,xadvance:9.534,chnl:15,x:103,y:145,page:0},{id:46,width:18,height:15,xoffset:0,yoffset:-4.956,xadvance:9.912,chnl:15,x:0,y:497,page:0},{id:32,width:0,height:0,xoffset:0,yoffset:0,xadvance:10.752,chnl:15,x:20,y:497,page:0}],info:{face:"Lato Regular",size:42,bold:0,italic:0,charset:[" ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"],unicode:1,stretchH:100,smooth:1,aa:1,padding:[0,0,0,0],spacing:[2,2]},common:{lineHeight:50.400000000000006,base:41.454,scaleW:512,scaleH:512,pages:1,packed:0,alphaChnl:0,redChnl:0,greenChnl:0,blueChnl:0},kernings:[]};class Zv extends _{get behavior(){return It}constructor(e){super();const n=Qa(Bh),r=j(e.field),i=e.as,o=e.fontSize;this.handle=s=>{const a=r(s);a!==void 0?s[i]=n.measureWidth(a,o):s[i]=0,this._propagate(s)}}}const Kv=65536;class qv extends _{get behavior(){return It}constructor(e){super(),this.params=e}reset(){this.initialize()}initialize(){const e=this.params,n=e.as||"lane",r=Ae(e.spacing)?e.spacing:1,i=j(e.start),o=j(e.end);if(!e.preference!=!e.preferredOrder)throw new Error('Must specify both "preference" and "preferredOrder"');if(e.preference){const s=new Float64Array(Kv),a=j(e.preference),u=e.preferredOrder;let c=1/0;this.handle=f=>{const l=i(f);l<c&&s.fill(-1/0),c=l;const h=u.indexOf(a(f));let p=-1;if(h>=0&&s[h]<l)p=h;else{const d=i(f);for(p=0;p<s.length&&!(s[p]<d);p++);if(p>=s.length)throw new Error("Out of lanes!")}s[p]=o(f)+r,f[n]=p,this._propagate(f)}}else{const s=new Eo,a=new Eo;let u=-1/0,c=0;this.handle=f=>{const l=i(f);for(;s.length&&(s.peekValue()<=l||l<u);){const p=s.pop();a.push(p,p)}u=l;let h=a.pop();h===void 0&&(h=c++),f[n]=h,this._propagate(f),s.push(h,o(f)+r)}}}}class Jv extends _{get behavior(){return lt}constructor(e){if(super(),e.as&&e.as.length!=e.fields.length)throw new Error('"fields" and "as" have unequal lengths!');const n=e.fields.map(i=>j(i)),r=e.as?e.as:n.map(G);this.handle=i=>{const o={};for(let s=0;s<n.length;s++)o[r[s]]=n[s](i);this._propagate(o)}}}class _v extends _{get behavior(){return It}constructor(e){super();const n=new RegExp(e.regex),r=typeof e.as=="string"?[e.as]:e.as,i=j(e.field);this.handle=o=>{const s=i(o);if(q(s)){const a=s.match(n);if(a){if(a.length-1!=r.length)throw new Error('The number of RegEx groups and the length of "as" do not match!');for(let u=0;u<r.length;u++)o[r[u]]=a[u+1]}else if(e.skipInvalidInput)for(let u=0;u<r.length;u++)o[r[u]]=void 0;else throw new Error(`"${s}" does not match the given regex: ${n.toString()}`)}else if(!e.skipInvalidInput)throw new Error(`Trying to match a non-string field. Encountered type: ${typeof s}, field content: "${s}".`);this._propagate(o)}}}class $v extends _{get behavior(){return lt}constructor(e){super();const n=Je(e.columnRegex).map(h=>new RegExp(h)),r=Je(e.asValue);if(n.length!=r.length)throw new Error('Lengths of "columnRegex" and "as" are not equal!');const i=e.skipRegex?new RegExp(e.skipRegex):void 0,o=e.asKey||"sample";let s,a,u;const c=h=>{var A;const p=Object.keys(h),d=new Map;for(const[m,b]of n.entries())for(const y of p){const v=(A=b.exec(y))==null?void 0:A[1];if(v!==void 0){let E=d.get(v);E||(E=[],d.set(v,E)),E[m]=y}}s=[...d.entries()],a=p.filter(m=>!n.some(b=>b.test(m))&&!(i&&i.test(m)));const g=[...a.map(m=>JSON.stringify(m)+": datum["+JSON.stringify(m)+"]"),JSON.stringify(o)+": sampleId",...r.map(m=>JSON.stringify(m)+": null")];u=new Function("datum","sampleId",`return {
|
|
145
145
|
`+g.join(`,
|
|
146
146
|
`)+`
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"contributors": [],
|
|
9
9
|
"license": "BSD-2-Clause",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.23.0",
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"module": "src/index.js",
|
|
13
13
|
"exports": {
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"vega-scale": "^7.1.1",
|
|
54
54
|
"vega-util": "^1.16.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "7420b51a4344e39985db59396ddf873eb3002143"
|
|
57
57
|
}
|
|
@@ -522,6 +522,27 @@ export default class ScaleResolution {
|
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
+
/**
|
|
526
|
+
* Resets the current domain to the initial one
|
|
527
|
+
*
|
|
528
|
+
* @returns true if the domain was changed
|
|
529
|
+
*/
|
|
530
|
+
resetZoom() {
|
|
531
|
+
if (!this.isZoomable()) {
|
|
532
|
+
throw new Error("Not a zoomable scale!");
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const oldDomain = this.getDomain();
|
|
536
|
+
const newDomain = this.getInitialDomain();
|
|
537
|
+
|
|
538
|
+
if ([0, 1].some((i) => newDomain[i] != oldDomain[i])) {
|
|
539
|
+
this._scale.domain(newDomain);
|
|
540
|
+
this._notifyDomainListeners();
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
|
|
525
546
|
/**
|
|
526
547
|
* Returns the zoom level with respect to the reference domain span (the original domain).
|
|
527
548
|
*
|