wuepgg3-track 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SharedSystems-BmeHVHUW.mjs → SharedSystems-CL-lHh4v.mjs} +2 -2
- package/dist/{WebGLRenderer-Bv8fZO4Y.mjs → WebGLRenderer-CDbcbt0p.mjs} +3 -3
- package/dist/{WebGPURenderer-BNZIgzAW.mjs → WebGPURenderer-CR61aTg_.mjs} +3 -3
- package/dist/{browserAll-BOfEu7V9.mjs → browserAll-TRKWyfPN.mjs} +2 -2
- package/dist/{colorToUniform-ZnNRpEyV.mjs → colorToUniform-DluML0P6.mjs} +1 -1
- package/dist/{index-BMAzrNcu.mjs → index-7zbti24_.mjs} +14 -12
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/{init-DLL03Mmb.mjs → init-B1gvEZg8.mjs} +2 -2
- package/dist/webworkerAll-8P014rfV.mjs +2 -0
- package/package.json +1 -1
- package/dist/webworkerAll-DpDEgl_B.mjs +0 -2
package/dist/index.umd.js
CHANGED
|
@@ -1366,7 +1366,7 @@ fn mainFragment(
|
|
|
1366
1366
|
`)))}return j_.get(n)});return(await Promise.all(e)).join(`
|
|
1367
1367
|
`)}function mEr(c,e,n,h,i){const{domElement:t,styleElement:s,svgRoot:a}=i;t.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${c}</div>`,t.setAttribute("style",`transform: scale(${n});transform-origin: top left; display: inline-block`),s.textContent=h;const{width:o,height:l}=i.image;return a.setAttribute("width",o.toString()),a.setAttribute("height",l.toString()),new XMLSerializer().serializeToString(a)}function dEr(c,e){const n=Ga.getOptimalCanvasAndContext(c.width,c.height,e),{context:h}=n;return h.clearRect(0,0,c.width,c.height),h.drawImage(c,0,0),n}function uEr(c,e,n){return new Promise(async h=>{n&&await new Promise(i=>setTimeout(i,100)),c.onload=()=>{h()},c.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,c.crossOrigin="anonymous"})}class oJ{constructor(e){this._activeTextures={},this._renderer=e,this._createCanvas=e.type===xt.WEBGPU}getTexture(e){return this.getTexturePromise(e)}getManagedTexture(e){const n=e.styleKey;if(this._activeTextures[n])return this._increaseReferenceCount(n),this._activeTextures[n].promise;const h=this._buildTexturePromise(e).then(i=>(this._activeTextures[n].texture=i,i));return this._activeTextures[n]={texture:null,promise:h,usageCount:1},h}getReferenceCount(e){var n;return((n=this._activeTextures[e])==null?void 0:n.usageCount)??null}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}decreaseReferenceCount(e){const n=this._activeTextures[e];n&&(n.usageCount--,n.usageCount===0&&(n.texture?this._cleanUp(n.texture):n.promise.then(h=>{n.texture=h,this._cleanUp(n.texture)}).catch(()=>{He("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[e]=null))}getTexturePromise(e){return this._buildTexturePromise(e)}async _buildTexturePromise(e){const{text:n,style:h,resolution:i,textureStyle:t}=e,s=$n.get(_F),a=sEr(n,h),o=await lEr(a),l=FXr(n,h,o,s),m=Math.ceil(Math.ceil(Math.max(1,l.width)+h.padding*2)*i),d=Math.ceil(Math.ceil(Math.max(1,l.height)+h.padding*2)*i),u=s.image,U=2;u.width=(m|0)+U,u.height=(d|0)+U;const C=mEr(n,h,i,o,s);await uEr(u,C,iEr()&&a.length>0);const p=u;let D;this._createCanvas&&(D=dEr(u,i));const A=aJ(D?D.canvas:p,u.width-U,u.height-U,i);return t&&(A.source.style=t),this._createCanvas&&(this._renderer.texture.initSource(A.source),Ga.returnCanvasAndContext(D)),$n.return(s),A}returnTexturePromise(e){e.then(n=>{this._cleanUp(n)}).catch(()=>{He("HTMLTextSystem: Failed to clean texture")})}_cleanUp(e){Ih.returnTexture(e,!0),e.source.resource=null,e.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const e in this._activeTextures)this._activeTextures[e]&&this.returnTexturePromise(this._activeTextures[e].promise);this._activeTextures=null}}oJ.extension={type:[c0.WebGLSystem,c0.WebGPUSystem,c0.CanvasSystem],name:"htmlText"};class UEr extends Sv{}class lJ{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),this._managedTexts=new ui({renderer:e,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const e in this._managedTexts.items){const n=this._managedTexts.items[e];n!=null&&n._autoResolution&&n.onViewUpdate()}}validateRenderable(e){const n=this._getGpuText(e),h=e.styleKey;return n.currentKey!==h?!0:e._didTextUpdate}addRenderable(e,n){const h=this._getGpuText(e);if(e._didTextUpdate){const i=e._autoResolution?this._renderer.resolution:e.resolution;(h.currentKey!==e.styleKey||e.resolution!==i)&&this._updateGpuText(e),e._didTextUpdate=!1,J_(h,e)}this._renderer.renderPipes.batch.addToBatch(h,n)}updateRenderable(e){const n=this._getGpuText(e);n._batcher.updateElement(n)}_updateGpuText(e){const n=this._getGpuText(e);n.texture&&this._renderer.canvasText.decreaseReferenceCount(n.currentKey),e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,n.texture=this._renderer.canvasText.getManagedTexture(e),n.currentKey=e.styleKey}_getGpuText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){const n=new UEr;return n.currentKey="--",n.renderable=e,n.transform=e.groupTransform,n.bounds={minX:0,maxX:1,minY:0,maxY:0},n.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=n,this._managedTexts.add(e),n}onTextUnload(e){const n=e._gpuData[this._renderer.uid];if(!n)return;const{canvasText:h}=this._renderer;h.getReferenceCount(n.currentKey)>0?h.decreaseReferenceCount(n.currentKey):n.texture&&h.returnTexture(n.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}lJ.extension={type:[c0.WebGLPipes,c0.WebGPUPipes,c0.CanvasPipes],name:"text"};class mJ{constructor(e){this._activeTextures={},this._renderer=e}getTexture(e,n,h,i){typeof e=="string"&&(Ne("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:h,resolution:n}),e.style instanceof Ma||(e.style=new Ma(e.style)),e.textureStyle instanceof Gs||(e.textureStyle=new Gs(e.textureStyle)),typeof e.text!="string"&&(e.text=e.text.toString());const{text:t,style:s,textureStyle:a}=e,o=e.resolution??this._renderer.resolution,{frame:l,canvasAndContext:m}=_4.getCanvasAndContext({text:t,style:s,resolution:o}),d=aJ(m.canvas,l.width,l.height,o);if(a&&(d.source.style=a),s.trim&&(l.pad(s.padding),d.frame.copyFrom(l),d.frame.scale(1/o),d.updateUvs()),s.filters){const u=this._applyFilters(d,s.filters);return this.returnTexture(d),_4.returnCanvasAndContext(m),u}return this._renderer.texture.initSource(d._source),_4.returnCanvasAndContext(m),d}returnTexture(e){const n=e.source;n.resource=null,n.uploadMethodId="unknown",n.alphaMode="no-premultiply-alpha",Ih.returnTexture(e,!0)}renderTextToCanvas(){Ne("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;const n=e.styleKey;if(this._activeTextures[n])return this._increaseReferenceCount(n),this._activeTextures[n].texture;const h=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle});return this._activeTextures[n]={texture:h,usageCount:1},h}decreaseReferenceCount(e){const n=this._activeTextures[e];n.usageCount--,n.usageCount===0&&(this.returnTexture(n.texture),this._activeTextures[e]=null)}getReferenceCount(e){var n;return((n=this._activeTextures[e])==null?void 0:n.usageCount)??0}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}_applyFilters(e,n){const h=this._renderer.renderTarget.renderTarget,i=this._renderer.filter.generateFilteredTexture({texture:e,filters:n});return this._renderer.renderTarget.bind(h,!1),i}destroy(){this._renderer=null;for(const e in this._activeTextures)this._activeTextures[e]&&this.returnTexture(this._activeTextures[e].texture);this._activeTextures=null}}mJ.extension={type:[c0.WebGLSystem,c0.WebGPUSystem,c0.CanvasSystem],name:"canvasText"},Le.add(TGr,XGr);class Nv extends E.PureComponent{constructor(n){super(n);q(this,"myRef");q(this,"container",null);q(this,"particles");q(this,"app");q(this,"t");q(this,"centerLine",null);q(this,"count",0);q(this,"sprites",[]);q(this,"labels",[]);q(this,"steps");q(this,"handleWidthChange",()=>{this.particles.removeChildren(),this.sprites=[];const n=Xn(this.props.color||"blue");for(let h=0;h<this.props.width;h++)if(this.t){const i=new Ws(this.t);i.tint=n,this.sprites.push(i),this.particles.addChild(i)}});q(this,"onWindowResize",()=>{const{height:n,width:h}=this.props;this.app&&this.app.renderer.resize(h,n)});q(this,"onPointerDown",n=>{n.button===1&&this.setState(h=>({isPlaying:!h.isPlaying}),()=>{this.state.isPlaying?this.app.ticker.start():this.app.ticker.stop()})});q(this,"tick",()=>{this.count+=.005*(this.props.speed?this.props.speed[0]:1),this.count>=this.steps-1&&(this.count=0);const n=Math.round(this.count),h=n===0?this.steps-1:n-1;this.setState({currentStep:n,prevStep:h})});q(this,"getMaxSteps",()=>this.props.steps?this.props.steps:Qr.max(this.props.xToValue.map(h=>h.length))||0);q(this,"draw",()=>{const{scales:n,width:h,useDynamicColors:i,dynamicColors:t}=this.props,{currentStep:s}=this.state;this.sprites.forEach(o=>o.scale.set(0));const a=n.valueToY(0);n.min<0?this.centerLine&&(this.centerLine.position.set(0,a),this.centerLine.tint=0,this.centerLine.scale.set(h,.5),this.centerLine.visible=!0):this.centerLine&&(this.centerLine.visible=!1),this.props.xToValue.forEach((o,l)=>{const m=s<o.length?s:s%o.length;if(Number.isNaN(o[m]))return;const d=n.valueToY(o[m])-a,u=this.sprites[l];if(u&&(u.position.set(l,a),u.scale.set(1,d),i&&t&&t.length)){const U=Xn(t[s%t.length]);u.tint=U}})});this.myRef=E.createRef(),this.state={currentStep:0,isPlaying:!0,prevStep:0},this.steps=this.getMaxSteps(),this.particles=new rh}async componentDidMount(){this.container=this.myRef.current;const{height:n,width:h,backgroundColor:i}=this.props,t=Xn(i||"0x000000");this.app=new s4,await this.app.init({width:h,height:n,backgroundColor:t,autoDensity:!0,resolution:window.devicePixelRatio}),this.container&&this.container.appendChild(this.app.view),this.app.ticker.add(this.tick),this.app.stage.interactive=!0,this.app.stage.on("pointerdown",this.onPointerDown);const s=new B3;s.lineStyle(0),s.beginFill(16777215,1),s.drawRect(0,0,1,1),s.endFill();const a=Xn(this.props.color||"blue");this.t=this.app.renderer.generateTexture(s);for(let o=0;o<h;o++){const l=new Ws(this.t);l.tint=a,this.sprites.push(l),this.particles.addChild(l)}this.app.stage.addChild(this.particles),window.addEventListener("resize",this.onWindowResize)}componentWillUnmount(){this.app.ticker.remove(this.tick),window.removeEventListener("resize",this.onWindowResize),this.app.stage.off("pointerdown",this.onPointerDown)}componentDidUpdate(n,h){const{currentStep:i,prevStep:t}=this.state;if((n.height!==this.props.height||n.width!==this.props.width)&&(this.onWindowResize(),n.width!==this.props.width&&this.handleWidthChange()),(n.xToValue!==this.props.xToValue||h.currentStep!==i)&&(this.steps=this.getMaxSteps(),this.draw()),n.color!==this.props.color){const s=Xn(this.props.color||"blue");this.sprites.forEach(a=>a.tint=s)}n.backgroundColor!==this.props.backgroundColor&&(this.app.renderer.background=Xn(this.props.backgroundColor||"0x000000")),n.playing!==this.props.playing&&(this.props.playing?this.app.ticker.start():this.app.ticker.stop()),n.viewWindow!==this.props.viewWindow&&this.labels.length&&this.labels.forEach(s=>{var a;return s.position.set((((a=this.props.viewWindow)==null?void 0:a.start)??0)+5,5)}),n.dynamicLabels!==this.props.dynamicLabels&&this.labels.length&&this.labels.forEach((s,a)=>{var o;return s.text=((o=this.props.dynamicLabels)==null?void 0:o[a])||""})}render(){const{height:n,width:h}=this.props,i={width:`${h}px`,height:`${n}px`};return _.jsx("div",{style:i,ref:this.myRef})}}q(Nv,"propTypes",{xToValue:Gr.array.isRequired,scales:Gr.object.isRequired,height:Gr.number.isRequired,width:Gr.number.isRequired,backgroundColor:Gr.string,color:Gr.string,speed:Gr.array,steps:Gr.number,currentStep:Gr.number}),q(Nv,"defaultProps",{currentStep:0,speed:[5],color:"blue",backgroundColor:"var(--bg-color)",dynamicColors:[],useDynamicColors:!1});const dJ={aggregateMethod:Nt.types.MEAN,height:80,yScale:Nc.AUTO,yMax:10,yMin:0,smooth:0,color:"blue",backgroundColor:"var(--bg-color)",playing:!0,speed:[10],dynamicColors:[],useDynamicColors:!1,dynamicLabels:[]},zEr=2;class uJ extends E.PureComponent{constructor(n){super(n);q(this,"xToValue");q(this,"scales");this.xToValue=null,this.scales=null,this.aggregateFeatures=Mt(this.aggregateFeatures),this.computeScales=Mt(this.computeScales)}aggregateFeatures(n,h,i,t){return new w5().xToValueMaker(n,h,i,this.props.options)[0]}computeScales(n,h){const{yScale:i,yMin:t,yMax:s}=this.props.options;t>s&&console.log("Y-axis min must be less than max","error",2e3);const a=Qr.flatten(n.map(m=>m.slice(this.props.viewWindow.start,this.props.viewWindow.end)));let o=Qr.max(a)||0,l=Qr.min(a)||0;return i===Nc.FIXED&&(o=s||o,l=t||l),l>o&&(l=o),{valueToY:ge().domain([o,l]).range([zEr,h]).clamp(!0),min:l,max:o}}render(){const{data:n,viewRegion:h,width:i,trackModel:t,unit:s,options:a,viewWindow:o,updatedLegend:l}=this.props,{height:m,aggregateMethod:d,smooth:u,color:U,backgroundColor:C,playing:p,speed:D,steps:A,dynamicLabels:f,dynamicColors:M,useDynamicColors:S}=a,N=n.map(W=>this.aggregateFeatures(W,h,i,d));this.xToValue=u===0?N:N.map(W=>yz(W,u)),this.scales=this.computeScales(this.xToValue,m);const x=Qr.zip(...this.xToValue);return l&&(l.current=_.jsx(Uh,{trackModel:t,height:m,axisScale:this.scales.valueToY,axisLegend:s})),_.jsxs(E.Fragment,{children:[_.jsx("div",{style:{display:"flex",flexDirection:"row",position:"absolute",zIndex:3},children:_.jsx(xh,{data:this.xToValue,windowWidth:i,trackType:"dynamic",trackModel:t,height:m,viewRegion:h,unit:s,hasReverse:!0,options:a})}),_.jsx(Nv,{xToValue:x,scales:this.scales,width:i,height:m,steps:A,color:U,backgroundColor:C,playing:p,speed:D,dynamicLabels:f,viewWindow:o,dynamicColors:M,useDynamicColors:S})]})}}q(uJ,"propTypes",{data:Gr.array.isRequired,unit:Gr.string,options:Gr.object.isRequired,isLoading:Gr.bool,error:Gr.any});const vEr={aggregateMethod:Nt.types.MEAN,height:60,yScale:Nc.AUTO,yMax:10,yMin:0,smooth:0,lineWidth:2},CEr=2;class UJ extends E.PureComponent{constructor(n){super(n);q(this,"xToValue");q(this,"scales");q(this,"aggregator");this.xToValue=null,this.scales=null,this.aggregator=new w5,this.computeScales=Mt(this.computeScales)}computeScales(n,h){const{yScale:i,yMin:t,yMax:s}=this.props.options,a=Qr.flatten(n.map(m=>m.slice(this.props.viewWindow.start,this.props.viewWindow.end)));let o=Qr.max(a)||0,l=Qr.min(a)||0;return i===Nc.FIXED&&(o=s||o,l=t||l),l>o&&(l=o),{valueToY:ge().domain([o,l]).range([CEr,h]).clamp(!0),min:l,max:o}}render(){const{data:n,viewRegion:h,width:i,trackModel:t,unit:s,options:a,forceSvg:o,updatedLegend:l,viewWindow:m,xvaluesData:d}=this.props,{height:u,smooth:U,lineWidth:C}=a;this.xToValue=d||(U===0?n.map(M=>this.aggregator.xToValueMaker(M,h,i,a)[0]):yz(n.map(M=>this.aggregator.xToValueMaker(M,h,i,a)[0]),U)),this.scales=this.computeScales(this.xToValue,u);const p=_.jsx("div",{style:{display:"flex"},children:_.jsx(Uh,{trackModel:t,height:u,axisScale:this.scales.valueToY,axisLegend:s,forceSvg:o})});l&&(l.current=p);let D=o?{position:"relative",overflow:"hidden",width:i/3}:{},A=o?{position:"relative",transform:`translateX(${-m.start}px)`}:{};return _.jsxs(E.Fragment,{children:[o?"":_.jsx("div",{style:{display:"flex",flexDirection:"row",position:"absolute",zIndex:3},children:_.jsx(xh,{data:this.xToValue,scale:this.scales,windowWidth:i,trackType:"matplot",trackModel:t,height:u,viewRegion:h,unit:s||"",hasReverse:!0,options:a})}),_.jsxs("div",{style:{display:"flex",...D},children:[o||a.packageVersion?p:"",_.jsx("div",{style:{...A},children:_.jsx(zJ,{trackModel:t,xToValue:this.xToValue,scales:this.scales,height:u,forceSvg:o,lineWidth:C,width:i,viewWindow:m})})]})]})}}q(UJ,"propTypes",Object.assign({},{data:Gr.array.isRequired,unit:Gr.string,options:Gr.shape({aggregateMethod:Gr.oneOf(Object.values(Nt.types)),height:Gr.number.isRequired}).isRequired,isLoading:Gr.bool,error:Gr.any}));class zJ extends E.PureComponent{constructor(e){super(e),this.renderLine=this.renderLine.bind(this)}renderLine(e,n){const{scales:h,trackModel:i,lineWidth:t}=this.props,s=e.map((o,l)=>{if(o&&!Number.isNaN(o)){const m=h.valueToY(o);return`${l},${m}`}}).filter(o=>o),a=i.tracks&&i.tracks[n]&&i.tracks[n].options&&i.tracks[n].options.color||"blue";return _.jsx("polyline",{points:s.join(" "),stroke:a,strokeWidth:t,fill:"none"},n)}render(){const{xToValue:e,height:n,width:h,forceSvg:i,viewWindow:t}=this.props;return e.length===0?_.jsx("div",{style:{width:h,height:n}}):_.jsx(Gt,{type:yn.SVG,width:h,height:n,forceSvg:i,viewWindow:t,style:{},children:e.map(this.renderLine)})}}q(zJ,"propTypes",{xToValue:Gr.array.isRequired,scales:Gr.object.isRequired,height:Gr.number.isRequired,lineWidth:Gr.number.isRequired,width:Gr.number.isRequired,trackModel:Gr.any.isRequired,forceSvg:Gr.bool});class pEr extends vc{constructor(n){const h=new J0(n.chr,n.start,n.end),i=n.rest.split(" ");super(i[0],h,i[2]);q(this,"repClass");q(this,"repFamily");q(this,"milliDiv");q(this,"_cachedValue");q(this,"rgb");this.repClass=i[7],this.repFamily=i[8],this.milliDiv=i[9],this.rgb=i[5],this._cachedValue=null}get repeatValue(){if(this._cachedValue===null){const n=Number.parseFloat(this.milliDiv)/100;this._cachedValue=1-n}return this._cachedValue}getClassDetails(){return this.repClass}}var Z4=(c=>(c.NONE="NONE",c.ASC="ASC",c.DESC="DESC",c.NOSORT="NOSORT",c))(Z4||{});const DEr=new ps;class vJ{_assignRows(e,n,h){const i=[],t=typeof n=="number";for(const s of e){const a=t?n:n(s.feature,s.xSpan),o=s.xSpan.start-a,l=s.xSpan.end+a;let m=i.findIndex(d=>d<o);m===-1?(i.push(l),m=i.length-1):i[m]=l,s.row=m}return i.length}arrange(e,n,h,i=0,t=.5,s=Z4.NONE,a){const o=DEr.placeFeatures({features:e,viewRegion:n,width:h,mode:po.ANNOTATION,viewWindow:a,hiddenPixels:t}),l=this._assignRows(o.placementsForward,i,s);return{placements:o.placementsForward,numRowsAssigned:l,numHidden:o.numHidden}}}const f4=9;class Wv extends E.Component{render(){const{feature:e,xSpan:n,y:h,color:i,isMinimal:t,onClick:s,height:a,category:o,alwaysDrawLabel:l}=this.props,m=At(i),[d,u]=n,U=u-d,C=l?Math.max(2,U):U;if(C<=0)return null;const p=_.jsx("rect",{x:d,y:0,width:C,height:a,fill:i});if(t)return _.jsx(An,{y:h,onClick:f=>s(f,e),children:p});let D;const A=o&&o[e.getName()]?o[e.getName()].name:e.getName();if(A){const f=A.length*f4,M=d+.5*C,S=(a-f4+1)*.5;f<.9*C?D=_.jsx(hi,{x:M,y:S,height:f4-1,fill:m,dominantBaseline:"hanging",textAnchor:"middle",backgroundColor:i,backgroundOpacity:1,children:A}):l&&(D=_.jsx(hi,{x:u+4,y:S,height:f4-1,fill:i,dominantBaseline:"hanging",textAnchor:"start",children:e.getName()}))}return _.jsxs(An,{y:h,onClick:f=>s(f,e),children:[p,D]})}}q(Wv,"TEXT_HEIGHT",f4),q(Wv,"propTypes",{feature:Gr.instanceOf(vc).isRequired,xSpan:Gr.instanceOf(Y0).isRequired,y:Gr.number,color:Gr.string,isMinimal:Gr.bool,onClick:Gr.func}),q(Wv,"defaultProps",{color:"blue",onClick:(e,n)=>{}});const bEr={SINE:1,LINE:2,LTR:3,DNA:4,RC:4,Simple_repeat:5,Satellite:6,Low_complexity:7,RNA:8,rRNA:8,scRNA:8,snRNA:8,srpRNA:8,tRNA:8,ncRNA:8,Other:9,Unknown:10,Retroposon:11,Retrotransposon:11,ARTEFACT:12},gEr={1:"SINE - short interspersed nuclear elements",2:"LINE - long interspersed nuclear element",3:"LTR - long terminal repeat element",4:"DNA transposon",5:"Simple repeat, micro-satellite",6:"Satellite repeat",7:"Low complexity repeat",8:"RNA repeat",9:"Other repeats",10:"Unknown",11:"Retroposon",12:"ARTEFACT"},_Er={1:"#CC0000",2:"#FF6600",3:"#006600",4:"#4A72E8",5:"#AB833B",6:"#660000",7:"#663333",8:"#CC33FF",9:"#488E8E",10:"#5C5C5C",11:"#EA53C4",12:"#00FFAA"};class Tv extends vc{constructor(n){const h=new J0(n.segment,n.min,n.max);super(n.label,h,n.orientation,n.score);q(this,"repClass");q(this,"repFamily");q(this,"milliDiv");q(this,"_value");this.repClass=n.repClass,this.repFamily=n.repFamily,this.milliDiv=n.milliDiv,this._value=null}get repeatValue(){if(this._value===null){const n=Number.parseInt(this.milliDiv,10)/1e3;this._value=1-n}return this._value}getCategoryId(){return bEr[this.repClass]}getClassDetails(){return gEr[this.getCategoryId()]||"???"}}q(Tv,"DEFAULT_CLASS_COLORS",_Er);const AEr=2.5;class yEr extends E.Component{render(){const{placement:e,y:n,color:h,color2:i,isMinimal:t,hiddenPixels:s,rowHeight:a,renderTooltip:o,onHideTooltip:l,displayMode:m,hideMinimalItems:d,pixelsPadding:u}=this.props,{feature:U,xSpan:C,visiblePart:p}=e,{relativeStart:D,relativeEnd:A}=p,f=A-D,[M,S]=C,N=S-M;if(N<s)return null;if(t)return d?null:_.jsx(An,{y:n,onMouseEnter:B=>o(B,U,0),onMouseOut:l,children:_.jsx("rect",{x:M,y:0,width:N,height:a,fill:h,opacity:.2})});const x=1/f*N;if(x<AEr){const B=m===za.AUTO?_.jsx("rect",{x:M,y:a,width:N,height:1,fill:"gray",opacity:.5}):null,W=Math.round(N),T=Array(W).fill(null);for(let dr=0;dr<W;dr++)T[dr]={on:0,off:0};U.ons.forEach(dr=>{const zr=Math.abs(dr);if(zr>=D&&zr<A){const tr=Math.floor((zr-D)/f*N);tr<W&&(T[tr].on+=1)}}),U.offs.forEach(dr=>{const zr=Math.abs(dr);if(zr>=D&&zr<A){const tr=Math.floor((zr-D)/f*N);tr<W&&(T[tr].off+=1)}});const L=T.map(dr=>dr.on+dr.off),I=Qr.max(L),J=T.map((dr,zr)=>dr.on/L[zr]),$=[],sr=Math.max(x,1),vr=ge().domain([0,1]).range([0,a]).clamp(!0),pr=ge().range([.2,.9]).domain([0,I]).clamp(!0);return T.forEach((dr,zr)=>{if(dr.on||dr.off)if(m===za.AUTO){$.push(_.jsx("rect",{x:M+zr,y:0,height:a,width:sr+(u||0),fill:"lightgray",opacity:pr(L[zr])},zr+"bgbar"));const tr=vr(J[zr]);$.push(_.jsx("rect",{x:M+zr,y:a-tr,height:tr,width:sr+(u||0),fill:h,opacity:.7,onMouseEnter:er=>o(er,U,void 0,"bar",dr.on,J[zr],L[zr]),onMouseOut:l},zr+"fgbar"))}else{const tr=J[zr]>=.5?h:i;$.push(_.jsx("rect",{x:M+zr,y:0,height:a,width:sr+(u||0),fill:tr,opacity:1,onMouseEnter:er=>o(er,U,void 0,"bar",dr.on,J[zr],L[zr]),onMouseOut:l},zr+"fgrect"))}}),_.jsxs(An,{y:n,children:[B,$]})}else{const B=_.jsx("rect",{x:M,y:a*.5,width:N,height:1,fill:"gray",opacity:.5}),W=U.strand!=="."&&_.jsx(Cs,{startX:M,endX:S,y:a*.25,height:a*.5,opacity:.75,isToRight:U.strand!=="-",color:"grey",separation:100}),T=[];return U.ons.forEach((L,I)=>{const J=Math.abs(L);if(J>=D&&J<A){const $=L>0?h:i;if(m===za.AUTO){const sr=Math.min(Math.max(x*.5,2),a*.5),vr=M+(J-D+.5)/f*N,pr=L>0?.4*a:.6*a;T.push(_.jsx("circle",{cx:vr,cy:pr,r:sr,fill:$,stroke:$,strokeWidth:2,opacity:.7,onMouseEnter:dr=>o(dr,U,J,"norm"),onMouseOut:l},I+"fg"))}else{const sr=Math.max(1,x),vr=M+(J-D)/f*N,pr=L>0?0:.5*a;T.push(_.jsx("rect",{x:vr,y:pr,height:a*.5,width:sr,fill:$,strokeWidth:0,opacity:.6,onMouseEnter:dr=>o(dr,U,J,"norm"),onMouseOut:l},I+"fg"))}}}),U.offs.forEach((L,I)=>{const J=Math.abs(L);if(J>=D&&J<A)if(m===za.AUTO){const $=L>0?h:i,sr=Math.min(Math.max(x*.5,2),a*.5),vr=M+(J-D+.5)/f*N,pr=L>0?.4*a:.6*a;T.push(_.jsx("circle",{cx:vr,cy:pr,r:sr,fill:$,stroke:$,strokeWidth:2,fillOpacity:0,opacity:.7,onMouseEnter:dr=>o(dr,U,J,"norm"),onMouseOut:l},I+"bg"))}else{const $=Math.max(1,x),sr=M+(J-D)/f*N,vr=L>0?0:.5*a;T.push(_.jsx("rect",{x:sr,y:vr,height:a*.5,width:$,fill:"lightgrey",strokeWidth:0,opacity:.5,onMouseEnter:pr=>o(pr,U,J,"norm"),onMouseOut:l},I+"bg"))}}),_.jsxs(An,{y:n,children:[B,W,T]})}}}const CJ=Math.PI/4,pJ=Math.sin(CJ);class H_ extends E.PureComponent{constructor(n){super(n);q(this,"myRef");q(this,"container",null);q(this,"app");q(this,"subcontainer");q(this,"count",0);q(this,"steps");q(this,"subs",[]);q(this,"hmData",[]);q(this,"getMaxSteps",()=>this.props.steps||this.props.placedInteractionsArray.length);q(this,"onPointerDown",async n=>{var h;n.button===1&&((h=this.app)!=null&&h.ticker)&&this.setState(i=>({isPlaying:!i.isPlaying}),()=>{var i;(i=this.app)!=null&&i.ticker&&(this.state.isPlaying?this.app.ticker.start():this.app.ticker.stop())})});q(this,"onWindowResize",()=>{var i,t;const{height:n,width:h}=this.props;(t=(i=this.app)==null?void 0:i.renderer)==null||t.resize(h,n)});q(this,"tick",()=>{this.count+=.005*(this.props.speed?this.props.speed[0]:1),this.count>=this.steps-1&&(this.count=0),this.setState({currentStep:Math.round(this.count)})});q(this,"initializeSubs",()=>{if(this.subcontainer){this.subs=[],this.steps=this.getMaxSteps();for(let n=0;n<this.steps;n++)this.subs.push(new rh),this.hmData.push([]);this.subs.forEach(n=>this.subcontainer.addChild(n))}});q(this,"resetSubs",()=>{this.subs.forEach(n=>n.removeChildren()),this.hmData=this.hmData.map(()=>[])});q(this,"drawHeatmap",()=>{if(!this.app||!this.app.renderer||!this.subcontainer)return;const{opacityScale:n,color:h,color2:i,viewWindow:t,height:s,placedInteractionsArray:a,trackModel:o,useDynamicColors:l,dynamicColors:m}=this.props;if(this.subs.length)this.resetSubs();else if(this.initializeSubs(),!this.subs.length)return;const d=new Ma({fontFamily:"Arial",fontSize:16}),u=new B3;u.lineStyle(0),u.beginFill(16777215,1),u.drawRect(0,0,1,1),u.endFill();const U=this.app.renderer.generateTexture(u);let C;a.forEach((p,D)=>{var f;if(l&&m.length){const M=D<m.length?D:D%m.length;C=m[M]}else C=h;p.forEach(M=>{const S=M.interaction.score;if(!S)return null;const{xSpan1:N,xSpan2:x}=M;if(N.end<t.start&&x.start>t.end)return null;const B=(N.end+x.start)/2,W=x.start-N.end,T=B,L=.5*W,I=Math.max(.5*N.getLength(),1),J=Math.max(.5*x.getLength(),1),$=!(l&&m.length)&&S<0?i:C,sr=Xn($),vr=L+I+J,pr=[[T,L],[T-I,L+I],[T-I+J,vr],[T+J,L+J]],dr=new Ws(U);dr.tint=sr,dr.position.set(T,L),dr.scale.set(pJ*x.getLength(),pJ*N.getLength()),dr.pivot.set(0),dr.rotation=CJ,dr.alpha=n(S),this.subs[D].addChild(dr),T+J>t.start&&T-I<t.end&&L<s&&this.hmData[D].push({points:pr,interaction:M.interaction})});const A=((f=o==null?void 0:o.tracks[D])==null?void 0:f.label)||"";if(A){const M=new Av({text:A,style:d});M.position.set(t.start+5,s-21),this.subs[D].addChild(M)}})});this.myRef=E.createRef(),this.state={currentStep:0,isPlaying:!0},this.steps=this.getMaxSteps(),this.subcontainer=new rh}async componentDidMount(){this.container=this.myRef.current;const{height:n,width:h,backgroundColor:i}=this.props,t=Xn("var(--bg-color)");this.app=new s4,await this.app.init({width:h,height:n,backgroundColor:t,autoDensity:!0,resolution:window.devicePixelRatio}),this.container&&this.container.appendChild(this.app.view),this.app.ticker.add(this.tick),this.app.stage.interactive=!0,this.app.stage.on("pointerdown",this.onPointerDown),this.app.stage.addChild(this.subcontainer),window.addEventListener("resize",this.onWindowResize),this.steps=this.getMaxSteps(),this.drawHeatmap()}componentWillUnmount(){var n,h;this.app&&((n=this.app.ticker)==null||n.remove(this.tick),(h=this.app.stage)==null||h.off("pointerdown",this.onPointerDown),window.removeEventListener("resize",this.onWindowResize))}componentDidUpdate(n,h){if(this.app){if(n.placedInteractionsArray!==this.props.placedInteractionsArray&&this.drawHeatmap(),n.color!==this.props.color&&!(this.props.useDynamicColors&&this.props.dynamicColors.length)){const i=Xn(this.props.color||"blue");this.subs.forEach(t=>t.children.forEach(s=>s.tint=i))}if(n.useDynamicColors!==this.props.useDynamicColors&&!this.props.useDynamicColors){const i=Xn(this.props.color||"green");this.subs.forEach(t=>t.children.forEach(s=>s.tint=i))}n.backgroundColor!==this.props.backgroundColor&&this.app.renderer&&(this.app.renderer.background=Xn(this.props.backgroundColor||"0x000000")),(n.height!==this.props.height||n.width!==this.props.width)&&this.app.renderer&&this.app.renderer.resize(this.props.width,this.props.height),n.playing!==this.props.playing&&this.app.ticker&&(this.props.playing?(this.setState({isPlaying:!0}),this.app.ticker.start()):(this.setState({isPlaying:!1}),this.app.ticker.stop())),h.currentStep!==this.state.currentStep&&(this.subs.forEach((i,t)=>{i.visible=t===this.state.currentStep}),this.props.viewer3dNumFrames&&this.props.viewer3dNumFrames.viewer3d&&this.props.viewer3dNumFrames.numFrames!==0&&this.props.viewer3dNumFrames.viewer3d.setFrame(this.state.currentStep%this.props.viewer3dNumFrames.numFrames).then(()=>this.props.viewer3dNumFrames.viewer3d.render()))}}render(){const{height:n,width:h}=this.props;return _.jsxs(E.Fragment,{children:[_.jsx("div",{style:{display:"flex",flexDirection:"row",position:"absolute",zIndex:3},children:_.jsx(xh,{data:this.hmData,windowWidth:h,viewWindow:this.props.viewWindow,trackType:"dynamichic",height:n})}),_.jsx("div",{ref:this.myRef}),";"]})}}q(H_,"propTypes",{placedInteractionsArray:Gr.array.isRequired,viewWindow:Gr.object.isRequired,opacityScale:Gr.func.isRequired,height:Gr.number.isRequired,width:Gr.number.isRequired,backgroundColor:Gr.string,color:Gr.string,color2:Gr.string,speed:Gr.array,steps:Gr.number,currentStep:Gr.number}),q(H_,"defaultProps",{currentStep:0,speed:[5],color:"blue",backgroundColor:"var(--bg-color)",dynamicColors:[],useDynamicColors:!1});const BEr=1e3;class DJ extends E.PureComponent{constructor(n){super(n);q(this,"myRef");q(this,"container",null);q(this,"subcontainer");q(this,"app");q(this,"count",0);q(this,"steps");q(this,"subs",[]);q(this,"arcData",[]);q(this,"onPointerDown",n=>{n.button===1&&this.setState(h=>({isPlaying:!h.isPlaying}),()=>{this.state.isPlaying?this.app.ticker.start():this.app.ticker.stop()})});q(this,"onWindowResize",()=>{const{height:n,width:h}=this.props;this.app&&this.app.renderer.resize(h,n)});q(this,"tick",()=>{this.count+=.005*(this.props.speed?this.props.speed[0]:1),this.count>=this.steps-1&&(this.count=0);const n=Math.round(this.count);this.setState({currentStep:n})});q(this,"getMaxSteps",()=>this.props.steps?this.props.steps:this.props.placedInteractionsArray.length);q(this,"initializeSubs",()=>{this.subs=[],this.steps=this.getMaxSteps();for(let n=0;n<this.steps;n++)this.subs.push(new B3),this.arcData.push([]);this.subs.forEach(n=>this.subcontainer.addChild(n))});q(this,"resetSubs",()=>{this.subs.forEach(n=>{n.clear(),n.removeChildren()}),this.arcData=this.arcData.map(()=>[])});q(this,"drawArc",()=>{const{opacityScale:n,color:h,color2:i,viewWindow:t,height:s,placedInteractionsArray:a,trackModel:o,lineWidth:l,useDynamicColors:m,dynamicColors:d}=this.props;this.subs.length?this.resetSubs():this.initializeSubs();const u=new Ma({fontFamily:"Arial",fontSize:16});let U;a.forEach((C,p)=>{const A=C.slice().sort((M,S)=>S.interaction.score-M.interaction.score).slice(0,BEr);if(m&&d&&d.length){const M=p<d.length?p:p%d.length;U=d[M]}else U=h;if(A.forEach(M=>{const S=M.interaction.score;if(!S)return;const{xSpan1:N,xSpan2:x}=M;let B,W;N.start===x.start&&N.end===x.end?(B=N.start,W=N.end):(B=.5*(N.start+N.end),W=.5*(x.start+x.end));const T=.5*(B+W),L=W-B,I=.5*L;if(L<1)return;const J=Math.max(0,Math.SQRT2*I-l*.5),$=!(m&&d&&d.length)&&S<0?i:U,sr=Xn($),vr=this.subs[p];vr.moveTo(W,0),vr.lineStyle(l,sr,n(S)),vr.arc(T,-I,J,Math.SQRT1_2,Math.PI-Math.SQRT1_2),this.arcData[p].push([T,-I,J,l,M.interaction])}),o.tracks[p].label?o.tracks[p].label:""){const M=new Av(o.tracks[p].label,u);M.position.set(t.start+5,s-21),this.subs[p].addChild(M)}})});this.myRef=E.createRef(),this.state={currentStep:0,isPlaying:!0},this.steps=this.getMaxSteps(),this.subcontainer=new rh}async componentDidMount(){this.container=this.myRef.current;const{height:n,width:h,backgroundColor:i}=this.props,t=Xn(i||"0x000000");this.app=new s4,await this.app.init({width:h,height:n,backgroundColor:t,autoDensity:!0,resolution:window.devicePixelRatio}),this.container&&this.container.appendChild(this.app.view),this.app.ticker.add(this.tick),this.app.stage.interactive=!0,this.app.stage.on("pointerdown",this.onPointerDown),this.app.stage.addChild(this.subcontainer),this.steps=this.getMaxSteps(),this.drawArc(),window.addEventListener("resize",this.onWindowResize)}componentWillUnmount(){this.app.ticker.remove(this.tick),window.removeEventListener("resize",this.onWindowResize),this.app.stage.off("pointerdown",this.onPointerDown)}componentDidUpdate(n,h){if(n.placedInteractionsArray!==this.props.placedInteractionsArray&&this.drawArc(),n.color!==this.props.color&&!(this.props.useDynamicColors&&this.props.dynamicColors&&this.props.dynamicColors.length)){const i=Xn(this.props.color||"0x000000");this.subs.forEach(t=>t.children.forEach(s=>s.tint=i))}if(n.useDynamicColors!==this.props.useDynamicColors&&!this.props.useDynamicColors){const i=Xn(this.props.color||"0x000000");this.subs.forEach(t=>t.children.forEach(s=>s.tint=i))}n.backgroundColor!==this.props.backgroundColor&&(this.app.renderer.backgroundColor=Xn(this.props.backgroundColor||"0x000000")),(n.height!==this.props.height||n.width!==this.props.width)&&this.app.renderer.resize(this.props.width,this.props.height),n.playing!==this.props.playing&&(this.props.playing?this.app.ticker.start():this.app.ticker.stop()),h.currentStep!==this.state.currentStep&&this.subs.forEach((i,t)=>{i.visible=t===this.state.currentStep})}render(){const{height:n,width:h}=this.props,i={width:`${h}px`,height:`${n}px`};return _.jsx("div",{style:i,ref:this.myRef})}}q(DJ,"defaultProps",{currentStep:0,speed:[5],color:"blue",backgroundColor:"var(--bg-color)",lineWidth:1,dynamicColors:[],useDynamicColors:!1});const bJ={color:"#B8008A",color2:"#006385",backgroundColor:"var(--bg-color)",scoreScale:Nc.AUTO,scoreMax:10,scoreMin:0,height:500,playing:!0,speed:[5],lineWidth:1,useDynamicColors:!1,dynamicColors:[],displayMode:Yo.HEATMAP};class ZEr extends E.PureComponent{constructor(n){super(n);q(this,"featurePlacer");q(this,"scales");q(this,"computeScale",()=>{const{scoreScale:n,scoreMin:h,scoreMax:i}=this.props.options,t=this.props.data.map(a=>{const o=Qr.maxBy(a,"score");return o?o.score:1}),s=Qr.max(t);return n===Nc.AUTO?{opacityScale:ge().domain([0,s]).range([0,1]).clamp(!0),min:0,max:s}:h!==void 0&&i!==void 0&&h>=i?(console.error("Score min cannot be greater than Score max"),{opacityScale:ge().domain([i-1,i]).range([0,1]).clamp(!0),min:i-1,max:i}):{opacityScale:ge().domain([h,i]).range([0,1]).clamp(!0),min:h,max:i}});this.scales=null,this.featurePlacer=new ps}showTooltip(n,h){h.locus1.toString(),h.locus2.toString(),h.score}render(){const{data:n,trackModel:h,visRegion:i,width:t,viewWindow:s,options:a,viewer3dNumFrames:o,updatedLegend:l}=this.props;this.scales=this.computeScale();const m={placedInteractionsArray:n.map(u=>this.featurePlacer.placeInteractions(u,i,t)),viewWindow:s,width:t,height:a.height,opacityScale:this.scales.opacityScale,color:a.color,color2:a.color2,backgroundColor:a.backgroundColor,binSize:a.binSize,playing:a.playing,speed:a.speed,trackModel:h,lineWidth:a.lineWidth,dynamicColors:a.dynamicColors,useDynamicColors:a.useDynamicColors,viewer3dNumFrames:o};let d;return l&&(l.current=_.jsx(Uh,{trackModel:h,height:a.height})),a.displayMode===Yo.ARC?d=_.jsx(DJ,{...m}):d=_.jsx(H_,{...m}),d}}const gJ=2,fEr=2;class K_ extends E.PureComponent{constructor(n){super(n);q(this,"myRef");q(this,"container",null);q(this,"subcontainer",null);q(this,"app",null);q(this,"count",0);q(this,"subs",[]);q(this,"steps",0);q(this,"onPointerDown",n=>{var h;n.button===1&&((h=this.app)!=null&&h.ticker)&&this.setState(i=>({isPlaying:!i.isPlaying}),()=>{var i;(i=this.app)!=null&&i.ticker&&(this.state.isPlaying?this.app.ticker.start():this.app.ticker.stop())})});q(this,"initializeSubs",()=>{if(this.subcontainer){this.subs=[],this.steps=this.getMaxSteps();for(let n=0;n<this.steps;n++)this.subs.push(new rh);this.subs.forEach(n=>this.subcontainer.addChild(n))}});q(this,"resetSubs",()=>{this.subs.forEach(n=>n.removeChildren())});q(this,"onWindowResize",()=>{var i;const{height:n,width:h}=this.props;(i=this.app)==null||i.renderer.resize(h,n)});q(this,"tick",()=>{this.count+=.005*this.props.speed[0],this.count>=this.steps-1&&(this.count=0),this.setState({currentStep:Math.round(this.count)})});q(this,"getMaxSteps",()=>{const{steps:n,arrangeResults:h}=this.props;return n||h.length});q(this,"drawAnnotations",()=>{if(!this.app||!this.subcontainer)return;const{color:n,color2:h,viewWindow:i,height:t,arrangeResults:s,trackModel:a,rowHeight:o,useDynamicColors:l,dynamicColors:m}=this.props;if(this.subs.length)this.resetSubs();else if(this.initializeSubs(),!this.subs.length)return;const d={fontFamily:"Arial",fontSize:16},u={fontFamily:"Arial",fontSize:o},U=new B3;U.lineStyle(0),U.beginFill(16777215,1),U.drawRect(0,0,1,1),U.endFill();let C;const p=this.app.renderer.generateTexture(U);s.forEach((D,A)=>{if(l&&(m!=null&&m.length)){const M=A<m.length?A:A%m.length;C=m[M]}else C=n;D.placements.forEach(M=>{const{xSpan:S,row:N,feature:x}=M,B=!(l&&(m!=null&&m.length))&&x.getIsReverseStrand()?h:C,W=Xn(B),T=Math.max(2,S.end-S.start),L=new Ws(p);L.tint=W;const I=N*(o+fEr)+gJ;L.position.set(S.start,I),L.scale.set(T,o),this.subs[A].addChild(L);const J={...u,fill:C},$=new Av({text:x.getName(),style:J});$.position.set(S.end+2,I-gJ),this.subs[A].addChild($)});const f=a.tracks[A].label||"";if(f){const M=new Av({text:f,style:d});M.position.set(i.start+5,t-21),this.subs[A].addChild(M)}}),U.destroy()});this.myRef=E.createRef(),this.state={currentStep:0,isPlaying:!0}}async componentDidMount(){this.container=this.myRef.current;const{height:n,width:h,backgroundColor:i}=this.props,t=Xn(i||"white");this.app=new s4,await this.app.init({width:h,height:n,backgroundColor:t,autoDensity:!0,resolution:window.devicePixelRatio}),this.container&&this.app.view&&this.container.appendChild(this.app.view),this.subcontainer=new rh,this.app.stage.addChild(this.subcontainer),this.app.ticker.add(this.tick),window.addEventListener("resize",this.onWindowResize),this.app.stage.interactive=!0,this.app.stage.on("pointerdown",this.onPointerDown),this.drawAnnotations()}componentWillUnmount(){var n,h;this.app&&((n=this.app.ticker)==null||n.remove(this.tick),(h=this.app.stage)==null||h.off("pointerdown",this.onPointerDown)),window.removeEventListener("resize",this.onWindowResize)}componentDidUpdate(n,h){var t;if(!this.app)return;const{currentStep:i}=this.state;if(n.arrangeResults!==this.props.arrangeResults&&this.drawAnnotations(),n.color!==this.props.color&&!(this.props.useDynamicColors&&((t=this.props.dynamicColors)!=null&&t.length))){const s=Xn(this.props.color||"blue");this.subs.forEach(a=>a.children.forEach(o=>o.tint=s))}if(n.useDynamicColors!==this.props.useDynamicColors&&!this.props.useDynamicColors){const s=Xn(this.props.color||"blue");this.subs.forEach(a=>a.children.forEach(o=>o.tint=s))}n.backgroundColor!==this.props.backgroundColor&&this.app.renderer&&(this.app.renderer.background.color=Xn(this.props.backgroundColor||"0x000000")),(n.height!==this.props.height||n.width!==this.props.width)&&this.app.renderer&&this.app.renderer.resize(this.props.width,this.props.height),n.playing!==this.props.playing&&this.app.ticker&&(this.props.playing?this.app.ticker.start():this.app.ticker.stop()),h.currentStep!==i&&this.subs.forEach((s,a)=>{s.visible=a===i})}render(){const{height:n,width:h}=this.props,i={width:`${h}px`,height:`${n}px`};return _.jsx("div",{style:i,ref:this.myRef})}}q(K_,"propTypes",{arrangeResults:Gr.array.isRequired,viewWindow:Gr.object.isRequired,height:Gr.number.isRequired,width:Gr.number.isRequired,backgroundColor:Gr.string,color:Gr.string,color2:Gr.string,speed:Gr.array,steps:Gr.number,currentStep:Gr.number}),q(K_,"defaultProps",{currentStep:0,speed:[5],color:"blue",backgroundColor:"var(--bg-color)",dynamicColors:[],useDynamicColors:!1});const SEr=2,MEr=2,GEr=(c,e)=>c.getName().length*e+2,NEr=(c,e,n)=>{const h=Qr.max(c.map(t=>t.numRowsAssigned));let i=Math.min(h,n);return i<1&&(i=1),i*(e+MEr)+SEr},WEr=({data:c,visRegion:e,viewWindow:n,width:h,options:i,trackModel:t,svgHeight:s,updatedLegend:a})=>{const o=E.useMemo(()=>new vJ,[]);o.arrange=Mt(o.arrange);const l=E.useMemo(()=>c.map(d=>o.arrange(d,e,h,u=>GEr(u,i.rowHeight),i.hiddenPixels,void 0,n)),[c,e,h,i]),m=NEr(l,i.rowHeight,i.maxRows);return s&&(s.current=m),a&&(a.current=_.jsx(Uh,{height:m,trackModel:t})),_.jsx(K_,{arrangeResults:l,width:h,height:m,rowHeight:i.rowHeight,maxRows:i.maxRows,viewWindow:n,backgroundColor:i.backgroundColor,color:i.color,color2:i.color2,speed:i.speed,playing:i.playing,trackModel:t,dynamicColors:i.dynamicColors,useDynamicColors:i.useDynamicColors})};yR.types.MEAN;const TEr=2,XEr=c=>{const{data:e,unit:n,options:h,trackModel:i,viewRegion:t,width:s,viewWindow:a,updatedLegend:o}=c,{height:l,arrayAggregateMethod:m,color:d,backgroundColor:u,playing:U,speed:C,dynamicColors:p,useDynamicColors:D}=h,A=E.useCallback(Mt((x,B,W,T)=>{const I=new jl().makeXMap(x,B,W);return I&&I.xToFeaturesForward?I.xToFeaturesForward.map(yR.fromId(T)):[]}),[]),f=E.useCallback(Mt((x,B)=>{const W=x.slice(a.start,a.end),T=Qr.max(W.map(I=>Qr.max(I)))||1;let L=Qr.min(W.map(I=>Qr.min(I)))||0;return L>0&&(L=0),{valueToY:ge().domain([T,L]).range([TEr,B]).clamp(!0),min:L,max:T}}),[a.start,a.end]),M=E.useMemo(()=>A(e,t,s,m),[e,t,s,m]),S=E.useMemo(()=>f(M,l),[M,l]);return o&&(o.current=_.jsx(Uh,{trackModel:i,height:l,axisScale:S.valueToY,axisLegend:n})),_.jsxs(E.Fragment,{children:[_.jsx("div",{style:{display:"flex",flexDirection:"row",position:"absolute",zIndex:3},children:_.jsx(xh,{data:M,windowWidth:s,trackType:"dbedgraph",trackModel:i,height:l,viewRegion:t,unit:n,hasReverse:!0,options:h})}),_.jsx(Nv,{xToValue:M,scales:S,width:s,height:l,color:d,backgroundColor:u,playing:U,speed:C,viewWindow:a,dynamicColors:p,useDynamicColors:D})]})};class YEr extends vc{constructor(n){const h=new J0(`chr${n.seq_region_name}`,n.start-1,n.end);super(n.id,h,n.strand===1?"+":"-");q(this,"id");q(this,"alleles");q(this,"consequence_type");q(this,"clinical_significance");this.id=n.id,this.name=n.id,this.alleles=n.alleles,this.consequence_type=n.consequence_type,this.clinical_significance=n.clinical_significance}}const S4=9,wEr=({snp:c,xSpan:e,y:n,color:h="green",reverseStrandColor:i="pink",isMinimal:t=!1,isInvertArrowDirection:s=!1,alwaysDrawLabel:a=!1,hiddenPixels:o=0,onClick:l})=>{const m=c.getIsReverseStrand()?i:h,d=At(m),[u,U]=e,C=U-u,p=a?Math.max(3,C):C;if(p<=o)return null;const D=_.jsx("rect",{x:u,y:0,width:p,height:S4,fill:m});if(t)return _.jsx(An,{y:n,onClick:S=>l(S,c),children:D});let A;c.getHasStrand()&&(A=_.jsx(Cs,{startX:u,endX:U,height:S4,isToRight:c.getIsReverseStrand()===s,color:d}));let f;if(c.getName().length*S4<.5*p){const S=u+.5*p;f=_.jsx(hi,{x:S,y:0,height:S4-1,fill:d,dominantBaseline:"hanging",textAnchor:"middle",backgroundColor:m,backgroundOpacity:1,children:c.getName()})}else a&&(f=_.jsx(hi,{x:U+4,y:0,height:S4-1,fill:m,dominantBaseline:"hanging",textAnchor:"start",children:c.getName()}));return _.jsxs(An,{y:n,onClick:S=>l(S,c),children:[D,A,f]})},M4="-";function Xv(c){return Qr.sumBy(c,e=>e===M4?0:1)}function _J(c,e,n=!1){const h=[],i=new RegExp(M4+"+","g");let t;for(;(t=i.exec(c))!==null;)o(!0,t.index,t[0].length,e);if(n)return h;let s=0;const a=h.slice();for(const l of a)o(!1,s,l.index-s),s=l.index+l.length;return o(!1,s,c.length-s),h;function o(l,m,d,u=0){d>u&&h.push({isGap:l,index:m,length:d})}}function P_(c,e,n=!1){const h=n?-1:1,i=[];let t=e;for(const s of c)i.push(t),s!==M4&&(t+=h);return i}class O_{constructor(e){q(this,"sequence");q(this,"_currentIndex");this.sequence=e,this._currentIndex=-1}reset(){this._currentIndex=0}getCurrentIndex(){return this._currentIndex}getIndexOfNextBase(){do this._currentIndex++;while(this.sequence.charAt(this._currentIndex)===M4);return this._currentIndex}hasNextBase(){return this._currentIndex<this.sequence.length-1}advanceN(e){let n=this._currentIndex;for(let h=0;h<e;h++)n=this.getIndexOfNextBase();return n}}const EEr=4,xEr=2048,REr=16,LEr=/\d+[MIDNSHP=X]/g;function IEr(c){return c.match(LEr).map(n=>({opName:n.charAt(n.length-1),count:Number.parseInt(n,10)}))}const VEr=new Set(["M","D","N","=","x"]);class Q_ extends vc{constructor(n){const h=n.data.start,i=IEr(n.data.cigar),t=n.data.end,s=new J0(n.ref,h,t),a=n.flags&REr?aN:GD;super(n.data.name,s,a);q(this,"MD");q(this,"cigar");q(this,"seq");this.id=n._id,this.MD=n.data.md,this.cigar=i,this.seq=n.data.seq||""}static makeBamAlignments(n){const h=[];for(const i of n)i.flags&EEr||i.flags&xEr||h.push(new Q_(i));return h}getSegments(){const n=[],h=[],i=(o,l)=>o==="N"?l==="N":l!=="N",t=this.cigar.filter(o=>VEr.has(o.opName));let s=0,a=0;for(;s<t.length;){const o=t[s].opName;let l=t[s].count,m=s+1;for(;m<t.length&&i(o,t[m].opName);)l+=t[m].count,m++;s=m,(o==="N"?h:n).push(new z1(this,a,a+l)),a+=l}return{aligned:n,skipped:h}}getAlignment(){const[n,h]=this._cigarPass(),i=this._mdPass(n);return{reference:i,lines:i.split("").map((t,s)=>t===h[s]?"|":" ").join(""),read:h}}_cigarPass(){let n="",h="",i=0;for(const t of this.cigar){const s=t.count;switch(t.opName){case"S":case"H":i+=s;break;case"M":case"=":case"X":n+=this.seq.slice(i,i+s),h+=this.seq.slice(i,i+s),i+=s;break;case"I":n+="-".repeat(s),h+=this.seq.slice(i,i+s),i+=s;break;case"D":n+="D".repeat(s),h+="-".repeat(s);break}}return[n,h]}_mdPass(n){const h=/(\d+)([A-Z]|\^[A-Z]+)/g,i=new O_(n);let t;for(;(t=h.exec(this.MD))!==null;){const a=Number.parseInt(t[1],10);let o=t[2];i.advanceN(a),o.charAt(0)==="^"&&(o=o.slice(1));for(let l=0;l<o.length;l++)n=s(n,i.getIndexOfNextBase(),o.charAt(l))}return n;function s(a,o,l){return a.substring(0,o)+l+a.substring(o+l.length)}}}const Yv=10,q_=0,AJ=new ps;class $_ extends E.Component{constructor(e){super(e),this.renderRead=this.renderRead.bind(this),this.renderSkip=this.renderSkip.bind(this),this.handleClick=this.handleClick.bind(this)}renderRead(e){const{segment:n,xSpan:h}=e,i=n.feature,t=this.props.options,s=this.props.placedRecord.isReverse;if(h.getLength()<q_)return null;const a=[_.jsx("rect",{x:h.start,y:0,width:h.getLength(),height:Yv,fill:i.getIsForwardStrand()?t.color:t.color2},n.relativeStart)];let o=h.getLength()/n.getLength();if(o<q_)return a;s&&(o*=-1);const l=i.getAlignment(),m=new O_(l.reference);m.advanceN(n.relativeStart);let d=m.getIndexOfNextBase();const u=d+n.getLength();let U=s?h.end-o:h.start;for(;d<u;d++,U+=o)if(l.reference.charAt(d)!==l.read.charAt(d)&&l.reference.charAt(d)!=="-"){const C=l.read.charAt(d)==="-"?t.deletionColor:t.mismatchColor;a.push(_.jsx("rect",{x:U,y:0,width:o,height:Yv,fill:C},"mismatch"+d))}return a}renderSkip(e){const n=e.xSpan;if(n.getLength()<q_)return null;const[h,i]=n,t=Yv/2;return _.jsx("line",{x1:h,y1:t,x2:i,y2:t,stroke:"grey"},h)}handleClick(e){this.props.onClick(e,this.props.placedRecord.feature)}render(){const e=this.props.placedRecord,h=this.props.placedRecord.feature.getSegments(),i=AJ.placeFeatureSegments(e,h.aligned),t=AJ.placeFeatureSegments(e,h.skipped);return _.jsxs(An,{y:this.props.y,onClick:this.handleClick,children:[t.map(this.renderSkip),i.map(this.renderRead)]})}}q($_,"HEIGHT",Yv),q($_,"defaultProps",{options:{}});class FEr extends vc{constructor(n){const h=new J0(n.chr,n.start,n.end);super("",h);q(this,"images");this.images=JSON.parse(n[3])}}const yJ=10;class BJ{constructor(e=60,n=new HEr){q(this,"_tickSeparationHint");q(this,"_elementFactory");this._tickSeparationHint=e,this._elementFactory=n}_getMajorUnit(e){return e>=6?{size:1e6,digits:1,name:"M"}:e>3?{size:1e3,digits:0,name:"K"}:{size:1,digits:0,name:""}}design(e,n){const h=e.getNavigationContext(),i=new Bh(e,n),t=i.getDrawWidth()/this._tickSeparationHint,s=Math.ceil(Math.log10(e.getWidth()/t)),a=Math.pow(10,s),o=a/yJ,l=i.basesToXWidth(a),m=l/yJ,d=this._getMajorUnit(s),u=this._elementFactory,U=[];U.push(u.mainLine(i.getDrawWidth()));const C=e.getFeatureSegments(!1);for(const f of C){const M=f.getLocus(),S=h.convertFeatureSegmentToContextCoordinates(f);p(M,S,!0,f.feature.getIsReverseStrand()),o>=1&&p(M,S,!1,f.feature.getIsReverseStrand())}return U;function p(f,M,S=!0,N=!1){let x,B,W,T;S?(x=l,B=a,W=u.majorTick.bind(u),T=u.majorTickText.bind(u)):(x=m,B=o,W=u.minorTick.bind(u),T=u.minorTickText.bind(u));let L,I;N?(L=A(f.end,B),I=f.end-L,B*=-1):(L=D(f.start,B),I=L-f.start);const J=i.baseToX(M.start+I),$=i.baseToX(M.end);let sr=J,vr=L;for(;sr<$;){U.push(W(sr));const pr=(vr/d.size).toFixed(d.digits);pr>"0"&&U.push(T(sr,pr+d.name)),sr+=x,vr+=B}}function D(f,M){return Math.ceil(f/M)*M}function A(f,M){return Math.floor(f/M)*M}}}const kEr="#bbb",JEr=10,jEr=12;class HEr{constructor(e=kEr,n=JEr,h=jEr){q(this,"color");q(this,"majorTickHeight");q(this,"fontSize");this.color=e,this.majorTickHeight=n,this.fontSize=h}mainLine(e){return _.jsx("line",{x1:0,y1:0,x2:e,y2:0,stroke:this.color,strokeWidth:1,className:"svg-line-bg"},"mainLine")}majorTick(e){const n="major"+e;return _.jsx("line",{x1:e,y1:-this.majorTickHeight,x2:e,y2:0,stroke:this.color,strokeWidth:2,className:"svg-line-bg"},n)}majorTickText(e,n){return _.jsx("text",{x:e,y:this.fontSize+2,style:{textAnchor:"middle",fontSize:this.fontSize},className:"svg-text-bg",children:n},"text"+e)}minorTick(e){const n="minor"+e,h=-this.majorTickHeight/2;return _.jsx("line",{x1:e,y1:h,x2:e,y2:0,stroke:this.color,strokeWidth:1,className:"svg-line-bg"},n)}minorTickText(e,n){return null}}const KEr=new BJ;let ZJ=class extends E.PureComponent{render(){const{viewRegion:e,width:n,x:h,y:i}=this.props;return _.jsx(An,{x:h,y:i,children:KEr.design(e,n)})}};const fJ=60,SJ=20,r8=40;class PEr extends E.PureComponent{constructor(e){super(e),this.getTooltipContents=this.getTooltipContents.bind(this)}getTooltipContents(e){const{viewRegion:n,width:h}=this.props;return _.jsx(fs,{viewRegion:n,width:h,x:e})}render(){const{viewRegion:e,width:n}=this.props,h=this.props.genomeConfig;return this.props.options&&this.props.options.forceSvg?_.jsxs("svg",{width:this.props.width,height:r8,display:"block",children:[_.jsx(nm,{genomeConfig:h,viewRegion:e,width:n,labelOffset:fJ,hideChromName:!0}),_.jsx(ZJ,{viewRegion:e,width:n,y:SJ})]}):_.jsxs("svg",{width:n,height:r8,style:{display:"block"},children:[_.jsx(nm,{genomeConfig:h,viewRegion:e,width:n,labelOffset:fJ,hideChromName:!0}),_.jsx(ZJ,{viewRegion:e,width:n,y:SJ})]})}}class OEr extends E.Component{render(){let e=_.jsx(Uh,{height:r8,trackModel:this.props.trackModel,trackViewRegion:this.props.viewRegion,selectedRegion:this.props.selectedRegion,trackWidth:this.props.width,forceSvg:this.props.options.forceSvg});this.props.updatedLegend&&(this.props.updatedLegend.current=e);const n=this.props.options.forceSvg;let h=n?{position:"relative",overflow:"hidden",width:this.props.width/3}:{},i=n?{position:"relative",transform:`translateX(${-this.props.viewWindow.start}px)`}:{},t=this.props.options.packageVersion?{marginLeft:120}:{};return _.jsxs(E.Fragment,{children:[n?"":_.jsx("div",{style:{display:"flex",flexDirection:"row",position:"absolute",zIndex:3,...t},children:_.jsx(xh,{data:new Array,windowWidth:this.props.width,trackType:"ruler",height:40,viewRegion:this.props.viewRegion})}),_.jsxs("div",{style:{display:"flex",...h},children:[n||this.props.options.packageVersion?e:"",_.jsx("div",{style:{...i},children:_.jsx(PEr,{genomeConfig:this.props.genomeConfig,viewRegion:this.props.viewRegion,viewWindow:this.props.viewWindow,width:this.props.width,options:this.props.options})})]})]})}}class QEr extends vc{constructor(n){const h=new J0(n.chr,n.start,n.end);super("",h,n[4]);q(this,"annotation");q(this,"value");q(this,"relativeX");q(this,"relativeY");this.value=Number.parseFloat(n[3]),this.annotation=n[5]}}class MJ extends vc{constructor(n){const h=new J0(n.CHROM,n.POS-1,n.POS-1+n.REF.length);super("",h);q(this,"variant");q(this,"samples");this.samples=n.SAMPLES,this.variant=n}}class e8 extends E.Component{render(){const{feature:e,xSpan:n,y:h,height:i,colorScale:t,isMinimal:s,onClick:a,alwaysDrawLabel:o}=this.props,l=t(e.variant.QUAL),m=At(l),[d,u]=n,U=u-d,C=Math.max(2,U),p=_.jsx("rect",{x:d,y:0,width:C,height:i,fill:l});if(s)return _.jsx(An,{y:h,onClick:f=>a(f,e),children:p});let D=null;if(e.getName().length*i<.5*C){const f=d+.5*C;D=_.jsx(hi,{x:f,y:0,height:i-1,fill:m,dominantBaseline:"hanging",textAnchor:"middle",backgroundColor:l,backgroundOpacity:1,children:e.getName()})}else o&&(D=_.jsx(hi,{x:u+4,y:0,height:i-1,fill:l,dominantBaseline:"hanging",textAnchor:"start",children:e.getName()}));return _.jsxs(An,{y:h,onClick:f=>a(f,e),children:[p,D]})}}q(e8,"propTypes",{feature:Gr.instanceOf(MJ).isRequired,xSpan:Gr.instanceOf(Y0).isRequired,y:Gr.number,height:Gr.number,colorScale:Gr.any,reverseStrandColor:Gr.string,isMinimal:Gr.bool,onClick:Gr.func}),q(e8,"defaultProps",{onClick:(e,n)=>{}});const qEr=({feature:c,xSpan:e,y:n,height:h,isMinimal:i,onClick:t=()=>{}})=>{const[s,a]=e,o=a-s;if(o<=0)return null;const l=_.jsx("rect",{x:s,y:0,width:o,height:h,fill:c.color});return i?_.jsx(An,{y:n,onClick:m=>t(m,c),children:l}):_.jsx(An,{y:n,onClick:m=>t(m,c),children:l})},G4=new Set(["hic","biginteract","longrange"]),$Er=new Set(["repeat","jaspar","bigbed","rmskv2"]),rxr=new Set(["hic","dynamichic","bam"]),GJ=new Set(["matplot","dynamic","dynamicbed"]),exr=new Set(["hic","longrange"]),NJ=new Set(["bigwig","qbed","bedgraph"]),cxr=3e5,wv=2,nxr=1e3,t1={full:function({formattedData:e,trackState:n,windowWidth:h,configOptions:i,renderTooltip:t,svgHeight:s,updatedLegend:a,trackModel:o,getGenePadding:l,ROW_HEIGHT:m,onClose:d,scales:u}){function U(W,T,L,I,J,$){function sr(pr,dr){const zr=(J||1/0)-1,tr=Math.min(pr.row,zr),er=tr*I+wv;return D[`${o.type}`](pr,er,tr===zr,dr,i.height)}let vr=X1();if(i.forceSvg||i.packageVersion){let pr=i.forceSvg?{position:"relative",overflow:"hidden",width:T/3}:{},dr=i.forceSvg?{position:"relative",transform:`translateX(${-n.viewWindow.start}px)`}:{};return _.jsx(E.Fragment,{children:_.jsxs("div",{style:{display:"flex",...pr},children:[i.forceSvg||i.packageVersion?$:"",_.jsx("div",{style:{display:"flex",flexDirection:"column",...dr},children:_.jsx("svg",{width:T,height:L,display:"block",children:W.map(sr)},vr)})]})})}return _.jsx("svg",{width:T,height:L,children:W.map(sr)},vr)}function C(W,T,L,I){const J=W.feature;return _.jsx(Usr,{gene:J,xSpan:W.xSpan,viewWindow:i.forceSvg?n.viewWindow:new Y0(0,h*3),y:T,isMinimal:L,options:i,onClick:t||(()=>{}),children:W.placedFeatures.map(($,sr)=>_.jsx(sN,{placedGene:$,y:T,options:i},sr))},I)}function p(W,T,L,I){return W.placedFeatures.map((J,$)=>_.jsx(T5,{feature:J.feature,xSpan:J.xSpan,y:T,isMinimal:L,color:i.color,reverseStrandColor:i.color2,isInvertArrowDirection:J.isReverse,onClick:t||(()=>{}),alwaysDrawLabel:i.alwaysDrawLabel,hiddenPixels:i.hiddenPixels},$))}const D={geneannotation:(W,T,L,I)=>C(W,T,L,I),refbed:(W,T,L,I)=>C(W,T,L,I),bed:(W,T,L,I)=>p(W,T,L),bedcolor:function(T,L,I,J){return T.placedFeatures.map(($,sr)=>_.jsx(qEr,{feature:$.feature,xSpan:$.xSpan,y:L,isMinimal:I,height:i.rowHeight,onClick:t},sr))},vcf:function(T,L,I,J){return T.placedFeatures.map(($,sr)=>_.jsx(e8,{feature:$.feature,xSpan:$.xSpan,y:L,isMinimal:I,height:i.rowHeight,colorScale:u,onClick:t,alwaysDrawLabel:i.alwaysDrawLabel},sr))},jaspar:function(T,L,I,J,$){let sr=ge().domain([0,1e3]).range([0,1]).clamp(!0);return T.placedFeatures.map((vr,pr)=>_.jsx(T5,{feature:vr.feature,xSpan:vr.xSpan,y:L,isMinimal:I,color:i.color,reverseStrandColor:i.color2,isInvertArrowDirection:vr.isReverse,onClick:t||(()=>{}),alwaysDrawLabel:i.alwaysDrawLabel,hiddenPixels:i.hiddenPixels,opacity:sr(vr.feature.score)},pr))},bigbed:(W,T,L,I)=>p(W,T,L),modbed:function(T,L,I,J,$){return T.placedFeatures.map((sr,vr)=>_.jsx(yEr,{y:L,isMinimal:I,placement:sr,color:i.color,color2:i.color2,rowHeight:i.rowHeight,renderTooltip:t||(()=>{}),onHideTooltip:d,hiddenPixels:i.hiddenPixels,hideMinimalItems:i.hideMinimalItems,pixelsPadding:i.pixelsPadding,displayMode:i.displayMode},vr))},repeatmasker:function(T,L,I,J,$){const{categoryColors:sr}=i,vr=9;return T.placedFeatures.map((pr,dr)=>{const{xSpan:zr,feature:tr,isReverse:er}=pr;if(pr.xSpan.getLength<=0)return null;let H;if(tr.rgb)H=`rgb(${tr.rgb})`;else{const xr=tr.getCategoryId();H=sr[xr]}const O=At(H);let k=ge().domain([1,0]).range([wv,i.height])(tr.repeatValue);const rr=i.height-k,mr=zr.getLength();if(rr<=0)return null;const yr=_.jsx("rect",{x:zr.start,y:k,width:mr,height:rr,fill:H,fillOpacity:.75});let Sr;const Hr=tr.getName();if(Hr.length*vr<.9*mr){const xr=zr.start+.5*mr,kr=$-vr*2;Sr=_.jsx(hi,{x:xr,y:kr,height:vr-1,fill:O,dominantBaseline:"hanging",textAnchor:"middle",children:Hr})}const Jr=_.jsx(Cs,{startX:zr.start,endX:zr.end,y:$-vr,height:vr,opacity:.75,isToRight:er===(tr.strand==="-"),color:"white"});return _.jsxs(An,{onClick:xr=>{t&&t(xr,tr)},children:[yr,Jr,Sr]},dr)})},rmskv2:function(T,L,I,J,$){const{categoryColors:sr}=i,vr=9;return T.placedFeatures.map((pr,dr)=>{const{xSpan:zr,feature:tr,isReverse:er}=pr;if(pr.xSpan.getLength<=0)return null;let H;if(tr.rgb)H=`rgb(${tr.rgb})`;else{const xr=tr.getCategoryId();H=sr[xr]}const O=At(H);let k=ge().domain([1,0]).range([wv,i.height])(tr.repeatValue);const rr=i.height-k,mr=zr.getLength();if(rr<=0)return null;const yr=_.jsx("rect",{x:zr.start,y:k,width:mr,height:rr,fill:H,fillOpacity:.75});let Sr;const Hr=tr.getName();if(Hr.length*vr<.9*mr){const xr=zr.start+.5*mr,kr=$-vr*2;Sr=_.jsx(hi,{x:xr,y:kr,height:vr-1,fill:O,dominantBaseline:"hanging",textAnchor:"middle",children:Hr})}const Jr=_.jsx(Cs,{startX:zr.start,endX:zr.end,y:$-vr,height:vr,opacity:.75,isToRight:er===(tr.strand==="-"),color:"white"});return _.jsxs(An,{onClick:xr=>{t&&t(xr,tr)},children:[yr,Jr,Sr]},dr)})},categorical:function(T,L,I,J,$){return T.placedFeatures.map((sr,vr)=>{const pr=sr.feature.getName(),dr=i.category&&i.category[pr]?i.category[`${pr}`].color:"blue";return _.jsx(Wv,{feature:sr.feature,xSpan:sr.xSpan,y:L,isMinimal:!1,color:dr,onClick:t||(()=>{}),category:i.category,height:i.height,alwaysDrawLabel:i.alwaysDrawLabel},vr)})},snp:function(T,L,I,J,$){return T.placedFeatures.map((sr,vr)=>_.jsx(wEr,{snp:sr.feature,xSpan:sr.xSpan,y:L,isMinimal:I,color:i.color,reverseStrandColor:i.color2,isInvertArrowDirection:sr.isReverse,onClick:t||(()=>{}),alwaysDrawLabel:i.alwaysDrawLabel,hiddenPixels:i.hiddenPixels},vr))},bam:function(T,L,I,J,$){return T.placedFeatures.map((sr,vr)=>_.jsx($_,{placedRecord:sr,y:L,onClick:t||(()=>{}),options:i},vr))}};if(o.type==="omeroidr"){let T=(()=>{let L={start:0,end:n.visWidth};const I=Qr.sum(e.map(dr=>dr.images.length)),J=Math.min(I,PR),$=Math.max((i.imageHeight[0]*i.imageAspectRatio+Wz)*J-Wz,0),sr=L.end-L.start;return{trackHeight:(Math.floor($/sr)+1)*(i.imageHeight[0]+Wz)-Wz,numHidden:I-J}})();return s&&(s.current=T.trackHeight),a&&(a.current=_.jsx(Uh,{height:s.current,trackModel:o,label:i.label?i.label:o.options.label?o.options.label:""})),_.jsx(fSr,{data:e,options:i,viewWindow:{start:0,end:n.visWidth},trackModel:o,forceSvg:!1,width:0,layoutModel:ip.Model.fromJson(Vl),isThereG3dTrack:!1,onSetImageInfo:()=>{},heightObj:T})}function A(W){let T=m,L=i,I=Math.min(W,L.maxRows);return L.hideMinimalItems&&(I-=1),I<1&&(I=1),o.type==="modbed"?(I+1)*T+2:I*T+wv}let f=new vJ,M=Z4.NOSORT;const S=f.arrange(e,kh(n.visRegion),n.visWidth,l,i.hiddenPixels,M,n.viewWindow);let N;N=o.type==="repeatmasker"||o.type==="rmskv2"||o.type==="categorical"?i.height:S.numRowsAssigned?A(S.numRowsAssigned):40;const x=_.jsx(Uh,{height:N,trackModel:o,label:i.label?i.label:o.options.label?o.options.label:"",forceSvg:i.forceSvg});a&&(a.current=x);const B=U(S.placements,n.visWidth,N,m,i.maxRows,x);return s&&(s.current=N),{component:B,numHidden:S.numHidden}},density:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t,groupScale:s,xvaluesData:a,initialLoad:o}){return _.jsx(x5,{data:e,options:h,viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),viewRegion:kh(n.visRegion),width:n.visWidth,forceSvg:h.forceSvg,trackModel:t,updatedLegend:i,groupScale:s,xvaluesData:a,dataIdx:n.dataIdx,initialLoad:o})},vcf:function({formattedData:e,trackState:n,getHeight:h,configOptions:i,renderTooltip:t,svgHeight:s,updatedLegend:a,trackModel:o,getGenePadding:l,xvaluesData:m,initialLoad:d}){return _.jsx(TJ,{viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),viewRegion:kh(n.visRegion),width:n.visWidth,trackModel:o,getGenePadding:l,renderTooltip:t,svgHeight:s,forceSvg:i.forceSvg,data:e,trackState:n,options:i,getHeight:h,xvaluesData:m,updatedLegend:a,dataIdx:n.dataIdx,initialLoad:d})},qbed:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t,initialLoad:s}){return _.jsx(vGr,{data:e,options:h,viewRegion:kh(n.visRegion),width:n.visWidth,viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),trackModel:t,isLoading:!1,error:void 0,forceSvg:h.forceSvg,updatedLegend:i,dataIdx:n.dataIdx,initialLoad:s})},boxplot:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t}){return _.jsx(uGr,{data:e,options:h,viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),viewRegion:kh(n.visRegion),width:n.visWidth,forceSvg:h.forceSvg,trackModel:t,updatedLegend:i,dataIdx:n.dataIdx,unit:""})},matplot:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t,xvaluesData:s}){return _.jsx(UJ,{data:e,options:h,viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),viewRegion:kh(n.visRegion),width:n.visWidth,forceSvg:h.forceSvg,trackModel:t,updatedLegend:i,xvaluesData:s})},dynamichic:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t}){return _.jsx(ZEr,{data:e,options:h,viewWindow:new Y0(n.startWindow,n.startWindow*2),visRegion:kh(n.visRegion),width:n.visWidth,trackModel:t,updatedLegend:i,dataIdx:n.dataIdx})},dynamicbed:function({formattedData:e,trackState:n,configOptions:h,trackModel:i,svgHeight:t,updatedLegend:s}){return _.jsx(WEr,{data:e,options:h,viewWindow:new Y0(0,n.visWidth),visRegion:kh(n.visRegion),width:n.visWidth,trackModel:i,svgHeight:t,updatedLegend:s,dataIdx:n.dataIdx})},dbedgraph:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t}){return _.jsx(XEr,{data:e,options:h,viewWindow:new Y0(0,n.visWidth),viewRegion:kh(n.visRegion),width:n.visWidth,trackModel:t,updatedLegend:i,dataIdx:n.dataIdx})},dynamic:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t}){return _.jsx(uJ,{data:e,options:h,viewWindow:new Y0(0,n.visWidth),viewRegion:kh(n.visRegion),width:n.visWidth,trackModel:t,updatedLegend:i,dataIdx:n.dataIdx})},modbed:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t,renderTooltip:s,svgHeight:a,getGenePadding:o,getHeight:l,ROW_HEIGHT:m,onClose:d,xvaluesData:u}){return _.jsx(TL,{data:e,options:h,viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),width:n.visWidth,forceSvg:h.forceSvg,visRegion:kh(n.visRegion),trackModel:t,updatedLegend:i,isLoading:!1,trackState:n,getAnnotationTrack:t1,renderTooltip:s,svgHeight:a,getGenePadding:o,getHeight:l,ROW_HEIGHT:m,onClose:d,xvaluesData:u,dataIdx:n.dataIdx})},interaction:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t,initialLoad:s}){return _.jsx(BGr,{data:e,options:h,viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),visRegion:kh(n.visRegion),width:n.visWidth,forceSvg:h.forceSvg,trackModel:t,updatedLegend:i,dataIdx:n.dataIdx,initialLoad:s})},methylc:function({formattedData:e,trackState:n,configOptions:h,updatedLegend:i,trackModel:t,xvaluesData:s,initialLoad:a}){return _.jsx(XSr,{data:e,options:h,viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),viewRegion:kh(n.visRegion),width:n.visWidth,forceSvg:h.forceSvg,trackModel:t,updatedLegend:i,xvaluesData:s,dataIdx:n.dataIdx,initialLoad:a})},dynseq:function({formattedData:e,trackState:n,windowWidth:h,configOptions:i,updatedLegend:t,trackModel:s,genomeConfig:a,basesByPixel:o,xvaluesData:l,initialLoad:m}){return _.jsx(PSr,{data:e,options:i,viewWindow:n.viewWindow?n.viewWindow:new Y0(0,n.visWidth),viewRegion:kh(n.visRegion),width:n.visWidth,forceSvg:i.forceSvg,trackModel:s,updatedLegend:t,basesByPixel:o,genomeConfig:a,xvaluesData:l,dataIdx:n.dataIdx,initialLoad:m})},ruler:function({trackState:e,configOptions:n,updatedLegend:h,trackModel:i,genomeName:t,genomeConfig:s}){return _.jsx(OEr,{viewRegion:kh(e.visRegion),width:e.visWidth,trackModel:i,selectedRegion:e.genomicFetchCoord?kh(e.genomicFetchCoord[`${t}`].primaryVisData.viewWindowRegion):e.visRegion,viewWindow:e.viewWindow?e.viewWindow:new Y0(0,e.visWidth),updatedLegend:h,genomeConfig:s,options:n})},genomealign:function(e){let n=e.genesArr;if(!n)return null;let h;e.svgHeight&&(e.svgHeight.current=e.configOptions.height);let i=_.jsx(Uh,{height:e.configOptions.height,trackModel:e.trackModel,label:e.configOptions.label?e.configOptions.label:e.trackModel.options.label?e.trackModel.options.label:"",forceSvg:e.configOptions.forceSvg});if(e.basesByPixel<=10){const t=n.drawData;e.updatedLegend&&(e.updatedLegend.current=i),h=t.map((o,l)=>GGr(o,l,e.configOptions));const s=n.drawGapText;h.push(s.map((o,l)=>MGr(o,l,e.configOptions)));let a;return e.configOptions.forceSvg?a=_.jsxs("div",{style:{display:"flex",position:"relative",width:e.trackState.visWidth/3,overflow:"hidden"},children:[i,_.jsx("div",{style:{position:"relative",transform:`translateX(${-e.trackState.viewWindow.start}px)`},children:_.jsx("svg",{width:e.trackState.visWidth,height:e.configOptions.height,display:"block",children:h},X1())})]}):a=_.jsxs(E.Fragment,{children:[_.jsx("div",{style:{display:"flex",flexDirection:"row",position:"absolute",zIndex:3},children:e.forceSvg?"":_.jsx(xh,{data:e.genesArr,windowWidth:e.trackState.visWidth,trackType:"genomealignFine",height:e.configOptions.height,viewRegion:e.trackState.visRegion,side:e.trackState.side,options:e.configOptions})}),_.jsx("svg",{width:e.trackState.visWidth,height:e.configOptions.height,display:"block",children:h},X1())]}),a}else{const t=n.drawData;e.updatedLegend&&(e.updatedLegend.current=i);const s=n.plotStrand,a=n.primaryGenome,o=n.queryGenome;h=t.map(u=>WGr(u,s==="-",80,a,o,e.configOptions));const l=EL("+",0,new Y0(0,e.trackState.visWidth),!1);h.push(l);const m=EL(s,65,new Y0(0,e.trackState.visWidth),!0);h.push(m);let d;if(e.configOptions.forceSvg){let u=e.configOptions.forceSvg?{position:"relative",overflow:"hidden",width:e.trackState.visWidth/3}:{},U=e.configOptions.forceSvg?{position:"relative",transform:`translateX(${-e.trackState.viewWindow.start}px)`}:{};d=_.jsx(E.Fragment,{children:_.jsxs("div",{style:{display:"flex",...u},children:[e.configOptions.forceSvg||e.configOptions.packageVersion?i:"",_.jsx("div",{style:{display:"flex",flexDirection:"column",...U},children:_.jsx("svg",{width:e.trackState.visWidth,height:e.configOptions.height,display:"block",children:h})})]})})}else d=_.jsxs(E.Fragment,{children:[_.jsx("div",{style:{display:"flex",flexDirection:"row",position:"absolute",zIndex:3},children:_.jsx(xh,{data:e.genesArr,windowWidth:e.trackState.visWidth,trackType:"genomealignRough",height:e.configOptions.height,viewRegion:e.trackState.visRegion,side:e.trackState.side,options:e.configOptions})}),_.jsx("svg",{width:e.trackState.visWidth,height:e.configOptions.height,display:"block",children:h})]});return d}},error:function({trackState:e,configOptions:n,updatedLegend:h,trackModel:i,errorInfo:t,handleRetryFetchTrack:s}){function a(l){h&&(h.current=l)}const o=_.jsx(Uh,{height:40,trackModel:i,label:n.label?n.label:i.options.label?i.options.label:""});return a(o),_.jsx("div",{onClick:()=>s(i.id),style:{width:e.visWidth,height:40,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",backgroundColor:"#fdf2f2",border:"1px solid #f5c6cb",borderRadius:"8px",fontFamily:"Google Sans, Roboto, sans-serif",fontSize:"14px",color:"#721c24",cursor:"pointer",transition:"background-color 0.2s"},onMouseEnter:l=>{l.target.style.backgroundColor="#f8d7da"},onMouseLeave:l=>{l.target.style.backgroundColor="#fdf2f2"},children:_.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"2px"},children:[_.jsxs("span",{children:[Array.isArray(t)?t.filter(l=>typeof l=="string")[0]||"Something went wrong":typeof t=="object"&&t.error?t.error:"Something went wrong"," "]}),_.jsx("span",{children:"! Refresh page or click track to try again."}),_.jsx("span",{style:{marginLeft:"4px",color:"#dc3545",fontSize:"16px",transform:"rotate(90deg)"},children:"↻"})]})})}};function c8(c){const{trackModel:e,configOptions:n,genesArr:h}=c,i=e.type,t=(u={})=>({trackState:c.trackState,configOptions:c.configOptions,updatedLegend:c.updatedLegend,trackModel:c.trackModel,initialLoad:c.initialLoad,...u}),s=(u={})=>({formattedData:h,windowWidth:c.windowWidth,renderTooltip:c.renderTooltip,svgHeight:c.svgHeight,getGenePadding:c.getGenePadding,getHeight:c.getHeight,xvaluesData:c.xvaluesData,...t(u)});if(c.errorInfo)return t1.error(t({errorInfo:c.errorInfo,handleRetryFetchTrack:c.handleRetryFetchTrack}));if(i==="ruler")return t1.ruler(t({genomeName:c.genomeName,genomeConfig:c.genomeConfig}));if(i==="genomealign")return t1.genomealign(c);const a=new Set(["genomealign","dynamicbed","dbedgraph","dynamic","dynamiclongrange","dynamichic","vcf"]);return n.displayMode==="full"&&!a.has(i)||i==="omeroidr"&&n.displayMode!=="density"?t1.full(s({ROW_HEIGHT:n.rowHeight?n.rowHeight+2:c.ROW_HEIGHT})):["vcf","matplot"].includes(i)?t1[i](s()):i==="modbed"?t1.modbed(s({ROW_HEIGHT:n.rowHeight+2,onHideToolTip:c.onHideToolTip,onClose:c.onClose})):G4.has(i)?t1.interaction(s()):i==="dynamichic"?t1.dynamichic(s({configOptions:{...n,displayMode:"heatmap"}})):new Set(["dynamic","dynamicbed","dynamiclongrange"]).has(i)?t1[i==="dynamiclongrange"?"dynamichic":i](s({ROW_HEIGHT:c.ROW_HEIGHT})):i==="methylc"||i==="dynseq"?t1[i](s({genomeConfig:c.genomeConfig,basesByPixel:c.basesByPixel})):["qbed","dbedgraph","boxplot"].includes(i)?t1[i](s()):NJ.has(i)||n.displayMode==="density"?t1.density(s({formattedData:h,configOptions:{...n},groupScale:c.groupScale})):null}function hxr(c){return c.map(e=>new AU(e))}function ixr(c){return c.map(e=>{const[n,h,i,t,s,a,o,l,m,d,u,U,C]=e.rest.split(" "),p={genoLeft:l,label:n,max:e.end,milliDel:a,milliDiv:s,milliIns:o,min:e.start,orientation:i,repClass:m,repEnd:U,repFamily:d,repLeft:C,repStart:u,score:Number(h),segment:e.chr,swScore:t,type:"bigbed",_chromId:e.chromId};return new Tv(p)})}function txr(c){const e=[];for(const n of c)e.push(new pEr(n));return e}function sxr(c){return c.map(e=>{const n={chrom:e.chr,txStart:e.start,txEnd:e.end,id:e[7],name:e[6],description:e[11]?e[11]:"",transcriptionClass:e[8],exonStarts:e[9],exonEnds:e[10],cdsStart:Number.parseInt(e[3],10),cdsEnd:Number.parseInt(e[4],10),strand:e[5]};return new AU(n)})}function axr(c){return c.map(e=>new oN("",new J0(e.chr,e.start,e.end),"+").withColor(e[3]))}function oxr(c){return c.map(e=>new oN("",new J0(e.chr,e.start,e.end),"+").withColor(e[3]))}function lxr(c){return Q_.makeBamAlignments(c)}function mxr(c){return c.map(e=>new FEr(e))}function dxr(c){return c.map(e=>{const n=e.segment||e.chr,h=e.min??e.start,i=e.max??e.end;let t=e.name||e.label||"",s=e.score,a=e.orientation;if(e.rest){const[o,l,m]=e.rest.split(" ");t=o||t,s=l?Number(l):s,a=m||a}return new vc(t,new J0(n,h,i),a,s)})}function uxr(c){return c.map(n=>new YEr(n))}function Uxr(c){return c.map(n=>new vc(n[3],new J0(n.chr,n.start,n.end)))}function zxr(c){return c.map(e=>{const n=e.rest.split(" ");return new vsr(n[3],new J0(e.chr,e.start,e.end),n[2]).withJaspar(Number.parseInt(n[1],10),n[0])})}function vxr(c){return c.map(e=>new psr(e[3],new J0(e.chr,e.start,e.end),e[5]).withFiber(ZN(e[4]),e[6],e[7]))}function n8(c){return c.map(e=>{const n=new J0(e.chr,e.start,e.end);return new Kd("",n).withValue(e.score)})}function Cxr(c){let e=[];for(let n=0;n<c.length;n++)e.push(c[n].map(h=>{let i=new J0(h.chr,h.start,h.end);return new Kd("",i).withValue(h.score)}));return e}function pxr(c){return c.map(e=>new Eo(e))}function Dxr(c){return c.map(e=>e.map(n=>new vc(n[3],new J0(n.chr,n.start,n.end))))}function bxr(c){return c.map(e=>{let n=[];return e.map(h=>{const i=h[3].match(/([\w.]+)\W+(\d+)\W+(\d+)\W+(\d+)/);if(i){const t=i[1],s=Number.parseInt(i[2],10),a=Number.parseInt(i[3],10),o=Number.parseFloat(h[3].split(",")[1]),l=new J0(h.chr,h.start,h.end),m=new J0(t,s,a);n.push(new N5(l,m,o))}else console.error(`${h[3]} not formatted correctly in longrange track`)}),n})}function gxr(c){return c.map(e=>new QEr(e))}function _xr(c){return c.map(e=>e.map(n=>new Kd("",new J0(n.chr,n.start,n.end)).withValue(n.score)))}function Axr(c){return c.map(n=>{const h=new J0(n.chr,n.start,n.end),i=Number(n[3]),t=Number.isFinite(i)?i:0;return new Kd("",h).withValue(t)})}function yxr(c){return c.map(h=>{const i=new J0(h.chr,h.start,h.end);let t;try{t=JSON.parse(h[3])}catch(s){console.error(s),t=[0]}return new Csr("",i).withValues(t)})}function Bxr(c){return c.map(e=>new MJ(e))}function Zxr(c){const e=[];return c.map(n=>{if(n.rest.match(/([\w.]+)\W+(\d+)\W+(\d+)\W+(\d+)/)){const i=n.rest.split(" "),t=parseInt(i[1]),s=i[5],a=parseInt(i[6]),o=parseInt(i[7]),l=i[10],m=parseInt(i[11]),d=parseInt(i[12]),u=new J0(s,a,o),U=new J0(l,m,d);e.push(new N5(u,U,t))}else console.error(`${n[3]} not formatted correctly in BIGinteract track`)}),e}function fxr(c){const e=[];return c.forEach(n=>{const h=n[3].match(/([\w.]+)\W+(\d+)\W+(\d+)\W+(\d+)/);if(h){const i=h[1],t=Number.parseInt(h[2],10),s=Number.parseInt(h[3],10),a=Number.parseFloat(n[3].split(",")[1]),o=new J0(n.chr,n.start,n.end),l=new J0(i,t,s);e.push(new N5(o,l,a))}else console.error(`${n[3]} not formated correctly in longrange track`)}),e}const Sxr={},Mxr={geneannotation:hxr,repeatmasker:ixr,rmskv2:txr,refbed:sxr,bed:oxr,bedcolor:axr,categorical:Uxr,bam:lxr,omeroidr:mxr,bigbed:dxr,snp:uxr,jaspar:zxr,modbed:vxr,bigwig:n8,dynseq:n8,boxplot:n8,matplot:Cxr,methylc:pxr,dynamicbed:Dxr,dynamiclongrange:bxr,qbed:gxr,dynamic:_xr,bedgraph:Axr,dbedgraph:yxr,biginteract:Zxr,vcf:Bxr,longrange:fxr};function h8(c,e,n){if(!c)return{error:"No data available"};if(typeof c=="object"&&c.error)return c;if(Array.isArray(c)&&c.length>0){for(const i of c)if(typeof i=="object"&&i!==null&&i.error)return{error:i.error}}const h=Mxr[e];return h?h(c):c}const WJ=2,Gxr={highValueColor:"blue",lowValueColor:"red",maxRows:10,rowHeight:20,hiddenPixels:0,colorScaleKey:X5.AF,displayMode:Y5.AUTO,ensemblStyle:!1},TJ=c=>{const e=E.useRef(null),n=E.useRef(null),h=E.useRef(void 0),i=E.useRef(null),t=E.useRef(null),s=E.useRef(null),{data:a,viewRegion:o,viewWindow:l,width:m,options:d,trackState:u,renderTooltip:U,svgHeight:C,trackModel:p,updatedLegend:D,getGenePadding:A,getHeight:f,xvaluesData:M,dataIdx:S,initialLoad:N,forceSvg:x}=c,B=E.useMemo(()=>(I,J,$,sr)=>{let vr;const pr=I.flatMap(zr=>zr.dataCache||[]);return J===X5.QUAL?vr=pr.map(zr=>zr.variant.QUAL):J===X5.AF?vr=pr.map(zr=>zr.variant.INFO&&zr.variant.INFO.hasOwnProperty("AF")?zr.variant.INFO.AF[0]:0):vr=[],ge().domain([0,Qr.max(vr)]).range([$,sr]).clamp(!0)},[]),W=o.getWidth()*l.getLength()/m,T={...d,displayMode:Zs.AUTO,aggregateMethod:Nt.types.COUNT};let L;return d.displayMode===Y5.AUTO?W>1e5?N||d.forceSvg||S===h.current&&!Qr.isEqual(l,i.current)||S!==h.current||!Qr.isEqual(d,s.current)||!d.usePrimaryNav?L=_.jsx(x5,{...c,unit:"feature density",options:T,xvaluesData:M,dataIdx:S,initialLoad:N,updatedLegend:D}):L=n.current:(e.current=B(a,d.colorScaleKey,d.lowValueColor,d.highValueColor),N||d.forceSvg||S!==h.current||!Qr.isEqual(d,s.current)||!d.usePrimaryNav?L=t1.full({formattedData:a,trackState:u,windowWidth:m,configOptions:d,renderTooltip:U,svgHeight:C,updatedLegend:D,trackModel:p,getGenePadding:A,getHeight:f,ROW_HEIGHT:d.rowHeight+WJ,scales:e.current}).component:L=n.current):d.displayMode===Y5.DENSITY?N||d.forceSvg||S===h.current&&!Qr.isEqual(l,i.current)||S!==h.current||!Qr.isEqual(d,s.current)||!d.usePrimaryNav?L=_.jsx(x5,{...c,unit:"feature density",options:T,xvaluesData:M,dataIdx:S,initialLoad:N,updatedLegend:D}):L=n.current:(e.current=B(a,d.colorScaleKey,d.lowValueColor,d.highValueColor),N||d.forceSvg||S!==h.current||!Qr.isEqual(d,s.current)||!d.usePrimaryNav?L=t1.full({formattedData:a,trackState:u,windowWidth:m,configOptions:d,renderTooltip:U,svgHeight:C,updatedLegend:D,trackModel:p,getGenePadding:A,getHeight:f,ROW_HEIGHT:d.rowHeight+WJ,scales:e.current}).component:L=n.current),n.current=L,h.current=S,i.current=l,t.current=e.current,s.current=d,L};TJ.displayName="VcfTrack";const S3=5,Nxr=10+2,Wxr=9+2,eh={ruler:{defaultOptions:{backgroundColor:"var(--bg-color)",height:40,forceSvg:!1}},bigbed:{defaultOptions:{...w7,...Yn,...C1},getGenePadding:(c,e)=>{const n=e.end-e.start,h=c.getName().length*9;return h<.5*n?5:9+h},ROW_HEIGHT:9+S3},geneannotation:{defaultOptions:{...MD,...Yn,...C1},getGenePadding:function(e){return e.getName().length*9},ROW_HEIGHT:9+S3},genomealign:{defaultOptions:{...ZGr,displayMode:"full"}},refbed:{defaultOptions:{...MD,...Yn,...C1},getGenePadding:function(e){return e.getName().length*9},ROW_HEIGHT:9+S3},bed:{defaultOptions:{...w7,...Yn,...C1},getGenePadding:function(e){return e.getName().length*9},ROW_HEIGHT:9+S3},repeatmasker:{defaultOptions:{...C1,maxRows:1,height:40,categoryColors:Tv.DEFAULT_CLASS_COLORS,displayMode:si.FULL,hiddenPixels:.5,backgroundColor:"var(--bg-color)",alwaysDrawLabel:!0},getGenePadding:function(e,n){const h=n.end-n.start,i=e.getName().length*9;return i<.5*h?5:9+i},ROW_HEIGHT:9+S3},rmskv2:{defaultOptions:{...C1,maxRows:1,height:40,categoryColors:Tv.DEFAULT_CLASS_COLORS,displayMode:si.FULL,hiddenPixels:.5,backgroundColor:"var(--bg-color)",alwaysDrawLabel:!0},getGenePadding:function(e,n){const h=n.end-n.start,i=e.getName().length*9;return i<.5*h?5:9+i},ROW_HEIGHT:9+S3},vcf:{defaultOptions:{...Yn,...Gxr,displayMode:Zs.AUTO,aggregateMethod:Nt.types.COUNT},getGenePadding:function(e,n){const h=n.end-n.start,i=e.getName().length*9;return i<.5*h?5:9+i}},omeroidr:{defaultOptions:{...ZSr,...Yn,aggregateMethod:"IMAGECOUNT"},getGenePadding:function(e){return e.getName().length*9},ROW_HEIGHT:9+S3},bam:{defaultOptions:{...Yn,...C1,mismatchColor:"yellow",deletionColor:"black",insertionColor:"green",color:"red",color2:"blue",smooth:0,aggregateMethod:"COUNT"},getGenePadding:5,ROW_HEIGHT:Nxr},snp:{defaultOptions:{...w7,...Yn,...C1},getGenePadding:5,ROW_HEIGHT:Wxr},modbed:{defaultOptions:{...C1,...Yn,...DGr,displayMode:Zs.AUTO,aggregateMethod:Nt.types.COUNT},getGenePadding:function(e,n){const h=n.end-n.start,i=e.getName().length*9;return i<.5*h?5:9+i},ROW_HEIGHT:40},categorical:{defaultOptions:{...C1,...MSr,height:20,color:"blue",maxRows:1,hiddenPixels:.5,backgroundColor:"var(--bg-color)",alwaysDrawLabel:!0,category:{}},getGenePadding:function(e,n){const h=n.end-n.start,i=e.getName().length*9;return i<.5*h?5:9+i},ROW_HEIGHT:9+S3},jaspar:{defaultOptions:{...C1,hiddenPixels:.5,alwaysDrawLabel:!0,backgroundColor:"var(--bg-color)"},getGenePadding:function(e,n){const h=n.end-n.start,i=e.getName().length*9;return i<.5*h?5:9+i},ROW_HEIGHT:T5.HEIGHT+2},bigwig:{defaultOptions:{...Yn}},methylc:{defaultOptions:{...Yn,...TSr}},dynseq:{defaultOptions:{...Yn,...q7}},boxplot:{defaultOptions:{...Yn,...mGr}},qbed:{defaultOptions:{...Yn,...UGr}},bedgraph:{defaultOptions:{...Yn}},hic:{defaultOptions:{...im}},biginteract:{defaultOptions:{...im}},longrange:{defaultOptions:{...im}},dynamichic:{defaultOptions:{...bJ}},dynamiclongrange:{defaultOptions:{...bJ}},dynamic:{defaultOptions:{...Yn,...dJ}},matplot:{defaultOptions:{...Yn,...vEr,forceSvg:!1}},dbedgraph:{defaultOptions:{...Yn,color:"blue",color2:"red",rowHeight:10,maxRows:5,hiddenPixels:.5,speed:[5],playing:!0,dynamicColors:[],useDynamicColors:!1,backgroundColor:"var(--bg-color)",arrayAggregateMethod:"MEAN"}},dynamicbed:{defaultOptions:{...C1,color:"blue",color2:"red",rowHeight:10,maxRows:5,hiddenPixels:.5,speed:[5],playing:!0,dynamicColors:[],useDynamicColors:!1,backgroundColor:"var(--bg-color)"}},dynamicplot:{defaultOptions:{...Yn,...dJ}},error:{defaultOptions:{...Yn}}},Txr=({trigger:c,children:e})=>{const[n,h]=E.useState(!1),[i,t]=E.useState("0px"),s=E.useRef(null),a=()=>{h(!n)};E.useEffect(()=>{s.current&&t(n?`${s.current.scrollHeight}px`:"0px")},[n]);const o={cursor:"pointer",padding:"6px",border:"none",textAlign:"left",outline:"none",fontSize:"15px",width:"100%"},l={...o},m={maxHeight:i,overflow:"hidden",transition:"max-height 0.3s ease"},d={margin:"10px 0"};return _.jsxs("div",{children:[_.jsx("button",{className:"collapsible",onClick:a,style:n?l:o,children:c}),_.jsx("div",{ref:s,className:"content",style:m,children:_.jsx("div",{className:"TrackContextMenu-item",style:d,children:e})})]})},bm=({value:c})=>{const[e,n]=E.useState(!1),h=async()=>{try{await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),2e3)}catch(i){console.error("Failed to copy text:",i)}};return _.jsxs("span",{children:[_.jsx("button",{className:"btn btn-sm btn-info",title:"Copy to clipboard",onClick:h,children:"Copy"})," ",e?_.jsx("span",{style:{color:"red"},children:"Copied"}):null]})};function Ev(c){return _.jsx(wn,{...c,optionName:"smooth",label:"Smooth (pixels):",minValue:0,step:1,hasSetButton:!1})}function kt(c){const e=c.optionsObjects[0].yScale==="fixed"?_.jsxs(E.Fragment,{children:[_.jsx(wn,{...c,optionName:"yMax",label:"Y-axis max:",isFloat:!0,defaultValue:10,hasSetButton:!0}),c.optionsObjects[0].colorAboveMax&&_.jsx(uSr,{...c}),_.jsx(wn,{...c,optionName:"yMin",label:"Y-axis min:",isFloat:!0,hasSetButton:!0,defaultValue:0}),c.optionsObjects[0].color2BelowMin&&_.jsx(USr,{...c})]}):null;return _.jsxs(E.Fragment,{children:[_.jsx(fh,{...c,optionName:"yScale",label:"Y-axis scale:",choices:{AUTO:Nc.AUTO,FIXED:Nc.FIXED},defaultValue:Nc.AUTO}),e]})}class Xxr extends wo{constructor(e){super(e),this.setDefaultOptions({mismatchColor:"yellow",deletionColor:"black",insertionColor:"green",color:"red",color2:"blue",smooth:0})}getMenuComponents(){const e=super.getMenuComponents();return this.getOptions().displayMode===si.FULL?e.splice(e.findIndex(n=>n===Bn),0,Yxr):e.splice(e.findIndex(n=>n===Wt),1,kt,Ev),e}}function Yxr(c){return _.jsx(oi,{...c,optionName:"mismatchColor",label:"Mismatched base color"})}function N4(c){return _.jsx(v1,{...c,optionName:"alwaysDrawLabel",label:"Always draw label",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class wxr extends wo{getMenuComponents(){const e=[...super.getMenuComponents(),Ss,N4];return this.getOptions().displayMode===si.DENSITY&&e.push(kt),e}}function xv(c){return _.jsx(wn,{...c,optionName:"rowHeight",label:"Row height:",minValue:6,step:1,isFloat:!1,hasSetButton:!0})}class Exr{getMenuComponents(){return[Ei,xv,Ql,Ss,Bn]}}function W4(c){return _.jsx(v1,{...c,optionName:"playing",label:"Play",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}var XJ=Math.sqrt(50),YJ=Math.sqrt(10),wJ=Math.sqrt(2);function xxr(c,e,n){var h,i=-1,t,s,a;if(e=+e,c=+c,n=+n,c===e&&n>0)return[c];if((h=e<c)&&(t=c,c=e,e=t),(a=Rxr(c,e,n))===0||!isFinite(a))return[];if(a>0){let o=Math.round(c/a),l=Math.round(e/a);for(o*a<c&&++o,l*a>e&&--l,s=new Array(t=l-o+1);++i<t;)s[i]=(o+i)*a}else{a=-a;let o=Math.round(c*a),l=Math.round(e*a);for(o/a<c&&++o,l/a>e&&--l,s=new Array(t=l-o+1);++i<t;)s[i]=(o+i)/a}return h&&s.reverse(),s}function Rxr(c,e,n){var h=(e-c)/Math.max(0,n),i=Math.floor(Math.log(h)/Math.LN10),t=h/Math.pow(10,i);return i>=0?(t>=XJ?10:t>=YJ?5:t>=wJ?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(t>=XJ?10:t>=YJ?5:t>=wJ?2:1)}function EJ(c,e){var n=Object.keys(c);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(c);e&&(h=h.filter(function(i){return Object.getOwnPropertyDescriptor(c,i).enumerable})),n.push.apply(n,h)}return n}function Ts(c){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EJ(Object(n),!0).forEach(function(h){Lxr(c,h,n[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(n)):EJ(Object(n)).forEach(function(h){Object.defineProperty(c,h,Object.getOwnPropertyDescriptor(n,h))})}return c}function r2(c,e){if(!(c instanceof e))throw new TypeError("Cannot call a class as a function")}function xJ(c,e){for(var n=0;n<e.length;n++){var h=e[n];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(c,h.key,h)}}function e2(c,e,n){return e&&xJ(c.prototype,e),n&&xJ(c,n),Object.defineProperty(c,"prototype",{writable:!1}),c}function Lxr(c,e,n){return e in c?Object.defineProperty(c,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):c[e]=n,c}function T4(c,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(e&&e.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),e&&i8(c,e)}function Rv(c){return Rv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Rv(c)}function i8(c,e){return i8=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,i){return h.__proto__=i,h},i8(c,e)}function Ixr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function c2(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function Vxr(c,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return c2(c)}function X4(c){var e=Ixr();return function(){var h=Rv(c),i;if(e){var t=Rv(this).constructor;i=Reflect.construct(h,arguments,t)}else i=h.apply(this,arguments);return Vxr(this,i)}}function t8(c,e){return kxr(c)||jxr(c,e)||RJ(c,e)||Kxr()}function s8(c){return Fxr(c)||Jxr(c)||RJ(c)||Hxr()}function Fxr(c){if(Array.isArray(c))return a8(c)}function kxr(c){if(Array.isArray(c))return c}function Jxr(c){if(typeof Symbol<"u"&&c[Symbol.iterator]!=null||c["@@iterator"]!=null)return Array.from(c)}function jxr(c,e){var n=c==null?null:typeof Symbol<"u"&&c[Symbol.iterator]||c["@@iterator"];if(n!=null){var h=[],i=!0,t=!1,s,a;try{for(n=n.call(c);!(i=(s=n.next()).done)&&(h.push(s.value),!(e&&h.length===e));i=!0);}catch(o){t=!0,a=o}finally{try{!i&&n.return!=null&&n.return()}finally{if(t)throw a}}return h}}function RJ(c,e){if(c){if(typeof c=="string")return a8(c,e);var n=Object.prototype.toString.call(c).slice(8,-1);if(n==="Object"&&c.constructor&&(n=c.constructor.name),n==="Map"||n==="Set")return Array.from(c);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a8(c,e)}}function a8(c,e){(e==null||e>c.length)&&(e=c.length);for(var n=0,h=new Array(e);n<e;n++)h[n]=c[n];return h}function Hxr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1368
1368
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Kxr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1369
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o8="react-compound-slider:";function LJ(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return function(n,h){return n.val>h.val?c?-1:1:h.val>n.val?c?1:-1:0}}function Y4(c,e,n){var h=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=c.findIndex(function(o){return o.key===e});if(i!==-1){var t=c[i],s=t.key,a=t.val;return a===n?c:[].concat(s8(c.slice(0,i)),[{key:s,val:n}],s8(c.slice(i+1))).sort(LJ(h))}return c}function w4(c,e){if(!c)return[0,0];var n=c.getBoundingClientRect(),h=e?n.top:n.left,i=e?n.bottom:n.right;return[h,i]}function IJ(c){var e=c.type,n=e===void 0?"":e,h=c.touches;return!h||h.length>1||n.toLowerCase()==="touchend"&&h.length>0}function l8(c,e){return c?e.touches[0].clientY:e.touches[0].pageX}function VJ(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,h=arguments.length>3?arguments[3]:void 0,i=0,t=c.map(function(s){var a=n.getValue(s);return s!==a&&(i+=1,Hd(!h,"".concat(o8," Invalid value encountered. Changing ").concat(s," to ").concat(a,"."))),a}).map(function(s,a){return{key:"$$-".concat(a),val:s}}).sort(LJ(e));return{handles:t,changes:i}}function Pxr(c,e){return e}function Oxr(c,e){for(var n=0;n<c.length;n++)if(c[n].key!==e[n].key||e[n+1]&&e[n].val===e[n+1].val)return c;return e}function m8(c,e,n,h,i){for(var t=-1,s=!0,a=0;a<c.length;a++){var o=c[a],l=e[a];if(!l||l.key!==o.key)return c;l.val!==o.val&&(t=a,s=l.val-o.val>0)}if(t===-1)return c;for(var m=s?n:-n,d=0;d<e.length;d++){var u=e[d],U=e[d+1];if(U&&u.val===U.val)if(d===t){var C=U.val+m;if(i(C)===C){var p=Y4(e,U.key,U.val+m,h),D=m8(e,p,n,h,i);return D===e?c:D}else return c}else{var A=u.val+m;if(i(A)===A){var f=Y4(e,u.key,u.val+m,h),M=m8(e,f,n,h,i);return M===e?c:M}else return c}}return e}function n2(){for(var c=arguments.length,e=new Array(c),n=0;n<c;n++)e[n]=arguments[n];return function(h){return e.forEach(function(i){return i&&i(h)})}}var Qxr=function(){return{value:0,percent:0}},FJ=function(c){T4(n,c);var e=X4(n);function n(){var h;r2(this,n);for(var i=arguments.length,t=new Array(i),s=0;s<i;s++)t[s]=arguments[s];return h=e.call.apply(e,[this].concat(t)),h.getRailProps=function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=h.props,l=o.emitMouse,m=o.emitTouch;return Ts(Ts({},a),{},{onMouseDown:n2(a&&a.onMouseDown,l),onTouchStart:n2(a&&a.onTouchStart,m)})},h}return e2(n,[{key:"render",value:function(){var i=this.getRailProps,t=this.props,s=t.getEventData,a=t.activeHandleID,o=a===void 0?"":a,l=t.children,m=l({getEventData:s||Qxr,activeHandleID:o,getRailProps:i});return m&&E.Children.only(m)}}]),n}(E.Component),kJ=function(c){T4(n,c);var e=X4(n);function n(){var h;r2(this,n);for(var i=arguments.length,t=new Array(i),s=0;s<i;s++)t[s]=arguments[s];return h=e.call.apply(e,[this].concat(t)),h.autofocus=function(a){a.target instanceof HTMLElement&&a.target.focus()},h.getHandleProps=function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=h.props,m=l.emitKeyboard,d=l.emitMouse,u=l.emitTouch;return Ts(Ts({},o),{},{onKeyDown:n2(o&&o.onKeyDown,function(U){return m&&m(U,a)}),onMouseDown:n2(o&&o.onMouseDown,h.autofocus,function(U){return d&&d(U,a)}),onTouchStart:n2(o&&o.onTouchStart,function(U){return u&&u(U,a)})})},h}return e2(n,[{key:"render",value:function(){var i=this.getHandleProps,t=this.props,s=t.activeHandleID,a=s===void 0?"":s,o=t.children,l=t.handles,m=l===void 0?[]:l,d=o({handles:m,activeHandleID:a,getHandleProps:i});return d&&E.Children.only(d)}}]),n}(E.Component),d8=function(){function c(){r2(this,c),this.interpolator=void 0,this.domain=[0,1],this.range=[0,1],this.domain=[0,1],this.range=[0,1],this.interpolator=null}return e2(c,[{key:"createInterpolator",value:function(n,h){var i=this,t=n[0],s=n[1],a=h[0],o=h[1];return s<t?function(l){return i.interpolateValue(o,a)(i.deinterpolateValue(s,t)(l))}:function(l){return i.interpolateValue(a,o)(i.deinterpolateValue(t,s)(l))}}},{key:"interpolateValue",value:function(n,h){return n=+n,h-=n,function(t){return n+h*t}}},{key:"deinterpolateValue",value:function(n,h){return(h-=n=+n)?function(i){return(i-n)/h}:function(){return h}}},{key:"rescale",value:function(){return this.interpolator=null,this}},{key:"getValue",value:function(n){var h=this.domain,i=this.range;return(this.interpolator||(this.interpolator=this.createInterpolator(h,i)))(+n)}},{key:"setDomain",value:function(n){return this.domain=[n[0],n[1]],this.rescale(),this}},{key:"getDomain",value:function(){return this.domain}},{key:"setRange",value:function(n){return this.range=[n[0],n[1]],this}},{key:"getRange",value:function(){return this.range}},{key:"getTicks",value:function(n){var h=this.domain;return xxr(h[0],h[h.length-1],n||10)}}]),c}(),qxr=function(){return{value:0,percent:0}},$xr=function(c){T4(n,c);var e=X4(n);function n(){return r2(this,n),e.apply(this,arguments)}return e2(n,[{key:"render",value:function(){var i=this.props,t=i.children,s=i.values,a=i.scale,o=a===void 0?new d8:a,l=i.count,m=l===void 0?10:l,d=i.getEventData,u=d===void 0?qxr:d,U=i.activeHandleID,C=U===void 0?"":U,p=(s||o.getTicks(m)).map(function(A){return{id:"$$-".concat(A),value:A,percent:o.getValue(A)}}),D=t({getEventData:u,activeHandleID:C,ticks:p});return D&&E.Children.only(D)}}]),n}(E.Component),rRr=function(){return{value:0,percent:0}},JJ=function(c){T4(n,c);var e=X4(n);function n(){var h;r2(this,n);for(var i=arguments.length,t=new Array(i),s=0;s<i;s++)t[s]=arguments[s];return h=e.call.apply(e,[this].concat(t)),h.getTrackProps=function(a){var o=h.props,l=o.emitMouse,m=o.emitTouch;return Ts(Ts({},a||{}),{},{onMouseDown:n2(a&&a.onMouseDown,l),onTouchStart:n2(a&&a.onTouchStart,m)})},h}return e2(n,[{key:"render",value:function(){for(var i=this.getTrackProps,t=this.props,s=t.children,a=t.left,o=a===void 0?!0:a,l=t.right,m=l===void 0?!0:l,d=t.scale,u=d===void 0?new d8:d,U=t.handles,C=U===void 0?[]:U,p=t.getEventData,D=p===void 0?rRr:p,A=t.activeHandleID,f=A===void 0?"":A,M=u.getDomain(),S=[],N=0;N<C.length+1;N++){var x=C[N-1],B=C[N];N===0&&o===!0?x={id:"$",value:M[0],percent:0}:N===C.length&&m===!0&&(B={id:"$",value:M[1],percent:100}),x&&B&&S.push({id:"".concat(x.id,"-").concat(B.id),source:x,target:B})}var W=s({getEventData:D,activeHandleID:f,tracks:S,getTrackProps:i});return W&&E.Children.only(W)}}]),n}(E.Component);function jJ(c,e,n){return Math.min(Math.max(c,e),n)}var HJ=e2(function c(){var e=this;r2(this,c),this.step=1,this.domain=[0,1],this.range=[0,1],this.setDomain=function(n){return e.domain=[n[0],n[1]],e},this.setRange=function(n){return e.range=[n[0],n[1]],e},this.setStep=function(n){return e.step=n,e},this.getValue=function(n){var h=t8(e.domain,2),i=h[0],t=h[1],s=t8(e.range,2),a=s[0],o=s[1],l=e.step,m=(jJ(n,i,t)-i)/(t-i),d=l*Math.round(m*(o-a)/l)+a;return jJ(d,a<o?a:o,o>a?o:a)}}),E4=typeof window<"u"&&typeof document<"u",Ji=function(){},eRr=function(e){return function(n,h,i){return n&&e[i]===h}},cRr=function(e,n){return e===n||e.length===n.length&&e.reduce(eRr(n),!0)},nRr=function(e){if(!E.isValidElement(e))return!1;var n=e.type,h=n?n.name:"";return h===kJ.name||h===FJ.name||h===$xr.name||h===JJ.name},hRr=function(e,n,h,i){var t=i?e-n:e+n;return i?Math.max(h[0],t):Math.min(h[1],t)},iRr=function(e,n,h,i){var t=i?e+n:e-n;return i?Math.min(h[1],t):Math.max(h[0],t)},Lv=[0,100],tRr=function(c){T4(n,c);var e=X4(n);function n(){var h;r2(this,n);for(var i=arguments.length,t=new Array(i),s=0;s<i;s++)t[s]=arguments[s];return h=e.call.apply(e,[this].concat(t)),h.state={step:.1,values:[],domain:Lv,handles:[],reversed:!1,activeHandleID:"",valueToPerc:null,valueToStep:null,pixelToStep:null},h.slider=E.createRef(),h.onKeyDown=function(a,o){var l=["ArrowRight","ArrowUp"],m=["ArrowDown","ArrowLeft"],d=c2(h),u=d.state.handles,U=d.props,C=U.step,p=C===void 0?.1:C,D=U.reversed,A=D===void 0?!1:D,f=U.vertical,M=f===void 0?!1:f,S=U.domain,N=S===void 0?[0,100]:S,x=a.key||"".concat(a.keyCode);if(l.concat(m).includes(x)){if(M){var B=[m,l];l=B[0],m=B[1]}a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault();var W=u.find(function(J){return J.key===o});if(W){var T=W.val,L=T;l.includes(x)?L=hRr(T,p,N,A):m.includes(x)&&(L=iRr(T,p,N,A));var I=u.map(function(J){return J.key===o?{key:J.key,val:L}:J});h.submitUpdate(I,!0)}}},h.onMouseDown=function(a,o){h.onStart(a,o,!1)},h.onTouchStart=function(a,o){IJ(a)||h.onStart(a,o,!0)},h.getEventData=function(a,o){var l=c2(h),m=l.state,d=m.pixelToStep,u=m.valueToPerc,U=l.props.vertical;d.setDomain(w4(h.slider.current,U));var C;return o&&a instanceof TouchEvent?C=d.getValue(l8(U,a)):a instanceof MouseEvent&&(C=d.getValue(U?a.clientY:a.pageX)),{value:C,percent:u.getValue(C)}},h.onMouseMove=function(a){var o=c2(h),l=o.state,m=l.handles,d=l.pixelToStep,u=l.activeHandleID,U=u===void 0?"":u,C=o.props,p=C.vertical,D=C.reversed,A=D===void 0?!1:D;d.setDomain(w4(h.slider.current,p));var f=d.getValue(p?a.clientY:a.pageX),M=Y4(m,U,f,A);h.submitUpdate(M)},h.onTouchMove=function(a){var o=c2(h),l=o.state,m=l.handles,d=l.pixelToStep,u=l.activeHandleID,U=o.props,C=U.vertical,p=U.reversed;if(!(d===null||IJ(a))){d.setDomain(w4(h.slider.current,C));var D=d.getValue(l8(C,a)),A=Y4(m,u,D,p);h.submitUpdate(A)}},h.onMouseUp=function(){var a=c2(h),o=a.state,l=o.handles,m=l===void 0?[]:l,d=o.activeHandleID,u=a.props,U=u.onChange,C=U===void 0?Ji:U,p=u.onSlideEnd,D=p===void 0?Ji:p;C(m.map(function(A){return A.val})),D(m.map(function(A){return A.val}),{activeHandleID:d}),h.setState({activeHandleID:""}),E4&&(document.removeEventListener("mousemove",h.onMouseMove),document.removeEventListener("mouseup",h.onMouseUp))},h.onTouchEnd=function(){var a=c2(h),o=a.state,l=o.handles,m=o.activeHandleID,d=a.props,u=d.onChange,U=u===void 0?Ji:u,C=d.onSlideEnd,p=C===void 0?Ji:C;U(l.map(function(D){return D.val})),p(l.map(function(D){return D.val}),{activeHandleID:m}),h.setState({activeHandleID:""}),E4&&(document.removeEventListener("touchmove",h.onTouchMove),document.removeEventListener("touchend",h.onTouchEnd))},h}return e2(n,[{key:"componentDidMount",value:function(){var i=this.state.pixelToStep,t=this.props.vertical;i.setDomain(w4(this.slider.current,t))}},{key:"componentWillUnmount",value:function(){this.removeListeners()}},{key:"removeListeners",value:function(){E4&&(document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd))}},{key:"onStart",value:function(i,t,s){var a=this.state.handles,o=this.props.onSlideStart,l=o===void 0?Ji:o;s||i.preventDefault&&i.preventDefault(),i.stopPropagation&&i.stopPropagation();var m=a.find(function(d){return d.key===t});m?(this.setState({activeHandleID:t}),l(a.map(function(d){return d.val}),{activeHandleID:t}),s?this.addTouchEvents():this.addMouseEvents()):(this.setState({activeHandleID:""}),this.handleRailAndTrackClicks(i,s))}},{key:"handleRailAndTrackClicks",value:function(i,t){var s=this,a=this.state,o=a.handles,l=a.pixelToStep,m=this.props,d=m.vertical,u=m.reversed,U=u===void 0?!1:u,C=this.slider;l.setDomain(w4(C.current,d));var p;t?p=l.getValue(l8(d,i)):p=l.getValue(d?i.clientY:i.pageX);for(var D="",A=1/0,f=0;f<o.length;f++){var M=o[f],S=M.key,N=M.val,x=Math.abs(N-p);x<A&&(D=S,A=x)}var B=Y4(o,D,p,U);this.setState({activeHandleID:D},function(){s.submitUpdate(B,!0),t?s.addTouchEvents():s.addMouseEvents()})}},{key:"addMouseEvents",value:function(){E4&&(document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp))}},{key:"addTouchEvents",value:function(){E4&&(document.addEventListener("touchmove",this.onTouchMove),document.addEventListener("touchend",this.onTouchEnd))}},{key:"submitUpdate",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=this.props,a=s.mode,o=a===void 0?1:a,l=s.step,m=l===void 0?.1:l,d=s.onUpdate,u=d===void 0?Ji:d,U=s.onChange,C=U===void 0?Ji:U,p=s.reversed,D=p===void 0?!1:p,A=this.state.valueToStep.getValue;this.setState(function(f){var M=f.handles,S=[];if(typeof o=="function")S=o(M,i,m,D,A),Hd(Array.isArray(S),"Custom mode function did not return an array.");else switch(o){case 1:S=Pxr(M,i);break;case 2:S=Oxr(M,i);break;case 3:S=m8(M,i,m,D,A);break;default:S=i,Hd(!1,"".concat(o8," Invalid mode value."))}return u(S.map(function(N){return N.val})),t&&C(S.map(function(N){return N.val})),{handles:S}})}},{key:"render",value:function(){var i=this,t=this.state,s=t.handles,a=t.valueToPerc,o=t.activeHandleID,l=this.props,m=l.className,d=l.rootStyle,u=d===void 0?{}:d,U=l.rootProps,C=U===void 0?{}:U,p=l.component,D=p===void 0?"div":p,A=l.disabled,f=A===void 0?!1:A,M=l.flatten,S=M===void 0?!1:M,N=s.map(function(B){var W=B.key,T=B.val;return{id:W,value:T,percent:a.getValue(T)}}),x=E.Children.map(this.props.children,function(B){return nRr(B)===!0?E.cloneElement(B,{scale:a,handles:N,activeHandleID:o,getEventData:i.getEventData,emitKeyboard:f?Ji:i.onKeyDown,emitMouse:f?Ji:i.onMouseDown,emitTouch:f?Ji:i.onTouchStart}):B});return S?E.createElement(E.Fragment,null,E.createElement(D,Ts(Ts({},C),{},{style:u,className:m,ref:this.slider})),x):E.createElement(E.Fragment,null,E.createElement(D,Ts(Ts({},C),{},{style:u,className:m,ref:this.slider}),x))}}],[{key:"getDerivedStateFromProps",value:function(i,t){var s=i.step,a=s===void 0?.1:s,o=i.values,l=i.domain,m=l===void 0?Lv:l,d=i.reversed,u=d===void 0?!1:d,U=i.onUpdate,C=U===void 0?Ji:U,p=i.onChange,D=p===void 0?Ji:p,A=i.warnOnChanges,f=A===void 0?!1:A,M=t.valueToPerc,S=t.valueToStep,N=t.pixelToStep,x={};if((!M||!S||!N)&&(M=new d8,S=new HJ,N=new HJ,x.valueToPerc=M,x.valueToStep=S,x.pixelToStep=N),t.domain===Lv||t.step===null||t.domain===null||t.reversed===null||a!==t.step||m[0]!==t.domain[0]||m[1]!==t.domain[1]||u!==t.reversed){var B=t8(m,2),W=B[0],T=B[1];S.setStep(a).setRange([W,T]).setDomain([W,T]),u===!0?(M.setDomain([W,T]).setRange([100,0]),N.setStep(a).setRange([T,W])):(M.setDomain([W,T]).setRange([0,100]),N.setStep(a).setRange([W,T])),Hd(T>W,"".concat(o8," Max must be greater than min (even if reversed). Max is ").concat(T,". Min is ").concat(W,"."));var L=VJ(o||t.values,u,S,f),I=L.handles,J=L.changes;(J||o===void 0||o===t.values)&&(C(I.map(function(pr){return pr.val})),D(I.map(function(pr){return pr.val}))),x.step=a,x.values=o,x.domain=m===Lv?s8(m):m,x.handles=I,x.reversed=u}else if(!cRr(o,t.values)){var $=VJ(o,u,S,f),sr=$.handles,vr=$.changes;vr&&(C(sr.map(function(pr){return pr.val})),D(sr.map(function(pr){return pr.val}))),x.values=o,x.handles=sr}return Object.keys(x).length?x:null}}]),n}(E.PureComponent);const sRr={position:"relative",width:200,height:40,marginLeft:"5%",marginTop:10},KJ={position:"absolute",width:"100%",height:10,marginTop:15,borderRadius:5,backgroundColor:"#D8D8D8"};function aRr({source:c,target:e,getTrackProps:n}){return _.jsx("div",{style:{position:"absolute",height:10,zIndex:1,marginTop:15,backgroundColor:"#262626",borderRadius:5,cursor:"pointer",left:`${c.percent}%`,width:`${e.percent-c.percent}%`},...n()})}function oRr({handle:{id:c,value:e,percent:n},getHandleProps:h}){return _.jsx("div",{style:{left:`${n}%`,position:"absolute",marginLeft:-10,marginTop:10,zIndex:2,width:20,height:20,border:0,textAlign:"center",cursor:"pointer",borderRadius:"50%",backgroundColor:"#7F7F7F"},...h(c),children:_.jsx("div",{style:{fontFamily:"Arial",fontSize:12,marginTop:-20},children:e})})}class x4 extends E.PureComponent{constructor(n){super(n);q(this,"onUpdate",n=>{this.setState({update:n}),this.props.onOptionSet(this.props.optionName,n)});q(this,"onChange",n=>{this.setState({values:n}),this.props.onOptionSet(this.props.optionName,n)});this.state={values:n.values.slice(),update:n.values.slice()},this.onUpdate=n.onUpdate===void 0?this.onUpdate.bind(this):n.onUpdate,this.onChange=n.onChange===void 0?this.onChange.bind(this):n.onChange}render(){const{label:n,mode:h,step:i,domain:t}=this.props;let s=_.jsxs(tRr,{mode:h,step:i,domain:t,rootStyle:sRr,onUpdate:this.onUpdate,onChange:this.onChange,values:this.state.values,children:[_.jsx("div",{style:KJ}),_.jsx(FJ,{children:({getRailProps:a})=>_.jsx("div",{style:KJ,...a()})}),_.jsx(kJ,{children:({handles:a,getHandleProps:o})=>_.jsx("div",{className:"slider-handles",children:a.map(l=>_.jsx(oRr,{handle:l,getHandleProps:o},l.id))})}),_.jsx(JJ,{right:!1,children:({tracks:a,getTrackProps:o})=>_.jsx("div",{className:"slider-tracks",children:a.map(({id:l,source:m,target:d})=>_.jsx(aRr,{source:m,target:d,getTrackProps:o},l))})})]});return _.jsx("div",{className:"TrackContextMenu-item",children:_.jsxs("label",{style:{margin:0},children:[n," ",s]})})}}q(x4,"propTypes",Object.assign({},{optionName:Gr.string.isRequired,label:Gr.string.isRequired,mode:Gr.number.isRequired,step:Gr.number.isRequired,domain:Gr.array.isRequired,values:Gr.array.isRequired})),q(x4,"defaultProps",{label:"Slider",mode:1,step:1,domain:[0,100],values:[]});function R4(c){return _.jsx(x4,{...c,optionName:"speed",label:"Play speed:",mode:1,step:1,domain:[1,10],values:c.optionsObjects[0].speed,onUpdate:()=>{}})}function Iv(c){return _.jsx(v1,{...c,optionName:"useDynamicColors",label:"Use dynamic colors",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class lRr extends on{getMenuComponents(){return[Ei,W4,R4,xi,Wt,Bn,Iv,xv,Ql,Ss]}}function mRr(c){const e=c.optionsObjects[0].show==="sample"?_.jsx(E.Fragment,{children:_.jsx(wn,{...c,optionName:"sampleSize",label:"Sample size:",isFloat:!1,min:1,defaultValue:1e3,hasSetButton:!0})}):null;return _.jsxs(E.Fragment,{children:[_.jsx(fh,{...c,optionName:"show",label:"Show:",choices:{ALL:J5.ALL,SAMPLE:J5.SAMPLE},defaultValue:J5.ALL}),e]})}function dRr(c){return _.jsx(fh,{...c,optionName:"logScale",label:"Logarithm:",choices:{NONE:Fo.AUTO,LOG10:Fo.BASE10},defaultValue:Fo.AUTO})}function uRr(c){return _.jsx(wn,{...c,optionName:"horizontalLineValue",label:"Horizontal line value:",hasSetButton:!0,isFloat:!0})}function URr(c){return _.jsx(wn,{...c,optionName:"markerSize",label:"Marker size:",minValue:1,step:1,hasSetButton:!1})}function zRr(c){return _.jsx(x4,{...c,optionName:"opacity",label:"Opacity:",mode:1,step:1,domain:[0,100],values:c.optionsObjects[0].opacity,onUpdate:()=>{}})}function vRr(c){return _.jsx(v1,{...c,optionName:"showHorizontalLine",label:"Horizontal line",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class CRr extends on{getMenuComponents(){const e=[...super.getMenuComponents(),qn,kt,dRr,mRr,zRr,URr,xi,Wt,Bn,vRr];return this.getOptions().showHorizontalLine&&e.push(uRr),e}}class pRr extends wo{getMenuComponents(){const e=[...super.getMenuComponents(),N4];return this.getOptions().displayMode===si.DENSITY&&e.push(kt),e}}function u8(c){return _.jsx(fh,{...c,optionName:"aggregateMethod",label:"Aggregate method:",choices:b3,defaultValue:b3.MEAN})}function PJ(c){return _.jsx(v1,{...c,optionName:"ensemblStyle",label:"Ensembl Style",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class OJ extends on{getMenuComponents(){return[...super.getMenuComponents(),gSr,qn,kt,u8,Ev,xi,Wt,Bn,PJ]}}class QJ extends OJ{}class U8 extends on{constructor(n){super(n);q(this,"numericalTrackConfig");this.numericalTrackConfig=new OJ(n),this.setDefaultOptions(Yn)}getMenuComponents(){return[...this.numericalTrackConfig.getMenuComponents()]}}function qJ(c){return _.jsx(v1,{...c,optionName:"hideMinimalItems",label:"Hide minimal items",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}function DRr(c){return _.jsx(v1,{...c,optionName:"italicizeText",label:"Italicize text",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class bRr extends wo{getMenuComponents(){return[...super.getMenuComponents(),DRr,Ss,qJ]}}function gm(c){return _.jsx(wn,{...c,optionName:"lineWidth",label:"Line width (pixels):",minValue:1,step:1,hasSetButton:!1})}function L4(c){const e=c.optionsObjects[0].scoreScale==="fixed"?_.jsxs(E.Fragment,{children:[_.jsx(wn,{...c,optionName:"scoreMax",label:"Score max:",isFloat:!0,hasSetButton:!0,defaultValue:10}),_.jsx(wn,{...c,optionName:"scoreMin",label:"Score min:",isFloat:!0,hasSetButton:!0,defaultValue:0})]}):null;return _.jsxs(E.Fragment,{children:[_.jsx(fh,{...c,optionName:"scoreScale",label:"Score scale:",choices:{AUTO:Nc.AUTO,FIXED:Nc.FIXED},defaultValue:Nc.AUTO}),e]})}function $J(c){return _.jsx(wn,{...c,optionName:"maxValueFilter",label:"Max value filter:",step:1,hasSetButton:!0})}function rj(c){return _.jsx(wn,{...c,optionName:"minValueFilter",label:"Min value filter:",step:1,hasSetButton:!0})}function ej(c){return _.jsx(v1,{...c,optionName:"bothAnchorsInView",label:"Both anchors in view window",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}function cj(c){return _.jsx(v1,{...c,optionName:"fetchViewWindowOnly",label:"Data in current view (no expansion)",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}function gRr(c){return _.jsx(wn,{...c,optionName:"scalePercentile",label:"Max Score percentile:",isFloat:!0,hasSetButton:!0,defaultValue:95})}function nj(c){return _.jsx(v1,{...c,optionName:"clampHeight",label:"Scale with height",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class _Rr extends on{constructor(e){super(e),this.setDefaultOptions({...im,binSize:_z.AUTO,normalization:Xo.NONE})}getMenuComponents(){const e=[Ei,J7,qn,L4,xi,Wt,Bn,$J,rj,cj,ej];return this.getOptions().scoreScale===Nc.AUTO&&e.splice(4,0,gRr),this.getOptions().displayMode!==e1.HEATMAP&&e.splice(1,0,gm),(this.getOptions().displayMode===e1.HEATMAP||this.getOptions().displayMode===e1.ARC)&&e.push(nj),e}}class ARr extends on{constructor(e){super(e),this.setDefaultOptions(im)}getMenuComponents(){const e=[Ei,J7,qn,L4,xi,Wt,Bn,$J,rj,cj,ej];return this.getOptions().displayMode===e1.ARC&&e.splice(1,0,gm),(this.getOptions().displayMode===e1.HEATMAP||this.getOptions().displayMode===e1.ARC)&&e.push(nj),e}}class yRr extends on{constructor(e){super(e),this.setDefaultOptions(im)}getMenuComponents(){const e=[J7,qn,L4,xi,Wt,Bn];return this.getOptions().displayMode===e1.ARC&&e.splice(1,0,gm),e}}function BRr(c){return _.jsxs(E.Fragment,{children:[_.jsx(wn,{...c,optionName:"maxMethyl",label:"Methylation value max:",isFloat:!0,defaultValue:1,step:.1,minValue:0,hasSetButton:!0}),_.jsx(wn,{...c,optionName:"depthFilter",label:"Depth filter:",isFloat:!1,defaultValue:0,minValue:0,hasSetButton:!0})]})}function ZRr(c){return _.jsx(v1,{...c,optionName:"isCombineStrands",label:"Combine strands",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}const hj="colorsForContext",fRr=["color","background"];class z8 extends E.Component{getContextColors(){if(this.props.optionsObjects.length===1){const e=this.props.optionsObjects[0];return e?e[hj]:null}else return null}handleColorChange(e,n,h){const i=this.getContextColors(),t=this.props.onOptionSet;if(i&&t){const s=Qr.cloneDeep(i);s[e][n]=h,t(hj,s)}}render(){const e=this.getContextColors();if(!e)return null;let n=[];for(let h in e){const i=e[h],t=fRr.map(s=>_.jsx("div",{children:_.jsx(Gz,{color:i[s],onChange:a=>this.handleColorChange(h,s,a.hex)},s)}));n.push(_.jsxs(E.Fragment,{children:[h,t]},h))}return _.jsxs("div",{className:"TrackContextMenu-item",children:[_.jsxs("div",{className:"MethylColorConfig-table",children:[_.jsx("span",{className:"MethylColorConfig-header",children:"Context"}),_.jsx("span",{className:"MethylColorConfig-header",children:"Color"}),_.jsx("span",{className:"MethylColorConfig-header",children:"Background"}),n]}),_.jsx("i",{children:"Add other contexts by specifying them in a data hub."})]})}}q(z8,"propTypes",{optionsObjects:Gr.arrayOf(Gr.object).isRequired,onOptionSet:Gr.func.isRequired});class SRr extends on{getMenuComponents(){return[...super.getMenuComponents(),qn,ZRr,z8,BRr,z8,Bn]}}class MRr extends on{getMenuComponents(){return[...super.getMenuComponents(),Nz,qn,Bn,Ss]}}class GRr extends on{getMenuComponents(){return[...super.getMenuComponents(),Nz,qn,Bn,Ss]}}class NRr extends on{getMenuComponents(){return[...super.getMenuComponents(),qn,zSr,vSr,Bn]}}class WRr extends on{getMenuComponents(){return[...super.getMenuComponents()]}}class TRr extends wo{getMenuComponents(){return[...super.getMenuComponents()]}}class XRr extends wo{getMenuComponents(){const e=[...super.getMenuComponents(),Ss,N4];return this.getOptions().displayMode===si.DENSITY&&e.push(kt),e}}class YRr extends on{getMenuComponents(){return[...super.getMenuComponents(),qn,kt,u8,gm,Ev,Bn]}}class wRr extends on{getMenuComponents(){return[...super.getMenuComponents(),qn,W4,R4,kt,u8,Ev,xi,Iv,Bn]}}function ERr(c){return _.jsx(fh,{...c,optionName:"arrayAggregateMethod",label:"Array Aggregate method:",choices:Az,defaultValue:Az.MEAN})}class xRr extends on{getMenuComponents(){return[Ei,W4,R4,qn,ERr,xi,Iv,Bn]}}function RRr(c){return _.jsx(fh,{...c,optionName:"binSize",label:"Bin size:",defaultValue:_z.AUTO,choices:_z})}function LRr(c){return _.jsx(fh,{optionName:"normalization",label:"Normalization",defaultValue:Xo.NONE,choices:Xo,...c})}class IRr extends on{getMenuComponents(){const e=[Ei,jR,W4,R4,LRr,qn,L4,RRr,xi,Wt,Iv,Bn];return this.getOptions().displayMode!==Yo.HEATMAP&&e.splice(2,0,gm),e}}class VRr extends on{getMenuComponents(){const e=[Ei,jR,W4,R4,qn,L4,xi,Wt,Bn];return this.getOptions().displayMode!==Yo.HEATMAP&&e.splice(2,0,gm),e}}function FRr(c){return _.jsx(x4,{...c,optionName:"imageHeight",label:"Image height:",mode:1,step:1,domain:[36,100],values:c.optionsObjects[0].imageHeight,onUpdate:()=>{}})}class kRr extends on{getMenuComponents(){const e=[Ei,Nz];return this.getOptions().displayMode===si.DENSITY?e.push(qn):e.push(FRr),e.push(Bn),e}}const JRr="https://idr.openmicroscopy.org/webclient/render_image",jRr="",HRr="https://idr.openmicroscopy.org/webclient/img_detail",KRr="https://idr.openmicroscopy.org/webclient/render_thumbnail",PRr="",ORr="https://idr.openmicroscopy.org/webclient/get_thumbnails",QRr="https://idr.openmicroscopy.org/webclient/render_image_region",qRr="0/0/?tile=8,0,0,1024,1024";class $Rr extends kRr{constructor(e){super(e);const n={imageUrl:e.options.renderImageRegion?QRr:JRr,imageUrlSuffix:e.options.renderImageRegion?qRr:jRr,detailUrl:HRr,thumbnailUrl:KRr,thumbnailUrlSuffix:PRr,thumbnailData:ORr};Qr.isEmpty(e.apiConfig)&&(e.apiConfig=n)}}class rLr extends on{constructor(n){super(n);q(this,"bigWigTrackConfig");this.bigWigTrackConfig=new U8(n),this.setDefaultOptions({...q7,zoomLevel:"auto"})}getMenuComponents(n=1){return n<=CL?[Ei,qn,kt,Bn]:this.bigWigTrackConfig.getMenuComponents()}}class eLr extends on{getMenuComponents(){return[Ei,ASr,_Sr,PJ,CSr,pSr,Bn,xv,Ql,N4]}}function cLr(c){return _.jsx(wn,{...c,optionName:"windowSize",label:"Window size (pixels):",minValue:1,step:1,hasSetButton:!0})}class nLr extends on{constructor(n){super(n);q(this,"trackConfig");let h;n.url.endsWith(".gz")?(this.trackConfig=new QJ(n),h={...C1}):(this.trackConfig=new U8(n),h={...C1,zoomLevel:"auto"}),this.setDefaultOptions(h)}getMenuComponents(){return[Ei,cLr,qn,DSr,bSr,Bn]}}class hLr extends wo{getMenuComponents(){const e=[...super.getMenuComponents(),Ss,N4];return this.getOptions().displayMode===si.DENSITY&&e.push(kt),e}}function iLr(c){return _.jsx(wn,{...c,optionName:"pixelsPadding",label:"Padding drawing tick:",minValue:0,step:.1,isFloat:!0,hasSetButton:!0})}function tLr(c){return _.jsx(fh,{optionName:"sortItems",label:"Sort items order",defaultValue:Z4.NONE,choices:Z4,...c})}class sLr extends on{getMenuComponents(){return[...super.getMenuComponents(),ySr,xv,xi,Wt,Ql,Ss,qn,kt,tLr,qJ,iLr]}}const ij={bed:wxr,categorical:GSr,bigbed:pRr,bigwig:U8,hic:_Rr,longrange:ARr,bedcolor:Exr,biginteract:yRr,geneannotation:bRr,refbed:TRr,methylc:SRr,repeatmasker:MRr,rmskv2:GRr,genomealign:NRr,ruler:WRr,matplot:YRr,vcf:eLr,dynseq:rLr,omeroidr:$Rr,bam:Xxr,snp:XRr,dynamiclongrange:VRr,dynamicbed:lRr,dbedgraph:xRr,dynamichic:IRr,jaspar:hLr,boxplot:nLr,qbed:CRr,bedgraph:QJ,dynamic:wRr,modbed:sLr},aLr=on;if(Ke.env.NODE_ENV!=="production"){for(const c in ij)if(c.toLowerCase()!==c)throw new TypeError(`Type names may not contain uppercase letters. Offender: "${c}"`)}function v8(c){let e=c.type||c.filetype||"";e=e.toLowerCase();const n=ij[e];return n?new n(c):new aLr(c)}const oLr=["bigwig","bedgraph"];function lLr(c){const e=c.title!==void 0?c.title:`${c.numTracks} tracks selected`;return _.jsx("div",{style:{paddingLeft:5,fontWeight:"bold"},children:e})}function mLr(c){return c.tracks.length===1||c.tracks.map(h=>h.type).some(h=>!oLr.includes(h))?null:_.jsx("div",{className:"TrackContextMenu-item",children:_.jsx("button",{className:"btn btn-info btn-sm btn-tight",onClick:()=>c.onApplyMatplot(c.tracks,"matplot"),children:"Apply matplot"})})}function dLr(c){return _.jsxs("div",{onClick:()=>c.onClick(c.trackId),className:"TrackContextMenu-item TrackContextMenu-hoverable-item-danger",children:["❌"," ",c.numTracks>1?`Remove ${c.numTracks} tracks`:"Remove"]})}function uLr(c){const{tracks:e,fileInfos:n,onOptionSet:h}=c,i=e.map(v8),t=i.map(U=>U.getOptions()),s=i.map(U=>U.isHicTrack());if(!Qr.every(s,Boolean))return null;const a=[],o=[];n&&Object.keys(n).forEach(U=>{a.push(n[U].resolutions),o.push(n[U].normOptions)});const l=Qr.intersection(...a),m=Qr.intersection(...o),d={AUTO:0},u={NONE:"NONE"};return l.forEach(U=>d[bN(U)]=U),m.forEach(U=>u[U]=U),_.jsxs(_.Fragment,{children:[_.jsx(fh,{optionName:"binSize",label:"Bin size:",defaultValue:d.AUTO,choices:d,optionsObjects:t,onOptionSet:h}),_.jsx(fh,{optionName:"normalization",label:"Normalization",defaultValue:u.NONE,choices:u,optionsObjects:t,onOptionSet:h})]})}function C8(c){const{title:e,content:n}=c;if(typeof n=="string")return _.jsx("div",{children:n});const h=Object.entries(n).map((t,s)=>{let a;return E.isValidElement(t[1])?a=t[1]:go(t[1])?a=_.jsx(C8,{content:t[1]}):a=Array.isArray(t[1])?t[1].join(" > "):t[1],_.jsxs("tr",{children:[_.jsx("td",{children:t[0]}),_.jsx("td",{children:a})]},s)}),i=e?_.jsx("h6",{children:e}):"";return _.jsxs(E.Fragment,{children:[i,_.jsx("table",{className:"table table-sm table-striped",children:_.jsx("tbody",{children:h})})]})}function ULr(c){const e=c.track;let n=[];return e.details&&n.push(_.jsx("div",{children:_.jsx(C8,{title:"Details",content:e.details})},"details")),e.url&&n.push(_.jsxs("div",{children:[_.jsxs("h6",{children:["URL ",_.jsx(bm,{value:e.url})]}),_.jsx("p",{className:"TrackContextMenu-URL",children:e.url})]},"url")),e.indexUrl&&n.push(_.jsxs("div",{children:[_.jsxs("h6",{children:["Index URL ",_.jsx(bm,{value:e.indexUrl})]}),_.jsx("p",{className:"TrackContextMenu-URL",children:e.indexUrl})]},"indexUrl")),e.metadata&&n.push(_.jsx("div",{children:_.jsx(C8,{title:"Metadata",content:e.metadata})},"metadata")),_.jsx(Txr,{trigger:"More information",children:_.jsx("div",{className:"TrackContextMenu-item",children:n})})}function zLr(c){const e=c.menuData,n=c.darkTheme,h=E.useRef(null),[i,t]=E.useState({left:0,top:0}),s=e.pageX||0,a=e.pageY||0,o=E.useMemo(()=>e.items.map((l,m)=>_.jsx(l,{optionsObjects:e.configOptions,defaultValue:void 0,onOptionSet:e.onConfigChange,trackId:e.trackId},m)),[e.items,e.configOptions,e.onConfigChange,e.trackId]);return E.useEffect(()=>{if(h.current){h.current.getBoundingClientRect();let l=s-19,m=a-167;t({left:l,top:m})}},[s,a]),_.jsx("div",{ref:h,style:{position:"absolute",left:i.left,top:i.top,color:n?"white":"black",zIndex:1e3,pointerEvents:"auto"},children:_.jsxs("div",{className:"TrackContextMenu-body",style:{backgroundColor:n?"black":"white"},children:[_.jsx(lLr,{title:e.selectCount>1?e.selectCount+" tracks selected":e.selectCount===1&&e.tracks&&e.tracks[0]&&e.tracks[0].options&&e.tracks[0].options.label?e.tracks[0].options.label:"(unnamed track)",numTracks:e.selectCount}),_.jsx(uLr,{tracks:e.tracks,fileInfos:e.fileInfos,onOptionSet:e.onConfigChange}),o,_.jsx(dLr,{onClick:e.handleDelete,trackId:e.configOptions.map(l=>l.trackId),numTracks:e.selectCount}),_.jsx(mLr,{tracks:e.tracks,onApplyMatplot:e.handleAdd}),e.tracks.length===1?_.jsx(ULr,{track:e.tracks[0]}):""]})})}const vLr=E.memo(zLr);function CLr(c,e){let n;return c.initial===1?n=-c.startWindow:c.side==="right"?n=Math.floor(-c.xDist/e)*e-c.startWindow:c.side==="left"&&(n=Math.floor(c.xDist/e)*e-c.startWindow),n}const p8=["#000000","#00FF00","#0000FF","#FF0000","#01FFFE","#FFA6FE","#FFDB66","#006401","#010067","#95003A","#007DB5","#FF00F6","#FFEEE8","#774D00","#90FB92","#0076FF","#D5FF00","#FF937E","#6A826C","#FF029D","#FE8900","#7A4782","#7E2DD2","#85A900","#FF0056","#A42400","#00AE7E","#683D3B","#BDC6FF","#263400","#BDD393","#00B917","#9E008E","#001544","#C28C9F","#FF74A3","#01D0FF","#004754","#E56FFE","#788231","#0E4CA1","#91D0CB","#BE9970","#968AE8","#BB8800","#43002C","#DEFF74","#00FFC6","#FFE502","#620E00","#008F9C","#98FF52","#7544B1","#B500FF","#00FF78","#FF6E41","#005F39","#6B6882","#5FAD4E","#A75740","#A5FFD2","#FFB167","#009BFF","#E85EBE"],pLr="rgba(173, 216, 230, 0.9)",Vv=16;function DLr(c){let e=0;for(let n=0;n<c.length;n++){const h=c.charCodeAt(n);e=(e<<5)-e+h,e=e&e}return e}const bLr=({track:c,terms:e=[],onClick:n=()=>{},height:h})=>{const i=s=>{if(!s)return"white";const a=Math.abs(DLr(s))%p8.length;return p8[a]},t=s=>{let a;if(a=c.getMetadataAsis(s),go(a)&&a.name&&a.color)return _.jsx(tj,{color:a.color,term:s,termValue:a.name,onClick:o=>n(s,a.name)},s);{a=c.getMetadata(s);const o=i(a);return _.jsx(tj,{color:o,term:s,termValue:a,onClick:l=>n(s,a)},s)}};return _.jsx("div",{style:{display:"flex",height:h},children:e.map(s=>t(s))})},tj=({color:c,term:e,termValue:n,onClick:h})=>{const[i,t]=E.useState(!1),[s,a]=E.useState({x:0,y:0}),o=U=>{a({x:U.pageX,y:U.pageY}),t(!0)},l=()=>t(!1),m={backgroundColor:c,width:15,height:"100%",borderLeft:"1px solid lightgrey"},d=Object.assign({marginTop:Vv,pointerEvents:"auto"}),u=()=>i?je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:U})=>_.jsx("div",{ref:U,style:{position:"absolute",left:s.x-8*2,top:s.y}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:U,style:C,placement:p,arrowProps:D})=>_.jsxs("div",{ref:U,style:{...C,...d,zIndex:1001},className:"Tooltip",children:[_.jsxs("div",{className:"Tooltip-minor-text",children:[e,":"]}),_.jsx("div",{children:n||"(no value)"}),je.createPortal(_.jsx("div",{ref:D.ref,style:{...D.style,width:0,height:0,position:"absolute",left:s.x-8,top:s.y,borderLeft:`${Vv/2}px solid transparent`,borderRight:`${Vv/2}px solid transparent`,borderBottom:`${Vv}px solid ${pLr}`}}),document.body)]})})]}),document.body):null;return _.jsx("div",{style:m,onClick:h,onMouseEnter:o,onMouseLeave:l,children:u()})},sj={bigwig:"",bedgraph:"",methylc:"",boxplot:"",qbed:"",vcf:"",dynseq:"",matplot:"",longrange:"",hic:""},D8={bigwig:"",bedgraph:""};class gLr{constructor(){q(this,"aggregator");q(this,"dynseqAggregator");q(this,"aggregateRecords");q(this,"aggregateFeaturesMatplot");this.aggregator=new w5,this.aggregateRecords=(e,n,h)=>{const t=new jl().makeXMap(e,n,h);return(t.xToFeaturesForward?t.xToFeaturesForward:[]).map(Eo.aggregateByStrand)}}getGroupScale(e,n,h,i,t,s){if(n){const a={};for(let o=0;o<e.length;o++)if(e[o].options.group&&e[o].type in D8){const l=e[o].options.group,m=e[o].id;if(e[o].options.yScale===Nc.FIXED){a[l]={scale:Nc.FIXED,min:{[m]:e[o].options.yMin},max:{[m]:e[o].options.yMax}};break}if(n[m]){const d=n[m].data;let u;s.current[m][t].xvalues?u=s.current[m][t].xvalues:(u=this.aggregator.xToValueMaker(d,n[m].visRegion,h,n[m].configOptions),s.current[m][t]||(s.current[m][t]={}),s.current[m][t].xvalues=u);const U=u[0]&&u[0].length?Qr.max(u[0].slice(i.start,i.end)):1,C=u[1]&&u[1].length?Qr.min(u[1].slice(i.start,i.end)):0;a.hasOwnProperty(l)?(a[l].min[m]=C,a[l].max[m]=U):a[l]={scale:Nc.AUTO,min:{[m]:C},max:{[m]:U}}}}else{const l=e[o].id;if(n[l]){const m=n[l].data;let d;if(s.current[l][t].xvalues&&n[l].usePrimaryNav)continue;e[o].type==="dynseq"?d=this.aggregator.xToValueMaker(m,n[l].visRegion,h,n[l].configOptions):e[o].type==="methylc"?d=this.aggregateRecords(m,n[l].visRegion,h):e[o].type==="matplot"?d=m.map(u=>this.aggregator.xToValueMaker(u,n[l].visRegion,h,n[l].configOptions)[0]):d=this.aggregator.xToValueMaker(m,n[l].visRegion,h,n[l].configOptions),s.current[l][t]||(s.current[l][t]={}),s.current[l][t].xvalues=d}}return Qr.isEmpty(a)?{}:a}return{}}getGroupScaleWithXvalues(e,n,h){if(n){const i={};for(let t=0;t<e.length;t++){if(!(e[t].type in D8)||!e[t].options.group)continue;const s=e[t].options.group,a=e[t].id;if(e[t].options.yScale===Nc.FIXED){i[s]={scale:Nc.FIXED,min:{[a]:e[t].options.yMin},max:{[a]:e[t].options.yMax}};break}if(n[a]){const o=n[a],l=o[0]&&o[0].length?Qr.max(o[0].slice(h.start,h.end)):1,m=o[1]&&o[1].length?Qr.min(o[1].slice(h.start,h.end)):0;i.hasOwnProperty(s)?(i[s].min[a]=m,i[s].max[a]=l):i[s]={scale:Nc.AUTO,min:{[a]:m},max:{[a]:l}}}}return Qr.isEmpty(i)?{}:i}return{}}}const _Lr=({buttonLabel:c,children:e,className:n,height:h,xOffset:i=0,isVisible:t=!0,color:s})=>{const[a,o]=E.useState(!1),l=E.useRef(null);return E.useEffect(()=>{function m(d){l.current&&!l.current.contains(d.target)&&o(!1)}return a&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[a]),_.jsxs("div",{ref:l,className:`popover-root ${n||""}`,style:{position:"absolute",top:h-16,left:i,visibility:t?"visible":"hidden",pointerEvents:t?"auto":"none",opacity:t?1:0},children:[_.jsxs("button",{type:"button",className:`popover-btn${a?" open":""}`,onClick:()=>o(m=>!m),style:{zIndex:10,width:120},children:[_.jsxs("div",{style:{fontStyle:"italic"},children:[c," "]}),_.jsx("div",{className:"loader"}),_.jsx("span",{className:`popover-arrow${a?" open":""}`})]}),_.jsx("div",{className:`popover-panel${a?" open":""}`,style:a?{position:"absolute",top:"100%",left:0,zIndex:10,maxWidth:"300px",maxHeight:"200px",overflow:"auto",backgroundColor:"white",border:"1px solid #ccc",borderRadius:"4px",padding:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}:{display:"none"},children:e})]})};class h2 extends E.PureComponent{render(){const{feature:e,category:n,queryEndpoint:h}=this.props,i=n?n[e.getName()].name:e.getName();let t;if(e.id)if(Qr.isEmpty(h))if(String(e.id).startsWith("ENS")){const s=`http://www.ensembl.org/Multi/Search/Results?q=${e.id}`;t=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:["Ensembl",_.jsx("span",{role:"img","aria-label":"Ensembl",children:"🔗"})]})}else{const s=`https://www.ncbi.nlm.nih.gov/gene/?term=${String(e.id).split(".")[0]}`;t=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:["NCBI",_.jsx("span",{role:"img","aria-label":"NCBI",children:"🔗"})]})}else{const s=`${h.endpoint}${String(e.id)}`;t=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:[h.name,_.jsx("span",{role:"img","aria-label":h.name,children:"🔗"})]})}return _.jsxs("div",{children:[i?_.jsxs("div",{className:"Tooltip-major-text",children:[i," ",_.jsx(bm,{value:i})," "]}):null,e.id?_.jsxs("div",{children:[e.id," ",t]}):null,_.jsxs("div",{children:[e.getLocus().toString()," (",e.getLocus().getLength(),"bp)"]}),e.getHasStrand()?_.jsxs("div",{children:["Strand: ",e.getStrand()]}):null]})}}q(h2,"propTypes",{feature:Gr.instanceOf(vc).isRequired,category:Gr.object,queryEndpoint:Gr.object});class ALr extends E.PureComponent{render(){const{feature:e}=this.props,n=e.getName(),h=e.matrixId,i=e.strand==="-"?"?revcomp=1":"",t=e.strand==="-"?".rc":"",s=`https://jaspar.genereg.net/matrix/${h}/${i}`,a=`https://jaspar.genereg.net/static/logos/all/svg/${h}${t}.svg`,o=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:["view in Jaspar database",_.jsx("span",{role:"img","aria-label":"jaspar",children:"🔗"})]});return _.jsxs("div",{children:[n?_.jsx("div",{className:"Tooltip-major-text",children:n}):null,h?_.jsxs("div",{children:[h," ",o]}):null,_.jsxs("div",{children:["Score: ",e.score]}),_.jsx("div",{style:{textAlign:"center"},children:_.jsx("img",{alt:h,className:"img-fluid",style:{maxWidth:"100%",height:225},src:a})}),_.jsxs("div",{children:[e.getLocus().toString()," (",e.getLocus().getLength(),"bp)"]}),e.getHasStrand()?_.jsxs("div",{children:["Strand: ",e.getStrand()]}):null]})}}const aj=({gene:c,queryEndpoint:e})=>{const n=SD(c),h=BN(c.description);let i;if(go(h)){let t;h.hasOwnProperty("maneStat")?t=_.jsxs(_.Fragment,{children:[_.jsx("tr",{children:_.jsx("td",{colSpan:2,children:_.jsx("i",{style:{wordBreak:"break-word"},children:h.description})})}),_.jsxs("tr",{children:[_.jsx("td",{children:"Ensembl id:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ensembl.org/Homo_sapiens/Transcript/Summary?t=${h["Ensembl id"]}`,target:"_blank",rel:"noopener noreferrer",children:h["Ensembl id"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"Ensembl gene:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ensembl.org/homo_sapiens/Gene/Summary?g=${h["Ensembl gene"]}&db=core}`,target:"_blank",rel:"noopener noreferrer",children:h["Ensembl gene"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"Ensembl protein:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ensembl.org/Homo_sapiens/Transcript/Summary?t=${h["Ensembl protein"]}`,target:"_blank",rel:"noopener noreferrer",children:h["Ensembl protein"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"NCBI id:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ncbi.nlm.nih.gov/nuccore/${h["NCBI id"]}`,target:"_blank",rel:"noopener noreferrer",children:h["NCBI id"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"NCBI gene:"}),_.jsx("td",{children:h["NCBI gene"]})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"NCBI protein:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ncbi.nlm.nih.gov/nuccore/${h["NCBI protein"]}`,target:"_blank",rel:"noopener noreferrer",children:h["NCBI protein"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"MANE transcript status:"}),_.jsx("td",{children:h.maneStat})]})]}):(t=Object.entries(h).map(([s,a],o)=>_.jsxs("tr",{children:[_.jsxs("td",{children:[s,":"]}),_.jsx("td",{children:a})]},o)),i=_.jsx("table",{className:"table table-sm table-striped",children:_.jsx("tbody",{children:t})}))}else i=_.jsx("i",{style:{wordBreak:"break-word"},children:h});return _.jsxs("div",{style:{maxWidth:400},children:[_.jsx(h2,{feature:c,queryEndpoint:e}),i,_.jsx("div",{children:c.transcriptionClass&&_.jsxs("span",{children:["Transcription class:"," ",_.jsx("span",{style:{color:n.color},children:c.transcriptionClass})]})})]})},oj=({snp:c})=>{const e=`https://www.ncbi.nlm.nih.gov/snp/?term=${c.id}`,n=_.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:["dbSNP",_.jsx("span",{role:"img","aria-label":"dbsnp",children:"🔗"})]});return _.jsxs("div",{children:[_.jsxs("div",{children:[c.id," ",n]}),_.jsxs("div",{children:[c.getLocus().toString()," (",c.getLocus().getLength(),"bp)"]}),c.getHasStrand()?_.jsxs("div",{children:["Strand: ",c.getStrand()]}):null]})},b8=10;class yLr extends E.PureComponent{render(){const{vcf:e}=this.props,n=e.variant.ID;let h,i={};if(n)if(n.length===1){const s=`https://www.ncbi.nlm.nih.gov/snp/${n[0]}`;h=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:[n[0],_.jsx("span",{role:"img","aria-label":"dbSNP",children:"🔗"})]})}else h=n.map(s=>_.jsxs("a",{href:`https://www.ncbi.nlm.nih.gov/snp/${s}`,target:"_blank",rel:"noopener noreferrer",children:[s,_.jsx("span",{role:"img","aria-label":"dbSNP",children:"🔗"})]},s));const t=Object.keys(e.variant.SAMPLES);return t.slice(0,b8).forEach(s=>i[s]=e.variant.SAMPLES[s]),_.jsxs("div",{children:[n?_.jsxs("div",{className:"Tooltip-major-text",children:[h," ",_.jsx(bm,{value:n.join(", ")})]}):null,_.jsxs("div",{children:[_.jsx("table",{className:"table table-sm",style:{marginBottom:0,lineHeight:1},children:_.jsxs("tbody",{children:[_.jsxs("tr",{children:[_.jsx("th",{children:"REF"}),_.jsx("td",{style:{wordBreak:"break-all",maxWidth:"300px"},children:e.variant.REF})]}),_.jsxs("tr",{children:[_.jsx("th",{children:"ALT"}),_.jsx("td",{style:{wordBreak:"break-all",maxWidth:"300px"},children:e.variant.ALT.join(", ")})]}),_.jsxs("tr",{children:[_.jsx("th",{children:"QUAL"}),_.jsx("td",{children:e.variant.QUAL})]})]})}),_.jsxs("div",{children:[e.getLocus().toString()," (",e.getLocus().getLength(),"bp)"]}),_.jsx("div",{children:ZLr(e.variant.INFO)}),_.jsxs("div",{children:[t&&t.length>0&&_.jsxs("span",{children:["Sample count: ",t.length]}),t&&t.length>b8&&_.jsxs("span",{children:["Showing first ",b8," samples:"]}),!Qr.isEmpty(i)&&BLr(i)]})]})]})}}const BLr=c=>{if(!c)return null;const e=Object.keys(c),n=Object.keys(c[e[0]]),h=e.map((t,s)=>_.jsxs("tr",{children:[_.jsx("td",{children:t}),n.map((a,o)=>_.jsx("td",{children:Array.isArray(c[t][a])?c[t][a].join(","):c[t][a]},o))]},s)),i=_.jsxs("tr",{children:[_.jsx("th",{children:"Sample"}),n.map((t,s)=>_.jsx("th",{children:t},s))]});return _.jsx("table",{className:"table table-bordered table-striped table-sm",style:{marginBottom:0,lineHeight:1,fontSize:12},children:_.jsxs("tbody",{children:[i,h]})})},ZLr=c=>{if(!c)return null;const e=Object.keys(c),n=_.jsx("tr",{children:e.map((i,t)=>_.jsx("td",{children:Array.isArray(c[i])?Qr.truncate(c[i].join(","),{length:75,separator:/[,; ]/}):c[i]},t))}),h=_.jsx("tr",{children:e.map((i,t)=>_.jsx("th",{children:i},t))});return _.jsx("table",{className:"table table-bordered table-striped table-sm",style:{marginBottom:0,lineHeight:1,fontSize:12},children:_.jsxs("tbody",{children:[h,n]})})},ji="rgba(173, 216, 230, 0.9)",fe=16,_m={bigbed:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(h2,{feature:e,category:void 0,queryEndpoint:void 0})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},geneannotation:function({gene:e,pageX:n,pageY:h,name:i,onClose:t,isThereG3dTrack:s,setShow3dGene:a}){const o=Object.assign({marginTop:fe,pointerEvents:"auto"});return _.jsxs(wh,{children:[_.jsx(r1,{children:({ref:m})=>_.jsx("div",{ref:m,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:m,style:d,placement:u,arrowProps:U})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:m,style:{...d,...o,zIndex:1001},className:"Tooltip",children:_.jsxs(Zh,{onOutsideClick:t,children:[_.jsx(aj,{gene:e,collectionName:i,queryEndpoint:{}}),s?_.jsx("div",{children:_.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>a?a(e):()=>{},children:"Show in 3D"})}):""]})}),_.jsx("div",{ref:U.ref,style:{...U.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]})},refbed:function({gene:e,pageX:n,pageY:h,name:i,onClose:t,isThereG3dTrack:s,setShow3dGene:a}){const o=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:l})=>_.jsx("div",{ref:l,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:l,style:m,placement:d,arrowProps:u})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:l,style:{...m,...o,zIndex:1001},className:"Tooltip",children:_.jsxs(Zh,{onOutsideClick:t,children:[_.jsx(aj,{gene:e,collectionName:i,queryEndpoint:{}}),s?_.jsx("div",{children:_.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>a?a(e):()=>{},children:"Show in 3D"})}):""]})}),_.jsx("div",{ref:u.ref,style:{...u.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},bed:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(h2,{feature:e,category:void 0,queryEndpoint:void 0})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},bedcolor:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(h2,{feature:e,category:void 0,queryEndpoint:void 0})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},repeatmasker:function({feature:e,pageX:n,pageY:h,name:i,onClose:t,trackModel:s}){const a=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:o})=>_.jsx("div",{ref:o,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:o,style:l,placement:m,arrowProps:d})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:o,style:{...l,...a,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsxs("div",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"Tooltip-major-text",style:{marginRight:5},children:e.getName()}),_.jsx("span",{className:"Tooltip-minor-text",children:e.getClassDetails()})]}),_.jsxs("div",{children:[e.getLocus().toString()," (",e.getLocus().getLength(),"bp)"]}),_.jsxs("div",{children:["(1 - divergence%) = ",e.repeatValue.toFixed(2)]}),_.jsxs("div",{children:["strand: ",e.strand]}),_.jsx("div",{className:"Tooltip-minor-text",children:s.getDisplayLabel()})]})})}),_.jsx("div",{ref:d.ref,style:{...d.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},omeroidr:function({snp:e,pageX:n,pageY:h,onClose:i}){const t=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:s})=>_.jsx("div",{ref:s,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:s,style:a,placement:o,arrowProps:l})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:s,style:{...a,...t,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:i,children:_.jsx(oj,{snp:e})})}),_.jsx("div",{ref:l.ref,style:{...l.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},bam:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"}),a=e.getAlignment();return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:o})=>_.jsx("div",{ref:o,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:o,style:l,placement:m,arrowProps:d})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:o,style:{...l,...s,zIndex:1001},className:"Tooltip",children:_.jsxs(Zh,{onOutsideClick:t,children:[_.jsx(h2,{feature:e,category:void 0,queryEndpoint:void 0}),_.jsxs("div",{style:{fontFamily:"monospace",whiteSpace:"pre"},children:[_.jsxs("div",{children:["Ref ",a.reference]}),_.jsxs("div",{children:[" ",a.lines]}),_.jsxs("div",{children:["Read ",a.read]})]})]})}),_.jsx("div",{ref:d.ref,style:{...d.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},snp:function({snp:e,pageX:n,pageY:h,name:i="",onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(oj,{snp:e})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},categorical:function({feature:e,pageX:n,pageY:h,name:i,onClose:t,configOptions:s}){const a=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:o})=>_.jsx("div",{ref:o,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:o,style:l,placement:m,arrowProps:d})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:o,style:{...l,...a,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(h2,{feature:e,category:s.category,queryEndpoint:void 0})})}),_.jsx("div",{ref:d.ref,style:{...d.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},vcf:function({vcf:e,pageX:n,pageY:h,name:i,onClose:t}){return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:s})=>_.jsx("div",{ref:s,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:s,style:a,placement:o,arrowProps:l})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:s,style:{...a,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(yLr,{vcf:e})})}),_.jsx("div",{ref:l.ref,style:{...l.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},jaspar:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(ALr,{feature:e})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},normModbed:function({bs:e,pageX:n,pageY:h,feature:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsxs("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:[_.jsx(Zh,{onOutsideClick:t,children:_.jsxs("div",{children:[e&&`position ${e} in`," ",i.getName()," read"]})}),_.jsx("div",{children:i.getName()})]})})]}),document.body)},barModbed:function({feature:e,pageX:n,pageY:h,onCount:i,onPct:t,total:s,onClose:a}){const o=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:l})=>_.jsx("div",{ref:l,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:l,style:m,placement:d,arrowProps:u})=>_.jsxs("div",{ref:l,style:{...m,...o,zIndex:1001},className:"Tooltip",children:[_.jsx(Zh,{onOutsideClick:a,children:_.jsxs("div",{children:[i,"/",s," (",`${(t*100).toFixed(2)}%`,")"]})}),_.jsx("div",{children:e.getName()})]})})]}),document.body)}},fLr=({numHidden:c,height:e,xOffset:n=0,isVisible:h=!1,color:i})=>{const[t,s]=E.useState(!1),[a,o]=E.useState(!0),l=E.useRef(null);return E.useEffect(()=>{function m(d){l.current&&!l.current.contains(d.target)&&s(!1)}return t&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[t]),_.jsx("div",{ref:l,style:{position:"absolute",top:e-16,left:a?0:n,visibility:h?"visible":"hidden",zIndex:10,pointerEvents:"none"},children:a?_.jsxs("div",{onClick:()=>o(!1),className:"popover-btn",style:{width:120,gap:"0.5em",position:"relative",verticalAlign:"top",padding:"0 7px 0 5px",fontStyle:"italic",pointerEvents:"auto"},children:[_.jsxs("span",{style:{textAlign:"left"},children:[c," items hidden"]}),_.jsx("span",{className:`popover-arrow${t?" open":""}`})]}):_.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",pointerEvents:"none"},children:_.jsx("div",{style:{gap:"0.8em",alignItems:"center",color:i,fontFamily:"BlinkMacSystemFont, -apple-system, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif",fontSize:"0.8rem",height:"16px",position:"relative",verticalAlign:"top",whiteSpace:"nowrap",pointerEvents:"none"},children:_.jsxs("div",{style:{fontStyle:"italic",pointerEvents:"none"},children:[c," items hidden - zoom"," ",_.jsx("span",{onClick:()=>o(!0),style:{fontSize:"12px",color:"#007acc",cursor:"pointer",textDecoration:"underline",pointerEvents:"auto"},children:"dismiss"})]})})})})};function lj(c){const e=c.length>0?Math.max(...c.map(h=>{var i;return((i=h.dataCache)==null?void 0:i.length)||0})):0,n=new Array(e);for(let h=0;h<e;h++)n[h]=[];for(let h=0;h<c.length;h++){const t=c[h].dataCache;for(let s=0;s<t.length;s++){const a=t[s];n[s].push(a)}}return n}const Fv={biginteract:"",dynamichic:"",dynamiclongrange:"",hic:"",longrange:"",genomealign:""},SLr=2,MLr=E.memo(function({trackManagerRef:e,basePerPixel:n,updateGlobalTrackConfig:h,side:i,windowWidth:t=0,genomeConfig:s,trackModel:a,dataIdx:o,signalTrackLoadComplete:l,trackIdx:m,id:d,setShow3dGene:u,isThereG3dTrack:U,viewWindowConfigChange:C,applyTrackConfigChange:p,sentScreenshotData:D,dragX:A,newDrawData:f,trackFetchedDataCache:M,globalTrackState:S,isScreenShotOpen:N,posRef:x,highlightElements:B,viewWindowConfigData:W,metaSets:T,onColorBoxClick:L,messageData:I,Toolbar:J,handleRetryFetchTrack:$,initialLoad:sr}){var g0;const vr=E.useRef(eh[a.type]?{...eh[`${a.type}`].defaultOptions}:{...eh.error.defaultOptions}),pr=E.useRef(!0),dr=E.useRef(0),zr=E.useRef("right"),tr=E.useRef(void 0),er=E.useRef(!1),H=E.useRef(0),[O,Q]=E.useState(null),[k,rr]=E.useState(),[mr,yr]=E.useState(!1),[Sr,Hr]=E.useState(null);function wr(z0){let m0=eh[`${a.type}`].ROW_HEIGHT,u0=vr.current,E0=Math.min(z0,u0.maxRows);return u0.hideMinimalItems&&(E0-=1),E0<1&&(E0=1),a.type==="modbed"?(E0+1)*m0+2:E0*m0+SLr}function Jr(z0,m0,u0,E0=null){const B0=CLr(z0,t),_0=c8({basesByPixel:n,genesArr:m0,genomeConfig:s,genomeName:s.genome.getName(),trackState:z0,windowWidth:t,configOptions:vr.current,renderTooltip:a.type==="modbed"?Pr:kr,svgHeight:dr,updatedLegend:tr,trackModel:a,getGenePadding:eh[`${a.type}`]?eh[`${a.type}`].getGenePadding:eh.error.getGenePadding,getHeight:wr,ROW_HEIGHT:eh[`${a.type}`]?eh[`${a.type}`].ROW_HEIGHT:eh.error.ROW_HEIGHT,groupScale:z0.groupScale,xvaluesData:E0,onClose:xr,errorInfo:er.current,handleRetryFetchTrack:$,initialLoad:sr.current});if(u0===o){l(d),zr.current=i;let w0,x0=0;typeof _0=="object"&&Object.prototype.hasOwnProperty.call(_0,"numHidden")?(w0=_0.component,x0=_0.numHidden):w0=_0,Q({component:w0,dataIdx:u0,numHidden:x0}),H.current=B0}}function xr(){rr(null)}function kr(z0,m0){const u0=_m[`${a.type}`]({gene:m0,feature:m0,snp:m0,vcf:m0,trackModel:a,pageX:z0.pageX,pageY:z0.pageY,name:s.genome._name,onClose:xr,isThereG3dTrack:U,setShow3dGene:u,configOptions:vr.current});yr(!0),rr(je.createPortal(u0,document.body))}function Pr(z0,m0,u0,E0,B0="",_0="",w0=""){let x0;E0==="norm"?x0=_m.normModbed({bs:u0,pageX:z0.pageX,pageY:z0.pageY,feature:m0,onClose:xr}):x0=_m.barModbed({feature:m0,pageX:z0.pageX,pageY:z0.pageY,onCount:B0,onPct:_0,total:w0,onClose:xr}),yr(!0),rr(x0)}E.useEffect(()=>{O&&O.dataIdx===o&&Hr(tr.current)},[O]);function D0({cacheTrackData:z0,trackState:m0,viewWindow:u0,groupScale:E0,xvalues:B0,isInit:_0,matplotCheck:w0,skipNoData:x0}){var L0;const a0=m0.genomicFetchCoord[m0.primaryGenName].primaryVisData;if(z0.trackType!=="genomealign"){let ce=!z0.usePrimaryNav&&((L0=m0.genomicFetchCoord[z0.queryGenome])!=null&&L0.queryRegion)?m0.genomicFetchCoord[z0.queryGenome].queryRegion:a0.visRegion;m0.visRegion=ce}if(m0.visWidth=a0.visWidth?a0.visWidth:t*3,m0.dataIdx=o,_0&&pr.current&&(G4.has(a.type)&&(vr.current.trackManagerRef=e),vr.current={...vr.current,...a.options},h({configOptions:vr.current,trackModel:a,id:d,trackIdx:m,usePrimaryNav:z0.usePrimaryNav}),pr.current=!1),vr.current.usePrimaryNav=z0.usePrimaryNav,er.current=z0.Error?z0.Error:null,er.current){m0.recreate=!1,Jr(m0,[],o,null);return}if(!z0.useExpandedLoci&&z0.usePrimaryNav){let ce=[],le=o+1,ve=!1;for(let or=0;or<3;or++){if(!z0[le]||!z0[le].dataCache){ve=!0;continue}ce.push(z0[le]),le--}GJ.has(a.type)&&(z0[`${o}`]&&z0[`${o}`].xvalues?ce=[]:ce=lj(ce)),(!ve||x0)&&(u0&&(m0.viewWindow=u0),E0!==void 0&&(m0.groupScale=E0),Jr(m0,ce,o,B0||null))}else{const ce=z0[o]?z0[o].dataCache:null;u0&&(m0.viewWindow=u0),ce&&Jr(m0,ce,o,B0||null)}}return E.useEffect(()=>{var z0;if(f.completedFetchedRegion&&f.completedFetchedRegion.current.done[d]===!1){if(o===f.completedFetchedRegion.current.key)f.completedFetchedRegion.current.done[d]=!0;else return;if(!M.current[`${d}`]||!S.current.trackStates[o]||!S.current.trackStates[o].trackState.genomicFetchCoord)return;const m0=M.current[`${d}`];let u0={...S.current.trackStates[o].trackState};D0({cacheTrackData:m0,trackState:u0,viewWindow:f.viewWindow,groupScale:S.current.trackStates[o].trackState.groupScale,xvalues:(z0=m0[o])==null?void 0:z0.xvalues,isInit:!0,matplotCheck:!0,skipNoData:!1})}},[f]),E.useEffect(()=>{var z0,m0;if(O!==null&&d in p){vr.current={...vr.current,...p[`${d}`]},h({configOptions:vr.current,trackModel:a,id:d,trackIdx:m});let u0=o,E0=M.current[`${d}`],B0=Qr.cloneDeep(S.current.trackStates[u0].trackState);B0.recreate=!0,D0({cacheTrackData:E0,trackState:B0,viewWindow:(z0=W.current)==null?void 0:z0.viewWindow,groupScale:S.current.trackStates[o].trackState.groupScale,xvalues:(m0=E0[o])==null?void 0:m0.xvalues,isInit:!1,matplotCheck:!0,skipNoData:!1})}},[p]),E.useEffect(()=>{var z0;if(C&&d in C.trackToDrawId&&(a.type in sj||vr.current.displayMode==="density")){let m0=Qr.cloneDeep(S.current.trackStates[o].trackState),u0=M.current[`${d}`];m0.recreate=!0,D0({cacheTrackData:u0,trackState:m0,viewWindow:C.viewWindow,groupScale:S.current.trackStates[o].trackState.groupScale,xvalues:(z0=u0[o])==null?void 0:z0.xvalues,isInit:!1,matplotCheck:!0,skipNoData:!1})}},[C]),E.useEffect(()=>{if(N){async function z0(){let m0=o,u0=M.current[`${d}`],E0=[],B0=Qr.cloneDeep(S.current.trackStates[m0].trackState);if(u0.useExpandedLoci)E0=u0[o]?Qr.clone(u0[o].dataCache):null,E0&&f.viewWindow&&(B0.viewWindow=f.viewWindow);else{let or=o+1;var _0=!1;for(let V=0;V<3;V++){if(!u0[or]||!u0[or].dataCache){_0=!0;continue}E0.push(Qr.clone(u0[or])),or--}_0||(f.viewWindow&&(B0.viewWindow=f.viewWindow),B0.groupScale=S.current.trackStates[o].trackState.groupScale)}const w0=B0.genomicFetchCoord[B0.primaryGenName].primaryVisData;let x0=u0.usePrimaryNav?w0.visRegion:B0.genomicFetchCoord[M.current[`${d}`].queryGenome].queryRegion;B0.visRegion=x0;const a0=w0.visWidth?w0.visWidth:t*3,L0=zr.current==="right"?new Y0(-(A+(H.current+t)),t*3+-(A+(H.current+t))):new Y0(-(A-(H.current+t))+t,t*3-(A-(H.current+t))+t);let ce=L0.start+a0/3,le=L0.end-a0/3;B0.viewWindow=new Y0(ce,le);let ve={...vr.current};ve.forceSvg=!0,B0.groupScale=S.current.trackStates[o].trackState.groupScale,E0&&D({fetchData:{genomeName:s.genome.getName(),genesArr:E0,trackState:B0,windowWidth:t,configOptions:ve,svgHeight:vr.current.displayMode==="full"?dr.current:vr.current.height,trackModel:a,basesByPixel:n,genomeConfig:s,xvaluesData:u0[o].xvalues?u0[o].xvalues:null,isError:er.current},trackId:d})}z0()}},[N]),_.jsxs("div",{style:{display:"flex",position:"relative"},children:[_.jsx("div",{style:{zIndex:2,width:120,backgroundColor:a.isSelected?"yellow":"var(--bg-color)",color:(g0=a.options)!=null&&g0.legendFontColor?a.options.legendFontColor:a.isSelected?"black":"var(--font-color)",marginBottom:"1px"},children:Sr}),_.jsx(_Lr,{buttonLabel:O&&o!==O.dataIdx||!O?"Loading View":"Getting Data",height:O?vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height:40,color:a.isSelected?"black":"var(--font-color)",isVisible:a.id in I||!O||O&&o!==O.dataIdx,children:_.jsx("div",{children:a.id in I?I[`${a.id}`].map((z0,m0)=>_.jsxs("div",{children:[z0.genomicLoci?z0.genomicLoci.map(u0=>u0.toString()):""," "]},`${a.index}loading-${m0}`)):""})}),_.jsx(fLr,{numHidden:O&&O.numHidden?O.numHidden:"",color:a.isSelected?"black":"var(--font-color)",height:vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height,xOffset:t/2+120-(15*T.terms.length-1),isVisible:O&&O.numHidden&&!(a.id in I||!O||O&&o!==O.dataIdx)}),J.skeleton&&!O?_.jsx("div",{style:{},children:_.jsx(J.skeleton,{width:t,height:40})}):"",_.jsxs("div",{ref:x,style:{display:"flex",height:vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height,position:"relative",WebkitBackfaceVisibility:"hidden",WebkitPerspective:"0px",backfaceVisibility:"hidden",perspective:"0px"},children:[_.jsx("div",{style:{position:"absolute",lineHeight:0,right:zr.current==="left"?`${H.current}px`:"",left:zr.current==="right"?`${H.current}px`:"",backgroundColor:vr.current.backgroundColor},children:O?O.component:""}),_.jsx("div",{className:mr?"visible":"hidden",children:k}),B.length>0?B.map((z0,m0)=>{if(z0.display)return _.jsx("div",{style:{display:"flex",position:"relative",height:"100%"},children:_.jsx("div",{style:{position:"absolute",backgroundColor:z0.color,top:"0",height:"100%",left:z0.side==="right"?`${z0.xPos}px`:"",right:z0.side==="left"?`${z0.xPos}px`:"",width:z0.width,pointerEvents:"none"}},m0)},m0)}):""]}),_.jsx("div",{style:{position:"absolute",zIndex:3,height:vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height,left:t+(120-(15*T.terms.length-1))},children:_.jsx(bLr,{track:a,terms:T.terms,onClick:L,height:vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height})})]})}),mj=E.memo(MLr);let dj=class{constructor(e,n){this.blockPosition=e,this.dataPosition=n}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}static min(...e){let n,h=0;for(;!n;h+=1)n=e[h];for(;h<e.length;h+=1)n.compareTo(e[h])>0&&(n=e[h]);return n}};function Am(c,e=0,n=!1){if(n)throw new Error("big-endian virtual file offsets not implemented");return new dj(c[e+7]*1099511627776+c[e+6]*4294967296+c[e+5]*16777216+c[e+4]*65536+c[e+3]*256+c[e+2],c[e+1]<<8|c[e])}let uj=class{constructor(e,n,h,i){this.minv=e,this.maxv=n,this.bin=h,this._fetchedSize=i}toUniqueString(){return`${this.minv.toString()}..${this.maxv.toString()} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}toString(){return this.toUniqueString()}compareTo(e){return this.minv.compareTo(e.minv)||this.maxv.compareTo(e.maxv)||this.bin-e.bin}fetchedSize(){return this._fetchedSize!==void 0?this._fetchedSize:this.maxv.blockPosition+65536-this.minv.blockPosition}};function GLr(c){return new Promise(e=>setTimeout(e,c))}function NLr(c){if(c.greaterThan(Number.MAX_SAFE_INTEGER)||c.lessThan(Number.MIN_SAFE_INTEGER))throw new Error("integer overflow");return c.toNumber()}function WLr(c){if(c&&c.aborted)if(typeof DOMException>"u"){const e=new Error("aborted");throw e.code="ERR_ABORTED",e}else throw new DOMException("aborted","AbortError")}function TLr(c,e){return e.minv.blockPosition-c.maxv.blockPosition<65e3&&e.maxv.blockPosition-c.minv.blockPosition<5e6}function XLr(c={}){return"aborted"in c?{signal:c}:c}function Uj(c,e){const n=[];let h;if(c.length===0)return c;c.sort((i,t)=>{const s=i.minv.blockPosition-t.minv.blockPosition;return s===0?i.minv.dataPosition-t.minv.dataPosition:s});for(const i of c)(!e||i.maxv.compareTo(e)>0)&&(h===void 0?(n.push(i),h=i):TLr(h,i)?i.maxv.compareTo(h.maxv)>0&&(h.maxv=i.maxv):(n.push(i),h=i));return n}function zj(c,e){return{lineCount:NLr(wz.fromBytesLE(Array.prototype.slice.call(c,e,e+8),!0))}}function kv(c,e){return c?c.compareTo(e)>0?e:c:e}function YLr(c,e=n=>n){let n=0,h=0;const i=[],t={};for(let s=0;s<c.length;s+=1)if(!c[s]){if(h<s){let a=c.toString("utf8",h,s);a=e(a),i[n]=a,t[a]=n}h=s+1,n+=1}return{refNameToId:t,refIdToName:i}}let vj=class{constructor({filehandle:e,renameRefSeq:n=h=>h}){this.filehandle=e,this.renameRefSeq=n}};const wLr=21578050;function ELr(c,e){return c-c%e}function xLr(c,e){return c-c%e+e}function RLr(c,e){return e-=1,[[0,0],[1+(c>>26),1+(e>>26)],[9+(c>>23),9+(e>>23)],[73+(c>>20),73+(e>>20)],[585+(c>>17),585+(e>>17)],[4681+(c>>14),4681+(e>>14)]]}class I4 extends vj{async lineCount(e,n){var h,i;return((i=(h=(await this.parse(n)).indices[e])===null||h===void 0?void 0:h.stats)===null||i===void 0?void 0:i.lineCount)||0}async _parse(e){const n=await this.filehandle.readFile(e);if(n.readUInt32LE(0)!==wLr)throw new Error("Not a BAI file");const h=n.readInt32LE(4),t=((1<<(5+1)*3)-1)/7;let s=8,a;const o=new Array(h);for(let l=0;l<h;l++){const m=n.readInt32LE(s);let d;s+=4;const u={};for(let p=0;p<m;p+=1){const D=n.readUInt32LE(s);if(s+=4,D===t+1)s+=4,d=zj(n,s+16),s+=32;else{if(D>t+1)throw new Error("bai index contains too many bins, please use CSI");{const A=n.readInt32LE(s);s+=4;const f=new Array(A);for(let M=0;M<A;M++){const S=Am(n,s);s+=8;const N=Am(n,s);s+=8,a=kv(a,S),f[M]=new uj(S,N,D)}u[D]=f}}}const U=n.readInt32LE(s);s+=4;const C=new Array(U);for(let p=0;p<U;p++){const D=Am(n,s);s+=8,a=kv(a,D),C[p]=D}o[l]={binIndex:u,linearIndex:C,stats:d}}return{bai:!0,firstDataLine:a,maxBlockSize:65536,indices:o,refCount:h}}async indexCov(e,n,h,i={}){const s=n!==void 0,o=(await this.parse(i)).indices[e];if(!o)return[];const{linearIndex:l=[],stats:m}=o;if(l.length===0)return[];const d=h===void 0?(l.length-1)*16384:xLr(h,16384),u=n===void 0?0:ELr(n,16384),U=s?new Array((d-u)/16384):new Array(l.length-1),C=l[l.length-1].blockPosition;if(d>(l.length-1)*16384)throw new Error("query outside of range of linear index");let p=l[u/16384].blockPosition;for(let D=u/16384,A=0;D<d/16384;D++,A++)U[A]={score:l[D+1].blockPosition-p,start:D*16384,end:D*16384+16384},p=l[D+1].blockPosition;return U.map(D=>({...D,score:D.score*((m==null?void 0:m.lineCount)||0)/C}))}async blocksForRange(e,n,h,i={}){n<0&&(n=0);const t=await this.parse(i);if(!t)return[];const s=t.indices[e];if(!s)return[];const a=RLr(n,h),o=[];for(const[U,C]of a)for(let p=U;p<=C;p++)if(s.binIndex[p]){const D=s.binIndex[p];for(const A of D)o.push(A)}const l=s.linearIndex.length;let m;const d=Math.min(n>>14,l-1),u=Math.min(h>>14,l-1);for(let U=d;U<=u;++U){const C=s.linearIndex[U];C&&(!m||C.compareTo(m)<0)&&(m=C)}return Uj(o,m)}async parse(e={}){return this.setupP||(this.setupP=this._parse(e).catch(n=>{throw this.setupP=void 0,n})),this.setupP}async hasRefSeq(e,n={}){var h;return!!(!((h=(await this.parse(n)).indices[e])===null||h===void 0)&&h.binIndex)}}let g8=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(g8=new Int32Array(g8));const LLr=(c,e)=>{let n=e===0?0:~~e^-1;for(let h=0;h<c.length;h++)n=g8[(n^c[h])&255]^n>>>8;return n^-1},Cj=(c,e)=>Ti.from(c,e);function ILr(c,e){const n=(h,i)=>e(Cj(h),i)>>>0;return n.signed=(h,i)=>e(Cj(h),i),n.unsigned=n,n.model=c,n}const VLr=ILr("crc-32",LLr);var Ta={};(function(c){var e=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function n(t,s){return Object.prototype.hasOwnProperty.call(t,s)}c.assign=function(t){for(var s=Array.prototype.slice.call(arguments,1);s.length;){var a=s.shift();if(a){if(typeof a!="object")throw new TypeError(a+"must be non-object");for(var o in a)n(a,o)&&(t[o]=a[o])}}return t},c.shrinkBuf=function(t,s){return t.length===s?t:t.subarray?t.subarray(0,s):(t.length=s,t)};var h={arraySet:function(t,s,a,o,l){if(s.subarray&&t.subarray){t.set(s.subarray(a,a+o),l);return}for(var m=0;m<o;m++)t[l+m]=s[a+m]},flattenChunks:function(t){var s,a,o,l,m,d;for(o=0,s=0,a=t.length;s<a;s++)o+=t[s].length;for(d=new Uint8Array(o),l=0,s=0,a=t.length;s<a;s++)m=t[s],d.set(m,l),l+=m.length;return d}},i={arraySet:function(t,s,a,o,l){for(var m=0;m<o;m++)t[l+m]=s[a+m]},flattenChunks:function(t){return[].concat.apply([],t)}};c.setTyped=function(t){t?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,h)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,i))},c.setTyped(e)})(Ta);var V4={},Xs={},ym={},FLr=Ta,kLr=4,pj=0,Dj=1,JLr=2;function Bm(c){for(var e=c.length;--e>=0;)c[e]=0}var jLr=0,bj=1,HLr=2,KLr=3,PLr=258,_8=29,F4=256,k4=F4+1+_8,Zm=30,A8=19,gj=2*k4+1,i2=15,y8=16,OLr=7,B8=256,_j=16,Aj=17,yj=18,Z8=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Jv=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],QLr=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Bj=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],qLr=512,Xa=new Array((k4+2)*2);Bm(Xa);var J4=new Array(Zm*2);Bm(J4);var j4=new Array(qLr);Bm(j4);var H4=new Array(PLr-KLr+1);Bm(H4);var f8=new Array(_8);Bm(f8);var jv=new Array(Zm);Bm(jv);function S8(c,e,n,h,i){this.static_tree=c,this.extra_bits=e,this.extra_base=n,this.elems=h,this.max_length=i,this.has_stree=c&&c.length}var Zj,fj,Sj;function M8(c,e){this.dyn_tree=c,this.max_code=0,this.stat_desc=e}function Mj(c){return c<256?j4[c]:j4[256+(c>>>7)]}function K4(c,e){c.pending_buf[c.pending++]=e&255,c.pending_buf[c.pending++]=e>>>8&255}function L1(c,e,n){c.bi_valid>y8-n?(c.bi_buf|=e<<c.bi_valid&65535,K4(c,c.bi_buf),c.bi_buf=e>>y8-c.bi_valid,c.bi_valid+=n-y8):(c.bi_buf|=e<<c.bi_valid&65535,c.bi_valid+=n)}function Ys(c,e,n){L1(c,n[e*2],n[e*2+1])}function Gj(c,e){var n=0;do n|=c&1,c>>>=1,n<<=1;while(--e>0);return n>>>1}function $Lr(c){c.bi_valid===16?(K4(c,c.bi_buf),c.bi_buf=0,c.bi_valid=0):c.bi_valid>=8&&(c.pending_buf[c.pending++]=c.bi_buf&255,c.bi_buf>>=8,c.bi_valid-=8)}function rIr(c,e){var n=e.dyn_tree,h=e.max_code,i=e.stat_desc.static_tree,t=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,o=e.stat_desc.max_length,l,m,d,u,U,C,p=0;for(u=0;u<=i2;u++)c.bl_count[u]=0;for(n[c.heap[c.heap_max]*2+1]=0,l=c.heap_max+1;l<gj;l++)m=c.heap[l],u=n[n[m*2+1]*2+1]+1,u>o&&(u=o,p++),n[m*2+1]=u,!(m>h)&&(c.bl_count[u]++,U=0,m>=a&&(U=s[m-a]),C=n[m*2],c.opt_len+=C*(u+U),t&&(c.static_len+=C*(i[m*2+1]+U)));if(p!==0){do{for(u=o-1;c.bl_count[u]===0;)u--;c.bl_count[u]--,c.bl_count[u+1]+=2,c.bl_count[o]--,p-=2}while(p>0);for(u=o;u!==0;u--)for(m=c.bl_count[u];m!==0;)d=c.heap[--l],!(d>h)&&(n[d*2+1]!==u&&(c.opt_len+=(u-n[d*2+1])*n[d*2],n[d*2+1]=u),m--)}}function Nj(c,e,n){var h=new Array(i2+1),i=0,t,s;for(t=1;t<=i2;t++)h[t]=i=i+n[t-1]<<1;for(s=0;s<=e;s++){var a=c[s*2+1];a!==0&&(c[s*2]=Gj(h[a]++,a))}}function eIr(){var c,e,n,h,i,t=new Array(i2+1);for(n=0,h=0;h<_8-1;h++)for(f8[h]=n,c=0;c<1<<Z8[h];c++)H4[n++]=h;for(H4[n-1]=h,i=0,h=0;h<16;h++)for(jv[h]=i,c=0;c<1<<Jv[h];c++)j4[i++]=h;for(i>>=7;h<Zm;h++)for(jv[h]=i<<7,c=0;c<1<<Jv[h]-7;c++)j4[256+i++]=h;for(e=0;e<=i2;e++)t[e]=0;for(c=0;c<=143;)Xa[c*2+1]=8,c++,t[8]++;for(;c<=255;)Xa[c*2+1]=9,c++,t[9]++;for(;c<=279;)Xa[c*2+1]=7,c++,t[7]++;for(;c<=287;)Xa[c*2+1]=8,c++,t[8]++;for(Nj(Xa,k4+1,t),c=0;c<Zm;c++)J4[c*2+1]=5,J4[c*2]=Gj(c,5);Zj=new S8(Xa,Z8,F4+1,k4,i2),fj=new S8(J4,Jv,0,Zm,i2),Sj=new S8(new Array(0),QLr,0,A8,OLr)}function Wj(c){var e;for(e=0;e<k4;e++)c.dyn_ltree[e*2]=0;for(e=0;e<Zm;e++)c.dyn_dtree[e*2]=0;for(e=0;e<A8;e++)c.bl_tree[e*2]=0;c.dyn_ltree[B8*2]=1,c.opt_len=c.static_len=0,c.last_lit=c.matches=0}function Tj(c){c.bi_valid>8?K4(c,c.bi_buf):c.bi_valid>0&&(c.pending_buf[c.pending++]=c.bi_buf),c.bi_buf=0,c.bi_valid=0}function cIr(c,e,n,h){Tj(c),K4(c,n),K4(c,~n),FLr.arraySet(c.pending_buf,c.window,e,n,c.pending),c.pending+=n}function Xj(c,e,n,h){var i=e*2,t=n*2;return c[i]<c[t]||c[i]===c[t]&&h[e]<=h[n]}function G8(c,e,n){for(var h=c.heap[n],i=n<<1;i<=c.heap_len&&(i<c.heap_len&&Xj(e,c.heap[i+1],c.heap[i],c.depth)&&i++,!Xj(e,h,c.heap[i],c.depth));)c.heap[n]=c.heap[i],n=i,i<<=1;c.heap[n]=h}function Yj(c,e,n){var h,i,t=0,s,a;if(c.last_lit!==0)do h=c.pending_buf[c.d_buf+t*2]<<8|c.pending_buf[c.d_buf+t*2+1],i=c.pending_buf[c.l_buf+t],t++,h===0?Ys(c,i,e):(s=H4[i],Ys(c,s+F4+1,e),a=Z8[s],a!==0&&(i-=f8[s],L1(c,i,a)),h--,s=Mj(h),Ys(c,s,n),a=Jv[s],a!==0&&(h-=jv[s],L1(c,h,a)));while(t<c.last_lit);Ys(c,B8,e)}function N8(c,e){var n=e.dyn_tree,h=e.stat_desc.static_tree,i=e.stat_desc.has_stree,t=e.stat_desc.elems,s,a,o=-1,l;for(c.heap_len=0,c.heap_max=gj,s=0;s<t;s++)n[s*2]!==0?(c.heap[++c.heap_len]=o=s,c.depth[s]=0):n[s*2+1]=0;for(;c.heap_len<2;)l=c.heap[++c.heap_len]=o<2?++o:0,n[l*2]=1,c.depth[l]=0,c.opt_len--,i&&(c.static_len-=h[l*2+1]);for(e.max_code=o,s=c.heap_len>>1;s>=1;s--)G8(c,n,s);l=t;do s=c.heap[1],c.heap[1]=c.heap[c.heap_len--],G8(c,n,1),a=c.heap[1],c.heap[--c.heap_max]=s,c.heap[--c.heap_max]=a,n[l*2]=n[s*2]+n[a*2],c.depth[l]=(c.depth[s]>=c.depth[a]?c.depth[s]:c.depth[a])+1,n[s*2+1]=n[a*2+1]=l,c.heap[1]=l++,G8(c,n,1);while(c.heap_len>=2);c.heap[--c.heap_max]=c.heap[1],rIr(c,e),Nj(n,o,c.bl_count)}function wj(c,e,n){var h,i=-1,t,s=e[0*2+1],a=0,o=7,l=4;for(s===0&&(o=138,l=3),e[(n+1)*2+1]=65535,h=0;h<=n;h++)t=s,s=e[(h+1)*2+1],!(++a<o&&t===s)&&(a<l?c.bl_tree[t*2]+=a:t!==0?(t!==i&&c.bl_tree[t*2]++,c.bl_tree[_j*2]++):a<=10?c.bl_tree[Aj*2]++:c.bl_tree[yj*2]++,a=0,i=t,s===0?(o=138,l=3):t===s?(o=6,l=3):(o=7,l=4))}function Ej(c,e,n){var h,i=-1,t,s=e[0*2+1],a=0,o=7,l=4;for(s===0&&(o=138,l=3),h=0;h<=n;h++)if(t=s,s=e[(h+1)*2+1],!(++a<o&&t===s)){if(a<l)do Ys(c,t,c.bl_tree);while(--a!==0);else t!==0?(t!==i&&(Ys(c,t,c.bl_tree),a--),Ys(c,_j,c.bl_tree),L1(c,a-3,2)):a<=10?(Ys(c,Aj,c.bl_tree),L1(c,a-3,3)):(Ys(c,yj,c.bl_tree),L1(c,a-11,7));a=0,i=t,s===0?(o=138,l=3):t===s?(o=6,l=3):(o=7,l=4)}}function nIr(c){var e;for(wj(c,c.dyn_ltree,c.l_desc.max_code),wj(c,c.dyn_dtree,c.d_desc.max_code),N8(c,c.bl_desc),e=A8-1;e>=3&&c.bl_tree[Bj[e]*2+1]===0;e--);return c.opt_len+=3*(e+1)+5+5+4,e}function hIr(c,e,n,h){var i;for(L1(c,e-257,5),L1(c,n-1,5),L1(c,h-4,4),i=0;i<h;i++)L1(c,c.bl_tree[Bj[i]*2+1],3);Ej(c,c.dyn_ltree,e-1),Ej(c,c.dyn_dtree,n-1)}function iIr(c){var e=4093624447,n;for(n=0;n<=31;n++,e>>>=1)if(e&1&&c.dyn_ltree[n*2]!==0)return pj;if(c.dyn_ltree[9*2]!==0||c.dyn_ltree[10*2]!==0||c.dyn_ltree[13*2]!==0)return Dj;for(n=32;n<F4;n++)if(c.dyn_ltree[n*2]!==0)return Dj;return pj}var xj=!1;function tIr(c){xj||(eIr(),xj=!0),c.l_desc=new M8(c.dyn_ltree,Zj),c.d_desc=new M8(c.dyn_dtree,fj),c.bl_desc=new M8(c.bl_tree,Sj),c.bi_buf=0,c.bi_valid=0,Wj(c)}function Rj(c,e,n,h){L1(c,(jLr<<1)+(h?1:0),3),cIr(c,e,n)}function sIr(c){L1(c,bj<<1,3),Ys(c,B8,Xa),$Lr(c)}function aIr(c,e,n,h){var i,t,s=0;c.level>0?(c.strm.data_type===JLr&&(c.strm.data_type=iIr(c)),N8(c,c.l_desc),N8(c,c.d_desc),s=nIr(c),i=c.opt_len+3+7>>>3,t=c.static_len+3+7>>>3,t<=i&&(i=t)):i=t=n+5,n+4<=i&&e!==-1?Rj(c,e,n,h):c.strategy===kLr||t===i?(L1(c,(bj<<1)+(h?1:0),3),Yj(c,Xa,J4)):(L1(c,(HLr<<1)+(h?1:0),3),hIr(c,c.l_desc.max_code+1,c.d_desc.max_code+1,s+1),Yj(c,c.dyn_ltree,c.dyn_dtree)),Wj(c),h&&Tj(c)}function oIr(c,e,n){return c.pending_buf[c.d_buf+c.last_lit*2]=e>>>8&255,c.pending_buf[c.d_buf+c.last_lit*2+1]=e&255,c.pending_buf[c.l_buf+c.last_lit]=n&255,c.last_lit++,e===0?c.dyn_ltree[n*2]++:(c.matches++,e--,c.dyn_ltree[(H4[n]+F4+1)*2]++,c.dyn_dtree[Mj(e)*2]++),c.last_lit===c.lit_bufsize-1}ym._tr_init=tIr,ym._tr_stored_block=Rj,ym._tr_flush_block=aIr,ym._tr_tally=oIr,ym._tr_align=sIr;function lIr(c,e,n,h){for(var i=c&65535|0,t=c>>>16&65535|0,s=0;n!==0;){s=n>2e3?2e3:n,n-=s;do i=i+e[h++]|0,t=t+i|0;while(--s);i%=65521,t%=65521}return i|t<<16|0}var Lj=lIr;function mIr(){for(var c,e=[],n=0;n<256;n++){c=n;for(var h=0;h<8;h++)c=c&1?3988292384^c>>>1:c>>>1;e[n]=c}return e}var dIr=mIr();function uIr(c,e,n,h){var i=dIr,t=h+n;c^=-1;for(var s=h;s<t;s++)c=c>>>8^i[(c^e[s])&255];return c^-1}var Ij=uIr,W8={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},g1=Ta,Hi=ym,Vj=Lj,M3=Ij,UIr=W8,t2=0,zIr=1,vIr=3,G3=4,Fj=5,ws=0,kj=1,Ki=-2,CIr=-3,T8=-5,pIr=-1,DIr=1,Hv=2,bIr=3,gIr=4,_Ir=0,AIr=2,Kv=8,yIr=9,BIr=15,ZIr=8,fIr=29,SIr=256,X8=SIr+1+fIr,MIr=30,GIr=19,NIr=2*X8+1,WIr=15,gc=3,N3=258,Jt=N3+gc+1,TIr=32,Pv=42,Y8=69,Ov=73,Qv=91,qv=103,s2=113,P4=666,vh=1,O4=2,a2=3,fm=4,XIr=3;function W3(c,e){return c.msg=UIr[e],e}function Jj(c){return(c<<1)-(c>4?9:0)}function T3(c){for(var e=c.length;--e>=0;)c[e]=0}function X3(c){var e=c.state,n=e.pending;n>c.avail_out&&(n=c.avail_out),n!==0&&(g1.arraySet(c.output,e.pending_buf,e.pending_out,n,c.next_out),c.next_out+=n,e.pending_out+=n,c.total_out+=n,c.avail_out-=n,e.pending-=n,e.pending===0&&(e.pending_out=0))}function Vh(c,e){Hi._tr_flush_block(c,c.block_start>=0?c.block_start:-1,c.strstart-c.block_start,e),c.block_start=c.strstart,X3(c.strm)}function Xc(c,e){c.pending_buf[c.pending++]=e}function Q4(c,e){c.pending_buf[c.pending++]=e>>>8&255,c.pending_buf[c.pending++]=e&255}function YIr(c,e,n,h){var i=c.avail_in;return i>h&&(i=h),i===0?0:(c.avail_in-=i,g1.arraySet(e,c.input,c.next_in,i,n),c.state.wrap===1?c.adler=Vj(c.adler,e,i,n):c.state.wrap===2&&(c.adler=M3(c.adler,e,i,n)),c.next_in+=i,c.total_in+=i,i)}function jj(c,e){var n=c.max_chain_length,h=c.strstart,i,t,s=c.prev_length,a=c.nice_match,o=c.strstart>c.w_size-Jt?c.strstart-(c.w_size-Jt):0,l=c.window,m=c.w_mask,d=c.prev,u=c.strstart+N3,U=l[h+s-1],C=l[h+s];c.prev_length>=c.good_match&&(n>>=2),a>c.lookahead&&(a=c.lookahead);do if(i=e,!(l[i+s]!==C||l[i+s-1]!==U||l[i]!==l[h]||l[++i]!==l[h+1])){h+=2,i++;do;while(l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&h<u);if(t=N3-(u-h),h=u-N3,t>s){if(c.match_start=e,s=t,t>=a)break;U=l[h+s-1],C=l[h+s]}}while((e=d[e&m])>o&&--n!==0);return s<=c.lookahead?s:c.lookahead}function o2(c){var e=c.w_size,n,h,i,t,s;do{if(t=c.window_size-c.lookahead-c.strstart,c.strstart>=e+(e-Jt)){g1.arraySet(c.window,c.window,e,e,0),c.match_start-=e,c.strstart-=e,c.block_start-=e,h=c.hash_size,n=h;do i=c.head[--n],c.head[n]=i>=e?i-e:0;while(--h);h=e,n=h;do i=c.prev[--n],c.prev[n]=i>=e?i-e:0;while(--h);t+=e}if(c.strm.avail_in===0)break;if(h=YIr(c.strm,c.window,c.strstart+c.lookahead,t),c.lookahead+=h,c.lookahead+c.insert>=gc)for(s=c.strstart-c.insert,c.ins_h=c.window[s],c.ins_h=(c.ins_h<<c.hash_shift^c.window[s+1])&c.hash_mask;c.insert&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[s+gc-1])&c.hash_mask,c.prev[s&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=s,s++,c.insert--,!(c.lookahead+c.insert<gc)););}while(c.lookahead<Jt&&c.strm.avail_in!==0)}function wIr(c,e){var n=65535;for(n>c.pending_buf_size-5&&(n=c.pending_buf_size-5);;){if(c.lookahead<=1){if(o2(c),c.lookahead===0&&e===t2)return vh;if(c.lookahead===0)break}c.strstart+=c.lookahead,c.lookahead=0;var h=c.block_start+n;if((c.strstart===0||c.strstart>=h)&&(c.lookahead=c.strstart-h,c.strstart=h,Vh(c,!1),c.strm.avail_out===0)||c.strstart-c.block_start>=c.w_size-Jt&&(Vh(c,!1),c.strm.avail_out===0))return vh}return c.insert=0,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):(c.strstart>c.block_start&&(Vh(c,!1),c.strm.avail_out===0),vh)}function w8(c,e){for(var n,h;;){if(c.lookahead<Jt){if(o2(c),c.lookahead<Jt&&e===t2)return vh;if(c.lookahead===0)break}if(n=0,c.lookahead>=gc&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+gc-1])&c.hash_mask,n=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),n!==0&&c.strstart-n<=c.w_size-Jt&&(c.match_length=jj(c,n)),c.match_length>=gc)if(h=Hi._tr_tally(c,c.strstart-c.match_start,c.match_length-gc),c.lookahead-=c.match_length,c.match_length<=c.max_lazy_match&&c.lookahead>=gc){c.match_length--;do c.strstart++,c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+gc-1])&c.hash_mask,n=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart;while(--c.match_length!==0);c.strstart++}else c.strstart+=c.match_length,c.match_length=0,c.ins_h=c.window[c.strstart],c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+1])&c.hash_mask;else h=Hi._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++;if(h&&(Vh(c,!1),c.strm.avail_out===0))return vh}return c.insert=c.strstart<gc-1?c.strstart:gc-1,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):c.last_lit&&(Vh(c,!1),c.strm.avail_out===0)?vh:O4}function Sm(c,e){for(var n,h,i;;){if(c.lookahead<Jt){if(o2(c),c.lookahead<Jt&&e===t2)return vh;if(c.lookahead===0)break}if(n=0,c.lookahead>=gc&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+gc-1])&c.hash_mask,n=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),c.prev_length=c.match_length,c.prev_match=c.match_start,c.match_length=gc-1,n!==0&&c.prev_length<c.max_lazy_match&&c.strstart-n<=c.w_size-Jt&&(c.match_length=jj(c,n),c.match_length<=5&&(c.strategy===DIr||c.match_length===gc&&c.strstart-c.match_start>4096)&&(c.match_length=gc-1)),c.prev_length>=gc&&c.match_length<=c.prev_length){i=c.strstart+c.lookahead-gc,h=Hi._tr_tally(c,c.strstart-1-c.prev_match,c.prev_length-gc),c.lookahead-=c.prev_length-1,c.prev_length-=2;do++c.strstart<=i&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+gc-1])&c.hash_mask,n=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart);while(--c.prev_length!==0);if(c.match_available=0,c.match_length=gc-1,c.strstart++,h&&(Vh(c,!1),c.strm.avail_out===0))return vh}else if(c.match_available){if(h=Hi._tr_tally(c,0,c.window[c.strstart-1]),h&&Vh(c,!1),c.strstart++,c.lookahead--,c.strm.avail_out===0)return vh}else c.match_available=1,c.strstart++,c.lookahead--}return c.match_available&&(h=Hi._tr_tally(c,0,c.window[c.strstart-1]),c.match_available=0),c.insert=c.strstart<gc-1?c.strstart:gc-1,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):c.last_lit&&(Vh(c,!1),c.strm.avail_out===0)?vh:O4}function EIr(c,e){for(var n,h,i,t,s=c.window;;){if(c.lookahead<=N3){if(o2(c),c.lookahead<=N3&&e===t2)return vh;if(c.lookahead===0)break}if(c.match_length=0,c.lookahead>=gc&&c.strstart>0&&(i=c.strstart-1,h=s[i],h===s[++i]&&h===s[++i]&&h===s[++i])){t=c.strstart+N3;do;while(h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&i<t);c.match_length=N3-(t-i),c.match_length>c.lookahead&&(c.match_length=c.lookahead)}if(c.match_length>=gc?(n=Hi._tr_tally(c,1,c.match_length-gc),c.lookahead-=c.match_length,c.strstart+=c.match_length,c.match_length=0):(n=Hi._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++),n&&(Vh(c,!1),c.strm.avail_out===0))return vh}return c.insert=0,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):c.last_lit&&(Vh(c,!1),c.strm.avail_out===0)?vh:O4}function xIr(c,e){for(var n;;){if(c.lookahead===0&&(o2(c),c.lookahead===0)){if(e===t2)return vh;break}if(c.match_length=0,n=Hi._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++,n&&(Vh(c,!1),c.strm.avail_out===0))return vh}return c.insert=0,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):c.last_lit&&(Vh(c,!1),c.strm.avail_out===0)?vh:O4}function Es(c,e,n,h,i){this.good_length=c,this.max_lazy=e,this.nice_length=n,this.max_chain=h,this.func=i}var Mm;Mm=[new Es(0,0,0,0,wIr),new Es(4,4,8,4,w8),new Es(4,5,16,8,w8),new Es(4,6,32,32,w8),new Es(4,4,16,16,Sm),new Es(8,16,32,32,Sm),new Es(8,16,128,128,Sm),new Es(8,32,128,256,Sm),new Es(32,128,258,1024,Sm),new Es(32,258,258,4096,Sm)];function RIr(c){c.window_size=2*c.w_size,T3(c.head),c.max_lazy_match=Mm[c.level].max_lazy,c.good_match=Mm[c.level].good_length,c.nice_match=Mm[c.level].nice_length,c.max_chain_length=Mm[c.level].max_chain,c.strstart=0,c.block_start=0,c.lookahead=0,c.insert=0,c.match_length=c.prev_length=gc-1,c.match_available=0,c.ins_h=0}function LIr(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Kv,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new g1.Buf16(NIr*2),this.dyn_dtree=new g1.Buf16((2*MIr+1)*2),this.bl_tree=new g1.Buf16((2*GIr+1)*2),T3(this.dyn_ltree),T3(this.dyn_dtree),T3(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new g1.Buf16(WIr+1),this.heap=new g1.Buf16(2*X8+1),T3(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new g1.Buf16(2*X8+1),T3(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Hj(c){var e;return!c||!c.state?W3(c,Ki):(c.total_in=c.total_out=0,c.data_type=AIr,e=c.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?Pv:s2,c.adler=e.wrap===2?0:1,e.last_flush=t2,Hi._tr_init(e),ws)}function Kj(c){var e=Hj(c);return e===ws&&RIr(c.state),e}function IIr(c,e){return!c||!c.state||c.state.wrap!==2?Ki:(c.state.gzhead=e,ws)}function Pj(c,e,n,h,i,t){if(!c)return Ki;var s=1;if(e===pIr&&(e=6),h<0?(s=0,h=-h):h>15&&(s=2,h-=16),i<1||i>yIr||n!==Kv||h<8||h>15||e<0||e>9||t<0||t>gIr)return W3(c,Ki);h===8&&(h=9);var a=new LIr;return c.state=a,a.strm=c,a.wrap=s,a.gzhead=null,a.w_bits=h,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+gc-1)/gc),a.window=new g1.Buf8(a.w_size*2),a.head=new g1.Buf16(a.hash_size),a.prev=new g1.Buf16(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new g1.Buf8(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=t,a.method=n,Kj(c)}function VIr(c,e){return Pj(c,e,Kv,BIr,ZIr,_Ir)}function FIr(c,e){var n,h,i,t;if(!c||!c.state||e>Fj||e<0)return c?W3(c,Ki):Ki;if(h=c.state,!c.output||!c.input&&c.avail_in!==0||h.status===P4&&e!==G3)return W3(c,c.avail_out===0?T8:Ki);if(h.strm=c,n=h.last_flush,h.last_flush=e,h.status===Pv)if(h.wrap===2)c.adler=0,Xc(h,31),Xc(h,139),Xc(h,8),h.gzhead?(Xc(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),Xc(h,h.gzhead.time&255),Xc(h,h.gzhead.time>>8&255),Xc(h,h.gzhead.time>>16&255),Xc(h,h.gzhead.time>>24&255),Xc(h,h.level===9?2:h.strategy>=Hv||h.level<2?4:0),Xc(h,h.gzhead.os&255),h.gzhead.extra&&h.gzhead.extra.length&&(Xc(h,h.gzhead.extra.length&255),Xc(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(c.adler=M3(c.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=Y8):(Xc(h,0),Xc(h,0),Xc(h,0),Xc(h,0),Xc(h,0),Xc(h,h.level===9?2:h.strategy>=Hv||h.level<2?4:0),Xc(h,XIr),h.status=s2);else{var s=Kv+(h.w_bits-8<<4)<<8,a=-1;h.strategy>=Hv||h.level<2?a=0:h.level<6?a=1:h.level===6?a=2:a=3,s|=a<<6,h.strstart!==0&&(s|=TIr),s+=31-s%31,h.status=s2,Q4(h,s),h.strstart!==0&&(Q4(h,c.adler>>>16),Q4(h,c.adler&65535)),c.adler=1}if(h.status===Y8)if(h.gzhead.extra){for(i=h.pending;h.gzindex<(h.gzhead.extra.length&65535)&&!(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),X3(c),i=h.pending,h.pending===h.pending_buf_size));)Xc(h,h.gzhead.extra[h.gzindex]&255),h.gzindex++;h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=Ov)}else h.status=Ov;if(h.status===Ov)if(h.gzhead.name){i=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),X3(c),i=h.pending,h.pending===h.pending_buf_size)){t=1;break}h.gzindex<h.gzhead.name.length?t=h.gzhead.name.charCodeAt(h.gzindex++)&255:t=0,Xc(h,t)}while(t!==0);h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),t===0&&(h.gzindex=0,h.status=Qv)}else h.status=Qv;if(h.status===Qv)if(h.gzhead.comment){i=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),X3(c),i=h.pending,h.pending===h.pending_buf_size)){t=1;break}h.gzindex<h.gzhead.comment.length?t=h.gzhead.comment.charCodeAt(h.gzindex++)&255:t=0,Xc(h,t)}while(t!==0);h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),t===0&&(h.status=qv)}else h.status=qv;if(h.status===qv&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&X3(c),h.pending+2<=h.pending_buf_size&&(Xc(h,c.adler&255),Xc(h,c.adler>>8&255),c.adler=0,h.status=s2)):h.status=s2),h.pending!==0){if(X3(c),c.avail_out===0)return h.last_flush=-1,ws}else if(c.avail_in===0&&Jj(e)<=Jj(n)&&e!==G3)return W3(c,T8);if(h.status===P4&&c.avail_in!==0)return W3(c,T8);if(c.avail_in!==0||h.lookahead!==0||e!==t2&&h.status!==P4){var o=h.strategy===Hv?xIr(h,e):h.strategy===bIr?EIr(h,e):Mm[h.level].func(h,e);if((o===a2||o===fm)&&(h.status=P4),o===vh||o===a2)return c.avail_out===0&&(h.last_flush=-1),ws;if(o===O4&&(e===zIr?Hi._tr_align(h):e!==Fj&&(Hi._tr_stored_block(h,0,0,!1),e===vIr&&(T3(h.head),h.lookahead===0&&(h.strstart=0,h.block_start=0,h.insert=0))),X3(c),c.avail_out===0))return h.last_flush=-1,ws}return e!==G3?ws:h.wrap<=0?kj:(h.wrap===2?(Xc(h,c.adler&255),Xc(h,c.adler>>8&255),Xc(h,c.adler>>16&255),Xc(h,c.adler>>24&255),Xc(h,c.total_in&255),Xc(h,c.total_in>>8&255),Xc(h,c.total_in>>16&255),Xc(h,c.total_in>>24&255)):(Q4(h,c.adler>>>16),Q4(h,c.adler&65535)),X3(c),h.wrap>0&&(h.wrap=-h.wrap),h.pending!==0?ws:kj)}function kIr(c){var e;return!c||!c.state?Ki:(e=c.state.status,e!==Pv&&e!==Y8&&e!==Ov&&e!==Qv&&e!==qv&&e!==s2&&e!==P4?W3(c,Ki):(c.state=null,e===s2?W3(c,CIr):ws))}function JIr(c,e){var n=e.length,h,i,t,s,a,o,l,m;if(!c||!c.state||(h=c.state,s=h.wrap,s===2||s===1&&h.status!==Pv||h.lookahead))return Ki;for(s===1&&(c.adler=Vj(c.adler,e,n,0)),h.wrap=0,n>=h.w_size&&(s===0&&(T3(h.head),h.strstart=0,h.block_start=0,h.insert=0),m=new g1.Buf8(h.w_size),g1.arraySet(m,e,n-h.w_size,h.w_size,0),e=m,n=h.w_size),a=c.avail_in,o=c.next_in,l=c.input,c.avail_in=n,c.next_in=0,c.input=e,o2(h);h.lookahead>=gc;){i=h.strstart,t=h.lookahead-(gc-1);do h.ins_h=(h.ins_h<<h.hash_shift^h.window[i+gc-1])&h.hash_mask,h.prev[i&h.w_mask]=h.head[h.ins_h],h.head[h.ins_h]=i,i++;while(--t);h.strstart=i,h.lookahead=gc-1,o2(h)}return h.strstart+=h.lookahead,h.block_start=h.strstart,h.insert=h.lookahead,h.lookahead=0,h.match_length=h.prev_length=gc-1,h.match_available=0,c.next_in=o,c.input=l,c.avail_in=a,h.wrap=s,ws}Xs.deflateInit=VIr,Xs.deflateInit2=Pj,Xs.deflateReset=Kj,Xs.deflateResetKeep=Hj,Xs.deflateSetHeader=IIr,Xs.deflate=FIr,Xs.deflateEnd=kIr,Xs.deflateSetDictionary=JIr,Xs.deflateInfo="pako deflate (from Nodeca project)";var l2={},$v=Ta,Oj=!0,Qj=!0;try{String.fromCharCode.apply(null,[0])}catch{Oj=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Qj=!1}for(var q4=new $v.Buf8(256),Y3=0;Y3<256;Y3++)q4[Y3]=Y3>=252?6:Y3>=248?5:Y3>=240?4:Y3>=224?3:Y3>=192?2:1;q4[254]=q4[254]=1,l2.string2buf=function(c){var e,n,h,i,t,s=c.length,a=0;for(i=0;i<s;i++)n=c.charCodeAt(i),(n&64512)===55296&&i+1<s&&(h=c.charCodeAt(i+1),(h&64512)===56320&&(n=65536+(n-55296<<10)+(h-56320),i++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new $v.Buf8(a),t=0,i=0;t<a;i++)n=c.charCodeAt(i),(n&64512)===55296&&i+1<s&&(h=c.charCodeAt(i+1),(h&64512)===56320&&(n=65536+(n-55296<<10)+(h-56320),i++)),n<128?e[t++]=n:n<2048?(e[t++]=192|n>>>6,e[t++]=128|n&63):n<65536?(e[t++]=224|n>>>12,e[t++]=128|n>>>6&63,e[t++]=128|n&63):(e[t++]=240|n>>>18,e[t++]=128|n>>>12&63,e[t++]=128|n>>>6&63,e[t++]=128|n&63);return e};function qj(c,e){if(e<65534&&(c.subarray&&Qj||!c.subarray&&Oj))return String.fromCharCode.apply(null,$v.shrinkBuf(c,e));for(var n="",h=0;h<e;h++)n+=String.fromCharCode(c[h]);return n}l2.buf2binstring=function(c){return qj(c,c.length)},l2.binstring2buf=function(c){for(var e=new $v.Buf8(c.length),n=0,h=e.length;n<h;n++)e[n]=c.charCodeAt(n);return e},l2.buf2string=function(c,e){var n,h,i,t,s=e||c.length,a=new Array(s*2);for(h=0,n=0;n<s;){if(i=c[n++],i<128){a[h++]=i;continue}if(t=q4[i],t>4){a[h++]=65533,n+=t-1;continue}for(i&=t===2?31:t===3?15:7;t>1&&n<s;)i=i<<6|c[n++]&63,t--;if(t>1){a[h++]=65533;continue}i<65536?a[h++]=i:(i-=65536,a[h++]=55296|i>>10&1023,a[h++]=56320|i&1023)}return qj(a,h)},l2.utf8border=function(c,e){var n;for(e=e||c.length,e>c.length&&(e=c.length),n=e-1;n>=0&&(c[n]&192)===128;)n--;return n<0||n===0?e:n+q4[c[n]]>e?n:e};function jIr(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var $j=jIr,$4=Xs,r9=Ta,E8=l2,x8=W8,HIr=$j,rH=Object.prototype.toString,KIr=0,R8=4,Gm=0,eH=1,cH=2,PIr=-1,OIr=0,QIr=8;function m2(c){if(!(this instanceof m2))return new m2(c);this.options=r9.assign({level:PIr,method:QIr,chunkSize:16384,windowBits:15,memLevel:8,strategy:OIr,to:""},c||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new HIr,this.strm.avail_out=0;var n=$4.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==Gm)throw new Error(x8[n]);if(e.header&&$4.deflateSetHeader(this.strm,e.header),e.dictionary){var h;if(typeof e.dictionary=="string"?h=E8.string2buf(e.dictionary):rH.call(e.dictionary)==="[object ArrayBuffer]"?h=new Uint8Array(e.dictionary):h=e.dictionary,n=$4.deflateSetDictionary(this.strm,h),n!==Gm)throw new Error(x8[n]);this._dict_set=!0}}m2.prototype.push=function(c,e){var n=this.strm,h=this.options.chunkSize,i,t;if(this.ended)return!1;t=e===~~e?e:e===!0?R8:KIr,typeof c=="string"?n.input=E8.string2buf(c):rH.call(c)==="[object ArrayBuffer]"?n.input=new Uint8Array(c):n.input=c,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new r9.Buf8(h),n.next_out=0,n.avail_out=h),i=$4.deflate(n,t),i!==eH&&i!==Gm)return this.onEnd(i),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(t===R8||t===cH))&&(this.options.to==="string"?this.onData(E8.buf2binstring(r9.shrinkBuf(n.output,n.next_out))):this.onData(r9.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&i!==eH);return t===R8?(i=$4.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Gm):(t===cH&&(this.onEnd(Gm),n.avail_out=0),!0)},m2.prototype.onData=function(c){this.chunks.push(c)},m2.prototype.onEnd=function(c){c===Gm&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r9.flattenChunks(this.chunks)),this.chunks=[],this.err=c,this.msg=this.strm.msg};function L8(c,e){var n=new m2(e);if(n.push(c,!0),n.err)throw n.msg||x8[n.err];return n.result}function qIr(c,e){return e=e||{},e.raw=!0,L8(c,e)}function $Ir(c,e){return e=e||{},e.gzip=!0,L8(c,e)}V4.Deflate=m2,V4.deflate=L8,V4.deflateRaw=qIr,V4.gzip=$Ir;var e9={},jt={},r6=30,rVr=12,eVr=function(e,n){var h,i,t,s,a,o,l,m,d,u,U,C,p,D,A,f,M,S,N,x,B,W,T,L,I;h=e.state,i=e.next_in,L=e.input,t=i+(e.avail_in-5),s=e.next_out,I=e.output,a=s-(n-e.avail_out),o=s+(e.avail_out-257),l=h.dmax,m=h.wsize,d=h.whave,u=h.wnext,U=h.window,C=h.hold,p=h.bits,D=h.lencode,A=h.distcode,f=(1<<h.lenbits)-1,M=(1<<h.distbits)-1;r:do{p<15&&(C+=L[i++]<<p,p+=8,C+=L[i++]<<p,p+=8),S=D[C&f];e:for(;;){if(N=S>>>24,C>>>=N,p-=N,N=S>>>16&255,N===0)I[s++]=S&65535;else if(N&16){x=S&65535,N&=15,N&&(p<N&&(C+=L[i++]<<p,p+=8),x+=C&(1<<N)-1,C>>>=N,p-=N),p<15&&(C+=L[i++]<<p,p+=8,C+=L[i++]<<p,p+=8),S=A[C&M];c:for(;;){if(N=S>>>24,C>>>=N,p-=N,N=S>>>16&255,N&16){if(B=S&65535,N&=15,p<N&&(C+=L[i++]<<p,p+=8,p<N&&(C+=L[i++]<<p,p+=8)),B+=C&(1<<N)-1,B>l){e.msg="invalid distance too far back",h.mode=r6;break r}if(C>>>=N,p-=N,N=s-a,B>N){if(N=B-N,N>d&&h.sane){e.msg="invalid distance too far back",h.mode=r6;break r}if(W=0,T=U,u===0){if(W+=m-N,N<x){x-=N;do I[s++]=U[W++];while(--N);W=s-B,T=I}}else if(u<N){if(W+=m+u-N,N-=u,N<x){x-=N;do I[s++]=U[W++];while(--N);if(W=0,u<x){N=u,x-=N;do I[s++]=U[W++];while(--N);W=s-B,T=I}}}else if(W+=u-N,N<x){x-=N;do I[s++]=U[W++];while(--N);W=s-B,T=I}for(;x>2;)I[s++]=T[W++],I[s++]=T[W++],I[s++]=T[W++],x-=3;x&&(I[s++]=T[W++],x>1&&(I[s++]=T[W++]))}else{W=s-B;do I[s++]=I[W++],I[s++]=I[W++],I[s++]=I[W++],x-=3;while(x>2);x&&(I[s++]=I[W++],x>1&&(I[s++]=I[W++]))}}else if(N&64){e.msg="invalid distance code",h.mode=r6;break r}else{S=A[(S&65535)+(C&(1<<N)-1)];continue c}break}}else if(N&64)if(N&32){h.mode=rVr;break r}else{e.msg="invalid literal/length code",h.mode=r6;break r}else{S=D[(S&65535)+(C&(1<<N)-1)];continue e}break}}while(i<t&&s<o);x=p>>3,i-=x,p-=x<<3,C&=(1<<p)-1,e.next_in=i,e.next_out=s,e.avail_in=i<t?5+(t-i):5-(i-t),e.avail_out=s<o?257+(o-s):257-(s-o),h.hold=C,h.bits=p},nH=Ta,Nm=15,hH=852,iH=592,tH=0,I8=1,sH=2,cVr=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],nVr=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],hVr=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],iVr=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],tVr=function(e,n,h,i,t,s,a,o){var l=o.bits,m=0,d=0,u=0,U=0,C=0,p=0,D=0,A=0,f=0,M=0,S,N,x,B,W,T=null,L=0,I,J=new nH.Buf16(Nm+1),$=new nH.Buf16(Nm+1),sr=null,vr=0,pr,dr,zr;for(m=0;m<=Nm;m++)J[m]=0;for(d=0;d<i;d++)J[n[h+d]]++;for(C=l,U=Nm;U>=1&&J[U]===0;U--);if(C>U&&(C=U),U===0)return t[s++]=1<<24|64<<16|0,t[s++]=1<<24|64<<16|0,o.bits=1,0;for(u=1;u<U&&J[u]===0;u++);for(C<u&&(C=u),A=1,m=1;m<=Nm;m++)if(A<<=1,A-=J[m],A<0)return-1;if(A>0&&(e===tH||U!==1))return-1;for($[1]=0,m=1;m<Nm;m++)$[m+1]=$[m]+J[m];for(d=0;d<i;d++)n[h+d]!==0&&(a[$[n[h+d]]++]=d);if(e===tH?(T=sr=a,I=19):e===I8?(T=cVr,L-=257,sr=nVr,vr-=257,I=256):(T=hVr,sr=iVr,I=-1),M=0,d=0,m=u,W=s,p=C,D=0,x=-1,f=1<<C,B=f-1,e===I8&&f>hH||e===sH&&f>iH)return 1;for(;;){pr=m-D,a[d]<I?(dr=0,zr=a[d]):a[d]>I?(dr=sr[vr+a[d]],zr=T[L+a[d]]):(dr=96,zr=0),S=1<<m-D,N=1<<p,u=N;do N-=S,t[W+(M>>D)+N]=pr<<24|dr<<16|zr|0;while(N!==0);for(S=1<<m-1;M&S;)S>>=1;if(S!==0?(M&=S-1,M+=S):M=0,d++,--J[m]===0){if(m===U)break;m=n[h+a[d]]}if(m>C&&(M&B)!==x){for(D===0&&(D=C),W+=u,p=m-D,A=1<<p;p+D<U&&(A-=J[p+D],!(A<=0));)p++,A<<=1;if(f+=1<<p,e===I8&&f>hH||e===sH&&f>iH)return 1;x=M&B,t[x]=C<<24|p<<16|W-s|0}}return M!==0&&(t[W+M]=m-D<<24|64<<16|0),o.bits=C,0},Ui=Ta,V8=Lj,xs=Ij,sVr=eVr,c9=tVr,aVr=0,aH=1,oH=2,lH=4,oVr=5,e6=6,d2=0,lVr=1,mVr=2,Pi=-2,mH=-3,dH=-4,dVr=-5,uH=8,UH=1,zH=2,vH=3,CH=4,pH=5,DH=6,bH=7,gH=8,_H=9,AH=10,c6=11,Ya=12,F8=13,yH=14,k8=15,BH=16,ZH=17,fH=18,SH=19,n6=20,h6=21,MH=22,GH=23,NH=24,WH=25,TH=26,J8=27,XH=28,YH=29,Dn=30,wH=31,uVr=32,UVr=852,zVr=592,vVr=15,CVr=vVr;function EH(c){return(c>>>24&255)+(c>>>8&65280)+((c&65280)<<8)+((c&255)<<24)}function pVr(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Ui.Buf16(320),this.work=new Ui.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function xH(c){var e;return!c||!c.state?Pi:(e=c.state,c.total_in=c.total_out=e.total=0,c.msg="",e.wrap&&(c.adler=e.wrap&1),e.mode=UH,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Ui.Buf32(UVr),e.distcode=e.distdyn=new Ui.Buf32(zVr),e.sane=1,e.back=-1,d2)}function RH(c){var e;return!c||!c.state?Pi:(e=c.state,e.wsize=0,e.whave=0,e.wnext=0,xH(c))}function LH(c,e){var n,h;return!c||!c.state||(h=c.state,e<0?(n=0,e=-e):(n=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?Pi:(h.window!==null&&h.wbits!==e&&(h.window=null),h.wrap=n,h.wbits=e,RH(c))}function IH(c,e){var n,h;return c?(h=new pVr,c.state=h,h.window=null,n=LH(c,e),n!==d2&&(c.state=null),n):Pi}function DVr(c){return IH(c,CVr)}var VH=!0,j8,H8;function bVr(c){if(VH){var e;for(j8=new Ui.Buf32(512),H8=new Ui.Buf32(32),e=0;e<144;)c.lens[e++]=8;for(;e<256;)c.lens[e++]=9;for(;e<280;)c.lens[e++]=7;for(;e<288;)c.lens[e++]=8;for(c9(aH,c.lens,0,288,j8,0,c.work,{bits:9}),e=0;e<32;)c.lens[e++]=5;c9(oH,c.lens,0,32,H8,0,c.work,{bits:5}),VH=!1}c.lencode=j8,c.lenbits=9,c.distcode=H8,c.distbits=5}function FH(c,e,n,h){var i,t=c.state;return t.window===null&&(t.wsize=1<<t.wbits,t.wnext=0,t.whave=0,t.window=new Ui.Buf8(t.wsize)),h>=t.wsize?(Ui.arraySet(t.window,e,n-t.wsize,t.wsize,0),t.wnext=0,t.whave=t.wsize):(i=t.wsize-t.wnext,i>h&&(i=h),Ui.arraySet(t.window,e,n-h,i,t.wnext),h-=i,h?(Ui.arraySet(t.window,e,n-h,h,0),t.wnext=h,t.whave=t.wsize):(t.wnext+=i,t.wnext===t.wsize&&(t.wnext=0),t.whave<t.wsize&&(t.whave+=i))),0}function gVr(c,e){var n,h,i,t,s,a,o,l,m,d,u,U,C,p,D=0,A,f,M,S,N,x,B,W,T=new Ui.Buf8(4),L,I,J=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!c||!c.state||!c.output||!c.input&&c.avail_in!==0)return Pi;n=c.state,n.mode===Ya&&(n.mode=F8),s=c.next_out,i=c.output,o=c.avail_out,t=c.next_in,h=c.input,a=c.avail_in,l=n.hold,m=n.bits,d=a,u=o,W=d2;r:for(;;)switch(n.mode){case UH:if(n.wrap===0){n.mode=F8;break}for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(n.wrap&2&&l===35615){n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=xs(n.check,T,2,0),l=0,m=0,n.mode=zH;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){c.msg="incorrect header check",n.mode=Dn;break}if((l&15)!==uH){c.msg="unknown compression method",n.mode=Dn;break}if(l>>>=4,m-=4,B=(l&15)+8,n.wbits===0)n.wbits=B;else if(B>n.wbits){c.msg="invalid window size",n.mode=Dn;break}n.dmax=1<<B,c.adler=n.check=1,n.mode=l&512?AH:Ya,l=0,m=0;break;case zH:for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(n.flags=l,(n.flags&255)!==uH){c.msg="unknown compression method",n.mode=Dn;break}if(n.flags&57344){c.msg="unknown header flags set",n.mode=Dn;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=xs(n.check,T,2,0)),l=0,m=0,n.mode=vH;case vH:for(;m<32;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.head&&(n.head.time=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=xs(n.check,T,4,0)),l=0,m=0,n.mode=CH;case CH:for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=xs(n.check,T,2,0)),l=0,m=0,n.mode=pH;case pH:if(n.flags&1024){for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=xs(n.check,T,2,0)),l=0,m=0}else n.head&&(n.head.extra=null);n.mode=DH;case DH:if(n.flags&1024&&(U=n.length,U>a&&(U=a),U&&(n.head&&(B=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Ui.arraySet(n.head.extra,h,t,U,B)),n.flags&512&&(n.check=xs(n.check,h,U,t)),a-=U,t+=U,n.length-=U),n.length))break r;n.length=0,n.mode=bH;case bH:if(n.flags&2048){if(a===0)break r;U=0;do B=h[t+U++],n.head&&B&&n.length<65536&&(n.head.name+=String.fromCharCode(B));while(B&&U<a);if(n.flags&512&&(n.check=xs(n.check,h,U,t)),a-=U,t+=U,B)break r}else n.head&&(n.head.name=null);n.length=0,n.mode=gH;case gH:if(n.flags&4096){if(a===0)break r;U=0;do B=h[t+U++],n.head&&B&&n.length<65536&&(n.head.comment+=String.fromCharCode(B));while(B&&U<a);if(n.flags&512&&(n.check=xs(n.check,h,U,t)),a-=U,t+=U,B)break r}else n.head&&(n.head.comment=null);n.mode=_H;case _H:if(n.flags&512){for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(l!==(n.check&65535)){c.msg="header crc mismatch",n.mode=Dn;break}l=0,m=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),c.adler=n.check=0,n.mode=Ya;break;case AH:for(;m<32;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}c.adler=n.check=EH(l),l=0,m=0,n.mode=c6;case c6:if(n.havedict===0)return c.next_out=s,c.avail_out=o,c.next_in=t,c.avail_in=a,n.hold=l,n.bits=m,mVr;c.adler=n.check=1,n.mode=Ya;case Ya:if(e===oVr||e===e6)break r;case F8:if(n.last){l>>>=m&7,m-=m&7,n.mode=J8;break}for(;m<3;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}switch(n.last=l&1,l>>>=1,m-=1,l&3){case 0:n.mode=yH;break;case 1:if(bVr(n),n.mode=n6,e===e6){l>>>=2,m-=2;break r}break;case 2:n.mode=ZH;break;case 3:c.msg="invalid block type",n.mode=Dn}l>>>=2,m-=2;break;case yH:for(l>>>=m&7,m-=m&7;m<32;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if((l&65535)!==(l>>>16^65535)){c.msg="invalid stored block lengths",n.mode=Dn;break}if(n.length=l&65535,l=0,m=0,n.mode=k8,e===e6)break r;case k8:n.mode=BH;case BH:if(U=n.length,U){if(U>a&&(U=a),U>o&&(U=o),U===0)break r;Ui.arraySet(i,h,t,U,s),a-=U,t+=U,o-=U,s+=U,n.length-=U;break}n.mode=Ya;break;case ZH:for(;m<14;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(n.nlen=(l&31)+257,l>>>=5,m-=5,n.ndist=(l&31)+1,l>>>=5,m-=5,n.ncode=(l&15)+4,l>>>=4,m-=4,n.nlen>286||n.ndist>30){c.msg="too many length or distance symbols",n.mode=Dn;break}n.have=0,n.mode=fH;case fH:for(;n.have<n.ncode;){for(;m<3;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.lens[J[n.have++]]=l&7,l>>>=3,m-=3}for(;n.have<19;)n.lens[J[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,L={bits:n.lenbits},W=c9(aVr,n.lens,0,19,n.lencode,0,n.work,L),n.lenbits=L.bits,W){c.msg="invalid code lengths set",n.mode=Dn;break}n.have=0,n.mode=SH;case SH:for(;n.have<n.nlen+n.ndist;){for(;D=n.lencode[l&(1<<n.lenbits)-1],A=D>>>24,f=D>>>16&255,M=D&65535,!(A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(M<16)l>>>=A,m-=A,n.lens[n.have++]=M;else{if(M===16){for(I=A+2;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(l>>>=A,m-=A,n.have===0){c.msg="invalid bit length repeat",n.mode=Dn;break}B=n.lens[n.have-1],U=3+(l&3),l>>>=2,m-=2}else if(M===17){for(I=A+3;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}l>>>=A,m-=A,B=0,U=3+(l&7),l>>>=3,m-=3}else{for(I=A+7;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}l>>>=A,m-=A,B=0,U=11+(l&127),l>>>=7,m-=7}if(n.have+U>n.nlen+n.ndist){c.msg="invalid bit length repeat",n.mode=Dn;break}for(;U--;)n.lens[n.have++]=B}}if(n.mode===Dn)break;if(n.lens[256]===0){c.msg="invalid code -- missing end-of-block",n.mode=Dn;break}if(n.lenbits=9,L={bits:n.lenbits},W=c9(aH,n.lens,0,n.nlen,n.lencode,0,n.work,L),n.lenbits=L.bits,W){c.msg="invalid literal/lengths set",n.mode=Dn;break}if(n.distbits=6,n.distcode=n.distdyn,L={bits:n.distbits},W=c9(oH,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,L),n.distbits=L.bits,W){c.msg="invalid distances set",n.mode=Dn;break}if(n.mode=n6,e===e6)break r;case n6:n.mode=h6;case h6:if(a>=6&&o>=258){c.next_out=s,c.avail_out=o,c.next_in=t,c.avail_in=a,n.hold=l,n.bits=m,sVr(c,u),s=c.next_out,i=c.output,o=c.avail_out,t=c.next_in,h=c.input,a=c.avail_in,l=n.hold,m=n.bits,n.mode===Ya&&(n.back=-1);break}for(n.back=0;D=n.lencode[l&(1<<n.lenbits)-1],A=D>>>24,f=D>>>16&255,M=D&65535,!(A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(f&&!(f&240)){for(S=A,N=f,x=M;D=n.lencode[x+((l&(1<<S+N)-1)>>S)],A=D>>>24,f=D>>>16&255,M=D&65535,!(S+A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}l>>>=S,m-=S,n.back+=S}if(l>>>=A,m-=A,n.back+=A,n.length=M,f===0){n.mode=TH;break}if(f&32){n.back=-1,n.mode=Ya;break}if(f&64){c.msg="invalid literal/length code",n.mode=Dn;break}n.extra=f&15,n.mode=MH;case MH:if(n.extra){for(I=n.extra;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,m-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=GH;case GH:for(;D=n.distcode[l&(1<<n.distbits)-1],A=D>>>24,f=D>>>16&255,M=D&65535,!(A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(!(f&240)){for(S=A,N=f,x=M;D=n.distcode[x+((l&(1<<S+N)-1)>>S)],A=D>>>24,f=D>>>16&255,M=D&65535,!(S+A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}l>>>=S,m-=S,n.back+=S}if(l>>>=A,m-=A,n.back+=A,f&64){c.msg="invalid distance code",n.mode=Dn;break}n.offset=M,n.extra=f&15,n.mode=NH;case NH:if(n.extra){for(I=n.extra;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,m-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){c.msg="invalid distance too far back",n.mode=Dn;break}n.mode=WH;case WH:if(o===0)break r;if(U=u-o,n.offset>U){if(U=n.offset-U,U>n.whave&&n.sane){c.msg="invalid distance too far back",n.mode=Dn;break}U>n.wnext?(U-=n.wnext,C=n.wsize-U):C=n.wnext-U,U>n.length&&(U=n.length),p=n.window}else p=i,C=s-n.offset,U=n.length;U>o&&(U=o),o-=U,n.length-=U;do i[s++]=p[C++];while(--U);n.length===0&&(n.mode=h6);break;case TH:if(o===0)break r;i[s++]=n.length,o--,n.mode=h6;break;case J8:if(n.wrap){for(;m<32;){if(a===0)break r;a--,l|=h[t++]<<m,m+=8}if(u-=o,c.total_out+=u,n.total+=u,u&&(c.adler=n.check=n.flags?xs(n.check,i,u,s-u):V8(n.check,i,u,s-u)),u=o,(n.flags?l:EH(l))!==n.check){c.msg="incorrect data check",n.mode=Dn;break}l=0,m=0}n.mode=XH;case XH:if(n.wrap&&n.flags){for(;m<32;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(l!==(n.total&4294967295)){c.msg="incorrect length check",n.mode=Dn;break}l=0,m=0}n.mode=YH;case YH:W=lVr;break r;case Dn:W=mH;break r;case wH:return dH;case uVr:default:return Pi}return c.next_out=s,c.avail_out=o,c.next_in=t,c.avail_in=a,n.hold=l,n.bits=m,(n.wsize||u!==c.avail_out&&n.mode<Dn&&(n.mode<J8||e!==lH))&&FH(c,c.output,c.next_out,u-c.avail_out),d-=c.avail_in,u-=c.avail_out,c.total_in+=d,c.total_out+=u,n.total+=u,n.wrap&&u&&(c.adler=n.check=n.flags?xs(n.check,i,u,c.next_out-u):V8(n.check,i,u,c.next_out-u)),c.data_type=n.bits+(n.last?64:0)+(n.mode===Ya?128:0)+(n.mode===n6||n.mode===k8?256:0),(d===0&&u===0||e===lH)&&W===d2&&(W=dVr),W}function _Vr(c){if(!c||!c.state)return Pi;var e=c.state;return e.window&&(e.window=null),c.state=null,d2}function AVr(c,e){var n;return!c||!c.state||(n=c.state,!(n.wrap&2))?Pi:(n.head=e,e.done=!1,d2)}function yVr(c,e){var n=e.length,h,i,t;return!c||!c.state||(h=c.state,h.wrap!==0&&h.mode!==c6)?Pi:h.mode===c6&&(i=1,i=V8(i,e,n,0),i!==h.check)?mH:(t=FH(c,e,n,n),t?(h.mode=wH,dH):(h.havedict=1,d2))}jt.inflateReset=RH,jt.inflateReset2=LH,jt.inflateResetKeep=xH,jt.inflateInit=DVr,jt.inflateInit2=IH,jt.inflate=gVr,jt.inflateEnd=_Vr,jt.inflateGetHeader=AVr,jt.inflateSetDictionary=yVr,jt.inflateInfo="pako inflate (from Nodeca project)";var kH={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function BVr(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var ZVr=BVr,Wm=jt,n9=Ta,i6=l2,Jn=kH,K8=W8,fVr=$j,SVr=ZVr,JH=Object.prototype.toString;function u2(c){if(!(this instanceof u2))return new u2(c);this.options=n9.assign({chunkSize:16384,windowBits:0,to:""},c||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(c&&c.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new fVr,this.strm.avail_out=0;var n=Wm.inflateInit2(this.strm,e.windowBits);if(n!==Jn.Z_OK)throw new Error(K8[n]);if(this.header=new SVr,Wm.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=i6.string2buf(e.dictionary):JH.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=Wm.inflateSetDictionary(this.strm,e.dictionary),n!==Jn.Z_OK)))throw new Error(K8[n])}u2.prototype.push=function(c,e){var n=this.strm,h=this.options.chunkSize,i=this.options.dictionary,t,s,a,o,l,m=!1;if(this.ended)return!1;s=e===~~e?e:e===!0?Jn.Z_FINISH:Jn.Z_NO_FLUSH,typeof c=="string"?n.input=i6.binstring2buf(c):JH.call(c)==="[object ArrayBuffer]"?n.input=new Uint8Array(c):n.input=c,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new n9.Buf8(h),n.next_out=0,n.avail_out=h),t=Wm.inflate(n,Jn.Z_NO_FLUSH),t===Jn.Z_NEED_DICT&&i&&(t=Wm.inflateSetDictionary(this.strm,i)),t===Jn.Z_BUF_ERROR&&m===!0&&(t=Jn.Z_OK,m=!1),t!==Jn.Z_STREAM_END&&t!==Jn.Z_OK)return this.onEnd(t),this.ended=!0,!1;n.next_out&&(n.avail_out===0||t===Jn.Z_STREAM_END||n.avail_in===0&&(s===Jn.Z_FINISH||s===Jn.Z_SYNC_FLUSH))&&(this.options.to==="string"?(a=i6.utf8border(n.output,n.next_out),o=n.next_out-a,l=i6.buf2string(n.output,a),n.next_out=o,n.avail_out=h-o,o&&n9.arraySet(n.output,n.output,a,o,0),this.onData(l)):this.onData(n9.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(m=!0)}while((n.avail_in>0||n.avail_out===0)&&t!==Jn.Z_STREAM_END);return t===Jn.Z_STREAM_END&&(s=Jn.Z_FINISH),s===Jn.Z_FINISH?(t=Wm.inflateEnd(this.strm),this.onEnd(t),this.ended=!0,t===Jn.Z_OK):(s===Jn.Z_SYNC_FLUSH&&(this.onEnd(Jn.Z_OK),n.avail_out=0),!0)},u2.prototype.onData=function(c){this.chunks.push(c)},u2.prototype.onEnd=function(c){c===Jn.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=n9.flattenChunks(this.chunks)),this.chunks=[],this.err=c,this.msg=this.strm.msg};function P8(c,e){var n=new u2(e);if(n.push(c,!0),n.err)throw n.msg||K8[n.err];return n.result}function MVr(c,e){return e=e||{},e.raw=!0,P8(c,e)}e9.Inflate=u2,e9.inflate=P8,e9.inflateRaw=MVr,e9.ungzip=P8;var GVr=Ta.assign,NVr=V4,WVr=e9,TVr=kH,jH={};GVr(jH,NVr,WVr,TVr);var t6=jH;async function Tm(c){try{let e,n=0,h=0;const i=[];let t=0,s;do{const o=c.subarray(n);if(s=new t6.Inflate,{strm:e}=s,s.push(o,t6.Z_SYNC_FLUSH),s.err)throw new Error(s.msg);n+=e.next_in,i[h]=s.result,t+=i[h].length,h+=1}while(e.avail_in);const a=new Uint8Array(t);for(let o=0,l=0;o<i.length;o++)a.set(i[o],l),l+=i[o].length;return Ti.from(a)}catch(e){throw/incorrect header check/.exec(`${e}`)?new Error("problem decompressing block: incorrect gzip header check"):e}}async function HH(c,e){try{let n;const{minv:h,maxv:i}=e;let t=h.blockPosition,s=h.dataPosition;const a=[],o=[],l=[];let m=0,d=0;do{const C=c.subarray(t-h.blockPosition),p=new t6.Inflate;if({strm:n}=p,p.push(C,t6.Z_SYNC_FLUSH),p.err)throw new Error(p.msg);const D=p.result;a.push(D);let A=D.length;o.push(t),l.push(s),a.length===1&&h.dataPosition&&(a[0]=a[0].subarray(h.dataPosition),A=a[0].length);const f=t;if(t+=n.next_in,s+=A,f>=i.blockPosition){a[d]=a[d].subarray(0,i.blockPosition===h.blockPosition?i.dataPosition-h.dataPosition+1:i.dataPosition+1),o.push(t),l.push(s),m+=a[d].length;break}m+=a[d].length,d++}while(n.avail_in);const u=new Uint8Array(m);for(let C=0,p=0;C<a.length;C++)u.set(a[C],p),p+=a[C].length;return{buffer:Ti.from(u),cpositions:o,dpositions:l}}catch(n){throw/incorrect header check/.exec(`${n}`)?new Error("problem decompressing block: incorrect gzip header check"):n}}class XVr{}class YVr{constructor(){this.signals=new Set,this.abortController=new AbortController}addSignal(e=new XVr){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(e),e.aborted?this.handleAborted(e):typeof e.addEventListener=="function"&&e.addEventListener("abort",()=>{this.handleAborted(e)})}handleAborted(e){this.signals.delete(e),this.signals.size===0&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}class wVr{constructor(){this.callbacks=new Set}addCallback(e=()=>{}){this.callbacks.add(e),e(this.currentMessage)}callback(e){this.currentMessage=e;for(const n of this.callbacks)n(e)}}class h9{constructor({fill:e,cache:n}){if(typeof e!="function")throw new TypeError("must pass a fill function");if(typeof n!="object")throw new TypeError("must pass a cache object");if(typeof n.get!="function"||typeof n.set!="function"||typeof n.delete!="function")throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=n,this.fillCallback=e}static isAbortException(e){return e.name==="AbortError"||e.code==="ERR_ABORTED"||e.message==="AbortError: aborted"||e.message==="Error: aborted"}evict(e,n){this.cache.get(e)===n&&this.cache.delete(e)}fill(e,n,h,i){const t=new YVr,s=new wVr;s.addCallback(i);const a={aborter:t,promise:this.fillCallback(n,t.signal,o=>{s.callback(o)}),settled:!1,statusReporter:s,get aborted(){return this.aborter.signal.aborted}};a.aborter.addSignal(h),a.aborter.signal.addEventListener("abort",()=>{a.settled||this.evict(e,a)}),a.promise.then(()=>{a.settled=!0},()=>{a.settled=!0,this.evict(e,a)}).catch(o=>{throw console.error(o),o}),this.cache.set(e,a)}static checkSinglePromise(e,n){function h(){if(n!=null&&n.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return e.then(i=>(h(),i),i=>{throw h(),i})}has(e){return this.cache.has(e)}get(e,n,h,i){if(!h&&n instanceof AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const t=this.cache.get(e);return t?t.aborted&&!t.settled?(this.evict(e,t),this.get(e,n,h,i)):t.settled?t.promise:(t.aborter.addSignal(h),t.statusReporter.addCallback(i),h9.checkSinglePromise(t.promise,h)):(this.fill(e,n,h,i),h9.checkSinglePromise(this.cache.get(e).promise,h))}delete(e){const n=this.cache.get(e);n&&(n.settled||n.aborter.abort(),this.cache.delete(e))}clear(){const e=this.cache.keys();let n=0;for(let h=e.next();!h.done;h=e.next())this.delete(h.value),n+=1;return n}}const EVr=21582659,xVr=38359875;function RVr(c,e){return c*2**e}function KH(c,e){return Math.floor(c/2**e)}let O8=class extends vj{constructor(){super(...arguments),this.maxBinNumber=0,this.depth=0,this.minShift=0}async lineCount(e,n){var h,i;return((i=(h=(await this.parse(n)).indices[e])===null||h===void 0?void 0:h.stats)===null||i===void 0?void 0:i.lineCount)||0}async indexCov(){return[]}parseAuxData(e,n){const h=e.readInt32LE(n),i=h&65536?"zero-based-half-open":"1-based-closed",t={0:"generic",1:"SAM",2:"VCF"}[h&15];if(!t)throw new Error(`invalid Tabix preset format flags ${h}`);const s={ref:e.readInt32LE(n+4),start:e.readInt32LE(n+8),end:e.readInt32LE(n+12)},a=e.readInt32LE(n+16),o=a?String.fromCharCode(a):"",l=e.readInt32LE(n+20),m=e.readInt32LE(n+24);return{columnNumbers:s,coordinateType:i,metaValue:a,metaChar:o,skipLines:l,format:t,formatFlags:h,...YLr(e.subarray(n+28,n+28+m),this.renameRefSeq)}}async _parse(e){const n=await this.filehandle.readFile(e),h=await Tm(n);let i;if(h.readUInt32LE(0)===EVr)i=1;else if(h.readUInt32LE(0)===xVr)i=2;else throw new Error("Not a CSI file");this.minShift=h.readInt32LE(4),this.depth=h.readInt32LE(8),this.maxBinNumber=((1<<(this.depth+1)*3)-1)/7;const t=h.readInt32LE(12),s=t>=30?this.parseAuxData(h,16):void 0,a=h.readInt32LE(16+t);let o=16+t+4,l;const m=new Array(a);for(let d=0;d<a;d++){const u=h.readInt32LE(o);o+=4;const U={};let C;for(let p=0;p<u;p++){const D=h.readUInt32LE(o);if(o+=4,D>this.maxBinNumber)C=zj(h,o+28),o+=44;else{l=kv(l,Am(h,o)),o+=8;const A=h.readInt32LE(o);o+=4;const f=new Array(A);for(let M=0;M<A;M+=1){const S=Am(h,o);o+=8;const N=Am(h,o);o+=8,l=kv(l,S),f[M]=new uj(S,N,D)}U[D]=f}}m[d]={binIndex:U,stats:C}}return{csiVersion:i,firstDataLine:l,indices:m,refCount:a,csi:!0,maxBlockSize:65536,...s}}async blocksForRange(e,n,h,i={}){n<0&&(n=0);const t=await this.parse(i),s=t==null?void 0:t.indices[e];if(!s)return[];const a=this.reg2bins(n,h);if(a.length===0)return[];const o=[];for(const[l,m]of a)for(let d=l;d<=m;d++)if(s.binIndex[d]){const u=s.binIndex[d];for(const U of u)o.push(U)}return Uj(o,new dj(0,0))}reg2bins(e,n){e-=1,e<1&&(e=1),n>2**50&&(n=2**34),n-=1;let h=0,i=0,t=this.minShift+this.depth*3;const s=[];for(;h<=this.depth;t-=3,i+=RVr(1,h*3),h+=1){const a=i+KH(e,t),o=i+KH(n,t);if(o-a+s.length>this.maxBinNumber)throw new Error(`query ${e}-${n} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);s.push([a,o])}return s}async parse(e={}){return this.setupP||(this.setupP=this._parse(e).catch(n=>{throw this.setupP=void 0,n})),this.setupP}async hasRefSeq(e,n={}){var h;return!!(!((h=(await this.parse(n)).indices[e])===null||h===void 0)&&h.binIndex)}};const Oi={BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048},PH="=ACMGRSVTWYHKDBN".split(""),i9="MIDNSHP=X???????".split("");class LVr{constructor(e){this.data={},this._tagList=[],this._allTagsParsed=!1;const{bytes:n,fileOffset:h}=e,{byteArray:i,start:t}=n;this.data={start:i.readInt32LE(t+8)},this.bytes=n,this._id=h,this._refID=i.readInt32LE(t+4),this.flags=(i.readInt32LE(t+16)&4294901760)>>16}get(e){return this[e]?this.data[e]?this.data[e]:(this.data[e]=this[e](),this.data[e]):this._get(e.toLowerCase())}end(){return this.get("start")+this.get("length_on_ref")}seq_id(){return this._refID}_get(e){return e in this.data?this.data[e]:(this.data[e]=this._parseTag(e),this.data[e])}_tags(){this._parseAllTags();let e=["seq"];this.isSegmentUnmapped()||e.push("start","end","strand","score","qual","MQ","CIGAR","length_on_ref","template_length"),this.isPaired()&&e.push("next_segment_position","pair_orientation"),e=e.concat(this._tagList||[]);for(const h of Object.keys(this.data))!h.startsWith("_")&&h!=="next_seq_id"&&e.push(h);const n={};return e.filter(h=>{if(h in this.data&&this.data[h]===void 0||h==="CG"||h==="cg")return!1;const i=h.toLowerCase(),t=n[i];return n[i]=!0,!t})}parent(){}children(){return this.get("subfeatures")}id(){return this._id}mq(){const e=(this.get("_bin_mq_nl")&65280)>>8;return e===255?void 0:e}score(){return this.get("mq")}qual(){var e;return(e=this.qualRaw())===null||e===void 0?void 0:e.join(" ")}qualRaw(){if(this.isSegmentUnmapped())return;const{start:e,byteArray:n}=this.bytes,h=e+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4+this.get("_seq_bytes"),i=this.get("seq_length");return n.subarray(h,h+i)}strand(){return this.isReverseComplemented()?-1:1}multi_segment_next_segment_strand(){if(!this.isMateUnmapped())return this.isMateReverseComplemented()?-1:1}name(){return this.get("_read_name")}_read_name(){const e=this.get("_l_read_name"),{byteArray:n,start:h}=this.bytes;return n.toString("ascii",h+36,h+36+e-1)}_parseTag(e){if(this._allTagsParsed)return;const{byteArray:n,start:h}=this.bytes;let i=this._tagOffset||h+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4+this.get("_seq_bytes")+this.get("seq_length");const t=this.bytes.end;let s;for(;i<t&&s!==e;){const a=String.fromCharCode(n[i],n[i+1]);s=a.toLowerCase();const o=String.fromCharCode(n[i+2]);i+=3;let l;switch(o){case"A":{l=String.fromCharCode(n[i]),i+=1;break}case"i":{l=n.readInt32LE(i),i+=4;break}case"I":{l=n.readUInt32LE(i),i+=4;break}case"c":{l=n.readInt8(i),i+=1;break}case"C":{l=n.readUInt8(i),i+=1;break}case"s":{l=n.readInt16LE(i),i+=2;break}case"S":{l=n.readUInt16LE(i),i+=2;break}case"f":{l=n.readFloatLE(i),i+=4;break}case"Z":case"H":{for(l="";i<=t;){const m=n[i++];if(m===0)break;l+=String.fromCharCode(m)}break}case"B":{l="";const m=n[i++],d=String.fromCharCode(m),u=n.readInt32LE(i);if(i+=4,d==="i")if(a==="CG")for(let U=0;U<u;U++){const C=n.readInt32LE(i),p=C>>4,D=i9[C&15];l+=p+D,i+=4}else for(let U=0;U<u;U++)l+=n.readInt32LE(i),U+1<u&&(l+=","),i+=4;if(d==="I")if(a==="CG")for(let U=0;U<u;U++){const C=n.readUInt32LE(i),p=C>>4,D=i9[C&15];l+=p+D,i+=4}else for(let U=0;U<u;U++)l+=n.readUInt32LE(i),U+1<u&&(l+=","),i+=4;if(d==="s")for(let U=0;U<u;U++)l+=n.readInt16LE(i),U+1<u&&(l+=","),i+=2;if(d==="S")for(let U=0;U<u;U++)l+=n.readUInt16LE(i),U+1<u&&(l+=","),i+=2;if(d==="c")for(let U=0;U<u;U++)l+=n.readInt8(i),U+1<u&&(l+=","),i+=1;if(d==="C")for(let U=0;U<u;U++)l+=n.readUInt8(i),U+1<u&&(l+=","),i+=1;if(d==="f")for(let U=0;U<u;U++)l+=n.readFloatLE(i),U+1<u&&(l+=","),i+=4;break}default:console.warn(`Unknown BAM tag type '${o}', tags may be incomplete`),l=void 0,i=t}if(this._tagOffset=i,this._tagList.push(a),s===e)return l;this.data[s]=l}this._allTagsParsed=!0}_parseAllTags(){this._parseTag("")}_parseCigar(e){return e.match(/\d+\D/g).map(n=>[/\D/.exec(n)[0].toUpperCase(),Number.parseInt(n,10)])}isPaired(){return!!(this.flags&Oi.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&Oi.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&Oi.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&Oi.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&Oi.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&Oi.BAM_FMREVERSE)}isRead1(){return!!(this.flags&Oi.BAM_FREAD1)}isRead2(){return!!(this.flags&Oi.BAM_FREAD2)}isSecondary(){return!!(this.flags&Oi.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&Oi.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&Oi.BAM_FDUP)}isSupplementary(){return!!(this.flags&Oi.BAM_FSUPPLEMENTARY)}cigar(){if(this.isSegmentUnmapped())return;const{byteArray:e,start:n}=this.bytes,h=this.get("_n_cigar_op");let i=n+36+this.get("_l_read_name");const t=this.get("seq_length");let s="",a=0,o=e.readInt32LE(i),l=o>>4,m=i9[o&15];if(m==="S"&&l===t)return i+=4,o=e.readInt32LE(i),l=o>>4,m=i9[o&15],m!=="N"&&console.warn("CG tag with no N tag"),this.data.length_on_ref=l,this.get("CG");for(let d=0;d<h;++d)o=e.readInt32LE(i),l=o>>4,m=i9[o&15],s+=l+m,m!=="H"&&m!=="S"&&m!=="I"&&(a+=l),i+=4;return this.data.length_on_ref=a,s}length_on_ref(){return this.data.length_on_ref?this.data.length_on_ref:(this.get("cigar"),this.data.length_on_ref)}_n_cigar_op(){return this.get("_flag_nc")&65535}_l_read_name(){return this.get("_bin_mq_nl")&255}_seq_bytes(){return this.get("seq_length")+1>>1}getReadBases(){return this.seq()}seq(){const{byteArray:e,start:n}=this.bytes,h=n+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4,i=this.get("_seq_bytes"),t=this.get("seq_length");let s="",a=0;for(let o=0;o<i;++o){const l=e[h+o];s+=PH[(l&240)>>4],a++,a<t&&(s+=PH[l&15],a++)}return s}getPairOrientation(){if(!this.isSegmentUnmapped()&&!this.isMateUnmapped()&&this._refID===this._next_refid()){const e=this.isReverseComplemented()?"R":"F",n=this.isMateReverseComplemented()?"R":"F";let h=" ",i=" ";this.isRead1()?(h="1",i="2"):this.isRead2()&&(h="2",i="1");const t=[];return this.template_length()>0?(t[0]=e,t[1]=h,t[2]=n,t[3]=i):(t[2]=e,t[3]=h,t[0]=n,t[1]=i),t.join("")}return""}_bin_mq_nl(){return this.bytes.byteArray.readInt32LE(this.bytes.start+12)}_flag_nc(){return this.bytes.byteArray.readInt32LE(this.bytes.start+16)}seq_length(){return this.bytes.byteArray.readInt32LE(this.bytes.start+20)}_next_refid(){return this.bytes.byteArray.readInt32LE(this.bytes.start+24)}_next_pos(){return this.bytes.byteArray.readInt32LE(this.bytes.start+28)}template_length(){return this.bytes.byteArray.readInt32LE(this.bytes.start+32)}toJSON(){const e={};for(const n of Object.keys(this))n.startsWith("_")||n==="bytes"||(e[n]=this[n]);return e}}function IVr(c){const e=c.split(/\r?\n/),n=[];for(const h of e){const[i,...t]=h.split(/\t/);i&&n.push({tag:i.slice(1),data:t.map(s=>{const a=s.indexOf(":"),o=s.slice(0,a),l=s.slice(a+1);return{tag:o,value:l}})})}return n}const VVr=21840194,OH=65536;async function FVr(c){let e=[];for await(const n of c)e=e.concat(n);return e}class kVr{read(){throw new Error("never called")}stat(){throw new Error("never called")}readFile(){throw new Error("never called")}close(){throw new Error("never called")}}class QH{constructor({bamFilehandle:e,bamPath:n,bamUrl:h,baiPath:i,baiFilehandle:t,baiUrl:s,csiPath:a,csiFilehandle:o,csiUrl:l,htsget:m,yieldThreadTime:d=100,renameRefSeqs:u=U=>U}){if(this.htsget=!1,this.featureCache=new h9({cache:new D7({maxSize:50}),fill:async(U,C)=>{const{chunk:p,opts:D}=U,{data:A,cpositions:f,dpositions:M}=await this._readChunk({chunk:p,opts:{...D,signal:C}});return this.readBamFeatures(A,f,M,p)}}),this.renameRefSeq=u,e)this.bam=e;else if(n)this.bam=new pa(n);else if(h)this.bam=new p1(h);else if(m)this.htsget=!0,this.bam=new kVr;else throw new Error("unable to initialize bam");if(o)this.index=new O8({filehandle:o});else if(a)this.index=new O8({filehandle:new pa(a)});else if(l)this.index=new O8({filehandle:new p1(l)});else if(t)this.index=new I4({filehandle:t});else if(i)this.index=new I4({filehandle:new pa(i)});else if(s)this.index=new I4({filehandle:new p1(s)});else if(n)this.index=new I4({filehandle:new pa(`${n}.bai`)});else if(h)this.index=new I4({filehandle:new p1(`${h}.bai`)});else if(m)this.htsget=!0;else throw new Error("unable to infer index format");this.yieldThreadTime=d}async getHeaderPre(e){const n=XLr(e);if(!this.index)return;const h=await this.index.parse(n),i=h.firstDataLine?h.firstDataLine.blockPosition+65535:void 0;let t;if(i){const m=i+OH,d=await this.bam.read(Ti.alloc(m),0,m,0,n);if(!d.bytesRead)throw new Error("Error reading header");t=d.buffer.subarray(0,Math.min(d.bytesRead,i))}else t=await this.bam.readFile(n);const s=await Tm(t);if(s.readInt32LE(0)!==VVr)throw new Error("Not a BAM file");const a=s.readInt32LE(4);this.header=s.toString("utf8",8,8+a);const{chrToIndex:o,indexToChr:l}=await this._readRefSeqs(a+8,65535,n);return this.chrToIndex=o,this.indexToChr=l,IVr(this.header)}getHeader(e){return this.headerP||(this.headerP=this.getHeaderPre(e).catch(n=>{throw this.headerP=void 0,n})),this.headerP}async getHeaderText(e={}){return await this.getHeader(e),this.header}async _readRefSeqs(e,n,h){if(e>n)return this._readRefSeqs(e,n*2,h);const i=n+OH,{bytesRead:t,buffer:s}=await this.bam.read(Ti.alloc(i),0,n,0,h);if(!t)throw new Error("Error reading refseqs from header");const a=await Tm(s.subarray(0,Math.min(t,n))),o=a.readInt32LE(e);let l=e+4;const m={},d=[];for(let u=0;u<o;u+=1){const U=a.readInt32LE(l),C=this.renameRefSeq(a.toString("utf8",l+4,l+4+U-1)),p=a.readInt32LE(l+U+4);if(m[C]=u,d.push({refName:C,length:p}),l=l+8+U,l>a.length)return console.warn(`BAM header is very big. Re-fetching ${n} bytes.`),this._readRefSeqs(e,n*2,h)}return{chrToIndex:m,indexToChr:d}}async getRecordsForRange(e,n,h,i){return FVr(this.streamRecordsForRange(e,n,h,i))}async*streamRecordsForRange(e,n,h,i){var t;await this.getHeader(i);const s=(t=this.chrToIndex)===null||t===void 0?void 0:t[e];if(s===void 0||!this.index)yield[];else{const a=await this.index.blocksForRange(s,n-1,h,i);yield*this._fetchChunkFeatures(a,s,n,h,i)}}async*_fetchChunkFeatures(e,n,h,i,t={}){const{viewAsPairs:s}=t,a=[];let o=!1;for(const l of e){const m=await this.featureCache.get(l.toString(),{chunk:l,opts:t},t.signal),d=[];for(const u of m)if(u.seq_id()===n)if(u.get("start")>=i){o=!0;break}else u.get("end")>=h&&d.push(u);if(a.push(d),yield d,o)break}WLr(t.signal),s&&(yield this.fetchPairs(n,a,t))}async fetchPairs(e,n,h){const{pairAcrossChr:i,maxInsertSize:t=2e5}=h,s={},a={};n.map(u=>{const U={};for(const C of u){const p=C.name(),D=C.id();U[p]||(U[p]=0),U[p]++,a[D]=1}for(const[C,p]of Object.entries(U))p===1&&(s[C]=!0)});const o=[];n.map(u=>{for(const U of u){const C=U.name(),p=U.get("start"),D=U._next_pos(),A=U._next_refid();this.index&&s[C]&&(i||A===e&&Math.abs(p-D)<t)&&o.push(this.index.blocksForRange(A,D,D+1,h))}});const l=new Map,m=await Promise.all(o);for(const u of m.flat())l.has(u.toString())||l.set(u.toString(),u);return(await Promise.all([...l.values()].map(async u=>{const{data:U,cpositions:C,dpositions:p,chunk:D}=await this._readChunk({chunk:u,opts:h}),A=[];for(const f of await this.readBamFeatures(U,C,p,D))s[f.get("name")]&&!a[f.id()]&&A.push(f);return A}))).flat()}async _readRegion(e,n,h={}){const{bytesRead:i,buffer:t}=await this.bam.read(Ti.alloc(n),0,n,e,h);return t.subarray(0,Math.min(i,n))}async _readChunk({chunk:e,opts:n}){const h=await this._readRegion(e.minv.blockPosition,e.fetchedSize(),n),{buffer:i,cpositions:t,dpositions:s}=await HH(h,e);return{data:i,cpositions:t,dpositions:s,chunk:e}}async readBamFeatures(e,n,h,i){let t=0;const s=[];let a=0,o=+Date.now();for(;t+4<e.length;){const l=e.readInt32LE(t),m=t+4+l-1;if(h){for(;t+i.minv.dataPosition>=h[a++];);a--}if(m<e.length){const d=new LVr({bytes:{byteArray:e,start:t,end:m},fileOffset:n.length>0?n[a]*256+(t-h[a])+i.minv.dataPosition+1:VLr.signed(e.slice(t,m))});s.push(d),this.yieldThreadTime&&+Date.now()-o>this.yieldThreadTime&&(await GLr(1),o=+Date.now())}t=m+1}return s}async hasRefSeq(e){var n,h;const i=(n=this.chrToIndex)===null||n===void 0?void 0:n[e];return i===void 0?!1:(h=this.index)===null||h===void 0?void 0:h.hasRefSeq(i)}async lineCount(e){var n;const h=(n=this.chrToIndex)===null||n===void 0?void 0:n[e];return h===void 0||!this.index?0:this.index.lineCount(h)}async indexCov(e,n,h){var i;if(!this.index)return[];await this.index.parse();const t=(i=this.chrToIndex)===null||i===void 0?void 0:i[e];return t===void 0?[]:this.index.indexCov(t,n,h)}async blocksForRange(e,n,h,i){var t;if(!this.index)return[];await this.index.parse();const s=(t=this.chrToIndex)===null||t===void 0?void 0:t[e];return s===void 0?[]:this.index.blocksForRange(s,n,h,i)}}class Q8{constructor(e){q(this,"bam");q(this,"header");if(this.bam=null,typeof e=="string")this.bam=new QH({bamUrl:e,baiUrl:e+".bai"});else{const n=new rm(e.filter(i=>i.name.endsWith(".bai"))[0]),h=new rm(e.filter(i=>!i.name.endsWith(".bai"))[0]);this.bam=new QH({bamFilehandle:h,baiFilehandle:n})}this.header=null}async getData(e,n,h={}){this.header||(this.header=await this.bam.getHeader());const i=e.map(o=>this.bam.getRecordsForRange(o.chr,o.start,o.end));return(await Promise.all(i)).flat(1).map(o=>Object.assign(o,{ref:this.bam.indexToChr[o.get("seq_id")].refName}))}}function q8(){}class $8 extends E.Component{constructor(n){super(n);q(this,"originEvent");this.originEvent=null,this.mousedown=this.mousedown.bind(this),this.mousemove=this.mousemove.bind(this),this.mouseup=this.mouseup.bind(this)}mousedown(n){this.originEvent===null&&n.button===this.props.mouseButton&&(n.persist(),this.originEvent=n,this.props.onDragStart(n))}mousemove(n){if(this.originEvent!==null){const h={dx:n.clientX-this.originEvent.clientX,dy:n.clientY-this.originEvent.clientY};this.props.onDrag(n,h)}}mouseup(n){if(this.originEvent!==null){const h={dx:n.clientX-this.originEvent.clientX,dy:n.clientY-this.originEvent.clientY};this.props.onDragEnd(n,h),this.originEvent=null}}render(){const{mouseButton:n,onDragStart:h,onDrag:i,onDragEnd:t,children:s,...a}=this.props;return _.jsx("div",{onMouseDown:this.mousedown,onMouseMove:this.mousemove,onMouseUp:this.mouseup,...a,children:s})}}q($8,"defaultProps",{onDragStart:q8,onDrag:q8,onDragEnd:q8});const JVr=27;class qH extends E.PureComponent{constructor(e){super(e),this.state={isDragging:!1,dragStartX:0,currentDragX:0},this.dragStart=this.dragStart.bind(this),this.drag=this.drag.bind(this),this.dragEnd=this.dragEnd.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),window.addEventListener("keyup",this.handleKeyUp)}componentWillUnmount(){window.removeEventListener("keyup",this.handleKeyUp)}isInDragLimits(e){return this.props.dragLimits.start<e&&e<this.props.dragLimits.end}getSelectedSpan(){return new Y0(Math.floor(Math.min(this.state.dragStartX,this.state.currentDragX)),Math.floor(Math.max(this.state.dragStartX,this.state.currentDragX)))}dragStart(e){e.preventDefault();const n=kD(e).x;this.isInDragLimits(n)&&this.setState({isDragging:!0,dragStartX:n,currentDragX:n})}drag(e){const n=kD(e).x;this.isInDragLimits(n)&&this.setState({currentDragX:n})}dragEnd(){if(this.state.isDragging){const e=this.getSelectedSpan();this.props.getIsAreaValid(e)&&this.props.onAreaSelected(e),this.setState({isDragging:!1})}}handleKeyUp(e){e.keyCode===JVr&&this.setState({isDragging:!1})}render(){const{mouseButton:e,height:n,y:h,getInnerElement:i,getIsAreaValid:t,children:s}=this.props;let a;if(this.state.isDragging){const o=this.getSelectedSpan();let l="SelectableArea-box";t(o)||(l+=" SelectableArea-box-invalid");const m={left:o.start+"px",top:h,width:o.getLength()+"px",height:n};a=_.jsx("div",{className:l,style:m,children:i(o)})}return _.jsxs($8,{mouseButton:e,onDragStart:this.dragStart,onDrag:this.drag,onDragEnd:this.dragEnd,style:{position:"relative"},children:[a,s]})}}q(qH,"defaultProps",{mouseButton:pU.LEFT,y:"0px",height:"100%",dragLimits:new Y0(-1/0,1/0),getInnerElement:()=>null,getIsAreaValid:()=>!0,onAreaSelected:()=>{}});const jVr=5;class $H extends E.PureComponent{constructor(e){super(e),this.getBoxCaption=this.getBoxCaption.bind(this),this.getIsAreaValid=this.getIsAreaValid.bind(this),this.handleAreaSelect=this.handleAreaSelect.bind(this)}getSelectedBases(e){const{selectableRegion:n,dragLimits:h}=this.props,i=n.getNavigationContext(),t=new Bh(n,h.getLength());return new Y0(s(e.start),s(e.end));function s(a){a-=h.start;const o=t.xToBase(a);return i.toGaplessCoordinate(Math.round(o))}}getIsBaseSpanValid(e){return e.getLength()>=jVr}getIsAreaValid(e){return this.getIsBaseSpanValid(this.getSelectedBases(e))}getBoxCaption(e){const n=this.getSelectedBases(e);return _.jsxs("div",{className:"SelectableArea-box-text-container",children:[_.jsx("h4",{style:{margin:0},children:Ds(n.getLength())}),_.jsx("p",{className:"SelectableArea-box-secondary-text",children:this.getIsBaseSpanValid(n)?"Esc to cancel":"Too small"})]})}handleAreaSelect(e){const n=this.getSelectedBases(e);this.getIsBaseSpanValid(n)&&this.props.onRegionSelected(n.start,n.end,this.props.selectedTool?this.props.selectedTool.title:"isJump")}render(){const{dragLimits:e,y:n,height:h,children:i}=this.props;return _.jsx(qH,{y:n,height:h,dragLimits:e,getInnerElement:this.getBoxCaption,getIsAreaValid:this.getIsAreaValid,onAreaSelected:this.handleAreaSelect,children:i})}}const HVr=({navContext:c,onRegionSelected:e,handleCloseModal:n,onNewHighlight:h,doHighlight:i,color:t,background:s,genomeConfig:a})=>{const o=l=>{const m=c.convertGenomeIntervalToBases(l.getLocus())[0];m?(e(m.start,m.end,"isJump",i),n()):console.log("Gene not available in current region set view","error",2e3)};return _.jsx(jX,{onGeneSelected:o,simpleMode:!1,voiceInput:!0,color:t,background:s,genomeConfig:a})},KVr=250,PVr={hg19:"https://grch37.rest.ensembl.org/variation/human",hg38:"https://rest.ensembl.org/variation/human"},OVr=({genomeConfig:c,navContext:e,onRegionSelected:n,handleCloseModal:h,onNewHighlight:i,doHighlight:t,color:s,background:a})=>{const[o,l]=E.useState(""),[m,d]=E.useState(null),[u,U]=E.useState(""),C=f=>{l(f.target.value)},p=E.useCallback(Qr.debounce(async()=>{const f=o.trim();if(f.length<1){console.log("Please input a valid SNP id.","error",2e3);return}const M=c.genome.getName(),S=PVr[M];if(!S){console.log("This genome is not supported in SNP search.","error",2e3);return}U("searching...");try{const N=await fetch(`${S}/${f}`,{headers:{"Content-Type":"application/json"}});if(!N.ok)throw new Error("Network response was not ok");const x=await N.json();d(x)}catch{console.log("Error fetching SNP data.","error",2e3)}finally{U("")}},KVr),[o,c.genome]),D=f=>{const M=new J0(`chr${f.seq_region_name}`,f.start-1,f.end),S=e.convertGenomeIntervalToBases(M)[0];S?(n(S.start,S.end,"isJump",t),h(),t&&i&&i(S.start,S.end,o.trim())):console.log("SNP not available in current region set view","error",2e3)},A=f=>_.jsx("table",{className:"table table-sm table-striped table-bordered",children:_.jsxs("tbody",{children:[_.jsxs("tr",{children:[_.jsx("td",{children:"name"}),_.jsx("td",{children:f.name})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"location"}),_.jsx("td",{children:_.jsx("ol",{style:{marginBottom:0},children:f.mappings.map((M,S)=>_.jsxs("li",{style:{color:"#3f51b5",textDecoration:"underline",cursor:"pointer"},onClick:()=>D(M),children:["chr",M.location," ",M.strand===1?"+":"-"," ",M.allele_string]},S))})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"ambiguity"}),_.jsx("td",{children:f.ambiguity})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"ancestral_allele"}),_.jsx("td",{children:f.ancestral_allele})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"synonyms"}),_.jsx("td",{children:_.jsx("ol",{style:{marginBottom:0},children:f.synonyms.map((M,S)=>_.jsx("li",{children:M},S))})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"source"}),_.jsx("td",{children:f.source})]})]})});return _.jsxs("div",{children:[_.jsxs("div",{children:[_.jsx("input",{type:"text",size:20,placeholder:"SNP id",onChange:C,style:{padding:"6px 8px",border:"1px solid #e2e8f0",borderRadius:"4px"}}),_.jsx("button",{className:"btn btn-secondary btn-sm",style:{marginLeft:"2px"},onClick:p,children:"Go"})," ",_.jsx("span",{className:"text-info font-italic",children:u})]}),_.jsx("div",{style:{position:"absolute",zIndex:2,backgroundColor:a,color:s},children:m&&A(m)})]})},rK={content:{position:"fixed",top:"50px",left:"40%",right:"unset",bottom:"unset",overflow:"visible",padding:"5px",borderRadius:"4px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)"},overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(111,107,101, 0.7)",zIndex:9999,display:"flex"}},QVr={cursor:"pointer",color:"red",fontSize:"2em",position:"absolute",top:"-5px",right:"15px"},qVr=({selectedRegion:c,onRegionSelected:e,contentColorSetup:n,virusBrowserMode:h,genomeConfig:i,windowWidth:t=800,fontSize:s,padding:a})=>{const[o,l]=E.useState(!1),[m,d]=E.useState(""),[u,U]=E.useState(!1),C=E.useRef(null),p=()=>l(!0),D=()=>l(!1),A=()=>{U(B=>!B)},f=B=>{B.key==="Enter"&&M()},M=()=>{var T;const B=c.getNavigationContext();let W;try{W=B.parse(((T=C.current)==null?void 0:T.value)||"")}catch(L){if(L instanceof RangeError){d(L.message);return}else throw L}m&&d(""),e(W?W.start:c._startBase,W?W.end:c._endBase,"isJump",u),D()},{color:S,background:N}=n,x=c.currentRegionAsString();return _.jsxs("div",{className:"bg tool-element",style:{fontSize:`${s||Math.max(11,Math.min(15,t*.009))}px`,paddingLeft:a||5},children:[_.jsx("button",{onClick:p,style:{fontSize:`${s||Math.max(11,Math.min(15,t*.009))}px`,cursor:"pointer",background:"none",border:"none",color:"inherit",fontFamily:"inherit",padding:"2px 6px",borderRadius:"6px",transition:"background-color 0.15s ease",textDecoration:"underline",transform:"translateY(.5px)"},onMouseEnter:B=>{B.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.05)"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="transparent"},children:x}),o&&je.createPortal(_.jsx("div",{style:rK.overlay,onClick:D,role:"dialog","aria-label":"Gene & Region search",children:_.jsxs("div",{style:{...rK.content,color:S,background:N},onClick:B=>B.stopPropagation(),children:[_.jsx("span",{className:"text-right",style:QVr,onClick:D,children:"×"}),_.jsx("div",{children:_.jsxs("span",{children:["Highlight search"," ",_.jsx("input",{type:"checkbox",name:"do-highlight",checked:u,onChange:A})]})}),_.jsx("h6",{children:"Gene search"}),_.jsx(HVr,{navContext:c.getNavigationContext(),onRegionSelected:e,doHighlight:u,handleCloseModal:D,color:S,background:N,genomeConfig:i}),!h&&_.jsxs(_.Fragment,{children:[_.jsx("h6",{style:{marginTop:"5px"},children:"SNP search"}),_.jsx(OVr,{navContext:c.getNavigationContext(),onRegionSelected:e,handleCloseModal:D,color:S,background:N,doHighlight:u,genomeConfig:i})]}),_.jsxs("h6",{children:["Region search (current region is ",x," ",_.jsx(bm,{value:x}),")"]}),_.jsx("input",{ref:C,type:"text",size:30,placeholder:"Coordinate",onKeyDown:f,style:{padding:"6px 8px",border:"1px solid #e2e8f0",borderRadius:"4px"}}),_.jsx("button",{className:"btn btn-secondary btn-sm",style:{marginLeft:"2px"},onClick:M,children:"Go"}),m&&_.jsx("span",{className:"alert-danger",children:m})]})}),document.body)]})};function $Vr({trackState:c,globalTrackState:e}){const n=c.genomicFetchCoord[c.primaryGenName].primaryVisData;if(c.initial===1){let h={initial:0,regionLoci:c.regionLoci[0],visData:c.initVisData[0],side:"left",xDist:0},i={...c,regionLoci:c.regionLoci[1],initial:1,side:"right",visData:c.initVisData[1],xDist:0,startWindow:n.viewWindow.start,visWidth:n.visWidth,viewWindow:c.viewWindow},t={regionLoci:c.regionLoci[2],initial:0,visData:c.initVisData[2],side:"right",xDist:0};e.current.trackStates[e.current.leftIdx]={trackState:h},e.current.leftIdx++,e.current.trackStates[e.current.rightIdx]={trackState:i},e.current.rightIdx--,e.current.trackStates[e.current.rightIdx]={trackState:t},e.current.rightIdx--}else{let h={...c,initial:0,side:c.side,xDist:c.xDist,viewWindow:c.viewWindow,startWindow:n.viewWindow.start,visWidth:n.visWidth};c.side==="right"?(e.current.trackStates[e.current.rightIdx]={trackState:{regionLoci:c.genomicFetchCoord[c.primaryGenName].genomicLoci}},e.current.trackStates[e.current.rightIdx+1]={trackState:h},e.current.rightIdx--):c.side==="left"&&(e.current.trackStates[e.current.leftIdx]={trackState:{regionLoci:c.genomicFetchCoord[c.primaryGenName].genomicLoci}},e.current.trackStates[e.current.leftIdx-1]={trackState:h},e.current.leftIdx++)}}var t9=(c=>(c[c.Drag=0]="Drag",c[c.Reorder=1]="Reorder",c[c.Highlight=2]="Highlight",c[c.Zoom=3]="Zoom",c[c.PanLeft=4]="PanLeft",c[c.PanRight=5]="PanRight",c[c.ZoomOutOneThirdFold=6]="ZoomOutOneThirdFold",c[c.ZoomOutOneFold=7]="ZoomOutOneFold",c[c.ZoomOutFiveFold=8]="ZoomOutFiveFold",c[c.ZoomInOneThirdFold=9]="ZoomInOneThirdFold",c[c.ZoomInOneFold=10]="ZoomInOneFold",c[c.ZoomInFiveFold=11]="ZoomInFiveFold",c[c.highlightMenu=12]="highlightMenu",c[c.ReorderMany=13]="ReorderMany",c))(t9||{});const rFr=new BJ;class eK extends E.PureComponent{render(){const{viewRegion:e,width:n,x:h,y:i}=this.props;return _.jsx(An,{x:h,y:i,children:rFr.design(e,n)})}}q(eK,"propTypes",{viewRegion:Gr.instanceOf(Ze).isRequired,width:Gr.number.isRequired,x:Gr.number,y:Gr.number});const cK=40,s6=50,Xm=50,eFr=11,U2=cK/2-Xm/2,nK=U2+Xm/2+3,hK=15,rA={stroke:"#090",fill:"#0f0",fillOpacity:.25},iK={fontSize:eFr,fontStyle:"italic"};class tK extends E.Component{constructor(e){super(e),this.gotoPressed=this.gotoPressed.bind(this)}gotoPressed(e){let n=this.props.selectedRegion.getContextCoordinates(),h=0;this.props.selectedRegion.getWidth()<this.props.viewRegion.getWidth()?h=this.props.viewRegion.getWidth()*.5:h=this.props.selectedRegion.getWidth()*3;let i=(n.end+n.start)*.5;this.props.onNewViewRequested(i-h,i+h)}render(){const{viewRegion:e,selectedRegion:n,x:h,y:i}=this.props,t=new Bh(e,this.props.width);let s=t.getDrawWidth(),a=n.getContextCoordinates(),o=Math.max(-10,t.baseToX(a.start)),l=Math.min(s+10,t.baseToX(a.end)),m=Math.max(0,l-o);const d=_.jsx("rect",{x:o,y:0,width:m,height:cK,style:rA});let u,U;if(l<=0){const C=[[0,U2+Xm/2],[s6,U2],[s6,U2+Xm]];u=_.jsx("polygon",{points:C,style:rA,onClick:this.gotoPressed}),U=_.jsx("text",{x:hK,y:nK,style:{...iK,textAnchor:"start"},onClick:this.gotoPressed,onMouseDown:p=>p.stopPropagation(),children:"GOTO"})}else if(o>=s){const C=[[s,U2+Xm/2],[s-s6,U2],[s-s6,U2+Xm]];u=_.jsx("polygon",{points:C,style:rA,onClick:this.gotoPressed}),U=_.jsx("text",{x:s-hK,y:nK,style:{...iK,textAnchor:"end"},onClick:this.gotoPressed,onMouseDown:p=>p.stopPropagation(),children:"GOTO"})}return _.jsxs(An,{x:h,y:i,style:{cursor:"pointer"},children:[d,u,U]})}}q(tK,"propTypes",{viewRegion:Gr.instanceOf(Ze).isRequired,width:Gr.number.isRequired,selectedRegion:Gr.instanceOf(Ze).isRequired,onNewViewRequested:Gr.func.isRequired});class cFr extends E.Component{constructor(n){super(n);q(this,"dragOriginRegion");this.dragOriginRegion=null,this.dragStart=this.dragStart.bind(this),this.drag=this.drag.bind(this),this.dragEnd=this.dragEnd.bind(this)}dragStart(n){this.dragOriginRegion=this.props.panRegion,this.props.onViewDragStart&&this.props.onViewDragStart(n)}drag(n,h){if(this.props.onViewDrag){const i=this._getRegionOffsetByX(this.dragOriginRegion,n,h.dx);this.props.onViewDrag(i.start,i.end,n,h)}}dragEnd(n,h){if(this.props.onViewDragEnd){const i=this._getRegionOffsetByX(this.dragOriginRegion,n,h.dx);this.props.onViewDragEnd(i.start,i.end,n,h)}}_getRegionOffsetByX(n,h,i){const t=this.props.basesPerPixel||this.props.panRegion.getWidth()/h.currentTarget.clientWidth,s=Math.round(-1*t*i),a=n.getNavigationContext(),[o,l]=n.getContextCoordinates(),m=a.toGaplessCoordinate(Math.max(0,o+s)),d=a.toGaplessCoordinate(Math.min(l+s,a.getTotalBases()-1));return new Y0(m,d)}render(){const{panRegion:n,onViewDragStart:h,onViewDrag:i,onViewDragEnd:t,basesPerPixel:s,children:a,...o}=this.props;return _.jsx($8,{onDragStart:this.dragStart,onDrag:this.drag,onDragEnd:this.dragEnd,...o,children:a})}}const sK=.2,nFr=100,aK=10,hFr=10,iFr=aK+30,tFr="5px",sFr="60px";class eA extends E.Component{constructor(n){super(n);q(this,"componentRef",E.createRef());this.mousewheel=this.mousewheel.bind(this)}componentDidMount(){this.componentRef.current&&this.componentRef.current.addEventListener("wheel",this.mousewheel)}componentWillUnmount(){this.componentRef.current&&this.componentRef.current.removeEventListener("wheel",this.mousewheel)}mousewheel(n){n.preventDefault();let h=n.currentTarget.clientWidth||n.currentTarget.parentNode.clientWidth,i=n.clientX/h;n.deltaY>0?this.props.onZoom(1+sK,i):n.deltaY<0&&this.props.onZoom(1-sK,i)}render(){const{containerWidth:n,viewRegion:h,selectedRegion:i,onNewViewRequested:t,onRegionSelected:s,genomeConfig:a}=this.props;return n===0?(Ke.env.NODE_ENV!=="test"&&console.warn("Cannot render with a width of 0"),null):_.jsx(cFr,{className:"MainPane MainPane-opaque",mouseButton:pU.RIGHT,onViewDrag:t,panRegion:h,children:_.jsx($H,{selectableRegion:h,dragLimits:new Y0(0,n),y:tFr,height:sFr,onRegionSelected:s,children:_.jsxs("svg",{width:n,height:nFr,onContextMenu:o=>o.preventDefault(),style:{border:"1px solid black"},ref:this.componentRef,children:[_.jsx(nm,{genomeConfig:a,viewRegion:h,width:n,y:aK,x:0}),_.jsx(eK,{viewRegion:h,width:n,y:iFr,x:0}),_.jsx(tK,{width:n,viewRegion:h,selectedRegion:i,onNewViewRequested:t,y:hFr,x:0})]})})})}}q(eA,"propTypes",{containerWidth:Gr.number.isRequired,viewRegion:Gr.instanceOf(Ze).isRequired,selectedRegion:Gr.instanceOf(Ze).isRequired,onRegionSelected:Gr.func,onNewViewRequested:Gr.func,onZoom:Gr.func.isRequired}),q(eA,"defaultProps",{onRegionSelected:()=>{},onNewView:()=>{}});const aFr=5;class oK extends E.Component{constructor(e){super(e),this.state={viewRegion:this._setInitialView(e.selectedRegion)},this.zoom=this.zoom.bind(this),this.setNewView=this.setNewView.bind(this),this.zoomSliderDragged=this.zoomSliderDragged.bind(this)}_setInitialView(e){const n=e.getNavigationContext(),h=e.getFeatureSegments().map(o=>o.feature),i=h[0],t=h[h.length-1],s=n.getFeatureStart(i),a=n.getFeatureStart(t)+t.getLength();return new Ze(n,s,a)}componentDidUpdate(e){const n=this.state.viewRegion.getNavigationContext(),h=this.props.selectedRegion.getNavigationContext();e.selectedRegion.getNavigationContext()!==h&&n!==h?(this.setState({viewRegion:new Ze(h)}),this.setState({viewRegion:this._setInitialView(this.props.selectedRegion)})):e.selectedRegion.getGenomeIntervals()[0].chr!==this.props.selectedRegion.getGenomeIntervals()[0].chr&&this.setState({viewRegion:this._setInitialView(this.props.selectedRegion)})}_setModelState(e,n){let h=this.state.viewRegion.clone();h[e].apply(h,n),!(h.getWidth()<aFr)&&this.setState({viewRegion:h})}zoom(e,n){this._setModelState("zoom",[e,n])}setNewView(e,n){this._setModelState("setRegion",[e,n])}zoomSliderDragged(e){let h=Math.exp(e.target.value)/this.state.viewRegion.getWidth();this._setModelState("zoom",[h])}render(){return _.jsx("div",{children:_.jsx(eA,{viewRegion:this.state.viewRegion,selectedRegion:this.props.selectedRegion,onRegionSelected:this.props.onRegionSelected,onNewViewRequested:this.setNewView,onZoom:this.zoom,containerWidth:this.props.windowWidth,genomeConfig:this.props.genomeConfig})})}}q(oK,"defaultProps",{onRegionSelected:()=>{}});function oFr(){for(var c=arguments.length,e=new Array(c),n=0;n<c;n++)e[n]=arguments[n];return E.useMemo(()=>h=>{e.forEach(i=>i(h))},e)}const a6=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ym(c){const e=Object.prototype.toString.call(c);return e==="[object Window]"||e==="[object global]"}function cA(c){return"nodeType"in c}function I1(c){var e,n;return c?Ym(c)?c:cA(c)&&(e=(n=c.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function nA(c){const{Document:e}=I1(c);return c instanceof e}function s9(c){return Ym(c)?!1:c instanceof I1(c).HTMLElement}function lK(c){return c instanceof I1(c).SVGElement}function wm(c){return c?Ym(c)?c.document:cA(c)?nA(c)?c:s9(c)||lK(c)?c.ownerDocument:document:document:document}const Rs=a6?E.useLayoutEffect:E.useEffect;function hA(c){const e=E.useRef(c);return Rs(()=>{e.current=c}),E.useCallback(function(){for(var n=arguments.length,h=new Array(n),i=0;i<n;i++)h[i]=arguments[i];return e.current==null?void 0:e.current(...h)},[])}function lFr(){const c=E.useRef(null),e=E.useCallback((h,i)=>{c.current=setInterval(h,i)},[]),n=E.useCallback(()=>{c.current!==null&&(clearInterval(c.current),c.current=null)},[]);return[e,n]}function a9(c,e){e===void 0&&(e=[c]);const n=E.useRef(c);return Rs(()=>{n.current!==c&&(n.current=c)},e),n}function o9(c,e){const n=E.useRef();return E.useMemo(()=>{const h=c(n.current);return n.current=h,h},[...e])}function o6(c){const e=hA(c),n=E.useRef(null),h=E.useCallback(i=>{i!==n.current&&(e==null||e(i,n.current)),n.current=i},[]);return[n,h]}function iA(c){const e=E.useRef();return E.useEffect(()=>{e.current=c},[c]),e.current}let tA={};function l9(c,e){return E.useMemo(()=>{if(e)return e;const n=tA[c]==null?0:tA[c]+1;return tA[c]=n,c+"-"+n},[c,e])}function mK(c){return function(e){for(var n=arguments.length,h=new Array(n>1?n-1:0),i=1;i<n;i++)h[i-1]=arguments[i];return h.reduce((t,s)=>{const a=Object.entries(s);for(const[o,l]of a){const m=t[o];m!=null&&(t[o]=m+c*l)}return t},{...e})}}const Em=mK(1),m9=mK(-1);function mFr(c){return"clientX"in c&&"clientY"in c}function sA(c){if(!c)return!1;const{KeyboardEvent:e}=I1(c.target);return e&&c instanceof e}function dFr(c){if(!c)return!1;const{TouchEvent:e}=I1(c.target);return e&&c instanceof e}function aA(c){if(dFr(c)){if(c.touches&&c.touches.length){const{clientX:e,clientY:n}=c.touches[0];return{x:e,y:n}}else if(c.changedTouches&&c.changedTouches.length){const{clientX:e,clientY:n}=c.changedTouches[0];return{x:e,y:n}}}return mFr(c)?{x:c.clientX,y:c.clientY}:null}const d9=Object.freeze({Translate:{toString(c){if(!c)return;const{x:e,y:n}=c;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(c){if(!c)return;const{scaleX:e,scaleY:n}=c;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(c){if(c)return[d9.Translate.toString(c),d9.Scale.toString(c)].join(" ")}},Transition:{toString(c){let{property:e,duration:n,easing:h}=c;return e+" "+n+"ms "+h}}}),dK="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function uFr(c){return c.matches(dK)?c:c.querySelector(dK)}const UFr={display:"none"};function zFr(c){let{id:e,value:n}=c;return E.createElement("div",{id:e,style:UFr},n)}function vFr(c){let{id:e,announcement:n,ariaLiveType:h="assertive"}=c;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return E.createElement("div",{id:e,style:i,role:"status","aria-live":h,"aria-atomic":!0},n)}function CFr(){const[c,e]=E.useState("");return{announce:E.useCallback(h=>{h!=null&&e(h)},[]),announcement:c}}const uK=E.createContext(null);function pFr(c){const e=E.useContext(uK);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(c)},[c,e])}function DFr(){const[c]=E.useState(()=>new Set),e=E.useCallback(h=>(c.add(h),()=>c.delete(h)),[c]);return[E.useCallback(h=>{let{type:i,event:t}=h;c.forEach(s=>{var a;return(a=s[i])==null?void 0:a.call(s,t)})},[c]),e]}const bFr={draggable:`
|
|
1369
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o8="react-compound-slider:";function LJ(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return function(n,h){return n.val>h.val?c?-1:1:h.val>n.val?c?1:-1:0}}function Y4(c,e,n){var h=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=c.findIndex(function(o){return o.key===e});if(i!==-1){var t=c[i],s=t.key,a=t.val;return a===n?c:[].concat(s8(c.slice(0,i)),[{key:s,val:n}],s8(c.slice(i+1))).sort(LJ(h))}return c}function w4(c,e){if(!c)return[0,0];var n=c.getBoundingClientRect(),h=e?n.top:n.left,i=e?n.bottom:n.right;return[h,i]}function IJ(c){var e=c.type,n=e===void 0?"":e,h=c.touches;return!h||h.length>1||n.toLowerCase()==="touchend"&&h.length>0}function l8(c,e){return c?e.touches[0].clientY:e.touches[0].pageX}function VJ(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,h=arguments.length>3?arguments[3]:void 0,i=0,t=c.map(function(s){var a=n.getValue(s);return s!==a&&(i+=1,Hd(!h,"".concat(o8," Invalid value encountered. Changing ").concat(s," to ").concat(a,"."))),a}).map(function(s,a){return{key:"$$-".concat(a),val:s}}).sort(LJ(e));return{handles:t,changes:i}}function Pxr(c,e){return e}function Oxr(c,e){for(var n=0;n<c.length;n++)if(c[n].key!==e[n].key||e[n+1]&&e[n].val===e[n+1].val)return c;return e}function m8(c,e,n,h,i){for(var t=-1,s=!0,a=0;a<c.length;a++){var o=c[a],l=e[a];if(!l||l.key!==o.key)return c;l.val!==o.val&&(t=a,s=l.val-o.val>0)}if(t===-1)return c;for(var m=s?n:-n,d=0;d<e.length;d++){var u=e[d],U=e[d+1];if(U&&u.val===U.val)if(d===t){var C=U.val+m;if(i(C)===C){var p=Y4(e,U.key,U.val+m,h),D=m8(e,p,n,h,i);return D===e?c:D}else return c}else{var A=u.val+m;if(i(A)===A){var f=Y4(e,u.key,u.val+m,h),M=m8(e,f,n,h,i);return M===e?c:M}else return c}}return e}function n2(){for(var c=arguments.length,e=new Array(c),n=0;n<c;n++)e[n]=arguments[n];return function(h){return e.forEach(function(i){return i&&i(h)})}}var Qxr=function(){return{value:0,percent:0}},FJ=function(c){T4(n,c);var e=X4(n);function n(){var h;r2(this,n);for(var i=arguments.length,t=new Array(i),s=0;s<i;s++)t[s]=arguments[s];return h=e.call.apply(e,[this].concat(t)),h.getRailProps=function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=h.props,l=o.emitMouse,m=o.emitTouch;return Ts(Ts({},a),{},{onMouseDown:n2(a&&a.onMouseDown,l),onTouchStart:n2(a&&a.onTouchStart,m)})},h}return e2(n,[{key:"render",value:function(){var i=this.getRailProps,t=this.props,s=t.getEventData,a=t.activeHandleID,o=a===void 0?"":a,l=t.children,m=l({getEventData:s||Qxr,activeHandleID:o,getRailProps:i});return m&&E.Children.only(m)}}]),n}(E.Component),kJ=function(c){T4(n,c);var e=X4(n);function n(){var h;r2(this,n);for(var i=arguments.length,t=new Array(i),s=0;s<i;s++)t[s]=arguments[s];return h=e.call.apply(e,[this].concat(t)),h.autofocus=function(a){a.target instanceof HTMLElement&&a.target.focus()},h.getHandleProps=function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=h.props,m=l.emitKeyboard,d=l.emitMouse,u=l.emitTouch;return Ts(Ts({},o),{},{onKeyDown:n2(o&&o.onKeyDown,function(U){return m&&m(U,a)}),onMouseDown:n2(o&&o.onMouseDown,h.autofocus,function(U){return d&&d(U,a)}),onTouchStart:n2(o&&o.onTouchStart,function(U){return u&&u(U,a)})})},h}return e2(n,[{key:"render",value:function(){var i=this.getHandleProps,t=this.props,s=t.activeHandleID,a=s===void 0?"":s,o=t.children,l=t.handles,m=l===void 0?[]:l,d=o({handles:m,activeHandleID:a,getHandleProps:i});return d&&E.Children.only(d)}}]),n}(E.Component),d8=function(){function c(){r2(this,c),this.interpolator=void 0,this.domain=[0,1],this.range=[0,1],this.domain=[0,1],this.range=[0,1],this.interpolator=null}return e2(c,[{key:"createInterpolator",value:function(n,h){var i=this,t=n[0],s=n[1],a=h[0],o=h[1];return s<t?function(l){return i.interpolateValue(o,a)(i.deinterpolateValue(s,t)(l))}:function(l){return i.interpolateValue(a,o)(i.deinterpolateValue(t,s)(l))}}},{key:"interpolateValue",value:function(n,h){return n=+n,h-=n,function(t){return n+h*t}}},{key:"deinterpolateValue",value:function(n,h){return(h-=n=+n)?function(i){return(i-n)/h}:function(){return h}}},{key:"rescale",value:function(){return this.interpolator=null,this}},{key:"getValue",value:function(n){var h=this.domain,i=this.range;return(this.interpolator||(this.interpolator=this.createInterpolator(h,i)))(+n)}},{key:"setDomain",value:function(n){return this.domain=[n[0],n[1]],this.rescale(),this}},{key:"getDomain",value:function(){return this.domain}},{key:"setRange",value:function(n){return this.range=[n[0],n[1]],this}},{key:"getRange",value:function(){return this.range}},{key:"getTicks",value:function(n){var h=this.domain;return xxr(h[0],h[h.length-1],n||10)}}]),c}(),qxr=function(){return{value:0,percent:0}},$xr=function(c){T4(n,c);var e=X4(n);function n(){return r2(this,n),e.apply(this,arguments)}return e2(n,[{key:"render",value:function(){var i=this.props,t=i.children,s=i.values,a=i.scale,o=a===void 0?new d8:a,l=i.count,m=l===void 0?10:l,d=i.getEventData,u=d===void 0?qxr:d,U=i.activeHandleID,C=U===void 0?"":U,p=(s||o.getTicks(m)).map(function(A){return{id:"$$-".concat(A),value:A,percent:o.getValue(A)}}),D=t({getEventData:u,activeHandleID:C,ticks:p});return D&&E.Children.only(D)}}]),n}(E.Component),rRr=function(){return{value:0,percent:0}},JJ=function(c){T4(n,c);var e=X4(n);function n(){var h;r2(this,n);for(var i=arguments.length,t=new Array(i),s=0;s<i;s++)t[s]=arguments[s];return h=e.call.apply(e,[this].concat(t)),h.getTrackProps=function(a){var o=h.props,l=o.emitMouse,m=o.emitTouch;return Ts(Ts({},a||{}),{},{onMouseDown:n2(a&&a.onMouseDown,l),onTouchStart:n2(a&&a.onTouchStart,m)})},h}return e2(n,[{key:"render",value:function(){for(var i=this.getTrackProps,t=this.props,s=t.children,a=t.left,o=a===void 0?!0:a,l=t.right,m=l===void 0?!0:l,d=t.scale,u=d===void 0?new d8:d,U=t.handles,C=U===void 0?[]:U,p=t.getEventData,D=p===void 0?rRr:p,A=t.activeHandleID,f=A===void 0?"":A,M=u.getDomain(),S=[],N=0;N<C.length+1;N++){var x=C[N-1],B=C[N];N===0&&o===!0?x={id:"$",value:M[0],percent:0}:N===C.length&&m===!0&&(B={id:"$",value:M[1],percent:100}),x&&B&&S.push({id:"".concat(x.id,"-").concat(B.id),source:x,target:B})}var W=s({getEventData:D,activeHandleID:f,tracks:S,getTrackProps:i});return W&&E.Children.only(W)}}]),n}(E.Component);function jJ(c,e,n){return Math.min(Math.max(c,e),n)}var HJ=e2(function c(){var e=this;r2(this,c),this.step=1,this.domain=[0,1],this.range=[0,1],this.setDomain=function(n){return e.domain=[n[0],n[1]],e},this.setRange=function(n){return e.range=[n[0],n[1]],e},this.setStep=function(n){return e.step=n,e},this.getValue=function(n){var h=t8(e.domain,2),i=h[0],t=h[1],s=t8(e.range,2),a=s[0],o=s[1],l=e.step,m=(jJ(n,i,t)-i)/(t-i),d=l*Math.round(m*(o-a)/l)+a;return jJ(d,a<o?a:o,o>a?o:a)}}),E4=typeof window<"u"&&typeof document<"u",Ji=function(){},eRr=function(e){return function(n,h,i){return n&&e[i]===h}},cRr=function(e,n){return e===n||e.length===n.length&&e.reduce(eRr(n),!0)},nRr=function(e){if(!E.isValidElement(e))return!1;var n=e.type,h=n?n.name:"";return h===kJ.name||h===FJ.name||h===$xr.name||h===JJ.name},hRr=function(e,n,h,i){var t=i?e-n:e+n;return i?Math.max(h[0],t):Math.min(h[1],t)},iRr=function(e,n,h,i){var t=i?e+n:e-n;return i?Math.min(h[1],t):Math.max(h[0],t)},Lv=[0,100],tRr=function(c){T4(n,c);var e=X4(n);function n(){var h;r2(this,n);for(var i=arguments.length,t=new Array(i),s=0;s<i;s++)t[s]=arguments[s];return h=e.call.apply(e,[this].concat(t)),h.state={step:.1,values:[],domain:Lv,handles:[],reversed:!1,activeHandleID:"",valueToPerc:null,valueToStep:null,pixelToStep:null},h.slider=E.createRef(),h.onKeyDown=function(a,o){var l=["ArrowRight","ArrowUp"],m=["ArrowDown","ArrowLeft"],d=c2(h),u=d.state.handles,U=d.props,C=U.step,p=C===void 0?.1:C,D=U.reversed,A=D===void 0?!1:D,f=U.vertical,M=f===void 0?!1:f,S=U.domain,N=S===void 0?[0,100]:S,x=a.key||"".concat(a.keyCode);if(l.concat(m).includes(x)){if(M){var B=[m,l];l=B[0],m=B[1]}a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault();var W=u.find(function(J){return J.key===o});if(W){var T=W.val,L=T;l.includes(x)?L=hRr(T,p,N,A):m.includes(x)&&(L=iRr(T,p,N,A));var I=u.map(function(J){return J.key===o?{key:J.key,val:L}:J});h.submitUpdate(I,!0)}}},h.onMouseDown=function(a,o){h.onStart(a,o,!1)},h.onTouchStart=function(a,o){IJ(a)||h.onStart(a,o,!0)},h.getEventData=function(a,o){var l=c2(h),m=l.state,d=m.pixelToStep,u=m.valueToPerc,U=l.props.vertical;d.setDomain(w4(h.slider.current,U));var C;return o&&a instanceof TouchEvent?C=d.getValue(l8(U,a)):a instanceof MouseEvent&&(C=d.getValue(U?a.clientY:a.pageX)),{value:C,percent:u.getValue(C)}},h.onMouseMove=function(a){var o=c2(h),l=o.state,m=l.handles,d=l.pixelToStep,u=l.activeHandleID,U=u===void 0?"":u,C=o.props,p=C.vertical,D=C.reversed,A=D===void 0?!1:D;d.setDomain(w4(h.slider.current,p));var f=d.getValue(p?a.clientY:a.pageX),M=Y4(m,U,f,A);h.submitUpdate(M)},h.onTouchMove=function(a){var o=c2(h),l=o.state,m=l.handles,d=l.pixelToStep,u=l.activeHandleID,U=o.props,C=U.vertical,p=U.reversed;if(!(d===null||IJ(a))){d.setDomain(w4(h.slider.current,C));var D=d.getValue(l8(C,a)),A=Y4(m,u,D,p);h.submitUpdate(A)}},h.onMouseUp=function(){var a=c2(h),o=a.state,l=o.handles,m=l===void 0?[]:l,d=o.activeHandleID,u=a.props,U=u.onChange,C=U===void 0?Ji:U,p=u.onSlideEnd,D=p===void 0?Ji:p;C(m.map(function(A){return A.val})),D(m.map(function(A){return A.val}),{activeHandleID:d}),h.setState({activeHandleID:""}),E4&&(document.removeEventListener("mousemove",h.onMouseMove),document.removeEventListener("mouseup",h.onMouseUp))},h.onTouchEnd=function(){var a=c2(h),o=a.state,l=o.handles,m=o.activeHandleID,d=a.props,u=d.onChange,U=u===void 0?Ji:u,C=d.onSlideEnd,p=C===void 0?Ji:C;U(l.map(function(D){return D.val})),p(l.map(function(D){return D.val}),{activeHandleID:m}),h.setState({activeHandleID:""}),E4&&(document.removeEventListener("touchmove",h.onTouchMove),document.removeEventListener("touchend",h.onTouchEnd))},h}return e2(n,[{key:"componentDidMount",value:function(){var i=this.state.pixelToStep,t=this.props.vertical;i.setDomain(w4(this.slider.current,t))}},{key:"componentWillUnmount",value:function(){this.removeListeners()}},{key:"removeListeners",value:function(){E4&&(document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd))}},{key:"onStart",value:function(i,t,s){var a=this.state.handles,o=this.props.onSlideStart,l=o===void 0?Ji:o;s||i.preventDefault&&i.preventDefault(),i.stopPropagation&&i.stopPropagation();var m=a.find(function(d){return d.key===t});m?(this.setState({activeHandleID:t}),l(a.map(function(d){return d.val}),{activeHandleID:t}),s?this.addTouchEvents():this.addMouseEvents()):(this.setState({activeHandleID:""}),this.handleRailAndTrackClicks(i,s))}},{key:"handleRailAndTrackClicks",value:function(i,t){var s=this,a=this.state,o=a.handles,l=a.pixelToStep,m=this.props,d=m.vertical,u=m.reversed,U=u===void 0?!1:u,C=this.slider;l.setDomain(w4(C.current,d));var p;t?p=l.getValue(l8(d,i)):p=l.getValue(d?i.clientY:i.pageX);for(var D="",A=1/0,f=0;f<o.length;f++){var M=o[f],S=M.key,N=M.val,x=Math.abs(N-p);x<A&&(D=S,A=x)}var B=Y4(o,D,p,U);this.setState({activeHandleID:D},function(){s.submitUpdate(B,!0),t?s.addTouchEvents():s.addMouseEvents()})}},{key:"addMouseEvents",value:function(){E4&&(document.addEventListener("mousemove",this.onMouseMove),document.addEventListener("mouseup",this.onMouseUp))}},{key:"addTouchEvents",value:function(){E4&&(document.addEventListener("touchmove",this.onTouchMove),document.addEventListener("touchend",this.onTouchEnd))}},{key:"submitUpdate",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=this.props,a=s.mode,o=a===void 0?1:a,l=s.step,m=l===void 0?.1:l,d=s.onUpdate,u=d===void 0?Ji:d,U=s.onChange,C=U===void 0?Ji:U,p=s.reversed,D=p===void 0?!1:p,A=this.state.valueToStep.getValue;this.setState(function(f){var M=f.handles,S=[];if(typeof o=="function")S=o(M,i,m,D,A),Hd(Array.isArray(S),"Custom mode function did not return an array.");else switch(o){case 1:S=Pxr(M,i);break;case 2:S=Oxr(M,i);break;case 3:S=m8(M,i,m,D,A);break;default:S=i,Hd(!1,"".concat(o8," Invalid mode value."))}return u(S.map(function(N){return N.val})),t&&C(S.map(function(N){return N.val})),{handles:S}})}},{key:"render",value:function(){var i=this,t=this.state,s=t.handles,a=t.valueToPerc,o=t.activeHandleID,l=this.props,m=l.className,d=l.rootStyle,u=d===void 0?{}:d,U=l.rootProps,C=U===void 0?{}:U,p=l.component,D=p===void 0?"div":p,A=l.disabled,f=A===void 0?!1:A,M=l.flatten,S=M===void 0?!1:M,N=s.map(function(B){var W=B.key,T=B.val;return{id:W,value:T,percent:a.getValue(T)}}),x=E.Children.map(this.props.children,function(B){return nRr(B)===!0?E.cloneElement(B,{scale:a,handles:N,activeHandleID:o,getEventData:i.getEventData,emitKeyboard:f?Ji:i.onKeyDown,emitMouse:f?Ji:i.onMouseDown,emitTouch:f?Ji:i.onTouchStart}):B});return S?E.createElement(E.Fragment,null,E.createElement(D,Ts(Ts({},C),{},{style:u,className:m,ref:this.slider})),x):E.createElement(E.Fragment,null,E.createElement(D,Ts(Ts({},C),{},{style:u,className:m,ref:this.slider}),x))}}],[{key:"getDerivedStateFromProps",value:function(i,t){var s=i.step,a=s===void 0?.1:s,o=i.values,l=i.domain,m=l===void 0?Lv:l,d=i.reversed,u=d===void 0?!1:d,U=i.onUpdate,C=U===void 0?Ji:U,p=i.onChange,D=p===void 0?Ji:p,A=i.warnOnChanges,f=A===void 0?!1:A,M=t.valueToPerc,S=t.valueToStep,N=t.pixelToStep,x={};if((!M||!S||!N)&&(M=new d8,S=new HJ,N=new HJ,x.valueToPerc=M,x.valueToStep=S,x.pixelToStep=N),t.domain===Lv||t.step===null||t.domain===null||t.reversed===null||a!==t.step||m[0]!==t.domain[0]||m[1]!==t.domain[1]||u!==t.reversed){var B=t8(m,2),W=B[0],T=B[1];S.setStep(a).setRange([W,T]).setDomain([W,T]),u===!0?(M.setDomain([W,T]).setRange([100,0]),N.setStep(a).setRange([T,W])):(M.setDomain([W,T]).setRange([0,100]),N.setStep(a).setRange([W,T])),Hd(T>W,"".concat(o8," Max must be greater than min (even if reversed). Max is ").concat(T,". Min is ").concat(W,"."));var L=VJ(o||t.values,u,S,f),I=L.handles,J=L.changes;(J||o===void 0||o===t.values)&&(C(I.map(function(pr){return pr.val})),D(I.map(function(pr){return pr.val}))),x.step=a,x.values=o,x.domain=m===Lv?s8(m):m,x.handles=I,x.reversed=u}else if(!cRr(o,t.values)){var $=VJ(o,u,S,f),sr=$.handles,vr=$.changes;vr&&(C(sr.map(function(pr){return pr.val})),D(sr.map(function(pr){return pr.val}))),x.values=o,x.handles=sr}return Object.keys(x).length?x:null}}]),n}(E.PureComponent);const sRr={position:"relative",width:200,height:40,marginLeft:"5%",marginTop:10},KJ={position:"absolute",width:"100%",height:10,marginTop:15,borderRadius:5,backgroundColor:"#D8D8D8"};function aRr({source:c,target:e,getTrackProps:n}){return _.jsx("div",{style:{position:"absolute",height:10,zIndex:1,marginTop:15,backgroundColor:"#262626",borderRadius:5,cursor:"pointer",left:`${c.percent}%`,width:`${e.percent-c.percent}%`},...n()})}function oRr({handle:{id:c,value:e,percent:n},getHandleProps:h}){return _.jsx("div",{style:{left:`${n}%`,position:"absolute",marginLeft:-10,marginTop:10,zIndex:2,width:20,height:20,border:0,textAlign:"center",cursor:"pointer",borderRadius:"50%",backgroundColor:"#7F7F7F"},...h(c),children:_.jsx("div",{style:{fontFamily:"Arial",fontSize:12,marginTop:-20},children:e})})}class x4 extends E.PureComponent{constructor(n){super(n);q(this,"onUpdate",n=>{this.setState({update:n}),this.props.onOptionSet(this.props.optionName,n)});q(this,"onChange",n=>{this.setState({values:n}),this.props.onOptionSet(this.props.optionName,n)});this.state={values:n.values.slice(),update:n.values.slice()},this.onUpdate=n.onUpdate===void 0?this.onUpdate.bind(this):n.onUpdate,this.onChange=n.onChange===void 0?this.onChange.bind(this):n.onChange}render(){const{label:n,mode:h,step:i,domain:t}=this.props;let s=_.jsxs(tRr,{mode:h,step:i,domain:t,rootStyle:sRr,onUpdate:this.onUpdate,onChange:this.onChange,values:this.state.values,children:[_.jsx("div",{style:KJ}),_.jsx(FJ,{children:({getRailProps:a})=>_.jsx("div",{style:KJ,...a()})}),_.jsx(kJ,{children:({handles:a,getHandleProps:o})=>_.jsx("div",{className:"slider-handles",children:a.map(l=>_.jsx(oRr,{handle:l,getHandleProps:o},l.id))})}),_.jsx(JJ,{right:!1,children:({tracks:a,getTrackProps:o})=>_.jsx("div",{className:"slider-tracks",children:a.map(({id:l,source:m,target:d})=>_.jsx(aRr,{source:m,target:d,getTrackProps:o},l))})})]});return _.jsx("div",{className:"TrackContextMenu-item",children:_.jsxs("label",{style:{margin:0},children:[n," ",s]})})}}q(x4,"propTypes",Object.assign({},{optionName:Gr.string.isRequired,label:Gr.string.isRequired,mode:Gr.number.isRequired,step:Gr.number.isRequired,domain:Gr.array.isRequired,values:Gr.array.isRequired})),q(x4,"defaultProps",{label:"Slider",mode:1,step:1,domain:[0,100],values:[]});function R4(c){return _.jsx(x4,{...c,optionName:"speed",label:"Play speed:",mode:1,step:1,domain:[1,10],values:c.optionsObjects[0].speed,onUpdate:()=>{}})}function Iv(c){return _.jsx(v1,{...c,optionName:"useDynamicColors",label:"Use dynamic colors",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class lRr extends on{getMenuComponents(){return[Ei,W4,R4,xi,Wt,Bn,Iv,xv,Ql,Ss]}}function mRr(c){const e=c.optionsObjects[0].show==="sample"?_.jsx(E.Fragment,{children:_.jsx(wn,{...c,optionName:"sampleSize",label:"Sample size:",isFloat:!1,min:1,defaultValue:1e3,hasSetButton:!0})}):null;return _.jsxs(E.Fragment,{children:[_.jsx(fh,{...c,optionName:"show",label:"Show:",choices:{ALL:J5.ALL,SAMPLE:J5.SAMPLE},defaultValue:J5.ALL}),e]})}function dRr(c){return _.jsx(fh,{...c,optionName:"logScale",label:"Logarithm:",choices:{NONE:Fo.AUTO,LOG10:Fo.BASE10},defaultValue:Fo.AUTO})}function uRr(c){return _.jsx(wn,{...c,optionName:"horizontalLineValue",label:"Horizontal line value:",hasSetButton:!0,isFloat:!0})}function URr(c){return _.jsx(wn,{...c,optionName:"markerSize",label:"Marker size:",minValue:1,step:1,hasSetButton:!1})}function zRr(c){return _.jsx(x4,{...c,optionName:"opacity",label:"Opacity:",mode:1,step:1,domain:[0,100],values:c.optionsObjects[0].opacity,onUpdate:()=>{}})}function vRr(c){return _.jsx(v1,{...c,optionName:"showHorizontalLine",label:"Horizontal line",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class CRr extends on{getMenuComponents(){const e=[...super.getMenuComponents(),qn,kt,dRr,mRr,zRr,URr,xi,Wt,Bn,vRr];return this.getOptions().showHorizontalLine&&e.push(uRr),e}}class pRr extends wo{getMenuComponents(){const e=[...super.getMenuComponents(),N4];return this.getOptions().displayMode===si.DENSITY&&e.push(kt),e}}function u8(c){return _.jsx(fh,{...c,optionName:"aggregateMethod",label:"Aggregate method:",choices:b3,defaultValue:b3.MEAN})}function PJ(c){return _.jsx(v1,{...c,optionName:"ensemblStyle",label:"Ensembl Style",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class OJ extends on{getMenuComponents(){return[...super.getMenuComponents(),gSr,qn,kt,u8,Ev,xi,Wt,Bn,PJ]}}class QJ extends OJ{}class U8 extends on{constructor(n){super(n);q(this,"numericalTrackConfig");this.numericalTrackConfig=new OJ(n),this.setDefaultOptions(Yn)}getMenuComponents(){return[...this.numericalTrackConfig.getMenuComponents()]}}function qJ(c){return _.jsx(v1,{...c,optionName:"hideMinimalItems",label:"Hide minimal items",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}function DRr(c){return _.jsx(v1,{...c,optionName:"italicizeText",label:"Italicize text",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class bRr extends wo{getMenuComponents(){return[...super.getMenuComponents(),DRr,Ss,qJ]}}function gm(c){return _.jsx(wn,{...c,optionName:"lineWidth",label:"Line width (pixels):",minValue:1,step:1,hasSetButton:!1})}function L4(c){const e=c.optionsObjects[0].scoreScale==="fixed"?_.jsxs(E.Fragment,{children:[_.jsx(wn,{...c,optionName:"scoreMax",label:"Score max:",isFloat:!0,hasSetButton:!0,defaultValue:10}),_.jsx(wn,{...c,optionName:"scoreMin",label:"Score min:",isFloat:!0,hasSetButton:!0,defaultValue:0})]}):null;return _.jsxs(E.Fragment,{children:[_.jsx(fh,{...c,optionName:"scoreScale",label:"Score scale:",choices:{AUTO:Nc.AUTO,FIXED:Nc.FIXED},defaultValue:Nc.AUTO}),e]})}function $J(c){return _.jsx(wn,{...c,optionName:"maxValueFilter",label:"Max value filter:",step:1,hasSetButton:!0})}function rj(c){return _.jsx(wn,{...c,optionName:"minValueFilter",label:"Min value filter:",step:1,hasSetButton:!0})}function ej(c){return _.jsx(v1,{...c,optionName:"bothAnchorsInView",label:"Both anchors in view window",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}function cj(c){return _.jsx(v1,{...c,optionName:"fetchViewWindowOnly",label:"Data in current view (no expansion)",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}function gRr(c){return _.jsx(wn,{...c,optionName:"scalePercentile",label:"Max Score percentile:",isFloat:!0,hasSetButton:!0,defaultValue:95})}function nj(c){return _.jsx(v1,{...c,optionName:"clampHeight",label:"Scale with height",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}class _Rr extends on{constructor(e){super(e),this.setDefaultOptions({...im,binSize:_z.AUTO,normalization:Xo.NONE})}getMenuComponents(){const e=[Ei,J7,qn,L4,xi,Wt,Bn,$J,rj,cj,ej];return this.getOptions().scoreScale===Nc.AUTO&&e.splice(4,0,gRr),this.getOptions().displayMode!==e1.HEATMAP&&e.splice(1,0,gm),(this.getOptions().displayMode===e1.HEATMAP||this.getOptions().displayMode===e1.ARC)&&e.push(nj),e}}class ARr extends on{constructor(e){super(e),this.setDefaultOptions(im)}getMenuComponents(){const e=[Ei,J7,qn,L4,xi,Wt,Bn,$J,rj,cj,ej];return this.getOptions().displayMode===e1.ARC&&e.splice(1,0,gm),(this.getOptions().displayMode===e1.HEATMAP||this.getOptions().displayMode===e1.ARC)&&e.push(nj),e}}class yRr extends on{constructor(e){super(e),this.setDefaultOptions(im)}getMenuComponents(){const e=[J7,qn,L4,xi,Wt,Bn];return this.getOptions().displayMode===e1.ARC&&e.splice(1,0,gm),e}}function BRr(c){return _.jsxs(E.Fragment,{children:[_.jsx(wn,{...c,optionName:"maxMethyl",label:"Methylation value max:",isFloat:!0,defaultValue:1,step:.1,minValue:0,hasSetButton:!0}),_.jsx(wn,{...c,optionName:"depthFilter",label:"Depth filter:",isFloat:!1,defaultValue:0,minValue:0,hasSetButton:!0})]})}function ZRr(c){return _.jsx(v1,{...c,optionName:"isCombineStrands",label:"Combine strands",getInputElement:(e,n)=>_.jsx("input",{type:"checkbox",checked:e,onChange:h=>n(h.target.checked)})})}const hj="colorsForContext",fRr=["color","background"];class z8 extends E.Component{getContextColors(){if(this.props.optionsObjects.length===1){const e=this.props.optionsObjects[0];return e?e[hj]:null}else return null}handleColorChange(e,n,h){const i=this.getContextColors(),t=this.props.onOptionSet;if(i&&t){const s=Qr.cloneDeep(i);s[e][n]=h,t(hj,s)}}render(){const e=this.getContextColors();if(!e)return null;let n=[];for(let h in e){const i=e[h],t=fRr.map(s=>_.jsx("div",{children:_.jsx(Gz,{color:i[s],onChange:a=>this.handleColorChange(h,s,a.hex)},s)}));n.push(_.jsxs(E.Fragment,{children:[h,t]},h))}return _.jsxs("div",{className:"TrackContextMenu-item",children:[_.jsxs("div",{className:"MethylColorConfig-table",children:[_.jsx("span",{className:"MethylColorConfig-header",children:"Context"}),_.jsx("span",{className:"MethylColorConfig-header",children:"Color"}),_.jsx("span",{className:"MethylColorConfig-header",children:"Background"}),n]}),_.jsx("i",{children:"Add other contexts by specifying them in a data hub."})]})}}q(z8,"propTypes",{optionsObjects:Gr.arrayOf(Gr.object).isRequired,onOptionSet:Gr.func.isRequired});class SRr extends on{getMenuComponents(){return[...super.getMenuComponents(),qn,ZRr,z8,BRr,z8,Bn]}}class MRr extends on{getMenuComponents(){return[...super.getMenuComponents(),Nz,qn,Bn,Ss]}}class GRr extends on{getMenuComponents(){return[...super.getMenuComponents(),Nz,qn,Bn,Ss]}}class NRr extends on{getMenuComponents(){return[...super.getMenuComponents(),qn,zSr,vSr,Bn]}}class WRr extends on{getMenuComponents(){return[...super.getMenuComponents()]}}class TRr extends wo{getMenuComponents(){return[...super.getMenuComponents()]}}class XRr extends wo{getMenuComponents(){const e=[...super.getMenuComponents(),Ss,N4];return this.getOptions().displayMode===si.DENSITY&&e.push(kt),e}}class YRr extends on{getMenuComponents(){return[...super.getMenuComponents(),qn,kt,u8,gm,Ev,Bn]}}class wRr extends on{getMenuComponents(){return[...super.getMenuComponents(),qn,W4,R4,kt,u8,Ev,xi,Iv,Bn]}}function ERr(c){return _.jsx(fh,{...c,optionName:"arrayAggregateMethod",label:"Array Aggregate method:",choices:Az,defaultValue:Az.MEAN})}class xRr extends on{getMenuComponents(){return[Ei,W4,R4,qn,ERr,xi,Iv,Bn]}}function RRr(c){return _.jsx(fh,{...c,optionName:"binSize",label:"Bin size:",defaultValue:_z.AUTO,choices:_z})}function LRr(c){return _.jsx(fh,{optionName:"normalization",label:"Normalization",defaultValue:Xo.NONE,choices:Xo,...c})}class IRr extends on{getMenuComponents(){const e=[Ei,jR,W4,R4,LRr,qn,L4,RRr,xi,Wt,Iv,Bn];return this.getOptions().displayMode!==Yo.HEATMAP&&e.splice(2,0,gm),e}}class VRr extends on{getMenuComponents(){const e=[Ei,jR,W4,R4,qn,L4,xi,Wt,Bn];return this.getOptions().displayMode!==Yo.HEATMAP&&e.splice(2,0,gm),e}}function FRr(c){return _.jsx(x4,{...c,optionName:"imageHeight",label:"Image height:",mode:1,step:1,domain:[36,100],values:c.optionsObjects[0].imageHeight,onUpdate:()=>{}})}class kRr extends on{getMenuComponents(){const e=[Ei,Nz];return this.getOptions().displayMode===si.DENSITY?e.push(qn):e.push(FRr),e.push(Bn),e}}const JRr="https://idr.openmicroscopy.org/webclient/render_image",jRr="",HRr="https://idr.openmicroscopy.org/webclient/img_detail",KRr="https://idr.openmicroscopy.org/webclient/render_thumbnail",PRr="",ORr="https://idr.openmicroscopy.org/webclient/get_thumbnails",QRr="https://idr.openmicroscopy.org/webclient/render_image_region",qRr="0/0/?tile=8,0,0,1024,1024";class $Rr extends kRr{constructor(e){super(e);const n={imageUrl:e.options.renderImageRegion?QRr:JRr,imageUrlSuffix:e.options.renderImageRegion?qRr:jRr,detailUrl:HRr,thumbnailUrl:KRr,thumbnailUrlSuffix:PRr,thumbnailData:ORr};Qr.isEmpty(e.apiConfig)&&(e.apiConfig=n)}}class rLr extends on{constructor(n){super(n);q(this,"bigWigTrackConfig");this.bigWigTrackConfig=new U8(n),this.setDefaultOptions({...q7,zoomLevel:"auto"})}getMenuComponents(n=1){return n<=CL?[Ei,qn,kt,Bn]:this.bigWigTrackConfig.getMenuComponents()}}class eLr extends on{getMenuComponents(){return[Ei,ASr,_Sr,PJ,CSr,pSr,Bn,xv,Ql,N4]}}function cLr(c){return _.jsx(wn,{...c,optionName:"windowSize",label:"Window size (pixels):",minValue:1,step:1,hasSetButton:!0})}class nLr extends on{constructor(n){super(n);q(this,"trackConfig");let h;n.url.endsWith(".gz")?(this.trackConfig=new QJ(n),h={...C1}):(this.trackConfig=new U8(n),h={...C1,zoomLevel:"auto"}),this.setDefaultOptions(h)}getMenuComponents(){return[Ei,cLr,qn,DSr,bSr,Bn]}}class hLr extends wo{getMenuComponents(){const e=[...super.getMenuComponents(),Ss,N4];return this.getOptions().displayMode===si.DENSITY&&e.push(kt),e}}function iLr(c){return _.jsx(wn,{...c,optionName:"pixelsPadding",label:"Padding drawing tick:",minValue:0,step:.1,isFloat:!0,hasSetButton:!0})}function tLr(c){return _.jsx(fh,{optionName:"sortItems",label:"Sort items order",defaultValue:Z4.NONE,choices:Z4,...c})}class sLr extends on{getMenuComponents(){return[...super.getMenuComponents(),ySr,xv,xi,Wt,Ql,Ss,qn,kt,tLr,qJ,iLr]}}const ij={bed:wxr,categorical:GSr,bigbed:pRr,bigwig:U8,hic:_Rr,longrange:ARr,bedcolor:Exr,biginteract:yRr,geneannotation:bRr,refbed:TRr,methylc:SRr,repeatmasker:MRr,rmskv2:GRr,genomealign:NRr,ruler:WRr,matplot:YRr,vcf:eLr,dynseq:rLr,omeroidr:$Rr,bam:Xxr,snp:XRr,dynamiclongrange:VRr,dynamicbed:lRr,dbedgraph:xRr,dynamichic:IRr,jaspar:hLr,boxplot:nLr,qbed:CRr,bedgraph:QJ,dynamic:wRr,modbed:sLr},aLr=on;if(Ke.env.NODE_ENV!=="production"){for(const c in ij)if(c.toLowerCase()!==c)throw new TypeError(`Type names may not contain uppercase letters. Offender: "${c}"`)}function v8(c){let e=c.type||c.filetype||"";e=e.toLowerCase();const n=ij[e];return n?new n(c):new aLr(c)}const oLr=["bigwig","bedgraph"];function lLr(c){const e=c.title!==void 0?c.title:`${c.numTracks} tracks selected`;return _.jsx("div",{style:{paddingLeft:5,fontWeight:"bold"},children:e})}function mLr(c){return c.tracks.length===1||c.tracks.map(h=>h.type).some(h=>!oLr.includes(h))?null:_.jsx("div",{className:"TrackContextMenu-item",children:_.jsx("button",{className:"btn btn-info btn-sm btn-tight",onClick:()=>c.onApplyMatplot(c.tracks,"matplot"),children:"Apply matplot"})})}function dLr(c){return _.jsxs("div",{onClick:()=>c.onClick(c.trackId),className:"TrackContextMenu-item TrackContextMenu-hoverable-item-danger",children:["❌"," ",c.numTracks>1?`Remove ${c.numTracks} tracks`:"Remove"]})}function uLr(c){const{tracks:e,fileInfos:n,onOptionSet:h}=c,i=e.map(v8);console.log(i);const t=e.map(U=>U.type==="hic");if(!Qr.every(t,Boolean))return null;const s=i.map(U=>U.getOptions()),a=[],o=[];n&&Object.keys(n).forEach(U=>{a.push(n[U].resolutions),o.push(n[U].normOptions)});const l=Qr.intersection(...a),m=Qr.intersection(...o),d={AUTO:0},u={NONE:"NONE"};return l.forEach(U=>d[bN(U)]=U),m.forEach(U=>u[U]=U),_.jsxs(_.Fragment,{children:[_.jsx(fh,{optionName:"binSize",label:"Bin size:",defaultValue:d.AUTO,choices:d,optionsObjects:s,onOptionSet:h}),_.jsx(fh,{optionName:"normalization",label:"Normalization",defaultValue:u.NONE,choices:u,optionsObjects:s,onOptionSet:h})]})}function C8(c){const{title:e,content:n}=c;if(typeof n=="string")return _.jsx("div",{children:n});const h=Object.entries(n).map((t,s)=>{let a;return E.isValidElement(t[1])?a=t[1]:go(t[1])?a=_.jsx(C8,{content:t[1]}):a=Array.isArray(t[1])?t[1].join(" > "):t[1],_.jsxs("tr",{children:[_.jsx("td",{children:t[0]}),_.jsx("td",{children:a})]},s)}),i=e?_.jsx("h6",{children:e}):"";return _.jsxs(E.Fragment,{children:[i,_.jsx("table",{className:"table table-sm table-striped",children:_.jsx("tbody",{children:h})})]})}function ULr(c){const e=c.track;let n=[];return e.details&&n.push(_.jsx("div",{children:_.jsx(C8,{title:"Details",content:e.details})},"details")),e.url&&n.push(_.jsxs("div",{children:[_.jsxs("h6",{children:["URL ",_.jsx(bm,{value:e.url})]}),_.jsx("p",{className:"TrackContextMenu-URL",children:e.url})]},"url")),e.indexUrl&&n.push(_.jsxs("div",{children:[_.jsxs("h6",{children:["Index URL ",_.jsx(bm,{value:e.indexUrl})]}),_.jsx("p",{className:"TrackContextMenu-URL",children:e.indexUrl})]},"indexUrl")),e.metadata&&n.push(_.jsx("div",{children:_.jsx(C8,{title:"Metadata",content:e.metadata})},"metadata")),_.jsx(Txr,{trigger:"More information",children:_.jsx("div",{className:"TrackContextMenu-item",children:n})})}function zLr(c){const e=c.menuData,n=c.darkTheme,h=E.useRef(null),[i,t]=E.useState({left:0,top:0}),s=e.pageX||0,a=e.pageY||0,o=E.useMemo(()=>e.items.map((l,m)=>_.jsx(l,{optionsObjects:e.configOptions,defaultValue:void 0,onOptionSet:e.onConfigChange,trackId:e.trackId},m)),[e.items,e.configOptions,e.onConfigChange,e.trackId]);return E.useEffect(()=>{if(h.current){const m=h.current.getBoundingClientRect().top+window.scrollY;let d=s-19,u=a-m;t({left:d,top:u})}},[s,a]),_.jsx("div",{ref:h,style:{position:"absolute",left:i.left,top:i.top,color:n?"white":"black",zIndex:1e3,pointerEvents:"auto"},children:_.jsxs("div",{className:"TrackContextMenu-body",style:{backgroundColor:n?"black":"white"},children:[_.jsx(lLr,{title:e.selectCount>1?e.selectCount+" tracks selected":e.selectCount===1&&e.tracks&&e.tracks[0]&&e.tracks[0].options&&e.tracks[0].options.label?e.tracks[0].options.label:"(unnamed track)",numTracks:e.selectCount}),_.jsx(uLr,{tracks:e.tracks,fileInfos:e.fileInfos,onOptionSet:e.onConfigChange}),o,_.jsx(dLr,{onClick:e.handleDelete,trackId:e.configOptions.map(l=>l.trackId),numTracks:e.selectCount}),_.jsx(mLr,{tracks:e.tracks,onApplyMatplot:e.handleAdd}),e.tracks.length===1?_.jsx(ULr,{track:e.tracks[0]}):""]})})}const vLr=E.memo(zLr);function CLr(c,e){let n;return c.initial===1?n=-c.startWindow:c.side==="right"?n=Math.floor(-c.xDist/e)*e-c.startWindow:c.side==="left"&&(n=Math.floor(c.xDist/e)*e-c.startWindow),n}const p8=["#000000","#00FF00","#0000FF","#FF0000","#01FFFE","#FFA6FE","#FFDB66","#006401","#010067","#95003A","#007DB5","#FF00F6","#FFEEE8","#774D00","#90FB92","#0076FF","#D5FF00","#FF937E","#6A826C","#FF029D","#FE8900","#7A4782","#7E2DD2","#85A900","#FF0056","#A42400","#00AE7E","#683D3B","#BDC6FF","#263400","#BDD393","#00B917","#9E008E","#001544","#C28C9F","#FF74A3","#01D0FF","#004754","#E56FFE","#788231","#0E4CA1","#91D0CB","#BE9970","#968AE8","#BB8800","#43002C","#DEFF74","#00FFC6","#FFE502","#620E00","#008F9C","#98FF52","#7544B1","#B500FF","#00FF78","#FF6E41","#005F39","#6B6882","#5FAD4E","#A75740","#A5FFD2","#FFB167","#009BFF","#E85EBE"],pLr="rgba(173, 216, 230, 0.9)",Vv=16;function DLr(c){let e=0;for(let n=0;n<c.length;n++){const h=c.charCodeAt(n);e=(e<<5)-e+h,e=e&e}return e}const bLr=({track:c,terms:e=[],onClick:n=()=>{},height:h})=>{const i=s=>{if(!s)return"white";const a=Math.abs(DLr(s))%p8.length;return p8[a]},t=s=>{let a;if(a=c.getMetadataAsis(s),go(a)&&a.name&&a.color)return _.jsx(tj,{color:a.color,term:s,termValue:a.name,onClick:o=>n(s,a.name)},s);{a=c.getMetadata(s);const o=i(a);return _.jsx(tj,{color:o,term:s,termValue:a,onClick:l=>n(s,a)},s)}};return _.jsx("div",{style:{display:"flex",height:h},children:e.map(s=>t(s))})},tj=({color:c,term:e,termValue:n,onClick:h})=>{const[i,t]=E.useState(!1),[s,a]=E.useState({x:0,y:0}),o=U=>{a({x:U.pageX,y:U.pageY}),t(!0)},l=()=>t(!1),m={backgroundColor:c,width:15,height:"100%",borderLeft:"1px solid lightgrey"},d=Object.assign({marginTop:Vv,pointerEvents:"auto"}),u=()=>i?je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:U})=>_.jsx("div",{ref:U,style:{position:"absolute",left:s.x-8*2,top:s.y}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:U,style:C,placement:p,arrowProps:D})=>_.jsxs("div",{ref:U,style:{...C,...d,zIndex:1001},className:"Tooltip",children:[_.jsxs("div",{className:"Tooltip-minor-text",children:[e,":"]}),_.jsx("div",{children:n||"(no value)"}),je.createPortal(_.jsx("div",{ref:D.ref,style:{...D.style,width:0,height:0,position:"absolute",left:s.x-8,top:s.y,borderLeft:`${Vv/2}px solid transparent`,borderRight:`${Vv/2}px solid transparent`,borderBottom:`${Vv}px solid ${pLr}`}}),document.body)]})})]}),document.body):null;return _.jsx("div",{style:m,onClick:h,onMouseEnter:o,onMouseLeave:l,children:u()})},sj={bigwig:"",bedgraph:"",methylc:"",boxplot:"",qbed:"",vcf:"",dynseq:"",matplot:"",longrange:"",hic:""},D8={bigwig:"",bedgraph:""};class gLr{constructor(){q(this,"aggregator");q(this,"dynseqAggregator");q(this,"aggregateRecords");q(this,"aggregateFeaturesMatplot");this.aggregator=new w5,this.aggregateRecords=(e,n,h)=>{const t=new jl().makeXMap(e,n,h);return(t.xToFeaturesForward?t.xToFeaturesForward:[]).map(Eo.aggregateByStrand)}}getGroupScale(e,n,h,i,t,s){if(n){const a={};for(let o=0;o<e.length;o++)if(e[o].options.group&&e[o].type in D8){const l=e[o].options.group,m=e[o].id;if(e[o].options.yScale===Nc.FIXED){a[l]={scale:Nc.FIXED,min:{[m]:e[o].options.yMin},max:{[m]:e[o].options.yMax}};break}if(n[m]){const d=n[m].data;let u;s.current[m][t].xvalues?u=s.current[m][t].xvalues:(u=this.aggregator.xToValueMaker(d,n[m].visRegion,h,n[m].configOptions),s.current[m][t]||(s.current[m][t]={}),s.current[m][t].xvalues=u);const U=u[0]&&u[0].length?Qr.max(u[0].slice(i.start,i.end)):1,C=u[1]&&u[1].length?Qr.min(u[1].slice(i.start,i.end)):0;a.hasOwnProperty(l)?(a[l].min[m]=C,a[l].max[m]=U):a[l]={scale:Nc.AUTO,min:{[m]:C},max:{[m]:U}}}}else{const l=e[o].id;if(n[l]){const m=n[l].data;let d;if(s.current[l][t].xvalues&&n[l].usePrimaryNav)continue;e[o].type==="dynseq"?d=this.aggregator.xToValueMaker(m,n[l].visRegion,h,n[l].configOptions):e[o].type==="methylc"?d=this.aggregateRecords(m,n[l].visRegion,h):e[o].type==="matplot"?d=m.map(u=>this.aggregator.xToValueMaker(u,n[l].visRegion,h,n[l].configOptions)[0]):d=this.aggregator.xToValueMaker(m,n[l].visRegion,h,n[l].configOptions),s.current[l][t]||(s.current[l][t]={}),s.current[l][t].xvalues=d}}return Qr.isEmpty(a)?{}:a}return{}}getGroupScaleWithXvalues(e,n,h){if(n){const i={};for(let t=0;t<e.length;t++){if(!(e[t].type in D8)||!e[t].options.group)continue;const s=e[t].options.group,a=e[t].id;if(e[t].options.yScale===Nc.FIXED){i[s]={scale:Nc.FIXED,min:{[a]:e[t].options.yMin},max:{[a]:e[t].options.yMax}};break}if(n[a]){const o=n[a],l=o[0]&&o[0].length?Qr.max(o[0].slice(h.start,h.end)):1,m=o[1]&&o[1].length?Qr.min(o[1].slice(h.start,h.end)):0;i.hasOwnProperty(s)?(i[s].min[a]=m,i[s].max[a]=l):i[s]={scale:Nc.AUTO,min:{[a]:m},max:{[a]:l}}}}return Qr.isEmpty(i)?{}:i}return{}}}const _Lr=({buttonLabel:c,children:e,className:n,height:h,xOffset:i=0,isVisible:t=!0,color:s})=>{const[a,o]=E.useState(!1),l=E.useRef(null);return E.useEffect(()=>{function m(d){l.current&&!l.current.contains(d.target)&&o(!1)}return a&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[a]),_.jsxs("div",{ref:l,className:`popover-root ${n||""}`,style:{position:"absolute",top:h-16,left:i,visibility:t?"visible":"hidden",pointerEvents:t?"auto":"none",opacity:t?1:0},children:[_.jsxs("button",{type:"button",className:`popover-btn${a?" open":""}`,onClick:()=>o(m=>!m),style:{zIndex:10,width:120},children:[_.jsxs("div",{style:{fontStyle:"italic"},children:[c," "]}),_.jsx("div",{className:"loader"}),_.jsx("span",{className:`popover-arrow${a?" open":""}`})]}),_.jsx("div",{className:`popover-panel${a?" open":""}`,style:a?{position:"absolute",top:"100%",left:0,zIndex:10,maxWidth:"300px",maxHeight:"200px",overflow:"auto",backgroundColor:"white",border:"1px solid #ccc",borderRadius:"4px",padding:"8px",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}:{display:"none"},children:e})]})};class h2 extends E.PureComponent{render(){const{feature:e,category:n,queryEndpoint:h}=this.props,i=n?n[e.getName()].name:e.getName();let t;if(e.id)if(Qr.isEmpty(h))if(String(e.id).startsWith("ENS")){const s=`http://www.ensembl.org/Multi/Search/Results?q=${e.id}`;t=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:["Ensembl",_.jsx("span",{role:"img","aria-label":"Ensembl",children:"🔗"})]})}else{const s=`https://www.ncbi.nlm.nih.gov/gene/?term=${String(e.id).split(".")[0]}`;t=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:["NCBI",_.jsx("span",{role:"img","aria-label":"NCBI",children:"🔗"})]})}else{const s=`${h.endpoint}${String(e.id)}`;t=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:[h.name,_.jsx("span",{role:"img","aria-label":h.name,children:"🔗"})]})}return _.jsxs("div",{children:[i?_.jsxs("div",{className:"Tooltip-major-text",children:[i," ",_.jsx(bm,{value:i})," "]}):null,e.id?_.jsxs("div",{children:[e.id," ",t]}):null,_.jsxs("div",{children:[e.getLocus().toString()," (",e.getLocus().getLength(),"bp)"]}),e.getHasStrand()?_.jsxs("div",{children:["Strand: ",e.getStrand()]}):null]})}}q(h2,"propTypes",{feature:Gr.instanceOf(vc).isRequired,category:Gr.object,queryEndpoint:Gr.object});class ALr extends E.PureComponent{render(){const{feature:e}=this.props,n=e.getName(),h=e.matrixId,i=e.strand==="-"?"?revcomp=1":"",t=e.strand==="-"?".rc":"",s=`https://jaspar.genereg.net/matrix/${h}/${i}`,a=`https://jaspar.genereg.net/static/logos/all/svg/${h}${t}.svg`,o=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:["view in Jaspar database",_.jsx("span",{role:"img","aria-label":"jaspar",children:"🔗"})]});return _.jsxs("div",{children:[n?_.jsx("div",{className:"Tooltip-major-text",children:n}):null,h?_.jsxs("div",{children:[h," ",o]}):null,_.jsxs("div",{children:["Score: ",e.score]}),_.jsx("div",{style:{textAlign:"center"},children:_.jsx("img",{alt:h,className:"img-fluid",style:{maxWidth:"100%",height:225},src:a})}),_.jsxs("div",{children:[e.getLocus().toString()," (",e.getLocus().getLength(),"bp)"]}),e.getHasStrand()?_.jsxs("div",{children:["Strand: ",e.getStrand()]}):null]})}}const aj=({gene:c,queryEndpoint:e})=>{const n=SD(c),h=BN(c.description);let i;if(go(h)){let t;h.hasOwnProperty("maneStat")?t=_.jsxs(_.Fragment,{children:[_.jsx("tr",{children:_.jsx("td",{colSpan:2,children:_.jsx("i",{style:{wordBreak:"break-word"},children:h.description})})}),_.jsxs("tr",{children:[_.jsx("td",{children:"Ensembl id:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ensembl.org/Homo_sapiens/Transcript/Summary?t=${h["Ensembl id"]}`,target:"_blank",rel:"noopener noreferrer",children:h["Ensembl id"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"Ensembl gene:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ensembl.org/homo_sapiens/Gene/Summary?g=${h["Ensembl gene"]}&db=core}`,target:"_blank",rel:"noopener noreferrer",children:h["Ensembl gene"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"Ensembl protein:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ensembl.org/Homo_sapiens/Transcript/Summary?t=${h["Ensembl protein"]}`,target:"_blank",rel:"noopener noreferrer",children:h["Ensembl protein"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"NCBI id:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ncbi.nlm.nih.gov/nuccore/${h["NCBI id"]}`,target:"_blank",rel:"noopener noreferrer",children:h["NCBI id"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"NCBI gene:"}),_.jsx("td",{children:h["NCBI gene"]})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"NCBI protein:"}),_.jsx("td",{children:_.jsx("a",{href:`https://www.ncbi.nlm.nih.gov/nuccore/${h["NCBI protein"]}`,target:"_blank",rel:"noopener noreferrer",children:h["NCBI protein"]})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"MANE transcript status:"}),_.jsx("td",{children:h.maneStat})]})]}):(t=Object.entries(h).map(([s,a],o)=>_.jsxs("tr",{children:[_.jsxs("td",{children:[s,":"]}),_.jsx("td",{children:a})]},o)),i=_.jsx("table",{className:"table table-sm table-striped",children:_.jsx("tbody",{children:t})}))}else i=_.jsx("i",{style:{wordBreak:"break-word"},children:h});return _.jsxs("div",{style:{maxWidth:400},children:[_.jsx(h2,{feature:c,queryEndpoint:e}),i,_.jsx("div",{children:c.transcriptionClass&&_.jsxs("span",{children:["Transcription class:"," ",_.jsx("span",{style:{color:n.color},children:c.transcriptionClass})]})})]})},oj=({snp:c})=>{const e=`https://www.ncbi.nlm.nih.gov/snp/?term=${c.id}`,n=_.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:["dbSNP",_.jsx("span",{role:"img","aria-label":"dbsnp",children:"🔗"})]});return _.jsxs("div",{children:[_.jsxs("div",{children:[c.id," ",n]}),_.jsxs("div",{children:[c.getLocus().toString()," (",c.getLocus().getLength(),"bp)"]}),c.getHasStrand()?_.jsxs("div",{children:["Strand: ",c.getStrand()]}):null]})},b8=10;class yLr extends E.PureComponent{render(){const{vcf:e}=this.props,n=e.variant.ID;let h,i={};if(n)if(n.length===1){const s=`https://www.ncbi.nlm.nih.gov/snp/${n[0]}`;h=_.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:[n[0],_.jsx("span",{role:"img","aria-label":"dbSNP",children:"🔗"})]})}else h=n.map(s=>_.jsxs("a",{href:`https://www.ncbi.nlm.nih.gov/snp/${s}`,target:"_blank",rel:"noopener noreferrer",children:[s,_.jsx("span",{role:"img","aria-label":"dbSNP",children:"🔗"})]},s));const t=Object.keys(e.variant.SAMPLES);return t.slice(0,b8).forEach(s=>i[s]=e.variant.SAMPLES[s]),_.jsxs("div",{children:[n?_.jsxs("div",{className:"Tooltip-major-text",children:[h," ",_.jsx(bm,{value:n.join(", ")})]}):null,_.jsxs("div",{children:[_.jsx("table",{className:"table table-sm",style:{marginBottom:0,lineHeight:1},children:_.jsxs("tbody",{children:[_.jsxs("tr",{children:[_.jsx("th",{children:"REF"}),_.jsx("td",{style:{wordBreak:"break-all",maxWidth:"300px"},children:e.variant.REF})]}),_.jsxs("tr",{children:[_.jsx("th",{children:"ALT"}),_.jsx("td",{style:{wordBreak:"break-all",maxWidth:"300px"},children:e.variant.ALT.join(", ")})]}),_.jsxs("tr",{children:[_.jsx("th",{children:"QUAL"}),_.jsx("td",{children:e.variant.QUAL})]})]})}),_.jsxs("div",{children:[e.getLocus().toString()," (",e.getLocus().getLength(),"bp)"]}),_.jsx("div",{children:ZLr(e.variant.INFO)}),_.jsxs("div",{children:[t&&t.length>0&&_.jsxs("span",{children:["Sample count: ",t.length]}),t&&t.length>b8&&_.jsxs("span",{children:["Showing first ",b8," samples:"]}),!Qr.isEmpty(i)&&BLr(i)]})]})]})}}const BLr=c=>{if(!c)return null;const e=Object.keys(c),n=Object.keys(c[e[0]]),h=e.map((t,s)=>_.jsxs("tr",{children:[_.jsx("td",{children:t}),n.map((a,o)=>_.jsx("td",{children:Array.isArray(c[t][a])?c[t][a].join(","):c[t][a]},o))]},s)),i=_.jsxs("tr",{children:[_.jsx("th",{children:"Sample"}),n.map((t,s)=>_.jsx("th",{children:t},s))]});return _.jsx("table",{className:"table table-bordered table-striped table-sm",style:{marginBottom:0,lineHeight:1,fontSize:12},children:_.jsxs("tbody",{children:[i,h]})})},ZLr=c=>{if(!c)return null;const e=Object.keys(c),n=_.jsx("tr",{children:e.map((i,t)=>_.jsx("td",{children:Array.isArray(c[i])?Qr.truncate(c[i].join(","),{length:75,separator:/[,; ]/}):c[i]},t))}),h=_.jsx("tr",{children:e.map((i,t)=>_.jsx("th",{children:i},t))});return _.jsx("table",{className:"table table-bordered table-striped table-sm",style:{marginBottom:0,lineHeight:1,fontSize:12},children:_.jsxs("tbody",{children:[h,n]})})},ji="rgba(173, 216, 230, 0.9)",fe=16,_m={bigbed:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(h2,{feature:e,category:void 0,queryEndpoint:void 0})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},geneannotation:function({gene:e,pageX:n,pageY:h,name:i,onClose:t,isThereG3dTrack:s,setShow3dGene:a}){const o=Object.assign({marginTop:fe,pointerEvents:"auto"});return _.jsxs(wh,{children:[_.jsx(r1,{children:({ref:m})=>_.jsx("div",{ref:m,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:m,style:d,placement:u,arrowProps:U})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:m,style:{...d,...o,zIndex:1001},className:"Tooltip",children:_.jsxs(Zh,{onOutsideClick:t,children:[_.jsx(aj,{gene:e,collectionName:i,queryEndpoint:{}}),s?_.jsx("div",{children:_.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>a?a(e):()=>{},children:"Show in 3D"})}):""]})}),_.jsx("div",{ref:U.ref,style:{...U.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]})},refbed:function({gene:e,pageX:n,pageY:h,name:i,onClose:t,isThereG3dTrack:s,setShow3dGene:a}){const o=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:l})=>_.jsx("div",{ref:l,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:l,style:m,placement:d,arrowProps:u})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:l,style:{...m,...o,zIndex:1001},className:"Tooltip",children:_.jsxs(Zh,{onOutsideClick:t,children:[_.jsx(aj,{gene:e,collectionName:i,queryEndpoint:{}}),s?_.jsx("div",{children:_.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>a?a(e):()=>{},children:"Show in 3D"})}):""]})}),_.jsx("div",{ref:u.ref,style:{...u.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},bed:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(h2,{feature:e,category:void 0,queryEndpoint:void 0})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},bedcolor:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(h2,{feature:e,category:void 0,queryEndpoint:void 0})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},repeatmasker:function({feature:e,pageX:n,pageY:h,name:i,onClose:t,trackModel:s}){const a=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:o})=>_.jsx("div",{ref:o,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:o,style:l,placement:m,arrowProps:d})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:o,style:{...l,...a,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsxs("div",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"Tooltip-major-text",style:{marginRight:5},children:e.getName()}),_.jsx("span",{className:"Tooltip-minor-text",children:e.getClassDetails()})]}),_.jsxs("div",{children:[e.getLocus().toString()," (",e.getLocus().getLength(),"bp)"]}),_.jsxs("div",{children:["(1 - divergence%) = ",e.repeatValue.toFixed(2)]}),_.jsxs("div",{children:["strand: ",e.strand]}),_.jsx("div",{className:"Tooltip-minor-text",children:s.getDisplayLabel()})]})})}),_.jsx("div",{ref:d.ref,style:{...d.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},omeroidr:function({snp:e,pageX:n,pageY:h,onClose:i}){const t=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:s})=>_.jsx("div",{ref:s,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:s,style:a,placement:o,arrowProps:l})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:s,style:{...a,...t,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:i,children:_.jsx(oj,{snp:e})})}),_.jsx("div",{ref:l.ref,style:{...l.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},bam:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"}),a=e.getAlignment();return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:o})=>_.jsx("div",{ref:o,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:o,style:l,placement:m,arrowProps:d})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:o,style:{...l,...s,zIndex:1001},className:"Tooltip",children:_.jsxs(Zh,{onOutsideClick:t,children:[_.jsx(h2,{feature:e,category:void 0,queryEndpoint:void 0}),_.jsxs("div",{style:{fontFamily:"monospace",whiteSpace:"pre"},children:[_.jsxs("div",{children:["Ref ",a.reference]}),_.jsxs("div",{children:[" ",a.lines]}),_.jsxs("div",{children:["Read ",a.read]})]})]})}),_.jsx("div",{ref:d.ref,style:{...d.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},snp:function({snp:e,pageX:n,pageY:h,name:i="",onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(oj,{snp:e})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},categorical:function({feature:e,pageX:n,pageY:h,name:i,onClose:t,configOptions:s}){const a=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:o})=>_.jsx("div",{ref:o,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:o,style:l,placement:m,arrowProps:d})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:o,style:{...l,...a,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(h2,{feature:e,category:s.category,queryEndpoint:void 0})})}),_.jsx("div",{ref:d.ref,style:{...d.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},vcf:function({vcf:e,pageX:n,pageY:h,name:i,onClose:t}){return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:s})=>_.jsx("div",{ref:s,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:s,style:a,placement:o,arrowProps:l})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:s,style:{...a,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(yLr,{vcf:e})})}),_.jsx("div",{ref:l.ref,style:{...l.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},jaspar:function({feature:e,pageX:n,pageY:h,name:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsx("div",{children:je.createPortal(_.jsxs(_.Fragment,{children:[_.jsx("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:_.jsx(Zh,{onOutsideClick:t,children:_.jsx(ALr,{feature:e})})}),_.jsx("div",{ref:m.ref,style:{...m.style,width:0,height:0,position:"absolute",left:n-8,top:h,borderLeft:`${fe/2}px solid transparent`,borderRight:`${fe/2}px solid transparent`,borderBottom:`${fe}px solid ${ji}`}})]}),document.body)})})]}),document.body)},normModbed:function({bs:e,pageX:n,pageY:h,feature:i,onClose:t}){const s=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:a})=>_.jsx("div",{ref:a,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:a,style:o,placement:l,arrowProps:m})=>_.jsxs("div",{ref:a,style:{...o,...s,zIndex:1001},className:"Tooltip",children:[_.jsx(Zh,{onOutsideClick:t,children:_.jsxs("div",{children:[e&&`position ${e} in`," ",i.getName()," read"]})}),_.jsx("div",{children:i.getName()})]})})]}),document.body)},barModbed:function({feature:e,pageX:n,pageY:h,onCount:i,onPct:t,total:s,onClose:a}){const o=Object.assign({marginTop:fe,pointerEvents:"auto"});return je.createPortal(_.jsxs(wh,{children:[_.jsx(r1,{children:({ref:l})=>_.jsx("div",{ref:l,style:{position:"absolute",left:n-8*2,top:h}})}),_.jsx($h,{placement:"bottom-start",modifiers:[{name:"flip",enabled:!1}],children:({ref:l,style:m,placement:d,arrowProps:u})=>_.jsxs("div",{ref:l,style:{...m,...o,zIndex:1001},className:"Tooltip",children:[_.jsx(Zh,{onOutsideClick:a,children:_.jsxs("div",{children:[i,"/",s," (",`${(t*100).toFixed(2)}%`,")"]})}),_.jsx("div",{children:e.getName()})]})})]}),document.body)}},fLr=({numHidden:c,height:e,xOffset:n=0,isVisible:h=!1,color:i})=>{const[t,s]=E.useState(!1),[a,o]=E.useState(!0),l=E.useRef(null);return E.useEffect(()=>{function m(d){l.current&&!l.current.contains(d.target)&&s(!1)}return t&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[t]),_.jsx("div",{ref:l,style:{position:"absolute",top:e-16,left:a?0:n,visibility:h?"visible":"hidden",zIndex:10,pointerEvents:"none"},children:a?_.jsxs("div",{onClick:()=>o(!1),className:"popover-btn",style:{width:120,gap:"0.5em",position:"relative",verticalAlign:"top",padding:"0 7px 0 5px",fontStyle:"italic",pointerEvents:"auto"},children:[_.jsxs("span",{style:{textAlign:"left"},children:[c," items hidden"]}),_.jsx("span",{className:`popover-arrow${t?" open":""}`})]}):_.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",pointerEvents:"none"},children:_.jsx("div",{style:{gap:"0.8em",alignItems:"center",color:i,fontFamily:"BlinkMacSystemFont, -apple-system, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif",fontSize:"0.8rem",height:"16px",position:"relative",verticalAlign:"top",whiteSpace:"nowrap",pointerEvents:"none"},children:_.jsxs("div",{style:{fontStyle:"italic",pointerEvents:"none"},children:[c," items hidden - zoom"," ",_.jsx("span",{onClick:()=>o(!0),style:{fontSize:"12px",color:"#007acc",cursor:"pointer",textDecoration:"underline",pointerEvents:"auto"},children:"dismiss"})]})})})})};function lj(c){const e=c.length>0?Math.max(...c.map(h=>{var i;return((i=h.dataCache)==null?void 0:i.length)||0})):0,n=new Array(e);for(let h=0;h<e;h++)n[h]=[];for(let h=0;h<c.length;h++){const t=c[h].dataCache;for(let s=0;s<t.length;s++){const a=t[s];n[s].push(a)}}return n}const Fv={biginteract:"",dynamichic:"",dynamiclongrange:"",hic:"",longrange:"",genomealign:""},SLr=2,MLr=E.memo(function({trackManagerRef:e,basePerPixel:n,updateGlobalTrackConfig:h,side:i,windowWidth:t=0,genomeConfig:s,trackModel:a,dataIdx:o,signalTrackLoadComplete:l,trackIdx:m,id:d,setShow3dGene:u,isThereG3dTrack:U,viewWindowConfigChange:C,applyTrackConfigChange:p,sentScreenshotData:D,dragX:A,newDrawData:f,trackFetchedDataCache:M,globalTrackState:S,isScreenShotOpen:N,posRef:x,highlightElements:B,viewWindowConfigData:W,metaSets:T,onColorBoxClick:L,messageData:I,Toolbar:J,handleRetryFetchTrack:$,initialLoad:sr}){var g0;const vr=E.useRef(eh[a.type]?{...eh[`${a.type}`].defaultOptions}:{...eh.error.defaultOptions}),pr=E.useRef(!0),dr=E.useRef(0),zr=E.useRef("right"),tr=E.useRef(void 0),er=E.useRef(!1),H=E.useRef(0),[O,Q]=E.useState(null),[k,rr]=E.useState(),[mr,yr]=E.useState(!1),[Sr,Hr]=E.useState(null);function wr(z0){let m0=eh[`${a.type}`].ROW_HEIGHT,u0=vr.current,E0=Math.min(z0,u0.maxRows);return u0.hideMinimalItems&&(E0-=1),E0<1&&(E0=1),a.type==="modbed"?(E0+1)*m0+2:E0*m0+SLr}function Jr(z0,m0,u0,E0=null){const B0=CLr(z0,t),_0=c8({basesByPixel:n,genesArr:m0,genomeConfig:s,genomeName:s.genome.getName(),trackState:z0,windowWidth:t,configOptions:vr.current,renderTooltip:a.type==="modbed"?Pr:kr,svgHeight:dr,updatedLegend:tr,trackModel:a,getGenePadding:eh[`${a.type}`]?eh[`${a.type}`].getGenePadding:eh.error.getGenePadding,getHeight:wr,ROW_HEIGHT:eh[`${a.type}`]?eh[`${a.type}`].ROW_HEIGHT:eh.error.ROW_HEIGHT,groupScale:z0.groupScale,xvaluesData:E0,onClose:xr,errorInfo:er.current,handleRetryFetchTrack:$,initialLoad:sr.current});if(u0===o){l(d),zr.current=i;let w0,x0=0;typeof _0=="object"&&Object.prototype.hasOwnProperty.call(_0,"numHidden")?(w0=_0.component,x0=_0.numHidden):w0=_0,Q({component:w0,dataIdx:u0,numHidden:x0}),H.current=B0}}function xr(){rr(null)}function kr(z0,m0){const u0=_m[`${a.type}`]({gene:m0,feature:m0,snp:m0,vcf:m0,trackModel:a,pageX:z0.pageX,pageY:z0.pageY,name:s.genome._name,onClose:xr,isThereG3dTrack:U,setShow3dGene:u,configOptions:vr.current});yr(!0),rr(je.createPortal(u0,document.body))}function Pr(z0,m0,u0,E0,B0="",_0="",w0=""){let x0;E0==="norm"?x0=_m.normModbed({bs:u0,pageX:z0.pageX,pageY:z0.pageY,feature:m0,onClose:xr}):x0=_m.barModbed({feature:m0,pageX:z0.pageX,pageY:z0.pageY,onCount:B0,onPct:_0,total:w0,onClose:xr}),yr(!0),rr(x0)}E.useEffect(()=>{O&&O.dataIdx===o&&Hr(tr.current)},[O]);function D0({cacheTrackData:z0,trackState:m0,viewWindow:u0,groupScale:E0,xvalues:B0,isInit:_0,matplotCheck:w0,skipNoData:x0}){var L0;const a0=m0.genomicFetchCoord[m0.primaryGenName].primaryVisData;if(z0.trackType!=="genomealign"){let ce=!z0.usePrimaryNav&&((L0=m0.genomicFetchCoord[z0.queryGenome])!=null&&L0.queryRegion)?m0.genomicFetchCoord[z0.queryGenome].queryRegion:a0.visRegion;m0.visRegion=ce}if(m0.visWidth=a0.visWidth?a0.visWidth:t*3,m0.dataIdx=o,_0&&pr.current&&(G4.has(a.type)&&(vr.current.trackManagerRef=e),vr.current={...vr.current,...a.options},h({configOptions:vr.current,trackModel:a,id:d,trackIdx:m,usePrimaryNav:z0.usePrimaryNav}),pr.current=!1),vr.current.usePrimaryNav=z0.usePrimaryNav,er.current=z0.Error?z0.Error:null,er.current){m0.recreate=!1,Jr(m0,[],o,null);return}if(!z0.useExpandedLoci&&z0.usePrimaryNav){let ce=[],le=o+1,ve=!1;for(let or=0;or<3;or++){if(!z0[le]||!z0[le].dataCache){ve=!0;continue}ce.push(z0[le]),le--}GJ.has(a.type)&&(z0[`${o}`]&&z0[`${o}`].xvalues?ce=[]:ce=lj(ce)),(!ve||x0)&&(u0&&(m0.viewWindow=u0),E0!==void 0&&(m0.groupScale=E0),Jr(m0,ce,o,B0||null))}else{const ce=z0[o]?z0[o].dataCache:null;u0&&(m0.viewWindow=u0),ce&&Jr(m0,ce,o,B0||null)}}return E.useEffect(()=>{var z0;if(f.completedFetchedRegion&&f.completedFetchedRegion.current.done[d]===!1){if(o===f.completedFetchedRegion.current.key)f.completedFetchedRegion.current.done[d]=!0;else return;if(!M.current[`${d}`]||!S.current.trackStates[o]||!S.current.trackStates[o].trackState.genomicFetchCoord)return;const m0=M.current[`${d}`];let u0={...S.current.trackStates[o].trackState};D0({cacheTrackData:m0,trackState:u0,viewWindow:f.viewWindow,groupScale:S.current.trackStates[o].trackState.groupScale,xvalues:(z0=m0[o])==null?void 0:z0.xvalues,isInit:!0,matplotCheck:!0,skipNoData:!1})}},[f]),E.useEffect(()=>{var z0,m0;if(O!==null&&d in p){vr.current={...vr.current,...p[`${d}`]},h({configOptions:vr.current,trackModel:a,id:d,trackIdx:m});let u0=o,E0=M.current[`${d}`],B0=Qr.cloneDeep(S.current.trackStates[u0].trackState);B0.recreate=!0,D0({cacheTrackData:E0,trackState:B0,viewWindow:(z0=W.current)==null?void 0:z0.viewWindow,groupScale:S.current.trackStates[o].trackState.groupScale,xvalues:(m0=E0[o])==null?void 0:m0.xvalues,isInit:!1,matplotCheck:!0,skipNoData:!1})}},[p]),E.useEffect(()=>{var z0;if(C&&d in C.trackToDrawId&&(a.type in sj||vr.current.displayMode==="density")){let m0=Qr.cloneDeep(S.current.trackStates[o].trackState),u0=M.current[`${d}`];m0.recreate=!0,D0({cacheTrackData:u0,trackState:m0,viewWindow:C.viewWindow,groupScale:S.current.trackStates[o].trackState.groupScale,xvalues:(z0=u0[o])==null?void 0:z0.xvalues,isInit:!1,matplotCheck:!0,skipNoData:!1})}},[C]),E.useEffect(()=>{if(N){async function z0(){let m0=o,u0=M.current[`${d}`],E0=[],B0=Qr.cloneDeep(S.current.trackStates[m0].trackState);if(u0.useExpandedLoci)E0=u0[o]?Qr.clone(u0[o].dataCache):null,E0&&f.viewWindow&&(B0.viewWindow=f.viewWindow);else{let or=o+1;var _0=!1;for(let V=0;V<3;V++){if(!u0[or]||!u0[or].dataCache){_0=!0;continue}E0.push(Qr.clone(u0[or])),or--}_0||(f.viewWindow&&(B0.viewWindow=f.viewWindow),B0.groupScale=S.current.trackStates[o].trackState.groupScale)}const w0=B0.genomicFetchCoord[B0.primaryGenName].primaryVisData;let x0=u0.usePrimaryNav?w0.visRegion:B0.genomicFetchCoord[M.current[`${d}`].queryGenome].queryRegion;B0.visRegion=x0;const a0=w0.visWidth?w0.visWidth:t*3,L0=zr.current==="right"?new Y0(-(A+(H.current+t)),t*3+-(A+(H.current+t))):new Y0(-(A-(H.current+t))+t,t*3-(A-(H.current+t))+t);let ce=L0.start+a0/3,le=L0.end-a0/3;B0.viewWindow=new Y0(ce,le);let ve={...vr.current};ve.forceSvg=!0,B0.groupScale=S.current.trackStates[o].trackState.groupScale,E0&&D({fetchData:{genomeName:s.genome.getName(),genesArr:E0,trackState:B0,windowWidth:t,configOptions:ve,svgHeight:vr.current.displayMode==="full"?dr.current:vr.current.height,trackModel:a,basesByPixel:n,genomeConfig:s,xvaluesData:u0[o].xvalues?u0[o].xvalues:null,isError:er.current},trackId:d})}z0()}},[N]),_.jsxs("div",{style:{display:"flex",position:"relative"},children:[_.jsx("div",{style:{zIndex:2,width:120,backgroundColor:a.isSelected?"yellow":"var(--bg-color)",color:(g0=a.options)!=null&&g0.legendFontColor?a.options.legendFontColor:a.isSelected?"black":"var(--font-color)",marginBottom:"1px"},children:Sr}),_.jsx(_Lr,{buttonLabel:O&&o!==O.dataIdx||!O?"Loading View":"Getting Data",height:O?vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height:40,color:a.isSelected?"black":"var(--font-color)",isVisible:a.id in I||!O||O&&o!==O.dataIdx,children:_.jsx("div",{children:a.id in I?I[`${a.id}`].map((z0,m0)=>_.jsxs("div",{children:[z0.genomicLoci?z0.genomicLoci.map(u0=>u0.toString()):""," "]},`${a.index}loading-${m0}`)):""})}),_.jsx(fLr,{numHidden:O&&O.numHidden?O.numHidden:"",color:a.isSelected?"black":"var(--font-color)",height:vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height,xOffset:t/2+120-(15*T.terms.length-1),isVisible:O&&O.numHidden&&!(a.id in I||!O||O&&o!==O.dataIdx)}),J.skeleton&&!O?_.jsx("div",{style:{},children:_.jsx(J.skeleton,{width:t,height:40})}):"",_.jsxs("div",{ref:x,style:{display:"flex",height:vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height,position:"relative",WebkitBackfaceVisibility:"hidden",WebkitPerspective:"0px",backfaceVisibility:"hidden",perspective:"0px"},children:[_.jsx("div",{style:{position:"absolute",lineHeight:0,right:zr.current==="left"?`${H.current}px`:"",left:zr.current==="right"?`${H.current}px`:"",backgroundColor:vr.current.backgroundColor},children:O?O.component:""}),_.jsx("div",{className:mr?"visible":"hidden",children:k}),B.length>0?B.map((z0,m0)=>{if(z0.display)return _.jsx("div",{style:{display:"flex",position:"relative",height:"100%"},children:_.jsx("div",{style:{position:"absolute",backgroundColor:z0.color,top:"0",height:"100%",left:z0.side==="right"?`${z0.xPos}px`:"",right:z0.side==="left"?`${z0.xPos}px`:"",width:z0.width,pointerEvents:"none"}},m0)},m0)}):""]}),_.jsx("div",{style:{position:"absolute",zIndex:3,height:vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height,left:t+(120-(15*T.terms.length-1))},children:_.jsx(bLr,{track:a,terms:T.terms,onClick:L,height:vr.current.displayMode==="full"?er.current?40:dr.current:er.current?40:vr.current.height})})]})}),mj=E.memo(MLr);let dj=class{constructor(e,n){this.blockPosition=e,this.dataPosition=n}toString(){return`${this.blockPosition}:${this.dataPosition}`}compareTo(e){return this.blockPosition-e.blockPosition||this.dataPosition-e.dataPosition}static min(...e){let n,h=0;for(;!n;h+=1)n=e[h];for(;h<e.length;h+=1)n.compareTo(e[h])>0&&(n=e[h]);return n}};function Am(c,e=0,n=!1){if(n)throw new Error("big-endian virtual file offsets not implemented");return new dj(c[e+7]*1099511627776+c[e+6]*4294967296+c[e+5]*16777216+c[e+4]*65536+c[e+3]*256+c[e+2],c[e+1]<<8|c[e])}let uj=class{constructor(e,n,h,i){this.minv=e,this.maxv=n,this.bin=h,this._fetchedSize=i}toUniqueString(){return`${this.minv.toString()}..${this.maxv.toString()} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`}toString(){return this.toUniqueString()}compareTo(e){return this.minv.compareTo(e.minv)||this.maxv.compareTo(e.maxv)||this.bin-e.bin}fetchedSize(){return this._fetchedSize!==void 0?this._fetchedSize:this.maxv.blockPosition+65536-this.minv.blockPosition}};function GLr(c){return new Promise(e=>setTimeout(e,c))}function NLr(c){if(c.greaterThan(Number.MAX_SAFE_INTEGER)||c.lessThan(Number.MIN_SAFE_INTEGER))throw new Error("integer overflow");return c.toNumber()}function WLr(c){if(c&&c.aborted)if(typeof DOMException>"u"){const e=new Error("aborted");throw e.code="ERR_ABORTED",e}else throw new DOMException("aborted","AbortError")}function TLr(c,e){return e.minv.blockPosition-c.maxv.blockPosition<65e3&&e.maxv.blockPosition-c.minv.blockPosition<5e6}function XLr(c={}){return"aborted"in c?{signal:c}:c}function Uj(c,e){const n=[];let h;if(c.length===0)return c;c.sort((i,t)=>{const s=i.minv.blockPosition-t.minv.blockPosition;return s===0?i.minv.dataPosition-t.minv.dataPosition:s});for(const i of c)(!e||i.maxv.compareTo(e)>0)&&(h===void 0?(n.push(i),h=i):TLr(h,i)?i.maxv.compareTo(h.maxv)>0&&(h.maxv=i.maxv):(n.push(i),h=i));return n}function zj(c,e){return{lineCount:NLr(wz.fromBytesLE(Array.prototype.slice.call(c,e,e+8),!0))}}function kv(c,e){return c?c.compareTo(e)>0?e:c:e}function YLr(c,e=n=>n){let n=0,h=0;const i=[],t={};for(let s=0;s<c.length;s+=1)if(!c[s]){if(h<s){let a=c.toString("utf8",h,s);a=e(a),i[n]=a,t[a]=n}h=s+1,n+=1}return{refNameToId:t,refIdToName:i}}let vj=class{constructor({filehandle:e,renameRefSeq:n=h=>h}){this.filehandle=e,this.renameRefSeq=n}};const wLr=21578050;function ELr(c,e){return c-c%e}function xLr(c,e){return c-c%e+e}function RLr(c,e){return e-=1,[[0,0],[1+(c>>26),1+(e>>26)],[9+(c>>23),9+(e>>23)],[73+(c>>20),73+(e>>20)],[585+(c>>17),585+(e>>17)],[4681+(c>>14),4681+(e>>14)]]}class I4 extends vj{async lineCount(e,n){var h,i;return((i=(h=(await this.parse(n)).indices[e])===null||h===void 0?void 0:h.stats)===null||i===void 0?void 0:i.lineCount)||0}async _parse(e){const n=await this.filehandle.readFile(e);if(n.readUInt32LE(0)!==wLr)throw new Error("Not a BAI file");const h=n.readInt32LE(4),t=((1<<(5+1)*3)-1)/7;let s=8,a;const o=new Array(h);for(let l=0;l<h;l++){const m=n.readInt32LE(s);let d;s+=4;const u={};for(let p=0;p<m;p+=1){const D=n.readUInt32LE(s);if(s+=4,D===t+1)s+=4,d=zj(n,s+16),s+=32;else{if(D>t+1)throw new Error("bai index contains too many bins, please use CSI");{const A=n.readInt32LE(s);s+=4;const f=new Array(A);for(let M=0;M<A;M++){const S=Am(n,s);s+=8;const N=Am(n,s);s+=8,a=kv(a,S),f[M]=new uj(S,N,D)}u[D]=f}}}const U=n.readInt32LE(s);s+=4;const C=new Array(U);for(let p=0;p<U;p++){const D=Am(n,s);s+=8,a=kv(a,D),C[p]=D}o[l]={binIndex:u,linearIndex:C,stats:d}}return{bai:!0,firstDataLine:a,maxBlockSize:65536,indices:o,refCount:h}}async indexCov(e,n,h,i={}){const s=n!==void 0,o=(await this.parse(i)).indices[e];if(!o)return[];const{linearIndex:l=[],stats:m}=o;if(l.length===0)return[];const d=h===void 0?(l.length-1)*16384:xLr(h,16384),u=n===void 0?0:ELr(n,16384),U=s?new Array((d-u)/16384):new Array(l.length-1),C=l[l.length-1].blockPosition;if(d>(l.length-1)*16384)throw new Error("query outside of range of linear index");let p=l[u/16384].blockPosition;for(let D=u/16384,A=0;D<d/16384;D++,A++)U[A]={score:l[D+1].blockPosition-p,start:D*16384,end:D*16384+16384},p=l[D+1].blockPosition;return U.map(D=>({...D,score:D.score*((m==null?void 0:m.lineCount)||0)/C}))}async blocksForRange(e,n,h,i={}){n<0&&(n=0);const t=await this.parse(i);if(!t)return[];const s=t.indices[e];if(!s)return[];const a=RLr(n,h),o=[];for(const[U,C]of a)for(let p=U;p<=C;p++)if(s.binIndex[p]){const D=s.binIndex[p];for(const A of D)o.push(A)}const l=s.linearIndex.length;let m;const d=Math.min(n>>14,l-1),u=Math.min(h>>14,l-1);for(let U=d;U<=u;++U){const C=s.linearIndex[U];C&&(!m||C.compareTo(m)<0)&&(m=C)}return Uj(o,m)}async parse(e={}){return this.setupP||(this.setupP=this._parse(e).catch(n=>{throw this.setupP=void 0,n})),this.setupP}async hasRefSeq(e,n={}){var h;return!!(!((h=(await this.parse(n)).indices[e])===null||h===void 0)&&h.binIndex)}}let g8=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(g8=new Int32Array(g8));const LLr=(c,e)=>{let n=e===0?0:~~e^-1;for(let h=0;h<c.length;h++)n=g8[(n^c[h])&255]^n>>>8;return n^-1},Cj=(c,e)=>Ti.from(c,e);function ILr(c,e){const n=(h,i)=>e(Cj(h),i)>>>0;return n.signed=(h,i)=>e(Cj(h),i),n.unsigned=n,n.model=c,n}const VLr=ILr("crc-32",LLr);var Ta={};(function(c){var e=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function n(t,s){return Object.prototype.hasOwnProperty.call(t,s)}c.assign=function(t){for(var s=Array.prototype.slice.call(arguments,1);s.length;){var a=s.shift();if(a){if(typeof a!="object")throw new TypeError(a+"must be non-object");for(var o in a)n(a,o)&&(t[o]=a[o])}}return t},c.shrinkBuf=function(t,s){return t.length===s?t:t.subarray?t.subarray(0,s):(t.length=s,t)};var h={arraySet:function(t,s,a,o,l){if(s.subarray&&t.subarray){t.set(s.subarray(a,a+o),l);return}for(var m=0;m<o;m++)t[l+m]=s[a+m]},flattenChunks:function(t){var s,a,o,l,m,d;for(o=0,s=0,a=t.length;s<a;s++)o+=t[s].length;for(d=new Uint8Array(o),l=0,s=0,a=t.length;s<a;s++)m=t[s],d.set(m,l),l+=m.length;return d}},i={arraySet:function(t,s,a,o,l){for(var m=0;m<o;m++)t[l+m]=s[a+m]},flattenChunks:function(t){return[].concat.apply([],t)}};c.setTyped=function(t){t?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,h)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,i))},c.setTyped(e)})(Ta);var V4={},Xs={},ym={},FLr=Ta,kLr=4,pj=0,Dj=1,JLr=2;function Bm(c){for(var e=c.length;--e>=0;)c[e]=0}var jLr=0,bj=1,HLr=2,KLr=3,PLr=258,_8=29,F4=256,k4=F4+1+_8,Zm=30,A8=19,gj=2*k4+1,i2=15,y8=16,OLr=7,B8=256,_j=16,Aj=17,yj=18,Z8=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Jv=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],QLr=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Bj=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],qLr=512,Xa=new Array((k4+2)*2);Bm(Xa);var J4=new Array(Zm*2);Bm(J4);var j4=new Array(qLr);Bm(j4);var H4=new Array(PLr-KLr+1);Bm(H4);var f8=new Array(_8);Bm(f8);var jv=new Array(Zm);Bm(jv);function S8(c,e,n,h,i){this.static_tree=c,this.extra_bits=e,this.extra_base=n,this.elems=h,this.max_length=i,this.has_stree=c&&c.length}var Zj,fj,Sj;function M8(c,e){this.dyn_tree=c,this.max_code=0,this.stat_desc=e}function Mj(c){return c<256?j4[c]:j4[256+(c>>>7)]}function K4(c,e){c.pending_buf[c.pending++]=e&255,c.pending_buf[c.pending++]=e>>>8&255}function L1(c,e,n){c.bi_valid>y8-n?(c.bi_buf|=e<<c.bi_valid&65535,K4(c,c.bi_buf),c.bi_buf=e>>y8-c.bi_valid,c.bi_valid+=n-y8):(c.bi_buf|=e<<c.bi_valid&65535,c.bi_valid+=n)}function Ys(c,e,n){L1(c,n[e*2],n[e*2+1])}function Gj(c,e){var n=0;do n|=c&1,c>>>=1,n<<=1;while(--e>0);return n>>>1}function $Lr(c){c.bi_valid===16?(K4(c,c.bi_buf),c.bi_buf=0,c.bi_valid=0):c.bi_valid>=8&&(c.pending_buf[c.pending++]=c.bi_buf&255,c.bi_buf>>=8,c.bi_valid-=8)}function rIr(c,e){var n=e.dyn_tree,h=e.max_code,i=e.stat_desc.static_tree,t=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,o=e.stat_desc.max_length,l,m,d,u,U,C,p=0;for(u=0;u<=i2;u++)c.bl_count[u]=0;for(n[c.heap[c.heap_max]*2+1]=0,l=c.heap_max+1;l<gj;l++)m=c.heap[l],u=n[n[m*2+1]*2+1]+1,u>o&&(u=o,p++),n[m*2+1]=u,!(m>h)&&(c.bl_count[u]++,U=0,m>=a&&(U=s[m-a]),C=n[m*2],c.opt_len+=C*(u+U),t&&(c.static_len+=C*(i[m*2+1]+U)));if(p!==0){do{for(u=o-1;c.bl_count[u]===0;)u--;c.bl_count[u]--,c.bl_count[u+1]+=2,c.bl_count[o]--,p-=2}while(p>0);for(u=o;u!==0;u--)for(m=c.bl_count[u];m!==0;)d=c.heap[--l],!(d>h)&&(n[d*2+1]!==u&&(c.opt_len+=(u-n[d*2+1])*n[d*2],n[d*2+1]=u),m--)}}function Nj(c,e,n){var h=new Array(i2+1),i=0,t,s;for(t=1;t<=i2;t++)h[t]=i=i+n[t-1]<<1;for(s=0;s<=e;s++){var a=c[s*2+1];a!==0&&(c[s*2]=Gj(h[a]++,a))}}function eIr(){var c,e,n,h,i,t=new Array(i2+1);for(n=0,h=0;h<_8-1;h++)for(f8[h]=n,c=0;c<1<<Z8[h];c++)H4[n++]=h;for(H4[n-1]=h,i=0,h=0;h<16;h++)for(jv[h]=i,c=0;c<1<<Jv[h];c++)j4[i++]=h;for(i>>=7;h<Zm;h++)for(jv[h]=i<<7,c=0;c<1<<Jv[h]-7;c++)j4[256+i++]=h;for(e=0;e<=i2;e++)t[e]=0;for(c=0;c<=143;)Xa[c*2+1]=8,c++,t[8]++;for(;c<=255;)Xa[c*2+1]=9,c++,t[9]++;for(;c<=279;)Xa[c*2+1]=7,c++,t[7]++;for(;c<=287;)Xa[c*2+1]=8,c++,t[8]++;for(Nj(Xa,k4+1,t),c=0;c<Zm;c++)J4[c*2+1]=5,J4[c*2]=Gj(c,5);Zj=new S8(Xa,Z8,F4+1,k4,i2),fj=new S8(J4,Jv,0,Zm,i2),Sj=new S8(new Array(0),QLr,0,A8,OLr)}function Wj(c){var e;for(e=0;e<k4;e++)c.dyn_ltree[e*2]=0;for(e=0;e<Zm;e++)c.dyn_dtree[e*2]=0;for(e=0;e<A8;e++)c.bl_tree[e*2]=0;c.dyn_ltree[B8*2]=1,c.opt_len=c.static_len=0,c.last_lit=c.matches=0}function Tj(c){c.bi_valid>8?K4(c,c.bi_buf):c.bi_valid>0&&(c.pending_buf[c.pending++]=c.bi_buf),c.bi_buf=0,c.bi_valid=0}function cIr(c,e,n,h){Tj(c),K4(c,n),K4(c,~n),FLr.arraySet(c.pending_buf,c.window,e,n,c.pending),c.pending+=n}function Xj(c,e,n,h){var i=e*2,t=n*2;return c[i]<c[t]||c[i]===c[t]&&h[e]<=h[n]}function G8(c,e,n){for(var h=c.heap[n],i=n<<1;i<=c.heap_len&&(i<c.heap_len&&Xj(e,c.heap[i+1],c.heap[i],c.depth)&&i++,!Xj(e,h,c.heap[i],c.depth));)c.heap[n]=c.heap[i],n=i,i<<=1;c.heap[n]=h}function Yj(c,e,n){var h,i,t=0,s,a;if(c.last_lit!==0)do h=c.pending_buf[c.d_buf+t*2]<<8|c.pending_buf[c.d_buf+t*2+1],i=c.pending_buf[c.l_buf+t],t++,h===0?Ys(c,i,e):(s=H4[i],Ys(c,s+F4+1,e),a=Z8[s],a!==0&&(i-=f8[s],L1(c,i,a)),h--,s=Mj(h),Ys(c,s,n),a=Jv[s],a!==0&&(h-=jv[s],L1(c,h,a)));while(t<c.last_lit);Ys(c,B8,e)}function N8(c,e){var n=e.dyn_tree,h=e.stat_desc.static_tree,i=e.stat_desc.has_stree,t=e.stat_desc.elems,s,a,o=-1,l;for(c.heap_len=0,c.heap_max=gj,s=0;s<t;s++)n[s*2]!==0?(c.heap[++c.heap_len]=o=s,c.depth[s]=0):n[s*2+1]=0;for(;c.heap_len<2;)l=c.heap[++c.heap_len]=o<2?++o:0,n[l*2]=1,c.depth[l]=0,c.opt_len--,i&&(c.static_len-=h[l*2+1]);for(e.max_code=o,s=c.heap_len>>1;s>=1;s--)G8(c,n,s);l=t;do s=c.heap[1],c.heap[1]=c.heap[c.heap_len--],G8(c,n,1),a=c.heap[1],c.heap[--c.heap_max]=s,c.heap[--c.heap_max]=a,n[l*2]=n[s*2]+n[a*2],c.depth[l]=(c.depth[s]>=c.depth[a]?c.depth[s]:c.depth[a])+1,n[s*2+1]=n[a*2+1]=l,c.heap[1]=l++,G8(c,n,1);while(c.heap_len>=2);c.heap[--c.heap_max]=c.heap[1],rIr(c,e),Nj(n,o,c.bl_count)}function wj(c,e,n){var h,i=-1,t,s=e[0*2+1],a=0,o=7,l=4;for(s===0&&(o=138,l=3),e[(n+1)*2+1]=65535,h=0;h<=n;h++)t=s,s=e[(h+1)*2+1],!(++a<o&&t===s)&&(a<l?c.bl_tree[t*2]+=a:t!==0?(t!==i&&c.bl_tree[t*2]++,c.bl_tree[_j*2]++):a<=10?c.bl_tree[Aj*2]++:c.bl_tree[yj*2]++,a=0,i=t,s===0?(o=138,l=3):t===s?(o=6,l=3):(o=7,l=4))}function Ej(c,e,n){var h,i=-1,t,s=e[0*2+1],a=0,o=7,l=4;for(s===0&&(o=138,l=3),h=0;h<=n;h++)if(t=s,s=e[(h+1)*2+1],!(++a<o&&t===s)){if(a<l)do Ys(c,t,c.bl_tree);while(--a!==0);else t!==0?(t!==i&&(Ys(c,t,c.bl_tree),a--),Ys(c,_j,c.bl_tree),L1(c,a-3,2)):a<=10?(Ys(c,Aj,c.bl_tree),L1(c,a-3,3)):(Ys(c,yj,c.bl_tree),L1(c,a-11,7));a=0,i=t,s===0?(o=138,l=3):t===s?(o=6,l=3):(o=7,l=4)}}function nIr(c){var e;for(wj(c,c.dyn_ltree,c.l_desc.max_code),wj(c,c.dyn_dtree,c.d_desc.max_code),N8(c,c.bl_desc),e=A8-1;e>=3&&c.bl_tree[Bj[e]*2+1]===0;e--);return c.opt_len+=3*(e+1)+5+5+4,e}function hIr(c,e,n,h){var i;for(L1(c,e-257,5),L1(c,n-1,5),L1(c,h-4,4),i=0;i<h;i++)L1(c,c.bl_tree[Bj[i]*2+1],3);Ej(c,c.dyn_ltree,e-1),Ej(c,c.dyn_dtree,n-1)}function iIr(c){var e=4093624447,n;for(n=0;n<=31;n++,e>>>=1)if(e&1&&c.dyn_ltree[n*2]!==0)return pj;if(c.dyn_ltree[9*2]!==0||c.dyn_ltree[10*2]!==0||c.dyn_ltree[13*2]!==0)return Dj;for(n=32;n<F4;n++)if(c.dyn_ltree[n*2]!==0)return Dj;return pj}var xj=!1;function tIr(c){xj||(eIr(),xj=!0),c.l_desc=new M8(c.dyn_ltree,Zj),c.d_desc=new M8(c.dyn_dtree,fj),c.bl_desc=new M8(c.bl_tree,Sj),c.bi_buf=0,c.bi_valid=0,Wj(c)}function Rj(c,e,n,h){L1(c,(jLr<<1)+(h?1:0),3),cIr(c,e,n)}function sIr(c){L1(c,bj<<1,3),Ys(c,B8,Xa),$Lr(c)}function aIr(c,e,n,h){var i,t,s=0;c.level>0?(c.strm.data_type===JLr&&(c.strm.data_type=iIr(c)),N8(c,c.l_desc),N8(c,c.d_desc),s=nIr(c),i=c.opt_len+3+7>>>3,t=c.static_len+3+7>>>3,t<=i&&(i=t)):i=t=n+5,n+4<=i&&e!==-1?Rj(c,e,n,h):c.strategy===kLr||t===i?(L1(c,(bj<<1)+(h?1:0),3),Yj(c,Xa,J4)):(L1(c,(HLr<<1)+(h?1:0),3),hIr(c,c.l_desc.max_code+1,c.d_desc.max_code+1,s+1),Yj(c,c.dyn_ltree,c.dyn_dtree)),Wj(c),h&&Tj(c)}function oIr(c,e,n){return c.pending_buf[c.d_buf+c.last_lit*2]=e>>>8&255,c.pending_buf[c.d_buf+c.last_lit*2+1]=e&255,c.pending_buf[c.l_buf+c.last_lit]=n&255,c.last_lit++,e===0?c.dyn_ltree[n*2]++:(c.matches++,e--,c.dyn_ltree[(H4[n]+F4+1)*2]++,c.dyn_dtree[Mj(e)*2]++),c.last_lit===c.lit_bufsize-1}ym._tr_init=tIr,ym._tr_stored_block=Rj,ym._tr_flush_block=aIr,ym._tr_tally=oIr,ym._tr_align=sIr;function lIr(c,e,n,h){for(var i=c&65535|0,t=c>>>16&65535|0,s=0;n!==0;){s=n>2e3?2e3:n,n-=s;do i=i+e[h++]|0,t=t+i|0;while(--s);i%=65521,t%=65521}return i|t<<16|0}var Lj=lIr;function mIr(){for(var c,e=[],n=0;n<256;n++){c=n;for(var h=0;h<8;h++)c=c&1?3988292384^c>>>1:c>>>1;e[n]=c}return e}var dIr=mIr();function uIr(c,e,n,h){var i=dIr,t=h+n;c^=-1;for(var s=h;s<t;s++)c=c>>>8^i[(c^e[s])&255];return c^-1}var Ij=uIr,W8={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},g1=Ta,Hi=ym,Vj=Lj,M3=Ij,UIr=W8,t2=0,zIr=1,vIr=3,G3=4,Fj=5,ws=0,kj=1,Ki=-2,CIr=-3,T8=-5,pIr=-1,DIr=1,Hv=2,bIr=3,gIr=4,_Ir=0,AIr=2,Kv=8,yIr=9,BIr=15,ZIr=8,fIr=29,SIr=256,X8=SIr+1+fIr,MIr=30,GIr=19,NIr=2*X8+1,WIr=15,gc=3,N3=258,Jt=N3+gc+1,TIr=32,Pv=42,Y8=69,Ov=73,Qv=91,qv=103,s2=113,P4=666,vh=1,O4=2,a2=3,fm=4,XIr=3;function W3(c,e){return c.msg=UIr[e],e}function Jj(c){return(c<<1)-(c>4?9:0)}function T3(c){for(var e=c.length;--e>=0;)c[e]=0}function X3(c){var e=c.state,n=e.pending;n>c.avail_out&&(n=c.avail_out),n!==0&&(g1.arraySet(c.output,e.pending_buf,e.pending_out,n,c.next_out),c.next_out+=n,e.pending_out+=n,c.total_out+=n,c.avail_out-=n,e.pending-=n,e.pending===0&&(e.pending_out=0))}function Vh(c,e){Hi._tr_flush_block(c,c.block_start>=0?c.block_start:-1,c.strstart-c.block_start,e),c.block_start=c.strstart,X3(c.strm)}function Xc(c,e){c.pending_buf[c.pending++]=e}function Q4(c,e){c.pending_buf[c.pending++]=e>>>8&255,c.pending_buf[c.pending++]=e&255}function YIr(c,e,n,h){var i=c.avail_in;return i>h&&(i=h),i===0?0:(c.avail_in-=i,g1.arraySet(e,c.input,c.next_in,i,n),c.state.wrap===1?c.adler=Vj(c.adler,e,i,n):c.state.wrap===2&&(c.adler=M3(c.adler,e,i,n)),c.next_in+=i,c.total_in+=i,i)}function jj(c,e){var n=c.max_chain_length,h=c.strstart,i,t,s=c.prev_length,a=c.nice_match,o=c.strstart>c.w_size-Jt?c.strstart-(c.w_size-Jt):0,l=c.window,m=c.w_mask,d=c.prev,u=c.strstart+N3,U=l[h+s-1],C=l[h+s];c.prev_length>=c.good_match&&(n>>=2),a>c.lookahead&&(a=c.lookahead);do if(i=e,!(l[i+s]!==C||l[i+s-1]!==U||l[i]!==l[h]||l[++i]!==l[h+1])){h+=2,i++;do;while(l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&l[++h]===l[++i]&&h<u);if(t=N3-(u-h),h=u-N3,t>s){if(c.match_start=e,s=t,t>=a)break;U=l[h+s-1],C=l[h+s]}}while((e=d[e&m])>o&&--n!==0);return s<=c.lookahead?s:c.lookahead}function o2(c){var e=c.w_size,n,h,i,t,s;do{if(t=c.window_size-c.lookahead-c.strstart,c.strstart>=e+(e-Jt)){g1.arraySet(c.window,c.window,e,e,0),c.match_start-=e,c.strstart-=e,c.block_start-=e,h=c.hash_size,n=h;do i=c.head[--n],c.head[n]=i>=e?i-e:0;while(--h);h=e,n=h;do i=c.prev[--n],c.prev[n]=i>=e?i-e:0;while(--h);t+=e}if(c.strm.avail_in===0)break;if(h=YIr(c.strm,c.window,c.strstart+c.lookahead,t),c.lookahead+=h,c.lookahead+c.insert>=gc)for(s=c.strstart-c.insert,c.ins_h=c.window[s],c.ins_h=(c.ins_h<<c.hash_shift^c.window[s+1])&c.hash_mask;c.insert&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[s+gc-1])&c.hash_mask,c.prev[s&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=s,s++,c.insert--,!(c.lookahead+c.insert<gc)););}while(c.lookahead<Jt&&c.strm.avail_in!==0)}function wIr(c,e){var n=65535;for(n>c.pending_buf_size-5&&(n=c.pending_buf_size-5);;){if(c.lookahead<=1){if(o2(c),c.lookahead===0&&e===t2)return vh;if(c.lookahead===0)break}c.strstart+=c.lookahead,c.lookahead=0;var h=c.block_start+n;if((c.strstart===0||c.strstart>=h)&&(c.lookahead=c.strstart-h,c.strstart=h,Vh(c,!1),c.strm.avail_out===0)||c.strstart-c.block_start>=c.w_size-Jt&&(Vh(c,!1),c.strm.avail_out===0))return vh}return c.insert=0,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):(c.strstart>c.block_start&&(Vh(c,!1),c.strm.avail_out===0),vh)}function w8(c,e){for(var n,h;;){if(c.lookahead<Jt){if(o2(c),c.lookahead<Jt&&e===t2)return vh;if(c.lookahead===0)break}if(n=0,c.lookahead>=gc&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+gc-1])&c.hash_mask,n=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),n!==0&&c.strstart-n<=c.w_size-Jt&&(c.match_length=jj(c,n)),c.match_length>=gc)if(h=Hi._tr_tally(c,c.strstart-c.match_start,c.match_length-gc),c.lookahead-=c.match_length,c.match_length<=c.max_lazy_match&&c.lookahead>=gc){c.match_length--;do c.strstart++,c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+gc-1])&c.hash_mask,n=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart;while(--c.match_length!==0);c.strstart++}else c.strstart+=c.match_length,c.match_length=0,c.ins_h=c.window[c.strstart],c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+1])&c.hash_mask;else h=Hi._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++;if(h&&(Vh(c,!1),c.strm.avail_out===0))return vh}return c.insert=c.strstart<gc-1?c.strstart:gc-1,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):c.last_lit&&(Vh(c,!1),c.strm.avail_out===0)?vh:O4}function Sm(c,e){for(var n,h,i;;){if(c.lookahead<Jt){if(o2(c),c.lookahead<Jt&&e===t2)return vh;if(c.lookahead===0)break}if(n=0,c.lookahead>=gc&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+gc-1])&c.hash_mask,n=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),c.prev_length=c.match_length,c.prev_match=c.match_start,c.match_length=gc-1,n!==0&&c.prev_length<c.max_lazy_match&&c.strstart-n<=c.w_size-Jt&&(c.match_length=jj(c,n),c.match_length<=5&&(c.strategy===DIr||c.match_length===gc&&c.strstart-c.match_start>4096)&&(c.match_length=gc-1)),c.prev_length>=gc&&c.match_length<=c.prev_length){i=c.strstart+c.lookahead-gc,h=Hi._tr_tally(c,c.strstart-1-c.prev_match,c.prev_length-gc),c.lookahead-=c.prev_length-1,c.prev_length-=2;do++c.strstart<=i&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+gc-1])&c.hash_mask,n=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart);while(--c.prev_length!==0);if(c.match_available=0,c.match_length=gc-1,c.strstart++,h&&(Vh(c,!1),c.strm.avail_out===0))return vh}else if(c.match_available){if(h=Hi._tr_tally(c,0,c.window[c.strstart-1]),h&&Vh(c,!1),c.strstart++,c.lookahead--,c.strm.avail_out===0)return vh}else c.match_available=1,c.strstart++,c.lookahead--}return c.match_available&&(h=Hi._tr_tally(c,0,c.window[c.strstart-1]),c.match_available=0),c.insert=c.strstart<gc-1?c.strstart:gc-1,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):c.last_lit&&(Vh(c,!1),c.strm.avail_out===0)?vh:O4}function EIr(c,e){for(var n,h,i,t,s=c.window;;){if(c.lookahead<=N3){if(o2(c),c.lookahead<=N3&&e===t2)return vh;if(c.lookahead===0)break}if(c.match_length=0,c.lookahead>=gc&&c.strstart>0&&(i=c.strstart-1,h=s[i],h===s[++i]&&h===s[++i]&&h===s[++i])){t=c.strstart+N3;do;while(h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&h===s[++i]&&i<t);c.match_length=N3-(t-i),c.match_length>c.lookahead&&(c.match_length=c.lookahead)}if(c.match_length>=gc?(n=Hi._tr_tally(c,1,c.match_length-gc),c.lookahead-=c.match_length,c.strstart+=c.match_length,c.match_length=0):(n=Hi._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++),n&&(Vh(c,!1),c.strm.avail_out===0))return vh}return c.insert=0,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):c.last_lit&&(Vh(c,!1),c.strm.avail_out===0)?vh:O4}function xIr(c,e){for(var n;;){if(c.lookahead===0&&(o2(c),c.lookahead===0)){if(e===t2)return vh;break}if(c.match_length=0,n=Hi._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++,n&&(Vh(c,!1),c.strm.avail_out===0))return vh}return c.insert=0,e===G3?(Vh(c,!0),c.strm.avail_out===0?a2:fm):c.last_lit&&(Vh(c,!1),c.strm.avail_out===0)?vh:O4}function Es(c,e,n,h,i){this.good_length=c,this.max_lazy=e,this.nice_length=n,this.max_chain=h,this.func=i}var Mm;Mm=[new Es(0,0,0,0,wIr),new Es(4,4,8,4,w8),new Es(4,5,16,8,w8),new Es(4,6,32,32,w8),new Es(4,4,16,16,Sm),new Es(8,16,32,32,Sm),new Es(8,16,128,128,Sm),new Es(8,32,128,256,Sm),new Es(32,128,258,1024,Sm),new Es(32,258,258,4096,Sm)];function RIr(c){c.window_size=2*c.w_size,T3(c.head),c.max_lazy_match=Mm[c.level].max_lazy,c.good_match=Mm[c.level].good_length,c.nice_match=Mm[c.level].nice_length,c.max_chain_length=Mm[c.level].max_chain,c.strstart=0,c.block_start=0,c.lookahead=0,c.insert=0,c.match_length=c.prev_length=gc-1,c.match_available=0,c.ins_h=0}function LIr(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Kv,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new g1.Buf16(NIr*2),this.dyn_dtree=new g1.Buf16((2*MIr+1)*2),this.bl_tree=new g1.Buf16((2*GIr+1)*2),T3(this.dyn_ltree),T3(this.dyn_dtree),T3(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new g1.Buf16(WIr+1),this.heap=new g1.Buf16(2*X8+1),T3(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new g1.Buf16(2*X8+1),T3(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Hj(c){var e;return!c||!c.state?W3(c,Ki):(c.total_in=c.total_out=0,c.data_type=AIr,e=c.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?Pv:s2,c.adler=e.wrap===2?0:1,e.last_flush=t2,Hi._tr_init(e),ws)}function Kj(c){var e=Hj(c);return e===ws&&RIr(c.state),e}function IIr(c,e){return!c||!c.state||c.state.wrap!==2?Ki:(c.state.gzhead=e,ws)}function Pj(c,e,n,h,i,t){if(!c)return Ki;var s=1;if(e===pIr&&(e=6),h<0?(s=0,h=-h):h>15&&(s=2,h-=16),i<1||i>yIr||n!==Kv||h<8||h>15||e<0||e>9||t<0||t>gIr)return W3(c,Ki);h===8&&(h=9);var a=new LIr;return c.state=a,a.strm=c,a.wrap=s,a.gzhead=null,a.w_bits=h,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+gc-1)/gc),a.window=new g1.Buf8(a.w_size*2),a.head=new g1.Buf16(a.hash_size),a.prev=new g1.Buf16(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new g1.Buf8(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=t,a.method=n,Kj(c)}function VIr(c,e){return Pj(c,e,Kv,BIr,ZIr,_Ir)}function FIr(c,e){var n,h,i,t;if(!c||!c.state||e>Fj||e<0)return c?W3(c,Ki):Ki;if(h=c.state,!c.output||!c.input&&c.avail_in!==0||h.status===P4&&e!==G3)return W3(c,c.avail_out===0?T8:Ki);if(h.strm=c,n=h.last_flush,h.last_flush=e,h.status===Pv)if(h.wrap===2)c.adler=0,Xc(h,31),Xc(h,139),Xc(h,8),h.gzhead?(Xc(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),Xc(h,h.gzhead.time&255),Xc(h,h.gzhead.time>>8&255),Xc(h,h.gzhead.time>>16&255),Xc(h,h.gzhead.time>>24&255),Xc(h,h.level===9?2:h.strategy>=Hv||h.level<2?4:0),Xc(h,h.gzhead.os&255),h.gzhead.extra&&h.gzhead.extra.length&&(Xc(h,h.gzhead.extra.length&255),Xc(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(c.adler=M3(c.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=Y8):(Xc(h,0),Xc(h,0),Xc(h,0),Xc(h,0),Xc(h,0),Xc(h,h.level===9?2:h.strategy>=Hv||h.level<2?4:0),Xc(h,XIr),h.status=s2);else{var s=Kv+(h.w_bits-8<<4)<<8,a=-1;h.strategy>=Hv||h.level<2?a=0:h.level<6?a=1:h.level===6?a=2:a=3,s|=a<<6,h.strstart!==0&&(s|=TIr),s+=31-s%31,h.status=s2,Q4(h,s),h.strstart!==0&&(Q4(h,c.adler>>>16),Q4(h,c.adler&65535)),c.adler=1}if(h.status===Y8)if(h.gzhead.extra){for(i=h.pending;h.gzindex<(h.gzhead.extra.length&65535)&&!(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),X3(c),i=h.pending,h.pending===h.pending_buf_size));)Xc(h,h.gzhead.extra[h.gzindex]&255),h.gzindex++;h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=Ov)}else h.status=Ov;if(h.status===Ov)if(h.gzhead.name){i=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),X3(c),i=h.pending,h.pending===h.pending_buf_size)){t=1;break}h.gzindex<h.gzhead.name.length?t=h.gzhead.name.charCodeAt(h.gzindex++)&255:t=0,Xc(h,t)}while(t!==0);h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),t===0&&(h.gzindex=0,h.status=Qv)}else h.status=Qv;if(h.status===Qv)if(h.gzhead.comment){i=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),X3(c),i=h.pending,h.pending===h.pending_buf_size)){t=1;break}h.gzindex<h.gzhead.comment.length?t=h.gzhead.comment.charCodeAt(h.gzindex++)&255:t=0,Xc(h,t)}while(t!==0);h.gzhead.hcrc&&h.pending>i&&(c.adler=M3(c.adler,h.pending_buf,h.pending-i,i)),t===0&&(h.status=qv)}else h.status=qv;if(h.status===qv&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&X3(c),h.pending+2<=h.pending_buf_size&&(Xc(h,c.adler&255),Xc(h,c.adler>>8&255),c.adler=0,h.status=s2)):h.status=s2),h.pending!==0){if(X3(c),c.avail_out===0)return h.last_flush=-1,ws}else if(c.avail_in===0&&Jj(e)<=Jj(n)&&e!==G3)return W3(c,T8);if(h.status===P4&&c.avail_in!==0)return W3(c,T8);if(c.avail_in!==0||h.lookahead!==0||e!==t2&&h.status!==P4){var o=h.strategy===Hv?xIr(h,e):h.strategy===bIr?EIr(h,e):Mm[h.level].func(h,e);if((o===a2||o===fm)&&(h.status=P4),o===vh||o===a2)return c.avail_out===0&&(h.last_flush=-1),ws;if(o===O4&&(e===zIr?Hi._tr_align(h):e!==Fj&&(Hi._tr_stored_block(h,0,0,!1),e===vIr&&(T3(h.head),h.lookahead===0&&(h.strstart=0,h.block_start=0,h.insert=0))),X3(c),c.avail_out===0))return h.last_flush=-1,ws}return e!==G3?ws:h.wrap<=0?kj:(h.wrap===2?(Xc(h,c.adler&255),Xc(h,c.adler>>8&255),Xc(h,c.adler>>16&255),Xc(h,c.adler>>24&255),Xc(h,c.total_in&255),Xc(h,c.total_in>>8&255),Xc(h,c.total_in>>16&255),Xc(h,c.total_in>>24&255)):(Q4(h,c.adler>>>16),Q4(h,c.adler&65535)),X3(c),h.wrap>0&&(h.wrap=-h.wrap),h.pending!==0?ws:kj)}function kIr(c){var e;return!c||!c.state?Ki:(e=c.state.status,e!==Pv&&e!==Y8&&e!==Ov&&e!==Qv&&e!==qv&&e!==s2&&e!==P4?W3(c,Ki):(c.state=null,e===s2?W3(c,CIr):ws))}function JIr(c,e){var n=e.length,h,i,t,s,a,o,l,m;if(!c||!c.state||(h=c.state,s=h.wrap,s===2||s===1&&h.status!==Pv||h.lookahead))return Ki;for(s===1&&(c.adler=Vj(c.adler,e,n,0)),h.wrap=0,n>=h.w_size&&(s===0&&(T3(h.head),h.strstart=0,h.block_start=0,h.insert=0),m=new g1.Buf8(h.w_size),g1.arraySet(m,e,n-h.w_size,h.w_size,0),e=m,n=h.w_size),a=c.avail_in,o=c.next_in,l=c.input,c.avail_in=n,c.next_in=0,c.input=e,o2(h);h.lookahead>=gc;){i=h.strstart,t=h.lookahead-(gc-1);do h.ins_h=(h.ins_h<<h.hash_shift^h.window[i+gc-1])&h.hash_mask,h.prev[i&h.w_mask]=h.head[h.ins_h],h.head[h.ins_h]=i,i++;while(--t);h.strstart=i,h.lookahead=gc-1,o2(h)}return h.strstart+=h.lookahead,h.block_start=h.strstart,h.insert=h.lookahead,h.lookahead=0,h.match_length=h.prev_length=gc-1,h.match_available=0,c.next_in=o,c.input=l,c.avail_in=a,h.wrap=s,ws}Xs.deflateInit=VIr,Xs.deflateInit2=Pj,Xs.deflateReset=Kj,Xs.deflateResetKeep=Hj,Xs.deflateSetHeader=IIr,Xs.deflate=FIr,Xs.deflateEnd=kIr,Xs.deflateSetDictionary=JIr,Xs.deflateInfo="pako deflate (from Nodeca project)";var l2={},$v=Ta,Oj=!0,Qj=!0;try{String.fromCharCode.apply(null,[0])}catch{Oj=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Qj=!1}for(var q4=new $v.Buf8(256),Y3=0;Y3<256;Y3++)q4[Y3]=Y3>=252?6:Y3>=248?5:Y3>=240?4:Y3>=224?3:Y3>=192?2:1;q4[254]=q4[254]=1,l2.string2buf=function(c){var e,n,h,i,t,s=c.length,a=0;for(i=0;i<s;i++)n=c.charCodeAt(i),(n&64512)===55296&&i+1<s&&(h=c.charCodeAt(i+1),(h&64512)===56320&&(n=65536+(n-55296<<10)+(h-56320),i++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new $v.Buf8(a),t=0,i=0;t<a;i++)n=c.charCodeAt(i),(n&64512)===55296&&i+1<s&&(h=c.charCodeAt(i+1),(h&64512)===56320&&(n=65536+(n-55296<<10)+(h-56320),i++)),n<128?e[t++]=n:n<2048?(e[t++]=192|n>>>6,e[t++]=128|n&63):n<65536?(e[t++]=224|n>>>12,e[t++]=128|n>>>6&63,e[t++]=128|n&63):(e[t++]=240|n>>>18,e[t++]=128|n>>>12&63,e[t++]=128|n>>>6&63,e[t++]=128|n&63);return e};function qj(c,e){if(e<65534&&(c.subarray&&Qj||!c.subarray&&Oj))return String.fromCharCode.apply(null,$v.shrinkBuf(c,e));for(var n="",h=0;h<e;h++)n+=String.fromCharCode(c[h]);return n}l2.buf2binstring=function(c){return qj(c,c.length)},l2.binstring2buf=function(c){for(var e=new $v.Buf8(c.length),n=0,h=e.length;n<h;n++)e[n]=c.charCodeAt(n);return e},l2.buf2string=function(c,e){var n,h,i,t,s=e||c.length,a=new Array(s*2);for(h=0,n=0;n<s;){if(i=c[n++],i<128){a[h++]=i;continue}if(t=q4[i],t>4){a[h++]=65533,n+=t-1;continue}for(i&=t===2?31:t===3?15:7;t>1&&n<s;)i=i<<6|c[n++]&63,t--;if(t>1){a[h++]=65533;continue}i<65536?a[h++]=i:(i-=65536,a[h++]=55296|i>>10&1023,a[h++]=56320|i&1023)}return qj(a,h)},l2.utf8border=function(c,e){var n;for(e=e||c.length,e>c.length&&(e=c.length),n=e-1;n>=0&&(c[n]&192)===128;)n--;return n<0||n===0?e:n+q4[c[n]]>e?n:e};function jIr(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var $j=jIr,$4=Xs,r9=Ta,E8=l2,x8=W8,HIr=$j,rH=Object.prototype.toString,KIr=0,R8=4,Gm=0,eH=1,cH=2,PIr=-1,OIr=0,QIr=8;function m2(c){if(!(this instanceof m2))return new m2(c);this.options=r9.assign({level:PIr,method:QIr,chunkSize:16384,windowBits:15,memLevel:8,strategy:OIr,to:""},c||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new HIr,this.strm.avail_out=0;var n=$4.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==Gm)throw new Error(x8[n]);if(e.header&&$4.deflateSetHeader(this.strm,e.header),e.dictionary){var h;if(typeof e.dictionary=="string"?h=E8.string2buf(e.dictionary):rH.call(e.dictionary)==="[object ArrayBuffer]"?h=new Uint8Array(e.dictionary):h=e.dictionary,n=$4.deflateSetDictionary(this.strm,h),n!==Gm)throw new Error(x8[n]);this._dict_set=!0}}m2.prototype.push=function(c,e){var n=this.strm,h=this.options.chunkSize,i,t;if(this.ended)return!1;t=e===~~e?e:e===!0?R8:KIr,typeof c=="string"?n.input=E8.string2buf(c):rH.call(c)==="[object ArrayBuffer]"?n.input=new Uint8Array(c):n.input=c,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new r9.Buf8(h),n.next_out=0,n.avail_out=h),i=$4.deflate(n,t),i!==eH&&i!==Gm)return this.onEnd(i),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(t===R8||t===cH))&&(this.options.to==="string"?this.onData(E8.buf2binstring(r9.shrinkBuf(n.output,n.next_out))):this.onData(r9.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&i!==eH);return t===R8?(i=$4.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Gm):(t===cH&&(this.onEnd(Gm),n.avail_out=0),!0)},m2.prototype.onData=function(c){this.chunks.push(c)},m2.prototype.onEnd=function(c){c===Gm&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r9.flattenChunks(this.chunks)),this.chunks=[],this.err=c,this.msg=this.strm.msg};function L8(c,e){var n=new m2(e);if(n.push(c,!0),n.err)throw n.msg||x8[n.err];return n.result}function qIr(c,e){return e=e||{},e.raw=!0,L8(c,e)}function $Ir(c,e){return e=e||{},e.gzip=!0,L8(c,e)}V4.Deflate=m2,V4.deflate=L8,V4.deflateRaw=qIr,V4.gzip=$Ir;var e9={},jt={},r6=30,rVr=12,eVr=function(e,n){var h,i,t,s,a,o,l,m,d,u,U,C,p,D,A,f,M,S,N,x,B,W,T,L,I;h=e.state,i=e.next_in,L=e.input,t=i+(e.avail_in-5),s=e.next_out,I=e.output,a=s-(n-e.avail_out),o=s+(e.avail_out-257),l=h.dmax,m=h.wsize,d=h.whave,u=h.wnext,U=h.window,C=h.hold,p=h.bits,D=h.lencode,A=h.distcode,f=(1<<h.lenbits)-1,M=(1<<h.distbits)-1;r:do{p<15&&(C+=L[i++]<<p,p+=8,C+=L[i++]<<p,p+=8),S=D[C&f];e:for(;;){if(N=S>>>24,C>>>=N,p-=N,N=S>>>16&255,N===0)I[s++]=S&65535;else if(N&16){x=S&65535,N&=15,N&&(p<N&&(C+=L[i++]<<p,p+=8),x+=C&(1<<N)-1,C>>>=N,p-=N),p<15&&(C+=L[i++]<<p,p+=8,C+=L[i++]<<p,p+=8),S=A[C&M];c:for(;;){if(N=S>>>24,C>>>=N,p-=N,N=S>>>16&255,N&16){if(B=S&65535,N&=15,p<N&&(C+=L[i++]<<p,p+=8,p<N&&(C+=L[i++]<<p,p+=8)),B+=C&(1<<N)-1,B>l){e.msg="invalid distance too far back",h.mode=r6;break r}if(C>>>=N,p-=N,N=s-a,B>N){if(N=B-N,N>d&&h.sane){e.msg="invalid distance too far back",h.mode=r6;break r}if(W=0,T=U,u===0){if(W+=m-N,N<x){x-=N;do I[s++]=U[W++];while(--N);W=s-B,T=I}}else if(u<N){if(W+=m+u-N,N-=u,N<x){x-=N;do I[s++]=U[W++];while(--N);if(W=0,u<x){N=u,x-=N;do I[s++]=U[W++];while(--N);W=s-B,T=I}}}else if(W+=u-N,N<x){x-=N;do I[s++]=U[W++];while(--N);W=s-B,T=I}for(;x>2;)I[s++]=T[W++],I[s++]=T[W++],I[s++]=T[W++],x-=3;x&&(I[s++]=T[W++],x>1&&(I[s++]=T[W++]))}else{W=s-B;do I[s++]=I[W++],I[s++]=I[W++],I[s++]=I[W++],x-=3;while(x>2);x&&(I[s++]=I[W++],x>1&&(I[s++]=I[W++]))}}else if(N&64){e.msg="invalid distance code",h.mode=r6;break r}else{S=A[(S&65535)+(C&(1<<N)-1)];continue c}break}}else if(N&64)if(N&32){h.mode=rVr;break r}else{e.msg="invalid literal/length code",h.mode=r6;break r}else{S=D[(S&65535)+(C&(1<<N)-1)];continue e}break}}while(i<t&&s<o);x=p>>3,i-=x,p-=x<<3,C&=(1<<p)-1,e.next_in=i,e.next_out=s,e.avail_in=i<t?5+(t-i):5-(i-t),e.avail_out=s<o?257+(o-s):257-(s-o),h.hold=C,h.bits=p},nH=Ta,Nm=15,hH=852,iH=592,tH=0,I8=1,sH=2,cVr=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],nVr=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],hVr=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],iVr=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],tVr=function(e,n,h,i,t,s,a,o){var l=o.bits,m=0,d=0,u=0,U=0,C=0,p=0,D=0,A=0,f=0,M=0,S,N,x,B,W,T=null,L=0,I,J=new nH.Buf16(Nm+1),$=new nH.Buf16(Nm+1),sr=null,vr=0,pr,dr,zr;for(m=0;m<=Nm;m++)J[m]=0;for(d=0;d<i;d++)J[n[h+d]]++;for(C=l,U=Nm;U>=1&&J[U]===0;U--);if(C>U&&(C=U),U===0)return t[s++]=1<<24|64<<16|0,t[s++]=1<<24|64<<16|0,o.bits=1,0;for(u=1;u<U&&J[u]===0;u++);for(C<u&&(C=u),A=1,m=1;m<=Nm;m++)if(A<<=1,A-=J[m],A<0)return-1;if(A>0&&(e===tH||U!==1))return-1;for($[1]=0,m=1;m<Nm;m++)$[m+1]=$[m]+J[m];for(d=0;d<i;d++)n[h+d]!==0&&(a[$[n[h+d]]++]=d);if(e===tH?(T=sr=a,I=19):e===I8?(T=cVr,L-=257,sr=nVr,vr-=257,I=256):(T=hVr,sr=iVr,I=-1),M=0,d=0,m=u,W=s,p=C,D=0,x=-1,f=1<<C,B=f-1,e===I8&&f>hH||e===sH&&f>iH)return 1;for(;;){pr=m-D,a[d]<I?(dr=0,zr=a[d]):a[d]>I?(dr=sr[vr+a[d]],zr=T[L+a[d]]):(dr=96,zr=0),S=1<<m-D,N=1<<p,u=N;do N-=S,t[W+(M>>D)+N]=pr<<24|dr<<16|zr|0;while(N!==0);for(S=1<<m-1;M&S;)S>>=1;if(S!==0?(M&=S-1,M+=S):M=0,d++,--J[m]===0){if(m===U)break;m=n[h+a[d]]}if(m>C&&(M&B)!==x){for(D===0&&(D=C),W+=u,p=m-D,A=1<<p;p+D<U&&(A-=J[p+D],!(A<=0));)p++,A<<=1;if(f+=1<<p,e===I8&&f>hH||e===sH&&f>iH)return 1;x=M&B,t[x]=C<<24|p<<16|W-s|0}}return M!==0&&(t[W+M]=m-D<<24|64<<16|0),o.bits=C,0},Ui=Ta,V8=Lj,xs=Ij,sVr=eVr,c9=tVr,aVr=0,aH=1,oH=2,lH=4,oVr=5,e6=6,d2=0,lVr=1,mVr=2,Pi=-2,mH=-3,dH=-4,dVr=-5,uH=8,UH=1,zH=2,vH=3,CH=4,pH=5,DH=6,bH=7,gH=8,_H=9,AH=10,c6=11,Ya=12,F8=13,yH=14,k8=15,BH=16,ZH=17,fH=18,SH=19,n6=20,h6=21,MH=22,GH=23,NH=24,WH=25,TH=26,J8=27,XH=28,YH=29,Dn=30,wH=31,uVr=32,UVr=852,zVr=592,vVr=15,CVr=vVr;function EH(c){return(c>>>24&255)+(c>>>8&65280)+((c&65280)<<8)+((c&255)<<24)}function pVr(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Ui.Buf16(320),this.work=new Ui.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function xH(c){var e;return!c||!c.state?Pi:(e=c.state,c.total_in=c.total_out=e.total=0,c.msg="",e.wrap&&(c.adler=e.wrap&1),e.mode=UH,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Ui.Buf32(UVr),e.distcode=e.distdyn=new Ui.Buf32(zVr),e.sane=1,e.back=-1,d2)}function RH(c){var e;return!c||!c.state?Pi:(e=c.state,e.wsize=0,e.whave=0,e.wnext=0,xH(c))}function LH(c,e){var n,h;return!c||!c.state||(h=c.state,e<0?(n=0,e=-e):(n=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?Pi:(h.window!==null&&h.wbits!==e&&(h.window=null),h.wrap=n,h.wbits=e,RH(c))}function IH(c,e){var n,h;return c?(h=new pVr,c.state=h,h.window=null,n=LH(c,e),n!==d2&&(c.state=null),n):Pi}function DVr(c){return IH(c,CVr)}var VH=!0,j8,H8;function bVr(c){if(VH){var e;for(j8=new Ui.Buf32(512),H8=new Ui.Buf32(32),e=0;e<144;)c.lens[e++]=8;for(;e<256;)c.lens[e++]=9;for(;e<280;)c.lens[e++]=7;for(;e<288;)c.lens[e++]=8;for(c9(aH,c.lens,0,288,j8,0,c.work,{bits:9}),e=0;e<32;)c.lens[e++]=5;c9(oH,c.lens,0,32,H8,0,c.work,{bits:5}),VH=!1}c.lencode=j8,c.lenbits=9,c.distcode=H8,c.distbits=5}function FH(c,e,n,h){var i,t=c.state;return t.window===null&&(t.wsize=1<<t.wbits,t.wnext=0,t.whave=0,t.window=new Ui.Buf8(t.wsize)),h>=t.wsize?(Ui.arraySet(t.window,e,n-t.wsize,t.wsize,0),t.wnext=0,t.whave=t.wsize):(i=t.wsize-t.wnext,i>h&&(i=h),Ui.arraySet(t.window,e,n-h,i,t.wnext),h-=i,h?(Ui.arraySet(t.window,e,n-h,h,0),t.wnext=h,t.whave=t.wsize):(t.wnext+=i,t.wnext===t.wsize&&(t.wnext=0),t.whave<t.wsize&&(t.whave+=i))),0}function gVr(c,e){var n,h,i,t,s,a,o,l,m,d,u,U,C,p,D=0,A,f,M,S,N,x,B,W,T=new Ui.Buf8(4),L,I,J=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!c||!c.state||!c.output||!c.input&&c.avail_in!==0)return Pi;n=c.state,n.mode===Ya&&(n.mode=F8),s=c.next_out,i=c.output,o=c.avail_out,t=c.next_in,h=c.input,a=c.avail_in,l=n.hold,m=n.bits,d=a,u=o,W=d2;r:for(;;)switch(n.mode){case UH:if(n.wrap===0){n.mode=F8;break}for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(n.wrap&2&&l===35615){n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=xs(n.check,T,2,0),l=0,m=0,n.mode=zH;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){c.msg="incorrect header check",n.mode=Dn;break}if((l&15)!==uH){c.msg="unknown compression method",n.mode=Dn;break}if(l>>>=4,m-=4,B=(l&15)+8,n.wbits===0)n.wbits=B;else if(B>n.wbits){c.msg="invalid window size",n.mode=Dn;break}n.dmax=1<<B,c.adler=n.check=1,n.mode=l&512?AH:Ya,l=0,m=0;break;case zH:for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(n.flags=l,(n.flags&255)!==uH){c.msg="unknown compression method",n.mode=Dn;break}if(n.flags&57344){c.msg="unknown header flags set",n.mode=Dn;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=xs(n.check,T,2,0)),l=0,m=0,n.mode=vH;case vH:for(;m<32;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.head&&(n.head.time=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=xs(n.check,T,4,0)),l=0,m=0,n.mode=CH;case CH:for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=xs(n.check,T,2,0)),l=0,m=0,n.mode=pH;case pH:if(n.flags&1024){for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=xs(n.check,T,2,0)),l=0,m=0}else n.head&&(n.head.extra=null);n.mode=DH;case DH:if(n.flags&1024&&(U=n.length,U>a&&(U=a),U&&(n.head&&(B=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Ui.arraySet(n.head.extra,h,t,U,B)),n.flags&512&&(n.check=xs(n.check,h,U,t)),a-=U,t+=U,n.length-=U),n.length))break r;n.length=0,n.mode=bH;case bH:if(n.flags&2048){if(a===0)break r;U=0;do B=h[t+U++],n.head&&B&&n.length<65536&&(n.head.name+=String.fromCharCode(B));while(B&&U<a);if(n.flags&512&&(n.check=xs(n.check,h,U,t)),a-=U,t+=U,B)break r}else n.head&&(n.head.name=null);n.length=0,n.mode=gH;case gH:if(n.flags&4096){if(a===0)break r;U=0;do B=h[t+U++],n.head&&B&&n.length<65536&&(n.head.comment+=String.fromCharCode(B));while(B&&U<a);if(n.flags&512&&(n.check=xs(n.check,h,U,t)),a-=U,t+=U,B)break r}else n.head&&(n.head.comment=null);n.mode=_H;case _H:if(n.flags&512){for(;m<16;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(l!==(n.check&65535)){c.msg="header crc mismatch",n.mode=Dn;break}l=0,m=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),c.adler=n.check=0,n.mode=Ya;break;case AH:for(;m<32;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}c.adler=n.check=EH(l),l=0,m=0,n.mode=c6;case c6:if(n.havedict===0)return c.next_out=s,c.avail_out=o,c.next_in=t,c.avail_in=a,n.hold=l,n.bits=m,mVr;c.adler=n.check=1,n.mode=Ya;case Ya:if(e===oVr||e===e6)break r;case F8:if(n.last){l>>>=m&7,m-=m&7,n.mode=J8;break}for(;m<3;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}switch(n.last=l&1,l>>>=1,m-=1,l&3){case 0:n.mode=yH;break;case 1:if(bVr(n),n.mode=n6,e===e6){l>>>=2,m-=2;break r}break;case 2:n.mode=ZH;break;case 3:c.msg="invalid block type",n.mode=Dn}l>>>=2,m-=2;break;case yH:for(l>>>=m&7,m-=m&7;m<32;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if((l&65535)!==(l>>>16^65535)){c.msg="invalid stored block lengths",n.mode=Dn;break}if(n.length=l&65535,l=0,m=0,n.mode=k8,e===e6)break r;case k8:n.mode=BH;case BH:if(U=n.length,U){if(U>a&&(U=a),U>o&&(U=o),U===0)break r;Ui.arraySet(i,h,t,U,s),a-=U,t+=U,o-=U,s+=U,n.length-=U;break}n.mode=Ya;break;case ZH:for(;m<14;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(n.nlen=(l&31)+257,l>>>=5,m-=5,n.ndist=(l&31)+1,l>>>=5,m-=5,n.ncode=(l&15)+4,l>>>=4,m-=4,n.nlen>286||n.ndist>30){c.msg="too many length or distance symbols",n.mode=Dn;break}n.have=0,n.mode=fH;case fH:for(;n.have<n.ncode;){for(;m<3;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.lens[J[n.have++]]=l&7,l>>>=3,m-=3}for(;n.have<19;)n.lens[J[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,L={bits:n.lenbits},W=c9(aVr,n.lens,0,19,n.lencode,0,n.work,L),n.lenbits=L.bits,W){c.msg="invalid code lengths set",n.mode=Dn;break}n.have=0,n.mode=SH;case SH:for(;n.have<n.nlen+n.ndist;){for(;D=n.lencode[l&(1<<n.lenbits)-1],A=D>>>24,f=D>>>16&255,M=D&65535,!(A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(M<16)l>>>=A,m-=A,n.lens[n.have++]=M;else{if(M===16){for(I=A+2;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(l>>>=A,m-=A,n.have===0){c.msg="invalid bit length repeat",n.mode=Dn;break}B=n.lens[n.have-1],U=3+(l&3),l>>>=2,m-=2}else if(M===17){for(I=A+3;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}l>>>=A,m-=A,B=0,U=3+(l&7),l>>>=3,m-=3}else{for(I=A+7;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}l>>>=A,m-=A,B=0,U=11+(l&127),l>>>=7,m-=7}if(n.have+U>n.nlen+n.ndist){c.msg="invalid bit length repeat",n.mode=Dn;break}for(;U--;)n.lens[n.have++]=B}}if(n.mode===Dn)break;if(n.lens[256]===0){c.msg="invalid code -- missing end-of-block",n.mode=Dn;break}if(n.lenbits=9,L={bits:n.lenbits},W=c9(aH,n.lens,0,n.nlen,n.lencode,0,n.work,L),n.lenbits=L.bits,W){c.msg="invalid literal/lengths set",n.mode=Dn;break}if(n.distbits=6,n.distcode=n.distdyn,L={bits:n.distbits},W=c9(oH,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,L),n.distbits=L.bits,W){c.msg="invalid distances set",n.mode=Dn;break}if(n.mode=n6,e===e6)break r;case n6:n.mode=h6;case h6:if(a>=6&&o>=258){c.next_out=s,c.avail_out=o,c.next_in=t,c.avail_in=a,n.hold=l,n.bits=m,sVr(c,u),s=c.next_out,i=c.output,o=c.avail_out,t=c.next_in,h=c.input,a=c.avail_in,l=n.hold,m=n.bits,n.mode===Ya&&(n.back=-1);break}for(n.back=0;D=n.lencode[l&(1<<n.lenbits)-1],A=D>>>24,f=D>>>16&255,M=D&65535,!(A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(f&&!(f&240)){for(S=A,N=f,x=M;D=n.lencode[x+((l&(1<<S+N)-1)>>S)],A=D>>>24,f=D>>>16&255,M=D&65535,!(S+A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}l>>>=S,m-=S,n.back+=S}if(l>>>=A,m-=A,n.back+=A,n.length=M,f===0){n.mode=TH;break}if(f&32){n.back=-1,n.mode=Ya;break}if(f&64){c.msg="invalid literal/length code",n.mode=Dn;break}n.extra=f&15,n.mode=MH;case MH:if(n.extra){for(I=n.extra;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,m-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=GH;case GH:for(;D=n.distcode[l&(1<<n.distbits)-1],A=D>>>24,f=D>>>16&255,M=D&65535,!(A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(!(f&240)){for(S=A,N=f,x=M;D=n.distcode[x+((l&(1<<S+N)-1)>>S)],A=D>>>24,f=D>>>16&255,M=D&65535,!(S+A<=m);){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}l>>>=S,m-=S,n.back+=S}if(l>>>=A,m-=A,n.back+=A,f&64){c.msg="invalid distance code",n.mode=Dn;break}n.offset=M,n.extra=f&15,n.mode=NH;case NH:if(n.extra){for(I=n.extra;m<I;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,m-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){c.msg="invalid distance too far back",n.mode=Dn;break}n.mode=WH;case WH:if(o===0)break r;if(U=u-o,n.offset>U){if(U=n.offset-U,U>n.whave&&n.sane){c.msg="invalid distance too far back",n.mode=Dn;break}U>n.wnext?(U-=n.wnext,C=n.wsize-U):C=n.wnext-U,U>n.length&&(U=n.length),p=n.window}else p=i,C=s-n.offset,U=n.length;U>o&&(U=o),o-=U,n.length-=U;do i[s++]=p[C++];while(--U);n.length===0&&(n.mode=h6);break;case TH:if(o===0)break r;i[s++]=n.length,o--,n.mode=h6;break;case J8:if(n.wrap){for(;m<32;){if(a===0)break r;a--,l|=h[t++]<<m,m+=8}if(u-=o,c.total_out+=u,n.total+=u,u&&(c.adler=n.check=n.flags?xs(n.check,i,u,s-u):V8(n.check,i,u,s-u)),u=o,(n.flags?l:EH(l))!==n.check){c.msg="incorrect data check",n.mode=Dn;break}l=0,m=0}n.mode=XH;case XH:if(n.wrap&&n.flags){for(;m<32;){if(a===0)break r;a--,l+=h[t++]<<m,m+=8}if(l!==(n.total&4294967295)){c.msg="incorrect length check",n.mode=Dn;break}l=0,m=0}n.mode=YH;case YH:W=lVr;break r;case Dn:W=mH;break r;case wH:return dH;case uVr:default:return Pi}return c.next_out=s,c.avail_out=o,c.next_in=t,c.avail_in=a,n.hold=l,n.bits=m,(n.wsize||u!==c.avail_out&&n.mode<Dn&&(n.mode<J8||e!==lH))&&FH(c,c.output,c.next_out,u-c.avail_out),d-=c.avail_in,u-=c.avail_out,c.total_in+=d,c.total_out+=u,n.total+=u,n.wrap&&u&&(c.adler=n.check=n.flags?xs(n.check,i,u,c.next_out-u):V8(n.check,i,u,c.next_out-u)),c.data_type=n.bits+(n.last?64:0)+(n.mode===Ya?128:0)+(n.mode===n6||n.mode===k8?256:0),(d===0&&u===0||e===lH)&&W===d2&&(W=dVr),W}function _Vr(c){if(!c||!c.state)return Pi;var e=c.state;return e.window&&(e.window=null),c.state=null,d2}function AVr(c,e){var n;return!c||!c.state||(n=c.state,!(n.wrap&2))?Pi:(n.head=e,e.done=!1,d2)}function yVr(c,e){var n=e.length,h,i,t;return!c||!c.state||(h=c.state,h.wrap!==0&&h.mode!==c6)?Pi:h.mode===c6&&(i=1,i=V8(i,e,n,0),i!==h.check)?mH:(t=FH(c,e,n,n),t?(h.mode=wH,dH):(h.havedict=1,d2))}jt.inflateReset=RH,jt.inflateReset2=LH,jt.inflateResetKeep=xH,jt.inflateInit=DVr,jt.inflateInit2=IH,jt.inflate=gVr,jt.inflateEnd=_Vr,jt.inflateGetHeader=AVr,jt.inflateSetDictionary=yVr,jt.inflateInfo="pako inflate (from Nodeca project)";var kH={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function BVr(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var ZVr=BVr,Wm=jt,n9=Ta,i6=l2,Jn=kH,K8=W8,fVr=$j,SVr=ZVr,JH=Object.prototype.toString;function u2(c){if(!(this instanceof u2))return new u2(c);this.options=n9.assign({chunkSize:16384,windowBits:0,to:""},c||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(c&&c.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new fVr,this.strm.avail_out=0;var n=Wm.inflateInit2(this.strm,e.windowBits);if(n!==Jn.Z_OK)throw new Error(K8[n]);if(this.header=new SVr,Wm.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=i6.string2buf(e.dictionary):JH.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=Wm.inflateSetDictionary(this.strm,e.dictionary),n!==Jn.Z_OK)))throw new Error(K8[n])}u2.prototype.push=function(c,e){var n=this.strm,h=this.options.chunkSize,i=this.options.dictionary,t,s,a,o,l,m=!1;if(this.ended)return!1;s=e===~~e?e:e===!0?Jn.Z_FINISH:Jn.Z_NO_FLUSH,typeof c=="string"?n.input=i6.binstring2buf(c):JH.call(c)==="[object ArrayBuffer]"?n.input=new Uint8Array(c):n.input=c,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new n9.Buf8(h),n.next_out=0,n.avail_out=h),t=Wm.inflate(n,Jn.Z_NO_FLUSH),t===Jn.Z_NEED_DICT&&i&&(t=Wm.inflateSetDictionary(this.strm,i)),t===Jn.Z_BUF_ERROR&&m===!0&&(t=Jn.Z_OK,m=!1),t!==Jn.Z_STREAM_END&&t!==Jn.Z_OK)return this.onEnd(t),this.ended=!0,!1;n.next_out&&(n.avail_out===0||t===Jn.Z_STREAM_END||n.avail_in===0&&(s===Jn.Z_FINISH||s===Jn.Z_SYNC_FLUSH))&&(this.options.to==="string"?(a=i6.utf8border(n.output,n.next_out),o=n.next_out-a,l=i6.buf2string(n.output,a),n.next_out=o,n.avail_out=h-o,o&&n9.arraySet(n.output,n.output,a,o,0),this.onData(l)):this.onData(n9.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(m=!0)}while((n.avail_in>0||n.avail_out===0)&&t!==Jn.Z_STREAM_END);return t===Jn.Z_STREAM_END&&(s=Jn.Z_FINISH),s===Jn.Z_FINISH?(t=Wm.inflateEnd(this.strm),this.onEnd(t),this.ended=!0,t===Jn.Z_OK):(s===Jn.Z_SYNC_FLUSH&&(this.onEnd(Jn.Z_OK),n.avail_out=0),!0)},u2.prototype.onData=function(c){this.chunks.push(c)},u2.prototype.onEnd=function(c){c===Jn.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=n9.flattenChunks(this.chunks)),this.chunks=[],this.err=c,this.msg=this.strm.msg};function P8(c,e){var n=new u2(e);if(n.push(c,!0),n.err)throw n.msg||K8[n.err];return n.result}function MVr(c,e){return e=e||{},e.raw=!0,P8(c,e)}e9.Inflate=u2,e9.inflate=P8,e9.inflateRaw=MVr,e9.ungzip=P8;var GVr=Ta.assign,NVr=V4,WVr=e9,TVr=kH,jH={};GVr(jH,NVr,WVr,TVr);var t6=jH;async function Tm(c){try{let e,n=0,h=0;const i=[];let t=0,s;do{const o=c.subarray(n);if(s=new t6.Inflate,{strm:e}=s,s.push(o,t6.Z_SYNC_FLUSH),s.err)throw new Error(s.msg);n+=e.next_in,i[h]=s.result,t+=i[h].length,h+=1}while(e.avail_in);const a=new Uint8Array(t);for(let o=0,l=0;o<i.length;o++)a.set(i[o],l),l+=i[o].length;return Ti.from(a)}catch(e){throw/incorrect header check/.exec(`${e}`)?new Error("problem decompressing block: incorrect gzip header check"):e}}async function HH(c,e){try{let n;const{minv:h,maxv:i}=e;let t=h.blockPosition,s=h.dataPosition;const a=[],o=[],l=[];let m=0,d=0;do{const C=c.subarray(t-h.blockPosition),p=new t6.Inflate;if({strm:n}=p,p.push(C,t6.Z_SYNC_FLUSH),p.err)throw new Error(p.msg);const D=p.result;a.push(D);let A=D.length;o.push(t),l.push(s),a.length===1&&h.dataPosition&&(a[0]=a[0].subarray(h.dataPosition),A=a[0].length);const f=t;if(t+=n.next_in,s+=A,f>=i.blockPosition){a[d]=a[d].subarray(0,i.blockPosition===h.blockPosition?i.dataPosition-h.dataPosition+1:i.dataPosition+1),o.push(t),l.push(s),m+=a[d].length;break}m+=a[d].length,d++}while(n.avail_in);const u=new Uint8Array(m);for(let C=0,p=0;C<a.length;C++)u.set(a[C],p),p+=a[C].length;return{buffer:Ti.from(u),cpositions:o,dpositions:l}}catch(n){throw/incorrect header check/.exec(`${n}`)?new Error("problem decompressing block: incorrect gzip header check"):n}}class XVr{}class YVr{constructor(){this.signals=new Set,this.abortController=new AbortController}addSignal(e=new XVr){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(e),e.aborted?this.handleAborted(e):typeof e.addEventListener=="function"&&e.addEventListener("abort",()=>{this.handleAborted(e)})}handleAborted(e){this.signals.delete(e),this.signals.size===0&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}class wVr{constructor(){this.callbacks=new Set}addCallback(e=()=>{}){this.callbacks.add(e),e(this.currentMessage)}callback(e){this.currentMessage=e;for(const n of this.callbacks)n(e)}}class h9{constructor({fill:e,cache:n}){if(typeof e!="function")throw new TypeError("must pass a fill function");if(typeof n!="object")throw new TypeError("must pass a cache object");if(typeof n.get!="function"||typeof n.set!="function"||typeof n.delete!="function")throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=n,this.fillCallback=e}static isAbortException(e){return e.name==="AbortError"||e.code==="ERR_ABORTED"||e.message==="AbortError: aborted"||e.message==="Error: aborted"}evict(e,n){this.cache.get(e)===n&&this.cache.delete(e)}fill(e,n,h,i){const t=new YVr,s=new wVr;s.addCallback(i);const a={aborter:t,promise:this.fillCallback(n,t.signal,o=>{s.callback(o)}),settled:!1,statusReporter:s,get aborted(){return this.aborter.signal.aborted}};a.aborter.addSignal(h),a.aborter.signal.addEventListener("abort",()=>{a.settled||this.evict(e,a)}),a.promise.then(()=>{a.settled=!0},()=>{a.settled=!0,this.evict(e,a)}).catch(o=>{throw console.error(o),o}),this.cache.set(e,a)}static checkSinglePromise(e,n){function h(){if(n!=null&&n.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return e.then(i=>(h(),i),i=>{throw h(),i})}has(e){return this.cache.has(e)}get(e,n,h,i){if(!h&&n instanceof AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const t=this.cache.get(e);return t?t.aborted&&!t.settled?(this.evict(e,t),this.get(e,n,h,i)):t.settled?t.promise:(t.aborter.addSignal(h),t.statusReporter.addCallback(i),h9.checkSinglePromise(t.promise,h)):(this.fill(e,n,h,i),h9.checkSinglePromise(this.cache.get(e).promise,h))}delete(e){const n=this.cache.get(e);n&&(n.settled||n.aborter.abort(),this.cache.delete(e))}clear(){const e=this.cache.keys();let n=0;for(let h=e.next();!h.done;h=e.next())this.delete(h.value),n+=1;return n}}const EVr=21582659,xVr=38359875;function RVr(c,e){return c*2**e}function KH(c,e){return Math.floor(c/2**e)}let O8=class extends vj{constructor(){super(...arguments),this.maxBinNumber=0,this.depth=0,this.minShift=0}async lineCount(e,n){var h,i;return((i=(h=(await this.parse(n)).indices[e])===null||h===void 0?void 0:h.stats)===null||i===void 0?void 0:i.lineCount)||0}async indexCov(){return[]}parseAuxData(e,n){const h=e.readInt32LE(n),i=h&65536?"zero-based-half-open":"1-based-closed",t={0:"generic",1:"SAM",2:"VCF"}[h&15];if(!t)throw new Error(`invalid Tabix preset format flags ${h}`);const s={ref:e.readInt32LE(n+4),start:e.readInt32LE(n+8),end:e.readInt32LE(n+12)},a=e.readInt32LE(n+16),o=a?String.fromCharCode(a):"",l=e.readInt32LE(n+20),m=e.readInt32LE(n+24);return{columnNumbers:s,coordinateType:i,metaValue:a,metaChar:o,skipLines:l,format:t,formatFlags:h,...YLr(e.subarray(n+28,n+28+m),this.renameRefSeq)}}async _parse(e){const n=await this.filehandle.readFile(e),h=await Tm(n);let i;if(h.readUInt32LE(0)===EVr)i=1;else if(h.readUInt32LE(0)===xVr)i=2;else throw new Error("Not a CSI file");this.minShift=h.readInt32LE(4),this.depth=h.readInt32LE(8),this.maxBinNumber=((1<<(this.depth+1)*3)-1)/7;const t=h.readInt32LE(12),s=t>=30?this.parseAuxData(h,16):void 0,a=h.readInt32LE(16+t);let o=16+t+4,l;const m=new Array(a);for(let d=0;d<a;d++){const u=h.readInt32LE(o);o+=4;const U={};let C;for(let p=0;p<u;p++){const D=h.readUInt32LE(o);if(o+=4,D>this.maxBinNumber)C=zj(h,o+28),o+=44;else{l=kv(l,Am(h,o)),o+=8;const A=h.readInt32LE(o);o+=4;const f=new Array(A);for(let M=0;M<A;M+=1){const S=Am(h,o);o+=8;const N=Am(h,o);o+=8,l=kv(l,S),f[M]=new uj(S,N,D)}U[D]=f}}m[d]={binIndex:U,stats:C}}return{csiVersion:i,firstDataLine:l,indices:m,refCount:a,csi:!0,maxBlockSize:65536,...s}}async blocksForRange(e,n,h,i={}){n<0&&(n=0);const t=await this.parse(i),s=t==null?void 0:t.indices[e];if(!s)return[];const a=this.reg2bins(n,h);if(a.length===0)return[];const o=[];for(const[l,m]of a)for(let d=l;d<=m;d++)if(s.binIndex[d]){const u=s.binIndex[d];for(const U of u)o.push(U)}return Uj(o,new dj(0,0))}reg2bins(e,n){e-=1,e<1&&(e=1),n>2**50&&(n=2**34),n-=1;let h=0,i=0,t=this.minShift+this.depth*3;const s=[];for(;h<=this.depth;t-=3,i+=RVr(1,h*3),h+=1){const a=i+KH(e,t),o=i+KH(n,t);if(o-a+s.length>this.maxBinNumber)throw new Error(`query ${e}-${n} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);s.push([a,o])}return s}async parse(e={}){return this.setupP||(this.setupP=this._parse(e).catch(n=>{throw this.setupP=void 0,n})),this.setupP}async hasRefSeq(e,n={}){var h;return!!(!((h=(await this.parse(n)).indices[e])===null||h===void 0)&&h.binIndex)}};const Oi={BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048},PH="=ACMGRSVTWYHKDBN".split(""),i9="MIDNSHP=X???????".split("");class LVr{constructor(e){this.data={},this._tagList=[],this._allTagsParsed=!1;const{bytes:n,fileOffset:h}=e,{byteArray:i,start:t}=n;this.data={start:i.readInt32LE(t+8)},this.bytes=n,this._id=h,this._refID=i.readInt32LE(t+4),this.flags=(i.readInt32LE(t+16)&4294901760)>>16}get(e){return this[e]?this.data[e]?this.data[e]:(this.data[e]=this[e](),this.data[e]):this._get(e.toLowerCase())}end(){return this.get("start")+this.get("length_on_ref")}seq_id(){return this._refID}_get(e){return e in this.data?this.data[e]:(this.data[e]=this._parseTag(e),this.data[e])}_tags(){this._parseAllTags();let e=["seq"];this.isSegmentUnmapped()||e.push("start","end","strand","score","qual","MQ","CIGAR","length_on_ref","template_length"),this.isPaired()&&e.push("next_segment_position","pair_orientation"),e=e.concat(this._tagList||[]);for(const h of Object.keys(this.data))!h.startsWith("_")&&h!=="next_seq_id"&&e.push(h);const n={};return e.filter(h=>{if(h in this.data&&this.data[h]===void 0||h==="CG"||h==="cg")return!1;const i=h.toLowerCase(),t=n[i];return n[i]=!0,!t})}parent(){}children(){return this.get("subfeatures")}id(){return this._id}mq(){const e=(this.get("_bin_mq_nl")&65280)>>8;return e===255?void 0:e}score(){return this.get("mq")}qual(){var e;return(e=this.qualRaw())===null||e===void 0?void 0:e.join(" ")}qualRaw(){if(this.isSegmentUnmapped())return;const{start:e,byteArray:n}=this.bytes,h=e+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4+this.get("_seq_bytes"),i=this.get("seq_length");return n.subarray(h,h+i)}strand(){return this.isReverseComplemented()?-1:1}multi_segment_next_segment_strand(){if(!this.isMateUnmapped())return this.isMateReverseComplemented()?-1:1}name(){return this.get("_read_name")}_read_name(){const e=this.get("_l_read_name"),{byteArray:n,start:h}=this.bytes;return n.toString("ascii",h+36,h+36+e-1)}_parseTag(e){if(this._allTagsParsed)return;const{byteArray:n,start:h}=this.bytes;let i=this._tagOffset||h+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4+this.get("_seq_bytes")+this.get("seq_length");const t=this.bytes.end;let s;for(;i<t&&s!==e;){const a=String.fromCharCode(n[i],n[i+1]);s=a.toLowerCase();const o=String.fromCharCode(n[i+2]);i+=3;let l;switch(o){case"A":{l=String.fromCharCode(n[i]),i+=1;break}case"i":{l=n.readInt32LE(i),i+=4;break}case"I":{l=n.readUInt32LE(i),i+=4;break}case"c":{l=n.readInt8(i),i+=1;break}case"C":{l=n.readUInt8(i),i+=1;break}case"s":{l=n.readInt16LE(i),i+=2;break}case"S":{l=n.readUInt16LE(i),i+=2;break}case"f":{l=n.readFloatLE(i),i+=4;break}case"Z":case"H":{for(l="";i<=t;){const m=n[i++];if(m===0)break;l+=String.fromCharCode(m)}break}case"B":{l="";const m=n[i++],d=String.fromCharCode(m),u=n.readInt32LE(i);if(i+=4,d==="i")if(a==="CG")for(let U=0;U<u;U++){const C=n.readInt32LE(i),p=C>>4,D=i9[C&15];l+=p+D,i+=4}else for(let U=0;U<u;U++)l+=n.readInt32LE(i),U+1<u&&(l+=","),i+=4;if(d==="I")if(a==="CG")for(let U=0;U<u;U++){const C=n.readUInt32LE(i),p=C>>4,D=i9[C&15];l+=p+D,i+=4}else for(let U=0;U<u;U++)l+=n.readUInt32LE(i),U+1<u&&(l+=","),i+=4;if(d==="s")for(let U=0;U<u;U++)l+=n.readInt16LE(i),U+1<u&&(l+=","),i+=2;if(d==="S")for(let U=0;U<u;U++)l+=n.readUInt16LE(i),U+1<u&&(l+=","),i+=2;if(d==="c")for(let U=0;U<u;U++)l+=n.readInt8(i),U+1<u&&(l+=","),i+=1;if(d==="C")for(let U=0;U<u;U++)l+=n.readUInt8(i),U+1<u&&(l+=","),i+=1;if(d==="f")for(let U=0;U<u;U++)l+=n.readFloatLE(i),U+1<u&&(l+=","),i+=4;break}default:console.warn(`Unknown BAM tag type '${o}', tags may be incomplete`),l=void 0,i=t}if(this._tagOffset=i,this._tagList.push(a),s===e)return l;this.data[s]=l}this._allTagsParsed=!0}_parseAllTags(){this._parseTag("")}_parseCigar(e){return e.match(/\d+\D/g).map(n=>[/\D/.exec(n)[0].toUpperCase(),Number.parseInt(n,10)])}isPaired(){return!!(this.flags&Oi.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&Oi.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&Oi.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&Oi.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&Oi.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&Oi.BAM_FMREVERSE)}isRead1(){return!!(this.flags&Oi.BAM_FREAD1)}isRead2(){return!!(this.flags&Oi.BAM_FREAD2)}isSecondary(){return!!(this.flags&Oi.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&Oi.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&Oi.BAM_FDUP)}isSupplementary(){return!!(this.flags&Oi.BAM_FSUPPLEMENTARY)}cigar(){if(this.isSegmentUnmapped())return;const{byteArray:e,start:n}=this.bytes,h=this.get("_n_cigar_op");let i=n+36+this.get("_l_read_name");const t=this.get("seq_length");let s="",a=0,o=e.readInt32LE(i),l=o>>4,m=i9[o&15];if(m==="S"&&l===t)return i+=4,o=e.readInt32LE(i),l=o>>4,m=i9[o&15],m!=="N"&&console.warn("CG tag with no N tag"),this.data.length_on_ref=l,this.get("CG");for(let d=0;d<h;++d)o=e.readInt32LE(i),l=o>>4,m=i9[o&15],s+=l+m,m!=="H"&&m!=="S"&&m!=="I"&&(a+=l),i+=4;return this.data.length_on_ref=a,s}length_on_ref(){return this.data.length_on_ref?this.data.length_on_ref:(this.get("cigar"),this.data.length_on_ref)}_n_cigar_op(){return this.get("_flag_nc")&65535}_l_read_name(){return this.get("_bin_mq_nl")&255}_seq_bytes(){return this.get("seq_length")+1>>1}getReadBases(){return this.seq()}seq(){const{byteArray:e,start:n}=this.bytes,h=n+36+this.get("_l_read_name")+this.get("_n_cigar_op")*4,i=this.get("_seq_bytes"),t=this.get("seq_length");let s="",a=0;for(let o=0;o<i;++o){const l=e[h+o];s+=PH[(l&240)>>4],a++,a<t&&(s+=PH[l&15],a++)}return s}getPairOrientation(){if(!this.isSegmentUnmapped()&&!this.isMateUnmapped()&&this._refID===this._next_refid()){const e=this.isReverseComplemented()?"R":"F",n=this.isMateReverseComplemented()?"R":"F";let h=" ",i=" ";this.isRead1()?(h="1",i="2"):this.isRead2()&&(h="2",i="1");const t=[];return this.template_length()>0?(t[0]=e,t[1]=h,t[2]=n,t[3]=i):(t[2]=e,t[3]=h,t[0]=n,t[1]=i),t.join("")}return""}_bin_mq_nl(){return this.bytes.byteArray.readInt32LE(this.bytes.start+12)}_flag_nc(){return this.bytes.byteArray.readInt32LE(this.bytes.start+16)}seq_length(){return this.bytes.byteArray.readInt32LE(this.bytes.start+20)}_next_refid(){return this.bytes.byteArray.readInt32LE(this.bytes.start+24)}_next_pos(){return this.bytes.byteArray.readInt32LE(this.bytes.start+28)}template_length(){return this.bytes.byteArray.readInt32LE(this.bytes.start+32)}toJSON(){const e={};for(const n of Object.keys(this))n.startsWith("_")||n==="bytes"||(e[n]=this[n]);return e}}function IVr(c){const e=c.split(/\r?\n/),n=[];for(const h of e){const[i,...t]=h.split(/\t/);i&&n.push({tag:i.slice(1),data:t.map(s=>{const a=s.indexOf(":"),o=s.slice(0,a),l=s.slice(a+1);return{tag:o,value:l}})})}return n}const VVr=21840194,OH=65536;async function FVr(c){let e=[];for await(const n of c)e=e.concat(n);return e}class kVr{read(){throw new Error("never called")}stat(){throw new Error("never called")}readFile(){throw new Error("never called")}close(){throw new Error("never called")}}class QH{constructor({bamFilehandle:e,bamPath:n,bamUrl:h,baiPath:i,baiFilehandle:t,baiUrl:s,csiPath:a,csiFilehandle:o,csiUrl:l,htsget:m,yieldThreadTime:d=100,renameRefSeqs:u=U=>U}){if(this.htsget=!1,this.featureCache=new h9({cache:new D7({maxSize:50}),fill:async(U,C)=>{const{chunk:p,opts:D}=U,{data:A,cpositions:f,dpositions:M}=await this._readChunk({chunk:p,opts:{...D,signal:C}});return this.readBamFeatures(A,f,M,p)}}),this.renameRefSeq=u,e)this.bam=e;else if(n)this.bam=new pa(n);else if(h)this.bam=new p1(h);else if(m)this.htsget=!0,this.bam=new kVr;else throw new Error("unable to initialize bam");if(o)this.index=new O8({filehandle:o});else if(a)this.index=new O8({filehandle:new pa(a)});else if(l)this.index=new O8({filehandle:new p1(l)});else if(t)this.index=new I4({filehandle:t});else if(i)this.index=new I4({filehandle:new pa(i)});else if(s)this.index=new I4({filehandle:new p1(s)});else if(n)this.index=new I4({filehandle:new pa(`${n}.bai`)});else if(h)this.index=new I4({filehandle:new p1(`${h}.bai`)});else if(m)this.htsget=!0;else throw new Error("unable to infer index format");this.yieldThreadTime=d}async getHeaderPre(e){const n=XLr(e);if(!this.index)return;const h=await this.index.parse(n),i=h.firstDataLine?h.firstDataLine.blockPosition+65535:void 0;let t;if(i){const m=i+OH,d=await this.bam.read(Ti.alloc(m),0,m,0,n);if(!d.bytesRead)throw new Error("Error reading header");t=d.buffer.subarray(0,Math.min(d.bytesRead,i))}else t=await this.bam.readFile(n);const s=await Tm(t);if(s.readInt32LE(0)!==VVr)throw new Error("Not a BAM file");const a=s.readInt32LE(4);this.header=s.toString("utf8",8,8+a);const{chrToIndex:o,indexToChr:l}=await this._readRefSeqs(a+8,65535,n);return this.chrToIndex=o,this.indexToChr=l,IVr(this.header)}getHeader(e){return this.headerP||(this.headerP=this.getHeaderPre(e).catch(n=>{throw this.headerP=void 0,n})),this.headerP}async getHeaderText(e={}){return await this.getHeader(e),this.header}async _readRefSeqs(e,n,h){if(e>n)return this._readRefSeqs(e,n*2,h);const i=n+OH,{bytesRead:t,buffer:s}=await this.bam.read(Ti.alloc(i),0,n,0,h);if(!t)throw new Error("Error reading refseqs from header");const a=await Tm(s.subarray(0,Math.min(t,n))),o=a.readInt32LE(e);let l=e+4;const m={},d=[];for(let u=0;u<o;u+=1){const U=a.readInt32LE(l),C=this.renameRefSeq(a.toString("utf8",l+4,l+4+U-1)),p=a.readInt32LE(l+U+4);if(m[C]=u,d.push({refName:C,length:p}),l=l+8+U,l>a.length)return console.warn(`BAM header is very big. Re-fetching ${n} bytes.`),this._readRefSeqs(e,n*2,h)}return{chrToIndex:m,indexToChr:d}}async getRecordsForRange(e,n,h,i){return FVr(this.streamRecordsForRange(e,n,h,i))}async*streamRecordsForRange(e,n,h,i){var t;await this.getHeader(i);const s=(t=this.chrToIndex)===null||t===void 0?void 0:t[e];if(s===void 0||!this.index)yield[];else{const a=await this.index.blocksForRange(s,n-1,h,i);yield*this._fetchChunkFeatures(a,s,n,h,i)}}async*_fetchChunkFeatures(e,n,h,i,t={}){const{viewAsPairs:s}=t,a=[];let o=!1;for(const l of e){const m=await this.featureCache.get(l.toString(),{chunk:l,opts:t},t.signal),d=[];for(const u of m)if(u.seq_id()===n)if(u.get("start")>=i){o=!0;break}else u.get("end")>=h&&d.push(u);if(a.push(d),yield d,o)break}WLr(t.signal),s&&(yield this.fetchPairs(n,a,t))}async fetchPairs(e,n,h){const{pairAcrossChr:i,maxInsertSize:t=2e5}=h,s={},a={};n.map(u=>{const U={};for(const C of u){const p=C.name(),D=C.id();U[p]||(U[p]=0),U[p]++,a[D]=1}for(const[C,p]of Object.entries(U))p===1&&(s[C]=!0)});const o=[];n.map(u=>{for(const U of u){const C=U.name(),p=U.get("start"),D=U._next_pos(),A=U._next_refid();this.index&&s[C]&&(i||A===e&&Math.abs(p-D)<t)&&o.push(this.index.blocksForRange(A,D,D+1,h))}});const l=new Map,m=await Promise.all(o);for(const u of m.flat())l.has(u.toString())||l.set(u.toString(),u);return(await Promise.all([...l.values()].map(async u=>{const{data:U,cpositions:C,dpositions:p,chunk:D}=await this._readChunk({chunk:u,opts:h}),A=[];for(const f of await this.readBamFeatures(U,C,p,D))s[f.get("name")]&&!a[f.id()]&&A.push(f);return A}))).flat()}async _readRegion(e,n,h={}){const{bytesRead:i,buffer:t}=await this.bam.read(Ti.alloc(n),0,n,e,h);return t.subarray(0,Math.min(i,n))}async _readChunk({chunk:e,opts:n}){const h=await this._readRegion(e.minv.blockPosition,e.fetchedSize(),n),{buffer:i,cpositions:t,dpositions:s}=await HH(h,e);return{data:i,cpositions:t,dpositions:s,chunk:e}}async readBamFeatures(e,n,h,i){let t=0;const s=[];let a=0,o=+Date.now();for(;t+4<e.length;){const l=e.readInt32LE(t),m=t+4+l-1;if(h){for(;t+i.minv.dataPosition>=h[a++];);a--}if(m<e.length){const d=new LVr({bytes:{byteArray:e,start:t,end:m},fileOffset:n.length>0?n[a]*256+(t-h[a])+i.minv.dataPosition+1:VLr.signed(e.slice(t,m))});s.push(d),this.yieldThreadTime&&+Date.now()-o>this.yieldThreadTime&&(await GLr(1),o=+Date.now())}t=m+1}return s}async hasRefSeq(e){var n,h;const i=(n=this.chrToIndex)===null||n===void 0?void 0:n[e];return i===void 0?!1:(h=this.index)===null||h===void 0?void 0:h.hasRefSeq(i)}async lineCount(e){var n;const h=(n=this.chrToIndex)===null||n===void 0?void 0:n[e];return h===void 0||!this.index?0:this.index.lineCount(h)}async indexCov(e,n,h){var i;if(!this.index)return[];await this.index.parse();const t=(i=this.chrToIndex)===null||i===void 0?void 0:i[e];return t===void 0?[]:this.index.indexCov(t,n,h)}async blocksForRange(e,n,h,i){var t;if(!this.index)return[];await this.index.parse();const s=(t=this.chrToIndex)===null||t===void 0?void 0:t[e];return s===void 0?[]:this.index.blocksForRange(s,n,h,i)}}class Q8{constructor(e){q(this,"bam");q(this,"header");if(this.bam=null,typeof e=="string")this.bam=new QH({bamUrl:e,baiUrl:e+".bai"});else{const n=new rm(e.filter(i=>i.name.endsWith(".bai"))[0]),h=new rm(e.filter(i=>!i.name.endsWith(".bai"))[0]);this.bam=new QH({bamFilehandle:h,baiFilehandle:n})}this.header=null}async getData(e,n,h={}){this.header||(this.header=await this.bam.getHeader());const i=e.map(o=>this.bam.getRecordsForRange(o.chr,o.start,o.end));return(await Promise.all(i)).flat(1).map(o=>Object.assign(o,{ref:this.bam.indexToChr[o.get("seq_id")].refName}))}}function q8(){}class $8 extends E.Component{constructor(n){super(n);q(this,"originEvent");this.originEvent=null,this.mousedown=this.mousedown.bind(this),this.mousemove=this.mousemove.bind(this),this.mouseup=this.mouseup.bind(this)}mousedown(n){this.originEvent===null&&n.button===this.props.mouseButton&&(n.persist(),this.originEvent=n,this.props.onDragStart(n))}mousemove(n){if(this.originEvent!==null){const h={dx:n.clientX-this.originEvent.clientX,dy:n.clientY-this.originEvent.clientY};this.props.onDrag(n,h)}}mouseup(n){if(this.originEvent!==null){const h={dx:n.clientX-this.originEvent.clientX,dy:n.clientY-this.originEvent.clientY};this.props.onDragEnd(n,h),this.originEvent=null}}render(){const{mouseButton:n,onDragStart:h,onDrag:i,onDragEnd:t,children:s,...a}=this.props;return _.jsx("div",{onMouseDown:this.mousedown,onMouseMove:this.mousemove,onMouseUp:this.mouseup,...a,children:s})}}q($8,"defaultProps",{onDragStart:q8,onDrag:q8,onDragEnd:q8});const JVr=27;class qH extends E.PureComponent{constructor(e){super(e),this.state={isDragging:!1,dragStartX:0,currentDragX:0},this.dragStart=this.dragStart.bind(this),this.drag=this.drag.bind(this),this.dragEnd=this.dragEnd.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),window.addEventListener("keyup",this.handleKeyUp)}componentWillUnmount(){window.removeEventListener("keyup",this.handleKeyUp)}isInDragLimits(e){return this.props.dragLimits.start<e&&e<this.props.dragLimits.end}getSelectedSpan(){return new Y0(Math.floor(Math.min(this.state.dragStartX,this.state.currentDragX)),Math.floor(Math.max(this.state.dragStartX,this.state.currentDragX)))}dragStart(e){e.preventDefault();const n=kD(e).x;this.isInDragLimits(n)&&this.setState({isDragging:!0,dragStartX:n,currentDragX:n})}drag(e){const n=kD(e).x;this.isInDragLimits(n)&&this.setState({currentDragX:n})}dragEnd(){if(this.state.isDragging){const e=this.getSelectedSpan();this.props.getIsAreaValid(e)&&this.props.onAreaSelected(e),this.setState({isDragging:!1})}}handleKeyUp(e){e.keyCode===JVr&&this.setState({isDragging:!1})}render(){const{mouseButton:e,height:n,y:h,getInnerElement:i,getIsAreaValid:t,children:s}=this.props;let a;if(this.state.isDragging){const o=this.getSelectedSpan();let l="SelectableArea-box";t(o)||(l+=" SelectableArea-box-invalid");const m={left:o.start+"px",top:h,width:o.getLength()+"px",height:n};a=_.jsx("div",{className:l,style:m,children:i(o)})}return _.jsxs($8,{mouseButton:e,onDragStart:this.dragStart,onDrag:this.drag,onDragEnd:this.dragEnd,style:{position:"relative"},children:[a,s]})}}q(qH,"defaultProps",{mouseButton:pU.LEFT,y:"0px",height:"100%",dragLimits:new Y0(-1/0,1/0),getInnerElement:()=>null,getIsAreaValid:()=>!0,onAreaSelected:()=>{}});const jVr=5;class $H extends E.PureComponent{constructor(e){super(e),this.getBoxCaption=this.getBoxCaption.bind(this),this.getIsAreaValid=this.getIsAreaValid.bind(this),this.handleAreaSelect=this.handleAreaSelect.bind(this)}getSelectedBases(e){const{selectableRegion:n,dragLimits:h}=this.props,i=n.getNavigationContext(),t=new Bh(n,h.getLength());return new Y0(s(e.start),s(e.end));function s(a){a-=h.start;const o=t.xToBase(a);return i.toGaplessCoordinate(Math.round(o))}}getIsBaseSpanValid(e){return e.getLength()>=jVr}getIsAreaValid(e){return this.getIsBaseSpanValid(this.getSelectedBases(e))}getBoxCaption(e){const n=this.getSelectedBases(e);return _.jsxs("div",{className:"SelectableArea-box-text-container",children:[_.jsx("h4",{style:{margin:0},children:Ds(n.getLength())}),_.jsx("p",{className:"SelectableArea-box-secondary-text",children:this.getIsBaseSpanValid(n)?"Esc to cancel":"Too small"})]})}handleAreaSelect(e){const n=this.getSelectedBases(e);this.getIsBaseSpanValid(n)&&this.props.onRegionSelected(n.start,n.end,this.props.selectedTool?this.props.selectedTool.title:"isJump")}render(){const{dragLimits:e,y:n,height:h,children:i}=this.props;return _.jsx(qH,{y:n,height:h,dragLimits:e,getInnerElement:this.getBoxCaption,getIsAreaValid:this.getIsAreaValid,onAreaSelected:this.handleAreaSelect,children:i})}}const HVr=({navContext:c,onRegionSelected:e,handleCloseModal:n,onNewHighlight:h,doHighlight:i,color:t,background:s,genomeConfig:a})=>{const o=l=>{const m=c.convertGenomeIntervalToBases(l.getLocus())[0];m?(e(m.start,m.end,"isJump",i),n()):console.log("Gene not available in current region set view","error",2e3)};return _.jsx(jX,{onGeneSelected:o,simpleMode:!1,voiceInput:!0,color:t,background:s,genomeConfig:a})},KVr=250,PVr={hg19:"https://grch37.rest.ensembl.org/variation/human",hg38:"https://rest.ensembl.org/variation/human"},OVr=({genomeConfig:c,navContext:e,onRegionSelected:n,handleCloseModal:h,onNewHighlight:i,doHighlight:t,color:s,background:a})=>{const[o,l]=E.useState(""),[m,d]=E.useState(null),[u,U]=E.useState(""),C=f=>{l(f.target.value)},p=E.useCallback(Qr.debounce(async()=>{const f=o.trim();if(f.length<1){console.log("Please input a valid SNP id.","error",2e3);return}const M=c.genome.getName(),S=PVr[M];if(!S){console.log("This genome is not supported in SNP search.","error",2e3);return}U("searching...");try{const N=await fetch(`${S}/${f}`,{headers:{"Content-Type":"application/json"}});if(!N.ok)throw new Error("Network response was not ok");const x=await N.json();d(x)}catch{console.log("Error fetching SNP data.","error",2e3)}finally{U("")}},KVr),[o,c.genome]),D=f=>{const M=new J0(`chr${f.seq_region_name}`,f.start-1,f.end),S=e.convertGenomeIntervalToBases(M)[0];S?(n(S.start,S.end,"isJump",t),h(),t&&i&&i(S.start,S.end,o.trim())):console.log("SNP not available in current region set view","error",2e3)},A=f=>_.jsx("table",{className:"table table-sm table-striped table-bordered",children:_.jsxs("tbody",{children:[_.jsxs("tr",{children:[_.jsx("td",{children:"name"}),_.jsx("td",{children:f.name})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"location"}),_.jsx("td",{children:_.jsx("ol",{style:{marginBottom:0},children:f.mappings.map((M,S)=>_.jsxs("li",{style:{color:"#3f51b5",textDecoration:"underline",cursor:"pointer"},onClick:()=>D(M),children:["chr",M.location," ",M.strand===1?"+":"-"," ",M.allele_string]},S))})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"ambiguity"}),_.jsx("td",{children:f.ambiguity})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"ancestral_allele"}),_.jsx("td",{children:f.ancestral_allele})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"synonyms"}),_.jsx("td",{children:_.jsx("ol",{style:{marginBottom:0},children:f.synonyms.map((M,S)=>_.jsx("li",{children:M},S))})})]}),_.jsxs("tr",{children:[_.jsx("td",{children:"source"}),_.jsx("td",{children:f.source})]})]})});return _.jsxs("div",{children:[_.jsxs("div",{children:[_.jsx("input",{type:"text",size:20,placeholder:"SNP id",onChange:C,style:{padding:"6px 8px",border:"1px solid #e2e8f0",borderRadius:"4px"}}),_.jsx("button",{className:"btn btn-secondary btn-sm",style:{marginLeft:"2px"},onClick:p,children:"Go"})," ",_.jsx("span",{className:"text-info font-italic",children:u})]}),_.jsx("div",{style:{position:"absolute",zIndex:2,backgroundColor:a,color:s},children:m&&A(m)})]})},rK={content:{position:"fixed",top:"50px",left:"40%",right:"unset",bottom:"unset",overflow:"visible",padding:"5px",borderRadius:"4px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)"},overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(111,107,101, 0.7)",zIndex:9999,display:"flex"}},QVr={cursor:"pointer",color:"red",fontSize:"2em",position:"absolute",top:"-5px",right:"15px"},qVr=({selectedRegion:c,onRegionSelected:e,contentColorSetup:n,virusBrowserMode:h,genomeConfig:i,windowWidth:t=800,fontSize:s,padding:a})=>{const[o,l]=E.useState(!1),[m,d]=E.useState(""),[u,U]=E.useState(!1),C=E.useRef(null),p=()=>l(!0),D=()=>l(!1),A=()=>{U(B=>!B)},f=B=>{B.key==="Enter"&&M()},M=()=>{var T;const B=c.getNavigationContext();let W;try{W=B.parse(((T=C.current)==null?void 0:T.value)||"")}catch(L){if(L instanceof RangeError){d(L.message);return}else throw L}m&&d(""),e(W?W.start:c._startBase,W?W.end:c._endBase,"isJump",u),D()},{color:S,background:N}=n,x=c.currentRegionAsString();return _.jsxs("div",{className:"bg tool-element",style:{fontSize:`${s||Math.max(11,Math.min(15,t*.009))}px`,paddingLeft:a||5},children:[_.jsx("button",{onClick:p,style:{fontSize:`${s||Math.max(11,Math.min(15,t*.009))}px`,cursor:"pointer",background:"none",border:"none",color:"inherit",fontFamily:"inherit",padding:"2px 6px",borderRadius:"6px",transition:"background-color 0.15s ease",textDecoration:"underline",transform:"translateY(.5px)"},onMouseEnter:B=>{B.currentTarget.style.backgroundColor="rgba(0, 0, 0, 0.05)"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="transparent"},children:x}),o&&je.createPortal(_.jsx("div",{style:rK.overlay,onClick:D,role:"dialog","aria-label":"Gene & Region search",children:_.jsxs("div",{style:{...rK.content,color:S,background:N},onClick:B=>B.stopPropagation(),children:[_.jsx("span",{className:"text-right",style:QVr,onClick:D,children:"×"}),_.jsx("div",{children:_.jsxs("span",{children:["Highlight search"," ",_.jsx("input",{type:"checkbox",name:"do-highlight",checked:u,onChange:A})]})}),_.jsx("h6",{children:"Gene search"}),_.jsx(HVr,{navContext:c.getNavigationContext(),onRegionSelected:e,doHighlight:u,handleCloseModal:D,color:S,background:N,genomeConfig:i}),!h&&_.jsxs(_.Fragment,{children:[_.jsx("h6",{style:{marginTop:"5px"},children:"SNP search"}),_.jsx(OVr,{navContext:c.getNavigationContext(),onRegionSelected:e,handleCloseModal:D,color:S,background:N,doHighlight:u,genomeConfig:i})]}),_.jsxs("h6",{children:["Region search (current region is ",x," ",_.jsx(bm,{value:x}),")"]}),_.jsx("input",{ref:C,type:"text",size:30,placeholder:"Coordinate",onKeyDown:f,style:{padding:"6px 8px",border:"1px solid #e2e8f0",borderRadius:"4px"}}),_.jsx("button",{className:"btn btn-secondary btn-sm",style:{marginLeft:"2px"},onClick:M,children:"Go"}),m&&_.jsx("span",{className:"alert-danger",children:m})]})}),document.body)]})};function $Vr({trackState:c,globalTrackState:e}){const n=c.genomicFetchCoord[c.primaryGenName].primaryVisData;if(c.initial===1){let h={initial:0,regionLoci:c.regionLoci[0],visData:c.initVisData[0],side:"left",xDist:0},i={...c,regionLoci:c.regionLoci[1],initial:1,side:"right",visData:c.initVisData[1],xDist:0,startWindow:n.viewWindow.start,visWidth:n.visWidth,viewWindow:c.viewWindow},t={regionLoci:c.regionLoci[2],initial:0,visData:c.initVisData[2],side:"right",xDist:0};e.current.trackStates[e.current.leftIdx]={trackState:h},e.current.leftIdx++,e.current.trackStates[e.current.rightIdx]={trackState:i},e.current.rightIdx--,e.current.trackStates[e.current.rightIdx]={trackState:t},e.current.rightIdx--}else{let h={...c,initial:0,side:c.side,xDist:c.xDist,viewWindow:c.viewWindow,startWindow:n.viewWindow.start,visWidth:n.visWidth};c.side==="right"?(e.current.trackStates[e.current.rightIdx]={trackState:{regionLoci:c.genomicFetchCoord[c.primaryGenName].genomicLoci}},e.current.trackStates[e.current.rightIdx+1]={trackState:h},e.current.rightIdx--):c.side==="left"&&(e.current.trackStates[e.current.leftIdx]={trackState:{regionLoci:c.genomicFetchCoord[c.primaryGenName].genomicLoci}},e.current.trackStates[e.current.leftIdx-1]={trackState:h},e.current.leftIdx++)}}var t9=(c=>(c[c.Drag=0]="Drag",c[c.Reorder=1]="Reorder",c[c.Highlight=2]="Highlight",c[c.Zoom=3]="Zoom",c[c.PanLeft=4]="PanLeft",c[c.PanRight=5]="PanRight",c[c.ZoomOutOneThirdFold=6]="ZoomOutOneThirdFold",c[c.ZoomOutOneFold=7]="ZoomOutOneFold",c[c.ZoomOutFiveFold=8]="ZoomOutFiveFold",c[c.ZoomInOneThirdFold=9]="ZoomInOneThirdFold",c[c.ZoomInOneFold=10]="ZoomInOneFold",c[c.ZoomInFiveFold=11]="ZoomInFiveFold",c[c.highlightMenu=12]="highlightMenu",c[c.ReorderMany=13]="ReorderMany",c))(t9||{});const rFr=new BJ;class eK extends E.PureComponent{render(){const{viewRegion:e,width:n,x:h,y:i}=this.props;return _.jsx(An,{x:h,y:i,children:rFr.design(e,n)})}}q(eK,"propTypes",{viewRegion:Gr.instanceOf(Ze).isRequired,width:Gr.number.isRequired,x:Gr.number,y:Gr.number});const cK=40,s6=50,Xm=50,eFr=11,U2=cK/2-Xm/2,nK=U2+Xm/2+3,hK=15,rA={stroke:"#090",fill:"#0f0",fillOpacity:.25},iK={fontSize:eFr,fontStyle:"italic"};class tK extends E.Component{constructor(e){super(e),this.gotoPressed=this.gotoPressed.bind(this)}gotoPressed(e){let n=this.props.selectedRegion.getContextCoordinates(),h=0;this.props.selectedRegion.getWidth()<this.props.viewRegion.getWidth()?h=this.props.viewRegion.getWidth()*.5:h=this.props.selectedRegion.getWidth()*3;let i=(n.end+n.start)*.5;this.props.onNewViewRequested(i-h,i+h)}render(){const{viewRegion:e,selectedRegion:n,x:h,y:i}=this.props,t=new Bh(e,this.props.width);let s=t.getDrawWidth(),a=n.getContextCoordinates(),o=Math.max(-10,t.baseToX(a.start)),l=Math.min(s+10,t.baseToX(a.end)),m=Math.max(0,l-o);const d=_.jsx("rect",{x:o,y:0,width:m,height:cK,style:rA});let u,U;if(l<=0){const C=[[0,U2+Xm/2],[s6,U2],[s6,U2+Xm]];u=_.jsx("polygon",{points:C,style:rA,onClick:this.gotoPressed}),U=_.jsx("text",{x:hK,y:nK,style:{...iK,textAnchor:"start"},onClick:this.gotoPressed,onMouseDown:p=>p.stopPropagation(),children:"GOTO"})}else if(o>=s){const C=[[s,U2+Xm/2],[s-s6,U2],[s-s6,U2+Xm]];u=_.jsx("polygon",{points:C,style:rA,onClick:this.gotoPressed}),U=_.jsx("text",{x:s-hK,y:nK,style:{...iK,textAnchor:"end"},onClick:this.gotoPressed,onMouseDown:p=>p.stopPropagation(),children:"GOTO"})}return _.jsxs(An,{x:h,y:i,style:{cursor:"pointer"},children:[d,u,U]})}}q(tK,"propTypes",{viewRegion:Gr.instanceOf(Ze).isRequired,width:Gr.number.isRequired,selectedRegion:Gr.instanceOf(Ze).isRequired,onNewViewRequested:Gr.func.isRequired});class cFr extends E.Component{constructor(n){super(n);q(this,"dragOriginRegion");this.dragOriginRegion=null,this.dragStart=this.dragStart.bind(this),this.drag=this.drag.bind(this),this.dragEnd=this.dragEnd.bind(this)}dragStart(n){this.dragOriginRegion=this.props.panRegion,this.props.onViewDragStart&&this.props.onViewDragStart(n)}drag(n,h){if(this.props.onViewDrag){const i=this._getRegionOffsetByX(this.dragOriginRegion,n,h.dx);this.props.onViewDrag(i.start,i.end,n,h)}}dragEnd(n,h){if(this.props.onViewDragEnd){const i=this._getRegionOffsetByX(this.dragOriginRegion,n,h.dx);this.props.onViewDragEnd(i.start,i.end,n,h)}}_getRegionOffsetByX(n,h,i){const t=this.props.basesPerPixel||this.props.panRegion.getWidth()/h.currentTarget.clientWidth,s=Math.round(-1*t*i),a=n.getNavigationContext(),[o,l]=n.getContextCoordinates(),m=a.toGaplessCoordinate(Math.max(0,o+s)),d=a.toGaplessCoordinate(Math.min(l+s,a.getTotalBases()-1));return new Y0(m,d)}render(){const{panRegion:n,onViewDragStart:h,onViewDrag:i,onViewDragEnd:t,basesPerPixel:s,children:a,...o}=this.props;return _.jsx($8,{onDragStart:this.dragStart,onDrag:this.drag,onDragEnd:this.dragEnd,...o,children:a})}}const sK=.2,nFr=100,aK=10,hFr=10,iFr=aK+30,tFr="5px",sFr="60px";class eA extends E.Component{constructor(n){super(n);q(this,"componentRef",E.createRef());this.mousewheel=this.mousewheel.bind(this)}componentDidMount(){this.componentRef.current&&this.componentRef.current.addEventListener("wheel",this.mousewheel)}componentWillUnmount(){this.componentRef.current&&this.componentRef.current.removeEventListener("wheel",this.mousewheel)}mousewheel(n){n.preventDefault();let h=n.currentTarget.clientWidth||n.currentTarget.parentNode.clientWidth,i=n.clientX/h;n.deltaY>0?this.props.onZoom(1+sK,i):n.deltaY<0&&this.props.onZoom(1-sK,i)}render(){const{containerWidth:n,viewRegion:h,selectedRegion:i,onNewViewRequested:t,onRegionSelected:s,genomeConfig:a}=this.props;return n===0?(Ke.env.NODE_ENV!=="test"&&console.warn("Cannot render with a width of 0"),null):_.jsx(cFr,{className:"MainPane MainPane-opaque",mouseButton:pU.RIGHT,onViewDrag:t,panRegion:h,children:_.jsx($H,{selectableRegion:h,dragLimits:new Y0(0,n),y:tFr,height:sFr,onRegionSelected:s,children:_.jsxs("svg",{width:n,height:nFr,onContextMenu:o=>o.preventDefault(),style:{border:"1px solid black"},ref:this.componentRef,children:[_.jsx(nm,{genomeConfig:a,viewRegion:h,width:n,y:aK,x:0}),_.jsx(eK,{viewRegion:h,width:n,y:iFr,x:0}),_.jsx(tK,{width:n,viewRegion:h,selectedRegion:i,onNewViewRequested:t,y:hFr,x:0})]})})})}}q(eA,"propTypes",{containerWidth:Gr.number.isRequired,viewRegion:Gr.instanceOf(Ze).isRequired,selectedRegion:Gr.instanceOf(Ze).isRequired,onRegionSelected:Gr.func,onNewViewRequested:Gr.func,onZoom:Gr.func.isRequired}),q(eA,"defaultProps",{onRegionSelected:()=>{},onNewView:()=>{}});const aFr=5;class oK extends E.Component{constructor(e){super(e),this.state={viewRegion:this._setInitialView(e.selectedRegion)},this.zoom=this.zoom.bind(this),this.setNewView=this.setNewView.bind(this),this.zoomSliderDragged=this.zoomSliderDragged.bind(this)}_setInitialView(e){const n=e.getNavigationContext(),h=e.getFeatureSegments().map(o=>o.feature),i=h[0],t=h[h.length-1],s=n.getFeatureStart(i),a=n.getFeatureStart(t)+t.getLength();return new Ze(n,s,a)}componentDidUpdate(e){const n=this.state.viewRegion.getNavigationContext(),h=this.props.selectedRegion.getNavigationContext();e.selectedRegion.getNavigationContext()!==h&&n!==h?(this.setState({viewRegion:new Ze(h)}),this.setState({viewRegion:this._setInitialView(this.props.selectedRegion)})):e.selectedRegion.getGenomeIntervals()[0].chr!==this.props.selectedRegion.getGenomeIntervals()[0].chr&&this.setState({viewRegion:this._setInitialView(this.props.selectedRegion)})}_setModelState(e,n){let h=this.state.viewRegion.clone();h[e].apply(h,n),!(h.getWidth()<aFr)&&this.setState({viewRegion:h})}zoom(e,n){this._setModelState("zoom",[e,n])}setNewView(e,n){this._setModelState("setRegion",[e,n])}zoomSliderDragged(e){let h=Math.exp(e.target.value)/this.state.viewRegion.getWidth();this._setModelState("zoom",[h])}render(){return _.jsx("div",{children:_.jsx(eA,{viewRegion:this.state.viewRegion,selectedRegion:this.props.selectedRegion,onRegionSelected:this.props.onRegionSelected,onNewViewRequested:this.setNewView,onZoom:this.zoom,containerWidth:this.props.windowWidth,genomeConfig:this.props.genomeConfig})})}}q(oK,"defaultProps",{onRegionSelected:()=>{}});function oFr(){for(var c=arguments.length,e=new Array(c),n=0;n<c;n++)e[n]=arguments[n];return E.useMemo(()=>h=>{e.forEach(i=>i(h))},e)}const a6=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ym(c){const e=Object.prototype.toString.call(c);return e==="[object Window]"||e==="[object global]"}function cA(c){return"nodeType"in c}function I1(c){var e,n;return c?Ym(c)?c:cA(c)&&(e=(n=c.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function nA(c){const{Document:e}=I1(c);return c instanceof e}function s9(c){return Ym(c)?!1:c instanceof I1(c).HTMLElement}function lK(c){return c instanceof I1(c).SVGElement}function wm(c){return c?Ym(c)?c.document:cA(c)?nA(c)?c:s9(c)||lK(c)?c.ownerDocument:document:document:document}const Rs=a6?E.useLayoutEffect:E.useEffect;function hA(c){const e=E.useRef(c);return Rs(()=>{e.current=c}),E.useCallback(function(){for(var n=arguments.length,h=new Array(n),i=0;i<n;i++)h[i]=arguments[i];return e.current==null?void 0:e.current(...h)},[])}function lFr(){const c=E.useRef(null),e=E.useCallback((h,i)=>{c.current=setInterval(h,i)},[]),n=E.useCallback(()=>{c.current!==null&&(clearInterval(c.current),c.current=null)},[]);return[e,n]}function a9(c,e){e===void 0&&(e=[c]);const n=E.useRef(c);return Rs(()=>{n.current!==c&&(n.current=c)},e),n}function o9(c,e){const n=E.useRef();return E.useMemo(()=>{const h=c(n.current);return n.current=h,h},[...e])}function o6(c){const e=hA(c),n=E.useRef(null),h=E.useCallback(i=>{i!==n.current&&(e==null||e(i,n.current)),n.current=i},[]);return[n,h]}function iA(c){const e=E.useRef();return E.useEffect(()=>{e.current=c},[c]),e.current}let tA={};function l9(c,e){return E.useMemo(()=>{if(e)return e;const n=tA[c]==null?0:tA[c]+1;return tA[c]=n,c+"-"+n},[c,e])}function mK(c){return function(e){for(var n=arguments.length,h=new Array(n>1?n-1:0),i=1;i<n;i++)h[i-1]=arguments[i];return h.reduce((t,s)=>{const a=Object.entries(s);for(const[o,l]of a){const m=t[o];m!=null&&(t[o]=m+c*l)}return t},{...e})}}const Em=mK(1),m9=mK(-1);function mFr(c){return"clientX"in c&&"clientY"in c}function sA(c){if(!c)return!1;const{KeyboardEvent:e}=I1(c.target);return e&&c instanceof e}function dFr(c){if(!c)return!1;const{TouchEvent:e}=I1(c.target);return e&&c instanceof e}function aA(c){if(dFr(c)){if(c.touches&&c.touches.length){const{clientX:e,clientY:n}=c.touches[0];return{x:e,y:n}}else if(c.changedTouches&&c.changedTouches.length){const{clientX:e,clientY:n}=c.changedTouches[0];return{x:e,y:n}}}return mFr(c)?{x:c.clientX,y:c.clientY}:null}const d9=Object.freeze({Translate:{toString(c){if(!c)return;const{x:e,y:n}=c;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(c){if(!c)return;const{scaleX:e,scaleY:n}=c;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(c){if(c)return[d9.Translate.toString(c),d9.Scale.toString(c)].join(" ")}},Transition:{toString(c){let{property:e,duration:n,easing:h}=c;return e+" "+n+"ms "+h}}}),dK="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function uFr(c){return c.matches(dK)?c:c.querySelector(dK)}const UFr={display:"none"};function zFr(c){let{id:e,value:n}=c;return E.createElement("div",{id:e,style:UFr},n)}function vFr(c){let{id:e,announcement:n,ariaLiveType:h="assertive"}=c;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return E.createElement("div",{id:e,style:i,role:"status","aria-live":h,"aria-atomic":!0},n)}function CFr(){const[c,e]=E.useState("");return{announce:E.useCallback(h=>{h!=null&&e(h)},[]),announcement:c}}const uK=E.createContext(null);function pFr(c){const e=E.useContext(uK);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(c)},[c,e])}function DFr(){const[c]=E.useState(()=>new Set),e=E.useCallback(h=>(c.add(h),()=>c.delete(h)),[c]);return[E.useCallback(h=>{let{type:i,event:t}=h;c.forEach(s=>{var a;return(a=s[i])==null?void 0:a.call(s,t)})},[c]),e]}const bFr={draggable:`
|
|
1370
1370
|
To pick up a draggable item, press the space bar.
|
|
1371
1371
|
While dragging, use the arrow keys to move the item.
|
|
1372
1372
|
Press space again to drop the item in its new position, or press escape to cancel.
|