import{r as xo,g as ca,R as ua,a as D,j as P}from"./react-vendor-BVoutfaX.js";function ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n{}};function Kt(){for(var e=0,t=arguments.length,n={},r;e=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}})}Tt.prototype=Kt.prototype={constructor:Tt,on:function(e,t){var n=this._,r=fa(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i0)for(var n=new Array(o),r=0,o,i;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),dr.hasOwnProperty(t)?{space:dr[t],local:e}:e}function ha(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Nn&&t.documentElement.namespaceURI===Nn?t.createElement(e):t.createElementNS(n,e)}}function ga(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function wo(e){var t=Zt(e);return(t.local?ga:ha)(t)}function pa(){}function Vn(e){return e==null?pa:function(){return this.querySelector(e)}}function ma(e){typeof e!="function"&&(e=Vn(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o=p&&(p=b+1);!(N=x[p])&&++p=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Fa(e){e||(e=Oa);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,r=n.length,o=new Array(r),i=0;it?1:e>=t?0:NaN}function ja(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Xa(){return Array.from(this)}function Ya(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?nc:typeof t=="function"?oc:rc)(e,t,n??"")):Xe(this.node(),e)}function Xe(e,t){return e.style.getPropertyValue(t)||So(e).getComputedStyle(e,null).getPropertyValue(t)}function sc(e){return function(){delete this[e]}}function ac(e,t){return function(){this[e]=t}}function cc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function uc(e,t){return arguments.length>1?this.each((t==null?sc:typeof t=="function"?cc:ac)(e,t)):this.node()[e]}function No(e){return e.trim().split(/^|\s+/)}function Bn(e){return e.classList||new Mo(e)}function Mo(e){this._node=e,this._names=No(e.getAttribute("class")||"")}Mo.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 Co(e,t){for(var n=Bn(e),r=-1,o=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Hc(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n()=>e;function Mn(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:l,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:d}})}Mn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function qc(e){return!e.ctrlKey&&!e.button}function Gc(){return this.parentNode}function Uc(e,t){return t??{x:e.x,y:e.y}}function Kc(){return navigator.maxTouchPoints||"ontouchstart"in this}function To(){var e=qc,t=Gc,n=Uc,r=Kc,o={},i=Kt("start","drag","end"),s=0,a,c,l,d,u=0;function f(w){w.on("mousedown.drag",h).filter(r).on("touchstart.drag",x).on("touchmove.drag",m,Wc).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,N){if(!(d||!e.call(this,w,N))){var _=p(this,t.call(this,w,N),w,N,"mouse");_&&(ce(w.view).on("mousemove.drag",g,at).on("mouseup.drag",y,at),$o(w.view),dn(w),l=!1,a=w.clientX,c=w.clientY,_("start",w))}}function g(w){if(Oe(w),!l){var N=w.clientX-a,_=w.clientY-c;l=N*N+_*_>u}o.mouse("drag",w)}function y(w){ce(w.view).on("mousemove.drag mouseup.drag",null),Po(w.view,l),Oe(w),o.mouse("end",w)}function x(w,N){if(e.call(this,w,N)){var _=w.changedTouches,M=t.call(this,w,N),T=_.length,z,B;for(z=0;z>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nt(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=Qc.exec(e))?new ae(t[1],t[2],t[3],1):(t=Jc.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=eu.exec(e))?Nt(t[1],t[2],t[3],t[4]):(t=tu.exec(e))?Nt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=nu.exec(e))?wr(t[1],t[2]/100,t[3]/100,1):(t=ru.exec(e))?wr(t[1],t[2]/100,t[3]/100,t[4]):hr.hasOwnProperty(e)?mr(hr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function mr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Nt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function su(e){return e instanceof yt||(e=ze(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Cn(e,t,n,r){return arguments.length===1?su(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}Fn(ae,Cn,zo(yt,{brighter(e){return e=e==null?Vt:Math.pow(Vt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ct:Math.pow(ct,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Pe(this.r),Pe(this.g),Pe(this.b),Bt(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:yr,formatHex:yr,formatHex8:au,formatRgb:xr,toString:xr}));function yr(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function au(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function xr(){const e=Bt(this.opacity);return`${e===1?"rgb(":"rgba("}${Pe(this.r)}, ${Pe(this.g)}, ${Pe(this.b)}${e===1?")":`, ${e})`}`}function Bt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $e(e){return e=Pe(e),(e<16?"0":"")+e.toString(16)}function wr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new fe(e,t,n,r)}function Do(e){if(e instanceof fe)return new fe(e.h,e.s,e.l,e.opacity);if(e instanceof yt||(e=ze(e)),!e)return new fe;if(e instanceof fe)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+(n0&&c<1?0:s,new fe(s,a,c,e.opacity)}function cu(e,t,n,r){return arguments.length===1?Do(e):new fe(e,t,n,r??1)}function fe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Fn(fe,cu,zo(yt,{brighter(e){return e=e==null?Vt:Math.pow(Vt,e),new fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ct:Math.pow(ct,e),new fe(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(hn(e>=240?e-240:e+120,o,r),hn(e,o,r),hn(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new fe(vr(this.h),Mt(this.s),Mt(this.l),Bt(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=Bt(this.opacity);return`${e===1?"hsl(":"hsla("}${vr(this.h)}, ${Mt(this.s)*100}%, ${Mt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function vr(e){return e=(e||0)%360,e<0?e+360:e}function Mt(e){return Math.max(0,Math.min(1,e||0))}function hn(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 On=e=>()=>e;function uu(e,t){return function(n){return e+n*t}}function lu(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 fu(e){return(e=+e)==1?Lo:function(t,n){return n-t?lu(t,n,e):On(isNaN(t)?n:t)}}function Lo(e,t){var n=t-e;return n?uu(e,n):On(isNaN(e)?t:e)}const Ft=(function e(t){var n=fu(t);function r(o,i){var s=n((o=Cn(o)).r,(i=Cn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),l=Lo(o.opacity,i.opacity);return function(d){return o.r=s(d),o.g=a(d),o.b=c(d),o.opacity=l(d),o+""}}return r.gamma=e,r})(1);function du(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;on&&(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:pe(r,o)})),n=gn.lastIndex;return n180?d+=360:d-l>180&&(l+=360),f.push({i:u.push(o(u)+"rotate(",null,r)-2,x:pe(l,d)})):d&&u.push(o(u)+"rotate("+d+r)}function a(l,d,u,f){l!==d?f.push({i:u.push(o(u)+"skewX(",null,r)-2,x:pe(l,d)}):d&&u.push(o(u)+"skewX("+d+r)}function c(l,d,u,f,h,g){if(l!==u||d!==f){var y=h.push(o(h)+"scale(",null,",",null,")");g.push({i:y-4,x:pe(l,u)},{i:y-2,x:pe(d,f)})}else(u!==1||f!==1)&&h.push(o(h)+"scale("+u+","+f+")")}return function(l,d){var u=[],f=[];return l=e(l),d=e(d),i(l.translateX,l.translateY,d.translateX,d.translateY,u,f),s(l.rotate,d.rotate,u,f),a(l.skewX,d.skewX,u,f),c(l.scaleX,l.scaleY,d.scaleX,d.scaleY,u,f),l=d=null,function(h){for(var g=-1,y=f.length,x;++g=0&&e._call.call(void 0,t),e=e._next;--Ye}function Er(){De=(jt=lt.now())+Qt,Ye=rt=0;try{Cu()}finally{Ye=0,ku(),De=0}}function Iu(){var e=lt.now(),t=e-jt;t>Bo&&(Qt-=t,jt=e)}function ku(){for(var e,t=Ot,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:Ot=n);ot=e,An(r)}function An(e){if(!Ye){rt&&(rt=clearTimeout(rt));var t=e-De;t>24?(e<1/0&&(rt=setTimeout(Er,e-lt.now()-Qt)),tt&&(tt=clearInterval(tt))):(tt||(jt=lt.now(),tt=setInterval(Iu,Bo)),Ye=1,Fo(Er))}}function Sr(e,t,n){var r=new Xt;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Au=Kt("start","end","cancel","interrupt"),$u=[],jo=0,Nr=1,$n=2,Dt=3,Mr=4,Pn=5,Lt=6;function Jt(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Pu(e,n,{name:t,index:r,group:o,on:Au,tween:$u,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:jo})}function Xn(e,t){var n=ge(e,t);if(n.state>jo)throw new Error("too late; already scheduled");return n}function xe(e,t){var n=ge(e,t);if(n.state>Dt)throw new Error("too late; already running");return n}function ge(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Pu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Oo(i,0,n.time);function i(l){n.state=Nr,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var d,u,f,h;if(n.state!==Nr)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===Dt)return Sr(s);h.state===Mr?(h.state=Lt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d$n&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function cl(e,t,n){var r,o,i=al(t)?Xn:xe;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function ul(e,t){var n=this._id;return arguments.length<2?ge(this.node(),n).on.on(e):this.each(cl(n,e,t))}function ll(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fl(){return this.on("end.remove",ll(this._id))}function dl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Vn(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s()=>e;function Hl(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 be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(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 en=new be(1,0,0);qo.prototype=be.prototype;function qo(e){for(;!e.__zoom;)if(!(e=e.parentNode))return en;return e.__zoom}function pn(e){e.stopImmediatePropagation()}function nt(e){e.preventDefault(),e.stopImmediatePropagation()}function Rl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Vl(){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 Cr(){return this.__zoom||en}function Bl(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Fl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ol(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 Go(){var e=Rl,t=Vl,n=Ol,r=Bl,o=Fl,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=zt,l=Kt("start","zoom","end"),d,u,f,h=500,g=150,y=0,x=10;function m(v){v.property("__zoom",Cr).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",B).filter(o).on("touchstart.zoom",I).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(v,k,E,A){var C=v.selection?v.selection():v;C.property("__zoom",Cr),v!==C?N(v,k,E,A):C.interrupt().each(function(){_(this,arguments).event(A).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},m.scaleBy=function(v,k,E,A){m.scaleTo(v,function(){var C=this.__zoom.k,S=typeof k=="function"?k.apply(this,arguments):k;return C*S},E,A)},m.scaleTo=function(v,k,E,A){m.transform(v,function(){var C=t.apply(this,arguments),S=this.__zoom,L=E==null?w(C):typeof E=="function"?E.apply(this,arguments):E,R=S.invert(L),H=typeof k=="function"?k.apply(this,arguments):k;return n(p(b(S,H),L,R),C,s)},E,A)},m.translateBy=function(v,k,E,A){m.transform(v,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),s)},null,A)},m.translateTo=function(v,k,E,A,C){m.transform(v,function(){var S=t.apply(this,arguments),L=this.__zoom,R=A==null?w(S):typeof A=="function"?A.apply(this,arguments):A;return n(en.translate(R[0],R[1]).scale(L.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof E=="function"?-E.apply(this,arguments):-E),S,s)},A,C)};function b(v,k){return k=Math.max(i[0],Math.min(i[1],k)),k===v.k?v:new be(k,v.x,v.y)}function p(v,k,E){var A=k[0]-E[0]*v.k,C=k[1]-E[1]*v.k;return A===v.x&&C===v.y?v:new be(v.k,A,C)}function w(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function N(v,k,E,A){v.on("start.zoom",function(){_(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(A).end()}).tween("zoom",function(){var C=this,S=arguments,L=_(C,S).event(A),R=t.apply(C,S),H=E==null?w(R):typeof E=="function"?E.apply(C,S):E,O=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),j=C.__zoom,Y=typeof k=="function"?k.apply(C,S):k,U=c(j.invert(H).concat(O/j.k),Y.invert(H).concat(O/Y.k));return function(q){if(q===1)q=Y;else{var F=U(q),W=O/F[2];q=new be(W,H[0]-F[0]*W,H[1]-F[1]*W)}L.zoom(null,q)}})}function _(v,k,E){return!E&&v.__zooming||new M(v,k)}function M(v,k){this.that=v,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,k),this.taps=0}M.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,k){return this.mouse&&v!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var k=ce(this.that).datum();l.call(v,this.that,new Hl(v,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),k)}};function T(v,...k){if(!e.apply(this,arguments))return;var E=_(this,k).event(v),A=this.__zoom,C=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),S=le(v);if(E.wheel)(E.mouse[0][0]!==S[0]||E.mouse[0][1]!==S[1])&&(E.mouse[1]=A.invert(E.mouse[0]=S)),clearTimeout(E.wheel);else{if(A.k===C)return;E.mouse=[S,A.invert(S)],Ht(this),E.start()}nt(v),E.wheel=setTimeout(L,g),E.zoom("mouse",n(p(b(A,C),E.mouse[0],E.mouse[1]),E.extent,s));function L(){E.wheel=null,E.end()}}function z(v,...k){if(f||!e.apply(this,arguments))return;var E=v.currentTarget,A=_(this,k,!0).event(v),C=ce(v.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",O,!0),S=le(v,E),L=v.clientX,R=v.clientY;$o(v.view),pn(v),A.mouse=[S,this.__zoom.invert(S)],Ht(this),A.start();function H(j){if(nt(j),!A.moved){var Y=j.clientX-L,U=j.clientY-R;A.moved=Y*Y+U*U>y}A.event(j).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=le(j,E),A.mouse[1]),A.extent,s))}function O(j){C.on("mousemove.zoom mouseup.zoom",null),Po(j.view,A.moved),nt(j),A.event(j).end()}}function B(v,...k){if(e.apply(this,arguments)){var E=this.__zoom,A=le(v.changedTouches?v.changedTouches[0]:v,this),C=E.invert(A),S=E.k*(v.shiftKey?.5:2),L=n(p(b(E,S),A,C),t.apply(this,k),s);nt(v),a>0?ce(this).transition().duration(a).call(N,L,A,v):ce(this).call(m.transform,L,A,v)}}function I(v,...k){if(e.apply(this,arguments)){var E=v.touches,A=E.length,C=_(this,k,v.changedTouches.length===A).event(v),S,L,R,H;for(pn(v),L=0;L"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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."},ft=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Uo=["Enter"," ","Escape"],Ko={"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 We;(function(e){e.Strict="strict",e.Loose="loose"})(We||(We={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var dt;(function(e){e.Partial="partial",e.Full="full"})(dt||(dt={}));const Zo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ce;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ce||(Ce={}));var Yt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Yt||(Yt={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Ir={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function Qo(e){return e===null?null:e?"valid":"invalid"}const Jo=e=>"id"in e&&"source"in e&&"target"in e,jl=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Wn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),xt=(e,t=[0,0])=>{const{width:n,height:r}=Ee(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},Xl=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let s=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(o):Wn(o)?o:t.nodeLookup.get(o.id));const a=s?Wt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return tn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return nn(n)},wt=(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=tn(n,Wt(o)),r=!0)}),r?nn(n):{x:0,y:0,width:0,height:0}},qn=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a={...bt(t,[n,r,o]),width:t.width/o,height:t.height/o},c=[];for(const l of e.values()){const{measured:d,selectable:u=!0,hidden:f=!1}=l;if(s&&!u||f)continue;const h=d.width??l.width??l.initialWidth??null,g=d.height??l.height??l.initialHeight??null,y=ht(a,Ge(l)),x=(h??0)*(g??0),m=i&&y>0;(!l.internals.handleBounds||m||y>=x||l.dragging)&&c.push(l)}return c},Yl=(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 Wl(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function ql({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=Wl(e,s),c=wt(a),l=Gn(c,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(l,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function ei({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},d=s.origin??r;let u=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",ye.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[c,l],[c+h,l+g]])}else a&&Ue(s.extent)&&(u=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const f=Ue(u)?Le(t,u,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",ye.error015())),{position:{x:f.x-c+(s.measured.width??0)*d[0],y:f.y-l+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function Gl({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(y=>y.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),d=Yl(s,c);for(const f of c)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!o)return{edges:d,nodes:s};const u=await o({nodes:s,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:s}:{edges:[],nodes:[]}:u}const qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Le=(e={x:0,y:0},t,n)=>({x:qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ti(e,t,n){const{width:r,height:o}=Ee(n),{x:i,y:s}=n.internals.positionAbsolute;return Le(e,[[i,s],[i+r,s+o]],t)}const kr=(e,t,n)=>en?-qe(Math.abs(e-n),1,t)/t:0,ni=(e,t,n=15,r=40)=>{const o=kr(e.x,r,t.width-r)*n,i=kr(e.y,r,t.height-r)*n;return[o,i]},tn=(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)}),Tn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),nn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Ge=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Wn(e)?e.internals.positionAbsolute:xt(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}},Wt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Wn(e)?e.internals.positionAbsolute:xt(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)}},ri=(e,t)=>nn(tn(Tn(e),Tn(t))),ht=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Ar=e=>de(e.width)&&de(e.height)&&de(e.x)&&de(e.y),de=e=>!isNaN(e)&&isFinite(e),Ul=(e,t)=>{},vt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),bt=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?vt(a,s):a},qt=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ve(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(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Kl(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ve(e,n),o=Ve(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ve(e.top??e.y??0,n),o=Ve(e.bottom??e.y??0,n),i=Ve(e.left??e.x??0,t),s=Ve(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 Zl(e,t,n,r,o,i){const{x:s,y:a}=qt(e,[t,n,r]),{x:c,y:l}=qt({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=o-c,u=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}const Gn=(e,t,n,r,o,i)=>{const s=Kl(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),d=qe(l,r,o),u=e.x+e.width/2,f=e.y+e.height/2,h=t/2-u*d,g=n/2-f*d,y=Zl(e,h,g,d,t,n),x={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:d}},gt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ue(e){return e!=null&&e!=="parent"}function Ee(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 oi(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 ii(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 $r(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Ql(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function Jl(e){return{...Ko,...e||{}}}function st(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=he(e),a=bt({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?vt(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Un=e=>({width:e.offsetWidth,height:e.offsetHeight}),si=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},ef=["INPUT","SELECT","TEXTAREA"];function ai(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:ef.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const ci=e=>"clientX"in e,he=(e,t)=>{var i,s;const n=ci(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)}},Pr=(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,...Un(s)}})};function ui({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+o*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+r*.125,d=Math.abs(c-e),u=Math.abs(l-t);return[c,l,d,u]}function kt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Tr({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case X.Left:return[t-kt(t-r,i),n];case X.Right:return[t+kt(r-t,i),n];case X.Top:return[t,n-kt(n-o,i)];case X.Bottom:return[t,n+kt(o-n,i)]}}function li({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:o,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Tr({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[l,d]=Tr({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[u,f,h,g]=ui({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${a},${c} ${l},${d} ${r},${o}`,u,f,h,g]}function fi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n0}const rf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,of=(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)),sf=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||rf;let o;return Jo(e)?o={...e}:o={...e,id:r(e)},of(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function di({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=fi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const zr={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},af=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cf({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:r=X.Top,center:o,offset:i,stepPosition:s}){const a=zr[t],c=zr[r],l={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},u=af({source:l,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],y,x;const m={x:0,y:0},b={x:0,y:0},[,,p,w]=fi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(y=o.x??l.x+(d.x-l.x)*s,x=o.y??(l.y+d.y)/2):(y=o.x??(l.x+d.x)/2,x=o.y??l.y+(d.y-l.y)*s);const _=[{x:y,y:l.y},{x:y,y:d.y}],M=[{x:l.x,y:x},{x:d.x,y:x}];a[f]===h?g=f==="x"?_:M:g=f==="x"?M:_}else{const _=[{x:l.x,y:d.y}],M=[{x:d.x,y:l.y}];if(f==="x"?g=a.x===h?M:_:g=a.y===h?_:M,t===r){const $=Math.abs(e[f]-n[f]);if($<=i){const V=Math.min(i-1,i-$);a[f]===h?m[f]=(l[f]>e[f]?-1:1)*V:b[f]=(d[f]>n[f]?-1:1)*V}}if(t!==r){const $=f==="x"?"y":"x",V=a[f]===c[$],v=l[$]>d[$],k=l[$]=I?(y=(T.x+z.x)/2,x=g[0].y):(y=g[0].x,x=(T.y+z.y)/2)}return[[e,{x:l.x+m.x,y:l.y+m.y},...g,{x:d.x+b.x,y:d.y+b.y},n],y,x,p,w]}function uf(e,t,n,r){const o=Math.min(Dr(e,t)/2,Dr(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x{let w="";return p>0&&pn.id===t):e[0])||null}function Dn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function ff(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const l=Dn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const hi=1e3,df=10,Kn={nodeOrigin:[0,0],nodeExtent:ft,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},hf={...Kn,checkEquality:!0};function Zn(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function gf(e,t,n){const r=Zn(Kn,n);for(const o of e.values())if(o.parentId)Jn(o,e,t,r);else{const i=xt(o,r.nodeOrigin),s=Ue(o.extent)?o.extent:r.nodeExtent,a=Le(i,s,Ee(o));o.internals.positionAbsolute=a}}function pf(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 Qn(e){return e==="manual"}function Ln(e,t,n,r={}){var l,d;const o=Zn(hf,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!Qn(o.zIndexMode)?hi:0;let c=e.length>0;t.clear(),n.clear();for(const u of e){let f=s.get(u.id);if(o.checkEquality&&u===(f==null?void 0:f.internals.userNode))t.set(u.id,f);else{const h=xt(u,o.nodeOrigin),g=Ue(u.extent)?u.extent:o.nodeExtent,y=Le(h,g,Ee(u));f={...o.defaults,...u,measured:{width:(l=u.measured)==null?void 0:l.width,height:(d=u.measured)==null?void 0:d.height},internals:{positionAbsolute:y,handleBounds:pf(u,f),z:gi(u,a,o.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),u.parentId&&Jn(f,t,n,r,i)}return c}function mf(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 Jn(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=Zn(Kn,r),l=e.parentId,d=t.get(l);if(!d){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mf(e,n),o&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++o.i,d.internals.z=d.internals.z+o.i*df),o&&d.internals.rootParentIndex!==void 0&&(o.i=d.internals.rootParentIndex);const u=i&&!Qn(c)?hi:0,{x:f,y:h,z:g}=yf(e,d,s,a,u,c),{positionAbsolute:y}=e.internals,x=f!==y.x||h!==y.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:y,z:g}})}function gi(e,t,n){const r=de(e.zIndex)?e.zIndex:0;return Qn(n)?r:r+(e.selected?t:0)}function yf(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=Ee(e),l=xt(e,n),d=Ue(e.extent)?Le(l,e.extent,c):l;let u=Le({x:s+d.x,y:a+d.y},r,c);e.extent==="parent"&&(u=ti(u,c,t));const f=gi(e,o,i),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function er(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Ge(c),d=ri(l,a.rect);i.set(a.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},l)=>{var p;const d=c.internals.positionAbsolute,u=Ee(c),f=c.origin??r,h=a.x0||g>0||m||b)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+m,y:c.position.y-g+b}}),(p=n.get(l))==null||p.forEach(w=>{e.some(N=>N.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+h,y:w.position.y+g}})})),(u.width0){const h=er(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function wf({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Vr(e,t,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),i){s=`${o}-${e}-${i}`;const l=r.get(s)||new Map;r.set(s,l.set(n,t))}}function pi(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},l=`${o}-${s}--${i}-${a}`,d=`${i}-${a}--${o}-${s}`;Vr("source",c,d,e,o,s),Vr("target",c,l,e,i,a),t.set(r.id,r)}}function mi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:mi(n,t):!1}function Br(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 vf(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!mi(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 mn({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[l,d]of t){const u=(s=n.get(l))==null?void 0:s.internals.userNode;u&&o.push({...u,position:d.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 bf({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=vt(i,t);return{x:s.x-i.x,y:s.y-i.y}}function _f({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},d=null,u=!1,f=null,h=!1,g=!1,y=null;function x({noDragClassName:b,handleSelector:p,domNode:w,isSelectable:N,nodeId:_,nodeClickDistance:M=0}){f=ce(w);function T({x:$,y:V}){const{nodeLookup:v,nodeExtent:k,snapGrid:E,snapToGrid:A,nodeOrigin:C,onNodeDrag:S,onSelectionDrag:L,onError:R,updateNodePositions:H}=t();i={x:$,y:V};let O=!1;const j=a.size>1,Y=j&&k?Tn(wt(a)):null,U=j&&A?bf({dragItems:a,snapGrid:E,x:$,y:V}):null;for(const[q,F]of a){if(!v.has(q))continue;let W={x:$-F.distance.x,y:V-F.distance.y};A&&(W=U?{x:Math.round(W.x+U.x),y:Math.round(W.y+U.y)}:vt(W,E));let Q=null;if(j&&k&&!F.extent&&Y){const{positionAbsolute:G}=F.internals,te=G.x-Y.x+k[0][0],ne=G.x+F.measured.width-Y.x2+k[1][0],ee=G.y-Y.y+k[0][1],se=G.y+F.measured.height-Y.y2+k[1][1];Q=[[te,ee],[ne,se]]}const{position:Z,positionAbsolute:K}=ei({nodeId:q,nextPosition:W,nodeLookup:v,nodeExtent:Q||k,nodeOrigin:C,onError:R});O=O||F.position.x!==Z.x||F.position.y!==Z.y,F.position=Z,F.internals.positionAbsolute=K}if(g=g||O,!!O&&(H(a,!0),y&&(r||S||!_&&L))){const[q,F]=mn({nodeId:_,dragItems:a,nodeLookup:v});r==null||r(y,a,q,F),S==null||S(y,q,F),_||L==null||L(y,F)}}async function z(){if(!d)return;const{transform:$,panBy:V,autoPanSpeed:v,autoPanOnNodeDrag:k}=t();if(!k){c=!1,cancelAnimationFrame(s);return}const[E,A]=ni(l,d,v);(E!==0||A!==0)&&(i.x=(i.x??0)-E/$[2],i.y=(i.y??0)-A/$[2],await V({x:E,y:A})&&T(i)),s=requestAnimationFrame(z)}function B($){var j;const{nodeLookup:V,multiSelectionActive:v,nodesDraggable:k,transform:E,snapGrid:A,snapToGrid:C,selectNodesOnDrag:S,onNodeDragStart:L,onSelectionDragStart:R,unselectNodesAndEdges:H}=t();u=!0,(!S||!N)&&!v&&_&&((j=V.get(_))!=null&&j.selected||H()),N&&S&&_&&(e==null||e(_));const O=st($.sourceEvent,{transform:E,snapGrid:A,snapToGrid:C,containerBounds:d});if(i=O,a=vf(V,k,O,_),a.size>0&&(n||L||!_&&R)){const[Y,U]=mn({nodeId:_,dragItems:a,nodeLookup:V});n==null||n($.sourceEvent,a,Y,U),L==null||L($.sourceEvent,Y,U),_||R==null||R($.sourceEvent,U)}}const I=To().clickDistance(M).on("start",$=>{const{domNode:V,nodeDragThreshold:v,transform:k,snapGrid:E,snapToGrid:A}=t();d=(V==null?void 0:V.getBoundingClientRect())||null,h=!1,g=!1,y=$.sourceEvent,v===0&&B($),i=st($.sourceEvent,{transform:k,snapGrid:E,snapToGrid:A,containerBounds:d}),l=he($.sourceEvent,d)}).on("drag",$=>{const{autoPanOnNodeDrag:V,transform:v,snapGrid:k,snapToGrid:E,nodeDragThreshold:A,nodeLookup:C}=t(),S=st($.sourceEvent,{transform:v,snapGrid:k,snapToGrid:E,containerBounds:d});if(y=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||_&&!C.has(_))&&(h=!0),!h){if(!c&&V&&u&&(c=!0,z()),!u){const L=he($.sourceEvent,d),R=L.x-l.x,H=L.y-l.y;Math.sqrt(R*R+H*H)>A&&B($)}(i.x!==S.xSnapped||i.y!==S.ySnapped)&&a&&u&&(l=he($.sourceEvent,d),T(S))}}).on("end",$=>{if(!(!u||h)&&(c=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:V,updateNodePositions:v,onNodeDragStop:k,onSelectionDragStop:E}=t();if(g&&(v(a,!1),g=!1),o||k||!_&&E){const[A,C]=mn({nodeId:_,dragItems:a,nodeLookup:V,dragging:!1});o==null||o($.sourceEvent,a,A,C),k==null||k($.sourceEvent,A,C),_||E==null||E($.sourceEvent,C)}}}).filter($=>{const V=$.target;return!$.button&&(!b||!Br(V,`.${b}`,w))&&(!p||Br(V,p,w))});f.call(I)}function m(){f==null||f.on(".drag",null)}return{update:x,destroy:m}}function Ef(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())ht(o,Ge(i))>0&&r.push(i);return r}const Sf=250;function Nf(e,t,n,r){var a,c;let o=[],i=1/0;const s=Ef(e,n,t+Sf);for(const l of s){const d=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of d){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:f,y:h}=He(l,u,u.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g1){const l=r.type==="source"?"target":"source";return o.find(d=>d.type===l)??o[0]}return o[0]}function yi(e,t,n,r,o,i=!1){var l,d,u;const s=r.get(e);if(!s)return null;const a=o==="strict"?(l=s.internals.handleBounds)==null?void 0:l[t]:[...((d=s.internals.handleBounds)==null?void 0:d.source)??[],...((u=s.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...He(s,c,c.position,!0)}:c}function xi(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Mf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const wi=()=>!0;function Cf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:y,onConnectEnd:x,isValidConnection:m=wi,onReconnectEnd:b,updateConnection:p,getTransform:w,getFromHandle:N,autoPanSpeed:_,dragThreshold:M=1,handleDomNode:T}){const z=si(e.target);let B=0,I;const{x:$,y:V}=he(e),v=xi(i,T),k=a==null?void 0:a.getBoundingClientRect();let E=!1;if(!k||!v)return;const A=yi(o,v,r,c,t);if(!A)return;let C=he(e,k),S=!1,L=null,R=!1,H=null;function O(){if(!d||!k)return;const[Z,K]=ni(C,k,_);f({x:Z,y:K}),B=requestAnimationFrame(O)}const j={...A,nodeId:o,type:v,position:A.position},Y=c.get(o);let q={inProgress:!0,isValid:null,from:He(Y,j,X.Left,!0),fromHandle:j,fromPosition:j.position,fromNode:Y,to:C,toHandle:null,toPosition:Ir[j.position],toNode:null,pointer:C};function F(){E=!0,p(q),g==null||g(e,{nodeId:o,handleId:r,handleType:v})}M===0&&F();function W(Z){if(!E){const{x:se,y:Se}=he(Z),we=se-$,ke=Se-V;if(!(we*we+ke*ke>M*M))return;F()}if(!N()||!j){Q(Z);return}const K=w();C=he(Z,k),I=Nf(bt(C,K,!1,[1,1]),n,c,j),S||(O(),S=!0);const G=vi(Z,{handle:I,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:z,lib:l,flowId:u,nodeLookup:c});H=G.handleDomNode,L=G.connection,R=Mf(!!I,G.isValid);const te=c.get(o),ne=te?He(te,j,X.Left,!0):q.from,ee={...q,from:ne,isValid:R,to:G.toHandle&&R?qt({x:G.toHandle.x,y:G.toHandle.y},K):C,toHandle:G.toHandle,toPosition:R&&G.toHandle?G.toHandle.position:Ir[j.position],toNode:G.toHandle?c.get(G.toHandle.nodeId):null,pointer:C};p(ee),q=ee}function Q(Z){if(!("touches"in Z&&Z.touches.length>0)){if(E){(I||H)&&L&&R&&(y==null||y(L));const{inProgress:K,...G}=q,te={...G,toPosition:q.toHandle?q.toPosition:null};x==null||x(Z,te),i&&(b==null||b(Z,te))}h(),cancelAnimationFrame(B),S=!1,R=!1,L=null,H=null,z.removeEventListener("mousemove",W),z.removeEventListener("mouseup",Q),z.removeEventListener("touchmove",W),z.removeEventListener("touchend",Q)}}z.addEventListener("mousemove",W),z.addEventListener("mouseup",Q),z.addEventListener("touchmove",W),z.addEventListener("touchend",Q)}function vi(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=wi,nodeLookup:d}){const u=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=he(e),y=s.elementFromPoint(h,g),x=y!=null&&y.classList.contains(`${a}-flow__handle`)?y:f,m={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const b=xi(void 0,x),p=x.getAttribute("data-nodeid"),w=x.getAttribute("data-handleid"),N=x.classList.contains("connectable"),_=x.classList.contains("connectableend");if(!p||!b)return m;const M={source:u?p:r,sourceHandle:u?w:o,target:u?r:p,targetHandle:u?o:w};m.connection=M;const z=N&&_&&(n===We.Strict?u&&b==="source"||!u&&b==="target":p!==r||w!==o);m.isValid=z&&l(M),m.toHandle=yi(p,b,w,d,n,!0)}return m}const Hn={onPointerDown:Cf,isValid:vi};function If({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:l,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),N=p.sourceEvent.ctrlKey&>()?10:1,_=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,M=w[2]*Math.pow(2,_*N);t.scaleTo(M)};let y=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const w=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],_=[N[0]-y[0],N[1]-y[1]];y=N;const M=r()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),T={x:w[0]-_[0]*M,y:w[1]-_[1]*M},z=[[0,0],[c,l]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},z,a)},b=Go().on("start",x).on("zoom",u?m:null).on("zoom.wheel",f?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:le}}const rn=e=>({x:e.x,y:e.y,zoom:e.k}),yn=({x:e,y:t,zoom:n})=>en.translate(e,t).scale(n),Be=(e,t)=>e.target.closest(`.${t}`),bi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,xn=(e,t=0,n=kf,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},_i=e=>{const t=e.ctrlKey&>()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Af({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return d=>{if(Be(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(d.ctrlKey&&s){const x=le(d),m=_i(d),b=u*Math.pow(2,m);r.scaleTo(n,b,x,d);return}const f=d.deltaMode===1?20:1;let h=o===Te.Vertical?0:d.deltaX*f,g=o===Te.Horizontal?0:d.deltaY*f;!gt()&&d.shiftKey&&o!==Te.Vertical&&(h=d.deltaY*f,g=0),r.translateBy(n,-(h/u)*i,-(g/u)*i,{internal:!0});const y=rn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,y),e.panScrollTimeout=setTimeout(()=>{l==null||l(d,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(d,y))}}function $f({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=Be(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function Pf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=rn(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 Tf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&bi(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,rn(i.transform)))}}function zf({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&&bi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=rn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Df({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:d}){return u=>{var x;const f=e||t,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(Be(u,`${l}-flow__node`)||Be(u,`${l}-flow__edge`)))return!0;if(!r&&!f&&!o&&!i&&!n||s||d&&!g||Be(u,a)&&g||Be(u,c)&&(!g||o&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&((x=u.touches)==null?void 0:x.length)>1)return u.preventDefault(),!1;if(!f&&!o&&!h&&g||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const y=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&y}}function Lf({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=Go().scaleExtent([t,n]).translateExtent(r),f=ce(e).call(u);b({x:o.x,y:o.y,zoom:qe(o.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(_i);function y(I,$){return f?new Promise(V=>{u==null||u.interpolate(($==null?void 0:$.interpolate)==="linear"?it:zt).transform(xn(f,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>V(!0)),I)}):Promise.resolve(!1)}function x({noWheelClassName:I,noPanClassName:$,onPaneContextMenu:V,userSelectionActive:v,panOnScroll:k,panOnDrag:E,panOnScrollMode:A,panOnScrollSpeed:C,preventScrolling:S,zoomOnPinch:L,zoomOnScroll:R,zoomOnDoubleClick:H,zoomActivationKeyPressed:O,lib:j,onTransformChange:Y,connectionInProgress:U,paneClickDistance:q,selectionOnDrag:F}){v&&!l.isZoomingOrPanning&&m();const W=k&&!O&&!v;u.clickDistance(F?1/0:!de(q)||q<0?0:q);const Q=W?Af({zoomPanValues:l,noWheelClassName:I,d3Selection:f,d3Zoom:u,panOnScrollMode:A,panOnScrollSpeed:C,zoomOnPinch:L,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):$f({noWheelClassName:I,preventScrolling:S,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const K=Pf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});u.on("start",K);const G=Tf({zoomPanValues:l,panOnDrag:E,onPaneContextMenu:!!V,onPanZoom:i,onTransformChange:Y});u.on("zoom",G);const te=zf({zoomPanValues:l,panOnDrag:E,panOnScroll:k,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:c});u.on("end",te)}const Z=Df({zoomActivationKeyPressed:O,panOnDrag:E,zoomOnScroll:R,panOnScroll:k,zoomOnDoubleClick:H,zoomOnPinch:L,userSelectionActive:v,noPanClassName:$,noWheelClassName:I,lib:j,connectionInProgress:U});u.filter(Z),H?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function b(I,$,V){const v=yn(I),k=u==null?void 0:u.constrain()(v,$,V);return k&&await y(k),new Promise(E=>E(k))}async function p(I,$){const V=yn(I);return await y(V,$),new Promise(v=>v(V))}function w(I){if(f){const $=yn(I),V=f.property("__zoom");(V.k!==I.zoom||V.x!==I.x||V.y!==I.y)&&(u==null||u.transform(f,$,null,{sync:!0}))}}function N(){const I=f?qo(f.node()):{x:0,y:0,k:1};return{x:I.x,y:I.y,zoom:I.k}}function _(I,$){return f?new Promise(V=>{u==null||u.interpolate(($==null?void 0:$.interpolate)==="linear"?it:zt).scaleTo(xn(f,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>V(!0)),I)}):Promise.resolve(!1)}function M(I,$){return f?new Promise(V=>{u==null||u.interpolate(($==null?void 0:$.interpolate)==="linear"?it:zt).scaleBy(xn(f,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>V(!0)),I)}):Promise.resolve(!1)}function T(I){u==null||u.scaleExtent(I)}function z(I){u==null||u.translateExtent(I)}function B(I){const $=!de(I)||I<0?0:I;u==null||u.clickDistance($)}return{update:x,destroy:m,setViewport:p,setViewportConstrained:b,getViewport:N,scaleTo:_,scaleBy:M,setScaleExtent:T,setTranslateExtent:z,syncViewport:w,setClickDistance:B}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function Hf({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 Fr(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 Ne(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function At(e,t,n){return Math.max(0,t-e,e-n)}function Or(e,t){return e?!t:t}function Rf(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:d,isVertical:u}=t,f=d&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:y,maxWidth:x,minHeight:m,maxHeight:b}=r,{x:p,y:w,width:N,height:_,aspectRatio:M}=e;let T=Math.floor(d?h-e.pointerX:0),z=Math.floor(u?g-e.pointerY:0);const B=N+(c?-T:T),I=_+(l?-z:z),$=-i[0]*N,V=-i[1]*_;let v=At(B,y,x),k=At(I,m,b);if(s){let C=0,S=0;c&&T<0?C=Ne(p+T+$,s[0][0]):!c&&T>0&&(C=Me(p+B+$,s[1][0])),l&&z<0?S=Ne(w+z+V,s[0][1]):!l&&z>0&&(S=Me(w+I+V,s[1][1])),v=Math.max(v,C),k=Math.max(k,S)}if(a){let C=0,S=0;c&&T>0?C=Me(p+T,a[0][0]):!c&&T<0&&(C=Ne(p+B,a[1][0])),l&&z>0?S=Me(w+z,a[0][1]):!l&&z<0&&(S=Ne(w+I,a[1][1])),v=Math.max(v,C),k=Math.max(k,S)}if(o){if(d){const C=At(B/M,m,b)*M;if(v=Math.max(v,C),s){let S=0;!c&&!l||c&&!l&&f?S=Me(w+V+B/M,s[1][1])*M:S=Ne(w+V+(c?T:-T)/M,s[0][1])*M,v=Math.max(v,S)}if(a){let S=0;!c&&!l||c&&!l&&f?S=Ne(w+B/M,a[1][1])*M:S=Me(w+(c?T:-T)/M,a[0][1])*M,v=Math.max(v,S)}}if(u){const C=At(I*M,y,x)/M;if(k=Math.max(k,C),s){let S=0;!c&&!l||l&&!c&&f?S=Me(p+I*M+$,s[1][0])/M:S=Ne(p+(l?z:-z)*M+$,s[0][0])/M,k=Math.max(k,S)}if(a){let S=0;!c&&!l||l&&!c&&f?S=Ne(p+I*M,a[1][0])/M:S=Me(p+(l?z:-z)*M,a[0][0])/M,k=Math.max(k,S)}}}z=z+(z<0?k:-k),T=T+(T<0?v:-v),o&&(f?B>I*M?z=(Or(c,l)?-T:T)/M:T=(Or(c,l)?-z:z)*M:d?(z=T/M,l=c):(T=z*M,c=l));const E=c?p+T:p,A=l?w+z:w;return{width:N+(c?-T:T),height:_+(l?-z:z),x:i[0]*T*(c?-1:1)+E,y:i[1]*z*(l?-1:1)+A}}const Ei={width:0,height:0,x:0,y:0},Vf={...Ei,pointerX:0,pointerY:0,aspectRatio:1};function Bf(e){return[[0,0],[e.measured.width,e.measured.height]]}function Ff(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 Of({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:Fr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:y,shouldResize:x}){let m={...Ei},b={...Vf};s={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Fr(l)};let p,w=null,N=[],_,M,T,z=!1;const B=To().on("start",I=>{const{nodeLookup:$,transform:V,snapGrid:v,snapToGrid:k,nodeOrigin:E,paneDomNode:A}=n();if(p=$.get(t),!p)return;w=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:C,ySnapped:S}=st(I.sourceEvent,{transform:V,snapGrid:v,snapToGrid:k,containerBounds:w});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:C,pointerY:S,aspectRatio:m.width/m.height},_=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(_=$.get(p.parentId),M=_&&p.extent==="parent"?Bf(_):void 0),N=[],T=void 0;for(const[L,R]of $)if(R.parentId===t&&(N.push({id:L,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const H=Ff(R,p,R.origin??E);T?T=[[Math.min(H[0][0],T[0][0]),Math.min(H[0][1],T[0][1])],[Math.max(H[1][0],T[1][0]),Math.max(H[1][1],T[1][1])]]:T=H}h==null||h(I,{...m})}).on("drag",I=>{const{transform:$,snapGrid:V,snapToGrid:v,nodeOrigin:k}=n(),E=st(I.sourceEvent,{transform:$,snapGrid:V,snapToGrid:v,containerBounds:w}),A=[];if(!p)return;const{x:C,y:S,width:L,height:R}=m,H={},O=p.origin??k,{width:j,height:Y,x:U,y:q}=Rf(b,s.controlDirection,E,s.boundaries,s.keepAspectRatio,O,M,T),F=j!==L,W=Y!==R,Q=U!==C&&F,Z=q!==S&&W;if(!Q&&!Z&&!F&&!W)return;if((Q||Z||O[0]===1||O[1]===1)&&(H.x=Q?U:m.x,H.y=Z?q:m.y,m.x=H.x,m.y=H.y,N.length>0)){const ne=U-C,ee=q-S;for(const se of N)se.position={x:se.position.x-ne+O[0]*(j-L),y:se.position.y-ee+O[1]*(Y-R)},A.push(se)}if((F||W)&&(H.width=F&&(!s.resizeDirection||s.resizeDirection==="horizontal")?j:m.width,H.height=W&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:m.height,m.width=H.width,m.height=H.height),_&&p.expandParent){const ne=O[0]*(H.width??0);H.x&&H.x{z&&(y==null||y(I,{...m}),o==null||o({...m}),z=!1)});i.call(B)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var wn={exports:{}},vn={},bn={exports:{}},_n={};/** * @license React * use-sync-external-store-shim.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var jr;function jf(){if(jr)return _n;jr=1;var e=xo();function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(u,f){var h=f(),g=r({inst:{value:h,getSnapshot:f}}),y=g[0].inst,x=g[1];return i(function(){y.value=h,y.getSnapshot=f,c(y)&&x({inst:y})},[u,h,f]),o(function(){return c(y)&&x({inst:y}),u(function(){c(y)&&x({inst:y})})},[u]),s(h),h}function c(u){var f=u.getSnapshot;u=u.value;try{var h=f();return!n(u,h)}catch{return!0}}function l(u,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return _n.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,_n}var Xr;function Xf(){return Xr||(Xr=1,bn.exports=jf()),bn.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Yr;function Yf(){if(Yr)return vn;Yr=1;var e=xo(),t=Xf();function n(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}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 vn.useSyncExternalStoreWithSelector=function(l,d,u,f,h){var g=i(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=a(function(){function m(_){if(!b){if(b=!0,p=_,_=f(_),h!==void 0&&y.hasValue){var M=y.value;if(h(M,_))return w=M}return w=_}if(M=w,r(p,_))return M;var T=f(_);return h!==void 0&&h(M,T)?(p=_,M):(p=_,w=T)}var b=!1,p,w,N=u===void 0?null:u;return[function(){return m(d())},N===null?void 0:function(){return m(N())}]},[d,u,f,h]);var x=o(l,g[0],g[1]);return s(function(){y.hasValue=!0,y.value=x},[x]),c(x),x},vn}var Wr;function Wf(){return Wr||(Wr=1,wn.exports=Yf()),wn.exports}var qf=Wf();const Gf=ca(qf),Uf={},qr=e=>{let t;const n=new Set,r=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Uf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(r,o,c);return c},Kf=e=>e?qr(e):qr,{useDebugValue:Zf}=ua,{useSyncExternalStoreWithSelector:Qf}=Gf,Jf=e=>e;function Si(e,t=Jf,n){const r=Qf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Zf(r),r}const Gr=(e,t)=>{const n=Kf(e),r=(o,i=t)=>Si(n,o,i);return Object.assign(r,n),r},ed=(e,t)=>e?Gr(e,t):Gr;function re(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 on=D.createContext(null),td=on.Provider,Ni=ye.error001();function J(e,t){const n=D.useContext(on);if(n===null)throw new Error(Ni);return Si(n,e,t)}function oe(){const e=D.useContext(on);if(e===null)throw new Error(Ni);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Ur={display:"none"},nd={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Mi="react-flow__node-desc",Ci="react-flow__edge-desc",rd="react-flow__aria-live",od=e=>e.ariaLiveMessage,id=e=>e.ariaLabelConfig;function sd({rfId:e}){const t=J(od);return P.jsx("div",{id:`${rd}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:nd,children:t})}function ad({rfId:e,disableKeyboardA11y:t}){const n=J(id);return P.jsxs(P.Fragment,{children:[P.jsx("div",{id:`${Mi}-${e}`,style:Ur,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),P.jsx("div",{id:`${Ci}-${e}`,style:Ur,children:n["edge.a11yDescription.default"]}),!t&&P.jsx(sd,{rfId:e})]})}const sn=D.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return P.jsx("div",{className:ie(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});sn.displayName="Panel";function cd({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:P.jsx(sn,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:P.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const ud=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}},$t=e=>e.id;function ld(e,t){return re(e.selectedNodes.map($t),t.selectedNodes.map($t))&&re(e.selectedEdges.map($t),t.selectedEdges.map($t))}function fd({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=J(ud,ld);return D.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const dd=e=>!!e.onSelectionChangeHandlers;function hd({onSelectionChange:e}){const t=J(dd);return e||t?P.jsx(fd,{onSelectionChange:e}):null}const Ii=[0,0],gd={x:0,y:0,zoom:1},pd=["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"],Kr=[...pd,"rfId"],md=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}),Zr={translateExtent:ft,nodeOrigin:Ii,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function yd(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=J(md,re),l=oe();D.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Zr,a()}),[]);const d=D.useRef(Zr);return D.useEffect(()=>{for(const u of Kr){const f=e[u],h=d.current[u];f!==h&&(typeof e[u]>"u"||(u==="nodes"?t(f):u==="edges"?n(f):u==="minZoom"?r(f):u==="maxZoom"?o(f):u==="translateExtent"?i(f):u==="nodeExtent"?s(f):u==="ariaLabelConfig"?l.setState({ariaLabelConfig:Jl(f)}):u==="fitView"?l.setState({fitViewQueued:f}):u==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[u]:f})))}d.current=e},Kr.map(u=>e[u])),null}function Qr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function xd(e){var r;const[t,n]=D.useState(e==="system"?null:e);return D.useEffect(()=>{if(e!=="system"){n(e);return}const o=Qr(),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=Qr())!=null&&r.matches?"dark":"light"}const Jr=typeof document<"u"?document:null;function pt(e=null,t={target:Jr,actInsideInputWithModifier:!0}){const[n,r]=D.useState(!1),o=D.useRef(!1),i=D.useRef(new Set([])),[s,a]=D.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",` `).replace(` `,` +`).split(` `)),d=l.reduce((u,f)=>u.concat(...f),[]);return[l,d]}return[[],[]]},[e]);return D.useEffect(()=>{const c=(t==null?void 0:t.target)??Jr,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=h=>{var x,m;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!l)&&ai(h))return!1;const y=to(h.code,a);if(i.current.add(h[y]),eo(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)}},u=h=>{const g=to(h.code,a);eo(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function eo(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function to(e,t){return t.includes(e)?"code":"key"}const wd=()=>{const e=oe();return D.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!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),Promise.resolve(!0)):Promise.resolve(!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=Gn(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}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},d=n.snapGrid??o,u=n.snapToGrid??i;return bt(l,r,u,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=qt(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function ki(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)vd(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 vd(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 Ai(e,t){return ki(e,t)}function $i(e,t){return ki(e,t)}function Ae(e,t){return{id:e,type:"select",selected:t}}function Fe(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(Ae(i.id,s)))}return r}function no({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 ro(e){return{id:e.id,type:"remove"}}const oo=e=>jl(e),bd=e=>Jo(e);function Pi(e){return D.forwardRef(e)}const _d=typeof window<"u"?D.useLayoutEffect:D.useEffect;function io(e){const[t,n]=D.useState(BigInt(0)),[r]=D.useState(()=>Ed(()=>n(o=>o+BigInt(1))));return _d(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function Ed(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ti=D.createContext(null);function Sd({children:e}){const t=oe(),n=D.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:d,onNodesChange:u,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let y=c;for(const m of a)y=typeof m=="function"?m(y):m;let x=no({items:y,lookup:f});for(const m of g.values())x=m(x);d&&l(y),x.length>0?u==null||u(x):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:b,setNodes:p}=t.getState();m&&p(b)})},[]),r=io(n),o=D.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:d,onEdgesChange:u,edgeLookup:f}=t.getState();let h=c;for(const g of a)h=typeof g=="function"?g(h):g;d?l(h):u&&u(no({items:h,lookup:f}))},[]),i=io(o),s=D.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return P.jsx(Ti.Provider,{value:s,children:e})}function Nd(){const e=D.useContext(Ti);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Md=e=>!!e.panZoom;function tr(){const e=wd(),t=oe(),n=Nd(),r=J(Md),o=D.useMemo(()=>{const i=u=>t.getState().nodeLookup.get(u),s=u=>{n.nodeQueue.push(u)},a=u=>{n.edgeQueue.push(u)},c=u=>{var m,b;const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=oo(u)?u:f.get(u.id),y=g.parentId?ii(g.position,g.measured,g.parentId,f,h):g.position,x={...g,position:y,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return Ge(x)},l=(u,f,h={replace:!1})=>{s(g=>g.map(y=>{if(y.id===u){const x=typeof f=="function"?f(y):f;return h.replace&&oo(x)?x:{...y,...x}}return y}))},d=(u,f,h={replace:!1})=>{a(g=>g.map(y=>{if(y.id===u){const x=typeof f=="function"?f(y):f;return h.replace&&bd(x)?x:{...y,...x}}return y}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var f;return(f=i(u))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(f=>({...f}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:s,setEdges:a,addNodes:u=>{const f=Array.isArray(u)?u:[u];n.nodeQueue.push(h=>[...h,...f])},addEdges:u=>{const f=Array.isArray(u)?u:[u];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:u=[],edges:f=[],transform:h}=t.getState(),[g,y,x]=h;return{nodes:u.map(m=>({...m})),edges:f.map(m=>({...m})),viewport:{x:g,y,zoom:x}}},deleteElements:async({nodes:u=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:y,onEdgesDelete:x,triggerNodeChanges:m,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:w}=t.getState(),{nodes:N,edges:_}=await Gl({nodesToRemove:u,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:w}),M=_.length>0,T=N.length>0;if(M){const z=_.map(ro);x==null||x(_),b(z)}if(T){const z=N.map(ro);y==null||y(N),m(z)}return(T||M)&&(p==null||p({nodes:N,edges:_})),{deletedNodes:N,deletedEdges:_}},getIntersectingNodes:(u,f=!0,h)=>{const g=Ar(u),y=g?u:c(u),x=h!==void 0;return y?(h||t.getState().nodes).filter(m=>{const b=t.getState().nodeLookup.get(m.id);if(b&&!g&&(m.id===u.id||!b.internals.positionAbsolute))return!1;const p=Ge(x?m:b),w=ht(p,y);return f&&w>0||w>=p.width*p.height||w>=y.width*y.height}):[]},isNodeIntersecting:(u,f,h=!0)=>{const y=Ar(u)?u:c(u);if(!y)return!1;const x=ht(y,f);return h&&x>0||x>=f.width*f.height||x>=y.width*y.height},updateNode:l,updateNodeData:(u,f,h={replace:!1})=>{l(u,g=>{const y=typeof f=="function"?f(g):f;return h.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},h)},updateEdge:d,updateEdgeData:(u,f,h={replace:!1})=>{d(u,g=>{const y=typeof f=="function"?f(g):f;return h.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},h)},getNodesBounds:u=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return Xl(u,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:u,id:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${u}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:u,handleId:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${u?f?`-${u}-${f}`:`-${u}`:""}`))==null?void 0:g.values())??[])},fitView:async u=>{const f=t.getState().fitViewResolver??Ql();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return D.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const so=e=>e.selected,Cd=typeof window<"u"?window:void 0;function Id({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=oe(),{deleteElements:r}=tr(),o=pt(e,{actInsideInputWithModifier:!1}),i=pt(t,{target:Cd});D.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter(so),edges:s.filter(so)}),n.setState({nodesSelectionActive:!1})}},[o]),D.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function kd(e){const t=oe();D.useEffect(()=>{const n=()=>{var o,i,s,a;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=Un(e.current);(r.height===0||r.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",ye.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 an={position:"absolute",width:"100%",height:"100%",top:0,left:0},Ad=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function $d({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=Te.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:l,minZoom:d,maxZoom:u,zoomActivationKeyCode:f,preventScrolling:h=!0,children:g,noWheelClassName:y,noPanClassName:x,onViewportChange:m,isControlledViewport:b,paneClickDistance:p,selectionOnDrag:w}){const N=oe(),_=D.useRef(null),{userSelectionActive:M,lib:T,connectionInProgress:z}=J(Ad,re),B=pt(f),I=D.useRef();kd(_);const $=D.useCallback(V=>{m==null||m({x:V[0],y:V[1],zoom:V[2]}),b||N.setState({transform:V})},[m,b]);return D.useEffect(()=>{if(_.current){I.current=Lf({domNode:_.current,minZoom:d,maxZoom:u,translateExtent:l,viewport:c,onDraggingChange:E=>N.setState(A=>A.paneDragging===E?A:{paneDragging:E}),onPanZoomStart:(E,A)=>{const{onViewportChangeStart:C,onMoveStart:S}=N.getState();S==null||S(E,A),C==null||C(A)},onPanZoom:(E,A)=>{const{onViewportChange:C,onMove:S}=N.getState();S==null||S(E,A),C==null||C(A)},onPanZoomEnd:(E,A)=>{const{onViewportChangeEnd:C,onMoveEnd:S}=N.getState();S==null||S(E,A),C==null||C(A)}});const{x:V,y:v,zoom:k}=I.current.getViewport();return N.setState({panZoom:I.current,transform:[V,v,k],domNode:_.current.closest(".react-flow")}),()=>{var E;(E=I.current)==null||E.destroy()}}},[]),D.useEffect(()=>{var V;(V=I.current)==null||V.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:B,preventScrolling:h,noPanClassName:x,userSelectionActive:M,noWheelClassName:y,lib:T,onTransformChange:$,connectionInProgress:z,selectionOnDrag:w,paneClickDistance:p})},[e,t,n,r,o,i,s,a,B,h,x,M,y,T,$,z,w,p]),P.jsx("div",{className:"react-flow__renderer",ref:_,style:an,children:g})}const Pd=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Td(){const{userSelectionActive:e,userSelectionRect:t}=J(Pd,re);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 En=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},zd=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Dd({isSelecting:e,selectionKeyPressed:t,selectionMode:n=dt.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:d,onPaneMouseEnter:u,onPaneMouseMove:f,onPaneMouseLeave:h,children:g}){const y=oe(),{userSelectionActive:x,elementsSelectable:m,dragging:b,connectionInProgress:p}=J(zd,re),w=m&&(e||x),N=D.useRef(null),_=D.useRef(),M=D.useRef(new Set),T=D.useRef(new Set),z=D.useRef(!1),B=C=>{if(z.current||p){z.current=!1;return}c==null||c(C),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},I=C=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){C.preventDefault();return}l==null||l(C)},$=d?C=>d(C):void 0,V=C=>{z.current&&(C.stopPropagation(),z.current=!1)},v=C=>{var Y,U;const{domNode:S}=y.getState();if(_.current=S==null?void 0:S.getBoundingClientRect(),!_.current)return;const L=C.target===N.current;if(!L&&!!C.target.closest(".nokey")||!e||!(i&&L||t)||C.button!==0||!C.isPrimary)return;(U=(Y=C.target)==null?void 0:Y.setPointerCapture)==null||U.call(Y,C.pointerId),z.current=!1;const{x:O,y:j}=he(C.nativeEvent,_.current);y.setState({userSelectionRect:{width:0,height:0,startX:O,startY:j,x:O,y:j}}),L||(C.stopPropagation(),C.preventDefault())},k=C=>{const{userSelectionRect:S,transform:L,nodeLookup:R,edgeLookup:H,connectionLookup:O,triggerNodeChanges:j,triggerEdgeChanges:Y,defaultEdgeOptions:U,resetSelectedElements:q}=y.getState();if(!_.current||!S)return;const{x:F,y:W}=he(C.nativeEvent,_.current),{startX:Q,startY:Z}=S;if(!z.current){const ee=t?0:o;if(Math.hypot(F-Q,W-Z)<=ee)return;q(),s==null||s(C)}z.current=!0;const K={startX:Q,startY:Z,x:Fee.id)),T.current=new Set;const ne=(U==null?void 0:U.selectable)??!0;for(const ee of M.current){const se=O.get(ee);if(se)for(const{edgeId:Se}of se.values()){const we=H.get(Se);we&&(we.selectable??ne)&&T.current.add(Se)}}if(!$r(G,M.current)){const ee=Fe(R,M.current,!0);j(ee)}if(!$r(te,T.current)){const ee=Fe(H,T.current);Y(ee)}y.setState({userSelectionRect:K,userSelectionActive:!0,nodesSelectionActive:!1})},E=C=>{var S,L;C.button===0&&((L=(S=C.target)==null?void 0:S.releasePointerCapture)==null||L.call(S,C.pointerId),!x&&C.target===N.current&&y.getState().userSelectionRect&&(B==null||B(C)),y.setState({userSelectionActive:!1,userSelectionRect:null}),z.current&&(a==null||a(C),y.setState({nodesSelectionActive:M.current.size>0})))},A=r===!0||Array.isArray(r)&&r.includes(0);return P.jsxs("div",{className:ie(["react-flow__pane",{draggable:A,dragging:b,selection:e}]),onClick:w?void 0:En(B,N),onContextMenu:En(I,N),onWheel:En($,N),onPointerEnter:w?void 0:u,onPointerMove:w?k:f,onPointerUp:w?E:void 0,onPointerDownCapture:w?v:void 0,onClickCapture:w?V:void 0,onPointerLeave:h,ref:N,style:an,children:[g,P.jsx(Td,{})]})}function Rn({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",ye.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):o([e])}function zi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=oe(),[c,l]=D.useState(!1),d=D.useRef();return D.useEffect(()=>{d.current=_f({getStoreItems:()=>a.getState(),onNodeMouseDown:u=>{Rn({id:u,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),D.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s}),()=>{var u;(u=d.current)==null||u.destroy()}},[n,r,t,i,e,o,s]),c}const Ld=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Di(){const e=oe();return D.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:d}=e.getState(),u=new Map,f=Ld(s),h=o?i[0]:5,g=o?i[1]:5,y=n.direction.x*h*n.factor,x=n.direction.y*g*n.factor;for(const[,m]of l){if(!f(m))continue;let b={x:m.internals.positionAbsolute.x+y,y:m.internals.positionAbsolute.y+x};o&&(b=vt(b,i));const{position:p,positionAbsolute:w}=ei({nodeId:m.id,nextPosition:b,nodeLookup:l,nodeExtent:r,nodeOrigin:d,onError:a});m.position=p,m.internals.positionAbsolute=w,u.set(m.id,m)}c(u)},[])}const nr=D.createContext(null),Hd=nr.Provider;nr.Consumer;const Li=()=>D.useContext(nr),Rd=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Vd=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:c,isValid:l}=s,d=(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:d,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===We.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:d&&l}};function Bd({type:e="source",position:t=X.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:d,onTouchStart:u,...f},h){var k,E;const g=s||null,y=e==="target",x=oe(),m=Li(),{connectOnClick:b,noPanClassName:p,rfId:w}=J(Rd,re),{connectingFrom:N,connectingTo:_,clickConnecting:M,isPossibleEndHandle:T,connectionInProcess:z,clickConnectionInProcess:B,valid:I}=J(Vd(m,g,e),re);m||(E=(k=x.getState()).onError)==null||E.call(k,"010",ye.error010());const $=A=>{const{defaultEdgeOptions:C,onConnect:S,hasDefaultEdges:L}=x.getState(),R={...C,...A};if(L){const{edges:H,setEdges:O}=x.getState();O(sf(R,H))}S==null||S(R),a==null||a(R)},V=A=>{if(!m)return;const C=ci(A.nativeEvent);if(o&&(C&&A.button===0||!C)){const S=x.getState();Hn.onPointerDown(A.nativeEvent,{handleDomNode:A.currentTarget,autoPanOnConnect:S.autoPanOnConnect,connectionMode:S.connectionMode,connectionRadius:S.connectionRadius,domNode:S.domNode,nodeLookup:S.nodeLookup,lib:S.lib,isTarget:y,handleId:g,nodeId:m,flowId:S.rfId,panBy:S.panBy,cancelConnection:S.cancelConnection,onConnectStart:S.onConnectStart,onConnectEnd:(...L)=>{var R,H;return(H=(R=x.getState()).onConnectEnd)==null?void 0:H.call(R,...L)},updateConnection:S.updateConnection,onConnect:$,isValidConnection:n||((...L)=>{var R,H;return((H=(R=x.getState()).isValidConnection)==null?void 0:H.call(R,...L))??!0}),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:S.autoPanSpeed,dragThreshold:S.connectionDragThreshold})}C?d==null||d(A):u==null||u(A)},v=A=>{const{onClickConnectStart:C,onClickConnectEnd:S,connectionClickStartHandle:L,connectionMode:R,isValidConnection:H,lib:O,rfId:j,nodeLookup:Y,connection:U}=x.getState();if(!m||!L&&!o)return;if(!L){C==null||C(A.nativeEvent,{nodeId:m,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:m,type:e,id:g}});return}const q=si(A.target),F=n||H,{connection:W,isValid:Q}=Hn.isValid(A.nativeEvent,{handle:{nodeId:m,id:g,type:e},connectionMode:R,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:F,flowId:j,doc:q,lib:O,nodeLookup:Y});Q&&W&&$(W);const Z=structuredClone(U);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,S==null||S(A,Z),x.setState({connectionClickStartHandle:null})};return P.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":t,"data-id":`${w}-${m}-${g}-${e}`,className:ie(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,l,{source:!y,target:y,connectable:r,connectablestart:o,connectableend:i,clickconnecting:M,connectingfrom:N,connectingto:_,valid:I,connectionindicator:r&&(!z||T)&&(z||B?i:o)}]),onMouseDown:V,onTouchStart:V,onClick:b?v:void 0,ref:h,...f,children:c})}const Gt=D.memo(Pi(Bd));function Fd({data:e,isConnectable:t,sourcePosition:n=X.Bottom}){return P.jsxs(P.Fragment,{children:[e==null?void 0:e.label,P.jsx(Gt,{type:"source",position:n,isConnectable:t})]})}function Od({data:e,isConnectable:t,targetPosition:n=X.Top,sourcePosition:r=X.Bottom}){return P.jsxs(P.Fragment,{children:[P.jsx(Gt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,P.jsx(Gt,{type:"source",position:r,isConnectable:t})]})}function jd(){return null}function Xd({data:e,isConnectable:t,targetPosition:n=X.Top}){return P.jsxs(P.Fragment,{children:[P.jsx(Gt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Ut={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ao={input:Fd,default:Od,output:Xd,group:jd};function Yd(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 Wd=e=>{const{width:t,height:n,x:r,y:o}=wt(e.nodeLookup,{filter:i=>!!i.selected});return{width:de(t)?t:null,height:de(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 qd({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=oe(),{width:o,height:i,transformString:s,userSelectionActive:a}=J(Wd,re),c=Di(),l=D.useRef(null);D.useEffect(()=>{var h;n||(h=l.current)==null||h.focus({preventScroll:!0})},[n]);const d=!a&&o!==null&&i!==null;if(zi({nodeRef:l,disabled:!d}),!d)return null;const u=e?h=>{const g=r.getState().nodes.filter(y=>y.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(Ut,h.key)&&(h.preventDefault(),c({direction:Ut[h.key],factor:h.shiftKey?4:1}))};return P.jsx("div",{className:ie(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:P.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const co=typeof window<"u"?window:void 0,Gd=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Hi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:d,selectionMode:u,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:y,zoomActivationKeyCode:x,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:w,panOnScrollSpeed:N,panOnScrollMode:_,zoomOnDoubleClick:M,panOnDrag:T,defaultViewport:z,translateExtent:B,minZoom:I,maxZoom:$,preventScrolling:V,onSelectionContextMenu:v,noWheelClassName:k,noPanClassName:E,disableKeyboardA11y:A,onViewportChange:C,isControlledViewport:S}){const{nodesSelectionActive:L,userSelectionActive:R}=J(Gd,re),H=pt(l,{target:co}),O=pt(y,{target:co}),j=O||T,Y=O||w,U=d&&j!==!0,q=H||R||U;return Id({deleteKeyCode:c,multiSelectionKeyCode:g}),P.jsx($d,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:Y,panOnScrollSpeed:N,panOnScrollMode:_,zoomOnDoubleClick:M,panOnDrag:!H&&j,defaultViewport:z,translateExtent:B,minZoom:I,maxZoom:$,zoomActivationKeyCode:x,preventScrolling:V,noWheelClassName:k,noPanClassName:E,onViewportChange:C,isControlledViewport:S,paneClickDistance:a,selectionOnDrag:U,children:P.jsxs(Dd,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:j,isSelecting:!!q,selectionMode:u,selectionKeyPressed:H,paneClickDistance:a,selectionOnDrag:U,children:[e,L&&P.jsx(qd,{onSelectionContextMenu:v,noPanClassName:E,disableKeyboardA11y:A})]})})}Hi.displayName="FlowRenderer";const Ud=D.memo(Hi),Kd=e=>t=>e?qn(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 Zd(e){return J(D.useCallback(Kd(e),[e]),re)}const Qd=e=>e.updateNodeInternals;function Jd(){const e=J(Qd),[t]=D.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return D.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function eh({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=oe(),i=D.useRef(null),s=D.useRef(null),a=D.useRef(e.sourcePosition),c=D.useRef(e.targetPosition),l=D.useRef(t),d=n&&!!e.internals.handleBounds;return D.useEffect(()=>{i.current&&!e.hidden&&(!d||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[d,e.hidden]),D.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),D.useEffect(()=>{if(i.current){const u=l.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(u||f||h)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function th({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:d,resizeObserver:u,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:y,nodeTypes:x,nodeClickDistance:m,onError:b}){const{node:p,internals:w,isParent:N}=J(F=>{const W=F.nodeLookup.get(e),Q=F.parentLookup.has(e);return{node:W,internals:W.internals,isParent:Q}},re);let _=p.type||"default",M=(x==null?void 0:x[_])||ao[_];M===void 0&&(b==null||b("003",ye.error003(_)),_="default",M=(x==null?void 0:x.default)||ao.default);const T=!!(p.draggable||a&&typeof p.draggable>"u"),z=!!(p.selectable||c&&typeof p.selectable>"u"),B=!!(p.connectable||l&&typeof p.connectable>"u"),I=!!(p.focusable||d&&typeof p.focusable>"u"),$=oe(),V=oi(p),v=eh({node:p,nodeType:_,hasDimensions:V,resizeObserver:u}),k=zi({nodeRef:v,disabled:p.hidden||!T,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:z,nodeClickDistance:m}),E=Di();if(p.hidden)return null;const A=Ee(p),C=Yd(p),S=z||T||t||n||r||o,L=n?F=>n(F,{...w.userNode}):void 0,R=r?F=>r(F,{...w.userNode}):void 0,H=o?F=>o(F,{...w.userNode}):void 0,O=i?F=>i(F,{...w.userNode}):void 0,j=s?F=>s(F,{...w.userNode}):void 0,Y=F=>{const{selectNodesOnDrag:W,nodeDragThreshold:Q}=$.getState();z&&(!W||!T||Q>0)&&Rn({id:e,store:$,nodeRef:v}),t&&t(F,{...w.userNode})},U=F=>{if(!(ai(F.nativeEvent)||g)){if(Uo.includes(F.key)&&z){const W=F.key==="Escape";Rn({id:e,store:$,unselect:W,nodeRef:v})}else if(T&&p.selected&&Object.prototype.hasOwnProperty.call(Ut,F.key)){F.preventDefault();const{ariaLabelConfig:W}=$.getState();$.setState({ariaLiveMessage:W["node.a11yDescription.ariaLiveMessage"]({direction:F.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),E({direction:Ut[F.key],factor:F.shiftKey?4:1})}}},q=()=>{var te;if(g||!((te=v.current)!=null&&te.matches(":focus-visible")))return;const{transform:F,width:W,height:Q,autoPanOnNodeFocus:Z,setCenter:K}=$.getState();if(!Z)return;qn(new Map([[e,p]]),{x:0,y:0,width:W,height:Q},F,!0).length>0||K(p.position.x+A.width/2,p.position.y+A.height/2,{zoom:F[2]})};return P.jsx("div",{className:ie(["react-flow__node",`react-flow__node-${_}`,{[h]:T},p.className,{selected:p.selected,selectable:z,parent:N,draggable:T,dragging:k}]),ref:v,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:S?"all":"none",visibility:V?"visible":"hidden",...p.style,...C},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:R,onMouseLeave:H,onContextMenu:O,onClick:Y,onDoubleClick:j,onKeyDown:I?U:void 0,tabIndex:I?0:void 0,onFocus:I?q:void 0,role:p.ariaRole??(I?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Mi}-${y}`,"aria-label":p.ariaLabel,...p.domAttributes,children:P.jsx(Hd,{value:e,children:P.jsx(M,{id:e,data:p.data,type:_,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:p.selected??!1,selectable:z,draggable:T,deletable:p.deletable??!0,isConnectable:B,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:k,dragHandle:p.dragHandle,zIndex:w.z,parentId:p.parentId,...A})})})}var nh=D.memo(th);const rh=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ri(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=J(rh,re),s=Zd(e.onlyRenderVisibleElements),a=Jd();return P.jsx("div",{className:"react-flow__nodes",style:an,children:s.map(c=>P.jsx(nh,{id:c,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:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}Ri.displayName="NodeRenderer";const oh=D.memo(Ri);function ih(e){return J(D.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&nf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),re)}const sh=({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"})},ah=({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"})},uo={[Yt.Arrow]:sh,[Yt.ArrowClosed]:ah};function ch(e){const t=oe();return D.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(uo,e)?uo[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",ye.error009(e)),null)},[e])}const uh=({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=ch(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},Vi=({defaultColor:e,rfId:t})=>{const n=J(i=>i.edges),r=J(i=>i.defaultEdgeOptions),o=D.useMemo(()=>ff(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(uh,{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};Vi.displayName="MarkerDefinitions";var lh=D.memo(Vi);function Bi({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...d}){const[u,f]=D.useState({x:1,y:0,width:0,height:0}),h=ie(["react-flow__edge-textwrapper",l]),g=D.useRef(null);return D.useEffect(()=>{if(g.current){const y=g.current.getBBox();f({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?P.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:h,visibility:u.width?"visible":"hidden",...d,children:[o&&P.jsx("rect",{width:u.width+2*s[0],x:-s[0],y:-s[1],height:u.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),P.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}Bi.displayName="EdgeText";const fh=D.memo(Bi);function cn({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...d}){return P.jsxs(P.Fragment,{children:[P.jsx("path",{...d,d:e,fill:"none",className:ie(["react-flow__edge-path",d.className])}),l?P.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,r&&de(t)&&de(n)?P.jsx(fh,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function lo({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===X.Left||e===X.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Fi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:o,targetPosition:i=X.Top}){const[s,a]=lo({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,l]=lo({pos:i,x1:r,y1:o,x2:e,y2:t}),[d,u,f,h]=ui({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${s},${a} ${c},${l} ${r},${o}`,d,u,f,h]}function Oi(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:x,interactionWidth:m})=>{const[b,p,w]=Fi({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),N=e.isInternal?void 0:t;return P.jsx(cn,{id:N,path:b,labelX:p,labelY:w,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:x,interactionWidth:m})})}const dh=Oi({isInternal:!1}),ji=Oi({isInternal:!0});dh.displayName="SimpleBezierEdge";ji.displayName="SimpleBezierEdgeInternal";function Xi(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:u,style:f,sourcePosition:h=X.Bottom,targetPosition:g=X.Top,markerEnd:y,markerStart:x,pathOptions:m,interactionWidth:b})=>{const[p,w,N]=zn({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.isInternal?void 0:t;return P.jsx(cn,{id:_,path:p,labelX:w,labelY:N,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:y,markerStart:x,interactionWidth:b})})}const Yi=Xi({isInternal:!1}),Wi=Xi({isInternal:!0});Yi.displayName="SmoothStepEdge";Wi.displayName="SmoothStepEdgeInternal";function qi(e){return D.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return P.jsx(Yi,{...n,id:r,pathOptions:D.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const hh=qi({isInternal:!1}),Gi=qi({isInternal:!0});hh.displayName="StepEdge";Gi.displayName="StepEdgeInternal";function Ui(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:h,markerStart:g,interactionWidth:y})=>{const[x,m,b]=di({sourceX:n,sourceY:r,targetX:o,targetY:i}),p=e.isInternal?void 0:t;return P.jsx(cn,{id:p,path:x,labelX:m,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:h,markerStart:g,interactionWidth:y})})}const gh=Ui({isInternal:!1}),Ki=Ui({isInternal:!0});gh.displayName="StraightEdge";Ki.displayName="StraightEdgeInternal";function Zi(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=X.Bottom,targetPosition:a=X.Top,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:x,pathOptions:m,interactionWidth:b})=>{const[p,w,N]=li({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),_=e.isInternal?void 0:t;return P.jsx(cn,{id:_,path:p,labelX:w,labelY:N,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:x,interactionWidth:b})})}const ph=Zi({isInternal:!1}),Qi=Zi({isInternal:!0});ph.displayName="BezierEdge";Qi.displayName="BezierEdgeInternal";const fo={default:Qi,straight:Ki,step:Gi,smoothstep:Wi,simplebezier:ji},ho={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},mh=(e,t,n)=>n===X.Left?e-t:n===X.Right?e+t:e,yh=(e,t,n)=>n===X.Top?e-t:n===X.Bottom?e+t:e,go="react-flow__edgeupdater";function po({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:ie([go,`${go}-${a}`]),cx:mh(t,r,e),cy:yh(n,r,e),r,stroke:"transparent",fill:"transparent"})}function xh({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:d,onReconnectEnd:u,setReconnecting:f,setUpdateHover:h}){const g=oe(),y=(w,N)=>{if(w.button!==0)return;const{autoPanOnConnect:_,domNode:M,connectionMode:T,connectionRadius:z,lib:B,onConnectStart:I,cancelConnection:$,nodeLookup:V,rfId:v,panBy:k,updateConnection:E}=g.getState(),A=N.type==="target",C=(R,H)=>{f(!1),u==null||u(R,n,N.type,H)},S=R=>l==null?void 0:l(n,R),L=(R,H)=>{f(!0),d==null||d(w,n,N.type),I==null||I(R,H)};Hn.onPointerDown(w.nativeEvent,{autoPanOnConnect:_,connectionMode:T,connectionRadius:z,domNode:M,handleId:N.id,nodeId:N.nodeId,nodeLookup:V,isTarget:A,edgeUpdaterType:N.type,lib:B,flowId:v,cancelConnection:$,panBy:k,isValidConnection:(...R)=>{var H,O;return((O=(H=g.getState()).isValidConnection)==null?void 0:O.call(H,...R))??!0},onConnect:S,onConnectStart:L,onConnectEnd:(...R)=>{var H,O;return(O=(H=g.getState()).onConnectEnd)==null?void 0:O.call(H,...R)},onReconnectEnd:C,updateConnection:E,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},x=w=>y(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=w=>y(w,{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(po,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:x,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&P.jsx(po,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function wh({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:y,noPanClassName:x,onError:m,disableKeyboardA11y:b}){let p=J(K=>K.edgeLookup.get(e));const w=J(K=>K.defaultEdgeOptions);p=w?{...w,...p}:p;let N=p.type||"default",_=(y==null?void 0:y[N])||fo[N];_===void 0&&(m==null||m("011",ye.error011(N)),N="default",_=(y==null?void 0:y.default)||fo.default);const M=!!(p.focusable||t&&typeof p.focusable>"u"),T=typeof u<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),z=!!(p.selectable||r&&typeof p.selectable>"u"),B=D.useRef(null),[I,$]=D.useState(!1),[V,v]=D.useState(!1),k=oe(),{zIndex:E,sourceX:A,sourceY:C,targetX:S,targetY:L,sourcePosition:R,targetPosition:H}=J(D.useCallback(K=>{const G=K.nodeLookup.get(p.source),te=K.nodeLookup.get(p.target);if(!G||!te)return{zIndex:p.zIndex,...ho};const ne=lf({id:e,sourceNode:G,targetNode:te,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:K.connectionMode,onError:m});return{zIndex:tf({selected:p.selected,zIndex:p.zIndex,sourceNode:G,targetNode:te,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode}),...ne||ho}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),re),O=D.useMemo(()=>p.markerStart?`url('#${Dn(p.markerStart,g)}')`:void 0,[p.markerStart,g]),j=D.useMemo(()=>p.markerEnd?`url('#${Dn(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||A===null||C===null||S===null||L===null)return null;const Y=K=>{var ee;const{addSelectedEdges:G,unselectNodesAndEdges:te,multiSelectionActive:ne}=k.getState();z&&(k.setState({nodesSelectionActive:!1}),p.selected&&ne?(te({nodes:[],edges:[p]}),(ee=B.current)==null||ee.blur()):G([e])),o&&o(K,p)},U=i?K=>{i(K,{...p})}:void 0,q=s?K=>{s(K,{...p})}:void 0,F=a?K=>{a(K,{...p})}:void 0,W=c?K=>{c(K,{...p})}:void 0,Q=l?K=>{l(K,{...p})}:void 0,Z=K=>{var G;if(!b&&Uo.includes(K.key)&&z){const{unselectNodesAndEdges:te,addSelectedEdges:ne}=k.getState();K.key==="Escape"?((G=B.current)==null||G.blur(),te({edges:[p]})):ne([e])}};return P.jsx("svg",{style:{zIndex:E},children:P.jsxs("g",{className:ie(["react-flow__edge",`react-flow__edge-${N}`,p.className,x,{selected:p.selected,animated:p.animated,inactive:!z&&!o,updating:I,selectable:z}]),onClick:Y,onDoubleClick:U,onContextMenu:q,onMouseEnter:F,onMouseMove:W,onMouseLeave:Q,onKeyDown:M?Z:void 0,tabIndex:M?0:void 0,role:p.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":M?`${Ci}-${g}`:void 0,ref:B,...p.domAttributes,children:[!V&&P.jsx(_,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:z,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:A,sourceY:C,targetX:S,targetY:L,sourcePosition:R,targetPosition:H,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:O,markerEnd:j,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),T&&P.jsx(xh,{edge:p,isReconnectable:T,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,sourceX:A,sourceY:C,targetX:S,targetY:L,sourcePosition:R,targetPosition:H,setUpdateHover:$,setReconnecting:v})]})})}var vh=D.memo(wh);const bh=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ji({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:d,reconnectRadius:u,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:y}){const{edgesFocusable:x,edgesReconnectable:m,elementsSelectable:b,onError:p}=J(bh,re),w=ih(t);return P.jsxs("div",{className:"react-flow__edges",children:[P.jsx(lh,{defaultColor:e,rfId:n}),w.map(N=>P.jsx(vh,{id:N,edgesFocusable:x,edgesReconnectable:m,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:d,reconnectRadius:u,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:y},N))]})}Ji.displayName="EdgeRenderer";const _h=D.memo(Ji),Eh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Sh({children:e}){const t=J(Eh);return P.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Nh(e){const t=tr(),n=D.useRef(!1);D.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Mh=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Ch(e){const t=J(Mh),n=oe();return D.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Ih(e){return e.connection.inProgress?{...e.connection,to:bt(e.connection.to,e.transform)}:{...e.connection}}function kh(e){return Ih}function Ah(e){const t=kh();return J(t,re)}const $h=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Ph({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:c}=J($h,re);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:ie(["react-flow__connection",Qo(a)]),children:P.jsx(es,{style:t,type:n,CustomComponent:r,isValid:a})})})}const es=({style:e,type:t=Ce.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:l,toNode:d,toHandle:u,toPosition:f,pointer:h}=Ah();if(!o)return;if(n)return P.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Qo(r),toNode:d,toHandle:u,pointer:h});let g="";const y={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case Ce.Bezier:[g]=li(y);break;case Ce.SimpleBezier:[g]=Fi(y);break;case Ce.Step:[g]=zn({...y,borderRadius:0});break;case Ce.SmoothStep:[g]=zn(y);break;default:[g]=di(y)}return P.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};es.displayName="ConnectionLine";const Th={};function mo(e=Th){D.useRef(e),oe(),D.useEffect(()=>{},[e])}function zh(){oe(),D.useRef(!1),D.useEffect(()=>{},[])}function ts({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:d,onSelectionContextMenu:u,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:y,connectionLineComponent:x,connectionLineContainerStyle:m,selectionKeyCode:b,selectionOnDrag:p,selectionMode:w,multiSelectionKeyCode:N,panActivationKeyCode:_,zoomActivationKeyCode:M,deleteKeyCode:T,onlyRenderVisibleElements:z,elementsSelectable:B,defaultViewport:I,translateExtent:$,minZoom:V,maxZoom:v,preventScrolling:k,defaultMarkerColor:E,zoomOnScroll:A,zoomOnPinch:C,panOnScroll:S,panOnScrollSpeed:L,panOnScrollMode:R,zoomOnDoubleClick:H,panOnDrag:O,onPaneClick:j,onPaneMouseEnter:Y,onPaneMouseMove:U,onPaneMouseLeave:q,onPaneScroll:F,onPaneContextMenu:W,paneClickDistance:Q,nodeClickDistance:Z,onEdgeContextMenu:K,onEdgeMouseEnter:G,onEdgeMouseMove:te,onEdgeMouseLeave:ne,reconnectRadius:ee,onReconnect:se,onReconnectStart:Se,onReconnectEnd:we,noDragClassName:ke,noWheelClassName:Ze,noPanClassName:Qe,disableKeyboardA11y:Je,nodeExtent:un,rfId:_t,viewport:Re,onViewportChange:et}){return mo(e),mo(t),zh(),Nh(n),Ch(Re),P.jsx(Ud,{onPaneClick:j,onPaneMouseEnter:Y,onPaneMouseMove:U,onPaneMouseLeave:q,onPaneContextMenu:W,onPaneScroll:F,paneClickDistance:Q,deleteKeyCode:T,selectionKeyCode:b,selectionOnDrag:p,selectionMode:w,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:N,panActivationKeyCode:_,zoomActivationKeyCode:M,elementsSelectable:B,zoomOnScroll:A,zoomOnPinch:C,zoomOnDoubleClick:H,panOnScroll:S,panOnScrollSpeed:L,panOnScrollMode:R,panOnDrag:O,defaultViewport:I,translateExtent:$,minZoom:V,maxZoom:v,onSelectionContextMenu:u,preventScrolling:k,noDragClassName:ke,noWheelClassName:Ze,noPanClassName:Qe,disableKeyboardA11y:Je,onViewportChange:et,isControlledViewport:!!Re,children:P.jsxs(Sh,{children:[P.jsx(_h,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:se,onReconnectStart:Se,onReconnectEnd:we,onlyRenderVisibleElements:z,onEdgeContextMenu:K,onEdgeMouseEnter:G,onEdgeMouseMove:te,onEdgeMouseLeave:ne,reconnectRadius:ee,defaultMarkerColor:E,noPanClassName:Qe,disableKeyboardA11y:Je,rfId:_t}),P.jsx(Ph,{style:y,type:g,component:x,containerStyle:m}),P.jsx("div",{className:"react-flow__edgelabel-renderer"}),P.jsx(oh,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:d,nodeClickDistance:Z,onlyRenderVisibleElements:z,noPanClassName:Qe,noDragClassName:ke,disableKeyboardA11y:Je,nodeExtent:un,rfId:_t}),P.jsx("div",{className:"react-flow__viewport-portal"})]})})}ts.displayName="GraphView";const Dh=D.memo(ts),yo=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:d,nodeExtent:u,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,y=new Map,x=new Map,m=r??t??[],b=n??e??[],p=d??[0,0],w=u??ft;pi(y,x,m);const N=Ln(b,h,g,{nodeOrigin:p,nodeExtent:w,zIndexMode:f});let _=[0,0,1];if(s&&o&&i){const M=wt(h,{filter:I=>!!((I.width||I.initialWidth)&&(I.height||I.initialHeight))}),{x:T,y:z,zoom:B}=Gn(M,o,i,c,l,(a==null?void 0:a.padding)??.1);_=[T,z,B]}return{rfId:"1",width:o??0,height:i??0,transform:_,nodes:b,nodesInitialized:N,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:x,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:ft,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:We.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:{...Zo},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Ul,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ko,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Lh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:d,nodeExtent:u,zIndexMode:f})=>ed((h,g)=>{async function y(){const{nodeLookup:x,panZoom:m,fitViewOptions:b,fitViewResolver:p,width:w,height:N,minZoom:_,maxZoom:M}=g();m&&(await ql({nodes:x,width:w,height:N,panZoom:m,minZoom:_,maxZoom:M},b),p==null||p.resolve(!0),h({fitViewResolver:null}))}return{...yo({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:d,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:x=>{const{nodeLookup:m,parentLookup:b,nodeOrigin:p,elevateNodesOnSelect:w,fitViewQueued:N,zIndexMode:_}=g(),M=Ln(x,m,b,{nodeOrigin:p,nodeExtent:u,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:_});N&&M?(y(),h({nodes:x,nodesInitialized:M,fitViewQueued:!1,fitViewOptions:void 0})):h({nodes:x,nodesInitialized:M})},setEdges:x=>{const{connectionLookup:m,edgeLookup:b}=g();pi(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:w,nodeOrigin:N,nodeExtent:_,debug:M,fitViewQueued:T,zIndexMode:z}=g(),{changes:B,updatedInternals:I}=xf(x,b,p,w,N,_,z);I&&(gf(b,p,{nodeOrigin:N,nodeExtent:_,zIndexMode:z}),T?(y(),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:w,triggerNodeChanges:N,connection:_,updateConnection:M,onNodesChangeMiddlewareMap:T}=g();for(const[z,B]of x){const I=w.get(z),$=!!(I!=null&&I.expandParent&&(I!=null&&I.parentId)&&(B!=null&&B.position)),V={id:z,type:"position",position:$?{x:Math.max(0,B.position.x),y:Math.max(0,B.position.y)}:B.position,dragging:m};if(I&&_.inProgress&&_.fromNode.id===I.id){const v=He(I,_.fromHandle,X.Left,!0);M({..._,from:v})}$&&I.parentId&&b.push({id:z,parentId:I.parentId,rect:{...B.internals.positionAbsolute,width:B.measured.width??0,height:B.measured.height??0}}),p.push(V)}if(b.length>0){const{parentLookup:z,nodeOrigin:B}=g(),I=er(b,w,z,B);p.push(...I)}for(const z of T.values())p=z(p);N(p)},triggerNodeChanges:x=>{const{onNodesChange:m,setNodes:b,nodes:p,hasDefaultNodes:w,debug:N}=g();if(x!=null&&x.length){if(w){const _=Ai(x,p);b(_)}N&&console.log("React Flow: trigger node changes",x),m==null||m(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:m,setEdges:b,edges:p,hasDefaultEdges:w,debug:N}=g();if(x!=null&&x.length){if(w){const _=$i(x,p);b(_)}N&&console.log("React Flow: trigger edge changes",x),m==null||m(x)}},addSelectedNodes:x=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:N}=g();if(m){const _=x.map(M=>Ae(M,!0));w(_);return}w(Fe(p,new Set([...x]),!0)),N(Fe(b))},addSelectedEdges:x=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:N}=g();if(m){const _=x.map(M=>Ae(M,!0));N(_);return}N(Fe(b,new Set([...x]))),w(Fe(p,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:m}={})=>{const{edges:b,nodes:p,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:_}=g(),M=x||p,T=m||b,z=[];for(const I of M){if(!I.selected)continue;const $=w.get(I.id);$&&($.selected=!1),z.push(Ae(I.id,!1))}const B=[];for(const I of T)I.selected&&B.push(Ae(I.id,!1));N(z),_(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:w}=g();if(!w)return;const N=m.reduce((M,T)=>T.selected?[...M,Ae(T.id,!1)]:M,[]),_=x.reduce((M,T)=>T.selected?[...M,Ae(T.id,!1)]:M,[]);b(N),p(_)},setNodeExtent:x=>{const{nodes:m,nodeLookup:b,parentLookup:p,nodeOrigin:w,elevateNodesOnSelect:N,nodeExtent:_,zIndexMode:M}=g();x[0][0]===_[0][0]&&x[0][1]===_[0][1]&&x[1][0]===_[1][0]&&x[1][1]===_[1][1]||(Ln(m,b,p,{nodeOrigin:w,nodeExtent:x,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:M}),h({nodeExtent:x}))},panBy:x=>{const{transform:m,width:b,height:p,panZoom:w,translateExtent:N}=g();return wf({delta:x,panZoom:w,transform:m,translateExtent:N,width:b,height:p})},setCenter:async(x,m,b)=>{const{width:p,height:w,maxZoom:N,panZoom:_}=g();if(!_)return Promise.resolve(!1);const M=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:N;return await _.setViewport({x:p/2-x*M,y:w/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}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...Zo}})},updateConnection:x=>{h({connection:x})},reset:()=>h({...yo()})}},Object.is);function Hh({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:d,nodeExtent:u,zIndexMode:f,children:h}){const[g]=D.useState(()=>Lh({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:l,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:d,nodeExtent:u,zIndexMode:f}));return P.jsx(td,{value:g,children:P.jsx(Sd,{children:h})})}function Rh({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h}){return D.useContext(on)?P.jsx(P.Fragment,{children:e}):P.jsx(Hh,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h,children:e})}const Vh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Bh({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:d,onMoveStart:u,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:y,onClickConnectStart:x,onClickConnectEnd:m,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:N,onNodeDoubleClick:_,onNodeDragStart:M,onNodeDrag:T,onNodeDragStop:z,onNodesDelete:B,onEdgesDelete:I,onDelete:$,onSelectionChange:V,onSelectionDragStart:v,onSelectionDrag:k,onSelectionDragStop:E,onSelectionContextMenu:A,onSelectionStart:C,onSelectionEnd:S,onBeforeDelete:L,connectionMode:R,connectionLineType:H=Ce.Bezier,connectionLineStyle:O,connectionLineComponent:j,connectionLineContainerStyle:Y,deleteKeyCode:U="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:F=!1,selectionMode:W=dt.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:Z=gt()?"Meta":"Control",zoomActivationKeyCode:K=gt()?"Meta":"Control",snapToGrid:G,snapGrid:te,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:ee,nodesDraggable:se,autoPanOnNodeFocus:Se,nodesConnectable:we,nodesFocusable:ke,nodeOrigin:Ze=Ii,edgesFocusable:Qe,edgesReconnectable:Je,elementsSelectable:un=!0,defaultViewport:_t=gd,minZoom:Re=.5,maxZoom:et=2,translateExtent:rr=ft,preventScrolling:is=!0,nodeExtent:ln,defaultMarkerColor:ss="#b1b1b7",zoomOnScroll:as=!0,zoomOnPinch:cs=!0,panOnScroll:us=!1,panOnScrollSpeed:ls=.5,panOnScrollMode:fs=Te.Free,zoomOnDoubleClick:ds=!0,panOnDrag:hs=!0,onPaneClick:gs,onPaneMouseEnter:ps,onPaneMouseMove:ms,onPaneMouseLeave:ys,onPaneScroll:xs,onPaneContextMenu:ws,paneClickDistance:vs=1,nodeClickDistance:bs=0,children:_s,onReconnect:Es,onReconnectStart:Ss,onReconnectEnd:Ns,onEdgeContextMenu:Ms,onEdgeDoubleClick:Cs,onEdgeMouseEnter:Is,onEdgeMouseMove:ks,onEdgeMouseLeave:As,reconnectRadius:$s=10,onNodesChange:Ps,onEdgesChange:Ts,noDragClassName:zs="nodrag",noWheelClassName:Ds="nowheel",noPanClassName:or="nopan",fitView:ir,fitViewOptions:sr,connectOnClick:Ls,attributionPosition:Hs,proOptions:Rs,defaultEdgeOptions:Vs,elevateNodesOnSelect:Bs=!0,elevateEdgesOnSelect:Fs=!1,disableKeyboardA11y:ar=!1,autoPanOnConnect:Os,autoPanOnNodeDrag:js,autoPanSpeed:Xs,connectionRadius:Ys,isValidConnection:Ws,onError:qs,style:Gs,id:cr,nodeDragThreshold:Us,connectionDragThreshold:Ks,viewport:Zs,onViewportChange:Qs,width:Js,height:ea,colorMode:ta="light",debug:na,onScroll:Et,ariaLabelConfig:ra,zIndexMode:ur="basic",...oa},ia){const fn=cr||"1",sa=xd(ta),aa=D.useCallback(lr=>{lr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Et==null||Et(lr)},[Et]);return P.jsx("div",{"data-testid":"rf__wrapper",...oa,onScroll:aa,style:{...Gs,...Vh},ref:ia,className:ie(["react-flow",o,sa]),id:cr,role:"application",children:P.jsxs(Rh,{nodes:e,edges:t,width:Js,height:ea,fitView:ir,fitViewOptions:sr,minZoom:Re,maxZoom:et,nodeOrigin:Ze,nodeExtent:ln,zIndexMode:ur,children:[P.jsx(Dh,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:N,onNodeDoubleClick:_,nodeTypes:i,edgeTypes:s,connectionLineType:H,connectionLineStyle:O,connectionLineComponent:j,connectionLineContainerStyle:Y,selectionKeyCode:q,selectionOnDrag:F,selectionMode:W,deleteKeyCode:U,multiSelectionKeyCode:Z,panActivationKeyCode:Q,zoomActivationKeyCode:K,onlyRenderVisibleElements:ne,defaultViewport:_t,translateExtent:rr,minZoom:Re,maxZoom:et,preventScrolling:is,zoomOnScroll:as,zoomOnPinch:cs,zoomOnDoubleClick:ds,panOnScroll:us,panOnScrollSpeed:ls,panOnScrollMode:fs,panOnDrag:hs,onPaneClick:gs,onPaneMouseEnter:ps,onPaneMouseMove:ms,onPaneMouseLeave:ys,onPaneScroll:xs,onPaneContextMenu:ws,paneClickDistance:vs,nodeClickDistance:bs,onSelectionContextMenu:A,onSelectionStart:C,onSelectionEnd:S,onReconnect:Es,onReconnectStart:Ss,onReconnectEnd:Ns,onEdgeContextMenu:Ms,onEdgeDoubleClick:Cs,onEdgeMouseEnter:Is,onEdgeMouseMove:ks,onEdgeMouseLeave:As,reconnectRadius:$s,defaultMarkerColor:ss,noDragClassName:zs,noWheelClassName:Ds,noPanClassName:or,rfId:fn,disableKeyboardA11y:ar,nodeExtent:ln,viewport:Zs,onViewportChange:Qs}),P.jsx(yd,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:y,onClickConnectStart:x,onClickConnectEnd:m,nodesDraggable:se,autoPanOnNodeFocus:Se,nodesConnectable:we,nodesFocusable:ke,edgesFocusable:Qe,edgesReconnectable:Je,elementsSelectable:un,elevateNodesOnSelect:Bs,elevateEdgesOnSelect:Fs,minZoom:Re,maxZoom:et,nodeExtent:ln,onNodesChange:Ps,onEdgesChange:Ts,snapToGrid:G,snapGrid:te,connectionMode:R,translateExtent:rr,connectOnClick:Ls,defaultEdgeOptions:Vs,fitView:ir,fitViewOptions:sr,onNodesDelete:B,onEdgesDelete:I,onDelete:$,onNodeDragStart:M,onNodeDrag:T,onNodeDragStop:z,onSelectionDrag:k,onSelectionDragStart:v,onSelectionDragStop:E,onMove:d,onMoveStart:u,onMoveEnd:f,noPanClassName:or,nodeOrigin:Ze,rfId:fn,autoPanOnConnect:Os,autoPanOnNodeDrag:js,autoPanSpeed:Xs,onError:qs,connectionRadius:Ys,isValidConnection:Ws,selectNodesOnDrag:ee,nodeDragThreshold:Us,connectionDragThreshold:Ks,onBeforeDelete:L,debug:na,ariaLabelConfig:ra,zIndexMode:ur}),P.jsx(hd,{onSelectionChange:V}),_s,P.jsx(cd,{proOptions:Rs,position:Hs}),P.jsx(ad,{rfId:fn,disableKeyboardA11y:ar})]})})}var gg=Pi(Bh);const Fh=e=>e.nodes;function pg(){return J(Fh,re)}function mg(e){const[t,n]=D.useState(e),r=D.useCallback(o=>n(i=>Ai(o,i)),[]);return[t,n,r]}function yg(e){const[t,n]=D.useState(e),r=D.useCallback(o=>n(i=>$i(o,i)),[]);return[t,n,r]}function Oh({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:ie(["react-flow__background-pattern",n,r])})}function jh({radius:e,className:t}){return P.jsx("circle",{cx:e,cy:e,r:e,className:ie(["react-flow__background-pattern","dots",t])})}var Ie;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ie||(Ie={}));const Xh={[Ie.Dots]:1,[Ie.Lines]:1,[Ie.Cross]:6},Yh=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ns({id:e,variant:t=Ie.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:c,className:l,patternClassName:d}){const u=D.useRef(null),{transform:f,patternId:h}=J(Yh,re),g=r||Xh[t],y=t===Ie.Dots,x=t===Ie.Cross,m=Array.isArray(n)?n:[n,n],b=[m[0]*f[2]||1,m[1]*f[2]||1],p=g*f[2],w=Array.isArray(i)?i:[i,i],N=x?[p,p]:b,_=[w[0]*f[2]||1+N[0]/2,w[1]*f[2]||1+N[1]/2],M=`${h}${e||""}`;return P.jsxs("svg",{className:ie(["react-flow__background",l]),style:{...c,...an,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:u,"data-testid":"rf__background",children:[P.jsx("pattern",{id:M,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:y?P.jsx(jh,{radius:p/2,className:d}):P.jsx(Oh,{dimensions:N,lineWidth:o,variant:t,className:d})}),P.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}ns.displayName="Background";const xg=D.memo(ns);function Wh(){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 qh(){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 Gh(){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 Uh(){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 Kh(){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 Pt({children:e,className:t,...n}){return P.jsx("button",{type:"button",className:ie(["react-flow__controls-button",t]),...n,children:e})}const Zh=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function rs({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:l,children:d,position:u="bottom-left",orientation:f="vertical","aria-label":h}){const g=oe(),{isInteractive:y,minZoomReached:x,maxZoomReached:m,ariaLabelConfig:b}=J(Zh,re),{zoomIn:p,zoomOut:w,fitView:N}=tr(),_=()=>{p(),i==null||i()},M=()=>{w(),s==null||s()},T=()=>{N(o),a==null||a()},z=()=>{g.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),c==null||c(!y)},B=f==="horizontal"?"horizontal":"vertical";return P.jsxs(sn,{className:ie(["react-flow__controls",B,l]),position:u,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&P.jsxs(P.Fragment,{children:[P.jsx(Pt,{onClick:_,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:m,children:P.jsx(Wh,{})}),P.jsx(Pt,{onClick:M,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:x,children:P.jsx(qh,{})})]}),n&&P.jsx(Pt,{className:"react-flow__controls-fitview",onClick:T,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:P.jsx(Gh,{})}),r&&P.jsx(Pt,{className:"react-flow__controls-interactive",onClick:z,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:y?P.jsx(Kh,{}):P.jsx(Uh,{})}),d]})}rs.displayName="Controls";const wg=D.memo(rs);function Qh({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:c,className:l,borderRadius:d,shapeRendering:u,selected:f,onClick:h}){const{background:g,backgroundColor:y}=i||{},x=s||g||y;return P.jsx("rect",{className:ie(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:d,ry:d,width:r,height:o,style:{fill:x,stroke:a,strokeWidth:c},shapeRendering:u,onClick:h?m=>h(m,e):void 0})}const Jh=D.memo(Qh),eg=e=>e.nodes.map(t=>t.id),Sn=e=>e instanceof Function?e:()=>e;function tg({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Jh,onClick:s}){const a=J(eg,re),c=Sn(t),l=Sn(e),d=Sn(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return P.jsx(P.Fragment,{children:a.map(f=>P.jsx(rg,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:u},f))})}function ng({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:l,x:d,y:u,width:f,height:h}=J(g=>{const y=g.nodeLookup.get(e);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const x=y.internals.userNode,{x:m,y:b}=y.internals.positionAbsolute,{width:p,height:w}=Ee(x);return{node:x,x:m,y:b,width:p,height:w}},re);return!l||l.hidden||!oi(l)?null:P.jsx(a,{x:d,y:u,width:f,height:h,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:o,strokeColor:n(l),strokeWidth:i,shapeRendering:s,onClick:c,id:l.id})}const rg=D.memo(ng);var og=D.memo(tg);const ig=200,sg=150,ag=e=>!e.hidden,cg=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?ri(wt(e.nodeLookup,{filter:ag}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},ug="react-flow__minimap-desc";function os({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:d,maskStrokeWidth:u,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:y=!1,zoomable:x=!1,ariaLabel:m,inversePan:b,zoomStep:p=1,offsetScale:w=5}){const N=oe(),_=D.useRef(null),{boundingRect:M,viewBB:T,rfId:z,panZoom:B,translateExtent:I,flowWidth:$,flowHeight:V,ariaLabelConfig:v}=J(cg,re),k=(e==null?void 0:e.width)??ig,E=(e==null?void 0:e.height)??sg,A=M.width/k,C=M.height/E,S=Math.max(A,C),L=S*k,R=S*E,H=w*S,O=M.x-(L-M.width)/2-H,j=M.y-(R-M.height)/2-H,Y=L+H*2,U=R+H*2,q=`${ug}-${z}`,F=D.useRef(0),W=D.useRef();F.current=S,D.useEffect(()=>{if(_.current&&B)return W.current=If({domNode:_.current,panZoom:B,getTransform:()=>N.getState().transform,getViewScale:()=>F.current}),()=>{var G;(G=W.current)==null||G.destroy()}},[B]),D.useEffect(()=>{var G;(G=W.current)==null||G.update({translateExtent:I,width:$,height:V,inversePan:b,pannable:y,zoomStep:p,zoomable:x})},[y,x,b,p,I,$,V]);const Q=h?G=>{var ee;const[te,ne]=((ee=W.current)==null?void 0:ee.pointer(G))||[0,0];h(G,{x:te,y:ne})}:void 0,Z=g?D.useCallback((G,te)=>{const ne=N.getState().nodeLookup.get(te).internals.userNode;g(G,ne)},[]):void 0,K=m??v["minimap.ariaLabel"];return P.jsx(sn,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*S: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:ie(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:P.jsxs("svg",{width:k,height:E,viewBox:`${O} ${j} ${Y} ${U}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":q,ref:_,onClick:Q,children:[K&&P.jsx("title",{id:q,children:K}),P.jsx(og,{onClick:Z,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),P.jsx("path",{className:"react-flow__minimap-mask",d:`M${O-H},${j-H}h${Y+H*2}v${U+H*2}h${-Y-H*2}z M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}os.displayName="MiniMap";const vg=D.memo(os),lg=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,fg={[Ke.Line]:"right",[Ke.Handle]:"bottom-right"};function dg({nodeId:e,position:t,variant:n=Ke.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:y,onResize:x,onResizeEnd:m}){const b=Li(),p=typeof e=="string"?e:b,w=oe(),N=D.useRef(null),_=n===Ke.Handle,M=J(D.useCallback(lg(_&&h),[_,h]),re),T=D.useRef(null),z=t??fg[n];D.useEffect(()=>{if(!(!N.current||!p))return T.current||(T.current=Of({domNode:N.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:I,transform:$,snapGrid:V,snapToGrid:v,nodeOrigin:k,domNode:E}=w.getState();return{nodeLookup:I,transform:$,snapGrid:V,snapToGrid:v,nodeOrigin:k,paneDomNode:E}},onChange:(I,$)=>{const{triggerNodeChanges:V,nodeLookup:v,parentLookup:k,nodeOrigin:E}=w.getState(),A=[],C={x:I.x,y:I.y},S=v.get(p);if(S&&S.expandParent&&S.parentId){const L=S.origin??E,R=I.width??S.measured.width??0,H=I.height??S.measured.height??0,O={id:S.id,parentId:S.parentId,rect:{width:R,height:H,...ii({x:I.x??S.position.x,y:I.y??S.position.y},{width:R,height:H},S.parentId,v,L)}},j=er([O],v,k,E);A.push(...j),C.x=I.x?Math.max(L[0]*R,I.x):void 0,C.y=I.y?Math.max(L[1]*H,I.y):void 0}if(C.x!==void 0&&C.y!==void 0){const L={id:p,type:"position",position:{...C}};A.push(L)}if(I.width!==void 0&&I.height!==void 0){const R={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:I.width,height:I.height}};A.push(R)}for(const L of $){const R={...L,type:"position"};A.push(R)}V(A)},onEnd:({width:I,height:$})=>{const V={id:p,type:"dimensions",resizing:!1,dimensions:{width:I,height:$}};w.getState().triggerNodeChanges([V])}})),T.current.update({controlPosition:z,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:y,onResize:x,onResizeEnd:m,shouldResize:g}),()=>{var I;(I=T.current)==null||I.destroy()}},[z,a,c,l,d,u,y,x,m,g]);const B=z.split("-");return P.jsx("div",{className:ie(["react-flow__resize-control","nodrag",...B,n,r]),ref:N,style:{...o,scale:M,...s&&{[_?"backgroundColor":"borderColor"]:s}},children:i})}D.memo(dg);export{xg as B,wg as C,Gt as H,vg as M,X as P,Hh as R,yg as a,tr as b,Ie as c,Kt as d,pg as e,gg as i,Oo as t,mg as u};