phylotree 2.1.5 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("underscore"),require("lodash")):"function"==typeof define&&define.amd?define(["exports","underscore","lodash"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phylotree=t.phylotree||{},t._,t._$1)}(this,function(t,e,n){"use strict";function r(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 i=r(e),o=r(n);function s(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function a(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,o=t.length){if(i<o){if(0!==e(r,r))return o;do{const e=i+o>>>1;n(t[e],r)<0?i=e+1:o=e}while(i<o)}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===a?t:l,n=t,r=t),{left:i,center:function(t,e,n=0,o=t.length){const s=i(t,e,n,o-1);return s>n&&r(t[s-1],e)>-r(t[s],e)?s-1:s},right:function(t,r,i=0,o=t.length){if(i<o){if(0!==e(r,r))return o;do{const e=i+o>>>1;n(t[e],r)<=0?i=e+1:o=e}while(i<o)}return i}}}function l(){return 0}const c=u(s).right;u(function(t){return null===t?NaN:+t}).center;var h=c;const p=Math.sqrt(50),f=Math.sqrt(10),d=Math.sqrt(2);function g(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),s=o>=p?10:o>=f?5:o>=d?2:1;let a,u,l;return i<0?(l=Math.pow(10,-i)/s,a=Math.round(t*l),u=Math.round(e*l),a/l<t&&++a,u/l>e&&--u,l=-l):(l=Math.pow(10,i)*s,a=Math.round(t/l),u=Math.round(e/l),a*l<t&&++a,u*l>e&&--u),u<a&&.5<=n&&n<2?g(t,e,2*n):[a,u,l]}function m(t,e,n){return g(t=+t,e=+e,n=+n)[2]}function y(t){return t}var _=1e-6;function v(t){return"translate("+t+",0)"}function w(t){return"translate(0,"+t+")"}function b(t){return e=>+t(e)}function x(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function T(){return!this.__axis}function E(t,e){var n=[],r=null,i=null,o=6,s=6,a=3,u="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,l=1===t||4===t?-1:1,c=4===t||2===t?"x":"y",h=1===t||3===t?v:w;function p(p){var f=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,d=null==i?e.tickFormat?e.tickFormat.apply(e,n):y:i,g=Math.max(o,0)+a,m=e.range(),v=+m[0]+u,w=+m[m.length-1]+u,E=(e.bandwidth?x:b)(e.copy(),u),N=p.selection?p.selection():p,A=N.selectAll(".domain").data([null]),D=N.selectAll(".tick").data(f,e).order(),O=D.exit(),I=D.enter().append("g").attr("class","tick"),C=D.select("line"),M=D.select("text");A=A.merge(A.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),D=D.merge(I),C=C.merge(I.append("line").attr("stroke","currentColor").attr(c+"2",l*o)),M=M.merge(I.append("text").attr("fill","currentColor").attr(c,l*g).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),p!==N&&(A=A.transition(p),D=D.transition(p),C=C.transition(p),M=M.transition(p),O=O.transition(p).attr("opacity",_).attr("transform",function(t){return isFinite(t=E(t))?h(t+u):this.getAttribute("transform")}),I.attr("opacity",_).attr("transform",function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:E(t))+u)})),O.remove(),A.attr("d",4===t||2===t?s?"M"+l*s+","+v+"H"+u+"V"+w+"H"+l*s:"M"+u+","+v+"V"+w:s?"M"+v+","+l*s+"V"+u+"H"+w+"V"+l*s:"M"+v+","+u+"H"+w),D.attr("opacity",1).attr("transform",function(t){return h(E(t)+u)}),C.attr(c+"2",l*o),M.attr(c,l*g).text(d),N.filter(T).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=E})}return p.scale=function(t){return arguments.length?(e=t,p):e},p.ticks=function(){return n=Array.from(arguments),p},p.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),p):n.slice()},p.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),p):r&&r.slice()},p.tickFormat=function(t){return arguments.length?(i=t,p):i},p.tickSize=function(t){return arguments.length?(o=s=+t,p):o},p.tickSizeInner=function(t){return arguments.length?(o=+t,p):o},p.tickSizeOuter=function(t){return arguments.length?(s=+t,p):s},p.tickPadding=function(t){return arguments.length?(a=+t,p):a},p.offset=function(t){return arguments.length?(u=+t,p):u},p}var N={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 D(r)}function D(t){this._=t}function O(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function I(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=N,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}D.prototype=A.prototype={constructor:D,on:function(t,e){var n,r,i=this._,o=(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}})),s=-1,a=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(n=(t=o[s]).type)i[n]=I(i[n],t.name,e);else if(null==e)for(n in i)i[n]=I(i[n],t.name,null);return this}for(;++s<a;)if((n=(t=o[s]).type)&&(n=O(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new D(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].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,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var C="http://www.w3.org/1999/xhtml",M={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 S(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),M.hasOwnProperty(e)?{space:M[e],local:t}:t}function P(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 k(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function L(t){var e=S(t);return(e.local?k:P)(e)}function R(){}function F(t){return null==t?R:function(){return this.querySelector(t)}}function j(){return[]}function U(t){return null==t?j:function(){return this.querySelectorAll(t)}}function z(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function B(t){return function(){return this.matches(t)}}function V(t){return function(e){return e.matches(t)}}var Y=Array.prototype.find;function $(){return this.firstElementChild}var q=Array.prototype.filter;function H(){return Array.from(this.children)}function X(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 W(t,e,n,r,i,o){for(var s,a=0,u=e.length,l=o.length;a<l;++a)(s=e[a])?(s.__data__=o[a],r[a]=s):n[a]=new G(t,o[a]);for(;a<u;++a)(s=e[a])&&(i[a]=s)}function K(t,e,n,r,i,o,s){var a,u,l,c=new Map,h=e.length,p=o.length,f=new Array(h);for(a=0;a<h;++a)(u=e[a])&&(f[a]=l=s.call(u,u.__data__,a,e)+"",c.has(l)?i[a]=u:c.set(l,u));for(a=0;a<p;++a)l=s.call(t,o[a],a,o)+"",(u=c.get(l))?(r[a]=u,u.__data__=o[a],c.delete(l)):n[a]=new G(t,o[a]);for(a=0;a<h;++a)(u=e[a])&&c.get(f[a])===u&&(i[a]=u)}function Z(t){return t.__data__}function Q(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function J(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function tt(t){return function(){this.removeAttribute(t)}}function et(t){return function(){this.removeAttributeNS(t.space,t.local)}}function nt(t,e){return function(){this.setAttribute(t,e)}}function rt(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function it(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 at(t){return function(){this.style.removeProperty(t)}}function ut(t,e,n){return function(){this.style.setProperty(t,e,n)}}function lt(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ct(t,e){return t.style.getPropertyValue(e)||st(t).getComputedStyle(t,null).getPropertyValue(e)}function ht(t){return function(){delete this[t]}}function pt(t,e){return function(){this[t]=e}}function ft(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function dt(t){return t.trim().split(/^|\s+/)}function gt(t){return t.classList||new mt(t)}function mt(t){this._node=t,this._names=dt(t.getAttribute("class")||"")}function yt(t,e){for(var n=gt(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function _t(t,e){for(var n=gt(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function vt(t){return function(){yt(this,t)}}function wt(t){return function(){_t(this,t)}}function bt(t,e){return function(){(e.apply(this,arguments)?yt:_t)(this,t)}}function xt(){this.textContent=""}function Tt(t){return function(){this.textContent=t}}function Et(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Nt(){this.innerHTML=""}function At(t){return function(){this.innerHTML=t}}function Dt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function Ot(){this.nextSibling&&this.parentNode.appendChild(this)}function It(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ct(){return null}function Mt(){var t=this.parentNode;t&&t.removeChild(this)}function St(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Pt(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function kt(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r<o;++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 Lt(t,e,n){return function(){var r,i=this.__on,o=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var s=0,a=i.length;s<a;++s)if((r=i[s]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),void(r.value=e);this.addEventListener(t.type,o,n),r={type:t.type,name:t.name,value:e,listener:o,options:n},i?i.push(r):this.__on=[r]}}function Rt(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 Ft(t,e){return function(){return Rt(this,t,e)}}function jt(t,e){return function(){return Rt(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)}},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 Ut=[null];function zt(t,e){this._groups=t,this._parents=e}function Bt(){return new zt([[document.documentElement]],Ut)}function Vt(t){return"string"==typeof t?new zt([[document.querySelector(t)]],[document.documentElement]):new zt([[t]],Ut)}function Yt(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]}zt.prototype=Bt.prototype={constructor:zt,select:function(t){"function"!=typeof t&&(t=F(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s,a=e[i],u=a.length,l=r[i]=new Array(u),c=0;c<u;++c)(o=a[c])&&(s=t.call(o,o.__data__,c,a))&&("__data__"in o&&(s.__data__=o.__data__),l[c]=s);return new zt(r,this._parents)},selectAll:function(t){t="function"==typeof t?z(t):U(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var s,a=e[o],u=a.length,l=0;l<u;++l)(s=a[l])&&(r.push(t.call(s,s.__data__,l,a)),i.push(s));return new zt(r,i)},selectChild:function(t){return this.select(null==t?$:function(t){return function(){return Y.call(this.children,t)}}("function"==typeof t?t:V(t)))},selectChildren:function(t){return this.selectAll(null==t?H:function(t){return function(){return q.call(this.children,t)}}("function"==typeof t?t:V(t)))},filter:function(t){"function"!=typeof t&&(t=B(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s=e[i],a=s.length,u=r[i]=[],l=0;l<a;++l)(o=s[l])&&t.call(o,o.__data__,l,s)&&u.push(o);return new zt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,Z);var n=e?K:W,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var o=i.length,s=new Array(o),a=new Array(o),u=new Array(o),l=0;l<o;++l){var c=r[l],h=i[l],p=h.length,f=Q(t.call(c,c&&c.__data__,l,r)),d=f.length,g=a[l]=new Array(d),m=s[l]=new Array(d);n(c,h,g,m,u[l]=new Array(p),f,e);for(var y,_,v=0,w=0;v<d;++v)if(y=g[v]){for(v>=w&&(w=v+1);!(_=m[w])&&++w<d;);y._next=_||null}}return(s=new zt(s,r))._enter=a,s._exit=u,s},enter:function(){return new zt(this._enter||this._groups.map(X),this._parents)},exit:function(){return new zt(this._exit||this._groups.map(X),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,o=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?o.remove():n(o),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,o=r.length,s=Math.min(i,o),a=new Array(i),u=0;u<s;++u)for(var l,c=n[u],h=r[u],p=c.length,f=a[u]=new Array(p),d=0;d<p;++d)(l=c[d]||h[d])&&(f[d]=l);for(;u<i;++u)a[u]=n[u];return new zt(a,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],o=i.length-1,s=i[o];--o>=0;)(r=i[o])&&(s&&4^r.compareDocumentPosition(s)&&s.parentNode.insertBefore(r,s),s=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=J);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s,a=n[o],u=a.length,l=i[o]=new Array(u),c=0;c<u;++c)(s=a[c])&&(l[c]=s);l.sort(e)}return new zt(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,o=r.length;i<o;++i){var s=r[i];if(s)return s}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,o=e[n],s=0,a=o.length;s<a;++s)(i=o[s])&&t.call(i,i.__data__,s,o);return this},attr:function(t,e){var n=S(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?et:tt:"function"==typeof e?n.local?ot:it:n.local?rt:nt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?at:"function"==typeof e?lt:ut)(t,e,null==n?"":n)):ct(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ht:"function"==typeof e?ft:pt)(t,e)):this.node()[t]},classed:function(t,e){var n=dt(t+"");if(arguments.length<2){for(var r=gt(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?bt:e?vt:wt)(n,e))},text:function(t){return arguments.length?this.each(null==t?xt:("function"==typeof t?Et:Tt)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Nt:("function"==typeof t?Dt:At)(t)):this.node().innerHTML},raise:function(){return this.each(Ot)},lower:function(){return this.each(It)},append:function(t){var e="function"==typeof t?t:L(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:L(t),r=null==e?Ct:"function"==typeof e?e:F(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(Mt)},clone:function(t){return this.select(t?Pt:St)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,o=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+""),s=o.length;if(!(arguments.length<2)){for(a=e?Lt:kt,r=0;r<s;++r)this.each(a(o[r],e,n));return this}var a=this.node().__on;if(a)for(var u,l=0,c=a.length;l<c;++l)for(r=0,u=a[l];r<s;++r)if((i=o[r]).type===u.type&&i.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?jt:Ft)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],o=0,s=i.length;o<s;++o)(r=i[o])&&(yield r)}};const $t={capture:!0,passive:!1};function qt(t){t.preventDefault(),t.stopImmediatePropagation()}function Ht(t){var e=t.document.documentElement,n=Vt(t).on("dragstart.drag",qt,$t);"onselectstart"in e?n.on("selectstart.drag",qt,$t):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Xt(t,e){var n=t.document.documentElement,r=Vt(t).on("dragstart.drag",null);e&&(r.on("click.drag",qt,$t),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 Wt(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Kt(){}var Zt=.7,Qt=1/Zt,Jt="\\s*([+-]?\\d+)\\s*",te="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ne=/^#([0-9a-f]{3,8})$/,re=new RegExp(`^rgb\\(${Jt},${Jt},${Jt}\\)$`),ie=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),oe=new RegExp(`^rgba\\(${Jt},${Jt},${Jt},${te}\\)$`),se=new RegExp(`^rgba\\(${ee},${ee},${ee},${te}\\)$`),ae=new RegExp(`^hsl\\(${te},${ee},${ee}\\)$`),ue=new RegExp(`^hsla\\(${te},${ee},${ee},${te}\\)$`),le={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 ce(){return this.rgb().formatHex()}function he(){return this.rgb().formatRgb()}function pe(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ne.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?fe(e):3===n?new me(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?de(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?de(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=re.exec(t))?new me(e[1],e[2],e[3],1):(e=ie.exec(t))?new me(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=oe.exec(t))?de(e[1],e[2],e[3],e[4]):(e=se.exec(t))?de(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=ae.exec(t))?xe(e[1],e[2]/100,e[3]/100,1):(e=ue.exec(t))?xe(e[1],e[2]/100,e[3]/100,e[4]):le.hasOwnProperty(t)?fe(le[t]):"transparent"===t?new me(NaN,NaN,NaN,0):null}function fe(t){return new me(t>>16&255,t>>8&255,255&t,1)}function de(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=pe(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 ye(){return`#${be(this.r)}${be(this.g)}${be(this.b)}`}function _e(){const t=ve(this.opacity);return`${1===t?"rgb(":"rgba("}${we(this.r)}, ${we(this.g)}, ${we(this.b)}${1===t?")":`, ${t})`}`}function ve(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 be(t){return((t=we(t))<16?"0":"")+t.toString(16)}function xe(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ee(t,e,n,r)}function Te(t){if(t instanceof Ee)return new Ee(t.h,t.s,t.l,t.opacity);if(t instanceof Kt||(t=pe(t)),!t)return new Ee;if(t instanceof Ee)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),s=NaN,a=o-i,u=(o+i)/2;return a?(s=e===o?(n-r)/a+6*(n<r):n===o?(r-e)/a+2:(e-n)/a+4,a/=u<.5?o+i:2-o-i,s*=60):a=u>0&&u<1?0:s,new Ee(s,a,u,t.opacity)}function Ee(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Ne(t){return(t=(t||0)%360)<0?t+360:t}function Ae(t){return Math.max(0,Math.min(1,t||0))}function De(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(Kt,pe,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:ce,formatHex:ce,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Te(this).formatHsl()},formatRgb:he,toString:he}),Gt(me,ge,Wt(Kt,{brighter(t){return t=null==t?Qt:Math.pow(Qt,t),new me(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Zt:Math.pow(Zt,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),ve(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`#${be(this.r)}${be(this.g)}${be(this.b)}${be(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:_e,toString:_e})),Gt(Ee,function(t,e,n,r){return 1===arguments.length?Te(t):new Ee(t,e,n,null==r?1:r)},Wt(Kt,{brighter(t){return t=null==t?Qt:Math.pow(Qt,t),new Ee(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Zt:Math.pow(Zt,t),new Ee(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(De(t>=240?t-240:t+120,i,r),De(t,i,r),De(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ee(Ne(this.h),Ae(this.s),Ae(this.l),ve(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=ve(this.opacity);return`${1===t?"hsl(":"hsla("}${Ne(this.h)}, ${100*Ae(this.s)}%, ${100*Ae(this.l)}%${1===t?")":`, ${t})`}`}}));var Oe=t=>()=>t;function Ie(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):Oe(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):Oe(isNaN(t)?e:t)}var Me=function t(e){var n=Ie(e);function r(t,e){var r=n((t=ge(t)).r,(e=ge(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),s=Ce(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=s(e),t+""}}return r.gamma=t,r}(1);function Se(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(o){for(n=0;n<r;++n)i[n]=t[n]*(1-o)+e[n]*o;return i}}function Pe(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,o=new Array(i),s=new Array(r);for(n=0;n<i;++n)o[n]=ze(t[n],e[n]);for(;n<r;++n)s[n]=e[n];return function(t){for(n=0;n<i;++n)s[n]=o[n](t);return s}}function ke(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Le(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Re(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]=ze(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var Fe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,je=new RegExp(Fe.source,"g");function Ue(t,e){var n,r,i,o=Fe.lastIndex=je.lastIndex=0,s=-1,a=[],u=[];for(t+="",e+="";(n=Fe.exec(t))&&(r=je.exec(e));)(i=r.index)>o&&(i=e.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,u.push({i:s,x:Le(n,r)})),o=je.lastIndex;return o<e.length&&(i=e.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,r=0;r<e;++r)a[(n=u[r]).i]=n.x(t);return a.join("")})}function ze(t,e){var n,r=typeof e;return null==e||"boolean"===r?Oe(e):("number"===r?Le:"string"===r?(n=pe(e))?(e=n,Me):Ue:e instanceof pe?Me:e instanceof Date?ke:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?Se:Array.isArray(e)?Pe:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?Re:Le)(t,e)}function Be(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Ve,Ye=180/Math.PI,$e={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function qe(t,e,n,r,i,o){var s,a,u;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,u/=a),t*r<e*n&&(t=-t,e=-e,u=-u,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*Ye,skewX:Math.atan(u)*Ye,scaleX:s,scaleY:a}}function He(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(o,s){var a=[],u=[];return o=t(o),s=t(s),function(t,r,i,o,s,a){if(t!==i||r!==o){var u=s.push("translate(",null,e,null,n);a.push({i:u-4,x:Le(t,i)},{i:u-2,x:Le(r,o)})}else(i||o)&&s.push("translate("+i+e+o+n)}(o.translateX,o.translateY,s.translateX,s.translateY,a,u),function(t,e,n,o){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Le(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,s.rotate,a,u),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Le(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,s.skewX,a,u),function(t,e,n,r,o,s){if(t!==n||e!==r){var a=o.push(i(o)+"scale(",null,",",null,")");s.push({i:a-4,x:Le(t,n)},{i:a-2,x:Le(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,s.scaleX,s.scaleY,a,u),o=s=null,function(t){for(var e,n=-1,r=u.length;++n<r;)a[(e=u[n]).i]=e.x(t);return a.join("")}}}var Xe=He(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?$e:qe(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Ge=He(function(t){return null==t?$e:(Ve||(Ve=document.createElementNS("http://www.w3.org/2000/svg","g")),Ve.setAttribute("transform",t),(t=Ve.transform.baseVal.consolidate())?qe((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):$e)},", ",")",")");function We(t){return((t=Math.exp(t))+1/t)/2}var Ke,Ze,Qe=function t(e,n,r){function i(t,i){var o,s,a=t[0],u=t[1],l=t[2],c=i[0],h=i[1],p=i[2],f=c-a,d=h-u,g=f*f+d*d;if(g<1e-12)s=Math.log(p/l)/e,o=function(t){return[a+t*f,u+t*d,l*Math.exp(e*t*s)]};else{var m=Math.sqrt(g),y=(p*p-l*l+r*g)/(2*l*n*m),_=(p*p-l*l-r*g)/(2*p*n*m),v=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(_*_+1)-_);s=(w-v)/e,o=function(t){var r=t*s,i=We(v),o=l/(n*m)*(i*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*r+v)-function(t){return((t=Math.exp(t))-1/t)/2}(v));return[a+o*f,u+o*d,l*i/We(e*r+v)]}}return o.duration=1e3*s*e/Math.SQRT2,o}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),Je=0,tn=0,en=0,nn=0,rn=0,on=0,sn="object"==typeof performance&&performance.now?performance:Date,an="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function un(){return rn||(an(ln),rn=sn.now()+on)}function ln(){rn=0}function cn(){this._call=this._time=this._next=null}function hn(t,e,n){var r=new cn;return r.restart(t,e,n),r}function pn(){rn=(nn=sn.now())+on,Je=tn=0;try{!function(){un(),++Je;for(var t,e=Ke;e;)(t=rn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Je}()}finally{Je=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);Ze=t,dn(r)}(),rn=0}}function fn(){var t=sn.now(),e=t-nn;e>1e3&&(on-=e,nn=t)}function dn(t){Je||(tn&&(tn=clearTimeout(tn)),t-rn>24?(t<1/0&&(tn=setTimeout(pn,t-sn.now()-on)),en&&(en=clearInterval(en))):(en||(nn=sn.now(),en=setInterval(fn,1e3)),Je=1,an(pn)))}function gn(t,e,n){var r=new cn;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}cn.prototype=hn.prototype={constructor:cn,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||Ze===this||(Ze?Ze._next=this:Ke=this,Ze=this),this._call=t,this._time=n,dn()},stop:function(){this._call&&(this._call=null,this._time=1/0,dn())}};var mn=A("start","end","cancel","interrupt"),yn=[];function _n(t,e,n,r,i,o){var s=t.__transition;if(s){if(n in s)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=1,n.timer.restart(s,n.delay,n.time),n.delay<=t&&s(t-n.delay)}function s(o){var l,c,h,p;if(1!==n.state)return u();for(l in i)if((p=i[l]).name===n.name){if(3===p.state)return gn(s);4===p.state?(p.state=6,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete i[l]):+l<e&&(p.state=6,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete i[l])}if(gn(function(){3===n.state&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(o))}),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),l=0,c=-1;l<h;++l)(p=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=p);r.length=c+1}}function a(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=5,1),o=-1,s=r.length;++o<s;)r[o].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=hn(o,0,n.time)}(t,n,{name:e,index:r,group:i,on:mn,tween:yn,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function vn(t,e){var n=bn(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function wn(t,e){var n=bn(t,e);if(n.state>3)throw new Error("too late; already running");return n}function bn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function xn(t,e){var n,r,i,o=t.__transition,s=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[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 o[i]):s=!1;s&&delete t.__transition}}function Tn(t,e){var n,r;return function(){var i=wn(this,t),o=i.tween;if(o!==n)for(var s=0,a=(r=n=o).length;s<a;++s)if(r[s].name===e){(r=r.slice()).splice(s,1);break}i.tween=r}}function En(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var o=wn(this,t),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:e,value:n},u=0,l=i.length;u<l;++u)if(i[u].name===e){i[u]=a;break}u===l&&i.push(a)}o.tween=i}}function Nn(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 bn(t,r).value[e]}}function An(t,e){var n;return("number"==typeof e?Le:e instanceof pe?Me:(n=pe(e))?(e=n,Me):Ue)(t,e)}function Dn(t){return function(){this.removeAttribute(t)}}function On(t){return function(){this.removeAttributeNS(t.space,t.local)}}function In(t,e,n){var r,i,o=n+"";return function(){var s=this.getAttribute(t);return s===o?null:s===r?i:i=e(r=s,n)}}function Cn(t,e,n){var r,i,o=n+"";return function(){var s=this.getAttributeNS(t.space,t.local);return s===o?null:s===r?i:i=e(r=s,n)}}function Mn(t,e,n){var r,i,o;return function(){var s,a,u=n(this);if(null!=u)return(s=this.getAttribute(t))===(a=u+"")?null:s===r&&a===i?o:(i=a,o=e(r=s,u));this.removeAttribute(t)}}function Sn(t,e,n){var r,i,o;return function(){var s,a,u=n(this);if(null!=u)return(s=this.getAttributeNS(t.space,t.local))===(a=u+"")?null:s===r&&a===i?o:(i=a,o=e(r=s,u));this.removeAttributeNS(t.space,t.local)}}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.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,i)),n}return i._value=e,i}function kn(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 Ln(t,e){return function(){vn(this,t).delay=+e.apply(this,arguments)}}function Rn(t,e){return e=+e,function(){vn(this,t).delay=e}}function Fn(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 Un=Bt.prototype.constructor;function zn(t){return function(){this.style.removeProperty(t)}}var Bn=0;function Vn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Yn(){return++Bn}var $n=Bt.prototype;Vn.prototype={constructor:Vn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=F(t));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a,u,l=r[s],c=l.length,h=o[s]=new Array(c),p=0;p<c;++p)(a=l[p])&&(u=t.call(a,a.__data__,p,l))&&("__data__"in a&&(u.__data__=a.__data__),h[p]=u,_n(h[p],e,n,p,h,bn(a,n)));return new Vn(o,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=U(t));for(var r=this._groups,i=r.length,o=[],s=[],a=0;a<i;++a)for(var u,l=r[a],c=l.length,h=0;h<c;++h)if(u=l[h]){for(var p,f=t.call(u,u.__data__,h,l),d=bn(u,n),g=0,m=f.length;g<m;++g)(p=f[g])&&_n(p,e,n,g,f,d);o.push(f),s.push(u)}return new Vn(o,s,e,n)},selectChild:$n.selectChild,selectChildren:$n.selectChildren,filter:function(t){"function"!=typeof t&&(t=B(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s=e[i],a=s.length,u=r[i]=[],l=0;l<a;++l)(o=s[l])&&t.call(o,o.__data__,l,s)&&u.push(o);return new Vn(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,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var u,l=e[a],c=n[a],h=l.length,p=s[a]=new Array(h),f=0;f<h;++f)(u=l[f]||c[f])&&(p[f]=u);for(;a<r;++a)s[a]=e[a];return new Vn(s,this._parents,this._name,this._id)},selection:function(){return new Un(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=Yn(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s,a=r[o],u=a.length,l=0;l<u;++l)if(s=a[l]){var c=bn(s,e);_n(s,t,n,l,a,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Vn(r,this._parents,t,n)},call:$n.call,nodes:$n.nodes,node:$n.node,size:$n.size,empty:$n.empty,each:$n.each,on:function(t,e){var n=this._id;return arguments.length<2?bn(this.node(),n).on.on(t):this.each(function(t,e,n){var r,i,o=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)?vn:wn;return function(){var s=o(this,t),a=s.on;a!==r&&(i=(r=a).copy()).on(e,n),s.on=i}}(n,t,e))},attr:function(t,e){var n=S(t),r="transform"===n?Ge:An;return this.attrTween(t,"function"==typeof e?(n.local?Sn:Mn)(n,r,Nn(this,"attr."+t,e)):null==e?(n.local?On:Dn)(n):(n.local?Cn:In)(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=S(t);return this.tween(n,(r.local?Pn:kn)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Xe:An;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var o=ct(this,t),s=(this.style.removeProperty(t),ct(this,t));return o===s?null:o===n&&s===r?i:i=e(n=o,r=s)}}(t,r)).on("end.style."+t,zn(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,o;return function(){var s=ct(this,t),a=n(this),u=a+"";return null==a&&(this.style.removeProperty(t),u=a=ct(this,t)),s===u?null:s===r&&u===i?o:(i=u,o=e(r=s,a))}}(t,r,Nn(this,"style."+t,e))).each(function(t,e){var n,r,i,o,s="style."+e,a="end."+s;return function(){var u=wn(this,t),l=u.on,c=null==u.value[s]?o||(o=zn(e)):void 0;l===n&&i===c||(r=(n=l).copy()).on(a,i=c),u.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,o=n+"";return function(){var s=ct(this,t);return s===o?null:s===r?i:i=e(r=s,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 o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,o,n)),r}return o._value=e,o}(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}}(Nn(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=bn(this.node(),n).tween,o=0,s=i.length;o<s;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==e?Tn:En)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Ln:Rn)(e,t)):bn(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Fn:jn)(e,t)):bn(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)):bn(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(o,s){var a={value:s},u={value:function(){0===--i&&o()}};n.each(function(){var n=wn(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(a),e._.interrupt.push(a),e._.end.push(u)),n.on=e}),0===i&&o()})},[Symbol.iterator]:$n[Symbol.iterator]};var qn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Hn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}Bt.prototype.interrupt=function(t){return this.each(function(){xn(this,t)})},Bt.prototype.transition=function(t){var e,n;t instanceof Vn?(e=t._id,t=t._name):(e=Yn(),(n=qn).time=un(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s,a=r[o],u=a.length,l=0;l<u;++l)(s=a[l])&&_n(s,t,e,l,a,n||Hn(s,e));return new Vn(r,this._parents,t,e)};var Xn=t=>()=>t;function Gn(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:o}){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:o}})}function Wn(t){t.preventDefault(),t.stopImmediatePropagation()}var Kn={name:"drag"},Zn={name:"space"},Qn={name:"handle"},Jn={name:"center"};const{abs:tr,max:er,min:nr}=Math;function rr(t){return[+t[0],+t[1]]}function ir(t){return[rr(t[0]),rr(t[1])]}var or={name:"x",handles:["w","e"].map(fr),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(fr),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]]}},ar={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(fr),input:function(t){return null==t?null:ir(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"},lr={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},cr={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},hr={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 fr(t){return{type:t}}function dr(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 yr(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function _r(){return function(t){var e,n=gr,r=dr,i=mr,o=!0,s=A("start","brush","end"),a=6;function u(e){var n=e.property("__brush",g).selectAll(".overlay").data([fr("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",ur.overlay).merge(n).each(function(){var t=yr(this).extent;Vt(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([fr("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(l).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",p).filter(i).on("touchstart.brush",p).on("touchmove.brush",f).on("touchend.brush touchcancel.brush",d).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function l(){var t=Vt(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]-a/2:e[0][0]-a/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-a/2:e[0][1]-a/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+a:a}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+a:a})):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 p(n){if((!e||n.touches)&&r.apply(this,arguments)){var i,s,a,u,h,p,f,d,g,m,y,_=this,v=n.target.__data__.type,w="selection"===(o&&n.metaKey?v="overlay":v)?Kn:o&&n.altKey?Jn:Qn,b=t===sr?null:hr[v],x=t===or?null:pr[v],T=yr(_),E=T.extent,N=T.selection,A=E[0][0],D=E[0][1],O=E[1][0],I=E[1][1],C=0,M=0,S=b&&x&&o&&n.shiftKey,P=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=Yt(t,_)).point0=t.slice(),t.identifier=e,t});xn(_);var k=c(_,arguments,!0).beforestart();if("overlay"===v){N&&(g=!0);const e=[P[0],P[1]||P[0]];T.selection=N=[[i=t===sr?A:nr(e[0][0],e[1][0]),a=t===or?D:nr(e[0][1],e[1][1])],[h=t===sr?O:er(e[0][0],e[1][0]),f=t===or?I:er(e[0][1],e[1][1])]],P.length>1&&U(n)}else i=N[0][0],a=N[0][1],h=N[1][0],f=N[1][1];s=i,u=a,p=h,d=f;var L=Vt(_).attr("pointer-events","none"),R=L.selectAll(".overlay").attr("cursor",ur[v]);if(n.touches)k.moved=j,k.ended=z;else{var F=Vt(n.view).on("mousemove.brush",j,!0).on("mouseup.brush",z,!0);o&&F.on("keydown.brush",B,!0).on("keyup.brush",V,!0),Ht(n.view)}l.call(_),k.start(n,w.name)}function j(t){for(const e of t.changedTouches||[t])for(const t of P)t.identifier===e.identifier&&(t.cur=Yt(e,_));if(S&&!m&&!y&&1===P.length){const t=P[0];tr(t.cur[0]-t[0])>tr(t.cur[1]-t[1])?y=!0:m=!0}for(const t of P)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);g=!0,Wn(t),U(t)}function U(t){const e=P[0],n=e.point0;var r;switch(C=e[0]-n[0],M=e[1]-n[1],w){case Zn:case Kn:b&&(C=er(A-i,nr(O-h,C)),s=i+C,p=h+C),x&&(M=er(D-a,nr(I-f,M)),u=a+M,d=f+M);break;case Qn:P[1]?(b&&(s=er(A,nr(O,P[0][0])),p=er(A,nr(O,P[1][0])),b=1),x&&(u=er(D,nr(I,P[0][1])),d=er(D,nr(I,P[1][1])),x=1)):(b<0?(C=er(A-i,nr(O-i,C)),s=i+C,p=h):b>0&&(C=er(A-h,nr(O-h,C)),s=i,p=h+C),x<0?(M=er(D-a,nr(I-a,M)),u=a+M,d=f):x>0&&(M=er(D-f,nr(I-f,M)),u=a,d=f+M));break;case Jn:b&&(s=er(A,nr(O,i-C*b)),p=er(A,nr(O,h+C*b))),x&&(u=er(D,nr(I,a-M*x)),d=er(D,nr(I,f+M*x)))}p<s&&(b*=-1,r=i,i=h,h=r,r=s,s=p,p=r,v in lr&&R.attr("cursor",ur[v=lr[v]])),d<u&&(x*=-1,r=a,a=f,f=r,r=u,u=d,d=r,v in cr&&R.attr("cursor",ur[v=cr[v]])),T.selection&&(N=T.selection),m&&(s=N[0][0],p=N[1][0]),y&&(u=N[0][1],d=N[1][1]),N[0][0]===s&&N[0][1]===u&&N[1][0]===p&&N[1][1]===d||(T.selection=[[s,u],[p,d]],l.call(_),k.brush(t,w.name))}function z(t){if(function(t){t.stopImmediatePropagation()}(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else Xt(t.view,g),F.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);L.attr("pointer-events","all"),R.attr("cursor",ur.overlay),T.selection&&(N=T.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(N)&&(T.selection=null,l.call(_)),k.end(t,w.name)}function B(t){switch(t.keyCode){case 16:S=b&&x;break;case 18:w===Qn&&(b&&(h=p-C*b,i=s+C*b),x&&(f=d-M*x,a=u+M*x),w=Jn,U(t));break;case 32:w!==Qn&&w!==Jn||(b<0?h=p-C:b>0&&(i=s-C),x<0?f=d-M:x>0&&(a=u-M),w=Zn,R.attr("cursor",ur.selection),U(t));break;default:return}Wn(t)}function V(t){switch(t.keyCode){case 16:S&&(m=y=S=!1,U(t));break;case 18:w===Jn&&(b<0?h=p:b>0&&(i=s),x<0?f=d:x>0&&(a=u),w=Qn,U(t));break;case 32:w===Zn&&(t.altKey?(b&&(h=p-C*b,i=s+C*b),x&&(f=d-M*x,a=u+M*x),w=Jn):(b<0?h=p:b>0&&(i=s),x<0?f=d:x>0&&(a=u),w=Qn),R.attr("cursor",ur[v]),U(t));break;default:return}Wn(t)}}function f(t){c(this,arguments).moved(t)}function d(t){c(this,arguments).ended(t)}function g(){var e=this.__brush||{selection:null};return e.extent=ir(n.apply(this,arguments)),e.dim=t,e}return u.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),o=r.selection,s=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),a=ze(o,s);function u(t){r.selection=1===t&&null===s?null:a(t),l.call(e),i.brush()}return null!==o&&null!==s?u:u(1)}):e.each(function(){var e=this,i=arguments,o=e.__brush,s=t.input("function"==typeof n?n.apply(e,i):n,o.extent),a=c(e,i).beforestart();xn(e),o.selection=null===s?null:s,l.call(e),a.start(r).brush(r).end(r)})},u.clear=function(t,e){u.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=Vt(this.that).datum();s.call(e,this.that,new Gn(e,{sourceEvent:n,target:u,selection:t.output(this.state.selection),mode:r,dispatch:s}),i)}},u.extent=function(t){return arguments.length?(n="function"==typeof t?t:Xn(ir(t)),u):n},u.filter=function(t){return arguments.length?(r="function"==typeof t?t:Xn(!!t),u):r},u.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Xn(!!t),u):i},u.handleSize=function(t){return arguments.length?(a=+t,u):a},u.keyModifiers=function(t){return arguments.length?(o=!!t,u):o},u.on=function(){var t=s.on.apply(s,arguments);return t===s?u:t},u}(ar)}const vr=Math.PI,wr=2*vr,br=1e-6,xr=wr-br;function Tr(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class Er{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?Tr:function(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return Tr;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,o){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+o}`}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 o=this._x1,s=this._y1,a=n-t,u=r-e,l=o-t,c=s-e,h=l*l+c*c;if(null===this._x1)this._append`M${this._x1=t},${this._y1=e}`;else if(h>br)if(Math.abs(c*a-u*l)>br&&i){let p=n-o,f=r-s,d=a*a+u*u,g=p*p+f*f,m=Math.sqrt(d),y=Math.sqrt(h),_=i*Math.tan((vr-Math.acos((d+h-g)/(2*m*y)))/2),v=_/y,w=_/m;Math.abs(v-1)>br&&this._append`L${t+v*l},${e+v*c}`,this._append`A${i},${i},0,0,${+(c*p>l*f)},${this._x1=t+w*a},${this._y1=e+w*u}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,o){if(t=+t,e=+e,o=!!o,(n=+n)<0)throw new Error(`negative radius: ${n}`);let s=n*Math.cos(r),a=n*Math.sin(r),u=t+s,l=e+a,c=1^o,h=o?r-i:i-r;null===this._x1?this._append`M${u},${l}`:(Math.abs(this._x1-u)>br||Math.abs(this._y1-l)>br)&&this._append`L${u},${l}`,n&&(h<0&&(h=h%wr+wr),h>xr?this._append`A${n},${n},0,1,${c},${t-s},${e-a}A${n},${n},0,1,${c},${this._x1=u},${this._y1=l}`:h>br&&this._append`A${n},${n},0,${+(h>=vr)},${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 Nr(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=Nr(Math.abs(t)))?t[1]:NaN}var Dr,Or=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Ir(t){if(!(e=Or.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 Mr(t,e){var n=Nr(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")}Ir.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 Sr={"%":(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)=>Mr(100*t,e),r:Mr,s:function(t,e){var n=Nr(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(Dr=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,s=r.length;return o===s?r:o>s?r+new Array(o-s+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Nr(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Pr(t){return t}var kr,Lr,Rr,Fr=Array.prototype.map,jr=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Ur(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Pr:(e=Fr.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,o=[],s=0,a=e[0],u=0;i>0&&a>0&&(u+a+1>r&&(a=Math.max(1,r-u)),o.push(t.substring(i-=a,i+a)),!((u+=a+1)>r));)a=e[s=(s+1)%e.length];return o.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",s=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?Pr:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(Fr.call(t.numerals,String)),u=void 0===t.percent?"%":t.percent+"",l=void 0===t.minus?"−":t.minus+"",c=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=Ir(t)).fill,n=t.align,h=t.sign,p=t.symbol,f=t.zero,d=t.width,g=t.comma,m=t.precision,y=t.trim,_=t.type;"n"===_?(g=!0,_="g"):Sr[_]||(void 0===m&&(m=12),y=!0,_="g"),(f||"0"===e&&"="===n)&&(f=!0,e="0",n="=");var v="$"===p?i:"#"===p&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",w="$"===p?o:/[%p]/.test(_)?u:"",b=Sr[_],x=/[defgprs%]/.test(_);function T(t){var i,o,u,p=v,T=w;if("c"===_)T=b(t)+T,t="";else{var E=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:b(Math.abs(t),m),y&&(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)),E&&0===+t&&"+"!==h&&(E=!1),p=(E?"("===h?h:l:"-"===h||"("===h?"":h)+p,T=("s"===_?jr[8+Dr/3]:"")+T+(E&&"("===h?")":""),x)for(i=-1,o=t.length;++i<o;)if(48>(u=t.charCodeAt(i))||u>57){T=(46===u?s+t.slice(i+1):t.slice(i))+T,t=t.slice(0,i);break}}g&&!f&&(t=r(t,1/0));var N=p.length+t.length+T.length,A=N<d?new Array(d-N+1).join(e):"";switch(g&&f&&(t=r(A+t,A.length?d-T.length:1/0),A=""),n){case"<":t=p+t+T+A;break;case"=":t=p+A+t+T;break;case"^":t=A.slice(0,N=A.length>>1)+p+t+T+A.slice(N);break;default:t=A+p+t+T}return a(t)}return m=void 0===m?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),T.toString=function(){return t+""},T}return{format:h,formatPrefix:function(t,e){var n=h(((t=Ir(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Ar(e)/3))),i=Math.pow(10,-r),o=jr[8+r/3];return function(t){return n(i*t)+o}}}}function zr(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 Br(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Yr)):void 0===e&&(e=Vr);for(var n,r,i,o,s,a=new Hr(t),u=[a];n=u.pop();)if((i=e(n.data))&&(s=(i=Array.from(i)).length))for(n.children=i,o=s-1;o>=0;--o)u.push(r=i[o]=new Hr(i[o])),r.parent=n,r.depth=n.depth+1;return a.eachBefore(qr)}function Vr(t){return t.children}function Yr(t){return Array.isArray(t)?t[1]:null}function $r(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function qr(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function Hr(t){this.data=t,this.depth=this.height=0,this.parent=null}function Xr(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}kr=Ur({thousands:",",grouping:[3],currency:["$",""]}),Lr=kr.format,Rr=kr.formatPrefix,Hr.prototype=Br.prototype={constructor:Hr,count:function(){return this.eachAfter(zr)},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,o=this,s=[o],a=[],u=-1;o=s.pop();)if(a.push(o),n=o.children)for(r=0,i=n.length;r<i;++r)s.push(n[r]);for(;o=a.pop();)t.call(e,o,++u,this);return this},eachBefore:function(t,e){for(var n,r,i=this,o=[i],s=-1;i=o.pop();)if(t.call(e,i,++s,this),n=i.children)for(r=n.length-1;r>=0;--r)o.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 Br(this).eachBefore($r)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,o=[i];do{for(t=o.reverse(),o=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)o.push(e[n])}while(o.length)}};var Wr=[0,1];function Kr(t){return t}function Zr(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:function(t){return function(){return t}}(isNaN(e)?NaN:.5)}function Qr(t,e,n){var r=t[0],i=t[1],o=e[0],s=e[1];return i<r?(r=Zr(i,r),o=n(s,o)):(r=Zr(r,i),o=n(o,s)),function(t){return o(r(t))}}function Jr(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=Zr(t[s],t[s+1]),o[s]=n(e[s],e[s+1]);return function(e){var n=h(t,e,1,r)-1;return o[n](i[n](e))}}function ti(){var t,e,n,r,i,o,s=Wr,a=Wr,u=ze,l=Kr;function c(){var t,e,n,u=Math.min(s.length,a.length);return l!==Kr&&(t=s[0],e=s[u-1],t>e&&(n=t,t=e,e=n),l=function(n){return Math.max(t,Math.min(e,n))}),r=u>2?Jr:Qr,i=o=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(s.map(t),a,u)))(t(l(e)))}return h.invert=function(n){return l(e((o||(o=r(a,s.map(t),Le)))(n)))},h.domain=function(t){return arguments.length?(s=Array.from(t,Gr),c()):s.slice()},h.range=function(t){return arguments.length?(a=Array.from(t),c()):a.slice()},h.rangeRound=function(t){return a=Array.from(t),u=Be,c()},h.clamp=function(t){return arguments.length?(l=!!t||Kr,c()):l!==Kr},h.interpolate=function(t){return arguments.length?(u=t,c()):u},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,c()}}function ei(t,e,n,r){var i,o=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=Ir(null==r?",f":r)).type){case"s":var s=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)))}(o,s))||(r.precision=i),Rr(r,s);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}(o,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)))}(o))||(r.precision=i-2*("%"===r.type))}return Lr(r)}function ni(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,o,s]=r?g(e,t,n):g(t,e,n);if(!(o>=i))return[];const a=o-i+1,u=new Array(a);if(r)if(s<0)for(let t=0;t<a;++t)u[t]=(o-t)/-s;else for(let t=0;t<a;++t)u[t]=(o-t)*s;else if(s<0)for(let t=0;t<a;++t)u[t]=(i+t)/-s;else for(let t=0;t<a;++t)u[t]=(i+t)*s;return u}(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return ei(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,o=e(),s=0,a=o.length-1,u=o[s],l=o[a],c=10;for(l<u&&(i=u,u=l,l=i,i=s,s=a,a=i);c-- >0;){if((i=m(u,l,n))===r)return o[s]=u,o[a]=l,e(o);if(i>0)u=Math.floor(u/i)*i,l=Math.ceil(l/i)*i;else{if(!(i<0))break;u=Math.ceil(u*i)/i,l=Math.floor(l*i)/i}r=i}return t},t}function ri(){var t=ti()(Kr,Kr);return t.copy=function(){return e=t,ri().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},Xr.apply(t,arguments),ni(t)}const ii=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,o)=>{const s=[];if(n=i.ceil(n),o=null==o?1:Math.floor(o),!(n<r&&o>0))return s;let a;do{s.push(a=new Date(+n)),e(n,o),t(n)}while(a<n&&n<r);return s},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)=>(ii.setTime(+e),oi.setTime(+r),t(ii),t(oi),Math.floor(n(ii,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 ai=6e4,ui=864e5,li=6048e5,ci=si(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ai)/ui,t=>t.getDate()-1);ci.range;const hi=si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/ui,t=>t.getUTCDate()-1);hi.range;const pi=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 fi(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())*ai)/li)}pi.range;const di=fi(0),gi=fi(1),mi=fi(2),yi=fi(3),_i=fi(4),vi=fi(5),wi=fi(6);function bi(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)/li)}di.range,gi.range,mi.range,yi.range,_i.range,vi.range,wi.range;const xi=bi(0),Ti=bi(1),Ei=bi(2),Ni=bi(3),Ai=bi(4),Di=bi(5),Oi=bi(6);xi.range,Ti.range,Ei.range,Ni.range,Ai.range,Di.range,Oi.range;const Ii=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());Ii.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,Ii.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 Mi(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 Si(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 Pi(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 ki,Li,Ri={"-":"",_:" ",0:"0"},Fi=/^\s*\d+/,ji=/^%/,Ui=/[\\^$*+?|[\]().{}]/g;function zi(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<n?new Array(n-o+1).join(e)+i:i)}function Bi(t){return t.replace(Ui,"\\$&")}function Vi(t){return new RegExp("^(?:"+t.map(Bi).join("|")+")","i")}function Yi(t){return new Map(t.map((t,e)=>[t.toLowerCase(),e]))}function $i(t,e,n){var r=Fi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function qi(t,e,n){var r=Fi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Hi(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Xi(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Gi(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Wi(t,e,n){var r=Fi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Ki(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Zi(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 Qi(t,e,n){var r=Fi.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function Ji(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function to(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function eo(t,e,n){var r=Fi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function no(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function ro(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function io(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function oo(t,e,n){var r=Fi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function so(t,e,n){var r=Fi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ao(t,e,n){var r=ji.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function uo(t,e,n){var r=Fi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function lo(t,e,n){var r=Fi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function co(t,e){return zi(t.getDate(),e,2)}function ho(t,e){return zi(t.getHours(),e,2)}function po(t,e){return zi(t.getHours()%12||12,e,2)}function fo(t,e){return zi(1+ci.count(Ii(t),t),e,3)}function go(t,e){return zi(t.getMilliseconds(),e,3)}function mo(t,e){return go(t,e)+"000"}function yo(t,e){return zi(t.getMonth()+1,e,2)}function _o(t,e){return zi(t.getMinutes(),e,2)}function vo(t,e){return zi(t.getSeconds(),e,2)}function wo(t){var e=t.getDay();return 0===e?7:e}function bo(t,e){return zi(di.count(Ii(t)-1,t),e,2)}function xo(t){var e=t.getDay();return e>=4||0===e?_i(t):_i.ceil(t)}function To(t,e){return t=xo(t),zi(_i.count(Ii(t),t)+(4===Ii(t).getDay()),e,2)}function Eo(t){return t.getDay()}function No(t,e){return zi(gi.count(Ii(t)-1,t),e,2)}function Ao(t,e){return zi(t.getFullYear()%100,e,2)}function Do(t,e){return zi((t=xo(t)).getFullYear()%100,e,2)}function Oo(t,e){return zi(t.getFullYear()%1e4,e,4)}function Io(t,e){var n=t.getDay();return zi((t=n>=4||0===n?_i(t):_i.ceil(t)).getFullYear()%1e4,e,4)}function Co(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+zi(e/60|0,"0",2)+zi(e%60,"0",2)}function Mo(t,e){return zi(t.getUTCDate(),e,2)}function So(t,e){return zi(t.getUTCHours(),e,2)}function Po(t,e){return zi(t.getUTCHours()%12||12,e,2)}function ko(t,e){return zi(1+hi.count(Ci(t),t),e,3)}function Lo(t,e){return zi(t.getUTCMilliseconds(),e,3)}function Ro(t,e){return Lo(t,e)+"000"}function Fo(t,e){return zi(t.getUTCMonth()+1,e,2)}function jo(t,e){return zi(t.getUTCMinutes(),e,2)}function Uo(t,e){return zi(t.getUTCSeconds(),e,2)}function zo(t){var e=t.getUTCDay();return 0===e?7:e}function Bo(t,e){return zi(xi.count(Ci(t)-1,t),e,2)}function Vo(t){var e=t.getUTCDay();return e>=4||0===e?Ai(t):Ai.ceil(t)}function Yo(t,e){return t=Vo(t),zi(Ai.count(Ci(t),t)+(4===Ci(t).getUTCDay()),e,2)}function $o(t){return t.getUTCDay()}function qo(t,e){return zi(Ti.count(Ci(t)-1,t),e,2)}function Ho(t,e){return zi(t.getUTCFullYear()%100,e,2)}function Xo(t,e){return zi((t=Vo(t)).getUTCFullYear()%100,e,2)}function Go(t,e){return zi(t.getUTCFullYear()%1e4,e,4)}function Wo(t,e){var n=t.getUTCDay();return zi((t=n>=4||0===n?Ai(t):Ai.ceil(t)).getUTCFullYear()%1e4,e,4)}function Ko(){return"+0000"}function Zo(){return"%"}function Qo(t){return+t}function Jo(t){return Math.floor(+t/1e3)}function ts(t){return function(){return t}}function es(t){this._context=t}function ns(t){return new es(t)}function rs(t){return t[0]}function is(t){return t[1]}function os(t,e){var n=ts(!0),r=null,i=ns,o=null,s=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 Er(e)}(a);function a(a){var u,l,c,h=(a=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(a)).length,p=!1;for(null==r&&(o=i(c=s())),u=0;u<=h;++u)!(u<h&&n(l=a[u],u,a))===p&&((p=!p)?o.lineStart():o.lineEnd()),p&&o.point(+t(l,u,a),+e(l,u,a));if(c)return o=null,c+""||null}return t="function"==typeof t?t:void 0===t?rs:ts(t),e="function"==typeof e?e:void 0===e?is:ts(e),a.x=function(e){return arguments.length?(t="function"==typeof e?e:ts(+e),a):t},a.y=function(t){return arguments.length?(e="function"==typeof t?t:ts(+t),a):e},a.defined=function(t){return arguments.length?(n="function"==typeof t?t:ts(!!t),a):n},a.curve=function(t){return arguments.length?(i=t,null!=r&&(o=i(r)),a):i},a.context=function(t){return arguments.length?(null==t?r=o=null:o=i(r=t),a):r},a}function ss(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 as(t){this._context=t}function us(t){return new as(t)}function ls(t,e){this._context=t,this._t=e}!function(t){ki=function(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,o=t.days,s=t.shortDays,a=t.months,u=t.shortMonths,l=Vi(i),c=Yi(i),h=Vi(o),p=Yi(o),f=Vi(s),d=Yi(s),g=Vi(a),m=Yi(a),y=Vi(u),_=Yi(u),v={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return u[t.getMonth()]},B:function(t){return a[t.getMonth()]},c:null,d:co,e:co,f:mo,g:Do,G:Io,H:ho,I:po,j:fo,L:go,m:yo,M:_o,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Qo,s:Jo,S:vo,u:wo,U:bo,V:To,w:Eo,W:No,x:null,X:null,y:Ao,Y:Oo,Z:Co,"%":Zo},w={a:function(t){return s[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return u[t.getUTCMonth()]},B:function(t){return a[t.getUTCMonth()]},c:null,d:Mo,e:Mo,f:Ro,g:Xo,G:Wo,H:So,I:Po,j:ko,L:Lo,m:Fo,M:jo,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Qo,s:Jo,S:Uo,u:zo,U:Bo,V:Yo,w:$o,W:qo,x:null,X:null,y:Ho,Y:Go,Z:Ko,"%":Zo},b={a:function(t,e,n){var r=f.exec(e.slice(n));return r?(t.w=d.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=p.get(r[0].toLowerCase()),n+r[0].length):-1},b:function(t,e,n){var r=y.exec(e.slice(n));return r?(t.m=_.get(r[0].toLowerCase()),n+r[0].length):-1},B:function(t,e,n){var r=g.exec(e.slice(n));return r?(t.m=m.get(r[0].toLowerCase()),n+r[0].length):-1},c:function(t,n,r){return E(t,e,n,r)},d:to,e:to,f:so,g:Ki,G:Wi,H:no,I:no,j:eo,L:oo,m:Ji,M:ro,p:function(t,e,n){var r=l.exec(e.slice(n));return r?(t.p=c.get(r[0].toLowerCase()),n+r[0].length):-1},q:Qi,Q:uo,s:lo,S:io,u:qi,U:Hi,V:Xi,w:$i,W:Gi,x:function(t,e,r){return E(t,n,e,r)},X:function(t,e,n){return E(t,r,e,n)},y:Ki,Y:Wi,Z:Zi,"%":ao};function x(t,e){return function(n){var r,i,o,s=[],a=-1,u=0,l=t.length;for(n instanceof Date||(n=new Date(+n));++a<l;)37===t.charCodeAt(a)&&(s.push(t.slice(u,a)),null!=(i=Ri[r=t.charAt(++a)])?r=t.charAt(++a):i="e"===r?" ":"0",(o=e[r])&&(r=o(n,i)),s.push(r),u=a+1);return s.push(t.slice(u,a)),s.join("")}}function T(t,e){return function(n){var r,i,o=Pi(1900,void 0,1);if(E(o,t,n+="",0)!=n.length)return null;if("Q"in o)return new Date(o.Q);if("s"in o)return new Date(1e3*o.s+("L"in o?o.L:0));if(e&&!("Z"in o)&&(o.Z=0),"p"in o&&(o.H=o.H%12+12*o.p),void 0===o.m&&(o.m="q"in o?o.q:0),"V"in o){if(o.V<1||o.V>53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=Si(Pi(o.y,0,1))).getUTCDay(),r=i>4||0===i?Ti.ceil(r):Ti(r),r=hi.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=Mi(Pi(o.y,0,1))).getDay(),r=i>4||0===i?gi.ceil(r):gi(r),r=ci.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?Si(Pi(o.y,0,1)).getUTCDay():Mi(Pi(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,Si(o)):Mi(o)}}function E(t,e,n,r){for(var i,o,s=0,a=e.length,u=n.length;s<a;){if(r>=u)return-1;if(37===(i=e.charCodeAt(s++))){if(i=e.charAt(s++),!(o=b[i in Ri?e.charAt(s++):i])||(r=o(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return v.x=x(n,v),v.X=x(r,v),v.c=x(e,v),w.x=x(n,w),w.X=x(r,w),w.c=x(e,w),{format:function(t){var e=x(t+="",v);return e.toString=function(){return t},e},parse:function(t){var e=T(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=x(t+="",w);return e.toString=function(){return t},e},utcParse:function(t){var e=T(t+="",!0);return e.toString=function(){return t},e}}}(t),ki.format,Li=ki.parse,ki.utcFormat,ki.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"]}),es.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)}}},as.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:ss(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:ss(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},ls.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 cs=t=>()=>t;function hs(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 ps(t,e,n){this.k=t,this.x=e,this.y=n}ps.prototype={constructor:ps,scale:function(t){return 1===t?this:new ps(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new ps(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 fs=new ps(1,0,0);function ds(t){t.stopImmediatePropagation()}function gs(t){t.preventDefault(),t.stopImmediatePropagation()}function ms(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function ys(){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 _s(){return this.__zoom||fs}function vs(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function ws(){return navigator.maxTouchPoints||"ontouchstart"in this}function bs(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function xs(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){var n=!1;try{n=this instanceof t}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}),n}ps.prototype;var Ts,Es={},Ns={};function As(){return Ts||(Ts=1,function(){Ns.defaults={.1:{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},.2:{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:"\n"},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}.call(Ns)),Ns}var Ds,Os={},Is={},Cs={};function Ms(){return Ds||(Ds=1,function(){var t,e,n,r,i,o,s,a=[].slice,u={}.hasOwnProperty;t=function(){var t,e,n,r,o,s;if(s=arguments[0],o=2<=arguments.length?a.call(arguments,1):[],i(Object.assign))Object.assign.apply(null,arguments);else for(t=0,n=o.length;t<n;t++)if(null!=(r=o[t]))for(e in r)u.call(r,e)&&(s[e]=r[e]);return s},i=function(t){return!!t&&"[object Function]"===Object.prototype.toString.call(t)},o=function(t){var e;return!!t&&("function"==(e=typeof t)||"object"===e)},n=function(t){return i(Array.isArray)?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},r=function(t){var e;if(n(t))return!t.length;for(e in t)if(u.call(t,e))return!1;return!0},s=function(t){var e,n;return o(t)&&(n=Object.getPrototypeOf(t))&&(e=n.constructor)&&"function"==typeof e&&e instanceof e&&Function.prototype.toString.call(e)===Function.prototype.toString.call(Object)},e=function(t){return i(t.valueOf)?t.valueOf():t},Cs.assign=t,Cs.isFunction=i,Cs.isObject=o,Cs.isArray=n,Cs.isEmpty=r,Cs.isPlainObject=s,Cs.getValue=e}.call(Cs)),Cs}var Ss,Ps={exports:{}},ks=Ps.exports;function Ls(){return Ss||(Ss=1,function(){Ps.exports=function(){function t(){}return t.prototype.hasFeature=function(t,e){return!0},t.prototype.createDocumentType=function(t,e,n){throw new Error("This DOM method is not implemented.")},t.prototype.createDocument=function(t,e,n){throw new Error("This DOM method is not implemented.")},t.prototype.createHTMLDocument=function(t){throw new Error("This DOM method is not implemented.")},t.prototype.getFeature=function(t,e){throw new Error("This DOM method is not implemented.")},t}()}.call(ks)),Ps.exports}var Rs,Fs={exports:{}},js={exports:{}},Us={exports:{}},zs=Us.exports;function Bs(){return Rs||(Rs=1,function(){Us.exports=function(){function t(){}return t.prototype.handleError=function(t){throw new Error(t)},t}()}.call(zs)),Us.exports}var Vs,Ys={exports:{}},$s=Ys.exports;function qs(){return Vs||(Vs=1,function(){Ys.exports=function(){function t(t){this.arr=t||[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.arr.length}}),t.prototype.item=function(t){return this.arr[t]||null},t.prototype.contains=function(t){return-1!==this.arr.indexOf(t)},t}()}.call($s)),Ys.exports}var Hs,Xs=js.exports;function Gs(){return Hs||(Hs=1,function(){var t,e;t=Bs(),e=qs(),js.exports=function(){function n(){this.defaultParams={"canonical-form":!1,"cdata-sections":!1,comments:!1,"datatype-normalization":!1,"element-content-whitespace":!0,entities:!0,"error-handler":new t,infoset:!0,"validate-if-schema":!1,namespaces:!0,"namespace-declarations":!0,"normalize-characters":!1,"schema-location":"","schema-type":"","split-cdata-sections":!0,validate:!1,"well-formed":!0},this.params=Object.create(this.defaultParams)}return Object.defineProperty(n.prototype,"parameterNames",{get:function(){return new e(Object.keys(this.defaultParams))}}),n.prototype.getParameter=function(t){return this.params.hasOwnProperty(t)?this.params[t]:null},n.prototype.canSetParameter=function(t,e){return!0},n.prototype.setParameter=function(t,e){return null!=e?this.params[t]=e:delete this.params[t]},n}()}.call(Xs)),js.exports}var Ws,Ks={exports:{}},Zs={exports:{}},Qs={exports:{}},Js=Qs.exports;function ta(){return Ws||(Ws=1,function(){Qs.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}.call(Js)),Qs.exports}var ea,na={exports:{}},ra=na.exports;function ia(){return ea||(ea=1,function(){var t;t=ta(),wu(),na.exports=function(){function e(e,n,r){if(this.parent=e,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),null==n)throw new Error("Missing attribute name. "+this.debugInfo(n));this.name=this.stringify.name(n),this.value=this.stringify.attValue(r),this.type=t.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(e.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(e.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(e.prototype,"textContent",{get:function(){return this.value},set:function(t){return this.value=t||""}}),Object.defineProperty(e.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(e.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(e.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(e.prototype,"specified",{get:function(){return!0}}),e.prototype.clone=function(){return Object.create(this)},e.prototype.toString=function(t){return this.options.writer.attribute(this,this.options.writer.filterOptions(t))},e.prototype.debugInfo=function(t){return null==(t=t||this.name)?"parent: <"+this.parent.name+">":"attribute: {"+t+"}, parent: <"+this.parent.name+">"},e.prototype.isEqualNode=function(t){return t.namespaceURI===this.namespaceURI&&(t.prefix===this.prefix&&(t.localName===this.localName&&t.value===this.value))},e}()}.call(ra)),na.exports}var oa,sa={exports:{}},aa=sa.exports;function ua(){return oa||(oa=1,function(){sa.exports=function(){function t(t){this.nodes=t}return Object.defineProperty(t.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),t.prototype.clone=function(){return this.nodes=null},t.prototype.getNamedItem=function(t){return this.nodes[t]},t.prototype.setNamedItem=function(t){var e;return e=this.nodes[t.nodeName],this.nodes[t.nodeName]=t,e||null},t.prototype.removeNamedItem=function(t){var e;return e=this.nodes[t],delete this.nodes[t],e||null},t.prototype.item=function(t){return this.nodes[Object.keys(this.nodes)[t]]||null},t.prototype.getNamedItemNS=function(t,e){throw new Error("This DOM method is not implemented.")},t.prototype.setNamedItemNS=function(t){throw new Error("This DOM method is not implemented.")},t.prototype.removeNamedItemNS=function(t,e){throw new Error("This DOM method is not implemented.")},t}()}.call(aa)),sa.exports}var la,ca=Zs.exports;function ha(){return la||(la=1,function(){var t,e,n,r,i,o,s,a,u={}.hasOwnProperty;a=Ms(),s=a.isObject,o=a.isFunction,i=a.getValue,r=wu(),t=ta(),e=ia(),n=ua(),Zs.exports=function(r){function a(e,n,r){var i,o,s,u;if(a.__super__.constructor.call(this,e),null==n)throw new Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(n),this.type=t.Element,this.attribs={},this.schemaTypeInfo=null,null!=r&&this.attribute(r),e.type===t.Document&&(this.isRoot=!0,this.documentObject=e,e.rootObject=this,e.children))for(o=0,s=(u=e.children).length;o<s;o++)if((i=u[o]).type===t.DocType){i.name=this.name;break}}return function(t,e){for(var n in e)u.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(a,r),Object.defineProperty(a.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(a.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(a.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(a.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(a.prototype,"id",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(a.prototype,"className",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(a.prototype,"classList",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(a.prototype,"attributes",{get:function(){return this.attributeMap&&this.attributeMap.nodes||(this.attributeMap=new n(this.attribs)),this.attributeMap}}),a.prototype.clone=function(){var t,e,n,r;for(e in(n=Object.create(this)).isRoot&&(n.documentObject=null),n.attribs={},r=this.attribs)u.call(r,e)&&(t=r[e],n.attribs[e]=t.clone());return n.children=[],this.children.forEach(function(t){var e;return(e=t.clone()).parent=n,n.children.push(e)}),n},a.prototype.attribute=function(t,n){var r,a;if(null!=t&&(t=i(t)),s(t))for(r in t)u.call(t,r)&&(a=t[r],this.attribute(r,a));else o(n)&&(n=n.apply()),this.options.keepNullAttributes&&null==n?this.attribs[t]=new e(this,t,""):null!=n&&(this.attribs[t]=new e(this,t,n));return this},a.prototype.removeAttribute=function(t){var e,n,r;if(null==t)throw new Error("Missing attribute name. "+this.debugInfo());if(t=i(t),Array.isArray(t))for(n=0,r=t.length;n<r;n++)e=t[n],delete this.attribs[e];else delete this.attribs[t];return this},a.prototype.toString=function(t){return this.options.writer.element(this,this.options.writer.filterOptions(t))},a.prototype.att=function(t,e){return this.attribute(t,e)},a.prototype.a=function(t,e){return this.attribute(t,e)},a.prototype.getAttribute=function(t){return this.attribs.hasOwnProperty(t)?this.attribs[t].value:null},a.prototype.setAttribute=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getAttributeNode=function(t){return this.attribs.hasOwnProperty(t)?this.attribs[t]:null},a.prototype.setAttributeNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.removeAttributeNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByTagName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getAttributeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.setAttributeNS=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.removeAttributeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getAttributeNodeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.setAttributeNodeNS=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByTagNameNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.hasAttribute=function(t){return this.attribs.hasOwnProperty(t)},a.prototype.hasAttributeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.setIdAttribute=function(t,e){return this.attribs.hasOwnProperty(t)?this.attribs[t].isId:e},a.prototype.setIdAttributeNS=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.setIdAttributeNode=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByTagName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByTagNameNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.getElementsByClassName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},a.prototype.isEqualNode=function(t){var e,n,r;if(!a.__super__.isEqualNode.apply(this,arguments).isEqualNode(t))return!1;if(t.namespaceURI!==this.namespaceURI)return!1;if(t.prefix!==this.prefix)return!1;if(t.localName!==this.localName)return!1;if(t.attribs.length!==this.attribs.length)return!1;for(e=n=0,r=this.attribs.length-1;0<=r?n<=r:n>=r;e=0<=r?++n:--n)if(!this.attribs[e].isEqualNode(t.attribs[e]))return!1;return!0},a}(r)}.call(ca)),Zs.exports}var pa,fa={exports:{}},da={exports:{}},ga=da.exports;function ma(){return pa||(pa=1,function(){var t,e={}.hasOwnProperty;t=wu(),da.exports=function(t){function n(t){n.__super__.constructor.call(this,t),this.value=""}return function(t,n){for(var r in n)e.call(n,r)&&(t[r]=n[r]);function i(){this.constructor=t}i.prototype=n.prototype,t.prototype=new i,t.__super__=n.prototype}(n,t),Object.defineProperty(n.prototype,"data",{get:function(){return this.value},set:function(t){return this.value=t||""}}),Object.defineProperty(n.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(n.prototype,"textContent",{get:function(){return this.value},set:function(t){return this.value=t||""}}),n.prototype.clone=function(){return Object.create(this)},n.prototype.substringData=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.appendData=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.insertData=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.deleteData=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.replaceData=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},n.prototype.isEqualNode=function(t){return!!n.__super__.isEqualNode.apply(this,arguments).isEqualNode(t)&&t.data===this.data},n}(t)}.call(ga)),da.exports}var ya,_a=fa.exports;function va(){return ya||(ya=1,function(){var t,e,n={}.hasOwnProperty;t=ta(),e=ma(),fa.exports=function(e){function r(e,n){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=t.CData,this.value=this.stringify.cdata(n)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.cdata(this,this.options.writer.filterOptions(t))},r}(e)}.call(_a)),fa.exports}var wa,ba={exports:{}},xa=ba.exports;function Ta(){return wa||(wa=1,function(){var t,e,n={}.hasOwnProperty;t=ta(),e=ma(),ba.exports=function(e){function r(e,n){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=t.Comment,this.value=this.stringify.comment(n)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.comment(this,this.options.writer.filterOptions(t))},r}(e)}.call(xa)),ba.exports}var Ea,Na={exports:{}},Aa=Na.exports;function Da(){return Ea||(Ea=1,function(){var t,e,n,r={}.hasOwnProperty;n=Ms().isObject,e=wu(),t=ta(),Na.exports=function(e){function i(e,r,o,s){var a;i.__super__.constructor.call(this,e),n(r)&&(r=(a=r).version,o=a.encoding,s=a.standalone),r||(r="1.0"),this.type=t.Declaration,this.version=this.stringify.xmlVersion(r),null!=o&&(this.encoding=this.stringify.xmlEncoding(o)),null!=s&&(this.standalone=this.stringify.xmlStandalone(s))}return function(t,e){for(var n in e)r.call(e,n)&&(t[n]=e[n]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(i,e),i.prototype.toString=function(t){return this.options.writer.declaration(this,this.options.writer.filterOptions(t))},i}(e)}.call(Aa)),Na.exports}var Oa,Ia={exports:{}},Ca={exports:{}},Ma=Ca.exports;function Sa(){return Oa||(Oa=1,function(){var t,e,n={}.hasOwnProperty;e=wu(),t=ta(),Ca.exports=function(e){function r(e,n,i,o,s,a){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD element name. "+this.debugInfo());if(null==i)throw new Error("Missing DTD attribute name. "+this.debugInfo(n));if(!o)throw new Error("Missing DTD attribute type. "+this.debugInfo(n));if(!s)throw new Error("Missing DTD attribute default. "+this.debugInfo(n));if(0!==s.indexOf("#")&&(s="#"+s),!s.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(n));if(a&&!s.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(n));this.elementName=this.stringify.name(n),this.type=t.AttributeDeclaration,this.attributeName=this.stringify.name(i),this.attributeType=this.stringify.dtdAttType(o),a&&(this.defaultValue=this.stringify.dtdAttDefault(a)),this.defaultValueType=s}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.toString=function(t){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(t))},r}(e)}.call(Ma)),Ca.exports}var Pa,ka={exports:{}},La=ka.exports;function Ra(){return Pa||(Pa=1,function(){var t,e,n,r={}.hasOwnProperty;n=Ms().isObject,e=wu(),t=ta(),ka.exports=function(e){function i(e,r,o,s){if(i.__super__.constructor.call(this,e),null==o)throw new Error("Missing DTD entity name. "+this.debugInfo(o));if(null==s)throw new Error("Missing DTD entity value. "+this.debugInfo(o));if(this.pe=!!r,this.name=this.stringify.name(o),this.type=t.EntityDeclaration,n(s)){if(!s.pubID&&!s.sysID)throw new Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(o));if(s.pubID&&!s.sysID)throw new Error("System identifier is required for a public external entity. "+this.debugInfo(o));if(this.internal=!1,null!=s.pubID&&(this.pubID=this.stringify.dtdPubID(s.pubID)),null!=s.sysID&&(this.sysID=this.stringify.dtdSysID(s.sysID)),null!=s.nData&&(this.nData=this.stringify.dtdNData(s.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(o))}else this.value=this.stringify.dtdEntityValue(s),this.internal=!0}return function(t,e){for(var n in e)r.call(e,n)&&(t[n]=e[n]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(i,e),Object.defineProperty(i.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(i.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(i.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(i.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(i.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(i.prototype,"xmlVersion",{get:function(){return null}}),i.prototype.toString=function(t){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(t))},i}(e)}.call(La)),ka.exports}var Fa,ja={exports:{}},Ua=ja.exports;function za(){return Fa||(Fa=1,function(){var t,e,n={}.hasOwnProperty;e=wu(),t=ta(),ja.exports=function(e){function r(e,n,i){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD element name. "+this.debugInfo());i||(i="(#PCDATA)"),Array.isArray(i)&&(i="("+i.join(",")+")"),this.name=this.stringify.name(n),this.type=t.ElementDeclaration,this.value=this.stringify.dtdElementValue(i)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.toString=function(t){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(t))},r}(e)}.call(Ua)),ja.exports}var Ba,Va={exports:{}},Ya=Va.exports;function $a(){return Ba||(Ba=1,function(){var t,e,n={}.hasOwnProperty;e=wu(),t=ta(),Va.exports=function(e){function r(e,n,i){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing DTD notation name. "+this.debugInfo(n));if(!i.pubID&&!i.sysID)throw new Error("Public or system identifiers are required for an external entity. "+this.debugInfo(n));this.name=this.stringify.name(n),this.type=t.NotationDeclaration,null!=i.pubID&&(this.pubID=this.stringify.dtdPubID(i.pubID)),null!=i.sysID&&(this.sysID=this.stringify.dtdSysID(i.sysID))}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),Object.defineProperty(r.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(r.prototype,"systemId",{get:function(){return this.sysID}}),r.prototype.toString=function(t){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(t))},r}(e)}.call(Ya)),Va.exports}var qa,Ha=Ia.exports;function Xa(){return qa||(qa=1,function(){var t,e,n,r,i,o,s,a,u={}.hasOwnProperty;a=Ms().isObject,s=wu(),t=ta(),e=Sa(),r=Ra(),n=za(),i=$a(),o=ua(),Ia.exports=function(s){function l(e,n,r){var i,o,s,u,c,h;if(l.__super__.constructor.call(this,e),this.type=t.DocType,e.children)for(o=0,s=(u=e.children).length;o<s;o++)if((i=u[o]).type===t.Element){this.name=i.name;break}this.documentObject=e,a(n)&&(n=(c=n).pubID,r=c.sysID),null==r&&(r=(h=[n,r])[0],n=h[1]),null!=n&&(this.pubID=this.stringify.dtdPubID(n)),null!=r&&(this.sysID=this.stringify.dtdSysID(r))}return function(t,e){for(var n in e)u.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(l,s),Object.defineProperty(l.prototype,"entities",{get:function(){var e,n,r,i,s;for(i={},n=0,r=(s=this.children).length;n<r;n++)(e=s[n]).type!==t.EntityDeclaration||e.pe||(i[e.name]=e);return new o(i)}}),Object.defineProperty(l.prototype,"notations",{get:function(){var e,n,r,i,s;for(i={},n=0,r=(s=this.children).length;n<r;n++)(e=s[n]).type===t.NotationDeclaration&&(i[e.name]=e);return new o(i)}}),Object.defineProperty(l.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(l.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(l.prototype,"internalSubset",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),l.prototype.element=function(t,e){var r;return r=new n(this,t,e),this.children.push(r),this},l.prototype.attList=function(t,n,r,i,o){var s;return s=new e(this,t,n,r,i,o),this.children.push(s),this},l.prototype.entity=function(t,e){var n;return n=new r(this,!1,t,e),this.children.push(n),this},l.prototype.pEntity=function(t,e){var n;return n=new r(this,!0,t,e),this.children.push(n),this},l.prototype.notation=function(t,e){var n;return n=new i(this,t,e),this.children.push(n),this},l.prototype.toString=function(t){return this.options.writer.docType(this,this.options.writer.filterOptions(t))},l.prototype.ele=function(t,e){return this.element(t,e)},l.prototype.att=function(t,e,n,r,i){return this.attList(t,e,n,r,i)},l.prototype.ent=function(t,e){return this.entity(t,e)},l.prototype.pent=function(t,e){return this.pEntity(t,e)},l.prototype.not=function(t,e){return this.notation(t,e)},l.prototype.up=function(){return this.root()||this.documentObject},l.prototype.isEqualNode=function(t){return!!l.__super__.isEqualNode.apply(this,arguments).isEqualNode(t)&&(t.name===this.name&&(t.publicId===this.publicId&&t.systemId===this.systemId))},l}(s)}.call(Ha)),Ia.exports}var Ga,Wa={exports:{}},Ka=Wa.exports;function Za(){return Ga||(Ga=1,function(){var t,e,n={}.hasOwnProperty;t=ta(),e=wu(),Wa.exports=function(e){function r(e,n){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing raw text. "+this.debugInfo());this.type=t.Raw,this.value=this.stringify.raw(n)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.raw(this,this.options.writer.filterOptions(t))},r}(e)}.call(Ka)),Wa.exports}var Qa,Ja={exports:{}},tu=Ja.exports;function eu(){return Qa||(Qa=1,function(){var t,e,n={}.hasOwnProperty;t=ta(),e=ma(),Ja.exports=function(e){function r(e,n){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=t.Text,this.value=this.stringify.text(n)}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),Object.defineProperty(r.prototype,"isElementContentWhitespace",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(r.prototype,"wholeText",{get:function(){var t,e,n;for(n="",e=this.previousSibling;e;)n=e.data+n,e=e.previousSibling;for(n+=this.data,t=this.nextSibling;t;)n+=t.data,t=t.nextSibling;return n}}),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.text(this,this.options.writer.filterOptions(t))},r.prototype.splitText=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},r.prototype.replaceWholeText=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},r}(e)}.call(tu)),Ja.exports}var nu,ru={exports:{}},iu=ru.exports;function ou(){return nu||(nu=1,function(){var t,e,n={}.hasOwnProperty;t=ta(),e=ma(),ru.exports=function(e){function r(e,n,i){if(r.__super__.constructor.call(this,e),null==n)throw new Error("Missing instruction target. "+this.debugInfo());this.type=t.ProcessingInstruction,this.target=this.stringify.insTarget(n),this.name=this.target,i&&(this.value=this.stringify.insValue(i))}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(t))},r.prototype.isEqualNode=function(t){return!!r.__super__.isEqualNode.apply(this,arguments).isEqualNode(t)&&t.target===this.target},r}(e)}.call(iu)),ru.exports}var su,au={exports:{}},uu=au.exports;function lu(){return su||(su=1,function(){var t,e,n={}.hasOwnProperty;e=wu(),t=ta(),au.exports=function(e){function r(e){r.__super__.constructor.call(this,e),this.type=t.Dummy}return function(t,e){for(var r in e)n.call(e,r)&&(t[r]=e[r]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(r,e),r.prototype.clone=function(){return Object.create(this)},r.prototype.toString=function(t){return""},r}(e)}.call(uu)),au.exports}var cu,hu={exports:{}},pu=hu.exports;function fu(){return cu||(cu=1,function(){hu.exports=function(){function t(t){this.nodes=t}return Object.defineProperty(t.prototype,"length",{get:function(){return this.nodes.length||0}}),t.prototype.clone=function(){return this.nodes=null},t.prototype.item=function(t){return this.nodes[t]||null},t}()}.call(pu)),hu.exports}var du,gu={exports:{}},mu=gu.exports;function yu(){return du||(du=1,function(){gu.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}.call(mu)),gu.exports}var _u,vu=Ks.exports;function wu(){return _u||(_u=1,function(){var t,e,n,r,i,o,s,a,u,l,c,h,p,f,d,g,m,y={}.hasOwnProperty;m=Ms(),g=m.isObject,d=m.isFunction,f=m.isEmpty,p=m.getValue,a=null,n=null,r=null,i=null,o=null,c=null,h=null,l=null,s=null,e=null,u=null,t=null,Ks.exports=function(){function m(p){this.parent=p,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),this.value=null,this.children=[],this.baseURI=null,a||(a=ha(),n=va(),r=Ta(),i=Da(),o=Xa(),c=Za(),h=eu(),l=ou(),s=lu(),e=ta(),u=fu(),ua(),t=yu())}return Object.defineProperty(m.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(m.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(m.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(m.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(m.prototype,"childNodes",{get:function(){return this.childNodeList&&this.childNodeList.nodes||(this.childNodeList=new u(this.children)),this.childNodeList}}),Object.defineProperty(m.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(m.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(m.prototype,"previousSibling",{get:function(){var t;return t=this.parent.children.indexOf(this),this.parent.children[t-1]||null}}),Object.defineProperty(m.prototype,"nextSibling",{get:function(){var t;return t=this.parent.children.indexOf(this),this.parent.children[t+1]||null}}),Object.defineProperty(m.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(m.prototype,"textContent",{get:function(){var t,n,r,i,o;if(this.nodeType===e.Element||this.nodeType===e.DocumentFragment){for(o="",n=0,r=(i=this.children).length;n<r;n++)(t=i[n]).textContent&&(o+=t.textContent);return o}return null},set:function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),m.prototype.setParent=function(t){var e,n,r,i,o;for(this.parent=t,t&&(this.options=t.options,this.stringify=t.stringify),o=[],n=0,r=(i=this.children).length;n<r;n++)e=i[n],o.push(e.setParent(this));return o},m.prototype.element=function(t,e,n){var r,i,o,s,a,u,l,c,h,m,_;if(u=null,null===e&&null==n&&(e=(h=[{},null])[0],n=h[1]),null==e&&(e={}),e=p(e),g(e)||(n=(m=[e,n])[0],e=m[1]),null!=t&&(t=p(t)),Array.isArray(t))for(o=0,l=t.length;o<l;o++)i=t[o],u=this.element(i);else if(d(t))u=this.element(t.apply());else if(g(t)){for(a in t)if(y.call(t,a))if(_=t[a],d(_)&&(_=_.apply()),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===a.indexOf(this.stringify.convertAttKey))u=this.attribute(a.substr(this.stringify.convertAttKey.length),_);else if(!this.options.separateArrayItems&&Array.isArray(_)&&f(_))u=this.dummy();else if(g(_)&&f(_))u=this.element(a);else if(this.options.keepNullNodes||null!=_)if(!this.options.separateArrayItems&&Array.isArray(_))for(s=0,c=_.length;s<c;s++)i=_[s],(r={})[a]=i,u=this.element(r);else g(_)?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===a.indexOf(this.stringify.convertTextKey)?u=this.element(_):(u=this.element(a)).element(_):u=this.element(a,_);else u=this.dummy()}else u=this.options.keepNullNodes||null!==n?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===t.indexOf(this.stringify.convertTextKey)?this.text(n):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&0===t.indexOf(this.stringify.convertCDataKey)?this.cdata(n):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&0===t.indexOf(this.stringify.convertCommentKey)?this.comment(n):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&0===t.indexOf(this.stringify.convertRawKey)?this.raw(n):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===t.indexOf(this.stringify.convertPIKey)?this.instruction(t.substr(this.stringify.convertPIKey.length),n):this.node(t,e,n):this.dummy();if(null==u)throw new Error("Could not create any elements with: "+t+". "+this.debugInfo());return u},m.prototype.insertBefore=function(t,e,n){var r,i,o,s,a;if(null!=t?t.type:void 0)return s=e,(o=t).setParent(this),s?(i=children.indexOf(s),a=children.splice(i),children.push(o),Array.prototype.push.apply(children,a)):children.push(o),o;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(t));return i=this.parent.children.indexOf(this),a=this.parent.children.splice(i),r=this.parent.element(t,e,n),Array.prototype.push.apply(this.parent.children,a),r},m.prototype.insertAfter=function(t,e,n){var r,i,o;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(t));return i=this.parent.children.indexOf(this),o=this.parent.children.splice(i+1),r=this.parent.element(t,e,n),Array.prototype.push.apply(this.parent.children,o),r},m.prototype.remove=function(){var t;if(this.isRoot)throw new Error("Cannot remove the root element. "+this.debugInfo());return t=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[t,t-t+1].concat([])),this.parent},m.prototype.node=function(t,e,n){var r,i;return null!=t&&(t=p(t)),e||(e={}),e=p(e),g(e)||(n=(i=[e,n])[0],e=i[1]),r=new a(this,t,e),null!=n&&r.text(n),this.children.push(r),r},m.prototype.text=function(t){var e;return g(t)&&this.element(t),e=new h(this,t),this.children.push(e),this},m.prototype.cdata=function(t){var e;return e=new n(this,t),this.children.push(e),this},m.prototype.comment=function(t){var e;return e=new r(this,t),this.children.push(e),this},m.prototype.commentBefore=function(t){var e,n;return e=this.parent.children.indexOf(this),n=this.parent.children.splice(e),this.parent.comment(t),Array.prototype.push.apply(this.parent.children,n),this},m.prototype.commentAfter=function(t){var e,n;return e=this.parent.children.indexOf(this),n=this.parent.children.splice(e+1),this.parent.comment(t),Array.prototype.push.apply(this.parent.children,n),this},m.prototype.raw=function(t){var e;return e=new c(this,t),this.children.push(e),this},m.prototype.dummy=function(){return new s(this)},m.prototype.instruction=function(t,e){var n,r,i,o,s;if(null!=t&&(t=p(t)),null!=e&&(e=p(e)),Array.isArray(t))for(o=0,s=t.length;o<s;o++)n=t[o],this.instruction(n);else if(g(t))for(n in t)y.call(t,n)&&(r=t[n],this.instruction(n,r));else d(e)&&(e=e.apply()),i=new l(this,t,e),this.children.push(i);return this},m.prototype.instructionBefore=function(t,e){var n,r;return n=this.parent.children.indexOf(this),r=this.parent.children.splice(n),this.parent.instruction(t,e),Array.prototype.push.apply(this.parent.children,r),this},m.prototype.instructionAfter=function(t,e){var n,r;return n=this.parent.children.indexOf(this),r=this.parent.children.splice(n+1),this.parent.instruction(t,e),Array.prototype.push.apply(this.parent.children,r),this},m.prototype.declaration=function(t,n,r){var o,s;return o=this.document(),s=new i(o,t,n,r),0===o.children.length?o.children.unshift(s):o.children[0].type===e.Declaration?o.children[0]=s:o.children.unshift(s),o.root()||o},m.prototype.dtd=function(t,n){var r,i,s,a,u,l,c,h,p;for(r=this.document(),i=new o(r,t,n),s=a=0,l=(h=r.children).length;a<l;s=++a)if(h[s].type===e.DocType)return r.children[s]=i,i;for(s=u=0,c=(p=r.children).length;u<c;s=++u)if(p[s].isRoot)return r.children.splice(s,0,i),i;return r.children.push(i),i},m.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},m.prototype.root=function(){var t;for(t=this;t;){if(t.type===e.Document)return t.rootObject;if(t.isRoot)return t;t=t.parent}},m.prototype.document=function(){var t;for(t=this;t;){if(t.type===e.Document)return t;t=t.parent}},m.prototype.end=function(t){return this.document().end(t)},m.prototype.prev=function(){var t;if((t=this.parent.children.indexOf(this))<1)throw new Error("Already at the first node. "+this.debugInfo());return this.parent.children[t-1]},m.prototype.next=function(){var t;if(-1===(t=this.parent.children.indexOf(this))||t===this.parent.children.length-1)throw new Error("Already at the last node. "+this.debugInfo());return this.parent.children[t+1]},m.prototype.importDocument=function(t){var e;return(e=t.root().clone()).parent=this,e.isRoot=!1,this.children.push(e),this},m.prototype.debugInfo=function(t){var e,n;return null!=(t=t||this.name)||(null!=(e=this.parent)?e.name:void 0)?null==t?"parent: <"+this.parent.name+">":(null!=(n=this.parent)?n.name:void 0)?"node: <"+t+">, parent: <"+this.parent.name+">":"node: <"+t+">":""},m.prototype.ele=function(t,e,n){return this.element(t,e,n)},m.prototype.nod=function(t,e,n){return this.node(t,e,n)},m.prototype.txt=function(t){return this.text(t)},m.prototype.dat=function(t){return this.cdata(t)},m.prototype.com=function(t){return this.comment(t)},m.prototype.ins=function(t,e){return this.instruction(t,e)},m.prototype.doc=function(){return this.document()},m.prototype.dec=function(t,e,n){return this.declaration(t,e,n)},m.prototype.e=function(t,e,n){return this.element(t,e,n)},m.prototype.n=function(t,e,n){return this.node(t,e,n)},m.prototype.t=function(t){return this.text(t)},m.prototype.d=function(t){return this.cdata(t)},m.prototype.c=function(t){return this.comment(t)},m.prototype.r=function(t){return this.raw(t)},m.prototype.i=function(t,e){return this.instruction(t,e)},m.prototype.u=function(){return this.up()},m.prototype.importXMLBuilder=function(t){return this.importDocument(t)},m.prototype.replaceChild=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.removeChild=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.appendChild=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.hasChildNodes=function(){return 0!==this.children.length},m.prototype.cloneNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.normalize=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.isSupported=function(t,e){return!0},m.prototype.hasAttributes=function(){return 0!==this.attribs.length},m.prototype.compareDocumentPosition=function(e){var n,r;return(n=this)===e?0:this.document()!==e.document()?(r=t.Disconnected|t.ImplementationSpecific,Math.random()<.5?r|=t.Preceding:r|=t.Following,r):n.isAncestor(e)?t.Contains|t.Preceding:n.isDescendant(e)?t.Contains|t.Following:n.isPreceding(e)?t.Preceding:t.Following},m.prototype.isSameNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.lookupPrefix=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.isDefaultNamespace=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.lookupNamespaceURI=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.isEqualNode=function(t){var e,n,r;if(t.nodeType!==this.nodeType)return!1;if(t.children.length!==this.children.length)return!1;for(e=n=0,r=this.children.length-1;0<=r?n<=r:n>=r;e=0<=r?++n:--n)if(!this.children[e].isEqualNode(t.children[e]))return!1;return!0},m.prototype.getFeature=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.setUserData=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.getUserData=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},m.prototype.contains=function(t){return!!t&&(t===this||this.isDescendant(t))},m.prototype.isDescendant=function(t){var e,n,r,i;for(n=0,r=(i=this.children).length;n<r;n++){if(t===(e=i[n]))return!0;if(e.isDescendant(t))return!0}return!1},m.prototype.isAncestor=function(t){return t.isDescendant(this)},m.prototype.isPreceding=function(t){var e,n;return e=this.treePosition(t),n=this.treePosition(this),-1!==e&&-1!==n&&e<n},m.prototype.isFollowing=function(t){var e,n;return e=this.treePosition(t),n=this.treePosition(this),-1!==e&&-1!==n&&e>n},m.prototype.treePosition=function(t){var e,n;return n=0,e=!1,this.foreachTreeNode(this.document(),function(r){if(n++,!e&&r===t)return e=!0}),e?n:-1},m.prototype.foreachTreeNode=function(t,e){var n,r,i,o,s;for(t||(t=this.document()),r=0,i=(o=t.children).length;r<i;r++){if(s=e(n=o[r]))return s;if(s=this.foreachTreeNode(n,e))return s}},m}()}.call(vu)),Ks.exports}var bu,xu={exports:{}},Tu=xu.exports;function Eu(){return bu||(bu=1,function(){var t=function(t,e){return function(){return t.apply(e,arguments)}},e={}.hasOwnProperty;xu.exports=function(){function n(n){var r,i,o;for(r in this.assertLegalName=t(this.assertLegalName,this),this.assertLegalChar=t(this.assertLegalChar,this),n||(n={}),this.options=n,this.options.version||(this.options.version="1.0"),i=n.stringify||{})e.call(i,r)&&(o=i[r],this[r]=o)}return n.prototype.name=function(t){return this.options.noValidation?t:this.assertLegalName(""+t||"")},n.prototype.text=function(t){return this.options.noValidation?t:this.assertLegalChar(this.textEscape(""+t||""))},n.prototype.cdata=function(t){return this.options.noValidation?t:(t=(t=""+t||"").replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(t))},n.prototype.comment=function(t){if(this.options.noValidation)return t;if((t=""+t||"").match(/--/))throw new Error("Comment text cannot contain double-hypen: "+t);return this.assertLegalChar(t)},n.prototype.raw=function(t){return this.options.noValidation?t:""+t||""},n.prototype.attValue=function(t){return this.options.noValidation?t:this.assertLegalChar(this.attEscape(t=""+t||""))},n.prototype.insTarget=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.insValue=function(t){if(this.options.noValidation)return t;if((t=""+t||"").match(/\?>/))throw new Error("Invalid processing instruction value: "+t);return this.assertLegalChar(t)},n.prototype.xmlVersion=function(t){if(this.options.noValidation)return t;if(!(t=""+t||"").match(/1\.[0-9]+/))throw new Error("Invalid version number: "+t);return t},n.prototype.xmlEncoding=function(t){if(this.options.noValidation)return t;if(!(t=""+t||"").match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw new Error("Invalid encoding: "+t);return this.assertLegalChar(t)},n.prototype.xmlStandalone=function(t){return this.options.noValidation?t:t?"yes":"no"},n.prototype.dtdPubID=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdSysID=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdElementValue=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdAttType=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdAttDefault=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdEntityValue=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.dtdNData=function(t){return this.options.noValidation?t:this.assertLegalChar(""+t||"")},n.prototype.convertAttKey="@",n.prototype.convertPIKey="?",n.prototype.convertTextKey="#text",n.prototype.convertCDataKey="#cdata",n.prototype.convertCommentKey="#comment",n.prototype.convertRawKey="#raw",n.prototype.assertLegalChar=function(t){var e,n;if(this.options.noValidation)return t;if(e="","1.0"===this.options.version){if(e=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,n=t.match(e))throw new Error("Invalid character in string: "+t+" at index "+n.index)}else if("1.1"===this.options.version&&(e=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,n=t.match(e)))throw new Error("Invalid character in string: "+t+" at index "+n.index);return t},n.prototype.assertLegalName=function(t){var e;if(this.options.noValidation)return t;if(this.assertLegalChar(t),e=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!t.match(e))throw new Error("Invalid character in name");return t},n.prototype.textEscape=function(t){var e;return this.options.noValidation?t:(e=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,t.replace(e,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;"))},n.prototype.attEscape=function(t){var e;return this.options.noValidation?t:(e=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,t.replace(e,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;"))},n}()}.call(Tu)),xu.exports}var Nu,Au={exports:{}},Du={exports:{}},Ou={exports:{}},Iu=Ou.exports;function Cu(){return Nu||(Nu=1,function(){Ou.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}.call(Iu)),Ou.exports}var Mu,Su=Du.exports;function Pu(){return Mu||(Mu=1,function(){var t,e,n,r={}.hasOwnProperty;n=Ms().assign,t=ta(),Da(),Xa(),va(),Ta(),ha(),Za(),eu(),ou(),lu(),Sa(),za(),Ra(),$a(),e=Cu(),Du.exports=function(){function i(t){var e,n,i;for(e in t||(t={}),this.options=t,n=t.writer||{})r.call(n,e)&&(i=n[e],this["_"+e]=this[e],this[e]=i)}return i.prototype.filterOptions=function(t){var r,i,o,s,a,u,l,c;return t||(t={}),t=n({},this.options,t),(r={writer:this}).pretty=t.pretty||!1,r.allowEmpty=t.allowEmpty||!1,r.indent=null!=(i=t.indent)?i:" ",r.newline=null!=(o=t.newline)?o:"\n",r.offset=null!=(s=t.offset)?s:0,r.dontPrettyTextNodes=null!=(a=null!=(u=t.dontPrettyTextNodes)?u:t.dontprettytextnodes)?a:0,r.spaceBeforeSlash=null!=(l=null!=(c=t.spaceBeforeSlash)?c:t.spacebeforeslash)?l:"",!0===r.spaceBeforeSlash&&(r.spaceBeforeSlash=" "),r.suppressPrettyCount=0,r.user={},r.state=e.None,r},i.prototype.indent=function(t,e,n){var r;return!e.pretty||e.suppressPrettyCount?"":e.pretty&&(r=(n||0)+e.offset+1)>0?new Array(r).join(e.indent):""},i.prototype.endline=function(t,e,n){return!e.pretty||e.suppressPrettyCount?"":e.newline},i.prototype.attribute=function(t,e,n){var r;return this.openAttribute(t,e,n),r=" "+t.name+'="'+t.value+'"',this.closeAttribute(t,e,n),r},i.prototype.cdata=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<![CDATA[",n.state=e.InsideTag,i+=t.value,n.state=e.CloseTag,i+="]]>"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.comment=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"\x3c!-- ",n.state=e.InsideTag,i+=t.value,n.state=e.CloseTag,i+=" --\x3e"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.declaration=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<?xml",n.state=e.InsideTag,i+=' version="'+t.version+'"',null!=t.encoding&&(i+=' encoding="'+t.encoding+'"'),null!=t.standalone&&(i+=' standalone="'+t.standalone+'"'),n.state=e.CloseTag,i+=n.spaceBeforeSlash+"?>",i+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.docType=function(t,n,r){var i,o,s,a,u;if(r||(r=0),this.openNode(t,n,r),n.state=e.OpenTag,a=this.indent(t,n,r),a+="<!DOCTYPE "+t.root().name,t.pubID&&t.sysID?a+=' PUBLIC "'+t.pubID+'" "'+t.sysID+'"':t.sysID&&(a+=' SYSTEM "'+t.sysID+'"'),t.children.length>0){for(a+=" [",a+=this.endline(t,n,r),n.state=e.InsideTag,o=0,s=(u=t.children).length;o<s;o++)i=u[o],a+=this.writeChildNode(i,n,r+1);n.state=e.CloseTag,a+="]"}return n.state=e.CloseTag,a+=n.spaceBeforeSlash+">",a+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),a},i.prototype.element=function(n,i,o){var s,a,u,l,c,h,p,f,d,g,m,y,_,v;for(d in o||(o=0),g=!1,m="",this.openNode(n,i,o),i.state=e.OpenTag,m+=this.indent(n,i,o)+"<"+n.name,y=n.attribs)r.call(y,d)&&(s=y[d],m+=this.attribute(s,i,o));if(l=0===(u=n.children.length)?null:n.children[0],0===u||n.children.every(function(e){return(e.type===t.Text||e.type===t.Raw)&&""===e.value}))i.allowEmpty?(m+=">",i.state=e.CloseTag,m+="</"+n.name+">"+this.endline(n,i,o)):(i.state=e.CloseTag,m+=i.spaceBeforeSlash+"/>"+this.endline(n,i,o));else if(!i.pretty||1!==u||l.type!==t.Text&&l.type!==t.Raw||null==l.value){if(i.dontPrettyTextNodes)for(c=0,p=(_=n.children).length;c<p;c++)if(((a=_[c]).type===t.Text||a.type===t.Raw)&&null!=a.value){i.suppressPrettyCount++,g=!0;break}for(m+=">"+this.endline(n,i,o),i.state=e.InsideTag,h=0,f=(v=n.children).length;h<f;h++)a=v[h],m+=this.writeChildNode(a,i,o+1);i.state=e.CloseTag,m+=this.indent(n,i,o)+"</"+n.name+">",g&&i.suppressPrettyCount--,m+=this.endline(n,i,o),i.state=e.None}else m+=">",i.state=e.InsideTag,i.suppressPrettyCount++,g=!0,m+=this.writeChildNode(l,i,o+1),i.suppressPrettyCount--,g=!1,i.state=e.CloseTag,m+="</"+n.name+">"+this.endline(n,i,o);return this.closeNode(n,i,o),m},i.prototype.writeChildNode=function(e,n,r){switch(e.type){case t.CData:return this.cdata(e,n,r);case t.Comment:return this.comment(e,n,r);case t.Element:return this.element(e,n,r);case t.Raw:return this.raw(e,n,r);case t.Text:return this.text(e,n,r);case t.ProcessingInstruction:return this.processingInstruction(e,n,r);case t.Dummy:return"";case t.Declaration:return this.declaration(e,n,r);case t.DocType:return this.docType(e,n,r);case t.AttributeDeclaration:return this.dtdAttList(e,n,r);case t.ElementDeclaration:return this.dtdElement(e,n,r);case t.EntityDeclaration:return this.dtdEntity(e,n,r);case t.NotationDeclaration:return this.dtdNotation(e,n,r);default:throw new Error("Unknown XML node type: "+e.constructor.name)}},i.prototype.processingInstruction=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<?",n.state=e.InsideTag,i+=t.target,t.value&&(i+=" "+t.value),n.state=e.CloseTag,i+=n.spaceBeforeSlash+"?>",i+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.raw=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r),n.state=e.InsideTag,i+=t.value,n.state=e.CloseTag,i+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.text=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r),n.state=e.InsideTag,i+=t.value,n.state=e.CloseTag,i+=this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.dtdAttList=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<!ATTLIST",n.state=e.InsideTag,i+=" "+t.elementName+" "+t.attributeName+" "+t.attributeType,"#DEFAULT"!==t.defaultValueType&&(i+=" "+t.defaultValueType),t.defaultValue&&(i+=' "'+t.defaultValue+'"'),n.state=e.CloseTag,i+=n.spaceBeforeSlash+">"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.dtdElement=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<!ELEMENT",n.state=e.InsideTag,i+=" "+t.name+" "+t.value,n.state=e.CloseTag,i+=n.spaceBeforeSlash+">"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.dtdEntity=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<!ENTITY",n.state=e.InsideTag,t.pe&&(i+=" %"),i+=" "+t.name,t.value?i+=' "'+t.value+'"':(t.pubID&&t.sysID?i+=' PUBLIC "'+t.pubID+'" "'+t.sysID+'"':t.sysID&&(i+=' SYSTEM "'+t.sysID+'"'),t.nData&&(i+=" NDATA "+t.nData)),n.state=e.CloseTag,i+=n.spaceBeforeSlash+">"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.dtdNotation=function(t,n,r){var i;return this.openNode(t,n,r),n.state=e.OpenTag,i=this.indent(t,n,r)+"<!NOTATION",n.state=e.InsideTag,i+=" "+t.name,t.pubID&&t.sysID?i+=' PUBLIC "'+t.pubID+'" "'+t.sysID+'"':t.pubID?i+=' PUBLIC "'+t.pubID+'"':t.sysID&&(i+=' SYSTEM "'+t.sysID+'"'),n.state=e.CloseTag,i+=n.spaceBeforeSlash+">"+this.endline(t,n,r),n.state=e.None,this.closeNode(t,n,r),i},i.prototype.openNode=function(t,e,n){},i.prototype.closeNode=function(t,e,n){},i.prototype.openAttribute=function(t,e,n){},i.prototype.closeAttribute=function(t,e,n){},i}()}.call(Su)),Du.exports}var ku,Lu=Au.exports;function Ru(){return ku||(ku=1,function(){var t,e={}.hasOwnProperty;t=Pu(),Au.exports=function(t){function n(t){n.__super__.constructor.call(this,t)}return function(t,n){for(var r in n)e.call(n,r)&&(t[r]=n[r]);function i(){this.constructor=t}i.prototype=n.prototype,t.prototype=new i,t.__super__=n.prototype}(n,t),n.prototype.document=function(t,e){var n,r,i,o,s;for(e=this.filterOptions(e),o="",r=0,i=(s=t.children).length;r<i;r++)n=s[r],o+=this.writeChildNode(n,e,0);return e.pretty&&o.slice(-e.newline.length)===e.newline&&(o=o.slice(0,-e.newline.length)),o},n}(t)}.call(Lu)),Au.exports}var Fu,ju=Fs.exports;function Uu(){return Fu||(Fu=1,function(){var t,e,n,r,i,o,s,a={}.hasOwnProperty;s=Ms().isPlainObject,n=Ls(),e=Gs(),r=wu(),t=ta(),o=Eu(),i=Ru(),Fs.exports=function(r){function u(n){u.__super__.constructor.call(this,null),this.name="#document",this.type=t.Document,this.documentURI=null,this.domConfig=new e,n||(n={}),n.writer||(n.writer=new i),this.options=n,this.stringify=new o(n)}return function(t,e){for(var n in e)a.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(u,r),Object.defineProperty(u.prototype,"implementation",{value:new n}),Object.defineProperty(u.prototype,"doctype",{get:function(){var e,n,r,i;for(n=0,r=(i=this.children).length;n<r;n++)if((e=i[n]).type===t.DocType)return e;return null}}),Object.defineProperty(u.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(u.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(u.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(u.prototype,"xmlEncoding",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration?this.children[0].encoding:null}}),Object.defineProperty(u.prototype,"xmlStandalone",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration&&"yes"===this.children[0].standalone}}),Object.defineProperty(u.prototype,"xmlVersion",{get:function(){return 0!==this.children.length&&this.children[0].type===t.Declaration?this.children[0].version:"1.0"}}),Object.defineProperty(u.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(u.prototype,"origin",{get:function(){return null}}),Object.defineProperty(u.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(u.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(u.prototype,"contentType",{get:function(){return null}}),u.prototype.end=function(t){var e;return e={},t?s(t)&&(e=t,t=this.options.writer):t=this.options.writer,t.document(this,t.filterOptions(e))},u.prototype.toString=function(t){return this.options.writer.document(this,this.options.writer.filterOptions(t))},u.prototype.createElement=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createDocumentFragment=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createTextNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createComment=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createCDATASection=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createProcessingInstruction=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createAttribute=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createEntityReference=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.getElementsByTagName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.importNode=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createElementNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createAttributeNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.getElementsByTagNameNS=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.getElementById=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.adoptNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.normalizeDocument=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.renameNode=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.getElementsByClassName=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createEvent=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createRange=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createNodeIterator=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},u.prototype.createTreeWalker=function(t,e,n){throw new Error("This DOM method is not implemented."+this.debugInfo())},u}(r)}.call(ju)),Fs.exports}var zu,Bu={exports:{}},Vu=Bu.exports;function Yu(){return zu||(zu=1,function(){var t,e,n,r,i,o,s,a,u,l,c,h,p,f,d,g,m,y,_,v,w,b,x,T={}.hasOwnProperty;x=Ms(),w=x.isObject,v=x.isFunction,b=x.isPlainObject,_=x.getValue,t=ta(),h=Uu(),p=ha(),r=va(),i=Ta(),d=Za(),y=eu(),f=ou(),l=Da(),c=Xa(),o=Sa(),a=Ra(),s=za(),u=$a(),n=ia(),m=Eu(),g=Ru(),e=Cu(),Bu.exports=function(){function x(e,n,r){var i;this.name="?xml",this.type=t.Document,e||(e={}),i={},e.writer?b(e.writer)&&(i=e.writer,e.writer=new g):e.writer=new g,this.options=e,this.writer=e.writer,this.writerOptions=this.writer.filterOptions(i),this.stringify=new m(e),this.onDataCallback=n||function(){},this.onEndCallback=r||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return x.prototype.createChildNode=function(e){var n,r,i,o,s,a,u,l;switch(e.type){case t.CData:this.cdata(e.value);break;case t.Comment:this.comment(e.value);break;case t.Element:for(r in i={},u=e.attribs)T.call(u,r)&&(n=u[r],i[r]=n.value);this.node(e.name,i);break;case t.Dummy:this.dummy();break;case t.Raw:this.raw(e.value);break;case t.Text:this.text(e.value);break;case t.ProcessingInstruction:this.instruction(e.target,e.value);break;default:throw new Error("This XML node type is not supported in a JS object: "+e.constructor.name)}for(s=0,a=(l=e.children).length;s<a;s++)o=l[s],this.createChildNode(o),o.type===t.Element&&this.up();return this},x.prototype.dummy=function(){return this},x.prototype.node=function(t,e,n){var r;if(null==t)throw new Error("Missing node name.");if(this.root&&-1===this.currentLevel)throw new Error("Document can only have one root node. "+this.debugInfo(t));return this.openCurrent(),t=_(t),null==e&&(e={}),e=_(e),w(e)||(n=(r=[e,n])[0],e=r[1]),this.currentNode=new p(this,t,e),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,null!=n&&this.text(n),this},x.prototype.element=function(e,n,r){var i,o,s,a,u,l;if(this.currentNode&&this.currentNode.type===t.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(e)||w(e)||v(e))for(a=this.options.noValidation,this.options.noValidation=!0,(l=new h(this.options).element("TEMP_ROOT")).element(e),this.options.noValidation=a,o=0,s=(u=l.children).length;o<s;o++)i=u[o],this.createChildNode(i),i.type===t.Element&&this.up();else this.node(e,n,r);return this},x.prototype.attribute=function(t,e){var r,i;if(!this.currentNode||this.currentNode.children)throw new Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(t));if(null!=t&&(t=_(t)),w(t))for(r in t)T.call(t,r)&&(i=t[r],this.attribute(r,i));else v(e)&&(e=e.apply()),this.options.keepNullAttributes&&null==e?this.currentNode.attribs[t]=new n(this,t,""):null!=e&&(this.currentNode.attribs[t]=new n(this,t,e));return this},x.prototype.text=function(t){var e;return this.openCurrent(),e=new y(this,t),this.onData(this.writer.text(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.cdata=function(t){var e;return this.openCurrent(),e=new r(this,t),this.onData(this.writer.cdata(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.comment=function(t){var e;return this.openCurrent(),e=new i(this,t),this.onData(this.writer.comment(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.raw=function(t){var e;return this.openCurrent(),e=new d(this,t),this.onData(this.writer.raw(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.instruction=function(t,e){var n,r,i,o,s;if(this.openCurrent(),null!=t&&(t=_(t)),null!=e&&(e=_(e)),Array.isArray(t))for(n=0,o=t.length;n<o;n++)r=t[n],this.instruction(r);else if(w(t))for(r in t)T.call(t,r)&&(i=t[r],this.instruction(r,i));else v(e)&&(e=e.apply()),s=new f(this,t,e),this.onData(this.writer.processingInstruction(s,this.writerOptions,this.currentLevel+1),this.currentLevel+1);return this},x.prototype.declaration=function(t,e,n){var r;if(this.openCurrent(),this.documentStarted)throw new Error("declaration() must be the first node.");return r=new l(this,t,e,n),this.onData(this.writer.declaration(r,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.doctype=function(t,e,n){if(this.openCurrent(),null==t)throw new Error("Missing root node name.");if(this.root)throw new Error("dtd() must come before the root node.");return this.currentNode=new c(this,e,n),this.currentNode.rootNodeName=t,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},x.prototype.dtdElement=function(t,e){var n;return this.openCurrent(),n=new s(this,t,e),this.onData(this.writer.dtdElement(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.attList=function(t,e,n,r,i){var s;return this.openCurrent(),s=new o(this,t,e,n,r,i),this.onData(this.writer.dtdAttList(s,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.entity=function(t,e){var n;return this.openCurrent(),n=new a(this,!1,t,e),this.onData(this.writer.dtdEntity(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.pEntity=function(t,e){var n;return this.openCurrent(),n=new a(this,!0,t,e),this.onData(this.writer.dtdEntity(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.notation=function(t,e){var n;return this.openCurrent(),n=new u(this,t,e),this.onData(this.writer.dtdNotation(n,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},x.prototype.up=function(){if(this.currentLevel<0)throw new Error("The document node has no parent.");return this.currentNode?(this.currentNode.children?this.closeNode(this.currentNode):this.openNode(this.currentNode),this.currentNode=null):this.closeNode(this.openTags[this.currentLevel]),delete this.openTags[this.currentLevel],this.currentLevel--,this},x.prototype.end=function(){for(;this.currentLevel>=0;)this.up();return this.onEnd()},x.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},x.prototype.openNode=function(n){var r,i,o,s;if(!n.isOpen){if(this.root||0!==this.currentLevel||n.type!==t.Element||(this.root=n),i="",n.type===t.Element){for(o in this.writerOptions.state=e.OpenTag,i=this.writer.indent(n,this.writerOptions,this.currentLevel)+"<"+n.name,s=n.attribs)T.call(s,o)&&(r=s[o],i+=this.writer.attribute(r,this.writerOptions,this.currentLevel));i+=(n.children?">":"/>")+this.writer.endline(n,this.writerOptions,this.currentLevel),this.writerOptions.state=e.InsideTag}else this.writerOptions.state=e.OpenTag,i=this.writer.indent(n,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+n.rootNodeName,n.pubID&&n.sysID?i+=' PUBLIC "'+n.pubID+'" "'+n.sysID+'"':n.sysID&&(i+=' SYSTEM "'+n.sysID+'"'),n.children?(i+=" [",this.writerOptions.state=e.InsideTag):(this.writerOptions.state=e.CloseTag,i+=">"),i+=this.writer.endline(n,this.writerOptions,this.currentLevel);return this.onData(i,this.currentLevel),n.isOpen=!0}},x.prototype.closeNode=function(n){var r;if(!n.isClosed)return r="",this.writerOptions.state=e.CloseTag,r=n.type===t.Element?this.writer.indent(n,this.writerOptions,this.currentLevel)+"</"+n.name+">"+this.writer.endline(n,this.writerOptions,this.currentLevel):this.writer.indent(n,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(n,this.writerOptions,this.currentLevel),this.writerOptions.state=e.None,this.onData(r,this.currentLevel),n.isClosed=!0},x.prototype.onData=function(t,e){return this.documentStarted=!0,this.onDataCallback(t,e+1)},x.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},x.prototype.debugInfo=function(t){return null==t?"":"node: <"+t+">"},x.prototype.ele=function(){return this.element.apply(this,arguments)},x.prototype.nod=function(t,e,n){return this.node(t,e,n)},x.prototype.txt=function(t){return this.text(t)},x.prototype.dat=function(t){return this.cdata(t)},x.prototype.com=function(t){return this.comment(t)},x.prototype.ins=function(t,e){return this.instruction(t,e)},x.prototype.dec=function(t,e,n){return this.declaration(t,e,n)},x.prototype.dtd=function(t,e,n){return this.doctype(t,e,n)},x.prototype.e=function(t,e,n){return this.element(t,e,n)},x.prototype.n=function(t,e,n){return this.node(t,e,n)},x.prototype.t=function(t){return this.text(t)},x.prototype.d=function(t){return this.cdata(t)},x.prototype.c=function(t){return this.comment(t)},x.prototype.r=function(t){return this.raw(t)},x.prototype.i=function(t,e){return this.instruction(t,e)},x.prototype.att=function(){return this.currentNode&&this.currentNode.type===t.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},x.prototype.a=function(){return this.currentNode&&this.currentNode.type===t.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},x.prototype.ent=function(t,e){return this.entity(t,e)},x.prototype.pent=function(t,e){return this.pEntity(t,e)},x.prototype.not=function(t,e){return this.notation(t,e)},x}()}.call(Vu)),Bu.exports}var $u,qu,Hu,Xu={exports:{}},Gu=Xu.exports;function Wu(){return $u||($u=1,function(){var t,e,n,r={}.hasOwnProperty;t=ta(),n=Pu(),e=Cu(),Xu.exports=function(n){function i(t,e){this.stream=t,i.__super__.constructor.call(this,e)}return function(t,e){for(var n in e)r.call(e,n)&&(t[n]=e[n]);function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype}(i,n),i.prototype.endline=function(t,n,r){return t.isLastRootNode&&n.state===e.CloseTag?"":i.__super__.endline.call(this,t,n,r)},i.prototype.document=function(t,e){var n,r,i,o,s,a,u,l,c;for(r=i=0,s=(u=t.children).length;i<s;r=++i)(n=u[r]).isLastRootNode=r===t.children.length-1;for(e=this.filterOptions(e),c=[],o=0,a=(l=t.children).length;o<a;o++)n=l[o],c.push(this.writeChildNode(n,e,0));return c},i.prototype.attribute=function(t,e,n){return this.stream.write(i.__super__.attribute.call(this,t,e,n))},i.prototype.cdata=function(t,e,n){return this.stream.write(i.__super__.cdata.call(this,t,e,n))},i.prototype.comment=function(t,e,n){return this.stream.write(i.__super__.comment.call(this,t,e,n))},i.prototype.declaration=function(t,e,n){return this.stream.write(i.__super__.declaration.call(this,t,e,n))},i.prototype.docType=function(t,n,r){var i,o,s,a;if(r||(r=0),this.openNode(t,n,r),n.state=e.OpenTag,this.stream.write(this.indent(t,n,r)),this.stream.write("<!DOCTYPE "+t.root().name),t.pubID&&t.sysID?this.stream.write(' PUBLIC "'+t.pubID+'" "'+t.sysID+'"'):t.sysID&&this.stream.write(' SYSTEM "'+t.sysID+'"'),t.children.length>0){for(this.stream.write(" ["),this.stream.write(this.endline(t,n,r)),n.state=e.InsideTag,o=0,s=(a=t.children).length;o<s;o++)i=a[o],this.writeChildNode(i,n,r+1);n.state=e.CloseTag,this.stream.write("]")}return n.state=e.CloseTag,this.stream.write(n.spaceBeforeSlash+">"),this.stream.write(this.endline(t,n,r)),n.state=e.None,this.closeNode(t,n,r)},i.prototype.element=function(n,i,o){var s,a,u,l,c,h,p,f,d;for(p in o||(o=0),this.openNode(n,i,o),i.state=e.OpenTag,this.stream.write(this.indent(n,i,o)+"<"+n.name),f=n.attribs)r.call(f,p)&&(s=f[p],this.attribute(s,i,o));if(l=0===(u=n.children.length)?null:n.children[0],0===u||n.children.every(function(e){return(e.type===t.Text||e.type===t.Raw)&&""===e.value}))i.allowEmpty?(this.stream.write(">"),i.state=e.CloseTag,this.stream.write("</"+n.name+">")):(i.state=e.CloseTag,this.stream.write(i.spaceBeforeSlash+"/>"));else if(!i.pretty||1!==u||l.type!==t.Text&&l.type!==t.Raw||null==l.value){for(this.stream.write(">"+this.endline(n,i,o)),i.state=e.InsideTag,c=0,h=(d=n.children).length;c<h;c++)a=d[c],this.writeChildNode(a,i,o+1);i.state=e.CloseTag,this.stream.write(this.indent(n,i,o)+"</"+n.name+">")}else this.stream.write(">"),i.state=e.InsideTag,i.suppressPrettyCount++,this.writeChildNode(l,i,o+1),i.suppressPrettyCount--,i.state=e.CloseTag,this.stream.write("</"+n.name+">");return this.stream.write(this.endline(n,i,o)),i.state=e.None,this.closeNode(n,i,o)},i.prototype.processingInstruction=function(t,e,n){return this.stream.write(i.__super__.processingInstruction.call(this,t,e,n))},i.prototype.raw=function(t,e,n){return this.stream.write(i.__super__.raw.call(this,t,e,n))},i.prototype.text=function(t,e,n){return this.stream.write(i.__super__.text.call(this,t,e,n))},i.prototype.dtdAttList=function(t,e,n){return this.stream.write(i.__super__.dtdAttList.call(this,t,e,n))},i.prototype.dtdElement=function(t,e,n){return this.stream.write(i.__super__.dtdElement.call(this,t,e,n))},i.prototype.dtdEntity=function(t,e,n){return this.stream.write(i.__super__.dtdEntity.call(this,t,e,n))},i.prototype.dtdNotation=function(t,e,n){return this.stream.write(i.__super__.dtdNotation.call(this,t,e,n))},i}(n)}.call(Gu)),Xu.exports}function Ku(){return Hu||(Hu=1,function(){var t,e,n,r,i,o={}.hasOwnProperty;qu||(qu=1,function(){var t,e,n,r,i,o,s,a,u,l;l=Ms(),a=l.assign,u=l.isFunction,n=Ls(),r=Uu(),i=Yu(),s=Ru(),o=Wu(),t=ta(),e=Cu(),Is.create=function(t,e,n,i){var o,s;if(null==t)throw new Error("Root element needs a name.");return i=a({},e,n,i),s=(o=new r(i)).element(t),i.headless||(o.declaration(i),null==i.pubID&&null==i.sysID||o.dtd(i)),s},Is.begin=function(t,e,n){var o;return u(t)&&(e=(o=[t,e])[0],n=o[1],t={}),e?new i(t,e,n):new r(t)},Is.stringWriter=function(t){return new s(t)},Is.streamWriter=function(t,e){return new o(t,e)},Is.implementation=new n,Is.nodeType=t,Is.writerState=e}.call(Is)),t=Is,e=As().defaults,r=function(t){return"string"==typeof t&&(t.indexOf("&")>=0||t.indexOf(">")>=0||t.indexOf("<")>=0)},i=function(t){return"<![CDATA["+n(t)+"]]>"},n=function(t){return t.replace("]]>","]]]]><![CDATA[>")},Os.Builder=function(){function n(t){var n,r,i;for(n in this.options={},r=e[.2])o.call(r,n)&&(i=r[n],this.options[n]=i);for(n in t)o.call(t,n)&&(i=t[n],this.options[n]=i)}return n.prototype.buildObject=function(n){var s,a,u,l,c,h;return s=this.options.attrkey,a=this.options.charkey,1===Object.keys(n).length&&this.options.rootName===e[.2].rootName?n=n[c=Object.keys(n)[0]]:c=this.options.rootName,h=this,u=function(t,e){var n,l,c,p,f,d;if("object"!=typeof e)h.options.cdata&&r(e)?t.raw(i(e)):t.txt(e);else if(Array.isArray(e)){for(p in e)if(o.call(e,p))for(f in l=e[p])c=l[f],t=u(t.ele(f),c).up()}else for(f in e)if(o.call(e,f))if(l=e[f],f===s){if("object"==typeof l)for(n in l)d=l[n],t=t.att(n,d)}else if(f===a)t=h.options.cdata&&r(l)?t.raw(i(l)):t.txt(l);else if(Array.isArray(l))for(p in l)o.call(l,p)&&(t="string"==typeof(c=l[p])?h.options.cdata&&r(c)?t.ele(f).raw(i(c)).up():t.ele(f,c).up():u(t.ele(f),c).up());else"object"==typeof l?t=u(t.ele(f),l).up():"string"==typeof l&&h.options.cdata&&r(l)?t=t.ele(f).raw(i(l)).up():(null==l&&(l=""),t=t.ele(f,l.toString()).up());return t},l=t.create(c,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),u(l,n).end(this.options.renderOpts)},n}()}.call(Os)),Os}var Zu={},Qu="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ju=[],tl=[],el="undefined"!=typeof Uint8Array?Uint8Array:Array,nl=!1;function rl(){nl=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)Ju[e]=t[e],tl[t.charCodeAt(e)]=e;tl["-".charCodeAt(0)]=62,tl["_".charCodeAt(0)]=63}function il(t){return Ju[t>>18&63]+Ju[t>>12&63]+Ju[t>>6&63]+Ju[63&t]}function ol(t,e,n){for(var r,i=[],o=e;o<n;o+=3)r=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(il(r));return i.join("")}function sl(t){var e;nl||rl();for(var n=t.length,r=n%3,i="",o=[],s=16383,a=0,u=n-r;a<u;a+=s)o.push(ol(t,a,a+s>u?u:a+s));return 1===r?(e=t[n-1],i+=Ju[e>>2],i+=Ju[e<<4&63],i+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],i+=Ju[e>>10],i+=Ju[e>>4&63],i+=Ju[e<<2&63],i+="="),o.push(i),o.join("")}function al(t,e,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,l=u>>1,c=-7,h=n?i-1:0,p=n?-1:1,f=t[e+h];for(h+=p,o=f&(1<<-c)-1,f>>=-c,c+=a;c>0;o=256*o+t[e+h],h+=p,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=256*s+t[e+h],h+=p,c-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=l}return(f?-1:1)*s*Math.pow(2,o-r)}function ul(t,e,n,r,i,o){var s,a,u,l=8*o-i-1,c=(1<<l)-1,h=c>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?p/u:p*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[n+f]=255&a,f+=d,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;t[n+f]=255&s,f+=d,s/=256,l-=8);t[n+f-d]|=128*g}var ll={}.toString,cl=Array.isArray||function(t){return"[object Array]"==ll.call(t)};function hl(){return fl.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function pl(t,e){if(hl()<e)throw new RangeError("Invalid typed array length");return fl.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=fl.prototype:(null===t&&(t=new fl(e)),t.length=e),t}function fl(t,e,n){if(!(fl.TYPED_ARRAY_SUPPORT||this instanceof fl))return new fl(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return ml(this,t)}return dl(this,t,e,n)}function dl(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);fl.TYPED_ARRAY_SUPPORT?(t=e).__proto__=fl.prototype:t=yl(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!fl.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|wl(e,n);t=pl(t,r);var i=t.write(e,n);i!==r&&(t=t.slice(0,i));return t}(t,e,n):function(t,e){if(vl(e)){var n=0|_l(e.length);return 0===(t=pl(t,n)).length||e.copy(t,0,0,n),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?pl(t,0):yl(t,e);if("Buffer"===e.type&&cl(e.data))return yl(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function gl(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function ml(t,e){if(gl(e),t=pl(t,e<0?0:0|_l(e)),!fl.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function yl(t,e){var n=e.length<0?0:0|_l(e.length);t=pl(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function _l(t){if(t>=hl())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+hl().toString(16)+" bytes");return 0|t}function vl(t){return!(null==t||!t._isBuffer)}function wl(t,e){if(vl(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Xl(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Gl(t).length;default:if(r)return Xl(t).length;e=(""+e).toLowerCase(),r=!0}}function bl(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return Rl(this,e,n);case"utf8":case"utf-8":return Sl(this,e,n);case"ascii":return kl(this,e,n);case"latin1":case"binary":return Ll(this,e,n);case"base64":return Ml(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Fl(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function xl(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Tl(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=fl.from(e,r)),vl(e))return 0===e.length?-1:El(t,e,n,r,i);if("number"==typeof e)return e&=255,fl.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):El(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function El(t,e,n,r,i){var o,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var c=-1;for(o=n;o<a;o++)if(l(t,o)===l(e,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){for(var h=!0,p=0;p<u;p++)if(l(t,o+p)!==l(e,p)){h=!1;break}if(h)return o}return-1}function Nl(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[n+s]=a}return s}function Al(t,e,n,r){return Wl(Xl(e,t.length-n),t,n,r)}function Dl(t,e,n,r){return Wl(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function Ol(t,e,n,r){return Dl(t,e,n,r)}function Il(t,e,n,r){return Wl(Gl(e),t,n,r)}function Cl(t,e,n,r){return Wl(function(t,e){for(var n,r,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=(n=t.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function Ml(t,e,n){return 0===e&&n===t.length?sl(t):sl(t.slice(e,n))}function Sl(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var o,s,a,u,l=t[i],c=null,h=l>239?4:l>223?3:l>191?2:1;if(i+h<=n)switch(h){case 1:l<128&&(c=l);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&l)<<6|63&o)>127&&(c=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&l)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=h}return function(t){var e=t.length;if(e<=Pl)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=Pl));return n}(r)}fl.TYPED_ARRAY_SUPPORT=void 0===Qu.TYPED_ARRAY_SUPPORT||Qu.TYPED_ARRAY_SUPPORT,hl(),fl.poolSize=8192,fl._augment=function(t){return t.__proto__=fl.prototype,t},fl.from=function(t,e,n){return dl(null,t,e,n)},fl.TYPED_ARRAY_SUPPORT&&(fl.prototype.__proto__=Uint8Array.prototype,fl.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&fl[Symbol.species]),fl.alloc=function(t,e,n){return function(t,e,n,r){return gl(e),e<=0?pl(t,e):void 0!==n?"string"==typeof r?pl(t,e).fill(n,r):pl(t,e).fill(n):pl(t,e)}(null,t,e,n)},fl.allocUnsafe=function(t){return ml(null,t)},fl.allocUnsafeSlow=function(t){return ml(null,t)},fl.isBuffer=function(t){return null!=t&&(!!t._isBuffer||Kl(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Kl(t.slice(0,0))}(t))},fl.compare=function(t,e){if(!vl(t)||!vl(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},fl.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},fl.concat=function(t,e){if(!cl(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return fl.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=fl.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var o=t[n];if(!vl(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},fl.byteLength=wl,fl.prototype._isBuffer=!0,fl.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)xl(this,e,e+1);return this},fl.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)xl(this,e,e+3),xl(this,e+1,e+2);return this},fl.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)xl(this,e,e+7),xl(this,e+1,e+6),xl(this,e+2,e+5),xl(this,e+3,e+4);return this},fl.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?Sl(this,0,t):bl.apply(this,arguments)},fl.prototype.equals=function(t){if(!vl(t))throw new TypeError("Argument must be a Buffer");return this===t||0===fl.compare(this,t)},fl.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},fl.prototype.compare=function(t,e,n,r,i){if(!vl(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(r,i),l=t.slice(e,n),c=0;c<a;++c)if(u[c]!==l[c]){o=u[c],s=l[c];break}return o<s?-1:s<o?1:0},fl.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},fl.prototype.indexOf=function(t,e,n){return Tl(this,t,e,n,!0)},fl.prototype.lastIndexOf=function(t,e,n){return Tl(this,t,e,n,!1)},fl.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return Nl(this,t,e,n);case"utf8":case"utf-8":return Al(this,t,e,n);case"ascii":return Dl(this,t,e,n);case"latin1":case"binary":return Ol(this,t,e,n);case"base64":return Il(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Cl(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},fl.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Pl=4096;function kl(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function Ll(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function Rl(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=e;o<n;++o)i+=Hl(t[o]);return i}function Fl(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function jl(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function Ul(t,e,n,r,i,o){if(!vl(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function zl(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i<o;++i)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function Bl(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i<o;++i)t[n+i]=e>>>8*(r?i:3-i)&255}function Vl(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Yl(t,e,n,r,i){return i||Vl(t,0,n,4),ul(t,e,n,r,23,4),n+4}function $l(t,e,n,r,i){return i||Vl(t,0,n,8),ul(t,e,n,r,52,8),n+8}fl.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),fl.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=fl.prototype;else{var i=e-t;n=new fl(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+t]}return n},fl.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||jl(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r},fl.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||jl(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},fl.prototype.readUInt8=function(t,e){return e||jl(t,1,this.length),this[t]},fl.prototype.readUInt16LE=function(t,e){return e||jl(t,2,this.length),this[t]|this[t+1]<<8},fl.prototype.readUInt16BE=function(t,e){return e||jl(t,2,this.length),this[t]<<8|this[t+1]},fl.prototype.readUInt32LE=function(t,e){return e||jl(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},fl.prototype.readUInt32BE=function(t,e){return e||jl(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},fl.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||jl(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},fl.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||jl(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},fl.prototype.readInt8=function(t,e){return e||jl(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},fl.prototype.readInt16LE=function(t,e){e||jl(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},fl.prototype.readInt16BE=function(t,e){e||jl(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},fl.prototype.readInt32LE=function(t,e){return e||jl(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},fl.prototype.readInt32BE=function(t,e){return e||jl(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},fl.prototype.readFloatLE=function(t,e){return e||jl(t,4,this.length),al(this,t,!0,23,4)},fl.prototype.readFloatBE=function(t,e){return e||jl(t,4,this.length),al(this,t,!1,23,4)},fl.prototype.readDoubleLE=function(t,e){return e||jl(t,8,this.length),al(this,t,!0,52,8)},fl.prototype.readDoubleBE=function(t,e){return e||jl(t,8,this.length),al(this,t,!1,52,8)},fl.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||Ul(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},fl.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||Ul(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},fl.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,1,255,0),fl.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},fl.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,2,65535,0),fl.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):zl(this,t,e,!0),e+2},fl.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,2,65535,0),fl.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):zl(this,t,e,!1),e+2},fl.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,4,4294967295,0),fl.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):Bl(this,t,e,!0),e+4},fl.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,4,4294967295,0),fl.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Bl(this,t,e,!1),e+4},fl.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);Ul(this,t,e,n,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<n&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s|0)-a&255;return e+n},fl.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);Ul(this,t,e,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s|0)-a&255;return e+n},fl.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,1,127,-128),fl.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},fl.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,2,32767,-32768),fl.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):zl(this,t,e,!0),e+2},fl.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,2,32767,-32768),fl.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):zl(this,t,e,!1),e+2},fl.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,4,2147483647,-2147483648),fl.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Bl(this,t,e,!0),e+4},fl.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||Ul(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),fl.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Bl(this,t,e,!1),e+4},fl.prototype.writeFloatLE=function(t,e,n){return Yl(this,t,e,!0,n)},fl.prototype.writeFloatBE=function(t,e,n){return Yl(this,t,e,!1,n)},fl.prototype.writeDoubleLE=function(t,e,n){return $l(this,t,e,!0,n)},fl.prototype.writeDoubleBE=function(t,e,n){return $l(this,t,e,!1,n)},fl.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,o=r-n;if(this===t&&n<e&&e<r)for(i=o-1;i>=0;--i)t[i+e]=this[i+n];else if(o<1e3||!fl.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o},fl.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!fl.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{var s=vl(t)?t:Xl(new fl(t,r).toString()),a=s.length;for(o=0;o<n-e;++o)this[o+e]=s[o%a]}return this};var ql=/[^+\/0-9A-Za-z-_]/g;function Hl(t){return t<16?"0"+t.toString(16):t.toString(16)}function Xl(t,e){var n;e=e||1/0;for(var r=t.length,i=null,o=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Gl(t){return function(t){var e,n,r,i,o,s;nl||rl();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[a-2]?2:"="===t[a-1]?1:0,s=new el(3*a/4-o),r=o>0?a-4:a;var u=0;for(e=0,n=0;e<r;e+=4,n+=3)i=tl[t.charCodeAt(e)]<<18|tl[t.charCodeAt(e+1)]<<12|tl[t.charCodeAt(e+2)]<<6|tl[t.charCodeAt(e+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=tl[t.charCodeAt(e)]<<2|tl[t.charCodeAt(e+1)]>>4,s[u++]=255&i):1===o&&(i=tl[t.charCodeAt(e)]<<10|tl[t.charCodeAt(e+1)]<<4|tl[t.charCodeAt(e+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(ql,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Wl(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Kl(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var Zl={};function Ql(){}function Jl(){Jl.init.call(this)}function tc(t){return void 0===t._maxListeners?Jl.defaultMaxListeners:t._maxListeners}function ec(t,e,n,r){var i,o,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]):(o=t._events=new Ql,t._eventsCount=0),s){if("function"==typeof s?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=tc(t))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[e]=n,++t._eventsCount;return t}function nc(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function rc(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function ic(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}Ql.prototype=Object.create(null),Jl.EventEmitter=Jl,Jl.usingDomains=!1,Jl.prototype.domain=void 0,Jl.prototype._events=void 0,Jl.prototype._maxListeners=void 0,Jl.defaultMaxListeners=10,Jl.init=function(){this.domain=null,Jl.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ql,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Jl.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},Jl.prototype.getMaxListeners=function(){return tc(this)},Jl.prototype.emit=function(t){var e,n,r,i,o,s,a,u="error"===t;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(a=this.domain,u){if(e=arguments[1],!a){if(e instanceof Error)throw e;var l=new Error('Uncaught, unspecified "error" event. ('+e+")");throw l.context=e,l}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=a,e.domainThrown=!1,a.emit("error",e),!1}if(!(n=s[t]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=ic(t,r),o=0;o<r;++o)i[o].call(n)}(n,c,this);break;case 2:!function(t,e,n,r){if(e)t.call(n,r);else for(var i=t.length,o=ic(t,i),s=0;s<i;++s)o[s].call(n,r)}(n,c,this,arguments[1]);break;case 3:!function(t,e,n,r,i){if(e)t.call(n,r,i);else for(var o=t.length,s=ic(t,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,c,this,arguments[1],arguments[2]);break;case 4:!function(t,e,n,r,i,o){if(e)t.call(n,r,i,o);else for(var s=t.length,a=ic(t,s),u=0;u<s;++u)a[u].call(n,r,i,o)}(n,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(t,e,n,r){if(e)t.apply(n,r);else for(var i=t.length,o=ic(t,i),s=0;s<i;++s)o[s].apply(n,r)}(n,c,this,i)}return!0},Jl.prototype.addListener=function(t,e){return ec(this,t,e,!1)},Jl.prototype.on=Jl.prototype.addListener,Jl.prototype.prependListener=function(t,e){return ec(this,t,e,!0)},Jl.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,nc(this,t,e)),this},Jl.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,nc(this,t,e)),this},Jl.prototype.removeListener=function(t,e){var n,r,i,o,s;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener&&n.listener===e)0===--this._eventsCount?this._events=new Ql:(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===e||n[o].listener&&n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0===--this._eventsCount)return this._events=new Ql,this;delete r[t]}else!function(t,e){for(var n=e,r=n+1,i=t.length;r<i;n+=1,r+=1)t[n]=t[r];t.pop()}(n,i);r.removeListener&&this.emit("removeListener",t,s||e)}return this},Jl.prototype.off=function(t,e){return this.removeListener(t,e)},Jl.prototype.removeAllListeners=function(t){var e,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Ql,this._eventsCount=0):n[t]&&(0===--this._eventsCount?this._events=new Ql:delete n[t]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Ql,this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(e)do{this.removeListener(t,e[e.length-1])}while(e[0]);return this},Jl.prototype.listeners=function(t){var e,n=this._events;return n&&(e=n[t])?"function"==typeof e?[e.listener||e]:function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(e):[]},Jl.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):rc.call(t,e)},Jl.prototype.listenerCount=rc,Jl.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var oc=Object.freeze({__proto__:null,default:Jl,EventEmitter:Jl});function sc(){throw new Error("setTimeout has not been defined")}function ac(){throw new Error("clearTimeout has not been defined")}var uc=sc,lc=ac;function cc(t){if(uc===setTimeout)return setTimeout(t,0);if((uc===sc||!uc)&&setTimeout)return uc=setTimeout,setTimeout(t,0);try{return uc(t,0)}catch(e){try{return uc.call(null,t,0)}catch(e){return uc.call(this,t,0)}}}"function"==typeof Qu.setTimeout&&(uc=setTimeout),"function"==typeof Qu.clearTimeout&&(lc=clearTimeout);var hc,pc=[],fc=!1,dc=-1;function gc(){fc&&hc&&(fc=!1,hc.length?pc=hc.concat(pc):dc=-1,pc.length&&mc())}function mc(){if(!fc){var t=cc(gc);fc=!0;for(var e=pc.length;e;){for(hc=pc,pc=[];++dc<e;)hc&&hc[dc].run();dc=-1,e=pc.length}hc=null,fc=!1,function(t){if(lc===clearTimeout)return clearTimeout(t);if((lc===ac||!lc)&&clearTimeout)return lc=clearTimeout,clearTimeout(t);try{return lc(t)}catch(e){try{return lc.call(null,t)}catch(e){return lc.call(this,t)}}}(t)}}function yc(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];pc.push(new _c(t,e)),1!==pc.length||fc||cc(mc)}function _c(t,e){this.fun=t,this.array=e}_c.prototype.run=function(){this.fun.apply(null,this.array)};function vc(){}var wc=vc,bc=vc,xc=vc,Tc=vc,Ec=vc,Nc=vc,Ac=vc;var Dc=Qu.performance||{},Oc=Dc.now||Dc.mozNow||Dc.msNow||Dc.oNow||Dc.webkitNow||function(){return(new Date).getTime()};var Ic=new Date;var Cc={nextTick:yc,title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:wc,addListener:bc,once:xc,off:Tc,removeListener:Ec,removeAllListeners:Nc,emit:Ac,binding:function(t){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*Oc.call(Dc),n=Math.floor(e),r=Math.floor(e%1*1e9);return t&&(n-=t[0],(r-=t[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Ic)/1e3}},Mc="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t},Sc=/%[sdj%]/g;function Pc(t){if(!qc(t)){for(var e=[],n=0;n<arguments.length;n++)e.push(Fc(arguments[n]));return e.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(t).replace(Sc,function(t){if("%%"===t)return"%";if(n>=i)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}}),s=r[n];n<i;s=r[++n])$c(s)||!Gc(s)?o+=" "+s:o+=" "+Fc(s);return o}function kc(t,e){if(Hc(Qu.process))return function(){return kc(t,e).apply(this,arguments)};if(!0===Cc.noDeprecation)return t;var n=!1;return function(){if(!n){if(Cc.throwDeprecation)throw new Error(e);Cc.traceDeprecation?console.trace(e):console.error(e),n=!0}return t.apply(this,arguments)}}var Lc,Rc={};function Fc(t,e){var n={seen:[],stylize:Uc};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),Yc(e)?n.showHidden=e:e&&function(t,e){if(!e||!Gc(e))return t;var n=Object.keys(e),r=n.length;for(;r--;)t[n[r]]=e[n[r]]}(n,e),Hc(n.showHidden)&&(n.showHidden=!1),Hc(n.depth)&&(n.depth=2),Hc(n.colors)&&(n.colors=!1),Hc(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=jc),zc(n,t,n.depth)}function jc(t,e){var n=Fc.styles[e];return n?"["+Fc.colors[n][0]+"m"+t+"["+Fc.colors[n][1]+"m":t}function Uc(t,e){return t}function zc(t,e,n){if(t.customInspect&&e&&Zc(e.inspect)&&e.inspect!==Fc&&(!e.constructor||e.constructor.prototype!==e)){var r=e.inspect(n,t);return qc(r)||(r=zc(t,r,n)),r}var i=function(t,e){if(Hc(e))return t.stylize("undefined","undefined");if(qc(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(r=e,"number"==typeof r)return t.stylize(""+e,"number");var r;if(Yc(e))return t.stylize(""+e,"boolean");if($c(e))return t.stylize("null","null")}(t,e);if(i)return i;var o=Object.keys(e),s=function(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),Kc(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Bc(e);if(0===o.length){if(Zc(e)){var a=e.name?": "+e.name:"";return t.stylize("[Function"+a+"]","special")}if(Xc(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(Wc(e))return t.stylize(Date.prototype.toString.call(e),"date");if(Kc(e))return Bc(e)}var u,l,c="",h=!1,p=["{","}"];(u=e,Array.isArray(u)&&(h=!0,p=["[","]"]),Zc(e))&&(c=" [Function"+(e.name?": "+e.name:"")+"]");return Xc(e)&&(c=" "+RegExp.prototype.toString.call(e)),Wc(e)&&(c=" "+Date.prototype.toUTCString.call(e)),Kc(e)&&(c=" "+Bc(e)),0!==o.length||h&&0!=e.length?n<0?Xc(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),l=h?function(t,e,n,r,i){for(var o=[],s=0,a=e.length;s<a;++s)Jc(e,String(s))?o.push(Vc(t,e,n,r,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(Vc(t,e,n,r,i,!0))}),o}(t,e,n,s,o):o.map(function(r){return Vc(t,e,n,s,r,h)}),t.seen.pop(),function(t,e,n){var r=t.reduce(function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(r>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(l,c,p)):p[0]+c+p[1]}function Bc(t){return"["+Error.prototype.toString.call(t)+"]"}function Vc(t,e,n,r,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),Jc(r,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=$c(n)?zc(t,u.value,null):zc(t,u.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),Hc(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function Yc(t){return"boolean"==typeof t}function $c(t){return null===t}function qc(t){return"string"==typeof t}function Hc(t){return void 0===t}function Xc(t){return Gc(t)&&"[object RegExp]"===Qc(t)}function Gc(t){return"object"==typeof t&&null!==t}function Wc(t){return Gc(t)&&"[object Date]"===Qc(t)}function Kc(t){return Gc(t)&&("[object Error]"===Qc(t)||t instanceof Error)}function Zc(t){return"function"==typeof t}function Qc(t){return Object.prototype.toString.call(t)}function Jc(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function th(){this.head=null,this.tail=null,this.length=0}Fc.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Fc.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},th.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},th.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},th.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},th.prototype.clear=function(){this.head=this.tail=null,this.length=0},th.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},th.prototype.concat=function(t){if(0===this.length)return fl.alloc(0);if(1===this.length)return this.head.data;for(var e=fl.allocUnsafe(t>>>0),n=this.head,r=0;n;)n.data.copy(e,r),r+=n.data.length,n=n.next;return e};var eh=fl.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function nh(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(t){if(t&&!eh(t))throw new Error("Unknown encoding: "+t)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=ih;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=oh;break;default:return void(this.write=rh)}this.charBuffer=new fl(6),this.charReceived=0,this.charLength=0}function rh(t){return t.toString(this.encoding)}function ih(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function oh(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}nh.prototype.write=function(t){for(var e="";this.charLength;){var n=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";if(t=t.slice(n,t.length),!((i=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var r=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,r),r-=this.charReceived);var i;r=(e+=t.toString(this.encoding,0,r)).length-1;if((i=e.charCodeAt(r))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,r)}return e},nh.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var n=t[t.length-e];if(1==e&&n>>5==6){this.charLength=2;break}if(e<=2&&n>>4==14){this.charLength=3;break}if(e<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=e},nh.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;e+=r.slice(0,n).toString(i)}return e};var sh=Object.freeze({__proto__:null,StringDecoder:nh});lh.ReadableState=uh;var ah=function(t){if(Hc(Lc)&&(Lc=Cc.env.NODE_DEBUG||""),t=t.toUpperCase(),!Rc[t])if(new RegExp("\\b"+t+"\\b","i").test(Lc)){Rc[t]=function(){var e=Pc.apply(null,arguments);console.error("%s %d: %s",t,0,e)}}else Rc[t]=function(){};return Rc[t]}("stream");function uh(t,e){t=t||{},this.objectMode=!!t.objectMode,e instanceof Fh&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var n=t.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.buffer=new th,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(this.decoder=new nh(t.encoding),this.encoding=t.encoding)}function lh(t){if(!(this instanceof lh))return new lh(t);this._readableState=new uh(t,this),this.readable=!0,t&&"function"==typeof t.read&&(this._read=t.read),Jl.call(this)}function ch(t,e,n,r,i){var o=function(t,e){var n=null;fl.isBuffer(e)||"string"==typeof e||null==e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));return n}(e,n);if(o)t.emit("error",o);else if(null===n)e.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,fh(t)}(t,e);else if(e.objectMode||n&&n.length>0)if(e.ended&&!i){var s=new Error("stream.push() after EOF");t.emit("error",s)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else{var u;!e.decoder||i||r||(n=e.decoder.write(n),u=!e.objectMode&&0===n.length),i||(e.reading=!1),u||(e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,i?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&fh(t))),function(t,e){e.readingMore||(e.readingMore=!0,yc(gh,t,e))}(t,e)}else i||(e.reading=!1);return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(e)}Mc(lh,Jl),lh.prototype.push=function(t,e){var n=this._readableState;return n.objectMode||"string"!=typeof t||(e=e||n.defaultEncoding)!==n.encoding&&(t=fl.from(t,e),e=""),ch(this,n,t,e,!1)},lh.prototype.unshift=function(t){return ch(this,this._readableState,t,"",!0)},lh.prototype.isPaused=function(){return!1===this._readableState.flowing},lh.prototype.setEncoding=function(t){return this._readableState.decoder=new nh(t),this._readableState.encoding=t,this};var hh=8388608;function ph(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=hh?t=hh:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function fh(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(ah("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?yc(dh,t):dh(t))}function dh(t){ah("emit readable"),t.emit("readable"),_h(t)}function gh(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(ah("maybeReadMore read 0"),t.read(0),n!==e.length);)n=e.length;e.readingMore=!1}function mh(t){ah("readable nexttick read 0"),t.read(0)}function yh(t,e){e.reading||(ah("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),_h(t),e.flowing&&!e.reading&&t.read(0)}function _h(t){var e=t._readableState;for(ah("flow",e.flowing);e.flowing&&null!==t.read(););}function vh(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;t<e.head.data.length?(r=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):r=t===e.head.data.length?e.shift():n?function(t,e){var n=e.head,r=1,i=n.data;t-=i.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=fl.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var o=r.data,s=t>o.length?o.length:t;if(o.copy(n,n.length-t,0,s),0===(t-=s)){s===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function wh(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,yc(bh,e,t))}function bh(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function xh(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1}function Th(){}function Eh(t,e,n){this.chunk=t,this.encoding=e,this.callback=n,this.next=null}function Nh(t,e){Object.defineProperty(this,"buffer",{get:kc(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),t=t||{},this.objectMode=!!t.objectMode,e instanceof Fh&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var n=t.highWaterMark,r=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:r,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=!1===t.decodeStrings;this.decodeStrings=!i,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,i=n.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,i){--e.pendingcb,n?yc(i,r):i(r);t._writableState.errorEmitted=!0,t.emit("error",r)}(t,n,r,e,i);else{var o=Ch(n);o||n.corked||n.bufferProcessing||!n.bufferedRequest||Ih(t,n),r?yc(Oh,t,n,o,i):Oh(t,n,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Ph(this)}function Ah(t){if(!(this instanceof Ah||this instanceof Fh))return new Ah(t);this._writableState=new Nh(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev)),Jl.call(this)}function Dh(t,e,n,r,i,o,s){e.writelen=r,e.writecb=s,e.writing=!0,e.sync=!0,n?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function Oh(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),Sh(t,e)}function Ih(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var s=0;n;)i[s]=n,n=n.next,s+=1;Dh(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new Ph(e)}else{for(;n;){var a=n.chunk,u=n.encoding,l=n.callback;if(Dh(t,e,!1,e.objectMode?1:a.length,a,u,l),n=n.next,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequestCount=0,e.bufferedRequest=n,e.bufferProcessing=!1}function Ch(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function Mh(t,e){e.prefinished||(e.prefinished=!0,t.emit("prefinish"))}function Sh(t,e){var n=Ch(e);return n&&(0===e.pendingcb?(Mh(t,e),e.finished=!0,t.emit("finish")):Mh(t,e)),n}function Ph(t){var e=this;this.next=null,this.entry=null,this.finish=function(n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}}lh.prototype.read=function(t){ah("read",t),t=parseInt(t,10);var e=this._readableState,n=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return ah("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?wh(this):fh(this),null;if(0===(t=ph(t,e))&&e.ended)return 0===e.length&&wh(this),null;var r,i=e.needReadable;return ah("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&ah("length less than watermark",i=!0),e.ended||e.reading?ah("reading or ended",i=!1):i&&(ah("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=ph(n,e))),null===(r=t>0?vh(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&wh(this)),null!==r&&this.emit("data",r),r},lh.prototype._read=function(t){this.emit("error",new Error("not implemented"))},lh.prototype.pipe=function(t,e){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=t;break;case 1:r.pipes=[r.pipes,t];break;default:r.pipes.push(t)}r.pipesCount+=1,ah("pipe count=%d opts=%j",r.pipesCount,e);var i=!e||!1!==e.end?s:l;function o(t){ah("onunpipe"),t===n&&l()}function s(){ah("onend"),t.end()}r.endEmitted?yc(i):n.once("end",i),t.on("unpipe",o);var a=function(t){return function(){var e=t._readableState;ah("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&t.listeners("data").length&&(e.flowing=!0,_h(t))}}(n);t.on("drain",a);var u=!1;function l(){ah("cleanup"),t.removeListener("close",f),t.removeListener("finish",d),t.removeListener("drain",a),t.removeListener("error",p),t.removeListener("unpipe",o),n.removeListener("end",s),n.removeListener("end",l),n.removeListener("data",h),u=!0,!r.awaitDrain||t._writableState&&!t._writableState.needDrain||a()}var c=!1;function h(e){ah("ondata"),c=!1,!1!==t.write(e)||c||((1===r.pipesCount&&r.pipes===t||r.pipesCount>1&&-1!==xh(r.pipes,t))&&!u&&(ah("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,c=!0),n.pause())}function p(e){ah("onerror",e),g(),t.removeListener("error",p),0===function(t,e){return t.listeners(e).length}(t,"error")&&t.emit("error",e)}function f(){t.removeListener("finish",d),g()}function d(){ah("onfinish"),t.removeListener("close",f),g()}function g(){ah("unpipe"),n.unpipe(t)}return n.on("data",h),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",p),t.once("close",f),t.once("finish",d),t.emit("pipe",n),r.flowing||(ah("pipe resume"),n.resume()),t},lh.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this)),this;if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this);return this}var o=xh(e.pipes,t);return-1===o||(e.pipes.splice(o,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this)),this},lh.prototype.on=function(t,e){var n=Jl.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&fh(this):yc(mh,this))}return n},lh.prototype.addListener=lh.prototype.on,lh.prototype.resume=function(){var t=this._readableState;return t.flowing||(ah("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,yc(yh,t,e))}(this,t)),this},lh.prototype.pause=function(){return ah("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(ah("pause"),this._readableState.flowing=!1,this.emit("pause")),this},lh.prototype.wrap=function(t){var e=this._readableState,n=!1,r=this;for(var i in t.on("end",function(){if(ah("wrapped end"),e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&r.push(t)}r.push(null)}),t.on("data",function(i){(ah("wrapped data"),e.decoder&&(i=e.decoder.write(i)),e.objectMode&&null==i)||(e.objectMode||i&&i.length)&&(r.push(i)||(n=!0,t.pause()))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));return function(t,e){for(var n=0,r=t.length;n<r;n++)e(t[n],n)}(["error","close","destroy","pause","resume"],function(e){t.on(e,r.emit.bind(r,e))}),r._read=function(e){ah("wrapped _read",e),n&&(n=!1,t.resume())},r},lh._fromList=vh,Ah.WritableState=Nh,Mc(Ah,Jl),Nh.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},Ah.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ah.prototype.write=function(t,e,n){var r=this._writableState,i=!1;return"function"==typeof e&&(n=e,e=null),fl.isBuffer(t)?e="buffer":e||(e=r.defaultEncoding),"function"!=typeof n&&(n=Th),r.ended?function(t,e){var n=new Error("write after end");t.emit("error",n),yc(e,n)}(this,n):function(t,e,n,r){var i=!0,o=!1;return null===n?o=new TypeError("May not write null values to stream"):fl.isBuffer(n)||"string"==typeof n||void 0===n||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),yc(r,o),i=!1),i}(this,r,t,n)&&(r.pendingcb++,i=function(t,e,n,r,i){n=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=fl.from(e,n));return e}(e,n,r),fl.isBuffer(n)&&(r="buffer");var o=e.objectMode?1:n.length;e.length+=o;var s=e.length<e.highWaterMark;s||(e.needDrain=!0);if(e.writing||e.corked){var a=e.lastBufferedRequest;e.lastBufferedRequest=new Eh(n,r,i),a?a.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else Dh(t,e,!1,o,n,r,i);return s}(this,r,t,e,n)),i},Ah.prototype.cork=function(){this._writableState.corked++},Ah.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.bufferedRequest||Ih(this,t))},Ah.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Ah.prototype._write=function(t,e,n){n(new Error("not implemented"))},Ah.prototype._writev=null,Ah.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(t,e,n){e.ending=!0,Sh(t,e),n&&(e.finished?yc(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,r,n)},Mc(Fh,lh);for(var kh=Object.keys(Ah.prototype),Lh=0;Lh<kh.length;Lh++){var Rh=kh[Lh];Fh.prototype[Rh]||(Fh.prototype[Rh]=Ah.prototype[Rh])}function Fh(t){if(!(this instanceof Fh))return new Fh(t);lh.call(this,t),Ah.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",jh)}function jh(){this.allowHalfOpen||this._writableState.ended||yc(Uh,this)}function Uh(t){t.end()}function zh(t){this.afterTransform=function(e,n){return function(t,e,n){var r=t._transformState;r.transforming=!1;var i=r.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!=n&&t.push(n);i(e);var o=t._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&t._read(o.highWaterMark)}(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function Bh(t){if(!(this instanceof Bh))return new Bh(t);Fh.call(this,t),this._transformState=new zh(this);var e=this;this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(t){Vh(e,t)}):Vh(e)})}function Vh(t,e){if(e)return t.emit("error",e);var n=t._writableState,r=t._transformState;if(n.length)throw new Error("Calling transform done when ws.length != 0");if(r.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}function Yh(t){if(!(this instanceof Yh))return new Yh(t);Bh.call(this,t)}function $h(){Jl.call(this)}Mc(Bh,Fh),Bh.prototype.push=function(t,e){return this._transformState.needTransform=!1,Fh.prototype.push.call(this,t,e)},Bh.prototype._transform=function(t,e,n){throw new Error("Not implemented")},Bh.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},Bh.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},Mc(Yh,Bh),Yh.prototype._transform=function(t,e,n){n(null,t)},Mc($h,Jl),$h.Readable=lh,$h.Writable=Ah,$h.Duplex=Fh,$h.Transform=Bh,$h.PassThrough=Yh,$h.Stream=$h,$h.prototype.pipe=function(t,e){var n=this;function r(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function i(){n.readable&&n.resume&&n.resume()}n.on("data",r),t.on("drain",i),t._isStdio||e&&!1===e.end||(n.on("end",s),n.on("close",a));var o=!1;function s(){o||(o=!0,t.end())}function a(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function u(t){if(l(),0===Jl.listenerCount(this,"error"))throw t}function l(){n.removeListener("data",r),t.removeListener("drain",i),n.removeListener("end",s),n.removeListener("close",a),n.removeListener("error",u),t.removeListener("error",u),n.removeListener("end",l),n.removeListener("close",l),t.removeListener("close",l)}return n.on("error",u),t.on("error",u),n.on("end",l),n.on("close",l),t.on("close",l),t.emit("pipe",n),t};var qh,Hh=xs(Object.freeze({__proto__:null,default:$h,Readable:lh,Writable:Ah,Duplex:Fh,Transform:Bh,PassThrough:Yh,Stream:$h})),Xh=xs(sh);function Gh(){return qh||(qh=1,function(t){!function(t){t.parser=function(t,e){return new r(t,e)},t.SAXParser=r,t.SAXStream=o,t.createStream=function(t,e){return new o(t,e)},t.MAX_BUFFER_LENGTH=65536;var e,n=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function r(e,i){if(!(this instanceof r))return new r(e,i);var o=this;!function(t){for(var e=0,r=n.length;e<r;e++)t[n[e]]=""}(o),o.q=o.c="",o.bufferCheckPosition=t.MAX_BUFFER_LENGTH,o.opt=i||{},o.opt.lowercase=o.opt.lowercase||o.opt.lowercasetags,o.looseCase=o.opt.lowercase?"toLowerCase":"toUpperCase",o.tags=[],o.closed=o.closedRoot=o.sawRoot=!1,o.tag=o.error=null,o.strict=!!e,o.noscript=!(!e&&!o.opt.noscript),o.state=T.BEGIN,o.strictEntities=o.opt.strictEntities,o.ENTITIES=o.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),o.attribList=[],o.opt.xmlns&&(o.ns=Object.create(c)),o.trackPosition=!1!==o.opt.position,o.trackPosition&&(o.position=o.line=o.column=0),N(o,"onready")}t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(t){function e(){}return e.prototype=t,new e}),Object.keys||(Object.keys=function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e}),r.prototype={end:function(){C(this)},write:function(e){var r=this;if(this.error)throw this.error;if(r.closed)return I(r,"Cannot write after close. Assign an onready handler.");if(null===e)return C(r);"object"==typeof e&&(e=e.toString());var i=0,o="";for(;o=U(e,i++),r.c=o,o;)switch(r.trackPosition&&(r.position++,"\n"===o?(r.line++,r.column=0):r.column++),r.state){case T.BEGIN:if(r.state=T.BEGIN_WHITESPACE,"\ufeff"===o)continue;j(r,o);continue;case T.BEGIN_WHITESPACE:j(r,o);continue;case T.TEXT:if(r.sawRoot&&!r.closedRoot){for(var u=i-1;o&&"<"!==o&&"&"!==o;)(o=U(e,i++))&&r.trackPosition&&(r.position++,"\n"===o?(r.line++,r.column=0):r.column++);r.textNode+=e.substring(u,i-1)}"<"!==o||r.sawRoot&&r.closedRoot&&!r.strict?(g(o)||r.sawRoot&&!r.closedRoot||M(r,"Text data outside of root node."),"&"===o?r.state=T.TEXT_ENTITY:r.textNode+=o):(r.state=T.OPEN_WAKA,r.startTagPosition=r.position);continue;case T.SCRIPT:"<"===o?r.state=T.SCRIPT_ENDING:r.script+=o;continue;case T.SCRIPT_ENDING:"/"===o?r.state=T.CLOSE_TAG:(r.script+="<"+o,r.state=T.SCRIPT);continue;case T.OPEN_WAKA:if("!"===o)r.state=T.SGML_DECL,r.sgmlDecl="";else if(g(o));else if(_(h,o))r.state=T.OPEN_TAG,r.tagName=o;else if("/"===o)r.state=T.CLOSE_TAG,r.tagName="";else if("?"===o)r.state=T.PROC_INST,r.procInstName=r.procInstBody="";else{if(M(r,"Unencoded <"),r.startTagPosition+1<r.position){var l=r.position-r.startTagPosition;o=new Array(l).join(" ")+o}r.textNode+="<"+o,r.state=T.TEXT}continue;case T.SGML_DECL:(r.sgmlDecl+o).toUpperCase()===s?(A(r,"onopencdata"),r.state=T.CDATA,r.sgmlDecl="",r.cdata=""):r.sgmlDecl+o==="--"?(r.state=T.COMMENT,r.comment="",r.sgmlDecl=""):(r.sgmlDecl+o).toUpperCase()===a?(r.state=T.DOCTYPE,(r.doctype||r.sawRoot)&&M(r,"Inappropriately located doctype declaration"),r.doctype="",r.sgmlDecl=""):">"===o?(A(r,"onsgmldeclaration",r.sgmlDecl),r.sgmlDecl="",r.state=T.TEXT):m(o)?(r.state=T.SGML_DECL_QUOTED,r.sgmlDecl+=o):r.sgmlDecl+=o;continue;case T.SGML_DECL_QUOTED:o===r.q&&(r.state=T.SGML_DECL,r.q=""),r.sgmlDecl+=o;continue;case T.DOCTYPE:">"===o?(r.state=T.TEXT,A(r,"ondoctype",r.doctype),r.doctype=!0):(r.doctype+=o,"["===o?r.state=T.DOCTYPE_DTD:m(o)&&(r.state=T.DOCTYPE_QUOTED,r.q=o));continue;case T.DOCTYPE_QUOTED:r.doctype+=o,o===r.q&&(r.q="",r.state=T.DOCTYPE);continue;case T.DOCTYPE_DTD:r.doctype+=o,"]"===o?r.state=T.DOCTYPE:m(o)&&(r.state=T.DOCTYPE_DTD_QUOTED,r.q=o);continue;case T.DOCTYPE_DTD_QUOTED:r.doctype+=o,o===r.q&&(r.state=T.DOCTYPE_DTD,r.q="");continue;case T.COMMENT:"-"===o?r.state=T.COMMENT_ENDING:r.comment+=o;continue;case T.COMMENT_ENDING:"-"===o?(r.state=T.COMMENT_ENDED,r.comment=O(r.opt,r.comment),r.comment&&A(r,"oncomment",r.comment),r.comment=""):(r.comment+="-"+o,r.state=T.COMMENT);continue;case T.COMMENT_ENDED:">"!==o?(M(r,"Malformed comment"),r.comment+="--"+o,r.state=T.COMMENT):r.state=T.TEXT;continue;case T.CDATA:"]"===o?r.state=T.CDATA_ENDING:r.cdata+=o;continue;case T.CDATA_ENDING:"]"===o?r.state=T.CDATA_ENDING_2:(r.cdata+="]"+o,r.state=T.CDATA);continue;case T.CDATA_ENDING_2:">"===o?(r.cdata&&A(r,"oncdata",r.cdata),A(r,"onclosecdata"),r.cdata="",r.state=T.TEXT):"]"===o?r.cdata+="]":(r.cdata+="]]"+o,r.state=T.CDATA);continue;case T.PROC_INST:"?"===o?r.state=T.PROC_INST_ENDING:g(o)?r.state=T.PROC_INST_BODY:r.procInstName+=o;continue;case T.PROC_INST_BODY:if(!r.procInstBody&&g(o))continue;"?"===o?r.state=T.PROC_INST_ENDING:r.procInstBody+=o;continue;case T.PROC_INST_ENDING:">"===o?(A(r,"onprocessinginstruction",{name:r.procInstName,body:r.procInstBody}),r.procInstName=r.procInstBody="",r.state=T.TEXT):(r.procInstBody+="?"+o,r.state=T.PROC_INST_BODY);continue;case T.OPEN_TAG:_(p,o)?r.tagName+=o:(S(r),">"===o?L(r):"/"===o?r.state=T.OPEN_TAG_SLASH:(g(o)||M(r,"Invalid character in tag name"),r.state=T.ATTRIB));continue;case T.OPEN_TAG_SLASH:">"===o?(L(r,!0),R(r)):(M(r,"Forward-slash in opening tag not followed by >"),r.state=T.ATTRIB);continue;case T.ATTRIB:if(g(o))continue;">"===o?L(r):"/"===o?r.state=T.OPEN_TAG_SLASH:_(h,o)?(r.attribName=o,r.attribValue="",r.state=T.ATTRIB_NAME):M(r,"Invalid attribute name");continue;case T.ATTRIB_NAME:"="===o?r.state=T.ATTRIB_VALUE:">"===o?(M(r,"Attribute without value"),r.attribValue=r.attribName,k(r),L(r)):g(o)?r.state=T.ATTRIB_NAME_SAW_WHITE:_(p,o)?r.attribName+=o:M(r,"Invalid attribute name");continue;case T.ATTRIB_NAME_SAW_WHITE:if("="===o)r.state=T.ATTRIB_VALUE;else{if(g(o))continue;M(r,"Attribute without value"),r.tag.attributes[r.attribName]="",r.attribValue="",A(r,"onattribute",{name:r.attribName,value:""}),r.attribName="",">"===o?L(r):_(h,o)?(r.attribName=o,r.state=T.ATTRIB_NAME):(M(r,"Invalid attribute name"),r.state=T.ATTRIB)}continue;case T.ATTRIB_VALUE:if(g(o))continue;m(o)?(r.q=o,r.state=T.ATTRIB_VALUE_QUOTED):(M(r,"Unquoted attribute value"),r.state=T.ATTRIB_VALUE_UNQUOTED,r.attribValue=o);continue;case T.ATTRIB_VALUE_QUOTED:if(o!==r.q){"&"===o?r.state=T.ATTRIB_VALUE_ENTITY_Q:r.attribValue+=o;continue}k(r),r.q="",r.state=T.ATTRIB_VALUE_CLOSED;continue;case T.ATTRIB_VALUE_CLOSED:g(o)?r.state=T.ATTRIB:">"===o?L(r):"/"===o?r.state=T.OPEN_TAG_SLASH:_(h,o)?(M(r,"No whitespace between attributes"),r.attribName=o,r.attribValue="",r.state=T.ATTRIB_NAME):M(r,"Invalid attribute name");continue;case T.ATTRIB_VALUE_UNQUOTED:if(!y(o)){"&"===o?r.state=T.ATTRIB_VALUE_ENTITY_U:r.attribValue+=o;continue}k(r),">"===o?L(r):r.state=T.ATTRIB;continue;case T.CLOSE_TAG:if(r.tagName)">"===o?R(r):_(p,o)?r.tagName+=o:r.script?(r.script+="</"+r.tagName,r.tagName="",r.state=T.SCRIPT):(g(o)||M(r,"Invalid tagname in closing tag"),r.state=T.CLOSE_TAG_SAW_WHITE);else{if(g(o))continue;v(h,o)?r.script?(r.script+="</"+o,r.state=T.SCRIPT):M(r,"Invalid tagname in closing tag."):r.tagName=o}continue;case T.CLOSE_TAG_SAW_WHITE:if(g(o))continue;">"===o?R(r):M(r,"Invalid characters in closing tag");continue;case T.TEXT_ENTITY:case T.ATTRIB_VALUE_ENTITY_Q:case T.ATTRIB_VALUE_ENTITY_U:var c,w;switch(r.state){case T.TEXT_ENTITY:c=T.TEXT,w="textNode";break;case T.ATTRIB_VALUE_ENTITY_Q:c=T.ATTRIB_VALUE_QUOTED,w="attribValue";break;case T.ATTRIB_VALUE_ENTITY_U:c=T.ATTRIB_VALUE_UNQUOTED,w="attribValue"}";"===o?(r[w]+=F(r),r.entity="",r.state=c):_(r.entity.length?d:f,o)?r.entity+=o:(M(r,"Invalid character in entity name"),r[w]+="&"+r.entity+o,r.entity="",r.state=c);continue;default:throw new Error(r,"Unknown state: "+r.state)}r.position>=r.bufferCheckPosition&&function(e){for(var r=Math.max(t.MAX_BUFFER_LENGTH,10),i=0,o=0,s=n.length;o<s;o++){var a=e[n[o]].length;if(a>r)switch(n[o]){case"textNode":D(e);break;case"cdata":A(e,"oncdata",e.cdata),e.cdata="";break;case"script":A(e,"onscript",e.script),e.script="";break;default:I(e,"Max buffer length exceeded: "+n[o])}i=Math.max(i,a)}var u=t.MAX_BUFFER_LENGTH-i;e.bufferCheckPosition=u+e.position}(r);return r}
2
- /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){!function(t){D(t),""!==t.cdata&&(A(t,"oncdata",t.cdata),t.cdata=""),""!==t.script&&(A(t,"onscript",t.script),t.script="")}(this)}};try{e=Hh.Stream}catch(t){e=function(){}}var i=t.EVENTS.filter(function(t){return"error"!==t&&"end"!==t});function o(t,n){if(!(this instanceof o))return new o(t,n);e.apply(this),this._parser=new r(t,n),this.writable=!0,this.readable=!0;var s=this;this._parser.onend=function(){s.emit("end")},this._parser.onerror=function(t){s.emit("error",t),s._parser.error=null},this._decoder=null,i.forEach(function(t){Object.defineProperty(s,"on"+t,{get:function(){return s._parser["on"+t]},set:function(e){if(!e)return s.removeAllListeners(t),s._parser["on"+t]=e,e;s.on(t,e)},enumerable:!0,configurable:!1})})}o.prototype=Object.create(e.prototype,{constructor:{value:o}}),o.prototype.write=function(t){if("function"==typeof fl.isBuffer&&fl.isBuffer(t)){if(!this._decoder){var e=Xh.StringDecoder;this._decoder=new e("utf8")}t=this._decoder.write(t)}return this._parser.write(t.toString()),this.emit("data",t),!0},o.prototype.end=function(t){return t&&t.length&&this.write(t),this._parser.end(),!0},o.prototype.on=function(t,n){var r=this;return r._parser["on"+t]||-1===i.indexOf(t)||(r._parser["on"+t]=function(){var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);e.splice(0,0,t),r.emit.apply(r,e)}),e.prototype.on.call(r,t,n)};var s="[CDATA[",a="DOCTYPE",u="http://www.w3.org/XML/1998/namespace",l="http://www.w3.org/2000/xmlns/",c={xml:u,xmlns:l},h=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,p=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,f=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,d=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function g(t){return" "===t||"\n"===t||"\r"===t||"\t"===t}function m(t){return'"'===t||"'"===t}function y(t){return">"===t||g(t)}function _(t,e){return t.test(e)}function v(t,e){return!_(t,e)}var w,b,x,T=0;for(var E in t.STATE={BEGIN:T++,BEGIN_WHITESPACE:T++,TEXT:T++,TEXT_ENTITY:T++,OPEN_WAKA:T++,SGML_DECL:T++,SGML_DECL_QUOTED:T++,DOCTYPE:T++,DOCTYPE_QUOTED:T++,DOCTYPE_DTD:T++,DOCTYPE_DTD_QUOTED:T++,COMMENT_STARTING:T++,COMMENT:T++,COMMENT_ENDING:T++,COMMENT_ENDED:T++,CDATA:T++,CDATA_ENDING:T++,CDATA_ENDING_2:T++,PROC_INST:T++,PROC_INST_BODY:T++,PROC_INST_ENDING:T++,OPEN_TAG:T++,OPEN_TAG_SLASH:T++,ATTRIB:T++,ATTRIB_NAME:T++,ATTRIB_NAME_SAW_WHITE:T++,ATTRIB_VALUE:T++,ATTRIB_VALUE_QUOTED:T++,ATTRIB_VALUE_CLOSED:T++,ATTRIB_VALUE_UNQUOTED:T++,ATTRIB_VALUE_ENTITY_Q:T++,ATTRIB_VALUE_ENTITY_U:T++,CLOSE_TAG:T++,CLOSE_TAG_SAW_WHITE:T++,SCRIPT:T++,SCRIPT_ENDING:T++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(e){var n=t.ENTITIES[e],r="number"==typeof n?String.fromCharCode(n):n;t.ENTITIES[e]=r}),t.STATE)t.STATE[t.STATE[E]]=E;function N(t,e,n){t[e]&&t[e](n)}function A(t,e,n){t.textNode&&D(t),N(t,e,n)}function D(t){t.textNode=O(t.opt,t.textNode),t.textNode&&N(t,"ontext",t.textNode),t.textNode=""}function O(t,e){return t.trim&&(e=e.trim()),t.normalize&&(e=e.replace(/\s+/g," ")),e}function I(t,e){return D(t),t.trackPosition&&(e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c),e=new Error(e),t.error=e,N(t,"onerror",e),t}function C(t){return t.sawRoot&&!t.closedRoot&&M(t,"Unclosed root tag"),t.state!==T.BEGIN&&t.state!==T.BEGIN_WHITESPACE&&t.state!==T.TEXT&&I(t,"Unexpected end"),D(t),t.c="",t.closed=!0,N(t,"onend"),r.call(t,t.strict,t.opt),t}function M(t,e){if("object"!=typeof t||!(t instanceof r))throw new Error("bad call to strictFail");t.strict&&I(t,e)}function S(t){t.strict||(t.tagName=t.tagName[t.looseCase]());var e=t.tags[t.tags.length-1]||t,n=t.tag={name:t.tagName,attributes:{}};t.opt.xmlns&&(n.ns=e.ns),t.attribList.length=0,A(t,"onopentagstart",n)}function P(t,e){var n=t.indexOf(":")<0?["",t]:t.split(":"),r=n[0],i=n[1];return e&&"xmlns"===t&&(r="xmlns",i=""),{prefix:r,local:i}}function k(t){if(t.strict||(t.attribName=t.attribName[t.looseCase]()),-1!==t.attribList.indexOf(t.attribName)||t.tag.attributes.hasOwnProperty(t.attribName))t.attribName=t.attribValue="";else{if(t.opt.xmlns){var e=P(t.attribName,!0),n=e.prefix,r=e.local;if("xmlns"===n)if("xml"===r&&t.attribValue!==u)M(t,"xml: prefix must be bound to "+u+"\nActual: "+t.attribValue);else if("xmlns"===r&&t.attribValue!==l)M(t,"xmlns: prefix must be bound to "+l+"\nActual: "+t.attribValue);else{var i=t.tag,o=t.tags[t.tags.length-1]||t;i.ns===o.ns&&(i.ns=Object.create(o.ns)),i.ns[r]=t.attribValue}t.attribList.push([t.attribName,t.attribValue])}else t.tag.attributes[t.attribName]=t.attribValue,A(t,"onattribute",{name:t.attribName,value:t.attribValue});t.attribName=t.attribValue=""}}function L(t,e){if(t.opt.xmlns){var n=t.tag,r=P(t.tagName);n.prefix=r.prefix,n.local=r.local,n.uri=n.ns[r.prefix]||"",n.prefix&&!n.uri&&(M(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),n.uri=r.prefix);var i=t.tags[t.tags.length-1]||t;n.ns&&i.ns!==n.ns&&Object.keys(n.ns).forEach(function(e){A(t,"onopennamespace",{prefix:e,uri:n.ns[e]})});for(var o=0,s=t.attribList.length;o<s;o++){var a=t.attribList[o],u=a[0],l=a[1],c=P(u,!0),h=c.prefix,p=c.local,f=""===h?"":n.ns[h]||"",d={name:u,value:l,prefix:h,local:p,uri:f};h&&"xmlns"!==h&&!f&&(M(t,"Unbound namespace prefix: "+JSON.stringify(h)),d.uri=h),t.tag.attributes[u]=d,A(t,"onattribute",d)}t.attribList.length=0}t.tag.isSelfClosing=!!e,t.sawRoot=!0,t.tags.push(t.tag),A(t,"onopentag",t.tag),e||(t.noscript||"script"!==t.tagName.toLowerCase()?t.state=T.TEXT:t.state=T.SCRIPT,t.tag=null,t.tagName=""),t.attribName=t.attribValue="",t.attribList.length=0}function R(t){if(!t.tagName)return M(t,"Weird empty close tag."),t.textNode+="</>",void(t.state=T.TEXT);if(t.script){if("script"!==t.tagName)return t.script+="</"+t.tagName+">",t.tagName="",void(t.state=T.SCRIPT);A(t,"onscript",t.script),t.script=""}var e=t.tags.length,n=t.tagName;t.strict||(n=n[t.looseCase]());for(var r=n;e--;){if(t.tags[e].name===r)break;M(t,"Unexpected close tag")}if(e<0)return M(t,"Unmatched closing tag: "+t.tagName),t.textNode+="</"+t.tagName+">",void(t.state=T.TEXT);t.tagName=n;for(var i=t.tags.length;i-- >e;){var o=t.tag=t.tags.pop();t.tagName=t.tag.name,A(t,"onclosetag",t.tagName);var s={};for(var a in o.ns)s[a]=o.ns[a];var u=t.tags[t.tags.length-1]||t;t.opt.xmlns&&o.ns!==u.ns&&Object.keys(o.ns).forEach(function(e){var n=o.ns[e];A(t,"onclosenamespace",{prefix:e,uri:n})})}0===e&&(t.closedRoot=!0),t.tagName=t.attribValue=t.attribName="",t.attribList.length=0,t.state=T.TEXT}function F(t){var e,n=t.entity,r=n.toLowerCase(),i="";return t.ENTITIES[n]?t.ENTITIES[n]:t.ENTITIES[r]?t.ENTITIES[r]:("#"===(n=r).charAt(0)&&("x"===n.charAt(1)?(n=n.slice(2),i=(e=parseInt(n,16)).toString(16)):(n=n.slice(1),i=(e=parseInt(n,10)).toString(10))),n=n.replace(/^0+/,""),isNaN(e)||i.toLowerCase()!==n?(M(t,"Invalid character entity"),"&"+t.entity+";"):String.fromCodePoint(e))}function j(t,e){"<"===e?(t.state=T.OPEN_WAKA,t.startTagPosition=t.position):g(e)||(M(t,"Non-whitespace before first tag."),t.textNode=e,t.state=T.TEXT)}function U(t,e){var n="";return e<t.length&&(n=t.charAt(e)),n}T=t.STATE,String.fromCodePoint||(w=String.fromCharCode,b=Math.floor,x=function(){var t,e,n=[],r=-1,i=arguments.length;if(!i)return"";for(var o="";++r<i;){var s=Number(arguments[r]);if(!isFinite(s)||s<0||s>1114111||b(s)!==s)throw RangeError("Invalid code point: "+s);s<=65535?n.push(s):(t=55296+((s-=65536)>>10),e=s%1024+56320,n.push(t,e)),(r+1===i||n.length>16384)&&(o+=w.apply(null,n),n.length=0)}return o},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:x,configurable:!0,writable:!0}):String.fromCodePoint=x)}(t)}(Zl)),Zl}var Wh,Kh=xs(oc),Zh={};function Qh(){return Wh||(Wh=1,function(){Zh.stripBOM=function(t){return"\ufeff"===t[0]?t.substring(1):t}}.call(Zh)),Zh}var Jh,tp={};function ep(){return Jh||(Jh=1,function(){var t;t=new RegExp(/(?!xmlns)^.*:/),tp.normalize=function(t){return t.toLowerCase()},tp.firstCharLowerCase=function(t){return t.charAt(0).toLowerCase()+t.slice(1)},tp.stripPrefix=function(e){return e.replace(t,"")},tp.parseNumbers=function(t){return isNaN(t)||(t=t%1==0?parseInt(t,10):parseFloat(t)),t},tp.parseBooleans=function(t){return/^(?:true|false)$/i.test(t)&&(t="true"===t.toLowerCase()),t}}.call(tp)),tp}var np,rp=1,ip={},op=!1,sp=Qu.document;function ap(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var r={callback:t,args:e};return ip[rp]=r,np(rp),rp++}function up(t){delete ip[t]}function lp(t){if(op)setTimeout(lp,0,t);else{var e=ip[t];if(e){op=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(void 0,n)}}(e)}finally{up(t),op=!1}}}}var cp,hp,pp,fp,dp=Object.getPrototypeOf&&Object.getPrototypeOf(Qu);dp=dp&&dp.setTimeout?dp:Qu,"[object process]"==={}.toString.call(Qu.process)?np=function(t){Cc.nextTick(function(){lp(t)})}:!function(){if(Qu.postMessage&&!Qu.importScripts){var t=!0,e=Qu.onmessage;return Qu.onmessage=function(){t=!1},Qu.postMessage("","*"),Qu.onmessage=e,t}}()?Qu.MessageChannel?((hp=new MessageChannel).port1.onmessage=function(t){lp(t.data)},np=function(t){hp.port2.postMessage(t)}):sp&&"onreadystatechange"in sp.createElement("script")?(cp=sp.documentElement,np=function(t){var e=sp.createElement("script");e.onreadystatechange=function(){lp(t),e.onreadystatechange=null,cp.removeChild(e),e=null},cp.appendChild(e)}):np=function(t){setTimeout(lp,0,t)}:(pp="setImmediate$"+Math.random()+"$",fp=function(t){t.source===Qu&&"string"==typeof t.data&&0===t.data.indexOf(pp)&&lp(+t.data.slice(pp.length))},Qu.addEventListener?Qu.addEventListener("message",fp,!1):Qu.attachEvent("onmessage",fp),np=function(t){Qu.postMessage(pp+t,"*")});var gp=Function.prototype.apply;function mp(t){"number"==typeof t&&"function"==typeof Qu.clearInterval?Qu.clearInterval(t):_p(t)}function yp(t){"number"==typeof t&&"function"==typeof Qu.clearTimeout?Qu.clearTimeout(t):_p(t)}function _p(t){t&&"function"==typeof t.close&&t.close()}function vp(){return new bp(gp.call(Qu.setTimeout,window,arguments))}function wp(){return new bp(gp.call(Qu.setInterval,window,arguments))}function bp(t){this._id=t}function xp(t,e){yp(t._idleTimeoutId),t._idleTimeout=e}function Tp(t){yp(t._idleTimeoutId),t._idleTimeout=-1}bp.prototype.unref=bp.prototype.ref=function(){},bp.prototype.close=function(){_p(this._id)};var Ep=Np;function Np(t){yp(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=vp(function(){t._onTimeout&&t._onTimeout()},e))}var Ap,Dp,Op={setImmediate:ap,clearImmediate:up,setTimeout:vp,clearTimeout:yp,setInterval:wp,clearInterval:mp,active:Np,unenroll:Tp,_unrefActive:Ep,enroll:xp},Ip=xs(Object.freeze({__proto__:null,setImmediate:ap,clearImmediate:up,clearInterval:mp,clearTimeout:yp,setTimeout:vp,setInterval:wp,enroll:xp,unenroll:Tp,_unrefActive:Ep,active:Np,default:Op}));function Cp(){return Ap||(Ap=1,function(t){(function(){var e,n,r,i,o,s,a,u,l,c=function(t,e){return function(){return t.apply(e,arguments)}},h={}.hasOwnProperty;u=Gh(),i=Kh,e=Qh(),a=ep(),l=Ip.setImmediate,n=As().defaults,o=function(t){return"object"==typeof t&&null!=t&&0===Object.keys(t).length},s=function(t,e,n){var r,i;for(r=0,i=t.length;r<i;r++)e=(0,t[r])(e,n);return e},r=function(t,e,n){var r;return(r=Object.create(null)).value=n,r.writable=!0,r.enumerable=!0,r.configurable=!0,Object.defineProperty(t,e,r)},t.Parser=function(i){function p(e){var r,i,o;if(this.parseStringPromise=c(this.parseStringPromise,this),this.parseString=c(this.parseString,this),this.reset=c(this.reset,this),this.assignOrPush=c(this.assignOrPush,this),this.processAsync=c(this.processAsync,this),!(this instanceof t.Parser))return new t.Parser(e);for(r in this.options={},i=n[.2])h.call(i,r)&&(o=i[r],this.options[r]=o);for(r in e)h.call(e,r)&&(o=e[r],this.options[r]=o);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(a.normalize)),this.reset()}return function(t,e){for(var n in e)h.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(p,i),p.prototype.processAsync=function(){var t,e;try{return this.remaining.length<=this.options.chunkSize?(t=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(t),this.saxParser.close()):(t=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(t),l(this.processAsync))}catch(t){if(e=t,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(e)}},p.prototype.assignOrPush=function(t,e,n){return e in t?(t[e]instanceof Array||r(t,e,[t[e]]),t[e].push(n)):this.options.explicitArray?r(t,e,[n]):r(t,e,n)},p.prototype.reset=function(){var t,e,n,i,a;return this.removeAllListeners(),this.saxParser=u.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=(a=this,function(t){if(a.saxParser.resume(),!a.saxParser.errThrown)return a.saxParser.errThrown=!0,a.emit("error",t)}),this.saxParser.onend=function(t){return function(){if(!t.saxParser.ended)return t.saxParser.ended=!0,t.emit("end",t.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,i=[],t=this.options.attrkey,e=this.options.charkey,this.saxParser.onopentag=function(n){return function(o){var a,u,l,c,p;if((l={})[e]="",!n.options.ignoreAttrs)for(a in p=o.attributes)h.call(p,a)&&(t in l||n.options.mergeAttrs||(l[t]={}),u=n.options.attrValueProcessors?s(n.options.attrValueProcessors,o.attributes[a],a):o.attributes[a],c=n.options.attrNameProcessors?s(n.options.attrNameProcessors,a):a,n.options.mergeAttrs?n.assignOrPush(l,c,u):r(l[t],c,u));return l["#name"]=n.options.tagNameProcessors?s(n.options.tagNameProcessors,o.name):o.name,n.options.xmlns&&(l[n.options.xmlnskey]={uri:o.uri,local:o.local}),i.push(l)}}(this),this.saxParser.onclosetag=function(t){return function(){var n,a,u,l,c,p,f,d,g,m;if(p=i.pop(),c=p["#name"],t.options.explicitChildren&&t.options.preserveChildrenOrder||delete p["#name"],!0===p.cdata&&(n=p.cdata,delete p.cdata),g=i[i.length-1],p[e].match(/^\s*$/)&&!n?(a=p[e],delete p[e]):(t.options.trim&&(p[e]=p[e].trim()),t.options.normalize&&(p[e]=p[e].replace(/\s{2,}/g," ").trim()),p[e]=t.options.valueProcessors?s(t.options.valueProcessors,p[e],c):p[e],1===Object.keys(p).length&&e in p&&!t.EXPLICIT_CHARKEY&&(p=p[e])),o(p)&&(p="function"==typeof t.options.emptyTag?t.options.emptyTag():""!==t.options.emptyTag?t.options.emptyTag:a),null!=t.options.validator&&(m="/"+function(){var t,e,n;for(n=[],t=0,e=i.length;t<e;t++)l=i[t],n.push(l["#name"]);return n}().concat(c).join("/"),function(){var e;try{return p=t.options.validator(m,g&&g[c],p)}catch(n){return e=n,t.emit("error",e)}}()),t.options.explicitChildren&&!t.options.mergeAttrs&&"object"==typeof p)if(t.options.preserveChildrenOrder){if(g){for(u in g[t.options.childkey]=g[t.options.childkey]||[],f={},p)h.call(p,u)&&r(f,u,p[u]);g[t.options.childkey].push(f),delete p["#name"],1===Object.keys(p).length&&e in p&&!t.EXPLICIT_CHARKEY&&(p=p[e])}}else l={},t.options.attrkey in p&&(l[t.options.attrkey]=p[t.options.attrkey],delete p[t.options.attrkey]),!t.options.charsAsChildren&&t.options.charkey in p&&(l[t.options.charkey]=p[t.options.charkey],delete p[t.options.charkey]),Object.getOwnPropertyNames(p).length>0&&(l[t.options.childkey]=p),p=l;return i.length>0?t.assignOrPush(g,c,p):(t.options.explicitRoot&&(d=p,r(p={},c,d)),t.resultObject=p,t.saxParser.ended=!0,t.emit("end",t.resultObject))}}(this),n=function(t){return function(n){var r,o;if(o=i[i.length-1])return o[e]+=n,t.options.explicitChildren&&t.options.preserveChildrenOrder&&t.options.charsAsChildren&&(t.options.includeWhiteChars||""!==n.replace(/\\n/g,"").trim())&&(o[t.options.childkey]=o[t.options.childkey]||[],(r={"#name":"__text__"})[e]=n,t.options.normalize&&(r[e]=r[e].replace(/\s{2,}/g," ").trim()),o[t.options.childkey].push(r)),o}}(this),this.saxParser.ontext=n,this.saxParser.oncdata=function(t){var e;if(e=n(t))return e.cdata=!0}},p.prototype.parseString=function(t,n){var r;null!=n&&"function"==typeof n&&(this.on("end",function(t){return this.reset(),n(null,t)}),this.on("error",function(t){return this.reset(),n(t)}));try{return""===(t=t.toString()).trim()?(this.emit("end",null),!0):(t=e.stripBOM(t),this.options.async?(this.remaining=t,l(this.processAsync),this.saxParser):this.saxParser.write(t).close())}catch(t){if(r=t,!this.saxParser.errThrown&&!this.saxParser.ended)return this.emit("error",r),this.saxParser.errThrown=!0;if(this.saxParser.ended)throw r}},p.prototype.parseStringPromise=function(t){return new Promise((e=this,function(n,r){return e.parseString(t,function(t,e){return t?r(t):n(e)})}));var e},p}(i),t.parseString=function(e,n,r){var i,o;return null!=r?("function"==typeof r&&(i=r),"object"==typeof n&&(o=n)):("function"==typeof n&&(i=n),o={}),new t.Parser(o).parseString(e,i)},t.parseStringPromise=function(e,n){var r;return"object"==typeof n&&(r=n),new t.Parser(r).parseStringPromise(e)}}).call(Zu)}(Zu)),Zu}var Mp=(Dp||(Dp=1,function(){var t,e,n,r,i={}.hasOwnProperty;e=As(),t=Ku(),n=Cp(),r=ep(),Es.defaults=e.defaults,Es.processors=r,Es.ValidationError=function(){function t(t){this.message=t}return function(t,e){for(var n in e)i.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype}(t,Error),t}(),Es.Builder=t.Builder,Es.Parser=n.Parser,Es.parseString=n.parseString,Es.parseStringPromise=n.parseStringPromise}.call(Es)),Es);function Sp(t){return!i.has(t,"children")}function Pp(t,e,n){let r=[];return function i(o){Sp(o)?e&&o!=t&&r.push(o):(n&&o!=t&&r.push(o),o.children.forEach(i))}(t),r}var kp=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),o={name:n,parent:t.parent,attribute:r?r[2]:null,original_child_order:t.original_child_order},s={name:e,parent:o,attribute:r?r[1]:null,original_child_order:2};o.children=[t,s],t.parent.children[i]=o,t.parent=o,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 i.filter(this.nodes.descendants(),t=>!i.has(t,"children"))},getInternals:function(){return i.filter(this.nodes.descendants(),t=>i.has(t,"children"))},getRootNode:function(){return this.nodes},getNodes:function(){return this.nodes},getNodeByName:function(t){return i.filter(this.nodes.descendants(),e=>e.data.name==t)[0]},assignAttributes:function(t){i.each(this.nodes.descendants(),function(e){e.data&&e.data.name in t&&(e.annotations=t[e.data.name])})},isLeafNode:Sp,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=>{Sp(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:Pp});function Lp(t,e={}){const n=/^-?\d+(\.\d+)?$/;let r=e.left_delimiter||"{",i=e.right_delimiter||"}",o=[];function s(){let t=o[o.length-1];"children"in t||(t.children=[]),o.push({name:null}),t.children.push(o[o.length-1]),o[o.length-1].original_child_order=t.children.length}function a(){let t=o.pop();t.name=c,"children"in t?t.bootstrap_values=c:t.name=c,t.attribute=h,"["==r&&p.includes("&&NHX")?p.split(":").slice(1).forEach(e=>{const[r,i]=e.split("=");t[r]=n.test(i)?+i:i}):t.annotation=p,c="",h="",p=""}function u(e){return{json:null,error:"Unexpected '"+t[e]+"' in '"+t.substring(e-20,e+1)+"[ERROR HERE]"+t.substring(e+1,e+20)+"'"}}let l=0,c="",h="",p="",f=null,d={"'":1,'"':1},g={name:"root"};o.push(g);for(var m=/\s/,y=0;y<t.length;y++)try{var _=t[y];switch(l){case 0:"("==_&&(s(),l=1);break;case 1:case 3:if(":"==_)l=3;else if(","==_||")"==_)try{a(),l=1,","==_&&s()}catch(t){return u(y)}else if("("==_){if(c.length>0)return u(y);s()}else{if(_ in d){if(1==l&&0===c.length&&0===h.length&&0===p.length){l=2,f=_;continue}return u(y)}if(_==r){if(p.length)return u(y);l=4}else if(3==l)h+=_;else{if(m.test(_))continue;if(";"==_){y=t.length;break}c+=_}}break;case 2:if(_==f){if(y<t.length-1&&t[y+1]==f){y++,c+=f;continue}f=0,l=1;continue}c+=_;break;case 4:if(_==i)l=3;else{if(_==r)return u(y);p+=_}}}catch(t){return u(y)}return 1!=o.length?u(t.length-1):{json:g,error:null}}function Rp(t,e){let n=this;t||(t=t=>"");let r=[];return t=t||"",function e(i){if(i.notshown)return;if(Sp(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 o=n.branch_length_accessor(i);void 0!==o&&r.push(":"+o)}(e||this.nodes),r.join("")+";"}function Fp(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 o=r.slice(0,n);r=i.map(o.split(";"),t=>t.trim());let s=i.filter(r,t=>t.toUpperCase().startsWith("DIMENSION"));s=s[0].split(" "),s=i.object(i.map(i.rest(s),t=>t.split("=")));let a=i.filter(r,t=>t.toUpperCase().startsWith("FORMAT"));a=a[0].split(" "),a=i.object(i.map(i.rest(a),t=>t.split("="))),a.symbols=i.reject(a.symbols.split(""),t=>'"'==t);let u=i.filter(r,t=>t.toUpperCase().startsWith("MATRIX"));return u=u[0].split("\n"),u=i.object(i.map(i.rest(u),t=>i.compact(t.split(" ")))),u=i.mapObject(u,(t,e)=>"?"==t?a.symbols:Array(t)),{dimensions:s,format:a,matrix:u}}function jp(t,e,n){i.each(t.getTips(),t=>{t.data.test=n.matrix[t.data.name]})}function Up(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 o=r.slice(0,n).split("\n");return o=i.filter(o,t=>t.trim().toUpperCase().startsWith("TREE")),Lp(o[0])}var zp=Object.freeze({__proto__:null,parseAnnotations:Fp,loadAnnotations:jp,default:Up});const Bp=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Vp=new RegExp("^"+("["+Bp+"]["+(Bp+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040")+"]*")+"$");function Yp(t,e){const n=[];let r=e.exec(t);for(;r;){const i=[];i.startIndex=e.lastIndex-r[0].length;const o=r.length;for(let t=0;t<o;t++)i.push(r[t]);n.push(i),r=e.exec(t)}return n}const $p=function(t){const e=Vp.exec(t);return!(null==e)};const qp={allowBooleanAttributes:!1,unpairedTags:[]};function Hp(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function Xp(t,e){const n=e;for(;e<t.length;e++)if("?"==t[e]||" "==t[e]){const r=t.substr(n,e-n);if(e>5&&"xml"===r)return ef("InvalidXml","XML declaration allowed only at the start of the document.",of(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}continue}return e}function Gp(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){let n=1;for(e+=8;e<t.length;e++)if("<"===t[e])n++;else if(">"===t[e]&&(n--,0===n))break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}const Wp='"',Kp="'";function Zp(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===Wp||t[e]===Kp)""===r?r=t[e]:r!==t[e]||(r="");else if(">"===t[e]&&""===r){i=!0;break}n+=t[e]}return""===r&&{value:n,index:e,tagClosed:i}}const Qp=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Jp(t,e){const n=Yp(t,Qp),r={};for(let t=0;t<n.length;t++){if(0===n[t][1].length)return ef("InvalidAttr","Attribute '"+n[t][2]+"' has no space in starting.",sf(n[t]));if(void 0!==n[t][3]&&void 0===n[t][4])return ef("InvalidAttr","Attribute '"+n[t][2]+"' is without value.",sf(n[t]));if(void 0===n[t][3]&&!e.allowBooleanAttributes)return ef("InvalidAttr","boolean attribute '"+n[t][2]+"' is not allowed.",sf(n[t]));const i=n[t][2];if(!nf(i))return ef("InvalidAttr","Attribute '"+i+"' is an invalid name.",sf(n[t]));if(r.hasOwnProperty(i))return ef("InvalidAttr","Attribute '"+i+"' is repeated.",sf(n[t]));r[i]=1}return!0}function tf(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){let n=/\d/;for("x"===t[e]&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(n))break}return-1}(t,++e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(";"===t[e])break;return-1}return e}function ef(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function nf(t){return $p(t)}function rf(t){return $p(t)}function of(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function sf(t){return t.startIndex+t[1].length}const af={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t},captureMetaData:!1};let uf;uf="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class lf{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][uf]={startIndex:e})}static getMetaDataSymbol(){return uf}}function cf(t,e){const n={};if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let r=1,i=!1,o=!1,s="";for(;e<t.length;e++)if("<"!==t[e]||o)if(">"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,r--):r--,0===r)break}else"["===t[e]?i=!0:s+=t[e];else{if(i&&mf(t,"!ENTITY",e)){let r,i;e+=7,[r,i,e]=pf(t,e+1),-1===i.indexOf("&")&&(n[r]={regx:RegExp(`&${r};`,"g"),val:i})}else if(i&&mf(t,"!ELEMENT",e)){e+=8;const{index:n}=gf(t,e+1);e=n}else if(i&&mf(t,"!ATTLIST",e))e+=8;else if(i&&mf(t,"!NOTATION",e)){e+=9;const{index:n}=ff(t,e+1);e=n}else{if(!mf(t,"!--",e))throw new Error("Invalid DOCTYPE");o=!0}r++,s=""}if(0!==r)throw new Error("Unclosed DOCTYPE")}return{entities:n,i:e}}const hf=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function pf(t,e){e=hf(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)n+=t[e],e++;if(yf(n),e=hf(t,e),"SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported");let r="";return[e,r]=df(t,e,"entity"),[n,r,--e]}function ff(t,e){e=hf(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;yf(n),e=hf(t,e);const r=t.substring(e,e+6).toUpperCase();if("SYSTEM"!==r&&"PUBLIC"!==r)throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);e+=r.length,e=hf(t,e);let i=null,o=null;if("PUBLIC"===r)[e,i]=df(t,e,"publicIdentifier"),'"'!==t[e=hf(t,e)]&&"'"!==t[e]||([e,o]=df(t,e,"systemIdentifier"));else if("SYSTEM"===r&&([e,o]=df(t,e,"systemIdentifier"),!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:i,systemIdentifier:o,index:--e}}function df(t,e,n){let r="";const i=t[e];if('"'!==i&&"'"!==i)throw new Error(`Expected quoted string, found "${i}"`);for(e++;e<t.length&&t[e]!==i;)r+=t[e],e++;if(t[e]!==i)throw new Error(`Unterminated ${n} value`);return[++e,r]}function gf(t,e){e=hf(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;if(!yf(n))throw new Error(`Invalid element name: "${n}"`);let r="";if("E"===t[e=hf(t,e)]&&mf(t,"MPTY",e))e+=4;else if("A"===t[e]&&mf(t,"NY",e))e+=2;else{if("("!==t[e])throw new Error(`Invalid Element Expression, found "${t[e]}"`);for(e++;e<t.length&&")"!==t[e];)r+=t[e],e++;if(")"!==t[e])throw new Error("Unterminated content model")}return{elementName:n,contentModel:r.trim(),index:e}}function mf(t,e,n){for(let r=0;r<e.length;r++)if(e[r]!==t[n+r+1])return!1;return!0}function yf(t){if($p(t))return t;throw new Error(`Invalid entity name ${t}`)}const _f=/^[-+]?0x[a-fA-F0-9]+$/,vf=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,wf={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function bf(t,e={}){if(e=Object.assign({},wf,e),!t||"string"!=typeof t)return t;let n=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(n))return t;if("0"===t)return 0;if(e.hex&&_f.test(n))return function(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(n,16);if(-1!==n.search(/.+[eE].+/))return function(t,e,n){if(!n.eNotation)return t;const r=e.match(xf);if(r){let i=r[1]||"";const o=-1===r[3].indexOf("e")?"E":"e",s=r[2],a=i?t[s.length+1]===o:t[s.length]===o;return s.length>1&&a?t:1!==s.length||!r[3].startsWith(`.${o}`)&&r[3][0]!==o?n.leadingZeros&&!a?(e=(r[1]||"")+r[3],Number(e)):t:Number(e)}return t}(t,n,e);{const r=vf.exec(n);if(r){const i=r[1]||"",o=r[2];let s=function(t){if(t&&-1!==t.indexOf("."))return"."===(t=t.replace(/0+$/,""))?t="0":"."===t[0]?t="0"+t:"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),t;return t}(r[3]);const a=i?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!a))return t;{const r=Number(n),a=String(r);if(0===r)return r;if(-1!==a.search(/[eE]/))return e.eNotation?r:t;if(-1!==n.indexOf("."))return"0"===a||a===s||a===`${i}${s}`?r:t;let u=o?s:n;return o?u===a||i+u===a?r:t:u===a||u===i+a?r:t}}return t}}const xf=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;class Tf{constructor(t){var e;this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,e)=>String.fromCodePoint(Number.parseInt(e,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,e)=>String.fromCodePoint(Number.parseInt(e,16))}},this.addExternalEntities=Ef,this.parseXml=If,this.parseTextData=Nf,this.resolveNameSpace=Af,this.buildAttributesMap=Of,this.isItStopNode=Pf,this.replaceEntitiesValue=Mf,this.readStopNodeData=Rf,this.saveTextToParentTag=Sf,this.addChild=Cf,this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const n of e){if("string"==typeof n&&t===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}}:()=>!1}}function Ef(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function Nf(t,e,n,r,i,o,s){if(void 0!==t&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t));const r=this.options.tagValueProcessor(e,t,n,i,o);if(null==r)return t;if(typeof r!=typeof t||r!==t)return r;if(this.options.trimValues)return Ff(t,this.options.parseTagValue,this.options.numberParseOptions);return t.trim()===t?Ff(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function Af(t){if(this.options.removeNSPrefix){const e=t.split(":"),n="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=n+e[1])}return t}const Df=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Of(t,e,n){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){const n=Yp(t,Df),r=n.length,i={};for(let t=0;t<r;t++){const r=this.resolveNameSpace(n[t][1]);if(this.ignoreAttributesFn(r,e))continue;let o=n[t][4],s=this.options.attributeNamePrefix+r;if(r.length)if(this.options.transformAttributeName&&(s=this.options.transformAttributeName(s)),"__proto__"===s&&(s="#__proto__"),void 0!==o){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);const t=this.options.attributeValueProcessor(r,o,e);i[s]=null==t?o:typeof t!=typeof o||t!==o?t:Ff(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(i[s]=!0)}if(!Object.keys(i).length)return;if(this.options.attributesGroupName){const t={};return t[this.options.attributesGroupName]=i,t}return i}}const If=function(t){t=t.replace(/\r\n?/g,"\n");const e=new lf("!xml");let n=e,r="",i="";for(let o=0;o<t.length;o++){if("<"===t[o])if("/"===t[o+1]){const e=kf(t,">",o,"Closing Tag is not closed.");let s=t.substring(o+2,e).trim();if(this.options.removeNSPrefix){const t=s.indexOf(":");-1!==t&&(s=s.substr(t+1))}this.options.transformTagName&&(s=this.options.transformTagName(s)),n&&(r=this.saveTextToParentTag(r,n,i));const a=i.substring(i.lastIndexOf(".")+1);if(s&&-1!==this.options.unpairedTags.indexOf(s))throw new Error(`Unpaired tag can not be used as closing tag: </${s}>`);let u=0;a&&-1!==this.options.unpairedTags.indexOf(a)?(u=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=i.lastIndexOf("."),i=i.substring(0,u),n=this.tagsNodeStack.pop(),r="",o=e}else if("?"===t[o+1]){let e=Lf(t,o,!1,"?>");if(!e)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),this.options.ignoreDeclaration&&"?xml"===e.tagName||this.options.ignorePiTags);else{const t=new lf(e.tagName);t.add(this.options.textNodeName,""),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[":@"]=this.buildAttributesMap(e.tagExp,i,e.tagName)),this.addChild(n,t,i,o)}o=e.closeIndex+1}else if("!--"===t.substr(o+1,3)){const e=kf(t,"--\x3e",o+4,"Comment is not closed.");if(this.options.commentPropName){const s=t.substring(o+4,e-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:s}])}o=e}else if("!D"===t.substr(o+1,2)){const e=cf(t,o);this.docTypeEntities=e.entities,o=e.i}else if("!["===t.substr(o+1,2)){const e=kf(t,"]]>",o,"CDATA is not closed.")-2,s=t.substring(o+9,e);r=this.saveTextToParentTag(r,n,i);let a=this.parseTextData(s,n.tagname,i,!0,!1,!0,!0);null==a&&(a=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:s}]):n.add(this.options.textNodeName,a),o=e+2}else{let s=Lf(t,o,this.options.removeNSPrefix),a=s.tagName;const u=s.rawTagName;let l=s.tagExp,c=s.attrExpPresent,h=s.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&r&&"!xml"!==n.tagname&&(r=this.saveTextToParentTag(r,n,i,!1));const p=n;p&&-1!==this.options.unpairedTags.indexOf(p.tagname)&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),a!==e.tagname&&(i+=i?"."+a:a);const f=o;if(this.isItStopNode(this.options.stopNodes,i,a)){let e="";if(l.length>0&&l.lastIndexOf("/")===l.length-1)"/"===a[a.length-1]?(a=a.substr(0,a.length-1),i=i.substr(0,i.length-1),l=a):l=l.substr(0,l.length-1),o=s.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(a))o=s.closeIndex;else{const n=this.readStopNodeData(t,u,h+1);if(!n)throw new Error(`Unexpected end of ${u}`);o=n.i,e=n.tagContent}const r=new lf(a);a!==l&&c&&(r[":@"]=this.buildAttributesMap(l,i,a)),e&&(e=this.parseTextData(e,a,i,!0,c,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),r.add(this.options.textNodeName,e),this.addChild(n,r,i,f)}else{if(l.length>0&&l.lastIndexOf("/")===l.length-1){"/"===a[a.length-1]?(a=a.substr(0,a.length-1),i=i.substr(0,i.length-1),l=a):l=l.substr(0,l.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));const t=new lf(a);a!==l&&c&&(t[":@"]=this.buildAttributesMap(l,i,a)),this.addChild(n,t,i,f),i=i.substr(0,i.lastIndexOf("."))}else{const t=new lf(a);this.tagsNodeStack.push(n),a!==l&&c&&(t[":@"]=this.buildAttributesMap(l,i,a)),this.addChild(n,t,i,f),n=t}r="",o=h}}else r+=t[o]}return e.child};function Cf(t,e,n,r){this.options.captureMetaData||(r=void 0);const i=this.options.updateTag(e.tagname,n,e[":@"]);!1===i||("string"==typeof i?(e.tagname=i,t.addChild(e,r)):t.addChild(e,r))}const Mf=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const n=this.docTypeEntities[e];t=t.replace(n.regx,n.val)}for(let e in this.lastEntities){const n=this.lastEntities[e];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const n=this.htmlEntities[e];t=t.replace(n.regex,n.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function Sf(t,e,n,r){return t&&(void 0===r&&(r=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,n,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,r))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function Pf(t,e,n){const r="*."+n;for(const n in t){const i=t[n];if(r===i||e===i)return!0}return!1}function kf(t,e,n,r){const i=t.indexOf(e,n);if(-1===i)throw new Error(r);return i+e.length-1}function Lf(t,e,n,r=">"){const i=function(t,e,n=">"){let r,i="";for(let o=e;o<t.length;o++){let e=t[o];if(r)e===r&&(r="");else if('"'===e||"'"===e)r=e;else if(e===n[0]){if(!n[1])return{data:i,index:o};if(t[o+1]===n[1])return{data:i,index:o}}else"\t"===e&&(e=" ");i+=e}}(t,e+1,r);if(!i)return;let o=i.data;const s=i.index,a=o.search(/\s/);let u=o,l=!0;-1!==a&&(u=o.substring(0,a),o=o.substring(a+1).trimStart());const c=u;if(n){const t=u.indexOf(":");-1!==t&&(u=u.substr(t+1),l=u!==i.data.substr(t+1))}return{tagName:u,tagExp:o,closeIndex:s,attrExpPresent:l,rawTagName:c}}function Rf(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if("<"===t[n])if("/"===t[n+1]){const o=kf(t,">",n,`${e} is not closed`);if(t.substring(n+2,o).trim()===e&&(i--,0===i))return{tagContent:t.substring(r,n),i:o};n=o}else if("?"===t[n+1]){n=kf(t,"?>",n+1,"StopNode is not closed.")}else if("!--"===t.substr(n+1,3)){n=kf(t,"--\x3e",n+3,"StopNode is not closed.")}else if("!["===t.substr(n+1,2)){n=kf(t,"]]>",n,"StopNode is not closed.")-2}else{const r=Lf(t,n,">");if(r){(r&&r.tagName)===e&&"/"!==r.tagExp[r.tagExp.length-1]&&i++,n=r.closeIndex}}}function Ff(t,e,n){if(e&&"string"==typeof t){const e=t.trim();return"true"===e||"false"!==e&&bf(t,n)}return function(t){return void 0!==t}(t)?t:""}const jf=lf.getMetaDataSymbol();function Uf(t,e){return zf(t,e)}function zf(t,e,n){let r;const i={};for(let o=0;o<t.length;o++){const s=t[o],a=Bf(s);let u="";if(u=void 0===n?a:n+"."+a,a===e.textNodeName)void 0===r?r=s[a]:r+=""+s[a];else{if(void 0===a)continue;if(s[a]){let t=zf(s[a],e,u);const n=Yf(t,e);void 0!==s[jf]&&(t[jf]=s[jf]),s[":@"]?Vf(t,s[":@"],u,e):1!==Object.keys(t).length||void 0===t[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(t).length&&(e.alwaysCreateTextNode?t[e.textNodeName]="":t=""):t=t[e.textNodeName],void 0!==i[a]&&i.hasOwnProperty(a)?(Array.isArray(i[a])||(i[a]=[i[a]]),i[a].push(t)):e.isArray(a,u,n)?i[a]=[t]:i[a]=t}}}return"string"==typeof r?r.length>0&&(i[e.textNodeName]=r):void 0!==r&&(i[e.textNodeName]=r),i}function Bf(t){const e=Object.keys(t);for(let t=0;t<e.length;t++){const n=e[t];if(":@"!==n)return n}}function Vf(t,e,n,r){if(e){const i=Object.keys(e),o=i.length;for(let s=0;s<o;s++){const o=i[s];r.isArray(o,n+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}}function Yf(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return 0===r||!(1!==r||!t[n]&&"boolean"!=typeof t[n]&&0!==t[n])}class $f{constructor(t){this.externalEntities={},this.options=function(t){return Object.assign({},af,t)}(t)}parse(t,e){if("string"==typeof t);else{if(!t.toString)throw new Error("XML data is accepted in String or Bytes[] form.");t=t.toString()}if(e){!0===e&&(e={});const n=function(t,e){e=Object.assign({},qp,e);const n=[];let r=!1,i=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(let o=0;o<t.length;o++)if("<"===t[o]&&"?"===t[o+1]){if(o+=2,o=Xp(t,o),o.err)return o}else{if("<"!==t[o]){if(Hp(t[o]))continue;return ef("InvalidChar","char '"+t[o]+"' is not expected.",of(t,o))}{let s=o;if(o++,"!"===t[o]){o=Gp(t,o);continue}{let a=!1;"/"===t[o]&&(a=!0,o++);let u="";for(;o<t.length&&">"!==t[o]&&" "!==t[o]&&"\t"!==t[o]&&"\n"!==t[o]&&"\r"!==t[o];o++)u+=t[o];if(u=u.trim(),"/"===u[u.length-1]&&(u=u.substring(0,u.length-1),o--),!rf(u)){let e;return e=0===u.trim().length?"Invalid space after '<'.":"Tag '"+u+"' is an invalid name.",ef("InvalidTag",e,of(t,o))}const l=Zp(t,o);if(!1===l)return ef("InvalidAttr","Attributes for '"+u+"' have open quote.",of(t,o));let c=l.value;if(o=l.index,"/"===c[c.length-1]){const n=o-c.length;c=c.substring(0,c.length-1);const i=Jp(c,e);if(!0!==i)return ef(i.err.code,i.err.msg,of(t,n+i.err.line));r=!0}else if(a){if(!l.tagClosed)return ef("InvalidTag","Closing tag '"+u+"' doesn't have proper closing.",of(t,o));if(c.trim().length>0)return ef("InvalidTag","Closing tag '"+u+"' can't have attributes or invalid starting.",of(t,s));if(0===n.length)return ef("InvalidTag","Closing tag '"+u+"' has not been opened.",of(t,s));{const e=n.pop();if(u!==e.tagName){let n=of(t,e.tagStartPos);return ef("InvalidTag","Expected closing tag '"+e.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+u+"'.",of(t,s))}0==n.length&&(i=!0)}}else{const a=Jp(c,e);if(!0!==a)return ef(a.err.code,a.err.msg,of(t,o-c.length+a.err.line));if(!0===i)return ef("InvalidXml","Multiple possible root nodes found.",of(t,o));-1!==e.unpairedTags.indexOf(u)||n.push({tagName:u,tagStartPos:s}),r=!0}for(o++;o<t.length;o++)if("<"===t[o]){if("!"===t[o+1]){o++,o=Gp(t,o);continue}if("?"!==t[o+1])break;if(o=Xp(t,++o),o.err)return o}else if("&"===t[o]){const e=tf(t,o);if(-1==e)return ef("InvalidChar","char '&' is not expected.",of(t,o));o=e}else if(!0===i&&!Hp(t[o]))return ef("InvalidXml","Extra text at the end",of(t,o));"<"===t[o]&&o--}}}return r?1==n.length?ef("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",of(t,n[0].tagStartPos)):!(n.length>0)||ef("InvalidXml","Invalid '"+JSON.stringify(n.map(t=>t.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):ef("InvalidXml","Start tag expected.",1)}(t,e);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const n=new Tf(this.options);n.addExternalEntities(this.externalEntities);const r=n.parseXml(t);return this.options.preserveOrder||void 0===r?r:Uf(r,this.options)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return lf.getMetaDataSymbol()}}function qf(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 o=t.childNodes.item(i),s=o.nodeName;if(void 0===e[s])e[s]=qf(o);else{if(void 0===e[s].push){var a=e[s];e[s]=[],e[s].push(a)}e[s].push(qf(o))}}return e}var Hf=function(t,e){var n;if("string"==typeof t)if(DOMParser){t=(new DOMParser).parseFromString(t,"text/xml")}else{t=(new $f).parse(t)}var r=(t=qf(t)).phyloxml.phylogeny;return Array.isArray(r)&&(r=r[0],console.warn("PhyloXML files with multiple phylogenies are not currently supported. Only the first phylogeny will be loaded.")),(n=r.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 Xf={nexml:function(t,e){var n;return Mp.parseString(t,function(t,e){n=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),o=r>0?r[0].id:e[0].id;return n[o].name="root",t.edge.map(t=>t.$).forEach(function(t){n[t.source].edges.push(t)}),function t(e,r){if(e.edges){var o=i.pluck(e.edges,"target");e.children=i.values(i.pick(n,o)),e.children.forEach(function(t,n){t.attribute=e.edges[n].length||""}),e.children.forEach(t),e.annotation=""}}(n[o]),n[o]})}),n},phyloxml:Hf,nexus:Up,nwk:Lp,nhx:Lp,beast:function(t,e){e.left_delimiter="[",e.right_delimiter="]";const n=Lp(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 Gf(t,e,n){let r,i,o,s=[t],a=[];for(;t=s.pop();)if((!n||!n(t))&&(a.push(t),r=t.children,r))for(i=0,o=r.length;i<o;++i)s.push(r[i]);for(;t=a.pop();)e(t);return t}function Wf(t,e,n){let r,i,o=[t];for(;t=o.pop();)if((!n||!n(t))&&(e(t),r=t.children,r))for(i=r.length-1;i>=0;--i)o.push(r[i]);return t}function Kf(t,e,n){let r,i,o,s,a=[t];do{for(r=a.reverse(),a=[];t=r.pop();)if((!n||!n(t))&&(e(t),i=t.children,i))for(o=0,s=i.length;o<s;++o)a.push(i[o])}while(a.length);return t}function Zf(t){return Gf(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 Qf(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 Jf=Object.freeze({__proto__:null,reroot:function(t,e){if(!(t instanceof Br))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=Br({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 s=t,a=t.parent,u=i.noop(),l=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl*e;var o;if(u=a.data.__mapped_bl,a.data.__mapped_bl=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl-l,t.data.__mapped_bl=l,a.parent){for(r.children.push(a);a.parent;){o=a.children.indexOf(s),a.parent.parent?a.children.splice(o,1,a.parent):a.children.splice(o,1);let t=a.parent.data.__mapped_bl;void 0!==t&&(a.parent.data.__mapped_bl=u,u=t),s=a,a=a.parent}o=a.children.indexOf(s),a.children.splice(o,1)}else o=a.children.indexOf(s),a.children.splice(o,1),u=a.data.__mapped_bl,s=r;if(1==a.children.length)u&&(a.children[0].data.__mapped_bl+=u),s.children=s.children.concat(a.children);else{let e=new Br({name:"__reroot_top_clade",__mapped_bl:u});i.extendOwn(r.children[0],t),e.data.__mapped_bl=u,e.children=a.children.map(function(t){return t.parent=e,t}),e.parent=s,s.children.push(e)}}if(this.update(r),this.traverse_and_compute(t=>{i.each(t.children,e=>{e.parent=t})},"pre-order"),!i.isUndefined(this.display)){let t=this.display.options;Vt(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(),Vt(n.container).node().appendChild(n.show()),Vt(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 td(t){return t.y}function ed(t){return t.x}function nd(t,e,n){return{x:n+t*Math.sin(e),y:n+t*Math.cos(e)}}function rd(t,e,n,r,i,o){t.radius=e*(t.radius+n),t.angle=2*Math.PI*t.x*i[0]/o[0];let s=nd(t.radius,t.angle,r);return t.x=s.x,t.y=s.y,t}function id(t,e){var n=nd(e[0].radius,e[0].angle,t),r=nd(e[0].radius,e[1].angle,t);return"M "+td(n)+","+ed(n)+" A "+e[0].radius+","+e[0].radius+" 0,0, "+(e[1].angle>e[0].angle?1:0)+" "+td(r)+","+ed(r)+" L "+td(e[1])+","+ed(e[1])}function od(t,e,n){var r=nd(t.target.radius+(t.source.radius-t.target.radius)*e,t.target.angle,n);return{x:td(r),y:ed(r)}}var sd=os().x(function(t){return td(t)}).y(function(t){return ed(t)}).curve(function(t){return new ls(t,0)});function ad(t,e){return{x:td(t.target)+(td(t.source)-td(t.target))*e,y:ed(t.target)}}function ud(t){return t.tag||!1}function ld(t,e){return t[e]||!1}const cd={"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 hd(t={}){Object.keys(t).forEach(e=>{cd[e]=t[e]})}function pd(t){return arguments.length?(pd="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):pd}var fd={all:t=>!0,none:t=>!1,"all-leaf-nodes":t=>Sp(t.target),"all-internal-nodes":t=>!Sp(t.target)};var dd=Object.freeze({__proto__:null,css_classes:cd,initializeCssClasses:hd,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 pd},predefined_selecters:fd,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function gd(t){return!(t.hidden||t.notshown)}function md(t){return t.notshown}function yd(t){return t.hasHiddenNodes||!1}function _d(t){return t.collapsed||!1}function vd(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 wd(t){return Sp(t=t.data)?t.name||"":this.showInternalName(t)?t.name:""}var bd=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=Vt(t);var r=Sp(e);r&&(t=t.attr("data-node-name",e.data.name));var i=t.selectAll("text").data([e]),o=t.selectAll("line");if(r||this.showInternalName(e)&&!_d(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()?(o=o.data([e]),n?o=o.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(o).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)):(o=o.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(o).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))):o.remove(),this.options["draw-size-bubbles"]){var s=this.nodeBubbleSize(e);t.selectAll("circle").data([s]).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:s)+.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)Sp(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=cd[Sp(t)?"node":"internal-node"];return ud(t)&&(e+=" "+cd["tagged-node"]),ld(t,this.selection_attribute_name)&&(e+=" "+cd["selected-node"]),t.parent||(e+=" "+cd["root-node"]),(_d(t)||yd(t))&&(e+=" "+cd["collapsed-node"]),e},nodeVisible:gd,nodeNotshown:md,hasHiddenNodes:yd,isNodeCollapsed:_d,nodeCssSelectors:vd,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];Sp(r)||ld(r,this.selection_attribute_name)||(r[this.selection_attribute_name]=t(r.children))}this.modifySelection((t,e)=>(Sp(t.target),t.target[this.selection_attribute_name]))},defNodeLabel:wd,nodeLabel:function(t){return arguments.length?(this._nodeLabel=t||wd,this.update(),this):this._nodeLabel}});function xd(t){return[t.clade].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var Td=Object.freeze({__proto__:null,cladeCssSelectors:xd,updateCollapsedClades:function(t){let e=this.svg.selectAll("."+this.css_classes["tree-container"]);var n=0;let r=e.selectAll(xd(this.css_classes)).data(this.phylotree.nodes.descendants().filter(_d),function(t){return t.id||(t.id=++n)}),o=function(){},s=i.noop();this.radial()?(o=os().curve(us).y(function(t){return t[0]}).x(function(t){return t[1]}),s=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]}):(o=os().y(function(t){return t[0]}).x(function(t){return t[1]}).curve(us),s=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 o(t.collapsed.map(function(r,i){return s(r,i,t,e,n)}))}).attr("d",function(t){return t.collapsed_clade=o(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=o(t.collapsed)})}});function Ed(t){return!(t.target.hidden||t.target.notshown)}function Nd(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 Ad=Object.freeze({__proto__:null,drawEdge:function(t,e,n){t=(t=Vt(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 o=t.selectAll("title");o.empty()&&(o=t.append("title")),o.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=cd.branch;return ud(t)&&(e+=" "+cd["tagged-branch"]),ld(t,this.selection_attribute_name)&&(e+=" "+cd["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+(ud(e)?1:0)},0),this.countUpdate(this,t,this.countHandler())}},edgeVisible:Ed,edgeCssSelectors:Nd,placeAlongAnEdge:function(t,e){return this.edge_placer(t,e)}});let Dd="phylotree.event";function Od(t){var e=new CustomEvent(Dd,{detail:["refresh",t]});document.dispatchEvent(e)}function Id(t,e){var n=new CustomEvent(Dd,{detail:["countUpdate",e,t.countHandler()]});document.dispatchEvent(n)}function Cd(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 Md(){document.addEventListener(Dd,Cd,!1)}var Sd=Object.freeze({__proto__:null,toggleCollapse:function(t){if(t.collapsed){t.collapsed=!1;let e=function(t){Sp(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("."+cd["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:Od,countUpdate:Id,d3PhylotreeTriggerLayout:function(t){var e=new CustomEvent(Dd,{detail:["layout",t,t.layoutHandler()]});document.dispatchEvent(e)},d3PhylotreeEventListener:Cd,d3PhylotreeAddEventListener:Md,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 Pd="d3_layout_phylotree_context_menu";function kd(t,e,n){let r=[];return function i(o){Sp(o)?e&&o!=t&&r.push(o):(n&&o!=t&&r.push(o),o.children.forEach(i))}(t),r}var Ld=Object.freeze({__proto__:null,nodeDropdownMenu:function(t,e,n,r,o){let s=Vt(e).select("#"+Pd);if(s.empty()&&(s=Vt(e).append("div").attr("id",Pd).attr("class","dropdown-menu").attr("role","menu")),s.selectAll("a").remove(),s.selectAll("h6").remove(),s.selectAll("div").remove(),t){if(!i.some([Boolean(t.menu_items),r.hide,r.selectable,r.collapsible])||!r["show-menu"])return;Sp(t)||(r.collapsible&&(s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(_d(t)?"Expand Subtree":"Collapse Subtree").on("click",e=>{s.style("display","none"),this.toggleCollapse(t).update()}),r.selectable&&(s.append("div").attr("class","dropdown-divider"),s.append("h6").attr("class","dropdown-header").text("Toggle selection"))),r.selectable&&(s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All descendant branches").on("click",function(e){s.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0))}),s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All terminal branches").on("click",function(e){s.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!1))}),s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All internal branches").on("click",function(e){s.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!1,!0))}))),t.parent&&(r.selectable&&(s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Incident branch").on("click",function(e){s.style("display","none"),n.modifySelection([t])}),s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Path to root").on("click",e=>{s.style("display","none"),this.modifySelection(this.phylotree.pathToRoot(t))}),(r.reroot||r.hide)&&s.append("div").attr("class","dropdown-divider")),r.reroot&&s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Reroot on this node").on("click",e=>{s.style("display","none"),this.phylotree.reroot(t),this.update()}),r.hide&&s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Hide this "+(Sp(t)?"node":"subtree")).on("click",e=>{s.style("display","none"),this.modifySelection([t],"notshown",!0,!0).updateHasHiddenNodes().update()})),yd(t)&&s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Show all descendant nodes").on("click",function(e){s.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0),"notshown",!0,!0,"false").updateHasHiddenNodes().update()});var a=[];if("menu_items"in t&&"object"==typeof t.menu_items&&t.menu_items.forEach(function(e){3==e.length&&(e[2]&&!e[2](t)||a.push([e[0],e[1]]))}),a.length){const e=[r.hide,r.selectable,r.collapsible];i.some(e)&&s.append("div").attr("class","dropdown-divider"),a.forEach(function(e){s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(e[0](t)).on("click",i.partial(e[1],t))})}let u=document.querySelector(e).getBoundingClientRect();s.style("position","absolute").style("left",o.clientX-u.x+12+"px").style("top",o.clientY-u.y+"px").style("display","block")}else s.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,o){if(e=e||this.selection_attribute_name,o=o||"toggle",this.options["restricted-selectable"].length){if(!i.contains(i.keys(fd),t))return;t=fd[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,a=!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,a=!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)})})),a&&(r||Od(this),this.countHandler()&&((s={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),this.countUpdate(this,s,this.countHandler())),n&&this.placenodes()));else{var s,a=!1;"function"==typeof t?this.links.forEach(function(n){let r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,a=!0,n.target[e]=r)}):(t.forEach(function(t){var n;switch(o){case"true":n=!0;break;case"false":n=!1;break;default:n=!t[e]}t[e]!=n&&(t[e]=n,a=!0)}),this.links.forEach(function(t){t[e]=t.target[e]})),a&&(r||Od(this),this.countHandler&&((s={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),Id(this,s,this.countHandler)),n&&this.placenodes())}return this._selectionCallback&&"tag"!=e&&this._selectionCallback(this.getSelection()),this.refresh(),this.update(),this},getSelection:function(){return kd(this.phylotree.getRootNode(),!0,!0).filter(t=>t[this.selection_attribute_name])},selectAllDescendants:kd,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function Rd(t){return function(){return t}}class Fd{constructor(t,e={}){hd(e["css-classes"]),this.css_classes=cd,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=sd,this.draw_scale_bar=null,this.edge_placer=ad,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:Rd(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=i.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(Sp(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(),Md()}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){_d(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&&(Vt(t).select("svg").remove(),this.svg=(e="svg",Vt(L(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")),Vt(this.container).on("click",t=>{this.handle_node_click(null)},!0)),this}update_layout(t,e){e&&(this.nodes=Br(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("."+cd["tree-container"]).data([0]);if(r=r.enter().append("g").attr("class",cd["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("."+cd["tree-scale-bar"]).data([0]);t.enter().append("g").attr("class",cd["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("."+cd["tree-scale-bar"]).remove();r=this.svg.selectAll("."+cd["tree-container"]).data([0]),this.updateCollapsedClades(t);let o=r.selectAll(Nd(cd)).data(this.links.filter(Ed),t=>t.target.id||(t.target.id=++n));o.exit().remove(),o=o.enter().insert("path",":first-child").merge(o).each(function(n){e.drawEdge(this,n,t)});let s=r.selectAll(vd(cd)).data(this.phylotree.nodes.descendants().filter(gd),t=>t.id||(t.id=++n));if(s.exit().remove(),s=s.enter().append("g").attr("class",this.reclassNode).merge(s).attr("transform",t=>{const e="right-to-left"==this.options.layout&&Sp(t);return t.screen_x=td(t),t.screen_y=ed(t),this.d3PhylotreeSvgTranslate([e?0:t.screen_x,t.screen_y])}).each(function(n){e.drawNode(this,n,t)}).attr("transform",t=>{if(!i.isUndefined(t.screen_x)&&!i.isUndefined(t.screen_y))return"translate("+t.screen_x+","+t.screen_y+")"}),this.options["label-nodes-with-name"]&&(s=s.attr("id",t=>"node-"+t.name)),this.resizeSvg(this.phylotree,this.svg,t),this.options.brush){var a=r.selectAll("."+cd["tree-selection-brush"]).data([0]).enter().insert("g",":first-child").attr("class",cd["tree-selection-brush"]),u=_r().on("brush",(t,e)=>{var n=t.selection,r=this.links.filter(Ed).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",()=>{});a.call(u)}if(this.syncEdgeLabels(),this.options.zoom){let t=function(){var t,e,n,r=ms,i=ys,o=bs,s=vs,a=ws,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,h=Qe,p=A("start","zoom","end"),f=0,d=10;function g(t){t.property("__zoom",_s).on("wheel.zoom",x,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",E).filter(a).on("touchstart.zoom",N).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(t,e){return(e=Math.max(u[0],Math.min(u[1],e)))===t.k?t:new ps(e,t.x,t.y)}function y(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 ps(t.k,r,i)}function _(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function v(t,e,n,r){t.on("start.zoom",function(){w(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,o=arguments,s=w(t,o).event(r),a=i.apply(t,o),u=null==n?_(a):"function"==typeof n?n.apply(t,o):n,l=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),c=t.__zoom,p="function"==typeof e?e.apply(t,o):e,f=h(c.invert(u).concat(l/c.k),p.invert(u).concat(l/p.k));return function(t){if(1===t)t=p;else{var e=f(t),n=l/e[2];t=new ps(n,u[0]-e[0]*n,u[1]-e[1]*n)}s.zoom(null,t)}})}function w(t,e,n){return!n&&t.__zooming||new b(t,e)}function b(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=w(this,e).event(t),i=this.__zoom,a=Math.max(u[0],Math.min(u[1],i.k*Math.pow(2,s.apply(this,arguments)))),c=Yt(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===a)return;n.mouse=[c,i.invert(c)],xn(this),n.start()}gs(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",o(y(m(i,a),n.mouse[0],n.mouse[1]),n.extent,l))}}function T(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,s=w(this,e,!0).event(t),a=Vt(t.view).on("mousemove.zoom",function(t){if(gs(t),!s.moved){var e=t.clientX-c,n=t.clientY-h;s.moved=e*e+n*n>f}s.event(t).zoom("mouse",o(y(s.that.__zoom,s.mouse[0]=Yt(t,i),s.mouse[1]),s.extent,l))},!0).on("mouseup.zoom",function(t){a.on("mousemove.zoom mouseup.zoom",null),Xt(t.view,s.moved),gs(t),s.event(t).end()},!0),u=Yt(t,i),c=t.clientX,h=t.clientY;Ht(t.view),ds(t),s.mouse=[u,this.__zoom.invert(u)],xn(this),s.start()}}function E(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,s=Yt(t.changedTouches?t.changedTouches[0]:t,this),a=n.invert(s),u=n.k*(t.shiftKey?.5:2),h=o(y(m(n,u),s,a),i.apply(this,e),l);gs(t),c>0?Vt(this).transition().duration(c).call(v,h,s,t):Vt(this).call(g.transform,h,s,t)}}function N(n,...i){if(r.apply(this,arguments)){var o,s,a,u,l=n.touches,c=l.length,h=w(this,i,n.changedTouches.length===c).event(n);for(ds(n),s=0;s<c;++s)u=[u=Yt(a=l[s],this),this.__zoom.invert(u),a.identifier],h.touch0?h.touch1||h.touch0[2]===u[2]||(h.touch1=u,h.taps=0):(h.touch0=u,o=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),o&&(h.taps<2&&(e=u[0],t=setTimeout(function(){t=null},500)),xn(this),h.start())}}function D(t,...e){if(this.__zooming){var n,r,i,s,a=w(this,e).event(t),u=t.changedTouches,c=u.length;for(gs(t),n=0;n<c;++n)i=Yt(r=u[n],this),a.touch0&&a.touch0[2]===r.identifier?a.touch0[0]=i:a.touch1&&a.touch1[2]===r.identifier&&(a.touch1[0]=i);if(r=a.that.__zoom,a.touch1){var h=a.touch0[0],p=a.touch0[1],f=a.touch1[0],d=a.touch1[1],g=(g=f[0]-h[0])*g+(g=f[1]-h[1])*g,_=(_=d[0]-p[0])*_+(_=d[1]-p[1])*_;r=m(r,Math.sqrt(g/_)),i=[(h[0]+f[0])/2,(h[1]+f[1])/2],s=[(p[0]+d[0])/2,(p[1]+d[1])/2]}else{if(!a.touch0)return;i=a.touch0[0],s=a.touch0[1]}a.zoom("touch",o(y(r,i,s),a.extent,l))}}function O(t,...r){if(this.__zooming){var i,o,s=w(this,r).event(t),a=t.changedTouches,u=a.length;for(ds(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<u;++i)o=a[i],s.touch0&&s.touch0[2]===o.identifier?delete s.touch0:s.touch1&&s.touch1[2]===o.identifier&&delete s.touch1;if(s.touch1&&!s.touch0&&(s.touch0=s.touch1,delete s.touch1),s.touch0)s.touch0[1]=this.__zoom.invert(s.touch0[0]);else if(s.end(),2===s.taps&&(o=Yt(o,this),Math.hypot(e[0]-o[0],e[1]-o[1])<d)){var l=Vt(this).on("dblclick.zoom");l&&l.apply(this,arguments)}}}return g.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",_s),t!==i?v(t,e,n,r):i.interrupt().each(function(){w(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},g.scaleBy=function(t,e,n,r){g.scaleTo(t,function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)},n,r)},g.scaleTo=function(t,e,n,r){g.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,s=null==n?_(t):"function"==typeof n?n.apply(this,arguments):n,a=r.invert(s),u="function"==typeof e?e.apply(this,arguments):e;return o(y(m(r,u),s,a),t,l)},n,r)},g.translateBy=function(t,e,n,r){g.transform(t,function(){return o(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),l)},null,r)},g.translateTo=function(t,e,n,r,s){g.transform(t,function(){var t=i.apply(this,arguments),s=this.__zoom,a=null==r?_(t):"function"==typeof r?r.apply(this,arguments):r;return o(fs.translate(a[0],a[1]).scale(s.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,l)},r,s)},b.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=Vt(this.that).datum();p.call(t,this.that,new hs(t,{sourceEvent:this.sourceEvent,target:g,type:t,transform:this.that.__zoom,dispatch:p}),e)}},g.wheelDelta=function(t){return arguments.length?(s="function"==typeof t?t:cs(+t),g):s},g.filter=function(t){return arguments.length?(r="function"==typeof t?t:cs(!!t),g):r},g.touchable=function(t){return arguments.length?(a="function"==typeof t?t:cs(!!t),g):a},g.extent=function(t){return arguments.length?(i="function"==typeof t?t:cs([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),g):i},g.scaleExtent=function(t){return arguments.length?(u[0]=+t[0],u[1]=+t[1],g):[u[0],u[1]]},g.translateExtent=function(t){return arguments.length?(l[0][0]=+t[0][0],l[1][0]=+t[1][0],l[0][1]=+t[0][1],l[1][1]=+t[1][1],g):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},g.constrain=function(t){return arguments.length?(o=t,g):o},g.duration=function(t){return arguments.length?(c=+t,g):c},g.interpolate=function(t){return arguments.length?(h=t,g):h},g.on=function(){var t=p.on.apply(p,arguments);return t===p?g:t},g.clickDistance=function(t){return arguments.length?(f=(t=+t)*t,g):Math.sqrt(f)},g.tapDistance=function(t){return arguments.length?(d=+t,g):d},g}().scaleExtent([.1,10]).on("zoom",t=>{Vt("."+cd["tree-container"]).attr("transform",e=>t.transform),Vt("."+cd["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(md(t))return;let e=Sp(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(_d(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,Sp(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=i.partial(id,this.radial_center),this.edge_placer=od;let e=null,n=null,r=null,o=0,s=this._extents[0][1]*this.scales[0],a=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)))},u=0;this.phylotree.nodes.each(t=>{let e=t.x*this.scales[0];t.angle=2*Math.PI*e/s,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],u=Math.max(t.radius,u)});let l=0;this.phylotree.nodes.each(t=>{if(!t.children){let i=t.x*this.scales[0];if(null!==e){let s=i-n,c=a(t.radius,r,t.angle,e,l),h=c>0?s/c:10*this.options["max-radius"];if(h>this.options["max-radius"]){let n=s/this.options["max-radius"],i=t.radius+r,a=t.radius*r-(n*n-(r-t.radius)*(r-t.radius))/2/(1-Math.cos(e-t.angle)),c=Math.sqrt(i*i-4*a);l=Math.min(this.options["annular-limit"]*u,(-i+c)/2),o=this.options["max-radius"]}else o=Math.max(o,h)}e=t.angle,n=i,r=t.radius}}),this.radius=Math.min(this.options["max-radius"],Math.max(s/2/Math.PI,o)),t&&(this.radius=Math.min(this.radius,.5*(Math.min(s,this._extents[1][1]*this.scales[1])-this.label_width)-this.radius*l)),this.radial_center=this.radius_pad_for_bubbles=this.radius,this.draw_branch=i.partial(id,this.radial_center);let c=1;l&&(c=u/(u+l),this.radius*=c),this.phylotree.nodes.each(t=>{if(rd(t,this.radius,l,this.radial_center,this.scales,this.size),u=Math.max(u,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=rd(e,this.radius,l,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=sd,this.edge_placer=ad,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),Sp(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=ri().domain([0,t]).range([0,e]),r=Lr(".2f");if(this.draw_scale_bar=function(t){return E(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(gd).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=Rd(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 cd)n in t&&t[n]!=cd[n]&&(cd[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 cd)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(Nd(this.css_classes)).attr("class",this.reclassEdge.bind(this));this.edge_styler&&t.each(t=>{this.edge_styler(Vt(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()}}i.extend(Fd.prototype,Td),i.extend(Fd.prototype,bd),i.extend(Fd.prototype,Ad),i.extend(Fd.prototype,Sd),i.extend(Fd.prototype,Ld),i.extend(Fd.prototype,dd);let jd=class{constructor(t,e={}){this.newick_string="",this.nodes=[],this.links=[],this.parsed_tags=[],this.partitions=[],this.branch_length_accessor=Qf,this.branch_length=Qf,this.logger=e.logger||console,this.selection_attribute_name="selected";var n=e.type||void 0,r=[],o=this;if(i.isString(n))n in Xf?r=Xf[n](t,e):o.logger.error("type "+n+" not in registry! Available types are "+i.keys(Xf));else if(i.isFunction(n))try{r=n(t,e)}catch(t){o.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=Hf(t):(this.newick_string=t,r=Lp(t,e));if(r.json){o.nodes=Br(r.json);let t={};o.nodes.each(e=>{e.data.annotation&&(t[e.data.annotation]=!0)}),o.parsed_tags=Object.keys(t)}else o.nodes=[];return o.links=o.nodes.links(),this.hasBranchLengths()||(console.warn("Phylotree User Warning : NO BRANCH LENGTHS DETECTED, SETTING ALL LENGTHS TO 1"),this.setBranchLength(t=>1)),o}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=i.clone(t);delete r.json_export_index,t.parent&&(r.parent=t.parent.json_export_index),t.children&&(r.children=i.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){Wf(e,t,r)}:"in-order"==e?function(e){Kf(e,t,r)}:function(e){i.isUndefined(e)||Gf(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 Fd(this,t),this.display}};function Ud(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&&i.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&&i.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&&i.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&&(i.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 zd(t,e,n,r,i){var o=t.branch_length(e),s=!1;if(n||(r=e.data.rootToTip,i=0,s=!0),e.children)for(var a=0;a<e.children.length;a++)e.children[a]!=n?zd(t,e.children[a],e,r,i):s=!0;e.data.rtta=e.data.rootToTip-r+i,s&&(r-=o,i+=o),e.parent&&s&&zd(t,e.parent,e,r,i)}function Bd(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,o=r/e,s=0,a=0,u=0;t.forEach(function(t){var e=t[0]-i;a+=t[2]*e*e,s+=t[2]*e*t[1],u+=t[2]*(t[1]-o)*(t[1]-o)});var l=(r-n*(s/=a))/e,c=0;return t.forEach(function(t){var e=t[1]-l-s*t[0];c+=t[2]*e*e}),{intercept:l,slope:s,r2:1-c/u,"var (intercept)":Math.sqrt((1+n*n/(e*a))/e),"var (slope)":Math.sqrt(1/a)}}function Vd(t){var e=t.branch_length_accessor,n=0;t.traverse_and_compute(r=>{if(r.parent&&(r.data._computed_length=e(r),!i.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:(i.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}jd.prototype.isLeafNode=Sp,jd.prototype.selectAllDescendants=Pp,jd.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=i.union(...n.descendants().map(t=>t.data.mrca)),e||n.data.mrca.length!=t.length||(e=n)):e||(e=n):n.data.mrca=i.intersection([n.data.name],t)}),e},jd.prototype.hasBranchLengths=function(){let t=this.branch_length;return!!t&&i.every(this.nodes.descendants(),function(e){return!e.parent||!i.isUndefined(t(e))})},jd.prototype.getBranchLengths=function(){let t=this.branch_length;return i.map(this.nodes.descendants(),e=>t(e))},jd.prototype.branchName=function(t){return arguments.length?(this.nodeLabel=t,this):this.nodeLabel},jd.prototype.normalizeBranchLengths=function(t){let e=this.branch_length,n=i.map(this.nodes.descendants(),function(t){return e(t)?e(t):null});const r=i.max(n),o=i.min(n);return i.each(this.nodes.descendants(),t=>{let n=e(t);n&&e(t,function(t){return(t-o)/(r-o)}(n))}),this},jd.prototype.scaleBranchLengths=function(t){let e=this.branch_length;return i.each(this.nodes.descendants(),n=>{let r=e(n);r&&e(n,t(r))}),this},jd.prototype.getNewick=Rp,jd.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},jd.prototype.setBranchLength=function(t){return arguments.length?(this.branch_length_accessor=t||Qf,this):this.branch_length_accessor},jd.prototype.maxParsimony=function(t,e){const n=i.partial(function(t,e){if(e.mp=[[0,0],[!1,!1]],Sp(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)=>Sp(t.target)?t.target[e]:t.target.mp)},jd.prototype.getTipLengths=function(){let t=this.getTips(),e=i.map(t,t=>({name:t.data.name,length:parseFloat(t.data.attribute)}));return e=i.sortBy(e,t=>-t.length),e},jd.prototype.leftChildRightSibling=Zf,i.extend(jd.prototype,kp),i.extend(jd.prototype,Jf),i.extend(jd.prototype,zp);const Yd=Li("%Y%m%d"),$d=/([0-9]{4}).?([0-9]{2}).?([0-9]{2})$/g,qd=function(t){if(Sp(t)&&"name"in t){let e=$d.exec(t.name);if(e)return e[1]+e[2]+e[3]}return null};function Hd(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=Ud(t),r=Number.MAX_VALUE,o=0,s=null;return 2==e?t.traverse_and_compute(function(t){if(t.parent){var e=0,a=0,u=0,l=0,c=0;i.each(t.cot_path_to_leaves_below,function(t){e+=t,a+=t*t,c++}),i.each(t.cot_path_to_leaves_above,function(t){u+=t,l+=t*t});var h=n-c,p=(u-e+t.cot_computed_length*h)/n;p<0?p=0:p>t.cot_computed_length&&(p=t.cot_computed_length);var f=l+a+2*(u*(t.cot_computed_length-p)+e*p)+c*p*p+(t.cot_computed_length-p)*(t.cot_computed_length-p)*h;f<r&&(s=t,o=p/t.cot_computed_length,r=f),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,a=0;a<t.cot_computed_length;){var u=0;i.each(t.cot_path_to_leaves_below,function(t){u+=Math.pow(t+a,e)}),i.each(t.cot_path_to_leaves_above,function(n){u+=Math.pow(n+(t.cot_computed_length-a),e)}),u<r&&(s=t,o=a/t.cot_computed_length,r=u),a+=n}}),{location:s,breakpoint:o,distance:r}},t.clusterPicker=function(t,e,n,r,o){r=r||t.getRootNode(),o=i.isNumber(o)?o:1;let s=t.branch_length;t.traverse_and_compute(function(t){if(t.parent){if(t._computed_length=s(t),!i.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 a=[];return t.traverse_and_compute(i.noop,"pre-order",r,function(r){if(!t.isLeafNode(r)){var s=i.isString(r.data.bootstrap_values)?+r.data.bootstrap_values:o;if(s>=e){var u=i.reduce(r.children,function(t,e){return e.max_path_length+e._computed_length+t},0);if(u<=n)return a.push({root:r,diameter:u,bootstrap:s}),!0}}return!1}),t.traverse_and_compute(function(t){t.parent&&(delete t._computed_length,delete t.max_path_length)},"post-order",r),i.each(a,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),a},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 o=e(i);if(!(o<=r))return{location:i,breakpoint:r/o};r-=o,i=i.parent}}return{location:n,breakpoint:0}},t.extract_dates=function(t,e,n=Yd){return e=e||qd,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(),o=new Date(i,0,1),s=new Date(i+1,0,1);return void(t.data.decimal_date_value=i+(t.data.date_value-o)/(s-o))}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),Vd(t),t.traverse_and_compute(function(n){t.isLeafNode(n)&&!i.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});let o=Bd(e);return t.traverse_and_compute(function(s){if(t.isLeafNode(s)&&!i.isNull(s.data.decimal_date_value)){zd(t,s,null,0,0),e=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&!i.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});var a=Bd(e),u=a.r2;u>n&&(n=u,r=s,o=a)}}),{root:r,fit:o}},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=Rp,t.inOrder=Kf,t.leftChildRightSibling=Zf,t.loadAnnotations=jp,t.neighborJoining=function t(e,n,r){if(n<=2){let t=new jd(""),n=t.getNodes(),i=e[0][1]/2,o=t.createNode(r[0],[null,[i]]),s=t.createNode(r[1],[null,[i]]);return t.addChild(n,o),t.addChild(n,s),t}{let s=n,a=(i=e,o.map(i,o.sum)),u=function(t,e,n){let r=o.chunk(o.fill(Array(n*n),0),n);for(let i of o.range(n))for(let s of o.range(o.parseInt(i)+1,n))r[i][s]=(n-2)*t[i][s]-e[i]-e[s],r[s][i]=r[i][s];return r}(e,a,s),[l,c,h]=function(t,e){let n=-1,r=-1,i=1/0;for(let s of o.range(e))for(let a of o.range(n,e))t[s][a]<i&&(n=s,r=a,i=t[n][r]);return[n,r,i]}(u,s),p=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}(a,s),f=(e[l][c]+p[l][c])/2,d=(e[l][c]-p[l][c])/2,g=o.concat(0,o.filter(o.map(o.range(n),t=>{if(t!=l&&t!=c)return.5*(e[t][l]+e[t][c]-e[l][c])}),o.isNumber)),m=r[l],y=r[c],_="InternalNode0",v=o.filter(r,t=>o.includes(t,"InternalNode"));if(v.length){let t=o.max(o.map(v,t=>o.split(t,"InternalNode")[1]));_="InternalNode"+ ++t}r.unshift(_),e=Hd(o.max([l,c]),e),(e=Hd(o.min([l,c]),e)).unshift(g),o.each(o.range(1,n-1),t=>e[t].unshift(g[t])),o.remove(r,t=>t==m||t==y);let w=t(e,s-1,r),b=w.createNode(m,[null,[f]]),x=w.createNode(y,[null,[d]]);if(w.getNodeByName(_)){let t=w.getNodeByName(_);w.addChild(t,b),w.addChild(t,x)}else{let t=w.createNode(_,[null,[0]]);w.addChild(w.getNodes(),t),w.addChild(t,b),w.addChild(t,x)}return w}var i},t.newickParser=Lp,t.pairwise_distances=Ud,t.parseAnnotations=Fp,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,o){r=i.isNumber(r)?r:1;var s=Ud(t),a=t.getRootNode().children[0],u=Number.MAX_VALUE,l=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<u?(u<l&&(l=u),u=e.cot_computed_length):e.cot_computed_length<l&&(l=e.cot_computed_length))}),u+=l;var c=i.reduce(a.cot_path_to_leaves_below,function(t,e){return e>t?e:t},0)+i.reduce(a.cot_path_to_leaves_above,function(t,e){return e>t?e:t},0)+a.cot_computed_length-u;i.isUndefined(o)&&(o=Math.min(.001,c/100));var h=1+(c/o|0);h>500&&(o=c/(h=500));var p=t.getRootNode();p.paths_to_leaves=new Array(s),i.each(p.children,function(t){i.each(p.cot_path_to_leaves_below,function(e,n){p.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=[],i.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 i=e.paths_to_leaves[n]+e.paths_to_leaves[r];e.histogram[(i-u)/o|0]++}e.leaf_count=e.paths_to_leaves.length,delete e.paths_to_leaves}});for(var f=(s-1)*s/2*n,d=0;d<h-1&&f>p.histogram[d];d++)f-=p.histogram[d];var g=u+(d+(p.histogram[d]-f)/p.histogram[d])*o,m=[];return t.traverse_and_compute(i.noop,"pre-order",null,function(n){if(!t.isLeafNode(n)){var s=i.isString(n.data.bootstrap_values)?+n.data.bootstrap_values:r;if(s>=e){for(var a=n.leaf_count*(n.leaf_count-1)*.25,l=0;l<h-1&&a>n.histogram[l];l++)a-=n.histogram[l];var c=u+(l+(n.histogram[l]-a)/n.histogram[l])*o;if(c<=g)return m.push({root:n,median:c,bootstrap:s}),!0}}return!1}),t.traverse_and_compute(function(e){t.isLeafNode(e)||"histogram"in e&&(delete e.histogram,delete e.leaf_count)}),i.each(m,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),m},t.phylotree=jd,t.postOrder=Gf,t.preOrder=Wf,t.rootToTip=Vd,t.sackin=function(t){let e=t.getTips(),n=i.map(e,t=>t.depth);return i.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("lodash")):"function"==typeof define&&define.amd?define(["exports","underscore","lodash"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).phylotree=t.phylotree||{},t._,t._$1)}(this,function(t,e,n){"use strict";function r(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 i=r(e),o=r(n);function s(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function a(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function l(t){let e,n,r;function i(t,r,i=0,o=t.length){if(i<o){if(0!==e(r,r))return o;do{const e=i+o>>>1;n(t[e],r)<0?i=e+1:o=e}while(i<o)}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===a?t:u,n=t,r=t),{left:i,center:function(t,e,n=0,o=t.length){const s=i(t,e,n,o-1);return s>n&&r(t[s-1],e)>-r(t[s],e)?s-1:s},right:function(t,r,i=0,o=t.length){if(i<o){if(0!==e(r,r))return o;do{const e=i+o>>>1;n(t[e],r)<=0?i=e+1:o=e}while(i<o)}return i}}}function u(){return 0}const c=l(s).right;l(function(t){return null===t?NaN:+t}).center;var h=c;const f=Math.sqrt(50),d=Math.sqrt(10),p=Math.sqrt(2);function _(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),s=o>=f?10:o>=d?5:o>=p?2:1;let a,l,u;return i<0?(u=Math.pow(10,-i)/s,a=Math.round(t*u),l=Math.round(e*u),a/u<t&&++a,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*s,a=Math.round(t/u),l=Math.round(e/u),a*u<t&&++a,l*u>e&&--l),l<a&&.5<=n&&n<2?_(t,e,2*n):[a,l,u]}function g(t,e,n){return _(t=+t,e=+e,n=+n)[2]}function m(t){return t}var v=1e-6;function y(t){return"translate("+t+",0)"}function b(t){return"translate(0,"+t+")"}function x(t){return e=>+t(e)}function w(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 M(t,e){var n=[],r=null,i=null,o=6,s=6,a=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?y:b;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):m:i,_=Math.max(o,0)+a,g=e.range(),y=+g[0]+l,b=+g[g.length-1]+l,M=(e.bandwidth?w:x)(e.copy(),l),T=f.selection?f.selection():f,E=T.selectAll(".domain").data([null]),A=T.selectAll(".tick").data(d,e).order(),k=A.exit(),S=A.enter().append("g").attr("class","tick"),C=A.select("line"),z=A.select("text");E=E.merge(E.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),A=A.merge(S),C=C.merge(S.append("line").attr("stroke","currentColor").attr(c+"2",u*o)),z=z.merge(S.append("text").attr("fill","currentColor").attr(c,u*_).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),f!==T&&(E=E.transition(f),A=A.transition(f),C=C.transition(f),z=z.transition(f),k=k.transition(f).attr("opacity",v).attr("transform",function(t){return isFinite(t=M(t))?h(t+l):this.getAttribute("transform")}),S.attr("opacity",v).attr("transform",function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:M(t))+l)})),k.remove(),E.attr("d",4===t||2===t?s?"M"+u*s+","+y+"H"+l+"V"+b+"H"+u*s:"M"+l+","+y+"V"+b:s?"M"+y+","+u*s+"V"+l+"H"+b+"V"+u*s:"M"+y+","+l+"H"+b),A.attr("opacity",1).attr("transform",function(t){return h(M(t)+l)}),C.attr(c+"2",u*o),z.attr(c,u*_).text(p),T.filter(N).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),T.each(function(){this.__axis=M})}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?(o=s=+t,f):o},f.tickSizeInner=function(t){return arguments.length?(o=+t,f):o},f.tickSizeOuter=function(t){return arguments.length?(s=+t,f):s},f.tickPadding=function(t){return arguments.length?(a=+t,f):a},f.offset=function(t){return arguments.length?(l=+t,f):l},f}var T={value:()=>{}};function E(){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 A(r)}function A(t){this._=t}function k(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function S(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}A.prototype=E.prototype={constructor:A,on:function(t,e){var n,r,i=this._,o=(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}})),s=-1,a=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++s<a;)if(n=(t=o[s]).type)i[n]=S(i[n],t.name,e);else if(null==e)for(n in i)i[n]=S(i[n],t.name,null);return this}for(;++s<a;)if((n=(t=o[s]).type)&&(n=k(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new A(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].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,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var C="http://www.w3.org/1999/xhtml",z={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)),z.hasOwnProperty(e)?{space:z[e],local:t}:t}function $(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 P(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function O(t){var e=D(t);return(e.local?P:$)(e)}function I(){}function L(t){return null==t?I:function(){return this.querySelector(t)}}function U(){return[]}function F(t){return null==t?U:function(){return this.querySelectorAll(t)}}function j(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function H(t){return function(){return this.matches(t)}}function Y(t){return function(e){return e.matches(t)}}var V=Array.prototype.find;function B(){return this.firstElementChild}var R=Array.prototype.filter;function q(){return Array.from(this.children)}function X(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 W(t,e,n,r,i,o){for(var s,a=0,l=e.length,u=o.length;a<u;++a)(s=e[a])?(s.__data__=o[a],r[a]=s):n[a]=new Z(t,o[a]);for(;a<l;++a)(s=e[a])&&(i[a]=s)}function G(t,e,n,r,i,o,s){var a,l,u,c=new Map,h=e.length,f=o.length,d=new Array(h);for(a=0;a<h;++a)(l=e[a])&&(d[a]=u=s.call(l,l.__data__,a,e)+"",c.has(u)?i[a]=l:c.set(u,l));for(a=0;a<f;++a)u=s.call(t,o[a],a,o)+"",(l=c.get(u))?(r[a]=l,l.__data__=o[a],c.delete(u)):n[a]=new Z(t,o[a]);for(a=0;a<h;++a)(l=e[a])&&c.get(d[a])===l&&(i[a]=l)}function K(t){return t.__data__}function J(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Q(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function tt(t){return function(){this.removeAttribute(t)}}function et(t){return function(){this.removeAttributeNS(t.space,t.local)}}function nt(t,e){return function(){this.setAttribute(t,e)}}function rt(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function it(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 at(t){return function(){this.style.removeProperty(t)}}function lt(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ut(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function ct(t,e){return t.style.getPropertyValue(e)||st(t).getComputedStyle(t,null).getPropertyValue(e)}function ht(t){return function(){delete this[t]}}function ft(t,e){return function(){this[t]=e}}function dt(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function pt(t){return t.trim().split(/^|\s+/)}function _t(t){return t.classList||new gt(t)}function gt(t){this._node=t,this._names=pt(t.getAttribute("class")||"")}function mt(t,e){for(var n=_t(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function vt(t,e){for(var n=_t(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function yt(t){return function(){mt(this,t)}}function bt(t){return function(){vt(this,t)}}function xt(t,e){return function(){(e.apply(this,arguments)?mt:vt)(this,t)}}function wt(){this.textContent=""}function Nt(t){return function(){this.textContent=t}}function Mt(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Tt(){this.innerHTML=""}function Et(t){return function(){this.innerHTML=t}}function At(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function kt(){this.nextSibling&&this.parentNode.appendChild(this)}function St(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ct(){return null}function zt(){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 $t(){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,o=e.length;r<o;++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,o=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(i)for(var s=0,a=i.length;s<a;++s)if((r=i[s]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),void(r.value=e);this.addEventListener(t.type,o,n),r={type:t.type,name:t.name,value:e,listener:o,options:n},i?i.push(r):this.__on=[r]}}function It(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 Lt(t,e){return function(){return It(this,t,e)}}function Ut(t,e){return function(){return It(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)}},gt.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 jt(t,e){this._groups=t,this._parents=e}function Ht(){return new jt([[document.documentElement]],Ft)}function Yt(t){return"string"==typeof t?new jt([[document.querySelector(t)]],[document.documentElement]):new jt([[t]],Ft)}function Vt(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]}jt.prototype=Ht.prototype={constructor:jt,select:function(t){"function"!=typeof t&&(t=L(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s,a=e[i],l=a.length,u=r[i]=new Array(l),c=0;c<l;++c)(o=a[c])&&(s=t.call(o,o.__data__,c,a))&&("__data__"in o&&(s.__data__=o.__data__),u[c]=s);return new jt(r,this._parents)},selectAll:function(t){t="function"==typeof t?j(t):F(t);for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o)for(var s,a=e[o],l=a.length,u=0;u<l;++u)(s=a[u])&&(r.push(t.call(s,s.__data__,u,a)),i.push(s));return new jt(r,i)},selectChild:function(t){return this.select(null==t?B:function(t){return function(){return V.call(this.children,t)}}("function"==typeof t?t:Y(t)))},selectChildren:function(t){return this.selectAll(null==t?q:function(t){return function(){return R.call(this.children,t)}}("function"==typeof t?t:Y(t)))},filter:function(t){"function"!=typeof t&&(t=H(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s=e[i],a=s.length,l=r[i]=[],u=0;u<a;++u)(o=s[u])&&t.call(o,o.__data__,u,s)&&l.push(o);return new jt(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,K);var n=e?G:W,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t}}(t));for(var o=i.length,s=new Array(o),a=new Array(o),l=new Array(o),u=0;u<o;++u){var c=r[u],h=i[u],f=h.length,d=J(t.call(c,c&&c.__data__,u,r)),p=d.length,_=a[u]=new Array(p),g=s[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(s=new jt(s,r))._enter=a,s._exit=l,s},enter:function(){return new jt(this._enter||this._groups.map(X),this._parents)},exit:function(){return new jt(this._exit||this._groups.map(X),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,o=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?o.remove():n(o),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,o=r.length,s=Math.min(i,o),a=new Array(i),l=0;l<s;++l)for(var u,c=n[l],h=r[l],f=c.length,d=a[l]=new Array(f),p=0;p<f;++p)(u=c[p]||h[p])&&(d[p]=u);for(;l<i;++l)a[l]=n[l];return new jt(a,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],o=i.length-1,s=i[o];--o>=0;)(r=i[o])&&(s&&4^r.compareDocumentPosition(s)&&s.parentNode.insertBefore(r,s),s=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=Q);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s,a=n[o],l=a.length,u=i[o]=new Array(l),c=0;c<l;++c)(s=a[c])&&(u[c]=s);u.sort(e)}return new jt(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,o=r.length;i<o;++i){var s=r[i];if(s)return s}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,o=e[n],s=0,a=o.length;s<a;++s)(i=o[s])&&t.call(i,i.__data__,s,o);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?et:tt:"function"==typeof e?n.local?ot:it:n.local?rt:nt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?at:"function"==typeof e?ut:lt)(t,e,null==n?"":n)):ct(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ht:"function"==typeof e?dt:ft)(t,e)):this.node()[t]},classed:function(t,e){var n=pt(t+"");if(arguments.length<2){for(var r=_t(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?xt:e?yt:bt)(n,e))},text:function(t){return arguments.length?this.each(null==t?wt:("function"==typeof t?Mt:Nt)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Tt:("function"==typeof t?At:Et)(t)):this.node().innerHTML},raise:function(){return this.each(kt)},lower:function(){return this.each(St)},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?Ct:"function"==typeof e?e:L(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(zt)},clone:function(t){return this.select(t?$t:Dt)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,o=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+""),s=o.length;if(!(arguments.length<2)){for(a=e?Ot:Pt,r=0;r<s;++r)this.each(a(o[r],e,n));return this}var a=this.node().__on;if(a)for(var l,u=0,c=a.length;u<c;++u)for(r=0,l=a[u];r<s;++r)if((i=o[r]).type===l.type&&i.name===l.name)return l.value},dispatch:function(t,e){return this.each(("function"==typeof e?Ut:Lt)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],o=0,s=i.length;o<s;++o)(r=i[o])&&(yield r)}};const Bt={capture:!0,passive:!1};function Rt(t){t.preventDefault(),t.stopImmediatePropagation()}function qt(t){var e=t.document.documentElement,n=Yt(t).on("dragstart.drag",Rt,Bt);"onselectstart"in e?n.on("selectstart.drag",Rt,Bt):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Xt(t,e){var n=t.document.documentElement,r=Yt(t).on("dragstart.drag",null);e&&(r.on("click.drag",Rt,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 Wt(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Gt(){}var Kt=.7,Jt=1/Kt,Qt="\\s*([+-]?\\d+)\\s*",te="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ne=/^#([0-9a-f]{3,8})$/,re=new RegExp(`^rgb\\(${Qt},${Qt},${Qt}\\)$`),ie=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),oe=new RegExp(`^rgba\\(${Qt},${Qt},${Qt},${te}\\)$`),se=new RegExp(`^rgba\\(${ee},${ee},${ee},${te}\\)$`),ae=new RegExp(`^hsl\\(${te},${ee},${ee}\\)$`),le=new RegExp(`^hsla\\(${te},${ee},${ee},${te}\\)$`),ue={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 ce(){return this.rgb().formatHex()}function he(){return this.rgb().formatRgb()}function fe(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ne.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?de(e):3===n?new ge(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?pe(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?pe(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=re.exec(t))?new ge(e[1],e[2],e[3],1):(e=ie.exec(t))?new ge(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=oe.exec(t))?pe(e[1],e[2],e[3],e[4]):(e=se.exec(t))?pe(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=ae.exec(t))?we(e[1],e[2]/100,e[3]/100,1):(e=le.exec(t))?we(e[1],e[2]/100,e[3]/100,e[4]):ue.hasOwnProperty(t)?de(ue[t]):"transparent"===t?new ge(NaN,NaN,NaN,0):null}function de(t){return new ge(t>>16&255,t>>8&255,255&t,1)}function pe(t,e,n,r){return r<=0&&(t=e=n=NaN),new ge(t,e,n,r)}function _e(t,e,n,r){return 1===arguments.length?((i=t)instanceof Gt||(i=fe(i)),i?new ge((i=i.rgb()).r,i.g,i.b,i.opacity):new ge):new ge(t,e,n,null==r?1:r);var i}function ge(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function me(){return`#${xe(this.r)}${xe(this.g)}${xe(this.b)}`}function ve(){const t=ye(this.opacity);return`${1===t?"rgb(":"rgba("}${be(this.r)}, ${be(this.g)}, ${be(this.b)}${1===t?")":`, ${t})`}`}function ye(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function be(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function xe(t){return((t=be(t))<16?"0":"")+t.toString(16)}function we(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Me(t,e,n,r)}function Ne(t){if(t instanceof Me)return new Me(t.h,t.s,t.l,t.opacity);if(t instanceof Gt||(t=fe(t)),!t)return new Me;if(t instanceof Me)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),s=NaN,a=o-i,l=(o+i)/2;return a?(s=e===o?(n-r)/a+6*(n<r):n===o?(r-e)/a+2:(e-n)/a+4,a/=l<.5?o+i:2-o-i,s*=60):a=l>0&&l<1?0:s,new Me(s,a,l,t.opacity)}function Me(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 Ee(t){return Math.max(0,Math.min(1,t||0))}function Ae(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(Gt,fe,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:ce,formatHex:ce,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Ne(this).formatHsl()},formatRgb:he,toString:he}),Zt(ge,_e,Wt(Gt,{brighter(t){return t=null==t?Jt:Math.pow(Jt,t),new ge(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Kt:Math.pow(Kt,t),new ge(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ge(be(this.r),be(this.g),be(this.b),ye(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:me,formatHex:me,formatHex8:function(){return`#${xe(this.r)}${xe(this.g)}${xe(this.b)}${xe(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:ve,toString:ve})),Zt(Me,function(t,e,n,r){return 1===arguments.length?Ne(t):new Me(t,e,n,null==r?1:r)},Wt(Gt,{brighter(t){return t=null==t?Jt:Math.pow(Jt,t),new Me(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Kt:Math.pow(Kt,t),new Me(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 ge(Ae(t>=240?t-240:t+120,i,r),Ae(t,i,r),Ae(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Me(Te(this.h),Ee(this.s),Ee(this.l),ye(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=ye(this.opacity);return`${1===t?"hsl(":"hsla("}${Te(this.h)}, ${100*Ee(this.s)}%, ${100*Ee(this.l)}%${1===t?")":`, ${t})`}`}}));var ke=t=>()=>t;function Se(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):ke(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):ke(isNaN(t)?e:t)}var ze=function t(e){var n=Se(e);function r(t,e){var r=n((t=_e(t)).r,(e=_e(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),s=Ce(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=s(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(o){for(n=0;n<r;++n)i[n]=t[n]*(1-o)+e[n]*o;return i}}function $e(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,o=new Array(i),s=new Array(r);for(n=0;n<i;++n)o[n]=je(t[n],e[n]);for(;n<r;++n)s[n]=e[n];return function(t){for(n=0;n<i;++n)s[n]=o[n](t);return s}}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 Ie(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]=je(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}var Le=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ue=new RegExp(Le.source,"g");function Fe(t,e){var n,r,i,o=Le.lastIndex=Ue.lastIndex=0,s=-1,a=[],l=[];for(t+="",e+="";(n=Le.exec(t))&&(r=Ue.exec(e));)(i=r.index)>o&&(i=e.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:Oe(n,r)})),o=Ue.lastIndex;return o<e.length&&(i=e.slice(o),a[s]?a[s]+=i:a[++s]=i),a.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)a[(n=l[r]).i]=n.x(t);return a.join("")})}function je(t,e){var n,r=typeof e;return null==e||"boolean"===r?ke(e):("number"===r?Oe:"string"===r?(n=fe(e))?(e=n,ze):Fe:e instanceof fe?ze:e instanceof Date?Pe:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(e)?De:Array.isArray(e)?$e:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?Ie:Oe)(t,e)}function He(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}var Ye,Ve=180/Math.PI,Be={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Re(t,e,n,r,i,o){var s,a,l;return(s=Math.sqrt(t*t+e*e))&&(t/=s,e/=s),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),t*r<e*n&&(t=-t,e=-e,l=-l,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*Ve,skewX:Math.atan(l)*Ve,scaleX:s,scaleY:a}}function qe(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(o,s){var a=[],l=[];return o=t(o),s=t(s),function(t,r,i,o,s,a){if(t!==i||r!==o){var l=s.push("translate(",null,e,null,n);a.push({i:l-4,x:Oe(t,i)},{i:l-2,x:Oe(r,o)})}else(i||o)&&s.push("translate("+i+e+o+n)}(o.translateX,o.translateY,s.translateX,s.translateY,a,l),function(t,e,n,o){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Oe(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,s.rotate,a,l),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Oe(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,s.skewX,a,l),function(t,e,n,r,o,s){if(t!==n||e!==r){var a=o.push(i(o)+"scale(",null,",",null,")");s.push({i:a-4,x:Oe(t,n)},{i:a-2,x:Oe(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,s.scaleX,s.scaleY,a,l),o=s=null,function(t){for(var e,n=-1,r=l.length;++n<r;)a[(e=l[n]).i]=e.x(t);return a.join("")}}}var Xe=qe(function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Be:Re(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),Ze=qe(function(t){return null==t?Be:(Ye||(Ye=document.createElementNS("http://www.w3.org/2000/svg","g")),Ye.setAttribute("transform",t),(t=Ye.transform.baseVal.consolidate())?Re((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Be)},", ",")",")");function We(t){return((t=Math.exp(t))+1/t)/2}var Ge,Ke,Je=function t(e,n,r){function i(t,i){var o,s,a=t[0],l=t[1],u=t[2],c=i[0],h=i[1],f=i[2],d=c-a,p=h-l,_=d*d+p*p;if(_<1e-12)s=Math.log(f/u)/e,o=function(t){return[a+t*d,l+t*p,u*Math.exp(e*t*s)]};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);s=(b-y)/e,o=function(t){var r=t*s,i=We(y),o=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[a+o*d,l+o*p,u*i/We(e*r+y)]}}return o.duration=1e3*s*e/Math.SQRT2,o}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),Qe=0,tn=0,en=0,nn=0,rn=0,on=0,sn="object"==typeof performance&&performance.now?performance:Date,an="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ln(){return rn||(an(un),rn=sn.now()+on)}function un(){rn=0}function cn(){this._call=this._time=this._next=null}function hn(t,e,n){var r=new cn;return r.restart(t,e,n),r}function fn(){rn=(nn=sn.now())+on,Qe=tn=0;try{!function(){ln(),++Qe;for(var t,e=Ge;e;)(t=rn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qe}()}finally{Qe=0,function(){var t,e,n=Ge,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:Ge=e);Ke=t,pn(r)}(),rn=0}}function dn(){var t=sn.now(),e=t-nn;e>1e3&&(on-=e,nn=t)}function pn(t){Qe||(tn&&(tn=clearTimeout(tn)),t-rn>24?(t<1/0&&(tn=setTimeout(fn,t-sn.now()-on)),en&&(en=clearInterval(en))):(en||(nn=sn.now(),en=setInterval(dn,1e3)),Qe=1,an(fn)))}function _n(t,e,n){var r=new cn;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}cn.prototype=hn.prototype={constructor:cn,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?ln():+n)+(null==e?0:+e),this._next||Ke===this||(Ke?Ke._next=this:Ge=this,Ke=this),this._call=t,this._time=n,pn()},stop:function(){this._call&&(this._call=null,this._time=1/0,pn())}};var gn=E("start","end","cancel","interrupt"),mn=[];function vn(t,e,n,r,i,o){var s=t.__transition;if(s){if(n in s)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(t){n.state=1,n.timer.restart(s,n.delay,n.time),n.delay<=t&&s(t-n.delay)}function s(o){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 _n(s);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(_n(function(){3===n.state&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(o))}),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 a(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(l),n.state=5,1),o=-1,s=r.length;++o<s;)r[o].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=hn(o,0,n.time)}(t,n,{name:e,index:r,group:i,on:gn,tween:mn,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function yn(t,e){var n=xn(t,e);if(n.state>0)throw new Error("too late; already scheduled");return n}function bn(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 wn(t,e){var n,r,i,o=t.__transition,s=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[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 o[i]):s=!1;s&&delete t.__transition}}function Nn(t,e){var n,r;return function(){var i=bn(this,t),o=i.tween;if(o!==n)for(var s=0,a=(r=n=o).length;s<a;++s)if(r[s].name===e){(r=r.slice()).splice(s,1);break}i.tween=r}}function Mn(t,e,n){var r,i;if("function"!=typeof n)throw new Error;return function(){var o=bn(this,t),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:e,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===e){i[l]=a;break}l===u&&i.push(a)}o.tween=i}}function Tn(t,e,n){var r=t._id;return t.each(function(){var t=bn(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return xn(t,r).value[e]}}function En(t,e){var n;return("number"==typeof e?Oe:e instanceof fe?ze:(n=fe(e))?(e=n,ze):Fe)(t,e)}function An(t){return function(){this.removeAttribute(t)}}function kn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Sn(t,e,n){var r,i,o=n+"";return function(){var s=this.getAttribute(t);return s===o?null:s===r?i:i=e(r=s,n)}}function Cn(t,e,n){var r,i,o=n+"";return function(){var s=this.getAttributeNS(t.space,t.local);return s===o?null:s===r?i:i=e(r=s,n)}}function zn(t,e,n){var r,i,o;return function(){var s,a,l=n(this);if(null!=l)return(s=this.getAttribute(t))===(a=l+"")?null:s===r&&a===i?o:(i=a,o=e(r=s,l));this.removeAttribute(t)}}function Dn(t,e,n){var r,i,o;return function(){var s,a,l=n(this);if(null!=l)return(s=this.getAttributeNS(t.space,t.local))===(a=l+"")?null:s===r&&a===i?o:(i=a,o=e(r=s,l));this.removeAttributeNS(t.space,t.local)}}function $n(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(){yn(this,t).delay=+e.apply(this,arguments)}}function In(t,e){return e=+e,function(){yn(this,t).delay=e}}function Ln(t,e){return function(){bn(this,t).duration=+e.apply(this,arguments)}}function Un(t,e){return e=+e,function(){bn(this,t).duration=e}}var Fn=Ht.prototype.constructor;function jn(t){return function(){this.style.removeProperty(t)}}var Hn=0;function Yn(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Vn(){return++Hn}var Bn=Ht.prototype;Yn.prototype={constructor:Yn,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=L(t));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a,l,u=r[s],c=u.length,h=o[s]=new Array(c),f=0;f<c;++f)(a=u[f])&&(l=t.call(a,a.__data__,f,u))&&("__data__"in a&&(l.__data__=a.__data__),h[f]=l,vn(h[f],e,n,f,h,xn(a,n)));return new Yn(o,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,o=[],s=[],a=0;a<i;++a)for(var l,u=r[a],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[_])&&vn(f,e,n,_,d,p);o.push(d),s.push(l)}return new Yn(o,s,e,n)},selectChild:Bn.selectChild,selectChildren:Bn.selectChildren,filter:function(t){"function"!=typeof t&&(t=H(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var o,s=e[i],a=s.length,l=r[i]=[],u=0;u<a;++u)(o=s[u])&&t.call(o,o.__data__,u,s)&&l.push(o);return new Yn(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,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var l,u=e[a],c=n[a],h=u.length,f=s[a]=new Array(h),d=0;d<h;++d)(l=u[d]||c[d])&&(f[d]=l);for(;a<r;++a)s[a]=e[a];return new Yn(s,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=Vn(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s,a=r[o],l=a.length,u=0;u<l;++u)if(s=a[u]){var c=xn(s,e);vn(s,t,n,u,a,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Yn(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,o=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)?yn:bn;return function(){var s=o(this,t),a=s.on;a!==r&&(i=(r=a).copy()).on(e,n),s.on=i}}(n,t,e))},attr:function(t,e){var n=D(t),r="transform"===n?Ze:En;return this.attrTween(t,"function"==typeof e?(n.local?Dn:zn)(n,r,Tn(this,"attr."+t,e)):null==e?(n.local?kn:An)(n):(n.local?Cn:Sn)(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?$n:Pn)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Xe:En;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var o=ct(this,t),s=(this.style.removeProperty(t),ct(this,t));return o===s?null:o===n&&s===r?i:i=e(n=o,r=s)}}(t,r)).on("end.style."+t,jn(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,o;return function(){var s=ct(this,t),a=n(this),l=a+"";return null==a&&(this.style.removeProperty(t),l=a=ct(this,t)),s===l?null:s===r&&l===i?o:(i=l,o=e(r=s,a))}}(t,r,Tn(this,"style."+t,e))).each(function(t,e){var n,r,i,o,s="style."+e,a="end."+s;return function(){var l=bn(this,t),u=l.on,c=null==l.value[s]?o||(o=jn(e)):void 0;u===n&&i===c||(r=(n=u).copy()).on(a,i=c),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,o=n+"";return function(){var s=ct(this,t);return s===o?null:s===r?i:i=e(r=s,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 o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,o,n)),r}return o._value=e,o}(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,o=0,s=i.length;o<s;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==e?Nn:Mn)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?On:In)(e,t)):xn(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Ln:Un)(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(){bn(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;bn(this,t).ease=n}}(this._id,t))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,s){var a={value:s},l={value:function(){0===--i&&o()}};n.each(function(){var n=bn(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),n.on=e}),0===i&&o()})},[Symbol.iterator]:Bn[Symbol.iterator]};var Rn={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function qn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}Ht.prototype.interrupt=function(t){return this.each(function(){wn(this,t)})},Ht.prototype.transition=function(t){var e,n;t instanceof Yn?(e=t._id,t=t._name):(e=Vn(),(n=Rn).time=ln(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s,a=r[o],l=a.length,u=0;u<l;++u)(s=a[u])&&vn(s,t,e,u,a,n||qn(s,e));return new Yn(r,this._parents,t,e)};var Xn=t=>()=>t;function Zn(t,{sourceEvent:e,target:n,selection:r,mode:i,dispatch:o}){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:o}})}function Wn(t){t.preventDefault(),t.stopImmediatePropagation()}var Gn={name:"drag"},Kn={name:"space"},Jn={name:"handle"},Qn={name:"center"};const{abs:tr,max:er,min:nr}=Math;function rr(t){return[+t[0],+t[1]]}function ir(t){return[rr(t[0]),rr(t[1])]}var or={name:"x",handles:["w","e"].map(dr),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(dr),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]]}},ar={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(dr),input:function(t){return null==t?null:ir(t)},output:function(t){return t}},lr={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"},ur={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},cr={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},hr={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},fr={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function dr(t){return{type:t}}function pr(t){return!t.ctrlKey&&!t.button}function _r(){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 gr(){return navigator.maxTouchPoints||"ontouchstart"in this}function mr(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function vr(){return function(t){var e,n=_r,r=pr,i=gr,o=!0,s=E("start","brush","end"),a=6;function l(e){var n=e.property("__brush",_).selectAll(".overlay").data([dr("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",lr.overlay).merge(n).each(function(){var t=mr(this).extent;Yt(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([dr("selection")]).enter().append("rect").attr("class","selection").attr("cursor",lr.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 lr[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=Yt(this),e=mr(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]-a/2:e[0][0]-a/2}).attr("y",function(t){return"s"===t.type[0]?e[1][1]-a/2:e[0][1]-a/2}).attr("width",function(t){return"n"===t.type||"s"===t.type?e[1][0]-e[0][0]+a:a}).attr("height",function(t){return"e"===t.type||"w"===t.type?e[1][1]-e[0][1]+a:a})):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,s,a,l,h,f,d,p,_,g,m,v=this,y=n.target.__data__.type,b="selection"===(o&&n.metaKey?y="overlay":y)?Gn:o&&n.altKey?Qn:Jn,x=t===sr?null:hr[y],w=t===or?null:fr[y],N=mr(v),M=N.extent,T=N.selection,E=M[0][0],A=M[0][1],k=M[1][0],S=M[1][1],C=0,z=0,D=x&&w&&o&&n.shiftKey,$=Array.from(n.touches||[n],t=>{const e=t.identifier;return(t=Vt(t,v)).point0=t.slice(),t.identifier=e,t});wn(v);var P=c(v,arguments,!0).beforestart();if("overlay"===y){T&&(_=!0);const e=[$[0],$[1]||$[0]];N.selection=T=[[i=t===sr?E:nr(e[0][0],e[1][0]),a=t===or?A:nr(e[0][1],e[1][1])],[h=t===sr?k:er(e[0][0],e[1][0]),d=t===or?S:er(e[0][1],e[1][1])]],$.length>1&&F(n)}else i=T[0][0],a=T[0][1],h=T[1][0],d=T[1][1];s=i,l=a,f=h,p=d;var O=Yt(v).attr("pointer-events","none"),I=O.selectAll(".overlay").attr("cursor",lr[y]);if(n.touches)P.moved=U,P.ended=j;else{var L=Yt(n.view).on("mousemove.brush",U,!0).on("mouseup.brush",j,!0);o&&L.on("keydown.brush",H,!0).on("keyup.brush",Y,!0),qt(n.view)}u.call(v),P.start(n,b.name)}function U(t){for(const e of t.changedTouches||[t])for(const t of $)t.identifier===e.identifier&&(t.cur=Vt(e,v));if(D&&!g&&!m&&1===$.length){const t=$[0];tr(t.cur[0]-t[0])>tr(t.cur[1]-t[1])?m=!0:g=!0}for(const t of $)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);_=!0,Wn(t),F(t)}function F(t){const e=$[0],n=e.point0;var r;switch(C=e[0]-n[0],z=e[1]-n[1],b){case Kn:case Gn:x&&(C=er(E-i,nr(k-h,C)),s=i+C,f=h+C),w&&(z=er(A-a,nr(S-d,z)),l=a+z,p=d+z);break;case Jn:$[1]?(x&&(s=er(E,nr(k,$[0][0])),f=er(E,nr(k,$[1][0])),x=1),w&&(l=er(A,nr(S,$[0][1])),p=er(A,nr(S,$[1][1])),w=1)):(x<0?(C=er(E-i,nr(k-i,C)),s=i+C,f=h):x>0&&(C=er(E-h,nr(k-h,C)),s=i,f=h+C),w<0?(z=er(A-a,nr(S-a,z)),l=a+z,p=d):w>0&&(z=er(A-d,nr(S-d,z)),l=a,p=d+z));break;case Qn:x&&(s=er(E,nr(k,i-C*x)),f=er(E,nr(k,h+C*x))),w&&(l=er(A,nr(S,a-z*w)),p=er(A,nr(S,d+z*w)))}f<s&&(x*=-1,r=i,i=h,h=r,r=s,s=f,f=r,y in ur&&I.attr("cursor",lr[y=ur[y]])),p<l&&(w*=-1,r=a,a=d,d=r,r=l,l=p,p=r,y in cr&&I.attr("cursor",lr[y=cr[y]])),N.selection&&(T=N.selection),g&&(s=T[0][0],f=T[1][0]),m&&(l=T[0][1],p=T[1][1]),T[0][0]===s&&T[0][1]===l&&T[1][0]===f&&T[1][1]===p||(N.selection=[[s,l],[f,p]],u.call(v),P.brush(t,b.name))}function j(t){if(function(t){t.stopImmediatePropagation()}(t),t.touches){if(t.touches.length)return;e&&clearTimeout(e),e=setTimeout(function(){e=null},500)}else Xt(t.view,_),L.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);O.attr("pointer-events","all"),I.attr("cursor",lr.overlay),N.selection&&(T=N.selection),function(t){return t[0][0]===t[1][0]||t[0][1]===t[1][1]}(T)&&(N.selection=null,u.call(v)),P.end(t,b.name)}function H(t){switch(t.keyCode){case 16:D=x&&w;break;case 18:b===Jn&&(x&&(h=f-C*x,i=s+C*x),w&&(d=p-z*w,a=l+z*w),b=Qn,F(t));break;case 32:b!==Jn&&b!==Qn||(x<0?h=f-C:x>0&&(i=s-C),w<0?d=p-z:w>0&&(a=l-z),b=Kn,I.attr("cursor",lr.selection),F(t));break;default:return}Wn(t)}function Y(t){switch(t.keyCode){case 16:D&&(g=m=D=!1,F(t));break;case 18:b===Qn&&(x<0?h=f:x>0&&(i=s),w<0?d=p:w>0&&(a=l),b=Jn,F(t));break;case 32:b===Kn&&(t.altKey?(x&&(h=f-C*x,i=s+C*x),w&&(d=p-z*w,a=l+z*w),b=Qn):(x<0?h=f:x>0&&(i=s),w<0?d=p:w>0&&(a=l),b=Jn),I.attr("cursor",lr[y]),F(t));break;default:return}Wn(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=ir(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),o=r.selection,s=t.input("function"==typeof n?n.apply(this,arguments):n,r.extent),a=je(o,s);function l(t){r.selection=1===t&&null===s?null:a(t),u.call(e),i.brush()}return null!==o&&null!==s?l:l(1)}):e.each(function(){var e=this,i=arguments,o=e.__brush,s=t.input("function"==typeof n?n.apply(e,i):n,o.extent),a=c(e,i).beforestart();wn(e),o.selection=null===s?null:s,u.call(e),a.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=Yt(this.that).datum();s.call(e,this.that,new Zn(e,{sourceEvent:n,target:l,selection:t.output(this.state.selection),mode:r,dispatch:s}),i)}},l.extent=function(t){return arguments.length?(n="function"==typeof t?t:Xn(ir(t)),l):n},l.filter=function(t){return arguments.length?(r="function"==typeof t?t:Xn(!!t),l):r},l.touchable=function(t){return arguments.length?(i="function"==typeof t?t:Xn(!!t),l):i},l.handleSize=function(t){return arguments.length?(a=+t,l):a},l.keyModifiers=function(t){return arguments.length?(o=!!t,l):o},l.on=function(){var t=s.on.apply(s,arguments);return t===s?l:t},l}(ar)}const yr=Math.PI,br=2*yr,xr=1e-6,wr=br-xr;function Nr(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}class Mr{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,o){this._append`C${+t},${+e},${+n},${+r},${this._x1=+i},${this._y1=+o}`}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 o=this._x1,s=this._y1,a=n-t,l=r-e,u=o-t,c=s-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*a-l*u)>xr&&i){let f=n-o,d=r-s,p=a*a+l*l,_=f*f+d*d,g=Math.sqrt(p),m=Math.sqrt(h),v=i*Math.tan((yr-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*a},${this._y1=e+b*l}`}else this._append`L${this._x1=t},${this._y1=e}`;else;}arc(t,e,n,r,i,o){if(t=+t,e=+e,o=!!o,(n=+n)<0)throw new Error(`negative radius: ${n}`);let s=n*Math.cos(r),a=n*Math.sin(r),l=t+s,u=e+a,c=1^o,h=o?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%br+br),h>wr?this._append`A${n},${n},0,1,${c},${t-s},${e-a}A${n},${n},0,1,${c},${this._x1=l},${this._y1=u}`:h>xr&&this._append`A${n},${n},0,${+(h>=yr)},${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 Er(t){return(t=Tr(Math.abs(t)))?t[1]:NaN}var Ar,kr=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Sr(t){if(!(e=kr.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 zr(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")}Sr.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)=>zr(100*t,e),r:zr,s:function(t,e){var n=Tr(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(Ar=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,s=r.length;return o===s?r:o>s?r+new Array(o-s+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Tr(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function $r(t){return t}var Pr,Or,Ir,Lr=Array.prototype.map,Ur=["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?$r:(e=Lr.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,o=[],s=0,a=e[0],l=0;i>0&&a>0&&(l+a+1>r&&(a=Math.max(1,r-l)),o.push(t.substring(i-=a,i+a)),!((l+=a+1)>r));)a=e[s=(s+1)%e.length];return o.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",s=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?$r:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}}(Lr.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=Sr(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?o:/[%p]/.test(v)?l:"",x=Dr[v],w=/[defgprs%]/.test(v);function N(t){var i,o,l,f=y,N=b;if("c"===v)N=x(t)+N,t="";else{var M=(t=+t)<0||1/t<0;if(t=isNaN(t)?c:x(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)),M&&0===+t&&"+"!==h&&(M=!1),f=(M?"("===h?h:u:"-"===h||"("===h?"":h)+f,N=("s"===v?Ur[8+Ar/3]:"")+N+(M&&"("===h?")":""),w)for(i=-1,o=t.length;++i<o;)if(48>(l=t.charCodeAt(i))||l>57){N=(46===l?s+t.slice(i+1):t.slice(i))+N,t=t.slice(0,i);break}}_&&!d&&(t=r(t,1/0));var T=f.length+t.length+N.length,E=T<p?new Array(p-T+1).join(e):"";switch(_&&d&&(t=r(E+t,E.length?p-N.length:1/0),E=""),n){case"<":t=f+t+N+E;break;case"=":t=f+E+t+N;break;case"^":t=E.slice(0,T=E.length>>1)+f+t+N+E.slice(T);break;default:t=E+f+t+N}return a(t)}return g=void 0===g?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),N.toString=function(){return t+""},N}return{format:h,formatPrefix:function(t,e){var n=h(((t=Sr(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Er(e)/3))),i=Math.pow(10,-r),o=Ur[8+r/3];return function(t){return n(i*t)+o}}}}function jr(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 Hr(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=Vr)):void 0===e&&(e=Yr);for(var n,r,i,o,s,a=new qr(t),l=[a];n=l.pop();)if((i=e(n.data))&&(s=(i=Array.from(i)).length))for(n.children=i,o=s-1;o>=0;--o)l.push(r=i[o]=new qr(i[o])),r.parent=n,r.depth=n.depth+1;return a.eachBefore(Rr)}function Yr(t){return t.children}function Vr(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 Rr(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function qr(t){this.data=t,this.depth=this.height=0,this.parent=null}function Xr(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}Pr=Fr({thousands:",",grouping:[3],currency:["$",""]}),Or=Pr.format,Ir=Pr.formatPrefix,qr.prototype=Hr.prototype={constructor:qr,count:function(){return this.eachAfter(jr)},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,o=this,s=[o],a=[],l=-1;o=s.pop();)if(a.push(o),n=o.children)for(r=0,i=n.length;r<i;++r)s.push(n[r]);for(;o=a.pop();)t.call(e,o,++l,this);return this},eachBefore:function(t,e){for(var n,r,i=this,o=[i],s=-1;i=o.pop();)if(t.call(e,i,++s,this),n=i.children)for(r=n.length-1;r>=0;--r)o.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 Hr(this).eachBefore(Br)},[Symbol.iterator]:function*(){var t,e,n,r,i=this,o=[i];do{for(t=o.reverse(),o=[];i=t.pop();)if(yield i,e=i.children)for(n=0,r=e.length;n<r;++n)o.push(e[n])}while(o.length)}};var Wr=[0,1];function Gr(t){return t}function Kr(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],o=e[0],s=e[1];return i<r?(r=Kr(i,r),o=n(s,o)):(r=Kr(r,i),o=n(o,s)),function(t){return o(r(t))}}function Qr(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=Kr(t[s],t[s+1]),o[s]=n(e[s],e[s+1]);return function(e){var n=h(t,e,1,r)-1;return o[n](i[n](e))}}function ti(){var t,e,n,r,i,o,s=Wr,a=Wr,l=je,u=Gr;function c(){var t,e,n,l=Math.min(s.length,a.length);return u!==Gr&&(t=s[0],e=s[l-1],t>e&&(n=t,t=e,e=n),u=function(n){return Math.max(t,Math.min(e,n))}),r=l>2?Qr:Jr,i=o=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(s.map(t),a,l)))(t(u(e)))}return h.invert=function(n){return u(e((o||(o=r(a,s.map(t),Oe)))(n)))},h.domain=function(t){return arguments.length?(s=Array.from(t,Zr),c()):s.slice()},h.range=function(t){return arguments.length?(a=Array.from(t),c()):a.slice()},h.rangeRound=function(t){return a=Array.from(t),l=He,c()},h.clamp=function(t){return arguments.length?(u=!!t||Gr,c()):u!==Gr},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 ei(t,e,n,r){var i,o=function(t,e,n){n=+n;const r=(e=+e)<(t=+t),i=r?g(e,t,n):g(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}(t,e,n);switch((r=Sr(null==r?",f":r)).type){case"s":var s=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(Er(e)/3)))-Er(Math.abs(t)))}(o,s))||(r.precision=i),Ir(r,s);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,Er(e)-Er(t))+1}(o,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,-Er(Math.abs(t)))}(o))||(r.precision=i-2*("%"===r.type))}return Or(r)}function ni(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,o,s]=r?_(e,t,n):_(t,e,n);if(!(o>=i))return[];const a=o-i+1,l=new Array(a);if(r)if(s<0)for(let t=0;t<a;++t)l[t]=(o-t)/-s;else for(let t=0;t<a;++t)l[t]=(o-t)*s;else if(s<0)for(let t=0;t<a;++t)l[t]=(i+t)/-s;else for(let t=0;t<a;++t)l[t]=(i+t)*s;return l}(n[0],n[n.length-1],null==t?10:t)},t.tickFormat=function(t,n){var r=e();return ei(r[0],r[r.length-1],null==t?10:t,n)},t.nice=function(n){null==n&&(n=10);var r,i,o=e(),s=0,a=o.length-1,l=o[s],u=o[a],c=10;for(u<l&&(i=l,l=u,u=i,i=s,s=a,a=i);c-- >0;){if((i=g(l,u,n))===r)return o[s]=l,o[a]=u,e(o);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 ri(){var t=ti()(Gr,Gr);return t.copy=function(){return e=t,ri().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},Xr.apply(t,arguments),ni(t)}const ii=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,o)=>{const s=[];if(n=i.ceil(n),o=null==o?1:Math.floor(o),!(n<r&&o>0))return s;let a;do{s.push(a=new Date(+n)),e(n,o),t(n)}while(a<n&&n<r);return s},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)=>(ii.setTime(+e),oi.setTime(+r),t(ii),t(oi),Math.floor(n(ii,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 ai=6e4,li=864e5,ui=6048e5,ci=si(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ai)/li,t=>t.getDate()-1);ci.range;const hi=si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/li,t=>t.getUTCDate()-1);hi.range;const fi=si(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/li,t=>Math.floor(t/li));function di(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())*ai)/ui)}fi.range;const pi=di(0),_i=di(1),gi=di(2),mi=di(3),vi=di(4),yi=di(5),bi=di(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)/ui)}pi.range,_i.range,gi.range,mi.range,vi.range,yi.range,bi.range;const wi=xi(0),Ni=xi(1),Mi=xi(2),Ti=xi(3),Ei=xi(4),Ai=xi(5),ki=xi(6);wi.range,Ni.range,Mi.range,Ti.range,Ei.range,Ai.range,ki.range;const Si=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());Si.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,Si.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 zi(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 $i(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 Pi,Oi,Ii={"-":"",_:" ",0:"0"},Li=/^\s*\d+/,Ui=/^%/,Fi=/[\\^$*+?|[\]().{}]/g;function ji(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<n?new Array(n-o+1).join(e)+i:i)}function Hi(t){return t.replace(Fi,"\\$&")}function Yi(t){return new RegExp("^(?:"+t.map(Hi).join("|")+")","i")}function Vi(t){return new Map(t.map((t,e)=>[t.toLowerCase(),e]))}function Bi(t,e,n){var r=Li.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Ri(t,e,n){var r=Li.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function qi(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Xi(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Zi(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function Wi(t,e,n){var r=Li.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function Gi(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Ki(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=Li.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1}function Qi(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function to(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function eo(t,e,n){var r=Li.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function no(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function ro(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function io(t,e,n){var r=Li.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function oo(t,e,n){var r=Li.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function so(t,e,n){var r=Li.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function ao(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function lo(t,e,n){var r=Li.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function uo(t,e,n){var r=Li.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function co(t,e){return ji(t.getDate(),e,2)}function ho(t,e){return ji(t.getHours(),e,2)}function fo(t,e){return ji(t.getHours()%12||12,e,2)}function po(t,e){return ji(1+ci.count(Si(t),t),e,3)}function _o(t,e){return ji(t.getMilliseconds(),e,3)}function go(t,e){return _o(t,e)+"000"}function mo(t,e){return ji(t.getMonth()+1,e,2)}function vo(t,e){return ji(t.getMinutes(),e,2)}function yo(t,e){return ji(t.getSeconds(),e,2)}function bo(t){var e=t.getDay();return 0===e?7:e}function xo(t,e){return ji(pi.count(Si(t)-1,t),e,2)}function wo(t){var e=t.getDay();return e>=4||0===e?vi(t):vi.ceil(t)}function No(t,e){return t=wo(t),ji(vi.count(Si(t),t)+(4===Si(t).getDay()),e,2)}function Mo(t){return t.getDay()}function To(t,e){return ji(_i.count(Si(t)-1,t),e,2)}function Eo(t,e){return ji(t.getFullYear()%100,e,2)}function Ao(t,e){return ji((t=wo(t)).getFullYear()%100,e,2)}function ko(t,e){return ji(t.getFullYear()%1e4,e,4)}function So(t,e){var n=t.getDay();return ji((t=n>=4||0===n?vi(t):vi.ceil(t)).getFullYear()%1e4,e,4)}function Co(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+ji(e/60|0,"0",2)+ji(e%60,"0",2)}function zo(t,e){return ji(t.getUTCDate(),e,2)}function Do(t,e){return ji(t.getUTCHours(),e,2)}function $o(t,e){return ji(t.getUTCHours()%12||12,e,2)}function Po(t,e){return ji(1+hi.count(Ci(t),t),e,3)}function Oo(t,e){return ji(t.getUTCMilliseconds(),e,3)}function Io(t,e){return Oo(t,e)+"000"}function Lo(t,e){return ji(t.getUTCMonth()+1,e,2)}function Uo(t,e){return ji(t.getUTCMinutes(),e,2)}function Fo(t,e){return ji(t.getUTCSeconds(),e,2)}function jo(t){var e=t.getUTCDay();return 0===e?7:e}function Ho(t,e){return ji(wi.count(Ci(t)-1,t),e,2)}function Yo(t){var e=t.getUTCDay();return e>=4||0===e?Ei(t):Ei.ceil(t)}function Vo(t,e){return t=Yo(t),ji(Ei.count(Ci(t),t)+(4===Ci(t).getUTCDay()),e,2)}function Bo(t){return t.getUTCDay()}function Ro(t,e){return ji(Ni.count(Ci(t)-1,t),e,2)}function qo(t,e){return ji(t.getUTCFullYear()%100,e,2)}function Xo(t,e){return ji((t=Yo(t)).getUTCFullYear()%100,e,2)}function Zo(t,e){return ji(t.getUTCFullYear()%1e4,e,4)}function Wo(t,e){var n=t.getUTCDay();return ji((t=n>=4||0===n?Ei(t):Ei.ceil(t)).getUTCFullYear()%1e4,e,4)}function Go(){return"+0000"}function Ko(){return"%"}function Jo(t){return+t}function Qo(t){return Math.floor(+t/1e3)}function ts(t){return function(){return t}}function es(t){this._context=t}function ns(t){return new es(t)}function rs(t){return t[0]}function is(t){return t[1]}function os(t,e){var n=ts(!0),r=null,i=ns,o=null,s=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 Mr(e)}(a);function a(a){var l,u,c,h=(a=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(a)).length,f=!1;for(null==r&&(o=i(c=s())),l=0;l<=h;++l)!(l<h&&n(u=a[l],l,a))===f&&((f=!f)?o.lineStart():o.lineEnd()),f&&o.point(+t(u,l,a),+e(u,l,a));if(c)return o=null,c+""||null}return t="function"==typeof t?t:void 0===t?rs:ts(t),e="function"==typeof e?e:void 0===e?is:ts(e),a.x=function(e){return arguments.length?(t="function"==typeof e?e:ts(+e),a):t},a.y=function(t){return arguments.length?(e="function"==typeof t?t:ts(+t),a):e},a.defined=function(t){return arguments.length?(n="function"==typeof t?t:ts(!!t),a):n},a.curve=function(t){return arguments.length?(i=t,null!=r&&(o=i(r)),a):i},a.context=function(t){return arguments.length?(null==t?r=o=null:o=i(r=t),a):r},a}function ss(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 as(t){this._context=t}function ls(t){return new as(t)}function us(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,o=t.days,s=t.shortDays,a=t.months,l=t.shortMonths,u=Yi(i),c=Vi(i),h=Yi(o),f=Vi(o),d=Yi(s),p=Vi(s),_=Yi(a),g=Vi(a),m=Yi(l),v=Vi(l),y={a:function(t){return s[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return l[t.getMonth()]},B:function(t){return a[t.getMonth()]},c:null,d:co,e:co,f:go,g:Ao,G:So,H:ho,I:fo,j:po,L:_o,m:mo,M:vo,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Jo,s:Qo,S:yo,u:bo,U:xo,V:No,w:Mo,W:To,x:null,X:null,y:Eo,Y:ko,Z:Co,"%":Ko},b={a:function(t){return s[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return l[t.getUTCMonth()]},B:function(t){return a[t.getUTCMonth()]},c:null,d:zo,e:zo,f:Io,g:Xo,G:Wo,H:Do,I:$o,j:Po,L:Oo,m:Lo,M:Uo,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Jo,s:Qo,S:Fo,u:jo,U:Ho,V:Vo,w:Bo,W:Ro,x:null,X:null,y:qo,Y:Zo,Z:Go,"%":Ko},x={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 M(t,e,n,r)},d:to,e:to,f:so,g:Gi,G:Wi,H:no,I:no,j:eo,L:oo,m:Qi,M:ro,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:lo,s:uo,S:io,u:Ri,U:qi,V:Xi,w:Bi,W:Zi,x:function(t,e,r){return M(t,n,e,r)},X:function(t,e,n){return M(t,r,e,n)},y:Gi,Y:Wi,Z:Ki,"%":ao};function w(t,e){return function(n){var r,i,o,s=[],a=-1,l=0,u=t.length;for(n instanceof Date||(n=new Date(+n));++a<u;)37===t.charCodeAt(a)&&(s.push(t.slice(l,a)),null!=(i=Ii[r=t.charAt(++a)])?r=t.charAt(++a):i="e"===r?" ":"0",(o=e[r])&&(r=o(n,i)),s.push(r),l=a+1);return s.push(t.slice(l,a)),s.join("")}}function N(t,e){return function(n){var r,i,o=$i(1900,void 0,1);if(M(o,t,n+="",0)!=n.length)return null;if("Q"in o)return new Date(o.Q);if("s"in o)return new Date(1e3*o.s+("L"in o?o.L:0));if(e&&!("Z"in o)&&(o.Z=0),"p"in o&&(o.H=o.H%12+12*o.p),void 0===o.m&&(o.m="q"in o?o.q:0),"V"in o){if(o.V<1||o.V>53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=Di($i(o.y,0,1))).getUTCDay(),r=i>4||0===i?Ni.ceil(r):Ni(r),r=hi.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=zi($i(o.y,0,1))).getDay(),r=i>4||0===i?_i.ceil(r):_i(r),r=ci.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?Di($i(o.y,0,1)).getUTCDay():zi($i(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,Di(o)):zi(o)}}function M(t,e,n,r){for(var i,o,s=0,a=e.length,l=n.length;s<a;){if(r>=l)return-1;if(37===(i=e.charCodeAt(s++))){if(i=e.charAt(s++),!(o=x[i in Ii?e.charAt(s++):i])||(r=o(t,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}return y.x=w(n,y),y.X=w(r,y),y.c=w(e,y),b.x=w(n,b),b.X=w(r,b),b.c=w(e,b),{format:function(t){var e=w(t+="",y);return e.toString=function(){return t},e},parse:function(t){var e=N(t+="",!1);return e.toString=function(){return t},e},utcFormat:function(t){var e=w(t+="",b);return e.toString=function(){return t},e},utcParse:function(t){var e=N(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"]}),es.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)}}},as.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:ss(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:ss(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}},us.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 cs=t=>()=>t;function hs(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 fs(t,e,n){this.k=t,this.x=e,this.y=n}fs.prototype={constructor:fs,scale:function(t){return 1===t?this:new fs(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new fs(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 ds=new fs(1,0,0);function ps(t){t.stopImmediatePropagation()}function _s(t){t.preventDefault(),t.stopImmediatePropagation()}function gs(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function ms(){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 vs(){return this.__zoom||ds}function ys(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function bs(){return navigator.maxTouchPoints||"ontouchstart"in this}function xs(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],s=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}fs.prototype;const ws=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Ns=new RegExp("^"+("["+ws+"]["+(ws+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040")+"]*")+"$");function Ms(t,e){const n=[];let r=e.exec(t);for(;r;){const i=[];i.startIndex=e.lastIndex-r[0].length;const o=r.length;for(let t=0;t<o;t++)i.push(r[t]);n.push(i),r=e.exec(t)}return n}const Ts=function(t){const e=Ns.exec(t);return!(null==e)};const Es={allowBooleanAttributes:!1,unpairedTags:[]};function As(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function ks(t,e){const n=e;for(;e<t.length;e++)if("?"==t[e]||" "==t[e]){const r=t.substr(n,e-n);if(e>5&&"xml"===r)return Is("InvalidXml","XML declaration allowed only at the start of the document.",Fs(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}continue}return e}function Ss(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){let n=1;for(e+=8;e<t.length;e++)if("<"===t[e])n++;else if(">"===t[e]&&(n--,0===n))break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}const Cs='"',zs="'";function Ds(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===Cs||t[e]===zs)""===r?r=t[e]:r!==t[e]||(r="");else if(">"===t[e]&&""===r){i=!0;break}n+=t[e]}return""===r&&{value:n,index:e,tagClosed:i}}const $s=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Ps(t,e){const n=Ms(t,$s),r={};for(let t=0;t<n.length;t++){if(0===n[t][1].length)return Is("InvalidAttr","Attribute '"+n[t][2]+"' has no space in starting.",js(n[t]));if(void 0!==n[t][3]&&void 0===n[t][4])return Is("InvalidAttr","Attribute '"+n[t][2]+"' is without value.",js(n[t]));if(void 0===n[t][3]&&!e.allowBooleanAttributes)return Is("InvalidAttr","boolean attribute '"+n[t][2]+"' is not allowed.",js(n[t]));const i=n[t][2];if(!Ls(i))return Is("InvalidAttr","Attribute '"+i+"' is an invalid name.",js(n[t]));if(r.hasOwnProperty(i))return Is("InvalidAttr","Attribute '"+i+"' is repeated.",js(n[t]));r[i]=1}return!0}function Os(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){let n=/\d/;for("x"===t[e]&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(n))break}return-1}(t,++e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(";"===t[e])break;return-1}return e}function Is(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function Ls(t){return Ts(t)}function Us(t){return Ts(t)}function Fs(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function js(t){return t.startIndex+t[1].length}const Hs={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t},captureMetaData:!1};let Ys;Ys="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class Vs{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][Ys]={startIndex:e})}static getMetaDataSymbol(){return Ys}}function Bs(t,e){const n={};if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let r=1,i=!1,o=!1,s="";for(;e<t.length;e++)if("<"!==t[e]||o)if(">"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,r--):r--,0===r)break}else"["===t[e]?i=!0:s+=t[e];else{if(i&&Gs(t,"!ENTITY",e)){let r,i;e+=7,[r,i,e]=qs(t,e+1),-1===i.indexOf("&")&&(n[r]={regx:RegExp(`&${r};`,"g"),val:i})}else if(i&&Gs(t,"!ELEMENT",e)){e+=8;const{index:n}=Ws(t,e+1);e=n}else if(i&&Gs(t,"!ATTLIST",e))e+=8;else if(i&&Gs(t,"!NOTATION",e)){e+=9;const{index:n}=Xs(t,e+1);e=n}else{if(!Gs(t,"!--",e))throw new Error("Invalid DOCTYPE");o=!0}r++,s=""}if(0!==r)throw new Error("Unclosed DOCTYPE")}return{entities:n,i:e}}const Rs=(t,e)=>{for(;e<t.length&&/\s/.test(t[e]);)e++;return e};function qs(t,e){e=Rs(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)n+=t[e],e++;if(Ks(n),e=Rs(t,e),"SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported");let r="";return[e,r]=Zs(t,e,"entity"),[n,r,--e]}function Xs(t,e){e=Rs(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;Ks(n),e=Rs(t,e);const r=t.substring(e,e+6).toUpperCase();if("SYSTEM"!==r&&"PUBLIC"!==r)throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);e+=r.length,e=Rs(t,e);let i=null,o=null;if("PUBLIC"===r)[e,i]=Zs(t,e,"publicIdentifier"),'"'!==t[e=Rs(t,e)]&&"'"!==t[e]||([e,o]=Zs(t,e,"systemIdentifier"));else if("SYSTEM"===r&&([e,o]=Zs(t,e,"systemIdentifier"),!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:i,systemIdentifier:o,index:--e}}function Zs(t,e,n){let r="";const i=t[e];if('"'!==i&&"'"!==i)throw new Error(`Expected quoted string, found "${i}"`);for(e++;e<t.length&&t[e]!==i;)r+=t[e],e++;if(t[e]!==i)throw new Error(`Unterminated ${n} value`);return[++e,r]}function Ws(t,e){e=Rs(t,e);let n="";for(;e<t.length&&!/\s/.test(t[e]);)n+=t[e],e++;if(!Ks(n))throw new Error(`Invalid element name: "${n}"`);let r="";if("E"===t[e=Rs(t,e)]&&Gs(t,"MPTY",e))e+=4;else if("A"===t[e]&&Gs(t,"NY",e))e+=2;else{if("("!==t[e])throw new Error(`Invalid Element Expression, found "${t[e]}"`);for(e++;e<t.length&&")"!==t[e];)r+=t[e],e++;if(")"!==t[e])throw new Error("Unterminated content model")}return{elementName:n,contentModel:r.trim(),index:e}}function Gs(t,e,n){for(let r=0;r<e.length;r++)if(e[r]!==t[n+r+1])return!1;return!0}function Ks(t){if(Ts(t))return t;throw new Error(`Invalid entity name ${t}`)}const Js=/^[-+]?0x[a-fA-F0-9]+$/,Qs=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,ta={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function ea(t,e={}){if(e=Object.assign({},ta,e),!t||"string"!=typeof t)return t;let n=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(n))return t;if("0"===t)return 0;if(e.hex&&Js.test(n))return function(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(n,16);if(-1!==n.search(/.+[eE].+/))return function(t,e,n){if(!n.eNotation)return t;const r=e.match(na);if(r){let i=r[1]||"";const o=-1===r[3].indexOf("e")?"E":"e",s=r[2],a=i?t[s.length+1]===o:t[s.length]===o;return s.length>1&&a?t:1!==s.length||!r[3].startsWith(`.${o}`)&&r[3][0]!==o?n.leadingZeros&&!a?(e=(r[1]||"")+r[3],Number(e)):t:Number(e)}return t}(t,n,e);{const r=Qs.exec(n);if(r){const i=r[1]||"",o=r[2];let s=function(t){if(t&&-1!==t.indexOf("."))return"."===(t=t.replace(/0+$/,""))?t="0":"."===t[0]?t="0"+t:"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),t;return t}(r[3]);const a=i?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!a))return t;{const r=Number(n),a=String(r);if(0===r)return r;if(-1!==a.search(/[eE]/))return e.eNotation?r:t;if(-1!==n.indexOf("."))return"0"===a||a===s||a===`${i}${s}`?r:t;let l=o?s:n;return o?l===a||i+l===a?r:t:l===a||l===i+a?r:t}}return t}}const na=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;class ra{constructor(t){var e;this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,e)=>String.fromCodePoint(Number.parseInt(e,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,e)=>String.fromCodePoint(Number.parseInt(e,16))}},this.addExternalEntities=ia,this.parseXml=ua,this.parseTextData=oa,this.resolveNameSpace=sa,this.buildAttributesMap=la,this.isItStopNode=da,this.replaceEntitiesValue=ha,this.readStopNodeData=ga,this.saveTextToParentTag=fa,this.addChild=ca,this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const n of e){if("string"==typeof n&&t===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}}:()=>!1}}function ia(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function oa(t,e,n,r,i,o,s){if(void 0!==t&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t));const r=this.options.tagValueProcessor(e,t,n,i,o);if(null==r)return t;if(typeof r!=typeof t||r!==t)return r;if(this.options.trimValues)return ma(t,this.options.parseTagValue,this.options.numberParseOptions);return t.trim()===t?ma(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function sa(t){if(this.options.removeNSPrefix){const e=t.split(":"),n="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=n+e[1])}return t}const aa=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function la(t,e,n){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){const n=Ms(t,aa),r=n.length,i={};for(let t=0;t<r;t++){const r=this.resolveNameSpace(n[t][1]);if(this.ignoreAttributesFn(r,e))continue;let o=n[t][4],s=this.options.attributeNamePrefix+r;if(r.length)if(this.options.transformAttributeName&&(s=this.options.transformAttributeName(s)),"__proto__"===s&&(s="#__proto__"),void 0!==o){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);const t=this.options.attributeValueProcessor(r,o,e);i[s]=null==t?o:typeof t!=typeof o||t!==o?t:ma(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(i[s]=!0)}if(!Object.keys(i).length)return;if(this.options.attributesGroupName){const t={};return t[this.options.attributesGroupName]=i,t}return i}}const ua=function(t){t=t.replace(/\r\n?/g,"\n");const e=new Vs("!xml");let n=e,r="",i="";for(let o=0;o<t.length;o++){if("<"===t[o])if("/"===t[o+1]){const e=pa(t,">",o,"Closing Tag is not closed.");let s=t.substring(o+2,e).trim();if(this.options.removeNSPrefix){const t=s.indexOf(":");-1!==t&&(s=s.substr(t+1))}this.options.transformTagName&&(s=this.options.transformTagName(s)),n&&(r=this.saveTextToParentTag(r,n,i));const a=i.substring(i.lastIndexOf(".")+1);if(s&&-1!==this.options.unpairedTags.indexOf(s))throw new Error(`Unpaired tag can not be used as closing tag: </${s}>`);let l=0;a&&-1!==this.options.unpairedTags.indexOf(a)?(l=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):l=i.lastIndexOf("."),i=i.substring(0,l),n=this.tagsNodeStack.pop(),r="",o=e}else if("?"===t[o+1]){let e=_a(t,o,!1,"?>");if(!e)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),this.options.ignoreDeclaration&&"?xml"===e.tagName||this.options.ignorePiTags);else{const t=new Vs(e.tagName);t.add(this.options.textNodeName,""),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[":@"]=this.buildAttributesMap(e.tagExp,i,e.tagName)),this.addChild(n,t,i,o)}o=e.closeIndex+1}else if("!--"===t.substr(o+1,3)){const e=pa(t,"--\x3e",o+4,"Comment is not closed.");if(this.options.commentPropName){const s=t.substring(o+4,e-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:s}])}o=e}else if("!D"===t.substr(o+1,2)){const e=Bs(t,o);this.docTypeEntities=e.entities,o=e.i}else if("!["===t.substr(o+1,2)){const e=pa(t,"]]>",o,"CDATA is not closed.")-2,s=t.substring(o+9,e);r=this.saveTextToParentTag(r,n,i);let a=this.parseTextData(s,n.tagname,i,!0,!1,!0,!0);null==a&&(a=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:s}]):n.add(this.options.textNodeName,a),o=e+2}else{let s=_a(t,o,this.options.removeNSPrefix),a=s.tagName;const l=s.rawTagName;let u=s.tagExp,c=s.attrExpPresent,h=s.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&r&&"!xml"!==n.tagname&&(r=this.saveTextToParentTag(r,n,i,!1));const f=n;f&&-1!==this.options.unpairedTags.indexOf(f.tagname)&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),a!==e.tagname&&(i+=i?"."+a:a);const d=o;if(this.isItStopNode(this.options.stopNodes,i,a)){let e="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)"/"===a[a.length-1]?(a=a.substr(0,a.length-1),i=i.substr(0,i.length-1),u=a):u=u.substr(0,u.length-1),o=s.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(a))o=s.closeIndex;else{const n=this.readStopNodeData(t,l,h+1);if(!n)throw new Error(`Unexpected end of ${l}`);o=n.i,e=n.tagContent}const r=new Vs(a);a!==u&&c&&(r[":@"]=this.buildAttributesMap(u,i,a)),e&&(e=this.parseTextData(e,a,i,!0,c,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),r.add(this.options.textNodeName,e),this.addChild(n,r,i,d)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){"/"===a[a.length-1]?(a=a.substr(0,a.length-1),i=i.substr(0,i.length-1),u=a):u=u.substr(0,u.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));const t=new Vs(a);a!==u&&c&&(t[":@"]=this.buildAttributesMap(u,i,a)),this.addChild(n,t,i,d),i=i.substr(0,i.lastIndexOf("."))}else{const t=new Vs(a);this.tagsNodeStack.push(n),a!==u&&c&&(t[":@"]=this.buildAttributesMap(u,i,a)),this.addChild(n,t,i,d),n=t}r="",o=h}}else r+=t[o]}return e.child};function ca(t,e,n,r){this.options.captureMetaData||(r=void 0);const i=this.options.updateTag(e.tagname,n,e[":@"]);!1===i||("string"==typeof i?(e.tagname=i,t.addChild(e,r)):t.addChild(e,r))}const ha=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const n=this.docTypeEntities[e];t=t.replace(n.regx,n.val)}for(let e in this.lastEntities){const n=this.lastEntities[e];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const n=this.htmlEntities[e];t=t.replace(n.regex,n.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function fa(t,e,n,r){return t&&(void 0===r&&(r=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,n,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,r))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function da(t,e,n){const r="*."+n;for(const n in t){const i=t[n];if(r===i||e===i)return!0}return!1}function pa(t,e,n,r){const i=t.indexOf(e,n);if(-1===i)throw new Error(r);return i+e.length-1}function _a(t,e,n,r=">"){const i=function(t,e,n=">"){let r,i="";for(let o=e;o<t.length;o++){let e=t[o];if(r)e===r&&(r="");else if('"'===e||"'"===e)r=e;else if(e===n[0]){if(!n[1])return{data:i,index:o};if(t[o+1]===n[1])return{data:i,index:o}}else"\t"===e&&(e=" ");i+=e}}(t,e+1,r);if(!i)return;let o=i.data;const s=i.index,a=o.search(/\s/);let l=o,u=!0;-1!==a&&(l=o.substring(0,a),o=o.substring(a+1).trimStart());const c=l;if(n){const t=l.indexOf(":");-1!==t&&(l=l.substr(t+1),u=l!==i.data.substr(t+1))}return{tagName:l,tagExp:o,closeIndex:s,attrExpPresent:u,rawTagName:c}}function ga(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if("<"===t[n])if("/"===t[n+1]){const o=pa(t,">",n,`${e} is not closed`);if(t.substring(n+2,o).trim()===e&&(i--,0===i))return{tagContent:t.substring(r,n),i:o};n=o}else if("?"===t[n+1]){n=pa(t,"?>",n+1,"StopNode is not closed.")}else if("!--"===t.substr(n+1,3)){n=pa(t,"--\x3e",n+3,"StopNode is not closed.")}else if("!["===t.substr(n+1,2)){n=pa(t,"]]>",n,"StopNode is not closed.")-2}else{const r=_a(t,n,">");if(r){(r&&r.tagName)===e&&"/"!==r.tagExp[r.tagExp.length-1]&&i++,n=r.closeIndex}}}function ma(t,e,n){if(e&&"string"==typeof t){const e=t.trim();return"true"===e||"false"!==e&&ea(t,n)}return void 0!==t?t:""}const va=Vs.getMetaDataSymbol();function ya(t,e){return ba(t,e)}function ba(t,e,n){let r;const i={};for(let o=0;o<t.length;o++){const s=t[o],a=xa(s);let l="";if(l=void 0===n?a:n+"."+a,a===e.textNodeName)void 0===r?r=s[a]:r+=""+s[a];else{if(void 0===a)continue;if(s[a]){let t=ba(s[a],e,l);const n=Na(t,e);void 0!==s[va]&&(t[va]=s[va]),s[":@"]?wa(t,s[":@"],l,e):1!==Object.keys(t).length||void 0===t[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(t).length&&(e.alwaysCreateTextNode?t[e.textNodeName]="":t=""):t=t[e.textNodeName],void 0!==i[a]&&i.hasOwnProperty(a)?(Array.isArray(i[a])||(i[a]=[i[a]]),i[a].push(t)):e.isArray(a,l,n)?i[a]=[t]:i[a]=t}}}return"string"==typeof r?r.length>0&&(i[e.textNodeName]=r):void 0!==r&&(i[e.textNodeName]=r),i}function xa(t){const e=Object.keys(t);for(let t=0;t<e.length;t++){const n=e[t];if(":@"!==n)return n}}function wa(t,e,n,r){if(e){const i=Object.keys(e),o=i.length;for(let s=0;s<o;s++){const o=i[s];r.isArray(o,n+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}}function Na(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return 0===r||!(1!==r||!t[n]&&"boolean"!=typeof t[n]&&0!==t[n])}class Ma{constructor(t){this.externalEntities={},this.options=function(t){return Object.assign({},Hs,t)}(t)}parse(t,e){if("string"==typeof t);else{if(!t.toString)throw new Error("XML data is accepted in String or Bytes[] form.");t=t.toString()}if(e){!0===e&&(e={});const n=function(t,e){e=Object.assign({},Es,e);const n=[];let r=!1,i=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(let o=0;o<t.length;o++)if("<"===t[o]&&"?"===t[o+1]){if(o+=2,o=ks(t,o),o.err)return o}else{if("<"!==t[o]){if(As(t[o]))continue;return Is("InvalidChar","char '"+t[o]+"' is not expected.",Fs(t,o))}{let s=o;if(o++,"!"===t[o]){o=Ss(t,o);continue}{let a=!1;"/"===t[o]&&(a=!0,o++);let l="";for(;o<t.length&&">"!==t[o]&&" "!==t[o]&&"\t"!==t[o]&&"\n"!==t[o]&&"\r"!==t[o];o++)l+=t[o];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),o--),!Us(l)){let e;return e=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",Is("InvalidTag",e,Fs(t,o))}const u=Ds(t,o);if(!1===u)return Is("InvalidAttr","Attributes for '"+l+"' have open quote.",Fs(t,o));let c=u.value;if(o=u.index,"/"===c[c.length-1]){const n=o-c.length;c=c.substring(0,c.length-1);const i=Ps(c,e);if(!0!==i)return Is(i.err.code,i.err.msg,Fs(t,n+i.err.line));r=!0}else if(a){if(!u.tagClosed)return Is("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Fs(t,o));if(c.trim().length>0)return Is("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Fs(t,s));if(0===n.length)return Is("InvalidTag","Closing tag '"+l+"' has not been opened.",Fs(t,s));{const e=n.pop();if(l!==e.tagName){let n=Fs(t,e.tagStartPos);return Is("InvalidTag","Expected closing tag '"+e.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+l+"'.",Fs(t,s))}0==n.length&&(i=!0)}}else{const a=Ps(c,e);if(!0!==a)return Is(a.err.code,a.err.msg,Fs(t,o-c.length+a.err.line));if(!0===i)return Is("InvalidXml","Multiple possible root nodes found.",Fs(t,o));-1!==e.unpairedTags.indexOf(l)||n.push({tagName:l,tagStartPos:s}),r=!0}for(o++;o<t.length;o++)if("<"===t[o]){if("!"===t[o+1]){o++,o=Ss(t,o);continue}if("?"!==t[o+1])break;if(o=ks(t,++o),o.err)return o}else if("&"===t[o]){const e=Os(t,o);if(-1==e)return Is("InvalidChar","char '&' is not expected.",Fs(t,o));o=e}else if(!0===i&&!As(t[o]))return Is("InvalidXml","Extra text at the end",Fs(t,o));"<"===t[o]&&o--}}}return r?1==n.length?Is("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Fs(t,n[0].tagStartPos)):!(n.length>0)||Is("InvalidXml","Invalid '"+JSON.stringify(n.map(t=>t.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Is("InvalidXml","Start tag expected.",1)}(t,e);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const n=new ra(this.options);n.addExternalEntities(this.externalEntities);const r=n.parseXml(t);return this.options.preserveOrder||void 0===r?r:ya(r,this.options)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return Vs.getMetaDataSymbol()}}function Ta(t){return!i.has(t,"children")}function Ea(t,e,n){let r=[];return function i(o){Ta(o)?e&&o!=t&&r.push(o):(n&&o!=t&&r.push(o),o.children.forEach(i))}(t),r}var Aa=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),o={name:n,parent:t.parent,attribute:r?r[2]:null,original_child_order:t.original_child_order},s={name:e,parent:o,attribute:r?r[1]:null,original_child_order:2};o.children=[t,s],t.parent.children[i]=o,t.parent=o,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 i.filter(this.nodes.descendants(),t=>!i.has(t,"children"))},getInternals:function(){return i.filter(this.nodes.descendants(),t=>i.has(t,"children"))},getRootNode:function(){return this.nodes},getNodes:function(){return this.nodes},getNodeByName:function(t){return i.filter(this.nodes.descendants(),e=>e.data.name==t)[0]},assignAttributes:function(t){i.each(this.nodes.descendants(),function(e){e.data&&e.data.name in t&&(e.annotations=t[e.data.name])})},isLeafNode:Ta,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=>{Ta(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:Ea});function ka(t,e={}){const n=/^-?\d+(\.\d+)?$/;let r=e.left_delimiter||"{",i=e.right_delimiter||"}",o=[];function s(){let t=o[o.length-1];"children"in t||(t.children=[]),o.push({name:null}),t.children.push(o[o.length-1]),o[o.length-1].original_child_order=t.children.length}function a(){let t=o.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"};o.push(_);for(var g=/\s/,m=0;m<t.length;m++)try{var v=t[m];switch(u){case 0:"("==v&&(s(),u=1);break;case 1:case 3:if(":"==v)u=3;else if(","==v||")"==v)try{a(),u=1,","==v&&s()}catch(t){return l(m)}else if("("==v){if(c.length>0)return l(m);s()}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!=o.length?l(t.length-1):{json:_,error:null}}function Sa(t,e){let n=this;t||(t=t=>"");let r=[];return t=t||"",function e(i){if(i.notshown)return;if(Ta(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 o=n.branch_length_accessor(i);void 0!==o&&r.push(":"+o)}(e||this.nodes),r.join("")+";"}function Ca(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 o=r.slice(0,n);r=i.map(o.split(";"),t=>t.trim());let s=i.filter(r,t=>t.toUpperCase().startsWith("DIMENSION"));s=s[0].split(" "),s=i.object(i.map(i.rest(s),t=>t.split("=")));let a=i.filter(r,t=>t.toUpperCase().startsWith("FORMAT"));a=a[0].split(" "),a=i.object(i.map(i.rest(a),t=>t.split("="))),a.symbols=i.reject(a.symbols.split(""),t=>'"'==t);let l=i.filter(r,t=>t.toUpperCase().startsWith("MATRIX"));return l=l[0].split("\n"),l=i.object(i.map(i.rest(l),t=>i.compact(t.split(" ")))),l=i.mapObject(l,(t,e)=>"?"==t?a.symbols:Array(t)),{dimensions:s,format:a,matrix:l}}function za(t,e,n){i.each(t.getTips(),t=>{t.data.test=n.matrix[t.data.name]})}function Da(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 o=r.slice(0,n).split("\n");return o=i.filter(o,t=>t.trim().toUpperCase().startsWith("TREE")),ka(o[0])}var $a=Object.freeze({__proto__:null,parseAnnotations:Ca,loadAnnotations:za,default:Da});function Pa(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 o=t.childNodes.item(i),s=o.nodeName;if(void 0===e[s])e[s]=Pa(o);else{if(void 0===e[s].push){var a=e[s];e[s]=[],e[s].push(a)}e[s].push(Pa(o))}}return e}var Oa=function(t,e){var n;if("string"==typeof t)if(DOMParser){t=(new DOMParser).parseFromString(t,"text/xml")}else{t=(new Ma).parse(t)}var r=(t=Pa(t)).phyloxml.phylogeny;return Array.isArray(r)&&(r=r[0],console.warn("PhyloXML files with multiple phylogenies are not currently supported. Only the first phylogeny will be loaded.")),(n=r.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 Ia={nexml:function(t,e){return new Ma({ignoreAttributes:!1,attributeNamePrefix:"",parseAttributeValue:!0}).parse(t)["nex:nexml"].trees.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),o=r>0?r[0].id:e[0].id;return n[o].name="root",t.edge.map(t=>t).forEach(function(t){n[t.source].edges.push(t)}),function t(e,r){if(e.edges){var o=i.pluck(e.edges,"target");e.children=i.values(i.pick(n,o)),e.children.forEach(function(t,n){t.attribute=e.edges[n].length||""}),e.children.forEach(t),e.annotation=""}}(n[o]),n[o]})},phyloxml:Oa,nexus:Da,nwk:ka,nhx:ka,beast:function(t,e){e.left_delimiter="[",e.right_delimiter="]";const n=ka(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 La(t,e,n){let r,i,o,s=[t],a=[];for(;t=s.pop();)if((!n||!n(t))&&(a.push(t),r=t.children,r))for(i=0,o=r.length;i<o;++i)s.push(r[i]);for(;t=a.pop();)e(t);return t}function Ua(t,e,n){let r,i,o=[t];for(;t=o.pop();)if((!n||!n(t))&&(e(t),r=t.children,r))for(i=r.length-1;i>=0;--i)o.push(r[i]);return t}function Fa(t,e,n){let r,i,o,s,a=[t];do{for(r=a.reverse(),a=[];t=r.pop();)if((!n||!n(t))&&(e(t),i=t.children,i))for(o=0,s=i.length;o<s;++o)a.push(i[o])}while(a.length);return t}function ja(t){return La(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 Ha(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 Ya=Object.freeze({__proto__:null,reroot:function(t,e){if(!(t instanceof Hr))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=Hr({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 s=t,a=t.parent,l=i.noop(),u=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl*e;var o;if(l=a.data.__mapped_bl,a.data.__mapped_bl=void 0===t.data.__mapped_bl?void 0:t.data.__mapped_bl-u,t.data.__mapped_bl=u,a.parent){for(r.children.push(a);a.parent;){o=a.children.indexOf(s),a.parent.parent?a.children.splice(o,1,a.parent):a.children.splice(o,1);let t=a.parent.data.__mapped_bl;void 0!==t&&(a.parent.data.__mapped_bl=l,l=t),s=a,a=a.parent}o=a.children.indexOf(s),a.children.splice(o,1)}else o=a.children.indexOf(s),a.children.splice(o,1),l=a.data.__mapped_bl,s=r;if(1==a.children.length)l&&(a.children[0].data.__mapped_bl+=l),s.children=s.children.concat(a.children);else{let e=new Hr({name:"__reroot_top_clade",__mapped_bl:l});i.extendOwn(r.children[0],t),e.data.__mapped_bl=l,e.children=a.children.map(function(t){return t.parent=e,t}),e.parent=s,s.children.push(e)}}if(this.update(r),this.traverse_and_compute(t=>{i.each(t.children,e=>{e.parent=t})},"pre-order"),!i.isUndefined(this.display)){let t=this.display.options;Yt(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(),Yt(n.container).node().appendChild(n.show()),Yt(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 Va(t){return t.y}function Ba(t){return t.x}function Ra(t,e,n){return{x:n+t*Math.sin(e),y:n+t*Math.cos(e)}}function qa(t,e,n,r,i,o){t.radius=e*(t.radius+n),t.angle=2*Math.PI*t.x*i[0]/o[0];let s=Ra(t.radius,t.angle,r);return t.x=s.x,t.y=s.y,t}function Xa(t,e){var n=Ra(e[0].radius,e[0].angle,t),r=Ra(e[0].radius,e[1].angle,t);return"M "+Va(n)+","+Ba(n)+" A "+e[0].radius+","+e[0].radius+" 0,0, "+(e[1].angle>e[0].angle?1:0)+" "+Va(r)+","+Ba(r)+" L "+Va(e[1])+","+Ba(e[1])}function Za(t,e,n){var r=Ra(t.target.radius+(t.source.radius-t.target.radius)*e,t.target.angle,n);return{x:Va(r),y:Ba(r)}}var Wa=os().x(function(t){return Va(t)}).y(function(t){return Ba(t)}).curve(function(t){return new us(t,0)});function Ga(t,e){return{x:Va(t.target)+(Va(t.source)-Va(t.target))*e,y:Ba(t.target)}}function Ka(t){return t.tag||!1}function Ja(t,e){return t[e]||!1}const Qa={"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 tl(t={}){Object.keys(t).forEach(e=>{Qa[e]=t[e]})}function el(t){return arguments.length?(el="string"==typeof t&&"equal"==t?function(t){return 1}:t,this):el}var nl={all:t=>!0,none:t=>!1,"all-leaf-nodes":t=>Ta(t.target),"all-internal-nodes":t=>!Ta(t.target)};var rl=Object.freeze({__proto__:null,css_classes:Qa,initializeCssClasses:tl,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 el},predefined_selecters:nl,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function il(t){return!(t.hidden||t.notshown)}function ol(t){return t.notshown}function sl(t){return t.hasHiddenNodes||!1}function al(t){return t.collapsed||!1}function ll(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 ul(t){return Ta(t=t.data)?t.name||"":this.showInternalName(t)?t.name:""}var cl=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=Yt(t);var r=Ta(e);r&&(t=t.attr("data-node-name",e.data.name));var i=t.selectAll("text").data([e]),o=t.selectAll("line");if(r||this.showInternalName(e)&&!al(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()?(o=o.data([e]),n?o=o.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(o).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)):(o=o.enter().append("line").classed(this.css_classes["branch-tracer"],!0).merge(o).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))):o.remove(),this.options["draw-size-bubbles"]){var s=this.nodeBubbleSize(e);t.selectAll("circle").data([s]).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:s)+.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)Ta(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=Qa[Ta(t)?"node":"internal-node"];return Ka(t)&&(e+=" "+Qa["tagged-node"]),Ja(t,this.selection_attribute_name)&&(e+=" "+Qa["selected-node"]),t.parent||(e+=" "+Qa["root-node"]),(al(t)||sl(t))&&(e+=" "+Qa["collapsed-node"]),e},nodeVisible:il,nodeNotshown:ol,hasHiddenNodes:sl,isNodeCollapsed:al,nodeCssSelectors:ll,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];Ta(r)||Ja(r,this.selection_attribute_name)||(r[this.selection_attribute_name]=t(r.children))}this.modifySelection((t,e)=>(Ta(t.target),t.target[this.selection_attribute_name]))},defNodeLabel:ul,nodeLabel:function(t){return arguments.length?(this._nodeLabel=t||ul,this.update(),this):this._nodeLabel}});function hl(t){return[t.clade].reduce(function(t,e,n,r){return t+"path."+e+(n<r.length-1?",":"")},"")}var fl=Object.freeze({__proto__:null,cladeCssSelectors:hl,updateCollapsedClades:function(t){let e=this.svg.selectAll("."+this.css_classes["tree-container"]);var n=0;let r=e.selectAll(hl(this.css_classes)).data(this.phylotree.nodes.descendants().filter(al),function(t){return t.id||(t.id=++n)}),o=function(){},s=i.noop();this.radial()?(o=os().curve(ls).y(function(t){return t[0]}).x(function(t){return t[1]}),s=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]}):(o=os().y(function(t){return t[0]}).x(function(t){return t[1]}).curve(ls),s=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 o(t.collapsed.map(function(r,i){return s(r,i,t,e,n)}))}).attr("d",function(t){return t.collapsed_clade=o(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=o(t.collapsed)})}});function dl(t){return!(t.target.hidden||t.target.notshown)}function pl(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 _l=Object.freeze({__proto__:null,drawEdge:function(t,e,n){t=(t=Yt(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 o=t.selectAll("title");o.empty()&&(o=t.append("title")),o.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=Qa.branch;return Ka(t)&&(e+=" "+Qa["tagged-branch"]),Ja(t,this.selection_attribute_name)&&(e+=" "+Qa["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+(Ka(e)?1:0)},0),this.countUpdate(this,t,this.countHandler())}},edgeVisible:dl,edgeCssSelectors:pl,placeAlongAnEdge:function(t,e){return this.edge_placer(t,e)}});let gl="phylotree.event";function ml(t){var e=new CustomEvent(gl,{detail:["refresh",t]});document.dispatchEvent(e)}function vl(t,e){var n=new CustomEvent(gl,{detail:["countUpdate",e,t.countHandler()]});document.dispatchEvent(n)}function yl(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 bl(){document.addEventListener(gl,yl,!1)}var xl=Object.freeze({__proto__:null,toggleCollapse:function(t){if(t.collapsed){t.collapsed=!1;let e=function(t){Ta(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("."+Qa["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:ml,countUpdate:vl,d3PhylotreeTriggerLayout:function(t){var e=new CustomEvent(gl,{detail:["layout",t,t.layoutHandler()]});document.dispatchEvent(e)},d3PhylotreeEventListener:yl,d3PhylotreeAddEventListener:bl,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 wl="d3_layout_phylotree_context_menu";function Nl(t,e,n){let r=[];return function i(o){Ta(o)?e&&o!=t&&r.push(o):(n&&o!=t&&r.push(o),o.children.forEach(i))}(t),r}var Ml=Object.freeze({__proto__:null,nodeDropdownMenu:function(t,e,n,r,o){let s=Yt(e).select("#"+wl);if(s.empty()&&(s=Yt(e).append("div").attr("id",wl).attr("class","dropdown-menu").attr("role","menu")),s.selectAll("a").remove(),s.selectAll("h6").remove(),s.selectAll("div").remove(),t){if(!i.some([Boolean(t.menu_items),r.hide,r.selectable,r.collapsible])||!r["show-menu"])return;Ta(t)||(r.collapsible&&(s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(al(t)?"Expand Subtree":"Collapse Subtree").on("click",e=>{s.style("display","none"),this.toggleCollapse(t).update()}),r.selectable&&(s.append("div").attr("class","dropdown-divider"),s.append("h6").attr("class","dropdown-header").text("Toggle selection"))),r.selectable&&(s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All descendant branches").on("click",function(e){s.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0))}),s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All terminal branches").on("click",function(e){s.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!1))}),s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("All internal branches").on("click",function(e){s.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!1,!0))}))),t.parent&&(r.selectable&&(s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Incident branch").on("click",function(e){s.style("display","none"),n.modifySelection([t])}),s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Path to root").on("click",e=>{s.style("display","none"),this.modifySelection(this.phylotree.pathToRoot(t))}),(r.reroot||r.hide)&&s.append("div").attr("class","dropdown-divider")),r.reroot&&s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Reroot on this node").on("click",e=>{s.style("display","none"),this.phylotree.reroot(t),this.update()}),r.hide&&s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Hide this "+(Ta(t)?"node":"subtree")).on("click",e=>{s.style("display","none"),this.modifySelection([t],"notshown",!0,!0).updateHasHiddenNodes().update()})),sl(t)&&s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text("Show all descendant nodes").on("click",function(e){s.style("display","none"),n.modifySelection(n.selectAllDescendants(t,!0,!0),"notshown",!0,!0,"false").updateHasHiddenNodes().update()});var a=[];if("menu_items"in t&&"object"==typeof t.menu_items&&t.menu_items.forEach(function(e){3==e.length&&(e[2]&&!e[2](t)||a.push([e[0],e[1]]))}),a.length){const e=[r.hide,r.selectable,r.collapsible];i.some(e)&&s.append("div").attr("class","dropdown-divider"),a.forEach(function(e){s.append("a").attr("class","dropdown-item").attr("tabindex","-1").text(e[0](t)).on("click",i.partial(e[1],t))})}let l=document.querySelector(e).getBoundingClientRect();s.style("position","absolute").style("left",o.clientX-l.x+12+"px").style("top",o.clientY-l.y+"px").style("display","block")}else s.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,o){if(e=e||this.selection_attribute_name,o=o||"toggle",this.options["restricted-selectable"].length){if(!i.contains(i.keys(nl),t))return;t=nl[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,a=!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,a=!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)})})),a&&(r||ml(this),this.countHandler()&&((s={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),this.countUpdate(this,s,this.countHandler())),n&&this.placenodes()));else{var s,a=!1;"function"==typeof t?this.links.forEach(function(n){let r=t(n);n[e]=n[e]||!1,n[e]!=r&&(n[e]=r,a=!0,n.target[e]=r)}):(t.forEach(function(t){var n;switch(o){case"true":n=!0;break;case"false":n=!1;break;default:n=!t[e]}t[e]!=n&&(t[e]=n,a=!0)}),this.links.forEach(function(t){t[e]=t.target[e]})),a&&(r||ml(this),this.countHandler&&((s={})[e]=this.links.reduce(function(t,n){return t+(n[e]?1:0)},0),vl(this,s,this.countHandler)),n&&this.placenodes())}return this._selectionCallback&&"tag"!=e&&this._selectionCallback(this.getSelection()),this.refresh(),this.update(),this},getSelection:function(){return Nl(this.phylotree.getRootNode(),!0,!0).filter(t=>t[this.selection_attribute_name])},selectAllDescendants:Nl,selectionCallback:function(t){return t?(this._selectionCallback=t,this):this._selectionCallback}});function Tl(t){return function(){return t}}class El{constructor(t,e={}){tl(e["css-classes"]),this.css_classes=Qa,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=Wa,this.draw_scale_bar=null,this.edge_placer=Ga,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:Tl(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=i.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(Ta(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(),bl()}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){al(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&&(Yt(t).select("svg").remove(),this.svg=(e="svg",Yt(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")),Yt(this.container).on("click",t=>{this.handle_node_click(null)},!0)),this}update_layout(t,e){e&&(this.nodes=Hr(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("."+Qa["tree-container"]).data([0]);if(r=r.enter().append("g").attr("class",Qa["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("."+Qa["tree-scale-bar"]).data([0]);t.enter().append("g").attr("class",Qa["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("."+Qa["tree-scale-bar"]).remove();r=this.svg.selectAll("."+Qa["tree-container"]).data([0]),this.updateCollapsedClades(t);let o=r.selectAll(pl(Qa)).data(this.links.filter(dl),t=>t.target.id||(t.target.id=++n));o.exit().remove(),o=o.enter().insert("path",":first-child").merge(o).each(function(n){e.drawEdge(this,n,t)});let s=r.selectAll(ll(Qa)).data(this.phylotree.nodes.descendants().filter(il),t=>t.id||(t.id=++n));if(s.exit().remove(),s=s.enter().append("g").attr("class",this.reclassNode).merge(s).attr("transform",t=>{const e="right-to-left"==this.options.layout&&Ta(t);return t.screen_x=Va(t),t.screen_y=Ba(t),this.d3PhylotreeSvgTranslate([e?0:t.screen_x,t.screen_y])}).each(function(n){e.drawNode(this,n,t)}).attr("transform",t=>{if(!i.isUndefined(t.screen_x)&&!i.isUndefined(t.screen_y))return"translate("+t.screen_x+","+t.screen_y+")"}),this.options["label-nodes-with-name"]&&(s=s.attr("id",t=>"node-"+t.name)),this.resizeSvg(this.phylotree,this.svg,t),this.options.brush){var a=r.selectAll("."+Qa["tree-selection-brush"]).data([0]).enter().insert("g",":first-child").attr("class",Qa["tree-selection-brush"]),l=vr().on("brush",(t,e)=>{var n=t.selection,r=this.links.filter(dl).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",()=>{});a.call(l)}if(this.syncEdgeLabels(),this.options.zoom){let t=function(){var t,e,n,r=gs,i=ms,o=xs,s=ys,a=bs,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,h=Je,f=E("start","zoom","end"),d=0,p=10;function _(t){t.property("__zoom",vs).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",M).filter(a).on("touchstart.zoom",T).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",k).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 fs(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 fs(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,o=arguments,s=b(t,o).event(r),a=i.apply(t,o),l=null==n?v(a):"function"==typeof n?n.apply(t,o):n,u=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),c=t.__zoom,f="function"==typeof e?e.apply(t,o):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 fs(n,l[0]-e[0]*n,l[1]-e[1]*n)}s.zoom(null,t)}})}function b(t,e,n){return!n&&t.__zooming||new x(t,e)}function x(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function w(t,...e){if(r.apply(this,arguments)){var n=b(this,e).event(t),i=this.__zoom,a=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,s.apply(this,arguments)))),c=Vt(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===a)return;n.mouse=[c,i.invert(c)],wn(this),n.start()}_s(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",o(m(g(i,a),n.mouse[0],n.mouse[1]),n.extent,u))}}function N(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,s=b(this,e,!0).event(t),a=Yt(t.view).on("mousemove.zoom",function(t){if(_s(t),!s.moved){var e=t.clientX-c,n=t.clientY-h;s.moved=e*e+n*n>d}s.event(t).zoom("mouse",o(m(s.that.__zoom,s.mouse[0]=Vt(t,i),s.mouse[1]),s.extent,u))},!0).on("mouseup.zoom",function(t){a.on("mousemove.zoom mouseup.zoom",null),Xt(t.view,s.moved),_s(t),s.event(t).end()},!0),l=Vt(t,i),c=t.clientX,h=t.clientY;qt(t.view),ps(t),s.mouse=[l,this.__zoom.invert(l)],wn(this),s.start()}}function M(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,s=Vt(t.changedTouches?t.changedTouches[0]:t,this),a=n.invert(s),l=n.k*(t.shiftKey?.5:2),h=o(m(g(n,l),s,a),i.apply(this,e),u);_s(t),c>0?Yt(this).transition().duration(c).call(y,h,s,t):Yt(this).call(_.transform,h,s,t)}}function T(n,...i){if(r.apply(this,arguments)){var o,s,a,l,u=n.touches,c=u.length,h=b(this,i,n.changedTouches.length===c).event(n);for(ps(n),s=0;s<c;++s)l=[l=Vt(a=u[s],this),this.__zoom.invert(l),a.identifier],h.touch0?h.touch1||h.touch0[2]===l[2]||(h.touch1=l,h.taps=0):(h.touch0=l,o=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),o&&(h.taps<2&&(e=l[0],t=setTimeout(function(){t=null},500)),wn(this),h.start())}}function A(t,...e){if(this.__zooming){var n,r,i,s,a=b(this,e).event(t),l=t.changedTouches,c=l.length;for(_s(t),n=0;n<c;++n)i=Vt(r=l[n],this),a.touch0&&a.touch0[2]===r.identifier?a.touch0[0]=i:a.touch1&&a.touch1[2]===r.identifier&&(a.touch1[0]=i);if(r=a.that.__zoom,a.touch1){var h=a.touch0[0],f=a.touch0[1],d=a.touch1[0],p=a.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],s=[(f[0]+p[0])/2,(f[1]+p[1])/2]}else{if(!a.touch0)return;i=a.touch0[0],s=a.touch0[1]}a.zoom("touch",o(m(r,i,s),a.extent,u))}}function k(t,...r){if(this.__zooming){var i,o,s=b(this,r).event(t),a=t.changedTouches,l=a.length;for(ps(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<l;++i)o=a[i],s.touch0&&s.touch0[2]===o.identifier?delete s.touch0:s.touch1&&s.touch1[2]===o.identifier&&delete s.touch1;if(s.touch1&&!s.touch0&&(s.touch0=s.touch1,delete s.touch1),s.touch0)s.touch0[1]=this.__zoom.invert(s.touch0[0]);else if(s.end(),2===s.taps&&(o=Vt(o,this),Math.hypot(e[0]-o[0],e[1]-o[1])<p)){var u=Yt(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",vs),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,s=null==n?v(t):"function"==typeof n?n.apply(this,arguments):n,a=r.invert(s),l="function"==typeof e?e.apply(this,arguments):e;return o(m(g(r,l),s,a),t,u)},n,r)},_.translateBy=function(t,e,n,r){_.transform(t,function(){return o(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,s){_.transform(t,function(){var t=i.apply(this,arguments),s=this.__zoom,a=null==r?v(t):"function"==typeof r?r.apply(this,arguments):r;return o(ds.translate(a[0],a[1]).scale(s.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,u)},r,s)},x.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=Yt(this.that).datum();f.call(t,this.that,new hs(t,{sourceEvent:this.sourceEvent,target:_,type:t,transform:this.that.__zoom,dispatch:f}),e)}},_.wheelDelta=function(t){return arguments.length?(s="function"==typeof t?t:cs(+t),_):s},_.filter=function(t){return arguments.length?(r="function"==typeof t?t:cs(!!t),_):r},_.touchable=function(t){return arguments.length?(a="function"==typeof t?t:cs(!!t),_):a},_.extent=function(t){return arguments.length?(i="function"==typeof t?t:cs([[+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?(o=t,_):o},_.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=>{Yt("."+Qa["tree-container"]).attr("transform",e=>t.transform),Yt("."+Qa["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(ol(t))return;let e=Ta(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(al(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,Ta(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=i.partial(Xa,this.radial_center),this.edge_placer=Za;let e=null,n=null,r=null,o=0,s=this._extents[0][1]*this.scales[0],a=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/s,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 i=t.x*this.scales[0];if(null!==e){let s=i-n,c=a(t.radius,r,t.angle,e,u),h=c>0?s/c:10*this.options["max-radius"];if(h>this.options["max-radius"]){let n=s/this.options["max-radius"],i=t.radius+r,a=t.radius*r-(n*n-(r-t.radius)*(r-t.radius))/2/(1-Math.cos(e-t.angle)),c=Math.sqrt(i*i-4*a);u=Math.min(this.options["annular-limit"]*l,(-i+c)/2),o=this.options["max-radius"]}else o=Math.max(o,h)}e=t.angle,n=i,r=t.radius}}),this.radius=Math.min(this.options["max-radius"],Math.max(s/2/Math.PI,o)),t&&(this.radius=Math.min(this.radius,.5*(Math.min(s,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=i.partial(Xa,this.radial_center);let c=1;u&&(c=l/(l+u),this.radius*=c),this.phylotree.nodes.each(t=>{if(qa(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=qa(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=Wa,this.edge_placer=Ga,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),Ta(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=ri().domain([0,t]).range([0,e]),r=Or(".2f");if(this.draw_scale_bar=function(t){return M(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(il).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=Tl(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 Qa)n in t&&t[n]!=Qa[n]&&(Qa[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 Qa)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(pl(this.css_classes)).attr("class",this.reclassEdge.bind(this));this.edge_styler&&t.each(t=>{this.edge_styler(Yt(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()}}i.extend(El.prototype,fl),i.extend(El.prototype,cl),i.extend(El.prototype,_l),i.extend(El.prototype,xl),i.extend(El.prototype,Ml),i.extend(El.prototype,rl);let Al=class{constructor(t,e={}){this.newick_string="",this.nodes=[],this.links=[],this.parsed_tags=[],this.partitions=[],this.branch_length_accessor=Ha,this.branch_length=Ha,this.logger=e.logger||console,this.selection_attribute_name="selected";var n=e.type||void 0,r=[],o=this;if(i.isString(n))n in Ia?r=Ia[n](t,e):o.logger.error("type "+n+" not in registry! Available types are "+i.keys(Ia));else if(i.isFunction(n))try{r=n(t,e)}catch(t){o.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=Oa(t):(this.newick_string=t,r=ka(t,e));if(r.json){o.nodes=Hr(r.json);let t={};o.nodes.each(e=>{e.data.annotation&&(t[e.data.annotation]=!0)}),o.parsed_tags=Object.keys(t)}else o.nodes=[];return o.links=o.nodes.links(),this.hasBranchLengths()||(console.warn("Phylotree User Warning : NO BRANCH LENGTHS DETECTED, SETTING ALL LENGTHS TO 1"),this.setBranchLength(t=>1)),o}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=i.clone(t);delete r.json_export_index,t.parent&&(r.parent=t.parent.json_export_index),t.children&&(r.children=i.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){Ua(e,t,r)}:"in-order"==e?function(e){Fa(e,t,r)}:function(e){i.isUndefined(e)||La(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 El(this,t),this.display}};function kl(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&&i.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&&i.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&&i.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&&(i.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 Sl(t,e,n,r,i){var o=t.branch_length(e),s=!1;if(n||(r=e.data.rootToTip,i=0,s=!0),e.children)for(var a=0;a<e.children.length;a++)e.children[a]!=n?Sl(t,e.children[a],e,r,i):s=!0;e.data.rtta=e.data.rootToTip-r+i,s&&(r-=o,i+=o),e.parent&&s&&Sl(t,e.parent,e,r,i)}function Cl(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,o=r/e,s=0,a=0,l=0;t.forEach(function(t){var e=t[0]-i;a+=t[2]*e*e,s+=t[2]*e*t[1],l+=t[2]*(t[1]-o)*(t[1]-o)});var u=(r-n*(s/=a))/e,c=0;return t.forEach(function(t){var e=t[1]-u-s*t[0];c+=t[2]*e*e}),{intercept:u,slope:s,r2:1-c/l,"var (intercept)":Math.sqrt((1+n*n/(e*a))/e),"var (slope)":Math.sqrt(1/a)}}function zl(t){var e=t.branch_length_accessor,n=0;t.traverse_and_compute(r=>{if(r.parent&&(r.data._computed_length=e(r),!i.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:(i.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}Al.prototype.isLeafNode=Ta,Al.prototype.selectAllDescendants=Ea,Al.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=i.union(...n.descendants().map(t=>t.data.mrca)),e||n.data.mrca.length!=t.length||(e=n)):e||(e=n):n.data.mrca=i.intersection([n.data.name],t)}),e},Al.prototype.hasBranchLengths=function(){let t=this.branch_length;return!!t&&i.every(this.nodes.descendants(),function(e){return!e.parent||!i.isUndefined(t(e))})},Al.prototype.getBranchLengths=function(){let t=this.branch_length;return i.map(this.nodes.descendants(),e=>t(e))},Al.prototype.branchName=function(t){return arguments.length?(this.nodeLabel=t,this):this.nodeLabel},Al.prototype.normalizeBranchLengths=function(t){let e=this.branch_length,n=i.map(this.nodes.descendants(),function(t){return e(t)?e(t):null});const r=i.max(n),o=i.min(n);return i.each(this.nodes.descendants(),t=>{let n=e(t);n&&e(t,function(t){return(t-o)/(r-o)}(n))}),this},Al.prototype.scaleBranchLengths=function(t){let e=this.branch_length;return i.each(this.nodes.descendants(),n=>{let r=e(n);r&&e(n,t(r))}),this},Al.prototype.getNewick=Sa,Al.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},Al.prototype.setBranchLength=function(t){return arguments.length?(this.branch_length_accessor=t||Ha,this):this.branch_length_accessor},Al.prototype.maxParsimony=function(t,e){const n=i.partial(function(t,e){if(e.mp=[[0,0],[!1,!1]],Ta(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)=>Ta(t.target)?t.target[e]:t.target.mp)},Al.prototype.getTipLengths=function(){let t=this.getTips(),e=i.map(t,t=>({name:t.data.name,length:parseFloat(t.data.attribute)}));return e=i.sortBy(e,t=>-t.length),e},Al.prototype.leftChildRightSibling=ja,i.extend(Al.prototype,Aa),i.extend(Al.prototype,Ya),i.extend(Al.prototype,$a);const Dl=Oi("%Y%m%d"),$l=/([0-9]{4}).?([0-9]{2}).?([0-9]{2})$/g,Pl=function(t){if(Ta(t)&&"name"in t){let e=$l.exec(t.name);if(e)return e[1]+e[2]+e[3]}return null};function Ol(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=kl(t),r=Number.MAX_VALUE,o=0,s=null;return 2==e?t.traverse_and_compute(function(t){if(t.parent){var e=0,a=0,l=0,u=0,c=0;i.each(t.cot_path_to_leaves_below,function(t){e+=t,a+=t*t,c++}),i.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+a+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&&(s=t,o=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,a=0;a<t.cot_computed_length;){var l=0;i.each(t.cot_path_to_leaves_below,function(t){l+=Math.pow(t+a,e)}),i.each(t.cot_path_to_leaves_above,function(n){l+=Math.pow(n+(t.cot_computed_length-a),e)}),l<r&&(s=t,o=a/t.cot_computed_length,r=l),a+=n}}),{location:s,breakpoint:o,distance:r}},t.clusterPicker=function(t,e,n,r,o){r=r||t.getRootNode(),o=i.isNumber(o)?o:1;let s=t.branch_length;t.traverse_and_compute(function(t){if(t.parent){if(t._computed_length=s(t),!i.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 a=[];return t.traverse_and_compute(i.noop,"pre-order",r,function(r){if(!t.isLeafNode(r)){var s=i.isString(r.data.bootstrap_values)?+r.data.bootstrap_values:o;if(s>=e){var l=i.reduce(r.children,function(t,e){return e.max_path_length+e._computed_length+t},0);if(l<=n)return a.push({root:r,diameter:l,bootstrap:s}),!0}}return!1}),t.traverse_and_compute(function(t){t.parent&&(delete t._computed_length,delete t.max_path_length)},"post-order",r),i.each(a,function(e){e.members=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&e.members.push(n)},"post-order",e.root)}),a},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 o=e(i);if(!(o<=r))return{location:i,breakpoint:r/o};r-=o,i=i.parent}}return{location:n,breakpoint:0}},t.extract_dates=function(t,e,n=Dl){return e=e||Pl,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(),o=new Date(i,0,1),s=new Date(i+1,0,1);return void(t.data.decimal_date_value=i+(t.data.date_value-o)/(s-o))}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),zl(t),t.traverse_and_compute(function(n){t.isLeafNode(n)&&!i.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});let o=Cl(e);return t.traverse_and_compute(function(s){if(t.isLeafNode(s)&&!i.isNull(s.data.decimal_date_value)){Sl(t,s,null,0,0),e=[],t.traverse_and_compute(function(n){t.isLeafNode(n)&&!i.isNull(n.data.decimal_date_value)&&e.push([n.data.decimal_date_value,n.data.rtta,n.data.copy_number])});var a=Cl(e),l=a.r2;l>n&&(n=l,r=s,o=a)}}),{root:r,fit:o}},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=Sa,t.inOrder=Fa,t.leftChildRightSibling=ja,t.loadAnnotations=za,t.neighborJoining=function t(e,n,r){if(n<=2){let t=new Al(""),n=t.getNodes(),i=e[0][1]/2,o=t.createNode(r[0],[null,[i]]),s=t.createNode(r[1],[null,[i]]);return t.addChild(n,o),t.addChild(n,s),t}{let s=n,a=(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 s of o.range(o.parseInt(i)+1,n))r[i][s]=(n-2)*t[i][s]-e[i]-e[s],r[s][i]=r[i][s];return r}(e,a,s),[u,c,h]=function(t,e){let n=-1,r=-1,i=1/0;for(let s of o.range(e))for(let a of o.range(n,e))t[s][a]<i&&(n=s,r=a,i=t[n][r]);return[n,r,i]}(l,s),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}(a,s),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=Ol(o.max([u,c]),e),(e=Ol(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,s-1,r),x=b.createNode(g,[null,[d]]),w=b.createNode(m,[null,[p]]);if(b.getNodeByName(v)){let t=b.getNodeByName(v);b.addChild(t,x),b.addChild(t,w)}else{let t=b.createNode(v,[null,[0]]);b.addChild(b.getNodes(),t),b.addChild(t,x),b.addChild(t,w)}return b}var i},t.newickParser=ka,t.pairwise_distances=kl,t.parseAnnotations=Ca,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,o){r=i.isNumber(r)?r:1;var s=kl(t),a=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=i.reduce(a.cot_path_to_leaves_below,function(t,e){return e>t?e:t},0)+i.reduce(a.cot_path_to_leaves_above,function(t,e){return e>t?e:t},0)+a.cot_computed_length-l;i.isUndefined(o)&&(o=Math.min(.001,c/100));var h=1+(c/o|0);h>500&&(o=c/(h=500));var f=t.getRootNode();f.paths_to_leaves=new Array(s),i.each(f.children,function(t){i.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=[],i.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 i=e.paths_to_leaves[n]+e.paths_to_leaves[r];e.histogram[(i-l)/o|0]++}e.leaf_count=e.paths_to_leaves.length,delete e.paths_to_leaves}});for(var d=(s-1)*s/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])*o,g=[];return t.traverse_and_compute(i.noop,"pre-order",null,function(n){if(!t.isLeafNode(n)){var s=i.isString(n.data.bootstrap_values)?+n.data.bootstrap_values:r;if(s>=e){for(var a=n.leaf_count*(n.leaf_count-1)*.25,u=0;u<h-1&&a>n.histogram[u];u++)a-=n.histogram[u];var c=l+(u+(n.histogram[u]-a)/n.histogram[u])*o;if(c<=_)return g.push({root:n,median:c,bootstrap:s}),!0}}return!1}),t.traverse_and_compute(function(e){t.isLeafNode(e)||"histogram"in e&&(delete e.histogram,delete e.leaf_count)}),i.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=Al,t.postOrder=La,t.preOrder=Ua,t.rootToTip=zl,t.sackin=function(t){let e=t.getTips(),n=i.map(e,t=>t.depth);return i.reduce(n,function(t,e){return t+e},0)},Object.defineProperty(t,"__esModule",{value:!0})});
3
2
  //# sourceMappingURL=phylotree.min.js.map