vendor: 10,573 bytes, lines 1-36
1import{ag as $e,ai as ea,aj as ta,R as na,r as P,j as y,ak as oa,f as Xo,a4 as Wo,al as qo,am as Go,v as Ko,G as ra,H as Uo,an as Zo,ao as ia,X as Qo,I as Jo,t as sa,B as fn,l as aa,e as ca,A as la,z as Ue,g as ua,k as da,P as fa,ap as ha}from"./index-BIdkve2-.js";import{a as Me,c as Gn,b as Kn,d as ga,i as tn}from"./value-3LWPH8SZ.js";import{w as nn}from"./workflows-nS2kVCdG.js";import{T as er}from"./trending-up-iuqOebNk.js";import{R as tr}from"./rotate-ccw-7r1vtdP8.js";import{C as nr}from"./clock-DT1WSrwQ.js";import{S as pa}from"./save-nKrXId3U.js";import{A as ma}from"./arrow-left-CgjFbDiB.js";/** 2 * @license lucide-react v0.400.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const or=$e("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** 7 * @license lucide-react v0.400.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const rr=$e("CircleCheckBig",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** 12 * @license lucide-react v0.400.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ir=$e("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** 17 * @license lucide-react v0.400.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const En=$e("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** 22 * @license lucide-react v0.400.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const ya=$e("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** 27 * @license lucide-react v0.400.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const sr=$e("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** 32 * @license lucide-react v0.400.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const ar=$e("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);var Un=180/Math.PI,hn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cr(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Un,skewX:Math.atan(c)*Un,scaleX:s,scaleY:a}}var xt;function xa(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?hn:cr(t.a,t.b,t.c,t.d,t.e,t.f)}function wa(e){return e==null||(xt||(xt=document.createElementNS("http://www.w3.org/2000/svg","g")),xt.setAttribute("transform",e),!(e=xt.transform.baseVal.consolidate()))?hn:(e=e.matrix,cr(e.a,e.b,e.c,e.d,e.e,e.f))}function lr(e,t,n,o){function r(u){return u.length?u.pop()+" ":""}function i(u,f,l,d,p,g){if(u!==l||f!==d){var w=p.push("translate(",null,t,null,n);g.push({i:w-4,x:Me(u,l)},{i:w-2,x:Me(f,d)})}else(l||d)&&p.push("translate("+l+t+d+n)}function s(u,f,l,d){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),d.push({i:l.push(r(l)+"rotate(",null,o)-2,x:Me(u,f)})):f&&l.push(r(l)+"rotate("+f+o)}function a(u,f,l,d){u!==f?d.push({i:l.push(r(l)+"skewX(",null,o)-2,x:Me(u,f)}):f&&l.push(r(l)+"skewX("+f+o)}function c(u,f,l,d,p,g){if(u!==l||f!==d){var w=p.push(r(p)+"scale(",null,",",null,")");g.push({i:w-4,x:Me(u,l)},{i:w-2,x:Me(f,d)})}else(l!==1||d!==1)&&p.push(r(p)+"scale("+l+","+d+")")}return function(u,f){var l=[],d=[];return u=e(u),f=e(f),i(u.translateX,u.translateY,f.translateX,f.translateY,l,d),s(u.rotate,f.rotate,l,d),a(u.skewX,f.skewX,l,d),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,l,d),u=f=null,function(p){for(var g=-1,w=d.length,b;++g<w;)l[(b=d[g]).i]=b.x(p);return l.join("")}}}var ba=lr(xa,"px, ","px)","deg)"),va=lr(wa,", ",")",")"),_a=1e-12;function Zn(e){return((e=Math.exp(e))+1/e)/2}function Na(e){return((e=Math.exp(e))-1/e)/2}function Ea(e){return((e=Math.exp(2*e))-1)/(e+1)}const St=function e(t,n,o){function r(i,s){var a=i[0],c=i[1],u=i[2],f=s[0],l=s[1],d=s[2],p=f-a,g=l-c,w=p*p+g*g,b,m;if(w<_a)m=Math.log(d/u)/t,b=function(I){return[a+I*p,c+I*g,u*Math.exp(t*I*m)]};else{var E=Math.sqrt(w),h=(d*d-u*u+o*w)/(2*u*n*E),x=(d*d-u*u-o*w)/(2*d*n*E),k=Math.log(Math.sqrt(h*h+1)-h),S=Math.log(Math.sqrt(x*x+1)-x);m=(S-k)/t,b=function(I){var D=I*m,j=Zn(k),B=u/(n*E)*(j*Ea(t*D+k)-Na(k));return[a+B*p,c+B*g,u*j/Zn(t*D+k)]}}return b.duration=m*1e3*t/Math.SQRT2,b}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r}(Math.SQRT2,2,4);function ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ie(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Ca={value:()=>{}};function Bt(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Mt(n)}function Mt(e){this._=e}function Sa(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Mt.prototype=Bt.prototype={constructor:Mt,on:function(e,t){var n=this._,o=Sa(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Ma(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Qn(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Qn(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Mt(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function Ma(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Qn(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Ca,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var gn="http://www.w3.org/1999/xhtml";const Jn={svg:"http://www.w3.org/2000/svg",xhtml:gn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Jn.hasOwnProperty(t)?{space:Jn[t],local:e}:e}function ka(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===gn&&t.documentElement.namespaceURI===gn?t.createElement(e):t.createElementNS(n,e)}}function Ia(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ur(e){var t=Vt(e);return(t.local?Ia:ka)(t)}function Aa(){}function Cn(e){return e==null?Aa:function(){return this.querySelector(e)}}function Pa(e){typeof e!="function"&&(e=Cn(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),c,u,f=0;f<s;++f)(c=i[f])&&(u=e.call(c,c.__data__,f,i))&&("__data__"in c&&(u.__data__=c.__data__),a[f]=u);return new ce(o,this._parents)}function Ta(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function $a(){return[]}function dr(e){return e==null?$a:function(){return this.querySelectorAll(e)}}function ja(e){return function(){return Ta(e.apply(this,arguments))}}function za(e){typeof e=="function"?e=ja(e):e=dr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,u=0;u<a;++u)(c=s[u])&&(o.push(e.call(c,c.__data__,u,s)),r.push(c));return new ce(o,r)}function fr(e){return function(){return this.matches(e)}}function hr(e){return function(t){return t.matches(e)}}var Da=Array.prototype.find;function La(e){return function(){return Da.call(this.children,e)}}function Ha(){return this.firstElementChild}function Ra(e){return this.select(e==null?Ha:La(typeof e=="function"?e:hr(e)))}var Ba=Array.prototype.filter;function Va(){return Array.from(this.children)}function Oa(e){return function(){return Ba.call(this.children,e)}}function Fa(e){return this.selectAll(e==null?Va:Oa(typeof e=="function"?e:hr(e)))}function Ya(e){typeof e!="function"&&(e=fr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new ce(o,this._parents)}function gr(e){return new Array(e.length)}function Xa(){return new ce(this._enter||this._groups.map(gr),this._parents)}function Pt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Pt.prototype={constructor:Pt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Wa(e){return function(){return e}}function qa(e,t,n,o,r,i){for(var s=0,a,c=t.length,u=i.length;s<u;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Pt(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function Ga(e,t,n,o,r,i,s){var a,c,u=new Map,f=t.length,l=i.length,d=new Array(f),p;for(a=0;a<f;
vendor: 7,192 bytes, line 36
36++a)(c=t[a])&&(d[a]=p=s.call(c,c.__data__,a,t)+"",u.has(p)?r[a]=c:u.set(p,c));for(a=0;a<l;++a)p=s.call(e,i[a],a,i)+"",(c=u.get(p))?(o[a]=c,c.__data__=i[a],u.delete(p)):n[a]=new Pt(e,i[a]);for(a=0;a<f;++a)(c=t[a])&&u.get(d[a])===c&&(r[a]=c)}function Ka(e){return e.__data__}function Ua(e,t){if(!arguments.length)return Array.from(this,Ka);var n=t?Ga:qa,o=this._parents,r=this._groups;typeof e!="function"&&(e=Wa(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),u=0;u<i;++u){var f=o[u],l=r[u],d=l.length,p=Za(e.call(f,f&&f.__data__,u,o)),g=p.length,w=a[u]=new Array(g),b=s[u]=new Array(g),m=c[u]=new Array(d);n(f,l,w,b,m,p,t);for(var E=0,h=0,x,k;E<g;++E)if(x=w[E]){for(E>=h&&(h=E+1);!(k=b[h])&&++h<g;);x._next=k||null}}return s=new ce(s,o),s._enter=a,s._exit=c,s}function Za(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Qa(){return new ce(this._exit||this._groups.map(gr),this._parents)}function Ja(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function ec(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),c=0;c<s;++c)for(var u=n[c],f=o[c],l=u.length,d=a[c]=new Array(l),p,g=0;g<l;++g)(p=u[g]||f[g])&&(d[g]=p);for(;c<r;++c)a[c]=n[c];return new ce(a,this._parents)}function tc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function nc(e){e||(e=oc);function t(l,d){return l&&d?e(l.__data__,d.__data__):!l-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,c=r[i]=new Array(a),u,f=0;f<a;++f)(u=s[f])&&(c[f]=u);c.sort(t)}return new ce(r,this._parents).order()}function oc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function rc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ic(){return Array.from(this)}function sc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function ac(){let e=0;for(const t of this)++e;return e}function cc(){return!this.node()}function lc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function uc(e){return function(){this.removeAttribute(e)}}function dc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fc(e,t){return function(){this.setAttribute(e,t)}}function hc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function gc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function pc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function mc(e,t){var n=Vt(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?dc:uc:typeof t=="function"?n.local?pc:gc:n.local?hc:fc)(n,t))}function pr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function yc(e){return function(){this.style.removeProperty(e)}}function xc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function wc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function bc(e,t,n){return arguments.length>1?this.each((t==null?yc:typeof t=="function"?wc:xc)(e,t,n??"")):Re(this.node(),e)}function Re(e,t){return e.style.getPropertyValue(t)||pr(e).getComputedStyle(e,null).getPropertyValue(t)}function vc(e){return function(){delete this[e]}}function _c(e,t){return function(){this[e]=t}}function Nc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ec(e,t){return arguments.length>1?this.each((t==null?vc:typeof t=="function"?Nc:_c)(e,t)):this.node()[e]}function mr(e){return e.trim().split(/^|\s+/)}function Sn(e){return e.classList||new yr(e)}function yr(e){this._node=e,this._names=mr(e.getAttribute("class")||"")}yr.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 xr(e,t){for(var n=Sn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function wr(e,t){for(var n=Sn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Cc(e){return function(){xr(this,e)}}function Sc(e){return function(){wr(this,e)}}function Mc(e,t){return function(){(t.apply(this,arguments)?xr:wr)(this,e)}}function kc(e,t){var n=mr(e+"");if(arguments.length<2){for(var o=Sn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Mc:t?Cc:Sc)(n,t))}function Ic(){this.textContent=""}function Ac(e){return function(){this.textContent=e}}function Pc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Tc(e){return arguments.length?this.each(e==null?Ic:(typeof e=="function"?Pc:Ac)(e)):this.node().textContent}function $c(){this.innerHTML=""}function jc(e){return function(){this.innerHTML=e}}function zc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Dc(e){return arguments.length?this.each(e==null?$c:(typeof e=="function"?zc:jc)(e)):this.node().innerHTML}function Lc(){this.nextSibling&&this.parentNode.appendChild(this)}function Hc(){return this.each(Lc)}function Rc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Bc(){return this.each(Rc)}function Vc(e){var t=typeof e=="function"?e:ur(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Oc(){return null}function Fc(e,t){var n=typeof e=="function"?e:ur(e),o=t==null?Oc:typeof t=="function"?t:Cn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Yc(){var e=this.parentNode;e&&e.removeChild(this)}function Xc(){return this.each(Yc)}function Wc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function qc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Gc(e){return this.select(e?qc:Wc)}function Kc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Uc(e){return function(t){e.call(this,t,this.__data__)}}function Zc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Qc(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}
vendor: 24,583 bytes, line 36
36function Jc(e,t,n){return function(){var o=this.__on,r,i=Uc(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function el(e,t,n){var o=Zc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,u=a.length,f;c<u;++c)for(r=0,f=a[c];r<i;++r)if((s=o[r]).type===f.type&&s.name===f.name)return f.value}return}for(a=t?Jc:Qc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function br(e,t,n){var o=pr(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function tl(e,t){return function(){return br(this,e,t)}}function nl(e,t){return function(){return br(this,e,t.apply(this,arguments))}}function ol(e,t){return this.each((typeof t=="function"?nl:tl)(e,t))}function*rl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var vr=[null];function ce(e,t){this._groups=e,this._parents=t}function ut(){return new ce([[document.documentElement]],vr)}function il(){return this}ce.prototype=ut.prototype={constructor:ce,select:Pa,selectAll:za,selectChild:Ra,selectChildren:Fa,filter:Ya,data:Ua,enter:Xa,exit:Qa,join:Ja,merge:ec,selection:il,order:tc,sort:nc,call:rc,nodes:ic,node:sc,size:ac,empty:cc,each:lc,attr:mc,style:bc,property:Ec,classed:kc,text:Tc,html:Dc,raise:Hc,lower:Bc,append:Vc,insert:Fc,remove:Xc,clone:Gc,datum:Kc,on:el,dispatch:ol,[Symbol.iterator]:rl};function ae(e){return typeof e=="string"?new ce([[document.querySelector(e)]],[document.documentElement]):new ce([[e]],vr)}function sl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ue(e,t){if(e=sl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const al={passive:!1},ot={capture:!0,passive:!1};function on(e){e.stopImmediatePropagation()}function He(e){e.preventDefault(),e.stopImmediatePropagation()}function _r(e){var t=e.document.documentElement,n=ae(e).on("dragstart.drag",He,ot);"onselectstart"in t?n.on("selectstart.drag",He,ot):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Nr(e,t){var n=e.document.documentElement,o=ae(e).on("dragstart.drag",null);t&&(o.on("click.drag",He,ot),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const wt=e=>()=>e;function pn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}pn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function cl(e){return!e.ctrlKey&&!e.button}function ll(){return this.parentNode}function ul(e,t){return t??{x:e.x,y:e.y}}function dl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Er(){var e=cl,t=ll,n=ul,o=dl,r={},i=Bt("start","drag","end"),s=0,a,c,u,f,l=0;function d(x){x.on("mousedown.drag",p).filter(o).on("touchstart.drag",b).on("touchmove.drag",m,al).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(x,k){if(!(f||!e.call(this,x,k))){var S=h(this,t.call(this,x,k),x,k,"mouse");S&&(ae(x.view).on("mousemove.drag",g,ot).on("mouseup.drag",w,ot),_r(x.view),on(x),u=!1,a=x.clientX,c=x.clientY,S("start",x))}}function g(x){if(He(x),!u){var k=x.clientX-a,S=x.clientY-c;u=k*k+S*S>l}r.mouse("drag",x)}function w(x){ae(x.view).on("mousemove.drag mouseup.drag",null),Nr(x.view,u),He(x),r.mouse("end",x)}function b(x,k){if(e.call(this,x,k)){var S=x.changedTouches,I=t.call(this,x,k),D=S.length,j,B;for(j=0;j<D;++j)(B=h(this,I,x,k,S[j].identifier,S[j]))&&(on(x),B("start",x,S[j]))}}function m(x){var k=x.changedTouches,S=k.length,I,D;for(I=0;I<S;++I)(D=r[k[I].identifier])&&(He(x),D("drag",x,k[I]))}function E(x){var k=x.changedTouches,S=k.length,I,D;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),I=0;I<S;++I)(D=r[k[I].identifier])&&(on(x),D("end",x,k[I]))}function h(x,k,S,I,D,j){var B=i.copy(),A=ue(j||S,k),$,R,_;if((_=n.call(x,new pn("beforestart",{sourceEvent:S,target:d,identifier:D,active:s,x:A[0],y:A[1],dx:0,dy:0,dispatch:B}),I))!=null)return $=_.x-A[0]||0,R=_.y-A[1]||0,function T(v,M,C){var N=A,z;switch(v){case"start":r[D]=T,z=s++;break;case"end":delete r[D],--s;case"drag":A=ue(C||M,k),z=s;break}B.call(v,x,new pn(v,{sourceEvent:M,subject:_,target:d,identifier:D,active:z,x:A[0]+$,y:A[1]+R,dx:A[0]-N[0],dy:A[1]-N[1],dispatch:B}),I)}}return d.filter=function(x){return arguments.length?(e=typeof x=="function"?x:wt(!!x),d):e},d.container=function(x){return arguments.length?(t=typeof x=="function"?x:wt(x),d):t},d.subject=function(x){return arguments.length?(n=typeof x=="function"?x:wt(x),d):n},d.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:wt(!!x),d):o},d.on=function(){var x=i.on.apply(i,arguments);return x===i?d:x},d.clickDistance=function(x){return arguments.length?(l=(x=+x)*x,d):Math.sqrt(l)},d}var Be=0,et=0,Ze=0,Cr=1e3,Tt,tt,$t=0,Ae=0,Ot=0,rt=typeof performance=="object"&&performance.now?performance:Date,Sr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Mn(){return Ae||(Sr(fl),Ae=rt.now()+Ot)}function fl(){Ae=0}function jt(){this._call=this._time=this._next=null}jt.prototype=Mr.prototype={constructor:jt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Mn():+n)+(t==null?0:+t),!this._next&&tt!==this&&(tt?tt._next=this:Tt=this,tt=this),this._call=e,this._time=n,mn()},stop:function(){this._call&&(this._call=null,this._time=1/0,mn())}};function Mr(e,t,n){var o=new jt;return o.restart(e,t,n),o}function hl(){Mn(),++Be;for(var e=Tt,t;e;)(t=Ae-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Be}function eo(){Ae=($t=rt.now())+Ot,Be=et=0;try{hl()}finally{Be=0,pl(),Ae=0}}function gl(){var e=rt.now(),t=e-$t;t>Cr&&(Ot-=t,$t=e)}function pl(){for(var e,t=Tt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Tt=n);tt=e,mn(o)}function mn(e){if(!Be){et&&(et=clearTimeout(et));var t=e-Ae;t>24?(e<1/0&&(et=setTimeout(eo,e-rt.now()-Ot)),Ze&&(Ze=clearInterval(Ze))):(Ze||($t=rt.now(),Ze=setInterval(gl,Cr)),Be=1,Sr(eo))}}function to(e,t,n){var o=new jt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var ml=Bt("start","end","cancel","interrupt"),yl=[],kr=0,no=1,yn=2,kt=3,oo=4,xn=5,It=6;function Ft(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;xl(e,n,{name:t,index:o,group:r,on:ml,tween:yl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:kr})}function kn(e,t){var n=he(e,t);if(n.state>kr)throw new Error("too late; already scheduled");return n}function pe(e,t){var n=he(e,t);if(n.state>kt)throw new Error("too late; already running");return n}function he(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function xl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Mr(i,0,n.time);function i(u){n.state=no,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var f,l,d,p;if(n.state!==no)return c();for(f in o)if(p=o[f],p.name===n.name){if(p.state===kt)return to(s);p.state===oo?(p.state=It,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete o[f]):+f<t&&(p.state=It,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete o[f])}if(to(function(){n.state===kt&&(n.state=oo,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=yn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===yn){for(n.state=kt,r=new Array(d=n.tween.length),f=0,l=-1;f<d;++f)(p=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(r[++l]=p);r.length=l+1}}function a(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=xn,1),l=-1,d=r.length;++l<d;)r[l].call(e,f);n.state===xn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=It,n.timer.stop(),delete o[t];for(var u in o)return;delete e.__transition}}function At(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>yn&&o.state<xn,o.state=It,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function wl(e){return this.each(function(){At(this,e)})}function bl(e,t){var n,o;return function(){var r=pe(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function vl(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=pe(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,u=r.length;c<u;++c)if(r[c].name===t){r[c]=a;break}c===u&&r.push(a)}i.tween=r}}function _l(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=he(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?bl:vl)(n,e,t))}function In(e,t,n){var o=e._id;return e.each(function(){var r=pe(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return he(r,o).value[t]}}function Ir(e,t){var n;return(typeof t=="number"?Me:t instanceof Gn?Kn:(n=Gn(t))?(t=n,Kn):ga)(e,t)}function Nl(e){return function(){this.removeAttribute(e)}}function El(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Cl(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Sl(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Ml(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function kl(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Il(e,t){var n=Vt(e),o=n==="transform"?va:Ir;return this.attrTween(e,typeof t=="function"?(n.local?kl:Ml)(n,o,In(this,"attr."+e,t)):t==null?(n.local?El:Nl)(n):(n.local?Sl:Cl)(n,o,t))}function Al(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Pl(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Tl(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Pl(e,i)),n}return r._value=t,r}function $l(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Al(e,i)),n}return r._value=t,r}function jl(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Vt(e);return this.tween(n,(o.local?Tl:$l)(o,t))}function zl(e,t){return function(){kn(this,e).delay=+t.apply(this,arguments)}}function Dl(e,t){return t=+t,function(){kn(this,e).delay=t}}function Ll(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?zl:Dl)(t,e)):he(this.node(),t).delay}function Hl(e,t){return function(){pe(this,e).duration=+t.apply(this,arguments)}}function Rl(e,t){return t=+t,function(){pe(this,e).duration=t}}function Bl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hl:Rl)(t,e)):he(this.node(),t).duration}function Vl(e,t){if(typeof t!="function")throw new Error;return function(){pe(this,e).ease=t}}function Ol(e){var t=this._id;return arguments.length?this.each(Vl(t,e)):he(this.node(),t).ease}function Fl(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;pe(this,e).ease=n}}function Yl(e){if(typeof e!="function")throw new Error;return this.each(Fl(this._id,e))}function Xl(e){typeof e!="function"&&(e=fr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new be(o,this._parents,this._name,this._id)}function Wl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var c=t[a],u=n[a],f=c.length,l=s[a]=new Array(f),d,p=0;p<f;++p)(d=c[p]||u[p])&&(l[p]=d);for(;a<o;++a)s[a]=t[a];return new be(s,this._parents,this._name,this._id)}function ql(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Gl(e,t,n){var o,r,i=ql(t)?kn:pe;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Kl(e,t){var n=this._id;return arguments.length<2?he(this.node(),n).on.on(e):this.each(Gl(n,e,t))}function Ul(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Zl(){return this.on("end.remove",Ul(this._id))}function Ql(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Cn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,u=i[s]=new Array(c),f,l,d=0;d<c;++d)(f=a[d])&&(l=e.call(f,f.__data__,d,a))&&("__data__"in f&&(l.__data__=f.__data__),u[d]=l,Ft(u[d],t,n,d,u,he(f,n)));return new be(i,this._parents,t,n)}function Jl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=dr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],u=c.length,f,l=0;l<u;++l)if(f=c[l]){for(var d=e.call(f,f.__data__,l,c),p,g=he(f,n),w=0,b=d.length;w<b;++w)(p=d[w])&&Ft(p,t,n,w,d,g);i.push(d),s.push(f)}return new be(i,s,t,n)}var eu=ut.prototype.constructor;function tu(){return new eu(this._groups,this._parents)}function nu(e,t){var n,o,r;return function(){var i=Re(this,e),s=(this.style.removeProperty(e),Re(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Ar(e){return function(){this.style.removeProperty(e)}}function ou(e,t,n){var o,r=n+"",i;return function(){var s=Re(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function ru(e,t,n){var o,r,i;return function(){var s=Re(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),Re(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function iu(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=pe(this,e),u=c.on,f=c.value[i]==null?a||(a=Ar(t)):void 0;(u!==n||r!==f)&&(o=(n=u).copy()).on(s,r=f),c.on=o}}function su(e,t,n){var o=(e+="")=="transform"?ba:Ir;return t==null?this.styleTween(e,nu(e,o)).on("end.style."+e,Ar(e)):typeof t=="function"?this.styleTween(e,ru(e,o,In(this,"style."+e,t))).each(iu(this._id,e)):this.styleTween(e,ou(e,o,t),n).on("end.style."+e,null)}function au(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function cu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&au(e,s,n)),o}return i._value=t,i}function lu(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,cu(e,t,n??""))}function uu(e){return function(){this.textContent=e}}function du(e){return function(){var t=e(this);this.textContent=t??""}}function fu(e){return this.tween("text",typeof e=="function"?du(In(this,"text",e)):uu(e==null?"":e+""))}function hu(e){return function(t){this.textContent=e.call(this,t)}}function gu(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&hu(r)),t}return o._value=e,o}function pu(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,gu(e))}function mu(){for(var e=this._name,t=this._id,n=Pr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,u=0;u<a;++u)if(c=s[u]){var f=he(c,t);Ft(c,e,n,u,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new be(o,this._parents,e,n)}function yu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var u=pe(this,o),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),u.on=t}),r===0&&i()})}var xu=0;function be(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Pr(){return++xu}var ye=ut.prototype;be.prototype={constructor:be,select:Ql,selectAll:Jl,selectChild:ye.selectChild,selectChildren:ye.selectChildren,filter:Xl,merge:Wl,selection:tu,transition:mu,call:ye.call,nodes:ye.nodes,node:ye.node,size:ye.size,empty:ye.empty,each:ye.each,on:Kl,attr:Il,attrTween:jl,style:su,styleTween:lu,text:fu,textTween:pu,remove:Zl,tween:_l,delay:Ll,duration:Bl,ease:Ol,easeVarying:Yl,end:yu,[Symbol.iterator]:ye[Symbol.iterator]};function wu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var bu={time:null,delay:0,duration:250,ease:wu};function vu(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function _u(e){var t,n;e instanceof be?(t=e._id,e=e._name):(t=Pr(),(n=bu).time=Mn(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,u=0;u<a;++u)(c=s[u])&&Ft(c,e,t,u,s,n||vu(c,t));return new be(o,this._parents,e,t)}ut.prototype.interrupt=wl;ut.prototype.transition=_u;const bt=e=>()=>e;function Nu(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){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:o,enumerable:!0,configurable:!0},_:{value:r}})}function xe(e,t,n){this.k=e,this.x=t,this.y=n}xe.prototype={constructor:xe,scale:function(e){return e===1?this:new xe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new xe(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 Yt=new xe(1,0,0);Tr.prototype=xe.prototype;function Tr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Yt;return e.__zoom}function rn(e){e.stopImmediatePropagation()}function Qe(e){e.preventDefault(),e.stopImmediatePropagation()}function Eu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Cu(){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 ro(){return this.__zoom||Yt}function Su(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Mu(){return navigator.maxTouchPoints||"ontouchstart"in this}function ku(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=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(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function $r(){var e=Eu,t=Cu,n=ku,o=Su,r=Mu,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=St,u=Bt("start","zoom","end"),f,l,d,p=500,g=150,w=0,b=10;function m(_){_.property("__zoom",ro).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",j).on("dblclick.zoom",B).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(_,T,v,M){var C=_.selection?_.selection():_;C.property("__zoom",ro),_!==C?k(_,T,v,M):C.interrupt().each(function(){S(this,arguments).event(M).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},m.scaleBy=function(_,T,v,M){m.scaleTo(_,function(){var C=this.__zoom.k,N=typeof T=="function"?T.apply(this,arguments):T;return C*N},v,M)},m.scaleTo=function(_,T,v,M){m.transform(_,function(){var C=t.apply(this,arguments),N=this.__zoom,z=v==null?x(C):typeof v=="function"?v.apply(this,arguments):v,H=N.invert(z),L=typeof T=="function"?T.apply(this,arguments):T;return n(h(E(N,L),z,H),C,s)},v,M)},m.translateBy=function(_,T,v,M){m.transform(_,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof v=="function"?v.apply(this,arguments):v),t.apply(this,arguments),s)},null,M)},m.translateTo=function(_,T,v,M,C){m.transform(_,function(){var N=t.apply(this,arguments),z=this.__zoom,H=M==null?x(N):typeof M=="function"?M.apply(this,arguments):M;return n(Yt.translate(H[0],H[1]).scale(z.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof v=="function"?-v.apply(this,arguments):-v),N,s)},M,C)};function E(_,T){return T=Math.max(i[0],Math.min(i[1],T)),T===_.k?_:new xe(T,_.x,_.y)}function h(_,T,v){var M=T[0]-v[0]*_.k,C=T[1]-v[1]*_.k;return M===_.x&&C===_.y?_:new xe(_.k,M,C)}function x(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function k(_,T,v,M){_.on("start.zoom",function(){S(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(M).end()}).tween("zoom",function(){var C=this,N=arguments,z=S(C,N).event(M),H=t.apply(C,N),L=v==null?x(H):typeof v=="function"?v.apply(C,N):v,V=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),F=C.__zoom,X=typeof T=="function"?T.apply(C,N):T,W=c(F.invert(L).concat(V/F.k),X.invert(L).concat(V/X.k));return function(q){if(q===1)q=X;else{var O=W(q),G=V/O[2];q=new xe(G,L[0]-O[0]*G,L[1]-O[1]*G)}z.zoom(null,q)}})}function S(_,T,v){return!v&&_.__zooming||new I(_,T)}function I(_,T){this.that=_,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,T),this.taps=0}I.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,T){return this.mouse&&_!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var T=ae(this.that).datum();u.call(_,this.that,new Nu(_,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:u}),T)}};function D(_,...T){if(!e.apply(this,arguments))return;var v=S(this,T).event(_),M=this.__zoom,C=Math.max(i[0],Math.min(i[1],M.k*Math.pow(2,o.apply(this,arguments)))),N=ue(_);if(v.wheel)(v.mouse[0][0]!==N[0]||v.mouse[0][1]!==N[1])&&(v.mouse[1]=M.invert(v.mouse[0]=N)),clearTimeout(v.wheel);else{if(M.k===C)return;v.mouse=[N,M.invert(N)],At(this),v.start()}Qe(_),v.wheel=setTimeout(z,g),v.zoom("mouse",n(h(E(M,C),v.mouse[0],v.mouse[1]),v.extent,s));function z(){v.wheel=null,v.end()}}function j(_,...T){if(d||!e.apply(this,arguments))return;var v=_.currentTarget,M=S(this,T,!0).event(_),C=ae(_.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",V,!0),N=ue(_,v),z=_.clientX,H=_.clientY;_r(_.view),rn(_),M.mouse=[N,this.__zoom.invert(N)],At(this),M.start();function L(F){if(Qe(F),!M.moved){var X=F.clientX-z,W=F.clientY-H;M.moved=X*X+W*W>w}
36M.event(F).zoom("mouse",n(h(M.that.__zoom,M.mouse[0]=ue(F,v),M.mouse[1]),M.extent,s))}function V(F){C.on("mousemove.zoom mouseup.zoom",null),Nr(F.view,M.moved),Qe(F),M.event(F).end()}}function B(_,...T){if(e.apply(this,arguments)){var v=this.__zoom,M=ue(_.changedTouches?_.changedTouches[0]:_,this),C=v.invert(M),N=v.k*(_.shiftKey?.5:2),z=n(h(E(v,N),M,C),t.apply(this,T),s);Qe(_),a>0?ae(this).transition().duration(a).call(k,z,M,_):ae(this).call(m.transform,z,M,_)}}function A(_,...T){if(e.apply(this,arguments)){var v=_.touches,M=v.length,C=S(this,T,_.changedTouches.length===M).event(_),N,z,H,L;for(rn(_),z=0;z<M;++z)H=v[z],L=ue(H,this),L=[L,this.__zoom.invert(L),H.identifier],C.touch0?!C.touch1&&C.touch0[2]!==L[2]&&(C.touch1=L,C.taps=0):(C.touch0=L,N=!0,C.taps=1+!!f);f&&(f=clearTimeout(f)),N&&(C.taps<2&&(l=L[0],f=setTimeout(function(){f=null},p)),At(this),C.start())}}function $(_,...T){if(this.__zooming){var v=S(this,T).event(_),M=_.changedTouches,C=M.length,N,z,H,L;for(Qe(_),N=0;N<C;++N)z=M[N],H=ue(z,this),v.touch0&&v.touch0[2]===z.identifier?v.touch0[0]=H:v.touch1&&v.touch1[2]===z.identifier&&(v.touch1[0]=H);if(z=v.that.__zoom,v.touch1){var V=v.touch0[0],F=v.touch0[1],X=v.touch1[0],W=v.touch1[1],q=(q=X[0]-V[0])*q+(q=X[1]-V[1])*q,O=(O=W[0]-F[0])*O+(O=W[1]-F[1])*O;z=E(z,Math.sqrt(q/O)),H=[(V[0]+X[0])/2,(V[1]+X[1])/2],L=[(F[0]+W[0])/2,(F[1]+W[1])/2]}else if(v.touch0)H=v.touch0[0],L=v.touch0[1];else return;v.zoom("touch",n(h(z,H,L),v.extent,s))}}function R(_,...T){if(this.__zooming){var v=S(this,T).event(_),M=_.changedTouches,C=M.length,N,z;for(rn(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),N=0;N<C;++N)z=M[N],v.touch0&&v.touch0[2]===z.identifier?delete v.touch0:v.touch1&&v.touch1[2]===z.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&(z=ue(z,this),Math.hypot(l[0]-z[0],l[1]-z[1])<b)){var H=ae(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return m.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:bt(+_),m):o},m.filter=function(_){return arguments.length?(e=typeof _=="function"?_:bt(!!_),m):e},m.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:bt(!!_),m):r},m.extent=function(_){return arguments.length?(t=typeof _=="function"?_:bt([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),m):t},m.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],m):[i[0],i[1]]},m.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(_){return arguments.length?(n=_,m):n},m.duration=function(_){return arguments.length?(a=+_,m):a},m.interpolate=function(_){return arguments.length?(c=_,m):c},m.on=function(){var _=u.on.apply(u,arguments);return _===u?m:_},m.clickDistance=function(_){return arguments.length?(w=(_=+_)*_,m):Math.sqrt(w)},m.tapDistance=function(_){return arguments.length?(b=+_,m):b},m}const ge={error001:()=>"[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:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", 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."},it=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],jr=["Enter"," ","Escape"],zr={"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 Ve;(function(e){e.Strict="strict",e.Loose="loose"})(Ve||(Ve={}));var Ie;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ie||(Ie={}));var st;(function(e){e.Partial="partial",e.Full="full"})(st||(st={}));const Dr={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 zt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(zt||(zt={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const io={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function Lr(e){return e===null?null:e?"valid":"invalid"}const Hr=e=>"id"in e&&"source"in e&&"target"in e,Iu=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),An=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),dt=(e,t=[0,0])=>{const{width:n,height:o}=ve(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Au=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):An(r)?r:t.nodeLookup.get(r.id));const a=s?Dt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Xt(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Wt(n)},ft=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=Xt(n,Dt(r)),o=!0)}),o?Wt(n):{x:0,y:0,width:0,height:0}}
36,Pn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...gt(t,[n,o,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:f,selectable:l=!0,hidden:d=!1}=u;if(s&&!l||d)continue;const p=f.width??u.width??u.initialWidth??null,g=f.height??u.height??u.initialHeight??null,w=at(a,Fe(u)),b=(p??0)*(g??0),m=i&&w>0;(!u.internals.handleBounds||m||w>=b||u.dragging)&&c.push(u)}return c},Pu=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function Tu(e,t){const n=new Map,o=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function $u({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=Tu(e,s),c=ft(a),u=Tn(c,t,n,(s==null?void 0:s.minZoom)??r,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await o.setViewport(u,{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 Rr({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},f=s.origin??o;let l=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",ge.error005());else{const p=a.measured.width,g=a.measured.height;p&&g&&(l=[[c,u],[c+p,u+g]])}else a&&Ye(s.extent)&&(l=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const d=Ye(l)?Pe(t,l,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",ge.error015())),{position:{x:d.x-c+(s.measured.width??0)*f[0],y:d.y-u+(s.measured.height??0)*f[1]},positionAbsolute:d}}async function ju({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const p=i.has(d.id),g=!p&&d.parentId&&s.find(w=>w.id===d.parentId);(p||g)&&s.push(d)}const a=new Set(t.map(d=>d.id)),c=o.filter(d=>d.deletable!==!1),f=Pu(s,c);for(const d of c)a.has(d.id)&&!f.find(g=>g.id===d.id)&&f.push(d);if(!r)return{edges:f,nodes:s};const l=await r({nodes:s,edges:f});return typeof l=="boolean"?l?{edges:f,nodes:s}:{edges:[],nodes:[]}:l}const Oe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Pe=(e={x:0,y:0},t,n)=>({x:Oe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Oe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Br(e,t,n){const{width:o,height:r}=ve(n),{x:i,y:s}=n.internals.positionAbsolute;return Pe(e,[[i,s],[i+o,s+r]],t)}const so=(e,t,n)=>e<t?Oe(Math.abs(e-t),1,t)/t:e>n?-Oe(Math.abs(e-n),1,t)/t:0,Vr=(e,t,n=15,o=40)=>{const r=so(e.x,o,t.width-o)*n,i=so(e.y,o,t.height-o)*n;return[r,i]},Xt=(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)}),wn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Wt=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Fe=(e,t=[0,0])=>{var r,i;const{x:n,y:o}=An(e)?e.internals.positionAbsolute:dt(e,t);return{x:n,y:o,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Dt=(e,t=[0,0])=>{var r,i;const{x:n,y:o}=An(e)?e.internals.positionAbsolute:dt(e,t);return{x:n,y:o,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:o+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Or=(e,t)=>Wt(Xt(wn(e),wn(t))),at=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},ao=e=>de(e.width)&&de(e.height)&&de(e.x)&&de(e.y),de=e=>!isNaN(e)&&isFinite(e),zu=(e,t)=>{},ht=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),gt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?ht(a,s):a},Lt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function ze(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);
36if(!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 Du(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=ze(e,n),r=ze(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=ze(e.top??e.y??0,n),r=ze(e.bottom??e.y??0,n),i=ze(e.left??e.x??0,t),s=ze(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Lu(e,t,n,o,r,i){const{x:s,y:a}=Lt(e,[t,n,o]),{x:c,y:u}=Lt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=r-c,l=i-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(l)}}const Tn=(e,t,n,o,r,i)=>{const s=Du(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),f=Oe(u,o,r),l=e.x+e.width/2,d=e.y+e.height/2,p=t/2-l*f,g=n/2-d*f,w=Lu(e,p,g,f,t,n),b={left:Math.min(w.left-s.left,0),top:Math.min(w.top-s.top,0),right:Math.min(w.right-s.right,0),bottom:Math.min(w.bottom-s.bottom,0)};return{x:p-b.left+b.right,y:g-b.top+b.bottom,zoom:f}},ct=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ye(e){return e!=null&&e!=="parent"}function ve(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 Fr(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 Yr(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;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 co(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Hu(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Ru(e){return{...zr,...e||{}}}function nt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=fe(e),a=gt({x:i-((r==null?void 0:r.left)??0),y:s-((r==null?void 0:r.top)??0)},o),{x:c,y:u}=n?ht(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const $n=e=>({width:e.offsetWidth,height:e.offsetHeight}),Xr=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Bu=["INPUT","SELECT","TEXTAREA"];function Wr(e){var o,r;const t=((r=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Bu.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".
36nokey")}const qr=e=>"clientX"in e,fe=(e,t)=>{var i,s;const n=qr(e),o=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,r=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},lo=(e,t,n,o,r)=>{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:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...$n(s)}})};function Gr({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,u=t*.125+i*.375+a*.375+o*.125,f=Math.abs(c-e),l=Math.abs(u-t);return[c,u,f,l]}function vt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function uo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case Y.Left:return[t-vt(t-o,i),n];case Y.Right:return[t+vt(o-t,i),n];case Y.Top:return[t,n-vt(n-r,i)];case Y.Bottom:return[t,n+vt(r-n,i)]}}function Kr({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:i=Y.Top,curvature:s=.25}){const[a,c]=uo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[u,f]=uo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[l,d,p,g]=Gr({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${a},${c} ${u},${f} ${o},${r}`,l,d,p,g]}function Ur({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function Vu({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function Ou({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=Xt(Dt(e),Dt(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return at(s,Wt(i))>0}const Fu=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Yu=(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)),Zr=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||Fu;let r;return Hr(e)?r={...e}:r={...e,id:o(e)},Yu(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Qr({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Ur({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const fo={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},Xu=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},ho=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Wu({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:o=Y.Top,center:r,offset:i,stepPosition:s}){const a=fo[t],c=fo[o],u={x:e.x+a.x*i,y:e.y+a.y*i},f={x:n.x+c.x*i,y:n.y+c.y*i},l=Xu({source:u,sourcePosition:t,target:f}),d=l.x!==0?"x":"y",p=l[d];let g=[],w,b;const m={x:0,y:0},E={x:0,y:0},[,,h,x]=Ur({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*c[d]===-1){d==="x"?(w=r.x??u.x+(f.x-u.x)*s,b=r.y??(u.y+f.y)/2):(w=r.x??(u.x+f.x)/2,b=r.y??u.y+(f.y-u.y)*s);const S=[{x:w,y:u.y},{x:w,y:f.y}],I=[{x:u.x,y:b},{x:f.x,y:b}];a[d]===p?g=d==="x"?S:I:g=d==="x"?I:S}else{const S=[{x:u.x,y:f.y}],I=[{x:f.x,y:u.y}];if(d==="x"?g=a.x===p?I:S:g=a.y===p?S:I,t===o){const $=Math.abs(e[d]-n[d]);if($<=i){const R=Math.min(i-1,i-$);a[d]===p?m[d]=(u[d]>e[d]?-1:1)*R:E[d]=(f[d]>n[d]?-1:1)*R}}if(t!==o){const $=d==="x"?"y":"x",R=a[d]===c[$],_=u[$]>f[$],T=u[$]<f[$];(a[d]===1&&(!R&&_||R&&T)||a[d]!==1&&(!R&&T||R&&_))&&(g=d==="x"?S:I)}const D={x:u.x+m.x,y:u.y+m.y},j={x:f.x+E.x,y:f.y+E.y},B=Math.max(Math.abs(D.x-g[0].x),Math.abs(j.x-g[0].x)),A=Math.max(Math.abs(D.y-g[0].y),Math.abs(j.y-g[0].y));B>=A?(w=(D.x+j.x)/2,b=g[0].y):(w=g[0].x,b=(D.y+j.y)/2)}return[[e,{x:u.x+m.x,y:u.y+m.y},...g,{x:f.x+E.x,y:f.y+E.y},n],w,b,h,x]}function qu(e,t,n,o){const r=Math.min(ho(e,t)/2,ho(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+r*u},${s}Q ${i},${s} ${i},${s+r*f}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}
36Q ${i},${s} ${i+r*a},${s}`}function Ht({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:i=Y.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:f=.5}){const[l,d,p,g,w]=Wu({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:u,stepPosition:f});return[l.reduce((m,E,h)=>{let x="";return h>0&&h<l.length-1?x=qu(l[h-1],E,l[h+1],s):x=`${h===0?"M":"L"}${E.x} ${E.y}`,m+=x,m},""),d,p,g,w]}function go(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Gu(e){var l;const{sourceNode:t,targetNode:n}=e;if(!go(t)||!go(n))return null;const o=t.internals.handleBounds||po(t.handles),r=n.internals.handleBounds||po(n.handles),i=mo((o==null?void 0:o.source)??[],e.sourceHandle),s=mo(e.connectionMode===Ve.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!i||!s)return(l=e.onError)==null||l.call(e,"008",ge.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||Y.Bottom,c=(s==null?void 0:s.position)||Y.Top,u=Te(t,i,a),f=Te(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:c}}function po(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Te(e,t,n=Y.Left,o=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??ve(e);if(o)return{x:r+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case Y.Top:return{x:r+s/2,y:i};case Y.Right:return{x:r+s,y:i+a/2};case Y.Bottom:return{x:r+s/2,y:i+a};case Y.Left:return{x:r,y:i+a/2}}}function mo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function bn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Ku(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=bn(c,t);i.has(u)||(s.push({id:u,color:c.color||n,...c}),i.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Jr=1e3,Uu=10,jn={nodeOrigin:[0,0],nodeExtent:it,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Zu={...jn,checkEquality:!0};function zn(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Qu(e,t,n){const o=zn(jn,n);for(const r of e.values())if(r.parentId)Ln(r,e,t,o);else{const i=dt(r,o.nodeOrigin),s=Ye(r.extent)?r.extent:o.nodeExtent,a=Pe(i,s,ve(r));r.internals.positionAbsolute=a}}function Ju(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function Dn(e){return e==="manual"}function vn(e,t,n,o={}){var u,f;const r=zn(Zu,o),i={i:0},s=new Map(t),a=r!=null&&r.elevateNodesOnSelect&&!Dn(r.zIndexMode)?Jr:0;let c=e.length>0;t.clear(),n.clear();for(const l of e){let d=s.get(l.id);if(r.checkEquality&&l===(d==null?void 0:d.internals.userNode))t.set(l.id,d);else{const p=dt(l,r.nodeOrigin),g=Ye(l.extent)?l.extent:r.nodeExtent,w=Pe(p,g,ve(l));d={...r.defaults,...l,measured:{width:(u=l.measured)==null?void 0:u.width,height:(f=l.measured)==null?void 0:f.height},internals:{positionAbsolute:w,handleBounds:Ju(l,d),z:ei(l,a,r.zIndexMode),userNode:l}},t.set(l.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),l.parentId&&Ln(d,t,n,o,i)}return c}function ed(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 Ln(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=zn(jn,o),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}ed(e,n),r&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++r.i,f.internals.z=f.internals.z+r.i*Uu),r&&f.internals.rootParentIndex!==void 0&&(r.i=f.internals.rootParentIndex);const l=i&&!Dn(c)?Jr:0,{x:d,y:p,z:g}=td(e,f,s,a,l,c),{positionAbsolute:w}=e.internals,b=d!==w.x||p!==w.y;(b||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:d,y:p}:w,z:g}})}
36function ei(e,t,n){const o=de(e.zIndex)?e.zIndex:0;return Dn(n)?o:o+(e.selected?t:0)}function td(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=ve(e),u=dt(e,n),f=Ye(e.extent)?Pe(u,e.extent,c):u;let l=Pe({x:s+f.x,y:a+f.y},o,c);e.extent==="parent"&&(l=Br(l,c,t));const d=ei(e,r,i),p=t.internals.z??0;return{x:l.x,y:l.y,z:p>=d?p+1:d}}function Hn(e,t,n,o=[0,0]){var s;const r=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Fe(c),f=Or(u,a.rect);i.set(a.parentId,{expandedRect:f,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},u)=>{var h;const f=c.internals.positionAbsolute,l=ve(c),d=c.origin??o,p=a.x<f.x?Math.round(Math.abs(f.x-a.x)):0,g=a.y<f.y?Math.round(Math.abs(f.y-a.y)):0,w=Math.max(l.width,Math.round(a.width)),b=Math.max(l.height,Math.round(a.height)),m=(w-l.width)*d[0],E=(b-l.height)*d[1];(p>0||g>0||m||E)&&(r.push({id:u,type:"position",position:{x:c.position.x-p+m,y:c.position.y-g+E}}),(h=n.get(u))==null||h.forEach(x=>{e.some(k=>k.id===x.id)||r.push({id:x.id,type:"position",position:{x:x.position.x+p,y:x.position.y+g}})})),(l.width<a.width||l.height<a.height||p||g)&&r.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:w+(p?d[0]*p-m:0),height:b+(g?d[1]*g-E:0)}})}),r}function nd(e,t,n,o,r,i,s){const a=o==null?void 0:o.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const u=[],f=window.getComputedStyle(a),{m22:l}=new window.DOMMatrixReadOnly(f.transform),d=[];for(const p of e.values()){const g=t.get(p.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const w=$n(p.nodeElement),b=g.measured.width!==w.width||g.measured.height!==w.height;if(!!(w.width&&w.height&&(b||!g.internals.handleBounds||p.force))){const E=p.nodeElement.getBoundingClientRect(),h=Ye(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;g.parentId&&g.extent==="parent"?x=Br(x,w,t.get(g.parentId)):h&&(x=Pe(x,h,w));const k={...g,measured:w,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:lo("source",p.nodeElement,E,l,g.id),target:lo("target",p.nodeElement,E,l,g.id)}}};t.set(g.id,k),g.parentId&&Ln(k,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,b&&(u.push({id:g.id,type:"dimensions",dimensions:w}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Fe(k,r)}))}}if(d.length>0){const p=Hn(d,t,n,r);u.push(...p)}return{changes:u,updatedInternals:c}}async function od({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,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],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function yo(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const u=o.get(s)||new Map;o.set(s,u.set(n,t))}}function ti(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},u=`${r}-${s}--${i}-${a}`,f=`${i}-${a}--${r}-${s}`;yo("source",c,f,e,r,s),yo("target",c,u,e,i,a),t.set(o.id,o)}}function ni(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ni(n,t):!1}function xo(e,t,n){var r;let o=e;do{if((r=o==null?void 0:o.matches)!=null&&r.call(o,t))return!0;if(o===n)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function rd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!ni(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.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 r}function sn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){var s,a,c;const r=[];for(const[u,f]of t){const l=(s=n.get(u))==null?void 0:s.internals.userNode;l&&r.push({...l,position:f.position,dragging:o})}if(!e)return[r[0],r];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:o}:r[0],r]}function id({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=ht(i,t);return{x:s.x-i.x,y:s.y-i.y}}function sd({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},f=null,l=!1,d=null,p=!1,g=!1,w=null;function b({noDragClassName:E,handleSelector:h,domNode:x,isSelectable:k,nodeId:S,nodeClickDistance:I=0}){d=ae(x);function D({x:$,y:R}
36){const{nodeLookup:_,nodeExtent:T,snapGrid:v,snapToGrid:M,nodeOrigin:C,onNodeDrag:N,onSelectionDrag:z,onError:H,updateNodePositions:L}=t();i={x:$,y:R};let V=!1;const F=a.size>1,X=F&&T?wn(ft(a)):null,W=F&&M?id({dragItems:a,snapGrid:v,x:$,y:R}):null;for(const[q,O]of a){if(!_.has(q))continue;let G={x:$-O.distance.x,y:R-O.distance.y};M&&(G=W?{x:Math.round(G.x+W.x),y:Math.round(G.y+W.y)}:ht(G,v));let Q=null;if(F&&T&&!O.extent&&X){const{positionAbsolute:K}=O.internals,te=K.x-X.x+T[0][0],ne=K.x+O.measured.width-X.x2+T[1][0],ee=K.y-X.y+T[0][1],se=K.y+O.measured.height-X.y2+T[1][1];Q=[[te,ee],[ne,se]]}const{position:Z,positionAbsolute:U}=Rr({nodeId:q,nextPosition:G,nodeLookup:_,nodeExtent:Q||T,nodeOrigin:C,onError:H});V=V||O.position.x!==Z.x||O.position.y!==Z.y,O.position=Z,O.internals.positionAbsolute=U}if(g=g||V,!!V&&(L(a,!0),w&&(o||N||!S&&z))){const[q,O]=sn({nodeId:S,dragItems:a,nodeLookup:_});o==null||o(w,a,q,O),N==null||N(w,q,O),S||z==null||z(w,O)}}async function j(){if(!f)return;const{transform:$,panBy:R,autoPanSpeed:_,autoPanOnNodeDrag:T}=t();if(!T){c=!1,cancelAnimationFrame(s);return}const[v,M]=Vr(u,f,_);(v!==0||M!==0)&&(i.x=(i.x??0)-v/$[2],i.y=(i.y??0)-M/$[2],await R({x:v,y:M})&&D(i)),s=requestAnimationFrame(j)}function B($){var F;const{nodeLookup:R,multiSelectionActive:_,nodesDraggable:T,transform:v,snapGrid:M,snapToGrid:C,selectNodesOnDrag:N,onNodeDragStart:z,onSelectionDragStart:H,unselectNodesAndEdges:L}=t();l=!0,(!N||!k)&&!_&&S&&((F=R.get(S))!=null&&F.selected||L()),k&&N&&S&&(e==null||e(S));const V=nt($.sourceEvent,{transform:v,snapGrid:M,snapToGrid:C,containerBounds:f});if(i=V,a=rd(R,T,V,S),a.size>0&&(n||z||!S&&H)){const[X,W]=sn({nodeId:S,dragItems:a,nodeLookup:R});n==null||n($.sourceEvent,a,X,W),z==null||z($.sourceEvent,X,W),S||H==null||H($.sourceEvent,W)}}const A=Er().clickDistance(I).on("start",$=>{const{domNode:R,nodeDragThreshold:_,transform:T,snapGrid:v,snapToGrid:M}=t();f=(R==null?void 0:R.getBoundingClientRect())||null,p=!1,g=!1,w=$.sourceEvent,_===0&&B($),i=nt($.sourceEvent,{transform:T,snapGrid:v,snapToGrid:M,containerBounds:f}),u=fe($.sourceEvent,f)}).on("drag",$=>{const{autoPanOnNodeDrag:R,transform:_,snapGrid:T,snapToGrid:v,nodeDragThreshold:M,nodeLookup:C}=t(),N=nt($.sourceEvent,{transform:_,snapGrid:T,snapToGrid:v,containerBounds:f});if(w=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||S&&!C.has(S))&&(p=!0),!p){if(!c&&R&&l&&(c=!0,j()),!l){const z=fe($.sourceEvent,f),H=z.x-u.x,L=z.y-u.y;Math.sqrt(H*H+L*L)>M&&B($)}(i.x!==N.xSnapped||i.y!==N.ySnapped)&&a&&l&&(u=fe($.sourceEvent,f),D(N))}}).on("end",$=>{if(!(!l||p)&&(c=!1,l=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:R,updateNodePositions:_,onNodeDragStop:T,onSelectionDragStop:v}=t();if(g&&(_(a,!1),g=!1),r||T||!S&&v){const[M,C]=sn({nodeId:S,dragItems:a,nodeLookup:R,dragging:!1});r==null||r($.sourceEvent,a,M,C),T==null||T($.sourceEvent,M,C),S||v==null||v($.sourceEvent,C)}}}).filter($=>{const R=$.target;return!$.button&&(!E||!xo(R,`.${E}`,x))&&(!h||xo(R,h,x))});d.call(A)}function m(){d==null||d.on(".drag",null)}return{update:b,destroy:m}}function ad(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())at(r,Fe(i))>0&&o.push(i);return o}const cd=250;function ld(e,t,n,o){var a,c;let r=[],i=1/0;const s=ad(e,n,t+cd);for(const u of s){const f=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const l of f){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:d,y:p}=Te(u,l,l.position,!0),g=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(p-e.y,2));g>t||(g<i?(r=[{...l,x:d,y:p}],i=g):g===i&&r.push({...l,x:d,y:p}))}}if(!r.length)return null;if(r.length>1){const u=o.type==="source"?"target":"source";return r.find(f=>f.type===u)??r[0]}return r[0]}function oi(e,t,n,o,r,i=!1){var u,f,l;const s=o.get(e);if(!s)return null;const a=r==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((l=s.internals.handleBounds)==null?void 0:l.target)??[]],c=(n?a==null?void 0:a.find(d=>d.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...Te(s,c,c.position,!0)}:c}function ri(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"
36source":null)}function ud(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ii=()=>!0;function dd(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:f,flowId:l,panBy:d,cancelConnection:p,onConnectStart:g,onConnect:w,onConnectEnd:b,isValidConnection:m=ii,onReconnectEnd:E,updateConnection:h,getTransform:x,getFromHandle:k,autoPanSpeed:S,dragThreshold:I=1,handleDomNode:D}){const j=Xr(e.target);let B=0,A;const{x:$,y:R}=fe(e),_=ri(i,D),T=a==null?void 0:a.getBoundingClientRect();let v=!1;if(!T||!_)return;const M=oi(r,_,o,c,t);if(!M)return;let C=fe(e,T),N=!1,z=null,H=!1,L=null;function V(){if(!f||!T)return;const[Z,U]=Vr(C,T,S);d({x:Z,y:U}),B=requestAnimationFrame(V)}const F={...M,nodeId:r,type:_,position:M.position},X=c.get(r);let q={inProgress:!0,isValid:null,from:Te(X,F,Y.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:X,to:C,toHandle:null,toPosition:io[F.position],toNode:null,pointer:C};function O(){v=!0,h(q),g==null||g(e,{nodeId:r,handleId:o,handleType:_})}I===0&&O();function G(Z){if(!v){const{x:se,y:_e}=fe(Z),me=se-$,Se=_e-R;if(!(me*me+Se*Se>I*I))return;O()}if(!k()||!F){Q(Z);return}const U=x();C=fe(Z,T),A=ld(gt(C,U,!1,[1,1]),n,c,F),N||(V(),N=!0);const K=si(Z,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:j,lib:u,flowId:l,nodeLookup:c});L=K.handleDomNode,z=K.connection,H=ud(!!A,K.isValid);const te=c.get(r),ne=te?Te(te,F,Y.Left,!0):q.from,ee={...q,from:ne,isValid:H,to:K.toHandle&&H?Lt({x:K.toHandle.x,y:K.toHandle.y},U):C,toHandle:K.toHandle,toPosition:H&&K.toHandle?K.toHandle.position:io[F.position],toNode:K.toHandle?c.get(K.toHandle.nodeId):null,pointer:C};h(ee),q=ee}function Q(Z){if(!("touches"in Z&&Z.touches.length>0)){if(v){(A||L)&&z&&H&&(w==null||w(z));const{inProgress:U,...K}=q,te={...K,toPosition:q.toHandle?q.toPosition:null};b==null||b(Z,te),i&&(E==null||E(Z,te))}p(),cancelAnimationFrame(B),N=!1,H=!1,z=null,L=null,j.removeEventListener("mousemove",G),j.removeEventListener("mouseup",Q),j.removeEventListener("touchmove",G),j.removeEventListener("touchend",Q)}}j.addEventListener("mousemove",G),j.addEventListener("mouseup",Q),j.addEventListener("touchmove",G),j.addEventListener("touchend",Q)}function si(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:u=ii,nodeLookup:f}){const l=i==="target",d=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:p,y:g}=fe(e),w=s.elementFromPoint(p,g),b=w!=null&&w.classList.contains(`${a}-flow__handle`)?w:d,m={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const E=ri(void 0,b),h=b.getAttribute("data-nodeid"),x=b.getAttribute("data-handleid"),k=b.classList.contains("connectable"),S=b.classList.contains("connectableend");if(!h||!E)return m;const I={source:l?h:o,sourceHandle:l?x:r,target:l?o:h,targetHandle:l?r:x};m.connection=I;const j=k&&S&&(n===Ve.Strict?l&&E==="source"||!l&&E==="target":h!==o||x!==r);m.isValid=j&&u(I),m.toHandle=oi(h,E,x,f,n,!0)}return m}const _n={onPointerDown:dd,isValid:si};function fd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ae(e);function i({translateExtent:a,width:c,height:u,zoomStep:f=1,pannable:l=!0,zoomable:d=!0,inversePan:p=!1}){const g=h=>{if(h.sourceEvent.type!=="wheel"||!t)return;const x=n(),k=h.sourceEvent.ctrlKey&&ct()?10:1,S=-h.sourceEvent.deltaY*(h.sourceEvent.deltaMode===1?.05:h.sourceEvent.deltaMode?1:.002)*f,I=x[2]*Math.pow(2,S*k);t.scaleTo(I)};let w=[0,0];const b=h=>{(h.sourceEvent.type==="mousedown"||h.sourceEvent.type==="touchstart")&&(w=[h.sourceEvent.clientX??h.sourceEvent.touches[0].clientX,h.sourceEvent.clientY??h.sourceEvent.touches[0].clientY])},m=h=>{const x=n();if(h.sourceEvent.type!=="mousemove"&&h.sourceEvent.type!=="touchmove"||!t)return;const k=[h.sourceEvent.clientX??h.sourceEvent.touches[0].clientX,h.sourceEvent.clientY??h.sourceEvent.touches[0].clientY],S=[k[0]-w[0],k[1]-w[1]];w=k;const I=o()*Math.max(x[2],Math.log(x[2]))*(p?-1:1),D={x:x[0]-S[0]*I,y:x[1]-S[1]*I},j=[[0,0],[c,u]];t.setViewportConstrained({x:D.x,y:D.y,zoom:x[2]},j,a)},E=$r().on("start",b).on("zoom",l?m:null).on("zoom.wheel",d?g:null);r.call(E,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:ue}}const qt=e=>({x:e.x,y:e.y,zoom:e.k}),an=({x:e,y:t,zoom:n})=>Yt.translate(e,t).scale(n),De=(e,t)=>e.target.closest(`.${t}`),ai=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),hd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,cn=(e,t=0,n=hd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},ci=e=>{const t=e.ctrlKey&&ct()?10:1;
36return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function gd({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return f=>{if(De(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const l=n.property("__zoom").k||1;if(f.ctrlKey&&s){const b=ue(f),m=ci(f),E=l*Math.pow(2,m);o.scaleTo(n,E,b,f);return}const d=f.deltaMode===1?20:1;let p=r===Ie.Vertical?0:f.deltaX*d,g=r===Ie.Horizontal?0:f.deltaY*d;!ct()&&f.shiftKey&&r!==Ie.Vertical&&(p=f.deltaY*d,g=0),o.translateBy(n,-(p/l)*i,-(g/l)*i,{internal:!0});const w=qt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(f,w),e.panScrollTimeout=setTimeout(()=>{u==null||u(f,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(f,w))}}function pd({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=De(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function md({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{var i,s,a;if((i=o.sourceEvent)!=null&&i.internal)return;const r=qt(o.transform);e.mouseButton=((s=o.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((a=o.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(o.sourceEvent,r))}}function yd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&ai(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!((a=i.sourceEvent)!=null&&a.internal)&&(r==null||r(i.sourceEvent,qt(i.transform)))}}function xd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&ai(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const c=qt(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(s.sourceEvent,c)},n?150:0)}}}function wd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:u,connectionInProgress:f}){return l=>{var b;const d=e||t,p=n&&l.ctrlKey,g=l.type==="wheel";if(l.button===1&&l.type==="mousedown"&&(De(l,`${u}-flow__node`)||De(l,`${u}-flow__edge`)))return!0;if(!o&&!d&&!r&&!i&&!n||s||f&&!g||De(l,a)&&g||De(l,c)&&(!g||r&&g&&!e)||!n&&l.ctrlKey&&g)return!1;if(!n&&l.type==="touchstart"&&((b=l.touches)==null?void 0:b.length)>1)return l.preventDefault(),!1;if(!d&&!r&&!p&&g||!o&&(l.type==="mousedown"||l.type==="touchstart")||Array.isArray(o)&&!o.includes(l.button)&&l.type==="mousedown")return!1;const w=Array.isArray(o)&&o.includes(l.button)||!l.button||l.button<=1;return(!l.ctrlKey||g)&&w}}function bd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),l=$r().scaleExtent([t,n]).translateExtent(o),d=ae(e).call(l);E({x:r.x,y:r.y,zoom:Oe(r.zoom,t,n)},[[0,0],[f.width,f.height]],o);const p=d.on("wheel.zoom"),g=d.on("dblclick.zoom");l.wheelDelta(ci);function w(A,$){return d?new Promise(R=>{l==null||l.interpolate(($==null?void 0:$.interpolate)==="linear"?tn:St).transform(cn(d,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function b({noWheelClassName:A,noPanClassName:$,onPaneContextMenu:R,userSelectionActive:_,panOnScroll:T,panOnDrag:v,panOnScrollMode:M,panOnScrollSpeed:C,preventScrolling:N,zoomOnPinch:z,zoomOnScroll:H,zoomOnDoubleClick:L,zoomActivationKeyPressed:V,lib:F,onTransformChange:X,connectionInProgress:W,paneClickDistance:q,selectionOnDrag:O}){_&&!u.isZoomingOrPanning&&m();const G=T&&!V&&!_;l.clickDistance(O?1/0:!de(q)||q<0?0:q);const Q=G?gd({zoomPanValues:u,noWheelClassName:A,d3Selection:d,d3Zoom:l,panOnScrollMode:M,panOnScrollSpeed:C,zoomOnPinch:z,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):pd({noWheelClassName:A,preventScrolling:N,d3ZoomHandler:p});if(d.on("wheel.zoom",Q,{passive:!1}),!_){const U=md({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});
36l.on("start",U);const K=yd({zoomPanValues:u,panOnDrag:v,onPaneContextMenu:!!R,onPanZoom:i,onTransformChange:X});l.on("zoom",K);const te=xd({zoomPanValues:u,panOnDrag:v,panOnScroll:T,onPaneContextMenu:R,onPanZoomEnd:a,onDraggingChange:c});l.on("end",te)}const Z=wd({zoomActivationKeyPressed:V,panOnDrag:v,zoomOnScroll:H,panOnScroll:T,zoomOnDoubleClick:L,zoomOnPinch:z,userSelectionActive:_,noPanClassName:$,noWheelClassName:A,lib:F,connectionInProgress:W});l.filter(Z),L?d.on("dblclick.zoom",g):d.on("dblclick.zoom",null)}function m(){l.on("zoom",null)}async function E(A,$,R){const _=an(A),T=l==null?void 0:l.constrain()(_,$,R);return T&&await w(T),new Promise(v=>v(T))}async function h(A,$){const R=an(A);return await w(R,$),new Promise(_=>_(R))}function x(A){if(d){const $=an(A),R=d.property("__zoom");(R.k!==A.zoom||R.x!==A.x||R.y!==A.y)&&(l==null||l.transform(d,$,null,{sync:!0}))}}function k(){const A=d?Tr(d.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function S(A,$){return d?new Promise(R=>{l==null||l.interpolate(($==null?void 0:$.interpolate)==="linear"?tn:St).scaleTo(cn(d,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function I(A,$){return d?new Promise(R=>{l==null||l.interpolate(($==null?void 0:$.interpolate)==="linear"?tn:St).scaleBy(cn(d,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>R(!0)),A)}):Promise.resolve(!1)}function D(A){l==null||l.scaleExtent(A)}function j(A){l==null||l.translateExtent(A)}function B(A){const $=!de(A)||A<0?0:A;l==null||l.clickDistance($)}return{update:b,destroy:m,setViewport:h,setViewportConstrained:E,getViewport:k,scaleTo:S,scaleBy:I,setScaleExtent:D,setTranslateExtent:j,syncViewport:x,setClickDistance:B}}var Xe;(function(e){e.Line="line",e.Handle="handle"})(Xe||(Xe={}));function vd({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function wo(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Ne(e,t){return Math.max(0,t-e)}function Ee(e,t){return Math.max(0,e-t)}function _t(e,t,n){return Math.max(0,t-e,e-n)}function bo(e,t){return e?!t:t}function _d(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:f,isVertical:l}=t,d=f&&l,{xSnapped:p,ySnapped:g}=n,{minWidth:w,maxWidth:b,minHeight:m,maxHeight:E}=o,{x:h,y:x,width:k,height:S,aspectRatio:I}=e;let D=Math.floor(f?p-e.pointerX:0),j=Math.floor(l?g-e.pointerY:0);const B=k+(c?-D:D),A=S+(u?-j:j),$=-i[0]*k,R=-i[1]*S;let _=_t(B,w,b),T=_t(A,m,E);if(s){let C=0,N=0;c&&D<0?C=Ne(h+D+$,s[0][0]):!c&&D>0&&(C=Ee(h+B+$,s[1][0])),u&&j<0?N=Ne(x+j+R,s[0][1]):!u&&j>0&&(N=Ee(x+A+R,s[1][1])),_=Math.max(_,C),T=Math.max(T,N)}if(a){let C=0,N=0;c&&D>0?C=Ee(h+D,a[0][0]):!c&&D<0&&(C=Ne(h+B,a[1][0])),u&&j>0?N=Ee(x+j,a[0][1]):!u&&j<0&&(N=Ne(x+A,a[1][1])),_=Math.max(_,C),T=Math.max(T,N)}if(r){if(f){const C=_t(B/I,m,E)*I;if(_=Math.max(_,C),s){let N=0;!c&&!u||c&&!u&&d?N=Ee(x+R+B/I,s[1][1])*I:N=Ne(x+R+(c?D:-D)/I,s[0][1])*I,_=Math.max(_,N)}if(a){let N=0;!c&&!u||c&&!u&&d?N=Ne(x+B/I,a[1][1])*I:N=Ee(x+(c?D:-D)/I,a[0][1])*I,_=Math.max(_,N)}}if(l){const C=_t(A*I,w,b)/I;if(T=Math.max(T,C),s){let N=0;!c&&!u||u&&!c&&d?N=Ee(h+A*I+$,s[1][0])/I:N=Ne(h+(u?j:-j)*I+$,s[0][0])/I,T=Math.max(T,N)}if(a){let N=0;!c&&!u||u&&!c&&d?N=Ne(h+A*I,a[1][0])/I:N=Ee(h+(u?j:-j)*I,a[0][0])/I,T=Math.max(T,N)}}}j=j+(j<0?T:-T),D=D+(D<0?_:-_),r&&(d?B>A*I?j=(bo(c,u)?-D:D)/I:D=(bo(c,u)?-j:j)*I:f?(j=D/I,u=c):(D=j*I,c=u));const v=c?h+D:h,M=u?x+j:x;return{width:k+(c?-D:D),height:S+(u?-j:j),x:i[0]*D*(c?-1:1)+v,y:i[1]*j*(u?-1:1)+M}}const li={width:0,height:0,x:0,y:0},Nd={...li,pointerX:0,pointerY:0,aspectRatio:1};function Ed(e){return[[0,0],[e.measured.width,e.measured.height]]}function Cd(e,t,n){const o=t.position.x+e.position.x,r=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[[o-a,r-c],[o+i-a,r+s-c]]}function Sd({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ae(e);let s={controlDirection:wo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:f,keepAspectRatio:l,resizeDirection:d,onResizeStart:p,onResize:g,onResizeEnd:w,shouldResize:b}){let m={...li},E={...Nd};s={boundaries:f,resizeDirection:d,keepAspectRatio:l,controlDirection:wo(u)};let h,x=null,k=[],S,I,D,j=!1;const B=Er().on("start",A=>
36{const{nodeLookup:$,transform:R,snapGrid:_,snapToGrid:T,nodeOrigin:v,paneDomNode:M}=n();if(h=$.get(t),!h)return;x=(M==null?void 0:M.getBoundingClientRect())??null;const{xSnapped:C,ySnapped:N}=nt(A.sourceEvent,{transform:R,snapGrid:_,snapToGrid:T,containerBounds:x});m={width:h.measured.width??0,height:h.measured.height??0,x:h.position.x??0,y:h.position.y??0},E={...m,pointerX:C,pointerY:N,aspectRatio:m.width/m.height},S=void 0,h.parentId&&(h.extent==="parent"||h.expandParent)&&(S=$.get(h.parentId),I=S&&h.extent==="parent"?Ed(S):void 0),k=[],D=void 0;for(const[z,H]of $)if(H.parentId===t&&(k.push({id:z,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const L=Cd(H,h,H.origin??v);D?D=[[Math.min(L[0][0],D[0][0]),Math.min(L[0][1],D[0][1])],[Math.max(L[1][0],D[1][0]),Math.max(L[1][1],D[1][1])]]:D=L}p==null||p(A,{...m})}).on("drag",A=>{const{transform:$,snapGrid:R,snapToGrid:_,nodeOrigin:T}=n(),v=nt(A.sourceEvent,{transform:$,snapGrid:R,snapToGrid:_,containerBounds:x}),M=[];if(!h)return;const{x:C,y:N,width:z,height:H}=m,L={},V=h.origin??T,{width:F,height:X,x:W,y:q}=_d(E,s.controlDirection,v,s.boundaries,s.keepAspectRatio,V,I,D),O=F!==z,G=X!==H,Q=W!==C&&O,Z=q!==N&&G;if(!Q&&!Z&&!O&&!G)return;if((Q||Z||V[0]===1||V[1]===1)&&(L.x=Q?W:m.x,L.y=Z?q:m.y,m.x=L.x,m.y=L.y,k.length>0)){const ne=W-C,ee=q-N;for(const se of k)se.position={x:se.position.x-ne+V[0]*(F-z),y:se.position.y-ee+V[1]*(X-H)},M.push(se)}if((O||G)&&(L.width=O&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:m.width,L.height=G&&(!s.resizeDirection||s.resizeDirection==="vertical")?X:m.height,m.width=L.width,m.height=L.height),S&&h.expandParent){const ne=V[0]*(L.width??0);L.x&&L.x<ne&&(m.x=ne,E.x=E.x-(L.x-ne));const ee=V[1]*(L.height??0);L.y&&L.y<ee&&(m.y=ee,E.y=E.y-(L.y-ee))}const U=vd({width:m.width,prevWidth:z,height:m.height,prevHeight:H,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),K={...m,direction:U};(b==null?void 0:b(A,K))!==!1&&(j=!0,g==null||g(A,K),o(L,M))}).on("end",A=>{j&&(w==null||w(A,{...m}),r==null||r({...m}),j=!1)});i.call(B)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}const{useDebugValue:Md}=na,{useSyncExternalStoreWithSelector:kd}=ta,Id=e=>e;function ui(e,t=Id,n){const o=kd(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Md(o),o}const vo=(e,t)=>{const n=ea(e),o=(r,i=t)=>ui(n,r,i);return Object.assign(o,n),o},Ad=(e,t)=>e?vo(e,t):vo;function oe(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[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const Gt=P.createContext(null),Pd=Gt.Provider,di=ge.error001();function J(e,t){const n=P.useContext(Gt);if(n===null)throw new Error(di);return ui(n,e,t)}function re(){const e=P.useContext(Gt);if(e===null)throw new Error(di);return P.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const _o={display:"none"},Td={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},fi="react-flow__node-desc",hi="react-flow__edge-desc",$d="react-flow__aria-live",jd=e=>e.ariaLiveMessage,zd=e=>e.ariaLabelConfig;function Dd({rfId:e}){const t=J(jd);return y.jsx("div",{id:`${$d}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Td,children:t})}function Ld({rfId:e,disableKeyboardA11y:t}){const n=J(zd);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${fi}-${e}`,style:_o,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${hi}-${e}`,style:_o,children:n["edge.a11yDescription.default"]}),!t&&y.jsx(Dd,{rfId:e})]})}const Kt=P.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return y.jsx("div",{className:ie(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Kt.displayName="Panel";function Hd({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:y.jsx(Kt,{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:y.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Rd=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Nt=e=>e.id;function Bd(e,t){return oe(e.selectedNodes.map(Nt),t.selectedNodes.map(Nt))&&oe(e.selectedEdges.map(Nt),t.selectedEdges.map(Nt))}function Vd({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:o}=J(Rd,Bd);return P.useEffect(()=>{const r={nodes:n,edges:o};
36e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Od=e=>!!e.onSelectionChangeHandlers;function Fd({onSelectionChange:e}){const t=J(Od);return e||t?y.jsx(Vd,{onSelectionChange:e}):null}const gi=[0,0],Yd={x:0,y:0,zoom:1},Xd=["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"],No=[...Xd,"rfId"],Wd=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Eo={translateExtent:it,nodeOrigin:gi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function qd(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=J(Wd,oe),u=re();P.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=Eo,a()}),[]);const f=P.useRef(Eo);return P.useEffect(()=>{for(const l of No){const d=e[l],p=f.current[l];d!==p&&(typeof e[l]>"u"||(l==="nodes"?t(d):l==="edges"?n(d):l==="minZoom"?o(d):l==="maxZoom"?r(d):l==="translateExtent"?i(d):l==="nodeExtent"?s(d):l==="ariaLabelConfig"?u.setState({ariaLabelConfig:Ru(d)}):l==="fitView"?u.setState({fitViewQueued:d}):l==="fitViewOptions"?u.setState({fitViewOptions:d}):u.setState({[l]:d})))}f.current=e},No.map(l=>e[l])),null}function Co(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Gd(e){var o;const[t,n]=P.useState(e==="system"?null:e);return P.useEffect(()=>{if(e!=="system"){n(e);return}const r=Co(),i=()=>n(r!=null&&r.matches?"dark":"light");return i(),r==null||r.addEventListener("change",i),()=>{r==null||r.removeEventListener("change",i)}},[e]),t!==null?t:(o=Co())!=null&&o.matches?"dark":"light"}const So=typeof document<"u"?document:null;function lt(e=null,t={target:So,actInsideInputWithModifier:!0}){const[n,o]=P.useState(!1),r=P.useRef(!1),i=P.useRef(new Set([])),[s,a]=P.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(l=>typeof l=="string").map(l=>l.replace("+",` 37`).replace(` 38 39`,` 40+`).split(` 41`)),f=u.reduce((l,d)=>l.concat(...d),[]);return[u,f]}return[[],[]]},[e]);return P.useEffect(()=>{const c=(t==null?void 0:t.target)??So,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=p=>{var b,m;if(r.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!r.current||r.current&&!u)&&Wr(p))return!1;const w=ko(p.code,a);if(i.current.add(p[w]),Mo(s,i.current,!1)){const E=((m=(b=p.composedPath)==null?void 0:b.call(p))==null?void 0:m[0])||p.target,h=(E==null?void 0:E.nodeName)==="BUTTON"||(E==null?void 0:E.nodeName)==="A";t.preventDefault!==!1&&(r.current||!h)&&p.preventDefault(),o(!0)}},l=p=>{const g=ko(p.code,a);Mo(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(p[g]),p.key==="Meta"&&i.current.clear(),r.current=!1},d=()=>{i.current.clear(),o(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",l),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",l),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,o]),n}
41function Mo(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function ko(e,t){return t.includes(e)?"code":"key"}const Kd=()=>{const e=re();return P.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:o}=e.getState();return o?o.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),c=Tn(t,o,r,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:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),u={x:t.x-a,y:t.y-c}
41,f=n.snapGrid??r,l=n.snapToGrid??i;return gt(u,o,l,f)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=Lt(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function pi(e,t){const n=[],o=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")o.set(i.id,[i]);else{const s=o.get(i.id);s?s.push(i):o.set(i.id,[i])}for(const i of t){const s=o.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)Ud(c,a);n.push(a)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Ud(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 mi(e,t){return pi(e,t)}function yi(e,t){return pi(e,t)}function ke(e,t){return{id:e,type:"select",selected:t}}function Le(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const s=t.has(r);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),o.push(ke(i.id,s)))}return o}function Io({items:e=[],lookup:t}){var r;const n=[],o=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const a=t.get(s.id),c=((r=a==null?void 0:a.internals)==null?void 0:r.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)o.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Ao(e){return{id:e.id,type:"remove"}}const Po=e=>Iu(e),Zd=e=>Hr(e);function xi(e){return P.forwardRef(e)}const Qd=typeof window<"u"?P.useLayoutEffect:P.useEffect;function To(e){const[t,n]=P.useState(BigInt(0)),[o]=P.useState(()=>Jd(()=>n(r=>r+BigInt(1))));return Qd(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Jd(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const wi=P.createContext(null);function ef({children:e}){const t=re(),n=P.useCallback(a=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:f,onNodesChange:l,nodeLookup:d,fitViewQueued:p,onNodesChangeMiddlewareMap:g}=t.getState();let w=c;for(const m of a)w=typeof m=="function"?m(w):m;let b=Io({items:w,lookup:d});for(const m of g.values())b=m(b);f&&u(w),b.length>0?l==null||l(b):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:E,setNodes:h}=t.getState();m&&h(E)})},[]),o=To(n),r=P.useCallback(a=>{const{edges:c=[],setEdges:u,hasDefaultEdges:f,onEdgesChange:l,edgeLookup:d}=t.getState();let p=c;for(const g of a)p=typeof g=="function"?g(p):g;f?u(p):l&&l(Io({items:p,lookup:d}))},[]),i=To(r),s=P.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return y.jsx(wi.Provider,{value:s,children:e})}function tf(){const e=P.useContext(wi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const nf=e=>!!e.panZoom;function Ut(){const e=Kd(),t=re(),n=tf(),o=J(nf),r=P.useMemo(()=>{const i=l=>t.getState().nodeLookup.get(l),s=l=>{n.nodeQueue.push(l)},a=l=>{n.edgeQueue.push(l)},c=l=>{var m,E;const{nodeLookup:d,nodeOrigin:p}=t.getState(),g=Po(l)?l:d.get(l.id),w=g.parentId?Yr(g.position,g.measured,g.parentId,d,p):g.position,b={...g,position:w,width:((m=g.measured)==null?void 0:m.width)??g.width,height:((E=g.measured)==null?void 0:E.height)??g.height};return Fe(b)},u=(l,d,p={replace:!1})=>{s(g=>g.map(w=>{if(w.id===l){const b=typeof d=="function"?d(w):d;return p.replace&&Po(b)?b:{...w,...b}}return w}))},f=(l,d,p={replace:!1})=>{a(g=>g.map(w=>{if(w.id===l){const b=typeof d=="function"?d(w):d;return p.replace&&Zd(b)?b:{...w,...b}}return w}))};return{getNodes:()=>t.getState().nodes.map(l=>({...l})),getNode:l=>{var d;return(d=i(l))==null?void 0:d.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:l=[]}=t.getState();return l.map(d=>({...d}))},getEdge:l=>t.getState().edgeLookup.get(l),setNodes:s,setEdges:a,addNodes:l=>{const d=Array.isArray(l)?l:[l];n.nodeQueue.push(p=>[...p,...d])},addEdges:l=>{const d=Array.isArray(l)?l:[l];n.edgeQueue.push(p=>[...p,...d])},toObject:()=>{const{nodes:l=[],edges:d=[],transform:p}=t.getState(),[g,w,b]=p;return{nodes:l.map(m=>({...m})),edges:d.map(m=>({...m})),viewport:{x:g,y:w,zoom:b}}},deleteElements:async({nodes:l=[],edges:d=[]})=>{const{nodes:p,edges:g,onNodesDelete:w,onEdgesDelete:b,triggerNodeChanges:m,triggerEdgeChanges:E,onDelete:h,onBeforeDelete:x}=t.getState(),{nodes:k,edges:S}=await ju({nodesToRemove:l,edgesToRemove:d,nodes:p,edges:g,onBeforeDelete:x}),I=S.length>0,D=k.length>0;if(I){const j=S.map(Ao);b==null||b(S),E(j)}if(D){const j=k.map(Ao);w==null||w(k),m(j)}return(D||I)&&(h==null||h({nodes:k,edges:S})),{deletedNodes:k,deletedEdges:S}},getIntersectingNodes:(l,d=!0,p)=>{const g=ao(l),w=g?l:c(l),b=p!==void 0;return w?(p||t.getState().nodes).filter(m=>{const E=t.getState().nodeLookup.get(m.id);if(E&&!g&&(m.id===l.id||!E.internals.positionAbsolute))return!1;const h=Fe(b?m:E),x=at(h,w);return d&&x>0||x>=h.width*h.height||x>=w.width*w.height}):[]},isNodeIntersecting:(l,d,p=!0)=>{const w=ao(l)?l:c(l);if(!w)return!1;const b=at(w,d);return p&&b>0||b>=d.width*d.height||b>=w.width*w.height},updateNode:u,updateNodeData:(l,d,p={replace:!1})=>{u(l,g=>{const w=typeof d=="function"?d(g):d;return p.replace?{...g,data:w}:{...g,data:{...g.data,...w}}},p)},updateEdge:f,updateEdgeData:(l,d,p={replace:!1})=>{f(l,g=>{const w=typeof d=="function"?d(g):d;return p.replace?{...g,data:w}:{...g,data:{...g.data,...w}}},p)}
41,getNodesBounds:l=>{const{nodeLookup:d,nodeOrigin:p}=t.getState();return Au(l,{nodeLookup:d,nodeOrigin:p})},getHandleConnections:({type:l,id:d,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}-${l}${d?`-${d}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:l,handleId:d,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}${l?d?`-${l}-${d}`:`-${l}`:""}`))==null?void 0:g.values())??[])},fitView:async l=>{const d=t.getState().fitViewResolver??Hu();return t.setState({fitViewQueued:!0,fitViewOptions:l,fitViewResolver:d}),n.nodeQueue.push(p=>[...p]),d.promise}}},[]);return P.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const $o=e=>e.selected,of=typeof window<"u"?window:void 0;function rf({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=re(),{deleteElements:o}=Ut(),r=lt(e,{actInsideInputWithModifier:!1}),i=lt(t,{target:of});P.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();o({nodes:a.filter($o),edges:s.filter($o)}),n.setState({nodesSelectionActive:!1})}},[r]),P.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function sf(e){const t=re();P.useEffect(()=>{const n=()=>{var r,i,s,a;if(!e.current||!(((i=(r=e.current).checkVisibility)==null?void 0:i.call(r))??!0))return!1;const o=$n(e.current);(o.height===0||o.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",ge.error004())),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const Zt={position:"absolute",width:"100%",height:"100%",top:0,left:0},af=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function cf({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=Ie.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:u,minZoom:f,maxZoom:l,zoomActivationKeyCode:d,preventScrolling:p=!0,children:g,noWheelClassName:w,noPanClassName:b,onViewportChange:m,isControlledViewport:E,paneClickDistance:h,selectionOnDrag:x}){const k=re(),S=P.useRef(null),{userSelectionActive:I,lib:D,connectionInProgress:j}=J(af,oe),B=lt(d),A=P.useRef();sf(S);const $=P.useCallback(R=>{m==null||m({x:R[0],y:R[1],zoom:R[2]}),E||k.setState({transform:R})},[m,E]);return P.useEffect(()=>{if(S.current){A.current=bd({domNode:S.current,minZoom:f,maxZoom:l,translateExtent:u,viewport:c,onDraggingChange:v=>k.setState(M=>M.paneDragging===v?M:{paneDragging:v}),onPanZoomStart:(v,M)=>{const{onViewportChangeStart:C,onMoveStart:N}=k.getState();N==null||N(v,M),C==null||C(M)},onPanZoom:(v,M)=>{const{onViewportChange:C,onMove:N}=k.getState();N==null||N(v,M),C==null||C(M)},onPanZoomEnd:(v,M)=>{const{onViewportChangeEnd:C,onMoveEnd:N}=k.getState();N==null||N(v,M),C==null||C(M)}});const{x:R,y:_,zoom:T}=A.current.getViewport();return k.setState({panZoom:A.current,transform:[R,_,T],domNode:S.current.closest(".react-flow")}),()=>{var v;(v=A.current)==null||v.destroy()}}},[]),P.useEffect(()=>{var R;(R=A.current)==null||R.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:B,preventScrolling:p,noPanClassName:b,userSelectionActive:I,noWheelClassName:w,lib:D,onTransformChange:$,connectionInProgress:j,selectionOnDrag:x,paneClickDistance:h})},[e,t,n,o,r,i,s,a,B,p,b,I,w,D,$,j,x,h]),y.jsx("div",{className:"react-flow__renderer",ref:S,style:Zt,children:g})}const lf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function uf(){const{userSelectionActive:e,userSelectionRect:t}=J(lf,oe);return e&&t?y.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 ln=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},df=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});
41function ff({isSelecting:e,selectionKeyPressed:t,selectionMode:n=st.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:f,onPaneMouseEnter:l,onPaneMouseMove:d,onPaneMouseLeave:p,children:g}){const w=re(),{userSelectionActive:b,elementsSelectable:m,dragging:E,connectionInProgress:h}=J(df,oe),x=m&&(e||b),k=P.useRef(null),S=P.useRef(),I=P.useRef(new Set),D=P.useRef(new Set),j=P.useRef(!1),B=C=>{if(j.current||h){j.current=!1;return}c==null||c(C),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},A=C=>{if(Array.isArray(o)&&(o!=null&&o.includes(2))){C.preventDefault();return}u==null||u(C)},$=f?C=>f(C):void 0,R=C=>{j.current&&(C.stopPropagation(),j.current=!1)},_=C=>{var X,W;const{domNode:N}=w.getState();if(S.current=N==null?void 0:N.getBoundingClientRect(),!S.current)return;const z=C.target===k.current;if(!z&&!!C.target.closest(".nokey")||!e||!(i&&z||t)||C.button!==0||!C.isPrimary)return;(W=(X=C.target)==null?void 0:X.setPointerCapture)==null||W.call(X,C.pointerId),j.current=!1;const{x:V,y:F}=fe(C.nativeEvent,S.current);w.setState({userSelectionRect:{width:0,height:0,startX:V,startY:F,x:V,y:F}}),z||(C.stopPropagation(),C.preventDefault())},T=C=>{const{userSelectionRect:N,transform:z,nodeLookup:H,edgeLookup:L,connectionLookup:V,triggerNodeChanges:F,triggerEdgeChanges:X,defaultEdgeOptions:W,resetSelectedElements:q}=w.getState();if(!S.current||!N)return;const{x:O,y:G}=fe(C.nativeEvent,S.current),{startX:Q,startY:Z}=N;if(!j.current){const ee=t?0:r;if(Math.hypot(O-Q,G-Z)<=ee)return;q(),s==null||s(C)}j.current=!0;const U={startX:Q,startY:Z,x:O<Q?O:Q,y:G<Z?G:Z,width:Math.abs(O-Q),height:Math.abs(G-Z)},K=I.current,te=D.current;I.current=new Set(Pn(H,U,z,n===st.Partial,!0).map(ee=>ee.id)),D.current=new Set;const ne=(W==null?void 0:W.selectable)??!0;for(const ee of I.current){const se=V.get(ee);if(se)for(const{edgeId:_e}of se.values()){const me=L.get(_e);me&&(me.selectable??ne)&&D.current.add(_e)}}if(!co(K,I.current)){const ee=Le(H,I.current,!0);F(ee)}if(!co(te,D.current)){const ee=Le(L,D.current);X(ee)}w.setState({userSelectionRect:U,userSelectionActive:!0,nodesSelectionActive:!1})},v=C=>{var N,z;C.button===0&&((z=(N=C.target)==null?void 0:N.releasePointerCapture)==null||z.call(N,C.pointerId),!b&&C.target===k.current&&w.getState().userSelectionRect&&(B==null||B(C)),w.setState({userSelectionActive:!1,userSelectionRect:null}),j.current&&(a==null||a(C),w.setState({nodesSelectionActive:I.current.size>0})))},M=o===!0||Array.isArray(o)&&o.includes(0);return y.jsxs("div",{className:ie(["react-flow__pane",{draggable:M,dragging:E,selection:e}]),onClick:x?void 0:ln(B,k),onContextMenu:ln(A,k),onWheel:ln($,k),onPointerEnter:x?void 0:l,onPointerMove:x?T:d,onPointerUp:x?v:void 0,onPointerDownCapture:x?_:void 0,onClickCapture:x?R:void 0,onPointerLeave:p,ref:k,style:Zt,children:[g,y.jsx(uf,{})]})}function Nn({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),u=a.get(e);if(!u){c==null||c("012",ge.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var f;return(f=o==null?void 0:o.current)==null?void 0:f.blur()})):r([e])}function bi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const a=re(),[c,u]=P.useState(!1),f=P.useRef();return P.useEffect(()=>{f.current=sd({getStoreItems:()=>a.getState(),onNodeMouseDown:l=>{Nn({id:l,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),P.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s}),()=>{var l;(l=f.current)==null||l.destroy()}},[n,o,t,i,e,r,s]),c}const hf=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function vi(){const e=re();return P.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:u,nodeOrigin:f}=e.getState(),l=new Map,d=hf(s),p=r?i[0]:5,g=r?i[1]:5,w=n.direction.x*p*n.factor,b=n.direction.y*g*n.factor;for(const[,m]of u){if(!d(m))continue;let E={x:m.internals.positionAbsolute.x+w,y:m.internals.positionAbsolute.y+b};r&&(E=ht(E,i));const{position:h,positionAbsolute:x}=Rr({nodeId:m.id,nextPosition:E,nodeLookup:u,nodeExtent:o,nodeOrigin:f,onError:a});m.position=h,m.internals.positionAbsolute=x,l.set(m.id,m)}c(l)},[])}const Rn=P.createContext(null),gf=Rn.Provider;Rn.Consumer;const _i=()=>P.useContext(Rn),pf=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),mf=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:a,toHandle:c,isValid:u}=s,f=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:f,clickConnecting:(r==null?void 0:r.no
41deId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:i===Ve.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:!!r,valid:f&&u}};function yf({type:e="source",position:t=Y.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:u,onMouseDown:f,onTouchStart:l,...d},p){var T,v;const g=s||null,w=e==="target",b=re(),m=_i(),{connectOnClick:E,noPanClassName:h,rfId:x}=J(pf,oe),{connectingFrom:k,connectingTo:S,clickConnecting:I,isPossibleEndHandle:D,connectionInProcess:j,clickConnectionInProcess:B,valid:A}=J(mf(m,g,e),oe);m||(v=(T=b.getState()).onError)==null||v.call(T,"010",ge.error010());const $=M=>{const{defaultEdgeOptions:C,onConnect:N,hasDefaultEdges:z}=b.getState(),H={...C,...M};if(z){const{edges:L,setEdges:V}=b.getState();V(Zr(H,L))}N==null||N(H),a==null||a(H)},R=M=>{if(!m)return;const C=qr(M.nativeEvent);if(r&&(C&&M.button===0||!C)){const N=b.getState();_n.onPointerDown(M.nativeEvent,{handleDomNode:M.currentTarget,autoPanOnConnect:N.autoPanOnConnect,connectionMode:N.connectionMode,connectionRadius:N.connectionRadius,domNode:N.domNode,nodeLookup:N.nodeLookup,lib:N.lib,isTarget:w,handleId:g,nodeId:m,flowId:N.rfId,panBy:N.panBy,cancelConnection:N.cancelConnection,onConnectStart:N.onConnectStart,onConnectEnd:(...z)=>{var H,L;return(L=(H=b.getState()).onConnectEnd)==null?void 0:L.call(H,...z)},updateConnection:N.updateConnection,onConnect:$,isValidConnection:n||((...z)=>{var H,L;return((L=(H=b.getState()).isValidConnection)==null?void 0:L.call(H,...z))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:N.autoPanSpeed,dragThreshold:N.connectionDragThreshold})}C?f==null||f(M):l==null||l(M)},_=M=>{const{onClickConnectStart:C,onClickConnectEnd:N,connectionClickStartHandle:z,connectionMode:H,isValidConnection:L,lib:V,rfId:F,nodeLookup:X,connection:W}=b.getState();if(!m||!z&&!r)return;if(!z){C==null||C(M.nativeEvent,{nodeId:m,handleId:g,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:m,type:e,id:g}});return}const q=Xr(M.target),O=n||L,{connection:G,isValid:Q}=_n.isValid(M.nativeEvent,{handle:{nodeId:m,id:g,type:e},connectionMode:H,fromNodeId:z.nodeId,fromHandleId:z.id||null,fromType:z.type,isValidConnection:O,flowId:F,doc:q,lib:V,nodeLookup:X});Q&&G&&$(G);const Z=structuredClone(W);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,N==null||N(M,Z),b.setState({connectionClickStartHandle:null})};return y.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":t,"data-id":`${x}-${m}-${g}-${e}`,className:ie(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",h,u,{source:!w,target:w,connectable:o,connectablestart:r,connectableend:i,clickconnecting:I,connectingfrom:k,connectingto:S,valid:A,connectionindicator:o&&(!j||D)&&(j||B?i:r)}]),onMouseDown:R,onTouchStart:R,onClick:E?_:void 0,ref:p,...d,children:c})}const le=P.memo(xi(yf));function xf({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return y.jsxs(y.Fragment,{children:[e==null?void 0:e.label,y.jsx(le,{type:"source",position:n,isConnectable:t})]})}function wf({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:o=Y.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(le,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,y.jsx(le,{type:"source",position:o,isConnectable:t})]})}function bf(){return null}function vf({data:e,isConnectable:t,targetPosition:n=Y.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(le,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Rt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},jo={input:xf,default:wf,output:vf,group:bf};function _f(e){var t,n,o,r;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??((o=e.style)==null?void 0:o.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const Nf=e=>{const{width:t,height:n,x:o,y:r}=ft(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(${o}px,${r}px)`}};function Ef({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=re(),{width:r,height:i,transformString:s,userSelectionActive:a}=J(Nf,oe),c=vi(),u=P.useRef(null);P.useEffect(()=>{var p;n||(p=u.current)==null||p.focus({preventScroll:!0})},[n]);const f=!a&&r!==null&&i!==null;if(bi({nodeRef:u,disabled:!f}),!f)return null;const l=e?p=>{const g=o.getState().nodes.filter(w=>w.selected);e(p,g)}:void 0,d=p=>{Object.prototype.hasOwnProperty.call(Rt,p.key)&&(p.preventDefault(),c({direction:Rt[p.key],factor:p.shiftKey?4:1}))};return y.jsx("div",{className:ie(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:y.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:l,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:i}})})}const zo=typeof window<"u"?window:void 0,Cf=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Ni({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:f,selectionMode:l,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:g,panActivationKeyCode:w,zoomActivationKeyCode:b,elementsSelectable:m,zoomOnScroll:E,zoomOnPinch:h,panOnScroll:x,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:I,panOnDrag:D,defaultViewport:j,translateExtent:B,minZoom:A,maxZoom:$,preventScrolling:R,onSelectionContextMenu:_,noWheelClassName:T,noPanClassName:v,disableKeyboardA11y:M,onViewportChange:C,isControlledViewport:N}){const{nodesSelectionActive:z,userSelectionActive:H}=J(Cf,oe),L=lt(u,{target:zo}),V=lt(w,{target:zo}),F=V||D,X=V||x,W=f&&F!==!0,q=L||H||W;return rf({deleteKeyCode:c,multiSelectionKeyCode:g}),y.jsx(cf,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:E,zoomOnPinch:h,panOnScroll:X,panOnScrollSpeed:k,panOnScrollMode:S,zoomOnDoubleClick:I,panOnDrag:!L&&F,defaultViewport:j,translateExtent:B,minZoom:A,maxZoom:$,zoomActivationKeyCode:b,preventScrolling:R,noWheelClassName:T,noPanClassName:v,onViewportChange:C,isControlledViewport:N,paneClickDistance:a,selectionOnDrag:W,children:y.jsxs(ff,{onSelectionStart:d,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:F,isSelecting:!!q,selectionMode:l,selectionKeyPressed:L,paneClickDistance:a,selectionOnDrag:W,children:[e,z&&y.jsx(Ef,{onSelectionContextMenu:_,noPanClassName:v,disableKeyboardA11y:M})]})})}Ni.displayName="FlowRenderer";const Sf=P.memo(Ni),Mf=e=>t=>e?Pn(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 kf(e){return J(P.useCallback(Mf(e),[e]),oe)}const If=e=>e.updateNodeInternals;function Af(){const e=J(If),[t]=P.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;
41n.forEach(r=>{const i=r.target.getAttribute("data-id");o.set(i,{id:i,nodeElement:r.target,force:!0})}),e(o)}));return P.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Pf({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=re(),i=P.useRef(null),s=P.useRef(null),a=P.useRef(e.sourcePosition),c=P.useRef(e.targetPosition),u=P.useRef(t),f=n&&!!e.internals.handleBounds;return P.useEffect(()=>{i.current&&!e.hidden&&(!f||s.current!==i.current)&&(s.current&&(o==null||o.unobserve(s.current)),o==null||o.observe(i.current),s.current=i.current)},[f,e.hidden]),P.useEffect(()=>()=>{s.current&&(o==null||o.unobserve(s.current),s.current=null)},[]),P.useEffect(()=>{if(i.current){const l=u.current!==t,d=a.current!==e.sourcePosition,p=c.current!==e.targetPosition;(l||d||p)&&(u.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Tf({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:u,nodesFocusable:f,resizeObserver:l,noDragClassName:d,noPanClassName:p,disableKeyboardA11y:g,rfId:w,nodeTypes:b,nodeClickDistance:m,onError:E}){const{node:h,internals:x,isParent:k}=J(O=>{const G=O.nodeLookup.get(e),Q=O.parentLookup.has(e);return{node:G,internals:G.internals,isParent:Q}},oe);let S=h.type||"default",I=(b==null?void 0:b[S])||jo[S];I===void 0&&(E==null||E("003",ge.error003(S)),S="default",I=(b==null?void 0:b.default)||jo.default);const D=!!(h.draggable||a&&typeof h.draggable>"u"),j=!!(h.selectable||c&&typeof h.selectable>"u"),B=!!(h.connectable||u&&typeof h.connectable>"u"),A=!!(h.focusable||f&&typeof h.focusable>"u"),$=re(),R=Fr(h),_=Pf({node:h,nodeType:S,hasDimensions:R,resizeObserver:l}),T=bi({nodeRef:_,disabled:h.hidden||!D,noDragClassName:d,handleSelector:h.dragHandle,nodeId:e,isSelectable:j,nodeClickDistance:m}),v=vi();if(h.hidden)return null;const M=ve(h),C=_f(h),N=j||D||t||n||o||r,z=n?O=>n(O,{...x.userNode}):void 0,H=o?O=>o(O,{...x.userNode}):void 0,L=r?O=>r(O,{...x.userNode}):void 0,V=i?O=>i(O,{...x.userNode}):void 0,F=s?O=>s(O,{...x.userNode}):void 0,X=O=>{const{selectNodesOnDrag:G,nodeDragThreshold:Q}=$.getState();j&&(!G||!D||Q>0)&&Nn({id:e,store:$,nodeRef:_}),t&&t(O,{...x.userNode})},W=O=>{if(!(Wr(O.nativeEvent)||g)){if(jr.includes(O.key)&&j){const G=O.key==="Escape";Nn({id:e,store:$,unselect:G,nodeRef:_})}else if(D&&h.selected&&Object.prototype.hasOwnProperty.call(Rt,O.key)){O.preventDefault();const{ariaLabelConfig:G}=$.getState();$.setState({ariaLiveMessage:G["node.a11yDescription.ariaLiveMessage"]({direction:O.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),v({direction:Rt[O.key],factor:O.shiftKey?4:1})}}},q=()=>{var te;if(g||!((te=_.current)!=null&&te.matches(":focus-visible")))return;const{transform:O,width:G,height:Q,autoPanOnNodeFocus:Z,setCenter:U}=$.getState();if(!Z)return;Pn(new Map([[e,h]]),{x:0,y:0,width:G,height:Q},O,!0).length>0||U(h.position.x+M.width/2,h.position.y+M.height/2,{zoom:O[2]})};return y.jsx("div",{className:ie(["react-flow__node",`react-flow__node-${S}`,{[p]:D},h.className,{selected:h.selected,selectable:j,parent:k,draggable:D,dragging:T}]),ref:_,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:N?"all":"none",visibility:R?"visible":"hidden",...h.style,...C},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:z,onMouseMove:H,onMouseLeave:L,onContextMenu:V,onClick:X,onDoubleClick:F,onKeyDown:A?W:void 0,tabIndex:A?0:void 0,onFocus:A?q:void 0,role:h.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${fi}-${w}`,"aria-label":h.ariaLabel,...h.domAttributes,children:y.jsx(gf,{value:e,children:y.jsx(I,{id:e,data:h.data,type:S,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:h.selected??!1,selectable:j,draggable:D,deletable:h.deletable??!0,isConnectable:B,sourcePosition:h.sourcePosition,targetPosition:h.targetPosition,dragging:T,dragHandle:h.dragHandle,zIndex:x.z,parentId:h.parentId,...M})})})}var $f=P.memo(Tf);const jf=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,no
41desFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ei(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:i}=J(jf,oe),s=kf(e.onlyRenderVisibleElements),a=Af();return y.jsx("div",{className:"react-flow__nodes",style:Zt,children:s.map(c=>y.jsx($f,{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:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}Ei.displayName="NodeRenderer";const zf=P.memo(Ei);function Df(e){return J(P.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);i&&s&&Ou({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),oe)}const Lf=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return y.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Hf=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return y.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Do={[zt.Arrow]:Lf,[zt.ArrowClosed]:Hf};function Rf(e){const t=re();return P.useMemo(()=>{var r,i;return Object.prototype.hasOwnProperty.call(Do,e)?Do[e]:((i=(r=t.getState()).onError)==null||i.call(r,"009",ge.error009(e)),null)},[e])}const Bf=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=Rf(t);return c?y.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:y.jsx(c,{color:n,strokeWidth:s})}):null},Ci=({defaultColor:e,rfId:t})=>{const n=J(i=>i.edges),o=J(i=>i.defaultEdgeOptions),r=P.useMemo(()=>Ku(n,{id:t,defaultColor:e,defaultMarkerStart:o==null?void 0:o.markerStart,defaultMarkerEnd:o==null?void 0:o.markerEnd}),[n,o,t,e]);return r.length?y.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:y.jsx("defs",{children:r.map(i=>y.jsx(Bf,{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};Ci.displayName="MarkerDefinitions";var Vf=P.memo(Ci);function Si({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:u,...f}){const[l,d]=P.useState({x:1,y:0,width:0,height:0}),p=ie(["react-flow__edge-textwrapper",u]),g=P.useRef(null);return P.useEffect(()=>{if(g.current){const w=g.current.getBBox();d({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?y.jsxs("g",{transform:`translate(${e-l.width/2} ${t-l.height/2})`,className:p,visibility:l.width?"visible":"hidden",...f,children:[r&&y.jsx("rect",{width:l.width+2*s[0],x:-s[0],y:-s[1],height:l.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),y.jsx("text",{className:"react-flow__edge-text",y:l.height/2,dy:"0.3em",ref:g,style:o,children:n}),c]}):null}Si.displayName="EdgeText";const Of=P.memo(Si);function pt({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:u=20,...f}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...f,d:e,fill:"none",className:ie(["react-flow__edge-path",f.className])}),u?y.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,o&&de(t)&&de(n)?y.jsx(Of,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function Lo({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===Y.Left||e===Y.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function Mi({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:o,targetY:r,targetPosition:i=Y.Top}){const[s,a]=Lo({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,u]=Lo({pos:i,x1:o,y1:r,x2:e,y2:t}),[f,l,d,p]=Gr({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${a} ${c},${u} ${o},${r}`,f,l,d,p]}function ki(e){return P.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:w,markerStart:b,interactionWidth:m})=>{const[E,h,x]=Mi({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a}),k=e.isInternal?void 0:t;return y.jsx(pt,{id:k,path:E,labelX:h,labelY:x,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:w,markerStart:b,interactionWidth:m})})}const Ff=ki({isInternal:!1}),Ii=ki({isInternal:!0});Ff.displayName="SimpleBezierEdge";Ii.displayName="SimpleBezierEdgeInternal";function Ai(e){return P.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:l,style:d,sourcePosition:p=Y.Bottom,targetPosition:g=Y.Top,markerEnd:w,markerStart:b,pathOptions:m,interactionWidth:E})=>{const[h,x,k]=Ht({sourceX:n,sourceY:o,sourcePosition:p,targetX:r,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}),S=e.isInternal?void 0:t;return y.jsx(pt,{id:S,path:h,labelX:x,labelY:k,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:l,style:d,markerEnd:w,markerStart:b,interactionWidth:E})})}const Pi=Ai({isInternal:!1}),Ti=Ai({isInternal:!0});Pi.displayName="SmoothStepEdge";Ti.displayName="SmoothStepEdgeInternal";function $i(e){return P.memo(({id:t,...n})=>{var r;const o=e.isInternal?void 0:t;return y.jsx(Pi,{...n,id:o,pathOptions:P.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const Yf=$i({isInternal:!1}),ji=$i({isInternal:!0});Yf.displayName="StepEdge";ji.displayName="StepEdgeInternal";function zi(e){return P.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:l,style:d,markerEnd:p,markerStart:g,interactionWidth:w})=>{const[b,m,E]=Qr({sourceX:n,sourceY:o,targetX:r,targetY:i}),h=e.isInternal?void 0:t;return y.jsx(pt,{id:h,path:b,labelX:m,labelY:E,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:l,style:d,markerEnd:p,markerStart:g,interactionWidth:w})})}const Xf=zi({isInternal:!1}),Di=zi({isInternal:!0});Xf.displayName="StraightEdge";Di.displayName="StraightEdgeInternal";function Li(e){return P.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=Y.Bottom,targetPosition:a=Y.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:w,markerStart:b,pathOptions:m,interactionWidth:E})=>{const[h,x,k]=Kr({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a,curvature:m==null?void 0:m.curvature}),S=e.isInternal?void 0:t;return y.jsx(pt,{id:S,path:h,labelX:x,labelY:k,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:w,markerStart:b,interactionWidth:E})})}const Wf=Li({isInternal:!1}),Hi=Li({isInternal:!0});Wf.displayName="BezierEdge";Hi.displayName="BezierEdgeInternal";const Ho={default:Hi,straight:Di,step:ji,smoothstep:Ti,simplebezier:Ii},Ro={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},qf=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,Gf=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,Bo="react-flow__edgeupdater";function Vo({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:a}){return y.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:ie([Bo,`${Bo}-${a}`]),cx:qf(t,o,e),cy:Gf(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Kf({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:u,onReconnectStart:f,onReconnectEnd:l,setReconnecting:d,setUpdateHover:p}){const g=re(),w=(x,k)=>{if(x.button!==0)return;
41const{autoPanOnConnect:S,domNode:I,connectionMode:D,connectionRadius:j,lib:B,onConnectStart:A,cancelConnection:$,nodeLookup:R,rfId:_,panBy:T,updateConnection:v}=g.getState(),M=k.type==="target",C=(H,L)=>{d(!1),l==null||l(H,n,k.type,L)},N=H=>u==null?void 0:u(n,H),z=(H,L)=>{d(!0),f==null||f(x,n,k.type),A==null||A(H,L)};_n.onPointerDown(x.nativeEvent,{autoPanOnConnect:S,connectionMode:D,connectionRadius:j,domNode:I,handleId:k.id,nodeId:k.nodeId,nodeLookup:R,isTarget:M,edgeUpdaterType:k.type,lib:B,flowId:_,cancelConnection:$,panBy:T,isValidConnection:(...H)=>{var L,V;return((V=(L=g.getState()).isValidConnection)==null?void 0:V.call(L,...H))??!0},onConnect:N,onConnectStart:z,onConnectEnd:(...H)=>{var L,V;return(V=(L=g.getState()).onConnectEnd)==null?void 0:V.call(L,...H)},onReconnectEnd:C,updateConnection:v,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},b=x=>w(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=x=>w(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),E=()=>p(!0),h=()=>p(!1);return y.jsxs(y.Fragment,{children:[(e===!0||e==="source")&&y.jsx(Vo,{position:a,centerX:o,centerY:r,radius:t,onMouseDown:b,onMouseEnter:E,onMouseOut:h,type:"source"}),(e===!0||e==="target")&&y.jsx(Vo,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:E,onMouseOut:h,type:"target"})]})}function Uf({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,reconnectRadius:f,onReconnect:l,onReconnectStart:d,onReconnectEnd:p,rfId:g,edgeTypes:w,noPanClassName:b,onError:m,disableKeyboardA11y:E}){let h=J(U=>U.edgeLookup.get(e));const x=J(U=>U.defaultEdgeOptions);h=x?{...x,...h}:h;let k=h.type||"default",S=(w==null?void 0:w[k])||Ho[k];S===void 0&&(m==null||m("011",ge.error011(k)),k="default",S=(w==null?void 0:w.default)||Ho.default);const I=!!(h.focusable||t&&typeof h.focusable>"u"),D=typeof l<"u"&&(h.reconnectable||n&&typeof h.reconnectable>"u"),j=!!(h.selectable||o&&typeof h.selectable>"u"),B=P.useRef(null),[A,$]=P.useState(!1),[R,_]=P.useState(!1),T=re(),{zIndex:v,sourceX:M,sourceY:C,targetX:N,targetY:z,sourcePosition:H,targetPosition:L}=J(P.useCallback(U=>{const K=U.nodeLookup.get(h.source),te=U.nodeLookup.get(h.target);if(!K||!te)return{zIndex:h.zIndex,...Ro};const ne=Gu({id:e,sourceNode:K,targetNode:te,sourceHandle:h.sourceHandle||null,targetHandle:h.targetHandle||null,connectionMode:U.connectionMode,onError:m});return{zIndex:Vu({selected:h.selected,zIndex:h.zIndex,sourceNode:K,targetNode:te,elevateOnSelect:U.elevateEdgesOnSelect,zIndexMode:U.zIndexMode}),...ne||Ro}},[h.source,h.target,h.sourceHandle,h.targetHandle,h.selected,h.zIndex]),oe),V=P.useMemo(()=>h.markerStart?`url('#${bn(h.markerStart,g)}')`:void 0,[h.markerStart,g]),F=P.useMemo(()=>h.markerEnd?`url('#${bn(h.markerEnd,g)}')`:void 0,[h.markerEnd,g]);if(h.hidden||M===null||C===null||N===null||z===null)return null;const X=U=>{var ee;const{addSelectedEdges:K,unselectNodesAndEdges:te,multiSelectionActive:ne}=T.getState();j&&(T.setState({nodesSelectionActive:!1}),h.selected&&ne?(te({nodes:[],edges:[h]}),(ee=B.current)==null||ee.blur()):K([e])),r&&r(U,h)},W=i?U=>{i(U,{...h})}:void 0,q=s?U=>{s(U,{...h})}:void 0,O=a?U=>{a(U,{...h})}:void 0,G=c?U=>{c(U,{...h})}:void 0,Q=u?U=>{u(U,{...h})}:void 0,Z=U=>{var K;if(!E&&jr.includes(U.key)&&j){const{unselectNodesAndEdges:te,addSelectedEdges:ne}=T.getState();U.key==="Escape"?((K=B.current)==null||K.blur(),te({edges:[h]})):ne([e])}};return y.jsx("svg",{style:{zIndex:v},children:y.jsxs("g",{className:ie(["react-flow__edge",`react-flow__edge-${k}`,h.className,b,{selected:h.selected,animated:h.animated,inactive:!j&&!r,updating:A,selectable:j}]),onClick:X,onDoubleClick:W,onContextMenu:q,onMouseEnter:O,onMouseMove:G,onMouseLeave:Q,onKeyDown:I?Z:void 0,tabIndex:I?0:void 0,role:h.ariaRole??(I?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":h.ariaLabel===null?void 0:h.ariaLabel||`Edge from ${h.source} to ${h.target}`,"aria-describedby":I?`${hi}-${g}`:void 0,ref:B,...h.domAttributes,children:[!R&&y.jsx(S,{id:e,source:h.source,target:h.target,type:h.type,selected:h.selected,animated:h.animated,selectable:j,deletable:h.deletable??!0,label:h.label,labelStyle:h.labelStyle,labelShowBg:h.labelShowBg,labelBgStyle:h.labelBgStyle,labelBgPadding:h.labelBgPadding,labelBgBorderRadius:h.labelBgBorderRadius,sourceX:M,sourceY:C,targetX:N,targetY:z,sourcePosition:H,targetPosition:L,data:h.data,style:h.style,sourceHandleId:h.sourceHandle,targetHandleId:h.targetHandle,markerStart:V,markerEnd:F,pathOptions:"pathOptions"in h?h.pathOptions:void 0,interactionWidth:h.interactionWidth}),D&&y.jsx(Kf,{edge:h,isReconnectable:D,reconnectRadius:f,onReconnect:l,onReconnectStart:d,onReconnectEnd:p,sourceX:M,sourceY:C,targetX:N,targetY:z,sourcePosition:H,targetPosition:L,setUpdateHover:$,setReconnecting:_})]})})}var Zf=P.memo(Uf);const Qf=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ri({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:f,re
41connectRadius:l,onEdgeDoubleClick:d,onReconnectStart:p,onReconnectEnd:g,disableKeyboardA11y:w}){const{edgesFocusable:b,edgesReconnectable:m,elementsSelectable:E,onError:h}=J(Qf,oe),x=Df(t);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(Vf,{defaultColor:e,rfId:n}),x.map(k=>y.jsx(Zf,{id:k,edgesFocusable:b,edgesReconnectable:m,elementsSelectable:E,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:f,reconnectRadius:l,onDoubleClick:d,onReconnectStart:p,onReconnectEnd:g,rfId:n,onError:h,edgeTypes:o,disableKeyboardA11y:w},k))]})}Ri.displayName="EdgeRenderer";const Jf=P.memo(Ri),eh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function th({children:e}){const t=J(eh);return y.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function nh(e){const t=Ut(),n=P.useRef(!1);P.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const oh=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function rh(e){const t=J(oh),n=re();return P.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:gt(e.connection.to,e.transform)}:{...e.connection}}function sh(e){return ih}function ah(e){const t=sh();return J(t,oe)}const ch=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function lh({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:a,inProgress:c}=J(ch,oe);return!(i&&r&&c)?null:y.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:y.jsx("g",{className:ie(["react-flow__connection",Lr(a)]),children:y.jsx(Bi,{style:t,type:n,CustomComponent:o,isValid:a})})})}const Bi=({style:e,type:t=Ce.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:u,toNode:f,toHandle:l,toPosition:d,pointer:p}=ah();if(!r)return;if(n)return y.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:d,connectionStatus:Lr(o),toNode:f,toHandle:l,pointer:p});let g="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case Ce.Bezier:[g]=Kr(w);break;case Ce.SimpleBezier:[g]=Mi(w);break;case Ce.Step:[g]=Ht({...w,borderRadius:0});break;case Ce.SmoothStep:[g]=Ht(w);break;default:[g]=Qr(w)}return y.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Bi.displayName="ConnectionLine";const uh={};function Oo(e=uh){P.useRef(e),re(),P.useEffect(()=>{},[e])}function dh(){re(),P.useRef(!1),P.useEffect(()=>{},[])}function Vi({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:f,onSelectionContextMenu:l,onSelectionStart:d,onSelectionEnd:p,connectionLineType:g,connectionLineStyle:w,connectionLineComponent:b,connectionLineContainerStyle:m,selectionKeyCode:E,selectionOnDrag:h,selectionMode:x,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:I,deleteKeyCode:D,onlyRenderVisibleElements:j,elementsSelectable:B,defaultViewport:A,translateExtent:$,minZoom:R,maxZoom:_,preventScrolling:T,defaultMarkerColor:v,zoomOnScroll:M,zoomOnPinch:C,panOnScroll:N,panOnScrollSpeed:z,panOnScrollMode:H,zoomOnDoubleClick:L,panOnDrag:V,onPaneClick:F,onPaneMouseEnter:X,onPaneMouseMove:W,onPaneMouseLeave:q,onPaneScroll:O,onPaneContextMenu:G,paneClickDistance:Q,nodeClickDistance:Z,onEdgeContextMenu:U,onEdgeMouseEnter:K,onEdgeMouseMove:te,onEdgeMouseLeave:ne,reconnectRadius:ee,onReconnect:se,onReconnectStart:_e,onReconnectEnd:me,noDragClassName:Se,noWheelClassName:We,noPanClassName:qe,disableKeyboardA11y:Ge,nodeExtent:Qt,rfId:mt,viewport:je,onViewportChange:Ke}){return Oo(e),Oo(t),dh(),nh(n),rh(je),y.jsx(Sf,{onPaneClick:F,onPaneMouseEnter:X,onPaneMouseMove:W,onPaneMouseLeave:q,onPaneContextMenu:G,onPaneScroll:O,paneClickDistance:Q,deleteKeyCode:D,selectionKeyCode:E,selectionOnDrag:h,selectionMode:x,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:k,panActivationKeyCode:S,zoomActivationKeyCode:I,elementsSelectable:B,zoomOnScroll:M,zoomOnPinch:C,zoomOnDoubleClick:L,panOnScroll:N,panOnScrollSpeed:z,panOnScrollMode:H,panOnDrag:V,defaultViewport:A,translateExtent:$,minZoom:R,maxZoom:_,onSelectionContextMenu:l,preventScrolling:T,n
41oDragClassName:Se,noWheelClassName:We,noPanClassName:qe,disableKeyboardA11y:Ge,onViewportChange:Ke,isControlledViewport:!!je,children:y.jsxs(th,{children:[y.jsx(Jf,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:se,onReconnectStart:_e,onReconnectEnd:me,onlyRenderVisibleElements:j,onEdgeContextMenu:U,onEdgeMouseEnter:K,onEdgeMouseMove:te,onEdgeMouseLeave:ne,reconnectRadius:ee,defaultMarkerColor:v,noPanClassName:qe,disableKeyboardA11y:Ge,rfId:mt}),y.jsx(lh,{style:w,type:g,component:b,containerStyle:m}),y.jsx("div",{className:"react-flow__edgelabel-renderer"}),y.jsx(zf,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:f,nodeClickDistance:Z,onlyRenderVisibleElements:j,noPanClassName:qe,noDragClassName:Se,disableKeyboardA11y:Ge,nodeExtent:Qt,rfId:mt}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}Vi.displayName="GraphView";const fh=P.memo(Vi),Fo=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:u=2,nodeOrigin:f,nodeExtent:l,zIndexMode:d="basic"}={})=>{const p=new Map,g=new Map,w=new Map,b=new Map,m=o??t??[],E=n??e??[],h=f??[0,0],x=l??it;ti(w,b,m);const k=vn(E,p,g,{nodeOrigin:h,nodeExtent:x,zIndexMode:d});let S=[0,0,1];if(s&&r&&i){const I=ft(p,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:D,y:j,zoom:B}=Tn(I,r,i,c,u,(a==null?void 0:a.padding)??.1);S=[D,j,B]}return{rfId:"1",width:r??0,height:i??0,transform:S,nodes:E,nodesInitialized:k,nodeLookup:p,parentLookup:g,edges:m,edgeLookup:b,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:it,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ve.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:h,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:{...Dr},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:zu,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:zr,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},hh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:l,zIndexMode:d})=>Ad((p,g)=>{async function w(){const{nodeLookup:b,panZoom:m,fitViewOptions:E,fitViewResolver:h,width:x,height:k,minZoom:S,maxZoom:I}=g();m&&(await $u({nodes:b,width:x,height:k,panZoom:m,minZoom:S,maxZoom:I},E),h==null||h.resolve(!0),p({fitViewResolver:null}))}return{...Fo({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:l,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:b=>{const{nodeLookup:m,parentLookup:E,nodeOrigin:h,elevateNodesOnSelect:x,fitViewQueued:k,zIndexMode:S}=g(),I=vn(b,m,E,{nodeOrigin:h,nodeExtent:l,elevateNodesOnSelect:x,checkEquality:!0,zIndexMode:S});k&&I?(w(),p({nodes:b,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0})):p({nodes:b,nodesInitialized:I})},setEdges:b=>{const{connectionLookup:m,edgeLookup:E}=g();ti(m,E,b),p({edges:b})},setDefaultNodesAndEdges:(b,m)=>{if(b){const{setNodes:E}=g();E(b),p({hasDefaultNodes:!0})}if(m){const{setEdges:E}=g();E(m),p({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:m,nodeLookup:E,parentLookup:h,domNode:x,nodeOrigin:k,nodeExtent:S,debug:I,fitViewQueued:D,zIndexMode:j}=g(),{changes:B,updatedInternals:A}=nd(b,E,h,x,k,S,j);A&&(Qu(E,h,{nodeOrigin:k,nodeExtent:S,zIndexMode:j}),D?(w(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(B==null?void 0:B.length)>0&&(I&&console.log("React Flow: trigger node changes",B),m==null||m(B)))},updateNodePositions:(b,m=!1)=>{const E=[];let h=[];const{nodeLookup:x,triggerNodeChanges:k,connection:S,updateConnection:I,onNodesChangeMiddlewareMap:D}=g();for(const[j,B]of b){const A=x.get(j),$=!!(A!=null&&A.expandParent&&(A!=null&&A.parentId)&&(B!=null&&B.position)),R={id:j,type:"position",position:$?{x:Math.max(0,B.position.x),y:Math.max(0,B.position.y)}:B.position,dragging:m};if(A&&S.inProgress&&S.fromNode.id===A.id){const _=Te(A,S.fromHandle,Y.Left,!0);I({...S,from:_})}$&&A.parentId&&E.push({id:j,parentId:A.parentId,rect:{...B.internals.positionAbsolute,width:B.measured.width??0,height:B.measured.height??0}}),h.push(R)}if(E.length>0){const{parentLookup:j,nodeOrigin:B}=g(),A=Hn(E,x,j,B);h.push(...A)}for(const j of D.values())h=j(h);k(h)},triggerNodeChanges:b=>{const{onNodesChange:m,setNodes:E,nodes:h,hasDefaultNodes:x,debug:k}=g();if(b!=null&&b.length){if(x){const S=mi(b,h);E(S)}k&&console.log("React Flow: trigger node changes",b),m==null||m(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:m,setEdges:E,edges:h,hasDefaultEdges:x,debug:k}=g();if(b!=null&&b.length){if(x){const S=yi(b,h);E(S)}k&&console.log("React Flow: trigger edge changes",b),m==null||m(b)}},addSelectedNodes:b=>{const{multiSelectionActive:m,edgeLookup:E,nodeLookup:h,triggerNodeChanges:x,triggerEdgeChanges:k}=g();if(m){const S=b.map(I=>ke(I,!0));x(S);return}x(Le(h,new Set([...b]),!0)),k(Le(E))},addSelectedEdges:b=>{const{multiSelectionActive:m,edgeLookup:E,nodeLookup:h,triggerNodeChanges:x,triggerEdgeChanges:k}=g();if(m){const S=b.map(I=>ke(I,!0));k(S);return}k(Le(E,new Set([...b]))),x(Le(h,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:m}={})=>{const{edges:E,nodes:h,nodeLookup:x,triggerNodeChanges:k,triggerEdgeChanges:S}=g(),I=b||h,D=m||E,j=[];for(const A of I){if(!A.selected)continue;const $=x.get(A.id);$&&($.selected=!1),j.push(ke(A.id,!1))}const B=[];for(const A of D)A.selected&&B.push(ke(A.id,!1));k(j),S(B)},setMinZoom:b=>
41{const{panZoom:m,maxZoom:E}=g();m==null||m.setScaleExtent([b,E]),p({minZoom:b})},setMaxZoom:b=>{const{panZoom:m,minZoom:E}=g();m==null||m.setScaleExtent([E,b]),p({maxZoom:b})},setTranslateExtent:b=>{var m;(m=g().panZoom)==null||m.setTranslateExtent(b),p({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:m,triggerNodeChanges:E,triggerEdgeChanges:h,elementsSelectable:x}=g();if(!x)return;const k=m.reduce((I,D)=>D.selected?[...I,ke(D.id,!1)]:I,[]),S=b.reduce((I,D)=>D.selected?[...I,ke(D.id,!1)]:I,[]);E(k),h(S)},setNodeExtent:b=>{const{nodes:m,nodeLookup:E,parentLookup:h,nodeOrigin:x,elevateNodesOnSelect:k,nodeExtent:S,zIndexMode:I}=g();b[0][0]===S[0][0]&&b[0][1]===S[0][1]&&b[1][0]===S[1][0]&&b[1][1]===S[1][1]||(vn(m,E,h,{nodeOrigin:x,nodeExtent:b,elevateNodesOnSelect:k,checkEquality:!1,zIndexMode:I}),p({nodeExtent:b}))},panBy:b=>{const{transform:m,width:E,height:h,panZoom:x,translateExtent:k}=g();return od({delta:b,panZoom:x,transform:m,translateExtent:k,width:E,height:h})},setCenter:async(b,m,E)=>{const{width:h,height:x,maxZoom:k,panZoom:S}=g();if(!S)return Promise.resolve(!1);const I=typeof(E==null?void 0:E.zoom)<"u"?E.zoom:k;return await S.setViewport({x:h/2-b*I,y:x/2-m*I,zoom:I},{duration:E==null?void 0:E.duration,ease:E==null?void 0:E.ease,interpolate:E==null?void 0:E.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...Dr}})},updateConnection:b=>{p({connection:b})},reset:()=>p({...Fo()})}},Object.is);function Oi({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:u,nodeOrigin:f,nodeExtent:l,zIndexMode:d,children:p}){const[g]=P.useState(()=>hh({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:u,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:f,nodeExtent:l,zIndexMode:d}));return y.jsx(Pd,{value:g,children:y.jsx(ef,{children:p})})}function gh({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:l,nodeExtent:d,zIndexMode:p}){return P.useContext(Gt)?y.jsx(y.Fragment,{children:e}):y.jsx(Oi,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:f,nodeOrigin:l,nodeExtent:d,zIndexMode:p,children:e})}const ph={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function mh({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:u,onMove:f,onMoveStart:l,onMoveEnd:d,onConnect:p,onConnectStart:g,onConnectEnd:w,onClickConnectStart:b,onClickConnectEnd:m,onNodeMouseEnter:E,onNodeMouseMove:h,onNodeMouseLeave:x,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:I,onNodeDrag:D,onNodeDragStop:j,onNodesDelete:B,onEdgesDelete:A,onDelete:$,onSelectionChange:R,onSelectionDragStart:_,onSelectionDrag:T,onSelectionDragStop:v,onSelectionContextMenu:M,onSelectionStart:C,onSelectionEnd:N,onBeforeDelete:z,connectionMode:H,connectionLineType:L=Ce.Bezier,connectionLineStyle:V,connectionLineComponent:F,connectionLineContainerStyle:X,deleteKeyCode:W="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:O=!1,selectionMode:G=st.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:Z=ct()?"Meta":"Control",zoomActivationKeyCode:U=ct()?"Meta":"Control",snapToGrid:K,snapGrid:te,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:ee,nodesDraggable:se,autoPanOnNodeFocus:_e,nodesConnectable:me,nodesFocusable:Se,nodeOrigin:We=gi,edgesFocusable:qe,edgesReconnectable:Ge,elementsSelectable:Qt=!0,defaultViewport:mt=Yd,minZoom:je=.5,maxZoom:Ke=2,translateExtent:Bn=it,preventScrolling:Zi=!0,nodeExtent:Jt,defaultMarkerColor:Qi="#b1b1b7",zoomOnScroll:Ji=!0,zoomOnPinch:es=!0,panOnScroll:ts=!1,panOnScrollSpeed:ns=.5,panOnScrollMode:os=Ie.Free,zoomOnDoubleClick:rs=!0,panOnDrag:is=!0,onPaneClick:ss,onPaneMouseEnter:as,onPaneMouseMove:cs,onPaneMouseLeave:ls,onPaneScroll:us,onPaneContextMenu:ds,paneClickDistance:fs=1,nodeClickDistance:hs=0,children:gs,onReconnect:ps,onReconnectStart:ms,onReconnectEnd:ys,onEdgeContextMenu:xs,onEdgeDoubleClick:ws,onEdgeMouseEnter:bs,onEdgeMouseMove:vs,onEdgeMouseLeave:_s,reconnectRadius:Ns=10,onNodesChange:Es,onEdgesChange:Cs,noDragClassName:Ss="nodrag",noWheelClassName:Ms="nowheel",noPanClassName:Vn="nopan",fitView:On,fitViewOptions:Fn,connectOnClick:ks,attributionPosition:Is,proOptions:As,defaultEdgeOptions:Ps,elevateNodesOnSelect:Ts=!0,elevateEdgesOnSelect:$s=!1,disableKeyboardA11y:Yn=!1,autoPanOnConnect:js,autoPanOnNodeDrag:zs,autoPanSpeed:Ds,connectionRadius:Ls,isValidConnection:Hs,onError:Rs,style:Bs,id:Xn,nodeDragThreshold:Vs,connectionDragThreshold:Os,viewport:Fs,onViewportChange:Ys,width:Xs,height:Ws,colorMode:qs="light",debug:Gs,onScroll:yt,ariaLabelConfig:Ks,zIndexMode:Wn="basic",...Us},Zs){const en=Xn||"1",Qs=Gd(qs),Js=P.useCallback(qn=>{qn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yt==null||yt(qn)},[yt]);return y.jsx("div",{"data-testid":"rf__wrapper",...Us,onScroll:Js,style:{...Bs,...ph},ref:Zs,className:ie(["react-flow",r,Qs]),id:Xn,role:"application",children:y.jsxs(gh,{nodes:e,edges:t,width:Xs,height:Ws,fitView:On,fitViewOptions:Fn,minZoom:je,maxZoom:Ke,nodeOrigin:We,no
41deExtent:Jt,zIndexMode:Wn,children:[y.jsx(fh,{onInit:u,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:E,onNodeMouseMove:h,onNodeMouseLeave:x,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:i,edgeTypes:s,connectionLineType:L,connectionLineStyle:V,connectionLineComponent:F,connectionLineContainerStyle:X,selectionKeyCode:q,selectionOnDrag:O,selectionMode:G,deleteKeyCode:W,multiSelectionKeyCode:Z,panActivationKeyCode:Q,zoomActivationKeyCode:U,onlyRenderVisibleElements:ne,defaultViewport:mt,translateExtent:Bn,minZoom:je,maxZoom:Ke,preventScrolling:Zi,zoomOnScroll:Ji,zoomOnPinch:es,zoomOnDoubleClick:rs,panOnScroll:ts,panOnScrollSpeed:ns,panOnScrollMode:os,panOnDrag:is,onPaneClick:ss,onPaneMouseEnter:as,onPaneMouseMove:cs,onPaneMouseLeave:ls,onPaneScroll:us,onPaneContextMenu:ds,paneClickDistance:fs,nodeClickDistance:hs,onSelectionContextMenu:M,onSelectionStart:C,onSelectionEnd:N,onReconnect:ps,onReconnectStart:ms,onReconnectEnd:ys,onEdgeContextMenu:xs,onEdgeDoubleClick:ws,onEdgeMouseEnter:bs,onEdgeMouseMove:vs,onEdgeMouseLeave:_s,reconnectRadius:Ns,defaultMarkerColor:Qi,noDragClassName:Ss,noWheelClassName:Ms,noPanClassName:Vn,rfId:en,disableKeyboardA11y:Yn,nodeExtent:Jt,viewport:Fs,onViewportChange:Ys}),y.jsx(qd,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:p,onConnectStart:g,onConnectEnd:w,onClickConnectStart:b,onClickConnectEnd:m,nodesDraggable:se,autoPanOnNodeFocus:_e,nodesConnectable:me,nodesFocusable:Se,edgesFocusable:qe,edgesReconnectable:Ge,elementsSelectable:Qt,elevateNodesOnSelect:Ts,elevateEdgesOnSelect:$s,minZoom:je,maxZoom:Ke,nodeExtent:Jt,onNodesChange:Es,onEdgesChange:Cs,snapToGri
41d:K,snapGrid:te,connectionMode:H,translateExtent:Bn,connectOnClick:ks,defaultEdgeOptions:Ps,fitView:On,fitViewOptions:Fn,onNodesDelete:B,onEdgesDelete:A,onDelete:$,onNodeDragStart:I,onNodeDrag:D,onNodeDragStop:j,onSelectionDrag:T,onSelectionDragStart:_,onSelectionDragStop:v,onMove:f,onMoveStart:l,onMoveEnd:d,noPanClassName:Vn,nodeOrigin:We,rfId:en,autoPanOnConnect:js,autoPanOnNodeDrag:zs,autoPanSpeed:Ds,onError:Rs,connectionRadius:Ls,isValidConnection:Hs,selectNodesOnDrag:ee,nodeDragThreshold:Vs,connectionDragThreshold:Os,onBeforeDelete:z,debug:Gs,ariaLabelConfig:Ks,zIndexMode:Wn}),y.jsx(Fd,{onSelectionChange:R}),gs,y.jsx(Hd,{proOptions:As,position:Is}),y.jsx(Ld,{rfId:en,disableKeyboardA11y:Yn})]})})}var yh=xi(mh);const xh=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function wh({children:e}){const t=J(xh);return t?oa.createPortal(e,t):null}const bh=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function vh(){return J(bh,oe)}function _h(e){const[t,n]=P.useState(e),o=P.useCallback(r=>n(i=>mi(r,i)),[]);return[t,n,o]}function Nh(e){const[t,n]=P.useState(e),o=P.useCallback(r=>n(i=>yi(r,i)),[]);return[t,n,o]}function Eh({dimensions:e,lineWidth:t,variant:n,className:o}){return y.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,o])})}function Ch({radius:e,className:t}){return y.jsx("circle",{cx:e,cy:e,r:e,className:ie(["react-flow__background-pattern","dots",t])})}var we;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(we||(we={}));const Sh={[we.Dots]:1,[we.Lines]:1,[we.Cross]:6},Mh=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Fi({id:e,variant:t=we.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:a,style:c,className:u,patternClassName:f}){const l=P.useRef(null),{transform:d,patternId:p}=J(Mh,oe),g=o||Sh[t],w=t===we.Dots,b=t===we.Cross,m=Array.isArray(n)?n:[n,n],E=[m[0]*d[2]||1,m[1]*d[2]||1],h=g*d[2],x=Array.isArray(i)?i:[i,i],k=b?[h,h]:E,S=[x[0]*d[2]||1+k[0]/2,x[1]*d[2]||1+k[1]/2],I=`${p}${e||""}`;return y.jsxs("svg",{className:ie(["react-flow__background",u]),style:{...c,...Zt,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:l,"data-testid":"rf__background",children:[y.jsx("pattern",{id:I,x:d[0]%E[0],y:d[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:w?y.jsx(Ch,{radius:h/2,className:f}):y.jsx(Eh,{dimensions:k,lineWidth:r,variant:t,className:f})}),y.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}Fi.displayName="Background";const kh=P.memo(Fi);function Ih(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:y.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Ah(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:y.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Ph(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:y.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 Th(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.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 $h(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.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 Et({children:e,className:t,...n}){return y.jsx("button",{type:"button",className:ie(["react-flow__controls-button",t]),...n,children:e})}const jh=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Yi({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:u,children:f,position:l="bottom-left",orientation:d="vertical","aria-label":p}){const g=re(),{isInteractive:w,minZoomReached:b,maxZoomReached:m,ariaLabelConfig:E}=J(jh,oe),{zoomIn:h,zoomOut:x,fitView:k}=Ut(),S=()=>{h(),i==null||i()},I=()=>{x(),s==null||s()},D=()=>{k(r),a==null||a()},j=()=>{g.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),c==null||c(!w)},B=d==="horizontal"?"horizontal":"vertical";return y.jsxs(Kt,{className:ie(["react-flow__controls",B,u]),position:l,style:e,"data-testid":"rf__controls","aria-label":p??E["controls.ariaLabel"],children:[t&&y.jsxs(y.Fragment,{children:[y.jsx(Et,{onClick:S,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:m,children:y.jsx(Ih,{})}),y.jsx(Et,{onClick:I,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:b,children:y.jsx(Ah,{})})]}),n&&y.jsx(Et,{className:"react-flow__controls-fitview",onClick:D,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:y.jsx(Ph,{})}),o&&y.jsx(Et,{className:"react-flow__controls-interactive",onClick:j,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:w?y.jsx($h,{}):y.jsx(Th,{})}),f]})}Yi.displayName="Controls";P.memo(Yi);function zh({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:a,strokeWidth:c,className:u,borderRadius:f,shapeRendering:l,selected:d,onClick:p}){const{background:g,backgroundColor:w}=i||{},b=s||g||w;return y.jsx("rect",{className:ie(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:f,ry:f,width:o,height:r,style:{fill:b,stroke:a,strokeWidth:c},shapeRendering:l,onClick:p?m=>p(m,e):void 0})}const Dh=P.memo(zh),Lh=e=>e.nodes.map(t=>
41t.id),un=e=>e instanceof Function?e:()=>e;function Hh({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=Dh,onClick:s}){const a=J(Lh,oe),c=un(t),u=un(e),f=un(n),l=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:a.map(d=>y.jsx(Bh,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:f,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:l},d))})}function Rh({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:u,x:f,y:l,width:d,height:p}=J(g=>{const w=g.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const b=w.internals.userNode,{x:m,y:E}=w.internals.positionAbsolute,{width:h,height:x}=ve(b);return{node:b,x:m,y:E,width:h,height:x}},oe);return!u||u.hidden||!Fr(u)?null:y.jsx(a,{x:f,y:l,width:d,height:p,style:u.style,selected:!!u.selected,className:o(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:i,shapeRendering:s,onClick:c,id:u.id})}const Bh=P.memo(Rh);var Vh=P.memo(Hh);const Oh=200,Fh=150,Yh=e=>!e.hidden,Xh=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?Or(ft(e.nodeLookup,{filter:Yh}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Wh="react-flow__minimap-desc";function Xi({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:u,maskStrokeColor:f,maskStrokeWidth:l,position:d="bottom-right",onClick:p,onNodeClick:g,pannable:w=!1,zoomable:b=!1,ariaLabel:m,inversePan:E,zoomStep:h=1,offsetScale:x=5}){const k=re(),S=P.useRef(null),{boundingRect:I,viewBB:D,rfId:j,panZoom:B,translateExtent:A,flowWidth:$,flowHeight:R,ariaLabelConfig:_}=J(Xh,oe),T=(e==null?void 0:e.width)??Oh,v=(e==null?void 0:e.height)??Fh,M=I.width/T,C=I.height/v,N=Math.max(M,C),z=N*T,H=N*v,L=x*N,V=I.x-(z-I.width)/2-L,F=I.y-(H-I.height)/2-L,X=z+L*2,W=H+L*2,q=`${Wh}-${j}`,O=P.useRef(0),G=P.useRef();O.current=N,P.useEffect(()=>{if(S.current&&B)return G.current=fd({domNode:S.current,panZoom:B,getTransform:()=>k.getState().transform,getViewScale:()=>O.current}),()=>{var K;(K=G.current)==null||K.destroy()}},[B]),P.useEffect(()=>{var K;(K=G.current)==null||K.update({translateExtent:A,width:$,height:R,inversePan:E,pannable:w,zoomStep:h,zoomable:b})},[w,b,E,h,A,$,R]);const Q=p?K=>{var ee;const[te,ne]=((ee=G.current)==null?void 0:ee.pointer(K))||[0,0];p(K,{x:te,y:ne})}:void 0,Z=g?P.useCallback((K,te)=>{const ne=k.getState().nodeLookup.get(te).internals.userNode;g(K,ne)},[]):void 0,U=m??_["minimap.ariaLabel"];return y.jsx(Kt,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof l=="number"?l*N:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o: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:y.jsxs("svg",{width:T,height:v,viewBox:`${V} ${F} ${X} ${W}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":q,ref:S,onClick:Q,children:[U&&y.jsx("title",{id:q,children:U}),y.jsx(Vh,{onClick:Z,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),y.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-L},${F-L}h${X+L*2}v${W+L*2}h${-X-L*2}z 42 M${D.x},${D.y}h${D.width}v${D.height}h${-D.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Xi.displayName="MiniMap";P.memo(Xi);const qh=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Gh={[Xe.Line]:"right",[Xe.Handle]:"bottom-right"};function Kh({nodeId:e,position:t,variant:n=Xe.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:l=!1,resizeDirection:d,autoScale:p=!0,shouldResize:g,onResizeStart:w,onResize:b,onResizeEnd:m}){const E=_i(),h=typeof e=="string"?e:E,x=re(),k=P.useRef(null),S=n===Xe.Handle,I=J(P.useCallback(qh(S&&p),[S,p]),oe),D=P.useRef(null),j=t??Gh[n];P.useEffect(()=>{if(!(!k.current||!h))return D.current||(D.current=Sd({domNode:k.current,nodeId:h,getStoreItems:()=>
42{const{nodeLookup:A,transform:$,snapGrid:R,snapToGrid:_,nodeOrigin:T,domNode:v}=x.getState();return{nodeLookup:A,transform:$,snapGrid:R,snapToGrid:_,nodeOrigin:T,paneDomNode:v}},onChange:(A,$)=>{const{triggerNodeChanges:R,nodeLookup:_,parentLookup:T,nodeOrigin:v}=x.getState(),M=[],C={x:A.x,y:A.y},N=_.get(h);if(N&&N.expandParent&&N.parentId){const z=N.origin??v,H=A.width??N.measured.width??0,L=A.height??N.measured.height??0,V={id:N.id,parentId:N.parentId,rect:{width:H,height:L,...Yr({x:A.x??N.position.x,y:A.y??N.position.y},{width:H,height:L},N.parentId,_,z)}},F=Hn([V],_,T,v);M.push(...F),C.x=A.x?Math.max(z[0]*H,A.x):void 0,C.y=A.y?Math.max(z[1]*L,A.y):void 0}if(C.x!==void 0&&C.y!==void 0){const z={id:h,type:"position",position:{...C}};M.push(z)}if(A.width!==void 0&&A.height!==void 0){const H={id:h,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};M.push(H)}for(const z of $){const H={...z,type:"position"};M.push(H)}R(M)},onEnd:({width:A,height:$})=>{const R={id:h,type:"dimensions",resizing:!1,dimensions:{width:A,height:$}};x.getState().triggerNodeChanges([R])}})),D.current.update({controlPosition:j,boundaries:{minWidth:a,minHeight:c,maxWidth:u,maxHeight:f},keepAspectRatio:l,resizeDirection:d,onResizeStart:w,onResize:b,onResizeEnd:m,shouldResize:g}),()=>{var A;(A=D.current)==null||A.destroy()}},[j,a,c,u,f,l,w,b,m,g]);const B=j.split("-");return y.jsx("div",{className:ie(["react-flow__resize-control","nodrag",...B,n,o]),ref:k,style:{...r,scale:I,...s&&{[S?"backgroundColor":"borderColor"]:s}},children:i})}P.memo(Kh);const Uh={review_content:En,approve_content:rr,request_changes:sr,publish_content:Ko,send_notification:Go,auto_quality_check:qo,seo_check:Wo,schedule_publication:Xo},Zh={review_content:"border-blue-200 bg-blue-50",approve_content:"border-emerald-200 bg-emerald-50",request_changes:"border-amber-200 bg-amber-50",publish_content:"border-violet-200 bg-violet-50",send_notification:"border-orange-200 bg-orange-50",auto_quality_check:"border-teal-200 bg-teal-50",seo_check:"border-cyan-200 bg-cyan-50",schedule_publication:"border-indigo-200 bg-indigo-50"},Qh={review_content:"text-blue-600 bg-blue-100",approve_content:"text-emerald-600 bg-emerald-100",request_changes:"text-amber-600 bg-amber-100",publish_content:"text-violet-600 bg-violet-100",
42send_notification:"text-orange-600 bg-orange-100",auto_quality_check:"text-teal-600 bg-teal-100",seo_check:"text-cyan-600 bg-cyan-100",schedule_publication:"text-indigo-600 bg-indigo-100"},Wi=P.memo(({id:e,data:t,selected:n})=>{const[o,r]=P.useState(!1),i=t.subtype,s=Uh[i]||En,a=Zh[i]||"border-gray-200 bg-gray-50",c=Qh[i]||"text-gray-600 bg-gray-100",u=t.label,f=t.onEdit,l=t.onDelete;return y.jsxs("div",{className:`relative min-w-[200px] rounded-xl border-2 ${a} shadow-soft px-4 py-3 cursor-grab active:cursor-grabbing transition-shadow ${n?"ring-2 ring-claude-accent ring-offset-2":""}`,children:[y.jsx(le,{type:"target",position:Y.Top,className:"!w-3 !h-3 !bg-claude-border-strong !border-2 !border-white"}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("div",{className:`h-8 w-8 rounded-lg flex items-center justify-center ${c}`,children:y.jsx(s,{className:"h-4 w-4"})}),y.jsx("span",{className:"text-sm font-medium text-claude-text flex-1",children:u}),y.jsx("button",{onClick:d=>{d.stopPropagation(),r(!o)},className:"p-1 rounded-lg hover:bg-white/60 transition-colors",children:y.jsx(ir,{className:"h-4 w-4 text-claude-text-tertiary"})})]}),o&&y.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-white rounded-xl border border-claude-border shadow-dropdown z-50 py-1 min-w-[140px]",children:[y.jsx("button",{onClick:()=>{f==null||f(e),r(!1)},className:"w-full text-left px-3 py-2 text-sm text-claude-text hover:bg-claude-bg-alt transition-colors",children:"Edit Config"}),y.jsx("button",{onClick:()=>{l==null||l(e),r(!1)},className:"w-full text-left px-3 py-2 text-sm text-claude-danger hover:bg-claude-danger-light transition-colors",children:"Delete"})]}),y.jsx(le,{type:"source",position:Y.Bottom,className:"!w-3 !h-3 !bg-claude-border-strong !border-2 !border-white"})]})});Wi.displayName="ActionNode";const Jh={if_approved:ar,if_changes_requested:tr,if_quality_score:or,if_seo_pass:er},qi=P.memo(({id:e,data:t,selected:n})=>{const[o,r]=P.useState(!1),i=t.subtype,s=Jh[i]||ra,a=t.label,c=t.onEdit,u=t.onDelete;return y.jsxs("div",{className:`relative min-w-[220px] rounded-xl border-2 border-purple-200 bg-purple-50 shadow-soft px-4 py-3 cursor-grab active:cursor-grabbing transition-shadow ${n?"ring-2 ring-claude-accent ring-offset-2":""}`,children:[y.jsx(le,{type:"target",position:Y.Top,className:"!w-3 !h-3 !bg-claude-border-strong !border-2 !border-white"}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("div",{className:"h-8 w-8 rounded-lg flex items-center justify-center bg-purple-100 text-purple-600",children:y.jsx(s,{className:"h-4 w-4"})}),y.jsx("span",{className:"text-sm font-medium text-claude-text flex-1",children:a}),y.jsx("button",{onClick:f=>{f.stopPropagation(),r(!o)},className:"p-1 rounded-lg hover:bg-white/60 transition-colors",children:y.jsx(ir,{className:"h-4 w-4 text-claude-text-tertiary"})})]}),y.jsxs("div",{className:"flex justify-between mt-2 px-1",children:[y.jsx("span",{className:"text-[10px] font-semibold text-claude-danger",children:"No"}),y.jsx("span",{className:"text-[10px] font-semibold text-claude-success",children:"Yes"})]}),o&&y.jsxs("div",{className:"absolute top-full right-0 mt-1 bg-white rounded-xl border border-claude-border shadow-dropdown z-50 py-1 min-w-[140px]",children:[y.jsx("button",{onClick:()=>{c==null||c(e),r(!1)},className:"w-full text-left px-3 py-2 text-sm text-claude-text hover:bg-claude-bg-alt transition-colors",children:"Edit Config"}),y.jsx("button",{onClick:()=>{u==null||u(e),r(!1)},className:"w-full text-left px-3 py-2 text-sm text-claude-danger hover:bg-claude-danger-light transition-colors",children:"Delete"})]}),y.jsx(le,{type:"source",position:Y.Bottom,id:"no",className:"!w-3 !h-3 !bg-red-400 !border-2 !border-white",style:{left:"25%"}}),y.jsx(le,{type:"source",position:Y.Bottom,id:"yes",className:"!w-3 !h-3 !bg-emerald-400 !border-2 !border-white",style:{left:"75%"}})]})});qi.displayName="ConditionNode";function eg(e,t){return e===1?`1 ${t.replace(/s$/,"")}`:`${e} ${t}`}const Gi=P.memo(({id:e,data:t,selected:n})=>{const o=t.delay||{duration:1,unit:"days"},r=eg(o.duration,o.unit),i=t.onEdit;return y.jsxs("div",{className:`relative cursor-pointer transition-shadow ${n?"ring-2 ring-claude-accent ring-offset-2 rounded-full":""}`,onClick:()=>i==null?void 0:i(e),children:[y.jsx(le,{type:"target",position:Y.Top,className:"!w-2 !h-2 !bg-transparent !border-0"}),y.jsxs("div",{className:"inline-flex items-center gap-1.5 bg-purple-100 border border-purple-200 rounded-full px-3 py-1.5",children:[y.jsx(nr,{className:"h-3.5 w-3.5 text-purple-600"}),y.jsx("span",{className:"text-xs font-medium text-purple-700",children:r})]}),y.jsx(le,{type:"source",position:Y.Bottom,className:"!w-2 !h-2 !bg-transparent !border-0"})]})});Gi.displayName="DelayNode";const Ki=P.memo(({id:e,data:t,selected:n})=>{const o=t.onAdd,r=t.onEnd;return y.jsxs("div",{className:`relative transition-shadow ${n?"ring-2 ring-claude-accent ring-offset-2 rounded-xl":""}`,children:[y.jsx(le,{type:"target",position:Y.Top,className:"!w-2 !h-2 !bg-transparent !border-0"}),y.jsxs("div",{className:"inline-flex items-center bg-white border border-claude-border rounded-xl overflow-hidden shadow-soft",children:[y.jsxs("button",{onClick:i=>{i.stopPropagation(),o==null||o(e)},className:"flex items-center gap-1.5 px-3 py-2 text-sm font-medium text-claude-text hover:bg-claude-bg-alt transition-colors border-r border-claude-border",children:[y.jsx(Uo,{className:"h-3.5 w-3.5 text-claude-success"}),"Add"]}),y.jsxs("button",{onClick:i=>{i.stopPropagation(),r==null||r(e)},className:"flex items-center gap-1.5 px-3 py-2 text-sm font-medium text-claude-text-secondary hover:bg-claude-bg-alt transition-colors",children:[y.jsx(Zo,{className:"h-3.5 w-3.5 text-claude-text-tertiary"}),"End"]})]})]})});
42Ki.displayName="AddEndControls";const Ui=P.memo(({id:e,sourceX:t,sourceY:n,targetX:o,targetY:r,sourcePosition:i,targetPosition:s,data:a,selected:c})=>{const[u,f,l]=Ht({sourceX:t,sourceY:n,targetX:o,targetY:r,sourcePosition:i,targetPosition:s,borderRadius:16}),p={green:"text-emerald-600 bg-emerald-50 border-emerald-200",red:"text-red-600 bg-red-50 border-red-200",default:"text-claude-text-secondary bg-white border-claude-border"}[(a==null?void 0:a.labelColor)||"default"];return y.jsxs(y.Fragment,{children:[y.jsx(pt,{id:e,path:u,style:{strokeDasharray:"6 4",stroke:c?"#C96442":"#D4C9B9",strokeWidth:1.5}}),(a==null?void 0:a.label)&&y.jsx(wh,{children:y.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${f}px,${l}px)`,pointerEvents:"all"},className:`text-[11px] font-semibold px-2 py-0.5 rounded-full border ${p}`,children:a.label})})]})});Ui.displayName="DashedEdge";const tg=[{subtype:"review_content",label:"Review Content",icon:En,category:"action"},{subtype:"approve_content",label:"Approve Content",icon:rr,category:"action"},{subtype:"request_changes",label:"Request Changes",icon:sr,category:"action"},{subtype:"publish_content",label:"Publish Content",icon:Ko,category:"action"},{subtype:"send_notification",label:"Send Notification",icon:Go,category:"action"},{subtype:"auto_quality_check",label:"Auto Quality Check",icon:qo,category:"action"},{subtype:"seo_check",label:"SEO Check",icon:Wo,category:"action"},{subtype:"schedule_publication",label:"Schedule Publication",icon:Xo,category:"action"}],ng=[{subtype:"if_approved",label:"If Approved",icon:ar,category:"condition"},{subtype:"if_changes_requested",label:"If Changes Requested",icon:tr,category:"condition"},{subtype:"if_quality_score",label:"If Quality Score Pass",icon:or,category:"condition"},{subtype:"if_seo_pass",label:"If SEO Score Pass",icon:er,category:"condition"}],og={subtype:"delay",label:"Time Delay",icon:nr,category:"delay"};function rg(e,t){e.dataTransfer.setData("application/workflow-node",JSON.stringify(t)),e.dataTransfer.effectAllowed="move"}function dn({item:e}){const t=e.icon;return y.jsxs("div",{draggable:!0,onDragStart:n=>rg(n,e),className:"flex items-center gap-2.5 px-3 py-2 rounded-lg border border-claude-border bg-white hover:bg-claude-bg-alt hover:border-claude-border-strong cursor-grab active:cursor-grabbing transition-all text-sm text-claude-text",children:[y.jsx(t,{className:"h-4 w-4 text-claude-text-secondary flex-shrink-0"}),y.jsx("span",{className:"font-medium",children:e.label})]})}const Yo=({className:e})=>y.jsxs("div",{className:ia("w-[260px] flex-shrink-0 bg-claude-surface border-r border-claude-border overflow-y-auto p-4 space-y-5",e),children:[y.jsxs("div",{children:[y.jsx("h3",{className:"text-xs font-semibold text-claude-text-tertiary uppercase tracking-wider mb-2.5",children:"Actions"}),y.jsx("div",{className:"space-y-1.5",children:tg.map(t=>y.jsx(dn,{item:t},t.subtype))})]}),y.jsxs("div",{children:[y.jsx("h3",{className:"text-xs font-semibold text-claude-text-tertiary uppercase tracking-wider mb-2.5",children:"Conditions"}),y.jsx("div",{className:"space-y-1.5",children:ng.map(t=>y.jsx(dn,{item:t},t.subtype))})]}),y.jsxs("div",{children:[y.jsx("h3",{className:"text-xs font-semibold text-claude-text-tertiary uppercase tracking-wider mb-2.5",children:"Timing"}),y.jsx(dn,{item:og})]})]});function ig({onSave:e,isSaving:t}){const{zoomIn:n,zoomOut:o,fitView:r}=Ut(),{zoom:i}=vh(),s=Math.round(i*100);return y.jsxs("div",{className:"absolute top-4 right-4 z-10 flex flex-col bg-white rounded-xl border border-claude-border shadow-card overflow-hidden",children:[y.jsx("button",{onClick:()=>n({duration:200}),className:"p-2.5 hover:bg-claude-bg-alt transition-colors border-b border-claude-border",title:"Zoom in",children:y.jsx(Uo,{className:"h-4 w-4 text-claude-text-secondary"})}),y.jsxs("div",{className:"px-2.5 py-1.5 text-[11px] font-medium text-claude-text-tertiary text-center border-b border-claude-border min-w-[48px]",children:[s,"%"]}),y.jsx("button",{onClick:()=>o({duration:200}),className:"p-2.5 hover:bg-claude-bg-alt transition-colors border-b border-claude-border",title:"Zoom out",children:y.jsx(Zo,{className:"h-4 w-4 text-claude-text-secondary"})}),y.jsx("button",{onClick:()=>r({duration:300,padding:.2}),className:"p-2.5 hover:bg-claude-bg-alt transition-colors border-b border-claude-border",title:"Fit to view",children:y.jsx(ya,{className:"h-4 w-4 text-claude-text-secondary"})}),e&&y.jsx("button",{onClick:e,disabled:t,className:"p-2.5 hover:bg-claude-bg-alt transition-colors disabled:opacity-50",title:"Save workflow",children:y.jsx(pa,{className:"h-4 w-4 text-claude-text-secondary"})})]})}function sg({isOpen:e,nodeId:t,nodeData:n,onSave:o,onClose:r}){var b,m,E,h;const[i,s]=P.useState(n.label),[a,c]=P.useState(((b=n.config)==null?void 0:b.notes)||""),[u,f]=P.useState(n.type==="delay"&&((m=n.delay)==null?void 0:m.duration)||1),[l,d]=P.useState(n.type==="delay"&&((E=n.delay)==null?void 0:E.unit)||"days"),[p,g]=P.useState(((h=n.config)==null?void 0:h.threshold)||80);if(P.useEffect(()=>{var x,k,S,I;s(n.label),c(((x=n.config)==null?void 0:x.notes)||""),n.type==="delay"&&(f(((k=n.delay)==null?void 0:k.duration)||1),d(((S=n.delay)==null?void 0:S.unit)||"days")),(I=n.config)!=null&&I.threshold&&g(n.config.threshold)},[n]),!e)return null;const w=()=>{const x={label:i,config:{...n.config,notes:a}};n.type==="delay"&&(x.delay={duration:u,unit:l}),n.type==="condition"&&(x.config={...x.config,threshold:p}),o(t,x),r()};return y.jsx("div",{className:"fixed inset-0 z-50 bg-black/30 backdrop-blur-sm overflow-y-auto",role:"presentation",onClick:r,children:y.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:x=>x.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"node-config-title",children:y.jsxs("div",{className:"relative bg-white w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-md overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-elevated",children:[y.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 sm:px-5 py-4 border-b border-claude-border bg-white/85 backdrop-blur-md",children:[y.jsxs("h3",{id:"node-config-title",className:"text-base font-semibold text-claude-text truncate",children:["Configure ",n.type==="action"?"Action":n.type==="condition"?"Condition":"Delay"]}),y.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-claude-bg-alt transition-colors shrink-0","aria-label":"Close",children:y.jsx(Qo,{className:"h-4 w-4 text-claude-text-tertiary"})})]}),y.jsxs("div",{className:"p-4 sm:p-5 space-y-4 flex-1 min-h-0 overflow-y-auto",children:[y.jsx(Jo,{id:"node-label",label:"Label",value:i,onChange:x=>s(x.target.value),placeholder:"Step name"}),n.type==="delay"&&y.jsxs("div",{children:[y.jsx("label",{className:"block text-sm font-medium text-claude-text mb-1.5",children:"Wait Duration"}),y.jsxs("div",{className:"flex gap-2 items-center",children:[y.jsx("input",{type:"number",min:1,value:u,onChange:x=>f(parseInt(x.target.value)||1),className:"block w-20 rounded-xl border border-claude-border bg-claude-surface px-3 py-2.5 text-sm text-claude-text focus:border-claude-accent focus:ring-2 focus:ring-primary-100 focus:outline-none transition-all"}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx(sa,{id:"delay-unit",value:l,onCh
42ange:x=>d(x.target.value),options:[{value:"minutes",label:"Minutes"},{value:"hours",label:"Hours"},{value:"days",label:"Days"}]})})]})]}),n.type==="condition"&&y.jsxs("div",{children:[y.jsx("label",{className:"block text-sm font-medium text-claude-text mb-1.5",children:"Threshold Score"}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("input",{type:"range",min:0,max:100,value:p,onChange:x=>g(parseInt(x.target.value)),className:"flex-1 accent-claude-accent"}),y.jsxs("span",{className:"text-sm font-medium text-claude-text w-10 text-right",children:[p,"%"]})]})]}),y.jsxs("div",{children:[y.jsx("label",{className:"block text-sm font-medium text-claude-text mb-1.5",children:"Notes"}),y.jsx("textarea",{value:a,onChange:x=>c(x.target.value),rows:3,className:"block w-full rounded-xl border border-claude-border bg-claude-surface px-4 py-2.5 text-sm text-claude-text placeholder:text-claude-text-tertiary focus:border-claude-accent focus:ring-2 focus:ring-primary-100 focus:outline-none transition-all",placeholder:"Optional notes for this step..."})]})]}),y.jsxs("div",{className:"sticky bottom-0 z-10 flex justify-end gap-2 px-4 sm:px-5 py-4 border-t border-claude-border bg-claude-bg",children:[y.jsx(fn,{variant:"outline",size:"sm",onClick:r,className:"flex-1 sm:flex-none",children:"Cancel"}),y.jsx(fn,{size:"sm",onClick:w,className:"flex-1 sm:flex-none",children:"Save Changes"})]})]})})})}const ag={ai_news:0,ideas:1,create_content:2,content_approval:4,schedule:6,publish:8};function cg(e){const t=e.data,n=(t==null?void 0:t.subtype)||"",r={review_content:"create_content",seo_check:"create_content",auto_quality_check:"create_content",approve_content:"content_approval",request_changes:"content_approval",schedule_publication:"schedule",publish_content:"publish",send_notification:"",if_approved:"",if_changes_requested:"",if_quality_score:"",if_seo_pass:"",delay:""}[n];return r===""?null:r||null}function Ct(e){const t=cg(e);if(!t)return null;const n=ag[t];return typeof n=="number"?n:null}const lg={action:Wi,condition:qi,delay:Gi,addEnd:Ki},ug={dashed:Ui},dg={type:"dashed",animated:!1};let fg=0;function Je(){return`node_${Date.now()}_${fg++}`}function hg(){const{id:e}=aa(),t=ca(),n=la(),o=P.useRef(null),r=e==="new",[i,s]=P.useState(""),[a,c]=P.useState(""),[u,f]=P.useState(!1),[l,d,p]=_h([]),[g,w,b]=Nh([]),[m,E]=P.useState(!1),[h,x]=P.useState({isOpen:!1,nodeId:"",nodeData:{type:"action",subtype:"review_content",label:"",config:{}}}),k=P.useCallback(v=>{d(M=>{const C=M.find(N=>N.id===v);return C&&x({isOpen:!0,nodeId:v,nodeData:C.data}),M})},[d]),S=P.useCallback(v=>{d(M=>M.filter(C=>C.id!==v)),w(M=>M.filter(C=>C.source!==v&&C.target!==v))},[d,w]),I=P.useCallback(v=>{Ue("Drag a step from the sidebar onto the canvas",{icon:"ð"})},[]),D=P.useCallback(v=>{d(M=>M.filter(C=>C.id!==v)),w(M=>M.filter(C=>C.target!==v))},[d,w]),j=P.useMemo(()=>l.map(v=>({...v,data:{...v.data,onEdit:k,onDelete:S,onAdd:I,onEnd:D}})),[l,k,S,I,D]),{isLoading:B}=ua({queryKey:["workflow-template",e],queryFn:async()=>{var M,C;if(r)return null;const{data:v}=await nn.getTemplate(e);return s(v.name),c(v.description),f(v.approval_gate_enabled??!1),(M=v.definition)!=null&&M.nodes&&d(v.definition.nodes.map(N=>{var z,H,L,V,F,X,W,q;return{...N,type:((z=N.data)==null?void 0:z.type)==="action"?"action":((H=N.data)==null?void 0:H.type)==="condition"?"condition":((L=N.data)==null?void 0:L.type)==="delay"?"delay":((V=N.data)==null?void 0:V.type)==="add_end"?"addEnd":(((F=N.data)==null?void 0:F.type)==="approval"||((X=N.data)==null?void 0:X.type)==="auto_check"||((W=N.data)==null?void 0:W.type)==="notification"||((q=N.data)==null?void 0:q.type)==="gate","action")}})),(C=v.definition)!=null&&C.edges&&w(v.definition.edges.map(N=>({...N,type:"dashed"}))),v},enabled:!r}),A=da({mutationFn:async()=>{const v=l.map(N=>{const{onEdit:z,onDelete:H,onAdd:L,onEnd:V,...F}=N.data;return{id:N.id,type:N.type,position:N.position,data:F}}),M=g.map(N=>({id:N.id,source:N.source,target:N.target,sourceHandle:N.sourceHandle,targetHandle:N.targetHandle,label:N.label,type:N.type,data:N.data||void 0})),C={name:i,description:a,approval_gate_enabled:u,definition:{nodes:v,edges:M}};return r?(await nn.createTemplate(C)).data:(await nn.updateTemplate(e,C)).data},onSuccess:v=>{n.invalidateQueries({queryKey:["workflow-templates"]}
42),Ue.success("Workflow saved"),r&&t(`/workflows/${v.id}`,{replace:!0})},onError:()=>Ue.error("Failed to save workflow")}),$=P.useCallback(v=>{var H,L;if(v.source===v.target){Ue.error("A step cannot connect to itself.");return}const M=l.find(V=>V.id===v.source),C=l.find(V=>V.id===v.target);if(M&&C){const V=Ct(M),F=Ct(C);if(V!==null&&F!==null&&V>F){const X=((H=M.data)==null?void 0:H.label)||"Source",W=((L=C.data)==null?void 0:L.label)||"Target";Ue.error(`Cannot connect "${X}" â "${W}": ordering would go backwards.`,{duration:4e3});return}}const N={},z=l.find(V=>V.id===v.source);(z==null?void 0:z.type)==="condition"&&(v.sourceHandle==="yes"?(N.label="Yes",N.labelColor="green"):v.sourceHandle==="no"&&(N.label="No",N.labelColor="red")),w(V=>Zr({...v,type:"dashed",data:Object.keys(N).length>0?N:void 0},V))},[l,w]),R=P.useCallback(v=>{v.preventDefault(),v.dataTransfer.dropEffect="move"},[]),_=P.useCallback(v=>{var H;v.preventDefault();const M=v.dataTransfer.getData("application/workflow-node");if(!M)return;const C=JSON.parse(M),N=(H=o.current)==null?void 0:H.getBoundingClientRect();if(!N)return;const z={x:v.clientX-N.left-100,y:v.clientY-N.top-25};if(C.category==="action"){const L={id:Je(),type:"action",position:z,data:{type:"action",subtype:C.subtype,label:C.label,config:{}}};d(V=>[...V,L])}else if(C.category==="condition"){const L=Je(),V=Je(),F=Je(),X={id:L,type:"condition",position:z,data:{type:"condition",subtype:C.subtype,label:C.label,config:{}}},W={id:V,type:"addEnd",position:{x:z.x+150,y:z.y+140},data:{type:"add_end",label:"Yes Branch",config:{}}},q={id:F,type:"addEnd",position:{x:z.x-150,y:z.y+140},data:{type:"add_end",label:"No Branch",config:{}}};d(Q=>[...Q,X,W,q]);const O={id:`edge_${L}_yes`,source:L,target:V,sourceHandle:"yes",type:"dashed",data:{label:"Yes",labelColor:"green"}},G={id:`edge_${L}_no`,source:L,target:F,sourceHandle:"no",type:"dashed",data:{label:"No",labelColor:"red"}};w(Q=>[...Q,O,G])}else if(C.category==="delay"){const L={id:Je(),type:"delay",position:z,data:{type:"delay",label:"1 day",delay:{duration:1,unit:"days"},config:{}}};d(V=>[...V,L])}},[d,w]),T=P.useCallback((v,M)=>{d(C=>C.map(N=>N.id!==v?N:{...N,data:{...N.data,...M}}))},[d]);return!r&&B?y.jsx(fa,{}):y.jsxs("div",{className:"flex flex-col h-[calc(100vh-64px)]",children:[y.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-3 bg-claude-surface border-b border-claude-border",children:[y.jsx("button",{onClick:()=>t("/workflows"),className:"p-1.5 rounded-lg hover:bg-claude-bg-alt transition-colors",children:y.jsx(ma,{className:"h-4 w-4 text-claude-text-secondary"})}),y.jsx("button",{type:"button",onClick:()=>E(!0),className:"lg:hidden p-1.5 rounded-lg hover:bg-claude-bg-alt transition-colors","aria-label":"Open step palette",title:"Steps",children:y.jsx(ha,{className:"h-4 w-4 text-claude-text-secondary"})}),y.jsxs("div",{className:"flex-1 flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4 min-w-0",children:[y.jsx(Jo,{id:"wf-name",value:i,onChange:v=>s(v.target.value),placeholder:"Workflow name...",className:"!w-full sm:!w-64 !py-1.5 !text-sm !rounded-lg"}),y.jsx("input",{value:a,onChange:v=>c(v.target.value),placeholder:"Description (optional)",className:"flex-1 min-w-0 max-w-none sm:max-w-sm text-sm text-claude-text-secondary bg-transparent border-none outline-none placeholder:text-claude-text-tertiary"})]}),y.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-xl border border-claude-border bg-claude-bg-alt w-full sm:w-auto",children:[y.jsx("button",{onClick:()=>f(!u),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none ${u?"bg-claude-accent":"bg-claude-border"}`,"aria-label":"Toggle approval gate",children:y.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-sm ${u?"translate-x-4":"translate-x-1"}`})}),y.jsx("span",{className:"text-xs font-medium text-claude-text-secondary",children:"Approval Gate"}),y.jsx("span",{className:"text-xs text-claude-text-tertiary",children:u?"â required before publishing":"â off"})]}),y.jsx(fn,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!i.trim(),className:"w-full sm:w-auto",children:A.isPending?"Saving...":"Save Workflow"})]}),y.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[y.jsx(Yo,{className:"hidden lg:block"}),y.jsxs("div",{className:["lg:hidden fixed inset-0 z-50",m?"pointer-events-auto":"pointer-events-none"].join(" "),"aria-hidden":!m,children:[y.jsx("button",{type:"button",className:["absolute inset-0 bg-black/40 transition-opacity",m?"opacity-100":"opacity-0"].join(" "),onClick:()=>E(!1),"aria-label":"Close palette overlay"}),y.jsxs("div",{className:["absolute left-0 top-0 bottom-0 w-[280px] max-w-[85vw] bg-claude-surface border-r border-claude-border","transition-transform duration-200",m?"translate-x-0":"-translate-x-full","flex flex-col"].join(" "),children:[y.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 h-14 border-b border-claude-border bg-claude-surface/85 backdrop-blur-md",children:[y.jsx("span",{className:"text-sm font-semibold text-claude-text",children:"Steps"}),y.jsx("button",{type:"button",onClick:()=>E(!1),className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt transition-colors","aria-label":"Close palette",children:y.jsx(Qo,{className:"h-4 w-4"})})]}),y.jsx(Yo,{className:"w-full border-r-0 flex-1"})]})]}),y.jsx("div",{className:"flex-1 relative",ref:o,children:y.jsxs(yh,{nodes:j,edges:g,onNodesChange:p,onEdgesChange:b,onConnect:$,isValidConnection:v=>{if(v.source===v.target)return!1;const M=l.find(H=>H.id===v.source),C=l.find(H=>H.id===v.target);if(!M||!C)return!1;const N=Ct(M),z=Ct(C);return N===null||z===null?!0:N<=z},onDrop:_,onDragOver:R,nodeTypes:lg,edgeTypes:ug,defaultEdgeOptions:dg,fitView:!0,fitViewOptions:{padding:.3},deleteKeyCode:["Backspace","Delete"],className:"bg-claude-bg",children:[y.jsx(kh,{variant:we.Dots,gap:20,size:1,color:"#D4C9B9"}),y.jsx(ig,{onSave:()=>A.mutate(),isSaving:A.isPending})]})})]}),y.jsx(sg,{isOpen:h.isOpen,nodeId:h.nodeId,nodeData:h.nodeData,onSave:T,onClose:()=>x(v=>({...v,isOpen:!1}))})]})}function _g(){return y.jsx(Oi,{children:y.jsx(hg,{})})}
42export{_g as WorkflowDesignerPage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.