@owox/web 0.33.0-next-20260903121925 → 0.33.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-MoPz1bki.js → ModelCanvas-CzDkVkX_.js} +2 -2
- package/dist/assets/{RelationshipCanvas-DzLulyY-.js → RelationshipCanvas-DUaCxmp5.js} +1 -1
- package/dist/assets/{erd-fields-section-BngQfGWe.js → erd-fields-section-CXhqGUVO.js} +5 -5
- package/dist/assets/index-D0EaJx5B.js +1457 -0
- package/dist/assets/{index-s1e4jO7J.js → index-LAfgsoTV.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +3 -12
- package/dist/assets/index-BTmqY2jZ.js +0 -1448
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{G as sr,J as Rc,K as
|
|
1
|
+
import{G as sr,J as Rc,K as Hc,r as D,j as S,P as zc,m as Fc,c as Bc,O as Vc,n as Yc,o as In,V as Xc,Q as Wc,U as zr,W as Gc,X as qc,Y as Kc,v as Uc,Z as Fr,$ as Zc,a0 as Br,a1 as ut,a2 as Qc,a3 as Jc,a4 as el,a5 as tl}from"./index-D0EaJx5B.js";/**
|
|
2
2
|
* @license lucide-react v0.475.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,15 +13,15 @@ import{G as sr,J as Rc,K as zc,r as j,j as S,P as Hc,m as Fc,c as Bc,O as Vc,n a
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const ol=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Uy=sr("ZoomOut",ol);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 il={value:()=>{}};function fn(){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 Xt(n)}function Xt(e){this._=e}function sl(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}})}Xt.prototype=fn.prototype={constructor:Xt,on:function(e,t){var n=this._,r=sl(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=al(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]=Vr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Vr(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 Xt(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 al(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function Vr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=il,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Xn="http://www.w3.org/1999/xhtml";const Yr={svg:"http://www.w3.org/2000/svg",xhtml:Xn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function hn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Yr.hasOwnProperty(t)?{space:Yr[t],local:e}:e}function cl(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Xn&&t.documentElement.namespaceURI===Xn?t.createElement(e):t.createElementNS(n,e)}}function ll(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function yi(e){var t=hn(e);return(t.local?ll:cl)(t)}function ul(){}function ar(e){return e==null?ul:function(){return this.querySelector(e)}}function dl(e){typeof e!="function"&&(e=ar(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 fl(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function hl(){return[]}function xi(e){return e==null?hl:function(){return this.querySelectorAll(e)}}function gl(e){return function(){return fl(e.apply(this,arguments))}}function pl(e){typeof e=="function"?e=gl(e):e=xi(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 wi(e){return function(){return this.matches(e)}}function vi(e){return function(t){return t.matches(e)}}var ml=Array.prototype.find;function yl(e){return function(){return ml.call(this.children,e)}}function xl(){return this.firstElementChild}function wl(e){return this.select(e==null?xl:yl(typeof e=="function"?e:vi(e)))}var vl=Array.prototype.filter;function bl(){return Array.from(this.children)}function El(e){return function(){return vl.call(this.children,e)}}function _l(e){return this.selectAll(e==null?bl:El(typeof e=="function"?e:vi(e)))}function Nl(e){typeof e!="function"&&(e=wi(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 bi(e){return new Array(e.length)}function Sl(){return new le(this._enter||this._groups.map(bi),this._parents)}function Ut(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ut.prototype={constructor:Ut,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 kl(e){return function(){return e}}function Cl(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 Ut(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Ml(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 Ut(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function Il(e){return e.__data__}function Al(e,t){if(!arguments.length)return Array.from(this,Il);var n=t?Ml:Cl,r=this._parents,o=this._groups;typeof e!="function"&&(e=kl(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=Tl(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,E;b<g;++b)if(x=v[b]){for(b>=p&&(p=b+1);!(E=w[p])&&++p<g;);x._next=E||null}}return s=new le(s,r),s._enter=a,s._exit=c,s}function Tl(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ol(){return new le(this._exit||this._groups.map(bi),this._parents)}function Pl(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 Ll(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 $l(){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 jl(e){e||(e=Dl);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 Dl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Rl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function zl(){return Array.from(this)}function Hl(){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 Fl(){let e=0;for(const t of this)++e;return e}function Bl(){return!this.node()}function Vl(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 Yl(e){return function(){this.removeAttribute(e)}}function Xl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Wl(e,t){return function(){this.setAttribute(e,t)}}function Gl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ql(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Kl(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 Ul(e,t){var n=hn(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?Xl:Yl:typeof t=="function"?n.local?Kl:ql:n.local?Gl:Wl)(n,t))}function Ei(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Zl(e){return function(){this.style.removeProperty(e)}}function Ql(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Jl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function eu(e,t,n){return arguments.length>1?this.each((t==null?Zl:typeof t=="function"?Jl:Ql)(e,t,n??"")):tt(this.node(),e)}function tt(e,t){return e.style.getPropertyValue(t)||Ei(e).getComputedStyle(e,null).getPropertyValue(t)}function tu(e){return function(){delete this[e]}}function nu(e,t){return function(){this[e]=t}}function ru(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function ou(e,t){return arguments.length>1?this.each((t==null?tu:typeof t=="function"?ru:nu)(e,t)):this.node()[e]}function _i(e){return e.trim().split(/^|\s+/)}function cr(e){return e.classList||new Ni(e)}function Ni(e){this._node=e,this._names=_i(e.getAttribute("class")||"")}Ni.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 Si(e,t){for(var n=cr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function ki(e,t){for(var n=cr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function iu(e){return function(){Si(this,e)}}function su(e){return function(){ki(this,e)}}function au(e,t){return function(){(t.apply(this,arguments)?Si:ki)(this,e)}}function cu(e,t){var n=_i(e+"");if(arguments.length<2){for(var r=cr(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?au:t?iu:su)(n,t))}function lu(){this.textContent=""}function uu(e){return function(){this.textContent=e}}function du(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function fu(e){return arguments.length?this.each(e==null?lu:(typeof e=="function"?du:uu)(e)):this.node().textContent}function hu(){this.innerHTML=""}function gu(e){return function(){this.innerHTML=e}}function pu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function mu(e){return arguments.length?this.each(e==null?hu:(typeof e=="function"?pu:gu)(e)):this.node().innerHTML}function yu(){this.nextSibling&&this.parentNode.appendChild(this)}function xu(){return this.each(yu)}function wu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function vu(){return this.each(wu)}function bu(e){var t=typeof e=="function"?e:yi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Eu(){return null}function _u(e,t){var n=typeof e=="function"?e:yi(e),r=t==null?Eu:typeof t=="function"?t:ar(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Nu(){var e=this.parentNode;e&&e.removeChild(this)}function Su(){return this.each(Nu)}function ku(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Cu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mu(e){return this.select(e?Cu:ku)}function Iu(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Au(e){return function(t){e.call(this,t,this.__data__)}}function Tu(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 Ou(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 Pu(e,t,n){return function(){var r=this.__on,o,i=Au(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 Lu(e,t,n){var r=Tu(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?Pu:Ou,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function Ci(e,t,n){var r=Ei(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 $u(e,t){return function(){return Ci(this,e,t)}}function ju(e,t){return function(){return Ci(this,e,t.apply(this,arguments))}}function Du(e,t){return this.each((typeof t=="function"?ju:$u)(e,t))}function*Ru(){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 Mi=[null];function le(e,t){this._groups=e,this._parents=t}function Mt(){return new le([[document.documentElement]],Mi)}function zu(){return this}le.prototype=Mt.prototype={constructor:le,select:dl,selectAll:pl,selectChild:wl,selectChildren:_l,filter:Nl,data:Al,enter:Sl,exit:Ol,join:Pl,merge:Ll,selection:zu,order:$l,sort:jl,call:Rl,nodes:zl,node:Hl,size:Fl,empty:Bl,each:Vl,attr:Ul,style:eu,property:ou,classed:cu,text:fu,html:mu,raise:xu,lower:vu,append:bu,insert:_u,remove:Su,clone:Mu,datum:Iu,on:Lu,dispatch:Du,[Symbol.iterator]:Ru};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],Mi)}function Hu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=Hu(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 Fu={passive:!1},xt={capture:!0,passive:!1};function An(e){e.stopImmediatePropagation()}function Je(e){e.preventDefault(),e.stopImmediatePropagation()}function Ii(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Je,xt);"onselectstart"in t?n.on("selectstart.drag",Je,xt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ai(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Je,xt),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 Wn(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}})}Wn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Bu(e){return!e.ctrlKey&&!e.button}function Vu(){return this.parentNode}function Yu(e,t){return t??{x:e.x,y:e.y}}function Xu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ti(){var e=Bu,t=Vu,n=Yu,r=Xu,o={},i=fn("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,Fu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,E){if(!(u||!e.call(this,x,E))){var N=p(this,t.call(this,x,E),x,E,"mouse");N&&(ce(x.view).on("mousemove.drag",g,xt).on("mouseup.drag",v,xt),Ii(x.view),An(x),l=!1,a=x.clientX,c=x.clientY,N("start",x))}}function g(x){if(Je(x),!l){var E=x.clientX-a,N=x.clientY-c;l=E*E+N*N>d}o.mouse("drag",x)}function v(x){ce(x.view).on("mousemove.drag mouseup.drag",null),Ai(x.view,l),Je(x),o.mouse("end",x)}function w(x,E){if(e.call(this,x,E)){var N=x.changedTouches,M=t.call(this,x,E),C=N.length,I,H;for(I=0;I<C;++I)(H=p(this,M,x,E,N[I].identifier,N[I]))&&(An(x),H("start",x,N[I]))}}function m(x){var E=x.changedTouches,N=E.length,M,C;for(M=0;M<N;++M)(C=o[E[M].identifier])&&(Je(x),C("drag",x,E[M]))}function b(x){var E=x.changedTouches,N=E.length,M,C;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),M=0;M<N;++M)(C=o[E[M].identifier])&&(An(x),C("end",x,E[M]))}function p(x,E,N,M,C,I){var H=i.copy(),O=fe(I||N,E),L,P,y;if((y=n.call(x,new Wn("beforestart",{sourceEvent:N,target:f,identifier:C,active:s,x:O[0],y:O[1],dx:0,dy:0,dispatch:H}),M))!=null)return L=y.x-O[0]||0,P=y.y-O[1]||0,function _(k,A,$){var T=O,D;switch(k){case"start":o[C]=_,D=s++;break;case"end":delete o[C],--s;case"drag":O=fe($||A,E),D=s;break}H.call(k,x,new Wn(k,{sourceEvent:A,subject:y,target:f,identifier:C,active:D,x:O[0]+L,y:O[1]+P,dx:O[0]-T[0],dy:O[1]-T[1],dispatch:H}),M)}}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 lr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Oi(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function It(){}var wt=.7,Zt=1/wt,et="\\s*([+-]?\\d+)\\s*",vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Wu=/^#([0-9a-f]{3,8})$/,Gu=new RegExp(`^rgb\\(${et},${et},${et}\\)$`),qu=new RegExp(`^rgb\\(${Ne},${Ne},${Ne}\\)$`),Ku=new RegExp(`^rgba\\(${et},${et},${et},${vt}\\)$`),Uu=new RegExp(`^rgba\\(${Ne},${Ne},${Ne},${vt}\\)$`),Zu=new RegExp(`^hsl\\(${vt},${Ne},${Ne}\\)$`),Qu=new RegExp(`^hsla\\(${vt},${Ne},${Ne},${vt}\\)$`),Xr={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};lr(It,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Wr,formatHex:Wr,formatHex8:Ju,formatHsl:ed,formatRgb:Gr,toString:Gr});function Wr(){return this.rgb().formatHex()}function Ju(){return this.rgb().formatHex8()}function ed(){return Pi(this).formatHsl()}function Gr(){return this.rgb().formatRgb()}function Ye(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Wu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?qr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Dt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Dt(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=Gu.exec(e))?new ae(t[1],t[2],t[3],1):(t=qu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ku.exec(e))?Dt(t[1],t[2],t[3],t[4]):(t=Uu.exec(e))?Dt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Zu.exec(e))?Zr(t[1],t[2]/100,t[3]/100,1):(t=Qu.exec(e))?Zr(t[1],t[2]/100,t[3]/100,t[4]):Xr.hasOwnProperty(e)?qr(Xr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function qr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Dt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function td(e){return e instanceof It||(e=Ye(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Gn(e,t,n,r){return arguments.length===1?td(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}lr(ae,Gn,Oi(It,{brighter(e){return e=e==null?Zt:Math.pow(Zt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,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),Qt(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:Kr,formatHex:Kr,formatHex8:nd,formatRgb:Ur,toString:Ur}));function Kr(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}`}function nd(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}${Fe((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ur(){const e=Qt(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Qt(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 Zr(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 Pi(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof It||(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 rd(e,t,n,r){return arguments.length===1?Pi(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}lr(he,rd,Oi(It,{brighter(e){return e=e==null?Zt:Math.pow(Zt,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,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(Tn(e>=240?e-240:e+120,o,r),Tn(e,o,r),Tn(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(Qr(this.h),Rt(this.s),Rt(this.l),Qt(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=Qt(this.opacity);return`${e===1?"hsl(":"hsla("}${Qr(this.h)}, ${Rt(this.s)*100}%, ${Rt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Qr(e){return e=(e||0)%360,e<0?e+360:e}function Rt(e){return Math.max(0,Math.min(1,e||0))}function Tn(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 ur=e=>()=>e;function od(e,t){return function(n){return e+n*t}}function id(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 sd(e){return(e=+e)==1?Li:function(t,n){return n-t?id(t,n,e):ur(isNaN(t)?n:t)}}function Li(e,t){var n=t-e;return n?od(e,n):ur(isNaN(e)?t:e)}const Jt=(function e(t){var n=sd(t);function r(o,i){var s=n((o=Gn(o)).r,(i=Gn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),l=Li(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 ad(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 cd(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ld(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]=mt(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 ud(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 dd(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]=mt(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var qn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,On=new RegExp(qn.source,"g");function fd(e){return function(){return e}}function hd(e){return function(t){return e(t)+""}}function $i(e,t){var n=qn.lastIndex=On.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=qn.exec(e))&&(o=On.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=On.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?hd(c[0].x):fd(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 mt(e,t){var n=typeof t,r;return t==null||n==="boolean"?ur(t):(n==="number"?Ee:n==="string"?(r=Ye(t))?(t=r,Jt):$i:t instanceof Ye?Jt:t instanceof Date?ud:cd(t)?ad:Array.isArray(t)?ld:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?dd:Ee)(e,t)}var Jr=180/Math.PI,Kn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ji(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)*Jr,skewX:Math.atan(c)*Jr,scaleX:s,scaleY:a}}var zt;function gd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Kn:ji(t.a,t.b,t.c,t.d,t.e,t.f)}function pd(e){return e==null||(zt||(zt=document.createElementNS("http://www.w3.org/2000/svg","g")),zt.setAttribute("transform",e),!(e=zt.transform.baseVal.consolidate()))?Kn:(e=e.matrix,ji(e.a,e.b,e.c,e.d,e.e,e.f))}function Di(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 md=Di(gd,"px, ","px)","deg)"),yd=Di(pd,", ",")",")"),xd=1e-12;function eo(e){return((e=Math.exp(e))+1/e)/2}function wd(e){return((e=Math.exp(e))-1/e)/2}function vd(e){return((e=Math.exp(2*e))-1)/(e+1)}const Wt=(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<xd)m=Math.log(f/l)/t,w=function(M){return[a+M*h,c+M*g,l*Math.exp(t*M*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),E=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(x*x+1)-x);m=(N-E)/t,w=function(M){var C=M*m,I=eo(E),H=l/(n*b)*(I*vd(t*C+E)-wd(E));return[a+H*h,c+H*g,l*I/eo(t*C+E)]}}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 nt=0,ht=0,dt=0,Ri=1e3,en,gt,tn=0,Xe=0,gn=0,bt=typeof performance=="object"&&performance.now?performance:Date,zi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function dr(){return Xe||(zi(bd),Xe=bt.now()+gn)}function bd(){Xe=0}function nn(){this._call=this._time=this._next=null}nn.prototype=Hi.prototype={constructor:nn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?dr():+n)+(t==null?0:+t),!this._next&>!==this&&(gt?gt._next=this:en=this,gt=this),this._call=e,this._time=n,Un()},stop:function(){this._call&&(this._call=null,this._time=1/0,Un())}};function Hi(e,t,n){var r=new nn;return r.restart(e,t,n),r}function Ed(){dr(),++nt;for(var e=en,t;e;)(t=Xe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--nt}function to(){Xe=(tn=bt.now())+gn,nt=ht=0;try{Ed()}finally{nt=0,Nd(),Xe=0}}function _d(){var e=bt.now(),t=e-tn;t>Ri&&(gn-=t,tn=e)}function Nd(){for(var e,t=en,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:en=n);gt=e,Un(r)}function Un(e){if(!nt){ht&&(ht=clearTimeout(ht));var t=e-Xe;t>24?(e<1/0&&(ht=setTimeout(to,e-bt.now()-gn)),dt&&(dt=clearInterval(dt))):(dt||(tn=bt.now(),dt=setInterval(_d,Ri)),nt=1,zi(to))}}function no(e,t,n){var r=new nn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Sd=fn("start","end","cancel","interrupt"),kd=[],Fi=0,ro=1,Zn=2,Gt=3,oo=4,Qn=5,qt=6;function pn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Cd(e,n,{name:t,index:r,group:o,on:Sd,tween:kd,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Fi})}function fr(e,t){var n=ye(e,t);if(n.state>Fi)throw new Error("too late; already scheduled");return n}function Se(e,t){var n=ye(e,t);if(n.state>Gt)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 Cd(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Hi(i,0,n.time);function i(l){n.state=ro,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!==ro)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Gt)return no(s);h.state===oo?(h.state=qt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=qt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(no(function(){n.state===Gt&&(n.state=oo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Zn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Zn){for(n.state=Gt,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=Qn,1),d=-1,f=o.length;++d<f;)o[d].call(e,u);n.state===Qn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=qt,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Kt(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>Zn&&r.state<Qn,r.state=qt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Md(e){return this.each(function(){Kt(this,e)})}function Id(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 Ad(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 Td(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?Id:Ad)(n,e,t))}function hr(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 Bi(e,t){var n;return(typeof t=="number"?Ee:t instanceof Ye?Jt:(n=Ye(t))?(t=n,Jt):$i)(e,t)}function Od(e){return function(){this.removeAttribute(e)}}function Pd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ld(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 $d(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 jd(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 Dd(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 Rd(e,t){var n=hn(e),r=n==="transform"?yd:Bi;return this.attrTween(e,typeof t=="function"?(n.local?Dd:jd)(n,r,hr(this,"attr."+e,t)):t==null?(n.local?Pd:Od)(n):(n.local?$d:Ld)(n,r,t))}function zd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Hd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Fd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Hd(e,i)),n}return o._value=t,o}function Bd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&zd(e,i)),n}return o._value=t,o}function Vd(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=hn(e);return this.tween(n,(r.local?Fd:Bd)(r,t))}function Yd(e,t){return function(){fr(this,e).delay=+t.apply(this,arguments)}}function Xd(e,t){return t=+t,function(){fr(this,e).delay=t}}function Wd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Yd:Xd)(t,e)):ye(this.node(),t).delay}function Gd(e,t){return function(){Se(this,e).duration=+t.apply(this,arguments)}}function qd(e,t){return t=+t,function(){Se(this,e).duration=t}}function Kd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Gd:qd)(t,e)):ye(this.node(),t).duration}function Ud(e,t){if(typeof t!="function")throw new Error;return function(){Se(this,e).ease=t}}function Zd(e){var t=this._id;return arguments.length?this.each(Ud(t,e)):ye(this.node(),t).ease}function Qd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Se(this,e).ease=n}}function Jd(e){if(typeof e!="function")throw new Error;return this.each(Qd(this._id,e))}function ef(e){typeof e!="function"&&(e=wi(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 tf(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 nf(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 rf(e,t,n){var r,o,i=nf(t)?fr:Se;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function of(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(rf(n,e,t))}function sf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function af(){return this.on("end.remove",sf(this._id))}function cf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ar(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,pn(l[f],t,n,f,l,ye(u,n)));return new Te(i,this._parents,t,n)}function lf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=xi(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])&&pn(h,t,n,v,f,g);i.push(f),s.push(u)}return new Te(i,s,t,n)}var uf=Mt.prototype.constructor;function df(){return new uf(this._groups,this._parents)}function ff(e,t){var n,r,o;return function(){var i=tt(this,e),s=(this.style.removeProperty(e),tt(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Vi(e){return function(){this.style.removeProperty(e)}}function hf(e,t,n){var r,o=n+"",i;return function(){var s=tt(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function gf(e,t,n){var r,o,i;return function(){var s=tt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),tt(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function pf(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=Vi(t)):void 0;(l!==n||o!==u)&&(r=(n=l).copy()).on(s,o=u),c.on=r}}function mf(e,t,n){var r=(e+="")=="transform"?md:Bi;return t==null?this.styleTween(e,ff(e,r)).on("end.style."+e,Vi(e)):typeof t=="function"?this.styleTween(e,gf(e,r,hr(this,"style."+e,t))).each(pf(this._id,e)):this.styleTween(e,hf(e,r,t),n).on("end.style."+e,null)}function yf(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function xf(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&yf(e,s,n)),r}return i._value=t,i}function wf(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,xf(e,t,n??""))}function vf(e){return function(){this.textContent=e}}function bf(e){return function(){var t=e(this);this.textContent=t??""}}function Ef(e){return this.tween("text",typeof e=="function"?bf(hr(this,"text",e)):vf(e==null?"":e+""))}function _f(e){return function(t){this.textContent=e.call(this,t)}}function Nf(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&_f(o)),t}return r._value=e,r}function Sf(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,Nf(e))}function kf(){for(var e=this._name,t=this._id,n=Yi(),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);pn(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 Cf(){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 Mf=0;function Te(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Yi(){return++Mf}var Ie=Mt.prototype;Te.prototype={constructor:Te,select:cf,selectAll:lf,selectChild:Ie.selectChild,selectChildren:Ie.selectChildren,filter:ef,merge:tf,selection:df,transition:kf,call:Ie.call,nodes:Ie.nodes,node:Ie.node,size:Ie.size,empty:Ie.empty,each:Ie.each,on:of,attr:Rd,attrTween:Vd,style:mf,styleTween:wf,text:Ef,textTween:Sf,remove:af,tween:Td,delay:Wd,duration:Kd,ease:Zd,easeVarying:Jd,end:Cf,[Symbol.iterator]:Ie[Symbol.iterator]};function If(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Af={time:null,delay:0,duration:250,ease:If};function Tf(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 Of(e){var t,n;e instanceof Te?(t=e._id,e=e._name):(t=Yi(),(n=Af).time=dr(),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])&&pn(c,e,t,l,s,n||Tf(c,t));return new Te(r,this._parents,e,t)}Mt.prototype.interrupt=Md;Mt.prototype.transition=Of;const Ht=e=>()=>e;function Pf(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 mn=new Ae(1,0,0);Xi.prototype=Ae.prototype;function Xi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return mn;return e.__zoom}function Pn(e){e.stopImmediatePropagation()}function ft(e){e.preventDefault(),e.stopImmediatePropagation()}function Lf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function $f(){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 io(){return this.__zoom||mn}function jf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Df(){return navigator.maxTouchPoints||"ontouchstart"in this}function Rf(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 Wi(){var e=Lf,t=$f,n=Rf,r=jf,o=Df,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Wt,l=fn("start","zoom","end"),u,d,f,h=500,g=150,v=0,w=10;function m(y){y.property("__zoom",io).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",H).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,_,k,A){var $=y.selection?y.selection():y;$.property("__zoom",io),y!==$?E(y,_,k,A):$.interrupt().each(function(){N(this,arguments).event(A).start().zoom(null,typeof _=="function"?_.apply(this,arguments):_).end()})},m.scaleBy=function(y,_,k,A){m.scaleTo(y,function(){var $=this.__zoom.k,T=typeof _=="function"?_.apply(this,arguments):_;return $*T},k,A)},m.scaleTo=function(y,_,k,A){m.transform(y,function(){var $=t.apply(this,arguments),T=this.__zoom,D=k==null?x($):typeof k=="function"?k.apply(this,arguments):k,F=T.invert(D),z=typeof _=="function"?_.apply(this,arguments):_;return n(p(b(T,z),D,F),$,s)},k,A)},m.translateBy=function(y,_,k,A){m.transform(y,function(){return n(this.__zoom.translate(typeof _=="function"?_.apply(this,arguments):_,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),s)},null,A)},m.translateTo=function(y,_,k,A,$){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(mn.translate(F[0],F[1]).scale(D.k).translate(typeof _=="function"?-_.apply(this,arguments):-_,typeof k=="function"?-k.apply(this,arguments):-k),T,s)},A,$)};function b(y,_){return _=Math.max(i[0],Math.min(i[1],_)),_===y.k?y:new Ae(_,y.x,y.y)}function p(y,_,k){var A=_[0]-k[0]*y.k,$=_[1]-k[1]*y.k;return A===y.x&&$===y.y?y:new Ae(y.k,A,$)}function x(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function E(y,_,k,A){y.on("start.zoom",function(){N(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(A).end()}).tween("zoom",function(){var $=this,T=arguments,D=N($,T).event(A),F=t.apply($,T),z=k==null?x(F):typeof k=="function"?k.apply($,T):k,V=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),Y=$.__zoom,K=typeof _=="function"?_.apply($,T):_,Q=c(Y.invert(z).concat(V/Y.k),K.invert(z).concat(V/K.k));return function(q){if(q===1)q=K;else{var R=Q(q),B=V/R[2];q=new Ae(B,z[0]-R[0]*B,z[1]-R[1]*B)}D.zoom(null,q)}})}function N(y,_,k){return!k&&y.__zooming||new M(y,_)}function M(y,_){this.that=y,this.args=_,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,_),this.taps=0}M.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,_){return this.mouse&&y!=="mouse"&&(this.mouse[1]=_.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=_.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=_.invert(this.touch1[0])),this.that.__zoom=_,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var _=ce(this.that).datum();l.call(y,this.that,new Pf(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),_)}};function C(y,..._){if(!e.apply(this,arguments))return;var k=N(this,_).event(y),A=this.__zoom,$=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),T=fe(y);if(k.wheel)(k.mouse[0][0]!==T[0]||k.mouse[0][1]!==T[1])&&(k.mouse[1]=A.invert(k.mouse[0]=T)),clearTimeout(k.wheel);else{if(A.k===$)return;k.mouse=[T,A.invert(T)],Kt(this),k.start()}ft(y),k.wheel=setTimeout(D,g),k.zoom("mouse",n(p(b(A,$),k.mouse[0],k.mouse[1]),k.extent,s));function D(){k.wheel=null,k.end()}}function I(y,..._){if(f||!e.apply(this,arguments))return;var k=y.currentTarget,A=N(this,_,!0).event(y),$=ce(y.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",V,!0),T=fe(y,k),D=y.clientX,F=y.clientY;Ii(y.view),Pn(y),A.mouse=[T,this.__zoom.invert(T)],Kt(this),A.start();function z(Y){if(ft(Y),!A.moved){var K=Y.clientX-D,Q=Y.clientY-F;A.moved=K*K+Q*Q>v}A.event(Y).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=fe(Y,k),A.mouse[1]),A.extent,s))}function V(Y){$.on("mousemove.zoom mouseup.zoom",null),Ai(Y.view,A.moved),ft(Y),A.event(Y).end()}}function H(y,..._){if(e.apply(this,arguments)){var k=this.__zoom,A=fe(y.changedTouches?y.changedTouches[0]:y,this),$=k.invert(A),T=k.k*(y.shiftKey?.5:2),D=n(p(b(k,T),A,$),t.apply(this,_),s);ft(y),a>0?ce(this).transition().duration(a).call(E,D,A,y):ce(this).call(m.transform,D,A,y)}}function O(y,..._){if(e.apply(this,arguments)){var k=y.touches,A=k.length,$=N(this,_,y.changedTouches.length===A).event(y),T,D,F,z;for(Pn(y),D=0;D<A;++D)F=k[D],z=fe(F,this),z=[z,this.__zoom.invert(z),F.identifier],$.touch0?!$.touch1&&$.touch0[2]!==z[2]&&($.touch1=z,$.taps=0):($.touch0=z,T=!0,$.taps=1+!!u);u&&(u=clearTimeout(u)),T&&($.taps<2&&(d=z[0],u=setTimeout(function(){u=null},h)),Kt(this),$.start())}}function L(y,..._){if(this.__zooming){var k=N(this,_).event(y),A=y.changedTouches,$=A.length,T,D,F,z;for(ft(y),T=0;T<$;++T)D=A[T],F=fe(D,this),k.touch0&&k.touch0[2]===D.identifier?k.touch0[0]=F:k.touch1&&k.touch1[2]===D.identifier&&(k.touch1[0]=F);if(D=k.that.__zoom,k.touch1){var V=k.touch0[0],Y=k.touch0[1],K=k.touch1[0],Q=k.touch1[1],q=(q=K[0]-V[0])*q+(q=K[1]-V[1])*q,R=(R=Q[0]-Y[0])*R+(R=Q[1]-Y[1])*R;D=b(D,Math.sqrt(q/R)),F=[(V[0]+K[0])/2,(V[1]+K[1])/2],z=[(Y[0]+Q[0])/2,(Y[1]+Q[1])/2]}else if(k.touch0)F=k.touch0[0],z=k.touch0[1];else return;k.zoom("touch",n(p(D,F,z),k.extent,s))}}function P(y,..._){if(this.__zooming){var k=N(this,_).event(y),A=y.changedTouches,$=A.length,T,D;for(Pn(y),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),T=0;T<$;++T)D=A[T],k.touch0&&k.touch0[2]===D.identifier?delete k.touch0:k.touch1&&k.touch1[2]===D.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.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.`},Et=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Gi=["Enter"," ","Escape"],qi={"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 rt;(function(e){e.Strict="strict",e.Loose="loose"})(rt||(rt={}));var Ve;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ve||(Ve={}));var _t;(function(e){e.Partial="partial",e.Full="full"})(_t||(_t={}));const Ki={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var $e;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})($e||($e={}));var rn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(rn||(rn={}));var G;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(G||(G={}));const so={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top};function Ui(e){return e===null?null:e?"valid":"invalid"}const Zi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,zf=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),gr=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),At=(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}},Hf=(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):gr(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,yn(o,on(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?xn(r):{x:0,y:0,width:0,height:0}},Tt=(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=yn(n,on(o)),r=!0)}),r?xn(n):{x:0,y:0,width:0,height:0}},pr=(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=ts(a,c,l,u,b,p,w,m),E=w*m,N=i&&x>0;(!f.internals.handleBounds||N||x>=E||f.dragging)&&d.push(f)}return d},Ff=(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 Bf(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 Vf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=Bf(e,s),c=Tt(a),l=yr(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 Qi({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 Yf({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=Ff(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 ot=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),We=(e={x:0,y:0},t,n)=>({x:ot(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:ot(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ji(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 ao=(e,t,n)=>e<t?ot(Math.abs(e-t),1,t)/t:e>n?-ot(Math.abs(e-n),1,t)/t:0,mr=(e,t,n=15,r=40)=>{const o=ao(e.x,r,t.width-r)*n,i=ao(e.y,r,t.height-r)*n;return[o,i]},yn=(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)}),Jn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),xn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Nt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=gr(e)?e.internals.positionAbsolute:At(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}},on=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=gr(e)?e.internals.positionAbsolute:At(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)}},es=(e,t)=>xn(yn(Jn(e),Jn(t))),ts=(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)},sn=(e,t)=>ts(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),co=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ns=(e,t)=>(n,r)=>{},Ot=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?Ot(a,s):a},it=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ze(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 Xf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ze(e,n),o=Ze(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ze(e.top??e.y??0,n),o=Ze(e.bottom??e.y??0,n),i=Ze(e.left??e.x??0,t),s=Ze(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 Wf(e,t,n,r,o,i){const{x:s,y:a}=it(e,[t,n,r]),{x:c,y:l}=it({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 yr=(e,t,n,r,o,i)=>{const s=Xf(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=ot(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=Wf(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}},St=()=>{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 rs(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 os(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 lo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Gf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function qf(e){return{...qi,...e||{}}}function yt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=Pt({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?Ot(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const xr=e=>({width:e.offsetWidth,height:e.offsetHeight}),is=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Kf=["INPUT","SELECT","TEXTAREA"];function ss(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:Kf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const as=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=as(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)}},uo=(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,...xr(s)}})};function cs({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 Ft(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fo({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case G.Left:return[t-Ft(t-r,i),n];case G.Right:return[t+Ft(r-t,i),n];case G.Top:return[t,n-Ft(n-o,i)];case G.Bottom:return[t,n+Ft(o-n,i)]}}function ls({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top,curvature:s=.25}){const[a,c]=fo({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[l,u]=fo({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,f,h,g]=cs({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 us({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 Uf({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 Zf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=yn(on(e),on(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 sn(s,xn(i))>0}const Qf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Jf=(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)),eh=(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||Qf;let o;return Zi(e)?o={...e}:o={...e,id:r(e)},Jf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function ds({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=us({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const ho={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},th=({source:e,sourcePosition:t=G.Bottom,target:n})=>t===G.Left||t===G.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},go=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function nh({source:e,sourcePosition:t=G.Bottom,target:n,targetPosition:r=G.Top,center:o,offset:i,stepPosition:s}){const a=ho[t],c=ho[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=th({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]=us({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 C=[{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"?C:I:g=f==="x"?I:C}else{const C=[{x:l.x,y:u.y}],I=[{x:u.x,y:l.y}];if(f==="x"?g=a.x===h?I:C:g=a.y===h?C:I,t===r){const y=Math.abs(e[f]-n[f]);if(y<=i){const _=Math.min(i-1,i-y);a[f]===h?m[f]=(l[f]>e[f]?-1:1)*_:b[f]=(u[f]>n[f]?-1:1)*_}}if(t!==r){const y=f==="x"?"y":"x",_=a[f]===c[y],k=l[y]>u[y],A=l[y]<u[y];(a[f]===1&&(!_&&k||_&&A)||a[f]!==1&&(!_&&A||_&&k))&&(g=f==="x"?C:I)}const H={x:l.x+m.x,y:l.y+m.y},O={x:u.x+b.x,y:u.y+b.y},L=Math.max(Math.abs(H.x-g[0].x),Math.abs(O.x-g[0].x)),P=Math.max(Math.abs(H.y-g[0].y),Math.abs(O.y-g[0].y));L>=P?(v=(H.x+O.x)/2,w=g[0].y):(v=g[0].x,w=(H.y+O.y)/2)}const E={x:l.x+m.x,y:l.y+m.y},N={x:u.x+b.x,y:u.y+b.y};return[[e,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],v,w,p,x]}function rh(e,t,n,r){const o=Math.min(go(e,t)/2,go(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 er({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[d,f,h,g,v]=nh({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+=rh(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 po(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function oh(e){var d;const{sourceNode:t,targetNode:n}=e;if(!po(t)||!po(n))return null;const r=t.internals.handleBounds||mo(t.handles),o=n.internals.handleBounds||mo(n.handles),i=yo((r==null?void 0:r.source)??[],e.sourceHandle),s=yo(e.connectionMode===rt.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)||G.Bottom,c=(s==null?void 0:s.position)||G.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 mo(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=G.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 G.Top:return{x:o+s/2,y:i};case G.Right:return{x:o+s,y:i+a/2};case G.Bottom:return{x:o+s/2,y:i+a};case G.Left:return{x:o,y:i+a/2}}}function yo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function tr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function ih(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=tr(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 fs=1e3,sh=10,wr={nodeOrigin:[0,0],nodeExtent:Et,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ah={...wr,checkEquality:!0};function vr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function ch(e,t,n){const r=vr(wr,n);for(const o of e.values())if(o.parentId)Er(o,e,t,r);else{const i=At(o,r.nodeOrigin),s=Ge(o.extent)?o.extent:r.nodeExtent,a=We(i,s,xe(o));o.internals.positionAbsolute=a}}function lh(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 br(e){return e==="manual"}function nr(e,t,n,r={}){var u,d;const o=vr(ah,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!br(o.zIndexMode)?fs: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=At(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:lh(f,h),z:hs(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&&Er(h,t,n,r,i),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function uh(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 Er(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=vr(wr,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}uh(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*sh),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const d=i&&!br(c)?fs:0,{x:f,y:h,z:g}=dh(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 hs(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return br(n)?r:r+(e.selected?t:0)}function dh(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),l=At(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=Ji(d,c,t));const f=hs(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function _r(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)??Nt(c),u=es(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(E=>E.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 fh(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=xr(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 N=t.get(g.parentId);N&&(x=Ji(x,v,N))}else p&&(x=We(x,p,v));const E={...g,measured:v,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:uo("source",h.nodeElement,b,d,g.id),target:uo("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,E),g.parentId&&Er(E,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:Nt(E,o)}))}}if(f.length>0){const h=_r(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function hh({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 xo(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 gs(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}`;xo("source",c,u,e,o,s),xo("target",c,l,e,i,a),t.set(r.id,r)}}function ps(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ps(n,t):!1}function wo(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 gh(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!ps(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 Ln({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 ph({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=Ot(i,t);return{x:s.x-i.x,y:s.y-i.y}}function mh({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:E,nodeId:N,nodeClickDistance:M=0}){f=ce(x);function C({x:L,y:P}){const{nodeLookup:y,nodeExtent:_,snapGrid:k,snapToGrid:A,nodeOrigin:$,onNodeDrag:T,onSelectionDrag:D,onError:F,updateNodePositions:z}=t();i={x:L,y:P};let V=!1;const Y=a.size>1,K=Y&&_?Jn(Tt(a)):null,Q=Y&&A?ph({dragItems:a,snapGrid:k,x:L,y:P}):null;for(const[q,R]of a){if(!y.has(q))continue;let B={x:L-R.distance.x,y:P-R.distance.y};A&&(B=Q?{x:Math.round(B.x+Q.x),y:Math.round(B.y+Q.y)}:Ot(B,k));let U=null;if(Y&&_&&!R.extent&&K){const{positionAbsolute:X}=R.internals,J=X.x-K.x+_[0][0],te=X.x+R.measured.width-K.x2+_[1][0],ne=X.y-K.y+_[0][1],oe=X.y+R.measured.height-K.y2+_[1][1];U=[[J,ne],[te,oe]]}const{position:Z,positionAbsolute:W}=Qi({nodeId:q,nextPosition:B,nodeLookup:y,nodeExtent:U||_,nodeOrigin:$,onError:F});V=V||R.position.x!==Z.x||R.position.y!==Z.y,R.position=Z,R.internals.positionAbsolute=W}if(g=g||V,!!V&&(z(a,!0),v&&(r||T||!N&&D))){const[q,R]=Ln({nodeId:N,dragItems:a,nodeLookup:y});r==null||r(v,a,q,R),T==null||T(v,q,R),N||D==null||D(v,R)}}async function I(){if(!u)return;const{transform:L,panBy:P,autoPanSpeed:y,autoPanOnNodeDrag:_}=t();if(!_){c=!1,cancelAnimationFrame(s);return}const[k,A]=mr(l,u,y);(k!==0||A!==0)&&(i.x=(i.x??0)-k/L[2],i.y=(i.y??0)-A/L[2],await P({x:k,y:A})&&C(i)),s=requestAnimationFrame(I)}function H(L){var Y;const{nodeLookup:P,multiSelectionActive:y,nodesDraggable:_,transform:k,snapGrid:A,snapToGrid:$,selectNodesOnDrag:T,onNodeDragStart:D,onSelectionDragStart:F,unselectNodesAndEdges:z}=t();d=!0,(!T||!E)&&!y&&N&&((Y=P.get(N))!=null&&Y.selected||z()),E&&T&&N&&(e==null||e(N));const V=yt(L.sourceEvent,{transform:k,snapGrid:A,snapToGrid:$,containerBounds:u});if(i=V,a=gh(P,_,V,N),a.size>0&&(n||D||!N&&F)){const[K,Q]=Ln({nodeId:N,dragItems:a,nodeLookup:P});n==null||n(L.sourceEvent,a,K,Q),D==null||D(L.sourceEvent,K,Q),N||F==null||F(L.sourceEvent,Q)}}const O=Ti().clickDistance(M).on("start",L=>{const{domNode:P,nodeDragThreshold:y,transform:_,snapGrid:k,snapToGrid:A}=t();u=(P==null?void 0:P.getBoundingClientRect())||null,h=!1,g=!1,v=L.sourceEvent,y===0&&H(L),i=yt(L.sourceEvent,{transform:_,snapGrid:k,snapToGrid:A,containerBounds:u}),l=pe(L.sourceEvent,u)}).on("drag",L=>{const{autoPanOnNodeDrag:P,transform:y,snapGrid:_,snapToGrid:k,nodeDragThreshold:A,nodeLookup:$}=t(),T=yt(L.sourceEvent,{transform:y,snapGrid:_,snapToGrid:k,containerBounds:u});if(v=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||N&&!$.has(N))&&(h=!0),!h){if(!c&&P&&d&&(c=!0,I()),!d){const D=pe(L.sourceEvent,u),F=D.x-l.x,z=D.y-l.y;Math.sqrt(F*F+z*z)>A&&H(L)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&a&&d&&(l=pe(L.sourceEvent,u),C(T))}}).on("end",L=>{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:_,onSelectionDragStop:k}=t();if(g&&(y(a,!1),g=!1),o||_||!N&&k){const[A,$]=Ln({nodeId:N,dragItems:a,nodeLookup:P,dragging:!1});o==null||o(L.sourceEvent,a,A,$),_==null||_(L.sourceEvent,A,$),N||k==null||k(L.sourceEvent,$)}}}).filter(L=>{const P=L.target;return!L.button&&(!b||!wo(P,`.${b}`,x))&&(!p||wo(P,p,x))});f.call(O)}function m(){f==null||f.on(".drag",null)}return{update:w,destroy:m}}function yh(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())sn(o,Nt(i))>0&&r.push(i);return r}const xh=250;function wh(e,t,n,r){var a,c;let o=[],i=1/0;const s=yh(e,n,t+xh);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 ms(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 ys(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function vh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const xs=()=>!0;function bh(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=xs,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:E,autoPanSpeed:N,dragThreshold:M=1,handleDomNode:C}){const I=is(e.target);let H=0,O;const{x:L,y:P}=pe(e),y=ys(i,C),_=a==null?void 0:a.getBoundingClientRect();let k=!1;if(!_||!y)return;const A=ms(o,y,r,c,t);if(!A)return;let $=pe(e,_),T=!1,D=null,F=!1,z=null;function V(){if(!u||!_)return;const[Z,W]=mr($,_,N);f({x:Z,y:W}),H=requestAnimationFrame(V)}const Y={...A,nodeId:o,type:y,position:A.position},K=c.get(o);let q={inProgress:!0,isValid:null,from:qe(K,Y,G.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:K,to:$,toHandle:null,toPosition:so[Y.position],toNode:null,pointer:$};function R(){k=!0,p(q),g==null||g(e,{nodeId:o,handleId:r,handleType:y})}M===0&&R();function B(Z){if(!k){const{x:oe,y:ue}=pe(Z),ve=oe-L,be=ue-P;if(!(ve*ve+be*be>M*M))return;R()}if(!E()||!Y){U(Z);return}const W=x();$=pe(Z,_),O=wh(Pt($,W,!1,[1,1]),n,c,Y),T||(V(),T=!0);const X=ws(Z,{handle:O,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:I,lib:l,flowId:d,nodeLookup:c});z=X.handleDomNode,D=X.connection,F=vh(!!O,X.isValid);const J=c.get(o),te=J?qe(J,Y,G.Left,!0):q.from,ne={...q,from:te,isValid:F,to:X.toHandle&&F?it({x:X.toHandle.x,y:X.toHandle.y},W):$,toHandle:X.toHandle,toPosition:F&&X.toHandle?X.toHandle.position:so[Y.position],toNode:X.toHandle?c.get(X.toHandle.nodeId):null,pointer:$};p(ne),q=ne}function U(Z){if(!("touches"in Z&&Z.touches.length>0)){if(k){(O||z)&&D&&F&&(v==null||v(D));const{inProgress:W,...X}=q,J={...X,toPosition:q.toHandle?q.toPosition:null};w==null||w(Z,J),i&&(b==null||b(Z,J))}h(),cancelAnimationFrame(H),T=!1,F=!1,D=null,z=null,I.removeEventListener("mousemove",B),I.removeEventListener("mouseup",U),I.removeEventListener("touchmove",B),I.removeEventListener("touchend",U)}}I.addEventListener("mousemove",B),I.addEventListener("mouseup",U),I.addEventListener("touchmove",B),I.addEventListener("touchend",U)}function ws(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=xs,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=ys(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),E=w.classList.contains("connectable"),N=w.classList.contains("connectableend");if(!p||!b)return m;const M={source:d?p:r,sourceHandle:d?x:o,target:d?r:p,targetHandle:d?o:x};m.connection=M;const I=E&&N&&(n===rt.Strict?d&&b==="source"||!d&&b==="target":p!==r||x!==o);m.isValid=I&&l(M),m.toHandle=ms(p,b,x,u,n,!0)}return m}const rr={onPointerDown:bh,isValid:ws};function Eh({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(),E=p.sourceEvent.ctrlKey&&St()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*u,M=x[2]*Math.pow(2,N*E);t.scaleTo(M)};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 E=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],N=[E[0]-v[0],E[1]-v[1]];v=E;const M=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),C={x:x[0]-N[0]*M,y:x[1]-N[1]*M},I=[[0,0],[c,l]];t.setViewportConstrained({x:C.x,y:C.y,zoom:x[2]},I,a)},b=Wi().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 wn=e=>({x:e.x,y:e.y,zoom:e.k}),$n=({x:e,y:t,zoom:n})=>mn.translate(e,t).scale(n),Le=(e,t)=>e.target.closest(`.${t}`),vs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),_h=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,jn=(e,t=0,n=_h,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},bs=e=>{const t=e.ctrlKey&&St()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Nh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Le(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=bs(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;!St()&&u.shiftKey&&o!==Ve.Vertical&&(h=u.deltaY*f,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const v=wn(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 Sh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=Le(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function kh({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=wn(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 Ch({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&vs(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,wn(i.transform)))}}function Mh({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&&vs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=wn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Ih({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"&&(Le(f,`${u}-flow__node`)||Le(f,`${u}-flow__edge`)||Le(f,`${u}-flow__selection`)||Le(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!v||Le(f,c)&&v||Le(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 Ah({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=Wi().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);x({x:o.x,y:o.y,zoom:ot(o.zoom,t,n)},[[0,0],[u.width,u.height]],r);const v=g.on("wheel.zoom"),w=g.on("dblclick.zoom");h.wheelDelta(bs);async function m(P,y){return g?new Promise(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?mt:Wt).transform(jn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}function b({noWheelClassName:P,noPanClassName:y,onPaneContextMenu:_,userSelectionActive:k,panOnScroll:A,panOnDrag:$,panOnScrollMode:T,panOnScrollSpeed:D,preventScrolling:F,zoomOnPinch:z,zoomOnScroll:V,zoomOnDoubleClick:Y,panActivationKeyPressed:K=!1,zoomActivationKeyPressed:Q,lib:q,onTransformChange:R,connectionInProgress:B,paneClickDistance:U,selectionOnDrag:Z}){k&&!l.isZoomingOrPanning&&p();const W=A&&!Q&&!k;h.clickDistance(Z?1/0:!ge(U)||U<0?0:U);const X=W?Nh({zoomPanValues:l,noWheelClassName:P,d3Selection:g,d3Zoom:h,panOnScrollMode:T,panOnScrollSpeed:D,zoomOnPinch:z,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Sh({noWheelClassName:P,preventScrolling:F,d3ZoomHandler:v});g.on("wheel.zoom",X,{passive:!1});const J=kh({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",J);const te=Ch({zoomPanValues:l,panOnDrag:$,onPaneContextMenu:!!_,onPanZoom:i,onTransformChange:R});h.on("zoom",te);const ne=Mh({zoomPanValues:l,panOnDrag:$,panOnScroll:A,onPaneContextMenu:_,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const oe=Ih({panActivationKeyPressed:K,zoomActivationKeyPressed:Q,panOnDrag:$,zoomOnScroll:V,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:z,userSelectionActive:k,noPanClassName:y,noWheelClassName:P,lib:q,connectionInProgress:B});h.filter(oe),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function p(){h.on("zoom",null)}async function x(P,y,_){const k=$n(P),A=h==null?void 0:h.constrain()(k,y,_);return A&&await m(A),A}async function E(P,y){const _=$n(P);return await m(_,y),_}function N(P){if(g){const y=$n(P),_=g.property("__zoom");(_.k!==P.zoom||_.x!==P.x||_.y!==P.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function M(){const P=g?Xi(g.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}async function C(P,y){return g?new Promise(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?mt:Wt).scaleTo(jn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}async function I(P,y){return g?new Promise(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?mt:Wt).scaleBy(jn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}function H(P){h==null||h.scaleExtent(P)}function O(P){h==null||h.translateExtent(P)}function L(P){const y=!ge(P)||P<0?0:P;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:E,setViewportConstrained:x,getViewport:M,scaleTo:C,scaleBy:I,setScaleExtent:H,setTranslateExtent:O,syncViewport:N,setClickDistance:L}}var st;(function(e){e.Line="line",e.Handle="handle"})(st||(st={}));function Th({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 vo(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 Bt(e,t,n){return Math.max(0,t-e,e-n)}function bo(e,t){return e?!t:t}function Oh(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:E,height:N,aspectRatio:M}=e;let C=Math.floor(u?h-e.pointerX:0),I=Math.floor(d?g-e.pointerY:0);const H=E+(c?-C:C),O=N+(l?-I:I),L=-i[0]*E,P=-i[1]*N;let y=Bt(H,v,w),_=Bt(O,m,b);if(s){let $=0,T=0;c&&C<0?$=Oe(p+C+L,s[0][0]):!c&&C>0&&($=Pe(p+H+L,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,$),_=Math.max(_,T)}if(a){let $=0,T=0;c&&C>0?$=Pe(p+C,a[0][0]):!c&&C<0&&($=Oe(p+H,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,$),_=Math.max(_,T)}if(o){if(u){const $=Bt(H/M,m,b)*M;if(y=Math.max(y,$),s){let T=0;!c&&!l||c&&!l&&f?T=Pe(x+P+H/M,s[1][1])*M:T=Oe(x+P+(c?C:-C)/M,s[0][1])*M,y=Math.max(y,T)}if(a){let T=0;!c&&!l||c&&!l&&f?T=Oe(x+H/M,a[1][1])*M:T=Pe(x+(c?C:-C)/M,a[0][1])*M,y=Math.max(y,T)}}if(d){const $=Bt(O*M,v,w)/M;if(_=Math.max(_,$),s){let T=0;!c&&!l||l&&!c&&f?T=Pe(p+O*M+L,s[1][0])/M:T=Oe(p+(l?I:-I)*M+L,s[0][0])/M,_=Math.max(_,T)}if(a){let T=0;!c&&!l||l&&!c&&f?T=Oe(p+O*M,a[1][0])/M:T=Pe(p+(l?I:-I)*M,a[0][0])/M,_=Math.max(_,T)}}}I=I+(I<0?_:-_),C=C+(C<0?y:-y),o&&(f?H>O*M?I=(bo(c,l)?-C:C)/M:C=(bo(c,l)?-I:I)*M:u?(I=C/M,l=c):(C=I*M,c=l));const k=c?p+C:p,A=l?x+I:x;return{width:E+(c?-C:C),height:N+(l?-I:I),x:i[0]*C*(c?-1:1)+k,y:i[1]*I*(l?-1:1)+A}}const Es={width:0,height:0,x:0,y:0},Ph={...Es,pointerX:0,pointerY:0,aspectRatio:1};function Lh(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 $h({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:vo("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={...Es},b={...Ph};s={boundaries:u,resizeDirection:f,keepAspectRatio:d,controlDirection:vo(l)};let p,x=null,E=[],N,M,C,I=!1;const H=Ti().on("start",O=>{const{nodeLookup:L,transform:P,snapGrid:y,snapToGrid:_,nodeOrigin:k,paneDomNode:A}=n();if(p=L.get(t),!p)return;x=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:$,ySnapped:T}=yt(O.sourceEvent,{transform:P,snapGrid:y,snapToGrid:_,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:$,pointerY:T,aspectRatio:m.width/m.height},N=void 0,M=Ge(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(N=L.get(p.parentId)),N&&p.extent==="parent"&&(M=[[0,0],[N.measured.width,N.measured.height]]),E=[],C=void 0;for(const[D,F]of L)if(F.parentId===t&&(E.push({id:D,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const z=Lh(F,p,F.origin??k);C?C=[[Math.min(z[0][0],C[0][0]),Math.min(z[0][1],C[0][1])],[Math.max(z[1][0],C[1][0]),Math.max(z[1][1],C[1][1])]]:C=z}h==null||h(O,{...m})}).on("drag",O=>{const{transform:L,snapGrid:P,snapToGrid:y,nodeOrigin:_}=n(),k=yt(O.sourceEvent,{transform:L,snapGrid:P,snapToGrid:y,containerBounds:x}),A=[];if(!p)return;const{x:$,y:T,width:D,height:F}=m,z={},V=p.origin??_,{width:Y,height:K,x:Q,y:q}=Oh(b,s.controlDirection,k,s.boundaries,s.keepAspectRatio,V,M,C),R=Y!==D,B=K!==F,U=Q!==$&&R,Z=q!==T&&B;if(!U&&!Z&&!R&&!B)return;if((U||Z||V[0]===1||V[1]===1)&&(z.x=U?Q:m.x,z.y=Z?q:m.y,m.x=z.x,m.y=z.y,E.length>0)){const te=Q-$,ne=q-T;for(const oe of E)oe.position={x:oe.position.x-te+V[0]*(Y-D),y:oe.position.y-ne+V[1]*(K-F)},A.push(oe)}if((R||B)&&(z.width=R&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:m.width,z.height=B&&(!s.resizeDirection||s.resizeDirection==="vertical")?K:m.height,m.width=z.width,m.height=z.height),N&&p.expandParent){const te=V[0]*(z.width??0);z.x&&z.x<te&&(m.x=te,b.x=b.x-(z.x-te));const ne=V[1]*(z.height??0);z.y&&z.y<ne&&(m.y=ne,b.y=b.y-(z.y-ne))}const W=Th({width:m.width,prevWidth:D,height:m.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),X={...m,direction:W};(w==null?void 0:w(O,X))!==!1&&(I=!0,g==null||g(O,X),r(z,A))}).on("end",O=>{I&&(v==null||v(O,{...m}),o==null||o({...m}),I=!1)});i.call(H)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}const jh={},Eo=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:()=>{(jh?"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},Dh=e=>e?Eo(e):Eo,{useDebugValue:Rh}=zc,{useSyncExternalStoreWithSelector:zh}=Rc,Hh=e=>e;function _s(e,t=Hh,n){const r=zh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Rh(r),r}const _o=(e,t)=>{const n=Dh(e),r=(o,i=t)=>_s(n,o,i);return Object.assign(r,n),r},Fh=(e,t)=>e?_o(e,t):_o;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 vn=j.createContext(null),Bh=vn.Provider,Ns=me.error001("react");function ee(e,t){const n=j.useContext(vn);if(n===null)throw new Error(Ns);return _s(n,e,t)}function re(){const e=j.useContext(vn);if(e===null)throw new Error(Ns);return j.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const No={display:"none"},Vh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ss="react-flow__node-desc",ks="react-flow__edge-desc",Yh="react-flow__aria-live",Xh=e=>e.ariaLiveMessage,Wh=e=>e.ariaLabelConfig;function Gh({rfId:e}){const t=ee(Xh);return S.jsx("div",{id:`${Yh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Vh,children:t})}function qh({rfId:e,disableKeyboardA11y:t}){const n=ee(Wh);return S.jsxs(S.Fragment,{children:[S.jsx("div",{id:`${Ss}-${e}`,style:No,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),S.jsx("div",{id:`${ks}-${e}`,style:No,children:n["edge.a11yDescription.default"]}),!t&&S.jsx(Gh,{rfId:e})]})}const bn=j.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return S.jsx("div",{className:se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});bn.displayName="Panel";const So="https://reactflow.dev?utm_source=attribution";function Kh({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:S.jsx(bn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${So}`,children:S.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Uh=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}},Vt=e=>e.id;function Zh(e,t){return ie(e.selectedNodes.map(Vt),t.selectedNodes.map(Vt))&&ie(e.selectedEdges.map(Vt),t.selectedEdges.map(Vt))}function Qh({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:r}=ee(Uh,Zh);return j.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const Jh=e=>!!e.onSelectionChangeHandlers;function eg({onSelectionChange:e}){const t=ee(Jh);return e||t?S.jsx(Qh,{onSelectionChange:e}):null}const Cs=[0,0],tg={x:0,y:0,zoom:1},ng=["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"],ko=[...ng,"rfId"],rg=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}),Co={translateExtent:Et,nodeOrigin:Cs,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function og(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=ee(rg,ie),l=re();j.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Co,a()}),[]);const u=j.useRef(Co);return j.useEffect(()=>{for(const d of ko){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:qf(f)}):d==="fitView"?l.setState({fitViewQueued:f}):d==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[d]:f})))}u.current=e},ko.map(d=>e[d])),null}function Mo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function ig(e){var r;const[t,n]=j.useState(e==="system"?null:e);return j.useEffect(()=>{if(e!=="system"){n(e);return}const o=Mo(),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=Mo())!=null&&r.matches?"dark":"light"}const Io=typeof document<"u"?document:null;function kt(e=null,t={target:Io,actInsideInputWithModifier:!0}){const[n,r]=j.useState(!1),o=j.useRef(!1),i=j.useRef(new Set([])),[s,a]=j.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace(/\+/g,`
|
|
16
|
+
*/const ol=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Uy=sr("ZoomOut",ol);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 il={value:()=>{}};function fn(){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 Xt(n)}function Xt(e){this._=e}function sl(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}})}Xt.prototype=fn.prototype={constructor:Xt,on:function(e,t){var n=this._,r=sl(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=al(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]=Vr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Vr(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 Xt(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 al(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function Vr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=il,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Xn="http://www.w3.org/1999/xhtml";const Yr={svg:"http://www.w3.org/2000/svg",xhtml:Xn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function hn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Yr.hasOwnProperty(t)?{space:Yr[t],local:e}:e}function cl(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Xn&&t.documentElement.namespaceURI===Xn?t.createElement(e):t.createElementNS(n,e)}}function ll(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function yi(e){var t=hn(e);return(t.local?ll:cl)(t)}function ul(){}function ar(e){return e==null?ul:function(){return this.querySelector(e)}}function dl(e){typeof e!="function"&&(e=ar(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 fl(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function hl(){return[]}function xi(e){return e==null?hl:function(){return this.querySelectorAll(e)}}function gl(e){return function(){return fl(e.apply(this,arguments))}}function pl(e){typeof e=="function"?e=gl(e):e=xi(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 wi(e){return function(){return this.matches(e)}}function vi(e){return function(t){return t.matches(e)}}var ml=Array.prototype.find;function yl(e){return function(){return ml.call(this.children,e)}}function xl(){return this.firstElementChild}function wl(e){return this.select(e==null?xl:yl(typeof e=="function"?e:vi(e)))}var vl=Array.prototype.filter;function bl(){return Array.from(this.children)}function El(e){return function(){return vl.call(this.children,e)}}function _l(e){return this.selectAll(e==null?bl:El(typeof e=="function"?e:vi(e)))}function Nl(e){typeof e!="function"&&(e=wi(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 bi(e){return new Array(e.length)}function Sl(){return new le(this._enter||this._groups.map(bi),this._parents)}function Ut(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ut.prototype={constructor:Ut,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 Cl(e){return function(){return e}}function kl(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 Ut(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Ml(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 Ut(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function Il(e){return e.__data__}function Al(e,t){if(!arguments.length)return Array.from(this,Il);var n=t?Ml:kl,r=this._parents,o=this._groups;typeof e!="function"&&(e=Cl(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=Tl(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,E;b<g;++b)if(x=v[b]){for(b>=p&&(p=b+1);!(E=w[p])&&++p<g;);x._next=E||null}}return s=new le(s,r),s._enter=a,s._exit=c,s}function Tl(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ol(){return new le(this._exit||this._groups.map(bi),this._parents)}function Pl(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 Ll(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 $l(){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 Dl(e){e||(e=jl);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 jl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Rl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hl(){return Array.from(this)}function zl(){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 Fl(){let e=0;for(const t of this)++e;return e}function Bl(){return!this.node()}function Vl(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 Yl(e){return function(){this.removeAttribute(e)}}function Xl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Wl(e,t){return function(){this.setAttribute(e,t)}}function Gl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ql(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Kl(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 Ul(e,t){var n=hn(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?Xl:Yl:typeof t=="function"?n.local?Kl:ql:n.local?Gl:Wl)(n,t))}function Ei(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Zl(e){return function(){this.style.removeProperty(e)}}function Ql(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Jl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function eu(e,t,n){return arguments.length>1?this.each((t==null?Zl:typeof t=="function"?Jl:Ql)(e,t,n??"")):tt(this.node(),e)}function tt(e,t){return e.style.getPropertyValue(t)||Ei(e).getComputedStyle(e,null).getPropertyValue(t)}function tu(e){return function(){delete this[e]}}function nu(e,t){return function(){this[e]=t}}function ru(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function ou(e,t){return arguments.length>1?this.each((t==null?tu:typeof t=="function"?ru:nu)(e,t)):this.node()[e]}function _i(e){return e.trim().split(/^|\s+/)}function cr(e){return e.classList||new Ni(e)}function Ni(e){this._node=e,this._names=_i(e.getAttribute("class")||"")}Ni.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 Si(e,t){for(var n=cr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Ci(e,t){for(var n=cr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function iu(e){return function(){Si(this,e)}}function su(e){return function(){Ci(this,e)}}function au(e,t){return function(){(t.apply(this,arguments)?Si:Ci)(this,e)}}function cu(e,t){var n=_i(e+"");if(arguments.length<2){for(var r=cr(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?au:t?iu:su)(n,t))}function lu(){this.textContent=""}function uu(e){return function(){this.textContent=e}}function du(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function fu(e){return arguments.length?this.each(e==null?lu:(typeof e=="function"?du:uu)(e)):this.node().textContent}function hu(){this.innerHTML=""}function gu(e){return function(){this.innerHTML=e}}function pu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function mu(e){return arguments.length?this.each(e==null?hu:(typeof e=="function"?pu:gu)(e)):this.node().innerHTML}function yu(){this.nextSibling&&this.parentNode.appendChild(this)}function xu(){return this.each(yu)}function wu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function vu(){return this.each(wu)}function bu(e){var t=typeof e=="function"?e:yi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Eu(){return null}function _u(e,t){var n=typeof e=="function"?e:yi(e),r=t==null?Eu:typeof t=="function"?t:ar(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Nu(){var e=this.parentNode;e&&e.removeChild(this)}function Su(){return this.each(Nu)}function Cu(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ku(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mu(e){return this.select(e?ku:Cu)}function Iu(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Au(e){return function(t){e.call(this,t,this.__data__)}}function Tu(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 Ou(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 Pu(e,t,n){return function(){var r=this.__on,o,i=Au(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 Lu(e,t,n){var r=Tu(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?Pu:Ou,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function ki(e,t,n){var r=Ei(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 $u(e,t){return function(){return ki(this,e,t)}}function Du(e,t){return function(){return ki(this,e,t.apply(this,arguments))}}function ju(e,t){return this.each((typeof t=="function"?Du:$u)(e,t))}function*Ru(){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 Mi=[null];function le(e,t){this._groups=e,this._parents=t}function Mt(){return new le([[document.documentElement]],Mi)}function Hu(){return this}le.prototype=Mt.prototype={constructor:le,select:dl,selectAll:pl,selectChild:wl,selectChildren:_l,filter:Nl,data:Al,enter:Sl,exit:Ol,join:Pl,merge:Ll,selection:Hu,order:$l,sort:Dl,call:Rl,nodes:Hl,node:zl,size:Fl,empty:Bl,each:Vl,attr:Ul,style:eu,property:ou,classed:cu,text:fu,html:mu,raise:xu,lower:vu,append:bu,insert:_u,remove:Su,clone:Mu,datum:Iu,on:Lu,dispatch:ju,[Symbol.iterator]:Ru};function ce(e){return typeof e=="string"?new le([[document.querySelector(e)]],[document.documentElement]):new le([[e]],Mi)}function zu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function fe(e,t){if(e=zu(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 Fu={passive:!1},xt={capture:!0,passive:!1};function An(e){e.stopImmediatePropagation()}function Je(e){e.preventDefault(),e.stopImmediatePropagation()}function Ii(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Je,xt);"onselectstart"in t?n.on("selectstart.drag",Je,xt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ai(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Je,xt),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 Dt=e=>()=>e;function Wn(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}})}Wn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Bu(e){return!e.ctrlKey&&!e.button}function Vu(){return this.parentNode}function Yu(e,t){return t??{x:e.x,y:e.y}}function Xu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ti(){var e=Bu,t=Vu,n=Yu,r=Xu,o={},i=fn("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,Fu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,E){if(!(u||!e.call(this,x,E))){var N=p(this,t.call(this,x,E),x,E,"mouse");N&&(ce(x.view).on("mousemove.drag",g,xt).on("mouseup.drag",v,xt),Ii(x.view),An(x),l=!1,a=x.clientX,c=x.clientY,N("start",x))}}function g(x){if(Je(x),!l){var E=x.clientX-a,N=x.clientY-c;l=E*E+N*N>d}o.mouse("drag",x)}function v(x){ce(x.view).on("mousemove.drag mouseup.drag",null),Ai(x.view,l),Je(x),o.mouse("end",x)}function w(x,E){if(e.call(this,x,E)){var N=x.changedTouches,k=t.call(this,x,E),M=N.length,I,z;for(I=0;I<M;++I)(z=p(this,k,x,E,N[I].identifier,N[I]))&&(An(x),z("start",x,N[I]))}}function m(x){var E=x.changedTouches,N=E.length,k,M;for(k=0;k<N;++k)(M=o[E[k].identifier])&&(Je(x),M("drag",x,E[k]))}function b(x){var E=x.changedTouches,N=E.length,k,M;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),k=0;k<N;++k)(M=o[E[k].identifier])&&(An(x),M("end",x,E[k]))}function p(x,E,N,k,M,I){var z=i.copy(),O=fe(I||N,E),L,P,y;if((y=n.call(x,new Wn("beforestart",{sourceEvent:N,target:f,identifier:M,active:s,x:O[0],y:O[1],dx:0,dy:0,dispatch:z}),k))!=null)return L=y.x-O[0]||0,P=y.y-O[1]||0,function _(C,A,$){var T=O,j;switch(C){case"start":o[M]=_,j=s++;break;case"end":delete o[M],--s;case"drag":O=fe($||A,E),j=s;break}z.call(C,x,new Wn(C,{sourceEvent:A,subject:y,target:f,identifier:M,active:j,x:O[0]+L,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:Dt(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:Dt(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:Dt(x),f):n},f.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:Dt(!!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 lr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Oi(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function It(){}var wt=.7,Zt=1/wt,et="\\s*([+-]?\\d+)\\s*",vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ne="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Wu=/^#([0-9a-f]{3,8})$/,Gu=new RegExp(`^rgb\\(${et},${et},${et}\\)$`),qu=new RegExp(`^rgb\\(${Ne},${Ne},${Ne}\\)$`),Ku=new RegExp(`^rgba\\(${et},${et},${et},${vt}\\)$`),Uu=new RegExp(`^rgba\\(${Ne},${Ne},${Ne},${vt}\\)$`),Zu=new RegExp(`^hsl\\(${vt},${Ne},${Ne}\\)$`),Qu=new RegExp(`^hsla\\(${vt},${Ne},${Ne},${vt}\\)$`),Xr={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};lr(It,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Wr,formatHex:Wr,formatHex8:Ju,formatHsl:ed,formatRgb:Gr,toString:Gr});function Wr(){return this.rgb().formatHex()}function Ju(){return this.rgb().formatHex8()}function ed(){return Pi(this).formatHsl()}function Gr(){return this.rgb().formatRgb()}function Ye(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Wu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?qr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jt(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=Gu.exec(e))?new ae(t[1],t[2],t[3],1):(t=qu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ku.exec(e))?jt(t[1],t[2],t[3],t[4]):(t=Uu.exec(e))?jt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Zu.exec(e))?Zr(t[1],t[2]/100,t[3]/100,1):(t=Qu.exec(e))?Zr(t[1],t[2]/100,t[3]/100,t[4]):Xr.hasOwnProperty(e)?qr(Xr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function qr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function jt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function td(e){return e instanceof It||(e=Ye(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Gn(e,t,n,r){return arguments.length===1?td(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}lr(ae,Gn,Oi(It,{brighter(e){return e=e==null?Zt:Math.pow(Zt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,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),Qt(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:Kr,formatHex:Kr,formatHex8:nd,formatRgb:Ur,toString:Ur}));function Kr(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}`}function nd(){return`#${Fe(this.r)}${Fe(this.g)}${Fe(this.b)}${Fe((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ur(){const e=Qt(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Qt(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 Zr(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 Pi(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof It||(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 rd(e,t,n,r){return arguments.length===1?Pi(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}lr(he,rd,Oi(It,{brighter(e){return e=e==null?Zt:Math.pow(Zt,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,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(Tn(e>=240?e-240:e+120,o,r),Tn(e,o,r),Tn(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(Qr(this.h),Rt(this.s),Rt(this.l),Qt(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=Qt(this.opacity);return`${e===1?"hsl(":"hsla("}${Qr(this.h)}, ${Rt(this.s)*100}%, ${Rt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Qr(e){return e=(e||0)%360,e<0?e+360:e}function Rt(e){return Math.max(0,Math.min(1,e||0))}function Tn(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 ur=e=>()=>e;function od(e,t){return function(n){return e+n*t}}function id(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 sd(e){return(e=+e)==1?Li:function(t,n){return n-t?id(t,n,e):ur(isNaN(t)?n:t)}}function Li(e,t){var n=t-e;return n?od(e,n):ur(isNaN(e)?t:e)}const Jt=(function e(t){var n=sd(t);function r(o,i){var s=n((o=Gn(o)).r,(i=Gn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),l=Li(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 ad(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 cd(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ld(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]=mt(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 ud(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 dd(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]=mt(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var qn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,On=new RegExp(qn.source,"g");function fd(e){return function(){return e}}function hd(e){return function(t){return e(t)+""}}function $i(e,t){var n=qn.lastIndex=On.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=qn.exec(e))&&(o=On.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=On.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?hd(c[0].x):fd(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 mt(e,t){var n=typeof t,r;return t==null||n==="boolean"?ur(t):(n==="number"?Ee:n==="string"?(r=Ye(t))?(t=r,Jt):$i:t instanceof Ye?Jt:t instanceof Date?ud:cd(t)?ad:Array.isArray(t)?ld:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?dd:Ee)(e,t)}var Jr=180/Math.PI,Kn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Di(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)*Jr,skewX:Math.atan(c)*Jr,scaleX:s,scaleY:a}}var Ht;function gd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Kn:Di(t.a,t.b,t.c,t.d,t.e,t.f)}function pd(e){return e==null||(Ht||(Ht=document.createElementNS("http://www.w3.org/2000/svg","g")),Ht.setAttribute("transform",e),!(e=Ht.transform.baseVal.consolidate()))?Kn:(e=e.matrix,Di(e.a,e.b,e.c,e.d,e.e,e.f))}function ji(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 md=ji(gd,"px, ","px)","deg)"),yd=ji(pd,", ",")",")"),xd=1e-12;function eo(e){return((e=Math.exp(e))+1/e)/2}function wd(e){return((e=Math.exp(e))-1/e)/2}function vd(e){return((e=Math.exp(2*e))-1)/(e+1)}const Wt=(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<xd)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),E=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(x*x+1)-x);m=(N-E)/t,w=function(k){var M=k*m,I=eo(E),z=l/(n*b)*(I*vd(t*M+E)-wd(E));return[a+z*h,c+z*g,l*I/eo(t*M+E)]}}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 nt=0,ht=0,dt=0,Ri=1e3,en,gt,tn=0,Xe=0,gn=0,bt=typeof performance=="object"&&performance.now?performance:Date,Hi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function dr(){return Xe||(Hi(bd),Xe=bt.now()+gn)}function bd(){Xe=0}function nn(){this._call=this._time=this._next=null}nn.prototype=zi.prototype={constructor:nn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?dr():+n)+(t==null?0:+t),!this._next&>!==this&&(gt?gt._next=this:en=this,gt=this),this._call=e,this._time=n,Un()},stop:function(){this._call&&(this._call=null,this._time=1/0,Un())}};function zi(e,t,n){var r=new nn;return r.restart(e,t,n),r}function Ed(){dr(),++nt;for(var e=en,t;e;)(t=Xe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--nt}function to(){Xe=(tn=bt.now())+gn,nt=ht=0;try{Ed()}finally{nt=0,Nd(),Xe=0}}function _d(){var e=bt.now(),t=e-tn;t>Ri&&(gn-=t,tn=e)}function Nd(){for(var e,t=en,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:en=n);gt=e,Un(r)}function Un(e){if(!nt){ht&&(ht=clearTimeout(ht));var t=e-Xe;t>24?(e<1/0&&(ht=setTimeout(to,e-bt.now()-gn)),dt&&(dt=clearInterval(dt))):(dt||(tn=bt.now(),dt=setInterval(_d,Ri)),nt=1,Hi(to))}}function no(e,t,n){var r=new nn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Sd=fn("start","end","cancel","interrupt"),Cd=[],Fi=0,ro=1,Zn=2,Gt=3,oo=4,Qn=5,qt=6;function pn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;kd(e,n,{name:t,index:r,group:o,on:Sd,tween:Cd,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Fi})}function fr(e,t){var n=ye(e,t);if(n.state>Fi)throw new Error("too late; already scheduled");return n}function Se(e,t){var n=ye(e,t);if(n.state>Gt)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 kd(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=zi(i,0,n.time);function i(l){n.state=ro,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!==ro)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Gt)return no(s);h.state===oo?(h.state=qt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=qt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(no(function(){n.state===Gt&&(n.state=oo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Zn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Zn){for(n.state=Gt,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=Qn,1),d=-1,f=o.length;++d<f;)o[d].call(e,u);n.state===Qn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=qt,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Kt(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>Zn&&r.state<Qn,r.state=qt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Md(e){return this.each(function(){Kt(this,e)})}function Id(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 Ad(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 Td(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?Id:Ad)(n,e,t))}function hr(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 Bi(e,t){var n;return(typeof t=="number"?Ee:t instanceof Ye?Jt:(n=Ye(t))?(t=n,Jt):$i)(e,t)}function Od(e){return function(){this.removeAttribute(e)}}function Pd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ld(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 $d(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 Dd(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 jd(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 Rd(e,t){var n=hn(e),r=n==="transform"?yd:Bi;return this.attrTween(e,typeof t=="function"?(n.local?jd:Dd)(n,r,hr(this,"attr."+e,t)):t==null?(n.local?Pd:Od)(n):(n.local?$d:Ld)(n,r,t))}function Hd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function zd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Fd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&zd(e,i)),n}return o._value=t,o}function Bd(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Hd(e,i)),n}return o._value=t,o}function Vd(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=hn(e);return this.tween(n,(r.local?Fd:Bd)(r,t))}function Yd(e,t){return function(){fr(this,e).delay=+t.apply(this,arguments)}}function Xd(e,t){return t=+t,function(){fr(this,e).delay=t}}function Wd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Yd:Xd)(t,e)):ye(this.node(),t).delay}function Gd(e,t){return function(){Se(this,e).duration=+t.apply(this,arguments)}}function qd(e,t){return t=+t,function(){Se(this,e).duration=t}}function Kd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Gd:qd)(t,e)):ye(this.node(),t).duration}function Ud(e,t){if(typeof t!="function")throw new Error;return function(){Se(this,e).ease=t}}function Zd(e){var t=this._id;return arguments.length?this.each(Ud(t,e)):ye(this.node(),t).ease}function Qd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Se(this,e).ease=n}}function Jd(e){if(typeof e!="function")throw new Error;return this.each(Qd(this._id,e))}function ef(e){typeof e!="function"&&(e=wi(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 tf(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 nf(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 rf(e,t,n){var r,o,i=nf(t)?fr:Se;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function of(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(rf(n,e,t))}function sf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function af(){return this.on("end.remove",sf(this._id))}function cf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ar(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,pn(l[f],t,n,f,l,ye(u,n)));return new Te(i,this._parents,t,n)}function lf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=xi(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])&&pn(h,t,n,v,f,g);i.push(f),s.push(u)}return new Te(i,s,t,n)}var uf=Mt.prototype.constructor;function df(){return new uf(this._groups,this._parents)}function ff(e,t){var n,r,o;return function(){var i=tt(this,e),s=(this.style.removeProperty(e),tt(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Vi(e){return function(){this.style.removeProperty(e)}}function hf(e,t,n){var r,o=n+"",i;return function(){var s=tt(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function gf(e,t,n){var r,o,i;return function(){var s=tt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),tt(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function pf(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=Vi(t)):void 0;(l!==n||o!==u)&&(r=(n=l).copy()).on(s,o=u),c.on=r}}function mf(e,t,n){var r=(e+="")=="transform"?md:Bi;return t==null?this.styleTween(e,ff(e,r)).on("end.style."+e,Vi(e)):typeof t=="function"?this.styleTween(e,gf(e,r,hr(this,"style."+e,t))).each(pf(this._id,e)):this.styleTween(e,hf(e,r,t),n).on("end.style."+e,null)}function yf(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function xf(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&yf(e,s,n)),r}return i._value=t,i}function wf(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,xf(e,t,n??""))}function vf(e){return function(){this.textContent=e}}function bf(e){return function(){var t=e(this);this.textContent=t??""}}function Ef(e){return this.tween("text",typeof e=="function"?bf(hr(this,"text",e)):vf(e==null?"":e+""))}function _f(e){return function(t){this.textContent=e.call(this,t)}}function Nf(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&_f(o)),t}return r._value=e,r}function Sf(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,Nf(e))}function Cf(){for(var e=this._name,t=this._id,n=Yi(),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);pn(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 kf(){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 Mf=0;function Te(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Yi(){return++Mf}var Ie=Mt.prototype;Te.prototype={constructor:Te,select:cf,selectAll:lf,selectChild:Ie.selectChild,selectChildren:Ie.selectChildren,filter:ef,merge:tf,selection:df,transition:Cf,call:Ie.call,nodes:Ie.nodes,node:Ie.node,size:Ie.size,empty:Ie.empty,each:Ie.each,on:of,attr:Rd,attrTween:Vd,style:mf,styleTween:wf,text:Ef,textTween:Sf,remove:af,tween:Td,delay:Wd,duration:Kd,ease:Zd,easeVarying:Jd,end:kf,[Symbol.iterator]:Ie[Symbol.iterator]};function If(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Af={time:null,delay:0,duration:250,ease:If};function Tf(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 Of(e){var t,n;e instanceof Te?(t=e._id,e=e._name):(t=Yi(),(n=Af).time=dr(),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])&&pn(c,e,t,l,s,n||Tf(c,t));return new Te(r,this._parents,e,t)}Mt.prototype.interrupt=Md;Mt.prototype.transition=Of;const zt=e=>()=>e;function Pf(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 mn=new Ae(1,0,0);Xi.prototype=Ae.prototype;function Xi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return mn;return e.__zoom}function Pn(e){e.stopImmediatePropagation()}function ft(e){e.preventDefault(),e.stopImmediatePropagation()}function Lf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function $f(){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 io(){return this.__zoom||mn}function Df(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function jf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Rf(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 Wi(){var e=Lf,t=$f,n=Rf,r=Df,o=jf,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Wt,l=fn("start","zoom","end"),u,d,f,h=500,g=150,v=0,w=10;function m(y){y.property("__zoom",io).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",I).on("dblclick.zoom",z).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,_,C,A){var $=y.selection?y.selection():y;$.property("__zoom",io),y!==$?E(y,_,C,A):$.interrupt().each(function(){N(this,arguments).event(A).start().zoom(null,typeof _=="function"?_.apply(this,arguments):_).end()})},m.scaleBy=function(y,_,C,A){m.scaleTo(y,function(){var $=this.__zoom.k,T=typeof _=="function"?_.apply(this,arguments):_;return $*T},C,A)},m.scaleTo=function(y,_,C,A){m.transform(y,function(){var $=t.apply(this,arguments),T=this.__zoom,j=C==null?x($):typeof C=="function"?C.apply(this,arguments):C,F=T.invert(j),H=typeof _=="function"?_.apply(this,arguments):_;return n(p(b(T,H),j,F),$,s)},C,A)},m.translateBy=function(y,_,C,A){m.transform(y,function(){return n(this.__zoom.translate(typeof _=="function"?_.apply(this,arguments):_,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,A)},m.translateTo=function(y,_,C,A,$){m.transform(y,function(){var T=t.apply(this,arguments),j=this.__zoom,F=A==null?x(T):typeof A=="function"?A.apply(this,arguments):A;return n(mn.translate(F[0],F[1]).scale(j.k).translate(typeof _=="function"?-_.apply(this,arguments):-_,typeof C=="function"?-C.apply(this,arguments):-C),T,s)},A,$)};function b(y,_){return _=Math.max(i[0],Math.min(i[1],_)),_===y.k?y:new Ae(_,y.x,y.y)}function p(y,_,C){var A=_[0]-C[0]*y.k,$=_[1]-C[1]*y.k;return A===y.x&&$===y.y?y:new Ae(y.k,A,$)}function x(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function E(y,_,C,A){y.on("start.zoom",function(){N(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(A).end()}).tween("zoom",function(){var $=this,T=arguments,j=N($,T).event(A),F=t.apply($,T),H=C==null?x(F):typeof C=="function"?C.apply($,T):C,V=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),Y=$.__zoom,q=typeof _=="function"?_.apply($,T):_,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)}j.zoom(null,G)}})}function N(y,_,C){return!C&&y.__zooming||new k(y,_)}function k(y,_){this.that=y,this.args=_,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,_),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,_){return this.mouse&&y!=="mouse"&&(this.mouse[1]=_.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=_.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=_.invert(this.touch1[0])),this.that.__zoom=_,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var _=ce(this.that).datum();l.call(y,this.that,new Pf(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),_)}};function M(y,..._){if(!e.apply(this,arguments))return;var C=N(this,_).event(y),A=this.__zoom,$=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===$)return;C.mouse=[T,A.invert(T)],Kt(this),C.start()}ft(y),C.wheel=setTimeout(j,g),C.zoom("mouse",n(p(b(A,$),C.mouse[0],C.mouse[1]),C.extent,s));function j(){C.wheel=null,C.end()}}function I(y,..._){if(f||!e.apply(this,arguments))return;var C=y.currentTarget,A=N(this,_,!0).event(y),$=ce(y.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",V,!0),T=fe(y,C),j=y.clientX,F=y.clientY;Ii(y.view),Pn(y),A.mouse=[T,this.__zoom.invert(T)],Kt(this),A.start();function H(Y){if(ft(Y),!A.moved){var q=Y.clientX-j,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){$.on("mousemove.zoom mouseup.zoom",null),Ai(Y.view,A.moved),ft(Y),A.event(Y).end()}}function z(y,..._){if(e.apply(this,arguments)){var C=this.__zoom,A=fe(y.changedTouches?y.changedTouches[0]:y,this),$=C.invert(A),T=C.k*(y.shiftKey?.5:2),j=n(p(b(C,T),A,$),t.apply(this,_),s);ft(y),a>0?ce(this).transition().duration(a).call(E,j,A,y):ce(this).call(m.transform,j,A,y)}}function O(y,..._){if(e.apply(this,arguments)){var C=y.touches,A=C.length,$=N(this,_,y.changedTouches.length===A).event(y),T,j,F,H;for(Pn(y),j=0;j<A;++j)F=C[j],H=fe(F,this),H=[H,this.__zoom.invert(H),F.identifier],$.touch0?!$.touch1&&$.touch0[2]!==H[2]&&($.touch1=H,$.taps=0):($.touch0=H,T=!0,$.taps=1+!!u);u&&(u=clearTimeout(u)),T&&($.taps<2&&(d=H[0],u=setTimeout(function(){u=null},h)),Kt(this),$.start())}}function L(y,..._){if(this.__zooming){var C=N(this,_).event(y),A=y.changedTouches,$=A.length,T,j,F,H;for(ft(y),T=0;T<$;++T)j=A[T],F=fe(j,this),C.touch0&&C.touch0[2]===j.identifier?C.touch0[0]=F:C.touch1&&C.touch1[2]===j.identifier&&(C.touch1[0]=F);if(j=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;j=b(j,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(j,F,H),C.extent,s))}}function P(y,..._){if(this.__zooming){var C=N(this,_).event(y),A=y.changedTouches,$=A.length,T,j;for(Pn(y),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),T=0;T<$;++T)j=A[T],C.touch0&&C.touch0[2]===j.identifier?delete C.touch0:C.touch1&&C.touch1[2]===j.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&&(j=fe(j,this),Math.hypot(d[0]-j[0],d[1]-j[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:zt(+y),m):r},m.filter=function(y){return arguments.length?(e=typeof y=="function"?y:zt(!!y),m):e},m.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:zt(!!y),m):o},m.extent=function(y){return arguments.length?(t=typeof y=="function"?y:zt([[+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.`},Et=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Gi=["Enter"," ","Escape"],qi={"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 rt;(function(e){e.Strict="strict",e.Loose="loose"})(rt||(rt={}));var Ve;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ve||(Ve={}));var _t;(function(e){e.Partial="partial",e.Full="full"})(_t||(_t={}));const Ki={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var $e;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})($e||($e={}));var rn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(rn||(rn={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const so={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},Ui=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Hf=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),gr=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),At=(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}},zf=(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):gr(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,yn(o,on(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?xn(r):{x:0,y:0,width:0,height:0}},Tt=(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=yn(n,on(o)),r=!0)}),r?xn(n):{x:0,y:0,width:0,height:0}},pr=(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=es(a,c,l,u,b,p,w,m),E=w*m,N=i&&x>0;(!f.internals.handleBounds||N||x>=E||f.dragging)&&d.push(f)}return d},Ff=(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 Bf(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 Vf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=Bf(e,s),c=Tt(a),l=yr(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 Zi({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 Yf({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=Ff(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 ot=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),We=(e={x:0,y:0},t,n)=>({x:ot(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:ot(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 ao=(e,t,n)=>e<t?ot(Math.abs(e-t),1,t)/t:e>n?-ot(Math.abs(e-n),1,t)/t:0,mr=(e,t,n=15,r=40)=>{const o=ao(e.x,r,t.width-r)*n,i=ao(e.y,r,t.height-r)*n;return[o,i]},yn=(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)}),Jn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),xn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Nt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=gr(e)?e.internals.positionAbsolute:At(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}},on=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=gr(e)?e.internals.positionAbsolute:At(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)}},Ji=(e,t)=>xn(yn(Jn(e),Jn(t))),es=(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)},sn=(e,t)=>es(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),co=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ts=(e,t)=>(n,r)=>{},Ot=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?Ot(a,s):a},it=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ze(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 Xf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ze(e,n),o=Ze(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ze(e.top??e.y??0,n),o=Ze(e.bottom??e.y??0,n),i=Ze(e.left??e.x??0,t),s=Ze(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 Wf(e,t,n,r,o,i){const{x:s,y:a}=it(e,[t,n,r]),{x:c,y:l}=it({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 yr=(e,t,n,r,o,i)=>{const s=Xf(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=ot(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=Wf(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}},St=()=>{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 ns(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 rs(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 lo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Gf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function qf(e){return{...qi,...e||{}}}function os(e){return e===null?null:e?"valid":"invalid"}function yt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=Pt({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?Ot(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const xr=e=>({width:e.offsetWidth,height:e.offsetHeight}),is=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Kf=["INPUT","SELECT","TEXTAREA"];function ss(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:Kf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const as=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=as(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)}},uo=(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,...xr(s)}})};function cs({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 Ft(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fo({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-Ft(t-r,i),n];case W.Right:return[t+Ft(r-t,i),n];case W.Top:return[t,n-Ft(n-o,i)];case W.Bottom:return[t,n+Ft(o-n,i)]}}function ls({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=fo({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[l,u]=fo({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,f,h,g]=cs({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 us({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 Uf({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 Zf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=yn(on(e),on(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 sn(s,xn(i))>0}const Qf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Jf=(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)),eh=(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||Qf;let o;return Ui(e)?o={...e}:o={...e,id:r(e)},Jf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function ds({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=us({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const ho={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},th=({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},go=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function nh({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=ho[t],c=ho[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=th({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]=us({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 _=Math.min(i-1,i-y);a[f]===h?m[f]=(l[f]>e[f]?-1:1)*_:b[f]=(u[f]>n[f]?-1:1)*_}}if(t!==r){const y=f==="x"?"y":"x",_=a[f]===c[y],C=l[y]>u[y],A=l[y]<u[y];(a[f]===1&&(!_&&C||_&&A)||a[f]!==1&&(!_&&A||_&&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},L=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));L>=P?(v=(z.x+O.x)/2,w=g[0].y):(v=g[0].x,w=(z.y+O.y)/2)}const E={x:l.x+m.x,y:l.y+m.y},N={x:u.x+b.x,y:u.y+b.y};return[[e,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],v,w,p,x]}function rh(e,t,n,r){const o=Math.min(go(e,t)/2,go(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 er({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]=nh({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+=rh(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 po(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function oh(e){var d;const{sourceNode:t,targetNode:n}=e;if(!po(t)||!po(n))return null;const r=t.internals.handleBounds||mo(t.handles),o=n.internals.handleBounds||mo(n.handles),i=yo((r==null?void 0:r.source)??[],e.sourceHandle),s=yo(e.connectionMode===rt.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 mo(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 yo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function tr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function ih(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=tr(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 fs=1e3,sh=10,wr={nodeOrigin:[0,0],nodeExtent:Et,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ah={...wr,checkEquality:!0};function vr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function ch(e,t,n){const r=vr(wr,n);for(const o of e.values())if(o.parentId)Er(o,e,t,r);else{const i=At(o,r.nodeOrigin),s=Ge(o.extent)?o.extent:r.nodeExtent,a=We(i,s,xe(o));o.internals.positionAbsolute=a}}function lh(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 br(e){return e==="manual"}function nr(e,t,n,r={}){var u,d;const o=vr(ah,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!br(o.zIndexMode)?fs: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=At(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:lh(f,h),z:hs(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&&Er(h,t,n,r,i),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function uh(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 Er(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=vr(wr,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}uh(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*sh),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const d=i&&!br(c)?fs:0,{x:f,y:h,z:g}=dh(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 hs(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return br(n)?r:r+(e.selected?t:0)}function dh(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),l=At(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=hs(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function _r(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)??Nt(c),u=Ji(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(E=>E.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 fh(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=xr(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 N=t.get(g.parentId);N&&(x=Qi(x,v,N))}else p&&(x=We(x,p,v));const E={...g,measured:v,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:uo("source",h.nodeElement,b,d,g.id),target:uo("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,E),g.parentId&&Er(E,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:Nt(E,o)}))}}if(f.length>0){const h=_r(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function hh({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 xo(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 gs(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}`;xo("source",c,u,e,o,s),xo("target",c,l,e,i,a),t.set(r.id,r)}}function ps(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ps(n,t):!1}function wo(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 gh(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!ps(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 Ln({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 ph({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=Ot(i,t);return{x:s.x-i.x,y:s.y-i.y}}function mh({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:E,nodeId:N,nodeClickDistance:k=0}){f=ce(x);function M({x:L,y:P}){const{nodeLookup:y,nodeExtent:_,snapGrid:C,snapToGrid:A,nodeOrigin:$,onNodeDrag:T,onSelectionDrag:j,onError:F,updateNodePositions:H}=t();i={x:L,y:P};let V=!1;const Y=a.size>1,q=Y&&_?Jn(Tt(a)):null,J=Y&&A?ph({dragItems:a,snapGrid:C,x:L,y:P}):null;for(const[G,R]of a){if(!y.has(G))continue;let B={x:L-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)}:Ot(B,C));let K=null;if(Y&&_&&!R.extent&&q){const{positionAbsolute:Z}=R.internals,Q=Z.x-q.x+_[0][0],ee=Z.x+R.measured.width-q.x2+_[1][0],ne=Z.y-q.y+_[0][1],re=Z.y+R.measured.height-q.y2+_[1][1];K=[[Q,ne],[ee,re]]}const{position:U,positionAbsolute:X}=Zi({nodeId:G,nextPosition:B,nodeLookup:y,nodeExtent:K||_,nodeOrigin:$,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||!N&&j))){const[G,R]=Ln({nodeId:N,dragItems:a,nodeLookup:y});r==null||r(v,a,G,R),T==null||T(v,G,R),N||j==null||j(v,R)}}async function I(){if(!u)return;const{transform:L,panBy:P,autoPanSpeed:y,autoPanOnNodeDrag:_}=t();if(!_){c=!1,cancelAnimationFrame(s);return}const[C,A]=mr(l,u,y);(C!==0||A!==0)&&(i.x=(i.x??0)-C/L[2],i.y=(i.y??0)-A/L[2],await P({x:C,y:A})&&M(i)),s=requestAnimationFrame(I)}function z(L){var Y;const{nodeLookup:P,multiSelectionActive:y,nodesDraggable:_,transform:C,snapGrid:A,snapToGrid:$,selectNodesOnDrag:T,onNodeDragStart:j,onSelectionDragStart:F,unselectNodesAndEdges:H}=t();d=!0,(!T||!E)&&!y&&N&&((Y=P.get(N))!=null&&Y.selected||H()),E&&T&&N&&(e==null||e(N));const V=yt(L.sourceEvent,{transform:C,snapGrid:A,snapToGrid:$,containerBounds:u});if(i=V,a=gh(P,_,V,N),a.size>0&&(n||j||!N&&F)){const[q,J]=Ln({nodeId:N,dragItems:a,nodeLookup:P});n==null||n(L.sourceEvent,a,q,J),j==null||j(L.sourceEvent,q,J),N||F==null||F(L.sourceEvent,J)}}const O=Ti().clickDistance(k).on("start",L=>{const{domNode:P,nodeDragThreshold:y,transform:_,snapGrid:C,snapToGrid:A}=t();u=(P==null?void 0:P.getBoundingClientRect())||null,h=!1,g=!1,v=L.sourceEvent,y===0&&z(L),i=yt(L.sourceEvent,{transform:_,snapGrid:C,snapToGrid:A,containerBounds:u}),l=pe(L.sourceEvent,u)}).on("drag",L=>{const{autoPanOnNodeDrag:P,transform:y,snapGrid:_,snapToGrid:C,nodeDragThreshold:A,nodeLookup:$}=t(),T=yt(L.sourceEvent,{transform:y,snapGrid:_,snapToGrid:C,containerBounds:u});if(v=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||N&&!$.has(N))&&(h=!0),!h){if(!c&&P&&d&&(c=!0,I()),!d){const j=pe(L.sourceEvent,u),F=j.x-l.x,H=j.y-l.y;Math.sqrt(F*F+H*H)>A&&z(L)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&a&&d&&(l=pe(L.sourceEvent,u),M(T))}}).on("end",L=>{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:_,onSelectionDragStop:C}=t();if(g&&(y(a,!1),g=!1),o||_||!N&&C){const[A,$]=Ln({nodeId:N,dragItems:a,nodeLookup:P,dragging:!1});o==null||o(L.sourceEvent,a,A,$),_==null||_(L.sourceEvent,A,$),N||C==null||C(L.sourceEvent,$)}}}).filter(L=>{const P=L.target;return!L.button&&(!b||!wo(P,`.${b}`,x))&&(!p||wo(P,p,x))});f.call(O)}function m(){f==null||f.on(".drag",null)}return{update:w,destroy:m}}function yh(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())sn(o,Nt(i))>0&&r.push(i);return r}const xh=250;function wh(e,t,n,r){var a,c;let o=[],i=1/0;const s=yh(e,n,t+xh);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 ms(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 ys(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function vh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const xs=()=>!0;function bh(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=xs,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:E,autoPanSpeed:N,dragThreshold:k=1,handleDomNode:M}){const I=is(e.target);let z=0,O;const{x:L,y:P}=pe(e),y=ys(i,M),_=a==null?void 0:a.getBoundingClientRect();let C=!1;if(!_||!y)return;const A=ms(o,y,r,c,t);if(!A)return;let $=pe(e,_),T=!1,j=null,F=!1,H=null;function V(){if(!u||!_)return;const[U,X]=mr($,_,N);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:$,toHandle:null,toPosition:so[Y.position],toNode:null,pointer:$};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-L,be=ue-P;if(!(ve*ve+be*be>k*k))return;R()}if(!E()||!Y){K(U);return}const X=x();$=pe(U,_),O=wh(Pt($,X,!1,[1,1]),n,c,Y),T||(V(),T=!0);const Z=ws(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,j=Z.connection,F=vh(!!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?it({x:Z.toHandle.x,y:Z.toHandle.y},X):$,toHandle:Z.toHandle,toPosition:F&&Z.toHandle?Z.toHandle.position:so[Y.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:$};p(ne),G=ne}function K(U){if(!("touches"in U&&U.touches.length>0)){if(C){(O||H)&&j&&F&&(v==null||v(j));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,j=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 ws(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=xs,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=ys(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),E=w.classList.contains("connectable"),N=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=E&&N&&(n===rt.Strict?d&&b==="source"||!d&&b==="target":p!==r||x!==o);m.isValid=I&&l(k),m.toHandle=ms(p,b,x,u,n,!0)}return m}const rr={onPointerDown:bh,isValid:ws};function Eh({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(),E=p.sourceEvent.ctrlKey&&St()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*u,k=x[2]*Math.pow(2,N*E);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 E=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],N=[E[0]-v[0],E[1]-v[1]];v=E;const k=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),M={x:x[0]-N[0]*k,y:x[1]-N[1]*k},I=[[0,0],[c,l]];t.setViewportConstrained({x:M.x,y:M.y,zoom:x[2]},I,a)},b=Wi().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 wn=e=>({x:e.x,y:e.y,zoom:e.k}),$n=({x:e,y:t,zoom:n})=>mn.translate(e,t).scale(n),Le=(e,t)=>e.target.closest(`.${t}`),vs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),_h=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Dn=(e,t=0,n=_h,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},bs=e=>{const t=e.ctrlKey&&St()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Nh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Le(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=bs(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;!St()&&u.shiftKey&&o!==Ve.Vertical&&(h=u.deltaY*f,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const v=wn(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 Sh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=Le(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function Ch({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=wn(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 kh({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&vs(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,wn(i.transform)))}}function Mh({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&&vs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=wn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Ih({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"&&(Le(f,`${u}-flow__node`)||Le(f,`${u}-flow__edge`)||Le(f,`${u}-flow__selection`)||Le(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!v||Le(f,c)&&v||Le(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 Ah({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=Wi().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);x({x:o.x,y:o.y,zoom:ot(o.zoom,t,n)},[[0,0],[u.width,u.height]],r);const v=g.on("wheel.zoom"),w=g.on("dblclick.zoom");h.wheelDelta(bs);async function m(P,y){return g?new Promise(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?mt:Wt).transform(Dn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}function b({noWheelClassName:P,noPanClassName:y,onPaneContextMenu:_,userSelectionActive:C,panOnScroll:A,panOnDrag:$,panOnScrollMode:T,panOnScrollSpeed:j,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?Nh({zoomPanValues:l,noWheelClassName:P,d3Selection:g,d3Zoom:h,panOnScrollMode:T,panOnScrollSpeed:j,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Sh({noWheelClassName:P,preventScrolling:F,d3ZoomHandler:v});g.on("wheel.zoom",Z,{passive:!1});const Q=Ch({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",Q);const ee=kh({zoomPanValues:l,panOnDrag:$,onPaneContextMenu:!!_,onPanZoom:i,onTransformChange:R});h.on("zoom",ee);const ne=Mh({zoomPanValues:l,panOnDrag:$,panOnScroll:A,onPaneContextMenu:_,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=Ih({panActivationKeyPressed:q,zoomActivationKeyPressed:J,panOnDrag:$,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,_){const C=$n(P),A=h==null?void 0:h.constrain()(C,y,_);return A&&await m(A),A}async function E(P,y){const _=$n(P);return await m(_,y),_}function N(P){if(g){const y=$n(P),_=g.property("__zoom");(_.k!==P.zoom||_.x!==P.x||_.y!==P.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function k(){const P=g?Xi(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(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?mt:Wt).scaleTo(Dn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}async function I(P,y){return g?new Promise(_=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?mt:Wt).scaleBy(Dn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>_(!0)),P)}):!1}function z(P){h==null||h.scaleExtent(P)}function O(P){h==null||h.translateExtent(P)}function L(P){const y=!ge(P)||P<0?0:P;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:E,setViewportConstrained:x,getViewport:k,scaleTo:M,scaleBy:I,setScaleExtent:z,setTranslateExtent:O,syncViewport:N,setClickDistance:L}}var st;(function(e){e.Line="line",e.Handle="handle"})(st||(st={}));function Th({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 vo(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 Bt(e,t,n){return Math.max(0,t-e,e-n)}function bo(e,t){return e?!t:t}function Oh(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:E,height:N,aspectRatio:k}=e;let M=Math.floor(u?h-e.pointerX:0),I=Math.floor(d?g-e.pointerY:0);const z=E+(c?-M:M),O=N+(l?-I:I),L=-i[0]*E,P=-i[1]*N;let y=Bt(z,v,w),_=Bt(O,m,b);if(s){let $=0,T=0;c&&M<0?$=Oe(p+M+L,s[0][0]):!c&&M>0&&($=Pe(p+z+L,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,$),_=Math.max(_,T)}if(a){let $=0,T=0;c&&M>0?$=Pe(p+M,a[0][0]):!c&&M<0&&($=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,$),_=Math.max(_,T)}if(o){if(u){const $=Bt(z/k,m,b)*k;if(y=Math.max(y,$),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 $=Bt(O*k,v,w)/k;if(_=Math.max(_,$),s){let T=0;!c&&!l||l&&!c&&f?T=Pe(p+O*k+L,s[1][0])/k:T=Oe(p+(l?I:-I)*k+L,s[0][0])/k,_=Math.max(_,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,_=Math.max(_,T)}}}I=I+(I<0?_:-_),M=M+(M<0?y:-y),o&&(f?z>O*k?I=(bo(c,l)?-M:M)/k:M=(bo(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:E+(c?-M:M),height:N+(l?-I:I),x:i[0]*M*(c?-1:1)+C,y:i[1]*I*(l?-1:1)+A}}const Es={width:0,height:0,x:0,y:0},Ph={...Es,pointerX:0,pointerY:0,aspectRatio:1};function Lh(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 $h({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:vo("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={...Es},b={...Ph};s={boundaries:u,resizeDirection:f,keepAspectRatio:d,controlDirection:vo(l)};let p,x=null,E=[],N,k,M,I=!1;const z=Ti().on("start",O=>{const{nodeLookup:L,transform:P,snapGrid:y,snapToGrid:_,nodeOrigin:C,paneDomNode:A}=n();if(p=L.get(t),!p)return;x=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:$,ySnapped:T}=yt(O.sourceEvent,{transform:P,snapGrid:y,snapToGrid:_,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:$,pointerY:T,aspectRatio:m.width/m.height},N=void 0,k=Ge(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(N=L.get(p.parentId)),N&&p.extent==="parent"&&(k=[[0,0],[N.measured.width,N.measured.height]]),E=[],M=void 0;for(const[j,F]of L)if(F.parentId===t&&(E.push({id:j,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const H=Lh(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:L,snapGrid:P,snapToGrid:y,nodeOrigin:_}=n(),C=yt(O.sourceEvent,{transform:L,snapGrid:P,snapToGrid:y,containerBounds:x}),A=[];if(!p)return;const{x:$,y:T,width:j,height:F}=m,H={},V=p.origin??_,{width:Y,height:q,x:J,y:G}=Oh(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,V,k,M),R=Y!==j,B=q!==F,K=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,E.length>0)){const ee=J-$,ne=G-T;for(const re of E)re.position={x:re.position.x-ee+V[0]*(Y-j),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),N&&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=Th({width:m.width,prevWidth:j,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 Dh={},Eo=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:()=>{(Dh?"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},jh=e=>e?Eo(e):Eo,{useDebugValue:Rh}=Hc,{useSyncExternalStoreWithSelector:Hh}=Rc,zh=e=>e;function _s(e,t=zh,n){const r=Hh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Rh(r),r}const _o=(e,t)=>{const n=jh(e),r=(o,i=t)=>_s(n,o,i);return Object.assign(r,n),r},Fh=(e,t)=>e?_o(e,t):_o;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 vn=D.createContext(null),Bh=vn.Provider,Ns=me.error001("react");function te(e,t){const n=D.useContext(vn);if(n===null)throw new Error(Ns);return _s(n,e,t)}function oe(){const e=D.useContext(vn);if(e===null)throw new Error(Ns);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const No={display:"none"},Vh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ss="react-flow__node-desc",Cs="react-flow__edge-desc",Yh="react-flow__aria-live",Xh=e=>e.ariaLiveMessage,Wh=e=>e.ariaLabelConfig;function Gh({rfId:e}){const t=te(Xh);return S.jsx("div",{id:`${Yh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Vh,children:t})}function qh({rfId:e,disableKeyboardA11y:t}){const n=te(Wh);return S.jsxs(S.Fragment,{children:[S.jsx("div",{id:`${Ss}-${e}`,style:No,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),S.jsx("div",{id:`${Cs}-${e}`,style:No,children:n["edge.a11yDescription.default"]}),!t&&S.jsx(Gh,{rfId:e})]})}const bn=D.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return S.jsx("div",{className:se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});bn.displayName="Panel";const So="https://reactflow.dev?utm_source=attribution";function Kh({proOptions:e,position:t="bottom-right"}){return D.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:S.jsx(bn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${So}`,children:S.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Uh=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}},Vt=e=>e.id;function Zh(e,t){return ie(e.selectedNodes.map(Vt),t.selectedNodes.map(Vt))&&ie(e.selectedEdges.map(Vt),t.selectedEdges.map(Vt))}function Qh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=te(Uh,Zh);return D.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const Jh=e=>!!e.onSelectionChangeHandlers;function eg({onSelectionChange:e}){const t=te(Jh);return e||t?S.jsx(Qh,{onSelectionChange:e}):null}const ks=[0,0],tg={x:0,y:0,zoom:1},ng=["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"],Co=[...ng,"rfId"],rg=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}),ko={translateExtent:Et,nodeOrigin:ks,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function og(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(rg,ie),l=oe();D.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=ko,a()}),[]);const u=D.useRef(ko);return D.useEffect(()=>{for(const d of Co){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:qf(f)}):d==="fitView"?l.setState({fitViewQueued:f}):d==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[d]:f})))}u.current=e},Co.map(d=>e[d])),null}function Mo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function ig(e){var r;const[t,n]=D.useState(e==="system"?null:e);return D.useEffect(()=>{if(e!=="system"){n(e);return}const o=Mo(),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=Mo())!=null&&r.matches?"dark":"light"}const Io=typeof document<"u"?document:null;function Ct(e=null,t={target:Io,actInsideInputWithModifier:!0}){const[n,r]=D.useState(!1),o=D.useRef(!1),i=D.useRef(new Set([])),[s,a]=D.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace(/\+/g,`
|
|
17
17
|
`).replace(`
|
|
18
18
|
|
|
19
19
|
`,`
|
|
20
20
|
+`).split(`
|
|
21
|
-
`)),u=l.reduce((d,f)=>d.concat(...f),[]);return[l,u]}return[[],[]]},[e]);return j.useEffect(()=>{const c=(t==null?void 0:t.target)??Io,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const u=h=>{var w,m;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!l)&&ss(h))return!1;const v=To(h.code,a);if(i.current.add(h[v]),Ao(s,i.current,!1)){const b=((m=(w=h.composedPath)==null?void 0:w.call(h))==null?void 0:m[0])||h.target,p=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(o.current||!p)&&h.preventDefault(),r(!0)}},d=h=>{const g=To(h.code,a);Ao(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function Ao(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function To(e,t){return t.includes(e)?"code":"key"}const sg=()=>{const e=re();return j.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),c=yr(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},u=n.snapGrid??o,d=n.snapToGrid??i;return Pt(l,r,d,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=it(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function Ms(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of t){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const c of s)ag(c,a);n.push(a)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function ag(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function cg(e,t){return Ms(e,t)}function lg(e,t){return Ms(e,t)}function He(e,t){return{id:e,type:"select",selected:t}}function Qe(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(He(i.id,s)))}return r}function Oo({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const a=t.get(s.id),c=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Po(e){return{id:e.id,type:"remove"}}const ug=ns();function dg(e,t,n={}){return eh(e,t,{...n,onError:n.onError??ug})}const Lo=e=>zf(e),fg=e=>Zi(e);function Is(e){return j.forwardRef(e)}const As=typeof window<"u"?j.useLayoutEffect:j.useEffect;function $o(e){const[t,n]=j.useState(BigInt(0)),[r]=j.useState(()=>hg(()=>n(o=>o+BigInt(1))));return As(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function hg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ts=j.createContext(null);function gg({children:e}){const t=re(),n=j.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:u,onNodesChange:d,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let v=c;for(const m of a)v=typeof m=="function"?m(v):m;let w=Oo({items:v,lookup:f});for(const m of g.values())w=m(w);u&&l(v),w.length>0?d==null||d(w):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:b,setNodes:p}=t.getState();m&&p(b)})},[]),r=$o(n),o=j.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:u,onEdgesChange:d,edgeLookup:f}=t.getState();let h=c;for(const g of a)h=typeof g=="function"?g(h):g;u?l(h):d&&d(Oo({items:h,lookup:f}))},[]),i=$o(o),s=j.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return S.jsx(Ts.Provider,{value:s,children:e})}function pg(){const e=j.useContext(Ts);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const mg=e=>!!e.panZoom;function Nr(){const e=sg(),t=re(),n=pg(),r=ee(mg),o=j.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),s=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},c=d=>{var m,b;const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=Lo(d)?d:f.get(d.id),v=g.parentId?os(g.position,g.measured,g.parentId,f,h):g.position,w={...g,position:v,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return Nt(w)},l=(d,f,h={replace:!1})=>{s(g=>g.map(v=>{if(v.id===d){const w=typeof f=="function"?f(v):f;return h.replace&&Lo(w)?w:{...v,...w}}return v}))},u=(d,f,h={replace:!1})=>{a(g=>g.map(v=>{if(v.id===d){const w=typeof f=="function"?f(v):f;return h.replace&&fg(w)?w:{...v,...w}}return v}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var f;return(f=i(d))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(f=>({...f}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:s,setEdges:a,addNodes:d=>{const f=Array.isArray(d)?d:[d];n.nodeQueue.push(h=>[...h,...f])},addEdges:d=>{const f=Array.isArray(d)?d:[d];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:d=[],edges:f=[],transform:h}=t.getState(),[g,v,w]=h;return{nodes:d.map(m=>({...m})),edges:f.map(m=>({...m})),viewport:{x:g,y:v,zoom:w}}},deleteElements:async({nodes:d=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:m,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:x}=t.getState(),{nodes:E,edges:N}=await Yf({nodesToRemove:d,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:x}),M=N.length>0,C=E.length>0;if(M){const I=N.map(Po);w==null||w(N),b(I)}if(C){const I=E.map(Po);v==null||v(E),m(I)}return(C||M)&&(p==null||p({nodes:E,edges:N})),{deletedNodes:E,deletedEdges:N}},getIntersectingNodes:(d,f=!0,h)=>{const g=co(d),v=g?d:c(d),w=h!==void 0;return v?(h||t.getState().nodes).filter(m=>{const b=t.getState().nodeLookup.get(m.id);if(b&&!g&&(m.id===d.id||!b.internals.positionAbsolute))return!1;const p=Nt(w?m:b),x=sn(p,v);return f&&x>0||x>=p.width*p.height||x>=v.width*v.height}):[]},isNodeIntersecting:(d,f,h=!0)=>{const v=co(d)?d:c(d);if(!v)return!1;const w=sn(v,f);return h&&w>0||w>=f.width*f.height||w>=v.width*v.height},updateNode:l,updateNodeData:(d,f,h={replace:!1})=>{l(d,g=>{const v=typeof f=="function"?f(g):f;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},updateEdge:u,updateEdgeData:(d,f,h={replace:!1})=>{u(d,g=>{const v=typeof f=="function"?f(g):f;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},getNodesBounds:d=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return Hf(d,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:d,id:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${d}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:d,handleId:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${d?f?`-${d}-${f}`:`-${d}`:""}`))==null?void 0:g.values())??[])},fitView:async d=>{const f=t.getState().fitViewResolver??Gf();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return j.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const jo=e=>e.selected,yg=typeof window<"u"?window:void 0;function xg({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=re(),{deleteElements:r}=Nr(),o=kt(e,{actInsideInputWithModifier:!1}),i=kt(t,{target:yg});j.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter(jo),edges:s.filter(jo)}),n.setState({nodesSelectionActive:!1})}},[o]),j.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function wg(e){const t=re();j.useEffect(()=>{const n=()=>{var o,i,s,a;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=xr(e.current);(r.height===0||r.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",me.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const En={position:"absolute",width:"100%",height:"100%",top:0,left:0},vg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function bg({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:o,panOnScrollSpeed:i=.5,panOnScrollMode:s=Ve.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:g=!0,children:v,noWheelClassName:w,noPanClassName:m,onViewportChange:b,isControlledViewport:p,paneClickDistance:x,selectionOnDrag:E}){const N=re(),M=j.useRef(null),{userSelectionActive:C,lib:I,connectionInProgress:H}=ee(vg,ie),O=kt(h),L=j.useRef();wg(M);const P=j.useCallback(y=>{b==null||b({x:y[0],y:y[1],zoom:y[2]}),p||N.setState({transform:y})},[b,p]);return j.useEffect(()=>{if(M.current){L.current=Ah({domNode:M.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:A=>N.setState($=>$.paneDragging===A?$:{paneDragging:A}),onPanZoomStart:(A,$)=>{const{onViewportChangeStart:T,onMoveStart:D}=N.getState();D==null||D(A,$),T==null||T($)},onPanZoom:(A,$)=>{const{onViewportChange:T,onMove:D}=N.getState();D==null||D(A,$),T==null||T($)},onPanZoomEnd:(A,$)=>{const{onViewportChangeEnd:T,onMoveEnd:D}=N.getState();D==null||D(A,$),T==null||T($)}});const{x:y,y:_,zoom:k}=L.current.getViewport();return N.setState({panZoom:L.current,transform:[y,_,k],domNode:M.current.closest(".react-flow")}),()=>{var A;(A=L.current)==null||A.destroy()}}},[]),j.useEffect(()=>{var y;(y=L.current)==null||y.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:o,panOnScrollSpeed:i,panOnScrollMode:s,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:O,preventScrolling:g,noPanClassName:m,userSelectionActive:C,noWheelClassName:w,lib:I,onTransformChange:P,connectionInProgress:H,selectionOnDrag:E,paneClickDistance:x})},[e,t,n,r,o,i,s,a,c,O,g,m,C,w,I,P,H,E,x]),S.jsx("div",{className:"react-flow__renderer",ref:M,style:En,children:v})}const Eg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function _g(){const{userSelectionActive:e,userSelectionRect:t}=ee(Eg,ie);return e&&t?S.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Dn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Ng=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Sg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=_t.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:g,children:v}){const w=j.useRef(0),m=re(),{userSelectionActive:b,elementsSelectable:p,dragging:x,panBy:E,autoPanSpeed:N}=ee(Ng,ie),M=p&&(e||b),C=j.useRef(null),I=j.useRef(),H=j.useRef(new Set),O=j.useRef(new Set),L=j.useRef(!1),P=j.useRef(!1),y=j.useRef({x:0,y:0}),_=j.useRef(!1),k=R=>{if(P.current||L.current||m.getState().connection.inProgress){P.current=!1,L.current=!1;return}l==null||l(R),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},A=R=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){R.preventDefault();return}u==null||u(R)},$=d?R=>d(R):void 0,T=R=>{P.current&&(R.stopPropagation(),P.current=!1)},D=R=>{var oe,ue;if(R.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:B,transform:U}=m.getState();if(I.current=B==null?void 0:B.getBoundingClientRect(),!I.current)return;const Z=R.target===C.current;if(!Z&&!!R.target.closest(".nokey")||!e||!(s&&Z||t)||R.button!==0||!R.isPrimary)return;(ue=(oe=R.target)==null?void 0:oe.setPointerCapture)==null||ue.call(oe,R.pointerId),P.current=!1;const{x:J,y:te}=pe(R.nativeEvent,I.current),ne=Pt({x:J,y:te},U);m.setState({userSelectionRect:{width:0,height:0,startX:ne.x,startY:ne.y,x:J,y:te}}),Z||(R.stopPropagation(),R.preventDefault())};function F(R,B){const{userSelectionRect:U}=m.getState();if(!U)return;const{transform:Z,nodeLookup:W,edgeLookup:X,connectionLookup:J,triggerNodeChanges:te,triggerEdgeChanges:ne,defaultEdgeOptions:oe}=m.getState(),ue={x:U.startX,y:U.startY},{x:ve,y:be}=it(ue,Z),ke={startX:ue.x,startY:ue.y,x:R<ve?R:ve,y:B<be?B:be,width:Math.abs(R-ve),height:Math.abs(B-be)},lt=H.current,De=O.current;H.current=new Set(pr(W,ke,Z,n===_t.Partial,!0).map(de=>de.id)),O.current=new Set;const Re=(oe==null?void 0:oe.selectable)??!0;for(const de of H.current){const Ce=J.get(de);if(Ce)for(const{edgeId:Me}of Ce.values()){const ze=X.get(Me);ze&&(ze.selectable??Re)&&O.current.add(Me)}}if(!lo(lt,H.current)){const de=Qe(W,H.current,!0);te(de)}if(!lo(De,O.current)){const de=Qe(X,O.current);ne(de)}m.setState({userSelectionRect:ke,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!o||!I.current)return;const[R,B]=mr(y.current,I.current,N);E({x:R,y:B}).then(U=>{if(!P.current||!U){w.current=requestAnimationFrame(z);return}const{x:Z,y:W}=y.current;F(Z,W),w.current=requestAnimationFrame(z)})}const V=()=>{cancelAnimationFrame(w.current),w.current=0,_.current=!1};j.useEffect(()=>()=>V(),[]);const Y=R=>{const{userSelectionRect:B,transform:U,resetSelectedElements:Z}=m.getState();if(!I.current||!B)return;const{x:W,y:X}=pe(R.nativeEvent,I.current);y.current={x:W,y:X};const J=it({x:B.startX,y:B.startY},U);if(!P.current){const te=t?0:i;if(Math.hypot(W-J.x,X-J.y)<=te)return;Z(),a==null||a(R)}P.current=!0,_.current||(z(),_.current=!0),F(W,X)},K=R=>{var B,U;if(!M){R.target===C.current&&m.getState().connection.inProgress&&(L.current=!0);return}R.button===0&&((U=(B=R.target)==null?void 0:B.releasePointerCapture)==null||U.call(B,R.pointerId),!b&&R.target===C.current&&m.getState().userSelectionRect&&(k==null||k(R)),m.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(c==null||c(R),m.setState({nodesSelectionActive:H.current.size>0})),V())},Q=R=>{var B,U;(U=(B=R.target)==null?void 0:B.releasePointerCapture)==null||U.call(B,R.pointerId),V()},q=r===!0||Array.isArray(r)&&r.includes(0);return S.jsxs("div",{className:se(["react-flow__pane",{draggable:q,dragging:x,selection:e}]),onClick:M?void 0:Dn(k,C),onContextMenu:Dn(A,C),onWheel:Dn($,C),onPointerEnter:M?void 0:f,onPointerMove:M?Y:h,onPointerUp:K,onPointerCancel:M?Q:void 0,onPointerDownCapture:M?D:void 0,onClickCapture:M?T:void 0,onPointerLeave:g,ref:C,style:En,children:[v,S.jsx(_g,{})]})}function or({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",me.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):o([e])}function Os({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=re(),[c,l]=j.useState(!1),u=j.useRef();return j.useEffect(()=>{if(!t)return u.current=mh({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{or({id:d,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{var d;(d=u.current)==null||d.destroy(),u.current=void 0}},[t,a,e]),j.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s})},[n,r,t,i,e,o,s]),c}const kg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ps(){const e=re();return j.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:u}=e.getState(),d=new Map,f=kg(s),h=o?i[0]:5,g=o?i[1]:5,v=n.direction.x*h*n.factor,w=n.direction.y*g*n.factor;for(const[,m]of l){if(!f(m))continue;let b={x:m.internals.positionAbsolute.x+v,y:m.internals.positionAbsolute.y+w};o&&(b=Ot(b,i));const{position:p,positionAbsolute:x}=Qi({nodeId:m.id,nextPosition:b,nodeLookup:l,nodeExtent:r,nodeOrigin:u,onError:a});m.position=p,m.internals.positionAbsolute=x,d.set(m.id,m)}c(d)},[])}const Sr=j.createContext(null),Cg=Sr.Provider;Sr.Consumer;const Ls=()=>j.useContext(Sr),Mg=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),$s=j.createContext(null);function Ig({children:e}){const t=ee(Mg,ie);return S.jsx($s.Provider,{value:t,children:e})}function Ag(){const e=j.useContext($s);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Tg={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Og=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:c,isValid:l}=s;if(!a&&!o)return Tg;const u=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:u,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===rt.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:u&&l}};function Pg({type:e="source",position:t=G.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},h){var _,k;const g=s||null,v=e==="target",w=re(),m=Ls(),{connectOnClick:b,noPanClassName:p,rfId:x}=Ag(),{connectingFrom:E,connectingTo:N,clickConnecting:M,isPossibleEndHandle:C,connectionInProcess:I,clickConnectionInProcess:H,valid:O}=ee(Og(m,g,e),ie);m||(k=(_=w.getState()).onError)==null||k.call(_,"010",me.error010());const L=A=>{const{defaultEdgeOptions:$,onConnect:T,hasDefaultEdges:D}=w.getState(),F={...$,...A};if(D){const{edges:z,setEdges:V,onError:Y}=w.getState();V(dg(F,z,{onError:Y}))}T==null||T(F),a==null||a(F)},P=A=>{if(!m)return;const $=as(A.nativeEvent);if(o&&($&&A.button===0||!$)){const T=w.getState();rr.onPointerDown(A.nativeEvent,{handleDomNode:A.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:v,handleId:g,nodeId:m,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...D)=>{var F,z;return(z=(F=w.getState()).onConnectEnd)==null?void 0:z.call(F,...D)},updateConnection:T.updateConnection,onConnect:L,isValidConnection:n||((...D)=>{var F,z;return((z=(F=w.getState()).isValidConnection)==null?void 0:z.call(F,...D))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}$?u==null||u(A):d==null||d(A)},y=A=>{const{onClickConnectStart:$,onClickConnectEnd:T,connectionClickStartHandle:D,connectionMode:F,isValidConnection:z,lib:V,rfId:Y,nodeLookup:K,connection:Q}=w.getState();if(!m||!D&&!o)return;if(!D){$==null||$(A.nativeEvent,{nodeId:m,handleId:g,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:m,type:e,id:g}});return}const q=is(A.target),R=n||z,{connection:B,isValid:U}=rr.isValid(A.nativeEvent,{handle:{nodeId:m,id:g,type:e},connectionMode:F,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:R,flowId:Y,doc:q,lib:V,nodeLookup:K});U&&B&&L(B);const Z=structuredClone(Q);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,T==null||T(A,Z),w.setState({connectionClickStartHandle:null})};return S.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":t,"data-id":`${x}-${m}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,l,{source:!v,target:v,connectable:r,connectablestart:o,connectableend:i,clickconnecting:M,connectingfrom:E,connectingto:N,valid:O,connectionindicator:r&&(!I||C)&&(I||H?i:o)}]),onMouseDown:P,onTouchStart:P,onClick:b?y:void 0,ref:h,...f,children:c})}const an=j.memo(Is(Pg));function Lg({data:e,isConnectable:t,sourcePosition:n=G.Bottom}){return S.jsxs(S.Fragment,{children:[e==null?void 0:e.label,S.jsx(an,{type:"source",position:n,isConnectable:t})]})}function $g({data:e,isConnectable:t,targetPosition:n=G.Top,sourcePosition:r=G.Bottom}){return S.jsxs(S.Fragment,{children:[S.jsx(an,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,S.jsx(an,{type:"source",position:r,isConnectable:t})]})}function jg(){return null}function Dg({data:e,isConnectable:t,targetPosition:n=G.Top}){return S.jsxs(S.Fragment,{children:[S.jsx(an,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const cn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Do={input:Lg,default:$g,output:Dg,group:jg};function Rg(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const zg=e=>{const{width:t,height:n,x:r,y:o}=Tt(e.nodeLookup,{filter:i=>!!i.selected});return{width:ge(t)?t:null,height:ge(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function Hg({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=re(),{width:o,height:i,transformString:s,userSelectionActive:a}=ee(zg,ie),c=Ps(),l=j.useRef(null);j.useEffect(()=>{var h;n||(h=l.current)==null||h.focus({preventScroll:!0})},[n]);const u=!a&&o!==null&&i!==null;if(Os({nodeRef:l,disabled:!u}),!u)return null;const d=e?h=>{const g=r.getState().nodes.filter(v=>v.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(cn,h.key)&&(h.preventDefault(),c({direction:cn[h.key],factor:h.shiftKey?4:1}))};return S.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:S.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const Ro=typeof window<"u"?window:void 0,Fg=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function js({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:v,zoomActivationKeyCode:w,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:x,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:M,panOnDrag:C,autoPanOnSelection:I,defaultViewport:H,translateExtent:O,minZoom:L,maxZoom:P,preventScrolling:y,onSelectionContextMenu:_,noWheelClassName:k,noPanClassName:A,disableKeyboardA11y:$,onViewportChange:T,isControlledViewport:D}){const{nodesSelectionActive:F,userSelectionActive:z}=ee(Fg,ie),V=kt(l,{target:Ro}),Y=kt(v,{target:Ro}),K=Y||C,Q=Y||x,q=u&&K!==!0,R=V||z||q;return xg({deleteKeyCode:c,multiSelectionKeyCode:g}),S.jsx(bg,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:Q,panActivationKeyPressed:Y,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:M,panOnDrag:!V&&K,defaultViewport:H,translateExtent:O,minZoom:L,maxZoom:P,zoomActivationKeyCode:w,preventScrolling:y,noWheelClassName:k,noPanClassName:A,onViewportChange:T,isControlledViewport:D,paneClickDistance:a,selectionOnDrag:q,children:S.jsxs(Sg,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:K,autoPanOnSelection:I,isSelecting:!!R,selectionMode:d,selectionKeyPressed:V,paneClickDistance:a,selectionOnDrag:q,children:[e,F&&S.jsx(Hg,{onSelectionContextMenu:_,noPanClassName:A,disableKeyboardA11y:$})]})})}js.displayName="FlowRenderer";const Bg=j.memo(js),Vg=e=>t=>e?pr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function Yg(e){return ee(j.useCallback(Vg(e),[e]),ie)}const Xg=e=>e.updateNodeInternals;function Wg(){const e=ee(Xg),[t]=j.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return j.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Gg({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=re(),i=j.useRef(null),s=j.useRef(null),a=j.useRef(e.sourcePosition),c=j.useRef(e.targetPosition),l=j.useRef(t),u=n&&!!e.internals.handleBounds;return j.useEffect(()=>{i.current&&!e.hidden&&(!u||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[u,e.hidden]),j.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),j.useEffect(()=>{if(i.current){const d=l.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(d||f||h)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function qg({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:v,nodeTypes:w,nodeClickDistance:m,onError:b}){const{node:p,internals:x,isParent:E}=ee(R=>{const B=R.nodeLookup.get(e),U=R.parentLookup.has(e);return{node:B,internals:B.internals,isParent:U}},ie);let N=p.type||"default",M=(w==null?void 0:w[N])||Do[N];M===void 0&&(b==null||b("003",me.error003(N)),N="default",M=(w==null?void 0:w.default)||Do.default);const C=!!(p.draggable||a&&typeof p.draggable>"u"),I=!!(p.selectable||c&&typeof p.selectable>"u"),H=!!(p.connectable||l&&typeof p.connectable>"u"),O=!!(p.focusable||u&&typeof p.focusable>"u"),L=re(),P=rs(p),y=Gg({node:p,nodeType:N,hasDimensions:P,resizeObserver:d}),_=Os({nodeRef:y,disabled:p.hidden||!C,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:m}),k=Ps();if(p.hidden)return null;const A=xe(p),$=Rg(p),T=I||C||t||n||r||o,D=n?R=>n(R,{...x.userNode}):void 0,F=r?R=>r(R,{...x.userNode}):void 0,z=o?R=>o(R,{...x.userNode}):void 0,V=i?R=>i(R,{...x.userNode}):void 0,Y=s?R=>s(R,{...x.userNode}):void 0,K=R=>{const{selectNodesOnDrag:B,nodeDragThreshold:U}=L.getState();I&&(!B||!C||U>0)&&or({id:e,store:L,nodeRef:y}),t&&t(R,{...x.userNode})},Q=R=>{if(!(ss(R.nativeEvent)||g)){if(Gi.includes(R.key)&&I){const B=R.key==="Escape";or({id:e,store:L,unselect:B,nodeRef:y})}else if(C&&p.selected&&Object.prototype.hasOwnProperty.call(cn,R.key)){R.preventDefault();const{ariaLabelConfig:B}=L.getState();L.setState({ariaLiveMessage:B["node.a11yDescription.ariaLiveMessage"]({direction:R.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),k({direction:cn[R.key],factor:R.shiftKey?4:1})}}},q=()=>{var J;if(g||!((J=y.current)!=null&&J.matches(":focus-visible")))return;const{transform:R,width:B,height:U,autoPanOnNodeFocus:Z,setCenter:W}=L.getState();if(!Z)return;pr(new Map([[e,p]]),{x:0,y:0,width:B,height:U},R,!0).length>0||W(p.position.x+A.width/2,p.position.y+A.height/2,{zoom:R[2]})};return S.jsx("div",{className:se(["react-flow__node",`react-flow__node-${N}`,{[h]:C},p.className,{selected:p.selected,selectable:I,parent:E,draggable:C,dragging:_}]),ref:y,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:P?"visible":"hidden",...p.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:F,onMouseLeave:z,onContextMenu:V,onClick:K,onDoubleClick:Y,onKeyDown:O?Q:void 0,tabIndex:O?0:void 0,onFocus:O?q:void 0,role:p.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Ss}-${v}`,"aria-label":p.ariaLabel,...p.domAttributes,children:S.jsx(Cg,{value:e,children:S.jsx(M,{id:e,data:p.data,type:N,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:p.selected??!1,selectable:I,draggable:C,deletable:p.deletable??!0,isConnectable:H,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:_,dragHandle:p.dragHandle,zIndex:x.z,parentId:p.parentId,...A})})})}var Kg=j.memo(qg);const Ug=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ds(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:o}=ee(Ug,ie),i=Yg(e.onlyRenderVisibleElements),s=Wg();return S.jsx("div",{className:"react-flow__nodes",style:En,children:i.map(a=>S.jsx(Kg,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},a))})}Ds.displayName="NodeRenderer";const Zg=j.memo(Ds);function Qg(e){return ee(j.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&Zf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),ie)}const Jg=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return S.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},ep=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return S.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},zo={[rn.Arrow]:Jg,[rn.ArrowClosed]:ep};function tp(e){const t=re();return j.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(zo,e)?zo[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",me.error009(e)),null)},[e])}const np=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=tp(t);return c?S.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:S.jsx(c,{color:n,strokeWidth:s})}):null},Rs=({defaultColor:e,rfId:t})=>{const n=ee(i=>i.edges),r=ee(i=>i.defaultEdgeOptions),o=j.useMemo(()=>ih(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?S.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:S.jsx("defs",{children:o.map(i=>S.jsx(np,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Rs.displayName="MarkerDefinitions";var rp=j.memo(Rs);function zs({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u}){const[d,f]=j.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",l]),g=j.useRef(null);return j.useEffect(()=>{if(g.current){const v=g.current.getBBox();f({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?S.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:h,visibility:d.width?"visible":"hidden",...u,children:[o&&S.jsx("rect",{width:d.width+2*s[0],x:-s[0],y:-s[1],height:d.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),S.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}zs.displayName="EdgeText";const op=j.memo(zs);function _n({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return S.jsxs(S.Fragment,{children:[S.jsx("path",{...u,d:e,fill:"none",className:se(["react-flow__edge-path",u.className])}),l?S.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,r&&ge(t)&&ge(n)?S.jsx(op,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function Ho({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===G.Left||e===G.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Hs({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:o,targetPosition:i=G.Top}){const[s,a]=Ho({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,l]=Ho({pos:i,x1:r,y1:o,x2:e,y2:t}),[u,d,f,h]=cs({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${s},${a} ${c},${l} ${r},${o}`,u,d,f,h]}function Fs(e){return j.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:m})=>{const[b,p,x]=Hs({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),E=e.isInternal?void 0:t;return S.jsx(_n,{id:E,path:b,labelX:p,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:m})})}const ip=Fs({isInternal:!1}),Bs=Fs({isInternal:!0});ip.displayName="SimpleBezierEdge";Bs.displayName="SimpleBezierEdgeInternal";function Vs(e){return j.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:h=G.Bottom,targetPosition:g=G.Top,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:b})=>{const[p,x,E]=er({sourceX:n,sourceY:r,sourcePosition:h,targetX:o,targetY:i,targetPosition:g,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset,stepPosition:m==null?void 0:m.stepPosition}),N=e.isInternal?void 0:t;return S.jsx(_n,{id:N,path:p,labelX:x,labelY:E,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:v,markerStart:w,interactionWidth:b})})}const Ys=Vs({isInternal:!1}),Xs=Vs({isInternal:!0});Ys.displayName="SmoothStepEdge";Xs.displayName="SmoothStepEdgeInternal";function Ws(e){return j.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return S.jsx(Ys,{...n,id:r,pathOptions:j.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const sp=Ws({isInternal:!1}),Gs=Ws({isInternal:!0});sp.displayName="StepEdge";Gs.displayName="StepEdgeInternal";function qs(e){return j.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})=>{const[w,m,b]=ds({sourceX:n,sourceY:r,targetX:o,targetY:i}),p=e.isInternal?void 0:t;return S.jsx(_n,{id:p,path:w,labelX:m,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}const ap=qs({isInternal:!1}),Ks=qs({isInternal:!0});ap.displayName="StraightEdge";Ks.displayName="StraightEdgeInternal";function Us(e){return j.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=G.Bottom,targetPosition:a=G.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:b})=>{const[p,x,E]=ls({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),N=e.isInternal?void 0:t;return S.jsx(_n,{id:N,path:p,labelX:x,labelY:E,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:b})})}const cp=Us({isInternal:!1}),Zs=Us({isInternal:!0});cp.displayName="BezierEdge";Zs.displayName="BezierEdgeInternal";const Fo={default:Zs,straight:Ks,step:Gs,smoothstep:Xs,simplebezier:Bs},Bo={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},lp=(e,t,n)=>n===G.Left?e-t:n===G.Right?e+t:e,up=(e,t,n)=>n===G.Top?e-t:n===G.Bottom?e+t:e,Vo="react-flow__edgeupdater";function Yo({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a}){return S.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:se([Vo,`${Vo}-${a}`]),cx:lp(t,r,e),cy:up(n,r,e),r,stroke:"transparent",fill:"transparent"})}function dp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:h}){const g=re(),v=(x,E)=>{if(x.button!==0)return;const{autoPanOnConnect:N,domNode:M,connectionMode:C,connectionRadius:I,lib:H,onConnectStart:O,cancelConnection:L,nodeLookup:P,rfId:y,panBy:_,updateConnection:k}=g.getState(),A=E.type==="target",$=(F,z)=>{f(!1),d==null||d(F,n,E.type,z)},T=F=>l==null?void 0:l(n,F),D=(F,z)=>{f(!0),u==null||u(x,n,E.type),O==null||O(F,z)};rr.onPointerDown(x.nativeEvent,{autoPanOnConnect:N,connectionMode:C,connectionRadius:I,domNode:M,handleId:E.id,nodeId:E.nodeId,nodeLookup:P,isTarget:A,edgeUpdaterType:E.type,lib:H,flowId:y,cancelConnection:L,panBy:_,isValidConnection:(...F)=>{var z,V;return((V=(z=g.getState()).isValidConnection)==null?void 0:V.call(z,...F))??!0},onConnect:T,onConnectStart:D,onConnectEnd:(...F)=>{var z,V;return(V=(z=g.getState()).onConnectEnd)==null?void 0:V.call(z,...F)},onReconnectEnd:$,updateConnection:k,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},w=x=>v(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=x=>v(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),p=()=>h(!1);return S.jsxs(S.Fragment,{children:[(e===!0||e==="source")&&S.jsx(Yo,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&S.jsx(Yo,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function fp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:v,noPanClassName:w,onError:m,disableKeyboardA11y:b}){let p=ee(W=>W.edgeLookup.get(e));const x=ee(W=>W.defaultEdgeOptions);p=x?{...x,...p}:p;let E=p.type||"default",N=(v==null?void 0:v[E])||Fo[E];N===void 0&&(m==null||m("011",me.error011(E)),E="default",N=(v==null?void 0:v.default)||Fo.default);const M=!!(p.focusable||t&&typeof p.focusable>"u"),C=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),I=!!(p.selectable||r&&typeof p.selectable>"u"),H=j.useRef(null),[O,L]=j.useState(!1),[P,y]=j.useState(!1),_=re(),{zIndex:k=p.zIndex,sourceX:A,sourceY:$,targetX:T,targetY:D,sourcePosition:F,targetPosition:z}=ee(j.useCallback(W=>{const X=W.nodeLookup.get(p.source),J=W.nodeLookup.get(p.target);if(!X||!J)return Bo;const te=oh({id:e,sourceNode:X,targetNode:J,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:W.connectionMode,onError:m}),ne=Uf({selected:p.selected,zIndex:p.zIndex,sourceNode:X,targetNode:J,elevateOnSelect:W.elevateEdgesOnSelect,zIndexMode:W.zIndexMode});return{...te||Bo,zIndex:ne}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex,m]),ie),V=j.useMemo(()=>p.markerStart?`url('#${tr(p.markerStart,g)}')`:void 0,[p.markerStart,g]),Y=j.useMemo(()=>p.markerEnd?`url('#${tr(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||A===null||$===null||T===null||D===null)return null;const K=W=>{var ne;const{addSelectedEdges:X,unselectNodesAndEdges:J,multiSelectionActive:te}=_.getState();I&&(_.setState({nodesSelectionActive:!1}),p.selected&&te?(J({nodes:[],edges:[p]}),(ne=H.current)==null||ne.blur()):X([e])),o&&o(W,p)},Q=i?W=>{i(W,{...p})}:void 0,q=s?W=>{s(W,{...p})}:void 0,R=a?W=>{a(W,{...p})}:void 0,B=c?W=>{c(W,{...p})}:void 0,U=l?W=>{l(W,{...p})}:void 0,Z=W=>{var X;if(!b&&Gi.includes(W.key)&&I){const{unselectNodesAndEdges:J,addSelectedEdges:te}=_.getState();W.key==="Escape"?((X=H.current)==null||X.blur(),J({edges:[p]})):te([e])}};return S.jsx("svg",{style:{zIndex:k},children:S.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${E}`,p.className,w,{selected:p.selected,animated:p.animated,inactive:!I&&!o,updating:O,selectable:I}]),onClick:K,onDoubleClick:Q,onContextMenu:q,onMouseEnter:R,onMouseMove:B,onMouseLeave:U,onKeyDown:M?Z:void 0,tabIndex:M?0:void 0,role:p.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":M?`${ks}-${g}`:void 0,ref:H,...p.domAttributes,children:[!P&&S.jsx(N,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:I,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:A,sourceY:$,targetX:T,targetY:D,sourcePosition:F,targetPosition:z,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:V,markerEnd:Y,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),C&&S.jsx(dp,{edge:p,isReconnectable:C,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:h,sourceX:A,sourceY:$,targetX:T,targetY:D,sourcePosition:F,targetPosition:z,setUpdateHover:L,setReconnecting:y})]})})}var hp=j.memo(fp);const gp=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Qs({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:v}){const{edgesFocusable:w,edgesReconnectable:m,elementsSelectable:b,onError:p}=ee(gp,ie),x=Qg(t);return S.jsxs("div",{className:"react-flow__edges",children:[S.jsx(rp,{defaultColor:e,rfId:n}),x.map(E=>S.jsx(hp,{id:E,edgesFocusable:w,edgesReconnectable:m,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:v},E))]})}Qs.displayName="EdgeRenderer";const pp=j.memo(Qs),Xo=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function mp({children:e}){const t=re(),n=j.useRef(null),[r]=j.useState(()=>t.getState().transform);return As(()=>{let o=null;const i=()=>{const s=t.getState().transform;o&&s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]||(o=s,n.current&&(n.current.style.transform=Xo(s)))};return i(),t.subscribe(i)},[t]),S.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Xo(r)},children:e})}function yp(e){const t=Nr(),n=j.useRef(!1);j.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const xp=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function wp(e){const t=ee(xp),n=re();return j.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function vp(e){return e.connection.inProgress?{...e.connection,to:Pt(e.connection.to,e.transform)}:{...e.connection}}function bp(e){return vp}function Ep(e){const t=bp();return ee(t,ie)}const _p=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Np({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:c}=ee(_p,ie);return!(i&&o&&c)?null:S.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:S.jsx("g",{className:se(["react-flow__connection",Ui(a)]),children:S.jsx(Js,{style:t,type:n,CustomComponent:r,isValid:a})})})}const Js=({style:e,type:t=$e.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:h}=Ep();if(!o)return;if(n)return S.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Ui(r),toNode:u,toHandle:d,pointer:h});let g="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case $e.Bezier:[g]=ls(v);break;case $e.SimpleBezier:[g]=Hs(v);break;case $e.Step:[g]=er({...v,borderRadius:0});break;case $e.SmoothStep:[g]=er(v);break;default:[g]=ds(v)}return S.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Js.displayName="ConnectionLine";const Sp={};function Wo(e=Sp){j.useRef(e),re(),j.useEffect(()=>{},[e])}function kp(){re(),j.useRef(!1),j.useEffect(()=>{},[])}function ea({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:m,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:M,deleteKeyCode:C,onlyRenderVisibleElements:I,elementsSelectable:H,defaultViewport:O,translateExtent:L,minZoom:P,maxZoom:y,preventScrolling:_,defaultMarkerColor:k,zoomOnScroll:A,zoomOnPinch:$,panOnScroll:T,panOnScrollSpeed:D,panOnScrollMode:F,zoomOnDoubleClick:z,panOnDrag:V,autoPanOnSelection:Y,onPaneClick:K,onPaneMouseEnter:Q,onPaneMouseMove:q,onPaneMouseLeave:R,onPaneScroll:B,onPaneContextMenu:U,paneClickDistance:Z,nodeClickDistance:W,onEdgeContextMenu:X,onEdgeMouseEnter:J,onEdgeMouseMove:te,onEdgeMouseLeave:ne,reconnectRadius:oe,onReconnect:ue,onReconnectStart:ve,onReconnectEnd:be,noDragClassName:ke,noWheelClassName:lt,noPanClassName:De,disableKeyboardA11y:Re,nodeExtent:de,rfId:Ce,viewport:Me,onViewportChange:ze,nodesDraggable:kn}){return Wo(e),Wo(t),kp(),yp(n),wp(Me),S.jsx(Bg,{onPaneClick:K,onPaneMouseEnter:Q,onPaneMouseMove:q,onPaneMouseLeave:R,onPaneContextMenu:U,onPaneScroll:B,paneClickDistance:Z,deleteKeyCode:C,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:M,elementsSelectable:H,zoomOnScroll:A,zoomOnPinch:$,zoomOnDoubleClick:z,panOnScroll:T,panOnScrollSpeed:D,panOnScrollMode:F,panOnDrag:V,autoPanOnSelection:Y,defaultViewport:O,translateExtent:L,minZoom:P,maxZoom:y,onSelectionContextMenu:d,preventScrolling:_,noDragClassName:ke,noWheelClassName:lt,noPanClassName:De,disableKeyboardA11y:Re,onViewportChange:ze,isControlledViewport:!!Me,children:S.jsxs(mp,{children:[S.jsx(pp,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:ue,onReconnectStart:ve,onReconnectEnd:be,onlyRenderVisibleElements:I,onEdgeContextMenu:X,onEdgeMouseEnter:J,onEdgeMouseMove:te,onEdgeMouseLeave:ne,reconnectRadius:oe,defaultMarkerColor:k,noPanClassName:De,disableKeyboardA11y:Re,rfId:Ce}),S.jsx(Np,{style:v,type:g,component:w,containerStyle:m}),S.jsx("div",{className:"react-flow__edgelabel-renderer"}),S.jsx(Zg,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:W,onlyRenderVisibleElements:I,noPanClassName:De,noDragClassName:ke,disableKeyboardA11y:Re,nodeExtent:de,rfId:Ce,nodesDraggable:kn}),S.jsx("div",{className:"react-flow__viewport-portal"})]})})}ea.displayName="GraphView";const Cp=j.memo(ea),Mp=ns(),Go=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,v=new Map,w=new Map,m=r??t??[],b=n??e??[],p=u??[0,0],x=d??Et;gs(v,w,m);const{nodesInitialized:E}=nr(b,h,g,{nodeOrigin:p,nodeExtent:x,zIndexMode:f});let N=[0,0,1];if(s&&o&&i){const M=Tt(h,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:C,y:I,zoom:H}=yr(M,o,i,c,l,(a==null?void 0:a.padding)??.1);N=[C,I,H]}return{rfId:"1",width:o??0,height:i??0,transform:N,nodes:b,nodesInitialized:E,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Et,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:rt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...Ki},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Mp,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:qi,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Ip=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>Fh((h,g)=>{async function v(){const{nodeLookup:w,panZoom:m,fitViewOptions:b,fitViewResolver:p,width:x,height:E,minZoom:N,maxZoom:M}=g();m&&(await Vf({nodes:w,width:x,height:E,panZoom:m,minZoom:N,maxZoom:M},b),p==null||p.resolve(!0),h({fitViewResolver:null}))}return{...Go({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:w=>{const{nodeLookup:m,parentLookup:b,nodeOrigin:p,nodeExtent:x,elevateNodesOnSelect:E,fitViewQueued:N,zIndexMode:M,nodesSelectionActive:C}=g(),{nodesInitialized:I,hasSelectedNodes:H}=nr(w,m,b,{nodeOrigin:p,nodeExtent:x,elevateNodesOnSelect:E,checkEquality:!0,zIndexMode:M}),O=C&&H;N&&I?(v(),h({nodes:w,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):h({nodes:w,nodesInitialized:I,nodesSelectionActive:O})},setEdges:w=>{const{connectionLookup:m,edgeLookup:b}=g();gs(m,b,w),h({edges:w})},setDefaultNodesAndEdges:(w,m)=>{if(w){const{setNodes:b}=g();b(w),h({hasDefaultNodes:!0})}if(m){const{setEdges:b}=g();b(m),h({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:m,nodeLookup:b,parentLookup:p,domNode:x,nodeOrigin:E,nodeExtent:N,debug:M,fitViewQueued:C,zIndexMode:I}=g(),{changes:H,updatedInternals:O}=fh(w,b,p,x,E,N,I);O&&(ch(b,p,{nodeOrigin:E,nodeExtent:N,zIndexMode:I}),C?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(H==null?void 0:H.length)>0&&(M&&console.log("React Flow: trigger node changes",H),m==null||m(H)))},updateNodePositions:(w,m=!1)=>{const b=[];let p=[];const{nodeLookup:x,triggerNodeChanges:E,connection:N,updateConnection:M,onNodesChangeMiddlewareMap:C}=g();for(const[I,H]of w){const O=x.get(I),L=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(H!=null&&H.position)),P={id:I,type:"position",position:L?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:m};if(O&&N.inProgress&&N.fromNode.id===O.id){const y=qe(O,N.fromHandle,G.Left,!0);M({...N,from:y})}L&&O.parentId&&b.push({id:I,parentId:O.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),p.push(P)}if(b.length>0){const{parentLookup:I,nodeOrigin:H}=g(),O=_r(b,x,I,H);p.push(...O)}for(const I of C.values())p=I(p);E(p)},triggerNodeChanges:w=>{const{onNodesChange:m,setNodes:b,nodes:p,hasDefaultNodes:x,debug:E}=g();if(w!=null&&w.length){if(x){const N=cg(w,p);b(N)}E&&console.log("React Flow: trigger node changes",w),m==null||m(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:m,setEdges:b,edges:p,hasDefaultEdges:x,debug:E}=g();if(w!=null&&w.length){if(x){const N=lg(w,p);b(N)}E&&console.log("React Flow: trigger edge changes",w),m==null||m(w)}},addSelectedNodes:w=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:E}=g();if(m){const N=w.map(M=>He(M,!0));x(N);return}x(Qe(p,new Set([...w]),!0)),E(Qe(b))},addSelectedEdges:w=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:E}=g();if(m){const N=w.map(M=>He(M,!0));E(N);return}E(Qe(b,new Set([...w]))),x(Qe(p,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:m}={})=>{const{edges:b,nodes:p,nodeLookup:x,triggerNodeChanges:E,triggerEdgeChanges:N}=g(),M=w||p,C=m||b,I=[];for(const O of M){if(!O.selected)continue;const L=x.get(O.id);L&&(L.selected=!1),I.push(He(O.id,!1))}const H=[];for(const O of C)O.selected&&H.push(He(O.id,!1));E(I),N(H)},setMinZoom:w=>{const{panZoom:m,maxZoom:b}=g();m==null||m.setScaleExtent([w,b]),h({minZoom:w})},setMaxZoom:w=>{const{panZoom:m,minZoom:b}=g();m==null||m.setScaleExtent([b,w]),h({maxZoom:w})},setTranslateExtent:w=>{var m;(m=g().panZoom)==null||m.setTranslateExtent(w),h({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:m,triggerNodeChanges:b,triggerEdgeChanges:p,elementsSelectable:x}=g();if(!x)return;const E=m.reduce((M,C)=>C.selected?[...M,He(C.id,!1)]:M,[]),N=w.reduce((M,C)=>C.selected?[...M,He(C.id,!1)]:M,[]);b(E),p(N)},setNodeExtent:w=>{const{nodes:m,nodeLookup:b,parentLookup:p,nodeOrigin:x,elevateNodesOnSelect:E,nodeExtent:N,zIndexMode:M}=g();w[0][0]===N[0][0]&&w[0][1]===N[0][1]&&w[1][0]===N[1][0]&&w[1][1]===N[1][1]||(nr(m,b,p,{nodeOrigin:x,nodeExtent:w,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:M}),h({nodeExtent:w}))},panBy:w=>{const{transform:m,width:b,height:p,panZoom:x,translateExtent:E}=g();return hh({delta:w,panZoom:x,transform:m,translateExtent:E,width:b,height:p})},setCenter:async(w,m,b)=>{const{width:p,height:x,maxZoom:E,panZoom:N}=g();if(!N)return!1;const M=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:E;return await N.setViewport({x:p/2-w*M,y:x/2-m*M,zoom:M},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),!0},cancelConnection:()=>{h({connection:{...Ki}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...Go()})}},Object.is);function Ap({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:h}){const[g]=j.useState(()=>Ip({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:l,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return S.jsx(Bh,{value:g,children:S.jsx(gg,{children:S.jsx(Ig,{children:h})})})}function Tp({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h}){return j.useContext(vn)?S.jsx(S.Fragment,{children:e}):S.jsx(Ap,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h,children:e})}const Op={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Pp({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:E,onNodeDoubleClick:N,onNodeDragStart:M,onNodeDrag:C,onNodeDragStop:I,onNodesDelete:H,onEdgesDelete:O,onDelete:L,onSelectionChange:P,onSelectionDragStart:y,onSelectionDrag:_,onSelectionDragStop:k,onSelectionContextMenu:A,onSelectionStart:$,onSelectionEnd:T,onBeforeDelete:D,connectionMode:F,connectionLineType:z=$e.Bezier,connectionLineStyle:V,connectionLineComponent:Y,connectionLineContainerStyle:K,deleteKeyCode:Q="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:R=!1,selectionMode:B=_t.Full,panActivationKeyCode:U="Space",multiSelectionKeyCode:Z=St()?"Meta":"Control",zoomActivationKeyCode:W=St()?"Meta":"Control",snapToGrid:X,snapGrid:J,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:ne,nodesDraggable:oe,autoPanOnNodeFocus:ue,nodesConnectable:ve,nodesFocusable:be,nodeOrigin:ke=Cs,edgesFocusable:lt,edgesReconnectable:De,elementsSelectable:Re=!0,defaultViewport:de=tg,minZoom:Ce=.5,maxZoom:Me=2,translateExtent:ze=Et,preventScrolling:kn=!0,nodeExtent:Cn,defaultMarkerColor:$a="#b1b1b7",zoomOnScroll:ja=!0,zoomOnPinch:Da=!0,panOnScroll:Ra=!1,panOnScrollSpeed:za=.5,panOnScrollMode:Ha=Ve.Free,zoomOnDoubleClick:Fa=!0,panOnDrag:Ba=!0,onPaneClick:Va,onPaneMouseEnter:Ya,onPaneMouseMove:Xa,onPaneMouseLeave:Wa,onPaneScroll:Ga,onPaneContextMenu:qa,paneClickDistance:Ka=1,nodeClickDistance:Ua=0,children:Za,onReconnect:Qa,onReconnectStart:Ja,onReconnectEnd:ec,onEdgeContextMenu:tc,onEdgeDoubleClick:nc,onEdgeMouseEnter:rc,onEdgeMouseMove:oc,onEdgeMouseLeave:ic,reconnectRadius:sc=10,onNodesChange:ac,onEdgesChange:cc,noDragClassName:lc="nodrag",noWheelClassName:uc="nowheel",noPanClassName:Pr="nopan",fitView:Lr,fitViewOptions:$r,connectOnClick:dc,attributionPosition:fc,proOptions:hc,defaultEdgeOptions:gc,elevateNodesOnSelect:pc=!0,elevateEdgesOnSelect:mc=!1,disableKeyboardA11y:jr=!1,autoPanOnConnect:yc,autoPanOnNodeDrag:xc,autoPanOnSelection:wc=!0,autoPanSpeed:vc,connectionRadius:bc,isValidConnection:Ec,onError:_c,style:Nc,id:Dr,nodeDragThreshold:Sc,connectionDragThreshold:kc,viewport:Cc,onViewportChange:Mc,width:Ic,height:Ac,colorMode:Tc="light",debug:Oc,onScroll:$t,ariaLabelConfig:Pc,zIndexMode:Rr="basic",...Lc},$c){const Mn=Dr||"1",jc=ig(Tc),Dc=j.useCallback(zr=>{zr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),$t==null||$t(zr)},[$t]);return S.jsx("div",{"data-testid":"rf__wrapper",...Lc,onScroll:Dc,style:{...Nc,...Op},ref:$c,className:se(["react-flow",o,jc]),id:Dr,role:"application",children:S.jsxs(Tp,{nodes:e,edges:t,width:Ic,height:Ac,fitView:Lr,fitViewOptions:$r,minZoom:Ce,maxZoom:Me,nodeOrigin:ke,nodeExtent:Cn,zIndexMode:Rr,children:[S.jsx(og,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,nodesDraggable:oe,autoPanOnNodeFocus:ue,nodesConnectable:ve,nodesFocusable:be,edgesFocusable:lt,edgesReconnectable:De,elementsSelectable:Re,elevateNodesOnSelect:pc,elevateEdgesOnSelect:mc,minZoom:Ce,maxZoom:Me,nodeExtent:Cn,onNodesChange:ac,onEdgesChange:cc,snapToGrid:X,snapGrid:J,connectionMode:F,translateExtent:ze,connectOnClick:dc,defaultEdgeOptions:gc,fitView:Lr,fitViewOptions:$r,onNodesDelete:H,onEdgesDelete:O,onDelete:L,onNodeDragStart:M,onNodeDrag:C,onNodeDragStop:I,onSelectionDrag:_,onSelectionDragStart:y,onSelectionDragStop:k,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Pr,nodeOrigin:ke,rfId:Mn,autoPanOnConnect:yc,autoPanOnNodeDrag:xc,autoPanSpeed:vc,onError:_c,connectionRadius:bc,isValidConnection:Ec,selectNodesOnDrag:ne,nodeDragThreshold:Sc,connectionDragThreshold:kc,onBeforeDelete:D,debug:Oc,ariaLabelConfig:Pc,zIndexMode:Rr}),S.jsx(Cp,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:E,onNodeDoubleClick:N,nodeTypes:i,edgeTypes:s,connectionLineType:z,connectionLineStyle:V,connectionLineComponent:Y,connectionLineContainerStyle:K,selectionKeyCode:q,selectionOnDrag:R,selectionMode:B,deleteKeyCode:Q,multiSelectionKeyCode:Z,panActivationKeyCode:U,zoomActivationKeyCode:W,onlyRenderVisibleElements:te,defaultViewport:de,translateExtent:ze,minZoom:Ce,maxZoom:Me,preventScrolling:kn,zoomOnScroll:ja,zoomOnPinch:Da,zoomOnDoubleClick:Fa,panOnScroll:Ra,panOnScrollSpeed:za,panOnScrollMode:Ha,panOnDrag:Ba,autoPanOnSelection:wc,onPaneClick:Va,onPaneMouseEnter:Ya,onPaneMouseMove:Xa,onPaneMouseLeave:Wa,onPaneScroll:Ga,onPaneContextMenu:qa,paneClickDistance:Ka,nodeClickDistance:Ua,onSelectionContextMenu:A,onSelectionStart:$,onSelectionEnd:T,onReconnect:Qa,onReconnectStart:Ja,onReconnectEnd:ec,onEdgeContextMenu:tc,onEdgeDoubleClick:nc,onEdgeMouseEnter:rc,onEdgeMouseMove:oc,onEdgeMouseLeave:ic,reconnectRadius:sc,defaultMarkerColor:$a,noDragClassName:lc,noWheelClassName:uc,noPanClassName:Pr,rfId:Mn,disableKeyboardA11y:jr,nodeExtent:Cn,viewport:Cc,onViewportChange:Mc,nodesDraggable:oe}),S.jsx(eg,{onSelectionChange:P}),Za,S.jsx(Kh,{proOptions:hc,position:fc}),S.jsx(qh,{rfId:Mn,disableKeyboardA11y:jr})]})})}var Zy=Is(Pp);function Qy(){const e=re();return j.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),o=Array.isArray(t)?t:[t],i=new Map;o.forEach(s=>{const a=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${s}"]`);a&&i.set(s,{id:s,nodeElement:a,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function Lp({dimensions:e,lineWidth:t,variant:n,className:r}){return S.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,r])})}function $p({radius:e,className:t}){return S.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var je;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(je||(je={}));const jp={[je.Dots]:1,[je.Lines]:1,[je.Cross]:6},Dp=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ta({id:e,variant:t=je.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:c,className:l,patternClassName:u}){const d=j.useRef(null),{transform:f,patternId:h}=ee(Dp,ie),g=r||jp[t],v=t===je.Dots,w=t===je.Cross,m=Array.isArray(n)?n:[n,n],b=[m[0]*f[2]||1,m[1]*f[2]||1],p=g*f[2],x=Array.isArray(i)?i:[i,i],E=w?[p,p]:b,N=[x[0]*f[2]+E[0]/2,x[1]*f[2]+E[1]/2],M=`${h}${e||""}`;return S.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...En,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:d,"data-testid":"rf__background",children:[S.jsx("pattern",{id:M,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:v?S.jsx($p,{radius:p/2,className:u}):S.jsx(Lp,{dimensions:E,lineWidth:o,variant:t,className:u})}),S.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}ta.displayName="Background";j.memo(ta);function Rp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:S.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function zp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:S.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Hp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:S.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Fp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:S.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Bp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:S.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Yt({children:e,className:t,...n}){return S.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const Vp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function na({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:l,children:u,position:d="bottom-left",orientation:f="vertical","aria-label":h}){const g=re(),{isInteractive:v,minZoomReached:w,maxZoomReached:m,ariaLabelConfig:b}=ee(Vp,ie),{zoomIn:p,zoomOut:x,fitView:E}=Nr(),N=()=>{p(),i==null||i()},M=()=>{x(),s==null||s()},C=()=>{E(o),a==null||a()},I=()=>{g.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},H=f==="horizontal"?"horizontal":"vertical";return S.jsxs(bn,{className:se(["react-flow__controls",H,l]),position:d,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&S.jsxs(S.Fragment,{children:[S.jsx(Yt,{onClick:N,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:m,children:S.jsx(Rp,{})}),S.jsx(Yt,{onClick:M,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:w,children:S.jsx(zp,{})})]}),n&&S.jsx(Yt,{className:"react-flow__controls-fitview",onClick:C,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:S.jsx(Hp,{})}),r&&S.jsx(Yt,{className:"react-flow__controls-interactive",onClick:I,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:v?S.jsx(Bp,{}):S.jsx(Fp,{})}),u]})}na.displayName="Controls";j.memo(na);function Yp({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:h}){const{background:g,backgroundColor:v}=i||{},w=s||g||v;return S.jsx("rect",{className:se(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:o,style:{fill:w,stroke:a,strokeWidth:c},shapeRendering:d,onClick:h?m=>h(m,e):void 0})}const Xp=j.memo(Yp),Wp=e=>e.nodes.map(t=>t.id),Rn=e=>e instanceof Function?e:()=>e;function Gp({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Xp,onClick:s}){const a=ee(Wp,ie),c=Rn(t),l=Rn(e),u=Rn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return S.jsx(S.Fragment,{children:a.map(f=>S.jsx(Kp,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:d},f))})}function qp({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:l,x:u,y:d,width:f,height:h}=ee(g=>{const v=g.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:m,y:b}=v.internals.positionAbsolute,{width:p,height:x}=xe(w);return{node:w,x:m,y:b,width:p,height:x}},ie);return!l||l.hidden||!rs(l)?null:S.jsx(a,{x:u,y:d,width:f,height:h,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:o,strokeColor:n(l),strokeWidth:i,shapeRendering:s,onClick:c,id:l.id})}const Kp=j.memo(qp);var Up=j.memo(Gp);const Zp=200,Qp=150,Jp=e=>!e.hidden,e0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?es(Tt(e.nodeLookup,{filter:Jp}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},qo=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,t0=(e,t)=>qo(e.viewBB,t.viewBB)&&qo(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,n0="react-flow__minimap-desc";function ra({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:v=!1,zoomable:w=!1,ariaLabel:m,inversePan:b,zoomStep:p=1,offsetScale:x=5}){const E=re(),N=j.useRef(null),{boundingRect:M,viewBB:C,rfId:I,panZoom:H,translateExtent:O,flowWidth:L,flowHeight:P,ariaLabelConfig:y}=ee(e0,t0),_=(e==null?void 0:e.width)??Zp,k=(e==null?void 0:e.height)??Qp,A=M.width/_,$=M.height/k,T=Math.max(A,$),D=T*_,F=T*k,z=x*T,V=M.x-(D-M.width)/2-z,Y=M.y-(F-M.height)/2-z,K=D+z*2,Q=F+z*2,q=`${n0}-${I}`,R=j.useRef(0),B=j.useRef();R.current=T,j.useEffect(()=>{if(N.current&&H)return B.current=Eh({domNode:N.current,panZoom:H,getTransform:()=>E.getState().transform,getViewScale:()=>R.current}),()=>{var X;(X=B.current)==null||X.destroy()}},[H]),j.useEffect(()=>{var X;(X=B.current)==null||X.update({translateExtent:O,width:L,height:P,inversePan:b,pannable:v,zoomStep:p,zoomable:w})},[v,w,b,p,O,L,P]);const U=h?X=>{var ne;const[J,te]=((ne=B.current)==null?void 0:ne.pointer(X))||[0,0];h(X,{x:J,y:te})}:void 0,Z=g?j.useCallback((X,J)=>{const te=E.getState().nodeLookup.get(J).internals.userNode;g(X,te)},[]):void 0,W=m??y["minimap.ariaLabel"];return S.jsx(bn,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*T:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:S.jsxs("svg",{width:_,height:k,viewBox:`${V} ${Y} ${K} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":q,ref:N,onClick:U,children:[W&&S.jsx("title",{id:q,children:W}),S.jsx(Up,{onClick:Z,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),S.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-z},${Y-z}h${K+z*2}v${Q+z*2}h${-K-z*2}z
|
|
22
|
-
M${
|
|
21
|
+
`)),u=l.reduce((d,f)=>d.concat(...f),[]);return[l,u]}return[[],[]]},[e]);return D.useEffect(()=>{const c=(t==null?void 0:t.target)??Io,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const u=h=>{var w,m;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!l)&&ss(h))return!1;const v=To(h.code,a);if(i.current.add(h[v]),Ao(s,i.current,!1)){const b=((m=(w=h.composedPath)==null?void 0:w.call(h))==null?void 0:m[0])||h.target,p=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(o.current||!p)&&h.preventDefault(),r(!0)}},d=h=>{const g=To(h.code,a);Ao(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function Ao(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function To(e,t){return t.includes(e)?"code":"key"}const sg=()=>{const e=oe();return D.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),c=yr(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},u=n.snapGrid??o,d=n.snapToGrid??i;return Pt(l,r,d,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=it(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function Ms(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of t){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const c of s)ag(c,a);n.push(a)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function ag(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function cg(e,t){return Ms(e,t)}function lg(e,t){return Ms(e,t)}function ze(e,t){return{id:e,type:"select",selected:t}}function Qe(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(ze(i.id,s)))}return r}function Oo({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const a=t.get(s.id),c=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Po(e){return{id:e.id,type:"remove"}}const ug=ts();function dg(e,t,n={}){return eh(e,t,{...n,onError:n.onError??ug})}const Lo=e=>Hf(e),fg=e=>Ui(e);function Is(e){return D.forwardRef(e)}const As=typeof window<"u"?D.useLayoutEffect:D.useEffect;function $o(e){const[t,n]=D.useState(BigInt(0)),[r]=D.useState(()=>hg(()=>n(o=>o+BigInt(1))));return As(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function hg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ts=D.createContext(null);function gg({children:e}){const t=oe(),n=D.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:u,onNodesChange:d,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let v=c;for(const m of a)v=typeof m=="function"?m(v):m;let w=Oo({items:v,lookup:f});for(const m of g.values())w=m(w);u&&l(v),w.length>0?d==null||d(w):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:b,setNodes:p}=t.getState();m&&p(b)})},[]),r=$o(n),o=D.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:u,onEdgesChange:d,edgeLookup:f}=t.getState();let h=c;for(const g of a)h=typeof g=="function"?g(h):g;u?l(h):d&&d(Oo({items:h,lookup:f}))},[]),i=$o(o),s=D.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return S.jsx(Ts.Provider,{value:s,children:e})}function pg(){const e=D.useContext(Ts);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const mg=e=>!!e.panZoom;function Nr(){const e=sg(),t=oe(),n=pg(),r=te(mg),o=D.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),s=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},c=d=>{var m,b;const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=Lo(d)?d:f.get(d.id),v=g.parentId?rs(g.position,g.measured,g.parentId,f,h):g.position,w={...g,position:v,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return Nt(w)},l=(d,f,h={replace:!1})=>{s(g=>g.map(v=>{if(v.id===d){const w=typeof f=="function"?f(v):f;return h.replace&&Lo(w)?w:{...v,...w}}return v}))},u=(d,f,h={replace:!1})=>{a(g=>g.map(v=>{if(v.id===d){const w=typeof f=="function"?f(v):f;return h.replace&&fg(w)?w:{...v,...w}}return v}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var f;return(f=i(d))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(f=>({...f}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:s,setEdges:a,addNodes:d=>{const f=Array.isArray(d)?d:[d];n.nodeQueue.push(h=>[...h,...f])},addEdges:d=>{const f=Array.isArray(d)?d:[d];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:d=[],edges:f=[],transform:h}=t.getState(),[g,v,w]=h;return{nodes:d.map(m=>({...m})),edges:f.map(m=>({...m})),viewport:{x:g,y:v,zoom:w}}},deleteElements:async({nodes:d=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:m,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:x}=t.getState(),{nodes:E,edges:N}=await Yf({nodesToRemove:d,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:x}),k=N.length>0,M=E.length>0;if(k){const I=N.map(Po);w==null||w(N),b(I)}if(M){const I=E.map(Po);v==null||v(E),m(I)}return(M||k)&&(p==null||p({nodes:E,edges:N})),{deletedNodes:E,deletedEdges:N}},getIntersectingNodes:(d,f=!0,h)=>{const g=co(d),v=g?d:c(d),w=h!==void 0;return v?(h||t.getState().nodes).filter(m=>{const b=t.getState().nodeLookup.get(m.id);if(b&&!g&&(m.id===d.id||!b.internals.positionAbsolute))return!1;const p=Nt(w?m:b),x=sn(p,v);return f&&x>0||x>=p.width*p.height||x>=v.width*v.height}):[]},isNodeIntersecting:(d,f,h=!0)=>{const v=co(d)?d:c(d);if(!v)return!1;const w=sn(v,f);return h&&w>0||w>=f.width*f.height||w>=v.width*v.height},updateNode:l,updateNodeData:(d,f,h={replace:!1})=>{l(d,g=>{const v=typeof f=="function"?f(g):f;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},updateEdge:u,updateEdgeData:(d,f,h={replace:!1})=>{u(d,g=>{const v=typeof f=="function"?f(g):f;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},getNodesBounds:d=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return zf(d,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:d,id:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${d}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:d,handleId:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${d?f?`-${d}-${f}`:`-${d}`:""}`))==null?void 0:g.values())??[])},fitView:async d=>{const f=t.getState().fitViewResolver??Gf();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return D.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const Do=e=>e.selected,yg=typeof window<"u"?window:void 0;function xg({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=oe(),{deleteElements:r}=Nr(),o=Ct(e,{actInsideInputWithModifier:!1}),i=Ct(t,{target:yg});D.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter(Do),edges:s.filter(Do)}),n.setState({nodesSelectionActive:!1})}},[o]),D.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function wg(e){const t=oe();D.useEffect(()=>{const n=()=>{var o,i,s,a;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=xr(e.current);(r.height===0||r.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",me.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const En={position:"absolute",width:"100%",height:"100%",top:0,left:0},vg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function bg({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:o,panOnScrollSpeed:i=.5,panOnScrollMode:s=Ve.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:g=!0,children:v,noWheelClassName:w,noPanClassName:m,onViewportChange:b,isControlledViewport:p,paneClickDistance:x,selectionOnDrag:E}){const N=oe(),k=D.useRef(null),{userSelectionActive:M,lib:I,connectionInProgress:z}=te(vg,ie),O=Ct(h),L=D.useRef();wg(k);const P=D.useCallback(y=>{b==null||b({x:y[0],y:y[1],zoom:y[2]}),p||N.setState({transform:y})},[b,p]);return D.useEffect(()=>{if(k.current){L.current=Ah({domNode:k.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:A=>N.setState($=>$.paneDragging===A?$:{paneDragging:A}),onPanZoomStart:(A,$)=>{const{onViewportChangeStart:T,onMoveStart:j}=N.getState();j==null||j(A,$),T==null||T($)},onPanZoom:(A,$)=>{const{onViewportChange:T,onMove:j}=N.getState();j==null||j(A,$),T==null||T($)},onPanZoomEnd:(A,$)=>{const{onViewportChangeEnd:T,onMoveEnd:j}=N.getState();j==null||j(A,$),T==null||T($)}});const{x:y,y:_,zoom:C}=L.current.getViewport();return N.setState({panZoom:L.current,transform:[y,_,C],domNode:k.current.closest(".react-flow")}),()=>{var A;(A=L.current)==null||A.destroy()}}},[]),D.useEffect(()=>{var y;(y=L.current)==null||y.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:o,panOnScrollSpeed:i,panOnScrollMode:s,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:O,preventScrolling:g,noPanClassName:m,userSelectionActive:M,noWheelClassName:w,lib:I,onTransformChange:P,connectionInProgress:z,selectionOnDrag:E,paneClickDistance:x})},[e,t,n,r,o,i,s,a,c,O,g,m,M,w,I,P,z,E,x]),S.jsx("div",{className:"react-flow__renderer",ref:k,style:En,children:v})}const Eg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function _g(){const{userSelectionActive:e,userSelectionRect:t}=te(Eg,ie);return e&&t?S.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const jn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Ng=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Sg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=_t.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:g,children:v}){const w=D.useRef(0),m=oe(),{userSelectionActive:b,elementsSelectable:p,dragging:x,panBy:E,autoPanSpeed:N}=te(Ng,ie),k=p&&(e||b),M=D.useRef(null),I=D.useRef(),z=D.useRef(new Set),O=D.useRef(new Set),L=D.useRef(!1),P=D.useRef(!1),y=D.useRef({x:0,y:0}),_=D.useRef(!1),C=R=>{if(P.current||L.current||m.getState().connection.inProgress){P.current=!1,L.current=!1;return}l==null||l(R),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},A=R=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){R.preventDefault();return}u==null||u(R)},$=d?R=>d(R):void 0,T=R=>{P.current&&(R.stopPropagation(),P.current=!1)},j=R=>{var re,ue;if(R.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:B,transform:K}=m.getState();if(I.current=B==null?void 0:B.getBoundingClientRect(),!I.current)return;const U=R.target===M.current;if(!U&&!!R.target.closest(".nokey")||!e||!(s&&U||t)||R.button!==0||!R.isPrimary)return;(ue=(re=R.target)==null?void 0:re.setPointerCapture)==null||ue.call(re,R.pointerId),P.current=!1;const{x:Q,y:ee}=pe(R.nativeEvent,I.current),ne=Pt({x:Q,y:ee},K);m.setState({userSelectionRect:{width:0,height:0,startX:ne.x,startY:ne.y,x:Q,y:ee}}),U||(R.stopPropagation(),R.preventDefault())};function F(R,B){const{userSelectionRect:K}=m.getState();if(!K)return;const{transform:U,nodeLookup:X,edgeLookup:Z,connectionLookup:Q,triggerNodeChanges:ee,triggerEdgeChanges:ne,defaultEdgeOptions:re}=m.getState(),ue={x:K.startX,y:K.startY},{x:ve,y:be}=it(ue,U),Ce={startX:ue.x,startY:ue.y,x:R<ve?R:ve,y:B<be?B:be,width:Math.abs(R-ve),height:Math.abs(B-be)},lt=z.current,je=O.current;z.current=new Set(pr(X,Ce,U,n===_t.Partial,!0).map(de=>de.id)),O.current=new Set;const Re=(re==null?void 0:re.selectable)??!0;for(const de of z.current){const ke=Q.get(de);if(ke)for(const{edgeId:Me}of ke.values()){const He=Z.get(Me);He&&(He.selectable??Re)&&O.current.add(Me)}}if(!lo(lt,z.current)){const de=Qe(X,z.current,!0);ee(de)}if(!lo(je,O.current)){const de=Qe(Z,O.current);ne(de)}m.setState({userSelectionRect:Ce,userSelectionActive:!0,nodesSelectionActive:!1})}function H(){if(!o||!I.current)return;const[R,B]=mr(y.current,I.current,N);E({x:R,y:B}).then(K=>{if(!P.current||!K){w.current=requestAnimationFrame(H);return}const{x:U,y:X}=y.current;F(U,X),w.current=requestAnimationFrame(H)})}const V=()=>{cancelAnimationFrame(w.current),w.current=0,_.current=!1};D.useEffect(()=>()=>V(),[]);const Y=R=>{const{userSelectionRect:B,transform:K,resetSelectedElements:U}=m.getState();if(!I.current||!B)return;const{x:X,y:Z}=pe(R.nativeEvent,I.current);y.current={x:X,y:Z};const Q=it({x:B.startX,y:B.startY},K);if(!P.current){const ee=t?0:i;if(Math.hypot(X-Q.x,Z-Q.y)<=ee)return;U(),a==null||a(R)}P.current=!0,_.current||(H(),_.current=!0),F(X,Z)},q=R=>{var B,K;if(!k){R.target===M.current&&m.getState().connection.inProgress&&(L.current=!0);return}R.button===0&&((K=(B=R.target)==null?void 0:B.releasePointerCapture)==null||K.call(B,R.pointerId),!b&&R.target===M.current&&m.getState().userSelectionRect&&(C==null||C(R)),m.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(c==null||c(R),m.setState({nodesSelectionActive:z.current.size>0})),V())},J=R=>{var B,K;(K=(B=R.target)==null?void 0:B.releasePointerCapture)==null||K.call(B,R.pointerId),V()},G=r===!0||Array.isArray(r)&&r.includes(0);return S.jsxs("div",{className:se(["react-flow__pane",{draggable:G,dragging:x,selection:e}]),onClick:k?void 0:jn(C,M),onContextMenu:jn(A,M),onWheel:jn($,M),onPointerEnter:k?void 0:f,onPointerMove:k?Y:h,onPointerUp:q,onPointerCancel:k?J:void 0,onPointerDownCapture:k?j:void 0,onClickCapture:k?T:void 0,onPointerLeave:g,ref:M,style:En,children:[v,S.jsx(_g,{})]})}function or({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",me.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):o([e])}function Os({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=oe(),[c,l]=D.useState(!1),u=D.useRef();return D.useEffect(()=>{if(!t)return u.current=mh({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{or({id:d,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{var d;(d=u.current)==null||d.destroy(),u.current=void 0}},[t,a,e]),D.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s})},[n,r,t,i,e,o,s]),c}const Cg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ps(){const e=oe();return D.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:u}=e.getState(),d=new Map,f=Cg(s),h=o?i[0]:5,g=o?i[1]:5,v=n.direction.x*h*n.factor,w=n.direction.y*g*n.factor;for(const[,m]of l){if(!f(m))continue;let b={x:m.internals.positionAbsolute.x+v,y:m.internals.positionAbsolute.y+w};o&&(b=Ot(b,i));const{position:p,positionAbsolute:x}=Zi({nodeId:m.id,nextPosition:b,nodeLookup:l,nodeExtent:r,nodeOrigin:u,onError:a});m.position=p,m.internals.positionAbsolute=x,d.set(m.id,m)}c(d)},[])}const Sr=D.createContext(null),kg=Sr.Provider;Sr.Consumer;const Ls=()=>D.useContext(Sr),Mg=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),$s=D.createContext(null);function Ig({children:e}){const t=te(Mg,ie);return S.jsx($s.Provider,{value:t,children:e})}function Ag(){const e=D.useContext($s);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Tg={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Og=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:c,isValid:l}=s;if(!a&&!o)return Tg;const u=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:u,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===rt.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:u&&l}};function Pg({type:e="source",position:t=W.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},h){var _,C;const g=s||null,v=e==="target",w=oe(),m=Ls(),{connectOnClick:b,noPanClassName:p,rfId:x}=Ag(),{connectingFrom:E,connectingTo:N,clickConnecting:k,isPossibleEndHandle:M,connectionInProcess:I,clickConnectionInProcess:z,valid:O}=te(Og(m,g,e),ie);m||(C=(_=w.getState()).onError)==null||C.call(_,"010",me.error010());const L=A=>{const{defaultEdgeOptions:$,onConnect:T,hasDefaultEdges:j}=w.getState(),F={...$,...A};if(j){const{edges:H,setEdges:V,onError:Y}=w.getState();V(dg(F,H,{onError:Y}))}T==null||T(F),a==null||a(F)},P=A=>{if(!m)return;const $=as(A.nativeEvent);if(o&&($&&A.button===0||!$)){const T=w.getState();rr.onPointerDown(A.nativeEvent,{handleDomNode:A.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:v,handleId:g,nodeId:m,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...j)=>{var F,H;return(H=(F=w.getState()).onConnectEnd)==null?void 0:H.call(F,...j)},updateConnection:T.updateConnection,onConnect:L,isValidConnection:n||((...j)=>{var F,H;return((H=(F=w.getState()).isValidConnection)==null?void 0:H.call(F,...j))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}$?u==null||u(A):d==null||d(A)},y=A=>{const{onClickConnectStart:$,onClickConnectEnd:T,connectionClickStartHandle:j,connectionMode:F,isValidConnection:H,lib:V,rfId:Y,nodeLookup:q,connection:J}=w.getState();if(!m||!j&&!o)return;if(!j){$==null||$(A.nativeEvent,{nodeId:m,handleId:g,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:m,type:e,id:g}});return}const G=is(A.target),R=n||H,{connection:B,isValid:K}=rr.isValid(A.nativeEvent,{handle:{nodeId:m,id:g,type:e},connectionMode:F,fromNodeId:j.nodeId,fromHandleId:j.id||null,fromType:j.type,isValidConnection:R,flowId:Y,doc:G,lib:V,nodeLookup:q});K&&B&&L(B);const U=structuredClone(J);delete U.inProgress,U.toPosition=U.toHandle?U.toHandle.position:null,T==null||T(A,U),w.setState({connectionClickStartHandle:null})};return S.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":t,"data-id":`${x}-${m}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,l,{source:!v,target:v,connectable:r,connectablestart:o,connectableend:i,clickconnecting:k,connectingfrom:E,connectingto:N,valid:O,connectionindicator:r&&(!I||M)&&(I||z?i:o)}]),onMouseDown:P,onTouchStart:P,onClick:b?y:void 0,ref:h,...f,children:c})}const an=D.memo(Is(Pg));function Lg({data:e,isConnectable:t,sourcePosition:n=W.Bottom}){return S.jsxs(S.Fragment,{children:[e==null?void 0:e.label,S.jsx(an,{type:"source",position:n,isConnectable:t})]})}function $g({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:r=W.Bottom}){return S.jsxs(S.Fragment,{children:[S.jsx(an,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,S.jsx(an,{type:"source",position:r,isConnectable:t})]})}function Dg(){return null}function jg({data:e,isConnectable:t,targetPosition:n=W.Top}){return S.jsxs(S.Fragment,{children:[S.jsx(an,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const cn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},jo={input:Lg,default:$g,output:jg,group:Dg};function Rg(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const Hg=e=>{const{width:t,height:n,x:r,y:o}=Tt(e.nodeLookup,{filter:i=>!!i.selected});return{width:ge(t)?t:null,height:ge(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function zg({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=oe(),{width:o,height:i,transformString:s,userSelectionActive:a}=te(Hg,ie),c=Ps(),l=D.useRef(null);D.useEffect(()=>{var h;n||(h=l.current)==null||h.focus({preventScroll:!0})},[n]);const u=!a&&o!==null&&i!==null;if(Os({nodeRef:l,disabled:!u}),!u)return null;const d=e?h=>{const g=r.getState().nodes.filter(v=>v.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(cn,h.key)&&(h.preventDefault(),c({direction:cn[h.key],factor:h.shiftKey?4:1}))};return S.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:S.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const Ro=typeof window<"u"?window:void 0,Fg=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Ds({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:v,zoomActivationKeyCode:w,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:x,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:k,panOnDrag:M,autoPanOnSelection:I,defaultViewport:z,translateExtent:O,minZoom:L,maxZoom:P,preventScrolling:y,onSelectionContextMenu:_,noWheelClassName:C,noPanClassName:A,disableKeyboardA11y:$,onViewportChange:T,isControlledViewport:j}){const{nodesSelectionActive:F,userSelectionActive:H}=te(Fg,ie),V=Ct(l,{target:Ro}),Y=Ct(v,{target:Ro}),q=Y||M,J=Y||x,G=u&&q!==!0,R=V||H||G;return xg({deleteKeyCode:c,multiSelectionKeyCode:g}),S.jsx(bg,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:J,panActivationKeyPressed:Y,panOnScrollSpeed:E,panOnScrollMode:N,zoomOnDoubleClick:k,panOnDrag:!V&&q,defaultViewport:z,translateExtent:O,minZoom:L,maxZoom:P,zoomActivationKeyCode:w,preventScrolling:y,noWheelClassName:C,noPanClassName:A,onViewportChange:T,isControlledViewport:j,paneClickDistance:a,selectionOnDrag:G,children:S.jsxs(Sg,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:q,autoPanOnSelection:I,isSelecting:!!R,selectionMode:d,selectionKeyPressed:V,paneClickDistance:a,selectionOnDrag:G,children:[e,F&&S.jsx(zg,{onSelectionContextMenu:_,noPanClassName:A,disableKeyboardA11y:$})]})})}Ds.displayName="FlowRenderer";const Bg=D.memo(Ds),Vg=e=>t=>e?pr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function Yg(e){return te(D.useCallback(Vg(e),[e]),ie)}const Xg=e=>e.updateNodeInternals;function Wg(){const e=te(Xg),[t]=D.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return D.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Gg({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=oe(),i=D.useRef(null),s=D.useRef(null),a=D.useRef(e.sourcePosition),c=D.useRef(e.targetPosition),l=D.useRef(t),u=n&&!!e.internals.handleBounds;return D.useEffect(()=>{i.current&&!e.hidden&&(!u||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[u,e.hidden]),D.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),D.useEffect(()=>{if(i.current){const d=l.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(d||f||h)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function qg({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:v,nodeTypes:w,nodeClickDistance:m,onError:b}){const{node:p,internals:x,isParent:E}=te(R=>{const B=R.nodeLookup.get(e),K=R.parentLookup.has(e);return{node:B,internals:B.internals,isParent:K}},ie);let N=p.type||"default",k=(w==null?void 0:w[N])||jo[N];k===void 0&&(b==null||b("003",me.error003(N)),N="default",k=(w==null?void 0:w.default)||jo.default);const M=!!(p.draggable||a&&typeof p.draggable>"u"),I=!!(p.selectable||c&&typeof p.selectable>"u"),z=!!(p.connectable||l&&typeof p.connectable>"u"),O=!!(p.focusable||u&&typeof p.focusable>"u"),L=oe(),P=ns(p),y=Gg({node:p,nodeType:N,hasDimensions:P,resizeObserver:d}),_=Os({nodeRef:y,disabled:p.hidden||!M,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:m}),C=Ps();if(p.hidden)return null;const A=xe(p),$=Rg(p),T=I||M||t||n||r||o,j=n?R=>n(R,{...x.userNode}):void 0,F=r?R=>r(R,{...x.userNode}):void 0,H=o?R=>o(R,{...x.userNode}):void 0,V=i?R=>i(R,{...x.userNode}):void 0,Y=s?R=>s(R,{...x.userNode}):void 0,q=R=>{const{selectNodesOnDrag:B,nodeDragThreshold:K}=L.getState();I&&(!B||!M||K>0)&&or({id:e,store:L,nodeRef:y}),t&&t(R,{...x.userNode})},J=R=>{if(!(ss(R.nativeEvent)||g)){if(Gi.includes(R.key)&&I){const B=R.key==="Escape";or({id:e,store:L,unselect:B,nodeRef:y})}else if(M&&p.selected&&Object.prototype.hasOwnProperty.call(cn,R.key)){R.preventDefault();const{ariaLabelConfig:B}=L.getState();L.setState({ariaLiveMessage:B["node.a11yDescription.ariaLiveMessage"]({direction:R.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),C({direction:cn[R.key],factor:R.shiftKey?4:1})}}},G=()=>{var Q;if(g||!((Q=y.current)!=null&&Q.matches(":focus-visible")))return;const{transform:R,width:B,height:K,autoPanOnNodeFocus:U,setCenter:X}=L.getState();if(!U)return;pr(new Map([[e,p]]),{x:0,y:0,width:B,height:K},R,!0).length>0||X(p.position.x+A.width/2,p.position.y+A.height/2,{zoom:R[2]})};return S.jsx("div",{className:se(["react-flow__node",`react-flow__node-${N}`,{[h]:M},p.className,{selected:p.selected,selectable:I,parent:E,draggable:M,dragging:_}]),ref:y,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:P?"visible":"hidden",...p.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:F,onMouseLeave:H,onContextMenu:V,onClick:q,onDoubleClick:Y,onKeyDown:O?J:void 0,tabIndex:O?0:void 0,onFocus:O?G:void 0,role:p.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Ss}-${v}`,"aria-label":p.ariaLabel,...p.domAttributes,children:S.jsx(kg,{value:e,children:S.jsx(k,{id:e,data:p.data,type:N,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:p.selected??!1,selectable:I,draggable:M,deletable:p.deletable??!0,isConnectable:z,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:_,dragHandle:p.dragHandle,zIndex:x.z,parentId:p.parentId,...A})})})}var Kg=D.memo(qg);const Ug=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function js(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:o}=te(Ug,ie),i=Yg(e.onlyRenderVisibleElements),s=Wg();return S.jsx("div",{className:"react-flow__nodes",style:En,children:i.map(a=>S.jsx(Kg,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},a))})}js.displayName="NodeRenderer";const Zg=D.memo(js);function Qg(e){return te(D.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&Zf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),ie)}const Jg=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return S.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},ep=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return S.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Ho={[rn.Arrow]:Jg,[rn.ArrowClosed]:ep};function tp(e){const t=oe();return D.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(Ho,e)?Ho[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",me.error009(e)),null)},[e])}const np=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=tp(t);return c?S.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:S.jsx(c,{color:n,strokeWidth:s})}):null},Rs=({defaultColor:e,rfId:t})=>{const n=te(i=>i.edges),r=te(i=>i.defaultEdgeOptions),o=D.useMemo(()=>ih(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?S.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:S.jsx("defs",{children:o.map(i=>S.jsx(np,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Rs.displayName="MarkerDefinitions";var rp=D.memo(Rs);function Hs({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u}){const[d,f]=D.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",l]),g=D.useRef(null);return D.useEffect(()=>{if(g.current){const v=g.current.getBBox();f({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?S.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:h,visibility:d.width?"visible":"hidden",...u,children:[o&&S.jsx("rect",{width:d.width+2*s[0],x:-s[0],y:-s[1],height:d.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),S.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}Hs.displayName="EdgeText";const op=D.memo(Hs);function _n({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return S.jsxs(S.Fragment,{children:[S.jsx("path",{...u,d:e,fill:"none",className:se(["react-flow__edge-path",u.className])}),l?S.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,r&&ge(t)&&ge(n)?S.jsx(op,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function zo({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===W.Left||e===W.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function zs({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top}){const[s,a]=zo({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,l]=zo({pos:i,x1:r,y1:o,x2:e,y2:t}),[u,d,f,h]=cs({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${s},${a} ${c},${l} ${r},${o}`,u,d,f,h]}function Fs(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:m})=>{const[b,p,x]=zs({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),E=e.isInternal?void 0:t;return S.jsx(_n,{id:E,path:b,labelX:p,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:m})})}const ip=Fs({isInternal:!1}),Bs=Fs({isInternal:!0});ip.displayName="SimpleBezierEdge";Bs.displayName="SimpleBezierEdgeInternal";function Vs(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:h=W.Bottom,targetPosition:g=W.Top,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:b})=>{const[p,x,E]=er({sourceX:n,sourceY:r,sourcePosition:h,targetX:o,targetY:i,targetPosition:g,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset,stepPosition:m==null?void 0:m.stepPosition}),N=e.isInternal?void 0:t;return S.jsx(_n,{id:N,path:p,labelX:x,labelY:E,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:v,markerStart:w,interactionWidth:b})})}const Ys=Vs({isInternal:!1}),Xs=Vs({isInternal:!0});Ys.displayName="SmoothStepEdge";Xs.displayName="SmoothStepEdgeInternal";function Ws(e){return D.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return S.jsx(Ys,{...n,id:r,pathOptions:D.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const sp=Ws({isInternal:!1}),Gs=Ws({isInternal:!0});sp.displayName="StepEdge";Gs.displayName="StepEdgeInternal";function qs(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})=>{const[w,m,b]=ds({sourceX:n,sourceY:r,targetX:o,targetY:i}),p=e.isInternal?void 0:t;return S.jsx(_n,{id:p,path:w,labelX:m,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}const ap=qs({isInternal:!1}),Ks=qs({isInternal:!0});ap.displayName="StraightEdge";Ks.displayName="StraightEdgeInternal";function Us(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=W.Bottom,targetPosition:a=W.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:b})=>{const[p,x,E]=ls({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),N=e.isInternal?void 0:t;return S.jsx(_n,{id:N,path:p,labelX:x,labelY:E,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:w,interactionWidth:b})})}const cp=Us({isInternal:!1}),Zs=Us({isInternal:!0});cp.displayName="BezierEdge";Zs.displayName="BezierEdgeInternal";const Fo={default:Zs,straight:Ks,step:Gs,smoothstep:Xs,simplebezier:Bs},Bo={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},lp=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,up=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,Vo="react-flow__edgeupdater";function Yo({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a}){return S.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:se([Vo,`${Vo}-${a}`]),cx:lp(t,r,e),cy:up(n,r,e),r,stroke:"transparent",fill:"transparent"})}function dp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:h}){const g=oe(),v=(x,E)=>{if(x.button!==0)return;const{autoPanOnConnect:N,domNode:k,connectionMode:M,connectionRadius:I,lib:z,onConnectStart:O,cancelConnection:L,nodeLookup:P,rfId:y,panBy:_,updateConnection:C}=g.getState(),A=E.type==="target",$=(F,H)=>{f(!1),d==null||d(F,n,E.type,H)},T=F=>l==null?void 0:l(n,F),j=(F,H)=>{f(!0),u==null||u(x,n,E.type),O==null||O(F,H)};rr.onPointerDown(x.nativeEvent,{autoPanOnConnect:N,connectionMode:M,connectionRadius:I,domNode:k,handleId:E.id,nodeId:E.nodeId,nodeLookup:P,isTarget:A,edgeUpdaterType:E.type,lib:z,flowId:y,cancelConnection:L,panBy:_,isValidConnection:(...F)=>{var H,V;return((V=(H=g.getState()).isValidConnection)==null?void 0:V.call(H,...F))??!0},onConnect:T,onConnectStart:j,onConnectEnd:(...F)=>{var H,V;return(V=(H=g.getState()).onConnectEnd)==null?void 0:V.call(H,...F)},onReconnectEnd:$,updateConnection:C,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},w=x=>v(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=x=>v(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),p=()=>h(!1);return S.jsxs(S.Fragment,{children:[(e===!0||e==="source")&&S.jsx(Yo,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&S.jsx(Yo,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function fp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:v,noPanClassName:w,onError:m,disableKeyboardA11y:b}){let p=te(X=>X.edgeLookup.get(e));const x=te(X=>X.defaultEdgeOptions);p=x?{...x,...p}:p;let E=p.type||"default",N=(v==null?void 0:v[E])||Fo[E];N===void 0&&(m==null||m("011",me.error011(E)),E="default",N=(v==null?void 0:v.default)||Fo.default);const k=!!(p.focusable||t&&typeof p.focusable>"u"),M=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),I=!!(p.selectable||r&&typeof p.selectable>"u"),z=D.useRef(null),[O,L]=D.useState(!1),[P,y]=D.useState(!1),_=oe(),{zIndex:C=p.zIndex,sourceX:A,sourceY:$,targetX:T,targetY:j,sourcePosition:F,targetPosition:H}=te(D.useCallback(X=>{const Z=X.nodeLookup.get(p.source),Q=X.nodeLookup.get(p.target);if(!Z||!Q)return Bo;const ee=oh({id:e,sourceNode:Z,targetNode:Q,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:X.connectionMode,onError:m}),ne=Uf({selected:p.selected,zIndex:p.zIndex,sourceNode:Z,targetNode:Q,elevateOnSelect:X.elevateEdgesOnSelect,zIndexMode:X.zIndexMode});return{...ee||Bo,zIndex:ne}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex,m]),ie),V=D.useMemo(()=>p.markerStart?`url('#${tr(p.markerStart,g)}')`:void 0,[p.markerStart,g]),Y=D.useMemo(()=>p.markerEnd?`url('#${tr(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||A===null||$===null||T===null||j===null)return null;const q=X=>{var ne;const{addSelectedEdges:Z,unselectNodesAndEdges:Q,multiSelectionActive:ee}=_.getState();I&&(_.setState({nodesSelectionActive:!1}),p.selected&&ee?(Q({nodes:[],edges:[p]}),(ne=z.current)==null||ne.blur()):Z([e])),o&&o(X,p)},J=i?X=>{i(X,{...p})}:void 0,G=s?X=>{s(X,{...p})}:void 0,R=a?X=>{a(X,{...p})}:void 0,B=c?X=>{c(X,{...p})}:void 0,K=l?X=>{l(X,{...p})}:void 0,U=X=>{var Z;if(!b&&Gi.includes(X.key)&&I){const{unselectNodesAndEdges:Q,addSelectedEdges:ee}=_.getState();X.key==="Escape"?((Z=z.current)==null||Z.blur(),Q({edges:[p]})):ee([e])}};return S.jsx("svg",{style:{zIndex:C},children:S.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${E}`,p.className,w,{selected:p.selected,animated:p.animated,inactive:!I&&!o,updating:O,selectable:I}]),onClick:q,onDoubleClick:J,onContextMenu:G,onMouseEnter:R,onMouseMove:B,onMouseLeave:K,onKeyDown:k?U:void 0,tabIndex:k?0:void 0,role:p.ariaRole??(k?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":k?`${Cs}-${g}`:void 0,ref:z,...p.domAttributes,children:[!P&&S.jsx(N,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:I,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:A,sourceY:$,targetX:T,targetY:j,sourcePosition:F,targetPosition:H,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:V,markerEnd:Y,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),M&&S.jsx(dp,{edge:p,isReconnectable:M,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:h,sourceX:A,sourceY:$,targetX:T,targetY:j,sourcePosition:F,targetPosition:H,setUpdateHover:L,setReconnecting:y})]})})}var hp=D.memo(fp);const gp=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Qs({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:v}){const{edgesFocusable:w,edgesReconnectable:m,elementsSelectable:b,onError:p}=te(gp,ie),x=Qg(t);return S.jsxs("div",{className:"react-flow__edges",children:[S.jsx(rp,{defaultColor:e,rfId:n}),x.map(E=>S.jsx(hp,{id:E,edgesFocusable:w,edgesReconnectable:m,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:v},E))]})}Qs.displayName="EdgeRenderer";const pp=D.memo(Qs),Xo=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function mp({children:e}){const t=oe(),n=D.useRef(null),[r]=D.useState(()=>t.getState().transform);return As(()=>{let o=null;const i=()=>{const s=t.getState().transform;o&&s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]||(o=s,n.current&&(n.current.style.transform=Xo(s)))};return i(),t.subscribe(i)},[t]),S.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Xo(r)},children:e})}function yp(e){const t=Nr(),n=D.useRef(!1);D.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const xp=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function wp(e){const t=te(xp),n=oe();return D.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function vp(e){return e.connection.inProgress?{...e.connection,to:Pt(e.connection.to,e.transform)}:{...e.connection}}function bp(e){return vp}function Ep(e){const t=bp();return te(t,ie)}const _p=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Np({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:c}=te(_p,ie);return!(i&&o&&c)?null:S.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:S.jsx("g",{className:se(["react-flow__connection",os(a)]),children:S.jsx(Js,{style:t,type:n,CustomComponent:r,isValid:a})})})}const Js=({style:e,type:t=$e.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:h}=Ep();if(!o)return;if(n)return S.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:os(r),toNode:u,toHandle:d,pointer:h});let g="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case $e.Bezier:[g]=ls(v);break;case $e.SimpleBezier:[g]=zs(v);break;case $e.Step:[g]=er({...v,borderRadius:0});break;case $e.SmoothStep:[g]=er(v);break;default:[g]=ds(v)}return S.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Js.displayName="ConnectionLine";const Sp={};function Wo(e=Sp){D.useRef(e),oe(),D.useEffect(()=>{},[e])}function Cp(){oe(),D.useRef(!1),D.useEffect(()=>{},[])}function ea({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:m,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:k,deleteKeyCode:M,onlyRenderVisibleElements:I,elementsSelectable:z,defaultViewport:O,translateExtent:L,minZoom:P,maxZoom:y,preventScrolling:_,defaultMarkerColor:C,zoomOnScroll:A,zoomOnPinch:$,panOnScroll:T,panOnScrollSpeed:j,panOnScrollMode:F,zoomOnDoubleClick:H,panOnDrag:V,autoPanOnSelection:Y,onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:G,onPaneMouseLeave:R,onPaneScroll:B,onPaneContextMenu:K,paneClickDistance:U,nodeClickDistance:X,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:re,onReconnect:ue,onReconnectStart:ve,onReconnectEnd:be,noDragClassName:Ce,noWheelClassName:lt,noPanClassName:je,disableKeyboardA11y:Re,nodeExtent:de,rfId:ke,viewport:Me,onViewportChange:He,nodesDraggable:Cn}){return Wo(e),Wo(t),Cp(),yp(n),wp(Me),S.jsx(Bg,{onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:G,onPaneMouseLeave:R,onPaneContextMenu:K,onPaneScroll:B,paneClickDistance:U,deleteKeyCode:M,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:E,panActivationKeyCode:N,zoomActivationKeyCode:k,elementsSelectable:z,zoomOnScroll:A,zoomOnPinch:$,zoomOnDoubleClick:H,panOnScroll:T,panOnScrollSpeed:j,panOnScrollMode:F,panOnDrag:V,autoPanOnSelection:Y,defaultViewport:O,translateExtent:L,minZoom:P,maxZoom:y,onSelectionContextMenu:d,preventScrolling:_,noDragClassName:Ce,noWheelClassName:lt,noPanClassName:je,disableKeyboardA11y:Re,onViewportChange:He,isControlledViewport:!!Me,children:S.jsxs(mp,{children:[S.jsx(pp,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:ue,onReconnectStart:ve,onReconnectEnd:be,onlyRenderVisibleElements:I,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:re,defaultMarkerColor:C,noPanClassName:je,disableKeyboardA11y:Re,rfId:ke}),S.jsx(Np,{style:v,type:g,component:w,containerStyle:m}),S.jsx("div",{className:"react-flow__edgelabel-renderer"}),S.jsx(Zg,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:X,onlyRenderVisibleElements:I,noPanClassName:je,noDragClassName:Ce,disableKeyboardA11y:Re,nodeExtent:de,rfId:ke,nodesDraggable:Cn}),S.jsx("div",{className:"react-flow__viewport-portal"})]})})}ea.displayName="GraphView";const kp=D.memo(ea),Mp=ts(),Go=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,v=new Map,w=new Map,m=r??t??[],b=n??e??[],p=u??[0,0],x=d??Et;gs(v,w,m);const{nodesInitialized:E}=nr(b,h,g,{nodeOrigin:p,nodeExtent:x,zIndexMode:f});let N=[0,0,1];if(s&&o&&i){const k=Tt(h,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:M,y:I,zoom:z}=yr(k,o,i,c,l,(a==null?void 0:a.padding)??.1);N=[M,I,z]}return{rfId:"1",width:o??0,height:i??0,transform:N,nodes:b,nodesInitialized:E,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Et,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:rt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...Ki},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Mp,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:qi,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},Ip=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>Fh((h,g)=>{async function v(){const{nodeLookup:w,panZoom:m,fitViewOptions:b,fitViewResolver:p,width:x,height:E,minZoom:N,maxZoom:k}=g();m&&(await Vf({nodes:w,width:x,height:E,panZoom:m,minZoom:N,maxZoom:k},b),p==null||p.resolve(!0),h({fitViewResolver:null}))}return{...Go({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:w=>{const{nodeLookup:m,parentLookup:b,nodeOrigin:p,nodeExtent:x,elevateNodesOnSelect:E,fitViewQueued:N,zIndexMode:k,nodesSelectionActive:M}=g(),{nodesInitialized:I,hasSelectedNodes:z}=nr(w,m,b,{nodeOrigin:p,nodeExtent:x,elevateNodesOnSelect:E,checkEquality:!0,zIndexMode:k}),O=M&&z;N&&I?(v(),h({nodes:w,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):h({nodes:w,nodesInitialized:I,nodesSelectionActive:O})},setEdges:w=>{const{connectionLookup:m,edgeLookup:b}=g();gs(m,b,w),h({edges:w})},setDefaultNodesAndEdges:(w,m)=>{if(w){const{setNodes:b}=g();b(w),h({hasDefaultNodes:!0})}if(m){const{setEdges:b}=g();b(m),h({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:m,nodeLookup:b,parentLookup:p,domNode:x,nodeOrigin:E,nodeExtent:N,debug:k,fitViewQueued:M,zIndexMode:I}=g(),{changes:z,updatedInternals:O}=fh(w,b,p,x,E,N,I);O&&(ch(b,p,{nodeOrigin:E,nodeExtent:N,zIndexMode:I}),M?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(z==null?void 0:z.length)>0&&(k&&console.log("React Flow: trigger node changes",z),m==null||m(z)))},updateNodePositions:(w,m=!1)=>{const b=[];let p=[];const{nodeLookup:x,triggerNodeChanges:E,connection:N,updateConnection:k,onNodesChangeMiddlewareMap:M}=g();for(const[I,z]of w){const O=x.get(I),L=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(z!=null&&z.position)),P={id:I,type:"position",position:L?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:m};if(O&&N.inProgress&&N.fromNode.id===O.id){const y=qe(O,N.fromHandle,W.Left,!0);k({...N,from:y})}L&&O.parentId&&b.push({id:I,parentId:O.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),p.push(P)}if(b.length>0){const{parentLookup:I,nodeOrigin:z}=g(),O=_r(b,x,I,z);p.push(...O)}for(const I of M.values())p=I(p);E(p)},triggerNodeChanges:w=>{const{onNodesChange:m,setNodes:b,nodes:p,hasDefaultNodes:x,debug:E}=g();if(w!=null&&w.length){if(x){const N=cg(w,p);b(N)}E&&console.log("React Flow: trigger node changes",w),m==null||m(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:m,setEdges:b,edges:p,hasDefaultEdges:x,debug:E}=g();if(w!=null&&w.length){if(x){const N=lg(w,p);b(N)}E&&console.log("React Flow: trigger edge changes",w),m==null||m(w)}},addSelectedNodes:w=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:E}=g();if(m){const N=w.map(k=>ze(k,!0));x(N);return}x(Qe(p,new Set([...w]),!0)),E(Qe(b))},addSelectedEdges:w=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:E}=g();if(m){const N=w.map(k=>ze(k,!0));E(N);return}E(Qe(b,new Set([...w]))),x(Qe(p,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:m}={})=>{const{edges:b,nodes:p,nodeLookup:x,triggerNodeChanges:E,triggerEdgeChanges:N}=g(),k=w||p,M=m||b,I=[];for(const O of k){if(!O.selected)continue;const L=x.get(O.id);L&&(L.selected=!1),I.push(ze(O.id,!1))}const z=[];for(const O of M)O.selected&&z.push(ze(O.id,!1));E(I),N(z)},setMinZoom:w=>{const{panZoom:m,maxZoom:b}=g();m==null||m.setScaleExtent([w,b]),h({minZoom:w})},setMaxZoom:w=>{const{panZoom:m,minZoom:b}=g();m==null||m.setScaleExtent([b,w]),h({maxZoom:w})},setTranslateExtent:w=>{var m;(m=g().panZoom)==null||m.setTranslateExtent(w),h({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:m,triggerNodeChanges:b,triggerEdgeChanges:p,elementsSelectable:x}=g();if(!x)return;const E=m.reduce((k,M)=>M.selected?[...k,ze(M.id,!1)]:k,[]),N=w.reduce((k,M)=>M.selected?[...k,ze(M.id,!1)]:k,[]);b(E),p(N)},setNodeExtent:w=>{const{nodes:m,nodeLookup:b,parentLookup:p,nodeOrigin:x,elevateNodesOnSelect:E,nodeExtent:N,zIndexMode:k}=g();w[0][0]===N[0][0]&&w[0][1]===N[0][1]&&w[1][0]===N[1][0]&&w[1][1]===N[1][1]||(nr(m,b,p,{nodeOrigin:x,nodeExtent:w,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:k}),h({nodeExtent:w}))},panBy:w=>{const{transform:m,width:b,height:p,panZoom:x,translateExtent:E}=g();return hh({delta:w,panZoom:x,transform:m,translateExtent:E,width:b,height:p})},setCenter:async(w,m,b)=>{const{width:p,height:x,maxZoom:E,panZoom:N}=g();if(!N)return!1;const k=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:E;return await N.setViewport({x:p/2-w*k,y:x/2-m*k,zoom:k},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),!0},cancelConnection:()=>{h({connection:{...Ki}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...Go()})}},Object.is);function Ap({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:h}){const[g]=D.useState(()=>Ip({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:l,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return S.jsx(Bh,{value:g,children:S.jsx(gg,{children:S.jsx(Ig,{children:h})})})}function Tp({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h}){return D.useContext(vn)?S.jsx(S.Fragment,{children:e}):S.jsx(Ap,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:h,children:e})}const Op={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Pp({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:E,onNodeDoubleClick:N,onNodeDragStart:k,onNodeDrag:M,onNodeDragStop:I,onNodesDelete:z,onEdgesDelete:O,onDelete:L,onSelectionChange:P,onSelectionDragStart:y,onSelectionDrag:_,onSelectionDragStop:C,onSelectionContextMenu:A,onSelectionStart:$,onSelectionEnd:T,onBeforeDelete:j,connectionMode:F,connectionLineType:H=$e.Bezier,connectionLineStyle:V,connectionLineComponent:Y,connectionLineContainerStyle:q,deleteKeyCode:J="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:R=!1,selectionMode:B=_t.Full,panActivationKeyCode:K="Space",multiSelectionKeyCode:U=St()?"Meta":"Control",zoomActivationKeyCode:X=St()?"Meta":"Control",snapToGrid:Z,snapGrid:Q,onlyRenderVisibleElements:ee=!1,selectNodesOnDrag:ne,nodesDraggable:re,autoPanOnNodeFocus:ue,nodesConnectable:ve,nodesFocusable:be,nodeOrigin:Ce=ks,edgesFocusable:lt,edgesReconnectable:je,elementsSelectable:Re=!0,defaultViewport:de=tg,minZoom:ke=.5,maxZoom:Me=2,translateExtent:He=Et,preventScrolling:Cn=!0,nodeExtent:kn,defaultMarkerColor:$a="#b1b1b7",zoomOnScroll:Da=!0,zoomOnPinch:ja=!0,panOnScroll:Ra=!1,panOnScrollSpeed:Ha=.5,panOnScrollMode:za=Ve.Free,zoomOnDoubleClick:Fa=!0,panOnDrag:Ba=!0,onPaneClick:Va,onPaneMouseEnter:Ya,onPaneMouseMove:Xa,onPaneMouseLeave:Wa,onPaneScroll:Ga,onPaneContextMenu:qa,paneClickDistance:Ka=1,nodeClickDistance:Ua=0,children:Za,onReconnect:Qa,onReconnectStart:Ja,onReconnectEnd:ec,onEdgeContextMenu:tc,onEdgeDoubleClick:nc,onEdgeMouseEnter:rc,onEdgeMouseMove:oc,onEdgeMouseLeave:ic,reconnectRadius:sc=10,onNodesChange:ac,onEdgesChange:cc,noDragClassName:lc="nodrag",noWheelClassName:uc="nowheel",noPanClassName:Pr="nopan",fitView:Lr,fitViewOptions:$r,connectOnClick:dc,attributionPosition:fc,proOptions:hc,defaultEdgeOptions:gc,elevateNodesOnSelect:pc=!0,elevateEdgesOnSelect:mc=!1,disableKeyboardA11y:Dr=!1,autoPanOnConnect:yc,autoPanOnNodeDrag:xc,autoPanOnSelection:wc=!0,autoPanSpeed:vc,connectionRadius:bc,isValidConnection:Ec,onError:_c,style:Nc,id:jr,nodeDragThreshold:Sc,connectionDragThreshold:Cc,viewport:kc,onViewportChange:Mc,width:Ic,height:Ac,colorMode:Tc="light",debug:Oc,onScroll:$t,ariaLabelConfig:Pc,zIndexMode:Rr="basic",...Lc},$c){const Mn=jr||"1",Dc=ig(Tc),jc=D.useCallback(Hr=>{Hr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),$t==null||$t(Hr)},[$t]);return S.jsx("div",{"data-testid":"rf__wrapper",...Lc,onScroll:jc,style:{...Nc,...Op},ref:$c,className:se(["react-flow",o,Dc]),id:jr,role:"application",children:S.jsxs(Tp,{nodes:e,edges:t,width:Ic,height:Ac,fitView:Lr,fitViewOptions:$r,minZoom:ke,maxZoom:Me,nodeOrigin:Ce,nodeExtent:kn,zIndexMode:Rr,children:[S.jsx(og,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,nodesDraggable:re,autoPanOnNodeFocus:ue,nodesConnectable:ve,nodesFocusable:be,edgesFocusable:lt,edgesReconnectable:je,elementsSelectable:Re,elevateNodesOnSelect:pc,elevateEdgesOnSelect:mc,minZoom:ke,maxZoom:Me,nodeExtent:kn,onNodesChange:ac,onEdgesChange:cc,snapToGrid:Z,snapGrid:Q,connectionMode:F,translateExtent:He,connectOnClick:dc,defaultEdgeOptions:gc,fitView:Lr,fitViewOptions:$r,onNodesDelete:z,onEdgesDelete:O,onDelete:L,onNodeDragStart:k,onNodeDrag:M,onNodeDragStop:I,onSelectionDrag:_,onSelectionDragStart:y,onSelectionDragStop:C,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Pr,nodeOrigin:Ce,rfId:Mn,autoPanOnConnect:yc,autoPanOnNodeDrag:xc,autoPanSpeed:vc,onError:_c,connectionRadius:bc,isValidConnection:Ec,selectNodesOnDrag:ne,nodeDragThreshold:Sc,connectionDragThreshold:Cc,onBeforeDelete:j,debug:Oc,ariaLabelConfig:Pc,zIndexMode:Rr}),S.jsx(kp,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:E,onNodeDoubleClick:N,nodeTypes:i,edgeTypes:s,connectionLineType:H,connectionLineStyle:V,connectionLineComponent:Y,connectionLineContainerStyle:q,selectionKeyCode:G,selectionOnDrag:R,selectionMode:B,deleteKeyCode:J,multiSelectionKeyCode:U,panActivationKeyCode:K,zoomActivationKeyCode:X,onlyRenderVisibleElements:ee,defaultViewport:de,translateExtent:He,minZoom:ke,maxZoom:Me,preventScrolling:Cn,zoomOnScroll:Da,zoomOnPinch:ja,zoomOnDoubleClick:Fa,panOnScroll:Ra,panOnScrollSpeed:Ha,panOnScrollMode:za,panOnDrag:Ba,autoPanOnSelection:wc,onPaneClick:Va,onPaneMouseEnter:Ya,onPaneMouseMove:Xa,onPaneMouseLeave:Wa,onPaneScroll:Ga,onPaneContextMenu:qa,paneClickDistance:Ka,nodeClickDistance:Ua,onSelectionContextMenu:A,onSelectionStart:$,onSelectionEnd:T,onReconnect:Qa,onReconnectStart:Ja,onReconnectEnd:ec,onEdgeContextMenu:tc,onEdgeDoubleClick:nc,onEdgeMouseEnter:rc,onEdgeMouseMove:oc,onEdgeMouseLeave:ic,reconnectRadius:sc,defaultMarkerColor:$a,noDragClassName:lc,noWheelClassName:uc,noPanClassName:Pr,rfId:Mn,disableKeyboardA11y:Dr,nodeExtent:kn,viewport:kc,onViewportChange:Mc,nodesDraggable:re}),S.jsx(eg,{onSelectionChange:P}),Za,S.jsx(Kh,{proOptions:hc,position:fc}),S.jsx(qh,{rfId:Mn,disableKeyboardA11y:Dr})]})})}var Zy=Is(Pp);function Qy(){const e=oe();return D.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),o=Array.isArray(t)?t:[t],i=new Map;o.forEach(s=>{const a=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${s}"]`);a&&i.set(s,{id:s,nodeElement:a,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function Lp({dimensions:e,lineWidth:t,variant:n,className:r}){return S.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,r])})}function $p({radius:e,className:t}){return S.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var De;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(De||(De={}));const Dp={[De.Dots]:1,[De.Lines]:1,[De.Cross]:6},jp=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ta({id:e,variant:t=De.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:c,className:l,patternClassName:u}){const d=D.useRef(null),{transform:f,patternId:h}=te(jp,ie),g=r||Dp[t],v=t===De.Dots,w=t===De.Cross,m=Array.isArray(n)?n:[n,n],b=[m[0]*f[2]||1,m[1]*f[2]||1],p=g*f[2],x=Array.isArray(i)?i:[i,i],E=w?[p,p]:b,N=[x[0]*f[2]+E[0]/2,x[1]*f[2]+E[1]/2],k=`${h}${e||""}`;return S.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...En,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:d,"data-testid":"rf__background",children:[S.jsx("pattern",{id:k,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:v?S.jsx($p,{radius:p/2,className:u}):S.jsx(Lp,{dimensions:E,lineWidth:o,variant:t,className:u})}),S.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}ta.displayName="Background";D.memo(ta);function Rp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:S.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Hp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:S.jsx("path",{d:"M0 0h32v4.2H0z"})})}function zp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:S.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Fp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:S.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Bp(){return S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:S.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Yt({children:e,className:t,...n}){return S.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const Vp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function na({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:l,children:u,position:d="bottom-left",orientation:f="vertical","aria-label":h}){const g=oe(),{isInteractive:v,minZoomReached:w,maxZoomReached:m,ariaLabelConfig:b}=te(Vp,ie),{zoomIn:p,zoomOut:x,fitView:E}=Nr(),N=()=>{p(),i==null||i()},k=()=>{x(),s==null||s()},M=()=>{E(o),a==null||a()},I=()=>{g.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},z=f==="horizontal"?"horizontal":"vertical";return S.jsxs(bn,{className:se(["react-flow__controls",z,l]),position:d,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&S.jsxs(S.Fragment,{children:[S.jsx(Yt,{onClick:N,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:m,children:S.jsx(Rp,{})}),S.jsx(Yt,{onClick:k,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:w,children:S.jsx(Hp,{})})]}),n&&S.jsx(Yt,{className:"react-flow__controls-fitview",onClick:M,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:S.jsx(zp,{})}),r&&S.jsx(Yt,{className:"react-flow__controls-interactive",onClick:I,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:v?S.jsx(Bp,{}):S.jsx(Fp,{})}),u]})}na.displayName="Controls";D.memo(na);function Yp({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:h}){const{background:g,backgroundColor:v}=i||{},w=s||g||v;return S.jsx("rect",{className:se(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:o,style:{fill:w,stroke:a,strokeWidth:c},shapeRendering:d,onClick:h?m=>h(m,e):void 0})}const Xp=D.memo(Yp),Wp=e=>e.nodes.map(t=>t.id),Rn=e=>e instanceof Function?e:()=>e;function Gp({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Xp,onClick:s}){const a=te(Wp,ie),c=Rn(t),l=Rn(e),u=Rn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return S.jsx(S.Fragment,{children:a.map(f=>S.jsx(Kp,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:d},f))})}function qp({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:l,x:u,y:d,width:f,height:h}=te(g=>{const v=g.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:m,y:b}=v.internals.positionAbsolute,{width:p,height:x}=xe(w);return{node:w,x:m,y:b,width:p,height:x}},ie);return!l||l.hidden||!ns(l)?null:S.jsx(a,{x:u,y:d,width:f,height:h,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:o,strokeColor:n(l),strokeWidth:i,shapeRendering:s,onClick:c,id:l.id})}const Kp=D.memo(qp);var Up=D.memo(Gp);const Zp=200,Qp=150,Jp=e=>!e.hidden,e0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};let n=!1;for(const r of e.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Ji(Tt(e.nodeLookup,{filter:Jp}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},qo=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,t0=(e,t)=>qo(e.viewBB,t.viewBB)&&qo(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,n0="react-flow__minimap-desc";function ra({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:v=!1,zoomable:w=!1,ariaLabel:m,inversePan:b,zoomStep:p=1,offsetScale:x=5}){const E=oe(),N=D.useRef(null),{boundingRect:k,panZoom:M,viewBB:I,rfId:z,translateExtent:O,flowWidth:L,flowHeight:P,ariaLabelConfig:y}=te(e0,t0),_=(e==null?void 0:e.width)??Zp,C=(e==null?void 0:e.height)??Qp,A=k.width/_,$=k.height/C,T=Math.max(A,$),j=T*_,F=T*C,H=x*T,V=k.x-(j-k.width)/2-H,Y=k.y-(F-k.height)/2-H,q=j+H*2,J=F+H*2,G=`${n0}-${z}`,R=D.useRef(0),B=D.useRef();R.current=T,D.useEffect(()=>{const Q=E.getState().panZoom;if(N.current&&Q)return B.current=Eh({domNode:N.current,panZoom:Q,getTransform:()=>E.getState().transform,getViewScale:()=>R.current}),()=>{var ee;(ee=B.current)==null||ee.destroy()}},[M]),D.useEffect(()=>{var Q;(Q=B.current)==null||Q.update({translateExtent:O,width:L,height:P,inversePan:b,pannable:v,zoomStep:p,zoomable:w})},[v,w,b,p,O,L,P]);const K=h?Q=>{var re;const[ee,ne]=((re=B.current)==null?void 0:re.pointer(Q))||[0,0];h(Q,{x:ee,y:ne})}:void 0,U=D.useCallback((Q,ee)=>{const ne=E.getState().nodeLookup.get(ee).internals.userNode;g==null||g(Q,ne)},[g]),X=g?U:void 0,Z=m??y["minimap.ariaLabel"];return S.jsx(bn,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*T:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:S.jsxs("svg",{width:_,height:C,viewBox:`${V} ${Y} ${q} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":G,ref:N,onClick:K,children:[Z&&S.jsx("title",{id:G,children:Z}),S.jsx(Up,{onClick:X,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),S.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-H},${Y-H}h${q+H*2}v${J+H*2}h${-q-H*2}z
|
|
22
|
+
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ra.displayName="MiniMap";const Jy=D.memo(ra),r0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,o0={[st.Line]:"right",[st.Handle]:"bottom-right"};function i0({nodeId:e,position:t,variant:n=st.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:v,onResize:w,onResizeEnd:m}){const b=Ls(),p=typeof e=="string"?e:b,x=oe(),E=D.useRef(null),N=n===st.Handle,k=te(D.useCallback(r0(N&&h),[N,h]),ie),M=D.useRef(null),I=t??o0[n];D.useEffect(()=>{if(!(!E.current||!p))return M.current||(M.current=$h({domNode:E.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:O,transform:L,snapGrid:P,snapToGrid:y,nodeOrigin:_,domNode:C}=x.getState();return{nodeLookup:O,transform:L,snapGrid:P,snapToGrid:y,nodeOrigin:_,paneDomNode:C}},onChange:(O,L)=>{const{triggerNodeChanges:P,nodeLookup:y,parentLookup:_,nodeOrigin:C}=x.getState(),A=[],$={x:O.x,y:O.y},T=y.get(p);if(T&&T.expandParent&&T.parentId){const j=T.origin??C,F=O.width??T.measured.width??0,H=O.height??T.measured.height??0,V={id:T.id,parentId:T.parentId,rect:{width:F,height:H,...rs({x:O.x??T.position.x,y:O.y??T.position.y},{width:F,height:H},T.parentId,y,j)}},Y=_r([V],y,_,C);A.push(...Y),$.x=O.x?Math.max(j[0]*F,O.x):void 0,$.y=O.y?Math.max(j[1]*H,O.y):void 0}if($.x!==void 0&&$.y!==void 0){const j={id:p,type:"position",position:{...$}};A.push(j)}if(O.width!==void 0&&O.height!==void 0){const F={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};A.push(F)}for(const j of L){const F={...j,type:"position"};A.push(F)}P(A)},onEnd:({width:O,height:L})=>{const P={id:p,type:"dimensions",resizing:!1,dimensions:{width:O,height:L}};x.getState().triggerNodeChanges([P])}})),M.current.update({controlPosition:I,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:v,onResize:w,onResizeEnd:m,shouldResize:g}),()=>{var O;(O=M.current)==null||O.destroy()}},[I,a,c,l,u,d,v,w,m,g]);const z=I.split("-");return S.jsx("div",{className:se(["react-flow__resize-control","nodrag",...z,n,r]),ref:E,style:{...o,scale:k,...s&&{[N?"backgroundColor":"borderColor"]:s}},children:i})}D.memo(i0);const s0={source:{label:"Input source",helper:"The source badge (VIEW / TABLE / SQL / PATTERN / CONNECTOR) and its accent stripe"},fields:{label:"Field count",helper:"The field count shown on each object"},status:{label:"Status dot",helper:"The published/draft status dot in the card header"}};function a0({viewMode:e,onViewModeChange:t,direction:n,onDirectionChange:r,showJoinFields:o,onShowJoinFieldsChange:i,joinFieldsSwitchId:s,objectLabels:a,onObjectLabelsChange:c}){return S.jsxs(S.Fragment,{children:[S.jsx(In,{children:"View"}),S.jsx("div",{role:"radiogroup","aria-label":"Card view mode",className:"bg-muted mt-2 grid grid-cols-2 gap-0.5 rounded-md p-0.5",children:Xc.map(l=>S.jsx("button",{type:"button",role:"radio","aria-checked":e===l.value,className:`rounded px-2 py-1 text-sm transition-colors ${e===l.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{t(l.value)},children:l.label},l.value))}),S.jsx(In,{className:"mt-3 border-t pt-3",children:"Layout algorithm"}),S.jsx("div",{role:"radiogroup","aria-label":"Layout algorithm",className:"mt-2 space-y-0.5",children:Wc.map(l=>S.jsxs("button",{type:"button",role:"radio","aria-checked":n===l.value,className:"hover:bg-muted flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm",onClick:()=>{r(l.value)},children:[S.jsx("span",{children:l.label}),n===l.value&&S.jsx(zr,{className:"h-4 w-4"})]},l.value))}),S.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 border-t pt-3",children:[S.jsx("label",{htmlFor:s,className:"text-sm",children:"Show join fields"}),S.jsx(Gc,{id:s,checked:o,onCheckedChange:i})]}),S.jsx(In,{className:"mt-3 border-t pt-3",children:"Object labels"}),S.jsx("p",{className:"text-muted-foreground mt-1 text-xs leading-snug",children:"Tick what every object shows — untick to hide it."}),S.jsx("div",{className:"mt-2 space-y-0.5",children:qc.map(l=>{const u=s0[l],d=!a[l];return S.jsxs("button",{type:"button",role:"checkbox","aria-checked":d,className:"hover:bg-muted flex w-full items-start gap-2 rounded px-2 py-1.5 text-left",onClick:()=>{c(Kc(a,l))},children:[S.jsx("span",{className:`mt-0.5 flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border transition-colors ${d?"border-primary bg-primary text-primary-foreground":"border-input bg-background text-transparent"}`,"aria-hidden":"true",children:S.jsx(zr,{className:"h-2.5 w-2.5",strokeWidth:3.5})}),S.jsxs("span",{className:"flex min-w-0 flex-col",children:[S.jsx("span",{className:`text-sm font-medium ${d?"text-foreground":"text-muted-foreground"}`,children:u.label}),S.jsx("span",{className:"text-muted-foreground text-xs leading-snug",children:u.helper})]})]},l)})}),S.jsxs("div",{className:"mt-1 space-y-0.5 border-t pt-1",children:[S.jsxs("button",{type:"button","aria-pressed":Fr(a),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm font-medium ${Fr(a)?"bg-primary/10 text-primary":"text-foreground hover:bg-muted"}`,onClick:()=>{c(Uc)},children:[S.jsx("span",{className:"w-4 shrink-0 text-center font-bold","aria-hidden":"true",children:"≡"}),"Check all — show everything"]}),S.jsxs("button",{type:"button","aria-pressed":Br(a),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm font-medium ${Br(a)?"bg-primary/10 text-primary":"text-foreground hover:bg-muted"}`,onClick:()=>{c(Zc)},children:[S.jsx("span",{className:"w-4 shrink-0 text-center font-bold","aria-hidden":"true",children:"⊘"}),"Uncheck all — title only"]})]})]})}function ex(e){const t=D.useId();return S.jsxs(zc,{children:[S.jsx(Fc,{asChild:!0,children:S.jsx(Bc,{variant:"outline",size:"icon",className:"h-12 w-12","aria-label":"Canvas settings",children:S.jsx(Vc,{className:"h-6 w-6"})})}),S.jsx(Yc,{align:"end",side:"left",className:"w-56",children:S.jsx(a0,{...e,joinFieldsSwitchId:t})})]})}const Ke={gray:["#000000","#2C2C2C","#606060","#C5C5C5","#E6E6E6","#F7F7F7"],blue:["#4286DE","#609DE4","#86B5EA","#CEE2F7","#E6F0FA","#F2F7FC"],green:["#6ABA5C","#84C77A","#A0D49A","#D9EED7","#ECF7EA","#F5FBF5"],yellow:["#F5C344","#F7CF58","#F9DA7B","#FCF1C9","#FEF7E3","#FEFBF1"],orange:["#E9883C","#ED9F5C","#F0B782","#F8E1CA","#FBEFE3","#FDF6F0"],red:["#E15241","#E57164","#EA938A","#F6D4D0","#FAE8E6","#FCF3F2"],purple:["#9F4DB6","#B06FC4","#C393D2","#E7D4ED","#F3E9F6","#F9F4FB"]},c0=Ke.blue[0],oa=Ke.green[0],Cr=Ke.yellow[0],ia=Ke.orange[0],l0=Ke.red[0],u0=Ke.purple[0],sa=Ke.gray[2],aa=sa,tx=c0,nx=ia,rx="#0084ff",ox=aa,ix=1.5,sx=2.5,ax="8 4",d0=.15,cx={width:10,height:10,borderRadius:"50%",background:aa,border:"2px solid var(--background)"},lx={pointerEvents:"all",cursor:"default"},ux=`
|
|
23
23
|
@keyframes node-pulse {
|
|
24
24
|
0%, 100% { box-shadow: 0 0 0 3px rgba(66, 134, 222, 0.25), 0 0 12px rgba(66, 134, 222, 0.4); }
|
|
25
25
|
50% { box-shadow: 0 0 0 6px rgba(66, 134, 222, 0.15), 0 0 20px rgba(66, 134, 222, 0.5); }
|
|
26
26
|
}
|
|
27
|
-
`,dx={highlighted:!1,dimmed:!1};function fx(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 hx(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 gx(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 ca=Object.defineProperty,f0=(e,t,n)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h0=(e,t)=>{for(var n in t)ca(e,n,{get:t[n],enumerable:!0})},g0=(e,t,n)=>f0(e,t+"",n),la={};h0(la,{Graph:()=>we,alg:()=>Mr});var p0=Object.defineProperty,ua=(e,t)=>{for(var n in t)p0(e,n,{get:t[n],enumerable:!0})},Cr=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=pt(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=m0(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ko(this._preds[i],o),Ko(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?zn(this._isDirected,e):pt(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?zn(this._isDirected,e):pt(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?zn(this._isDirected,e):pt(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],Uo(this._preds[s],i),Uo(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 Ko(e,t){e[t]?e[t]++:e[t]=1}function Uo(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function pt(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 m0(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 zn(e,t){return pt(e,t.v,t.w,t.name)}var y0={};ua(y0,{read:()=>b0,write:()=>x0});function x0(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:w0(e),edges:v0(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function w0(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 v0(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 b0(e){let t=new Cr(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 Mr={};ua(Mr,{CycleException:()=>un,bellmanFord:()=>da,components:()=>N0,dijkstra:()=>ln,dijkstraAll:()=>C0,findCycles:()=>M0,floydWarshall:()=>A0,isAcyclic:()=>O0,postorder:()=>L0,preorder:()=>$0,prim:()=>j0,shortestPaths:()=>D0,tarjan:()=>ha,topsort:()=>ga});var E0=()=>1;function da(e,t,n,r){return _0(e,String(t),n||E0,r||function(o){var i;return(i=e.outEdges(o))!=null?i:[]})}function _0(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 N0(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 fa=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}},S0=()=>1;function ln(e,t,n,r){let o=function(i){var s;return(s=e.outEdges(i))!=null?s:[]};return k0(e,String(t),n||S0,r||o)}function k0(e,t,n,r){let o={},i=new fa,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 C0(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=ln(e,o,t,n),r},{})}function ha(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 M0(e){return ha(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 I0=()=>1;function A0(e,t,n){return T0(e,t||I0,n||function(r){var o;return(o=e.outEdges(r))!=null?o:[]})}function T0(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 un=class extends Error{constructor(e){super(e),this.name="CycleException"}};function ga(e){let t={},n={},r=[];function o(i){var s;if(i in n)throw new un;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 un;return r}function O0(e){try{ga(e)}catch(t){if(t instanceof un)return!1;throw t}return!0}function P0(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=pa(e,a,n==="post",s,i,r,o)}),o}function pa(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=pa(e,a,n,r,o,i,s)}),n&&(s=i(s,t))),s}function ma(e,t,n){return P0(e,t,n,function(r,o){return r.push(o),r},[])}function L0(e,t){return ma(e,t,"post")}function $0(e,t){return ma(e,t,"pre")}function j0(e,t){var n;let r=new Cr,o={},i=new fa,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 D0(e,t,n,r){return R0(e,t,n,r??(o=>{var i;return(i=e.outEdges(o))!=null?i:[]}))}function R0(e,t,n,r){if(n===void 0)return ln(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 da(e,t,n,r)}return ln(e,t,n,r)}var we=Cr;function ct(e,t,n,r){let o=r;for(;e.hasNode(o);)o=Ir(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 ya(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 Zo(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 Lt(e){let t=Ct(wa(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 H0(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 F0(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),ct(e,"border",o,t)}function B0(e,t=xa){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var xa=65535;function _e(e,t){if(t.length>xa){let n=B0(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function wa(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 V0(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Y0(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function va(e,t){return t()}var X0=0;function Ir(e){let t=++X0;return e+(""+t)}function Ct(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 dn(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Nn(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 W0(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Sn="\0";function ba(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 G0="3.1.1",q0=class{constructor(){g0(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Jo(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Jo(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,K0)),n=n._prev;return"["+e.join(", ")+"]"}};function Jo(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function K0(e,t){if(e!=="_next"&&e!=="_prev")return t}var U0=q0,Z0=()=>1;function Q0(e,t){if(e.nodeCount()<=1)return[];let n=em(e,t||Z0);return J0(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function J0(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)Hn(e,t,n,a);for(;a=i.dequeue();)Hn(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(Hn(e,t,n,a,!0)||[]);break}}}return o}function Hn(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,ir(t,n,l)}),(e.outEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=a.w,u=e.node(l);u.in-=c,ir(t,n,u)}),e.removeNode(r.v),s}function em(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=tm(o+r+3).map(()=>new U0),s=r+1;return n.nodes().forEach(a=>{ir(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function ir(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 tm(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function nm(e,t){(e.graph().acyclicer==="greedy"?Q0(e,n(e)):rm(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,Ir("rev"))});function n(r){return o=>r.edge(o).weight}}function rm(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)&&im(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 om(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 im(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 sm(e){e.graph().dummyChains=[],e.edges().forEach(t=>am(e,t))}function am(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=ct(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 cm(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 Ar(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 at(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Ea=lm;function lm(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(;um(t,e)<o&&(i=dm(t,e),!!i);)s=t.hasNode(i.v)?at(e,i):-at(e,i),fm(t,e,s);return t}function um(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)&&!at(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function dm(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=at(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function fm(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:hm,postorder:gm}=Mr,pm=Ue;Ue.initLowLimValues=Or;Ue.initCutValues=Tr;Ue.calcCutValue=_a;Ue.leaveEdge=Sa;Ue.enterEdge=ka;Ue.exchangeEdges=Ca;function Ue(e){e=z0(e),Ar(e);let t=Ea(e);Or(t),Tr(t,e);let n,r;for(;n=Sa(t);)r=ka(t,e,n),Ca(t,e,n,r)}function Tr(e,t){let n=gm(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>mm(e,t,r))}function mm(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=_a(e,t,n)}function _a(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,xm(e,n,u)){let h=e.edge(n,u).cutvalue;s+=d?-h:h}}}),s}function Or(e,t){arguments.length<2&&(t=e.nodes()[0]),Na(e,{},1,t)}function Na(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=Na(e,t,n,c,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function Sa(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function ka(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===ei(e,e.node(l.v),a)&&c!==ei(e,e.node(l.w),a)).reduce((l,u)=>at(t,u)<at(t,l)?u:l)}function Ca(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Or(e),Tr(e,t),ym(e,t)}function ym(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=hm(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 xm(e,t,n){return e.hasEdge(t,n)}function ei(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var wm=vm;function vm(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":ti(e);break;case"tight-tree":Em(e);break;case"longest-path":bm(e);break;case"none":break;default:ti(e)}}var bm=Ar;function Em(e){Ar(e),Ea(e)}function ti(e){pm(e)}var _m=Nm;function Nm(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=Sm(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 Sm(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(Sn).forEach(r),t}function Cm(e){let t=ct(e,"root",{},"_root"),n=Mm(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=Im(e)+1;e.children(Sn).forEach(a=>{Ma(e,t,i,s,o,n,a)}),e.graph().nodeRankFactor=i}function Ma(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;Ma(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 Mm(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(Sn).forEach(r=>n(r,1)),t}function Im(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Am(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Tm=Om;function Om(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)ni(e,"borderLeft","_bl",n,o,i),ni(e,"borderRight","_br",n,o,i)}}e.children(Sn).forEach(t)}function ni(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=ct(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}function Pm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&Ia(e)}function Lm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&$m(e),(n==="lr"||n==="rl")&&(jm(e),Ia(e))}function Ia(e){e.nodes().forEach(t=>ri(e.node(t))),e.edges().forEach(t=>ri(e.edge(t)))}function ri(e){let t=e.width;e.width=e.height,e.height=t}function $m(e){e.nodes().forEach(t=>Fn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Fn),Object.hasOwn(r,"y")&&Fn(r)})}function Fn(e){e.y=-e.y}function jm(e){e.nodes().forEach(t=>Bn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Bn),Object.hasOwn(r,"x")&&Bn(r)})}function Bn(e){let t=e.x;e.x=e.y,e.y=t}function Dm(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=Ct(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 ba(t,d,f)}return s}function Rm(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=W0(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 Hm(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 Fm(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 Bm(r)}function Bm(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Vm(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=>dn(o,["vs","i","barycenter","weight"]))}function Vm(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 Ym(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=V0(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(Xm(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=oi(f,d,v),u.forEach(m=>{v+=m.vs.length,f.push(m.vs),h+=m.barycenter*m.weight,g+=m.weight,v=oi(f,d,v)});let w={vs:f.flat(1)};return g&&(w.barycenter=h/g,w.weight=g),w}function oi(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 Xm(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=ba(t,i,s);if(a!==0)return a}return n?o.i-r.i:r.i-o.i}}function Aa(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,E=p?p.borderRight:void 0,N={};x&&(b=b.filter(L=>L!==x&&L!==E));let M=Hm(e,b);M.forEach(L=>{if(e.children(L.v).length){let{result:P}=Aa(e,L.v,n,w,m);N[L.v]=P,Object.hasOwn(P,"barycenter")&&Gm(L,P)}});let C=Fm(M,n);Wm(C,N);let I={},H=!1;for(let L=0;L<C.length;L++)for(let P=L+1;P<C.length;P++)if(!(!C[L]||!C[P]||!((i=C[L])!=null&&i.barycenter)||!((s=C[P])!=null&&s.barycenter))&&((a=C[L])==null?void 0:a.barycenter)===C[P].barycenter){let y=(l=(c=C[L])==null?void 0:c.vs[0])!=null?l:"",_=(d=(u=C[P])==null?void 0:u.vs[0])!=null?d:"",k=e.node(y),A=e.node(_);if(k.dummy==="edge"&&A.dummy==="edge"&&((f=k.edgeObj)==null?void 0:f.v)===((h=A.edgeObj)==null?void 0:h.v)&&((g=k.edgeObj)==null?void 0:g.w)===((v=A.edgeObj)==null?void 0:v.w))if(k.edgeLabel.reversed){I[_]=C[L],C.splice(L,1),L--;break}else I[y]=C[P],C.splice(P,1),P--;else H=!0}let O=Ym(C,I,w,e,m);if(x&&E){O.vs=[x,O.vs,E].flat(1);let L=e.predecessors(x);if(L&&L.length){let P=e.node(L[0]),y=e.predecessors(E),_=e.node(y[0]);Object.hasOwn(O,"barycenter")||(O.barycenter=0,O.weight=0),O.barycenter=(O.barycenter*O.weight+P.order+_.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:H,enumerable:!1,configurable:!0,writable:!0}),O}function Wm(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function Gm(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 qm(e,t,n,r){r||(r=e.nodes());let o=Km(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 Km(e){let t;for(;e.hasNode(t=Ir("_root")););return t}function Um(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 Ta(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,Ta);return}let r=wa(e),o=ii(e,Ct(1,r+1),"inEdges"),i=ii(e,Ct(r-1,-1,-1),"outEdges"),s=Dm(e,n);if(si(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,c,l=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){Zm(u%2?o:i,u%4>=2,l,n),s=Lt(e);let f=Rm(e,s);f<a?(d=0,c=Object.assign({},s),a=f):f===a&&(c=structuredClone(s))}si(e,c)}function ii(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 qm(e,i,n,r.get(i)||[])})}function Zm(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}=Aa(s,a,i,r,o);t&&l&&(o=!o),c.vs.forEach((u,d)=>s.node(u).order=d),Um(s,i,c.vs)})}function si(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function Qm(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=ey(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)&&Oa(n,w,g)})}),a=d+1,s=h)}),i}return t.length&&t.reduce(r),n}function Jm(e,t){let n={};function r(i,s,a,c,l){Ct(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)&&Oa(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 ey(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function Oa(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 ty(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 ny(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))||ai(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=>ai(p,e,o)));let m=w.sort((p,x)=>{let E=a[p],N=a[x];return(E!==void 0?E:0)-(N!==void 0?N:0)}),b=(m.length-1)/2;for(let p=Math.floor(b),x=Math.ceil(b);p<=x;++p){let E=m[p];if(E===void 0)continue;let N=a[E];if(N!==void 0&&s[g]===g&&l<N&&a[E]!==u&&!ty(n,g,E)){let M=i[E];M!==void 0&&(s[E]=g,s[g]=i[g]=M,l=N,d&&(l=-1,u=(v=a[E])!=null?v:-1,d=!1))}}}})}),{root:i,align:s}}function ry(e,t,n,r,o=!1){let i={},s=oy(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 oy(e,t,n,r){let o=new we,i=e.graph(),s=ly(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 iy(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=uy(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 sy(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]=Nn(c,d=>d+u))})})}function ay(e,t=void 0){let n=e.ul;return n?Nn(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 cy(e,t){let n=Lt(e),r=Object.assign(Qm(e,n),Jm(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=ny(e,i,r,d=>(a==="u"?e.predecessors(d):e.successors(d))||[],t),u=ry(e,i,l.root,l.align,c==="r");c==="r"&&(u=Nn(u,d=>-d)),o[a+c]=u})});let s=iy(e,o);return sy(o,s),ay(o,e.graph().align)}function ly(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 uy(e,t){return e.node(t).width}function ai(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 dy(e,t){e=ya(e),fy(e),Object.entries(cy(e,t)).forEach(([n,r])=>e.node(n).x=r)}function fy(e){let t=Lt(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 ci=new WeakMap;function hy(e,t={}){return Pa(e,va,t),e}function li(e,t,n){let r=t;for(;r!==void 0;){let o=e.parent(r);if(o===n)return r;r=o}}function Pa(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=e.children(b);E.forEach(y=>{let _={...e.node(y)};x.setNode(y,_);let k=e.parent(y);k&&k!==b&&E.includes(k)&&x.setParent(y,k)});let N=new Set;e.edges().forEach(y=>{let _=li(e,y.v,b),k=li(e,y.w,b);if(_&&k&&_!==k){let A=`${_}\0${k}`;N.has(A)||(N.add(A),x.setEdge(_,k,{...e.edge(y)}))}}),Pa(x,t,n);let M=hi(x);ui(M,t,n,null),di(x,M);let C=1/0,I=1/0,H=-1/0,O=-1/0;x.nodes().forEach(y=>{if(y===b)return;let _=x.node(y);_&&typeof _.x=="number"&&typeof _.y=="number"&&typeof _.width=="number"&&typeof _.height=="number"&&(C=Math.min(C,_.x-_.width/2),H=Math.max(H,_.x+_.width/2),I=Math.min(I,_.y-_.height/2),O=Math.max(O,_.y+_.height/2))}),(!isFinite(C)||!isFinite(I)||!isFinite(H)||!isFinite(O))&&(C=I=0,H=O=0);let L=H-C,P=O-I;i[b]={minX:C,minY:I,maxX:H,maxY:O,width:L,height:P,offsetX:C,offsetY:I},p._dagreClusterSubgraph=x}});let s=[],a=b=>{let p=[],x=(e.children(b)||[]).filter(E=>E!==b);for(;x.length>0;){let E=x.shift();p.push(E),(e.children(E)||[]).filter(N=>N!==E).forEach(N=>x.push(N))}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),E=[];b.forEach(C=>{let I=e.node(C);I&&(E.push({id:C,node:I,parent:g.get(C)}),e.removeNode(C))});let N=h.filter(({edge:C})=>b.includes(C.v)||b.includes(C.w)),M=i[p];x&&(s.push({clusterId:p,subgraph:x._dagreClusterSubgraph,bounds:M,children:b,removedNodes:E,removedEdges:N}),x.width=M.width,x.height=M.height)});let v=new Set;h.forEach(({edge:b,label:p})=>{let x=f(b.v),E=f(b.w);if(x!==E&&e.hasNode(x)&&e.hasNode(E)){let N=`${x}\0${E}`;v.has(N)||(v.add(N),e.setEdge(x,E,{...p,width:0,height:0}))}});let w=hi(e),m=ui(w,t,n,(r=ci.get(e))!=null?r:null);ci.set(e,m),di(e,w),v.forEach(b=>{let p=b.indexOf("\0"),x=b.slice(0,p),E=b.slice(p+1);e.hasEdge(x,E)&&e.removeEdge(x,E)}),s.forEach(({clusterId:b,subgraph:p,bounds:x,removedNodes:E,removedEdges:N})=>{var M,C;let I=e.node(b),H=(M=I==null?void 0:I.x)!=null?M:0,O=(C=I==null?void 0:I.y)!=null?C:0,L=(x.minX+x.maxX)/2,P=(x.minY+x.maxY)/2;E.forEach(({id:y,node:_,parent:k})=>{e.setNode(y,_),k!==void 0&&e.setParent(y,k)}),N.forEach(({edge:y,label:_})=>{e.setEdge(y,_)}),p.nodes().forEach(y=>{if(y===b)return;let _=p.node(y),k=e.node(y);k&&_&&typeof _.x=="number"&&typeof _.y=="number"&&(k.x=H+(_.x-L),k.y=O+(_.y-P))}),delete I._dagreClusterSubgraph}),o.forEach(b=>{var p,x;let E=e.node(b),N=i[b];if(E&&E.rankdir&&E._dagreClusterSubgraph&&N){let M=E._dagreClusterSubgraph,C=(p=E.x)!=null?p:0,I=(x=E.y)!=null?x:0,H=(N.minX+N.maxX)/2,O=(N.minY+N.maxY)/2;M.nodes().forEach(L=>{if(L===b)return;let P=M.node(L),y=e.node(L);if(y&&P&&typeof P.x=="number"&&typeof P.y=="number"){let _=P.x-H,k=P.y-O;y.x=C+_,y.y=I+k}}),delete E._dagreClusterSubgraph}})}function ui(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",()=>by(e)),t(" removeSelfEdges",()=>Ay(e)),t(" acyclic",()=>nm(e,a)),t(" nestingGraph.run",()=>Cm(e)),t(" rank",()=>wm(ya(e))),t(" injectEdgeLabelProxies",()=>Ey(e)),t(" removeEmptyRanks",()=>F0(e)),t(" nestingGraph.cleanup",()=>Am(e)),t(" normalizeRanks",()=>H0(e)),t(" assignRankMinMax",()=>_y(e)),t(" removeEdgeLabelProxies",()=>Ny(e)),t(" normalize.run",()=>sm(e)),t(" parentDummyChains",()=>_m(e)),t(" addBorderSegments",()=>Tm(e)),t(" order",()=>Ta(e,n,c)),t(" insertSelfEdges",()=>Ty(e)),t(" adjustCoordinateSystem",()=>Pm(e)),t(" position",()=>dy(e,n.corePath)),t(" positionSelfEdges",()=>Oy(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>Iy(e)),t(" normalize.undo",()=>cm(e)),t(" fixupEdgeLabelCoords",()=>Cy(e)),t(" undoCoordinateSystem",()=>Lm(e)),t(" translateGraph",()=>Sy(e)),t(" assignNodeIntersects",()=>ky(e)),t(" reversePoints",()=>My(e)),t(" acyclic.undo",()=>om(e)),{graph:e,rawNodes:l}}function di(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 gy=["nodesep","edgesep","ranksep","marginx","marginy"],py={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},my=["acyclicer","ranker","rankdir","align","rankalign"],yy=["width","height","rank"],fi={width:0,height:0},xy=["minlen","weight","width","height","labeloffset"],wy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},vy=["labelpos"];function hi(e){let t=new we({multigraph:!0,compound:!0}),n=Yn(e.graph());return t.setGraph(Object.assign({},py,Vn(n,gy),dn(n,my))),e.nodes().forEach(r=>{let o=Yn(e.node(r)),i=Vn(o,yy);Object.keys(fi).forEach(a=>{i[a]===void 0&&(i[a]=fi[a])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Yn(e.edge(r));t.setEdge(r,Object.assign({},wy,Vn(o,xy),dn(o,vy)))}),t}function by(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 Ey(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};ct(e,"edge-proxy",o,"_ep")}})}function _y(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 Ny(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 Sy(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(Zo(r,i)),n.points.push(Zo(o,s))})}function Cy(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 My(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Iy(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 Ay(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 Ty(e){Lt(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=>{ct(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 Oy(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 Vn(e,t){return Nn(dn(e,t),Number)}function Yn(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function Py(e){let t=Lt(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 Ly={graphlib:la,version:G0,layout:hy,debug:Py,util:{time:Y0,notime:va}},gi=Ly;/*! For license information please see dagre.esm.js.LEGAL.txt */const pi=80,$y=6.6,jy=18,Dy=16.5,Ry=8;function px(e){return e.length===0?void 0:{width:Math.max(...e.map(n=>n.length))*$y+jy,height:e.length*Dy+Ry}}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+pi),y:d*(i+pi)})}),n}function mx(e,t,n){const r=new Map,o=new Map,i=new Map;if(e.length===0)return{positions:r,routes:o,labelPositions:i};const s=new gi.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)}try{gi.layout(s)}catch(a){if(!(a instanceof RangeError))throw a;return{positions:zy(e,n),routes:o,labelPositions:i}}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){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}}const Hy={[ut.SQL]:oa,[ut.VIEW]:kr,[ut.TABLE]:u0,[ut.TABLE_PATTERN]:l0,[ut.CONNECTOR]:ia},mi=sa;function Fy(e){return e?Hy[e]??mi:mi}const yx=256,By=26,Vy=26,Yy=4;function Xy(e){return[...e.filter(t=>t.isPrimaryKey),...e.filter(t=>!t.isPrimaryKey)]}function La(e){const t=e.filter(n=>n.isPrimaryKey).length;return Math.min(e.length,Math.max(Yy,t))}function xx(e){if(e.length===0)return 0;const t=La(e),n=e.length>t;return t*By+(n?Vy:0)}function wx({markerId:e,color:t,withStart:n}){return S.jsxs("defs",{children:[S.jsx("marker",{id:`${e}-end`,markerWidth:"9",markerHeight:"9",refX:"7",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:S.jsx("path",{d:"M0,0 L7,3 L0,6 z",fill:t})}),n&&S.jsx("marker",{id:`${e}-start`,markerWidth:"9",markerHeight:"9",refX:"0",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:S.jsx("path",{d:"M7,0 L0,3 L7,6 z",fill:t})})]})}function vx({x:e,y:t,lines:n,selected:r,dimmed:o}){return n.length===0?null:S.jsx("foreignObject",{x:e,y:t,width:1,height:1,style:{overflow:"visible"},children:S.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?d0:1,transition:"opacity 0.2s",boxShadow:"0 1px 3px 0 rgba(0,0,0,0.08)"},children:n.map((i,s)=>S.jsx("div",{children:i},`${String(s)}-${i}`))})})}function bx(e,t){return`${e}-${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function Ex({isDraft:e,decorative:t=!1}){const n=e?"Draft":"Published";return S.jsxs("span",{className:"inline-flex shrink-0 items-center",title:n,children:[S.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:e?kr:oa},"aria-hidden":"true"}),!t&&S.jsx("span",{className:"sr-only",children:n})]})}function _x({type:e}){if(!e)return null;const t=Qc.getInfo(e),n=Fy(e),r=t.icon;return S.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white uppercase",style:{background:n},children:[S.jsx(r,{className:"h-2.5 w-2.5"}),t.displayName]})}function Wy({field:e}){return S.jsxs("div",{className:"border-border/50 flex items-center gap-2 border-b px-3.5 py-1.5 text-[11.5px] last:border-b-0",style:{opacity:e.isHidden?.5:1},title:e.isHidden?`${e.alias} (hidden from reporting)`:e.alias,children:[e.isPrimaryKey?S.jsx(tl,{className:"h-3 w-3 shrink-0",style:{color:kr},"aria-label":"Primary key"}):S.jsx("span",{className:"w-3 shrink-0"}),S.jsx("span",{className:"text-foreground flex-1 truncate",children:e.alias}),S.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-[10px] tracking-tight",children:e.type})]})}function Nx({fields:e,expanded:t,onToggleExpanded:n}){const r=Xy(e),o=La(e),i=t?r:r.slice(0,o),s=r.length-o;function a(c){c.stopPropagation(),c.preventDefault(),n()}return S.jsxs("div",{className:"border-t",children:[i.map(c=>S.jsx(Wy,{field:c},c.name)),s>0&&S.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:c=>{c.stopPropagation()},onClick:a,children:t?S.jsxs(S.Fragment,{children:[S.jsx(Jc,{className:"h-3 w-3"})," Show less"]}):S.jsxs(S.Fragment,{children:[S.jsx(el,{className:"h-3 w-3"})," +",s," more field",s!==1?"s":""]})})]})}export{vx as A,_n as B,ex as C,d0 as D,Ex as E,yx as F,xx as G,an as H,La as I,By as J,Vy as K,qy as L,Jy as M,ux as N,sa as O,G as P,cg as Q,Ap as R,cx as S,lg as T,Hf as U,nx as W,Ky as Z,_x as a,Nx as b,Nr as c,Fy as d,ee as e,hx as f,yr as g,fx as h,dx as i,gx as j,Uy as k,Zy as l,kr as m,tx as n,rx as o,px as p,lx as q,mx as r,ls as s,ox as t,Qy as u,bx as v,wx as w,ax as x,sx as y,ix as z};
|
|
27
|
+
`,dx={highlighted:!1,dimmed:!1};function fx(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 hx(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 gx(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 ca=Object.defineProperty,f0=(e,t,n)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h0=(e,t)=>{for(var n in t)ca(e,n,{get:t[n],enumerable:!0})},g0=(e,t,n)=>f0(e,t+"",n),la={};h0(la,{Graph:()=>we,alg:()=>Mr});var p0=Object.defineProperty,ua=(e,t)=>{for(var n in t)p0(e,n,{get:t[n],enumerable:!0})},kr=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=pt(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=m0(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ko(this._preds[i],o),Ko(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?Hn(this._isDirected,e):pt(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?Hn(this._isDirected,e):pt(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Hn(this._isDirected,e):pt(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],Uo(this._preds[s],i),Uo(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 Ko(e,t){e[t]?e[t]++:e[t]=1}function Uo(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function pt(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 m0(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 Hn(e,t){return pt(e,t.v,t.w,t.name)}var y0={};ua(y0,{read:()=>b0,write:()=>x0});function x0(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:w0(e),edges:v0(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function w0(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 v0(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 b0(e){let t=new kr(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 Mr={};ua(Mr,{CycleException:()=>un,bellmanFord:()=>da,components:()=>N0,dijkstra:()=>ln,dijkstraAll:()=>k0,findCycles:()=>M0,floydWarshall:()=>A0,isAcyclic:()=>O0,postorder:()=>L0,preorder:()=>$0,prim:()=>D0,shortestPaths:()=>j0,tarjan:()=>ha,topsort:()=>ga});var E0=()=>1;function da(e,t,n,r){return _0(e,String(t),n||E0,r||function(o){var i;return(i=e.outEdges(o))!=null?i:[]})}function _0(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 N0(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 fa=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}},S0=()=>1;function ln(e,t,n,r){let o=function(i){var s;return(s=e.outEdges(i))!=null?s:[]};return C0(e,String(t),n||S0,r||o)}function C0(e,t,n,r){let o={},i=new fa,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 k0(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=ln(e,o,t,n),r},{})}function ha(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 M0(e){return ha(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 I0=()=>1;function A0(e,t,n){return T0(e,t||I0,n||function(r){var o;return(o=e.outEdges(r))!=null?o:[]})}function T0(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 un=class extends Error{constructor(e){super(e),this.name="CycleException"}};function ga(e){let t={},n={},r=[];function o(i){var s;if(i in n)throw new un;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 un;return r}function O0(e){try{ga(e)}catch(t){if(t instanceof un)return!1;throw t}return!0}function P0(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=pa(e,a,n==="post",s,i,r,o)}),o}function pa(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=pa(e,a,n,r,o,i,s)}),n&&(s=i(s,t))),s}function ma(e,t,n){return P0(e,t,n,function(r,o){return r.push(o),r},[])}function L0(e,t){return ma(e,t,"post")}function $0(e,t){return ma(e,t,"pre")}function D0(e,t){var n;let r=new kr,o={},i=new fa,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 j0(e,t,n,r){return R0(e,t,n,r??(o=>{var i;return(i=e.outEdges(o))!=null?i:[]}))}function R0(e,t,n,r){if(n===void 0)return ln(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 da(e,t,n,r)}return ln(e,t,n,r)}var we=kr;function ct(e,t,n,r){let o=r;for(;e.hasNode(o);)o=Ir(r);return n.dummy=t,e.setNode(o,n),o}function H0(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 ya(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 Zo(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 Lt(e){let t=kt(wa(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 z0(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 F0(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),ct(e,"border",o,t)}function B0(e,t=xa){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var xa=65535;function _e(e,t){if(t.length>xa){let n=B0(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function wa(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 V0(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Y0(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function va(e,t){return t()}var X0=0;function Ir(e){let t=++X0;return e+(""+t)}function kt(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 dn(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Nn(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 W0(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Sn="\0";function ba(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 G0="3.1.1",q0=class{constructor(){g0(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Jo(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Jo(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,K0)),n=n._prev;return"["+e.join(", ")+"]"}};function Jo(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function K0(e,t){if(e!=="_next"&&e!=="_prev")return t}var U0=q0,Z0=()=>1;function Q0(e,t){if(e.nodeCount()<=1)return[];let n=em(e,t||Z0);return J0(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function J0(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)zn(e,t,n,a);for(;a=i.dequeue();)zn(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(zn(e,t,n,a,!0)||[]);break}}}return o}function zn(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,ir(t,n,l)}),(e.outEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),l=a.w,u=e.node(l);u.in-=c,ir(t,n,u)}),e.removeNode(r.v),s}function em(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=tm(o+r+3).map(()=>new U0),s=r+1;return n.nodes().forEach(a=>{ir(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function ir(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 tm(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function nm(e,t){(e.graph().acyclicer==="greedy"?Q0(e,n(e)):rm(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,Ir("rev"))});function n(r){return o=>r.edge(o).weight}}function rm(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)&&im(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 om(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 im(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 sm(e){e.graph().dummyChains=[],e.edges().forEach(t=>am(e,t))}function am(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=ct(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 cm(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 Ar(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 at(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Ea=lm;function lm(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(;um(t,e)<o&&(i=dm(t,e),!!i);)s=t.hasNode(i.v)?at(e,i):-at(e,i),fm(t,e,s);return t}function um(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)&&!at(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function dm(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=at(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function fm(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:hm,postorder:gm}=Mr,pm=Ue;Ue.initLowLimValues=Or;Ue.initCutValues=Tr;Ue.calcCutValue=_a;Ue.leaveEdge=Sa;Ue.enterEdge=Ca;Ue.exchangeEdges=ka;function Ue(e){e=H0(e),Ar(e);let t=Ea(e);Or(t),Tr(t,e);let n,r;for(;n=Sa(t);)r=Ca(t,e,n),ka(t,e,n,r)}function Tr(e,t){let n=gm(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>mm(e,t,r))}function mm(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=_a(e,t,n)}function _a(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,xm(e,n,u)){let h=e.edge(n,u).cutvalue;s+=d?-h:h}}}),s}function Or(e,t){arguments.length<2&&(t=e.nodes()[0]),Na(e,{},1,t)}function Na(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=Na(e,t,n,c,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function Sa(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Ca(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===ei(e,e.node(l.v),a)&&c!==ei(e,e.node(l.w),a)).reduce((l,u)=>at(t,u)<at(t,l)?u:l)}function ka(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Or(e),Tr(e,t),ym(e,t)}function ym(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=hm(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 xm(e,t,n){return e.hasEdge(t,n)}function ei(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var wm=vm;function vm(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":ti(e);break;case"tight-tree":Em(e);break;case"longest-path":bm(e);break;case"none":break;default:ti(e)}}var bm=Ar;function Em(e){Ar(e),Ea(e)}function ti(e){pm(e)}var _m=Nm;function Nm(e){let t=Cm(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(r=>{let o=e.node(r),i=o.edgeObj,s=Sm(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 Sm(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 Cm(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(Sn).forEach(r),t}function km(e){let t=ct(e,"root",{},"_root"),n=Mm(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=Im(e)+1;e.children(Sn).forEach(a=>{Ma(e,t,i,s,o,n,a)}),e.graph().nodeRankFactor=i}function Ma(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;Ma(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 Mm(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(Sn).forEach(r=>n(r,1)),t}function Im(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Am(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Tm=Om;function Om(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)ni(e,"borderLeft","_bl",n,o,i),ni(e,"borderRight","_br",n,o,i)}}e.children(Sn).forEach(t)}function ni(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=ct(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}function Pm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&Ia(e)}function Lm(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&$m(e),(n==="lr"||n==="rl")&&(Dm(e),Ia(e))}function Ia(e){e.nodes().forEach(t=>ri(e.node(t))),e.edges().forEach(t=>ri(e.edge(t)))}function ri(e){let t=e.width;e.width=e.height,e.height=t}function $m(e){e.nodes().forEach(t=>Fn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Fn),Object.hasOwn(r,"y")&&Fn(r)})}function Fn(e){e.y=-e.y}function Dm(e){e.nodes().forEach(t=>Bn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Bn),Object.hasOwn(r,"x")&&Bn(r)})}function Bn(e){let t=e.x;e.x=e.y,e.y=t}function jm(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=kt(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 ba(t,d,f)}return s}function Rm(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Hm(e,t[r-1],t[r]);return n}function Hm(e,t,n){let r=W0(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 zm(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 Fm(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 Bm(r)}function Bm(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&Vm(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=>dn(o,["vs","i","barycenter","weight"]))}function Vm(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 Ym(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=V0(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(Xm(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=oi(f,d,v),u.forEach(m=>{v+=m.vs.length,f.push(m.vs),h+=m.barycenter*m.weight,g+=m.weight,v=oi(f,d,v)});let w={vs:f.flat(1)};return g&&(w.barycenter=h/g,w.weight=g),w}function oi(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 Xm(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=ba(t,i,s);if(a!==0)return a}return n?o.i-r.i:r.i-o.i}}function Aa(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,E=p?p.borderRight:void 0,N={};x&&(b=b.filter(L=>L!==x&&L!==E));let k=zm(e,b);k.forEach(L=>{if(e.children(L.v).length){let{result:P}=Aa(e,L.v,n,w,m);N[L.v]=P,Object.hasOwn(P,"barycenter")&&Gm(L,P)}});let M=Fm(k,n);Wm(M,N);let I={},z=!1;for(let L=0;L<M.length;L++)for(let P=L+1;P<M.length;P++)if(!(!M[L]||!M[P]||!((i=M[L])!=null&&i.barycenter)||!((s=M[P])!=null&&s.barycenter))&&((a=M[L])==null?void 0:a.barycenter)===M[P].barycenter){let y=(l=(c=M[L])==null?void 0:c.vs[0])!=null?l:"",_=(d=(u=M[P])==null?void 0:u.vs[0])!=null?d:"",C=e.node(y),A=e.node(_);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[_]=M[L],M.splice(L,1),L--;break}else I[y]=M[P],M.splice(P,1),P--;else z=!0}let O=Ym(M,I,w,e,m);if(x&&E){O.vs=[x,O.vs,E].flat(1);let L=e.predecessors(x);if(L&&L.length){let P=e.node(L[0]),y=e.predecessors(E),_=e.node(y[0]);Object.hasOwn(O,"barycenter")||(O.barycenter=0,O.weight=0),O.barycenter=(O.barycenter*O.weight+P.order+_.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 Wm(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function Gm(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 qm(e,t,n,r){r||(r=e.nodes());let o=Km(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 Km(e){let t;for(;e.hasNode(t=Ir("_root")););return t}function Um(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 Ta(e,t={},n=null){if(typeof t.customOrder=="function"){t.customOrder(e,Ta);return}let r=wa(e),o=ii(e,kt(1,r+1),"inEdges"),i=ii(e,kt(r-1,-1,-1),"outEdges"),s=jm(e,n);if(si(e,s),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,c,l=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){Zm(u%2?o:i,u%4>=2,l,n),s=Lt(e);let f=Rm(e,s);f<a?(d=0,c=Object.assign({},s),a=f):f===a&&(c=structuredClone(s))}si(e,c)}function ii(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 qm(e,i,n,r.get(i)||[])})}function Zm(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}=Aa(s,a,i,r,o);t&&l&&(o=!o),c.vs.forEach((u,d)=>s.node(u).order=d),Um(s,i,c.vs)})}function si(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function Qm(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=ey(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)&&Oa(n,w,g)})}),a=d+1,s=h)}),i}return t.length&&t.reduce(r),n}function Jm(e,t){let n={};function r(i,s,a,c,l){kt(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)&&Oa(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 ey(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function Oa(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 ty(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 ny(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))||ai(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=>ai(p,e,o)));let m=w.sort((p,x)=>{let E=a[p],N=a[x];return(E!==void 0?E:0)-(N!==void 0?N:0)}),b=(m.length-1)/2;for(let p=Math.floor(b),x=Math.ceil(b);p<=x;++p){let E=m[p];if(E===void 0)continue;let N=a[E];if(N!==void 0&&s[g]===g&&l<N&&a[E]!==u&&!ty(n,g,E)){let k=i[E];k!==void 0&&(s[E]=g,s[g]=i[g]=k,l=N,d&&(l=-1,u=(v=a[E])!=null?v:-1,d=!1))}}}})}),{root:i,align:s}}function ry(e,t,n,r,o=!1){let i={},s=oy(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 oy(e,t,n,r){let o=new we,i=e.graph(),s=ly(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 iy(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=uy(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 sy(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]=Nn(c,d=>d+u))})})}function ay(e,t=void 0){let n=e.ul;return n?Nn(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 cy(e,t){let n=Lt(e),r=Object.assign(Qm(e,n),Jm(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=ny(e,i,r,d=>(a==="u"?e.predecessors(d):e.successors(d))||[],t),u=ry(e,i,l.root,l.align,c==="r");c==="r"&&(u=Nn(u,d=>-d)),o[a+c]=u})});let s=iy(e,o);return sy(o,s),ay(o,e.graph().align)}function ly(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 uy(e,t){return e.node(t).width}function ai(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 dy(e,t){e=ya(e),fy(e),Object.entries(cy(e,t)).forEach(([n,r])=>e.node(n).x=r)}function fy(e){let t=Lt(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 ci=new WeakMap;function hy(e,t={}){return Pa(e,va,t),e}function li(e,t,n){let r=t;for(;r!==void 0;){let o=e.parent(r);if(o===n)return r;r=o}}function Pa(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=e.children(b);E.forEach(y=>{let _={...e.node(y)};x.setNode(y,_);let C=e.parent(y);C&&C!==b&&E.includes(C)&&x.setParent(y,C)});let N=new Set;e.edges().forEach(y=>{let _=li(e,y.v,b),C=li(e,y.w,b);if(_&&C&&_!==C){let A=`${_}\0${C}`;N.has(A)||(N.add(A),x.setEdge(_,C,{...e.edge(y)}))}}),Pa(x,t,n);let k=hi(x);ui(k,t,n,null),di(x,k);let M=1/0,I=1/0,z=-1/0,O=-1/0;x.nodes().forEach(y=>{if(y===b)return;let _=x.node(y);_&&typeof _.x=="number"&&typeof _.y=="number"&&typeof _.width=="number"&&typeof _.height=="number"&&(M=Math.min(M,_.x-_.width/2),z=Math.max(z,_.x+_.width/2),I=Math.min(I,_.y-_.height/2),O=Math.max(O,_.y+_.height/2))}),(!isFinite(M)||!isFinite(I)||!isFinite(z)||!isFinite(O))&&(M=I=0,z=O=0);let L=z-M,P=O-I;i[b]={minX:M,minY:I,maxX:z,maxY:O,width:L,height:P,offsetX:M,offsetY:I},p._dagreClusterSubgraph=x}});let s=[],a=b=>{let p=[],x=(e.children(b)||[]).filter(E=>E!==b);for(;x.length>0;){let E=x.shift();p.push(E),(e.children(E)||[]).filter(N=>N!==E).forEach(N=>x.push(N))}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),E=[];b.forEach(M=>{let I=e.node(M);I&&(E.push({id:M,node:I,parent:g.get(M)}),e.removeNode(M))});let N=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:E,removedEdges:N}),x.width=k.width,x.height=k.height)});let v=new Set;h.forEach(({edge:b,label:p})=>{let x=f(b.v),E=f(b.w);if(x!==E&&e.hasNode(x)&&e.hasNode(E)){let N=`${x}\0${E}`;v.has(N)||(v.add(N),e.setEdge(x,E,{...p,width:0,height:0}))}});let w=hi(e),m=ui(w,t,n,(r=ci.get(e))!=null?r:null);ci.set(e,m),di(e,w),v.forEach(b=>{let p=b.indexOf("\0"),x=b.slice(0,p),E=b.slice(p+1);e.hasEdge(x,E)&&e.removeEdge(x,E)}),s.forEach(({clusterId:b,subgraph:p,bounds:x,removedNodes:E,removedEdges:N})=>{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,L=(x.minX+x.maxX)/2,P=(x.minY+x.maxY)/2;E.forEach(({id:y,node:_,parent:C})=>{e.setNode(y,_),C!==void 0&&e.setParent(y,C)}),N.forEach(({edge:y,label:_})=>{e.setEdge(y,_)}),p.nodes().forEach(y=>{if(y===b)return;let _=p.node(y),C=e.node(y);C&&_&&typeof _.x=="number"&&typeof _.y=="number"&&(C.x=z+(_.x-L),C.y=O+(_.y-P))}),delete I._dagreClusterSubgraph}),o.forEach(b=>{var p,x;let E=e.node(b),N=i[b];if(E&&E.rankdir&&E._dagreClusterSubgraph&&N){let k=E._dagreClusterSubgraph,M=(p=E.x)!=null?p:0,I=(x=E.y)!=null?x:0,z=(N.minX+N.maxX)/2,O=(N.minY+N.maxY)/2;k.nodes().forEach(L=>{if(L===b)return;let P=k.node(L),y=e.node(L);if(y&&P&&typeof P.x=="number"&&typeof P.y=="number"){let _=P.x-z,C=P.y-O;y.x=M+_,y.y=I+C}}),delete E._dagreClusterSubgraph}})}function ui(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",()=>by(e)),t(" removeSelfEdges",()=>Ay(e)),t(" acyclic",()=>nm(e,a)),t(" nestingGraph.run",()=>km(e)),t(" rank",()=>wm(ya(e))),t(" injectEdgeLabelProxies",()=>Ey(e)),t(" removeEmptyRanks",()=>F0(e)),t(" nestingGraph.cleanup",()=>Am(e)),t(" normalizeRanks",()=>z0(e)),t(" assignRankMinMax",()=>_y(e)),t(" removeEdgeLabelProxies",()=>Ny(e)),t(" normalize.run",()=>sm(e)),t(" parentDummyChains",()=>_m(e)),t(" addBorderSegments",()=>Tm(e)),t(" order",()=>Ta(e,n,c)),t(" insertSelfEdges",()=>Ty(e)),t(" adjustCoordinateSystem",()=>Pm(e)),t(" position",()=>dy(e,n.corePath)),t(" positionSelfEdges",()=>Oy(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>Iy(e)),t(" normalize.undo",()=>cm(e)),t(" fixupEdgeLabelCoords",()=>ky(e)),t(" undoCoordinateSystem",()=>Lm(e)),t(" translateGraph",()=>Sy(e)),t(" assignNodeIntersects",()=>Cy(e)),t(" reversePoints",()=>My(e)),t(" acyclic.undo",()=>om(e)),{graph:e,rawNodes:l}}function di(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 gy=["nodesep","edgesep","ranksep","marginx","marginy"],py={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},my=["acyclicer","ranker","rankdir","align","rankalign"],yy=["width","height","rank"],fi={width:0,height:0},xy=["minlen","weight","width","height","labeloffset"],wy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},vy=["labelpos"];function hi(e){let t=new we({multigraph:!0,compound:!0}),n=Yn(e.graph());return t.setGraph(Object.assign({},py,Vn(n,gy),dn(n,my))),e.nodes().forEach(r=>{let o=Yn(e.node(r)),i=Vn(o,yy);Object.keys(fi).forEach(a=>{i[a]===void 0&&(i[a]=fi[a])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Yn(e.edge(r));t.setEdge(r,Object.assign({},wy,Vn(o,xy),dn(o,vy)))}),t}function by(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 Ey(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};ct(e,"edge-proxy",o,"_ep")}})}function _y(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 Ny(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 Sy(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 Cy(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(Zo(r,i)),n.points.push(Zo(o,s))})}function ky(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 My(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Iy(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 Ay(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 Ty(e){Lt(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=>{ct(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 Oy(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 Vn(e,t){return Nn(dn(e,t),Number)}function Yn(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function Py(e){let t=Lt(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 Ly={graphlib:la,version:G0,layout:hy,debug:Py,util:{time:Y0,notime:va}},gi=Ly;/*! For license information please see dagre.esm.js.LEGAL.txt */const pi=80,$y=6.6,Dy=18,jy=16.5,Ry=8;function px(e){return e.length===0?void 0:{width:Math.max(...e.map(n=>n.length))*$y+Dy,height:e.length*jy+Ry}}function Hy(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+pi),y:d*(i+pi)})}),n}function mx(e,t,n){const r=new Map,o=new Map,i=new Map;if(e.length===0)return{positions:r,routes:o,labelPositions:i};const s=new gi.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)}try{gi.layout(s)}catch(a){if(!(a instanceof RangeError))throw a;return{positions:Hy(e,n),routes:o,labelPositions:i}}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){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}}const zy={[ut.SQL]:oa,[ut.VIEW]:Cr,[ut.TABLE]:u0,[ut.TABLE_PATTERN]:l0,[ut.CONNECTOR]:ia},mi=sa;function Fy(e){return e?zy[e]??mi:mi}const yx=256,By=26,Vy=26,Yy=4;function Xy(e){return[...e.filter(t=>t.isPrimaryKey),...e.filter(t=>!t.isPrimaryKey)]}function La(e){const t=e.filter(n=>n.isPrimaryKey).length;return Math.min(e.length,Math.max(Yy,t))}function xx(e){if(e.length===0)return 0;const t=La(e),n=e.length>t;return t*By+(n?Vy:0)}function wx({markerId:e,color:t,withStart:n}){return S.jsxs("defs",{children:[S.jsx("marker",{id:`${e}-end`,markerWidth:"9",markerHeight:"9",refX:"7",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:S.jsx("path",{d:"M0,0 L7,3 L0,6 z",fill:t})}),n&&S.jsx("marker",{id:`${e}-start`,markerWidth:"9",markerHeight:"9",refX:"0",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:S.jsx("path",{d:"M7,0 L0,3 L7,6 z",fill:t})})]})}function vx({x:e,y:t,lines:n,selected:r,dimmed:o}){return n.length===0?null:S.jsx("foreignObject",{x:e,y:t,width:1,height:1,style:{overflow:"visible"},children:S.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?d0:1,transition:"opacity 0.2s",boxShadow:"0 1px 3px 0 rgba(0,0,0,0.08)"},children:n.map((i,s)=>S.jsx("div",{children:i},`${String(s)}-${i}`))})})}function bx(e,t){return`${e}-${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function Ex({isDraft:e,decorative:t=!1}){const n=e?"Draft":"Published";return S.jsxs("span",{className:"inline-flex shrink-0 items-center",title:n,children:[S.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:e?Cr:oa},"aria-hidden":"true"}),!t&&S.jsx("span",{className:"sr-only",children:n})]})}function _x({type:e}){if(!e)return null;const t=Qc.getInfo(e),n=Fy(e),r=t.icon;return S.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white uppercase",style:{background:n},children:[S.jsx(r,{className:"h-2.5 w-2.5"}),t.displayName]})}function Wy({field:e}){return S.jsxs("div",{className:"border-border/50 flex items-center gap-2 border-b px-3.5 py-1.5 text-[11.5px] last:border-b-0",style:{opacity:e.isHidden?.5:1},title:e.isHidden?`${e.alias} (hidden from reporting)`:e.alias,children:[e.isPrimaryKey?S.jsx(tl,{className:"h-3 w-3 shrink-0",style:{color:Cr},"aria-label":"Primary key"}):S.jsx("span",{className:"w-3 shrink-0"}),S.jsx("span",{className:"text-foreground flex-1 truncate",children:e.alias}),S.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-[10px] tracking-tight",children:e.type})]})}function Nx({fields:e,expanded:t,onToggleExpanded:n}){const r=Xy(e),o=La(e),i=t?r:r.slice(0,o),s=r.length-o;function a(c){c.stopPropagation(),c.preventDefault(),n()}return S.jsxs("div",{className:"border-t",children:[i.map(c=>S.jsx(Wy,{field:c},c.name)),s>0&&S.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:c=>{c.stopPropagation()},onClick:a,children:t?S.jsxs(S.Fragment,{children:[S.jsx(Jc,{className:"h-3 w-3"})," Show less"]}):S.jsxs(S.Fragment,{children:[S.jsx(el,{className:"h-3 w-3"})," +",s," more field",s!==1?"s":""]})})]})}export{vx as A,_n as B,ex as C,d0 as D,Ex as E,yx as F,xx as G,an as H,La as I,By as J,Vy as K,qy as L,Jy as M,ux as N,sa as O,W as P,cg as Q,Ap as R,cx as S,lg as T,zf as U,nx as W,Ky as Z,_x as a,Nx as b,Nr as c,Fy as d,te as e,hx as f,yr as g,fx as h,dx as i,gx as j,Uy as k,Zy as l,Cr as m,tx as n,rx as o,px as p,lx as q,mx as r,ls as s,ox as t,Qy as u,bx as v,wx as w,ax as x,sx as y,ix as z};
|