@genome-spy/core 0.28.0 → 0.28.1
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/LICENSE +24 -0
- package/dist/index.js +1 -1
- package/package.json +3 -2
- package/src/view/gridView.js +10 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2022 Kari Lavikka
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/dist/index.js
CHANGED
|
@@ -144,7 +144,7 @@ if(scale<1.0){if(uSqueeze){vec2 scaleFadeExtent=vec2(3.0,6.0)/size;if(scale<scal
|
|
|
144
144
|
* All rights reserved.
|
|
145
145
|
*
|
|
146
146
|
* BSD-3-Clause License: https://github.com/vega/vega-lite/blob/master/LICENSE
|
|
147
|
-
*/const Yw="locus",Ww="index";var Xw=5;function Zw(t){const e=t.type;return!t.bins&&(e===bn||e===wr||e===vr)}function uh(t){return Pe(t)&&![Ze,Ww,Yw].includes(t)}function ch(t){return t||{warn:(e,...n)=>console.warn(e,...n)}}var Kw=fi(["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 lh(t,e,n){n=ch(n);for(const r in t)if(!Kw[r]){if(r==="padding"&&uh(e.type))continue;ge(e[r])?e[r](t[r]):n.warn("Unsupported scale property: "+r)}rv(e,t,nv(e,t,$w(e,t,n)))}function qw(t,e){const n=Jw(t),r=O(n);if(!r)throw new Error("Unknown scale type: "+n);const i=r();return lh(t,i,e),i}function Jw(t){var e=t.type,n="",r;return e===Ze?Ze+"-"+bn:(_w(t)&&(r=t.rawDomain?t.rawDomain.length:t.domain?t.domain.length+ +(t.domainMid!=null):0,n=r===2?Ze+"-":r===3?wn+"-":""),(n+e||bn).toLowerCase())}function _w(t){const e=t.type;return Pe(e)&&e!==Vl&&e!==Yl&&(t.scheme||t.range&&t.range.length&&t.range.every(Z))}function $w(t,e,n){if(!t.domain)return 0;n=ch(n);var r=ev(t,e.domainRaw,n);if(r>-1)return r;var i=e.domain,o=t.type,s=e.zero||e.zero===void 0&&Zw(t),a,u;return i?(uh(o)&&e.padding&&i[0]!==Ne(i)&&(i=tv(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(fh(o,i,n)),o===Xs&&t.unknown(e.domainImplicit?ps:void 0),e.nice&&t.nice&&t.nice(e.nice!==!0&&sh(t,e.nice)||null),i.length):0}function ev(t,e,n){return e?(t.domain(fh(t.type,e,n)),e.length):-1}function tv(t,e,n,r,i,o){var s=Math.abs(Ne(n)-n[0]),a=s/(s-2*r),u=t===bt?xu(e,null,a):t===vr?Lo(e,null,a,.5):t===wr?Lo(e,null,a,i||1):t===Hi?hd(e,null,a,o||1):Au(e,null,a);return e=e.slice(),e[0]=u[0],e[e.length-1]=u[1],e}function fh(t,e,n){if(_l(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: "+li(e))}return e}function nv(t,e,n){let r=e.bins;if(r&&!Me(r)){const i=(r.start==null||r.stop==null)&&t.domain(),o=r.start==null?i[0]:r.start,s=r.stop==null?Ne(i):r.stop,a=r.step;a||X("Scale bins parameter missing step property."),r=Kn(o,s+a,a)}return r?t.bins=r:t.bins&&delete t.bins,t.type===Ks&&(r?!e.domain&&!e.domainRaw&&(t.domain(r),n=r.length):t.bins=t.domain()),n}function rv(t,e,n){var r=t.type,i=e.round||!1,o=e.range;if(e.rangeStep!=null)o=iv(r,e,n);else if(e.scheme&&(o=ov(r,e,n),ge(o))){if(t.interpolator)return t.interpolator(o);X(`Scale type ${r} does not support interpolating color schemes.`)}if(o&&ji(r))return t.interpolator(Vi(Za(o,e.reverse),e.interpolate,e.interpolateGamma));o&&e.interpolate&&t.interpolate?t.interpolate($l(e.interpolate,e.interpolateGamma)):ge(t.round)?t.round(i):ge(t.rangeRound)&&t.interpolate(i?yr:xt),o&&t.range(Za(o,e.reverse))}function iv(t,e,n){t!==Zl&&t!==Zs&&X("Only band and point scales support rangeStep.");var r=(e.paddingOuter!=null?e.paddingOuter:e.padding)||0,i=t===Zs?1:(e.paddingInner!=null?e.paddingInner:e.padding)||0;return[0,e.rangeStep*Ys(n,i,r)]}function ov(t,e,n){var r=e.schemeExtent,i,o;return Me(e.scheme)?o=Vi(e.scheme,e.interpolate,e.interpolateGamma):(i=e.scheme.toLowerCase(),o=Js(i),o||X(`Unrecognized scheme name: ${e.scheme}`)),n=t===Xl?n+1:t===Ks?n-1:t===Ws||t===Wl?+e.schemeCount||Xw:n,ji(t)?hh(o,r,e.reverse):ge(o)?gA(hh(o,r),n):t===Xs?o:o.slice(0,n)}function hh(t,e,n){return ge(t)&&(e||n)?pA(t,Za(e||[0,1],n)):t}function Za(t,e){return e?t.slice().reverse():t}const dh=se(",d");function sv(t,e){return t.chrom+":"+dh(Math.floor(t.pos+1))+"-"+(t.chrom!=e.chrom?e.chrom+":":"")+dh(Math.ceil(e.pos))}const av="https://genomespy.app/data/genomes/";class uv{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=av;try{this.setChromSizes(cv(await Di({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={...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=an(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 sv(...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 cv(t){return Td(t).filter(e=>/^chr[0-9A-Z]+$/.test(e[0])).map(([e,n])=>({name:e,size:parseInt(n)}))}function ph(t){return ke(t)&&"chrom"in t}function lv(t){return t.every(ph)}class qr extends Array{constructor(){super(),this.type=void 0}extend(e){return this}extendAll(e){if(e instanceof qr&&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 Ka extends qr{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 gh extends qr{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 mh extends gh{constructor(){super(),this.type="nominal"}}class fv extends qr{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 Ah={quantitative:Ka,index:Ka,locus:Ka,nominal:mh,ordinal:gh};function xh(t,e){if(t=="quantitative"&&hv(e)){const n=new fv(e);return n.type=t,n}else if(Ah[t]){const n=new Ah[t];return n.type=t,e&&n.extendAll(e),n}throw new Error("Unknown type: "+t)}function hv(t){return t&&t.length>0&&t.length!=2&&t.every(e=>typeof e=="number")}function dv(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}const yh="quantitative",bh="ordinal",wh="nominal",vh="locus",pv="index";class gv{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=aa(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&&!zr(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=>aa(n.view,n.channel).scale).filter(n=>n!==void 0);return So(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={...this._getDefaultScaleProperties(this.type),...e};n.type||(n.type=mv(this.channel,this.type));const r=this.getInitialDomain();return r&&r.length>0?n.domain=r:Wt(n.type)&&(n.domain=new mh),!n.domain&&n.domainMid!==void 0&&(n.domain=[(i=n.domainMin)!=null?i:0,(o=n.domainMax)!=null?o:1]),this.channel=="y"&&Wt(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),Av(n,this.channel),n})}getInitialDomain(){var e;return(e=this.getConfiguredDomain())!=null?e:this.type==vh?this.getGenome().getExtent():this.getDataDomain()}getConfiguredDomain(){return this._reduceDomains(e=>zr(e.channel)?void 0:e.view.getConfiguredDomain(e.channel))}getDataDomain(){return this._reduceDomains(e=>zr(e.channel)?void 0:e.view.extractDataDomain(e.channel))}reconfigure(){if(this._scale&&this._scale.type!="null"){V0(this,"scaleProps");const e=this.getScaleProps();lh(e,this._scale),Pe(this._scale.type)&&(this._zoomExtent=this._getZoomExtent())}}getScale(){if(this._scale)return this._scale;const e=this.getScaleProps(),n=qw(e);return this._scale=n,nm(n)&&n.genome(this.getGenome()),Pe(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()&&rf(this.getInitialDomain(),this.getDomain())}isZoomable(){if(!yf(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=cd(s,r||0),s=Au(s,a,e);break;case"log":s=ld(s,r||0),s=xu(s,a,e);break;case"pow":case"sqrt":{const u=i;s=fd(s,r||0,u.exponent()),s=Lo(s,a,e,u.exponent());break}default:throw new Error("Zooming is not implemented for: "+i.type)}return this._zoomExtent&&(s=dd(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(ui(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=yl([c,0,u],[l,0,f]).rho(.7);await i.transition({duration:n/1e3*h.duration,easingFunction:dv,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()?ci(this._zoomExtent)/ci(this.getScale().domain()):1}_getZoomExtent(){const e=this.getScaleProps(),n=e.zoom;if(xv(n)&&Me(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),Nr(n)?r.nice=!this.isExplicitDomain():qt(n)?r.scheme=e==wh?"tableau10":e==bh?"blues":"viridis":Ji(n)?r.range=wf(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 ph(e)?this.getGenome().toContinuous(e.chrom,e.pos):e}fromComplexInterval(e){return this.type==="locus"&&lv(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 mv(t,e){if(e==pv||e==vh){if(yf(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][[wh,bh,yh].indexOf(e)]:e==yh?"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 Av(t,e){Nr(e)&&t.type!=="ordinal"&&(t.range=[0,1]),e=="opacity"&&Pe(t.type)&&(t.clamp=!0)}function xv(t){return ke(t)}function qa(...t){for(const e of t)if(e!==void 0)return e}class yv{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:So(e.filter(n=>n!==void 0),"axis",["title"])})}getTitle(){const e=o=>{var a;const s=aa(o.view,o.channel);if(!Ue(s))return{member:o,explicitTitle:qa((a=s.axis)==null?void 0:a.title,s.title),implicitTitle:qa(Lr(s)?s.field:void 0,ua(s)?s.expr:void 0)}},n=this.members.map(e),r=n.filter(o=>{var s;if(zr(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=>qa(o.explicitTitle,o.implicitTitle)).filter(Z));return i.size?[...i].join(", "):null}}class Ch extends ih{constructor(e,n,r,i){super(e,n,r,i),this.spec=e}}class nn extends Nn{constructor(e,n,r,i){super(e,n,r,i),this.spec=e,this.children=(e.layer||[]).map((o,s)=>{if(nu(o)||tu(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 Eh{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 ct(t){return()=>t}const lt=class{static create(e,n,r,i){return new lt(ct(e),ct(n),ct(r),ct(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"?ct(i):typeof i=="function"?i:this._passThrough(r)};return new lt(n("x"),n("y"),n("width"),n("height"))}translate(e,n){return e===0&&n===0?this:new lt(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 lt(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 lt(()=>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 lt(ct(this.x),ct(this.y),ct(this.width),ct(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=lt;$h(On,"ZERO",lt.create(0,0,0,0));function bv(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 J{get identifier(){}handle(e){throw new Error("Source does not handle incoming data!")}async load(){}}function Sh(t){var n,r;const e={...t.format};if((n=e.type)!=null||(e.type=Ev(t)&&wv(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 wv(t){var e;if(Array.isArray(t)&&(t=t[0]),t)return(e=t.match(/\.(csv|tsv|json)/))==null?void 0:e[1]}const Do=t=>typeof t!="object"?vv:Cv,vv=t=>({data:t}),Cv=t=>t;function Ev(t){return"url"in t}function Sv(t){return"dynamicCallbackSource"in t}class Dh 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=Do(r)),this._propagate(n(r));this.complete()}async load(){this.loadSynchronously()}}const Bh="chromosome_ticks_and_labels",Fh={x:"width",y:"height"};function Ja(t){return t=="x"?"y":"x"}const _a={x:["bottom","top"],y:["left","right"]},Mh=Object.fromEntries(Object.entries(_a).map(([t,e])=>e.map(n=>[n,t])).flat(1));function rn(t){return Mh[t]}class Dv extends nn{constructor(e,n,r,i){const o=n=="locus",s={...o?Mv:Ih,...Fv(n,e),...e};if(super(o?Iv(s):Th(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 Dh(()=>this.ticks),o){const a=rn(this.axisProps.orient),u=this.getScaleResolution(a).getGenome();this.findChildByName(Bh).getDynamicDataSource=()=>new Dh(()=>u.chromosomes)}this.blockEncodingInheritance=!0}getOrient(){return this.axisProps.orient}getSize(){const e={px:this.getPerpendicularSize()},n={grow:1};return Mh[this.axisProps.orient]=="x"?new tn(n,e):new tn(e,n)}getPerpendicularSize(){return $a(this.axisProps)}getDynamicDataSource(){return this.tickSource}_updateAxisData(){const e=rn(this.axisProps.orient),n=this.getScaleResolution(e).getScale(),r=n.domain();if(rf(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[Fh[rn(this.getOrient())]],super.render(e,n,r))}isPickingSupported(){return!1}}function $a(t){const e=rn(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*bv(100,700,a);let o=me(t.tickCount)?t.tickCount:Math.round(n/i(n));o=sh(e,o,t.tickMinStep);const s=t.values?ah(e,t.values,o):Ow(e,o);if(bA(s,r,a=>a,a=>a.value))return r;{const a=Uw(e,o,t.format);return s.map(u=>({value:u,label:a(u)}))}}const Ih={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 Fv(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 Th(t){const e={...t,extent:$a(t)},n=rn(e.orient),r=Ja(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={[Fh[Ja(rn(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 Mv={...Ih,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 Iv(t){const e={...t,extent:$a(t)},n=rn(e.orient),r=Ja(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:{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=Th({...t,...a});if(t.chromTicks||t.chromLabels){const c={name:Bh,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 Ph={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"},Tv={orient:"left",anchor:"middle",align:"right",baseline:"middle",angle:0,fontSize:12},Pv={orient:"top",anchor:"start",align:"left",baseline:"top",offset:-10,dx:10,fontSize:12},Lv={start:0,middle:.5,end:1},Rv={start:"left",middle:"center",end:"right"};function kv(t){var c,f,l;if(!t)return;const e=Z(t)?{text:t}:t;if(!e.text||e.orient=="none")return;const n=(c={"track-title":Tv,overlay:Pv}[e.style])!=null?c:{},r={...Ph,...n,...e};let i={},o={x:0,y:0};const s=Lv[(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={...Ph,...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:{type:"text",tooltip:null,clip:!1,...o,...u,text:a.text,align:(l=a.align)!=null?l:Rv[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 Nv(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 Lh extends Nn{constructor(n,r,i,o,s){var a;super(n,r,i,o);he(this,_r);he(this,$e);he(this,Fo);he(this,Mo);he(this,on);he(this,$r);he(this,ei);he(this,ti);he(this,Io);he(this,Un,1/0);he(this,Hn,10);he(this,Re,[]);he(this,Qn,0);this.spec=n,Yn(this,Hn,(a=n.spacing)!=null?a:10),Yn(this,Un,s),Yn(this,Re,[]),this.wrappingFacet=!1,this._createChildren()}_createChildren(){}appendChild(n){var r;(r=n.parent)!=null||(n.parent=this),V(this,Re).push(ue(this,_r,fu).call(this,n)),ed(this,Qn)._++}setChildren(n){for(const r of n)this.appendChild(r)}replaceChild(n,r){const i=V(this,Re).findIndex(o=>o.view==n);if(i>=0)V(this,Re)[i]=ue(this,_r,fu).call(this,r);else throw new Error("Not my child view!")}get children(){return V(this,Re).map(n=>n.view)}get childCount(){return V(this,Re).length}onScalesResolved(){super.onScalesResolved(),ue(this,Mo,nd).call(this)}*[Symbol.iterator](){for(const n of V(this,Re)){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=ue(this,on,ri).call(this,"column"),r=ue(this,on,ri).call(this,"row");return!n.length||!r.length?je.zero():new je(r.at(0).axisBefore,n.at(-1).axisAfter,r.at(-1).axisAfter,n.at(0).axisBefore)}getSize(){return this._cache("size",()=>new tn(ue(this,ei,du).call(this,"column"),ue(this,ei,du).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=eh(ue(this,$r,hu).call(this,"column"),r.width,o),a=eh(ue(this,$r,hu).call(this,"row"),r.height,o),u=new Eh(V(this,$e,Mt).length,(c=V(this,Un))!=null?c:1/0);for(const[f,l]of V(this,$e,Mt).entries()){const{view:h,axes:p,background:d,title:g}=l,[A,m]=u.getCellCoords(f),b=s[ue(this,ti,pu).call(this,"column",A)],y=a[ue(this,ti,pu).call(this,"row",m)],w=h.getSize(),E=h.getPadding().subtract(h.getOverhang()),C=b.location+E.left,B=y.location+E.top,I=(w.width.grow?b.size:w.width.px)-E.width,P=(w.height.grow?y.size:w.height.px)-E.height,U=new On(()=>r.x+C,()=>r.y+B,()=>I,()=>P);l.coords=U,d==null||d.render(n,U,i);const M=Gv(h);M&&h.render(n,U,i);for(const[ve,oe]of Object.entries(p)){const Se=oe.axisProps;let et;const De=oe.getPerpendicularSize();ve=="bottom"?et=U.translate(0,U.height+Se.offset).modify({height:De}):ve=="top"?et=U.translate(0,-De-Se.offset).modify({height:De}):ve=="left"?et=U.translate(-De-Se.offset,0).modify({width:De}):ve=="right"&&(et=U.translate(U.width+Se.offset,0).modify({width:De})),oe.render(n,et)}M||h.render(n,U,i),g==null||g.render(n,U,{...i,clipRect:void 0})}n.popView(this)}propagateInteractionEvent(n){if(this.handleInteractionEvent(void 0,n,!0),n.stopped)return;const r=V(this,$e,Mt).find(o=>o.coords.containsPoint(n.point.x,n.point.y)),i=r==null?void 0:r.view;i&&(i.propagateInteractionEvent(n),(i instanceof we||i instanceof nn)&&Nv(n,r.coords,o=>ue(this,Io,rd).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,Re=new WeakMap,Qn=new WeakMap,_r=new WeakSet,fu=function(n){var i;const r={view:n,background:void 0,axes:{},coords:On.ZERO};if(n instanceof we||n instanceof nn){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 we(zv(o),this.context,n,"background"+V(this,Qn));a.blockEncodingInheritance=!0,r.background=a}const s=kv(n.spec.title);if(s){const a=new we(s,this.context,n,"title"+V(this,Qn));a.blockEncodingInheritance=!0,r.title=a}}return r},$e=new WeakSet,Mt=function(){return V(this,Re).filter(n=>n.view.isVisible())},Fo=new WeakSet,td=function(){var n;return new Eh(V(this,$e,Mt).length,(n=V(this,Un))!=null?n:1/0)},Mo=new WeakSet,nd=function(){if(Object.keys(this.resolutions.axis).length)throw new Error("ConcatView does not (currently) support shared axes!");for(const n of V(this,Re)){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 _a[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()),!_a[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 Dv(c,s.scaleResolution.type,this.context,u)}};if(r instanceof we||r instanceof nn)for(const s of["x","y"]){const a=r.resolutions.axis[s];!a||o(a,s,r)}if(r instanceof nn){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)}}}},on=new WeakSet,ri=function(n){const r=n=="column"?["left","right"]:["top","bottom"],i=n=="column"?"width":"height",o=(s,a)=>s.map(u=>{const c=V(this,$e,Mt)[u].axes[r[a]];if(c)return Math.max(c.getPerpendicularSize()+c.axisProps.offset,0);const f=V(this,$e,Mt)[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 V(this,Fo,td)[n=="column"?"colIndices":"rowIndices"].map(s=>({axisBefore:o(s,0),axisAfter:o(s,1),view:Tw(s.map(a=>V(this,$e,Mt)[a].view.getSize()[i]))}))},$r=new WeakSet,hu=function(n){const r=ue(this,on,ri).call(this,n),i=[];i.push(Zr);for(const[o,s]of r.entries())o>0&&i.push({px:V(this,Hn),grow:0}),(o==0||this.wrappingFacet)&&i.push(Zr),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(Zr);return i},ei=new WeakSet,du=function(n){var a,u;let r=0,i=0;const o=n=="row"&&this.spec.height||n=="column"&&this.spec.width;if(o!==void 0&&o!=="")return th(o);const s=ue(this,on,ri).call(this,n);for(const[c,f]of s.entries())c>0&&(i+=V(this,Hn)),(c==0||this.wrappingFacet)&&(i+=0),i+=f.axisBefore,i+=(a=f.view.px)!=null?a:0,r+=(u=f.view.grow)!=null?u:0,i+=f.axisAfter,(c==s.length-1||this.wrappingFacet)&&(i+=0);return{px:i,grow:r}},ti=new WeakSet,pu=function(n,r){return n=="row"&&this.wrappingFacet?1+6*r+2:2+4*r+1},Io=new WeakSet,rd=function(n,r,i){for(const[o,s]of Object.entries(Ov(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 zv(t){return{configurableVisibility:!1,data:{values:[{}]},mark:{fill:null,strokeWidth:1,fillOpacity:t.fill?1:0,...t,type:"rect",clip:!1,tooltip:null}}}function Ov(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 Gv(t){let e=!0;return t.visit(n=>{n instanceof we&&e&&(e=n.mark.properties.clip)}),e}class eu extends Lh{constructor(e,n,r,i){super(e,n,r,i,iu(e)?e.columns:ru(e)?1:1/0),this.spec=e}_createChildren(){const e=this.spec,n=iu(e)?e.concat:ru(e)?e.vconcat:e.hconcat;this.setChildren(n.map((r,i)=>this.context.createView(r,this,"grid"+i)))}}class Uv{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(Hv,e(Ch)),this.addViewType(nu,e(nn)),this.addViewType(tu,e(we)),this.addViewType(ru,e(eu)),this.addViewType(Qv,e(eu)),this.addViewType(iu,e(eu))}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 tu(t){return"mark"in t&&(Z(t.mark)||ke(t.mark))}function nu(t){return"layer"in t&&ke(t.layer)}function Rh(t){return t&&(tu(t)||nu(t))&&"aggregateSamples"in t}function Hv(t){return"import"in t}function ru(t){return"vconcat"in t&&Me(t.vconcat)}function Qv(t){return"hconcat"in t&&Me(t.hconcat)}function iu(t){return"concat"in t&&Me(t.concat)}const jv={point:Aw,rect:lw,rule:bw,link:Ew,text:Iw};class we extends Nn{constructor(e,n,r,i){super(e,n,r,i),this.spec=e;const o=jv[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(!Le(o))continue;let s=En((r=o.resolutionChannel)!=null?r:i);if(e=="axis"&&!Nr(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 gv(s):new yv(s)),Nr(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(zr(e))throw new Error(`getDomain(${e}), must only be called for primary channels!`);const n=this.mark.encoding[e];if(!Le(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 xh((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=xh(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=ca[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 kr.map(e).reduce((n,r)=>n*r,1)}_initializeAggregateViews(){var e,n;if(Rh(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={...(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*ou(t,e=[]){for(const[n,r]of t.entries())if(r instanceof Map)for(const i of ou(r,[...e,n]))yield i;else yield[[...e,n],r]}class su extends J{constructor(e){super(),this.params=e!=null?e:{type:"collect"},this.observers=[],this.facetBatches=void 0,this._init()}_init(){this._data=[],this.facetBatches=new Pt([],JSON.stringify),this.facetBatches.set(void 0,this._data)}reset(){super.reset(),this._init()}handle(e){this._data.push(e)}beginBatch(e){pw(e)&&(this._data=[],this.facetBatches.set(Ke(e.facetId),this._data))}complete(){var i,o;const e=(i=this.params)==null?void 0:i.sort,n=e?yu(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=>H(u)),a=di(this._data,...s);this.facetBatches.clear();for(const[u,c]of ou(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 Bo{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 Vv extends J{get behavior(){return ut}constructor(e){super(),this.params=e,this.startAccessor=H(e.start),this.endAccessor=H(e.end),this.chromAccessor=e.chrom?H(e.chrom):n=>{},this.weightAccessor=e.weight?H(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 Bo}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 w=s(A);w!==c&&(g(),f=w,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 Yv(t,e,n=0,r=t.length){const i=new Bo,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 Wv{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 Xv extends J{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=H(this.params.pos),this.posBisector=hi(this.posAccessor),this.scoreAccessor=H(this.params.score),this.widthAccessor=H(this.params.width),this.laneAccessor=this.params.lane?H(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 Wv(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=Yv(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 Zv extends J{constructor(e){super(),this.params=e,this.predicate=void 0}initialize(){this.predicate=sa(this.params.expr,this.getGlobalObject())}handle(e){this.predicate(e)&&this._propagate(e)}}const Kv="0".charCodeAt(0);function*qv(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-Kv}yield r}class Jv extends J{get behavior(){return ut}constructor(e){var s,a;super();const n=H((s=e.exons)!=null?s:"exons"),r=H((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 qv(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 _v extends J{get behavior(){return ut}constructor(e){super();const n=Ke(e.field).map(o=>H(o)),r=Ke(e.separator),i=Ke(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]));$v(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 $v(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 eC extends J{get behavior(){return Ft}constructor(e){super(),this.params=e,this.as=e.as,this.fn=void 0}initialize(){this.fn=sa(this.params.expr,this.getGlobalObject())}handle(e){e[this.as]=this.fn(e),this._propagate(e)}}class kh extends J{get behavior(){return Ft}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=H(e.chrom),s=Ke(e.pos).map(g=>H(g)),a=Ke(e.as);if(s.length!=a.length)throw new Error('The number of "pos" and "as" elements must be equal!');const u=Ke(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(`
|
|
147
|
+
*/const Yw="locus",Ww="index";var Xw=5;function Zw(t){const e=t.type;return!t.bins&&(e===bn||e===wr||e===vr)}function uh(t){return Pe(t)&&![Ze,Ww,Yw].includes(t)}function ch(t){return t||{warn:(e,...n)=>console.warn(e,...n)}}var Kw=fi(["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 lh(t,e,n){n=ch(n);for(const r in t)if(!Kw[r]){if(r==="padding"&&uh(e.type))continue;ge(e[r])?e[r](t[r]):n.warn("Unsupported scale property: "+r)}rv(e,t,nv(e,t,$w(e,t,n)))}function qw(t,e){const n=Jw(t),r=O(n);if(!r)throw new Error("Unknown scale type: "+n);const i=r();return lh(t,i,e),i}function Jw(t){var e=t.type,n="",r;return e===Ze?Ze+"-"+bn:(_w(t)&&(r=t.rawDomain?t.rawDomain.length:t.domain?t.domain.length+ +(t.domainMid!=null):0,n=r===2?Ze+"-":r===3?wn+"-":""),(n+e||bn).toLowerCase())}function _w(t){const e=t.type;return Pe(e)&&e!==Vl&&e!==Yl&&(t.scheme||t.range&&t.range.length&&t.range.every(Z))}function $w(t,e,n){if(!t.domain)return 0;n=ch(n);var r=ev(t,e.domainRaw,n);if(r>-1)return r;var i=e.domain,o=t.type,s=e.zero||e.zero===void 0&&Zw(t),a,u;return i?(uh(o)&&e.padding&&i[0]!==Ne(i)&&(i=tv(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(fh(o,i,n)),o===Xs&&t.unknown(e.domainImplicit?ps:void 0),e.nice&&t.nice&&t.nice(e.nice!==!0&&sh(t,e.nice)||null),i.length):0}function ev(t,e,n){return e?(t.domain(fh(t.type,e,n)),e.length):-1}function tv(t,e,n,r,i,o){var s=Math.abs(Ne(n)-n[0]),a=s/(s-2*r),u=t===bt?xu(e,null,a):t===vr?Lo(e,null,a,.5):t===wr?Lo(e,null,a,i||1):t===Hi?hd(e,null,a,o||1):Au(e,null,a);return e=e.slice(),e[0]=u[0],e[e.length-1]=u[1],e}function fh(t,e,n){if(_l(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: "+li(e))}return e}function nv(t,e,n){let r=e.bins;if(r&&!Me(r)){const i=(r.start==null||r.stop==null)&&t.domain(),o=r.start==null?i[0]:r.start,s=r.stop==null?Ne(i):r.stop,a=r.step;a||X("Scale bins parameter missing step property."),r=Kn(o,s+a,a)}return r?t.bins=r:t.bins&&delete t.bins,t.type===Ks&&(r?!e.domain&&!e.domainRaw&&(t.domain(r),n=r.length):t.bins=t.domain()),n}function rv(t,e,n){var r=t.type,i=e.round||!1,o=e.range;if(e.rangeStep!=null)o=iv(r,e,n);else if(e.scheme&&(o=ov(r,e,n),ge(o))){if(t.interpolator)return t.interpolator(o);X(`Scale type ${r} does not support interpolating color schemes.`)}if(o&&ji(r))return t.interpolator(Vi(Za(o,e.reverse),e.interpolate,e.interpolateGamma));o&&e.interpolate&&t.interpolate?t.interpolate($l(e.interpolate,e.interpolateGamma)):ge(t.round)?t.round(i):ge(t.rangeRound)&&t.interpolate(i?yr:xt),o&&t.range(Za(o,e.reverse))}function iv(t,e,n){t!==Zl&&t!==Zs&&X("Only band and point scales support rangeStep.");var r=(e.paddingOuter!=null?e.paddingOuter:e.padding)||0,i=t===Zs?1:(e.paddingInner!=null?e.paddingInner:e.padding)||0;return[0,e.rangeStep*Ys(n,i,r)]}function ov(t,e,n){var r=e.schemeExtent,i,o;return Me(e.scheme)?o=Vi(e.scheme,e.interpolate,e.interpolateGamma):(i=e.scheme.toLowerCase(),o=Js(i),o||X(`Unrecognized scheme name: ${e.scheme}`)),n=t===Xl?n+1:t===Ks?n-1:t===Ws||t===Wl?+e.schemeCount||Xw:n,ji(t)?hh(o,r,e.reverse):ge(o)?gA(hh(o,r),n):t===Xs?o:o.slice(0,n)}function hh(t,e,n){return ge(t)&&(e||n)?pA(t,Za(e||[0,1],n)):t}function Za(t,e){return e?t.slice().reverse():t}const dh=se(",d");function sv(t,e){return t.chrom+":"+dh(Math.floor(t.pos+1))+"-"+(t.chrom!=e.chrom?e.chrom+":":"")+dh(Math.ceil(e.pos))}const av="https://genomespy.app/data/genomes/";class uv{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=av;try{this.setChromSizes(cv(await Di({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={...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=an(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 sv(...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 cv(t){return Td(t).filter(e=>/^chr[0-9A-Z]+$/.test(e[0])).map(([e,n])=>({name:e,size:parseInt(n)}))}function ph(t){return ke(t)&&"chrom"in t}function lv(t){return t.every(ph)}class qr extends Array{constructor(){super(),this.type=void 0}extend(e){return this}extendAll(e){if(e instanceof qr&&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 Ka extends qr{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 gh extends qr{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 mh extends gh{constructor(){super(),this.type="nominal"}}class fv extends qr{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 Ah={quantitative:Ka,index:Ka,locus:Ka,nominal:mh,ordinal:gh};function xh(t,e){if(t=="quantitative"&&hv(e)){const n=new fv(e);return n.type=t,n}else if(Ah[t]){const n=new Ah[t];return n.type=t,e&&n.extendAll(e),n}throw new Error("Unknown type: "+t)}function hv(t){return t&&t.length>0&&t.length!=2&&t.every(e=>typeof e=="number")}function dv(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}const yh="quantitative",bh="ordinal",wh="nominal",vh="locus",pv="index";class gv{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=aa(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&&!zr(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=>aa(n.view,n.channel).scale).filter(n=>n!==void 0);return So(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={...this._getDefaultScaleProperties(this.type),...e};n.type||(n.type=mv(this.channel,this.type));const r=this.getInitialDomain();return r&&r.length>0?n.domain=r:Wt(n.type)&&(n.domain=new mh),!n.domain&&n.domainMid!==void 0&&(n.domain=[(i=n.domainMin)!=null?i:0,(o=n.domainMax)!=null?o:1]),this.channel=="y"&&Wt(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),Av(n,this.channel),n})}getInitialDomain(){var e;return(e=this.getConfiguredDomain())!=null?e:this.type==vh?this.getGenome().getExtent():this.getDataDomain()}getConfiguredDomain(){return this._reduceDomains(e=>zr(e.channel)?void 0:e.view.getConfiguredDomain(e.channel))}getDataDomain(){return this._reduceDomains(e=>zr(e.channel)?void 0:e.view.extractDataDomain(e.channel))}reconfigure(){if(this._scale&&this._scale.type!="null"){V0(this,"scaleProps");const e=this.getScaleProps();lh(e,this._scale),Pe(this._scale.type)&&(this._zoomExtent=this._getZoomExtent())}}getScale(){if(this._scale)return this._scale;const e=this.getScaleProps(),n=qw(e);return this._scale=n,nm(n)&&n.genome(this.getGenome()),Pe(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()&&rf(this.getInitialDomain(),this.getDomain())}isZoomable(){if(!yf(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=cd(s,r||0),s=Au(s,a,e);break;case"log":s=ld(s,r||0),s=xu(s,a,e);break;case"pow":case"sqrt":{const u=i;s=fd(s,r||0,u.exponent()),s=Lo(s,a,e,u.exponent());break}default:throw new Error("Zooming is not implemented for: "+i.type)}return this._zoomExtent&&(s=dd(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(ui(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=yl([c,0,u],[l,0,f]).rho(.7);await i.transition({duration:n/1e3*h.duration,easingFunction:dv,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()?ci(this._zoomExtent)/ci(this.getScale().domain()):1}_getZoomExtent(){const e=this.getScaleProps(),n=e.zoom;if(xv(n)&&Me(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),Nr(n)?r.nice=!this.isExplicitDomain():qt(n)?r.scheme=e==wh?"tableau10":e==bh?"blues":"viridis":Ji(n)?r.range=wf(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 ph(e)?this.getGenome().toContinuous(e.chrom,e.pos):e}fromComplexInterval(e){return this.type==="locus"&&lv(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 mv(t,e){if(e==pv||e==vh){if(yf(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][[wh,bh,yh].indexOf(e)]:e==yh?"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 Av(t,e){Nr(e)&&t.type!=="ordinal"&&(t.range=[0,1]),e=="opacity"&&Pe(t.type)&&(t.clamp=!0)}function xv(t){return ke(t)}function qa(...t){for(const e of t)if(e!==void 0)return e}class yv{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:So(e.filter(n=>n!==void 0),"axis",["title"])})}getTitle(){const e=o=>{var a;const s=aa(o.view,o.channel);if(!Ue(s))return{member:o,explicitTitle:qa((a=s.axis)==null?void 0:a.title,s.title),implicitTitle:qa(Lr(s)?s.field:void 0,ua(s)?s.expr:void 0)}},n=this.members.map(e),r=n.filter(o=>{var s;if(zr(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=>qa(o.explicitTitle,o.implicitTitle)).filter(Z));return i.size?[...i].join(", "):null}}class Ch extends ih{constructor(e,n,r,i){super(e,n,r,i),this.spec=e}}class nn extends Nn{constructor(e,n,r,i){super(e,n,r,i),this.spec=e,this.children=(e.layer||[]).map((o,s)=>{if(nu(o)||tu(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 Eh{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 ct(t){return()=>t}const lt=class{static create(e,n,r,i){return new lt(ct(e),ct(n),ct(r),ct(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"?ct(i):typeof i=="function"?i:this._passThrough(r)};return new lt(n("x"),n("y"),n("width"),n("height"))}translate(e,n){return e===0&&n===0?this:new lt(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 lt(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 lt(()=>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 lt(ct(this.x),ct(this.y),ct(this.width),ct(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=lt;$h(On,"ZERO",lt.create(0,0,0,0));function bv(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 J{get identifier(){}handle(e){throw new Error("Source does not handle incoming data!")}async load(){}}function Sh(t){var n,r;const e={...t.format};if((n=e.type)!=null||(e.type=Ev(t)&&wv(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 wv(t){var e;if(Array.isArray(t)&&(t=t[0]),t)return(e=t.match(/\.(csv|tsv|json)/))==null?void 0:e[1]}const Do=t=>typeof t!="object"?vv:Cv,vv=t=>({data:t}),Cv=t=>t;function Ev(t){return"url"in t}function Sv(t){return"dynamicCallbackSource"in t}class Dh 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=Do(r)),this._propagate(n(r));this.complete()}async load(){this.loadSynchronously()}}const Bh="chromosome_ticks_and_labels",Fh={x:"width",y:"height"};function Ja(t){return t=="x"?"y":"x"}const _a={x:["bottom","top"],y:["left","right"]},Mh=Object.fromEntries(Object.entries(_a).map(([t,e])=>e.map(n=>[n,t])).flat(1));function rn(t){return Mh[t]}class Dv extends nn{constructor(e,n,r,i){const o=n=="locus",s={...o?Mv:Ih,...Fv(n,e),...e};if(super(o?Iv(s):Th(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 Dh(()=>this.ticks),o){const a=rn(this.axisProps.orient),u=this.getScaleResolution(a).getGenome();this.findChildByName(Bh).getDynamicDataSource=()=>new Dh(()=>u.chromosomes)}this.blockEncodingInheritance=!0}getOrient(){return this.axisProps.orient}getSize(){const e={px:this.getPerpendicularSize()},n={grow:1};return Mh[this.axisProps.orient]=="x"?new tn(n,e):new tn(e,n)}getPerpendicularSize(){return $a(this.axisProps)}getDynamicDataSource(){return this.tickSource}_updateAxisData(){const e=rn(this.axisProps.orient),n=this.getScaleResolution(e).getScale(),r=n.domain();if(rf(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[Fh[rn(this.getOrient())]],super.render(e,n,r))}isPickingSupported(){return!1}}function $a(t){const e=rn(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*bv(100,700,a);let o=me(t.tickCount)?t.tickCount:Math.round(n/i(n));o=sh(e,o,t.tickMinStep);const s=t.values?ah(e,t.values,o):Ow(e,o);if(bA(s,r,a=>a,a=>a.value))return r;{const a=Uw(e,o,t.format);return s.map(u=>({value:u,label:a(u)}))}}const Ih={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 Fv(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 Th(t){const e={...t,extent:$a(t)},n=rn(e.orient),r=Ja(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={[Fh[Ja(rn(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 Mv={...Ih,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 Iv(t){const e={...t,extent:$a(t)},n=rn(e.orient),r=Ja(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:{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=Th({...t,...a});if(t.chromTicks||t.chromLabels){const c={name:Bh,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 Ph={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"},Tv={orient:"left",anchor:"middle",align:"right",baseline:"middle",angle:0,fontSize:12},Pv={orient:"top",anchor:"start",align:"left",baseline:"top",offset:-10,dx:10,fontSize:12},Lv={start:0,middle:.5,end:1},Rv={start:"left",middle:"center",end:"right"};function kv(t){var c,f,l;if(!t)return;const e=Z(t)?{text:t}:t;if(!e.text||e.orient=="none")return;const n=(c={"track-title":Tv,overlay:Pv}[e.style])!=null?c:{},r={...Ph,...n,...e};let i={},o={x:0,y:0};const s=Lv[(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={...Ph,...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:{type:"text",tooltip:null,clip:!1,...o,...u,text:a.text,align:(l=a.align)!=null?l:Rv[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 Nv(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 Lh extends Nn{constructor(n,r,i,o,s){var a;super(n,r,i,o);he(this,_r);he(this,$e);he(this,Fo);he(this,Mo);he(this,on);he(this,$r);he(this,ei);he(this,ti);he(this,Io);he(this,Un,1/0);he(this,Hn,10);he(this,Re,[]);he(this,Qn,0);this.spec=n,Yn(this,Hn,(a=n.spacing)!=null?a:10),Yn(this,Un,s),Yn(this,Re,[]),this.wrappingFacet=!1,this._createChildren()}_createChildren(){}appendChild(n){var r;(r=n.parent)!=null||(n.parent=this),V(this,Re).push(ue(this,_r,fu).call(this,n)),ed(this,Qn)._++}setChildren(n){for(const r of n)this.appendChild(r)}replaceChild(n,r){const i=V(this,Re).findIndex(o=>o.view==n);if(i>=0)V(this,Re)[i]=ue(this,_r,fu).call(this,r);else throw new Error("Not my child view!")}get children(){return V(this,Re).map(n=>n.view)}get childCount(){return V(this,Re).length}onScalesResolved(){super.onScalesResolved(),ue(this,Mo,nd).call(this)}*[Symbol.iterator](){for(const n of V(this,Re)){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=ue(this,on,ri).call(this,"column"),r=ue(this,on,ri).call(this,"row");return!n.length||!r.length?je.zero():new je(r.at(0).axisBefore,n.at(-1).axisAfter,r.at(-1).axisAfter,n.at(0).axisBefore)}getSize(){return new tn(ue(this,ei,du).call(this,"column"),ue(this,ei,du).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=eh(ue(this,$r,hu).call(this,"column"),r.width,o),a=eh(ue(this,$r,hu).call(this,"row"),r.height,o),u=new Eh(V(this,$e,Mt).length,(c=V(this,Un))!=null?c:1/0);for(const[f,l]of V(this,$e,Mt).entries()){const{view:h,axes:p,background:d,title:g}=l,[A,m]=u.getCellCoords(f),b=s[ue(this,ti,pu).call(this,"column",A)],y=a[ue(this,ti,pu).call(this,"row",m)],w=h.getSize(),E=h.getPadding().subtract(h.getOverhang()),C=b.location+E.left,B=y.location+E.top,I=(w.width.grow?b.size:w.width.px)-E.width,P=(w.height.grow?y.size:w.height.px)-E.height,U=new On(()=>r.x+C,()=>r.y+B,()=>I,()=>P);l.coords=U,d==null||d.render(n,U,i);const M=Gv(h);M&&h.render(n,U,i);for(const[ve,oe]of Object.entries(p)){const Se=oe.axisProps;let et;const De=oe.getPerpendicularSize();ve=="bottom"?et=U.translate(0,U.height+Se.offset).modify({height:De}):ve=="top"?et=U.translate(0,-De-Se.offset).modify({height:De}):ve=="left"?et=U.translate(-De-Se.offset,0).modify({width:De}):ve=="right"&&(et=U.translate(U.width+Se.offset,0).modify({width:De})),oe.render(n,et)}M||h.render(n,U,i),g==null||g.render(n,U,{...i,clipRect:void 0})}n.popView(this)}propagateInteractionEvent(n){if(this.handleInteractionEvent(void 0,n,!0),n.stopped)return;const r=V(this,$e,Mt).find(o=>o.coords.containsPoint(n.point.x,n.point.y)),i=r==null?void 0:r.view;i&&(i.propagateInteractionEvent(n),(i instanceof we||i instanceof nn)&&Nv(n,r.coords,o=>ue(this,Io,rd).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,Re=new WeakMap,Qn=new WeakMap,_r=new WeakSet,fu=function(n){var i;const r={view:n,background:void 0,axes:{},coords:On.ZERO};if(n instanceof we||n instanceof nn){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 we(zv(o),this.context,n,"background"+V(this,Qn));a.blockEncodingInheritance=!0,r.background=a}const s=kv(n.spec.title);if(s){const a=new we(s,this.context,n,"title"+V(this,Qn));a.blockEncodingInheritance=!0,r.title=a}}return r},$e=new WeakSet,Mt=function(){return V(this,Re).filter(n=>n.view.isVisible())},Fo=new WeakSet,td=function(){var n;return new Eh(V(this,$e,Mt).length,(n=V(this,Un))!=null?n:1/0)},Mo=new WeakSet,nd=function(){if(Object.keys(this.resolutions.axis).length)throw new Error("ConcatView does not (currently) support shared axes!");for(const n of V(this,Re)){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 _a[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()),!_a[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 Dv(c,s.scaleResolution.type,this.context,u)}};if(r instanceof we||r instanceof nn)for(const s of["x","y"]){const a=r.resolutions.axis[s];!a||o(a,s,r)}if(r instanceof nn){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)}}}},on=new WeakSet,ri=function(n){const r=n=="column"?["left","right"]:["top","bottom"],i=n=="column"?"width":"height",o=(s,a)=>s.map(u=>{const c=V(this,$e,Mt)[u].axes[r[a]];if(c)return Math.max(c.getPerpendicularSize()+c.axisProps.offset,0);const f=V(this,$e,Mt)[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 V(this,Fo,td)[n=="column"?"colIndices":"rowIndices"].map(s=>({axisBefore:o(s,0),axisAfter:o(s,1),view:Tw(s.map(a=>V(this,$e,Mt)[a].view.getSize()[i]))}))},$r=new WeakSet,hu=function(n){const r=ue(this,on,ri).call(this,n),i=[];i.push(Zr);for(const[o,s]of r.entries())o>0&&i.push({px:V(this,Hn),grow:0}),(o==0||this.wrappingFacet)&&i.push(Zr),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(Zr);return i},ei=new WeakSet,du=function(n){var a,u,c;let r=0,i=0;const o=(a=n=="row"&&this.spec.height)!=null?a:n=="column"&&this.spec.width;if(o||o===0)return th(o);const s=ue(this,on,ri).call(this,n);for(const[f,l]of s.entries())f>0&&(i+=V(this,Hn)),(f==0||this.wrappingFacet)&&(i+=0),i+=l.axisBefore,i+=(u=l.view.px)!=null?u:0,r+=(c=l.view.grow)!=null?c:0,i+=l.axisAfter,(f==s.length-1||this.wrappingFacet)&&(i+=0);return{px:i,grow:r}},ti=new WeakSet,pu=function(n,r){return n=="row"&&this.wrappingFacet?1+6*r+2:2+4*r+1},Io=new WeakSet,rd=function(n,r,i){for(const[o,s]of Object.entries(Ov(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 zv(t){return{configurableVisibility:!1,data:{values:[{}]},mark:{fill:null,strokeWidth:1,fillOpacity:t.fill?1:0,...t,type:"rect",clip:!1,tooltip:null}}}function Ov(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 Gv(t){let e=!0;return t.visit(n=>{n instanceof we&&e&&(e=n.mark.properties.clip)}),e}class eu extends Lh{constructor(e,n,r,i){super(e,n,r,i,iu(e)?e.columns:ru(e)?1:1/0),this.spec=e}_createChildren(){const e=this.spec,n=iu(e)?e.concat:ru(e)?e.vconcat:e.hconcat;this.setChildren(n.map((r,i)=>this.context.createView(r,this,"grid"+i)))}}class Uv{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(Hv,e(Ch)),this.addViewType(nu,e(nn)),this.addViewType(tu,e(we)),this.addViewType(ru,e(eu)),this.addViewType(Qv,e(eu)),this.addViewType(iu,e(eu))}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 tu(t){return"mark"in t&&(Z(t.mark)||ke(t.mark))}function nu(t){return"layer"in t&&ke(t.layer)}function Rh(t){return t&&(tu(t)||nu(t))&&"aggregateSamples"in t}function Hv(t){return"import"in t}function ru(t){return"vconcat"in t&&Me(t.vconcat)}function Qv(t){return"hconcat"in t&&Me(t.hconcat)}function iu(t){return"concat"in t&&Me(t.concat)}const jv={point:Aw,rect:lw,rule:bw,link:Ew,text:Iw};class we extends Nn{constructor(e,n,r,i){super(e,n,r,i),this.spec=e;const o=jv[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(!Le(o))continue;let s=En((r=o.resolutionChannel)!=null?r:i);if(e=="axis"&&!Nr(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 gv(s):new yv(s)),Nr(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(zr(e))throw new Error(`getDomain(${e}), must only be called for primary channels!`);const n=this.mark.encoding[e];if(!Le(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 xh((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=xh(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=ca[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 kr.map(e).reduce((n,r)=>n*r,1)}_initializeAggregateViews(){var e,n;if(Rh(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={...(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*ou(t,e=[]){for(const[n,r]of t.entries())if(r instanceof Map)for(const i of ou(r,[...e,n]))yield i;else yield[[...e,n],r]}class su extends J{constructor(e){super(),this.params=e!=null?e:{type:"collect"},this.observers=[],this.facetBatches=void 0,this._init()}_init(){this._data=[],this.facetBatches=new Pt([],JSON.stringify),this.facetBatches.set(void 0,this._data)}reset(){super.reset(),this._init()}handle(e){this._data.push(e)}beginBatch(e){pw(e)&&(this._data=[],this.facetBatches.set(Ke(e.facetId),this._data))}complete(){var i,o;const e=(i=this.params)==null?void 0:i.sort,n=e?yu(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=>H(u)),a=di(this._data,...s);this.facetBatches.clear();for(const[u,c]of ou(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 Bo{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 Vv extends J{get behavior(){return ut}constructor(e){super(),this.params=e,this.startAccessor=H(e.start),this.endAccessor=H(e.end),this.chromAccessor=e.chrom?H(e.chrom):n=>{},this.weightAccessor=e.weight?H(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 Bo}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 w=s(A);w!==c&&(g(),f=w,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 Yv(t,e,n=0,r=t.length){const i=new Bo,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 Wv{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 Xv extends J{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=H(this.params.pos),this.posBisector=hi(this.posAccessor),this.scoreAccessor=H(this.params.score),this.widthAccessor=H(this.params.width),this.laneAccessor=this.params.lane?H(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 Wv(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=Yv(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 Zv extends J{constructor(e){super(),this.params=e,this.predicate=void 0}initialize(){this.predicate=sa(this.params.expr,this.getGlobalObject())}handle(e){this.predicate(e)&&this._propagate(e)}}const Kv="0".charCodeAt(0);function*qv(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-Kv}yield r}class Jv extends J{get behavior(){return ut}constructor(e){var s,a;super();const n=H((s=e.exons)!=null?s:"exons"),r=H((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 qv(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 _v extends J{get behavior(){return ut}constructor(e){super();const n=Ke(e.field).map(o=>H(o)),r=Ke(e.separator),i=Ke(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]));$v(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 $v(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 eC extends J{get behavior(){return Ft}constructor(e){super(),this.params=e,this.as=e.as,this.fn=void 0}initialize(){this.fn=sa(this.params.expr,this.getGlobalObject())}handle(e){e[this.as]=this.fn(e),this._propagate(e)}}class kh extends J{get behavior(){return Ft}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=H(e.chrom),s=Ke(e.pos).map(g=>H(g)),a=Ke(e.as);if(s.length!=a.length)throw new Error('The number of "pos" and "as" elements must be equal!');const u=Ke(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(`
|
|
148
148
|
`));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)}}}const Nh={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 tC extends J{get behavior(){return Ft}constructor(e){super();const n=Va(Nh),r=H(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 nC=65536;class rC extends J{get behavior(){return Ft}constructor(e){super(),this.params=e}reset(){this.initialize()}initialize(){const e=this.params,n=e.as||"lane",r=me(e.spacing)?e.spacing:1,i=H(e.start),o=H(e.end);if(!e.preference!=!e.preferredOrder)throw new Error('Must specify both "preference" and "preferredOrder"');if(e.preference){const s=new Float64Array(nC),a=H(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 Bo,a=new Bo;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 iC extends J{get behavior(){return ut}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=>H(i)),r=e.as?e.as:n.map(K);this.handle=i=>{const o={};for(let s=0;s<n.length;s++)o[r[s]]=n[s](i);this._propagate(o)}}}class oC extends J{get behavior(){return Ft}constructor(e){super();const n=new RegExp(e.regex),r=typeof e.as=="string"?[e.as]:e.as,i=H(e.field);this.handle=o=>{const s=i(o);if(Z(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 sC extends J{get behavior(){return ut}constructor(e){super();const n=Ke(e.columnRegex).map(h=>new RegExp(h)),r=Ke(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 w=(A=b.exec(y))==null?void 0:A[1];if(w!==void 0){let E=d.get(w);E||(E=[],d.set(w,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 {
|
|
149
149
|
`+g.join(`,
|
|
150
150
|
`)+`
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"contributors": [],
|
|
9
9
|
"license": "BSD-2-Clause",
|
|
10
|
-
"version": "0.28.
|
|
10
|
+
"version": "0.28.1",
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"module": "src/index.js",
|
|
13
13
|
"exports": {
|
|
@@ -52,5 +52,6 @@
|
|
|
52
52
|
"vega-loader": "^4.4.0",
|
|
53
53
|
"vega-scale": "^7.1.1",
|
|
54
54
|
"vega-util": "^1.16.0"
|
|
55
|
-
}
|
|
55
|
+
},
|
|
56
|
+
"gitHead": "afa6f0dad1d3b205e95a6335fd474cf7984021b3"
|
|
56
57
|
}
|
package/src/view/gridView.js
CHANGED
|
@@ -431,9 +431,9 @@ export default class GridView extends ContainerView {
|
|
|
431
431
|
let px = 0;
|
|
432
432
|
|
|
433
433
|
const explicitSize =
|
|
434
|
-
(direction == "row" && this.spec.height)
|
|
434
|
+
(direction == "row" && this.spec.height) ??
|
|
435
435
|
(direction == "column" && this.spec.width);
|
|
436
|
-
if (explicitSize
|
|
436
|
+
if (explicitSize || explicitSize === 0) {
|
|
437
437
|
return parseSizeDef(explicitSize);
|
|
438
438
|
}
|
|
439
439
|
|
|
@@ -507,14 +507,14 @@ export default class GridView extends ContainerView {
|
|
|
507
507
|
* @returns {FlexDimensions}
|
|
508
508
|
*/
|
|
509
509
|
getSize() {
|
|
510
|
-
return this._cache("size", () =>
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
);
|
|
510
|
+
//return this._cache("size", () =>
|
|
511
|
+
return new FlexDimensions(
|
|
512
|
+
this.#getFlexSize("column"),
|
|
513
|
+
this.#getFlexSize("row")
|
|
514
|
+
)
|
|
515
|
+
.subtractPadding(this.getOverhang())
|
|
516
|
+
.addPadding(this.getPadding());
|
|
517
|
+
//);
|
|
518
518
|
}
|
|
519
519
|
|
|
520
520
|
/**
|