bullpane 0.6.2 → 0.7.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.
@@ -0,0 +1,23 @@
1
+ import{ap as Eo,aq as ma,ar as ya,r as T,j as P,as as xa}from"./index-Dj9D1-XU.js";function Mg(e,t,n={}){const{columnGap:r=90,rowGap:o=28,nodeWidth:i=220,nodeHeight:s=84}=n,a=e.map(_=>_.id),c=new Set(a),u=new Map,f=new Map;a.forEach(_=>{u.set(_,[]),f.set(_,[])});for(const _ of t)!c.has(_.from)||!c.has(_.to)||_.from===_.to||(u.get(_.from).push(_.to),f.get(_.to).push(_.from));const d=new Map,l=new Map;a.forEach(_=>{d.set(_,0),l.set(_,[])});const h=_=>{d.set(_,1);for(const S of u.get(_)){const B=d.get(S);B!==1&&(l.get(_).push(S),B===0&&h(S))}d.set(_,2)},g=[...a].sort((_,S)=>f.get(_).length-f.get(S).length);for(const _ of g)d.get(_)===0&&h(_);const w=new Map;a.forEach(_=>w.set(_,[])),l.forEach((_,S)=>_.forEach(B=>w.get(B).push(S)));const x=new Map;a.forEach(_=>x.set(_,w.get(_).length));const m=new Map,b=a.filter(_=>x.get(_)===0);for(b.forEach(_=>m.set(_,0));b.length;){const _=b.shift();for(const S of l.get(_))m.set(S,Math.max(m.get(S)??0,(m.get(_)??0)+1)),x.set(S,x.get(S)-1),x.get(S)===0&&b.push(S)}a.forEach(_=>{m.has(_)||m.set(_,0)});const p=new Map;a.forEach(_=>{const S=m.get(_);p.has(S)||p.set(S,[]),p.get(S).push(_)});const v=Math.max(0,...p.keys()),N=new Map;for(let _=0;_<=v;_++){const S=p.get(_)??[];if(_===0)S.sort((B,$)=>l.get($).length-l.get(B).length||B.localeCompare($));else{const B=$=>{const R=w.get($).filter(D=>N.has(D));return R.length===0?Number.POSITIVE_INFINITY:R.reduce((D,y)=>D+N.get(y),0)/R.length};S.sort(($,R)=>{const D=B($),y=B(R);return D!==y?D-y:$.localeCompare(R)})}S.forEach((B,$)=>N.set(B,$))}const E=Math.max(1,...[...p.values()].map(_=>_.length)),M=new Map;return p.forEach((_,S)=>{const B=(E-_.length)*(s+o)/2;_.forEach($=>{const R=N.get($);M.set($,{id:$,depth:S,row:R,x:S*(i+r),y:B+R*(s+o)})})}),M}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 wa={value:()=>{}};function Qt(){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 Dt(n)}function Dt(e){this._=e}function va(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}})}Dt.prototype=Qt.prototype={constructor:Dt,on:function(e,t){var n=this._,r=va(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=ba(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]=hr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=hr(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 Dt(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 ba(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function hr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=wa,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Cn="http://www.w3.org/1999/xhtml";const gr={svg:"http://www.w3.org/2000/svg",xhtml:Cn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),gr.hasOwnProperty(t)?{space:gr[t],local:e}:e}function _a(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cn&&t.documentElement.namespaceURI===Cn?t.createElement(e):t.createElementNS(n,e)}}function Ea(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function So(e){var t=Jt(e);return(t.local?Ea:_a)(t)}function Sa(){}function Fn(e){return e==null?Sa:function(){return this.querySelector(e)}}function Na(e){typeof e!="function"&&(e=Fn(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,u,f=0;f<s;++f)(c=i[f])&&(u=e.call(c,c.__data__,f,i))&&("__data__"in c&&(u.__data__=c.__data__),a[f]=u);return new ue(r,this._parents)}function Ma(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ca(){return[]}function No(e){return e==null?Ca:function(){return this.querySelectorAll(e)}}function Ia(e){return function(){return Ma(e.apply(this,arguments))}}function Aa(e){typeof e=="function"?e=Ia(e):e=No(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,u=0;u<a;++u)(c=s[u])&&(r.push(e.call(c,c.__data__,u,s)),o.push(c));return new ue(r,o)}function Mo(e){return function(){return this.matches(e)}}function Co(e){return function(t){return t.matches(e)}}var ka=Array.prototype.find;function $a(e){return function(){return ka.call(this.children,e)}}function Pa(){return this.firstElementChild}function Ta(e){return this.select(e==null?Pa:$a(typeof e=="function"?e:Co(e)))}var za=Array.prototype.filter;function Da(){return Array.from(this.children)}function Ha(e){return function(){return za.call(this.children,e)}}function La(e){return this.selectAll(e==null?Da:Ha(typeof e=="function"?e:Co(e)))}function Ra(e){typeof e!="function"&&(e=Mo(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,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new ue(r,this._parents)}function Io(e){return new Array(e.length)}function Va(){return new ue(this._enter||this._groups.map(Io),this._parents)}function Bt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Bt.prototype={constructor:Bt,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 Ba(e){return function(){return e}}function Fa(e,t,n,r,o,i){for(var s=0,a,c=t.length,u=i.length;s<u;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new Bt(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Oa(e,t,n,r,o,i,s){var a,c,u=new Map,f=t.length,d=i.length,l=new Array(f),h;for(a=0;a<f;++a)(c=t[a])&&(l[a]=h=s.call(c,c.__data__,a,t)+"",u.has(h)?o[a]=c:u.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=u.get(h))?(r[a]=c,c.__data__=i[a],u.delete(h)):n[a]=new Bt(e,i[a]);for(a=0;a<f;++a)(c=t[a])&&u.get(l[a])===c&&(o[a]=c)}function ja(e){return e.__data__}function Xa(e,t){if(!arguments.length)return Array.from(this,ja);var n=t?Oa:Fa,r=this._parents,o=this._groups;typeof e!="function"&&(e=Ba(e));for(var i=o.length,s=new Array(i),a=new Array(i),c=new Array(i),u=0;u<i;++u){var f=r[u],d=o[u],l=d.length,h=Ya(e.call(f,f&&f.__data__,u,r)),g=h.length,w=a[u]=new Array(g),x=s[u]=new Array(g),m=c[u]=new Array(l);n(f,d,w,x,m,h,t);for(var b=0,p=0,v,N;b<g;++b)if(v=w[b]){for(b>=p&&(p=b+1);!(N=x[p])&&++p<g;);v._next=N||null}}return s=new ue(s,r),s._enter=a,s._exit=c,s}function Ya(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Wa(){return new ue(this._exit||this._groups.map(Io),this._parents)}function qa(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 Ga(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 u=n[c],f=r[c],d=u.length,l=a[c]=new Array(d),h,g=0;g<d;++g)(h=u[g]||f[g])&&(l[g]=h);for(;c<o;++c)a[c]=n[c];return new ue(a,this._parents)}function Za(){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 Ua(e){e||(e=Ka);function t(d,l){return d&&l?e(d.__data__,l.__data__):!d-!l}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),u,f=0;f<a;++f)(u=s[f])&&(c[f]=u);c.sort(t)}return new ue(o,this._parents).order()}function Ka(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Qa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ja(){return Array.from(this)}function ec(){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 tc(){let e=0;for(const t of this)++e;return e}function nc(){return!this.node()}function rc(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 oc(e){return function(){this.removeAttribute(e)}}function ic(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sc(e,t){return function(){this.setAttribute(e,t)}}function ac(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function cc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function uc(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 lc(e,t){var n=Jt(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?ic:oc:typeof t=="function"?n.local?uc:cc:n.local?ac:sc)(n,t))}function Ao(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function fc(e){return function(){this.style.removeProperty(e)}}function dc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function hc(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function gc(e,t,n){return arguments.length>1?this.each((t==null?fc:typeof t=="function"?hc:dc)(e,t,n??"")):Ke(this.node(),e)}function Ke(e,t){return e.style.getPropertyValue(t)||Ao(e).getComputedStyle(e,null).getPropertyValue(t)}function pc(e){return function(){delete this[e]}}function mc(e,t){return function(){this[e]=t}}function yc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function xc(e,t){return arguments.length>1?this.each((t==null?pc:typeof t=="function"?yc:mc)(e,t)):this.node()[e]}function ko(e){return e.trim().split(/^|\s+/)}function On(e){return e.classList||new $o(e)}function $o(e){this._node=e,this._names=ko(e.getAttribute("class")||"")}$o.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 Po(e,t){for(var n=On(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function To(e,t){for(var n=On(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function wc(e){return function(){Po(this,e)}}function vc(e){return function(){To(this,e)}}function bc(e,t){return function(){(t.apply(this,arguments)?Po:To)(this,e)}}function _c(e,t){var n=ko(e+"");if(arguments.length<2){for(var r=On(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?bc:t?wc:vc)(n,t))}function Ec(){this.textContent=""}function Sc(e){return function(){this.textContent=e}}function Nc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Mc(e){return arguments.length?this.each(e==null?Ec:(typeof e=="function"?Nc:Sc)(e)):this.node().textContent}function Cc(){this.innerHTML=""}function Ic(e){return function(){this.innerHTML=e}}function Ac(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function kc(e){return arguments.length?this.each(e==null?Cc:(typeof e=="function"?Ac:Ic)(e)):this.node().innerHTML}function $c(){this.nextSibling&&this.parentNode.appendChild(this)}function Pc(){return this.each($c)}function Tc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function zc(){return this.each(Tc)}function Dc(e){var t=typeof e=="function"?e:So(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Hc(){return null}function Lc(e,t){var n=typeof e=="function"?e:So(e),r=t==null?Hc:typeof t=="function"?t:Fn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Rc(){var e=this.parentNode;e&&e.removeChild(this)}function Vc(){return this.each(Rc)}function Bc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Oc(e){return this.select(e?Fc:Bc)}function jc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Xc(e){return function(t){e.call(this,t,this.__data__)}}function Yc(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 Wc(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 qc(e,t,n){return function(){var r=this.__on,o,i=Xc(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 Gc(e,t,n){var r=Yc(e+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,u=a.length,f;c<u;++c)for(o=0,f=a[c];o<i;++o)if((s=r[o]).type===f.type&&s.name===f.name)return f.value}return}for(a=t?qc:Wc,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function zo(e,t,n){var r=Ao(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 Zc(e,t){return function(){return zo(this,e,t)}}function Uc(e,t){return function(){return zo(this,e,t.apply(this,arguments))}}function Kc(e,t){return this.each((typeof t=="function"?Uc:Zc)(e,t))}function*Qc(){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 Do=[null];function ue(e,t){this._groups=e,this._parents=t}function wt(){return new ue([[document.documentElement]],Do)}function Jc(){return this}ue.prototype=wt.prototype={constructor:ue,select:Na,selectAll:Aa,selectChild:Ta,selectChildren:La,filter:Ra,data:Xa,enter:Va,exit:Wa,join:qa,merge:Ga,selection:Jc,order:Za,sort:Ua,call:Qa,nodes:Ja,node:ec,size:tc,empty:nc,each:rc,attr:lc,style:gc,property:xc,classed:_c,text:Mc,html:kc,raise:Pc,lower:zc,append:Dc,insert:Lc,remove:Vc,clone:Oc,datum:jc,on:Gc,dispatch:Kc,[Symbol.iterator]:Qc};function ce(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Do)}function eu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=eu(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 tu={passive:!1},lt={capture:!0,passive:!1};function gn(e){e.stopImmediatePropagation()}function Ze(e){e.preventDefault(),e.stopImmediatePropagation()}function Ho(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Ze,lt);"onselectstart"in t?n.on("selectstart.drag",Ze,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lo(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ze,lt),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 Mt=e=>()=>e;function In(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:u,dispatch:f}){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:u,enumerable:!0,configurable:!0},_:{value:f}})}In.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function nu(e){return!e.ctrlKey&&!e.button}function ru(){return this.parentNode}function ou(e,t){return t??{x:e.x,y:e.y}}function iu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ro(){var e=nu,t=ru,n=ou,r=iu,o={},i=Qt("start","drag","end"),s=0,a,c,u,f,d=0;function l(v){v.on("mousedown.drag",h).filter(r).on("touchstart.drag",x).on("touchmove.drag",m,tu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,N){if(!(f||!e.call(this,v,N))){var E=p(this,t.call(this,v,N),v,N,"mouse");E&&(ce(v.view).on("mousemove.drag",g,lt).on("mouseup.drag",w,lt),Ho(v.view),gn(v),u=!1,a=v.clientX,c=v.clientY,E("start",v))}}function g(v){if(Ze(v),!u){var N=v.clientX-a,E=v.clientY-c;u=N*N+E*E>d}o.mouse("drag",v)}function w(v){ce(v.view).on("mousemove.drag mouseup.drag",null),Lo(v.view,u),Ze(v),o.mouse("end",v)}function x(v,N){if(e.call(this,v,N)){var E=v.changedTouches,M=t.call(this,v,N),_=E.length,S,B;for(S=0;S<_;++S)(B=p(this,M,v,N,E[S].identifier,E[S]))&&(gn(v),B("start",v,E[S]))}}function m(v){var N=v.changedTouches,E=N.length,M,_;for(M=0;M<E;++M)(_=o[N[M].identifier])&&(Ze(v),_("drag",v,N[M]))}function b(v){var N=v.changedTouches,E=N.length,M,_;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),M=0;M<E;++M)(_=o[N[M].identifier])&&(gn(v),_("end",v,N[M]))}function p(v,N,E,M,_,S){var B=i.copy(),$=de(S||E,N),R,D,y;if((y=n.call(v,new In("beforestart",{sourceEvent:E,target:l,identifier:_,active:s,x:$[0],y:$[1],dx:0,dy:0,dispatch:B}),M))!=null)return R=y.x-$[0]||0,D=y.y-$[1]||0,function C(I,k,z){var A=$,H;switch(I){case"start":o[_]=C,H=s++;break;case"end":delete o[_],--s;case"drag":$=de(z||k,N),H=s;break}B.call(I,v,new In(I,{sourceEvent:k,subject:y,target:l,identifier:_,active:H,x:$[0]+R,y:$[1]+D,dx:$[0]-A[0],dy:$[1]-A[1],dispatch:B}),M)}}return l.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Mt(!!v),l):e},l.container=function(v){return arguments.length?(t=typeof v=="function"?v:Mt(v),l):t},l.subject=function(v){return arguments.length?(n=typeof v=="function"?v:Mt(v),l):n},l.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:Mt(!!v),l):r},l.on=function(){var v=i.on.apply(i,arguments);return v===i?l:v},l.clickDistance=function(v){return arguments.length?(d=(v=+v)*v,l):Math.sqrt(d)},l}function jn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Vo(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function vt(){}var ft=.7,Ft=1/ft,Ue="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",su=/^#([0-9a-f]{3,8})$/,au=new RegExp(`^rgb\\(${Ue},${Ue},${Ue}\\)$`),cu=new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`),uu=new RegExp(`^rgba\\(${Ue},${Ue},${Ue},${dt}\\)$`),lu=new RegExp(`^rgba\\(${_e},${_e},${_e},${dt}\\)$`),fu=new RegExp(`^hsl\\(${dt},${_e},${_e}\\)$`),du=new RegExp(`^hsla\\(${dt},${_e},${_e},${dt}\\)$`),pr={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};jn(vt,Oe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:mr,formatHex:mr,formatHex8:hu,formatHsl:gu,formatRgb:yr,toString:yr});function mr(){return this.rgb().formatHex()}function hu(){return this.rgb().formatHex8()}function gu(){return Bo(this).formatHsl()}function yr(){return this.rgb().formatRgb()}function Oe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=su.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?xr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Ct(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Ct(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=au.exec(e))?new ae(t[1],t[2],t[3],1):(t=cu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=uu.exec(e))?Ct(t[1],t[2],t[3],t[4]):(t=lu.exec(e))?Ct(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=fu.exec(e))?br(t[1],t[2]/100,t[3]/100,1):(t=du.exec(e))?br(t[1],t[2]/100,t[3]/100,t[4]):pr.hasOwnProperty(e)?xr(pr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function xr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Ct(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function pu(e){return e instanceof vt||(e=Oe(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function An(e,t,n,r){return arguments.length===1?pu(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}jn(ae,An,Vo(vt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,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),Ot(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:wr,formatHex:wr,formatHex8:mu,formatRgb:vr,toString:vr}));function wr(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function mu(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function vr(){const e=Ot(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Ot(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 Ve(e){return e=Be(e),(e<16?"0":"")+e.toString(16)}function br(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 Bo(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof vt||(e=Oe(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 yu(e,t,n,r){return arguments.length===1?Bo(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}jn(he,yu,Vo(vt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,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(pn(e>=240?e-240:e+120,o,r),pn(e,o,r),pn(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(_r(this.h),It(this.s),It(this.l),Ot(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=Ot(this.opacity);return`${e===1?"hsl(":"hsla("}${_r(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _r(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function pn(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 Xn=e=>()=>e;function xu(e,t){return function(n){return e+n*t}}function wu(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 vu(e){return(e=+e)==1?Fo:function(t,n){return n-t?wu(t,n,e):Xn(isNaN(t)?n:t)}}function Fo(e,t){var n=t-e;return n?xu(e,n):Xn(isNaN(e)?t:e)}const jt=(function e(t){var n=vu(t);function r(o,i){var s=n((o=An(o)).r,(i=An(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),u=Fo(o.opacity,i.opacity);return function(f){return o.r=s(f),o.g=a(f),o.b=c(f),o.opacity=u(f),o+""}}return r.gamma=e,r})(1);function bu(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 _u(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Eu(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]=ct(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 Su(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function be(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Nu(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]=ct(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var kn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(kn.source,"g");function Mu(e){return function(){return e}}function Cu(e){return function(t){return e(t)+""}}function Oo(e,t){var n=kn.lastIndex=mn.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=kn.exec(e))&&(o=mn.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:be(r,o)})),n=mn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?Cu(c[0].x):Mu(t):(t=c.length,function(u){for(var f=0,d;f<t;++f)a[(d=c[f]).i]=d.x(u);return a.join("")})}function ct(e,t){var n=typeof t,r;return t==null||n==="boolean"?Xn(t):(n==="number"?be:n==="string"?(r=Oe(t))?(t=r,jt):Oo:t instanceof Oe?jt:t instanceof Date?Su:_u(t)?bu:Array.isArray(t)?Eu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Nu:be)(e,t)}var Er=180/Math.PI,$n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function jo(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)*Er,skewX:Math.atan(c)*Er,scaleX:s,scaleY:a}}var At;function Iu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$n:jo(t.a,t.b,t.c,t.d,t.e,t.f)}function Au(e){return e==null||(At||(At=document.createElementNS("http://www.w3.org/2000/svg","g")),At.setAttribute("transform",e),!(e=At.transform.baseVal.consolidate()))?$n:(e=e.matrix,jo(e.a,e.b,e.c,e.d,e.e,e.f))}function Xo(e,t,n,r){function o(u){return u.length?u.pop()+" ":""}function i(u,f,d,l,h,g){if(u!==d||f!==l){var w=h.push("translate(",null,t,null,n);g.push({i:w-4,x:be(u,d)},{i:w-2,x:be(f,l)})}else(d||l)&&h.push("translate("+d+t+l+n)}function s(u,f,d,l){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),l.push({i:d.push(o(d)+"rotate(",null,r)-2,x:be(u,f)})):f&&d.push(o(d)+"rotate("+f+r)}function a(u,f,d,l){u!==f?l.push({i:d.push(o(d)+"skewX(",null,r)-2,x:be(u,f)}):f&&d.push(o(d)+"skewX("+f+r)}function c(u,f,d,l,h,g){if(u!==d||f!==l){var w=h.push(o(h)+"scale(",null,",",null,")");g.push({i:w-4,x:be(u,d)},{i:w-2,x:be(f,l)})}else(d!==1||l!==1)&&h.push(o(h)+"scale("+d+","+l+")")}return function(u,f){var d=[],l=[];return u=e(u),f=e(f),i(u.translateX,u.translateY,f.translateX,f.translateY,d,l),s(u.rotate,f.rotate,d,l),a(u.skewX,f.skewX,d,l),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,d,l),u=f=null,function(h){for(var g=-1,w=l.length,x;++g<w;)d[(x=l[g]).i]=x.x(h);return d.join("")}}}var ku=Xo(Iu,"px, ","px)","deg)"),$u=Xo(Au,", ",")",")"),Pu=1e-12;function Sr(e){return((e=Math.exp(e))+1/e)/2}function Tu(e){return((e=Math.exp(e))-1/e)/2}function zu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ht=(function e(t,n,r){function o(i,s){var a=i[0],c=i[1],u=i[2],f=s[0],d=s[1],l=s[2],h=f-a,g=d-c,w=h*h+g*g,x,m;if(w<Pu)m=Math.log(l/u)/t,x=function(M){return[a+M*h,c+M*g,u*Math.exp(t*M*m)]};else{var b=Math.sqrt(w),p=(l*l-u*u+r*w)/(2*u*n*b),v=(l*l-u*u-r*w)/(2*l*n*b),N=Math.log(Math.sqrt(p*p+1)-p),E=Math.log(Math.sqrt(v*v+1)-v);m=(E-N)/t,x=function(M){var _=M*m,S=Sr(N),B=u/(n*b)*(S*zu(t*_+N)-Tu(N));return[a+B*h,c+B*g,u*S/Sr(t*_+N)]}}return x.duration=m*1e3*t/Math.SQRT2,x}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 Qe=0,st=0,ot=0,Yo=1e3,Xt,at,Yt=0,je=0,en=0,ht=typeof performance=="object"&&performance.now?performance:Date,Wo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yn(){return je||(Wo(Du),je=ht.now()+en)}function Du(){je=0}function Wt(){this._call=this._time=this._next=null}Wt.prototype=qo.prototype={constructor:Wt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Yn():+n)+(t==null?0:+t),!this._next&&at!==this&&(at?at._next=this:Xt=this,at=this),this._call=e,this._time=n,Pn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Pn())}};function qo(e,t,n){var r=new Wt;return r.restart(e,t,n),r}function Hu(){Yn(),++Qe;for(var e=Xt,t;e;)(t=je-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qe}function Nr(){je=(Yt=ht.now())+en,Qe=st=0;try{Hu()}finally{Qe=0,Ru(),je=0}}function Lu(){var e=ht.now(),t=e-Yt;t>Yo&&(en-=t,Yt=e)}function Ru(){for(var e,t=Xt,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:Xt=n);at=e,Pn(r)}function Pn(e){if(!Qe){st&&(st=clearTimeout(st));var t=e-je;t>24?(e<1/0&&(st=setTimeout(Nr,e-ht.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Yt=ht.now(),ot=setInterval(Lu,Yo)),Qe=1,Wo(Nr))}}function Mr(e,t,n){var r=new Wt;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Vu=Qt("start","end","cancel","interrupt"),Bu=[],Go=0,Cr=1,Tn=2,Lt=3,Ir=4,zn=5,Rt=6;function tn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Fu(e,n,{name:t,index:r,group:o,on:Vu,tween:Bu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Go})}function Wn(e,t){var n=ye(e,t);if(n.state>Go)throw new Error("too late; already scheduled");return n}function Ee(e,t){var n=ye(e,t);if(n.state>Lt)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 Fu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=qo(i,0,n.time);function i(u){n.state=Cr,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var f,d,l,h;if(n.state!==Cr)return c();for(f in r)if(h=r[f],h.name===n.name){if(h.state===Lt)return Mr(s);h.state===Ir?(h.state=Rt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[f]):+f<t&&(h.state=Rt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[f])}if(Mr(function(){n.state===Lt&&(n.state=Ir,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=Tn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tn){for(n.state=Lt,o=new Array(l=n.tween.length),f=0,d=-1;f<l;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=h);o.length=d+1}}function a(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=zn,1),d=-1,l=o.length;++d<l;)o[d].call(e,f);n.state===zn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Rt,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function Vt(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>Tn&&r.state<zn,r.state=Rt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Ou(e){return this.each(function(){Vt(this,e)})}function ju(e,t){var n,r;return function(){var o=Ee(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 Xu(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Ee(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:t,value:n},c=0,u=o.length;c<u;++c)if(o[c].name===t){o[c]=a;break}c===u&&o.push(a)}i.tween=o}}function Yu(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?ju:Xu)(n,e,t))}function qn(e,t,n){var r=e._id;return e.each(function(){var o=Ee(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ye(o,r).value[t]}}function Zo(e,t){var n;return(typeof t=="number"?be:t instanceof Oe?jt:(n=Oe(t))?(t=n,jt):Oo)(e,t)}function Wu(e){return function(){this.removeAttribute(e)}}function qu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Gu(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 Zu(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 Uu(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 Ku(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 Qu(e,t){var n=Jt(e),r=n==="transform"?$u:Zo;return this.attrTween(e,typeof t=="function"?(n.local?Ku:Uu)(n,r,qn(this,"attr."+e,t)):t==null?(n.local?qu:Wu)(n):(n.local?Zu:Gu)(n,r,t))}function Ju(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function el(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function tl(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&el(e,i)),n}return o._value=t,o}function nl(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Ju(e,i)),n}return o._value=t,o}function rl(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=Jt(e);return this.tween(n,(r.local?tl:nl)(r,t))}function ol(e,t){return function(){Wn(this,e).delay=+t.apply(this,arguments)}}function il(e,t){return t=+t,function(){Wn(this,e).delay=t}}function sl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ol:il)(t,e)):ye(this.node(),t).delay}function al(e,t){return function(){Ee(this,e).duration=+t.apply(this,arguments)}}function cl(e,t){return t=+t,function(){Ee(this,e).duration=t}}function ul(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?al:cl)(t,e)):ye(this.node(),t).duration}function ll(e,t){if(typeof t!="function")throw new Error;return function(){Ee(this,e).ease=t}}function fl(e){var t=this._id;return arguments.length?this.each(ll(t,e)):ye(this.node(),t).ease}function dl(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ee(this,e).ease=n}}function hl(e){if(typeof e!="function")throw new Error;return this.each(dl(this._id,e))}function gl(e){typeof e!="function"&&(e=Mo(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,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new Ae(r,this._parents,this._name,this._id)}function pl(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],u=n[a],f=c.length,d=s[a]=new Array(f),l,h=0;h<f;++h)(l=c[h]||u[h])&&(d[h]=l);for(;a<r;++a)s[a]=t[a];return new Ae(s,this._parents,this._name,this._id)}function ml(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 yl(e,t,n){var r,o,i=ml(t)?Wn:Ee;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function xl(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(yl(n,e,t))}function wl(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function vl(){return this.on("end.remove",wl(this._id))}function bl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fn(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,u=i[s]=new Array(c),f,d,l=0;l<c;++l)(f=a[l])&&(d=e.call(f,f.__data__,l,a))&&("__data__"in f&&(d.__data__=f.__data__),u[l]=d,tn(u[l],t,n,l,u,ye(f,n)));return new Ae(i,this._parents,t,n)}function _l(e){var t=this._name,n=this._id;typeof e!="function"&&(e=No(e));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var c=r[a],u=c.length,f,d=0;d<u;++d)if(f=c[d]){for(var l=e.call(f,f.__data__,d,c),h,g=ye(f,n),w=0,x=l.length;w<x;++w)(h=l[w])&&tn(h,t,n,w,l,g);i.push(l),s.push(f)}return new Ae(i,s,t,n)}var El=wt.prototype.constructor;function Sl(){return new El(this._groups,this._parents)}function Nl(e,t){var n,r,o;return function(){var i=Ke(this,e),s=(this.style.removeProperty(e),Ke(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Uo(e){return function(){this.style.removeProperty(e)}}function Ml(e,t,n){var r,o=n+"",i;return function(){var s=Ke(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function Cl(e,t,n){var r,o,i;return function(){var s=Ke(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),Ke(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function Il(e,t){var n,r,o,i="style."+t,s="end."+i,a;return function(){var c=Ee(this,e),u=c.on,f=c.value[i]==null?a||(a=Uo(t)):void 0;(u!==n||o!==f)&&(r=(n=u).copy()).on(s,o=f),c.on=r}}function Al(e,t,n){var r=(e+="")=="transform"?ku:Zo;return t==null?this.styleTween(e,Nl(e,r)).on("end.style."+e,Uo(e)):typeof t=="function"?this.styleTween(e,Cl(e,r,qn(this,"style."+e,t))).each(Il(this._id,e)):this.styleTween(e,Ml(e,r,t),n).on("end.style."+e,null)}function kl(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function $l(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&kl(e,s,n)),r}return i._value=t,i}function Pl(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,$l(e,t,n??""))}function Tl(e){return function(){this.textContent=e}}function zl(e){return function(){var t=e(this);this.textContent=t??""}}function Dl(e){return this.tween("text",typeof e=="function"?zl(qn(this,"text",e)):Tl(e==null?"":e+""))}function Hl(e){return function(t){this.textContent=e.call(this,t)}}function Ll(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Hl(o)),t}return r._value=e,r}function Rl(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,Ll(e))}function Vl(){for(var e=this._name,t=this._id,n=Ko(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,u=0;u<a;++u)if(c=s[u]){var f=ye(c,t);tn(c,e,n,u,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Ae(r,this._parents,e,n)}function Bl(){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 u=Ee(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),u.on=t}),o===0&&i()})}var Fl=0;function Ae(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ko(){return++Fl}var Ce=wt.prototype;Ae.prototype={constructor:Ae,select:bl,selectAll:_l,selectChild:Ce.selectChild,selectChildren:Ce.selectChildren,filter:gl,merge:pl,selection:Sl,transition:Vl,call:Ce.call,nodes:Ce.nodes,node:Ce.node,size:Ce.size,empty:Ce.empty,each:Ce.each,on:xl,attr:Qu,attrTween:rl,style:Al,styleTween:Pl,text:Dl,textTween:Rl,remove:vl,tween:Yu,delay:sl,duration:ul,ease:fl,easeVarying:hl,end:Bl,[Symbol.iterator]:Ce[Symbol.iterator]};function Ol(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jl={time:null,delay:0,duration:250,ease:Ol};function Xl(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 Yl(e){var t,n;e instanceof Ae?(t=e._id,e=e._name):(t=Ko(),(n=jl).time=Yn(),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,u=0;u<a;++u)(c=s[u])&&tn(c,e,t,u,s,n||Xl(c,t));return new Ae(r,this._parents,e,t)}wt.prototype.interrupt=Ou;wt.prototype.transition=Yl;const kt=e=>()=>e;function Wl(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 Ie(e,t,n){this.k=e,this.x=t,this.y=n}Ie.prototype={constructor:Ie,scale:function(e){return e===1?this:new Ie(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ie(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 nn=new Ie(1,0,0);Qo.prototype=Ie.prototype;function Qo(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function yn(e){e.stopImmediatePropagation()}function it(e){e.preventDefault(),e.stopImmediatePropagation()}function ql(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Gl(){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 Ar(){return this.__zoom||nn}function Zl(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ul(){return navigator.maxTouchPoints||"ontouchstart"in this}function Kl(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 Jo(){var e=ql,t=Gl,n=Kl,r=Zl,o=Ul,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Ht,u=Qt("start","zoom","end"),f,d,l,h=500,g=150,w=0,x=10;function m(y){y.property("__zoom",Ar).on("wheel.zoom",_,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",B).filter(o).on("touchstart.zoom",$).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,C,I,k){var z=y.selection?y.selection():y;z.property("__zoom",Ar),y!==z?N(y,C,I,k):z.interrupt().each(function(){E(this,arguments).event(k).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},m.scaleBy=function(y,C,I,k){m.scaleTo(y,function(){var z=this.__zoom.k,A=typeof C=="function"?C.apply(this,arguments):C;return z*A},I,k)},m.scaleTo=function(y,C,I,k){m.transform(y,function(){var z=t.apply(this,arguments),A=this.__zoom,H=I==null?v(z):typeof I=="function"?I.apply(this,arguments):I,F=A.invert(H),V=typeof C=="function"?C.apply(this,arguments):C;return n(p(b(A,V),H,F),z,s)},I,k)},m.translateBy=function(y,C,I,k){m.transform(y,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),s)},null,k)},m.translateTo=function(y,C,I,k,z){m.transform(y,function(){var A=t.apply(this,arguments),H=this.__zoom,F=k==null?v(A):typeof k=="function"?k.apply(this,arguments):k;return n(nn.translate(F[0],F[1]).scale(H.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof I=="function"?-I.apply(this,arguments):-I),A,s)},k,z)};function b(y,C){return C=Math.max(i[0],Math.min(i[1],C)),C===y.k?y:new Ie(C,y.x,y.y)}function p(y,C,I){var k=C[0]-I[0]*y.k,z=C[1]-I[1]*y.k;return k===y.x&&z===y.y?y:new Ie(y.k,k,z)}function v(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function N(y,C,I,k){y.on("start.zoom",function(){E(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(k).end()}).tween("zoom",function(){var z=this,A=arguments,H=E(z,A).event(k),F=t.apply(z,A),V=I==null?v(F):typeof I=="function"?I.apply(z,A):I,j=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),X=z.__zoom,G=typeof C=="function"?C.apply(z,A):C,J=c(X.invert(V).concat(j/X.k),G.invert(V).concat(j/G.k));return function(q){if(q===1)q=G;else{var L=J(q),O=j/L[2];q=new Ie(O,V[0]-L[0]*O,V[1]-L[1]*O)}H.zoom(null,q)}})}function E(y,C,I){return!I&&y.__zooming||new M(y,C)}function M(y,C){this.that=y,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,C),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,C){return this.mouse&&y!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var C=ce(this.that).datum();u.call(y,this.that,new Wl(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:u}),C)}};function _(y,...C){if(!e.apply(this,arguments))return;var I=E(this,C).event(y),k=this.__zoom,z=Math.max(i[0],Math.min(i[1],k.k*Math.pow(2,r.apply(this,arguments)))),A=de(y);if(I.wheel)(I.mouse[0][0]!==A[0]||I.mouse[0][1]!==A[1])&&(I.mouse[1]=k.invert(I.mouse[0]=A)),clearTimeout(I.wheel);else{if(k.k===z)return;I.mouse=[A,k.invert(A)],Vt(this),I.start()}it(y),I.wheel=setTimeout(H,g),I.zoom("mouse",n(p(b(k,z),I.mouse[0],I.mouse[1]),I.extent,s));function H(){I.wheel=null,I.end()}}function S(y,...C){if(l||!e.apply(this,arguments))return;var I=y.currentTarget,k=E(this,C,!0).event(y),z=ce(y.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",j,!0),A=de(y,I),H=y.clientX,F=y.clientY;Ho(y.view),yn(y),k.mouse=[A,this.__zoom.invert(A)],Vt(this),k.start();function V(X){if(it(X),!k.moved){var G=X.clientX-H,J=X.clientY-F;k.moved=G*G+J*J>w}k.event(X).zoom("mouse",n(p(k.that.__zoom,k.mouse[0]=de(X,I),k.mouse[1]),k.extent,s))}function j(X){z.on("mousemove.zoom mouseup.zoom",null),Lo(X.view,k.moved),it(X),k.event(X).end()}}function B(y,...C){if(e.apply(this,arguments)){var I=this.__zoom,k=de(y.changedTouches?y.changedTouches[0]:y,this),z=I.invert(k),A=I.k*(y.shiftKey?.5:2),H=n(p(b(I,A),k,z),t.apply(this,C),s);it(y),a>0?ce(this).transition().duration(a).call(N,H,k,y):ce(this).call(m.transform,H,k,y)}}function $(y,...C){if(e.apply(this,arguments)){var I=y.touches,k=I.length,z=E(this,C,y.changedTouches.length===k).event(y),A,H,F,V;for(yn(y),H=0;H<k;++H)F=I[H],V=de(F,this),V=[V,this.__zoom.invert(V),F.identifier],z.touch0?!z.touch1&&z.touch0[2]!==V[2]&&(z.touch1=V,z.taps=0):(z.touch0=V,A=!0,z.taps=1+!!f);f&&(f=clearTimeout(f)),A&&(z.taps<2&&(d=V[0],f=setTimeout(function(){f=null},h)),Vt(this),z.start())}}function R(y,...C){if(this.__zooming){var I=E(this,C).event(y),k=y.changedTouches,z=k.length,A,H,F,V;for(it(y),A=0;A<z;++A)H=k[A],F=de(H,this),I.touch0&&I.touch0[2]===H.identifier?I.touch0[0]=F:I.touch1&&I.touch1[2]===H.identifier&&(I.touch1[0]=F);if(H=I.that.__zoom,I.touch1){var j=I.touch0[0],X=I.touch0[1],G=I.touch1[0],J=I.touch1[1],q=(q=G[0]-j[0])*q+(q=G[1]-j[1])*q,L=(L=J[0]-X[0])*L+(L=J[1]-X[1])*L;H=b(H,Math.sqrt(q/L)),F=[(j[0]+G[0])/2,(j[1]+G[1])/2],V=[(X[0]+J[0])/2,(X[1]+J[1])/2]}else if(I.touch0)F=I.touch0[0],V=I.touch0[1];else return;I.zoom("touch",n(p(H,F,V),I.extent,s))}}function D(y,...C){if(this.__zooming){var I=E(this,C).event(y),k=y.changedTouches,z=k.length,A,H;for(yn(y),l&&clearTimeout(l),l=setTimeout(function(){l=null},h),A=0;A<z;++A)H=k[A],I.touch0&&I.touch0[2]===H.identifier?delete I.touch0:I.touch1&&I.touch1[2]===H.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(H=de(H,this),Math.hypot(d[0]-H[0],d[1]-H[1])<x)){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:kt(+y),m):r},m.filter=function(y){return arguments.length?(e=typeof y=="function"?y:kt(!!y),m):e},m.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:kt(!!y),m):o},m.extent=function(y){return arguments.length?(t=typeof y=="function"?y:kt([[+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=u.on.apply(u,arguments);return y===u?m:y},m.clickDistance=function(y){return arguments.length?(w=(y=+y)*y,m):Math.sqrt(w)},m.tapDistance=function(y){return arguments.length?(x=+y,m):x},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.`},gt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ei=["Enter"," ","Escape"],ti={"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 Je;(function(e){e.Strict="strict",e.Loose="loose"})(Je||(Je={}));var Fe;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Fe||(Fe={}));var pt;(function(e){e.Partial="partial",e.Full="full"})(pt||(pt={}));const ni={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Te;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Te||(Te={}));var qt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qt||(qt={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const kr={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},ri=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Ql=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gn=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),bt=(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}},Jl=(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):Gn(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,rn(o,Gt(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?on(r):{x:0,y:0,width:0,height:0}},_t=(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=rn(n,Gt(o)),r=!0)}),r?on(n):{x:0,y:0,width:0,height:0}},Zn=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/o,c=(t.y-r)/o,u=t.width/o,f=t.height/o,d=[];for(const l of e.values()){const{measured:h,selectable:g=!0,hidden:w=!1}=l;if(s&&!g||w)continue;const x=h.width??l.width??l.initialWidth??0,m=h.height??l.height??l.initialHeight??0,{x:b,y:p}=l.internals.positionAbsolute,v=ai(a,c,u,f,b,p,x,m),N=x*m,E=i&&v>0;(!l.internals.handleBounds||E||v>=N||l.dragging)&&d.push(l)}return d},ef=(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 tf(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 nf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=tf(e,s),c=_t(a),u=Kn(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(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0}function oi({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:u}=a?a.internals.positionAbsolute:{x:0,y:0},f=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,u],[c+h,u+g]])}else a&&Ye(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const l=Ye(d)?Xe(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",me.error015())),{position:{x:l.x-c+(s.measured.width??0)*f[0],y:l.y-u+(s.measured.height??0)*f[1]},positionAbsolute:l}}async function rf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(l=>l.id)),s=[];for(const l of n){if(l.deletable===!1)continue;const h=i.has(l.id),g=!h&&l.parentId&&s.find(w=>w.id===l.parentId);(h||g)&&s.push(l)}const a=new Set(t.map(l=>l.id)),c=r.filter(l=>l.deletable!==!1),f=ef(s,c);for(const l of c)a.has(l.id)&&!f.find(g=>g.id===l.id)&&f.push(l);if(!o)return{edges:f,nodes:s};const d=await o({nodes:s,edges:f});return typeof d=="boolean"?d?{edges:f,nodes:s}:{edges:[],nodes:[]}:d}const et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Xe=(e={x:0,y:0},t,n)=>({x:et(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:et(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ii(e,t,n){const{width:r,height:o}=xe(n),{x:i,y:s}=n.internals.positionAbsolute;return Xe(e,[[i,s],[i+r,s+o]],t)}const $r=(e,t,n)=>e<t?et(Math.abs(e-t),1,t)/t:e>n?-et(Math.abs(e-n),1,t)/t:0,Un=(e,t,n=15,r=40)=>{const o=$r(e.x,r,t.width-r)*n,i=$r(e.y,r,t.height-r)*n;return[o,i]},rn=(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)}),Dn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),on=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),mt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Gn(e)?e.internals.positionAbsolute:bt(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}},Gt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Gn(e)?e.internals.positionAbsolute:bt(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)}},si=(e,t)=>on(rn(Dn(e),Dn(t))),ai=(e,t,n,r,o,i,s,a)=>{const c=Math.max(0,Math.min(e+n,o+s)-Math.max(e,o)),u=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(c*u)},Zt=(e,t)=>ai(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Pr=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ci=(e,t)=>(n,r)=>{},Et=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),St=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?Et(a,s):a},tt=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function qe(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 of(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=qe(e,n),o=qe(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=qe(e.top??e.y??0,n),o=qe(e.bottom??e.y??0,n),i=qe(e.left??e.x??0,t),s=qe(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 sf(e,t,n,r,o,i){const{x:s,y:a}=tt(e,[t,n,r]),{x:c,y:u}=tt({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=o-c,d=i-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(d)}}const Kn=(e,t,n,r,o,i)=>{const s=of(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),f=et(u,r,o),d=e.x+e.width/2,l=e.y+e.height/2,h=t/2-d*f,g=n/2-l*f,w=sf(e,h,g,f,t,n),x={left:Math.min(w.left-s.left,0),top:Math.min(w.top-s.top,0),right:Math.min(w.right-s.right,0),bottom:Math.min(w.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:f}},yt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ye(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 ui(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 li(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 Tr(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function af(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function cf(e){return{...ti,...e||{}}}function fi(e){return e===null?null:e?"valid":"invalid"}function ut(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=St({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:u}=n?Et(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const Qn=e=>({width:e.offsetWidth,height:e.offsetHeight}),di=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},uf=["INPUT","SELECT","TEXTAREA"];function hi(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:uf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const gi=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=gi(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)}},zr=(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,...Qn(s)}})};function pi({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,u=t*.125+i*.375+a*.375+r*.125,f=Math.abs(c-e),d=Math.abs(u-t);return[c,u,f,d]}function $t(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Dr({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-$t(t-r,i),n];case W.Right:return[t+$t(r-t,i),n];case W.Top:return[t,n-$t(n-o,i)];case W.Bottom:return[t,n+$t(o-n,i)]}}function mi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=Dr({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[u,f]=Dr({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,l,h,g]=pi({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${a},${c} ${u},${f} ${r},${o}`,d,l,h,g]}function yi({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 lf({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 ff({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=rn(Gt(e),Gt(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 Zt(s,on(i))>0}const df=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,hf=(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)),gf=(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||df;let o;return ri(e)?o={...e}:o={...e,id:r(e)},hf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function xi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=yi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const Hr={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},pf=({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},Lr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function mf({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=Hr[t],c=Hr[r],u={x:e.x+a.x*i,y:e.y+a.y*i},f={x:n.x+c.x*i,y:n.y+c.y*i},d=pf({source:u,sourcePosition:t,target:f}),l=d.x!==0?"x":"y",h=d[l];let g=[],w,x;const m={x:0,y:0},b={x:0,y:0},[,,p,v]=yi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[l]*c[l]===-1){l==="x"?(w=o.x??u.x+(f.x-u.x)*s,x=o.y??(u.y+f.y)/2):(w=o.x??(u.x+f.x)/2,x=o.y??u.y+(f.y-u.y)*s);const _=[{x:w,y:u.y},{x:w,y:f.y}],S=[{x:u.x,y:x},{x:f.x,y:x}];a[l]===h?g=l==="x"?_:S:g=l==="x"?S:_}else{const _=[{x:u.x,y:f.y}],S=[{x:f.x,y:u.y}];if(l==="x"?g=a.x===h?S:_:g=a.y===h?_:S,t===r){const y=Math.abs(e[l]-n[l]);if(y<=i){const C=Math.min(i-1,i-y);a[l]===h?m[l]=(u[l]>e[l]?-1:1)*C:b[l]=(f[l]>n[l]?-1:1)*C}}if(t!==r){const y=l==="x"?"y":"x",C=a[l]===c[y],I=u[y]>f[y],k=u[y]<f[y];(a[l]===1&&(!C&&I||C&&k)||a[l]!==1&&(!C&&k||C&&I))&&(g=l==="x"?_:S)}const B={x:u.x+m.x,y:u.y+m.y},$={x:f.x+b.x,y:f.y+b.y},R=Math.max(Math.abs(B.x-g[0].x),Math.abs($.x-g[0].x)),D=Math.max(Math.abs(B.y-g[0].y),Math.abs($.y-g[0].y));R>=D?(w=(B.x+$.x)/2,x=g[0].y):(w=g[0].x,x=(B.y+$.y)/2)}const N={x:u.x+m.x,y:u.y+m.y},E={x:f.x+b.x,y:f.y+b.y};return[[e,...N.x!==g[0].x||N.y!==g[0].y?[N]:[],...g,...E.x!==g[g.length-1].x||E.y!==g[g.length-1].y?[E]:[],n],w,x,p,v]}function yf(e,t,n,r){const o=Math.min(Lr(e,t)/2,Lr(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 u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+o*u},${s}Q ${i},${s} ${i},${s+o*f}`}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 Hn({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:f=.5}){const[d,l,h,g,w]=mf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:u,stepPosition:f});let x=`M${d[0].x} ${d[0].y}`;for(let m=1;m<d.length-1;m++)x+=yf(d[m-1],d[m],d[m+1],s);return x+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[x,l,h,g,w]}function Rr(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function xf(e){var d;const{sourceNode:t,targetNode:n}=e;if(!Rr(t)||!Rr(n))return null;const r=t.internals.handleBounds||Vr(t.handles),o=n.internals.handleBounds||Vr(n.handles),i=Br((r==null?void 0:r.source)??[],e.sourceHandle),s=Br(e.connectionMode===Je.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,u=We(t,i,a),f=We(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:c}}function Vr(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 We(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 Br(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ln(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function wf(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 u=Ln(c,t);i.has(u)||(s.push({id:u,color:c.color||n,...c}),i.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const wi=1e3,vf=10,Jn={nodeOrigin:[0,0],nodeExtent:gt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},bf={...Jn,checkEquality:!0};function er(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function _f(e,t,n){const r=er(Jn,n);for(const o of e.values())if(o.parentId)nr(o,e,t,r);else{const i=bt(o,r.nodeOrigin),s=Ye(o.extent)?o.extent:r.nodeExtent,a=Xe(i,s,xe(o));o.internals.positionAbsolute=a}}function Ef(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 tr(e){return e==="manual"}function Rn(e,t,n,r={}){var f,d;const o=er(bf,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!tr(o.zIndexMode)?wi:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const l of e){let h=s.get(l.id);if(o.checkEquality&&l===(h==null?void 0:h.internals.userNode))t.set(l.id,h);else{const g=bt(l,o.nodeOrigin),w=Ye(l.extent)?l.extent:o.nodeExtent,x=Xe(g,w,xe(l));h={...o.defaults,...l,measured:{width:(f=l.measured)==null?void 0:f.width,height:(d=l.measured)==null?void 0:d.height},internals:{positionAbsolute:x,handleBounds:Ef(l,h),z:vi(l,a,o.zIndexMode),userNode:l}},t.set(l.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),l.parentId&&nr(h,t,n,r,i),u||(u=l.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function Sf(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 nr(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=er(Jn,r),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Sf(e,n),o&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++o.i,f.internals.z=f.internals.z+o.i*vf),o&&f.internals.rootParentIndex!==void 0&&(o.i=f.internals.rootParentIndex);const d=i&&!tr(c)?wi:0,{x:l,y:h,z:g}=Nf(e,f,s,a,d,c),{positionAbsolute:w}=e.internals,x=l!==w.x||h!==w.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:l,y:h}:w,z:g}})}function vi(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return tr(n)?r:r+(e.selected?t:0)}function Nf(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),u=bt(e,n),f=Ye(e.extent)?Xe(u,e.extent,c):u;let d=Xe({x:s+f.x,y:a+f.y},r,c);e.extent==="parent"&&(d=ii(d,c,t));const l=vi(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=l?h+1:l}}function rr(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 u=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??mt(c),f=si(u,a.rect);i.set(a.parentId,{expandedRect:f,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},u)=>{var p;const f=c.internals.positionAbsolute,d=xe(c),l=c.origin??r,h=a.x<f.x?Math.round(Math.abs(f.x-a.x)):0,g=a.y<f.y?Math.round(Math.abs(f.y-a.y)):0,w=Math.max(d.width,Math.round(a.width)),x=Math.max(d.height,Math.round(a.height)),m=(w-d.width)*l[0],b=(x-d.height)*l[1];(h>0||g>0||m||b)&&(o.push({id:u,type:"position",position:{x:c.position.x-h+m,y:c.position.y-g+b}}),(p=n.get(u))==null||p.forEach(v=>{e.some(N=>N.id===v.id)||o.push({id:v.id,type:"position",position:{x:v.position.x+h,y:v.position.y+g}})})),(d.width<a.width||d.height<a.height||h||g)&&o.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:w+(h?l[0]*h-m:0),height:x+(g?l[1]*g-b:0)}})}),o}function Mf(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 u=[],f=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(f.transform),l=[];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 w=Qn(h.nodeElement),x=g.measured.width!==w.width||g.measured.height!==w.height;if(!!(w.width&&w.height&&(x||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ye(g.extent)?g.extent:i;let{positionAbsolute:v}=g.internals;if(g.parentId&&g.extent==="parent"){const E=t.get(g.parentId);E&&(v=ii(v,w,E))}else p&&(v=Xe(v,p,w));const N={...g,measured:w,internals:{...g.internals,positionAbsolute:v,handleBounds:{source:zr("source",h.nodeElement,b,d,g.id),target:zr("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,N),g.parentId&&nr(N,t,n,{nodeOrigin:o,zIndexMode:s}),c=!0,x&&(u.push({id:g.id,type:"dimensions",dimensions:w}),g.expandParent&&g.parentId&&l.push({id:g.id,parentId:g.parentId,rect:mt(N,o)}))}}if(l.length>0){const h=rr(l,t,n,o);u.push(...h)}return{changes:u,updatedInternals:c}}async function Cf({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 Fr(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 u=r.get(s)||new Map;r.set(s,u.set(n,t))}}function bi(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},u=`${o}-${s}--${i}-${a}`,f=`${i}-${a}--${o}-${s}`;Fr("source",c,f,e,o,s),Fr("target",c,u,e,i,a),t.set(r.id,r)}}function _i(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:_i(n,t):!1}function Or(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 If(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!_i(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 xn({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[u,f]of t){const d=(s=n.get(u))==null?void 0:s.internals.userNode;d&&o.push({...d,position:f.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 Af({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=Et(i,t);return{x:s.x-i.x,y:s.y-i.y}}function kf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},f=null,d=!1,l=null,h=!1,g=!1,w=null;function x({noDragClassName:b,handleSelector:p,domNode:v,isSelectable:N,nodeId:E,nodeClickDistance:M=0}){l=ce(v);function _({x:R,y:D}){const{nodeLookup:y,nodeExtent:C,snapGrid:I,snapToGrid:k,nodeOrigin:z,onNodeDrag:A,onSelectionDrag:H,onError:F,updateNodePositions:V}=t();i={x:R,y:D};let j=!1;const X=a.size>1,G=X&&C?Dn(_t(a)):null,J=X&&k?Af({dragItems:a,snapGrid:I,x:R,y:D}):null;for(const[q,L]of a){if(!y.has(q))continue;let O={x:R-L.distance.x,y:D-L.distance.y};k&&(O=J?{x:Math.round(O.x+J.x),y:Math.round(O.y+J.y)}:Et(O,I));let Z=null;if(X&&C&&!L.extent&&G){const{positionAbsolute:K}=L.internals,Q=K.x-G.x+C[0][0],ee=K.x+L.measured.width-G.x2+C[1][0],ne=K.y-G.y+C[0][1],re=K.y+L.measured.height-G.y2+C[1][1];Z=[[Q,ne],[ee,re]]}const{position:U,positionAbsolute:Y}=oi({nodeId:q,nextPosition:O,nodeLookup:y,nodeExtent:Z||C,nodeOrigin:z,onError:F});j=j||L.position.x!==U.x||L.position.y!==U.y,L.position=U,L.internals.positionAbsolute=Y}if(g=g||j,!!j&&(V(a,!0),w&&(r||A||!E&&H))){const[q,L]=xn({nodeId:E,dragItems:a,nodeLookup:y});r==null||r(w,a,q,L),A==null||A(w,q,L),E||H==null||H(w,L)}}async function S(){if(!f)return;const{transform:R,panBy:D,autoPanSpeed:y,autoPanOnNodeDrag:C}=t();if(!C){c=!1,cancelAnimationFrame(s);return}const[I,k]=Un(u,f,y);(I!==0||k!==0)&&(i.x=(i.x??0)-I/R[2],i.y=(i.y??0)-k/R[2],await D({x:I,y:k})&&_(i)),s=requestAnimationFrame(S)}function B(R){var X;const{nodeLookup:D,multiSelectionActive:y,nodesDraggable:C,transform:I,snapGrid:k,snapToGrid:z,selectNodesOnDrag:A,onNodeDragStart:H,onSelectionDragStart:F,unselectNodesAndEdges:V}=t();d=!0,(!A||!N)&&!y&&E&&((X=D.get(E))!=null&&X.selected||V()),N&&A&&E&&(e==null||e(E));const j=ut(R.sourceEvent,{transform:I,snapGrid:k,snapToGrid:z,containerBounds:f});if(i=j,a=If(D,C,j,E),a.size>0&&(n||H||!E&&F)){const[G,J]=xn({nodeId:E,dragItems:a,nodeLookup:D});n==null||n(R.sourceEvent,a,G,J),H==null||H(R.sourceEvent,G,J),E||F==null||F(R.sourceEvent,J)}}const $=Ro().clickDistance(M).on("start",R=>{const{domNode:D,nodeDragThreshold:y,transform:C,snapGrid:I,snapToGrid:k}=t();f=(D==null?void 0:D.getBoundingClientRect())||null,h=!1,g=!1,w=R.sourceEvent,y===0&&B(R),i=ut(R.sourceEvent,{transform:C,snapGrid:I,snapToGrid:k,containerBounds:f}),u=pe(R.sourceEvent,f)}).on("drag",R=>{const{autoPanOnNodeDrag:D,transform:y,snapGrid:C,snapToGrid:I,nodeDragThreshold:k,nodeLookup:z}=t(),A=ut(R.sourceEvent,{transform:y,snapGrid:C,snapToGrid:I,containerBounds:f});if(w=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||E&&!z.has(E))&&(h=!0),!h){if(!c&&D&&d&&(c=!0,S()),!d){const H=pe(R.sourceEvent,f),F=H.x-u.x,V=H.y-u.y;Math.sqrt(F*F+V*V)>k&&B(R)}(i.x!==A.xSnapped||i.y!==A.ySnapped)&&a&&d&&(u=pe(R.sourceEvent,f),_(A))}}).on("end",R=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:D,updateNodePositions:y,onNodeDragStop:C,onSelectionDragStop:I}=t();if(g&&(y(a,!1),g=!1),o||C||!E&&I){const[k,z]=xn({nodeId:E,dragItems:a,nodeLookup:D,dragging:!1});o==null||o(R.sourceEvent,a,k,z),C==null||C(R.sourceEvent,k,z),E||I==null||I(R.sourceEvent,z)}}}).filter(R=>{const D=R.target;return!R.button&&(!b||!Or(D,`.${b}`,v))&&(!p||Or(D,p,v))});l.call($)}function m(){l==null||l.on(".drag",null)}return{update:x,destroy:m}}function $f(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())Zt(o,mt(i))>0&&r.push(i);return r}const Pf=250;function Tf(e,t,n,r){var a,c;let o=[],i=1/0;const s=$f(e,n,t+Pf);for(const u of s){const f=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of f){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:l,y:h}=We(u,d,d.position,!0),g=Math.sqrt(Math.pow(l-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(o=[{...d,x:l,y:h}],i=g):g===i&&o.push({...d,x:l,y:h}))}}if(!o.length)return null;if(o.length>1){const u=r.type==="source"?"target":"source";return o.find(f=>f.type===u)??o[0]}return o[0]}function Ei(e,t,n,r,o,i=!1){var u,f,d;const s=r.get(e);if(!s)return null;const a=o==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(l=>l.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...We(s,c,c.position,!0)}:c}function Si(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function zf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ni=()=>!0;function Df(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:f,flowId:d,panBy:l,cancelConnection:h,onConnectStart:g,onConnect:w,onConnectEnd:x,isValidConnection:m=Ni,onReconnectEnd:b,updateConnection:p,getTransform:v,getFromHandle:N,autoPanSpeed:E,dragThreshold:M=1,handleDomNode:_}){const S=di(e.target);let B=0,$;const{x:R,y:D}=pe(e),y=Si(i,_),C=a==null?void 0:a.getBoundingClientRect();let I=!1;if(!C||!y)return;const k=Ei(o,y,r,c,t);if(!k)return;let z=pe(e,C),A=!1,H=null,F=!1,V=null;function j(){if(!f||!C)return;const[U,Y]=Un(z,C,E);l({x:U,y:Y}),B=requestAnimationFrame(j)}const X={...k,nodeId:o,type:y,position:k.position},G=c.get(o);let q={inProgress:!0,isValid:null,from:We(G,X,W.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:G,to:z,toHandle:null,toPosition:kr[X.position],toNode:null,pointer:z};function L(){I=!0,p(q),g==null||g(e,{nodeId:o,handleId:r,handleType:y})}M===0&&L();function O(U){if(!I){const{x:re,y:le}=pe(U),we=re-R,ve=le-D;if(!(we*we+ve*ve>M*M))return;L()}if(!N()||!X){Z(U);return}const Y=v();z=pe(U,C),$=Tf(St(z,Y,!1,[1,1]),n,c,X),A||(j(),A=!0);const K=Mi(U,{handle:$,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:S,lib:u,flowId:d,nodeLookup:c});V=K.handleDomNode,H=K.connection,F=zf(!!$,K.isValid);const Q=c.get(o),ee=Q?We(Q,X,W.Left,!0):q.from,ne={...q,from:ee,isValid:F,to:K.toHandle&&F?tt({x:K.toHandle.x,y:K.toHandle.y},Y):z,toHandle:K.toHandle,toPosition:F&&K.toHandle?K.toHandle.position:kr[X.position],toNode:K.toHandle?c.get(K.toHandle.nodeId):null,pointer:z};p(ne),q=ne}function Z(U){if(!("touches"in U&&U.touches.length>0)){if(I){($||V)&&H&&F&&(w==null||w(H));const{inProgress:Y,...K}=q,Q={...K,toPosition:q.toHandle?q.toPosition:null};x==null||x(U,Q),i&&(b==null||b(U,Q))}h(),cancelAnimationFrame(B),A=!1,F=!1,H=null,V=null,S.removeEventListener("mousemove",O),S.removeEventListener("mouseup",Z),S.removeEventListener("touchmove",O),S.removeEventListener("touchend",Z)}}S.addEventListener("mousemove",O),S.addEventListener("mouseup",Z),S.addEventListener("touchmove",O),S.addEventListener("touchend",Z)}function Mi(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:u=Ni,nodeLookup:f}){const d=i==="target",l=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),w=s.elementFromPoint(h,g),x=w!=null&&w.classList.contains(`${a}-flow__handle`)?w:l,m={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const b=Si(void 0,x),p=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),N=x.classList.contains("connectable"),E=x.classList.contains("connectableend");if(!p||!b)return m;const M={source:d?p:r,sourceHandle:d?v:o,target:d?r:p,targetHandle:d?o:v};m.connection=M;const S=N&&E&&(n===Je.Strict?d&&b==="source"||!d&&b==="target":p!==r||v!==o);m.isValid=S&&u(M),m.toHandle=Ei(p,b,v,f,n,!0)}return m}const Vn={onPointerDown:Df,isValid:Mi};function Hf({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:u,zoomStep:f=1,pannable:d=!0,zoomable:l=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const v=n(),N=p.sourceEvent.ctrlKey&&yt()?10:1,E=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*f,M=v[2]*Math.pow(2,E*N);t.scaleTo(M)};let w=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(w=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const v=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const N=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],E=[N[0]-w[0],N[1]-w[1]];w=N;const M=r()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),_={x:v[0]-E[0]*M,y:v[1]-E[1]*M},S=[[0,0],[c,u]];t.setViewportConstrained({x:_.x,y:_.y,zoom:v[2]},S,a)},b=Jo().on("start",x).on("zoom",d?m:null).on("zoom.wheel",l?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:de}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),wn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),Pe=(e,t)=>e.target.closest(`.${t}`),Ci=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Lf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,vn=(e,t=0,n=Lf,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},Ii=e=>{const t=e.ctrlKey&&yt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Rf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return f=>{if(Pe(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(f.ctrlKey&&s){const x=de(f),m=Ii(f),b=d*Math.pow(2,m);r.scaleTo(n,b,x,f);return}const l=f.deltaMode===1?20:1;let h=o===Fe.Vertical?0:f.deltaX*l,g=o===Fe.Horizontal?0:f.deltaY*l;!yt()&&f.shiftKey&&o!==Fe.Vertical&&(h=f.deltaY*l,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const w=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c==null||c(f,w):(e.isPanScrolling=!0,a==null||a(f,w)),e.panScrollTimeout=setTimeout(()=>{u==null||u(f,w),e.isPanScrolling=!1},150)}}function Vf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=Pe(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function Bf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=sn(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 Ff({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&Ci(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,sn(i.transform)))}}function Of({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&&Ci(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=sn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function jf({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:u,lib:f,connectionInProgress:d}){return l=>{var m;const h=t||n,g=r&&l.ctrlKey,w=l.type==="wheel";if(l.button===1&&l.type==="mousedown"&&(Pe(l,`${f}-flow__node`)||Pe(l,`${f}-flow__edge`)||Pe(l,`${f}-flow__selection`)||Pe(l,`${f}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!w||Pe(l,c)&&w||Pe(l,u)&&(!w||i&&w&&!t)||!r&&l.ctrlKey&&w)return!1;if(!r&&l.type==="touchstart"&&((m=l.touches)==null?void 0:m.length)>1)return l.preventDefault(),!1;if(!h&&!i&&!g&&w||!o&&(l.type==="mousedown"||l.type==="touchstart")||Array.isArray(o)&&!o.includes(l.button)&&l.type==="mousedown")return!1;const x=Array.isArray(o)&&o.includes(l.button)||!l.button||l.button<=1;return(!l.ctrlKey||w||e)&&x}}function Xf({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect();let d=[[0,0],[f.width,f.height]];const l=typeof ResizeObserver<"u"?new ResizeObserver(D=>{const y=D[0];y&&(d=[[0,0],[y.contentRect.width,y.contentRect.height]])}):null;l==null||l.observe(e);const h=Jo().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);v({x:o.x,y:o.y,zoom:et(o.zoom,t,n)},[[0,0],[f.width,f.height]],r);const w=g.on("wheel.zoom"),x=g.on("dblclick.zoom");h.wheelDelta(Ii);async function m(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).transform(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}function b({noWheelClassName:D,noPanClassName:y,onPaneContextMenu:C,userSelectionActive:I,panOnScroll:k,panOnDrag:z,panOnScrollMode:A,panOnScrollSpeed:H,preventScrolling:F,zoomOnPinch:V,zoomOnScroll:j,zoomOnDoubleClick:X,panActivationKeyPressed:G=!1,zoomActivationKeyPressed:J,lib:q,onTransformChange:L,connectionInProgress:O,paneClickDistance:Z,selectionOnDrag:U}){I&&!u.isZoomingOrPanning&&p();const Y=k&&!J&&!I;h.clickDistance(U?1/0:!ge(Z)||Z<0?0:Z);const K=Y?Rf({zoomPanValues:u,noWheelClassName:D,d3Selection:g,d3Zoom:h,panOnScrollMode:A,panOnScrollSpeed:H,zoomOnPinch:V,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Vf({noWheelClassName:D,preventScrolling:F,d3ZoomHandler:w});g.on("wheel.zoom",K,{passive:!1});const Q=Bf({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});h.on("start",Q);const ee=Ff({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!C,onPanZoom:i,onTransformChange:L});h.on("zoom",ee);const ne=Of({zoomPanValues:u,panOnDrag:z,panOnScroll:k,onPaneContextMenu:C,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=jf({panActivationKeyPressed:G,zoomActivationKeyPressed:J,panOnDrag:z,zoomOnScroll:j,panOnScroll:k,zoomOnDoubleClick:X,zoomOnPinch:V,userSelectionActive:I,noPanClassName:y,noWheelClassName:D,lib:q,connectionInProgress:O});h.filter(re),X?g.on("dblclick.zoom",x):g.on("dblclick.zoom",null)}function p(){h.on("zoom",null)}async function v(D,y,C){const I=wn(D),k=h==null?void 0:h.constrain()(I,y,C);return k&&await m(k),k}async function N(D,y){const C=wn(D);return await m(C,y),C}function E(D){if(g){const y=wn(D),C=g.property("__zoom");(C.k!==D.zoom||C.x!==D.x||C.y!==D.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function M(){const D=g?Qo(g.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}async function _(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).scaleTo(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}async function S(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).scaleBy(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}function B(D){h==null||h.scaleExtent(D)}function $(D){h==null||h.translateExtent(D)}function R(D){const y=!ge(D)||D<0?0:D;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:N,setViewportConstrained:v,getViewport:M,scaleTo:_,scaleBy:S,setScaleExtent:B,setTranslateExtent:$,syncViewport:E,setClickDistance:R}}var nt;(function(e){e.Line="line",e.Handle="handle"})(nt||(nt={}));function Yf({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 jr(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 ke(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function Pt(e,t,n){return Math.max(0,t-e,e-n)}function Xr(e,t){return e?!t:t}function Wf(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:f,isVertical:d}=t,l=f&&d,{xSnapped:h,ySnapped:g}=n,{minWidth:w,maxWidth:x,minHeight:m,maxHeight:b}=r,{x:p,y:v,width:N,height:E,aspectRatio:M}=e;let _=Math.floor(f?h-e.pointerX:0),S=Math.floor(d?g-e.pointerY:0);const B=N+(c?-_:_),$=E+(u?-S:S),R=-i[0]*N,D=-i[1]*E;let y=Pt(B,w,x),C=Pt($,m,b);if(s){let z=0,A=0;c&&_<0?z=ke(p+_+R,s[0][0]):!c&&_>0&&(z=$e(p+B+R,s[1][0])),u&&S<0?A=ke(v+S+D,s[0][1]):!u&&S>0&&(A=$e(v+$+D,s[1][1])),y=Math.max(y,z),C=Math.max(C,A)}if(a){let z=0,A=0;c&&_>0?z=$e(p+_,a[0][0]):!c&&_<0&&(z=ke(p+B,a[1][0])),u&&S>0?A=$e(v+S,a[0][1]):!u&&S<0&&(A=ke(v+$,a[1][1])),y=Math.max(y,z),C=Math.max(C,A)}if(o){if(f){const z=Pt(B/M,m,b)*M;if(y=Math.max(y,z),s){let A=0;!c&&!u||c&&!u&&l?A=$e(v+D+B/M,s[1][1])*M:A=ke(v+D+(c?_:-_)/M,s[0][1])*M,y=Math.max(y,A)}if(a){let A=0;!c&&!u||c&&!u&&l?A=ke(v+B/M,a[1][1])*M:A=$e(v+(c?_:-_)/M,a[0][1])*M,y=Math.max(y,A)}}if(d){const z=Pt($*M,w,x)/M;if(C=Math.max(C,z),s){let A=0;!c&&!u||u&&!c&&l?A=$e(p+$*M+R,s[1][0])/M:A=ke(p+(u?S:-S)*M+R,s[0][0])/M,C=Math.max(C,A)}if(a){let A=0;!c&&!u||u&&!c&&l?A=ke(p+$*M,a[1][0])/M:A=$e(p+(u?S:-S)*M,a[0][0])/M,C=Math.max(C,A)}}}S=S+(S<0?C:-C),_=_+(_<0?y:-y),o&&(l?B>$*M?S=(Xr(c,u)?-_:_)/M:_=(Xr(c,u)?-S:S)*M:f?(S=_/M,u=c):(_=S*M,c=u));const I=c?p+_:p,k=u?v+S:v;return{width:N+(c?-_:_),height:E+(u?-S:S),x:i[0]*_*(c?-1:1)+I,y:i[1]*S*(u?-1:1)+k}}const Ai={width:0,height:0,x:0,y:0},qf={...Ai,pointerX:0,pointerY:0,aspectRatio:1};function Gf(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 Zf({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:jr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:f,keepAspectRatio:d,resizeDirection:l,onResizeStart:h,onResize:g,onResizeEnd:w,shouldResize:x}){let m={...Ai},b={...qf};s={boundaries:f,resizeDirection:l,keepAspectRatio:d,controlDirection:jr(u)};let p,v=null,N=[],E,M,_,S=!1;const B=Ro().on("start",$=>{const{nodeLookup:R,transform:D,snapGrid:y,snapToGrid:C,nodeOrigin:I,paneDomNode:k}=n();if(p=R.get(t),!p)return;v=(k==null?void 0:k.getBoundingClientRect())??null;const{xSnapped:z,ySnapped:A}=ut($.sourceEvent,{transform:D,snapGrid:y,snapToGrid:C,containerBounds:v});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:z,pointerY:A,aspectRatio:m.width/m.height},E=void 0,M=Ye(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(E=R.get(p.parentId)),E&&p.extent==="parent"&&(M=[[0,0],[E.measured.width,E.measured.height]]),N=[],_=void 0;for(const[H,F]of R)if(F.parentId===t&&(N.push({id:H,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const V=Gf(F,p,F.origin??I);_?_=[[Math.min(V[0][0],_[0][0]),Math.min(V[0][1],_[0][1])],[Math.max(V[1][0],_[1][0]),Math.max(V[1][1],_[1][1])]]:_=V}h==null||h($,{...m})}).on("drag",$=>{const{transform:R,snapGrid:D,snapToGrid:y,nodeOrigin:C}=n(),I=ut($.sourceEvent,{transform:R,snapGrid:D,snapToGrid:y,containerBounds:v}),k=[];if(!p)return;const{x:z,y:A,width:H,height:F}=m,V={},j=p.origin??C,{width:X,height:G,x:J,y:q}=Wf(b,s.controlDirection,I,s.boundaries,s.keepAspectRatio,j,M,_),L=X!==H,O=G!==F,Z=J!==z&&L,U=q!==A&&O;if(!Z&&!U&&!L&&!O)return;if((Z||U||j[0]===1||j[1]===1)&&(V.x=Z?J:m.x,V.y=U?q:m.y,m.x=V.x,m.y=V.y,N.length>0)){const ee=J-z,ne=q-A;for(const re of N)re.position={x:re.position.x-ee+j[0]*(X-H),y:re.position.y-ne+j[1]*(G-F)},k.push(re)}if((L||O)&&(V.width=L&&(!s.resizeDirection||s.resizeDirection==="horizontal")?X:m.width,V.height=O&&(!s.resizeDirection||s.resizeDirection==="vertical")?G:m.height,m.width=V.width,m.height=V.height),E&&p.expandParent){const ee=j[0]*(V.width??0);V.x&&V.x<ee&&(m.x=ee,b.x=b.x-(V.x-ee));const ne=j[1]*(V.height??0);V.y&&V.y<ne&&(m.y=ne,b.y=b.y-(V.y-ne))}const Y=Yf({width:m.width,prevWidth:H,height:m.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),K={...m,direction:Y};(x==null?void 0:x($,K))!==!1&&(S=!0,g==null||g($,K),r(V,k))}).on("end",$=>{S&&(w==null||w($,{...m}),o==null||o({...m}),S=!1)});i.call(B)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var bn={exports:{}},_n={},En={exports:{}},Sn={};/**
2
+ * @license React
3
+ * use-sync-external-store-shim.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Yr;function Uf(){if(Yr)return Sn;Yr=1;var e=Eo();function t(d,l){return d===l&&(d!==0||1/d===1/l)||d!==d&&l!==l}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(d,l){var h=l(),g=r({inst:{value:h,getSnapshot:l}}),w=g[0].inst,x=g[1];return i(function(){w.value=h,w.getSnapshot=l,c(w)&&x({inst:w})},[d,h,l]),o(function(){return c(w)&&x({inst:w}),d(function(){c(w)&&x({inst:w})})},[d]),s(h),h}function c(d){var l=d.getSnapshot;d=d.value;try{var h=l();return!n(d,h)}catch{return!0}}function u(d,l){return l()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:a;return Sn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Sn}var Wr;function Kf(){return Wr||(Wr=1,En.exports=Uf()),En.exports}/**
10
+ * @license React
11
+ * use-sync-external-store-shim/with-selector.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var qr;function Qf(){if(qr)return _n;qr=1;var e=Eo(),t=Kf();function n(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return _n.useSyncExternalStoreWithSelector=function(u,f,d,l,h){var g=i(null);if(g.current===null){var w={hasValue:!1,value:null};g.current=w}else w=g.current;g=a(function(){function m(E){if(!b){if(b=!0,p=E,E=l(E),h!==void 0&&w.hasValue){var M=w.value;if(h(M,E))return v=M}return v=E}if(M=v,r(p,E))return M;var _=l(E);return h!==void 0&&h(M,_)?(p=E,M):(p=E,v=_)}var b=!1,p,v,N=d===void 0?null:d;return[function(){return m(f())},N===null?void 0:function(){return m(N())}]},[f,d,l,h]);var x=o(u,g[0],g[1]);return s(function(){w.hasValue=!0,w.value=x},[x]),c(x),x},_n}var Gr;function Jf(){return Gr||(Gr=1,bn.exports=Qf()),bn.exports}var ed=Jf();const td=ma(ed),nd={},Zr=e=>{let t;const n=new Set,r=(f,d)=>{const l=typeof f=="function"?f(t):f;if(!Object.is(l,t)){const h=t;t=d??(typeof l!="object"||l===null)?l:Object.assign({},t,l),n.forEach(g=>g(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(nd?"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()}},u=t=e(r,o,c);return c},rd=e=>e?Zr(e):Zr,{useDebugValue:od}=ya,{useSyncExternalStoreWithSelector:id}=td,sd=e=>e;function ki(e,t=sd,n){const r=id(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return od(r),r}const Ur=(e,t)=>{const n=rd(e),r=(o,i=t)=>ki(n,o,i);return Object.assign(r,n),r},ad=(e,t)=>e?Ur(e,t):Ur;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 an=T.createContext(null),cd=an.Provider,$i=me.error001("react");function te(e,t){const n=T.useContext(an);if(n===null)throw new Error($i);return ki(n,e,t)}function oe(){const e=T.useContext(an);if(e===null)throw new Error($i);return T.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Kr={display:"none"},ud={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Pi="react-flow__node-desc",Ti="react-flow__edge-desc",ld="react-flow__aria-live",fd=e=>e.ariaLiveMessage,dd=e=>e.ariaLabelConfig;function hd({rfId:e}){const t=te(fd);return P.jsx("div",{id:`${ld}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ud,children:t})}function gd({rfId:e,disableKeyboardA11y:t}){const n=te(dd);return P.jsxs(P.Fragment,{children:[P.jsx("div",{id:`${Pi}-${e}`,style:Kr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),P.jsx("div",{id:`${Ti}-${e}`,style:Kr,children:n["edge.a11yDescription.default"]}),!t&&P.jsx(hd,{rfId:e})]})}const cn=T.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return P.jsx("div",{className:se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});cn.displayName="Panel";const Qr="https://reactflow.dev?utm_source=attribution";function pd({proOptions:e,position:t="bottom-right"}){return T.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:P.jsx(cn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Qr}`,children:P.jsx("a",{href:Qr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const md=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}},Tt=e=>e.id;function yd(e,t){return ie(e.selectedNodes.map(Tt),t.selectedNodes.map(Tt))&&ie(e.selectedEdges.map(Tt),t.selectedEdges.map(Tt))}function xd({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=te(md,yd);return T.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const wd=e=>!!e.onSelectionChangeHandlers;function vd({onSelectionChange:e}){const t=te(wd);return e||t?P.jsx(xd,{onSelectionChange:e}):null}const zi=[0,0],bd={x:0,y:0,zoom:1},_d=["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"],Jr=[..._d,"rfId"],Ed=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}),eo={translateExtent:gt,nodeOrigin:zi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Sd(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(Ed,ie),u=oe();T.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=eo,a()}),[]);const f=T.useRef(eo);return T.useEffect(()=>{for(const d of Jr){const l=e[d],h=f.current[d];l!==h&&(typeof e[d]>"u"||(d==="nodes"?t(l):d==="edges"?n(l):d==="minZoom"?r(l):d==="maxZoom"?o(l):d==="translateExtent"?i(l):d==="nodeExtent"?s(l):d==="ariaLabelConfig"?u.setState({ariaLabelConfig:cf(l)}):d==="fitView"?u.setState({fitViewQueued:l}):d==="fitViewOptions"?u.setState({fitViewOptions:l}):u.setState({[d]:l})))}f.current=e},Jr.map(d=>e[d])),null}function to(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Nd(e){var r;const[t,n]=T.useState(e==="system"?null:e);return T.useEffect(()=>{if(e!=="system"){n(e);return}const o=to(),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=to())!=null&&r.matches?"dark":"light"}const no=typeof document<"u"?document:null;function xt(e=null,t={target:no,actInsideInputWithModifier:!0}){const[n,r]=T.useState(!1),o=T.useRef(!1),i=T.useRef(new Set([])),[s,a]=T.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace(/\+/g,`
18
+ `).replace(`
19
+
20
+ `,`
21
+ +`).split(`
22
+ `)),f=u.reduce((d,l)=>d.concat(...l),[]);return[u,f]}return[[],[]]},[e]);return T.useEffect(()=>{const c=(t==null?void 0:t.target)??no,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=h=>{var x,m;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!u)&&hi(h))return!1;const w=oo(h.code,a);if(i.current.add(h[w]),ro(s,i.current,!1)){const b=((m=(x=h.composedPath)==null?void 0:x.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=oo(h.code,a);ro(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},l=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",l),window.addEventListener("contextmenu",l),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",l),window.removeEventListener("contextmenu",l)}}},[e,r]),n}function ro(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function oo(e,t){return t.includes(e)?"code":"key"}const Md=()=>{const e=oe();return T.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=Kn(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(),u={x:t.x-a,y:t.y-c},f=n.snapGrid??o,d=n.snapToGrid??i;return St(u,r,d,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=tt(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function Di(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)Cd(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 Cd(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 Hi(e,t){return Di(e,t)}function Li(e,t){return Di(e,t)}function Re(e,t){return{id:e,type:"select",selected:t}}function Ge(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(Re(i.id,s)))}return r}function io({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 so(e){return{id:e.id,type:"remove"}}const Id=ci();function Ad(e,t,n={}){return gf(e,t,{...n,onError:n.onError??Id})}const ao=e=>Ql(e),kd=e=>ri(e);function Ri(e){return T.forwardRef(e)}const Vi=typeof window<"u"?T.useLayoutEffect:T.useEffect;function co(e){const[t,n]=T.useState(BigInt(0)),[r]=T.useState(()=>$d(()=>n(o=>o+BigInt(1))));return Vi(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function $d(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Bi=T.createContext(null);function Pd({children:e}){const t=oe(),n=T.useCallback(a=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:f,onNodesChange:d,nodeLookup:l,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let w=c;for(const m of a)w=typeof m=="function"?m(w):m;let x=io({items:w,lookup:l});for(const m of g.values())x=m(x);f&&u(w),x.length>0?d==null||d(x):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:b,setNodes:p}=t.getState();m&&p(b)})},[]),r=co(n),o=T.useCallback(a=>{const{edges:c=[],setEdges:u,hasDefaultEdges:f,onEdgesChange:d,edgeLookup:l}=t.getState();let h=c;for(const g of a)h=typeof g=="function"?g(h):g;f?u(h):d&&d(io({items:h,lookup:l}))},[]),i=co(o),s=T.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return P.jsx(Bi.Provider,{value:s,children:e})}function Td(){const e=T.useContext(Bi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const zd=e=>!!e.panZoom;function or(){const e=Md(),t=oe(),n=Td(),r=te(zd),o=T.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:l,nodeOrigin:h}=t.getState(),g=ao(d)?d:l.get(d.id),w=g.parentId?li(g.position,g.measured,g.parentId,l,h):g.position,x={...g,position:w,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return mt(x)},u=(d,l,h={replace:!1})=>{s(g=>g.map(w=>{if(w.id===d){const x=typeof l=="function"?l(w):l;return h.replace&&ao(x)?x:{...w,...x}}return w}))},f=(d,l,h={replace:!1})=>{a(g=>g.map(w=>{if(w.id===d){const x=typeof l=="function"?l(w):l;return h.replace&&kd(x)?x:{...w,...x}}return w}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var l;return(l=i(d))==null?void 0:l.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(l=>({...l}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:s,setEdges:a,addNodes:d=>{const l=Array.isArray(d)?d:[d];n.nodeQueue.push(h=>[...h,...l])},addEdges:d=>{const l=Array.isArray(d)?d:[d];n.edgeQueue.push(h=>[...h,...l])},toObject:()=>{const{nodes:d=[],edges:l=[],transform:h}=t.getState(),[g,w,x]=h;return{nodes:d.map(m=>({...m})),edges:l.map(m=>({...m})),viewport:{x:g,y:w,zoom:x}}},deleteElements:async({nodes:d=[],edges:l=[]})=>{const{nodes:h,edges:g,onNodesDelete:w,onEdgesDelete:x,triggerNodeChanges:m,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:v}=t.getState(),{nodes:N,edges:E}=await rf({nodesToRemove:d,edgesToRemove:l,nodes:h,edges:g,onBeforeDelete:v}),M=E.length>0,_=N.length>0;if(M){const S=E.map(so);x==null||x(E),b(S)}if(_){const S=N.map(so);w==null||w(N),m(S)}return(_||M)&&(p==null||p({nodes:N,edges:E})),{deletedNodes:N,deletedEdges:E}},getIntersectingNodes:(d,l=!0,h)=>{const g=Pr(d),w=g?d:c(d),x=h!==void 0;return w?(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=mt(x?m:b),v=Zt(p,w);return l&&v>0||v>=p.width*p.height||v>=w.width*w.height}):[]},isNodeIntersecting:(d,l,h=!0)=>{const w=Pr(d)?d:c(d);if(!w)return!1;const x=Zt(w,l);return h&&x>0||x>=l.width*l.height||x>=w.width*w.height},updateNode:u,updateNodeData:(d,l,h={replace:!1})=>{u(d,g=>{const w=typeof l=="function"?l(g):l;return h.replace?{...g,data:w}:{...g,data:{...g.data,...w}}},h)},updateEdge:f,updateEdgeData:(d,l,h={replace:!1})=>{f(d,g=>{const w=typeof l=="function"?l(g):l;return h.replace?{...g,data:w}:{...g,data:{...g.data,...w}}},h)},getNodesBounds:d=>{const{nodeLookup:l,nodeOrigin:h}=t.getState();return Jl(d,{nodeLookup:l,nodeOrigin:h})},getHandleConnections:({type:d,id:l,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${d}${l?`-${l}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:d,handleId:l,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${d?l?`-${d}-${l}`:`-${d}`:""}`))==null?void 0:g.values())??[])},fitView:async d=>{const l=t.getState().fitViewResolver??af();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:l}),n.nodeQueue.push(h=>[...h]),l.promise}}},[]);return T.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const uo=e=>e.selected,Dd=typeof window<"u"?window:void 0;function Hd({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=oe(),{deleteElements:r}=or(),o=xt(e,{actInsideInputWithModifier:!1}),i=xt(t,{target:Dd});T.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter(uo),edges:s.filter(uo)}),n.setState({nodesSelectionActive:!1})}},[o]),T.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Ld(e){const t=oe();T.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=Qn(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 un={position:"absolute",width:"100%",height:"100%",top:0,left:0},Rd=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Vd({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:o,panOnScrollSpeed:i=.5,panOnScrollMode:s=Fe.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:u,translateExtent:f,minZoom:d,maxZoom:l,zoomActivationKeyCode:h,preventScrolling:g=!0,children:w,noWheelClassName:x,noPanClassName:m,onViewportChange:b,isControlledViewport:p,paneClickDistance:v,selectionOnDrag:N}){const E=oe(),M=T.useRef(null),{userSelectionActive:_,lib:S,connectionInProgress:B}=te(Rd,ie),$=xt(h),R=T.useRef();Ld(M);const D=T.useCallback(y=>{b==null||b({x:y[0],y:y[1],zoom:y[2]}),p||E.setState({transform:y})},[b,p]);return T.useEffect(()=>{if(M.current){R.current=Xf({domNode:M.current,minZoom:d,maxZoom:l,translateExtent:f,viewport:u,onDraggingChange:k=>E.setState(z=>z.paneDragging===k?z:{paneDragging:k}),onPanZoomStart:(k,z)=>{const{onViewportChangeStart:A,onMoveStart:H}=E.getState();H==null||H(k,z),A==null||A(z)},onPanZoom:(k,z)=>{const{onViewportChange:A,onMove:H}=E.getState();H==null||H(k,z),A==null||A(z)},onPanZoomEnd:(k,z)=>{const{onViewportChangeEnd:A,onMoveEnd:H}=E.getState();H==null||H(k,z),A==null||A(z)}});const{x:y,y:C,zoom:I}=R.current.getViewport();return E.setState({panZoom:R.current,transform:[y,C,I],domNode:M.current.closest(".react-flow")}),()=>{var k;(k=R.current)==null||k.destroy()}}},[]),T.useEffect(()=>{var y;(y=R.current)==null||y.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:o,panOnScrollSpeed:i,panOnScrollMode:s,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:$,preventScrolling:g,noPanClassName:m,userSelectionActive:_,noWheelClassName:x,lib:S,onTransformChange:D,connectionInProgress:B,selectionOnDrag:N,paneClickDistance:v})},[e,t,n,r,o,i,s,a,c,$,g,m,_,x,S,D,B,N,v]),P.jsx("div",{className:"react-flow__renderer",ref:M,style:un,children:w})}const Bd=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Fd(){const{userSelectionActive:e,userSelectionRect:t}=te(Bd,ie);return e&&t?P.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 Nn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Od=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function jd({isSelecting:e,selectionKeyPressed:t,selectionMode:n=pt.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:a,onSelectionEnd:c,onPaneClick:u,onPaneContextMenu:f,onPaneScroll:d,onPaneMouseEnter:l,onPaneMouseMove:h,onPaneMouseLeave:g,children:w}){const x=T.useRef(0),m=oe(),{userSelectionActive:b,elementsSelectable:p,dragging:v,panBy:N,autoPanSpeed:E}=te(Od,ie),M=p&&(e||b),_=T.useRef(null),S=T.useRef(),B=T.useRef(new Set),$=T.useRef(new Set),R=T.useRef(!1),D=T.useRef(!1),y=T.useRef({x:0,y:0}),C=T.useRef(!1),I=L=>{if(D.current||R.current||m.getState().connection.inProgress){D.current=!1,R.current=!1;return}u==null||u(L),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},k=L=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){L.preventDefault();return}f==null||f(L)},z=d?L=>d(L):void 0,A=L=>{D.current&&(L.stopPropagation(),D.current=!1)},H=L=>{var re,le;if(L.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:O,transform:Z}=m.getState();if(S.current=O==null?void 0:O.getBoundingClientRect(),!S.current)return;const U=L.target===_.current;if(!U&&!!L.target.closest(".nokey")||!e||!(s&&U||t)||L.button!==0||!L.isPrimary)return;(le=(re=L.target)==null?void 0:re.setPointerCapture)==null||le.call(re,L.pointerId),D.current=!1;const{x:Q,y:ee}=pe(L.nativeEvent,S.current),ne=St({x:Q,y:ee},Z);m.setState({userSelectionRect:{width:0,height:0,startX:ne.x,startY:ne.y,x:Q,y:ee}}),U||(L.stopPropagation(),L.preventDefault())};function F(L,O){const{userSelectionRect:Z}=m.getState();if(!Z)return;const{transform:U,nodeLookup:Y,edgeLookup:K,connectionLookup:Q,triggerNodeChanges:ee,triggerEdgeChanges:ne,defaultEdgeOptions:re}=m.getState(),le={x:Z.startX,y:Z.startY},{x:we,y:ve}=tt(le,U),Se={startX:le.x,startY:le.y,x:L<we?L:we,y:O<ve?O:ve,width:Math.abs(L-we),height:Math.abs(O-ve)},rt=B.current,De=$.current;B.current=new Set(Zn(Y,Se,U,n===pt.Partial,!0).map(fe=>fe.id)),$.current=new Set;const He=(re==null?void 0:re.selectable)??!0;for(const fe of B.current){const Ne=Q.get(fe);if(Ne)for(const{edgeId:Me}of Ne.values()){const Le=K.get(Me);Le&&(Le.selectable??He)&&$.current.add(Me)}}if(!Tr(rt,B.current)){const fe=Ge(Y,B.current,!0);ee(fe)}if(!Tr(De,$.current)){const fe=Ge(K,$.current);ne(fe)}m.setState({userSelectionRect:Se,userSelectionActive:!0,nodesSelectionActive:!1})}function V(){if(!o||!S.current)return;const[L,O]=Un(y.current,S.current,E);N({x:L,y:O}).then(Z=>{if(!D.current||!Z){x.current=requestAnimationFrame(V);return}const{x:U,y:Y}=y.current;F(U,Y),x.current=requestAnimationFrame(V)})}const j=()=>{cancelAnimationFrame(x.current),x.current=0,C.current=!1};T.useEffect(()=>()=>j(),[]);const X=L=>{const{userSelectionRect:O,transform:Z,resetSelectedElements:U}=m.getState();if(!S.current||!O)return;const{x:Y,y:K}=pe(L.nativeEvent,S.current);y.current={x:Y,y:K};const Q=tt({x:O.startX,y:O.startY},Z);if(!D.current){const ee=t?0:i;if(Math.hypot(Y-Q.x,K-Q.y)<=ee)return;U(),a==null||a(L)}D.current=!0,C.current||(V(),C.current=!0),F(Y,K)},G=L=>{var O,Z;if(!M){L.target===_.current&&m.getState().connection.inProgress&&(R.current=!0);return}L.button===0&&((Z=(O=L.target)==null?void 0:O.releasePointerCapture)==null||Z.call(O,L.pointerId),!b&&L.target===_.current&&m.getState().userSelectionRect&&(I==null||I(L)),m.setState({userSelectionActive:!1,userSelectionRect:null}),D.current&&(c==null||c(L),m.setState({nodesSelectionActive:B.current.size>0})),j())},J=L=>{var O,Z;(Z=(O=L.target)==null?void 0:O.releasePointerCapture)==null||Z.call(O,L.pointerId),j()},q=r===!0||Array.isArray(r)&&r.includes(0);return P.jsxs("div",{className:se(["react-flow__pane",{draggable:q,dragging:v,selection:e}]),onClick:M?void 0:Nn(I,_),onContextMenu:Nn(k,_),onWheel:Nn(z,_),onPointerEnter:M?void 0:l,onPointerMove:M?X:h,onPointerUp:G,onPointerCancel:M?J:void 0,onPointerDownCapture:M?H:void 0,onClickCapture:M?A:void 0,onPointerLeave:g,ref:_,style:un,children:[w,P.jsx(Fd,{})]})}function Bn({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),u=a.get(e);if(!u){c==null||c("012",me.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):o([e])}function Fi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=oe(),[c,u]=T.useState(!1),f=T.useRef();return T.useEffect(()=>{if(!t)return f.current=kf({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{Bn({id:d,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}}),()=>{var d;(d=f.current)==null||d.destroy(),f.current=void 0}},[t,a,e]),T.useEffect(()=>{t||!e.current||!f.current||f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s})},[n,r,t,i,e,o,s]),c}const Xd=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Oi(){const e=oe();return T.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:u,nodeOrigin:f}=e.getState(),d=new Map,l=Xd(s),h=o?i[0]:5,g=o?i[1]:5,w=n.direction.x*h*n.factor,x=n.direction.y*g*n.factor;for(const[,m]of u){if(!l(m))continue;let b={x:m.internals.positionAbsolute.x+w,y:m.internals.positionAbsolute.y+x};o&&(b=Et(b,i));const{position:p,positionAbsolute:v}=oi({nodeId:m.id,nextPosition:b,nodeLookup:u,nodeExtent:r,nodeOrigin:f,onError:a});m.position=p,m.internals.positionAbsolute=v,d.set(m.id,m)}c(d)},[])}const ir=T.createContext(null),Yd=ir.Provider;ir.Consumer;const ji=()=>T.useContext(ir),Wd=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Xi=T.createContext(null);function qd({children:e}){const t=te(Wd,ie);return P.jsx(Xi.Provider,{value:t,children:e})}function Gd(){const e=T.useContext(Xi);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Zd={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Ud=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:c,isValid:u}=s;if(!a&&!o)return Zd;const f=(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:f,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===Je.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:f&&u}};function Kd({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:u,onMouseDown:f,onTouchStart:d,...l},h){var C,I;const g=s||null,w=e==="target",x=oe(),m=ji(),{connectOnClick:b,noPanClassName:p,rfId:v}=Gd(),{connectingFrom:N,connectingTo:E,clickConnecting:M,isPossibleEndHandle:_,connectionInProcess:S,clickConnectionInProcess:B,valid:$}=te(Ud(m,g,e),ie);m||(I=(C=x.getState()).onError)==null||I.call(C,"010",me.error010());const R=k=>{const{defaultEdgeOptions:z,onConnect:A,hasDefaultEdges:H}=x.getState(),F={...z,...k};if(H){const{edges:V,setEdges:j,onError:X}=x.getState();j(Ad(F,V,{onError:X}))}A==null||A(F),a==null||a(F)},D=k=>{if(!m)return;const z=gi(k.nativeEvent);if(o&&(z&&k.button===0||!z)){const A=x.getState();Vn.onPointerDown(k.nativeEvent,{handleDomNode:k.currentTarget,autoPanOnConnect:A.autoPanOnConnect,connectionMode:A.connectionMode,connectionRadius:A.connectionRadius,domNode:A.domNode,nodeLookup:A.nodeLookup,lib:A.lib,isTarget:w,handleId:g,nodeId:m,flowId:A.rfId,panBy:A.panBy,cancelConnection:A.cancelConnection,onConnectStart:A.onConnectStart,onConnectEnd:(...H)=>{var F,V;return(V=(F=x.getState()).onConnectEnd)==null?void 0:V.call(F,...H)},updateConnection:A.updateConnection,onConnect:R,isValidConnection:n||((...H)=>{var F,V;return((V=(F=x.getState()).isValidConnection)==null?void 0:V.call(F,...H))??!0}),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:A.autoPanSpeed,dragThreshold:A.connectionDragThreshold})}z?f==null||f(k):d==null||d(k)},y=k=>{const{onClickConnectStart:z,onClickConnectEnd:A,connectionClickStartHandle:H,connectionMode:F,isValidConnection:V,lib:j,rfId:X,nodeLookup:G,connection:J}=x.getState();if(!m||!H&&!o)return;if(!H){z==null||z(k.nativeEvent,{nodeId:m,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:m,type:e,id:g}});return}const q=di(k.target),L=n||V,{connection:O,isValid:Z}=Vn.isValid(k.nativeEvent,{handle:{nodeId:m,id:g,type:e},connectionMode:F,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:L,flowId:X,doc:q,lib:j,nodeLookup:G});Z&&O&&R(O);const U=structuredClone(J);delete U.inProgress,U.toPosition=U.toHandle?U.toHandle.position:null,A==null||A(k,U),x.setState({connectionClickStartHandle:null})};return P.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":t,"data-id":`${v}-${m}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,u,{source:!w,target:w,connectable:r,connectablestart:o,connectableend:i,clickconnecting:M,connectingfrom:N,connectingto:E,valid:$,connectionindicator:r&&(!S||_)&&(S||B?i:o)}]),onMouseDown:D,onTouchStart:D,onClick:b?y:void 0,ref:h,...l,children:c})}const Ut=T.memo(Ri(Kd));function Qd({data:e,isConnectable:t,sourcePosition:n=W.Bottom}){return P.jsxs(P.Fragment,{children:[e==null?void 0:e.label,P.jsx(Ut,{type:"source",position:n,isConnectable:t})]})}function Jd({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:r=W.Bottom}){return P.jsxs(P.Fragment,{children:[P.jsx(Ut,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,P.jsx(Ut,{type:"source",position:r,isConnectable:t})]})}function eh(){return null}function th({data:e,isConnectable:t,targetPosition:n=W.Top}){return P.jsxs(P.Fragment,{children:[P.jsx(Ut,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Kt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},lo={input:Qd,default:Jd,output:th,group:eh};function nh(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 rh=e=>{const{width:t,height:n,x:r,y:o}=_t(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 oh({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=oe(),{width:o,height:i,transformString:s,userSelectionActive:a}=te(rh,ie),c=Oi(),u=T.useRef(null);T.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const f=!a&&o!==null&&i!==null;if(Fi({nodeRef:u,disabled:!f}),!f)return null;const d=e?h=>{const g=r.getState().nodes.filter(w=>w.selected);e(h,g)}:void 0,l=h=>{Object.prototype.hasOwnProperty.call(Kt,h.key)&&(h.preventDefault(),c({direction:Kt[h.key],factor:h.shiftKey?4:1}))};return P.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:P.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:l,style:{width:o,height:i}})})}const fo=typeof window<"u"?window:void 0,ih=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Yi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:f,selectionMode:d,onSelectionStart:l,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:w,zoomActivationKeyCode:x,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:v,panOnScrollSpeed:N,panOnScrollMode:E,zoomOnDoubleClick:M,panOnDrag:_,autoPanOnSelection:S,defaultViewport:B,translateExtent:$,minZoom:R,maxZoom:D,preventScrolling:y,onSelectionContextMenu:C,noWheelClassName:I,noPanClassName:k,disableKeyboardA11y:z,onViewportChange:A,isControlledViewport:H}){const{nodesSelectionActive:F,userSelectionActive:V}=te(ih,ie),j=xt(u,{target:fo}),X=xt(w,{target:fo}),G=X||_,J=X||v,q=f&&G!==!0,L=j||V||q;return Hd({deleteKeyCode:c,multiSelectionKeyCode:g}),P.jsx(Vd,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:J,panActivationKeyPressed:X,panOnScrollSpeed:N,panOnScrollMode:E,zoomOnDoubleClick:M,panOnDrag:!j&&G,defaultViewport:B,translateExtent:$,minZoom:R,maxZoom:D,zoomActivationKeyCode:x,preventScrolling:y,noWheelClassName:I,noPanClassName:k,onViewportChange:A,isControlledViewport:H,paneClickDistance:a,selectionOnDrag:q,children:P.jsxs(jd,{onSelectionStart:l,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:G,autoPanOnSelection:S,isSelecting:!!L,selectionMode:d,selectionKeyPressed:j,paneClickDistance:a,selectionOnDrag:q,children:[e,F&&P.jsx(oh,{onSelectionContextMenu:C,noPanClassName:k,disableKeyboardA11y:z})]})})}Yi.displayName="FlowRenderer";const sh=T.memo(Yi),ah=e=>t=>e?Zn(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 ch(e){return te(T.useCallback(ah(e),[e]),ie)}const uh=e=>e.updateNodeInternals;function lh(){const e=te(uh),[t]=T.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 T.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function fh({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=oe(),i=T.useRef(null),s=T.useRef(null),a=T.useRef(e.sourcePosition),c=T.useRef(e.targetPosition),u=T.useRef(t),f=n&&!!e.internals.handleBounds;return T.useEffect(()=>{i.current&&!e.hidden&&(!f||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[f,e.hidden]),T.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),T.useEffect(()=>{if(i.current){const d=u.current!==t,l=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(d||l||h)&&(u.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 dh({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:u,nodesFocusable:f,resizeObserver:d,noDragClassName:l,noPanClassName:h,disableKeyboardA11y:g,rfId:w,nodeTypes:x,nodeClickDistance:m,onError:b}){const{node:p,internals:v,isParent:N}=te(L=>{const O=L.nodeLookup.get(e),Z=L.parentLookup.has(e);return{node:O,internals:O.internals,isParent:Z}},ie);let E=p.type||"default",M=(x==null?void 0:x[E])||lo[E];M===void 0&&(b==null||b("003",me.error003(E)),E="default",M=(x==null?void 0:x.default)||lo.default);const _=!!(p.draggable||a&&typeof p.draggable>"u"),S=!!(p.selectable||c&&typeof p.selectable>"u"),B=!!(p.connectable||u&&typeof p.connectable>"u"),$=!!(p.focusable||f&&typeof p.focusable>"u"),R=oe(),D=ui(p),y=fh({node:p,nodeType:E,hasDimensions:D,resizeObserver:d}),C=Fi({nodeRef:y,disabled:p.hidden||!_,noDragClassName:l,handleSelector:p.dragHandle,nodeId:e,isSelectable:S,nodeClickDistance:m}),I=Oi();if(p.hidden)return null;const k=xe(p),z=nh(p),A=S||_||t||n||r||o,H=n?L=>n(L,{...v.userNode}):void 0,F=r?L=>r(L,{...v.userNode}):void 0,V=o?L=>o(L,{...v.userNode}):void 0,j=i?L=>i(L,{...v.userNode}):void 0,X=s?L=>s(L,{...v.userNode}):void 0,G=L=>{const{selectNodesOnDrag:O,nodeDragThreshold:Z}=R.getState();S&&(!O||!_||Z>0)&&Bn({id:e,store:R,nodeRef:y}),t&&t(L,{...v.userNode})},J=L=>{if(!(hi(L.nativeEvent)||g)){if(ei.includes(L.key)&&S){const O=L.key==="Escape";Bn({id:e,store:R,unselect:O,nodeRef:y})}else if(_&&p.selected&&Object.prototype.hasOwnProperty.call(Kt,L.key)){L.preventDefault();const{ariaLabelConfig:O}=R.getState();R.setState({ariaLiveMessage:O["node.a11yDescription.ariaLiveMessage"]({direction:L.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),I({direction:Kt[L.key],factor:L.shiftKey?4:1})}}},q=()=>{var Q;if(g||!((Q=y.current)!=null&&Q.matches(":focus-visible")))return;const{transform:L,width:O,height:Z,autoPanOnNodeFocus:U,setCenter:Y}=R.getState();if(!U)return;Zn(new Map([[e,p]]),{x:0,y:0,width:O,height:Z},L,!0).length>0||Y(p.position.x+k.width/2,p.position.y+k.height/2,{zoom:L[2]})};return P.jsx("div",{className:se(["react-flow__node",`react-flow__node-${E}`,{[h]:_},p.className,{selected:p.selected,selectable:S,parent:N,draggable:_,dragging:C}]),ref:y,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:A?"all":"none",visibility:D?"visible":"hidden",...p.style,...z},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:F,onMouseLeave:V,onContextMenu:j,onClick:G,onDoubleClick:X,onKeyDown:$?J:void 0,tabIndex:$?0:void 0,onFocus:$?q:void 0,role:p.ariaRole??($?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Pi}-${w}`,"aria-label":p.ariaLabel,...p.domAttributes,children:P.jsx(Yd,{value:e,children:P.jsx(M,{id:e,data:p.data,type:E,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:p.selected??!1,selectable:S,draggable:_,deletable:p.deletable??!0,isConnectable:B,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:C,dragHandle:p.dragHandle,zIndex:v.z,parentId:p.parentId,...k})})})}var hh=T.memo(dh);const gh=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Wi(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:o}=te(gh,ie),i=ch(e.onlyRenderVisibleElements),s=lh();return P.jsx("div",{className:"react-flow__nodes",style:un,children:i.map(a=>P.jsx(hh,{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))})}Wi.displayName="NodeRenderer";const ph=T.memo(Wi);function mh(e){return te(T.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&&ff({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),ie)}const yh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return P.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},xh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return P.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ho={[qt.Arrow]:yh,[qt.ArrowClosed]:xh};function wh(e){const t=oe();return T.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 vh=({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=wh(t);return c?P.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:P.jsx(c,{color:n,strokeWidth:s})}):null},qi=({defaultColor:e,rfId:t})=>{const n=te(i=>i.edges),r=te(i=>i.defaultEdgeOptions),o=T.useMemo(()=>wf(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?P.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:P.jsx("defs",{children:o.map(i=>P.jsx(vh,{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};qi.displayName="MarkerDefinitions";var bh=T.memo(qi);function Gi({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:u,...f}){const[d,l]=T.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",u]),g=T.useRef(null);return T.useEffect(()=>{if(g.current){const w=g.current.getBBox();l({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?P.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:h,visibility:d.width?"visible":"hidden",...f,children:[o&&P.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}),P.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}Gi.displayName="EdgeText";const _h=T.memo(Gi);function ln({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:u=20,...f}){return P.jsxs(P.Fragment,{children:[P.jsx("path",{...f,d:e,fill:"none",className:se(["react-flow__edge-path",f.className])}),u?P.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&ge(t)&&ge(n)?P.jsx(_h,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function go({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 Zi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top}){const[s,a]=go({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,u]=go({pos:i,x1:r,y1:o,x2:e,y2:t}),[f,d,l,h]=pi({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${a} ${c},${u} ${r},${o}`,f,d,l,h]}function Ui(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:d,labelBgPadding:l,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:x,interactionWidth:m})=>{const[b,p,v]=Zi({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),N=e.isInternal?void 0:t;return P.jsx(ln,{id:N,path:b,labelX:p,labelY:v,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:d,labelBgPadding:l,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:x,interactionWidth:m})})}const Eh=Ui({isInternal:!1}),Ki=Ui({isInternal:!0});Eh.displayName="SimpleBezierEdge";Ki.displayName="SimpleBezierEdgeInternal";function Qi(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:d,style:l,sourcePosition:h=W.Bottom,targetPosition:g=W.Top,markerEnd:w,markerStart:x,pathOptions:m,interactionWidth:b})=>{const[p,v,N]=Hn({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}),E=e.isInternal?void 0:t;return P.jsx(ln,{id:E,path:p,labelX:v,labelY:N,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:d,style:l,markerEnd:w,markerStart:x,interactionWidth:b})})}const Ji=Qi({isInternal:!1}),es=Qi({isInternal:!0});Ji.displayName="SmoothStepEdge";es.displayName="SmoothStepEdgeInternal";function ts(e){return T.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return P.jsx(Ji,{...n,id:r,pathOptions:T.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const Sh=ts({isInternal:!1}),ns=ts({isInternal:!0});Sh.displayName="StepEdge";ns.displayName="StepEdgeInternal";function rs(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:d,style:l,markerEnd:h,markerStart:g,interactionWidth:w})=>{const[x,m,b]=xi({sourceX:n,sourceY:r,targetX:o,targetY:i}),p=e.isInternal?void 0:t;return P.jsx(ln,{id:p,path:x,labelX:m,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:d,style:l,markerEnd:h,markerStart:g,interactionWidth:w})})}const Nh=rs({isInternal:!1}),os=rs({isInternal:!0});Nh.displayName="StraightEdge";os.displayName="StraightEdgeInternal";function is(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=W.Bottom,targetPosition:a=W.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:d,labelBgPadding:l,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:x,pathOptions:m,interactionWidth:b})=>{const[p,v,N]=mi({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),E=e.isInternal?void 0:t;return P.jsx(ln,{id:E,path:p,labelX:v,labelY:N,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:d,labelBgPadding:l,labelBgBorderRadius:h,style:g,markerEnd:w,markerStart:x,interactionWidth:b})})}const Mh=is({isInternal:!1}),ss=is({isInternal:!0});Mh.displayName="BezierEdge";ss.displayName="BezierEdgeInternal";const po={default:ss,straight:os,step:ns,smoothstep:es,simplebezier:Ki},mo={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Ch=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,Ih=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,yo="react-flow__edgeupdater";function xo({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a}){return P.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:se([yo,`${yo}-${a}`]),cx:Ch(t,r,e),cy:Ih(n,r,e),r,stroke:"transparent",fill:"transparent"})}function Ah({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:u,onReconnectStart:f,onReconnectEnd:d,setReconnecting:l,setUpdateHover:h}){const g=oe(),w=(v,N)=>{if(v.button!==0)return;const{autoPanOnConnect:E,domNode:M,connectionMode:_,connectionRadius:S,lib:B,onConnectStart:$,cancelConnection:R,nodeLookup:D,rfId:y,panBy:C,updateConnection:I}=g.getState(),k=N.type==="target",z=(F,V)=>{l(!1),d==null||d(F,n,N.type,V)},A=F=>u==null?void 0:u(n,F),H=(F,V)=>{l(!0),f==null||f(v,n,N.type),$==null||$(F,V)};Vn.onPointerDown(v.nativeEvent,{autoPanOnConnect:E,connectionMode:_,connectionRadius:S,domNode:M,handleId:N.id,nodeId:N.nodeId,nodeLookup:D,isTarget:k,edgeUpdaterType:N.type,lib:B,flowId:y,cancelConnection:R,panBy:C,isValidConnection:(...F)=>{var V,j;return((j=(V=g.getState()).isValidConnection)==null?void 0:j.call(V,...F))??!0},onConnect:A,onConnectStart:H,onConnectEnd:(...F)=>{var V,j;return(j=(V=g.getState()).onConnectEnd)==null?void 0:j.call(V,...F)},onReconnectEnd:z,updateConnection:I,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:v.currentTarget})},x=v=>w(v,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=v=>w(v,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),p=()=>h(!1);return P.jsxs(P.Fragment,{children:[(e===!0||e==="source")&&P.jsx(xo,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:x,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&P.jsx(xo,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function kh({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,reconnectRadius:f,onReconnect:d,onReconnectStart:l,onReconnectEnd:h,rfId:g,edgeTypes:w,noPanClassName:x,onError:m,disableKeyboardA11y:b}){let p=te(Y=>Y.edgeLookup.get(e));const v=te(Y=>Y.defaultEdgeOptions);p=v?{...v,...p}:p;let N=p.type||"default",E=(w==null?void 0:w[N])||po[N];E===void 0&&(m==null||m("011",me.error011(N)),N="default",E=(w==null?void 0:w.default)||po.default);const M=!!(p.focusable||t&&typeof p.focusable>"u"),_=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),S=!!(p.selectable||r&&typeof p.selectable>"u"),B=T.useRef(null),[$,R]=T.useState(!1),[D,y]=T.useState(!1),C=oe(),{zIndex:I=p.zIndex,sourceX:k,sourceY:z,targetX:A,targetY:H,sourcePosition:F,targetPosition:V}=te(T.useCallback(Y=>{const K=Y.nodeLookup.get(p.source),Q=Y.nodeLookup.get(p.target);if(!K||!Q)return mo;const ee=xf({id:e,sourceNode:K,targetNode:Q,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:Y.connectionMode,onError:m}),ne=lf({selected:p.selected,zIndex:p.zIndex,sourceNode:K,targetNode:Q,elevateOnSelect:Y.elevateEdgesOnSelect,zIndexMode:Y.zIndexMode});return{...ee||mo,zIndex:ne}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex,m]),ie),j=T.useMemo(()=>p.markerStart?`url('#${Ln(p.markerStart,g)}')`:void 0,[p.markerStart,g]),X=T.useMemo(()=>p.markerEnd?`url('#${Ln(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||k===null||z===null||A===null||H===null)return null;const G=Y=>{var ne;const{addSelectedEdges:K,unselectNodesAndEdges:Q,multiSelectionActive:ee}=C.getState();S&&(C.setState({nodesSelectionActive:!1}),p.selected&&ee?(Q({nodes:[],edges:[p]}),(ne=B.current)==null||ne.blur()):K([e])),o&&o(Y,p)},J=i?Y=>{i(Y,{...p})}:void 0,q=s?Y=>{s(Y,{...p})}:void 0,L=a?Y=>{a(Y,{...p})}:void 0,O=c?Y=>{c(Y,{...p})}:void 0,Z=u?Y=>{u(Y,{...p})}:void 0,U=Y=>{var K;if(!b&&ei.includes(Y.key)&&S){const{unselectNodesAndEdges:Q,addSelectedEdges:ee}=C.getState();Y.key==="Escape"?((K=B.current)==null||K.blur(),Q({edges:[p]})):ee([e])}};return P.jsx("svg",{style:{zIndex:I},children:P.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${N}`,p.className,x,{selected:p.selected,animated:p.animated,inactive:!S&&!o,updating:$,selectable:S}]),onClick:G,onDoubleClick:J,onContextMenu:q,onMouseEnter:L,onMouseMove:O,onMouseLeave:Z,onKeyDown:M?U: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?`${Ti}-${g}`:void 0,ref:B,...p.domAttributes,children:[!D&&P.jsx(E,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:S,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:k,sourceY:z,targetX:A,targetY:H,sourcePosition:F,targetPosition:V,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:j,markerEnd:X,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),_&&P.jsx(Ah,{edge:p,isReconnectable:_,reconnectRadius:f,onReconnect:d,onReconnectStart:l,onReconnectEnd:h,sourceX:k,sourceY:z,targetX:A,targetY:H,sourcePosition:F,targetPosition:V,setUpdateHover:R,setReconnecting:y})]})})}var $h=T.memo(kh);const Ph=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function as({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:f,reconnectRadius:d,onEdgeDoubleClick:l,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:w}){const{edgesFocusable:x,edgesReconnectable:m,elementsSelectable:b,onError:p}=te(Ph,ie),v=mh(t);return P.jsxs("div",{className:"react-flow__edges",children:[P.jsx(bh,{defaultColor:e,rfId:n}),v.map(N=>P.jsx($h,{id:N,edgesFocusable:x,edgesReconnectable:m,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:f,reconnectRadius:d,onDoubleClick:l,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:w},N))]})}as.displayName="EdgeRenderer";const Th=T.memo(as),wo=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function zh({children:e}){const t=oe(),n=T.useRef(null),[r]=T.useState(()=>t.getState().transform);return Vi(()=>{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=wo(s)))};return i(),t.subscribe(i)},[t]),P.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:wo(r)},children:e})}function Dh(e){const t=or(),n=T.useRef(!1);T.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Hh=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Lh(e){const t=te(Hh),n=oe();return T.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Rh(e){return e.connection.inProgress?{...e.connection,to:St(e.connection.to,e.transform)}:{...e.connection}}function Vh(e){return Rh}function Bh(e){const t=Vh();return te(t,ie)}const Fh=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Oh({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:c}=te(Fh,ie);return!(i&&o&&c)?null:P.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:P.jsx("g",{className:se(["react-flow__connection",fi(a)]),children:P.jsx(cs,{style:t,type:n,CustomComponent:r,isValid:a})})})}const cs=({style:e,type:t=Te.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:u,toNode:f,toHandle:d,toPosition:l,pointer:h}=Bh();if(!o)return;if(n)return P.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:l,connectionStatus:fi(r),toNode:f,toHandle:d,pointer:h});let g="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:l};switch(t){case Te.Bezier:[g]=mi(w);break;case Te.SimpleBezier:[g]=Zi(w);break;case Te.Step:[g]=Hn({...w,borderRadius:0});break;case Te.SmoothStep:[g]=Hn(w);break;default:[g]=xi(w)}return P.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};cs.displayName="ConnectionLine";const jh={};function vo(e=jh){T.useRef(e),oe(),T.useEffect(()=>{},[e])}function Xh(){oe(),T.useRef(!1),T.useEffect(()=>{},[])}function us({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:f,onSelectionContextMenu:d,onSelectionStart:l,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:w,connectionLineComponent:x,connectionLineContainerStyle:m,selectionKeyCode:b,selectionOnDrag:p,selectionMode:v,multiSelectionKeyCode:N,panActivationKeyCode:E,zoomActivationKeyCode:M,deleteKeyCode:_,onlyRenderVisibleElements:S,elementsSelectable:B,defaultViewport:$,translateExtent:R,minZoom:D,maxZoom:y,preventScrolling:C,defaultMarkerColor:I,zoomOnScroll:k,zoomOnPinch:z,panOnScroll:A,panOnScrollSpeed:H,panOnScrollMode:F,zoomOnDoubleClick:V,panOnDrag:j,autoPanOnSelection:X,onPaneClick:G,onPaneMouseEnter:J,onPaneMouseMove:q,onPaneMouseLeave:L,onPaneScroll:O,onPaneContextMenu:Z,paneClickDistance:U,nodeClickDistance:Y,onEdgeContextMenu:K,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:re,onReconnect:le,onReconnectStart:we,onReconnectEnd:ve,noDragClassName:Se,noWheelClassName:rt,noPanClassName:De,disableKeyboardA11y:He,nodeExtent:fe,rfId:Ne,viewport:Me,onViewportChange:Le,nodesDraggable:fn}){return vo(e),vo(t),Xh(),Dh(n),Lh(Me),P.jsx(sh,{onPaneClick:G,onPaneMouseEnter:J,onPaneMouseMove:q,onPaneMouseLeave:L,onPaneContextMenu:Z,onPaneScroll:O,paneClickDistance:U,deleteKeyCode:_,selectionKeyCode:b,selectionOnDrag:p,selectionMode:v,onSelectionStart:l,onSelectionEnd:h,multiSelectionKeyCode:N,panActivationKeyCode:E,zoomActivationKeyCode:M,elementsSelectable:B,zoomOnScroll:k,zoomOnPinch:z,zoomOnDoubleClick:V,panOnScroll:A,panOnScrollSpeed:H,panOnScrollMode:F,panOnDrag:j,autoPanOnSelection:X,defaultViewport:$,translateExtent:R,minZoom:D,maxZoom:y,onSelectionContextMenu:d,preventScrolling:C,noDragClassName:Se,noWheelClassName:rt,noPanClassName:De,disableKeyboardA11y:He,onViewportChange:Le,isControlledViewport:!!Me,children:P.jsxs(zh,{children:[P.jsx(Th,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:le,onReconnectStart:we,onReconnectEnd:ve,onlyRenderVisibleElements:S,onEdgeContextMenu:K,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:re,defaultMarkerColor:I,noPanClassName:De,disableKeyboardA11y:He,rfId:Ne}),P.jsx(Oh,{style:w,type:g,component:x,containerStyle:m}),P.jsx("div",{className:"react-flow__edgelabel-renderer"}),P.jsx(ph,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:f,nodeClickDistance:Y,onlyRenderVisibleElements:S,noPanClassName:De,noDragClassName:Se,disableKeyboardA11y:He,nodeExtent:fe,rfId:Ne,nodesDraggable:fn}),P.jsx("div",{className:"react-flow__viewport-portal"})]})})}us.displayName="GraphView";const Yh=T.memo(us),Wh=ci(),bo=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:u=2,nodeOrigin:f,nodeExtent:d,zIndexMode:l="basic"}={})=>{const h=new Map,g=new Map,w=new Map,x=new Map,m=r??t??[],b=n??e??[],p=f??[0,0],v=d??gt;bi(w,x,m);const{nodesInitialized:N}=Rn(b,h,g,{nodeOrigin:p,nodeExtent:v,zIndexMode:l});let E=[0,0,1];if(s&&o&&i){const M=_t(h,{filter:$=>!!(($.width||$.initialWidth)&&($.height||$.initialHeight))}),{x:_,y:S,zoom:B}=Kn(M,o,i,c,u,(a==null?void 0:a.padding)??.1);E=[_,S,B]}return{rfId:"1",width:o??0,height:i??0,transform:E,nodes:b,nodesInitialized:N,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:x,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:gt,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Je.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:{...ni},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Wh,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ti,zIndexMode:l,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}},qh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:d,zIndexMode:l})=>ad((h,g)=>{async function w(){const{nodeLookup:x,panZoom:m,fitViewOptions:b,fitViewResolver:p,width:v,height:N,minZoom:E,maxZoom:M}=g();m&&(await nf({nodes:x,width:v,height:N,panZoom:m,minZoom:E,maxZoom:M},b),p==null||p.resolve(!0),h({fitViewResolver:null}))}return{...bo({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:l}),setNodes:x=>{const{nodeLookup:m,parentLookup:b,nodeOrigin:p,nodeExtent:v,elevateNodesOnSelect:N,fitViewQueued:E,zIndexMode:M,nodesSelectionActive:_}=g(),{nodesInitialized:S,hasSelectedNodes:B}=Rn(x,m,b,{nodeOrigin:p,nodeExtent:v,elevateNodesOnSelect:N,checkEquality:!0,zIndexMode:M}),$=_&&B;E&&S?(w(),h({nodes:x,nodesInitialized:S,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:$})):h({nodes:x,nodesInitialized:S,nodesSelectionActive:$})},setEdges:x=>{const{connectionLookup:m,edgeLookup:b}=g();bi(m,b,x),h({edges:x})},setDefaultNodesAndEdges:(x,m)=>{if(x){const{setNodes:b}=g();b(x),h({hasDefaultNodes:!0})}if(m){const{setEdges:b}=g();b(m),h({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:m,nodeLookup:b,parentLookup:p,domNode:v,nodeOrigin:N,nodeExtent:E,debug:M,fitViewQueued:_,zIndexMode:S}=g(),{changes:B,updatedInternals:$}=Mf(x,b,p,v,N,E,S);$&&(_f(b,p,{nodeOrigin:N,nodeExtent:E,zIndexMode:S}),_?(w(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(B==null?void 0:B.length)>0&&(M&&console.log("React Flow: trigger node changes",B),m==null||m(B)))},updateNodePositions:(x,m=!1)=>{const b=[];let p=[];const{nodeLookup:v,triggerNodeChanges:N,connection:E,updateConnection:M,onNodesChangeMiddlewareMap:_}=g();for(const[S,B]of x){const $=v.get(S),R=!!($!=null&&$.expandParent&&($!=null&&$.parentId)&&(B!=null&&B.position)),D={id:S,type:"position",position:R?{x:Math.max(0,B.position.x),y:Math.max(0,B.position.y)}:B.position,dragging:m};if($&&E.inProgress&&E.fromNode.id===$.id){const y=We($,E.fromHandle,W.Left,!0);M({...E,from:y})}R&&$.parentId&&b.push({id:S,parentId:$.parentId,rect:{...B.internals.positionAbsolute,width:B.measured.width??0,height:B.measured.height??0}}),p.push(D)}if(b.length>0){const{parentLookup:S,nodeOrigin:B}=g(),$=rr(b,v,S,B);p.push(...$)}for(const S of _.values())p=S(p);N(p)},triggerNodeChanges:x=>{const{onNodesChange:m,setNodes:b,nodes:p,hasDefaultNodes:v,debug:N}=g();if(x!=null&&x.length){if(v){const E=Hi(x,p);b(E)}N&&console.log("React Flow: trigger node changes",x),m==null||m(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:m,setEdges:b,edges:p,hasDefaultEdges:v,debug:N}=g();if(x!=null&&x.length){if(v){const E=Li(x,p);b(E)}N&&console.log("React Flow: trigger edge changes",x),m==null||m(x)}},addSelectedNodes:x=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:v,triggerEdgeChanges:N}=g();if(m){const E=x.map(M=>Re(M,!0));v(E);return}v(Ge(p,new Set([...x]),!0)),N(Ge(b))},addSelectedEdges:x=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:v,triggerEdgeChanges:N}=g();if(m){const E=x.map(M=>Re(M,!0));N(E);return}N(Ge(b,new Set([...x]))),v(Ge(p,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:m}={})=>{const{edges:b,nodes:p,nodeLookup:v,triggerNodeChanges:N,triggerEdgeChanges:E}=g(),M=x||p,_=m||b,S=[];for(const $ of M){if(!$.selected)continue;const R=v.get($.id);R&&(R.selected=!1),S.push(Re($.id,!1))}const B=[];for(const $ of _)$.selected&&B.push(Re($.id,!1));N(S),E(B)},setMinZoom:x=>{const{panZoom:m,maxZoom:b}=g();m==null||m.setScaleExtent([x,b]),h({minZoom:x})},setMaxZoom:x=>{const{panZoom:m,minZoom:b}=g();m==null||m.setScaleExtent([b,x]),h({maxZoom:x})},setTranslateExtent:x=>{var m;(m=g().panZoom)==null||m.setTranslateExtent(x),h({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:m,triggerNodeChanges:b,triggerEdgeChanges:p,elementsSelectable:v}=g();if(!v)return;const N=m.reduce((M,_)=>_.selected?[...M,Re(_.id,!1)]:M,[]),E=x.reduce((M,_)=>_.selected?[...M,Re(_.id,!1)]:M,[]);b(N),p(E)},setNodeExtent:x=>{const{nodes:m,nodeLookup:b,parentLookup:p,nodeOrigin:v,elevateNodesOnSelect:N,nodeExtent:E,zIndexMode:M}=g();x[0][0]===E[0][0]&&x[0][1]===E[0][1]&&x[1][0]===E[1][0]&&x[1][1]===E[1][1]||(Rn(m,b,p,{nodeOrigin:v,nodeExtent:x,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:M}),h({nodeExtent:x}))},panBy:x=>{const{transform:m,width:b,height:p,panZoom:v,translateExtent:N}=g();return Cf({delta:x,panZoom:v,transform:m,translateExtent:N,width:b,height:p})},setCenter:async(x,m,b)=>{const{width:p,height:v,maxZoom:N,panZoom:E}=g();if(!E)return!1;const M=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:N;return await E.setViewport({x:p/2-x*M,y:v/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:{...ni}})},updateConnection:x=>{h({connection:x})},reset:()=>h({...bo()})}},Object.is);function Gh({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:u,nodeOrigin:f,nodeExtent:d,zIndexMode:l,children:h}){const[g]=T.useState(()=>qh({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:u,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:f,nodeExtent:d,zIndexMode:l}));return P.jsx(cd,{value:g,children:P.jsx(Pd,{children:P.jsx(qd,{children:h})})})}function Zh({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:d,nodeExtent:l,zIndexMode:h}){return T.useContext(an)?P.jsx(P.Fragment,{children:e}):P.jsx(Gh,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:f,nodeOrigin:d,nodeExtent:l,zIndexMode:h,children:e})}const Uh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Kh({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:u,onMove:f,onMoveStart:d,onMoveEnd:l,onConnect:h,onConnectStart:g,onConnectEnd:w,onClickConnectStart:x,onClickConnectEnd:m,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:N,onNodeDoubleClick:E,onNodeDragStart:M,onNodeDrag:_,onNodeDragStop:S,onNodesDelete:B,onEdgesDelete:$,onDelete:R,onSelectionChange:D,onSelectionDragStart:y,onSelectionDrag:C,onSelectionDragStop:I,onSelectionContextMenu:k,onSelectionStart:z,onSelectionEnd:A,onBeforeDelete:H,connectionMode:F,connectionLineType:V=Te.Bezier,connectionLineStyle:j,connectionLineComponent:X,connectionLineContainerStyle:G,deleteKeyCode:J="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:L=!1,selectionMode:O=pt.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:U=yt()?"Meta":"Control",zoomActivationKeyCode:Y=yt()?"Meta":"Control",snapToGrid:K,snapGrid:Q,onlyRenderVisibleElements:ee=!1,selectNodesOnDrag:ne,nodesDraggable:re,autoPanOnNodeFocus:le,nodesConnectable:we,nodesFocusable:ve,nodeOrigin:Se=zi,edgesFocusable:rt,edgesReconnectable:De,elementsSelectable:He=!0,defaultViewport:fe=bd,minZoom:Ne=.5,maxZoom:Me=2,translateExtent:Le=gt,preventScrolling:fn=!0,nodeExtent:dn,defaultMarkerColor:hs="#b1b1b7",zoomOnScroll:gs=!0,zoomOnPinch:ps=!0,panOnScroll:ms=!1,panOnScrollSpeed:ys=.5,panOnScrollMode:xs=Fe.Free,zoomOnDoubleClick:ws=!0,panOnDrag:vs=!0,onPaneClick:bs,onPaneMouseEnter:_s,onPaneMouseMove:Es,onPaneMouseLeave:Ss,onPaneScroll:Ns,onPaneContextMenu:Ms,paneClickDistance:Cs=1,nodeClickDistance:Is=0,children:As,onReconnect:ks,onReconnectStart:$s,onReconnectEnd:Ps,onEdgeContextMenu:Ts,onEdgeDoubleClick:zs,onEdgeMouseEnter:Ds,onEdgeMouseMove:Hs,onEdgeMouseLeave:Ls,reconnectRadius:Rs=10,onNodesChange:Vs,onEdgesChange:Bs,noDragClassName:Fs="nodrag",noWheelClassName:Os="nowheel",noPanClassName:sr="nopan",fitView:ar,fitViewOptions:cr,connectOnClick:js,attributionPosition:Xs,proOptions:Ys,defaultEdgeOptions:Ws,elevateNodesOnSelect:qs=!0,elevateEdgesOnSelect:Gs=!1,disableKeyboardA11y:ur=!1,autoPanOnConnect:Zs,autoPanOnNodeDrag:Us,autoPanOnSelection:Ks=!0,autoPanSpeed:Qs,connectionRadius:Js,isValidConnection:ea,onError:ta,style:na,id:lr,nodeDragThreshold:ra,connectionDragThreshold:oa,viewport:ia,onViewportChange:sa,width:aa,height:ca,colorMode:ua="light",debug:la,onScroll:Nt,ariaLabelConfig:fa,zIndexMode:fr="basic",...da},ha){const hn=lr||"1",ga=Nd(ua),pa=T.useCallback(dr=>{dr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Nt==null||Nt(dr)},[Nt]);return P.jsx("div",{"data-testid":"rf__wrapper",...da,onScroll:pa,style:{...na,...Uh},ref:ha,className:se(["react-flow",o,ga]),id:lr,role:"application",children:P.jsxs(Zh,{nodes:e,edges:t,width:aa,height:ca,fitView:ar,fitViewOptions:cr,minZoom:Ne,maxZoom:Me,nodeOrigin:Se,nodeExtent:dn,zIndexMode:fr,children:[P.jsx(Sd,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:w,onClickConnectStart:x,onClickConnectEnd:m,nodesDraggable:re,autoPanOnNodeFocus:le,nodesConnectable:we,nodesFocusable:ve,edgesFocusable:rt,edgesReconnectable:De,elementsSelectable:He,elevateNodesOnSelect:qs,elevateEdgesOnSelect:Gs,minZoom:Ne,maxZoom:Me,nodeExtent:dn,onNodesChange:Vs,onEdgesChange:Bs,snapToGrid:K,snapGrid:Q,connectionMode:F,translateExtent:Le,connectOnClick:js,defaultEdgeOptions:Ws,fitView:ar,fitViewOptions:cr,onNodesDelete:B,onEdgesDelete:$,onDelete:R,onNodeDragStart:M,onNodeDrag:_,onNodeDragStop:S,onSelectionDrag:C,onSelectionDragStart:y,onSelectionDragStop:I,onMove:f,onMoveStart:d,onMoveEnd:l,noPanClassName:sr,nodeOrigin:Se,rfId:hn,autoPanOnConnect:Zs,autoPanOnNodeDrag:Us,autoPanSpeed:Qs,onError:ta,connectionRadius:Js,isValidConnection:ea,selectNodesOnDrag:ne,nodeDragThreshold:ra,connectionDragThreshold:oa,onBeforeDelete:H,debug:la,ariaLabelConfig:fa,zIndexMode:fr}),P.jsx(Yh,{onInit:u,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:N,onNodeDoubleClick:E,nodeTypes:i,edgeTypes:s,connectionLineType:V,connectionLineStyle:j,connectionLineComponent:X,connectionLineContainerStyle:G,selectionKeyCode:q,selectionOnDrag:L,selectionMode:O,deleteKeyCode:J,multiSelectionKeyCode:U,panActivationKeyCode:Z,zoomActivationKeyCode:Y,onlyRenderVisibleElements:ee,defaultViewport:fe,translateExtent:Le,minZoom:Ne,maxZoom:Me,preventScrolling:fn,zoomOnScroll:gs,zoomOnPinch:ps,zoomOnDoubleClick:ws,panOnScroll:ms,panOnScrollSpeed:ys,panOnScrollMode:xs,panOnDrag:vs,autoPanOnSelection:Ks,onPaneClick:bs,onPaneMouseEnter:_s,onPaneMouseMove:Es,onPaneMouseLeave:Ss,onPaneScroll:Ns,onPaneContextMenu:Ms,paneClickDistance:Cs,nodeClickDistance:Is,onSelectionContextMenu:k,onSelectionStart:z,onSelectionEnd:A,onReconnect:ks,onReconnectStart:$s,onReconnectEnd:Ps,onEdgeContextMenu:Ts,onEdgeDoubleClick:zs,onEdgeMouseEnter:Ds,onEdgeMouseMove:Hs,onEdgeMouseLeave:Ls,reconnectRadius:Rs,defaultMarkerColor:hs,noDragClassName:Fs,noWheelClassName:Os,noPanClassName:sr,rfId:hn,disableKeyboardA11y:ur,nodeExtent:dn,viewport:ia,onViewportChange:sa,nodesDraggable:re}),P.jsx(vd,{onSelectionChange:D}),As,P.jsx(pd,{proOptions:Ys,position:Xs}),P.jsx(gd,{rfId:hn,disableKeyboardA11y:ur})]})})}var Cg=Ri(Kh);const Qh=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function Ig({children:e}){const t=te(Qh);return t?xa.createPortal(e,t):null}function Ag(e){const[t,n]=T.useState(e),r=T.useCallback(o=>n(i=>Hi(o,i)),[]);return[t,n,r]}function kg(e){const[t,n]=T.useState(e),r=T.useCallback(o=>n(i=>Li(o,i)),[]);return[t,n,r]}function Jh({dimensions:e,lineWidth:t,variant:n,className:r}){return P.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 eg({radius:e,className:t}){return P.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var ze;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ze||(ze={}));const tg={[ze.Dots]:1,[ze.Lines]:1,[ze.Cross]:6},ng=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ls({id:e,variant:t=ze.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:c,className:u,patternClassName:f}){const d=T.useRef(null),{transform:l,patternId:h}=te(ng,ie),g=r||tg[t],w=t===ze.Dots,x=t===ze.Cross,m=Array.isArray(n)?n:[n,n],b=[m[0]*l[2]||1,m[1]*l[2]||1],p=g*l[2],v=Array.isArray(i)?i:[i,i],N=x?[p,p]:b,E=[v[0]*l[2]+N[0]/2,v[1]*l[2]+N[1]/2],M=`${h}${e||""}`;return P.jsxs("svg",{className:se(["react-flow__background",u]),style:{...c,...un,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:d,"data-testid":"rf__background",children:[P.jsx("pattern",{id:M,x:l[0]%b[0],y:l[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`,children:w?P.jsx(eg,{radius:p/2,className:f}):P.jsx(Jh,{dimensions:N,lineWidth:o,variant:t,className:f})}),P.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}ls.displayName="Background";const $g=T.memo(ls);function rg(){return P.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:P.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function og(){return P.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:P.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ig(){return P.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:P.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 sg(){return P.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:P.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 ag(){return P.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:P.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 zt({children:e,className:t,...n}){return P.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const cg=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function fs({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:u,children:f,position:d="bottom-left",orientation:l="vertical","aria-label":h}){const g=oe(),{isInteractive:w,minZoomReached:x,maxZoomReached:m,ariaLabelConfig:b}=te(cg,ie),{zoomIn:p,zoomOut:v,fitView:N}=or(),E=()=>{p(),i==null||i()},M=()=>{v(),s==null||s()},_=()=>{N(o),a==null||a()},S=()=>{g.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),c==null||c(!w)},B=l==="horizontal"?"horizontal":"vertical";return P.jsxs(cn,{className:se(["react-flow__controls",B,u]),position:d,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&P.jsxs(P.Fragment,{children:[P.jsx(zt,{onClick:E,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:m,children:P.jsx(rg,{})}),P.jsx(zt,{onClick:M,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:x,children:P.jsx(og,{})})]}),n&&P.jsx(zt,{className:"react-flow__controls-fitview",onClick:_,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:P.jsx(ig,{})}),r&&P.jsx(zt,{className:"react-flow__controls-interactive",onClick:S,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:w?P.jsx(ag,{}):P.jsx(sg,{})}),f]})}fs.displayName="Controls";const Pg=T.memo(fs);function ug({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:c,className:u,borderRadius:f,shapeRendering:d,selected:l,onClick:h}){const{background:g,backgroundColor:w}=i||{},x=s||g||w;return P.jsx("rect",{className:se(["react-flow__minimap-node",{selected:l},u]),x:t,y:n,rx:f,ry:f,width:r,height:o,style:{fill:x,stroke:a,strokeWidth:c},shapeRendering:d,onClick:h?m=>h(m,e):void 0})}const lg=T.memo(ug),fg=e=>e.nodes.map(t=>t.id),Mn=e=>e instanceof Function?e:()=>e;function dg({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=lg,onClick:s}){const a=te(fg,ie),c=Mn(t),u=Mn(e),f=Mn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return P.jsx(P.Fragment,{children:a.map(l=>P.jsx(gg,{id:l,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:d},l))})}function hg({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:u,x:f,y:d,width:l,height:h}=te(g=>{const w=g.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const x=w.internals.userNode,{x:m,y:b}=w.internals.positionAbsolute,{width:p,height:v}=xe(x);return{node:x,x:m,y:b,width:p,height:v}},ie);return!u||u.hidden||!ui(u)?null:P.jsx(a,{x:f,y:d,width:l,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:o,strokeColor:n(u),strokeWidth:i,shapeRendering:s,onClick:c,id:u.id})}const gg=T.memo(hg);var pg=T.memo(dg);const mg=200,yg=150,xg=e=>!e.hidden,wg=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?si(_t(e.nodeLookup,{filter:xg}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},_o=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,vg=(e,t)=>_o(e.viewBB,t.viewBB)&&_o(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,bg="react-flow__minimap-desc";function ds({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:u,maskStrokeColor:f,maskStrokeWidth:d,position:l="bottom-right",onClick:h,onNodeClick:g,pannable:w=!1,zoomable:x=!1,ariaLabel:m,inversePan:b,zoomStep:p=1,offsetScale:v=5}){const N=oe(),E=T.useRef(null),{boundingRect:M,panZoom:_,viewBB:S,rfId:B,translateExtent:$,flowWidth:R,flowHeight:D,ariaLabelConfig:y}=te(wg,vg),C=(e==null?void 0:e.width)??mg,I=(e==null?void 0:e.height)??yg,k=M.width/C,z=M.height/I,A=Math.max(k,z),H=A*C,F=A*I,V=v*A,j=M.x-(H-M.width)/2-V,X=M.y-(F-M.height)/2-V,G=H+V*2,J=F+V*2,q=`${bg}-${B}`,L=T.useRef(0),O=T.useRef();L.current=A,T.useEffect(()=>{const Q=N.getState().panZoom;if(E.current&&Q)return O.current=Hf({domNode:E.current,panZoom:Q,getTransform:()=>N.getState().transform,getViewScale:()=>L.current}),()=>{var ee;(ee=O.current)==null||ee.destroy()}},[_]),T.useEffect(()=>{var Q;(Q=O.current)==null||Q.update({translateExtent:$,width:R,height:D,inversePan:b,pannable:w,zoomStep:p,zoomable:x})},[w,x,b,p,$,R,D]);const Z=h?Q=>{var re;const[ee,ne]=((re=O.current)==null?void 0:re.pointer(Q))||[0,0];h(Q,{x:ee,y:ne})}:void 0,U=T.useCallback((Q,ee)=>{const ne=N.getState().nodeLookup.get(ee).internals.userNode;g==null||g(Q,ne)},[g]),Y=g?U:void 0,K=m??y["minimap.ariaLabel"];return P.jsx(cn,{position:l,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*A: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:P.jsxs("svg",{width:C,height:I,viewBox:`${j} ${X} ${G} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":q,ref:E,onClick:Z,children:[K&&P.jsx("title",{id:q,children:K}),P.jsx(pg,{onClick:Y,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),P.jsx("path",{className:"react-flow__minimap-mask",d:`M${j-V},${X-V}h${G+V*2}v${J+V*2}h${-G-V*2}z
23
+ M${S.x},${S.y}h${S.width}v${S.height}h${-S.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ds.displayName="MiniMap";const Tg=T.memo(ds),_g=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Eg={[nt.Line]:"right",[nt.Handle]:"bottom-right"};function Sg({nodeId:e,position:t,variant:n=nt.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:l,autoScale:h=!0,shouldResize:g,onResizeStart:w,onResize:x,onResizeEnd:m}){const b=ji(),p=typeof e=="string"?e:b,v=oe(),N=T.useRef(null),E=n===nt.Handle,M=te(T.useCallback(_g(E&&h),[E,h]),ie),_=T.useRef(null),S=t??Eg[n];T.useEffect(()=>{if(!(!N.current||!p))return _.current||(_.current=Zf({domNode:N.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:$,transform:R,snapGrid:D,snapToGrid:y,nodeOrigin:C,domNode:I}=v.getState();return{nodeLookup:$,transform:R,snapGrid:D,snapToGrid:y,nodeOrigin:C,paneDomNode:I}},onChange:($,R)=>{const{triggerNodeChanges:D,nodeLookup:y,parentLookup:C,nodeOrigin:I}=v.getState(),k=[],z={x:$.x,y:$.y},A=y.get(p);if(A&&A.expandParent&&A.parentId){const H=A.origin??I,F=$.width??A.measured.width??0,V=$.height??A.measured.height??0,j={id:A.id,parentId:A.parentId,rect:{width:F,height:V,...li({x:$.x??A.position.x,y:$.y??A.position.y},{width:F,height:V},A.parentId,y,H)}},X=rr([j],y,C,I);k.push(...X),z.x=$.x?Math.max(H[0]*F,$.x):void 0,z.y=$.y?Math.max(H[1]*V,$.y):void 0}if(z.x!==void 0&&z.y!==void 0){const H={id:p,type:"position",position:{...z}};k.push(H)}if($.width!==void 0&&$.height!==void 0){const F={id:p,type:"dimensions",resizing:!0,setAttributes:l?l==="horizontal"?"width":"height":!0,dimensions:{width:$.width,height:$.height}};k.push(F)}for(const H of R){const F={...H,type:"position"};k.push(F)}D(k)},onEnd:({width:$,height:R})=>{const D={id:p,type:"dimensions",resizing:!1,dimensions:{width:$,height:R}};v.getState().triggerNodeChanges([D])}})),_.current.update({controlPosition:S,boundaries:{minWidth:a,minHeight:c,maxWidth:u,maxHeight:f},keepAspectRatio:d,resizeDirection:l,onResizeStart:w,onResize:x,onResizeEnd:m,shouldResize:g}),()=>{var $;($=_.current)==null||$.destroy()}},[S,a,c,u,f,d,w,x,m,g]);const B=S.split("-");return P.jsx("div",{className:se(["react-flow__resize-control","nodrag",...B,n,r]),ref:N,style:{...o,scale:M,...s&&{[E?"backgroundColor":"borderColor"]:s}},children:i})}T.memo(Sg);export{ln as B,Pg as C,Ig as E,Ut as H,qt as M,W as P,Gh as R,Ag as a,kg as b,Kn as c,$g as d,ze as e,Tg as f,mi as g,Cg as i,Mg as l,or as u};
package/web/index.html CHANGED
@@ -9,8 +9,8 @@
9
9
  rel="icon"
10
10
  href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%230b0d10'/%3E%3Crect x='7' y='8' width='18' height='4' rx='2' fill='%235b8def'/%3E%3Crect x='7' y='14' width='13' height='4' rx='2' fill='%235b8def' opacity='.75'/%3E%3Crect x='7' y='20' width='8' height='4' rx='2' fill='%235b8def' opacity='.5'/%3E%3Ccircle cx='24' cy='22' r='3' fill='%23f85149'/%3E%3C/svg%3E"
11
11
  />
12
- <script type="module" crossorigin src="/assets/index-CN2nADIL.js"></script>
13
- <link rel="stylesheet" crossorigin href="/assets/index-C2gL_lbF.css">
12
+ <script type="module" crossorigin src="/assets/index-Dj9D1-XU.js"></script>
13
+ <link rel="stylesheet" crossorigin href="/assets/index-BuIZl_Bc.css">
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
@@ -1,6 +0,0 @@
1
- import{c as ae,u as $,a as Z,j as e,L as G,P as _,S as J,E as A,W as O,N as ne,r as N,b as oe,d as re,e as le,f as c,g as ie,h as de,i as ce,k as S,l as v,B as b,R as ue,m as me,n as F,I as xe,o as R,p as K,q as U,t as E,T as ge,s as P,v as X,D as he,w as pe,x as fe}from"./index-CN2nADIL.js";import{u as be,a as je,l as H,i as ve,B as Ne,b as we,C as ye,M as ke,c as Ce,H as V,P as Q}from"./flowLayout-GUFMVhrV.js";/**
2
- * @license lucide-react v0.469.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Ee=ae("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),B=220,I=84;function Me(){var i;const{has:t}=$(),o=Z();if(!t("flows"))return e.jsx(G,{feature:"flows"});if(o.isLoading)return e.jsx(_,{children:e.jsx(J,{label:"Loading…"})});const u=(i=o.data)==null?void 0:i[0];return u?e.jsx(ne,{to:N.flows(u.id),replace:!0}):e.jsx(_,{children:e.jsx(A,{icon:e.jsx(O,{}),title:"No connections",description:"Add a Redis connection first; flows are detected per connection."})})}function Ae(){const{has:t}=$();return t("flows")?e.jsx(Le,{}):e.jsx(G,{feature:"flows"})}const Se=c.memo(function({data:o,selected:u}){const{node:i,connectionId:p}=o,m=i.counts;return e.jsxs("div",{className:X("rounded-lg border bg-surface px-3 py-2 text-fg shadow-sm transition-colors",u?"border-accent ring-2 ring-accent/30":"border-border-strong",i.isPaused&&"border-dashed"),style:{width:B,height:I},children:[e.jsx(V,{type:"target",position:Q.Left,className:"!size-2 !border-0 !bg-fg-subtle"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-semibold",title:i.queueName,children:i.queueName}),i.isPaused&&e.jsx(R,{variant:"warning",size:"xs",className:"ml-auto",children:"paused"})]}),e.jsxs("div",{className:"mt-1.5 grid grid-cols-3 gap-1 text-[11px]",children:[e.jsx(M,{label:"waiting",value:m.waiting+m.prioritized,tone:P.waiting.textClass}),e.jsx(M,{label:"active",value:m.active,tone:P.active.textClass}),e.jsx(M,{label:"failed",value:m.failed,tone:m.failed>0?P.failed.textClass:"text-fg-subtle"})]}),e.jsx(K,{to:N.queue(p,i.queueName),className:"absolute top-1.5 right-1.5 rounded p-0.5 text-fg-subtle hover:text-fg",title:"Open queue","aria-label":"Open queue",children:e.jsx(U,{className:"size-3"})}),e.jsx(V,{type:"source",position:Q.Right,className:"!size-2 !border-0 !bg-fg-subtle"})]})});function M({label:t,value:o,tone:u}){return e.jsxs("span",{className:"flex flex-col leading-tight",children:[e.jsx("span",{className:X("num font-semibold",u),children:fe(o)}),e.jsx("span",{className:"text-[10px] text-fg-subtle",children:t})]})}const qe={queue:Se};function ze(t){const o=t.source==="manual";return{id:t.id,source:t.from,target:t.to,type:"smoothstep",data:{edge:t},label:o?t.label??void 0:`×${v(t.evidence)}${t.label?` · ${t.label}`:""}`,labelStyle:{fontSize:10,fill:"var(--fg-muted)"},labelBgStyle:{fill:"var(--surface)",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:3,style:o?{stroke:"var(--accent)",strokeDasharray:"6 4",strokeWidth:1.5}:{stroke:"var(--fg-subtle)",strokeWidth:Math.min(4,1+Math.log10(Math.max(1,t.evidence)))},markerEnd:{type:Ce.ArrowClosed,color:o?"var(--accent)":"var(--fg-subtle)",width:16,height:16},animated:!1}}function Le(){var W,T;const{connectionId:t=""}=oe(),o=re(),{isOperator:u}=le(),i=Z(),[p,m]=c.useState(200),n=ie(t,p),w=de(),g=ce(),[q,h,z]=be([]),[y,r,L]=je([]),k=c.useRef(new Map),[d,j]=c.useState(null),[f,C]=c.useState(null),[Y,D]=c.useState(!1);c.useEffect(()=>{const s=n.data;if(!s)return;const l=H(s.nodes.map(a=>({id:a.id})),s.edges.map(a=>({from:a.from,to:a.to})),{nodeWidth:B,nodeHeight:I});h(s.nodes.map(a=>{const x=k.current.get(a.id)??l.get(a.id)??{x:0,y:0};return{id:a.id,type:"queue",position:{x:x.x,y:x.y},data:{node:a,connectionId:t},draggable:!0}})),r(s.edges.map(ze)),j(a=>a?s.edges.find(x=>x.id===a.id)??null:null),C(a=>a?s.nodes.find(x=>x.id===a.id)??null:null)},[n.data,t,h,r]),c.useEffect(()=>{k.current.clear()},[t]);const ee=c.useCallback(()=>{k.current.clear();const s=n.data;if(!s)return;const l=H(s.nodes.map(a=>({id:a.id})),s.edges.map(a=>({from:a.from,to:a.to})),{nodeWidth:B,nodeHeight:I});h(a=>a.map(x=>({...x,position:l.get(x.id)??x.position})))},[n.data,h]),se=((W=n.data)==null?void 0:W.edges.filter(s=>s.source==="detected").length)??0,te=((T=n.data)==null?void 0:T.edges.filter(s=>s.source==="manual").length)??0;return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border bg-surface px-4 py-2",children:[e.jsx(O,{className:"size-4 text-pro","aria-hidden":!0}),e.jsx("h1",{className:"text-sm font-semibold",children:"Flows"}),e.jsx(S,{"aria-label":"Connection",className:"!h-7 !w-auto text-xs",value:t,onChange:s=>o(N.flows(s.target.value)),options:(i.data??[]).map(s=>({value:s.id,label:s.name}))}),e.jsx(S,{"aria-label":"Sample size",className:"!h-7 !w-auto text-xs",value:String(p),onChange:s=>m(Number(s.target.value)),options:[50,200,500,1e3].map(s=>({value:String(s),label:`sample ${s} jobs/queue`}))}),e.jsx("span",{className:"text-xs text-fg-muted",children:n.data?e.jsxs(e.Fragment,{children:[v(n.data.nodes.length)," queues · ",se," detected · ",te," manual · sampled ",v(n.data.sampledJobs)," jobs"]}):n.isLoading?e.jsx(J,{label:"Detecting flows…"}):null}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(b,{size:"sm",variant:"ghost",leftIcon:e.jsx(ue,{}),onClick:()=>n.refetch(),loading:n.isFetching,children:"Refresh"}),e.jsx(b,{size:"sm",variant:"ghost",onClick:ee,children:"Re-layout"}),u&&e.jsx(b,{size:"sm",variant:"primary",leftIcon:e.jsx(me,{}),onClick:()=>D(!0),disabled:!n.data||n.data.nodes.length<2,children:"Add edge"})]})]}),e.jsxs("div",{className:"relative min-h-0 flex-1",children:[n.isError&&!n.data&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:e.jsx(A,{title:"Could not load flows",description:F(n.error)})}),n.data&&n.data.nodes.length===0&&e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:e.jsx(A,{icon:e.jsx(O,{}),title:"No queues on this connection",description:"Flows are built from the queues discovered on the connection."})}),e.jsxs(ve,{nodes:q,edges:y,nodeTypes:qe,onNodesChange:z,onEdgesChange:L,onNodeDragStop:(s,l)=>k.current.set(l.id,l.position),onEdgeClick:(s,l)=>{var a;j(((a=l.data)==null?void 0:a.edge)??null),C(null)},onNodeClick:(s,l)=>{C(l.data.node),j(null)},onPaneClick:()=>{j(null),C(null)},onNodeDoubleClick:(s,l)=>o(N.queue(t,l.data.node.queueName)),fitView:!0,fitViewOptions:{padding:.2,maxZoom:1},minZoom:.2,maxZoom:1.75,nodesConnectable:!1,proOptions:{hideAttribution:!0},colorMode:"system",className:"bg-bg",children:[e.jsx(Ne,{variant:we.Dots,gap:20,size:1}),e.jsx(ye,{showInteractive:!1,position:"bottom-right"}),e.jsx(ke,{pannable:!0,zoomable:!0,position:"bottom-left",nodeColor:()=>"var(--surface-3)",maskColor:"color-mix(in srgb, var(--bg) 70%, transparent)",style:{width:160,height:100}})]}),e.jsxs("div",{className:"pointer-events-none absolute top-3 left-3 flex flex-col gap-2",children:[e.jsxs("div",{className:"pointer-events-auto rounded-md border border-border bg-surface/95 px-3 py-2 text-[11px] text-fg-muted shadow-sm",children:[e.jsx("div",{className:"mb-1 font-semibold tracking-wider text-fg-subtle uppercase",children:"Legend"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{width:"36",height:"8",children:e.jsx("line",{x1:"0",y1:"4",x2:"36",y2:"4",stroke:"var(--fg-subtle)",strokeWidth:"2"})}),"detected · ",e.jsx("span",{className:"font-mono",children:"×n"})," = jobs evidencing it"]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("svg",{width:"36",height:"8",children:e.jsx("line",{x1:"0",y1:"4",x2:"36",y2:"4",stroke:"var(--accent)",strokeWidth:"1.5",strokeDasharray:"6 4"})}),"manual edge"]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-3 w-9 rounded border border-dashed border-border-strong"})," paused queue"]})]}),e.jsxs("div",{className:"pointer-events-auto flex max-w-sm items-start gap-2 rounded-md border border-border bg-surface/95 px-3 py-2 text-[11px] text-fg-muted shadow-sm",children:[e.jsx(xe,{className:"mt-px size-3.5 shrink-0 text-info","aria-hidden":!0}),e.jsxs("span",{children:["Detected edges come from BullMQ flows: children carry a ",e.jsx("span",{className:"font-mono",children:"parent"})," reference, so the arrow points from the child queue to the parent that waits for it. A worker that simply calls ",e.jsx("span",{className:"font-mono",children:"otherQueue.add()"})," leaves no trace in Redis; draw those with a manual edge. Double-click a queue to open it."]})]})]}),(d||f)&&e.jsxs("div",{className:"absolute top-3 right-3 w-72 rounded-lg border border-border bg-surface p-3 text-xs shadow-[var(--shadow)]",children:[f&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-semibold",children:f.queueName}),f.isPaused&&e.jsx(R,{variant:"warning",size:"xs",children:"paused"})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-x-3 gap-y-1 text-fg-muted",children:Object.entries(f.counts).map(([s,l])=>e.jsxs("div",{className:"flex justify-between border-b border-border/60 py-0.5",children:[e.jsx("dt",{children:s}),e.jsx("dd",{className:"num text-fg",children:v(l)})]},s))}),e.jsxs(K,{to:N.queue(t,f.queueName),className:"mt-3 inline-flex items-center gap-1 text-accent hover:underline",children:["Open queue ",e.jsx(U,{className:"size-3"})]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Ee,{className:"size-4 text-fg-subtle","aria-hidden":!0}),e.jsxs("span",{className:"font-mono text-[13px] font-semibold",children:[d.from," → ",d.to]})]}),e.jsxs("div",{className:"space-y-1 text-fg-muted",children:[e.jsxs("p",{children:["Source: ",e.jsx(R,{variant:d.source==="manual"?"accent":"neutral",size:"xs",children:d.source})]}),d.source==="detected"&&e.jsxs("p",{children:["Evidence: ",v(d.evidence)," sampled jobs referenced this parent."]}),d.label&&e.jsxs("p",{children:["Label: ",d.label]})]}),d.source==="manual"&&u&&e.jsx(b,{size:"sm",variant:"ghost",className:"mt-3 hover:text-danger",leftIcon:e.jsx(ge,{}),loading:g.isPending,onClick:()=>g.mutate(d.id,{onSuccess:()=>(j(null),E.success("Edge removed")),onError:s=>E.error(F(s))}),children:"Delete manual edge"}),d.source==="detected"&&e.jsx("p",{className:"mt-2 text-fg-subtle",children:"Detected edges disappear on their own once no sampled job references the parent."})]})]})]}),n.data&&e.jsx(De,{open:Y,onClose:()=>D(!1),queues:n.data.nodes.map(s=>s.queueName),saving:w.isPending,onSave:(s,l,a)=>w.mutate({connectionId:t,from:s,to:l,label:a||null},{onSuccess:()=>(D(!1),E.success("Edge added")),onError:x=>E.error(F(x))})})]})}function De({open:t,onClose:o,queues:u,onSave:i,saving:p}){const m=c.useMemo(()=>[...u].sort((r,L)=>r.localeCompare(L)),[u]),[n,w]=c.useState(m[0]??""),[g,q]=c.useState(m[1]??""),[h,z]=c.useState(""),y=n===g;return e.jsx(he,{open:t,onClose:o,size:"sm",title:"Add manual edge",description:"Document a producer → consumer relationship that Redis cannot observe.",footer:e.jsxs(e.Fragment,{children:[e.jsx(b,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),e.jsx(b,{variant:"primary",size:"sm",disabled:y||!n||!g,loading:p,onClick:()=>i(n,g,h.trim()),children:"Add edge"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(S,{label:"From (producer)",value:n,onChange:r=>w(r.target.value),options:m.map(r=>({value:r,label:r}))}),e.jsx(S,{label:"To (consumer)",value:g,onChange:r=>q(r.target.value),options:m.map(r=>({value:r,label:r})),error:y?"Pick two different queues":void 0}),e.jsx(pe,{label:"Label (optional)",value:h,onChange:r=>z(r.target.value),maxLength:120,placeholder:"e.g. enqueues on success"})]})})}export{Me as FlowsIndexPage,Ae as FlowsPage};
@@ -1 +0,0 @@
1
- import{y as S,z as P,e as N,j as e,A as o,C as M,S as C,N as A,F as B,G as q,f as p,n as j,B as m,H as E,v as z}from"./index-CN2nADIL.js";function L(){const[n]=S(),t=P(),{user:s,loading:a}=N(),r=n.get("error"),i=n.get("request");return r||!i?e.jsx(o,{title:"Could not connect to Bullpane",children:e.jsxs("p",{className:"flex gap-2 text-sm text-fg",children:[e.jsx(M,{className:"mt-0.5 size-4 shrink-0 text-danger"}),r??"This page needs a sign-in request from an MCP client. Start the connection again from Claude."]})}):a?e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx(C,{})}):s?e.jsx(D,{request:i}):e.jsx(A,{to:"/login",replace:!0,state:{from:t}})}function D({request:n}){const{user:t}=N(),s=B(n),a=q(),[r,i]=p.useState(null),[f,g]=p.useState(null);if(s.isLoading)return e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx(C,{})});if(s.isError||!s.data)return e.jsx(o,{title:"Could not connect to Bullpane",children:e.jsx("p",{className:"text-sm text-fg",children:j(s.error,"This sign-in request is no longer valid. Start the connection again from Claude.")})});const{clientName:c,redirectHost:w,allowed:l,requested:y,maxAccess:k}=s.data,d=r??(l==="write"&&y==="write"?"write":"read"),h=l==="write"?null:k!=="write"?"an admin limited MCP to read only":`your role is ${t==null?void 0:t.role}`,x=v=>{g(null),a.mutate({request:n,approve:v,access:d},{onSuccess:({redirectTo:u})=>window.location.assign(u),onError:u=>g(j(u))})};return l==="off"?e.jsxs(o,{title:"MCP is turned off",children:[e.jsxs("p",{className:"text-sm text-fg-muted",children:["An admin has to allow MCP clients in ",e.jsx("span",{className:"text-fg",children:"Settings → MCP"})," before ",c," can connect."]}),e.jsxs(m,{className:"mt-5 w-full",variant:"secondary",loading:a.isPending,onClick:()=>x(!1),children:["Back to ",c]})]}):e.jsxs(o,{title:`Connect ${c} to Bullpane`,description:e.jsxs(e.Fragment,{children:["It will act as ",e.jsx("span",{className:"text-fg",children:t==null?void 0:t.email})," (",t==null?void 0:t.role,") and send you back to ",w,"."]}),children:[e.jsxs("div",{className:"flex flex-col gap-2",role:"radiogroup","aria-label":"Access",children:[e.jsx(b,{selected:d==="read",onSelect:()=>i("read"),title:"Read only",detail:"See connections, queues, jobs, logs and schedulers."}),e.jsx(b,{selected:d==="write",disabled:l!=="write",onSelect:()=>i("write"),title:"Read & write",detail:h?`Not available: ${h}.`:"Also retry, promote, remove and add jobs, pause and resume queues."})]}),e.jsxs("p",{className:"mt-3 flex gap-1.5 text-[11px] text-fg-subtle",children:[e.jsx(E,{className:"size-3.5 shrink-0"}),"Every change is in the audit log. Drain, clean and obliterate always need you in the dashboard. Disconnect any time in Settings → MCP."]}),f&&e.jsx("p",{className:"mt-3 text-xs text-danger",children:f}),e.jsxs("div",{className:"mt-5 flex gap-2",children:[e.jsx(m,{className:"flex-1",variant:"ghost",disabled:a.isPending,onClick:()=>x(!1),children:"Cancel"}),e.jsx(m,{className:"flex-1",variant:"primary",loading:a.isPending,onClick:()=>x(!0),children:"Allow"})]})]})}function b({selected:n,disabled:t,onSelect:s,title:a,detail:r}){return e.jsxs("button",{type:"button",role:"radio","aria-checked":n,disabled:t,onClick:s,className:z("rounded-md border px-3 py-2.5 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-60",n?"border-accent bg-accent/10":"border-border bg-surface-2 hover:border-border-strong"),children:[e.jsx("span",{className:"block text-sm font-medium text-fg",children:a}),e.jsx("span",{className:"mt-0.5 block text-xs text-fg-muted",children:r})]})}export{L as McpConsentPage};