hoodini-viz 0.2.4 → 0.2.5

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.
@@ -1,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs } from "./index-7pW9RJyb.js";
1
+ import { g as getDefaultExportFromCjs } from "./index-DK4ArtL_.js";
2
2
  function _mergeNamespaces(K, D) {
3
3
  for (var d = 0; d < D.length; d++) {
4
4
  const E = D[d];
@@ -1,6 +1,6 @@
1
1
  import * as r from "react";
2
2
  import { createPortal as J } from "react-dom";
3
- import { s as Q, i as I, a as U, b as Z, T as ee, C as te, m as re } from "./index-7pW9RJyb.js";
3
+ import { s as Q, i as I, a as U, b as Z, T as ee, C as te, m as re } from "./index-DK4ArtL_.js";
4
4
  const ne = () => (t) => t.targetX, ie = () => (t) => t.targetY, se = () => (t) => t.targetWidth, ae = () => (t) => t.targetHeight, oe = () => (t) => t.targetY + 10, le = () => (t) => Math.max(0, (t.targetHeight - 28) / 2), de = /* @__PURE__ */ Q("div")({
5
5
  name: "DataGridOverlayEditorStyle",
6
6
  class: "gdg-d19meir1",
@@ -1,4 +1,4 @@
1
- import { D as s, c as o, F as t, G as i, d as r, H as l, H as d, e as n, P as D, f as P, R as c, h, j as f, k as H, l as R, n as m, o as u } from "./index-7pW9RJyb.js";
1
+ import { D as s, c as o, F as t, G as i, d as r, H as l, H as d, e as n, P as D, f as P, R as c, h, j as f, k as H, l as R, n as m, o as u } from "./index-DK4ArtL_.js";
2
2
  import { default as G } from "react";
3
3
  export {
4
4
  s as DEFAULT_CONFIG,
@@ -2789,7 +2789,7 @@ DECKGL_FILTER_COLOR(fragColor, geometry);
2789
2789
  `,pr+=`<!-- Format: ${Mn.preset.name} (${Mn.preset.width}×${Mn.preset.height}${Mn.preset.unit}) -->
2790
2790
  `,pr+=`<!-- Scale: ${Mn.scale.toFixed(3)}x -->
2791
2791
  `,pr+=`<!-- Original size: ${Mn.originalWidth.toFixed(0)}×${Mn.originalHeight.toFixed(0)}px -->
2792
- `);const wr=At.background||"#ffffff";pr+=`<rect width='${fn}' height='${mn}' fill='${wr}'/>`;let xr;if(kt)isFinite(Xt)?xr=Gt(Xt)+10:xr=mn-Rt-20;else if(Ot&&xn!==1){const ar=Qt*xn,Qn=pn-Rt,Cn=Qn/2,Bn=Cn-ar/2,In=Bn+ar;xr=In+10,console.log("🖼️ Scale to format ruler calc:",{scaledHeight:ar,availableHeight:Qn,yCenter:Cn,contentStartY:Bn,contentEndY:In,rulerTopY:xr})}else isFinite(Xt)?xr=Gt(Xt)-yn+10:xr=Qt;console.log("🖼️ Ruler positioning:",{useGuidesCrop:kt,useFormatDimensions:Ot,contentScale:xn,actualMinWorldY:Xt,rulerTopY:xr,totalSVGHeight:mn,rulerHeight:Rt});const Dr=bt?xr:mn;pr+="<defs>",pr+=`<clipPath id='viz-clip'><rect x='0' y='0' width='${fn}' height='${Dr}'/></clipPath>`,pr+="</defs>",pr+="<g id='visualization' clip-path='url(#viz-clip)'>";for(const ar of yt){const Qn=ar.props;if(Qn.visible===!1)continue;const Cn=ar.id==="domains"||ar.id.startsWith("domains-"),Bn=ar.id==="region-polygons";if(ar.id==="genes"||ar.id==="protein-polygons"||ar.id==="nucleotide-polygons"||Cn||ar.id==="ncrna-features"||Bn)for(const In of Qn.data){const or=Qn.getPolygon(In),rr=Qn.getFillColor(In);let vr=[0,0,0,255],cr="none",gn=1;if(ar.id==="genes"||ar.id==="ncrna-features"){typeof Qn.getLineColor=="function"?vr=Qn.getLineColor(In):Array.isArray(Qn.getLineColor)&&(vr=Qn.getLineColor);const Or=colorToStr(vr);cr=vr[3]===0||Or==="none"?"none":Or,gn=vt?.gene?.edgeWidth||1}else Cn?(vr=At.text||vt?.colors?.black||[0,0,0,255],cr=colorToStr(vr),gn=vt?.domain?.edgeWidth||1):Bn&&(typeof Qn.getLineColor=="function"?vr=Qn.getLineColor(In):In.strokeColor&&(vr=In.strokeColor),cr=colorToStr(vr),typeof Qn.getLineWidth=="function"?gn=Qn.getLineWidth(In):In.strokeWidth?gn=In.strokeWidth:gn=2);const wn=colorToStr(rr),Xn=getOpacity(rr),tr=getOpacity(vr),Hn=dr(or,It,Nt,Ut,jt);if(!Hn||Hn.length===0)continue;let _n=Hn.map(Or=>Rn(Or)).map((Or,hn)=>hn===0?`M${Or[0]},${Or[1]}`:`L${Or[0]},${Or[1]}`).join(" ")+"Z",yr="";Xn<1&&(yr+=` fill-opacity='${Xn}'`),tr<1&&(yr+=` stroke-opacity='${tr}'`),pr+=`<path d='${_n}' fill='${wn}' stroke='${cr}' stroke-width='${gn}'${yr}/>`}if(ar.id==="region-outlines"){const In=Qn.getDashArray||[6,4],or=Array.isArray(In)?In.join(","):"6,4";for(const rr of Qn.data){let vr=[];if(typeof Qn.getPath=="function"?vr=Qn.getPath(rr):vr=rr.polygon||rr.path||[],!vr||vr.length<2)continue;let cr=[100,100,100,255];if(rr.strokeColor)cr=rr.strokeColor;else if(Qn.getColor)if(typeof Qn.getColor=="function")try{cr=Qn.getColor(rr)}catch{cr=[100,100,100,255]}else Array.isArray(Qn.getColor)&&(cr=Qn.getColor);let gn=rr.strokeWidth||2;if(Qn.getWidth)if(typeof Qn.getWidth=="function")try{gn=Qn.getWidth(rr)}catch{gn=2}else gn=Qn.getWidth;const wn=colorToStr(cr),Xn=getOpacity(cr),tr=Cr(vr,It,Nt,Ut,jt);if(!tr||tr.length===0)continue;const Kn=tr.map(_n=>Rn(_n)).map((_n,yr)=>yr===0?`M${_n[0]},${_n[1]}`:`L${_n[0]},${_n[1]}`).join(" ")+" Z";pr+=`<path d='${Kn}' fill='none' stroke='${wn}' stroke-width='${gn}' stroke-dasharray='${or}'${Xn<1?` stroke-opacity='${Xn}'`:""}/>`}}if(ar.id==="phylo-tree")for(const In of Qn.data){let or=[];typeof Qn.getPath=="function"?or=Qn.getPath(In):Array.isArray(Qn.getPath)&&(or=Qn.getPath);let rr=[0,0,0,255];if(In.color)rr=In.color;else if(Qn.getColor)if(typeof Qn.getColor=="function")try{rr=Qn.getColor(In)}catch{rr=Qn.getColor()}else Array.isArray(Qn.getColor)&&(rr=Qn.getColor);const vr=colorToStr(rr),cr=Cr(or,It,Nt,Ut,jt);if(!cr||cr.length===0)continue;const wn=cr.map(Xn=>Rn(Xn)).map((Xn,tr)=>tr===0?`M${Xn[0]},${Xn[1]}`:`L${Xn[0]},${Xn[1]}`).join(" ");pr+=`<path d='${wn}' fill='none' stroke='${vr}' stroke-width='1'/>`}if(ar.id==="connecting-lines"||ar.id==="hoods")for(const In of Qn.data){const or=In.sourcePosition||(Qn.getSourcePosition?Qn.getSourcePosition(In):[0,0]),rr=In.targetPosition||(Qn.getTargetPosition?Qn.getTargetPosition(In):[0,0]);let vr=[0,0,0,255];if(In.color)vr=In.color;else if(Qn.getColor)if(typeof Qn.getColor=="function")try{vr=Qn.getColor(In)}catch{try{vr=Qn.getColor()}catch{vr=[0,0,0,255]}}else Array.isArray(Qn.getColor)&&(vr=Qn.getColor);let cr=1;if(ar.id==="hoods")cr=vt?.stroke?.hoodWidth||vt?.hood?.width||.25;else if(In.width)cr=In.width;else if(Qn.getWidth)if(typeof Qn.getWidth=="function")try{cr=Qn.getWidth(In)}catch{try{cr=Qn.getWidth()}catch{cr=1}}else cr=Qn.getWidth;const gn=colorToStr(vr),wn=Fr(or[0],or[1],rr[0],rr[1],It,Nt,Ut,jt);if(!wn)continue;const[Xn,tr,Hn,Kn]=wn,[_n,yr]=Rn([Xn,tr]),[Or,hn]=Rn([Hn,Kn]);pr+=`<line x1="${_n}" y1="${yr}" x2="${Or}" y2="${hn}" stroke="${gn}" stroke-width="${cr}" />`}if(ar.id==="nodes"||ar.id==="tree-nodes")for(const In of Qn.data){const or=In.position||(Qn.getPosition?Qn.getPosition(In):[0,0]),rr=In.color||(Qn.getFillColor?Qn.getFillColor(In):[0,0,0,255]),vr=In.radius||(Qn.getRadius?Qn.getRadius(In):5),[cr,gn]=Rn(or);if(!_r([cr,gn]))continue;const wn=colorToStr(rr),Xn=(vr||1)*br;pr+=`<circle cx="${cr}" cy="${gn}" r="${Xn}" fill="${wn}" />`}if(ar.id==="phylo-labels"||ar.id==="gene-labels"||ar.id==="scale-labels")for(const In of Qn.data){const or=In.position||(Qn.getPosition?typeof Qn.getPosition=="function"?Qn.getPosition(In):Qn.getPosition:[0,0]),rr=In.text||(Qn.getText?typeof Qn.getText=="function"?Qn.getText(In):Qn.getText:""),vr=In.color||(Qn.getColor?typeof Qn.getColor=="function"?Qn.getColor(In):Qn.getColor:[0,0,0,255]),cr=In.size||(Qn.getSize?typeof Qn.getSize=="function"?Qn.getSize(In):Qn.getSize:14),gn=colorToStr(vr),wn=getOpacity(vr);let[Xn,tr]=Rn(or);if(!_r([Xn,tr]))continue;const Hn=In.textAnchor||(Qn.getTextAnchor?typeof Qn.getTextAnchor=="function"?Qn.getTextAnchor(In):Qn.getTextAnchor:"start");let Kn=In.pixelOffset;Kn===void 0&&Qn.getPixelOffset&&(typeof Qn.getPixelOffset=="function"?Kn=Qn.getPixelOffset(In):Array.isArray(Qn.getPixelOffset)&&(Kn=Qn.getPixelOffset)),Array.isArray(Kn)&&Kn.length===2&&(Xn+=Kn[0],tr+=Kn[1]);const _n=Math.max(.1,(cr||12)*Wn);let yr="alphabetic",Or=0;if(ar.id==="phylo-labels")yr="middle",Or=0;else if(ar.id==="gene-labels")switch((In.alignmentBaseline||(Qn.getAlignmentBaseline?typeof Qn.getAlignmentBaseline=="function"?Qn.getAlignmentBaseline(In):Qn.getAlignmentBaseline:"top")||"top").toString().toLowerCase()){case"top":yr="hanging",Or=_n*.2;break;case"center":case"middle":yr="middle",Or=0;break;case"bottom":yr="alphabetic",Or=-_n*.25;break;default:yr="middle",Or=0}if(ar.id==="phylo-labels"&&Qn.background){let An=[255,255,255,255];Qn.getBackgroundColor&&(typeof Qn.getBackgroundColor=="function"?An=Qn.getBackgroundColor(In):Array.isArray(Qn.getBackgroundColor)&&(An=Qn.getBackgroundColor));const nr=Qn.backgroundPadding||[2,1,2,1],gr=colorToStr(An),ii=rr.length*_n*.6,ti=_n,di=Xn-nr[0]-(Hn==="middle"?ii/2:Hn==="end"?ii:0),Bi=tr-ti/2-nr[1],as=ii+nr[0]+nr[2],ki=ti+nr[1]+nr[3];pr+=`<rect x="${di}" y="${Bi}" width="${as}" height="${ki}" fill="${gr}" />`}let hn=0;yr==="hanging"?hn=_n*.85:yr==="middle"?hn=_n*.35:(yr==="alphabetic"||yr==="baseline")&&(hn=0);const Ar=tr+Or+hn,hr=wn<1?` fill-opacity="${wn}"`:"";pr+=`<text x="${Xn}" y="${Ar}" fill="${gn}"${hr} font-size="${_n}px" font-family="sans-serif" text-anchor="${Hn}">${rr}</text>`}}if(pr+="</g>",console.log("🎯 Ruler section - checking conditions:",{hasRulerOptions:!!bt,hasConfig:!!bt?.config,hasWidth:typeof bt?.width,hasHeight:typeof bt?.height,hasPrecomputedTicks:!!bt?.precomputedTicks,ticksLength:bt?.precomputedTicks?.length}),bt&&bt.config&&typeof bt.width=="number"&&typeof bt.height=="number"){const{minX:ar,maxX:Qn,config:Cn,viewState:Bn,alignmentReferencePoint:In,bounds:or,genomeView:rr,precomputedTicks:vr}=bt;bt.width,bt.height;const cr=Cn||vt;if(console.log("🎯 Ruler section - inside condition, precomputedTicks:",vr?.length),vr&&Array.isArray(vr)){const _i=At.text||(At.background==="#ffffff"?"#666":"#aaa"),ci=At.text||(At.background==="#ffffff"?"#333":"#ccc"),xi=At.text||(At.background==="#ffffff"?"#666":"#aaa");console.log("🎯 Ruler rendering with rulerScaleFactor:",$n,"base fontSize: 11 -> scaled:",11*$n),cr.ruler.height*$n;const mi=xr,wi=cr.ruler.tickHeight*$n,vi=cr.ruler.labelOffset*$n,qi=11*$n;pr+="<g id='ruler'>";const ji=In||0,ls=(cr.genome&&typeof cr.genome.xScalePercent=="number"?cr.genome.xScalePercent:100)/100,xs=Mi=>Mi*ls+ji,$s=Mi=>{const Wa=xs(Mi.x),[Wi]=Rn([Wa,0]);return Wi},Is=vr.slice(0,3);console.log("🎯 Ruler debug - sample ticks:",Is.map(Mi=>({relativeX:Mi.x,worldX:xs(Mi.x),screenX:Mi.screenX,type:Mi.type,computedSvgX:$s(Mi)}))),console.log("🎯 Ruler debug - bounds:",{min_x:It,max_x:Nt,svgWidth:Vt,xOffset:vn,contentScale:xn,useFormatDimensions:Ot,compactWidth:ln,finalWidth:fn,alignmentRef:ji,genomeXScaleValue:ls});const Hs=vr.filter(Mi=>Mi&&typeof Mi.x=="number"&&isFinite(Mi.x)).map(Mi=>$s(Mi)),ws=10,Es=Math.max(0,Math.min(...Hs)-ws),Ds=Math.min(fn,Math.max(...Hs)+ws);pr+=`<line x1='${Es}' y1='${mi}' x2='${Ds}' y2='${mi}' stroke='${_i}' stroke-width='0.5'/>`;const Fa=vr.filter(Mi=>Mi&&Mi.type&&typeof Mi.x=="number"&&isFinite(Mi.x)).map(Mi=>({...Mi,worldX:xs(Mi.x),screenX:$s(Mi)})).filter(Mi=>Mi.screenX>=0&&Mi.screenX<=fn);console.log("🎯 SVG Export: filtered ticks:",Fa.length,{contentScale:xn,useFormatDimensions:Ot});const oa=bt.showTreeLayer===!0||bt.showTreeTextLayer===!0?Fa.filter(Mi=>Mi.type==="tree"&&Mi.isScale):[],aa=Fa.filter(Mi=>Mi.type==="gene");pr+="<g id='ruler-tree'>";for(const Mi of oa)pr+=`<line x1='${Mi.screenX}' y1='${mi}' x2='${Mi.screenX}' y2='${mi+wi/2}' stroke='${xi}' stroke-width='1'/>`,pr+=`<text x='${Mi.screenX}' y='${mi+vi}' text-anchor='middle' font-size='${qi}px' fill='${xi}' font-family='Helvetica, Arial, sans-serif' font-weight='bold'>${Mi.label}</text>`;pr+="</g>",pr+="<g id='ruler-genes'>";for(const Mi of aa)pr+=`<line x1='${Mi.screenX}' y1='${mi}' x2='${Mi.screenX}' y2='${mi+wi}' stroke='${_i}' stroke-width='1'/>`,pr+=`<text x='${Mi.screenX}' y='${mi+vi}' text-anchor='middle' font-size='${qi}px' fill='${ci}' font-family='Helvetica, Arial, sans-serif'>${formatCoordinate(Mi.x)}</text>`;if(aa.length>1)for(let Mi=0;Mi<aa.length-1;Mi++){const Wa=aa[Mi],Wi=aa[Mi+1];if(Wi.x-Wa.x>20){const ys=Wa.screenX+(Wi.screenX-Wa.screenX)/2;ys>=0&&ys<=fn&&(pr+=`<line x1='${ys}' y1='${mi}' x2='${ys}' y2='${mi+wi/2}' stroke='${_i}' stroke-width='0.5'/>`)}}return pr+="</g>",pr+="</g>",pr+="</svg>",pr}(cr.ruler?.height||36)*$n;const gn=xr,wn=(cr.ruler?.tickHeight||8)*$n,Xn=(cr.ruler?.labelOffset||24)*$n,tr=11*$n,Hn=At.text||(At.background==="#ffffff"?"#666":"#aaa"),Kn=At.text||(At.background==="#ffffff"?"#333":"#ccc"),_n=At.text||(At.background==="#ffffff"?"#666":"#aaa");let yr=null;if(rr&&rr.nucleotidesBySeqid){let _i=1/0;Object.values(rr.nucleotidesBySeqid).forEach(ci=>{ci.hood&&(_i=Math.min(_i,Math.min(ci.hood.start,ci.hood.end)))}),isFinite(_i)&&(yr=_i)}const Or=_i=>{const[ci]=Rn([_i,0]);return ci},hn=yr!==null?Or(yr):0,Ar=[],hr=[],An=[],nr=or?.minX??It,gr=or?.maxX??Nt,ii=In||0,ti=cr.genome&&typeof cr.genome.xScalePercent=="number"?cr.genome.xScalePercent/100:1,di=Math.max(yr!==null?yr:It,It,nr),Bi=Math.min(Nt,gr),as=(di-ii)/ti,ki=(Bi-ii)/ti;if(ki>as){const _i=ki-as,ci=60,xi=ln-hn,mi=Math.floor(xi/ci),wi=Math.max(3,Math.min(8,mi)),vi=_i/wi,qi=Math.pow(10,Math.floor(Math.log10(vi))),ji=vi/qi;let Ni;ji<=1?Ni=1:ji<=2?Ni=2:ji<=5?Ni=5:Ni=10;const ls=Ni*qi,xs=Math.floor(as/ls),$s=Math.ceil(ki/ls);for(let Is=xs;Is<=$s;Is++){const Hs=Is*ls;if(Hs<as-ls*.1||Hs>ki+ls*.1)continue;const ws=Hs*ti+ii,Es=Or(ws);Es>=hn&&Es<=fn&&(hr.push({screenX:Es,label:formatCoordinate(Hs)}),Ar.push(Es))}}if((bt.showTreeLayer===!0||bt.showTreeTextLayer===!0)&&yr!==null&&hn>30&&rr&&rr.tree&&or){const _i=or.treeOffset||0,ci=cr.tree&&typeof cr.tree.xScalePercent=="number"?cr.tree.xScalePercent/100:1,xi=rr.tree.allNodes.map(ls=>ls.y*ci+_i),mi=Math.min(...xi),wi=Math.max(...xi),vi=rr.tree.maxEvolutionaryDistance||1,qi=cr.tree?.fixedCoordinateWidth||2e3,ji=Math.max(mi,It),Ni=Math.min(wi,yr);if(Ni>ji){const xs=Math.floor(hn/60),$s=Math.min(4,Math.max(2,xs));for(let Is=0;Is<$s;Is++){const Hs=ji+Is/Math.max(1,$s-1)*(Ni-ji),ws=Or(Hs),Es=(Hs-_i)/ci*(vi/qi);let Ds;vi<.001?Ds=Es.toExponential(1):vi<.1||vi<1?Ds=Es.toFixed(2):Ds=Es.toFixed(1),ws>=0&&ws<=hn&&(An.push({screenX:ws,label:Ds}),Ar.push(ws))}}}if(pr+="<g id='ruler'>",Ar.length>0){const ci=Math.max(0,Math.min(...Ar)-10),xi=Math.min(fn,Math.max(...Ar)+10);pr+=`<line x1='${ci}' y1='${gn}' x2='${xi}' y2='${gn}' stroke='${Hn}' stroke-width='0.5'/>`}pr+="<g id='ruler-tree'>";for(const _i of An)pr+=`<line x1='${_i.screenX}' y1='${gn}' x2='${_i.screenX}' y2='${gn+wn/2}' stroke='${_n}' stroke-width='1'/>`,pr+=`<text x='${_i.screenX}' y='${gn+Xn}' text-anchor='middle' font-size='${tr}px' fill='${_n}' font-family='Helvetica, Arial, sans-serif' font-weight='bold'>${_i.label}</text>`;pr+="</g>",pr+="<g id='ruler-genes'>";for(const _i of hr)pr+=`<line x1='${_i.screenX}' y1='${gn}' x2='${_i.screenX}' y2='${gn+wn}' stroke='${Hn}' stroke-width='1'/>`,pr+=`<text x='${_i.screenX}' y='${gn+Xn}' text-anchor='middle' font-size='${tr}px' fill='${Kn}' font-family='Helvetica, Arial, sans-serif'>${_i.label}</text>`;pr+="</g>",pr+="</g>"}return pr+="</svg>",pr}function formatCoordinate(yt){const Et=Math.abs(yt);return Et>=1e6?`${(yt/1e6).toFixed(1)}M`:Et>=1e3?`${(yt/1e3).toFixed(1)}K`:Math.round(yt).toString()}const DEBUG_LOGS=!1,HoodiniViz=React.forwardRef(({newickStr:yt,gffFeatures:Et,proteinLinks:xt,nucleotideLinks:vt,domainsByGene:bt,hoods:At,hiddenHoodIds:Ft,visibleGeneIds:Ct,hiddenGeneIds:wt,showScrollbar:St,setGenomeViewRef:Tt,onLegendChange:Rt,alignCluster:Pt,defaultAlign:Lt="start",useDefaultGeneAlignment:kt=!0,showRuler:Ot=!0,onObjectClick:Mt,showSVGWidget:It=!1,proteinMetadata:Nt,domainMetadata:Ut,nonCodingMetadata:jt,colorBy:Vt="cluster",labelBy:zt,treeMetadata:Ht,treeLabelBy:Wt,treeColorBy:Gt,config:qt=DEFAULT_CONFIG$1,ultrametric:Xt=!1,showConnectingLines:Kt=!1,forceUpdateCounter:Jt=1e3,phyloLabelPosition:tn="after-tree",alignLabels:sn=!0,arrowheadHeight:Zt,geneHeight:nn,tipWidthMode:rn,tipWidthFactor:on,tipWidthFixed:ln,genePalette:Qt,domainPalette:fn,phyloPalette:pn,ncRNAPalette:mn,regionPalette:vn,geneColorBy:yn,geneLabelBy:xn,domainColorBy:Mn="domainName",domainSource:$n="all",proteinLinkConfig:Rn,nucleotideLinkConfig:Tn,styleConfig:ir,treeXScale:Jn,adjacencyN:jn=1,showTreeLayer:Wn=!0,showGeneLayer:br=!0,showDomainLayer:Fr=!0,showProteinLinkLayer:Cr=!0,showNucleotideLinkLayer:dr=!0,showNcRNALayer:_r=!0,showRegionsLayer:pr=!0,showGeneTextLayer:wr=!0,showTreeTextLayer:xr=!0,showBaselineLayer:Dr=!0,geneLabelPosition:ar="bottom",flashHood:Qn=null,geneColors:Cn=null,phyloColors:Bn=null,showFormatGuides:In=!1,formatGuidePreset:or=null,scaleExportToFormat:rr=!1,cropToGuides:vr=!0,scaleRulerWithCrop:cr=!0,ySpacing:gn,phyloLabelSize:wn,geneLabelSize:Xn,rulerLabelSize:tr,strokeLineWidth:Hn,genomeXScale:Kn},_n)=>{const yr=reactExports.useRef(0),Or=reactExports.useRef({});React.useEffect(()=>{yr.current+=1;try{const En=["treeXScale","arrowheadHeight","geneHeight","alignmentVersion","paletteVersion","geneColorBy","colorBy","phyloLabelPosition"],kn={treeXScale:Jn,arrowheadHeight:Zt,geneHeight:nn,alignmentVersion:mi,paletteVersion:typeof mo<"u"?mo:null,geneColorBy:yn,colorBy:Vt,phyloLabelPosition:tn};En.filter(Nn=>Or.current[Nn]!==kn[Nn]).length>0,Or.current=kn}catch{}});const{getThemeColors:hn,theme:Ar,resolvedTheme:hr}=useTheme(),An=React.useMemo(()=>hn(hr),[hr]),nr=memoGetPalette,gr=React.useMemo(()=>Ft?Ft instanceof Set?Ft:Array.isArray(Ft)?new Set(Ft):new Set:new Set,[Ft]),ii=React.useCallback(En=>gr.size===0||En==null?!1:gr.has(String(En))||gr.has(Number(En)),[gr]),ti=React.useMemo(()=>wt?wt instanceof Set?wt:Array.isArray(wt)?new Set(wt.map(String)):new Set:new Set,[wt]),di=React.useMemo(()=>{if(!Cn)return null;if(Cn instanceof Map)return Cn;if(typeof Cn=="object"){const En=new Map;for(const[kn,Vn]of Object.entries(Cn))En.set(String(kn),Vn);return En}return null},[Cn]),Bi=React.useMemo(()=>{if(!Bn)return null;if(Bn instanceof Map)return Bn;if(typeof Bn=="object"){const En=new Map;for(const[kn,Vn]of Object.entries(Bn))En.set(String(kn),Vn);return En}return null},[Bn]),as=React.useCallback((En,kn)=>{if(!En)return null;const Vn=kn?.origStart??kn?.start,Nn=kn?.origEnd??kn?.end;return Vn!=null&&Nn!=null?`${En}:${Vn}-${Nn}`:String(En)},[]),ki=React.useMemo(()=>{if(!At||!Array.isArray(At))return"none";try{return At.map(En=>as(En?.hood_id||En?.hoodId||En?.seqid,En)||"").join("|")}catch{return`len:${At.length}`}},[At,as]),Xi=qt&&qt.ruler&&typeof qt.ruler.height=="number"?qt.ruler.height:DEFAULT_CONFIG$1.ruler.height,_i=En=>{if(!Ht)return{};if(Ht[En])return Ht[En];const kn=Object.values(Ht);for(let Vn=0;Vn<kn.length;++Vn){const Nn=kn[Vn];if(Nn&&(Nn.leaf_id==En||Nn.leaf_id===En||Nn.leaf_name==En||Nn.leaf_name===En||Nn.id==En||Nn.id===En||Nn.name==En||Nn.name===En||Nn.originalId==En||Nn.original_id==En))return Nn}return{}},[ci,xi]=reactExports.useState(null),[mi,wi]=reactExports.useState(0),[vi,qi]=reactExports.useState(!1),ji=React.useRef(null),[Ni,ls]=React.useState({width:0,height:0}),[xs,$s]=React.useState(!0),[Is,Hs]=reactExports.useState(qt?.tree?.xScalePercent||DEFAULT_CONFIG$1.tree.xScalePercent),ws=Jn??Is,[Es,Ds]=reactExports.useState({target:[0,0,0],zoom:-2}),[Fa,Ja]=reactExports.useState(null),[oa,aa]=reactExports.useState(null),[Mi,Wa]=reactExports.useState(null),[Wi,Mo]=reactExports.useState(null),[ys,Va]=reactExports.useState(null),[io,Fo]=reactExports.useState(null),[_o,lo]=reactExports.useState(null),[Do,Cl]=reactExports.useState(null),ta=reactExports.useRef(!1),ma=reactExports.useRef(null),cs=reactExports.useRef(null),wa=reactExports.useRef(0),la=reactExports.useRef([]),Sa=React.useRef(null);React.useEffect(()=>{try{console.debug("[HoodiniViz] mounted; initial selectedNode=",ci)}catch{}return()=>{}},[]),React.useEffect(()=>{try{console.debug("[HoodiniViz] selectedNode changed ->",ci&&(ci.id||ci.name||ci))}catch{}},[ci]);const Io=React.useCallback(()=>{Ja(null),Wa(null)},[]),xo=React.useCallback(()=>{lo(null)},[]),Ga=React.useCallback(()=>{ta.current=!1,Fo(null)},[]),wo=React.useCallback(()=>{aa(null),Mo(null)},[]),Fl=React.useCallback(()=>{Va(null)},[]),ca=React.useCallback(()=>{Cl(null)},[]),za=React.useCallback((En,kn=null)=>{if(!En){Io();return}xo(),ca(),Ja(String(En)),kn&&Wa([kn])},[Io,xo,ca]),Uo=React.useCallback(En=>{if(!En){xo();return}ca(),lo([En])},[xo,ca]),Vi=React.useCallback(En=>{if(!En){ca();return}xo(),Cl([En])},[ca,xo]),Os=reactExports.useRef(Qn);reactExports.useEffect(()=>{const En=Os.current;if(Os.current=Qn,ta.current)return;if(!Qn){En&&Fo(null);return}const kn=typeof Qn=="string"?Qn:Qn?.id!=null?String(Qn.id):null;if(!kn||!bs.current){Fo(null);return}const Nn=(bs.current.nucleotideLinks?.filter(Dn=>Dn.hood)||[]).filter(Dn=>{const On=Dn?.hood_id!=null?String(Dn.hood_id):null,Pn=Dn?.seqid!=null?String(Dn.seqid):null;return On===kn||Pn===kn});Fo(Nn.length>0?Nn:null)},[Qn]);const bs=reactExports.useRef(null),$o=reactExports.useRef(null),al=reactExports.useRef(ws),qo=reactExports.useRef(null);reactExports.useRef(null),reactExports.useRef(null);const Da=reactExports.useRef(null),qa=reactExports.useRef(null),Ta=reactExports.useRef([]),Zl=reactExports.useRef(null),$l=reactExports.useRef(null),Ts=reactExports.useRef(null),To=reactExports.useRef(null),Ea=reactExports.useRef(!1),Kr=React.useMemo(()=>Nt?Object.values(Nt):[],[Nt]),gs=React.useMemo(()=>{if(!Kr.length)return null;const En={};for(const kn of Kr){const Vn=kn?.id||kn?.gene_id||kn?.geneId;if(!Vn)continue;const Nn=kn?.cluster??kn?.clusterId??kn?.cluster_id;Nn==null||Nn===""||(En[Vn]=Nn)}return Object.keys(En).length?En:null},[Kr]),Ra=React.useMemo(()=>({}),[]),po=yt&&typeof yt=="string"&&yt.trim()!=="",el=React.useMemo(()=>{if(po||!At||!Array.isArray(At))return null;const En=[...new Set(At.map(kn=>kn?.hood_id||kn?.hoodId||kn?.seqid).filter(Boolean))];return En.sort((kn,Vn)=>{const Nn=String(kn),Dn=String(Vn),On=parseFloat(Nn),Pn=parseFloat(Dn);return!isNaN(On)&&!isNaN(Pn)?On-Pn:Nn.localeCompare(Dn,void 0,{numeric:!0,sensitivity:"base"})}),En.map(String)},[po,At]),tl=React.useMemo(()=>{const En=typeof gn=="number"?gn:qt?.tree?.ySpacing||DEFAULT_CONFIG$1.tree.ySpacing;return{...qt,tree:{...qt?.tree,ySpacing:En}}},[qt,gn]),ll=React.useMemo(()=>{const En=typeof gn=="number"?gn:qt?.tree?.ySpacing||DEFAULT_CONFIG$1.tree.ySpacing,kn=typeof Kn=="number"?Kn:qt?.genome?.xScalePercent||DEFAULT_CONFIG$1.genome.xScalePercent;return{...qt,tree:{...qt?.tree,ySpacing:En},genome:{...qt?.genome,xScalePercent:kn}}},[qt,gn,Kn]),us=React.useMemo(()=>{const En=po?yt:el||[],kn=new PhyloTree(En,tl,Xt),Vn=kn.getLeafNodes().map(Nn=>Nn.name);return kn.layout(Vn),kn},[yt,po,el,Xt,tl,Ra]),si=React.useMemo(()=>{const En=po?yt:el||[],kn=new PhyloTree(En,tl,!1),Vn=kn.getLeafNodes().map(Nn=>Nn.name);return kn.layout(Vn),kn},[yt,po,el,tl,Ra]),Un=React.useMemo(()=>{const En=si.getLeafNodes().map(Nn=>Nn.name),kn=new GenomeView(En,si,ll);if(kn.addFeatures(Et),At&&kn.applyHoods(At),kn.initGenes(),gs&&Object.keys(gs).length>0){kn.proteinClusters={},kn._genesIndexReady||kn._buildGeneIndex();for(const Nn of Object.keys(gs)){const Dn=gs[Nn],On=Dn==null?null:String(Dn).trim(),Pn=kn._genesByOriginalId.get(Nn)||[];for(const Zn of Pn)kn.proteinClusters[Zn]=On}}if(kn.computeTrackPositions(),Pt!=null&&Pt!=="")kn.alignCluster(String(Pt));else{const Nn=Object.values(kn.hoodRanges||{}).some(Dn=>Dn.align_gene);kt&&Nn?kn.alignByDefaultGenes():Lt==="center"?kn.alignAllToCenter():Lt==="end"?kn.alignAllToEnd():kn.alignAllToStart()}if(kn.addDomains(bt),Ut&&kn.addDomainMetadata(Ut),kn.addProteinLinks(xt,[200,200,200,255],jn),kn.addNucleotideLinks(vt,[200,200,200,255],jn),Nt&&Object.keys(Nt).length>0){performance.now();for(const Nn in kn.genesById){const Dn=kn.genesById[Nn],On=Dn.originalGeneId;On&&Nt[On]?Dn.metadata=Nt[On]:Dn.metadata={}}if(gs&&kn.proteinClusters){kn._clusterSummary=null;for(const Nn in kn.genesById){const Dn=kn.genesById[Nn],On=kn.proteinClusters[Nn];Dn.metadata||(Dn.metadata={}),Dn.metadata.clusterId=On||null}}performance.now()}const Vn=Nn=>{if(!Nn||typeof Nn!="object")return Nn;const Dn={...Nn};return Dn.sequence||(Dn.sequence=Dn.rna_sequence||Dn.sequence_nt||Dn.nucleotide_sequence||Dn.rna_seq||Dn.seq||null),Dn.structure||(Dn.structure=Dn.secondary_structure||Dn.dot_bracket||Dn.dbn||Dn.structure_dbn||null),Dn.type||(Dn.type=Dn.ncrna_type||Dn.rna_type||Dn.subtype||null),Dn};if(jt&&Object.keys(jt).length>0)for(const Nn in kn.ncRNAsById){const Dn=kn.ncRNAsById[Nn],On=Number.isFinite(Number(Dn.genomicStart))?Number(Dn.genomicStart):null,Pn=Number.isFinite(Number(Dn.genomicEnd))?Number(Dn.genomicEnd):null;let Zn=!1;if(On!==null&&Pn!==null){const sr=`${Dn.seqid}:${On}:${Pn}`;if(jt[sr]&&(Dn.metadata={...Dn.metadata||{},...Vn(jt[sr])},Zn=!0),!Zn){const fr=`${Dn.seqid}:${Pn}:${On}`;jt[fr]&&(Dn.metadata={...Dn.metadata||{},...Vn(jt[fr])},Zn=!0)}}if(!Zn){const sr=Number.isFinite(Number(Dn.start))?Number(Dn.start):null,fr=Number.isFinite(Number(Dn.end))?Number(Dn.end):null;if(sr!==null&&fr!==null){const mr=`${Dn.seqid}:${sr}:${fr}`;jt[mr]&&(Dn.metadata={...Dn.metadata||{},...Vn(jt[mr])},Zn=!0)}}if(!Zn){const sr=Dn.id||Dn.originalId;sr&&jt[sr]&&(Dn.metadata={...Dn.metadata||{},...Vn(jt[sr])},Zn=!0)}Zn||Dn.metadata||(Dn.metadata={})}else for(const Nn in kn.ncRNAsById){const Dn=kn.ncRNAsById[Nn];Dn.metadata||(Dn.metadata={})}return bs.current=kn,performance.now(),kn},[si,ll,Et?Et.length:0,xt?xt.length:0,vt?vt.length:0,bt?Object.keys(bt).length:0,ki,Nt?Object.keys(Nt).length:0,Ut?Object.keys(Ut).length:0,gs?Object.keys(gs).length:0,jt?Object.keys(jt).length:0,Pt,kt,Lt,Ra]);reactExports.useEffect(()=>{xi(null)},[us]),reactExports.useEffect(()=>{if(!Un)return;const En=Qt||qt?.colorPalettes?.genePalette;gs&&Un.setProteinClustersWithPalette(gs,En);const kn=mn||qt?.colorPalettes?.ncRNAPalette;Un.setNcRNAColorsWithPalette(kn);const Vn=vn||qt?.colorPalettes?.regionPalette;Un.setRegionColorsWithPalette(Vn),wi(Nn=>Nn+1)},[Un,Qt,mn,vn,gs,qt?.colorPalettes]),reactExports.useEffect(()=>{Jt>0&&(Ea.current=!0,wi(En=>En+1))},[Jt]);const pi=React.useRef(Kn),zi=React.useRef(Lt),Zi=React.useRef(Pt),bi=React.useRef(kt),Fi=React.useRef(gn),ts=React.useRef(0),Gi=React.useMemo(()=>{if(!Un)return`empty-${ts.current}`;const En=Un.config?.genome?.xScalePercent,kn=Kn??En??30;En!==kn&&(Un.config={...Un.config,genome:{...Un.config?.genome,xScalePercent:kn}});const Vn=pi.current!==Kn,Nn=zi.current!==Lt,Dn=Zi.current!==Pt,On=bi.current!==kt,Pn=Fi.current!==gn;if(Vn||Nn||Dn||On){if(pi.current=Kn,zi.current=Lt,Zi.current=Pt,bi.current=kt,Pt!=null&&Pt!=="")Un.alignCluster(String(Pt));else{const Zn=Object.values(Un.hoodRanges||{}).some(sr=>sr.align_gene);kt&&Zn?Un.alignByDefaultGenes():Lt==="center"?Un.alignAllToCenter():Lt==="end"?Un.alignAllToEnd():Un.alignAllToStart()}ts.current++}return Pn&&(Fi.current=gn),`${Kn}-${Lt}-${Pt||""}-${kt}-${gn}-${ts.current}`},[Un,Kn,Lt,Pt,kt,gn]),hs=React.useMemo(()=>{if(!us)return 100;const En=mr=>{if(!Ht)return{};if(Ht[mr])return Ht[mr];const Pr=Object.values(Ht);for(let Ur=0;Ur<Pr.length;++Ur){const Rr=Pr[Ur];if(Rr&&(Rr.leaf_id==mr||Rr.leaf_id===mr||Rr.leaf_name==mr||Rr.leaf_name===mr||Rr.id==mr||Rr.id===mr||Rr.name==mr||Rr.name===mr||Rr.originalId==mr||Rr.original_id==mr))return Rr}return{}},kn=Wt?Array.isArray(Wt)?Wt:Wt.split(",").map(mr=>mr.trim()).filter(Boolean):null,Nn=us.leafNodes.map(mr=>{const Pr=En(mr.name)||{};let Ur;if(kn&&kn.length>0){const Rr=kn.map(Wr=>Wr==="name"?mr.name:Pr[Wr]).filter(Wr=>Wr!=null&&Wr!=="");Ur=Rr.length>0?Rr.join(" | "):mr.name}else Ur=Pr[Wt],Ur==null&&(Ur=mr.name);return String(Ur)}).reduce((mr,Pr)=>Math.max(mr,Pr.length),0),Dn=qt.tree.labelPadding.charWidth,On=Nn*Dn,Pn=typeof wn=="number"?wn:qt?.text?.phyloLabelSize||14,Zn=qt?.text?.scaleFactors?.phylo||1,fr=Pn*Zn*5;return On+fr},[us,Ht,Wt,qt,wn]),Rs=React.useMemo(()=>{if(!us)return new Map;const En=Nn=>{if(!Ht)return{};if(Ht[Nn])return Ht[Nn];const Dn=Object.values(Ht);for(let On=0;On<Dn.length;++On){const Pn=Dn[On];if(Pn&&(Pn.leaf_id==Nn||Pn.leaf_name==Nn||Pn.id==Nn||Pn.name==Nn))return Pn}return{}},kn=Wt?Array.isArray(Wt)?Wt:Wt.split(",").map(Nn=>Nn.trim()).filter(Boolean):null,Vn=new Map;return us.leafNodes.forEach(Nn=>{const Dn=En(Nn.name)||{};let On;if(kn&&kn.length>0){const Pn=kn.map(Zn=>Zn==="name"?Nn.name:Dn[Zn]).filter(Zn=>Zn!=null&&Zn!=="");On=Pn.length>0?Pn.join(" | "):Nn.name}else On=Dn[Wt],On==null&&(On=Nn.name);Vn.set(String(Nn.name),String(On).length)}),Vn},[us,Ht,Wt]);function vo(En,kn,Vn="after-tree",Nn=null,Dn=!0,On=null){let Pn=1/0,Zn=1/0,sr=-1/0,fr=-1/0,mr=1/0,Pr=null;if(!En)return qt.layout.containerFallback;const Ur=On&&On.size>0;Ur?(Object.values(En.genesById).forEach(Si=>{On.has(String(Si.hood_id))&&Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})}),Object.values(En.ncRNAsById).forEach(Si=>{On.has(String(Si.hood_id))&&Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})}),En.getAllDomains().forEach(Si=>{const Ci=Si.parentGene;Ci&&!On.has(String(Ci.hood_id))||Si.polygon&&Si.polygon.forEach(([Ai,Xs])=>{Pn=Math.min(Pn,Ai),sr=Math.max(sr,Ai)})})):En.globalMin!==1/0&&En.globalMax!==-1/0?(Pn=En.globalMin,sr=En.globalMax):(Object.values(En.genesById).forEach(Si=>{Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})}),Object.values(En.ncRNAsById).forEach(Si=>{Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})}),En.getAllDomains().forEach(Si=>{Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})})),Object.values(En.genesById).forEach(Si=>{Ur&&!On.has(String(Si.hood_id))||Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Zn=Math.min(Zn,Ai),fr=Math.max(fr,Ai)})}),Object.values(En.ncRNAsById).forEach(Si=>{Ur&&!On.has(String(Si.hood_id))||Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Zn=Math.min(Zn,Ai),fr=Math.max(fr,Ai)})}),En.getAllDomains().forEach(Si=>{const Ci=Si.parentGene;Ur&&Ci&&!On.has(String(Ci.hood_id))||Si.polygon&&Si.polygon.forEach(([Ai,Xs])=>{Zn=Math.min(Zn,Xs),fr=Math.max(fr,Xs)})});const Rr=En.leaves&&En.leaves.length>0,Wr=Rr?new Set:null;if(Rr){const Si=new Set(En.leaves.map(Ci=>String(Ci)));for(const Ci of Si){const Ai=En.hoodToSeqidMap[Ci];Ai&&Wr.add(Ai)}}let $r=-1/0;const qr=Nn!==null?Nn/100:qt.tree&&typeof qt.tree.xScalePercent=="number"?qt.tree.xScalePercent/100:1;if(kn){let Si=null;if(Ur&&On&&On.size>0){Si=new Set;for(const Ci of kn.allNodes)if((!Ci.branchset||Ci.branchset.length===0)&&(On.has(String(Ci.name))||On.has(String(Ci.id)))){let Xs=Ci;for(;Xs;)Si.add(String(Xs.id||Xs.name)),Xs=Xs.parent}}kn.buildEdges().forEach(Ci=>{if(Si){const Ai=String(Ci.source?.id||Ci.source?.name),Xs=String(Ci.target?.id||Ci.target?.name);if(!Si.has(Ai)&&!Si.has(Xs))return}Ci.path.forEach(([Ai,Xs])=>{$r=Math.max($r,Ai*qr)})})}const Vr=Ur?isFinite(Pn)?Pn:isFinite(mr)?mr:-1/0:isFinite(En.globalMin)?En.globalMin:isFinite(mr)?mr:isFinite(Pn)?Pn:-1/0,ri=isFinite(Vr)?qt.layout.geneOffset-Vr:0,Ei=qt.tree.gap,Di=isFinite(Vr)?Vr:Pn,Hi=Vn||qt.tree?.phyloLabelPosition||"after-tree";let Pi=0;if(Hi==="after-tree"&&kn){const Si=Ur&&On?kn.leafNodes.filter(Ci=>On.has(String(Ci.name))||On.has(String(Ci.id))):kn.leafNodes;if(Si.length>0){const Ci=qt.tree.labelPadding.charWidth,Ai=typeof wn=="number"?wn:qt?.text?.phyloLabelSize||14,Xs=qt?.text?.scaleFactors?.phylo||1,fa=Ai*Xs*5;Pi=Si.reduce((Qs,Ia)=>{const ba=Rs.get(String(Ia.name))??String(Ia.name).length;return Math.max(Qs,ba)},0)*Ci+fa}}const Qi=isFinite($r)&&isFinite(Di)?Di-$r-Ei-Pi:0;if(kn&&Dn&&isFinite(Qi)){let Si=1/0;kn.buildEdges().forEach(Ci=>{Ci.path.forEach(([Ai,Xs])=>{Si=Math.min(Si,Ai*qr+Qi)})}),isFinite(Si)&&(Pn=Math.min(Pn,Si))}if(!isFinite(Pn)||!isFinite(Zn)||!isFinite(sr)||!isFinite(fr)){const Si=qt.layout.containerFallback;Pn=Si.minX,Zn=Si.minY,sr=Si.maxX,fr=Si.maxY}return{minX:Pn,minY:Zn,maxX:sr,maxY:fr,treeOffset:Qi,geneOffset:ri}}React.useEffect(()=>{const En=ji.current;if(!En)return;const kn={w:-1,h:-1};let Vn=0;const Nn=new ResizeObserver(Pn=>{const{width:Zn,height:sr}=Pn[0].contentRect,fr=Math.floor(Zn),mr=Math.floor(sr);fr===kn.w&&mr===kn.h||(kn.w=fr,kn.h=mr,Vn&&cancelAnimationFrame(Vn),Vn=requestAnimationFrame(()=>ls({width:fr,height:mr})))});Nn.observe(En);const Dn=En.clientWidth||0,On=En.clientHeight||0;return kn.w=Dn,kn.h=On,ls({width:Dn,height:On}),()=>{Nn.disconnect(),Vn&&cancelAnimationFrame(Vn)}},[ji.current]);function go(En){if(!En)return null;const kn=En.leaves.some(On=>En.trackOffset&&En.trackOffset[On]!==void 0&&En.trackOffset[On]!==0),Vn=(Lt==="start"||Lt==="center"||Lt==="end")&&En.leaves.some(On=>En.trackOffset&&En.trackOffset[On]!==void 0),Nn=Pt!=null&&Pt!=="";return!kn&&!Vn&&!Nn&&!!!kt?null:0}const ms=React.useMemo(()=>{const En=bs.current;if(!En||!us||!ci)return null;try{const kn=typeof En.getNodeDescendantLeaves=="function"?En.getNodeDescendantLeaves(ci):us&&typeof us.getNodeDescendantLeaves=="function"?us.getNodeDescendantLeaves(ci):[],Vn=Array.isArray(kn)?kn:[];return new Set(Vn.map(Nn=>String(Nn)))}catch{return null}},[us,ci]),Ii=React.useMemo(()=>vo(bs.current,us,tn,ws,!1,ms),[us,tn,ws,Gi,Kn,gn,nn,Zt,ms,wn,Rs]),Ui=React.useMemo(()=>po?vo(bs.current,us,tn,ws,!0,ms):Ii,[po,us,tn,ws,Gi,Ii,Kn,gn,nn,Zt,ms,wn,Rs]);React.useEffect(()=>{isFinite(Ii.minY)&&isFinite(Ii.maxY)&&Ii.maxY>Ii.minY&&isFinite(Ii.minX)&&isFinite(Ii.maxX)&&(Sa.current={minY:Ii.minY,maxY:Ii.maxY,minX:Ii.minX,maxX:Ii.maxX,ySpacing:gn,genomeXScale:Kn})},[Ii.minY,Ii.maxY,Ii.minX,Ii.maxX,gn,Kn,nn,Zt,ws]);const Fs=React.useRef(!1);React.useEffect(()=>{if(Fs.current||!Ni.width||!Ni.height||!isFinite(Ui.minX)||!isFinite(Ui.maxX)||!isFinite(Ui.minY)||!isFinite(Ui.maxY))return;const En=Ui.maxX-Ui.minX,kn=Ui.maxY-Ui.minY;if(En<=0||kn<=0)return;const Vn=.5,Nn=Math.log2(Ni.width*Vn/En),Dn=Math.log2(Ni.height*Vn/kn),On=Math.min(Nn,Dn),Pn=Math.max(-5,Math.min(2,On)),Zn=(Ui.minX+Ui.maxX)/2,sr=(Ui.minY+Ui.maxY)/2;Ds(fr=>({...fr,target:[Zn,sr,0],zoom:Pn})),Fs.current=!0},[Ni.width,Ni.height,Ui.minX,Ui.maxX,Ui.minY,Ui.maxY]);const Ws=Sa.current||Ii,Ba=Ws.minY,ua=Ws.maxY,Oo=Ws.minX??Ii.minX,jo=Ws.maxX??Ii.maxX,qs=qt?.scrollbar?.panPaddingY??50,Ya=Ba-qs,Yo=ua+qs,[wl,cl]=React.useState(0);React.useEffect(()=>{if(Es&&isFinite(Es.target[1])&&isFinite(Ba)&&isFinite(ua)&&ua>Ba){const En=(ua-Es.target[1])/(ua-Ba)*100;cl(Math.max(0,Math.min(100,En)))}},[Es?.target?.[1],Ba,ua]);let As=1;if(Es&&Ni.height&&ua>Ba){const En=Math.pow(2,Es.zoom||0),kn=Ni.height/En;As=Math.min(1,kn/(ua-Ba))}function Po(En,kn,Vn,Nn,Dn,On,Pn="bottom",Zn=null,sr=100,fr=150){const mr=Vr=>{if(Array.isArray(Vr))return Vr.length===3?[Vr[0],Vr[1],Vr[2],255]:Vr;if(typeof Vr=="string"){const ri=Vr.split(",").map(Ei=>parseInt(Ei.trim(),10)).filter(Ei=>!isNaN(Ei));if(ri.length===3)return[ri[0],ri[1],ri[2],255];if(ri.length>=4)return[ri[0],ri[1],ri[2],ri[3]]}return Array.isArray(Dn.geneFill)?Dn.geneFill:[150,150,150,255]},Pr=Vr=>{if(!hi?.enabled)return mr(Dn.geneFill);const ri=Vn||Nn||"cluster";let Ei=Vr?.metadata?.[ri];(Ei==null||Ei==="")&&ri==="cluster"&&(Ei=Vr?.metadata?.clusterId??Vr?.metadata?.cluster_id??Vr?.cluster);let Di=null;return kn&&!Ls(Ei)&&(Di=ya(kn,normalizeKey(Ei),hi?.type)||null),mr(Di||Vr.fillColor||Dn.geneFill)},Ur=(Vr,ri,Ei,Di=1/0)=>{const Hi=Ei*.6,Pi=Math.max(3,Math.floor(ri/Hi));if(Vr.length<=Pi)return Vr;const Qi=[];let Si=Vr;for(;Si.length>Pi&&Qi.length<Di;){let Ci=Pi;const Ai=Si.substring(0,Pi),Xs=Math.floor(Pi*.7);for(let Ks=Pi-1;Ks>=Xs;Ks--){const fa=Ai[Ks];if(fa==="_"||fa==="-"||fa===" "||fa==="|"){Ci=Ks+1;break}}Qi.push(Si.substring(0,Ci).trim()),Si=Si.substring(Ci).trim()}if(Si&&Qi.length<Di)Qi.push(Si);else if(Si&&Qi.length>=Di){const Ci=Qi[Qi.length-1],Ai=Ci.length>3?Ci.substring(0,Ci.length-3)+"...":"...";Qi[Qi.length-1]=Ai}return Qi.join(`
2792
+ `);const wr=At.background||"#ffffff";pr+=`<rect width='${fn}' height='${mn}' fill='${wr}'/>`;let xr;if(kt)isFinite(Xt)?xr=Gt(Xt)+10:xr=mn-Rt-20;else if(Ot&&xn!==1){const ar=Qt*xn,Qn=pn-Rt,Cn=Qn/2,Bn=Cn-ar/2,In=Bn+ar;xr=In+10,console.log("🖼️ Scale to format ruler calc:",{scaledHeight:ar,availableHeight:Qn,yCenter:Cn,contentStartY:Bn,contentEndY:In,rulerTopY:xr})}else isFinite(Xt)?xr=Gt(Xt)-yn+10:xr=Qt;console.log("🖼️ Ruler positioning:",{useGuidesCrop:kt,useFormatDimensions:Ot,contentScale:xn,actualMinWorldY:Xt,rulerTopY:xr,totalSVGHeight:mn,rulerHeight:Rt});const Dr=bt?xr:mn;pr+="<defs>",pr+=`<clipPath id='viz-clip'><rect x='0' y='0' width='${fn}' height='${Dr}'/></clipPath>`,pr+="</defs>",pr+="<g id='visualization' clip-path='url(#viz-clip)'>";for(const ar of yt){const Qn=ar.props;if(Qn.visible===!1)continue;const Cn=ar.id==="domains"||ar.id.startsWith("domains-"),Bn=ar.id==="region-polygons";if(ar.id==="genes"||ar.id==="protein-polygons"||ar.id==="nucleotide-polygons"||Cn||ar.id==="ncrna-features"||Bn)for(const In of Qn.data){const or=Qn.getPolygon(In),rr=Qn.getFillColor(In);let vr=[0,0,0,255],cr="none",gn=1;if(ar.id==="genes"||ar.id==="ncrna-features"){typeof Qn.getLineColor=="function"?vr=Qn.getLineColor(In):Array.isArray(Qn.getLineColor)&&(vr=Qn.getLineColor);const Or=colorToStr(vr);cr=vr[3]===0||Or==="none"?"none":Or,gn=vt?.gene?.edgeWidth||1}else Cn?(vr=At.text||vt?.colors?.black||[0,0,0,255],cr=colorToStr(vr),gn=vt?.domain?.edgeWidth||1):Bn&&(typeof Qn.getLineColor=="function"?vr=Qn.getLineColor(In):In.strokeColor&&(vr=In.strokeColor),cr=colorToStr(vr),typeof Qn.getLineWidth=="function"?gn=Qn.getLineWidth(In):In.strokeWidth?gn=In.strokeWidth:gn=2);const wn=colorToStr(rr),Xn=getOpacity(rr),tr=getOpacity(vr),Hn=dr(or,It,Nt,Ut,jt);if(!Hn||Hn.length===0)continue;let _n=Hn.map(Or=>Rn(Or)).map((Or,hn)=>hn===0?`M${Or[0]},${Or[1]}`:`L${Or[0]},${Or[1]}`).join(" ")+"Z",yr="";Xn<1&&(yr+=` fill-opacity='${Xn}'`),tr<1&&(yr+=` stroke-opacity='${tr}'`),pr+=`<path d='${_n}' fill='${wn}' stroke='${cr}' stroke-width='${gn}'${yr}/>`}if(ar.id==="region-outlines"){const In=Qn.getDashArray||[6,4],or=Array.isArray(In)?In.join(","):"6,4";for(const rr of Qn.data){let vr=[];if(typeof Qn.getPath=="function"?vr=Qn.getPath(rr):vr=rr.polygon||rr.path||[],!vr||vr.length<2)continue;let cr=[100,100,100,255];if(rr.strokeColor)cr=rr.strokeColor;else if(Qn.getColor)if(typeof Qn.getColor=="function")try{cr=Qn.getColor(rr)}catch{cr=[100,100,100,255]}else Array.isArray(Qn.getColor)&&(cr=Qn.getColor);let gn=rr.strokeWidth||2;if(Qn.getWidth)if(typeof Qn.getWidth=="function")try{gn=Qn.getWidth(rr)}catch{gn=2}else gn=Qn.getWidth;const wn=colorToStr(cr),Xn=getOpacity(cr),tr=Cr(vr,It,Nt,Ut,jt);if(!tr||tr.length===0)continue;const Kn=tr.map(_n=>Rn(_n)).map((_n,yr)=>yr===0?`M${_n[0]},${_n[1]}`:`L${_n[0]},${_n[1]}`).join(" ")+" Z";pr+=`<path d='${Kn}' fill='none' stroke='${wn}' stroke-width='${gn}' stroke-dasharray='${or}'${Xn<1?` stroke-opacity='${Xn}'`:""}/>`}}if(ar.id==="phylo-tree")for(const In of Qn.data){let or=[];typeof Qn.getPath=="function"?or=Qn.getPath(In):Array.isArray(Qn.getPath)&&(or=Qn.getPath);let rr=[0,0,0,255];if(In.color)rr=In.color;else if(Qn.getColor)if(typeof Qn.getColor=="function")try{rr=Qn.getColor(In)}catch{rr=Qn.getColor()}else Array.isArray(Qn.getColor)&&(rr=Qn.getColor);const vr=colorToStr(rr),cr=Cr(or,It,Nt,Ut,jt);if(!cr||cr.length===0)continue;const wn=cr.map(Xn=>Rn(Xn)).map((Xn,tr)=>tr===0?`M${Xn[0]},${Xn[1]}`:`L${Xn[0]},${Xn[1]}`).join(" ");pr+=`<path d='${wn}' fill='none' stroke='${vr}' stroke-width='1'/>`}if(ar.id==="connecting-lines"||ar.id==="hoods")for(const In of Qn.data){const or=In.sourcePosition||(Qn.getSourcePosition?Qn.getSourcePosition(In):[0,0]),rr=In.targetPosition||(Qn.getTargetPosition?Qn.getTargetPosition(In):[0,0]);let vr=[0,0,0,255];if(In.color)vr=In.color;else if(Qn.getColor)if(typeof Qn.getColor=="function")try{vr=Qn.getColor(In)}catch{try{vr=Qn.getColor()}catch{vr=[0,0,0,255]}}else Array.isArray(Qn.getColor)&&(vr=Qn.getColor);let cr=1;if(ar.id==="hoods")cr=vt?.stroke?.hoodWidth||vt?.hood?.width||.25;else if(In.width)cr=In.width;else if(Qn.getWidth)if(typeof Qn.getWidth=="function")try{cr=Qn.getWidth(In)}catch{try{cr=Qn.getWidth()}catch{cr=1}}else cr=Qn.getWidth;const gn=colorToStr(vr),wn=Fr(or[0],or[1],rr[0],rr[1],It,Nt,Ut,jt);if(!wn)continue;const[Xn,tr,Hn,Kn]=wn,[_n,yr]=Rn([Xn,tr]),[Or,hn]=Rn([Hn,Kn]);pr+=`<line x1="${_n}" y1="${yr}" x2="${Or}" y2="${hn}" stroke="${gn}" stroke-width="${cr}" />`}if(ar.id==="nodes"||ar.id==="tree-nodes")for(const In of Qn.data){const or=In.position||(Qn.getPosition?Qn.getPosition(In):[0,0]),rr=In.color||(Qn.getFillColor?Qn.getFillColor(In):[0,0,0,255]),vr=In.radius||(Qn.getRadius?Qn.getRadius(In):5),[cr,gn]=Rn(or);if(!_r([cr,gn]))continue;const wn=colorToStr(rr),Xn=(vr||1)*br;pr+=`<circle cx="${cr}" cy="${gn}" r="${Xn}" fill="${wn}" />`}if(ar.id==="phylo-labels"||ar.id==="gene-labels"||ar.id==="scale-labels")for(const In of Qn.data){const or=In.position||(Qn.getPosition?typeof Qn.getPosition=="function"?Qn.getPosition(In):Qn.getPosition:[0,0]),rr=In.text||(Qn.getText?typeof Qn.getText=="function"?Qn.getText(In):Qn.getText:""),vr=In.color||(Qn.getColor?typeof Qn.getColor=="function"?Qn.getColor(In):Qn.getColor:[0,0,0,255]),cr=In.size||(Qn.getSize?typeof Qn.getSize=="function"?Qn.getSize(In):Qn.getSize:14),gn=colorToStr(vr),wn=getOpacity(vr);let[Xn,tr]=Rn(or);if(!_r([Xn,tr]))continue;const Hn=In.textAnchor||(Qn.getTextAnchor?typeof Qn.getTextAnchor=="function"?Qn.getTextAnchor(In):Qn.getTextAnchor:"start");let Kn=In.pixelOffset;Kn===void 0&&Qn.getPixelOffset&&(typeof Qn.getPixelOffset=="function"?Kn=Qn.getPixelOffset(In):Array.isArray(Qn.getPixelOffset)&&(Kn=Qn.getPixelOffset)),Array.isArray(Kn)&&Kn.length===2&&(Xn+=Kn[0],tr+=Kn[1]);const _n=Math.max(.1,(cr||12)*Wn);let yr="alphabetic",Or=0;if(ar.id==="phylo-labels")yr="middle",Or=0;else if(ar.id==="gene-labels")switch((In.alignmentBaseline||(Qn.getAlignmentBaseline?typeof Qn.getAlignmentBaseline=="function"?Qn.getAlignmentBaseline(In):Qn.getAlignmentBaseline:"top")||"top").toString().toLowerCase()){case"top":yr="hanging",Or=_n*.2;break;case"center":case"middle":yr="middle",Or=0;break;case"bottom":yr="alphabetic",Or=-_n*.25;break;default:yr="middle",Or=0}if(ar.id==="phylo-labels"&&Qn.background){let An=[255,255,255,255];Qn.getBackgroundColor&&(typeof Qn.getBackgroundColor=="function"?An=Qn.getBackgroundColor(In):Array.isArray(Qn.getBackgroundColor)&&(An=Qn.getBackgroundColor));const nr=Qn.backgroundPadding||[2,1,2,1],gr=colorToStr(An),ii=rr.length*_n*.6,ti=_n,di=Xn-nr[0]-(Hn==="middle"?ii/2:Hn==="end"?ii:0),Bi=tr-ti/2-nr[1],as=ii+nr[0]+nr[2],ki=ti+nr[1]+nr[3];pr+=`<rect x="${di}" y="${Bi}" width="${as}" height="${ki}" fill="${gr}" />`}let hn=0;yr==="hanging"?hn=_n*.85:yr==="middle"?hn=_n*.35:(yr==="alphabetic"||yr==="baseline")&&(hn=0);const Ar=tr+Or+hn,hr=wn<1?` fill-opacity="${wn}"`:"";pr+=`<text x="${Xn}" y="${Ar}" fill="${gn}"${hr} font-size="${_n}px" font-family="sans-serif" text-anchor="${Hn}">${rr}</text>`}}if(pr+="</g>",console.log("🎯 Ruler section - checking conditions:",{hasRulerOptions:!!bt,hasConfig:!!bt?.config,hasWidth:typeof bt?.width,hasHeight:typeof bt?.height,hasPrecomputedTicks:!!bt?.precomputedTicks,ticksLength:bt?.precomputedTicks?.length}),bt&&bt.config&&typeof bt.width=="number"&&typeof bt.height=="number"){const{minX:ar,maxX:Qn,config:Cn,viewState:Bn,alignmentReferencePoint:In,bounds:or,genomeView:rr,precomputedTicks:vr}=bt;bt.width,bt.height;const cr=Cn||vt;if(console.log("🎯 Ruler section - inside condition, precomputedTicks:",vr?.length),vr&&Array.isArray(vr)){const _i=At.text||(At.background==="#ffffff"?"#666":"#aaa"),ci=At.text||(At.background==="#ffffff"?"#333":"#ccc"),xi=At.text||(At.background==="#ffffff"?"#666":"#aaa");console.log("🎯 Ruler rendering with rulerScaleFactor:",$n,"base fontSize: 11 -> scaled:",11*$n),cr.ruler.height*$n;const mi=xr,wi=cr.ruler.tickHeight*$n,vi=cr.ruler.labelOffset*$n,qi=11*$n;pr+="<g id='ruler'>";const ji=In||0,ls=(cr.genome&&typeof cr.genome.xScalePercent=="number"?cr.genome.xScalePercent:100)/100,xs=Mi=>Mi*ls+ji,$s=Mi=>{const Wa=xs(Mi.x),[Wi]=Rn([Wa,0]);return Wi},Is=vr.slice(0,3);console.log("🎯 Ruler debug - sample ticks:",Is.map(Mi=>({relativeX:Mi.x,worldX:xs(Mi.x),screenX:Mi.screenX,type:Mi.type,computedSvgX:$s(Mi)}))),console.log("🎯 Ruler debug - bounds:",{min_x:It,max_x:Nt,svgWidth:Vt,xOffset:vn,contentScale:xn,useFormatDimensions:Ot,compactWidth:ln,finalWidth:fn,alignmentRef:ji,genomeXScaleValue:ls});const Hs=vr.filter(Mi=>Mi&&typeof Mi.x=="number"&&isFinite(Mi.x)).map(Mi=>$s(Mi)),ws=10,Es=Math.max(0,Math.min(...Hs)-ws),Ds=Math.min(fn,Math.max(...Hs)+ws);pr+=`<line x1='${Es}' y1='${mi}' x2='${Ds}' y2='${mi}' stroke='${_i}' stroke-width='0.5'/>`;const Fa=vr.filter(Mi=>Mi&&Mi.type&&typeof Mi.x=="number"&&isFinite(Mi.x)).map(Mi=>({...Mi,worldX:xs(Mi.x),screenX:$s(Mi)})).filter(Mi=>Mi.screenX>=0&&Mi.screenX<=fn);console.log("🎯 SVG Export: filtered ticks:",Fa.length,{contentScale:xn,useFormatDimensions:Ot});const oa=bt.showTreeLayer===!0||bt.showTreeTextLayer===!0?Fa.filter(Mi=>Mi.type==="tree"&&Mi.isScale):[],aa=Fa.filter(Mi=>Mi.type==="gene");pr+="<g id='ruler-tree'>";for(const Mi of oa)pr+=`<line x1='${Mi.screenX}' y1='${mi}' x2='${Mi.screenX}' y2='${mi+wi/2}' stroke='${xi}' stroke-width='1'/>`,pr+=`<text x='${Mi.screenX}' y='${mi+vi}' text-anchor='middle' font-size='${qi}px' fill='${xi}' font-family='Helvetica, Arial, sans-serif' font-weight='bold'>${Mi.label}</text>`;pr+="</g>",pr+="<g id='ruler-genes'>";for(const Mi of aa)pr+=`<line x1='${Mi.screenX}' y1='${mi}' x2='${Mi.screenX}' y2='${mi+wi}' stroke='${_i}' stroke-width='1'/>`,pr+=`<text x='${Mi.screenX}' y='${mi+vi}' text-anchor='middle' font-size='${qi}px' fill='${ci}' font-family='Helvetica, Arial, sans-serif'>${formatCoordinate(Mi.x)}</text>`;if(aa.length>1)for(let Mi=0;Mi<aa.length-1;Mi++){const Wa=aa[Mi],Wi=aa[Mi+1];if(Wi.x-Wa.x>20){const ys=Wa.screenX+(Wi.screenX-Wa.screenX)/2;ys>=0&&ys<=fn&&(pr+=`<line x1='${ys}' y1='${mi}' x2='${ys}' y2='${mi+wi/2}' stroke='${_i}' stroke-width='0.5'/>`)}}return pr+="</g>",pr+="</g>",pr+="</svg>",pr}(cr.ruler?.height||36)*$n;const gn=xr,wn=(cr.ruler?.tickHeight||8)*$n,Xn=(cr.ruler?.labelOffset||24)*$n,tr=11*$n,Hn=At.text||(At.background==="#ffffff"?"#666":"#aaa"),Kn=At.text||(At.background==="#ffffff"?"#333":"#ccc"),_n=At.text||(At.background==="#ffffff"?"#666":"#aaa");let yr=null;if(rr&&rr.nucleotidesBySeqid){let _i=1/0;Object.values(rr.nucleotidesBySeqid).forEach(ci=>{ci.hood&&(_i=Math.min(_i,Math.min(ci.hood.start,ci.hood.end)))}),isFinite(_i)&&(yr=_i)}const Or=_i=>{const[ci]=Rn([_i,0]);return ci},hn=yr!==null?Or(yr):0,Ar=[],hr=[],An=[],nr=or?.minX??It,gr=or?.maxX??Nt,ii=In||0,ti=cr.genome&&typeof cr.genome.xScalePercent=="number"?cr.genome.xScalePercent/100:1,di=Math.max(yr!==null?yr:It,It,nr),Bi=Math.min(Nt,gr),as=(di-ii)/ti,ki=(Bi-ii)/ti;if(ki>as){const _i=ki-as,ci=60,xi=ln-hn,mi=Math.floor(xi/ci),wi=Math.max(3,Math.min(8,mi)),vi=_i/wi,qi=Math.pow(10,Math.floor(Math.log10(vi))),ji=vi/qi;let Ni;ji<=1?Ni=1:ji<=2?Ni=2:ji<=5?Ni=5:Ni=10;const ls=Ni*qi,xs=Math.floor(as/ls),$s=Math.ceil(ki/ls);for(let Is=xs;Is<=$s;Is++){const Hs=Is*ls;if(Hs<as-ls*.1||Hs>ki+ls*.1)continue;const ws=Hs*ti+ii,Es=Or(ws);Es>=hn&&Es<=fn&&(hr.push({screenX:Es,label:formatCoordinate(Hs)}),Ar.push(Es))}}if((bt.showTreeLayer===!0||bt.showTreeTextLayer===!0)&&yr!==null&&hn>30&&rr&&rr.tree&&or){const _i=or.treeOffset||0,ci=cr.tree&&typeof cr.tree.xScalePercent=="number"?cr.tree.xScalePercent/100:1,xi=rr.tree.allNodes.map(ls=>ls.y*ci+_i),mi=Math.min(...xi),wi=Math.max(...xi),vi=rr.tree.maxEvolutionaryDistance||1,qi=cr.tree?.fixedCoordinateWidth||2e3,ji=Math.max(mi,It),Ni=Math.min(wi,yr);if(Ni>ji){const xs=Math.floor(hn/60),$s=Math.min(4,Math.max(2,xs));for(let Is=0;Is<$s;Is++){const Hs=ji+Is/Math.max(1,$s-1)*(Ni-ji),ws=Or(Hs),Es=(Hs-_i)/ci*(vi/qi);let Ds;vi<.001?Ds=Es.toExponential(1):vi<.1||vi<1?Ds=Es.toFixed(2):Ds=Es.toFixed(1),ws>=0&&ws<=hn&&(An.push({screenX:ws,label:Ds}),Ar.push(ws))}}}if(pr+="<g id='ruler'>",Ar.length>0){const ci=Math.max(0,Math.min(...Ar)-10),xi=Math.min(fn,Math.max(...Ar)+10);pr+=`<line x1='${ci}' y1='${gn}' x2='${xi}' y2='${gn}' stroke='${Hn}' stroke-width='0.5'/>`}pr+="<g id='ruler-tree'>";for(const _i of An)pr+=`<line x1='${_i.screenX}' y1='${gn}' x2='${_i.screenX}' y2='${gn+wn/2}' stroke='${_n}' stroke-width='1'/>`,pr+=`<text x='${_i.screenX}' y='${gn+Xn}' text-anchor='middle' font-size='${tr}px' fill='${_n}' font-family='Helvetica, Arial, sans-serif' font-weight='bold'>${_i.label}</text>`;pr+="</g>",pr+="<g id='ruler-genes'>";for(const _i of hr)pr+=`<line x1='${_i.screenX}' y1='${gn}' x2='${_i.screenX}' y2='${gn+wn}' stroke='${Hn}' stroke-width='1'/>`,pr+=`<text x='${_i.screenX}' y='${gn+Xn}' text-anchor='middle' font-size='${tr}px' fill='${Kn}' font-family='Helvetica, Arial, sans-serif'>${_i.label}</text>`;pr+="</g>",pr+="</g>"}return pr+="</svg>",pr}function formatCoordinate(yt){const Et=Math.abs(yt);return Et>=1e6?`${(yt/1e6).toFixed(1)}M`:Et>=1e3?`${(yt/1e3).toFixed(1)}K`:Math.round(yt).toString()}const DEBUG_LOGS=!1,HoodiniViz=React.forwardRef(({newickStr:yt,gffFeatures:Et,proteinLinks:xt,nucleotideLinks:vt,domainsByGene:bt,hoods:At,hiddenHoodIds:Ft,visibleGeneIds:Ct,hiddenGeneIds:wt,showScrollbar:St,setGenomeViewRef:Tt,onLegendChange:Rt,alignCluster:Pt,defaultAlign:Lt="start",useDefaultGeneAlignment:kt=!0,showRuler:Ot=!0,onObjectClick:Mt,showSVGWidget:It=!1,proteinMetadata:Nt,domainMetadata:Ut,nonCodingMetadata:jt,colorBy:Vt="cluster",labelBy:zt,treeMetadata:Ht,treeLabelBy:Wt,treeColorBy:Gt,config:qt=DEFAULT_CONFIG$1,ultrametric:Xt=!1,showConnectingLines:Kt=!1,forceUpdateCounter:Jt=1e3,phyloLabelPosition:tn="after-tree",alignLabels:sn=!0,arrowheadHeight:Zt,geneHeight:nn,tipWidthMode:rn,tipWidthFactor:on,tipWidthFixed:ln,genePalette:Qt,domainPalette:fn,phyloPalette:pn,ncRNAPalette:mn,regionPalette:vn,geneColorBy:yn,geneLabelBy:xn,domainColorBy:Mn="domainName",domainSource:$n="all",proteinLinkConfig:Rn,nucleotideLinkConfig:Tn,styleConfig:ir,treeXScale:Jn,adjacencyN:jn=1,showTreeLayer:Wn=!0,showGeneLayer:br=!0,showDomainLayer:Fr=!0,showProteinLinkLayer:Cr=!0,showNucleotideLinkLayer:dr=!0,showNcRNALayer:_r=!0,showRegionsLayer:pr=!0,showGeneTextLayer:wr=!0,showTreeTextLayer:xr=!0,showBaselineLayer:Dr=!0,geneLabelPosition:ar="bottom",flashHood:Qn=null,geneColors:Cn=null,phyloColors:Bn=null,showFormatGuides:In=!1,formatGuidePreset:or=null,scaleExportToFormat:rr=!1,cropToGuides:vr=!0,scaleRulerWithCrop:cr=!0,ySpacing:gn,phyloLabelSize:wn,geneLabelSize:Xn,rulerLabelSize:tr,strokeLineWidth:Hn,genomeXScale:Kn},_n)=>{const yr=reactExports.useRef(0),Or=reactExports.useRef({});React.useEffect(()=>{yr.current+=1;try{const En=["treeXScale","arrowheadHeight","geneHeight","alignmentVersion","paletteVersion","geneColorBy","colorBy","phyloLabelPosition"],kn={treeXScale:Jn,arrowheadHeight:Zt,geneHeight:nn,alignmentVersion:mi,paletteVersion:typeof mo<"u"?mo:null,geneColorBy:yn,colorBy:Vt,phyloLabelPosition:tn};En.filter(Nn=>Or.current[Nn]!==kn[Nn]).length>0,Or.current=kn}catch{}});const{getThemeColors:hn,theme:Ar,resolvedTheme:hr}=useTheme(),An=React.useMemo(()=>hn(hr),[hr]),nr=memoGetPalette,gr=React.useMemo(()=>Ft?Ft instanceof Set?Ft:Array.isArray(Ft)?new Set(Ft):new Set:new Set,[Ft]),ii=React.useCallback(En=>gr.size===0||En==null?!1:gr.has(String(En))||gr.has(Number(En)),[gr]),ti=React.useMemo(()=>wt?wt instanceof Set?wt:Array.isArray(wt)?new Set(wt.map(String)):new Set:new Set,[wt]),di=React.useMemo(()=>{if(!Cn)return null;if(Cn instanceof Map)return Cn;if(typeof Cn=="object"){const En=new Map;for(const[kn,Vn]of Object.entries(Cn))En.set(String(kn),Vn);return En}return null},[Cn]),Bi=React.useMemo(()=>{if(!Bn)return null;if(Bn instanceof Map)return Bn;if(typeof Bn=="object"){const En=new Map;for(const[kn,Vn]of Object.entries(Bn))En.set(String(kn),Vn);return En}return null},[Bn]),as=React.useCallback((En,kn)=>{if(!En)return null;const Vn=kn?.origStart??kn?.start,Nn=kn?.origEnd??kn?.end;return Vn!=null&&Nn!=null?`${En}:${Vn}-${Nn}`:String(En)},[]),ki=React.useMemo(()=>{if(!At||!Array.isArray(At))return"none";try{return At.map(En=>as(En?.hood_id||En?.hoodId||En?.seqid,En)||"").join("|")}catch{return`len:${At.length}`}},[At,as]),Xi=qt&&qt.ruler&&typeof qt.ruler.height=="number"?qt.ruler.height:DEFAULT_CONFIG$1.ruler.height,_i=En=>{if(!Ht)return{};if(Ht[En])return Ht[En];const kn=Object.values(Ht);for(let Vn=0;Vn<kn.length;++Vn){const Nn=kn[Vn];if(Nn&&(Nn.leaf_id==En||Nn.leaf_id===En||Nn.leaf_name==En||Nn.leaf_name===En||Nn.id==En||Nn.id===En||Nn.name==En||Nn.name===En||Nn.originalId==En||Nn.original_id==En))return Nn}return{}},[ci,xi]=reactExports.useState(null),[mi,wi]=reactExports.useState(0),[vi,qi]=reactExports.useState(!1),ji=React.useRef(null),[Ni,ls]=React.useState({width:0,height:0}),[xs,$s]=React.useState(!0),[Is,Hs]=reactExports.useState(qt?.tree?.xScalePercent||DEFAULT_CONFIG$1.tree.xScalePercent),ws=Jn??Is,[Es,Ds]=reactExports.useState({target:[0,0,0],zoom:-2}),[Fa,Ja]=reactExports.useState(null),[oa,aa]=reactExports.useState(null),[Mi,Wa]=reactExports.useState(null),[Wi,Mo]=reactExports.useState(null),[ys,Va]=reactExports.useState(null),[io,Fo]=reactExports.useState(null),[_o,lo]=reactExports.useState(null),[Do,Cl]=reactExports.useState(null),ta=reactExports.useRef(!1),ma=reactExports.useRef(null),cs=reactExports.useRef(null),wa=reactExports.useRef(0),la=reactExports.useRef([]),Sa=React.useRef(null);React.useEffect(()=>{try{console.debug("[HoodiniViz] mounted; initial selectedNode=",ci)}catch{}return()=>{}},[]),React.useEffect(()=>{try{console.debug("[HoodiniViz] selectedNode changed ->",ci&&(ci.id||ci.name||ci))}catch{}},[ci]);const Io=React.useCallback(()=>{Ja(null),Wa(null)},[]),xo=React.useCallback(()=>{lo(null)},[]),Ga=React.useCallback(()=>{ta.current=!1,Fo(null)},[]),wo=React.useCallback(()=>{aa(null),Mo(null)},[]),Fl=React.useCallback(()=>{Va(null)},[]),ca=React.useCallback(()=>{Cl(null)},[]),za=React.useCallback((En,kn=null)=>{if(!En){Io();return}xo(),ca(),Ja(String(En)),kn&&Wa([kn])},[Io,xo,ca]),Uo=React.useCallback(En=>{if(!En){xo();return}ca(),lo([En])},[xo,ca]),Vi=React.useCallback(En=>{if(!En){ca();return}xo(),Cl([En])},[ca,xo]),Os=reactExports.useRef(Qn);reactExports.useEffect(()=>{const En=Os.current;if(Os.current=Qn,ta.current)return;if(!Qn){En&&Fo(null);return}const kn=typeof Qn=="string"?Qn:Qn?.id!=null?String(Qn.id):null;if(!kn||!bs.current){Fo(null);return}const Nn=(bs.current.nucleotideLinks?.filter(Dn=>Dn.hood)||[]).filter(Dn=>{const On=Dn?.hood_id!=null?String(Dn.hood_id):null,Pn=Dn?.seqid!=null?String(Dn.seqid):null;return On===kn||Pn===kn});Fo(Nn.length>0?Nn:null)},[Qn]);const bs=reactExports.useRef(null),$o=reactExports.useRef(null),al=reactExports.useRef(ws),qo=reactExports.useRef(null);reactExports.useRef(null),reactExports.useRef(null);const Da=reactExports.useRef(null),qa=reactExports.useRef(null),Ta=reactExports.useRef([]),Zl=reactExports.useRef(null),$l=reactExports.useRef(null),Ts=reactExports.useRef(null),To=reactExports.useRef(null),Ea=reactExports.useRef(!1),Kr=React.useMemo(()=>Nt?Object.values(Nt):[],[Nt]),gs=React.useMemo(()=>{if(!Kr.length)return null;const En={};for(const kn of Kr){const Vn=kn?.id||kn?.gene_id||kn?.geneId;if(!Vn)continue;const Nn=kn?.cluster??kn?.clusterId??kn?.cluster_id;Nn==null||Nn===""||(En[Vn]=Nn)}return Object.keys(En).length?En:null},[Kr]),Ra=React.useMemo(()=>({}),[]),po=yt&&typeof yt=="string"&&yt.trim()!=="",el=React.useMemo(()=>{if(po||!At||!Array.isArray(At))return null;const En=[...new Set(At.map(kn=>kn?.hood_id||kn?.hoodId||kn?.seqid).filter(Boolean))];return En.sort((kn,Vn)=>{const Nn=String(kn),Dn=String(Vn),On=parseFloat(Nn),Pn=parseFloat(Dn);return!isNaN(On)&&!isNaN(Pn)?On-Pn:Nn.localeCompare(Dn,void 0,{numeric:!0,sensitivity:"base"})}),En.map(String)},[po,At]),tl=React.useMemo(()=>{const En=typeof gn=="number"?gn:qt?.tree?.ySpacing||DEFAULT_CONFIG$1.tree.ySpacing;return{...qt,tree:{...qt?.tree,ySpacing:En}}},[qt,gn]),ll=React.useMemo(()=>{const En=typeof gn=="number"?gn:qt?.tree?.ySpacing||DEFAULT_CONFIG$1.tree.ySpacing,kn=typeof Kn=="number"?Kn:qt?.genome?.xScalePercent||DEFAULT_CONFIG$1.genome.xScalePercent;return{...qt,tree:{...qt?.tree,ySpacing:En},genome:{...qt?.genome,xScalePercent:kn}}},[qt,gn,Kn]),us=React.useMemo(()=>{const En=po?yt:el||[],kn=new PhyloTree(En,tl,Xt),Vn=kn.getLeafNodes().map(Nn=>Nn.name);return kn.layout(Vn),kn},[yt,po,el,Xt,tl,Ra]),si=React.useMemo(()=>{const En=po?yt:el||[],kn=new PhyloTree(En,tl,!1),Vn=kn.getLeafNodes().map(Nn=>Nn.name);return kn.layout(Vn),kn},[yt,po,el,tl,Ra]),Un=React.useMemo(()=>{const En=si.getLeafNodes().map(Nn=>Nn.name),kn=new GenomeView(En,si,ll);if(kn.addFeatures(Et),At&&kn.applyHoods(At),kn.initGenes(),gs&&Object.keys(gs).length>0){kn.proteinClusters={},kn._genesIndexReady||kn._buildGeneIndex();for(const Nn of Object.keys(gs)){const Dn=gs[Nn],On=Dn==null?null:String(Dn).trim(),Pn=kn._genesByOriginalId.get(Nn)||[];for(const Zn of Pn)kn.proteinClusters[Zn]=On}}if(kn.computeTrackPositions(),Pt!=null&&Pt!=="")kn.alignCluster(String(Pt));else{const Nn=Object.values(kn.hoodRanges||{}).some(Dn=>Dn.align_gene);kt&&Nn?kn.alignByDefaultGenes():Lt==="center"?kn.alignAllToCenter():Lt==="end"?kn.alignAllToEnd():kn.alignAllToStart()}if(kn.addDomains(bt),Ut&&kn.addDomainMetadata(Ut),kn.addProteinLinks(xt,[200,200,200,255],jn),kn.addNucleotideLinks(vt,[200,200,200,255],jn),Nt&&Object.keys(Nt).length>0){performance.now();for(const Nn in kn.genesById){const Dn=kn.genesById[Nn],On=Dn.originalGeneId;On&&Nt[On]&&(Dn.metadata={...Dn.metadata,...Nt[On]})}if(gs&&kn.proteinClusters){kn._clusterSummary=null;for(const Nn in kn.genesById){const Dn=kn.genesById[Nn],On=kn.proteinClusters[Nn];Dn.metadata||(Dn.metadata={}),Dn.metadata.clusterId=On||null}}performance.now()}const Vn=Nn=>{if(!Nn||typeof Nn!="object")return Nn;const Dn={...Nn};return Dn.sequence||(Dn.sequence=Dn.rna_sequence||Dn.sequence_nt||Dn.nucleotide_sequence||Dn.rna_seq||Dn.seq||null),Dn.structure||(Dn.structure=Dn.secondary_structure||Dn.dot_bracket||Dn.dbn||Dn.structure_dbn||null),Dn.type||(Dn.type=Dn.ncrna_type||Dn.rna_type||Dn.subtype||null),Dn};if(jt&&Object.keys(jt).length>0)for(const Nn in kn.ncRNAsById){const Dn=kn.ncRNAsById[Nn],On=Number.isFinite(Number(Dn.genomicStart))?Number(Dn.genomicStart):null,Pn=Number.isFinite(Number(Dn.genomicEnd))?Number(Dn.genomicEnd):null;let Zn=!1;if(On!==null&&Pn!==null){const sr=`${Dn.seqid}:${On}:${Pn}`;if(jt[sr]&&(Dn.metadata={...Dn.metadata||{},...Vn(jt[sr])},Zn=!0),!Zn){const fr=`${Dn.seqid}:${Pn}:${On}`;jt[fr]&&(Dn.metadata={...Dn.metadata||{},...Vn(jt[fr])},Zn=!0)}}if(!Zn){const sr=Number.isFinite(Number(Dn.start))?Number(Dn.start):null,fr=Number.isFinite(Number(Dn.end))?Number(Dn.end):null;if(sr!==null&&fr!==null){const mr=`${Dn.seqid}:${sr}:${fr}`;jt[mr]&&(Dn.metadata={...Dn.metadata||{},...Vn(jt[mr])},Zn=!0)}}if(!Zn){const sr=Dn.id||Dn.originalId;sr&&jt[sr]&&(Dn.metadata={...Dn.metadata||{},...Vn(jt[sr])},Zn=!0)}Zn||Dn.metadata||(Dn.metadata={})}else for(const Nn in kn.ncRNAsById){const Dn=kn.ncRNAsById[Nn];Dn.metadata||(Dn.metadata={})}return bs.current=kn,performance.now(),kn},[si,ll,Et?Et.length:0,xt?xt.length:0,vt?vt.length:0,bt?Object.keys(bt).length:0,ki,Nt?Object.keys(Nt).length:0,Ut?Object.keys(Ut).length:0,gs?Object.keys(gs).length:0,jt?Object.keys(jt).length:0,Pt,kt,Lt,Ra]);reactExports.useEffect(()=>{xi(null)},[us]),reactExports.useEffect(()=>{if(!Un)return;const En=Qt||qt?.colorPalettes?.genePalette;gs&&Un.setProteinClustersWithPalette(gs,En);const kn=mn||qt?.colorPalettes?.ncRNAPalette;Un.setNcRNAColorsWithPalette(kn);const Vn=vn||qt?.colorPalettes?.regionPalette;Un.setRegionColorsWithPalette(Vn),wi(Nn=>Nn+1)},[Un,Qt,mn,vn,gs,qt?.colorPalettes]),reactExports.useEffect(()=>{Jt>0&&(Ea.current=!0,wi(En=>En+1))},[Jt]);const pi=React.useRef(Kn),zi=React.useRef(Lt),Zi=React.useRef(Pt),bi=React.useRef(kt),Fi=React.useRef(gn),ts=React.useRef(0),Gi=React.useMemo(()=>{if(!Un)return`empty-${ts.current}`;const En=Un.config?.genome?.xScalePercent,kn=Kn??En??30;En!==kn&&(Un.config={...Un.config,genome:{...Un.config?.genome,xScalePercent:kn}});const Vn=pi.current!==Kn,Nn=zi.current!==Lt,Dn=Zi.current!==Pt,On=bi.current!==kt,Pn=Fi.current!==gn;if(Vn||Nn||Dn||On){if(pi.current=Kn,zi.current=Lt,Zi.current=Pt,bi.current=kt,Pt!=null&&Pt!=="")Un.alignCluster(String(Pt));else{const Zn=Object.values(Un.hoodRanges||{}).some(sr=>sr.align_gene);kt&&Zn?Un.alignByDefaultGenes():Lt==="center"?Un.alignAllToCenter():Lt==="end"?Un.alignAllToEnd():Un.alignAllToStart()}ts.current++}return Pn&&(Fi.current=gn),`${Kn}-${Lt}-${Pt||""}-${kt}-${gn}-${ts.current}`},[Un,Kn,Lt,Pt,kt,gn]),hs=React.useMemo(()=>{if(!us)return 100;const En=mr=>{if(!Ht)return{};if(Ht[mr])return Ht[mr];const Pr=Object.values(Ht);for(let Ur=0;Ur<Pr.length;++Ur){const Rr=Pr[Ur];if(Rr&&(Rr.leaf_id==mr||Rr.leaf_id===mr||Rr.leaf_name==mr||Rr.leaf_name===mr||Rr.id==mr||Rr.id===mr||Rr.name==mr||Rr.name===mr||Rr.originalId==mr||Rr.original_id==mr))return Rr}return{}},kn=Wt?Array.isArray(Wt)?Wt:Wt.split(",").map(mr=>mr.trim()).filter(Boolean):null,Nn=us.leafNodes.map(mr=>{const Pr=En(mr.name)||{};let Ur;if(kn&&kn.length>0){const Rr=kn.map(Wr=>Wr==="name"?mr.name:Pr[Wr]).filter(Wr=>Wr!=null&&Wr!=="");Ur=Rr.length>0?Rr.join(" | "):mr.name}else Ur=Pr[Wt],Ur==null&&(Ur=mr.name);return String(Ur)}).reduce((mr,Pr)=>Math.max(mr,Pr.length),0),Dn=qt.tree.labelPadding.charWidth,On=Nn*Dn,Pn=typeof wn=="number"?wn:qt?.text?.phyloLabelSize||14,Zn=qt?.text?.scaleFactors?.phylo||1,fr=Pn*Zn*5;return On+fr},[us,Ht,Wt,qt,wn]),Rs=React.useMemo(()=>{if(!us)return new Map;const En=Nn=>{if(!Ht)return{};if(Ht[Nn])return Ht[Nn];const Dn=Object.values(Ht);for(let On=0;On<Dn.length;++On){const Pn=Dn[On];if(Pn&&(Pn.leaf_id==Nn||Pn.leaf_name==Nn||Pn.id==Nn||Pn.name==Nn))return Pn}return{}},kn=Wt?Array.isArray(Wt)?Wt:Wt.split(",").map(Nn=>Nn.trim()).filter(Boolean):null,Vn=new Map;return us.leafNodes.forEach(Nn=>{const Dn=En(Nn.name)||{};let On;if(kn&&kn.length>0){const Pn=kn.map(Zn=>Zn==="name"?Nn.name:Dn[Zn]).filter(Zn=>Zn!=null&&Zn!=="");On=Pn.length>0?Pn.join(" | "):Nn.name}else On=Dn[Wt],On==null&&(On=Nn.name);Vn.set(String(Nn.name),String(On).length)}),Vn},[us,Ht,Wt]);function vo(En,kn,Vn="after-tree",Nn=null,Dn=!0,On=null){let Pn=1/0,Zn=1/0,sr=-1/0,fr=-1/0,mr=1/0,Pr=null;if(!En)return qt.layout.containerFallback;const Ur=On&&On.size>0;Ur?(Object.values(En.genesById).forEach(Si=>{On.has(String(Si.hood_id))&&Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})}),Object.values(En.ncRNAsById).forEach(Si=>{On.has(String(Si.hood_id))&&Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})}),En.getAllDomains().forEach(Si=>{const Ci=Si.parentGene;Ci&&!On.has(String(Ci.hood_id))||Si.polygon&&Si.polygon.forEach(([Ai,Xs])=>{Pn=Math.min(Pn,Ai),sr=Math.max(sr,Ai)})})):En.globalMin!==1/0&&En.globalMax!==-1/0?(Pn=En.globalMin,sr=En.globalMax):(Object.values(En.genesById).forEach(Si=>{Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})}),Object.values(En.ncRNAsById).forEach(Si=>{Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})}),En.getAllDomains().forEach(Si=>{Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Pn=Math.min(Pn,Ci),sr=Math.max(sr,Ci)})})),Object.values(En.genesById).forEach(Si=>{Ur&&!On.has(String(Si.hood_id))||Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Zn=Math.min(Zn,Ai),fr=Math.max(fr,Ai)})}),Object.values(En.ncRNAsById).forEach(Si=>{Ur&&!On.has(String(Si.hood_id))||Si.polygon&&Si.polygon.forEach(([Ci,Ai])=>{Zn=Math.min(Zn,Ai),fr=Math.max(fr,Ai)})}),En.getAllDomains().forEach(Si=>{const Ci=Si.parentGene;Ur&&Ci&&!On.has(String(Ci.hood_id))||Si.polygon&&Si.polygon.forEach(([Ai,Xs])=>{Zn=Math.min(Zn,Xs),fr=Math.max(fr,Xs)})});const Rr=En.leaves&&En.leaves.length>0,Wr=Rr?new Set:null;if(Rr){const Si=new Set(En.leaves.map(Ci=>String(Ci)));for(const Ci of Si){const Ai=En.hoodToSeqidMap[Ci];Ai&&Wr.add(Ai)}}let $r=-1/0;const qr=Nn!==null?Nn/100:qt.tree&&typeof qt.tree.xScalePercent=="number"?qt.tree.xScalePercent/100:1;if(kn){let Si=null;if(Ur&&On&&On.size>0){Si=new Set;for(const Ci of kn.allNodes)if((!Ci.branchset||Ci.branchset.length===0)&&(On.has(String(Ci.name))||On.has(String(Ci.id)))){let Xs=Ci;for(;Xs;)Si.add(String(Xs.id||Xs.name)),Xs=Xs.parent}}kn.buildEdges().forEach(Ci=>{if(Si){const Ai=String(Ci.source?.id||Ci.source?.name),Xs=String(Ci.target?.id||Ci.target?.name);if(!Si.has(Ai)&&!Si.has(Xs))return}Ci.path.forEach(([Ai,Xs])=>{$r=Math.max($r,Ai*qr)})})}const Vr=Ur?isFinite(Pn)?Pn:isFinite(mr)?mr:-1/0:isFinite(En.globalMin)?En.globalMin:isFinite(mr)?mr:isFinite(Pn)?Pn:-1/0,ri=isFinite(Vr)?qt.layout.geneOffset-Vr:0,Ei=qt.tree.gap,Di=isFinite(Vr)?Vr:Pn,Hi=Vn||qt.tree?.phyloLabelPosition||"after-tree";let Pi=0;if(Hi==="after-tree"&&kn){const Si=Ur&&On?kn.leafNodes.filter(Ci=>On.has(String(Ci.name))||On.has(String(Ci.id))):kn.leafNodes;if(Si.length>0){const Ci=qt.tree.labelPadding.charWidth,Ai=typeof wn=="number"?wn:qt?.text?.phyloLabelSize||14,Xs=qt?.text?.scaleFactors?.phylo||1,fa=Ai*Xs*5;Pi=Si.reduce((Qs,Ia)=>{const ba=Rs.get(String(Ia.name))??String(Ia.name).length;return Math.max(Qs,ba)},0)*Ci+fa}}const Qi=isFinite($r)&&isFinite(Di)?Di-$r-Ei-Pi:0;if(kn&&Dn&&isFinite(Qi)){let Si=1/0;kn.buildEdges().forEach(Ci=>{Ci.path.forEach(([Ai,Xs])=>{Si=Math.min(Si,Ai*qr+Qi)})}),isFinite(Si)&&(Pn=Math.min(Pn,Si))}if(!isFinite(Pn)||!isFinite(Zn)||!isFinite(sr)||!isFinite(fr)){const Si=qt.layout.containerFallback;Pn=Si.minX,Zn=Si.minY,sr=Si.maxX,fr=Si.maxY}return{minX:Pn,minY:Zn,maxX:sr,maxY:fr,treeOffset:Qi,geneOffset:ri}}React.useEffect(()=>{const En=ji.current;if(!En)return;const kn={w:-1,h:-1};let Vn=0;const Nn=new ResizeObserver(Pn=>{const{width:Zn,height:sr}=Pn[0].contentRect,fr=Math.floor(Zn),mr=Math.floor(sr);fr===kn.w&&mr===kn.h||(kn.w=fr,kn.h=mr,Vn&&cancelAnimationFrame(Vn),Vn=requestAnimationFrame(()=>ls({width:fr,height:mr})))});Nn.observe(En);const Dn=En.clientWidth||0,On=En.clientHeight||0;return kn.w=Dn,kn.h=On,ls({width:Dn,height:On}),()=>{Nn.disconnect(),Vn&&cancelAnimationFrame(Vn)}},[ji.current]);function go(En){if(!En)return null;const kn=En.leaves.some(On=>En.trackOffset&&En.trackOffset[On]!==void 0&&En.trackOffset[On]!==0),Vn=(Lt==="start"||Lt==="center"||Lt==="end")&&En.leaves.some(On=>En.trackOffset&&En.trackOffset[On]!==void 0),Nn=Pt!=null&&Pt!=="";return!kn&&!Vn&&!Nn&&!!!kt?null:0}const ms=React.useMemo(()=>{const En=bs.current;if(!En||!us||!ci)return null;try{const kn=typeof En.getNodeDescendantLeaves=="function"?En.getNodeDescendantLeaves(ci):us&&typeof us.getNodeDescendantLeaves=="function"?us.getNodeDescendantLeaves(ci):[],Vn=Array.isArray(kn)?kn:[];return new Set(Vn.map(Nn=>String(Nn)))}catch{return null}},[us,ci]),Ii=React.useMemo(()=>vo(bs.current,us,tn,ws,!1,ms),[us,tn,ws,Gi,Kn,gn,nn,Zt,ms,wn,Rs]),Ui=React.useMemo(()=>po?vo(bs.current,us,tn,ws,!0,ms):Ii,[po,us,tn,ws,Gi,Ii,Kn,gn,nn,Zt,ms,wn,Rs]);React.useEffect(()=>{isFinite(Ii.minY)&&isFinite(Ii.maxY)&&Ii.maxY>Ii.minY&&isFinite(Ii.minX)&&isFinite(Ii.maxX)&&(Sa.current={minY:Ii.minY,maxY:Ii.maxY,minX:Ii.minX,maxX:Ii.maxX,ySpacing:gn,genomeXScale:Kn})},[Ii.minY,Ii.maxY,Ii.minX,Ii.maxX,gn,Kn,nn,Zt,ws]);const Fs=React.useRef(!1);React.useEffect(()=>{if(Fs.current||!Ni.width||!Ni.height||!isFinite(Ui.minX)||!isFinite(Ui.maxX)||!isFinite(Ui.minY)||!isFinite(Ui.maxY))return;const En=Ui.maxX-Ui.minX,kn=Ui.maxY-Ui.minY;if(En<=0||kn<=0)return;const Vn=.5,Nn=Math.log2(Ni.width*Vn/En),Dn=Math.log2(Ni.height*Vn/kn),On=Math.min(Nn,Dn),Pn=Math.max(-5,Math.min(2,On)),Zn=(Ui.minX+Ui.maxX)/2,sr=(Ui.minY+Ui.maxY)/2;Ds(fr=>({...fr,target:[Zn,sr,0],zoom:Pn})),Fs.current=!0},[Ni.width,Ni.height,Ui.minX,Ui.maxX,Ui.minY,Ui.maxY]);const Ws=Sa.current||Ii,Ba=Ws.minY,ua=Ws.maxY,Oo=Ws.minX??Ii.minX,jo=Ws.maxX??Ii.maxX,qs=qt?.scrollbar?.panPaddingY??50,Ya=Ba-qs,Yo=ua+qs,[wl,cl]=React.useState(0);React.useEffect(()=>{if(Es&&isFinite(Es.target[1])&&isFinite(Ba)&&isFinite(ua)&&ua>Ba){const En=(ua-Es.target[1])/(ua-Ba)*100;cl(Math.max(0,Math.min(100,En)))}},[Es?.target?.[1],Ba,ua]);let As=1;if(Es&&Ni.height&&ua>Ba){const En=Math.pow(2,Es.zoom||0),kn=Ni.height/En;As=Math.min(1,kn/(ua-Ba))}function Po(En,kn,Vn,Nn,Dn,On,Pn="bottom",Zn=null,sr=100,fr=150){const mr=Vr=>{if(Array.isArray(Vr))return Vr.length===3?[Vr[0],Vr[1],Vr[2],255]:Vr;if(typeof Vr=="string"){const ri=Vr.split(",").map(Ei=>parseInt(Ei.trim(),10)).filter(Ei=>!isNaN(Ei));if(ri.length===3)return[ri[0],ri[1],ri[2],255];if(ri.length>=4)return[ri[0],ri[1],ri[2],ri[3]]}return Array.isArray(Dn.geneFill)?Dn.geneFill:[150,150,150,255]},Pr=Vr=>{if(!hi?.enabled)return mr(Dn.geneFill);const ri=Vn||Nn||"cluster";let Ei=Vr?.metadata?.[ri];(Ei==null||Ei==="")&&ri==="cluster"&&(Ei=Vr?.metadata?.clusterId??Vr?.metadata?.cluster_id??Vr?.cluster);let Di=null;return kn&&!Ls(Ei)&&(Di=ya(kn,normalizeKey(Ei),hi?.type)||null),mr(Di||Vr.fillColor||Dn.geneFill)},Ur=(Vr,ri,Ei,Di=1/0)=>{const Hi=Ei*.6,Pi=Math.max(3,Math.floor(ri/Hi));if(Vr.length<=Pi)return Vr;const Qi=[];let Si=Vr;for(;Si.length>Pi&&Qi.length<Di;){let Ci=Pi;const Ai=Si.substring(0,Pi),Xs=Math.floor(Pi*.7);for(let Ks=Pi-1;Ks>=Xs;Ks--){const fa=Ai[Ks];if(fa==="_"||fa==="-"||fa===" "||fa==="|"){Ci=Ks+1;break}}Qi.push(Si.substring(0,Ci).trim()),Si=Si.substring(Ci).trim()}if(Si&&Qi.length<Di)Qi.push(Si);else if(Si&&Qi.length>=Di){const Ci=Qi[Qi.length-1],Ai=Ci.length>3?Ci.substring(0,Ci.length-3)+"...":"...";Qi[Qi.length-1]=Ai}return Qi.join(`
2793
2793
  `)},Rr=Zn?Array.isArray(Zn)?Zn:Zn.split(",").map(Vr=>Vr.trim()).filter(Boolean):null;let Wr=null;const $r=(Pn||"bottom").toLowerCase();if(fr<150&&$r!=="center"){const Vr=new Map;for(const ri of En){const Ei=ri.id||ri.uniqueId||"",Di=Ei.indexOf("_"),Hi=Di>0?Ei.substring(0,Di):"";if(!Hi)continue;const Pi=ri.trackY??0;(!Vr.has(Hi)||Pi<Vr.get(Hi))&&Vr.set(Hi,Pi)}if(Vr.size>0){let ri="",Ei="",Di=-1/0,Hi=1/0;for(const[Pi,Qi]of Vr)Qi>Di&&(Di=Qi,ri=Pi),Qi<Hi&&(Hi=Qi,Ei=Pi);Wr=$r==="bottom"?Ei:ri}}return En.map(Vr=>{if(Wr!==null){const Ko=Vr.id||Vr.uniqueId||"",Zo=Ko.indexOf("_");if((Zo>0?Ko.substring(0,Zo):"")!==Wr)return null}const ri=Vr;let Ei;if(Rr&&Rr.length>0){const Ko=Rr.map(Zo=>Zo==="gene_id"?ri.id||ri.geneId||ri.metadata?.gene_id:ri.metadata?.[Zo]??ri.metadata?.attributes?.[Zo]).filter(Zo=>Zo!=null&&Zo!=="");Ei=Ko.length>0?Ko.join(" | "):null}else Ei=ri.id||ri.geneId||ri.metadata?.gene_id||null;if(Ei==null)return null;const Di=(ri.start+ri.end)/2,Hi=ri.trackY!==void 0&&ri.trackY!==null?ri.trackY:ri.polygon&&ri.polygon.length?Math.min(...ri.polygon.map(([Ko,Zo])=>Zo)):0,Qi=(ri.geneHeight!==void 0&&ri.geneHeight!==null?ri.geneHeight:On&&On.gene?On.gene.height:60)/2,Si=Pr(ri),Ci=da(Si)||mr(Dn.geneFill),Ai=Math.abs(ri.end-ri.start)*(sr/100),Xs=On&&On.text&&On.text.geneLabelSize?On.text.geneLabelSize:12,Ks=Ei==null?"":String(Ei),ia=Ai/(Xs*.4);let Qs=Xs;if(Ks.length>ia&&ia>0){const Ko=Math.min(1,ia*2/Ks.length);Qs=Math.max(Xs*.5,Xs*Math.max(.5,Ko))}const Ia=ri.geneHeight!==void 0&&ri.geneHeight!==null?ri.geneHeight:On&&On.gene?On.gene.height:60,ba=fr-Ia-10,zl=Qs*7,Ua=Math.max(1,Math.floor(ba/zl)),Il=Ur(Ks,Ai,Qs,Ua),Oa=2;let Xo;switch((Pn||"bottom").toLowerCase()){case"top":Xo=Hi+Qi+Oa;break;case"center":Xo=Hi;break;default:Xo=Hi-Qi-Oa;break}let Pa="top";switch((Pn||"bottom").toLowerCase()){case"center":Pa="center";break;case"top":Pa="bottom";break;default:Pa="top";break}return{position:[Di,Xo],text:Il,color:Ci,size:Qs,textAnchor:"middle",alignmentBaseline:Pa}}).filter(Boolean)}function da(En,kn=qt.stroke.darkenFactor){return!Array.isArray(En)||En.length<3?En:[Math.max(0,Math.floor(En[0]*kn)),Math.max(0,Math.floor(En[1]*kn)),Math.max(0,Math.floor(En[2]*kn)),En.length>3?En[3]:255]}function nl(En){let kn=0;for(let On=0;On<En.length;++On)kn=En.charCodeAt(On)+((kn<<5)-kn);const Vn=kn>>0&255,Nn=kn>>8&255,Dn=kn>>16&255;return[Math.abs(Vn),Math.abs(Nn),Math.abs(Dn),255]}function uo(En){if(En==null)return NaN;if(typeof En=="number")return Number.isFinite(En)?En:NaN;let kn=String(En).trim();if(kn==="")return NaN;kn=kn.replace(/,/g,""),kn=kn.replace(/^\s*[<>]=?\s*/,""),kn.endsWith("%")&&(kn=kn.slice(0,-1));const Vn=Number(kn);return Number.isFinite(Vn)?Vn:NaN}function Ls(En){if(En==null)return!0;if(typeof En=="string"){const kn=En.trim();if(kn==="")return!0;const Vn=kn.toLowerCase();return Vn==="null"||Vn==="none"}return!1}function ya(En,kn,Vn){if(En&&!Ls(kn)){if(Vn==="sequential"){const Nn=uo(kn);return isNaN(Nn)?void 0:En.get(Nn)}return En.get(String(kn).trim())}}function jl(En,kn){if(!En||!kn)return;if(En[kn]!==void 0&&En[kn]!=="")return En[kn];if(En.metadata&&En.metadata[kn]!==void 0&&En.metadata[kn]!=="")return En.metadata[kn];const Vn={start:["start","from","begin","pos","coord_start"],end:["end","to","stop","finish","pos2","coord_end"],evalue:["evalue","e_value","E-value","score"],coverage:["coverage","cov","pct_coverage","percent_coverage"]},Nn=String(kn).toLowerCase(),Dn=Vn[Nn]||[kn];for(const On of Dn){if(En[On]!==void 0&&En[On]!=="")return En[On];if(En.metadata&&En.metadata[On]!==void 0&&En.metadata[On]!=="")return En.metadata[On]}if(En.metadata){for(const[On,Pn]of Object.entries(En.metadata))if(On&&String(On).toLowerCase()===Nn&&Pn!==void 0&&Pn!=="")return Pn}}function Ho(En,kn,Vn,Nn,Dn=null){if(!Nn||!Nn.enabled)return En.map(fr=>({...fr,color:[0,0,0,255]}));if(Dn&&Dn.size>0)return En.map(fr=>{const Pr=(_i(fr.leafNode.name)||{})[kn];if(Pr!=null){const Ur=String(Pr),Rr=Dn.get(Ur)||Dn.get(Number(Ur))||[0,0,0,255];return{...fr,color:Rr}}else return{...fr,color:[0,0,0,255]}});const On=new Set;for(const fr of En){const Pr=(_i(fr.leafNode.name)||{})[kn];Pr!=null&&Pr!==""&&On.add(String(Pr))}const Pn=Array.from(On).sort();let Zn=[];if(Nn&&Nn.name)try{Zn=nr(Nn.name,Math.max(Pn.length,Nn.numColors||Pn.length),Nn.reverse||!1)}catch{Zn=[]}const sr={};if(Nn.type==="sequential"&&Pn.length>0&&Pn.every(fr=>!isNaN(Number(fr)))){const fr=Pn.map(Ur=>Number(Ur)),mr=Math.min(...fr),Pr=Math.max(...fr);Pn.forEach(Ur=>{const Rr=Number(Ur),Wr=Pr>mr?(Rr-mr)/(Pr-mr):0,$r=Math.floor(Wr*(Zn.length-1));sr[Ur]=Zn[$r]})}else Pn.forEach((fr,mr)=>{sr[fr]=Zn[mr%Zn.length]});return En.map(fr=>{const Pr=(_i(fr.leafNode.name)||{})[kn];if(Pr!=null){const Ur=String(Pr);return{...fr,color:sr[Ur]||[0,0,0,255]}}else return{...fr,color:[0,0,0,255]}})}const hi=Qt||qt?.colorPalettes?.genePalette,Bs=fn||qt?.colorPalettes?.domainPalette,Li=pn||qt?.colorPalettes?.phyloPalette;mn||qt?.colorPalettes?.ncRNAPalette,reactExports.useEffect(()=>{if(!Wi||Wi.length===0)return;const En=Wi[0]?.id;if(!En)return;const kn=requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(!Ts.current?.nodes)return;const Vn=Ts.current.nodes.find(Nn=>Nn.id===En||Nn.name===En||Nn.leaf_id===En||Nn.node?.id===En||Nn.node?.name===En||Nn.node?.leaf_id===En);if(Vn?.color){const Nn=Array.isArray(Vn.color)?[...Vn.color]:Vn.color,Dn=Wi[0]?.color;(!Dn||Nn[0]!==Dn[0]||Nn[1]!==Dn[1]||Nn[2]!==Dn[2])&&Mo(Pn=>Pn?Pn.map(Zn=>({...Zn,color:Nn})):null)}})});return()=>cancelAnimationFrame(kn)},[Wi?.[0]?.id,Gt,Li?.name,Li?.type]);const _a=React.useMemo(()=>{if(!Un)return new Set;if(!ci)return new Set(Un.leaves||[]);try{const En=Un.filterBySelectedNode(ci)||{};if(Array.isArray(En.genes)){const kn=En.genes.map(Vn=>Vn.hood_id).filter(Boolean);return new Set(kn)}}catch{}return new Set(Un.leaves||[])},[Un,ci]),na=React.useMemo(()=>{if(!Un)return null;const En=yn||Vt||"cluster";if(!ci)return Un.computeGenePrevalence(En);const kn=_a,Vn=kn.size||0;if(Vn===0)return new Map;const Nn=new Map;for(const On of Object.values(Un.genesById)){const Pn=On.hood_id||Un.getHoodIdFromSeqid(On.seqid);if(!Pn||!kn.has(Pn))continue;let Zn=null;if(En==="cluster"?Zn=On.metadata?.cluster??On.metadata?.clusterId??On.cluster:Zn=On.metadata?.[En],Zn==null||Zn==="")continue;const sr=String(Zn);Nn.has(sr)||Nn.set(sr,new Set),Nn.get(sr).add(Pn)}const Dn=new Map;for(const[On,Pn]of Nn)Dn.set(On,Pn.size/Vn);return Dn},[Un,yn,Vt,ci,_a]),Pl=React.useRef(null),lc=React.useRef(null),_l=React.useMemo(()=>{if(!Un||!hi?.enabled)return null;const En=yn||Vt||"cluster",kn=Object.values(Un.genesById),Vn=mr=>{let Pr=mr?.metadata?.[En];return(Pr==null||Pr==="")&&En==="cluster"&&(Pr=mr?.metadata?.clusterId??mr?.metadata?.cluster_id??mr?.cluster),Pr},Nn=kn.map(Vn).map(mr=>normalizeKey(mr)).filter(mr=>!Ls(mr)),Dn=[...new Set(Nn)].sort((mr,Pr)=>{const Ur=Number(mr),Rr=Number(Pr);return!isNaN(Ur)&&!isNaN(Rr)?Ur-Rr:String(mr).localeCompare(String(Pr))});if(Dn.length===0)return null;const On=`${En}-${hi.name}-${hi.numColors}-${hi.reverse}-${Dn.length}`;if(Pl.current&&lc.current===On)return Pl.current;const Zn=Dn.map(mr=>uo(mr)).filter(mr=>!isNaN(mr)).length===Dn.length&&Dn.length>0,sr=nr(hi.name,hi.numColors&&hi.type==="sequential"?hi.numColors:Math.max(Dn.length,hi.numColors||Dn.length),hi.reverse||!1,hi.type||"qualitative"),fr=new Map;if(hi.type==="sequential"&&Zn){const mr=Dn.map(Rr=>uo(Rr)),Pr=Math.min(...mr),Ur=Math.max(...mr);Dn.forEach(Rr=>{const Wr=uo(Rr),$r=Ur>Pr?(Wr-Pr)/(Ur-Pr):0,qr=Math.floor($r*(sr.length-1));fr.set(Wr,sr[qr]);try{fr.set(String(Rr),sr[qr])}catch{}})}else Dn.forEach((mr,Pr)=>{fr.set(String(mr),sr[Pr%sr.length]);const Ur=uo(mr);isNaN(Ur)||fr.set(Ur,sr[Pr%sr.length])});return Pl.current=fr,lc.current=On,console.debug("stableGeneColorMap: generated for",Dn.length,"unique values"),fr},[Un,yn,Vt,hi?.enabled,hi?.name,hi?.numColors,hi?.reverse,hi?.type]),ul=React.useRef(null),Ec=React.useRef(null),Sl=React.useMemo(()=>{if(!us||!Ht||!Gt||!Li?.enabled)return null;const En=new Set;for(const On of us.leafNodes||[]){const Zn=(Ht[On.name]||{})[Gt];Zn!=null&&Zn!==""&&En.add(String(Zn))}const kn=Array.from(En).sort();if(kn.length===0)return null;const Vn=`${Gt}-${Li.name}-${Li.numColors}-${Li.reverse}-${kn.length}`;if(ul.current&&Ec.current===Vn)return ul.current;let Nn=[];try{Nn=nr(Li.name,Math.max(kn.length,Li.numColors||kn.length),Li.reverse||!1,Li.type||"qualitative")}catch{Nn=[]}const Dn=new Map;if(Li.type==="sequential"&&kn.every(On=>!isNaN(Number(On)))){const On=kn.map(sr=>Number(sr)),Pn=Math.min(...On),Zn=Math.max(...On);kn.forEach(sr=>{const fr=Number(sr),mr=Zn>Pn?(fr-Pn)/(Zn-Pn):0,Pr=Math.floor(mr*(Nn.length-1));Dn.set(sr,Nn[Pr]),Dn.set(fr,Nn[Pr])})}else kn.forEach((On,Pn)=>{Dn.set(On,Nn[Pn%Nn.length]);const Zn=Number(On);isNaN(Zn)||Dn.set(Zn,Nn[Pn%Nn.length])});return ul.current=Dn,Ec.current=Vn,console.debug("stableTreeColorMap: generated for",kn.length,"unique values"),Dn},[us,Ht,Gt,Li?.enabled,Li?.name,Li?.numColors,Li?.reverse,Li?.type]),Lo=hi?.stableColors!==!1,cc=Li?.stableColors!==!1,ss=React.useMemo(()=>{if(!Un||!hi?.enabled||Lo&&!_l)return null;const En=yn||Vt||"cluster";let kn=Object.values(Un.genesById);!Lo&&_a&&_a.size>0&&(kn=kn.filter(Pr=>{const Ur=Pr.hood_id||Un.getHoodIdFromSeqid(Pr.seqid);return Ur&&_a.has(Ur)}));const Vn=Pr=>{let Ur=Pr?.metadata?.[En];return(Ur==null||Ur==="")&&En==="cluster"&&(Ur=Pr?.metadata?.clusterId??Pr?.metadata?.cluster_id??Pr?.cluster),Ur},Nn=kn.map(Vn).map(Pr=>normalizeKey(Pr)).filter(Pr=>!Ls(Pr)),Dn=[...new Set(Nn)].sort((Pr,Ur)=>{const Rr=Number(Pr),Wr=Number(Ur);return!isNaN(Rr)&&!isNaN(Wr)?Rr-Wr:String(Pr).localeCompare(String(Ur))});if(Dn.length===0)return null;const Pn=Dn.map(Pr=>uo(Pr)).filter(Pr=>!isNaN(Pr)).length===Dn.length&&Dn.length>0,Zn=new Map,sr=DEFAULT_CONFIG$1.gene.fillColor,fr=hi.transparentByPrevalence?[sr[0],sr[1],sr[2],0]:sr,mr=(hi.prevalenceFilter||0)/100;if(Lo)Dn.forEach(Pr=>{const Ur=na?.get(String(Pr))||0,Rr=Ur>=mr,Wr=ya(_l,Pr,hi?.type);let $r=Rr?Wr:fr;Rr&&hi.desaturateByPrevalence&&na&&Un._desaturateColorByPrevalence&&($r=Un._desaturateColorByPrevalence($r,Ur)),Rr&&hi.transparentByPrevalence&&na&&Un._transparentByPrevalence&&($r=Un._transparentByPrevalence($r,Ur));const qr=hi.type==="sequential"&&Pn?uo(Pr):String(Pr);Zn.set(qr,$r);try{Zn.set(String(Pr),$r)}catch{}const Vr=uo(Pr);isNaN(Vr)||Zn.set(Vr,$r)});else{const Pr=Dn.filter(Rr=>(na?.get(String(Rr))||0)>=mr),Ur=nr(hi.name,hi.numColors&&hi.type==="sequential"?hi.numColors:Math.max(Pr.length,hi.numColors||Pr.length),hi.reverse||!1,hi.type||"qualitative");if(hi.type==="sequential"&&Pn){const Rr=Pr.map(qr=>uo(qr)),Wr=Math.min(...Rr),$r=Math.max(...Rr);Pr.forEach(qr=>{const Vr=uo(qr),ri=$r>Wr?(Vr-Wr)/($r-Wr):0,Ei=Math.floor(ri*(Ur.length-1));let Di=Ur[Ei];if(hi.desaturateByPrevalence&&na&&Un._desaturateColorByPrevalence){const Hi=na.get(String(qr))||0;Di=Un._desaturateColorByPrevalence(Di,Hi)}if(hi.transparentByPrevalence&&na&&Un._transparentByPrevalence){const Hi=na.get(String(qr))||0;Di=Un._transparentByPrevalence(Di,Hi)}Zn.set(Vr,Di);try{Zn.set(String(qr),Di)}catch{}})}else Pr.forEach((Rr,Wr)=>{let $r=Ur[Wr%Ur.length];if(hi.desaturateByPrevalence&&na&&Un._desaturateColorByPrevalence){const Vr=na.get(String(Rr))||0;$r=Un._desaturateColorByPrevalence($r,Vr)}if(hi.transparentByPrevalence&&na&&Un._transparentByPrevalence){const Vr=na.get(String(Rr))||0;$r=Un._transparentByPrevalence($r,Vr)}Zn.set(String(Rr),$r);const qr=uo(Rr);isNaN(qr)||Zn.set(qr,$r)});Dn.forEach(Rr=>{if((na?.get(String(Rr))||0)<mr){const $r=hi.type==="sequential"&&Pn?uo(Rr):String(Rr);Zn.set($r,fr);try{Zn.set(String(Rr),fr)}catch{}const qr=uo(Rr);isNaN(qr)||Zn.set(qr,fr)}})}return Zn},[Un,_l,na,_a,hi?.enabled,hi?.type,hi?.name,hi?.numColors,hi?.reverse,hi?.desaturateByPrevalence,hi?.transparentByPrevalence,hi?.prevalenceFilter,hi?.stableColors,Lo,Vt,yn,mi]);React.useEffect(()=>{try{if(!Un)return;const En=yn||Vt||"cluster",Vn=Object.values(Un.genesById||{}).map(Pn=>{let Zn=Pn?.metadata?.[En];return(Zn==null||Zn==="")&&En==="cluster"&&(Zn=Pn?.metadata?.clusterId??Pn?.metadata?.cluster_id??Pn?.cluster),Zn}).filter(Pn=>Pn!=null&&Pn!==""),Nn=[...new Set(Vn)],On=Nn.map(Pn=>uo(Pn)).filter(Pn=>!isNaN(Pn)).length===Nn.length&&Nn.length>0}catch(En){console.error("ColorSelect gene logging error",En)}},[yn,Vt,Un,ss,hi?.name,hi?.type]);const Dl=({object:En,layer:kn})=>{if(!En)return null;if(kn&&kn.id==="protein-polygons"){const Vn=bs.current,Nn=Vn?.genesById?.[En.gAId],Dn=Vn?.genesById?.[En.gBId],On=En.metadata?.similarity??En.similarity??"N/A",Pn=[["type","Protein Link"],["similarity",typeof On=="number"?`${On.toFixed(1)}%`:On]];if(Nn){const fr=Nn.metadata?.gene_name||Nn.metadata?.name||Nn.gene_id||En.gAId,mr=Nn.metadata?.cluster||Nn.metadata?.clusterId||Nn.cluster||"";Pn.push(["source gene",fr]),mr&&String(mr)!==String(fr)&&Pn.push(["source cluster",mr]),Pn.push(["source hood",Nn.hood_id||Nn.seqid||""])}if(Dn){const fr=Dn.metadata?.gene_name||Dn.metadata?.name||Dn.gene_id||En.gBId,mr=Dn.metadata?.cluster||Dn.metadata?.clusterId||Dn.cluster||"";Pn.push(["target gene",fr]),mr&&String(mr)!==String(fr)&&Pn.push(["target cluster",mr]),Pn.push(["target hood",Dn.hood_id||Dn.seqid||""])}const Zn=Pn.filter(([fr,mr])=>mr!==""&&mr!==null&&mr!==void 0);return Zn.length===0?null:{html:`<table>${Zn.map(([fr,mr])=>`<tr><td><b>${fr}</b></td><td style="width:10px"></td><td>${String(mr)}</td></tr>`).join("")}</table>`}}if(kn&&kn.id==="nucleotide-polygons"){let Vn=En.similarity;if(Vn==null&&(Vn=En.metadata?.similarity),Vn==null){const fr=bs.current;if(fr&&fr.nucleotideLinks){const mr=fr.nucleotideLinks.find(Pr=>Pr.hoodA===En.hoodA&&Pr.hoodB===En.hoodB&&Pr.hoodStartA===En.hoodStartA);mr&&(Vn=mr.similarity)}}let Nn="N/A";typeof Vn=="number"&&!isNaN(Vn)?Nn=`${Vn.toFixed(1)}%`:typeof Vn=="string"&&Vn!==""&&(Nn=Vn);const Dn=bs.current;let On="";if(Dn){const fr=Dn.nucleotideLinks?.find(mr=>mr.hoodA===En.hoodA&&mr.hoodB===En.hoodB&&mr.hoodStartA===En.hoodStartA);if(fr){const mr=fr.strandA||"+",Pr=fr.strandB||"+",Ur=!!Dn.trackFlipped[En.hoodA],Rr=!!Dn.trackFlipped[En.hoodB],Wr=mr==="+"!==Ur?"+":"-",$r=Pr==="+"!==Rr?"+":"-";On=`${Wr}/${$r} (${Wr===$r?"same strand":"opposite strand"})`}}const Pn=[["type","Nucleotide Link"],["similarity",Nn],["strand",On],["hood A",En.hoodA||""],["hood B",En.hoodB||""]];En.hoodStartA!==void 0&&En.hoodEndA!==void 0&&Pn.push(["region A",`${Math.round(En.hoodStartA)}-${Math.round(En.hoodEndA)}`]),En.hoodStartB!==void 0&&En.hoodEndB!==void 0&&Pn.push(["region B",`${Math.round(En.hoodStartB)}-${Math.round(En.hoodEndB)}`]);const Zn=Pn.filter(([fr,mr])=>mr!==""&&mr!==null&&mr!==void 0);return Zn.length===0?null:{html:`<table>${Zn.map(([fr,mr])=>`<tr><td><b>${fr}</b></td><td style="width:10px"></td><td>${String(mr)}</td></tr>`).join("")}</table>`}}if(kn&&kn.id==="nodes"&&En.node&&En.node.branchset&&En.node.branchset.length===0){const Vn=En.node.name||En.node.id||En.id,Dn=(Zn=>{if(!Ht)return{};if(!Zn)return{};if(Ht[Zn])return Ht[Zn];const sr=Object.values(Ht);for(let fr=0;fr<sr.length;++fr){const mr=sr[fr];if(mr&&(mr.leaf_id==Zn||mr.leaf_id===Zn||mr.leaf_name==Zn||mr.leaf_name===Zn||mr.id==Zn||mr.id===Zn||mr.name==Zn||mr.name===Zn||mr.originalId==Zn||mr.original_id==Zn))return mr}return{}})(Vn)||{},On=Object.entries(Dn).filter(([Zn,sr])=>{if(!Zn)return!1;const fr=String(Zn).toLowerCase();if(fr==="sequence"||fr==="attributes"||Ls(sr))return!1;const mr=typeof sr;return mr==="string"||mr==="number"||mr==="boolean"});return On.length===0?null:{html:`<table>${On.map(([Zn,sr])=>`<tr><td><b>${Zn}</b></td><td style="width:10px"></td><td>${String(sr)}</td></tr>`).join("")}</table>`}}if(En.metadata){const Vn=En.metadata||{},Nn=Object.entries(Vn).filter(([On,Pn])=>{if(!On)return!1;const Zn=String(On).toLowerCase();if(Zn==="sequence"||Zn==="structure"||Zn==="attributes"||Zn==="clusterid"||Zn==="cluster_id"||Ls(Pn))return!1;const sr=typeof Pn;return sr==="string"||sr==="number"||sr==="boolean"});if(En.metadata.attributes){if(typeof En.metadata.attributes=="object"&&!Array.isArray(En.metadata.attributes))Object.entries(En.metadata.attributes).forEach(([On,Pn])=>{On&&Pn!==null&&Pn!==void 0&&Nn.push([On,String(Pn)])});else if(typeof En.metadata.attributes=="string"){const On=En.metadata.attributes.split(";").filter(Pn=>Pn.trim());for(const Pn of On){const[Zn,sr]=Pn.split("=").map(fr=>fr.trim());Zn&&sr&&Nn.push([Zn,sr])}}}if(na&&En.metadata&&(yn||Vt)){const On=yn||Vt||"cluster";let Pn=En.metadata[On];if((Pn==null||Pn==="")&&On==="cluster"&&(Pn=En.metadata.clusterId??En.metadata.cluster_id??En.cluster),Pn!=null&&Pn!==""){const Zn=na.get(String(Pn));if(Zn!==void 0){const sr=(Zn*100).toFixed(1);Nn.push(["prevalence",`${sr}% of hoods`])}}}return Nn.length===0?null:{html:`<table>${Nn.map(([On,Pn])=>`<tr><td><b>${On}</b></td><td style="width:10px"></td><td>${String(Pn)}</td></tr>`).join("")}</table>`}}return En.name?{text:En.name}:En.id?{text:En.id}:En.gene_id?{text:En.gene_id}:null};React.useMemo(()=>!0,[mi,hi?.enabled,hi?.name,hi?.numColors,hi?.reverse]);const{filteredProteinPolygons:Ql,filteredNucleotidePolygons:so}=React.useMemo(()=>{if(!Un)return{filteredProteinPolygons:[],filteredNucleotidePolygons:[]};let En=Un.getProteinPolygons(),kn=Un.getNucleotidePolygons(),Vn=Un.leaves;if(ci)try{const sr=Un.filterBySelectedNode(ci);sr&&Array.isArray(sr.proteinPolygons)&&(En=sr.proteinPolygons.map(fr=>({polygon:fr.polygon||fr.polygon,fillColor:fr.fillColor,metadata:fr.metadata}))),sr&&Array.isArray(sr.nucleotidePolygons)&&(kn=sr.nucleotidePolygons.map(fr=>({polygon:fr.polygon||fr.polygon,fillColor:fr.fillColor,metadata:fr.metadata}))),Vn=sr&&Array.isArray(sr.genes)?sr.genes.map(fr=>fr.hood_id):Vn}catch{}const Nn=new Set;for(let sr=0;sr<Vn.length-1;sr++){const[fr,mr]=[Vn[sr],Vn[sr+1]].sort();Nn.add(`${fr}__${mr}`)}const Dn=En.filter(sr=>{if(!sr.metadata)return!1;const{gAId:fr,gBId:mr,hoodA:Pr,hoodB:Ur,seqids:Rr}=sr.metadata;let Wr=Pr||fr&&Un.genesById[fr]?.hood_id||Rr?.[0],$r=Ur||mr&&Un.genesById[mr]?.hood_id||Rr?.[1];if(gr.size>0&&(Wr!=null&&(gr.has(String(Wr))||gr.has(Number(Wr)))||$r!=null&&(gr.has(String($r))||gr.has(Number($r)))))return!1;if(Wr&&$r){const[qr,Vr]=[Wr,$r].sort();return Nn.has(`${qr}__${Vr}`)}return!1}),On=new Set;for(let sr=0;sr<Vn.length-1;sr++){const[fr,mr]=[Vn[sr],Vn[sr+1]].sort();On.add(`${fr}__${mr}`)}const Pn=new Set,Zn=kn.filter(sr=>{if(!sr.metadata)return!1;const{seqids:fr,hoodA:mr,hoodB:Pr}=sr.metadata;if(!fr||fr.length<2)return!1;const Ur=mr||fr[0],Rr=Pr||fr[1];if(gr.size>0&&(Ur!=null&&(gr.has(String(Ur))||gr.has(Number(Ur)))||Rr!=null&&(gr.has(String(Rr))||gr.has(Number(Rr)))))return!1;const[Wr,$r]=fr.sort(),qr=`${Wr}__${$r}`;return On.has(qr)&&!Pn.has(qr)?(Pn.add(qr),!0):!1});return{filteredProteinPolygons:Dn,filteredNucleotidePolygons:Zn}},[Un,xt,vt,mi,Rn,Tn,ss,hi,ci,gr]),xl=React.useMemo(()=>{if(!Un)return[];try{if(ci){const En=Un.filterBySelectedNode(ci);if(En&&Array.isArray(En.genes))return En.genes.map(kn=>({...kn,fillColor:kn.fillColor||An.geneFill}))}}catch{}return Object.values(Un.genesById).map(En=>({...En,fillColor:En.fillColor||An.geneFill}))},[Un,ss,yn,Vt,An.geneFill,mi,ci]),Jl=React.useCallback(()=>{const En=Un;mn||qt?.colorPalettes?.ncRNAPalette,vn||qt?.colorPalettes?.regionPalette;const kn={genes:null,phylo:null,regions:null,ncRNAs:null,proteinLinks:null,nucleotideLinks:null};try{if(typeof ss<"u"&&ss&&ss.size>0){const Nn=new Set,Dn=Array.from(ss.entries()).filter(([On])=>{const Pn=String(On);return Nn.has(Pn)?!1:(Nn.add(Pn),!0)}).map(([On,Pn])=>({value:String(On),color:Pn,stroke:Array.isArray(Pn)?da(Pn):null}));kn.genes=Dn}else if(En&&En.genesById){const Nn=new Map,Dn=yn||Vt||"cluster",On=Pn=>{try{if(ss){let Zn=Pn?.metadata?.[Dn];if((Zn==null||Zn==="")&&Dn==="cluster"&&(Zn=Pn?.metadata?.clusterId??Pn?.metadata?.cluster_id??Pn?.cluster),Zn!=null&&Zn!==""){const sr=ya(ss,Zn,hi?.type);if(sr)return sr}}}catch{}return Pn.fillColor||An.geneFill};xl.forEach(Pn=>{const Zn=Pn.metadata&&Pn.metadata[Dn]?Pn.metadata[Dn]:null;if(Zn!=null){const sr=String(Zn);if(!Nn.has(sr)){const fr=On(Pn);Nn.set(sr,{value:sr,color:fr,stroke:Array.isArray(fr)?da(fr):null})}}}),kn.genes=Array.from(Nn.values())}const Vn=new Map;if(us&&us.leafNodes&&Array.isArray(us.leafNodes)&&us.leafNodes.length>0&&Ht&&Gt){const Nn=Gt,On=[...new Set(us.leafNodes.map(Zn=>{const fr=(Ht[Zn.name]||{})[Nn];return fr!=null&&fr!==""?fr:null}).filter(Zn=>Zn!==null))].sort();let Pn=[];if(Li&&Li.enabled&&On.length>0)try{Pn=nr(Li.name,Math.max(On.length,Li.numColors||On.length),Li.reverse||!1,Li.type||"qualitative")}catch{Pn=[]}On.forEach((Zn,sr)=>{const fr=String(Zn);let mr=null;if(Pn.length>0&&sr<Pn.length)mr=Pn[sr];else{let Pr=0;for(let $r=0;$r<fr.length;++$r)Pr=fr.charCodeAt($r)+((Pr<<5)-Pr);const Ur=Pr>>0&255,Rr=Pr>>8&255,Wr=Pr>>16&255;mr=[Math.abs(Ur),Math.abs(Rr),Math.abs(Wr),255]}Vn.set(fr,{value:fr,color:mr,stroke:Array.isArray(mr)?da(mr):null})})}if(kn.phylo=Array.from(Vn.values()),En&&Array.isArray(En.proteinLinks)&&En.proteinLinks.length>0){const Nn=Rn||{};if(Nn.colorBy==="identity_gradient"&&Nn.palette&&Nn.palette.enabled){const Dn=En.proteinLinks.map(sr=>typeof sr.similarity=="number"?sr.similarity:0),On=Math.min(...Dn),Pn=Math.max(...Dn);let Zn=[];try{Zn=nr(Nn.palette.name,Nn.palette.numColors||8,Nn.palette.reverse||!1)}catch{Zn=[]}kn.proteinLinks={mode:"identity_gradient",minSim:On,maxSim:Pn,palette:Zn}}else if(Nn.colorBy==="source_gene"||Nn.colorBy==="target_gene"){const Dn=[];En.proteinLinks.forEach(Pn=>{const Zn=En.genesById&&En.genesById[Pn.gAId],sr=En.genesById&&En.genesById[Pn.gBId];if(Nn.colorBy==="source_gene"&&Zn){const fr=yn||Vt||"cluster";let mr=Zn.metadata&&Zn.metadata[fr];Ls(mr)&&fr==="cluster"&&(mr=Zn.cluster);const Pr=ss&&Zn&&!Ls(mr)?ya(ss,normalizeKey(mr),hi?.type)||Zn.fillColor:Zn.fillColor||An.geneFill;Dn.push({id:Pn.gAId,label:Zn.metadata?Zn.metadata[yn||Vt]:Zn.id,color:Pr,stroke:Array.isArray(Pr)?da(Pr):null})}if(Nn.colorBy==="target_gene"&&sr){const fr=yn||Vt||"cluster";let mr=sr.metadata&&sr.metadata[fr];Ls(mr)&&fr==="cluster"&&(mr=sr.cluster);const Pr=ss&&sr&&!Ls(mr)?ya(ss,normalizeKey(mr),hi?.type)||sr.fillColor:sr.fillColor||An.geneFill;Dn.push({id:Pn.gBId,label:sr.metadata?sr.metadata[yn||Vt]:sr.id,color:Pr,stroke:Array.isArray(Pr)?da(Pr):null})}});const On=new Map;Dn.forEach(Pn=>{Pn&&Pn.id&&!On.has(Pn.id)&&On.set(Pn.id,Pn)}),kn.proteinLinks={mode:Nn.colorBy,mapping:Array.from(On.values())}}else kn.proteinLinks={mode:Nn.colorBy,solidColor:Nn.solidColor||null,useAlpha:Nn.useAlpha,minAlpha:Nn.minAlpha,maxAlpha:Nn.maxAlpha}}if(En&&Array.isArray(En.nucleotideLinks)&&En.nucleotideLinks.length>0){const Nn=Tn||{};if(Nn.colorBy==="identity_gradient"&&Nn.palette&&Nn.palette.enabled){const Dn=En.nucleotideLinks.map(sr=>typeof sr.similarity=="number"?sr.similarity:0),On=Math.min(...Dn),Pn=Math.max(...Dn);let Zn=[];try{Zn=nr(Nn.palette.name,Nn.palette.numColors||8,Nn.palette.reverse||!1)}catch{Zn=[]}kn.nucleotideLinks={mode:"identity_gradient",minSim:On,maxSim:Pn,palette:Zn}}else if(Nn.colorBy==="source_gene"||Nn.colorBy==="target_gene"){const Dn=[];En.nucleotideLinks.forEach(Pn=>{const Zn=En.genesById&&En.genesById[Pn.gAId],sr=En.genesById&&En.genesById[Pn.gBId];if(Nn.colorBy==="source_gene"&&Zn){const fr=Zn.metadata&&Zn.metadata[yn||Vt]||Zn.cluster,mr=ss&&Zn&&fr?ya(ss,fr,hi?.type)||Zn.fillColor:Zn.fillColor||An.geneFill;Dn.push({id:Pn.gAId,label:Zn.metadata?Zn.metadata[yn||Vt]:Zn.id,color:mr,stroke:Array.isArray(mr)?da(mr):null})}if(Nn.colorBy==="target_gene"&&sr){const fr=sr.metadata&&sr.metadata[yn||Vt]||sr.cluster,mr=ss&&sr&&fr?ya(ss,fr,hi?.type)||sr.fillColor:sr.fillColor||An.geneFill;Dn.push({id:Pn.gBId,label:sr.metadata?sr.metadata[yn||Vt]:sr.id,color:mr,stroke:Array.isArray(mr)?da(mr):null})}});const On=new Map;Dn.forEach(Pn=>{Pn&&Pn.id&&!On.has(Pn.id)&&On.set(Pn.id,Pn)}),kn.nucleotideLinks={mode:Nn.colorBy,mapping:Array.from(On.values())}}else kn.nucleotideLinks={mode:Nn.colorBy,solidColor:Nn.solidColor||null,useAlpha:Nn.useAlpha,minAlpha:Nn.minAlpha,maxAlpha:Nn.maxAlpha}}try{const Nn=En?En.getAllRegions():[];if(Nn.length>0){const Dn={};if(Nn.forEach(On=>{if(On.fillColor){const Pn=On.getColorKey();Pn!=null&&Pn!==""&&(Dn[String(Pn)]=On.fillColor)}}),Object.keys(Dn).length>0)kn.regions=Dn;else{const On={};Nn.forEach(Pn=>{const Zn=Pn.metadata&&(Pn.metadata.region_type||Pn.metadata.type)?String(Pn.metadata.region_type||Pn.metadata.type):Pn.name||Pn.id||"region",sr=Pn.fillColor||Pn.color||null,fr=Pn.strokeColor||(Array.isArray(sr)?da(sr):null);On[Zn]={color:sr,stroke:fr}}),kn.regions=On}}}catch{}try{const Nn=En?En.getAllNonCodingFeatures():[];if(Nn&&Nn.length>0){const Dn=new Map;Nn.forEach(On=>{const Pn=On.metadata&&On.metadata.type?String(On.metadata.type):On.name||On.id||"ncRNA",Zn=On.fillColor||On.color||null,sr=On.strokeColor||(Array.isArray(Zn)?da(Zn):null);Dn.has(Pn)||Dn.set(Pn,{label:String(Pn),color:Zn,stroke:sr})}),kn.ncRNAs=Array.from(Dn.values())}}catch{}}catch{}return kn},[Un,ss,xl,yn,Vt,An.geneFill,hi,us,Ht,Gt,Li,mn,vn,Rn,Tn,qt]),Ll=React.useRef(null);React.useEffect(()=>{if(typeof Rt!="function"){try{console.debug("[Legend] onLegendChange not provided or not a function:",Rt)}catch{}return}try{const En=Jl();if(!En||typeof En!="object")return;let kn=null;try{kn=JSON.stringify(En)}catch{kn=String(En)}if(Ll.current!==kn){Ll.current=kn;try{(Nn=>!Nn||typeof Nn!="object"?!1:Object.keys(Nn).some(Dn=>{const On=Nn[Dn];return On==null?!1:!!(Array.isArray(On)&&On.length>0||typeof On=="object"&&Object.keys(On).length>0)}))(En)}catch{}try{const Vn={};try{En.genes&&(Vn.genes=Array.isArray(En.genes)?En.genes.length:Object.keys(En.genes||{}).length),En.phylo&&(Vn.phylo=Array.isArray(En.phylo)?En.phylo.length:0),En.regions&&(Vn.regions=Array.isArray(En.regions)?En.regions.length:Object.keys(En.regions||{}).length),En.ncRNAs&&(Vn.ncRNAs=Array.isArray(En.ncRNAs)?En.ncRNAs.length:Object.keys(En.ncRNAs||{}).length),En.proteinLinks&&(Vn.proteinLinks=typeof En.proteinLinks=="object"?Object.keys(En.proteinLinks).length:0),En.nucleotideLinks&&(Vn.nucleotideLinks=typeof En.nucleotideLinks=="object"?Object.keys(En.nucleotideLinks).length:0)}catch{}}catch{}Rt(En)}}catch{}},[Jl,Rt]);const uc=React.useRef(null);React.useEffect(()=>{if(Un)try{const kn=[Un?Object.keys(Un.genesById||{}).length:0,Nt&&typeof Nt=="object"?Object.keys(Nt).length:0,Rn?JSON.stringify(Rn):"",Tn?JSON.stringify(Tn):"",String(yn||""),String(Vt||"")].join("|");uc.current!==kn&&(uc.current=kn,wi(Vn=>Vn+1))}catch{wi(kn=>kn+1)}},[Un,Nt,jt,Rn,Tn,yn,Vt]);const Xa=React.useMemo(()=>{if(!Un||!Bs?.enabled)return null;let En=Un.getAllDomains();$n&&$n!=="all"&&(En=En.filter(fr=>{const mr=fr&&(fr.source||fr.metadata&&fr.metadata.source)||null;return String(mr)===String($n)}));const kn=En.map(fr=>{if(Mn==="domainName")return fr.domainName;const mr=jl(fr,Mn);return mr!==void 0&&mr!==""?mr:void 0}).filter(fr=>fr!=null&&fr!==""),Vn=[...new Set(kn)];if(Vn.length===0)return null;const Dn=Vn.map(fr=>uo(fr)).filter(fr=>!isNaN(fr)).length===Vn.length&&Vn.length>0;let On=Bs.reverse||!1;const Pn=String(Mn).toLowerCase()==="evalue"||String(Mn).toLowerCase()==="e_value";Bs.type==="sequential"&&Dn&&Pn&&(On=!On);const Zn=nr(Bs.name,Bs.numColors&&Bs.type==="sequential"?Bs.numColors:Math.max(Vn.length,Bs.numColors||Vn.length),On,Bs.type||"qualitative"),sr=new Map;if(Bs.type==="sequential"&&Dn){const fr=Vn.map(Wr=>uo(Wr));let mr=fr.slice();(String(Mn).toLowerCase()==="evalue"||String(Mn).toLowerCase()==="e_value")&&(mr=fr.map(Wr=>!isFinite(Wr)||Wr<=0?-Math.log10(Number.MIN_VALUE):-Math.log10(Wr)),mr=mr.map(Wr=>Math.log2(1+Math.max(0,Wr))));const Pr=Math.max(...mr);let Ur=128,Rr=255;try{if(Bs.alphaRange&&Array.isArray(Bs.alphaRange)&&Bs.alphaRange.length===2){let Wr=Number(Bs.alphaRange[0]),$r=Number(Bs.alphaRange[1]);!isNaN(Wr)&&!isNaN($r)&&(Wr<=1&&$r<=1&&(Wr=Wr*255,$r=$r*255),Ur=Math.max(0,Math.min(255,Math.round(Wr))),Rr=Math.max(0,Math.min(255,Math.round($r))))}}catch{}Vn.forEach((Wr,$r)=>{const qr=fr[$r],Vr=mr[$r],Ei=Pr>0?Vr/Pr:0,Di=Math.floor(Ei*(Zn.length-1)),Hi=Zn[Di]||[0,0,0,255],Pi=Math.round(Ur+(Rr-Ur)*Ei),Qi=[Hi[0]!==void 0?Hi[0]:0,Hi[1]!==void 0?Hi[1]:0,Hi[2]!==void 0?Hi[2]:0,Pi];try{sr.set(qr,Qi)}catch{}try{sr.set(String(qr),Qi)}catch{}try{sr.set(String(Wr),Qi)}catch{}})}else Vn.forEach((fr,mr)=>{sr.set(String(fr),Zn[mr%Zn.length]);const Pr=uo(fr);isNaN(Pr)||sr.set(Pr,Zn[mr%Zn.length])});return sr},[Un,Bs,Mn,$n]);React.useEffect(()=>{try{if(!Un)return;const kn=Un.getAllDomains().map(On=>Mn==="domainName"?On.domainName:jl(On,Mn)).filter(On=>On!=null&&On!==""),Vn=[...new Set(kn)],Dn=Vn.map(On=>uo(On)).filter(On=>!isNaN(On)).length===Vn.length&&Vn.length>0}catch(En){console.error("ColorSelect domain logging error",En)}},[Mn,Un,Xa,Bs?.name,Bs?.type,$n]),React.useMemo(()=>{const En=[],kn=_l||ss;if(kn&&kn.size>0){const Dn=new Set,On=[];for(const[sr,fr]of kn.entries())if(typeof sr=="string"){const mr=String(sr).trim();!Dn.has(mr)&&mr.length>0&&(Dn.add(mr),On.push({label:mr,color:fr}))}const Pn=[],Zn=new Set;for(const sr of On)Zn.has(sr.label)||(Zn.add(sr.label),Pn.push(sr));Pn.length>0&&En.push({id:"genes",title:"Gene families",items:Pn.slice(0,20)})}if(Li&&Li.enabled&&us&&Ht&&Gt){const Dn=new Set;us.leafNodes.forEach(Pn=>{const sr=(Ht[Pn.name]||{})[Gt];sr!=null&&sr!==""&&Dn.add(String(sr))});const On=Array.from(Dn).sort();if(On.length>0){let Pn=[];try{Pn=nr(Li.name,Math.max(On.length,Li.numColors||On.length),Li.reverse||!1)}catch{Pn=[]}const Zn=On.map((sr,fr)=>({label:sr,color:Pn[fr%(Pn.length||1)]||[0,0,0,255]}));En.push({id:"phylo",title:"Phylo labels",items:Zn})}}const Vn=[];Un&&Object.values(Un.ncRNAsById||{}).slice(0,20).forEach(Dn=>{const On=Dn.name||Dn.originalId||Dn.id||"ncRNA",Pn=Dn.fillColor||Dn.color||[0,0,0,255];Vn.push({label:String(On),color:Pn})}),Vn.length>0&&En.push({id:"ncrna",title:"ncRNAs",items:Vn});const Nn=Un.getAllRegions();if(Nn.length>0){const Dn=new Map;if(Nn.forEach(On=>{if(On.fillColor){const Pn=On.getColorKey();Pn!=null&&Pn!==""&&Dn.set(Pn,On.fillColor)}}),Dn.size>0){const On=Array.from(Dn.entries()).map(([Pn,Zn])=>({label:String(Pn),color:Zn}));En.push({id:"regions",title:"Regions",items:On})}}if(Rn)if(Rn.palette&&Rn.palette.enabled||Rn.colorBy==="identity_gradient"){let Dn=[];try{Dn=nr(Rn.palette?.name||DEFAULT_CONFIG$1.proteinLink.palette.name,Math.max(Rn.palette?.numColors||6,6),Rn.palette?.reverse||!1)}catch{Dn=[]}const On=(Dn.length>0?Dn:[[100,0,220,255]]).slice(0,12).map((Pn,Zn)=>({label:`${Zn+1}`,color:Pn}));En.push({id:"proteinLinks",title:"Protein links (palette)",items:On})}else Rn.colorBy==="source_gene"||Rn.colorBy==="target_gene"?En.push({id:"proteinLinks",title:"Protein links",note:`Colored by ${Rn.colorBy.replace("_"," ")}`}):En.push({id:"proteinLinks",title:"Protein links",items:[{label:"solid",color:Rn.solidColor||DEFAULT_CONFIG$1.proteinLink.solidColor}]});if(Tn)if(Tn.palette&&Tn.palette.enabled||Tn.colorBy==="identity_gradient"){let Dn=[];try{Dn=nr(Tn.palette?.name||DEFAULT_CONFIG$1.nucleotideLink.palette.name,Math.max(Tn.palette?.numColors||6,6),Tn.palette?.reverse||!1)}catch{Dn=[]}const On=(Dn.length>0?Dn:[[200,200,200,255]]).slice(0,12).map((Pn,Zn)=>({label:`${Zn+1}`,color:Pn}));En.push({id:"nucleotideLinks",title:"Nucleotide links (palette)",items:On})}else En.push({id:"nucleotideLinks",title:"Nucleotide links",items:[{label:"solid",color:Tn.solidColor||DEFAULT_CONFIG$1.nucleotideLink.solidColor}]});return En},[ss,_l,Li,us,Ht,Gt,JSON.stringify(Qt),JSON.stringify(mn),JSON.stringify(vn),Rn,Tn,An,mi]);const rl=React.useMemo(()=>{if(!Un||!us)return new Map;if((tn||qt.tree?.phyloLabelPosition||"after-tree")!=="after-tracks")return new Map;const kn=new Map;return us.leafNodes.forEach(Nn=>{kn.set(Nn.name,-1/0)}),Object.values(Un.genesById).forEach(Nn=>{const Dn=Nn.hood_id||Un.getHoodIdFromSeqid(Nn.seqid);if(Dn&&kn.has(Dn)){const On=kn.get(Dn);kn.set(Dn,Math.max(On,Math.max(Nn.start,Nn.end)))}}),Object.values(Un.ncRNAsById).forEach(Nn=>{const Dn=Nn.hood_id||Un.getHoodIdFromSeqid(Nn.seqid);if(Dn&&kn.has(Dn)){const On=kn.get(Dn);kn.set(Dn,Math.max(On,Math.max(Nn.start,Nn.end)))}}),Un.nucleotideLinks.filter(Nn=>Nn.hood).forEach(Nn=>{if(Nn.hood_id&&kn.has(Nn.hood_id)){const Dn=kn.get(Nn.hood_id);kn.set(Nn.hood_id,Math.max(Dn,Math.max(Nn.start,Nn.end)))}}),kn},[Un,us,tn,qt.tree?.phyloLabelPosition,mi,ws,pn,Gt,Ht,Wt,Kn]),mo=React.useMemo(()=>{const En=JSON.stringify(Qt||qt?.colorPalettes?.genePalette||{}),kn=JSON.stringify(mn||qt?.colorPalettes?.ncRNAPalette||{}),Vn=JSON.stringify(vn||qt?.colorPalettes?.regionPalette||{}),Nn=JSON.stringify(fn||qt?.colorPalettes?.domainPalette||{}),Dn=JSON.stringify(Rn||{}),On=JSON.stringify(Tn||{});return`${En}|${kn}|${Vn}|${Nn}|${Dn}|${On}|${mi}`},[Qt,mn,vn,Rn,Tn,mi,qt]),ra=React.useMemo(()=>{const En=new Map;if(!Un)return En;const kn=hi?.enabled,Vn=yn||Vt||"cluster",Nn=Dn=>{if(!Dn)return null;if(Array.isArray(Dn))return Dn.length>=3?Dn:null;if(typeof Dn=="string"){const On=Dn.split(",").map(Pn=>parseInt(Pn.trim(),10)).filter(Pn=>!isNaN(Pn));if(On.length>=3)return On.length===3?[...On,255]:On.slice(0,4)}return null};di&&di.size>0,Nt&&Object.keys(Nt).slice(0,3);for(const Dn in Un.genesById){const On=Un.genesById[Dn];let Pn=null;if(di&&(Pn=di.get(Dn)||di.get(On?.id)||di.get(On?.originalGeneId)||di.get(On?.gene_id),Dn.includes("gene_A1")),!Pn&&Nt){const Zn=On?.id||On?.gene_id||On?.originalGeneId||Dn,sr=Nt[Zn]||Nt[Dn];sr?.color&&(Pn=Nn(sr.color),Dn.includes("gene_A1"))}if(kn){if(!Pn&&ss){const Zn=On?.metadata?.[Vn];if(Zn!=null&&Zn!==""){const sr=normalizeKey(Zn);Pn=ya(ss,sr,hi?.type)}}if(!Pn&&Un.proteinClusters&&Un.proteinClusters[Dn]){const Zn=Un.proteinClusters[Dn];Un.clusterColors&&Un.clusterColors[Zn]&&(Pn=Un.clusterColors[Zn])}}En.set(Dn,Pn||null)}return[...En.entries()].filter(([,Dn])=>Dn!==null),En},[Un,Un?._paletteVersion,hi?.enabled,hi?.type,hi?.prevalenceFilter,mo,ss,yn,Vt,di,Nt]);React.useMemo(()=>{if(!Un)return[];const En=Ct instanceof Set?Ct:null,kn=Dn=>Dn?.gene_id||Dn?.originalGeneId||Dn?.originalId||Dn?.id||Dn?.uniqueId||"",Vn=Dn=>{const On=kn(Dn),Pn=Dn?.hood_id??Dn?.hoodId;return ii(Pn)||ti.size>0&&On&&ti.has(String(On))?!1:En&&On?En.has(String(On)):!0};if(ci)try{const Dn=Un.filterBySelectedNode(ci);if(Dn&&Array.isArray(Dn.genes))return Dn.genes.filter(Vn).map(On=>{const Pn=On.uniqueId||On.id||"";return{id:Pn,gene:On,start:On.start,end:On.end,strand:On.strand,trackY:On.trackY,fillColor:ra.get(Pn)||An.geneFill||[200,200,200,255]}})}catch{}const Nn=Object.entries(Un.genesById).filter(([,Dn])=>Vn(Dn)).map(([Dn,On])=>({id:Dn,gene:On,start:On.start,end:On.end,strand:On.strand,trackY:On.trackY,fillColor:ra.get(Dn)||An.geneFill||[200,200,200,255]}));return Nn.filter(Dn=>Dn.fillColor&&Dn.fillColor[0]!==200),Nn},[Un,Un?._paletteVersion,hi?.enabled,ra,An,mo,Ct,ti,ii,ci,mi,Kn,gn]);const dl=React.useMemo(()=>JSON.stringify(Rn),[Rn]),Tl=React.useMemo(()=>JSON.stringify(Tn),[Tn]),Rl=React.useMemo(()=>{if(!Un||!Un.proteinLinks||!Array.isArray(Un.proteinLinks))return[];Rn&&Un.applyProteinLinkColors(Rn,An.geneFill);let En=null;if(ci&&Un.getNodeDescendantLeaves)try{const Vn=Un.getNodeDescendantLeaves(ci);Array.isArray(Vn)&&Vn.length>0&&(En=new Set(Vn))}catch(Vn){console.warn("[proteinLinkData] Error getting descendant leaves:",Vn)}const kn=Vn=>{if(!Vn)return null;const Nn=Vn.attributes;let Dn=null;if(Nn)if(typeof Nn=="string"){const On=Nn.match(/ID=([^;]+)/);Dn=On?On[1]:null}else typeof Nn=="object"&&(Dn=Nn.ID||Nn.gene_id||Nn.protein_id||null);return Vn.originalGeneId||Vn.gene_id||Dn||Vn.uniqueId};return Un.proteinLinks.filter(Vn=>{const Nn=Un.genesById[Vn.gAId],Dn=Un.genesById[Vn.gBId],On=Nn?.hood_id,Pn=Dn?.hood_id;if(ii(On)||ii(Pn))return!1;if(ti.size>0){const Zn=kn(Nn),sr=kn(Dn);if(Zn&&ti.has(String(Zn))||sr&&ti.has(String(sr)))return!1}return En?On&&Pn&&En.has(On)&&En.has(Pn):!0}).map((Vn,Nn)=>{let Dn=Vn.fillColor||[150,150,150,255];if(hi?.transparentByPrevalence&&ss){const On=Un.genesById[Vn.gAId],Pn=Un.genesById[Vn.gBId],Zn=yn||Vt||"cluster";let sr=On?.metadata?.[Zn];(sr==null||sr==="")&&Zn==="cluster"&&(sr=On?.metadata?.clusterId??On?.metadata?.cluster_id??On?.cluster);const fr=sr!=null&&sr!==""?ya(ss,sr,hi?.type):null;let mr=Pn?.metadata?.[Zn];(mr==null||mr==="")&&Zn==="cluster"&&(mr=Pn?.metadata?.clusterId??Pn?.metadata?.cluster_id??Pn?.cluster);const Pr=mr!=null&&mr!==""?ya(ss,mr,hi?.type):null,Ur=fr&&Array.isArray(fr)&&fr.length>=4?fr[3]/255:0,Rr=Pr&&Array.isArray(Pr)&&Pr.length>=4?Pr[3]/255:0,Wr=Math.min(Ur,Rr),$r=Array.isArray(Dn)&&Dn.length>=4?Dn[3]/255:1,qr=Math.round($r*Wr*255);Dn=Array.isArray(Dn)?[Dn[0],Dn[1],Dn[2],qr]:Dn}return{id:`${Vn.gAId}|${Vn.gBId}|${Nn}`,gAId:Vn.gAId,gBId:Vn.gBId,metadata:Vn.metadata||Vn,fillColor:Dn,_k:`${mi}_${Nn}`}})},[Un,Un?.proteinLinks,Un?._paletteVersion,mo,mi,dl,ss,ci,ii,ti,hi?.enabled,hi?.transparentByPrevalence,hi?.prevalenceFilter,yn,Vt,An.geneFill]);React.useEffect(()=>{},[ci]);const Ma=React.useMemo(()=>{if(!Un||!Un.nucleotideLinks||!Array.isArray(Un.nucleotideLinks))return[];Tn&&Un.applyNucleotideLinkColors(Tn);let En=null;if(ci&&Un.getNodeDescendantLeaves)try{const Vn=Un.getNodeDescendantLeaves(ci);Array.isArray(Vn)&&Vn.length>0&&(En=new Set(Vn))}catch{}return Un.nucleotideLinks.filter(Vn=>{const Nn=Vn.hoodA,Dn=Vn.hoodB;if(ii(Nn)||ii(Dn))return!1;if(!En)return!0;const On=En.has(Nn),Pn=En.has(Dn),Zn=On&&Pn;return!Zn&&Un.nucleotideLinks.indexOf(Vn)<5,Zn}).map((Vn,Nn)=>({id:`${Vn.seqidA}:${Vn.startA}-${Vn.endA}|${Vn.seqidB}:${Vn.startB}-${Vn.endB}|${Nn}`,seqidA:Vn.seqidA,seqidB:Vn.seqidB,hoodA:Vn.hoodA||Vn.seqidA,hoodB:Vn.hoodB||Vn.seqidB,hoodStartA:Vn.hoodStartA??Vn.startA,hoodEndA:Vn.hoodEndA??Vn.endA,hoodStartB:Vn.hoodStartB??Vn.startB,hoodEndB:Vn.hoodEndB??Vn.endB,similarity:Vn.similarity,metadata:{similarity:Vn.similarity},fillColor:Vn.fillColor||[200,100,100,255],_k:`${mi}_${Nn}`}))},[Un,Un?.nucleotideLinks,mo,mi,Tl,ci,ii]),kr=React.useMemo(()=>{const En=ir||qt,kn=typeof nn=="number"?nn:En.gene?.height||En.gene?.defaultHeight||DEFAULT_CONFIG$1.gene.height,Vn=typeof Zt=="number"?Zt:En.gene?.arrowheadHeight??DEFAULT_CONFIG$1.gene.arrowheadHeight,Nn=typeof gn=="number"?gn:En.tree?.ySpacing||DEFAULT_CONFIG$1.tree.ySpacing,Dn=typeof Kn=="number"?Kn:En.genome?.xScalePercent||DEFAULT_CONFIG$1.genome.xScalePercent,On=typeof Hn=="number"?Hn:En.gene?.edgeWidth||DEFAULT_CONFIG$1.gene.edgeWidth,Pn=typeof wn=="number"?wn:En.text?.phyloLabelSize||DEFAULT_CONFIG$1.text.phyloLabelSize,Zn=typeof Xn=="number"?Xn:En.text?.geneLabelSize||DEFAULT_CONFIG$1.text.geneLabelSize,sr=typeof tr=="number"?tr:En.text?.rulerLabelSize||DEFAULT_CONFIG$1.text.rulerLabelSize;return{...En,debug:{...En.debug,alignment:En?.debug?.alignment||!1},tree:{...En.tree,xScalePercent:ws,ySpacing:Nn},gene:{...En.gene,height:kn,arrowheadHeight:Vn,edgeWidth:On,tipWidthMode:rn??En.gene?.tipWidthMode??DEFAULT_CONFIG$1.gene.tipWidthMode,tipWidthFactor:on??En.gene?.tipWidthFactor??DEFAULT_CONFIG$1.gene.tipWidthFactor,tipWidthFixed:ln??En.gene?.tipWidthFixed??DEFAULT_CONFIG$1.gene.tipWidthFixed},genome:{...En.genome,xScalePercent:Dn},domain:{...En.domain},text:{...En.text,phyloLabelSize:Pn,geneLabelSize:Zn,rulerLabelSize:sr},stroke:{...En.stroke,lineWidth:On}}},[ir,qt,ws,nn,Zt,rn,on,ln,gn,Kn,Hn,wn,Xn,tr]);reactExports.useEffect(()=>{if(!ys||ys.length===0)return;const En=An.treeEdges||[100,180,255,255],kn=ys[0]?.color;(!kn||En[0]!==kn[0]||En[1]!==kn[1]||En[2]!==kn[2])&&Va(Nn=>Nn?Nn.map(Dn=>({...Dn,color:En})):null)},[An.treeEdges,ys?.length]),reactExports.useEffect(()=>{if(!ys||ys.length===0||!Ts.current?.nodes)return;const En=ys[0]?.id;if(!En)return;const kn=requestAnimationFrame(()=>{const Vn=Ts.current.nodes.find(Nn=>Nn.id===En);if(Vn){const Nn=(kr.tree?.xScalePercent||100)/100,Dn=Ii?.treeOffset||0,On=Number(Vn.rawY),Pn=Number(Vn.x);if(Number.isFinite(On)&&Number.isFinite(Pn)){const Zn=[On*Nn+Dn,Pn];Va(sr=>sr?sr.map(fr=>({...fr,position:Zn})):null)}}});return()=>cancelAnimationFrame(kn)},[kr.tree?.xScalePercent,Ii?.treeOffset,kr.tree?.ySpacing,ys?.[0]?.id]),reactExports.useEffect(()=>{if(!Wi||Wi.length===0||!Ts.current?.nodes)return;const En=Wi[0]?.id;if(!En)return;const kn=requestAnimationFrame(()=>{const Vn=Ts.current.nodes.find(Nn=>Nn.id===En||Nn.name===En||Nn.leaf_id===En||Nn.node?.id===En||Nn.node?.name===En||Nn.node?.leaf_id===En);if(Vn){const Nn=(kr.tree?.xScalePercent||100)/100,Dn=Ii?.treeOffset||0,On=Number(Vn.rawY),Pn=Number(Vn.x);if(Number.isFinite(On)&&Number.isFinite(Pn)){const Zn=[On*Nn+Dn,Pn];Mo(sr=>sr?sr.map(fr=>({...fr,position:Zn})):null)}}});return()=>cancelAnimationFrame(kn)},[kr.tree?.xScalePercent,Ii?.treeOffset,kr.tree?.ySpacing,Wi?.[0]?.id]);const kl=React.useCallback((En,kn=null)=>{if(!En)return null;const Vn=kr.gene?.height||kr.gene?.geneHeight||20,Nn=kr.gene?.arrowheadHeight||10,Dn=(kr.genome?.xScalePercent||100)/100,On=En.gene||En,Pn=kn??En.trackY??On.trackY??0,Zn=(En.start??On.start)*Dn,sr=(En.end??On.end)*Dn,fr=En.strand??On.strand,mr=Vn/2,Pr=Nn/2,Ur=Math.abs(sr-Zn),Rr=calculateTipWidth(Ur,kr);if(Rr<1){const Wr=Math.min(Zn,sr),$r=Math.max(Zn,sr);return[[Wr,Pn-mr],[$r,Pn-mr],[$r,Pn+mr],[Wr,Pn+mr]]}if(fr==="+"||fr===1){const Wr=Math.max(Zn,sr-Rr);return[[Zn,Pn-mr],[Wr,Pn-mr],[Wr,Pn-mr-Pr],[sr,Pn],[Wr,Pn+mr+Pr],[Wr,Pn+mr],[Zn,Pn+mr]]}else{const Wr=Math.min(sr,Zn+Rr);return[[sr,Pn-mr],[Wr,Pn-mr],[Wr,Pn-mr-Pr],[Zn,Pn],[Wr,Pn+mr+Pr],[Wr,Pn+mr],[sr,Pn+mr]]}},[kr.gene?.height,kr.gene?.geneHeight,kr.gene?.arrowheadHeight,kr.genome?.xScalePercent,kr.gene?.tipWidthFactor,kr.gene?.tipWidthMode,kr.gene?.tipWidthFixed]);reactExports.useEffect(()=>{if(!Mi||Mi.length===0)return;const En=Mi[0];if(En.polygon&&Array.isArray(En.polygon)&&En.polygon.length>0)return;const kn=En.gene||En,Vn=En.id||En.uniqueId||En.gene?.uniqueId||En.gene?.id,Nn=kn.hood_id||En.hood_id;let Dn=null;if(Un&&Nn&&typeof Un.getTrackYByHoodId=="function"&&(Dn=Un.getTrackYByHoodId(Nn)),Dn===null&&Un&&Vn&&Un.genesById){const sr=Un.genesById[Vn];sr&&(Dn=sr.trackY)}const Pn=ss?.get?.(Vn)||En.fillColor||En.gene?.fillColor||An.geneFill||qt.gene?.fillColor||[100,200,255,255],Zn=kl(En,Dn);Zn&&Wa(sr=>!sr||sr.length===0?null:sr.map(fr=>({...fr,polygon:Zn,fillColor:Pn,trackY:Dn??fr.trackY})))},[Mi,kl,An.geneFill,qt.gene?.fillColor,ss,Un]),reactExports.useEffect(()=>{if(!Mi||Mi.length===0||!Un||!Mi[0]?.polygon)return;const En=Mi[0],kn=En.id||En.uniqueId||En.gene?.uniqueId||En.gene?.id,Vn=En.gene||En,Nn=Vn.hood_id||En.hood_id,Dn=requestAnimationFrame(()=>{let On=null,Pn=En.start??Vn.start,Zn=En.end??Vn.end,sr=En.strand??Vn.strand;if(kn&&Un.genesById){const Rr=Un.genesById[kn];Rr&&(On=Rr.trackY,Pn=Rr.start,Zn=Rr.end,sr=Rr.strand)}On===null&&Nn&&typeof Un.getTrackYByHoodId=="function"&&(On=Un.getTrackYByHoodId(Nn));const mr=ss?.get?.(kn)||En.fillColor||En.gene?.fillColor||An.geneFill||qt.gene?.fillColor||[100,200,255,255],Pr={...En,start:Pn,end:Zn,strand:sr,trackY:On??En.trackY},Ur=kl(Pr,On);Ur&&Wa(Rr=>!Rr||Rr.length===0?null:Rr.map(Wr=>({...Wr,polygon:Ur,fillColor:mr,start:Pn,end:Zn,strand:sr,trackY:On??Wr.trackY})))});return()=>cancelAnimationFrame(Dn)},[An.geneFill,qt.gene?.fillColor,kr.gene?.height,kr.gene?.geneHeight,kr.gene?.arrowheadHeight,kr.genome?.xScalePercent,kr.gene?.tipWidthFactor,kr.tree?.ySpacing,gn,Kn,mi,ss,kl,Un]),reactExports.useEffect(()=>{if(!_o||_o.length===0||!Un)return;const kn=_o[0].id;if(!kn)return;const Vn=requestAnimationFrame(()=>{const On=(Un.getAllRegions?.()||[]).find(Pn=>Pn.id===kn);On&&lo(Pn=>{if(!Pn||Pn.length===0)return null;const Zn=On.fillColor||On.strokeColor||[255,180,50,255];return Pn.map(sr=>({...sr,polygon:On.polygon,startX:On.start,endX:On.end,strokeColor:Zn,fillColor:Zn,trackY:On.trackY}))})});return()=>cancelAnimationFrame(Vn)},[Un,kr.gene?.height,kr.gene?.geneHeight,kr.gene?.arrowheadHeight,kr.region?.padding,kr.tree?.ySpacing,kr.genome?.xScalePercent,gn,Kn,mi,mo]);const bo=React.useMemo(()=>{if(!Un||!us)return new Set;let En=Un.leaves||[];if(ci)try{const kn=typeof Un.getNodeDescendantLeaves=="function"?Un.getNodeDescendantLeaves(ci):us&&typeof us.getNodeDescendantLeaves=="function"?us.getNodeDescendantLeaves(ci):[];En=Array.isArray(kn)?kn:[]}catch{En=Un.leaves||[]}if(Qn){const kn=typeof Qn=="string"?Qn:Qn?.id!=null?String(Qn.id):null;kn&&!new Set(En).has(kn)&&(En=[...En,kn])}return new Set(En)},[Un,us,ci,Qn,gr]),Ys=React.useMemo(()=>{if(performance.now(),!Un||!us)return[];const En=`${Object.keys(Un.genesById).length}:${kr.gene.height}:${kr.gene.arrowheadHeight}:${kr.domain.heightFactor||.6}:${kr.genome.xScalePercent}:${kr.tree.ySpacing}:${mi}:${Lt}:${Pt||""}:${kt}:${ci?.id??"null"}:${bo.size}:${gr.size}:${ti.size}:${kr.gene.tipWidthMode}:${kr.gene.tipWidthFactor}:${kr.gene.tipWidthFixed}`,kn=qo.current===En,Vn=al.current===ws,Nn=qo.current===null,Dn=kn&&!Vn,On=kn&&Vn;if((Dn||On)&&!Nn)al.current=ws,Un.config=kr;else{const Fn=performance.now();try{Un.config=kr,typeof Un.computeTrackPositions=="function"&&Un.computeTrackPositions();const Gn=performance.now();for(const er in Un.genesById){const Er=Un.genesById[er];if(Er&&(Er.config=kr,Er.geneHeight=kr.gene.height,typeof Er.updatePolygon=="function"))try{Er.updatePolygon()}catch{}}}catch{}performance.now();for(const Gn in Un.ncRNAsById){const er=Un.ncRNAsById[Gn];er.config=kr,typeof kr?.gene?.height=="number"&&(er.featureHeight=kr.gene.height),er.updatePolygon&&er.updatePolygon()}performance.now();for(const Gn in Un.genesById){const er=Un.genesById[Gn];if(er&&er.domains)for(const Er of er.domains)Er.config=kr,Er.updatePolygon&&Er.updatePolygon()}Un._cachedAllDomains=void 0,performance.now(),Un.proteinLinks&&Un.proteinLinks.forEach(Gn=>{Gn.config=kr,Gn.updatePolygon&&Gn.updatePolygon()}),performance.now(),Un.nucleotideLinks&&Un.nucleotideLinks.forEach(Gn=>{Gn.config=kr,Gn.updatePolygon&&Gn.updatePolygon()}),performance.now(),Un.getAllRegions().forEach(Gn=>{Gn.config=kr;const er=Un.getTrackYByHoodId(Gn.hood_id);er!=null&&Gn.updatePolygon([],er)}),performance.now()-Fn,qo.current=En,al.current=ws,To.current=null}const Pn=`${En}:${ws}:${ci?.id??"null"}:${tn}:${Xt}`,Zn=On&&To.current===Pn,sr=`${Object.keys(Un.genesById).length}:${mi}:${ws}:${ci?.id??"null"}:${Xt}:${Lt}:${Pt||""}:${kt}:${gr.size}:${bo.size}:${kr.tree.ySpacing}:${kr.genome.xScalePercent}:${tn}:${wn}`,fr=$l.current?.signature===sr,mr=Ts.current?.structuralSignature===sr;performance.now();const Pr=vo(Un,us,tn,ws,!0,ms),Ur=Pr.treeOffset||0;Zl.current=Pr,performance.now();const Rr=(Ql||[]).map((Fn,Ln)=>({...Fn,polygon:Fn.polygon,fillColor:Fn.fillColor||An.proteinFill||Fn.fillColor,_alignmentKey:`${mi}_${Ln}`}));performance.now();const Wr=(so||[]).map((Fn,Ln)=>({...Fn,polygon:Fn.polygon,fillColor:Fn.fillColor||An.nucleotideFill||Fn.fillColor,_alignmentKey:`${mi}_${Ln}`}));performance.now();const $r=Fn=>{if(ti.size===0)return!1;const Ln=Fn.gene_id||Fn.geneId||Fn.metadata?.gene_id||Fn.metadata?.geneId||Fn.metadata?.Parent;return Ln?ti.has(String(Ln)):!1},qr=(Un.getAllRegions()||[]).filter(Fn=>{if(ii(Fn.hood_id)||$r(Fn))return!1;if(!ci)return!0;try{return bo.has(Fn.hood_id)}catch{return!0}}).map(Fn=>{let Ln=Fn.fillColor,Gn,er;return!Ln||Array.isArray(Ln)&&Ln[3]===0?(Gn=Fn.strokeColor||[100,100,100,255],er=[0,0,0,0]):(Gn=Ln,er=[0,0,0,0]),{polygon:Fn.polygon,fillColor:er,strokeColor:Gn,strokeWidth:Fn.strokeWidth,metadata:Fn.metadata,hood_id:Fn.hood_id,seqid:Fn.seqid,start:Fn.start,end:Fn.end,trackY:Fn.trackY,type:Fn.type||"region",id:Fn.id||Fn.metadata?.ID||`${Fn.hood_id}:${Fn.start}-${Fn.end}`}});Ta.current=qr,performance.now(),performance.now();const Vr=Un.getAllDomains();let ri=[];const Ei=Fn=>{const Gn=(Fn.gene||Fn.geneId&&Un.genesById[Fn.geneId])?.hood_id??Fn.hood_id;return ii(Gn)},Di=Fn=>{if(ti.size===0)return!1;const Ln=Fn.gene||Fn.geneId&&Un.genesById[Fn.geneId];if(!Ln)return!1;const Gn=typeof Ln.attributes=="string"?Ln.attributes.match(/ID=([^;]+)/)?.[1]||null:Ln.attributes?.ID||null,er=Ln.originalGeneId||Ln.gene_id||Gn||Fn.geneId;return er&&ti.has(String(er))};if(Vr.length!==0){let Fn=Vr;if(ci)try{const Ln=Un.filterBySelectedNode(ci);Ln&&Array.isArray(Ln.domains)&&(Fn=Ln.domains)}catch{}$n&&$n!=="all"&&(Fn=Fn.filter(Ln=>{const Gn=Ln&&(Ln.source||Ln.metadata&&Ln.metadata.source)||null;return String(Gn)===String($n)})),gr.size>0&&(Fn=Fn.filter(Ln=>!Ei(Ln))),ti.size>0&&(Fn=Fn.filter(Ln=>!Di(Ln))),performance.now(),ri=Fn.map(Ln=>{let Gn;if(!Bs||!Bs.enabled?Gn=An.domainFill:Gn=Ln.fillColor||An.domainFill,Xa){const er=Mn==="domainName"?Ln.domainName:jl(Ln,Mn);if(er!==void 0){const Er=ya(Xa,er,Bs?.type);Er&&(Gn=Er)}}if(hi?.transparentByPrevalence&&Ln.geneId&&ss){const er=Un.genesById[Ln.geneId];if(er){const Er=yn||Vt||"cluster";let Tr=er?.metadata?.[Er];(Tr==null||Tr==="")&&Er==="cluster"&&(Tr=er?.metadata?.clusterId??er?.metadata?.cluster_id??er?.cluster);const ai=Tr!=null&&Tr!==""?ya(ss,Tr,hi?.type):null;if(ai&&Array.isArray(ai)&&ai.length>=4){const Yr=ai[3]/255,li=Array.isArray(Gn)&&Gn.length>=4?Gn[3]/255:1,yi=Math.round(li*Yr*255);Gn=Array.isArray(Gn)?[Gn[0],Gn[1],Gn[2],yi]:Gn}else ai||(Gn=Array.isArray(Gn)?[Gn[0],Gn[1],Gn[2],0]:Gn)}}return{...Ln,fillColor:Gn,polygon:Ln.polygon?[...Ln.polygon]:null}})}performance.now();let Hi;if(fr)Hi=$l.current.data;else{const Fn=er=>{const Er=Un.hoodRanges[er],Tr=Un.hoodToSeqidMap[er],ai=Un.nucleotidesBySeqid[Tr];if(!Er||!ai)return null;const Yr=Un.trackOffset[er]||0,li=!!Un.trackFlipped[er],yi=Er.length/2,Ri=0,Ki=Er.length,ns=Un.constructor.getTransformedXUnified(Ri,yi,Yr,li),Vs=Un.constructor.getTransformedXUnified(Ki,yi,Yr,li),Ps=kr.genome&&typeof kr.genome.xScalePercent=="number"?kr.genome.xScalePercent/100:1,ks=yi+(ns-yi)*Ps,Ms=yi+(Vs-yi)*Ps,fo=Un.getTrackYByHoodId(er);return fo==null?null:{hood_id:er,seqid:Tr,start:ks,end:Ms,trackY:fo}},Ln=Object.keys(Un.hoodRanges||{});let Gn=ci?Array.from(bo):Ln;if(Gn.length||(Gn=Ln),Hi=Gn.filter(er=>!Un.hoodRanges[er]||gr.size>0&&(gr.has(String(er))||gr.has(Number(er)))?!1:Un.getTrackYByHoodId(er)!=null).map(Fn).filter(Boolean),!Hi.length&&Gn.length){try{Un.computeTrackPositions()}catch{}Hi=Gn.filter(er=>!Un.hoodRanges[er]||gr.size>0&&(gr.has(String(er))||gr.has(Number(er)))?!1:Un.getTrackYByHoodId(er)!=null).map(Fn).filter(Boolean)}$l.current={data:Hi,signature:sr}}performance.now();const Pi=po?us.buildEdges().filter(Fn=>{if(!ci)return!0;try{const Ln=Un.getNodeDescendantLeaves(Fn.target)||[];return!Array.isArray(Ln)||Ln.length===0?!1:Ln.every(Gn=>bo.has(Gn))}catch{return!1}}).map(Fn=>({rawPath:Fn.path,metadata:{source:Fn.source.name||`internal_${Fn.source.id}`,target:Fn.target.name||`internal_${Fn.target.id}`,length:Fn.target.branchLength||0,type:"phylo_edge"},color:An?.treeEdges||qt.tree.edgeColor||[85,85,85,255]})):[];performance.now();const Qi=tn||qt.tree?.phyloLabelPosition||"after-tree",Si=sn!==void 0?sn:qt.tree?.alignLabels!==void 0?qt.tree.alignLabels:!0,Ci=Wt?Array.isArray(Wt)?Wt:Wt.split(",").map(Fn=>Fn.trim()).filter(Boolean):null;let Ai=[],Xs="";if(po){let Fn=us.leafNodes.filter(er=>!ci||bo.has(er.name)).map(er=>{const Er=typeof _i=="function"?_i(er.name):Ht?.[er.name]||{};let Tr;if(Ci&&Ci.length>0){const Yr=Ci.map(li=>li==="name"?er.name:Er[li]).filter(li=>li!=null&&li!=="");Tr=Yr.length>0?Yr.join(" | "):er.name}else Tr=Er[Wt],Tr==null&&(Tr=er.name);typeof Tr!="string"&&(Tr=String(Tr));let ai;if(Li&&Li.enabled){const Yr=Er[Gt];Yr!=null?ai=nl(Yr):ai=An.phyloLabelFill||[0,0,0,255]}else ai=An.phyloLabelFill||[0,0,0,255];return{rawY:er.y,x:er.x,text:Tr,color:ai,size:kr.text.phyloLabelSize,textAnchor:"start",alignmentBaseline:"center",leafNode:er,labelPosition:Qi,rightmostX:Qi==="after-tracks"?rl.get(er.name):null}});const Ln=er=>{if(!er)return null;if(Array.isArray(er))return er.length>=3?er:null;if(typeof er=="string"){const Er=er.split(",").map(Tr=>parseInt(Tr.trim(),10)).filter(Tr=>!isNaN(Tr));if(Er.length>=3)return Er.length===3?[...Er,255]:Er.slice(0,4)}return null};let Gn;Li&&Li.enabled&&Ht?Gn=Ho(Fn,Gt,Ht,Li,cc?Sl:null).map(Er=>{if(Bi){const Yr=Bi.get(Er.leafNode.name);if(Yr)return{...Er,color:Yr}}const Tr=_i(Er.leafNode.name);if(Tr?.color){const Yr=Ln(Tr.color);if(Yr)return{...Er,color:Yr}}const ai=Ht?.[Er.leafNode.name]?.[Gt];return ai!=null&&ai!==""?Er:{...Er,color:An.phyloLabelFill}}):Gn=Fn.map(er=>{if(Bi){const Tr=Bi.get(er.leafNode.name);if(Tr)return{...er,color:Tr}}const Er=_i(er.leafNode.name);if(Er?.color){const Tr=Ln(Er.color);if(Tr)return{...er,color:Tr}}return{...er,color:An.phyloLabelFill}}),Ai=Gn.filter(er=>Number.isFinite(er.rawY)&&Number.isFinite(er.x)&&typeof er.text=="string"&&er.text.trim()!==""),Ai.length===0&&Ai.push({rawY:0,x:0,text:"_",color:[0,0,0,0],size:1,textAnchor:"start"}),Xs=Ai.map(er=>Array.isArray(er.color)?er.color.join(","):String(er.color)).join("|")}performance.now();const Ks=qt?.tree?.nodeRadius||{internal:4,leaf:2};let fa=`${us.allNodes.length}:${ci?.id||"null"}:${Ks?.internal||4}:${Ks?.leaf||2}:${Xt}:${kr.tree.ySpacing}`;const ia=po&&(mr||Zn)&&Ts.current&&Ts.current.geometrySignature===fa;let Qs;if(!po)Qs=[],fa="no-tree";else if(ia){const Fn=new Map;Ai&&Array.isArray(Ai)&&Ai.forEach(Ln=>{Ln.leafNode&&Ln.leafNode.name&&Fn.set(Ln.leafNode.name,Ln.color)}),Qs=Ts.current.nodes.map(Ln=>{let Gn;const er=Ln.node;return er.branchset.length>0?Gn=An.treeEdges||[0,0,0,255]:Gn=Fn.get(er.name)||An.treeEdges||[100,100,100,255],{...Ln,color:Gn}}),Ts.current={...Ts.current,nodes:Qs}}else{const Fn=ci?bo:null,Ln=new Map;Ai&&Array.isArray(Ai)&&Ai.forEach(Gn=>{Gn.leafNode&&Gn.leafNode.name&&Ln.set(Gn.leafNode.name,Gn.color)}),Qs=us.allNodes.filter(Gn=>{if(!ci)return!0;try{const er=Un.getNodeDescendantLeaves(Gn)||[];return er.length===0?!1:er.every(Er=>Fn.has(Er))}catch{return!1}}).map(Gn=>{const er=Un.getNodeDescendantLeaves(Gn);!ci||er.some(Ki=>Fn.has(Ki));let Er;const Tr=Gn.metadata||_i(Gn.name)||{},ai=Tr.leaf_id||Gn.leaf_id;if(!Gn.leaf_id&&ai&&(Gn.leaf_id=ai),!Gn.metadata&&Object.keys(Tr).length&&(Gn.metadata=Tr),Gn.branchset.length>0)Er=An.treeEdges||[0,0,0,255];else{const Ki=Ln.get(Gn.name);if(Ki)Er=Ki;else{const Vs=(Gn.metadata||{})[Gt];if(Vs&&Li&&Li.enabled)try{const ks=[...new Set(us.leafNodes.map(fo=>{const Jo=(Ht&&Ht[fo.name]||{})[Gt];return Jo!=null&&Jo!==""?Jo:null}).filter(fo=>fo!==null))].sort(),Ms=ks.indexOf(Vs);if(Ms>=0){const fo=nr(Li.name,Math.max(ks.length,Li.numColors||ks.length),Li.reverse||!1);fo&&fo[Ms]?Er=fo[Ms]:Er=An.treeEdges||[100,100,100,255]}else Er=An.treeEdges||[100,100,100,255]}catch{const ks=String(Vs);let Ms=0;for(let ha=0;ha<ks.length;++ha)Ms=ks.charCodeAt(ha)+((Ms<<5)-Ms);const fo=Ms>>0&255,Qo=Ms>>8&255,Jo=Ms>>16&255;Er=[Math.abs(fo),Math.abs(Qo),Math.abs(Jo),255]}else Er=An.treeEdges||[100,100,100,255]}}const Yr=Array.isArray(Gn.branchset)&&Gn.branchset.length>0,li=Yr?Ks.internal||4:Ks.leaf||2,Ri=ci&&ci.id===Gn.id&&Yr?Math.max(li*2,li+8):li;return{id:Gn.id,name:Gn.name,leaf_id:ai,node:Gn,rawY:Gn.y,x:Gn.x,color:Er,radius:Ri,metadata:{...Tr,name:Gn.name,id:Gn.id,leaf_id:ai||Tr.leaf_id||Gn.leaf_id}}}),Ts.current={nodes:Qs,geometrySignature:fa,structuralSignature:sr}}function Ia(Fn){const Ln=Yr=>{if(Array.isArray(Yr))return Yr.length===3?[Yr[0],Yr[1],Yr[2],255]:Yr;if(typeof Yr=="string"){const li=Yr.split(",").map(yi=>parseInt(yi.trim(),10)).filter(yi=>!isNaN(yi));if(li.length===3)return[li[0],li[1],li[2],255];if(li.length>=4)return[li[0],li[1],li[2],li[3]]}return Array.isArray(An.geneFill)?An.geneFill:[150,150,150,255]};if(!hi?.enabled){const Yr=Ln(An.geneFill||kr.gene.fillColor),yi=An.background==="#ffffff"?.7:1.3;return[Math.max(0,Math.min(255,Math.floor(Yr[0]*yi))),Math.max(0,Math.min(255,Math.floor(Yr[1]*yi))),Math.max(0,Math.min(255,Math.floor(Yr[2]*yi))),Yr[3]??255]}let Gn=null;const er=yn||Vt||"cluster";if(ss){let Yr=Fn?.metadata?.[er];(Yr==null||Yr==="")&&er==="cluster"&&(Yr=Fn?.metadata?.clusterId??Fn?.metadata?.cluster_id??Fn?.cluster),Yr!=null&&Yr!==""&&(Gn=ya(ss,Yr,hi?.type)||null)}let Er;if(ss&&er!=="cluster")if(Gn)Er=Ln(Gn);else if(hi.transparentByPrevalence){const Yr=Ln(kr.gene.fillColor);Er=[Yr[0],Yr[1],Yr[2],0]}else Er=Ln(kr.gene.fillColor);else if(Gn)Er=Ln(Gn);else if(hi.transparentByPrevalence){const Yr=Ln(Fn.fillColor||kr.gene.fillColor);Er=[Yr[0],Yr[1],Yr[2],0]}else Er=Ln(Fn.fillColor||kr.gene.fillColor);const ai=An.background==="#ffffff"?.7:1.3;return[Math.max(0,Math.min(255,Math.floor(Er[0]*ai))),Math.max(0,Math.min(255,Math.floor(Er[1]*ai))),Math.max(0,Math.min(255,Math.floor(Er[2]*ai))),Er[3]??255]}const ba=`${Object.keys(Un.genesById).length}:${kr.gene.height}:${ci?.id??"null"}:${mi}:${bo.size}:${gr.size}:${ti.size}`,zl=performance.now(),Ua=(()=>{if(On&&Da.current&&qa.current===ba)return Da.current.forEach(er=>{const Er=ra.get(er.uniqueId);er.fillColor=Er||er._originalFillColor||An.geneFill}),Da.current;const Fn=er=>{if(!er)return null;if(typeof er=="string"){const Er=er.match(/ID=([^;]+)/);return Er?Er[1]:null}else if(typeof er=="object")return er.ID||er.gene_id||er.protein_id||null;return null},Ln=(er,Er)=>{const Tr=er.hood_id??er.hoodId;if(gr.size>0&&Tr!=null&&(gr.has(String(Tr))||gr.has(Number(Tr))))return!1;const ai=Fn(er.attributes),Yr=er.originalGeneId||er.gene_id||ai||Er;return ti.size>0&&console.log("[isGeneVisibleInLayer] geneKey:",Yr,"uid:",Er,"originalGeneId:",er.originalGeneId,"attrId:",ai,"hiddenGeneSet:",Array.from(ti)),!(ti.size>0&&Yr&&ti.has(String(Yr)))};let Gn=Object.entries(Un.genesById).filter(([er,Er])=>Ln(Er,er));if(ci)try{Gn=Gn.filter(([er,Er])=>{const Tr=Er.hood_id||Un.getHoodIdFromSeqid(Er.seqid);return Tr?bo.has(Tr):!1})}catch{}return Gn.map(([er,Er])=>{const ai=ra.get(er)||Er.fillColor||An.geneFill;return{type:"gene",id:Er.id||er,uniqueId:er,start:Er.start,end:Er.end,trackY:Er.trackY,strand:Er.strand,fillColor:ai,_originalFillColor:Er.fillColor,geneHeight:Er.geneHeight||kr.gene.height,config:Er.config||kr,polygon:Er.polygon,metadata:Er.metadata}})})();Da.current=Ua,qa.current=ba,performance.now()-zl;const Il=typeof gn=="number"?gn:qt?.tree?.ySpacing||150,Oa=Po(Ua,ss,yn,Vt,An,kr||qt,ar,xn,Kn||100,Il);try{typeof console<"u"&&console.debug&&console.debug("[HoodiniViz] geneLabels sample:",{geneHeight:nn,effectiveGeneHeight:kr&&kr.gene?kr.gene.height:null,sample:Oa&&Oa.length?Oa.slice(0,6):[]})}catch{}const Xo=Ua.map(Fn=>{const Ln=Fn.geneHeight!==void 0&&Fn.geneHeight!==null?Fn.geneHeight:kr&&kr.gene?kr.gene.height:0,Gn=Fn.config&&Fn.config.gene&&Fn.config.gene.arrowheadHeight?Fn.config.gene.arrowheadHeight:kr&&kr.gene?kr.gene.arrowheadHeight:0;return`${Fn.uniqueId||""}:${Ln}:${Gn}`}).join("|"),Pa=8,Ko=(Fn,Ln=0,Gn=255)=>Math.max(Ln,Math.min(Gn,Fn)),Zo=(Fn,Ln)=>[Ko(Math.round(Fn[0]*Ln)),Ko(Math.round(Fn[1]*Ln)),Ko(Math.round(Fn[2]*Ln)),Fn[3]!==void 0?Ko(Math.round(Fn[3])):255],Ol=(Fn,Ln,Gn)=>[Math.round(Fn[0]+(Ln[0]-Fn[0])*Gn),Math.round(Fn[1]+(Ln[1]-Fn[1])*Gn),Math.round(Fn[2]+(Ln[2]-Fn[2])*Gn),Math.round((Fn[3]||255)+((Ln[3]||255)-(Fn[3]||255))*Gn)],$a=(Fn,Ln)=>{if(!Fn||Fn.length===0)return[];if(!Ln)return[];if(!(Ln.colorBy==="identity_gradient"&&Ln.palette&&Ln.palette.enabled))return[];let Gn=[];try{Gn=nr(Ln.palette.name,Ln.palette.numColors||8,Ln.palette.reverse||!1)}catch{Gn=[]}const er=[];for(const Er of Fn){const Tr=Er.polygon||[];if(!Tr||Tr.length<4)continue;const ai=Math.floor(Tr.length/2),Yr=[];for(let Ps=0;Ps<ai;Ps++){const ks=Tr[Ps],Ms=Tr[Ps+ai]||Tr[Tr.length-1];Yr.push([(ks[0]+Ms[0])/2,(ks[1]+Ms[1])/2])}if(Yr.length<2)continue;const li=Er.metadata&&typeof Er.metadata.similarity=="number"?Er.metadata.similarity:0,yi=Gn.length>0?Math.floor(Math.max(0,Math.min(1,li/100))*(Gn.length-1)):0,Ri=Gn.length>0?Gn[yi]:Er.fillColor||[150,150,150,255],Ki=Zo(Ri.slice(0,4),.9),ns=Zo(Ri.slice(0,4),1.1),Vs=Math.max(2,Pa);for(let Ps=0;Ps<Vs-1;Ps++){const ks=Ps/(Vs-1),Ms=(Ps+1)/(Vs-1),fo=Wl=>{const ho=Wl*(Yr.length-1),gl=Math.floor(ho),sa=Yr[gl],Eo=Yr[Math.min(Yr.length-1,gl+1)],tc=ho-gl;return[sa[0]+(Eo[0]-sa[0])*tc,sa[1]+(Eo[1]-sa[1])*tc]},Qo=fo(ks),Jo=fo(Ms),ha=Ol(Ki,ns,ks),co=Ol(Ki,ns,Ms),Ca=Ol(ha,co,.5);er.push({path:[Qo,Jo],color:Ca,width:Math.max(1,Ln.strokeWidth||2)})}}return er};$a(Rr,Rn),$a(Wr,Tn);const Aa=(Un.nucleotideLinks||[]).map((Fn,Ln)=>{let Gn=Fn.fillColor||An.nucleotideFill;try{const er=Un.genesById&&Un.genesById[Fn.gAId],Er=Un.genesById&&Un.genesById[Fn.gBId],Tr=yn||Vt||"cluster",ai=er&&ss?.get(er.metadata?.[Tr])||Er&&ss?.get(Er.metadata?.[Tr]);ai&&(Gn=ai)}catch{}return{hoodA:Fn.hoodA,hoodB:Fn.hoodB,hoodStartA:Fn.hoodStartA,hoodEndA:Fn.hoodEndA,hoodStartB:Fn.hoodStartB,hoodEndB:Fn.hoodEndB,seqidA:Fn.seqidA,seqidB:Fn.seqidB,fillColor:Gn,metadata:Fn.metadata,_k:`${mi}_${Ln}`}}).filter(Fn=>!(!Fn.hoodA||!Fn.hoodB||gr.size>0&&(gr.has(String(Fn.hoodA))||gr.has(Number(Fn.hoodA))||gr.has(String(Fn.hoodB))||gr.has(Number(Fn.hoodB))))),fl=(Rr||[]).map((Fn,Ln)=>{let Gn=Fn.fillColor||An.proteinFill||[200,200,200,255];try{const er=Un.genesById&&Un.genesById[Fn?.metadata?.gAId],Er=Un.genesById&&Un.genesById[Fn?.metadata?.gBId],Tr=yn||Vt||"cluster",ai=er&&ss?.get(er.metadata?.[Tr])||Er&&ss?.get(Er.metadata?.[Tr]);ai&&(Gn=ai)}catch{}return{gAId:Fn?.metadata?.gAId,gBId:Fn?.metadata?.gBId,fillColor:Gn,metadata:Fn.metadata,_k:`${mi}_${Ln}`}}).filter(Fn=>Fn.gAId&&Fn.gBId),hl=(Fn,Ln,Gn,er,Er=20)=>{const Tr=[];for(let ai=0;ai<=1;ai+=1/Er){const Yr=Math.pow(1-ai,3)*Fn[0]+3*Math.pow(1-ai,2)*ai*Ln[0]+3*(1-ai)*ai*ai*Gn[0]+ai*ai*ai*er[0],li=Math.pow(1-ai,3)*Fn[1]+3*Math.pow(1-ai,2)*ai*Ln[1]+3*(1-ai)*ai*ai*Gn[1]+ai*ai*ai*er[1];Tr.push([Yr,li])}return Tr},pl=(Fn,Ln)=>{if(!Fn||!Ln)return[];const Gn=Math.min(Fn.start,Fn.end),er=Math.max(Fn.start,Fn.end),Er=Math.min(Ln.start,Ln.end),Tr=Math.max(Ln.start,Ln.end),ai=Fn.trackY,Yr=Ln.trackY;let li,yi;ai<=Yr?(li={left:[Gn,ai],right:[er,ai]},yi={left:[Er,Yr],right:[Tr,Yr]}):(li={left:[Er,Yr],right:[Tr,Yr]},yi={left:[Gn,ai],right:[er,ai]});const Ri=(li.left[1]+yi.right[1])/2,Ki=(Ps,ks)=>hl(Ps,[Ps[0],Ri],[ks[0],Ri],ks,20),ns=Ki(li.right,yi.right),Vs=Ki(yi.left,li.left);return[li.left,li.right,...ns,yi.right,yi.left,...Vs]},vl=Fn=>{if(Fn.gene&&Fn.gene.polygon&&Array.isArray(Fn.gene.polygon)&&Fn.gene.polygon.length>0)return Fn.gene.polygon;const Ln=Fn.trackY;if(Ln==null)return[];const Gn=kr.gene.height||kr.gene.defaultHeight,er=kr.gene.arrowheadHeight||0;let Er=Fn.start,Tr=Fn.end;if(Er>Tr){const Ki=Er;Er=Tr,Tr=Ki}const ai=Math.abs(Tr-Er),Yr=calculateTipWidth(ai,kr),li=Gn/2,yi=Fn.strand==="+",Ri=li+er/2;return yi?[[Er,Ln-li],[Tr-Yr,Ln-li],[Tr-Yr,Ln-Ri],[Tr,Ln],[Tr-Yr,Ln+Ri],[Tr-Yr,Ln+li],[Er,Ln+li]]:[[Tr,Ln-li],[Er+Yr,Ln-li],[Er+Yr,Ln-Ri],[Er,Ln],[Er+Yr,Ln+Ri],[Er+Yr,Ln+li],[Tr,Ln+li]]},bc=typeof kr.gene.glowPadFactor=="number"?kr.gene.glowPadFactor:.2;(kr.gene.height||kr.gene.defaultHeight||10)*bc;const Mr=((Fn,Ln=[100,100,100,255])=>{const Gn=er=>Math.max(0,Math.min(255,Math.round(er)));if(Array.isArray(Fn)){const[er=0,Er=0,Tr=0,ai=255]=Fn;return[Gn(er),Gn(Er),Gn(Tr),Gn(ai)]}if(typeof Fn=="string"){const er=Fn.split(",").map(Er=>parseInt(Er.trim(),10)).filter(Er=>!isNaN(Er));if(er.length>=3){const[Er,Tr,ai,Yr=255]=er;return[Gn(Er),Gn(Tr),Gn(ai),Gn(Yr)]}}return Ln})(An.hoods||kr.colors.darkGray||[85,85,85,255]),Br=kr.hood?.width||kr.stroke?.hoodWidth||kr.stroke?.lineWidth||2;performance.now();const Nr=[new LineLayer({id:"hoods",data:Hi,visible:Dr,getSourcePosition:Fn=>[Fn.start,Fn.trackY],getTargetPosition:Fn=>[Fn.end,Fn.trackY],getColor:Mr,getWidth:Br,widthUnits:"meters",pickable:!1,updateTriggers:{getSourcePosition:[Hi,mi,ki,gn,Kn],getTargetPosition:[Hi,mi,ki,gn,Kn]}}),new PolygonLayer({id:"protein-polygons",data:fl,visible:Cr,getPolygon:Fn=>{const Ln=bs.current;if(ci&&bo.size>0){const Er=Ln?.genesById?.[Fn.gAId],Tr=Ln?.genesById?.[Fn.gBId],ai=Er?.hood_id,Yr=Tr?.hood_id;if(ai&&Yr&&(!bo.has(ai)||!bo.has(Yr)))return[]}if(ti.size>0){const Er=Ln?.genesById?.[Fn.gAId],Tr=Ln?.genesById?.[Fn.gBId],ai=(yi,Ri)=>{if(!yi)return Ri;const Ki=typeof yi.attributes=="string"?yi.attributes.match(/ID=([^;]+)/)?.[1]||null:yi.attributes?.ID||null;return yi.originalGeneId||yi.gene_id||Ki||Ri},Yr=ai(Er,Fn.gAId),li=ai(Tr,Fn.gBId);if(Yr&&ti.has(String(Yr))||li&&ti.has(String(li)))return[]}const Gn=Ln?.genesById?.[Fn.gAId],er=Ln?.genesById?.[Fn.gBId];return pl(Gn,er)},getFillColor:Fn=>{bs.current;let Ln=An?.geneFill?.slice(0,3)||[100,150,200],Gn=255;const er=Rn?.colorBy;if(er==="source_gene"){const Tr=ra.get(Fn.gAId);Tr&&(Ln=Tr.slice(0,3))}else if(er==="target_gene"){const Tr=ra.get(Fn.gBId);Tr&&(Ln=Tr.slice(0,3))}else if(er==="identity_solid")Rn?.solidColor&&(Ln=Rn.solidColor.slice(0,3));else if(er==="identity_gradient"&&Rn?.palette?.enabled)try{const Tr=nr(Rn.palette.name,Rn.palette.numColors,Rn.palette.reverse),ai=Fn.metadata?.similarity??50,Yr=Math.max(0,Math.min(1,ai/100)),li=Math.floor(Yr*(Tr.length-1));Ln=Tr[li]?.slice(0,3)||Ln}catch{}const Er=Rn||kr?.proteinLink||DEFAULT_CONFIG$1.proteinLink;if(Er?.useAlpha&&Fn.metadata?.similarity!==void 0){const Tr=Fn.metadata.similarity/100,ai=Er.minAlpha??0,li=(Er.maxAlpha??.5)-ai,yi=ai+Tr*li;Gn=Math.round(yi*255)}if(Fn.fillColor&&Array.isArray(Fn.fillColor)&&Fn.fillColor.length>=4){const Tr=Fn.fillColor[3]/255;Gn=Math.round(Gn*Tr)}return[...Ln,Gn]},stroked:!1,autoHighlight:!0,filled:!0,pickable:!0,updateTriggers:{getPolygon:[fl,mi,mo,ci,gn,Kn],getFillColor:[fl,mo,dl,ra.size,ss,hi?.prevalenceFilter,hi?.name,yn,Vt,An?.geneFill,ci]}}),new PolygonLayer({id:"nucleotide-polygons",data:Aa,visible:dr,getPolygon:Fn=>{const Ln=bs.current;if(!Ln)return[];if(ci&&bo.size>0&&(!bo.has(Fn.hoodA)||!bo.has(Fn.hoodB)))return[];if(ti.size>0&&Fn.geneA&&Fn.geneB){const co=(sa,Eo)=>{if(!sa)return Eo;const tc=typeof sa.attributes=="string"?sa.attributes.match(/ID=([^;]+)/)?.[1]||null:sa.attributes?.ID||null;return sa.originalGeneId||sa.gene_id||tc||Eo},Ca=Ln?.genesById?.[Fn.geneA],Wl=Ln?.genesById?.[Fn.geneB],ho=co(Ca,Fn.geneA),gl=co(Wl,Fn.geneB);if(ho&&ti.has(String(ho))||gl&&ti.has(String(gl)))return[]}const Gn=Ln.getTrackYByHoodId(Fn.hoodA),er=Ln.getTrackYByHoodId(Fn.hoodB);if(Gn==null||er==null)return[];const Tr=(Ln.config.genome&&typeof Ln.config.genome.xScalePercent=="number"?Ln.config.genome.xScalePercent:100)/100,ai=Ln.hoodRanges[Fn.hoodA],Yr=Ln.hoodRanges[Fn.hoodB],li=ai?ai.length/2:0,yi=Yr?Yr.length/2:0,Ri=Ln.trackOffset[Fn.hoodA]||0,Ki=Ln.trackOffset[Fn.hoodB]||0,ns=!!Ln.trackFlipped[Fn.hoodA],Vs=!!Ln.trackFlipped[Fn.hoodB],Ps=Ln.constructor.getTransformedXUnified;let ks=Ps(Fn.hoodStartA,li,Ri,ns),Ms=Ps(Fn.hoodEndA,li,Ri,ns),fo=Ps(Fn.hoodStartB,yi,Ki,Vs),Qo=Ps(Fn.hoodEndB,yi,Ki,Vs);ks=li+(ks-li)*Tr,Ms=li+(Ms-li)*Tr,fo=yi+(fo-yi)*Tr,Qo=yi+(Qo-yi)*Tr;const Jo=[[ks,Gn],[Ms,Gn]].sort((co,Ca)=>co[0]-Ca[0]),ha=[[fo,er],[Qo,er]].sort((co,Ca)=>co[0]-Ca[0]);return[Jo[0],Jo[1],ha[1],ha[0]]},getFillColor:Fn=>{let Ln=[200,200,200],Gn=255;const er=Tn?.colorBy,Er=Tn?.strandColoring,Tr=Fn.similarity??Fn.metadata?.similarity??50,ai=()=>{const li=bs.current;if(!li)return!0;const yi=li.nucleotideLinks?.find(Ms=>Ms.hoodA===Fn.hoodA&&Ms.hoodB===Fn.hoodB&&Ms.hoodStartA===Fn.hoodStartA);if(!yi)return!0;const Ri=yi.strandA||"+",Ki=yi.strandB||"+",ns=!!li.trackFlipped[Fn.hoodA],Vs=!!li.trackFlipped[Fn.hoodB];return(Ri==="+"!==ns?"+":"-")===(Ki==="+"!==Vs?"+":"-")};if(er==="solid")Er?ai()?Ln=Tn?.sameStrandColor?.slice(0,3)||[180,180,180]:Ln=Tn?.oppositeStrandColor?.slice(0,3)||[220,80,80]:Tn?.solidColor&&(Ln=Tn.solidColor.slice(0,3),!Tn?.useAlpha&&Tn.solidColor.length>3&&(Gn=Tn.solidColor[3]));else if(er==="identity_gradient"){if(Er){const yi=ai()?Tn?.sameStrandPalette:Tn?.oppositeStrandPalette;if(yi?.enabled)try{const Ri=nr(yi.name,yi.numColors,yi.reverse),Ki=Math.max(0,Math.min(1,Tr/100)),ns=Math.floor(Ki*(Ri.length-1));Ln=Ri[ns]?.slice(0,3)||Ln}catch{}}else if(Tn?.palette?.enabled)try{const li=nr(Tn.palette.name,Tn.palette.numColors,Tn.palette.reverse),yi=Math.max(0,Math.min(1,Tr/100)),Ri=Math.floor(yi*(li.length-1));Ln=li[Ri]?.slice(0,3)||Ln}catch{}}const Yr=Tn||kr?.nucleotideLink||DEFAULT_CONFIG$1.nucleotideLink;if(Yr?.useAlpha){const li=Tr/100,yi=Yr.minAlpha??0,Ki=(Yr.maxAlpha??.5)-yi,ns=yi+li*Ki;Gn=Math.round(ns*255)}return[...Ln,Gn]},stroked:!1,filled:!0,autoHighlight:!0,pickable:!0,updateTriggers:{getPolygon:[Aa,mi,mo,bs.current&&bs.current.config&&bs.current.config.genome&&bs.current.config.genome.xScalePercent||null,ci,gn,Kn],getFillColor:[Aa,mo,Tl,Tn?.useAlpha,Tn?.minAlpha,Tn?.maxAlpha,Tn?.colorBy,Tn?.strandColoring,Tn?.sameStrandColor,Tn?.oppositeStrandColor,Tn?.sameStrandPalette,Tn?.oppositeStrandPalette,ci,bs.current?.trackFlipped,mi]}}),new PolygonLayer({id:"region-polygons",data:qr,visible:pr,getPolygon:Fn=>Fn.polygon,getFillColor:Fn=>{const Ln=Fn.strokeColor||[100,100,100,255];return[Ln[0],Ln[1],Ln[2],30]},stroked:!0,getLineColor:Fn=>Fn.strokeColor||[100,100,100,255],getLineWidth:Fn=>Fn.strokeWidth||2,lineWidthUnits:"pixels",filled:!0,autoHighlight:!0,pickable:!0,updateTriggers:{getPolygon:[qr,mi,gn,Kn],getFillColor:[qr,mi],getLineColor:[qr,mi],getLineWidth:[qr,mi]}}),new PathLayer({id:"phylo-tree",data:Pi,visible:Wn&&po,getPath:Fn=>{const Ln=kr.tree&&typeof kr.tree.xScalePercent=="number"?kr.tree.xScalePercent/100:1;return Fn.rawPath.map(([Gn,er])=>[Gn*Ln+Ur,er])},getColor:Fn=>Fn.color||An.treeEdges||kr.tree.edgeColor,autoHighlight:!0,widthUnits:"pixels",jointRounded:!0,capRounded:!0,getWidth:()=>kr.tree.edgeWidth||3,pickable:!0,updateTriggers:{getPath:[Pi.length,kr.tree.xScalePercent,Ur,mi],getColor:[Pi.length,An.treeEdges,kr.tree.edgeColor],getWidth:kr.tree.edgeWidth}}),new PolygonLayer({id:"genes",data:Ua,visible:br,getPolygon:vl,getFillColor:Fn=>{const Ln=Tr=>{if(Array.isArray(Tr))return Tr.length===3?[Tr[0],Tr[1],Tr[2],255]:Tr;if(typeof Tr=="string"){const ai=Tr.split(",").map(Yr=>parseInt(Yr.trim(),10)).filter(Yr=>!isNaN(Yr));if(ai.length===3)return[ai[0],ai[1],ai[2],255];if(ai.length>=4)return[ai[0],ai[1],ai[2],ai[3]]}return An.geneFill||[150,150,150,255]};let Gn=null;const er=yn||Vt||"cluster";if(ss){let Tr=Fn?.metadata?.[er];(Tr==null||Tr==="")&&er==="cluster"&&(Tr=Fn?.metadata?.clusterId??Fn?.metadata?.cluster_id??Fn?.cluster),Tr!=null&&Tr!==""&&(Gn=ya(ss,Tr,hi?.type)||null)}if(!hi?.enabled)Gn||(Gn=An.geneFill||kr.gene.fillColor);else if(ss&&er!=="cluster"){if(!Gn)if(hi.transparentByPrevalence){const Tr=An.geneFill||kr.gene.fillColor;Gn=[Tr[0],Tr[1],Tr[2],0]}else Gn=An.geneFill||kr.gene.fillColor}else if(!Gn)if(hi.transparentByPrevalence){const Tr=Fn.fillColor||An.geneFill||kr.gene.fillColor;Gn=[Tr[0],Tr[1],Tr[2],0]}else Gn=Fn.fillColor||An.geneFill||kr.gene.fillColor;return Ln(Gn)},stroked:kr.gene.edgeWidth>0,getLineColor:Fn=>Ia(Fn),getLineWidth:()=>kr.gene.edgeWidth,lineWidthUnits:"pixels",lineWidthMinPixels:0,filled:!0,pickable:!0,autoHighlight:!0,updateTriggers:{getPolygon:[Ua,Xo,mi,kr.gene.height,kr.gene.defaultHeight,kr.gene.arrowheadHeight,kr.gene.tipWidthFactor,Zt,nn,ci,gn,Kn],getFillColor:[Ua,yn,Vt,mo,An.geneFill,mi,hi?.enabled,hi?.transparentByPrevalence],getLineColor:[Ua,yn,Vt,mo,An.geneFill,kr.gene.edgeWidth,mi,hr,hi?.transparentByPrevalence],getLineWidth:kr.gene.edgeWidth,stroked:kr.gene.edgeWidth}}),new PolygonLayer({id:`domains-${kr.gene.height}-${kr.gene.arrowheadHeight}`,data:ri,visible:Fr,getPolygon:Fn=>Fn.polygon,getFillColor:Fn=>Fn.fillColor||An.geneFill||qt.colors.gray,stroked:!0,getLineColor:Fn=>{const Ln=Fn.fillColor||qt.colors.black;return Array.isArray(Ln)&&Ln.length>=4&&Ln[3]<255?[0,0,0,Ln[3]]:qt.colors.black},getLineWidth:()=>kr.domain.edgeWidth||2,lineWidthUnits:"pixels",filled:!0,autoHighlight:!0,pickable:!0,updateTriggers:{getPolygon:[ri,mi,kr.domain.height,kr.gene.height,kr.gene.arrowheadHeight,kr.domain.heightFactor,$n,ci,gn,Kn],getFillColor:[ri.length,Mn,mo,An.domainFill,$n,ci,hi?.transparentByPrevalence,ss],getLineColor:[ri.length,hi?.transparentByPrevalence],getLineWidth:kr.domain.edgeWidth}}),new TextLayer({id:"gene-labels",data:Oa,visible:wr,getPosition:Fn=>Fn.position,getText:Fn=>Fn.text,getColor:Fn=>Fn.color,getSize:Fn=>Fn.size*(kr.text?.scaleFactors?.gene||1),sizeUnits:"meters",fontFamily:"sans-serif",getTextAnchor:Fn=>Fn.textAnchor||"middle",getAlignmentBaseline:Fn=>Fn.alignmentBaseline||"top",pickable:!1,updateTriggers:{getPosition:[Oa.length,mi,kr&&kr.gene?kr.gene.height:null,nn,ar,gn,Kn,Ua],getText:[Oa.length,xn,Kn,gn],getColor:[Oa.length,yn,hi&&hi.name||null,mo],getSize:[kr.text?.geneLabelSize,kr.text?.scaleFactors?.gene,Oa.length,nn,ar],getAlignmentBaseline:[Oa.length,ar,mi]}}),new TextLayer({id:"phylo-labels",data:Ai,visible:xr&&po,getPosition:Fn=>{const Ln=kr.tree&&typeof kr.tree.xScalePercent=="number"?kr.tree.xScalePercent/100:1;let Gn;if(Fn.labelPosition==="after-tracks")if(Si){const er=Ai.map(Tr=>Tr.rightmostX).filter(Tr=>isFinite(Tr));Gn=(er.length>0?Math.max(...er):Fn.rawY*Ln+Ur+(qt.tree?.labelOffset||10))+(qt.tree?.labelOffset||10)}else{let er=Fn.rightmostX;isFinite(er)?er+=kr.tree?.labelOffset||10:er=Fn.rawY*Ln+Ur+(kr.tree?.labelOffset||10),Gn=er}else if(Si){const er=Ai.map(Tr=>Tr.rawY*Ln);Gn=(er.length>0?Math.max(...er):Fn.rawY*Ln)+Ur+(kr.tree?.labelOffset||10)}else Gn=Fn.rawY*Ln+Ur+(kr.tree?.labelOffset||10);return[Gn,Fn.x]},getText:Fn=>Fn.text,getColor:Fn=>Fn.color,getSize:Fn=>Fn.size*kr.text.scaleFactors.phylo,sizeUnits:"meters",fontFamily:"sans-serif",getTextAnchor:Fn=>Fn.textAnchor||"start",getAlignmentBaseline:Fn=>Fn.alignmentBaseline||"center",getPixelOffset:Fn=>[5,0],background:Kt,getBackgroundColor:()=>{const Fn=An.background==="#ffffff";return Kt?[Fn?255:0,Fn?255:0,Fn?255:0,255]:[0,0,0,0]},backgroundPadding:Kt?[2,1,2,1]:[0,0,0,0],pickable:!1,updateTriggers:{getPosition:[Ai.length,kr.tree.xScalePercent,Ur,mi,rl,Si],getText:Ai,getSize:[kr.text.phyloLabelSize,kr.text.scaleFactors.phylo,Ai],getColor:[Ai,Gt,Li?`${Li.name}|${Li.numColors||0}|${Li.reverse||!1}|${Li.enabled||!1}`:null,Xs,An.phyloLabelFill,Ht?Object.keys(Ht).length:0],background:Kt,getBackgroundColor:Kt,backgroundPadding:Kt}}),new ScatterplotLayer({id:"nodes",data:Qs,visible:Wn&&po,getPosition:Fn=>{const Ln=Number(Fn.rawY),Gn=Number(Fn.x);if(!Number.isFinite(Ln)||!Number.isFinite(Gn))return[0,0];const er=kr.tree&&typeof kr.tree.xScalePercent=="number"?kr.tree.xScalePercent/100:1;return[Ln*er+Ur,Gn]},getFillColor:Fn=>Fn.color,getRadius:Fn=>Fn.radius,lineWidthUnits:"meters",radiusUnits:"meters",autoHighlight:!0,filled:!0,stroked:!1,pickable:!0,updateTriggers:{getPosition:[Qs.length,kr.tree.xScalePercent,Ur,mi],getFillColor:[Qs.length,An.treeEdges,ci,Gt,Li?`${Li.name}|${Li.numColors||0}|${Li.reverse||!1}|${Li.enabled||!1}`:null,Xs,Ht?Object.keys(Ht).length:0]}})];if(Kt){const Fn=us.leafNodes.filter(Ln=>ci&&!bo.has(Ln.name)?!1:Un.getTrackYByHoodId(Ln.name)!=null).map(Ln=>{const Gn=Un.getTrackYByHoodId(Ln.name);let er=1/0;const Er=Hi.find(Tr=>Tr.hood_id===Ln.name);return Er?er=Math.min(Er.start,Er.end):Object.values(Un.genesById).forEach(Tr=>{(Tr.hood_id===Ln.name||Un.getHoodIdFromSeqid(Tr.seqid)===Ln.name)&&(er=Math.min(er,Math.min(Tr.start,Tr.end)))}),{rawLeafY:Ln.y,leafX:Ln.x,genomeStartX:isFinite(er)?er:null,trackY:Gn,metadata:{leaf_id:Ln.name,type:"connecting_line"}}}).filter(Ln=>Ln.genomeStartX!==null);Fn.length>0&&Nr.unshift(new LineLayer({id:"connecting-lines",data:Fn,getSourcePosition:Ln=>{const Gn=kr.tree&&typeof kr.tree.xScalePercent=="number"?kr.tree.xScalePercent/100:1;return[Ln.rawLeafY*Gn+Ur,Ln.leafX]},getTargetPosition:Ln=>[Ln.genomeStartX,Ln.trackY],getColor:qt.connectingLines.color,getWidth:qt.connectingLines.width,widthUnits:"pixels",pickable:!0,autoHighlight:!1,updateTriggers:{getSourcePosition:[Fn.length,kr.tree.xScalePercent,Ur,mi],getTargetPosition:Fn}}))}let Hr=Object.values(Un.ncRNAsById||{});if(ci)try{const Fn=Un.filterBySelectedNode(ci)||{};Array.isArray(Fn.ncRNAs)&&(Hr=Fn.ncRNAs)}catch{}Hr=Hr.filter(Fn=>!ii(Fn.hood_id??Fn.hoodId)),ti.size>0&&(Hr=Hr.filter(Fn=>{const Ln=Fn.gene_id||Fn.geneId||Fn.metadata?.gene_id||Fn.metadata?.geneId||Fn.metadata?.Parent;return Ln?!ti.has(String(Ln)):!0})),Hr=Hr.map(Fn=>({...Fn,fillColor:Fn.fillColor||Fn.metadata&&Fn.metadata.color||An.geneFill})),Nr.push(new PolygonLayer({id:"ncrna-features",data:Hr,visible:_r,getPolygon:Fn=>Fn.polygon,getFillColor:Fn=>Fn.fillColor,stroked:kr.gene.edgeWidth>0,getLineColor:Fn=>Ia(Fn),getLineWidth:()=>kr.gene.edgeWidth,lineWidthUnits:"pixels",lineWidthMinPixels:0,filled:!0,pickable:!0,autoHighlight:!0,updateTriggers:{getPolygon:[Hr,kr.gene.height,kr.gene.arrowheadHeight,mi,mo,gn,Kn],getFillColor:[Hr.length,mo],getLineColor:[Hr.length,mo],getLineWidth:kr.gene.edgeWidth,stroked:kr.gene.edgeWidth}})),To.current=Pn,performance.now();try{console.groupEnd&&console.groupEnd()}catch{}return Nr},[kr,bo,ms,Un,Ii,mi,us,ci,Ma,Rl,ss,ra,Xa,hr,Kt,tn,sn,zt,Wt,Gt,pn,Ht,$n,ki,Rn,Tn,Nt,jt,Vt,yn,Mn,Qt,fn,xn,ar,gn,di,Bi,gr,ti,ii,Dr,Wn,br,Fr,Cr,dr,_r,pr,wr,xr,bs.current?._paletteVersion,hi?.enabled]);React.useMemo(()=>{const En=[],kn=Vn=>{const Nn=Dn=>Math.max(0,Math.min(255,Math.round(Dn)));if(Array.isArray(Vn)){const[Dn=0,On=0,Pn=0,Zn=255]=Vn;return[Nn(Dn),Nn(On),Nn(Pn),Nn(Zn??255)]}if(typeof Vn=="string"){const Dn=Vn.split(",").map(On=>parseInt(On.trim(),10)).filter(On=>!isNaN(On));if(Dn.length>=3){const[On,Pn,Zn,sr=255]=Dn;return[Nn(On),Nn(Pn),Nn(Zn),Nn(sr)]}}return[150,150,150,255]};if(Mi&&Mi.length>0){const Vn=Dn=>{const On=Dn?.fillColor||An.geneFill||qt.gene?.fillColor||[100,200,255,255];return kn(On)},Nn=Dn=>{if(Dn.polygon&&Array.isArray(Dn.polygon)&&Dn.polygon.length>0)return Dn.polygon;const On=Dn.gene||Dn,Pn=Dn.trackY??On.trackY??0,Zn=kr.gene?.height||kr.gene?.geneHeight||20,sr=kr.gene?.arrowheadHeight||10,fr=(kr.genome?.xScalePercent||100)/100,mr=(Dn.start??On.start)*fr,Pr=(Dn.end??On.end)*fr,Ur=Dn.strand??On.strand,Rr=Zn/2,Wr=sr/2,$r=Math.abs(Pr-mr),qr=calculateTipWidth($r,kr);if(qr<1){const[Vr,ri]=mr<Pr?[mr,Pr]:[Pr,mr];return[[Vr,Pn-Rr-Wr],[ri,Pn-Rr-Wr],[ri,Pn+Rr+Wr],[Vr,Pn+Rr+Wr]]}if(Ur==="+"||Ur===1){const Vr=Math.max(mr,Pr-qr);return[[mr,Pn-Rr],[Vr,Pn-Rr],[Vr,Pn-Rr-Wr],[Pr,Pn],[Vr,Pn+Rr+Wr],[Vr,Pn+Rr],[mr,Pn+Rr]]}else{const Vr=Math.min(Pr,mr+qr);return[[Pr,Pn-Rr],[Vr,Pn-Rr],[Vr,Pn-Rr-Wr],[mr,Pn],[Vr,Pn+Rr+Wr],[Vr,Pn+Rr],[Pr,Pn+Rr]]}};En.push(new PolygonLayer({id:"genes-glow-outer",data:Mi,getPolygon:Nn,stroked:!0,filled:!1,getLineWidth:35,getLineColor:Dn=>{const[On,Pn,Zn]=Vn(Dn);return[On,Pn,Zn,70]},lineWidthUnits:"pixels",lineWidthMinPixels:8,pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new PolygonLayer({id:"genes-glow-mid",data:Mi,getPolygon:Nn,stroked:!0,filled:!1,getLineWidth:18,getLineColor:Dn=>{const[On,Pn,Zn]=Vn(Dn);return[On,Pn,Zn,120]},lineWidthUnits:"pixels",lineWidthMinPixels:4,pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new PolygonLayer({id:"genes-glow-core",data:Mi,getPolygon:Nn,stroked:!0,filled:!0,getFillColor:Dn=>{const[On,Pn,Zn]=Vn(Dn);return[On,Pn,Zn,40]},getLineColor:[255,255,255,255],getLineWidth:3,lineWidthUnits:"pixels",lineWidthMinPixels:2,pickable:!1,parameters:{depthTest:!1,depthMask:!1,polygonOffset:[-2,-2]}}))}if(_o&&_o.length>0){console.log("[glowLayers] highlightedRegionData:",_o[0]);const Vn=Dn=>{const On=Dn?.fillColor||Dn?.strokeColor||[255,180,50,255];return console.log("[glowLayers] getRegionColor:",{fillColor:Dn?.fillColor,strokeColor:Dn?.strokeColor,base:On}),kn(On)},Nn=Dn=>{if(Dn.polygon&&Array.isArray(Dn.polygon)&&Dn.polygon.length>0)return Dn.polygon;const On=Math.min(Dn.startX||0,Dn.endX||0),Pn=Math.max(Dn.startX||0,Dn.endX||0),Zn=Dn.trackY||0,sr=25;return[[On,Zn-sr],[Pn,Zn-sr],[Pn,Zn+sr],[On,Zn+sr]]};En.push(new PolygonLayer({id:"regions-glow-outer",data:_o,getPolygon:Nn,stroked:!0,filled:!1,getLineWidth:30,getLineColor:Dn=>{const[On,Pn,Zn]=Vn(Dn);return[On,Pn,Zn,70]},lineWidthUnits:"pixels",lineWidthMinPixels:6,pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new PolygonLayer({id:"regions-glow-mid",data:_o,getPolygon:Nn,stroked:!0,filled:!1,getLineWidth:15,getLineColor:Dn=>{const[On,Pn,Zn]=Vn(Dn);return[On,Pn,Zn,130]},lineWidthUnits:"pixels",lineWidthMinPixels:3,pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new PolygonLayer({id:"regions-glow-core",data:_o,getPolygon:Nn,stroked:!0,filled:!1,getLineColor:[255,255,255,255],getLineWidth:3,lineWidthUnits:"pixels",lineWidthMinPixels:2,pickable:!1,parameters:{depthTest:!1,depthMask:!1,polygonOffset:[-2,-2]}}))}if(Do&&Do.length>0){const Vn=Dn=>{const On=Dn?.fillColor||Dn?.strokeColor||[120,200,255,255];return kn(On)},Nn=Dn=>{if(Dn.polygon&&Array.isArray(Dn.polygon)&&Dn.polygon.length>0)return Dn.polygon;const On=Math.min(Dn.start||0,Dn.end||0),Pn=Math.max(Dn.start||0,Dn.end||0),Zn=Dn.trackY||0,sr=15;return[[On,Zn-sr],[Pn,Zn-sr],[Pn,Zn+sr],[On,Zn+sr]]};En.push(new PolygonLayer({id:"ncrna-glow-outer",data:Do,getPolygon:Nn,stroked:!0,filled:!1,getLineWidth:25,getLineColor:Dn=>{const[On,Pn,Zn]=Vn(Dn);return[On,Pn,Zn,70]},lineWidthUnits:"pixels",lineWidthMinPixels:6,pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new PolygonLayer({id:"ncrna-glow-mid",data:Do,getPolygon:Nn,stroked:!0,filled:!1,getLineWidth:12,getLineColor:Dn=>{const[On,Pn,Zn]=Vn(Dn);return[On,Pn,Zn,150]},lineWidthUnits:"pixels",lineWidthMinPixels:3,pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new PolygonLayer({id:"ncrna-glow-core",data:Do,getPolygon:Nn,stroked:!0,filled:!1,getLineColor:[255,255,255,255],getLineWidth:3,lineWidthUnits:"pixels",lineWidthMinPixels:2,pickable:!1,parameters:{depthTest:!1,depthMask:!1,polygonOffset:[-2,-2]}}))}return Wi&&Wi.length>0&&(En.push(new ScatterplotLayer({id:"tree-glow-outer",data:Wi,getPosition:Vn=>Vn.position||[0,0],getRadius:Vn=>(Vn.radius||2)*3.5,getFillColor:Vn=>{const Nn=Vn?.color||An.treeEdges||[255,200,100,255],[Dn,On,Pn]=kn(Nn);return[Dn,On,Pn,90]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"meters",radiusMinPixels:12,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new ScatterplotLayer({id:"tree-glow-core",data:Wi,getPosition:Vn=>Vn.position||[0,0],getRadius:Vn=>(Vn.radius||2)*1.8,getFillColor:[255,255,255,255],stroked:!1,filled:!0,pickable:!1,radiusUnits:"meters",radiusMinPixels:6,parameters:{depthTest:!1,depthMask:!1}}))),ys&&ys.length>0&&(En.push(new ScatterplotLayer({id:"tree-node-glow-outer",data:ys,getPosition:Vn=>Vn.position||[0,0],getRadius:Vn=>(Vn.radius||2)*4,getFillColor:Vn=>{const Nn=Vn?.color||An.treeEdges||[100,180,255,255],[Dn,On,Pn]=kn(Nn);return[Dn,On,Pn,80]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"meters",radiusMinPixels:14,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new ScatterplotLayer({id:"tree-node-glow-mid",data:ys,getPosition:Vn=>Vn.position||[0,0],getRadius:Vn=>(Vn.radius||2)*2.5,getFillColor:Vn=>{const Nn=Vn?.color||An.treeEdges||[100,180,255,255],[Dn,On,Pn]=kn(Nn);return[Dn,On,Pn,130]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"meters",radiusMinPixels:10,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new ScatterplotLayer({id:"tree-node-glow-core",data:ys,getPosition:Vn=>Vn.position||[0,0],getRadius:Vn=>(Vn.radius||2)*1.5,getFillColor:[255,255,255,255],stroked:!1,filled:!0,pickable:!1,radiusUnits:"meters",radiusMinPixels:5,parameters:{depthTest:!1,depthMask:!1}}))),io&&io.length>0&&(En.push(new LineLayer({id:"hoods-glow-outer",data:io,getSourcePosition:Vn=>[Vn.start,Vn.trackY],getTargetPosition:Vn=>[Vn.end,Vn.trackY],getColor:[255,215,80,100],getWidth:28,widthUnits:"pixels",pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),En.push(new LineLayer({id:"hoods-glow-core",data:io,getSourcePosition:Vn=>[Vn.start,Vn.trackY],getTargetPosition:Vn=>[Vn.end,Vn.trackY],getColor:[255,255,255,255],getWidth:3,widthUnits:"pixels",pickable:!1,parameters:{depthTest:!1,depthMask:!1}}))),En},[Mi,Wi,ys,io,_o,Do,An.geneFill,An.treeEdges,qt.gene?.fillColor,qt.stroke?.hoodWidth,qt.stroke?.lineWidth,kr.gene?.height,kr.gene?.geneHeight,kr.gene?.arrowheadHeight,kr.genome?.xScalePercent,kr.gene?.tipWidthFactor,kr.tree?.ySpacing,Kn,mi]);const va=React.useCallback(En=>{const kn=[],Vn=Math.sin(En*.2),Nn=1+Vn*.15,Dn=hr==="light",On=Pr=>{const Ur=Rr=>Math.max(0,Math.min(255,Math.round(Rr)));if(Array.isArray(Pr)){const[Rr=0,Wr=0,$r=0,qr=255]=Pr;return[Ur(Rr),Ur(Wr),Ur($r),Ur(qr??255)]}return[150,150,150,255]},Pn=(Pr,Ur,Rr)=>(.299*Pr+.587*Ur+.114*Rr)/255,Zn=(Pr,Ur,Rr,Wr)=>{const $r=Pn(Pr,Ur,Rr);if(Dn){if($r>.7){const qr=.4+(1-$r)*.3;return{color:[Math.round(Pr*qr),Math.round(Ur*qr),Math.round(Rr*qr)],opacity:Math.min(255,Math.round(Wr*1.5))}}else if($r>.4)return{color:[Math.round(Pr*.7),Math.round(Ur*.7),Math.round(Rr*.7)],opacity:Math.round(Wr*1.2)}}return{color:[Pr,Ur,Rr],opacity:Wr}},sr=kr.gene?.height||nn||DEFAULT_CONFIG$1.gene.height,fr=kr.gene?.arrowheadHeight??Zt??DEFAULT_CONFIG$1.gene.arrowheadHeight,mr=Pr=>{const Ur=Pr.trackY;if(Ur==null)return Pr.polygon||[];let Rr=Pr.start,Wr=Pr.end;if(Rr>Wr){const Di=Rr;Rr=Wr,Wr=Di}const $r=Math.abs(Wr-Rr),qr=calculateTipWidth($r,kr),Vr=sr/2,ri=Pr.strand==="+";if(qr<1)return[[Rr,Ur-Vr],[Wr,Ur-Vr],[Wr,Ur+Vr],[Rr,Ur+Vr]];if(fr<.1)return ri?[[Rr,Ur-Vr],[Wr-qr,Ur-Vr],[Wr,Ur],[Wr-qr,Ur+Vr],[Rr,Ur+Vr]]:[[Wr,Ur-Vr],[Rr+qr,Ur-Vr],[Rr,Ur],[Rr+qr,Ur+Vr],[Wr,Ur+Vr]];const Ei=Vr+fr/2;return ri?[[Rr,Ur-Vr],[Wr-qr,Ur-Vr],[Wr-qr,Ur-Ei],[Wr,Ur],[Wr-qr,Ur+Ei],[Wr-qr,Ur+Vr],[Rr,Ur+Vr]]:[[Wr,Ur-Vr],[Rr+qr,Ur-Vr],[Rr+qr,Ur-Ei],[Rr,Ur],[Rr+qr,Ur+Ei],[Rr+qr,Ur+Vr],[Wr,Ur+Vr]]};if(Mi&&Mi.length>0){const Pr=$r=>{const qr=$r?.fillColor||An.geneFill||qt.gene?.fillColor||[100,200,255,255];return On(qr)},Ur=sr*(.3+Vn*.2),Rr=Math.round(150+Vn*50);kn.push(new PolygonLayer({id:`genes-glow-outer-anim-${En}`,data:Mi,getPolygon:mr,stroked:!0,filled:!1,getLineWidth:Ur,getLineColor:$r=>{const[qr,Vr,ri]=Pr($r),Ei=Zn(qr,Vr,ri,Rr);return[...Ei.color,Ei.opacity]},lineWidthUnits:"common",pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}}));const Wr=Dn?[80,80,80,200]:[255,255,255,255];kn.push(new PolygonLayer({id:"genes-glow-core-anim",data:Mi,getPolygon:mr,stroked:!0,filled:!1,getLineColor:Wr,getLineWidth:sr*.03,lineWidthUnits:"common",pickable:!1,parameters:{depthTest:!1,depthMask:!1,polygonOffset:[-1,-1]}}))}if(Wi&&Wi.length>0){const Pr=qr=>{const Vr=qr?.color;return Vr&&Array.isArray(Vr)&&Vr.some(ri=>ri>0)?On(Vr):[220,180,60,255]},Ur=4*(1.5+Vn*.5)*Nn,Rr=4*(.8+Vn*.3)*Nn,Wr=Math.round(60+Vn*30),$r=Math.round(120+Vn*50);kn.push(new ScatterplotLayer({id:`tree-glow-outer-anim-${En}`,data:Wi,getPosition:qr=>qr.position||[0,0],getRadius:qr=>(qr.radius||2)*Ur,getFillColor:qr=>{const[Vr,ri,Ei]=Pr(qr),Di=Zn(Vr,ri,Ei,Wr);return[...Di.color,Di.opacity]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"common",parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),kn.push(new ScatterplotLayer({id:`tree-glow-mid-anim-${En}`,data:Wi,getPosition:qr=>qr.position||[0,0],getRadius:qr=>(qr.radius||2)*Rr,getFillColor:qr=>{const[Vr,ri,Ei]=Pr(qr),Di=Zn(Vr,ri,Ei,$r);return[...Di.color,Di.opacity]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"common",parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),kn.push(new ScatterplotLayer({id:"tree-glow-core-anim",data:Wi,getPosition:qr=>qr.position||[0,0],getRadius:qr=>(qr.radius||2)*1.5,getFillColor:qr=>{const[Vr,ri,Ei]=Pr(qr),Di=Zn(Vr,ri,Ei,255);return[...Di.color,Di.opacity]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"common",parameters:{depthTest:!1,depthMask:!1}}))}if(ys&&ys.length>0){const Pr=qr=>{const Vr=qr?.color;return Vr&&Array.isArray(Vr)&&Vr.some(ri=>ri>0)?On(Vr):[100,180,255,255]},Ur=4*(1.6+Vn*.6)*Nn,Rr=4*(.9+Vn*.35)*Nn,Wr=Math.round(50+Vn*30),$r=Math.round(110+Vn*50);kn.push(new ScatterplotLayer({id:`tree-node-glow-outer-anim-${En}`,data:ys,getPosition:qr=>qr.position||[0,0],getRadius:qr=>(qr.radius||4)*Ur,getFillColor:qr=>{const[Vr,ri,Ei]=Pr(qr),Di=Zn(Vr,ri,Ei,Wr);return[...Di.color,Di.opacity]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"common",parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),kn.push(new ScatterplotLayer({id:`tree-node-glow-mid-anim-${En}`,data:ys,getPosition:qr=>qr.position||[0,0],getRadius:qr=>(qr.radius||4)*Rr,getFillColor:qr=>{const[Vr,ri,Ei]=Pr(qr),Di=Zn(Vr,ri,Ei,$r);return[...Di.color,Di.opacity]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"common",parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),kn.push(new ScatterplotLayer({id:"tree-node-glow-core-anim",data:ys,getPosition:qr=>qr.position||[0,0],getRadius:qr=>(qr.radius||4)*1.5,getFillColor:qr=>{const[Vr,ri,Ei]=Pr(qr),Di=Zn(Vr,ri,Ei,255);return[...Di.color,Di.opacity]},stroked:!1,filled:!0,pickable:!1,radiusUnits:"common",parameters:{depthTest:!1,depthMask:!1}}))}if(io&&io.length>0){const Pr=10+Vn*8,Ur=Math.round(150+Vn*50),Rr=Dn?[180,140,40]:[255,215,80],Wr=Dn?Math.min(255,Math.round(Ur*1.3)):Ur;kn.push(new LineLayer({id:`hoods-glow-outer-anim-${En}`,data:io,getSourcePosition:qr=>[qr.start,qr.trackY],getTargetPosition:qr=>[qr.end,qr.trackY],getColor:[...Rr,Wr],getWidth:Pr*Nn,widthUnits:"common",pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}}));const $r=Dn?[80,80,80,200]:[255,255,255,255];kn.push(new LineLayer({id:"hoods-glow-core-anim",data:io,getSourcePosition:qr=>[qr.start,qr.trackY],getTargetPosition:qr=>[qr.end,qr.trackY],getColor:$r,getWidth:1,widthUnits:"common",pickable:!1,parameters:{depthTest:!1,depthMask:!1}}))}if(_o&&_o.length>0){const Pr=$r=>{if($r.polygon&&Array.isArray($r.polygon)&&$r.polygon.length>0)return $r.polygon;const qr=Math.min($r.startX||0,$r.endX||0),Vr=Math.max($r.startX||0,$r.endX||0),ri=$r.trackY||0,Ei=$r.geneHeight||sr,Di=$r.arrowheadHeight||fr,Hi=$r.padding||10,Qi=Math.max(Ei,Di)/2+Hi;return[[qr,ri-Qi],[Vr,ri-Qi],[Vr,ri+Qi],[qr,ri+Qi]]},Ur=$r=>{const qr=$r?.strokeColor||$r?.fillColor||[255,180,50,255];return On(qr)},Rr=sr*(.4+Vn*.2),Wr=Math.round(120+Vn*60);kn.push(new PolygonLayer({id:`regions-glow-outer-anim-${En}`,data:_o,getPolygon:Pr,stroked:!0,filled:!1,getLineWidth:Rr,getLineColor:$r=>{const[qr,Vr,ri]=Ur($r),Ei=Zn(qr,Vr,ri,Wr);return[...Ei.color,Ei.opacity]},lineWidthUnits:"common",pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),kn.push(new PolygonLayer({id:"regions-glow-core-anim",data:_o,getPolygon:Pr,stroked:!0,filled:!1,getLineColor:$r=>{const[qr,Vr,ri]=Ur($r);return Dn?[Math.round(qr*.5),Math.round(Vr*.5),Math.round(ri*.5),220]:[255,255,255,255]},getLineWidth:sr*.04,lineWidthUnits:"common",pickable:!1,parameters:{depthTest:!1,depthMask:!1,polygonOffset:[-1,-1]}}))}if(Do&&Do.length>0){const Pr=$r=>{if($r.polygon&&Array.isArray($r.polygon)&&$r.polygon.length>0)return $r.polygon;const qr=Math.min($r.start||0,$r.end||0),Vr=Math.max($r.start||0,$r.end||0),ri=$r.trackY||0,Ei=15;return[[qr,ri-Ei],[Vr,ri-Ei],[Vr,ri+Ei],[qr,ri+Ei]]},Ur=$r=>{const qr=$r?.fillColor||$r?.strokeColor||[120,200,255,255];return On(qr)},Rr=sr*(.35+Vn*.15),Wr=Math.round(100+Vn*50);kn.push(new PolygonLayer({id:`ncrna-glow-outer-anim-${En}`,data:Do,getPolygon:Pr,stroked:!0,filled:!1,getLineWidth:Rr,getLineColor:$r=>{const[qr,Vr,ri]=Ur($r),Ei=Zn(qr,Vr,ri,Wr);return[...Ei.color,Ei.opacity]},lineWidthUnits:"common",pickable:!1,parameters:{blendFunc:[770,1],depthTest:!1,depthMask:!1}})),kn.push(new PolygonLayer({id:"ncrna-glow-core-anim",data:Do,getPolygon:Pr,stroked:!0,filled:!1,getLineColor:$r=>{const[qr,Vr,ri]=Ur($r);return Dn?[Math.round(qr*.5),Math.round(Vr*.5),Math.round(ri*.5),220]:[255,255,255,255]},getLineWidth:sr*.04,lineWidthUnits:"common",pickable:!1,parameters:{depthTest:!1,depthMask:!1,polygonOffset:[-1,-1]}}))}return kn},[Mi,Wi,ys,io,_o,Do,An,qt.gene?.fillColor,hr,kr.gene?.height,kr.gene?.geneHeight,kr.gene?.arrowheadHeight,kr.gene?.tipWidthFactor,kr.genome?.xScalePercent,kr.tree?.ySpacing,Kn,mi,Gt,Li?.name,Li?.enabled,Li?.numColors,Li?.reverse]),dc=Mi?.length>0||Wi?.length>0||ys?.length>0||io?.length>0||_o?.length>0||Do?.length>0;reactExports.useEffect(()=>{la.current=Ys},[Ys]),reactExports.useEffect(()=>(cs.current&&(cancelAnimationFrame(cs.current),cs.current=null),dc?((()=>{let kn=0;const Vn=33,Nn=Dn=>{if(Dn-kn<Vn){cs.current=requestAnimationFrame(Nn);return}kn=Dn,wa.current+=1;const On=va(wa.current),Pn=ma.current?.deck;if(Pn){const Zn=[...la.current,...On];Pn.setProps({layers:Zn})}cs.current=requestAnimationFrame(Nn)};cs.current=requestAnimationFrame(Nn)})(),()=>{cs.current&&(cancelAnimationFrame(cs.current),cs.current=null)}):void 0),[dc,va]);const fc=React.useMemo(()=>Ys,[Ys]),il=React.useRef(!0),Bl=React.useRef(Pt),sl=React.useRef(Lt),Nl=React.useRef(kt),Ml=React.useRef(0),Hl=100;reactExports.useEffect(()=>{if(typeof window.__hoodini_alignCluster=="function"){Bl.current=Pt,sl.current=Lt,Nl.current=kt,il.current&&(il.current=!1);return}const kn=bs.current;if(!kn||Ea.current||performance.now()-Ml.current<Hl)return;const Nn=Pt!==Bl.current,Dn=Lt!==sl.current,On=kt!==Nl.current;window._visualConfigUpdateTime&&(performance.now()-window._visualConfigUpdateTime,window._visualConfigUpdateTime=null);let Pn=!1;if((Nn||Dn||On||il.current)&&!(il.current&&!Nn&&!Dn&&!On)){const sr=performance.now();if(Pt!=null&&Pt!=="")kn.alignCluster(Pt),Pn=!0;else{const fr=Object.values(kn.hoodRanges||{}).some(mr=>mr.align_gene);kt&&fr?(kn.alignByDefaultGenes(),Pn=!0):Lt==="center"?(kn.alignAllToCenter(),Pn=!0):Lt==="end"?(kn.alignAllToEnd(),Pn=!0):(kn.alignAllToStart(),Pn=!0)}Ml.current=sr}Pn?wi(Zn=>Zn+1):il.current,il.current&&(il.current=!1),Bl.current=Pt,sl.current=Lt,Nl.current=kt},[Pt,Lt,kt]),reactExports.useEffect(()=>{!bs.current||Ni.width===0&&Ni.height},[Ni,tn]),React.useRef(!1),React.useRef(null);const ko=Math.max(0,Ni.height-(Ot?Xi:0)),Zs=React.useRef(Es);return React.useEffect(()=>{Zs.current=Es},[Es]),reactExports.useImperativeHandle(_n,()=>({exportToSVG:()=>{let En=Zs.current||Es;if(!Ys||!En){console.warn("🖼️ HoodiniViz.exportToSVG - missing layers or viewState, aborting");return}let kn=null;if(rr&&or&&vr){const mr=or.unit==="mm"?300:96,Pr=1/25.4;let Ur,Rr;or.unit==="mm"?(Ur=or.width*Pr*mr,Rr=or.height*Pr*mr):(Ur=or.width,Rr=or.height);const Wr=40,$r=Ni.width-2*Wr,qr=ko-2*Wr,Vr=$r/Ur,ri=qr/Rr,Ei=Math.min(Vr,ri),Di=Ur*Ei,Hi=Rr*Ei,Pi=(Ni.width-Di)/2,Qi=(ko-Hi)/2,Si=Pi+Di,Ci=Qi+Hi,Ai=Math.pow(2,En.zoom||0),Xs=En.target[0],Ks=En.target[1],fa=Qs=>Xs+(Qs-Ni.width/2)/Ai,ia=Qs=>Ks+(ko/2-Qs)/Ai;kn={minX:fa(Pi),maxX:fa(Si),minY:ia(Ci),maxY:ia(Qi)}}const Vn=Ot?{minX:Ii.minX,maxX:Ii.maxX,width:Ni.width,height:ko,config:{...qt,tree:{...qt.tree,xScalePercent:ws}},viewState:En,alignmentReferencePoint:go(bs.current),bounds:Ii,genomeView:bs.current,precomputedTicks:$o.current?$o.current.getTicks():void 0,showTreeLayer:Wn&&po,showTreeTextLayer:xr&&po}:void 0,Nn=Ys.filter(mr=>{if(!mr||!mr.id)return!0;const Pr=mr.id;return Pr==="phylo-tree"||Pr==="nodes"||Pr==="tree-nodes"?Wn:Pr==="phylo-labels"?xr:Pr==="genes"?br:Pr==="gene-labels"?wr:Pr==="domains"||Pr.startsWith("domains-")?Fr:Pr==="protein-polygons"?Cr:Pr==="nucleotide-polygons"?dr:Pr==="ncrna-features"?_r:Pr==="region-polygons"?pr:!0}),Dn=exportToSVG(Nn,En,{width:Ni.width,height:ko},qt,Ot?Vn:void 0,An,5,1,rr&&or?{scaleToFormat:!0,formatPreset:or,guideBounds:vr?kn:null,scaleRulerWithCrop:cr}:void 0);if(!Dn)return;let On=Dn,Pn="hoodini-viz-export.svg";if(rr&&or){const mr=new Date().toISOString().slice(0,19).replace(/[:-]/g,"");Pn=`hoodini_${or.name.toLowerCase().replace(/\s+/g,"_")}_${mr}.svg`}const Zn=new Blob([On],{type:"image/svg+xml"}),sr=URL.createObjectURL(Zn),fr=document.createElement("a");fr.href=sr,fr.download=Pn,document.body.appendChild(fr),fr.click(),document.body.removeChild(fr),URL.revokeObjectURL(sr)},genomeView:bs.current,forceAlignUpdate:()=>{try{return wi(En=>En+1),!0}catch{return!1}},alignCluster:En=>{try{const kn=bs.current;return!kn||typeof kn.alignCluster!="function"?!1:(kn.alignCluster(En),wi(Vn=>Vn+1),!0)}catch{return!1}},alignByDefaultGenes:()=>{try{const En=bs.current;return!En||typeof En.alignByDefaultGenes!="function"?!1:(En.alignByDefaultGenes(),wi(kn=>kn+1),!0)}catch{return!1}},focusFeatureByPosition:(En,kn,Vn,Nn="region",Dn=null)=>{try{if(Io(),xo(),ca(),!En||kn==null||Vn==null)return!1;const On=bs.current;if(!On)return!1;const Pn=String(En),sr=Nn==="ncRNA"||Nn==="ncRNA_gene"?On.getAllNcRNAs?.()||[]:On.getAllRegions?.()||[];console.log(`[focusFeatureByPosition] Searching for ${Nn}:`,{seqid:Pn,start:kn,end:Vn,featureCount:sr.length});let fr=null,mr=null;if(Dn&&(fr=sr.find(ri=>ri.id===Dn),fr&&(mr=fr.hood_id)),!fr){let ri=[];On.hoodRanges?.[Pn]&&ri.push(Pn),On.seqidToHoodsMap?.[Pn]&&ri.push(...On.seqidToHoodsMap[Pn]);for(const Ei of ri){const Di=On.hoodRanges?.[Ei];if(Di&&kn>=Di.origStart&&Vn<=Di.origEnd){const Hi=kn-Di.origStart,Pi=Vn-Di.origStart;if(fr=sr.find(Qi=>Qi.hood_id===Ei&&(Qi.origStart===Hi||Qi.start===Hi||Qi.metadata?.start===Hi)&&(Qi.origEnd===Pi||Qi.end===Pi||Qi.metadata?.end===Pi)),fr){mr=Ei;break}}}}if(!fr){for(const ri of sr)if(ri.metadata?.seqid===Pn||ri.hood_id===Pn||ri.seqid===Pn){const Ei=On.hoodRanges?.[ri.hood_id];if(Ei){const Di=kn-(Ei.origStart||0),Hi=Vn-(Ei.origStart||0);if(ri.metadata?.start===Di&&ri.metadata?.end===Hi||ri.origStart===Di&&ri.origEnd===Hi){fr=ri,mr=ri.hood_id;break}}}}if(!fr||!mr)return console.warn(`[focusFeatureByPosition] ${Nn} not found. seqid:`,Pn,"start:",kn,"end:",Vn),!1;if(console.log(`[focusFeatureByPosition] Found ${Nn}:`,{id:fr.id,hood_id:mr,start:fr.start,end:fr.end}),!On.hoodRanges?.[mr])return console.warn("[focusFeatureByPosition] No hoodRange found for hood:",mr),!1;const Ur=On.getTrackYByHoodId?.(mr);if(Ur==null)return console.warn("[focusFeatureByPosition] No trackY found for hood:",mr),!1;const Rr=(fr.start+fr.end)/2,Wr=fr.trackY??Ur;console.log(`[focusFeatureByPosition] ${Nn} colors:`,{fillColor:fr.fillColor,strokeColor:fr.strokeColor,color:fr.color});let $r=[255,180,50,255];if(fr.fillColor&&Array.isArray(fr.fillColor)&&fr.fillColor[3]!==0)$r=fr.fillColor;else if(fr.color&&Array.isArray(fr.color)&&fr.color[3]!==0)$r=fr.color;else if(fr.strokeColor&&Array.isArray(fr.strokeColor)&&fr.strokeColor[3]!==0)$r=fr.strokeColor;else if(typeof fr.getStrokeColor=="function"){const ri=fr.getStrokeColor();ri&&Array.isArray(ri)&&ri[3]!==0&&($r=ri)}const qr={id:fr.id,polygon:fr.polygon,startX:fr.start,endX:fr.end,trackY:fr.trackY,strokeColor:$r,fillColor:$r,featureType:Nn,hoodId:mr};Uo(qr);const Vr=Zs.current&&Zs.current.zoom!==void 0?Zs.current.zoom:Es.zoom||-3;return Ds(ri=>({...ri,target:[Rr,Wr,0],zoom:Vr})),Zs.current={...Zs.current||{},target:[Rr,Wr,0],zoom:Vr},!0}catch(On){return console.error("[focusFeatureByPosition] Error:",On),!1}},focusGeneById:En=>{try{if(!En)return!1;const kn=bs.current;if(!kn)return!1;const Vn=String(En);let Nn=null;if(kn._genesByOriginalId&&typeof kn._genesByOriginalId.get=="function"){const sr=kn._genesByOriginalId.get(Vn);sr&&sr.length&&(Nn=sr[0])}if(!Nn)for(const[sr,fr]of Object.entries(kn.genesById||{})){const mr=fr.originalGeneId||fr.gene_id||fr.originalId||fr.id||fr.metadata&&(fr.metadata.gene_id||fr.metadata.id);if(mr&&String(mr)===Vn){Nn=sr;break}}if(!Nn)return!1;const Dn=kn.genesById[Nn];if(!Dn)return!1;const On=(Dn.start+Dn.end)/2,Pn=Dn.trackY||0,Zn=Zs.current&&Zs.current.zoom!==void 0?Zs.current.zoom:Es.zoom||-3;return Ds(sr=>({...sr,target:[On,Pn,0],zoom:Zn})),Zs.current={...Zs.current||{},target:[On,Pn,0],zoom:Zn},za(Nn,Dn),!0}catch{return!1}},focusBaselineByHood:En=>{try{if(Io(),xo(),ca(),!En)return!1;const kn=bs.current;if(!kn||!kn.hoodRanges)return!1;const Vn=String(En),Nn=kn.hoodRanges[Vn];if(!Nn)return!1;const Dn=kn.trackOffset&&kn.trackOffset[Vn]||0,On=kn.trackFlipped?!!kn.trackFlipped[Vn]:!1,Pn=Nn.length/2,Zn=0,sr=Nn.length,fr=kn.constructor.getTransformedXUnified(Zn,Pn,Dn,On),mr=kn.constructor.getTransformedXUnified(sr,Pn,Dn,On),Pr=kr.genome&&typeof kr.genome.xScalePercent=="number"?kr.genome.xScalePercent/100:1,Ur=Pn+(fr-Pn)*Pr,Rr=Pn+(mr-Pn)*Pr,Wr=(Ur+Rr)/2,$r=typeof kn.getTrackYByHoodId=="function"&&kn.getTrackYByHoodId(Vn)||0,qr=Zs.current&&Zs.current.zoom!==void 0?Zs.current.zoom:Es.zoom||-3;Ds(Ei=>({...Ei,target:[Wr,$r,0],zoom:qr})),Zs.current={...Zs.current||{},target:[Wr,$r,0],zoom:qr},ta.current=!0;const Vr=kn.hoodToSeqidMap?kn.hoodToSeqidMap[Vn]:null;return Fo([{hood_id:Vn,seqid:Vr,start:Ur,end:Rr,trackY:$r}]),setTimeout(()=>{ta.current=!1},100),!0}catch{return!1}},focusTreeLeafById:En=>{try{if(!En)return!1;const kn=us;if(!kn||!Array.isArray(kn.leafNodes))return!1;const Vn=String(En),Nn=kn.leafNodes.find(Wr=>[Wr?.leaf_id,Wr?.metadata?.leaf_id,Wr?.metadata?.leaf_name,Wr?.name,Wr?.metadata?.name].filter($r=>$r!=null).some($r=>String($r)===Vn));if(!Nn)return!1;const Dn=Number.isFinite(Number(Nn.rawY))?Number(Nn.rawY):Number(Nn.y),On=Number.isFinite(Number(Nn.x))?Number(Nn.x):Number(Nn.rawX);if(!Number.isFinite(Dn)||!Number.isFinite(On))return!1;const Pn=qt.tree&&typeof qt.tree.xScalePercent=="number"?qt.tree.xScalePercent/100:1,Zn=Ii.treeOffset||0,sr=[Dn*Pn+Zn,On,0],fr=Zs.current&&Zs.current.zoom!==void 0?Zs.current.zoom:Es.zoom||-3;Ds(Wr=>({...Wr,target:sr,zoom:fr})),Zs.current={...Zs.current||{},target:sr,zoom:fr};const mr=String(Nn.leaf_id||Nn.metadata?.leaf_id||Nn.name||Vn);aa(null),setTimeout(()=>aa(mr),0);const Pr=qt?.tree?.nodeRadius||{internal:4,leaf:2};let Ur=An.treeEdges||[220,180,60,255];if(Ts.current?.nodes){const Wr=Ts.current.nodes.find($r=>$r.leaf_id===mr||$r.name===mr||$r.id===mr||$r.metadata?.leaf_id===mr);Wr?.color&&Array.isArray(Wr.color)&&Wr.color.some($r=>$r>0)&&(Ur=Wr.color)}const Rr=[{id:mr,position:[Dn*Pn+Zn,On],radius:Pr.leaf||2,color:Ur}];return Mo(Rr),!0}catch{return!1}},getLegendData:()=>{try{return Jl()}catch{return null}},geneColorMap:ss}),[Ys,Es,qt,Ot,Ii,An,ws,ko,za,Io,rr,or,vr,cr]),jsxRuntimeExports.jsxs("div",{id:"phylo-tree-viewer-container",ref:ji,style:{width:"100%",height:"100%",position:"relative",overflow:"hidden",background:An?.background||"var(--background, #ffffff)",color:An?.text||"var(--foreground, #222)"},children:[jsxRuntimeExports.jsx(DeckGL,{ref:ma,views:[new OrthographicView({flipY:!1})],controller:{dragPan:!0,dragRotate:!1,scrollZoom:{smooth:!1,speed:.01},doubleClickZoom:!1,keyboard:!1,inertia:!0,transitionDuration:0,touchZoom:!0,touchRotate:!1},onViewStateChange:En=>{try{const kn=En.viewState;if(In){Zs.current=kn;return}const Vn=qt?.scrollbar?.panPaddingY??50,Nn=qt?.scrollbar?.panPaddingX??500,Dn=Math.pow(2,kn.zoom||0),On=Math.max(1,Dn*.5),Pn=tn!=="none"?hs||200:0,Zn=Vn*On,sr=(Nn+Pn)*On,fr=ua-Ba||1e3,mr=jo-Oo||1e4,Pr=Ni.height||600,Ur=Ni.width||800,Rr=Math.log2(Pr/(fr*1.5)),Wr=Math.log2(Ur/(mr*1.5)),$r=Math.min(Rr,Wr,qt?.scrollbar?.minZoom??-5),qr=qt?.scrollbar?.maxZoom??2;isFinite(kn.zoom)&&(kn.zoom=Math.max($r,Math.min(qr,kn.zoom)));const Vr=Ba-Zn,ri=ua+Zn;if(isFinite(Vr)&&isFinite(ri)&&ri>Vr){const Hi=kn.target[1],Pi=Math.max(Vr,Math.min(ri,Hi));Pi!==Hi&&(kn.target=[kn.target[0],Pi,kn.target[2]||0])}const Ei=Oo-sr,Di=jo+sr;if(isFinite(Ei)&&isFinite(Di)&&Di>Ei){const Hi=kn.target[0],Pi=Math.max(Ei,Math.min(Di,Hi));Pi!==Hi&&(kn.target=[Pi,kn.target[1],kn.target[2]||0])}Zs.current=kn}catch{}},initialViewState:Es,layers:fc,pickingRadius:100,style:{width:"100%",height:Ot?`${ko}px`:`${ko}px`,position:"absolute",left:"0",top:"0",backgroundColor:"transparent"},getTooltip:Dl,useDevicePixels:!0,_animate:!1,onClick:({object:En,x:kn,y:Vn,srcEvent:Nn})=>{try{console.debug("[HoodiniViz] DeckGL onClick event",{objectType:En&&En.metadata&&En.metadata.type,object:En,x:kn,y:Vn});const Dn=Ii?.treeOffset||0,On=kr?.tree?.nodeRadius||{internal:4,leaf:2},Pn=En&&En.node&&Array.isArray(En.node.branchset)&&En.node.branchset.length===0;if(Pn){const Rr=En.node?.leaf_id||En.node?.metadata?.leaf_id||En.node?.metadata?.leaf_name||En.node?.name||En.node?.id;if(Rr){aa(null),setTimeout(()=>aa(String(Rr)),0);const Wr=Number.isFinite(Number(En.rawY))?Number(En.rawY):Number.isFinite(Number(En.node?.y))?Number(En.node.y):Number(En.node?.rawY),$r=Number.isFinite(Number(En.x))?Number(En.x):Number(En.node?.x),qr=kr.tree&&typeof kr.tree.xScalePercent=="number"?kr.tree.xScalePercent/100:1;Number.isFinite(Wr)&&Number.isFinite($r)&&Mo([{id:Rr,position:[Wr*qr+Dn,$r],radius:En.radius||On.leaf||2,color:En.color||En.node?.color||An.treeEdges||[220,180,60,255]}])}}const Zn=En&&(En.type==="gene"||En.gene),sr=En&&En.type==="hood",fr=En&&En.type==="region",mr=En&&(En.type==="ncRNA"||En.type==="ncRNA_gene"),Pr=Rr=>{try{if(!Rr||!jt||Object.keys(jt).length===0)return;const Wr=Ci=>{if(!Ci||typeof Ci!="object")return Ci;const Ai={...Ci};return Ai.sequence||(Ai.sequence=Ai.rna_sequence||Ai.sequence_nt||Ai.nucleotide_sequence||Ai.rna_seq||Ai.seq||null),Ai.structure||(Ai.structure=Ai.secondary_structure||Ai.dot_bracket||Ai.dbn||Ai.structure_dbn||null),Ai.type||(Ai.type=Ai.ncrna_type||Ai.rna_type||Ai.subtype||null),Ai},$r=bs.current,qr=Rr.hood_id||Rr.hoodId||($r&&$r.getHoodIdFromSeqid?$r.getHoodIdFromSeqid(Rr.seqid):null),Vr=qr&&$r&&$r.hoodRanges?$r.hoodRanges[qr]:null,ri=Vr&&Number.isFinite(Number(Vr.start))?Number(Vr.start):null,Ei=Number.isFinite(Number(Rr.origStart))?Number(Rr.origStart):Number(Rr.start),Di=Number.isFinite(Number(Rr.origEnd))?Number(Rr.origEnd):Number(Rr.end),Hi=Ci=>Ci&&jt[Ci]?(Rr.metadata={...Rr.metadata||{},...Wr(jt[Ci])},!0):!1;if(ri!==null&&Number.isFinite(Ei)&&Number.isFinite(Di)){const Ci=Ei+ri,Ai=Di+ri,Xs=`${Rr.seqid}:${Ci}:${Ai}`;if(Hi(Xs))return}const Pi=`${Rr.seqid}:${Ei}:${Di}`;if(Hi(Pi))return;const Qi=`${Rr.seqid}:${Di}:${Ei}`;if(Hi(Qi))return;const Si=Rr.id||Rr.originalId;if(Hi(Si))return}catch(Wr){console.debug("[HoodiniViz] ncRNA click-time metadata hydration failed",Wr)}};if(Zn){const Rr=En.id||En.uniqueId||En.gene&&(En.gene.uniqueId||En.gene.id||En.gene.gene_id||En.gene.originalGeneId);Rr&&za(Rr,En),Ga(),wo(),xo(),ca()}else fr?(Uo(En),Io(),Ga(),wo(),ca()):mr?(Vi(En),Pr(En),Io(),Ga(),wo(),xo()):(Io(),xo(),ca());if(sr||Ga(),Pn||wo(),En&&En.node&&En.node.branchset&&En.node.branchset.length>0){const Rr=En.node;if(ci&&ci.id===Rr.id)console.debug("[HoodiniViz] deselecting node",Rr.id),xi(null),Fl();else{console.debug("[HoodiniViz] selecting node",Rr.id),xi(Rr);const Wr=Number.isFinite(Number(En.rawY))?Number(En.rawY):Number.isFinite(Number(Rr.y))?Number(Rr.y):Number(Rr.rawY),$r=Number.isFinite(Number(En.x))?Number(En.x):Number(Rr.x),qr=kr.tree&&typeof kr.tree.xScalePercent=="number"?kr.tree.xScalePercent/100:1;Number.isFinite(Wr)&&Number.isFinite($r)&&Va([{id:Rr.id,position:[Wr*qr+Dn,$r],radius:En.radius||On&&On.internal||4,color:En.color||An.treeEdges||[100,180,255,255]}])}}}catch(Dn){console.warn("[HoodiniViz] onClick handler error",Dn)}if(En&&Mt){try{console.debug("[HoodiniViz] forwarding click to onObjectClick",En&&(En.type||En.metadata&&En.metadata.type||En.node&&"tree-node"))}catch{}Mt(En)}En||(Io(),Ga(),wo(),xo(),ca())}}),Ot&&jsxRuntimeExports.jsx("div",{style:{position:"absolute",left:"0",bottom:"0",width:"100%",height:`${Xi}px`,transform:"translateX(0)",zIndex:1},children:jsxRuntimeExports.jsx(RulerWidget,{ref:$o,minX:Ii.minX,maxX:Ii.maxX,viewState:Es,viewStateRef:Zs,containerWidth:Ni.width,containerHeight:ko,visible:Ot,genomeView:bs.current,hasNewick:po,alignmentReferencePoint:go(bs.current),bounds:Ii,config:kr})}),St&&jsxRuntimeExports.jsx(ScrollbarWidget,{minY:Ya,maxY:Yo,scrollNorm:wl,setScrollNorm:cl,visibleFraction:As,setViewState:Ds,containerHeight:ko,viewState:Es,viewStateRef:Zs,config:qt,themeColors:An}),jsxRuntimeExports.jsx(GuideOverlay,{visible:In,formatPreset:or,containerWidth:Ni.width,containerHeight:ko,viewState:Es,themeColors:{accent:An.accent,border:An.border}})]})});var _baseHas,hasRequired_baseHas;function require_baseHas(){if(hasRequired_baseHas)return _baseHas;hasRequired_baseHas=1;var yt=Object.prototype,Et=yt.hasOwnProperty;function xt(vt,bt){return vt!=null&&Et.call(vt,bt)}return _baseHas=xt,_baseHas}var isArray_1,hasRequiredIsArray;function requireIsArray(){if(hasRequiredIsArray)return isArray_1;hasRequiredIsArray=1;var yt=Array.isArray;return isArray_1=yt,isArray_1}var _freeGlobal,hasRequired_freeGlobal;function require_freeGlobal(){if(hasRequired_freeGlobal)return _freeGlobal;hasRequired_freeGlobal=1;var yt=typeof commonjsGlobal=="object"&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal;return _freeGlobal=yt,_freeGlobal}var _root,hasRequired_root;function require_root(){if(hasRequired_root)return _root;hasRequired_root=1;var yt=require_freeGlobal(),Et=typeof self=="object"&&self&&self.Object===Object&&self,xt=yt||Et||Function("return this")();return _root=xt,_root}var _Symbol,hasRequired_Symbol;function require_Symbol(){if(hasRequired_Symbol)return _Symbol;hasRequired_Symbol=1;var yt=require_root(),Et=yt.Symbol;return _Symbol=Et,_Symbol}var _getRawTag,hasRequired_getRawTag;function require_getRawTag(){if(hasRequired_getRawTag)return _getRawTag;hasRequired_getRawTag=1;var yt=require_Symbol(),Et=Object.prototype,xt=Et.hasOwnProperty,vt=Et.toString,bt=yt?yt.toStringTag:void 0;function At(Ft){var Ct=xt.call(Ft,bt),wt=Ft[bt];try{Ft[bt]=void 0;var St=!0}catch{}var Tt=vt.call(Ft);return St&&(Ct?Ft[bt]=wt:delete Ft[bt]),Tt}return _getRawTag=At,_getRawTag}var _objectToString,hasRequired_objectToString;function require_objectToString(){if(hasRequired_objectToString)return _objectToString;hasRequired_objectToString=1;var yt=Object.prototype,Et=yt.toString;function xt(vt){return Et.call(vt)}return _objectToString=xt,_objectToString}var _baseGetTag,hasRequired_baseGetTag;function require_baseGetTag(){if(hasRequired_baseGetTag)return _baseGetTag;hasRequired_baseGetTag=1;var yt=require_Symbol(),Et=require_getRawTag(),xt=require_objectToString(),vt="[object Null]",bt="[object Undefined]",At=yt?yt.toStringTag:void 0;function Ft(Ct){return Ct==null?Ct===void 0?bt:vt:At&&At in Object(Ct)?Et(Ct):xt(Ct)}return _baseGetTag=Ft,_baseGetTag}var isObjectLike_1,hasRequiredIsObjectLike;function requireIsObjectLike(){if(hasRequiredIsObjectLike)return isObjectLike_1;hasRequiredIsObjectLike=1;function yt(Et){return Et!=null&&typeof Et=="object"}return isObjectLike_1=yt,isObjectLike_1}var isSymbol_1,hasRequiredIsSymbol;function requireIsSymbol(){if(hasRequiredIsSymbol)return isSymbol_1;hasRequiredIsSymbol=1;var yt=require_baseGetTag(),Et=requireIsObjectLike(),xt="[object Symbol]";function vt(bt){return typeof bt=="symbol"||Et(bt)&&yt(bt)==xt}return isSymbol_1=vt,isSymbol_1}var _isKey,hasRequired_isKey;function require_isKey(){if(hasRequired_isKey)return _isKey;hasRequired_isKey=1;var yt=requireIsArray(),Et=requireIsSymbol(),xt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vt=/^\w*$/;function bt(At,Ft){if(yt(At))return!1;var Ct=typeof At;return Ct=="number"||Ct=="symbol"||Ct=="boolean"||At==null||Et(At)?!0:vt.test(At)||!xt.test(At)||Ft!=null&&At in Object(Ft)}return _isKey=bt,_isKey}var isObject_1,hasRequiredIsObject;function requireIsObject(){if(hasRequiredIsObject)return isObject_1;hasRequiredIsObject=1;function yt(Et){var xt=typeof Et;return Et!=null&&(xt=="object"||xt=="function")}return isObject_1=yt,isObject_1}var isFunction_1,hasRequiredIsFunction;function requireIsFunction(){if(hasRequiredIsFunction)return isFunction_1;hasRequiredIsFunction=1;var yt=require_baseGetTag(),Et=requireIsObject(),xt="[object AsyncFunction]",vt="[object Function]",bt="[object GeneratorFunction]",At="[object Proxy]";function Ft(Ct){if(!Et(Ct))return!1;var wt=yt(Ct);return wt==vt||wt==bt||wt==xt||wt==At}return isFunction_1=Ft,isFunction_1}var _coreJsData,hasRequired_coreJsData;function require_coreJsData(){if(hasRequired_coreJsData)return _coreJsData;hasRequired_coreJsData=1;var yt=require_root(),Et=yt["__core-js_shared__"];return _coreJsData=Et,_coreJsData}var _isMasked,hasRequired_isMasked;function require_isMasked(){if(hasRequired_isMasked)return _isMasked;hasRequired_isMasked=1;var yt=require_coreJsData(),Et=(function(){var vt=/[^.]+$/.exec(yt&&yt.keys&&yt.keys.IE_PROTO||"");return vt?"Symbol(src)_1."+vt:""})();function xt(vt){return!!Et&&Et in vt}return _isMasked=xt,_isMasked}var _toSource,hasRequired_toSource;function require_toSource(){if(hasRequired_toSource)return _toSource;hasRequired_toSource=1;var yt=Function.prototype,Et=yt.toString;function xt(vt){if(vt!=null){try{return Et.call(vt)}catch{}try{return vt+""}catch{}}return""}return _toSource=xt,_toSource}var _baseIsNative,hasRequired_baseIsNative;function require_baseIsNative(){if(hasRequired_baseIsNative)return _baseIsNative;hasRequired_baseIsNative=1;var yt=requireIsFunction(),Et=require_isMasked(),xt=requireIsObject(),vt=require_toSource(),bt=/[\\^$.*+?()[\]{}|]/g,At=/^\[object .+?Constructor\]$/,Ft=Function.prototype,Ct=Object.prototype,wt=Ft.toString,St=Ct.hasOwnProperty,Tt=RegExp("^"+wt.call(St).replace(bt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Rt(Pt){if(!xt(Pt)||Et(Pt))return!1;var Lt=yt(Pt)?Tt:At;return Lt.test(vt(Pt))}return _baseIsNative=Rt,_baseIsNative}var _getValue,hasRequired_getValue;function require_getValue(){if(hasRequired_getValue)return _getValue;hasRequired_getValue=1;function yt(Et,xt){return Et?.[xt]}return _getValue=yt,_getValue}var _getNative,hasRequired_getNative;function require_getNative(){if(hasRequired_getNative)return _getNative;hasRequired_getNative=1;var yt=require_baseIsNative(),Et=require_getValue();function xt(vt,bt){var At=Et(vt,bt);return yt(At)?At:void 0}return _getNative=xt,_getNative}var _nativeCreate,hasRequired_nativeCreate;function require_nativeCreate(){if(hasRequired_nativeCreate)return _nativeCreate;hasRequired_nativeCreate=1;var yt=require_getNative(),Et=yt(Object,"create");return _nativeCreate=Et,_nativeCreate}var _hashClear,hasRequired_hashClear;function require_hashClear(){if(hasRequired_hashClear)return _hashClear;hasRequired_hashClear=1;var yt=require_nativeCreate();function Et(){this.__data__=yt?yt(null):{},this.size=0}return _hashClear=Et,_hashClear}var _hashDelete,hasRequired_hashDelete;function require_hashDelete(){if(hasRequired_hashDelete)return _hashDelete;hasRequired_hashDelete=1;function yt(Et){var xt=this.has(Et)&&delete this.__data__[Et];return this.size-=xt?1:0,xt}return _hashDelete=yt,_hashDelete}var _hashGet,hasRequired_hashGet;function require_hashGet(){if(hasRequired_hashGet)return _hashGet;hasRequired_hashGet=1;var yt=require_nativeCreate(),Et="__lodash_hash_undefined__",xt=Object.prototype,vt=xt.hasOwnProperty;function bt(At){var Ft=this.__data__;if(yt){var Ct=Ft[At];return Ct===Et?void 0:Ct}return vt.call(Ft,At)?Ft[At]:void 0}return _hashGet=bt,_hashGet}var _hashHas,hasRequired_hashHas;function require_hashHas(){if(hasRequired_hashHas)return _hashHas;hasRequired_hashHas=1;var yt=require_nativeCreate(),Et=Object.prototype,xt=Et.hasOwnProperty;function vt(bt){var At=this.__data__;return yt?At[bt]!==void 0:xt.call(At,bt)}return _hashHas=vt,_hashHas}var _hashSet,hasRequired_hashSet;function require_hashSet(){if(hasRequired_hashSet)return _hashSet;hasRequired_hashSet=1;var yt=require_nativeCreate(),Et="__lodash_hash_undefined__";function xt(vt,bt){var At=this.__data__;return this.size+=this.has(vt)?0:1,At[vt]=yt&&bt===void 0?Et:bt,this}return _hashSet=xt,_hashSet}var _Hash,hasRequired_Hash;function require_Hash(){if(hasRequired_Hash)return _Hash;hasRequired_Hash=1;var yt=require_hashClear(),Et=require_hashDelete(),xt=require_hashGet(),vt=require_hashHas(),bt=require_hashSet();function At(Ft){var Ct=-1,wt=Ft==null?0:Ft.length;for(this.clear();++Ct<wt;){var St=Ft[Ct];this.set(St[0],St[1])}}return At.prototype.clear=yt,At.prototype.delete=Et,At.prototype.get=xt,At.prototype.has=vt,At.prototype.set=bt,_Hash=At,_Hash}var _listCacheClear,hasRequired_listCacheClear;function require_listCacheClear(){if(hasRequired_listCacheClear)return _listCacheClear;hasRequired_listCacheClear=1;function yt(){this.__data__=[],this.size=0}return _listCacheClear=yt,_listCacheClear}var eq_1,hasRequiredEq;function requireEq(){if(hasRequiredEq)return eq_1;hasRequiredEq=1;function yt(Et,xt){return Et===xt||Et!==Et&&xt!==xt}return eq_1=yt,eq_1}var _assocIndexOf,hasRequired_assocIndexOf;function require_assocIndexOf(){if(hasRequired_assocIndexOf)return _assocIndexOf;hasRequired_assocIndexOf=1;var yt=requireEq();function Et(xt,vt){for(var bt=xt.length;bt--;)if(yt(xt[bt][0],vt))return bt;return-1}return _assocIndexOf=Et,_assocIndexOf}var _listCacheDelete,hasRequired_listCacheDelete;function require_listCacheDelete(){if(hasRequired_listCacheDelete)return _listCacheDelete;hasRequired_listCacheDelete=1;var yt=require_assocIndexOf(),Et=Array.prototype,xt=Et.splice;function vt(bt){var At=this.__data__,Ft=yt(At,bt);if(Ft<0)return!1;var Ct=At.length-1;return Ft==Ct?At.pop():xt.call(At,Ft,1),--this.size,!0}return _listCacheDelete=vt,_listCacheDelete}var _listCacheGet,hasRequired_listCacheGet;function require_listCacheGet(){if(hasRequired_listCacheGet)return _listCacheGet;hasRequired_listCacheGet=1;var yt=require_assocIndexOf();function Et(xt){var vt=this.__data__,bt=yt(vt,xt);return bt<0?void 0:vt[bt][1]}return _listCacheGet=Et,_listCacheGet}var _listCacheHas,hasRequired_listCacheHas;function require_listCacheHas(){if(hasRequired_listCacheHas)return _listCacheHas;hasRequired_listCacheHas=1;var yt=require_assocIndexOf();function Et(xt){return yt(this.__data__,xt)>-1}return _listCacheHas=Et,_listCacheHas}var _listCacheSet,hasRequired_listCacheSet;function require_listCacheSet(){if(hasRequired_listCacheSet)return _listCacheSet;hasRequired_listCacheSet=1;var yt=require_assocIndexOf();function Et(xt,vt){var bt=this.__data__,At=yt(bt,xt);return At<0?(++this.size,bt.push([xt,vt])):bt[At][1]=vt,this}return _listCacheSet=Et,_listCacheSet}var _ListCache,hasRequired_ListCache;function require_ListCache(){if(hasRequired_ListCache)return _ListCache;hasRequired_ListCache=1;var yt=require_listCacheClear(),Et=require_listCacheDelete(),xt=require_listCacheGet(),vt=require_listCacheHas(),bt=require_listCacheSet();function At(Ft){var Ct=-1,wt=Ft==null?0:Ft.length;for(this.clear();++Ct<wt;){var St=Ft[Ct];this.set(St[0],St[1])}}return At.prototype.clear=yt,At.prototype.delete=Et,At.prototype.get=xt,At.prototype.has=vt,At.prototype.set=bt,_ListCache=At,_ListCache}var _Map,hasRequired_Map;function require_Map(){if(hasRequired_Map)return _Map;hasRequired_Map=1;var yt=require_getNative(),Et=require_root(),xt=yt(Et,"Map");return _Map=xt,_Map}var _mapCacheClear,hasRequired_mapCacheClear;function require_mapCacheClear(){if(hasRequired_mapCacheClear)return _mapCacheClear;hasRequired_mapCacheClear=1;var yt=require_Hash(),Et=require_ListCache(),xt=require_Map();function vt(){this.size=0,this.__data__={hash:new yt,map:new(xt||Et),string:new yt}}return _mapCacheClear=vt,_mapCacheClear}var _isKeyable,hasRequired_isKeyable;function require_isKeyable(){if(hasRequired_isKeyable)return _isKeyable;hasRequired_isKeyable=1;function yt(Et){var xt=typeof Et;return xt=="string"||xt=="number"||xt=="symbol"||xt=="boolean"?Et!=="__proto__":Et===null}return _isKeyable=yt,_isKeyable}var _getMapData,hasRequired_getMapData;function require_getMapData(){if(hasRequired_getMapData)return _getMapData;hasRequired_getMapData=1;var yt=require_isKeyable();function Et(xt,vt){var bt=xt.__data__;return yt(vt)?bt[typeof vt=="string"?"string":"hash"]:bt.map}return _getMapData=Et,_getMapData}var _mapCacheDelete,hasRequired_mapCacheDelete;function require_mapCacheDelete(){if(hasRequired_mapCacheDelete)return _mapCacheDelete;hasRequired_mapCacheDelete=1;var yt=require_getMapData();function Et(xt){var vt=yt(this,xt).delete(xt);return this.size-=vt?1:0,vt}return _mapCacheDelete=Et,_mapCacheDelete}var _mapCacheGet,hasRequired_mapCacheGet;function require_mapCacheGet(){if(hasRequired_mapCacheGet)return _mapCacheGet;hasRequired_mapCacheGet=1;var yt=require_getMapData();function Et(xt){return yt(this,xt).get(xt)}return _mapCacheGet=Et,_mapCacheGet}var _mapCacheHas,hasRequired_mapCacheHas;function require_mapCacheHas(){if(hasRequired_mapCacheHas)return _mapCacheHas;hasRequired_mapCacheHas=1;var yt=require_getMapData();function Et(xt){return yt(this,xt).has(xt)}return _mapCacheHas=Et,_mapCacheHas}var _mapCacheSet,hasRequired_mapCacheSet;function require_mapCacheSet(){if(hasRequired_mapCacheSet)return _mapCacheSet;hasRequired_mapCacheSet=1;var yt=require_getMapData();function Et(xt,vt){var bt=yt(this,xt),At=bt.size;return bt.set(xt,vt),this.size+=bt.size==At?0:1,this}return _mapCacheSet=Et,_mapCacheSet}var _MapCache,hasRequired_MapCache;function require_MapCache(){if(hasRequired_MapCache)return _MapCache;hasRequired_MapCache=1;var yt=require_mapCacheClear(),Et=require_mapCacheDelete(),xt=require_mapCacheGet(),vt=require_mapCacheHas(),bt=require_mapCacheSet();function At(Ft){var Ct=-1,wt=Ft==null?0:Ft.length;for(this.clear();++Ct<wt;){var St=Ft[Ct];this.set(St[0],St[1])}}return At.prototype.clear=yt,At.prototype.delete=Et,At.prototype.get=xt,At.prototype.has=vt,At.prototype.set=bt,_MapCache=At,_MapCache}var memoize_1,hasRequiredMemoize;function requireMemoize(){if(hasRequiredMemoize)return memoize_1;hasRequiredMemoize=1;var yt=require_MapCache(),Et="Expected a function";function xt(vt,bt){if(typeof vt!="function"||bt!=null&&typeof bt!="function")throw new TypeError(Et);var At=function(){var Ft=arguments,Ct=bt?bt.apply(this,Ft):Ft[0],wt=At.cache;if(wt.has(Ct))return wt.get(Ct);var St=vt.apply(this,Ft);return At.cache=wt.set(Ct,St)||wt,St};return At.cache=new(xt.Cache||yt),At}return xt.Cache=yt,memoize_1=xt,memoize_1}var _memoizeCapped,hasRequired_memoizeCapped;function require_memoizeCapped(){if(hasRequired_memoizeCapped)return _memoizeCapped;hasRequired_memoizeCapped=1;var yt=requireMemoize(),Et=500;function xt(vt){var bt=yt(vt,function(Ft){return At.size===Et&&At.clear(),Ft}),At=bt.cache;return bt}return _memoizeCapped=xt,_memoizeCapped}var _stringToPath,hasRequired_stringToPath;function require_stringToPath(){if(hasRequired_stringToPath)return _stringToPath;hasRequired_stringToPath=1;var yt=require_memoizeCapped(),Et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xt=/\\(\\)?/g,vt=yt(function(bt){var At=[];return bt.charCodeAt(0)===46&&At.push(""),bt.replace(Et,function(Ft,Ct,wt,St){At.push(wt?St.replace(xt,"$1"):Ct||Ft)}),At});return _stringToPath=vt,_stringToPath}var _arrayMap,hasRequired_arrayMap;function require_arrayMap(){if(hasRequired_arrayMap)return _arrayMap;hasRequired_arrayMap=1;function yt(Et,xt){for(var vt=-1,bt=Et==null?0:Et.length,At=Array(bt);++vt<bt;)At[vt]=xt(Et[vt],vt,Et);return At}return _arrayMap=yt,_arrayMap}var _baseToString,hasRequired_baseToString;function require_baseToString(){if(hasRequired_baseToString)return _baseToString;hasRequired_baseToString=1;var yt=require_Symbol(),Et=require_arrayMap(),xt=requireIsArray(),vt=requireIsSymbol(),bt=yt?yt.prototype:void 0,At=bt?bt.toString:void 0;function Ft(Ct){if(typeof Ct=="string")return Ct;if(xt(Ct))return Et(Ct,Ft)+"";if(vt(Ct))return At?At.call(Ct):"";var wt=Ct+"";return wt=="0"&&1/Ct==-1/0?"-0":wt}return _baseToString=Ft,_baseToString}var toString_1,hasRequiredToString;function requireToString(){if(hasRequiredToString)return toString_1;hasRequiredToString=1;var yt=require_baseToString();function Et(xt){return xt==null?"":yt(xt)}return toString_1=Et,toString_1}var _castPath,hasRequired_castPath;function require_castPath(){if(hasRequired_castPath)return _castPath;hasRequired_castPath=1;var yt=requireIsArray(),Et=require_isKey(),xt=require_stringToPath(),vt=requireToString();function bt(At,Ft){return yt(At)?At:Et(At,Ft)?[At]:xt(vt(At))}return _castPath=bt,_castPath}var _baseIsArguments,hasRequired_baseIsArguments;function require_baseIsArguments(){if(hasRequired_baseIsArguments)return _baseIsArguments;hasRequired_baseIsArguments=1;var yt=require_baseGetTag(),Et=requireIsObjectLike(),xt="[object Arguments]";function vt(bt){return Et(bt)&&yt(bt)==xt}return _baseIsArguments=vt,_baseIsArguments}var isArguments_1,hasRequiredIsArguments;function requireIsArguments(){if(hasRequiredIsArguments)return isArguments_1;hasRequiredIsArguments=1;var yt=require_baseIsArguments(),Et=requireIsObjectLike(),xt=Object.prototype,vt=xt.hasOwnProperty,bt=xt.propertyIsEnumerable,At=yt((function(){return arguments})())?yt:function(Ft){return Et(Ft)&&vt.call(Ft,"callee")&&!bt.call(Ft,"callee")};return isArguments_1=At,isArguments_1}var _isIndex,hasRequired_isIndex;function require_isIndex(){if(hasRequired_isIndex)return _isIndex;hasRequired_isIndex=1;var yt=9007199254740991,Et=/^(?:0|[1-9]\d*)$/;function xt(vt,bt){var At=typeof vt;return bt=bt??yt,!!bt&&(At=="number"||At!="symbol"&&Et.test(vt))&&vt>-1&&vt%1==0&&vt<bt}return _isIndex=xt,_isIndex}var isLength_1,hasRequiredIsLength;function requireIsLength(){if(hasRequiredIsLength)return isLength_1;hasRequiredIsLength=1;var yt=9007199254740991;function Et(xt){return typeof xt=="number"&&xt>-1&&xt%1==0&&xt<=yt}return isLength_1=Et,isLength_1}var _toKey,hasRequired_toKey;function require_toKey(){if(hasRequired_toKey)return _toKey;hasRequired_toKey=1;var yt=requireIsSymbol();function Et(xt){if(typeof xt=="string"||yt(xt))return xt;var vt=xt+"";return vt=="0"&&1/xt==-1/0?"-0":vt}return _toKey=Et,_toKey}var _hasPath,hasRequired_hasPath;function require_hasPath(){if(hasRequired_hasPath)return _hasPath;hasRequired_hasPath=1;var yt=require_castPath(),Et=requireIsArguments(),xt=requireIsArray(),vt=require_isIndex(),bt=requireIsLength(),At=require_toKey();function Ft(Ct,wt,St){wt=yt(wt,Ct);for(var Tt=-1,Rt=wt.length,Pt=!1;++Tt<Rt;){var Lt=At(wt[Tt]);if(!(Pt=Ct!=null&&St(Ct,Lt)))break;Ct=Ct[Lt]}return Pt||++Tt!=Rt?Pt:(Rt=Ct==null?0:Ct.length,!!Rt&&bt(Rt)&&vt(Lt,Rt)&&(xt(Ct)||Et(Ct)))}return _hasPath=Ft,_hasPath}var has_1,hasRequiredHas;function requireHas(){if(hasRequiredHas)return has_1;hasRequiredHas=1;var yt=require_baseHas(),Et=require_hasPath();function xt(vt,bt){return vt!=null&&Et(vt,bt,yt)}return has_1=xt,has_1}var hasExports=requireHas();const has$1=getDefaultExportFromCjs(hasExports);function panic(yt="This should not happen"){throw new Error(yt)}function assert(yt,Et="Assertion failed"){if(!yt)return panic(Et)}function assertNever(yt,Et){return panic(Et??"Hell froze over")}function maybe(yt,Et){try{return yt()}catch{return Et}}const has=Object.prototype.hasOwnProperty;function deepEqual(yt,Et){let xt,vt;if(yt===Et)return!0;if(yt&&Et&&(xt=yt.constructor)===Et.constructor){if(xt===Date)return yt.getTime()===Et.getTime();if(xt===RegExp)return yt.toString()===Et.toString();if(xt===Array){if((vt=yt.length)===Et.length)for(;vt--&&deepEqual(yt[vt],Et[vt]););return vt===-1}if(!xt||typeof yt=="object"){vt=0;for(xt in yt)if(has.call(yt,xt)&&++vt&&!has.call(Et,xt)||!(xt in Et)||!deepEqual(yt[xt],Et[xt]))return!1;return Object.keys(Et).length===vt}}return yt!==yt&&Et!==Et}const BooleanEmpty=null,BooleanIndeterminate=void 0;var GridCellKind;(function(yt){yt.Uri="uri",yt.Text="text",yt.Image="image",yt.RowID="row-id",yt.Number="number",yt.Bubble="bubble",yt.Boolean="boolean",yt.Loading="loading",yt.Markdown="markdown",yt.Drilldown="drilldown",yt.Protected="protected",yt.Custom="custom"})(GridCellKind||(GridCellKind={}));var GridColumnIcon;(function(yt){yt.HeaderRowID="headerRowID",yt.HeaderCode="headerCode",yt.HeaderNumber="headerNumber",yt.HeaderString="headerString",yt.HeaderBoolean="headerBoolean",yt.HeaderAudioUri="headerAudioUri",yt.HeaderVideoUri="headerVideoUri",yt.HeaderEmoji="headerEmoji",yt.HeaderImage="headerImage",yt.HeaderUri="headerUri",yt.HeaderPhone="headerPhone",yt.HeaderMarkdown="headerMarkdown",yt.HeaderDate="headerDate",yt.HeaderTime="headerTime",yt.HeaderEmail="headerEmail",yt.HeaderReference="headerReference",yt.HeaderIfThenElse="headerIfThenElse",yt.HeaderSingleValue="headerSingleValue",yt.HeaderLookup="headerLookup",yt.HeaderTextTemplate="headerTextTemplate",yt.HeaderMath="headerMath",yt.HeaderRollup="headerRollup",yt.HeaderJoinStrings="headerJoinStrings",yt.HeaderSplitString="headerSplitString",yt.HeaderGeoDistance="headerGeoDistance",yt.HeaderArray="headerArray",yt.RowOwnerOverlay="rowOwnerOverlay",yt.ProtectedColumnOverlay="protectedColumnOverlay"})(GridColumnIcon||(GridColumnIcon={}));var GridColumnMenuIcon;(function(yt){yt.Triangle="triangle",yt.Dots="dots"})(GridColumnMenuIcon||(GridColumnMenuIcon={}));function isSizedGridColumn(yt){return"width"in yt&&typeof yt.width=="number"}async function resolveCellsThunk(yt){return typeof yt=="object"?yt:await yt()}function isEditableGridCell(yt){return!(yt.kind===GridCellKind.Loading||yt.kind===GridCellKind.Bubble||yt.kind===GridCellKind.RowID||yt.kind===GridCellKind.Protected||yt.kind===GridCellKind.Drilldown)}function isInnerOnlyCell(yt){return yt.kind===InnerGridCellKind.Marker||yt.kind===InnerGridCellKind.NewRow}function isReadWriteCell(yt){if(!isEditableGridCell(yt)||yt.kind===GridCellKind.Image)return!1;switch(yt.kind){case GridCellKind.Text:case GridCellKind.Number:case GridCellKind.Markdown:case GridCellKind.Uri:case GridCellKind.Custom:case GridCellKind.Boolean:return yt.readonly!==!0;default:assertNever(yt,"A cell was passed with an invalid kind")}}function isObjectEditorCallbackResult(yt){return has$1(yt,"editor")}function booleanCellIsEditable(yt){return!(yt.readonly??!1)}var InnerGridCellKind;(function(yt){yt.NewRow="new-row",yt.Marker="marker"})(InnerGridCellKind||(InnerGridCellKind={}));const DEFAULT_FILL_HANDLE={shape:"square",size:4,offsetX:-2,offsetY:-2,outline:0};function mergeRanges(yt){if(yt.length===0)return[];const Et=[...yt],xt=[];Et.sort(function(vt,bt){return vt[0]-bt[0]}),xt.push([...Et[0]]);for(const vt of Et.slice(1)){const bt=xt[xt.length-1];bt[1]<vt[0]?xt.push([...vt]):bt[1]<vt[1]&&(bt[1]=vt[1])}return xt}let emptyCompactSelection;class CompactSelection{items;constructor(Et){this.items=Et}static create=Et=>new CompactSelection(mergeRanges(Et));static empty=()=>emptyCompactSelection??(emptyCompactSelection=new CompactSelection([]));static fromSingleSelection=Et=>CompactSelection.empty().add(Et);static fromArray=Et=>{if(Et.length===0)return CompactSelection.empty();const xt=Et.map(bt=>[bt,bt+1]),vt=mergeRanges(xt);return new CompactSelection(vt)};offset(Et){if(Et===0)return this;const xt=this.items.map(vt=>[vt[0]+Et,vt[1]+Et]);return new CompactSelection(xt)}add(Et){const xt=typeof Et=="number"?[Et,Et+1]:Et,vt=mergeRanges([...this.items,xt]);return new CompactSelection(vt)}remove(Et){const xt=[...this.items],vt=typeof Et=="number"?Et:Et[0],bt=typeof Et=="number"?Et+1:Et[1];for(const[At,Ft]of xt.entries()){const[Ct,wt]=Ft;if(Ct<=bt&&vt<=wt){const St=[];Ct<vt&&St.push([Ct,vt]),bt<wt&&St.push([bt,wt]),xt.splice(At,1,...St)}}return new CompactSelection(xt)}first(){if(this.items.length!==0)return this.items[0][0]}last(){if(this.items.length!==0)return this.items.slice(-1)[0][1]-1}hasIndex(Et){for(let xt=0;xt<this.items.length;xt++){const[vt,bt]=this.items[xt];if(Et>=vt&&Et<bt)return!0}return!1}hasAll(Et){for(let xt=Et[0];xt<Et[1];xt++)if(!this.hasIndex(xt))return!1;return!0}some(Et){for(const xt of this)if(Et(xt))return!0;return!1}equals(Et){if(Et===this)return!0;if(Et.items.length!==this.items.length)return!1;for(let xt=0;xt<this.items.length;xt++){const vt=Et.items[xt],bt=this.items[xt];if(vt[0]!==bt[0]||vt[1]!==bt[1])return!1}return!0}toArray(){const Et=[];for(const[xt,vt]of this.items)for(let bt=xt;bt<vt;bt++)Et.push(bt);return Et}get length(){let Et=0;for(const[xt,vt]of this.items)Et+=vt-xt;return Et}*[Symbol.iterator](){for(const[Et,xt]of this.items)for(let vt=Et;vt<xt;vt++)yield vt}}function memoize(yt){var Et=Object.create(null);return function(xt){return Et[xt]===void 0&&(Et[xt]=yt(xt)),Et[xt]}}var reactPropsRegex=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,isPropValid=memoize(function(yt){return reactPropsRegex.test(yt)||yt.charCodeAt(0)===111&&yt.charCodeAt(1)===110&&yt.charCodeAt(2)<91}),cx=function(){const Et=Array.prototype.slice.call(arguments).filter(Boolean),xt={},vt=[];Et.forEach(At=>{(At?At.split(" "):[]).forEach(Ct=>{if(Ct.startsWith("atm_")){const[,wt]=Ct.split("_");xt[wt]=Ct}else vt.push(Ct)})});const bt=[];for(const At in xt)Object.prototype.hasOwnProperty.call(xt,At)&&bt.push(xt[At]);return bt.push(...vt),bt.join(" ")},cx_default=cx,isCapital=yt=>yt.toUpperCase()===yt,filterKey=yt=>Et=>yt.indexOf(Et)===-1,omit=(yt,Et)=>{const xt={};return Object.keys(yt).filter(filterKey(Et)).forEach(vt=>{xt[vt]=yt[vt]}),xt};function filterProps(yt,Et,xt){const vt=omit(Et,xt);if(!yt){const bt=typeof isPropValid=="function"?{default:isPropValid}:isPropValid;Object.keys(vt).forEach(At=>{bt.default(At)||delete vt[At]})}return vt}var warnIfInvalid=(yt,Et)=>{};function styled(yt){let Et="";return xt=>{const vt=(At,Ft)=>{const{as:Ct=yt,class:wt=Et}=At,St=xt.propsAsIs===void 0?!(typeof Ct=="string"&&Ct.indexOf("-")===-1&&!isCapital(Ct[0])):xt.propsAsIs,Tt=filterProps(St,At,["as","class"]);Tt.ref=Ft,Tt.className=xt.atomic?cx_default(xt.class,Tt.className||wt):cx_default(Tt.className||wt,xt.class);const{vars:Rt}=xt;if(Rt){const Pt={};for(const Ot in Rt){const Mt=Rt[Ot],It=Mt[0],Nt=Mt[1]||"",Ut=typeof It=="function"?It(At):It;warnIfInvalid(Ut,xt.name),Pt[`--${Ot}`]=`${Ut}${Nt}`}const Lt=Tt.style||{},kt=Object.keys(Lt);kt.length>0&&kt.forEach(Ot=>{Pt[Ot]=Lt[Ot]}),Tt.style=Pt}return yt.__wyw_meta&&yt!==Ct?(Tt.as=Ct,reactExports.createElement(yt,Tt)):reactExports.createElement(Ct,Tt)},bt=reactExports.forwardRef?reactExports.forwardRef(vt):(At=>{const Ft=omit(At,["innerRef"]);return vt(Ft,At.innerRef)});return bt.displayName=xt.name,bt.__wyw_meta={className:xt.class||Et,extends:yt},bt}}var styled_default=styled;const ImageOverlayEditorStyle=styled_default("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var js={},Carousel={},lib={},reactSwipe={},propTypes={exports:{}},ReactPropTypesSecret_1,hasRequiredReactPropTypesSecret;function requireReactPropTypesSecret(){if(hasRequiredReactPropTypesSecret)return ReactPropTypesSecret_1;hasRequiredReactPropTypesSecret=1;var yt="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ReactPropTypesSecret_1=yt,ReactPropTypesSecret_1}var factoryWithThrowingShims,hasRequiredFactoryWithThrowingShims;function requireFactoryWithThrowingShims(){if(hasRequiredFactoryWithThrowingShims)return factoryWithThrowingShims;hasRequiredFactoryWithThrowingShims=1;var yt=requireReactPropTypesSecret();function Et(){}function xt(){}return xt.resetWarningCache=Et,factoryWithThrowingShims=function(){function vt(Ft,Ct,wt,St,Tt,Rt){if(Rt!==yt){var Pt=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw Pt.name="Invariant Violation",Pt}}vt.isRequired=vt;function bt(){return vt}var At={array:vt,bigint:vt,bool:vt,func:vt,number:vt,object:vt,string:vt,symbol:vt,any:vt,arrayOf:bt,element:vt,elementType:vt,instanceOf:bt,node:vt,objectOf:bt,oneOf:bt,oneOfType:bt,shape:bt,exact:bt,checkPropTypes:xt,resetWarningCache:Et};return At.PropTypes=At,At},factoryWithThrowingShims}var hasRequiredPropTypes;function requirePropTypes(){return hasRequiredPropTypes||(hasRequiredPropTypes=1,propTypes.exports=requireFactoryWithThrowingShims()()),propTypes.exports}var hasRequiredReactSwipe;function requireReactSwipe(){return hasRequiredReactSwipe||(hasRequiredReactSwipe=1,(function(yt){(function(Et,xt){xt(yt,requireReact(),requirePropTypes())})(reactSwipe,function(Et,xt,vt){Object.defineProperty(Et,"__esModule",{value:!0}),Et.setHasSupportToCaptureOption=kt;var bt=Ft(xt),At=Ft(vt);function Ft(Nt){return Nt&&Nt.__esModule?Nt:{default:Nt}}var Ct=Object.assign||function(Nt){for(var Ut=1;Ut<arguments.length;Ut++){var jt=arguments[Ut];for(var Vt in jt)Object.prototype.hasOwnProperty.call(jt,Vt)&&(Nt[Vt]=jt[Vt])}return Nt};function wt(Nt,Ut){var jt={};for(var Vt in Nt)Ut.indexOf(Vt)>=0||Object.prototype.hasOwnProperty.call(Nt,Vt)&&(jt[Vt]=Nt[Vt]);return jt}function St(Nt,Ut){if(!(Nt instanceof Ut))throw new TypeError("Cannot call a class as a function")}var Tt=(function(){function Nt(Ut,jt){for(var Vt=0;Vt<jt.length;Vt++){var zt=jt[Vt];zt.enumerable=zt.enumerable||!1,zt.configurable=!0,"value"in zt&&(zt.writable=!0),Object.defineProperty(Ut,zt.key,zt)}}return function(Ut,jt,Vt){return jt&&Nt(Ut.prototype,jt),Vt&&Nt(Ut,Vt),Ut}})();function Rt(Nt,Ut){if(!Nt)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Ut&&(typeof Ut=="object"||typeof Ut=="function")?Ut:Nt}function Pt(Nt,Ut){if(typeof Ut!="function"&&Ut!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof Ut);Nt.prototype=Object.create(Ut&&Ut.prototype,{constructor:{value:Nt,enumerable:!1,writable:!0,configurable:!0}}),Ut&&(Object.setPrototypeOf?Object.setPrototypeOf(Nt,Ut):Nt.__proto__=Ut)}var Lt=!1;function kt(Nt){Lt=Nt}try{addEventListener("test",null,Object.defineProperty({},"capture",{get:function(){kt(!0)}}))}catch{}function Ot(){var Nt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return Lt?Nt:Nt.capture}function Mt(Nt){if("touches"in Nt){var Ut=Nt.touches[0],jt=Ut.pageX,Vt=Ut.pageY;return{x:jt,y:Vt}}var zt=Nt.screenX,Ht=Nt.screenY;return{x:zt,y:Ht}}var It=(function(Nt){Pt(Ut,Nt);function Ut(){var jt;St(this,Ut);for(var Vt=arguments.length,zt=Array(Vt),Ht=0;Ht<Vt;Ht++)zt[Ht]=arguments[Ht];var Wt=Rt(this,(jt=Ut.__proto__||Object.getPrototypeOf(Ut)).call.apply(jt,[this].concat(zt)));return Wt._handleSwipeStart=Wt._handleSwipeStart.bind(Wt),Wt._handleSwipeMove=Wt._handleSwipeMove.bind(Wt),Wt._handleSwipeEnd=Wt._handleSwipeEnd.bind(Wt),Wt._onMouseDown=Wt._onMouseDown.bind(Wt),Wt._onMouseMove=Wt._onMouseMove.bind(Wt),Wt._onMouseUp=Wt._onMouseUp.bind(Wt),Wt._setSwiperRef=Wt._setSwiperRef.bind(Wt),Wt}return Tt(Ut,[{key:"componentDidMount",value:function(){this.swiper&&this.swiper.addEventListener("touchmove",this._handleSwipeMove,Ot({capture:!0,passive:!1}))}},{key:"componentWillUnmount",value:function(){this.swiper&&this.swiper.removeEventListener("touchmove",this._handleSwipeMove,Ot({capture:!0,passive:!1}))}},{key:"_onMouseDown",value:function(Vt){this.props.allowMouseEvents&&(this.mouseDown=!0,document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("mousemove",this._onMouseMove),this._handleSwipeStart(Vt))}},{key:"_onMouseMove",value:function(Vt){this.mouseDown&&this._handleSwipeMove(Vt)}},{key:"_onMouseUp",value:function(Vt){this.mouseDown=!1,document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("mousemove",this._onMouseMove),this._handleSwipeEnd(Vt)}},{key:"_handleSwipeStart",value:function(Vt){var zt=Mt(Vt),Ht=zt.x,Wt=zt.y;this.moveStart={x:Ht,y:Wt},this.props.onSwipeStart(Vt)}},{key:"_handleSwipeMove",value:function(Vt){if(this.moveStart){var zt=Mt(Vt),Ht=zt.x,Wt=zt.y,Gt=Ht-this.moveStart.x,qt=Wt-this.moveStart.y;this.moving=!0;var Xt=this.props.onSwipeMove({x:Gt,y:qt},Vt);Xt&&Vt.cancelable&&Vt.preventDefault(),this.movePosition={deltaX:Gt,deltaY:qt}}}},{key:"_handleSwipeEnd",value:function(Vt){this.props.onSwipeEnd(Vt);var zt=this.props.tolerance;this.moving&&this.movePosition&&(this.movePosition.deltaX<-zt?this.props.onSwipeLeft(1,Vt):this.movePosition.deltaX>zt&&this.props.onSwipeRight(1,Vt),this.movePosition.deltaY<-zt?this.props.onSwipeUp(1,Vt):this.movePosition.deltaY>zt&&this.props.onSwipeDown(1,Vt)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(Vt){this.swiper=Vt,this.props.innerRef(Vt)}},{key:"render",value:function(){var Vt=this.props;Vt.tagName;var zt=Vt.className,Ht=Vt.style,Wt=Vt.children;Vt.allowMouseEvents,Vt.onSwipeUp,Vt.onSwipeDown,Vt.onSwipeLeft,Vt.onSwipeRight,Vt.onSwipeStart,Vt.onSwipeMove,Vt.onSwipeEnd,Vt.innerRef,Vt.tolerance;var Gt=wt(Vt,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return bt.default.createElement(this.props.tagName,Ct({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:zt,style:Ht},Gt),Wt)}}]),Ut})(xt.Component);It.displayName="ReactSwipe",It.propTypes={tagName:At.default.string,className:At.default.string,style:At.default.object,children:At.default.node,allowMouseEvents:At.default.bool,onSwipeUp:At.default.func,onSwipeDown:At.default.func,onSwipeLeft:At.default.func,onSwipeRight:At.default.func,onSwipeStart:At.default.func,onSwipeMove:At.default.func,onSwipeEnd:At.default.func,innerRef:At.default.func,tolerance:At.default.number.isRequired},It.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},Et.default=It})})(reactSwipe)),reactSwipe}var hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,(function(yt){(function(Et,xt){xt(yt,requireReactSwipe())})(lib,function(Et,xt){Object.defineProperty(Et,"__esModule",{value:!0});var vt=bt(xt);function bt(At){return At&&At.__esModule?At:{default:At}}Et.default=vt.default})})(lib)),lib}var cssClasses={},classnames={exports:{}};var hasRequiredClassnames;function requireClassnames(){return hasRequiredClassnames||(hasRequiredClassnames=1,(function(yt){(function(){var Et={}.hasOwnProperty;function xt(){for(var At="",Ft=0;Ft<arguments.length;Ft++){var Ct=arguments[Ft];Ct&&(At=bt(At,vt(Ct)))}return At}function vt(At){if(typeof At=="string"||typeof At=="number")return At;if(typeof At!="object")return"";if(Array.isArray(At))return xt.apply(null,At);if(At.toString!==Object.prototype.toString&&!At.toString.toString().includes("[native code]"))return At.toString();var Ft="";for(var Ct in At)Et.call(At,Ct)&&At[Ct]&&(Ft=bt(Ft,Ct));return Ft}function bt(At,Ft){return Ft?At?At+" "+Ft:At+Ft:At}yt.exports?(xt.default=xt,yt.exports=xt):window.classNames=xt})()})(classnames)),classnames.exports}var hasRequiredCssClasses;function requireCssClasses(){if(hasRequiredCssClasses)return cssClasses;hasRequiredCssClasses=1,Object.defineProperty(cssClasses,"__esModule",{value:!0}),cssClasses.default=void 0;var yt=Et(requireClassnames());function Et(bt){return bt&&bt.__esModule?bt:{default:bt}}function xt(bt,At,Ft){return At in bt?Object.defineProperty(bt,At,{value:Ft,enumerable:!0,configurable:!0,writable:!0}):bt[At]=Ft,bt}var vt={ROOT:function(At){return(0,yt.default)(xt({"carousel-root":!0},At||"",!!At))},CAROUSEL:function(At){return(0,yt.default)({carousel:!0,"carousel-slider":At})},WRAPPER:function(At,Ft){return(0,yt.default)({"thumbs-wrapper":!At,"slider-wrapper":At,"axis-horizontal":Ft==="horizontal","axis-vertical":Ft!=="horizontal"})},SLIDER:function(At,Ft){return(0,yt.default)({thumbs:!At,slider:At,animated:!Ft})},ITEM:function(At,Ft,Ct){return(0,yt.default)({thumb:!At,slide:At,selected:Ft,previous:Ct})},ARROW_PREV:function(At){return(0,yt.default)({"control-arrow control-prev":!0,"control-disabled":At})},ARROW_NEXT:function(At){return(0,yt.default)({"control-arrow control-next":!0,"control-disabled":At})},DOT:function(At){return(0,yt.default)({dot:!0,selected:At})}};return cssClasses.default=vt,cssClasses}var Thumbs={},dimensions={},hasRequiredDimensions;function requireDimensions(){if(hasRequiredDimensions)return dimensions;hasRequiredDimensions=1,Object.defineProperty(dimensions,"__esModule",{value:!0}),dimensions.outerWidth=void 0;var yt=function(xt){var vt=xt.offsetWidth,bt=getComputedStyle(xt);return vt+=parseInt(bt.marginLeft)+parseInt(bt.marginRight),vt};return dimensions.outerWidth=yt,dimensions}var CSSTranslate={},hasRequiredCSSTranslate;function requireCSSTranslate(){if(hasRequiredCSSTranslate)return CSSTranslate;hasRequiredCSSTranslate=1,Object.defineProperty(CSSTranslate,"__esModule",{value:!0}),CSSTranslate.default=void 0;var yt=function(xt,vt,bt){var At=xt===0?xt:xt+vt,Ft=bt==="horizontal"?[At,0,0]:[0,At,0],Ct="translate3d",wt="("+Ft.join(",")+")";return Ct+wt};return CSSTranslate.default=yt,CSSTranslate}var window$1={},hasRequiredWindow;function requireWindow(){if(hasRequiredWindow)return window$1;hasRequiredWindow=1,Object.defineProperty(window$1,"__esModule",{value:!0}),window$1.default=void 0;var yt=function(){return window};return window$1.default=yt,window$1}var hasRequiredThumbs;function requireThumbs(){if(hasRequiredThumbs)return Thumbs;hasRequiredThumbs=1,Object.defineProperty(Thumbs,"__esModule",{value:!0}),Thumbs.default=void 0;var yt=wt(requireReact()),Et=Ft(requireCssClasses()),xt=requireDimensions(),vt=Ft(requireCSSTranslate()),bt=Ft(requireLib()),At=Ft(requireWindow());function Ft(Wt){return Wt&&Wt.__esModule?Wt:{default:Wt}}function Ct(){if(typeof WeakMap!="function")return null;var Wt=new WeakMap;return Ct=function(){return Wt},Wt}function wt(Wt){if(Wt&&Wt.__esModule)return Wt;if(Wt===null||St(Wt)!=="object"&&typeof Wt!="function")return{default:Wt};var Gt=Ct();if(Gt&&Gt.has(Wt))return Gt.get(Wt);var qt={},Xt=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Kt in Wt)if(Object.prototype.hasOwnProperty.call(Wt,Kt)){var Jt=Xt?Object.getOwnPropertyDescriptor(Wt,Kt):null;Jt&&(Jt.get||Jt.set)?Object.defineProperty(qt,Kt,Jt):qt[Kt]=Wt[Kt]}return qt.default=Wt,Gt&&Gt.set(Wt,qt),qt}function St(Wt){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?St=function(qt){return typeof qt}:St=function(qt){return qt&&typeof Symbol=="function"&&qt.constructor===Symbol&&qt!==Symbol.prototype?"symbol":typeof qt},St(Wt)}function Tt(){return Tt=Object.assign||function(Wt){for(var Gt=1;Gt<arguments.length;Gt++){var qt=arguments[Gt];for(var Xt in qt)Object.prototype.hasOwnProperty.call(qt,Xt)&&(Wt[Xt]=qt[Xt])}return Wt},Tt.apply(this,arguments)}function Rt(Wt,Gt){if(!(Wt instanceof Gt))throw new TypeError("Cannot call a class as a function")}function Pt(Wt,Gt){for(var qt=0;qt<Gt.length;qt++){var Xt=Gt[qt];Xt.enumerable=Xt.enumerable||!1,Xt.configurable=!0,"value"in Xt&&(Xt.writable=!0),Object.defineProperty(Wt,Xt.key,Xt)}}function Lt(Wt,Gt,qt){return Gt&&Pt(Wt.prototype,Gt),Wt}function kt(Wt,Gt){if(typeof Gt!="function"&&Gt!==null)throw new TypeError("Super expression must either be null or a function");Wt.prototype=Object.create(Gt&&Gt.prototype,{constructor:{value:Wt,writable:!0,configurable:!0}}),Gt&&Ot(Wt,Gt)}function Ot(Wt,Gt){return Ot=Object.setPrototypeOf||function(Xt,Kt){return Xt.__proto__=Kt,Xt},Ot(Wt,Gt)}function Mt(Wt){var Gt=Ut();return function(){var Xt=jt(Wt),Kt;if(Gt){var Jt=jt(this).constructor;Kt=Reflect.construct(Xt,arguments,Jt)}else Kt=Xt.apply(this,arguments);return It(this,Kt)}}function It(Wt,Gt){return Gt&&(St(Gt)==="object"||typeof Gt=="function")?Gt:Nt(Wt)}function Nt(Wt){if(Wt===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Wt}function Ut(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function jt(Wt){return jt=Object.setPrototypeOf?Object.getPrototypeOf:function(qt){return qt.__proto__||Object.getPrototypeOf(qt)},jt(Wt)}function Vt(Wt,Gt,qt){return Gt in Wt?Object.defineProperty(Wt,Gt,{value:qt,enumerable:!0,configurable:!0,writable:!0}):Wt[Gt]=qt,Wt}var zt=function(Gt){return Gt.hasOwnProperty("key")},Ht=(function(Wt){kt(qt,Wt);var Gt=Mt(qt);function qt(Xt){var Kt;return Rt(this,qt),Kt=Gt.call(this,Xt),Vt(Nt(Kt),"itemsWrapperRef",void 0),Vt(Nt(Kt),"itemsListRef",void 0),Vt(Nt(Kt),"thumbsRef",void 0),Vt(Nt(Kt),"setItemsWrapperRef",function(Jt){Kt.itemsWrapperRef=Jt}),Vt(Nt(Kt),"setItemsListRef",function(Jt){Kt.itemsListRef=Jt}),Vt(Nt(Kt),"setThumbsRef",function(Jt,tn){Kt.thumbsRef||(Kt.thumbsRef=[]),Kt.thumbsRef[tn]=Jt}),Vt(Nt(Kt),"updateSizes",function(){if(!(!Kt.props.children||!Kt.itemsWrapperRef||!Kt.thumbsRef)){var Jt=yt.Children.count(Kt.props.children),tn=Kt.itemsWrapperRef.clientWidth,sn=Kt.props.thumbWidth?Kt.props.thumbWidth:(0,xt.outerWidth)(Kt.thumbsRef[0]),Zt=Math.floor(tn/sn),nn=Zt<Jt,rn=nn?Jt-Zt:0;Kt.setState(function(on,ln){return{itemSize:sn,visibleItems:Zt,firstItem:nn?Kt.getFirstItem(ln.selectedItem):0,lastPosition:rn,showArrows:nn}})}}),Vt(Nt(Kt),"handleClickItem",function(Jt,tn,sn){if(!zt(sn)||sn.key==="Enter"){var Zt=Kt.props.onSelectItem;typeof Zt=="function"&&Zt(Jt,tn)}}),Vt(Nt(Kt),"onSwipeStart",function(){Kt.setState({swiping:!0})}),Vt(Nt(Kt),"onSwipeEnd",function(){Kt.setState({swiping:!1})}),Vt(Nt(Kt),"onSwipeMove",function(Jt){var tn=Jt.x;if(!Kt.state.itemSize||!Kt.itemsWrapperRef||!Kt.state.visibleItems)return!1;var sn=0,Zt=yt.Children.count(Kt.props.children),nn=-(Kt.state.firstItem*100)/Kt.state.visibleItems,rn=Math.max(Zt-Kt.state.visibleItems,0),on=-rn*100/Kt.state.visibleItems;nn===sn&&tn>0&&(tn=0),nn===on&&tn<0&&(tn=0);var ln=Kt.itemsWrapperRef.clientWidth,Qt=nn+100/(ln/tn);return Kt.itemsListRef&&["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(fn){Kt.itemsListRef.style[fn]=(0,vt.default)(Qt,"%",Kt.props.axis)}),!0}),Vt(Nt(Kt),"slideRight",function(Jt){Kt.moveTo(Kt.state.firstItem-(typeof Jt=="number"?Jt:1))}),Vt(Nt(Kt),"slideLeft",function(Jt){Kt.moveTo(Kt.state.firstItem+(typeof Jt=="number"?Jt:1))}),Vt(Nt(Kt),"moveTo",function(Jt){Jt=Jt<0?0:Jt,Jt=Jt>=Kt.state.lastPosition?Kt.state.lastPosition:Jt,Kt.setState({firstItem:Jt})}),Kt.state={selectedItem:Xt.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},Kt}return Lt(qt,[{key:"componentDidMount",value:function(){this.setupThumbs()}},{key:"componentDidUpdate",value:function(Kt){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==Kt.children&&this.updateSizes()}},{key:"componentWillUnmount",value:function(){this.destroyThumbs()}},{key:"setupThumbs",value:function(){(0,At.default)().addEventListener("resize",this.updateSizes),(0,At.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,At.default)().removeEventListener("resize",this.updateSizes),(0,At.default)().removeEventListener("DOMContentLoaded",this.updateSizes)}},{key:"getFirstItem",value:function(Kt){var Jt=Kt;return Kt>=this.state.lastPosition&&(Jt=this.state.lastPosition),Kt<this.state.firstItem+this.state.visibleItems&&(Jt=this.state.firstItem),Kt<this.state.firstItem&&(Jt=Kt),Jt}},{key:"renderItems",value:function(){var Kt=this;return this.props.children.map(function(Jt,tn){var sn=Et.default.ITEM(!1,tn===Kt.state.selectedItem),Zt={key:tn,ref:function(rn){return Kt.setThumbsRef(rn,tn)},className:sn,onClick:Kt.handleClickItem.bind(Kt,tn,Kt.props.children[tn]),onKeyDown:Kt.handleClickItem.bind(Kt,tn,Kt.props.children[tn]),"aria-label":"".concat(Kt.props.labels.item," ").concat(tn+1),style:{width:Kt.props.thumbWidth}};return yt.default.createElement("li",Tt({},Zt,{role:"button",tabIndex:0}),Jt)})}},{key:"render",value:function(){var Kt=this;if(!this.props.children)return null;var Jt=yt.Children.count(this.props.children)>1,tn=this.state.showArrows&&this.state.firstItem>0,sn=this.state.showArrows&&this.state.firstItem<this.state.lastPosition,Zt={},nn=-this.state.firstItem*(this.state.itemSize||0),rn=(0,vt.default)(nn,"px",this.props.axis),on=this.props.transitionTime+"ms";return Zt={WebkitTransform:rn,MozTransform:rn,MsTransform:rn,OTransform:rn,transform:rn,msTransform:rn,WebkitTransitionDuration:on,MozTransitionDuration:on,MsTransitionDuration:on,OTransitionDuration:on,transitionDuration:on,msTransitionDuration:on},yt.default.createElement("div",{className:Et.default.CAROUSEL(!1)},yt.default.createElement("div",{className:Et.default.WRAPPER(!1),ref:this.setItemsWrapperRef},yt.default.createElement("button",{type:"button",className:Et.default.ARROW_PREV(!tn),onClick:function(){return Kt.slideRight()},"aria-label":this.props.labels.leftArrow}),Jt?yt.default.createElement(bt.default,{tagName:"ul",className:Et.default.SLIDER(!1,this.state.swiping),onSwipeLeft:this.slideLeft,onSwipeRight:this.slideRight,onSwipeMove:this.onSwipeMove,onSwipeStart:this.onSwipeStart,onSwipeEnd:this.onSwipeEnd,style:Zt,innerRef:this.setItemsListRef,allowMouseEvents:this.props.emulateTouch},this.renderItems()):yt.default.createElement("ul",{className:Et.default.SLIDER(!1,this.state.swiping),ref:function(Qt){return Kt.setItemsListRef(Qt)},style:Zt},this.renderItems()),yt.default.createElement("button",{type:"button",className:Et.default.ARROW_NEXT(!sn),onClick:function(){return Kt.slideLeft()},"aria-label":this.props.labels.rightArrow})))}}]),qt})(yt.Component);return Thumbs.default=Ht,Vt(Ht,"displayName","Thumbs"),Vt(Ht,"defaultProps",{axis:"horizontal",labels:{leftArrow:"previous slide / item",rightArrow:"next slide / item",item:"slide item"},selectedItem:0,thumbWidth:80,transitionTime:350}),Thumbs}var document$1={},hasRequiredDocument;function requireDocument(){if(hasRequiredDocument)return document$1;hasRequiredDocument=1,Object.defineProperty(document$1,"__esModule",{value:!0}),document$1.default=void 0;var yt=function(){return document};return document$1.default=yt,document$1}var utils={},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils;hasRequiredUtils=1,Object.defineProperty(utils,"__esModule",{value:!0}),utils.setPosition=utils.getPosition=utils.isKeyboardEvent=utils.defaultStatusFormatter=utils.noop=void 0;var yt=requireReact(),Et=xt(requireCSSTranslate());function xt(wt){return wt&&wt.__esModule?wt:{default:wt}}var vt=function(){};utils.noop=vt;var bt=function(St,Tt){return"".concat(St," of ").concat(Tt)};utils.defaultStatusFormatter=bt;var At=function(St){return St?St.hasOwnProperty("key"):!1};utils.isKeyboardEvent=At;var Ft=function(St,Tt){if(Tt.infiniteLoop&&++St,St===0)return 0;var Rt=yt.Children.count(Tt.children);if(Tt.centerMode&&Tt.axis==="horizontal"){var Pt=-St*Tt.centerSlidePercentage,Lt=Rt-1;return St&&(St!==Lt||Tt.infiniteLoop)?Pt+=(100-Tt.centerSlidePercentage)/2:St===Lt&&(Pt+=100-Tt.centerSlidePercentage),Pt}return-St*100};utils.getPosition=Ft;var Ct=function(St,Tt){var Rt={};return["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(Pt){Rt[Pt]=(0,Et.default)(St,"%",Tt)}),Rt};return utils.setPosition=Ct,utils}var animations={},hasRequiredAnimations;function requireAnimations(){if(hasRequiredAnimations)return animations;hasRequiredAnimations=1,Object.defineProperty(animations,"__esModule",{value:!0}),animations.fadeAnimationHandler=animations.slideStopSwipingHandler=animations.slideSwipeAnimationHandler=animations.slideAnimationHandler=void 0;var yt=requireReact(),Et=vt(requireCSSTranslate()),xt=requireUtils();function vt(Rt){return Rt&&Rt.__esModule?Rt:{default:Rt}}function bt(Rt,Pt){var Lt=Object.keys(Rt);if(Object.getOwnPropertySymbols){var kt=Object.getOwnPropertySymbols(Rt);Pt&&(kt=kt.filter(function(Ot){return Object.getOwnPropertyDescriptor(Rt,Ot).enumerable})),Lt.push.apply(Lt,kt)}return Lt}function At(Rt){for(var Pt=1;Pt<arguments.length;Pt++){var Lt=arguments[Pt]!=null?arguments[Pt]:{};Pt%2?bt(Object(Lt),!0).forEach(function(kt){Ft(Rt,kt,Lt[kt])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Rt,Object.getOwnPropertyDescriptors(Lt)):bt(Object(Lt)).forEach(function(kt){Object.defineProperty(Rt,kt,Object.getOwnPropertyDescriptor(Lt,kt))})}return Rt}function Ft(Rt,Pt,Lt){return Pt in Rt?Object.defineProperty(Rt,Pt,{value:Lt,enumerable:!0,configurable:!0,writable:!0}):Rt[Pt]=Lt,Rt}var Ct=function(Pt,Lt){var kt={},Ot=Lt.selectedItem,Mt=Ot,It=yt.Children.count(Pt.children)-1,Nt=Pt.infiniteLoop&&(Ot<0||Ot>It);if(Nt)return Mt<0?Pt.centerMode&&Pt.centerSlidePercentage&&Pt.axis==="horizontal"?kt.itemListStyle=(0,xt.setPosition)(-(It+2)*Pt.centerSlidePercentage-(100-Pt.centerSlidePercentage)/2,Pt.axis):kt.itemListStyle=(0,xt.setPosition)(-(It+2)*100,Pt.axis):Mt>It&&(kt.itemListStyle=(0,xt.setPosition)(0,Pt.axis)),kt;var Ut=(0,xt.getPosition)(Ot,Pt),jt=(0,Et.default)(Ut,"%",Pt.axis),Vt=Pt.transitionTime+"ms";return kt.itemListStyle={WebkitTransform:jt,msTransform:jt,OTransform:jt,transform:jt},Lt.swiping||(kt.itemListStyle=At(At({},kt.itemListStyle),{},{WebkitTransitionDuration:Vt,MozTransitionDuration:Vt,OTransitionDuration:Vt,transitionDuration:Vt,msTransitionDuration:Vt})),kt};animations.slideAnimationHandler=Ct;var wt=function(Pt,Lt,kt,Ot){var Mt={},It=Lt.axis==="horizontal",Nt=yt.Children.count(Lt.children),Ut=0,jt=(0,xt.getPosition)(kt.selectedItem,Lt),Vt=Lt.infiniteLoop?(0,xt.getPosition)(Nt-1,Lt)-100:(0,xt.getPosition)(Nt-1,Lt),zt=It?Pt.x:Pt.y,Ht=zt;jt===Ut&&zt>0&&(Ht=0),jt===Vt&&zt<0&&(Ht=0);var Wt=jt+100/(kt.itemSize/Ht),Gt=Math.abs(zt)>Lt.swipeScrollTolerance;return Lt.infiniteLoop&&Gt&&(kt.selectedItem===0&&Wt>-100?Wt-=Nt*100:kt.selectedItem===Nt-1&&Wt<-Nt*100&&(Wt+=Nt*100)),(!Lt.preventMovementUntilSwipeScrollTolerance||Gt||kt.swipeMovementStarted)&&(kt.swipeMovementStarted||Ot({swipeMovementStarted:!0}),Mt.itemListStyle=(0,xt.setPosition)(Wt,Lt.axis)),Gt&&!kt.cancelClick&&Ot({cancelClick:!0}),Mt};animations.slideSwipeAnimationHandler=wt;var St=function(Pt,Lt){var kt=(0,xt.getPosition)(Lt.selectedItem,Pt),Ot=(0,xt.setPosition)(kt,Pt.axis);return{itemListStyle:Ot}};animations.slideStopSwipingHandler=St;var Tt=function(Pt,Lt){var kt=Pt.transitionTime+"ms",Ot="ease-in-out",Mt={position:"absolute",display:"block",zIndex:-2,minHeight:"100%",opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:Ot,msTransitionTimingFunction:Ot,MozTransitionTimingFunction:Ot,WebkitTransitionTimingFunction:Ot,OTransitionTimingFunction:Ot};return Lt.swiping||(Mt=At(At({},Mt),{},{WebkitTransitionDuration:kt,MozTransitionDuration:kt,OTransitionDuration:kt,transitionDuration:kt,msTransitionDuration:kt})),{slideStyle:Mt,selectedStyle:At(At({},Mt),{},{opacity:1,position:"relative"}),prevStyle:At({},Mt)}};return animations.fadeAnimationHandler=Tt,animations}var hasRequiredCarousel;function requireCarousel(){if(hasRequiredCarousel)return Carousel;hasRequiredCarousel=1,Object.defineProperty(Carousel,"__esModule",{value:!0}),Carousel.default=void 0;var yt=Tt(requireReact()),Et=wt(requireLib()),xt=wt(requireCssClasses()),vt=wt(requireThumbs()),bt=wt(requireDocument()),At=wt(requireWindow()),Ft=requireUtils(),Ct=requireAnimations();function wt(Xt){return Xt&&Xt.__esModule?Xt:{default:Xt}}function St(){if(typeof WeakMap!="function")return null;var Xt=new WeakMap;return St=function(){return Xt},Xt}function Tt(Xt){if(Xt&&Xt.__esModule)return Xt;if(Xt===null||Rt(Xt)!=="object"&&typeof Xt!="function")return{default:Xt};var Kt=St();if(Kt&&Kt.has(Xt))return Kt.get(Xt);var Jt={},tn=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var sn in Xt)if(Object.prototype.hasOwnProperty.call(Xt,sn)){var Zt=tn?Object.getOwnPropertyDescriptor(Xt,sn):null;Zt&&(Zt.get||Zt.set)?Object.defineProperty(Jt,sn,Zt):Jt[sn]=Xt[sn]}return Jt.default=Xt,Kt&&Kt.set(Xt,Jt),Jt}function Rt(Xt){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Rt=function(Jt){return typeof Jt}:Rt=function(Jt){return Jt&&typeof Symbol=="function"&&Jt.constructor===Symbol&&Jt!==Symbol.prototype?"symbol":typeof Jt},Rt(Xt)}function Pt(){return Pt=Object.assign||function(Xt){for(var Kt=1;Kt<arguments.length;Kt++){var Jt=arguments[Kt];for(var tn in Jt)Object.prototype.hasOwnProperty.call(Jt,tn)&&(Xt[tn]=Jt[tn])}return Xt},Pt.apply(this,arguments)}function Lt(Xt,Kt){var Jt=Object.keys(Xt);if(Object.getOwnPropertySymbols){var tn=Object.getOwnPropertySymbols(Xt);Kt&&(tn=tn.filter(function(sn){return Object.getOwnPropertyDescriptor(Xt,sn).enumerable})),Jt.push.apply(Jt,tn)}return Jt}function kt(Xt){for(var Kt=1;Kt<arguments.length;Kt++){var Jt=arguments[Kt]!=null?arguments[Kt]:{};Kt%2?Lt(Object(Jt),!0).forEach(function(tn){Gt(Xt,tn,Jt[tn])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Xt,Object.getOwnPropertyDescriptors(Jt)):Lt(Object(Jt)).forEach(function(tn){Object.defineProperty(Xt,tn,Object.getOwnPropertyDescriptor(Jt,tn))})}return Xt}function Ot(Xt,Kt){if(!(Xt instanceof Kt))throw new TypeError("Cannot call a class as a function")}function Mt(Xt,Kt){for(var Jt=0;Jt<Kt.length;Jt++){var tn=Kt[Jt];tn.enumerable=tn.enumerable||!1,tn.configurable=!0,"value"in tn&&(tn.writable=!0),Object.defineProperty(Xt,tn.key,tn)}}function It(Xt,Kt,Jt){return Kt&&Mt(Xt.prototype,Kt),Xt}function Nt(Xt,Kt){if(typeof Kt!="function"&&Kt!==null)throw new TypeError("Super expression must either be null or a function");Xt.prototype=Object.create(Kt&&Kt.prototype,{constructor:{value:Xt,writable:!0,configurable:!0}}),Kt&&Ut(Xt,Kt)}function Ut(Xt,Kt){return Ut=Object.setPrototypeOf||function(tn,sn){return tn.__proto__=sn,tn},Ut(Xt,Kt)}function jt(Xt){var Kt=Ht();return function(){var tn=Wt(Xt),sn;if(Kt){var Zt=Wt(this).constructor;sn=Reflect.construct(tn,arguments,Zt)}else sn=tn.apply(this,arguments);return Vt(this,sn)}}function Vt(Xt,Kt){return Kt&&(Rt(Kt)==="object"||typeof Kt=="function")?Kt:zt(Xt)}function zt(Xt){if(Xt===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Xt}function Ht(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Wt(Xt){return Wt=Object.setPrototypeOf?Object.getPrototypeOf:function(Jt){return Jt.__proto__||Object.getPrototypeOf(Jt)},Wt(Xt)}function Gt(Xt,Kt,Jt){return Kt in Xt?Object.defineProperty(Xt,Kt,{value:Jt,enumerable:!0,configurable:!0,writable:!0}):Xt[Kt]=Jt,Xt}var qt=(function(Xt){Nt(Jt,Xt);var Kt=jt(Jt);function Jt(tn){var sn;Ot(this,Jt),sn=Kt.call(this,tn),Gt(zt(sn),"thumbsRef",void 0),Gt(zt(sn),"carouselWrapperRef",void 0),Gt(zt(sn),"listRef",void 0),Gt(zt(sn),"itemsRef",void 0),Gt(zt(sn),"timer",void 0),Gt(zt(sn),"animationHandler",void 0),Gt(zt(sn),"setThumbsRef",function(nn){sn.thumbsRef=nn}),Gt(zt(sn),"setCarouselWrapperRef",function(nn){sn.carouselWrapperRef=nn}),Gt(zt(sn),"setListRef",function(nn){sn.listRef=nn}),Gt(zt(sn),"setItemsRef",function(nn,rn){sn.itemsRef||(sn.itemsRef=[]),sn.itemsRef[rn]=nn}),Gt(zt(sn),"autoPlay",function(){yt.Children.count(sn.props.children)<=1||(sn.clearAutoPlay(),sn.props.autoPlay&&(sn.timer=setTimeout(function(){sn.increment()},sn.props.interval)))}),Gt(zt(sn),"clearAutoPlay",function(){sn.timer&&clearTimeout(sn.timer)}),Gt(zt(sn),"resetAutoPlay",function(){sn.clearAutoPlay(),sn.autoPlay()}),Gt(zt(sn),"stopOnHover",function(){sn.setState({isMouseEntered:!0},sn.clearAutoPlay)}),Gt(zt(sn),"startOnLeave",function(){sn.setState({isMouseEntered:!1},sn.autoPlay)}),Gt(zt(sn),"isFocusWithinTheCarousel",function(){return sn.carouselWrapperRef?!!((0,bt.default)().activeElement===sn.carouselWrapperRef||sn.carouselWrapperRef.contains((0,bt.default)().activeElement)):!1}),Gt(zt(sn),"navigateWithKeyboard",function(nn){if(sn.isFocusWithinTheCarousel()){var rn=sn.props.axis,on=rn==="horizontal",ln={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},Qt=on?ln.ArrowRight:ln.ArrowDown,fn=on?ln.ArrowLeft:ln.ArrowUp;Qt===nn.keyCode?sn.increment():fn===nn.keyCode&&sn.decrement()}}),Gt(zt(sn),"updateSizes",function(){if(!(!sn.state.initialized||!sn.itemsRef||sn.itemsRef.length===0)){var nn=sn.props.axis==="horizontal",rn=sn.itemsRef[0];if(rn){var on=nn?rn.clientWidth:rn.clientHeight;sn.setState({itemSize:on}),sn.thumbsRef&&sn.thumbsRef.updateSizes()}}}),Gt(zt(sn),"setMountState",function(){sn.setState({hasMount:!0}),sn.updateSizes()}),Gt(zt(sn),"handleClickItem",function(nn,rn){if(yt.Children.count(sn.props.children)!==0){if(sn.state.cancelClick){sn.setState({cancelClick:!1});return}sn.props.onClickItem(nn,rn),nn!==sn.state.selectedItem&&sn.setState({selectedItem:nn})}}),Gt(zt(sn),"handleOnChange",function(nn,rn){yt.Children.count(sn.props.children)<=1||sn.props.onChange(nn,rn)}),Gt(zt(sn),"handleClickThumb",function(nn,rn){sn.props.onClickThumb(nn,rn),sn.moveTo(nn)}),Gt(zt(sn),"onSwipeStart",function(nn){sn.setState({swiping:!0}),sn.props.onSwipeStart(nn)}),Gt(zt(sn),"onSwipeEnd",function(nn){sn.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),sn.props.onSwipeEnd(nn),sn.clearAutoPlay(),sn.state.autoPlay&&sn.autoPlay()}),Gt(zt(sn),"onSwipeMove",function(nn,rn){sn.props.onSwipeMove(rn);var on=sn.props.swipeAnimationHandler(nn,sn.props,sn.state,sn.setState.bind(zt(sn)));return sn.setState(kt({},on)),!!Object.keys(on).length}),Gt(zt(sn),"decrement",function(){var nn=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;sn.moveTo(sn.state.selectedItem-(typeof nn=="number"?nn:1))}),Gt(zt(sn),"increment",function(){var nn=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;sn.moveTo(sn.state.selectedItem+(typeof nn=="number"?nn:1))}),Gt(zt(sn),"moveTo",function(nn){if(typeof nn=="number"){var rn=yt.Children.count(sn.props.children)-1;nn<0&&(nn=sn.props.infiniteLoop?rn:0),nn>rn&&(nn=sn.props.infiniteLoop?0:rn),sn.selectItem({selectedItem:nn}),sn.state.autoPlay&&sn.state.isMouseEntered===!1&&sn.resetAutoPlay()}}),Gt(zt(sn),"onClickNext",function(){sn.increment(1)}),Gt(zt(sn),"onClickPrev",function(){sn.decrement(1)}),Gt(zt(sn),"onSwipeForward",function(){sn.increment(1),sn.props.emulateTouch&&sn.setState({cancelClick:!0})}),Gt(zt(sn),"onSwipeBackwards",function(){sn.decrement(1),sn.props.emulateTouch&&sn.setState({cancelClick:!0})}),Gt(zt(sn),"changeItem",function(nn){return function(rn){(!(0,Ft.isKeyboardEvent)(rn)||rn.key==="Enter")&&sn.moveTo(nn)}}),Gt(zt(sn),"selectItem",function(nn){sn.setState(kt({previousItem:sn.state.selectedItem},nn),function(){sn.setState(sn.animationHandler(sn.props,sn.state))}),sn.handleOnChange(nn.selectedItem,yt.Children.toArray(sn.props.children)[nn.selectedItem])}),Gt(zt(sn),"getInitialImage",function(){var nn=sn.props.selectedItem,rn=sn.itemsRef&&sn.itemsRef[nn],on=rn&&rn.getElementsByTagName("img")||[];return on[0]}),Gt(zt(sn),"getVariableItemHeight",function(nn){var rn=sn.itemsRef&&sn.itemsRef[nn];if(sn.state.hasMount&&rn&&rn.children.length){var on=rn.children[0].getElementsByTagName("img")||[];if(on.length>0){var ln=on[0];if(!ln.complete){var Qt=function mn(){sn.forceUpdate(),ln.removeEventListener("load",mn)};ln.addEventListener("load",Qt)}}var fn=on[0]||rn.children[0],pn=fn.clientHeight;return pn>0?pn:null}return null});var Zt={initialized:!1,previousItem:tn.selectedItem,selectedItem:tn.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:tn.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return sn.animationHandler=typeof tn.animationHandler=="function"&&tn.animationHandler||tn.animationHandler==="fade"&&Ct.fadeAnimationHandler||Ct.slideAnimationHandler,sn.state=kt(kt({},Zt),sn.animationHandler(tn,Zt)),sn}return It(Jt,[{key:"componentDidMount",value:function(){this.props.children&&this.setupCarousel()}},{key:"componentDidUpdate",value:function(sn,Zt){!sn.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!sn.autoFocus&&this.props.autoFocus&&this.forceFocus(),Zt.swiping&&!this.state.swiping&&this.setState(kt({},this.props.stopSwipingHandler(this.props,this.state))),(sn.selectedItem!==this.props.selectedItem||sn.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),sn.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var sn=this;this.bindEvents(),this.state.autoPlay&&yt.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var Zt=sn.getInitialImage();Zt&&!Zt.complete?Zt.addEventListener("load",sn.setMountState):sn.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var sn=this.carouselWrapperRef;this.props.stopOnHover&&sn&&(sn.addEventListener("mouseenter",this.stopOnHover),sn.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var sn=this.carouselWrapperRef;this.props.stopOnHover&&sn&&(sn.removeEventListener("mouseenter",this.stopOnHover),sn.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,At.default)().addEventListener("resize",this.updateSizes),(0,At.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,bt.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,At.default)().removeEventListener("resize",this.updateSizes),(0,At.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var sn=this.getInitialImage();sn&&sn.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,bt.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var sn;(sn=this.carouselWrapperRef)===null||sn===void 0||sn.focus()}},{key:"renderItems",value:function(sn){var Zt=this;return this.props.children?yt.Children.map(this.props.children,function(nn,rn){var on=rn===Zt.state.selectedItem,ln=rn===Zt.state.previousItem,Qt=on&&Zt.state.selectedStyle||ln&&Zt.state.prevStyle||Zt.state.slideStyle||{};Zt.props.centerMode&&Zt.props.axis==="horizontal"&&(Qt=kt(kt({},Qt),{},{minWidth:Zt.props.centerSlidePercentage+"%"})),Zt.state.swiping&&Zt.state.swipeMovementStarted&&(Qt=kt(kt({},Qt),{},{pointerEvents:"none"}));var fn={ref:function(mn){return Zt.setItemsRef(mn,rn)},key:"itemKey"+rn+(sn?"clone":""),className:xt.default.ITEM(!0,rn===Zt.state.selectedItem,rn===Zt.state.previousItem),onClick:Zt.handleClickItem.bind(Zt,rn,nn),style:Qt};return yt.default.createElement("li",fn,Zt.props.renderItem(nn,{isSelected:rn===Zt.state.selectedItem,isPrevious:rn===Zt.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var sn=this,Zt=this.props,nn=Zt.showIndicators,rn=Zt.labels,on=Zt.renderIndicator,ln=Zt.children;return nn?yt.default.createElement("ul",{className:"control-dots"},yt.Children.map(ln,function(Qt,fn){return on&&on(sn.changeItem(fn),fn===sn.state.selectedItem,fn,rn.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?yt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,yt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||yt.Children.count(this.props.children)===0?null:yt.default.createElement(vt.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var sn=this;if(!this.props.children||yt.Children.count(this.props.children)===0)return null;var Zt=this.props.swipeable&&yt.Children.count(this.props.children)>1,nn=this.props.axis==="horizontal",rn=this.props.showArrows&&yt.Children.count(this.props.children)>1,on=rn&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,ln=rn&&(this.state.selectedItem<yt.Children.count(this.props.children)-1||this.props.infiniteLoop)||!1,Qt=this.renderItems(!0),fn=Qt.shift(),pn=Qt.pop(),mn={className:xt.default.SLIDER(!0,this.state.swiping),onSwipeMove:this.onSwipeMove,onSwipeStart:this.onSwipeStart,onSwipeEnd:this.onSwipeEnd,style:this.state.itemListStyle,tolerance:this.props.swipeScrollTolerance},vn={};if(nn){if(mn.onSwipeLeft=this.onSwipeForward,mn.onSwipeRight=this.onSwipeBackwards,this.props.dynamicHeight){var yn=this.getVariableItemHeight(this.state.selectedItem);vn.height=yn||"auto"}}else mn.onSwipeUp=this.props.verticalSwipe==="natural"?this.onSwipeBackwards:this.onSwipeForward,mn.onSwipeDown=this.props.verticalSwipe==="natural"?this.onSwipeForward:this.onSwipeBackwards,mn.style=kt(kt({},mn.style),{},{height:this.state.itemSize}),vn.height=this.state.itemSize;return yt.default.createElement("div",{"aria-label":this.props.ariaLabel,className:xt.default.ROOT(this.props.className),ref:this.setCarouselWrapperRef,tabIndex:this.props.useKeyboardArrows?0:void 0},yt.default.createElement("div",{className:xt.default.CAROUSEL(!0),style:{width:this.props.width}},this.renderControls(),this.props.renderArrowPrev(this.onClickPrev,on,this.props.labels.leftArrow),yt.default.createElement("div",{className:xt.default.WRAPPER(!0,this.props.axis),style:vn},Zt?yt.default.createElement(Et.default,Pt({tagName:"ul",innerRef:this.setListRef},mn,{allowMouseEvents:this.props.emulateTouch}),this.props.infiniteLoop&&pn,this.renderItems(),this.props.infiniteLoop&&fn):yt.default.createElement("ul",{className:xt.default.SLIDER(!0,this.state.swiping),ref:function(Mn){return sn.setListRef(Mn)},style:this.state.itemListStyle||{}},this.props.infiniteLoop&&pn,this.renderItems(),this.props.infiniteLoop&&fn)),this.props.renderArrowNext(this.onClickNext,ln,this.props.labels.rightArrow),this.renderStatus()),this.renderThumbs())}}]),Jt})(yt.default.Component);return Carousel.default=qt,Gt(qt,"displayName","Carousel"),Gt(qt,"defaultProps",{ariaLabel:void 0,axis:"horizontal",centerSlidePercentage:80,interval:3e3,labels:{leftArrow:"previous slide / item",rightArrow:"next slide / item",item:"slide item"},onClickItem:Ft.noop,onClickThumb:Ft.noop,onChange:Ft.noop,onSwipeStart:function(){},onSwipeEnd:function(){},onSwipeMove:function(){return!1},preventMovementUntilSwipeScrollTolerance:!1,renderArrowPrev:function(Kt,Jt,tn){return yt.default.createElement("button",{type:"button","aria-label":tn,className:xt.default.ARROW_PREV(!Jt),onClick:Kt})},renderArrowNext:function(Kt,Jt,tn){return yt.default.createElement("button",{type:"button","aria-label":tn,className:xt.default.ARROW_NEXT(!Jt),onClick:Kt})},renderIndicator:function(Kt,Jt,tn,sn){return yt.default.createElement("li",{className:xt.default.DOT(Jt),onClick:Kt,onKeyDown:Kt,value:tn,key:tn,role:"button",tabIndex:0,"aria-label":"".concat(sn," ").concat(tn+1)})},renderItem:function(Kt){return Kt},renderThumbs:function(Kt){var Jt=yt.Children.map(Kt,function(tn){var sn=tn;if(tn.type!=="img"&&(sn=yt.Children.toArray(tn.props.children).find(function(Zt){return Zt.type==="img"})),!!sn)return sn});return Jt.filter(function(tn){return tn}).length===0?(console.warn("No images found! Can't build the thumb list without images. If you don't need thumbs, set showThumbs={false} in the Carousel. Note that it's not possible to get images rendered inside custom components. More info at https://github.com/leandrowd/react-responsive-carousel/blob/master/TROUBLESHOOTING.md"),[]):Jt},statusFormatter:Ft.defaultStatusFormatter,selectedItem:0,showArrows:!0,showIndicators:!0,showStatus:!0,showThumbs:!0,stopOnHover:!0,swipeScrollTolerance:5,swipeable:!0,transitionTime:350,verticalSwipe:"standard",width:"100%",animationHandler:"slide",swipeAnimationHandler:Ct.slideSwipeAnimationHandler,stopSwipingHandler:Ct.slideStopSwipingHandler}),Carousel}var types={},hasRequiredTypes;function requireTypes(){return hasRequiredTypes||(hasRequiredTypes=1),types}var hasRequiredJs;function requireJs(){return hasRequiredJs||(hasRequiredJs=1,(function(yt){Object.defineProperty(yt,"__esModule",{value:!0}),Object.defineProperty(yt,"Carousel",{enumerable:!0,get:function(){return Et.default}}),Object.defineProperty(yt,"CarouselProps",{enumerable:!0,get:function(){return xt.CarouselProps}}),Object.defineProperty(yt,"Thumbs",{enumerable:!0,get:function(){return vt.default}});var Et=bt(requireCarousel()),xt=requireTypes(),vt=bt(requireThumbs());function bt(At){return At&&At.__esModule?At:{default:At}}})(js)),js}var jsExports=requireJs(),now_1,hasRequiredNow;function requireNow(){if(hasRequiredNow)return now_1;hasRequiredNow=1;var yt=require_root(),Et=function(){return yt.Date.now()};return now_1=Et,now_1}var _trimmedEndIndex,hasRequired_trimmedEndIndex;function require_trimmedEndIndex(){if(hasRequired_trimmedEndIndex)return _trimmedEndIndex;hasRequired_trimmedEndIndex=1;var yt=/\s/;function Et(xt){for(var vt=xt.length;vt--&&yt.test(xt.charAt(vt)););return vt}return _trimmedEndIndex=Et,_trimmedEndIndex}var _baseTrim,hasRequired_baseTrim;function require_baseTrim(){if(hasRequired_baseTrim)return _baseTrim;hasRequired_baseTrim=1;var yt=require_trimmedEndIndex(),Et=/^\s+/;function xt(vt){return vt&&vt.slice(0,yt(vt)+1).replace(Et,"")}return _baseTrim=xt,_baseTrim}var toNumber_1,hasRequiredToNumber;function requireToNumber(){if(hasRequiredToNumber)return toNumber_1;hasRequiredToNumber=1;var yt=require_baseTrim(),Et=requireIsObject(),xt=requireIsSymbol(),vt=NaN,bt=/^[-+]0x[0-9a-f]+$/i,At=/^0b[01]+$/i,Ft=/^0o[0-7]+$/i,Ct=parseInt;function wt(St){if(typeof St=="number")return St;if(xt(St))return vt;if(Et(St)){var Tt=typeof St.valueOf=="function"?St.valueOf():St;St=Et(Tt)?Tt+"":Tt}if(typeof St!="string")return St===0?St:+St;St=yt(St);var Rt=At.test(St);return Rt||Ft.test(St)?Ct(St.slice(2),Rt?2:8):bt.test(St)?vt:+St}return toNumber_1=wt,toNumber_1}var debounce_1,hasRequiredDebounce;function requireDebounce(){if(hasRequiredDebounce)return debounce_1;hasRequiredDebounce=1;var yt=requireIsObject(),Et=requireNow(),xt=requireToNumber(),vt="Expected a function",bt=Math.max,At=Math.min;function Ft(Ct,wt,St){var Tt,Rt,Pt,Lt,kt,Ot,Mt=0,It=!1,Nt=!1,Ut=!0;if(typeof Ct!="function")throw new TypeError(vt);wt=xt(wt)||0,yt(St)&&(It=!!St.leading,Nt="maxWait"in St,Pt=Nt?bt(xt(St.maxWait)||0,wt):Pt,Ut="trailing"in St?!!St.trailing:Ut);function jt(Jt){var tn=Tt,sn=Rt;return Tt=Rt=void 0,Mt=Jt,Lt=Ct.apply(sn,tn),Lt}function Vt(Jt){return Mt=Jt,kt=setTimeout(Wt,wt),It?jt(Jt):Lt}function zt(Jt){var tn=Jt-Ot,sn=Jt-Mt,Zt=wt-tn;return Nt?At(Zt,Pt-sn):Zt}function Ht(Jt){var tn=Jt-Ot,sn=Jt-Mt;return Ot===void 0||tn>=wt||tn<0||Nt&&sn>=Pt}function Wt(){var Jt=Et();if(Ht(Jt))return Gt(Jt);kt=setTimeout(Wt,zt(Jt))}function Gt(Jt){return kt=void 0,Ut&&Tt?jt(Jt):(Tt=Rt=void 0,Lt)}function qt(){kt!==void 0&&clearTimeout(kt),Mt=0,Tt=Ot=Rt=kt=void 0}function Xt(){return kt===void 0?Lt:Gt(Et())}function Kt(){var Jt=Et(),tn=Ht(Jt);if(Tt=arguments,Rt=this,Ot=Jt,tn){if(kt===void 0)return Vt(Ot);if(Nt)return clearTimeout(kt),kt=setTimeout(Wt,wt),jt(Ot)}return kt===void 0&&(kt=setTimeout(Wt,wt)),Lt}return Kt.cancel=qt,Kt.flush=Xt,Kt}return debounce_1=Ft,debounce_1}var debounceExports=requireDebounce();const debounce=getDefaultExportFromCjs(debounceExports);function useEventListener(yt,Et,xt,vt,bt=!1){const At=reactExports.useRef();At.current=Et,reactExports.useEffect(()=>{if(xt===null||xt.addEventListener===void 0)return;const Ft=xt,Ct=wt=>{At.current?.call(Ft,wt)};return Ft.addEventListener(yt,Ct,{passive:vt,capture:bt}),()=>{Ft.removeEventListener(yt,Ct,{capture:bt})}},[yt,xt,vt,bt])}function whenDefined(yt,Et){return yt===void 0?void 0:Et}const PI=Math.PI;function degreesToRadians(yt){return yt*PI/180}const getSquareBB=(yt,Et,xt)=>({x1:yt-xt/2,y1:Et-xt/2,x2:yt+xt/2,y2:Et+xt/2}),getSquareXPosFromAlign=(yt,Et,xt,vt,bt)=>{switch(yt){case"left":return Math.floor(Et)+vt+bt/2;case"center":return Math.floor(Et+xt/2);case"right":return Math.floor(Et+xt)-vt-bt/2}},getSquareWidth=(yt,Et,xt)=>Math.min(yt,Et-xt*2),pointIsWithinBB=(yt,Et,xt)=>xt.x1<=yt&&yt<=xt.x2&&xt.y1<=Et&&Et<=xt.y2,EditPencil=yt=>{const Et=yt.fgColor??"currentColor";return reactExports.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},reactExports.createElement("path",{d:"M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929",stroke:Et,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),reactExports.createElement("path",{d:"M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z",stroke:Et,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}))},Checkmark=yt=>{const Et=yt.fgColor??"currentColor";return reactExports.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},reactExports.createElement("path",{d:"M19 6L10.3802 17L5.34071 11.8758",vectorEffect:"non-scaling-stroke",stroke:Et,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function useDebouncedMemo(yt,Et,xt){const[vt,bt]=reactExports.useState(yt),At=reactExports.useRef(!0);reactExports.useEffect(()=>()=>{At.current=!1},[]);const Ft=reactExports.useRef(debounce(Ct=>{At.current&&bt(Ct)},xt));return reactExports.useLayoutEffect(()=>{At.current&&Ft.current(()=>yt())},Et),vt}const rtlRange="֑-߿יִ-﷽ﹰ-ﻼ",ltrRange="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",rtl=new RegExp("^[^"+ltrRange+"]*["+rtlRange+"]");function direction(yt){return rtl.test(yt)?"rtl":"not-rtl"}let scrollbarWidthCache;function getScrollBarWidth(){if(typeof document>"u")return 0;if(scrollbarWidthCache!==void 0)return scrollbarWidthCache;const yt=document.createElement("p");yt.style.width="100%",yt.style.height="200px";const Et=document.createElement("div");Et.id="testScrollbar",Et.style.position="absolute",Et.style.top="0px",Et.style.left="0px",Et.style.visibility="hidden",Et.style.width="200px",Et.style.height="150px",Et.style.overflow="hidden",Et.append(yt),document.body.append(Et);const xt=yt.offsetWidth;Et.style.overflow="scroll";let vt=yt.offsetWidth;return xt===vt&&(vt=Et.clientWidth),Et.remove(),scrollbarWidthCache=xt-vt,scrollbarWidthCache}const empty=Symbol();function useStateWithReactiveInput(yt){const Et=reactExports.useRef([empty,yt]);Et.current[1]!==yt&&(Et.current[0]=yt),Et.current[1]=yt;const[xt,vt]=reactExports.useState(yt),[,bt]=reactExports.useState(),At=reactExports.useCallback(Ct=>{const wt=Et.current[0];wt!==empty&&(Ct=typeof Ct=="function"?Ct(wt):Ct,Ct===wt)||(wt!==empty&&bt({}),vt(St=>typeof Ct=="function"?Ct(wt===empty?St:wt):Ct),Et.current[0]=empty)},[]),Ft=reactExports.useCallback(()=>{Et.current[0]=empty,bt({})},[]);return[Et.current[0]===empty?xt:Et.current[0],At,Ft]}function makeAccessibilityStringForArray(yt){if(yt.length===0)return"";let Et=0,xt=0;for(const vt of yt){if(xt+=vt.length,xt>1e4)break;Et++}return yt.slice(0,Et).join(", ")}function useDeepMemo(yt){const Et=reactExports.useRef(yt);return deepEqual(yt,Et.current)||(Et.current=yt),Et.current}const ImageOverlayEditor=yt=>{const{urls:Et,canWrite:xt,onEditClick:vt,renderImage:bt}=yt,At=Et.filter(Ct=>Ct!=="");if(At.length===0)return null;const Ft=At.length>1;return reactExports.createElement(ImageOverlayEditorStyle,{"data-testid":"GDG-default-image-overlay-editor"},reactExports.createElement(jsExports.Carousel,{showArrows:Ft,showThumbs:!1,swipeable:Ft,emulateTouch:Ft,infiniteLoop:Ft},At.map(Ct=>{const wt=bt?.(Ct)??reactExports.createElement("img",{draggable:!1,src:Ct});return reactExports.createElement("div",{className:"gdg-centering-container",key:Ct},wt)})),xt&&vt&&reactExports.createElement("button",{className:"gdg-edit-icon",onClick:vt},reactExports.createElement(EditPencil,null)))};function L(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var T$1=L();function G(yt){T$1=yt}var E={exec:()=>null};function d$1(yt,Et=""){let xt=typeof yt=="string"?yt:yt.source,vt={replace:(bt,At)=>{let Ft=typeof At=="string"?At:At.source;return Ft=Ft.replace(m.caret,"$1"),xt=xt.replace(bt,Ft),vt},getRegex:()=>new RegExp(xt,Et)};return vt}var be=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),m={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:yt=>new RegExp(`^( {0,3}${yt})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:yt=>new RegExp(`^ {0,${Math.min(3,yt-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:yt=>new RegExp(`^ {0,${Math.min(3,yt-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:yt=>new RegExp(`^ {0,${Math.min(3,yt-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:yt=>new RegExp(`^ {0,${Math.min(3,yt-1)}}#`),htmlBeginRegex:yt=>new RegExp(`^ {0,${Math.min(3,yt-1)}}<(?:[a-z].*>|!--)`,"i")},Re=/^(?:[ \t]*(?:\n|$))+/,Te=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Oe=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,I=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,we=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,F=/(?:[*+-]|\d{1,9}[.)])/,ie=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oe=d$1(ie).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ye=d$1(ie).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),j=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Pe=/^[^\n]+/,Q=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Se=d$1(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Q).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),$e=d$1(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,F).getRegex(),v$1="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",U=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_e=d$1("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",U).replace("tag",v$1).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ae=d$1(j).replace("hr",I).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v$1).getRegex(),Le=d$1(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ae).getRegex(),K={blockquote:Le,code:Te,def:Se,fences:Oe,heading:we,hr:I,html:_e,lheading:oe,list:$e,newline:Re,paragraph:ae,table:E,text:Pe},re=d$1("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",I).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v$1).getRegex(),Me={...K,lheading:ye,table:re,paragraph:d$1(j).replace("hr",I).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",re).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v$1).getRegex()},ze={...K,html:d$1(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",U).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:E,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:d$1(j).replace("hr",I).replace("heading",` *#{1,6} *[^
2794
2794
  ]`).replace("lheading",oe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ae=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ee=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,le=/^( {2,}|\\)\n(?!\s*$)/,Ie=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,D=/[\p{P}\p{S}]/u,W=/[\s\p{P}\p{S}]/u,ue=/[^\s\p{P}\p{S}]/u,Ce=d$1(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,W).getRegex(),pe=/(?!~)[\p{P}\p{S}]/u,Be=/(?!~)[\s\p{P}\p{S}]/u,qe=/(?:[^\s\p{P}\p{S}]|~)/u,ve=d$1(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",be?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ce=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,De=d$1(ce,"u").replace(/punct/g,D).getRegex(),He=d$1(ce,"u").replace(/punct/g,pe).getRegex(),he="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ze=d$1(he,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ge=d$1(he,"gu").replace(/notPunctSpace/g,qe).replace(/punctSpace/g,Be).replace(/punct/g,pe).getRegex(),Ne=d$1("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Fe=d$1(/\\(punct)/,"gu").replace(/punct/g,D).getRegex(),je=d$1(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Qe=d$1(U).replace("(?:-->|$)","-->").getRegex(),Ue=d$1("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Qe).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Ke=d$1(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),de=d$1(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",Q).getRegex(),ke=d$1(/^!?\[(ref)\](?:\[\])?/).replace("ref",Q).getRegex(),We=d$1("reflink|nolink(?!\\()","g").replace("reflink",de).replace("nolink",ke).getRegex(),se=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,X={_backpedal:E,anyPunctuation:Fe,autolink:je,blockSkip:ve,br:le,code:Ee,del:E,emStrongLDelim:De,emStrongRDelimAst:Ze,emStrongRDelimUnd:Ne,escape:Ae,link:Ke,nolink:ke,punctuation:Ce,reflink:de,reflinkSearch:We,tag:Ue,text:Ie,url:E},Xe={...X,link:d$1(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:d$1(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},N={...X,emStrongRDelimAst:Ge,emStrongLDelim:He,url:d$1(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",se).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:d$1(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",se).getRegex()},Je={...N,br:d$1(le).replace("{2,}","*").getRegex(),text:d$1(N.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},C={normal:K,gfm:Me,pedantic:ze},M={normal:X,gfm:N,breaks:Je,pedantic:Xe},Ve={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ge=yt=>Ve[yt];function w$1(yt,Et){if(Et){if(m.escapeTest.test(yt))return yt.replace(m.escapeReplace,ge)}else if(m.escapeTestNoEncode.test(yt))return yt.replace(m.escapeReplaceNoEncode,ge);return yt}function J(yt){try{yt=encodeURI(yt).replace(m.percentDecode,"%")}catch{return null}return yt}function V(yt,Et){let xt=yt.replace(m.findPipe,(At,Ft,Ct)=>{let wt=!1,St=Ft;for(;--St>=0&&Ct[St]==="\\";)wt=!wt;return wt?"|":" |"}),vt=xt.split(m.splitPipe),bt=0;if(vt[0].trim()||vt.shift(),vt.length>0&&!vt.at(-1)?.trim()&&vt.pop(),Et)if(vt.length>Et)vt.splice(Et);else for(;vt.length<Et;)vt.push("");for(;bt<vt.length;bt++)vt[bt]=vt[bt].trim().replace(m.slashPipe,"|");return vt}function z$1(yt,Et,xt){let vt=yt.length;if(vt===0)return"";let bt=0;for(;bt<vt&&yt.charAt(vt-bt-1)===Et;)bt++;return yt.slice(0,vt-bt)}function fe(yt,Et){if(yt.indexOf(Et[1])===-1)return-1;let xt=0;for(let vt=0;vt<yt.length;vt++)if(yt[vt]==="\\")vt++;else if(yt[vt]===Et[0])xt++;else if(yt[vt]===Et[1]&&(xt--,xt<0))return vt;return xt>0?-2:-1}function me(yt,Et,xt,vt,bt){let At=Et.href,Ft=Et.title||null,Ct=yt[1].replace(bt.other.outputLinkReplace,"$1");vt.state.inLink=!0;let wt={type:yt[0].charAt(0)==="!"?"image":"link",raw:xt,href:At,title:Ft,text:Ct,tokens:vt.inlineTokens(Ct)};return vt.state.inLink=!1,wt}function Ye(yt,Et,xt){let vt=yt.match(xt.other.indentCodeCompensation);if(vt===null)return Et;let bt=vt[1];return Et.split(`
2795
2795
  `).map(At=>{let Ft=At.match(xt.other.beginningSpace);if(Ft===null)return At;let[Ct]=Ft;return Ct.length>=bt.length?At.slice(bt.length):At}).join(`
@@ -22149,7 +22149,7 @@ const NW = () => {
22149
22149
  })(u.current);
22150
22150
  let oe = window.$3Dmol;
22151
22151
  if (!oe) {
22152
- const Xe = await import("./3Dmol-BWURIyI9.js").then((ot) => ot._);
22152
+ const Xe = await import("./3Dmol-6LnWs8rI.js").then((ot) => ot._);
22153
22153
  oe = Xe.default || Xe, window.$3Dmol = oe;
22154
22154
  }
22155
22155
  if (d) {
@@ -57977,7 +57977,7 @@ const as = !1, xM = it.forwardRef(({
57977
57977
  performance.now();
57978
57978
  for (const te in Q.genesById) {
57979
57979
  const X = Q.genesById[te], G = X.originalGeneId;
57980
- G && E[G] ? X.metadata = E[G] : X.metadata = {};
57980
+ G && E[G] && (X.metadata = { ...X.metadata, ...E[G] });
57981
57981
  }
57982
57982
  if (qn && Q.proteinClusters) {
57983
57983
  Q._clusterSummary = null;
@@ -71858,7 +71858,7 @@ function zde(t, e, n, r, i) {
71858
71858
  scrollRef: m
71859
71859
  };
71860
71860
  }
71861
- const Ude = A.lazy(async () => await import("./data-grid-overlay-editor-BGJ8nj3b.js"));
71861
+ const Ude = A.lazy(async () => await import("./data-grid-overlay-editor-CRLEhkp9.js"));
71862
71862
  let $de = 0;
71863
71863
  function Hde(t) {
71864
71864
  return Ple(kB(kB(t).filter((e) => e.span !== void 0).map((e) => Yu((e.span?.[0] ?? 0) + 1, (e.span?.[1] ?? 0) + 1))));
@@ -73998,7 +73998,7 @@ function pfe(t, e, n, r, i) {
73998
73998
  height: d - 1
73999
73999
  };
74000
74000
  }
74001
- const mfe = A.lazy(async () => await import("./number-overlay-editor-8SOLFxTU.js")), yfe = {
74001
+ const mfe = A.lazy(async () => await import("./number-overlay-editor-JNkdSGLh.js")), yfe = {
74002
74002
  getAccessibilityString: (t) => t.data?.toString() ?? "",
74003
74003
  kind: dn.Number,
74004
74004
  needsHover: (t) => t.hoverEffect === !0,
@@ -1,6 +1,6 @@
1
1
  import * as ie from "react";
2
2
  import Q, { useRef as X, useState as xe, useEffect as ve, useMemo as Fe, useLayoutEffect as je } from "react";
3
- import { s as Le } from "./index-7pW9RJyb.js";
3
+ import { s as Le } from "./index-DK4ArtL_.js";
4
4
  const Me = /* @__PURE__ */ Le("div")({
5
5
  name: "NumberOverlayEditorStyle",
6
6
  class: "gdg-n15fjm3e",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hoodini-viz",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Interactive phylogenetic and genomic visualization library",
5
5
  "type": "module",
6
6
  "main": "./dist/hoodini-viz.umd.js",