import{r as b,g as Ps,R as A,j as Z}from"./index-CAah_nA8.js";import{i as Vt,a as Zn,b as Hs,d as Kn}from"./string-BbYD24iH.js";function ct(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=ct(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var Tr={exports:{}},Ir={},Dr={exports:{}},zr={};/**
 * @license React
 * use-sync-external-store-shim.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var se=b;function Bs(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var Fs=typeof Object.is=="function"?Object.is:Bs,Vs=se.useState,Ls=se.useEffect,Os=se.useLayoutEffect,Ys=se.useDebugValue;function Xs(t,e){var n=e(),r=Vs({inst:{value:n,getSnapshot:e}}),o=r[0].inst,s=r[1];return Os(function(){o.value=n,o.getSnapshot=e,rn(o)&&s({inst:o})},[t,n,e]),Ls(function(){return rn(o)&&s({inst:o}),t(function(){rn(o)&&s({inst:o})})},[t]),Ys(n),n}function rn(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!Fs(t,n)}catch{return!0}}function Ws(t,e){return e()}var Us=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Ws:Xs;zr.useSyncExternalStore=se.useSyncExternalStore!==void 0?se.useSyncExternalStore:Us;Dr.exports=zr;var Gs=Dr.exports;/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ue=b,Zs=Gs;function Ks(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var qs=typeof Object.is=="function"?Object.is:Ks,js=Zs.useSyncExternalStore,Qs=Ue.useRef,Js=Ue.useEffect,ti=Ue.useMemo,ei=Ue.useDebugValue;Ir.useSyncExternalStoreWithSelector=function(t,e,n,r,o){var s=Qs(null);if(s.current===null){var i={hasValue:!1,value:null};s.current=i}else i=s.current;s=ti(function(){function a(h){if(!l){if(l=!0,u=h,h=r(h),o!==void 0&&i.hasValue){var _=i.value;if(o(_,h))return f=_}return f=h}if(_=f,qs(u,h))return _;var w=r(h);return o!==void 0&&o(_,w)?(u=h,_):(u=h,f=w)}var l=!1,u,f,g=n===void 0?null:n;return[function(){return a(e())},g===null?void 0:function(){return a(g())}]},[e,n,r,o]);var c=js(t,s[0],s[1]);return Js(function(){i.hasValue=!0,i.value=c},[c]),ei(c),c};Tr.exports=Ir;var ni=Tr.exports;const ri=Ps(ni),oi={},qn=t=>{let e;const n=new Set,r=(u,f)=>{const g=typeof u=="function"?u(e):u;if(!Object.is(g,e)){const h=e;e=f??(typeof g!="object"||g===null)?g:Object.assign({},e,g),n.forEach(_=>_(e,h))}},o=()=>e,a={setState:r,getState:o,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(oi?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=e=t(r,o,a);return a},si=t=>t?qn(t):qn,{useDebugValue:ii}=A,{useSyncExternalStoreWithSelector:ci}=ri,ai=t=>t;function Rr(t,e=ai,n){const r=ci(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return ii(r),r}const jn=(t,e)=>{const n=si(t),r=(o,s=e)=>Rr(n,o,s);return Object.assign(r,n),r},li=(t,e)=>t?jn(t,e):jn;function st(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[r,o]of t)if(!Object.is(o,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}var ui={value:()=>{}};function Ge(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Re(n)}function Re(t){this._=t}function fi(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Re.prototype=Ge.prototype={constructor:Re,on:function(t,e){var n=this._,r=fi(t+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(t=r[s]).type)&&(o=di(n[o],t.name)))return o;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<i;)if(o=(t=r[s]).type)n[o]=Qn(n[o],t.name,e);else if(e==null)for(o in n)n[o]=Qn(n[o],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Re(t)},call:function(t,e){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,s;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],r=0,o=s.length;r<o;++r)s[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],o=0,s=r.length;o<s;++o)r[o].value.apply(e,n)}};function di(t,e){for(var n=0,r=t.length,o;n<r;++n)if((o=t[n]).name===e)return o.value}function Qn(t,e,n){for(var r=0,o=t.length;r<o;++r)if(t[r].name===e){t[r]=ui,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var hn="http://www.w3.org/1999/xhtml";const Jn={svg:"http://www.w3.org/2000/svg",xhtml:hn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ze(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Jn.hasOwnProperty(e)?{space:Jn[e],local:t}:t}function hi(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===hn&&e.documentElement.namespaceURI===hn?e.createElement(t):e.createElementNS(n,t)}}function gi(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Pr(t){var e=Ze(t);return(e.local?gi:hi)(e)}function mi(){}function Mn(t){return t==null?mi:function(){return this.querySelector(t)}}function pi(t){typeof t!="function"&&(t=Mn(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var s=e[o],i=s.length,c=r[o]=new Array(i),a,l,u=0;u<i;++u)(a=s[u])&&(l=t.call(a,a.__data__,u,s))&&("__data__"in a&&(l.__data__=a.__data__),c[u]=l);return new ht(r,this._parents)}function yi(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function wi(){return[]}function Hr(t){return t==null?wi:function(){return this.querySelectorAll(t)}}function _i(t){return function(){return yi(t.apply(this,arguments))}}function xi(t){typeof t=="function"?t=_i(t):t=Hr(t);for(var e=this._groups,n=e.length,r=[],o=[],s=0;s<n;++s)for(var i=e[s],c=i.length,a,l=0;l<c;++l)(a=i[l])&&(r.push(t.call(a,a.__data__,l,i)),o.push(a));return new ht(r,o)}function Br(t){return function(){return this.matches(t)}}function Fr(t){return function(e){return e.matches(t)}}var vi=Array.prototype.find;function Ei(t){return function(){return vi.call(this.children,t)}}function Si(){return this.firstElementChild}function bi(t){return this.select(t==null?Si:Ei(typeof t=="function"?t:Fr(t)))}var Ni=Array.prototype.filter;function Ai(){return Array.from(this.children)}function Mi(t){return function(){return Ni.call(this.children,t)}}function Ci(t){return this.selectAll(t==null?Ai:Mi(typeof t=="function"?t:Fr(t)))}function ki(t){typeof t!="function"&&(t=Br(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var s=e[o],i=s.length,c=r[o]=[],a,l=0;l<i;++l)(a=s[l])&&t.call(a,a.__data__,l,s)&&c.push(a);return new ht(r,this._parents)}function Vr(t){return new Array(t.length)}function $i(){return new ht(this._enter||this._groups.map(Vr),this._parents)}function Fe(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Fe.prototype={constructor:Fe,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function Ti(t){return function(){return t}}function Ii(t,e,n,r,o,s){for(var i=0,c,a=e.length,l=s.length;i<l;++i)(c=e[i])?(c.__data__=s[i],r[i]=c):n[i]=new Fe(t,s[i]);for(;i<a;++i)(c=e[i])&&(o[i]=c)}function Di(t,e,n,r,o,s,i){var c,a,l=new Map,u=e.length,f=s.length,g=new Array(u),h;for(c=0;c<u;++c)(a=e[c])&&(g[c]=h=i.call(a,a.__data__,c,e)+"",l.has(h)?o[c]=a:l.set(h,a));for(c=0;c<f;++c)h=i.call(t,s[c],c,s)+"",(a=l.get(h))?(r[c]=a,a.__data__=s[c],l.delete(h)):n[c]=new Fe(t,s[c]);for(c=0;c<u;++c)(a=e[c])&&l.get(g[c])===a&&(o[c]=a)}function zi(t){return t.__data__}function Ri(t,e){if(!arguments.length)return Array.from(this,zi);var n=e?Di:Ii,r=this._parents,o=this._groups;typeof t!="function"&&(t=Ti(t));for(var s=o.length,i=new Array(s),c=new Array(s),a=new Array(s),l=0;l<s;++l){var u=r[l],f=o[l],g=f.length,h=Pi(t.call(u,u&&u.__data__,l,r)),_=h.length,w=c[l]=new Array(_),p=i[l]=new Array(_),m=a[l]=new Array(g);n(u,f,w,p,m,h,e);for(var x=0,S=0,y,M;x<_;++x)if(y=w[x]){for(x>=S&&(S=x+1);!(M=p[S])&&++S<_;);y._next=M||null}}return i=new ht(i,r),i._enter=c,i._exit=a,i}function Pi(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Hi(){return new ht(this._exit||this._groups.map(Vr),this._parents)}function Bi(t,e,n){var r=this.enter(),o=this,s=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(o=e(o),o&&(o=o.selection())),n==null?s.remove():n(s),r&&o?r.merge(o).order():o}function Fi(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,o=n.length,s=r.length,i=Math.min(o,s),c=new Array(o),a=0;a<i;++a)for(var l=n[a],u=r[a],f=l.length,g=c[a]=new Array(f),h,_=0;_<f;++_)(h=l[_]||u[_])&&(g[_]=h);for(;a<o;++a)c[a]=n[a];return new ht(c,this._parents)}function Vi(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],o=r.length-1,s=r[o],i;--o>=0;)(i=r[o])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function Li(t){t||(t=Oi);function e(f,g){return f&&g?t(f.__data__,g.__data__):!f-!g}for(var n=this._groups,r=n.length,o=new Array(r),s=0;s<r;++s){for(var i=n[s],c=i.length,a=o[s]=new Array(c),l,u=0;u<c;++u)(l=i[u])&&(a[u]=l);a.sort(e)}return new ht(o,this._parents).order()}function Oi(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Yi(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Xi(){return Array.from(this)}function Wi(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],o=0,s=r.length;o<s;++o){var i=r[o];if(i)return i}return null}function Ui(){let t=0;for(const e of this)++t;return t}function Gi(){return!this.node()}function Zi(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var o=e[n],s=0,i=o.length,c;s<i;++s)(c=o[s])&&t.call(c,c.__data__,s,o);return this}function Ki(t){return function(){this.removeAttribute(t)}}function qi(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ji(t,e){return function(){this.setAttribute(t,e)}}function Qi(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Ji(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function tc(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function ec(t,e){var n=Ze(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?qi:Ki:typeof e=="function"?n.local?tc:Ji:n.local?Qi:ji)(n,e))}function Lr(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function nc(t){return function(){this.style.removeProperty(t)}}function rc(t,e,n){return function(){this.style.setProperty(t,e,n)}}function oc(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function sc(t,e,n){return arguments.length>1?this.each((e==null?nc:typeof e=="function"?oc:rc)(t,e,n??"")):ie(this.node(),t)}function ie(t,e){return t.style.getPropertyValue(e)||Lr(t).getComputedStyle(t,null).getPropertyValue(e)}function ic(t){return function(){delete this[t]}}function cc(t,e){return function(){this[t]=e}}function ac(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function lc(t,e){return arguments.length>1?this.each((e==null?ic:typeof e=="function"?ac:cc)(t,e)):this.node()[t]}function Or(t){return t.trim().split(/^|\s+/)}function Cn(t){return t.classList||new Yr(t)}function Yr(t){this._node=t,this._names=Or(t.getAttribute("class")||"")}Yr.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Xr(t,e){for(var n=Cn(t),r=-1,o=e.length;++r<o;)n.add(e[r])}function Wr(t,e){for(var n=Cn(t),r=-1,o=e.length;++r<o;)n.remove(e[r])}function uc(t){return function(){Xr(this,t)}}function fc(t){return function(){Wr(this,t)}}function dc(t,e){return function(){(e.apply(this,arguments)?Xr:Wr)(this,t)}}function hc(t,e){var n=Or(t+"");if(arguments.length<2){for(var r=Cn(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof e=="function"?dc:e?uc:fc)(n,e))}function gc(){this.textContent=""}function mc(t){return function(){this.textContent=t}}function pc(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function yc(t){return arguments.length?this.each(t==null?gc:(typeof t=="function"?pc:mc)(t)):this.node().textContent}function wc(){this.innerHTML=""}function _c(t){return function(){this.innerHTML=t}}function xc(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function vc(t){return arguments.length?this.each(t==null?wc:(typeof t=="function"?xc:_c)(t)):this.node().innerHTML}function Ec(){this.nextSibling&&this.parentNode.appendChild(this)}function Sc(){return this.each(Ec)}function bc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Nc(){return this.each(bc)}function Ac(t){var e=typeof t=="function"?t:Pr(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Mc(){return null}function Cc(t,e){var n=typeof t=="function"?t:Pr(t),r=e==null?Mc:typeof e=="function"?e:Mn(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function kc(){var t=this.parentNode;t&&t.removeChild(this)}function $c(){return this.each(kc)}function Tc(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ic(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Dc(t){return this.select(t?Ic:Tc)}function zc(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Rc(t){return function(e){t.call(this,e,this.__data__)}}function Pc(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Hc(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,o=e.length,s;n<o;++n)s=e[n],(!t.type||s.type===t.type)&&s.name===t.name?this.removeEventListener(s.type,s.listener,s.options):e[++r]=s;++r?e.length=r:delete this.__on}}}function Bc(t,e,n){return function(){var r=this.__on,o,s=Rc(e);if(r){for(var i=0,c=r.length;i<c;++i)if((o=r[i]).type===t.type&&o.name===t.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=s,o.options=n),o.value=e;return}}this.addEventListener(t.type,s,n),o={type:t.type,name:t.name,value:e,listener:s,options:n},r?r.push(o):this.__on=[o]}}function Fc(t,e,n){var r=Pc(t+""),o,s=r.length,i;if(arguments.length<2){var c=this.node().__on;if(c){for(var a=0,l=c.length,u;a<l;++a)for(o=0,u=c[a];o<s;++o)if((i=r[o]).type===u.type&&i.name===u.name)return u.value}return}for(c=e?Bc:Hc,o=0;o<s;++o)this.each(c(r[o],e,n));return this}function Ur(t,e,n){var r=Lr(t),o=r.CustomEvent;typeof o=="function"?o=new o(e,n):(o=r.document.createEvent("Event"),n?(o.initEvent(e,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(e,!1,!1)),t.dispatchEvent(o)}function Vc(t,e){return function(){return Ur(this,t,e)}}function Lc(t,e){return function(){return Ur(this,t,e.apply(this,arguments))}}function Oc(t,e){return this.each((typeof e=="function"?Lc:Vc)(t,e))}function*Yc(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],o=0,s=r.length,i;o<s;++o)(i=r[o])&&(yield i)}var Gr=[null];function ht(t,e){this._groups=t,this._parents=e}function Ae(){return new ht([[document.documentElement]],Gr)}function Xc(){return this}ht.prototype=Ae.prototype={constructor:ht,select:pi,selectAll:xi,selectChild:bi,selectChildren:Ci,filter:ki,data:Ri,enter:$i,exit:Hi,join:Bi,merge:Fi,selection:Xc,order:Vi,sort:Li,call:Yi,nodes:Xi,node:Wi,size:Ui,empty:Gi,each:Zi,attr:ec,style:sc,property:lc,classed:hc,text:yc,html:vc,raise:Sc,lower:Nc,append:Ac,insert:Cc,remove:$c,clone:Dc,datum:zc,on:Fc,dispatch:Oc,[Symbol.iterator]:Yc};function gt(t){return typeof t=="string"?new ht([[document.querySelector(t)]],[document.documentElement]):new ht([[t]],Gr)}function Wc(t){let e;for(;e=t.sourceEvent;)t=e;return t}function yt(t,e){if(t=Wc(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var o=e.getBoundingClientRect();return[t.clientX-o.left-e.clientLeft,t.clientY-o.top-e.clientTop]}}return[t.pageX,t.pageY]}const Uc={passive:!1},ve={capture:!0,passive:!1};function on(t){t.stopImmediatePropagation()}function re(t){t.preventDefault(),t.stopImmediatePropagation()}function Zr(t){var e=t.document.documentElement,n=gt(t).on("dragstart.drag",re,ve);"onselectstart"in e?n.on("selectstart.drag",re,ve):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Kr(t,e){var n=t.document.documentElement,r=gt(t).on("dragstart.drag",null);e&&(r.on("click.drag",re,ve),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ce=t=>()=>t;function gn(t,{sourceEvent:e,subject:n,target:r,identifier:o,active:s,x:i,y:c,dx:a,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}gn.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Gc(t){return!t.ctrlKey&&!t.button}function Zc(){return this.parentNode}function Kc(t,e){return e??{x:t.x,y:t.y}}function qc(){return navigator.maxTouchPoints||"ontouchstart"in this}function jc(){var t=Gc,e=Zc,n=Kc,r=qc,o={},s=Ge("start","drag","end"),i=0,c,a,l,u,f=0;function g(y){y.on("mousedown.drag",h).filter(r).on("touchstart.drag",p).on("touchmove.drag",m,Uc).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(y,M){if(!(u||!t.call(this,y,M))){var C=S(this,e.call(this,y,M),y,M,"mouse");C&&(gt(y.view).on("mousemove.drag",_,ve).on("mouseup.drag",w,ve),Zr(y.view),on(y),l=!1,c=y.clientX,a=y.clientY,C("start",y))}}function _(y){if(re(y),!l){var M=y.clientX-c,C=y.clientY-a;l=M*M+C*C>f}o.mouse("drag",y)}function w(y){gt(y.view).on("mousemove.drag mouseup.drag",null),Kr(y.view,l),re(y),o.mouse("end",y)}function p(y,M){if(t.call(this,y,M)){var C=y.changedTouches,I=e.call(this,y,M),D=C.length,$,F;for($=0;$<D;++$)(F=S(this,I,y,M,C[$].identifier,C[$]))&&(on(y),F("start",y,C[$]))}}function m(y){var M=y.changedTouches,C=M.length,I,D;for(I=0;I<C;++I)(D=o[M[I].identifier])&&(re(y),D("drag",y,M[I]))}function x(y){var M=y.changedTouches,C=M.length,I,D;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),I=0;I<C;++I)(D=o[M[I].identifier])&&(on(y),D("end",y,M[I]))}function S(y,M,C,I,D,$){var F=s.copy(),H=yt($||C,M),V,B,d;if((d=n.call(y,new gn("beforestart",{sourceEvent:C,target:g,identifier:D,active:i,x:H[0],y:H[1],dx:0,dy:0,dispatch:F}),I))!=null)return V=d.x-H[0]||0,B=d.y-H[1]||0,function N(v,T,z){var E=H,k;switch(v){case"start":o[D]=N,k=i++;break;case"end":delete o[D],--i;case"drag":H=yt(z||T,M),k=i;break}F.call(v,y,new gn(v,{sourceEvent:T,subject:d,target:g,identifier:D,active:k,x:H[0]+V,y:H[1]+B,dx:H[0]-E[0],dy:H[1]-E[1],dispatch:F}),I)}}return g.filter=function(y){return arguments.length?(t=typeof y=="function"?y:Ce(!!y),g):t},g.container=function(y){return arguments.length?(e=typeof y=="function"?y:Ce(y),g):e},g.subject=function(y){return arguments.length?(n=typeof y=="function"?y:Ce(y),g):n},g.touchable=function(y){return arguments.length?(r=typeof y=="function"?y:Ce(!!y),g):r},g.on=function(){var y=s.on.apply(s,arguments);return y===s?g:y},g.clickDistance=function(y){return arguments.length?(f=(y=+y)*y,g):Math.sqrt(f)},g}var tr=180/Math.PI,mn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function qr(t,e,n,r,o,s){var i,c,a;return(i=Math.sqrt(t*t+e*e))&&(t/=i,e/=i),(a=t*n+e*r)&&(n-=t*a,r-=e*a),(c=Math.sqrt(n*n+r*r))&&(n/=c,r/=c,a/=c),t*r<e*n&&(t=-t,e=-e,a=-a,i=-i),{translateX:o,translateY:s,rotate:Math.atan2(e,t)*tr,skewX:Math.atan(a)*tr,scaleX:i,scaleY:c}}var ke;function Qc(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?mn:qr(e.a,e.b,e.c,e.d,e.e,e.f)}function Jc(t){return t==null||(ke||(ke=document.createElementNS("http://www.w3.org/2000/svg","g")),ke.setAttribute("transform",t),!(t=ke.transform.baseVal.consolidate()))?mn:(t=t.matrix,qr(t.a,t.b,t.c,t.d,t.e,t.f))}function jr(t,e,n,r){function o(l){return l.length?l.pop()+" ":""}function s(l,u,f,g,h,_){if(l!==f||u!==g){var w=h.push("translate(",null,e,null,n);_.push({i:w-4,x:Vt(l,f)},{i:w-2,x:Vt(u,g)})}else(f||g)&&h.push("translate("+f+e+g+n)}function i(l,u,f,g){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),g.push({i:f.push(o(f)+"rotate(",null,r)-2,x:Vt(l,u)})):u&&f.push(o(f)+"rotate("+u+r)}function c(l,u,f,g){l!==u?g.push({i:f.push(o(f)+"skewX(",null,r)-2,x:Vt(l,u)}):u&&f.push(o(f)+"skewX("+u+r)}function a(l,u,f,g,h,_){if(l!==f||u!==g){var w=h.push(o(h)+"scale(",null,",",null,")");_.push({i:w-4,x:Vt(l,f)},{i:w-2,x:Vt(u,g)})}else(f!==1||g!==1)&&h.push(o(h)+"scale("+f+","+g+")")}return function(l,u){var f=[],g=[];return l=t(l),u=t(u),s(l.translateX,l.translateY,u.translateX,u.translateY,f,g),i(l.rotate,u.rotate,f,g),c(l.skewX,u.skewX,f,g),a(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,g),l=u=null,function(h){for(var _=-1,w=g.length,p;++_<w;)f[(p=g[_]).i]=p.x(h);return f.join("")}}}var ta=jr(Qc,"px, ","px)","deg)"),ea=jr(Jc,", ",")",")"),na=1e-12;function er(t){return((t=Math.exp(t))+1/t)/2}function ra(t){return((t=Math.exp(t))-1/t)/2}function oa(t){return((t=Math.exp(2*t))-1)/(t+1)}const sa=function t(e,n,r){function o(s,i){var c=s[0],a=s[1],l=s[2],u=i[0],f=i[1],g=i[2],h=u-c,_=f-a,w=h*h+_*_,p,m;if(w<na)m=Math.log(g/l)/e,p=function(I){return[c+I*h,a+I*_,l*Math.exp(e*I*m)]};else{var x=Math.sqrt(w),S=(g*g-l*l+r*w)/(2*l*n*x),y=(g*g-l*l-r*w)/(2*g*n*x),M=Math.log(Math.sqrt(S*S+1)-S),C=Math.log(Math.sqrt(y*y+1)-y);m=(C-M)/e,p=function(I){var D=I*m,$=er(M),F=l/(n*x)*($*oa(e*D+M)-ra(M));return[c+F*h,a+F*_,l*$/er(e*D+M)]}}return p.duration=m*1e3*e/Math.SQRT2,p}return o.rho=function(s){var i=Math.max(.001,+s),c=i*i,a=c*c;return t(i,c,a)},o}(Math.SQRT2,2,4);var ce=0,we=0,he=0,Qr=1e3,Ve,_e,Le=0,Wt=0,Ke=0,Ee=typeof performance=="object"&&performance.now?performance:Date,Jr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function kn(){return Wt||(Jr(ia),Wt=Ee.now()+Ke)}function ia(){Wt=0}function Oe(){this._call=this._time=this._next=null}Oe.prototype=to.prototype={constructor:Oe,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?kn():+n)+(e==null?0:+e),!this._next&&_e!==this&&(_e?_e._next=this:Ve=this,_e=this),this._call=t,this._time=n,pn()},stop:function(){this._call&&(this._call=null,this._time=1/0,pn())}};function to(t,e,n){var r=new Oe;return r.restart(t,e,n),r}function ca(){kn(),++ce;for(var t=Ve,e;t;)(e=Wt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--ce}function nr(){Wt=(Le=Ee.now())+Ke,ce=we=0;try{ca()}finally{ce=0,la(),Wt=0}}function aa(){var t=Ee.now(),e=t-Le;e>Qr&&(Ke-=e,Le=t)}function la(){for(var t,e=Ve,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Ve=n);_e=t,pn(r)}function pn(t){if(!ce){we&&(we=clearTimeout(we));var e=t-Wt;e>24?(t<1/0&&(we=setTimeout(nr,t-Ee.now()-Ke)),he&&(he=clearInterval(he))):(he||(Le=Ee.now(),he=setInterval(aa,Qr)),ce=1,Jr(nr))}}function rr(t,e,n){var r=new Oe;return e=e==null?0:+e,r.restart(o=>{r.stop(),t(o+e)},e,n),r}var ua=Ge("start","end","cancel","interrupt"),fa=[],eo=0,or=1,yn=2,Pe=3,sr=4,wn=5,He=6;function qe(t,e,n,r,o,s){var i=t.__transition;if(!i)t.__transition={};else if(n in i)return;da(t,n,{name:e,index:r,group:o,on:ua,tween:fa,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:eo})}function $n(t,e){var n=_t(t,e);if(n.state>eo)throw new Error("too late; already scheduled");return n}function vt(t,e){var n=_t(t,e);if(n.state>Pe)throw new Error("too late; already running");return n}function _t(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function da(t,e,n){var r=t.__transition,o;r[e]=n,n.timer=to(s,0,n.time);function s(l){n.state=or,n.timer.restart(i,n.delay,n.time),n.delay<=l&&i(l-n.delay)}function i(l){var u,f,g,h;if(n.state!==or)return a();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Pe)return rr(i);h.state===sr?(h.state=He,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete r[u]):+u<e&&(h.state=He,h.timer.stop(),h.on.call("cancel",t,t.__data__,h.index,h.group),delete r[u])}if(rr(function(){n.state===Pe&&(n.state=sr,n.timer.restart(c,n.delay,n.time),c(l))}),n.state=yn,n.on.call("start",t,t.__data__,n.index,n.group),n.state===yn){for(n.state=Pe,o=new Array(g=n.tween.length),u=0,f=-1;u<g;++u)(h=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(o[++f]=h);o.length=f+1}}function c(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(a),n.state=wn,1),f=-1,g=o.length;++f<g;)o[f].call(t,u);n.state===wn&&(n.on.call("end",t,t.__data__,n.index,n.group),a())}function a(){n.state=He,n.timer.stop(),delete r[e];for(var l in r)return;delete t.__transition}}function Be(t,e){var n=t.__transition,r,o,s=!0,i;if(n){e=e==null?null:e+"";for(i in n){if((r=n[i]).name!==e){s=!1;continue}o=r.state>yn&&r.state<wn,r.state=He,r.timer.stop(),r.on.call(o?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[i]}s&&delete t.__transition}}function ha(t){return this.each(function(){Be(this,t)})}function ga(t,e){var n,r;return function(){var o=vt(this,t),s=o.tween;if(s!==n){r=n=s;for(var i=0,c=r.length;i<c;++i)if(r[i].name===e){r=r.slice(),r.splice(i,1);break}}o.tween=r}}function ma(t,e,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=vt(this,t),i=s.tween;if(i!==r){o=(r=i).slice();for(var c={name:e,value:n},a=0,l=o.length;a<l;++a)if(o[a].name===e){o[a]=c;break}a===l&&o.push(c)}s.tween=o}}function pa(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=_t(this.node(),n).tween,o=0,s=r.length,i;o<s;++o)if((i=r[o]).name===t)return i.value;return null}return this.each((e==null?ga:ma)(n,t,e))}function Tn(t,e,n){var r=t._id;return t.each(function(){var o=vt(this,r);(o.value||(o.value={}))[e]=n.apply(this,arguments)}),function(o){return _t(o,r).value[e]}}function no(t,e){var n;return(typeof e=="number"?Vt:e instanceof Kn?Zn:(n=Kn(e))?(e=n,Zn):Hs)(t,e)}function ya(t){return function(){this.removeAttribute(t)}}function wa(t){return function(){this.removeAttributeNS(t.space,t.local)}}function _a(t,e,n){var r,o=n+"",s;return function(){var i=this.getAttribute(t);return i===o?null:i===r?s:s=e(r=i,n)}}function xa(t,e,n){var r,o=n+"",s;return function(){var i=this.getAttributeNS(t.space,t.local);return i===o?null:i===r?s:s=e(r=i,n)}}function va(t,e,n){var r,o,s;return function(){var i,c=n(this),a;return c==null?void this.removeAttribute(t):(i=this.getAttribute(t),a=c+"",i===a?null:i===r&&a===o?s:(o=a,s=e(r=i,c)))}}function Ea(t,e,n){var r,o,s;return function(){var i,c=n(this),a;return c==null?void this.removeAttributeNS(t.space,t.local):(i=this.getAttributeNS(t.space,t.local),a=c+"",i===a?null:i===r&&a===o?s:(o=a,s=e(r=i,c)))}}function Sa(t,e){var n=Ze(t),r=n==="transform"?ea:no;return this.attrTween(t,typeof e=="function"?(n.local?Ea:va)(n,r,Tn(this,"attr."+t,e)):e==null?(n.local?wa:ya)(n):(n.local?xa:_a)(n,r,e))}function ba(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function Na(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function Aa(t,e){var n,r;function o(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&Na(t,s)),n}return o._value=e,o}function Ma(t,e){var n,r;function o(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&ba(t,s)),n}return o._value=e,o}function Ca(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Ze(t);return this.tween(n,(r.local?Aa:Ma)(r,e))}function ka(t,e){return function(){$n(this,t).delay=+e.apply(this,arguments)}}function $a(t,e){return e=+e,function(){$n(this,t).delay=e}}function Ta(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?ka:$a)(e,t)):_t(this.node(),e).delay}function Ia(t,e){return function(){vt(this,t).duration=+e.apply(this,arguments)}}function Da(t,e){return e=+e,function(){vt(this,t).duration=e}}function za(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?Ia:Da)(e,t)):_t(this.node(),e).duration}function Ra(t,e){if(typeof e!="function")throw new Error;return function(){vt(this,t).ease=e}}function Pa(t){var e=this._id;return arguments.length?this.each(Ra(e,t)):_t(this.node(),e).ease}function Ha(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;vt(this,t).ease=n}}function Ba(t){if(typeof t!="function")throw new Error;return this.each(Ha(this._id,t))}function Fa(t){typeof t!="function"&&(t=Br(t));for(var e=this._groups,n=e.length,r=new Array(n),o=0;o<n;++o)for(var s=e[o],i=s.length,c=r[o]=[],a,l=0;l<i;++l)(a=s[l])&&t.call(a,a.__data__,l,s)&&c.push(a);return new Ct(r,this._parents,this._name,this._id)}function Va(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,o=n.length,s=Math.min(r,o),i=new Array(r),c=0;c<s;++c)for(var a=e[c],l=n[c],u=a.length,f=i[c]=new Array(u),g,h=0;h<u;++h)(g=a[h]||l[h])&&(f[h]=g);for(;c<r;++c)i[c]=e[c];return new Ct(i,this._parents,this._name,this._id)}function La(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function Oa(t,e,n){var r,o,s=La(e)?$n:vt;return function(){var i=s(this,t),c=i.on;c!==r&&(o=(r=c).copy()).on(e,n),i.on=o}}function Ya(t,e){var n=this._id;return arguments.length<2?_t(this.node(),n).on.on(t):this.each(Oa(n,t,e))}function Xa(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function Wa(){return this.on("end.remove",Xa(this._id))}function Ua(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Mn(t));for(var r=this._groups,o=r.length,s=new Array(o),i=0;i<o;++i)for(var c=r[i],a=c.length,l=s[i]=new Array(a),u,f,g=0;g<a;++g)(u=c[g])&&(f=t.call(u,u.__data__,g,c))&&("__data__"in u&&(f.__data__=u.__data__),l[g]=f,qe(l[g],e,n,g,l,_t(u,n)));return new Ct(s,this._parents,e,n)}function Ga(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Hr(t));for(var r=this._groups,o=r.length,s=[],i=[],c=0;c<o;++c)for(var a=r[c],l=a.length,u,f=0;f<l;++f)if(u=a[f]){for(var g=t.call(u,u.__data__,f,a),h,_=_t(u,n),w=0,p=g.length;w<p;++w)(h=g[w])&&qe(h,e,n,w,g,_);s.push(g),i.push(u)}return new Ct(s,i,e,n)}var Za=Ae.prototype.constructor;function Ka(){return new Za(this._groups,this._parents)}function qa(t,e){var n,r,o;return function(){var s=ie(this,t),i=(this.style.removeProperty(t),ie(this,t));return s===i?null:s===n&&i===r?o:o=e(n=s,r=i)}}function ro(t){return function(){this.style.removeProperty(t)}}function ja(t,e,n){var r,o=n+"",s;return function(){var i=ie(this,t);return i===o?null:i===r?s:s=e(r=i,n)}}function Qa(t,e,n){var r,o,s;return function(){var i=ie(this,t),c=n(this),a=c+"";return c==null&&(a=c=(this.style.removeProperty(t),ie(this,t))),i===a?null:i===r&&a===o?s:(o=a,s=e(r=i,c))}}function Ja(t,e){var n,r,o,s="style."+e,i="end."+s,c;return function(){var a=vt(this,t),l=a.on,u=a.value[s]==null?c||(c=ro(e)):void 0;(l!==n||o!==u)&&(r=(n=l).copy()).on(i,o=u),a.on=r}}function tl(t,e,n){var r=(t+="")=="transform"?ta:no;return e==null?this.styleTween(t,qa(t,r)).on("end.style."+t,ro(t)):typeof e=="function"?this.styleTween(t,Qa(t,r,Tn(this,"style."+t,e))).each(Ja(this._id,t)):this.styleTween(t,ja(t,r,e),n).on("end.style."+t,null)}function el(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function nl(t,e,n){var r,o;function s(){var i=e.apply(this,arguments);return i!==o&&(r=(o=i)&&el(t,i,n)),r}return s._value=e,s}function rl(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,nl(t,e,n??""))}function ol(t){return function(){this.textContent=t}}function sl(t){return function(){var e=t(this);this.textContent=e??""}}function il(t){return this.tween("text",typeof t=="function"?sl(Tn(this,"text",t)):ol(t==null?"":t+""))}function cl(t){return function(e){this.textContent=t.call(this,e)}}function al(t){var e,n;function r(){var o=t.apply(this,arguments);return o!==n&&(e=(n=o)&&cl(o)),e}return r._value=t,r}function ll(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,al(t))}function ul(){for(var t=this._name,e=this._id,n=oo(),r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],c=i.length,a,l=0;l<c;++l)if(a=i[l]){var u=_t(a,e);qe(a,t,n,l,i,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ct(r,this._parents,t,n)}function fl(){var t,e,n=this,r=n._id,o=n.size();return new Promise(function(s,i){var c={value:i},a={value:function(){--o===0&&s()}};n.each(function(){var l=vt(this,r),u=l.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(c),e._.interrupt.push(c),e._.end.push(a)),l.on=e}),o===0&&s()})}var dl=0;function Ct(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function oo(){return++dl}var Nt=Ae.prototype;Ct.prototype={constructor:Ct,select:Ua,selectAll:Ga,selectChild:Nt.selectChild,selectChildren:Nt.selectChildren,filter:Fa,merge:Va,selection:Ka,transition:ul,call:Nt.call,nodes:Nt.nodes,node:Nt.node,size:Nt.size,empty:Nt.empty,each:Nt.each,on:Ya,attr:Sa,attrTween:Ca,style:tl,styleTween:rl,text:il,textTween:ll,remove:Wa,tween:pa,delay:Ta,duration:za,ease:Pa,easeVarying:Ba,end:fl,[Symbol.iterator]:Nt[Symbol.iterator]};function hl(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var gl={time:null,delay:0,duration:250,ease:hl};function ml(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function pl(t){var e,n;t instanceof Ct?(e=t._id,t=t._name):(e=oo(),(n=gl).time=kn(),t=t==null?null:t+"");for(var r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],c=i.length,a,l=0;l<c;++l)(a=i[l])&&qe(a,t,e,l,i,n||ml(a,e));return new Ct(r,this._parents,t,e)}Ae.prototype.interrupt=ha;Ae.prototype.transition=pl;const $e=t=>()=>t;function yl(t,{sourceEvent:e,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function At(t,e,n){this.k=t,this.x=e,this.y=n}At.prototype={constructor:At,scale:function(t){return t===1?this:new At(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new At(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Mt=new At(1,0,0);At.prototype;function sn(t){t.stopImmediatePropagation()}function ge(t){t.preventDefault(),t.stopImmediatePropagation()}function wl(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function _l(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function ir(){return this.__zoom||Mt}function xl(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function vl(){return navigator.maxTouchPoints||"ontouchstart"in this}function El(t,e,n){var r=t.invertX(e[0][0])-n[0][0],o=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],i=t.invertY(e[1][1])-n[1][1];return t.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function so(){var t=wl,e=_l,n=El,r=xl,o=vl,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,a=sa,l=Ge("start","zoom","end"),u,f,g,h=500,_=150,w=0,p=10;function m(d){d.property("__zoom",ir).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",F).filter(o).on("touchstart.zoom",H).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(d,N,v,T){var z=d.selection?d.selection():d;z.property("__zoom",ir),d!==z?M(d,N,v,T):z.interrupt().each(function(){C(this,arguments).event(T).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},m.scaleBy=function(d,N,v,T){m.scaleTo(d,function(){var z=this.__zoom.k,E=typeof N=="function"?N.apply(this,arguments):N;return z*E},v,T)},m.scaleTo=function(d,N,v,T){m.transform(d,function(){var z=e.apply(this,arguments),E=this.__zoom,k=v==null?y(z):typeof v=="function"?v.apply(this,arguments):v,R=E.invert(k),P=typeof N=="function"?N.apply(this,arguments):N;return n(S(x(E,P),k,R),z,i)},v,T)},m.translateBy=function(d,N,v,T){m.transform(d,function(){return n(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof v=="function"?v.apply(this,arguments):v),e.apply(this,arguments),i)},null,T)},m.translateTo=function(d,N,v,T,z){m.transform(d,function(){var E=e.apply(this,arguments),k=this.__zoom,R=T==null?y(E):typeof T=="function"?T.apply(this,arguments):T;return n(Mt.translate(R[0],R[1]).scale(k.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof v=="function"?-v.apply(this,arguments):-v),E,i)},T,z)};function x(d,N){return N=Math.max(s[0],Math.min(s[1],N)),N===d.k?d:new At(N,d.x,d.y)}function S(d,N,v){var T=N[0]-v[0]*d.k,z=N[1]-v[1]*d.k;return T===d.x&&z===d.y?d:new At(d.k,T,z)}function y(d){return[(+d[0][0]+ +d[1][0])/2,(+d[0][1]+ +d[1][1])/2]}function M(d,N,v,T){d.on("start.zoom",function(){C(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(T).end()}).tween("zoom",function(){var z=this,E=arguments,k=C(z,E).event(T),R=e.apply(z,E),P=v==null?y(R):typeof v=="function"?v.apply(z,E):v,O=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),L=z.__zoom,W=typeof N=="function"?N.apply(z,E):N,U=a(L.invert(P).concat(O/L.k),W.invert(P).concat(O/W.k));return function(K){if(K===1)K=W;else{var Q=U(K),j=O/Q[2];K=new At(j,P[0]-Q[0]*j,P[1]-Q[1]*j)}k.zoom(null,K)}})}function C(d,N,v){return!v&&d.__zooming||new I(d,N)}function I(d,N){this.that=d,this.args=N,this.active=0,this.sourceEvent=null,this.extent=e.apply(d,N),this.taps=0}I.prototype={event:function(d){return d&&(this.sourceEvent=d),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(d,N){return this.mouse&&d!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&d!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&d!=="touch"&&(this.touch1[1]=N.invert(this.touch1[0])),this.that.__zoom=N,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(d){var N=gt(this.that).datum();l.call(d,this.that,new yl(d,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),N)}};function D(d,...N){if(!t.apply(this,arguments))return;var v=C(this,N).event(d),T=this.__zoom,z=Math.max(s[0],Math.min(s[1],T.k*Math.pow(2,r.apply(this,arguments)))),E=yt(d);if(v.wheel)(v.mouse[0][0]!==E[0]||v.mouse[0][1]!==E[1])&&(v.mouse[1]=T.invert(v.mouse[0]=E)),clearTimeout(v.wheel);else{if(T.k===z)return;v.mouse=[E,T.invert(E)],Be(this),v.start()}ge(d),v.wheel=setTimeout(k,_),v.zoom("mouse",n(S(x(T,z),v.mouse[0],v.mouse[1]),v.extent,i));function k(){v.wheel=null,v.end()}}function $(d,...N){if(g||!t.apply(this,arguments))return;var v=d.currentTarget,T=C(this,N,!0).event(d),z=gt(d.view).on("mousemove.zoom",P,!0).on("mouseup.zoom",O,!0),E=yt(d,v),k=d.clientX,R=d.clientY;Zr(d.view),sn(d),T.mouse=[E,this.__zoom.invert(E)],Be(this),T.start();function P(L){if(ge(L),!T.moved){var W=L.clientX-k,U=L.clientY-R;T.moved=W*W+U*U>w}T.event(L).zoom("mouse",n(S(T.that.__zoom,T.mouse[0]=yt(L,v),T.mouse[1]),T.extent,i))}function O(L){z.on("mousemove.zoom mouseup.zoom",null),Kr(L.view,T.moved),ge(L),T.event(L).end()}}function F(d,...N){if(t.apply(this,arguments)){var v=this.__zoom,T=yt(d.changedTouches?d.changedTouches[0]:d,this),z=v.invert(T),E=v.k*(d.shiftKey?.5:2),k=n(S(x(v,E),T,z),e.apply(this,N),i);ge(d),c>0?gt(this).transition().duration(c).call(M,k,T,d):gt(this).call(m.transform,k,T,d)}}function H(d,...N){if(t.apply(this,arguments)){var v=d.touches,T=v.length,z=C(this,N,d.changedTouches.length===T).event(d),E,k,R,P;for(sn(d),k=0;k<T;++k)R=v[k],P=yt(R,this),P=[P,this.__zoom.invert(P),R.identifier],z.touch0?!z.touch1&&z.touch0[2]!==P[2]&&(z.touch1=P,z.taps=0):(z.touch0=P,E=!0,z.taps=1+!!u);u&&(u=clearTimeout(u)),E&&(z.taps<2&&(f=P[0],u=setTimeout(function(){u=null},h)),Be(this),z.start())}}function V(d,...N){if(this.__zooming){var v=C(this,N).event(d),T=d.changedTouches,z=T.length,E,k,R,P;for(ge(d),E=0;E<z;++E)k=T[E],R=yt(k,this),v.touch0&&v.touch0[2]===k.identifier?v.touch0[0]=R:v.touch1&&v.touch1[2]===k.identifier&&(v.touch1[0]=R);if(k=v.that.__zoom,v.touch1){var O=v.touch0[0],L=v.touch0[1],W=v.touch1[0],U=v.touch1[1],K=(K=W[0]-O[0])*K+(K=W[1]-O[1])*K,Q=(Q=U[0]-L[0])*Q+(Q=U[1]-L[1])*Q;k=x(k,Math.sqrt(K/Q)),R=[(O[0]+W[0])/2,(O[1]+W[1])/2],P=[(L[0]+U[0])/2,(L[1]+U[1])/2]}else if(v.touch0)R=v.touch0[0],P=v.touch0[1];else return;v.zoom("touch",n(S(k,R,P),v.extent,i))}}function B(d,...N){if(this.__zooming){var v=C(this,N).event(d),T=d.changedTouches,z=T.length,E,k;for(sn(d),g&&clearTimeout(g),g=setTimeout(function(){g=null},h),E=0;E<z;++E)k=T[E],v.touch0&&v.touch0[2]===k.identifier?delete v.touch0:v.touch1&&v.touch1[2]===k.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&&(k=yt(k,this),Math.hypot(f[0]-k[0],f[1]-k[1])<p)){var R=gt(this).on("dblclick.zoom");R&&R.apply(this,arguments)}}}return m.wheelDelta=function(d){return arguments.length?(r=typeof d=="function"?d:$e(+d),m):r},m.filter=function(d){return arguments.length?(t=typeof d=="function"?d:$e(!!d),m):t},m.touchable=function(d){return arguments.length?(o=typeof d=="function"?d:$e(!!d),m):o},m.extent=function(d){return arguments.length?(e=typeof d=="function"?d:$e([[+d[0][0],+d[0][1]],[+d[1][0],+d[1][1]]]),m):e},m.scaleExtent=function(d){return arguments.length?(s[0]=+d[0],s[1]=+d[1],m):[s[0],s[1]]},m.translateExtent=function(d){return arguments.length?(i[0][0]=+d[0][0],i[1][0]=+d[1][0],i[0][1]=+d[0][1],i[1][1]=+d[1][1],m):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},m.constrain=function(d){return arguments.length?(n=d,m):n},m.duration=function(d){return arguments.length?(c=+d,m):c},m.interpolate=function(d){return arguments.length?(a=d,m):a},m.on=function(){var d=l.on.apply(l,arguments);return d===l?m:d},m.clickDistance=function(d){return arguments.length?(w=(d=+d)*d,m):Math.sqrt(w)},m.tapDistance=function(d){return arguments.length?(p=+d,m):p},m}const je=b.createContext(null),Sl=je.Provider,kt={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:t=>`Node type "${t}" 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:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},io=kt.error001();function tt(t,e){const n=b.useContext(je);if(n===null)throw new Error(io);return Rr(n,t,e)}const ot=()=>{const t=b.useContext(je);if(t===null)throw new Error(io);return b.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},bl=t=>t.userSelectionActive?"none":"all";function In({position:t,children:e,className:n,style:r,...o}){const s=tt(bl),i=`${t}`.split("-");return A.createElement("div",{className:ct(["react-flow__panel",n,...i]),style:{...r,pointerEvents:s},...o},e)}function Nl({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:A.createElement(In,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},A.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const Al=({x:t,y:e,label:n,labelStyle:r={},labelShowBg:o=!0,labelBgStyle:s={},labelBgPadding:i=[2,4],labelBgBorderRadius:c=2,children:a,className:l,...u})=>{const f=b.useRef(null),[g,h]=b.useState({x:0,y:0,width:0,height:0}),_=ct(["react-flow__edge-textwrapper",l]);return b.useEffect(()=>{if(f.current){const w=f.current.getBBox();h({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),typeof n>"u"||!n?null:A.createElement("g",{transform:`translate(${t-g.width/2} ${e-g.height/2})`,className:_,visibility:g.width?"visible":"hidden",...u},o&&A.createElement("rect",{width:g.width+2*i[0],x:-i[0],y:-i[1],height:g.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:c,ry:c}),A.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:f,style:r},n),a)};var Ml=b.memo(Al);const Dn=t=>({width:t.offsetWidth,height:t.offsetHeight}),ae=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),zn=(t={x:0,y:0},e)=>({x:ae(t.x,e[0][0],e[1][0]),y:ae(t.y,e[0][1],e[1][1])}),cr=(t,e,n)=>t<e?ae(Math.abs(t-e),1,50)/50:t>n?-ae(Math.abs(t-n),1,50)/50:0,co=(t,e)=>{const n=cr(t.x,35,e.width-35)*20,r=cr(t.y,35,e.height-35)*20;return[n,r]},ao=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},lo=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),Se=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),uo=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),ar=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),Cl=(t,e)=>uo(lo(Se(t),Se(e))),_n=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},kl=t=>mt(t.width)&&mt(t.height)&&mt(t.x)&&mt(t.y),mt=t=>!isNaN(t)&&isFinite(t),et=Symbol.for("internals"),fo=["Enter"," ","Escape"],$l=(t,e)=>{},Tl=t=>"nativeEvent"in t;function xn(t){var o,s;const e=Tl(t)?t.nativeEvent:t,n=((s=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:s[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const ho=t=>"clientX"in t,Dt=(t,e)=>{var s,i;const n=ho(t),r=n?t.clientX:(s=t.touches)==null?void 0:s[0].clientX,o=n?t.clientY:(i=t.touches)==null?void 0:i[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:o-((e==null?void 0:e.top)??0)}},Ye=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},Me=({id:t,path:e,labelX:n,labelY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:g,interactionWidth:h=20})=>A.createElement(A.Fragment,null,A.createElement("path",{id:t,style:u,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:g}),h&&A.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),o&&mt(n)&&mt(r)?A.createElement(Ml,{x:n,y:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:l}):null);Me.displayName="BaseEdge";function me(t,e,n){return n===void 0?n:r=>{const o=e().edges.find(s=>s.id===t);o&&n(r,{...o})}}function go({sourceX:t,sourceY:e,targetX:n,targetY:r}){const o=Math.abs(n-t)/2,s=n<t?n+o:n-o,i=Math.abs(r-e)/2,c=r<e?r+i:r-i;return[s,c,o,i]}function mo({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:c}){const a=t*.125+o*.375+i*.375+n*.125,l=e*.125+s*.375+c*.375+r*.125,u=Math.abs(a-t),f=Math.abs(l-e);return[a,l,u,f]}var Ut;(function(t){t.Strict="strict",t.Loose="loose"})(Ut||(Ut={}));var Ot;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Ot||(Ot={}));var be;(function(t){t.Partial="partial",t.Full="full"})(be||(be={}));var It;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(It||(It={}));var Yt;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Yt||(Yt={}));var X;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(X||(X={}));function lr({pos:t,x1:e,y1:n,x2:r,y2:o}){return t===X.Left||t===X.Right?[.5*(e+r),n]:[e,.5*(n+o)]}function po({sourceX:t,sourceY:e,sourcePosition:n=X.Bottom,targetX:r,targetY:o,targetPosition:s=X.Top}){const[i,c]=lr({pos:n,x1:t,y1:e,x2:r,y2:o}),[a,l]=lr({pos:s,x1:r,y1:o,x2:t,y2:e}),[u,f,g,h]=mo({sourceX:t,sourceY:e,targetX:r,targetY:o,sourceControlX:i,sourceControlY:c,targetControlX:a,targetControlY:l});return[`M${t},${e} C${i},${c} ${a},${l} ${r},${o}`,u,f,g,h]}const Rn=b.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:o=X.Bottom,targetPosition:s=X.Top,label:i,labelStyle:c,labelShowBg:a,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:g,markerEnd:h,markerStart:_,interactionWidth:w})=>{const[p,m,x]=po({sourceX:t,sourceY:e,sourcePosition:o,targetX:n,targetY:r,targetPosition:s});return A.createElement(Me,{path:p,labelX:m,labelY:x,label:i,labelStyle:c,labelShowBg:a,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:g,markerEnd:h,markerStart:_,interactionWidth:w})});Rn.displayName="SimpleBezierEdge";const ur={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},Il=({source:t,sourcePosition:e=X.Bottom,target:n})=>e===X.Left||e===X.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},fr=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function Dl({source:t,sourcePosition:e=X.Bottom,target:n,targetPosition:r=X.Top,center:o,offset:s}){const i=ur[e],c=ur[r],a={x:t.x+i.x*s,y:t.y+i.y*s},l={x:n.x+c.x*s,y:n.y+c.y*s},u=Il({source:a,sourcePosition:e,target:l}),f=u.x!==0?"x":"y",g=u[f];let h=[],_,w;const p={x:0,y:0},m={x:0,y:0},[x,S,y,M]=go({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(i[f]*c[f]===-1){_=o.x??x,w=o.y??S;const I=[{x:_,y:a.y},{x:_,y:l.y}],D=[{x:a.x,y:w},{x:l.x,y:w}];i[f]===g?h=f==="x"?I:D:h=f==="x"?D:I}else{const I=[{x:a.x,y:l.y}],D=[{x:l.x,y:a.y}];if(f==="x"?h=i.x===g?D:I:h=i.y===g?I:D,e===r){const B=Math.abs(t[f]-n[f]);if(B<=s){const d=Math.min(s-1,s-B);i[f]===g?p[f]=(a[f]>t[f]?-1:1)*d:m[f]=(l[f]>n[f]?-1:1)*d}}if(e!==r){const B=f==="x"?"y":"x",d=i[f]===c[B],N=a[B]>l[B],v=a[B]<l[B];(i[f]===1&&(!d&&N||d&&v)||i[f]!==1&&(!d&&v||d&&N))&&(h=f==="x"?I:D)}const $={x:a.x+p.x,y:a.y+p.y},F={x:l.x+m.x,y:l.y+m.y},H=Math.max(Math.abs($.x-h[0].x),Math.abs(F.x-h[0].x)),V=Math.max(Math.abs($.y-h[0].y),Math.abs(F.y-h[0].y));H>=V?(_=($.x+F.x)/2,w=h[0].y):(_=h[0].x,w=($.y+F.y)/2)}return[[t,{x:a.x+p.x,y:a.y+p.y},...h,{x:l.x+m.x,y:l.y+m.y},n],_,w,y,M]}function zl(t,e,n,r){const o=Math.min(fr(t,e)/2,fr(e,n)/2,r),{x:s,y:i}=e;if(t.x===s&&s===n.x||t.y===i&&i===n.y)return`L${s} ${i}`;if(t.y===i){const l=t.x<n.x?-1:1,u=t.y<n.y?1:-1;return`L ${s+o*l},${i}Q ${s},${i} ${s},${i+o*u}`}const c=t.x<n.x?1:-1,a=t.y<n.y?-1:1;return`L ${s},${i+o*a}Q ${s},${i} ${s+o*c},${i}`}function vn({sourceX:t,sourceY:e,sourcePosition:n=X.Bottom,targetX:r,targetY:o,targetPosition:s=X.Top,borderRadius:i=5,centerX:c,centerY:a,offset:l=20}){const[u,f,g,h,_]=Dl({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:c,y:a},offset:l});return[u.reduce((p,m,x)=>{let S="";return x>0&&x<u.length-1?S=zl(u[x-1],m,u[x+1],i):S=`${x===0?"M":"L"}${m.x} ${m.y}`,p+=S,p},""),f,g,h,_]}const Qe=b.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:l,style:u,sourcePosition:f=X.Bottom,targetPosition:g=X.Top,markerEnd:h,markerStart:_,pathOptions:w,interactionWidth:p})=>{const[m,x,S]=vn({sourceX:t,sourceY:e,sourcePosition:f,targetX:n,targetY:r,targetPosition:g,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset});return A.createElement(Me,{path:m,labelX:x,labelY:S,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:_,interactionWidth:p})});Qe.displayName="SmoothStepEdge";const Pn=b.memo(t=>{var e;return A.createElement(Qe,{...t,pathOptions:b.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});Pn.displayName="StepEdge";function Rl({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[o,s,i,c]=go({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,o,s,i,c]}const Hn=b.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:g,interactionWidth:h})=>{const[_,w,p]=Rl({sourceX:t,sourceY:e,targetX:n,targetY:r});return A.createElement(Me,{path:_,labelX:w,labelY:p,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:l,style:u,markerEnd:f,markerStart:g,interactionWidth:h})});Hn.displayName="StraightEdge";function Te(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function dr({pos:t,x1:e,y1:n,x2:r,y2:o,c:s}){switch(t){case X.Left:return[e-Te(e-r,s),n];case X.Right:return[e+Te(r-e,s),n];case X.Top:return[e,n-Te(n-o,s)];case X.Bottom:return[e,n+Te(o-n,s)]}}function yo({sourceX:t,sourceY:e,sourcePosition:n=X.Bottom,targetX:r,targetY:o,targetPosition:s=X.Top,curvature:i=.25}){const[c,a]=dr({pos:n,x1:t,y1:e,x2:r,y2:o,c:i}),[l,u]=dr({pos:s,x1:r,y1:o,x2:t,y2:e,c:i}),[f,g,h,_]=mo({sourceX:t,sourceY:e,targetX:r,targetY:o,sourceControlX:c,sourceControlY:a,targetControlX:l,targetControlY:u});return[`M${t},${e} C${c},${a} ${l},${u} ${r},${o}`,f,g,h,_]}const Xe=b.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,sourcePosition:o=X.Bottom,targetPosition:s=X.Top,label:i,labelStyle:c,labelShowBg:a,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:g,markerEnd:h,markerStart:_,pathOptions:w,interactionWidth:p})=>{const[m,x,S]=yo({sourceX:t,sourceY:e,sourcePosition:o,targetX:n,targetY:r,targetPosition:s,curvature:w==null?void 0:w.curvature});return A.createElement(Me,{path:m,labelX:x,labelY:S,label:i,labelStyle:c,labelShowBg:a,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:g,markerEnd:h,markerStart:_,interactionWidth:p})});Xe.displayName="BezierEdge";const Bn=b.createContext(null),Pl=Bn.Provider;Bn.Consumer;const Hl=()=>b.useContext(Bn),Bl=t=>"id"in t&&"source"in t&&"target"in t,Fl=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`reactflow__edge-${t}${e||""}-${n}${r||""}`,En=(t,e)=>typeof t>"u"?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`,Vl=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),Ll=(t,e)=>{if(!t.source||!t.target)return e;let n;return Bl(t)?n={...t}:n={...t,id:Fl(t)},Vl(n,e)?e:e.concat(n)},Sn=({x:t,y:e},[n,r,o],s,[i,c])=>{const a={x:(t-n)/o,y:(e-r)/o};return s?{x:i*Math.round(a.x/i),y:c*Math.round(a.y/c)}:a},wo=({x:t,y:e},[n,r,o])=>({x:t*o+n,y:e*o+r}),Xt=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],r=(t.height??0)*e[1],o={x:t.position.x-n,y:t.position.y-r};return{...o,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-r}:o}},Je=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,o)=>{const{x:s,y:i}=Xt(o,e).positionAbsolute;return lo(r,Se({x:s,y:i,width:o.width||0,height:o.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return uo(n)},_o=(t,e,[n,r,o]=[0,0,1],s=!1,i=!1,c=[0,0])=>{const a={x:(e.x-n)/o,y:(e.y-r)/o,width:e.width/o,height:e.height/o},l=[];return t.forEach(u=>{const{width:f,height:g,selectable:h=!0,hidden:_=!1}=u;if(i&&!h||_)return!1;const{positionAbsolute:w}=Xt(u,c),p={x:w.x,y:w.y,width:f||0,height:g||0},m=_n(a,p),x=typeof f>"u"||typeof g>"u"||f===null||g===null,S=s&&m>0,y=(f||0)*(g||0);(x||S||m>=y||u.dragging)&&l.push(u)}),l},xo=(t,e)=>{const n=t.map(r=>r.id);return e.filter(r=>n.includes(r.source)||n.includes(r.target))},vo=(t,e,n,r,o,s=.1)=>{const i=e/(t.width*(1+s)),c=n/(t.height*(1+s)),a=Math.min(i,c),l=ae(a,r,o),u=t.x+t.width/2,f=t.y+t.height/2,g=e/2-u*l,h=n/2-f*l;return{x:g,y:h,zoom:l}},Lt=(t,e=0)=>t.transition().duration(e);function hr(t,e,n,r){return(e[n]||[]).reduce((o,s)=>{var i,c;return`${t.id}-${s.id}-${n}`!==r&&o.push({id:s.id||null,type:n,nodeId:t.id,x:(((i=t.positionAbsolute)==null?void 0:i.x)??0)+s.x+s.width/2,y:(((c=t.positionAbsolute)==null?void 0:c.y)??0)+s.y+s.height/2}),o},[])}function Ol(t,e,n,r,o,s){const{x:i,y:c}=Dt(t),l=e.elementsFromPoint(i,c).find(_=>_.classList.contains("react-flow__handle"));if(l){const _=l.getAttribute("data-nodeid");if(_){const w=Fn(void 0,l),p=l.getAttribute("data-handleid"),m=s({nodeId:_,id:p,type:w});if(m){const x=o.find(S=>S.nodeId===_&&S.type===w&&S.id===p);return{handle:{id:p,type:w,nodeId:_,x:(x==null?void 0:x.x)||n.x,y:(x==null?void 0:x.y)||n.y},validHandleResult:m}}}}let u=[],f=1/0;if(o.forEach(_=>{const w=Math.sqrt((_.x-n.x)**2+(_.y-n.y)**2);if(w<=r){const p=s(_);w<=f&&(w<f?u=[{handle:_,validHandleResult:p}]:w===f&&u.push({handle:_,validHandleResult:p}),f=w)}}),!u.length)return{handle:null,validHandleResult:Eo()};if(u.length===1)return u[0];const g=u.some(({validHandleResult:_})=>_.isValid),h=u.some(({handle:_})=>_.type==="target");return u.find(({handle:_,validHandleResult:w})=>h?_.type==="target":g?w.isValid:!0)||u[0]}const Yl={source:null,target:null,sourceHandle:null,targetHandle:null},Eo=()=>({handleDomNode:null,isValid:!1,connection:Yl,endHandle:null});function So(t,e,n,r,o,s,i){const c=o==="target",a=i.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),l={...Eo(),handleDomNode:a};if(a){const u=Fn(void 0,a),f=a.getAttribute("data-nodeid"),g=a.getAttribute("data-handleid"),h=a.classList.contains("connectable"),_=a.classList.contains("connectableend"),w={source:c?f:n,sourceHandle:c?g:r,target:c?n:f,targetHandle:c?r:g};l.connection=w,h&&_&&(e===Ut.Strict?c&&u==="source"||!c&&u==="target":f!==n||g!==r)&&(l.endHandle={nodeId:f,handleId:g,type:u},l.isValid=s(w))}return l}function Xl({nodes:t,nodeId:e,handleId:n,handleType:r}){return t.reduce((o,s)=>{if(s[et]){const{handleBounds:i}=s[et];let c=[],a=[];i&&(c=hr(s,i,"source",`${e}-${n}-${r}`),a=hr(s,i,"target",`${e}-${n}-${r}`)),o.push(...c,...a)}return o},[])}function Fn(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function cn(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function Wl(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function bo({event:t,handleId:e,nodeId:n,onConnect:r,isTarget:o,getState:s,setState:i,isValidConnection:c,edgeUpdaterType:a,onReconnectEnd:l}){const u=ao(t.target),{connectionMode:f,domNode:g,autoPanOnConnect:h,connectionRadius:_,onConnectStart:w,panBy:p,getNodes:m,cancelConnection:x}=s();let S=0,y;const{x:M,y:C}=Dt(t),I=u==null?void 0:u.elementFromPoint(M,C),D=Fn(a,I),$=g==null?void 0:g.getBoundingClientRect();if(!$||!D)return;let F,H=Dt(t,$),V=!1,B=null,d=!1,N=null;const v=Xl({nodes:m(),nodeId:n,handleId:e,handleType:D}),T=()=>{if(!h)return;const[k,R]=co(H,$);p({x:k,y:R}),S=requestAnimationFrame(T)};i({connectionPosition:H,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:D,connectionStartHandle:{nodeId:n,handleId:e,type:D},connectionEndHandle:null}),w==null||w(t,{nodeId:n,handleId:e,handleType:D});function z(k){const{transform:R}=s();H=Dt(k,$);const{handle:P,validHandleResult:O}=Ol(k,u,Sn(H,R,!1,[1,1]),_,v,L=>So(L,f,n,e,o?"target":"source",c,u));if(y=P,V||(T(),V=!0),N=O.handleDomNode,B=O.connection,d=O.isValid,i({connectionPosition:y&&d?wo({x:y.x,y:y.y},R):H,connectionStatus:Wl(!!y,d),connectionEndHandle:O.endHandle}),!y&&!d&&!N)return cn(F);B.source!==B.target&&N&&(cn(F),F=N,N.classList.add("connecting","react-flow__handle-connecting"),N.classList.toggle("valid",d),N.classList.toggle("react-flow__handle-valid",d))}function E(k){var R,P;(y||N)&&B&&d&&(r==null||r(B)),(P=(R=s()).onConnectEnd)==null||P.call(R,k),a&&(l==null||l(k)),cn(F),x(),cancelAnimationFrame(S),V=!1,d=!1,B=null,N=null,u.removeEventListener("mousemove",z),u.removeEventListener("mouseup",E),u.removeEventListener("touchmove",z),u.removeEventListener("touchend",E)}u.addEventListener("mousemove",z),u.addEventListener("mouseup",E),u.addEventListener("touchmove",z),u.addEventListener("touchend",E)}const gr=()=>!0,Ul=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),Gl=(t,e,n)=>r=>{const{connectionStartHandle:o,connectionEndHandle:s,connectionClickStartHandle:i}=r;return{connecting:(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.handleId)===e&&(o==null?void 0:o.type)===n||(s==null?void 0:s.nodeId)===t&&(s==null?void 0:s.handleId)===e&&(s==null?void 0:s.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===t&&(i==null?void 0:i.handleId)===e&&(i==null?void 0:i.type)===n}},No=b.forwardRef(({type:t="source",position:e=X.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:s=!0,id:i,onConnect:c,children:a,className:l,onMouseDown:u,onTouchStart:f,...g},h)=>{var $,F;const _=i||null,w=t==="target",p=ot(),m=Hl(),{connectOnClick:x,noPanClassName:S}=tt(Ul,st),{connecting:y,clickConnecting:M}=tt(Gl(m,_,t),st);m||(F=($=p.getState()).onError)==null||F.call($,"010",kt.error010());const C=H=>{const{defaultEdgeOptions:V,onConnect:B,hasDefaultEdges:d}=p.getState(),N={...V,...H};if(d){const{edges:v,setEdges:T}=p.getState();T(Ll(N,v))}B==null||B(N),c==null||c(N)},I=H=>{if(!m)return;const V=ho(H);o&&(V&&H.button===0||!V)&&bo({event:H,handleId:_,nodeId:m,onConnect:C,isTarget:w,getState:p.getState,setState:p.setState,isValidConnection:n||p.getState().isValidConnection||gr}),V?u==null||u(H):f==null||f(H)},D=H=>{const{onClickConnectStart:V,onClickConnectEnd:B,connectionClickStartHandle:d,connectionMode:N,isValidConnection:v}=p.getState();if(!m||!d&&!o)return;if(!d){V==null||V(H,{nodeId:m,handleId:_,handleType:t}),p.setState({connectionClickStartHandle:{nodeId:m,type:t,handleId:_}});return}const T=ao(H.target),z=n||v||gr,{connection:E,isValid:k}=So({nodeId:m,id:_,type:t},N,d.nodeId,d.handleId||null,d.type,z,T);k&&C(E),B==null||B(H),p.setState({connectionClickStartHandle:null})};return A.createElement("div",{"data-handleid":_,"data-nodeid":m,"data-handlepos":e,"data-id":`${m}-${_}-${t}`,className:ct(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",S,l,{source:!w,target:w,connectable:r,connectablestart:o,connectableend:s,connecting:M,connectionindicator:r&&(o&&!y||s&&y)}]),onMouseDown:I,onTouchStart:I,onClick:x?D:void 0,ref:h,...g},a)});No.displayName="Handle";var We=b.memo(No);const Ao=({data:t,isConnectable:e,targetPosition:n=X.Top,sourcePosition:r=X.Bottom})=>A.createElement(A.Fragment,null,A.createElement(We,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,A.createElement(We,{type:"source",position:r,isConnectable:e}));Ao.displayName="DefaultNode";var bn=b.memo(Ao);const Mo=({data:t,isConnectable:e,sourcePosition:n=X.Bottom})=>A.createElement(A.Fragment,null,t==null?void 0:t.label,A.createElement(We,{type:"source",position:n,isConnectable:e}));Mo.displayName="InputNode";var Co=b.memo(Mo);const ko=({data:t,isConnectable:e,targetPosition:n=X.Top})=>A.createElement(A.Fragment,null,A.createElement(We,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);ko.displayName="OutputNode";var $o=b.memo(ko);const Vn=()=>null;Vn.displayName="GroupNode";const Zl=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),Ie=t=>t.id;function Kl(t,e){return st(t.selectedNodes.map(Ie),e.selectedNodes.map(Ie))&&st(t.selectedEdges.map(Ie),e.selectedEdges.map(Ie))}const To=b.memo(({onSelectionChange:t})=>{const e=ot(),{selectedNodes:n,selectedEdges:r}=tt(Zl,Kl);return b.useEffect(()=>{const o={nodes:n,edges:r};t==null||t(o),e.getState().onSelectionChange.forEach(s=>s(o))},[n,r,t]),null});To.displayName="SelectionListener";const ql=t=>!!t.onSelectionChange;function jl({onSelectionChange:t}){const e=tt(ql);return t||e?A.createElement(To,{onSelectionChange:t}):null}const Ql=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function Qt(t,e){b.useEffect(()=>{typeof t<"u"&&e(t)},[t])}function G(t,e,n){b.useEffect(()=>{typeof e<"u"&&n({[t]:e})},[e])}const Jl=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:o,onConnectStart:s,onConnectEnd:i,onClickConnectStart:c,onClickConnectEnd:a,nodesDraggable:l,nodesConnectable:u,nodesFocusable:f,edgesFocusable:g,edgesUpdatable:h,elevateNodesOnSelect:_,minZoom:w,maxZoom:p,nodeExtent:m,onNodesChange:x,onEdgesChange:S,elementsSelectable:y,connectionMode:M,snapGrid:C,snapToGrid:I,translateExtent:D,connectOnClick:$,defaultEdgeOptions:F,fitView:H,fitViewOptions:V,onNodesDelete:B,onEdgesDelete:d,onNodeDrag:N,onNodeDragStart:v,onNodeDragStop:T,onSelectionDrag:z,onSelectionDragStart:E,onSelectionDragStop:k,noPanClassName:R,nodeOrigin:P,rfId:O,autoPanOnConnect:L,autoPanOnNodeDrag:W,onError:U,connectionRadius:K,isValidConnection:Q,nodeDragThreshold:j})=>{const{setNodes:q,setEdges:it,setDefaultNodesAndEdges:rt,setMinZoom:ut,setMaxZoom:at,setTranslateExtent:nt,setNodeExtent:dt,reset:J}=tt(Ql,st),Y=ot();return b.useEffect(()=>{const ft=r==null?void 0:r.map(Et=>({...Et,...F}));return rt(n,ft),()=>{J()}},[]),G("defaultEdgeOptions",F,Y.setState),G("connectionMode",M,Y.setState),G("onConnect",o,Y.setState),G("onConnectStart",s,Y.setState),G("onConnectEnd",i,Y.setState),G("onClickConnectStart",c,Y.setState),G("onClickConnectEnd",a,Y.setState),G("nodesDraggable",l,Y.setState),G("nodesConnectable",u,Y.setState),G("nodesFocusable",f,Y.setState),G("edgesFocusable",g,Y.setState),G("edgesUpdatable",h,Y.setState),G("elementsSelectable",y,Y.setState),G("elevateNodesOnSelect",_,Y.setState),G("snapToGrid",I,Y.setState),G("snapGrid",C,Y.setState),G("onNodesChange",x,Y.setState),G("onEdgesChange",S,Y.setState),G("connectOnClick",$,Y.setState),G("fitViewOnInit",H,Y.setState),G("fitViewOnInitOptions",V,Y.setState),G("onNodesDelete",B,Y.setState),G("onEdgesDelete",d,Y.setState),G("onNodeDrag",N,Y.setState),G("onNodeDragStart",v,Y.setState),G("onNodeDragStop",T,Y.setState),G("onSelectionDrag",z,Y.setState),G("onSelectionDragStart",E,Y.setState),G("onSelectionDragStop",k,Y.setState),G("noPanClassName",R,Y.setState),G("nodeOrigin",P,Y.setState),G("rfId",O,Y.setState),G("autoPanOnConnect",L,Y.setState),G("autoPanOnNodeDrag",W,Y.setState),G("onError",U,Y.setState),G("connectionRadius",K,Y.setState),G("isValidConnection",Q,Y.setState),G("nodeDragThreshold",j,Y.setState),Qt(t,q),Qt(e,it),Qt(w,ut),Qt(p,at),Qt(D,nt),Qt(m,dt),null},mr={display:"none"},tu={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Io="react-flow__node-desc",Do="react-flow__edge-desc",eu="react-flow__aria-live",nu=t=>t.ariaLiveMessage;function ru({rfId:t}){const e=tt(nu);return A.createElement("div",{id:`${eu}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:tu},e)}function ou({rfId:t,disableKeyboardA11y:e}){return A.createElement(A.Fragment,null,A.createElement("div",{id:`${Io}-${t}`,style:mr},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),A.createElement("div",{id:`${Do}-${t}`,style:mr},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&A.createElement(ru,{rfId:t}))}var Ne=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,r]=b.useState(!1),o=b.useRef(!1),s=b.useRef(new Set([])),[i,c]=b.useMemo(()=>{if(t!==null){const l=(Array.isArray(t)?t:[t]).filter(f=>typeof f=="string").map(f=>f.split("+")),u=l.reduce((f,g)=>f.concat(...g),[]);return[l,u]}return[[],[]]},[t]);return b.useEffect(()=>{const a=typeof document<"u"?document:null,l=(e==null?void 0:e.target)||a;if(t!==null){const u=h=>{if(o.current=h.ctrlKey||h.metaKey||h.shiftKey,(!o.current||o.current&&!e.actInsideInputWithModifier)&&xn(h))return!1;const w=yr(h.code,c);s.current.add(h[w]),pr(i,s.current,!1)&&(h.preventDefault(),r(!0))},f=h=>{if((!o.current||o.current&&!e.actInsideInputWithModifier)&&xn(h))return!1;const w=yr(h.code,c);pr(i,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(h[w]),h.key==="Meta"&&s.current.clear(),o.current=!1},g=()=>{s.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",u),l==null||l.addEventListener("keyup",f),window.addEventListener("blur",g),()=>{l==null||l.removeEventListener("keydown",u),l==null||l.removeEventListener("keyup",f),window.removeEventListener("blur",g)}}},[t,r]),n};function pr(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(o=>e.has(o)))}function yr(t,e){return e.includes(t)?"code":"key"}function zo(t,e,n,r){var c,a;const o=t.parentNode||t.parentId;if(!o)return n;const s=e.get(o),i=Xt(s,r);return zo(s,e,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((c=s[et])==null?void 0:c.z)??0)>(n.z??0)?((a=s[et])==null?void 0:a.z)??0:n.z??0},r)}function Ro(t,e,n){t.forEach(r=>{var s;const o=r.parentNode||r.parentId;if(o&&!t.has(o))throw new Error(`Parent node ${o} not found`);if(o||n!=null&&n[r.id]){const{x:i,y:c,z:a}=zo(r,t,{...r.position,z:((s=r[et])==null?void 0:s.z)??0},e);r.positionAbsolute={x:i,y:c},r[et].z=a,n!=null&&n[r.id]&&(r[et].isParent=!0)}})}function an(t,e,n,r){const o=new Map,s={},i=r?1e3:0;return t.forEach(c=>{var h;const a=(mt(c.zIndex)?c.zIndex:0)+(c.selected?i:0),l=e.get(c.id),u={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},f=c.parentNode||c.parentId;f&&(s[f]=!0);const g=(l==null?void 0:l.type)&&(l==null?void 0:l.type)!==c.type;Object.defineProperty(u,et,{enumerable:!1,value:{handleBounds:g||(h=l==null?void 0:l[et])==null?void 0:h.handleBounds,z:a}}),o.set(c.id,u)}),Ro(o,n,s),o}function Po(t,e={}){const{getNodes:n,width:r,height:o,minZoom:s,maxZoom:i,d3Zoom:c,d3Selection:a,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:f}=t(),g=e.initial&&!l&&u;if(c&&a&&(g||!e.initial)){const _=n().filter(p=>{var x;const m=e.includeHiddenNodes?p.width&&p.height:!p.hidden;return(x=e.nodes)!=null&&x.length?m&&e.nodes.some(S=>S.id===p.id):m}),w=_.every(p=>p.width&&p.height);if(_.length>0&&w){const p=Je(_,f),{x:m,y:x,zoom:S}=vo(p,r,o,e.minZoom??s,e.maxZoom??i,e.padding??.1),y=Mt.translate(m,x).scale(S);return typeof e.duration=="number"&&e.duration>0?c.transform(Lt(a,e.duration),y):c.transform(a,y),!0}}return!1}function su(t,e){return t.forEach(n=>{const r=e.get(n.id);r&&e.set(r.id,{...r,[et]:r[et],selected:n.selected})}),new Map(e)}function iu(t,e){return e.map(n=>{const r=t.find(o=>o.id===n.id);return r&&(n.selected=r.selected),n})}function De({changedNodes:t,changedEdges:e,get:n,set:r}){const{nodeInternals:o,edges:s,onNodesChange:i,onEdgesChange:c,hasDefaultNodes:a,hasDefaultEdges:l}=n();t!=null&&t.length&&(a&&r({nodeInternals:su(t,o)}),i==null||i(t)),e!=null&&e.length&&(l&&r({edges:iu(e,s)}),c==null||c(e))}const Jt=()=>{},cu={zoomIn:Jt,zoomOut:Jt,zoomTo:Jt,getZoom:()=>1,setViewport:Jt,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Jt,fitBounds:Jt,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},au=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection}),lu=()=>{const t=ot(),{d3Zoom:e,d3Selection:n}=tt(au,st);return b.useMemo(()=>n&&e?{zoomIn:o=>e.scaleBy(Lt(n,o==null?void 0:o.duration),1.2),zoomOut:o=>e.scaleBy(Lt(n,o==null?void 0:o.duration),1/1.2),zoomTo:(o,s)=>e.scaleTo(Lt(n,s==null?void 0:s.duration),o),getZoom:()=>t.getState().transform[2],setViewport:(o,s)=>{const[i,c,a]=t.getState().transform,l=Mt.translate(o.x??i,o.y??c).scale(o.zoom??a);e.transform(Lt(n,s==null?void 0:s.duration),l)},getViewport:()=>{const[o,s,i]=t.getState().transform;return{x:o,y:s,zoom:i}},fitView:o=>Po(t.getState,o),setCenter:(o,s,i)=>{const{width:c,height:a,maxZoom:l}=t.getState(),u=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:l,f=c/2-o*u,g=a/2-s*u,h=Mt.translate(f,g).scale(u);e.transform(Lt(n,i==null?void 0:i.duration),h)},fitBounds:(o,s)=>{const{width:i,height:c,minZoom:a,maxZoom:l}=t.getState(),{x:u,y:f,zoom:g}=vo(o,i,c,a,l,(s==null?void 0:s.padding)??.1),h=Mt.translate(u,f).scale(g);e.transform(Lt(n,s==null?void 0:s.duration),h)},project:o=>{const{transform:s,snapToGrid:i,snapGrid:c}=t.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Sn(o,s,i,c)},screenToFlowPosition:o=>{const{transform:s,snapToGrid:i,snapGrid:c,domNode:a}=t.getState();if(!a)return o;const{x:l,y:u}=a.getBoundingClientRect(),f={x:o.x-l,y:o.y-u};return Sn(f,s,i,c)},flowToScreenPosition:o=>{const{transform:s,domNode:i}=t.getState();if(!i)return o;const{x:c,y:a}=i.getBoundingClientRect(),l=wo(o,s);return{x:l.x+c,y:l.y+a}},viewportInitialized:!0}:cu,[e,n])};function Ln(){const t=lu(),e=ot(),n=b.useCallback(()=>e.getState().getNodes().map(w=>({...w})),[]),r=b.useCallback(w=>e.getState().nodeInternals.get(w),[]),o=b.useCallback(()=>{const{edges:w=[]}=e.getState();return w.map(p=>({...p}))},[]),s=b.useCallback(w=>{const{edges:p=[]}=e.getState();return p.find(m=>m.id===w)},[]),i=b.useCallback(w=>{const{getNodes:p,setNodes:m,hasDefaultNodes:x,onNodesChange:S}=e.getState(),y=p(),M=typeof w=="function"?w(y):w;if(x)m(M);else if(S){const C=M.length===0?y.map(I=>({type:"remove",id:I.id})):M.map(I=>({item:I,type:"reset"}));S(C)}},[]),c=b.useCallback(w=>{const{edges:p=[],setEdges:m,hasDefaultEdges:x,onEdgesChange:S}=e.getState(),y=typeof w=="function"?w(p):w;if(x)m(y);else if(S){const M=y.length===0?p.map(C=>({type:"remove",id:C.id})):y.map(C=>({item:C,type:"reset"}));S(M)}},[]),a=b.useCallback(w=>{const p=Array.isArray(w)?w:[w],{getNodes:m,setNodes:x,hasDefaultNodes:S,onNodesChange:y}=e.getState();if(S){const C=[...m(),...p];x(C)}else if(y){const M=p.map(C=>({item:C,type:"add"}));y(M)}},[]),l=b.useCallback(w=>{const p=Array.isArray(w)?w:[w],{edges:m=[],setEdges:x,hasDefaultEdges:S,onEdgesChange:y}=e.getState();if(S)x([...m,...p]);else if(y){const M=p.map(C=>({item:C,type:"add"}));y(M)}},[]),u=b.useCallback(()=>{const{getNodes:w,edges:p=[],transform:m}=e.getState(),[x,S,y]=m;return{nodes:w().map(M=>({...M})),edges:p.map(M=>({...M})),viewport:{x,y:S,zoom:y}}},[]),f=b.useCallback(({nodes:w,edges:p})=>{const{nodeInternals:m,getNodes:x,edges:S,hasDefaultNodes:y,hasDefaultEdges:M,onNodesDelete:C,onEdgesDelete:I,onNodesChange:D,onEdgesChange:$}=e.getState(),F=(w||[]).map(N=>N.id),H=(p||[]).map(N=>N.id),V=x().reduce((N,v)=>{const T=v.parentNode||v.parentId,z=!F.includes(v.id)&&T&&N.find(k=>k.id===T);return(typeof v.deletable=="boolean"?v.deletable:!0)&&(F.includes(v.id)||z)&&N.push(v),N},[]),B=S.filter(N=>typeof N.deletable=="boolean"?N.deletable:!0),d=B.filter(N=>H.includes(N.id));if(V||d){const N=xo(V,B),v=[...d,...N],T=v.reduce((z,E)=>(z.includes(E.id)||z.push(E.id),z),[]);if((M||y)&&(M&&e.setState({edges:S.filter(z=>!T.includes(z.id))}),y&&(V.forEach(z=>{m.delete(z.id)}),e.setState({nodeInternals:new Map(m)}))),T.length>0&&(I==null||I(v),$&&$(T.map(z=>({id:z,type:"remove"})))),V.length>0&&(C==null||C(V),D)){const z=V.map(E=>({id:E.id,type:"remove"}));D(z)}}},[]),g=b.useCallback(w=>{const p=kl(w),m=p?null:e.getState().nodeInternals.get(w.id);return!p&&!m?[null,null,p]:[p?w:ar(m),m,p]},[]),h=b.useCallback((w,p=!0,m)=>{const[x,S,y]=g(w);return x?(m||e.getState().getNodes()).filter(M=>{if(!y&&(M.id===S.id||!M.positionAbsolute))return!1;const C=ar(M),I=_n(C,x);return p&&I>0||I>=x.width*x.height}):[]},[]),_=b.useCallback((w,p,m=!0)=>{const[x]=g(w);if(!x)return!1;const S=_n(x,p);return m&&S>0||S>=x.width*x.height},[]);return b.useMemo(()=>({...t,getNodes:n,getNode:r,getEdges:o,getEdge:s,setNodes:i,setEdges:c,addNodes:a,addEdges:l,toObject:u,deleteElements:f,getIntersectingNodes:h,isNodeIntersecting:_}),[t,n,r,o,s,i,c,a,l,u,f,h,_])}const uu={actInsideInputWithModifier:!1};var fu=({deleteKeyCode:t,multiSelectionKeyCode:e})=>{const n=ot(),{deleteElements:r}=Ln(),o=Ne(t,uu),s=Ne(e);b.useEffect(()=>{if(o){const{edges:i,getNodes:c}=n.getState(),a=c().filter(u=>u.selected),l=i.filter(u=>u.selected);r({nodes:a,edges:l}),n.setState({nodesSelectionActive:!1})}},[o]),b.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])};function du(t){const e=ot();b.useEffect(()=>{let n;const r=()=>{var s,i;if(!t.current)return;const o=Dn(t.current);(o.height===0||o.width===0)&&((i=(s=e.getState()).onError)==null||i.call(s,"004",kt.error004())),e.setState({width:o.width||500,height:o.height||500})};return r(),window.addEventListener("resize",r),t.current&&(n=new ResizeObserver(()=>r()),n.observe(t.current)),()=>{window.removeEventListener("resize",r),n&&t.current&&n.unobserve(t.current)}},[])}const On={position:"absolute",width:"100%",height:"100%",top:0,left:0},hu=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,ze=t=>({x:t.x,y:t.y,zoom:t.k}),te=(t,e)=>t.target.closest(`.${e}`),wr=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),_r=t=>{const e=t.ctrlKey&&Ye()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},gu=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),mu=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:o=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:c=.5,panOnScrollMode:a=Ot.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:f=!0,defaultViewport:g,translateExtent:h,minZoom:_,maxZoom:w,zoomActivationKeyCode:p,preventScrolling:m=!0,children:x,noWheelClassName:S,noPanClassName:y})=>{const M=b.useRef(),C=ot(),I=b.useRef(!1),D=b.useRef(!1),$=b.useRef(null),F=b.useRef({x:0,y:0,zoom:0}),{d3Zoom:H,d3Selection:V,d3ZoomHandler:B,userSelectionActive:d}=tt(gu,st),N=Ne(p),v=b.useRef(0),T=b.useRef(!1),z=b.useRef();return du($),b.useEffect(()=>{if($.current){const E=$.current.getBoundingClientRect(),k=so().scaleExtent([_,w]).translateExtent(h),R=gt($.current).call(k),P=Mt.translate(g.x,g.y).scale(ae(g.zoom,_,w)),O=[[0,0],[E.width,E.height]],L=k.constrain()(P,O,h);k.transform(R,L),k.wheelDelta(_r),C.setState({d3Zoom:k,d3Selection:R,d3ZoomHandler:R.on("wheel.zoom"),transform:[L.x,L.y,L.k],domNode:$.current.closest(".react-flow")})}},[]),b.useEffect(()=>{V&&H&&(i&&!N&&!d?V.on("wheel.zoom",E=>{if(te(E,S))return!1;E.preventDefault(),E.stopImmediatePropagation();const k=V.property("__zoom").k||1;if(E.ctrlKey&&s){const Q=yt(E),j=_r(E),q=k*Math.pow(2,j);H.scaleTo(V,q,Q,E);return}const R=E.deltaMode===1?20:1;let P=a===Ot.Vertical?0:E.deltaX*R,O=a===Ot.Horizontal?0:E.deltaY*R;!Ye()&&E.shiftKey&&a!==Ot.Vertical&&(P=E.deltaY*R,O=0),H.translateBy(V,-(P/k)*c,-(O/k)*c,{internal:!0});const L=ze(V.property("__zoom")),{onViewportChangeStart:W,onViewportChange:U,onViewportChangeEnd:K}=C.getState();clearTimeout(z.current),T.current||(T.current=!0,e==null||e(E,L),W==null||W(L)),T.current&&(t==null||t(E,L),U==null||U(L),z.current=setTimeout(()=>{n==null||n(E,L),K==null||K(L),T.current=!1},150))},{passive:!1}):typeof B<"u"&&V.on("wheel.zoom",function(E,k){if(!m&&E.type==="wheel"&&!E.ctrlKey||te(E,S))return null;E.preventDefault(),B.call(this,E,k)},{passive:!1}))},[d,i,a,V,H,B,N,s,m,S,e,t,n]),b.useEffect(()=>{H&&H.on("start",E=>{var P,O;if(!E.sourceEvent||E.sourceEvent.internal)return null;v.current=(P=E.sourceEvent)==null?void 0:P.button;const{onViewportChangeStart:k}=C.getState(),R=ze(E.transform);I.current=!0,F.current=R,((O=E.sourceEvent)==null?void 0:O.type)==="mousedown"&&C.setState({paneDragging:!0}),k==null||k(R),e==null||e(E.sourceEvent,R)})},[H,e]),b.useEffect(()=>{H&&(d&&!I.current?H.on("zoom",null):d||H.on("zoom",E=>{var R;const{onViewportChange:k}=C.getState();if(C.setState({transform:[E.transform.x,E.transform.y,E.transform.k]}),D.current=!!(r&&wr(f,v.current??0)),(t||k)&&!((R=E.sourceEvent)!=null&&R.internal)){const P=ze(E.transform);k==null||k(P),t==null||t(E.sourceEvent,P)}}))},[d,H,t,f,r]),b.useEffect(()=>{H&&H.on("end",E=>{if(!E.sourceEvent||E.sourceEvent.internal)return null;const{onViewportChangeEnd:k}=C.getState();if(I.current=!1,C.setState({paneDragging:!1}),r&&wr(f,v.current??0)&&!D.current&&r(E.sourceEvent),D.current=!1,(n||k)&&hu(F.current,E.transform)){const R=ze(E.transform);F.current=R,clearTimeout(M.current),M.current=setTimeout(()=>{k==null||k(R),n==null||n(E.sourceEvent,R)},i?150:0)}})},[H,i,f,n,r]),b.useEffect(()=>{H&&H.filter(E=>{const k=N||o,R=s&&E.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&E.button===1&&E.type==="mousedown"&&(te(E,"react-flow__node")||te(E,"react-flow__edge")))return!0;if(!f&&!k&&!i&&!l&&!s||d||!l&&E.type==="dblclick"||te(E,S)&&E.type==="wheel"||te(E,y)&&(E.type!=="wheel"||i&&E.type==="wheel"&&!N)||!s&&E.ctrlKey&&E.type==="wheel"||!k&&!i&&!R&&E.type==="wheel"||!f&&(E.type==="mousedown"||E.type==="touchstart")||Array.isArray(f)&&!f.includes(E.button)&&E.type==="mousedown")return!1;const P=Array.isArray(f)&&f.includes(E.button)||!E.button||E.button<=1;return(!E.ctrlKey||E.type==="wheel")&&P})},[d,H,o,s,i,l,f,u,N]),A.createElement("div",{className:"react-flow__renderer",ref:$,style:On},x)},pu=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function yu(){const{userSelectionActive:t,userSelectionRect:e}=tt(pu,st);return t&&e?A.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function xr(t,e){const n=e.parentNode||e.parentId,r=t.find(o=>o.id===n);if(r){const o=e.position.x+e.width-r.width,s=e.position.y+e.height-r.height;if(o>0||s>0||e.position.x<0||e.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,o>0&&(r.style.width+=o),s>0&&(r.style.height+=s),e.position.x<0){const i=Math.abs(e.position.x);r.position.x=r.position.x-i,r.style.width+=i,e.position.x=0}if(e.position.y<0){const i=Math.abs(e.position.y);r.position.y=r.position.y-i,r.style.height+=i,e.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Ho(t,e){if(t.some(r=>r.type==="reset"))return t.filter(r=>r.type==="reset").map(r=>r.item);const n=t.filter(r=>r.type==="add").map(r=>r.item);return e.reduce((r,o)=>{const s=t.filter(c=>c.id===o.id);if(s.length===0)return r.push(o),r;const i={...o};for(const c of s)if(c)switch(c.type){case"select":{i.selected=c.selected;break}case"position":{typeof c.position<"u"&&(i.position=c.position),typeof c.positionAbsolute<"u"&&(i.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(i.dragging=c.dragging),i.expandParent&&xr(r,i);break}case"dimensions":{typeof c.dimensions<"u"&&(i.width=c.dimensions.width,i.height=c.dimensions.height),typeof c.updateStyle<"u"&&(i.style={...i.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(i.resizing=c.resizing),i.expandParent&&xr(r,i);break}case"remove":return r}return r.push(i),r},n)}function Bo(t,e){return Ho(t,e)}function wu(t,e){return Ho(t,e)}const Tt=(t,e)=>({id:t,type:"select",selected:e});function ne(t,e){return t.reduce((n,r)=>{const o=e.includes(r.id);return!r.selected&&o?(r.selected=!0,n.push(Tt(r.id,!0))):r.selected&&!o&&(r.selected=!1,n.push(Tt(r.id,!1))),n},[])}const ln=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},_u=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),Fo=b.memo(({isSelecting:t,selectionMode:e=be.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:o,onPaneClick:s,onPaneContextMenu:i,onPaneScroll:c,onPaneMouseEnter:a,onPaneMouseMove:l,onPaneMouseLeave:u,children:f})=>{const g=b.useRef(null),h=ot(),_=b.useRef(0),w=b.useRef(0),p=b.useRef(),{userSelectionActive:m,elementsSelectable:x,dragging:S}=tt(_u,st),y=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),_.current=0,w.current=0},M=B=>{s==null||s(B),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},C=B=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){B.preventDefault();return}i==null||i(B)},I=c?B=>c(B):void 0,D=B=>{const{resetSelectedElements:d,domNode:N}=h.getState();if(p.current=N==null?void 0:N.getBoundingClientRect(),!x||!t||B.button!==0||B.target!==g.current||!p.current)return;const{x:v,y:T}=Dt(B,p.current);d(),h.setState({userSelectionRect:{width:0,height:0,startX:v,startY:T,x:v,y:T}}),r==null||r(B)},$=B=>{const{userSelectionRect:d,nodeInternals:N,edges:v,transform:T,onNodesChange:z,onEdgesChange:E,nodeOrigin:k,getNodes:R}=h.getState();if(!t||!p.current||!d)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const P=Dt(B,p.current),O=d.startX??0,L=d.startY??0,W={...d,x:P.x<O?P.x:O,y:P.y<L?P.y:L,width:Math.abs(P.x-O),height:Math.abs(P.y-L)},U=R(),K=_o(N,W,T,e===be.Partial,!0,k),Q=xo(K,v).map(q=>q.id),j=K.map(q=>q.id);if(_.current!==j.length){_.current=j.length;const q=ne(U,j);q.length&&(z==null||z(q))}if(w.current!==Q.length){w.current=Q.length;const q=ne(v,Q);q.length&&(E==null||E(q))}h.setState({userSelectionRect:W})},F=B=>{if(B.button!==0)return;const{userSelectionRect:d}=h.getState();!m&&d&&B.target===g.current&&(M==null||M(B)),h.setState({nodesSelectionActive:_.current>0}),y(),o==null||o(B)},H=B=>{m&&(h.setState({nodesSelectionActive:_.current>0}),o==null||o(B)),y()},V=x&&(t||m);return A.createElement("div",{className:ct(["react-flow__pane",{dragging:S,selection:t}]),onClick:V?void 0:ln(M,g),onContextMenu:ln(C,g),onWheel:ln(I,g),onMouseEnter:V?void 0:a,onMouseDown:V?D:void 0,onMouseMove:V?$:l,onMouseUp:V?F:void 0,onMouseLeave:V?H:u,ref:g,style:On},f,A.createElement(yu,null))});Fo.displayName="Pane";function Vo(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const r=e.get(n);return r?r.selected?!0:Vo(r,e):!1}function vr(t,e,n){let r=t;do{if(r!=null&&r.matches(e))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function xu(t,e,n,r){return Array.from(t.values()).filter(o=>(o.selected||o.id===r)&&(!o.parentNode||o.parentId||!Vo(o,t))&&(o.draggable||e&&typeof o.draggable>"u")).map(o=>{var s,i;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((s=o.positionAbsolute)==null?void 0:s.x)??0),y:n.y-(((i=o.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode||o.parentId,parentId:o.parentNode||o.parentId,width:o.width,height:o.height,expandParent:o.expandParent}})}function vu(t,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(t.width||0),e[1][1]-(t.height||0)]]}function Lo(t,e,n,r,o=[0,0],s){const i=vu(t,t.extent||r);let c=i;const a=t.parentNode||t.parentId;if(t.extent==="parent"&&!t.expandParent)if(a&&t.width&&t.height){const f=n.get(a),{x:g,y:h}=Xt(f,o).positionAbsolute;c=f&&mt(g)&&mt(h)&&mt(f.width)&&mt(f.height)?[[g+t.width*o[0],h+t.height*o[1]],[g+f.width-t.width+t.width*o[0],h+f.height-t.height+t.height*o[1]]]:c}else s==null||s("005",kt.error005()),c=i;else if(t.extent&&a&&t.extent!=="parent"){const f=n.get(a),{x:g,y:h}=Xt(f,o).positionAbsolute;c=[[t.extent[0][0]+g,t.extent[0][1]+h],[t.extent[1][0]+g,t.extent[1][1]+h]]}let l={x:0,y:0};if(a){const f=n.get(a);l=Xt(f,o).positionAbsolute}const u=c&&c!=="parent"?zn(e,c):e;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function un({nodeId:t,dragItems:e,nodeInternals:n}){const r=e.map(o=>({...n.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[t?r.find(o=>o.id===t):r[0],r]}const Er=(t,e,n,r)=>{const o=e.querySelectorAll(t);if(!o||!o.length)return null;const s=Array.from(o),i=e.getBoundingClientRect(),c={x:i.width*r[0],y:i.height*r[1]};return s.map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),position:a.getAttribute("data-handlepos"),x:(l.left-i.left-c.x)/n,y:(l.top-i.top-c.y)/n,...Dn(a)}})};function pe(t,e,n){return n===void 0?n:r=>{const o=e().nodeInternals.get(t);o&&n(r,{...o})}}function Nn({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeInternals:c,onError:a}=e.getState(),l=c.get(t);if(!l){a==null||a("012",kt.error012(t));return}e.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(s({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):o([t])}function Eu(){const t=ot();return b.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:o,snapToGrid:s}=t.getState(),i=n.touches?n.touches[0].clientX:n.clientX,c=n.touches?n.touches[0].clientY:n.clientY,a={x:(i-r[0])/r[2],y:(c-r[1])/r[2]};return{xSnapped:s?o[0]*Math.round(a.x/o[0]):a.x,ySnapped:s?o[1]*Math.round(a.y/o[1]):a.y,...a}},[])}function fn(t){return(e,n,r)=>t==null?void 0:t(e,r)}function Oo({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:s,selectNodesOnDrag:i}){const c=ot(),[a,l]=b.useState(!1),u=b.useRef([]),f=b.useRef({x:null,y:null}),g=b.useRef(0),h=b.useRef(null),_=b.useRef({x:0,y:0}),w=b.useRef(null),p=b.useRef(!1),m=b.useRef(!1),x=b.useRef(!1),S=Eu();return b.useEffect(()=>{if(t!=null&&t.current){const y=gt(t.current),M=({x:D,y:$})=>{const{nodeInternals:F,onNodeDrag:H,onSelectionDrag:V,updateNodePositions:B,nodeExtent:d,snapGrid:N,snapToGrid:v,nodeOrigin:T,onError:z}=c.getState();f.current={x:D,y:$};let E=!1,k={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&d){const P=Je(u.current,T);k=Se(P)}if(u.current=u.current.map(P=>{const O={x:D-P.distance.x,y:$-P.distance.y};v&&(O.x=N[0]*Math.round(O.x/N[0]),O.y=N[1]*Math.round(O.y/N[1]));const L=[[d[0][0],d[0][1]],[d[1][0],d[1][1]]];u.current.length>1&&d&&!P.extent&&(L[0][0]=P.positionAbsolute.x-k.x+d[0][0],L[1][0]=P.positionAbsolute.x+(P.width??0)-k.x2+d[1][0],L[0][1]=P.positionAbsolute.y-k.y+d[0][1],L[1][1]=P.positionAbsolute.y+(P.height??0)-k.y2+d[1][1]);const W=Lo(P,O,F,L,T,z);return E=E||P.position.x!==W.position.x||P.position.y!==W.position.y,P.position=W.position,P.positionAbsolute=W.positionAbsolute,P}),!E)return;B(u.current,!0,!0),l(!0);const R=o?H:fn(V);if(R&&w.current){const[P,O]=un({nodeId:o,dragItems:u.current,nodeInternals:F});R(w.current,P,O)}},C=()=>{if(!h.current)return;const[D,$]=co(_.current,h.current);if(D!==0||$!==0){const{transform:F,panBy:H}=c.getState();f.current.x=(f.current.x??0)-D/F[2],f.current.y=(f.current.y??0)-$/F[2],H({x:D,y:$})&&M(f.current)}g.current=requestAnimationFrame(C)},I=D=>{var T;const{nodeInternals:$,multiSelectionActive:F,nodesDraggable:H,unselectNodesAndEdges:V,onNodeDragStart:B,onSelectionDragStart:d}=c.getState();m.current=!0;const N=o?B:fn(d);(!i||!s)&&!F&&o&&((T=$.get(o))!=null&&T.selected||V()),o&&s&&i&&Nn({id:o,store:c,nodeRef:t});const v=S(D);if(f.current=v,u.current=xu($,H,v,o),N&&u.current){const[z,E]=un({nodeId:o,dragItems:u.current,nodeInternals:$});N(D.sourceEvent,z,E)}};if(e)y.on(".drag",null);else{const D=jc().on("start",$=>{const{domNode:F,nodeDragThreshold:H}=c.getState();H===0&&I($),x.current=!1;const V=S($);f.current=V,h.current=(F==null?void 0:F.getBoundingClientRect())||null,_.current=Dt($.sourceEvent,h.current)}).on("drag",$=>{var B,d;const F=S($),{autoPanOnNodeDrag:H,nodeDragThreshold:V}=c.getState();if($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1&&(x.current=!0),!x.current){if(!p.current&&m.current&&H&&(p.current=!0,C()),!m.current){const N=F.xSnapped-(((B=f==null?void 0:f.current)==null?void 0:B.x)??0),v=F.ySnapped-(((d=f==null?void 0:f.current)==null?void 0:d.y)??0);Math.sqrt(N*N+v*v)>V&&I($)}(f.current.x!==F.xSnapped||f.current.y!==F.ySnapped)&&u.current&&m.current&&(w.current=$.sourceEvent,_.current=Dt($.sourceEvent,h.current),M(F))}}).on("end",$=>{if(!(!m.current||x.current)&&(l(!1),p.current=!1,m.current=!1,cancelAnimationFrame(g.current),u.current)){const{updateNodePositions:F,nodeInternals:H,onNodeDragStop:V,onSelectionDragStop:B}=c.getState(),d=o?V:fn(B);if(F(u.current,!1,!1),d){const[N,v]=un({nodeId:o,dragItems:u.current,nodeInternals:H});d($.sourceEvent,N,v)}}}).filter($=>{const F=$.target;return!$.button&&(!n||!vr(F,`.${n}`,t))&&(!r||vr(F,r,t))});return y.call(D),()=>{y.on(".drag",null)}}}},[t,e,n,r,s,c,o,i,S]),a}function Yo(){const t=ot();return b.useCallback(n=>{const{nodeInternals:r,nodeExtent:o,updateNodePositions:s,getNodes:i,snapToGrid:c,snapGrid:a,onError:l,nodesDraggable:u}=t.getState(),f=i().filter(x=>x.selected&&(x.draggable||u&&typeof x.draggable>"u")),g=c?a[0]:5,h=c?a[1]:5,_=n.isShiftPressed?4:1,w=n.x*g*_,p=n.y*h*_,m=f.map(x=>{if(x.positionAbsolute){const S={x:x.positionAbsolute.x+w,y:x.positionAbsolute.y+p};c&&(S.x=a[0]*Math.round(S.x/a[0]),S.y=a[1]*Math.round(S.y/a[1]));const{positionAbsolute:y,position:M}=Lo(x,S,r,o,void 0,l);x.position=M,x.positionAbsolute=y}return x});s(m,!0,!1)},[])}const oe={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var ye=t=>{const e=({id:n,type:r,data:o,xPos:s,yPos:i,xPosOrigin:c,yPosOrigin:a,selected:l,onClick:u,onMouseEnter:f,onMouseMove:g,onMouseLeave:h,onContextMenu:_,onDoubleClick:w,style:p,className:m,isDraggable:x,isSelectable:S,isConnectable:y,isFocusable:M,selectNodesOnDrag:C,sourcePosition:I,targetPosition:D,hidden:$,resizeObserver:F,dragHandle:H,zIndex:V,isParent:B,noDragClassName:d,noPanClassName:N,initialized:v,disableKeyboardA11y:T,ariaLabel:z,rfId:E,hasHandleBounds:k})=>{const R=ot(),P=b.useRef(null),O=b.useRef(null),L=b.useRef(I),W=b.useRef(D),U=b.useRef(r),K=S||x||u||f||g||h,Q=Yo(),j=pe(n,R.getState,f),q=pe(n,R.getState,g),it=pe(n,R.getState,h),rt=pe(n,R.getState,_),ut=pe(n,R.getState,w),at=J=>{const{nodeDragThreshold:Y}=R.getState();if(S&&(!C||!x||Y>0)&&Nn({id:n,store:R,nodeRef:P}),u){const ft=R.getState().nodeInternals.get(n);ft&&u(J,{...ft})}},nt=J=>{if(!xn(J)&&!T)if(fo.includes(J.key)&&S){const Y=J.key==="Escape";Nn({id:n,store:R,unselect:Y,nodeRef:P})}else x&&l&&Object.prototype.hasOwnProperty.call(oe,J.key)&&(R.setState({ariaLiveMessage:`Moved selected node ${J.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~i}`}),Q({x:oe[J.key].x,y:oe[J.key].y,isShiftPressed:J.shiftKey}))};b.useEffect(()=>()=>{O.current&&(F==null||F.unobserve(O.current),O.current=null)},[]),b.useEffect(()=>{if(P.current&&!$){const J=P.current;(!v||!k||O.current!==J)&&(O.current&&(F==null||F.unobserve(O.current)),F==null||F.observe(J),O.current=J)}},[$,v,k]),b.useEffect(()=>{const J=U.current!==r,Y=L.current!==I,ft=W.current!==D;P.current&&(J||Y||ft)&&(J&&(U.current=r),Y&&(L.current=I),ft&&(W.current=D),R.getState().updateNodeDimensions([{id:n,nodeElement:P.current,forceUpdate:!0}]))},[n,r,I,D]);const dt=Oo({nodeRef:P,disabled:$||!x,noDragClassName:d,handleSelector:H,nodeId:n,isSelectable:S,selectNodesOnDrag:C});return $?null:A.createElement("div",{className:ct(["react-flow__node",`react-flow__node-${r}`,{[N]:x},m,{selected:l,selectable:S,parent:B,dragging:dt}]),ref:P,style:{zIndex:V,transform:`translate(${c}px,${a}px)`,pointerEvents:K?"all":"none",visibility:v?"visible":"hidden",...p},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:j,onMouseMove:q,onMouseLeave:it,onContextMenu:rt,onClick:at,onDoubleClick:ut,onKeyDown:M?nt:void 0,tabIndex:M?0:void 0,role:M?"button":void 0,"aria-describedby":T?void 0:`${Io}-${E}`,"aria-label":z},A.createElement(Pl,{value:n},A.createElement(t,{id:n,data:o,type:r,xPos:s,yPos:i,selected:l,isConnectable:y,sourcePosition:I,targetPosition:D,dragging:dt,dragHandle:H,zIndex:V})))};return e.displayName="NodeWrapper",b.memo(e)};const Su=t=>{const e=t.getNodes().filter(n=>n.selected);return{...Je(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};function bu({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=ot(),{width:o,height:s,x:i,y:c,transformString:a,userSelectionActive:l}=tt(Su,st),u=Yo(),f=b.useRef(null);if(b.useEffect(()=>{var _;n||(_=f.current)==null||_.focus({preventScroll:!0})},[n]),Oo({nodeRef:f}),l||!o||!s)return null;const g=t?_=>{const w=r.getState().getNodes().filter(p=>p.selected);t(_,w)}:void 0,h=_=>{Object.prototype.hasOwnProperty.call(oe,_.key)&&u({x:oe[_.key].x,y:oe[_.key].y,isShiftPressed:_.shiftKey})};return A.createElement("div",{className:ct(["react-flow__nodesselection","react-flow__container",e]),style:{transform:a}},A.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:o,height:s,top:c,left:i}}))}var Nu=b.memo(bu);const Au=t=>t.nodesSelectionActive,Xo=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,deleteKeyCode:c,onMove:a,onMoveStart:l,onMoveEnd:u,selectionKeyCode:f,selectionOnDrag:g,selectionMode:h,onSelectionStart:_,onSelectionEnd:w,multiSelectionKeyCode:p,panActivationKeyCode:m,zoomActivationKeyCode:x,elementsSelectable:S,zoomOnScroll:y,zoomOnPinch:M,panOnScroll:C,panOnScrollSpeed:I,panOnScrollMode:D,zoomOnDoubleClick:$,panOnDrag:F,defaultViewport:H,translateExtent:V,minZoom:B,maxZoom:d,preventScrolling:N,onSelectionContextMenu:v,noWheelClassName:T,noPanClassName:z,disableKeyboardA11y:E})=>{const k=tt(Au),R=Ne(f),P=Ne(m),O=P||F,L=P||C,W=R||g&&O!==!0;return fu({deleteKeyCode:c,multiSelectionKeyCode:p}),A.createElement(mu,{onMove:a,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:s,elementsSelectable:S,zoomOnScroll:y,zoomOnPinch:M,panOnScroll:L,panOnScrollSpeed:I,panOnScrollMode:D,zoomOnDoubleClick:$,panOnDrag:!R&&O,defaultViewport:H,translateExtent:V,minZoom:B,maxZoom:d,zoomActivationKeyCode:x,preventScrolling:N,noWheelClassName:T,noPanClassName:z},A.createElement(Fo,{onSelectionStart:_,onSelectionEnd:w,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:O,isSelecting:!!W,selectionMode:h},t,k&&A.createElement(Nu,{onSelectionContextMenu:v,noPanClassName:z,disableKeyboardA11y:E})))};Xo.displayName="FlowRenderer";var Mu=b.memo(Xo);function Cu(t){return tt(b.useCallback(n=>t?_o(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[t]))}function ku(t){const e={input:ye(t.input||Co),default:ye(t.default||bn),output:ye(t.output||$o),group:ye(t.group||Vn)},n={},r=Object.keys(t).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,s)=>(o[s]=ye(t[s]||bn),o),n);return{...e,...r}}const $u=({x:t,y:e,width:n,height:r,origin:o})=>!n||!r?{x:t,y:e}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:t,y:e}:{x:t-n*o[0],y:e-r*o[1]},Tu=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),Wo=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,updateNodeDimensions:s,onError:i}=tt(Tu,st),c=Cu(t.onlyRenderVisibleElements),a=b.useRef(),l=b.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(f=>{const g=f.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));s(g)});return a.current=u,u},[]);return b.useEffect(()=>()=>{var u;(u=a==null?void 0:a.current)==null||u.disconnect()},[]),A.createElement("div",{className:"react-flow__nodes",style:On},c.map(u=>{var M,C,I;let f=u.type||"default";t.nodeTypes[f]||(i==null||i("003",kt.error003(f)),f="default");const g=t.nodeTypes[f]||t.nodeTypes.default,h=!!(u.draggable||e&&typeof u.draggable>"u"),_=!!(u.selectable||o&&typeof u.selectable>"u"),w=!!(u.connectable||n&&typeof u.connectable>"u"),p=!!(u.focusable||r&&typeof u.focusable>"u"),m=t.nodeExtent?zn(u.positionAbsolute,t.nodeExtent):u.positionAbsolute,x=(m==null?void 0:m.x)??0,S=(m==null?void 0:m.y)??0,y=$u({x,y:S,width:u.width??0,height:u.height??0,origin:t.nodeOrigin});return A.createElement(g,{key:u.id,id:u.id,className:u.className,style:u.style,type:f,data:u.data,sourcePosition:u.sourcePosition||X.Bottom,targetPosition:u.targetPosition||X.Top,hidden:u.hidden,xPos:x,yPos:S,xPosOrigin:y.x,yPosOrigin:y.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!u.selected,isDraggable:h,isSelectable:_,isConnectable:w,isFocusable:p,resizeObserver:l,dragHandle:u.dragHandle,zIndex:((M=u[et])==null?void 0:M.z)??0,isParent:!!((C=u[et])!=null&&C.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!u.width&&!!u.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((I=u[et])!=null&&I.handleBounds)})}))};Wo.displayName="NodeRenderer";var Iu=b.memo(Wo);const Du=(t,e,n)=>n===X.Left?t-e:n===X.Right?t+e:t,zu=(t,e,n)=>n===X.Top?t-e:n===X.Bottom?t+e:t,Sr="react-flow__edgeupdater",br=({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:c})=>A.createElement("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:ct([Sr,`${Sr}-${c}`]),cx:Du(e,r,t),cy:zu(n,r,t),r,stroke:"transparent",fill:"transparent"}),Ru=()=>!0;var ee=t=>{const e=({id:n,className:r,type:o,data:s,onClick:i,onEdgeDoubleClick:c,selected:a,animated:l,label:u,labelStyle:f,labelShowBg:g,labelBgStyle:h,labelBgPadding:_,labelBgBorderRadius:w,style:p,source:m,target:x,sourceX:S,sourceY:y,targetX:M,targetY:C,sourcePosition:I,targetPosition:D,elementsSelectable:$,hidden:F,sourceHandleId:H,targetHandleId:V,onContextMenu:B,onMouseEnter:d,onMouseMove:N,onMouseLeave:v,reconnectRadius:T,onReconnect:z,onReconnectStart:E,onReconnectEnd:k,markerEnd:R,markerStart:P,rfId:O,ariaLabel:L,isFocusable:W,isReconnectable:U,pathOptions:K,interactionWidth:Q,disableKeyboardA11y:j})=>{const q=b.useRef(null),[it,rt]=b.useState(!1),[ut,at]=b.useState(!1),nt=ot(),dt=b.useMemo(()=>`url('#${En(P,O)}')`,[P,O]),J=b.useMemo(()=>`url('#${En(R,O)}')`,[R,O]);if(F)return null;const Y=lt=>{var xt;const{edges:pt,addSelectedEdges:Pt,unselectNodesAndEdges:Ht,multiSelectionActive:Bt}=nt.getState(),bt=pt.find(fe=>fe.id===n);bt&&($&&(nt.setState({nodesSelectionActive:!1}),bt.selected&&Bt?(Ht({nodes:[],edges:[bt]}),(xt=q.current)==null||xt.blur()):Pt([n])),i&&i(lt,bt))},ft=me(n,nt.getState,c),Et=me(n,nt.getState,B),le=me(n,nt.getState,d),Gt=me(n,nt.getState,N),Zt=me(n,nt.getState,v),St=(lt,pt)=>{if(lt.button!==0)return;const{edges:Pt,isValidConnection:Ht}=nt.getState(),Bt=pt?x:m,bt=(pt?V:H)||null,xt=pt?"target":"source",fe=Ht||Ru,tn=pt,de=Pt.find(Ft=>Ft.id===n);at(!0),E==null||E(lt,de,xt);const en=Ft=>{at(!1),k==null||k(Ft,de,xt)};bo({event:lt,handleId:bt,nodeId:Bt,onConnect:Ft=>z==null?void 0:z(de,Ft),isTarget:tn,getState:nt.getState,setState:nt.setState,isValidConnection:fe,edgeUpdaterType:xt,onReconnectEnd:en})},Kt=lt=>St(lt,!0),zt=lt=>St(lt,!1),Rt=()=>rt(!0),qt=()=>rt(!1),jt=!$&&!i,ue=lt=>{var pt;if(!j&&fo.includes(lt.key)&&$){const{unselectNodesAndEdges:Pt,addSelectedEdges:Ht,edges:Bt}=nt.getState();lt.key==="Escape"?((pt=q.current)==null||pt.blur(),Pt({edges:[Bt.find(xt=>xt.id===n)]})):Ht([n])}};return A.createElement("g",{className:ct(["react-flow__edge",`react-flow__edge-${o}`,r,{selected:a,animated:l,inactive:jt,updating:it}]),onClick:Y,onDoubleClick:ft,onContextMenu:Et,onMouseEnter:le,onMouseMove:Gt,onMouseLeave:Zt,onKeyDown:W?ue:void 0,tabIndex:W?0:void 0,role:W?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":L===null?void 0:L||`Edge from ${m} to ${x}`,"aria-describedby":W?`${Do}-${O}`:void 0,ref:q},!ut&&A.createElement(t,{id:n,source:m,target:x,selected:a,animated:l,label:u,labelStyle:f,labelShowBg:g,labelBgStyle:h,labelBgPadding:_,labelBgBorderRadius:w,data:s,style:p,sourceX:S,sourceY:y,targetX:M,targetY:C,sourcePosition:I,targetPosition:D,sourceHandleId:H,targetHandleId:V,markerStart:dt,markerEnd:J,pathOptions:K,interactionWidth:Q}),U&&A.createElement(A.Fragment,null,(U==="source"||U===!0)&&A.createElement(br,{position:I,centerX:S,centerY:y,radius:T,onMouseDown:Kt,onMouseEnter:Rt,onMouseOut:qt,type:"source"}),(U==="target"||U===!0)&&A.createElement(br,{position:D,centerX:M,centerY:C,radius:T,onMouseDown:zt,onMouseEnter:Rt,onMouseOut:qt,type:"target"})))};return e.displayName="EdgeWrapper",b.memo(e)};function Pu(t){const e={default:ee(t.default||Xe),straight:ee(t.bezier||Hn),step:ee(t.step||Pn),smoothstep:ee(t.step||Qe),simplebezier:ee(t.simplebezier||Rn)},n={},r=Object.keys(t).filter(o=>!["default","bezier"].includes(o)).reduce((o,s)=>(o[s]=ee(t[s]||Xe),o),n);return{...e,...r}}function Nr(t,e,n=null){const r=((n==null?void 0:n.x)||0)+e.x,o=((n==null?void 0:n.y)||0)+e.y,s=(n==null?void 0:n.width)||e.width,i=(n==null?void 0:n.height)||e.height;switch(t){case X.Top:return{x:r+s/2,y:o};case X.Right:return{x:r+s,y:o+i/2};case X.Bottom:return{x:r+s/2,y:o+i};case X.Left:return{x:r,y:o+i/2}}}function Ar(t,e){return t?t.length===1||!e?t[0]:e&&t.find(n=>n.id===e)||null:null}const Hu=(t,e,n,r,o,s)=>{const i=Nr(n,t,e),c=Nr(s,r,o);return{sourceX:i.x,sourceY:i.y,targetX:c.x,targetY:c.y}};function Bu({sourcePos:t,targetPos:e,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:s,width:i,height:c,transform:a}){const l={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x+n,e.x+o),y2:Math.max(t.y+r,e.y+s)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u=Se({x:(0-a[0])/a[2],y:(0-a[1])/a[2],width:i/a[2],height:c/a[2]}),f=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),g=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(f*g)>0}function Mr(t){var r,o,s,i,c;const e=((r=t==null?void 0:t[et])==null?void 0:r.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&typeof((o=t==null?void 0:t.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.y)<"u";return[{x:((i=t==null?void 0:t.positionAbsolute)==null?void 0:i.x)||0,y:((c=t==null?void 0:t.positionAbsolute)==null?void 0:c.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const Fu=[{level:0,isMaxLevel:!0,edges:[]}];function Vu(t,e,n=!1){let r=-1;const o=t.reduce((i,c)=>{var u,f;const a=mt(c.zIndex);let l=a?c.zIndex:0;if(n){const g=e.get(c.target),h=e.get(c.source),_=c.selected||(g==null?void 0:g.selected)||(h==null?void 0:h.selected),w=Math.max(((u=h==null?void 0:h[et])==null?void 0:u.z)||0,((f=g==null?void 0:g[et])==null?void 0:f.z)||0,1e3);l=(a?c.zIndex:0)+(_?w:0)}return i[l]?i[l].push(c):i[l]=[c],r=l>r?l:r,i},{}),s=Object.entries(o).map(([i,c])=>{const a=+i;return{edges:c,level:a,isMaxLevel:a===r}});return s.length===0?Fu:s}function Lu(t,e,n){const r=tt(b.useCallback(o=>t?o.edges.filter(s=>{const i=e.get(s.source),c=e.get(s.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&Bu({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:c.width,targetHeight:c.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[t,e]));return Vu(r,e,n)}const Ou=({color:t="none",strokeWidth:e=1})=>A.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Yu=({color:t="none",strokeWidth:e=1})=>A.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Cr={[Yt.Arrow]:Ou,[Yt.ArrowClosed]:Yu};function Xu(t){const e=ot();return b.useMemo(()=>{var o,s;return Object.prototype.hasOwnProperty.call(Cr,t)?Cr[t]:((s=(o=e.getState()).onError)==null||s.call(o,"009",kt.error009(t)),null)},[t])}const Wu=({id:t,type:e,color:n,width:r=12.5,height:o=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:c="auto-start-reverse"})=>{const a=Xu(e);return a?A.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:c,refX:"0",refY:"0"},A.createElement(a,{color:n,strokeWidth:i})):null},Uu=({defaultColor:t,rfId:e})=>n=>{const r=[];return n.edges.reduce((o,s)=>([s.markerStart,s.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const c=En(i,e);r.includes(c)||(o.push({id:c,color:i.color||t,...i}),r.push(c))}}),o),[]).sort((o,s)=>o.id.localeCompare(s.id))},Uo=({defaultColor:t,rfId:e})=>{const n=tt(b.useCallback(Uu({defaultColor:t,rfId:e}),[t,e]),(r,o)=>!(r.length!==o.length||r.some((s,i)=>s.id!==o[i].id)));return A.createElement("defs",null,n.map(r=>A.createElement(Wu,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};Uo.displayName="MarkerDefinitions";var Gu=b.memo(Uo);const Zu=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),Go=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:r,edgeTypes:o,noPanClassName:s,onEdgeContextMenu:i,onEdgeMouseEnter:c,onEdgeMouseMove:a,onEdgeMouseLeave:l,onEdgeClick:u,onEdgeDoubleClick:f,onReconnect:g,onReconnectStart:h,onReconnectEnd:_,reconnectRadius:w,children:p,disableKeyboardA11y:m})=>{const{edgesFocusable:x,edgesUpdatable:S,elementsSelectable:y,width:M,height:C,connectionMode:I,nodeInternals:D,onError:$}=tt(Zu,st),F=Lu(e,D,n);return M?A.createElement(A.Fragment,null,F.map(({level:H,edges:V,isMaxLevel:B})=>A.createElement("svg",{key:H,style:{zIndex:H},width:M,height:C,className:"react-flow__edges react-flow__container"},B&&A.createElement(Gu,{defaultColor:t,rfId:r}),A.createElement("g",null,V.map(d=>{const[N,v,T]=Mr(D.get(d.source)),[z,E,k]=Mr(D.get(d.target));if(!T||!k)return null;let R=d.type||"default";o[R]||($==null||$("011",kt.error011(R)),R="default");const P=o[R]||o.default,O=I===Ut.Strict?E.target:(E.target??[]).concat(E.source??[]),L=Ar(v.source,d.sourceHandle),W=Ar(O,d.targetHandle),U=(L==null?void 0:L.position)||X.Bottom,K=(W==null?void 0:W.position)||X.Top,Q=!!(d.focusable||x&&typeof d.focusable>"u"),j=d.reconnectable||d.updatable,q=typeof g<"u"&&(j||S&&typeof j>"u");if(!L||!W)return $==null||$("008",kt.error008(L,d)),null;const{sourceX:it,sourceY:rt,targetX:ut,targetY:at}=Hu(N,L,U,z,W,K);return A.createElement(P,{key:d.id,id:d.id,className:ct([d.className,s]),type:R,data:d.data,selected:!!d.selected,animated:!!d.animated,hidden:!!d.hidden,label:d.label,labelStyle:d.labelStyle,labelShowBg:d.labelShowBg,labelBgStyle:d.labelBgStyle,labelBgPadding:d.labelBgPadding,labelBgBorderRadius:d.labelBgBorderRadius,style:d.style,source:d.source,target:d.target,sourceHandleId:d.sourceHandle,targetHandleId:d.targetHandle,markerEnd:d.markerEnd,markerStart:d.markerStart,sourceX:it,sourceY:rt,targetX:ut,targetY:at,sourcePosition:U,targetPosition:K,elementsSelectable:y,onContextMenu:i,onMouseEnter:c,onMouseMove:a,onMouseLeave:l,onClick:u,onEdgeDoubleClick:f,onReconnect:g,onReconnectStart:h,onReconnectEnd:_,reconnectRadius:w,rfId:r,ariaLabel:d.ariaLabel,isFocusable:Q,isReconnectable:q,pathOptions:"pathOptions"in d?d.pathOptions:void 0,interactionWidth:d.interactionWidth,disableKeyboardA11y:m})})))),p):null};Go.displayName="EdgeRenderer";var Ku=b.memo(Go);const qu=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function ju({children:t}){const e=tt(qu);return A.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}function Qu(t){const e=Ln(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const Ju={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top},Zo=({nodeId:t,handleType:e,style:n,type:r=It.Bezier,CustomComponent:o,connectionStatus:s})=>{var C,I,D;const{fromNode:i,handleId:c,toX:a,toY:l,connectionMode:u}=tt(b.useCallback($=>({fromNode:$.nodeInternals.get(t),handleId:$.connectionHandleId,toX:($.connectionPosition.x-$.transform[0])/$.transform[2],toY:($.connectionPosition.y-$.transform[1])/$.transform[2],connectionMode:$.connectionMode}),[t]),st),f=(C=i==null?void 0:i[et])==null?void 0:C.handleBounds;let g=f==null?void 0:f[e];if(u===Ut.Loose&&(g=g||(f==null?void 0:f[e==="source"?"target":"source"])),!i||!g)return null;const h=c?g.find($=>$.id===c):g[0],_=h?h.x+h.width/2:(i.width??0)/2,w=h?h.y+h.height/2:i.height??0,p=(((I=i.positionAbsolute)==null?void 0:I.x)??0)+_,m=(((D=i.positionAbsolute)==null?void 0:D.y)??0)+w,x=h==null?void 0:h.position,S=x?Ju[x]:null;if(!x||!S)return null;if(o)return A.createElement(o,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:h,fromX:p,fromY:m,toX:a,toY:l,fromPosition:x,toPosition:S,connectionStatus:s});let y="";const M={sourceX:p,sourceY:m,sourcePosition:x,targetX:a,targetY:l,targetPosition:S};return r===It.Bezier?[y]=yo(M):r===It.Step?[y]=vn({...M,borderRadius:0}):r===It.SmoothStep?[y]=vn(M):r===It.SimpleBezier?[y]=po(M):y=`M${p},${m} ${a},${l}`,A.createElement("path",{d:y,fill:"none",className:"react-flow__connection-path",style:n})};Zo.displayName="ConnectionLine";const tf=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function ef({containerStyle:t,style:e,type:n,component:r}){const{nodeId:o,handleType:s,nodesConnectable:i,width:c,height:a,connectionStatus:l}=tt(tf,st);return!(o&&s&&c&&i)?null:A.createElement("svg",{style:t,width:c,height:a,className:"react-flow__edges react-flow__connectionline react-flow__container"},A.createElement("g",{className:ct(["react-flow__connection",l])},A.createElement(Zo,{nodeId:o,handleType:s,style:e,type:n,CustomComponent:r,connectionStatus:l})))}function kr(t,e){return b.useRef(null),ot(),b.useMemo(()=>e(t),[t])}const Ko=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:r,onMoveEnd:o,onInit:s,onNodeClick:i,onEdgeClick:c,onNodeDoubleClick:a,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:g,onNodeContextMenu:h,onSelectionContextMenu:_,onSelectionStart:w,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:x,connectionLineComponent:S,connectionLineContainerStyle:y,selectionKeyCode:M,selectionOnDrag:C,selectionMode:I,multiSelectionKeyCode:D,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:H,onlyRenderVisibleElements:V,elementsSelectable:B,selectNodesOnDrag:d,defaultViewport:N,translateExtent:v,minZoom:T,maxZoom:z,preventScrolling:E,defaultMarkerColor:k,zoomOnScroll:R,zoomOnPinch:P,panOnScroll:O,panOnScrollSpeed:L,panOnScrollMode:W,zoomOnDoubleClick:U,panOnDrag:K,onPaneClick:Q,onPaneMouseEnter:j,onPaneMouseMove:q,onPaneMouseLeave:it,onPaneScroll:rt,onPaneContextMenu:ut,onEdgeContextMenu:at,onEdgeMouseEnter:nt,onEdgeMouseMove:dt,onEdgeMouseLeave:J,onReconnect:Y,onReconnectStart:ft,onReconnectEnd:Et,reconnectRadius:le,noDragClassName:Gt,noWheelClassName:Zt,noPanClassName:St,elevateEdgesOnSelect:Kt,disableKeyboardA11y:zt,nodeOrigin:Rt,nodeExtent:qt,rfId:jt})=>{const ue=kr(t,ku),lt=kr(e,Pu);return Qu(s),A.createElement(Mu,{onPaneClick:Q,onPaneMouseEnter:j,onPaneMouseMove:q,onPaneMouseLeave:it,onPaneContextMenu:ut,onPaneScroll:rt,deleteKeyCode:H,selectionKeyCode:M,selectionOnDrag:C,selectionMode:I,onSelectionStart:w,onSelectionEnd:p,multiSelectionKeyCode:D,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:B,onMove:n,onMoveStart:r,onMoveEnd:o,zoomOnScroll:R,zoomOnPinch:P,zoomOnDoubleClick:U,panOnScroll:O,panOnScrollSpeed:L,panOnScrollMode:W,panOnDrag:K,defaultViewport:N,translateExtent:v,minZoom:T,maxZoom:z,onSelectionContextMenu:_,preventScrolling:E,noDragClassName:Gt,noWheelClassName:Zt,noPanClassName:St,disableKeyboardA11y:zt},A.createElement(ju,null,A.createElement(Ku,{edgeTypes:lt,onEdgeClick:c,onEdgeDoubleClick:l,onlyRenderVisibleElements:V,onEdgeContextMenu:at,onEdgeMouseEnter:nt,onEdgeMouseMove:dt,onEdgeMouseLeave:J,onReconnect:Y,onReconnectStart:ft,onReconnectEnd:Et,reconnectRadius:le,defaultMarkerColor:k,noPanClassName:St,elevateEdgesOnSelect:!!Kt,disableKeyboardA11y:zt,rfId:jt},A.createElement(ef,{style:x,type:m,component:S,containerStyle:y})),A.createElement("div",{className:"react-flow__edgelabel-renderer"}),A.createElement(Iu,{nodeTypes:ue,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:g,onNodeContextMenu:h,selectNodesOnDrag:d,onlyRenderVisibleElements:V,noPanClassName:St,noDragClassName:Gt,disableKeyboardA11y:zt,nodeOrigin:Rt,nodeExtent:qt,rfId:jt})))};Ko.displayName="GraphView";var nf=b.memo(Ko);const An=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],$t={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:An,nodeExtent:An,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Ut.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:$l,isValidConnection:void 0},rf=()=>li((t,e)=>({...$t,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:s}=e();t({nodeInternals:an(n,r,o,s)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=e();t({edges:n.map(o=>({...r,...o}))})},setDefaultNodesAndEdges:(n,r)=>{const o=typeof n<"u",s=typeof r<"u",i=o?an(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:i,edges:s?r:[],hasDefaultNodes:o,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:o,fitViewOnInit:s,fitViewOnInitDone:i,fitViewOnInitOptions:c,domNode:a,nodeOrigin:l}=e(),u=a==null?void 0:a.querySelector(".react-flow__viewport");if(!u)return;const f=window.getComputedStyle(u),{m22:g}=new window.DOMMatrixReadOnly(f.transform),h=n.reduce((w,p)=>{const m=o.get(p.id);if(m!=null&&m.hidden)o.set(m.id,{...m,[et]:{...m[et],handleBounds:void 0}});else if(m){const x=Dn(p.nodeElement);!!(x.width&&x.height&&(m.width!==x.width||m.height!==x.height||p.forceUpdate))&&(o.set(m.id,{...m,[et]:{...m[et],handleBounds:{source:Er(".source",p.nodeElement,g,l),target:Er(".target",p.nodeElement,g,l)}},...x}),w.push({id:m.id,type:"dimensions",dimensions:x}))}return w},[]);Ro(o,l);const _=i||s&&!i&&Po(e,{initial:!0,...c});t({nodeInternals:new Map(o),fitViewOnInitDone:_}),(h==null?void 0:h.length)>0&&(r==null||r(h))},updateNodePositions:(n,r=!0,o=!1)=>{const{triggerNodeChanges:s}=e(),i=n.map(c=>{const a={id:c.id,type:"position",dragging:o};return r&&(a.positionAbsolute=c.positionAbsolute,a.position=c.position),a});s(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:o,hasDefaultNodes:s,nodeOrigin:i,getNodes:c,elevateNodesOnSelect:a}=e();if(n!=null&&n.length){if(s){const l=Bo(n,c()),u=an(l,o,i,a);t({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=e();let i,c=null;r?i=n.map(a=>Tt(a,!0)):(i=ne(s(),n),c=ne(o,[])),De({changedNodes:i,changedEdges:c,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=e();let i,c=null;r?i=n.map(a=>Tt(a,!0)):(i=ne(o,n),c=ne(s(),[])),De({changedNodes:c,changedEdges:i,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:o,getNodes:s}=e(),i=n||s(),c=r||o,a=i.map(u=>(u.selected=!1,Tt(u.id,!1))),l=c.map(u=>Tt(u.id,!1));De({changedNodes:a,changedEdges:l,get:e,set:t})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:o}=e();r==null||r.scaleExtent([n,o]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:o}=e();r==null||r.scaleExtent([o,n]),t({maxZoom:n})},setTranslateExtent:n=>{var r;(r=e().d3Zoom)==null||r.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=e(),s=r().filter(c=>c.selected).map(c=>Tt(c.id,!1)),i=n.filter(c=>c.selected).map(c=>Tt(c.id,!1));De({changedNodes:s,changedEdges:i,get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:r}=e();r.forEach(o=>{o.positionAbsolute=zn(o.position,n)}),t({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:o,height:s,d3Zoom:i,d3Selection:c,translateExtent:a}=e();if(!i||!c||!n.x&&!n.y)return!1;const l=Mt.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[o,s]],f=i==null?void 0:i.constrain()(l,u,a);return i.transform(c,f),r[0]!==f.x||r[1]!==f.y||r[2]!==f.k},cancelConnection:()=>t({connectionNodeId:$t.connectionNodeId,connectionHandleId:$t.connectionHandleId,connectionHandleType:$t.connectionHandleType,connectionStatus:$t.connectionStatus,connectionStartHandle:$t.connectionStartHandle,connectionEndHandle:$t.connectionEndHandle}),reset:()=>t({...$t})}),Object.is),Yn=({children:t})=>{const e=b.useRef(null);return e.current||(e.current=rf()),A.createElement(Sl,{value:e.current},t)};Yn.displayName="ReactFlowProvider";const qo=({children:t})=>b.useContext(je)?A.createElement(A.Fragment,null,t):A.createElement(Yn,null,t);qo.displayName="ReactFlowWrapper";const of={input:Co,default:bn,output:$o,group:Vn},sf={default:Xe,straight:Hn,step:Pn,smoothstep:Qe,simplebezier:Rn},cf=[0,0],af=[15,15],lf={x:0,y:0,zoom:1},uf={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},jo=b.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s=of,edgeTypes:i=sf,onNodeClick:c,onEdgeClick:a,onInit:l,onMove:u,onMoveStart:f,onMoveEnd:g,onConnect:h,onConnectStart:_,onConnectEnd:w,onClickConnectStart:p,onClickConnectEnd:m,onNodeMouseEnter:x,onNodeMouseMove:S,onNodeMouseLeave:y,onNodeContextMenu:M,onNodeDoubleClick:C,onNodeDragStart:I,onNodeDrag:D,onNodeDragStop:$,onNodesDelete:F,onEdgesDelete:H,onSelectionChange:V,onSelectionDragStart:B,onSelectionDrag:d,onSelectionDragStop:N,onSelectionContextMenu:v,onSelectionStart:T,onSelectionEnd:z,connectionMode:E=Ut.Strict,connectionLineType:k=It.Bezier,connectionLineStyle:R,connectionLineComponent:P,connectionLineContainerStyle:O,deleteKeyCode:L="Backspace",selectionKeyCode:W="Shift",selectionOnDrag:U=!1,selectionMode:K=be.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:j=Ye()?"Meta":"Control",zoomActivationKeyCode:q=Ye()?"Meta":"Control",snapToGrid:it=!1,snapGrid:rt=af,onlyRenderVisibleElements:ut=!1,selectNodesOnDrag:at=!0,nodesDraggable:nt,nodesConnectable:dt,nodesFocusable:J,nodeOrigin:Y=cf,edgesFocusable:ft,edgesUpdatable:Et,elementsSelectable:le,defaultViewport:Gt=lf,minZoom:Zt=.5,maxZoom:St=2,translateExtent:Kt=An,preventScrolling:zt=!0,nodeExtent:Rt,defaultMarkerColor:qt="#b1b1b7",zoomOnScroll:jt=!0,zoomOnPinch:ue=!0,panOnScroll:lt=!1,panOnScrollSpeed:pt=.5,panOnScrollMode:Pt=Ot.Free,zoomOnDoubleClick:Ht=!0,panOnDrag:Bt=!0,onPaneClick:bt,onPaneMouseEnter:xt,onPaneMouseMove:fe,onPaneMouseLeave:tn,onPaneScroll:de,onPaneContextMenu:en,children:Xn,onEdgeContextMenu:Ft,onEdgeDoubleClick:rs,onEdgeMouseEnter:os,onEdgeMouseMove:ss,onEdgeMouseLeave:is,onEdgeUpdate:cs,onEdgeUpdateStart:as,onEdgeUpdateEnd:ls,onReconnect:us,onReconnectStart:fs,onReconnectEnd:ds,reconnectRadius:hs=10,edgeUpdaterRadius:gs=10,onNodesChange:ms,onEdgesChange:ps,noDragClassName:ys="nodrag",noWheelClassName:ws="nowheel",noPanClassName:Wn="nopan",fitView:_s=!1,fitViewOptions:xs,connectOnClick:vs=!0,attributionPosition:Es,proOptions:Ss,defaultEdgeOptions:bs,elevateNodesOnSelect:Ns=!0,elevateEdgesOnSelect:As=!1,disableKeyboardA11y:Un=!1,autoPanOnConnect:Ms=!0,autoPanOnNodeDrag:Cs=!0,connectionRadius:ks=20,isValidConnection:$s,onError:Ts,style:Is,id:Gn,nodeDragThreshold:Ds,...zs},Rs)=>{const nn=Gn||"1";return A.createElement("div",{...zs,style:{...Is,...uf},ref:Rs,className:ct(["react-flow",o]),"data-testid":"rf__wrapper",id:Gn},A.createElement(qo,null,A.createElement(nf,{onInit:l,onMove:u,onMoveStart:f,onMoveEnd:g,onNodeClick:c,onEdgeClick:a,onNodeMouseEnter:x,onNodeMouseMove:S,onNodeMouseLeave:y,onNodeContextMenu:M,onNodeDoubleClick:C,nodeTypes:s,edgeTypes:i,connectionLineType:k,connectionLineStyle:R,connectionLineComponent:P,connectionLineContainerStyle:O,selectionKeyCode:W,selectionOnDrag:U,selectionMode:K,deleteKeyCode:L,multiSelectionKeyCode:j,panActivationKeyCode:Q,zoomActivationKeyCode:q,onlyRenderVisibleElements:ut,selectNodesOnDrag:at,defaultViewport:Gt,translateExtent:Kt,minZoom:Zt,maxZoom:St,preventScrolling:zt,zoomOnScroll:jt,zoomOnPinch:ue,zoomOnDoubleClick:Ht,panOnScroll:lt,panOnScrollSpeed:pt,panOnScrollMode:Pt,panOnDrag:Bt,onPaneClick:bt,onPaneMouseEnter:xt,onPaneMouseMove:fe,onPaneMouseLeave:tn,onPaneScroll:de,onPaneContextMenu:en,onSelectionContextMenu:v,onSelectionStart:T,onSelectionEnd:z,onEdgeContextMenu:Ft,onEdgeDoubleClick:rs,onEdgeMouseEnter:os,onEdgeMouseMove:ss,onEdgeMouseLeave:is,onReconnect:us??cs,onReconnectStart:fs??as,onReconnectEnd:ds??ls,reconnectRadius:hs??gs,defaultMarkerColor:qt,noDragClassName:ys,noWheelClassName:ws,noPanClassName:Wn,elevateEdgesOnSelect:As,rfId:nn,disableKeyboardA11y:Un,nodeOrigin:Y,nodeExtent:Rt}),A.createElement(Jl,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:_,onConnectEnd:w,onClickConnectStart:p,onClickConnectEnd:m,nodesDraggable:nt,nodesConnectable:dt,nodesFocusable:J,edgesFocusable:ft,edgesUpdatable:Et,elementsSelectable:le,elevateNodesOnSelect:Ns,minZoom:Zt,maxZoom:St,nodeExtent:Rt,onNodesChange:ms,onEdgesChange:ps,snapToGrid:it,snapGrid:rt,connectionMode:E,translateExtent:Kt,connectOnClick:vs,defaultEdgeOptions:bs,fitView:_s,fitViewOptions:xs,onNodesDelete:F,onEdgesDelete:H,onNodeDragStart:I,onNodeDrag:D,onNodeDragStop:$,onSelectionDrag:d,onSelectionDragStart:B,onSelectionDragStop:N,noPanClassName:Wn,nodeOrigin:Y,rfId:nn,autoPanOnConnect:Ms,autoPanOnNodeDrag:Cs,onError:Ts,connectionRadius:ks,isValidConnection:$s,nodeDragThreshold:Ds}),A.createElement(jl,{onSelectionChange:V}),Xn,A.createElement(Nl,{proOptions:Ss,position:Es}),A.createElement(ou,{rfId:nn,disableKeyboardA11y:Un})))});jo.displayName="ReactFlow";function Qo(t){return e=>{const[n,r]=b.useState(e),o=b.useCallback(s=>r(i=>t(s,i)),[]);return[n,r,o]}}const ff=Qo(Bo),df=Qo(wu),Jo=({id:t,x:e,y:n,width:r,height:o,style:s,color:i,strokeColor:c,strokeWidth:a,className:l,borderRadius:u,shapeRendering:f,onClick:g,selected:h})=>{const{background:_,backgroundColor:w}=s||{},p=i||_||w;return A.createElement("rect",{className:ct(["react-flow__minimap-node",{selected:h},l]),x:e,y:n,rx:u,ry:u,width:r,height:o,fill:p,stroke:c,strokeWidth:a,shapeRendering:f,onClick:g?m=>g(m,t):void 0})};Jo.displayName="MiniMapNode";var hf=b.memo(Jo);const gf=t=>t.nodeOrigin,mf=t=>t.getNodes().filter(e=>!e.hidden&&e.width&&e.height),dn=t=>t instanceof Function?t:()=>t;function pf({nodeStrokeColor:t="transparent",nodeColor:e="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o=2,nodeComponent:s=hf,onClick:i}){const c=tt(mf,st),a=tt(gf),l=dn(e),u=dn(t),f=dn(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return A.createElement(A.Fragment,null,c.map(h=>{const{x:_,y:w}=Xt(h,a).positionAbsolute;return A.createElement(s,{key:h.id,x:_,y:w,width:h.width,height:h.height,style:h.style,selected:h.selected,className:f(h),color:l(h),borderRadius:r,strokeColor:u(h),strokeWidth:o,shapeRendering:g,onClick:i,id:h.id})}))}var yf=b.memo(pf);const wf=200,_f=150,xf=t=>{const e=t.getNodes(),n={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:n,boundingRect:e.length>0?Cl(Je(e,t.nodeOrigin),n):n,rfId:t.rfId}},vf="react-flow__minimap-desc";function ts({style:t,className:e,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:i=2,nodeComponent:c,maskColor:a="rgb(240, 240, 240, 0.6)",maskStrokeColor:l="none",maskStrokeWidth:u=1,position:f="bottom-right",onClick:g,onNodeClick:h,pannable:_=!1,zoomable:w=!1,ariaLabel:p="React Flow mini map",inversePan:m=!1,zoomStep:x=10,offsetScale:S=5}){const y=ot(),M=b.useRef(null),{boundingRect:C,viewBB:I,rfId:D}=tt(xf,st),$=(t==null?void 0:t.width)??wf,F=(t==null?void 0:t.height)??_f,H=C.width/$,V=C.height/F,B=Math.max(H,V),d=B*$,N=B*F,v=S*B,T=C.x-(d-C.width)/2-v,z=C.y-(N-C.height)/2-v,E=d+v*2,k=N+v*2,R=`${vf}-${D}`,P=b.useRef(0);P.current=B,b.useEffect(()=>{if(M.current){const W=gt(M.current),U=j=>{const{transform:q,d3Selection:it,d3Zoom:rt}=y.getState();if(j.sourceEvent.type!=="wheel"||!it||!rt)return;const ut=-j.sourceEvent.deltaY*(j.sourceEvent.deltaMode===1?.05:j.sourceEvent.deltaMode?1:.002)*x,at=q[2]*Math.pow(2,ut);rt.scaleTo(it,at)},K=j=>{const{transform:q,d3Selection:it,d3Zoom:rt,translateExtent:ut,width:at,height:nt}=y.getState();if(j.sourceEvent.type!=="mousemove"||!it||!rt)return;const dt=P.current*Math.max(1,q[2])*(m?-1:1),J={x:q[0]-j.sourceEvent.movementX*dt,y:q[1]-j.sourceEvent.movementY*dt},Y=[[0,0],[at,nt]],ft=Mt.translate(J.x,J.y).scale(q[2]),Et=rt.constrain()(ft,Y,ut);rt.transform(it,Et)},Q=so().on("zoom",_?K:null).on("zoom.wheel",w?U:null);return W.call(Q),()=>{W.on("zoom",null)}}},[_,w,m,x]);const O=g?W=>{const U=yt(W);g(W,{x:U[0],y:U[1]})}:void 0,L=h?(W,U)=>{const K=y.getState().nodeInternals.get(U);h(W,K)}:void 0;return A.createElement(In,{position:f,style:t,className:ct(["react-flow__minimap",e]),"data-testid":"rf__minimap"},A.createElement("svg",{width:$,height:F,viewBox:`${T} ${z} ${E} ${k}`,role:"img","aria-labelledby":R,ref:M,onClick:O},p&&A.createElement("title",{id:R},p),A.createElement(yf,{onClick:L,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:c}),A.createElement("path",{className:"react-flow__minimap-mask",d:`M${T-v},${z-v}h${E+v*2}v${k+v*2}h${-E-v*2}z
        M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fill:a,fillRule:"evenodd",stroke:l,strokeWidth:u,pointerEvents:"none"})))}ts.displayName="MiniMap";var Ef=b.memo(ts);function Sf(){return A.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},A.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function bf(){return A.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},A.createElement("path",{d:"M0 0h32v4.2H0z"}))}function Nf(){return A.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},A.createElement("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 Af(){return A.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},A.createElement("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 Mf(){return A.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},A.createElement("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"}))}const xe=({children:t,className:e,...n})=>A.createElement("button",{type:"button",className:ct(["react-flow__controls-button",e]),...n},t);xe.displayName="ControlButton";const Cf=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom}),es=({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:c,onInteractiveChange:a,className:l,children:u,position:f="bottom-left"})=>{const g=ot(),[h,_]=b.useState(!1),{isInteractive:w,minZoomReached:p,maxZoomReached:m}=tt(Cf,st),{zoomIn:x,zoomOut:S,fitView:y}=Ln();if(b.useEffect(()=>{_(!0)},[]),!h)return null;const M=()=>{x(),s==null||s()},C=()=>{S(),i==null||i()},I=()=>{y(o),c==null||c()},D=()=>{g.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),a==null||a(!w)};return A.createElement(In,{className:ct(["react-flow__controls",l]),position:f,style:t,"data-testid":"rf__controls"},e&&A.createElement(A.Fragment,null,A.createElement(xe,{onClick:M,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:m},A.createElement(Sf,null)),A.createElement(xe,{onClick:C,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:p},A.createElement(bf,null))),n&&A.createElement(xe,{className:"react-flow__controls-fitview",onClick:I,title:"fit view","aria-label":"fit view"},A.createElement(Nf,null)),r&&A.createElement(xe,{className:"react-flow__controls-interactive",onClick:D,title:"toggle interactivity","aria-label":"toggle interactivity"},w?A.createElement(Mf,null):A.createElement(Af,null)),u)};es.displayName="Controls";var kf=b.memo(es),wt;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(wt||(wt={}));function $f({color:t,dimensions:e,lineWidth:n}){return A.createElement("path",{stroke:t,strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})}function Tf({color:t,radius:e}){return A.createElement("circle",{cx:e,cy:e,r:e,fill:t})}const If={[wt.Dots]:"#91919a",[wt.Lines]:"#eee",[wt.Cross]:"#e2e2e2"},Df={[wt.Dots]:1,[wt.Lines]:1,[wt.Cross]:6},zf=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function ns({id:t,variant:e=wt.Dots,gap:n=20,size:r,lineWidth:o=1,offset:s=2,color:i,style:c,className:a}){const l=b.useRef(null),{transform:u,patternId:f}=tt(zf,st),g=i||If[e],h=r||Df[e],_=e===wt.Dots,w=e===wt.Cross,p=Array.isArray(n)?n:[n,n],m=[p[0]*u[2]||1,p[1]*u[2]||1],x=h*u[2],S=w?[x,x]:m,y=_?[x/s,x/s]:[S[0]/s,S[1]/s];return A.createElement("svg",{className:ct(["react-flow__background",a]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:l,"data-testid":"rf__background"},A.createElement("pattern",{id:f+t,x:u[0]%m[0],y:u[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${y[0]},-${y[1]})`},_?A.createElement(Tf,{color:g,radius:x/s}):A.createElement($f,{dimensions:S,color:g,lineWidth:o})),A.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+t})`}))}ns.displayName="Background";var Rf=b.memo(ns);function Pf(){const[t,e]=b.useState({x:20,y:20}),[n,r]=b.useState(!1),[o,s]=b.useState({x:0,y:0}),i=l=>{r(!0),s({x:l.clientX-t.x,y:l.clientY-t.y})},c=l=>{n&&e({x:l.clientX-o.x,y:l.clientY-o.y})},a=()=>{r(!1)};return Z.jsxs("div",{className:"absolute bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 rounded-lg shadow-lg p-4 z-50 select-none",style:{left:`${t.x}px`,top:`${t.y}px`,cursor:n?"grabbing":"grab"},onMouseMove:c,onMouseUp:a,onMouseLeave:a,children:[Z.jsx("div",{onMouseDown:i,className:"font-semibold text-gray-900 dark:text-white mb-3 pb-2 border-b border-gray-300 dark:border-gray-700",children:"Edge Types"}),Z.jsxs("div",{className:"space-y-3",children:[Z.jsxs("div",{className:"flex items-center gap-3",children:[Z.jsxs("svg",{width:"40",height:"12",className:"flex-shrink-0",children:[Z.jsx("line",{x1:"0",y1:"6",x2:"32",y2:"6",stroke:"#3B82F6",strokeWidth:"2.2"}),Z.jsx("polygon",{points:"32,6 27,4 27,8",fill:"#3B82F6"})]}),Z.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Graph Edge"})]}),Z.jsxs("div",{className:"flex items-center gap-3",children:[Z.jsxs("svg",{width:"40",height:"12",className:"flex-shrink-0",children:[Z.jsx("line",{x1:"0",y1:"6",x2:"32",y2:"6",stroke:"#F59E0B",strokeWidth:"2.5",strokeDasharray:"5,5"}),Z.jsx("polygon",{points:"32,6 27,4 27,8",fill:"#F59E0B"})]}),Z.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Conditional"})]}),Z.jsxs("div",{className:"flex items-center gap-3",children:[Z.jsxs("svg",{width:"40",height:"12",className:"flex-shrink-0",children:[Z.jsx("line",{x1:"0",y1:"6",x2:"32",y2:"6",stroke:"#A0A0A0",strokeWidth:"1.2",strokeDasharray:"4,4",opacity:"0.6"}),Z.jsx("polygon",{points:"32,6 27,4 27,8",fill:"#A0A0A0",opacity:"0.6"})]}),Z.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Hierarchical"})]}),Z.jsxs("div",{className:"flex items-center gap-3",children:[Z.jsxs("svg",{width:"40",height:"12",className:"flex-shrink-0",children:[Z.jsx("line",{x1:"0",y1:"6",x2:"32",y2:"6",stroke:"#16A34A",strokeWidth:"2"}),Z.jsx("polygon",{points:"32,6 27,4 27,8",fill:"#16A34A"})]}),Z.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Sequential"})]})]})]})}const Hf={llm_call:{bg:"#DBEAFE",border:"#3B82F6"},tool_call:{bg:"#DCFCE7",border:"#16A34A"},agent_start:{bg:"#FED7AA",border:"#EA580C"},agent_end:{bg:"#FED7AA",border:"#EA580C"},chain_start:{bg:"#FED7AA",border:"#EA580C"},chain_end:{bg:"#FED7AA",border:"#EA580C"},error:{bg:"#FEE2E2",border:"#DC2626"},node_execution:{bg:"#E0E7FF",border:"#6366F1"}};function Bf(t){return Hf[t]||{bg:"#F3F4F6",border:"#9CA3AF"}}function $r(t){const e=t.data;if(t.event_type==="tool_call"){if(e!=null&&e.tool_name&&typeof e.tool_name=="string"&&e.tool_name.trim())return String(e.tool_name);if(e!=null&&e.tool&&typeof e.tool=="string"&&e.tool.trim())return String(e.tool)}if(t.event_type==="node_execution"&&e!=null&&e.node_name&&typeof e.node_name=="string"&&e.node_name.trim())return String(e.node_name);if(e!=null&&e.name&&typeof e.name=="string"&&e.name.trim())return String(e.name);if(e!=null&&e.tool_name&&typeof e.tool_name=="string"&&e.tool_name.trim())return String(e.tool_name);if(e!=null&&e.tool&&typeof e.tool=="string"&&e.tool.trim())return String(e.tool);if(e!=null&&e.function_name&&typeof e.function_name=="string"&&e.function_name.trim())return String(e.function_name);if(e!=null&&e.function&&typeof e.function=="string"&&e.function.trim())return String(e.function);if(e!=null&&e.node_name&&typeof e.node_name=="string"&&e.node_name.trim())return String(e.node_name);if(e!=null&&e.model&&typeof e.model=="string"&&e.model.trim())return String(e.model);if(t.event_type==="node_execution"||t.event_type==="tool_call"){const r=Object.keys(e||{}).filter(o=>!["timestamp","event_id","run_id","agent_name","created_at","updated_at","status","completed","success","error","result","output","input","parent_event_id","latency_ms","duration_ms","cost","tokens_in","tokens_out"].includes(o));for(const o of r){const s=e[o];if(typeof s=="string"&&s.trim()&&s.length<100&&s.length>0&&!s.startsWith("{")&&!s.startsWith("[")&&!s.includes("uuid")&&!/^[a-f0-9-]{36}$/.test(s))return String(s)}}return{llm_call:"LLM Call",tool_call:"Tool Call",agent_start:"Agent Start",agent_end:"Agent End",chain_start:"Chain Start",chain_end:"Chain End",node_execution:"Node Execution"}[t.event_type]||t.event_type.replace(/_/g," ")}function Ff(t,e,n){const r=[],o=[],s=new Map;function i(p){const m=p.data;return p.event_type==="node_execution"&&(m!=null&&m.node_name)?String(m.node_name):p.event_type==="tool_call"&&(m!=null&&m.tool_name)?String(m.tool_name):$r(p)}const c=new Map;let a=-1;e!=null&&e.execution_order&&e.execution_order.forEach((p,m)=>{c.set(p,m),a=Math.max(a,m)});const l=new Map,u=new Map;function f(p){p.previous_event_id&&l.set(p.event_id,p.previous_event_id);const m=i(p);u.set(p.event_id,m),p.children&&p.children.forEach(f)}if(t.forEach(f),a===-1&&l.size>0){const p=new Set;t.forEach(x=>{(!x.previous_event_id||!l.has(x.previous_event_id))&&p.add(x.event_id)});let m=0;for(const x of p){let S=x;for(;S;){const y=u.get(S);y&&!c.has(y)&&(c.set(y,m),a=Math.max(a,m),m++);let M;for(const[C,I]of l.entries())if(I===S){M=C;break}S=M||""}}}function g(p,m,x,S){let y=120;if(S>20?y=80:S>5&&(y=100),m==="agent_start")return 0;if(m==="agent_end")return(S+1)*y;const M=i(p),C=x.get(M)??-1;return C>=0?C*y:y}function h(p,m,x,S,y){const M=Bf(p.event_type||"unknown"),C=$r(p);if(r.push({id:p.event_id,data:{label:Z.jsxs("div",{className:"text-xs font-mono max-w-xs",children:[Z.jsx("div",{className:"font-bold mb-1 text-gray-900",children:C}),Z.jsx("div",{className:"text-gray-600",children:p.latency_ms!==void 0&&p.latency_ms!==null?`${(p.latency_ms/1e3).toFixed(2)}s`:"—"}),p.cost!==void 0&&p.cost!==null?Z.jsxs("div",{className:"text-green-700 font-semibold",children:["$",p.cost.toFixed(4)]}):null]})},position:{x:m,y:x},style:{background:M.bg,border:`1px solid ${M.border}`,borderRadius:"8px",padding:"12px 14px",minWidth:"140px",minHeight:"75px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.08)",fontFamily:"inherit"}}),s.set(p.event_id,p),S&&o.push({id:`hier-${S}-${p.event_id}`,source:S,target:p.event_id,style:{stroke:"#A0A0A0",strokeWidth:1.2,strokeDasharray:"4,4",opacity:.6},markerEnd:{type:Yt.ArrowClosed,color:"#A0A0A0"}}),p.children&&p.children.length>0){const I=p.children.length,D=I>5?150:200,$=(I-1)*D,F=m-$/2;p.children.forEach((H,V)=>{const B=F+V*D,d=x+150;h(H,B,d,p.event_id,y+1)})}return y}t.forEach((p,m)=>{const x=g(p,p.event_type||"unknown",c,a),S=m*300;h(p,S,x,null,0)});const _=[];function w(p){_.push(p),p.children&&p.children.forEach(w)}if(t.forEach(w),_.forEach(p=>{p.previous_event_id&&s.has(p.previous_event_id)&&o.push({id:`seq-${p.previous_event_id}-${p.event_id}`,source:p.previous_event_id,target:p.event_id,animated:!0,style:{stroke:"#16A34A",strokeWidth:2},markerEnd:{type:Yt.ArrowClosed,color:"#16A34A"}})}),n&&n.edges){const p=new Map;_.forEach(m=>{const x=m.data;if(m.event_type==="agent_start")p.set("__start__",m.event_id),n.entry_point&&p.set(n.entry_point,m.event_id);else if(m.event_type==="agent_end")p.set("__end__",m.event_id),p.set("END",m.event_id);else if(m.event_type==="node_execution"){const S=x==null?void 0:x.node_name;S&&p.set(S,m.event_id);const y=i(m);y&&y!==S&&p.set(y,m.event_id)}else{const S=i(m);S&&p.set(S,m.event_id)}}),console.log("Node name to event ID mapping:",Object.fromEntries(p)),console.log("Graph structure edges:",n.edges),n.edges.forEach((m,x)=>{const S=p.get(m.from),M=p.get(m.to)||(m.to==="__end__"||m.to==="END"?p.get("__end__"):null);if(S||console.warn(`Could not find source event ID for node: ${m.from}`),!M&&m.to!=="__end__"&&m.to!=="END"&&console.warn(`Could not find target event ID for node: ${m.to}`),S&&M){const C=`graph-${m.from}-${m.to}-${x}`;if(!o.some(D=>D.source===S&&D.target===M)){const D=m.type==="conditional";o.push({id:C,source:S,target:M,label:D?m.condition_func||"conditional":void 0,animated:D,style:{stroke:D?"#F59E0B":"#3B82F6",strokeWidth:D?2.5:2.2,strokeDasharray:D?"5,5":void 0},markerEnd:{type:Yt.ArrowClosed,color:D?"#F59E0B":"#3B82F6",width:30,height:30}})}}})}return{nodes:r,edges:o,nodeMap:s}}function Vf({nodes:t,graphStructure:e,executionFlow:n,onNodeSelect:r,selectedNodeId:o}){const{nodes:s,edges:i,nodeMap:c}=b.useMemo(()=>Ff(t,n,e),[t,n,e]),[a,l,u]=ff(s),[f,g,h]=df(i),[_,w]=b.useState(()=>document.documentElement.classList.contains("dark"));b.useEffect(()=>{const x=new MutationObserver(()=>{w(document.documentElement.classList.contains("dark"))});return x.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>x.disconnect()},[]);const p=b.useMemo(()=>{const x=_?"#60A5FA":"#3B82F6",S=_?"rgba(96, 165, 250, 0.4)":"rgba(59, 130, 246, 0.3)";return a.map(y=>{var M,C;return{...y,style:{...y.style,border:y.id===o?`3px solid ${x}`:(M=y.style)==null?void 0:M.border,boxShadow:y.id===o?`0 0 0 4px ${S}`:((C=y.style)==null?void 0:C.boxShadow)||"0 1px 3px rgba(0, 0, 0, 0.08)"}}})},[a,o,_]),m=b.useCallback((x,S)=>{const y=c.get(S.id);y&&(r==null||r(y))},[c,r]);return!t||t.length===0?Z.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 dark:bg-gray-900 rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-700",children:Z.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"No execution events to display"})}):Z.jsxs("div",{className:"w-full h-full relative",children:[Z.jsxs(jo,{nodes:p,edges:f,onNodesChange:u,onEdgesChange:h,onNodeClick:m,fitView:!0,defaultEdgeOptions:{type:"straight"},children:[Z.jsx(Rf,{color:"#aaa",gap:16}),Z.jsx(kf,{}),Z.jsx(Ef,{})]}),Z.jsx(Pf,{})]})}function Yf(t){return Z.jsx(Yn,{children:Z.jsx(Vf,{...t})})}export{Yf as default};
