@figtreejs/core 0.1.0-beta.2 → 0.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),P=require("react"),ro=require("react-dom");function io(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ea=io(P);var Qr=nn(),R=e=>tn(e,Qr),Xr=nn();R.write=e=>tn(e,Xr);var Un=nn();R.onStart=e=>tn(e,Un);var Zr=nn();R.onFrame=e=>tn(e,Zr);var Kr=nn();R.onFinish=e=>tn(e,Kr);var st=[];R.setTimeout=(e,t)=>{const n=R.now()+t,r=()=>{const a=st.findIndex(s=>s.cancel==r);~a&&st.splice(a,1),Ue-=~a?1:0},i={time:n,handler:e,cancel:r};return st.splice(Ra(n),0,i),Ue+=1,Ia(),i};var Ra=e=>~(~st.findIndex(t=>t.time>e)||~st.length);R.cancel=e=>{Un.delete(e),Zr.delete(e),Kr.delete(e),Qr.delete(e),Xr.delete(e)};R.sync=e=>{_r=!0,R.batchedUpdates(e),_r=!1};R.throttle=e=>{let t;function n(){try{e(...t)}finally{t=null}}function r(...i){t=i,R.onStart(n)}return r.handler=e,r.cancel=()=>{Un.delete(n),t=null},r};var Jr=typeof window<"u"?window.requestAnimationFrame:(()=>{});R.use=e=>Jr=e;R.now=typeof performance<"u"?()=>performance.now():Date.now;R.batchedUpdates=e=>e();R.catch=console.error;R.frameLoop="always";R.advance=()=>{R.frameLoop!=="demand"?console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"):Fa()};var De=-1,Ue=0,_r=!1;function tn(e,t){_r?(t.delete(e),e(0)):(t.add(e),Ia())}function Ia(){De<0&&(De=0,R.frameLoop!=="demand"&&Jr(La))}function ao(){De=-1}function La(){~De&&(Jr(La),R.batchedUpdates(Fa))}function Fa(){const e=De;De=R.now();const t=Ra(De);if(t&&(Da(st.splice(0,t),n=>n.handler()),Ue-=t),!Ue){ao();return}Un.flush(),Qr.flush(e?Math.min(64,De-e):16.667),Zr.flush(),Xr.flush(),Kr.flush()}function nn(){let e=new Set,t=e;return{add(n){Ue+=t==e&&!e.has(n)?1:0,e.add(n)},delete(n){return Ue-=t==e&&e.has(n)?1:0,e.delete(n)},flush(n){t.size&&(e=new Set,Ue-=t.size,Da(t,r=>r(n)&&e.add(r)),Ue+=e.size,t=e)}}}function Da(e,t){e.forEach(n=>{try{t(n)}catch(r){R.catch(r)}})}var so=Object.defineProperty,oo=(e,t)=>{for(var n in t)so(e,n,{get:t[n],enumerable:!0})},Ne={};oo(Ne,{assign:()=>co,colors:()=>Oe,createStringInterpolator:()=>ti,skipAnimation:()=>Oa,to:()=>Ua,willAdvance:()=>ni});function Nr(){}var uo=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0}),N={arr:Array.isArray,obj:e=>!!e&&e.constructor.name==="Object",fun:e=>typeof e=="function",str:e=>typeof e=="string",num:e=>typeof e=="number",und:e=>e===void 0};function Re(e,t){if(N.arr(e)){if(!N.arr(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return e===t}var O=(e,t)=>e.forEach(t);function Te(e,t,n){if(N.arr(e)){for(let r=0;r<e.length;r++)t.call(n,e[r],`${r}`);return}for(const r in e)e.hasOwnProperty(r)&&t.call(n,e[r],r)}var he=e=>N.und(e)?[]:N.arr(e)?e:[e];function Rt(e,t){if(e.size){const n=Array.from(e);e.clear(),O(n,t)}}var Et=(e,...t)=>Rt(e,n=>n(...t)),ei=()=>typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),ti,Ua,Oe=null,Oa=!1,ni=Nr,co=e=>{e.to&&(Ua=e.to),e.now&&(R.now=e.now),e.colors!==void 0&&(Oe=e.colors),e.skipAnimation!=null&&(Oa=e.skipAnimation),e.createStringInterpolator&&(ti=e.createStringInterpolator),e.requestAnimationFrame&&R.use(e.requestAnimationFrame),e.batchedUpdates&&(R.batchedUpdates=e.batchedUpdates),e.willAdvance&&(ni=e.willAdvance),e.frameLoop&&(R.frameLoop=e.frameLoop)},It=new Set,ge=[],Jn=[],wn=0,On={get idle(){return!It.size&&!ge.length},start(e){wn>e.priority?(It.add(e),R.onStart(lo)):(ja(e),R(Cr))},advance:Cr,sort(e){if(wn)R.onFrame(()=>On.sort(e));else{const t=ge.indexOf(e);~t&&(ge.splice(t,1),za(e))}},clear(){ge=[],It.clear()}};function lo(){It.forEach(ja),It.clear(),R(Cr)}function ja(e){ge.includes(e)||za(e)}function za(e){ge.splice(ho(ge,t=>t.priority>e.priority),0,e)}function Cr(e){const t=Jn;for(let n=0;n<ge.length;n++){const r=ge[n];wn=r.priority,r.idle||(ni(r),r.advance(e),r.idle||t.push(r))}return wn=0,Jn=ge,Jn.length=0,ge=t,ge.length>0}function ho(e,t){const n=e.findIndex(t);return n<0?e.length:n}var fo={transparent:0,aliceblue:4042850303,antiquewhite:4209760255,aqua:16777215,aquamarine:2147472639,azure:4043309055,beige:4126530815,bisque:4293182719,black:255,blanchedalmond:4293643775,blue:65535,blueviolet:2318131967,brown:2771004159,burlywood:3736635391,burntsienna:3934150143,cadetblue:1604231423,chartreuse:2147418367,chocolate:3530104575,coral:4286533887,cornflowerblue:1687547391,cornsilk:4294499583,crimson:3692313855,cyan:16777215,darkblue:35839,darkcyan:9145343,darkgoldenrod:3095792639,darkgray:2846468607,darkgreen:6553855,darkgrey:2846468607,darkkhaki:3182914559,darkmagenta:2332068863,darkolivegreen:1433087999,darkorange:4287365375,darkorchid:2570243327,darkred:2332033279,darksalmon:3918953215,darkseagreen:2411499519,darkslateblue:1211993087,darkslategray:793726975,darkslategrey:793726975,darkturquoise:13554175,darkviolet:2483082239,deeppink:4279538687,deepskyblue:12582911,dimgray:1768516095,dimgrey:1768516095,dodgerblue:512819199,firebrick:2988581631,floralwhite:4294635775,forestgreen:579543807,fuchsia:4278255615,gainsboro:3705462015,ghostwhite:4177068031,gold:4292280575,goldenrod:3668254975,gray:2155905279,green:8388863,greenyellow:2919182335,grey:2155905279,honeydew:4043305215,hotpink:4285117695,indianred:3445382399,indigo:1258324735,ivory:4294963455,khaki:4041641215,lavender:3873897215,lavenderblush:4293981695,lawngreen:2096890111,lemonchiffon:4294626815,lightblue:2916673279,lightcoral:4034953471,lightcyan:3774873599,lightgoldenrodyellow:4210742015,lightgray:3553874943,lightgreen:2431553791,lightgrey:3553874943,lightpink:4290167295,lightsalmon:4288707327,lightseagreen:548580095,lightskyblue:2278488831,lightslategray:2005441023,lightslategrey:2005441023,lightsteelblue:2965692159,lightyellow:4294959359,lime:16711935,limegreen:852308735,linen:4210091775,magenta:4278255615,maroon:2147483903,mediumaquamarine:1724754687,mediumblue:52735,mediumorchid:3126187007,mediumpurple:2473647103,mediumseagreen:1018393087,mediumslateblue:2070474495,mediumspringgreen:16423679,mediumturquoise:1221709055,mediumvioletred:3340076543,midnightblue:421097727,mintcream:4127193855,mistyrose:4293190143,moccasin:4293178879,navajowhite:4292783615,navy:33023,oldlace:4260751103,olive:2155872511,olivedrab:1804477439,orange:4289003775,orangered:4282712319,orchid:3664828159,palegoldenrod:4008225535,palegreen:2566625535,paleturquoise:2951671551,palevioletred:3681588223,papayawhip:4293907967,peachpuff:4292524543,peru:3448061951,pink:4290825215,plum:3718307327,powderblue:2967529215,purple:2147516671,rebeccapurple:1714657791,red:4278190335,rosybrown:3163525119,royalblue:1097458175,saddlebrown:2336560127,salmon:4202722047,sandybrown:4104413439,seagreen:780883967,seashell:4294307583,sienna:2689740287,silver:3233857791,skyblue:2278484991,slateblue:1784335871,slategray:1887473919,slategrey:1887473919,snow:4294638335,springgreen:16744447,steelblue:1182971135,tan:3535047935,teal:8421631,thistle:3636451583,tomato:4284696575,turquoise:1088475391,violet:4001558271,wheat:4125012991,white:4294967295,whitesmoke:4126537215,yellow:4294902015,yellowgreen:2597139199},_e="[-+]?\\d*\\.?\\d+",_n=_e+"%";function jn(...e){return"\\(\\s*("+e.join(")\\s*,\\s*(")+")\\s*\\)"}var mo=new RegExp("rgb"+jn(_e,_e,_e)),go=new RegExp("rgba"+jn(_e,_e,_e,_e)),yo=new RegExp("hsl"+jn(_e,_n,_n)),po=new RegExp("hsla"+jn(_e,_n,_n,_e)),xo=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,bo=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,vo=/^#([0-9a-fA-F]{6})$/,wo=/^#([0-9a-fA-F]{8})$/;function _o(e){let t;return typeof e=="number"?e>>>0===e&&e>=0&&e<=4294967295?e:null:(t=vo.exec(e))?parseInt(t[1]+"ff",16)>>>0:Oe&&Oe[e]!==void 0?Oe[e]:(t=mo.exec(e))?(nt(t[1])<<24|nt(t[2])<<16|nt(t[3])<<8|255)>>>0:(t=go.exec(e))?(nt(t[1])<<24|nt(t[2])<<16|nt(t[3])<<8|$i(t[4]))>>>0:(t=xo.exec(e))?parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+"ff",16)>>>0:(t=wo.exec(e))?parseInt(t[1],16)>>>0:(t=bo.exec(e))?parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+t[4]+t[4],16)>>>0:(t=yo.exec(e))?(Mi(Si(t[1]),un(t[2]),un(t[3]))|255)>>>0:(t=po.exec(e))?(Mi(Si(t[1]),un(t[2]),un(t[3]))|$i(t[4]))>>>0:null}function er(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Mi(e,t,n){const r=n<.5?n*(1+t):n+t-n*t,i=2*n-r,a=er(i,r,e+1/3),s=er(i,r,e),o=er(i,r,e-1/3);return Math.round(a*255)<<24|Math.round(s*255)<<16|Math.round(o*255)<<8}function nt(e){const t=parseInt(e,10);return t<0?0:t>255?255:t}function Si(e){return(parseFloat(e)%360+360)%360/360}function $i(e){const t=parseFloat(e);return t<0?0:t>1?255:Math.round(t*255)}function un(e){const t=parseFloat(e);return t<0?0:t>100?1:t/100}function ki(e){let t=_o(e);if(t===null)return e;t=t||0;const n=(t&4278190080)>>>24,r=(t&16711680)>>>16,i=(t&65280)>>>8,a=(t&255)/255;return`rgba(${n}, ${r}, ${i}, ${a})`}var Ut=(e,t,n)=>{if(N.fun(e))return e;if(N.arr(e))return Ut({range:e,output:t,extrapolate:n});if(N.str(e.output[0]))return ti(e);const r=e,i=r.output,a=r.range||[0,1],s=r.extrapolateLeft||r.extrapolate||"extend",o=r.extrapolateRight||r.extrapolate||"extend",c=r.easing||(u=>u);return u=>{const l=Co(u,a);return No(u,a[l],a[l+1],i[l],i[l+1],c,s,o,r.map)}};function No(e,t,n,r,i,a,s,o,c){let u=c?c(e):e;if(u<t){if(s==="identity")return u;s==="clamp"&&(u=t)}if(u>n){if(o==="identity")return u;o==="clamp"&&(u=n)}return r===i?r:t===n?e<=t?r:i:(t===-1/0?u=-u:n===1/0?u=u-t:u=(u-t)/(n-t),u=a(u),r===-1/0?u=-u:i===1/0?u=u+r:u=u*(i-r)+r,u)}function Co(e,t){for(var n=1;n<t.length-1&&!(t[n]>=e);++n);return n-1}var Mo={linear:e=>e},Ot=Symbol.for("FluidValue.get"),ct=Symbol.for("FluidValue.observers"),de=e=>!!(e&&e[Ot]),ae=e=>e&&e[Ot]?e[Ot]():e,Ti=e=>e[ct]||null;function So(e,t){e.eventObserved?e.eventObserved(t):e(t)}function jt(e,t){const n=e[ct];n&&n.forEach(r=>{So(r,t)})}var Ba=class{constructor(e){if(!e&&!(e=this.get))throw Error("Unknown getter");$o(this,e)}},$o=(e,t)=>Va(e,Ot,t);function xt(e,t){if(e[Ot]){let n=e[ct];n||Va(e,ct,n=new Set),n.has(t)||(n.add(t),e.observerAdded&&e.observerAdded(n.size,t))}return t}function zt(e,t){const n=e[ct];if(n&&n.has(t)){const r=n.size-1;r?n.delete(t):e[ct]=null,e.observerRemoved&&e.observerRemoved(r,t)}}var Va=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0}),pn=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,ko=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,Pi=new RegExp(`(${pn.source})(%|[a-z]+)`,"i"),To=/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi,zn=/var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/,qa=e=>{const[t,n]=Po(e);if(!t||ei())return e;const r=window.getComputedStyle(document.documentElement).getPropertyValue(t);if(r)return r.trim();if(n&&n.startsWith("--")){const i=window.getComputedStyle(document.documentElement).getPropertyValue(n);return i||e}else{if(n&&zn.test(n))return qa(n);if(n)return n}return e},Po=e=>{const t=zn.exec(e);if(!t)return[,];const[,n,r]=t;return[n,r]},tr,Ao=(e,t,n,r,i)=>`rgba(${Math.round(t)}, ${Math.round(n)}, ${Math.round(r)}, ${i})`,Ha=e=>{tr||(tr=Oe?new RegExp(`(${Object.keys(Oe).join("|")})(?!\\w)`,"g"):/^\b$/);const t=e.output.map(a=>ae(a).replace(zn,qa).replace(ko,ki).replace(tr,ki)),n=t.map(a=>a.match(pn).map(Number)),i=n[0].map((a,s)=>n.map(o=>{if(!(s in o))throw Error('The arity of each "output" value must be equal');return o[s]})).map(a=>Ut({...e,output:a}));return a=>{const s=!Pi.test(t[0])&&t.find(c=>Pi.test(c))?.replace(pn,"");let o=0;return t[0].replace(pn,()=>`${i[o++](a)}${s||""}`).replace(To,Ao)}},ri="react-spring: ",Ya=e=>{const t=e;let n=!1;if(typeof t!="function")throw new TypeError(`${ri}once requires a function parameter`);return(...r)=>{n||(t(...r),n=!0)}},Eo=Ya(console.warn);function Ro(){Eo(`${ri}The "interpolate" function is deprecated in v9 (use "to" instead)`)}var Io=Ya(console.warn);function Lo(){Io(`${ri}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`)}function Bn(e){return N.str(e)&&(e[0]=="#"||/\d/.test(e)||!ei()&&zn.test(e)||e in(Oe||{}))}var ii=ei()?P.useEffect:P.useLayoutEffect,Fo=()=>{const e=P.useRef(!1);return ii(()=>(e.current=!0,()=>{e.current=!1}),[]),e};function Wa(){const e=P.useState()[1],t=Fo();return()=>{t.current&&e(Math.random())}}var Ga=e=>P.useEffect(e,Do),Do=[];function Ai(e){const t=P.useRef(void 0);return P.useEffect(()=>{t.current=e}),t.current}var Bt=Symbol.for("Animated:node"),Uo=e=>!!e&&e[Bt]===e,Se=e=>e&&e[Bt],ai=(e,t)=>uo(e,Bt,t),Vn=e=>e&&e[Bt]&&e[Bt].getPayload(),Qa=class{constructor(){ai(this,this)}getPayload(){return this.payload||[]}},qn=class Xa extends Qa{constructor(t){super(),this._value=t,this.done=!0,this.durationProgress=0,N.num(this._value)&&(this.lastPosition=this._value)}static create(t){return new Xa(t)}getPayload(){return[this]}getValue(){return this._value}setValue(t,n){return N.num(t)&&(this.lastPosition=t,n&&(t=Math.round(t/n)*n,this.done&&(this.lastPosition=t))),this._value===t?!1:(this._value=t,!0)}reset(){const{done:t}=this;this.done=!1,N.num(this._value)&&(this.elapsedTime=0,this.durationProgress=0,this.lastPosition=this._value,t&&(this.lastVelocity=null),this.v0=null)}},Nn=class Za extends qn{constructor(t){super(0),this._string=null,this._toString=Ut({output:[t,t]})}static create(t){return new Za(t)}getValue(){const t=this._string;return t??(this._string=this._toString(this._value))}setValue(t){if(N.str(t)){if(t==this._string)return!1;this._string=t,this._value=1}else if(super.setValue(t))this._string=null;else return!1;return!0}reset(t){t&&(this._toString=Ut({output:[this.getValue(),t]})),this._value=0,super.reset()}},Cn={dependencies:null},Hn=class extends Qa{constructor(e){super(),this.source=e,this.setValue(e)}getValue(e){const t={};return Te(this.source,(n,r)=>{Uo(n)?t[r]=n.getValue(e):de(n)?t[r]=ae(n):e||(t[r]=n)}),t}setValue(e){this.source=e,this.payload=this._makePayload(e)}reset(){this.payload&&O(this.payload,e=>e.reset())}_makePayload(e){if(e){const t=new Set;return Te(e,this._addToPayload,t),Array.from(t)}}_addToPayload(e){Cn.dependencies&&de(e)&&Cn.dependencies.add(e);const t=Vn(e);t&&O(t,n=>this.add(n))}},Oo=class Ka extends Hn{constructor(t){super(t)}static create(t){return new Ka(t)}getValue(){return this.source.map(t=>t.getValue())}setValue(t){const n=this.getPayload();return t.length==n.length?n.map((r,i)=>r.setValue(t[i])).some(Boolean):(super.setValue(t.map(jo)),!0)}};function jo(e){return(Bn(e)?Nn:qn).create(e)}function Mr(e){const t=Se(e);return t?t.constructor:N.arr(e)?Oo:Bn(e)?Nn:qn}var Ei=(e,t)=>{const n=!N.fun(e)||e.prototype&&e.prototype.isReactComponent;return P.forwardRef((r,i)=>{const a=P.useRef(null),s=n&&P.useCallback(m=>{a.current=Vo(i,m)},[i]),[o,c]=Bo(r,t),u=Wa(),l=()=>{const m=a.current;if(n&&!m)return;(m?t.applyAnimatedValues(m,o.getValue(!0)):!1)===!1&&u()},h=new zo(l,c),f=P.useRef(void 0);ii(()=>(f.current=h,O(c,m=>xt(m,h)),()=>{f.current&&(O(f.current.deps,m=>zt(m,f.current)),R.cancel(f.current.update))})),P.useEffect(l,[]),Ga(()=>()=>{const m=f.current;O(m.deps,g=>zt(g,m))});const d=t.getComponentProps(o.getValue());return Ea.createElement(e,{...d,ref:s})})},zo=class{constructor(e,t){this.update=e,this.deps=t}eventObserved(e){e.type=="change"&&R.write(this.update)}};function Bo(e,t){const n=new Set;return Cn.dependencies=n,e.style&&(e={...e,style:t.createAnimatedStyle(e.style)}),e=new Hn(e),Cn.dependencies=null,[e,n]}function Vo(e,t){return e&&(N.fun(e)?e(t):e.current=t),t}var Ri=Symbol.for("AnimatedComponent"),qo=(e,{applyAnimatedValues:t=()=>!1,createAnimatedStyle:n=i=>new Hn(i),getComponentProps:r=i=>i}={})=>{const i={applyAnimatedValues:t,createAnimatedStyle:n,getComponentProps:r},a=s=>{const o=Ii(s)||"Anonymous";return N.str(s)?s=a[s]||(a[s]=Ei(s,i)):s=s[Ri]||(s[Ri]=Ei(s,i)),s.displayName=`Animated(${o})`,s};return Te(e,(s,o)=>{N.arr(e)&&(o=Ii(s)),a[o]=a(s)}),{animated:a}},Ii=e=>N.str(e)?e:e&&N.str(e.displayName)?e.displayName:N.fun(e)&&e.name||null;function He(e,...t){return N.fun(e)?e(...t):e}var Lt=(e,t)=>e===!0||!!(t&&e&&(N.fun(e)?e(t):he(e).includes(t))),Ja=(e,t)=>N.obj(e)?t&&e[t]:e,es=(e,t)=>e.default===!0?e[t]:e.default?e.default[t]:void 0,Ho=e=>e,si=(e,t=Ho)=>{let n=Yo;e.default&&e.default!==!0&&(e=e.default,n=Object.keys(e));const r={};for(const i of n){const a=t(e[i],i);N.und(a)||(r[i]=a)}return r},Yo=["config","onProps","onStart","onChange","onPause","onResume","onRest"],Wo={config:1,from:1,to:1,ref:1,loop:1,reset:1,pause:1,cancel:1,reverse:1,immediate:1,default:1,delay:1,onProps:1,onStart:1,onChange:1,onPause:1,onResume:1,onRest:1,onResolve:1,items:1,trail:1,sort:1,expires:1,initial:1,enter:1,update:1,leave:1,children:1,onDestroyed:1,keys:1,callId:1,parentId:1};function Go(e){const t={};let n=0;if(Te(e,(r,i)=>{Wo[i]||(t[i]=r,n++)}),n)return t}function ts(e){const t=Go(e);if(t){const n={to:t};return Te(e,(r,i)=>i in t||(n[i]=r)),n}return{...e}}function Vt(e){return e=ae(e),N.arr(e)?e.map(Vt):Bn(e)?Ne.createStringInterpolator({range:[0,1],output:[e,e]})(1):e}function Qo(e){for(const t in e)return!0;return!1}function Sr(e){return N.fun(e)||N.arr(e)&&N.obj(e[0])}function Xo(e,t){e.ref?.delete(e),t?.delete(e)}function Zo(e,t){t&&e.ref!==t&&(e.ref?.delete(e),t.add(e),e.ref=t)}var Ko={default:{tension:170,friction:26}},$r={...Ko.default,mass:1,damping:1,easing:Mo.linear,clamp:!1},Jo=class{constructor(){this.velocity=0,Object.assign(this,$r)}};function eu(e,t,n){n&&(n={...n},Li(n,t),t={...n,...t}),Li(e,t),Object.assign(e,t);for(const s in $r)e[s]==null&&(e[s]=$r[s]);let{frequency:r,damping:i}=e;const{mass:a}=e;return N.und(r)||(r<.01&&(r=.01),i<0&&(i=0),e.tension=Math.pow(2*Math.PI/r,2)*a,e.friction=4*Math.PI*i*a/r),e}function Li(e,t){if(!N.und(t.decay))e.duration=void 0;else{const n=!N.und(t.tension)||!N.und(t.friction);(n||!N.und(t.frequency)||!N.und(t.damping)||!N.und(t.mass))&&(e.duration=void 0,e.decay=void 0),n&&(e.frequency=void 0)}}var Fi=[],tu=class{constructor(){this.changed=!1,this.values=Fi,this.toValues=null,this.fromValues=Fi,this.config=new Jo,this.immediate=!1}};function ns(e,{key:t,props:n,defaultProps:r,state:i,actions:a}){return new Promise((s,o)=>{let c,u,l=Lt(n.cancel??r?.cancel,t);if(l)d();else{N.und(n.pause)||(i.paused=Lt(n.pause,t));let m=r?.pause;m!==!0&&(m=i.paused||Lt(m,t)),c=He(n.delay||0,t),m?(i.resumeQueue.add(f),a.pause()):(a.resume(),f())}function h(){i.resumeQueue.add(f),i.timeouts.delete(u),u.cancel(),c=u.time-R.now()}function f(){c>0&&!Ne.skipAnimation?(i.delayed=!0,u=R.setTimeout(d,c),i.pauseQueue.add(h),i.timeouts.add(u)):d()}function d(){i.delayed&&(i.delayed=!1),i.pauseQueue.delete(h),i.timeouts.delete(u),e<=(i.cancelId||0)&&(l=!0);try{a.start({...n,callId:e,cancel:l},s)}catch(m){o(m)}}})}var oi=(e,t)=>t.length==1?t[0]:t.some(n=>n.cancelled)?ot(e.get()):t.every(n=>n.noop)?rs(e.get()):ve(e.get(),t.every(n=>n.finished)),rs=e=>({value:e,noop:!0,finished:!0,cancelled:!1}),ve=(e,t,n=!1)=>({value:e,finished:t,cancelled:n}),ot=e=>({value:e,cancelled:!0,finished:!1});function is(e,t,n,r){const{callId:i,parentId:a,onRest:s}=t,{asyncTo:o,promise:c}=n;return!a&&e===o&&!t.reset?c:n.promise=(async()=>{n.asyncId=i,n.asyncTo=e;const u=si(t,(x,y)=>y==="onRest"?void 0:x);let l,h;const f=new Promise((x,y)=>(l=x,h=y)),d=x=>{const y=i<=(n.cancelId||0)&&ot(r)||i!==n.asyncId&&ve(r,!1);if(y)throw x.result=y,h(x),x},m=(x,y)=>{const b=new Di,p=new Ui;return(async()=>{if(Ne.skipAnimation)throw qt(n),p.result=ve(r,!1),h(p),p;d(b);const w=N.obj(x)?{...x}:{...y,to:x};w.parentId=i,Te(u,(k,T)=>{N.und(w[T])&&(w[T]=k)});const C=await r.start(w);return d(b),n.paused&&await new Promise(k=>{n.resumeQueue.add(k)}),C})()};let g;if(Ne.skipAnimation)return qt(n),ve(r,!1);try{let x;N.arr(e)?x=(async y=>{for(const b of y)await m(b)})(e):x=Promise.resolve(e(m,r.stop.bind(r))),await Promise.all([x.then(l),f]),g=ve(r.get(),!0,!1)}catch(x){if(x instanceof Di)g=x.result;else if(x instanceof Ui)g=x.result;else throw x}finally{i==n.asyncId&&(n.asyncId=a,n.asyncTo=a?o:void 0,n.promise=a?c:void 0)}return N.fun(s)&&R.batchedUpdates(()=>{s(g,r,r.item)}),g})()}function qt(e,t){Rt(e.timeouts,n=>n.cancel()),e.pauseQueue.clear(),e.resumeQueue.clear(),e.asyncId=e.asyncTo=e.promise=void 0,t&&(e.cancelId=t)}var Di=class extends Error{constructor(){super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.")}},Ui=class extends Error{constructor(){super("SkipAnimationSignal")}},kr=e=>e instanceof ui,nu=1,ui=class extends Ba{constructor(){super(...arguments),this.id=nu++,this._priority=0}get priority(){return this._priority}set priority(e){this._priority!=e&&(this._priority=e,this._onPriorityChange(e))}get(){const e=Se(this);return e&&e.getValue()}to(...e){return Ne.to(this,e)}interpolate(...e){return Ro(),Ne.to(this,e)}toJSON(){return this.get()}observerAdded(e){e==1&&this._attach()}observerRemoved(e){e==0&&this._detach()}_attach(){}_detach(){}_onChange(e,t=!1){jt(this,{type:"change",parent:this,value:e,idle:t})}_onPriorityChange(e){this.idle||On.sort(this),jt(this,{type:"priority",parent:this,priority:e})}},Qe=Symbol.for("SpringPhase"),as=1,Tr=2,Pr=4,nr=e=>(e[Qe]&as)>0,Le=e=>(e[Qe]&Tr)>0,Mt=e=>(e[Qe]&Pr)>0,Oi=(e,t)=>t?e[Qe]|=Tr|as:e[Qe]&=~Tr,ji=(e,t)=>t?e[Qe]|=Pr:e[Qe]&=~Pr,ss=class extends ui{constructor(e,t){if(super(),this.animation=new tu,this.defaultProps={},this._state={paused:!1,delayed:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._pendingCalls=new Set,this._lastCallId=0,this._lastToId=0,this._memoizedDuration=0,!N.und(e)||!N.und(t)){const n=N.obj(e)?{...e}:{...t,from:e};N.und(n.default)&&(n.default=!0),this.start(n)}}get idle(){return!(Le(this)||this._state.asyncTo)||Mt(this)}get goal(){return ae(this.animation.to)}get velocity(){const e=Se(this);return e instanceof qn?e.lastVelocity||0:e.getPayload().map(t=>t.lastVelocity||0)}get hasAnimated(){return nr(this)}get isAnimating(){return Le(this)}get isPaused(){return Mt(this)}get isDelayed(){return this._state.delayed}advance(e){let t=!0,n=!1;const r=this.animation;let{toValues:i}=r;const{config:a}=r,s=Vn(r.to);!s&&de(r.to)&&(i=he(ae(r.to))),r.values.forEach((u,l)=>{if(u.done)return;const h=u.constructor==Nn?1:s?s[l].lastPosition:i[l];let f=r.immediate,d=h;if(!f){if(d=u.lastPosition,a.tension<=0){u.done=!0;return}let m=u.elapsedTime+=e;const g=r.fromValues[l],x=u.v0!=null?u.v0:u.v0=N.arr(a.velocity)?a.velocity[l]:a.velocity;let y;const b=a.precision||(g==h?.005:Math.min(1,Math.abs(h-g)*.001));if(N.und(a.duration))if(a.decay){const p=a.decay===!0?.998:a.decay,w=Math.exp(-(1-p)*m);d=g+x/(1-p)*(1-w),f=Math.abs(u.lastPosition-d)<=b,y=x*w}else{y=u.lastVelocity==null?x:u.lastVelocity;const p=a.restVelocity||b/10,w=a.clamp?0:a.bounce,C=!N.und(w),k=g==h?u.v0>0:g<h;let T,L=!1;const I=1,D=Math.ceil(e/I);for(let _=0;_<D&&(T=Math.abs(y)>p,!(!T&&(f=Math.abs(h-d)<=b,f)));++_){C&&(L=d==h||d>h==k,L&&(y=-y*w,d=h));const A=-a.tension*1e-6*(d-h),M=-a.friction*.001*y,E=(A+M)/a.mass;y=y+E*I,d=d+y*I}}else{let p=1;a.duration>0&&(this._memoizedDuration!==a.duration&&(this._memoizedDuration=a.duration,u.durationProgress>0&&(u.elapsedTime=a.duration*u.durationProgress,m=u.elapsedTime+=e)),p=(a.progress||0)+m/this._memoizedDuration,p=p>1?1:p<0?0:p,u.durationProgress=p),d=g+a.easing(p)*(h-g),y=(d-u.lastPosition)/e,f=p==1}u.lastVelocity=y,Number.isNaN(d)&&(console.warn("Got NaN while animating:",this),f=!0)}s&&!s[l].done&&(f=!1),f?u.done=!0:t=!1,u.setValue(d,a.round)&&(n=!0)});const o=Se(this),c=o.getValue();if(t){const u=ae(r.to);(c!==u||n)&&!a.decay?(o.setValue(u),this._onChange(u)):n&&a.decay&&this._onChange(c),this._stop()}else n&&this._onChange(c)}set(e){return R.batchedUpdates(()=>{this._stop(),this._focus(e),this._set(e)}),this}pause(){this._update({pause:!0})}resume(){this._update({pause:!1})}finish(){if(Le(this)){const{to:e,config:t}=this.animation;R.batchedUpdates(()=>{this._onStart(),t.decay||this._set(e,!1),this._stop()})}return this}update(e){return(this.queue||(this.queue=[])).push(e),this}start(e,t){let n;return N.und(e)?(n=this.queue||[],this.queue=[]):n=[N.obj(e)?e:{...t,to:e}],Promise.all(n.map(r=>this._update(r))).then(r=>oi(this,r))}stop(e){const{to:t}=this.animation;return this._focus(this.get()),qt(this._state,e&&this._lastCallId),R.batchedUpdates(()=>this._stop(t,e)),this}reset(){this._update({reset:!0})}eventObserved(e){e.type=="change"?this._start():e.type=="priority"&&(this.priority=e.priority+1)}_prepareNode(e){const t=this.key||"";let{to:n,from:r}=e;n=N.obj(n)?n[t]:n,(n==null||Sr(n))&&(n=void 0),r=N.obj(r)?r[t]:r,r==null&&(r=void 0);const i={to:n,from:r};return nr(this)||(e.reverse&&([n,r]=[r,n]),r=ae(r),N.und(r)?Se(this)||this._set(n):this._set(r)),i}_update({...e},t){const{key:n,defaultProps:r}=this;e.default&&Object.assign(r,si(e,(s,o)=>/^on/.test(o)?Ja(s,n):s)),Bi(this,e,"onProps"),$t(this,"onProps",e,this);const i=this._prepareNode(e);if(Object.isFrozen(this))throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");const a=this._state;return ns(++this._lastCallId,{key:n,props:e,defaultProps:r,state:a,actions:{pause:()=>{Mt(this)||(ji(this,!0),Et(a.pauseQueue),$t(this,"onPause",ve(this,St(this,this.animation.to)),this))},resume:()=>{Mt(this)&&(ji(this,!1),Le(this)&&this._resume(),Et(a.resumeQueue),$t(this,"onResume",ve(this,St(this,this.animation.to)),this))},start:this._merge.bind(this,i)}}).then(s=>{if(e.loop&&s.finished&&!(t&&s.noop)){const o=os(e);if(o)return this._update(o,!0)}return s})}_merge(e,t,n){if(t.cancel)return this.stop(!0),n(ot(this));const r=!N.und(e.to),i=!N.und(e.from);if(r||i)if(t.callId>this._lastToId)this._lastToId=t.callId;else return n(ot(this));const{key:a,defaultProps:s,animation:o}=this,{to:c,from:u}=o;let{to:l=c,from:h=u}=e;i&&!r&&(!t.default||N.und(l))&&(l=h),t.reverse&&([l,h]=[h,l]);const f=!Re(h,u);f&&(o.from=h),h=ae(h);const d=!Re(l,c);d&&this._focus(l);const m=Sr(t.to),{config:g}=o,{decay:x,velocity:y}=g;(r||i)&&(g.velocity=0),t.config&&!m&&eu(g,He(t.config,a),t.config!==s.config?He(s.config,a):void 0);let b=Se(this);if(!b||N.und(l))return n(ve(this,!0));const p=N.und(t.reset)?i&&!t.default:!N.und(h)&&Lt(t.reset,a),w=p?h:this.get(),C=Vt(l),k=N.num(C)||N.arr(C)||Bn(C),T=!m&&(!k||Lt(s.immediate||t.immediate,a));if(d){const _=Mr(l);if(_!==b.constructor)if(T)b=this._set(C);else throw Error(`Cannot animate between ${b.constructor.name} and ${_.name}, as the "to" prop suggests`)}const L=b.constructor;let I=de(l),D=!1;if(!I){const _=p||!nr(this)&&f;(d||_)&&(D=Re(Vt(w),C),I=!D),(!Re(o.immediate,T)&&!T||!Re(g.decay,x)||!Re(g.velocity,y))&&(I=!0)}if(D&&Le(this)&&(o.changed&&!p?I=!0:I||this._stop(c)),!m&&((I||de(c))&&(o.values=b.getPayload(),o.toValues=de(l)?null:L==Nn?[1]:he(C)),o.immediate!=T&&(o.immediate=T,!T&&!p&&this._set(c)),I)){const{onRest:_}=o;O(iu,M=>Bi(this,t,M));const A=ve(this,St(this,c));Et(this._pendingCalls,A),this._pendingCalls.add(n),o.changed&&R.batchedUpdates(()=>{o.changed=!p,_?.(A,this),p?He(s.onRest,A):o.onStart?.(A,this)})}p&&this._set(w),m?n(is(t.to,t,this._state,this)):I?this._start():Le(this)&&!d?this._pendingCalls.add(n):n(rs(w))}_focus(e){const t=this.animation;e!==t.to&&(Ti(this)&&this._detach(),t.to=e,Ti(this)&&this._attach())}_attach(){let e=0;const{to:t}=this.animation;de(t)&&(xt(t,this),kr(t)&&(e=t.priority+1)),this.priority=e}_detach(){const{to:e}=this.animation;de(e)&&zt(e,this)}_set(e,t=!0){const n=ae(e);if(!N.und(n)){const r=Se(this);if(!r||!Re(n,r.getValue())){const i=Mr(n);!r||r.constructor!=i?ai(this,i.create(n)):r.setValue(n),r&&R.batchedUpdates(()=>{this._onChange(n,t)})}}return Se(this)}_onStart(){const e=this.animation;e.changed||(e.changed=!0,$t(this,"onStart",ve(this,St(this,e.to)),this))}_onChange(e,t){t||(this._onStart(),He(this.animation.onChange,e,this)),He(this.defaultProps.onChange,e,this),super._onChange(e,t)}_start(){const e=this.animation;Se(this).reset(ae(e.to)),e.immediate||(e.fromValues=e.values.map(t=>t.lastPosition)),Le(this)||(Oi(this,!0),Mt(this)||this._resume())}_resume(){Ne.skipAnimation?this.finish():On.start(this)}_stop(e,t){if(Le(this)){Oi(this,!1);const n=this.animation;O(n.values,i=>{i.done=!0}),n.toValues&&(n.onChange=n.onPause=n.onResume=void 0),jt(this,{type:"idle",parent:this});const r=t?ot(this.get()):ve(this.get(),St(this,e??n.to));Et(this._pendingCalls,r),n.changed&&(n.changed=!1,$t(this,"onRest",r,this))}}};function St(e,t){const n=Vt(t),r=Vt(e.get());return Re(r,n)}function os(e,t=e.loop,n=e.to){const r=He(t);if(r){const i=r!==!0&&ts(r),a=(i||e).reverse,s=!i||i.reset;return Ht({...e,loop:t,default:!1,pause:void 0,to:!a||Sr(n)?n:void 0,from:s?e.from:void 0,reset:s,...i})}}function Ht(e){const{to:t,from:n}=e=ts(e),r=new Set;return N.obj(t)&&zi(t,r),N.obj(n)&&zi(n,r),e.keys=r.size?Array.from(r):null,e}function ru(e){const t=Ht(e);return N.und(t.default)&&(t.default=si(t)),t}function zi(e,t){Te(e,(n,r)=>n!=null&&t.add(r))}var iu=["onStart","onRest","onChange","onPause","onResume"];function Bi(e,t,n){e.animation[n]=t[n]!==es(t,n)?Ja(t[n],e.key):void 0}function $t(e,t,...n){e.animation[t]?.(...n),e.defaultProps[t]?.(...n)}var au=["onStart","onChange","onRest"],su=1,ou=class{constructor(e,t){this.id=su++,this.springs={},this.queue=[],this._lastAsyncId=0,this._active=new Set,this._changed=new Set,this._started=!1,this._state={paused:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._events={onStart:new Map,onChange:new Map,onRest:new Map},this._onFrame=this._onFrame.bind(this),t&&(this._flush=t),e&&this.start({default:!0,...e})}get idle(){return!this._state.asyncTo&&Object.values(this.springs).every(e=>e.idle&&!e.isDelayed&&!e.isPaused)}get item(){return this._item}set item(e){this._item=e}get(){const e={};return this.each((t,n)=>e[n]=t.get()),e}set(e){for(const t in e){const n=e[t];N.und(n)||this.springs[t].set(n)}}update(e){return e&&this.queue.push(Ht(e)),this}start(e){let{queue:t}=this;return e?t=he(e).map(Ht):this.queue=[],this._flush?this._flush(this,t):(fs(this,t),Ar(this,t))}stop(e,t){if(e!==!!e&&(t=e),t){const n=this.springs;O(he(t),r=>n[r].stop(!!e))}else qt(this._state,this._lastAsyncId),this.each(n=>n.stop(!!e));return this}pause(e){if(N.und(e))this.start({pause:!0});else{const t=this.springs;O(he(e),n=>t[n].pause())}return this}resume(e){if(N.und(e))this.start({pause:!1});else{const t=this.springs;O(he(e),n=>t[n].resume())}return this}each(e){Te(this.springs,e)}_onFrame(){const{onStart:e,onChange:t,onRest:n}=this._events,r=this._active.size>0,i=this._changed.size>0;(r&&!this._started||i&&!this._started)&&(this._started=!0,Rt(e,([o,c])=>{c.value=this.get(),o(c,this,this._item)}));const a=!r&&this._started,s=i||a&&n.size?this.get():null;i&&t.size&&Rt(t,([o,c])=>{c.value=s,o(c,this,this._item)}),a&&(this._started=!1,Rt(n,([o,c])=>{c.value=s,o(c,this,this._item)}))}eventObserved(e){if(e.type=="change")this._changed.add(e.parent),e.idle||this._active.add(e.parent);else if(e.type=="idle")this._active.delete(e.parent);else return;R.onFrame(this._onFrame)}};function Ar(e,t){return Promise.all(t.map(n=>us(e,n))).then(n=>oi(e,n))}async function us(e,t,n){const{keys:r,to:i,from:a,loop:s,onRest:o,onResolve:c}=t,u=N.obj(t.default)&&t.default;s&&(t.loop=!1),i===!1&&(t.to=null),a===!1&&(t.from=null);const l=N.arr(i)||N.fun(i)?i:void 0;l?(t.to=void 0,t.onRest=void 0,u&&(u.onRest=void 0)):O(au,g=>{const x=t[g];if(N.fun(x)){const y=e._events[g];t[g]=({finished:b,cancelled:p})=>{const w=y.get(x);w?(b||(w.finished=!1),p&&(w.cancelled=!0)):y.set(x,{value:null,finished:b||!1,cancelled:p||!1})},u&&(u[g]=t[g])}});const h=e._state;t.pause===!h.paused?(h.paused=t.pause,Et(t.pause?h.pauseQueue:h.resumeQueue)):h.paused&&(t.pause=!0);const f=(r||Object.keys(e.springs)).map(g=>e.springs[g].start(t)),d=t.cancel===!0||es(t,"cancel")===!0;(l||d&&h.asyncId)&&f.push(ns(++e._lastAsyncId,{props:t,state:h,actions:{pause:Nr,resume:Nr,start(g,x){d?(qt(h,e._lastAsyncId),x(ot(e))):(g.onRest=o,x(is(l,g,h,e)))}}})),h.paused&&await new Promise(g=>{h.resumeQueue.add(g)});const m=oi(e,await Promise.all(f));if(s&&m.finished&&!(n&&m.noop)){const g=os(t,s,i);if(g)return fs(e,[g]),us(e,g,!0)}return c&&R.batchedUpdates(()=>c(m,e,e.item)),m}function Vi(e,t){const n={...e.springs};return t&&O(he(t),r=>{N.und(r.keys)&&(r=Ht(r)),N.obj(r.to)||(r={...r,to:void 0}),hs(n,r,i=>ls(i))}),cs(e,n),n}function cs(e,t){Te(t,(n,r)=>{e.springs[r]||(e.springs[r]=n,xt(n,e))})}function ls(e,t){const n=new ss;return n.key=e,t&&xt(n,t),n}function hs(e,t,n){t.keys&&O(t.keys,r=>{(e[r]||(e[r]=n(r)))._prepareNode(t)})}function fs(e,t){O(t,n=>{hs(e.springs,n,r=>ls(r,e))})}var uu=Ea.createContext({pause:!1,immediate:!1}),cu=()=>{const e=[],t=function(r){Lo();const i=[];return O(e,(a,s)=>{if(N.und(r))i.push(a.start());else{const o=n(r,a,s);o&&i.push(a.start(o))}}),i};t.current=e,t.add=function(r){e.includes(r)||e.push(r)},t.delete=function(r){const i=e.indexOf(r);~i&&e.splice(i,1)},t.pause=function(){return O(e,r=>r.pause(...arguments)),this},t.resume=function(){return O(e,r=>r.resume(...arguments)),this},t.set=function(r){O(e,(i,a)=>{const s=N.fun(r)?r(a,i):r;s&&i.set(s)})},t.start=function(r){const i=[];return O(e,(a,s)=>{if(N.und(r))i.push(a.start());else{const o=this._getProps(r,a,s);o&&i.push(a.start(o))}}),i},t.stop=function(){return O(e,r=>r.stop(...arguments)),this},t.update=function(r){return O(e,(i,a)=>i.update(this._getProps(r,i,a))),this};const n=function(r,i,a){return N.fun(r)?r(a,i):r};return t._getProps=n,t};function lu(e,t,n){const r=N.fun(t)&&t;r&&!n&&(n=[]);const i=P.useMemo(()=>r||arguments.length==3?cu():void 0,[]),a=P.useRef(0),s=Wa(),o=P.useMemo(()=>({ctrls:[],queue:[],flush(y,b){const p=Vi(y,b);return a.current>0&&!o.queue.length&&!Object.keys(p).some(C=>!y.springs[C])?Ar(y,b):new Promise(C=>{cs(y,p),o.queue.push(()=>{C(Ar(y,b))}),s()})}}),[]),c=P.useRef([...o.ctrls]),u=P.useRef([]),l=Ai(e)||0;P.useMemo(()=>{O(c.current.slice(e,l),y=>{Xo(y,i),y.stop(!0)}),c.current.length=e,h(l,e)},[e]),P.useMemo(()=>{h(0,Math.min(l,e))},n);function h(y,b){for(let p=y;p<b;p++){const w=c.current[p]||(c.current[p]=new ou(null,o.flush)),C=r?r(p,w):t[p];C&&(u.current[p]=ru(C))}}const f=c.current.map((y,b)=>Vi(y,u.current[b])),d=P.useContext(uu),m=Ai(d),g=d!==m&&Qo(d);ii(()=>{a.current++,o.ctrls=c.current;const{queue:y}=o;y.length&&(o.queue=[],O(y,b=>b())),O(c.current,(b,p)=>{i?.add(b),g&&b.start({default:d});const w=u.current[p];w&&(Zo(b,w.ref),b.ref?b.queue.push(w):b.start(w))})}),Ga(()=>()=>{O(o.ctrls,y=>y.stop(!0))});const x=f.map(y=>({...y}));return i?[x,i]:x}function Yn(e,t){const n=N.fun(e),[[r],i]=lu(1,n?e:[e],n?[]:t);return n||arguments.length==2?[r,i]:r}var ds=class extends ui{constructor(e,t){super(),this.source=e,this.idle=!0,this._active=new Set,this.calc=Ut(...t);const n=this._get(),r=Mr(n);ai(this,r.create(n))}advance(e){const t=this._get(),n=this.get();Re(t,n)||(Se(this).setValue(t),this._onChange(t,this.idle)),!this.idle&&qi(this._active)&&rr(this)}_get(){const e=N.arr(this.source)?this.source.map(ae):he(ae(this.source));return this.calc(...e)}_start(){this.idle&&!qi(this._active)&&(this.idle=!1,O(Vn(this),e=>{e.done=!1}),Ne.skipAnimation?(R.batchedUpdates(()=>this.advance()),rr(this)):On.start(this))}_attach(){let e=1;O(he(this.source),t=>{de(t)&&xt(t,this),kr(t)&&(t.idle||this._active.add(t),e=Math.max(e,t.priority+1))}),this.priority=e,this._start()}_detach(){O(he(this.source),e=>{de(e)&&zt(e,this)}),this._active.clear(),rr(this)}eventObserved(e){e.type=="change"?e.idle?this.advance():(this._active.add(e.parent),this._start()):e.type=="idle"?this._active.delete(e.parent):e.type=="priority"&&(this.priority=he(this.source).reduce((t,n)=>Math.max(t,(kr(n)?n.priority:0)+1),0))}};function hu(e){return e.idle!==!1}function qi(e){return!e.size||Array.from(e).every(hu)}function rr(e){e.idle||(e.idle=!0,O(Vn(e),t=>{t.done=!0}),jt(e,{type:"idle",parent:e}))}var fu=(e,...t)=>new ds(e,t);Ne.assign({createStringInterpolator:Ha,to:(e,t)=>new ds(e,t)});var ms=/^--/;function du(e,t){return t==null||typeof t=="boolean"||t===""?"":typeof t=="number"&&t!==0&&!ms.test(e)&&!(Ft.hasOwnProperty(e)&&Ft[e])?t+"px":(""+t).trim()}var Hi={};function mu(e,t){if(!e.nodeType||!e.setAttribute)return!1;const n=e.nodeName==="filter"||e.parentNode&&e.parentNode.nodeName==="filter",{className:r,style:i,children:a,scrollTop:s,scrollLeft:o,viewBox:c,...u}=t,l=Object.values(u),h=Object.keys(u).map(f=>n||e.hasAttribute(f)?f:Hi[f]||(Hi[f]=f.replace(/([A-Z])/g,d=>"-"+d.toLowerCase())));a!==void 0&&(e.textContent=a);for(const f in i)if(i.hasOwnProperty(f)){const d=du(f,i[f]);ms.test(f)?e.style.setProperty(f,d):e.style[f]=d}h.forEach((f,d)=>{e.setAttribute(f,l[d])}),r!==void 0&&(e.className=r),s!==void 0&&(e.scrollTop=s),o!==void 0&&(e.scrollLeft=o),c!==void 0&&e.setAttribute("viewBox",c)}var Ft={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},gu=(e,t)=>e+t.charAt(0).toUpperCase()+t.substring(1),yu=["Webkit","Ms","Moz","O"];Ft=Object.keys(Ft).reduce((e,t)=>(yu.forEach(n=>e[gu(n,t)]=e[t]),e),Ft);var pu=/^(matrix|translate|scale|rotate|skew)/,xu=/^(translate)/,bu=/^(rotate|skew)/,ir=(e,t)=>N.num(e)&&e!==0?e+t:e,xn=(e,t)=>N.arr(e)?e.every(n=>xn(n,t)):N.num(e)?e===t:parseFloat(e)===t,vu=class extends Hn{constructor({x:e,y:t,z:n,...r}){const i=[],a=[];(e||t||n)&&(i.push([e||0,t||0,n||0]),a.push(s=>[`translate3d(${s.map(o=>ir(o,"px")).join(",")})`,xn(s,0)])),Te(r,(s,o)=>{if(o==="transform")i.push([s||""]),a.push(c=>[c,c===""]);else if(pu.test(o)){if(delete r[o],N.und(s))return;const c=xu.test(o)?"px":bu.test(o)?"deg":"";i.push(he(s)),a.push(o==="rotate3d"?([u,l,h,f])=>[`rotate3d(${u},${l},${h},${ir(f,c)})`,xn(f,0)]:u=>[`${o}(${u.map(l=>ir(l,c)).join(",")})`,xn(u,o.startsWith("scale")?1:0)])}}),i.length&&(r.transform=new wu(i,a)),super(r)}},wu=class extends Ba{constructor(e,t){super(),this.inputs=e,this.transforms=t,this._value=null}get(){return this._value||(this._value=this._get())}_get(){let e="",t=!0;return O(this.inputs,(n,r)=>{const i=ae(n[0]),[a,s]=this.transforms[r](N.arr(i)?i:n.map(ae));e+=" "+a,t=t&&s}),t?"none":e}observerAdded(e){e==1&&O(this.inputs,t=>O(t,n=>de(n)&&xt(n,this)))}observerRemoved(e){e==0&&O(this.inputs,t=>O(t,n=>de(n)&&zt(n,this)))}eventObserved(e){e.type=="change"&&(this._value=null),jt(this,e)}},_u=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"];Ne.assign({batchedUpdates:ro.unstable_batchedUpdates,createStringInterpolator:Ha,colors:fo});var Nu=qo(_u,{applyAnimatedValues:mu,createAnimatedStyle:e=>new vu(e),getComponentProps:({scrollTop:e,scrollLeft:t,...n})=>n}),$e=Nu.animated;const Cu=["cx","cy","r","stroke","strokeWidth","fill"];function Mu(e){const t={};for(const n of Cu){const r=e[n];r!=null&&(typeof r=="number"||typeof r=="string")&&(t[n]=r)}return t}const Su=function(e){const{animated:t,x:n,y:r,...i}=e,a={...i,cx:n,cy:r},s=Mu(a),o=Yn({...s,config:{duration:500}});return t?S.jsx($e.circle,{className:"node-shape",...a,...o}):S.jsx($e.circle,{className:"node-shape",...a})},$u=["d","stroke","strokeWidth"];function ku(e){const t={};for(const n of $u){const r=e[n];r!=null&&(typeof r=="number"||typeof r=="string")&&(t[n]=r)}return t}function Wn(e){const{animated:t,...n}=e,r=ku(n),i=Yn({...r,config:{duration:500}});return t?S.jsx($e.path,{...n,...i}):S.jsx($e.path,{...n})}function Yi(e,t){return e-t/2}const Tu=["rx","ry","x","y","width","height","stroke","strokeWidth"];function Pu(e){const t={};for(const n of Tu){const r=e[n];r!=null&&(typeof r=="number"||typeof r=="string")&&(t[n]=r)}return t}const Au=function(e){const{x:t,y:n,width:r,height:i,...a}=e,s=Yi(t,r),o=Yi(n,i),c={...a,x:s,y:o,width:r,height:i};return S.jsx(ci,{...c})},ci=function(e){const{animated:t,...n}=e,r=Pu(n),i=Yn({...r,config:{duration:500}});return t?S.jsx($e.rect,{className:"node-shape",...n,...i}):S.jsx($e.rect,{className:"node-shape",...n})},ar=e=>e instanceof ss;function Wi(e,t,n){return ar(e)||ar(t)||ar(n)?fu([e,t,n],(r,i,a)=>`translate(${r},${i}) rotate(${a})`):`translate(${e},${t}) rotate(${n})`}function gs(e){const{alignmentBaseline:t,textAnchor:n,rotation:r,x:i,y:a,text:s,d:o,animated:c,...u}=e,l=Yn({x:i,y:a,rotation:r,config:{duration:500}});if(c){const h=Wi(l.x,l.y,l.rotation);return S.jsxs("g",{children:[S.jsx($e.text,{alignmentBaseline:t,textAnchor:n,transform:h,...u,children:s}),o?S.jsx($e.path,{strokeWidth:1,stroke:"grey",strokeDasharray:"2",d:o}):null]})}else{const h=Wi(i,a,r);return S.jsxs("g",{children:[S.jsx($e.text,{alignmentBaseline:t,textAnchor:n,transform:h,...u,children:s}),o?S.jsx($e.path,{strokeWidth:1,stroke:"grey",strokeDasharray:"2",d:o}):null]})}}const Eu=e=>({...e,x:0,y:0}),Ie=P.createContext(Eu),ys={width:1e3,height:1e3,rootLength:0,rootAngle:0,angleRange:2*Math.PI-.3,tipSpace:()=>1,curvature:0,showRoot:!1,spread:1,fishEye:{x:0,y:0,scale:0},cartoonedNodes:new Map,pollard:0,padding:20,invert:!1,minRadius:0};function bn(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Ru(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ps(e){let t,n,r;e.length!==2?(t=bn,n=(o,c)=>bn(e(o),c),r=(o,c)=>e(o)-c):(t=e===bn||e===Ru?e:Iu,n=e,r=e);function i(o,c,u=0,l=o.length){if(u<l){if(t(c,c)!==0)return l;do{const h=u+l>>>1;n(o[h],c)<0?u=h+1:l=h}while(u<l)}return u}function a(o,c,u=0,l=o.length){if(u<l){if(t(c,c)!==0)return l;do{const h=u+l>>>1;n(o[h],c)<=0?u=h+1:l=h}while(u<l)}return u}function s(o,c,u=0,l=o.length){const h=i(o,c,u,l-1);return h>u&&r(o[h-1],c)>-r(o[h],c)?h-1:h}return{left:i,center:s,right:a}}function Iu(){return 0}function Lu(e){return e===null?NaN:+e}const Fu=ps(bn),Du=Fu.right;ps(Lu).center;function lt(e,t){let n,r;if(t===void 0)for(const i of e)i!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)));else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}const Uu=Math.sqrt(50),Ou=Math.sqrt(10),ju=Math.sqrt(2);function Mn(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),s=a>=Uu?10:a>=Ou?5:a>=ju?2:1;let o,c,u;return i<0?(u=Math.pow(10,-i)/s,o=Math.round(e*u),c=Math.round(t*u),o/u<e&&++o,c/u>t&&--c,u=-u):(u=Math.pow(10,i)*s,o=Math.round(e/u),c=Math.round(t/u),o*u<e&&++o,c*u>t&&--c),c<o&&.5<=n&&n<2?Mn(e,t,n*2):[o,c,u]}function zu(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const r=t<e,[i,a,s]=r?Mn(t,e,n):Mn(e,t,n);if(!(a>=i))return[];const o=a-i+1,c=new Array(o);if(r)if(s<0)for(let u=0;u<o;++u)c[u]=(a-u)/-s;else for(let u=0;u<o;++u)c[u]=(a-u)*s;else if(s<0)for(let u=0;u<o;++u)c[u]=(i+u)/-s;else for(let u=0;u<o;++u)c[u]=(i+u)*s;return c}function Er(e,t,n){return t=+t,e=+e,n=+n,Mn(e,t,n)[2]}function Bu(e,t,n){t=+t,e=+e,n=+n;const r=t<e,i=r?Er(t,e,n):Er(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function Vu(e,t){let n,r=-1,i=-1;if(t===void 0)for(const a of e)++i,a!=null&&(n<a||n===void 0&&a>=a)&&(n=a,r=i);else for(let a of e)(a=t(a,++i,e))!=null&&(n<a||n===void 0&&a>=a)&&(n=a,r=i);return r}function li(e,t){let n=0,r=0;if(t===void 0)for(let i of e)i!=null&&(i=+i)>=i&&(++n,r+=i);else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(a=+a)>=a&&(++n,r+=a)}if(n)return r/n}var V=(e=>(e.DISCRETE="DISCRETE",e.BOOLEAN="BOOLEAN",e.NUMERICAL="NUMERICAL",e.NUMERICAL_SET="NUMERICAL_SET",e.DISCRETE_SET="DISCRETE_SET",e.MARKOV_JUMPS="MARKOV_JUMPS",e.DENSITIES="DENSITIES",e))(V||{});function qu(e){const t=e.split(/\s*('[^']+'|"[^"]+"|;|\(|\)|,|:|=|\[&|\]|\{|\})\s*/).filter(u=>u.length>0);let n=!0,r="",i=!1,a=!1,s=[],o;const c={};if(t[0]!=="[&"||t[t.length-1]!=="]")throw new Error("expecting a [& at the start and ] at the end of the annotation");for(const u of t)if(u==="[&")n=!0;else if(u==="=")n=!1;else if(u===","){if(i)continue;if(n=!0,o===void 0)throw new Error("Empty annotation value");c[r]=o}else if(u==="{")i?(a=!0,s=[]):o=[],i=!0;else if(u==="}")a?(a=!1,o.push(s)):i=!1;else if(u==="]"){if(o===void 0)throw new Error("Empty annotation value");c[r]=o}else{let l=u;(l.startsWith('"')||l.startsWith("'"))&&(l=l.slice(1)),(l.endsWith('"')||l.endsWith("'"))&&(l=l.slice(0,-1)),n?r=l.replace(".","_"):i?a?s.push(l):o.push(l):isNaN(l)?o=l:o=parseFloat(l)}return c}function Hu(e){if(Array.isArray(e)){if(Array.isArray(e[0])){const i=e;if(i.map(a=>a.length===3).reduce((a,s)=>a&&s,!0)){const a=i.map(([s,o,c])=>{const u=Number(s);if(!Number.isFinite(u))throw new Error(`Expected a markov jump annotation but the first entry ${s} could not be make a number`);return{time:u,from:o,to:c}});return{type:V.MARKOV_JUMPS,value:a}}else throw Error(`Markov jump with dimension ${i[0].length} detected. Expected 3. ${i.map(a=>a.length).join(",")}`)}const t=e,n=t.every(i=>typeof i=="string");if(t.every(i=>Number.isFinite(Number(i)))){const i=t.map(a=>Number(a));return{type:V.NUMERICAL_SET,value:i}}return n?{type:V.DISCRETE_SET,value:t.slice()}:{type:V.DISCRETE_SET,value:t.map(String)}}else if(Yu(e)){const n=Object.entries(e),r=n.every(([,a])=>Number.isFinite(Number(a))),i=n.every(([,a])=>typeof a=="boolean");if(r){const a={};for(const[s,o]of n){const c=Number(o);a[s]=c}return{type:V.DENSITIES,value:a}}if(i){const a=n.filter(([,s])=>s===!0).map(([s])=>s).sort();return{type:V.DISCRETE_SET,value:a}}throw new Error("Unsupported object value: expected numeric (probabilities) or boolean map")}else{if(typeof e=="boolean")return{type:V.BOOLEAN,value:e};if(typeof e=="number")return{type:V.NUMERICAL,value:e};if(typeof e=="string"){const t=e.toLowerCase();if(t==="true"||t==="false")return{type:V.BOOLEAN,value:t==="true"};const n=Number(e);return Number.isFinite(n)?{type:V.NUMERICAL,value:n}:{type:V.DISCRETE,value:e}}}throw new Error(`Unsupported annotation value: ${String(e)}`)}function Yu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wu(e){switch(e.type){case V.DISCRETE:return e.value;case V.BOOLEAN:return String(e.value);case V.NUMERICAL:return String(e.value);case V.NUMERICAL_SET:return"{"+e.value.map(t=>String(t)).join(", ")+"}";case V.DISCRETE_SET:return"{"+e.value.join(", ")+"}";case V.MARKOV_JUMPS:return"{"+e.value.map(t=>`{${String(t.time)},${t.from},${t.to}}`).join(", ")+"}";case V.DENSITIES:throw new Error(`No defined why to write densities (${e.id}) as a string.
2
- Please convert keys and values to separate array annotations.`)}}var B=(e=>(e.Some="some",e.Nothing="nothing",e))(B||{});const Pe=()=>({type:"nothing"}),Gn=e=>({type:"some",value:e}),Gi=(e,t)=>{switch(e.type){case"some":return e.value;case"nothing":throw new Error(t)}};function Z(e,t){if(e===void 0)throw new Error(t)}function pe(e,t){if(e===null)throw new Error(t);return e}const sr=new Date,or=new Date;function Ae(e,t,n,r){function i(a){return e(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(e(a=new Date(+a)),a),i.ceil=a=>(e(a=new Date(a-1)),t(a,1),e(a),a),i.round=a=>{const s=i(a),o=i.ceil(a);return a-s<o-a?s:o},i.offset=(a,s)=>(t(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,o)=>{const c=[];if(a=i.ceil(a),o=o==null?1:Math.floor(o),!(a<s)||!(o>0))return c;let u;do c.push(u=new Date(+a)),t(a,o),e(a);while(u<a&&a<s);return c},i.filter=a=>Ae(s=>{if(s>=s)for(;e(s),!a(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;t(s,-1),!a(s););else for(;--o>=0;)for(;t(s,1),!a(s););}),n&&(i.count=(a,s)=>(sr.setTime(+a),or.setTime(+s),e(sr),e(or),Math.floor(n(sr,or))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?s=>r(s)%a===0:s=>i.count(0,s)%a===0):i)),i}const Gu=1e3,hi=Gu*60,Qu=hi*60,Yt=Qu*24,xs=Yt*7,fi=Ae(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*hi)/Yt,e=>e.getDate()-1);fi.range;const di=Ae(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Yt,e=>e.getUTCDate()-1);di.range;const Xu=Ae(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Yt,e=>Math.floor(e/Yt));Xu.range;function et(e){return Ae(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*hi)/xs)}const bs=et(0),Sn=et(1),Zu=et(2),Ku=et(3),ht=et(4),Ju=et(5),ec=et(6);bs.range;Sn.range;Zu.range;Ku.range;ht.range;Ju.range;ec.range;function tt(e){return Ae(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/xs)}const vs=tt(0),$n=tt(1),tc=tt(2),nc=tt(3),ft=tt(4),rc=tt(5),ic=tt(6);vs.range;$n.range;tc.range;nc.range;ft.range;rc.range;ic.range;const Xe=Ae(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Xe.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ae(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});Xe.range;const Ze=Ae(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Ze.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ae(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});Ze.range;function ur(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function cr(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function kt(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function ac(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,s=e.shortDays,o=e.months,c=e.shortMonths,u=Tt(i),l=Pt(i),h=Tt(a),f=Pt(a),d=Tt(s),m=Pt(s),g=Tt(o),x=Pt(o),y=Tt(c),b=Pt(c),p={a:z,A:W,b:G,B:xe,c:null,d:ea,e:ea,f:kc,g:Uc,G:jc,H:Mc,I:Sc,j:$c,L:ws,m:Tc,M:Pc,p:Ce,q:te,Q:ra,s:ia,S:Ac,u:Ec,U:Rc,V:Ic,w:Lc,W:Fc,x:null,X:null,y:Dc,Y:Oc,Z:zc,"%":na},w={a:je,A:wt,b:be,B:_t,c:null,d:ta,e:ta,f:Hc,g:tl,G:rl,H:Bc,I:Vc,j:qc,L:Ns,m:Yc,M:Wc,p:Nt,q:Ct,Q:ra,s:ia,S:Gc,u:Qc,U:Xc,V:Zc,w:Kc,W:Jc,x:null,X:null,y:el,Y:nl,Z:il,"%":na},C={a:D,A:_,b:A,B:M,c:E,d:Ki,e:Ki,f:wc,g:Zi,G:Xi,H:Ji,I:Ji,j:pc,L:vc,m:yc,M:xc,p:I,q:gc,Q:Nc,s:Cc,S:bc,u:lc,U:hc,V:fc,w:cc,W:dc,x:K,X:Y,y:Zi,Y:Xi,Z:mc,"%":_c};p.x=k(n,p),p.X=k(r,p),p.c=k(t,p),w.x=k(n,w),w.X=k(r,w),w.c=k(t,w);function k($,F){return function(U){var v=[],ne=-1,q=0,ue=$.length,ce,ze,Ci;for(U instanceof Date||(U=new Date(+U));++ne<ue;)$.charCodeAt(ne)===37&&(v.push($.slice(q,ne)),(ze=Qi[ce=$.charAt(++ne)])!=null?ce=$.charAt(++ne):ze=ce==="e"?" ":"0",(Ci=F[ce])&&(ce=Ci(U,ze)),v.push(ce),q=ne+1);return v.push($.slice(q,ne)),v.join("")}}function T($,F){return function(U){var v=kt(1900,void 0,1),ne=L(v,$,U+="",0),q,ue;if(ne!=U.length)return null;if("Q"in v)return new Date(v.Q);if("s"in v)return new Date(v.s*1e3+("L"in v?v.L:0));if(F&&!("Z"in v)&&(v.Z=0),"p"in v&&(v.H=v.H%12+v.p*12),v.m===void 0&&(v.m="q"in v?v.q:0),"V"in v){if(v.V<1||v.V>53)return null;"w"in v||(v.w=1),"Z"in v?(q=cr(kt(v.y,0,1)),ue=q.getUTCDay(),q=ue>4||ue===0?$n.ceil(q):$n(q),q=di.offset(q,(v.V-1)*7),v.y=q.getUTCFullYear(),v.m=q.getUTCMonth(),v.d=q.getUTCDate()+(v.w+6)%7):(q=ur(kt(v.y,0,1)),ue=q.getDay(),q=ue>4||ue===0?Sn.ceil(q):Sn(q),q=fi.offset(q,(v.V-1)*7),v.y=q.getFullYear(),v.m=q.getMonth(),v.d=q.getDate()+(v.w+6)%7)}else("W"in v||"U"in v)&&("w"in v||(v.w="u"in v?v.u%7:"W"in v?1:0),ue="Z"in v?cr(kt(v.y,0,1)).getUTCDay():ur(kt(v.y,0,1)).getDay(),v.m=0,v.d="W"in v?(v.w+6)%7+v.W*7-(ue+5)%7:v.w+v.U*7-(ue+6)%7);return"Z"in v?(v.H+=v.Z/100|0,v.M+=v.Z%100,cr(v)):ur(v)}}function L($,F,U,v){for(var ne=0,q=F.length,ue=U.length,ce,ze;ne<q;){if(v>=ue)return-1;if(ce=F.charCodeAt(ne++),ce===37){if(ce=F.charAt(ne++),ze=C[ce in Qi?F.charAt(ne++):ce],!ze||(v=ze($,U,v))<0)return-1}else if(ce!=U.charCodeAt(v++))return-1}return v}function I($,F,U){var v=u.exec(F.slice(U));return v?($.p=l.get(v[0].toLowerCase()),U+v[0].length):-1}function D($,F,U){var v=d.exec(F.slice(U));return v?($.w=m.get(v[0].toLowerCase()),U+v[0].length):-1}function _($,F,U){var v=h.exec(F.slice(U));return v?($.w=f.get(v[0].toLowerCase()),U+v[0].length):-1}function A($,F,U){var v=y.exec(F.slice(U));return v?($.m=b.get(v[0].toLowerCase()),U+v[0].length):-1}function M($,F,U){var v=g.exec(F.slice(U));return v?($.m=x.get(v[0].toLowerCase()),U+v[0].length):-1}function E($,F,U){return L($,t,F,U)}function K($,F,U){return L($,n,F,U)}function Y($,F,U){return L($,r,F,U)}function z($){return s[$.getDay()]}function W($){return a[$.getDay()]}function G($){return c[$.getMonth()]}function xe($){return o[$.getMonth()]}function Ce($){return i[+($.getHours()>=12)]}function te($){return 1+~~($.getMonth()/3)}function je($){return s[$.getUTCDay()]}function wt($){return a[$.getUTCDay()]}function be($){return c[$.getUTCMonth()]}function _t($){return o[$.getUTCMonth()]}function Nt($){return i[+($.getUTCHours()>=12)]}function Ct($){return 1+~~($.getUTCMonth()/3)}return{format:function($){var F=k($+="",p);return F.toString=function(){return $},F},parse:function($){var F=T($+="",!1);return F.toString=function(){return $},F},utcFormat:function($){var F=k($+="",w);return F.toString=function(){return $},F},utcParse:function($){var F=T($+="",!0);return F.toString=function(){return $},F}}}var Qi={"-":"",_:" ",0:"0"},Q=/^\s*\d+/,sc=/^%/,oc=/[\\^$*+?|[\]().{}]/g;function j(e,t,n){var r=e<0?"-":"",i=(r?-e:e)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(t)+i:i)}function uc(e){return e.replace(oc,"\\$&")}function Tt(e){return new RegExp("^(?:"+e.map(uc).join("|")+")","i")}function Pt(e){return new Map(e.map((t,n)=>[t.toLowerCase(),n]))}function cc(e,t,n){var r=Q.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function lc(e,t,n){var r=Q.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function hc(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function fc(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function dc(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function Xi(e,t,n){var r=Q.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function Zi(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function mc(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function gc(e,t,n){var r=Q.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function yc(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function Ki(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function pc(e,t,n){var r=Q.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function Ji(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function xc(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function bc(e,t,n){var r=Q.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function vc(e,t,n){var r=Q.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function wc(e,t,n){var r=Q.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function _c(e,t,n){var r=sc.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Nc(e,t,n){var r=Q.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function Cc(e,t,n){var r=Q.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function ea(e,t){return j(e.getDate(),t,2)}function Mc(e,t){return j(e.getHours(),t,2)}function Sc(e,t){return j(e.getHours()%12||12,t,2)}function $c(e,t){return j(1+fi.count(Xe(e),e),t,3)}function ws(e,t){return j(e.getMilliseconds(),t,3)}function kc(e,t){return ws(e,t)+"000"}function Tc(e,t){return j(e.getMonth()+1,t,2)}function Pc(e,t){return j(e.getMinutes(),t,2)}function Ac(e,t){return j(e.getSeconds(),t,2)}function Ec(e){var t=e.getDay();return t===0?7:t}function Rc(e,t){return j(bs.count(Xe(e)-1,e),t,2)}function _s(e){var t=e.getDay();return t>=4||t===0?ht(e):ht.ceil(e)}function Ic(e,t){return e=_s(e),j(ht.count(Xe(e),e)+(Xe(e).getDay()===4),t,2)}function Lc(e){return e.getDay()}function Fc(e,t){return j(Sn.count(Xe(e)-1,e),t,2)}function Dc(e,t){return j(e.getFullYear()%100,t,2)}function Uc(e,t){return e=_s(e),j(e.getFullYear()%100,t,2)}function Oc(e,t){return j(e.getFullYear()%1e4,t,4)}function jc(e,t){var n=e.getDay();return e=n>=4||n===0?ht(e):ht.ceil(e),j(e.getFullYear()%1e4,t,4)}function zc(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+j(t/60|0,"0",2)+j(t%60,"0",2)}function ta(e,t){return j(e.getUTCDate(),t,2)}function Bc(e,t){return j(e.getUTCHours(),t,2)}function Vc(e,t){return j(e.getUTCHours()%12||12,t,2)}function qc(e,t){return j(1+di.count(Ze(e),e),t,3)}function Ns(e,t){return j(e.getUTCMilliseconds(),t,3)}function Hc(e,t){return Ns(e,t)+"000"}function Yc(e,t){return j(e.getUTCMonth()+1,t,2)}function Wc(e,t){return j(e.getUTCMinutes(),t,2)}function Gc(e,t){return j(e.getUTCSeconds(),t,2)}function Qc(e){var t=e.getUTCDay();return t===0?7:t}function Xc(e,t){return j(vs.count(Ze(e)-1,e),t,2)}function Cs(e){var t=e.getUTCDay();return t>=4||t===0?ft(e):ft.ceil(e)}function Zc(e,t){return e=Cs(e),j(ft.count(Ze(e),e)+(Ze(e).getUTCDay()===4),t,2)}function Kc(e){return e.getUTCDay()}function Jc(e,t){return j($n.count(Ze(e)-1,e),t,2)}function el(e,t){return j(e.getUTCFullYear()%100,t,2)}function tl(e,t){return e=Cs(e),j(e.getUTCFullYear()%100,t,2)}function nl(e,t){return j(e.getUTCFullYear()%1e4,t,4)}function rl(e,t){var n=e.getUTCDay();return e=n>=4||n===0?ft(e):ft.ceil(e),j(e.getUTCFullYear()%1e4,t,4)}function il(){return"+0000"}function na(){return"%"}function ra(e){return+e}function ia(e){return Math.floor(+e/1e3)}var rt,Rr,Ms;al({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function al(e){return rt=ac(e),Rr=rt.format,Ms=rt.parse,rt.utcFormat,rt.utcParse,rt}function mi(e){return e%4===0&&e%100!==0||e%400===0}function sl(e){const t=Math.trunc(e),n=mi(t)?366:365,r=Math.round((e-t)*n),i=Ms("%Y-%j")(`${t}-${r}`);return pe(i,`Could not convert ${e} to date tried (year:${t} - day: ${r})`)}function ol(e){const t=parseInt(Rr("%Y")(e)),n=parseInt(Rr("%j")(e)),r=mi(t)?366:365;return t+n/r}function Ss(e,t){let n;if(t instanceof Object){if(t.type===B.Nothing)return t;n=t.value}else n=t;const r=e.allNames[n];return r===void 0?Pe():Gn(r)}function Wt(e,t){let n;if(t instanceof Object){if(t.type===B.Nothing)return t;n=t.value}else n=t;const r=e.byName[n];return r===void 0?Pe():Gn(r)}function ul(e,t){return{name:e,number:t,annotations:{}}}class rn{_data;constructor(t){this._data=t||{allNames:[],byName:{},finalized:!1}}lockTaxa(){return this._data.finalized||(this._data.finalized=!0),this}addTaxon(t){if(this._data.finalized)throw new Error("Cannot add taxon to finalized set");let n;if(typeof t=="string"){const r=t;if(Object.prototype.hasOwnProperty.call(this._data.byName,r))throw new Error(`taxon ${r} already exists in the set. Names must be unique`);n=ul(r,this._data.allNames.length)}else{if(n=t,Object.prototype.hasOwnProperty.call(this._data.byName,n.name))throw new Error(`taxon ${n.name} already exists in the set. Names must be unique`);if(this._data.allNames[n.number]&&this._data.allNames[n.number]!==n.name)throw new Error(`taxon number ${n.number} already exists in the set with name ${this._data.allNames[n.number]}. Taxon numbers must be unique`);console.log("Adding existing taxon:",n.name)}return this._data.allNames[n.number]=n.name,this._data.byName[n.name]=n,this}getTaxon(t){const n=Wt(this._data,Ss(this._data,t));switch(n.type){case B.Some:return n.value;case B.Nothing:throw new Error(`Taxon by name ${t} not found`)}}getTaxonByName(t){const n=Wt(this._data,t);switch(n.type){case B.Some:return n.value;case B.Nothing:throw new Error(`Taxon by name ${t} not found`)}}hasTaxon(t){return Object.prototype.hasOwnProperty.call(this._data.byName,t)}getTaxonCount(){return this._data.allNames.length}get isFinalized(){return this._data.finalized}}class $s{done;started;level;currentNode;nodeStack;labelNext;lengthNext;taxonSet;tree;options;constructor(t=new rn,n={}){this.done=!1,this.started=!1,this.level=0,this.currentNode=void 0,this.nodeStack=[],this.labelNext=!1,this.lengthNext=!1,this.taxonSet=t,this.options=n,this.tree=new bi({taxonSet:this.taxonSet})}isDone(){return this.done}isStarted(){return this.started}getTree(){if(!this.done)throw new Error("expecting a semi-colon at the end of the newick string");if(!this.started)throw new Error("No tree to give - parsing has not started.");return this.tree}parseCharacter(t){if(this.done)throw new Error("Parsing is done. We have seen a ';'");if(t.length>2&&t.substring(0,2)==="[&"){const n=qu(t);Z(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.annotateNode(this.currentNode,n)}else if(t===";"){if(this.level>0)throw new Error("unexpected semi-colon in tree did not reach the root yet");if(!this.started)throw new Error("unexpected semi-colon in tree parsing has not started yet");this.done=!0}else if(t==="("){if(this.started=!0,this.labelNext)throw new Error("expecting a comma");let n;if(this.level+=1,this.currentNode!==void 0){const r=this.tree.addNodes(1);this.tree=r.tree,n=r.nodes[0],this.nodeStack.push(this.currentNode)}else n=this.tree.getRoot();this.currentNode=n}else if(t===","){if(this.labelNext=!1,this.lengthNext)throw new Error("branch length missing");const n=this.nodeStack.pop();Z(n,"Internal Parsing error - node stack unexpectedly empty"),Z(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.addChild(n,this.currentNode),this.currentNode=n}else if(t===")"){if(this.level===0)throw new Error("the brackets in the newick file are not balanced: too many closed");if(this.labelNext=!1,this.lengthNext)throw new Error("branch length missing");const n=this.nodeStack.pop();Z(n,"Internal Parsing error - node stack unexpectedly empty"),Z(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.addChild(n,this.currentNode),this.level-=1,this.currentNode=n,this.labelNext=!0}else if(t===":")this.labelNext=!1,this.lengthNext=!0;else if(this.lengthNext)Z(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.setLength(this.currentNode,parseFloat(t)),this.lengthNext=!1;else if(this.labelNext){if(t.startsWith("#"))Z(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.setLabel(this.currentNode,t.slice(1));else{let n=parseFloat(t);isNaN(n)&&(n=t),this.options.labelName?(Z(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.annotateNode(this.currentNode,this.options.labelName,n)):console.warn(`No label name provided to newick parser but found label ${t}. It will be ignored`)}this.labelNext=!1}else{let n=t;(n.startsWith('"')||n.startsWith("'"))&&(n=n.slice(1)),(n.endsWith('"')||n.endsWith("'"))&&(n=n.slice(0,-1)),n=n.trim();const r=this.tree.addNodes(1);this.tree=r.tree;const i=r.nodes[0];let a;if(this.options.translateTaxonNames)if(this.options.translateTaxonNames.has(n))n=pe(this.options.translateTaxonNames.get(n),`${n} not found in taxon translation map`);else throw new Error(`No mapping found for ${n} in tipNameMap. It's name will not be updated`);if(this.taxonSet.isFinalized){if(!this.taxonSet.hasTaxon(n))throw new Error(`Taxon ${n} not found in taxa - but found in tree`);a=this.taxonSet.getTaxonByName(n)}else this.taxonSet.addTaxon(n),a=this.taxonSet.getTaxonByName(n);this.tree=this.tree.setTaxon(i,a),this.currentNode&&this.nodeStack.push(this.currentNode),this.currentNode=i}}}function Ir(e,t={}){const n=t.taxonSet?t.taxonSet:new rn,r=e.split(/\s*('[^']+'|"[^"]+"|\[&[^[]+]|,|:|\)|\(|;)\s*/).filter(s=>s.length>0),i=new $s(n,t);for(const s of r)i.parseCharacter(s);return i.getTree()}function cl(e,t={}){const n=e.split(/\s*(?:\bBegin\s+|\bbegin\s+|\bBEGIN\s+|\bend\s*;|\bEnd\s*;|\bEND\s*;)\s*/).filter(i=>i!=="");if(n.length===0||n===void 0)throw new Error("No nexus tokens found in string. This may not be a nexus formated tree");if(n.shift().trim().toLowerCase()!=="#nexus")throw Error("File does not begin with #NEXUS is it a nexus file?");for(const i of n){const a=i.replace(/^\s+|\s+$/g,"").split(/\n/);if(a.shift().toLowerCase().trim()==="trees;"){let o=!1;const c=new Map;for(const u of a)if(u.trim().toLowerCase()==="translate")o=!0;else if(o)if(u.trim()===";")o=!1;else{const l=u.trim().replace(",","").split(/\s*\s\s*/);c.set(l[0],l[1])}else{const l=u.substring(u.indexOf("("));return c.size>0?Ir(l,{parseAnnotations:!0,...t,tipNameMap:c}):Ir(l,{parseAnnotations:!0,...t,tipNameMap:c})}}}throw new Error("No tree section found in nexus file")}var ks=Symbol.for("immer-nothing"),Lr=Symbol.for("immer-draftable"),fe=Symbol.for("immer-state"),ll=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function se(e,...t){if(process.env.NODE_ENV!=="production"){const n=ll[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var dt=Object.getPrototypeOf;function mt(e){return!!e&&!!e[fe]}function Ke(e){return e?Ts(e)||Array.isArray(e)||!!e[Lr]||!!e.constructor?.[Lr]||an(e)||Xn(e):!1}var hl=Object.prototype.constructor.toString();function Ts(e){if(!e||typeof e!="object")return!1;const t=dt(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===hl}function kn(e,t){Qn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Qn(e){const t=e[fe];return t?t.type_:Array.isArray(e)?1:an(e)?2:Xn(e)?3:0}function Fr(e,t){return Qn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ps(e,t,n){const r=Qn(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function fl(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function an(e){return e instanceof Map}function Xn(e){return e instanceof Set}function Ve(e){return e.copy_||e.base_}function Dr(e,t){if(an(e))return new Map(e);if(Xn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Ts(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[fe];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[s]})}return Object.create(dt(e),r)}else{const r=dt(e);if(r!==null&&n)return{...e};const i=Object.create(r);return Object.assign(i,e)}}function gi(e,t=!1){return Zn(e)||mt(e)||!Ke(e)||(Qn(e)>1&&Object.defineProperties(e,{set:{value:cn},add:{value:cn},clear:{value:cn},delete:{value:cn}}),Object.freeze(e),t&&Object.values(e).forEach(n=>gi(n,!0))),e}function cn(){se(2)}function Zn(e){return Object.isFrozen(e)}var dl={};function Je(e){const t=dl[e];return t||se(0,e),t}var Gt;function As(){return Gt}function ml(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function aa(e,t){t&&(Je("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ur(e){Or(e),e.drafts_.forEach(gl),e.drafts_=null}function Or(e){e===Gt&&(Gt=e.parent_)}function sa(e){return Gt=ml(Gt,e)}function gl(e){const t=e[fe];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function oa(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[fe].modified_&&(Ur(t),se(4)),Ke(e)&&(e=Tn(t,e),t.parent_||Pn(t,e)),t.patches_&&Je("Patches").generateReplacementPatches_(n[fe].base_,e,t.patches_,t.inversePatches_)):e=Tn(t,n,[]),Ur(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ks?e:void 0}function Tn(e,t,n){if(Zn(t))return t;const r=t[fe];if(!r)return kn(t,(i,a)=>ua(e,r,t,i,a,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return Pn(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let a=i,s=!1;r.type_===3&&(a=new Set(i),i.clear(),s=!0),kn(a,(o,c)=>ua(e,r,i,o,c,n,s)),Pn(e,i,!1),n&&e.patches_&&Je("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function ua(e,t,n,r,i,a,s){if(process.env.NODE_ENV!=="production"&&i===n&&se(5),mt(i)){const o=a&&t&&t.type_!==3&&!Fr(t.assigned_,r)?a.concat(r):void 0,c=Tn(e,i,o);if(Ps(n,r,c),mt(c))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(Ke(i)&&!Zn(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Tn(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(an(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Pn(e,i)}}function Pn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&gi(t,n)}function yl(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:As(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=yi;n&&(i=[r],a=Qt);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var yi={get(e,t){if(t===fe)return e;const n=Ve(e);if(!Fr(n,t))return pl(e,n,t);const r=n[t];return e.finalized_||!Ke(r)?r:r===lr(e.base_,t)?(hr(e),e.copy_[t]=zr(r,e)):r},has(e,t){return t in Ve(e)},ownKeys(e){return Reflect.ownKeys(Ve(e))},set(e,t,n){const r=Es(Ve(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=lr(Ve(e),t),a=i?.[fe];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(fl(n,i)&&(n!==void 0||Fr(e.base_,t)))return!0;hr(e),jr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return lr(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,hr(e),jr(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ve(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){se(11)},getPrototypeOf(e){return dt(e.base_)},setPrototypeOf(){se(12)}},Qt={};kn(yi,(e,t)=>{Qt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Qt.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&se(13),Qt.set.call(this,e,t,void 0)};Qt.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&se(14),yi.set.call(this,e[0],t,n,e[0])};function lr(e,t){const n=e[fe];return(n?Ve(n):e)[t]}function pl(e,t,n){const r=Es(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}function Es(e,t){if(!(t in e))return;let n=dt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=dt(n)}}function jr(e){e.modified_||(e.modified_=!0,e.parent_&&jr(e.parent_))}function hr(e){e.copy_||(e.copy_=Dr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var xl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const a=n;n=t;const s=this;return function(c=a,...u){return s.produce(c,l=>n.call(this,l,...u))}}typeof n!="function"&&se(6),r!==void 0&&typeof r!="function"&&se(7);let i;if(Ke(t)){const a=sa(this),s=zr(t,void 0);let o=!0;try{i=n(s),o=!1}finally{o?Ur(a):Or(a)}return aa(a,r),oa(i,a)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===ks&&(i=void 0),this.autoFreeze_&&gi(i,!0),r){const a=[],s=[];Je("Patches").generateReplacementPatches_(t,i,a,s),r(a,s)}return i}else se(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...o)=>this.produceWithPatches(s,c=>t(c,...o));let r,i;return[this.produce(t,n,(s,o)=>{r=s,i=o}),r,i]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Ke(e)||se(8),mt(e)&&(e=bl(e));const t=sa(this),n=zr(e,void 0);return n[fe].isManual_=!0,Or(t),n}finishDraft(e,t){const n=e&&e[fe];(!n||!n.isManual_)&&se(9);const{scope_:r}=n;return aa(r,t),oa(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Je("Patches").applyPatches_;return mt(e)?r(e,t):this.produce(e,i=>r(i,t))}};function zr(e,t){const n=an(e)?Je("MapSet").proxyMap_(e,t):Xn(e)?Je("MapSet").proxySet_(e,t):yl(e,t);return(t?t.scope_:As()).drafts_.push(n),n}function bl(e){return mt(e)||se(10,e),Rs(e)}function Rs(e){if(!Ke(e)||Zn(e))return e;const t=e[fe];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Dr(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Dr(e,!0);return kn(n,(r,i)=>{Ps(n,r,Rs(i))}),t&&(t.finalized_=!1),n}var vl=new xl,J=vl.produce;function wl(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function An(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function gt(e){return e=An(Math.abs(e)),e?e[1]:NaN}function _l(e,t){return function(n,r){for(var i=n.length,a=[],s=0,o=e[0],c=0;i>0&&o>0&&(c+o+1>r&&(o=Math.max(1,r-c)),a.push(n.substring(i-=o,i+o)),!((c+=o+1)>r));)o=e[s=(s+1)%e.length];return a.reverse().join(t)}}function Nl(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var Cl=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function En(e){if(!(t=Cl.exec(e)))throw new Error("invalid format: "+e);var t;return new pi({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}En.prototype=pi.prototype;function pi(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}pi.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Ml(e){e:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+e[n])break e;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var Is;function Sl(e,t){var n=An(e,t);if(!n)return e+"";var r=n[0],i=n[1],a=i-(Is=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=r.length;return a===s?r:a>s?r+new Array(a-s+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+An(e,Math.max(0,t+a-1))[0]}function ca(e,t){var n=An(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const la={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:wl,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>ca(e*100,t),r:ca,s:Sl,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function ha(e){return e}var fa=Array.prototype.map,da=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function $l(e){var t=e.grouping===void 0||e.thousands===void 0?ha:_l(fa.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",a=e.numerals===void 0?ha:Nl(fa.call(e.numerals,String)),s=e.percent===void 0?"%":e.percent+"",o=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function u(h){h=En(h);var f=h.fill,d=h.align,m=h.sign,g=h.symbol,x=h.zero,y=h.width,b=h.comma,p=h.precision,w=h.trim,C=h.type;C==="n"?(b=!0,C="g"):la[C]||(p===void 0&&(p=12),w=!0,C="g"),(x||f==="0"&&d==="=")&&(x=!0,f="0",d="=");var k=g==="$"?n:g==="#"&&/[boxX]/.test(C)?"0"+C.toLowerCase():"",T=g==="$"?r:/[%p]/.test(C)?s:"",L=la[C],I=/[defgprs%]/.test(C);p=p===void 0?6:/[gprs]/.test(C)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p));function D(_){var A=k,M=T,E,K,Y;if(C==="c")M=L(_)+M,_="";else{_=+_;var z=_<0||1/_<0;if(_=isNaN(_)?c:L(Math.abs(_),p),w&&(_=Ml(_)),z&&+_==0&&m!=="+"&&(z=!1),A=(z?m==="("?m:o:m==="-"||m==="("?"":m)+A,M=(C==="s"?da[8+Is/3]:"")+M+(z&&m==="("?")":""),I){for(E=-1,K=_.length;++E<K;)if(Y=_.charCodeAt(E),48>Y||Y>57){M=(Y===46?i+_.slice(E+1):_.slice(E))+M,_=_.slice(0,E);break}}}b&&!x&&(_=t(_,1/0));var W=A.length+_.length+M.length,G=W<y?new Array(y-W+1).join(f):"";switch(b&&x&&(_=t(G+_,G.length?y-M.length:1/0),G=""),d){case"<":_=A+_+M+G;break;case"=":_=A+G+_+M;break;case"^":_=G.slice(0,W=G.length>>1)+A+_+M+G.slice(W);break;default:_=G+A+_+M;break}return a(_)}return D.toString=function(){return h+""},D}function l(h,f){var d=u((h=En(h),h.type="f",h)),m=Math.max(-8,Math.min(8,Math.floor(gt(f)/3)))*3,g=Math.pow(10,-m),x=da[8+m/3];return function(y){return d(g*y)+x}}return{format:u,formatPrefix:l}}var ln,Xt,Ls;kl({thousands:",",grouping:[3],currency:["$",""]});function kl(e){return ln=$l(e),Xt=ln.format,Ls=ln.formatPrefix,ln}function Tl(e){return Math.max(0,-gt(Math.abs(e)))}function Pl(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(gt(t)/3)))*3-gt(Math.abs(e)))}function Al(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,gt(t)-gt(e))+1}function Fs(e,t){const n=e._data.nodes.allNodes[t];return n===void 0?Pe():Gn(n)}function xi(e,t){if(typeof t=="number")return Fs(e,t);if(t instanceof Object)return Br(e,t);if(typeof t=="string"){const n=Wt(e.taxonSet._data,t);return n.type===B.Some?Br(e,n.value):El(e,t)}return Pe()}function Br(e,t){const n=e._data.nodes.byTaxon[t.number];return n===void 0?Pe():xi(e,n)}function El(e,t){const n=e._data.nodes.byLabel[t];return n===void 0?Pe():Fs(e,n)}function fr(e,t,n){const r=e.getNode(t.number).annotations[n];return r===void 0?Pe():Gn(r)}function Vr(e,t){const n=e._data.nodeToTaxon[t.number];return n===void 0?Pe():Ds(e,n)}function Ds(e,t){return typeof t=="number"?Wt(e.taxonSet._data,Ss(e.taxonSet._data,t)):typeof t=="string"?Wt(e.taxonSet._data,t):Vr(e,t)}function dr(e,t){const n=e._data.nodes.allNodes[t.number];if(n===void 0)return Pe();const r=n.parent;return r===void 0?Pe():xi(e,r)}const X=[];for(let e=0;e<256;++e)X.push((e+256).toString(16).slice(1));function Rl(e,t=0){return(X[e[t+0]]+X[e[t+1]]+X[e[t+2]]+X[e[t+3]]+"-"+X[e[t+4]]+X[e[t+5]]+"-"+X[e[t+6]]+X[e[t+7]]+"-"+X[e[t+8]]+X[e[t+9]]+"-"+X[e[t+10]]+X[e[t+11]]+X[e[t+12]]+X[e[t+13]]+X[e[t+14]]+X[e[t+15]]).toLowerCase()}let mr;const Il=new Uint8Array(16);function Ll(){if(!mr){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");mr=crypto.getRandomValues.bind(crypto)}return mr(Il)}const Fl=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ma={randomUUID:Fl};function Dl(e,t,n){e=e||{};const r=e.random??e.rng?.()??Ll();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Rl(r)}function hn(e,t,n){return ma.randomUUID&&!e?ma.randomUUID():Dl(e)}class bi{[Lr]=!0;_data;taxonSet;constructor(t={}){const{data:n,taxonSet:r}=t;let i=n;r?this.taxonSet=r:this.taxonSet=new rn,i===void 0&&(i={nodes:{allNodes:[{number:0,children:[],parent:void 0,label:void 0,length:void 0,taxon:void 0,annotations:{},_id:hn()}],byTaxon:[],byLabel:{}},nodeToTaxon:[],rootNode:0,is_rooted:!0,annotations:{},heights:[],hasLengths:!1}),this._data=i}lockTaxa(){return this.taxonSet.lockTaxa(),this}addTaxon(t){return this.taxonSet.addTaxon(t),this}getTaxonCount(){return this.taxonSet.getTaxonCount()}getTaxonSet(){return this.taxonSet}static fromNewick(t,n={}){return Ir(t,n)}static fromNexus(t,n){return cl(t,n)}static fromString(t,n){return t.toLowerCase().includes("#nexus")?this.fromNexus(t,n):this.fromNewick(t,n)}static fromTree(t,n){let r=new this;const i=(a,s)=>{const o=[];let c;for(const u of a.getChildren(s))o.push(i(a,u));s!==n?(r=this._addNodeWithMetadata(a,s,r),c=r.getNode(r.getNodeCount()-1)):(c=r.getRoot(),this._copyNodeMetadata(a,s,r,c));for(const u of o)r=r.addChild(c,u);return c};return i(t,n),r=r.deleteLength(r.getRoot()),r}static _addNodeWithMetadata(t,n,r){const i=r.addNodes(1),a=i.nodes[0];return r=i.tree,r=this._copyNodeMetadata(t,n,r,a),r}static _copyNodeMetadata(t,n,r,i){if(t.hasTaxon(n)){const a=t.getTaxonFromNode(n);r=r.addTaxon(a),console.log("Current taxa:",r.taxonSet),r=r.setTaxon(i,a)}if(t.hasLabel(n)){const a=t.getLabel(n);r=r.setLabel(i,a)}for(const a of t.getAnnotationKeys())if(t.hasAnnotation(n,a)){const s=t.getFullNodeAnnotation(n,a);if(s.type===V.MARKOV_JUMPS){const o=s.value.map(c=>[Number(c.time),c.from,c.to]);r=r.annotateNode(i,a,o)}else r=r.annotateNode(i,a,s.value)}if(t.hasBranchLength(n)){const a=t.getLength(n);r=r.setLength(i,a)}return r}isRooted(){return this._data.is_rooted}getAnnotationType(t){if(this._data.annotations[t]===void 0)throw new Error(`No annotation found with name: ${t}`);return this._data.annotations[t].type}getAnnotationKeys(){return Object.keys(this._data.annotations)}getRoot(){return this._data.nodes.allNodes[this._data.rootNode]}getNodeCount(){return this._data.nodes.allNodes.length}getInternalNodeCount(){return this._data.nodes.allNodes.filter(t=>t.children.length>0).length}getExternalNodeCount(){return this._data.nodes.allNodes.filter(t=>t.children.length==0).length}getInternalNodes(){return this._data.nodes.allNodes.filter(t=>t.children.length>0)}getExternalNodes(){return this._data.nodes.allNodes.filter(t=>t.children.length==0)}getNodes(){return this._data.nodes.allNodes}getNode(t){const n=xi(this,t);switch(n.type){case B.Some:return n.value;case B.Nothing:throw new Error("No node found")}}getNodeByTaxon(t){const n=Br(this,t);switch(n.type){case B.Nothing:throw new Error(`No node found for Taxon ${t.name}`);case B.Some:return n.value}}getTaxonByName(t){return this.taxonSet.getTaxonByName(t)}getNodeByLabel(t){return this.getNode(this._data.nodes.byLabel[t])}hasTaxon(t){switch(Vr(this,t).type){case B.Some:return!0;case B.Nothing:return!1}}getTaxonFromNode(t){const n=Vr(this,t);switch(n.type){case B.Some:return n.value;case B.Nothing:throw new Error("Node taxon found for the provided node")}}getTaxon(t){const n=Ds(this,t);switch(n.type){case B.Some:return n.value;case B.Nothing:throw new Error("Node taxon found that matched the provided id")}}hasNodeHeights(){throw new Error("hasNodeHeights not implemented.")}getHeight(t){let n=-1;for(const r of Kn(this)){const i=this.getDivergence(r);i>n&&(n=i)}return n-this.getDivergence(t)}hasBranchLength(t){return this.getNode(t.number).length!==void 0}getLength(t){const r=this.getNode(t.number).length;if(r===void 0){if(this.hasLengths())throw new Error(`The tree has lengths but, no length was found for node ${t.number}`);return console.warn("The tree does not have branchlengths so a length of 1 is used as default"),1}return r}hasLengths(){return this._data.hasLengths}_toString(t,n){return n===void 0&&(n={blFormat:Xt("0.2"),includeAnnotations:!1}),(this.getChildCount(t)>0?`(${this.getChildren(t).map(r=>this._toString(r,n)).join(",")})${this.hasLabel(t)?"#"+this.getLabel(t):""}`:this.hasTaxon(t)?this.getTaxonFromNode(t).name:"")+(n.includeAnnotations?this._writeAnnotations(t):"")+(this.hasBranchLength(t)?`:${n.blFormat(this.getLength(t))}`:"")}_writeAnnotations(t){const n=this._data.nodes.allNodes[t.number].annotations;if(Object.keys(n).length===0)return"";let r="[&",i=0;for(const[a,s]of Object.entries(n))i>0&&(r+=", "),r+=`${a}=${Wu(s)}`,i+=1;return r+="]",r}toNewick(t,n){const r={blFormat:Xt("0.2"),includeAnnotations:!1,...n};return t===void 0&&(t=this.getRoot()),this._toString(t,r)+";"}getMRCA(t,n){if(Array.isArray(t)){const r=t;if(r.length===0)throw new Error("No nodes provided to get MRCA");let i=r[0];for(let a=1;a<r.length;a++)if(i=this.getMRCA(i,r[a]),this.isRoot(i))return i;return i}else{if(n===void 0)throw new Error("No second node provided. A node must be provided if the first value is not an array");const r=[...this.getPathToRoot(t)];let i=null;for(const a of this.getPathToRoot(n))if(r.includes(a)){i=a;break}if(i===null)throw new Error("No MRCA found");return i}}getPath(t,n){const r=[],i=this.getMRCA(t,n);for(let a of[t,n])for(;a!=i;)r.push(a),a=this.getParent(a);return r}getPathLength(t,n){let r=0;const i=this.getMRCA(t,n);for(let a of[t,n])for(;a!=i;){const s=this.getLength(a);r+=s,a=this.getParent(a)}return r}*getPathToRoot(t){let n=t;for(;!this.isRoot(n);)yield n,n=this.getParent(n);yield n}getNextSibling(t){if(!this.hasLeftSibling(t)&&!this.hasRightSibling(t))throw new Error(`Node ${t.number} has no sibling`);const n=this.getParent(t),r=n.children.map(i=>i).indexOf(t.number);return this.getChild(n,(r+1)%this.getChildCount(n))}hasRightSibling(t){const n=dr(this,t);switch(n.type){case B.Nothing:return!1;case B.Some:return n.value.children.map(r=>r).indexOf(t.number)<this.getChildCount(n.value)-1}}getRightSibling(t){if(!this.hasRightSibling(t))throw new Error(`node ${t.number} does not have a right sibling`);const n=this.getParent(t),r=n.children.map(i=>i).indexOf(t.number);return this.getChild(n,r+1)}hasLeftSibling(t){const n=dr(this,t);switch(n.type){case B.Nothing:return!1;case B.Some:return this.getChildCount(n.value)>1&&n.value.children.map(r=>r).indexOf(t.number)>0}}getLeftSibling(t){if(!this.hasLeftSibling(t))throw new Error(`node ${t.number} does not have a left sibling`);const n=this.getParent(t),r=n.children.map(i=>i).indexOf(t.number);return this.getChild(n,r-1)}getDivergence(t){let n=0;for(const r of this.getPathToRoot(t))this.isRoot(r)?this.hasBranchLength(r)&&(n+=this.getLength(r)):n+=this.getLength(r);return n}getChildCount(t){if(!this._data.nodes.allNodes[t.number])throw new Error(`Node ${t.number} not found`);return this._data.nodes.allNodes[t.number].children.length}getChild(t,n){return this._data.nodes.allNodes[this._data.nodes.allNodes[t.number].children[n]]}getParent(t){const n=dr(this,t);switch(n.type){case B.Some:return n.value;case B.Nothing:throw new Error(`No parent for node ${t.number}`)}}getChildren(t){return this._data.nodes.allNodes[t.number].children.map(n=>this.getNode(n))}hasLabel(t){return this._data.nodes.allNodes[t.number].label!==void 0}getLabel(t){const n=this._data.nodes.allNodes[t.number].label;if(n===void 0)throw new Error(`no label for node ${t.number}`);return n}isExternal(t){return this.getNode(t.number).children.length===0}isInternal(t){return this.getNode(t.number).children.length>0}isRoot(t){return this._data.rootNode===t.number}addNodes(t=1){const n=[];return{tree:J(this,r=>{const i=r._data.nodes.allNodes.length;for(let a=0;a<t;a++){const s={number:i+a,children:[],parent:void 0,label:void 0,length:void 0,taxon:void 0,annotations:{},_id:hn()};n.push(s),r._data.nodes.allNodes.push(s)}}),nodes:n}}setTaxon(t,n){if(n!==this.taxonSet.getTaxonByName(n.name))throw new Error(`Taxon ${n.name} is either not in the taxon set. Has it been copied?`);return J(this,r=>{const i=r.getNode(t.number);i.taxon=n.number,r._data.nodes.byTaxon[n.number]=t.number,r._data.nodeToTaxon[t.number]=n.number})}getAnnotationSummary(t){if(this._data.annotations[t]===void 0)throw new Error(`No annotation with name ${t} found in tree`);return this._data.annotations[t]}getAnnotations(){return Object.values(this._data.annotations)}getAnnotation(t,n,r){const i=fr(this,this.getNode(t.number),n);if(r===void 0){const{value:a}=Gi(i,`Node ${t.number} is not annotated with ${n}`);return a}else switch(i.type){case B.Some:return i.value.value;case B.Nothing:return r}}getFullNodeAnnotation(t,n){const r=fr(this,this.getNode(t.number),n);return Gi(r,`Node ${t.number} is not annotated with ${n}`)}hasAnnotation(t,n){switch(fr(this,this.getNode(t.number),n).type){case B.Some:return!0;case B.Nothing:return!1}}annotateNode(t,n,r){if(typeof n=="string"){const i=n,s=Hu(r),o=this._data.annotations[i];if(o!==void 0&&o.type!==s.type)throw new Error(`Tried annotation ${i} was parsed as ${s.type} - but is ${o.type} in tree.`);return J(this,c=>{const u=o?o.domain:void 0,l=zl(s,u);c._data.nodes.allNodes[t.number].annotations[i]={id:i,type:s.type,value:s.value},c._data.annotations[i]={id:i,type:s.type,domain:l}})}else{let i=this;for(const[a,s]of Object.entries(n))i=i.annotateNode(t,a,s);return i}}setHeight(t,n){if(!this.hasLengths())throw new Error("Can not set the heights of nodes in a tree without branch lengths");return J(this,r=>{const i=r.getNode(t.number);if(n<0)throw new Error("Height must be non-negative");const s=r.getHeight(t)-n;if(i.length===void 0){if(!r.isRoot(t))throw new Error("Cannot set height on a node without length")}else i.length=i.length+s;for(const o of r.getChildren(t)){const c=r.getNode(o.number),u=r.getLength(c)-s;c.length=u}})}setLength(t,n){return J(this,r=>{const i=r.getNode(t.number);i.length=n,r._data.hasLengths=!0})}deleteLength(t){return J(this,n=>{const r=n.getNode(t.number);r.length=void 0})}setDivergence(t,n){if(!this.hasLengths())throw new Error("Can not set the divergences of nodes in a tree without branch lengths");return J(this,r=>{const i=r.getNode(t.number),a=r.getHeight(t),c=r.getHeight(r.getRoot())-a-n,u=r.getLength(t);i.length=u-c})}setLabel(t,n){if(this._data.nodes.byLabel[n]!==void 0)throw new Error(`Duplicate node label ${n}`);return J(this,r=>{const i=r.getNode(t.number);i.label=n,r._data.nodes.byLabel[n]=t.number})}insertNode(t,n=.5){return J(this,r=>{const i={number:r._data.nodes.allNodes.length,children:[],parent:void 0,label:"",length:void 0,taxon:void 0,annotations:{},_id:hn()};r._data.nodes.allNodes.push(i),r._data.nodes.byTaxon.length+=1;const a=r.getNode(t.number),s=r.getParent(a),o=s.children.indexOf(a.number);s.children.splice(o,1,i.number),i.parent=s.number;const u=r.getLength(a);a.length=u*(1-n),i.length=u*n,i.children=[a.number],a.parent=i.number})}unroot(t){throw new Error("unroot not implemented in immutable tree")}deleteNode(t){throw new Error("deleteNode not implemented in immutable tree")}deleteClade(t){throw new Error("deleteClade not implemented in immutable tree")}orderNodesByDensity(t,n){return J(this,r=>{n===void 0&&(n=r._data.nodes.allNodes[r._data.rootNode]);const i=t?1:-1;Us(r._data,n,(a,s,o,c)=>(s-c)*i)})}rotate(t,n=!1){return J(this,r=>{const i=r.getNode(t.number);if(i.children=i.children.reverse(),n)for(const a of i.children.map(s=>r.getNode(s)))r.rotate(a,n)})}reroot(t,n=.5){return J(this,r=>{if(t.number===r._data.rootNode)return;const i=r.getRoot();i.children.length!==2&&console.warn("Root node has more than two children and we are rerooting! There be dragons!");let a=0;if(i.children.length==2)a=i.children.map(o=>r.getNode(o)).map(o=>r.getLength(o)).reduce((o,c)=>c+o,0);else{const o=[...r.getPathToRoot(t)],c=o[o.length-2];if(Z(c,"Index error when looking for the root child"),!i.children.includes(c.number))throw new Error("Root child not in path to root - likely an internal error");a=r.getLength(c)}const s=r.getNode(t.number);if(r.getParent(t)!==i){let o=s,c=r.getParent(s);const u=r.getChild(c,0).number===t.number,l=s,h=c;let f=r.getLength(c);for(;!r.isRoot(c);){if(c.children=c.children.filter(m=>m!==o.number),r.getParent(c).number===i.number)if(i.children.length==2){if(!r.hasLeftSibling(c)&&!r.hasRightSibling(c))throw new Error("no sibling in rerooting");const g=r.hasLeftSibling(c)?r.getLeftSibling(c):r.getRightSibling(c);c.children.push(g.number),g.parent=c.number,g.length=a}else{const m={number:r._data.nodes.allNodes.length,children:[],parent:void 0,label:"",length:void 0,taxon:void 0,annotations:{},_id:hn()};r._data.nodes.allNodes.push(m),m.length=a,c.children.push(m.number),m.parent=c.number;for(const g of i.children){const x=r.getNode(g);x.number!==c.number&&(x.parent=m.number,m.children.push(x.number))}}else{const m=r.getParent(c),g=r.getLength(m);m.length=f,f=g,c.children.push(m.number)}o=c,c=r.getParent(c)}l.parent=i.number,h.parent=i.number,i.children=[l.number,h.number],u||(i.children=i.children.reverse()),this.getInternalNodes().forEach(m=>{for(const g of r.getChildren(m))g.parent=m.number});const d=r.getLength(l)*n;h.length=d,Z(l.length,"Expected the root's new child to have a length"),l.length-=d}else{const o=r.getLength(t)*(1-n);s.length=o;const c=r.getNextSibling(t);c.length=a-o}})}removeChild(t,n){return J(this,r=>{r._data.nodes.allNodes[t.number].children=r._data.nodes.allNodes[t.number].children.filter(i=>i!==n.number),r._data.nodes.allNodes[n.number].parent=-1})}sortChildren(t,n){return J(this,r=>{r._data.nodes.allNodes[t.number].children=this._data.nodes.allNodes[t.number].children.map(i=>r.getNode(i)).sort(n).map(i=>i.number)})}addChild(t,n){return J(this,r=>{const i=r.getNode(n.number);r.getNode(t.number).children.push(i.number),i.parent=t.number})}setRoot(t){return J(this,n=>{n._data.rootNode=t.number})}}function Us(e,t,n){let r=0;if(e.nodes.allNodes[t.number].children.length>0){const i=new Map;for(const o of e.nodes.allNodes[t.number].children.map(c=>e.nodes.allNodes[c])){const c=Us(e,o,n);i.set(o.number,c),r+=c}const a=e.nodes.allNodes[t.number].children.slice().sort((o,c)=>n(e.nodes.allNodes[o],pe(i.get(o),"Internal error when ordering. Counts not defined."),e.nodes.allNodes[c],pe(i.get(c),"Internal error when ordering. Counts not defined.")));a.reduce((o,c,u)=>o||c!==e.nodes.allNodes[t.number].children[u],!0)&&(e.nodes.allNodes[t.number].children=a)}else r=1;return r}function*Os(e,t=void 0){const n=function*(r){yield e.getNode(r.number);const i=e.getChildCount(r);if(i>0)for(let a=0;a<i;a++){const s=e.getChild(r,a);yield*n(s)}};t===void 0&&(t=e.getRoot()),yield*n(t)}function*Ul(e,t=void 0,n=(r,i)=>r.number-i.number){const r=function*(i,a=void 0){yield e.getNode(i.number);const s=[...e.getChildren(i),e.getParent(i)].filter(o=>o.number!==a);s.sort(n);for(const o of s)yield*r(o,i.number)};t===void 0&&(t=e.getRoot()),yield*r(t)}function*Ol(e,t=void 0,n=(r,i)=>r.number-i.number){const r=function*(i,a=void 0){const s=[...e.getChildren(i),e.getParent(i)].filter(o=>o.number!==a);s.sort(n);for(const o of s)yield*r(o,i.number);yield e.getNode(i.number)};t===void 0&&(t=e.getRoot()),yield*r(t)}function*js(e,t=void 0){const n=function*(r){const i=e.getChildCount(r);if(i>0)for(let a=0;a<i;a++){const s=e.getChild(r,a);yield*n(s)}yield r};t===void 0&&(t=e.getRoot()),yield*n(t)}function*Kn(e,t){t===void 0&&(t=e.getRoot());const n=function*(r){const i=e.getChildCount(r);if(i>0)for(let a=0;a<i;a++){const s=e.getChild(r,a);yield*n(s)}else yield r};yield*n(t)}function*jl(e,t){let n=t;for(;!e.isRoot(n);)yield n,n=e.getParent(n);yield n}function zl(e,t){switch(e.type){case V.BOOLEAN:return[!0,!1];case V.DISCRETE:{const n=e.value;if(t!==void 0){const r=t;return[...new Set([...r,n])].sort()}else return[n]}case V.NUMERICAL:{const n=e.value;return lt([...t||[],n])}case V.DISCRETE_SET:{const n=e.value,r=t||[];return[...new Set([...r,...n])].sort()}case V.NUMERICAL_SET:{const n=e.value;return lt([...t||[],...n])}case V.DENSITIES:if(t!==void 0){const n=t;return[...new Set([...n,...Object.keys(e.value)])].sort()}else return[...new Set(Object.keys(e.value))].sort().filter(n=>n);case V.MARKOV_JUMPS:{const n=e.value.reduce((i,a)=>i.concat([a.to,a.from]),[]),r=t||[];return[...new Set([...r,...n])].sort()}default:throw new Error("Unrecognized type when updating domain")}}function Bl(){return{lastChunk:"",status:"parsing",end:"",start(){},transform(e,t){const n=this.lastChunk+e;let r="";for(let i=0;i<n.length;i++){const a=n[i];Z(a,"Internal Error. Hit empty character in array"),this.status==="parsing"?([this.status,this.end]=Vl(a),this.status==="in comment"&&(r.length>0&&t.enqueue(r),r="")):a===this.end&&(this.status="parsing",this.end=""),this.status==="parsing"&&/\s|;|\]/.test(a)?(r.length>0&&(/\]/.test(a)&&(r+=a),t.enqueue(r),r=""),/;/.test(a)&&t.enqueue(a)):r+=a}this.lastChunk=r},flush(e){this.lastChunk&&e.enqueue(this.lastChunk)}}}function Vl(e){return e==="'"?["in single quote","'"]:e==='"'?["in double quote",'"']:e==="["?["in comment","]"]:["parsing",""]}const ga=/\s*('[^']+'|"[^"]+"|\[&[^[]+]|,|:|\)|\(|;)\s*/;class ql{reader;taxonSet;currentBlock;hasTree;options;translateTaxonMap;constructor(t,n={}){const r=new TransformStream(Bl());this.reader=t.pipeThrough(new TextDecoderStream).pipeThrough(r).getReader(),this.taxonSet=new rn,this.currentBlock=void 0,this.options=n}async*getTrees(){for(;this.currentBlock!=="trees";)await this.parseNextBlock(),this.hasTree=!0;yield*this.parseTreesBlock()}async parseNextBlock(){const t=await this.getNextBlockName();switch(t){case"taxa":this.currentBlock="taxa",await this.parseTaxaBlock();break;case"trees":this.currentBlock="trees";break;default:console.log(`skipping block ${t}. Only parsing blocks are taxa and trees for now.`),await this.readToEndOfBlock()}}async nextToken(){const{done:t,value:n}=await this.reader.read();if(t)throw new Error("unexpectedly hit the end of the stream");return n}async skipSemiColon(){const{done:t,value:n}=await this.reader.read();if(t)throw new Error("unexpectedly hit the end of the stream");if(!n.match(/;$/))throw new Error(`expected ";" got ${n}`)}async getNextBlockName(){let t=!0,n;for(;t;)(await this.nextToken()).match(/\bbegin/i)&&(n=await this.nextToken(),await this.skipSemiColon(),t=!1);return n}async readToEndOfBlock(){let t=!0;for(;t;)(await this.nextToken()).match(/\bend;/i)&&(t=!1)}async skipUntil(t){let n,r=!0;for(;r;)n=await this.nextToken(),t.test(n)&&(r=!1);if(n==null)throw new Error(`Internal parsing error: ${t.source} not found `);return n}async readUntil(t){let n="",r=!0;for(;r;){const i=await this.nextToken();t.test(i)&&(n+=i,r=!1),n+=i}return n}async parseTaxaBlock(){let t,n=!0;for(;n;){const r=await this.skipUntil(/dimensions|taxlabels|end/i);switch(!0){case/dimensions/i.test(r):{const i=await this.readUntil(/;/),a=i.match(/ntax=(\d+);/);if(a)Z(a[1],"No number of taxa found despite matching regex"),t=parseInt(a[1]);else throw new Error(`Expected dimension in form of ntax=(\\d+);. Got ${i}`);break}case/taxlabels/i.test(r):{let i=await this.nextToken();for(;i!==";";)this.taxonSet.addTaxon(i),i=await this.nextToken();if(t&&t!=this.taxonSet.getTaxonCount())throw new Error(`found ${this.taxonSet.getTaxonCount()} taxa. Expected: ${t}}`);break}case/end/i.test(r):{if(this.taxonSet.getTaxonCount()===0)throw new Error("hit end of taxa section but didn't find any taxa");this.taxonSet.lockTaxa(),await this.skipSemiColon(),n=!1;break}default:throw new Error(`Reached impossible code looking for dimensions or taxlabels or end in taxa block "${r}"`)}}}async*parseTreesBlock(){let t,n=!0;for(;n;){const r=await this.skipUntil(/translate|tree|end/i);switch(!0){case/translate/i.test(r):{this.translateTaxonMap=new Map;let i=0,a;for(t=await this.nextToken();t!==";";){if(i%2==0)a=t;else{if(t[t.length-1]===","&&(t=t.slice(0,-1)),this.taxonSet.isFinalized){if(!this.taxonSet.hasTaxon(t))throw new Error(`Taxon ${t} not found in taxa block - but found in translate block`)}else this.taxonSet.addTaxon(t);Z(a,"Error parsing nexus. Expected key for taxa but found nothing"),this.translateTaxonMap.set(a,t)}for(t=await this.nextToken();t===",";)t=await this.nextToken();i++}this.taxonSet.lockTaxa();break}case/tree/i.test(r):{await this.nextToken();const i=new $s(this.taxonSet,{translateTaxonNames:this.translateTaxonMap});t=await this.skipUntil(/\(/);let a=t.split(ga).filter(o=>o.length>0).reverse();for(;!i.isDone();){for(;a.length>0;){const o=a.pop();Z(o,"Unexpectedly hit the end of the buffer"),i.parseCharacter(o)}i.isDone()||(t=await this.nextToken(),a=t.split(ga).filter(o=>o.length>0).reverse())}yield i.getTree();break}case/end/i.test(r):await this.skipSemiColon(),this.hasTree=!1,this.reader.releaseLock(),n=!1;break;default:throw new Error(`Reached impossible code in treeblock block "${r}"`)}}}}class Hl{_forwardCache;_reverseCache;constructor(){this._forwardCache=new Map,this._reverseCache=new Map}*traverse(t,n){const r=function*(i){const a=t.getChildCount(i);if(a>0)for(let s=0;s<a;s++){const o=t.getChild(i,s);yield*r(o)}yield i};n===void 0&&(n=t.getRoot()),yield*r(n)}getNext(t,n){const r=this._forwardCache.get(n);if(r!==void 0&&this._forwardCache.get(r)!==void 0)return r;if(t.isRoot(n))return;const i=t.getParent(n);if(t.hasRightSibling(n)){const a=t.getRightSibling(n);this._forwardCache.set(n,a),this._reverseCache.set(a,n)}else this._forwardCache.set(n,i),this._reverseCache.set(i,n);return this._forwardCache.get(n)}getPrevious(t,n){const r=this._reverseCache.get(n);if(r!==void 0&&this._reverseCache.get(r)!==void 0)return r;if(n!==this.traverse(t).next().value){if(t.isInternal(n)){const i=t.getChildCount(n)-1,a=t.getChild(n,i);this._reverseCache.set(n,a),this._forwardCache.set(a,n)}else if(t.hasLeftSibling(n)){const i=t.getLeftSibling(n);this._reverseCache.set(n,i),this._forwardCache.set(i,n)}else{let i=n;for(;!t.hasLeftSibling(i);)i=t.getParent(i);const a=t.getLeftSibling(i);this._reverseCache.set(n,a),this._forwardCache.set(a,n)}return this._reverseCache.get(n)}}}var H=(e=>(e.Rectangular="Rectangular",e.Polar="Polar",e.Radial="Radial",e))(H||{});function zs(e){function t(n){const r=new Map;let i=0;for(const a of js(n)){let s;const o=n.getDivergence(a),c=n.getChildCount(a)>0,u=!n.isRoot(a),l=n.getChildCount(a)>0&&(!u||n.getChild(n.getParent(a),0)!==a);if(n.isExternal(a))s={x:o,y:i},i++;else{const f=n.getChildren(a).map(m=>pe(r.get(m),"Internal Error: child not yet found in layout")),d=pe(li(f,m=>m.y),"Error taking the mean of child positions");s={x:o,y:d}}const h={...s,layoutClass:e,nodeLabel:{alignmentBaseline:c?l?"bottom":"hanging":"middle",textAnchor:c?"end":"start",dxFactor:c?-1:1,dyFactor:c?l?-1:1:0,rotation:0}};r.set(a,h)}return function(a){if(r.has(a))return r.get(a);throw console.log(a),new Error("Node not found in layout - has the tree changed")}}return t}const Bs=zs(H.Rectangular),Yl=zs(H.Polar);function Wl(e,t={}){const{spread:n=1}=t;console.log("radial layout with spread",n);const r=new Map,i=[{angleStart:0,angleEnd:2*Math.PI,xpos:0,ypos:0,level:0,number:e.getRoot().number}];for(const a of Os(e)){const s=i.pop();Z(s,"Internal Error, hit the end of the data stack unexpectedly");const{angleStart:o,angleEnd:c,xpos:u,ypos:l,level:h}=s,f=(o+c)/2,d=e.isRoot(a)?0:e.getLength(a),m=Math.cos(f),g=Math.sin(f),x=u+d*m,y=l+d*g,b=e.getChildCount(a)>0;let p,w;p=Math.cos(f),w=Math.sin(f);const C=Vs(f),k={x,y,layoutClass:H.Radial,theta:C,nodeLabel:{dxFactor:p,dyFactor:w,alignmentBaseline:"middle",textAnchor:C>Math.PI/2&&C<3*Math.PI/2?"end":" start",rotation:Gl(C)*2}};if(e.getChildCount(a)>0){const T=[];let L=0;for(let A=0;A<e.getChildCount(a);A++){const M=[...Kn(e,e.getChild(a,A))].length;T[A]=M,L+=M}let I=c-o,D=o;e.getRoot()!==a&&(I*=1+n*Math.PI/180/10,D=f-I/2);let _=D;for(let A=e.getChildCount(a)-1;A>-1;A--){const M=_;_=M+I*T[A]/L,i.push({angleStart:M,angleEnd:_,xpos:x,ypos:y,level:h+1,number:e.getChild(a,A).number})}}r.set(a,k)}return function(a){if(r.has(a))return r.get(a);throw new Error("Node not found in layout - has the tree changed")}}function Gl(e){const t=Ql(e);return t>90&&t<270?(t-180)/2:t>0&&t<90?t/2:t<360&&t>270?(360+t)/2:t}function Vs(e){for(;e>2*Math.PI;)e-=2*Math.PI;return e}function Ql(e){return Vs(e)*180/Math.PI}const Xl=()=>({x:0,y:0,layoutClass:H.Rectangular,nodeLabel:{alignmentBaseline:"middle",textAnchor:"end",dxFactor:0,dyFactor:0,rotation:0}}),bt=P.createContext(Xl),vt=P.createContext(!1),Zl={canvasWidth:0,canvasHeight:0,domainX:[0,1],domainY:[0,1],layoutClass:H.Rectangular,invert:!1,pollard:0,minRadius:0,fishEye:{x:0,y:0,scale:0},rootAngle:0,angleRange:0},sn=P.createContext(Zl);function Kl(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function vi(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function qs(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function on(){}var Zt=.7,Rn=1/Zt,ut="\\s*([+-]?\\d+)\\s*",Kt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ke="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Jl=/^#([0-9a-f]{3,8})$/,eh=new RegExp(`^rgb\\(${ut},${ut},${ut}\\)$`),th=new RegExp(`^rgb\\(${ke},${ke},${ke}\\)$`),nh=new RegExp(`^rgba\\(${ut},${ut},${ut},${Kt}\\)$`),rh=new RegExp(`^rgba\\(${ke},${ke},${ke},${Kt}\\)$`),ih=new RegExp(`^hsl\\(${Kt},${ke},${ke}\\)$`),ah=new RegExp(`^hsla\\(${Kt},${ke},${ke},${Kt}\\)$`),ya={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};vi(on,Jt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:pa,formatHex:pa,formatHex8:sh,formatHsl:oh,formatRgb:xa,toString:xa});function pa(){return this.rgb().formatHex()}function sh(){return this.rgb().formatHex8()}function oh(){return Hs(this).formatHsl()}function xa(){return this.rgb().formatRgb()}function Jt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Jl.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ba(t):n===3?new oe(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?fn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?fn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=eh.exec(e))?new oe(t[1],t[2],t[3],1):(t=th.exec(e))?new oe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=nh.exec(e))?fn(t[1],t[2],t[3],t[4]):(t=rh.exec(e))?fn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ih.exec(e))?_a(t[1],t[2]/100,t[3]/100,1):(t=ah.exec(e))?_a(t[1],t[2]/100,t[3]/100,t[4]):ya.hasOwnProperty(e)?ba(ya[e]):e==="transparent"?new oe(NaN,NaN,NaN,0):null}function ba(e){return new oe(e>>16&255,e>>8&255,e&255,1)}function fn(e,t,n,r){return r<=0&&(e=t=n=NaN),new oe(e,t,n,r)}function uh(e){return e instanceof on||(e=Jt(e)),e?(e=e.rgb(),new oe(e.r,e.g,e.b,e.opacity)):new oe}function qr(e,t,n,r){return arguments.length===1?uh(e):new oe(e,t,n,r??1)}function oe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}vi(oe,qr,qs(on,{brighter(e){return e=e==null?Rn:Math.pow(Rn,e),new oe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Zt:Math.pow(Zt,e),new oe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new oe(Ge(this.r),Ge(this.g),Ge(this.b),In(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:va,formatHex:va,formatHex8:ch,formatRgb:wa,toString:wa}));function va(){return`#${Ye(this.r)}${Ye(this.g)}${Ye(this.b)}`}function ch(){return`#${Ye(this.r)}${Ye(this.g)}${Ye(this.b)}${Ye((isNaN(this.opacity)?1:this.opacity)*255)}`}function wa(){const e=In(this.opacity);return`${e===1?"rgb(":"rgba("}${Ge(this.r)}, ${Ge(this.g)}, ${Ge(this.b)}${e===1?")":`, ${e})`}`}function In(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ge(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ye(e){return e=Ge(e),(e<16?"0":"")+e.toString(16)}function _a(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new we(e,t,n,r)}function Hs(e){if(e instanceof we)return new we(e.h,e.s,e.l,e.opacity);if(e instanceof on||(e=Jt(e)),!e)return new we;if(e instanceof we)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),s=NaN,o=a-i,c=(a+i)/2;return o?(t===a?s=(n-r)/o+(n<r)*6:n===a?s=(r-t)/o+2:s=(t-n)/o+4,o/=c<.5?a+i:2-a-i,s*=60):o=c>0&&c<1?0:s,new we(s,o,c,e.opacity)}function lh(e,t,n,r){return arguments.length===1?Hs(e):new we(e,t,n,r??1)}function we(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}vi(we,lh,qs(on,{brighter(e){return e=e==null?Rn:Math.pow(Rn,e),new we(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Zt:Math.pow(Zt,e),new we(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new oe(gr(e>=240?e-240:e+120,i,r),gr(e,i,r),gr(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new we(Na(this.h),dn(this.s),dn(this.l),In(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=In(this.opacity);return`${e===1?"hsl(":"hsla("}${Na(this.h)}, ${dn(this.s)*100}%, ${dn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Na(e){return e=(e||0)%360,e<0?e+360:e}function dn(e){return Math.max(0,Math.min(1,e||0))}function gr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const wi=e=>()=>e;function hh(e,t){return function(n){return e+n*t}}function fh(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function dh(e){return(e=+e)==1?Ys:function(t,n){return n-t?fh(t,n,e):wi(isNaN(t)?n:t)}}function Ys(e,t){var n=t-e;return n?hh(e,n):wi(isNaN(e)?t:e)}const Ca=(function e(t){var n=dh(t);function r(i,a){var s=n((i=qr(i)).r,(a=qr(a)).r),o=n(i.g,a.g),c=n(i.b,a.b),u=Ys(i.opacity,a.opacity);return function(l){return i.r=s(l),i.g=o(l),i.b=c(l),i.opacity=u(l),i+""}}return r.gamma=e,r})(1);function mh(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function gh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function yh(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)i[s]=_i(e[s],t[s]);for(;s<n;++s)a[s]=t[s];return function(o){for(s=0;s<r;++s)a[s]=i[s](o);return a}}function ph(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ln(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function xh(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=_i(e[i],t[i]):r[i]=t[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var Hr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yr=new RegExp(Hr.source,"g");function bh(e){return function(){return e}}function vh(e){return function(t){return e(t)+""}}function wh(e,t){var n=Hr.lastIndex=yr.lastIndex=0,r,i,a,s=-1,o=[],c=[];for(e=e+"",t=t+"";(r=Hr.exec(e))&&(i=yr.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),o[s]?o[s]+=a:o[++s]=a),(r=r[0])===(i=i[0])?o[s]?o[s]+=i:o[++s]=i:(o[++s]=null,c.push({i:s,x:Ln(r,i)})),n=yr.lastIndex;return n<t.length&&(a=t.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?c[0]?vh(c[0].x):bh(t):(t=c.length,function(u){for(var l=0,h;l<t;++l)o[(h=c[l]).i]=h.x(u);return o.join("")})}function _i(e,t){var n=typeof t,r;return t==null||n==="boolean"?wi(t):(n==="number"?Ln:n==="string"?(r=Jt(t))?(t=r,Ca):wh:t instanceof Jt?Ca:t instanceof Date?ph:gh(t)?mh:Array.isArray(t)?yh:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?xh:Ln)(e,t)}function _h(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function Nh(e){return function(){return e}}function Ch(e){return+e}var Ma=[0,1];function it(e){return e}function Yr(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Nh(isNaN(t)?NaN:.5)}function Mh(e,t){var n;return e>t&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function Sh(e,t,n){var r=e[0],i=e[1],a=t[0],s=t[1];return i<r?(r=Yr(i,r),a=n(s,a)):(r=Yr(r,i),a=n(a,s)),function(o){return a(r(o))}}function $h(e,t,n){var r=Math.min(e.length,t.length)-1,i=new Array(r),a=new Array(r),s=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++s<r;)i[s]=Yr(e[s],e[s+1]),a[s]=n(t[s],t[s+1]);return function(o){var c=Du(e,o,1,r)-1;return a[c](i[c](o))}}function kh(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Th(){var e=Ma,t=Ma,n=_i,r,i,a,s=it,o,c,u;function l(){var f=Math.min(e.length,t.length);return s!==it&&(s=Mh(e[0],e[f-1])),o=f>2?$h:Sh,c=u=null,h}function h(f){return f==null||isNaN(f=+f)?a:(c||(c=o(e.map(r),t,n)))(r(s(f)))}return h.invert=function(f){return s(i((u||(u=o(t,e.map(r),Ln)))(f)))},h.domain=function(f){return arguments.length?(e=Array.from(f,Ch),l()):e.slice()},h.range=function(f){return arguments.length?(t=Array.from(f),l()):t.slice()},h.rangeRound=function(f){return t=Array.from(f),n=_h,l()},h.clamp=function(f){return arguments.length?(s=f?!0:it,l()):s!==it},h.interpolate=function(f){return arguments.length?(n=f,l()):n},h.unknown=function(f){return arguments.length?(a=f,h):a},function(f,d){return r=f,i=d,l()}}function Ph(){return Th()(it,it)}function Ah(e,t,n,r){var i=Bu(e,t,n),a;switch(r=En(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=Pl(i,s))&&(r.precision=a),Ls(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=Al(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=Tl(i))&&(r.precision=a-(r.type==="%")*2);break}}return Xt(r)}function Eh(e){var t=e.domain;return e.ticks=function(n){var r=t();return zu(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var i=t();return Ah(i[0],i[i.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),i=0,a=r.length-1,s=r[i],o=r[a],c,u,l=10;for(o<s&&(u=s,s=o,o=u,u=i,i=a,a=u);l-- >0;){if(u=Er(s,o,n),u===c)return r[i]=s,r[a]=o,t(r);if(u>0)s=Math.floor(s/u)*u,o=Math.ceil(o/u)*u;else if(u<0)s=Math.ceil(s*u)/u,o=Math.floor(o*u)/u;else break;c=u}return e},e}function me(){var e=Ph();return e.copy=function(){return kh(e,me())},Kl.apply(e,arguments),Eh(e)}function Rh(e,t,n,r,i=!1,a=0,s=1.7*Math.PI,o=0,c=0){const u=Math.min(n,r)/2,l=We(s),h=e*c,f=i?[a*u,u].reverse():[a*u,u],d=me().domain([h,e]).range(f),m=o+(2*3.14-l)/2,g=m+l,x=me().domain([0,t]).range([m,g]),y=[[0,0],At(u,m),At(u,g)],b=We(m),p=We(b+l);if(p>b)for(const Y of[Math.PI/2,Math.PI,3*Math.PI/2].filter(z=>z>b&&z<p)){const[z,W]=At(u,Y);y.push([z,W])}else for(const Y of[0,Math.PI/2,Math.PI,3*Math.PI/2].filter(z=>z>b||z<p)){const[z,W]=At(u,Y);y.push([z,W])}const w=lt(y,Y=>Y[0]),C=lt(y,Y=>Y[1]),k=(w[1]-w[0])/(C[1]-C[0]),T=Math.min(n,r*k),L=T,I=T/k,D=(n-L)/2,_=(r-I)/2,A=[_,r-_],M=[D,n-D],E=me().domain(w).range(M),K=me().domain(C).range(A);return function(z){const[W,G]=[d(z.x),x(z.y)],[xe,Ce]=At(W,G),te=We(G),je={alignmentBaseline:"middle",textAnchor:te>Math.PI/2&&te<3*Math.PI/2?"end":" start",dxFactor:Math.cos(te),dyFactor:Math.sin(te),rotation:Ws(te)};return{...z,x:E(xe),y:K(Ce),r:W,theta:G,nodeLabel:je}}}function At(e,t){return[e*Math.cos(t),e*Math.sin(t)]}function We(e){for(;e>2*Math.PI;)e-=2*Math.PI;return e}function Ih(e){return We(e)*180/Math.PI}function Ws(e){const t=Ih(We(e));return t>90&&t<270?t-180:t}const Lh={alignmentBaseline:"middle",textAnchor:"middle",dxFactor:1,dyFactor:1,rotation:0};function Fh({domainX:e,domainY:t,canvasWidth:n,canvasHeight:r,layoutClass:i,invert:a=!1,minRadius:s=0,angleRange:o=2*Math.PI,rootAngle:c=0,pollard:u=0,fishEye:l={x:0,y:0,scale:0}}){let h,f;switch(i){case H.Rectangular:{const d=e[1]*u;h=me().domain([d,e[1]]).range([0,n]),f=me().domain(t).range([0,r]);let m=g=>f(g);if(l.scale>0){const g=f.invert(l.y),x=Dh(l.scale,g),y=f.copy().domain(f.domain().map(x));m=b=>y(x(b))}return a&&h.range([n,0]),function(x){return{...x,x:h(x.x),y:m(x.y)}}}case H.Polar:return Rh(e[1],t[1],n,r,a,s,o,c,u);case H.Radial:{const d=me().domain(e).range([0,1]),m=me().domain(t).range([0,1]),g=Math.min(n,r),x=(n-g)/2,y=(r-g)/2,b=[x,g+x],p=[y,g+y];return f=me().domain([0,1]).range(p),h=me().domain([0,1]).range(b),function(C){return{...C,x:h(d(C.x)),y:f(m(C.y))}}}default:throw new Error("Not implemented in calcX")}}const Dh=(e,t)=>n=>{if(e===0)return n;const r=1/e,i=t-n,a=1-t/(r+t),s=1-(t-1)/(r-(t-1));return(1-(i<0?i/(r-i):i/(r+i))-a)/(s-a)};function Gs(e){const t=n=>{const r=P.useContext(Ie),i=P.useContext(bt),a=P.useContext(vt),{node:s,...o}=n,c=r(i(s));return S.jsx(e,{...o,x:c.x,y:c.y,animated:a})};return t.displayName=`withNode(${e.displayName||e.name||"Component"})`,t}function Qs(e){const t=n=>{const r=P.useContext(Ie),i=P.useContext(bt),a=P.useContext(vt),{domainX:s,layoutClass:o}=P.useContext(sn),{node:c,parent:u,aligned:l,gap:h=6,...f}=n,d=i(c),m=r(d);if(u===void 0){const g=m.nodeLabel??Lh,x=g.dxFactor*h,y=g.dyFactor*h,b=r({x:s[1],y:d.y}),p=(l?b.x:m.x)+x,w=(l&&o===H.Polar?b.y:m.y)+y,{alignmentBaseline:C,rotation:k,textAnchor:T}=g,L=l?`M${m.x} ${m.y}L${p} ${w}`:`M${m.x} ${m.y}L${m.x} ${m.y}`;return S.jsx(e,{alignmentBaseline:C,rotation:k,textAnchor:T,d:L,x:p,y:w,...f,animated:a})}else{const g=i(u),x=r(g),y=o===H.Polar?pe(m.theta,"The layout is polar but theta was not calculated for this node"):0,b=o===H.Polar?Ws(y):0,p=r({x:g.x,y:d.y}),{dx:w,dy:C}=o===H.Polar?Uh(y,h):{dx:0,dy:-1*h},k=(o===H.Polar?(m.x+p.x)/2:(m.x+x.x)/2)+w,T=(o===H.Polar?(m.y+p.y)/2:o===H.Radial?(m.y+x.y)/2:m.y)+C;return S.jsx(e,{alignmentBaseline:"baseline",rotation:b,textAnchor:"middle",x:k,y:T,...f,animated:a})}};return t.displayName=`withNodeLabel(${e.displayName||e.name||"Component"})`,t}function Uh(e,t){let n,r;return e>0&&e<Math.PI/2?(n=Math.sin(Math.PI/2-e)*t,r=-Math.cos(Math.PI/2-e)*t):e>Math.PI/2&&e<Math.PI?(n=-Math.cos(Math.PI/2-(Math.PI-e))*t,r=-Math.sin(Math.PI/2-(Math.PI-e))*t):e>Math.PI&&e<3*Math.PI/2?(n=Math.cos(Math.PI/2-(e-Math.PI))*t,r=-Math.sin(Math.PI/2-(e-Math.PI))*t):(n=-Math.cos(Math.PI/2-(2*Math.PI-e))*t,r=-Math.sin(Math.PI/2-(2*Math.PI-e))*t),{dx:n,dy:r}}function Ni(e){const t=n=>{const{nodes:r,keyBy:i=o=>o._id,attrs:a={},aligned:s}=n;return S.jsx("g",{className:"node-layer",children:r.map(o=>{const c=a[o._id]??{};return S.jsx(e,{node:o,...c,aligned:s},i(o))})})};return t.displayName=`withNodesArray(${e.displayName||e.name||"Component"})`,t}function Xs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pr,Sa;function Oh(){if(Sa)return pr;Sa=1,pr=e;function e(t){var n=0,r=0,i=0,a=0;return t.map(function(s){s=s.slice();var o=s[0],c=o.toUpperCase();if(o!=c)switch(s[0]=c,o){case"a":s[6]+=i,s[7]+=a;break;case"v":s[1]+=a;break;case"h":s[1]+=i;break;default:for(var u=1;u<s.length;)s[u++]+=i,s[u++]+=a}switch(c){case"Z":i=n,a=r;break;case"H":i=s[1];break;case"V":a=s[1];break;case"M":i=n=s[1],a=r=s[2];break;default:i=s[s.length-2],a=s[s.length-1]}return s})}return pr}var jh=Oh();const zh=Xs(jh);var Bh=(function(){function e(t,n){var r=[],i=!0,a=!1,s=void 0;try{for(var o=t[Symbol.iterator](),c;!(i=(c=o.next()).done)&&(r.push(c.value),!(n&&r.length===n));i=!0);}catch(u){a=!0,s=u}finally{try{!i&&o.return&&o.return()}finally{if(a)throw s}}return r}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),Dt=Math.PI*2,xr=function(t,n,r,i,a,s,o){var c=t.x,u=t.y;c*=n,u*=r;var l=i*c-a*u,h=a*c+i*u;return{x:l+s,y:h+o}},Vh=function(t,n){var r=n===1.5707963267948966?.551915024494:n===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(n/4),i=Math.cos(t),a=Math.sin(t),s=Math.cos(t+n),o=Math.sin(t+n);return[{x:i-a*r,y:a+i*r},{x:s+o*r,y:o-s*r},{x:s,y:o}]},$a=function(t,n,r,i){var a=t*i-n*r<0?-1:1,s=t*r+n*i;return s>1&&(s=1),s<-1&&(s=-1),a*Math.acos(s)},qh=function(t,n,r,i,a,s,o,c,u,l,h,f){var d=Math.pow(a,2),m=Math.pow(s,2),g=Math.pow(h,2),x=Math.pow(f,2),y=d*m-d*x-m*g;y<0&&(y=0),y/=d*x+m*g,y=Math.sqrt(y)*(o===c?-1:1);var b=y*a/s*f,p=y*-s/a*h,w=l*b-u*p+(t+r)/2,C=u*b+l*p+(n+i)/2,k=(h-b)/a,T=(f-p)/s,L=(-h-b)/a,I=(-f-p)/s,D=$a(1,0,k,T),_=$a(k,T,L,I);return c===0&&_>0&&(_-=Dt),c===1&&_<0&&(_+=Dt),[w,C,D,_]},Hh=function(t){var n=t.px,r=t.py,i=t.cx,a=t.cy,s=t.rx,o=t.ry,c=t.xAxisRotation,u=c===void 0?0:c,l=t.largeArcFlag,h=l===void 0?0:l,f=t.sweepFlag,d=f===void 0?0:f,m=[];if(s===0||o===0)return[];var g=Math.sin(u*Dt/360),x=Math.cos(u*Dt/360),y=x*(n-i)/2+g*(r-a)/2,b=-g*(n-i)/2+x*(r-a)/2;if(y===0&&b===0)return[];s=Math.abs(s),o=Math.abs(o);var p=Math.pow(y,2)/Math.pow(s,2)+Math.pow(b,2)/Math.pow(o,2);p>1&&(s*=Math.sqrt(p),o*=Math.sqrt(p));var w=qh(n,r,i,a,s,o,h,d,g,x,y,b),C=Bh(w,4),k=C[0],T=C[1],L=C[2],I=C[3],D=Math.abs(I)/(Dt/4);Math.abs(1-D)<1e-7&&(D=1);var _=Math.max(Math.ceil(D),1);I/=_;for(var A=0;A<_;A++)m.push(Vh(L,I)),L+=I;return m.map(function(M){var E=xr(M[0],s,o,x,g,k,T),K=E.x,Y=E.y,z=xr(M[1],s,o,x,g,k,T),W=z.x,G=z.y,xe=xr(M[2],s,o,x,g,k,T),Ce=xe.x,te=xe.y;return{x1:K,y1:Y,x2:W,y2:G,x:Ce,y:te}})};function Yh(e){for(var t,n=[],r=0,i=0,a=0,s=0,o=null,c=null,u=0,l=0,h=0,f=e.length;h<f;h++){var d=e[h],m=d[0];switch(m){case"M":a=d[1],s=d[2];break;case"A":var g=Hh({px:u,py:l,cx:d[6],cy:d[7],rx:d[1],ry:d[2],xAxisRotation:d[3],largeArcFlag:d[4],sweepFlag:d[5]});if(!g.length)continue;for(var x=0,y;x<g.length;x++)y=g[x],d=["C",y.x1,y.y1,y.x2,y.y2,y.x,y.y],x<g.length-1&&n.push(d);break;case"S":var b=u,p=l;(t=="C"||t=="S")&&(b+=b-r,p+=p-i),d=["C",b,p,d[1],d[2],d[3],d[4]];break;case"T":t=="Q"||t=="T"?(o=u*2-o,c=l*2-c):(o=u,c=l),d=ka(u,l,o,c,d[1],d[2]);break;case"Q":o=d[1],c=d[2],d=ka(u,l,d[1],d[2],d[3],d[4]);break;case"L":d=mn(u,l,d[1],d[2]);break;case"H":d=mn(u,l,d[1],l);break;case"V":d=mn(u,l,u,d[1]);break;case"Z":d=mn(u,l,a,s);break}t=m,u=d[d.length-2],l=d[d.length-1],d.length>4?(r=d[d.length-4],i=d[d.length-3]):(r=u,i=l),n.push(d)}return n}function mn(e,t,n,r){return["C",e,t,n,r,n,r]}function ka(e,t,n,r,i,a){return["C",e/3+2/3*n,t/3+2/3*r,i/3+2/3*n,a/3+2/3*r,i,a]}var br,Ta;function Wh(){if(Ta)return br;Ta=1,br=n;var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function n(a){var s=[];return a.replace(t,function(o,c,u){var l=c.toLowerCase();for(u=i(u),l=="m"&&u.length>2&&(s.push([c].concat(u.splice(0,2))),l="l",c=c=="m"?"l":"L");;){if(u.length==e[l])return u.unshift(c),s.push(u);if(u.length<e[l])throw new Error("malformed path data");s.push([c].concat(u.splice(0,e[l])))}}),s}var r=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function i(a){var s=a.match(r);return s?s.map(Number):[]}return br}var Gh=Wh();const Qh=Xs(Gh);class vn{x;y;constructor(t,n){this.x=t,this.y=n}}const vr=6;function Zs(e){const t=Qh(e),n=zh(t),r=Yh(n);let i=`${r[0][0]} ${r[0][1]} ${r[0][2]} `;const a=r.filter(s=>s[0]==="C").map(s=>[new vn(s[1],s[2]),new vn(s[3],s[4]),new vn(s[5],s[6])]);if(a.length>vr)throw new Error(`Path must have no more than ${vr} nodes (excluding start point) detected ${a.length} nodes update layout or path.helpers`);if(a.length==0)throw new Error("Path must have at least 1 node (excluding start point) update layout or path.helpers");for(;a.length<vr;){const s=pe(a.pop(),"Internal error in normalization"),{left:o,right:c}=Xh(s,.5);a.push(o),a.push(c.reverse())}for(let s=0;s<a.length;s++){const o=a[s];i+=`C${o[0].x},${o[0].y} ${o[1].x},${o[1].y} ${o[2].x},${o[2].y} `}return i}function Xh(e,t){const n=[],r=[];function i(a,s){if(a.length==1)n.push(a[0]),r.push(a[0]);else{const o=Array(a.length-1);for(let c=0;c<o.length;c++)c==0&&n.push(a[0]),c==o.length-1&&r.push(a[c+1]),o[c]=new vn((1-s)*a[c].x+s*a[c+1].x,(1-s)*a[c].y+s*a[c+1].y);i(o,s)}}return i(e,t),{left:n,right:r}}function Zh(e){const t=n=>{const r=P.useContext(Ie),i=P.useContext(bt),a=P.useContext(vt),{node:s,parent:o,curvature:c=0,...u}=n,l=i(s),{layoutClass:h}=l,f=o?i(o):{x:l.x,y:l.y},d={x:f.x,y:l.y},m=[f,l,d].map(x=>r(x)),g=Zs(Kh(m,c,h));return S.jsx(e,{d:g,animated:a,...u})};return t.displayName=`withBranchArray(${e.displayName||e.name||"Component"})`,t}function Kh(e,t,n){switch(n){case H.Rectangular:return Jh(e,t);case H.Polar:return ef(e);case H.Radial:return tf(e);default:throw new Error(`path generator not implemented for the ${n} of points`)}}function Jh(e,t){const n=e.length;switch(n){case 0:return"";case 3:{const[r,i]=e;return t===0?`M${r.x+.001},${r.y}L${r.x},${i.y}L${i.x},${i.y+.001}`:t<1?`M${r.x},${r.y}C${r.x},${i.y}, ${r.x+Math.abs(t*(r.x-i.x))},${i.y} ${i.x},${i.y}`:`M${r.x},${r.y}L${(r.x+i.x)/2},${(r.y+i.y)/2}L${i.x},${i.y}`}default:throw new Error(`path rectangular generator not implemented for this ${n} of points`)}}function ef(e){const t=e.length;switch(t){case 3:{const[n,r,i]=e,a=n.theta===r.theta||n.r===0?"":`A${n.r},${n.r} 0 0 ${n.theta<r.theta?1:0} ${i.x},${i.y}`;return`M${n.x},${n.y} ${a} L${r.x},${r.y}`}case 0:return"";default:throw new Error(`Error in polar path generator. not expecting ${t} points`)}}function tf(e){const t=e.length;switch(t){case 0:return"";case 3:{const[n,r]=e;return`M${n.x},${n.y}L${(n.x+r.x)/2},${(n.y+r.y)/2}L${r.x},${r.y}`}default:throw new Error(`path rectangular generator not implemented for this ${t} of points`)}}function Ks(e){const t=n=>{const{branches:r,keyBy:i=o=>o._id,attrs:a={},curvature:s}=n;return S.jsx("g",{className:"branch-layer",children:r.map(({node:o,parent:c})=>{const u=a[o._id]??{};return S.jsx(e,{node:o,parent:c,...u,curvature:s},i(o))})})};return t.displayName=`withBranchArray(${e.displayName||e.name||"Component"})`,t}function Js(e){const t=n=>{const{clades:r,keyBy:i=s=>s._id,attrs:a={}}=n;return S.jsx("g",{className:"node-layer",children:r.map(s=>{const o=a[s.root._id]??{};return S.jsx(e,{clade:s,...o},i(s.root))})})};return t.displayName=`withCladessArray(${e.displayName||e.name||"Component"})`,t}const nf=Ni(Gs(Su)),rf=Ni(Gs(Au));function af(e){switch(e.shape){case yt.Circle:return S.jsx(nf,{...e});case yt.Rectangle:return S.jsx(rf,{...e})}}const sf=Ks(Qs(gs)),of=Ni(Qs(gs)),uf=Ks(Zh(Wn));function cf(e){switch(e.target){case 0:return S.jsx(af,{...e});case 1:return S.jsx(uf,{...e});case 2:return S.jsx(of,{...e});case 3:return S.jsx(sf,{...e});case 4:return S.jsx(Tf,{...e})}}var ye=(e=>(e[e.Node=0]="Node",e[e.Branch=1]="Branch",e[e.NodeLabel=2]="NodeLabel",e[e.BranchLabel=3]="BranchLabel",e[e.Clade=4]="Clade",e[e.Axis=5]="Axis",e))(ye||{}),yt=(e=>(e[e.Circle=0]="Circle",e[e.Rectangle=1]="Rectangle",e))(yt||{}),pt=(e=>(e[e.Cartoon=0]="Cartoon",e[e.Highlight=1]="Highlight",e))(pt||{});function lf(e){const{clade:t,...n}=e,r=P.useContext(Ie),i=P.useContext(bt),a=P.useContext(vt),{root:s,leftMost:o,rightMost:c,mostDiverged:u}=t,l=r(i(s)),{x:h,y:f}=l,d=r(i(o)),m=r(i(c)),g=r(i(u)),{layoutClass:x}=i(s);let y;if(x===H.Rectangular){const p=g.x,w=m.y,C=d.y;y=`M${h},${f}L${p},${w}L${p},${C}Z`}else if(x===H.Polar){const p=d,w=m,C=p.theta===w.theta||p.r===0?"":`A${p.r},${p.r} 0 0 ${p.theta<w.theta?1:0} ${w.x},${w.y}`;y=`M${h},${f}L${p.x},${p.y} ${C} Z`}else return null;const b=Zs(y);return S.jsx(Wn,{d:b,...n,animated:a})}const hf=Js(lf);function Fe(e){return function(){return e}}const Pa=Math.abs,ee=Math.atan2,Be=Math.cos,ff=Math.max,wr=Math.min,Me=Math.sin,at=Math.sqrt,ie=1e-12,en=Math.PI,Fn=en/2,df=2*en;function mf(e){return e>1?0:e<-1?en:Math.acos(e)}function Aa(e){return e>=1?Fn:e<=-1?-Fn:Math.asin(e)}const Wr=Math.PI,Gr=2*Wr,qe=1e-6,gf=Gr-qe;function eo(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function yf(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return eo;const n=10**t;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class pf{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?eo:yf(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,a,s){this._append`C${+t},${+n},${+r},${+i},${this._x1=+a},${this._y1=+s}`}arcTo(t,n,r,i,a){if(t=+t,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let s=this._x1,o=this._y1,c=r-t,u=i-n,l=s-t,h=o-n,f=l*l+h*h;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(f>qe)if(!(Math.abs(h*c-u*l)>qe)||!a)this._append`L${this._x1=t},${this._y1=n}`;else{let d=r-s,m=i-o,g=c*c+u*u,x=d*d+m*m,y=Math.sqrt(g),b=Math.sqrt(f),p=a*Math.tan((Wr-Math.acos((g+f-x)/(2*y*b)))/2),w=p/b,C=p/y;Math.abs(w-1)>qe&&this._append`L${t+w*l},${n+w*h}`,this._append`A${a},${a},0,0,${+(h*d>l*m)},${this._x1=t+C*c},${this._y1=n+C*u}`}}arc(t,n,r,i,a,s){if(t=+t,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),c=r*Math.sin(i),u=t+o,l=n+c,h=1^s,f=s?i-a:a-i;this._x1===null?this._append`M${u},${l}`:(Math.abs(this._x1-u)>qe||Math.abs(this._y1-l)>qe)&&this._append`L${u},${l}`,r&&(f<0&&(f=f%Gr+Gr),f>gf?this._append`A${r},${r},0,1,${h},${t-o},${n-c}A${r},${r},0,1,${h},${this._x1=u},${this._y1=l}`:f>qe&&this._append`A${r},${r},0,${+(f>=Wr)},${h},${this._x1=t+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function xf(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new pf(t)}function bf(e){return e.innerRadius}function vf(e){return e.outerRadius}function wf(e){return e.startAngle}function _f(e){return e.endAngle}function Nf(e){return e&&e.padAngle}function Cf(e,t,n,r,i,a,s,o){var c=n-e,u=r-t,l=s-i,h=o-a,f=h*c-l*u;if(!(f*f<ie))return f=(l*(t-a)-h*(e-i))/f,[e+f*c,t+f*u]}function gn(e,t,n,r,i,a,s){var o=e-n,c=t-r,u=(s?a:-a)/at(o*o+c*c),l=u*c,h=-u*o,f=e+l,d=t+h,m=n+l,g=r+h,x=(f+m)/2,y=(d+g)/2,b=m-f,p=g-d,w=b*b+p*p,C=i-a,k=f*g-m*d,T=(p<0?-1:1)*at(ff(0,C*C*w-k*k)),L=(k*p-b*T)/w,I=(-k*b-p*T)/w,D=(k*p+b*T)/w,_=(-k*b+p*T)/w,A=L-x,M=I-y,E=D-x,K=_-y;return A*A+M*M>E*E+K*K&&(L=D,I=_),{cx:L,cy:I,x01:-l,y01:-h,x11:L*(i/C-1),y11:I*(i/C-1)}}function Mf(){var e=bf,t=vf,n=Fe(0),r=null,i=wf,a=_f,s=Nf,o=null,c=xf(u);function u(){var l,h,f=+e.apply(this,arguments),d=+t.apply(this,arguments),m=i.apply(this,arguments)-Fn,g=a.apply(this,arguments)-Fn,x=Pa(g-m),y=g>m;if(o||(o=l=c()),d<f&&(h=d,d=f,f=h),!(d>ie))o.moveTo(0,0);else if(x>df-ie)o.moveTo(d*Be(m),d*Me(m)),o.arc(0,0,d,m,g,!y),f>ie&&(o.moveTo(f*Be(g),f*Me(g)),o.arc(0,0,f,g,m,y));else{var b=m,p=g,w=m,C=g,k=x,T=x,L=s.apply(this,arguments)/2,I=L>ie&&(r?+r.apply(this,arguments):at(f*f+d*d)),D=wr(Pa(d-f)/2,+n.apply(this,arguments)),_=D,A=D,M,E;if(I>ie){var K=Aa(I/f*Me(L)),Y=Aa(I/d*Me(L));(k-=K*2)>ie?(K*=y?1:-1,w+=K,C-=K):(k=0,w=C=(m+g)/2),(T-=Y*2)>ie?(Y*=y?1:-1,b+=Y,p-=Y):(T=0,b=p=(m+g)/2)}var z=d*Be(b),W=d*Me(b),G=f*Be(C),xe=f*Me(C);if(D>ie){var Ce=d*Be(p),te=d*Me(p),je=f*Be(w),wt=f*Me(w),be;if(x<en)if(be=Cf(z,W,je,wt,Ce,te,G,xe)){var _t=z-be[0],Nt=W-be[1],Ct=Ce-be[0],$=te-be[1],F=1/Me(mf((_t*Ct+Nt*$)/(at(_t*_t+Nt*Nt)*at(Ct*Ct+$*$)))/2),U=at(be[0]*be[0]+be[1]*be[1]);_=wr(D,(f-U)/(F-1)),A=wr(D,(d-U)/(F+1))}else _=A=0}T>ie?A>ie?(M=gn(je,wt,z,W,d,A,y),E=gn(Ce,te,G,xe,d,A,y),o.moveTo(M.cx+M.x01,M.cy+M.y01),A<D?o.arc(M.cx,M.cy,A,ee(M.y01,M.x01),ee(E.y01,E.x01),!y):(o.arc(M.cx,M.cy,A,ee(M.y01,M.x01),ee(M.y11,M.x11),!y),o.arc(0,0,d,ee(M.cy+M.y11,M.cx+M.x11),ee(E.cy+E.y11,E.cx+E.x11),!y),o.arc(E.cx,E.cy,A,ee(E.y11,E.x11),ee(E.y01,E.x01),!y))):(o.moveTo(z,W),o.arc(0,0,d,b,p,!y)):o.moveTo(z,W),!(f>ie)||!(k>ie)?o.lineTo(G,xe):_>ie?(M=gn(G,xe,Ce,te,f,-_,y),E=gn(z,W,je,wt,f,-_,y),o.lineTo(M.cx+M.x01,M.cy+M.y01),_<D?o.arc(M.cx,M.cy,_,ee(M.y01,M.x01),ee(E.y01,E.x01),!y):(o.arc(M.cx,M.cy,_,ee(M.y01,M.x01),ee(M.y11,M.x11),!y),o.arc(0,0,f,ee(M.cy+M.y11,M.cx+M.x11),ee(E.cy+E.y11,E.cx+E.x11),y),o.arc(E.cx,E.cy,_,ee(E.y11,E.x11),ee(E.y01,E.x01),!y))):o.arc(0,0,f,C,w,y)}if(o.closePath(),l)return o=null,l+""||null}return u.centroid=function(){var l=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,h=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-en/2;return[Be(h)*l,Me(h)*l]},u.innerRadius=function(l){return arguments.length?(e=typeof l=="function"?l:Fe(+l),u):e},u.outerRadius=function(l){return arguments.length?(t=typeof l=="function"?l:Fe(+l),u):t},u.cornerRadius=function(l){return arguments.length?(n=typeof l=="function"?l:Fe(+l),u):n},u.padRadius=function(l){return arguments.length?(r=l==null?null:typeof l=="function"?l:Fe(+l),u):r},u.startAngle=function(l){return arguments.length?(i=typeof l=="function"?l:Fe(+l),u):i},u.endAngle=function(l){return arguments.length?(a=typeof l=="function"?l:Fe(+l),u):a},u.padAngle=function(l){return arguments.length?(s=typeof l=="function"?l:Fe(+l),u):s},u.context=function(l){return arguments.length?(o=l??null,u):o},u}const Sf=Mf();function $f(e){const{clade:t,...n}=e,r=P.useContext(Ie),i=P.useContext(bt),a=P.useContext(vt),{root:s,leftMost:o,rightMost:c,mostDiverged:u}=t,l=r(i(s)),h=r(i(o)),f=r(i(c)),d=r(i(u)),{layoutClass:m}=i(s);if(m===H.Rectangular){const g=d.x-l.x,x=Math.abs(h.y-f.y);return S.jsx(ci,{width:g,height:x,x:l.x,y:Math.min(h.y,f.y),...n,animated:a})}else if(m===H.Polar){const g=r({x:0,y:0}),x=`translate(${g.x},${g.y})`,y=l.r,b=d.r,p=h.theta,w=f.theta,C=Sf({innerRadius:y,outerRadius:b+5,startAngle:w+Math.PI/2,endAngle:p+Math.PI/2});return Z(C,"Error making arc shape for Clade Highlight"),S.jsx(Wn,{d:C,transform:x,...n,animated:a})}else return null}const kf=Js($f);function Tf(e){switch(e.shape){case pt.Cartoon:return S.jsx(hf,{...e});case pt.Highlight:return S.jsx(kf,{...e})}}function Pf(e){return typeof e=="function"}function Ee(e){return function(t){const n={};for(const r in e){const i=e[r];Pf(i)?n[r]=i(t):n[r]=i}return n}}function yn(e){return function(t){const n={};for(const r in e){const i=e[r];i!==void 0&&(n[r]=()=>{i(t)})}return n}}function Af(e,t){const n="filter"in e?e.filter:()=>!0;Z(n,"Issue with filter option when making baubles");const r="nodes"in e?e.nodes:t.getNodes().filter(n),i=yn(e.interactions??{});if(e.target===ye.Node)if(e.shape===yt.Circle){const a=Ee(e.attrs),s=r.reduce((o,c)=>{const u=a(c),l=i(c);return o[c._id]={...u,...l},o},{});return{nodes:r,attrs:s,id:e.id,target:e.target,shape:e.shape}}else{const a=Ee(e.attrs),s=r.reduce((o,c)=>{const u=a(c),l=i(c);return o[c._id]={...u,...l},o},{});return{nodes:r,attrs:s,id:e.id,target:e.target,shape:e.shape}}else if(e.target===ye.Branch){const a=r.filter(u=>!t.isRoot(u)).map(u=>({node:u,parent:t.getParent(u)})),s=Ee({fill:"none",...e.attrs}),o=yn(e.interactions??{}),c=r.reduce((u,l)=>{const h=s(l),f=o(l);return u[l._id]={...h,...f},u},{});return{branches:a,attrs:c,id:e.id,curvature:e.curvature,target:e.target}}else if(e.target===ye.NodeLabel){const a=Ee(e.attrs),s=Ee({text:e.text}),o=yn(e.interactions??{}),c=r.reduce((u,l)=>{const h=a(l),f=o(l),d=s(l);return u[l._id]={...h,...f,...d},u},{});return{nodes:r,attrs:c,id:e.id,target:e.target,aligned:e.aligned??!1}}else if(e.target===ye.BranchLabel){const a=r.filter(h=>!t.isRoot(h)),s=a.map(h=>({node:h,parent:t.getParent(h)})),o=Ee(e.attrs),c=yn(e.interactions??{}),u=Ee({text:e.text}),l=a.reduce((h,f)=>{const d=o(f),m=c(f),g=u(f);return h[f._id]={...d,...m,...g},h},{});return{branches:s,attrs:l,id:e.id,target:e.target}}else{const a=r.map(s=>{const o=[...Kn(t,s)],c=o[0],u=o[o.length-1],l=o[Vu(o,h=>t.getDivergence(h))];return{root:s,leftMost:c,rightMost:u,mostDiverged:l}});if(e.shape===pt.Highlight){const s=Ee(e.attrs),o=r.reduce((c,u)=>{const l=s(u),h=i(u);return c[u._id]={...l,...h},c},{});return{clades:a,attrs:o,id:e.id,target:e.target,shape:e.shape}}else{const s=Ee(e.attrs),o=r.reduce((c,u)=>{const l=s(u),h=i(u);return c[u._id]={...l,...h},c},{});return{clades:a,attrs:o,id:e.id,target:e.target,shape:e.shape}}}}function Ef(e){return{...e,shape:yt.Circle,target:ye.Node}}function Rf(e){return{...e,shape:yt.Rectangle,target:ye.Node}}function to(e){return{...e,target:ye.Branch}}function If(e){return{attrs:{},aligned:!1,...e,target:ye.NodeLabel}}function Lf(e){return{attrs:{},...e,target:ye.BranchLabel}}function Ff(e){return{...e,shape:pt.Highlight,target:ye.Clade}}function Df(e){return{...e,shape:pt.Cartoon,target:ye.Clade}}const le={offsetBy:0,scaleBy:1,reverse:!1,gap:5,title:{text:"",padding:40,style:{}},ticks:{number:5,format:Xt(".1f"),padding:20,style:{},length:6},attrs:{strokeWidth:1}},Dn={evenFill:"#EDEDED",oddFill:"none"};function Uf(e){const{attrs:t,evenFill:n=Dn.evenFill,oddFill:r=Dn.oddFill,tickValues:i,scale:a,figureScale:s,axisY:o}=e;return S.jsx("g",{className:"axisBars",children:i.filter((c,u,l)=>u<l.length-1).map((c,u)=>{const l=s({x:a(c),y:o}),h=s({x:a(c),y:0}),f=s({x:a(i[u+1]),y:0}),d=s({x:a(i[u+1]),y:o}),m=l.theta===h.theta||l.r===0?"":`A${l.r},${l.r} 0 1 0 ${h.x},${h.y}`,g=f.theta===d.theta||f.r===0?"":`A${f.r},${f.r} 0 1 1 ${d.x},${d.y}`,x=`M${l.x},${l.y} ${m} L${h.x},${h.y} L${f.x},${f.y} ${g} L ${l.x} ${l.y} Z`,y=u%2===0?n:r;return S.jsx(Wn,{d:x,fill:y,...t,animated:!1},u)})})}function Of(e){const t=P.useContext(sn),n=P.useContext(Ie),{bars:r,attrs:i}=e,a=e.ticks?{...le.ticks,...e.ticks}:le.ticks,s=e.title?{...le.title,...e.title}:le.title,o=no(e,t);let c;a.values!=null?c=a.values:c=o.ticks(a.number);const u=We(n({x:t.domainX[1],y:t.domainY[1]}).theta),l=t.domainY[1]+t.domainY[1]*.005,h=n({x:t.domainX[0],y:l}),f=n({x:t.domainX[1],y:l}),d=`M${h.x},${h.y} L${f.x},${f.y}`,m=a.length*Math.cos(u),g=a.length*Math.sin(u),x=a.padding*Math.cos(u),y=a.padding*Math.sin(u),b=pe(li(o.range()),"Error calculating x position for title"),p=n({x:b,y:l}),w=s.padding*Math.cos(u),C=s.padding*Math.sin(u);return S.jsxs("g",{className:"axis",children:[S.jsx(Uf,{...r,tickValues:c,scale:o,axisY:l}),":",S.jsx("path",{d,stroke:"black",...i}),S.jsxs("g",{children:[c.map((k,T)=>{const L=n({x:o(k),y:l});return S.jsxs("g",{transform:`translate(${L.x},${L.y}) rotate(90)`,children:[S.jsx("line",{x1:m,y1:g,x2:0,y2:0,stroke:"black",...i}),S.jsx("text",{transform:`translate(${x},${y}) rotate(-90)`,textAnchor:"middle",dominantBaseline:"central",...a.style,children:a.format(k)})]},`tick-${T}`)}),S.jsx("g",{transform:`translate(${p.x},${p.y}) rotate(90)`,children:S.jsx("text",{textAnchor:"middle",transform:`translate(${w},${C}) rotate(-90)`,children:s.text})})]})]})}function no(e,t){const{reverse:n=le.reverse,offsetBy:r=le.offsetBy,scaleBy:i=le.scaleBy,scale:a}=e,{domainX:s}=t,o=a===void 0?me().domain(s).range(s):a.copy();if(a===void 0){const u=s.map(l=>l+r).map(l=>(l-r)*i+r);o.domain(u),n&&o.domain([r-(u[1]-u[0]),r])}return o.nice()}function jf(e){const{attrs:t,evenFill:n=Dn.evenFill,oddFill:r=Dn.oddFill,tickValues:i,scale:a,axisY:s}=e,o=P.useContext(Ie);return S.jsx("g",{className:"axisBars",children:i.filter((c,u,l)=>u<l.length-1).map((c,u)=>{const l=o({x:a(c),y:s}),h=o({x:a(c),y:-.05}),f=o({x:a(i[u+1]),y:0}),d=u%2===0?n:r;return S.jsx(ci,{x:l.x,width:f.x-l.x,y:h.y,height:l.y-h.y,fill:d,rx:2,ry:2,...t,animated:!1},`recBar-${u}`)},[])},"axisBars")}function zf(e){const t=P.useContext(sn),n=P.useContext(Ie),{gap:r=le.gap,bars:i}=e,a={...le.attrs,...e.attrs},s=e.ticks?{...le.ticks,...e.ticks}:le.ticks,o=e.title?{...le.title,...e.title}:le.title,c=no(e,t);let u;s.values!==void 0?u=s.values:u=c.ticks(s.number);const l=t.domainY[1]+t.domainY[1]*.01,h=n({x:t.domainX[0],y:l}),f=n({x:t.domainX[1],y:l}),d=`M${h.x},${h.y+r} L${f.x},${f.y+r}`,m=pe(li(c.range()),"Error calculating x position for title"),g=n({x:m,y:l});return S.jsxs("g",{className:"axis",children:[i?S.jsx(jf,{...i,tickValues:u,scale:c,axisY:l}):null,S.jsx("path",{d,stroke:"black",...a}),S.jsxs("g",{children:[u.map((x,y)=>{const b=n({x:c(x),y:l});return S.jsxs("g",{transform:`translate(${b.x},${b.y+r})`,children:[S.jsx("line",{x1:0,y1:0,x2:0,y2:s.length,stroke:"black",...a}),S.jsx("text",{transform:`translate(0,${s.padding})`,textAnchor:"middle",dominantBaseline:"central",...s.style,children:s.format(x)})]},`tick-${y}`)}),S.jsx("g",{transform:`translate(${g.x},${g.y+r}) `,children:S.jsx("text",{textAnchor:"middle",transform:`translate(0,${o.padding})`,...o.style,children:o.text})})]})]})}function Bf(e){const t=P.useContext(sn),{layoutClass:n}=t;return n===H.Polar?S.jsx(Of,{...e}):n===H.Rectangular?S.jsx(zf,{...e}):(console.warn(`Axis not supported for ${n}`),null)}const Vf=bi.fromNewick("((A:1,B:1):1,C:2);"),re={opts:ys,width:100,layout:Bs,margins:{top:10,right:10,bottom:10,left:10},tree:Vf,baubles:[to({filter:()=>!0,attrs:{stroke:"black",strokeWidth:1}})],animated:!1};function qf(e){const{width:t=re.width,height:n=re.width,margins:r=re.margins,tree:i=re.tree,layout:a=re.layout,animated:s=re.animated,baubles:o=re.baubles,axis:c}=e,u=e.opts?e.opts:re.opts,{rootAngle:l=re.opts.rootAngle,angleRange:h=re.opts.angleRange,fishEye:f=re.opts.fishEye,pollard:d=re.opts.pollard,minRadius:m=re.opts.minRadius,invert:g=re.opts.invert}=u;let x,y,{x:b,y:p}=e;b!==void 0&&p!==void 0?(x=t,y=n):(x=t-r.left-r.right,y=n-r.top-r.bottom,b=r.left,p=r.top);const w=a(i,u),{layoutClass:C}=w(i.getRoot()),k=lt(i.getNodes().map(_=>w(_).x)).map(_=>pe(_,"Error finding x extent from layout")),T=lt(i.getNodes().map(_=>w(_).y)).map(_=>pe(_,"Error finding y extent from layout")),L={canvasWidth:x,canvasHeight:y,domainX:k,domainY:T,layoutClass:C,invert:g,pollard:d,minRadius:m,fishEye:f,rootAngle:l,angleRange:h},I=Fh(L),D=o.map(_=>Af(_,i));return S.jsx("g",{children:S.jsx("g",{transform:`translate(${b},${p})`,children:S.jsx(Ie.Provider,{value:I,children:S.jsx(sn.Provider,{value:L,children:S.jsx(bt.Provider,{value:w,children:S.jsxs(vt.Provider,{value:s,children:[c?S.jsx(Bf,{...c}):null,D.map((_,A)=>S.jsx(cf,{..._},_.id??A))]})})})})})})}exports.BaseAnnotationType=V;exports.BranchLabels=Lf;exports.Branches=to;exports.CartoonClades=Df;exports.CircleNodes=Ef;exports.FigTree=qf;exports.HighlightClades=Ff;exports.ImmutableTree=bi;exports.NexusImporter=ql;exports.NodeLabels=If;exports.PreOrderTraversalCache=Hl;exports.RectangleNodes=Rf;exports.TaxonSet=rn;exports.dateToDecimal=ol;exports.decimalToDate=sl;exports.defaultInternalLayoutOptions=ys;exports.layoutClass=H;exports.leapYear=mi;exports.pathToRootIterator=jl;exports.polarLayout=Yl;exports.postOrderIterator=js;exports.preOrderIterator=Os;exports.psuedoRootPostOrderIterator=Ol;exports.psuedoRootPreOrderIterator=Ul;exports.radialLayout=Wl;exports.rectangularLayout=Bs;exports.tipIterator=Kn;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),P=require("react"),ao=require("react-dom");function so(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ea=so(P);var Qr=rn(),R=e=>nn(e,Qr),Xr=rn();R.write=e=>nn(e,Xr);var On=rn();R.onStart=e=>nn(e,On);var Zr=rn();R.onFrame=e=>nn(e,Zr);var Kr=rn();R.onFinish=e=>nn(e,Kr);var st=[];R.setTimeout=(e,t)=>{const n=R.now()+t,r=()=>{const a=st.findIndex(s=>s.cancel==r);~a&&st.splice(a,1),Ue-=~a?1:0},i={time:n,handler:e,cancel:r};return st.splice(Ia(n),0,i),Ue+=1,La(),i};var Ia=e=>~(~st.findIndex(t=>t.time>e)||~st.length);R.cancel=e=>{On.delete(e),Zr.delete(e),Kr.delete(e),Qr.delete(e),Xr.delete(e)};R.sync=e=>{_r=!0,R.batchedUpdates(e),_r=!1};R.throttle=e=>{let t;function n(){try{e(...t)}finally{t=null}}function r(...i){t=i,R.onStart(n)}return r.handler=e,r.cancel=()=>{On.delete(n),t=null},r};var Jr=typeof window<"u"?window.requestAnimationFrame:(()=>{});R.use=e=>Jr=e;R.now=typeof performance<"u"?()=>performance.now():Date.now;R.batchedUpdates=e=>e();R.catch=console.error;R.frameLoop="always";R.advance=()=>{R.frameLoop!=="demand"?console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"):Da()};var De=-1,Ue=0,_r=!1;function nn(e,t){_r?(t.delete(e),e(0)):(t.add(e),La())}function La(){De<0&&(De=0,R.frameLoop!=="demand"&&Jr(Fa))}function oo(){De=-1}function Fa(){~De&&(Jr(Fa),R.batchedUpdates(Da))}function Da(){const e=De;De=R.now();const t=Ia(De);if(t&&(Ua(st.splice(0,t),n=>n.handler()),Ue-=t),!Ue){oo();return}On.flush(),Qr.flush(e?Math.min(64,De-e):16.667),Zr.flush(),Xr.flush(),Kr.flush()}function rn(){let e=new Set,t=e;return{add(n){Ue+=t==e&&!e.has(n)?1:0,e.add(n)},delete(n){return Ue-=t==e&&e.has(n)?1:0,e.delete(n)},flush(n){t.size&&(e=new Set,Ue-=t.size,Ua(t,r=>r(n)&&e.add(r)),Ue+=e.size,t=e)}}}function Ua(e,t){e.forEach(n=>{try{t(n)}catch(r){R.catch(r)}})}var uo=Object.defineProperty,lo=(e,t)=>{for(var n in t)uo(e,n,{get:t[n],enumerable:!0})},Ne={};lo(Ne,{assign:()=>ho,colors:()=>Oe,createStringInterpolator:()=>ti,skipAnimation:()=>ja,to:()=>Oa,willAdvance:()=>ni});function Nr(){}var co=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0}),_={arr:Array.isArray,obj:e=>!!e&&e.constructor.name==="Object",fun:e=>typeof e=="function",str:e=>typeof e=="string",num:e=>typeof e=="number",und:e=>e===void 0};function Ee(e,t){if(_.arr(e)){if(!_.arr(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return e===t}var O=(e,t)=>e.forEach(t);function Te(e,t,n){if(_.arr(e)){for(let r=0;r<e.length;r++)t.call(n,e[r],`${r}`);return}for(const r in e)e.hasOwnProperty(r)&&t.call(n,e[r],r)}var he=e=>_.und(e)?[]:_.arr(e)?e:[e];function It(e,t){if(e.size){const n=Array.from(e);e.clear(),O(n,t)}}var Et=(e,...t)=>It(e,n=>n(...t)),ei=()=>typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),ti,Oa,Oe=null,ja=!1,ni=Nr,ho=e=>{e.to&&(Oa=e.to),e.now&&(R.now=e.now),e.colors!==void 0&&(Oe=e.colors),e.skipAnimation!=null&&(ja=e.skipAnimation),e.createStringInterpolator&&(ti=e.createStringInterpolator),e.requestAnimationFrame&&R.use(e.requestAnimationFrame),e.batchedUpdates&&(R.batchedUpdates=e.batchedUpdates),e.willAdvance&&(ni=e.willAdvance),e.frameLoop&&(R.frameLoop=e.frameLoop)},Lt=new Set,pe=[],Jn=[],_n=0,jn={get idle(){return!Lt.size&&!pe.length},start(e){_n>e.priority?(Lt.add(e),R.onStart(fo)):(za(e),R(Cr))},advance:Cr,sort(e){if(_n)R.onFrame(()=>jn.sort(e));else{const t=pe.indexOf(e);~t&&(pe.splice(t,1),Ba(e))}},clear(){pe=[],Lt.clear()}};function fo(){Lt.forEach(za),Lt.clear(),R(Cr)}function za(e){pe.includes(e)||Ba(e)}function Ba(e){pe.splice(go(pe,t=>t.priority>e.priority),0,e)}function Cr(e){const t=Jn;for(let n=0;n<pe.length;n++){const r=pe[n];_n=r.priority,r.idle||(ni(r),r.advance(e),r.idle||t.push(r))}return _n=0,Jn=pe,Jn.length=0,pe=t,pe.length>0}function go(e,t){const n=e.findIndex(t);return n<0?e.length:n}var mo={transparent:0,aliceblue:4042850303,antiquewhite:4209760255,aqua:16777215,aquamarine:2147472639,azure:4043309055,beige:4126530815,bisque:4293182719,black:255,blanchedalmond:4293643775,blue:65535,blueviolet:2318131967,brown:2771004159,burlywood:3736635391,burntsienna:3934150143,cadetblue:1604231423,chartreuse:2147418367,chocolate:3530104575,coral:4286533887,cornflowerblue:1687547391,cornsilk:4294499583,crimson:3692313855,cyan:16777215,darkblue:35839,darkcyan:9145343,darkgoldenrod:3095792639,darkgray:2846468607,darkgreen:6553855,darkgrey:2846468607,darkkhaki:3182914559,darkmagenta:2332068863,darkolivegreen:1433087999,darkorange:4287365375,darkorchid:2570243327,darkred:2332033279,darksalmon:3918953215,darkseagreen:2411499519,darkslateblue:1211993087,darkslategray:793726975,darkslategrey:793726975,darkturquoise:13554175,darkviolet:2483082239,deeppink:4279538687,deepskyblue:12582911,dimgray:1768516095,dimgrey:1768516095,dodgerblue:512819199,firebrick:2988581631,floralwhite:4294635775,forestgreen:579543807,fuchsia:4278255615,gainsboro:3705462015,ghostwhite:4177068031,gold:4292280575,goldenrod:3668254975,gray:2155905279,green:8388863,greenyellow:2919182335,grey:2155905279,honeydew:4043305215,hotpink:4285117695,indianred:3445382399,indigo:1258324735,ivory:4294963455,khaki:4041641215,lavender:3873897215,lavenderblush:4293981695,lawngreen:2096890111,lemonchiffon:4294626815,lightblue:2916673279,lightcoral:4034953471,lightcyan:3774873599,lightgoldenrodyellow:4210742015,lightgray:3553874943,lightgreen:2431553791,lightgrey:3553874943,lightpink:4290167295,lightsalmon:4288707327,lightseagreen:548580095,lightskyblue:2278488831,lightslategray:2005441023,lightslategrey:2005441023,lightsteelblue:2965692159,lightyellow:4294959359,lime:16711935,limegreen:852308735,linen:4210091775,magenta:4278255615,maroon:2147483903,mediumaquamarine:1724754687,mediumblue:52735,mediumorchid:3126187007,mediumpurple:2473647103,mediumseagreen:1018393087,mediumslateblue:2070474495,mediumspringgreen:16423679,mediumturquoise:1221709055,mediumvioletred:3340076543,midnightblue:421097727,mintcream:4127193855,mistyrose:4293190143,moccasin:4293178879,navajowhite:4292783615,navy:33023,oldlace:4260751103,olive:2155872511,olivedrab:1804477439,orange:4289003775,orangered:4282712319,orchid:3664828159,palegoldenrod:4008225535,palegreen:2566625535,paleturquoise:2951671551,palevioletred:3681588223,papayawhip:4293907967,peachpuff:4292524543,peru:3448061951,pink:4290825215,plum:3718307327,powderblue:2967529215,purple:2147516671,rebeccapurple:1714657791,red:4278190335,rosybrown:3163525119,royalblue:1097458175,saddlebrown:2336560127,salmon:4202722047,sandybrown:4104413439,seagreen:780883967,seashell:4294307583,sienna:2689740287,silver:3233857791,skyblue:2278484991,slateblue:1784335871,slategray:1887473919,slategrey:1887473919,snow:4294638335,springgreen:16744447,steelblue:1182971135,tan:3535047935,teal:8421631,thistle:3636451583,tomato:4284696575,turquoise:1088475391,violet:4001558271,wheat:4125012991,white:4294967295,whitesmoke:4126537215,yellow:4294902015,yellowgreen:2597139199},_e="[-+]?\\d*\\.?\\d+",Nn=_e+"%";function zn(...e){return"\\(\\s*("+e.join(")\\s*,\\s*(")+")\\s*\\)"}var po=new RegExp("rgb"+zn(_e,_e,_e)),yo=new RegExp("rgba"+zn(_e,_e,_e,_e)),xo=new RegExp("hsl"+zn(_e,Nn,Nn)),bo=new RegExp("hsla"+zn(_e,Nn,Nn,_e)),vo=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,wo=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,_o=/^#([0-9a-fA-F]{6})$/,No=/^#([0-9a-fA-F]{8})$/;function Co(e){let t;return typeof e=="number"?e>>>0===e&&e>=0&&e<=4294967295?e:null:(t=_o.exec(e))?parseInt(t[1]+"ff",16)>>>0:Oe&&Oe[e]!==void 0?Oe[e]:(t=po.exec(e))?(nt(t[1])<<24|nt(t[2])<<16|nt(t[3])<<8|255)>>>0:(t=yo.exec(e))?(nt(t[1])<<24|nt(t[2])<<16|nt(t[3])<<8|ki(t[4]))>>>0:(t=vo.exec(e))?parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+"ff",16)>>>0:(t=No.exec(e))?parseInt(t[1],16)>>>0:(t=wo.exec(e))?parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+t[4]+t[4],16)>>>0:(t=xo.exec(e))?(Si($i(t[1]),ln(t[2]),ln(t[3]))|255)>>>0:(t=bo.exec(e))?(Si($i(t[1]),ln(t[2]),ln(t[3]))|ki(t[4]))>>>0:null}function er(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Si(e,t,n){const r=n<.5?n*(1+t):n+t-n*t,i=2*n-r,a=er(i,r,e+1/3),s=er(i,r,e),o=er(i,r,e-1/3);return Math.round(a*255)<<24|Math.round(s*255)<<16|Math.round(o*255)<<8}function nt(e){const t=parseInt(e,10);return t<0?0:t>255?255:t}function $i(e){return(parseFloat(e)%360+360)%360/360}function ki(e){const t=parseFloat(e);return t<0?0:t>1?255:Math.round(t*255)}function ln(e){const t=parseFloat(e);return t<0?0:t>100?1:t/100}function Ti(e){let t=Co(e);if(t===null)return e;t=t||0;const n=(t&4278190080)>>>24,r=(t&16711680)>>>16,i=(t&65280)>>>8,a=(t&255)/255;return`rgba(${n}, ${r}, ${i}, ${a})`}var Ot=(e,t,n)=>{if(_.fun(e))return e;if(_.arr(e))return Ot({range:e,output:t,extrapolate:n});if(_.str(e.output[0]))return ti(e);const r=e,i=r.output,a=r.range||[0,1],s=r.extrapolateLeft||r.extrapolate||"extend",o=r.extrapolateRight||r.extrapolate||"extend",l=r.easing||(u=>u);return u=>{const c=So(u,a);return Mo(u,a[c],a[c+1],i[c],i[c+1],l,s,o,r.map)}};function Mo(e,t,n,r,i,a,s,o,l){let u=l?l(e):e;if(u<t){if(s==="identity")return u;s==="clamp"&&(u=t)}if(u>n){if(o==="identity")return u;o==="clamp"&&(u=n)}return r===i?r:t===n?e<=t?r:i:(t===-1/0?u=-u:n===1/0?u=u-t:u=(u-t)/(n-t),u=a(u),r===-1/0?u=-u:i===1/0?u=u+r:u=u*(i-r)+r,u)}function So(e,t){for(var n=1;n<t.length-1&&!(t[n]>=e);++n);return n-1}var $o={linear:e=>e},jt=Symbol.for("FluidValue.get"),lt=Symbol.for("FluidValue.observers"),ge=e=>!!(e&&e[jt]),ae=e=>e&&e[jt]?e[jt]():e,Pi=e=>e[lt]||null;function ko(e,t){e.eventObserved?e.eventObserved(t):e(t)}function zt(e,t){const n=e[lt];n&&n.forEach(r=>{ko(r,t)})}var Va=class{constructor(e){if(!e&&!(e=this.get))throw Error("Unknown getter");To(this,e)}},To=(e,t)=>qa(e,jt,t);function bt(e,t){if(e[jt]){let n=e[lt];n||qa(e,lt,n=new Set),n.has(t)||(n.add(t),e.observerAdded&&e.observerAdded(n.size,t))}return t}function Bt(e,t){const n=e[lt];if(n&&n.has(t)){const r=n.size-1;r?n.delete(t):e[lt]=null,e.observerRemoved&&e.observerRemoved(r,t)}}var qa=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0}),xn=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,Po=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,Ai=new RegExp(`(${xn.source})(%|[a-z]+)`,"i"),Ao=/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi,Bn=/var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/,Ha=e=>{const[t,n]=Ro(e);if(!t||ei())return e;const r=window.getComputedStyle(document.documentElement).getPropertyValue(t);if(r)return r.trim();if(n&&n.startsWith("--")){const i=window.getComputedStyle(document.documentElement).getPropertyValue(n);return i||e}else{if(n&&Bn.test(n))return Ha(n);if(n)return n}return e},Ro=e=>{const t=Bn.exec(e);if(!t)return[,];const[,n,r]=t;return[n,r]},tr,Eo=(e,t,n,r,i)=>`rgba(${Math.round(t)}, ${Math.round(n)}, ${Math.round(r)}, ${i})`,Ya=e=>{tr||(tr=Oe?new RegExp(`(${Object.keys(Oe).join("|")})(?!\\w)`,"g"):/^\b$/);const t=e.output.map(a=>ae(a).replace(Bn,Ha).replace(Po,Ti).replace(tr,Ti)),n=t.map(a=>a.match(xn).map(Number)),i=n[0].map((a,s)=>n.map(o=>{if(!(s in o))throw Error('The arity of each "output" value must be equal');return o[s]})).map(a=>Ot({...e,output:a}));return a=>{const s=!Ai.test(t[0])&&t.find(l=>Ai.test(l))?.replace(xn,"");let o=0;return t[0].replace(xn,()=>`${i[o++](a)}${s||""}`).replace(Ao,Eo)}},ri="react-spring: ",Wa=e=>{const t=e;let n=!1;if(typeof t!="function")throw new TypeError(`${ri}once requires a function parameter`);return(...r)=>{n||(t(...r),n=!0)}},Io=Wa(console.warn);function Lo(){Io(`${ri}The "interpolate" function is deprecated in v9 (use "to" instead)`)}var Fo=Wa(console.warn);function Do(){Fo(`${ri}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`)}function Vn(e){return _.str(e)&&(e[0]=="#"||/\d/.test(e)||!ei()&&Bn.test(e)||e in(Oe||{}))}var ii=ei()?P.useEffect:P.useLayoutEffect,Uo=()=>{const e=P.useRef(!1);return ii(()=>(e.current=!0,()=>{e.current=!1}),[]),e};function Ga(){const e=P.useState()[1],t=Uo();return()=>{t.current&&e(Math.random())}}var Qa=e=>P.useEffect(e,Oo),Oo=[];function Ri(e){const t=P.useRef(void 0);return P.useEffect(()=>{t.current=e}),t.current}var Vt=Symbol.for("Animated:node"),jo=e=>!!e&&e[Vt]===e,Se=e=>e&&e[Vt],ai=(e,t)=>co(e,Vt,t),qn=e=>e&&e[Vt]&&e[Vt].getPayload(),Xa=class{constructor(){ai(this,this)}getPayload(){return this.payload||[]}},Hn=class Za extends Xa{constructor(t){super(),this._value=t,this.done=!0,this.durationProgress=0,_.num(this._value)&&(this.lastPosition=this._value)}static create(t){return new Za(t)}getPayload(){return[this]}getValue(){return this._value}setValue(t,n){return _.num(t)&&(this.lastPosition=t,n&&(t=Math.round(t/n)*n,this.done&&(this.lastPosition=t))),this._value===t?!1:(this._value=t,!0)}reset(){const{done:t}=this;this.done=!1,_.num(this._value)&&(this.elapsedTime=0,this.durationProgress=0,this.lastPosition=this._value,t&&(this.lastVelocity=null),this.v0=null)}},Cn=class Ka extends Hn{constructor(t){super(0),this._string=null,this._toString=Ot({output:[t,t]})}static create(t){return new Ka(t)}getValue(){const t=this._string;return t??(this._string=this._toString(this._value))}setValue(t){if(_.str(t)){if(t==this._string)return!1;this._string=t,this._value=1}else if(super.setValue(t))this._string=null;else return!1;return!0}reset(t){t&&(this._toString=Ot({output:[this.getValue(),t]})),this._value=0,super.reset()}},Mn={dependencies:null},Yn=class extends Xa{constructor(e){super(),this.source=e,this.setValue(e)}getValue(e){const t={};return Te(this.source,(n,r)=>{jo(n)?t[r]=n.getValue(e):ge(n)?t[r]=ae(n):e||(t[r]=n)}),t}setValue(e){this.source=e,this.payload=this._makePayload(e)}reset(){this.payload&&O(this.payload,e=>e.reset())}_makePayload(e){if(e){const t=new Set;return Te(e,this._addToPayload,t),Array.from(t)}}_addToPayload(e){Mn.dependencies&&ge(e)&&Mn.dependencies.add(e);const t=qn(e);t&&O(t,n=>this.add(n))}},zo=class Ja extends Yn{constructor(t){super(t)}static create(t){return new Ja(t)}getValue(){return this.source.map(t=>t.getValue())}setValue(t){const n=this.getPayload();return t.length==n.length?n.map((r,i)=>r.setValue(t[i])).some(Boolean):(super.setValue(t.map(Bo)),!0)}};function Bo(e){return(Vn(e)?Cn:Hn).create(e)}function Mr(e){const t=Se(e);return t?t.constructor:_.arr(e)?zo:Vn(e)?Cn:Hn}var Ei=(e,t)=>{const n=!_.fun(e)||e.prototype&&e.prototype.isReactComponent;return P.forwardRef((r,i)=>{const a=P.useRef(null),s=n&&P.useCallback(g=>{a.current=Ho(i,g)},[i]),[o,l]=qo(r,t),u=Ga(),c=()=>{const g=a.current;if(n&&!g)return;(g?t.applyAnimatedValues(g,o.getValue(!0)):!1)===!1&&u()},h=new Vo(c,l),f=P.useRef(void 0);ii(()=>(f.current=h,O(l,g=>bt(g,h)),()=>{f.current&&(O(f.current.deps,g=>Bt(g,f.current)),R.cancel(f.current.update))})),P.useEffect(c,[]),Qa(()=>()=>{const g=f.current;O(g.deps,m=>Bt(m,g))});const d=t.getComponentProps(o.getValue());return Ea.createElement(e,{...d,ref:s})})},Vo=class{constructor(e,t){this.update=e,this.deps=t}eventObserved(e){e.type=="change"&&R.write(this.update)}};function qo(e,t){const n=new Set;return Mn.dependencies=n,e.style&&(e={...e,style:t.createAnimatedStyle(e.style)}),e=new Yn(e),Mn.dependencies=null,[e,n]}function Ho(e,t){return e&&(_.fun(e)?e(t):e.current=t),t}var Ii=Symbol.for("AnimatedComponent"),Yo=(e,{applyAnimatedValues:t=()=>!1,createAnimatedStyle:n=i=>new Yn(i),getComponentProps:r=i=>i}={})=>{const i={applyAnimatedValues:t,createAnimatedStyle:n,getComponentProps:r},a=s=>{const o=Li(s)||"Anonymous";return _.str(s)?s=a[s]||(a[s]=Ei(s,i)):s=s[Ii]||(s[Ii]=Ei(s,i)),s.displayName=`Animated(${o})`,s};return Te(e,(s,o)=>{_.arr(e)&&(o=Li(s)),a[o]=a(s)}),{animated:a}},Li=e=>_.str(e)?e:e&&_.str(e.displayName)?e.displayName:_.fun(e)&&e.name||null;function He(e,...t){return _.fun(e)?e(...t):e}var Ft=(e,t)=>e===!0||!!(t&&e&&(_.fun(e)?e(t):he(e).includes(t))),es=(e,t)=>_.obj(e)?t&&e[t]:e,ts=(e,t)=>e.default===!0?e[t]:e.default?e.default[t]:void 0,Wo=e=>e,si=(e,t=Wo)=>{let n=Go;e.default&&e.default!==!0&&(e=e.default,n=Object.keys(e));const r={};for(const i of n){const a=t(e[i],i);_.und(a)||(r[i]=a)}return r},Go=["config","onProps","onStart","onChange","onPause","onResume","onRest"],Qo={config:1,from:1,to:1,ref:1,loop:1,reset:1,pause:1,cancel:1,reverse:1,immediate:1,default:1,delay:1,onProps:1,onStart:1,onChange:1,onPause:1,onResume:1,onRest:1,onResolve:1,items:1,trail:1,sort:1,expires:1,initial:1,enter:1,update:1,leave:1,children:1,onDestroyed:1,keys:1,callId:1,parentId:1};function Xo(e){const t={};let n=0;if(Te(e,(r,i)=>{Qo[i]||(t[i]=r,n++)}),n)return t}function ns(e){const t=Xo(e);if(t){const n={to:t};return Te(e,(r,i)=>i in t||(n[i]=r)),n}return{...e}}function qt(e){return e=ae(e),_.arr(e)?e.map(qt):Vn(e)?Ne.createStringInterpolator({range:[0,1],output:[e,e]})(1):e}function Zo(e){for(const t in e)return!0;return!1}function Sr(e){return _.fun(e)||_.arr(e)&&_.obj(e[0])}function Ko(e,t){e.ref?.delete(e),t?.delete(e)}function Jo(e,t){t&&e.ref!==t&&(e.ref?.delete(e),t.add(e),e.ref=t)}var eu={default:{tension:170,friction:26}},$r={...eu.default,mass:1,damping:1,easing:$o.linear,clamp:!1},tu=class{constructor(){this.velocity=0,Object.assign(this,$r)}};function nu(e,t,n){n&&(n={...n},Fi(n,t),t={...n,...t}),Fi(e,t),Object.assign(e,t);for(const s in $r)e[s]==null&&(e[s]=$r[s]);let{frequency:r,damping:i}=e;const{mass:a}=e;return _.und(r)||(r<.01&&(r=.01),i<0&&(i=0),e.tension=Math.pow(2*Math.PI/r,2)*a,e.friction=4*Math.PI*i*a/r),e}function Fi(e,t){if(!_.und(t.decay))e.duration=void 0;else{const n=!_.und(t.tension)||!_.und(t.friction);(n||!_.und(t.frequency)||!_.und(t.damping)||!_.und(t.mass))&&(e.duration=void 0,e.decay=void 0),n&&(e.frequency=void 0)}}var Di=[],ru=class{constructor(){this.changed=!1,this.values=Di,this.toValues=null,this.fromValues=Di,this.config=new tu,this.immediate=!1}};function rs(e,{key:t,props:n,defaultProps:r,state:i,actions:a}){return new Promise((s,o)=>{let l,u,c=Ft(n.cancel??r?.cancel,t);if(c)d();else{_.und(n.pause)||(i.paused=Ft(n.pause,t));let g=r?.pause;g!==!0&&(g=i.paused||Ft(g,t)),l=He(n.delay||0,t),g?(i.resumeQueue.add(f),a.pause()):(a.resume(),f())}function h(){i.resumeQueue.add(f),i.timeouts.delete(u),u.cancel(),l=u.time-R.now()}function f(){l>0&&!Ne.skipAnimation?(i.delayed=!0,u=R.setTimeout(d,l),i.pauseQueue.add(h),i.timeouts.add(u)):d()}function d(){i.delayed&&(i.delayed=!1),i.pauseQueue.delete(h),i.timeouts.delete(u),e<=(i.cancelId||0)&&(c=!0);try{a.start({...n,callId:e,cancel:c},s)}catch(g){o(g)}}})}var oi=(e,t)=>t.length==1?t[0]:t.some(n=>n.cancelled)?ot(e.get()):t.every(n=>n.noop)?is(e.get()):ve(e.get(),t.every(n=>n.finished)),is=e=>({value:e,noop:!0,finished:!0,cancelled:!1}),ve=(e,t,n=!1)=>({value:e,finished:t,cancelled:n}),ot=e=>({value:e,cancelled:!0,finished:!1});function as(e,t,n,r){const{callId:i,parentId:a,onRest:s}=t,{asyncTo:o,promise:l}=n;return!a&&e===o&&!t.reset?l:n.promise=(async()=>{n.asyncId=i,n.asyncTo=e;const u=si(t,(x,p)=>p==="onRest"?void 0:x);let c,h;const f=new Promise((x,p)=>(c=x,h=p)),d=x=>{const p=i<=(n.cancelId||0)&&ot(r)||i!==n.asyncId&&ve(r,!1);if(p)throw x.result=p,h(x),x},g=(x,p)=>{const b=new Ui,y=new Oi;return(async()=>{if(Ne.skipAnimation)throw Ht(n),y.result=ve(r,!1),h(y),y;d(b);const w=_.obj(x)?{...x}:{...p,to:x};w.parentId=i,Te(u,(k,A)=>{_.und(w[A])&&(w[A]=k)});const C=await r.start(w);return d(b),n.paused&&await new Promise(k=>{n.resumeQueue.add(k)}),C})()};let m;if(Ne.skipAnimation)return Ht(n),ve(r,!1);try{let x;_.arr(e)?x=(async p=>{for(const b of p)await g(b)})(e):x=Promise.resolve(e(g,r.stop.bind(r))),await Promise.all([x.then(c),f]),m=ve(r.get(),!0,!1)}catch(x){if(x instanceof Ui)m=x.result;else if(x instanceof Oi)m=x.result;else throw x}finally{i==n.asyncId&&(n.asyncId=a,n.asyncTo=a?o:void 0,n.promise=a?l:void 0)}return _.fun(s)&&R.batchedUpdates(()=>{s(m,r,r.item)}),m})()}function Ht(e,t){It(e.timeouts,n=>n.cancel()),e.pauseQueue.clear(),e.resumeQueue.clear(),e.asyncId=e.asyncTo=e.promise=void 0,t&&(e.cancelId=t)}var Ui=class extends Error{constructor(){super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.")}},Oi=class extends Error{constructor(){super("SkipAnimationSignal")}},kr=e=>e instanceof ui,iu=1,ui=class extends Va{constructor(){super(...arguments),this.id=iu++,this._priority=0}get priority(){return this._priority}set priority(e){this._priority!=e&&(this._priority=e,this._onPriorityChange(e))}get(){const e=Se(this);return e&&e.getValue()}to(...e){return Ne.to(this,e)}interpolate(...e){return Lo(),Ne.to(this,e)}toJSON(){return this.get()}observerAdded(e){e==1&&this._attach()}observerRemoved(e){e==0&&this._detach()}_attach(){}_detach(){}_onChange(e,t=!1){zt(this,{type:"change",parent:this,value:e,idle:t})}_onPriorityChange(e){this.idle||jn.sort(this),zt(this,{type:"priority",parent:this,priority:e})}},Qe=Symbol.for("SpringPhase"),ss=1,Tr=2,Pr=4,nr=e=>(e[Qe]&ss)>0,Le=e=>(e[Qe]&Tr)>0,St=e=>(e[Qe]&Pr)>0,ji=(e,t)=>t?e[Qe]|=Tr|ss:e[Qe]&=~Tr,zi=(e,t)=>t?e[Qe]|=Pr:e[Qe]&=~Pr,os=class extends ui{constructor(e,t){if(super(),this.animation=new ru,this.defaultProps={},this._state={paused:!1,delayed:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._pendingCalls=new Set,this._lastCallId=0,this._lastToId=0,this._memoizedDuration=0,!_.und(e)||!_.und(t)){const n=_.obj(e)?{...e}:{...t,from:e};_.und(n.default)&&(n.default=!0),this.start(n)}}get idle(){return!(Le(this)||this._state.asyncTo)||St(this)}get goal(){return ae(this.animation.to)}get velocity(){const e=Se(this);return e instanceof Hn?e.lastVelocity||0:e.getPayload().map(t=>t.lastVelocity||0)}get hasAnimated(){return nr(this)}get isAnimating(){return Le(this)}get isPaused(){return St(this)}get isDelayed(){return this._state.delayed}advance(e){let t=!0,n=!1;const r=this.animation;let{toValues:i}=r;const{config:a}=r,s=qn(r.to);!s&&ge(r.to)&&(i=he(ae(r.to))),r.values.forEach((u,c)=>{if(u.done)return;const h=u.constructor==Cn?1:s?s[c].lastPosition:i[c];let f=r.immediate,d=h;if(!f){if(d=u.lastPosition,a.tension<=0){u.done=!0;return}let g=u.elapsedTime+=e;const m=r.fromValues[c],x=u.v0!=null?u.v0:u.v0=_.arr(a.velocity)?a.velocity[c]:a.velocity;let p;const b=a.precision||(m==h?.005:Math.min(1,Math.abs(h-m)*.001));if(_.und(a.duration))if(a.decay){const y=a.decay===!0?.998:a.decay,w=Math.exp(-(1-y)*g);d=m+x/(1-y)*(1-w),f=Math.abs(u.lastPosition-d)<=b,p=x*w}else{p=u.lastVelocity==null?x:u.lastVelocity;const y=a.restVelocity||b/10,w=a.clamp?0:a.bounce,C=!_.und(w),k=m==h?u.v0>0:m<h;let A,E=!1;const I=1,j=Math.ceil(e/I);for(let N=0;N<j&&(A=Math.abs(p)>y,!(!A&&(f=Math.abs(h-d)<=b,f)));++N){C&&(E=d==h||d>h==k,E&&(p=-p*w,d=h));const L=-a.tension*1e-6*(d-h),M=-a.friction*.001*p,T=(L+M)/a.mass;p=p+T*I,d=d+p*I}}else{let y=1;a.duration>0&&(this._memoizedDuration!==a.duration&&(this._memoizedDuration=a.duration,u.durationProgress>0&&(u.elapsedTime=a.duration*u.durationProgress,g=u.elapsedTime+=e)),y=(a.progress||0)+g/this._memoizedDuration,y=y>1?1:y<0?0:y,u.durationProgress=y),d=m+a.easing(y)*(h-m),p=(d-u.lastPosition)/e,f=y==1}u.lastVelocity=p,Number.isNaN(d)&&(console.warn("Got NaN while animating:",this),f=!0)}s&&!s[c].done&&(f=!1),f?u.done=!0:t=!1,u.setValue(d,a.round)&&(n=!0)});const o=Se(this),l=o.getValue();if(t){const u=ae(r.to);(l!==u||n)&&!a.decay?(o.setValue(u),this._onChange(u)):n&&a.decay&&this._onChange(l),this._stop()}else n&&this._onChange(l)}set(e){return R.batchedUpdates(()=>{this._stop(),this._focus(e),this._set(e)}),this}pause(){this._update({pause:!0})}resume(){this._update({pause:!1})}finish(){if(Le(this)){const{to:e,config:t}=this.animation;R.batchedUpdates(()=>{this._onStart(),t.decay||this._set(e,!1),this._stop()})}return this}update(e){return(this.queue||(this.queue=[])).push(e),this}start(e,t){let n;return _.und(e)?(n=this.queue||[],this.queue=[]):n=[_.obj(e)?e:{...t,to:e}],Promise.all(n.map(r=>this._update(r))).then(r=>oi(this,r))}stop(e){const{to:t}=this.animation;return this._focus(this.get()),Ht(this._state,e&&this._lastCallId),R.batchedUpdates(()=>this._stop(t,e)),this}reset(){this._update({reset:!0})}eventObserved(e){e.type=="change"?this._start():e.type=="priority"&&(this.priority=e.priority+1)}_prepareNode(e){const t=this.key||"";let{to:n,from:r}=e;n=_.obj(n)?n[t]:n,(n==null||Sr(n))&&(n=void 0),r=_.obj(r)?r[t]:r,r==null&&(r=void 0);const i={to:n,from:r};return nr(this)||(e.reverse&&([n,r]=[r,n]),r=ae(r),_.und(r)?Se(this)||this._set(n):this._set(r)),i}_update({...e},t){const{key:n,defaultProps:r}=this;e.default&&Object.assign(r,si(e,(s,o)=>/^on/.test(o)?es(s,n):s)),Vi(this,e,"onProps"),kt(this,"onProps",e,this);const i=this._prepareNode(e);if(Object.isFrozen(this))throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");const a=this._state;return rs(++this._lastCallId,{key:n,props:e,defaultProps:r,state:a,actions:{pause:()=>{St(this)||(zi(this,!0),Et(a.pauseQueue),kt(this,"onPause",ve(this,$t(this,this.animation.to)),this))},resume:()=>{St(this)&&(zi(this,!1),Le(this)&&this._resume(),Et(a.resumeQueue),kt(this,"onResume",ve(this,$t(this,this.animation.to)),this))},start:this._merge.bind(this,i)}}).then(s=>{if(e.loop&&s.finished&&!(t&&s.noop)){const o=us(e);if(o)return this._update(o,!0)}return s})}_merge(e,t,n){if(t.cancel)return this.stop(!0),n(ot(this));const r=!_.und(e.to),i=!_.und(e.from);if(r||i)if(t.callId>this._lastToId)this._lastToId=t.callId;else return n(ot(this));const{key:a,defaultProps:s,animation:o}=this,{to:l,from:u}=o;let{to:c=l,from:h=u}=e;i&&!r&&(!t.default||_.und(c))&&(c=h),t.reverse&&([c,h]=[h,c]);const f=!Ee(h,u);f&&(o.from=h),h=ae(h);const d=!Ee(c,l);d&&this._focus(c);const g=Sr(t.to),{config:m}=o,{decay:x,velocity:p}=m;(r||i)&&(m.velocity=0),t.config&&!g&&nu(m,He(t.config,a),t.config!==s.config?He(s.config,a):void 0);let b=Se(this);if(!b||_.und(c))return n(ve(this,!0));const y=_.und(t.reset)?i&&!t.default:!_.und(h)&&Ft(t.reset,a),w=y?h:this.get(),C=qt(c),k=_.num(C)||_.arr(C)||Vn(C),A=!g&&(!k||Ft(s.immediate||t.immediate,a));if(d){const N=Mr(c);if(N!==b.constructor)if(A)b=this._set(C);else throw Error(`Cannot animate between ${b.constructor.name} and ${N.name}, as the "to" prop suggests`)}const E=b.constructor;let I=ge(c),j=!1;if(!I){const N=y||!nr(this)&&f;(d||N)&&(j=Ee(qt(w),C),I=!j),(!Ee(o.immediate,A)&&!A||!Ee(m.decay,x)||!Ee(m.velocity,p))&&(I=!0)}if(j&&Le(this)&&(o.changed&&!y?I=!0:I||this._stop(l)),!g&&((I||ge(l))&&(o.values=b.getPayload(),o.toValues=ge(c)?null:E==Cn?[1]:he(C)),o.immediate!=A&&(o.immediate=A,!A&&!y&&this._set(l)),I)){const{onRest:N}=o;O(su,M=>Vi(this,t,M));const L=ve(this,$t(this,l));Et(this._pendingCalls,L),this._pendingCalls.add(n),o.changed&&R.batchedUpdates(()=>{o.changed=!y,N?.(L,this),y?He(s.onRest,L):o.onStart?.(L,this)})}y&&this._set(w),g?n(as(t.to,t,this._state,this)):I?this._start():Le(this)&&!d?this._pendingCalls.add(n):n(is(w))}_focus(e){const t=this.animation;e!==t.to&&(Pi(this)&&this._detach(),t.to=e,Pi(this)&&this._attach())}_attach(){let e=0;const{to:t}=this.animation;ge(t)&&(bt(t,this),kr(t)&&(e=t.priority+1)),this.priority=e}_detach(){const{to:e}=this.animation;ge(e)&&Bt(e,this)}_set(e,t=!0){const n=ae(e);if(!_.und(n)){const r=Se(this);if(!r||!Ee(n,r.getValue())){const i=Mr(n);!r||r.constructor!=i?ai(this,i.create(n)):r.setValue(n),r&&R.batchedUpdates(()=>{this._onChange(n,t)})}}return Se(this)}_onStart(){const e=this.animation;e.changed||(e.changed=!0,kt(this,"onStart",ve(this,$t(this,e.to)),this))}_onChange(e,t){t||(this._onStart(),He(this.animation.onChange,e,this)),He(this.defaultProps.onChange,e,this),super._onChange(e,t)}_start(){const e=this.animation;Se(this).reset(ae(e.to)),e.immediate||(e.fromValues=e.values.map(t=>t.lastPosition)),Le(this)||(ji(this,!0),St(this)||this._resume())}_resume(){Ne.skipAnimation?this.finish():jn.start(this)}_stop(e,t){if(Le(this)){ji(this,!1);const n=this.animation;O(n.values,i=>{i.done=!0}),n.toValues&&(n.onChange=n.onPause=n.onResume=void 0),zt(this,{type:"idle",parent:this});const r=t?ot(this.get()):ve(this.get(),$t(this,e??n.to));Et(this._pendingCalls,r),n.changed&&(n.changed=!1,kt(this,"onRest",r,this))}}};function $t(e,t){const n=qt(t),r=qt(e.get());return Ee(r,n)}function us(e,t=e.loop,n=e.to){const r=He(t);if(r){const i=r!==!0&&ns(r),a=(i||e).reverse,s=!i||i.reset;return Yt({...e,loop:t,default:!1,pause:void 0,to:!a||Sr(n)?n:void 0,from:s?e.from:void 0,reset:s,...i})}}function Yt(e){const{to:t,from:n}=e=ns(e),r=new Set;return _.obj(t)&&Bi(t,r),_.obj(n)&&Bi(n,r),e.keys=r.size?Array.from(r):null,e}function au(e){const t=Yt(e);return _.und(t.default)&&(t.default=si(t)),t}function Bi(e,t){Te(e,(n,r)=>n!=null&&t.add(r))}var su=["onStart","onRest","onChange","onPause","onResume"];function Vi(e,t,n){e.animation[n]=t[n]!==ts(t,n)?es(t[n],e.key):void 0}function kt(e,t,...n){e.animation[t]?.(...n),e.defaultProps[t]?.(...n)}var ou=["onStart","onChange","onRest"],uu=1,lu=class{constructor(e,t){this.id=uu++,this.springs={},this.queue=[],this._lastAsyncId=0,this._active=new Set,this._changed=new Set,this._started=!1,this._state={paused:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set},this._events={onStart:new Map,onChange:new Map,onRest:new Map},this._onFrame=this._onFrame.bind(this),t&&(this._flush=t),e&&this.start({default:!0,...e})}get idle(){return!this._state.asyncTo&&Object.values(this.springs).every(e=>e.idle&&!e.isDelayed&&!e.isPaused)}get item(){return this._item}set item(e){this._item=e}get(){const e={};return this.each((t,n)=>e[n]=t.get()),e}set(e){for(const t in e){const n=e[t];_.und(n)||this.springs[t].set(n)}}update(e){return e&&this.queue.push(Yt(e)),this}start(e){let{queue:t}=this;return e?t=he(e).map(Yt):this.queue=[],this._flush?this._flush(this,t):(ds(this,t),Ar(this,t))}stop(e,t){if(e!==!!e&&(t=e),t){const n=this.springs;O(he(t),r=>n[r].stop(!!e))}else Ht(this._state,this._lastAsyncId),this.each(n=>n.stop(!!e));return this}pause(e){if(_.und(e))this.start({pause:!0});else{const t=this.springs;O(he(e),n=>t[n].pause())}return this}resume(e){if(_.und(e))this.start({pause:!1});else{const t=this.springs;O(he(e),n=>t[n].resume())}return this}each(e){Te(this.springs,e)}_onFrame(){const{onStart:e,onChange:t,onRest:n}=this._events,r=this._active.size>0,i=this._changed.size>0;(r&&!this._started||i&&!this._started)&&(this._started=!0,It(e,([o,l])=>{l.value=this.get(),o(l,this,this._item)}));const a=!r&&this._started,s=i||a&&n.size?this.get():null;i&&t.size&&It(t,([o,l])=>{l.value=s,o(l,this,this._item)}),a&&(this._started=!1,It(n,([o,l])=>{l.value=s,o(l,this,this._item)}))}eventObserved(e){if(e.type=="change")this._changed.add(e.parent),e.idle||this._active.add(e.parent);else if(e.type=="idle")this._active.delete(e.parent);else return;R.onFrame(this._onFrame)}};function Ar(e,t){return Promise.all(t.map(n=>ls(e,n))).then(n=>oi(e,n))}async function ls(e,t,n){const{keys:r,to:i,from:a,loop:s,onRest:o,onResolve:l}=t,u=_.obj(t.default)&&t.default;s&&(t.loop=!1),i===!1&&(t.to=null),a===!1&&(t.from=null);const c=_.arr(i)||_.fun(i)?i:void 0;c?(t.to=void 0,t.onRest=void 0,u&&(u.onRest=void 0)):O(ou,m=>{const x=t[m];if(_.fun(x)){const p=e._events[m];t[m]=({finished:b,cancelled:y})=>{const w=p.get(x);w?(b||(w.finished=!1),y&&(w.cancelled=!0)):p.set(x,{value:null,finished:b||!1,cancelled:y||!1})},u&&(u[m]=t[m])}});const h=e._state;t.pause===!h.paused?(h.paused=t.pause,Et(t.pause?h.pauseQueue:h.resumeQueue)):h.paused&&(t.pause=!0);const f=(r||Object.keys(e.springs)).map(m=>e.springs[m].start(t)),d=t.cancel===!0||ts(t,"cancel")===!0;(c||d&&h.asyncId)&&f.push(rs(++e._lastAsyncId,{props:t,state:h,actions:{pause:Nr,resume:Nr,start(m,x){d?(Ht(h,e._lastAsyncId),x(ot(e))):(m.onRest=o,x(as(c,m,h,e)))}}})),h.paused&&await new Promise(m=>{h.resumeQueue.add(m)});const g=oi(e,await Promise.all(f));if(s&&g.finished&&!(n&&g.noop)){const m=us(t,s,i);if(m)return ds(e,[m]),ls(e,m,!0)}return l&&R.batchedUpdates(()=>l(g,e,e.item)),g}function qi(e,t){const n={...e.springs};return t&&O(he(t),r=>{_.und(r.keys)&&(r=Yt(r)),_.obj(r.to)||(r={...r,to:void 0}),fs(n,r,i=>hs(i))}),cs(e,n),n}function cs(e,t){Te(t,(n,r)=>{e.springs[r]||(e.springs[r]=n,bt(n,e))})}function hs(e,t){const n=new os;return n.key=e,t&&bt(n,t),n}function fs(e,t,n){t.keys&&O(t.keys,r=>{(e[r]||(e[r]=n(r)))._prepareNode(t)})}function ds(e,t){O(t,n=>{fs(e.springs,n,r=>hs(r,e))})}var cu=Ea.createContext({pause:!1,immediate:!1}),hu=()=>{const e=[],t=function(r){Do();const i=[];return O(e,(a,s)=>{if(_.und(r))i.push(a.start());else{const o=n(r,a,s);o&&i.push(a.start(o))}}),i};t.current=e,t.add=function(r){e.includes(r)||e.push(r)},t.delete=function(r){const i=e.indexOf(r);~i&&e.splice(i,1)},t.pause=function(){return O(e,r=>r.pause(...arguments)),this},t.resume=function(){return O(e,r=>r.resume(...arguments)),this},t.set=function(r){O(e,(i,a)=>{const s=_.fun(r)?r(a,i):r;s&&i.set(s)})},t.start=function(r){const i=[];return O(e,(a,s)=>{if(_.und(r))i.push(a.start());else{const o=this._getProps(r,a,s);o&&i.push(a.start(o))}}),i},t.stop=function(){return O(e,r=>r.stop(...arguments)),this},t.update=function(r){return O(e,(i,a)=>i.update(this._getProps(r,i,a))),this};const n=function(r,i,a){return _.fun(r)?r(a,i):r};return t._getProps=n,t};function fu(e,t,n){const r=_.fun(t)&&t;r&&!n&&(n=[]);const i=P.useMemo(()=>r||arguments.length==3?hu():void 0,[]),a=P.useRef(0),s=Ga(),o=P.useMemo(()=>({ctrls:[],queue:[],flush(p,b){const y=qi(p,b);return a.current>0&&!o.queue.length&&!Object.keys(y).some(C=>!p.springs[C])?Ar(p,b):new Promise(C=>{cs(p,y),o.queue.push(()=>{C(Ar(p,b))}),s()})}}),[]),l=P.useRef([...o.ctrls]),u=P.useRef([]),c=Ri(e)||0;P.useMemo(()=>{O(l.current.slice(e,c),p=>{Ko(p,i),p.stop(!0)}),l.current.length=e,h(c,e)},[e]),P.useMemo(()=>{h(0,Math.min(c,e))},n);function h(p,b){for(let y=p;y<b;y++){const w=l.current[y]||(l.current[y]=new lu(null,o.flush)),C=r?r(y,w):t[y];C&&(u.current[y]=au(C))}}const f=l.current.map((p,b)=>qi(p,u.current[b])),d=P.useContext(cu),g=Ri(d),m=d!==g&&Zo(d);ii(()=>{a.current++,o.ctrls=l.current;const{queue:p}=o;p.length&&(o.queue=[],O(p,b=>b())),O(l.current,(b,y)=>{i?.add(b),m&&b.start({default:d});const w=u.current[y];w&&(Jo(b,w.ref),b.ref?b.queue.push(w):b.start(w))})}),Qa(()=>()=>{O(o.ctrls,p=>p.stop(!0))});const x=f.map(p=>({...p}));return i?[x,i]:x}function Wn(e,t){const n=_.fun(e),[[r],i]=fu(1,n?e:[e],n?[]:t);return n||arguments.length==2?[r,i]:r}var gs=class extends ui{constructor(e,t){super(),this.source=e,this.idle=!0,this._active=new Set,this.calc=Ot(...t);const n=this._get(),r=Mr(n);ai(this,r.create(n))}advance(e){const t=this._get(),n=this.get();Ee(t,n)||(Se(this).setValue(t),this._onChange(t,this.idle)),!this.idle&&Hi(this._active)&&rr(this)}_get(){const e=_.arr(this.source)?this.source.map(ae):he(ae(this.source));return this.calc(...e)}_start(){this.idle&&!Hi(this._active)&&(this.idle=!1,O(qn(this),e=>{e.done=!1}),Ne.skipAnimation?(R.batchedUpdates(()=>this.advance()),rr(this)):jn.start(this))}_attach(){let e=1;O(he(this.source),t=>{ge(t)&&bt(t,this),kr(t)&&(t.idle||this._active.add(t),e=Math.max(e,t.priority+1))}),this.priority=e,this._start()}_detach(){O(he(this.source),e=>{ge(e)&&Bt(e,this)}),this._active.clear(),rr(this)}eventObserved(e){e.type=="change"?e.idle?this.advance():(this._active.add(e.parent),this._start()):e.type=="idle"?this._active.delete(e.parent):e.type=="priority"&&(this.priority=he(this.source).reduce((t,n)=>Math.max(t,(kr(n)?n.priority:0)+1),0))}};function du(e){return e.idle!==!1}function Hi(e){return!e.size||Array.from(e).every(du)}function rr(e){e.idle||(e.idle=!0,O(qn(e),t=>{t.done=!0}),zt(e,{type:"idle",parent:e}))}var gu=(e,...t)=>new gs(e,t);Ne.assign({createStringInterpolator:Ya,to:(e,t)=>new gs(e,t)});var ms=/^--/;function mu(e,t){return t==null||typeof t=="boolean"||t===""?"":typeof t=="number"&&t!==0&&!ms.test(e)&&!(Dt.hasOwnProperty(e)&&Dt[e])?t+"px":(""+t).trim()}var Yi={};function pu(e,t){if(!e.nodeType||!e.setAttribute)return!1;const n=e.nodeName==="filter"||e.parentNode&&e.parentNode.nodeName==="filter",{className:r,style:i,children:a,scrollTop:s,scrollLeft:o,viewBox:l,...u}=t,c=Object.values(u),h=Object.keys(u).map(f=>n||e.hasAttribute(f)?f:Yi[f]||(Yi[f]=f.replace(/([A-Z])/g,d=>"-"+d.toLowerCase())));a!==void 0&&(e.textContent=a);for(const f in i)if(i.hasOwnProperty(f)){const d=mu(f,i[f]);ms.test(f)?e.style.setProperty(f,d):e.style[f]=d}h.forEach((f,d)=>{e.setAttribute(f,c[d])}),r!==void 0&&(e.className=r),s!==void 0&&(e.scrollTop=s),o!==void 0&&(e.scrollLeft=o),l!==void 0&&e.setAttribute("viewBox",l)}var Dt={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},yu=(e,t)=>e+t.charAt(0).toUpperCase()+t.substring(1),xu=["Webkit","Ms","Moz","O"];Dt=Object.keys(Dt).reduce((e,t)=>(xu.forEach(n=>e[yu(n,t)]=e[t]),e),Dt);var bu=/^(matrix|translate|scale|rotate|skew)/,vu=/^(translate)/,wu=/^(rotate|skew)/,ir=(e,t)=>_.num(e)&&e!==0?e+t:e,bn=(e,t)=>_.arr(e)?e.every(n=>bn(n,t)):_.num(e)?e===t:parseFloat(e)===t,_u=class extends Yn{constructor({x:e,y:t,z:n,...r}){const i=[],a=[];(e||t||n)&&(i.push([e||0,t||0,n||0]),a.push(s=>[`translate3d(${s.map(o=>ir(o,"px")).join(",")})`,bn(s,0)])),Te(r,(s,o)=>{if(o==="transform")i.push([s||""]),a.push(l=>[l,l===""]);else if(bu.test(o)){if(delete r[o],_.und(s))return;const l=vu.test(o)?"px":wu.test(o)?"deg":"";i.push(he(s)),a.push(o==="rotate3d"?([u,c,h,f])=>[`rotate3d(${u},${c},${h},${ir(f,l)})`,bn(f,0)]:u=>[`${o}(${u.map(c=>ir(c,l)).join(",")})`,bn(u,o.startsWith("scale")?1:0)])}}),i.length&&(r.transform=new Nu(i,a)),super(r)}},Nu=class extends Va{constructor(e,t){super(),this.inputs=e,this.transforms=t,this._value=null}get(){return this._value||(this._value=this._get())}_get(){let e="",t=!0;return O(this.inputs,(n,r)=>{const i=ae(n[0]),[a,s]=this.transforms[r](_.arr(i)?i:n.map(ae));e+=" "+a,t=t&&s}),t?"none":e}observerAdded(e){e==1&&O(this.inputs,t=>O(t,n=>ge(n)&&bt(n,this)))}observerRemoved(e){e==0&&O(this.inputs,t=>O(t,n=>ge(n)&&Bt(n,this)))}eventObserved(e){e.type=="change"&&(this._value=null),zt(this,e)}},Cu=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"];Ne.assign({batchedUpdates:ao.unstable_batchedUpdates,createStringInterpolator:Ya,colors:mo});var Mu=Yo(Cu,{applyAnimatedValues:pu,createAnimatedStyle:e=>new _u(e),getComponentProps:({scrollTop:e,scrollLeft:t,...n})=>n}),$e=Mu.animated;const Su=["cx","cy","r","stroke","strokeWidth","fill"];function $u(e){const t={};for(const n of Su){const r=e[n];r!=null&&(typeof r=="number"||typeof r=="string")&&(t[n]=r)}return t}const ku=function(e){const{animated:t,x:n,y:r,...i}=e,a={...i,cx:n,cy:r},s=$u(a),o=Wn({...s,config:{duration:500}});return t?S.jsx($e.circle,{className:"node-shape",...a,...o}):S.jsx($e.circle,{className:"node-shape",...a})},Tu=["d","stroke","strokeWidth"];function Pu(e){const t={};for(const n of Tu){const r=e[n];r!=null&&(typeof r=="number"||typeof r=="string")&&(t[n]=r)}return t}function Gn(e){const{animated:t,...n}=e,r=Pu(n),i=Wn({...r,config:{duration:500}});return t?S.jsx($e.path,{...n,...i}):S.jsx($e.path,{...n})}function Wi(e,t){return e-t/2}const Au=["rx","ry","x","y","width","height","stroke","strokeWidth"];function Ru(e){const t={};for(const n of Au){const r=e[n];r!=null&&(typeof r=="number"||typeof r=="string")&&(t[n]=r)}return t}const Eu=function(e){const{x:t,y:n,width:r,height:i,...a}=e,s=Wi(t,r),o=Wi(n,i),l={...a,x:s,y:o,width:r,height:i};return S.jsx(li,{...l})},li=function(e){const{animated:t,...n}=e,r=Ru(n),i=Wn({...r,config:{duration:500}});return t?S.jsx($e.rect,{className:"node-shape",...n,...i}):S.jsx($e.rect,{className:"node-shape",...n})},ar=e=>e instanceof os;function Gi(e,t,n){return ar(e)||ar(t)||ar(n)?gu([e,t,n],(r,i,a)=>`translate(${r},${i}) rotate(${a})`):`translate(${e},${t}) rotate(${n})`}function ps(e){const{alignmentBaseline:t,textAnchor:n,rotation:r,x:i,y:a,text:s,d:o,animated:l,...u}=e,c=Wn({x:i,y:a,rotation:r,config:{duration:500}});if(l){const h=Gi(c.x,c.y,c.rotation);return S.jsxs("g",{children:[S.jsx($e.text,{alignmentBaseline:t,textAnchor:n,transform:h,...u,children:s}),o?S.jsx($e.path,{strokeWidth:1,stroke:"grey",strokeDasharray:"2",d:o}):null]})}else{const h=Gi(i,a,r);return S.jsxs("g",{children:[S.jsx($e.text,{alignmentBaseline:t,textAnchor:n,transform:h,...u,children:s}),o?S.jsx($e.path,{strokeWidth:1,stroke:"grey",strokeDasharray:"2",d:o}):null]})}}const Iu=e=>({...e,x:0,y:0}),Ie=P.createContext(Iu),ys={width:1e3,height:1e3,rootLength:0,rootAngle:0,angleRange:2*Math.PI-.3,tipSpace:()=>1,curvature:0,showRoot:!1,spread:1,fishEye:{x:0,y:0,scale:0},cartoonedNodes:new Map,pollard:0,padding:20,invert:!1,minRadius:0};function vn(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Lu(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function xs(e){let t,n,r;e.length!==2?(t=vn,n=(o,l)=>vn(e(o),l),r=(o,l)=>e(o)-l):(t=e===vn||e===Lu?e:Fu,n=e,r=e);function i(o,l,u=0,c=o.length){if(u<c){if(t(l,l)!==0)return c;do{const h=u+c>>>1;n(o[h],l)<0?u=h+1:c=h}while(u<c)}return u}function a(o,l,u=0,c=o.length){if(u<c){if(t(l,l)!==0)return c;do{const h=u+c>>>1;n(o[h],l)<=0?u=h+1:c=h}while(u<c)}return u}function s(o,l,u=0,c=o.length){const h=i(o,l,u,c-1);return h>u&&r(o[h-1],l)>-r(o[h],l)?h-1:h}return{left:i,center:s,right:a}}function Fu(){return 0}function Du(e){return e===null?NaN:+e}const Uu=xs(vn),Ou=Uu.right;xs(Du).center;function ct(e,t){let n,r;if(t===void 0)for(const i of e)i!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)));else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}const ju=Math.sqrt(50),zu=Math.sqrt(10),Bu=Math.sqrt(2);function Sn(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),s=a>=ju?10:a>=zu?5:a>=Bu?2:1;let o,l,u;return i<0?(u=Math.pow(10,-i)/s,o=Math.round(e*u),l=Math.round(t*u),o/u<e&&++o,l/u>t&&--l,u=-u):(u=Math.pow(10,i)*s,o=Math.round(e/u),l=Math.round(t/u),o*u<e&&++o,l*u>t&&--l),l<o&&.5<=n&&n<2?Sn(e,t,n*2):[o,l,u]}function Vu(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const r=t<e,[i,a,s]=r?Sn(t,e,n):Sn(e,t,n);if(!(a>=i))return[];const o=a-i+1,l=new Array(o);if(r)if(s<0)for(let u=0;u<o;++u)l[u]=(a-u)/-s;else for(let u=0;u<o;++u)l[u]=(a-u)*s;else if(s<0)for(let u=0;u<o;++u)l[u]=(i+u)/-s;else for(let u=0;u<o;++u)l[u]=(i+u)*s;return l}function Rr(e,t,n){return t=+t,e=+e,n=+n,Sn(e,t,n)[2]}function qu(e,t,n){t=+t,e=+e,n=+n;const r=t<e,i=r?Rr(t,e,n):Rr(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function Hu(e,t){let n,r=-1,i=-1;if(t===void 0)for(const a of e)++i,a!=null&&(n<a||n===void 0&&a>=a)&&(n=a,r=i);else for(let a of e)(a=t(a,++i,e))!=null&&(n<a||n===void 0&&a>=a)&&(n=a,r=i);return r}function Yu(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}function ci(e,t){let n=0,r=0;if(t===void 0)for(let i of e)i!=null&&(i=+i)>=i&&(++n,r+=i);else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(a=+a)>=a&&(++n,r+=a)}if(n)return r/n}var q=(e=>(e.DISCRETE="DISCRETE",e.BOOLEAN="BOOLEAN",e.NUMERICAL="NUMERICAL",e.NUMERICAL_SET="NUMERICAL_SET",e.DISCRETE_SET="DISCRETE_SET",e.MARKOV_JUMPS="MARKOV_JUMPS",e.DENSITIES="DENSITIES",e))(q||{});function Wu(e){const t=e.split(/\s*('[^']+'|"[^"]+"|;|\(|\)|,|:|=|\[&|\]|\{|\})\s*/).filter(u=>u.length>0);let n=!0,r="",i=!1,a=!1,s=[],o;const l={};if(t[0]!=="[&"||t[t.length-1]!=="]")throw new Error("expecting a [& at the start and ] at the end of the annotation");for(const u of t)if(u==="[&")n=!0;else if(u==="=")n=!1;else if(u===","){if(i)continue;if(n=!0,o===void 0)throw new Error("Empty annotation value");l[r]=o}else if(u==="{")i?(a=!0,s=[]):o=[],i=!0;else if(u==="}")a?(a=!1,o.push(s)):i=!1;else if(u==="]"){if(o===void 0)throw new Error("Empty annotation value");l[r]=o}else{let c=u;(c.startsWith('"')||c.startsWith("'"))&&(c=c.slice(1)),(c.endsWith('"')||c.endsWith("'"))&&(c=c.slice(0,-1)),n?r=c.replace(".","_"):i?a?s.push(c):o.push(c):isNaN(c)?o=c:o=parseFloat(c)}return l}function Gu(e){if(Array.isArray(e)){if(Array.isArray(e[0])){const i=e;if(i.map(a=>a.length===3).reduce((a,s)=>a&&s,!0)){const a=i.map(([s,o,l])=>{const u=Number(s);if(!Number.isFinite(u))throw new Error(`Expected a markov jump annotation but the first entry ${s} could not be make a number`);return{time:u,from:o,to:l}});return{type:q.MARKOV_JUMPS,value:a}}else throw Error(`Markov jump with dimension ${i[0].length} detected. Expected 3. ${i.map(a=>a.length).join(",")}`)}const t=e,n=t.every(i=>typeof i=="string");if(t.every(i=>Number.isFinite(Number(i)))){const i=t.map(a=>Number(a));return{type:q.NUMERICAL_SET,value:i}}return n?{type:q.DISCRETE_SET,value:t.slice()}:{type:q.DISCRETE_SET,value:t.map(String)}}else if(Qu(e)){const n=Object.entries(e),r=n.every(([,a])=>Number.isFinite(Number(a))),i=n.every(([,a])=>typeof a=="boolean");if(r){const a={};for(const[s,o]of n){const l=Number(o);a[s]=l}return{type:q.DENSITIES,value:a}}if(i){const a=n.filter(([,s])=>s===!0).map(([s])=>s).sort();return{type:q.DISCRETE_SET,value:a}}throw new Error("Unsupported object value: expected numeric (probabilities) or boolean map")}else{if(typeof e=="boolean")return{type:q.BOOLEAN,value:e};if(typeof e=="number")return{type:q.NUMERICAL,value:e};if(typeof e=="string"){const t=e.toLowerCase();if(t==="true"||t==="false")return{type:q.BOOLEAN,value:t==="true"};const n=Number(e);return Number.isFinite(n)?{type:q.NUMERICAL,value:n}:{type:q.DISCRETE,value:e}}}throw new Error(`Unsupported annotation value: ${String(e)}`)}function Qu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xu(e){switch(e.type){case q.DISCRETE:return e.value;case q.BOOLEAN:return String(e.value);case q.NUMERICAL:return String(e.value);case q.NUMERICAL_SET:return"{"+e.value.map(t=>String(t)).join(", ")+"}";case q.DISCRETE_SET:return"{"+e.value.join(", ")+"}";case q.MARKOV_JUMPS:return"{"+e.value.map(t=>`{${String(t.time)},${t.from},${t.to}}`).join(", ")+"}";case q.DENSITIES:throw new Error(`No defined why to write densities (${e.id}) as a string.
2
+ Please convert keys and values to separate array annotations.`)}}var V=(e=>(e.Some="some",e.Nothing="nothing",e))(V||{});const Pe=()=>({type:"nothing"}),Qn=e=>({type:"some",value:e}),Qi=(e,t)=>{switch(e.type){case"some":return e.value;case"nothing":throw new Error(t)}};function K(e,t){if(e===void 0)throw new Error(t)}function fe(e,t){if(e===null)throw new Error(t);return e}const sr=new Date,or=new Date;function Ae(e,t,n,r){function i(a){return e(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(e(a=new Date(+a)),a),i.ceil=a=>(e(a=new Date(a-1)),t(a,1),e(a),a),i.round=a=>{const s=i(a),o=i.ceil(a);return a-s<o-a?s:o},i.offset=(a,s)=>(t(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,o)=>{const l=[];if(a=i.ceil(a),o=o==null?1:Math.floor(o),!(a<s)||!(o>0))return l;let u;do l.push(u=new Date(+a)),t(a,o),e(a);while(u<a&&a<s);return l},i.filter=a=>Ae(s=>{if(s>=s)for(;e(s),!a(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;t(s,-1),!a(s););else for(;--o>=0;)for(;t(s,1),!a(s););}),n&&(i.count=(a,s)=>(sr.setTime(+a),or.setTime(+s),e(sr),e(or),Math.floor(n(sr,or))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?s=>r(s)%a===0:s=>i.count(0,s)%a===0):i)),i}const Zu=1e3,hi=Zu*60,Ku=hi*60,Wt=Ku*24,bs=Wt*7,fi=Ae(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*hi)/Wt,e=>e.getDate()-1);fi.range;const di=Ae(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Wt,e=>e.getUTCDate()-1);di.range;const Ju=Ae(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Wt,e=>Math.floor(e/Wt));Ju.range;function et(e){return Ae(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*hi)/bs)}const vs=et(0),$n=et(1),el=et(2),tl=et(3),ht=et(4),nl=et(5),rl=et(6);vs.range;$n.range;el.range;tl.range;ht.range;nl.range;rl.range;function tt(e){return Ae(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/bs)}const ws=tt(0),kn=tt(1),il=tt(2),al=tt(3),ft=tt(4),sl=tt(5),ol=tt(6);ws.range;kn.range;il.range;al.range;ft.range;sl.range;ol.range;const Xe=Ae(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Xe.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ae(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});Xe.range;const Ze=Ae(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Ze.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ae(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});Ze.range;function ur(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function lr(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Tt(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function ul(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,s=e.shortDays,o=e.months,l=e.shortMonths,u=Pt(i),c=At(i),h=Pt(a),f=At(a),d=Pt(s),g=At(s),m=Pt(o),x=At(o),p=Pt(l),b=At(l),y={a:D,A:W,b:G,B:xe,c:null,d:ta,e:ta,f:Al,g:zl,G:Vl,H:kl,I:Tl,j:Pl,L:_s,m:Rl,M:El,p:Ce,q:te,Q:ia,s:aa,S:Il,u:Ll,U:Fl,V:Dl,w:Ul,W:Ol,x:null,X:null,y:jl,Y:Bl,Z:ql,"%":ra},w={a:je,A:_t,b:be,B:Nt,c:null,d:na,e:na,f:Gl,g:ic,G:sc,H:Hl,I:Yl,j:Wl,L:Cs,m:Ql,M:Xl,p:Ct,q:Mt,Q:ia,s:aa,S:Zl,u:Kl,U:Jl,V:ec,w:tc,W:nc,x:null,X:null,y:rc,Y:ac,Z:oc,"%":ra},C={a:j,A:N,b:L,B:M,c:T,d:Ji,e:Ji,f:Cl,g:Ki,G:Zi,H:ea,I:ea,j:vl,L:Nl,m:bl,M:wl,p:I,q:xl,Q:Sl,s:$l,S:_l,u:dl,U:gl,V:ml,w:fl,W:pl,x:Q,X:z,y:Ki,Y:Zi,Z:yl,"%":Ml};y.x=k(n,y),y.X=k(r,y),y.c=k(t,y),w.x=k(n,w),w.X=k(r,w),w.c=k(t,w);function k($,F){return function(U){var v=[],ne=-1,H=0,ue=$.length,le,ze,Mi;for(U instanceof Date||(U=new Date(+U));++ne<ue;)$.charCodeAt(ne)===37&&(v.push($.slice(H,ne)),(ze=Xi[le=$.charAt(++ne)])!=null?le=$.charAt(++ne):ze=le==="e"?" ":"0",(Mi=F[le])&&(le=Mi(U,ze)),v.push(le),H=ne+1);return v.push($.slice(H,ne)),v.join("")}}function A($,F){return function(U){var v=Tt(1900,void 0,1),ne=E(v,$,U+="",0),H,ue;if(ne!=U.length)return null;if("Q"in v)return new Date(v.Q);if("s"in v)return new Date(v.s*1e3+("L"in v?v.L:0));if(F&&!("Z"in v)&&(v.Z=0),"p"in v&&(v.H=v.H%12+v.p*12),v.m===void 0&&(v.m="q"in v?v.q:0),"V"in v){if(v.V<1||v.V>53)return null;"w"in v||(v.w=1),"Z"in v?(H=lr(Tt(v.y,0,1)),ue=H.getUTCDay(),H=ue>4||ue===0?kn.ceil(H):kn(H),H=di.offset(H,(v.V-1)*7),v.y=H.getUTCFullYear(),v.m=H.getUTCMonth(),v.d=H.getUTCDate()+(v.w+6)%7):(H=ur(Tt(v.y,0,1)),ue=H.getDay(),H=ue>4||ue===0?$n.ceil(H):$n(H),H=fi.offset(H,(v.V-1)*7),v.y=H.getFullYear(),v.m=H.getMonth(),v.d=H.getDate()+(v.w+6)%7)}else("W"in v||"U"in v)&&("w"in v||(v.w="u"in v?v.u%7:"W"in v?1:0),ue="Z"in v?lr(Tt(v.y,0,1)).getUTCDay():ur(Tt(v.y,0,1)).getDay(),v.m=0,v.d="W"in v?(v.w+6)%7+v.W*7-(ue+5)%7:v.w+v.U*7-(ue+6)%7);return"Z"in v?(v.H+=v.Z/100|0,v.M+=v.Z%100,lr(v)):ur(v)}}function E($,F,U,v){for(var ne=0,H=F.length,ue=U.length,le,ze;ne<H;){if(v>=ue)return-1;if(le=F.charCodeAt(ne++),le===37){if(le=F.charAt(ne++),ze=C[le in Xi?F.charAt(ne++):le],!ze||(v=ze($,U,v))<0)return-1}else if(le!=U.charCodeAt(v++))return-1}return v}function I($,F,U){var v=u.exec(F.slice(U));return v?($.p=c.get(v[0].toLowerCase()),U+v[0].length):-1}function j($,F,U){var v=d.exec(F.slice(U));return v?($.w=g.get(v[0].toLowerCase()),U+v[0].length):-1}function N($,F,U){var v=h.exec(F.slice(U));return v?($.w=f.get(v[0].toLowerCase()),U+v[0].length):-1}function L($,F,U){var v=p.exec(F.slice(U));return v?($.m=b.get(v[0].toLowerCase()),U+v[0].length):-1}function M($,F,U){var v=m.exec(F.slice(U));return v?($.m=x.get(v[0].toLowerCase()),U+v[0].length):-1}function T($,F,U){return E($,t,F,U)}function Q($,F,U){return E($,n,F,U)}function z($,F,U){return E($,r,F,U)}function D($){return s[$.getDay()]}function W($){return a[$.getDay()]}function G($){return l[$.getMonth()]}function xe($){return o[$.getMonth()]}function Ce($){return i[+($.getHours()>=12)]}function te($){return 1+~~($.getMonth()/3)}function je($){return s[$.getUTCDay()]}function _t($){return a[$.getUTCDay()]}function be($){return l[$.getUTCMonth()]}function Nt($){return o[$.getUTCMonth()]}function Ct($){return i[+($.getUTCHours()>=12)]}function Mt($){return 1+~~($.getUTCMonth()/3)}return{format:function($){var F=k($+="",y);return F.toString=function(){return $},F},parse:function($){var F=A($+="",!1);return F.toString=function(){return $},F},utcFormat:function($){var F=k($+="",w);return F.toString=function(){return $},F},utcParse:function($){var F=A($+="",!0);return F.toString=function(){return $},F}}}var Xi={"-":"",_:" ",0:"0"},X=/^\s*\d+/,ll=/^%/,cl=/[\\^$*+?|[\]().{}]/g;function B(e,t,n){var r=e<0?"-":"",i=(r?-e:e)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(t)+i:i)}function hl(e){return e.replace(cl,"\\$&")}function Pt(e){return new RegExp("^(?:"+e.map(hl).join("|")+")","i")}function At(e){return new Map(e.map((t,n)=>[t.toLowerCase(),n]))}function fl(e,t,n){var r=X.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function dl(e,t,n){var r=X.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function gl(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function ml(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function pl(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function Zi(e,t,n){var r=X.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function Ki(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function yl(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function xl(e,t,n){var r=X.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function bl(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function Ji(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function vl(e,t,n){var r=X.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function ea(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function wl(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function _l(e,t,n){var r=X.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function Nl(e,t,n){var r=X.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function Cl(e,t,n){var r=X.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Ml(e,t,n){var r=ll.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Sl(e,t,n){var r=X.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function $l(e,t,n){var r=X.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function ta(e,t){return B(e.getDate(),t,2)}function kl(e,t){return B(e.getHours(),t,2)}function Tl(e,t){return B(e.getHours()%12||12,t,2)}function Pl(e,t){return B(1+fi.count(Xe(e),e),t,3)}function _s(e,t){return B(e.getMilliseconds(),t,3)}function Al(e,t){return _s(e,t)+"000"}function Rl(e,t){return B(e.getMonth()+1,t,2)}function El(e,t){return B(e.getMinutes(),t,2)}function Il(e,t){return B(e.getSeconds(),t,2)}function Ll(e){var t=e.getDay();return t===0?7:t}function Fl(e,t){return B(vs.count(Xe(e)-1,e),t,2)}function Ns(e){var t=e.getDay();return t>=4||t===0?ht(e):ht.ceil(e)}function Dl(e,t){return e=Ns(e),B(ht.count(Xe(e),e)+(Xe(e).getDay()===4),t,2)}function Ul(e){return e.getDay()}function Ol(e,t){return B($n.count(Xe(e)-1,e),t,2)}function jl(e,t){return B(e.getFullYear()%100,t,2)}function zl(e,t){return e=Ns(e),B(e.getFullYear()%100,t,2)}function Bl(e,t){return B(e.getFullYear()%1e4,t,4)}function Vl(e,t){var n=e.getDay();return e=n>=4||n===0?ht(e):ht.ceil(e),B(e.getFullYear()%1e4,t,4)}function ql(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+B(t/60|0,"0",2)+B(t%60,"0",2)}function na(e,t){return B(e.getUTCDate(),t,2)}function Hl(e,t){return B(e.getUTCHours(),t,2)}function Yl(e,t){return B(e.getUTCHours()%12||12,t,2)}function Wl(e,t){return B(1+di.count(Ze(e),e),t,3)}function Cs(e,t){return B(e.getUTCMilliseconds(),t,3)}function Gl(e,t){return Cs(e,t)+"000"}function Ql(e,t){return B(e.getUTCMonth()+1,t,2)}function Xl(e,t){return B(e.getUTCMinutes(),t,2)}function Zl(e,t){return B(e.getUTCSeconds(),t,2)}function Kl(e){var t=e.getUTCDay();return t===0?7:t}function Jl(e,t){return B(ws.count(Ze(e)-1,e),t,2)}function Ms(e){var t=e.getUTCDay();return t>=4||t===0?ft(e):ft.ceil(e)}function ec(e,t){return e=Ms(e),B(ft.count(Ze(e),e)+(Ze(e).getUTCDay()===4),t,2)}function tc(e){return e.getUTCDay()}function nc(e,t){return B(kn.count(Ze(e)-1,e),t,2)}function rc(e,t){return B(e.getUTCFullYear()%100,t,2)}function ic(e,t){return e=Ms(e),B(e.getUTCFullYear()%100,t,2)}function ac(e,t){return B(e.getUTCFullYear()%1e4,t,4)}function sc(e,t){var n=e.getUTCDay();return e=n>=4||n===0?ft(e):ft.ceil(e),B(e.getUTCFullYear()%1e4,t,4)}function oc(){return"+0000"}function ra(){return"%"}function ia(e){return+e}function aa(e){return Math.floor(+e/1e3)}var rt,Er,Ss;uc({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function uc(e){return rt=ul(e),Er=rt.format,Ss=rt.parse,rt.utcFormat,rt.utcParse,rt}function gi(e){return e%4===0&&e%100!==0||e%400===0}function lc(e){const t=Math.trunc(e),n=gi(t)?366:365,r=Math.round((e-t)*n),i=Ss("%Y-%j")(`${t}-${r}`);return fe(i,`Could not convert ${e} to date tried (year:${t} - day: ${r})`)}function cc(e){const t=parseInt(Er("%Y")(e)),n=parseInt(Er("%j")(e)),r=gi(t)?366:365;return t+n/r}function $s(e,t){let n;if(t instanceof Object){if(t.type===V.Nothing)return t;n=t.value}else n=t;const r=e.allNames[n];return r===void 0?Pe():Qn(r)}function Gt(e,t){let n;if(t instanceof Object){if(t.type===V.Nothing)return t;n=t.value}else n=t;const r=e.byName[n];return r===void 0?Pe():Qn(r)}function hc(e,t){return{name:e,number:t,annotations:{}}}class an{_data;constructor(t){this._data=t||{allNames:[],byName:{},finalized:!1}}lockTaxa(){return this._data.finalized||(this._data.finalized=!0),this}addTaxon(t){if(this._data.finalized)throw new Error("Cannot add taxon to finalized set");let n;if(typeof t=="string"){const r=t;if(Object.prototype.hasOwnProperty.call(this._data.byName,r))throw new Error(`taxon ${r} already exists in the set. Names must be unique`);n=hc(r,this._data.allNames.length)}else{if(n=t,Object.prototype.hasOwnProperty.call(this._data.byName,n.name))throw new Error(`taxon ${n.name} already exists in the set. Names must be unique`);if(this._data.allNames[n.number]&&this._data.allNames[n.number]!==n.name)throw new Error(`taxon number ${n.number} already exists in the set with name ${this._data.allNames[n.number]}. Taxon numbers must be unique`);console.log("Adding existing taxon:",n.name)}return this._data.allNames[n.number]=n.name,this._data.byName[n.name]=n,this}getTaxon(t){const n=Gt(this._data,$s(this._data,t));switch(n.type){case V.Some:return n.value;case V.Nothing:throw new Error(`Taxon by name ${t} not found`)}}getTaxonByName(t){const n=Gt(this._data,t);switch(n.type){case V.Some:return n.value;case V.Nothing:throw new Error(`Taxon by name ${t} not found`)}}hasTaxon(t){return Object.prototype.hasOwnProperty.call(this._data.byName,t)}getTaxonCount(){return this._data.allNames.length}get isFinalized(){return this._data.finalized}}class ks{done;started;level;currentNode;nodeStack;labelNext;lengthNext;taxonSet;tree;options;constructor(t=new an,n={}){this.done=!1,this.started=!1,this.level=0,this.currentNode=void 0,this.nodeStack=[],this.labelNext=!1,this.lengthNext=!1,this.taxonSet=t,this.options=n,this.tree=new bi({taxonSet:this.taxonSet})}isDone(){return this.done}isStarted(){return this.started}getTree(){if(!this.done)throw new Error("expecting a semi-colon at the end of the newick string");if(!this.started)throw new Error("No tree to give - parsing has not started.");return this.tree}parseCharacter(t){if(this.done)throw new Error("Parsing is done. We have seen a ';'");if(t.length>2&&t.substring(0,2)==="[&"){const n=Wu(t);K(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.annotateNode(this.currentNode,n)}else if(t===";"){if(this.level>0)throw new Error("unexpected semi-colon in tree did not reach the root yet");if(!this.started)throw new Error("unexpected semi-colon in tree parsing has not started yet");this.done=!0}else if(t==="("){if(this.started=!0,this.labelNext)throw new Error("expecting a comma");let n;if(this.level+=1,this.currentNode!==void 0){const r=this.tree.addNodes(1);this.tree=r.tree,n=r.nodes[0],this.nodeStack.push(this.currentNode)}else n=this.tree.getRoot();this.currentNode=n}else if(t===","){if(this.labelNext=!1,this.lengthNext)throw new Error("branch length missing");const n=this.nodeStack.pop();K(n,"Internal Parsing error - node stack unexpectedly empty"),K(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.addChild(n,this.currentNode),this.currentNode=n}else if(t===")"){if(this.level===0)throw new Error("the brackets in the newick file are not balanced: too many closed");if(this.labelNext=!1,this.lengthNext)throw new Error("branch length missing");const n=this.nodeStack.pop();K(n,"Internal Parsing error - node stack unexpectedly empty"),K(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.addChild(n,this.currentNode),this.level-=1,this.currentNode=n,this.labelNext=!0}else if(t===":")this.labelNext=!1,this.lengthNext=!0;else if(this.lengthNext)K(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.setLength(this.currentNode,parseFloat(t)),this.lengthNext=!1;else if(this.labelNext){if(t.startsWith("#"))K(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.setLabel(this.currentNode,t.slice(1));else{let n=parseFloat(t);isNaN(n)&&(n=t),this.options.labelName?(K(this.currentNode,"Internal Parsing error - Current not is not defined"),this.tree=this.tree.annotateNode(this.currentNode,this.options.labelName,n)):console.warn(`No label name provided to newick parser but found label ${t}. It will be ignored`)}this.labelNext=!1}else{let n=t;(n.startsWith('"')||n.startsWith("'"))&&(n=n.slice(1)),(n.endsWith('"')||n.endsWith("'"))&&(n=n.slice(0,-1)),n=n.trim();const r=this.tree.addNodes(1);this.tree=r.tree;const i=r.nodes[0];let a;if(this.options.translateTaxonNames)if(this.options.translateTaxonNames.has(n))n=fe(this.options.translateTaxonNames.get(n),`${n} not found in taxon translation map`);else throw new Error(`No mapping found for ${n} in tipNameMap. It's name will not be updated`);if(this.taxonSet.isFinalized){if(!this.taxonSet.hasTaxon(n))throw new Error(`Taxon ${n} not found in taxa - but found in tree`);a=this.taxonSet.getTaxonByName(n)}else this.taxonSet.addTaxon(n),a=this.taxonSet.getTaxonByName(n);this.tree=this.tree.setTaxon(i,a),this.currentNode&&this.nodeStack.push(this.currentNode),this.currentNode=i}}}function Ir(e,t={}){const n=t.taxonSet?t.taxonSet:new an,r=e.split(/\s*('[^']+'|"[^"]+"|\[&[^[]+]|,|:|\)|\(|;)\s*/).filter(s=>s.length>0),i=new ks(n,t);for(const s of r)i.parseCharacter(s);return i.getTree()}function fc(e,t={}){const n=e.split(/\s*(?:\bBegin\s+|\bbegin\s+|\bBEGIN\s+|\bend\s*;|\bEnd\s*;|\bEND\s*;)\s*/).filter(i=>i!=="");if(n.length===0||n===void 0)throw new Error("No nexus tokens found in string. This may not be a nexus formated tree");if(n.shift().trim().toLowerCase()!=="#nexus")throw Error("File does not begin with #NEXUS is it a nexus file?");for(const i of n){const a=i.replace(/^\s+|\s+$/g,"").split(/\n/);if(a.shift().toLowerCase().trim()==="trees;"){let o=!1;const l=new Map;for(const u of a)if(u.trim().toLowerCase()==="translate")o=!0;else if(o)if(u.trim()===";")o=!1;else{const c=u.trim().replace(",","").split(/\s*\s\s*/);l.set(c[0],c[1])}else{const c=u.substring(u.indexOf("("));return l.size>0?Ir(c,{parseAnnotations:!0,...t,tipNameMap:l}):Ir(c,{parseAnnotations:!0,...t,tipNameMap:l})}}}throw new Error("No tree section found in nexus file")}var Ts=Symbol.for("immer-nothing"),Lr=Symbol.for("immer-draftable"),de=Symbol.for("immer-state"),dc=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function se(e,...t){if(process.env.NODE_ENV!=="production"){const n=dc[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var dt=Object.getPrototypeOf;function gt(e){return!!e&&!!e[de]}function Ke(e){return e?Ps(e)||Array.isArray(e)||!!e[Lr]||!!e.constructor?.[Lr]||sn(e)||Zn(e):!1}var gc=Object.prototype.constructor.toString();function Ps(e){if(!e||typeof e!="object")return!1;const t=dt(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===gc}function Tn(e,t){Xn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Xn(e){const t=e[de];return t?t.type_:Array.isArray(e)?1:sn(e)?2:Zn(e)?3:0}function Fr(e,t){return Xn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function As(e,t,n){const r=Xn(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function mc(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function sn(e){return e instanceof Map}function Zn(e){return e instanceof Set}function Ve(e){return e.copy_||e.base_}function Dr(e,t){if(sn(e))return new Map(e);if(Zn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Ps(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[de];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[s]})}return Object.create(dt(e),r)}else{const r=dt(e);if(r!==null&&n)return{...e};const i=Object.create(r);return Object.assign(i,e)}}function mi(e,t=!1){return Kn(e)||gt(e)||!Ke(e)||(Xn(e)>1&&Object.defineProperties(e,{set:{value:cn},add:{value:cn},clear:{value:cn},delete:{value:cn}}),Object.freeze(e),t&&Object.values(e).forEach(n=>mi(n,!0))),e}function cn(){se(2)}function Kn(e){return Object.isFrozen(e)}var pc={};function Je(e){const t=pc[e];return t||se(0,e),t}var Qt;function Rs(){return Qt}function yc(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function sa(e,t){t&&(Je("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ur(e){Or(e),e.drafts_.forEach(xc),e.drafts_=null}function Or(e){e===Qt&&(Qt=e.parent_)}function oa(e){return Qt=yc(Qt,e)}function xc(e){const t=e[de];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ua(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[de].modified_&&(Ur(t),se(4)),Ke(e)&&(e=Pn(t,e),t.parent_||An(t,e)),t.patches_&&Je("Patches").generateReplacementPatches_(n[de].base_,e,t.patches_,t.inversePatches_)):e=Pn(t,n,[]),Ur(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ts?e:void 0}function Pn(e,t,n){if(Kn(t))return t;const r=t[de];if(!r)return Tn(t,(i,a)=>la(e,r,t,i,a,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return An(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let a=i,s=!1;r.type_===3&&(a=new Set(i),i.clear(),s=!0),Tn(a,(o,l)=>la(e,r,i,o,l,n,s)),An(e,i,!1),n&&e.patches_&&Je("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function la(e,t,n,r,i,a,s){if(process.env.NODE_ENV!=="production"&&i===n&&se(5),gt(i)){const o=a&&t&&t.type_!==3&&!Fr(t.assigned_,r)?a.concat(r):void 0,l=Pn(e,i,o);if(As(n,r,l),gt(l))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(Ke(i)&&!Kn(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Pn(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(sn(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&An(e,i)}}function An(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&mi(t,n)}function bc(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Rs(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=pi;n&&(i=[r],a=Xt);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var pi={get(e,t){if(t===de)return e;const n=Ve(e);if(!Fr(n,t))return vc(e,n,t);const r=n[t];return e.finalized_||!Ke(r)?r:r===cr(e.base_,t)?(hr(e),e.copy_[t]=zr(r,e)):r},has(e,t){return t in Ve(e)},ownKeys(e){return Reflect.ownKeys(Ve(e))},set(e,t,n){const r=Es(Ve(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=cr(Ve(e),t),a=i?.[de];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(mc(n,i)&&(n!==void 0||Fr(e.base_,t)))return!0;hr(e),jr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return cr(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,hr(e),jr(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ve(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){se(11)},getPrototypeOf(e){return dt(e.base_)},setPrototypeOf(){se(12)}},Xt={};Tn(pi,(e,t)=>{Xt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Xt.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&se(13),Xt.set.call(this,e,t,void 0)};Xt.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&se(14),pi.set.call(this,e[0],t,n,e[0])};function cr(e,t){const n=e[de];return(n?Ve(n):e)[t]}function vc(e,t,n){const r=Es(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}function Es(e,t){if(!(t in e))return;let n=dt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=dt(n)}}function jr(e){e.modified_||(e.modified_=!0,e.parent_&&jr(e.parent_))}function hr(e){e.copy_||(e.copy_=Dr(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var wc=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const a=n;n=t;const s=this;return function(l=a,...u){return s.produce(l,c=>n.call(this,c,...u))}}typeof n!="function"&&se(6),r!==void 0&&typeof r!="function"&&se(7);let i;if(Ke(t)){const a=oa(this),s=zr(t,void 0);let o=!0;try{i=n(s),o=!1}finally{o?Ur(a):Or(a)}return sa(a,r),ua(i,a)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===Ts&&(i=void 0),this.autoFreeze_&&mi(i,!0),r){const a=[],s=[];Je("Patches").generateReplacementPatches_(t,i,a,s),r(a,s)}return i}else se(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...o)=>this.produceWithPatches(s,l=>t(l,...o));let r,i;return[this.produce(t,n,(s,o)=>{r=s,i=o}),r,i]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Ke(e)||se(8),gt(e)&&(e=_c(e));const t=oa(this),n=zr(e,void 0);return n[de].isManual_=!0,Or(t),n}finishDraft(e,t){const n=e&&e[de];(!n||!n.isManual_)&&se(9);const{scope_:r}=n;return sa(r,t),ua(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Je("Patches").applyPatches_;return gt(e)?r(e,t):this.produce(e,i=>r(i,t))}};function zr(e,t){const n=sn(e)?Je("MapSet").proxyMap_(e,t):Zn(e)?Je("MapSet").proxySet_(e,t):bc(e,t);return(t?t.scope_:Rs()).drafts_.push(n),n}function _c(e){return gt(e)||se(10,e),Is(e)}function Is(e){if(!Ke(e)||Kn(e))return e;const t=e[de];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Dr(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Dr(e,!0);return Tn(n,(r,i)=>{As(n,r,Is(i))}),t&&(t.finalized_=!1),n}var Nc=new wc,J=Nc.produce;function Cc(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Rn(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function mt(e){return e=Rn(Math.abs(e)),e?e[1]:NaN}function Mc(e,t){return function(n,r){for(var i=n.length,a=[],s=0,o=e[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),a.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=e[s=(s+1)%e.length];return a.reverse().join(t)}}function Sc(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var $c=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function En(e){if(!(t=$c.exec(e)))throw new Error("invalid format: "+e);var t;return new yi({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}En.prototype=yi.prototype;function yi(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}yi.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function kc(e){e:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+e[n])break e;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var Ls;function Tc(e,t){var n=Rn(e,t);if(!n)return e+"";var r=n[0],i=n[1],a=i-(Ls=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=r.length;return a===s?r:a>s?r+new Array(a-s+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Rn(e,Math.max(0,t+a-1))[0]}function ca(e,t){var n=Rn(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const ha={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Cc,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>ca(e*100,t),r:ca,s:Tc,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function fa(e){return e}var da=Array.prototype.map,ga=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Pc(e){var t=e.grouping===void 0||e.thousands===void 0?fa:Mc(da.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",a=e.numerals===void 0?fa:Sc(da.call(e.numerals,String)),s=e.percent===void 0?"%":e.percent+"",o=e.minus===void 0?"−":e.minus+"",l=e.nan===void 0?"NaN":e.nan+"";function u(h){h=En(h);var f=h.fill,d=h.align,g=h.sign,m=h.symbol,x=h.zero,p=h.width,b=h.comma,y=h.precision,w=h.trim,C=h.type;C==="n"?(b=!0,C="g"):ha[C]||(y===void 0&&(y=12),w=!0,C="g"),(x||f==="0"&&d==="=")&&(x=!0,f="0",d="=");var k=m==="$"?n:m==="#"&&/[boxX]/.test(C)?"0"+C.toLowerCase():"",A=m==="$"?r:/[%p]/.test(C)?s:"",E=ha[C],I=/[defgprs%]/.test(C);y=y===void 0?6:/[gprs]/.test(C)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y));function j(N){var L=k,M=A,T,Q,z;if(C==="c")M=E(N)+M,N="";else{N=+N;var D=N<0||1/N<0;if(N=isNaN(N)?l:E(Math.abs(N),y),w&&(N=kc(N)),D&&+N==0&&g!=="+"&&(D=!1),L=(D?g==="("?g:o:g==="-"||g==="("?"":g)+L,M=(C==="s"?ga[8+Ls/3]:"")+M+(D&&g==="("?")":""),I){for(T=-1,Q=N.length;++T<Q;)if(z=N.charCodeAt(T),48>z||z>57){M=(z===46?i+N.slice(T+1):N.slice(T))+M,N=N.slice(0,T);break}}}b&&!x&&(N=t(N,1/0));var W=L.length+N.length+M.length,G=W<p?new Array(p-W+1).join(f):"";switch(b&&x&&(N=t(G+N,G.length?p-M.length:1/0),G=""),d){case"<":N=L+N+M+G;break;case"=":N=L+G+N+M;break;case"^":N=G.slice(0,W=G.length>>1)+L+N+M+G.slice(W);break;default:N=G+L+N+M;break}return a(N)}return j.toString=function(){return h+""},j}function c(h,f){var d=u((h=En(h),h.type="f",h)),g=Math.max(-8,Math.min(8,Math.floor(mt(f)/3)))*3,m=Math.pow(10,-g),x=ga[8+g/3];return function(p){return d(m*p)+x}}return{format:u,formatPrefix:c}}var hn,Zt,Fs;Ac({thousands:",",grouping:[3],currency:["$",""]});function Ac(e){return hn=Pc(e),Zt=hn.format,Fs=hn.formatPrefix,hn}function Rc(e){return Math.max(0,-mt(Math.abs(e)))}function Ec(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(mt(t)/3)))*3-mt(Math.abs(e)))}function Ic(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,mt(t)-mt(e))+1}function Ds(e,t){const n=e._data.nodes.allNodes[t];return n===void 0?Pe():Qn(n)}function xi(e,t){if(typeof t=="number")return Ds(e,t);if(t instanceof Object)return Br(e,t);if(typeof t=="string"){const n=Gt(e.taxonSet._data,t);return n.type===V.Some?Br(e,n.value):Lc(e,t)}return Pe()}function Br(e,t){const n=e._data.nodes.byTaxon[t.number];return n===void 0?Pe():xi(e,n)}function Lc(e,t){const n=e._data.nodes.byLabel[t];return n===void 0?Pe():Ds(e,n)}function fr(e,t,n){const r=e.getNode(t.number).annotations[n];return r===void 0?Pe():Qn(r)}function Vr(e,t){const n=e._data.nodeToTaxon[t.number];return n===void 0?Pe():Us(e,n)}function Us(e,t){return typeof t=="number"?Gt(e.taxonSet._data,$s(e.taxonSet._data,t)):typeof t=="string"?Gt(e.taxonSet._data,t):Vr(e,t)}function dr(e,t){const n=e._data.nodes.allNodes[t.number];if(n===void 0)return Pe();const r=n.parent;return r===void 0?Pe():xi(e,r)}const Z=[];for(let e=0;e<256;++e)Z.push((e+256).toString(16).slice(1));function Fc(e,t=0){return(Z[e[t+0]]+Z[e[t+1]]+Z[e[t+2]]+Z[e[t+3]]+"-"+Z[e[t+4]]+Z[e[t+5]]+"-"+Z[e[t+6]]+Z[e[t+7]]+"-"+Z[e[t+8]]+Z[e[t+9]]+"-"+Z[e[t+10]]+Z[e[t+11]]+Z[e[t+12]]+Z[e[t+13]]+Z[e[t+14]]+Z[e[t+15]]).toLowerCase()}let gr;const Dc=new Uint8Array(16);function Uc(){if(!gr){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");gr=crypto.getRandomValues.bind(crypto)}return gr(Dc)}const Oc=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ma={randomUUID:Oc};function jc(e,t,n){e=e||{};const r=e.random??e.rng?.()??Uc();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Fc(r)}function fn(e,t,n){return ma.randomUUID&&!e?ma.randomUUID():jc(e)}class bi{[Lr]=!0;_data;taxonSet;constructor(t={}){const{data:n,taxonSet:r}=t;let i=n;r?this.taxonSet=r:this.taxonSet=new an,i===void 0&&(i={nodes:{allNodes:[{number:0,children:[],parent:void 0,label:void 0,length:void 0,taxon:void 0,annotations:{},_id:fn()}],byTaxon:[],byLabel:{}},nodeToTaxon:[],rootNode:0,is_rooted:!0,annotations:{},heights:[],hasLengths:!1}),this._data=i}lockTaxa(){return this.taxonSet.lockTaxa(),this}addTaxon(t){return this.taxonSet.addTaxon(t),this}getTaxonCount(){return this.taxonSet.getTaxonCount()}getTaxonSet(){return this.taxonSet}static fromNewick(t,n={}){return Ir(t,n)}static fromNexus(t,n){return fc(t,n)}static fromString(t,n){return t.toLowerCase().includes("#nexus")?this.fromNexus(t,n):this.fromNewick(t,n)}static fromTree(t,n){let r=new this;const i=(a,s)=>{const o=[];let l;for(const u of a.getChildren(s))o.push(i(a,u));s!==n?(r=this._addNodeWithMetadata(a,s,r),l=r.getNode(r.getNodeCount()-1)):(l=r.getRoot(),this._copyNodeMetadata(a,s,r,l));for(const u of o)r=r.addChild(l,u);return l};return i(t,n),r=r.deleteLength(r.getRoot()),r}static _addNodeWithMetadata(t,n,r){const i=r.addNodes(1),a=i.nodes[0];return r=i.tree,r=this._copyNodeMetadata(t,n,r,a),r}static _copyNodeMetadata(t,n,r,i){if(t.hasTaxon(n)){const a=t.getTaxonFromNode(n);r=r.addTaxon(a),console.log("Current taxa:",r.taxonSet),r=r.setTaxon(i,a)}if(t.hasLabel(n)){const a=t.getLabel(n);r=r.setLabel(i,a)}for(const a of t.getAnnotationKeys())if(t.hasAnnotation(n,a)){const s=t.getFullNodeAnnotation(n,a);if(s.type===q.MARKOV_JUMPS){const o=s.value.map(l=>[Number(l.time),l.from,l.to]);r=r.annotateNode(i,a,o)}else r=r.annotateNode(i,a,s.value)}if(t.hasBranchLength(n)){const a=t.getLength(n);r=r.setLength(i,a)}return r}isRooted(){return this._data.is_rooted}getAnnotationType(t){if(this._data.annotations[t]===void 0)throw new Error(`No annotation found with name: ${t}`);return this._data.annotations[t].type}getAnnotationKeys(){return Object.keys(this._data.annotations)}getRoot(){return this._data.nodes.allNodes[this._data.rootNode]}getNodeCount(){return this._data.nodes.allNodes.length}getInternalNodeCount(){return this._data.nodes.allNodes.filter(t=>t.children.length>0).length}getExternalNodeCount(){return this._data.nodes.allNodes.filter(t=>t.children.length==0).length}getInternalNodes(){return this._data.nodes.allNodes.filter(t=>t.children.length>0)}getExternalNodes(){return this._data.nodes.allNodes.filter(t=>t.children.length==0)}getNodes(){return this._data.nodes.allNodes}getNode(t){const n=xi(this,t);switch(n.type){case V.Some:return n.value;case V.Nothing:throw new Error("No node found")}}getNodeByTaxon(t){const n=Br(this,t);switch(n.type){case V.Nothing:throw new Error(`No node found for Taxon ${t.name}`);case V.Some:return n.value}}getTaxonByName(t){return this.taxonSet.getTaxonByName(t)}getNodeByLabel(t){return this.getNode(this._data.nodes.byLabel[t])}hasTaxon(t){switch(Vr(this,t).type){case V.Some:return!0;case V.Nothing:return!1}}getTaxonFromNode(t){const n=Vr(this,t);switch(n.type){case V.Some:return n.value;case V.Nothing:throw new Error("Node taxon found for the provided node")}}getTaxon(t){const n=Us(this,t);switch(n.type){case V.Some:return n.value;case V.Nothing:throw new Error("Node taxon found that matched the provided id")}}hasNodeHeights(){throw new Error("hasNodeHeights not implemented.")}getHeight(t){let n=-1;for(const r of vi(this)){const i=this.getDivergence(r);i>n&&(n=i)}return n-this.getDivergence(t)}hasBranchLength(t){return this.getNode(t.number).length!==void 0}getLength(t){const r=this.getNode(t.number).length;if(r===void 0){if(this.hasLengths())throw new Error(`The tree has lengths but, no length was found for node ${t.number}`);return console.warn("The tree does not have branchlengths so a length of 1 is used as default"),1}return r}hasLengths(){return this._data.hasLengths}_toString(t,n){return n===void 0&&(n={blFormat:Zt("0.2"),includeAnnotations:!1}),(this.getChildCount(t)>0?`(${this.getChildren(t).map(r=>this._toString(r,n)).join(",")})${this.hasLabel(t)?"#"+this.getLabel(t):""}`:this.hasTaxon(t)?this.getTaxonFromNode(t).name:"")+(n.includeAnnotations?this._writeAnnotations(t):"")+(this.hasBranchLength(t)?`:${n.blFormat(this.getLength(t))}`:"")}_writeAnnotations(t){const n=this._data.nodes.allNodes[t.number].annotations;if(Object.keys(n).length===0)return"";let r="[&",i=0;for(const[a,s]of Object.entries(n))i>0&&(r+=", "),r+=`${a}=${Xu(s)}`,i+=1;return r+="]",r}toNewick(t,n){const r={blFormat:Zt("0.2"),includeAnnotations:!1,...n};return t===void 0&&(t=this.getRoot()),this._toString(t,r)+";"}getMRCA(t,n){if(Array.isArray(t)){const r=t;if(r.length===0)throw new Error("No nodes provided to get MRCA");let i=r[0];for(let a=1;a<r.length;a++)if(i=this.getMRCA(i,r[a]),this.isRoot(i))return i;return i}else{if(n===void 0)throw new Error("No second node provided. A node must be provided if the first value is not an array");const r=[...this.getPathToRoot(t)];let i=null;for(const a of this.getPathToRoot(n))if(r.includes(a)){i=a;break}if(i===null)throw new Error("No MRCA found");return i}}getPath(t,n){const r=[],i=this.getMRCA(t,n);for(let a of[t,n])for(;a!=i;)r.push(a),a=this.getParent(a);return r}getPathLength(t,n){let r=0;const i=this.getMRCA(t,n);for(let a of[t,n])for(;a!=i;){const s=this.getLength(a);r+=s,a=this.getParent(a)}return r}*getPathToRoot(t){let n=t;for(;!this.isRoot(n);)yield n,n=this.getParent(n);yield n}getNextSibling(t){if(!this.hasLeftSibling(t)&&!this.hasRightSibling(t))throw new Error(`Node ${t.number} has no sibling`);const n=this.getParent(t),r=n.children.map(i=>i).indexOf(t.number);return this.getChild(n,(r+1)%this.getChildCount(n))}hasRightSibling(t){const n=dr(this,t);switch(n.type){case V.Nothing:return!1;case V.Some:return n.value.children.map(r=>r).indexOf(t.number)<this.getChildCount(n.value)-1}}getRightSibling(t){if(!this.hasRightSibling(t))throw new Error(`node ${t.number} does not have a right sibling`);const n=this.getParent(t),r=n.children.map(i=>i).indexOf(t.number);return this.getChild(n,r+1)}hasLeftSibling(t){const n=dr(this,t);switch(n.type){case V.Nothing:return!1;case V.Some:return this.getChildCount(n.value)>1&&n.value.children.map(r=>r).indexOf(t.number)>0}}getLeftSibling(t){if(!this.hasLeftSibling(t))throw new Error(`node ${t.number} does not have a left sibling`);const n=this.getParent(t),r=n.children.map(i=>i).indexOf(t.number);return this.getChild(n,r-1)}getDivergence(t){let n=0;for(const r of this.getPathToRoot(t))this.isRoot(r)?this.hasBranchLength(r)&&(n+=this.getLength(r)):n+=this.getLength(r);return n}getChildCount(t){if(!this._data.nodes.allNodes[t.number])throw new Error(`Node ${t.number} not found`);return this._data.nodes.allNodes[t.number].children.length}getChild(t,n){return this._data.nodes.allNodes[this._data.nodes.allNodes[t.number].children[n]]}getParent(t){const n=dr(this,t);switch(n.type){case V.Some:return n.value;case V.Nothing:throw new Error(`No parent for node ${t.number}`)}}getChildren(t){return this._data.nodes.allNodes[t.number].children.map(n=>this.getNode(n))}hasLabel(t){return this._data.nodes.allNodes[t.number].label!==void 0}getLabel(t){const n=this._data.nodes.allNodes[t.number].label;if(n===void 0)throw new Error(`no label for node ${t.number}`);return n}isExternal(t){return this.getNode(t.number).children.length===0}isInternal(t){return this.getNode(t.number).children.length>0}isRoot(t){return this._data.rootNode===t.number}addNodes(t=1){const n=[];return{tree:J(this,r=>{const i=r._data.nodes.allNodes.length;for(let a=0;a<t;a++){const s={number:i+a,children:[],parent:void 0,label:void 0,length:void 0,taxon:void 0,annotations:{},_id:fn()};n.push(s),r._data.nodes.allNodes.push(s)}}),nodes:n}}setTaxon(t,n){if(n!==this.taxonSet.getTaxonByName(n.name))throw new Error(`Taxon ${n.name} is either not in the taxon set. Has it been copied?`);return J(this,r=>{const i=r.getNode(t.number);i.taxon=n.number,r._data.nodes.byTaxon[n.number]=t.number,r._data.nodeToTaxon[t.number]=n.number})}getAnnotationSummary(t){if(this._data.annotations[t]===void 0)throw new Error(`No annotation with name ${t} found in tree`);return this._data.annotations[t]}getAnnotations(){return Object.values(this._data.annotations)}getAnnotation(t,n,r){const i=fr(this,this.getNode(t.number),n);if(r===void 0){const{value:a}=Qi(i,`Node ${t.number} is not annotated with ${n}`);return a}else switch(i.type){case V.Some:return i.value.value;case V.Nothing:return r}}getFullNodeAnnotation(t,n){const r=fr(this,this.getNode(t.number),n);return Qi(r,`Node ${t.number} is not annotated with ${n}`)}hasAnnotation(t,n){switch(fr(this,this.getNode(t.number),n).type){case V.Some:return!0;case V.Nothing:return!1}}annotateNode(t,n,r){if(typeof n=="string"){const i=n,s=Gu(r),o=this._data.annotations[i];if(o!==void 0&&o.type!==s.type)throw new Error(`Tried annotation ${i} was parsed as ${s.type} - but is ${o.type} in tree.`);return J(this,l=>{const u=o?o.domain:void 0,c=qc(s,u);l._data.nodes.allNodes[t.number].annotations[i]={id:i,type:s.type,value:s.value},l._data.annotations[i]={id:i,type:s.type,domain:c}})}else{let i=this;for(const[a,s]of Object.entries(n))i=i.annotateNode(t,a,s);return i}}setHeight(t,n){if(!this.hasLengths())throw new Error("Can not set the heights of nodes in a tree without branch lengths");return J(this,r=>{const i=r.getNode(t.number);if(n<0)throw new Error("Height must be non-negative");const s=r.getHeight(t)-n;if(i.length===void 0){if(!r.isRoot(t))throw new Error("Cannot set height on a node without length")}else i.length=i.length+s;for(const o of r.getChildren(t)){const l=r.getNode(o.number),u=r.getLength(l)-s;l.length=u}})}setLength(t,n){return J(this,r=>{const i=r.getNode(t.number);i.length=n,r._data.hasLengths=!0})}deleteLength(t){return J(this,n=>{const r=n.getNode(t.number);r.length=void 0})}setDivergence(t,n){if(!this.hasLengths())throw new Error("Can not set the divergences of nodes in a tree without branch lengths");return J(this,r=>{const i=r.getNode(t.number),a=r.getHeight(t),l=r.getHeight(r.getRoot())-a-n,u=r.getLength(t);i.length=u-l})}setLabel(t,n){if(this._data.nodes.byLabel[n]!==void 0)throw new Error(`Duplicate node label ${n}`);return J(this,r=>{const i=r.getNode(t.number);i.label=n,r._data.nodes.byLabel[n]=t.number})}insertNode(t,n=.5){return J(this,r=>{const i={number:r._data.nodes.allNodes.length,children:[],parent:void 0,label:"",length:void 0,taxon:void 0,annotations:{},_id:fn()};r._data.nodes.allNodes.push(i),r._data.nodes.byTaxon.length+=1;const a=r.getNode(t.number),s=r.getParent(a),o=s.children.indexOf(a.number);s.children.splice(o,1,i.number),i.parent=s.number;const u=r.getLength(a);a.length=u*(1-n),i.length=u*n,i.children=[a.number],a.parent=i.number})}unroot(t){throw new Error("unroot not implemented in immutable tree")}deleteNode(t){throw new Error("deleteNode not implemented in immutable tree")}deleteClade(t){throw new Error("deleteClade not implemented in immutable tree")}orderNodesByDensity(t,n){return J(this,r=>{n===void 0&&(n=r._data.nodes.allNodes[r._data.rootNode]);const i=t?1:-1;Os(r._data,n,(a,s,o,l)=>(s-l)*i)})}rotate(t,n=!1){return J(this,r=>{const i=r.getNode(t.number);if(i.children=i.children.reverse(),n)for(const a of i.children.map(s=>r.getNode(s)))r.rotate(a,n)})}reroot(t,n=.5){return J(this,r=>{if(t.number===r._data.rootNode)return;const i=r.getRoot();i.children.length!==2&&console.warn("Root node has more than two children and we are rerooting! There be dragons!");let a=0;if(i.children.length==2)a=i.children.map(o=>r.getNode(o)).map(o=>r.getLength(o)).reduce((o,l)=>l+o,0);else{const o=[...r.getPathToRoot(t)],l=o[o.length-2];if(K(l,"Index error when looking for the root child"),!i.children.includes(l.number))throw new Error("Root child not in path to root - likely an internal error");a=r.getLength(l)}const s=r.getNode(t.number);if(r.getParent(t)!==i){let o=s,l=r.getParent(s);const u=r.getChild(l,0).number===t.number,c=s,h=l;let f=r.getLength(l);for(;!r.isRoot(l);){if(l.children=l.children.filter(g=>g!==o.number),r.getParent(l).number===i.number)if(i.children.length==2){if(!r.hasLeftSibling(l)&&!r.hasRightSibling(l))throw new Error("no sibling in rerooting");const m=r.hasLeftSibling(l)?r.getLeftSibling(l):r.getRightSibling(l);l.children.push(m.number),m.parent=l.number,m.length=a}else{const g={number:r._data.nodes.allNodes.length,children:[],parent:void 0,label:"",length:void 0,taxon:void 0,annotations:{},_id:fn()};r._data.nodes.allNodes.push(g),g.length=a,l.children.push(g.number),g.parent=l.number;for(const m of i.children){const x=r.getNode(m);x.number!==l.number&&(x.parent=g.number,g.children.push(x.number))}}else{const g=r.getParent(l),m=r.getLength(g);g.length=f,f=m,l.children.push(g.number)}o=l,l=r.getParent(l)}c.parent=i.number,h.parent=i.number,i.children=[c.number,h.number],u||(i.children=i.children.reverse()),this.getInternalNodes().forEach(g=>{for(const m of r.getChildren(g))m.parent=g.number});const d=r.getLength(c)*n;h.length=d,K(c.length,"Expected the root's new child to have a length"),c.length-=d}else{const o=r.getLength(t)*(1-n);s.length=o;const l=r.getNextSibling(t);l.length=a-o}})}removeChild(t,n){return J(this,r=>{r._data.nodes.allNodes[t.number].children=r._data.nodes.allNodes[t.number].children.filter(i=>i!==n.number),r._data.nodes.allNodes[n.number].parent=-1})}sortChildren(t,n){return J(this,r=>{r._data.nodes.allNodes[t.number].children=this._data.nodes.allNodes[t.number].children.map(i=>r.getNode(i)).sort(n).map(i=>i.number)})}addChild(t,n){return J(this,r=>{const i=r.getNode(n.number);r.getNode(t.number).children.push(i.number),i.parent=t.number})}setRoot(t){return J(this,n=>{n._data.rootNode=t.number})}}function Os(e,t,n){let r=0;if(e.nodes.allNodes[t.number].children.length>0){const i=new Map;for(const o of e.nodes.allNodes[t.number].children.map(l=>e.nodes.allNodes[l])){const l=Os(e,o,n);i.set(o.number,l),r+=l}const a=e.nodes.allNodes[t.number].children.slice().sort((o,l)=>n(e.nodes.allNodes[o],fe(i.get(o),"Internal error when ordering. Counts not defined."),e.nodes.allNodes[l],fe(i.get(l),"Internal error when ordering. Counts not defined.")));a.reduce((o,l,u)=>o||l!==e.nodes.allNodes[t.number].children[u],!0)&&(e.nodes.allNodes[t.number].children=a)}else r=1;return r}function*zc(e,t=void 0){const n=function*(r){yield e.getNode(r.number);const i=e.getChildCount(r);if(i>0)for(let a=0;a<i;a++){const s=e.getChild(r,a);yield*n(s)}};t===void 0&&(t=e.getRoot()),yield*n(t)}function pt(e,t,n){let r;return e.isRoot(t)?r=Yu(e.getChildren(t).filter(i=>i.number!=n.number),i=>i.number):r=t.number,fe(r,"There was an error finding the path through the root. check the children")}function*Bc(e,t=void 0){const n=function*(r,i=void 0){const a=[...e.getChildren(r)];e.isRoot(r)||a.push(e.getParent(r));const s=a.filter(u=>u.number!==i),o=a.find(u=>u.number===i);s.sort((u,c)=>pt(e,u,r)-pt(e,c,r));let l;!e.isRoot(r)&&o===e.getParent(r)?l=e.getLength(r):o!==void 0&&(l=e.getLength(o));for(const u of s)yield*n(u,r.number);yield{...e.getNode(r.number),pseudoLength:l,pseudoChildren:s,pseudoParent:o}};t===void 0&&(t=e.getRoot()),yield*n(t)}function*js(e,t=void 0){const n=function*(r,i=void 0){const a=[...e.getChildren(r)];e.isRoot(r)||a.push(e.getParent(r));const s=a.filter(u=>u.number!==i),o=a.find(u=>u.number===i);s.sort((u,c)=>pt(e,u,r)-pt(e,c,r));let l;!e.isRoot(r)&&o===e.getParent(r)?l=e.getLength(r):o!==void 0&&(l=e.getLength(o)),yield{...e.getNode(r.number),pseudoLength:l,pseudoChildren:s,pseudoParent:o};for(const u of s)yield*n(u,r.number)};t===void 0&&(t=e.getRoot()),yield*n(t)}function*zs(e,t,n){const r=function*(i,a=void 0){const s=[...e.getChildren(i)];e.isRoot(i)||s.push(e.getParent(i));const o=s.filter(c=>c.number!==a),l=s.find(c=>c.number===a);o.sort((c,h)=>pt(e,c,i)-pt(e,h,i));let u;if(!e.isRoot(i)&&l===e.getParent(i)?u=e.getLength(i):l!==void 0&&(u=e.getLength(l)),o.length==0)yield{...e.getNode(i.number),pseudoLength:u,pseudoChildren:o,pseudoParent:l};else for(const c of o)yield*r(c,i.number)};t===void 0&&(t=e.getRoot()),n!==void 0?yield*r(t,n.number):yield*r(t)}function*Bs(e,t=void 0){const n=function*(r){const i=e.getChildCount(r);if(i>0)for(let a=0;a<i;a++){const s=e.getChild(r,a);yield*n(s)}yield r};t===void 0&&(t=e.getRoot()),yield*n(t)}function*vi(e,t){t===void 0&&(t=e.getRoot());const n=function*(r){const i=e.getChildCount(r);if(i>0)for(let a=0;a<i;a++){const s=e.getChild(r,a);yield*n(s)}else yield r};yield*n(t)}function*Vc(e,t){let n=t;for(;!e.isRoot(n);)yield n,n=e.getParent(n);yield n}function qc(e,t){switch(e.type){case q.BOOLEAN:return[!0,!1];case q.DISCRETE:{const n=e.value;if(t!==void 0){const r=t;return[...new Set([...r,n])].sort()}else return[n]}case q.NUMERICAL:{const n=e.value;return ct([...t||[],n])}case q.DISCRETE_SET:{const n=e.value,r=t||[];return[...new Set([...r,...n])].sort()}case q.NUMERICAL_SET:{const n=e.value;return ct([...t||[],...n])}case q.DENSITIES:if(t!==void 0){const n=t;return[...new Set([...n,...Object.keys(e.value)])].sort()}else return[...new Set(Object.keys(e.value))].sort().filter(n=>n);case q.MARKOV_JUMPS:{const n=e.value.reduce((i,a)=>i.concat([a.to,a.from]),[]),r=t||[];return[...new Set([...r,...n])].sort()}default:throw new Error("Unrecognized type when updating domain")}}function Hc(){return{lastChunk:"",status:"parsing",end:"",start(){},transform(e,t){const n=this.lastChunk+e;let r="";for(let i=0;i<n.length;i++){const a=n[i];K(a,"Internal Error. Hit empty character in array"),this.status==="parsing"?([this.status,this.end]=Yc(a),this.status==="in comment"&&(r.length>0&&t.enqueue(r),r="")):a===this.end&&(this.status="parsing",this.end=""),this.status==="parsing"&&/\s|;|\]/.test(a)?(r.length>0&&(/\]/.test(a)&&(r+=a),t.enqueue(r),r=""),/;/.test(a)&&t.enqueue(a)):r+=a}this.lastChunk=r},flush(e){this.lastChunk&&e.enqueue(this.lastChunk)}}}function Yc(e){return e==="'"?["in single quote","'"]:e==='"'?["in double quote",'"']:e==="["?["in comment","]"]:["parsing",""]}const pa=/\s*('[^']+'|"[^"]+"|\[&[^[]+]|,|:|\)|\(|;)\s*/;class Wc{reader;taxonSet;currentBlock;hasTree;options;translateTaxonMap;constructor(t,n={}){const r=new TransformStream(Hc());this.reader=t.pipeThrough(new TextDecoderStream).pipeThrough(r).getReader(),this.taxonSet=new an,this.currentBlock=void 0,this.options=n}async*getTrees(){for(;this.currentBlock!=="trees";)await this.parseNextBlock(),this.hasTree=!0;yield*this.parseTreesBlock()}async parseNextBlock(){const t=await this.getNextBlockName();switch(t){case"taxa":this.currentBlock="taxa",await this.parseTaxaBlock();break;case"trees":this.currentBlock="trees";break;default:console.log(`skipping block ${t}. Only parsing blocks are taxa and trees for now.`),await this.readToEndOfBlock()}}async nextToken(){const{done:t,value:n}=await this.reader.read();if(t)throw new Error("unexpectedly hit the end of the stream");return n}async skipSemiColon(){const{done:t,value:n}=await this.reader.read();if(t)throw new Error("unexpectedly hit the end of the stream");if(!n.match(/;$/))throw new Error(`expected ";" got ${n}`)}async getNextBlockName(){let t=!0,n;for(;t;)(await this.nextToken()).match(/\bbegin/i)&&(n=await this.nextToken(),await this.skipSemiColon(),t=!1);return n}async readToEndOfBlock(){let t=!0;for(;t;)(await this.nextToken()).match(/\bend;/i)&&(t=!1)}async skipUntil(t){let n,r=!0;for(;r;)n=await this.nextToken(),t.test(n)&&(r=!1);if(n==null)throw new Error(`Internal parsing error: ${t.source} not found `);return n}async readUntil(t){let n="",r=!0;for(;r;){const i=await this.nextToken();t.test(i)&&(n+=i,r=!1),n+=i}return n}async parseTaxaBlock(){let t,n=!0;for(;n;){const r=await this.skipUntil(/dimensions|taxlabels|end/i);switch(!0){case/dimensions/i.test(r):{const i=await this.readUntil(/;/),a=i.match(/ntax=(\d+);/);if(a)K(a[1],"No number of taxa found despite matching regex"),t=parseInt(a[1]);else throw new Error(`Expected dimension in form of ntax=(\\d+);. Got ${i}`);break}case/taxlabels/i.test(r):{let i=await this.nextToken();for(;i!==";";)this.taxonSet.addTaxon(i),i=await this.nextToken();if(t&&t!=this.taxonSet.getTaxonCount())throw new Error(`found ${this.taxonSet.getTaxonCount()} taxa. Expected: ${t}}`);break}case/end/i.test(r):{if(this.taxonSet.getTaxonCount()===0)throw new Error("hit end of taxa section but didn't find any taxa");this.taxonSet.lockTaxa(),await this.skipSemiColon(),n=!1;break}default:throw new Error(`Reached impossible code looking for dimensions or taxlabels or end in taxa block "${r}"`)}}}async*parseTreesBlock(){let t,n=!0;for(;n;){const r=await this.skipUntil(/translate|tree|end/i);switch(!0){case/translate/i.test(r):{this.translateTaxonMap=new Map;let i=0,a;for(t=await this.nextToken();t!==";";){if(i%2==0)a=t;else{if(t[t.length-1]===","&&(t=t.slice(0,-1)),this.taxonSet.isFinalized){if(!this.taxonSet.hasTaxon(t))throw new Error(`Taxon ${t} not found in taxa block - but found in translate block`)}else this.taxonSet.addTaxon(t);K(a,"Error parsing nexus. Expected key for taxa but found nothing"),this.translateTaxonMap.set(a,t)}for(t=await this.nextToken();t===",";)t=await this.nextToken();i++}this.taxonSet.lockTaxa();break}case/tree/i.test(r):{await this.nextToken();const i=new ks(this.taxonSet,{translateTaxonNames:this.translateTaxonMap});t=await this.skipUntil(/\(/);let a=t.split(pa).filter(o=>o.length>0).reverse();for(;!i.isDone();){for(;a.length>0;){const o=a.pop();K(o,"Unexpectedly hit the end of the buffer"),i.parseCharacter(o)}i.isDone()||(t=await this.nextToken(),a=t.split(pa).filter(o=>o.length>0).reverse())}yield i.getTree();break}case/end/i.test(r):await this.skipSemiColon(),this.hasTree=!1,this.reader.releaseLock(),n=!1;break;default:throw new Error(`Reached impossible code in treeblock block "${r}"`)}}}}class Gc{_forwardCache;_reverseCache;constructor(){this._forwardCache=new Map,this._reverseCache=new Map}*traverse(t,n){const r=function*(i){const a=t.getChildCount(i);if(a>0)for(let s=0;s<a;s++){const o=t.getChild(i,s);yield*r(o)}yield i};n===void 0&&(n=t.getRoot()),yield*r(n)}getNext(t,n){const r=this._forwardCache.get(n);if(r!==void 0&&this._forwardCache.get(r)!==void 0)return r;if(t.isRoot(n))return;const i=t.getParent(n);if(t.hasRightSibling(n)){const a=t.getRightSibling(n);this._forwardCache.set(n,a),this._reverseCache.set(a,n)}else this._forwardCache.set(n,i),this._reverseCache.set(i,n);return this._forwardCache.get(n)}getPrevious(t,n){const r=this._reverseCache.get(n);if(r!==void 0&&this._reverseCache.get(r)!==void 0)return r;if(n!==this.traverse(t).next().value){if(t.isInternal(n)){const i=t.getChildCount(n)-1,a=t.getChild(n,i);this._reverseCache.set(n,a),this._forwardCache.set(a,n)}else if(t.hasLeftSibling(n)){const i=t.getLeftSibling(n);this._reverseCache.set(n,i),this._forwardCache.set(i,n)}else{let i=n;for(;!t.hasLeftSibling(i);)i=t.getParent(i);const a=t.getLeftSibling(i);this._reverseCache.set(n,a),this._forwardCache.set(a,n)}return this._reverseCache.get(n)}}}var Y=(e=>(e.Rectangular="Rectangular",e.Polar="Polar",e.Radial="Radial",e))(Y||{});function Vs(e){function t(n){const r=new Map;let i=0;for(const a of Bs(n)){let s;const o=n.getDivergence(a),l=n.getChildCount(a)>0,u=!n.isRoot(a),c=n.getChildCount(a)>0&&(!u||n.getChild(n.getParent(a),0)!==a);if(n.isExternal(a))s={x:o,y:i},i++;else{const f=n.getChildren(a).map(g=>fe(r.get(g),"Internal Error: child not yet found in layout")),d=fe(ci(f,g=>g.y),"Error taking the mean of child positions");s={x:o,y:d}}const h={...s,layoutClass:e,nodeLabel:{alignmentBaseline:l?c?"bottom":"hanging":"middle",textAnchor:l?"end":"start",dxFactor:l?-1:1,dyFactor:l?c?-1:1:0,rotation:0}};r.set(a,h)}return function(a){if(r.has(a))return r.get(a);throw console.log(a),new Error("Node not found in layout - has the tree changed")}}return t}const qs=Vs(Y.Rectangular),Qc=Vs(Y.Polar);function Xc(e,t={}){const{spread:n=1,root:r=e.getRoot(),startAngle:i=2.5*Math.PI/2}=t;console.log("radial layout with spread",n);const a=new Map,s=e.isRoot(r)&&e.getChildCount(r)==2,o=[{angleStart:i,angleEnd:i+2*Math.PI,xpos:0,ypos:0,level:0,number:r.number}];for(const l of js(e,r)){const u=o.pop();K(u,"Internal Error, hit the end of the data stack unexpectedly");const{angleStart:c,angleEnd:h,xpos:f,ypos:d,level:g}=u,m=(h+c)/2,x=l.pseudoLength!==void 0?l.pseudoLength:0,p=Math.cos(m),b=Math.sin(m),y=f+x*p,w=d+x*b,C=e.isRoot(e.getNode(l.number))?0:l.pseudoParent===void 0||l.pseudoParent.number!==e.getParent(l).number?-Math.PI:0,k=Hs(m-C),A=l.pseudoChildren.length>0;let E,I;E=Math.cos(k),I=Math.sin(k);const j={x:y,y:w,layoutClass:Y.Radial,theta:k,nodeLabel:{dxFactor:E,dyFactor:I,alignmentBaseline:"middle",textAnchor:k>Math.PI/2&&k<3*Math.PI/2?"end":" start",rotation:Zc(k)*2}};if(l.pseudoChildren.length>0){const N=[];let L=0;for(let z=0;z<l.pseudoChildren.length;z++){const D=[...zs(e,l.pseudoChildren[z],l.pseudoParent)].length;N[z]=D,L+=D}let M=h-c,T=c;l.pseudoChildren.length>1&&(console.log(s),(!s||!e.isRoot(e.getNode(l.number)))&&(M*=1+n/1e3*Math.PI,T=m-M/2)),console.log("here");let Q=T;for(let z=l.pseudoChildren.length-1;z>-1;z--){const D=Q;Q=D+M*N[z]/L,o.push({angleStart:D,angleEnd:Q,xpos:y,ypos:w,level:g+1,number:l.pseudoChildren[z].number})}}a.set(e.getNode(l.number),j)}return function(l){if(a.has(l))return a.get(l);throw new Error("Node not found in layout - has the tree changed")}}function Zc(e){const t=Kc(e);return t>90&&t<270?(t-180)/2:t>0&&t<90?t/2:t<360&&t>270?(360+t)/2:t}function Hs(e){for(;e>2*Math.PI;)e-=2*Math.PI;return e}function Kc(e){return Hs(e)*180/Math.PI}const Jc=()=>({x:0,y:0,layoutClass:Y.Rectangular,nodeLabel:{alignmentBaseline:"middle",textAnchor:"end",dxFactor:0,dyFactor:0,rotation:0}}),vt=P.createContext(Jc),wt=P.createContext(!1),eh={canvasWidth:0,canvasHeight:0,domainX:[0,1],domainY:[0,1],layoutClass:Y.Rectangular,invert:!1,pollard:0,minRadius:0,fishEye:{x:0,y:0,scale:0},rootAngle:0,angleRange:0},on=P.createContext(eh);function th(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function wi(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ys(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function un(){}var Kt=.7,In=1/Kt,ut="\\s*([+-]?\\d+)\\s*",Jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ke="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",nh=/^#([0-9a-f]{3,8})$/,rh=new RegExp(`^rgb\\(${ut},${ut},${ut}\\)$`),ih=new RegExp(`^rgb\\(${ke},${ke},${ke}\\)$`),ah=new RegExp(`^rgba\\(${ut},${ut},${ut},${Jt}\\)$`),sh=new RegExp(`^rgba\\(${ke},${ke},${ke},${Jt}\\)$`),oh=new RegExp(`^hsl\\(${Jt},${ke},${ke}\\)$`),uh=new RegExp(`^hsla\\(${Jt},${ke},${ke},${Jt}\\)$`),ya={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};wi(un,en,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xa,formatHex:xa,formatHex8:lh,formatHsl:ch,formatRgb:ba,toString:ba});function xa(){return this.rgb().formatHex()}function lh(){return this.rgb().formatHex8()}function ch(){return Ws(this).formatHsl()}function ba(){return this.rgb().formatRgb()}function en(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=nh.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?va(t):n===3?new oe(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?dn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?dn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=rh.exec(e))?new oe(t[1],t[2],t[3],1):(t=ih.exec(e))?new oe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ah.exec(e))?dn(t[1],t[2],t[3],t[4]):(t=sh.exec(e))?dn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=oh.exec(e))?Na(t[1],t[2]/100,t[3]/100,1):(t=uh.exec(e))?Na(t[1],t[2]/100,t[3]/100,t[4]):ya.hasOwnProperty(e)?va(ya[e]):e==="transparent"?new oe(NaN,NaN,NaN,0):null}function va(e){return new oe(e>>16&255,e>>8&255,e&255,1)}function dn(e,t,n,r){return r<=0&&(e=t=n=NaN),new oe(e,t,n,r)}function hh(e){return e instanceof un||(e=en(e)),e?(e=e.rgb(),new oe(e.r,e.g,e.b,e.opacity)):new oe}function qr(e,t,n,r){return arguments.length===1?hh(e):new oe(e,t,n,r??1)}function oe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}wi(oe,qr,Ys(un,{brighter(e){return e=e==null?In:Math.pow(In,e),new oe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Kt:Math.pow(Kt,e),new oe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new oe(Ge(this.r),Ge(this.g),Ge(this.b),Ln(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:wa,formatHex:wa,formatHex8:fh,formatRgb:_a,toString:_a}));function wa(){return`#${Ye(this.r)}${Ye(this.g)}${Ye(this.b)}`}function fh(){return`#${Ye(this.r)}${Ye(this.g)}${Ye(this.b)}${Ye((isNaN(this.opacity)?1:this.opacity)*255)}`}function _a(){const e=Ln(this.opacity);return`${e===1?"rgb(":"rgba("}${Ge(this.r)}, ${Ge(this.g)}, ${Ge(this.b)}${e===1?")":`, ${e})`}`}function Ln(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ge(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ye(e){return e=Ge(e),(e<16?"0":"")+e.toString(16)}function Na(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new we(e,t,n,r)}function Ws(e){if(e instanceof we)return new we(e.h,e.s,e.l,e.opacity);if(e instanceof un||(e=en(e)),!e)return new we;if(e instanceof we)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),s=NaN,o=a-i,l=(a+i)/2;return o?(t===a?s=(n-r)/o+(n<r)*6:n===a?s=(r-t)/o+2:s=(t-n)/o+4,o/=l<.5?a+i:2-a-i,s*=60):o=l>0&&l<1?0:s,new we(s,o,l,e.opacity)}function dh(e,t,n,r){return arguments.length===1?Ws(e):new we(e,t,n,r??1)}function we(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}wi(we,dh,Ys(un,{brighter(e){return e=e==null?In:Math.pow(In,e),new we(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Kt:Math.pow(Kt,e),new we(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new oe(mr(e>=240?e-240:e+120,i,r),mr(e,i,r),mr(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new we(Ca(this.h),gn(this.s),gn(this.l),Ln(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ln(this.opacity);return`${e===1?"hsl(":"hsla("}${Ca(this.h)}, ${gn(this.s)*100}%, ${gn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ca(e){return e=(e||0)%360,e<0?e+360:e}function gn(e){return Math.max(0,Math.min(1,e||0))}function mr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const _i=e=>()=>e;function gh(e,t){return function(n){return e+n*t}}function mh(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function ph(e){return(e=+e)==1?Gs:function(t,n){return n-t?mh(t,n,e):_i(isNaN(t)?n:t)}}function Gs(e,t){var n=t-e;return n?gh(e,n):_i(isNaN(e)?t:e)}const Ma=(function e(t){var n=ph(t);function r(i,a){var s=n((i=qr(i)).r,(a=qr(a)).r),o=n(i.g,a.g),l=n(i.b,a.b),u=Gs(i.opacity,a.opacity);return function(c){return i.r=s(c),i.g=o(c),i.b=l(c),i.opacity=u(c),i+""}}return r.gamma=e,r})(1);function yh(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function xh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function bh(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)i[s]=Ni(e[s],t[s]);for(;s<n;++s)a[s]=t[s];return function(o){for(s=0;s<r;++s)a[s]=i[s](o);return a}}function vh(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Fn(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function wh(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=Ni(e[i],t[i]):r[i]=t[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var Hr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pr=new RegExp(Hr.source,"g");function _h(e){return function(){return e}}function Nh(e){return function(t){return e(t)+""}}function Ch(e,t){var n=Hr.lastIndex=pr.lastIndex=0,r,i,a,s=-1,o=[],l=[];for(e=e+"",t=t+"";(r=Hr.exec(e))&&(i=pr.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),o[s]?o[s]+=a:o[++s]=a),(r=r[0])===(i=i[0])?o[s]?o[s]+=i:o[++s]=i:(o[++s]=null,l.push({i:s,x:Fn(r,i)})),n=pr.lastIndex;return n<t.length&&(a=t.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?l[0]?Nh(l[0].x):_h(t):(t=l.length,function(u){for(var c=0,h;c<t;++c)o[(h=l[c]).i]=h.x(u);return o.join("")})}function Ni(e,t){var n=typeof t,r;return t==null||n==="boolean"?_i(t):(n==="number"?Fn:n==="string"?(r=en(t))?(t=r,Ma):Ch:t instanceof en?Ma:t instanceof Date?vh:xh(t)?yh:Array.isArray(t)?bh:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?wh:Fn)(e,t)}function Mh(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function Sh(e){return function(){return e}}function $h(e){return+e}var Sa=[0,1];function it(e){return e}function Yr(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Sh(isNaN(t)?NaN:.5)}function kh(e,t){var n;return e>t&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function Th(e,t,n){var r=e[0],i=e[1],a=t[0],s=t[1];return i<r?(r=Yr(i,r),a=n(s,a)):(r=Yr(r,i),a=n(a,s)),function(o){return a(r(o))}}function Ph(e,t,n){var r=Math.min(e.length,t.length)-1,i=new Array(r),a=new Array(r),s=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++s<r;)i[s]=Yr(e[s],e[s+1]),a[s]=n(t[s],t[s+1]);return function(o){var l=Ou(e,o,1,r)-1;return a[l](i[l](o))}}function Ah(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Rh(){var e=Sa,t=Sa,n=Ni,r,i,a,s=it,o,l,u;function c(){var f=Math.min(e.length,t.length);return s!==it&&(s=kh(e[0],e[f-1])),o=f>2?Ph:Th,l=u=null,h}function h(f){return f==null||isNaN(f=+f)?a:(l||(l=o(e.map(r),t,n)))(r(s(f)))}return h.invert=function(f){return s(i((u||(u=o(t,e.map(r),Fn)))(f)))},h.domain=function(f){return arguments.length?(e=Array.from(f,$h),c()):e.slice()},h.range=function(f){return arguments.length?(t=Array.from(f),c()):t.slice()},h.rangeRound=function(f){return t=Array.from(f),n=Mh,c()},h.clamp=function(f){return arguments.length?(s=f?!0:it,c()):s!==it},h.interpolate=function(f){return arguments.length?(n=f,c()):n},h.unknown=function(f){return arguments.length?(a=f,h):a},function(f,d){return r=f,i=d,c()}}function Eh(){return Rh()(it,it)}function Ih(e,t,n,r){var i=qu(e,t,n),a;switch(r=En(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=Ec(i,s))&&(r.precision=a),Fs(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=Ic(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=Rc(i))&&(r.precision=a-(r.type==="%")*2);break}}return Zt(r)}function Lh(e){var t=e.domain;return e.ticks=function(n){var r=t();return Vu(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var i=t();return Ih(i[0],i[i.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),i=0,a=r.length-1,s=r[i],o=r[a],l,u,c=10;for(o<s&&(u=s,s=o,o=u,u=i,i=a,a=u);c-- >0;){if(u=Rr(s,o,n),u===l)return r[i]=s,r[a]=o,t(r);if(u>0)s=Math.floor(s/u)*u,o=Math.ceil(o/u)*u;else if(u<0)s=Math.ceil(s*u)/u,o=Math.floor(o*u)/u;else break;l=u}return e},e}function me(){var e=Eh();return e.copy=function(){return Ah(e,me())},th.apply(e,arguments),Lh(e)}function Fh(e,t,n,r,i=!1,a=0,s=1.7*Math.PI,o=0,l=0){const u=Math.min(n,r)/2,c=We(s),h=e*l,f=i?[a*u,u].reverse():[a*u,u],d=me().domain([h,e]).range(f),g=o+(2*3.14-c)/2,m=g+c,x=me().domain([0,t]).range([g,m]),p=[[0,0],Rt(u,g),Rt(u,m)],b=We(g),y=We(b+c);if(y>b)for(const z of[Math.PI/2,Math.PI,3*Math.PI/2].filter(D=>D>b&&D<y)){const[D,W]=Rt(u,z);p.push([D,W])}else for(const z of[0,Math.PI/2,Math.PI,3*Math.PI/2].filter(D=>D>b||D<y)){const[D,W]=Rt(u,z);p.push([D,W])}const w=ct(p,z=>z[0]),C=ct(p,z=>z[1]),k=(w[1]-w[0])/(C[1]-C[0]),A=Math.min(n,r*k),E=A,I=A/k,j=(n-E)/2,N=(r-I)/2,L=[N,r-N],M=[j,n-j],T=me().domain(w).range(M),Q=me().domain(C).range(L);return function(D){const[W,G]=[d(D.x),x(D.y)],[xe,Ce]=Rt(W,G),te=We(G),je={alignmentBaseline:"middle",textAnchor:te>Math.PI/2&&te<3*Math.PI/2?"end":" start",dxFactor:Math.cos(te),dyFactor:Math.sin(te),rotation:Qs(te)};return{...D,x:T(xe),y:Q(Ce),r:W,theta:G,nodeLabel:je}}}function Rt(e,t){return[e*Math.cos(t),e*Math.sin(t)]}function We(e){for(;e>2*Math.PI;)e-=2*Math.PI;return e}function Dh(e){return We(e)*180/Math.PI}function Qs(e){const t=Dh(We(e));return t>90&&t<270?t-180:t}const Uh={alignmentBaseline:"middle",textAnchor:"middle",dxFactor:1,dyFactor:1,rotation:0};function Oh({domainX:e,domainY:t,canvasWidth:n,canvasHeight:r,layoutClass:i,invert:a=!1,minRadius:s=0,angleRange:o=2*Math.PI,rootAngle:l=0,pollard:u=0,fishEye:c={x:0,y:0,scale:0}}){let h,f;switch(i){case Y.Rectangular:{const d=e[1]*u;h=me().domain([d,e[1]]).range([0,n]),f=me().domain(t).range([0,r]);let g=m=>f(m);if(c.scale>0){const m=f.invert(c.y),x=jh(c.scale,m),p=f.copy().domain(f.domain().map(x));g=b=>p(x(b))}return a&&h.range([n,0]),function(x){return{...x,x:h(x.x),y:g(x.y)}}}case Y.Polar:return Fh(e[1],t[1],n,r,a,s,o,l,u);case Y.Radial:{const d=me().domain(e).range([0,1]),g=me().domain(t).range([0,1]),m=Math.min(n,r),x=(n-m)/2,p=(r-m)/2,b=[x,m+x],y=[p,m+p];return f=me().domain([0,1]).range(y),h=me().domain([0,1]).range(b),function(C){return{...C,x:h(d(C.x)),y:f(g(C.y))}}}default:throw new Error("Not implemented in calcX")}}const jh=(e,t)=>n=>{if(e===0)return n;const r=1/e,i=t-n,a=1-t/(r+t),s=1-(t-1)/(r-(t-1));return(1-(i<0?i/(r-i):i/(r+i))-a)/(s-a)};function Xs(e){const t=n=>{const r=P.useContext(Ie),i=P.useContext(vt),a=P.useContext(wt),{node:s,...o}=n,l=r(i(s));return S.jsx(e,{...o,x:l.x,y:l.y,animated:a})};return t.displayName=`withNode(${e.displayName||e.name||"Component"})`,t}function Zs(e){const t=n=>{const r=P.useContext(Ie),i=P.useContext(vt),a=P.useContext(wt),{domainX:s,layoutClass:o}=P.useContext(on),{node:l,parent:u,aligned:c,gap:h=6,...f}=n,d=i(l),g=r(d);if(u===void 0){const m=g.nodeLabel??Uh,x=m.dxFactor*h,p=m.dyFactor*h,b=r({x:s[1],y:d.y}),y=(c?b.x:g.x)+x,w=(c&&o===Y.Polar?b.y:g.y)+p,{alignmentBaseline:C,rotation:k,textAnchor:A}=m,E=c?`M${g.x} ${g.y}L${y} ${w}`:`M${g.x} ${g.y}L${g.x} ${g.y}`;return S.jsx(e,{alignmentBaseline:C,rotation:k,textAnchor:A,d:E,x:y,y:w,...f,animated:a})}else{const m=i(u),x=r(m),p=o===Y.Polar?fe(g.theta,"The layout is polar but theta was not calculated for this node"):0,b=o===Y.Polar?Qs(p):0,y=r({x:m.x,y:d.y}),{dx:w,dy:C}=o===Y.Polar?zh(p,h):{dx:0,dy:-1*h},k=(o===Y.Polar?(g.x+y.x)/2:(g.x+x.x)/2)+w,A=(o===Y.Polar?(g.y+y.y)/2:o===Y.Radial?(g.y+x.y)/2:g.y)+C;return S.jsx(e,{alignmentBaseline:"baseline",rotation:b,textAnchor:"middle",x:k,y:A,...f,animated:a})}};return t.displayName=`withNodeLabel(${e.displayName||e.name||"Component"})`,t}function zh(e,t){let n,r;return e>0&&e<Math.PI/2?(n=Math.sin(Math.PI/2-e)*t,r=-Math.cos(Math.PI/2-e)*t):e>Math.PI/2&&e<Math.PI?(n=-Math.cos(Math.PI/2-(Math.PI-e))*t,r=-Math.sin(Math.PI/2-(Math.PI-e))*t):e>Math.PI&&e<3*Math.PI/2?(n=Math.cos(Math.PI/2-(e-Math.PI))*t,r=-Math.sin(Math.PI/2-(e-Math.PI))*t):(n=-Math.cos(Math.PI/2-(2*Math.PI-e))*t,r=-Math.sin(Math.PI/2-(2*Math.PI-e))*t),{dx:n,dy:r}}function Ci(e){const t=n=>{const{nodes:r,keyBy:i=o=>o._id,attrs:a={},aligned:s}=n;return S.jsx("g",{className:"node-layer",children:r.map(o=>{const l=a[o._id]??{};return S.jsx(e,{node:o,...l,aligned:s},i(o))})})};return t.displayName=`withNodesArray(${e.displayName||e.name||"Component"})`,t}function Ks(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yr,$a;function Bh(){if($a)return yr;$a=1,yr=e;function e(t){var n=0,r=0,i=0,a=0;return t.map(function(s){s=s.slice();var o=s[0],l=o.toUpperCase();if(o!=l)switch(s[0]=l,o){case"a":s[6]+=i,s[7]+=a;break;case"v":s[1]+=a;break;case"h":s[1]+=i;break;default:for(var u=1;u<s.length;)s[u++]+=i,s[u++]+=a}switch(l){case"Z":i=n,a=r;break;case"H":i=s[1];break;case"V":a=s[1];break;case"M":i=n=s[1],a=r=s[2];break;default:i=s[s.length-2],a=s[s.length-1]}return s})}return yr}var Vh=Bh();const qh=Ks(Vh);var Hh=(function(){function e(t,n){var r=[],i=!0,a=!1,s=void 0;try{for(var o=t[Symbol.iterator](),l;!(i=(l=o.next()).done)&&(r.push(l.value),!(n&&r.length===n));i=!0);}catch(u){a=!0,s=u}finally{try{!i&&o.return&&o.return()}finally{if(a)throw s}}return r}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),Ut=Math.PI*2,xr=function(t,n,r,i,a,s,o){var l=t.x,u=t.y;l*=n,u*=r;var c=i*l-a*u,h=a*l+i*u;return{x:c+s,y:h+o}},Yh=function(t,n){var r=n===1.5707963267948966?.551915024494:n===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(n/4),i=Math.cos(t),a=Math.sin(t),s=Math.cos(t+n),o=Math.sin(t+n);return[{x:i-a*r,y:a+i*r},{x:s+o*r,y:o-s*r},{x:s,y:o}]},ka=function(t,n,r,i){var a=t*i-n*r<0?-1:1,s=t*r+n*i;return s>1&&(s=1),s<-1&&(s=-1),a*Math.acos(s)},Wh=function(t,n,r,i,a,s,o,l,u,c,h,f){var d=Math.pow(a,2),g=Math.pow(s,2),m=Math.pow(h,2),x=Math.pow(f,2),p=d*g-d*x-g*m;p<0&&(p=0),p/=d*x+g*m,p=Math.sqrt(p)*(o===l?-1:1);var b=p*a/s*f,y=p*-s/a*h,w=c*b-u*y+(t+r)/2,C=u*b+c*y+(n+i)/2,k=(h-b)/a,A=(f-y)/s,E=(-h-b)/a,I=(-f-y)/s,j=ka(1,0,k,A),N=ka(k,A,E,I);return l===0&&N>0&&(N-=Ut),l===1&&N<0&&(N+=Ut),[w,C,j,N]},Gh=function(t){var n=t.px,r=t.py,i=t.cx,a=t.cy,s=t.rx,o=t.ry,l=t.xAxisRotation,u=l===void 0?0:l,c=t.largeArcFlag,h=c===void 0?0:c,f=t.sweepFlag,d=f===void 0?0:f,g=[];if(s===0||o===0)return[];var m=Math.sin(u*Ut/360),x=Math.cos(u*Ut/360),p=x*(n-i)/2+m*(r-a)/2,b=-m*(n-i)/2+x*(r-a)/2;if(p===0&&b===0)return[];s=Math.abs(s),o=Math.abs(o);var y=Math.pow(p,2)/Math.pow(s,2)+Math.pow(b,2)/Math.pow(o,2);y>1&&(s*=Math.sqrt(y),o*=Math.sqrt(y));var w=Wh(n,r,i,a,s,o,h,d,m,x,p,b),C=Hh(w,4),k=C[0],A=C[1],E=C[2],I=C[3],j=Math.abs(I)/(Ut/4);Math.abs(1-j)<1e-7&&(j=1);var N=Math.max(Math.ceil(j),1);I/=N;for(var L=0;L<N;L++)g.push(Yh(E,I)),E+=I;return g.map(function(M){var T=xr(M[0],s,o,x,m,k,A),Q=T.x,z=T.y,D=xr(M[1],s,o,x,m,k,A),W=D.x,G=D.y,xe=xr(M[2],s,o,x,m,k,A),Ce=xe.x,te=xe.y;return{x1:Q,y1:z,x2:W,y2:G,x:Ce,y:te}})};function Qh(e){for(var t,n=[],r=0,i=0,a=0,s=0,o=null,l=null,u=0,c=0,h=0,f=e.length;h<f;h++){var d=e[h],g=d[0];switch(g){case"M":a=d[1],s=d[2];break;case"A":var m=Gh({px:u,py:c,cx:d[6],cy:d[7],rx:d[1],ry:d[2],xAxisRotation:d[3],largeArcFlag:d[4],sweepFlag:d[5]});if(!m.length)continue;for(var x=0,p;x<m.length;x++)p=m[x],d=["C",p.x1,p.y1,p.x2,p.y2,p.x,p.y],x<m.length-1&&n.push(d);break;case"S":var b=u,y=c;(t=="C"||t=="S")&&(b+=b-r,y+=y-i),d=["C",b,y,d[1],d[2],d[3],d[4]];break;case"T":t=="Q"||t=="T"?(o=u*2-o,l=c*2-l):(o=u,l=c),d=Ta(u,c,o,l,d[1],d[2]);break;case"Q":o=d[1],l=d[2],d=Ta(u,c,d[1],d[2],d[3],d[4]);break;case"L":d=mn(u,c,d[1],d[2]);break;case"H":d=mn(u,c,d[1],c);break;case"V":d=mn(u,c,u,d[1]);break;case"Z":d=mn(u,c,a,s);break}t=g,u=d[d.length-2],c=d[d.length-1],d.length>4?(r=d[d.length-4],i=d[d.length-3]):(r=u,i=c),n.push(d)}return n}function mn(e,t,n,r){return["C",e,t,n,r,n,r]}function Ta(e,t,n,r,i,a){return["C",e/3+2/3*n,t/3+2/3*r,i/3+2/3*n,a/3+2/3*r,i,a]}var br,Pa;function Xh(){if(Pa)return br;Pa=1,br=n;var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function n(a){var s=[];return a.replace(t,function(o,l,u){var c=l.toLowerCase();for(u=i(u),c=="m"&&u.length>2&&(s.push([l].concat(u.splice(0,2))),c="l",l=l=="m"?"l":"L");;){if(u.length==e[c])return u.unshift(l),s.push(u);if(u.length<e[c])throw new Error("malformed path data");s.push([l].concat(u.splice(0,e[c])))}}),s}var r=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function i(a){var s=a.match(r);return s?s.map(Number):[]}return br}var Zh=Xh();const Kh=Ks(Zh);class wn{x;y;constructor(t,n){this.x=t,this.y=n}}const vr=6;function Js(e){const t=Kh(e),n=qh(t),r=Qh(n);let i=`${r[0][0]} ${r[0][1]} ${r[0][2]} `;const a=r.filter(s=>s[0]==="C").map(s=>[new wn(s[1],s[2]),new wn(s[3],s[4]),new wn(s[5],s[6])]);if(a.length>vr)throw new Error(`Path must have no more than ${vr} nodes (excluding start point) detected ${a.length} nodes update layout or path.helpers`);if(a.length==0)throw new Error("Path must have at least 1 node (excluding start point) update layout or path.helpers");for(;a.length<vr;){const s=fe(a.pop(),"Internal error in normalization"),{left:o,right:l}=Jh(s,.5);a.push(o),a.push(l.reverse())}for(let s=0;s<a.length;s++){const o=a[s];i+=`C${o[0].x},${o[0].y} ${o[1].x},${o[1].y} ${o[2].x},${o[2].y} `}return i}function Jh(e,t){const n=[],r=[];function i(a,s){if(a.length==1)n.push(a[0]),r.push(a[0]);else{const o=Array(a.length-1);for(let l=0;l<o.length;l++)l==0&&n.push(a[0]),l==o.length-1&&r.push(a[l+1]),o[l]=new wn((1-s)*a[l].x+s*a[l+1].x,(1-s)*a[l].y+s*a[l+1].y);i(o,s)}}return i(e,t),{left:n,right:r}}function ef(e){const t=n=>{const r=P.useContext(Ie),i=P.useContext(vt),a=P.useContext(wt),{node:s,parent:o,curvature:l=0,...u}=n,c=i(s),{layoutClass:h}=c,f=o?i(o):{x:c.x,y:c.y},d={x:f.x,y:c.y},g=[f,c,d].map(x=>r(x)),m=Js(tf(g,l,h));return S.jsx(e,{d:m,animated:a,...u})};return t.displayName=`withBranchArray(${e.displayName||e.name||"Component"})`,t}function tf(e,t,n){switch(n){case Y.Rectangular:return nf(e,t);case Y.Polar:return rf(e);case Y.Radial:return af(e);default:throw new Error(`path generator not implemented for the ${n} of points`)}}function nf(e,t){const n=e.length;switch(n){case 0:return"";case 3:{const[r,i]=e;return t===0?`M${r.x+.001},${r.y}L${r.x},${i.y}L${i.x},${i.y+.001}`:t<1?`M${r.x},${r.y}C${r.x},${i.y}, ${r.x+Math.abs(t*(r.x-i.x))},${i.y} ${i.x},${i.y}`:`M${r.x},${r.y}L${(r.x+i.x)/2},${(r.y+i.y)/2}L${i.x},${i.y}`}default:throw new Error(`path rectangular generator not implemented for this ${n} of points`)}}function rf(e){const t=e.length;switch(t){case 3:{const[n,r,i]=e,a=n.theta===r.theta||n.r===0?"":`A${n.r},${n.r} 0 0 ${n.theta<r.theta?1:0} ${i.x},${i.y}`;return`M${n.x},${n.y} ${a} L${r.x},${r.y}`}case 0:return"";default:throw new Error(`Error in polar path generator. not expecting ${t} points`)}}function af(e){const t=e.length;switch(t){case 0:return"";case 3:{const[n,r]=e;return`M${n.x},${n.y}L${(n.x+r.x)/2},${(n.y+r.y)/2}L${r.x},${r.y}`}default:throw new Error(`path rectangular generator not implemented for this ${t} of points`)}}function eo(e){const t=n=>{const{branches:r,keyBy:i=o=>o._id,attrs:a={},curvature:s}=n;return S.jsx("g",{className:"branch-layer",children:r.map(({node:o,parent:l})=>{const u=a[o._id]??{};return S.jsx(e,{node:o,parent:l,...u,curvature:s},i(o))})})};return t.displayName=`withBranchArray(${e.displayName||e.name||"Component"})`,t}function to(e){const t=n=>{const{clades:r,keyBy:i=s=>s._id,attrs:a={}}=n;return S.jsx("g",{className:"node-layer",children:r.map(s=>{const o=a[s.root._id]??{};return S.jsx(e,{clade:s,...o},i(s.root))})})};return t.displayName=`withCladessArray(${e.displayName||e.name||"Component"})`,t}const sf=Ci(Xs(ku)),of=Ci(Xs(Eu));function uf(e){switch(e.shape){case yt.Circle:return S.jsx(sf,{...e});case yt.Rectangle:return S.jsx(of,{...e})}}const lf=eo(Zs(ps)),cf=Ci(Zs(ps)),hf=eo(ef(Gn));function ff(e){switch(e.target){case 0:return S.jsx(uf,{...e});case 1:return S.jsx(hf,{...e});case 2:return S.jsx(cf,{...e});case 3:return S.jsx(lf,{...e});case 4:return S.jsx(Rf,{...e})}}var ye=(e=>(e[e.Node=0]="Node",e[e.Branch=1]="Branch",e[e.NodeLabel=2]="NodeLabel",e[e.BranchLabel=3]="BranchLabel",e[e.Clade=4]="Clade",e[e.Axis=5]="Axis",e))(ye||{}),yt=(e=>(e[e.Circle=0]="Circle",e[e.Rectangle=1]="Rectangle",e))(yt||{}),xt=(e=>(e[e.Cartoon=0]="Cartoon",e[e.Highlight=1]="Highlight",e))(xt||{});function df(e){const{clade:t,...n}=e,r=P.useContext(Ie),i=P.useContext(vt),a=P.useContext(wt),{root:s,leftMost:o,rightMost:l,mostDiverged:u}=t,c=r(i(s)),{x:h,y:f}=c,d=r(i(o)),g=r(i(l)),m=r(i(u)),{layoutClass:x}=i(s);let p;if(x===Y.Rectangular){const y=m.x,w=g.y,C=d.y;p=`M${h},${f}L${y},${w}L${y},${C}Z`}else if(x===Y.Polar){const y=d,w=g,C=y.theta===w.theta||y.r===0?"":`A${y.r},${y.r} 0 0 ${y.theta<w.theta?1:0} ${w.x},${w.y}`;p=`M${h},${f}L${y.x},${y.y} ${C} Z`}else return null;const b=Js(p);return S.jsx(Gn,{d:b,...n,animated:a})}const gf=to(df);function Fe(e){return function(){return e}}const Aa=Math.abs,ee=Math.atan2,Be=Math.cos,mf=Math.max,wr=Math.min,Me=Math.sin,at=Math.sqrt,ie=1e-12,tn=Math.PI,Dn=tn/2,pf=2*tn;function yf(e){return e>1?0:e<-1?tn:Math.acos(e)}function Ra(e){return e>=1?Dn:e<=-1?-Dn:Math.asin(e)}const Wr=Math.PI,Gr=2*Wr,qe=1e-6,xf=Gr-qe;function no(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function bf(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return no;const n=10**t;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class vf{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?no:bf(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,a,s){this._append`C${+t},${+n},${+r},${+i},${this._x1=+a},${this._y1=+s}`}arcTo(t,n,r,i,a){if(t=+t,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let s=this._x1,o=this._y1,l=r-t,u=i-n,c=s-t,h=o-n,f=c*c+h*h;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(f>qe)if(!(Math.abs(h*l-u*c)>qe)||!a)this._append`L${this._x1=t},${this._y1=n}`;else{let d=r-s,g=i-o,m=l*l+u*u,x=d*d+g*g,p=Math.sqrt(m),b=Math.sqrt(f),y=a*Math.tan((Wr-Math.acos((m+f-x)/(2*p*b)))/2),w=y/b,C=y/p;Math.abs(w-1)>qe&&this._append`L${t+w*c},${n+w*h}`,this._append`A${a},${a},0,0,${+(h*d>c*g)},${this._x1=t+C*l},${this._y1=n+C*u}`}}arc(t,n,r,i,a,s){if(t=+t,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),u=t+o,c=n+l,h=1^s,f=s?i-a:a-i;this._x1===null?this._append`M${u},${c}`:(Math.abs(this._x1-u)>qe||Math.abs(this._y1-c)>qe)&&this._append`L${u},${c}`,r&&(f<0&&(f=f%Gr+Gr),f>xf?this._append`A${r},${r},0,1,${h},${t-o},${n-l}A${r},${r},0,1,${h},${this._x1=u},${this._y1=c}`:f>qe&&this._append`A${r},${r},0,${+(f>=Wr)},${h},${this._x1=t+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function wf(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new vf(t)}function _f(e){return e.innerRadius}function Nf(e){return e.outerRadius}function Cf(e){return e.startAngle}function Mf(e){return e.endAngle}function Sf(e){return e&&e.padAngle}function $f(e,t,n,r,i,a,s,o){var l=n-e,u=r-t,c=s-i,h=o-a,f=h*l-c*u;if(!(f*f<ie))return f=(c*(t-a)-h*(e-i))/f,[e+f*l,t+f*u]}function pn(e,t,n,r,i,a,s){var o=e-n,l=t-r,u=(s?a:-a)/at(o*o+l*l),c=u*l,h=-u*o,f=e+c,d=t+h,g=n+c,m=r+h,x=(f+g)/2,p=(d+m)/2,b=g-f,y=m-d,w=b*b+y*y,C=i-a,k=f*m-g*d,A=(y<0?-1:1)*at(mf(0,C*C*w-k*k)),E=(k*y-b*A)/w,I=(-k*b-y*A)/w,j=(k*y+b*A)/w,N=(-k*b+y*A)/w,L=E-x,M=I-p,T=j-x,Q=N-p;return L*L+M*M>T*T+Q*Q&&(E=j,I=N),{cx:E,cy:I,x01:-c,y01:-h,x11:E*(i/C-1),y11:I*(i/C-1)}}function kf(){var e=_f,t=Nf,n=Fe(0),r=null,i=Cf,a=Mf,s=Sf,o=null,l=wf(u);function u(){var c,h,f=+e.apply(this,arguments),d=+t.apply(this,arguments),g=i.apply(this,arguments)-Dn,m=a.apply(this,arguments)-Dn,x=Aa(m-g),p=m>g;if(o||(o=c=l()),d<f&&(h=d,d=f,f=h),!(d>ie))o.moveTo(0,0);else if(x>pf-ie)o.moveTo(d*Be(g),d*Me(g)),o.arc(0,0,d,g,m,!p),f>ie&&(o.moveTo(f*Be(m),f*Me(m)),o.arc(0,0,f,m,g,p));else{var b=g,y=m,w=g,C=m,k=x,A=x,E=s.apply(this,arguments)/2,I=E>ie&&(r?+r.apply(this,arguments):at(f*f+d*d)),j=wr(Aa(d-f)/2,+n.apply(this,arguments)),N=j,L=j,M,T;if(I>ie){var Q=Ra(I/f*Me(E)),z=Ra(I/d*Me(E));(k-=Q*2)>ie?(Q*=p?1:-1,w+=Q,C-=Q):(k=0,w=C=(g+m)/2),(A-=z*2)>ie?(z*=p?1:-1,b+=z,y-=z):(A=0,b=y=(g+m)/2)}var D=d*Be(b),W=d*Me(b),G=f*Be(C),xe=f*Me(C);if(j>ie){var Ce=d*Be(y),te=d*Me(y),je=f*Be(w),_t=f*Me(w),be;if(x<tn)if(be=$f(D,W,je,_t,Ce,te,G,xe)){var Nt=D-be[0],Ct=W-be[1],Mt=Ce-be[0],$=te-be[1],F=1/Me(yf((Nt*Mt+Ct*$)/(at(Nt*Nt+Ct*Ct)*at(Mt*Mt+$*$)))/2),U=at(be[0]*be[0]+be[1]*be[1]);N=wr(j,(f-U)/(F-1)),L=wr(j,(d-U)/(F+1))}else N=L=0}A>ie?L>ie?(M=pn(je,_t,D,W,d,L,p),T=pn(Ce,te,G,xe,d,L,p),o.moveTo(M.cx+M.x01,M.cy+M.y01),L<j?o.arc(M.cx,M.cy,L,ee(M.y01,M.x01),ee(T.y01,T.x01),!p):(o.arc(M.cx,M.cy,L,ee(M.y01,M.x01),ee(M.y11,M.x11),!p),o.arc(0,0,d,ee(M.cy+M.y11,M.cx+M.x11),ee(T.cy+T.y11,T.cx+T.x11),!p),o.arc(T.cx,T.cy,L,ee(T.y11,T.x11),ee(T.y01,T.x01),!p))):(o.moveTo(D,W),o.arc(0,0,d,b,y,!p)):o.moveTo(D,W),!(f>ie)||!(k>ie)?o.lineTo(G,xe):N>ie?(M=pn(G,xe,Ce,te,f,-N,p),T=pn(D,W,je,_t,f,-N,p),o.lineTo(M.cx+M.x01,M.cy+M.y01),N<j?o.arc(M.cx,M.cy,N,ee(M.y01,M.x01),ee(T.y01,T.x01),!p):(o.arc(M.cx,M.cy,N,ee(M.y01,M.x01),ee(M.y11,M.x11),!p),o.arc(0,0,f,ee(M.cy+M.y11,M.cx+M.x11),ee(T.cy+T.y11,T.cx+T.x11),p),o.arc(T.cx,T.cy,N,ee(T.y11,T.x11),ee(T.y01,T.x01),!p))):o.arc(0,0,f,C,w,p)}if(o.closePath(),c)return o=null,c+""||null}return u.centroid=function(){var c=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,h=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-tn/2;return[Be(h)*c,Me(h)*c]},u.innerRadius=function(c){return arguments.length?(e=typeof c=="function"?c:Fe(+c),u):e},u.outerRadius=function(c){return arguments.length?(t=typeof c=="function"?c:Fe(+c),u):t},u.cornerRadius=function(c){return arguments.length?(n=typeof c=="function"?c:Fe(+c),u):n},u.padRadius=function(c){return arguments.length?(r=c==null?null:typeof c=="function"?c:Fe(+c),u):r},u.startAngle=function(c){return arguments.length?(i=typeof c=="function"?c:Fe(+c),u):i},u.endAngle=function(c){return arguments.length?(a=typeof c=="function"?c:Fe(+c),u):a},u.padAngle=function(c){return arguments.length?(s=typeof c=="function"?c:Fe(+c),u):s},u.context=function(c){return arguments.length?(o=c??null,u):o},u}const Tf=kf();function Pf(e){const{clade:t,...n}=e,r=P.useContext(Ie),i=P.useContext(vt),a=P.useContext(wt),{root:s,leftMost:o,rightMost:l,mostDiverged:u}=t,c=r(i(s)),h=r(i(o)),f=r(i(l)),d=r(i(u)),{layoutClass:g}=i(s);if(g===Y.Rectangular){const m=d.x-c.x,x=Math.abs(h.y-f.y);return S.jsx(li,{width:m,height:x,x:c.x,y:Math.min(h.y,f.y),...n,animated:a})}else if(g===Y.Polar){const m=r({x:0,y:0}),x=`translate(${m.x},${m.y})`,p=c.r,b=d.r,y=h.theta,w=f.theta,C=Tf({innerRadius:p,outerRadius:b+5,startAngle:w+Math.PI/2,endAngle:y+Math.PI/2});return K(C,"Error making arc shape for Clade Highlight"),S.jsx(Gn,{d:C,transform:x,...n,animated:a})}else return null}const Af=to(Pf);function Rf(e){switch(e.shape){case xt.Cartoon:return S.jsx(gf,{...e});case xt.Highlight:return S.jsx(Af,{...e})}}function Ef(e){return typeof e=="function"}function Re(e){return function(t){const n={};for(const r in e){const i=e[r];Ef(i)?n[r]=i(t):n[r]=i}return n}}function yn(e){return function(t){const n={};for(const r in e){const i=e[r];i!==void 0&&(n[r]=()=>{i(t)})}return n}}function If(e,t){const n="filter"in e?e.filter:()=>!0;K(n,"Issue with filter option when making baubles");const r="nodes"in e?e.nodes:t.getNodes().filter(n),i=yn(e.interactions??{});if(e.target===ye.Node)if(e.shape===yt.Circle){const a=Re(e.attrs),s=r.reduce((o,l)=>{const u=a(l),c=i(l);return o[l._id]={...u,...c},o},{});return{nodes:r,attrs:s,id:e.id,target:e.target,shape:e.shape}}else{const a=Re(e.attrs),s=r.reduce((o,l)=>{const u=a(l),c=i(l);return o[l._id]={...u,...c},o},{});return{nodes:r,attrs:s,id:e.id,target:e.target,shape:e.shape}}else if(e.target===ye.Branch){const a=r.filter(u=>!t.isRoot(u)).map(u=>({node:u,parent:t.getParent(u)})),s=Re({fill:"none",...e.attrs}),o=yn(e.interactions??{}),l=r.reduce((u,c)=>{const h=s(c),f=o(c);return u[c._id]={...h,...f},u},{});return{branches:a,attrs:l,id:e.id,curvature:e.curvature,target:e.target}}else if(e.target===ye.NodeLabel){const a=Re(e.attrs),s=Re({text:e.text}),o=yn(e.interactions??{}),l=r.reduce((u,c)=>{const h=a(c),f=o(c),d=s(c);return u[c._id]={...h,...f,...d},u},{});return{nodes:r,attrs:l,id:e.id,target:e.target,aligned:e.aligned??!1}}else if(e.target===ye.BranchLabel){const a=r.filter(h=>!t.isRoot(h)),s=a.map(h=>({node:h,parent:t.getParent(h)})),o=Re(e.attrs),l=yn(e.interactions??{}),u=Re({text:e.text}),c=a.reduce((h,f)=>{const d=o(f),g=l(f),m=u(f);return h[f._id]={...d,...g,...m},h},{});return{branches:s,attrs:c,id:e.id,target:e.target}}else{const a=r.map(s=>{const o=[...vi(t,s)],l=o[0],u=o[o.length-1],c=o[Hu(o,h=>t.getDivergence(h))];return{root:s,leftMost:l,rightMost:u,mostDiverged:c}});if(e.shape===xt.Highlight){const s=Re(e.attrs),o=r.reduce((l,u)=>{const c=s(u),h=i(u);return l[u._id]={...c,...h},l},{});return{clades:a,attrs:o,id:e.id,target:e.target,shape:e.shape}}else{const s=Re(e.attrs),o=r.reduce((l,u)=>{const c=s(u),h=i(u);return l[u._id]={...c,...h},l},{});return{clades:a,attrs:o,id:e.id,target:e.target,shape:e.shape}}}}function Lf(e){return{...e,shape:yt.Circle,target:ye.Node}}function Ff(e){return{...e,shape:yt.Rectangle,target:ye.Node}}function ro(e){return{...e,target:ye.Branch}}function Df(e){return{attrs:{},aligned:!1,...e,target:ye.NodeLabel}}function Uf(e){return{attrs:{},...e,target:ye.BranchLabel}}function Of(e){return{...e,shape:xt.Highlight,target:ye.Clade}}function jf(e){return{...e,shape:xt.Cartoon,target:ye.Clade}}const ce={offsetBy:0,scaleBy:1,reverse:!1,gap:5,title:{text:"",padding:40,style:{}},ticks:{number:5,format:Zt(".1f"),padding:20,style:{},length:6},attrs:{strokeWidth:1}},Un={evenFill:"#EDEDED",oddFill:"none"};function zf(e){const{attrs:t,evenFill:n=Un.evenFill,oddFill:r=Un.oddFill,tickValues:i,scale:a,figureScale:s,axisY:o}=e;return S.jsx("g",{className:"axisBars",children:i.filter((l,u,c)=>u<c.length-1).map((l,u)=>{const c=s({x:a(l),y:o}),h=s({x:a(l),y:0}),f=s({x:a(i[u+1]),y:0}),d=s({x:a(i[u+1]),y:o}),g=c.theta===h.theta||c.r===0?"":`A${c.r},${c.r} 0 1 0 ${h.x},${h.y}`,m=f.theta===d.theta||f.r===0?"":`A${f.r},${f.r} 0 1 1 ${d.x},${d.y}`,x=`M${c.x},${c.y} ${g} L${h.x},${h.y} L${f.x},${f.y} ${m} L ${c.x} ${c.y} Z`,p=u%2===0?n:r;return S.jsx(Gn,{d:x,fill:p,...t,animated:!1},u)})})}function Bf(e){const t=P.useContext(on),n=P.useContext(Ie),{bars:r,attrs:i}=e,a=e.ticks?{...ce.ticks,...e.ticks}:ce.ticks,s=e.title?{...ce.title,...e.title}:ce.title,o=io(e,t);let l;a.values!=null?l=a.values:l=o.ticks(a.number);const u=We(n({x:t.domainX[1],y:t.domainY[1]}).theta),c=t.domainY[1]+t.domainY[1]*.005,h=n({x:t.domainX[0],y:c}),f=n({x:t.domainX[1],y:c}),d=`M${h.x},${h.y} L${f.x},${f.y}`,g=a.length*Math.cos(u),m=a.length*Math.sin(u),x=a.padding*Math.cos(u),p=a.padding*Math.sin(u),b=fe(ci(o.range()),"Error calculating x position for title"),y=n({x:b,y:c}),w=s.padding*Math.cos(u),C=s.padding*Math.sin(u);return S.jsxs("g",{className:"axis",children:[S.jsx(zf,{...r,tickValues:l,scale:o,axisY:c}),":",S.jsx("path",{d,stroke:"black",...i}),S.jsxs("g",{children:[l.map((k,A)=>{const E=n({x:o(k),y:c});return S.jsxs("g",{transform:`translate(${E.x},${E.y}) rotate(90)`,children:[S.jsx("line",{x1:g,y1:m,x2:0,y2:0,stroke:"black",...i}),S.jsx("text",{transform:`translate(${x},${p}) rotate(-90)`,textAnchor:"middle",dominantBaseline:"central",...a.style,children:a.format(k)})]},`tick-${A}`)}),S.jsx("g",{transform:`translate(${y.x},${y.y}) rotate(90)`,children:S.jsx("text",{textAnchor:"middle",transform:`translate(${w},${C}) rotate(-90)`,children:s.text})})]})]})}function io(e,t){const{reverse:n=ce.reverse,offsetBy:r=ce.offsetBy,scaleBy:i=ce.scaleBy,scale:a}=e,{domainX:s}=t,o=a===void 0?me().domain(s).range(s):a.copy();if(a===void 0){const u=s.map(c=>c+r).map(c=>(c-r)*i+r);o.domain(u),n&&o.domain([r-(u[1]-u[0]),r])}return o.nice()}function Vf(e){const{attrs:t,evenFill:n=Un.evenFill,oddFill:r=Un.oddFill,tickValues:i,scale:a,axisY:s}=e,o=P.useContext(Ie);return S.jsx("g",{className:"axisBars",children:i.filter((l,u,c)=>u<c.length-1).map((l,u)=>{const c=o({x:a(l),y:s}),h=o({x:a(l),y:-.05}),f=o({x:a(i[u+1]),y:0}),d=u%2===0?n:r;return S.jsx(li,{x:c.x,width:f.x-c.x,y:h.y,height:c.y-h.y,fill:d,rx:2,ry:2,...t,animated:!1},`recBar-${u}`)},[])},"axisBars")}function qf(e){const t=P.useContext(on),n=P.useContext(Ie),{gap:r=ce.gap,bars:i}=e,a={...ce.attrs,...e.attrs},s=e.ticks?{...ce.ticks,...e.ticks}:ce.ticks,o=e.title?{...ce.title,...e.title}:ce.title,l=io(e,t);let u;s.values!==void 0?u=s.values:u=l.ticks(s.number);const c=t.domainY[1]+t.domainY[1]*.01,h=n({x:t.domainX[0],y:c}),f=n({x:t.domainX[1],y:c}),d=`M${h.x},${h.y+r} L${f.x},${f.y+r}`,g=fe(ci(l.range()),"Error calculating x position for title"),m=n({x:g,y:c});return S.jsxs("g",{className:"axis",children:[i?S.jsx(Vf,{...i,tickValues:u,scale:l,axisY:c}):null,S.jsx("path",{d,stroke:"black",...a}),S.jsxs("g",{children:[u.map((x,p)=>{const b=n({x:l(x),y:c});return S.jsxs("g",{transform:`translate(${b.x},${b.y+r})`,children:[S.jsx("line",{x1:0,y1:0,x2:0,y2:s.length,stroke:"black",...a}),S.jsx("text",{transform:`translate(0,${s.padding})`,textAnchor:"middle",dominantBaseline:"central",...s.style,children:s.format(x)})]},`tick-${p}`)}),S.jsx("g",{transform:`translate(${m.x},${m.y+r}) `,children:S.jsx("text",{textAnchor:"middle",transform:`translate(0,${o.padding})`,...o.style,children:o.text})})]})]})}function Hf(e){const t=P.useContext(on),{layoutClass:n}=t;return n===Y.Polar?S.jsx(Bf,{...e}):n===Y.Rectangular?S.jsx(qf,{...e}):(console.warn(`Axis not supported for ${n}`),null)}const Yf=bi.fromNewick("((A:1,B:1):1,C:2);"),re={opts:ys,width:100,layout:qs,margins:{top:10,right:10,bottom:10,left:10},tree:Yf,baubles:[ro({filter:()=>!0,attrs:{stroke:"black",strokeWidth:1}})],animated:!1};function Wf(e){const{width:t=re.width,height:n=re.width,margins:r=re.margins,tree:i=re.tree,layout:a=re.layout,animated:s=re.animated,baubles:o=re.baubles,axis:l}=e,u=e.opts?e.opts:re.opts,{rootAngle:c=re.opts.rootAngle,angleRange:h=re.opts.angleRange,fishEye:f=re.opts.fishEye,pollard:d=re.opts.pollard,minRadius:g=re.opts.minRadius,invert:m=re.opts.invert}=u;let x,p,{x:b,y}=e;b!==void 0&&y!==void 0?(x=t,p=n):(x=t-r.left-r.right,p=n-r.top-r.bottom,b=r.left,y=r.top);const w=a(i,u),{layoutClass:C}=w(i.getRoot()),k=ct(i.getNodes().map(N=>w(N).x)).map(N=>fe(N,"Error finding x extent from layout")),A=ct(i.getNodes().map(N=>w(N).y)).map(N=>fe(N,"Error finding y extent from layout")),E={canvasWidth:x,canvasHeight:p,domainX:k,domainY:A,layoutClass:C,invert:m,pollard:d,minRadius:g,fishEye:f,rootAngle:c,angleRange:h},I=Oh(E),j=o.map(N=>If(N,i));return S.jsx("g",{children:S.jsx("g",{transform:`translate(${b},${y})`,children:S.jsx(Ie.Provider,{value:I,children:S.jsx(on.Provider,{value:E,children:S.jsx(vt.Provider,{value:w,children:S.jsxs(wt.Provider,{value:s,children:[l?S.jsx(Hf,{...l}):null,j.map((N,L)=>S.jsx(ff,{...N},N.id??L))]})})})})})})}exports.BaseAnnotationType=q;exports.BranchLabels=Uf;exports.Branches=ro;exports.CartoonClades=jf;exports.CircleNodes=Lf;exports.FigTree=Wf;exports.HighlightClades=Of;exports.ImmutableTree=bi;exports.NexusImporter=Wc;exports.NodeLabels=Df;exports.PreOrderTraversalCache=Gc;exports.RectangleNodes=Ff;exports.TaxonSet=an;exports.dateToDecimal=cc;exports.decimalToDate=lc;exports.defaultInternalLayoutOptions=ys;exports.layoutClass=Y;exports.leapYear=gi;exports.pathToRootIterator=Vc;exports.polarLayout=Qc;exports.postOrderIterator=Bs;exports.preOrderIterator=zc;exports.pseudoTipIterator=zs;exports.psuedoRootPostOrderIterator=Bc;exports.psuedoRootPreOrderIterator=js;exports.radialLayout=Xc;exports.rectangularLayout=qs;exports.tipIterator=vi;