import{r as io,g as ds,R as N,a as b}from"./vendor-react-BVoutfaX.js";function it(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=it(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var pn={exports:{}},mn={},yn={exports:{}},xn={};/**
 * @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 dr;function hs(){if(dr)return xn;dr=1;var t=io();function e(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,o=t.useEffect,s=t.useLayoutEffect,i=t.useDebugValue;function c(f,d){var g=d(),y=r({inst:{value:g,getSnapshot:d}}),p=y[0].inst,v=y[1];return s(function(){p.value=g,p.getSnapshot=d,a(p)&&v({inst:p})},[f,g,d]),o(function(){return a(p)&&v({inst:p}),f(function(){a(p)&&v({inst:p})})},[f]),i(g),g}function a(f){var d=f.getSnapshot;f=f.value;try{var g=d();return!n(f,g)}catch{return!0}}function u(f,d){return d()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:c;return xn.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,xn}var hr;function gs(){return hr||(hr=1,yn.exports=hs()),yn.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 gr;function ps(){if(gr)return mn;gr=1;var t=io(),e=gs();function n(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,s=t.useRef,i=t.useEffect,c=t.useMemo,a=t.useDebugValue;return mn.useSyncExternalStoreWithSelector=function(u,l,f,d,g){var y=s(null);if(y.current===null){var p={hasValue:!1,value:null};y.current=p}else p=y.current;y=c(function(){function m(C){if(!E){if(E=!0,M=C,C=d(C),g!==void 0&&p.hasValue){var z=p.value;if(g(z,C))return x=z}return x=C}if(z=x,r(M,C))return z;var P=d(C);return g!==void 0&&g(z,P)?(M=C,z):(M=C,x=P)}var E=!1,M,x,$=f===void 0?null:f;return[function(){return m(l())},$===null?void 0:function(){return m($())}]},[l,f,d,g]);var v=o(u,y[0],y[1]);return i(function(){p.hasValue=!0,p.value=v},[v]),a(v),v},mn}var pr;function ms(){return pr||(pr=1,pn.exports=ps()),pn.exports}var ys=ms();const xs=ds(ys),ws={},mr=t=>{let e;const n=new Set,r=(l,f)=>{const d=typeof l=="function"?l(e):l;if(!Object.is(d,e)){const g=e;e=f??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(y=>y(e,g))}},o=()=>e,a={setState:r,getState:o,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l)),destroy:()=>{(ws?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=e=t(r,o,a);return a},vs=t=>t?mr(t):mr,{useDebugValue:_s}=N,{useSyncExternalStoreWithSelector:Es}=xs,Ss=t=>t;function so(t,e=Ss,n){const r=Es(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return _s(r),r}const yr=(t,e)=>{const n=vs(t),r=(o,s=e)=>so(n,o,s);return Object.assign(r,n),r},bs=(t,e)=>t?yr(t,e):yr;function ft(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 Ns={value:()=>{}};function on(){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 Xe(n)}function Xe(t){this._=t}function Ms(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}})}Xe.prototype=on.prototype={constructor:Xe,on:function(t,e){var n=this._,r=Ms(t+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(t=r[s]).type)&&(o=$s(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]=xr(n[o],t.name,e);else if(e==null)for(o in n)n[o]=xr(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 Xe(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 $s(t,e){for(var n=0,r=t.length,o;n<r;++n)if((o=t[n]).name===e)return o.value}function xr(t,e,n){for(var r=0,o=t.length;r<o;++r)if(t[r].name===e){t[r]=Ns,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var An="http://www.w3.org/1999/xhtml";const wr={svg:"http://www.w3.org/2000/svg",xhtml:An,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function sn(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),wr.hasOwnProperty(e)?{space:wr[e],local:t}:t}function Cs(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===An&&e.documentElement.namespaceURI===An?e.createElement(t):e.createElementNS(n,t)}}function As(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function co(t){var e=sn(t);return(e.local?As:Cs)(e)}function ks(){}function Wn(t){return t==null?ks:function(){return this.querySelector(t)}}function Ts(t){typeof t!="function"&&(t=Wn(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,u,l=0;l<i;++l)(a=s[l])&&(u=t.call(a,a.__data__,l,s))&&("__data__"in a&&(u.__data__=a.__data__),c[l]=u);return new ht(r,this._parents)}function zs(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function Is(){return[]}function ao(t){return t==null?Is:function(){return this.querySelectorAll(t)}}function Rs(t){return function(){return zs(t.apply(this,arguments))}}function Ds(t){typeof t=="function"?t=Rs(t):t=ao(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,u=0;u<c;++u)(a=i[u])&&(r.push(t.call(a,a.__data__,u,i)),o.push(a));return new ht(r,o)}function lo(t){return function(){return this.matches(t)}}function uo(t){return function(e){return e.matches(t)}}var Hs=Array.prototype.find;function Ps(t){return function(){return Hs.call(this.children,t)}}function Vs(){return this.firstElementChild}function Ls(t){return this.select(t==null?Vs:Ps(typeof t=="function"?t:uo(t)))}var Os=Array.prototype.filter;function Fs(){return Array.from(this.children)}function Bs(t){return function(){return Os.call(this.children,t)}}function Ys(t){return this.selectAll(t==null?Fs:Bs(typeof t=="function"?t:uo(t)))}function Xs(t){typeof t!="function"&&(t=lo(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,u=0;u<i;++u)(a=s[u])&&t.call(a,a.__data__,u,s)&&c.push(a);return new ht(r,this._parents)}function fo(t){return new Array(t.length)}function Ws(){return new ht(this._enter||this._groups.map(fo),this._parents)}function Ze(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}Ze.prototype={constructor:Ze,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 Us(t){return function(){return t}}function qs(t,e,n,r,o,s){for(var i=0,c,a=e.length,u=s.length;i<u;++i)(c=e[i])?(c.__data__=s[i],r[i]=c):n[i]=new Ze(t,s[i]);for(;i<a;++i)(c=e[i])&&(o[i]=c)}function Zs(t,e,n,r,o,s,i){var c,a,u=new Map,l=e.length,f=s.length,d=new Array(l),g;for(c=0;c<l;++c)(a=e[c])&&(d[c]=g=i.call(a,a.__data__,c,e)+"",u.has(g)?o[c]=a:u.set(g,a));for(c=0;c<f;++c)g=i.call(t,s[c],c,s)+"",(a=u.get(g))?(r[c]=a,a.__data__=s[c],u.delete(g)):n[c]=new Ze(t,s[c]);for(c=0;c<l;++c)(a=e[c])&&u.get(d[c])===a&&(o[c]=a)}function Gs(t){return t.__data__}function Ks(t,e){if(!arguments.length)return Array.from(this,Gs);var n=e?Zs:qs,r=this._parents,o=this._groups;typeof t!="function"&&(t=Us(t));for(var s=o.length,i=new Array(s),c=new Array(s),a=new Array(s),u=0;u<s;++u){var l=r[u],f=o[u],d=f.length,g=Qs(t.call(l,l&&l.__data__,u,r)),y=g.length,p=c[u]=new Array(y),v=i[u]=new Array(y),m=a[u]=new Array(d);n(l,f,p,v,m,g,e);for(var E=0,M=0,x,$;E<y;++E)if(x=p[E]){for(E>=M&&(M=E+1);!($=v[M])&&++M<y;);x._next=$||null}}return i=new ht(i,r),i._enter=c,i._exit=a,i}function Qs(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Js(){return new ht(this._exit||this._groups.map(fo),this._parents)}function js(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 tc(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 u=n[a],l=r[a],f=u.length,d=c[a]=new Array(f),g,y=0;y<f;++y)(g=u[y]||l[y])&&(d[y]=g);for(;a<o;++a)c[a]=n[a];return new ht(c,this._parents)}function ec(){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 nc(t){t||(t=rc);function e(f,d){return f&&d?t(f.__data__,d.__data__):!f-!d}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),u,l=0;l<c;++l)(u=i[l])&&(a[l]=u);a.sort(e)}return new ht(o,this._parents).order()}function rc(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function oc(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function ic(){return Array.from(this)}function sc(){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 cc(){let t=0;for(const e of this)++t;return t}function ac(){return!this.node()}function lc(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 uc(t){return function(){this.removeAttribute(t)}}function fc(t){return function(){this.removeAttributeNS(t.space,t.local)}}function dc(t,e){return function(){this.setAttribute(t,e)}}function hc(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function gc(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function pc(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 mc(t,e){var n=sn(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?fc:uc:typeof e=="function"?n.local?pc:gc:n.local?hc:dc)(n,e))}function ho(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function yc(t){return function(){this.style.removeProperty(t)}}function xc(t,e,n){return function(){this.style.setProperty(t,e,n)}}function wc(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function vc(t,e,n){return arguments.length>1?this.each((e==null?yc:typeof e=="function"?wc:xc)(t,e,n??"")):le(this.node(),t)}function le(t,e){return t.style.getPropertyValue(e)||ho(t).getComputedStyle(t,null).getPropertyValue(e)}function _c(t){return function(){delete this[t]}}function Ec(t,e){return function(){this[t]=e}}function Sc(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function bc(t,e){return arguments.length>1?this.each((e==null?_c:typeof e=="function"?Sc:Ec)(t,e)):this.node()[t]}function go(t){return t.trim().split(/^|\s+/)}function Un(t){return t.classList||new po(t)}function po(t){this._node=t,this._names=go(t.getAttribute("class")||"")}po.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 mo(t,e){for(var n=Un(t),r=-1,o=e.length;++r<o;)n.add(e[r])}function yo(t,e){for(var n=Un(t),r=-1,o=e.length;++r<o;)n.remove(e[r])}function Nc(t){return function(){mo(this,t)}}function Mc(t){return function(){yo(this,t)}}function $c(t,e){return function(){(e.apply(this,arguments)?mo:yo)(this,t)}}function Cc(t,e){var n=go(t+"");if(arguments.length<2){for(var r=Un(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof e=="function"?$c:e?Nc:Mc)(n,e))}function Ac(){this.textContent=""}function kc(t){return function(){this.textContent=t}}function Tc(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function zc(t){return arguments.length?this.each(t==null?Ac:(typeof t=="function"?Tc:kc)(t)):this.node().textContent}function Ic(){this.innerHTML=""}function Rc(t){return function(){this.innerHTML=t}}function Dc(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function Hc(t){return arguments.length?this.each(t==null?Ic:(typeof t=="function"?Dc:Rc)(t)):this.node().innerHTML}function Pc(){this.nextSibling&&this.parentNode.appendChild(this)}function Vc(){return this.each(Pc)}function Lc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Oc(){return this.each(Lc)}function Fc(t){var e=typeof t=="function"?t:co(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Bc(){return null}function Yc(t,e){var n=typeof t=="function"?t:co(t),r=e==null?Bc:typeof e=="function"?e:Wn(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Xc(){var t=this.parentNode;t&&t.removeChild(this)}function Wc(){return this.each(Xc)}function Uc(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function qc(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Zc(t){return this.select(t?qc:Uc)}function Gc(t){return arguments.length?this.property("__data__",t):this.node().__data__}function Kc(t){return function(e){t.call(this,e,this.__data__)}}function Qc(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 Jc(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 jc(t,e,n){return function(){var r=this.__on,o,s=Kc(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 ta(t,e,n){var r=Qc(t+""),o,s=r.length,i;if(arguments.length<2){var c=this.node().__on;if(c){for(var a=0,u=c.length,l;a<u;++a)for(o=0,l=c[a];o<s;++o)if((i=r[o]).type===l.type&&i.name===l.name)return l.value}return}for(c=e?jc:Jc,o=0;o<s;++o)this.each(c(r[o],e,n));return this}function xo(t,e,n){var r=ho(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 ea(t,e){return function(){return xo(this,t,e)}}function na(t,e){return function(){return xo(this,t,e.apply(this,arguments))}}function ra(t,e){return this.each((typeof e=="function"?na:ea)(t,e))}function*oa(){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 wo=[null];function ht(t,e){this._groups=t,this._parents=e}function ze(){return new ht([[document.documentElement]],wo)}function ia(){return this}ht.prototype=ze.prototype={constructor:ht,select:Ts,selectAll:Ds,selectChild:Ls,selectChildren:Ys,filter:Xs,data:Ks,enter:Ws,exit:Js,join:js,merge:tc,selection:ia,order:ec,sort:nc,call:oc,nodes:ic,node:sc,size:cc,empty:ac,each:lc,attr:mc,style:vc,property:bc,classed:Cc,text:zc,html:Hc,raise:Vc,lower:Oc,append:Fc,insert:Yc,remove:Wc,clone:Zc,datum:Gc,on:ta,dispatch:ra,[Symbol.iterator]:oa};function gt(t){return typeof t=="string"?new ht([[document.querySelector(t)]],[document.documentElement]):new ht([[t]],wo)}function sa(t){let e;for(;e=t.sourceEvent;)t=e;return t}function yt(t,e){if(t=sa(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 ca={passive:!1},be={capture:!0,passive:!1};function wn(t){t.stopImmediatePropagation()}function se(t){t.preventDefault(),t.stopImmediatePropagation()}function vo(t){var e=t.document.documentElement,n=gt(t).on("dragstart.drag",se,be);"onselectstart"in e?n.on("selectstart.drag",se,be):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function _o(t,e){var n=t.document.documentElement,r=gt(t).on("dragstart.drag",null);e&&(r.on("click.drag",se,be),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 De=t=>()=>t;function kn(t,{sourceEvent:e,subject:n,target:r,identifier:o,active:s,x:i,y:c,dx:a,dy:u,dispatch:l}){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:u,enumerable:!0,configurable:!0},_:{value:l}})}kn.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function aa(t){return!t.ctrlKey&&!t.button}function la(){return this.parentNode}function ua(t,e){return e??{x:t.x,y:t.y}}function fa(){return navigator.maxTouchPoints||"ontouchstart"in this}function da(){var t=aa,e=la,n=ua,r=fa,o={},s=on("start","drag","end"),i=0,c,a,u,l,f=0;function d(x){x.on("mousedown.drag",g).filter(r).on("touchstart.drag",v).on("touchmove.drag",m,ca).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(x,$){if(!(l||!t.call(this,x,$))){var C=M(this,e.call(this,x,$),x,$,"mouse");C&&(gt(x.view).on("mousemove.drag",y,be).on("mouseup.drag",p,be),vo(x.view),wn(x),u=!1,c=x.clientX,a=x.clientY,C("start",x))}}function y(x){if(se(x),!u){var $=x.clientX-c,C=x.clientY-a;u=$*$+C*C>f}o.mouse("drag",x)}function p(x){gt(x.view).on("mousemove.drag mouseup.drag",null),_o(x.view,u),se(x),o.mouse("end",x)}function v(x,$){if(t.call(this,x,$)){var C=x.changedTouches,z=e.call(this,x,$),P=C.length,T,L;for(T=0;T<P;++T)(L=M(this,z,x,$,C[T].identifier,C[T]))&&(wn(x),L("start",x,C[T]))}}function m(x){var $=x.changedTouches,C=$.length,z,P;for(z=0;z<C;++z)(P=o[$[z].identifier])&&(se(x),P("drag",x,$[z]))}function E(x){var $=x.changedTouches,C=$.length,z,P;for(l&&clearTimeout(l),l=setTimeout(function(){l=null},500),z=0;z<C;++z)(P=o[$[z].identifier])&&(wn(x),P("end",x,$[z]))}function M(x,$,C,z,P,T){var L=s.copy(),H=yt(T||C,$),O,V,h;if((h=n.call(x,new kn("beforestart",{sourceEvent:C,target:d,identifier:P,active:i,x:H[0],y:H[1],dx:0,dy:0,dispatch:L}),z))!=null)return O=h.x-H[0]||0,V=h.y-H[1]||0,function S(w,k,I){var _=H,A;switch(w){case"start":o[P]=S,A=i++;break;case"end":delete o[P],--i;case"drag":H=yt(I||k,$),A=i;break}L.call(w,x,new kn(w,{sourceEvent:k,subject:h,target:d,identifier:P,active:A,x:H[0]+O,y:H[1]+V,dx:H[0]-_[0],dy:H[1]-_[1],dispatch:L}),z)}}return d.filter=function(x){return arguments.length?(t=typeof x=="function"?x:De(!!x),d):t},d.container=function(x){return arguments.length?(e=typeof x=="function"?x:De(x),d):e},d.subject=function(x){return arguments.length?(n=typeof x=="function"?x:De(x),d):n},d.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:De(!!x),d):r},d.on=function(){var x=s.on.apply(s,arguments);return x===s?d:x},d.clickDistance=function(x){return arguments.length?(f=(x=+x)*x,d):Math.sqrt(f)},d}function qn(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Eo(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Ie(){}var Ne=.7,Ge=1/Ne,ce="\\s*([+-]?\\d+)\\s*",Me="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Et="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ha=/^#([0-9a-f]{3,8})$/,ga=new RegExp(`^rgb\\(${ce},${ce},${ce}\\)$`),pa=new RegExp(`^rgb\\(${Et},${Et},${Et}\\)$`),ma=new RegExp(`^rgba\\(${ce},${ce},${ce},${Me}\\)$`),ya=new RegExp(`^rgba\\(${Et},${Et},${Et},${Me}\\)$`),xa=new RegExp(`^hsl\\(${Me},${Et},${Et}\\)$`),wa=new RegExp(`^hsla\\(${Me},${Et},${Et},${Me}\\)$`),vr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};qn(Ie,$e,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:_r,formatHex:_r,formatHex8:va,formatHsl:_a,formatRgb:Er,toString:Er});function _r(){return this.rgb().formatHex()}function va(){return this.rgb().formatHex8()}function _a(){return So(this).formatHsl()}function Er(){return this.rgb().formatRgb()}function $e(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=ha.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?Sr(e):n===3?new ut(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?He(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?He(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=ga.exec(t))?new ut(e[1],e[2],e[3],1):(e=pa.exec(t))?new ut(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ma.exec(t))?He(e[1],e[2],e[3],e[4]):(e=ya.exec(t))?He(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=xa.exec(t))?Mr(e[1],e[2]/100,e[3]/100,1):(e=wa.exec(t))?Mr(e[1],e[2]/100,e[3]/100,e[4]):vr.hasOwnProperty(t)?Sr(vr[t]):t==="transparent"?new ut(NaN,NaN,NaN,0):null}function Sr(t){return new ut(t>>16&255,t>>8&255,t&255,1)}function He(t,e,n,r){return r<=0&&(t=e=n=NaN),new ut(t,e,n,r)}function Ea(t){return t instanceof Ie||(t=$e(t)),t?(t=t.rgb(),new ut(t.r,t.g,t.b,t.opacity)):new ut}function Tn(t,e,n,r){return arguments.length===1?Ea(t):new ut(t,e,n,r??1)}function ut(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}qn(ut,Tn,Eo(Ie,{brighter(t){return t=t==null?Ge:Math.pow(Ge,t),new ut(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Ne:Math.pow(Ne,t),new ut(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ut(Ut(this.r),Ut(this.g),Ut(this.b),Ke(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:br,formatHex:br,formatHex8:Sa,formatRgb:Nr,toString:Nr}));function br(){return`#${Xt(this.r)}${Xt(this.g)}${Xt(this.b)}`}function Sa(){return`#${Xt(this.r)}${Xt(this.g)}${Xt(this.b)}${Xt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Nr(){const t=Ke(this.opacity);return`${t===1?"rgb(":"rgba("}${Ut(this.r)}, ${Ut(this.g)}, ${Ut(this.b)}${t===1?")":`, ${t})`}`}function Ke(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ut(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Xt(t){return t=Ut(t),(t<16?"0":"")+t.toString(16)}function Mr(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new xt(t,e,n,r)}function So(t){if(t instanceof xt)return new xt(t.h,t.s,t.l,t.opacity);if(t instanceof Ie||(t=$e(t)),!t)return new xt;if(t instanceof xt)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,o=Math.min(e,n,r),s=Math.max(e,n,r),i=NaN,c=s-o,a=(s+o)/2;return c?(e===s?i=(n-r)/c+(n<r)*6:n===s?i=(r-e)/c+2:i=(e-n)/c+4,c/=a<.5?s+o:2-s-o,i*=60):c=a>0&&a<1?0:i,new xt(i,c,a,t.opacity)}function ba(t,e,n,r){return arguments.length===1?So(t):new xt(t,e,n,r??1)}function xt(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}qn(xt,ba,Eo(Ie,{brighter(t){return t=t==null?Ge:Math.pow(Ge,t),new xt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Ne:Math.pow(Ne,t),new xt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,o=2*n-r;return new ut(vn(t>=240?t-240:t+120,o,r),vn(t,o,r),vn(t<120?t+240:t-120,o,r),this.opacity)},clamp(){return new xt($r(this.h),Pe(this.s),Pe(this.l),Ke(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Ke(this.opacity);return`${t===1?"hsl(":"hsla("}${$r(this.h)}, ${Pe(this.s)*100}%, ${Pe(this.l)*100}%${t===1?")":`, ${t})`}`}}));function $r(t){return t=(t||0)%360,t<0?t+360:t}function Pe(t){return Math.max(0,Math.min(1,t||0))}function vn(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const bo=t=>()=>t;function Na(t,e){return function(n){return t+n*e}}function Ma(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function $a(t){return(t=+t)==1?No:function(e,n){return n-e?Ma(e,n,t):bo(isNaN(e)?n:e)}}function No(t,e){var n=e-t;return n?Na(t,n):bo(isNaN(t)?e:t)}const Cr=(function t(e){var n=$a(e);function r(o,s){var i=n((o=Tn(o)).r,(s=Tn(s)).r),c=n(o.g,s.g),a=n(o.b,s.b),u=No(o.opacity,s.opacity);return function(l){return o.r=i(l),o.g=c(l),o.b=a(l),o.opacity=u(l),o+""}}return r.gamma=t,r})(1);function It(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var zn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,_n=new RegExp(zn.source,"g");function Ca(t){return function(){return t}}function Aa(t){return function(e){return t(e)+""}}function ka(t,e){var n=zn.lastIndex=_n.lastIndex=0,r,o,s,i=-1,c=[],a=[];for(t=t+"",e=e+"";(r=zn.exec(t))&&(o=_n.exec(e));)(s=o.index)>n&&(s=e.slice(n,s),c[i]?c[i]+=s:c[++i]=s),(r=r[0])===(o=o[0])?c[i]?c[i]+=o:c[++i]=o:(c[++i]=null,a.push({i,x:It(r,o)})),n=_n.lastIndex;return n<e.length&&(s=e.slice(n),c[i]?c[i]+=s:c[++i]=s),c.length<2?a[0]?Aa(a[0].x):Ca(e):(e=a.length,function(u){for(var l=0,f;l<e;++l)c[(f=a[l]).i]=f.x(u);return c.join("")})}var Ar=180/Math.PI,In={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Mo(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)*Ar,skewX:Math.atan(a)*Ar,scaleX:i,scaleY:c}}var Ve;function Ta(t){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?In:Mo(e.a,e.b,e.c,e.d,e.e,e.f)}function za(t){return t==null||(Ve||(Ve=document.createElementNS("http://www.w3.org/2000/svg","g")),Ve.setAttribute("transform",t),!(t=Ve.transform.baseVal.consolidate()))?In:(t=t.matrix,Mo(t.a,t.b,t.c,t.d,t.e,t.f))}function $o(t,e,n,r){function o(u){return u.length?u.pop()+" ":""}function s(u,l,f,d,g,y){if(u!==f||l!==d){var p=g.push("translate(",null,e,null,n);y.push({i:p-4,x:It(u,f)},{i:p-2,x:It(l,d)})}else(f||d)&&g.push("translate("+f+e+d+n)}function i(u,l,f,d){u!==l?(u-l>180?l+=360:l-u>180&&(u+=360),d.push({i:f.push(o(f)+"rotate(",null,r)-2,x:It(u,l)})):l&&f.push(o(f)+"rotate("+l+r)}function c(u,l,f,d){u!==l?d.push({i:f.push(o(f)+"skewX(",null,r)-2,x:It(u,l)}):l&&f.push(o(f)+"skewX("+l+r)}function a(u,l,f,d,g,y){if(u!==f||l!==d){var p=g.push(o(g)+"scale(",null,",",null,")");y.push({i:p-4,x:It(u,f)},{i:p-2,x:It(l,d)})}else(f!==1||d!==1)&&g.push(o(g)+"scale("+f+","+d+")")}return function(u,l){var f=[],d=[];return u=t(u),l=t(l),s(u.translateX,u.translateY,l.translateX,l.translateY,f,d),i(u.rotate,l.rotate,f,d),c(u.skewX,l.skewX,f,d),a(u.scaleX,u.scaleY,l.scaleX,l.scaleY,f,d),u=l=null,function(g){for(var y=-1,p=d.length,v;++y<p;)f[(v=d[y]).i]=v.x(g);return f.join("")}}}var Ia=$o(Ta,"px, ","px)","deg)"),Ra=$o(za,", ",")",")"),Da=1e-12;function kr(t){return((t=Math.exp(t))+1/t)/2}function Ha(t){return((t=Math.exp(t))-1/t)/2}function Pa(t){return((t=Math.exp(2*t))-1)/(t+1)}const Va=(function t(e,n,r){function o(s,i){var c=s[0],a=s[1],u=s[2],l=i[0],f=i[1],d=i[2],g=l-c,y=f-a,p=g*g+y*y,v,m;if(p<Da)m=Math.log(d/u)/e,v=function(z){return[c+z*g,a+z*y,u*Math.exp(e*z*m)]};else{var E=Math.sqrt(p),M=(d*d-u*u+r*p)/(2*u*n*E),x=(d*d-u*u-r*p)/(2*d*n*E),$=Math.log(Math.sqrt(M*M+1)-M),C=Math.log(Math.sqrt(x*x+1)-x);m=(C-$)/e,v=function(z){var P=z*m,T=kr($),L=u/(n*E)*(T*Pa(e*P+$)-Ha($));return[c+L*g,a+L*y,u*T/kr(e*P+$)]}}return v.duration=m*1e3*e/Math.SQRT2,v}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 ue=0,_e=0,me=0,Co=1e3,Qe,Ee,Je=0,Zt=0,cn=0,Ce=typeof performance=="object"&&performance.now?performance:Date,Ao=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Zn(){return Zt||(Ao(La),Zt=Ce.now()+cn)}function La(){Zt=0}function je(){this._call=this._time=this._next=null}je.prototype=ko.prototype={constructor:je,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Zn():+n)+(e==null?0:+e),!this._next&&Ee!==this&&(Ee?Ee._next=this:Qe=this,Ee=this),this._call=t,this._time=n,Rn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Rn())}};function ko(t,e,n){var r=new je;return r.restart(t,e,n),r}function Oa(){Zn(),++ue;for(var t=Qe,e;t;)(e=Zt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--ue}function Tr(){Zt=(Je=Ce.now())+cn,ue=_e=0;try{Oa()}finally{ue=0,Ba(),Zt=0}}function Fa(){var t=Ce.now(),e=t-Je;e>Co&&(cn-=e,Je=t)}function Ba(){for(var t,e=Qe,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:Qe=n);Ee=t,Rn(r)}function Rn(t){if(!ue){_e&&(_e=clearTimeout(_e));var e=t-Zt;e>24?(t<1/0&&(_e=setTimeout(Tr,t-Ce.now()-cn)),me&&(me=clearInterval(me))):(me||(Je=Ce.now(),me=setInterval(Fa,Co)),ue=1,Ao(Tr))}}function zr(t,e,n){var r=new je;return e=e==null?0:+e,r.restart(o=>{r.stop(),t(o+e)},e,n),r}var Ya=on("start","end","cancel","interrupt"),Xa=[],To=0,Ir=1,Dn=2,We=3,Rr=4,Hn=5,Ue=6;function an(t,e,n,r,o,s){var i=t.__transition;if(!i)t.__transition={};else if(n in i)return;Wa(t,n,{name:e,index:r,group:o,on:Ya,tween:Xa,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:To})}function Gn(t,e){var n=vt(t,e);if(n.state>To)throw new Error("too late; already scheduled");return n}function St(t,e){var n=vt(t,e);if(n.state>We)throw new Error("too late; already running");return n}function vt(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Wa(t,e,n){var r=t.__transition,o;r[e]=n,n.timer=ko(s,0,n.time);function s(u){n.state=Ir,n.timer.restart(i,n.delay,n.time),n.delay<=u&&i(u-n.delay)}function i(u){var l,f,d,g;if(n.state!==Ir)return a();for(l in r)if(g=r[l],g.name===n.name){if(g.state===We)return zr(i);g.state===Rr?(g.state=Ue,g.timer.stop(),g.on.call("interrupt",t,t.__data__,g.index,g.group),delete r[l]):+l<e&&(g.state=Ue,g.timer.stop(),g.on.call("cancel",t,t.__data__,g.index,g.group),delete r[l])}if(zr(function(){n.state===We&&(n.state=Rr,n.timer.restart(c,n.delay,n.time),c(u))}),n.state=Dn,n.on.call("start",t,t.__data__,n.index,n.group),n.state===Dn){for(n.state=We,o=new Array(d=n.tween.length),l=0,f=-1;l<d;++l)(g=n.tween[l].value.call(t,t.__data__,n.index,n.group))&&(o[++f]=g);o.length=f+1}}function c(u){for(var l=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(a),n.state=Hn,1),f=-1,d=o.length;++f<d;)o[f].call(t,l);n.state===Hn&&(n.on.call("end",t,t.__data__,n.index,n.group),a())}function a(){n.state=Ue,n.timer.stop(),delete r[e];for(var u in r)return;delete t.__transition}}function qe(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>Dn&&r.state<Hn,r.state=Ue,r.timer.stop(),r.on.call(o?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[i]}s&&delete t.__transition}}function Ua(t){return this.each(function(){qe(this,t)})}function qa(t,e){var n,r;return function(){var o=St(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 Za(t,e,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=St(this,t),i=s.tween;if(i!==r){o=(r=i).slice();for(var c={name:e,value:n},a=0,u=o.length;a<u;++a)if(o[a].name===e){o[a]=c;break}a===u&&o.push(c)}s.tween=o}}function Ga(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=vt(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?qa:Za)(n,t,e))}function Kn(t,e,n){var r=t._id;return t.each(function(){var o=St(this,r);(o.value||(o.value={}))[e]=n.apply(this,arguments)}),function(o){return vt(o,r).value[e]}}function zo(t,e){var n;return(typeof e=="number"?It:e instanceof $e?Cr:(n=$e(e))?(e=n,Cr):ka)(t,e)}function Ka(t){return function(){this.removeAttribute(t)}}function Qa(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Ja(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 ja(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 tl(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 el(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 nl(t,e){var n=sn(t),r=n==="transform"?Ra:zo;return this.attrTween(t,typeof e=="function"?(n.local?el:tl)(n,r,Kn(this,"attr."+t,e)):e==null?(n.local?Qa:Ka)(n):(n.local?ja:Ja)(n,r,e))}function rl(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function ol(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function il(t,e){var n,r;function o(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&ol(t,s)),n}return o._value=e,o}function sl(t,e){var n,r;function o(){var s=e.apply(this,arguments);return s!==r&&(n=(r=s)&&rl(t,s)),n}return o._value=e,o}function cl(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=sn(t);return this.tween(n,(r.local?il:sl)(r,e))}function al(t,e){return function(){Gn(this,t).delay=+e.apply(this,arguments)}}function ll(t,e){return e=+e,function(){Gn(this,t).delay=e}}function ul(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?al:ll)(e,t)):vt(this.node(),e).delay}function fl(t,e){return function(){St(this,t).duration=+e.apply(this,arguments)}}function dl(t,e){return e=+e,function(){St(this,t).duration=e}}function hl(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?fl:dl)(e,t)):vt(this.node(),e).duration}function gl(t,e){if(typeof e!="function")throw new Error;return function(){St(this,t).ease=e}}function pl(t){var e=this._id;return arguments.length?this.each(gl(e,t)):vt(this.node(),e).ease}function ml(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;St(this,t).ease=n}}function yl(t){if(typeof t!="function")throw new Error;return this.each(ml(this._id,t))}function xl(t){typeof t!="function"&&(t=lo(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,u=0;u<i;++u)(a=s[u])&&t.call(a,a.__data__,u,s)&&c.push(a);return new kt(r,this._parents,this._name,this._id)}function wl(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],u=n[c],l=a.length,f=i[c]=new Array(l),d,g=0;g<l;++g)(d=a[g]||u[g])&&(f[g]=d);for(;c<r;++c)i[c]=e[c];return new kt(i,this._parents,this._name,this._id)}function vl(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 _l(t,e,n){var r,o,s=vl(e)?Gn:St;return function(){var i=s(this,t),c=i.on;c!==r&&(o=(r=c).copy()).on(e,n),i.on=o}}function El(t,e){var n=this._id;return arguments.length<2?vt(this.node(),n).on.on(t):this.each(_l(n,t,e))}function Sl(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function bl(){return this.on("end.remove",Sl(this._id))}function Nl(t){var e=this._name,n=this._id;typeof t!="function"&&(t=Wn(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,u=s[i]=new Array(a),l,f,d=0;d<a;++d)(l=c[d])&&(f=t.call(l,l.__data__,d,c))&&("__data__"in l&&(f.__data__=l.__data__),u[d]=f,an(u[d],e,n,d,u,vt(l,n)));return new kt(s,this._parents,e,n)}function Ml(t){var e=this._name,n=this._id;typeof t!="function"&&(t=ao(t));for(var r=this._groups,o=r.length,s=[],i=[],c=0;c<o;++c)for(var a=r[c],u=a.length,l,f=0;f<u;++f)if(l=a[f]){for(var d=t.call(l,l.__data__,f,a),g,y=vt(l,n),p=0,v=d.length;p<v;++p)(g=d[p])&&an(g,e,n,p,d,y);s.push(d),i.push(l)}return new kt(s,i,e,n)}var $l=ze.prototype.constructor;function Cl(){return new $l(this._groups,this._parents)}function Al(t,e){var n,r,o;return function(){var s=le(this,t),i=(this.style.removeProperty(t),le(this,t));return s===i?null:s===n&&i===r?o:o=e(n=s,r=i)}}function Io(t){return function(){this.style.removeProperty(t)}}function kl(t,e,n){var r,o=n+"",s;return function(){var i=le(this,t);return i===o?null:i===r?s:s=e(r=i,n)}}function Tl(t,e,n){var r,o,s;return function(){var i=le(this,t),c=n(this),a=c+"";return c==null&&(a=c=(this.style.removeProperty(t),le(this,t))),i===a?null:i===r&&a===o?s:(o=a,s=e(r=i,c))}}function zl(t,e){var n,r,o,s="style."+e,i="end."+s,c;return function(){var a=St(this,t),u=a.on,l=a.value[s]==null?c||(c=Io(e)):void 0;(u!==n||o!==l)&&(r=(n=u).copy()).on(i,o=l),a.on=r}}function Il(t,e,n){var r=(t+="")=="transform"?Ia:zo;return e==null?this.styleTween(t,Al(t,r)).on("end.style."+t,Io(t)):typeof e=="function"?this.styleTween(t,Tl(t,r,Kn(this,"style."+t,e))).each(zl(this._id,t)):this.styleTween(t,kl(t,r,e),n).on("end.style."+t,null)}function Rl(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function Dl(t,e,n){var r,o;function s(){var i=e.apply(this,arguments);return i!==o&&(r=(o=i)&&Rl(t,i,n)),r}return s._value=e,s}function Hl(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,Dl(t,e,n??""))}function Pl(t){return function(){this.textContent=t}}function Vl(t){return function(){var e=t(this);this.textContent=e??""}}function Ll(t){return this.tween("text",typeof t=="function"?Vl(Kn(this,"text",t)):Pl(t==null?"":t+""))}function Ol(t){return function(e){this.textContent=t.call(this,e)}}function Fl(t){var e,n;function r(){var o=t.apply(this,arguments);return o!==n&&(e=(n=o)&&Ol(o)),e}return r._value=t,r}function Bl(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,Fl(t))}function Yl(){for(var t=this._name,e=this._id,n=Ro(),r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],c=i.length,a,u=0;u<c;++u)if(a=i[u]){var l=vt(a,e);an(a,t,n,u,i,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new kt(r,this._parents,t,n)}function Xl(){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 u=St(this,r),l=u.on;l!==t&&(e=(t=l).copy(),e._.cancel.push(c),e._.interrupt.push(c),e._.end.push(a)),u.on=e}),o===0&&s()})}var Wl=0;function kt(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function Ro(){return++Wl}var $t=ze.prototype;kt.prototype={constructor:kt,select:Nl,selectAll:Ml,selectChild:$t.selectChild,selectChildren:$t.selectChildren,filter:xl,merge:wl,selection:Cl,transition:Yl,call:$t.call,nodes:$t.nodes,node:$t.node,size:$t.size,empty:$t.empty,each:$t.each,on:El,attr:nl,attrTween:cl,style:Il,styleTween:Hl,text:Ll,textTween:Bl,remove:bl,tween:Ga,delay:ul,duration:hl,ease:pl,easeVarying:yl,end:Xl,[Symbol.iterator]:$t[Symbol.iterator]};function Ul(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var ql={time:null,delay:0,duration:250,ease:Ul};function Zl(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 Gl(t){var e,n;t instanceof kt?(e=t._id,t=t._name):(e=Ro(),(n=ql).time=Zn(),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,u=0;u<c;++u)(a=i[u])&&an(a,t,e,u,i,n||Zl(a,e));return new kt(r,this._parents,t,e)}ze.prototype.interrupt=Ua;ze.prototype.transition=Gl;const Le=t=>()=>t;function Kl(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 Ct(t,e,n){this.k=t,this.x=e,this.y=n}Ct.prototype={constructor:Ct,scale:function(t){return t===1?this:new Ct(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new Ct(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 At=new Ct(1,0,0);Ct.prototype;function En(t){t.stopImmediatePropagation()}function ye(t){t.preventDefault(),t.stopImmediatePropagation()}function Ql(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Jl(){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 Dr(){return this.__zoom||At}function jl(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function tu(){return navigator.maxTouchPoints||"ontouchstart"in this}function eu(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 Do(){var t=Ql,e=Jl,n=eu,r=jl,o=tu,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,a=Va,u=on("start","zoom","end"),l,f,d,g=500,y=150,p=0,v=10;function m(h){h.property("__zoom",Dr).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",L).filter(o).on("touchstart.zoom",H).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(h,S,w,k){var I=h.selection?h.selection():h;I.property("__zoom",Dr),h!==I?$(h,S,w,k):I.interrupt().each(function(){C(this,arguments).event(k).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},m.scaleBy=function(h,S,w,k){m.scaleTo(h,function(){var I=this.__zoom.k,_=typeof S=="function"?S.apply(this,arguments):S;return I*_},w,k)},m.scaleTo=function(h,S,w,k){m.transform(h,function(){var I=e.apply(this,arguments),_=this.__zoom,A=w==null?x(I):typeof w=="function"?w.apply(this,arguments):w,R=_.invert(A),D=typeof S=="function"?S.apply(this,arguments):S;return n(M(E(_,D),A,R),I,i)},w,k)},m.translateBy=function(h,S,w,k){m.transform(h,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof w=="function"?w.apply(this,arguments):w),e.apply(this,arguments),i)},null,k)},m.translateTo=function(h,S,w,k,I){m.transform(h,function(){var _=e.apply(this,arguments),A=this.__zoom,R=k==null?x(_):typeof k=="function"?k.apply(this,arguments):k;return n(At.translate(R[0],R[1]).scale(A.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof w=="function"?-w.apply(this,arguments):-w),_,i)},k,I)};function E(h,S){return S=Math.max(s[0],Math.min(s[1],S)),S===h.k?h:new Ct(S,h.x,h.y)}function M(h,S,w){var k=S[0]-w[0]*h.k,I=S[1]-w[1]*h.k;return k===h.x&&I===h.y?h:new Ct(h.k,k,I)}function x(h){return[(+h[0][0]+ +h[1][0])/2,(+h[0][1]+ +h[1][1])/2]}function $(h,S,w,k){h.on("start.zoom",function(){C(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(k).end()}).tween("zoom",function(){var I=this,_=arguments,A=C(I,_).event(k),R=e.apply(I,_),D=w==null?x(R):typeof w=="function"?w.apply(I,_):w,B=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),F=I.__zoom,W=typeof S=="function"?S.apply(I,_):S,U=a(F.invert(D).concat(B/F.k),W.invert(D).concat(B/W.k));return function(Z){if(Z===1)Z=W;else{var Q=U(Z),K=B/Q[2];Z=new Ct(K,D[0]-Q[0]*K,D[1]-Q[1]*K)}A.zoom(null,Z)}})}function C(h,S,w){return!w&&h.__zooming||new z(h,S)}function z(h,S){this.that=h,this.args=S,this.active=0,this.sourceEvent=null,this.extent=e.apply(h,S),this.taps=0}z.prototype={event:function(h){return h&&(this.sourceEvent=h),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(h,S){return this.mouse&&h!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&h!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&h!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(h){var S=gt(this.that).datum();u.call(h,this.that,new Kl(h,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:u}),S)}};function P(h,...S){if(!t.apply(this,arguments))return;var w=C(this,S).event(h),k=this.__zoom,I=Math.max(s[0],Math.min(s[1],k.k*Math.pow(2,r.apply(this,arguments)))),_=yt(h);if(w.wheel)(w.mouse[0][0]!==_[0]||w.mouse[0][1]!==_[1])&&(w.mouse[1]=k.invert(w.mouse[0]=_)),clearTimeout(w.wheel);else{if(k.k===I)return;w.mouse=[_,k.invert(_)],qe(this),w.start()}ye(h),w.wheel=setTimeout(A,y),w.zoom("mouse",n(M(E(k,I),w.mouse[0],w.mouse[1]),w.extent,i));function A(){w.wheel=null,w.end()}}function T(h,...S){if(d||!t.apply(this,arguments))return;var w=h.currentTarget,k=C(this,S,!0).event(h),I=gt(h.view).on("mousemove.zoom",D,!0).on("mouseup.zoom",B,!0),_=yt(h,w),A=h.clientX,R=h.clientY;vo(h.view),En(h),k.mouse=[_,this.__zoom.invert(_)],qe(this),k.start();function D(F){if(ye(F),!k.moved){var W=F.clientX-A,U=F.clientY-R;k.moved=W*W+U*U>p}k.event(F).zoom("mouse",n(M(k.that.__zoom,k.mouse[0]=yt(F,w),k.mouse[1]),k.extent,i))}function B(F){I.on("mousemove.zoom mouseup.zoom",null),_o(F.view,k.moved),ye(F),k.event(F).end()}}function L(h,...S){if(t.apply(this,arguments)){var w=this.__zoom,k=yt(h.changedTouches?h.changedTouches[0]:h,this),I=w.invert(k),_=w.k*(h.shiftKey?.5:2),A=n(M(E(w,_),k,I),e.apply(this,S),i);ye(h),c>0?gt(this).transition().duration(c).call($,A,k,h):gt(this).call(m.transform,A,k,h)}}function H(h,...S){if(t.apply(this,arguments)){var w=h.touches,k=w.length,I=C(this,S,h.changedTouches.length===k).event(h),_,A,R,D;for(En(h),A=0;A<k;++A)R=w[A],D=yt(R,this),D=[D,this.__zoom.invert(D),R.identifier],I.touch0?!I.touch1&&I.touch0[2]!==D[2]&&(I.touch1=D,I.taps=0):(I.touch0=D,_=!0,I.taps=1+!!l);l&&(l=clearTimeout(l)),_&&(I.taps<2&&(f=D[0],l=setTimeout(function(){l=null},g)),qe(this),I.start())}}function O(h,...S){if(this.__zooming){var w=C(this,S).event(h),k=h.changedTouches,I=k.length,_,A,R,D;for(ye(h),_=0;_<I;++_)A=k[_],R=yt(A,this),w.touch0&&w.touch0[2]===A.identifier?w.touch0[0]=R:w.touch1&&w.touch1[2]===A.identifier&&(w.touch1[0]=R);if(A=w.that.__zoom,w.touch1){var B=w.touch0[0],F=w.touch0[1],W=w.touch1[0],U=w.touch1[1],Z=(Z=W[0]-B[0])*Z+(Z=W[1]-B[1])*Z,Q=(Q=U[0]-F[0])*Q+(Q=U[1]-F[1])*Q;A=E(A,Math.sqrt(Z/Q)),R=[(B[0]+W[0])/2,(B[1]+W[1])/2],D=[(F[0]+U[0])/2,(F[1]+U[1])/2]}else if(w.touch0)R=w.touch0[0],D=w.touch0[1];else return;w.zoom("touch",n(M(A,R,D),w.extent,i))}}function V(h,...S){if(this.__zooming){var w=C(this,S).event(h),k=h.changedTouches,I=k.length,_,A;for(En(h),d&&clearTimeout(d),d=setTimeout(function(){d=null},g),_=0;_<I;++_)A=k[_],w.touch0&&w.touch0[2]===A.identifier?delete w.touch0:w.touch1&&w.touch1[2]===A.identifier&&delete w.touch1;if(w.touch1&&!w.touch0&&(w.touch0=w.touch1,delete w.touch1),w.touch0)w.touch0[1]=this.__zoom.invert(w.touch0[0]);else if(w.end(),w.taps===2&&(A=yt(A,this),Math.hypot(f[0]-A[0],f[1]-A[1])<v)){var R=gt(this).on("dblclick.zoom");R&&R.apply(this,arguments)}}}return m.wheelDelta=function(h){return arguments.length?(r=typeof h=="function"?h:Le(+h),m):r},m.filter=function(h){return arguments.length?(t=typeof h=="function"?h:Le(!!h),m):t},m.touchable=function(h){return arguments.length?(o=typeof h=="function"?h:Le(!!h),m):o},m.extent=function(h){return arguments.length?(e=typeof h=="function"?h:Le([[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]]),m):e},m.scaleExtent=function(h){return arguments.length?(s[0]=+h[0],s[1]=+h[1],m):[s[0],s[1]]},m.translateExtent=function(h){return arguments.length?(i[0][0]=+h[0][0],i[1][0]=+h[1][0],i[0][1]=+h[0][1],i[1][1]=+h[1][1],m):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},m.constrain=function(h){return arguments.length?(n=h,m):n},m.duration=function(h){return arguments.length?(c=+h,m):c},m.interpolate=function(h){return arguments.length?(a=h,m):a},m.on=function(){var h=u.on.apply(u,arguments);return h===u?m:h},m.clickDistance=function(h){return arguments.length?(p=(h=+h)*h,m):Math.sqrt(p)},m.tapDistance=function(h){return arguments.length?(v=+h,m):v},m}const ln=b.createContext(null),nu=ln.Provider,Tt={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.`},Ho=Tt.error001();function j(t,e){const n=b.useContext(ln);if(n===null)throw new Error(Ho);return so(n,t,e)}const rt=()=>{const t=b.useContext(ln);if(t===null)throw new Error(Ho);return b.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},ru=t=>t.userSelectionActive?"none":"all";function Qn({position:t,children:e,className:n,style:r,...o}){const s=j(ru),i=`${t}`.split("-");return N.createElement("div",{className:it(["react-flow__panel",n,...i]),style:{...r,pointerEvents:s},...o},e)}function ou({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:N.createElement(Qn,{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"},N.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const iu=({x:t,y:e,label:n,labelStyle:r={},labelShowBg:o=!0,labelBgStyle:s={},labelBgPadding:i=[2,4],labelBgBorderRadius:c=2,children:a,className:u,...l})=>{const f=b.useRef(null),[d,g]=b.useState({x:0,y:0,width:0,height:0}),y=it(["react-flow__edge-textwrapper",u]);return b.useEffect(()=>{if(f.current){const p=f.current.getBBox();g({x:p.x,y:p.y,width:p.width,height:p.height})}},[n]),typeof n>"u"||!n?null:N.createElement("g",{transform:`translate(${t-d.width/2} ${e-d.height/2})`,className:y,visibility:d.width?"visible":"hidden",...l},o&&N.createElement("rect",{width:d.width+2*i[0],x:-i[0],y:-i[1],height:d.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:c,ry:c}),N.createElement("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:f,style:r},n),a)};var su=b.memo(iu);const Jn=t=>({width:t.offsetWidth,height:t.offsetHeight}),fe=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),jn=(t={x:0,y:0},e)=>({x:fe(t.x,e[0][0],e[1][0]),y:fe(t.y,e[0][1],e[1][1])}),Hr=(t,e,n)=>t<e?fe(Math.abs(t-e),1,50)/50:t>n?-fe(Math.abs(t-n),1,50)/50:0,Po=(t,e)=>{const n=Hr(t.x,35,e.width-35)*20,r=Hr(t.y,35,e.height-35)*20;return[n,r]},Vo=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)}),Ae=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),Oo=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),Pr=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),cu=(t,e)=>Oo(Lo(Ae(t),Ae(e))),Pn=(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)},au=t=>pt(t.width)&&pt(t.height)&&pt(t.x)&&pt(t.y),pt=t=>!isNaN(t)&&isFinite(t),tt=Symbol.for("internals"),Fo=["Enter"," ","Escape"],lu=(t,e)=>{},uu=t=>"nativeEvent"in t;function Vn(t){var o,s;const e=uu(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 Bo=t=>"clientX"in t,Ht=(t,e)=>{var s,i;const n=Bo(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)}},tn=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},Re=({id:t,path:e,labelX:n,labelY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:u,style:l,markerEnd:f,markerStart:d,interactionWidth:g=20})=>N.createElement(N.Fragment,null,N.createElement("path",{id:t,style:l,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:d}),g&&N.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:g,className:"react-flow__edge-interaction"}),o&&pt(n)&&pt(r)?N.createElement(su,{x:n,y:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:u}):null);Re.displayName="BaseEdge";function xe(t,e,n){return n===void 0?n:r=>{const o=e().edges.find(s=>s.id===t);o&&n(r,{...o})}}function Yo({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 Xo({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,u=e*.125+s*.375+c*.375+r*.125,l=Math.abs(a-t),f=Math.abs(u-e);return[a,u,l,f]}var Gt;(function(t){t.Strict="strict",t.Loose="loose"})(Gt||(Gt={}));var Wt;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Wt||(Wt={}));var ke;(function(t){t.Partial="partial",t.Full="full"})(ke||(ke={}));var Dt;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Dt||(Dt={}));var en;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(en||(en={}));var X;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(X||(X={}));function Vr({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 Wo({sourceX:t,sourceY:e,sourcePosition:n=X.Bottom,targetX:r,targetY:o,targetPosition:s=X.Top}){const[i,c]=Vr({pos:n,x1:t,y1:e,x2:r,y2:o}),[a,u]=Vr({pos:s,x1:r,y1:o,x2:t,y2:e}),[l,f,d,g]=Xo({sourceX:t,sourceY:e,targetX:r,targetY:o,sourceControlX:i,sourceControlY:c,targetControlX:a,targetControlY:u});return[`M${t},${e} C${i},${c} ${a},${u} ${r},${o}`,l,f,d,g]}const tr=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:u,labelBgPadding:l,labelBgBorderRadius:f,style:d,markerEnd:g,markerStart:y,interactionWidth:p})=>{const[v,m,E]=Wo({sourceX:t,sourceY:e,sourcePosition:o,targetX:n,targetY:r,targetPosition:s});return N.createElement(Re,{path:v,labelX:m,labelY:E,label:i,labelStyle:c,labelShowBg:a,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:f,style:d,markerEnd:g,markerStart:y,interactionWidth:p})});tr.displayName="SimpleBezierEdge";const Lr={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},fu=({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},Or=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function du({source:t,sourcePosition:e=X.Bottom,target:n,targetPosition:r=X.Top,center:o,offset:s}){const i=Lr[e],c=Lr[r],a={x:t.x+i.x*s,y:t.y+i.y*s},u={x:n.x+c.x*s,y:n.y+c.y*s},l=fu({source:a,sourcePosition:e,target:u}),f=l.x!==0?"x":"y",d=l[f];let g=[],y,p;const v={x:0,y:0},m={x:0,y:0},[E,M,x,$]=Yo({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(i[f]*c[f]===-1){y=o.x??E,p=o.y??M;const z=[{x:y,y:a.y},{x:y,y:u.y}],P=[{x:a.x,y:p},{x:u.x,y:p}];i[f]===d?g=f==="x"?z:P:g=f==="x"?P:z}else{const z=[{x:a.x,y:u.y}],P=[{x:u.x,y:a.y}];if(f==="x"?g=i.x===d?P:z:g=i.y===d?z:P,e===r){const V=Math.abs(t[f]-n[f]);if(V<=s){const h=Math.min(s-1,s-V);i[f]===d?v[f]=(a[f]>t[f]?-1:1)*h:m[f]=(u[f]>n[f]?-1:1)*h}}if(e!==r){const V=f==="x"?"y":"x",h=i[f]===c[V],S=a[V]>u[V],w=a[V]<u[V];(i[f]===1&&(!h&&S||h&&w)||i[f]!==1&&(!h&&w||h&&S))&&(g=f==="x"?z:P)}const T={x:a.x+v.x,y:a.y+v.y},L={x:u.x+m.x,y:u.y+m.y},H=Math.max(Math.abs(T.x-g[0].x),Math.abs(L.x-g[0].x)),O=Math.max(Math.abs(T.y-g[0].y),Math.abs(L.y-g[0].y));H>=O?(y=(T.x+L.x)/2,p=g[0].y):(y=g[0].x,p=(T.y+L.y)/2)}return[[t,{x:a.x+v.x,y:a.y+v.y},...g,{x:u.x+m.x,y:u.y+m.y},n],y,p,x,$]}function hu(t,e,n,r){const o=Math.min(Or(t,e)/2,Or(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 u=t.x<n.x?-1:1,l=t.y<n.y?1:-1;return`L ${s+o*u},${i}Q ${s},${i} ${s},${i+o*l}`}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 Ln({sourceX:t,sourceY:e,sourcePosition:n=X.Bottom,targetX:r,targetY:o,targetPosition:s=X.Top,borderRadius:i=5,centerX:c,centerY:a,offset:u=20}){const[l,f,d,g,y]=du({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:c,y:a},offset:u});return[l.reduce((v,m,E)=>{let M="";return E>0&&E<l.length-1?M=hu(l[E-1],m,l[E+1],i):M=`${E===0?"M":"L"}${m.x} ${m.y}`,v+=M,v},""),f,d,g,y]}const un=b.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:u,style:l,sourcePosition:f=X.Bottom,targetPosition:d=X.Top,markerEnd:g,markerStart:y,pathOptions:p,interactionWidth:v})=>{const[m,E,M]=Ln({sourceX:t,sourceY:e,sourcePosition:f,targetX:n,targetY:r,targetPosition:d,borderRadius:p==null?void 0:p.borderRadius,offset:p==null?void 0:p.offset});return N.createElement(Re,{path:m,labelX:E,labelY:M,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:u,style:l,markerEnd:g,markerStart:y,interactionWidth:v})});un.displayName="SmoothStepEdge";const er=b.memo(t=>{var e;return N.createElement(un,{...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])})});er.displayName="StepEdge";function gu({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[o,s,i,c]=Yo({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,o,s,i,c]}const nr=b.memo(({sourceX:t,sourceY:e,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:u,style:l,markerEnd:f,markerStart:d,interactionWidth:g})=>{const[y,p,v]=gu({sourceX:t,sourceY:e,targetX:n,targetY:r});return N.createElement(Re,{path:y,labelX:p,labelY:v,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:c,labelBgPadding:a,labelBgBorderRadius:u,style:l,markerEnd:f,markerStart:d,interactionWidth:g})});nr.displayName="StraightEdge";function Oe(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function Fr({pos:t,x1:e,y1:n,x2:r,y2:o,c:s}){switch(t){case X.Left:return[e-Oe(e-r,s),n];case X.Right:return[e+Oe(r-e,s),n];case X.Top:return[e,n-Oe(n-o,s)];case X.Bottom:return[e,n+Oe(o-n,s)]}}function Uo({sourceX:t,sourceY:e,sourcePosition:n=X.Bottom,targetX:r,targetY:o,targetPosition:s=X.Top,curvature:i=.25}){const[c,a]=Fr({pos:n,x1:t,y1:e,x2:r,y2:o,c:i}),[u,l]=Fr({pos:s,x1:r,y1:o,x2:t,y2:e,c:i}),[f,d,g,y]=Xo({sourceX:t,sourceY:e,targetX:r,targetY:o,sourceControlX:c,sourceControlY:a,targetControlX:u,targetControlY:l});return[`M${t},${e} C${c},${a} ${u},${l} ${r},${o}`,f,d,g,y]}const nn=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:u,labelBgPadding:l,labelBgBorderRadius:f,style:d,markerEnd:g,markerStart:y,pathOptions:p,interactionWidth:v})=>{const[m,E,M]=Uo({sourceX:t,sourceY:e,sourcePosition:o,targetX:n,targetY:r,targetPosition:s,curvature:p==null?void 0:p.curvature});return N.createElement(Re,{path:m,labelX:E,labelY:M,label:i,labelStyle:c,labelShowBg:a,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:f,style:d,markerEnd:g,markerStart:y,interactionWidth:v})});nn.displayName="BezierEdge";const rr=b.createContext(null),pu=rr.Provider;rr.Consumer;const mu=()=>b.useContext(rr),yu=t=>"id"in t&&"source"in t&&"target"in t,xu=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`reactflow__edge-${t}${e||""}-${n}${r||""}`,On=(t,e)=>typeof t>"u"?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`,wu=(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)),vu=(t,e)=>{if(!t.source||!t.target)return e;let n;return yu(t)?n={...t}:n={...t,id:xu(t)},wu(n,e)?e:e.concat(n)},Fn=({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},qo=({x:t,y:e},[n,r,o])=>({x:t*o+n,y:e*o+r}),qt=(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}},fn=(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}=qt(o,e).positionAbsolute;return Lo(r,Ae({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 Oo(n)},Zo=(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},u=[];return t.forEach(l=>{const{width:f,height:d,selectable:g=!0,hidden:y=!1}=l;if(i&&!g||y)return!1;const{positionAbsolute:p}=qt(l,c),v={x:p.x,y:p.y,width:f||0,height:d||0},m=Pn(a,v),E=typeof f>"u"||typeof d>"u"||f===null||d===null,M=s&&m>0,x=(f||0)*(d||0);(E||M||m>=x||l.dragging)&&u.push(l)}),u},Go=(t,e)=>{const n=t.map(r=>r.id);return e.filter(r=>n.includes(r.source)||n.includes(r.target))},Ko=(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),u=fe(a,r,o),l=t.x+t.width/2,f=t.y+t.height/2,d=e/2-l*u,g=n/2-f*u;return{x:d,y:g,zoom:u}},Yt=(t,e=0)=>t.transition().duration(e);function Br(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 _u(t,e,n,r,o,s){const{x:i,y:c}=Ht(t),u=e.elementsFromPoint(i,c).find(y=>y.classList.contains("react-flow__handle"));if(u){const y=u.getAttribute("data-nodeid");if(y){const p=or(void 0,u),v=u.getAttribute("data-handleid"),m=s({nodeId:y,id:v,type:p});if(m){const E=o.find(M=>M.nodeId===y&&M.type===p&&M.id===v);return{handle:{id:v,type:p,nodeId:y,x:(E==null?void 0:E.x)||n.x,y:(E==null?void 0:E.y)||n.y},validHandleResult:m}}}}let l=[],f=1/0;if(o.forEach(y=>{const p=Math.sqrt((y.x-n.x)**2+(y.y-n.y)**2);if(p<=r){const v=s(y);p<=f&&(p<f?l=[{handle:y,validHandleResult:v}]:p===f&&l.push({handle:y,validHandleResult:v}),f=p)}}),!l.length)return{handle:null,validHandleResult:Qo()};if(l.length===1)return l[0];const d=l.some(({validHandleResult:y})=>y.isValid),g=l.some(({handle:y})=>y.type==="target");return l.find(({handle:y,validHandleResult:p})=>g?y.type==="target":d?p.isValid:!0)||l[0]}const Eu={source:null,target:null,sourceHandle:null,targetHandle:null},Qo=()=>({handleDomNode:null,isValid:!1,connection:Eu,endHandle:null});function Jo(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}"]`),u={...Qo(),handleDomNode:a};if(a){const l=or(void 0,a),f=a.getAttribute("data-nodeid"),d=a.getAttribute("data-handleid"),g=a.classList.contains("connectable"),y=a.classList.contains("connectableend"),p={source:c?f:n,sourceHandle:c?d:r,target:c?n:f,targetHandle:c?r:d};u.connection=p,g&&y&&(e===Gt.Strict?c&&l==="source"||!c&&l==="target":f!==n||d!==r)&&(u.endHandle={nodeId:f,handleId:d,type:l},u.isValid=s(p))}return u}function Su({nodes:t,nodeId:e,handleId:n,handleType:r}){return t.reduce((o,s)=>{if(s[tt]){const{handleBounds:i}=s[tt];let c=[],a=[];i&&(c=Br(s,i,"source",`${e}-${n}-${r}`),a=Br(s,i,"target",`${e}-${n}-${r}`)),o.push(...c,...a)}return o},[])}function or(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function Sn(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function bu(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function jo({event:t,handleId:e,nodeId:n,onConnect:r,isTarget:o,getState:s,setState:i,isValidConnection:c,edgeUpdaterType:a,onReconnectEnd:u}){const l=Vo(t.target),{connectionMode:f,domNode:d,autoPanOnConnect:g,connectionRadius:y,onConnectStart:p,panBy:v,getNodes:m,cancelConnection:E}=s();let M=0,x;const{x:$,y:C}=Ht(t),z=l==null?void 0:l.elementFromPoint($,C),P=or(a,z),T=d==null?void 0:d.getBoundingClientRect();if(!T||!P)return;let L,H=Ht(t,T),O=!1,V=null,h=!1,S=null;const w=Su({nodes:m(),nodeId:n,handleId:e,handleType:P}),k=()=>{if(!g)return;const[A,R]=Po(H,T);v({x:A,y:R}),M=requestAnimationFrame(k)};i({connectionPosition:H,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:P,connectionStartHandle:{nodeId:n,handleId:e,type:P},connectionEndHandle:null}),p==null||p(t,{nodeId:n,handleId:e,handleType:P});function I(A){const{transform:R}=s();H=Ht(A,T);const{handle:D,validHandleResult:B}=_u(A,l,Fn(H,R,!1,[1,1]),y,w,F=>Jo(F,f,n,e,o?"target":"source",c,l));if(x=D,O||(k(),O=!0),S=B.handleDomNode,V=B.connection,h=B.isValid,i({connectionPosition:x&&h?qo({x:x.x,y:x.y},R):H,connectionStatus:bu(!!x,h),connectionEndHandle:B.endHandle}),!x&&!h&&!S)return Sn(L);V.source!==V.target&&S&&(Sn(L),L=S,S.classList.add("connecting","react-flow__handle-connecting"),S.classList.toggle("valid",h),S.classList.toggle("react-flow__handle-valid",h))}function _(A){var R,D;(x||S)&&V&&h&&(r==null||r(V)),(D=(R=s()).onConnectEnd)==null||D.call(R,A),a&&(u==null||u(A)),Sn(L),E(),cancelAnimationFrame(M),O=!1,h=!1,V=null,S=null,l.removeEventListener("mousemove",I),l.removeEventListener("mouseup",_),l.removeEventListener("touchmove",I),l.removeEventListener("touchend",_)}l.addEventListener("mousemove",I),l.addEventListener("mouseup",_),l.addEventListener("touchmove",I),l.addEventListener("touchend",_)}const Yr=()=>!0,Nu=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),Mu=(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}},ti=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:u,onMouseDown:l,onTouchStart:f,...d},g)=>{var T,L;const y=i||null,p=t==="target",v=rt(),m=mu(),{connectOnClick:E,noPanClassName:M}=j(Nu,ft),{connecting:x,clickConnecting:$}=j(Mu(m,y,t),ft);m||(L=(T=v.getState()).onError)==null||L.call(T,"010",Tt.error010());const C=H=>{const{defaultEdgeOptions:O,onConnect:V,hasDefaultEdges:h}=v.getState(),S={...O,...H};if(h){const{edges:w,setEdges:k}=v.getState();k(vu(S,w))}V==null||V(S),c==null||c(S)},z=H=>{if(!m)return;const O=Bo(H);o&&(O&&H.button===0||!O)&&jo({event:H,handleId:y,nodeId:m,onConnect:C,isTarget:p,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||Yr}),O?l==null||l(H):f==null||f(H)},P=H=>{const{onClickConnectStart:O,onClickConnectEnd:V,connectionClickStartHandle:h,connectionMode:S,isValidConnection:w}=v.getState();if(!m||!h&&!o)return;if(!h){O==null||O(H,{nodeId:m,handleId:y,handleType:t}),v.setState({connectionClickStartHandle:{nodeId:m,type:t,handleId:y}});return}const k=Vo(H.target),I=n||w||Yr,{connection:_,isValid:A}=Jo({nodeId:m,id:y,type:t},S,h.nodeId,h.handleId||null,h.type,I,k);A&&C(_),V==null||V(H),v.setState({connectionClickStartHandle:null})};return N.createElement("div",{"data-handleid":y,"data-nodeid":m,"data-handlepos":e,"data-id":`${m}-${y}-${t}`,className:it(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",M,u,{source:!p,target:p,connectable:r,connectablestart:o,connectableend:s,connecting:$,connectionindicator:r&&(o&&!x||s&&x)}]),onMouseDown:z,onTouchStart:z,onClick:E?P:void 0,ref:g,...d},a)});ti.displayName="Handle";var rn=b.memo(ti);const ei=({data:t,isConnectable:e,targetPosition:n=X.Top,sourcePosition:r=X.Bottom})=>N.createElement(N.Fragment,null,N.createElement(rn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,N.createElement(rn,{type:"source",position:r,isConnectable:e}));ei.displayName="DefaultNode";var Bn=b.memo(ei);const ni=({data:t,isConnectable:e,sourcePosition:n=X.Bottom})=>N.createElement(N.Fragment,null,t==null?void 0:t.label,N.createElement(rn,{type:"source",position:n,isConnectable:e}));ni.displayName="InputNode";var ri=b.memo(ni);const oi=({data:t,isConnectable:e,targetPosition:n=X.Top})=>N.createElement(N.Fragment,null,N.createElement(rn,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);oi.displayName="OutputNode";var ii=b.memo(oi);const ir=()=>null;ir.displayName="GroupNode";const $u=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),Fe=t=>t.id;function Cu(t,e){return ft(t.selectedNodes.map(Fe),e.selectedNodes.map(Fe))&&ft(t.selectedEdges.map(Fe),e.selectedEdges.map(Fe))}const si=b.memo(({onSelectionChange:t})=>{const e=rt(),{selectedNodes:n,selectedEdges:r}=j($u,Cu);return b.useEffect(()=>{const o={nodes:n,edges:r};t==null||t(o),e.getState().onSelectionChange.forEach(s=>s(o))},[n,r,t]),null});si.displayName="SelectionListener";const Au=t=>!!t.onSelectionChange;function ku({onSelectionChange:t}){const e=j(Au);return t||e?N.createElement(si,{onSelectionChange:t}):null}const Tu=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 ee(t,e){b.useEffect(()=>{typeof t<"u"&&e(t)},[t])}function q(t,e,n){b.useEffect(()=>{typeof e<"u"&&n({[t]:e})},[e])}const zu=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:o,onConnectStart:s,onConnectEnd:i,onClickConnectStart:c,onClickConnectEnd:a,nodesDraggable:u,nodesConnectable:l,nodesFocusable:f,edgesFocusable:d,edgesUpdatable:g,elevateNodesOnSelect:y,minZoom:p,maxZoom:v,nodeExtent:m,onNodesChange:E,onEdgesChange:M,elementsSelectable:x,connectionMode:$,snapGrid:C,snapToGrid:z,translateExtent:P,connectOnClick:T,defaultEdgeOptions:L,fitView:H,fitViewOptions:O,onNodesDelete:V,onEdgesDelete:h,onNodeDrag:S,onNodeDragStart:w,onNodeDragStop:k,onSelectionDrag:I,onSelectionDragStart:_,onSelectionDragStop:A,noPanClassName:R,nodeOrigin:D,rfId:B,autoPanOnConnect:F,autoPanOnNodeDrag:W,onError:U,connectionRadius:Z,isValidConnection:Q,nodeDragThreshold:K})=>{const{setNodes:G,setEdges:ot,setDefaultNodesAndEdges:nt,setMinZoom:at,setMaxZoom:st,setTranslateExtent:et,setNodeExtent:dt,reset:J}=j(Tu,ft),Y=rt();return b.useEffect(()=>{const lt=r==null?void 0:r.map(bt=>({...bt,...L}));return nt(n,lt),()=>{J()}},[]),q("defaultEdgeOptions",L,Y.setState),q("connectionMode",$,Y.setState),q("onConnect",o,Y.setState),q("onConnectStart",s,Y.setState),q("onConnectEnd",i,Y.setState),q("onClickConnectStart",c,Y.setState),q("onClickConnectEnd",a,Y.setState),q("nodesDraggable",u,Y.setState),q("nodesConnectable",l,Y.setState),q("nodesFocusable",f,Y.setState),q("edgesFocusable",d,Y.setState),q("edgesUpdatable",g,Y.setState),q("elementsSelectable",x,Y.setState),q("elevateNodesOnSelect",y,Y.setState),q("snapToGrid",z,Y.setState),q("snapGrid",C,Y.setState),q("onNodesChange",E,Y.setState),q("onEdgesChange",M,Y.setState),q("connectOnClick",T,Y.setState),q("fitViewOnInit",H,Y.setState),q("fitViewOnInitOptions",O,Y.setState),q("onNodesDelete",V,Y.setState),q("onEdgesDelete",h,Y.setState),q("onNodeDrag",S,Y.setState),q("onNodeDragStart",w,Y.setState),q("onNodeDragStop",k,Y.setState),q("onSelectionDrag",I,Y.setState),q("onSelectionDragStart",_,Y.setState),q("onSelectionDragStop",A,Y.setState),q("noPanClassName",R,Y.setState),q("nodeOrigin",D,Y.setState),q("rfId",B,Y.setState),q("autoPanOnConnect",F,Y.setState),q("autoPanOnNodeDrag",W,Y.setState),q("onError",U,Y.setState),q("connectionRadius",Z,Y.setState),q("isValidConnection",Q,Y.setState),q("nodeDragThreshold",K,Y.setState),ee(t,G),ee(e,ot),ee(p,at),ee(v,st),ee(P,et),ee(m,dt),null},Xr={display:"none"},Iu={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ci="react-flow__node-desc",ai="react-flow__edge-desc",Ru="react-flow__aria-live",Du=t=>t.ariaLiveMessage;function Hu({rfId:t}){const e=j(Du);return N.createElement("div",{id:`${Ru}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:Iu},e)}function Pu({rfId:t,disableKeyboardA11y:e}){return N.createElement(N.Fragment,null,N.createElement("div",{id:`${ci}-${t}`,style:Xr},"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."," "),N.createElement("div",{id:`${ai}-${t}`,style:Xr},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&N.createElement(Hu,{rfId:t}))}var Te=(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 u=(Array.isArray(t)?t:[t]).filter(f=>typeof f=="string").map(f=>f.split("+")),l=u.reduce((f,d)=>f.concat(...d),[]);return[u,l]}return[[],[]]},[t]);return b.useEffect(()=>{const a=typeof document<"u"?document:null,u=(e==null?void 0:e.target)||a;if(t!==null){const l=g=>{if(o.current=g.ctrlKey||g.metaKey||g.shiftKey,(!o.current||o.current&&!e.actInsideInputWithModifier)&&Vn(g))return!1;const p=Ur(g.code,c);s.current.add(g[p]),Wr(i,s.current,!1)&&(g.preventDefault(),r(!0))},f=g=>{if((!o.current||o.current&&!e.actInsideInputWithModifier)&&Vn(g))return!1;const p=Ur(g.code,c);Wr(i,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(g[p]),g.key==="Meta"&&s.current.clear(),o.current=!1},d=()=>{s.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",l),u==null||u.addEventListener("keyup",f),window.addEventListener("blur",d),()=>{u==null||u.removeEventListener("keydown",l),u==null||u.removeEventListener("keyup",f),window.removeEventListener("blur",d)}}},[t,r]),n};function Wr(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(o=>e.has(o)))}function Ur(t,e){return e.includes(t)?"code":"key"}function li(t,e,n,r){var c,a;const o=t.parentNode||t.parentId;if(!o)return n;const s=e.get(o),i=qt(s,r);return li(s,e,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((c=s[tt])==null?void 0:c.z)??0)>(n.z??0)?((a=s[tt])==null?void 0:a.z)??0:n.z??0},r)}function ui(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}=li(r,t,{...r.position,z:((s=r[tt])==null?void 0:s.z)??0},e);r.positionAbsolute={x:i,y:c},r[tt].z=a,n!=null&&n[r.id]&&(r[tt].isParent=!0)}})}function bn(t,e,n,r){const o=new Map,s={},i=r?1e3:0;return t.forEach(c=>{var g;const a=(pt(c.zIndex)?c.zIndex:0)+(c.selected?i:0),u=e.get(c.id),l={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},f=c.parentNode||c.parentId;f&&(s[f]=!0);const d=(u==null?void 0:u.type)&&(u==null?void 0:u.type)!==c.type;Object.defineProperty(l,tt,{enumerable:!1,value:{handleBounds:d||(g=u==null?void 0:u[tt])==null?void 0:g.handleBounds,z:a}}),o.set(c.id,l)}),ui(o,n,s),o}function fi(t,e={}){const{getNodes:n,width:r,height:o,minZoom:s,maxZoom:i,d3Zoom:c,d3Selection:a,fitViewOnInitDone:u,fitViewOnInit:l,nodeOrigin:f}=t(),d=e.initial&&!u&&l;if(c&&a&&(d||!e.initial)){const y=n().filter(v=>{var E;const m=e.includeHiddenNodes?v.width&&v.height:!v.hidden;return(E=e.nodes)!=null&&E.length?m&&e.nodes.some(M=>M.id===v.id):m}),p=y.every(v=>v.width&&v.height);if(y.length>0&&p){const v=fn(y,f),{x:m,y:E,zoom:M}=Ko(v,r,o,e.minZoom??s,e.maxZoom??i,e.padding??.1),x=At.translate(m,E).scale(M);return typeof e.duration=="number"&&e.duration>0?c.transform(Yt(a,e.duration),x):c.transform(a,x),!0}}return!1}function Vu(t,e){return t.forEach(n=>{const r=e.get(n.id);r&&e.set(r.id,{...r,[tt]:r[tt],selected:n.selected})}),new Map(e)}function Lu(t,e){return e.map(n=>{const r=t.find(o=>o.id===n.id);return r&&(n.selected=r.selected),n})}function Be({changedNodes:t,changedEdges:e,get:n,set:r}){const{nodeInternals:o,edges:s,onNodesChange:i,onEdgesChange:c,hasDefaultNodes:a,hasDefaultEdges:u}=n();t!=null&&t.length&&(a&&r({nodeInternals:Vu(t,o)}),i==null||i(t)),e!=null&&e.length&&(u&&r({edges:Lu(e,s)}),c==null||c(e))}const ne=()=>{},Ou={zoomIn:ne,zoomOut:ne,zoomTo:ne,getZoom:()=>1,setViewport:ne,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ne,fitBounds:ne,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},Fu=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection}),Bu=()=>{const t=rt(),{d3Zoom:e,d3Selection:n}=j(Fu,ft);return b.useMemo(()=>n&&e?{zoomIn:o=>e.scaleBy(Yt(n,o==null?void 0:o.duration),1.2),zoomOut:o=>e.scaleBy(Yt(n,o==null?void 0:o.duration),1/1.2),zoomTo:(o,s)=>e.scaleTo(Yt(n,s==null?void 0:s.duration),o),getZoom:()=>t.getState().transform[2],setViewport:(o,s)=>{const[i,c,a]=t.getState().transform,u=At.translate(o.x??i,o.y??c).scale(o.zoom??a);e.transform(Yt(n,s==null?void 0:s.duration),u)},getViewport:()=>{const[o,s,i]=t.getState().transform;return{x:o,y:s,zoom:i}},fitView:o=>fi(t.getState,o),setCenter:(o,s,i)=>{const{width:c,height:a,maxZoom:u}=t.getState(),l=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:u,f=c/2-o*l,d=a/2-s*l,g=At.translate(f,d).scale(l);e.transform(Yt(n,i==null?void 0:i.duration),g)},fitBounds:(o,s)=>{const{width:i,height:c,minZoom:a,maxZoom:u}=t.getState(),{x:l,y:f,zoom:d}=Ko(o,i,c,a,u,(s==null?void 0:s.padding)??.1),g=At.translate(l,f).scale(d);e.transform(Yt(n,s==null?void 0:s.duration),g)},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"),Fn(o,s,i,c)},screenToFlowPosition:o=>{const{transform:s,snapToGrid:i,snapGrid:c,domNode:a}=t.getState();if(!a)return o;const{x:u,y:l}=a.getBoundingClientRect(),f={x:o.x-u,y:o.y-l};return Fn(f,s,i,c)},flowToScreenPosition:o=>{const{transform:s,domNode:i}=t.getState();if(!i)return o;const{x:c,y:a}=i.getBoundingClientRect(),u=qo(o,s);return{x:u.x+c,y:u.y+a}},viewportInitialized:!0}:Ou,[e,n])};function sr(){const t=Bu(),e=rt(),n=b.useCallback(()=>e.getState().getNodes().map(p=>({...p})),[]),r=b.useCallback(p=>e.getState().nodeInternals.get(p),[]),o=b.useCallback(()=>{const{edges:p=[]}=e.getState();return p.map(v=>({...v}))},[]),s=b.useCallback(p=>{const{edges:v=[]}=e.getState();return v.find(m=>m.id===p)},[]),i=b.useCallback(p=>{const{getNodes:v,setNodes:m,hasDefaultNodes:E,onNodesChange:M}=e.getState(),x=v(),$=typeof p=="function"?p(x):p;if(E)m($);else if(M){const C=$.length===0?x.map(z=>({type:"remove",id:z.id})):$.map(z=>({item:z,type:"reset"}));M(C)}},[]),c=b.useCallback(p=>{const{edges:v=[],setEdges:m,hasDefaultEdges:E,onEdgesChange:M}=e.getState(),x=typeof p=="function"?p(v):p;if(E)m(x);else if(M){const $=x.length===0?v.map(C=>({type:"remove",id:C.id})):x.map(C=>({item:C,type:"reset"}));M($)}},[]),a=b.useCallback(p=>{const v=Array.isArray(p)?p:[p],{getNodes:m,setNodes:E,hasDefaultNodes:M,onNodesChange:x}=e.getState();if(M){const C=[...m(),...v];E(C)}else if(x){const $=v.map(C=>({item:C,type:"add"}));x($)}},[]),u=b.useCallback(p=>{const v=Array.isArray(p)?p:[p],{edges:m=[],setEdges:E,hasDefaultEdges:M,onEdgesChange:x}=e.getState();if(M)E([...m,...v]);else if(x){const $=v.map(C=>({item:C,type:"add"}));x($)}},[]),l=b.useCallback(()=>{const{getNodes:p,edges:v=[],transform:m}=e.getState(),[E,M,x]=m;return{nodes:p().map($=>({...$})),edges:v.map($=>({...$})),viewport:{x:E,y:M,zoom:x}}},[]),f=b.useCallback(({nodes:p,edges:v})=>{const{nodeInternals:m,getNodes:E,edges:M,hasDefaultNodes:x,hasDefaultEdges:$,onNodesDelete:C,onEdgesDelete:z,onNodesChange:P,onEdgesChange:T}=e.getState(),L=(p||[]).map(S=>S.id),H=(v||[]).map(S=>S.id),O=E().reduce((S,w)=>{const k=w.parentNode||w.parentId,I=!L.includes(w.id)&&k&&S.find(A=>A.id===k);return(typeof w.deletable=="boolean"?w.deletable:!0)&&(L.includes(w.id)||I)&&S.push(w),S},[]),V=M.filter(S=>typeof S.deletable=="boolean"?S.deletable:!0),h=V.filter(S=>H.includes(S.id));if(O||h){const S=Go(O,V),w=[...h,...S],k=w.reduce((I,_)=>(I.includes(_.id)||I.push(_.id),I),[]);if(($||x)&&($&&e.setState({edges:M.filter(I=>!k.includes(I.id))}),x&&(O.forEach(I=>{m.delete(I.id)}),e.setState({nodeInternals:new Map(m)}))),k.length>0&&(z==null||z(w),T&&T(k.map(I=>({id:I,type:"remove"})))),O.length>0&&(C==null||C(O),P)){const I=O.map(_=>({id:_.id,type:"remove"}));P(I)}}},[]),d=b.useCallback(p=>{const v=au(p),m=v?null:e.getState().nodeInternals.get(p.id);return!v&&!m?[null,null,v]:[v?p:Pr(m),m,v]},[]),g=b.useCallback((p,v=!0,m)=>{const[E,M,x]=d(p);return E?(m||e.getState().getNodes()).filter($=>{if(!x&&($.id===M.id||!$.positionAbsolute))return!1;const C=Pr($),z=Pn(C,E);return v&&z>0||z>=E.width*E.height}):[]},[]),y=b.useCallback((p,v,m=!0)=>{const[E]=d(p);if(!E)return!1;const M=Pn(E,v);return m&&M>0||M>=E.width*E.height},[]);return b.useMemo(()=>({...t,getNodes:n,getNode:r,getEdges:o,getEdge:s,setNodes:i,setEdges:c,addNodes:a,addEdges:u,toObject:l,deleteElements:f,getIntersectingNodes:g,isNodeIntersecting:y}),[t,n,r,o,s,i,c,a,u,l,f,g,y])}const Yu={actInsideInputWithModifier:!1};var Xu=({deleteKeyCode:t,multiSelectionKeyCode:e})=>{const n=rt(),{deleteElements:r}=sr(),o=Te(t,Yu),s=Te(e);b.useEffect(()=>{if(o){const{edges:i,getNodes:c}=n.getState(),a=c().filter(l=>l.selected),u=i.filter(l=>l.selected);r({nodes:a,edges:u}),n.setState({nodesSelectionActive:!1})}},[o]),b.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])};function Wu(t){const e=rt();b.useEffect(()=>{let n;const r=()=>{var s,i;if(!t.current)return;const o=Jn(t.current);(o.height===0||o.width===0)&&((i=(s=e.getState()).onError)==null||i.call(s,"004",Tt.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 cr={position:"absolute",width:"100%",height:"100%",top:0,left:0},Uu=(t,e)=>t.x!==e.x||t.y!==e.y||t.zoom!==e.k,Ye=t=>({x:t.x,y:t.y,zoom:t.k}),re=(t,e)=>t.target.closest(`.${e}`),qr=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),Zr=t=>{const e=t.ctrlKey&&tn()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},qu=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),Zu=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:o=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:c=.5,panOnScrollMode:a=Wt.Free,zoomOnDoubleClick:u=!0,elementsSelectable:l,panOnDrag:f=!0,defaultViewport:d,translateExtent:g,minZoom:y,maxZoom:p,zoomActivationKeyCode:v,preventScrolling:m=!0,children:E,noWheelClassName:M,noPanClassName:x})=>{const $=b.useRef(),C=rt(),z=b.useRef(!1),P=b.useRef(!1),T=b.useRef(null),L=b.useRef({x:0,y:0,zoom:0}),{d3Zoom:H,d3Selection:O,d3ZoomHandler:V,userSelectionActive:h}=j(qu,ft),S=Te(v),w=b.useRef(0),k=b.useRef(!1),I=b.useRef();return Wu(T),b.useEffect(()=>{if(T.current){const _=T.current.getBoundingClientRect(),A=Do().scaleExtent([y,p]).translateExtent(g),R=gt(T.current).call(A),D=At.translate(d.x,d.y).scale(fe(d.zoom,y,p)),B=[[0,0],[_.width,_.height]],F=A.constrain()(D,B,g);A.transform(R,F),A.wheelDelta(Zr),C.setState({d3Zoom:A,d3Selection:R,d3ZoomHandler:R.on("wheel.zoom"),transform:[F.x,F.y,F.k],domNode:T.current.closest(".react-flow")})}},[]),b.useEffect(()=>{O&&H&&(i&&!S&&!h?O.on("wheel.zoom",_=>{if(re(_,M))return!1;_.preventDefault(),_.stopImmediatePropagation();const A=O.property("__zoom").k||1;if(_.ctrlKey&&s){const Q=yt(_),K=Zr(_),G=A*Math.pow(2,K);H.scaleTo(O,G,Q,_);return}const R=_.deltaMode===1?20:1;let D=a===Wt.Vertical?0:_.deltaX*R,B=a===Wt.Horizontal?0:_.deltaY*R;!tn()&&_.shiftKey&&a!==Wt.Vertical&&(D=_.deltaY*R,B=0),H.translateBy(O,-(D/A)*c,-(B/A)*c,{internal:!0});const F=Ye(O.property("__zoom")),{onViewportChangeStart:W,onViewportChange:U,onViewportChangeEnd:Z}=C.getState();clearTimeout(I.current),k.current||(k.current=!0,e==null||e(_,F),W==null||W(F)),k.current&&(t==null||t(_,F),U==null||U(F),I.current=setTimeout(()=>{n==null||n(_,F),Z==null||Z(F),k.current=!1},150))},{passive:!1}):typeof V<"u"&&O.on("wheel.zoom",function(_,A){if(!m&&_.type==="wheel"&&!_.ctrlKey||re(_,M))return null;_.preventDefault(),V.call(this,_,A)},{passive:!1}))},[h,i,a,O,H,V,S,s,m,M,e,t,n]),b.useEffect(()=>{H&&H.on("start",_=>{var D,B;if(!_.sourceEvent||_.sourceEvent.internal)return null;w.current=(D=_.sourceEvent)==null?void 0:D.button;const{onViewportChangeStart:A}=C.getState(),R=Ye(_.transform);z.current=!0,L.current=R,((B=_.sourceEvent)==null?void 0:B.type)==="mousedown"&&C.setState({paneDragging:!0}),A==null||A(R),e==null||e(_.sourceEvent,R)})},[H,e]),b.useEffect(()=>{H&&(h&&!z.current?H.on("zoom",null):h||H.on("zoom",_=>{var R;const{onViewportChange:A}=C.getState();if(C.setState({transform:[_.transform.x,_.transform.y,_.transform.k]}),P.current=!!(r&&qr(f,w.current??0)),(t||A)&&!((R=_.sourceEvent)!=null&&R.internal)){const D=Ye(_.transform);A==null||A(D),t==null||t(_.sourceEvent,D)}}))},[h,H,t,f,r]),b.useEffect(()=>{H&&H.on("end",_=>{if(!_.sourceEvent||_.sourceEvent.internal)return null;const{onViewportChangeEnd:A}=C.getState();if(z.current=!1,C.setState({paneDragging:!1}),r&&qr(f,w.current??0)&&!P.current&&r(_.sourceEvent),P.current=!1,(n||A)&&Uu(L.current,_.transform)){const R=Ye(_.transform);L.current=R,clearTimeout($.current),$.current=setTimeout(()=>{A==null||A(R),n==null||n(_.sourceEvent,R)},i?150:0)}})},[H,i,f,n,r]),b.useEffect(()=>{H&&H.filter(_=>{const A=S||o,R=s&&_.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&_.button===1&&_.type==="mousedown"&&(re(_,"react-flow__node")||re(_,"react-flow__edge")))return!0;if(!f&&!A&&!i&&!u&&!s||h||!u&&_.type==="dblclick"||re(_,M)&&_.type==="wheel"||re(_,x)&&(_.type!=="wheel"||i&&_.type==="wheel"&&!S)||!s&&_.ctrlKey&&_.type==="wheel"||!A&&!i&&!R&&_.type==="wheel"||!f&&(_.type==="mousedown"||_.type==="touchstart")||Array.isArray(f)&&!f.includes(_.button)&&_.type==="mousedown")return!1;const D=Array.isArray(f)&&f.includes(_.button)||!_.button||_.button<=1;return(!_.ctrlKey||_.type==="wheel")&&D})},[h,H,o,s,i,u,f,l,S]),N.createElement("div",{className:"react-flow__renderer",ref:T,style:cr},E)},Gu=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function Ku(){const{userSelectionActive:t,userSelectionRect:e}=j(Gu,ft);return t&&e?N.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 Gr(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 di(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&&Gr(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&&Gr(r,i);break}case"remove":return r}return r.push(i),r},n)}function hi(t,e){return di(t,e)}function Qu(t,e){return di(t,e)}const Rt=(t,e)=>({id:t,type:"select",selected:e});function ie(t,e){return t.reduce((n,r)=>{const o=e.includes(r.id);return!r.selected&&o?(r.selected=!0,n.push(Rt(r.id,!0))):r.selected&&!o&&(r.selected=!1,n.push(Rt(r.id,!1))),n},[])}const Nn=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},Ju=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),gi=b.memo(({isSelecting:t,selectionMode:e=ke.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:o,onPaneClick:s,onPaneContextMenu:i,onPaneScroll:c,onPaneMouseEnter:a,onPaneMouseMove:u,onPaneMouseLeave:l,children:f})=>{const d=b.useRef(null),g=rt(),y=b.useRef(0),p=b.useRef(0),v=b.useRef(),{userSelectionActive:m,elementsSelectable:E,dragging:M}=j(Ju,ft),x=()=>{g.setState({userSelectionActive:!1,userSelectionRect:null}),y.current=0,p.current=0},$=V=>{s==null||s(V),g.getState().resetSelectedElements(),g.setState({nodesSelectionActive:!1})},C=V=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){V.preventDefault();return}i==null||i(V)},z=c?V=>c(V):void 0,P=V=>{const{resetSelectedElements:h,domNode:S}=g.getState();if(v.current=S==null?void 0:S.getBoundingClientRect(),!E||!t||V.button!==0||V.target!==d.current||!v.current)return;const{x:w,y:k}=Ht(V,v.current);h(),g.setState({userSelectionRect:{width:0,height:0,startX:w,startY:k,x:w,y:k}}),r==null||r(V)},T=V=>{const{userSelectionRect:h,nodeInternals:S,edges:w,transform:k,onNodesChange:I,onEdgesChange:_,nodeOrigin:A,getNodes:R}=g.getState();if(!t||!v.current||!h)return;g.setState({userSelectionActive:!0,nodesSelectionActive:!1});const D=Ht(V,v.current),B=h.startX??0,F=h.startY??0,W={...h,x:D.x<B?D.x:B,y:D.y<F?D.y:F,width:Math.abs(D.x-B),height:Math.abs(D.y-F)},U=R(),Z=Zo(S,W,k,e===ke.Partial,!0,A),Q=Go(Z,w).map(G=>G.id),K=Z.map(G=>G.id);if(y.current!==K.length){y.current=K.length;const G=ie(U,K);G.length&&(I==null||I(G))}if(p.current!==Q.length){p.current=Q.length;const G=ie(w,Q);G.length&&(_==null||_(G))}g.setState({userSelectionRect:W})},L=V=>{if(V.button!==0)return;const{userSelectionRect:h}=g.getState();!m&&h&&V.target===d.current&&($==null||$(V)),g.setState({nodesSelectionActive:y.current>0}),x(),o==null||o(V)},H=V=>{m&&(g.setState({nodesSelectionActive:y.current>0}),o==null||o(V)),x()},O=E&&(t||m);return N.createElement("div",{className:it(["react-flow__pane",{dragging:M,selection:t}]),onClick:O?void 0:Nn($,d),onContextMenu:Nn(C,d),onWheel:Nn(z,d),onMouseEnter:O?void 0:a,onMouseDown:O?P:void 0,onMouseMove:O?T:u,onMouseUp:O?L:void 0,onMouseLeave:O?H:l,ref:d,style:cr},f,N.createElement(Ku,null))});gi.displayName="Pane";function pi(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const r=e.get(n);return r?r.selected?!0:pi(r,e):!1}function Kr(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 ju(t,e,n,r){return Array.from(t.values()).filter(o=>(o.selected||o.id===r)&&(!o.parentNode||o.parentId||!pi(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 tf(t,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(t.width||0),e[1][1]-(t.height||0)]]}function mi(t,e,n,r,o=[0,0],s){const i=tf(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:d,y:g}=qt(f,o).positionAbsolute;c=f&&pt(d)&&pt(g)&&pt(f.width)&&pt(f.height)?[[d+t.width*o[0],g+t.height*o[1]],[d+f.width-t.width+t.width*o[0],g+f.height-t.height+t.height*o[1]]]:c}else s==null||s("005",Tt.error005()),c=i;else if(t.extent&&a&&t.extent!=="parent"){const f=n.get(a),{x:d,y:g}=qt(f,o).positionAbsolute;c=[[t.extent[0][0]+d,t.extent[0][1]+g],[t.extent[1][0]+d,t.extent[1][1]+g]]}let u={x:0,y:0};if(a){const f=n.get(a);u=qt(f,o).positionAbsolute}const l=c&&c!=="parent"?jn(e,c):e;return{position:{x:l.x-u.x,y:l.y-u.y},positionAbsolute:l}}function Mn({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 Qr=(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 u=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),position:a.getAttribute("data-handlepos"),x:(u.left-i.left-c.x)/n,y:(u.top-i.top-c.y)/n,...Jn(a)}})};function we(t,e,n){return n===void 0?n:r=>{const o=e().nodeInternals.get(t);o&&n(r,{...o})}}function Yn({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeInternals:c,onError:a}=e.getState(),u=c.get(t);if(!u){a==null||a("012",Tt.error012(t));return}e.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&i)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var l;return(l=r==null?void 0:r.current)==null?void 0:l.blur()})):o([t])}function ef(){const t=rt();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 $n(t){return(e,n,r)=>t==null?void 0:t(e,r)}function yi({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:s,selectNodesOnDrag:i}){const c=rt(),[a,u]=b.useState(!1),l=b.useRef([]),f=b.useRef({x:null,y:null}),d=b.useRef(0),g=b.useRef(null),y=b.useRef({x:0,y:0}),p=b.useRef(null),v=b.useRef(!1),m=b.useRef(!1),E=b.useRef(!1),M=ef();return b.useEffect(()=>{if(t!=null&&t.current){const x=gt(t.current),$=({x:P,y:T})=>{const{nodeInternals:L,onNodeDrag:H,onSelectionDrag:O,updateNodePositions:V,nodeExtent:h,snapGrid:S,snapToGrid:w,nodeOrigin:k,onError:I}=c.getState();f.current={x:P,y:T};let _=!1,A={x:0,y:0,x2:0,y2:0};if(l.current.length>1&&h){const D=fn(l.current,k);A=Ae(D)}if(l.current=l.current.map(D=>{const B={x:P-D.distance.x,y:T-D.distance.y};w&&(B.x=S[0]*Math.round(B.x/S[0]),B.y=S[1]*Math.round(B.y/S[1]));const F=[[h[0][0],h[0][1]],[h[1][0],h[1][1]]];l.current.length>1&&h&&!D.extent&&(F[0][0]=D.positionAbsolute.x-A.x+h[0][0],F[1][0]=D.positionAbsolute.x+(D.width??0)-A.x2+h[1][0],F[0][1]=D.positionAbsolute.y-A.y+h[0][1],F[1][1]=D.positionAbsolute.y+(D.height??0)-A.y2+h[1][1]);const W=mi(D,B,L,F,k,I);return _=_||D.position.x!==W.position.x||D.position.y!==W.position.y,D.position=W.position,D.positionAbsolute=W.positionAbsolute,D}),!_)return;V(l.current,!0,!0),u(!0);const R=o?H:$n(O);if(R&&p.current){const[D,B]=Mn({nodeId:o,dragItems:l.current,nodeInternals:L});R(p.current,D,B)}},C=()=>{if(!g.current)return;const[P,T]=Po(y.current,g.current);if(P!==0||T!==0){const{transform:L,panBy:H}=c.getState();f.current.x=(f.current.x??0)-P/L[2],f.current.y=(f.current.y??0)-T/L[2],H({x:P,y:T})&&$(f.current)}d.current=requestAnimationFrame(C)},z=P=>{var k;const{nodeInternals:T,multiSelectionActive:L,nodesDraggable:H,unselectNodesAndEdges:O,onNodeDragStart:V,onSelectionDragStart:h}=c.getState();m.current=!0;const S=o?V:$n(h);(!i||!s)&&!L&&o&&((k=T.get(o))!=null&&k.selected||O()),o&&s&&i&&Yn({id:o,store:c,nodeRef:t});const w=M(P);if(f.current=w,l.current=ju(T,H,w,o),S&&l.current){const[I,_]=Mn({nodeId:o,dragItems:l.current,nodeInternals:T});S(P.sourceEvent,I,_)}};if(e)x.on(".drag",null);else{const P=da().on("start",T=>{const{domNode:L,nodeDragThreshold:H}=c.getState();H===0&&z(T),E.current=!1;const O=M(T);f.current=O,g.current=(L==null?void 0:L.getBoundingClientRect())||null,y.current=Ht(T.sourceEvent,g.current)}).on("drag",T=>{var V,h;const L=M(T),{autoPanOnNodeDrag:H,nodeDragThreshold:O}=c.getState();if(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1&&(E.current=!0),!E.current){if(!v.current&&m.current&&H&&(v.current=!0,C()),!m.current){const S=L.xSnapped-(((V=f==null?void 0:f.current)==null?void 0:V.x)??0),w=L.ySnapped-(((h=f==null?void 0:f.current)==null?void 0:h.y)??0);Math.sqrt(S*S+w*w)>O&&z(T)}(f.current.x!==L.xSnapped||f.current.y!==L.ySnapped)&&l.current&&m.current&&(p.current=T.sourceEvent,y.current=Ht(T.sourceEvent,g.current),$(L))}}).on("end",T=>{if(!(!m.current||E.current)&&(u(!1),v.current=!1,m.current=!1,cancelAnimationFrame(d.current),l.current)){const{updateNodePositions:L,nodeInternals:H,onNodeDragStop:O,onSelectionDragStop:V}=c.getState(),h=o?O:$n(V);if(L(l.current,!1,!1),h){const[S,w]=Mn({nodeId:o,dragItems:l.current,nodeInternals:H});h(T.sourceEvent,S,w)}}}).filter(T=>{const L=T.target;return!T.button&&(!n||!Kr(L,`.${n}`,t))&&(!r||Kr(L,r,t))});return x.call(P),()=>{x.on(".drag",null)}}}},[t,e,n,r,s,c,o,i,M]),a}function xi(){const t=rt();return b.useCallback(n=>{const{nodeInternals:r,nodeExtent:o,updateNodePositions:s,getNodes:i,snapToGrid:c,snapGrid:a,onError:u,nodesDraggable:l}=t.getState(),f=i().filter(E=>E.selected&&(E.draggable||l&&typeof E.draggable>"u")),d=c?a[0]:5,g=c?a[1]:5,y=n.isShiftPressed?4:1,p=n.x*d*y,v=n.y*g*y,m=f.map(E=>{if(E.positionAbsolute){const M={x:E.positionAbsolute.x+p,y:E.positionAbsolute.y+v};c&&(M.x=a[0]*Math.round(M.x/a[0]),M.y=a[1]*Math.round(M.y/a[1]));const{positionAbsolute:x,position:$}=mi(E,M,r,o,void 0,u);E.position=$,E.positionAbsolute=x}return E});s(m,!0,!1)},[])}const ae={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var ve=t=>{const e=({id:n,type:r,data:o,xPos:s,yPos:i,xPosOrigin:c,yPosOrigin:a,selected:u,onClick:l,onMouseEnter:f,onMouseMove:d,onMouseLeave:g,onContextMenu:y,onDoubleClick:p,style:v,className:m,isDraggable:E,isSelectable:M,isConnectable:x,isFocusable:$,selectNodesOnDrag:C,sourcePosition:z,targetPosition:P,hidden:T,resizeObserver:L,dragHandle:H,zIndex:O,isParent:V,noDragClassName:h,noPanClassName:S,initialized:w,disableKeyboardA11y:k,ariaLabel:I,rfId:_,hasHandleBounds:A})=>{const R=rt(),D=b.useRef(null),B=b.useRef(null),F=b.useRef(z),W=b.useRef(P),U=b.useRef(r),Z=M||E||l||f||d||g,Q=xi(),K=we(n,R.getState,f),G=we(n,R.getState,d),ot=we(n,R.getState,g),nt=we(n,R.getState,y),at=we(n,R.getState,p),st=J=>{const{nodeDragThreshold:Y}=R.getState();if(M&&(!C||!E||Y>0)&&Yn({id:n,store:R,nodeRef:D}),l){const lt=R.getState().nodeInternals.get(n);lt&&l(J,{...lt})}},et=J=>{if(!Vn(J)&&!k)if(Fo.includes(J.key)&&M){const Y=J.key==="Escape";Yn({id:n,store:R,unselect:Y,nodeRef:D})}else E&&u&&Object.prototype.hasOwnProperty.call(ae,J.key)&&(R.setState({ariaLiveMessage:`Moved selected node ${J.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~i}`}),Q({x:ae[J.key].x,y:ae[J.key].y,isShiftPressed:J.shiftKey}))};b.useEffect(()=>()=>{B.current&&(L==null||L.unobserve(B.current),B.current=null)},[]),b.useEffect(()=>{if(D.current&&!T){const J=D.current;(!w||!A||B.current!==J)&&(B.current&&(L==null||L.unobserve(B.current)),L==null||L.observe(J),B.current=J)}},[T,w,A]),b.useEffect(()=>{const J=U.current!==r,Y=F.current!==z,lt=W.current!==P;D.current&&(J||Y||lt)&&(J&&(U.current=r),Y&&(F.current=z),lt&&(W.current=P),R.getState().updateNodeDimensions([{id:n,nodeElement:D.current,forceUpdate:!0}]))},[n,r,z,P]);const dt=yi({nodeRef:D,disabled:T||!E,noDragClassName:h,handleSelector:H,nodeId:n,isSelectable:M,selectNodesOnDrag:C});return T?null:N.createElement("div",{className:it(["react-flow__node",`react-flow__node-${r}`,{[S]:E},m,{selected:u,selectable:M,parent:V,dragging:dt}]),ref:D,style:{zIndex:O,transform:`translate(${c}px,${a}px)`,pointerEvents:Z?"all":"none",visibility:w?"visible":"hidden",...v},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:K,onMouseMove:G,onMouseLeave:ot,onContextMenu:nt,onClick:st,onDoubleClick:at,onKeyDown:$?et:void 0,tabIndex:$?0:void 0,role:$?"button":void 0,"aria-describedby":k?void 0:`${ci}-${_}`,"aria-label":I},N.createElement(pu,{value:n},N.createElement(t,{id:n,data:o,type:r,xPos:s,yPos:i,selected:u,isConnectable:x,sourcePosition:z,targetPosition:P,dragging:dt,dragHandle:H,zIndex:O})))};return e.displayName="NodeWrapper",b.memo(e)};const nf=t=>{const e=t.getNodes().filter(n=>n.selected);return{...fn(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};function rf({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=rt(),{width:o,height:s,x:i,y:c,transformString:a,userSelectionActive:u}=j(nf,ft),l=xi(),f=b.useRef(null);if(b.useEffect(()=>{var y;n||(y=f.current)==null||y.focus({preventScroll:!0})},[n]),yi({nodeRef:f}),u||!o||!s)return null;const d=t?y=>{const p=r.getState().getNodes().filter(v=>v.selected);t(y,p)}:void 0,g=y=>{Object.prototype.hasOwnProperty.call(ae,y.key)&&l({x:ae[y.key].x,y:ae[y.key].y,isShiftPressed:y.shiftKey})};return N.createElement("div",{className:it(["react-flow__nodesselection","react-flow__container",e]),style:{transform:a}},N.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:o,height:s,top:c,left:i}}))}var of=b.memo(rf);const sf=t=>t.nodesSelectionActive,wi=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,deleteKeyCode:c,onMove:a,onMoveStart:u,onMoveEnd:l,selectionKeyCode:f,selectionOnDrag:d,selectionMode:g,onSelectionStart:y,onSelectionEnd:p,multiSelectionKeyCode:v,panActivationKeyCode:m,zoomActivationKeyCode:E,elementsSelectable:M,zoomOnScroll:x,zoomOnPinch:$,panOnScroll:C,panOnScrollSpeed:z,panOnScrollMode:P,zoomOnDoubleClick:T,panOnDrag:L,defaultViewport:H,translateExtent:O,minZoom:V,maxZoom:h,preventScrolling:S,onSelectionContextMenu:w,noWheelClassName:k,noPanClassName:I,disableKeyboardA11y:_})=>{const A=j(sf),R=Te(f),D=Te(m),B=D||L,F=D||C,W=R||d&&B!==!0;return Xu({deleteKeyCode:c,multiSelectionKeyCode:v}),N.createElement(Zu,{onMove:a,onMoveStart:u,onMoveEnd:l,onPaneContextMenu:s,elementsSelectable:M,zoomOnScroll:x,zoomOnPinch:$,panOnScroll:F,panOnScrollSpeed:z,panOnScrollMode:P,zoomOnDoubleClick:T,panOnDrag:!R&&B,defaultViewport:H,translateExtent:O,minZoom:V,maxZoom:h,zoomActivationKeyCode:E,preventScrolling:S,noWheelClassName:k,noPanClassName:I},N.createElement(gi,{onSelectionStart:y,onSelectionEnd:p,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:B,isSelecting:!!W,selectionMode:g},t,A&&N.createElement(of,{onSelectionContextMenu:w,noPanClassName:I,disableKeyboardA11y:_})))};wi.displayName="FlowRenderer";var cf=b.memo(wi);function af(t){return j(b.useCallback(n=>t?Zo(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[t]))}function lf(t){const e={input:ve(t.input||ri),default:ve(t.default||Bn),output:ve(t.output||ii),group:ve(t.group||ir)},n={},r=Object.keys(t).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,s)=>(o[s]=ve(t[s]||Bn),o),n);return{...e,...r}}const uf=({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]},ff=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),vi=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,updateNodeDimensions:s,onError:i}=j(ff,ft),c=af(t.onlyRenderVisibleElements),a=b.useRef(),u=b.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const l=new ResizeObserver(f=>{const d=f.map(g=>({id:g.target.getAttribute("data-id"),nodeElement:g.target,forceUpdate:!0}));s(d)});return a.current=l,l},[]);return b.useEffect(()=>()=>{var l;(l=a==null?void 0:a.current)==null||l.disconnect()},[]),N.createElement("div",{className:"react-flow__nodes",style:cr},c.map(l=>{var $,C,z;let f=l.type||"default";t.nodeTypes[f]||(i==null||i("003",Tt.error003(f)),f="default");const d=t.nodeTypes[f]||t.nodeTypes.default,g=!!(l.draggable||e&&typeof l.draggable>"u"),y=!!(l.selectable||o&&typeof l.selectable>"u"),p=!!(l.connectable||n&&typeof l.connectable>"u"),v=!!(l.focusable||r&&typeof l.focusable>"u"),m=t.nodeExtent?jn(l.positionAbsolute,t.nodeExtent):l.positionAbsolute,E=(m==null?void 0:m.x)??0,M=(m==null?void 0:m.y)??0,x=uf({x:E,y:M,width:l.width??0,height:l.height??0,origin:t.nodeOrigin});return N.createElement(d,{key:l.id,id:l.id,className:l.className,style:l.style,type:f,data:l.data,sourcePosition:l.sourcePosition||X.Bottom,targetPosition:l.targetPosition||X.Top,hidden:l.hidden,xPos:E,yPos:M,xPosOrigin:x.x,yPosOrigin:x.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!l.selected,isDraggable:g,isSelectable:y,isConnectable:p,isFocusable:v,resizeObserver:u,dragHandle:l.dragHandle,zIndex:(($=l[tt])==null?void 0:$.z)??0,isParent:!!((C=l[tt])!=null&&C.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!l.width&&!!l.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:l.ariaLabel,hasHandleBounds:!!((z=l[tt])!=null&&z.handleBounds)})}))};vi.displayName="NodeRenderer";var df=b.memo(vi);const hf=(t,e,n)=>n===X.Left?t-e:n===X.Right?t+e:t,gf=(t,e,n)=>n===X.Top?t-e:n===X.Bottom?t+e:t,Jr="react-flow__edgeupdater",jr=({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:c})=>N.createElement("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:it([Jr,`${Jr}-${c}`]),cx:hf(e,r,t),cy:gf(n,r,t),r,stroke:"transparent",fill:"transparent"}),pf=()=>!0;var oe=t=>{const e=({id:n,className:r,type:o,data:s,onClick:i,onEdgeDoubleClick:c,selected:a,animated:u,label:l,labelStyle:f,labelShowBg:d,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:p,style:v,source:m,target:E,sourceX:M,sourceY:x,targetX:$,targetY:C,sourcePosition:z,targetPosition:P,elementsSelectable:T,hidden:L,sourceHandleId:H,targetHandleId:O,onContextMenu:V,onMouseEnter:h,onMouseMove:S,onMouseLeave:w,reconnectRadius:k,onReconnect:I,onReconnectStart:_,onReconnectEnd:A,markerEnd:R,markerStart:D,rfId:B,ariaLabel:F,isFocusable:W,isReconnectable:U,pathOptions:Z,interactionWidth:Q,disableKeyboardA11y:K})=>{const G=b.useRef(null),[ot,nt]=b.useState(!1),[at,st]=b.useState(!1),et=rt(),dt=b.useMemo(()=>`url('#${On(D,B)}')`,[D,B]),J=b.useMemo(()=>`url('#${On(R,B)}')`,[R,B]);if(L)return null;const Y=ct=>{var _t;const{edges:mt,addSelectedEdges:Lt,unselectNodesAndEdges:Ot,multiSelectionActive:Ft}=et.getState(),Mt=mt.find(ge=>ge.id===n);Mt&&(T&&(et.setState({nodesSelectionActive:!1}),Mt.selected&&Ft?(Ot({nodes:[],edges:[Mt]}),(_t=G.current)==null||_t.blur()):Lt([n])),i&&i(ct,Mt))},lt=xe(n,et.getState,c),bt=xe(n,et.getState,V),de=xe(n,et.getState,h),Kt=xe(n,et.getState,S),Qt=xe(n,et.getState,w),Nt=(ct,mt)=>{if(ct.button!==0)return;const{edges:Lt,isValidConnection:Ot}=et.getState(),Ft=mt?E:m,Mt=(mt?O:H)||null,_t=mt?"target":"source",ge=Ot||pf,dn=mt,pe=Lt.find(Bt=>Bt.id===n);st(!0),_==null||_(ct,pe,_t);const hn=Bt=>{st(!1),A==null||A(Bt,pe,_t)};jo({event:ct,handleId:Mt,nodeId:Ft,onConnect:Bt=>I==null?void 0:I(pe,Bt),isTarget:dn,getState:et.getState,setState:et.setState,isValidConnection:ge,edgeUpdaterType:_t,onReconnectEnd:hn})},Jt=ct=>Nt(ct,!0),Pt=ct=>Nt(ct,!1),Vt=()=>nt(!0),jt=()=>nt(!1),te=!T&&!i,he=ct=>{var mt;if(!K&&Fo.includes(ct.key)&&T){const{unselectNodesAndEdges:Lt,addSelectedEdges:Ot,edges:Ft}=et.getState();ct.key==="Escape"?((mt=G.current)==null||mt.blur(),Lt({edges:[Ft.find(_t=>_t.id===n)]})):Ot([n])}};return N.createElement("g",{className:it(["react-flow__edge",`react-flow__edge-${o}`,r,{selected:a,animated:u,inactive:te,updating:ot}]),onClick:Y,onDoubleClick:lt,onContextMenu:bt,onMouseEnter:de,onMouseMove:Kt,onMouseLeave:Qt,onKeyDown:W?he:void 0,tabIndex:W?0:void 0,role:W?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":F===null?void 0:F||`Edge from ${m} to ${E}`,"aria-describedby":W?`${ai}-${B}`:void 0,ref:G},!at&&N.createElement(t,{id:n,source:m,target:E,selected:a,animated:u,label:l,labelStyle:f,labelShowBg:d,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:p,data:s,style:v,sourceX:M,sourceY:x,targetX:$,targetY:C,sourcePosition:z,targetPosition:P,sourceHandleId:H,targetHandleId:O,markerStart:dt,markerEnd:J,pathOptions:Z,interactionWidth:Q}),U&&N.createElement(N.Fragment,null,(U==="source"||U===!0)&&N.createElement(jr,{position:z,centerX:M,centerY:x,radius:k,onMouseDown:Jt,onMouseEnter:Vt,onMouseOut:jt,type:"source"}),(U==="target"||U===!0)&&N.createElement(jr,{position:P,centerX:$,centerY:C,radius:k,onMouseDown:Pt,onMouseEnter:Vt,onMouseOut:jt,type:"target"})))};return e.displayName="EdgeWrapper",b.memo(e)};function mf(t){const e={default:oe(t.default||nn),straight:oe(t.bezier||nr),step:oe(t.step||er),smoothstep:oe(t.step||un),simplebezier:oe(t.simplebezier||tr)},n={},r=Object.keys(t).filter(o=>!["default","bezier"].includes(o)).reduce((o,s)=>(o[s]=oe(t[s]||nn),o),n);return{...e,...r}}function to(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 eo(t,e){return t?t.length===1||!e?t[0]:e&&t.find(n=>n.id===e)||null:null}const yf=(t,e,n,r,o,s)=>{const i=to(n,t,e),c=to(s,r,o);return{sourceX:i.x,sourceY:i.y,targetX:c.x,targetY:c.y}};function xf({sourcePos:t,targetPos:e,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:s,width:i,height:c,transform:a}){const u={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)};u.x===u.x2&&(u.x2+=1),u.y===u.y2&&(u.y2+=1);const l=Ae({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(l.x2,u.x2)-Math.max(l.x,u.x)),d=Math.max(0,Math.min(l.y2,u.y2)-Math.max(l.y,u.y));return Math.ceil(f*d)>0}function no(t){var r,o,s,i,c;const e=((r=t==null?void 0:t[tt])==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 wf=[{level:0,isMaxLevel:!0,edges:[]}];function vf(t,e,n=!1){let r=-1;const o=t.reduce((i,c)=>{var l,f;const a=pt(c.zIndex);let u=a?c.zIndex:0;if(n){const d=e.get(c.target),g=e.get(c.source),y=c.selected||(d==null?void 0:d.selected)||(g==null?void 0:g.selected),p=Math.max(((l=g==null?void 0:g[tt])==null?void 0:l.z)||0,((f=d==null?void 0:d[tt])==null?void 0:f.z)||0,1e3);u=(a?c.zIndex:0)+(y?p:0)}return i[u]?i[u].push(c):i[u]=[c],r=u>r?u:r,i},{}),s=Object.entries(o).map(([i,c])=>{const a=+i;return{edges:c,level:a,isMaxLevel:a===r}});return s.length===0?wf:s}function _f(t,e,n){const r=j(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)&&xf({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 vf(r,e,n)}const Ef=({color:t="none",strokeWidth:e=1})=>N.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Sf=({color:t="none",strokeWidth:e=1})=>N.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),ro={[en.Arrow]:Ef,[en.ArrowClosed]:Sf};function bf(t){const e=rt();return b.useMemo(()=>{var o,s;return Object.prototype.hasOwnProperty.call(ro,t)?ro[t]:((s=(o=e.getState()).onError)==null||s.call(o,"009",Tt.error009(t)),null)},[t])}const Nf=({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=bf(e);return a?N.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"},N.createElement(a,{color:n,strokeWidth:i})):null},Mf=({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=On(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))},_i=({defaultColor:t,rfId:e})=>{const n=j(b.useCallback(Mf({defaultColor:t,rfId:e}),[t,e]),(r,o)=>!(r.length!==o.length||r.some((s,i)=>s.id!==o[i].id)));return N.createElement("defs",null,n.map(r=>N.createElement(Nf,{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})))};_i.displayName="MarkerDefinitions";var $f=b.memo(_i);const Cf=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}),Ei=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:r,edgeTypes:o,noPanClassName:s,onEdgeContextMenu:i,onEdgeMouseEnter:c,onEdgeMouseMove:a,onEdgeMouseLeave:u,onEdgeClick:l,onEdgeDoubleClick:f,onReconnect:d,onReconnectStart:g,onReconnectEnd:y,reconnectRadius:p,children:v,disableKeyboardA11y:m})=>{const{edgesFocusable:E,edgesUpdatable:M,elementsSelectable:x,width:$,height:C,connectionMode:z,nodeInternals:P,onError:T}=j(Cf,ft),L=_f(e,P,n);return $?N.createElement(N.Fragment,null,L.map(({level:H,edges:O,isMaxLevel:V})=>N.createElement("svg",{key:H,style:{zIndex:H},width:$,height:C,className:"react-flow__edges react-flow__container"},V&&N.createElement($f,{defaultColor:t,rfId:r}),N.createElement("g",null,O.map(h=>{const[S,w,k]=no(P.get(h.source)),[I,_,A]=no(P.get(h.target));if(!k||!A)return null;let R=h.type||"default";o[R]||(T==null||T("011",Tt.error011(R)),R="default");const D=o[R]||o.default,B=z===Gt.Strict?_.target:(_.target??[]).concat(_.source??[]),F=eo(w.source,h.sourceHandle),W=eo(B,h.targetHandle),U=(F==null?void 0:F.position)||X.Bottom,Z=(W==null?void 0:W.position)||X.Top,Q=!!(h.focusable||E&&typeof h.focusable>"u"),K=h.reconnectable||h.updatable,G=typeof d<"u"&&(K||M&&typeof K>"u");if(!F||!W)return T==null||T("008",Tt.error008(F,h)),null;const{sourceX:ot,sourceY:nt,targetX:at,targetY:st}=yf(S,F,U,I,W,Z);return N.createElement(D,{key:h.id,id:h.id,className:it([h.className,s]),type:R,data:h.data,selected:!!h.selected,animated:!!h.animated,hidden:!!h.hidden,label:h.label,labelStyle:h.labelStyle,labelShowBg:h.labelShowBg,labelBgStyle:h.labelBgStyle,labelBgPadding:h.labelBgPadding,labelBgBorderRadius:h.labelBgBorderRadius,style:h.style,source:h.source,target:h.target,sourceHandleId:h.sourceHandle,targetHandleId:h.targetHandle,markerEnd:h.markerEnd,markerStart:h.markerStart,sourceX:ot,sourceY:nt,targetX:at,targetY:st,sourcePosition:U,targetPosition:Z,elementsSelectable:x,onContextMenu:i,onMouseEnter:c,onMouseMove:a,onMouseLeave:u,onClick:l,onEdgeDoubleClick:f,onReconnect:d,onReconnectStart:g,onReconnectEnd:y,reconnectRadius:p,rfId:r,ariaLabel:h.ariaLabel,isFocusable:Q,isReconnectable:G,pathOptions:"pathOptions"in h?h.pathOptions:void 0,interactionWidth:h.interactionWidth,disableKeyboardA11y:m})})))),v):null};Ei.displayName="EdgeRenderer";var Af=b.memo(Ei);const kf=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function Tf({children:t}){const e=j(kf);return N.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}function zf(t){const e=sr(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const If={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top},Si=({nodeId:t,handleType:e,style:n,type:r=Dt.Bezier,CustomComponent:o,connectionStatus:s})=>{var C,z,P;const{fromNode:i,handleId:c,toX:a,toY:u,connectionMode:l}=j(b.useCallback(T=>({fromNode:T.nodeInternals.get(t),handleId:T.connectionHandleId,toX:(T.connectionPosition.x-T.transform[0])/T.transform[2],toY:(T.connectionPosition.y-T.transform[1])/T.transform[2],connectionMode:T.connectionMode}),[t]),ft),f=(C=i==null?void 0:i[tt])==null?void 0:C.handleBounds;let d=f==null?void 0:f[e];if(l===Gt.Loose&&(d=d||(f==null?void 0:f[e==="source"?"target":"source"])),!i||!d)return null;const g=c?d.find(T=>T.id===c):d[0],y=g?g.x+g.width/2:(i.width??0)/2,p=g?g.y+g.height/2:i.height??0,v=(((z=i.positionAbsolute)==null?void 0:z.x)??0)+y,m=(((P=i.positionAbsolute)==null?void 0:P.y)??0)+p,E=g==null?void 0:g.position,M=E?If[E]:null;if(!E||!M)return null;if(o)return N.createElement(o,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:g,fromX:v,fromY:m,toX:a,toY:u,fromPosition:E,toPosition:M,connectionStatus:s});let x="";const $={sourceX:v,sourceY:m,sourcePosition:E,targetX:a,targetY:u,targetPosition:M};return r===Dt.Bezier?[x]=Uo($):r===Dt.Step?[x]=Ln({...$,borderRadius:0}):r===Dt.SmoothStep?[x]=Ln($):r===Dt.SimpleBezier?[x]=Wo($):x=`M${v},${m} ${a},${u}`,N.createElement("path",{d:x,fill:"none",className:"react-flow__connection-path",style:n})};Si.displayName="ConnectionLine";const Rf=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function Df({containerStyle:t,style:e,type:n,component:r}){const{nodeId:o,handleType:s,nodesConnectable:i,width:c,height:a,connectionStatus:u}=j(Rf,ft);return!(o&&s&&c&&i)?null:N.createElement("svg",{style:t,width:c,height:a,className:"react-flow__edges react-flow__connectionline react-flow__container"},N.createElement("g",{className:it(["react-flow__connection",u])},N.createElement(Si,{nodeId:o,handleType:s,style:e,type:n,CustomComponent:r,connectionStatus:u})))}function oo(t,e){return b.useRef(null),rt(),b.useMemo(()=>e(t),[t])}const bi=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:r,onMoveEnd:o,onInit:s,onNodeClick:i,onEdgeClick:c,onNodeDoubleClick:a,onEdgeDoubleClick:u,onNodeMouseEnter:l,onNodeMouseMove:f,onNodeMouseLeave:d,onNodeContextMenu:g,onSelectionContextMenu:y,onSelectionStart:p,onSelectionEnd:v,connectionLineType:m,connectionLineStyle:E,connectionLineComponent:M,connectionLineContainerStyle:x,selectionKeyCode:$,selectionOnDrag:C,selectionMode:z,multiSelectionKeyCode:P,panActivationKeyCode:T,zoomActivationKeyCode:L,deleteKeyCode:H,onlyRenderVisibleElements:O,elementsSelectable:V,selectNodesOnDrag:h,defaultViewport:S,translateExtent:w,minZoom:k,maxZoom:I,preventScrolling:_,defaultMarkerColor:A,zoomOnScroll:R,zoomOnPinch:D,panOnScroll:B,panOnScrollSpeed:F,panOnScrollMode:W,zoomOnDoubleClick:U,panOnDrag:Z,onPaneClick:Q,onPaneMouseEnter:K,onPaneMouseMove:G,onPaneMouseLeave:ot,onPaneScroll:nt,onPaneContextMenu:at,onEdgeContextMenu:st,onEdgeMouseEnter:et,onEdgeMouseMove:dt,onEdgeMouseLeave:J,onReconnect:Y,onReconnectStart:lt,onReconnectEnd:bt,reconnectRadius:de,noDragClassName:Kt,noWheelClassName:Qt,noPanClassName:Nt,elevateEdgesOnSelect:Jt,disableKeyboardA11y:Pt,nodeOrigin:Vt,nodeExtent:jt,rfId:te})=>{const he=oo(t,lf),ct=oo(e,mf);return zf(s),N.createElement(cf,{onPaneClick:Q,onPaneMouseEnter:K,onPaneMouseMove:G,onPaneMouseLeave:ot,onPaneContextMenu:at,onPaneScroll:nt,deleteKeyCode:H,selectionKeyCode:$,selectionOnDrag:C,selectionMode:z,onSelectionStart:p,onSelectionEnd:v,multiSelectionKeyCode:P,panActivationKeyCode:T,zoomActivationKeyCode:L,elementsSelectable:V,onMove:n,onMoveStart:r,onMoveEnd:o,zoomOnScroll:R,zoomOnPinch:D,zoomOnDoubleClick:U,panOnScroll:B,panOnScrollSpeed:F,panOnScrollMode:W,panOnDrag:Z,defaultViewport:S,translateExtent:w,minZoom:k,maxZoom:I,onSelectionContextMenu:y,preventScrolling:_,noDragClassName:Kt,noWheelClassName:Qt,noPanClassName:Nt,disableKeyboardA11y:Pt},N.createElement(Tf,null,N.createElement(Af,{edgeTypes:ct,onEdgeClick:c,onEdgeDoubleClick:u,onlyRenderVisibleElements:O,onEdgeContextMenu:st,onEdgeMouseEnter:et,onEdgeMouseMove:dt,onEdgeMouseLeave:J,onReconnect:Y,onReconnectStart:lt,onReconnectEnd:bt,reconnectRadius:de,defaultMarkerColor:A,noPanClassName:Nt,elevateEdgesOnSelect:!!Jt,disableKeyboardA11y:Pt,rfId:te},N.createElement(Df,{style:E,type:m,component:M,containerStyle:x})),N.createElement("div",{className:"react-flow__edgelabel-renderer"}),N.createElement(df,{nodeTypes:he,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:f,onNodeMouseLeave:d,onNodeContextMenu:g,selectNodesOnDrag:h,onlyRenderVisibleElements:O,noPanClassName:Nt,noDragClassName:Kt,disableKeyboardA11y:Pt,nodeOrigin:Vt,nodeExtent:jt,rfId:te})))};bi.displayName="GraphView";var Hf=b.memo(bi);const Xn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],zt={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:Xn,nodeExtent:Xn,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Gt.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:lu,isValidConnection:void 0},Pf=()=>bs((t,e)=>({...zt,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:s}=e();t({nodeInternals:bn(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?bn(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:u}=e(),l=a==null?void 0:a.querySelector(".react-flow__viewport");if(!l)return;const f=window.getComputedStyle(l),{m22:d}=new window.DOMMatrixReadOnly(f.transform),g=n.reduce((p,v)=>{const m=o.get(v.id);if(m!=null&&m.hidden)o.set(m.id,{...m,[tt]:{...m[tt],handleBounds:void 0}});else if(m){const E=Jn(v.nodeElement);!!(E.width&&E.height&&(m.width!==E.width||m.height!==E.height||v.forceUpdate))&&(o.set(m.id,{...m,[tt]:{...m[tt],handleBounds:{source:Qr(".source",v.nodeElement,d,u),target:Qr(".target",v.nodeElement,d,u)}},...E}),p.push({id:m.id,type:"dimensions",dimensions:E}))}return p},[]);ui(o,u);const y=i||s&&!i&&fi(e,{initial:!0,...c});t({nodeInternals:new Map(o),fitViewOnInitDone:y}),(g==null?void 0:g.length)>0&&(r==null||r(g))},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 u=hi(n,c()),l=bn(u,o,i,a);t({nodeInternals:l})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=e();let i,c=null;r?i=n.map(a=>Rt(a,!0)):(i=ie(s(),n),c=ie(o,[])),Be({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=>Rt(a,!0)):(i=ie(o,n),c=ie(s(),[])),Be({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(l=>(l.selected=!1,Rt(l.id,!1))),u=c.map(l=>Rt(l.id,!1));Be({changedNodes:a,changedEdges:u,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=>Rt(c.id,!1)),i=n.filter(c=>c.selected).map(c=>Rt(c.id,!1));Be({changedNodes:s,changedEdges:i,get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:r}=e();r.forEach(o=>{o.positionAbsolute=jn(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 u=At.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),l=[[0,0],[o,s]],f=i==null?void 0:i.constrain()(u,l,a);return i.transform(c,f),r[0]!==f.x||r[1]!==f.y||r[2]!==f.k},cancelConnection:()=>t({connectionNodeId:zt.connectionNodeId,connectionHandleId:zt.connectionHandleId,connectionHandleType:zt.connectionHandleType,connectionStatus:zt.connectionStatus,connectionStartHandle:zt.connectionStartHandle,connectionEndHandle:zt.connectionEndHandle}),reset:()=>t({...zt})}),Object.is),Ni=({children:t})=>{const e=b.useRef(null);return e.current||(e.current=Pf()),N.createElement(nu,{value:e.current},t)};Ni.displayName="ReactFlowProvider";const Mi=({children:t})=>b.useContext(ln)?N.createElement(N.Fragment,null,t):N.createElement(Ni,null,t);Mi.displayName="ReactFlowWrapper";const Vf={input:ri,default:Bn,output:ii,group:ir},Lf={default:nn,straight:nr,step:er,smoothstep:un,simplebezier:tr},Of=[0,0],Ff=[15,15],Bf={x:0,y:0,zoom:1},Yf={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Xf=b.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s=Vf,edgeTypes:i=Lf,onNodeClick:c,onEdgeClick:a,onInit:u,onMove:l,onMoveStart:f,onMoveEnd:d,onConnect:g,onConnectStart:y,onConnectEnd:p,onClickConnectStart:v,onClickConnectEnd:m,onNodeMouseEnter:E,onNodeMouseMove:M,onNodeMouseLeave:x,onNodeContextMenu:$,onNodeDoubleClick:C,onNodeDragStart:z,onNodeDrag:P,onNodeDragStop:T,onNodesDelete:L,onEdgesDelete:H,onSelectionChange:O,onSelectionDragStart:V,onSelectionDrag:h,onSelectionDragStop:S,onSelectionContextMenu:w,onSelectionStart:k,onSelectionEnd:I,connectionMode:_=Gt.Strict,connectionLineType:A=Dt.Bezier,connectionLineStyle:R,connectionLineComponent:D,connectionLineContainerStyle:B,deleteKeyCode:F="Backspace",selectionKeyCode:W="Shift",selectionOnDrag:U=!1,selectionMode:Z=ke.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:K=tn()?"Meta":"Control",zoomActivationKeyCode:G=tn()?"Meta":"Control",snapToGrid:ot=!1,snapGrid:nt=Ff,onlyRenderVisibleElements:at=!1,selectNodesOnDrag:st=!0,nodesDraggable:et,nodesConnectable:dt,nodesFocusable:J,nodeOrigin:Y=Of,edgesFocusable:lt,edgesUpdatable:bt,elementsSelectable:de,defaultViewport:Kt=Bf,minZoom:Qt=.5,maxZoom:Nt=2,translateExtent:Jt=Xn,preventScrolling:Pt=!0,nodeExtent:Vt,defaultMarkerColor:jt="#b1b1b7",zoomOnScroll:te=!0,zoomOnPinch:he=!0,panOnScroll:ct=!1,panOnScrollSpeed:mt=.5,panOnScrollMode:Lt=Wt.Free,zoomOnDoubleClick:Ot=!0,panOnDrag:Ft=!0,onPaneClick:Mt,onPaneMouseEnter:_t,onPaneMouseMove:ge,onPaneMouseLeave:dn,onPaneScroll:pe,onPaneContextMenu:hn,children:ar,onEdgeContextMenu:Bt,onEdgeDoubleClick:Ii,onEdgeMouseEnter:Ri,onEdgeMouseMove:Di,onEdgeMouseLeave:Hi,onEdgeUpdate:Pi,onEdgeUpdateStart:Vi,onEdgeUpdateEnd:Li,onReconnect:Oi,onReconnectStart:Fi,onReconnectEnd:Bi,reconnectRadius:Yi=10,edgeUpdaterRadius:Xi=10,onNodesChange:Wi,onEdgesChange:Ui,noDragClassName:qi="nodrag",noWheelClassName:Zi="nowheel",noPanClassName:lr="nopan",fitView:Gi=!1,fitViewOptions:Ki,connectOnClick:Qi=!0,attributionPosition:Ji,proOptions:ji,defaultEdgeOptions:ts,elevateNodesOnSelect:es=!0,elevateEdgesOnSelect:ns=!1,disableKeyboardA11y:ur=!1,autoPanOnConnect:rs=!0,autoPanOnNodeDrag:os=!0,connectionRadius:is=20,isValidConnection:ss,onError:cs,style:as,id:fr,nodeDragThreshold:ls,...us},fs)=>{const gn=fr||"1";return N.createElement("div",{...us,style:{...as,...Yf},ref:fs,className:it(["react-flow",o]),"data-testid":"rf__wrapper",id:fr},N.createElement(Mi,null,N.createElement(Hf,{onInit:u,onMove:l,onMoveStart:f,onMoveEnd:d,onNodeClick:c,onEdgeClick:a,onNodeMouseEnter:E,onNodeMouseMove:M,onNodeMouseLeave:x,onNodeContextMenu:$,onNodeDoubleClick:C,nodeTypes:s,edgeTypes:i,connectionLineType:A,connectionLineStyle:R,connectionLineComponent:D,connectionLineContainerStyle:B,selectionKeyCode:W,selectionOnDrag:U,selectionMode:Z,deleteKeyCode:F,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:G,onlyRenderVisibleElements:at,selectNodesOnDrag:st,defaultViewport:Kt,translateExtent:Jt,minZoom:Qt,maxZoom:Nt,preventScrolling:Pt,zoomOnScroll:te,zoomOnPinch:he,zoomOnDoubleClick:Ot,panOnScroll:ct,panOnScrollSpeed:mt,panOnScrollMode:Lt,panOnDrag:Ft,onPaneClick:Mt,onPaneMouseEnter:_t,onPaneMouseMove:ge,onPaneMouseLeave:dn,onPaneScroll:pe,onPaneContextMenu:hn,onSelectionContextMenu:w,onSelectionStart:k,onSelectionEnd:I,onEdgeContextMenu:Bt,onEdgeDoubleClick:Ii,onEdgeMouseEnter:Ri,onEdgeMouseMove:Di,onEdgeMouseLeave:Hi,onReconnect:Oi??Pi,onReconnectStart:Fi??Vi,onReconnectEnd:Bi??Li,reconnectRadius:Yi??Xi,defaultMarkerColor:jt,noDragClassName:qi,noWheelClassName:Zi,noPanClassName:lr,elevateEdgesOnSelect:ns,rfId:gn,disableKeyboardA11y:ur,nodeOrigin:Y,nodeExtent:Vt}),N.createElement(zu,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:g,onConnectStart:y,onConnectEnd:p,onClickConnectStart:v,onClickConnectEnd:m,nodesDraggable:et,nodesConnectable:dt,nodesFocusable:J,edgesFocusable:lt,edgesUpdatable:bt,elementsSelectable:de,elevateNodesOnSelect:es,minZoom:Qt,maxZoom:Nt,nodeExtent:Vt,onNodesChange:Wi,onEdgesChange:Ui,snapToGrid:ot,snapGrid:nt,connectionMode:_,translateExtent:Jt,connectOnClick:Qi,defaultEdgeOptions:ts,fitView:Gi,fitViewOptions:Ki,onNodesDelete:L,onEdgesDelete:H,onNodeDragStart:z,onNodeDrag:P,onNodeDragStop:T,onSelectionDrag:h,onSelectionDragStart:V,onSelectionDragStop:S,noPanClassName:lr,nodeOrigin:Y,rfId:gn,autoPanOnConnect:rs,autoPanOnNodeDrag:os,onError:cs,connectionRadius:is,isValidConnection:ss,nodeDragThreshold:ls}),N.createElement(ku,{onSelectionChange:O}),ar,N.createElement(ou,{proOptions:ji,position:Ji}),N.createElement(Pu,{rfId:gn,disableKeyboardA11y:ur})))});Xf.displayName="ReactFlow";function $i(t){return e=>{const[n,r]=b.useState(e),o=b.useCallback(s=>r(i=>t(s,i)),[]);return[n,r,o]}}const gd=$i(hi),pd=$i(Qu);function Ci(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}const Ai=({id:t,x:e,y:n,width:r,height:o,style:s,color:i,strokeColor:c,strokeWidth:a,className:u,borderRadius:l,shapeRendering:f,onClick:d,selected:g})=>{const{background:y,backgroundColor:p}=s||{},v=i||y||p;return N.createElement("rect",{className:it(["react-flow__minimap-node",{selected:g},u]),x:e,y:n,rx:l,ry:l,width:r,height:o,fill:v,stroke:c,strokeWidth:a,shapeRendering:f,onClick:d?m=>d(m,t):void 0})};Ai.displayName="MiniMapNode";var Wf=b.memo(Ai);const Uf=t=>t.nodeOrigin,qf=t=>t.getNodes().filter(e=>!e.hidden&&e.width&&e.height),Cn=t=>t instanceof Function?t:()=>t;function Zf({nodeStrokeColor:t="transparent",nodeColor:e="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o=2,nodeComponent:s=Wf,onClick:i}){const c=j(qf,Ci),a=j(Uf),u=Cn(e),l=Cn(t),f=Cn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return N.createElement(N.Fragment,null,c.map(g=>{const{x:y,y:p}=qt(g,a).positionAbsolute;return N.createElement(s,{key:g.id,x:y,y:p,width:g.width,height:g.height,style:g.style,selected:g.selected,className:f(g),color:u(g),borderRadius:r,strokeColor:l(g),strokeWidth:o,shapeRendering:d,onClick:i,id:g.id})}))}var Gf=b.memo(Zf);const Kf=200,Qf=150,Jf=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?cu(fn(e,t.nodeOrigin),n):n,rfId:t.rfId}},jf="react-flow__minimap-desc";function ki({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:u="none",maskStrokeWidth:l=1,position:f="bottom-right",onClick:d,onNodeClick:g,pannable:y=!1,zoomable:p=!1,ariaLabel:v="React Flow mini map",inversePan:m=!1,zoomStep:E=10,offsetScale:M=5}){const x=rt(),$=b.useRef(null),{boundingRect:C,viewBB:z,rfId:P}=j(Jf,Ci),T=(t==null?void 0:t.width)??Kf,L=(t==null?void 0:t.height)??Qf,H=C.width/T,O=C.height/L,V=Math.max(H,O),h=V*T,S=V*L,w=M*V,k=C.x-(h-C.width)/2-w,I=C.y-(S-C.height)/2-w,_=h+w*2,A=S+w*2,R=`${jf}-${P}`,D=b.useRef(0);D.current=V,b.useEffect(()=>{if($.current){const W=gt($.current),U=K=>{const{transform:G,d3Selection:ot,d3Zoom:nt}=x.getState();if(K.sourceEvent.type!=="wheel"||!ot||!nt)return;const at=-K.sourceEvent.deltaY*(K.sourceEvent.deltaMode===1?.05:K.sourceEvent.deltaMode?1:.002)*E,st=G[2]*Math.pow(2,at);nt.scaleTo(ot,st)},Z=K=>{const{transform:G,d3Selection:ot,d3Zoom:nt,translateExtent:at,width:st,height:et}=x.getState();if(K.sourceEvent.type!=="mousemove"||!ot||!nt)return;const dt=D.current*Math.max(1,G[2])*(m?-1:1),J={x:G[0]-K.sourceEvent.movementX*dt,y:G[1]-K.sourceEvent.movementY*dt},Y=[[0,0],[st,et]],lt=At.translate(J.x,J.y).scale(G[2]),bt=nt.constrain()(lt,Y,at);nt.transform(ot,bt)},Q=Do().on("zoom",y?Z:null).on("zoom.wheel",p?U:null);return W.call(Q),()=>{W.on("zoom",null)}}},[y,p,m,E]);const B=d?W=>{const U=yt(W);d(W,{x:U[0],y:U[1]})}:void 0,F=g?(W,U)=>{const Z=x.getState().nodeInternals.get(U);g(W,Z)}:void 0;return N.createElement(Qn,{position:f,style:t,className:it(["react-flow__minimap",e]),"data-testid":"rf__minimap"},N.createElement("svg",{width:T,height:L,viewBox:`${k} ${I} ${_} ${A}`,role:"img","aria-labelledby":R,ref:$,onClick:B},v&&N.createElement("title",{id:R},v),N.createElement(Gf,{onClick:F,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:c}),N.createElement("path",{className:"react-flow__minimap-mask",d:`M${k-w},${I-w}h${_+w*2}v${A+w*2}h${-_-w*2}z
        M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fill:a,fillRule:"evenodd",stroke:u,strokeWidth:l,pointerEvents:"none"})))}ki.displayName="MiniMap";var md=b.memo(ki);function td(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}function ed(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},N.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function nd(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},N.createElement("path",{d:"M0 0h32v4.2H0z"}))}function rd(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},N.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 od(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},N.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 id(){return N.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},N.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 Se=({children:t,className:e,...n})=>N.createElement("button",{type:"button",className:it(["react-flow__controls-button",e]),...n},t);Se.displayName="ControlButton";const sd=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom}),Ti=({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:c,onInteractiveChange:a,className:u,children:l,position:f="bottom-left"})=>{const d=rt(),[g,y]=b.useState(!1),{isInteractive:p,minZoomReached:v,maxZoomReached:m}=j(sd,td),{zoomIn:E,zoomOut:M,fitView:x}=sr();if(b.useEffect(()=>{y(!0)},[]),!g)return null;const $=()=>{E(),s==null||s()},C=()=>{M(),i==null||i()},z=()=>{x(o),c==null||c()},P=()=>{d.setState({nodesDraggable:!p,nodesConnectable:!p,elementsSelectable:!p}),a==null||a(!p)};return N.createElement(Qn,{className:it(["react-flow__controls",u]),position:f,style:t,"data-testid":"rf__controls"},e&&N.createElement(N.Fragment,null,N.createElement(Se,{onClick:$,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:m},N.createElement(ed,null)),N.createElement(Se,{onClick:C,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},N.createElement(nd,null))),n&&N.createElement(Se,{className:"react-flow__controls-fitview",onClick:z,title:"fit view","aria-label":"fit view"},N.createElement(rd,null)),r&&N.createElement(Se,{className:"react-flow__controls-interactive",onClick:P,title:"toggle interactivity","aria-label":"toggle interactivity"},p?N.createElement(id,null):N.createElement(od,null)),l)};Ti.displayName="Controls";var yd=b.memo(Ti);function cd(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 wt;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(wt||(wt={}));function ad({color:t,dimensions:e,lineWidth:n}){return N.createElement("path",{stroke:t,strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})}function ld({color:t,radius:e}){return N.createElement("circle",{cx:e,cy:e,r:e,fill:t})}const ud={[wt.Dots]:"#91919a",[wt.Lines]:"#eee",[wt.Cross]:"#e2e2e2"},fd={[wt.Dots]:1,[wt.Lines]:1,[wt.Cross]:6},dd=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function zi({id:t,variant:e=wt.Dots,gap:n=20,size:r,lineWidth:o=1,offset:s=2,color:i,style:c,className:a}){const u=b.useRef(null),{transform:l,patternId:f}=j(dd,cd),d=i||ud[e],g=r||fd[e],y=e===wt.Dots,p=e===wt.Cross,v=Array.isArray(n)?n:[n,n],m=[v[0]*l[2]||1,v[1]*l[2]||1],E=g*l[2],M=p?[E,E]:m,x=y?[E/s,E/s]:[M[0]/s,M[1]/s];return N.createElement("svg",{className:it(["react-flow__background",a]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},N.createElement("pattern",{id:f+t,x:l[0]%m[0],y:l[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${x[0]},-${x[1]})`},y?N.createElement(ld,{color:d,radius:E/s}):N.createElement(ad,{dimensions:M,color:d,lineWidth:o})),N.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+t})`}))}zi.displayName="Background";var xd=b.memo(zi);export{Re as B,yd as C,rn as H,en as M,X as P,Xf as R,pd as a,xd as b,Qn as c,md as d,gd as u};
