@owox/web 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/ModelCanvas-BZUjsuzU.js +2 -0
- package/dist/assets/{RelationshipCanvas-HaHLbPRS.js → RelationshipCanvas-CLsK8_sZ.js} +1 -1
- package/dist/assets/RelationshipDetailsSheet-BB2tABQt.js +1 -0
- package/dist/assets/{erd-fields-section-CDkC1Pzu.js → erd-fields-section-_gVp8PxG.js} +2 -2
- package/dist/assets/index-BW17AtYZ.js +1761 -0
- package/dist/assets/index-Bu4VCLfp.css +1 -0
- package/dist/assets/{index-Dr0TbJRt.js → index-CfHV4Rj5.js} +7 -7
- package/dist/assets/{lucide-icon-catalog-BIDsv2NX.js → lucide-icon-catalog-DtgVQFwd.js} +1 -1
- package/dist/assets/{pencil-line-BP_bhkzs.js → pencil-line-CUWsvz42.js} +1 -1
- package/dist/assets/{zoom-out-CcoidGXK.js → zoom-out-C2ChQihe.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/ModelCanvas-By1wBUBL.js +0 -2
- package/dist/assets/index-DPgXWGfA.css +0 -1
- package/dist/assets/index-IRYqNEd8.js +0 -1758
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a0 as jc,a1 as Lc,r as L,j as E,P as Dc,n as Rc,c as Hc,a2 as zc,p as Fc,a3 as Lr,a4 as Bc,a5 as Vc,G as Yc,y as Xc,a6 as Wc,a7 as Gc,a8 as qc,T as Kc,a as Uc,I as Zc,b as Qc,a9 as Jc,aa as el,ab as tl}from"./index-IRYqNEd8.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var nl={value:()=>{}};function dn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Yt(n)}function Yt(e){this._=e}function rl(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Yt.prototype=dn.prototype={constructor:Yt,on:function(e,t){var n=this._,r=rl(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=ol(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=Dr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Dr(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Yt(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function ol(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function Dr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=nl,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Vn="http://www.w3.org/1999/xhtml";const Rr={svg:"http://www.w3.org/2000/svg",xhtml:Vn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function fn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Rr.hasOwnProperty(t)?{space:Rr[t],local:e}:e}function il(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Vn&&t.documentElement.namespaceURI===Vn?t.createElement(e):t.createElementNS(n,e)}}function sl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hi(e){var t=fn(e);return(t.local?sl:il)(t)}function al(){}function or(e){return e==null?al:function(){return this.querySelector(e)}}function cl(e){typeof e!="function"&&(e=or(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new le(r,this._parents)}function ll(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ul(){return[]}function gi(e){return e==null?ul:function(){return this.querySelectorAll(e)}}function dl(e){return function(){return ll(e.apply(this,arguments))}}function fl(e){typeof e=="function"?e=dl(e):e=gi(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(r.push(e.call(c,c.__data__,l,s)),o.push(c));return new le(r,o)}function pi(e){return function(){return this.matches(e)}}function mi(e){return function(t){return t.matches(e)}}var hl=Array.prototype.find;function gl(e){return function(){return hl.call(this.children,e)}}function pl(){return this.firstElementChild}function ml(e){return this.select(e==null?pl:gl(typeof e=="function"?e:mi(e)))}var yl=Array.prototype.filter;function xl(){return Array.from(this.children)}function wl(e){return function(){return yl.call(this.children,e)}}function vl(e){return this.selectAll(e==null?xl:wl(typeof e=="function"?e:mi(e)))}function bl(e){typeof e!="function"&&(e=pi(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new le(r,this._parents)}function yi(e){return new Array(e.length)}function El(){return new le(this._enter||this._groups.map(yi),this._parents)}function Kt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kt.prototype={constructor:Kt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function _l(e){return function(){return e}}function Nl(e,t,n,r,o,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new Kt(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Sl(e,t,n,r,o,i,s){var a,c,l=new Map,u=t.length,d=i.length,f=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(f[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?o[a]=c:l.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(r[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new Kt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function Cl(e){return e.__data__}function kl(e,t){if(!arguments.length)return Array.from(this,Cl);var n=t?Sl:Nl,r=this._parents,o=this._groups;typeof e!="function"&&(e=_l(e));for(var i=o.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=r[l],d=o[l],f=d.length,h=Ml(e.call(u,u&&u.__data__,l,r)),g=h.length,v=a[l]=new Array(g),w=s[l]=new Array(g),m=c[l]=new Array(f);n(u,d,v,w,m,h,t);for(var b=0,p=0,x,_;b<g;++b)if(x=v[b]){for(b>=p&&(p=b+1);!(_=w[p])&&++p<g;);x._next=_||null}}return s=new le(s,r),s._enter=a,s._exit=c,s}function Ml(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Il(){return new le(this._exit||this._groups.map(yi),this._parents)}function Al(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function Tl(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),c=0;c<s;++c)for(var l=n[c],u=r[c],d=l.length,f=a[c]=new Array(d),h,g=0;g<d;++g)(h=l[g]||u[g])&&(f[g]=h);for(;c<o;++c)a[c]=n[c];return new le(a,this._parents)}function Ol(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Pl(e){e||(e=$l);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],a=s.length,c=o[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new le(o,this._parents).order()}function $l(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function jl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ll(){return Array.from(this)}function Dl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function Rl(){let e=0;for(const t of this)++e;return e}function Hl(){return!this.node()}function zl(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&e.call(a,a.__data__,i,o);return this}function Fl(e){return function(){this.removeAttribute(e)}}function Bl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Vl(e,t){return function(){this.setAttribute(e,t)}}function Yl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Xl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Wl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Gl(e,t){var n=fn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Bl:Fl:typeof t=="function"?n.local?Wl:Xl:n.local?Yl:Vl)(n,t))}function xi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ql(e){return function(){this.style.removeProperty(e)}}function Kl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Ul(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Zl(e,t,n){return arguments.length>1?this.each((t==null?ql:typeof t=="function"?Ul:Kl)(e,t,n??"")):et(this.node(),e)}function et(e,t){return e.style.getPropertyValue(t)||xi(e).getComputedStyle(e,null).getPropertyValue(t)}function Ql(e){return function(){delete this[e]}}function Jl(e,t){return function(){this[e]=t}}function eu(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function tu(e,t){return arguments.length>1?this.each((t==null?Ql:typeof t=="function"?eu:Jl)(e,t)):this.node()[e]}function wi(e){return e.trim().split(/^|\s+/)}function ir(e){return e.classList||new vi(e)}function vi(e){this._node=e,this._names=wi(e.getAttribute("class")||"")}vi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function bi(e,t){for(var n=ir(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Ei(e,t){for(var n=ir(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function nu(e){return function(){bi(this,e)}}function ru(e){return function(){Ei(this,e)}}function ou(e,t){return function(){(t.apply(this,arguments)?bi:Ei)(this,e)}}function iu(e,t){var n=wi(e+"");if(arguments.length<2){for(var r=ir(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?ou:t?nu:ru)(n,t))}function su(){this.textContent=""}function au(e){return function(){this.textContent=e}}function cu(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function lu(e){return arguments.length?this.each(e==null?su:(typeof e=="function"?cu:au)(e)):this.node().textContent}function uu(){this.innerHTML=""}function du(e){return function(){this.innerHTML=e}}function fu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function hu(e){return arguments.length?this.each(e==null?uu:(typeof e=="function"?fu:du)(e)):this.node().innerHTML}function gu(){this.nextSibling&&this.parentNode.appendChild(this)}function pu(){return this.each(gu)}function mu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function yu(){return this.each(mu)}function xu(e){var t=typeof e=="function"?e:hi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function wu(){return null}function vu(e,t){var n=typeof e=="function"?e:hi(e),r=t==null?wu:typeof t=="function"?t:or(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function bu(){var e=this.parentNode;e&&e.removeChild(this)}function Eu(){return this.each(bu)}function _u(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Nu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Su(e){return this.select(e?Nu:_u)}function Cu(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ku(e){return function(t){e.call(this,t,this.__data__)}}function Mu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Iu(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function Au(e,t,n){return function(){var r=this.__on,o,i=ku(t);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function Tu(e,t,n){var r=Mu(e+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(o=0,u=a[c];o<i;++o)if((s=r[o]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Au:Iu,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function _i(e,t,n){var r=xi(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Ou(e,t){return function(){return _i(this,e,t)}}function Pu(e,t){return function(){return _i(this,e,t.apply(this,arguments))}}function $u(e,t){return this.each((typeof t=="function"?Pu:Ou)(e,t))}function*ju(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var Ni=[null];function le(e,t){this._groups=e,this._parents=t}function Ct(){return new le([[document.documentElement]],Ni)}function Lu(){return this}le.prototype=Ct.prototype={constructor:le,select:cl,selectAll:fl,selectChild:ml,selectChildren:vl,filter:bl,data:kl,enter:El,exit:Il,join:Al,merge:Tl,selection:Lu,order:Ol,sort:Pl,call:jl,nodes:Ll,node:Dl,size:Rl,empty:Hl,each:zl,attr:Gl,style:Zl,property:tu,classed:iu,text:lu,html:hu,raise:pu,lower:yu,append:xu,insert:vu,remove:Eu,clone:Su,datum:Cu,on:Tu,dispatch:$u,[Symbol.iterator]:ju};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],Ni)}function Du(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=Du(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ru={passive:!1},mt={capture:!0,passive:!1};function Mn(e){e.stopImmediatePropagation()}function Qe(e){e.preventDefault(),e.stopImmediatePropagation()}function Si(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Qe,mt);"onselectstart"in t?n.on("selectstart.drag",Qe,mt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ci(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Qe,mt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const jt=e=>()=>e;function Yn(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Yn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Hu(e){return!e.ctrlKey&&!e.button}function zu(){return this.parentNode}function Fu(e,t){return t??{x:e.x,y:e.y}}function Bu(){return navigator.maxTouchPoints||"ontouchstart"in this}function ki(){var e=Hu,t=zu,n=Fu,r=Bu,o={},i=dn("start","drag","end"),s=0,a,c,l,u,d=0;function f(x){x.on("mousedown.drag",h).filter(r).on("touchstart.drag",w).on("touchmove.drag",m,Ru).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,_){if(!(u||!e.call(this,x,_))){var S=p(this,t.call(this,x,_),x,_,"mouse");S&&(ce(x.view).on("mousemove.drag",g,mt).on("mouseup.drag",v,mt),Si(x.view),Mn(x),l=!1,a=x.clientX,c=x.clientY,S("start",x))}}function g(x){if(Qe(x),!l){var _=x.clientX-a,S=x.clientY-c;l=_*_+S*S>d}o.mouse("drag",x)}function v(x){ce(x.view).on("mousemove.drag mouseup.drag",null),Ci(x.view,l),Qe(x),o.mouse("end",x)}function w(x,_){if(e.call(this,x,_)){var S=x.changedTouches,k=t.call(this,x,_),M=S.length,I,z;for(I=0;I<M;++I)(z=p(this,k,x,_,S[I].identifier,S[I]))&&(Mn(x),z("start",x,S[I]))}}function m(x){var _=x.changedTouches,S=_.length,k,M;for(k=0;k<S;++k)(M=o[_[k].identifier])&&(Qe(x),M("drag",x,_[k]))}function b(x){var _=x.changedTouches,S=_.length,k,M;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),k=0;k<S;++k)(M=o[_[k].identifier])&&(Mn(x),M("end",x,_[k]))}function p(x,_,S,k,M,I){var z=i.copy(),O=fe(I||S,_),$,P,y;if((y=n.call(x,new Yn("beforestart",{sourceEvent:S,target:f,identifier:M,active:s,x:O[0],y:O[1],dx:0,dy:0,dispatch:z}),k))!=null)return $=y.x-O[0]||0,P=y.y-O[1]||0,function N(C,A,j){var T=O,D;switch(C){case"start":o[M]=N,D=s++;break;case"end":delete o[M],--s;case"drag":O=fe(j||A,_),D=s;break}z.call(C,x,new Yn(C,{sourceEvent:A,subject:y,target:f,identifier:M,active:D,x:O[0]+$,y:O[1]+P,dx:O[0]-T[0],dy:O[1]-T[1],dispatch:z}),k)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:jt(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:jt(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:jt(x),f):n},f.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:jt(!!x),f):r},f.on=function(){var x=i.on.apply(i,arguments);return x===i?f:x},f.clickDistance=function(x){return arguments.length?(d=(x=+x)*x,f):Math.sqrt(d)},f}function sr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Mi(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function kt(){}var yt=.7,Ut=1/yt,Je="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Vu=/^#([0-9a-f]{3,8})$/,Yu=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Xu=new RegExp(`^rgb\\(${Ne},${Ne},${Ne}\\)$`),Wu=new RegExp(`^rgba\\(${Je},${Je},${Je},${xt}\\)$`),Gu=new RegExp(`^rgba\\(${Ne},${Ne},${Ne},${xt}\\)$`),qu=new RegExp(`^hsl\\(${xt},${Ne},${Ne}\\)$`),Ku=new RegExp(`^hsla\\(${xt},${Ne},${Ne},${xt}\\)$`),Hr={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};sr(kt,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:zr,formatHex:zr,formatHex8:Uu,formatHsl:Zu,formatRgb:Fr,toString:Fr});function zr(){return this.rgb().formatHex()}function Uu(){return this.rgb().formatHex8()}function Zu(){return Ii(this).formatHsl()}function Fr(){return this.rgb().formatRgb()}function Ye(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Vu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Br(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Lt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Lt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Yu.exec(e))?new ae(t[1],t[2],t[3],1):(t=Xu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Wu.exec(e))?Lt(t[1],t[2],t[3],t[4]):(t=Gu.exec(e))?Lt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=qu.exec(e))?Xr(t[1],t[2]/100,t[3]/100,1):(t=Ku.exec(e))?Xr(t[1],t[2]/100,t[3]/100,t[4]):Hr.hasOwnProperty(e)?Br(Hr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function Br(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Lt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function Qu(e){return e instanceof kt||(e=Ye(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Xn(e,t,n,r){return arguments.length===1?Qu(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}sr(ae,Xn,Mi(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?yt:Math.pow(yt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Be(this.r),Be(this.g),Be(this.b),Zt(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:Vr,formatHex:Vr,formatHex8:Ju,formatRgb:Yr,toString:Yr}));function Vr(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}`}function Ju(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}${Fe((isNaN(this.opacity)?1:this.opacity)*255)}`}function Yr(){const e=Zt(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Zt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Be(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fe(e){return e=Be(e),(e<16?"0":"")+e.toString(16)}function Xr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,n,r)}function Ii(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof kt||(e=Ye(e)),!e)return new he;if(e instanceof he)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,a=i-o,c=(i+o)/2;return a?(t===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+o:2-i-o,s*=60):a=c>0&&c<1?0:s,new he(s,a,c,e.opacity)}function ed(e,t,n,r){return arguments.length===1?Ii(e):new he(e,t,n,r??1)}function he(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}sr(he,ed,Mi(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?yt:Math.pow(yt,e),new he(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new ae(In(e>=240?e-240:e+120,o,r),In(e,o,r),In(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(Wr(this.h),Dt(this.s),Dt(this.l),Zt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Zt(this.opacity);return`${e===1?"hsl(":"hsla("}${Wr(this.h)}, ${Dt(this.s)*100}%, ${Dt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Wr(e){return e=(e||0)%360,e<0?e+360:e}function Dt(e){return Math.max(0,Math.min(1,e||0))}function In(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ar=e=>()=>e;function td(e,t){return function(n){return e+n*t}}function nd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function rd(e){return(e=+e)==1?Ai:function(t,n){return n-t?nd(t,n,e):ar(isNaN(t)?n:t)}}function Ai(e,t){var n=t-e;return n?td(e,n):ar(isNaN(e)?t:e)}const Qt=(function e(t){var n=rd(t);function r(o,i){var s=n((o=Xn(o)).r,(i=Xn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),l=Ai(o.opacity,i.opacity);return function(u){return o.r=s(u),o.g=a(u),o.b=c(u),o.opacity=l(u),o+""}}return r.gamma=e,r})(1);function od(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function id(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function sd(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=gt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function ad(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ee(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function cd(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=gt(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Wn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,An=new RegExp(Wn.source,"g");function ld(e){return function(){return e}}function ud(e){return function(t){return e(t)+""}}function Ti(e,t){var n=Wn.lastIndex=An.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Wn.exec(e))&&(o=An.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(r=r[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,c.push({i:s,x:Ee(r,o)})),n=An.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?ud(c[0].x):ld(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)a[(d=c[u]).i]=d.x(l);return a.join("")})}function gt(e,t){var n=typeof t,r;return t==null||n==="boolean"?ar(t):(n==="number"?Ee:n==="string"?(r=Ye(t))?(t=r,Qt):Ti:t instanceof Ye?Qt:t instanceof Date?ad:id(t)?od:Array.isArray(t)?sd:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?cd:Ee)(e,t)}var Gr=180/Math.PI,Gn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Oi(e,t,n,r,o,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*Gr,skewX:Math.atan(c)*Gr,scaleX:s,scaleY:a}}var Rt;function dd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Gn:Oi(t.a,t.b,t.c,t.d,t.e,t.f)}function fd(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Gn:(e=e.matrix,Oi(e.a,e.b,e.c,e.d,e.e,e.f))}function Pi(e,t,n,r){function o(l){return l.length?l.pop()+" ":""}function i(l,u,d,f,h,g){if(l!==d||u!==f){var v=h.push("translate(",null,t,null,n);g.push({i:v-4,x:Ee(l,d)},{i:v-2,x:Ee(u,f)})}else(d||f)&&h.push("translate("+d+t+f+n)}function s(l,u,d,f){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),f.push({i:d.push(o(d)+"rotate(",null,r)-2,x:Ee(l,u)})):u&&d.push(o(d)+"rotate("+u+r)}function a(l,u,d,f){l!==u?f.push({i:d.push(o(d)+"skewX(",null,r)-2,x:Ee(l,u)}):u&&d.push(o(d)+"skewX("+u+r)}function c(l,u,d,f,h,g){if(l!==d||u!==f){var v=h.push(o(h)+"scale(",null,",",null,")");g.push({i:v-4,x:Ee(l,d)},{i:v-2,x:Ee(u,f)})}else(d!==1||f!==1)&&h.push(o(h)+"scale("+d+","+f+")")}return function(l,u){var d=[],f=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,d,f),s(l.rotate,u.rotate,d,f),a(l.skewX,u.skewX,d,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,f),l=u=null,function(h){for(var g=-1,v=f.length,w;++g<v;)d[(w=f[g]).i]=w.x(h);return d.join("")}}}var hd=Pi(dd,"px, ","px)","deg)"),gd=Pi(fd,", ",")",")"),pd=1e-12;function qr(e){return((e=Math.exp(e))+1/e)/2}function md(e){return((e=Math.exp(e))-1/e)/2}function yd(e){return((e=Math.exp(2*e))-1)/(e+1)}const Xt=(function e(t,n,r){function o(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],d=s[1],f=s[2],h=u-a,g=d-c,v=h*h+g*g,w,m;if(v<pd)m=Math.log(f/l)/t,w=function(k){return[a+k*h,c+k*g,l*Math.exp(t*k*m)]};else{var b=Math.sqrt(v),p=(f*f-l*l+r*v)/(2*l*n*b),x=(f*f-l*l-r*v)/(2*f*n*b),_=Math.log(Math.sqrt(p*p+1)-p),S=Math.log(Math.sqrt(x*x+1)-x);m=(S-_)/t,w=function(k){var M=k*m,I=qr(_),z=l/(n*b)*(I*yd(t*M+_)-md(_));return[a+z*h,c+z*g,l*I/qr(t*M+_)]}}return w.duration=m*1e3*t/Math.SQRT2,w}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},o})(Math.SQRT2,2,4);var tt=0,dt=0,lt=0,$i=1e3,Jt,ft,en=0,Xe=0,hn=0,wt=typeof performance=="object"&&performance.now?performance:Date,ji=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function cr(){return Xe||(ji(xd),Xe=wt.now()+hn)}function xd(){Xe=0}function tn(){this._call=this._time=this._next=null}tn.prototype=Li.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?cr():+n)+(t==null?0:+t),!this._next&&ft!==this&&(ft?ft._next=this:Jt=this,ft=this),this._call=e,this._time=n,qn()},stop:function(){this._call&&(this._call=null,this._time=1/0,qn())}};function Li(e,t,n){var r=new tn;return r.restart(e,t,n),r}function wd(){cr(),++tt;for(var e=Jt,t;e;)(t=Xe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tt}function Kr(){Xe=(en=wt.now())+hn,tt=dt=0;try{wd()}finally{tt=0,bd(),Xe=0}}function vd(){var e=wt.now(),t=e-en;t>$i&&(hn-=t,en=e)}function bd(){for(var e,t=Jt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);ft=e,qn(r)}function qn(e){if(!tt){dt&&(dt=clearTimeout(dt));var t=e-Xe;t>24?(e<1/0&&(dt=setTimeout(Kr,e-wt.now()-hn)),lt&&(lt=clearInterval(lt))):(lt||(en=wt.now(),lt=setInterval(vd,$i)),tt=1,ji(Kr))}}function Ur(e,t,n){var r=new tn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Ed=dn("start","end","cancel","interrupt"),_d=[],Di=0,Zr=1,Kn=2,Wt=3,Qr=4,Un=5,Gt=6;function gn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Nd(e,n,{name:t,index:r,group:o,on:Ed,tween:_d,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Di})}function lr(e,t){var n=ye(e,t);if(n.state>Di)throw new Error("too late; already scheduled");return n}function Se(e,t){var n=ye(e,t);if(n.state>Wt)throw new Error("too late; already running");return n}function ye(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Nd(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Li(i,0,n.time);function i(l){n.state=Zr,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,d,f,h;if(n.state!==Zr)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Wt)return Ur(s);h.state===Qr?(h.state=Gt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=Gt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(Ur(function(){n.state===Wt&&(n.state=Qr,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Kn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Kn){for(n.state=Wt,o=new Array(f=n.tween.length),u=0,d=-1;u<f;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=h);o.length=d+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Un,1),d=-1,f=o.length;++d<f;)o[d].call(e,u);n.state===Un&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Gt,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function qt(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Kn&&r.state<Un,r.state=Gt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Sd(e){return this.each(function(){qt(this,e)})}function Cd(e,t){var n,r;return function(){var o=Se(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function kd(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Se(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:t,value:n},c=0,l=o.length;c<l;++c)if(o[c].name===t){o[c]=a;break}c===l&&o.push(a)}i.tween=o}}function Md(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ye(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?Cd:kd)(n,e,t))}function ur(e,t,n){var r=e._id;return e.each(function(){var o=Se(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ye(o,r).value[t]}}function Ri(e,t){var n;return(typeof t=="number"?Ee:t instanceof Ye?Qt:(n=Ye(t))?(t=n,Qt):Ti)(e,t)}function Id(e){return function(){this.removeAttribute(e)}}function Ad(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Td(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function Od(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function Pd(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function $d(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function jd(e,t){var n=fn(e),r=n==="transform"?gd:Ri;return this.attrTween(e,typeof t=="function"?(n.local?$d:Pd)(n,r,ur(this,"attr."+e,t)):t==null?(n.local?Ad:Id)(n):(n.local?Od:Td)(n,r,t))}function Ld(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Dd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Rd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Dd(e,i)),n}return o._value=t,o}function Hd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Ld(e,i)),n}return o._value=t,o}function zd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=fn(e);return this.tween(n,(r.local?Rd:Hd)(r,t))}function Fd(e,t){return function(){lr(this,e).delay=+t.apply(this,arguments)}}function Bd(e,t){return t=+t,function(){lr(this,e).delay=t}}function Vd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Fd:Bd)(t,e)):ye(this.node(),t).delay}function Yd(e,t){return function(){Se(this,e).duration=+t.apply(this,arguments)}}function Xd(e,t){return t=+t,function(){Se(this,e).duration=t}}function Wd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Yd:Xd)(t,e)):ye(this.node(),t).duration}function Gd(e,t){if(typeof t!="function")throw new Error;return function(){Se(this,e).ease=t}}function qd(e){var t=this._id;return arguments.length?this.each(Gd(t,e)):ye(this.node(),t).ease}function Kd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Se(this,e).ease=n}}function Ud(e){if(typeof e!="function")throw new Error;return this.each(Kd(this._id,e))}function Zd(e){typeof e!="function"&&(e=pi(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Te(r,this._parents,this._name,this._id)}function Qd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,d=s[a]=new Array(u),f,h=0;h<u;++h)(f=c[h]||l[h])&&(d[h]=f);for(;a<r;++a)s[a]=t[a];return new Te(s,this._parents,this._name,this._id)}function Jd(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function ef(e,t,n){var r,o,i=Jd(t)?lr:Se;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function tf(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(ef(n,e,t))}function nf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function rf(){return this.on("end.remove",nf(this._id))}function of(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],c=a.length,l=i[s]=new Array(c),u,d,f=0;f<c;++f)(u=a[f])&&(d=e.call(u,u.__data__,f,a))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d,gn(l[f],t,n,f,l,ye(u,n)));return new Te(i,this._parents,t,n)}function sf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=gi(e));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var c=r[a],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),h,g=ye(u,n),v=0,w=f.length;v<w;++v)(h=f[v])&&gn(h,t,n,v,f,g);i.push(f),s.push(u)}return new Te(i,s,t,n)}var af=Ct.prototype.constructor;function cf(){return new af(this._groups,this._parents)}function lf(e,t){var n,r,o;return function(){var i=et(this,e),s=(this.style.removeProperty(e),et(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Hi(e){return function(){this.style.removeProperty(e)}}function uf(e,t,n){var r,o=n+"",i;return function(){var s=et(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function df(e,t,n){var r,o,i;return function(){var s=et(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),et(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function ff(e,t){var n,r,o,i="style."+t,s="end."+i,a;return function(){var c=Se(this,e),l=c.on,u=c.value[i]==null?a||(a=Hi(t)):void 0;(l!==n||o!==u)&&(r=(n=l).copy()).on(s,o=u),c.on=r}}function hf(e,t,n){var r=(e+="")=="transform"?hd:Ri;return t==null?this.styleTween(e,lf(e,r)).on("end.style."+e,Hi(e)):typeof t=="function"?this.styleTween(e,df(e,r,ur(this,"style."+e,t))).each(ff(this._id,e)):this.styleTween(e,uf(e,r,t),n).on("end.style."+e,null)}function gf(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function pf(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&gf(e,s,n)),r}return i._value=t,i}function mf(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,pf(e,t,n??""))}function yf(e){return function(){this.textContent=e}}function xf(e){return function(){var t=e(this);this.textContent=t??""}}function wf(e){return this.tween("text",typeof e=="function"?xf(ur(this,"text",e)):yf(e==null?"":e+""))}function vf(e){return function(t){this.textContent=e.call(this,t)}}function bf(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&vf(o)),t}return r._value=e,r}function Ef(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,bf(e))}function _f(){for(var e=this._name,t=this._id,n=zi(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=ye(c,t);gn(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Te(r,this._parents,e,n)}function Nf(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--o===0&&i()}};n.each(function(){var l=Se(this,r),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),o===0&&i()})}var Sf=0;function Te(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function zi(){return++Sf}var Ie=Ct.prototype;Te.prototype={constructor:Te,select:of,selectAll:sf,selectChild:Ie.selectChild,selectChildren:Ie.selectChildren,filter:Zd,merge:Qd,selection:cf,transition:_f,call:Ie.call,nodes:Ie.nodes,node:Ie.node,size:Ie.size,empty:Ie.empty,each:Ie.each,on:tf,attr:jd,attrTween:zd,style:hf,styleTween:mf,text:wf,textTween:Ef,remove:rf,tween:Md,delay:Vd,duration:Wd,ease:qd,easeVarying:Ud,end:Nf,[Symbol.iterator]:Ie[Symbol.iterator]};function Cf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var kf={time:null,delay:0,duration:250,ease:Cf};function Mf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function If(e){var t,n;e instanceof Te?(t=e._id,e=e._name):(t=zi(),(n=kf).time=cr(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&gn(c,e,t,l,s,n||Mf(c,t));return new Te(r,this._parents,e,t)}Ct.prototype.interrupt=Sd;Ct.prototype.transition=If;const Ht=e=>()=>e;function Af(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Ae(e,t,n){this.k=e,this.x=t,this.y=n}Ae.prototype={constructor:Ae,scale:function(e){return e===1?this:new Ae(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ae(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var pn=new Ae(1,0,0);Fi.prototype=Ae.prototype;function Fi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return pn;return e.__zoom}function Tn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function Tf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Of(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Jr(){return this.__zoom||pn}function Pf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $f(){return navigator.maxTouchPoints||"ontouchstart"in this}function jf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Bi(){var e=Tf,t=Of,n=jf,r=Pf,o=$f,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Xt,l=dn("start","zoom","end"),u,d,f,h=500,g=150,v=0,w=10;function m(y){y.property("__zoom",Jr).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,N,C,A){var j=y.selection?y.selection():y;j.property("__zoom",Jr),y!==j?_(y,N,C,A):j.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},m.scaleBy=function(y,N,C,A){m.scaleTo(y,function(){var j=this.__zoom.k,T=typeof N=="function"?N.apply(this,arguments):N;return j*T},C,A)},m.scaleTo=function(y,N,C,A){m.transform(y,function(){var j=t.apply(this,arguments),T=this.__zoom,D=C==null?x(j):typeof C=="function"?C.apply(this,arguments):C,F=T.invert(D),H=typeof N=="function"?N.apply(this,arguments):N;return n(p(b(T,H),D,F),j,s)},C,A)},m.translateBy=function(y,N,C,A){m.transform(y,function(){return n(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,A)},m.translateTo=function(y,N,C,A,j){m.transform(y,function(){var T=t.apply(this,arguments),D=this.__zoom,F=A==null?x(T):typeof A=="function"?A.apply(this,arguments):A;return n(pn.translate(F[0],F[1]).scale(D.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof C=="function"?-C.apply(this,arguments):-C),T,s)},A,j)};function b(y,N){return N=Math.max(i[0],Math.min(i[1],N)),N===y.k?y:new Ae(N,y.x,y.y)}function p(y,N,C){var A=N[0]-C[0]*y.k,j=N[1]-C[1]*y.k;return A===y.x&&j===y.y?y:new Ae(y.k,A,j)}function x(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function _(y,N,C,A){y.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var j=this,T=arguments,D=S(j,T).event(A),F=t.apply(j,T),H=C==null?x(F):typeof C=="function"?C.apply(j,T):C,V=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),Y=j.__zoom,q=typeof N=="function"?N.apply(j,T):N,J=c(Y.invert(H).concat(V/Y.k),q.invert(H).concat(V/q.k));return function(G){if(G===1)G=q;else{var R=J(G),B=V/R[2];G=new Ae(B,H[0]-R[0]*B,H[1]-R[1]*B)}D.zoom(null,G)}})}function S(y,N,C){return!C&&y.__zooming||new k(y,N)}function k(y,N){this.that=y,this.args=N,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,N),this.taps=0}k.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,N){return this.mouse&&y!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=N.invert(this.touch1[0])),this.that.__zoom=N,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var N=ce(this.that).datum();l.call(y,this.that,new Af(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),N)}};function M(y,...N){if(!e.apply(this,arguments))return;var C=S(this,N).event(y),A=this.__zoom,j=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),T=fe(y);if(C.wheel)(C.mouse[0][0]!==T[0]||C.mouse[0][1]!==T[1])&&(C.mouse[1]=A.invert(C.mouse[0]=T)),clearTimeout(C.wheel);else{if(A.k===j)return;C.mouse=[T,A.invert(T)],qt(this),C.start()}ut(y),C.wheel=setTimeout(D,g),C.zoom("mouse",n(p(b(A,j),C.mouse[0],C.mouse[1]),C.extent,s));function D(){C.wheel=null,C.end()}}function I(y,...N){if(f||!e.apply(this,arguments))return;var C=y.currentTarget,A=S(this,N,!0).event(y),j=ce(y.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",V,!0),T=fe(y,C),D=y.clientX,F=y.clientY;Si(y.view),Tn(y),A.mouse=[T,this.__zoom.invert(T)],qt(this),A.start();function H(Y){if(ut(Y),!A.moved){var q=Y.clientX-D,J=Y.clientY-F;A.moved=q*q+J*J>v}A.event(Y).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=fe(Y,C),A.mouse[1]),A.extent,s))}function V(Y){j.on("mousemove.zoom mouseup.zoom",null),Ci(Y.view,A.moved),ut(Y),A.event(Y).end()}}function z(y,...N){if(e.apply(this,arguments)){var C=this.__zoom,A=fe(y.changedTouches?y.changedTouches[0]:y,this),j=C.invert(A),T=C.k*(y.shiftKey?.5:2),D=n(p(b(C,T),A,j),t.apply(this,N),s);ut(y),a>0?ce(this).transition().duration(a).call(_,D,A,y):ce(this).call(m.transform,D,A,y)}}function O(y,...N){if(e.apply(this,arguments)){var C=y.touches,A=C.length,j=S(this,N,y.changedTouches.length===A).event(y),T,D,F,H;for(Tn(y),D=0;D<A;++D)F=C[D],H=fe(F,this),H=[H,this.__zoom.invert(H),F.identifier],j.touch0?!j.touch1&&j.touch0[2]!==H[2]&&(j.touch1=H,j.taps=0):(j.touch0=H,T=!0,j.taps=1+!!u);u&&(u=clearTimeout(u)),T&&(j.taps<2&&(d=H[0],u=setTimeout(function(){u=null},h)),qt(this),j.start())}}function $(y,...N){if(this.__zooming){var C=S(this,N).event(y),A=y.changedTouches,j=A.length,T,D,F,H;for(ut(y),T=0;T<j;++T)D=A[T],F=fe(D,this),C.touch0&&C.touch0[2]===D.identifier?C.touch0[0]=F:C.touch1&&C.touch1[2]===D.identifier&&(C.touch1[0]=F);if(D=C.that.__zoom,C.touch1){var V=C.touch0[0],Y=C.touch0[1],q=C.touch1[0],J=C.touch1[1],G=(G=q[0]-V[0])*G+(G=q[1]-V[1])*G,R=(R=J[0]-Y[0])*R+(R=J[1]-Y[1])*R;D=b(D,Math.sqrt(G/R)),F=[(V[0]+q[0])/2,(V[1]+q[1])/2],H=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(C.touch0)F=C.touch0[0],H=C.touch0[1];else return;C.zoom("touch",n(p(D,F,H),C.extent,s))}}function P(y,...N){if(this.__zooming){var C=S(this,N).event(y),A=y.changedTouches,j=A.length,T,D;for(Tn(y),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),T=0;T<j;++T)D=A[T],C.touch0&&C.touch0[2]===D.identifier?delete C.touch0:C.touch1&&C.touch1[2]===D.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(D=fe(D,this),Math.hypot(d[0]-D[0],d[1]-D[1])<w)){var F=ce(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return m.wheelDelta=function(y){return arguments.length?(r=typeof y=="function"?y:Ht(+y),m):r},m.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Ht(!!y),m):e},m.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:Ht(!!y),m):o},m.extent=function(y){return arguments.length?(t=typeof y=="function"?y:Ht([[+y[0][0],+y[0][1]],[+y[1][0],+y[1][1]]]),m):t},m.scaleExtent=function(y){return arguments.length?(i[0]=+y[0],i[1]=+y[1],m):[i[0],i[1]]},m.translateExtent=function(y){return arguments.length?(s[0][0]=+y[0][0],s[1][0]=+y[1][0],s[0][1]=+y[0][1],s[1][1]=+y[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(y){return arguments.length?(n=y,m):n},m.duration=function(y){return arguments.length?(a=+y,m):a},m.interpolate=function(y){return arguments.length?(c=y,m):c},m.on=function(){var y=l.on.apply(l,arguments);return y===l?m:y},m.clickDistance=function(y){return arguments.length?(v=(y=+y)*y,m):Math.sqrt(v)},m.tapDistance=function(y){return arguments.length?(w=+y,m):w},m}const me={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},vt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Vi=["Enter"," ","Escape"],Yi={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var nt;(function(e){e.Strict="strict",e.Loose="loose"})(nt||(nt={}));var Ve;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ve||(Ve={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const Xi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var je;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(je||(je={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const eo={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},Wi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Lf=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),dr=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mt=(e,t=[0,0])=>{const{width:n,height:r}=xe(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},Df=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((o,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):dr(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,mn(o,rn(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?yn(r):{x:0,y:0,width:0,height:0}},It=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=mn(n,rn(o)),r=!0)}),r?yn(n):{x:0,y:0,width:0,height:0}},fr=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/o,c=(t.y-r)/o,l=t.width/o,u=t.height/o,d=[];for(const f of e.values()){const{measured:h,selectable:g=!0,hidden:v=!1}=f;if(s&&!g||v)continue;const w=h.width??f.width??f.initialWidth??0,m=h.height??f.height??f.initialHeight??0,{x:b,y:p}=f.internals.positionAbsolute,x=Ui(a,c,l,u,b,p,w,m),_=w*m,S=i&&x>0;(!f.internals.handleBounds||S||x>=_||f.dragging)&&d.push(f)}return d},Rf=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Hf(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let i;if(t!=null&&t.includeHiddenNodes){const{width:s,height:a}=xe(o);i=s>0&&a>0}else i=!!(o.measured.width&&o.measured.height&&!o.hidden);i&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function zf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=Hf(e,s),c=It(a),l=gr(c,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(l,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0}function Gi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??r;let d=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",me.error005());else{const{width:h,height:g}=xe(a);h&&g&&(d=[[c,l],[c+h,l+g]])}else a&&Ge(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const f=Ge(d)?We(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",me.error015())),{position:{x:f.x-c+(s.measured.width??0)*u[0],y:f.y-l+(s.measured.height??0)*u[1]},positionAbsolute:f}}async function Ff({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(v=>v.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),u=Rf(s,c);for(const f of c)a.has(f.id)&&!u.find(g=>g.id===f.id)&&u.push(f);if(!o)return{edges:u,nodes:s};const d=await o({nodes:s,edges:u});return typeof d=="boolean"?d?{edges:u,nodes:s}:{edges:[],nodes:[]}:d}const rt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),We=(e={x:0,y:0},t,n)=>({x:rt(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:rt(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function qi(e,t,n){const{width:r,height:o}=xe(n),{x:i,y:s}=n.internals.positionAbsolute;return We(e,[[i,s],[i+r,s+o]],t)}const to=(e,t,n)=>e<t?rt(Math.abs(e-t),1,t)/t:e>n?-rt(Math.abs(e-n),1,t)/t:0,hr=(e,t,n=15,r=40)=>{const o=to(e.x,r,t.width-r)*n,i=to(e.y,r,t.height-r)*n;return[o,i]},mn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),yn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Et=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=dr(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},rn=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=dr(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Ki=(e,t)=>yn(mn(Zn(e),Zn(t))),Ui=(e,t,n,r,o,i,s,a)=>{const c=Math.max(0,Math.min(e+n,o+s)-Math.max(e,o)),l=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(c*l)},on=(e,t)=>Ui(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),no=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),Zi=(e,t)=>(n,r)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Tt=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?At(a,s):a},ot=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ue(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Bf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ue(e,n),o=Ue(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ue(e.top??e.y??0,n),o=Ue(e.bottom??e.y??0,n),i=Ue(e.left??e.x??0,t),s=Ue(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Vf(e,t,n,r,o,i){const{x:s,y:a}=ot(e,[t,n,r]),{x:c,y:l}=ot({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=o-c,d=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(d)}}const gr=(e,t,n,r,o,i)=>{const s=Bf(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=rt(l,r,o),d=e.x+e.width/2,f=e.y+e.height/2,h=t/2-d*u,g=n/2-f*u,v=Vf(e,h,g,u,t,n),w={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-w.left+w.right,y:g-w.top+w.bottom,zoom:u}},_t=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ge(e){return e!=null&&e!=="parent"}function xe(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Qi(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Ji(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function ro(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Yf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function Xf(e){return{...Yi,...e||{}}}function es(e){return e===null?null:e?"valid":"invalid"}function pt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=Tt({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const pr=e=>({width:e.offsetWidth,height:e.offsetHeight}),ts=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Wf=["INPUT","SELECT","TEXTAREA"];function ns(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Wf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const rs=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=rs(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},oo=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...pr(s)}})};function os({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+o*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+r*.125,u=Math.abs(c-e),d=Math.abs(l-t);return[c,l,u,d]}function zt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function io({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-zt(t-r,i),n];case W.Right:return[t+zt(r-t,i),n];case W.Top:return[t,n-zt(n-o,i)];case W.Bottom:return[t,n+zt(o-n,i)]}}function is({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=io({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[l,u]=io({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,f,h,g]=os({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${r},${o}`,d,f,h,g]}function ss({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,a=r<t?r+s:r-s;return[i,a,o,s]}function Gf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,a=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+a}function qf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=mn(rn(e),rn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return on(s,yn(i))>0}const Kf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Uf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Zf=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",me.error006()),t;const r=n.getEdgeId||Kf;let o;return Wi(e)?o={...e}:o={...e,id:r(e)},Uf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function as({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=ss({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const so={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Qf=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},ao=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Jf({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=so[t],c=so[r],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},d=Qf({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let g=[],v,w;const m={x:0,y:0},b={x:0,y:0},[,,p,x]=ss({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(v=o.x??l.x+(u.x-l.x)*s,w=o.y??(l.y+u.y)/2):(v=o.x??(l.x+u.x)/2,w=o.y??l.y+(u.y-l.y)*s);const M=[{x:v,y:l.y},{x:v,y:u.y}],I=[{x:l.x,y:w},{x:u.x,y:w}];a[f]===h?g=f==="x"?M:I:g=f==="x"?I:M}else{const M=[{x:l.x,y:u.y}],I=[{x:u.x,y:l.y}];if(f==="x"?g=a.x===h?I:M:g=a.y===h?M:I,t===r){const y=Math.abs(e[f]-n[f]);if(y<=i){const N=Math.min(i-1,i-y);a[f]===h?m[f]=(l[f]>e[f]?-1:1)*N:b[f]=(u[f]>n[f]?-1:1)*N}}if(t!==r){const y=f==="x"?"y":"x",N=a[f]===c[y],C=l[y]>u[y],A=l[y]<u[y];(a[f]===1&&(!N&&C||N&&A)||a[f]!==1&&(!N&&A||N&&C))&&(g=f==="x"?M:I)}const z={x:l.x+m.x,y:l.y+m.y},O={x:u.x+b.x,y:u.y+b.y},$=Math.max(Math.abs(z.x-g[0].x),Math.abs(O.x-g[0].x)),P=Math.max(Math.abs(z.y-g[0].y),Math.abs(O.y-g[0].y));$>=P?(v=(z.x+O.x)/2,w=g[0].y):(v=g[0].x,w=(z.y+O.y)/2)}const _={x:l.x+m.x,y:l.y+m.y},S={x:u.x+b.x,y:u.y+b.y};return[[e,..._.x!==g[0].x||_.y!==g[0].y?[_]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],v,w,p,x]}function eh(e,t,n,r){const o=Math.min(ao(e,t)/2,ao(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+o*l},${s}Q ${i},${s} ${i},${s+o*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+o*c}Q ${i},${s} ${i+o*a},${s}`}function Qn({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[d,f,h,g,v]=Jf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let w=`M${d[0].x} ${d[0].y}`;for(let m=1;m<d.length-1;m++)w+=eh(d[m-1],d[m],d[m+1],s);return w+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[w,f,h,g,v]}function co(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function th(e){var d;const{sourceNode:t,targetNode:n}=e;if(!co(t)||!co(n))return null;const r=t.internals.handleBounds||lo(t.handles),o=n.internals.handleBounds||lo(n.handles),i=uo((r==null?void 0:r.source)??[],e.sourceHandle),s=uo(e.connectionMode===nt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(d=e.onError)==null||d.call(e,"008",me.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||W.Bottom,c=(s==null?void 0:s.position)||W.Top,l=qe(t,i,a),u=qe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function lo(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function qe(e,t,n=W.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??xe(e);if(r)return{x:o+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:o+s/2,y:i};case W.Right:return{x:o+s,y:i+a/2};case W.Bottom:return{x:o+s/2,y:i+a};case W.Left:return{x:o,y:i+a/2}}}function uo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Jn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function nh(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const l=Jn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const cs=1e3,rh=10,mr={nodeOrigin:[0,0],nodeExtent:vt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},oh={...mr,checkEquality:!0};function yr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function ih(e,t,n){const r=yr(mr,n);for(const o of e.values())if(o.parentId)wr(o,e,t,r);else{const i=Mt(o,r.nodeOrigin),s=Ge(o.extent)?o.extent:r.nodeExtent,a=We(i,s,xe(o));o.internals.positionAbsolute=a}}function sh(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function xr(e){return e==="manual"}function er(e,t,n,r={}){var u,d;const o=yr(oh,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!xr(o.zIndexMode)?cs:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let h=s.get(f.id);if(o.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const g=Mt(f,o.nodeOrigin),v=Ge(f.extent)?f.extent:o.nodeExtent,w=We(g,v,xe(f));h={...o.defaults,...f,measured:{width:(u=f.measured)==null?void 0:u.width,height:(d=f.measured)==null?void 0:d.height},internals:{positionAbsolute:w,handleBounds:sh(f,h),z:ls(f,a,o.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),f.parentId&&wr(h,t,n,r,i),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function ah(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function wr(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yr(mr,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}ah(e,n),o&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++o.i,u.internals.z=u.internals.z+o.i*rh),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const d=i&&!xr(c)?cs:0,{x:f,y:h,z:g}=ch(e,u,s,a,d,c),{positionAbsolute:v}=e.internals,w=f!==v.x||h!==v.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:v,z:g}})}function ls(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return xr(n)?r:r+(e.selected?t:0)}function ch(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),l=Mt(e,n),u=Ge(e.extent)?We(l,e.extent,c):l;let d=We({x:s+u.x,y:a+u.y},r,c);e.extent==="parent"&&(d=qi(d,c,t));const f=ls(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function vr(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Et(c),u=Ki(l,a.rect);i.set(a.parentId,{expandedRect:u,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var p;const u=c.internals.positionAbsolute,d=xe(c),f=c.origin??r,h=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,g=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,v=Math.max(d.width,Math.round(a.width)),w=Math.max(d.height,Math.round(a.height)),m=(v-d.width)*f[0],b=(w-d.height)*f[1];(h>0||g>0||m||b)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+m,y:c.position.y-g+b}}),(p=n.get(l))==null||p.forEach(x=>{e.some(_=>_.id===x.id)||o.push({id:x.id,type:"position",position:{x:x.position.x+h,y:x.position.y+g}})})),(d.width<a.width||d.height<a.height||h||g)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?f[0]*h-m:0),height:w+(g?f[1]*g-b:0)}})}),o}function lh(e,t,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const v=pr(h.nodeElement),w=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ge(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;if(g.parentId&&g.extent==="parent"){const S=t.get(g.parentId);S&&(x=qi(x,v,S))}else p&&(x=We(x,p,v));const _={...g,measured:v,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:oo("source",h.nodeElement,b,d,g.id),target:oo("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,_),g.parentId&&wr(_,t,n,{nodeOrigin:o,zIndexMode:s}),c=!0,w&&(l.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:Et(_,o)}))}}if(f.length>0){const h=vr(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function uh({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function fo(e,t,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),i){s=`${o}-${e}-${i}`;const l=r.get(s)||new Map;r.set(s,l.set(n,t))}}function us(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},l=`${o}-${s}--${i}-${a}`,u=`${i}-${a}--${o}-${s}`;fo("source",c,u,e,o,s),fo("target",c,l,e,i,a),t.set(r.id,r)}}function ds(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ds(n,t):!1}function ho(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function dh(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!ds(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&o.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function On({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[l,u]of t){const d=(s=n.get(l))==null?void 0:s.internals.userNode;d&&o.push({...d,position:u.position,dragging:r})}if(!e)return[o[0],o];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:o[0],o]}function fh({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function hh({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,h=!1,g=!1,v=null;function w({noDragClassName:b,handleSelector:p,domNode:x,isSelectable:_,nodeId:S,nodeClickDistance:k=0}){f=ce(x);function M({x:$,y:P}){const{nodeLookup:y,nodeExtent:N,snapGrid:C,snapToGrid:A,nodeOrigin:j,onNodeDrag:T,onSelectionDrag:D,onError:F,updateNodePositions:H}=t();i={x:$,y:P};let V=!1;const Y=a.size>1,q=Y&&N?Zn(It(a)):null,J=Y&&A?fh({dragItems:a,snapGrid:C,x:$,y:P}):null;for(const[G,R]of a){if(!y.has(G))continue;let B={x:$-R.distance.x,y:P-R.distance.y};A&&(B=J?{x:Math.round(B.x+J.x),y:Math.round(B.y+J.y)}:At(B,C));let K=null;if(Y&&N&&!R.extent&&q){const{positionAbsolute:Z}=R.internals,Q=Z.x-q.x+N[0][0],ee=Z.x+R.measured.width-q.x2+N[1][0],ne=Z.y-q.y+N[0][1],re=Z.y+R.measured.height-q.y2+N[1][1];K=[[Q,ne],[ee,re]]}const{position:U,positionAbsolute:X}=Gi({nodeId:G,nextPosition:B,nodeLookup:y,nodeExtent:K||N,nodeOrigin:j,onError:F});V=V||R.position.x!==U.x||R.position.y!==U.y,R.position=U,R.internals.positionAbsolute=X}if(g=g||V,!!V&&(H(a,!0),v&&(r||T||!S&&D))){const[G,R]=On({nodeId:S,dragItems:a,nodeLookup:y});r==null||r(v,a,G,R),T==null||T(v,G,R),S||D==null||D(v,R)}}async function I(){if(!u)return;const{transform:$,panBy:P,autoPanSpeed:y,autoPanOnNodeDrag:N}=t();if(!N){c=!1,cancelAnimationFrame(s);return}const[C,A]=hr(l,u,y);(C!==0||A!==0)&&(i.x=(i.x??0)-C/$[2],i.y=(i.y??0)-A/$[2],await P({x:C,y:A})&&M(i)),s=requestAnimationFrame(I)}function z($){var Y;const{nodeLookup:P,multiSelectionActive:y,nodesDraggable:N,transform:C,snapGrid:A,snapToGrid:j,selectNodesOnDrag:T,onNodeDragStart:D,onSelectionDragStart:F,unselectNodesAndEdges:H}=t();d=!0,(!T||!_)&&!y&&S&&((Y=P.get(S))!=null&&Y.selected||H()),_&&T&&S&&(e==null||e(S));const V=pt($.sourceEvent,{transform:C,snapGrid:A,snapToGrid:j,containerBounds:u});if(i=V,a=dh(P,N,V,S),a.size>0&&(n||D||!S&&F)){const[q,J]=On({nodeId:S,dragItems:a,nodeLookup:P});n==null||n($.sourceEvent,a,q,J),D==null||D($.sourceEvent,q,J),S||F==null||F($.sourceEvent,J)}}const O=ki().clickDistance(k).on("start",$=>{const{domNode:P,nodeDragThreshold:y,transform:N,snapGrid:C,snapToGrid:A}=t();u=(P==null?void 0:P.getBoundingClientRect())||null,h=!1,g=!1,v=$.sourceEvent,y===0&&z($),i=pt($.sourceEvent,{transform:N,snapGrid:C,snapToGrid:A,containerBounds:u}),l=pe($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:P,transform:y,snapGrid:N,snapToGrid:C,nodeDragThreshold:A,nodeLookup:j}=t(),T=pt($.sourceEvent,{transform:y,snapGrid:N,snapToGrid:C,containerBounds:u});if(v=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||S&&!j.has(S))&&(h=!0),!h){if(!c&&P&&d&&(c=!0,I()),!d){const D=pe($.sourceEvent,u),F=D.x-l.x,H=D.y-l.y;Math.sqrt(F*F+H*H)>A&&z($)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&a&&d&&(l=pe($.sourceEvent,u),M(T))}}).on("end",$=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:P,updateNodePositions:y,onNodeDragStop:N,onSelectionDragStop:C}=t();if(g&&(y(a,!1),g=!1),o||N||!S&&C){const[A,j]=On({nodeId:S,dragItems:a,nodeLookup:P,dragging:!1});o==null||o($.sourceEvent,a,A,j),N==null||N($.sourceEvent,A,j),S||C==null||C($.sourceEvent,j)}}}).filter($=>{const P=$.target;return!$.button&&(!b||!ho(P,`.${b}`,x))&&(!p||ho(P,p,x))});f.call(O)}function m(){f==null||f.on(".drag",null)}return{update:w,destroy:m}}function gh(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())on(o,Et(i))>0&&r.push(i);return r}const ph=250;function mh(e,t,n,r){var a,c;let o=[],i=1/0;const s=gh(e,n,t+ph);for(const l of s){const u=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of u){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:f,y:h}=qe(l,d,d.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(o=[{...d,x:f,y:h}],i=g):g===i&&o.push({...d,x:f,y:h}))}}if(!o.length)return null;if(o.length>1){const l=r.type==="source"?"target":"source";return o.find(u=>u.type===l)??o[0]}return o[0]}function fs(e,t,n,r,o,i=!1){var l,u,d;const s=r.get(e);if(!s)return null;const a=o==="strict"?(l=s.internals.handleBounds)==null?void 0:l[t]:[...((u=s.internals.handleBounds)==null?void 0:u.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...qe(s,c,c.position,!0)}:c}function hs(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function yh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const gs=()=>!0;function xh(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:v,onConnectEnd:w,isValidConnection:m=gs,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:_,autoPanSpeed:S,dragThreshold:k=1,handleDomNode:M}){const I=ts(e.target);let z=0,O;const{x:$,y:P}=pe(e),y=hs(i,M),N=a==null?void 0:a.getBoundingClientRect();let C=!1;if(!N||!y)return;const A=fs(o,y,r,c,t);if(!A)return;let j=pe(e,N),T=!1,D=null,F=!1,H=null;function V(){if(!u||!N)return;const[U,X]=hr(j,N,S);f({x:U,y:X}),z=requestAnimationFrame(V)}const Y={...A,nodeId:o,type:y,position:A.position},q=c.get(o);let G={inProgress:!0,isValid:null,from:qe(q,Y,W.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:q,to:j,toHandle:null,toPosition:eo[Y.position],toNode:null,pointer:j};function R(){C=!0,p(G),g==null||g(e,{nodeId:o,handleId:r,handleType:y})}k===0&&R();function B(U){if(!C){const{x:re,y:ue}=pe(U),ve=re-$,be=ue-P;if(!(ve*ve+be*be>k*k))return;R()}if(!_()||!Y){K(U);return}const X=x();j=pe(U,N),O=mh(Tt(j,X,!1,[1,1]),n,c,Y),T||(V(),T=!0);const Z=ps(U,{handle:O,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:I,lib:l,flowId:d,nodeLookup:c});H=Z.handleDomNode,D=Z.connection,F=yh(!!O,Z.isValid);const Q=c.get(o),ee=Q?qe(Q,Y,W.Left,!0):G.from,ne={...G,from:ee,isValid:F,to:Z.toHandle&&F?ot({x:Z.toHandle.x,y:Z.toHandle.y},X):j,toHandle:Z.toHandle,toPosition:F&&Z.toHandle?Z.toHandle.position:eo[Y.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:j};p(ne),G=ne}function K(U){if(!("touches"in U&&U.touches.length>0)){if(C){(O||H)&&D&&F&&(v==null||v(D));const{inProgress:X,...Z}=G,Q={...Z,toPosition:G.toHandle?G.toPosition:null};w==null||w(U,Q),i&&(b==null||b(U,Q))}h(),cancelAnimationFrame(z),T=!1,F=!1,D=null,H=null,I.removeEventListener("mousemove",B),I.removeEventListener("mouseup",K),I.removeEventListener("touchmove",B),I.removeEventListener("touchend",K)}}I.addEventListener("mousemove",B),I.addEventListener("mouseup",K),I.addEventListener("touchmove",B),I.addEventListener("touchend",K)}function ps(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=gs,nodeLookup:u}){const d=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=pe(e),v=s.elementFromPoint(h,g),w=v!=null&&v.classList.contains(`${a}-flow__handle`)?v:f,m={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=hs(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),_=w.classList.contains("connectable"),S=w.classList.contains("connectableend");if(!p||!b)return m;const k={source:d?p:r,sourceHandle:d?x:o,target:d?r:p,targetHandle:d?o:x};m.connection=k;const I=_&&S&&(n===nt.Strict?d&&b==="source"||!d&&b==="target":p!==r||x!==o);m.isValid=I&&l(k),m.toHandle=fs(p,b,x,u,n,!0)}return m}const tr={onPointerDown:xh,isValid:ps};function wh({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:d=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const x=n(),_=p.sourceEvent.ctrlKey&&_t()?10:1,S=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*u,k=x[2]*Math.pow(2,S*_);t.scaleTo(k)};let v=[0,0];const w=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(v=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const x=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const _=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],S=[_[0]-v[0],_[1]-v[1]];v=_;const k=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),M={x:x[0]-S[0]*k,y:x[1]-S[1]*k},I=[[0,0],[c,l]];t.setViewportConstrained({x:M.x,y:M.y,zoom:x[2]},I,a)},b=Bi().on("start",w).on("zoom",d?m:null).on("zoom.wheel",f?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:fe}}const xn=e=>({x:e.x,y:e.y,zoom:e.k}),Pn=({x:e,y:t,zoom:n})=>pn.translate(e,t).scale(n),$e=(e,t)=>e.target.closest(`.${t}`),ms=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),vh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,$n=(e,t=0,n=vh,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},ys=e=>{const t=e.ctrlKey&&_t()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function bh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if($e(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(u.ctrlKey&&s){const w=fe(u),m=ys(u),b=d*Math.pow(2,m);r.scaleTo(n,b,w,u);return}const f=u.deltaMode===1?20:1;let h=o===Ve.Vertical?0:u.deltaX*f,g=o===Ve.Horizontal?0:u.deltaY*f;!_t()&&u.shiftKey&&o!==Ve.Vertical&&(h=u.deltaY*f,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const v=xn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c==null||c(u,v):(e.isPanScrolling=!0,a==null||a(u,v)),e.panScrollTimeout=setTimeout(()=>{l==null||l(u,v),e.isPanScrolling=!1},150)}}function Eh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=$e(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function _h({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=xn(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Nh({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&ms(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((a=i.sourceEvent)!=null&&a.internal)&&(o==null||o(i.sourceEvent,xn(i.transform)))}}function Sh({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&ms(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=xn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Ch({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{var m;const h=t||n,g=r&&f.ctrlKey,v=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&($e(f,`${u}-flow__node`)||$e(f,`${u}-flow__edge`)||$e(f,`${u}-flow__selection`)||$e(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!v||$e(f,c)&&v||$e(f,l)&&(!v||i&&v&&!t)||!r&&f.ctrlKey&&v)return!1;if(!r&&f.type==="touchstart"&&((m=f.touches)==null?void 0:m.length)>1)return f.preventDefault(),!1;if(!h&&!i&&!g&&v||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const w=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||v||e)&&w}}function kh({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let d=[[0,0],[u.width,u.height]];const f=typeof ResizeObserver<"u"?new ResizeObserver(P=>{const y=P[0];y&&(d=[[0,0],[y.contentRect.width,y.contentRect.height]])}):null;f==null||f.observe(e);const h=Bi().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);x({x:o.x,y:o.y,zoom:rt(o.zoom,t,n)},[[0,0],[u.width,u.height]],r);const v=g.on("wheel.zoom"),w=g.on("dblclick.zoom");h.wheelDelta(ys);async function m(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).transform($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}function b({noWheelClassName:P,noPanClassName:y,onPaneContextMenu:N,userSelectionActive:C,panOnScroll:A,panOnDrag:j,panOnScrollMode:T,panOnScrollSpeed:D,preventScrolling:F,zoomOnPinch:H,zoomOnScroll:V,zoomOnDoubleClick:Y,panActivationKeyPressed:q=!1,zoomActivationKeyPressed:J,lib:G,onTransformChange:R,connectionInProgress:B,paneClickDistance:K,selectionOnDrag:U}){C&&!l.isZoomingOrPanning&&p();const X=A&&!J&&!C;h.clickDistance(U?1/0:!ge(K)||K<0?0:K);const Z=X?bh({zoomPanValues:l,noWheelClassName:P,d3Selection:g,d3Zoom:h,panOnScrollMode:T,panOnScrollSpeed:D,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Eh({noWheelClassName:P,preventScrolling:F,d3ZoomHandler:v});g.on("wheel.zoom",Z,{passive:!1});const Q=_h({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",Q);const ee=Nh({zoomPanValues:l,panOnDrag:j,onPaneContextMenu:!!N,onPanZoom:i,onTransformChange:R});h.on("zoom",ee);const ne=Sh({zoomPanValues:l,panOnDrag:j,panOnScroll:A,onPaneContextMenu:N,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=Ch({panActivationKeyPressed:q,zoomActivationKeyPressed:J,panOnDrag:j,zoomOnScroll:V,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:H,userSelectionActive:C,noPanClassName:y,noWheelClassName:P,lib:G,connectionInProgress:B});h.filter(re),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function p(){h.on("zoom",null)}async function x(P,y,N){const C=Pn(P),A=h==null?void 0:h.constrain()(C,y,N);return A&&await m(A),A}async function _(P,y){const N=Pn(P);return await m(N,y),N}function S(P){if(g){const y=Pn(P),N=g.property("__zoom");(N.k!==P.zoom||N.x!==P.x||N.y!==P.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function k(){const P=g?Fi(g.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}async function M(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).scaleTo($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}async function I(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).scaleBy($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}function z(P){h==null||h.scaleExtent(P)}function O(P){h==null||h.translateExtent(P)}function $(P){const y=!ge(P)||P<0?0:P;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:_,setViewportConstrained:x,getViewport:k,scaleTo:M,scaleBy:I,setScaleExtent:z,setTranslateExtent:O,syncViewport:S,setClickDistance:$}}var it;(function(e){e.Line="line",e.Handle="handle"})(it||(it={}));function Mh({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,a=n-r,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function go(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Oe(e,t){return Math.max(0,t-e)}function Pe(e,t){return Math.max(0,e-t)}function Ft(e,t,n){return Math.max(0,t-e,e-n)}function po(e,t){return e?!t:t}function Ih(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:h,ySnapped:g}=n,{minWidth:v,maxWidth:w,minHeight:m,maxHeight:b}=r,{x:p,y:x,width:_,height:S,aspectRatio:k}=e;let M=Math.floor(u?h-e.pointerX:0),I=Math.floor(d?g-e.pointerY:0);const z=_+(c?-M:M),O=S+(l?-I:I),$=-i[0]*_,P=-i[1]*S;let y=Ft(z,v,w),N=Ft(O,m,b);if(s){let j=0,T=0;c&&M<0?j=Oe(p+M+$,s[0][0]):!c&&M>0&&(j=Pe(p+z+$,s[1][0])),l&&I<0?T=Oe(x+I+P,s[0][1]):!l&&I>0&&(T=Pe(x+O+P,s[1][1])),y=Math.max(y,j),N=Math.max(N,T)}if(a){let j=0,T=0;c&&M>0?j=Pe(p+M,a[0][0]):!c&&M<0&&(j=Oe(p+z,a[1][0])),l&&I>0?T=Pe(x+I,a[0][1]):!l&&I<0&&(T=Oe(x+O,a[1][1])),y=Math.max(y,j),N=Math.max(N,T)}if(o){if(u){const j=Ft(z/k,m,b)*k;if(y=Math.max(y,j),s){let T=0;!c&&!l||c&&!l&&f?T=Pe(x+P+z/k,s[1][1])*k:T=Oe(x+P+(c?M:-M)/k,s[0][1])*k,y=Math.max(y,T)}if(a){let T=0;!c&&!l||c&&!l&&f?T=Oe(x+z/k,a[1][1])*k:T=Pe(x+(c?M:-M)/k,a[0][1])*k,y=Math.max(y,T)}}if(d){const j=Ft(O*k,v,w)/k;if(N=Math.max(N,j),s){let T=0;!c&&!l||l&&!c&&f?T=Pe(p+O*k+$,s[1][0])/k:T=Oe(p+(l?I:-I)*k+$,s[0][0])/k,N=Math.max(N,T)}if(a){let T=0;!c&&!l||l&&!c&&f?T=Oe(p+O*k,a[1][0])/k:T=Pe(p+(l?I:-I)*k,a[0][0])/k,N=Math.max(N,T)}}}I=I+(I<0?N:-N),M=M+(M<0?y:-y),o&&(f?z>O*k?I=(po(c,l)?-M:M)/k:M=(po(c,l)?-I:I)*k:u?(I=M/k,l=c):(M=I*k,c=l));const C=c?p+M:p,A=l?x+I:x;return{width:_+(c?-M:M),height:S+(l?-I:I),x:i[0]*M*(c?-1:1)+C,y:i[1]*I*(l?-1:1)+A}}const xs={width:0,height:0,x:0,y:0},Ah={...xs,pointerX:0,pointerY:0,aspectRatio:1};function Th(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[r-a,o-c],[r+i-a,o+s-c]]}function Oh({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:go("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:w}){let m={...xs},b={...Ah};s={boundaries:u,resizeDirection:f,keepAspectRatio:d,controlDirection:go(l)};let p,x=null,_=[],S,k,M,I=!1;const z=ki().on("start",O=>{const{nodeLookup:$,transform:P,snapGrid:y,snapToGrid:N,nodeOrigin:C,paneDomNode:A}=n();if(p=$.get(t),!p)return;x=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:j,ySnapped:T}=pt(O.sourceEvent,{transform:P,snapGrid:y,snapToGrid:N,containerBounds:x});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:j,pointerY:T,aspectRatio:m.width/m.height},S=void 0,k=Ge(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(S=$.get(p.parentId)),S&&p.extent==="parent"&&(k=[[0,0],[S.measured.width,S.measured.height]]),_=[],M=void 0;for(const[D,F]of $)if(F.parentId===t&&(_.push({id:D,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const H=Th(F,p,F.origin??C);M?M=[[Math.min(H[0][0],M[0][0]),Math.min(H[0][1],M[0][1])],[Math.max(H[1][0],M[1][0]),Math.max(H[1][1],M[1][1])]]:M=H}h==null||h(O,{...m})}).on("drag",O=>{const{transform:$,snapGrid:P,snapToGrid:y,nodeOrigin:N}=n(),C=pt(O.sourceEvent,{transform:$,snapGrid:P,snapToGrid:y,containerBounds:x}),A=[];if(!p)return;const{x:j,y:T,width:D,height:F}=m,H={},V=p.origin??N,{width:Y,height:q,x:J,y:G}=Ih(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,V,k,M),R=Y!==D,B=q!==F,K=J!==j&&R,U=G!==T&&B;if(!K&&!U&&!R&&!B)return;if((K||U||V[0]===1||V[1]===1)&&(H.x=K?J:m.x,H.y=U?G:m.y,m.x=H.x,m.y=H.y,_.length>0)){const ee=J-j,ne=G-T;for(const re of _)re.position={x:re.position.x-ee+V[0]*(Y-D),y:re.position.y-ne+V[1]*(q-F)},A.push(re)}if((R||B)&&(H.width=R&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:m.width,H.height=B&&(!s.resizeDirection||s.resizeDirection==="vertical")?q:m.height,m.width=H.width,m.height=H.height),S&&p.expandParent){const ee=V[0]*(H.width??0);H.x&&H.x<ee&&(m.x=ee,b.x=b.x-(H.x-ee));const ne=V[1]*(H.height??0);H.y&&H.y<ne&&(m.y=ne,b.y=b.y-(H.y-ne))}const X=Mh({width:m.width,prevWidth:D,height:m.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),Z={...m,direction:X};(w==null?void 0:w(O,Z))!==!1&&(I=!0,g==null||g(O,Z),r(H,A))}).on("end",O=>{I&&(v==null||v(O,{...m}),o==null||o({...m}),I=!1)});i.call(z)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}const Ph={},mo=e=>{let t;const n=new Set,r=(u,d)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Ph?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(r,o,c);return c},$h=e=>e?mo(e):mo,{useDebugValue:jh}=Lc,{useSyncExternalStoreWithSelector:Lh}=jc,Dh=e=>e;function ws(e,t=Dh,n){const r=Lh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return jh(r),r}const yo=(e,t)=>{const n=$h(e),r=(o,i=t)=>ws(n,o,i);return Object.assign(r,n),r},Rh=(e,t)=>e?yo(e,t):yo;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const wn=L.createContext(null),Hh=wn.Provider,vs=me.error001("react");function te(e,t){const n=L.useContext(wn);if(n===null)throw new Error(vs);return ws(n,e,t)}function oe(){const e=L.useContext(wn);if(e===null)throw new Error(vs);return L.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const xo={display:"none"},zh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},bs="react-flow__node-desc",Es="react-flow__edge-desc",Fh="react-flow__aria-live",Bh=e=>e.ariaLiveMessage,Vh=e=>e.ariaLabelConfig;function Yh({rfId:e}){const t=te(Bh);return E.jsx("div",{id:`${Fh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:zh,children:t})}function Xh({rfId:e,disableKeyboardA11y:t}){const n=te(Vh);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${bs}-${e}`,style:xo,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${Es}-${e}`,style:xo,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(Yh,{rfId:e})]})}const vn=L.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return E.jsx("div",{className:se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});vn.displayName="Panel";const wo="https://reactflow.dev?utm_source=attribution";function Wh({proOptions:e,position:t="bottom-right"}){return L.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:E.jsx(vn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${wo}`,children:E.jsx("a",{href:wo,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Gh=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Bt=e=>e.id;function qh(e,t){return ie(e.selectedNodes.map(Bt),t.selectedNodes.map(Bt))&&ie(e.selectedEdges.map(Bt),t.selectedEdges.map(Bt))}function Kh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=te(Gh,qh);return L.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const Uh=e=>!!e.onSelectionChangeHandlers;function Zh({onSelectionChange:e}){const t=te(Uh);return e||t?E.jsx(Kh,{onSelectionChange:e}):null}const _s=[0,0],Qh={x:0,y:0,zoom:1},Jh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],vo=[...Jh,"rfId"],eg=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),bo={translateExtent:vt,nodeOrigin:_s,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function tg(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(eg,ie),l=oe();L.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=bo,a()}),[]);const u=L.useRef(bo);return L.useEffect(()=>{for(const d of vo){const f=e[d],h=u.current[d];f!==h&&(typeof e[d]>"u"||(d==="nodes"?t(f):d==="edges"?n(f):d==="minZoom"?r(f):d==="maxZoom"?o(f):d==="translateExtent"?i(f):d==="nodeExtent"?s(f):d==="ariaLabelConfig"?l.setState({ariaLabelConfig:Xf(f)}):d==="fitView"?l.setState({fitViewQueued:f}):d==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[d]:f})))}u.current=e},vo.map(d=>e[d])),null}function Eo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function ng(e){var r;const[t,n]=L.useState(e==="system"?null:e);return L.useEffect(()=>{if(e!=="system"){n(e);return}const o=Eo(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=Eo())!=null&&r.matches?"dark":"light"}const _o=typeof document<"u"?document:null;function Nt(e=null,t={target:_o,actInsideInputWithModifier:!0}){const[n,r]=L.useState(!1),o=L.useRef(!1),i=L.useRef(new Set([])),[s,a]=L.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace(/\+/g,`
|
|
1
|
+
import{a0 as jc,a1 as Lc,r as L,j as E,P as Dc,n as Rc,c as Hc,a2 as zc,p as Fc,a3 as Lr,a4 as Bc,a5 as Vc,G as Yc,y as Xc,a6 as Wc,a7 as Gc,a8 as qc,T as Kc,a as Uc,I as Zc,b as Qc,a9 as Jc,aa as el,ab as tl}from"./index-BW17AtYZ.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var nl={value:()=>{}};function dn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Yt(n)}function Yt(e){this._=e}function rl(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Yt.prototype=dn.prototype={constructor:Yt,on:function(e,t){var n=this._,r=rl(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=ol(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=Dr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Dr(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Yt(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function ol(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function Dr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=nl,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Vn="http://www.w3.org/1999/xhtml";const Rr={svg:"http://www.w3.org/2000/svg",xhtml:Vn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function fn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Rr.hasOwnProperty(t)?{space:Rr[t],local:e}:e}function il(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Vn&&t.documentElement.namespaceURI===Vn?t.createElement(e):t.createElementNS(n,e)}}function sl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hi(e){var t=fn(e);return(t.local?sl:il)(t)}function al(){}function or(e){return e==null?al:function(){return this.querySelector(e)}}function cl(e){typeof e!="function"&&(e=or(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new le(r,this._parents)}function ll(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ul(){return[]}function gi(e){return e==null?ul:function(){return this.querySelectorAll(e)}}function dl(e){return function(){return ll(e.apply(this,arguments))}}function fl(e){typeof e=="function"?e=dl(e):e=gi(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(r.push(e.call(c,c.__data__,l,s)),o.push(c));return new le(r,o)}function pi(e){return function(){return this.matches(e)}}function mi(e){return function(t){return t.matches(e)}}var hl=Array.prototype.find;function gl(e){return function(){return hl.call(this.children,e)}}function pl(){return this.firstElementChild}function ml(e){return this.select(e==null?pl:gl(typeof e=="function"?e:mi(e)))}var yl=Array.prototype.filter;function xl(){return Array.from(this.children)}function wl(e){return function(){return yl.call(this.children,e)}}function vl(e){return this.selectAll(e==null?xl:wl(typeof e=="function"?e:mi(e)))}function bl(e){typeof e!="function"&&(e=pi(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new le(r,this._parents)}function yi(e){return new Array(e.length)}function El(){return new le(this._enter||this._groups.map(yi),this._parents)}function Kt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kt.prototype={constructor:Kt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function _l(e){return function(){return e}}function Nl(e,t,n,r,o,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new Kt(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Sl(e,t,n,r,o,i,s){var a,c,l=new Map,u=t.length,d=i.length,f=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(f[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?o[a]=c:l.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(r[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new Kt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function Cl(e){return e.__data__}function kl(e,t){if(!arguments.length)return Array.from(this,Cl);var n=t?Sl:Nl,r=this._parents,o=this._groups;typeof e!="function"&&(e=_l(e));for(var i=o.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=r[l],d=o[l],f=d.length,h=Ml(e.call(u,u&&u.__data__,l,r)),g=h.length,v=a[l]=new Array(g),w=s[l]=new Array(g),m=c[l]=new Array(f);n(u,d,v,w,m,h,t);for(var b=0,p=0,x,_;b<g;++b)if(x=v[b]){for(b>=p&&(p=b+1);!(_=w[p])&&++p<g;);x._next=_||null}}return s=new le(s,r),s._enter=a,s._exit=c,s}function Ml(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Il(){return new le(this._exit||this._groups.map(yi),this._parents)}function Al(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function Tl(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),c=0;c<s;++c)for(var l=n[c],u=r[c],d=l.length,f=a[c]=new Array(d),h,g=0;g<d;++g)(h=l[g]||u[g])&&(f[g]=h);for(;c<o;++c)a[c]=n[c];return new le(a,this._parents)}function Ol(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Pl(e){e||(e=$l);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],a=s.length,c=o[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new le(o,this._parents).order()}function $l(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function jl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ll(){return Array.from(this)}function Dl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function Rl(){let e=0;for(const t of this)++e;return e}function Hl(){return!this.node()}function zl(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&e.call(a,a.__data__,i,o);return this}function Fl(e){return function(){this.removeAttribute(e)}}function Bl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Vl(e,t){return function(){this.setAttribute(e,t)}}function Yl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Xl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Wl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Gl(e,t){var n=fn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Bl:Fl:typeof t=="function"?n.local?Wl:Xl:n.local?Yl:Vl)(n,t))}function xi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ql(e){return function(){this.style.removeProperty(e)}}function Kl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Ul(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Zl(e,t,n){return arguments.length>1?this.each((t==null?ql:typeof t=="function"?Ul:Kl)(e,t,n??"")):et(this.node(),e)}function et(e,t){return e.style.getPropertyValue(t)||xi(e).getComputedStyle(e,null).getPropertyValue(t)}function Ql(e){return function(){delete this[e]}}function Jl(e,t){return function(){this[e]=t}}function eu(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function tu(e,t){return arguments.length>1?this.each((t==null?Ql:typeof t=="function"?eu:Jl)(e,t)):this.node()[e]}function wi(e){return e.trim().split(/^|\s+/)}function ir(e){return e.classList||new vi(e)}function vi(e){this._node=e,this._names=wi(e.getAttribute("class")||"")}vi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function bi(e,t){for(var n=ir(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Ei(e,t){for(var n=ir(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function nu(e){return function(){bi(this,e)}}function ru(e){return function(){Ei(this,e)}}function ou(e,t){return function(){(t.apply(this,arguments)?bi:Ei)(this,e)}}function iu(e,t){var n=wi(e+"");if(arguments.length<2){for(var r=ir(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?ou:t?nu:ru)(n,t))}function su(){this.textContent=""}function au(e){return function(){this.textContent=e}}function cu(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function lu(e){return arguments.length?this.each(e==null?su:(typeof e=="function"?cu:au)(e)):this.node().textContent}function uu(){this.innerHTML=""}function du(e){return function(){this.innerHTML=e}}function fu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function hu(e){return arguments.length?this.each(e==null?uu:(typeof e=="function"?fu:du)(e)):this.node().innerHTML}function gu(){this.nextSibling&&this.parentNode.appendChild(this)}function pu(){return this.each(gu)}function mu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function yu(){return this.each(mu)}function xu(e){var t=typeof e=="function"?e:hi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function wu(){return null}function vu(e,t){var n=typeof e=="function"?e:hi(e),r=t==null?wu:typeof t=="function"?t:or(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function bu(){var e=this.parentNode;e&&e.removeChild(this)}function Eu(){return this.each(bu)}function _u(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Nu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Su(e){return this.select(e?Nu:_u)}function Cu(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ku(e){return function(t){e.call(this,t,this.__data__)}}function Mu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Iu(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function Au(e,t,n){return function(){var r=this.__on,o,i=ku(t);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function Tu(e,t,n){var r=Mu(e+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(o=0,u=a[c];o<i;++o)if((s=r[o]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Au:Iu,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function _i(e,t,n){var r=xi(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Ou(e,t){return function(){return _i(this,e,t)}}function Pu(e,t){return function(){return _i(this,e,t.apply(this,arguments))}}function $u(e,t){return this.each((typeof t=="function"?Pu:Ou)(e,t))}function*ju(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var Ni=[null];function le(e,t){this._groups=e,this._parents=t}function Ct(){return new le([[document.documentElement]],Ni)}function Lu(){return this}le.prototype=Ct.prototype={constructor:le,select:cl,selectAll:fl,selectChild:ml,selectChildren:vl,filter:bl,data:kl,enter:El,exit:Il,join:Al,merge:Tl,selection:Lu,order:Ol,sort:Pl,call:jl,nodes:Ll,node:Dl,size:Rl,empty:Hl,each:zl,attr:Gl,style:Zl,property:tu,classed:iu,text:lu,html:hu,raise:pu,lower:yu,append:xu,insert:vu,remove:Eu,clone:Su,datum:Cu,on:Tu,dispatch:$u,[Symbol.iterator]:ju};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],Ni)}function Du(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=Du(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ru={passive:!1},mt={capture:!0,passive:!1};function Mn(e){e.stopImmediatePropagation()}function Qe(e){e.preventDefault(),e.stopImmediatePropagation()}function Si(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Qe,mt);"onselectstart"in t?n.on("selectstart.drag",Qe,mt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ci(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Qe,mt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const jt=e=>()=>e;function Yn(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Yn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Hu(e){return!e.ctrlKey&&!e.button}function zu(){return this.parentNode}function Fu(e,t){return t??{x:e.x,y:e.y}}function Bu(){return navigator.maxTouchPoints||"ontouchstart"in this}function ki(){var e=Hu,t=zu,n=Fu,r=Bu,o={},i=dn("start","drag","end"),s=0,a,c,l,u,d=0;function f(x){x.on("mousedown.drag",h).filter(r).on("touchstart.drag",w).on("touchmove.drag",m,Ru).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,_){if(!(u||!e.call(this,x,_))){var S=p(this,t.call(this,x,_),x,_,"mouse");S&&(ce(x.view).on("mousemove.drag",g,mt).on("mouseup.drag",v,mt),Si(x.view),Mn(x),l=!1,a=x.clientX,c=x.clientY,S("start",x))}}function g(x){if(Qe(x),!l){var _=x.clientX-a,S=x.clientY-c;l=_*_+S*S>d}o.mouse("drag",x)}function v(x){ce(x.view).on("mousemove.drag mouseup.drag",null),Ci(x.view,l),Qe(x),o.mouse("end",x)}function w(x,_){if(e.call(this,x,_)){var S=x.changedTouches,k=t.call(this,x,_),M=S.length,I,z;for(I=0;I<M;++I)(z=p(this,k,x,_,S[I].identifier,S[I]))&&(Mn(x),z("start",x,S[I]))}}function m(x){var _=x.changedTouches,S=_.length,k,M;for(k=0;k<S;++k)(M=o[_[k].identifier])&&(Qe(x),M("drag",x,_[k]))}function b(x){var _=x.changedTouches,S=_.length,k,M;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),k=0;k<S;++k)(M=o[_[k].identifier])&&(Mn(x),M("end",x,_[k]))}function p(x,_,S,k,M,I){var z=i.copy(),O=fe(I||S,_),$,P,y;if((y=n.call(x,new Yn("beforestart",{sourceEvent:S,target:f,identifier:M,active:s,x:O[0],y:O[1],dx:0,dy:0,dispatch:z}),k))!=null)return $=y.x-O[0]||0,P=y.y-O[1]||0,function N(C,A,j){var T=O,D;switch(C){case"start":o[M]=N,D=s++;break;case"end":delete o[M],--s;case"drag":O=fe(j||A,_),D=s;break}z.call(C,x,new Yn(C,{sourceEvent:A,subject:y,target:f,identifier:M,active:D,x:O[0]+$,y:O[1]+P,dx:O[0]-T[0],dy:O[1]-T[1],dispatch:z}),k)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:jt(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:jt(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:jt(x),f):n},f.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:jt(!!x),f):r},f.on=function(){var x=i.on.apply(i,arguments);return x===i?f:x},f.clickDistance=function(x){return arguments.length?(d=(x=+x)*x,f):Math.sqrt(d)},f}function sr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Mi(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function kt(){}var yt=.7,Ut=1/yt,Je="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Vu=/^#([0-9a-f]{3,8})$/,Yu=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Xu=new RegExp(`^rgb\\(${Ne},${Ne},${Ne}\\)$`),Wu=new RegExp(`^rgba\\(${Je},${Je},${Je},${xt}\\)$`),Gu=new RegExp(`^rgba\\(${Ne},${Ne},${Ne},${xt}\\)$`),qu=new RegExp(`^hsl\\(${xt},${Ne},${Ne}\\)$`),Ku=new RegExp(`^hsla\\(${xt},${Ne},${Ne},${xt}\\)$`),Hr={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};sr(kt,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:zr,formatHex:zr,formatHex8:Uu,formatHsl:Zu,formatRgb:Fr,toString:Fr});function zr(){return this.rgb().formatHex()}function Uu(){return this.rgb().formatHex8()}function Zu(){return Ii(this).formatHsl()}function Fr(){return this.rgb().formatRgb()}function Ye(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Vu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Br(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Lt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Lt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Yu.exec(e))?new ae(t[1],t[2],t[3],1):(t=Xu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Wu.exec(e))?Lt(t[1],t[2],t[3],t[4]):(t=Gu.exec(e))?Lt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=qu.exec(e))?Xr(t[1],t[2]/100,t[3]/100,1):(t=Ku.exec(e))?Xr(t[1],t[2]/100,t[3]/100,t[4]):Hr.hasOwnProperty(e)?Br(Hr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function Br(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Lt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function Qu(e){return e instanceof kt||(e=Ye(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Xn(e,t,n,r){return arguments.length===1?Qu(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}sr(ae,Xn,Mi(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?yt:Math.pow(yt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Be(this.r),Be(this.g),Be(this.b),Zt(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:Vr,formatHex:Vr,formatHex8:Ju,formatRgb:Yr,toString:Yr}));function Vr(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}`}function Ju(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}${Fe((isNaN(this.opacity)?1:this.opacity)*255)}`}function Yr(){const e=Zt(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Zt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Be(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fe(e){return e=Be(e),(e<16?"0":"")+e.toString(16)}function Xr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,n,r)}function Ii(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof kt||(e=Ye(e)),!e)return new he;if(e instanceof he)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,a=i-o,c=(i+o)/2;return a?(t===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+o:2-i-o,s*=60):a=c>0&&c<1?0:s,new he(s,a,c,e.opacity)}function ed(e,t,n,r){return arguments.length===1?Ii(e):new he(e,t,n,r??1)}function he(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}sr(he,ed,Mi(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?yt:Math.pow(yt,e),new he(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new ae(In(e>=240?e-240:e+120,o,r),In(e,o,r),In(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(Wr(this.h),Dt(this.s),Dt(this.l),Zt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Zt(this.opacity);return`${e===1?"hsl(":"hsla("}${Wr(this.h)}, ${Dt(this.s)*100}%, ${Dt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Wr(e){return e=(e||0)%360,e<0?e+360:e}function Dt(e){return Math.max(0,Math.min(1,e||0))}function In(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ar=e=>()=>e;function td(e,t){return function(n){return e+n*t}}function nd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function rd(e){return(e=+e)==1?Ai:function(t,n){return n-t?nd(t,n,e):ar(isNaN(t)?n:t)}}function Ai(e,t){var n=t-e;return n?td(e,n):ar(isNaN(e)?t:e)}const Qt=(function e(t){var n=rd(t);function r(o,i){var s=n((o=Xn(o)).r,(i=Xn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),l=Ai(o.opacity,i.opacity);return function(u){return o.r=s(u),o.g=a(u),o.b=c(u),o.opacity=l(u),o+""}}return r.gamma=e,r})(1);function od(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function id(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function sd(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=gt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function ad(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ee(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function cd(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=gt(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Wn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,An=new RegExp(Wn.source,"g");function ld(e){return function(){return e}}function ud(e){return function(t){return e(t)+""}}function Ti(e,t){var n=Wn.lastIndex=An.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Wn.exec(e))&&(o=An.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(r=r[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,c.push({i:s,x:Ee(r,o)})),n=An.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?ud(c[0].x):ld(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)a[(d=c[u]).i]=d.x(l);return a.join("")})}function gt(e,t){var n=typeof t,r;return t==null||n==="boolean"?ar(t):(n==="number"?Ee:n==="string"?(r=Ye(t))?(t=r,Qt):Ti:t instanceof Ye?Qt:t instanceof Date?ad:id(t)?od:Array.isArray(t)?sd:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?cd:Ee)(e,t)}var Gr=180/Math.PI,Gn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Oi(e,t,n,r,o,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*Gr,skewX:Math.atan(c)*Gr,scaleX:s,scaleY:a}}var Rt;function dd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Gn:Oi(t.a,t.b,t.c,t.d,t.e,t.f)}function fd(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Gn:(e=e.matrix,Oi(e.a,e.b,e.c,e.d,e.e,e.f))}function Pi(e,t,n,r){function o(l){return l.length?l.pop()+" ":""}function i(l,u,d,f,h,g){if(l!==d||u!==f){var v=h.push("translate(",null,t,null,n);g.push({i:v-4,x:Ee(l,d)},{i:v-2,x:Ee(u,f)})}else(d||f)&&h.push("translate("+d+t+f+n)}function s(l,u,d,f){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),f.push({i:d.push(o(d)+"rotate(",null,r)-2,x:Ee(l,u)})):u&&d.push(o(d)+"rotate("+u+r)}function a(l,u,d,f){l!==u?f.push({i:d.push(o(d)+"skewX(",null,r)-2,x:Ee(l,u)}):u&&d.push(o(d)+"skewX("+u+r)}function c(l,u,d,f,h,g){if(l!==d||u!==f){var v=h.push(o(h)+"scale(",null,",",null,")");g.push({i:v-4,x:Ee(l,d)},{i:v-2,x:Ee(u,f)})}else(d!==1||f!==1)&&h.push(o(h)+"scale("+d+","+f+")")}return function(l,u){var d=[],f=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,d,f),s(l.rotate,u.rotate,d,f),a(l.skewX,u.skewX,d,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,f),l=u=null,function(h){for(var g=-1,v=f.length,w;++g<v;)d[(w=f[g]).i]=w.x(h);return d.join("")}}}var hd=Pi(dd,"px, ","px)","deg)"),gd=Pi(fd,", ",")",")"),pd=1e-12;function qr(e){return((e=Math.exp(e))+1/e)/2}function md(e){return((e=Math.exp(e))-1/e)/2}function yd(e){return((e=Math.exp(2*e))-1)/(e+1)}const Xt=(function e(t,n,r){function o(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],d=s[1],f=s[2],h=u-a,g=d-c,v=h*h+g*g,w,m;if(v<pd)m=Math.log(f/l)/t,w=function(k){return[a+k*h,c+k*g,l*Math.exp(t*k*m)]};else{var b=Math.sqrt(v),p=(f*f-l*l+r*v)/(2*l*n*b),x=(f*f-l*l-r*v)/(2*f*n*b),_=Math.log(Math.sqrt(p*p+1)-p),S=Math.log(Math.sqrt(x*x+1)-x);m=(S-_)/t,w=function(k){var M=k*m,I=qr(_),z=l/(n*b)*(I*yd(t*M+_)-md(_));return[a+z*h,c+z*g,l*I/qr(t*M+_)]}}return w.duration=m*1e3*t/Math.SQRT2,w}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},o})(Math.SQRT2,2,4);var tt=0,dt=0,lt=0,$i=1e3,Jt,ft,en=0,Xe=0,hn=0,wt=typeof performance=="object"&&performance.now?performance:Date,ji=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function cr(){return Xe||(ji(xd),Xe=wt.now()+hn)}function xd(){Xe=0}function tn(){this._call=this._time=this._next=null}tn.prototype=Li.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?cr():+n)+(t==null?0:+t),!this._next&&ft!==this&&(ft?ft._next=this:Jt=this,ft=this),this._call=e,this._time=n,qn()},stop:function(){this._call&&(this._call=null,this._time=1/0,qn())}};function Li(e,t,n){var r=new tn;return r.restart(e,t,n),r}function wd(){cr(),++tt;for(var e=Jt,t;e;)(t=Xe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tt}function Kr(){Xe=(en=wt.now())+hn,tt=dt=0;try{wd()}finally{tt=0,bd(),Xe=0}}function vd(){var e=wt.now(),t=e-en;t>$i&&(hn-=t,en=e)}function bd(){for(var e,t=Jt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);ft=e,qn(r)}function qn(e){if(!tt){dt&&(dt=clearTimeout(dt));var t=e-Xe;t>24?(e<1/0&&(dt=setTimeout(Kr,e-wt.now()-hn)),lt&&(lt=clearInterval(lt))):(lt||(en=wt.now(),lt=setInterval(vd,$i)),tt=1,ji(Kr))}}function Ur(e,t,n){var r=new tn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Ed=dn("start","end","cancel","interrupt"),_d=[],Di=0,Zr=1,Kn=2,Wt=3,Qr=4,Un=5,Gt=6;function gn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Nd(e,n,{name:t,index:r,group:o,on:Ed,tween:_d,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Di})}function lr(e,t){var n=ye(e,t);if(n.state>Di)throw new Error("too late; already scheduled");return n}function Se(e,t){var n=ye(e,t);if(n.state>Wt)throw new Error("too late; already running");return n}function ye(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Nd(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Li(i,0,n.time);function i(l){n.state=Zr,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,d,f,h;if(n.state!==Zr)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Wt)return Ur(s);h.state===Qr?(h.state=Gt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=Gt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(Ur(function(){n.state===Wt&&(n.state=Qr,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Kn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Kn){for(n.state=Wt,o=new Array(f=n.tween.length),u=0,d=-1;u<f;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=h);o.length=d+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Un,1),d=-1,f=o.length;++d<f;)o[d].call(e,u);n.state===Un&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Gt,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function qt(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Kn&&r.state<Un,r.state=Gt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Sd(e){return this.each(function(){qt(this,e)})}function Cd(e,t){var n,r;return function(){var o=Se(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function kd(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Se(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:t,value:n},c=0,l=o.length;c<l;++c)if(o[c].name===t){o[c]=a;break}c===l&&o.push(a)}i.tween=o}}function Md(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ye(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?Cd:kd)(n,e,t))}function ur(e,t,n){var r=e._id;return e.each(function(){var o=Se(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ye(o,r).value[t]}}function Ri(e,t){var n;return(typeof t=="number"?Ee:t instanceof Ye?Qt:(n=Ye(t))?(t=n,Qt):Ti)(e,t)}function Id(e){return function(){this.removeAttribute(e)}}function Ad(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Td(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function Od(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function Pd(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function $d(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function jd(e,t){var n=fn(e),r=n==="transform"?gd:Ri;return this.attrTween(e,typeof t=="function"?(n.local?$d:Pd)(n,r,ur(this,"attr."+e,t)):t==null?(n.local?Ad:Id)(n):(n.local?Od:Td)(n,r,t))}function Ld(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Dd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Rd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Dd(e,i)),n}return o._value=t,o}function Hd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Ld(e,i)),n}return o._value=t,o}function zd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=fn(e);return this.tween(n,(r.local?Rd:Hd)(r,t))}function Fd(e,t){return function(){lr(this,e).delay=+t.apply(this,arguments)}}function Bd(e,t){return t=+t,function(){lr(this,e).delay=t}}function Vd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Fd:Bd)(t,e)):ye(this.node(),t).delay}function Yd(e,t){return function(){Se(this,e).duration=+t.apply(this,arguments)}}function Xd(e,t){return t=+t,function(){Se(this,e).duration=t}}function Wd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Yd:Xd)(t,e)):ye(this.node(),t).duration}function Gd(e,t){if(typeof t!="function")throw new Error;return function(){Se(this,e).ease=t}}function qd(e){var t=this._id;return arguments.length?this.each(Gd(t,e)):ye(this.node(),t).ease}function Kd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Se(this,e).ease=n}}function Ud(e){if(typeof e!="function")throw new Error;return this.each(Kd(this._id,e))}function Zd(e){typeof e!="function"&&(e=pi(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Te(r,this._parents,this._name,this._id)}function Qd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,d=s[a]=new Array(u),f,h=0;h<u;++h)(f=c[h]||l[h])&&(d[h]=f);for(;a<r;++a)s[a]=t[a];return new Te(s,this._parents,this._name,this._id)}function Jd(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function ef(e,t,n){var r,o,i=Jd(t)?lr:Se;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function tf(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(ef(n,e,t))}function nf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function rf(){return this.on("end.remove",nf(this._id))}function of(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],c=a.length,l=i[s]=new Array(c),u,d,f=0;f<c;++f)(u=a[f])&&(d=e.call(u,u.__data__,f,a))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d,gn(l[f],t,n,f,l,ye(u,n)));return new Te(i,this._parents,t,n)}function sf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=gi(e));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var c=r[a],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),h,g=ye(u,n),v=0,w=f.length;v<w;++v)(h=f[v])&&gn(h,t,n,v,f,g);i.push(f),s.push(u)}return new Te(i,s,t,n)}var af=Ct.prototype.constructor;function cf(){return new af(this._groups,this._parents)}function lf(e,t){var n,r,o;return function(){var i=et(this,e),s=(this.style.removeProperty(e),et(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Hi(e){return function(){this.style.removeProperty(e)}}function uf(e,t,n){var r,o=n+"",i;return function(){var s=et(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function df(e,t,n){var r,o,i;return function(){var s=et(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),et(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function ff(e,t){var n,r,o,i="style."+t,s="end."+i,a;return function(){var c=Se(this,e),l=c.on,u=c.value[i]==null?a||(a=Hi(t)):void 0;(l!==n||o!==u)&&(r=(n=l).copy()).on(s,o=u),c.on=r}}function hf(e,t,n){var r=(e+="")=="transform"?hd:Ri;return t==null?this.styleTween(e,lf(e,r)).on("end.style."+e,Hi(e)):typeof t=="function"?this.styleTween(e,df(e,r,ur(this,"style."+e,t))).each(ff(this._id,e)):this.styleTween(e,uf(e,r,t),n).on("end.style."+e,null)}function gf(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function pf(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&gf(e,s,n)),r}return i._value=t,i}function mf(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,pf(e,t,n??""))}function yf(e){return function(){this.textContent=e}}function xf(e){return function(){var t=e(this);this.textContent=t??""}}function wf(e){return this.tween("text",typeof e=="function"?xf(ur(this,"text",e)):yf(e==null?"":e+""))}function vf(e){return function(t){this.textContent=e.call(this,t)}}function bf(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&vf(o)),t}return r._value=e,r}function Ef(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,bf(e))}function _f(){for(var e=this._name,t=this._id,n=zi(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=ye(c,t);gn(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Te(r,this._parents,e,n)}function Nf(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--o===0&&i()}};n.each(function(){var l=Se(this,r),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),o===0&&i()})}var Sf=0;function Te(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function zi(){return++Sf}var Ie=Ct.prototype;Te.prototype={constructor:Te,select:of,selectAll:sf,selectChild:Ie.selectChild,selectChildren:Ie.selectChildren,filter:Zd,merge:Qd,selection:cf,transition:_f,call:Ie.call,nodes:Ie.nodes,node:Ie.node,size:Ie.size,empty:Ie.empty,each:Ie.each,on:tf,attr:jd,attrTween:zd,style:hf,styleTween:mf,text:wf,textTween:Ef,remove:rf,tween:Md,delay:Vd,duration:Wd,ease:qd,easeVarying:Ud,end:Nf,[Symbol.iterator]:Ie[Symbol.iterator]};function Cf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var kf={time:null,delay:0,duration:250,ease:Cf};function Mf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function If(e){var t,n;e instanceof Te?(t=e._id,e=e._name):(t=zi(),(n=kf).time=cr(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&gn(c,e,t,l,s,n||Mf(c,t));return new Te(r,this._parents,e,t)}Ct.prototype.interrupt=Sd;Ct.prototype.transition=If;const Ht=e=>()=>e;function Af(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Ae(e,t,n){this.k=e,this.x=t,this.y=n}Ae.prototype={constructor:Ae,scale:function(e){return e===1?this:new Ae(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ae(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var pn=new Ae(1,0,0);Fi.prototype=Ae.prototype;function Fi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return pn;return e.__zoom}function Tn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function Tf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Of(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Jr(){return this.__zoom||pn}function Pf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $f(){return navigator.maxTouchPoints||"ontouchstart"in this}function jf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Bi(){var e=Tf,t=Of,n=jf,r=Pf,o=$f,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Xt,l=dn("start","zoom","end"),u,d,f,h=500,g=150,v=0,w=10;function m(y){y.property("__zoom",Jr).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,N,C,A){var j=y.selection?y.selection():y;j.property("__zoom",Jr),y!==j?_(y,N,C,A):j.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},m.scaleBy=function(y,N,C,A){m.scaleTo(y,function(){var j=this.__zoom.k,T=typeof N=="function"?N.apply(this,arguments):N;return j*T},C,A)},m.scaleTo=function(y,N,C,A){m.transform(y,function(){var j=t.apply(this,arguments),T=this.__zoom,D=C==null?x(j):typeof C=="function"?C.apply(this,arguments):C,F=T.invert(D),H=typeof N=="function"?N.apply(this,arguments):N;return n(p(b(T,H),D,F),j,s)},C,A)},m.translateBy=function(y,N,C,A){m.transform(y,function(){return n(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,A)},m.translateTo=function(y,N,C,A,j){m.transform(y,function(){var T=t.apply(this,arguments),D=this.__zoom,F=A==null?x(T):typeof A=="function"?A.apply(this,arguments):A;return n(pn.translate(F[0],F[1]).scale(D.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof C=="function"?-C.apply(this,arguments):-C),T,s)},A,j)};function b(y,N){return N=Math.max(i[0],Math.min(i[1],N)),N===y.k?y:new Ae(N,y.x,y.y)}function p(y,N,C){var A=N[0]-C[0]*y.k,j=N[1]-C[1]*y.k;return A===y.x&&j===y.y?y:new Ae(y.k,A,j)}function x(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function _(y,N,C,A){y.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var j=this,T=arguments,D=S(j,T).event(A),F=t.apply(j,T),H=C==null?x(F):typeof C=="function"?C.apply(j,T):C,V=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),Y=j.__zoom,q=typeof N=="function"?N.apply(j,T):N,J=c(Y.invert(H).concat(V/Y.k),q.invert(H).concat(V/q.k));return function(G){if(G===1)G=q;else{var R=J(G),B=V/R[2];G=new Ae(B,H[0]-R[0]*B,H[1]-R[1]*B)}D.zoom(null,G)}})}function S(y,N,C){return!C&&y.__zooming||new k(y,N)}function k(y,N){this.that=y,this.args=N,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,N),this.taps=0}k.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,N){return this.mouse&&y!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=N.invert(this.touch1[0])),this.that.__zoom=N,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var N=ce(this.that).datum();l.call(y,this.that,new Af(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),N)}};function M(y,...N){if(!e.apply(this,arguments))return;var C=S(this,N).event(y),A=this.__zoom,j=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),T=fe(y);if(C.wheel)(C.mouse[0][0]!==T[0]||C.mouse[0][1]!==T[1])&&(C.mouse[1]=A.invert(C.mouse[0]=T)),clearTimeout(C.wheel);else{if(A.k===j)return;C.mouse=[T,A.invert(T)],qt(this),C.start()}ut(y),C.wheel=setTimeout(D,g),C.zoom("mouse",n(p(b(A,j),C.mouse[0],C.mouse[1]),C.extent,s));function D(){C.wheel=null,C.end()}}function I(y,...N){if(f||!e.apply(this,arguments))return;var C=y.currentTarget,A=S(this,N,!0).event(y),j=ce(y.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",V,!0),T=fe(y,C),D=y.clientX,F=y.clientY;Si(y.view),Tn(y),A.mouse=[T,this.__zoom.invert(T)],qt(this),A.start();function H(Y){if(ut(Y),!A.moved){var q=Y.clientX-D,J=Y.clientY-F;A.moved=q*q+J*J>v}A.event(Y).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=fe(Y,C),A.mouse[1]),A.extent,s))}function V(Y){j.on("mousemove.zoom mouseup.zoom",null),Ci(Y.view,A.moved),ut(Y),A.event(Y).end()}}function z(y,...N){if(e.apply(this,arguments)){var C=this.__zoom,A=fe(y.changedTouches?y.changedTouches[0]:y,this),j=C.invert(A),T=C.k*(y.shiftKey?.5:2),D=n(p(b(C,T),A,j),t.apply(this,N),s);ut(y),a>0?ce(this).transition().duration(a).call(_,D,A,y):ce(this).call(m.transform,D,A,y)}}function O(y,...N){if(e.apply(this,arguments)){var C=y.touches,A=C.length,j=S(this,N,y.changedTouches.length===A).event(y),T,D,F,H;for(Tn(y),D=0;D<A;++D)F=C[D],H=fe(F,this),H=[H,this.__zoom.invert(H),F.identifier],j.touch0?!j.touch1&&j.touch0[2]!==H[2]&&(j.touch1=H,j.taps=0):(j.touch0=H,T=!0,j.taps=1+!!u);u&&(u=clearTimeout(u)),T&&(j.taps<2&&(d=H[0],u=setTimeout(function(){u=null},h)),qt(this),j.start())}}function $(y,...N){if(this.__zooming){var C=S(this,N).event(y),A=y.changedTouches,j=A.length,T,D,F,H;for(ut(y),T=0;T<j;++T)D=A[T],F=fe(D,this),C.touch0&&C.touch0[2]===D.identifier?C.touch0[0]=F:C.touch1&&C.touch1[2]===D.identifier&&(C.touch1[0]=F);if(D=C.that.__zoom,C.touch1){var V=C.touch0[0],Y=C.touch0[1],q=C.touch1[0],J=C.touch1[1],G=(G=q[0]-V[0])*G+(G=q[1]-V[1])*G,R=(R=J[0]-Y[0])*R+(R=J[1]-Y[1])*R;D=b(D,Math.sqrt(G/R)),F=[(V[0]+q[0])/2,(V[1]+q[1])/2],H=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(C.touch0)F=C.touch0[0],H=C.touch0[1];else return;C.zoom("touch",n(p(D,F,H),C.extent,s))}}function P(y,...N){if(this.__zooming){var C=S(this,N).event(y),A=y.changedTouches,j=A.length,T,D;for(Tn(y),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),T=0;T<j;++T)D=A[T],C.touch0&&C.touch0[2]===D.identifier?delete C.touch0:C.touch1&&C.touch1[2]===D.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(D=fe(D,this),Math.hypot(d[0]-D[0],d[1]-D[1])<w)){var F=ce(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return m.wheelDelta=function(y){return arguments.length?(r=typeof y=="function"?y:Ht(+y),m):r},m.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Ht(!!y),m):e},m.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:Ht(!!y),m):o},m.extent=function(y){return arguments.length?(t=typeof y=="function"?y:Ht([[+y[0][0],+y[0][1]],[+y[1][0],+y[1][1]]]),m):t},m.scaleExtent=function(y){return arguments.length?(i[0]=+y[0],i[1]=+y[1],m):[i[0],i[1]]},m.translateExtent=function(y){return arguments.length?(s[0][0]=+y[0][0],s[1][0]=+y[1][0],s[0][1]=+y[0][1],s[1][1]=+y[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(y){return arguments.length?(n=y,m):n},m.duration=function(y){return arguments.length?(a=+y,m):a},m.interpolate=function(y){return arguments.length?(c=y,m):c},m.on=function(){var y=l.on.apply(l,arguments);return y===l?m:y},m.clickDistance=function(y){return arguments.length?(v=(y=+y)*y,m):Math.sqrt(v)},m.tapDistance=function(y){return arguments.length?(w=+y,m):w},m}const me={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},vt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Vi=["Enter"," ","Escape"],Yi={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var nt;(function(e){e.Strict="strict",e.Loose="loose"})(nt||(nt={}));var Ve;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ve||(Ve={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const Xi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var je;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(je||(je={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const eo={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},Wi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Lf=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),dr=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mt=(e,t=[0,0])=>{const{width:n,height:r}=xe(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},Df=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((o,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):dr(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,mn(o,rn(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?yn(r):{x:0,y:0,width:0,height:0}},It=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=mn(n,rn(o)),r=!0)}),r?yn(n):{x:0,y:0,width:0,height:0}},fr=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/o,c=(t.y-r)/o,l=t.width/o,u=t.height/o,d=[];for(const f of e.values()){const{measured:h,selectable:g=!0,hidden:v=!1}=f;if(s&&!g||v)continue;const w=h.width??f.width??f.initialWidth??0,m=h.height??f.height??f.initialHeight??0,{x:b,y:p}=f.internals.positionAbsolute,x=Ui(a,c,l,u,b,p,w,m),_=w*m,S=i&&x>0;(!f.internals.handleBounds||S||x>=_||f.dragging)&&d.push(f)}return d},Rf=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Hf(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let i;if(t!=null&&t.includeHiddenNodes){const{width:s,height:a}=xe(o);i=s>0&&a>0}else i=!!(o.measured.width&&o.measured.height&&!o.hidden);i&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function zf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=Hf(e,s),c=It(a),l=gr(c,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(l,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0}function Gi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??r;let d=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",me.error005());else{const{width:h,height:g}=xe(a);h&&g&&(d=[[c,l],[c+h,l+g]])}else a&&Ge(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const f=Ge(d)?We(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",me.error015())),{position:{x:f.x-c+(s.measured.width??0)*u[0],y:f.y-l+(s.measured.height??0)*u[1]},positionAbsolute:f}}async function Ff({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(v=>v.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),u=Rf(s,c);for(const f of c)a.has(f.id)&&!u.find(g=>g.id===f.id)&&u.push(f);if(!o)return{edges:u,nodes:s};const d=await o({nodes:s,edges:u});return typeof d=="boolean"?d?{edges:u,nodes:s}:{edges:[],nodes:[]}:d}const rt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),We=(e={x:0,y:0},t,n)=>({x:rt(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:rt(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function qi(e,t,n){const{width:r,height:o}=xe(n),{x:i,y:s}=n.internals.positionAbsolute;return We(e,[[i,s],[i+r,s+o]],t)}const to=(e,t,n)=>e<t?rt(Math.abs(e-t),1,t)/t:e>n?-rt(Math.abs(e-n),1,t)/t:0,hr=(e,t,n=15,r=40)=>{const o=to(e.x,r,t.width-r)*n,i=to(e.y,r,t.height-r)*n;return[o,i]},mn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),yn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Et=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=dr(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},rn=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=dr(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Ki=(e,t)=>yn(mn(Zn(e),Zn(t))),Ui=(e,t,n,r,o,i,s,a)=>{const c=Math.max(0,Math.min(e+n,o+s)-Math.max(e,o)),l=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(c*l)},on=(e,t)=>Ui(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),no=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),Zi=(e,t)=>(n,r)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Tt=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?At(a,s):a},ot=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ue(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Bf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ue(e,n),o=Ue(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ue(e.top??e.y??0,n),o=Ue(e.bottom??e.y??0,n),i=Ue(e.left??e.x??0,t),s=Ue(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Vf(e,t,n,r,o,i){const{x:s,y:a}=ot(e,[t,n,r]),{x:c,y:l}=ot({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=o-c,d=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(d)}}const gr=(e,t,n,r,o,i)=>{const s=Bf(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=rt(l,r,o),d=e.x+e.width/2,f=e.y+e.height/2,h=t/2-d*u,g=n/2-f*u,v=Vf(e,h,g,u,t,n),w={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-w.left+w.right,y:g-w.top+w.bottom,zoom:u}},_t=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ge(e){return e!=null&&e!=="parent"}function xe(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Qi(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Ji(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function ro(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Yf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function Xf(e){return{...Yi,...e||{}}}function es(e){return e===null?null:e?"valid":"invalid"}function pt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=Tt({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const pr=e=>({width:e.offsetWidth,height:e.offsetHeight}),ts=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Wf=["INPUT","SELECT","TEXTAREA"];function ns(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Wf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const rs=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=rs(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},oo=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...pr(s)}})};function os({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+o*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+r*.125,u=Math.abs(c-e),d=Math.abs(l-t);return[c,l,u,d]}function zt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function io({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-zt(t-r,i),n];case W.Right:return[t+zt(r-t,i),n];case W.Top:return[t,n-zt(n-o,i)];case W.Bottom:return[t,n+zt(o-n,i)]}}function is({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=io({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[l,u]=io({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,f,h,g]=os({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${r},${o}`,d,f,h,g]}function ss({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,a=r<t?r+s:r-s;return[i,a,o,s]}function Gf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,a=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+a}function qf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=mn(rn(e),rn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return on(s,yn(i))>0}const Kf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Uf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Zf=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",me.error006()),t;const r=n.getEdgeId||Kf;let o;return Wi(e)?o={...e}:o={...e,id:r(e)},Uf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function as({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=ss({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const so={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Qf=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},ao=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Jf({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=so[t],c=so[r],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},d=Qf({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let g=[],v,w;const m={x:0,y:0},b={x:0,y:0},[,,p,x]=ss({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(v=o.x??l.x+(u.x-l.x)*s,w=o.y??(l.y+u.y)/2):(v=o.x??(l.x+u.x)/2,w=o.y??l.y+(u.y-l.y)*s);const M=[{x:v,y:l.y},{x:v,y:u.y}],I=[{x:l.x,y:w},{x:u.x,y:w}];a[f]===h?g=f==="x"?M:I:g=f==="x"?I:M}else{const M=[{x:l.x,y:u.y}],I=[{x:u.x,y:l.y}];if(f==="x"?g=a.x===h?I:M:g=a.y===h?M:I,t===r){const y=Math.abs(e[f]-n[f]);if(y<=i){const N=Math.min(i-1,i-y);a[f]===h?m[f]=(l[f]>e[f]?-1:1)*N:b[f]=(u[f]>n[f]?-1:1)*N}}if(t!==r){const y=f==="x"?"y":"x",N=a[f]===c[y],C=l[y]>u[y],A=l[y]<u[y];(a[f]===1&&(!N&&C||N&&A)||a[f]!==1&&(!N&&A||N&&C))&&(g=f==="x"?M:I)}const z={x:l.x+m.x,y:l.y+m.y},O={x:u.x+b.x,y:u.y+b.y},$=Math.max(Math.abs(z.x-g[0].x),Math.abs(O.x-g[0].x)),P=Math.max(Math.abs(z.y-g[0].y),Math.abs(O.y-g[0].y));$>=P?(v=(z.x+O.x)/2,w=g[0].y):(v=g[0].x,w=(z.y+O.y)/2)}const _={x:l.x+m.x,y:l.y+m.y},S={x:u.x+b.x,y:u.y+b.y};return[[e,..._.x!==g[0].x||_.y!==g[0].y?[_]:[],...g,...S.x!==g[g.length-1].x||S.y!==g[g.length-1].y?[S]:[],n],v,w,p,x]}function eh(e,t,n,r){const o=Math.min(ao(e,t)/2,ao(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+o*l},${s}Q ${i},${s} ${i},${s+o*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+o*c}Q ${i},${s} ${i+o*a},${s}`}function Qn({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[d,f,h,g,v]=Jf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let w=`M${d[0].x} ${d[0].y}`;for(let m=1;m<d.length-1;m++)w+=eh(d[m-1],d[m],d[m+1],s);return w+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[w,f,h,g,v]}function co(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function th(e){var d;const{sourceNode:t,targetNode:n}=e;if(!co(t)||!co(n))return null;const r=t.internals.handleBounds||lo(t.handles),o=n.internals.handleBounds||lo(n.handles),i=uo((r==null?void 0:r.source)??[],e.sourceHandle),s=uo(e.connectionMode===nt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(d=e.onError)==null||d.call(e,"008",me.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||W.Bottom,c=(s==null?void 0:s.position)||W.Top,l=qe(t,i,a),u=qe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function lo(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function qe(e,t,n=W.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??xe(e);if(r)return{x:o+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:o+s/2,y:i};case W.Right:return{x:o+s,y:i+a/2};case W.Bottom:return{x:o+s/2,y:i+a};case W.Left:return{x:o,y:i+a/2}}}function uo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Jn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function nh(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const l=Jn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const cs=1e3,rh=10,mr={nodeOrigin:[0,0],nodeExtent:vt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},oh={...mr,checkEquality:!0};function yr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function ih(e,t,n){const r=yr(mr,n);for(const o of e.values())if(o.parentId)wr(o,e,t,r);else{const i=Mt(o,r.nodeOrigin),s=Ge(o.extent)?o.extent:r.nodeExtent,a=We(i,s,xe(o));o.internals.positionAbsolute=a}}function sh(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function xr(e){return e==="manual"}function er(e,t,n,r={}){var u,d;const o=yr(oh,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!xr(o.zIndexMode)?cs:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let h=s.get(f.id);if(o.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const g=Mt(f,o.nodeOrigin),v=Ge(f.extent)?f.extent:o.nodeExtent,w=We(g,v,xe(f));h={...o.defaults,...f,measured:{width:(u=f.measured)==null?void 0:u.width,height:(d=f.measured)==null?void 0:d.height},internals:{positionAbsolute:w,handleBounds:sh(f,h),z:ls(f,a,o.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),f.parentId&&wr(h,t,n,r,i),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function ah(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function wr(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yr(mr,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}ah(e,n),o&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++o.i,u.internals.z=u.internals.z+o.i*rh),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const d=i&&!xr(c)?cs:0,{x:f,y:h,z:g}=ch(e,u,s,a,d,c),{positionAbsolute:v}=e.internals,w=f!==v.x||h!==v.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:v,z:g}})}function ls(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return xr(n)?r:r+(e.selected?t:0)}function ch(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),l=Mt(e,n),u=Ge(e.extent)?We(l,e.extent,c):l;let d=We({x:s+u.x,y:a+u.y},r,c);e.extent==="parent"&&(d=qi(d,c,t));const f=ls(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function vr(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Et(c),u=Ki(l,a.rect);i.set(a.parentId,{expandedRect:u,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var p;const u=c.internals.positionAbsolute,d=xe(c),f=c.origin??r,h=a.x<u.x?Math.round(Math.abs(u.x-a.x)):0,g=a.y<u.y?Math.round(Math.abs(u.y-a.y)):0,v=Math.max(d.width,Math.round(a.width)),w=Math.max(d.height,Math.round(a.height)),m=(v-d.width)*f[0],b=(w-d.height)*f[1];(h>0||g>0||m||b)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+m,y:c.position.y-g+b}}),(p=n.get(l))==null||p.forEach(x=>{e.some(_=>_.id===x.id)||o.push({id:x.id,type:"position",position:{x:x.position.x+h,y:x.position.y+g}})})),(d.width<a.width||d.height<a.height||h||g)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?f[0]*h-m:0),height:w+(g?f[1]*g-b:0)}})}),o}function lh(e,t,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const v=pr(h.nodeElement),w=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ge(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;if(g.parentId&&g.extent==="parent"){const S=t.get(g.parentId);S&&(x=qi(x,v,S))}else p&&(x=We(x,p,v));const _={...g,measured:v,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:oo("source",h.nodeElement,b,d,g.id),target:oo("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,_),g.parentId&&wr(_,t,n,{nodeOrigin:o,zIndexMode:s}),c=!0,w&&(l.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:Et(_,o)}))}}if(f.length>0){const h=vr(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function uh({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function fo(e,t,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),i){s=`${o}-${e}-${i}`;const l=r.get(s)||new Map;r.set(s,l.set(n,t))}}function us(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},l=`${o}-${s}--${i}-${a}`,u=`${i}-${a}--${o}-${s}`;fo("source",c,u,e,o,s),fo("target",c,l,e,i,a),t.set(r.id,r)}}function ds(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ds(n,t):!1}function ho(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function dh(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!ds(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&o.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function On({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[l,u]of t){const d=(s=n.get(l))==null?void 0:s.internals.userNode;d&&o.push({...d,position:u.position,dragging:r})}if(!e)return[o[0],o];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:o[0],o]}function fh({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function hh({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,h=!1,g=!1,v=null;function w({noDragClassName:b,handleSelector:p,domNode:x,isSelectable:_,nodeId:S,nodeClickDistance:k=0}){f=ce(x);function M({x:$,y:P}){const{nodeLookup:y,nodeExtent:N,snapGrid:C,snapToGrid:A,nodeOrigin:j,onNodeDrag:T,onSelectionDrag:D,onError:F,updateNodePositions:H}=t();i={x:$,y:P};let V=!1;const Y=a.size>1,q=Y&&N?Zn(It(a)):null,J=Y&&A?fh({dragItems:a,snapGrid:C,x:$,y:P}):null;for(const[G,R]of a){if(!y.has(G))continue;let B={x:$-R.distance.x,y:P-R.distance.y};A&&(B=J?{x:Math.round(B.x+J.x),y:Math.round(B.y+J.y)}:At(B,C));let K=null;if(Y&&N&&!R.extent&&q){const{positionAbsolute:Z}=R.internals,Q=Z.x-q.x+N[0][0],ee=Z.x+R.measured.width-q.x2+N[1][0],ne=Z.y-q.y+N[0][1],re=Z.y+R.measured.height-q.y2+N[1][1];K=[[Q,ne],[ee,re]]}const{position:U,positionAbsolute:X}=Gi({nodeId:G,nextPosition:B,nodeLookup:y,nodeExtent:K||N,nodeOrigin:j,onError:F});V=V||R.position.x!==U.x||R.position.y!==U.y,R.position=U,R.internals.positionAbsolute=X}if(g=g||V,!!V&&(H(a,!0),v&&(r||T||!S&&D))){const[G,R]=On({nodeId:S,dragItems:a,nodeLookup:y});r==null||r(v,a,G,R),T==null||T(v,G,R),S||D==null||D(v,R)}}async function I(){if(!u)return;const{transform:$,panBy:P,autoPanSpeed:y,autoPanOnNodeDrag:N}=t();if(!N){c=!1,cancelAnimationFrame(s);return}const[C,A]=hr(l,u,y);(C!==0||A!==0)&&(i.x=(i.x??0)-C/$[2],i.y=(i.y??0)-A/$[2],await P({x:C,y:A})&&M(i)),s=requestAnimationFrame(I)}function z($){var Y;const{nodeLookup:P,multiSelectionActive:y,nodesDraggable:N,transform:C,snapGrid:A,snapToGrid:j,selectNodesOnDrag:T,onNodeDragStart:D,onSelectionDragStart:F,unselectNodesAndEdges:H}=t();d=!0,(!T||!_)&&!y&&S&&((Y=P.get(S))!=null&&Y.selected||H()),_&&T&&S&&(e==null||e(S));const V=pt($.sourceEvent,{transform:C,snapGrid:A,snapToGrid:j,containerBounds:u});if(i=V,a=dh(P,N,V,S),a.size>0&&(n||D||!S&&F)){const[q,J]=On({nodeId:S,dragItems:a,nodeLookup:P});n==null||n($.sourceEvent,a,q,J),D==null||D($.sourceEvent,q,J),S||F==null||F($.sourceEvent,J)}}const O=ki().clickDistance(k).on("start",$=>{const{domNode:P,nodeDragThreshold:y,transform:N,snapGrid:C,snapToGrid:A}=t();u=(P==null?void 0:P.getBoundingClientRect())||null,h=!1,g=!1,v=$.sourceEvent,y===0&&z($),i=pt($.sourceEvent,{transform:N,snapGrid:C,snapToGrid:A,containerBounds:u}),l=pe($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:P,transform:y,snapGrid:N,snapToGrid:C,nodeDragThreshold:A,nodeLookup:j}=t(),T=pt($.sourceEvent,{transform:y,snapGrid:N,snapToGrid:C,containerBounds:u});if(v=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||S&&!j.has(S))&&(h=!0),!h){if(!c&&P&&d&&(c=!0,I()),!d){const D=pe($.sourceEvent,u),F=D.x-l.x,H=D.y-l.y;Math.sqrt(F*F+H*H)>A&&z($)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&a&&d&&(l=pe($.sourceEvent,u),M(T))}}).on("end",$=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:P,updateNodePositions:y,onNodeDragStop:N,onSelectionDragStop:C}=t();if(g&&(y(a,!1),g=!1),o||N||!S&&C){const[A,j]=On({nodeId:S,dragItems:a,nodeLookup:P,dragging:!1});o==null||o($.sourceEvent,a,A,j),N==null||N($.sourceEvent,A,j),S||C==null||C($.sourceEvent,j)}}}).filter($=>{const P=$.target;return!$.button&&(!b||!ho(P,`.${b}`,x))&&(!p||ho(P,p,x))});f.call(O)}function m(){f==null||f.on(".drag",null)}return{update:w,destroy:m}}function gh(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())on(o,Et(i))>0&&r.push(i);return r}const ph=250;function mh(e,t,n,r){var a,c;let o=[],i=1/0;const s=gh(e,n,t+ph);for(const l of s){const u=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of u){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:f,y:h}=qe(l,d,d.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(o=[{...d,x:f,y:h}],i=g):g===i&&o.push({...d,x:f,y:h}))}}if(!o.length)return null;if(o.length>1){const l=r.type==="source"?"target":"source";return o.find(u=>u.type===l)??o[0]}return o[0]}function fs(e,t,n,r,o,i=!1){var l,u,d;const s=r.get(e);if(!s)return null;const a=o==="strict"?(l=s.internals.handleBounds)==null?void 0:l[t]:[...((u=s.internals.handleBounds)==null?void 0:u.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...qe(s,c,c.position,!0)}:c}function hs(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function yh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const gs=()=>!0;function xh(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:v,onConnectEnd:w,isValidConnection:m=gs,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:_,autoPanSpeed:S,dragThreshold:k=1,handleDomNode:M}){const I=ts(e.target);let z=0,O;const{x:$,y:P}=pe(e),y=hs(i,M),N=a==null?void 0:a.getBoundingClientRect();let C=!1;if(!N||!y)return;const A=fs(o,y,r,c,t);if(!A)return;let j=pe(e,N),T=!1,D=null,F=!1,H=null;function V(){if(!u||!N)return;const[U,X]=hr(j,N,S);f({x:U,y:X}),z=requestAnimationFrame(V)}const Y={...A,nodeId:o,type:y,position:A.position},q=c.get(o);let G={inProgress:!0,isValid:null,from:qe(q,Y,W.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:q,to:j,toHandle:null,toPosition:eo[Y.position],toNode:null,pointer:j};function R(){C=!0,p(G),g==null||g(e,{nodeId:o,handleId:r,handleType:y})}k===0&&R();function B(U){if(!C){const{x:re,y:ue}=pe(U),ve=re-$,be=ue-P;if(!(ve*ve+be*be>k*k))return;R()}if(!_()||!Y){K(U);return}const X=x();j=pe(U,N),O=mh(Tt(j,X,!1,[1,1]),n,c,Y),T||(V(),T=!0);const Z=ps(U,{handle:O,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:I,lib:l,flowId:d,nodeLookup:c});H=Z.handleDomNode,D=Z.connection,F=yh(!!O,Z.isValid);const Q=c.get(o),ee=Q?qe(Q,Y,W.Left,!0):G.from,ne={...G,from:ee,isValid:F,to:Z.toHandle&&F?ot({x:Z.toHandle.x,y:Z.toHandle.y},X):j,toHandle:Z.toHandle,toPosition:F&&Z.toHandle?Z.toHandle.position:eo[Y.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:j};p(ne),G=ne}function K(U){if(!("touches"in U&&U.touches.length>0)){if(C){(O||H)&&D&&F&&(v==null||v(D));const{inProgress:X,...Z}=G,Q={...Z,toPosition:G.toHandle?G.toPosition:null};w==null||w(U,Q),i&&(b==null||b(U,Q))}h(),cancelAnimationFrame(z),T=!1,F=!1,D=null,H=null,I.removeEventListener("mousemove",B),I.removeEventListener("mouseup",K),I.removeEventListener("touchmove",B),I.removeEventListener("touchend",K)}}I.addEventListener("mousemove",B),I.addEventListener("mouseup",K),I.addEventListener("touchmove",B),I.addEventListener("touchend",K)}function ps(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=gs,nodeLookup:u}){const d=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=pe(e),v=s.elementFromPoint(h,g),w=v!=null&&v.classList.contains(`${a}-flow__handle`)?v:f,m={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=hs(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),_=w.classList.contains("connectable"),S=w.classList.contains("connectableend");if(!p||!b)return m;const k={source:d?p:r,sourceHandle:d?x:o,target:d?r:p,targetHandle:d?o:x};m.connection=k;const I=_&&S&&(n===nt.Strict?d&&b==="source"||!d&&b==="target":p!==r||x!==o);m.isValid=I&&l(k),m.toHandle=fs(p,b,x,u,n,!0)}return m}const tr={onPointerDown:xh,isValid:ps};function wh({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:d=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const x=n(),_=p.sourceEvent.ctrlKey&&_t()?10:1,S=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*u,k=x[2]*Math.pow(2,S*_);t.scaleTo(k)};let v=[0,0];const w=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(v=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const x=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const _=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],S=[_[0]-v[0],_[1]-v[1]];v=_;const k=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),M={x:x[0]-S[0]*k,y:x[1]-S[1]*k},I=[[0,0],[c,l]];t.setViewportConstrained({x:M.x,y:M.y,zoom:x[2]},I,a)},b=Bi().on("start",w).on("zoom",d?m:null).on("zoom.wheel",f?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:fe}}const xn=e=>({x:e.x,y:e.y,zoom:e.k}),Pn=({x:e,y:t,zoom:n})=>pn.translate(e,t).scale(n),$e=(e,t)=>e.target.closest(`.${t}`),ms=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),vh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,$n=(e,t=0,n=vh,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},ys=e=>{const t=e.ctrlKey&&_t()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function bh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if($e(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(u.ctrlKey&&s){const w=fe(u),m=ys(u),b=d*Math.pow(2,m);r.scaleTo(n,b,w,u);return}const f=u.deltaMode===1?20:1;let h=o===Ve.Vertical?0:u.deltaX*f,g=o===Ve.Horizontal?0:u.deltaY*f;!_t()&&u.shiftKey&&o!==Ve.Vertical&&(h=u.deltaY*f,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const v=xn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c==null||c(u,v):(e.isPanScrolling=!0,a==null||a(u,v)),e.panScrollTimeout=setTimeout(()=>{l==null||l(u,v),e.isPanScrolling=!1},150)}}function Eh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=$e(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function _h({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=xn(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Nh({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&ms(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((a=i.sourceEvent)!=null&&a.internal)&&(o==null||o(i.sourceEvent,xn(i.transform)))}}function Sh({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&ms(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=xn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Ch({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{var m;const h=t||n,g=r&&f.ctrlKey,v=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&($e(f,`${u}-flow__node`)||$e(f,`${u}-flow__edge`)||$e(f,`${u}-flow__selection`)||$e(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!v||$e(f,c)&&v||$e(f,l)&&(!v||i&&v&&!t)||!r&&f.ctrlKey&&v)return!1;if(!r&&f.type==="touchstart"&&((m=f.touches)==null?void 0:m.length)>1)return f.preventDefault(),!1;if(!h&&!i&&!g&&v||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const w=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||v||e)&&w}}function kh({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let d=[[0,0],[u.width,u.height]];const f=typeof ResizeObserver<"u"?new ResizeObserver(P=>{const y=P[0];y&&(d=[[0,0],[y.contentRect.width,y.contentRect.height]])}):null;f==null||f.observe(e);const h=Bi().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);x({x:o.x,y:o.y,zoom:rt(o.zoom,t,n)},[[0,0],[u.width,u.height]],r);const v=g.on("wheel.zoom"),w=g.on("dblclick.zoom");h.wheelDelta(ys);async function m(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).transform($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}function b({noWheelClassName:P,noPanClassName:y,onPaneContextMenu:N,userSelectionActive:C,panOnScroll:A,panOnDrag:j,panOnScrollMode:T,panOnScrollSpeed:D,preventScrolling:F,zoomOnPinch:H,zoomOnScroll:V,zoomOnDoubleClick:Y,panActivationKeyPressed:q=!1,zoomActivationKeyPressed:J,lib:G,onTransformChange:R,connectionInProgress:B,paneClickDistance:K,selectionOnDrag:U}){C&&!l.isZoomingOrPanning&&p();const X=A&&!J&&!C;h.clickDistance(U?1/0:!ge(K)||K<0?0:K);const Z=X?bh({zoomPanValues:l,noWheelClassName:P,d3Selection:g,d3Zoom:h,panOnScrollMode:T,panOnScrollSpeed:D,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Eh({noWheelClassName:P,preventScrolling:F,d3ZoomHandler:v});g.on("wheel.zoom",Z,{passive:!1});const Q=_h({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",Q);const ee=Nh({zoomPanValues:l,panOnDrag:j,onPaneContextMenu:!!N,onPanZoom:i,onTransformChange:R});h.on("zoom",ee);const ne=Sh({zoomPanValues:l,panOnDrag:j,panOnScroll:A,onPaneContextMenu:N,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=Ch({panActivationKeyPressed:q,zoomActivationKeyPressed:J,panOnDrag:j,zoomOnScroll:V,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:H,userSelectionActive:C,noPanClassName:y,noWheelClassName:P,lib:G,connectionInProgress:B});h.filter(re),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function p(){h.on("zoom",null)}async function x(P,y,N){const C=Pn(P),A=h==null?void 0:h.constrain()(C,y,N);return A&&await m(A),A}async function _(P,y){const N=Pn(P);return await m(N,y),N}function S(P){if(g){const y=Pn(P),N=g.property("__zoom");(N.k!==P.zoom||N.x!==P.x||N.y!==P.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function k(){const P=g?Fi(g.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}async function M(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).scaleTo($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}async function I(P,y){return g?new Promise(N=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?gt:Xt).scaleBy($n(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>N(!0)),P)}):!1}function z(P){h==null||h.scaleExtent(P)}function O(P){h==null||h.translateExtent(P)}function $(P){const y=!ge(P)||P<0?0:P;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:_,setViewportConstrained:x,getViewport:k,scaleTo:M,scaleBy:I,setScaleExtent:z,setTranslateExtent:O,syncViewport:S,setClickDistance:$}}var it;(function(e){e.Line="line",e.Handle="handle"})(it||(it={}));function Mh({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,a=n-r,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function go(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Oe(e,t){return Math.max(0,t-e)}function Pe(e,t){return Math.max(0,e-t)}function Ft(e,t,n){return Math.max(0,t-e,e-n)}function po(e,t){return e?!t:t}function Ih(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:h,ySnapped:g}=n,{minWidth:v,maxWidth:w,minHeight:m,maxHeight:b}=r,{x:p,y:x,width:_,height:S,aspectRatio:k}=e;let M=Math.floor(u?h-e.pointerX:0),I=Math.floor(d?g-e.pointerY:0);const z=_+(c?-M:M),O=S+(l?-I:I),$=-i[0]*_,P=-i[1]*S;let y=Ft(z,v,w),N=Ft(O,m,b);if(s){let j=0,T=0;c&&M<0?j=Oe(p+M+$,s[0][0]):!c&&M>0&&(j=Pe(p+z+$,s[1][0])),l&&I<0?T=Oe(x+I+P,s[0][1]):!l&&I>0&&(T=Pe(x+O+P,s[1][1])),y=Math.max(y,j),N=Math.max(N,T)}if(a){let j=0,T=0;c&&M>0?j=Pe(p+M,a[0][0]):!c&&M<0&&(j=Oe(p+z,a[1][0])),l&&I>0?T=Pe(x+I,a[0][1]):!l&&I<0&&(T=Oe(x+O,a[1][1])),y=Math.max(y,j),N=Math.max(N,T)}if(o){if(u){const j=Ft(z/k,m,b)*k;if(y=Math.max(y,j),s){let T=0;!c&&!l||c&&!l&&f?T=Pe(x+P+z/k,s[1][1])*k:T=Oe(x+P+(c?M:-M)/k,s[0][1])*k,y=Math.max(y,T)}if(a){let T=0;!c&&!l||c&&!l&&f?T=Oe(x+z/k,a[1][1])*k:T=Pe(x+(c?M:-M)/k,a[0][1])*k,y=Math.max(y,T)}}if(d){const j=Ft(O*k,v,w)/k;if(N=Math.max(N,j),s){let T=0;!c&&!l||l&&!c&&f?T=Pe(p+O*k+$,s[1][0])/k:T=Oe(p+(l?I:-I)*k+$,s[0][0])/k,N=Math.max(N,T)}if(a){let T=0;!c&&!l||l&&!c&&f?T=Oe(p+O*k,a[1][0])/k:T=Pe(p+(l?I:-I)*k,a[0][0])/k,N=Math.max(N,T)}}}I=I+(I<0?N:-N),M=M+(M<0?y:-y),o&&(f?z>O*k?I=(po(c,l)?-M:M)/k:M=(po(c,l)?-I:I)*k:u?(I=M/k,l=c):(M=I*k,c=l));const C=c?p+M:p,A=l?x+I:x;return{width:_+(c?-M:M),height:S+(l?-I:I),x:i[0]*M*(c?-1:1)+C,y:i[1]*I*(l?-1:1)+A}}const xs={width:0,height:0,x:0,y:0},Ah={...xs,pointerX:0,pointerY:0,aspectRatio:1};function Th(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[r-a,o-c],[r+i-a,o+s-c]]}function Oh({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:go("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:w}){let m={...xs},b={...Ah};s={boundaries:u,resizeDirection:f,keepAspectRatio:d,controlDirection:go(l)};let p,x=null,_=[],S,k,M,I=!1;const z=ki().on("start",O=>{const{nodeLookup:$,transform:P,snapGrid:y,snapToGrid:N,nodeOrigin:C,paneDomNode:A}=n();if(p=$.get(t),!p)return;x=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:j,ySnapped:T}=pt(O.sourceEvent,{transform:P,snapGrid:y,snapToGrid:N,containerBounds:x});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:j,pointerY:T,aspectRatio:m.width/m.height},S=void 0,k=Ge(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(S=$.get(p.parentId)),S&&p.extent==="parent"&&(k=[[0,0],[S.measured.width,S.measured.height]]),_=[],M=void 0;for(const[D,F]of $)if(F.parentId===t&&(_.push({id:D,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const H=Th(F,p,F.origin??C);M?M=[[Math.min(H[0][0],M[0][0]),Math.min(H[0][1],M[0][1])],[Math.max(H[1][0],M[1][0]),Math.max(H[1][1],M[1][1])]]:M=H}h==null||h(O,{...m})}).on("drag",O=>{const{transform:$,snapGrid:P,snapToGrid:y,nodeOrigin:N}=n(),C=pt(O.sourceEvent,{transform:$,snapGrid:P,snapToGrid:y,containerBounds:x}),A=[];if(!p)return;const{x:j,y:T,width:D,height:F}=m,H={},V=p.origin??N,{width:Y,height:q,x:J,y:G}=Ih(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,V,k,M),R=Y!==D,B=q!==F,K=J!==j&&R,U=G!==T&&B;if(!K&&!U&&!R&&!B)return;if((K||U||V[0]===1||V[1]===1)&&(H.x=K?J:m.x,H.y=U?G:m.y,m.x=H.x,m.y=H.y,_.length>0)){const ee=J-j,ne=G-T;for(const re of _)re.position={x:re.position.x-ee+V[0]*(Y-D),y:re.position.y-ne+V[1]*(q-F)},A.push(re)}if((R||B)&&(H.width=R&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:m.width,H.height=B&&(!s.resizeDirection||s.resizeDirection==="vertical")?q:m.height,m.width=H.width,m.height=H.height),S&&p.expandParent){const ee=V[0]*(H.width??0);H.x&&H.x<ee&&(m.x=ee,b.x=b.x-(H.x-ee));const ne=V[1]*(H.height??0);H.y&&H.y<ne&&(m.y=ne,b.y=b.y-(H.y-ne))}const X=Mh({width:m.width,prevWidth:D,height:m.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),Z={...m,direction:X};(w==null?void 0:w(O,Z))!==!1&&(I=!0,g==null||g(O,Z),r(H,A))}).on("end",O=>{I&&(v==null||v(O,{...m}),o==null||o({...m}),I=!1)});i.call(z)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}const Ph={},mo=e=>{let t;const n=new Set,r=(u,d)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Ph?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(r,o,c);return c},$h=e=>e?mo(e):mo,{useDebugValue:jh}=Lc,{useSyncExternalStoreWithSelector:Lh}=jc,Dh=e=>e;function ws(e,t=Dh,n){const r=Lh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return jh(r),r}const yo=(e,t)=>{const n=$h(e),r=(o,i=t)=>ws(n,o,i);return Object.assign(r,n),r},Rh=(e,t)=>e?yo(e,t):yo;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const wn=L.createContext(null),Hh=wn.Provider,vs=me.error001("react");function te(e,t){const n=L.useContext(wn);if(n===null)throw new Error(vs);return ws(n,e,t)}function oe(){const e=L.useContext(wn);if(e===null)throw new Error(vs);return L.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const xo={display:"none"},zh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},bs="react-flow__node-desc",Es="react-flow__edge-desc",Fh="react-flow__aria-live",Bh=e=>e.ariaLiveMessage,Vh=e=>e.ariaLabelConfig;function Yh({rfId:e}){const t=te(Bh);return E.jsx("div",{id:`${Fh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:zh,children:t})}function Xh({rfId:e,disableKeyboardA11y:t}){const n=te(Vh);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${bs}-${e}`,style:xo,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${Es}-${e}`,style:xo,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(Yh,{rfId:e})]})}const vn=L.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return E.jsx("div",{className:se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});vn.displayName="Panel";const wo="https://reactflow.dev?utm_source=attribution";function Wh({proOptions:e,position:t="bottom-right"}){return L.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:E.jsx(vn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${wo}`,children:E.jsx("a",{href:wo,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Gh=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Bt=e=>e.id;function qh(e,t){return ie(e.selectedNodes.map(Bt),t.selectedNodes.map(Bt))&&ie(e.selectedEdges.map(Bt),t.selectedEdges.map(Bt))}function Kh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=te(Gh,qh);return L.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const Uh=e=>!!e.onSelectionChangeHandlers;function Zh({onSelectionChange:e}){const t=te(Uh);return e||t?E.jsx(Kh,{onSelectionChange:e}):null}const _s=[0,0],Qh={x:0,y:0,zoom:1},Jh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],vo=[...Jh,"rfId"],eg=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),bo={translateExtent:vt,nodeOrigin:_s,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function tg(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(eg,ie),l=oe();L.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=bo,a()}),[]);const u=L.useRef(bo);return L.useEffect(()=>{for(const d of vo){const f=e[d],h=u.current[d];f!==h&&(typeof e[d]>"u"||(d==="nodes"?t(f):d==="edges"?n(f):d==="minZoom"?r(f):d==="maxZoom"?o(f):d==="translateExtent"?i(f):d==="nodeExtent"?s(f):d==="ariaLabelConfig"?l.setState({ariaLabelConfig:Xf(f)}):d==="fitView"?l.setState({fitViewQueued:f}):d==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[d]:f})))}u.current=e},vo.map(d=>e[d])),null}function Eo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function ng(e){var r;const[t,n]=L.useState(e==="system"?null:e);return L.useEffect(()=>{if(e!=="system"){n(e);return}const o=Eo(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=Eo())!=null&&r.matches?"dark":"light"}const _o=typeof document<"u"?document:null;function Nt(e=null,t={target:_o,actInsideInputWithModifier:!0}){const[n,r]=L.useState(!1),o=L.useRef(!1),i=L.useRef(new Set([])),[s,a]=L.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace(/\+/g,`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|
|
@@ -9,4 +9,4 @@ import{a0 as jc,a1 as Lc,r as L,j as E,P as Dc,n as Rc,c as Hc,a2 as zc,p as Fc,
|
|
|
9
9
|
0%, 100% { box-shadow: 0 0 0 3px rgba(66, 134, 222, 0.25), 0 0 12px rgba(66, 134, 222, 0.4); }
|
|
10
10
|
50% { box-shadow: 0 0 0 6px rgba(66, 134, 222, 0.15), 0 0 20px rgba(66, 134, 222, 0.5); }
|
|
11
11
|
}
|
|
12
|
-
`,fx={highlighted:!1,dimmed:!1};function hx(e,t,n,r){const o=t.trim().toLowerCase(),i=new Map;for(const s of e){const a=o!==""&&r(s).toLowerCase().includes(o);i.set(n(s),{highlighted:a,dimmed:o!==""&&!a})}return i}function gx(e){if(e.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const i of e)t=Math.min(t,i.position.x),n=Math.min(n,i.position.y),r=Math.max(r,i.position.x+(i.width??0)),o=Math.max(o,i.position.y+(i.height??0));return{minX:t,minY:n,maxX:r,maxY:o}}function px(e,t,n,r,o){const i=o-t.maxX*e.zoom,s=n-o-t.minX*e.zoom,a=o-t.maxY*e.zoom,c=r-o-t.minY*e.zoom;return{x:Math.min(Math.max(e.x,i),s),y:Math.min(Math.max(e.y,a),c),zoom:e.zoom}}var ta=Object.defineProperty,h0=(e,t,n)=>t in e?ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g0=(e,t)=>{for(var n in t)ta(e,n,{get:t[n],enumerable:!0})},p0=(e,t,n)=>h0(e,t+"",n),na={};g0(na,{Graph:()=>we,alg:()=>Nr});var m0=Object.defineProperty,ra=(e,t)=>{for(var n in t)m0(e,n,{get:t[n],enumerable:!0})},_r=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let o of r)n.add(o);return Array.from(n.values())}}isLeaf(e){var t;let n;return this.isDirected()?n=this.successors(e):n=this.neighbors(e),((t=n==null?void 0:n.length)!=null?t:0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,s,a,c=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(a=t,c=!0)):(o=e,i=t,s=r,arguments.length>2&&(a=n,c=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let l=ht(this._isDirected,o,i,s);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[l]=c?a:this._defaultEdgeLabelFn(o,i,s);let u=y0(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[l]=u,Xo(this._preds[i],o),Xo(this._sucs[o],i),this._in[i][l]=u,this._out[o][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"||r===null?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Wo(this._preds[s],i),Wo(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function Xo(e,t){e[t]?e[t]++:e[t]=1}function Wo(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function ht(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function y0(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let a=o;o=i,i=a}let s={v:o,w:i};return r&&(s.name=r),s}function Dn(e,t){return ht(e,t.v,t.w,t.name)}var x0={};ra(x0,{read:()=>E0,write:()=>w0});function w0(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:v0(e),edges:b0(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function v0(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function b0(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function E0(e){let t=new _r(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var Nr={};ra(Nr,{CycleException:()=>ln,bellmanFord:()=>oa,components:()=>S0,dijkstra:()=>cn,dijkstraAll:()=>M0,findCycles:()=>I0,floydWarshall:()=>T0,isAcyclic:()=>P0,postorder:()=>j0,preorder:()=>L0,prim:()=>D0,shortestPaths:()=>R0,tarjan:()=>sa,topsort:()=>aa});var _0=()=>1;function oa(e,t,n,r){return N0(e,String(t),n||_0,r||function(o){var i;return(i=e.outEdges(o))!=null?i:[]})}function N0(e,t,n,r){let o={},i,s=0,a=e.nodes(),c=function(d){let f=o[d.v],h=o[d.w];if(!f||!h)return;let g=n(d);f.distance+g<h.distance&&(o[d.w]={distance:f.distance+g,predecessor:d.v},i=!0)},l=function(){a.forEach(function(d){r(d).forEach(function(f){let h=f.v===d?f.v:f.w,g=h===f.v?f.w:f.v;c({v:h,w:g})})})};a.forEach(function(d){let f=d===t?0:Number.POSITIVE_INFINITY;o[d]={distance:f,predecessor:""}});let u=a.length;for(let d=1;d<u&&(i=!1,s++,l(),!!i);d++);if(s===u-1&&(i=!1,l(),i))throw new Error("The graph contains a negative weight cycle");return o}function S0(e){let t={},n=[],r;function o(i){var s,a;i in t||(t[i]=!0,r.push(i),(s=e.successors(i))==null||s.forEach(o),(a=e.predecessors(i))==null||a.forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var ia=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw new Error("Queue underflow");this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},C0=()=>1;function cn(e,t,n,r){let o=function(i){var s;return(s=e.outEdges(i))!=null?s:[]};return k0(e,String(t),n||C0,r||o)}function k0(e,t,n,r){let o={},i=new ia,s,a,c=function(l){let u=l.v!==s?l.v:l.w,d=o[u];if(!d)return;let f=n(l),h=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+f);h<d.distance&&(d.distance=h,d.predecessor=s,i.decrease(u,h))};for(e.nodes().forEach(function(l){let u=l===t?0:Number.POSITIVE_INFINITY;o[l]={distance:u,predecessor:""},i.add(l,u)});i.size()>0;){s=i.removeMin();let l=o[s];if(!l||l.distance===Number.POSITIVE_INFINITY)break;a=l,r(s).forEach(c)}return o}function M0(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=cn(e,o,t,n),r},{})}function sa(e){let t=0,n=[],r={},o=[];function i(s){var a;let c=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),(a=e.successors(s))==null||a.forEach(function(l){if(l in r){let u=r[l];u!=null&&u.onStack&&(c.lowlink=Math.min(c.lowlink,u.index))}else{i(l);let u=r[l];u&&(c.lowlink=Math.min(c.lowlink,u.lowlink))}}),c.lowlink===c.index){let l=[],u;do{u=n.pop();let d=r[u];d&&(d.onStack=!1),l.push(u)}while(s!==u);o.push(l)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function I0(e){return sa(e).filter(function(t){var n;let r=t[0];return r?t.length>1||t.length===1&&((n=e.outEdges(r,r))!=null?n:[]).length>0:!1})}var A0=()=>1;function T0(e,t,n){return O0(e,t||A0,n||function(r){var o;return(o=e.outEdges(r))!=null?o:[]})}function O0(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){let s={};r[i]=s,s[i]={distance:0,predecessor:""},o.forEach(function(a){i!==a&&(s[a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(a){let c=a.v===i?a.w:a.v,l=t(a);s[c]={distance:l,predecessor:i}})}),o.forEach(function(i){let s=r[i];s&&o.forEach(function(a){let c=r[a];c&&o.forEach(function(l){let u=c[i],d=s[l],f=c[l];if(u&&d&&f){let h=u.distance+d.distance;h<f.distance&&(f.distance=h,f.predecessor=d.predecessor)}})})}),r}var ln=class extends Error{constructor(e){super(e),this.name="CycleException"}};function aa(e){let t={},n={},r=[];function o(i){var s;if(i in n)throw new ln;i in t||(n[i]=!0,t[i]=!0,(s=e.predecessors(i))==null||s.forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new ln;return r}function P0(e){try{aa(e)}catch(t){if(t instanceof ln)return!1;throw t}return!0}function $0(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=(a=>{var c;return(c=e.isDirected()?e.successors(a):e.neighbors(a))!=null?c:[]}),s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);o=ca(e,a,n==="post",s,i,r,o)}),o}function ca(e,t,n,r,o,i,s){return t in r||(r[t]=!0,n||(s=i(s,t)),o(t).forEach(function(a){s=ca(e,a,n,r,o,i,s)}),n&&(s=i(s,t))),s}function la(e,t,n){return $0(e,t,n,function(r,o){return r.push(o),r},[])}function j0(e,t){return la(e,t,"post")}function L0(e,t){return la(e,t,"pre")}function D0(e,t){var n;let r=new _r,o={},i=new ia,s;function a(u){let d=u.v===s?u.w:u.v,f=i.priority(d);if(f!==void 0){let h=t(u);h<f&&(o[d]=s,i.decrease(d,h))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(u){i.add(u,Number.POSITIVE_INFINITY),r.setNode(u)});let c=e.nodes()[0];c!==void 0&&i.decrease(c,0);let l=!1;for(;i.size()>0;){if(s=i.removeMin(),s in o)r.setEdge(s,o[s]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}(n=e.nodeEdges(s))==null||n.forEach(a)}return r}function R0(e,t,n,r){return H0(e,t,n,r??(o=>{var i;return(i=e.outEdges(o))!=null?i:[]}))}function H0(e,t,n,r){if(n===void 0)return cn(e,t,n,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let a=i[s];if(a===void 0)continue;let c=r(a);for(let l=0;l<c.length;l++){let u=c[l];if(!u)continue;let d=u.v===a?u.v:u.w,f=d===u.v?u.w:u.v;n({v:d,w:f})<0&&(o=!0)}if(o)return oa(e,t,n,r)}return cn(e,t,n,r)}var we=_r;function at(e,t,n,r){let o=r;for(;e.hasNode(o);)o=Sr(r);return n.dummy=t,e.setNode(o,n),o}function z0(e){let t=new we().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function ua(e){let t=new we({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Go(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,s=e.width/2,a=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let c,l;return Math.abs(i)*s>Math.abs(o)*a?(i<0&&(a=-a),c=a*o/i,l=a):(o<0&&(s=-s),c=s,l=s*i/o),{x:n+c,y:r+l}}function Pt(e){let t=St(fa(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function F0(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=_e(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function B0(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=_e(Math.min,t),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;r[a]||(r[a]=[]),r[a].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%i!==0?--o:s!==void 0&&o&&s.forEach(c=>e.node(c).rank+=o)})}function qo(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),at(e,"border",o,t)}function V0(e,t=da){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var da=65535;function _e(e,t){if(t.length>da){let n=V0(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function fa(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return _e(Math.max,t)}function Y0(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function X0(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function ha(e,t){return t()}var W0=0;function Sr(e){let t=++W0;return e+(""+t)}function St(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function un(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function _n(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function G0(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Nn="\0";function ga(e,t,n){var r,o,i,s,a,c;if(!(e&&t&&n&&t.dummy==="edge"&&n.dummy==="edge"&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let l=!0;t.edgeObj.w===n.edgeObj.w&&(l=!1);let u=l?(o=(r=e[t.edgeObj.v])==null?void 0:r.rank)!=null?o:NaN+1:(s=(i=e[t.edgeObj.w])==null?void 0:i.rank)!=null?s:NaN-1,d=Object.entries(e).find(v=>{var w,m;return((w=v[1].edgeObj)==null?void 0:w.v)===t.edgeObj.v&&((m=v[1].edgeObj)==null?void 0:m.w)===t.edgeObj.w&&v[1].rank===u}),f=Object.entries(e).find(v=>{var w,m;return((w=v[1].edgeObj)==null?void 0:w.v)===n.edgeObj.v&&((m=v[1].edgeObj)==null?void 0:m.w)===n.edgeObj.w&&v[1].rank===u});if(!d||!f)return 0;let h=(a=d[1].order)!=null?a:NaN,g=(c=f[1].order)!=null?c:NaN;return isNaN(h-g)?0:h-g}var q0="3.1.1",K0=class{constructor(){p0(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Ko(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Ko(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,U0)),n=n._prev;return"["+e.join(", ")+"]"}};function Ko(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function U0(e,t){if(e!=="_next"&&e!=="_prev")return t}var Z0=K0,Q0=()=>1;function J0(e,t){if(e.nodeCount()<=1)return[];let n=tm(e,t||Q0);return em(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function em(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)Rn(e,t,n,a);for(;a=i.dequeue();)Rn(e,t,n,a);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(a=(r=t[c])==null?void 0:r.dequeue(),a){o=o.concat(Rn(e,t,n,a,!0)||[]);break}}}return o}function Rn(e,t,n,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=e.node(a.v);o&&i.push({v:a.v,w:a.w}),l.out-=c,rr(t,n,l)}),(e.outEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=a.w,u=e.node(l);u.in-=c,rr(t,n,u)}),e.removeNode(r.v),s}function tm(e,t){let n=new we,r=0,o=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let c=n.edge(a.v,a.w)||0,l=t(a),u=c+l;n.setEdge(a.v,a.w,u);let d=n.node(a.v),f=n.node(a.w);o=Math.max(o,d.out+=l),r=Math.max(r,f.in+=l)});let i=nm(o+r+3).map(()=>new Z0),s=r+1;return n.nodes().forEach(a=>{rr(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function rr(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function nm(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function rm(e,t){(e.graph().acyclicer==="greedy"?J0(e,n(e)):om(e,t??null)).forEach(r=>{let o=e.edge(r);e.removeEdge(r),o.forwardName=r.name,o.reversed=!0,e.setEdge(r.w,r.v,o,Sr("rev"))});function n(r){return o=>r.edge(o).weight}}function om(e,t){let n=[],r={},o={};function i(c){Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,e.outEdges(c).forEach(l=>{Object.hasOwn(r,l.w)?n.push(l):i(l.w)}),delete r[c])}function s(c){var l;Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,(l=e.outEdges(c))==null||l.forEach(u=>{var d,f;Object.hasOwn(r,u.w)||((d=t.node(c))==null?void 0:d.rank)>((f=t.node(u.w))==null?void 0:f.rank)&&sm(e,u.w,u)?n.push(u):s(u.w)}),delete r[c])}let a=i;return t&&typeof t.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),n}function im(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function sm(e,t,n){let r=new Set;function o(i){var s;if(e.sources().includes(i))return!0;r.add(i);for(let a of(s=e.inEdges(i))!=null?s:[])if(!(a.v===n.v&&a.w===n.w)&&!r.has(a.v)&&o(a.v))return!0;return!1}return o(t)}function am(e){e.graph().dummyChains=[],e.edges().forEach(t=>cm(e,t))}function cm(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,s=t.name,a=e.edge(t),c=a.labelRank;if(i===r+1)return;e.removeEdge(t);let l,u,d;for(d=0,++r;r<i;++d,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},l=at(e,"edge",u,"_d"),r===c&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(n,l,{weight:a.weight},s),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,o,{weight:a.weight},s)}function lm(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function Cr(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),s=i?i.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],a=_e(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),o.rank=a}e.sources().forEach(n)}function st(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var pa=um;function um(e){let t=new we({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,s;for(;dm(t,e)<o&&(i=fm(t,e),!!i);)s=t.hasNode(i.v)?st(e,i):-st(e,i),hm(t,e,s);return t}function dm(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,a=r===s?i.w:s;!e.hasNode(a)&&!st(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function fm(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=st(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function hm(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:gm,postorder:pm}=Nr,mm=Ke;Ke.initLowLimValues=Mr;Ke.initCutValues=kr;Ke.calcCutValue=ma;Ke.leaveEdge=xa;Ke.enterEdge=wa;Ke.exchangeEdges=va;function Ke(e){e=z0(e),Cr(e);let t=pa(e);Mr(t),kr(t,e);let n,r;for(;n=xa(t);)r=wa(t,e,n),va(t,e,n,r)}function kr(e,t){let n=pm(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>ym(e,t,r))}function ym(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=ma(e,t,n)}function ma(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),s=0;i||(o=!1,i=t.edge(r,n)),s=i.weight;let a=t.nodeEdges(n);return a&&a.forEach(c=>{let l=c.v===n,u=l?c.w:c.v;if(u!==r){let d=l===o,f=t.edge(c).weight;if(s+=d?f:-f,wm(e,n,u)){let h=e.edge(n,u).cutvalue;s+=d?-h:h}}}),s}function Mr(e,t){arguments.length<2&&(t=e.nodes()[0]),ya(e,{},1,t)}function ya(e,t,n,r,o){let i=n,s=e.node(r);t[r]=!0;let a=e.neighbors(r);return a&&a.forEach(c=>{Object.hasOwn(t,c)||(n=ya(e,t,n,c,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function xa(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function wa(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),s=e.node(o),a=i,c=!1;return i.lim>s.lim&&(a=s,c=!0),t.edges().filter(l=>c===Uo(e,e.node(l.v),a)&&c!==Uo(e,e.node(l.w),a)).reduce((l,u)=>st(t,u)<st(t,l)?u:l)}function va(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Mr(e),kr(e,t),xm(e,t)}function xm(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=gm(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),a=!1;s||(s=t.edge(i,o),a=!0),t.node(o).rank=t.node(i).rank+(a?s.minlen:-s.minlen)})}function wm(e,t,n){return e.hasEdge(t,n)}function Uo(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var vm=bm;function bm(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Zo(e);break;case"tight-tree":_m(e);break;case"longest-path":Em(e);break;case"none":break;default:Zo(e)}}var Em=Cr;function _m(e){Cr(e),pa(e)}function Zo(e){mm(e)}var Nm=Sm;function Sm(e){let t=km(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(r=>{let o=e.node(r),i=o.edgeObj,s=Cm(e,t,i.v,i.w),a=s.path,c=s.lca,l=0,u=a[l],d=!0;for(;r!==i.w;){if(o=e.node(r),d){for(;(u=a[l])!==c&&e.node(u).maxRank<o.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<a.length-1&&e.node(a[l+1]).minRank<=o.rank;)l++;u=a[l]}u!==void 0&&e.setParent(r,u),r=e.successors(r)[0]}})}function Cm(e,t,n,r){let o=[],i=[],s=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),o.push(c);while(c&&(t[c].low>s||a>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)i.push(u);return{path:o.concat(i.reverse()),lca:l}}function km(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(Nn).forEach(r),t}function Mm(e){let t=at(e,"root",{},"_root"),n=Im(e),r=Object.values(n),o=_e(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=Am(e)+1;e.children(Nn).forEach(a=>{ba(e,t,i,s,o,n,a)}),e.graph().nodeRankFactor=i}function ba(e,t,n,r,o,i,s){var a;let c=e.children(s);if(!c.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let l=qo(e,"_bt"),u=qo(e,"_bb"),d=e.node(s);e.setParent(l,s),d.borderTop=l,e.setParent(u,s),d.borderBottom=u,c.forEach(f=>{var h;ba(e,t,n,r,o,i,f);let g=e.node(f),v=g.borderTop?g.borderTop:f,w=g.borderBottom?g.borderBottom:f,m=g.borderTop?r:2*r,b=v!==w?1:o-((h=i[s])!=null?h:0)+1;e.setEdge(l,v,{weight:m,minlen:b,nestingEdge:!0}),e.setEdge(w,u,{weight:m,minlen:b,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,l,{weight:0,minlen:o+((a=i[s])!=null?a:0)})}function Im(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children(Nn).forEach(r=>n(r,1)),t}function Am(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Tm(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Om=Pm;function Pm(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),o&&Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Qo(e,"borderLeft","_bl",n,o,i),Qo(e,"borderRight","_br",n,o,i)}}e.children(Nn).forEach(t)}function Qo(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=at(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}function $m(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&Ea(e)}function jm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Lm(e),(n==="lr"||n==="rl")&&(Dm(e),Ea(e))}function Ea(e){e.nodes().forEach(t=>Jo(e.node(t))),e.edges().forEach(t=>Jo(e.edge(t)))}function Jo(e){let t=e.width;e.width=e.height,e.height=t}function Lm(e){e.nodes().forEach(t=>Hn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Hn),Object.hasOwn(r,"y")&&Hn(r)})}function Hn(e){e.y=-e.y}function Dm(e){e.nodes().forEach(t=>zn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(zn),Object.hasOwn(r,"x")&&zn(r)})}function zn(e){let t=e.x;e.x=e.y,e.y=t}function Rm(e,t=null){let n={},r=e.nodes().filter(l=>!e.children(l).length),o=r.map(l=>e.node(l).rank),i=_e(Math.max,o),s=St(i+1).map(()=>[]);function a(l){if(n[l])return;n[l]=!0;let u=e.node(l);s[u.rank].push(l);let d=e.successors(l);d&&[...d].sort((f,h)=>c(f,h)).forEach(a)}r.sort((l,u)=>e.node(l).rank-e.node(u).rank).forEach(a);function c(l,u){let d=e.node(l),f=e.node(u);return ga(t,d,f)}return s}function Hm(e,t){let n=0;for(let r=1;r<t.length;++r)n+=zm(e,t[r-1],t[r]);return n}function zm(e,t,n){let r=G0(n,n.map((l,u)=>u)),o=t.flatMap(l=>{let u=e.outEdges(l);return u?u.map(d=>({pos:r[d.w],weight:e.edge(d).weight})).sort((d,f)=>d.pos-f.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let a=new Array(s).fill(0),c=0;return o.forEach(l=>{let u=l.pos+i;a[u]+=l.weight;let d=0;for(;u>0;)u%2&&(d+=a[u+1]),u=u-1>>1,a[u]+=l.weight;c+=l.weight*d}),c}function Fm(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,s)=>{let a=e.edge(s),c=e.node(s.v);return{sum:i.sum+a.weight*c.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function Bm(e,t){let n={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),n[o.v]=s}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(n).filter(o=>!o.indegree);return Vm(r)}function Vm(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Ym(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>un(o,["vs","i","barycenter","weight"]))}function Ym(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Xm(e,t,n,r,o){let i={},s=null,a=null,c=o;typeof t=="boolean"?(c=t,i={}):t&&(i=t,s=n??null,a=r??null);let l=Y0(e,m=>Object.hasOwn(m,"barycenter")),u=l.lhs,d=l.rhs.sort((m,b)=>b.i-m.i),f=[],h=0,g=0,v=0;u.sort(Wm(a,s,!!c));for(let[m,b]of Object.entries(i)){let p=u.findIndex(x=>x.vs[0]===m);u.splice(p+1,0,b)}v=ei(f,d,v),u.forEach(m=>{v+=m.vs.length,f.push(m.vs),h+=m.barycenter*m.weight,g+=m.weight,v=ei(f,d,v)});let w={vs:f.flat(1)};return g&&(w.barycenter=h/g,w.weight=g),w}function ei(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Wm(e,t,n){return(r,o)=>{if(r.barycenter<o.barycenter)return-1;if(r.barycenter>o.barycenter)return 1;if(e&&(typeof r.vs[0]=="string"||typeof o.vs[0]=="string")){let i=e.node(r.vs[0]),s=e.node(o.vs[0]),a=ga(t,i,s);if(a!==0)return a}return n?o.i-r.i:r.i-o.i}}function _a(e,t,n,r,o){var i,s,a,c,l,u,d,f,h,g,v;let w=null,m=o;typeof r=="boolean"?(m=r,w=null):r!==void 0&&(w=r);let b=e.children(t),p=e.node(t),x=p?p.borderLeft:void 0,_=p?p.borderRight:void 0,S={};x&&(b=b.filter($=>$!==x&&$!==_));let k=Fm(e,b);k.forEach($=>{if(e.children($.v).length){let{result:P}=_a(e,$.v,n,w,m);S[$.v]=P,Object.hasOwn(P,"barycenter")&&qm($,P)}});let M=Bm(k,n);Gm(M,S);let I={},z=!1;for(let $=0;$<M.length;$++)for(let P=$+1;P<M.length;P++)if(!(!M[$]||!M[P]||!((i=M[$])!=null&&i.barycenter)||!((s=M[P])!=null&&s.barycenter))&&((a=M[$])==null?void 0:a.barycenter)===M[P].barycenter){let y=(l=(c=M[$])==null?void 0:c.vs[0])!=null?l:"",N=(d=(u=M[P])==null?void 0:u.vs[0])!=null?d:"",C=e.node(y),A=e.node(N);if(C.dummy==="edge"&&A.dummy==="edge"&&((f=C.edgeObj)==null?void 0:f.v)===((h=A.edgeObj)==null?void 0:h.v)&&((g=C.edgeObj)==null?void 0:g.w)===((v=A.edgeObj)==null?void 0:v.w))if(C.edgeLabel.reversed){I[N]=M[$],M.splice($,1),$--;break}else I[y]=M[P],M.splice(P,1),P--;else z=!0}let O=Xm(M,I,w,e,m);if(x&&_){O.vs=[x,O.vs,_].flat(1);let $=e.predecessors(x);if($&&$.length){let P=e.node($[0]),y=e.predecessors(_),N=e.node(y[0]);Object.hasOwn(O,"barycenter")||(O.barycenter=0,O.weight=0),O.barycenter=(O.barycenter*O.weight+P.order+N.order)/(O.weight+2),O.weight+=2}}return Object.defineProperty(O,"result",{value:O,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(O,"usedBias",{value:z,enumerable:!1,configurable:!0,writable:!0}),O}function Gm(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function qm(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Km(e,t,n,r){r||(r=e.nodes());let o=Um(e),i=new we({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),c=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){i.setNode(s),i.setParent(s,c||o);let l=e[n](s);l&&l.forEach(u=>{let d=u.v===s?u.w:u.v,f=i.edge(d,s),h=f!==void 0?f.weight:0;i.setEdge(d,s,{weight:e.edge(u).weight+h})}),Object.hasOwn(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),i}function Um(e){let t;for(;e.hasNode(t=Sr("_root")););return t}function Zm(e,t,n){let r={},o;n.forEach(i=>{let s=e.parent(i),a,c;for(;s;){if(a=e.parent(s),a?(c=r[a],r[a]=s):(c=o,o=s),c&&c!==s){t.setEdge(c,s);return}s=a}})}function Na(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,Na);return}let r=fa(e),o=ti(e,St(1,r+1),"inEdges"),i=ti(e,St(r-1,-1,-1),"outEdges"),s=Rm(e,n);if(ni(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,c,l=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){Qm(u%2?o:i,u%4>=2,l,n),s=Pt(e);let f=Hm(e,s);f<a?(d=0,c=Object.assign({},s),a=f):f===a&&(c=structuredClone(s))}ni(e,c)}function ti(e,t,n){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&o(a,i)}return t.map(function(i){return Km(e,i,n,r.get(i)||[])})}function Qm(e,t,n,r){let o=!0,i=new we;e.forEach(function(s){n.forEach(u=>i.setEdge(u.left,u.right));let a=s.graph().root,{result:c,usedBias:l}=_a(s,a,i,r,o);t&&l&&(o=!o),c.vs.forEach((u,d)=>s.node(u).order=d),Zm(s,i,c.vs)})}function ni(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function Jm(e,t){let n={};function r(o,i){let s=0,a=0,c=o.length,l=i[i.length-1];return i.forEach((u,d)=>{let f=ty(e,u),h=f?e.node(f).order:c;(f||u===l)&&(i.slice(a,d+1).forEach(g=>{let v=e.predecessors(g);v&&v.forEach(w=>{let m=e.node(w),b=m.order;(b<s||h<b)&&!(m.dummy&&e.node(g).dummy)&&Sa(n,w,g)})}),a=d+1,s=h)}),i}return t.length&&t.reduce(r),n}function ey(e,t){let n={};function r(i,s,a,c,l){St(s,a).forEach(u=>{let d=i[u];if(d!==void 0&&e.node(d).dummy){let f=e.predecessors(d);f&&f.forEach(h=>{if(h===void 0)return;let g=e.node(h);g.dummy&&(g.order<c||g.order>l)&&Sa(n,h,d)})}})}function o(i,s){let a=-1,c=-1,l=0;return s.forEach((u,d)=>{if(e.node(u).dummy==="border"){let f=e.predecessors(u);if(f&&f.length){let h=f[0];if(h===void 0)return;c=e.node(h).order,r(s,l,d,a,c),l=d,a=c}}r(s,l,s.length,c,i.length)}),s}return t.length&&t.reduce(o),n}function ty(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function Sa(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function ny(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function ry(e,t,n,r,o){let i={},s={},a={};return t.forEach(c=>{c.forEach((l,u)=>{i[l]=l,s[l]=l,a[l]=u})}),t.forEach(c=>{let l=-1,u=-1,d=!1,f=c,h=c.findIndex(g=>(o==null?void 0:o.includes(g))||ri(g,e,o));h>0&&(f=[c[h],...c.slice(0,h),...c.slice(h+1)],d=!0),f.forEach(g=>{var v;let w=r(g);if(w&&w.length){o!=null&&o.includes(g)&&(w=w.filter(p=>ri(p,e,o)));let m=w.sort((p,x)=>{let _=a[p],S=a[x];return(_!==void 0?_:0)-(S!==void 0?S:0)}),b=(m.length-1)/2;for(let p=Math.floor(b),x=Math.ceil(b);p<=x;++p){let _=m[p];if(_===void 0)continue;let S=a[_];if(S!==void 0&&s[g]===g&&l<S&&a[_]!==u&&!ny(n,g,_)){let k=i[_];k!==void 0&&(s[_]=g,s[g]=i[g]=k,l=S,d&&(l=-1,u=(v=a[_])!=null?v:-1,d=!1))}}}})}),{root:i,align:s}}function oy(e,t,n,r,o=!1){let i={},s=iy(e,t,n,o),a=o?"borderLeft":"borderRight";function c(h,g){let v=s.nodes().slice(),w={},m=v.pop();for(;m;){if(w[m])h(m);else{w[m]=!0,v.push(m);for(let b of g(m))v.push(b)}m=v.pop()}}function l(h){let g=s.inEdges(h);g?i[h]=g.reduce((v,w)=>{var m;let b=(m=i[w.v])!=null?m:0,p=s.edge(w);return Math.max(v,b+(p!==void 0?p:0))},0):i[h]=0}function u(h){let g=s.outEdges(h),v=Number.POSITIVE_INFINITY;g&&(v=g.reduce((m,b)=>{let p=i[b.w],x=s.edge(b);return Math.min(m,(p!==void 0?p:0)-(x!==void 0?x:0))},Number.POSITIVE_INFINITY));let w=e.node(h);v!==Number.POSITIVE_INFINITY&&w.borderType!==a&&(i[h]=Math.max(i[h]!==void 0?i[h]:0,v))}function d(h){return s.predecessors(h)||[]}function f(h){return s.successors(h)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(h=>{var g;let v=n[h];v!==void 0&&(i[h]=(g=i[v])!=null?g:0)}),i}function iy(e,t,n,r){let o=new we,i=e.graph(),s=uy(i.nodesep,i.edgesep,r);return t.forEach(a=>{let c;a.forEach(l=>{let u=n[l];if(u!==void 0){if(o.setNode(u),c!==void 0){let d=n[c];if(d!==void 0){let f=o.edge(d,u);o.setEdge(d,u,Math.max(s(e,l,c),f||0))}}c=l}})}),o}function sy(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,c])=>{let l=dy(e,a)/2;o=Math.max(c+l,o),i=Math.min(c-l,i)});let s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function ay(e,t){let n=Object.values(t),r=_e(Math.min,n),o=_e(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,c=e[a];if(!c||c===t)return;let l=Object.values(c),u=r-_e(Math.min,l);s!=="l"&&(u=o-_e(Math.max,l)),u&&(e[a]=_n(c,d=>d+u))})})}function cy(e,t=void 0){let n=e.ul;return n?_n(n,(r,o)=>{var i,s;if(t){let c=t.toLowerCase(),l=e[c];if(l&&l[o]!==void 0)return l[o]}let a=Object.values(e).map(c=>{let l=c[o];return l!==void 0?l:0}).sort((c,l)=>c-l);return(((i=a[1])!=null?i:0)+((s=a[2])!=null?s:0))/2}):{}}function ly(e,t){let n=Pt(e),r=Object.assign(Jm(e,n),ey(e,n)),o={},i;["u","d"].forEach(a=>{i=a==="u"?n:Object.values(n).reverse(),["l","r"].forEach(c=>{c==="r"&&(i=i.map(d=>Object.values(d).reverse()));let l=ry(e,i,r,d=>(a==="u"?e.predecessors(d):e.successors(d))||[],t),u=oy(e,i,l.root,l.align,c==="r");c==="r"&&(u=_n(u,d=>-d)),o[a+c]=u})});let s=sy(e,o);return ay(o,s),cy(o,e.graph().align)}function uy(e,t,n){return(r,o,i)=>{let s=r.node(o),a=r.node(i),c=0,l;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":l=-s.width/2;break;case"r":l=s.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(s.dummy?t:e)/2,c+=(a.dummy?t:e)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":l=a.width/2;break;case"r":l=-a.width/2;break}return l&&(c+=n?l:-l),c}}function dy(e,t){return e.node(t).width}function ri(e,t,n){var r;if(!n)return!1;let o=(r=t.node(e))==null?void 0:r.edgeObj;if(!o||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(o==null?void 0:o.v),s=n.indexOf(o==null?void 0:o.w);return i!==-1&&s!==-1&&i===(s+1)%n.length||i===(s-1)%n.length}function fy(e,t){e=ua(e),hy(e),Object.entries(ly(e,t)).forEach(([n,r])=>e.node(n).x=r)}function hy(e){let t=Pt(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(s=>{let a=s.reduce((c,l)=>{var u;let d=(u=e.node(l).height)!=null?u:0;return c>d?c:d},0);s.forEach(c=>{let l=e.node(c);o==="top"?l.y=i+l.height/2:o==="bottom"?l.y=i+a-l.height/2:l.y=i+a/2}),i+=a+r})}var oi=new WeakMap;function gy(e,t={}){return Ca(e,ha,t),e}function ii(e,t,n){let r=t;for(;r!==void 0;){let o=e.parent(r);if(o===n)return r;r=o}}function Ca(e,t,n){var r;let o=e.nodes().filter(b=>e.children(b).length),i={};o.forEach(b=>{let p=e.node(b);if(p&&p.rankdir){let x=new we({multigraph:!0,compound:!0});x.setGraph({rankdir:p.rankdir});let _=e.children(b);_.forEach(y=>{let N={...e.node(y)};x.setNode(y,N);let C=e.parent(y);C&&C!==b&&_.includes(C)&&x.setParent(y,C)});let S=new Set;e.edges().forEach(y=>{let N=ii(e,y.v,b),C=ii(e,y.w,b);if(N&&C&&N!==C){let A=`${N}\0${C}`;S.has(A)||(S.add(A),x.setEdge(N,C,{...e.edge(y)}))}}),Ca(x,t,n);let k=li(x);si(k,t,n,null),ai(x,k);let M=1/0,I=1/0,z=-1/0,O=-1/0;x.nodes().forEach(y=>{if(y===b)return;let N=x.node(y);N&&typeof N.x=="number"&&typeof N.y=="number"&&typeof N.width=="number"&&typeof N.height=="number"&&(M=Math.min(M,N.x-N.width/2),z=Math.max(z,N.x+N.width/2),I=Math.min(I,N.y-N.height/2),O=Math.max(O,N.y+N.height/2))}),(!isFinite(M)||!isFinite(I)||!isFinite(z)||!isFinite(O))&&(M=I=0,z=O=0);let $=z-M,P=O-I;i[b]={minX:M,minY:I,maxX:z,maxY:O,width:$,height:P,offsetX:M,offsetY:I},p._dagreClusterSubgraph=x}});let s=[],a=b=>{let p=[],x=(e.children(b)||[]).filter(_=>_!==b);for(;x.length>0;){let _=x.shift();p.push(_),(e.children(_)||[]).filter(S=>S!==_).forEach(S=>x.push(S))}return p},c=new Map;o.forEach(b=>{let p=e.node(b);p&&p.rankdir&&i[b]&&c.set(b,(e.children(b)||[]).filter(x=>x!==b))});let l=new Set([...c.values()].flat()),u=new Map;c.forEach((b,p)=>{l.has(p)||u.set(p,a(p))});let d=new Set([...u.values()].flat()),f=b=>{for(let[p,x]of u)if(x.includes(b))return p;return b},h=[];e.edges().forEach(b=>{(d.has(b.v)||d.has(b.w))&&h.push({edge:b,label:e.edge(b)})});let g=new Map;d.forEach(b=>{let p=e.parent(b);g.set(b,typeof p=="string"?p:void 0)}),u.forEach((b,p)=>{let x=e.node(p),_=[];b.forEach(M=>{let I=e.node(M);I&&(_.push({id:M,node:I,parent:g.get(M)}),e.removeNode(M))});let S=h.filter(({edge:M})=>b.includes(M.v)||b.includes(M.w)),k=i[p];x&&(s.push({clusterId:p,subgraph:x._dagreClusterSubgraph,bounds:k,children:b,removedNodes:_,removedEdges:S}),x.width=k.width,x.height=k.height)});let v=new Set;h.forEach(({edge:b,label:p})=>{let x=f(b.v),_=f(b.w);if(x!==_&&e.hasNode(x)&&e.hasNode(_)){let S=`${x}\0${_}`;v.has(S)||(v.add(S),e.setEdge(x,_,{...p,width:0,height:0}))}});let w=li(e),m=si(w,t,n,(r=oi.get(e))!=null?r:null);oi.set(e,m),ai(e,w),v.forEach(b=>{let p=b.indexOf("\0"),x=b.slice(0,p),_=b.slice(p+1);e.hasEdge(x,_)&&e.removeEdge(x,_)}),s.forEach(({clusterId:b,subgraph:p,bounds:x,removedNodes:_,removedEdges:S})=>{var k,M;let I=e.node(b),z=(k=I==null?void 0:I.x)!=null?k:0,O=(M=I==null?void 0:I.y)!=null?M:0,$=(x.minX+x.maxX)/2,P=(x.minY+x.maxY)/2;_.forEach(({id:y,node:N,parent:C})=>{e.setNode(y,N),C!==void 0&&e.setParent(y,C)}),S.forEach(({edge:y,label:N})=>{e.setEdge(y,N)}),p.nodes().forEach(y=>{if(y===b)return;let N=p.node(y),C=e.node(y);C&&N&&typeof N.x=="number"&&typeof N.y=="number"&&(C.x=z+(N.x-$),C.y=O+(N.y-P))}),delete I._dagreClusterSubgraph}),o.forEach(b=>{var p,x;let _=e.node(b),S=i[b];if(_&&_.rankdir&&_._dagreClusterSubgraph&&S){let k=_._dagreClusterSubgraph,M=(p=_.x)!=null?p:0,I=(x=_.y)!=null?x:0,z=(S.minX+S.maxX)/2,O=(S.minY+S.maxY)/2;k.nodes().forEach($=>{if($===b)return;let P=k.node($),y=e.node($);if(y&&P&&typeof P.x=="number"&&typeof P.y=="number"){let N=P.x-z,C=P.y-O;y.x=M+N,y.y=I+C}}),delete _._dagreClusterSubgraph}})}function si(e,t,n,r=null){var o,i;let s=(n==null?void 0:n.useDynamic)!==!1,a=s&&(o=r==null?void 0:r.graph)!=null?o:null,c=s&&(i=r==null?void 0:r.rawNodes)!=null?i:null;t(" makeSpaceForEdgeLabels",()=>Ey(e)),t(" removeSelfEdges",()=>Ty(e)),t(" acyclic",()=>rm(e,a)),t(" nestingGraph.run",()=>Mm(e)),t(" rank",()=>vm(ua(e))),t(" injectEdgeLabelProxies",()=>_y(e)),t(" removeEmptyRanks",()=>B0(e)),t(" nestingGraph.cleanup",()=>Tm(e)),t(" normalizeRanks",()=>F0(e)),t(" assignRankMinMax",()=>Ny(e)),t(" removeEdgeLabelProxies",()=>Sy(e)),t(" normalize.run",()=>am(e)),t(" parentDummyChains",()=>Nm(e)),t(" addBorderSegments",()=>Om(e)),t(" order",()=>Na(e,n,c)),t(" insertSelfEdges",()=>Oy(e)),t(" adjustCoordinateSystem",()=>$m(e)),t(" position",()=>fy(e,n.corePath)),t(" positionSelfEdges",()=>Py(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>Ay(e)),t(" normalize.undo",()=>lm(e)),t(" fixupEdgeLabelCoords",()=>My(e)),t(" undoCoordinateSystem",()=>jm(e)),t(" translateGraph",()=>Cy(e)),t(" assignNodeIntersects",()=>ky(e)),t(" reversePoints",()=>Iy(e)),t(" acyclic.undo",()=>im(e)),{graph:e,rawNodes:l}}function ai(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var py=["nodesep","edgesep","ranksep","marginx","marginy"],my={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},yy=["acyclicer","ranker","rankdir","align","rankalign"],xy=["width","height","rank"],ci={width:0,height:0},wy=["minlen","weight","width","height","labeloffset"],vy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},by=["labelpos"];function li(e){let t=new we({multigraph:!0,compound:!0}),n=Bn(e.graph());return t.setGraph(Object.assign({},my,Fn(n,py),un(n,yy))),e.nodes().forEach(r=>{let o=Bn(e.node(r)),i=Fn(o,xy);Object.keys(ci).forEach(a=>{i[a]===void 0&&(i[a]=ci[a])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Bn(e.edge(r));t.setEdge(r,Object.assign({},vy,Fn(o,wy),un(o,by)))}),t}function Ey(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{var r;let o=e.edge(n);o.minlen*=2,((r=o.labelpos)!=null?r:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?o.width+=o.labeloffset:o.height+=o.labeloffset)})}function _y(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};at(e,"edge-proxy",o,"_ep")}})}function Ny(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Sy(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Cy(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,a=i.marginy||0;function c(l){let u=l.x,d=l.y,f=l.width,h=l.height;t=Math.min(t,u-f/2),n=Math.max(n,u+f/2),r=Math.min(r,d-h/2),o=Math.max(o,d+h/2)}e.nodes().forEach(l=>c(e.node(l))),e.edges().forEach(l=>{let u=e.edge(l);Object.hasOwn(u,"x")&&c(u)}),t-=s,r-=a,e.nodes().forEach(l=>{let u=e.node(l);u.x-=t,u.y-=r}),e.edges().forEach(l=>{let u=e.edge(l);u.points.forEach(d=>{d.x-=t,d.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=n-t+s,i.height=o-r+a}function ky(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=o,s=r),n.points.unshift(Go(r,i)),n.points.push(Go(o,s))})}function My(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Iy(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Ay(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Ty(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Oy(e){Pt(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);typeof i.rank!="number"&&(i.rank=0),i.order=o+n,(i.selfEdges||[]).forEach(s=>{at(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++n,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Py(e){e.nodes().forEach(t=>{let n=e.node(t),r=o=>typeof o=="number"&&isFinite(o);if(n.dummy==="selfedge"){let o=n,i=e.node(o.e.v),s=r(i==null?void 0:i.x)?i.x:0,a=r(i==null?void 0:i.y)?i.y:0,c=r(i==null?void 0:i.width)?i.width:0,l=r(i==null?void 0:i.height)?i.height:0,u=r(n.x)?n.x:s,d=r(n.y)?n.y:a,f=c/2,h=l/2;o.edgeLabel.points=[{x:u+f,y:d-h},{x:u+f,y:d-h},{x:u,y:d},{x:u-f,y:d+h},{x:u-f,y:d+h},{x:u,y:d},{x:u,y:d}],o.edgeLabel.x=u,o.edgeLabel.y=d,e.setEdge(o.e,o.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(o=>{if(!Array.isArray(o.label.points)||o.label.points.length!==7){let i=r(n.x)?n.x:0,s=r(n.y)?n.y:0,a=r(n.width)?n.width:0,c=r(n.height)?n.height:0,l=a/2,u=c/2;o.label.points=[{x:i+l,y:s-u},{x:i+l,y:s-u},{x:i,y:s},{x:i-l,y:s+u},{x:i-l,y:s+u},{x:i,y:s},{x:i,y:s}]}})})}function Fn(e,t){return _n(un(e,t),Number)}function Bn(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function $y(e){let t=Pt(e),n=new we({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,o)=>{let i="layer"+o;n.setNode(i,{rank:"same"}),r.reduce((s,a)=>(n.setEdge(s,a,{style:"invis"}),a))}),n}var jy={graphlib:na,version:q0,layout:gy,debug:$y,util:{time:X0,notime:ha}},ui=jy;/*! For license information please see dagre.esm.js.LEGAL.txt */const di=80,Ly=6.6,Dy=18,Ry=16.5,Hy=8;function mx(e){return e.length===0?void 0:{width:Math.max(...e.map(n=>n.length))*Ly+Dy,height:e.length*Ry+Hy}}function zy(e,t){const n=new Map,r=Math.ceil(Math.sqrt(e.length)),{maxWidth:o,maxHeight:i}=e.reduce((s,a)=>({maxWidth:Math.max(s.maxWidth,a.width),maxHeight:Math.max(s.maxHeight,a.height)}),{maxWidth:0,maxHeight:0});return e.forEach((s,a)=>{const c=a%r,l=Math.floor(a/r),u=t==="horizontal"?c:l,d=t==="horizontal"?l:c;n.set(s.id,{x:u*(o+di),y:d*(i+di)})}),n}function Fy(e){const t=new Set,n=[];for(const r of e){if(r.sourceId===r.targetId)continue;const o=`${r.sourceId} -> ${r.targetId}`;t.has(o)||(t.add(o),n.push(r))}return n}function fi(e,t,n){const r=new Map,o=new Map,i=new Map,s=new ui.graphlib.Graph({multigraph:!0});s.setGraph({rankdir:n==="horizontal"?"LR":"TB"}),s.setDefaultEdgeLabel(()=>({}));for(const a of e)s.setNode(a.id,{width:a.width,height:a.height});for(const a of t){const c=a.label?{width:a.label.width,height:a.label.height,labelpos:"c"}:{};s.setEdge(a.sourceId,a.targetId,c,a.id)}ui.layout(s);for(const a of s.nodes()){const c=s.node(a);c.x===void 0||c.y===void 0||r.set(a,{x:c.x-c.width/2,y:c.y-c.height/2})}for(const a of t){if(!s.hasEdge(a.sourceId,a.targetId,a.id))continue;const c=s.edge({v:a.sourceId,w:a.targetId,name:a.id}),l=(c.points??[]).slice(1,-1);l.length>0&&o.set(a.id,l),c.x!==void 0&&c.y!==void 0&&i.set(a.id,{x:c.x,y:c.y})}return{positions:r,routes:o,labelPositions:i}}function yx(e,t,n){if(e.length===0)return{positions:new Map,routes:new Map,labelPositions:new Map};try{return fi(e,t,n)}catch{const r=Fy(t);if(r.length<t.length)try{return fi(e,r,n)}catch{}return{positions:zy(e,n),routes:new Map,labelPositions:new Map}}}const ka={alias:!0,description:!0},xx=256,By=26,Vy=14,Yy=26,Xy=4;function Ma(e){return[...e.filter(t=>t.isPrimaryKey),...e.filter(t=>!t.isPrimaryKey)]}function Ia(e){const t=e.filter(n=>n.isPrimaryKey).length;return Math.min(e.length,Math.max(Xy,t))}function Aa(e){return e.alias.trim()!==e.name.trim()}function Wy(e,t){return t.alias&&Aa(e)?e.alias:e.name}function Ta(e,t){var n;return t.description&&((n=e.description)!=null&&n.trim())?e.description:null}function Gy(e,t){return By+(Ta(e,t)?Vy:0)}function wx(e,t=ka){if(e.length===0)return 0;const n=Ia(e),r=e.length>n;return Ma(e).slice(0,n).reduce((s,a)=>s+Gy(a,t),0)+(r?Yy:0)}function vx({markerId:e,color:t,withStart:n}){return E.jsxs("defs",{children:[E.jsx("marker",{id:`${e}-end`,markerWidth:"9",markerHeight:"9",refX:"7",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:E.jsx("path",{d:"M0,0 L7,3 L0,6 z",fill:t})}),n&&E.jsx("marker",{id:`${e}-start`,markerWidth:"9",markerHeight:"9",refX:"0",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:E.jsx("path",{d:"M7,0 L0,3 L7,6 z",fill:t})})]})}function bx({x:e,y:t,lines:n,selected:r,dimmed:o}){return n.length===0?null:E.jsx("foreignObject",{x:e,y:t,width:1,height:1,style:{overflow:"visible"},children:E.jsx("div",{style:{transform:"translate(-50%, -50%)",width:"max-content",background:"var(--background)",border:`1px solid ${r?"var(--primary)":"var(--border)"}`,borderRadius:8,padding:"3px 8px",fontSize:11,fontWeight:600,lineHeight:1.5,color:"var(--foreground)",pointerEvents:"none",opacity:o?f0:1,transition:"opacity 0.2s",boxShadow:"0 1px 3px 0 rgba(0,0,0,0.08)"},children:n.map((i,s)=>E.jsx("div",{children:i},`${String(s)}-${i}`))})})}function Ex(e,t){return`${e}-${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function qy({field:e,labels:t}){const n=Wy(e,t),r=Ta(e,t),o=Aa(e)?n===e.name?e.alias:e.name:null,i=[[n,o].filter(Boolean).join(" · "),e.isHidden?"(hidden from reporting)":null].filter(Boolean).join(" ");return E.jsxs("div",{className:"border-border/50 border-b px-3.5 py-1.5 text-[11.5px] last:border-b-0",style:{opacity:e.isHidden?.5:1},title:i,children:[E.jsxs("div",{className:"flex items-center gap-2",children:[e.isPrimaryKey?E.jsx(tl,{className:"h-3 w-3 shrink-0",style:{color:l0},"aria-label":"Primary key"}):E.jsx("span",{className:"w-3 shrink-0"}),E.jsx("span",{className:"text-foreground flex-1 truncate",children:n}),E.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-[10px] tracking-tight",children:e.type})]}),r&&E.jsx("div",{className:"text-muted-foreground/80 truncate pl-5 text-[10.5px] leading-[14px] italic",title:r,children:r})]})}function _x({fields:e,labels:t=ka,expanded:n,onToggleExpanded:r}){const o=Ma(e),i=Ia(e),s=n?o:o.slice(0,i),a=o.length-i;function c(l){l.stopPropagation(),l.preventDefault(),r()}return E.jsxs("div",{className:"border-t",children:[s.map(l=>E.jsx(qy,{field:l,labels:t},l.name)),a>0&&E.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground hover:bg-muted nodrag flex w-full items-center justify-center gap-1 border-t py-1.5 text-[11px] font-medium transition-colors",onPointerDown:l=>{l.stopPropagation()},onClick:c,children:n?E.jsxs(E.Fragment,{children:[E.jsx(Jc,{className:"h-3 w-3"})," Show less"]}):E.jsxs(E.Fragment,{children:[E.jsx(el,{className:"h-3 w-3"})," +",a," more field",a!==1?"s":""]})})]})}export{wx as A,En as B,Jy as C,f0 as D,_x as E,ka as F,ig as G,sn as H,sg as I,Df as J,Qy as M,dx as N,l0 as O,W as P,kp as R,lx as S,nx as W,ex as a,br as b,te as c,gx as d,hx as e,fx as f,gr as g,px as h,Uy as i,cx as j,d0 as k,tx as l,rx as m,mx as n,ux as o,is as p,ox as q,yx as r,Ex as s,vx as t,Zy as u,ax as v,sx as w,ix as x,bx as y,xx as z};
|
|
12
|
+
`,fx={highlighted:!1,dimmed:!1};function hx(e,t,n,r){const o=t.trim().toLowerCase(),i=new Map;for(const s of e){const a=o!==""&&r(s).toLowerCase().includes(o);i.set(n(s),{highlighted:a,dimmed:o!==""&&!a})}return i}function gx(e){if(e.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const i of e)t=Math.min(t,i.position.x),n=Math.min(n,i.position.y),r=Math.max(r,i.position.x+(i.width??0)),o=Math.max(o,i.position.y+(i.height??0));return{minX:t,minY:n,maxX:r,maxY:o}}function px(e,t,n,r,o){const i=o-t.maxX*e.zoom,s=n-o-t.minX*e.zoom,a=o-t.maxY*e.zoom,c=r-o-t.minY*e.zoom;return{x:Math.min(Math.max(e.x,i),s),y:Math.min(Math.max(e.y,a),c),zoom:e.zoom}}var ta=Object.defineProperty,h0=(e,t,n)=>t in e?ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g0=(e,t)=>{for(var n in t)ta(e,n,{get:t[n],enumerable:!0})},p0=(e,t,n)=>h0(e,t+"",n),na={};g0(na,{Graph:()=>we,alg:()=>Nr});var m0=Object.defineProperty,ra=(e,t)=>{for(var n in t)m0(e,n,{get:t[n],enumerable:!0})},_r=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let o of r)n.add(o);return Array.from(n.values())}}isLeaf(e){var t;let n;return this.isDirected()?n=this.successors(e):n=this.neighbors(e),((t=n==null?void 0:n.length)!=null?t:0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,s,a,c=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(a=t,c=!0)):(o=e,i=t,s=r,arguments.length>2&&(a=n,c=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let l=ht(this._isDirected,o,i,s);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[l]=c?a:this._defaultEdgeLabelFn(o,i,s);let u=y0(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[l]=u,Xo(this._preds[i],o),Xo(this._sucs[o],i),this._in[i][l]=u,this._out[o][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"||r===null?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Dn(this._isDirected,e):ht(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Wo(this._preds[s],i),Wo(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function Xo(e,t){e[t]?e[t]++:e[t]=1}function Wo(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function ht(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function y0(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let a=o;o=i,i=a}let s={v:o,w:i};return r&&(s.name=r),s}function Dn(e,t){return ht(e,t.v,t.w,t.name)}var x0={};ra(x0,{read:()=>E0,write:()=>w0});function w0(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:v0(e),edges:b0(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function v0(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function b0(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function E0(e){let t=new _r(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var Nr={};ra(Nr,{CycleException:()=>ln,bellmanFord:()=>oa,components:()=>S0,dijkstra:()=>cn,dijkstraAll:()=>M0,findCycles:()=>I0,floydWarshall:()=>T0,isAcyclic:()=>P0,postorder:()=>j0,preorder:()=>L0,prim:()=>D0,shortestPaths:()=>R0,tarjan:()=>sa,topsort:()=>aa});var _0=()=>1;function oa(e,t,n,r){return N0(e,String(t),n||_0,r||function(o){var i;return(i=e.outEdges(o))!=null?i:[]})}function N0(e,t,n,r){let o={},i,s=0,a=e.nodes(),c=function(d){let f=o[d.v],h=o[d.w];if(!f||!h)return;let g=n(d);f.distance+g<h.distance&&(o[d.w]={distance:f.distance+g,predecessor:d.v},i=!0)},l=function(){a.forEach(function(d){r(d).forEach(function(f){let h=f.v===d?f.v:f.w,g=h===f.v?f.w:f.v;c({v:h,w:g})})})};a.forEach(function(d){let f=d===t?0:Number.POSITIVE_INFINITY;o[d]={distance:f,predecessor:""}});let u=a.length;for(let d=1;d<u&&(i=!1,s++,l(),!!i);d++);if(s===u-1&&(i=!1,l(),i))throw new Error("The graph contains a negative weight cycle");return o}function S0(e){let t={},n=[],r;function o(i){var s,a;i in t||(t[i]=!0,r.push(i),(s=e.successors(i))==null||s.forEach(o),(a=e.predecessors(i))==null||a.forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var ia=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw new Error("Queue underflow");this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},C0=()=>1;function cn(e,t,n,r){let o=function(i){var s;return(s=e.outEdges(i))!=null?s:[]};return k0(e,String(t),n||C0,r||o)}function k0(e,t,n,r){let o={},i=new ia,s,a,c=function(l){let u=l.v!==s?l.v:l.w,d=o[u];if(!d)return;let f=n(l),h=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+l+" Weight: "+f);h<d.distance&&(d.distance=h,d.predecessor=s,i.decrease(u,h))};for(e.nodes().forEach(function(l){let u=l===t?0:Number.POSITIVE_INFINITY;o[l]={distance:u,predecessor:""},i.add(l,u)});i.size()>0;){s=i.removeMin();let l=o[s];if(!l||l.distance===Number.POSITIVE_INFINITY)break;a=l,r(s).forEach(c)}return o}function M0(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=cn(e,o,t,n),r},{})}function sa(e){let t=0,n=[],r={},o=[];function i(s){var a;let c=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),(a=e.successors(s))==null||a.forEach(function(l){if(l in r){let u=r[l];u!=null&&u.onStack&&(c.lowlink=Math.min(c.lowlink,u.index))}else{i(l);let u=r[l];u&&(c.lowlink=Math.min(c.lowlink,u.lowlink))}}),c.lowlink===c.index){let l=[],u;do{u=n.pop();let d=r[u];d&&(d.onStack=!1),l.push(u)}while(s!==u);o.push(l)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function I0(e){return sa(e).filter(function(t){var n;let r=t[0];return r?t.length>1||t.length===1&&((n=e.outEdges(r,r))!=null?n:[]).length>0:!1})}var A0=()=>1;function T0(e,t,n){return O0(e,t||A0,n||function(r){var o;return(o=e.outEdges(r))!=null?o:[]})}function O0(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){let s={};r[i]=s,s[i]={distance:0,predecessor:""},o.forEach(function(a){i!==a&&(s[a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(a){let c=a.v===i?a.w:a.v,l=t(a);s[c]={distance:l,predecessor:i}})}),o.forEach(function(i){let s=r[i];s&&o.forEach(function(a){let c=r[a];c&&o.forEach(function(l){let u=c[i],d=s[l],f=c[l];if(u&&d&&f){let h=u.distance+d.distance;h<f.distance&&(f.distance=h,f.predecessor=d.predecessor)}})})}),r}var ln=class extends Error{constructor(e){super(e),this.name="CycleException"}};function aa(e){let t={},n={},r=[];function o(i){var s;if(i in n)throw new ln;i in t||(n[i]=!0,t[i]=!0,(s=e.predecessors(i))==null||s.forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new ln;return r}function P0(e){try{aa(e)}catch(t){if(t instanceof ln)return!1;throw t}return!0}function $0(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=(a=>{var c;return(c=e.isDirected()?e.successors(a):e.neighbors(a))!=null?c:[]}),s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);o=ca(e,a,n==="post",s,i,r,o)}),o}function ca(e,t,n,r,o,i,s){return t in r||(r[t]=!0,n||(s=i(s,t)),o(t).forEach(function(a){s=ca(e,a,n,r,o,i,s)}),n&&(s=i(s,t))),s}function la(e,t,n){return $0(e,t,n,function(r,o){return r.push(o),r},[])}function j0(e,t){return la(e,t,"post")}function L0(e,t){return la(e,t,"pre")}function D0(e,t){var n;let r=new _r,o={},i=new ia,s;function a(u){let d=u.v===s?u.w:u.v,f=i.priority(d);if(f!==void 0){let h=t(u);h<f&&(o[d]=s,i.decrease(d,h))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(u){i.add(u,Number.POSITIVE_INFINITY),r.setNode(u)});let c=e.nodes()[0];c!==void 0&&i.decrease(c,0);let l=!1;for(;i.size()>0;){if(s=i.removeMin(),s in o)r.setEdge(s,o[s]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}(n=e.nodeEdges(s))==null||n.forEach(a)}return r}function R0(e,t,n,r){return H0(e,t,n,r??(o=>{var i;return(i=e.outEdges(o))!=null?i:[]}))}function H0(e,t,n,r){if(n===void 0)return cn(e,t,n,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let a=i[s];if(a===void 0)continue;let c=r(a);for(let l=0;l<c.length;l++){let u=c[l];if(!u)continue;let d=u.v===a?u.v:u.w,f=d===u.v?u.w:u.v;n({v:d,w:f})<0&&(o=!0)}if(o)return oa(e,t,n,r)}return cn(e,t,n,r)}var we=_r;function at(e,t,n,r){let o=r;for(;e.hasNode(o);)o=Sr(r);return n.dummy=t,e.setNode(o,n),o}function z0(e){let t=new we().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function ua(e){let t=new we({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Go(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,s=e.width/2,a=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let c,l;return Math.abs(i)*s>Math.abs(o)*a?(i<0&&(a=-a),c=a*o/i,l=a):(o<0&&(s=-s),c=s,l=s*i/o),{x:n+c,y:r+l}}function Pt(e){let t=St(fa(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function F0(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=_e(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function B0(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=_e(Math.min,t),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;r[a]||(r[a]=[]),r[a].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%i!==0?--o:s!==void 0&&o&&s.forEach(c=>e.node(c).rank+=o)})}function qo(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),at(e,"border",o,t)}function V0(e,t=da){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var da=65535;function _e(e,t){if(t.length>da){let n=V0(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function fa(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return _e(Math.max,t)}function Y0(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function X0(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function ha(e,t){return t()}var W0=0;function Sr(e){let t=++W0;return e+(""+t)}function St(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function un(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function _n(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function G0(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Nn="\0";function ga(e,t,n){var r,o,i,s,a,c;if(!(e&&t&&n&&t.dummy==="edge"&&n.dummy==="edge"&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let l=!0;t.edgeObj.w===n.edgeObj.w&&(l=!1);let u=l?(o=(r=e[t.edgeObj.v])==null?void 0:r.rank)!=null?o:NaN+1:(s=(i=e[t.edgeObj.w])==null?void 0:i.rank)!=null?s:NaN-1,d=Object.entries(e).find(v=>{var w,m;return((w=v[1].edgeObj)==null?void 0:w.v)===t.edgeObj.v&&((m=v[1].edgeObj)==null?void 0:m.w)===t.edgeObj.w&&v[1].rank===u}),f=Object.entries(e).find(v=>{var w,m;return((w=v[1].edgeObj)==null?void 0:w.v)===n.edgeObj.v&&((m=v[1].edgeObj)==null?void 0:m.w)===n.edgeObj.w&&v[1].rank===u});if(!d||!f)return 0;let h=(a=d[1].order)!=null?a:NaN,g=(c=f[1].order)!=null?c:NaN;return isNaN(h-g)?0:h-g}var q0="3.1.1",K0=class{constructor(){p0(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Ko(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Ko(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,U0)),n=n._prev;return"["+e.join(", ")+"]"}};function Ko(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function U0(e,t){if(e!=="_next"&&e!=="_prev")return t}var Z0=K0,Q0=()=>1;function J0(e,t){if(e.nodeCount()<=1)return[];let n=tm(e,t||Q0);return em(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function em(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)Rn(e,t,n,a);for(;a=i.dequeue();)Rn(e,t,n,a);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(a=(r=t[c])==null?void 0:r.dequeue(),a){o=o.concat(Rn(e,t,n,a,!0)||[]);break}}}return o}function Rn(e,t,n,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=e.node(a.v);o&&i.push({v:a.v,w:a.w}),l.out-=c,rr(t,n,l)}),(e.outEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=a.w,u=e.node(l);u.in-=c,rr(t,n,u)}),e.removeNode(r.v),s}function tm(e,t){let n=new we,r=0,o=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let c=n.edge(a.v,a.w)||0,l=t(a),u=c+l;n.setEdge(a.v,a.w,u);let d=n.node(a.v),f=n.node(a.w);o=Math.max(o,d.out+=l),r=Math.max(r,f.in+=l)});let i=nm(o+r+3).map(()=>new Z0),s=r+1;return n.nodes().forEach(a=>{rr(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function rr(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function nm(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function rm(e,t){(e.graph().acyclicer==="greedy"?J0(e,n(e)):om(e,t??null)).forEach(r=>{let o=e.edge(r);e.removeEdge(r),o.forwardName=r.name,o.reversed=!0,e.setEdge(r.w,r.v,o,Sr("rev"))});function n(r){return o=>r.edge(o).weight}}function om(e,t){let n=[],r={},o={};function i(c){Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,e.outEdges(c).forEach(l=>{Object.hasOwn(r,l.w)?n.push(l):i(l.w)}),delete r[c])}function s(c){var l;Object.hasOwn(o,c)||(o[c]=!0,r[c]=!0,(l=e.outEdges(c))==null||l.forEach(u=>{var d,f;Object.hasOwn(r,u.w)||((d=t.node(c))==null?void 0:d.rank)>((f=t.node(u.w))==null?void 0:f.rank)&&sm(e,u.w,u)?n.push(u):s(u.w)}),delete r[c])}let a=i;return t&&typeof t.node=="function"&&(a=s),e.sources().forEach(a),e.nodes().forEach(a),n}function im(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function sm(e,t,n){let r=new Set;function o(i){var s;if(e.sources().includes(i))return!0;r.add(i);for(let a of(s=e.inEdges(i))!=null?s:[])if(!(a.v===n.v&&a.w===n.w)&&!r.has(a.v)&&o(a.v))return!0;return!1}return o(t)}function am(e){e.graph().dummyChains=[],e.edges().forEach(t=>cm(e,t))}function cm(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,s=t.name,a=e.edge(t),c=a.labelRank;if(i===r+1)return;e.removeEdge(t);let l,u,d;for(d=0,++r;r<i;++d,++r)a.points=[],u={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},l=at(e,"edge",u,"_d"),r===c&&(u.width=a.width,u.height=a.height,u.dummy="edge-label",u.labelpos=a.labelpos),e.setEdge(n,l,{weight:a.weight},s),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,o,{weight:a.weight},s)}function lm(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function Cr(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),s=i?i.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],a=_e(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),o.rank=a}e.sources().forEach(n)}function st(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var pa=um;function um(e){let t=new we({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,s;for(;dm(t,e)<o&&(i=fm(t,e),!!i);)s=t.hasNode(i.v)?st(e,i):-st(e,i),hm(t,e,s);return t}function dm(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,a=r===s?i.w:s;!e.hasNode(a)&&!st(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function fm(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=st(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function hm(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:gm,postorder:pm}=Nr,mm=Ke;Ke.initLowLimValues=Mr;Ke.initCutValues=kr;Ke.calcCutValue=ma;Ke.leaveEdge=xa;Ke.enterEdge=wa;Ke.exchangeEdges=va;function Ke(e){e=z0(e),Cr(e);let t=pa(e);Mr(t),kr(t,e);let n,r;for(;n=xa(t);)r=wa(t,e,n),va(t,e,n,r)}function kr(e,t){let n=pm(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>ym(e,t,r))}function ym(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=ma(e,t,n)}function ma(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),s=0;i||(o=!1,i=t.edge(r,n)),s=i.weight;let a=t.nodeEdges(n);return a&&a.forEach(c=>{let l=c.v===n,u=l?c.w:c.v;if(u!==r){let d=l===o,f=t.edge(c).weight;if(s+=d?f:-f,wm(e,n,u)){let h=e.edge(n,u).cutvalue;s+=d?-h:h}}}),s}function Mr(e,t){arguments.length<2&&(t=e.nodes()[0]),ya(e,{},1,t)}function ya(e,t,n,r,o){let i=n,s=e.node(r);t[r]=!0;let a=e.neighbors(r);return a&&a.forEach(c=>{Object.hasOwn(t,c)||(n=ya(e,t,n,c,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function xa(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function wa(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),s=e.node(o),a=i,c=!1;return i.lim>s.lim&&(a=s,c=!0),t.edges().filter(l=>c===Uo(e,e.node(l.v),a)&&c!==Uo(e,e.node(l.w),a)).reduce((l,u)=>st(t,u)<st(t,l)?u:l)}function va(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Mr(e),kr(e,t),xm(e,t)}function xm(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=gm(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),a=!1;s||(s=t.edge(i,o),a=!0),t.node(o).rank=t.node(i).rank+(a?s.minlen:-s.minlen)})}function wm(e,t,n){return e.hasEdge(t,n)}function Uo(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var vm=bm;function bm(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Zo(e);break;case"tight-tree":_m(e);break;case"longest-path":Em(e);break;case"none":break;default:Zo(e)}}var Em=Cr;function _m(e){Cr(e),pa(e)}function Zo(e){mm(e)}var Nm=Sm;function Sm(e){let t=km(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(r=>{let o=e.node(r),i=o.edgeObj,s=Cm(e,t,i.v,i.w),a=s.path,c=s.lca,l=0,u=a[l],d=!0;for(;r!==i.w;){if(o=e.node(r),d){for(;(u=a[l])!==c&&e.node(u).maxRank<o.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<a.length-1&&e.node(a[l+1]).minRank<=o.rank;)l++;u=a[l]}u!==void 0&&e.setParent(r,u),r=e.successors(r)[0]}})}function Cm(e,t,n,r){let o=[],i=[],s=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),o.push(c);while(c&&(t[c].low>s||a>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)i.push(u);return{path:o.concat(i.reverse()),lca:l}}function km(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(Nn).forEach(r),t}function Mm(e){let t=at(e,"root",{},"_root"),n=Im(e),r=Object.values(n),o=_e(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=Am(e)+1;e.children(Nn).forEach(a=>{ba(e,t,i,s,o,n,a)}),e.graph().nodeRankFactor=i}function ba(e,t,n,r,o,i,s){var a;let c=e.children(s);if(!c.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let l=qo(e,"_bt"),u=qo(e,"_bb"),d=e.node(s);e.setParent(l,s),d.borderTop=l,e.setParent(u,s),d.borderBottom=u,c.forEach(f=>{var h;ba(e,t,n,r,o,i,f);let g=e.node(f),v=g.borderTop?g.borderTop:f,w=g.borderBottom?g.borderBottom:f,m=g.borderTop?r:2*r,b=v!==w?1:o-((h=i[s])!=null?h:0)+1;e.setEdge(l,v,{weight:m,minlen:b,nestingEdge:!0}),e.setEdge(w,u,{weight:m,minlen:b,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,l,{weight:0,minlen:o+((a=i[s])!=null?a:0)})}function Im(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children(Nn).forEach(r=>n(r,1)),t}function Am(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Tm(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Om=Pm;function Pm(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),o&&Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Qo(e,"borderLeft","_bl",n,o,i),Qo(e,"borderRight","_br",n,o,i)}}e.children(Nn).forEach(t)}function Qo(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=at(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}function $m(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&Ea(e)}function jm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Lm(e),(n==="lr"||n==="rl")&&(Dm(e),Ea(e))}function Ea(e){e.nodes().forEach(t=>Jo(e.node(t))),e.edges().forEach(t=>Jo(e.edge(t)))}function Jo(e){let t=e.width;e.width=e.height,e.height=t}function Lm(e){e.nodes().forEach(t=>Hn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Hn),Object.hasOwn(r,"y")&&Hn(r)})}function Hn(e){e.y=-e.y}function Dm(e){e.nodes().forEach(t=>zn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(zn),Object.hasOwn(r,"x")&&zn(r)})}function zn(e){let t=e.x;e.x=e.y,e.y=t}function Rm(e,t=null){let n={},r=e.nodes().filter(l=>!e.children(l).length),o=r.map(l=>e.node(l).rank),i=_e(Math.max,o),s=St(i+1).map(()=>[]);function a(l){if(n[l])return;n[l]=!0;let u=e.node(l);s[u.rank].push(l);let d=e.successors(l);d&&[...d].sort((f,h)=>c(f,h)).forEach(a)}r.sort((l,u)=>e.node(l).rank-e.node(u).rank).forEach(a);function c(l,u){let d=e.node(l),f=e.node(u);return ga(t,d,f)}return s}function Hm(e,t){let n=0;for(let r=1;r<t.length;++r)n+=zm(e,t[r-1],t[r]);return n}function zm(e,t,n){let r=G0(n,n.map((l,u)=>u)),o=t.flatMap(l=>{let u=e.outEdges(l);return u?u.map(d=>({pos:r[d.w],weight:e.edge(d).weight})).sort((d,f)=>d.pos-f.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let a=new Array(s).fill(0),c=0;return o.forEach(l=>{let u=l.pos+i;a[u]+=l.weight;let d=0;for(;u>0;)u%2&&(d+=a[u+1]),u=u-1>>1,a[u]+=l.weight;c+=l.weight*d}),c}function Fm(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,s)=>{let a=e.edge(s),c=e.node(s.v);return{sum:i.sum+a.weight*c.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function Bm(e,t){let n={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),n[o.v]=s}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(n).filter(o=>!o.indegree);return Vm(r)}function Vm(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Ym(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>un(o,["vs","i","barycenter","weight"]))}function Ym(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Xm(e,t,n,r,o){let i={},s=null,a=null,c=o;typeof t=="boolean"?(c=t,i={}):t&&(i=t,s=n??null,a=r??null);let l=Y0(e,m=>Object.hasOwn(m,"barycenter")),u=l.lhs,d=l.rhs.sort((m,b)=>b.i-m.i),f=[],h=0,g=0,v=0;u.sort(Wm(a,s,!!c));for(let[m,b]of Object.entries(i)){let p=u.findIndex(x=>x.vs[0]===m);u.splice(p+1,0,b)}v=ei(f,d,v),u.forEach(m=>{v+=m.vs.length,f.push(m.vs),h+=m.barycenter*m.weight,g+=m.weight,v=ei(f,d,v)});let w={vs:f.flat(1)};return g&&(w.barycenter=h/g,w.weight=g),w}function ei(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Wm(e,t,n){return(r,o)=>{if(r.barycenter<o.barycenter)return-1;if(r.barycenter>o.barycenter)return 1;if(e&&(typeof r.vs[0]=="string"||typeof o.vs[0]=="string")){let i=e.node(r.vs[0]),s=e.node(o.vs[0]),a=ga(t,i,s);if(a!==0)return a}return n?o.i-r.i:r.i-o.i}}function _a(e,t,n,r,o){var i,s,a,c,l,u,d,f,h,g,v;let w=null,m=o;typeof r=="boolean"?(m=r,w=null):r!==void 0&&(w=r);let b=e.children(t),p=e.node(t),x=p?p.borderLeft:void 0,_=p?p.borderRight:void 0,S={};x&&(b=b.filter($=>$!==x&&$!==_));let k=Fm(e,b);k.forEach($=>{if(e.children($.v).length){let{result:P}=_a(e,$.v,n,w,m);S[$.v]=P,Object.hasOwn(P,"barycenter")&&qm($,P)}});let M=Bm(k,n);Gm(M,S);let I={},z=!1;for(let $=0;$<M.length;$++)for(let P=$+1;P<M.length;P++)if(!(!M[$]||!M[P]||!((i=M[$])!=null&&i.barycenter)||!((s=M[P])!=null&&s.barycenter))&&((a=M[$])==null?void 0:a.barycenter)===M[P].barycenter){let y=(l=(c=M[$])==null?void 0:c.vs[0])!=null?l:"",N=(d=(u=M[P])==null?void 0:u.vs[0])!=null?d:"",C=e.node(y),A=e.node(N);if(C.dummy==="edge"&&A.dummy==="edge"&&((f=C.edgeObj)==null?void 0:f.v)===((h=A.edgeObj)==null?void 0:h.v)&&((g=C.edgeObj)==null?void 0:g.w)===((v=A.edgeObj)==null?void 0:v.w))if(C.edgeLabel.reversed){I[N]=M[$],M.splice($,1),$--;break}else I[y]=M[P],M.splice(P,1),P--;else z=!0}let O=Xm(M,I,w,e,m);if(x&&_){O.vs=[x,O.vs,_].flat(1);let $=e.predecessors(x);if($&&$.length){let P=e.node($[0]),y=e.predecessors(_),N=e.node(y[0]);Object.hasOwn(O,"barycenter")||(O.barycenter=0,O.weight=0),O.barycenter=(O.barycenter*O.weight+P.order+N.order)/(O.weight+2),O.weight+=2}}return Object.defineProperty(O,"result",{value:O,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(O,"usedBias",{value:z,enumerable:!1,configurable:!0,writable:!0}),O}function Gm(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function qm(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function Km(e,t,n,r){r||(r=e.nodes());let o=Um(e),i=new we({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),c=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){i.setNode(s),i.setParent(s,c||o);let l=e[n](s);l&&l.forEach(u=>{let d=u.v===s?u.w:u.v,f=i.edge(d,s),h=f!==void 0?f.weight:0;i.setEdge(d,s,{weight:e.edge(u).weight+h})}),Object.hasOwn(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),i}function Um(e){let t;for(;e.hasNode(t=Sr("_root")););return t}function Zm(e,t,n){let r={},o;n.forEach(i=>{let s=e.parent(i),a,c;for(;s;){if(a=e.parent(s),a?(c=r[a],r[a]=s):(c=o,o=s),c&&c!==s){t.setEdge(c,s);return}s=a}})}function Na(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,Na);return}let r=fa(e),o=ti(e,St(1,r+1),"inEdges"),i=ti(e,St(r-1,-1,-1),"outEdges"),s=Rm(e,n);if(ni(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,c,l=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){Qm(u%2?o:i,u%4>=2,l,n),s=Pt(e);let f=Hm(e,s);f<a?(d=0,c=Object.assign({},s),a=f):f===a&&(c=structuredClone(s))}ni(e,c)}function ti(e,t,n){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&o(a,i)}return t.map(function(i){return Km(e,i,n,r.get(i)||[])})}function Qm(e,t,n,r){let o=!0,i=new we;e.forEach(function(s){n.forEach(u=>i.setEdge(u.left,u.right));let a=s.graph().root,{result:c,usedBias:l}=_a(s,a,i,r,o);t&&l&&(o=!o),c.vs.forEach((u,d)=>s.node(u).order=d),Zm(s,i,c.vs)})}function ni(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function Jm(e,t){let n={};function r(o,i){let s=0,a=0,c=o.length,l=i[i.length-1];return i.forEach((u,d)=>{let f=ty(e,u),h=f?e.node(f).order:c;(f||u===l)&&(i.slice(a,d+1).forEach(g=>{let v=e.predecessors(g);v&&v.forEach(w=>{let m=e.node(w),b=m.order;(b<s||h<b)&&!(m.dummy&&e.node(g).dummy)&&Sa(n,w,g)})}),a=d+1,s=h)}),i}return t.length&&t.reduce(r),n}function ey(e,t){let n={};function r(i,s,a,c,l){St(s,a).forEach(u=>{let d=i[u];if(d!==void 0&&e.node(d).dummy){let f=e.predecessors(d);f&&f.forEach(h=>{if(h===void 0)return;let g=e.node(h);g.dummy&&(g.order<c||g.order>l)&&Sa(n,h,d)})}})}function o(i,s){let a=-1,c=-1,l=0;return s.forEach((u,d)=>{if(e.node(u).dummy==="border"){let f=e.predecessors(u);if(f&&f.length){let h=f[0];if(h===void 0)return;c=e.node(h).order,r(s,l,d,a,c),l=d,a=c}}r(s,l,s.length,c,i.length)}),s}return t.length&&t.reduce(o),n}function ty(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function Sa(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function ny(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function ry(e,t,n,r,o){let i={},s={},a={};return t.forEach(c=>{c.forEach((l,u)=>{i[l]=l,s[l]=l,a[l]=u})}),t.forEach(c=>{let l=-1,u=-1,d=!1,f=c,h=c.findIndex(g=>(o==null?void 0:o.includes(g))||ri(g,e,o));h>0&&(f=[c[h],...c.slice(0,h),...c.slice(h+1)],d=!0),f.forEach(g=>{var v;let w=r(g);if(w&&w.length){o!=null&&o.includes(g)&&(w=w.filter(p=>ri(p,e,o)));let m=w.sort((p,x)=>{let _=a[p],S=a[x];return(_!==void 0?_:0)-(S!==void 0?S:0)}),b=(m.length-1)/2;for(let p=Math.floor(b),x=Math.ceil(b);p<=x;++p){let _=m[p];if(_===void 0)continue;let S=a[_];if(S!==void 0&&s[g]===g&&l<S&&a[_]!==u&&!ny(n,g,_)){let k=i[_];k!==void 0&&(s[_]=g,s[g]=i[g]=k,l=S,d&&(l=-1,u=(v=a[_])!=null?v:-1,d=!1))}}}})}),{root:i,align:s}}function oy(e,t,n,r,o=!1){let i={},s=iy(e,t,n,o),a=o?"borderLeft":"borderRight";function c(h,g){let v=s.nodes().slice(),w={},m=v.pop();for(;m;){if(w[m])h(m);else{w[m]=!0,v.push(m);for(let b of g(m))v.push(b)}m=v.pop()}}function l(h){let g=s.inEdges(h);g?i[h]=g.reduce((v,w)=>{var m;let b=(m=i[w.v])!=null?m:0,p=s.edge(w);return Math.max(v,b+(p!==void 0?p:0))},0):i[h]=0}function u(h){let g=s.outEdges(h),v=Number.POSITIVE_INFINITY;g&&(v=g.reduce((m,b)=>{let p=i[b.w],x=s.edge(b);return Math.min(m,(p!==void 0?p:0)-(x!==void 0?x:0))},Number.POSITIVE_INFINITY));let w=e.node(h);v!==Number.POSITIVE_INFINITY&&w.borderType!==a&&(i[h]=Math.max(i[h]!==void 0?i[h]:0,v))}function d(h){return s.predecessors(h)||[]}function f(h){return s.successors(h)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(h=>{var g;let v=n[h];v!==void 0&&(i[h]=(g=i[v])!=null?g:0)}),i}function iy(e,t,n,r){let o=new we,i=e.graph(),s=uy(i.nodesep,i.edgesep,r);return t.forEach(a=>{let c;a.forEach(l=>{let u=n[l];if(u!==void 0){if(o.setNode(u),c!==void 0){let d=n[c];if(d!==void 0){let f=o.edge(d,u);o.setEdge(d,u,Math.max(s(e,l,c),f||0))}}c=l}})}),o}function sy(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,c])=>{let l=dy(e,a)/2;o=Math.max(c+l,o),i=Math.min(c-l,i)});let s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function ay(e,t){let n=Object.values(t),r=_e(Math.min,n),o=_e(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,c=e[a];if(!c||c===t)return;let l=Object.values(c),u=r-_e(Math.min,l);s!=="l"&&(u=o-_e(Math.max,l)),u&&(e[a]=_n(c,d=>d+u))})})}function cy(e,t=void 0){let n=e.ul;return n?_n(n,(r,o)=>{var i,s;if(t){let c=t.toLowerCase(),l=e[c];if(l&&l[o]!==void 0)return l[o]}let a=Object.values(e).map(c=>{let l=c[o];return l!==void 0?l:0}).sort((c,l)=>c-l);return(((i=a[1])!=null?i:0)+((s=a[2])!=null?s:0))/2}):{}}function ly(e,t){let n=Pt(e),r=Object.assign(Jm(e,n),ey(e,n)),o={},i;["u","d"].forEach(a=>{i=a==="u"?n:Object.values(n).reverse(),["l","r"].forEach(c=>{c==="r"&&(i=i.map(d=>Object.values(d).reverse()));let l=ry(e,i,r,d=>(a==="u"?e.predecessors(d):e.successors(d))||[],t),u=oy(e,i,l.root,l.align,c==="r");c==="r"&&(u=_n(u,d=>-d)),o[a+c]=u})});let s=sy(e,o);return ay(o,s),cy(o,e.graph().align)}function uy(e,t,n){return(r,o,i)=>{let s=r.node(o),a=r.node(i),c=0,l;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":l=-s.width/2;break;case"r":l=s.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(s.dummy?t:e)/2,c+=(a.dummy?t:e)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":l=a.width/2;break;case"r":l=-a.width/2;break}return l&&(c+=n?l:-l),c}}function dy(e,t){return e.node(t).width}function ri(e,t,n){var r;if(!n)return!1;let o=(r=t.node(e))==null?void 0:r.edgeObj;if(!o||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(o==null?void 0:o.v),s=n.indexOf(o==null?void 0:o.w);return i!==-1&&s!==-1&&i===(s+1)%n.length||i===(s-1)%n.length}function fy(e,t){e=ua(e),hy(e),Object.entries(ly(e,t)).forEach(([n,r])=>e.node(n).x=r)}function hy(e){let t=Pt(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(s=>{let a=s.reduce((c,l)=>{var u;let d=(u=e.node(l).height)!=null?u:0;return c>d?c:d},0);s.forEach(c=>{let l=e.node(c);o==="top"?l.y=i+l.height/2:o==="bottom"?l.y=i+a-l.height/2:l.y=i+a/2}),i+=a+r})}var oi=new WeakMap;function gy(e,t={}){return Ca(e,ha,t),e}function ii(e,t,n){let r=t;for(;r!==void 0;){let o=e.parent(r);if(o===n)return r;r=o}}function Ca(e,t,n){var r;let o=e.nodes().filter(b=>e.children(b).length),i={};o.forEach(b=>{let p=e.node(b);if(p&&p.rankdir){let x=new we({multigraph:!0,compound:!0});x.setGraph({rankdir:p.rankdir});let _=e.children(b);_.forEach(y=>{let N={...e.node(y)};x.setNode(y,N);let C=e.parent(y);C&&C!==b&&_.includes(C)&&x.setParent(y,C)});let S=new Set;e.edges().forEach(y=>{let N=ii(e,y.v,b),C=ii(e,y.w,b);if(N&&C&&N!==C){let A=`${N}\0${C}`;S.has(A)||(S.add(A),x.setEdge(N,C,{...e.edge(y)}))}}),Ca(x,t,n);let k=li(x);si(k,t,n,null),ai(x,k);let M=1/0,I=1/0,z=-1/0,O=-1/0;x.nodes().forEach(y=>{if(y===b)return;let N=x.node(y);N&&typeof N.x=="number"&&typeof N.y=="number"&&typeof N.width=="number"&&typeof N.height=="number"&&(M=Math.min(M,N.x-N.width/2),z=Math.max(z,N.x+N.width/2),I=Math.min(I,N.y-N.height/2),O=Math.max(O,N.y+N.height/2))}),(!isFinite(M)||!isFinite(I)||!isFinite(z)||!isFinite(O))&&(M=I=0,z=O=0);let $=z-M,P=O-I;i[b]={minX:M,minY:I,maxX:z,maxY:O,width:$,height:P,offsetX:M,offsetY:I},p._dagreClusterSubgraph=x}});let s=[],a=b=>{let p=[],x=(e.children(b)||[]).filter(_=>_!==b);for(;x.length>0;){let _=x.shift();p.push(_),(e.children(_)||[]).filter(S=>S!==_).forEach(S=>x.push(S))}return p},c=new Map;o.forEach(b=>{let p=e.node(b);p&&p.rankdir&&i[b]&&c.set(b,(e.children(b)||[]).filter(x=>x!==b))});let l=new Set([...c.values()].flat()),u=new Map;c.forEach((b,p)=>{l.has(p)||u.set(p,a(p))});let d=new Set([...u.values()].flat()),f=b=>{for(let[p,x]of u)if(x.includes(b))return p;return b},h=[];e.edges().forEach(b=>{(d.has(b.v)||d.has(b.w))&&h.push({edge:b,label:e.edge(b)})});let g=new Map;d.forEach(b=>{let p=e.parent(b);g.set(b,typeof p=="string"?p:void 0)}),u.forEach((b,p)=>{let x=e.node(p),_=[];b.forEach(M=>{let I=e.node(M);I&&(_.push({id:M,node:I,parent:g.get(M)}),e.removeNode(M))});let S=h.filter(({edge:M})=>b.includes(M.v)||b.includes(M.w)),k=i[p];x&&(s.push({clusterId:p,subgraph:x._dagreClusterSubgraph,bounds:k,children:b,removedNodes:_,removedEdges:S}),x.width=k.width,x.height=k.height)});let v=new Set;h.forEach(({edge:b,label:p})=>{let x=f(b.v),_=f(b.w);if(x!==_&&e.hasNode(x)&&e.hasNode(_)){let S=`${x}\0${_}`;v.has(S)||(v.add(S),e.setEdge(x,_,{...p,width:0,height:0}))}});let w=li(e),m=si(w,t,n,(r=oi.get(e))!=null?r:null);oi.set(e,m),ai(e,w),v.forEach(b=>{let p=b.indexOf("\0"),x=b.slice(0,p),_=b.slice(p+1);e.hasEdge(x,_)&&e.removeEdge(x,_)}),s.forEach(({clusterId:b,subgraph:p,bounds:x,removedNodes:_,removedEdges:S})=>{var k,M;let I=e.node(b),z=(k=I==null?void 0:I.x)!=null?k:0,O=(M=I==null?void 0:I.y)!=null?M:0,$=(x.minX+x.maxX)/2,P=(x.minY+x.maxY)/2;_.forEach(({id:y,node:N,parent:C})=>{e.setNode(y,N),C!==void 0&&e.setParent(y,C)}),S.forEach(({edge:y,label:N})=>{e.setEdge(y,N)}),p.nodes().forEach(y=>{if(y===b)return;let N=p.node(y),C=e.node(y);C&&N&&typeof N.x=="number"&&typeof N.y=="number"&&(C.x=z+(N.x-$),C.y=O+(N.y-P))}),delete I._dagreClusterSubgraph}),o.forEach(b=>{var p,x;let _=e.node(b),S=i[b];if(_&&_.rankdir&&_._dagreClusterSubgraph&&S){let k=_._dagreClusterSubgraph,M=(p=_.x)!=null?p:0,I=(x=_.y)!=null?x:0,z=(S.minX+S.maxX)/2,O=(S.minY+S.maxY)/2;k.nodes().forEach($=>{if($===b)return;let P=k.node($),y=e.node($);if(y&&P&&typeof P.x=="number"&&typeof P.y=="number"){let N=P.x-z,C=P.y-O;y.x=M+N,y.y=I+C}}),delete _._dagreClusterSubgraph}})}function si(e,t,n,r=null){var o,i;let s=(n==null?void 0:n.useDynamic)!==!1,a=s&&(o=r==null?void 0:r.graph)!=null?o:null,c=s&&(i=r==null?void 0:r.rawNodes)!=null?i:null;t(" makeSpaceForEdgeLabels",()=>Ey(e)),t(" removeSelfEdges",()=>Ty(e)),t(" acyclic",()=>rm(e,a)),t(" nestingGraph.run",()=>Mm(e)),t(" rank",()=>vm(ua(e))),t(" injectEdgeLabelProxies",()=>_y(e)),t(" removeEmptyRanks",()=>B0(e)),t(" nestingGraph.cleanup",()=>Tm(e)),t(" normalizeRanks",()=>F0(e)),t(" assignRankMinMax",()=>Ny(e)),t(" removeEdgeLabelProxies",()=>Sy(e)),t(" normalize.run",()=>am(e)),t(" parentDummyChains",()=>Nm(e)),t(" addBorderSegments",()=>Om(e)),t(" order",()=>Na(e,n,c)),t(" insertSelfEdges",()=>Oy(e)),t(" adjustCoordinateSystem",()=>$m(e)),t(" position",()=>fy(e,n.corePath)),t(" positionSelfEdges",()=>Py(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>Ay(e)),t(" normalize.undo",()=>lm(e)),t(" fixupEdgeLabelCoords",()=>My(e)),t(" undoCoordinateSystem",()=>jm(e)),t(" translateGraph",()=>Cy(e)),t(" assignNodeIntersects",()=>ky(e)),t(" reversePoints",()=>Iy(e)),t(" acyclic.undo",()=>im(e)),{graph:e,rawNodes:l}}function ai(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var py=["nodesep","edgesep","ranksep","marginx","marginy"],my={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},yy=["acyclicer","ranker","rankdir","align","rankalign"],xy=["width","height","rank"],ci={width:0,height:0},wy=["minlen","weight","width","height","labeloffset"],vy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},by=["labelpos"];function li(e){let t=new we({multigraph:!0,compound:!0}),n=Bn(e.graph());return t.setGraph(Object.assign({},my,Fn(n,py),un(n,yy))),e.nodes().forEach(r=>{let o=Bn(e.node(r)),i=Fn(o,xy);Object.keys(ci).forEach(a=>{i[a]===void 0&&(i[a]=ci[a])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Bn(e.edge(r));t.setEdge(r,Object.assign({},vy,Fn(o,wy),un(o,by)))}),t}function Ey(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{var r;let o=e.edge(n);o.minlen*=2,((r=o.labelpos)!=null?r:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?o.width+=o.labeloffset:o.height+=o.labeloffset)})}function _y(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};at(e,"edge-proxy",o,"_ep")}})}function Ny(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Sy(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Cy(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,a=i.marginy||0;function c(l){let u=l.x,d=l.y,f=l.width,h=l.height;t=Math.min(t,u-f/2),n=Math.max(n,u+f/2),r=Math.min(r,d-h/2),o=Math.max(o,d+h/2)}e.nodes().forEach(l=>c(e.node(l))),e.edges().forEach(l=>{let u=e.edge(l);Object.hasOwn(u,"x")&&c(u)}),t-=s,r-=a,e.nodes().forEach(l=>{let u=e.node(l);u.x-=t,u.y-=r}),e.edges().forEach(l=>{let u=e.edge(l);u.points.forEach(d=>{d.x-=t,d.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=n-t+s,i.height=o-r+a}function ky(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=o,s=r),n.points.unshift(Go(r,i)),n.points.push(Go(o,s))})}function My(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Iy(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Ay(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Ty(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Oy(e){Pt(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);typeof i.rank!="number"&&(i.rank=0),i.order=o+n,(i.selfEdges||[]).forEach(s=>{at(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++n,e:s.e,edgeLabel:s.label},"_se"),(!Array.isArray(s.label.points)||s.label.points.length!==7)&&(s.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Py(e){e.nodes().forEach(t=>{let n=e.node(t),r=o=>typeof o=="number"&&isFinite(o);if(n.dummy==="selfedge"){let o=n,i=e.node(o.e.v),s=r(i==null?void 0:i.x)?i.x:0,a=r(i==null?void 0:i.y)?i.y:0,c=r(i==null?void 0:i.width)?i.width:0,l=r(i==null?void 0:i.height)?i.height:0,u=r(n.x)?n.x:s,d=r(n.y)?n.y:a,f=c/2,h=l/2;o.edgeLabel.points=[{x:u+f,y:d-h},{x:u+f,y:d-h},{x:u,y:d},{x:u-f,y:d+h},{x:u-f,y:d+h},{x:u,y:d},{x:u,y:d}],o.edgeLabel.x=u,o.edgeLabel.y=d,e.setEdge(o.e,o.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(o=>{if(!Array.isArray(o.label.points)||o.label.points.length!==7){let i=r(n.x)?n.x:0,s=r(n.y)?n.y:0,a=r(n.width)?n.width:0,c=r(n.height)?n.height:0,l=a/2,u=c/2;o.label.points=[{x:i+l,y:s-u},{x:i+l,y:s-u},{x:i,y:s},{x:i-l,y:s+u},{x:i-l,y:s+u},{x:i,y:s},{x:i,y:s}]}})})}function Fn(e,t){return _n(un(e,t),Number)}function Bn(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function $y(e){let t=Pt(e),n=new we({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,o)=>{let i="layer"+o;n.setNode(i,{rank:"same"}),r.reduce((s,a)=>(n.setEdge(s,a,{style:"invis"}),a))}),n}var jy={graphlib:na,version:q0,layout:gy,debug:$y,util:{time:X0,notime:ha}},ui=jy;/*! For license information please see dagre.esm.js.LEGAL.txt */const di=80,Ly=6.6,Dy=18,Ry=16.5,Hy=8;function mx(e){return e.length===0?void 0:{width:Math.max(...e.map(n=>n.length))*Ly+Dy,height:e.length*Ry+Hy}}function zy(e,t){const n=new Map,r=Math.ceil(Math.sqrt(e.length)),{maxWidth:o,maxHeight:i}=e.reduce((s,a)=>({maxWidth:Math.max(s.maxWidth,a.width),maxHeight:Math.max(s.maxHeight,a.height)}),{maxWidth:0,maxHeight:0});return e.forEach((s,a)=>{const c=a%r,l=Math.floor(a/r),u=t==="horizontal"?c:l,d=t==="horizontal"?l:c;n.set(s.id,{x:u*(o+di),y:d*(i+di)})}),n}function Fy(e){const t=new Set,n=[];for(const r of e){if(r.sourceId===r.targetId)continue;const o=`${r.sourceId} -> ${r.targetId}`;t.has(o)||(t.add(o),n.push(r))}return n}function fi(e,t,n){const r=new Map,o=new Map,i=new Map,s=new ui.graphlib.Graph({multigraph:!0});s.setGraph({rankdir:n==="horizontal"?"LR":"TB"}),s.setDefaultEdgeLabel(()=>({}));for(const a of e)s.setNode(a.id,{width:a.width,height:a.height});for(const a of t){const c=a.label?{width:a.label.width,height:a.label.height,labelpos:"c"}:{};s.setEdge(a.sourceId,a.targetId,c,a.id)}ui.layout(s);for(const a of s.nodes()){const c=s.node(a);c.x===void 0||c.y===void 0||r.set(a,{x:c.x-c.width/2,y:c.y-c.height/2})}for(const a of t){if(!s.hasEdge(a.sourceId,a.targetId,a.id))continue;const c=s.edge({v:a.sourceId,w:a.targetId,name:a.id}),l=(c.points??[]).slice(1,-1);l.length>0&&o.set(a.id,l),c.x!==void 0&&c.y!==void 0&&i.set(a.id,{x:c.x,y:c.y})}return{positions:r,routes:o,labelPositions:i}}function yx(e,t,n){if(e.length===0)return{positions:new Map,routes:new Map,labelPositions:new Map};try{return fi(e,t,n)}catch{const r=Fy(t);if(r.length<t.length)try{return fi(e,r,n)}catch{}return{positions:zy(e,n),routes:new Map,labelPositions:new Map}}}const ka={alias:!0,description:!0},xx=256,By=26,Vy=14,Yy=26,Xy=4;function Ma(e){return[...e.filter(t=>t.isPrimaryKey),...e.filter(t=>!t.isPrimaryKey)]}function Ia(e){const t=e.filter(n=>n.isPrimaryKey).length;return Math.min(e.length,Math.max(Xy,t))}function Aa(e){return e.alias.trim()!==e.name.trim()}function Wy(e,t){return t.alias&&Aa(e)?e.alias:e.name}function Ta(e,t){var n;return t.description&&((n=e.description)!=null&&n.trim())?e.description:null}function Gy(e,t){return By+(Ta(e,t)?Vy:0)}function wx(e,t=ka){if(e.length===0)return 0;const n=Ia(e),r=e.length>n;return Ma(e).slice(0,n).reduce((s,a)=>s+Gy(a,t),0)+(r?Yy:0)}function vx({markerId:e,color:t,withStart:n}){return E.jsxs("defs",{children:[E.jsx("marker",{id:`${e}-end`,markerWidth:"9",markerHeight:"9",refX:"7",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:E.jsx("path",{d:"M0,0 L7,3 L0,6 z",fill:t})}),n&&E.jsx("marker",{id:`${e}-start`,markerWidth:"9",markerHeight:"9",refX:"0",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:E.jsx("path",{d:"M7,0 L0,3 L7,6 z",fill:t})})]})}function bx({x:e,y:t,lines:n,selected:r,dimmed:o,interactive:i=!1}){return n.length===0?null:E.jsx("foreignObject",{x:e,y:t,width:1,height:1,style:{overflow:"visible"},children:E.jsx("div",{style:{transform:"translate(-50%, -50%)",width:"max-content",background:"var(--background)",border:`1px solid ${r?"var(--primary)":"var(--border)"}`,borderRadius:8,padding:"3px 8px",fontSize:11,fontWeight:600,lineHeight:1.5,color:"var(--foreground)",pointerEvents:i?"all":"none",cursor:i?"pointer":void 0,opacity:o?f0:1,transition:"opacity 0.2s",boxShadow:"0 1px 3px 0 rgba(0,0,0,0.08)"},children:n.map((s,a)=>E.jsx("div",{children:s},`${String(a)}-${s}`))})})}function Ex(e,t){return`${e}-${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function qy({field:e,labels:t}){const n=Wy(e,t),r=Ta(e,t),o=Aa(e)?n===e.name?e.alias:e.name:null,i=[[n,o].filter(Boolean).join(" · "),e.isHidden?"(hidden from reporting)":null].filter(Boolean).join(" ");return E.jsxs("div",{className:"border-border/50 border-b px-3.5 py-1.5 text-[11.5px] last:border-b-0",style:{opacity:e.isHidden?.5:1},title:i,children:[E.jsxs("div",{className:"flex items-center gap-2",children:[e.isPrimaryKey?E.jsx(tl,{className:"h-3 w-3 shrink-0",style:{color:l0},"aria-label":"Primary key"}):E.jsx("span",{className:"w-3 shrink-0"}),E.jsx("span",{className:"text-foreground flex-1 truncate",children:n}),E.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-[10px] tracking-tight",children:e.type})]}),r&&E.jsx("div",{className:"text-muted-foreground/80 truncate pl-5 text-[10.5px] leading-[14px] italic",title:r,children:r})]})}function _x({fields:e,labels:t=ka,expanded:n,onToggleExpanded:r}){const o=Ma(e),i=Ia(e),s=n?o:o.slice(0,i),a=o.length-i;function c(l){l.stopPropagation(),l.preventDefault(),r()}return E.jsxs("div",{className:"border-t",children:[s.map(l=>E.jsx(qy,{field:l,labels:t},l.name)),a>0&&E.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground hover:bg-muted nodrag flex w-full items-center justify-center gap-1 border-t py-1.5 text-[11px] font-medium transition-colors",onPointerDown:l=>{l.stopPropagation()},onClick:c,children:n?E.jsxs(E.Fragment,{children:[E.jsx(Jc,{className:"h-3 w-3"})," Show less"]}):E.jsxs(E.Fragment,{children:[E.jsx(el,{className:"h-3 w-3"})," +",a," more field",a!==1?"s":""]})})]})}export{wx as A,En as B,Jy as C,f0 as D,_x as E,ka as F,ig as G,sn as H,Df as I,Qy as M,dx as N,l0 as O,W as P,kp as R,lx as S,nx as W,ex as a,br as b,te as c,gx as d,hx as e,fx as f,gr as g,px as h,Uy as i,cx as j,d0 as k,tx as l,rx as m,mx as n,ux as o,is as p,ox as q,yx as r,Ex as s,vx as t,Zy as u,ax as v,sx as w,ix as x,bx as y,xx as z};
|