phylotree 2.1.2 → 2.1.3
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/phylotree.js +26 -8
- package/dist/phylotree.min.js +1 -1
- package/package.json +4 -3
- package/src/formats/phyloxml.js +24 -4
package/dist/phylotree.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('underscore'), require('xml2js'), require('lodash')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'underscore', 'xml2js', 'lodash'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.phylotree = global.phylotree || {}, global._, global.xml2js, global._$1));
|
|
5
|
-
})(this, (function (exports, _, xml2js, _$1) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('underscore'), require('xml2js'), require('fast-xml-parser'), require('lodash')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'underscore', 'xml2js', 'fast-xml-parser', 'lodash'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.phylotree = global.phylotree || {}, global._, global.xml2js, global.fastXmlParser, global._$1));
|
|
5
|
+
})(this, (function (exports, _, xml2js, fastXmlParser, _$1) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
8
8
|
if (e && e.__esModule) return e;
|
|
@@ -7145,15 +7145,18 @@
|
|
|
7145
7145
|
|
|
7146
7146
|
function parsePhyloxml(node, index) {
|
|
7147
7147
|
if (node.clade) {
|
|
7148
|
+
if (!Array.isArray(node.clade)) {
|
|
7149
|
+
node.clade = [node.clade];
|
|
7150
|
+
}
|
|
7148
7151
|
node.clade.forEach(parsePhyloxml);
|
|
7149
7152
|
node.children = node.clade;
|
|
7150
7153
|
delete node.clade;
|
|
7151
7154
|
}
|
|
7152
7155
|
|
|
7153
|
-
|
|
7154
|
-
|
|
7156
|
+
node.annotation = 1;
|
|
7157
|
+
node.attribute = "0.01";
|
|
7155
7158
|
if (node.branch_length) {
|
|
7156
|
-
|
|
7159
|
+
node.attribute = node.branch_length;
|
|
7157
7160
|
}
|
|
7158
7161
|
if (node.taxonomy) {
|
|
7159
7162
|
node.name = node.taxonomy.scientific_name;
|
|
@@ -7165,8 +7168,23 @@
|
|
|
7165
7168
|
|
|
7166
7169
|
var tree_json;
|
|
7167
7170
|
|
|
7171
|
+
if (typeof xml === "string") {
|
|
7172
|
+
if (DOMParser) {
|
|
7173
|
+
const parser = new DOMParser();
|
|
7174
|
+
xml = parser.parseFromString(xml, "text/xml");
|
|
7175
|
+
} else {
|
|
7176
|
+
const parser = new fastXmlParser.XMLParser();
|
|
7177
|
+
xml = parser.parse(xml);
|
|
7178
|
+
}
|
|
7179
|
+
}
|
|
7180
|
+
|
|
7168
7181
|
xml = xmlToJson(xml);
|
|
7169
|
-
|
|
7182
|
+
var phylogeny = xml.phyloxml.phylogeny;
|
|
7183
|
+
if (Array.isArray(phylogeny)) {
|
|
7184
|
+
phylogeny = phylogeny[0];
|
|
7185
|
+
console.warn('PhyloXML files with multiple phylogenies are not currently supported. Only the first phylogeny will be loaded.');
|
|
7186
|
+
}
|
|
7187
|
+
tree_json = phylogeny.clade;
|
|
7170
7188
|
tree_json.name = "root";
|
|
7171
7189
|
parsePhyloxml(tree_json);
|
|
7172
7190
|
|
package/dist/phylotree.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("underscore"),require("xml2js"),require("lodash")):"function"==typeof define&&define.amd?define(["exports","underscore","xml2js","lodash"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phylotree=t.phylotree||{},t._,t.xml2js,t._$1)}(this,function(t,e,n,r){"use strict";function i(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var a=i(e),o=i(r);function s(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function l(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function u(t){let e,n,r;function i(t,r,i=0,a=t.length){if(i<a){if(0!==e(r,r))return a;do{const e=i+a>>>1;n(t[e],r)<0?i=e+1:a=e}while(i<a)}return i}return 2!==t.length?(e=s,n=(e,n)=>s(t(e),n),r=(e,n)=>t(e)-n):(e=t===s||t===l?t:c,n=t,r=t),{left:i,center:function(t,e,n=0,a=t.length){const o=i(t,e,n,a-1);return o>n&&r(t[o-1],e)>-r(t[o],e)?o-1:o},right:function(t,r,i=0,a=t.length){if(i<a){if(0!==e(r,r))return a;do{const e=i+a>>>1;n(t[e],r)<=0?i=e+1:a=e}while(i<a)}return i}}}function c(){return 0}const h=u(s).right;u(function(t){return null===t?NaN:+t}).center;var f=h;const d=Math.sqrt(50),p=Math.sqrt(10),_=Math.sqrt(2);function g(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=d?10:a>=p?5:a>=_?2:1;let s,l,u;return i<0?(u=Math.pow(10,-i)/o,s=Math.round(t*u),l=Math.round(e*u),s/u<t&&++s,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*o,s=Math.round(t/u),l=Math.round(e/u),s*u<t&&++s,l*u>e&&--l),l<s&&.5<=n&&n<2?g(t,e,2*n):[s,l,u]}function m(t,e,n){return g(t=+t,e=+e,n=+n)[2]}function v(t){return t}var y=1e-6;function b(t){return"translate("+t+",0)"}function w(t){return"translate(0,"+t+")"}function x(t){return e=>+t(e)}function M(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function k(){return!this.__axis}function N(t,e){var n=[],r=null,i=null,a=6,o=6,s=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,u=1===t||4===t?-1:1,c=4===t||2===t?"x":"y",h=1===t||3===t?b:w;function f(f){var d=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,p=null==i?e.tickFormat?e.tickFormat.apply(e,n):v:i,_=Math.max(a,0)+s,g=e.range(),m=+g[0]+l,b=+g[g.length-1]+l,w=(e.bandwidth?M:x)(e.copy(),l),N=f.selection?f.selection():f,T=N.selectAll(".domain").data([null]),A=N.selectAll(".tick").data(d,e).order(),z=A.exit(),S=A.enter().append("g").attr("class","tick"),E=A.select("line"),C=A.select("text");T=T.merge(T.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),A=A.merge(S),E=E.merge(S.append("line").attr("stroke","currentColor").attr(c+"2",u*a)),C=C.merge(S.append("text").attr("fill","currentColor").attr(c,u*_).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),f!==N&&(T=T.transition(f),A=A.transition(f),E=E.transition(f),C=C.transition(f),z=z.transition(f).attr("opacity",y).attr("transform",function(t){return isFinite(t=w(t))?h(t+l):this.getAttribute("transform")}),S.attr("opacity",y).attr("transform",function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:w(t))+l)})),z.remove(),T.attr("d",4===t||2===t?o?"M"+u*o+","+m+"H"+l+"V"+b+"H"+u*o:"M"+l+","+m+"V"+b:o?"M"+m+","+u*o+"V"+l+"H"+b+"V"+u*o:"M"+m+","+l+"H"+b),A.attr("opacity",1).attr("transform",function(t){return h(w(t)+l)}),E.attr(c+"2",u*a),C.attr(c,u*_).text(p),N.filter(k).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),N.each(function(){this.__axis=w})}return f.scale=function(t){return arguments.length?(e=t,f):e},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),f):n.slice()},f.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),f):r&&r.slice()},f.tickFormat=function(t){return arguments.length?(i=t,f):i},f.tickSize=function(t){return arguments.length?(a=o=+t,f):a},f.tickSizeInner=function(t){return arguments.length?(a=+t,f):a},f.tickSizeOuter=function(t){return arguments.length?(o=+t,f):o},f.tickPadding=function(t){return arguments.length?(s=+t,f):s},f.offset=function(t){return arguments.length?(l=+t,f):l},f}var T={value:()=>{}};function A(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new z(r)}function z(t){this._=t}function S(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function E(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=T,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}z.prototype=A.prototype={constructor:z,on:function(t,e){var n,r,i=this._,a=(r=i,(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),o=-1,s=a.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<s;)if(n=(t=a[o]).type)i[n]=E(i[n],t.name,e);else if(null==e)for(n in i)i[n]=E(i[n],t.name,null);return this}for(;++o<s;)if((n=(t=a[o]).type)&&(n=S(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new z(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};var C="http://www.w3.org/1999/xhtml",$={svg:"http://www.w3.org/2000/svg",xhtml:C,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function D(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),$.hasOwnProperty(e)?{space:$[e],local:t}:t}function L(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===C&&e.documentElement.namespaceURI===C?e.createElement(t):e.createElementNS(n,t)}}function U(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function P(t){var e=D(t);return(e.local?U:L)(e)}function H(){}function O(t){return null==t?H:function(){return this.querySelector(t)}}function j(){return[]}function F(t){return null==t?j:function(){return this.querySelectorAll(t)}}function Y(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function R(t){return function(){return this.matches(t)}}function I(t){return function(e){return e.matches(t)}}var q=Array.prototype.find;function B(){return this.firstElementChild}var V=Array.prototype.filter;function X(){return Array.from(this.children)}function W(t){return new Array(t.length)}function Z(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function G(t,e,n,r,i,a){for(var o,s=0,l=e.length,u=a.length;s<u;++s)(o=e[s])?(o.__data__=a[s],r[s]=o):n[s]=new Z(t,a[s]);for(;s<l;++s)(o=e[s])&&(i[s]=o)}function K(t,e,n,r,i,a,o){var s,l,u,c=new Map,h=e.length,f=a.length,d=new Array(h);for(s=0;s<h;++s)(l=e[s])&&(d[s]=u=o.call(l,l.__data__,s,e)+"",c.has(u)?i[s]=l:c.set(u,l));for(s=0;s<f;++s)u=o.call(t,a[s],s,a)+"",(l=c.get(u))?(r[s]=l,l.__data__=a[s],c.delete(u)):n[s]=new Z(t,a[s]);for(s=0;s<h;++s)(l=e[s])&&c.get(d[s])===l&&(i[s]=l)}function Q(t){return t.__data__}function J(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function tt(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function et(t){return function(){this.removeAttribute(t)}}function nt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function rt(t,e){return function(){this.setAttribute(t,e)}}function it(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function at(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function ot(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function st(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function lt(t){return function(){this.style.removeProperty(t)}}function ut(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ct(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ht(t,e){return t.style.getPropertyValue(e)||st(t).getComputedStyle(t,null).getPropertyValue(e)}function ft(t){return function(){delete this[t]}}function dt(t,e){return function(){this[t]=e}}function pt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function _t(t){return t.trim().split(/^|\s+/)}function gt(t){return t.classList||new mt(t)}function mt(t){this._node=t,this._names=_t(t.getAttribute("class")||"")}function vt(t,e){for(var n=gt(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function yt(t,e){for(var n=gt(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function bt(t){return function(){vt(this,t)}}function wt(t){return function(){yt(this,t)}}function xt(t,e){return function(){(e.apply(this,arguments)?vt:yt)(this,t)}}function Mt(){this.textContent=""}function kt(t){return function(){this.textContent=t}}function Nt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Tt(){this.innerHTML=""}function At(t){return function(){this.innerHTML=t}}function zt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function St(){this.nextSibling&&this.parentNode.appendChild(this)}function Et(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ct(){return null}function $t(){var t=this.parentNode;t&&t.removeChild(this)}function Dt(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Lt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ut(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,a=e.length;r<a;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function Pt(t,e,n){return function(){var r,i=this.__on,a=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,s=i.length;o<s;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=e);this.addEventListener(t.type,a,n),r={type:t.type,name:t.name,value:e,listener:a,options:n},i?i.push(r):this.__on=[r]}}function Ht(t,e,n){var r=st(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function Ot(t,e){return function(){return Ht(this,t,e)}}function jt(t,e){return function(){return Ht(this,t,e.apply(this,arguments))}}Z.prototype={constructor:Z,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},mt.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Ft=[null];function Yt(t,e){this._groups=t,this._parents=e}function Rt(){return new Yt([[document.documentElement]],Ft)}function It(t){return"string"==typeof t?new Yt([[document.querySelector(t)]],[document.documentElement]):new Yt([[t]],Ft)}function qt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}Yt.prototype=Rt.prototype={constructor:Yt,select:function(t){"function"!=typeof t&&(t=O(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o,s=e[i],l=s.length,u=r[i]=new Array(l),c=0;c<l;++c)(a=s[c])&&(o=t.call(a,a.__data__,c,s))&&("__data__"in a&&(o.__data__=a.__data__),u[c]=o);return new Yt(r,this._parents)},selectAll:function(t){t="function"==typeof t?Y(t):F(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o,s=e[a],l=s.length,u=0;u<l;++u)(o=s[u])&&(r.push(t.call(o,o.__data__,u,s)),i.push(o));return new Yt(r,i)},selectChild:function(t){return this.select(null==t?B:function(t){return function(){return q.call(this.children,t)}}("function"==typeof t?t:I(t)))},selectChildren:function(t){return this.selectAll(null==t?X:function(t){return function(){return V.call(this.children,t)}}("function"==typeof t?t:I(t)))},filter:function(t){"function"!=typeof t&&(t=R(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,l=r[i]=[],u=0;u<s;++u)(a=o[u])&&t.call(a,a.__data__,u,o)&&l.push(a);return new Yt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,Q);var n=e?K:G,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var a=i.length,o=new Array(a),s=new Array(a),l=new Array(a),u=0;u<a;++u){var c=r[u],h=i[u],f=h.length,d=J(t.call(c,c&&c.__data__,u,r)),p=d.length,_=s[u]=new Array(p),g=o[u]=new Array(p);n(c,h,_,g,l[u]=new Array(f),d,e);for(var m,v,y=0,b=0;y<p;++y)if(m=_[y]){for(y>=b&&(b=y+1);!(v=g[b])&&++b<p;);m._next=v||null}}return(o=new Yt(o,r))._enter=s,o._exit=l,o},enter:function(){return new Yt(this._enter||this._groups.map(W),this._parents)},exit:function(){return new Yt(this._exit||this._groups.map(W),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,a=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?a.remove():n(a),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,a=r.length,o=Math.min(i,a),s=new Array(i),l=0;l<o;++l)for(var u,c=n[l],h=r[l],f=c.length,d=s[l]=new Array(f),p=0;p<f;++p)(u=c[p]||h[p])&&(d[p]=u);for(;l<i;++l)s[l]=n[l];return new Yt(s,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],a=i.length-1,o=i[a];--a>=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=tt);for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o,s=n[a],l=s.length,u=i[a]=new Array(l),c=0;c<l;++c)(o=s[c])&&(u[c]=o);u.sort(e)}return new Yt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,a=e[n],o=0,s=a.length;o<s;++o)(i=a[o])&&t.call(i,i.__data__,o,a);return this},attr:function(t,e){var n=D(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?nt:et:"function"==typeof e?n.local?ot:at:n.local?it:rt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?lt:"function"==typeof e?ct:ut)(t,e,null==n?"":n)):ht(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ft:"function"==typeof e?pt:dt)(t,e)):this.node()[t]},classed:function(t,e){var n=_t(t+"");if(arguments.length<2){for(var r=gt(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?xt:e?bt:wt)(n,e))},text:function(t){return arguments.length?this.each(null==t?Mt:("function"==typeof t?Nt:kt)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Tt:("function"==typeof t?zt:At)(t)):this.node().innerHTML},raise:function(){return this.each(St)},lower:function(){return this.each(Et)},append:function(t){var e="function"==typeof t?t:P(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:P(t),r=null==e?Ct:"function"==typeof e?e:O(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each($t)},clone:function(t){return this.select(t?Lt:Dt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,a=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),o=a.length;if(!(arguments.length<2)){for(s=e?Pt:Ut,r=0;r<o;++r)this.each(s(a[r],e,n));return this}var s=this.node().__on;if(s)for(var l,u=0,c=s.length;u<c;++u)for(r=0,l=s[u];r<o;++r)if((i=a[r]).type===l.type&&i.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?jt:Ot)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],a=0,o=i.length;a<o;++a)(r=i[a])&&(yield r)}};const Bt={capture:!0,passive:!1};function Vt(t){t.preventDefault(),t.stopImmediatePropagation()}function Xt(t){var e=t.document.documentElement,n=It(t).on("dragstart.drag",Vt,Bt);"onselectstart"in e?n.on("selectstart.drag",Vt,Bt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Wt(t,e){var n=t.document.documentElement,r=It(t).on("dragstart.drag",null);e&&(r.on("click.drag",Vt,Bt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Zt(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Gt(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Kt(){}var Qt=.7,Jt=1/Qt,te="\\s*([+-]?\\d+)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",re=/^#([0-9a-f]{3,8})$/,ie=new RegExp(`^rgb\\(${te},${te},${te}\\)$`),ae=new RegExp(`^rgb\\(${ne},${ne},${ne}\\)$`),oe=new RegExp(`^rgba\\(${te},${te},${te},${ee}\\)$`),se=new RegExp(`^rgba\\(${ne},${ne},${ne},${ee}\\)$`),le=new RegExp(`^hsl\\(${ee},${ne},${ne}\\)$`),ue=new RegExp(`^hsla\\(${ee},${ne},${ne},${ee}\\)$`),ce={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};function he(){return this.rgb().formatHex()}function fe(){return this.rgb().formatRgb()}function de(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=re.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?pe(e):3===n?new me(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?_e(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?_e(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=ie.exec(t))?new me(e[1],e[2],e[3],1):(e=ae.exec(t))?new me(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=oe.exec(t))?_e(e[1],e[2],e[3],e[4]):(e=se.exec(t))?_e(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=le.exec(t))?Me(e[1],e[2]/100,e[3]/100,1):(e=ue.exec(t))?Me(e[1],e[2]/100,e[3]/100,e[4]):ce.hasOwnProperty(t)?pe(ce[t]):"transparent"===t?new me(NaN,NaN,NaN,0):null}function pe(t){return new me(t>>16&255,t>>8&255,255&t,1)}function _e(t,e,n,r){return r<=0&&(t=e=n=NaN),new me(t,e,n,r)}function ge(t,e,n,r){return 1===arguments.length?((i=t)instanceof Kt||(i=de(i)),i?new me((i=i.rgb()).r,i.g,i.b,i.opacity):new me):new me(t,e,n,null==r?1:r);var i}function me(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ve(){return`#${xe(this.r)}${xe(this.g)}${xe(this.b)}`}function ye(){const t=be(this.opacity);return`${1===t?"rgb(":"rgba("}${we(this.r)}, ${we(this.g)}, ${we(this.b)}${1===t?")":`, ${t})`}`}function be(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function we(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function xe(t){return((t=we(t))<16?"0":"")+t.toString(16)}function Me(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ne(t,e,n,r)}function ke(t){if(t instanceof Ne)return new Ne(t.h,t.s,t.l,t.opacity);if(t instanceof Kt||(t=de(t)),!t)return new Ne;if(t instanceof Ne)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,s=a-i,l=(a+i)/2;return s?(o=e===a?(n-r)/s+6*(n<r):n===a?(r-e)/s+2:(e-n)/s+4,s/=l<.5?a+i:2-a-i,o*=60):s=l>0&&l<1?0:o,new Ne(o,s,l,t.opacity)}function Ne(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Te(t){return(t=(t||0)%360)<0?t+360:t}function Ae(t){return Math.max(0,Math.min(1,t||0))}function ze(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Zt(Kt,de,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:he,formatHex:he,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ke(this).formatHsl()},formatRgb:fe,toString:fe}),Zt(me,ge,Gt(Kt,{brighter(t){return t=null==t?Jt:Math.pow(Jt,t),new me(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Qt:Math.pow(Qt,t),new me(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new me(we(this.r),we(this.g),we(this.b),be(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:ve,formatHex:ve,formatHex8:function(){return`#${xe(this.r)}${xe(this.g)}${xe(this.b)}${xe(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:ye,toString:ye})),Zt(Ne,function(t,e,n,r){return 1===arguments.length?ke(t):new Ne(t,e,n,null==r?1:r)},Gt(Kt,{brighter(t){return t=null==t?Jt:Math.pow(Jt,t),new Ne(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Qt:Math.pow(Qt,t),new Ne(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new me(ze(t>=240?t-240:t+120,i,r),ze(t,i,r),ze(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ne(Te(this.h),Ae(this.s),Ae(this.l),be(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 t=be(this.opacity);return`${1===t?"hsl(":"hsla("}${Te(this.h)}, ${100*Ae(this.s)}%, ${100*Ae(this.l)}%${1===t?")":`, ${t})`}`}}));var Se=t=>()=>t;function Ee(t){return 1===(t=+t)?Ce:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Se(isNaN(e)?n:e)}}function Ce(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Se(isNaN(t)?e:t)}var $e=function t(e){var n=Ee(e);function r(t,e){var r=n((t=ge(t)).r,(e=ge(e)).r),i=n(t.g,e.g),a=n(t.b,e.b),o=Ce(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function De(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(a){for(n=0;n<r;++n)i[n]=t[n]*(1-a)+e[n]*a;return i}}function Le(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,a=new Array(i),o=new Array(r);for(n=0;n<i;++n)a[n]=Ye(t[n],e[n]);for(;n<r;++n)o[n]=e[n];return function(t){for(n=0;n<i;++n)o[n]=a[n](t);return o}}function Ue(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Pe(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function He(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=Ye(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var Oe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,je=new RegExp(Oe.source,"g");function Fe(t,e){var n,r,i,a=Oe.lastIndex=je.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(n=Oe.exec(t))&&(r=je.exec(e));)(i=r.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,l.push({i:o,x:Pe(n,r)})),a=je.lastIndex;return a<e.length&&(i=e.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var n,r=0;r<e;++r)s[(n=l[r]).i]=n.x(t);return s.join("")})}function Ye(t,e){var n,r=typeof e;return null==e||"boolean"===r?Se(e):("number"===r?Pe:"string"===r?(n=de(e))?(e=n,$e):Fe:e instanceof de?$e:e instanceof Date?Ue:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?De:Array.isArray(e)?Le:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?He:Pe)(t,e)}function Re(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Ie,qe=180/Math.PI,Be={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ve(t,e,n,r,i,a){var o,s,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,l/=s),t*r<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*qe,skewX:Math.atan(l)*qe,scaleX:o,scaleY:s}}function Xe(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(a,o){var s=[],l=[];return a=t(a),o=t(o),function(t,r,i,a,o,s){if(t!==i||r!==a){var l=o.push("translate(",null,e,null,n);s.push({i:l-4,x:Pe(t,i)},{i:l-2,x:Pe(r,a)})}else(i||a)&&o.push("translate("+i+e+a+n)}(a.translateX,a.translateY,o.translateX,o.translateY,s,l),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Pe(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(a.rotate,o.rotate,s,l),function(t,e,n,a){t!==e?a.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Pe(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(a.skewX,o.skewX,s,l),function(t,e,n,r,a,o){if(t!==n||e!==r){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:Pe(t,n)},{i:s-2,x:Pe(e,r)})}else 1===n&&1===r||a.push(i(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,l),a=o=null,function(t){for(var e,n=-1,r=l.length;++n<r;)s[(e=l[n]).i]=e.x(t);return s.join("")}}}var We=Xe(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Be:Ve(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Ze=Xe(function(t){return null==t?Be:(Ie||(Ie=document.createElementNS("http://www.w3.org/2000/svg","g")),Ie.setAttribute("transform",t),(t=Ie.transform.baseVal.consolidate())?Ve((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Be)},", ",")",")");function Ge(t){return((t=Math.exp(t))+1/t)/2}var Ke,Qe,Je=function t(e,n,r){function i(t,i){var a,o,s=t[0],l=t[1],u=t[2],c=i[0],h=i[1],f=i[2],d=c-s,p=h-l,_=d*d+p*p;if(_<1e-12)o=Math.log(f/u)/e,a=function(t){return[s+t*d,l+t*p,u*Math.exp(e*t*o)]};else{var g=Math.sqrt(_),m=(f*f-u*u+r*_)/(2*u*n*g),v=(f*f-u*u-r*_)/(2*f*n*g),y=Math.log(Math.sqrt(m*m+1)-m),b=Math.log(Math.sqrt(v*v+1)-v);o=(b-y)/e,a=function(t){var r=t*o,i=Ge(y),a=u/(n*g)*(i*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*r+y)-function(t){return((t=Math.exp(t))-1/t)/2}(y));return[s+a*d,l+a*p,u*i/Ge(e*r+y)]}}return a.duration=1e3*o*e/Math.SQRT2,a}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4),tn=0,en=0,nn=0,rn=0,an=0,on=0,sn="object"==typeof performance&&performance.now?performance:Date,ln="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function un(){return an||(ln(cn),an=sn.now()+on)}function cn(){an=0}function hn(){this._call=this._time=this._next=null}function fn(t,e,n){var r=new hn;return r.restart(t,e,n),r}function dn(){an=(rn=sn.now())+on,tn=en=0;try{!function(){un(),++tn;for(var t,e=Ke;e;)(t=an-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tn}()}finally{tn=0,function(){var t,e,n=Ke,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Ke=e);Qe=t,_n(r)}(),an=0}}function pn(){var t=sn.now(),e=t-rn;e>1e3&&(on-=e,rn=t)}function _n(t){tn||(en&&(en=clearTimeout(en)),t-an>24?(t<1/0&&(en=setTimeout(dn,t-sn.now()-on)),nn&&(nn=clearInterval(nn))):(nn||(rn=sn.now(),nn=setInterval(pn,1e3)),tn=1,ln(dn)))}function gn(t,e,n){var r=new hn;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}hn.prototype=fn.prototype={constructor:hn,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?un():+n)+(null==e?0:+e),this._next||Qe===this||(Qe?Qe._next=this:Ke=this,Qe=this),this._call=t,this._time=n,_n()},stop:function(){this._call&&(this._call=null,this._time=1/0,_n())}};var mn=A("start","end","cancel","interrupt"),vn=[];function yn(t,e,n,r,i,a){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function a(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(a){var u,c,h,f;if(1!==n.state)return l();for(u in i)if((f=i[u]).name===n.name){if(3===f.state)return gn(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[u]):+u<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[u])}if(gn(function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(h=n.tween.length),u=0,c=-1;u<h;++u)(f=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=f);r.length=c+1}}function s(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(l),n.state=5,1),a=-1,o=r.length;++a<o;)r[a].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=fn(a,0,n.time)}(t,n,{name:e,index:r,group:i,on:mn,tween:vn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function bn(t,e){var n=xn(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function wn(t,e){var n=xn(t,e);if(n.state>3)throw new Error("too late; already running");return n}function xn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Mn(t,e){var n,r,i,a=t.__transition,o=!0;if(a){for(i in e=null==e?null:e+"",a)(n=a[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete a[i]):o=!1;o&&delete t.__transition}}function kn(t,e){var n,r;return function(){var i=wn(this,t),a=i.tween;if(a!==n)for(var o=0,s=(r=n=a).length;o<s;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function Nn(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var a=wn(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===e){i[l]=s;break}l===u&&i.push(s)}a.tween=i}}function Tn(t,e,n){var r=t._id;return t.each(function(){var t=wn(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return xn(t,r).value[e]}}function An(t,e){var n;return("number"==typeof e?Pe:e instanceof de?$e:(n=de(e))?(e=n,$e):Fe)(t,e)}function zn(t){return function(){this.removeAttribute(t)}}function Sn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function En(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function Cn(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function $n(t,e,n){var r,i,a;return function(){var o,s,l=n(this);if(null!=l)return(o=this.getAttribute(t))===(s=l+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,l));this.removeAttribute(t)}}function Dn(t,e,n){var r,i,a;return function(){var o,s,l=n(this);if(null!=l)return(o=this.getAttributeNS(t.space,t.local))===(s=l+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,l));this.removeAttributeNS(t.space,t.local)}}function Ln(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Un(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Pn(t,e){return function(){bn(this,t).delay=+e.apply(this,arguments)}}function Hn(t,e){return e=+e,function(){bn(this,t).delay=e}}function On(t,e){return function(){wn(this,t).duration=+e.apply(this,arguments)}}function jn(t,e){return e=+e,function(){wn(this,t).duration=e}}var Fn=Rt.prototype.constructor;function Yn(t){return function(){this.style.removeProperty(t)}}var Rn=0;function In(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function qn(){return++Rn}var Bn=Rt.prototype;In.prototype={constructor:In,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=O(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s,l,u=r[o],c=u.length,h=a[o]=new Array(c),f=0;f<c;++f)(s=u[f])&&(l=t.call(s,s.__data__,f,u))&&("__data__"in s&&(l.__data__=s.__data__),h[f]=l,yn(h[f],e,n,f,h,xn(s,n)));return new In(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=F(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var l,u=r[s],c=u.length,h=0;h<c;++h)if(l=u[h]){for(var f,d=t.call(l,l.__data__,h,u),p=xn(l,n),_=0,g=d.length;_<g;++_)(f=d[_])&&yn(f,e,n,_,d,p);a.push(d),o.push(l)}return new In(a,o,e,n)},selectChild:Bn.selectChild,selectChildren:Bn.selectChildren,filter:function(t){"function"!=typeof t&&(t=R(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,l=r[i]=[],u=0;u<s;++u)(a=o[u])&&t.call(a,a.__data__,u,o)&&l.push(a);return new In(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var l,u=e[s],c=n[s],h=u.length,f=o[s]=new Array(h),d=0;d<h;++d)(l=u[d]||c[d])&&(f[d]=l);for(;s<r;++s)o[s]=e[s];return new In(o,this._parents,this._name,this._id)},selection:function(){return new Fn(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=qn(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],l=s.length,u=0;u<l;++u)if(o=s[u]){var c=xn(o,e);yn(o,t,n,u,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new In(r,this._parents,t,n)},call:Bn.call,nodes:Bn.nodes,node:Bn.node,size:Bn.size,empty:Bn.empty,each:Bn.each,on:function(t,e){var n=this._id;return arguments.length<2?xn(this.node(),n).on.on(t):this.each(function(t,e,n){var r,i,a=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?bn:wn;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i}}(n,t,e))},attr:function(t,e){var n=D(t),r="transform"===n?Ze:An;return this.attrTween(t,"function"==typeof e?(n.local?Dn:$n)(n,r,Tn(this,"attr."+t,e)):null==e?(n.local?Sn:zn)(n):(n.local?Cn:En)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=D(t);return this.tween(n,(r.local?Ln:Un)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?We:An;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var a=ht(this,t),o=(this.style.removeProperty(t),ht(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}(t,r)).on("end.style."+t,Yn(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,a;return function(){var o=ht(this,t),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(t),l=s=ht(this,t)),o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s))}}(t,r,Tn(this,"style."+t,e))).each(function(t,e){var n,r,i,a,o="style."+e,s="end."+o;return function(){var l=wn(this,t),u=l.on,c=null==l.value[o]?a||(a=Yn(e)):void 0;u===n&&i===c||(r=(n=u).copy()).on(s,i=c),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,a=n+"";return function(){var o=ht(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function a(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,a,n)),r}return a._value=e,a}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Tn(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=xn(this.node(),n).tween,a=0,o=i.length;a<o;++a)if((r=i[a]).name===t)return r.value;return null}return this.each((null==e?kn:Nn)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Pn:Hn)(e,t)):xn(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?On:jn)(e,t)):xn(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){wn(this,t).ease=e}}(e,t)):xn(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;wn(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},l={value:function(){0===--i&&a()}};n.each(function(){var n=wn(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(l)),n.on=e}),0===i&&a()})},[Symbol.iterator]:Bn[Symbol.iterator]};var Vn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Xn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}Rt.prototype.interrupt=function(t){return this.each(function(){Mn(this,t)})},Rt.prototype.transition=function(t){var e,n;t instanceof In?(e=t._id,t=t._name):(e=qn(),(n=Vn).time=un(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],l=s.length,u=0;u<l;++u)(o=s[u])&&yn(o,t,e,u,s,n||Xn(o,e));return new In(r,this._parents,t,e)};var Wn=t=>()=>t;function Zn(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function Gn(t){t.preventDefault(),t.stopImmediatePropagation()}var Kn={name:"drag"},Qn={name:"space"},Jn={name:"handle"},tr={name:"center"};const{abs:er,max:nr,min:rr}=Math;function ir(t){return[+t[0],+t[1]]}function ar(t){return[ir(t[0]),ir(t[1])]}var or={name:"x",handles:["w","e"].map(pr),input:function(t,e){return null==t?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},sr={name:"y",handles:["n","s"].map(pr),input:function(t,e){return null==t?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},lr={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(pr),input:function(t){return null==t?null:ar(t)},output:function(t){return t}},ur={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},cr={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},hr={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},fr={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},dr={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function pr(t){return{type:t}}function _r(t){return!t.ctrlKey&&!t.button}function gr(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function mr(){return navigator.maxTouchPoints||"ontouchstart"in this}function vr(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function yr(){return function(t){var e,n=gr,r=_r,i=mr,a=!0,o=A("start","brush","end"),s=6;function l(e){var n=e.property("__brush",_).selectAll(".overlay").data([pr("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",ur.overlay).merge(n).each(function(){var t=vr(this).extent;It(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])}),e.selectAll(".selection").data([pr("selection")]).enter().append("rect").attr("class","selection").attr("cursor",ur.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=e.selectAll(".handle").data(t.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return ur[t.type]}),e.each(u).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",f).filter(i).on("touchstart.brush",f).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function u(){var t=It(this),e=vr(this).selection;e?(t.selectAll(".selection").style("display",null).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1]),t.selectAll(".handle").style("display",null).attr("x",function(t){return"e"===t.type[t.type.length-1]?e[1][0]-s/2:e[0][0]-s/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-s/2:e[0][1]-s/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+s:s}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+s:s})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function c(t,e,n){var r=t.__brush.emitter;return!r||n&&r.clean?new h(t,e,n):r}function h(t,e,n){this.that=t,this.args=e,this.state=t.__brush,this.active=0,this.clean=n}function f(n){if((!e||n.touches)&&r.apply(this,arguments)){var i,o,s,l,h,f,d,p,_,g,m,v=this,y=n.target.__data__.type,b="selection"===(a&&n.metaKey?y="overlay":y)?Kn:a&&n.altKey?tr:Jn,w=t===sr?null:fr[y],x=t===or?null:dr[y],M=vr(v),k=M.extent,N=M.selection,T=k[0][0],A=k[0][1],z=k[1][0],S=k[1][1],E=0,C=0,$=w&&x&&a&&n.shiftKey,D=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=qt(t,v)).point0=t.slice(),t.identifier=e,t});Mn(v);var L=c(v,arguments,!0).beforestart();if("overlay"===y){N&&(_=!0);const e=[D[0],D[1]||D[0]];M.selection=N=[[i=t===sr?T:rr(e[0][0],e[1][0]),s=t===or?A:rr(e[0][1],e[1][1])],[h=t===sr?z:nr(e[0][0],e[1][0]),d=t===or?S:nr(e[0][1],e[1][1])]],D.length>1&&j(n)}else i=N[0][0],s=N[0][1],h=N[1][0],d=N[1][1];o=i,l=s,f=h,p=d;var U=It(v).attr("pointer-events","none"),P=U.selectAll(".overlay").attr("cursor",ur[y]);if(n.touches)L.moved=O,L.ended=F;else{var H=It(n.view).on("mousemove.brush",O,!0).on("mouseup.brush",F,!0);a&&H.on("keydown.brush",Y,!0).on("keyup.brush",R,!0),Xt(n.view)}u.call(v),L.start(n,b.name)}function O(t){for(const e of t.changedTouches||[t])for(const t of D)t.identifier===e.identifier&&(t.cur=qt(e,v));if($&&!g&&!m&&1===D.length){const t=D[0];er(t.cur[0]-t[0])>er(t.cur[1]-t[1])?m=!0:g=!0}for(const t of D)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);_=!0,Gn(t),j(t)}function j(t){const e=D[0],n=e.point0;var r;switch(E=e[0]-n[0],C=e[1]-n[1],b){case Qn:case Kn:w&&(E=nr(T-i,rr(z-h,E)),o=i+E,f=h+E),x&&(C=nr(A-s,rr(S-d,C)),l=s+C,p=d+C);break;case Jn:D[1]?(w&&(o=nr(T,rr(z,D[0][0])),f=nr(T,rr(z,D[1][0])),w=1),x&&(l=nr(A,rr(S,D[0][1])),p=nr(A,rr(S,D[1][1])),x=1)):(w<0?(E=nr(T-i,rr(z-i,E)),o=i+E,f=h):w>0&&(E=nr(T-h,rr(z-h,E)),o=i,f=h+E),x<0?(C=nr(A-s,rr(S-s,C)),l=s+C,p=d):x>0&&(C=nr(A-d,rr(S-d,C)),l=s,p=d+C));break;case tr:w&&(o=nr(T,rr(z,i-E*w)),f=nr(T,rr(z,h+E*w))),x&&(l=nr(A,rr(S,s-C*x)),p=nr(A,rr(S,d+C*x)))}f<o&&(w*=-1,r=i,i=h,h=r,r=o,o=f,f=r,y in cr&&P.attr("cursor",ur[y=cr[y]])),p<l&&(x*=-1,r=s,s=d,d=r,r=l,l=p,p=r,y in hr&&P.attr("cursor",ur[y=hr[y]])),M.selection&&(N=M.selection),g&&(o=N[0][0],f=N[1][0]),m&&(l=N[0][1],p=N[1][1]),N[0][0]===o&&N[0][1]===l&&N[1][0]===f&&N[1][1]===p||(M.selection=[[o,l],[f,p]],u.call(v),L.brush(t,b.name))}function F(t){if(function(t){t.stopImmediatePropagation()}(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else Wt(t.view,_),H.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);U.attr("pointer-events","all"),P.attr("cursor",ur.overlay),M.selection&&(N=M.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(N)&&(M.selection=null,u.call(v)),L.end(t,b.name)}function Y(t){switch(t.keyCode){case 16:$=w&&x;break;case 18:b===Jn&&(w&&(h=f-E*w,i=o+E*w),x&&(d=p-C*x,s=l+C*x),b=tr,j(t));break;case 32:b!==Jn&&b!==tr||(w<0?h=f-E:w>0&&(i=o-E),x<0?d=p-C:x>0&&(s=l-C),b=Qn,P.attr("cursor",ur.selection),j(t));break;default:return}Gn(t)}function R(t){switch(t.keyCode){case 16:$&&(g=m=$=!1,j(t));break;case 18:b===tr&&(w<0?h=f:w>0&&(i=o),x<0?d=p:x>0&&(s=l),b=Jn,j(t));break;case 32:b===Qn&&(t.altKey?(w&&(h=f-E*w,i=o+E*w),x&&(d=p-C*x,s=l+C*x),b=tr):(w<0?h=f:w>0&&(i=o),x<0?d=p:x>0&&(s=l),b=Jn),P.attr("cursor",ur[y]),j(t));break;default:return}Gn(t)}}function d(t){c(this,arguments).moved(t)}function p(t){c(this,arguments).ended(t)}function _(){var e=this.__brush||{selection:null};return e.extent=ar(n.apply(this,arguments)),e.dim=t,e}return l.move=function(e,n,r){e.tween?e.on("start.brush",function(t){c(this,arguments).beforestart().start(t)}).on("interrupt.brush end.brush",function(t){c(this,arguments).end(t)}).tween("brush",function(){var e=this,r=e.__brush,i=c(e,arguments),a=r.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),s=Ye(a,o);function l(t){r.selection=1===t&&null===o?null:s(t),u.call(e),i.brush()}return null!==a&&null!==o?l:l(1)}):e.each(function(){var e=this,i=arguments,a=e.__brush,o=t.input("function"==typeof n?n.apply(e,i):n,a.extent),s=c(e,i).beforestart();Mn(e),a.selection=null===o?null:o,u.call(e),s.start(r).brush(r).end(r)})},l.clear=function(t,e){l.move(t,null,e)},h.prototype={beforestart:function(){return 1===++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,e){return this.starting?(this.starting=!1,this.emit("start",t,e)):this.emit("brush",t),this},brush:function(t,e){return this.emit("brush",t,e),this},end:function(t,e){return 0===--this.active&&(delete this.state.emitter,this.emit("end",t,e)),this},emit:function(e,n,r){var i=It(this.that).datum();o.call(e,this.that,new Zn(e,{sourceEvent:n,target:l,selection:t.output(this.state.selection),mode:r,dispatch:o}),i)}},l.extent=function(t){return arguments.length?(n="function"==typeof t?t:Wn(ar(t)),l):n},l.filter=function(t){return arguments.length?(r="function"==typeof t?t:Wn(!!t),l):r},l.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Wn(!!t),l):i},l.handleSize=function(t){return arguments.length?(s=+t,l):s},l.keyModifiers=function(t){return arguments.length?(a=!!t,l):a},l.on=function(){var t=o.on.apply(o,arguments);return t===o?l:t},l}(lr)}const br=Math.PI,wr=2*br,xr=1e-6,Mr=wr-xr;function kr(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class Nr{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?kr:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return kr;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=Math.round(arguments[e]*n)/n+t[e]}}(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,a){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,(i=+i)<0)throw new Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-t,l=r-e,u=a-t,c=o-e,h=u*u+c*c;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(h>xr)if(Math.abs(c*s-l*u)>xr&&i){let f=n-a,d=r-o,p=s*s+l*l,_=f*f+d*d,g=Math.sqrt(p),m=Math.sqrt(h),v=i*Math.tan((br-Math.acos((p+h-_)/(2*g*m)))/2),y=v/m,b=v/g;Math.abs(y-1)>xr&&this._append`L${t+y*u},${e+y*c}`,this._append`A${i},${i},0,0,${+(c*f>u*d)},${this._x1=t+b*s},${this._y1=e+b*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,a){if(t=+t,e=+e,a=!!a,(n=+n)<0)throw new Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),l=t+o,u=e+s,c=1^a,h=a?r-i:i-r;null===this._x1?this._append`M${l},${u}`:(Math.abs(this._x1-l)>xr||Math.abs(this._y1-u)>xr)&&this._append`L${l},${u}`,n&&(h<0&&(h=h%wr+wr),h>Mr?this._append`A${n},${n},0,1,${c},${t-o},${e-s}A${n},${n},0,1,${c},${this._x1=l},${this._y1=u}`:h>xr&&this._append`A${n},${n},0,${+(h>=br)},${c},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}}function Tr(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Ar(t){return(t=Tr(Math.abs(t)))?t[1]:NaN}var zr,Sr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Er(t){if(!(e=Sr.exec(t)))throw new Error("invalid format: "+t);var e;return new Cr({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function Cr(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function $r(t,e){var n=Tr(t,e);if(!n)return t+"";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")}Er.prototype=Cr.prototype,Cr.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Dr={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>$r(100*t,e),r:$r,s:function(t,e){var n=Tr(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(zr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Tr(t,Math.max(0,e+a-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Lr(t){return t}var Ur,Pr,Hr,Or=Array.prototype.map,jr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Fr(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Lr:(e=Or.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,a=[],o=0,s=e[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?Lr:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(Or.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=Er(t)).fill,n=t.align,h=t.sign,f=t.symbol,d=t.zero,p=t.width,_=t.comma,g=t.precision,m=t.trim,v=t.type;"n"===v?(_=!0,v="g"):Dr[v]||(void 0===g&&(g=12),m=!0,v="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var y="$"===f?i:"#"===f&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",b="$"===f?a:/[%p]/.test(v)?l:"",w=Dr[v],x=/[defgprs%]/.test(v);function M(t){var i,a,l,f=y,M=b;if("c"===v)M=w(t)+M,t="";else{var k=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:w(Math.abs(t),g),m&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),k&&0===+t&&"+"!==h&&(k=!1),f=(k?"("===h?h:u:"-"===h||"("===h?"":h)+f,M=("s"===v?jr[8+zr/3]:"")+M+(k&&"("===h?")":""),x)for(i=-1,a=t.length;++i<a;)if(48>(l=t.charCodeAt(i))||l>57){M=(46===l?o+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}_&&!d&&(t=r(t,1/0));var N=f.length+t.length+M.length,T=N<p?new Array(p-N+1).join(e):"";switch(_&&d&&(t=r(T+t,T.length?p-M.length:1/0),T=""),n){case"<":t=f+t+M+T;break;case"=":t=f+T+t+M;break;case"^":t=T.slice(0,N=T.length>>1)+f+t+M+T.slice(N);break;default:t=T+f+t+M}return s(t)}return g=void 0===g?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:h,formatPrefix:function(t,e){var n=h(((t=Er(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Ar(e)/3))),i=Math.pow(10,-r),a=jr[8+r/3];return function(t){return n(i*t)+a}}}}function Yr(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function Rr(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=qr)):void 0===e&&(e=Ir);for(var n,r,i,a,o,s=new Xr(t),l=[s];n=l.pop();)if((i=e(n.data))&&(o=(i=Array.from(i)).length))for(n.children=i,a=o-1;a>=0;--a)l.push(r=i[a]=new Xr(i[a])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(Vr)}function Ir(t){return t.children}function qr(t){return Array.isArray(t)?t[1]:null}function Br(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Vr(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Xr(t){this.data=t,this.depth=this.height=0,this.parent=null}function Wr(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Zr(t){return+t}Ur=Fr({thousands:",",grouping:[3],currency:["$",""]}),Pr=Ur.format,Hr=Ur.formatPrefix,Xr.prototype=Rr.prototype={constructor:Xr,count:function(){return this.eachAfter(Yr)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,a=this,o=[a],s=[],l=-1;a=o.pop();)if(s.push(a),n=a.children)for(r=0,i=n.length;r<i;++r)o.push(n[r]);for(;a=s.pop();)t.call(e,a,++l,this);return this},eachBefore:function(t,e){for(var n,r,i=this,a=[i],o=-1;i=a.pop();)if(t.call(e,i,++o,this),n=i.children)for(r=n.length-1;r>=0;--r)a.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})},sort:function(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t},links:function(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e},copy:function(){return Rr(this).eachBefore(Br)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,a=[i];do{for(t=a.reverse(),a=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)a.push(e[n])}while(a.length)}};var Gr=[0,1];function Kr(t){return t}function Qr(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function Jr(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=Qr(i,r),a=n(o,a)):(r=Qr(r,i),a=n(a,o)),function(t){return a(r(t))}}function ti(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=Qr(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(e){var n=f(t,e,1,r)-1;return a[n](i[n](e))}}function ei(){var t,e,n,r,i,a,o=Gr,s=Gr,l=Ye,u=Kr;function c(){var t,e,n,l=Math.min(o.length,s.length);return u!==Kr&&(t=o[0],e=o[l-1],t>e&&(n=t,t=e,e=n),u=function(n){return Math.max(t,Math.min(e,n))}),r=l>2?ti:Jr,i=a=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(o.map(t),s,l)))(t(u(e)))}return h.invert=function(n){return u(e((a||(a=r(s,o.map(t),Pe)))(n)))},h.domain=function(t){return arguments.length?(o=Array.from(t,Zr),c()):o.slice()},h.range=function(t){return arguments.length?(s=Array.from(t),c()):s.slice()},h.rangeRound=function(t){return s=Array.from(t),l=Re,c()},h.clamp=function(t){return arguments.length?(u=!!t||Kr,c()):u!==Kr},h.interpolate=function(t){return arguments.length?(l=t,c()):l},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,c()}}function ni(t,e,n,r){var i,a=function(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?m(e,t,n):m(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}(t,e,n);switch((r=Er(null==r?",f":r)).type){case"s":var o=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Ar(e)/3)))-Ar(Math.abs(t)))}(a,o))||(r.precision=i),Hr(r,o);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Ar(e)-Ar(t))+1}(a,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-Ar(Math.abs(t)))}(a))||(r.precision=i-2*("%"===r.type))}return Pr(r)}function ri(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)===(e=+e))return[t];const r=e<t,[i,a,o]=r?g(e,t,n):g(t,e,n);if(!(a>=i))return[];const s=a-i+1,l=new Array(s);if(r)if(o<0)for(let t=0;t<s;++t)l[t]=(a-t)/-o;else for(let t=0;t<s;++t)l[t]=(a-t)*o;else if(o<0)for(let t=0;t<s;++t)l[t]=(i+t)/-o;else for(let t=0;t<s;++t)l[t]=(i+t)*o;return l}(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return ni(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,a=e(),o=0,s=a.length-1,l=a[o],u=a[s],c=10;for(u<l&&(i=l,l=u,u=i,i=o,o=s,s=i);c-- >0;){if((i=m(l,u,n))===r)return a[o]=l,a[s]=u,e(a);if(i>0)l=Math.floor(l/i)*i,u=Math.ceil(u/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,u=Math.floor(u*i)/i}r=i}return t},t}function ii(){var t=ei()(Kr,Kr);return t.copy=function(){return e=t,ii().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},Wr.apply(t,arguments),ri(t)}const ai=new Date,oi=new Date;function si(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=e=>(t(e=new Date(+e)),e),i.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),i.round=t=>{const e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=(t,n)=>(e(t=new Date(+t),null==n?1:Math.floor(n)),t),i.range=(n,r,a)=>{const o=[];if(n=i.ceil(n),a=null==a?1:Math.floor(a),!(n<r&&a>0))return o;let s;do{o.push(s=new Date(+n)),e(n,a),t(n)}while(s<n&&n<r);return o},i.filter=n=>si(e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)},(t,r)=>{if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}),n&&(i.count=(e,r)=>(ai.setTime(+e),oi.setTime(+r),t(ai),t(oi),Math.floor(n(ai,oi))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?e=>r(e)%t===0:e=>i.count(0,e)%t===0):i:null)),i}const li=6e4,ui=864e5,ci=6048e5,hi=si(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*li)/ui,t=>t.getDate()-1);hi.range;const fi=si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ui,t=>t.getUTCDate()-1);fi.range;const di=si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ui,t=>Math.floor(t/ui));function pi(t){return si(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+7*e)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*li)/ci)}di.range;const _i=pi(0),gi=pi(1),mi=pi(2),vi=pi(3),yi=pi(4),bi=pi(5),wi=pi(6);function xi(t){return si(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)},(t,e)=>(e-t)/ci)}_i.range,gi.range,mi.range,vi.range,yi.range,bi.range,wi.range;const Mi=xi(0),ki=xi(1),Ni=xi(2),Ti=xi(3),Ai=xi(4),zi=xi(5),Si=xi(6);Mi.range,ki.range,Ni.range,Ti.range,Ai.range,zi.range,Si.range;const Ei=si(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Ei.every=t=>isFinite(t=Math.floor(t))&&t>0?si(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)}):null,Ei.range;const Ci=si(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());function $i(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Di(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Li(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}Ci.every=t=>isFinite(t=Math.floor(t))&&t>0?si(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)}):null,Ci.range;var Ui,Pi,Hi={"-":"",_:" ",0:"0"},Oi=/^\s*\d+/,ji=/^%/,Fi=/[\\^$*+?|[\]().{}]/g;function Yi(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function Ri(t){return t.replace(Fi,"\\$&")}function Ii(t){return new RegExp("^(?:"+t.map(Ri).join("|")+")","i")}function qi(t){return new Map(t.map((t,e)=>[t.toLowerCase(),e]))}function Bi(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Vi(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Xi(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Wi(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Zi(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Gi(t,e,n){var r=Oi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Ki(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Qi(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function Ji(t,e,n){var r=Oi.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function ta(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ea(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function na(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function ra(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function ia(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function aa(t,e,n){var r=Oi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function oa(t,e,n){var r=Oi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function sa(t,e,n){var r=Oi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function la(t,e,n){var r=ji.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ua(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function ca(t,e,n){var r=Oi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function ha(t,e){return Yi(t.getDate(),e,2)}function fa(t,e){return Yi(t.getHours(),e,2)}function da(t,e){return Yi(t.getHours()%12||12,e,2)}function pa(t,e){return Yi(1+hi.count(Ei(t),t),e,3)}function _a(t,e){return Yi(t.getMilliseconds(),e,3)}function ga(t,e){return _a(t,e)+"000"}function ma(t,e){return Yi(t.getMonth()+1,e,2)}function va(t,e){return Yi(t.getMinutes(),e,2)}function ya(t,e){return Yi(t.getSeconds(),e,2)}function ba(t){var e=t.getDay();return 0===e?7:e}function wa(t,e){return Yi(_i.count(Ei(t)-1,t),e,2)}function xa(t){var e=t.getDay();return e>=4||0===e?yi(t):yi.ceil(t)}function Ma(t,e){return t=xa(t),Yi(yi.count(Ei(t),t)+(4===Ei(t).getDay()),e,2)}function ka(t){return t.getDay()}function Na(t,e){return Yi(gi.count(Ei(t)-1,t),e,2)}function Ta(t,e){return Yi(t.getFullYear()%100,e,2)}function Aa(t,e){return Yi((t=xa(t)).getFullYear()%100,e,2)}function za(t,e){return Yi(t.getFullYear()%1e4,e,4)}function Sa(t,e){var n=t.getDay();return Yi((t=n>=4||0===n?yi(t):yi.ceil(t)).getFullYear()%1e4,e,4)}function Ea(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Yi(e/60|0,"0",2)+Yi(e%60,"0",2)}function Ca(t,e){return Yi(t.getUTCDate(),e,2)}function $a(t,e){return Yi(t.getUTCHours(),e,2)}function Da(t,e){return Yi(t.getUTCHours()%12||12,e,2)}function La(t,e){return Yi(1+fi.count(Ci(t),t),e,3)}function Ua(t,e){return Yi(t.getUTCMilliseconds(),e,3)}function Pa(t,e){return Ua(t,e)+"000"}function Ha(t,e){return Yi(t.getUTCMonth()+1,e,2)}function Oa(t,e){return Yi(t.getUTCMinutes(),e,2)}function ja(t,e){return Yi(t.getUTCSeconds(),e,2)}function Fa(t){var e=t.getUTCDay();return 0===e?7:e}function Ya(t,e){return Yi(Mi.count(Ci(t)-1,t),e,2)}function Ra(t){var e=t.getUTCDay();return e>=4||0===e?Ai(t):Ai.ceil(t)}function Ia(t,e){return t=Ra(t),Yi(Ai.count(Ci(t),t)+(4===Ci(t).getUTCDay()),e,2)}function qa(t){return t.getUTCDay()}function Ba(t,e){return Yi(ki.count(Ci(t)-1,t),e,2)}function Va(t,e){return Yi(t.getUTCFullYear()%100,e,2)}function Xa(t,e){return Yi((t=Ra(t)).getUTCFullYear()%100,e,2)}function Wa(t,e){return Yi(t.getUTCFullYear()%1e4,e,4)}function Za(t,e){var n=t.getUTCDay();return Yi((t=n>=4||0===n?Ai(t):Ai.ceil(t)).getUTCFullYear()%1e4,e,4)}function Ga(){return"+0000"}function Ka(){return"%"}function Qa(t){return+t}function Ja(t){return Math.floor(+t/1e3)}function to(t){return function(){return t}}function eo(t){this._context=t}function no(t){return new eo(t)}function ro(t){return t[0]}function io(t){return t[1]}function ao(t,e){var n=to(!0),r=null,i=no,a=null,o=function(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new Nr(e)}(s);function s(s){var l,u,c,h=(s=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(s)).length,f=!1;for(null==r&&(a=i(c=o())),l=0;l<=h;++l)!(l<h&&n(u=s[l],l,s))===f&&((f=!f)?a.lineStart():a.lineEnd()),f&&a.point(+t(u,l,s),+e(u,l,s));if(c)return a=null,c+""||null}return t="function"==typeof t?t:void 0===t?ro:to(t),e="function"==typeof e?e:void 0===e?io:to(e),s.x=function(e){return arguments.length?(t="function"==typeof e?e:to(+e),s):t},s.y=function(t){return arguments.length?(e="function"==typeof t?t:to(+t),s):e},s.defined=function(t){return arguments.length?(n="function"==typeof t?t:to(!!t),s):n},s.curve=function(t){return arguments.length?(i=t,null!=r&&(a=i(r)),s):i},s.context=function(t){return arguments.length?(null==t?r=a=null:a=i(r=t),s):r},s}function oo(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function so(t){this._context=t}function lo(t){return new so(t)}function uo(t,e){this._context=t,this._t=e}!function(t){Ui=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,s=t.months,l=t.shortMonths,u=Ii(i),c=qi(i),h=Ii(a),f=qi(a),d=Ii(o),p=qi(o),_=Ii(s),g=qi(s),m=Ii(l),v=qi(l),y={a:function(t){return o[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:null,d:ha,e:ha,f:ga,g:Aa,G:Sa,H:fa,I:da,j:pa,L:_a,m:ma,M:va,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Qa,s:Ja,S:ya,u:ba,U:wa,V:Ma,w:ka,W:Na,x:null,X:null,y:Ta,Y:za,Z:Ea,"%":Ka},b={a:function(t){return o[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return s[t.getUTCMonth()]},c:null,d:Ca,e:Ca,f:Pa,g:Xa,G:Za,H:$a,I:Da,j:La,L:Ua,m:Ha,M:Oa,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Qa,s:Ja,S:ja,u:Fa,U:Ya,V:Ia,w:qa,W:Ba,x:null,X:null,y:Va,Y:Wa,Z:Ga,"%":Ka},w={a:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.w=f.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=_.exec(e.slice(n));return r?(t.m=g.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return k(t,e,n,r)},d:ea,e:ea,f:sa,g:Ki,G:Gi,H:ra,I:ra,j:na,L:oa,m:ta,M:ia,p:function(t,e,n){var r=u.exec(e.slice(n));return r?(t.p=c.get(r[0].toLowerCase()),n+r[0].length):-1},q:Ji,Q:ua,s:ca,S:aa,u:Vi,U:Xi,V:Wi,w:Bi,W:Zi,x:function(t,e,r){return k(t,n,e,r)},X:function(t,e,n){return k(t,r,e,n)},y:Ki,Y:Gi,Z:Qi,"%":la};function x(t,e){return function(n){var r,i,a,o=[],s=-1,l=0,u=t.length;for(n instanceof Date||(n=new Date(+n));++s<u;)37===t.charCodeAt(s)&&(o.push(t.slice(l,s)),null!=(i=Hi[r=t.charAt(++s)])?r=t.charAt(++s):i="e"===r?" ":"0",(a=e[r])&&(r=a(n,i)),o.push(r),l=s+1);return o.push(t.slice(l,s)),o.join("")}}function M(t,e){return function(n){var r,i,a=Li(1900,void 0,1);if(k(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(e&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(r=Di(Li(a.y,0,1))).getUTCDay(),r=i>4||0===i?ki.ceil(r):ki(r),r=fi.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(i=(r=$i(Li(a.y,0,1))).getDay(),r=i>4||0===i?gi.ceil(r):gi(r),r=hi.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),i="Z"in a?Di(Li(a.y,0,1)).getUTCDay():$i(Li(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(i+5)%7:a.w+7*a.U-(i+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,Di(a)):$i(a)}}function k(t,e,n,r){for(var i,a,o=0,s=e.length,l=n.length;o<s;){if(r>=l)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(a=w[i in Hi?e.charAt(o++):i])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return y.x=x(n,y),y.X=x(r,y),y.c=x(e,y),b.x=x(n,b),b.X=x(r,b),b.c=x(e,b),{format:function(t){var e=x(t+="",y);return e.toString=function(){return t},e},parse:function(t){var e=M(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=x(t+="",b);return e.toString=function(){return t},e},utcParse:function(t){var e=M(t+="",!0);return e.toString=function(){return t},e}}}(t),Ui.format,Pi=Ui.parse,Ui.utcFormat,Ui.utcParse}({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"]}),eo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}},so.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:oo(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:oo(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},uo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}};var co=t=>()=>t;function ho(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function fo(t,e,n){this.k=t,this.x=e,this.y=n}fo.prototype={constructor:fo,scale:function(t){return 1===t?this:new fo(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new fo(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var po=new fo(1,0,0);function _o(t){t.stopImmediatePropagation()}function go(t){t.preventDefault(),t.stopImmediatePropagation()}function mo(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function vo(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function yo(){return this.__zoom||po}function bo(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function wo(){return navigator.maxTouchPoints||"ontouchstart"in this}function xo(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],a=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}fo.prototype;function Mo(t){return!a.has(t,"children")}function ko(t,e,n){let r=[];return function i(a){Mo(a)?e&&a!=t&&r.push(a):(n&&a!=t&&r.push(a),a.children.forEach(i))}(t),r}var No=Object.freeze({__proto__:null,graftANode:function(t,e,n,r){let i=this.nodes.descendants();if(t.parent){if(i.indexOf(t)>=0){let i=t.parent.children.indexOf(t),a={name:n,parent:t.parent,attribute:r?r[2]:null,original_child_order:t.original_child_order},o={name:e,parent:a,attribute:r?r[1]:null,original_child_order:2};a.children=[t,o],t.parent.children[i]=a,t.parent=a,t.attribute=r?r[0]:null,t.original_child_order=1}}return this},addChild:function(t,e){return t.children?t.children.push(e):t.children=[e],t},createNode:function(t,e){return{data:{name:t,attribute:e?e[1]:null},parent:""}},deleteANode:function(t){let e=this.nodes.descendants();if("number"!=typeof t)return this.deleteANode(e.indexOf(t));if(t>0&&t<e.length){let n=e[t];if(n.parent){let r=n.parent.children.indexOf(n);r>=0&&(e.splice(t,1),n.children&&n.children.forEach(function(t){t.original_child_order=n.parent.children.length,n.parent.children.push(t),t.parent=n.parent}),n.parent.children.length>2?n.parent.children.splice(r,1):n.parent.parent?(n.parent.parent.children[n.parent.parent.children.indexOf(n.parent)]=n.parent.children[1-r],n.parent.children[1-r].parent=n.parent.parent,e.splice(e.indexOf(n.parent),1)):(e.splice(0,1),e.parent=null,delete e.data.attribute,delete e.data.annotation,delete e.data.original_child_order,e.name="root",e.data.name="root"))}}return this},getTips:function(){return a.filter(this.nodes.descendants(),t=>!a.has(t,"children"))},getInternals:function(){return a.filter(this.nodes.descendants(),t=>a.has(t,"children"))},getRootNode:function(){return this.nodes},getNodes:function(){return this.nodes},getNodeByName:function(t){return a.filter(this.nodes.descendants(),e=>e.data.name==t)[0]},assignAttributes:function(t){a.each(this.nodes.descendants(),function(e){e.data&&e.data.name in t&&(e.annotations=t[e.data.name])})},isLeafNode:Mo,updateKeyName:function(t,e){return this.nodes.each(function(n){t in n&&(e&&(n[e]=n[t]),delete n[t])}),this},clearInternalNodes:function(t){t||this.nodes.each(t=>{Mo(t)||(t[this.selection_attribute_name]=!1,t.data.traits||(t.data.traits={}),t.data.traits[this.selection_attribute_name]=t[this.selection_attribute_name])})},selectAllDescendants:ko});function To(t,e={}){const n=/^-?\d+(\.\d+)?$/;let r=e.left_delimiter||"{",i=e.right_delimiter||"}",a=[];function o(){let t=a[a.length-1];"children"in t||(t.children=[]),a.push({name:null}),t.children.push(a[a.length-1]),a[a.length-1].original_child_order=t.children.length}function s(){let t=a.pop();t.name=c,"children"in t?t.bootstrap_values=c:t.name=c,t.attribute=h,"["==r&&f.includes("&&NHX")?f.split(":").slice(1).forEach(e=>{const[r,i]=e.split("=");t[r]=n.test(i)?+i:i}):t.annotation=f,c="",h="",f=""}function l(e){return{json:null,error:"Unexpected '"+t[e]+"' in '"+t.substring(e-20,e+1)+"[ERROR HERE]"+t.substring(e+1,e+20)+"'"}}let u=0,c="",h="",f="",d=null,p={"'":1,'"':1},_={name:"root"};a.push(_);for(var g=/\s/,m=0;m<t.length;m++)try{var v=t[m];switch(u){case 0:"("==v&&(o(),u=1);break;case 1:case 3:if(":"==v)u=3;else if(","==v||")"==v)try{s(),u=1,","==v&&o()}catch(t){return l(m)}else if("("==v){if(c.length>0)return l(m);o()}else{if(v in p){if(1==u&&0===c.length&&0===h.length&&0===f.length){u=2,d=v;continue}return l(m)}if(v==r){if(f.length)return l(m);u=4}else if(3==u)h+=v;else{if(g.test(v))continue;if(";"==v){m=t.length;break}c+=v}}break;case 2:if(v==d){if(m<t.length-1&&t[m+1]==d){m++,c+=d;continue}d=0,u=1;continue}c+=v;break;case 4:if(v==i)u=3;else{if(v==r)return l(m);f+=v}}}catch(t){return l(m)}return 1!=a.length?l(t.length-1):{json:_,error:null}}function Ao(t,e){let n=this;t||(t=t=>"");let r=[];return t=t||"",function e(i){if(i.notshown)return;if(Mo(i)||(r.push("("),i.children.forEach(function(t,n){n&&r.push(","),e(t)}),r.push(")")),"root"!==i.data.name){const t=i.data.name.replaceAll("'","''");/\W/.test(t)?r.push("'"+t+"'"):r.push(t)}r.push(t(i));let a=n.branch_length_accessor(i);void 0!==a&&r.push(":"+a)}(e||this.nodes),r.join("")+";"}function zo(t){let e=t,n=e.toUpperCase().indexOf("BEGIN DATA;"),r=e.slice(n);if(r.length<2)return"";n=r.toUpperCase().indexOf("END;");let i=r.slice(0,n);r=a.map(i.split(";"),t=>t.trim());let o=a.filter(r,t=>t.toUpperCase().startsWith("DIMENSION"));o=o[0].split(" "),o=a.object(a.map(a.rest(o),t=>t.split("=")));let s=a.filter(r,t=>t.toUpperCase().startsWith("FORMAT"));s=s[0].split(" "),s=a.object(a.map(a.rest(s),t=>t.split("="))),s.symbols=a.reject(s.symbols.split(""),t=>'"'==t);let l=a.filter(r,t=>t.toUpperCase().startsWith("MATRIX"));return l=l[0].split("\n"),l=a.object(a.map(a.rest(l),t=>a.compact(t.split(" ")))),l=a.mapObject(l,(t,e)=>"?"==t?s.symbols:Array(t)),{dimensions:o,format:s,matrix:l}}function So(t,e,n){a.each(t.getTips(),t=>{t.data.test=n.matrix[t.data.name]})}function Eo(t){let e=t,n=e.toUpperCase().indexOf("BEGIN TREES;"),r=e.slice(n);if(r.length<2)return"";n=r.toUpperCase().indexOf("END;");let i=r.slice(0,n).split("\n");return i=a.filter(i,t=>t.trim().toUpperCase().startsWith("TREE")),To(i[0])}var Co=Object.freeze({__proto__:null,parseAnnotations:zo,loadAnnotations:So,default:Eo});function $o(t){var e={};if(1==t.nodeType){if(t.attributes.length>0){e["@attributes"]={};for(var n=0;n<t.attributes.length;n++){var r=t.attributes.item(n);e["@attributes"][r.nodeName]=r.nodeValue}}}else 3==t.nodeType&&(e=t.nodeValue);if(t.hasChildNodes()&&1===t.childNodes.length&&3===t.childNodes[0].nodeType)e=t.childNodes[0].nodeValue;else if(t.hasChildNodes())for(var i=0;i<t.childNodes.length;i++){var a=t.childNodes.item(i),o=a.nodeName;if(void 0===e[o])e[o]=$o(a);else{if(void 0===e[o].push){var s=e[o];e[o]=[],e[o].push(s)}e[o].push($o(a))}}return e}var Do=function(t,e){var n;return(n=(t=$o(t)).phyloxml.phylogeny.clade).name="root",function t(e,n){e.clade&&(e.clade.forEach(t),e.children=e.clade,delete e.clade),e.annotation=1,e.attribute="0.01",e.branch_length&&(e.attribute=e.branch_length),e.taxonomy&&(e.name=e.taxonomy.scientific_name),e.annotation=""}(n),{json:n,error:null}};var Lo={nexml:function(t,e){var r;return n.parseString(t,function(t,e){r=e["nex:nexml"].trees[0].tree.map(function(t){var e=t.node.map(t=>t.$),n=e.reduce(function(t,e){return e.edges=[],e.name=e.id,t[e.id]=e,t},{}),r=e.filter(t=>t.root),i=r>0?r[0].id:e[0].id;return n[i].name="root",t.edge.map(t=>t.$).forEach(function(t){n[t.source].edges.push(t)}),function t(e,r){if(e.edges){var i=a.pluck(e.edges,"target");e.children=a.values(a.pick(n,i)),e.children.forEach(function(t,n){t.attribute=e.edges[n].length||""}),e.children.forEach(t),e.annotation=""}}(n[i]),n[i]})}),r},phyloxml:Do,nexus:Eo,nwk:To,nhx:To,beast:function(t,e){e.left_delimiter="[",e.right_delimiter="]";const n=To(t,e);return function t(e){if(e.annotation){e.beast={};const t=e.annotation.split(/=|,|{|}/).filter(t=>t);for(var n=0;n<t.length;n+=2){let r=t[n].replace(/&|%/g,"");/[a-df-zA-DF-Z]+/.test(t[n+2])?e.beast[r]=+t[n+1]:(e.beast[r]=[+t[n+1],+t[n+2]],n++)}}e.annotation=void 0,e.children&&e.children.forEach(t)}(n.json),n}};function Uo(t,e,n){let r,i,a,o=[t],s=[];for(;t=o.pop();)if((!n||!n(t))&&(s.push(t),r=t.children,r))for(i=0,a=r.length;i<a;++i)o.push(r[i]);for(;t=s.pop();)e(t);return t}function Po(t,e,n){let r,i,a=[t];for(;t=a.pop();)if((!n||!n(t))&&(e(t),r=t.children,r))for(i=r.length-1;i>=0;--i)a.push(r[i]);return t}function Ho(t,e,n){let r,i,a,o,s=[t];do{for(r=s.reverse(),s=[];t=r.pop();)if((!n||!n(t))&&(e(t),i=t.children,i))for(a=0,o=i.length;a<o;++a)s.push(i[a])}while(s.length);return t}function Oo(t){return Uo(t,function(t){t.children&&(t.children[0].data.multiway_parent=t,t.children[1].data.multiway_parent=t.parent)}),o.map(t.descendants(),t=>{let e=t.data.multiway_parent,n="unknown";return e&&(n=e.data.name),{source:t.data.multiway_parent,target:t,name:n}})}function jo(t,e){let n=t.data;if("attribute"in n&&n.attribute&&n.attribute.length){e>0&&(n.attribute=String(e));let t=parseFloat(n.attribute);if(!isNaN(t))return Math.max(0,t)}if("root"==n.name)return 0;console.warn("Undefined branch length at "+n.name+"!")}var Fo=Object.freeze({__proto__:null,reroot:function(t,e){if(!(t instanceof Rr))throw new Error("node needs to be an instance of a d3.hierarchy node!");let n=this.nodes.copy();if(e=void 0!==e?e:.5,t.parent){var r=Rr({name:"new_root"});r.children=[t.copy()],r.data.__mapped_bl=void 0,n.each(t=>{t.data.__mapped_bl=this.branch_length_accessor(t)}),this.setBranchLength(t=>t.data.__mapped_bl);let o=t,s=t.parent,l=a.noop(),u=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl*e;var i;if(l=s.data.__mapped_bl,s.data.__mapped_bl=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl-u,t.data.__mapped_bl=u,s.parent){for(r.children.push(s);s.parent;){i=s.children.indexOf(o),s.parent.parent?s.children.splice(i,1,s.parent):s.children.splice(i,1);let t=s.parent.data.__mapped_bl;void 0!==t&&(s.parent.data.__mapped_bl=l,l=t),o=s,s=s.parent}i=s.children.indexOf(o),s.children.splice(i,1)}else i=s.children.indexOf(o),s.children.splice(i,1),l=s.data.__mapped_bl,o=r;if(1==s.children.length)l&&(s.children[0].data.__mapped_bl+=l),o.children=o.children.concat(s.children);else{let e=new Rr({name:"__reroot_top_clade",__mapped_bl:l});a.extendOwn(r.children[0],t),e.data.__mapped_bl=l,e.children=s.children.map(function(t){return t.parent=e,t}),e.parent=o,o.children.push(e)}}if(this.update(r),this.traverse_and_compute(t=>{a.each(t.children,e=>{e.parent=t})},"pre-order"),!a.isUndefined(this.display)){let t=this.display.options;It(this.display.container).select("svg").remove();let e=this.display.selection_attribute_name;delete this.display;let n=this.render(t);n.selectionLabel(e),n.update(),It(n.container).node().appendChild(n.show()),It(this.display.container).dispatch("reroot")}return this},rootpath:function(t,e){if(t=t||"attribute",e=e||"y_scaled","parent"in this){let n=parseFloat(this[t]);this[e]=this.parent[e]+(isNaN(n)?.1:n)}else this[e]=0;return this[e]},pathToRoot:function(t){let e=[];for(;t;)e.push(t),t=t.parent;return e}});function Yo(t){return t.y}function Ro(t){return t.x}function Io(t,e,n){return{x:n+t*Math.sin(e),y:n+t*Math.cos(e)}}function qo(t,e,n,r,i,a){t.radius=e*(t.radius+n),t.angle=2*Math.PI*t.x*i[0]/a[0];let o=Io(t.radius,t.angle,r);return t.x=o.x,t.y=o.y,t}function Bo(t,e){var n=Io(e[0].radius,e[0].angle,t),r=Io(e[0].radius,e[1].angle,t);return"M "+Yo(n)+","+Ro(n)+" A "+e[0].radius+","+e[0].radius+" 0,0, "+(e[1].angle>e[0].angle?1:0)+" "+Yo(r)+","+Ro(r)+" L "+Yo(e[1])+","+Ro(e[1])}function Vo(t,e,n){var r=Io(t.target.radius+(t.source.radius-t.target.radius)*e,t.target.angle,n);return{x:Yo(r),y:Ro(r)}}var Xo=ao().x(function(t){return Yo(t)}).y(function(t){return Ro(t)}).curve(function(t){return new uo(t,0)});function Wo(t,e){return{x:Yo(t.target)+(Yo(t.source)-Yo(t.target))*e,y:Ro(t.target)}}function Zo(t){return t.tag||!1}function Go(t,e){return t[e]||!1}const Ko={"tree-container":"phylotree-container","tree-scale-bar":"tree-scale-bar",node:"node","internal-node":"internal-node","tagged-node":"node-tagged","selected-node":"node-selected","collapsed-node":"node-collapsed","root-node":"root-node",branch:"branch","selected-branch":"branch-selected","tagged-branch":"branch-tagged","tree-selection-brush":"tree-selection-brush","branch-tracer":"branch-tracer",clade:"clade",node_text:"phylotree-node-text"};function Qo(t={}){Object.keys(t).forEach(e=>{Ko[e]=t[e]})}function Jo(t){return arguments.length?(Jo="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):Jo}var ts={all:t=>!0,none:t=>!1,"all-leaf-nodes":t=>Mo(t.target),"all-internal-nodes":t=>!Mo(t.target)};var es=Object.freeze({__proto__:null,css_classes:Ko,initializeCssClasses:Qo,internalNames:function(t){return arguments.length?(this.options["internal-names"]=t,this):this.options["internal-names"]},radial:function(t){return arguments.length?(this.options["is-radial"]=t,this):this.options["is-radial"]},alignTips:function(t){return arguments.length?(this.options["align-tips"]=t,this):this.options["align-tips"]},nodeBubbleSize:function(t){return this.options["draw-size-bubbles"]&&this.options["bubble-styler"]?this.options["bubble-styler"](t):this.options["draw-size-bubbles"]?this.relative_nodeSpan(t)*this.scales[0]*.25:0},shiftTip:function(t){return this.options["is-radial"]?[("end"==t.text_align?-1:1)*(this.radius_pad_for_bubbles-t.radius),0]:(this.options["right-to-left"],[this.right_most_leaf-t.screen_x,0])},layoutHandler:function(t){return arguments.length?(this.layout_listener_handler=t,this):this.layout_listener_handler},selectionLabel:function(t){return arguments.length?(this.selection_attribute_name=t,this.syncEdgeLabels(),this):this.selection_attribute_name},get nodeSpan(){return Jo},predefined_selecters:ts,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function ns(t){return!(t.hidden||t.notshown)}function rs(t){return t.notshown}function is(t){return t.hasHiddenNodes||!1}function as(t){return t.collapsed||!1}function os(t){return[t.node,t["internal-node"],t["collapsed-node"],t["tagged-node"],t["root-node"]].reduce(function(t,e,n,r){return t+"g."+e+(n<r.length-1?",":"")},"")}function ss(t){return Mo(t=t.data)?t.name||"":this.showInternalName(t)?t.name:""}var ls=Object.freeze({__proto__:null,shiftTip:function(t){return this.radial()?[("end"==t.text_align?-1:1)*(this.radius_pad_for_bubbles-t.radius),0]:(this.options["right-to-left"],[this.right_most_leaf-t.screen_x,0])},drawNode:function(t,e,n){t=It(t);var r=Mo(e);r&&(t=t.attr("data-node-name",e.data.name));var i=t.selectAll("text").data([e]),a=t.selectAll("line");if(r||this.showInternalName(e)&&!as(e))if(i=i.enter().append("text").classed(this.css_classes.node_text,!0).merge(i).on("click",t=>{this.handle_node_click(e,t)}).attr("dy",t=>.33*this.shown_font_size).text(t=>this.options["show-labels"]?this._nodeLabel(t):"").style("font-size",t=>this.ensure_size_is_in_px(this.shown_font_size)),i=this.radial()?i.attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)+this.d3PhylotreeSvgTranslate(this.alignTips()?this.shiftTip(t):null)).attr("text-anchor",t=>t.text_align):i.attr("text-anchor","start").attr("transform",t=>"right-to-left"==this.options.layout?this.d3PhylotreeSvgTranslate([-20,0]):this.d3PhylotreeSvgTranslate(this.alignTips()?this.shiftTip(t):null)),this.alignTips()?(a=a.data([e]),n?a=a.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(a).attr("x1",t=>("end"==t.text_align?-1:1)*this.nodeBubbleSize(e)).attr("x2",0).attr("y1",0).attr("y2",0).attr("x2",t=>"right-to-left"==this.options.layout?t.screen_x:this.shiftTip(t)[0]).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)).attr("x2",t=>"right-to-left"==this.options.layout?t.screen_x:this.shiftTip(t)[0]).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)):(a=a.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(a).attr("x1",t=>("end"==t.text_align?-1:1)*this.nodeBubbleSize(e)).attr("y2",0).attr("y1",0).attr("x2",t=>this.shiftTip(t)[0])).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle))):a.remove(),this.options["draw-size-bubbles"]){var o=this.nodeBubbleSize(e);t.selectAll("circle").data([o]).enter().append("circle").attr("r",function(t){return t}),this.shown_font_size>=5&&(i=i.attr("dx",t=>("end"==t.text_align?-1:1)*((this.alignTips()?0:o)+.33*this.shown_font_size)))}else this.shown_font_size>=5&&(i=i.attr("dx",t=>("end"==t.text_align?-1:1)*this.shown_font_size*.33));if(!r){let n=t.selectAll("circle").data([e]).enter().append("circle"),r=this.node_circle_size()(e);r>0?n.merge(n).attr("r",t=>Math.min(.75*this.shown_font_size,r)).on("click",t=>{this.handle_node_click(e,t)}):n.remove()}return this.node_styler&&this.node_styler(t,e),e},updateHasHiddenNodes:function(){let t=this.phylotree.nodes.descendants();for(let e=t.length-1;e>=0;e-=1)Mo(t[e])?t[e].hasHiddenNodes=t[e].notshown:t[e].hasHiddenNodes=t[e].children.reduce(function(t,e){return e.notshown||t},!1);return this},showInternalName:function(t){const e=this.internalNames();return!!e&&("function"==typeof e?e(t):e)},nodeSpan:function(t){return arguments.length?(this.nodeSpan="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):this.nodeSpan},reclassNode:function(t){let e=Ko[Mo(t)?"node":"internal-node"];return Zo(t)&&(e+=" "+Ko["tagged-node"]),Go(t,this.selection_attribute_name)&&(e+=" "+Ko["selected-node"]),t.parent||(e+=" "+Ko["root-node"]),(as(t)||is(t))&&(e+=" "+Ko["collapsed-node"]),e},nodeVisible:ns,nodeNotshown:rs,hasHiddenNodes:is,isNodeCollapsed:as,nodeCssSelectors:os,internalLabel:function(t,e){this.phylotree.clearInternalNodes(e);for(var n=this.phylotree.nodes.descendants().length-1;n>=0;n--){var r=this.phylotree.nodes.descendants()[n];Mo(r)||Go(r,this.selection_attribute_name)||(r[this.selection_attribute_name]=t(r.children))}this.modifySelection((t,e)=>(Mo(t.target),t.target[this.selection_attribute_name]))},defNodeLabel:ss,nodeLabel:function(t){return arguments.length?(this._nodeLabel=t||ss,this.update(),this):this._nodeLabel}});function us(t){return[t.clade].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var cs=Object.freeze({__proto__:null,cladeCssSelectors:us,updateCollapsedClades:function(t){let e=this.svg.selectAll("."+this.css_classes["tree-container"]);var n=0;let r=e.selectAll(us(this.css_classes)).data(this.phylotree.nodes.descendants().filter(as),function(t){return t.id||(t.id=++n)}),i=function(){},o=a.noop();this.radial()?(i=ao().curve(lo).y(function(t){return t[0]}).x(function(t){return t[1]}),o=function(t,e,n,r,i){return e?[n.screen_y+(t[0]-r)/50,n.screen_x+(t[1]-i)/50]:[n.screen_y,n.screen_x]}):(i=ao().y(function(t){return t[0]}).x(function(t){return t[1]}).curve(lo),o=function(t,e,n,r,i){return e?[n.screen_y+(t[0]-r)/50,n.screen_x+(t[1]-i)/50]:[n.screen_y,n.screen_x]}),r.exit().each(function(t){t.collapsed_clade=null}).remove(),t?r.enter().insert("path",":first-child").attr("class",this.css_classes.clade).merge(r).attr("d",function(t){if(t.collapsed_clade)return t.collapsed_clade;let e=t.collapsed[0][0],n=t.collapsed[0][1];return i(t.collapsed.map(function(r,i){return o(r,i,t,e,n)}))}).attr("d",function(t){return t.collapsed_clade=i(t.collapsed)}):r.enter().insert("path",":first-child").attr("class",this.css_classes.clade).merge(r).attr("d",function(t){return t.collapsed_clade?t.collapsed_clade:t.collapsed_clade=i(t.collapsed)})}});function hs(t){return!(t.target.hidden||t.target.notshown)}function fs(t){return[t.branch,t["selected-branch"],t["tagged-branch"]].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var ds=Object.freeze({__proto__:null,drawEdge:function(t,e,n){t=(t=It(t)).attr("class",t=>this.reclassEdge(t)).on("click",t=>{this.modifySelection([e.target],this.selection_attribute_name),this.update()});let r=this.draw_branch([e.source,e.target]);n?(t.datum().existing_path&&(t=t.attr("d",function(t){return t.existing_path})),t=t.attr("d",r)):t=t.attr("d",r),e.existing_path=r;var i=this.phylotree.branch_length_accessor(e.target);if(void 0!==i){var a=t.selectAll("title");a.empty()&&(a=t.append("title")),a.text("Length = "+i)}else t.selectAll("title").remove();return this.edge_styler&&this.edge_styler(t,e,n),this.phylotree},reclassEdge:function(t){let e=Ko.branch;return Zo(t)&&(e+=" "+Ko["tagged-branch"]),Go(t,this.selection_attribute_name)&&(e+=" "+Ko["selected-branch"]),e},initializeEdgeLabels:function(){this.links.forEach(t=>{t.target.data.annotation&&(t.target[t.target.data.annotation]=t.target.data.annotation)})},syncEdgeLabels:function(){if(this.links.forEach(t=>{t[this.selection_attribute_name]=t.target[this.selection_attribute_name]||!1,t.tag=t.target.tag||!1}),this.countHandler()){let t={};t[this.selection_attribute_name]=this.links.reduce((t,e)=>t+(e[this.selection_attribute_name]?1:0),0),t.tagged=this.links.reduce(function(t,e){return t+(Zo(e)?1:0)},0),this.countUpdate(this,t,this.countHandler())}},edgeVisible:hs,edgeCssSelectors:fs,placeAlongAnEdge:function(t,e){return this.edge_placer(t,e)}});let ps="phylotree.event";function _s(t){var e=new CustomEvent(ps,{detail:["refresh",t]});document.dispatchEvent(e)}function gs(t,e){var n=new CustomEvent(ps,{detail:["countUpdate",e,t.countHandler()]});document.dispatchEvent(n)}function ms(t){switch(t.detail[0]){case"refresh":t.detail[1].refresh();break;case"countUpdate":case"layout":t.detail[2](t.detail[1])}return!0}function vs(){document.addEventListener(ps,ms,!1)}var ys=Object.freeze({__proto__:null,toggleCollapse:function(t){if(t.collapsed){t.collapsed=!1;let e=function(t){Mo(t)||t.collapsed||t.children.forEach(e),t.hidden=!1};e(t)}else t.collapsed=!0;return this.placenodes(),this},resizeSvg:function(t,e,n){let r=this.size;if(this.radial()){let t=this.pad_width(),n="fit-to-size"!=this.options["top-bottom-spacing"]?this.pad_height():0;r=[r[1]+2*t,r[0]+2*t+n],e&&e.selectAll("."+Ko["tree-container"]).attr("transform","translate ("+t+","+(t+n)+")")}else r=[r[0]+("fit-to-size"!=this.options["top-bottom-spacing"]?this.pad_height():0),r[1]+("fit-to-size"!=this.options["left-right-spacing"]?this.pad_width():0)];return e&&(n&&(e=e.transition(100)),e.attr("height",r[0]).attr("width",r[1])),this.size=r,r},rescale:function(t,e){(e=e||"y_scaled")in this&&(this[e]*=t)},triggerRefresh:_s,countUpdate:gs,d3PhylotreeTriggerLayout:function(t){var e=new CustomEvent(ps,{detail:["layout",t,t.layoutHandler()]});document.dispatchEvent(e)},d3PhylotreeEventListener:ms,d3PhylotreeAddEventListener:vs,d3PhylotreeSvgTranslate:function(t){return!t||null===t[0]&&null===t[1]?"":"translate ("+(null!==t[0]?t[0]:0)+","+(null!==t[1]?t[1]:0)+") "},d3PhylotreeSvgRotate:function(t){return null!==t?"rotate ("+t+") ":""}});let bs="d3_layout_phylotree_context_menu";function ws(t,e,n){let r=[];return function i(a){Mo(a)?e&&a!=t&&r.push(a):(n&&a!=t&&r.push(a),a.children.forEach(i))}(t),r}var xs=Object.freeze({__proto__:null,nodeDropdownMenu:function(t,e,n,r,i){let o=It(e).select("#"+bs);if(o.empty()&&(o=It(e).append("div").attr("id",bs).attr("class","dropdown-menu").attr("role","menu")),o.selectAll("a").remove(),o.selectAll("h6").remove(),o.selectAll("div").remove(),t){if(!a.some([Boolean(t.menu_items),r.hide,r.selectable,r.collapsible])||!r["show-menu"])return;Mo(t)||(r.collapsible&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(as(t)?"Expand Subtree":"Collapse Subtree").on("click",e=>{o.style("display","none"),this.toggleCollapse(t).update()}),r.selectable&&(o.append("div").attr("class","dropdown-divider"),o.append("h6").attr("class","dropdown-header").text("Toggle selection"))),r.selectable&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All descendant branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0))}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All terminal branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!1))}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All internal branches").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!1,!0))}))),t.parent&&(r.selectable&&(o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Incident branch").on("click",function(e){o.style("display","none"),n.modifySelection([t])}),o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Path to root").on("click",e=>{o.style("display","none"),this.modifySelection(this.phylotree.pathToRoot(t))}),(r.reroot||r.hide)&&o.append("div").attr("class","dropdown-divider")),r.reroot&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Reroot on this node").on("click",e=>{o.style("display","none"),this.phylotree.reroot(t),this.update()}),r.hide&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Hide this "+(Mo(t)?"node":"subtree")).on("click",e=>{o.style("display","none"),this.modifySelection([t],"notshown",!0,!0).updateHasHiddenNodes().update()})),is(t)&&o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Show all descendant nodes").on("click",function(e){o.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0),"notshown",!0,!0,"false").updateHasHiddenNodes().update()});var s=[];if("menu_items"in t&&"object"==typeof t.menu_items&&t.menu_items.forEach(function(e){3==e.length&&(e[2]&&!e[2](t)||s.push([e[0],e[1]]))}),s.length){const e=[r.hide,r.selectable,r.collapsible];a.some(e)&&o.append("div").attr("class","dropdown-divider"),s.forEach(function(e){o.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(e[0](t)).on("click",a.partial(e[1],t))})}let l=document.querySelector(e).getBoundingClientRect();o.style("position","absolute").style("left",i.clientX-l.x+12+"px").style("top",i.clientY-l.y+"px").style("display","block")}else o.style("display","none")},addCustomMenu:function(t,e,n,r){"menu_items"in t||(t.menu_items=[]),t.menu_items.some(function(t){return t[0]==e&&t[1]==n&&t[2]==r})||t.menu_items.push([e,n,r])},modifySelection:function(t,e,n,r,i){if(e=e||this.selection_attribute_name,i=i||"toggle",this.options["restricted-selectable"].length){if(!a.contains(a.keys(ts),t))return;t=ts[t]}if(!this.options["restricted-selectable"]&&!this.options.selectable||this.options["binary-selectable"])this.options["binary-selectable"]&&("function"==typeof t?this.links.forEach(function(n){var r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,s=!0,n.target[e]=r),this.options["attribute-list"].forEach(function(t){t!=e&&!0===n[e]&&(n[t]=!1,n.target[t]=!1)})}):(t.forEach(function(t){var n;n=!t[e],t[e]!=n&&(t[e]=n,s=!0)}),this.links.forEach(function(t){t[e]=t.target[e],this.options["attribute-list"].forEach(function(n){n!=e&&!0!==t[e]&&(t[n]=!1,t.target[n]=!1)})})),s&&(r||_s(this),this.countHandler()&&((o={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),this.countUpdate(this,o,this.countHandler())),n&&this.placenodes()));else{var o,s=!1;"function"==typeof t?this.links.forEach(function(n){let r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,s=!0,n.target[e]=r)}):(t.forEach(function(t){var n;switch(i){case"true":n=!0;break;case"false":n=!1;break;default:n=!t[e]}t[e]!=n&&(t[e]=n,s=!0)}),this.links.forEach(function(t){t[e]=t.target[e]})),s&&(r||_s(this),this.countHandler&&((o={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),gs(this,o,this.countHandler)),n&&this.placenodes())}return this._selectionCallback&&"tag"!=e&&this._selectionCallback(this.getSelection()),this.refresh(),this.update(),this},getSelection:function(){return ws(this.phylotree.getRootNode(),!0,!0).filter(t=>t[this.selection_attribute_name])},selectAllDescendants:ws,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function Ms(t){return function(){return t}}class ks{constructor(t,e={}){Qo(e["css-classes"]),this.css_classes=Ko,this.phylotree=t,this.container=e.container,this.separation=function(t,e){return 0},this._nodeLabel=this.defNodeLabel,this.svg=null,this._selectionCallback=null,this.scales=[1,1],this.size=[1,1],this.fixed_width=[14,30],this.scale_bar_font_size=12,this.draw_branch=Xo,this.draw_scale_bar=null,this.edge_placer=Wo,this.count_listener_handler=function(){},this.layout_listener_handler=function(){},this.node_styler=void 0,this.edge_styler=void 0,this.selection_attribute_name="selected",this.right_most_leaf=0,this.label_width=0,this.radial_center=0,this.radius=1,this.radius_pad_for_bubbles=0,this.rescale_nodeSpan=1,this.relative_nodeSpan=function(t){return this.nodeSpan(t)/this.rescale_nodeSpan};let n={layout:"left-to-right",logger:console,branches:"step",scaling:!0,bootstrap:!1,"color-fill":!0,"font-size":14,"internal-names":!1,selectable:!0,"restricted-selectable":!1,collapsible:!0,"left-right-spacing":"fixed-step","top-bottom-spacing":"fixed-step","left-offset":0,"show-scale":"top","draw-size-bubbles":!1,"bubble-styler":this.radius_pad_for_bubbles,"binary-selectable":!1,"is-radial":!1,"attribute-list":[],"max-radius":768,"annular-limit":.38196601125010515,compression:.2,"align-tips":!1,"maximum-per-node-spacing":100,"minimum-per-node-spacing":2,"maximum-per-level-spacing":100,"minimum-per-level-spacing":10,node_circle_size:Ms(3),transitions:null,brush:!0,reroot:!0,hide:!0,"label-nodes-with-name":!1,zoom:!1,"show-menu":!0,"show-labels":!0,"node-styler":null,"edge-styler":null,"node-span":null};this.ensure_size_is_in_px=function(t){return"number"==typeof t?t+"px":t},this.options=a.defaults(e,n),this.font_size=this.options["font-size"],this.offsets=[0,this.font_size/2],this.shown_font_size=this.font_size,this.width=this.options.width||800,this.height=this.options.height||600,this.node_styler=this.options["node-styler"],this.edge_styler=this.options["edge-styler"],this.nodeSpan=this.options["node-span"],this.nodeSpan||(this.nodeSpan=function(t){return 1}),this.rescale_nodeSpan=this.phylotree.nodes.children.map(t=>{if(Mo(t)||this.showInternalName(t))return this.nodeSpan(t)}).reduce(function(t,e){return Math.min(e,t||1e200)},null)||1,this.initialize_svg(this.container),this.links=this.phylotree.nodes.links(),this.initializeEdgeLabels(),this.update(),vs()}pad_height(){return this.draw_scale_bar?this.scale_bar_font_size+25:0}pad_width(){this.label_width=this._label_width(this.shown_font_size);const t=this.options["show-labels"]?this.label_width:0;return this.offsets[1]+this.options["left-offset"]+t}collapse_node(t){as(t)||(t.collapsed=!0)}set_size(t){if(!arguments.length)return this.size;let e=t;return"fixed-step"!=this.options["top-bottom-spacing"]&&(this.size[0]=e[0]),"fixed-step"!=this.options["left-right-spacing"]&&(this.size[1]=e[1]),this}initialize_svg(t){var e;return this.svg!==t&&(It(t).select("svg").remove(),this.svg=(e="svg",It(P(e).call(document.documentElement))).attr("width",this.width).attr("height",this.height),this.set_size([this.height,this.width]),"phylotree-container"==this.css_classes["tree-container"]&&(this.svg.selectAll("*").remove(),this.svg.append("defs")),It(this.container).on("click",t=>{this.handle_node_click(null)},!0)),this}update_layout(t,e){e&&(this.nodes=Rr(t),this.nodes.each(function(t){t.id=null})),this.update(),this.syncEdgeLabels()}update(t){var e=this;this.placenodes(),t=this.transitions(t);let n=0,r=this.svg.selectAll("."+Ko["tree-container"]).data([0]);if(r=r.enter().append("g").attr("class",Ko["tree-container"]).merge(r).attr("transform",t=>this.d3PhylotreeSvgTranslate([this.offsets[1]+this.options["left-offset"],this.pad_height()])),this.draw_scale_bar){let t=this.svg.selectAll("."+Ko["tree-scale-bar"]).data([0]);t.enter().append("g").attr("class",Ko["tree-scale-bar"]).style("font-size",this.ensure_size_is_in_px(this.scale_bar_font_size)).merge(t).attr("transform",t=>this.d3PhylotreeSvgTranslate([this.offsets[1]+this.options["left-offset"],this.pad_height()-10])).call(this.draw_scale_bar),t.selectAll("text").style("text-anchor","end")}else this.svg.selectAll("."+Ko["tree-scale-bar"]).remove();r=this.svg.selectAll("."+Ko["tree-container"]).data([0]),this.updateCollapsedClades(t);let i=r.selectAll(fs(Ko)).data(this.links.filter(hs),t=>t.target.id||(t.target.id=++n));i.exit().remove(),i=i.enter().insert("path",":first-child").merge(i).each(function(n){e.drawEdge(this,n,t)});let o=r.selectAll(os(Ko)).data(this.phylotree.nodes.descendants().filter(ns),t=>t.id||(t.id=++n));if(o.exit().remove(),o=o.enter().append("g").attr("class",this.reclassNode).merge(o).attr("transform",t=>{const e="right-to-left"==this.options.layout&&Mo(t);return t.screen_x=Yo(t),t.screen_y=Ro(t),this.d3PhylotreeSvgTranslate([e?0:t.screen_x,t.screen_y])}).each(function(n){e.drawNode(this,n,t)}).attr("transform",t=>{if(!a.isUndefined(t.screen_x)&&!a.isUndefined(t.screen_y))return"translate("+t.screen_x+","+t.screen_y+")"}),this.options["label-nodes-with-name"]&&(o=o.attr("id",t=>"node-"+t.name)),this.resizeSvg(this.phylotree,this.svg,t),this.options.brush){var s=r.selectAll("."+Ko["tree-selection-brush"]).data([0]).enter().insert("g",":first-child").attr("class",Ko["tree-selection-brush"]),l=yr().on("brush",(t,e)=>{var n=t.selection,r=this.links.filter(hs).filter((t,e)=>t.source.screen_x>=n[0][0]&&t.source.screen_x<=n[1][0]&&t.source.screen_y>=n[0][1]&&t.source.screen_y<=n[1][1]&&t.target.screen_x>=n[0][0]&&t.target.screen_x<=n[1][0]&&t.target.screen_y>=n[0][1]&&t.target.screen_y<=n[1][1]).map(t=>t.target);this.modifySelection(this.phylotree.links.map(t=>t.target),"tag",!1,r.length>0,"false"),this.modifySelection(r,"tag",!1,!1,"true")}).on("end",()=>{});s.call(l)}if(this.syncEdgeLabels(),this.options.zoom){let t=function(){var t,e,n,r=mo,i=vo,a=xo,o=bo,s=wo,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,h=Je,f=A("start","zoom","end"),d=0,p=10;function _(t){t.property("__zoom",yo).on("wheel.zoom",x,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",k).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(t,e){return(e=Math.max(l[0],Math.min(l[1],e)))===t.k?t:new fo(e,t.x,t.y)}function m(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new fo(t.k,r,i)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function y(t,e,n,r){t.on("start.zoom",function(){b(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,a=arguments,o=b(t,a).event(r),s=i.apply(t,a),l=null==n?v(s):"function"==typeof n?n.apply(t,a):n,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),c=t.__zoom,f="function"==typeof e?e.apply(t,a):e,d=h(c.invert(l).concat(u/c.k),f.invert(l).concat(u/f.k));return function(t){if(1===t)t=f;else{var e=d(t),n=u/e[2];t=new fo(n,l[0]-e[0]*n,l[1]-e[1]*n)}o.zoom(null,t)}})}function b(t,e,n){return!n&&t.__zooming||new w(t,e)}function w(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function x(t,...e){if(r.apply(this,arguments)){var n=b(this,e).event(t),i=this.__zoom,s=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,o.apply(this,arguments)))),c=qt(t);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=i.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[c,i.invert(c)],Mn(this),n.start()}go(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",a(m(g(i,s),n.mouse[0],n.mouse[1]),n.extent,u))}}function M(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,o=b(this,e,!0).event(t),s=It(t.view).on("mousemove.zoom",function(t){if(go(t),!o.moved){var e=t.clientX-c,n=t.clientY-h;o.moved=e*e+n*n>d}o.event(t).zoom("mouse",a(m(o.that.__zoom,o.mouse[0]=qt(t,i),o.mouse[1]),o.extent,u))},!0).on("mouseup.zoom",function(t){s.on("mousemove.zoom mouseup.zoom",null),Wt(t.view,o.moved),go(t),o.event(t).end()},!0),l=qt(t,i),c=t.clientX,h=t.clientY;Xt(t.view),_o(t),o.mouse=[l,this.__zoom.invert(l)],Mn(this),o.start()}}function k(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,o=qt(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(o),l=n.k*(t.shiftKey?.5:2),h=a(m(g(n,l),o,s),i.apply(this,e),u);go(t),c>0?It(this).transition().duration(c).call(y,h,o,t):It(this).call(_.transform,h,o,t)}}function N(n,...i){if(r.apply(this,arguments)){var a,o,s,l,u=n.touches,c=u.length,h=b(this,i,n.changedTouches.length===c).event(n);for(_o(n),o=0;o<c;++o)l=[l=qt(s=u[o],this),this.__zoom.invert(l),s.identifier],h.touch0?h.touch1||h.touch0[2]===l[2]||(h.touch1=l,h.taps=0):(h.touch0=l,a=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),a&&(h.taps<2&&(e=l[0],t=setTimeout(function(){t=null},500)),Mn(this),h.start())}}function T(t,...e){if(this.__zooming){var n,r,i,o,s=b(this,e).event(t),l=t.changedTouches,c=l.length;for(go(t),n=0;n<c;++n)i=qt(r=l[n],this),s.touch0&&s.touch0[2]===r.identifier?s.touch0[0]=i:s.touch1&&s.touch1[2]===r.identifier&&(s.touch1[0]=i);if(r=s.that.__zoom,s.touch1){var h=s.touch0[0],f=s.touch0[1],d=s.touch1[0],p=s.touch1[1],_=(_=d[0]-h[0])*_+(_=d[1]-h[1])*_,v=(v=p[0]-f[0])*v+(v=p[1]-f[1])*v;r=g(r,Math.sqrt(_/v)),i=[(h[0]+d[0])/2,(h[1]+d[1])/2],o=[(f[0]+p[0])/2,(f[1]+p[1])/2]}else{if(!s.touch0)return;i=s.touch0[0],o=s.touch0[1]}s.zoom("touch",a(m(r,i,o),s.extent,u))}}function z(t,...r){if(this.__zooming){var i,a,o=b(this,r).event(t),s=t.changedTouches,l=s.length;for(_o(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<l;++i)a=s[i],o.touch0&&o.touch0[2]===a.identifier?delete o.touch0:o.touch1&&o.touch1[2]===a.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(a=qt(a,this),Math.hypot(e[0]-a[0],e[1]-a[1])<p)){var u=It(this).on("dblclick.zoom");u&&u.apply(this,arguments)}}}return _.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",yo),t!==i?y(t,e,n,r):i.interrupt().each(function(){b(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},_.scaleBy=function(t,e,n,r){_.scaleTo(t,function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)},n,r)},_.scaleTo=function(t,e,n,r){_.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,o=null==n?v(t):"function"==typeof n?n.apply(this,arguments):n,s=r.invert(o),l="function"==typeof e?e.apply(this,arguments):e;return a(m(g(r,l),o,s),t,u)},n,r)},_.translateBy=function(t,e,n,r){_.transform(t,function(){return a(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),u)},null,r)},_.translateTo=function(t,e,n,r,o){_.transform(t,function(){var t=i.apply(this,arguments),o=this.__zoom,s=null==r?v(t):"function"==typeof r?r.apply(this,arguments):r;return a(po.translate(s[0],s[1]).scale(o.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,u)},r,o)},w.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1===++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0===--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=It(this.that).datum();f.call(t,this.that,new ho(t,{sourceEvent:this.sourceEvent,target:_,type:t,transform:this.that.__zoom,dispatch:f}),e)}},_.wheelDelta=function(t){return arguments.length?(o="function"==typeof t?t:co(+t),_):o},_.filter=function(t){return arguments.length?(r="function"==typeof t?t:co(!!t),_):r},_.touchable=function(t){return arguments.length?(s="function"==typeof t?t:co(!!t),_):s},_.extent=function(t){return arguments.length?(i="function"==typeof t?t:co([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),_):i},_.scaleExtent=function(t){return arguments.length?(l[0]=+t[0],l[1]=+t[1],_):[l[0],l[1]]},_.translateExtent=function(t){return arguments.length?(u[0][0]=+t[0][0],u[1][0]=+t[1][0],u[0][1]=+t[0][1],u[1][1]=+t[1][1],_):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},_.constrain=function(t){return arguments.length?(a=t,_):a},_.duration=function(t){return arguments.length?(c=+t,_):c},_.interpolate=function(t){return arguments.length?(h=t,_):h},_.on=function(){var t=f.on.apply(f,arguments);return t===f?_:t},_.clickDistance=function(t){return arguments.length?(d=(t=+t)*t,_):Math.sqrt(d)},_.tapDistance=function(t){return arguments.length?(p=+t,_):p},_}().scaleExtent([.1,10]).on("zoom",t=>{It("."+Ko["tree-container"]).attr("transform",e=>t.transform),It("."+Ko["tree-scale-bar"]).attr("transform",e=>{let n=t.transform;return n.y-=10,n})});this.svg.call(t)}return this}_handle_single_node_layout(t){let e=this.nodeSpan(t)/this.rescale_nodeSpan;this.x=t.x=this.x+this.separation(this.last_node,t)+.5*(this.last_span+e),this._extents[1][1]=Math.max(this._extents[1][1],t.y),this._extents[1][0]=Math.min(this._extents[1][0],t.y-.5*e),this.is_under_collapsed_parent?this._extents[0][1]=Math.max(this._extents[0][1],this.save_x+(t.x-this.save_x)*this.options.compression+this.save_span+(.5*e+this.separation(this.last_node,t))*this.options.compression):this._extents[0][1]=Math.max(this._extents[0][1],this.x+.5*e+this.separation(this.last_node,t)),this.last_node=t,this.last_span=e}tree_layout(t){if(rs(t))return;let e=Mo(t);t.text_angle=null,t.text_align=null,t.radius=null,t.angle=null;let n=!1;if(t.parent)if(this.do_scaling){if(n)return 0;if(t.y=this.phylotree.branch_length_accessor(t),void 0===t.y)return n=!0,0;t.y+=t.parent.y}else t.y=e?this.max_depth:t.depth;else this.x=0,t.y=0,this.last_node=null,this.last_span=0,this._extents=[[0,0],[0,0]];if(e&&this._handle_single_node_layout(t),!e)if(as(t)&&!this.is_under_collapsed_parent){if(this.save_x=this.x,this.save_span=.5*this.last_span,this.is_under_collapsed_parent=!0,this.process_internal_node(t),this.is_under_collapsed_parent=!1,"number"==typeof t.x){t.x=this.save_x+(t.x-this.save_x)*this.options.compression+this.save_span,t.collapsed=[[t.x,t.y]];var r=e=>{e.hidden=!0,Mo(e)?(this.x=e.x=this.save_x+(e.x-this.save_x)*this.options.compression+this.save_span,t.collapsed.push([e.x,e.y])):e.children.map(r)};this.x=this.save_x,r(t),t.collapsed.splice(1,0,[this.save_x,t.y]),t.collapsed.push([this.x,t.y]),t.collapsed.push([t.x,t.y]),t.hidden=!1}}else this.process_internal_node(t);return t.x}process_internal_node(t){let e=0;if(this.showInternalName(t)){let e=t.children.length/2|0,n=0,r=!1;for(let i=0;i<t.children.length;i++){"number"==typeof this.tree_layout(t.children[i])&&n++,n>=e&&!r&&(this._handle_single_node_layout(t),r=!0)}0==n?(t.notshown=!0,t.x=void 0):r||this._handle_single_node_layout(t)}else t.x=t.children.map(this.tree_layout.bind(this)).reduce((t,n)=>"number"==typeof n?t+n:(e+=1,t),0),e==t.children.length?(t.notshown=!0,t.x=void 0):t.x/=t.children.length-e}do_lr(t){if(this.radial()&&t&&(this.offsets[1]=0),"fixed-step"==this.options["left-right-spacing"])this.size[1]=this.max_depth*this.fixed_width[1],this.scales[1]=(this.size[1]-this.offsets[1]-this.options["left-offset"])/this._extents[1][1],this.label_width=this._label_width(this.shown_font_size),this.radial()&&(this.label_width*=2);else{this.label_width=this._label_width(this.shown_font_size),t=!0;let e=this.size[1]-this.offsets[1]-this.options["left-offset"];.5*e<this.label_width&&(this.shown_font_size*=.5*e/this.label_width,this.label_width=.5*e),this.scales[1]=(this.size[1]-this.offsets[1]-this.options["left-offset"]-this.label_width)/this._extents[1][1]}}placenodes(){this._extents=[[0,0],[0,0]],this.x=0,this.last_span=0,this.last_node=null,this.last_span=0,this.save_x=this.x,this.save_span=.5*this.last_span,this.do_scaling=this.options.scaling;this.is_under_collapsed_parent=!1,this.max_depth=1,this.phylotree.nodes.x=this.tree_layout(this.phylotree.nodes,this.do_scaling),this.max_depth=function(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n<e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i)}return n}(this.phylotree.nodes.descendants(),t=>t.depth),this.do_scaling;let t=!1;if(this.draw_scale_bar=this.options["show-scale"]&&this.do_scaling,this.offsets[1]=Math.max(this.font_size,-this._extents[1][0]*this.fixed_width[0]),"fixed-step"==this.options["top-bottom-spacing"]?(this.size[0]=this._extents[0][1]*this.fixed_width[0],this.scales[0]=this.fixed_width[0]):(this.scales[0]=(this.size[0]-this.pad_height())/this._extents[0][1],t=!0),this.shown_font_size=Math.min(this.font_size,this.scales[0]),this.radial()){this.draw_branch=a.partial(Bo,this.radial_center),this.edge_placer=Vo;let e=null,n=null,r=null,i=0,o=this._extents[0][1]*this.scales[0],s=function(t,e,n,r,i){return i=i||0,Math.sqrt((e-t)*(e-t)+2*(t+i)*(e+i)*(1-Math.cos(n-r)))},l=0;this.phylotree.nodes.each(t=>{let e=t.x*this.scales[0];t.angle=2*Math.PI*e/o,t.text_angle=t.angle-Math.PI/2,t.text_angle=t.text_angle>0&&t.text_angle<Math.PI,t.text_align=t.text_angle?"end":"start",t.text_angle=(t.text_angle?180:0)+180*t.angle/Math.PI}),this.do_lr(t),this.phylotree.nodes.each(t=>{t.radius=t.y*this.scales[1]/this.size[1],l=Math.max(t.radius,l)});let u=0;this.phylotree.nodes.each(t=>{if(!t.children){let a=t.x*this.scales[0];if(null!==e){let o=a-n,c=s(t.radius,r,t.angle,e,u),h=c>0?o/c:10*this.options["max-radius"];if(h>this.options["max-radius"]){let n=o/this.options["max-radius"],a=t.radius+r,s=t.radius*r-(n*n-(r-t.radius)*(r-t.radius))/2/(1-Math.cos(e-t.angle)),c=Math.sqrt(a*a-4*s);u=Math.min(this.options["annular-limit"]*l,(-a+c)/2),i=this.options["max-radius"]}else i=Math.max(i,h)}e=t.angle,n=a,r=t.radius}}),this.radius=Math.min(this.options["max-radius"],Math.max(o/2/Math.PI,i)),t&&(this.radius=Math.min(this.radius,.5*(Math.min(o,this._extents[1][1]*this.scales[1])-this.label_width)-this.radius*u)),this.radial_center=this.radius_pad_for_bubbles=this.radius,this.draw_branch=a.partial(Bo,this.radial_center);let c=1;u&&(c=l/(l+u),this.radius*=c),this.phylotree.nodes.each(t=>{if(qo(t,this.radius,u,this.radial_center,this.scales,this.size),l=Math.max(l,t.radius),this.options["draw-size-bubbles"]?this.radius_pad_for_bubbles=Math.max(this.radius_pad_for_bubbles,t.radius+this.nodeBubbleSize(t)):this.radius_pad_for_bubbles=Math.max(this.radius_pad_for_bubbles,t.radius),t.collapsed){t.collapsed=t.collapsed.map(t=>{let e={};return e.x=t[0],e.y=t[1],e=qo(e,this.radius,u,this.radial_center,this.scales,this.size),[e.x,e.y]});let e=t.collapsed[1];t.collapsed=t.collapsed.filter(function(n,r){return r<3||r>t.collapsed.length-4||Math.sqrt(Math.pow(n[0]-e[0],2)+Math.pow(n[1]-e[1],2))>3&&(e=n,!0)})}}),this.size[0]=this.radial_center+this.radius/c,this.size[1]=this.radial_center+this.radius/c}else this.do_lr(),this.draw_branch=Xo,this.edge_placer=Wo,this.right_most_leaf=0,this.phylotree.nodes.each(t=>{if(t.x*=this.scales[0],t.y*=.8*this.scales[1],"right-to-left"==this.options.layout&&(t.y=this._extents[1][1]*this.scales[1]-t.y),Mo(t)&&(this.right_most_leaf=Math.max(this.right_most_leaf,t.y+this.nodeBubbleSize(t))),t.collapsed){t.collapsed.forEach(t=>{t[0]*=this.scales[0],t[1]*=.8*this.scales[1]});let e=t.collapsed[1][0];t.collapsed=t.collapsed.filter(function(n,r){return r<3||r>t.collapsed.length-4||n[0]-e>3&&(e=n[0],!0)})}});if(this.draw_scale_bar){let t,e;if(this.radial()){if(e=Math.min(this.radius/5,50),t=Math.pow(10,Math.ceil(Math.log(this._extents[1][1]*e/this.radius)/Math.log(10))),e=t*(this.radius/this._extents[1][1]),e<30){let n=Math.ceil(30/e);e*=n,t*=n}}else t=this._extents[1][1],e=this.size[1]-this.offsets[1]-this.options["left-offset"]-this.shown_font_size;let n=ii().domain([0,t]).range([0,e]),r=Pr(".2f");if(this.draw_scale_bar=function(t){return N(1,t)}().scale(n).tickFormat(function(t){return 0===t?"":r(t)}),this.radial())this.draw_scale_bar.tickValues([t]);else{let t=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},i=n.ticks();i=i.length>1?i[1]:i[0],this.draw_scale_bar.ticks(Math.min(10,t(e/(this.shown_font_size*r(i).length*2),0)))}}else this.draw_scale_bar=null;return this}spacing_x(t,e){return arguments.length?(this.fixed_width[0]!=t&&t>=this.options["minimum-per-node-spacing"]&&t<=this.options["maximum-per-node-spacing"]&&(this.fixed_width[0]=t,e||this.placenodes()),this):this.fixed_width[0]}spacing_y(t,e){return arguments.length?(this.fixed_width[1]!=t&&t>=this.options["minimum-per-level-spacing"]&&t<=this.options["maximum-per-level-spacing"]&&(this.fixed_width[1]=t,e||this.placenodes()),this):this.fixed_width[1]}_label_width(t){t=t||this.shown_font_size;let e=0;return this.phylotree.nodes.descendants().filter(ns).forEach(n=>{let r=12+this._nodeLabel(n).length*t*.8;null!==n.angle&&(r*=Math.max(Math.abs(Math.cos(n.angle)),Math.abs(Math.sin(n.angle)))),e=Math.max(r,e)}),e}font_size(t){return arguments.length?(this.font_size=void 0===t?12:t,this):this.font_size}scale_bar_font_size(t){return arguments.length?(this.scale_bar_font_size=void 0===t?12:t,this):this.scale_bar_font_size}node_circle_size(t,e){return arguments.length?(this.options.node_circle_size=Ms(void 0===t?3:t),this):this.options.node_circle_size}css(t){if(0===arguments.length)return this.css_classes;if(arguments.length>2){var e={};return e[t[0]]=t[1],this.css(e)}for(var n in Ko)n in t&&t[n]!=Ko[n]&&(Ko[n]=t[n]);return this}transitions(t){return void 0!==t?t:null!==this.options.transitions?this.options.transitions:this.phylotree.nodes.descendants().length<=300}css_classes(t,e){if(!arguments.length)return this.css_classes;let n=!1;for(var r in Ko)r in t&&t[r]!=this.css_classes[r]&&(n=!0,this.css_classes[r]=t[r]);return e&&n&&this.layout(),this}layout(t){return this.svg?(this.svg.selectAll("."+this.css_classes["tree-container"]+",."+this.css_classes["tree-scale-bar"]+",."+this.css_classes["tree-selection-brush"]),this.d3PhylotreeTriggerLayout(this),this.update()):(this.d3PhylotreeTriggerLayout(this),this)}handle_node_click(t,e){this.nodeDropdownMenu(t,this.container,this,this.options,e)}refresh(){if(this.svg){let t=this.svg.selectAll("."+this.css_classes["tree-container"]).selectAll(fs(this.css_classes)).attr("class",this.reclassEdge.bind(this));this.edge_styler&&t.each(t=>{this.edge_styler(It(this),t)})}return this}countHandler(t){return arguments.length?(this.count_listener_handler=t,this):this.count_listener_handler}style_nodes(t){return arguments.length?(this.node_styler=t,this):this.node_styler}style_edges(t){return arguments.length?(this.edge_styler=t.bind(this),this):this.edge_styler}itemSelected(t,e){return t[e]||!1}show(){return this.svg.node()}}a.extend(ks.prototype,cs),a.extend(ks.prototype,ls),a.extend(ks.prototype,ds),a.extend(ks.prototype,ys),a.extend(ks.prototype,xs),a.extend(ks.prototype,es);let Ns=class{constructor(t,e={}){this.newick_string="",this.nodes=[],this.links=[],this.parsed_tags=[],this.partitions=[],this.branch_length_accessor=jo,this.branch_length=jo,this.logger=e.logger||console,this.selection_attribute_name="selected";var n=e.type||void 0,r=[],i=this;if(a.isString(n))n in Lo?r=Lo[n](t,e):i.logger.error("type "+n+" not in registry! Available types are "+a.keys(Lo));else if(a.isFunction(n))try{r=n(t,e)}catch(t){i.logger.error("Could not parse custom format!")}else"root"==t.name?r={json:t,error:null}:"string"!=typeof t?r=t:"application/xml"==t.contentType?r=Do(t):(this.newick_string=t,r=To(t,e));if(r.json){i.nodes=Rr(r.json);let t={};i.nodes.each(e=>{e.data.annotation&&(t[e.data.annotation]=!0)}),i.parsed_tags=Object.keys(t)}else i.nodes=[];return i.links=i.nodes.links(),this.hasBranchLengths()||(console.warn("Phylotree User Warning : NO BRANCH LENGTHS DETECTED, SETTING ALL LENGTHS TO 1"),this.setBranchLength(t=>1)),i}json(t){var e=0;this.traverse_and_compute(function(t){t.json_export_index=e++},t);var n=new Array(e);return e=0,this.traverse_and_compute(function(t){let r=a.clone(t);delete r.json_export_index,t.parent&&(r.parent=t.parent.json_export_index),t.children&&(r.children=a.map(t.children,function(t){return t.json_export_index})),n[e++]=r},t),this.traverse_and_compute(function(t){delete t.json_export_index},t),JSON.stringify(n)}traverse_and_compute(t,e,n,r){return(e="pre-order"==(e=e||"post-order")?function(e){Po(e,t,r)}:"in-order"==e?function(e){Ho(e,t,r)}:function(e){a.isUndefined(e)||Uo(e,t,r)})(n||this.nodes),this}get_parsed_tags(){return this.parsed_tags}update(t){this.nodes=t}render(t){return this.display=new ks(this,t),this.display}};function Ts(t){var e=t.branch_length_accessor;if(!e)throw"A non-null branch lengths accessor function is required for this operation";var n=0;function r(t){for(var e=0;e<t.children.length;e++)for(var n=0;n<t.children.length;n++)e!=n&&a.each(t.children[n].cot_path_to_leaves_below,function(r,i){t.children[e].cot_path_to_leaves_above&&(t.children[e].cot_path_to_leaves_above[i]=r+t.children[n].cot_computed_length)})}return t.traverse_and_compute(function(r){if(r.cot_computed_length=e(r),r.parent&&a.isUndefined(r.cot_computed_length))throw"Non-null branch lengths are required for this operation: missing branch length at node "+r.data.name;t.isLeafNode(r)?(r.cot_leaf_index=n++,r.cot_path_to_leaves_below={},r.cot_path_to_leaves_below[r.cot_leaf_index]=0,r.cot_path_to_leaves_above={}):(r.cot_path_to_leaves_below={},r.cot_path_to_leaves_above={})}),t.traverse_and_compute(function(t){t.parent&&a.each(t.cot_path_to_leaves_below,function(e,n){t.parent.cot_path_to_leaves_below[n]=e+t.cot_computed_length})}),r(t.getRootNode()),t.traverse_and_compute(function(e){e.parent&&(a.each(e.parent.cot_path_to_leaves_above,function(t,n){e.cot_path_to_leaves_above[n]=t+e.parent.cot_computed_length}),t.isLeafNode(e)||r(e))},"pre-order"),n}function As(t,e,n,r,i){var a=t.branch_length(e),o=!1;if(n||(r=e.data.rootToTip,i=0,o=!0),e.children)for(var s=0;s<e.children.length;s++)e.children[s]!=n?As(t,e.children[s],e,r,i):o=!0;e.data.rtta=e.data.rootToTip-r+i,o&&(r-=a,i+=a),e.parent&&o&&As(t,e.parent,e,r,i)}function zs(t){var e=t.reduce(function(t,e){return e[2]+t},0),n=t.reduce(function(t,e){return e[2]*e[0]+t},0),r=t.reduce(function(t,e){return e[2]*e[1]+t},0),i=n/e,a=r/e,o=0,s=0,l=0;t.forEach(function(t){var e=t[0]-i;s+=t[2]*e*e,o+=t[2]*e*t[1],l+=t[2]*(t[1]-a)*(t[1]-a)});var u=(r-n*(o/=s))/e,c=0;return t.forEach(function(t){var e=t[1]-u-o*t[0];c+=t[2]*e*e}),{intercept:u,slope:o,r2:1-c/l,"var (intercept)":Math.sqrt((1+n*n/(e*s))/e),"var (slope)":Math.sqrt(1/s)}}function Ss(t){var e=t.branch_length_accessor,n=0;t.traverse_and_compute(r=>{if(r.parent&&(r.data._computed_length=e(r),!a.isNumber(r.data._computed_length)))throw"rootToTip cannot be run on trees with missing branch lengths";t.isLeafNode(r)&&(r.data.leaf_index=n++),"r2t"in r.data&&delete r.data.r2t}),t.traverse_and_compute(e=>{e.parent&&("r2t"in e.parent.data||(e.parent.data.r2t={}),t.isLeafNode(e)?e.parent.data.r2t[e.data.leaf_index]=e.data._computed_length:(a.each(e.data.r2t,function(t,n){e.parent.data.r2t[n]=t+e.data._computed_length}),delete e.data.r2t),delete e.data._computed_length)});var r=t.getRootNode().data.r2t;return t.traverse_and_compute(e=>{t.isLeafNode(e)&&(e.data.rootToTip=r[e.data.leaf_index]||0,delete e.data.leaf_index)}),delete t.getRootNode().data.r2t,t}Ns.prototype.isLeafNode=Mo,Ns.prototype.selectAllDescendants=ko,Ns.prototype.mrca=function(t){var e;return t=t.map(function(t){return"string"==typeof t?t:t.data.name}),this.traverse_and_compute(function(n){n.children?n.parent?(n.data.mrca=a.union(...n.descendants().map(t=>t.data.mrca)),e||n.data.mrca.length!=t.length||(e=n)):e||(e=n):n.data.mrca=a.intersection([n.data.name],t)}),e},Ns.prototype.hasBranchLengths=function(){let t=this.branch_length;return!!t&&a.every(this.nodes.descendants(),function(e){return!e.parent||!a.isUndefined(t(e))})},Ns.prototype.getBranchLengths=function(){let t=this.branch_length;return a.map(this.nodes.descendants(),e=>t(e))},Ns.prototype.branchName=function(t){return arguments.length?(this.nodeLabel=t,this):this.nodeLabel},Ns.prototype.normalizeBranchLengths=function(t){let e=this.branch_length,n=a.map(this.nodes.descendants(),function(t){return e(t)?e(t):null});const r=a.max(n),i=a.min(n);return a.each(this.nodes.descendants(),t=>{let n=e(t);n&&e(t,function(t){return(t-i)/(r-i)}(n))}),this},Ns.prototype.scaleBranchLengths=function(t){let e=this.branch_length;return a.each(this.nodes.descendants(),n=>{let r=e(n);r&&e(n,t(r))}),this},Ns.prototype.getNewick=Ao,Ns.prototype.resortChildren=function(t,e,n){return this.nodes.sum(function(t){return t.value}).sort(t),this.display&&(this.display.update_layout(this.nodes),this.display.update()),this},Ns.prototype.setBranchLength=function(t){return arguments.length?(this.branch_length_accessor=t||jo,this):this.branch_length_accessor},Ns.prototype.maxParsimony=function(t,e){const n=a.partial(function(t,e){if(e.mp=[[0,0],[!1,!1]],Mo(e))e.mp[1][0]=e.mp[1][1]=e[t]||!1,e.mp[0][0]=e.mp[1][0]?1:0,e.mp[0][1]=1-e.mp[0][0];else{e.children.forEach(n);var r=e.children.reduce(function(t,e){return e.mp[0][0]+t},0),i=e.children.reduce(function(t,e){return e.mp[0][1]+t},0);e[t]?(e.mp[0][0]=i+1,e.mp[1][0]=!0,e.mp[0][1]=i,e.mp[1][1]=!0):(r<i+1?(e.mp[0][0]=r,e.mp[1][0]=!1):(e.mp[0][0]=i+1,e.mp[1][0]=!0),i<r+1?(e.mp[0][1]=i,e.mp[1][1]=!0):(e.mp[0][1]=r+1,e.mp[1][1]=!1))}},e);n(this.nodes),this.nodes.each(t=>{t.parent?t.mp=t.mp[1][t.parent.mp?1:0]:t.mp=t.mp[1][t.mp[0][0]<t.mp[0][1]?0:1]}),this.display.modifySelection((t,n)=>Mo(t.target)?t.target[e]:t.target.mp)},Ns.prototype.getTipLengths=function(){let t=this.getTips(),e=a.map(t,t=>({name:t.data.name,length:parseFloat(t.data.attribute)}));return e=a.sortBy(e,t=>-t.length),e},Ns.prototype.leftChildRightSibling=Oo,a.extend(Ns.prototype,No),a.extend(Ns.prototype,Fo),a.extend(Ns.prototype,Co);const Es=Pi("%Y%m%d"),Cs=/([0-9]{4}).?([0-9]{2}).?([0-9]{2})$/g,$s=function(t){if(Mo(t)&&"name"in t){let e=Cs.exec(t.name);if(e)return e[1]+e[2]+e[3]}return null};function Ds(t,e){let n=[];for(let r of o.range(e.length))if(r!=t){let i=[];for(let n of o.range(e[r].length))n!=t&&i.push(e[r][n]);n.push(i)}return n}t.centerOfTree=function(t,e){e=e||2;var n=Ts(t),r=Number.MAX_VALUE,i=0,o=null;return 2==e?t.traverse_and_compute(function(t){if(t.parent){var e=0,s=0,l=0,u=0,c=0;a.each(t.cot_path_to_leaves_below,function(t){e+=t,s+=t*t,c++}),a.each(t.cot_path_to_leaves_above,function(t){l+=t,u+=t*t});var h=n-c,f=(l-e+t.cot_computed_length*h)/n;f<0?f=0:f>t.cot_computed_length&&(f=t.cot_computed_length);var d=u+s+2*(l*(t.cot_computed_length-f)+e*f)+c*f*f+(t.cot_computed_length-f)*(t.cot_computed_length-f)*h;d<r&&(o=t,i=f/t.cot_computed_length,r=d),delete t.cot_computed_length,delete t.cot_path_to_leaves_below,delete t.cot_path_to_leaves_above,delete t.cot_leaf_index}}):t.traverse_and_compute(function(t){if(t.parent)for(var n=t.cot_computed_length>0?.05*t.cot_computed_length:.1,s=0;s<t.cot_computed_length;){var l=0;a.each(t.cot_path_to_leaves_below,function(t){l+=Math.pow(t+s,e)}),a.each(t.cot_path_to_leaves_above,function(n){l+=Math.pow(n+(t.cot_computed_length-s),e)}),l<r&&(o=t,i=s/t.cot_computed_length,r=l),s+=n}}),{location:o,breakpoint:i,distance:r}},t.clusterPicker=function(t,e,n,r,i){r=r||t.getRootNode(),i=a.isNumber(i)?i:1;let o=t.branch_length;t.traverse_and_compute(function(t){if(t.parent){if(t._computed_length=o(t),!a.isNumber(t._computed_length))throw"clusterPicker cannot be run on trees with missing branch lengths";t.max_path_length=0}}),t.traverse_and_compute(function(t){t.parent&&(t.parent.max_path_length=Math.max(t.parent.max_path_length,t.max_path_length+t._computed_length))});var s=[];return t.traverse_and_compute(a.noop,"pre-order",r,function(r){if(!t.isLeafNode(r)){var o=a.isString(r.data.bootstrap_values)?+r.data.bootstrap_values:i;if(o>=e){var l=a.reduce(r.children,function(t,e){return e.max_path_length+e._computed_length+t},0);if(l<=n)return s.push({root:r,diameter:l,bootstrap:o}),!0}}return!1}),t.traverse_and_compute(function(t){t.parent&&(delete t._computed_length,delete t.max_path_length)},"post-order",r),a.each(s,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),s},t.computeMidpoint=function(t){if(!t.hasBranchLengths())throw"Center of tree calculation cannot be performed on trees that do not have fully specified branch lengths";var e=t.branch_length;t.traverse_and_compute(function(n){if(n.parent){var r,i=e(n);t.isLeafNode(n)?(r=n,n.max_path=0,n.max_path_terminus=n):(i+=n.max_path,r=n.max_path_terminus),(!n.parent.max_path||n.parent.max_path<i)&&(n.parent.max_path=i,n.parent.max_path_terminus=r)}});var n=t.getRootNode(),r=0;if(n.children.forEach(function(t){if(t.max_path_terminus!==n.max_path_terminus){var i=t.max_path+e(t);i>=r&&(r=i)}}),n.max_path>r){r=.5*(r+n.max_path);for(var i=n.max_path_terminus;;){var a=e(i);if(!(a<=r))return{location:i,breakpoint:r/a};r-=a,i=i.parent}}return{location:n,breakpoint:0}},t.extract_dates=function(t,e,n=Es){return e=e||$s,t.traverse_and_compute(function(t){var r=e(t);if(r)try{t.data.date_value=n(r);var i=t.data.date_value.getFullYear(),a=new Date(i,0,1),o=new Date(i+1,0,1);return void(t.data.decimal_date_value=i+(t.data.date_value-a)/(o-a))}catch(t){}t.data.date_value=null,t.data.decimal_date_value=null}),t},t.fitRootToTip=function(t){var e=[],n=0,r=0;!function(t){t.traverse_and_compute(function(e){t.isLeafNode(e)&&(e.data.copy_number=1)})}(t),Ss(t),t.traverse_and_compute(function(n){t.isLeafNode(n)&&!a.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});let i=zs(e);return t.traverse_and_compute(function(o){if(t.isLeafNode(o)&&!a.isNull(o.data.decimal_date_value)){As(t,o,null,0,0),e=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&!a.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});var s=zs(e),l=s.r2;l>n&&(n=l,r=o,i=s)}}),{root:r,fit:i}},t.getDistanceMatrix=function(t){let e=o.keys(t)[0],n=t[e].length;return o.mapValues(t,e=>o.map(t,t=>o.sum(o.map(o.range(n),n=>e[n]!=t[n]&&"-"!=e[n]&&"-"!=t[n]))))},t.getNewick=Ao,t.inOrder=Ho,t.leftChildRightSibling=Oo,t.loadAnnotations=So,t.neighborJoining=function t(e,n,r){if(n<=2){let t=new Ns(""),n=t.getNodes(),i=e[0][1]/2,a=t.createNode(r[0],[null,[i]]),o=t.createNode(r[1],[null,[i]]);return t.addChild(n,a),t.addChild(n,o),t}{let a=n,s=(i=e,o.map(i,o.sum)),l=function(t,e,n){let r=o.chunk(o.fill(Array(n*n),0),n);for(let i of o.range(n))for(let a of o.range(o.parseInt(i)+1,n))r[i][a]=(n-2)*t[i][a]-e[i]-e[a],r[a][i]=r[i][a];return r}(e,s,a),[u,c,h]=function(t,e){let n=-1,r=-1,i=1/0;for(let a of o.range(e))for(let s of o.range(n,e))t[a][s]<i&&(n=a,r=s,i=t[n][r]);return[n,r,i]}(l,a),f=function(t,e){let n=o.chunk(Array(e*e),e);for(let r of o.range(e))for(let i of o.range(parseInt(r)+1,e))n[r][i]=(t[r]-t[i])/(e-2),n[i][r]=n[r][i];return n}(s,a),d=(e[u][c]+f[u][c])/2,p=(e[u][c]-f[u][c])/2,_=o.concat(0,o.filter(o.map(o.range(n),t=>{if(t!=u&&t!=c)return.5*(e[t][u]+e[t][c]-e[u][c])}),o.isNumber)),g=r[u],m=r[c],v="InternalNode0",y=o.filter(r,t=>o.includes(t,"InternalNode"));if(y.length){let t=o.max(o.map(y,t=>o.split(t,"InternalNode")[1]));v="InternalNode"+ ++t}r.unshift(v),e=Ds(o.max([u,c]),e),(e=Ds(o.min([u,c]),e)).unshift(_),o.each(o.range(1,n-1),t=>e[t].unshift(_[t])),o.remove(r,t=>t==g||t==m);let b=t(e,a-1,r),w=b.createNode(g,[null,[d]]),x=b.createNode(m,[null,[p]]);if(b.getNodeByName(v)){let t=b.getNodeByName(v);b.addChild(t,w),b.addChild(t,x)}else{let t=b.createNode(v,[null,[0]]);b.addChild(b.getNodes(),t),b.addChild(t,w),b.addChild(t,x)}return b}var i},t.newickParser=To,t.pairwise_distances=Ts,t.parseAnnotations=zo,t.parseFasta=function(t){let e=o.split(t,"\n");return o.chain(e).map((t,e)=>t.startsWith(">")?e:-1).filter(t=>-1!=t).map((t,n,r)=>o.slice(e,r[n],r[n+1])).keyBy(t=>o.trim(t[0],">")).mapValues(t=>o.tail(t).join("")).value()},t.phylopart=function(t,e,n,r,i){r=a.isNumber(r)?r:1;var o=Ts(t),s=t.getRootNode().children[0],l=Number.MAX_VALUE,u=Number.MAX_VALUE;if(!(n>0&&n<1))throw"Invalid percentile threshold in perform_phylopart";t.traverse_and_compute(function(e){t.isLeafNode(e)&&(e.cot_computed_length<l?(l<u&&(u=l),l=e.cot_computed_length):e.cot_computed_length<u&&(u=e.cot_computed_length))}),l+=u;var c=a.reduce(s.cot_path_to_leaves_below,function(t,e){return e>t?e:t},0)+a.reduce(s.cot_path_to_leaves_above,function(t,e){return e>t?e:t},0)+s.cot_computed_length-l;a.isUndefined(i)&&(i=Math.min(.001,c/100));var h=1+(c/i|0);h>500&&(i=c/(h=500));var f=t.getRootNode();f.paths_to_leaves=new Array(o),a.each(f.children,function(t){a.each(f.cot_path_to_leaves_below,function(e,n){f.paths_to_leaves[n]=e+t.cot_computed_length})}),t.traverse_and_compute(function(e){if(!t.isLeafNode(e)){e.histogram=new Array(h);for(var n=0;n<h;n++)e.histogram[n]=0;if(e.parent){var r=0;e.paths_to_leaves=[],a.each(e.cot_path_to_leaves_below,function(t,n){e.paths_to_leaves[r++]=t})}}delete e.cot_path_to_leaves_above,delete e.cot_path_to_leaves_below}),t.traverse_and_compute(function(e){if(!t.isLeafNode(e)){for(var n=0;n<e.paths_to_leaves.length;n++)for(var r=n+1;r<e.paths_to_leaves.length;r++){var a=e.paths_to_leaves[n]+e.paths_to_leaves[r];e.histogram[(a-l)/i|0]++}e.leaf_count=e.paths_to_leaves.length,delete e.paths_to_leaves}});for(var d=(o-1)*o/2*n,p=0;p<h-1&&d>f.histogram[p];p++)d-=f.histogram[p];var _=l+(p+(f.histogram[p]-d)/f.histogram[p])*i,g=[];return t.traverse_and_compute(a.noop,"pre-order",null,function(n){if(!t.isLeafNode(n)){var o=a.isString(n.data.bootstrap_values)?+n.data.bootstrap_values:r;if(o>=e){for(var s=n.leaf_count*(n.leaf_count-1)*.25,u=0;u<h-1&&s>n.histogram[u];u++)s-=n.histogram[u];var c=l+(u+(n.histogram[u]-s)/n.histogram[u])*i;if(c<=_)return g.push({root:n,median:c,bootstrap:o}),!0}}return!1}),t.traverse_and_compute(function(e){t.isLeafNode(e)||"histogram"in e&&(delete e.histogram,delete e.leaf_count)}),a.each(g,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),g},t.phylotree=Ns,t.postOrder=Uo,t.preOrder=Po,t.rootToTip=Ss,t.sackin=function(t){let e=t.getTips(),n=a.map(e,t=>t.depth);return a.reduce(n,function(t,e){return t+e},0)},Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("underscore"),require("xml2js"),require("fast-xml-parser"),require("lodash")):"function"==typeof define&&define.amd?define(["exports","underscore","xml2js","fast-xml-parser","lodash"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phylotree=t.phylotree||{},t._,t.xml2js,t.fastXmlParser,t._$1)}(this,function(t,e,n,r,i){"use strict";function a(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var o=a(e),s=a(i);function l(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function u(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function c(t){let e,n,r;function i(t,r,i=0,a=t.length){if(i<a){if(0!==e(r,r))return a;do{const e=i+a>>>1;n(t[e],r)<0?i=e+1:a=e}while(i<a)}return i}return 2!==t.length?(e=l,n=(e,n)=>l(t(e),n),r=(e,n)=>t(e)-n):(e=t===l||t===u?t:h,n=t,r=t),{left:i,center:function(t,e,n=0,a=t.length){const o=i(t,e,n,a-1);return o>n&&r(t[o-1],e)>-r(t[o],e)?o-1:o},right:function(t,r,i=0,a=t.length){if(i<a){if(0!==e(r,r))return a;do{const e=i+a>>>1;n(t[e],r)<=0?i=e+1:a=e}while(i<a)}return i}}}function h(){return 0}const f=c(l).right;c(function(t){return null===t?NaN:+t}).center;var d=f;const p=Math.sqrt(50),_=Math.sqrt(10),g=Math.sqrt(2);function m(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=p?10:a>=_?5:a>=g?2:1;let s,l,u;return i<0?(u=Math.pow(10,-i)/o,s=Math.round(t*u),l=Math.round(e*u),s/u<t&&++s,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*o,s=Math.round(t/u),l=Math.round(e/u),s*u<t&&++s,l*u>e&&--l),l<s&&.5<=n&&n<2?m(t,e,2*n):[s,l,u]}function v(t,e,n){return m(t=+t,e=+e,n=+n)[2]}function y(t){return t}var b=1e-6;function w(t){return"translate("+t+",0)"}function x(t){return"translate(0,"+t+")"}function M(t){return e=>+t(e)}function k(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function N(){return!this.__axis}function A(t,e){var n=[],r=null,i=null,a=6,o=6,s=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,u=1===t||4===t?-1:1,c=4===t||2===t?"x":"y",h=1===t||3===t?w:x;function f(f){var d=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,p=null==i?e.tickFormat?e.tickFormat.apply(e,n):y:i,_=Math.max(a,0)+s,g=e.range(),m=+g[0]+l,v=+g[g.length-1]+l,w=(e.bandwidth?k:M)(e.copy(),l),x=f.selection?f.selection():f,A=x.selectAll(".domain").data([null]),T=x.selectAll(".tick").data(d,e).order(),z=T.exit(),S=T.enter().append("g").attr("class","tick"),E=T.select("line"),C=T.select("text");A=A.merge(A.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),T=T.merge(S),E=E.merge(S.append("line").attr("stroke","currentColor").attr(c+"2",u*a)),C=C.merge(S.append("text").attr("fill","currentColor").attr(c,u*_).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),f!==x&&(A=A.transition(f),T=T.transition(f),E=E.transition(f),C=C.transition(f),z=z.transition(f).attr("opacity",b).attr("transform",function(t){return isFinite(t=w(t))?h(t+l):this.getAttribute("transform")}),S.attr("opacity",b).attr("transform",function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:w(t))+l)})),z.remove(),A.attr("d",4===t||2===t?o?"M"+u*o+","+m+"H"+l+"V"+v+"H"+u*o:"M"+l+","+m+"V"+v:o?"M"+m+","+u*o+"V"+l+"H"+v+"V"+u*o:"M"+m+","+l+"H"+v),T.attr("opacity",1).attr("transform",function(t){return h(w(t)+l)}),E.attr(c+"2",u*a),C.attr(c,u*_).text(p),x.filter(N).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),x.each(function(){this.__axis=w})}return f.scale=function(t){return arguments.length?(e=t,f):e},f.ticks=function(){return n=Array.from(arguments),f},f.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),f):n.slice()},f.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),f):r&&r.slice()},f.tickFormat=function(t){return arguments.length?(i=t,f):i},f.tickSize=function(t){return arguments.length?(a=o=+t,f):a},f.tickSizeInner=function(t){return arguments.length?(a=+t,f):a},f.tickSizeOuter=function(t){return arguments.length?(o=+t,f):o},f.tickPadding=function(t){return arguments.length?(s=+t,f):s},f.offset=function(t){return arguments.length?(l=+t,f):l},f}var T={value:()=>{}};function z(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new S(r)}function S(t){this._=t}function E(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function C(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=T,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}S.prototype=z.prototype={constructor:S,on:function(t,e){var n,r,i=this._,a=(r=i,(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),o=-1,s=a.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<s;)if(n=(t=a[o]).type)i[n]=C(i[n],t.name,e);else if(null==e)for(n in i)i[n]=C(i[n],t.name,null);return this}for(;++o<s;)if((n=(t=a[o]).type)&&(n=E(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new S(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),a=0;a<n;++a)i[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=0,n=(r=this._[t]).length;a<n;++a)r[a].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};var $="http://www.w3.org/1999/xhtml",D={svg:"http://www.w3.org/2000/svg",xhtml:$,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function L(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),D.hasOwnProperty(e)?{space:D[e],local:t}:t}function U(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===$&&e.documentElement.namespaceURI===$?e.createElement(t):e.createElementNS(n,t)}}function P(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function O(t){var e=L(t);return(e.local?P:U)(e)}function H(){}function j(t){return null==t?H:function(){return this.querySelector(t)}}function F(){return[]}function Y(t){return null==t?F:function(){return this.querySelectorAll(t)}}function R(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function q(t){return function(){return this.matches(t)}}function I(t){return function(e){return e.matches(t)}}var B=Array.prototype.find;function V(){return this.firstElementChild}var X=Array.prototype.filter;function W(){return Array.from(this.children)}function Z(t){return new Array(t.length)}function G(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function K(t,e,n,r,i,a){for(var o,s=0,l=e.length,u=a.length;s<u;++s)(o=e[s])?(o.__data__=a[s],r[s]=o):n[s]=new G(t,a[s]);for(;s<l;++s)(o=e[s])&&(i[s]=o)}function Q(t,e,n,r,i,a,o){var s,l,u,c=new Map,h=e.length,f=a.length,d=new Array(h);for(s=0;s<h;++s)(l=e[s])&&(d[s]=u=o.call(l,l.__data__,s,e)+"",c.has(u)?i[s]=l:c.set(u,l));for(s=0;s<f;++s)u=o.call(t,a[s],s,a)+"",(l=c.get(u))?(r[s]=l,l.__data__=a[s],c.delete(u)):n[s]=new G(t,a[s]);for(s=0;s<h;++s)(l=e[s])&&c.get(d[s])===l&&(i[s]=l)}function J(t){return t.__data__}function tt(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function et(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function nt(t){return function(){this.removeAttribute(t)}}function rt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function it(t,e){return function(){this.setAttribute(t,e)}}function at(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function ot(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function st(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function lt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ut(t){return function(){this.style.removeProperty(t)}}function ct(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ht(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ft(t,e){return t.style.getPropertyValue(e)||lt(t).getComputedStyle(t,null).getPropertyValue(e)}function dt(t){return function(){delete this[t]}}function pt(t,e){return function(){this[t]=e}}function _t(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function gt(t){return t.trim().split(/^|\s+/)}function mt(t){return t.classList||new vt(t)}function vt(t){this._node=t,this._names=gt(t.getAttribute("class")||"")}function yt(t,e){for(var n=mt(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function bt(t,e){for(var n=mt(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function wt(t){return function(){yt(this,t)}}function xt(t){return function(){bt(this,t)}}function Mt(t,e){return function(){(e.apply(this,arguments)?yt:bt)(this,t)}}function kt(){this.textContent=""}function Nt(t){return function(){this.textContent=t}}function At(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Tt(){this.innerHTML=""}function zt(t){return function(){this.innerHTML=t}}function St(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function Et(){this.nextSibling&&this.parentNode.appendChild(this)}function Ct(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function $t(){return null}function Dt(){var t=this.parentNode;t&&t.removeChild(this)}function Lt(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ut(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Pt(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,a=e.length;r<a;++r)n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function Ot(t,e,n){return function(){var r,i=this.__on,a=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var o=0,s=i.length;o<s;++o)if((r=i[o]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=a,r.options=n),void(r.value=e);this.addEventListener(t.type,a,n),r={type:t.type,name:t.name,value:e,listener:a,options:n},i?i.push(r):this.__on=[r]}}function Ht(t,e,n){var r=lt(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function jt(t,e){return function(){return Ht(this,t,e)}}function Ft(t,e){return function(){return Ht(this,t,e.apply(this,arguments))}}G.prototype={constructor:G,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},vt.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Yt=[null];function Rt(t,e){this._groups=t,this._parents=e}function qt(){return new Rt([[document.documentElement]],Yt)}function It(t){return"string"==typeof t?new Rt([[document.querySelector(t)]],[document.documentElement]):new Rt([[t]],Yt)}function Bt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}Rt.prototype=qt.prototype={constructor:Rt,select:function(t){"function"!=typeof t&&(t=j(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o,s=e[i],l=s.length,u=r[i]=new Array(l),c=0;c<l;++c)(a=s[c])&&(o=t.call(a,a.__data__,c,s))&&("__data__"in a&&(o.__data__=a.__data__),u[c]=o);return new Rt(r,this._parents)},selectAll:function(t){t="function"==typeof t?R(t):Y(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o,s=e[a],l=s.length,u=0;u<l;++u)(o=s[u])&&(r.push(t.call(o,o.__data__,u,s)),i.push(o));return new Rt(r,i)},selectChild:function(t){return this.select(null==t?V:function(t){return function(){return B.call(this.children,t)}}("function"==typeof t?t:I(t)))},selectChildren:function(t){return this.selectAll(null==t?W:function(t){return function(){return X.call(this.children,t)}}("function"==typeof t?t:I(t)))},filter:function(t){"function"!=typeof t&&(t=q(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,l=r[i]=[],u=0;u<s;++u)(a=o[u])&&t.call(a,a.__data__,u,o)&&l.push(a);return new Rt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,J);var n=e?Q:K,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var a=i.length,o=new Array(a),s=new Array(a),l=new Array(a),u=0;u<a;++u){var c=r[u],h=i[u],f=h.length,d=tt(t.call(c,c&&c.__data__,u,r)),p=d.length,_=s[u]=new Array(p),g=o[u]=new Array(p);n(c,h,_,g,l[u]=new Array(f),d,e);for(var m,v,y=0,b=0;y<p;++y)if(m=_[y]){for(y>=b&&(b=y+1);!(v=g[b])&&++b<p;);m._next=v||null}}return(o=new Rt(o,r))._enter=s,o._exit=l,o},enter:function(){return new Rt(this._enter||this._groups.map(Z),this._parents)},exit:function(){return new Rt(this._exit||this._groups.map(Z),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,a=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?a.remove():n(a),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,a=r.length,o=Math.min(i,a),s=new Array(i),l=0;l<o;++l)for(var u,c=n[l],h=r[l],f=c.length,d=s[l]=new Array(f),p=0;p<f;++p)(u=c[p]||h[p])&&(d[p]=u);for(;l<i;++l)s[l]=n[l];return new Rt(s,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],a=i.length-1,o=i[a];--a>=0;)(r=i[a])&&(o&&4^r.compareDocumentPosition(o)&&o.parentNode.insertBefore(r,o),o=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=et);for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o,s=n[a],l=s.length,u=i[a]=new Array(l),c=0;c<l;++c)(o=s[c])&&(u[c]=o);u.sort(e)}return new Rt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,a=e[n],o=0,s=a.length;o<s;++o)(i=a[o])&&t.call(i,i.__data__,o,a);return this},attr:function(t,e){var n=L(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?rt:nt:"function"==typeof e?n.local?st:ot:n.local?at:it)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?ut:"function"==typeof e?ht:ct)(t,e,null==n?"":n)):ft(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?dt:"function"==typeof e?_t:pt)(t,e)):this.node()[t]},classed:function(t,e){var n=gt(t+"");if(arguments.length<2){for(var r=mt(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?Mt:e?wt:xt)(n,e))},text:function(t){return arguments.length?this.each(null==t?kt:("function"==typeof t?At:Nt)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Tt:("function"==typeof t?St:zt)(t)):this.node().innerHTML},raise:function(){return this.each(Et)},lower:function(){return this.each(Ct)},append:function(t){var e="function"==typeof t?t:O(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:O(t),r=null==e?$t:"function"==typeof e?e:j(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(Dt)},clone:function(t){return this.select(t?Ut:Lt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,a=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),o=a.length;if(!(arguments.length<2)){for(s=e?Ot:Pt,r=0;r<o;++r)this.each(s(a[r],e,n));return this}var s=this.node().__on;if(s)for(var l,u=0,c=s.length;u<c;++u)for(r=0,l=s[u];r<o;++r)if((i=a[r]).type===l.type&&i.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?Ft:jt)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],a=0,o=i.length;a<o;++a)(r=i[a])&&(yield r)}};const Vt={capture:!0,passive:!1};function Xt(t){t.preventDefault(),t.stopImmediatePropagation()}function Wt(t){var e=t.document.documentElement,n=It(t).on("dragstart.drag",Xt,Vt);"onselectstart"in e?n.on("selectstart.drag",Xt,Vt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Zt(t,e){var n=t.document.documentElement,r=It(t).on("dragstart.drag",null);e&&(r.on("click.drag",Xt,Vt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Gt(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Kt(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Qt(){}var Jt=.7,te=1/Jt,ee="\\s*([+-]?\\d+)\\s*",ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",re="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ie=/^#([0-9a-f]{3,8})$/,ae=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),oe=new RegExp(`^rgb\\(${re},${re},${re}\\)$`),se=new RegExp(`^rgba\\(${ee},${ee},${ee},${ne}\\)$`),le=new RegExp(`^rgba\\(${re},${re},${re},${ne}\\)$`),ue=new RegExp(`^hsl\\(${ne},${re},${re}\\)$`),ce=new RegExp(`^hsla\\(${ne},${re},${re},${ne}\\)$`),he={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};function fe(){return this.rgb().formatHex()}function de(){return this.rgb().formatRgb()}function pe(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ie.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?_e(e):3===n?new ve(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?ge(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?ge(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=ae.exec(t))?new ve(e[1],e[2],e[3],1):(e=oe.exec(t))?new ve(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=se.exec(t))?ge(e[1],e[2],e[3],e[4]):(e=le.exec(t))?ge(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=ue.exec(t))?ke(e[1],e[2]/100,e[3]/100,1):(e=ce.exec(t))?ke(e[1],e[2]/100,e[3]/100,e[4]):he.hasOwnProperty(t)?_e(he[t]):"transparent"===t?new ve(NaN,NaN,NaN,0):null}function _e(t){return new ve(t>>16&255,t>>8&255,255&t,1)}function ge(t,e,n,r){return r<=0&&(t=e=n=NaN),new ve(t,e,n,r)}function me(t,e,n,r){return 1===arguments.length?((i=t)instanceof Qt||(i=pe(i)),i?new ve((i=i.rgb()).r,i.g,i.b,i.opacity):new ve):new ve(t,e,n,null==r?1:r);var i}function ve(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ye(){return`#${Me(this.r)}${Me(this.g)}${Me(this.b)}`}function be(){const t=we(this.opacity);return`${1===t?"rgb(":"rgba("}${xe(this.r)}, ${xe(this.g)}, ${xe(this.b)}${1===t?")":`, ${t})`}`}function we(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function xe(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Me(t){return((t=xe(t))<16?"0":"")+t.toString(16)}function ke(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ae(t,e,n,r)}function Ne(t){if(t instanceof Ae)return new Ae(t.h,t.s,t.l,t.opacity);if(t instanceof Qt||(t=pe(t)),!t)return new Ae;if(t instanceof Ae)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,s=a-i,l=(a+i)/2;return s?(o=e===a?(n-r)/s+6*(n<r):n===a?(r-e)/s+2:(e-n)/s+4,s/=l<.5?a+i:2-a-i,o*=60):s=l>0&&l<1?0:o,new Ae(o,s,l,t.opacity)}function Ae(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Te(t){return(t=(t||0)%360)<0?t+360:t}function ze(t){return Math.max(0,Math.min(1,t||0))}function Se(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Gt(Qt,pe,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:fe,formatHex:fe,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Ne(this).formatHsl()},formatRgb:de,toString:de}),Gt(ve,me,Kt(Qt,{brighter(t){return t=null==t?te:Math.pow(te,t),new ve(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Jt:Math.pow(Jt,t),new ve(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ve(xe(this.r),xe(this.g),xe(this.b),we(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:ye,formatHex:ye,formatHex8:function(){return`#${Me(this.r)}${Me(this.g)}${Me(this.b)}${Me(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:be,toString:be})),Gt(Ae,function(t,e,n,r){return 1===arguments.length?Ne(t):new Ae(t,e,n,null==r?1:r)},Kt(Qt,{brighter(t){return t=null==t?te:Math.pow(te,t),new Ae(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Jt:Math.pow(Jt,t),new Ae(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new ve(Se(t>=240?t-240:t+120,i,r),Se(t,i,r),Se(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ae(Te(this.h),ze(this.s),ze(this.l),we(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 t=we(this.opacity);return`${1===t?"hsl(":"hsla("}${Te(this.h)}, ${100*ze(this.s)}%, ${100*ze(this.l)}%${1===t?")":`, ${t})`}`}}));var Ee=t=>()=>t;function Ce(t){return 1===(t=+t)?$e:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):Ee(isNaN(e)?n:e)}}function $e(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Ee(isNaN(t)?e:t)}var De=function t(e){var n=Ce(e);function r(t,e){var r=n((t=me(t)).r,(e=me(e)).r),i=n(t.g,e.g),a=n(t.b,e.b),o=$e(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=a(e),t.opacity=o(e),t+""}}return r.gamma=t,r}(1);function Le(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(a){for(n=0;n<r;++n)i[n]=t[n]*(1-a)+e[n]*a;return i}}function Ue(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,a=new Array(i),o=new Array(r);for(n=0;n<i;++n)a[n]=Re(t[n],e[n]);for(;n<r;++n)o[n]=e[n];return function(t){for(n=0;n<i;++n)o[n]=a[n](t);return o}}function Pe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Oe(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function He(t,e){var n,r={},i={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?r[n]=Re(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var je=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fe=new RegExp(je.source,"g");function Ye(t,e){var n,r,i,a=je.lastIndex=Fe.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(n=je.exec(t))&&(r=Fe.exec(e));)(i=r.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(n=n[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,l.push({i:o,x:Oe(n,r)})),a=Fe.lastIndex;return a<e.length&&(i=e.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?l[0]?function(t){return function(e){return t(e)+""}}(l[0].x):function(t){return function(){return t}}(e):(e=l.length,function(t){for(var n,r=0;r<e;++r)s[(n=l[r]).i]=n.x(t);return s.join("")})}function Re(t,e){var n,r=typeof e;return null==e||"boolean"===r?Ee(e):("number"===r?Oe:"string"===r?(n=pe(e))?(e=n,De):Ye:e instanceof pe?De:e instanceof Date?Pe:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?Le:Array.isArray(e)?Ue:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?He:Oe)(t,e)}function qe(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Ie,Be=180/Math.PI,Ve={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Xe(t,e,n,r,i,a){var o,s,l;return(o=Math.sqrt(t*t+e*e))&&(t/=o,e/=o),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,l/=s),t*r<e*n&&(t=-t,e=-e,l=-l,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(e,t)*Be,skewX:Math.atan(l)*Be,scaleX:o,scaleY:s}}function We(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(a,o){var s=[],l=[];return a=t(a),o=t(o),function(t,r,i,a,o,s){if(t!==i||r!==a){var l=o.push("translate(",null,e,null,n);s.push({i:l-4,x:Oe(t,i)},{i:l-2,x:Oe(r,a)})}else(i||a)&&o.push("translate("+i+e+a+n)}(a.translateX,a.translateY,o.translateX,o.translateY,s,l),function(t,e,n,a){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),a.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Oe(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(a.rotate,o.rotate,s,l),function(t,e,n,a){t!==e?a.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Oe(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(a.skewX,o.skewX,s,l),function(t,e,n,r,a,o){if(t!==n||e!==r){var s=a.push(i(a)+"scale(",null,",",null,")");o.push({i:s-4,x:Oe(t,n)},{i:s-2,x:Oe(e,r)})}else 1===n&&1===r||a.push(i(a)+"scale("+n+","+r+")")}(a.scaleX,a.scaleY,o.scaleX,o.scaleY,s,l),a=o=null,function(t){for(var e,n=-1,r=l.length;++n<r;)s[(e=l[n]).i]=e.x(t);return s.join("")}}}var Ze=We(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Ve:Xe(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Ge=We(function(t){return null==t?Ve:(Ie||(Ie=document.createElementNS("http://www.w3.org/2000/svg","g")),Ie.setAttribute("transform",t),(t=Ie.transform.baseVal.consolidate())?Xe((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Ve)},", ",")",")");function Ke(t){return((t=Math.exp(t))+1/t)/2}var Qe,Je,tn=function t(e,n,r){function i(t,i){var a,o,s=t[0],l=t[1],u=t[2],c=i[0],h=i[1],f=i[2],d=c-s,p=h-l,_=d*d+p*p;if(_<1e-12)o=Math.log(f/u)/e,a=function(t){return[s+t*d,l+t*p,u*Math.exp(e*t*o)]};else{var g=Math.sqrt(_),m=(f*f-u*u+r*_)/(2*u*n*g),v=(f*f-u*u-r*_)/(2*f*n*g),y=Math.log(Math.sqrt(m*m+1)-m),b=Math.log(Math.sqrt(v*v+1)-v);o=(b-y)/e,a=function(t){var r=t*o,i=Ke(y),a=u/(n*g)*(i*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*r+y)-function(t){return((t=Math.exp(t))-1/t)/2}(y));return[s+a*d,l+a*p,u*i/Ke(e*r+y)]}}return a.duration=1e3*o*e/Math.SQRT2,a}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4),en=0,nn=0,rn=0,an=0,on=0,sn=0,ln="object"==typeof performance&&performance.now?performance:Date,un="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function cn(){return on||(un(hn),on=ln.now()+sn)}function hn(){on=0}function fn(){this._call=this._time=this._next=null}function dn(t,e,n){var r=new fn;return r.restart(t,e,n),r}function pn(){on=(an=ln.now())+sn,en=nn=0;try{!function(){cn(),++en;for(var t,e=Qe;e;)(t=on-e._time)>=0&&e._call.call(void 0,t),e=e._next;--en}()}finally{en=0,function(){var t,e,n=Qe,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Qe=e);Je=t,gn(r)}(),on=0}}function _n(){var t=ln.now(),e=t-an;e>1e3&&(sn-=e,an=t)}function gn(t){en||(nn&&(nn=clearTimeout(nn)),t-on>24?(t<1/0&&(nn=setTimeout(pn,t-ln.now()-sn)),rn&&(rn=clearInterval(rn))):(rn||(an=ln.now(),rn=setInterval(_n,1e3)),en=1,un(pn)))}function mn(t,e,n){var r=new fn;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}fn.prototype=dn.prototype={constructor:fn,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?cn():+n)+(null==e?0:+e),this._next||Je===this||(Je?Je._next=this:Qe=this,Je=this),this._call=t,this._time=n,gn()},stop:function(){this._call&&(this._call=null,this._time=1/0,gn())}};var vn=z("start","end","cancel","interrupt"),yn=[];function bn(t,e,n,r,i,a){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function a(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)}function o(a){var u,c,h,f;if(1!==n.state)return l();for(u in i)if((f=i[u]).name===n.name){if(3===f.state)return mn(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[u]):+u<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[u])}if(mn(function(){3===n.state&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=new Array(h=n.tween.length),u=0,c=-1;u<h;++u)(f=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=f);r.length=c+1}}function s(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(l),n.state=5,1),a=-1,o=r.length;++a<o;)r[a].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=dn(a,0,n.time)}(t,n,{name:e,index:r,group:i,on:vn,tween:yn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function wn(t,e){var n=Mn(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function xn(t,e){var n=Mn(t,e);if(n.state>3)throw new Error("too late; already running");return n}function Mn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function kn(t,e){var n,r,i,a=t.__transition,o=!0;if(a){for(i in e=null==e?null:e+"",a)(n=a[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete a[i]):o=!1;o&&delete t.__transition}}function Nn(t,e){var n,r;return function(){var i=xn(this,t),a=i.tween;if(a!==n)for(var o=0,s=(r=n=a).length;o<s;++o)if(r[o].name===e){(r=r.slice()).splice(o,1);break}i.tween=r}}function An(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var a=xn(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===e){i[l]=s;break}l===u&&i.push(s)}a.tween=i}}function Tn(t,e,n){var r=t._id;return t.each(function(){var t=xn(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return Mn(t,r).value[e]}}function zn(t,e){var n;return("number"==typeof e?Oe:e instanceof pe?De:(n=pe(e))?(e=n,De):Ye)(t,e)}function Sn(t){return function(){this.removeAttribute(t)}}function En(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Cn(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttribute(t);return o===a?null:o===r?i:i=e(r=o,n)}}function $n(t,e,n){var r,i,a=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===a?null:o===r?i:i=e(r=o,n)}}function Dn(t,e,n){var r,i,a;return function(){var o,s,l=n(this);if(null!=l)return(o=this.getAttribute(t))===(s=l+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,l));this.removeAttribute(t)}}function Ln(t,e,n){var r,i,a;return function(){var o,s,l=n(this);if(null!=l)return(o=this.getAttributeNS(t.space,t.local))===(s=l+"")?null:o===r&&s===i?a:(i=s,a=e(r=o,l));this.removeAttributeNS(t.space,t.local)}}function Un(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function Pn(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,i)),n}return i._value=e,i}function On(t,e){return function(){wn(this,t).delay=+e.apply(this,arguments)}}function Hn(t,e){return e=+e,function(){wn(this,t).delay=e}}function jn(t,e){return function(){xn(this,t).duration=+e.apply(this,arguments)}}function Fn(t,e){return e=+e,function(){xn(this,t).duration=e}}var Yn=qt.prototype.constructor;function Rn(t){return function(){this.style.removeProperty(t)}}var qn=0;function In(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Bn(){return++qn}var Vn=qt.prototype;In.prototype={constructor:In,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=j(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s,l,u=r[o],c=u.length,h=a[o]=new Array(c),f=0;f<c;++f)(s=u[f])&&(l=t.call(s,s.__data__,f,u))&&("__data__"in s&&(l.__data__=s.__data__),h[f]=l,bn(h[f],e,n,f,h,Mn(s,n)));return new In(a,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=Y(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var l,u=r[s],c=u.length,h=0;h<c;++h)if(l=u[h]){for(var f,d=t.call(l,l.__data__,h,u),p=Mn(l,n),_=0,g=d.length;_<g;++_)(f=d[_])&&bn(f,e,n,_,d,p);a.push(d),o.push(l)}return new In(a,o,e,n)},selectChild:Vn.selectChild,selectChildren:Vn.selectChildren,filter:function(t){"function"!=typeof t&&(t=q(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a,o=e[i],s=o.length,l=r[i]=[],u=0;u<s;++u)(a=o[u])&&t.call(a,a.__data__,u,o)&&l.push(a);return new In(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var l,u=e[s],c=n[s],h=u.length,f=o[s]=new Array(h),d=0;d<h;++d)(l=u[d]||c[d])&&(f[d]=l);for(;s<r;++s)o[s]=e[s];return new In(o,this._parents,this._name,this._id)},selection:function(){return new Yn(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Bn(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],l=s.length,u=0;u<l;++u)if(o=s[u]){var c=Mn(o,e);bn(o,t,n,u,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new In(r,this._parents,t,n)},call:Vn.call,nodes:Vn.nodes,node:Vn.node,size:Vn.size,empty:Vn.empty,each:Vn.each,on:function(t,e){var n=this._id;return arguments.length<2?Mn(this.node(),n).on.on(t):this.each(function(t,e,n){var r,i,a=function(t){return(t+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?wn:xn;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i}}(n,t,e))},attr:function(t,e){var n=L(t),r="transform"===n?Ge:zn;return this.attrTween(t,"function"==typeof e?(n.local?Ln:Dn)(n,r,Tn(this,"attr."+t,e)):null==e?(n.local?En:Sn)(n):(n.local?$n:Cn)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=L(t);return this.tween(n,(r.local?Un:Pn)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Ze:zn;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var a=ft(this,t),o=(this.style.removeProperty(t),ft(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}(t,r)).on("end.style."+t,Rn(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,a;return function(){var o=ft(this,t),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(t),l=s=ft(this,t)),o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s))}}(t,r,Tn(this,"style."+t,e))).each(function(t,e){var n,r,i,a,o="style."+e,s="end."+o;return function(){var l=xn(this,t),u=l.on,c=null==l.value[o]?a||(a=Rn(e)):void 0;u===n&&i===c||(r=(n=u).copy()).on(s,i=c),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,a=n+"";return function(){var o=ft(this,t);return o===a?null:o===r?i:i=e(r=o,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function a(){var a=e.apply(this,arguments);return a!==i&&(r=(i=a)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,a,n)),r}return a._value=e,a}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Tn(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=Mn(this.node(),n).tween,a=0,o=i.length;a<o;++a)if((r=i[a]).name===t)return r.value;return null}return this.each((null==e?Nn:An)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?On:Hn)(e,t)):Mn(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?jn:Fn)(e,t)):Mn(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){xn(this,t).ease=e}}(e,t)):Mn(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;xn(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},l={value:function(){0===--i&&a()}};n.each(function(){var n=xn(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(l)),n.on=e}),0===i&&a()})},[Symbol.iterator]:Vn[Symbol.iterator]};var Xn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Wn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}qt.prototype.interrupt=function(t){return this.each(function(){kn(this,t)})},qt.prototype.transition=function(t){var e,n;t instanceof In?(e=t._id,t=t._name):(e=Bn(),(n=Xn).time=cn(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o,s=r[a],l=s.length,u=0;u<l;++u)(o=s[u])&&bn(o,t,e,u,s,n||Wn(o,e));return new In(r,this._parents,t,e)};var Zn=t=>()=>t;function Gn(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function Kn(t){t.preventDefault(),t.stopImmediatePropagation()}var Qn={name:"drag"},Jn={name:"space"},tr={name:"handle"},er={name:"center"};const{abs:nr,max:rr,min:ir}=Math;function ar(t){return[+t[0],+t[1]]}function or(t){return[ar(t[0]),ar(t[1])]}var sr={name:"x",handles:["w","e"].map(_r),input:function(t,e){return null==t?null:[[+t[0],e[0][1]],[+t[1],e[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},lr={name:"y",handles:["n","s"].map(_r),input:function(t,e){return null==t?null:[[e[0][0],+t[0]],[e[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},ur={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(_r),input:function(t){return null==t?null:or(t)},output:function(t){return t}},cr={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},hr={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},fr={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},dr={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},pr={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function _r(t){return{type:t}}function gr(t){return!t.ctrlKey&&!t.button}function mr(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function vr(){return navigator.maxTouchPoints||"ontouchstart"in this}function yr(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function br(){return function(t){var e,n=mr,r=gr,i=vr,a=!0,o=z("start","brush","end"),s=6;function l(e){var n=e.property("__brush",_).selectAll(".overlay").data([_r("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",cr.overlay).merge(n).each(function(){var t=yr(this).extent;It(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])}),e.selectAll(".selection").data([_r("selection")]).enter().append("rect").attr("class","selection").attr("cursor",cr.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=e.selectAll(".handle").data(t.handles,function(t){return t.type});r.exit().remove(),r.enter().append("rect").attr("class",function(t){return"handle handle--"+t.type}).attr("cursor",function(t){return cr[t.type]}),e.each(u).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",f).filter(i).on("touchstart.brush",f).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function u(){var t=It(this),e=yr(this).selection;e?(t.selectAll(".selection").style("display",null).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1]),t.selectAll(".handle").style("display",null).attr("x",function(t){return"e"===t.type[t.type.length-1]?e[1][0]-s/2:e[0][0]-s/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-s/2:e[0][1]-s/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+s:s}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+s:s})):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function c(t,e,n){var r=t.__brush.emitter;return!r||n&&r.clean?new h(t,e,n):r}function h(t,e,n){this.that=t,this.args=e,this.state=t.__brush,this.active=0,this.clean=n}function f(n){if((!e||n.touches)&&r.apply(this,arguments)){var i,o,s,l,h,f,d,p,_,g,m,v=this,y=n.target.__data__.type,b="selection"===(a&&n.metaKey?y="overlay":y)?Qn:a&&n.altKey?er:tr,w=t===lr?null:dr[y],x=t===sr?null:pr[y],M=yr(v),k=M.extent,N=M.selection,A=k[0][0],T=k[0][1],z=k[1][0],S=k[1][1],E=0,C=0,$=w&&x&&a&&n.shiftKey,D=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=Bt(t,v)).point0=t.slice(),t.identifier=e,t});kn(v);var L=c(v,arguments,!0).beforestart();if("overlay"===y){N&&(_=!0);const e=[D[0],D[1]||D[0]];M.selection=N=[[i=t===lr?A:ir(e[0][0],e[1][0]),s=t===sr?T:ir(e[0][1],e[1][1])],[h=t===lr?z:rr(e[0][0],e[1][0]),d=t===sr?S:rr(e[0][1],e[1][1])]],D.length>1&&j(n)}else i=N[0][0],s=N[0][1],h=N[1][0],d=N[1][1];o=i,l=s,f=h,p=d;var U=It(v).attr("pointer-events","none"),P=U.selectAll(".overlay").attr("cursor",cr[y]);if(n.touches)L.moved=H,L.ended=F;else{var O=It(n.view).on("mousemove.brush",H,!0).on("mouseup.brush",F,!0);a&&O.on("keydown.brush",Y,!0).on("keyup.brush",R,!0),Wt(n.view)}u.call(v),L.start(n,b.name)}function H(t){for(const e of t.changedTouches||[t])for(const t of D)t.identifier===e.identifier&&(t.cur=Bt(e,v));if($&&!g&&!m&&1===D.length){const t=D[0];nr(t.cur[0]-t[0])>nr(t.cur[1]-t[1])?m=!0:g=!0}for(const t of D)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);_=!0,Kn(t),j(t)}function j(t){const e=D[0],n=e.point0;var r;switch(E=e[0]-n[0],C=e[1]-n[1],b){case Jn:case Qn:w&&(E=rr(A-i,ir(z-h,E)),o=i+E,f=h+E),x&&(C=rr(T-s,ir(S-d,C)),l=s+C,p=d+C);break;case tr:D[1]?(w&&(o=rr(A,ir(z,D[0][0])),f=rr(A,ir(z,D[1][0])),w=1),x&&(l=rr(T,ir(S,D[0][1])),p=rr(T,ir(S,D[1][1])),x=1)):(w<0?(E=rr(A-i,ir(z-i,E)),o=i+E,f=h):w>0&&(E=rr(A-h,ir(z-h,E)),o=i,f=h+E),x<0?(C=rr(T-s,ir(S-s,C)),l=s+C,p=d):x>0&&(C=rr(T-d,ir(S-d,C)),l=s,p=d+C));break;case er:w&&(o=rr(A,ir(z,i-E*w)),f=rr(A,ir(z,h+E*w))),x&&(l=rr(T,ir(S,s-C*x)),p=rr(T,ir(S,d+C*x)))}f<o&&(w*=-1,r=i,i=h,h=r,r=o,o=f,f=r,y in hr&&P.attr("cursor",cr[y=hr[y]])),p<l&&(x*=-1,r=s,s=d,d=r,r=l,l=p,p=r,y in fr&&P.attr("cursor",cr[y=fr[y]])),M.selection&&(N=M.selection),g&&(o=N[0][0],f=N[1][0]),m&&(l=N[0][1],p=N[1][1]),N[0][0]===o&&N[0][1]===l&&N[1][0]===f&&N[1][1]===p||(M.selection=[[o,l],[f,p]],u.call(v),L.brush(t,b.name))}function F(t){if(function(t){t.stopImmediatePropagation()}(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else Zt(t.view,_),O.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);U.attr("pointer-events","all"),P.attr("cursor",cr.overlay),M.selection&&(N=M.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(N)&&(M.selection=null,u.call(v)),L.end(t,b.name)}function Y(t){switch(t.keyCode){case 16:$=w&&x;break;case 18:b===tr&&(w&&(h=f-E*w,i=o+E*w),x&&(d=p-C*x,s=l+C*x),b=er,j(t));break;case 32:b!==tr&&b!==er||(w<0?h=f-E:w>0&&(i=o-E),x<0?d=p-C:x>0&&(s=l-C),b=Jn,P.attr("cursor",cr.selection),j(t));break;default:return}Kn(t)}function R(t){switch(t.keyCode){case 16:$&&(g=m=$=!1,j(t));break;case 18:b===er&&(w<0?h=f:w>0&&(i=o),x<0?d=p:x>0&&(s=l),b=tr,j(t));break;case 32:b===Jn&&(t.altKey?(w&&(h=f-E*w,i=o+E*w),x&&(d=p-C*x,s=l+C*x),b=er):(w<0?h=f:w>0&&(i=o),x<0?d=p:x>0&&(s=l),b=tr),P.attr("cursor",cr[y]),j(t));break;default:return}Kn(t)}}function d(t){c(this,arguments).moved(t)}function p(t){c(this,arguments).ended(t)}function _(){var e=this.__brush||{selection:null};return e.extent=or(n.apply(this,arguments)),e.dim=t,e}return l.move=function(e,n,r){e.tween?e.on("start.brush",function(t){c(this,arguments).beforestart().start(t)}).on("interrupt.brush end.brush",function(t){c(this,arguments).end(t)}).tween("brush",function(){var e=this,r=e.__brush,i=c(e,arguments),a=r.selection,o=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),s=Re(a,o);function l(t){r.selection=1===t&&null===o?null:s(t),u.call(e),i.brush()}return null!==a&&null!==o?l:l(1)}):e.each(function(){var e=this,i=arguments,a=e.__brush,o=t.input("function"==typeof n?n.apply(e,i):n,a.extent),s=c(e,i).beforestart();kn(e),a.selection=null===o?null:o,u.call(e),s.start(r).brush(r).end(r)})},l.clear=function(t,e){l.move(t,null,e)},h.prototype={beforestart:function(){return 1===++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(t,e){return this.starting?(this.starting=!1,this.emit("start",t,e)):this.emit("brush",t),this},brush:function(t,e){return this.emit("brush",t,e),this},end:function(t,e){return 0===--this.active&&(delete this.state.emitter,this.emit("end",t,e)),this},emit:function(e,n,r){var i=It(this.that).datum();o.call(e,this.that,new Gn(e,{sourceEvent:n,target:l,selection:t.output(this.state.selection),mode:r,dispatch:o}),i)}},l.extent=function(t){return arguments.length?(n="function"==typeof t?t:Zn(or(t)),l):n},l.filter=function(t){return arguments.length?(r="function"==typeof t?t:Zn(!!t),l):r},l.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Zn(!!t),l):i},l.handleSize=function(t){return arguments.length?(s=+t,l):s},l.keyModifiers=function(t){return arguments.length?(a=!!t,l):a},l.on=function(){var t=o.on.apply(o,arguments);return t===o?l:t},l}(ur)}const wr=Math.PI,xr=2*wr,Mr=1e-6,kr=xr-Mr;function Nr(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class Ar{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?Nr:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Nr;const n=10**e;return function(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=Math.round(arguments[e]*n)/n+t[e]}}(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,n,r){this._append`Q${+t},${+e},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(t,e,n,r,i,a){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(t,e,n,r,i){if(t=+t,e=+e,n=+n,r=+r,(i=+i)<0)throw new Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-t,l=r-e,u=a-t,c=o-e,h=u*u+c*c;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(h>Mr)if(Math.abs(c*s-l*u)>Mr&&i){let f=n-a,d=r-o,p=s*s+l*l,_=f*f+d*d,g=Math.sqrt(p),m=Math.sqrt(h),v=i*Math.tan((wr-Math.acos((p+h-_)/(2*g*m)))/2),y=v/m,b=v/g;Math.abs(y-1)>Mr&&this._append`L${t+y*u},${e+y*c}`,this._append`A${i},${i},0,0,${+(c*f>u*d)},${this._x1=t+b*s},${this._y1=e+b*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,a){if(t=+t,e=+e,a=!!a,(n=+n)<0)throw new Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),l=t+o,u=e+s,c=1^a,h=a?r-i:i-r;null===this._x1?this._append`M${l},${u}`:(Math.abs(this._x1-l)>Mr||Math.abs(this._y1-u)>Mr)&&this._append`L${l},${u}`,n&&(h<0&&(h=h%xr+xr),h>kr?this._append`A${n},${n},0,1,${c},${t-o},${e-s}A${n},${n},0,1,${c},${this._x1=l},${this._y1=u}`:h>Mr&&this._append`A${n},${n},0,${+(h>=wr)},${c},${this._x1=t+n*Math.cos(i)},${this._y1=e+n*Math.sin(i)}`)}rect(t,e,n,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}}function Tr(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function zr(t){return(t=Tr(Math.abs(t)))?t[1]:NaN}var Sr,Er=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Cr(t){if(!(e=Er.exec(t)))throw new Error("invalid format: "+t);var e;return new $r({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function $r(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Dr(t,e){var n=Tr(t,e);if(!n)return t+"";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")}Cr.prototype=$r.prototype,$r.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Lr={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Dr(100*t,e),r:Dr,s:function(t,e){var n=Tr(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(Sr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Tr(t,Math.max(0,e+a-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Ur(t){return t}var Pr,Or,Hr,jr=Array.prototype.map,Fr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Yr(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Ur:(e=jr.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,a=[],o=0,s=e[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",a=void 0===t.currency?"":t.currency[1]+"",o=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?Ur:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(jr.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",u=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=Cr(t)).fill,n=t.align,h=t.sign,f=t.symbol,d=t.zero,p=t.width,_=t.comma,g=t.precision,m=t.trim,v=t.type;"n"===v?(_=!0,v="g"):Lr[v]||(void 0===g&&(g=12),m=!0,v="g"),(d||"0"===e&&"="===n)&&(d=!0,e="0",n="=");var y="$"===f?i:"#"===f&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",b="$"===f?a:/[%p]/.test(v)?l:"",w=Lr[v],x=/[defgprs%]/.test(v);function M(t){var i,a,l,f=y,M=b;if("c"===v)M=w(t)+M,t="";else{var k=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:w(Math.abs(t),g),m&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r)switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),k&&0===+t&&"+"!==h&&(k=!1),f=(k?"("===h?h:u:"-"===h||"("===h?"":h)+f,M=("s"===v?Fr[8+Sr/3]:"")+M+(k&&"("===h?")":""),x)for(i=-1,a=t.length;++i<a;)if(48>(l=t.charCodeAt(i))||l>57){M=(46===l?o+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}_&&!d&&(t=r(t,1/0));var N=f.length+t.length+M.length,A=N<p?new Array(p-N+1).join(e):"";switch(_&&d&&(t=r(A+t,A.length?p-M.length:1/0),A=""),n){case"<":t=f+t+M+A;break;case"=":t=f+A+t+M;break;case"^":t=A.slice(0,N=A.length>>1)+f+t+M+A.slice(N);break;default:t=A+f+t+M}return s(t)}return g=void 0===g?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:h,formatPrefix:function(t,e){var n=h(((t=Cr(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(zr(e)/3))),i=Math.pow(10,-r),a=Fr[8+r/3];return function(t){return n(i*t)+a}}}}function Rr(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function qr(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Br)):void 0===e&&(e=Ir);for(var n,r,i,a,o,s=new Wr(t),l=[s];n=l.pop();)if((i=e(n.data))&&(o=(i=Array.from(i)).length))for(n.children=i,a=o-1;a>=0;--a)l.push(r=i[a]=new Wr(i[a])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(Xr)}function Ir(t){return t.children}function Br(t){return Array.isArray(t)?t[1]:null}function Vr(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Xr(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Wr(t){this.data=t,this.depth=this.height=0,this.parent=null}function Zr(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}function Gr(t){return+t}Pr=Yr({thousands:",",grouping:[3],currency:["$",""]}),Or=Pr.format,Hr=Pr.formatPrefix,Wr.prototype=qr.prototype={constructor:Wr,count:function(){return this.eachAfter(Rr)},each:function(t,e){let n=-1;for(const r of this)t.call(e,r,++n,this);return this},eachAfter:function(t,e){for(var n,r,i,a=this,o=[a],s=[],l=-1;a=o.pop();)if(s.push(a),n=a.children)for(r=0,i=n.length;r<i;++r)o.push(n[r]);for(;a=s.pop();)t.call(e,a,++l,this);return this},eachBefore:function(t,e){for(var n,r,i=this,a=[i],o=-1;i=a.pop();)if(t.call(e,i,++o,this),n=i.children)for(r=n.length-1;r>=0;--r)a.push(n[r]);return this},find:function(t,e){let n=-1;for(const r of this)if(t.call(e,r,++n,this))return r},sum:function(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n})},sort:function(t){return this.eachBefore(function(e){e.children&&e.children.sort(t)})},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore(function(e){e.children||t.push(e)}),t},links:function(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n})}),e},copy:function(){return qr(this).eachBefore(Vr)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,a=[i];do{for(t=a.reverse(),a=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)a.push(e[n])}while(a.length)}};var Kr=[0,1];function Qr(t){return t}function Jr(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function ti(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=Jr(i,r),a=n(o,a)):(r=Jr(r,i),a=n(a,o)),function(t){return a(r(t))}}function ei(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=Jr(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(e){var n=d(t,e,1,r)-1;return a[n](i[n](e))}}function ni(){var t,e,n,r,i,a,o=Kr,s=Kr,l=Re,u=Qr;function c(){var t,e,n,l=Math.min(o.length,s.length);return u!==Qr&&(t=o[0],e=o[l-1],t>e&&(n=t,t=e,e=n),u=function(n){return Math.max(t,Math.min(e,n))}),r=l>2?ei:ti,i=a=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(o.map(t),s,l)))(t(u(e)))}return h.invert=function(n){return u(e((a||(a=r(s,o.map(t),Oe)))(n)))},h.domain=function(t){return arguments.length?(o=Array.from(t,Gr),c()):o.slice()},h.range=function(t){return arguments.length?(s=Array.from(t),c()):s.slice()},h.rangeRound=function(t){return s=Array.from(t),l=qe,c()},h.clamp=function(t){return arguments.length?(u=!!t||Qr,c()):u!==Qr},h.interpolate=function(t){return arguments.length?(l=t,c()):l},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,c()}}function ri(t,e,n,r){var i,a=function(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?v(e,t,n):v(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}(t,e,n);switch((r=Cr(null==r?",f":r)).type){case"s":var o=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=function(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(zr(e)/3)))-zr(Math.abs(t)))}(a,o))||(r.precision=i),Hr(r,o);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=function(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,zr(e)-zr(t))+1}(a,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=function(t){return Math.max(0,-zr(Math.abs(t)))}(a))||(r.precision=i-2*("%"===r.type))}return Or(r)}function ii(t){var e=t.domain;return t.ticks=function(t){var n=e();return function(t,e,n){if(!((n=+n)>0))return[];if((t=+t)===(e=+e))return[t];const r=e<t,[i,a,o]=r?m(e,t,n):m(t,e,n);if(!(a>=i))return[];const s=a-i+1,l=new Array(s);if(r)if(o<0)for(let t=0;t<s;++t)l[t]=(a-t)/-o;else for(let t=0;t<s;++t)l[t]=(a-t)*o;else if(o<0)for(let t=0;t<s;++t)l[t]=(i+t)/-o;else for(let t=0;t<s;++t)l[t]=(i+t)*o;return l}(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return ri(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,a=e(),o=0,s=a.length-1,l=a[o],u=a[s],c=10;for(u<l&&(i=l,l=u,u=i,i=o,o=s,s=i);c-- >0;){if((i=v(l,u,n))===r)return a[o]=l,a[s]=u,e(a);if(i>0)l=Math.floor(l/i)*i,u=Math.ceil(u/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,u=Math.floor(u*i)/i}r=i}return t},t}function ai(){var t=ni()(Qr,Qr);return t.copy=function(){return e=t,ai().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},Zr.apply(t,arguments),ii(t)}const oi=new Date,si=new Date;function li(t,e,n,r){function i(e){return t(e=0===arguments.length?new Date:new Date(+e)),e}return i.floor=e=>(t(e=new Date(+e)),e),i.ceil=n=>(t(n=new Date(n-1)),e(n,1),t(n),n),i.round=t=>{const e=i(t),n=i.ceil(t);return t-e<n-t?e:n},i.offset=(t,n)=>(e(t=new Date(+t),null==n?1:Math.floor(n)),t),i.range=(n,r,a)=>{const o=[];if(n=i.ceil(n),a=null==a?1:Math.floor(a),!(n<r&&a>0))return o;let s;do{o.push(s=new Date(+n)),e(n,a),t(n)}while(s<n&&n<r);return o},i.filter=n=>li(e=>{if(e>=e)for(;t(e),!n(e);)e.setTime(e-1)},(t,r)=>{if(t>=t)if(r<0)for(;++r<=0;)for(;e(t,-1),!n(t););else for(;--r>=0;)for(;e(t,1),!n(t););}),n&&(i.count=(e,r)=>(oi.setTime(+e),si.setTime(+r),t(oi),t(si),Math.floor(n(oi,si))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?e=>r(e)%t===0:e=>i.count(0,e)%t===0):i:null)),i}const ui=6e4,ci=864e5,hi=6048e5,fi=li(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ui)/ci,t=>t.getDate()-1);fi.range;const di=li(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ci,t=>t.getUTCDate()-1);di.range;const pi=li(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ci,t=>Math.floor(t/ci));function _i(t){return li(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+7*e)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ui)/hi)}pi.range;const gi=_i(0),mi=_i(1),vi=_i(2),yi=_i(3),bi=_i(4),wi=_i(5),xi=_i(6);function Mi(t){return li(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+7*e)},(t,e)=>(e-t)/hi)}gi.range,mi.range,vi.range,yi.range,bi.range,wi.range,xi.range;const ki=Mi(0),Ni=Mi(1),Ai=Mi(2),Ti=Mi(3),zi=Mi(4),Si=Mi(5),Ei=Mi(6);ki.range,Ni.range,Ai.range,Ti.range,zi.range,Si.range,Ei.range;const Ci=li(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Ci.every=t=>isFinite(t=Math.floor(t))&&t>0?li(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)}):null,Ci.range;const $i=li(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());function Di(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function Li(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Ui(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}$i.every=t=>isFinite(t=Math.floor(t))&&t>0?li(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)}):null,$i.range;var Pi,Oi,Hi={"-":"",_:" ",0:"0"},ji=/^\s*\d+/,Fi=/^%/,Yi=/[\\^$*+?|[\]().{}]/g;function Ri(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function qi(t){return t.replace(Yi,"\\$&")}function Ii(t){return new RegExp("^(?:"+t.map(qi).join("|")+")","i")}function Bi(t){return new Map(t.map((t,e)=>[t.toLowerCase(),e]))}function Vi(t,e,n){var r=ji.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Xi(t,e,n){var r=ji.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Wi(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Zi(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Gi(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Ki(t,e,n){var r=ji.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Qi(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Ji(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function ta(t,e,n){var r=ji.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function ea(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function na(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function ra(t,e,n){var r=ji.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function ia(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function aa(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function oa(t,e,n){var r=ji.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function sa(t,e,n){var r=ji.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function la(t,e,n){var r=ji.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ua(t,e,n){var r=Fi.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ca(t,e,n){var r=ji.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function ha(t,e,n){var r=ji.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function fa(t,e){return Ri(t.getDate(),e,2)}function da(t,e){return Ri(t.getHours(),e,2)}function pa(t,e){return Ri(t.getHours()%12||12,e,2)}function _a(t,e){return Ri(1+fi.count(Ci(t),t),e,3)}function ga(t,e){return Ri(t.getMilliseconds(),e,3)}function ma(t,e){return ga(t,e)+"000"}function va(t,e){return Ri(t.getMonth()+1,e,2)}function ya(t,e){return Ri(t.getMinutes(),e,2)}function ba(t,e){return Ri(t.getSeconds(),e,2)}function wa(t){var e=t.getDay();return 0===e?7:e}function xa(t,e){return Ri(gi.count(Ci(t)-1,t),e,2)}function Ma(t){var e=t.getDay();return e>=4||0===e?bi(t):bi.ceil(t)}function ka(t,e){return t=Ma(t),Ri(bi.count(Ci(t),t)+(4===Ci(t).getDay()),e,2)}function Na(t){return t.getDay()}function Aa(t,e){return Ri(mi.count(Ci(t)-1,t),e,2)}function Ta(t,e){return Ri(t.getFullYear()%100,e,2)}function za(t,e){return Ri((t=Ma(t)).getFullYear()%100,e,2)}function Sa(t,e){return Ri(t.getFullYear()%1e4,e,4)}function Ea(t,e){var n=t.getDay();return Ri((t=n>=4||0===n?bi(t):bi.ceil(t)).getFullYear()%1e4,e,4)}function Ca(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Ri(e/60|0,"0",2)+Ri(e%60,"0",2)}function $a(t,e){return Ri(t.getUTCDate(),e,2)}function Da(t,e){return Ri(t.getUTCHours(),e,2)}function La(t,e){return Ri(t.getUTCHours()%12||12,e,2)}function Ua(t,e){return Ri(1+di.count($i(t),t),e,3)}function Pa(t,e){return Ri(t.getUTCMilliseconds(),e,3)}function Oa(t,e){return Pa(t,e)+"000"}function Ha(t,e){return Ri(t.getUTCMonth()+1,e,2)}function ja(t,e){return Ri(t.getUTCMinutes(),e,2)}function Fa(t,e){return Ri(t.getUTCSeconds(),e,2)}function Ya(t){var e=t.getUTCDay();return 0===e?7:e}function Ra(t,e){return Ri(ki.count($i(t)-1,t),e,2)}function qa(t){var e=t.getUTCDay();return e>=4||0===e?zi(t):zi.ceil(t)}function Ia(t,e){return t=qa(t),Ri(zi.count($i(t),t)+(4===$i(t).getUTCDay()),e,2)}function Ba(t){return t.getUTCDay()}function Va(t,e){return Ri(Ni.count($i(t)-1,t),e,2)}function Xa(t,e){return Ri(t.getUTCFullYear()%100,e,2)}function Wa(t,e){return Ri((t=qa(t)).getUTCFullYear()%100,e,2)}function Za(t,e){return Ri(t.getUTCFullYear()%1e4,e,4)}function Ga(t,e){var n=t.getUTCDay();return Ri((t=n>=4||0===n?zi(t):zi.ceil(t)).getUTCFullYear()%1e4,e,4)}function Ka(){return"+0000"}function Qa(){return"%"}function Ja(t){return+t}function to(t){return Math.floor(+t/1e3)}function eo(t){return function(){return t}}function no(t){this._context=t}function ro(t){return new no(t)}function io(t){return t[0]}function ao(t){return t[1]}function oo(t,e){var n=eo(!0),r=null,i=ro,a=null,o=function(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(null==n)e=null;else{const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);e=t}return t},()=>new Ar(e)}(s);function s(s){var l,u,c,h=(s=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(s)).length,f=!1;for(null==r&&(a=i(c=o())),l=0;l<=h;++l)!(l<h&&n(u=s[l],l,s))===f&&((f=!f)?a.lineStart():a.lineEnd()),f&&a.point(+t(u,l,s),+e(u,l,s));if(c)return a=null,c+""||null}return t="function"==typeof t?t:void 0===t?io:eo(t),e="function"==typeof e?e:void 0===e?ao:eo(e),s.x=function(e){return arguments.length?(t="function"==typeof e?e:eo(+e),s):t},s.y=function(t){return arguments.length?(e="function"==typeof t?t:eo(+t),s):e},s.defined=function(t){return arguments.length?(n="function"==typeof t?t:eo(!!t),s):n},s.curve=function(t){return arguments.length?(i=t,null!=r&&(a=i(r)),s):i},s.context=function(t){return arguments.length?(null==t?r=a=null:a=i(r=t),s):r},s}function so(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function lo(t){this._context=t}function uo(t){return new lo(t)}function co(t,e){this._context=t,this._t=e}!function(t){Pi=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,s=t.months,l=t.shortMonths,u=Ii(i),c=Bi(i),h=Ii(a),f=Bi(a),d=Ii(o),p=Bi(o),_=Ii(s),g=Bi(s),m=Ii(l),v=Bi(l),y={a:function(t){return o[t.getDay()]},A:function(t){return a[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return s[t.getMonth()]},c:null,d:fa,e:fa,f:ma,g:za,G:Ea,H:da,I:pa,j:_a,L:ga,m:va,M:ya,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Ja,s:to,S:ba,u:wa,U:xa,V:ka,w:Na,W:Aa,x:null,X:null,y:Ta,Y:Sa,Z:Ca,"%":Qa},b={a:function(t){return o[t.getUTCDay()]},A:function(t){return a[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return s[t.getUTCMonth()]},c:null,d:$a,e:$a,f:Oa,g:Wa,G:Ga,H:Da,I:La,j:Ua,L:Pa,m:Ha,M:ja,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Ja,s:to,S:Fa,u:Ya,U:Ra,V:Ia,w:Ba,W:Va,x:null,X:null,y:Xa,Y:Za,Z:Ka,"%":Qa},w={a:function(t,e,n){var r=d.exec(e.slice(n));return r?(t.w=p.get(r[0].toLowerCase()),n+r[0].length):-1},A:function(t,e,n){var r=h.exec(e.slice(n));return r?(t.w=f.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=m.exec(e.slice(n));return r?(t.m=v.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=_.exec(e.slice(n));return r?(t.m=g.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return k(t,e,n,r)},d:na,e:na,f:la,g:Qi,G:Ki,H:ia,I:ia,j:ra,L:sa,m:ea,M:aa,p:function(t,e,n){var r=u.exec(e.slice(n));return r?(t.p=c.get(r[0].toLowerCase()),n+r[0].length):-1},q:ta,Q:ca,s:ha,S:oa,u:Xi,U:Wi,V:Zi,w:Vi,W:Gi,x:function(t,e,r){return k(t,n,e,r)},X:function(t,e,n){return k(t,r,e,n)},y:Qi,Y:Ki,Z:Ji,"%":ua};function x(t,e){return function(n){var r,i,a,o=[],s=-1,l=0,u=t.length;for(n instanceof Date||(n=new Date(+n));++s<u;)37===t.charCodeAt(s)&&(o.push(t.slice(l,s)),null!=(i=Hi[r=t.charAt(++s)])?r=t.charAt(++s):i="e"===r?" ":"0",(a=e[r])&&(r=a(n,i)),o.push(r),l=s+1);return o.push(t.slice(l,s)),o.join("")}}function M(t,e){return function(n){var r,i,a=Ui(1900,void 0,1);if(k(a,t,n+="",0)!=n.length)return null;if("Q"in a)return new Date(a.Q);if("s"in a)return new Date(1e3*a.s+("L"in a?a.L:0));if(e&&!("Z"in a)&&(a.Z=0),"p"in a&&(a.H=a.H%12+12*a.p),void 0===a.m&&(a.m="q"in a?a.q:0),"V"in a){if(a.V<1||a.V>53)return null;"w"in a||(a.w=1),"Z"in a?(i=(r=Li(Ui(a.y,0,1))).getUTCDay(),r=i>4||0===i?Ni.ceil(r):Ni(r),r=di.offset(r,7*(a.V-1)),a.y=r.getUTCFullYear(),a.m=r.getUTCMonth(),a.d=r.getUTCDate()+(a.w+6)%7):(i=(r=Di(Ui(a.y,0,1))).getDay(),r=i>4||0===i?mi.ceil(r):mi(r),r=fi.offset(r,7*(a.V-1)),a.y=r.getFullYear(),a.m=r.getMonth(),a.d=r.getDate()+(a.w+6)%7)}else("W"in a||"U"in a)&&("w"in a||(a.w="u"in a?a.u%7:"W"in a?1:0),i="Z"in a?Li(Ui(a.y,0,1)).getUTCDay():Di(Ui(a.y,0,1)).getDay(),a.m=0,a.d="W"in a?(a.w+6)%7+7*a.W-(i+5)%7:a.w+7*a.U-(i+6)%7);return"Z"in a?(a.H+=a.Z/100|0,a.M+=a.Z%100,Li(a)):Di(a)}}function k(t,e,n,r){for(var i,a,o=0,s=e.length,l=n.length;o<s;){if(r>=l)return-1;if(37===(i=e.charCodeAt(o++))){if(i=e.charAt(o++),!(a=w[i in Hi?e.charAt(o++):i])||(r=a(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return y.x=x(n,y),y.X=x(r,y),y.c=x(e,y),b.x=x(n,b),b.X=x(r,b),b.c=x(e,b),{format:function(t){var e=x(t+="",y);return e.toString=function(){return t},e},parse:function(t){var e=M(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=x(t+="",b);return e.toString=function(){return t},e},utcParse:function(t){var e=M(t+="",!0);return e.toString=function(){return t},e}}}(t),Pi.format,Oi=Pi.parse,Pi.utcFormat,Pi.utcParse}({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"]}),no.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}},lo.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:so(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:so(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},co.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}};var ho=t=>()=>t;function fo(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function po(t,e,n){this.k=t,this.x=e,this.y=n}po.prototype={constructor:po,scale:function(t){return 1===t?this:new po(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new po(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var _o=new po(1,0,0);function go(t){t.stopImmediatePropagation()}function mo(t){t.preventDefault(),t.stopImmediatePropagation()}function vo(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function yo(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function bo(){return this.__zoom||_o}function wo(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function xo(){return navigator.maxTouchPoints||"ontouchstart"in this}function Mo(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],a=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}po.prototype;function ko(t){return!o.has(t,"children")}function No(t,e,n){let r=[];return function i(a){ko(a)?e&&a!=t&&r.push(a):(n&&a!=t&&r.push(a),a.children.forEach(i))}(t),r}var Ao=Object.freeze({__proto__:null,graftANode:function(t,e,n,r){let i=this.nodes.descendants();if(t.parent){if(i.indexOf(t)>=0){let i=t.parent.children.indexOf(t),a={name:n,parent:t.parent,attribute:r?r[2]:null,original_child_order:t.original_child_order},o={name:e,parent:a,attribute:r?r[1]:null,original_child_order:2};a.children=[t,o],t.parent.children[i]=a,t.parent=a,t.attribute=r?r[0]:null,t.original_child_order=1}}return this},addChild:function(t,e){return t.children?t.children.push(e):t.children=[e],t},createNode:function(t,e){return{data:{name:t,attribute:e?e[1]:null},parent:""}},deleteANode:function(t){let e=this.nodes.descendants();if("number"!=typeof t)return this.deleteANode(e.indexOf(t));if(t>0&&t<e.length){let n=e[t];if(n.parent){let r=n.parent.children.indexOf(n);r>=0&&(e.splice(t,1),n.children&&n.children.forEach(function(t){t.original_child_order=n.parent.children.length,n.parent.children.push(t),t.parent=n.parent}),n.parent.children.length>2?n.parent.children.splice(r,1):n.parent.parent?(n.parent.parent.children[n.parent.parent.children.indexOf(n.parent)]=n.parent.children[1-r],n.parent.children[1-r].parent=n.parent.parent,e.splice(e.indexOf(n.parent),1)):(e.splice(0,1),e.parent=null,delete e.data.attribute,delete e.data.annotation,delete e.data.original_child_order,e.name="root",e.data.name="root"))}}return this},getTips:function(){return o.filter(this.nodes.descendants(),t=>!o.has(t,"children"))},getInternals:function(){return o.filter(this.nodes.descendants(),t=>o.has(t,"children"))},getRootNode:function(){return this.nodes},getNodes:function(){return this.nodes},getNodeByName:function(t){return o.filter(this.nodes.descendants(),e=>e.data.name==t)[0]},assignAttributes:function(t){o.each(this.nodes.descendants(),function(e){e.data&&e.data.name in t&&(e.annotations=t[e.data.name])})},isLeafNode:ko,updateKeyName:function(t,e){return this.nodes.each(function(n){t in n&&(e&&(n[e]=n[t]),delete n[t])}),this},clearInternalNodes:function(t){t||this.nodes.each(t=>{ko(t)||(t[this.selection_attribute_name]=!1,t.data.traits||(t.data.traits={}),t.data.traits[this.selection_attribute_name]=t[this.selection_attribute_name])})},selectAllDescendants:No});function To(t,e={}){const n=/^-?\d+(\.\d+)?$/;let r=e.left_delimiter||"{",i=e.right_delimiter||"}",a=[];function o(){let t=a[a.length-1];"children"in t||(t.children=[]),a.push({name:null}),t.children.push(a[a.length-1]),a[a.length-1].original_child_order=t.children.length}function s(){let t=a.pop();t.name=c,"children"in t?t.bootstrap_values=c:t.name=c,t.attribute=h,"["==r&&f.includes("&&NHX")?f.split(":").slice(1).forEach(e=>{const[r,i]=e.split("=");t[r]=n.test(i)?+i:i}):t.annotation=f,c="",h="",f=""}function l(e){return{json:null,error:"Unexpected '"+t[e]+"' in '"+t.substring(e-20,e+1)+"[ERROR HERE]"+t.substring(e+1,e+20)+"'"}}let u=0,c="",h="",f="",d=null,p={"'":1,'"':1},_={name:"root"};a.push(_);for(var g=/\s/,m=0;m<t.length;m++)try{var v=t[m];switch(u){case 0:"("==v&&(o(),u=1);break;case 1:case 3:if(":"==v)u=3;else if(","==v||")"==v)try{s(),u=1,","==v&&o()}catch(t){return l(m)}else if("("==v){if(c.length>0)return l(m);o()}else{if(v in p){if(1==u&&0===c.length&&0===h.length&&0===f.length){u=2,d=v;continue}return l(m)}if(v==r){if(f.length)return l(m);u=4}else if(3==u)h+=v;else{if(g.test(v))continue;if(";"==v){m=t.length;break}c+=v}}break;case 2:if(v==d){if(m<t.length-1&&t[m+1]==d){m++,c+=d;continue}d=0,u=1;continue}c+=v;break;case 4:if(v==i)u=3;else{if(v==r)return l(m);f+=v}}}catch(t){return l(m)}return 1!=a.length?l(t.length-1):{json:_,error:null}}function zo(t,e){let n=this;t||(t=t=>"");let r=[];return t=t||"",function e(i){if(i.notshown)return;if(ko(i)||(r.push("("),i.children.forEach(function(t,n){n&&r.push(","),e(t)}),r.push(")")),"root"!==i.data.name){const t=i.data.name.replaceAll("'","''");/\W/.test(t)?r.push("'"+t+"'"):r.push(t)}r.push(t(i));let a=n.branch_length_accessor(i);void 0!==a&&r.push(":"+a)}(e||this.nodes),r.join("")+";"}function So(t){let e=t,n=e.toUpperCase().indexOf("BEGIN DATA;"),r=e.slice(n);if(r.length<2)return"";n=r.toUpperCase().indexOf("END;");let i=r.slice(0,n);r=o.map(i.split(";"),t=>t.trim());let a=o.filter(r,t=>t.toUpperCase().startsWith("DIMENSION"));a=a[0].split(" "),a=o.object(o.map(o.rest(a),t=>t.split("=")));let s=o.filter(r,t=>t.toUpperCase().startsWith("FORMAT"));s=s[0].split(" "),s=o.object(o.map(o.rest(s),t=>t.split("="))),s.symbols=o.reject(s.symbols.split(""),t=>'"'==t);let l=o.filter(r,t=>t.toUpperCase().startsWith("MATRIX"));return l=l[0].split("\n"),l=o.object(o.map(o.rest(l),t=>o.compact(t.split(" ")))),l=o.mapObject(l,(t,e)=>"?"==t?s.symbols:Array(t)),{dimensions:a,format:s,matrix:l}}function Eo(t,e,n){o.each(t.getTips(),t=>{t.data.test=n.matrix[t.data.name]})}function Co(t){let e=t,n=e.toUpperCase().indexOf("BEGIN TREES;"),r=e.slice(n);if(r.length<2)return"";n=r.toUpperCase().indexOf("END;");let i=r.slice(0,n).split("\n");return i=o.filter(i,t=>t.trim().toUpperCase().startsWith("TREE")),To(i[0])}var $o=Object.freeze({__proto__:null,parseAnnotations:So,loadAnnotations:Eo,default:Co});function Do(t){var e={};if(1==t.nodeType){if(t.attributes.length>0){e["@attributes"]={};for(var n=0;n<t.attributes.length;n++){var r=t.attributes.item(n);e["@attributes"][r.nodeName]=r.nodeValue}}}else 3==t.nodeType&&(e=t.nodeValue);if(t.hasChildNodes()&&1===t.childNodes.length&&3===t.childNodes[0].nodeType)e=t.childNodes[0].nodeValue;else if(t.hasChildNodes())for(var i=0;i<t.childNodes.length;i++){var a=t.childNodes.item(i),o=a.nodeName;if(void 0===e[o])e[o]=Do(a);else{if(void 0===e[o].push){var s=e[o];e[o]=[],e[o].push(s)}e[o].push(Do(a))}}return e}var Lo=function(t,e){var n;if("string"==typeof t)if(DOMParser){t=(new DOMParser).parseFromString(t,"text/xml")}else{t=(new r.XMLParser).parse(t)}var i=(t=Do(t)).phyloxml.phylogeny;return Array.isArray(i)&&(i=i[0],console.warn("PhyloXML files with multiple phylogenies are not currently supported. Only the first phylogeny will be loaded.")),(n=i.clade).name="root",function t(e,n){e.clade&&(Array.isArray(e.clade)||(e.clade=[e.clade]),e.clade.forEach(t),e.children=e.clade,delete e.clade),e.annotation=1,e.attribute="0.01",e.branch_length&&(e.attribute=e.branch_length),e.taxonomy&&(e.name=e.taxonomy.scientific_name),e.annotation=""}(n),{json:n,error:null}};var Uo={nexml:function(t,e){var r;return n.parseString(t,function(t,e){r=e["nex:nexml"].trees[0].tree.map(function(t){var e=t.node.map(t=>t.$),n=e.reduce(function(t,e){return e.edges=[],e.name=e.id,t[e.id]=e,t},{}),r=e.filter(t=>t.root),i=r>0?r[0].id:e[0].id;return n[i].name="root",t.edge.map(t=>t.$).forEach(function(t){n[t.source].edges.push(t)}),function t(e,r){if(e.edges){var i=o.pluck(e.edges,"target");e.children=o.values(o.pick(n,i)),e.children.forEach(function(t,n){t.attribute=e.edges[n].length||""}),e.children.forEach(t),e.annotation=""}}(n[i]),n[i]})}),r},phyloxml:Lo,nexus:Co,nwk:To,nhx:To,beast:function(t,e){e.left_delimiter="[",e.right_delimiter="]";const n=To(t,e);return function t(e){if(e.annotation){e.beast={};const t=e.annotation.split(/=|,|{|}/).filter(t=>t);for(var n=0;n<t.length;n+=2){let r=t[n].replace(/&|%/g,"");/[a-df-zA-DF-Z]+/.test(t[n+2])?e.beast[r]=+t[n+1]:(e.beast[r]=[+t[n+1],+t[n+2]],n++)}}e.annotation=void 0,e.children&&e.children.forEach(t)}(n.json),n}};function Po(t,e,n){let r,i,a,o=[t],s=[];for(;t=o.pop();)if((!n||!n(t))&&(s.push(t),r=t.children,r))for(i=0,a=r.length;i<a;++i)o.push(r[i]);for(;t=s.pop();)e(t);return t}function Oo(t,e,n){let r,i,a=[t];for(;t=a.pop();)if((!n||!n(t))&&(e(t),r=t.children,r))for(i=r.length-1;i>=0;--i)a.push(r[i]);return t}function Ho(t,e,n){let r,i,a,o,s=[t];do{for(r=s.reverse(),s=[];t=r.pop();)if((!n||!n(t))&&(e(t),i=t.children,i))for(a=0,o=i.length;a<o;++a)s.push(i[a])}while(s.length);return t}function jo(t){return Po(t,function(t){t.children&&(t.children[0].data.multiway_parent=t,t.children[1].data.multiway_parent=t.parent)}),s.map(t.descendants(),t=>{let e=t.data.multiway_parent,n="unknown";return e&&(n=e.data.name),{source:t.data.multiway_parent,target:t,name:n}})}function Fo(t,e){let n=t.data;if("attribute"in n&&n.attribute&&n.attribute.length){e>0&&(n.attribute=String(e));let t=parseFloat(n.attribute);if(!isNaN(t))return Math.max(0,t)}if("root"==n.name)return 0;console.warn("Undefined branch length at "+n.name+"!")}var Yo=Object.freeze({__proto__:null,reroot:function(t,e){if(!(t instanceof qr))throw new Error("node needs to be an instance of a d3.hierarchy node!");let n=this.nodes.copy();if(e=void 0!==e?e:.5,t.parent){var r=qr({name:"new_root"});r.children=[t.copy()],r.data.__mapped_bl=void 0,n.each(t=>{t.data.__mapped_bl=this.branch_length_accessor(t)}),this.setBranchLength(t=>t.data.__mapped_bl);let a=t,s=t.parent,l=o.noop(),u=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl*e;var i;if(l=s.data.__mapped_bl,s.data.__mapped_bl=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl-u,t.data.__mapped_bl=u,s.parent){for(r.children.push(s);s.parent;){i=s.children.indexOf(a),s.parent.parent?s.children.splice(i,1,s.parent):s.children.splice(i,1);let t=s.parent.data.__mapped_bl;void 0!==t&&(s.parent.data.__mapped_bl=l,l=t),a=s,s=s.parent}i=s.children.indexOf(a),s.children.splice(i,1)}else i=s.children.indexOf(a),s.children.splice(i,1),l=s.data.__mapped_bl,a=r;if(1==s.children.length)l&&(s.children[0].data.__mapped_bl+=l),a.children=a.children.concat(s.children);else{let e=new qr({name:"__reroot_top_clade",__mapped_bl:l});o.extendOwn(r.children[0],t),e.data.__mapped_bl=l,e.children=s.children.map(function(t){return t.parent=e,t}),e.parent=a,a.children.push(e)}}if(this.update(r),this.traverse_and_compute(t=>{o.each(t.children,e=>{e.parent=t})},"pre-order"),!o.isUndefined(this.display)){let t=this.display.options;It(this.display.container).select("svg").remove();let e=this.display.selection_attribute_name;delete this.display;let n=this.render(t);n.selectionLabel(e),n.update(),It(n.container).node().appendChild(n.show()),It(this.display.container).dispatch("reroot")}return this},rootpath:function(t,e){if(t=t||"attribute",e=e||"y_scaled","parent"in this){let n=parseFloat(this[t]);this[e]=this.parent[e]+(isNaN(n)?.1:n)}else this[e]=0;return this[e]},pathToRoot:function(t){let e=[];for(;t;)e.push(t),t=t.parent;return e}});function Ro(t){return t.y}function qo(t){return t.x}function Io(t,e,n){return{x:n+t*Math.sin(e),y:n+t*Math.cos(e)}}function Bo(t,e,n,r,i,a){t.radius=e*(t.radius+n),t.angle=2*Math.PI*t.x*i[0]/a[0];let o=Io(t.radius,t.angle,r);return t.x=o.x,t.y=o.y,t}function Vo(t,e){var n=Io(e[0].radius,e[0].angle,t),r=Io(e[0].radius,e[1].angle,t);return"M "+Ro(n)+","+qo(n)+" A "+e[0].radius+","+e[0].radius+" 0,0, "+(e[1].angle>e[0].angle?1:0)+" "+Ro(r)+","+qo(r)+" L "+Ro(e[1])+","+qo(e[1])}function Xo(t,e,n){var r=Io(t.target.radius+(t.source.radius-t.target.radius)*e,t.target.angle,n);return{x:Ro(r),y:qo(r)}}var Wo=oo().x(function(t){return Ro(t)}).y(function(t){return qo(t)}).curve(function(t){return new co(t,0)});function Zo(t,e){return{x:Ro(t.target)+(Ro(t.source)-Ro(t.target))*e,y:qo(t.target)}}function Go(t){return t.tag||!1}function Ko(t,e){return t[e]||!1}const Qo={"tree-container":"phylotree-container","tree-scale-bar":"tree-scale-bar",node:"node","internal-node":"internal-node","tagged-node":"node-tagged","selected-node":"node-selected","collapsed-node":"node-collapsed","root-node":"root-node",branch:"branch","selected-branch":"branch-selected","tagged-branch":"branch-tagged","tree-selection-brush":"tree-selection-brush","branch-tracer":"branch-tracer",clade:"clade",node_text:"phylotree-node-text"};function Jo(t={}){Object.keys(t).forEach(e=>{Qo[e]=t[e]})}function ts(t){return arguments.length?(ts="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):ts}var es={all:t=>!0,none:t=>!1,"all-leaf-nodes":t=>ko(t.target),"all-internal-nodes":t=>!ko(t.target)};var ns=Object.freeze({__proto__:null,css_classes:Qo,initializeCssClasses:Jo,internalNames:function(t){return arguments.length?(this.options["internal-names"]=t,this):this.options["internal-names"]},radial:function(t){return arguments.length?(this.options["is-radial"]=t,this):this.options["is-radial"]},alignTips:function(t){return arguments.length?(this.options["align-tips"]=t,this):this.options["align-tips"]},nodeBubbleSize:function(t){return this.options["draw-size-bubbles"]&&this.options["bubble-styler"]?this.options["bubble-styler"](t):this.options["draw-size-bubbles"]?this.relative_nodeSpan(t)*this.scales[0]*.25:0},shiftTip:function(t){return this.options["is-radial"]?[("end"==t.text_align?-1:1)*(this.radius_pad_for_bubbles-t.radius),0]:(this.options["right-to-left"],[this.right_most_leaf-t.screen_x,0])},layoutHandler:function(t){return arguments.length?(this.layout_listener_handler=t,this):this.layout_listener_handler},selectionLabel:function(t){return arguments.length?(this.selection_attribute_name=t,this.syncEdgeLabels(),this):this.selection_attribute_name},get nodeSpan(){return ts},predefined_selecters:es,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function rs(t){return!(t.hidden||t.notshown)}function is(t){return t.notshown}function as(t){return t.hasHiddenNodes||!1}function os(t){return t.collapsed||!1}function ss(t){return[t.node,t["internal-node"],t["collapsed-node"],t["tagged-node"],t["root-node"]].reduce(function(t,e,n,r){return t+"g."+e+(n<r.length-1?",":"")},"")}function ls(t){return ko(t=t.data)?t.name||"":this.showInternalName(t)?t.name:""}var us=Object.freeze({__proto__:null,shiftTip:function(t){return this.radial()?[("end"==t.text_align?-1:1)*(this.radius_pad_for_bubbles-t.radius),0]:(this.options["right-to-left"],[this.right_most_leaf-t.screen_x,0])},drawNode:function(t,e,n){t=It(t);var r=ko(e);r&&(t=t.attr("data-node-name",e.data.name));var i=t.selectAll("text").data([e]),a=t.selectAll("line");if(r||this.showInternalName(e)&&!os(e))if(i=i.enter().append("text").classed(this.css_classes.node_text,!0).merge(i).on("click",t=>{this.handle_node_click(e,t)}).attr("dy",t=>.33*this.shown_font_size).text(t=>this.options["show-labels"]?this._nodeLabel(t):"").style("font-size",t=>this.ensure_size_is_in_px(this.shown_font_size)),i=this.radial()?i.attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)+this.d3PhylotreeSvgTranslate(this.alignTips()?this.shiftTip(t):null)).attr("text-anchor",t=>t.text_align):i.attr("text-anchor","start").attr("transform",t=>"right-to-left"==this.options.layout?this.d3PhylotreeSvgTranslate([-20,0]):this.d3PhylotreeSvgTranslate(this.alignTips()?this.shiftTip(t):null)),this.alignTips()?(a=a.data([e]),n?a=a.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(a).attr("x1",t=>("end"==t.text_align?-1:1)*this.nodeBubbleSize(e)).attr("x2",0).attr("y1",0).attr("y2",0).attr("x2",t=>"right-to-left"==this.options.layout?t.screen_x:this.shiftTip(t)[0]).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)).attr("x2",t=>"right-to-left"==this.options.layout?t.screen_x:this.shiftTip(t)[0]).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle)):(a=a.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(a).attr("x1",t=>("end"==t.text_align?-1:1)*this.nodeBubbleSize(e)).attr("y2",0).attr("y1",0).attr("x2",t=>this.shiftTip(t)[0])).attr("transform",t=>this.d3PhylotreeSvgRotate(t.text_angle))):a.remove(),this.options["draw-size-bubbles"]){var o=this.nodeBubbleSize(e);t.selectAll("circle").data([o]).enter().append("circle").attr("r",function(t){return t}),this.shown_font_size>=5&&(i=i.attr("dx",t=>("end"==t.text_align?-1:1)*((this.alignTips()?0:o)+.33*this.shown_font_size)))}else this.shown_font_size>=5&&(i=i.attr("dx",t=>("end"==t.text_align?-1:1)*this.shown_font_size*.33));if(!r){let n=t.selectAll("circle").data([e]).enter().append("circle"),r=this.node_circle_size()(e);r>0?n.merge(n).attr("r",t=>Math.min(.75*this.shown_font_size,r)).on("click",t=>{this.handle_node_click(e,t)}):n.remove()}return this.node_styler&&this.node_styler(t,e),e},updateHasHiddenNodes:function(){let t=this.phylotree.nodes.descendants();for(let e=t.length-1;e>=0;e-=1)ko(t[e])?t[e].hasHiddenNodes=t[e].notshown:t[e].hasHiddenNodes=t[e].children.reduce(function(t,e){return e.notshown||t},!1);return this},showInternalName:function(t){const e=this.internalNames();return!!e&&("function"==typeof e?e(t):e)},nodeSpan:function(t){return arguments.length?(this.nodeSpan="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):this.nodeSpan},reclassNode:function(t){let e=Qo[ko(t)?"node":"internal-node"];return Go(t)&&(e+=" "+Qo["tagged-node"]),Ko(t,this.selection_attribute_name)&&(e+=" "+Qo["selected-node"]),t.parent||(e+=" "+Qo["root-node"]),(os(t)||as(t))&&(e+=" "+Qo["collapsed-node"]),e},nodeVisible:rs,nodeNotshown:is,hasHiddenNodes:as,isNodeCollapsed:os,nodeCssSelectors:ss,internalLabel:function(t,e){this.phylotree.clearInternalNodes(e);for(var n=this.phylotree.nodes.descendants().length-1;n>=0;n--){var r=this.phylotree.nodes.descendants()[n];ko(r)||Ko(r,this.selection_attribute_name)||(r[this.selection_attribute_name]=t(r.children))}this.modifySelection((t,e)=>(ko(t.target),t.target[this.selection_attribute_name]))},defNodeLabel:ls,nodeLabel:function(t){return arguments.length?(this._nodeLabel=t||ls,this.update(),this):this._nodeLabel}});function cs(t){return[t.clade].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var hs=Object.freeze({__proto__:null,cladeCssSelectors:cs,updateCollapsedClades:function(t){let e=this.svg.selectAll("."+this.css_classes["tree-container"]);var n=0;let r=e.selectAll(cs(this.css_classes)).data(this.phylotree.nodes.descendants().filter(os),function(t){return t.id||(t.id=++n)}),i=function(){},a=o.noop();this.radial()?(i=oo().curve(uo).y(function(t){return t[0]}).x(function(t){return t[1]}),a=function(t,e,n,r,i){return e?[n.screen_y+(t[0]-r)/50,n.screen_x+(t[1]-i)/50]:[n.screen_y,n.screen_x]}):(i=oo().y(function(t){return t[0]}).x(function(t){return t[1]}).curve(uo),a=function(t,e,n,r,i){return e?[n.screen_y+(t[0]-r)/50,n.screen_x+(t[1]-i)/50]:[n.screen_y,n.screen_x]}),r.exit().each(function(t){t.collapsed_clade=null}).remove(),t?r.enter().insert("path",":first-child").attr("class",this.css_classes.clade).merge(r).attr("d",function(t){if(t.collapsed_clade)return t.collapsed_clade;let e=t.collapsed[0][0],n=t.collapsed[0][1];return i(t.collapsed.map(function(r,i){return a(r,i,t,e,n)}))}).attr("d",function(t){return t.collapsed_clade=i(t.collapsed)}):r.enter().insert("path",":first-child").attr("class",this.css_classes.clade).merge(r).attr("d",function(t){return t.collapsed_clade?t.collapsed_clade:t.collapsed_clade=i(t.collapsed)})}});function fs(t){return!(t.target.hidden||t.target.notshown)}function ds(t){return[t.branch,t["selected-branch"],t["tagged-branch"]].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var ps=Object.freeze({__proto__:null,drawEdge:function(t,e,n){t=(t=It(t)).attr("class",t=>this.reclassEdge(t)).on("click",t=>{this.modifySelection([e.target],this.selection_attribute_name),this.update()});let r=this.draw_branch([e.source,e.target]);n?(t.datum().existing_path&&(t=t.attr("d",function(t){return t.existing_path})),t=t.attr("d",r)):t=t.attr("d",r),e.existing_path=r;var i=this.phylotree.branch_length_accessor(e.target);if(void 0!==i){var a=t.selectAll("title");a.empty()&&(a=t.append("title")),a.text("Length = "+i)}else t.selectAll("title").remove();return this.edge_styler&&this.edge_styler(t,e,n),this.phylotree},reclassEdge:function(t){let e=Qo.branch;return Go(t)&&(e+=" "+Qo["tagged-branch"]),Ko(t,this.selection_attribute_name)&&(e+=" "+Qo["selected-branch"]),e},initializeEdgeLabels:function(){this.links.forEach(t=>{t.target.data.annotation&&(t.target[t.target.data.annotation]=t.target.data.annotation)})},syncEdgeLabels:function(){if(this.links.forEach(t=>{t[this.selection_attribute_name]=t.target[this.selection_attribute_name]||!1,t.tag=t.target.tag||!1}),this.countHandler()){let t={};t[this.selection_attribute_name]=this.links.reduce((t,e)=>t+(e[this.selection_attribute_name]?1:0),0),t.tagged=this.links.reduce(function(t,e){return t+(Go(e)?1:0)},0),this.countUpdate(this,t,this.countHandler())}},edgeVisible:fs,edgeCssSelectors:ds,placeAlongAnEdge:function(t,e){return this.edge_placer(t,e)}});let _s="phylotree.event";function gs(t){var e=new CustomEvent(_s,{detail:["refresh",t]});document.dispatchEvent(e)}function ms(t,e){var n=new CustomEvent(_s,{detail:["countUpdate",e,t.countHandler()]});document.dispatchEvent(n)}function vs(t){switch(t.detail[0]){case"refresh":t.detail[1].refresh();break;case"countUpdate":case"layout":t.detail[2](t.detail[1])}return!0}function ys(){document.addEventListener(_s,vs,!1)}var bs=Object.freeze({__proto__:null,toggleCollapse:function(t){if(t.collapsed){t.collapsed=!1;let e=function(t){ko(t)||t.collapsed||t.children.forEach(e),t.hidden=!1};e(t)}else t.collapsed=!0;return this.placenodes(),this},resizeSvg:function(t,e,n){let r=this.size;if(this.radial()){let t=this.pad_width(),n="fit-to-size"!=this.options["top-bottom-spacing"]?this.pad_height():0;r=[r[1]+2*t,r[0]+2*t+n],e&&e.selectAll("."+Qo["tree-container"]).attr("transform","translate ("+t+","+(t+n)+")")}else r=[r[0]+("fit-to-size"!=this.options["top-bottom-spacing"]?this.pad_height():0),r[1]+("fit-to-size"!=this.options["left-right-spacing"]?this.pad_width():0)];return e&&(n&&(e=e.transition(100)),e.attr("height",r[0]).attr("width",r[1])),this.size=r,r},rescale:function(t,e){(e=e||"y_scaled")in this&&(this[e]*=t)},triggerRefresh:gs,countUpdate:ms,d3PhylotreeTriggerLayout:function(t){var e=new CustomEvent(_s,{detail:["layout",t,t.layoutHandler()]});document.dispatchEvent(e)},d3PhylotreeEventListener:vs,d3PhylotreeAddEventListener:ys,d3PhylotreeSvgTranslate:function(t){return!t||null===t[0]&&null===t[1]?"":"translate ("+(null!==t[0]?t[0]:0)+","+(null!==t[1]?t[1]:0)+") "},d3PhylotreeSvgRotate:function(t){return null!==t?"rotate ("+t+") ":""}});let ws="d3_layout_phylotree_context_menu";function xs(t,e,n){let r=[];return function i(a){ko(a)?e&&a!=t&&r.push(a):(n&&a!=t&&r.push(a),a.children.forEach(i))}(t),r}var Ms=Object.freeze({__proto__:null,nodeDropdownMenu:function(t,e,n,r,i){let a=It(e).select("#"+ws);if(a.empty()&&(a=It(e).append("div").attr("id",ws).attr("class","dropdown-menu").attr("role","menu")),a.selectAll("a").remove(),a.selectAll("h6").remove(),a.selectAll("div").remove(),t){if(!o.some([Boolean(t.menu_items),r.hide,r.selectable,r.collapsible])||!r["show-menu"])return;ko(t)||(r.collapsible&&(a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(os(t)?"Expand Subtree":"Collapse Subtree").on("click",e=>{a.style("display","none"),this.toggleCollapse(t).update()}),r.selectable&&(a.append("div").attr("class","dropdown-divider"),a.append("h6").attr("class","dropdown-header").text("Toggle selection"))),r.selectable&&(a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All descendant branches").on("click",function(e){a.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0))}),a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All terminal branches").on("click",function(e){a.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!1))}),a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All internal branches").on("click",function(e){a.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!1,!0))}))),t.parent&&(r.selectable&&(a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Incident branch").on("click",function(e){a.style("display","none"),n.modifySelection([t])}),a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Path to root").on("click",e=>{a.style("display","none"),this.modifySelection(this.phylotree.pathToRoot(t))}),(r.reroot||r.hide)&&a.append("div").attr("class","dropdown-divider")),r.reroot&&a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Reroot on this node").on("click",e=>{a.style("display","none"),this.phylotree.reroot(t),this.update()}),r.hide&&a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Hide this "+(ko(t)?"node":"subtree")).on("click",e=>{a.style("display","none"),this.modifySelection([t],"notshown",!0,!0).updateHasHiddenNodes().update()})),as(t)&&a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Show all descendant nodes").on("click",function(e){a.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0),"notshown",!0,!0,"false").updateHasHiddenNodes().update()});var s=[];if("menu_items"in t&&"object"==typeof t.menu_items&&t.menu_items.forEach(function(e){3==e.length&&(e[2]&&!e[2](t)||s.push([e[0],e[1]]))}),s.length){const e=[r.hide,r.selectable,r.collapsible];o.some(e)&&a.append("div").attr("class","dropdown-divider"),s.forEach(function(e){a.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(e[0](t)).on("click",o.partial(e[1],t))})}let l=document.querySelector(e).getBoundingClientRect();a.style("position","absolute").style("left",i.clientX-l.x+12+"px").style("top",i.clientY-l.y+"px").style("display","block")}else a.style("display","none")},addCustomMenu:function(t,e,n,r){"menu_items"in t||(t.menu_items=[]),t.menu_items.some(function(t){return t[0]==e&&t[1]==n&&t[2]==r})||t.menu_items.push([e,n,r])},modifySelection:function(t,e,n,r,i){if(e=e||this.selection_attribute_name,i=i||"toggle",this.options["restricted-selectable"].length){if(!o.contains(o.keys(es),t))return;t=es[t]}if(!this.options["restricted-selectable"]&&!this.options.selectable||this.options["binary-selectable"])this.options["binary-selectable"]&&("function"==typeof t?this.links.forEach(function(n){var r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,s=!0,n.target[e]=r),this.options["attribute-list"].forEach(function(t){t!=e&&!0===n[e]&&(n[t]=!1,n.target[t]=!1)})}):(t.forEach(function(t){var n;n=!t[e],t[e]!=n&&(t[e]=n,s=!0)}),this.links.forEach(function(t){t[e]=t.target[e],this.options["attribute-list"].forEach(function(n){n!=e&&!0!==t[e]&&(t[n]=!1,t.target[n]=!1)})})),s&&(r||gs(this),this.countHandler()&&((a={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),this.countUpdate(this,a,this.countHandler())),n&&this.placenodes()));else{var a,s=!1;"function"==typeof t?this.links.forEach(function(n){let r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,s=!0,n.target[e]=r)}):(t.forEach(function(t){var n;switch(i){case"true":n=!0;break;case"false":n=!1;break;default:n=!t[e]}t[e]!=n&&(t[e]=n,s=!0)}),this.links.forEach(function(t){t[e]=t.target[e]})),s&&(r||gs(this),this.countHandler&&((a={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),ms(this,a,this.countHandler)),n&&this.placenodes())}return this._selectionCallback&&"tag"!=e&&this._selectionCallback(this.getSelection()),this.refresh(),this.update(),this},getSelection:function(){return xs(this.phylotree.getRootNode(),!0,!0).filter(t=>t[this.selection_attribute_name])},selectAllDescendants:xs,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function ks(t){return function(){return t}}class Ns{constructor(t,e={}){Jo(e["css-classes"]),this.css_classes=Qo,this.phylotree=t,this.container=e.container,this.separation=function(t,e){return 0},this._nodeLabel=this.defNodeLabel,this.svg=null,this._selectionCallback=null,this.scales=[1,1],this.size=[1,1],this.fixed_width=[14,30],this.scale_bar_font_size=12,this.draw_branch=Wo,this.draw_scale_bar=null,this.edge_placer=Zo,this.count_listener_handler=function(){},this.layout_listener_handler=function(){},this.node_styler=void 0,this.edge_styler=void 0,this.selection_attribute_name="selected",this.right_most_leaf=0,this.label_width=0,this.radial_center=0,this.radius=1,this.radius_pad_for_bubbles=0,this.rescale_nodeSpan=1,this.relative_nodeSpan=function(t){return this.nodeSpan(t)/this.rescale_nodeSpan};let n={layout:"left-to-right",logger:console,branches:"step",scaling:!0,bootstrap:!1,"color-fill":!0,"font-size":14,"internal-names":!1,selectable:!0,"restricted-selectable":!1,collapsible:!0,"left-right-spacing":"fixed-step","top-bottom-spacing":"fixed-step","left-offset":0,"show-scale":"top","draw-size-bubbles":!1,"bubble-styler":this.radius_pad_for_bubbles,"binary-selectable":!1,"is-radial":!1,"attribute-list":[],"max-radius":768,"annular-limit":.38196601125010515,compression:.2,"align-tips":!1,"maximum-per-node-spacing":100,"minimum-per-node-spacing":2,"maximum-per-level-spacing":100,"minimum-per-level-spacing":10,node_circle_size:ks(3),transitions:null,brush:!0,reroot:!0,hide:!0,"label-nodes-with-name":!1,zoom:!1,"show-menu":!0,"show-labels":!0,"node-styler":null,"edge-styler":null,"node-span":null};this.ensure_size_is_in_px=function(t){return"number"==typeof t?t+"px":t},this.options=o.defaults(e,n),this.font_size=this.options["font-size"],this.offsets=[0,this.font_size/2],this.shown_font_size=this.font_size,this.width=this.options.width||800,this.height=this.options.height||600,this.node_styler=this.options["node-styler"],this.edge_styler=this.options["edge-styler"],this.nodeSpan=this.options["node-span"],this.nodeSpan||(this.nodeSpan=function(t){return 1}),this.rescale_nodeSpan=this.phylotree.nodes.children.map(t=>{if(ko(t)||this.showInternalName(t))return this.nodeSpan(t)}).reduce(function(t,e){return Math.min(e,t||1e200)},null)||1,this.initialize_svg(this.container),this.links=this.phylotree.nodes.links(),this.initializeEdgeLabels(),this.update(),ys()}pad_height(){return this.draw_scale_bar?this.scale_bar_font_size+25:0}pad_width(){this.label_width=this._label_width(this.shown_font_size);const t=this.options["show-labels"]?this.label_width:0;return this.offsets[1]+this.options["left-offset"]+t}collapse_node(t){os(t)||(t.collapsed=!0)}set_size(t){if(!arguments.length)return this.size;let e=t;return"fixed-step"!=this.options["top-bottom-spacing"]&&(this.size[0]=e[0]),"fixed-step"!=this.options["left-right-spacing"]&&(this.size[1]=e[1]),this}initialize_svg(t){var e;return this.svg!==t&&(It(t).select("svg").remove(),this.svg=(e="svg",It(O(e).call(document.documentElement))).attr("width",this.width).attr("height",this.height),this.set_size([this.height,this.width]),"phylotree-container"==this.css_classes["tree-container"]&&(this.svg.selectAll("*").remove(),this.svg.append("defs")),It(this.container).on("click",t=>{this.handle_node_click(null)},!0)),this}update_layout(t,e){e&&(this.nodes=qr(t),this.nodes.each(function(t){t.id=null})),this.update(),this.syncEdgeLabels()}update(t){var e=this;this.placenodes(),t=this.transitions(t);let n=0,r=this.svg.selectAll("."+Qo["tree-container"]).data([0]);if(r=r.enter().append("g").attr("class",Qo["tree-container"]).merge(r).attr("transform",t=>this.d3PhylotreeSvgTranslate([this.offsets[1]+this.options["left-offset"],this.pad_height()])),this.draw_scale_bar){let t=this.svg.selectAll("."+Qo["tree-scale-bar"]).data([0]);t.enter().append("g").attr("class",Qo["tree-scale-bar"]).style("font-size",this.ensure_size_is_in_px(this.scale_bar_font_size)).merge(t).attr("transform",t=>this.d3PhylotreeSvgTranslate([this.offsets[1]+this.options["left-offset"],this.pad_height()-10])).call(this.draw_scale_bar),t.selectAll("text").style("text-anchor","end")}else this.svg.selectAll("."+Qo["tree-scale-bar"]).remove();r=this.svg.selectAll("."+Qo["tree-container"]).data([0]),this.updateCollapsedClades(t);let i=r.selectAll(ds(Qo)).data(this.links.filter(fs),t=>t.target.id||(t.target.id=++n));i.exit().remove(),i=i.enter().insert("path",":first-child").merge(i).each(function(n){e.drawEdge(this,n,t)});let a=r.selectAll(ss(Qo)).data(this.phylotree.nodes.descendants().filter(rs),t=>t.id||(t.id=++n));if(a.exit().remove(),a=a.enter().append("g").attr("class",this.reclassNode).merge(a).attr("transform",t=>{const e="right-to-left"==this.options.layout&&ko(t);return t.screen_x=Ro(t),t.screen_y=qo(t),this.d3PhylotreeSvgTranslate([e?0:t.screen_x,t.screen_y])}).each(function(n){e.drawNode(this,n,t)}).attr("transform",t=>{if(!o.isUndefined(t.screen_x)&&!o.isUndefined(t.screen_y))return"translate("+t.screen_x+","+t.screen_y+")"}),this.options["label-nodes-with-name"]&&(a=a.attr("id",t=>"node-"+t.name)),this.resizeSvg(this.phylotree,this.svg,t),this.options.brush){var s=r.selectAll("."+Qo["tree-selection-brush"]).data([0]).enter().insert("g",":first-child").attr("class",Qo["tree-selection-brush"]),l=br().on("brush",(t,e)=>{var n=t.selection,r=this.links.filter(fs).filter((t,e)=>t.source.screen_x>=n[0][0]&&t.source.screen_x<=n[1][0]&&t.source.screen_y>=n[0][1]&&t.source.screen_y<=n[1][1]&&t.target.screen_x>=n[0][0]&&t.target.screen_x<=n[1][0]&&t.target.screen_y>=n[0][1]&&t.target.screen_y<=n[1][1]).map(t=>t.target);this.modifySelection(this.phylotree.links.map(t=>t.target),"tag",!1,r.length>0,"false"),this.modifySelection(r,"tag",!1,!1,"true")}).on("end",()=>{});s.call(l)}if(this.syncEdgeLabels(),this.options.zoom){let t=function(){var t,e,n,r=vo,i=yo,a=Mo,o=wo,s=xo,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,h=tn,f=z("start","zoom","end"),d=0,p=10;function _(t){t.property("__zoom",bo).on("wheel.zoom",x,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",k).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",T).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(t,e){return(e=Math.max(l[0],Math.min(l[1],e)))===t.k?t:new po(e,t.x,t.y)}function m(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new po(t.k,r,i)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function y(t,e,n,r){t.on("start.zoom",function(){b(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,a=arguments,o=b(t,a).event(r),s=i.apply(t,a),l=null==n?v(s):"function"==typeof n?n.apply(t,a):n,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),c=t.__zoom,f="function"==typeof e?e.apply(t,a):e,d=h(c.invert(l).concat(u/c.k),f.invert(l).concat(u/f.k));return function(t){if(1===t)t=f;else{var e=d(t),n=u/e[2];t=new po(n,l[0]-e[0]*n,l[1]-e[1]*n)}o.zoom(null,t)}})}function b(t,e,n){return!n&&t.__zooming||new w(t,e)}function w(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function x(t,...e){if(r.apply(this,arguments)){var n=b(this,e).event(t),i=this.__zoom,s=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,o.apply(this,arguments)))),c=Bt(t);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=i.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[c,i.invert(c)],kn(this),n.start()}mo(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",a(m(g(i,s),n.mouse[0],n.mouse[1]),n.extent,u))}}function M(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,o=b(this,e,!0).event(t),s=It(t.view).on("mousemove.zoom",function(t){if(mo(t),!o.moved){var e=t.clientX-c,n=t.clientY-h;o.moved=e*e+n*n>d}o.event(t).zoom("mouse",a(m(o.that.__zoom,o.mouse[0]=Bt(t,i),o.mouse[1]),o.extent,u))},!0).on("mouseup.zoom",function(t){s.on("mousemove.zoom mouseup.zoom",null),Zt(t.view,o.moved),mo(t),o.event(t).end()},!0),l=Bt(t,i),c=t.clientX,h=t.clientY;Wt(t.view),go(t),o.mouse=[l,this.__zoom.invert(l)],kn(this),o.start()}}function k(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,o=Bt(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(o),l=n.k*(t.shiftKey?.5:2),h=a(m(g(n,l),o,s),i.apply(this,e),u);mo(t),c>0?It(this).transition().duration(c).call(y,h,o,t):It(this).call(_.transform,h,o,t)}}function N(n,...i){if(r.apply(this,arguments)){var a,o,s,l,u=n.touches,c=u.length,h=b(this,i,n.changedTouches.length===c).event(n);for(go(n),o=0;o<c;++o)l=[l=Bt(s=u[o],this),this.__zoom.invert(l),s.identifier],h.touch0?h.touch1||h.touch0[2]===l[2]||(h.touch1=l,h.taps=0):(h.touch0=l,a=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),a&&(h.taps<2&&(e=l[0],t=setTimeout(function(){t=null},500)),kn(this),h.start())}}function A(t,...e){if(this.__zooming){var n,r,i,o,s=b(this,e).event(t),l=t.changedTouches,c=l.length;for(mo(t),n=0;n<c;++n)i=Bt(r=l[n],this),s.touch0&&s.touch0[2]===r.identifier?s.touch0[0]=i:s.touch1&&s.touch1[2]===r.identifier&&(s.touch1[0]=i);if(r=s.that.__zoom,s.touch1){var h=s.touch0[0],f=s.touch0[1],d=s.touch1[0],p=s.touch1[1],_=(_=d[0]-h[0])*_+(_=d[1]-h[1])*_,v=(v=p[0]-f[0])*v+(v=p[1]-f[1])*v;r=g(r,Math.sqrt(_/v)),i=[(h[0]+d[0])/2,(h[1]+d[1])/2],o=[(f[0]+p[0])/2,(f[1]+p[1])/2]}else{if(!s.touch0)return;i=s.touch0[0],o=s.touch0[1]}s.zoom("touch",a(m(r,i,o),s.extent,u))}}function T(t,...r){if(this.__zooming){var i,a,o=b(this,r).event(t),s=t.changedTouches,l=s.length;for(go(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<l;++i)a=s[i],o.touch0&&o.touch0[2]===a.identifier?delete o.touch0:o.touch1&&o.touch1[2]===a.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(a=Bt(a,this),Math.hypot(e[0]-a[0],e[1]-a[1])<p)){var u=It(this).on("dblclick.zoom");u&&u.apply(this,arguments)}}}return _.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",bo),t!==i?y(t,e,n,r):i.interrupt().each(function(){b(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},_.scaleBy=function(t,e,n,r){_.scaleTo(t,function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)},n,r)},_.scaleTo=function(t,e,n,r){_.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,o=null==n?v(t):"function"==typeof n?n.apply(this,arguments):n,s=r.invert(o),l="function"==typeof e?e.apply(this,arguments):e;return a(m(g(r,l),o,s),t,u)},n,r)},_.translateBy=function(t,e,n,r){_.transform(t,function(){return a(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),u)},null,r)},_.translateTo=function(t,e,n,r,o){_.transform(t,function(){var t=i.apply(this,arguments),o=this.__zoom,s=null==r?v(t):"function"==typeof r?r.apply(this,arguments):r;return a(_o.translate(s[0],s[1]).scale(o.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,u)},r,o)},w.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1===++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0===--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=It(this.that).datum();f.call(t,this.that,new fo(t,{sourceEvent:this.sourceEvent,target:_,type:t,transform:this.that.__zoom,dispatch:f}),e)}},_.wheelDelta=function(t){return arguments.length?(o="function"==typeof t?t:ho(+t),_):o},_.filter=function(t){return arguments.length?(r="function"==typeof t?t:ho(!!t),_):r},_.touchable=function(t){return arguments.length?(s="function"==typeof t?t:ho(!!t),_):s},_.extent=function(t){return arguments.length?(i="function"==typeof t?t:ho([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),_):i},_.scaleExtent=function(t){return arguments.length?(l[0]=+t[0],l[1]=+t[1],_):[l[0],l[1]]},_.translateExtent=function(t){return arguments.length?(u[0][0]=+t[0][0],u[1][0]=+t[1][0],u[0][1]=+t[0][1],u[1][1]=+t[1][1],_):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},_.constrain=function(t){return arguments.length?(a=t,_):a},_.duration=function(t){return arguments.length?(c=+t,_):c},_.interpolate=function(t){return arguments.length?(h=t,_):h},_.on=function(){var t=f.on.apply(f,arguments);return t===f?_:t},_.clickDistance=function(t){return arguments.length?(d=(t=+t)*t,_):Math.sqrt(d)},_.tapDistance=function(t){return arguments.length?(p=+t,_):p},_}().scaleExtent([.1,10]).on("zoom",t=>{It("."+Qo["tree-container"]).attr("transform",e=>t.transform),It("."+Qo["tree-scale-bar"]).attr("transform",e=>{let n=t.transform;return n.y-=10,n})});this.svg.call(t)}return this}_handle_single_node_layout(t){let e=this.nodeSpan(t)/this.rescale_nodeSpan;this.x=t.x=this.x+this.separation(this.last_node,t)+.5*(this.last_span+e),this._extents[1][1]=Math.max(this._extents[1][1],t.y),this._extents[1][0]=Math.min(this._extents[1][0],t.y-.5*e),this.is_under_collapsed_parent?this._extents[0][1]=Math.max(this._extents[0][1],this.save_x+(t.x-this.save_x)*this.options.compression+this.save_span+(.5*e+this.separation(this.last_node,t))*this.options.compression):this._extents[0][1]=Math.max(this._extents[0][1],this.x+.5*e+this.separation(this.last_node,t)),this.last_node=t,this.last_span=e}tree_layout(t){if(is(t))return;let e=ko(t);t.text_angle=null,t.text_align=null,t.radius=null,t.angle=null;let n=!1;if(t.parent)if(this.do_scaling){if(n)return 0;if(t.y=this.phylotree.branch_length_accessor(t),void 0===t.y)return n=!0,0;t.y+=t.parent.y}else t.y=e?this.max_depth:t.depth;else this.x=0,t.y=0,this.last_node=null,this.last_span=0,this._extents=[[0,0],[0,0]];if(e&&this._handle_single_node_layout(t),!e)if(os(t)&&!this.is_under_collapsed_parent){if(this.save_x=this.x,this.save_span=.5*this.last_span,this.is_under_collapsed_parent=!0,this.process_internal_node(t),this.is_under_collapsed_parent=!1,"number"==typeof t.x){t.x=this.save_x+(t.x-this.save_x)*this.options.compression+this.save_span,t.collapsed=[[t.x,t.y]];var r=e=>{e.hidden=!0,ko(e)?(this.x=e.x=this.save_x+(e.x-this.save_x)*this.options.compression+this.save_span,t.collapsed.push([e.x,e.y])):e.children.map(r)};this.x=this.save_x,r(t),t.collapsed.splice(1,0,[this.save_x,t.y]),t.collapsed.push([this.x,t.y]),t.collapsed.push([t.x,t.y]),t.hidden=!1}}else this.process_internal_node(t);return t.x}process_internal_node(t){let e=0;if(this.showInternalName(t)){let e=t.children.length/2|0,n=0,r=!1;for(let i=0;i<t.children.length;i++){"number"==typeof this.tree_layout(t.children[i])&&n++,n>=e&&!r&&(this._handle_single_node_layout(t),r=!0)}0==n?(t.notshown=!0,t.x=void 0):r||this._handle_single_node_layout(t)}else t.x=t.children.map(this.tree_layout.bind(this)).reduce((t,n)=>"number"==typeof n?t+n:(e+=1,t),0),e==t.children.length?(t.notshown=!0,t.x=void 0):t.x/=t.children.length-e}do_lr(t){if(this.radial()&&t&&(this.offsets[1]=0),"fixed-step"==this.options["left-right-spacing"])this.size[1]=this.max_depth*this.fixed_width[1],this.scales[1]=(this.size[1]-this.offsets[1]-this.options["left-offset"])/this._extents[1][1],this.label_width=this._label_width(this.shown_font_size),this.radial()&&(this.label_width*=2);else{this.label_width=this._label_width(this.shown_font_size),t=!0;let e=this.size[1]-this.offsets[1]-this.options["left-offset"];.5*e<this.label_width&&(this.shown_font_size*=.5*e/this.label_width,this.label_width=.5*e),this.scales[1]=(this.size[1]-this.offsets[1]-this.options["left-offset"]-this.label_width)/this._extents[1][1]}}placenodes(){this._extents=[[0,0],[0,0]],this.x=0,this.last_span=0,this.last_node=null,this.last_span=0,this.save_x=this.x,this.save_span=.5*this.last_span,this.do_scaling=this.options.scaling;this.is_under_collapsed_parent=!1,this.max_depth=1,this.phylotree.nodes.x=this.tree_layout(this.phylotree.nodes,this.do_scaling),this.max_depth=function(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n<e||void 0===n&&e>=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r,t))&&(n<i||void 0===n&&i>=i)&&(n=i)}return n}(this.phylotree.nodes.descendants(),t=>t.depth),this.do_scaling;let t=!1;if(this.draw_scale_bar=this.options["show-scale"]&&this.do_scaling,this.offsets[1]=Math.max(this.font_size,-this._extents[1][0]*this.fixed_width[0]),"fixed-step"==this.options["top-bottom-spacing"]?(this.size[0]=this._extents[0][1]*this.fixed_width[0],this.scales[0]=this.fixed_width[0]):(this.scales[0]=(this.size[0]-this.pad_height())/this._extents[0][1],t=!0),this.shown_font_size=Math.min(this.font_size,this.scales[0]),this.radial()){this.draw_branch=o.partial(Vo,this.radial_center),this.edge_placer=Xo;let e=null,n=null,r=null,i=0,a=this._extents[0][1]*this.scales[0],s=function(t,e,n,r,i){return i=i||0,Math.sqrt((e-t)*(e-t)+2*(t+i)*(e+i)*(1-Math.cos(n-r)))},l=0;this.phylotree.nodes.each(t=>{let e=t.x*this.scales[0];t.angle=2*Math.PI*e/a,t.text_angle=t.angle-Math.PI/2,t.text_angle=t.text_angle>0&&t.text_angle<Math.PI,t.text_align=t.text_angle?"end":"start",t.text_angle=(t.text_angle?180:0)+180*t.angle/Math.PI}),this.do_lr(t),this.phylotree.nodes.each(t=>{t.radius=t.y*this.scales[1]/this.size[1],l=Math.max(t.radius,l)});let u=0;this.phylotree.nodes.each(t=>{if(!t.children){let a=t.x*this.scales[0];if(null!==e){let o=a-n,c=s(t.radius,r,t.angle,e,u),h=c>0?o/c:10*this.options["max-radius"];if(h>this.options["max-radius"]){let n=o/this.options["max-radius"],a=t.radius+r,s=t.radius*r-(n*n-(r-t.radius)*(r-t.radius))/2/(1-Math.cos(e-t.angle)),c=Math.sqrt(a*a-4*s);u=Math.min(this.options["annular-limit"]*l,(-a+c)/2),i=this.options["max-radius"]}else i=Math.max(i,h)}e=t.angle,n=a,r=t.radius}}),this.radius=Math.min(this.options["max-radius"],Math.max(a/2/Math.PI,i)),t&&(this.radius=Math.min(this.radius,.5*(Math.min(a,this._extents[1][1]*this.scales[1])-this.label_width)-this.radius*u)),this.radial_center=this.radius_pad_for_bubbles=this.radius,this.draw_branch=o.partial(Vo,this.radial_center);let c=1;u&&(c=l/(l+u),this.radius*=c),this.phylotree.nodes.each(t=>{if(Bo(t,this.radius,u,this.radial_center,this.scales,this.size),l=Math.max(l,t.radius),this.options["draw-size-bubbles"]?this.radius_pad_for_bubbles=Math.max(this.radius_pad_for_bubbles,t.radius+this.nodeBubbleSize(t)):this.radius_pad_for_bubbles=Math.max(this.radius_pad_for_bubbles,t.radius),t.collapsed){t.collapsed=t.collapsed.map(t=>{let e={};return e.x=t[0],e.y=t[1],e=Bo(e,this.radius,u,this.radial_center,this.scales,this.size),[e.x,e.y]});let e=t.collapsed[1];t.collapsed=t.collapsed.filter(function(n,r){return r<3||r>t.collapsed.length-4||Math.sqrt(Math.pow(n[0]-e[0],2)+Math.pow(n[1]-e[1],2))>3&&(e=n,!0)})}}),this.size[0]=this.radial_center+this.radius/c,this.size[1]=this.radial_center+this.radius/c}else this.do_lr(),this.draw_branch=Wo,this.edge_placer=Zo,this.right_most_leaf=0,this.phylotree.nodes.each(t=>{if(t.x*=this.scales[0],t.y*=.8*this.scales[1],"right-to-left"==this.options.layout&&(t.y=this._extents[1][1]*this.scales[1]-t.y),ko(t)&&(this.right_most_leaf=Math.max(this.right_most_leaf,t.y+this.nodeBubbleSize(t))),t.collapsed){t.collapsed.forEach(t=>{t[0]*=this.scales[0],t[1]*=.8*this.scales[1]});let e=t.collapsed[1][0];t.collapsed=t.collapsed.filter(function(n,r){return r<3||r>t.collapsed.length-4||n[0]-e>3&&(e=n[0],!0)})}});if(this.draw_scale_bar){let t,e;if(this.radial()){if(e=Math.min(this.radius/5,50),t=Math.pow(10,Math.ceil(Math.log(this._extents[1][1]*e/this.radius)/Math.log(10))),e=t*(this.radius/this._extents[1][1]),e<30){let n=Math.ceil(30/e);e*=n,t*=n}}else t=this._extents[1][1],e=this.size[1]-this.offsets[1]-this.options["left-offset"]-this.shown_font_size;let n=ai().domain([0,t]).range([0,e]),r=Or(".2f");if(this.draw_scale_bar=function(t){return A(1,t)}().scale(n).tickFormat(function(t){return 0===t?"":r(t)}),this.radial())this.draw_scale_bar.tickValues([t]);else{let t=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},i=n.ticks();i=i.length>1?i[1]:i[0],this.draw_scale_bar.ticks(Math.min(10,t(e/(this.shown_font_size*r(i).length*2),0)))}}else this.draw_scale_bar=null;return this}spacing_x(t,e){return arguments.length?(this.fixed_width[0]!=t&&t>=this.options["minimum-per-node-spacing"]&&t<=this.options["maximum-per-node-spacing"]&&(this.fixed_width[0]=t,e||this.placenodes()),this):this.fixed_width[0]}spacing_y(t,e){return arguments.length?(this.fixed_width[1]!=t&&t>=this.options["minimum-per-level-spacing"]&&t<=this.options["maximum-per-level-spacing"]&&(this.fixed_width[1]=t,e||this.placenodes()),this):this.fixed_width[1]}_label_width(t){t=t||this.shown_font_size;let e=0;return this.phylotree.nodes.descendants().filter(rs).forEach(n=>{let r=12+this._nodeLabel(n).length*t*.8;null!==n.angle&&(r*=Math.max(Math.abs(Math.cos(n.angle)),Math.abs(Math.sin(n.angle)))),e=Math.max(r,e)}),e}font_size(t){return arguments.length?(this.font_size=void 0===t?12:t,this):this.font_size}scale_bar_font_size(t){return arguments.length?(this.scale_bar_font_size=void 0===t?12:t,this):this.scale_bar_font_size}node_circle_size(t,e){return arguments.length?(this.options.node_circle_size=ks(void 0===t?3:t),this):this.options.node_circle_size}css(t){if(0===arguments.length)return this.css_classes;if(arguments.length>2){var e={};return e[t[0]]=t[1],this.css(e)}for(var n in Qo)n in t&&t[n]!=Qo[n]&&(Qo[n]=t[n]);return this}transitions(t){return void 0!==t?t:null!==this.options.transitions?this.options.transitions:this.phylotree.nodes.descendants().length<=300}css_classes(t,e){if(!arguments.length)return this.css_classes;let n=!1;for(var r in Qo)r in t&&t[r]!=this.css_classes[r]&&(n=!0,this.css_classes[r]=t[r]);return e&&n&&this.layout(),this}layout(t){return this.svg?(this.svg.selectAll("."+this.css_classes["tree-container"]+",."+this.css_classes["tree-scale-bar"]+",."+this.css_classes["tree-selection-brush"]),this.d3PhylotreeTriggerLayout(this),this.update()):(this.d3PhylotreeTriggerLayout(this),this)}handle_node_click(t,e){this.nodeDropdownMenu(t,this.container,this,this.options,e)}refresh(){if(this.svg){let t=this.svg.selectAll("."+this.css_classes["tree-container"]).selectAll(ds(this.css_classes)).attr("class",this.reclassEdge.bind(this));this.edge_styler&&t.each(t=>{this.edge_styler(It(this),t)})}return this}countHandler(t){return arguments.length?(this.count_listener_handler=t,this):this.count_listener_handler}style_nodes(t){return arguments.length?(this.node_styler=t,this):this.node_styler}style_edges(t){return arguments.length?(this.edge_styler=t.bind(this),this):this.edge_styler}itemSelected(t,e){return t[e]||!1}show(){return this.svg.node()}}o.extend(Ns.prototype,hs),o.extend(Ns.prototype,us),o.extend(Ns.prototype,ps),o.extend(Ns.prototype,bs),o.extend(Ns.prototype,Ms),o.extend(Ns.prototype,ns);let As=class{constructor(t,e={}){this.newick_string="",this.nodes=[],this.links=[],this.parsed_tags=[],this.partitions=[],this.branch_length_accessor=Fo,this.branch_length=Fo,this.logger=e.logger||console,this.selection_attribute_name="selected";var n=e.type||void 0,r=[],i=this;if(o.isString(n))n in Uo?r=Uo[n](t,e):i.logger.error("type "+n+" not in registry! Available types are "+o.keys(Uo));else if(o.isFunction(n))try{r=n(t,e)}catch(t){i.logger.error("Could not parse custom format!")}else"root"==t.name?r={json:t,error:null}:"string"!=typeof t?r=t:"application/xml"==t.contentType?r=Lo(t):(this.newick_string=t,r=To(t,e));if(r.json){i.nodes=qr(r.json);let t={};i.nodes.each(e=>{e.data.annotation&&(t[e.data.annotation]=!0)}),i.parsed_tags=Object.keys(t)}else i.nodes=[];return i.links=i.nodes.links(),this.hasBranchLengths()||(console.warn("Phylotree User Warning : NO BRANCH LENGTHS DETECTED, SETTING ALL LENGTHS TO 1"),this.setBranchLength(t=>1)),i}json(t){var e=0;this.traverse_and_compute(function(t){t.json_export_index=e++},t);var n=new Array(e);return e=0,this.traverse_and_compute(function(t){let r=o.clone(t);delete r.json_export_index,t.parent&&(r.parent=t.parent.json_export_index),t.children&&(r.children=o.map(t.children,function(t){return t.json_export_index})),n[e++]=r},t),this.traverse_and_compute(function(t){delete t.json_export_index},t),JSON.stringify(n)}traverse_and_compute(t,e,n,r){return(e="pre-order"==(e=e||"post-order")?function(e){Oo(e,t,r)}:"in-order"==e?function(e){Ho(e,t,r)}:function(e){o.isUndefined(e)||Po(e,t,r)})(n||this.nodes),this}get_parsed_tags(){return this.parsed_tags}update(t){this.nodes=t}render(t){return this.display=new Ns(this,t),this.display}};function Ts(t){var e=t.branch_length_accessor;if(!e)throw"A non-null branch lengths accessor function is required for this operation";var n=0;function r(t){for(var e=0;e<t.children.length;e++)for(var n=0;n<t.children.length;n++)e!=n&&o.each(t.children[n].cot_path_to_leaves_below,function(r,i){t.children[e].cot_path_to_leaves_above&&(t.children[e].cot_path_to_leaves_above[i]=r+t.children[n].cot_computed_length)})}return t.traverse_and_compute(function(r){if(r.cot_computed_length=e(r),r.parent&&o.isUndefined(r.cot_computed_length))throw"Non-null branch lengths are required for this operation: missing branch length at node "+r.data.name;t.isLeafNode(r)?(r.cot_leaf_index=n++,r.cot_path_to_leaves_below={},r.cot_path_to_leaves_below[r.cot_leaf_index]=0,r.cot_path_to_leaves_above={}):(r.cot_path_to_leaves_below={},r.cot_path_to_leaves_above={})}),t.traverse_and_compute(function(t){t.parent&&o.each(t.cot_path_to_leaves_below,function(e,n){t.parent.cot_path_to_leaves_below[n]=e+t.cot_computed_length})}),r(t.getRootNode()),t.traverse_and_compute(function(e){e.parent&&(o.each(e.parent.cot_path_to_leaves_above,function(t,n){e.cot_path_to_leaves_above[n]=t+e.parent.cot_computed_length}),t.isLeafNode(e)||r(e))},"pre-order"),n}function zs(t,e,n,r,i){var a=t.branch_length(e),o=!1;if(n||(r=e.data.rootToTip,i=0,o=!0),e.children)for(var s=0;s<e.children.length;s++)e.children[s]!=n?zs(t,e.children[s],e,r,i):o=!0;e.data.rtta=e.data.rootToTip-r+i,o&&(r-=a,i+=a),e.parent&&o&&zs(t,e.parent,e,r,i)}function Ss(t){var e=t.reduce(function(t,e){return e[2]+t},0),n=t.reduce(function(t,e){return e[2]*e[0]+t},0),r=t.reduce(function(t,e){return e[2]*e[1]+t},0),i=n/e,a=r/e,o=0,s=0,l=0;t.forEach(function(t){var e=t[0]-i;s+=t[2]*e*e,o+=t[2]*e*t[1],l+=t[2]*(t[1]-a)*(t[1]-a)});var u=(r-n*(o/=s))/e,c=0;return t.forEach(function(t){var e=t[1]-u-o*t[0];c+=t[2]*e*e}),{intercept:u,slope:o,r2:1-c/l,"var (intercept)":Math.sqrt((1+n*n/(e*s))/e),"var (slope)":Math.sqrt(1/s)}}function Es(t){var e=t.branch_length_accessor,n=0;t.traverse_and_compute(r=>{if(r.parent&&(r.data._computed_length=e(r),!o.isNumber(r.data._computed_length)))throw"rootToTip cannot be run on trees with missing branch lengths";t.isLeafNode(r)&&(r.data.leaf_index=n++),"r2t"in r.data&&delete r.data.r2t}),t.traverse_and_compute(e=>{e.parent&&("r2t"in e.parent.data||(e.parent.data.r2t={}),t.isLeafNode(e)?e.parent.data.r2t[e.data.leaf_index]=e.data._computed_length:(o.each(e.data.r2t,function(t,n){e.parent.data.r2t[n]=t+e.data._computed_length}),delete e.data.r2t),delete e.data._computed_length)});var r=t.getRootNode().data.r2t;return t.traverse_and_compute(e=>{t.isLeafNode(e)&&(e.data.rootToTip=r[e.data.leaf_index]||0,delete e.data.leaf_index)}),delete t.getRootNode().data.r2t,t}As.prototype.isLeafNode=ko,As.prototype.selectAllDescendants=No,As.prototype.mrca=function(t){var e;return t=t.map(function(t){return"string"==typeof t?t:t.data.name}),this.traverse_and_compute(function(n){n.children?n.parent?(n.data.mrca=o.union(...n.descendants().map(t=>t.data.mrca)),e||n.data.mrca.length!=t.length||(e=n)):e||(e=n):n.data.mrca=o.intersection([n.data.name],t)}),e},As.prototype.hasBranchLengths=function(){let t=this.branch_length;return!!t&&o.every(this.nodes.descendants(),function(e){return!e.parent||!o.isUndefined(t(e))})},As.prototype.getBranchLengths=function(){let t=this.branch_length;return o.map(this.nodes.descendants(),e=>t(e))},As.prototype.branchName=function(t){return arguments.length?(this.nodeLabel=t,this):this.nodeLabel},As.prototype.normalizeBranchLengths=function(t){let e=this.branch_length,n=o.map(this.nodes.descendants(),function(t){return e(t)?e(t):null});const r=o.max(n),i=o.min(n);return o.each(this.nodes.descendants(),t=>{let n=e(t);n&&e(t,function(t){return(t-i)/(r-i)}(n))}),this},As.prototype.scaleBranchLengths=function(t){let e=this.branch_length;return o.each(this.nodes.descendants(),n=>{let r=e(n);r&&e(n,t(r))}),this},As.prototype.getNewick=zo,As.prototype.resortChildren=function(t,e,n){return this.nodes.sum(function(t){return t.value}).sort(t),this.display&&(this.display.update_layout(this.nodes),this.display.update()),this},As.prototype.setBranchLength=function(t){return arguments.length?(this.branch_length_accessor=t||Fo,this):this.branch_length_accessor},As.prototype.maxParsimony=function(t,e){const n=o.partial(function(t,e){if(e.mp=[[0,0],[!1,!1]],ko(e))e.mp[1][0]=e.mp[1][1]=e[t]||!1,e.mp[0][0]=e.mp[1][0]?1:0,e.mp[0][1]=1-e.mp[0][0];else{e.children.forEach(n);var r=e.children.reduce(function(t,e){return e.mp[0][0]+t},0),i=e.children.reduce(function(t,e){return e.mp[0][1]+t},0);e[t]?(e.mp[0][0]=i+1,e.mp[1][0]=!0,e.mp[0][1]=i,e.mp[1][1]=!0):(r<i+1?(e.mp[0][0]=r,e.mp[1][0]=!1):(e.mp[0][0]=i+1,e.mp[1][0]=!0),i<r+1?(e.mp[0][1]=i,e.mp[1][1]=!0):(e.mp[0][1]=r+1,e.mp[1][1]=!1))}},e);n(this.nodes),this.nodes.each(t=>{t.parent?t.mp=t.mp[1][t.parent.mp?1:0]:t.mp=t.mp[1][t.mp[0][0]<t.mp[0][1]?0:1]}),this.display.modifySelection((t,n)=>ko(t.target)?t.target[e]:t.target.mp)},As.prototype.getTipLengths=function(){let t=this.getTips(),e=o.map(t,t=>({name:t.data.name,length:parseFloat(t.data.attribute)}));return e=o.sortBy(e,t=>-t.length),e},As.prototype.leftChildRightSibling=jo,o.extend(As.prototype,Ao),o.extend(As.prototype,Yo),o.extend(As.prototype,$o);const Cs=Oi("%Y%m%d"),$s=/([0-9]{4}).?([0-9]{2}).?([0-9]{2})$/g,Ds=function(t){if(ko(t)&&"name"in t){let e=$s.exec(t.name);if(e)return e[1]+e[2]+e[3]}return null};function Ls(t,e){let n=[];for(let r of s.range(e.length))if(r!=t){let i=[];for(let n of s.range(e[r].length))n!=t&&i.push(e[r][n]);n.push(i)}return n}t.centerOfTree=function(t,e){e=e||2;var n=Ts(t),r=Number.MAX_VALUE,i=0,a=null;return 2==e?t.traverse_and_compute(function(t){if(t.parent){var e=0,s=0,l=0,u=0,c=0;o.each(t.cot_path_to_leaves_below,function(t){e+=t,s+=t*t,c++}),o.each(t.cot_path_to_leaves_above,function(t){l+=t,u+=t*t});var h=n-c,f=(l-e+t.cot_computed_length*h)/n;f<0?f=0:f>t.cot_computed_length&&(f=t.cot_computed_length);var d=u+s+2*(l*(t.cot_computed_length-f)+e*f)+c*f*f+(t.cot_computed_length-f)*(t.cot_computed_length-f)*h;d<r&&(a=t,i=f/t.cot_computed_length,r=d),delete t.cot_computed_length,delete t.cot_path_to_leaves_below,delete t.cot_path_to_leaves_above,delete t.cot_leaf_index}}):t.traverse_and_compute(function(t){if(t.parent)for(var n=t.cot_computed_length>0?.05*t.cot_computed_length:.1,s=0;s<t.cot_computed_length;){var l=0;o.each(t.cot_path_to_leaves_below,function(t){l+=Math.pow(t+s,e)}),o.each(t.cot_path_to_leaves_above,function(n){l+=Math.pow(n+(t.cot_computed_length-s),e)}),l<r&&(a=t,i=s/t.cot_computed_length,r=l),s+=n}}),{location:a,breakpoint:i,distance:r}},t.clusterPicker=function(t,e,n,r,i){r=r||t.getRootNode(),i=o.isNumber(i)?i:1;let a=t.branch_length;t.traverse_and_compute(function(t){if(t.parent){if(t._computed_length=a(t),!o.isNumber(t._computed_length))throw"clusterPicker cannot be run on trees with missing branch lengths";t.max_path_length=0}}),t.traverse_and_compute(function(t){t.parent&&(t.parent.max_path_length=Math.max(t.parent.max_path_length,t.max_path_length+t._computed_length))});var s=[];return t.traverse_and_compute(o.noop,"pre-order",r,function(r){if(!t.isLeafNode(r)){var a=o.isString(r.data.bootstrap_values)?+r.data.bootstrap_values:i;if(a>=e){var l=o.reduce(r.children,function(t,e){return e.max_path_length+e._computed_length+t},0);if(l<=n)return s.push({root:r,diameter:l,bootstrap:a}),!0}}return!1}),t.traverse_and_compute(function(t){t.parent&&(delete t._computed_length,delete t.max_path_length)},"post-order",r),o.each(s,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),s},t.computeMidpoint=function(t){if(!t.hasBranchLengths())throw"Center of tree calculation cannot be performed on trees that do not have fully specified branch lengths";var e=t.branch_length;t.traverse_and_compute(function(n){if(n.parent){var r,i=e(n);t.isLeafNode(n)?(r=n,n.max_path=0,n.max_path_terminus=n):(i+=n.max_path,r=n.max_path_terminus),(!n.parent.max_path||n.parent.max_path<i)&&(n.parent.max_path=i,n.parent.max_path_terminus=r)}});var n=t.getRootNode(),r=0;if(n.children.forEach(function(t){if(t.max_path_terminus!==n.max_path_terminus){var i=t.max_path+e(t);i>=r&&(r=i)}}),n.max_path>r){r=.5*(r+n.max_path);for(var i=n.max_path_terminus;;){var a=e(i);if(!(a<=r))return{location:i,breakpoint:r/a};r-=a,i=i.parent}}return{location:n,breakpoint:0}},t.extract_dates=function(t,e,n=Cs){return e=e||Ds,t.traverse_and_compute(function(t){var r=e(t);if(r)try{t.data.date_value=n(r);var i=t.data.date_value.getFullYear(),a=new Date(i,0,1),o=new Date(i+1,0,1);return void(t.data.decimal_date_value=i+(t.data.date_value-a)/(o-a))}catch(t){}t.data.date_value=null,t.data.decimal_date_value=null}),t},t.fitRootToTip=function(t){var e=[],n=0,r=0;!function(t){t.traverse_and_compute(function(e){t.isLeafNode(e)&&(e.data.copy_number=1)})}(t),Es(t),t.traverse_and_compute(function(n){t.isLeafNode(n)&&!o.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});let i=Ss(e);return t.traverse_and_compute(function(a){if(t.isLeafNode(a)&&!o.isNull(a.data.decimal_date_value)){zs(t,a,null,0,0),e=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&!o.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});var s=Ss(e),l=s.r2;l>n&&(n=l,r=a,i=s)}}),{root:r,fit:i}},t.getDistanceMatrix=function(t){let e=s.keys(t)[0],n=t[e].length;return s.mapValues(t,e=>s.map(t,t=>s.sum(s.map(s.range(n),n=>e[n]!=t[n]&&"-"!=e[n]&&"-"!=t[n]))))},t.getNewick=zo,t.inOrder=Ho,t.leftChildRightSibling=jo,t.loadAnnotations=Eo,t.neighborJoining=function t(e,n,r){if(n<=2){let t=new As(""),n=t.getNodes(),i=e[0][1]/2,a=t.createNode(r[0],[null,[i]]),o=t.createNode(r[1],[null,[i]]);return t.addChild(n,a),t.addChild(n,o),t}{let a=n,o=(i=e,s.map(i,s.sum)),l=function(t,e,n){let r=s.chunk(s.fill(Array(n*n),0),n);for(let i of s.range(n))for(let a of s.range(s.parseInt(i)+1,n))r[i][a]=(n-2)*t[i][a]-e[i]-e[a],r[a][i]=r[i][a];return r}(e,o,a),[u,c,h]=function(t,e){let n=-1,r=-1,i=1/0;for(let a of s.range(e))for(let o of s.range(n,e))t[a][o]<i&&(n=a,r=o,i=t[n][r]);return[n,r,i]}(l,a),f=function(t,e){let n=s.chunk(Array(e*e),e);for(let r of s.range(e))for(let i of s.range(parseInt(r)+1,e))n[r][i]=(t[r]-t[i])/(e-2),n[i][r]=n[r][i];return n}(o,a),d=(e[u][c]+f[u][c])/2,p=(e[u][c]-f[u][c])/2,_=s.concat(0,s.filter(s.map(s.range(n),t=>{if(t!=u&&t!=c)return.5*(e[t][u]+e[t][c]-e[u][c])}),s.isNumber)),g=r[u],m=r[c],v="InternalNode0",y=s.filter(r,t=>s.includes(t,"InternalNode"));if(y.length){let t=s.max(s.map(y,t=>s.split(t,"InternalNode")[1]));v="InternalNode"+ ++t}r.unshift(v),e=Ls(s.max([u,c]),e),(e=Ls(s.min([u,c]),e)).unshift(_),s.each(s.range(1,n-1),t=>e[t].unshift(_[t])),s.remove(r,t=>t==g||t==m);let b=t(e,a-1,r),w=b.createNode(g,[null,[d]]),x=b.createNode(m,[null,[p]]);if(b.getNodeByName(v)){let t=b.getNodeByName(v);b.addChild(t,w),b.addChild(t,x)}else{let t=b.createNode(v,[null,[0]]);b.addChild(b.getNodes(),t),b.addChild(t,w),b.addChild(t,x)}return b}var i},t.newickParser=To,t.pairwise_distances=Ts,t.parseAnnotations=So,t.parseFasta=function(t){let e=s.split(t,"\n");return s.chain(e).map((t,e)=>t.startsWith(">")?e:-1).filter(t=>-1!=t).map((t,n,r)=>s.slice(e,r[n],r[n+1])).keyBy(t=>s.trim(t[0],">")).mapValues(t=>s.tail(t).join("")).value()},t.phylopart=function(t,e,n,r,i){r=o.isNumber(r)?r:1;var a=Ts(t),s=t.getRootNode().children[0],l=Number.MAX_VALUE,u=Number.MAX_VALUE;if(!(n>0&&n<1))throw"Invalid percentile threshold in perform_phylopart";t.traverse_and_compute(function(e){t.isLeafNode(e)&&(e.cot_computed_length<l?(l<u&&(u=l),l=e.cot_computed_length):e.cot_computed_length<u&&(u=e.cot_computed_length))}),l+=u;var c=o.reduce(s.cot_path_to_leaves_below,function(t,e){return e>t?e:t},0)+o.reduce(s.cot_path_to_leaves_above,function(t,e){return e>t?e:t},0)+s.cot_computed_length-l;o.isUndefined(i)&&(i=Math.min(.001,c/100));var h=1+(c/i|0);h>500&&(i=c/(h=500));var f=t.getRootNode();f.paths_to_leaves=new Array(a),o.each(f.children,function(t){o.each(f.cot_path_to_leaves_below,function(e,n){f.paths_to_leaves[n]=e+t.cot_computed_length})}),t.traverse_and_compute(function(e){if(!t.isLeafNode(e)){e.histogram=new Array(h);for(var n=0;n<h;n++)e.histogram[n]=0;if(e.parent){var r=0;e.paths_to_leaves=[],o.each(e.cot_path_to_leaves_below,function(t,n){e.paths_to_leaves[r++]=t})}}delete e.cot_path_to_leaves_above,delete e.cot_path_to_leaves_below}),t.traverse_and_compute(function(e){if(!t.isLeafNode(e)){for(var n=0;n<e.paths_to_leaves.length;n++)for(var r=n+1;r<e.paths_to_leaves.length;r++){var a=e.paths_to_leaves[n]+e.paths_to_leaves[r];e.histogram[(a-l)/i|0]++}e.leaf_count=e.paths_to_leaves.length,delete e.paths_to_leaves}});for(var d=(a-1)*a/2*n,p=0;p<h-1&&d>f.histogram[p];p++)d-=f.histogram[p];var _=l+(p+(f.histogram[p]-d)/f.histogram[p])*i,g=[];return t.traverse_and_compute(o.noop,"pre-order",null,function(n){if(!t.isLeafNode(n)){var a=o.isString(n.data.bootstrap_values)?+n.data.bootstrap_values:r;if(a>=e){for(var s=n.leaf_count*(n.leaf_count-1)*.25,u=0;u<h-1&&s>n.histogram[u];u++)s-=n.histogram[u];var c=l+(u+(n.histogram[u]-s)/n.histogram[u])*i;if(c<=_)return g.push({root:n,median:c,bootstrap:a}),!0}}return!1}),t.traverse_and_compute(function(e){t.isLeafNode(e)||"histogram"in e&&(delete e.histogram,delete e.leaf_count)}),o.each(g,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),g},t.phylotree=As,t.postOrder=Po,t.preOrder=Oo,t.rootToTip=Es,t.sackin=function(t){let e=t.getTips(),n=o.map(e,t=>t.depth);return o.reduce(n,function(t,e){return t+e},0)},Object.defineProperty(t,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=phylotree.min.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phylotree",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"main": "dist/phylotree.js",
|
|
5
5
|
"unpkg": "dist/phylotree.js",
|
|
6
6
|
"jsdelivr": "dist/phylotree.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"commander": "^6.2.1",
|
|
26
26
|
"csv-stringify": "^5.3.6",
|
|
27
27
|
"d3": "^7.9.0",
|
|
28
|
+
"fast-xml-parser": "^5.2.5",
|
|
28
29
|
"jquery": "3",
|
|
29
30
|
"lodash": "^4.17.11",
|
|
30
31
|
"moment": "^2.29.4",
|
|
@@ -37,14 +38,14 @@
|
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"concurrently": "^6.2.0",
|
|
39
40
|
"eslint": "^7.32.0",
|
|
40
|
-
"http-server": "^
|
|
41
|
+
"http-server": "^14.1.1",
|
|
41
42
|
"jsdoc-to-markdown": "^7.0.1",
|
|
42
43
|
"prettier": "^2.3.2",
|
|
43
44
|
"rollup": "^2.50.6",
|
|
44
45
|
"rollup-plugin-copy": "^3.3.0",
|
|
45
46
|
"rollup-plugin-execute": "^1.1.1",
|
|
46
47
|
"rollup-plugin-terser": "^7.0.2",
|
|
47
|
-
"rollup-watch": "^
|
|
48
|
+
"rollup-watch": "^3.2.2",
|
|
48
49
|
"tape": "5.2.2",
|
|
49
50
|
"tape-watch": "^2.3.0",
|
|
50
51
|
"yarn": "^1.22.11"
|
package/src/formats/phyloxml.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
2
|
+
|
|
1
3
|
// Changes XML to JSON
|
|
2
4
|
// Modified version from here: http://davidwalsh.name/convert-xml-json
|
|
3
5
|
function xmlToJson(xml) {
|
|
@@ -46,15 +48,18 @@ var phyloxml_parser = function(xml, options) {
|
|
|
46
48
|
|
|
47
49
|
function parsePhyloxml(node, index) {
|
|
48
50
|
if (node.clade) {
|
|
51
|
+
if (!Array.isArray(node.clade)) {
|
|
52
|
+
node.clade = [node.clade];
|
|
53
|
+
}
|
|
49
54
|
node.clade.forEach(parsePhyloxml);
|
|
50
55
|
node.children = node.clade;
|
|
51
56
|
delete node.clade;
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
node.annotation = 1;
|
|
60
|
+
node.attribute = "0.01";
|
|
56
61
|
if (node.branch_length) {
|
|
57
|
-
|
|
62
|
+
node.attribute = node.branch_length;
|
|
58
63
|
}
|
|
59
64
|
if (node.taxonomy) {
|
|
60
65
|
node.name = node.taxonomy.scientific_name;
|
|
@@ -66,8 +71,23 @@ var phyloxml_parser = function(xml, options) {
|
|
|
66
71
|
|
|
67
72
|
var tree_json;
|
|
68
73
|
|
|
74
|
+
if (typeof xml === "string") {
|
|
75
|
+
if (DOMParser) {
|
|
76
|
+
const parser = new DOMParser();
|
|
77
|
+
xml = parser.parseFromString(xml, "text/xml");
|
|
78
|
+
} else {
|
|
79
|
+
const parser = new XMLParser();
|
|
80
|
+
xml = parser.parse(xml);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
69
84
|
xml = xmlToJson(xml);
|
|
70
|
-
|
|
85
|
+
var phylogeny = xml.phyloxml.phylogeny;
|
|
86
|
+
if (Array.isArray(phylogeny)) {
|
|
87
|
+
phylogeny = phylogeny[0];
|
|
88
|
+
console.warn('PhyloXML files with multiple phylogenies are not currently supported. Only the first phylogeny will be loaded.')
|
|
89
|
+
}
|
|
90
|
+
tree_json = phylogeny.clade;
|
|
71
91
|
tree_json.name = "root";
|
|
72
92
|
parsePhyloxml(tree_json, 0);
|
|
73
93
|
|