@xyflow/react 12.0.0-next.21 → 12.0.0-next.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/esm/components/ConnectionLine/index.d.ts.map +1 -1
  2. package/dist/esm/components/EdgeWrapper/EdgeUpdateAnchors.d.ts +7 -7
  3. package/dist/esm/components/EdgeWrapper/EdgeUpdateAnchors.d.ts.map +1 -1
  4. package/dist/esm/components/EdgeWrapper/index.d.ts +1 -1
  5. package/dist/esm/components/EdgeWrapper/index.d.ts.map +1 -1
  6. package/dist/esm/components/StoreUpdater/index.d.ts +1 -1
  7. package/dist/esm/components/StoreUpdater/index.d.ts.map +1 -1
  8. package/dist/esm/container/EdgeRenderer/index.d.ts +2 -2
  9. package/dist/esm/container/EdgeRenderer/index.d.ts.map +1 -1
  10. package/dist/esm/container/FlowRenderer/index.d.ts.map +1 -1
  11. package/dist/esm/container/GraphView/index.d.ts +1 -1
  12. package/dist/esm/container/GraphView/index.d.ts.map +1 -1
  13. package/dist/esm/container/Pane/index.d.ts +2 -1
  14. package/dist/esm/container/Pane/index.d.ts.map +1 -1
  15. package/dist/esm/hooks/useGlobalKeyHandler.d.ts.map +1 -1
  16. package/dist/esm/index.d.ts +1 -1
  17. package/dist/esm/index.d.ts.map +1 -1
  18. package/dist/esm/index.js +60 -48
  19. package/dist/esm/index.mjs +60 -48
  20. package/dist/esm/types/component-props.d.ts +6 -6
  21. package/dist/esm/types/component-props.d.ts.map +1 -1
  22. package/dist/esm/types/edges.d.ts +7 -8
  23. package/dist/esm/types/edges.d.ts.map +1 -1
  24. package/dist/esm/types/store.d.ts +1 -1
  25. package/dist/esm/types/store.d.ts.map +1 -1
  26. package/dist/umd/components/ConnectionLine/index.d.ts.map +1 -1
  27. package/dist/umd/components/EdgeWrapper/EdgeUpdateAnchors.d.ts +7 -7
  28. package/dist/umd/components/EdgeWrapper/EdgeUpdateAnchors.d.ts.map +1 -1
  29. package/dist/umd/components/EdgeWrapper/index.d.ts +1 -1
  30. package/dist/umd/components/EdgeWrapper/index.d.ts.map +1 -1
  31. package/dist/umd/components/StoreUpdater/index.d.ts +1 -1
  32. package/dist/umd/components/StoreUpdater/index.d.ts.map +1 -1
  33. package/dist/umd/container/EdgeRenderer/index.d.ts +2 -2
  34. package/dist/umd/container/EdgeRenderer/index.d.ts.map +1 -1
  35. package/dist/umd/container/FlowRenderer/index.d.ts.map +1 -1
  36. package/dist/umd/container/GraphView/index.d.ts +1 -1
  37. package/dist/umd/container/GraphView/index.d.ts.map +1 -1
  38. package/dist/umd/container/Pane/index.d.ts +2 -1
  39. package/dist/umd/container/Pane/index.d.ts.map +1 -1
  40. package/dist/umd/hooks/useGlobalKeyHandler.d.ts.map +1 -1
  41. package/dist/umd/index.d.ts +1 -1
  42. package/dist/umd/index.d.ts.map +1 -1
  43. package/dist/umd/index.js +2 -2
  44. package/dist/umd/types/component-props.d.ts +6 -6
  45. package/dist/umd/types/component-props.d.ts.map +1 -1
  46. package/dist/umd/types/edges.d.ts +7 -8
  47. package/dist/umd/types/edges.d.ts.map +1 -1
  48. package/dist/umd/types/store.d.ts +1 -1
  49. package/dist/umd/types/store.d.ts.map +1 -1
  50. package/package.json +2 -2
package/dist/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactFlow={},e.jsxRuntime,e.React,e.ReactDOM)}(this,(function(e,t,n,o){"use strict";function r(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=r(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var i={value:()=>{}};function a(){for(var e,t=0,n=arguments.length,o={};t<n;++t){if(!(e=arguments[t]+"")||e in o||/[\s.]/.test(e))throw new Error("illegal type: "+e);o[e]=[]}return new s(o)}function s(e){this._=e}function l(e,t){for(var n,o=0,r=e.length;o<r;++o)if((n=e[o]).name===t)return n.value}function c(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=i,e=e.slice(0,o).concat(e.slice(o+1));break}return null!=n&&e.push({name:t,value:n}),e}s.prototype=a.prototype={constructor:s,on:function(e,t){var n,o,r=this._,i=(o=r,(e+"").trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!o.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++a<s;)if(n=(e=i[a]).type)r[n]=c(r[n],e.name,t);else if(null==t)for(n in r)r[n]=c(r[n],e.name,null);return this}for(;++a<s;)if((n=(e=i[a]).type)&&(n=l(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new s(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,o,r=new Array(n),i=0;i<n;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(o=this._[e]).length;i<n;++i)o[i].value.apply(t,r)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};var u="http://www.w3.org/1999/xhtml",d={svg:"http://www.w3.org/2000/svg",xhtml:u,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function h(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),d.hasOwnProperty(t)?{space:d[t],local:e}:e}function f(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===u&&t.documentElement.namespaceURI===u?t.createElement(e):t.createElementNS(n,e)}}function g(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function p(e){var t=h(e);return(t.local?g:f)(t)}function m(){}function y(e){return null==e?m:function(){return this.querySelector(e)}}function v(){return[]}function x(e){return null==e?v:function(){return this.querySelectorAll(e)}}function w(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}function b(e){return function(){return this.matches(e)}}function S(e){return function(t){return t.matches(e)}}var E=Array.prototype.find;function C(){return this.firstElementChild}var _=Array.prototype.filter;function M(){return Array.from(this.children)}function N(e){return new Array(e.length)}function k(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function P(e,t,n,o,r,i){for(var a,s=0,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new k(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function z(e,t,n,o,r,i,a){var s,l,c,u=new Map,d=t.length,h=i.length,f=new Array(d);for(s=0;s<d;++s)(l=t[s])&&(f[s]=c=a.call(l,l.__data__,s,t)+"",u.has(c)?r[s]=l:u.set(c,l));for(s=0;s<h;++s)c=a.call(e,i[s],s,i)+"",(l=u.get(c))?(o[s]=l,l.__data__=i[s],u.delete(c)):n[s]=new k(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&u.get(f[s])===l&&(r[s]=l)}function O(e){return e.__data__}function I(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function A(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function D(e){return function(){this.removeAttribute(e)}}function R(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $(e,t){return function(){this.setAttribute(e,t)}}function L(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function T(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function B(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function j(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function V(e){return function(){this.style.removeProperty(e)}}function H(e,t,n){return function(){this.style.setProperty(e,t,n)}}function X(e,t,n){return function(){var o=t.apply(this,arguments);null==o?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Y(e,t){return e.style.getPropertyValue(t)||j(e).getComputedStyle(e,null).getPropertyValue(t)}function Z(e){return function(){delete this[e]}}function W(e,t){return function(){this[e]=t}}function U(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function F(e){return e.trim().split(/^|\s+/)}function K(e){return e.classList||new G(e)}function G(e){this._node=e,this._names=F(e.getAttribute("class")||"")}function q(e,t){for(var n=K(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Q(e,t){for(var n=K(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function J(e){return function(){q(this,e)}}function ee(e){return function(){Q(this,e)}}function te(e,t){return function(){(t.apply(this,arguments)?q:Q)(this,e)}}function ne(){this.textContent=""}function oe(e){return function(){this.textContent=e}}function re(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function ie(){this.innerHTML=""}function ae(e){return function(){this.innerHTML=e}}function se(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function le(){this.nextSibling&&this.parentNode.appendChild(this)}function ce(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ue(){return null}function de(){var e=this.parentNode;e&&e.removeChild(this)}function he(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ge(e){return function(){var t=this.__on;if(t){for(var n,o=0,r=-1,i=t.length;o<i;++o)n=t[o],e.type&&n.type!==e.type||n.name!==e.name?t[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?t.length=r:delete this.__on}}}function pe(e,t,n){return function(){var o,r=this.__on,i=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(r)for(var a=0,s=r.length;a<s;++a)if((o=r[a]).type===e.type&&o.name===e.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=t);this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function me(e,t,n){var o=j(e),r=o.CustomEvent;"function"==typeof r?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function ye(e,t){return function(){return me(this,e,t)}}function ve(e,t){return function(){return me(this,e,t.apply(this,arguments))}}k.prototype={constructor:k,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}},G.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var xe=[null];function we(e,t){this._groups=e,this._parents=t}function be(){return new we([[document.documentElement]],xe)}function Se(e){return"string"==typeof e?new we([[document.querySelector(e)]],[document.documentElement]):new we([[e]],xe)}function Ee(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,[(o=o.matrixTransform(t.getScreenCTM().inverse())).x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}we.prototype=be.prototype={constructor:we,select:function(e){"function"!=typeof e&&(e=y(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a,s=t[r],l=s.length,c=o[r]=new Array(l),u=0;u<l;++u)(i=s[u])&&(a=e.call(i,i.__data__,u,s))&&("__data__"in i&&(a.__data__=i.__data__),c[u]=a);return new we(o,this._parents)},selectAll:function(e){e="function"==typeof e?w(e):x(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var a,s=t[i],l=s.length,c=0;c<l;++c)(a=s[c])&&(o.push(e.call(a,a.__data__,c,s)),r.push(a));return new we(o,r)},selectChild:function(e){return this.select(null==e?C:function(e){return function(){return E.call(this.children,e)}}("function"==typeof e?e:S(e)))},selectChildren:function(e){return this.selectAll(null==e?M:function(e){return function(){return _.call(this.children,e)}}("function"==typeof e?e:S(e)))},filter:function(e){"function"!=typeof e&&(e=b(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a=t[r],s=a.length,l=o[r]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&l.push(i);return new we(o,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,O);var n,o=t?z:P,r=this._parents,i=this._groups;"function"!=typeof e&&(n=e,e=function(){return n});for(var a=i.length,s=new Array(a),l=new Array(a),c=new Array(a),u=0;u<a;++u){var d=r[u],h=i[u],f=h.length,g=I(e.call(d,d&&d.__data__,u,r)),p=g.length,m=l[u]=new Array(p),y=s[u]=new Array(p);o(d,h,m,y,c[u]=new Array(f),g,t);for(var v,x,w=0,b=0;w<p;++w)if(v=m[w]){for(w>=b&&(b=w+1);!(x=y[b])&&++b<p;);v._next=x||null}}return(s=new we(s,r))._enter=l,s._exit=c,s},enter:function(){return new we(this._enter||this._groups.map(N),this._parents)},exit:function(){return new we(this._exit||this._groups.map(N),this._parents)},join:function(e,t,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof e?(o=e(o))&&(o=o.selection()):o=o.append(e+""),null!=t&&(r=t(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c,u=n[l],d=o[l],h=u.length,f=s[l]=new Array(h),g=0;g<h;++g)(c=u[g]||d[g])&&(f[g]=c);for(;l<r;++l)s[l]=n[l];return new we(s,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o,r=e[t],i=r.length-1,a=r[i];--i>=0;)(o=r[i])&&(a&&4^o.compareDocumentPosition(a)&&a.parentNode.insertBefore(o,a),a=o);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=A);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var a,s=n[i],l=s.length,c=r[i]=new Array(l),u=0;u<l;++u)(a=s[u])&&(c[u]=a);c.sort(t)}return new we(r,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var a=o[r];if(a)return a}return null},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r,i=t[n],a=0,s=i.length;a<s;++a)(r=i[a])&&e.call(r,r.__data__,a,i);return this},attr:function(e,t){var n=h(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==t?n.local?R:D:"function"==typeof t?n.local?B:T:n.local?L:$)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?V:"function"==typeof t?X:H)(e,t,null==n?"":n)):Y(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?Z:"function"==typeof t?U:W)(e,t)):this.node()[e]},classed:function(e,t){var n=F(e+"");if(arguments.length<2){for(var o=K(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof t?te:t?J:ee)(n,t))},text:function(e){return arguments.length?this.each(null==e?ne:("function"==typeof e?re:oe)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?ie:("function"==typeof e?se:ae)(e)):this.node().innerHTML},raise:function(){return this.each(le)},lower:function(){return this.each(ce)},append:function(e){var t="function"==typeof e?e:p(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:p(e),o=null==t?ue:"function"==typeof t?t:y(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(de)},clone:function(e){return this.select(e?fe:he)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var o,r,i=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=i.length;if(!(arguments.length<2)){for(s=t?pe:ge,o=0;o<a;++o)this.each(s(i[o],t,n));return this}var s=this.node().__on;if(s)for(var l,c=0,u=s.length;c<u;++c)for(o=0,l=s[c];o<a;++o)if((r=i[o]).type===l.type&&r.name===l.name)return l.value},dispatch:function(e,t){return this.each(("function"==typeof t?ve:ye)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o,r=e[t],i=0,a=r.length;i<a;++i)(o=r[i])&&(yield o)}};const Ce={passive:!1},_e={capture:!0,passive:!1};function Me(e){e.stopImmediatePropagation()}function Ne(e){e.preventDefault(),e.stopImmediatePropagation()}function ke(e){var t=e.document.documentElement,n=Se(e).on("dragstart.drag",Ne,_e);"onselectstart"in t?n.on("selectstart.drag",Ne,_e):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Pe(e,t){var n=e.document.documentElement,o=Se(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ne,_e),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var ze=e=>()=>e;function Oe(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function Ie(e){return!e.ctrlKey&&!e.button}function Ae(){return this.parentNode}function De(e,t){return null==t?{x:e.x,y:e.y}:t}function Re(){return navigator.maxTouchPoints||"ontouchstart"in this}function $e(){var e,t,n,o,r=Ie,i=Ae,s=De,l=Re,c={},u=a("start","drag","end"),d=0,h=0;function f(e){e.on("mousedown.drag",g).filter(l).on("touchstart.drag",y).on("touchmove.drag",v,Ce).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(a,s){if(!o&&r.call(this,a,s)){var l=w(this,i.call(this,a,s),a,s,"mouse");l&&(Se(a.view).on("mousemove.drag",p,_e).on("mouseup.drag",m,_e),ke(a.view),Me(a),n=!1,e=a.clientX,t=a.clientY,l("start",a))}}function p(o){if(Ne(o),!n){var r=o.clientX-e,i=o.clientY-t;n=r*r+i*i>h}c.mouse("drag",o)}function m(e){Se(e.view).on("mousemove.drag mouseup.drag",null),Pe(e.view,n),Ne(e),c.mouse("end",e)}function y(e,t){if(r.call(this,e,t)){var n,o,a=e.changedTouches,s=i.call(this,e,t),l=a.length;for(n=0;n<l;++n)(o=w(this,s,e,t,a[n].identifier,a[n]))&&(Me(e),o("start",e,a[n]))}}function v(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=c[o[t].identifier])&&(Ne(e),n("drag",e,o[t]))}function x(e){var t,n,r=e.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<i;++t)(n=c[r[t].identifier])&&(Me(e),n("end",e,r[t]))}function w(e,t,n,o,r,i){var a,l,h,g=u.copy(),p=Ee(i||n,t);if(null!=(h=s.call(e,new Oe("beforestart",{sourceEvent:n,target:f,identifier:r,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:g}),o)))return a=h.x-p[0]||0,l=h.y-p[1]||0,function n(i,s,u){var m,y=p;switch(i){case"start":c[r]=n,m=d++;break;case"end":delete c[r],--d;case"drag":p=Ee(u||s,t),m=d}g.call(i,e,new Oe(i,{sourceEvent:s,subject:h,target:f,identifier:r,active:m,x:p[0]+a,y:p[1]+l,dx:p[0]-y[0],dy:p[1]-y[1],dispatch:g}),o)}}return f.filter=function(e){return arguments.length?(r="function"==typeof e?e:ze(!!e),f):r},f.container=function(e){return arguments.length?(i="function"==typeof e?e:ze(e),f):i},f.subject=function(e){return arguments.length?(s="function"==typeof e?e:ze(e),f):s},f.touchable=function(e){return arguments.length?(l="function"==typeof e?e:ze(!!e),f):l},f.on=function(){var e=u.on.apply(u,arguments);return e===u?f:e},f.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,f):Math.sqrt(h)},f}function Le(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Te(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Be(){}Oe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var je=.7,Ve=1/je,He="\\s*([+-]?\\d+)\\s*",Xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ye="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ze=/^#([0-9a-f]{3,8})$/,We=new RegExp(`^rgb\\(${He},${He},${He}\\)$`),Ue=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),Fe=new RegExp(`^rgba\\(${He},${He},${He},${Xe}\\)$`),Ke=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${Xe}\\)$`),Ge=new RegExp(`^hsl\\(${Xe},${Ye},${Ye}\\)$`),qe=new RegExp(`^hsla\\(${Xe},${Ye},${Ye},${Xe}\\)$`),Qe={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};function Je(){return this.rgb().formatHex()}function et(){return this.rgb().formatRgb()}function tt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ze.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?nt(t):3===n?new it(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?ot(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?ot(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=We.exec(e))?new it(t[1],t[2],t[3],1):(t=Ue.exec(e))?new it(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Fe.exec(e))?ot(t[1],t[2],t[3],t[4]):(t=Ke.exec(e))?ot(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=Ge.exec(e))?dt(t[1],t[2]/100,t[3]/100,1):(t=qe.exec(e))?dt(t[1],t[2]/100,t[3]/100,t[4]):Qe.hasOwnProperty(e)?nt(Qe[e]):"transparent"===e?new it(NaN,NaN,NaN,0):null}function nt(e){return new it(e>>16&255,e>>8&255,255&e,1)}function ot(e,t,n,o){return o<=0&&(e=t=n=NaN),new it(e,t,n,o)}function rt(e,t,n,o){return 1===arguments.length?((r=e)instanceof Be||(r=tt(r)),r?new it((r=r.rgb()).r,r.g,r.b,r.opacity):new it):new it(e,t,n,null==o?1:o);var r}function it(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}function at(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}`}function st(){const e=lt(this.opacity);return`${1===e?"rgb(":"rgba("}${ct(this.r)}, ${ct(this.g)}, ${ct(this.b)}${1===e?")":`, ${e})`}`}function lt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ct(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ut(e){return((e=ct(e))<16?"0":"")+e.toString(16)}function dt(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ft(e,t,n,o)}function ht(e){if(e instanceof ft)return new ft(e.h,e.s,e.l,e.opacity);if(e instanceof Be||(e=tt(e)),!e)return new ft;if(e instanceof ft)return e;var t=(e=e.rgb()).r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),a=NaN,s=i-r,l=(i+r)/2;return s?(a=t===i?(n-o)/s+6*(n<o):n===i?(o-t)/s+2:(t-n)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new ft(a,s,l,e.opacity)}function ft(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}function gt(e){return(e=(e||0)%360)<0?e+360:e}function pt(e){return Math.max(0,Math.min(1,e||0))}function mt(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}Le(Be,tt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Je,formatHex:Je,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ht(this).formatHsl()},formatRgb:et,toString:et}),Le(it,rt,Te(Be,{brighter(e){return e=null==e?Ve:Math.pow(Ve,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?je:Math.pow(je,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new it(ct(this.r),ct(this.g),ct(this.b),lt(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:at,formatHex:at,formatHex8:function(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}${ut(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:st,toString:st})),Le(ft,(function(e,t,n,o){return 1===arguments.length?ht(e):new ft(e,t,n,null==o?1:o)}),Te(Be,{brighter(e){return e=null==e?Ve:Math.pow(Ve,e),new ft(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?je:Math.pow(je,e),new ft(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new it(mt(e>=240?e-240:e+120,r,o),mt(e,r,o),mt(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new ft(gt(this.h),pt(this.s),pt(this.l),lt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=lt(this.opacity);return`${1===e?"hsl(":"hsla("}${gt(this.h)}, ${100*pt(this.s)}%, ${100*pt(this.l)}%${1===e?")":`, ${e})`}`}}));var yt=e=>()=>e;function vt(e){return 1==(e=+e)?xt:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}(t,n,e):yt(isNaN(t)?n:t)}}function xt(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):yt(isNaN(e)?t:e)}var wt=function e(t){var n=vt(t);function o(e,t){var o=n((e=rt(e)).r,(t=rt(t)).r),r=n(e.g,t.g),i=n(e.b,t.b),a=xt(e.opacity,t.opacity);return function(t){return e.r=o(t),e.g=r(t),e.b=i(t),e.opacity=a(t),e+""}}return o.gamma=e,o}(1);function bt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var St=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Et=new RegExp(St.source,"g");function Ct(e,t){var n,o,r,i=St.lastIndex=Et.lastIndex=0,a=-1,s=[],l=[];for(e+="",t+="";(n=St.exec(e))&&(o=Et.exec(t));)(r=o.index)>i&&(r=t.slice(i,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(o=o[0])?s[a]?s[a]+=o:s[++a]=o:(s[++a]=null,l.push({i:a,x:bt(n,o)})),i=Et.lastIndex;return i<t.length&&(r=t.slice(i),s[a]?s[a]+=r:s[++a]=r),s.length<2?l[0]?function(e){return function(t){return e(t)+""}}(l[0].x):function(e){return function(){return e}}(t):(t=l.length,function(e){for(var n,o=0;o<t;++o)s[(n=l[o]).i]=n.x(e);return s.join("")})}var _t,Mt=180/Math.PI,Nt={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function kt(e,t,n,o,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(s=Math.sqrt(n*n+o*o))&&(n/=s,o/=s,l/=s),e*o<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Mt,skewX:Math.atan(l)*Mt,scaleX:a,scaleY:s}}function Pt(e,t,n,o){function r(e){return e.length?e.pop()+" ":""}return function(i,a){var s=[],l=[];return i=e(i),a=e(a),function(e,o,r,i,a,s){if(e!==r||o!==i){var l=a.push("translate(",null,t,null,n);s.push({i:l-4,x:bt(e,r)},{i:l-2,x:bt(o,i)})}else(r||i)&&a.push("translate("+r+t+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,l),function(e,t,n,i){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:bt(e,t)})):t&&n.push(r(n)+"rotate("+t+o)}(i.rotate,a.rotate,s,l),function(e,t,n,i){e!==t?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:bt(e,t)}):t&&n.push(r(n)+"skewX("+t+o)}(i.skewX,a.skewX,s,l),function(e,t,n,o,i,a){if(e!==n||t!==o){var s=i.push(r(i)+"scale(",null,",",null,")");a.push({i:s-4,x:bt(e,n)},{i:s-2,x:bt(t,o)})}else 1===n&&1===o||i.push(r(i)+"scale("+n+","+o+")")}(i.scaleX,i.scaleY,a.scaleX,a.scaleY,s,l),i=a=null,function(e){for(var t,n=-1,o=l.length;++n<o;)s[(t=l[n]).i]=t.x(e);return s.join("")}}}var zt=Pt((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Nt:kt(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),Ot=Pt((function(e){return null==e?Nt:(_t||(_t=document.createElementNS("http://www.w3.org/2000/svg","g")),_t.setAttribute("transform",e),(e=_t.transform.baseVal.consolidate())?kt((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):Nt)}),", ",")",")");function It(e){return((e=Math.exp(e))+1/e)/2}var At,Dt,Rt=function e(t,n,o){function r(e,r){var i,a,s=e[0],l=e[1],c=e[2],u=r[0],d=r[1],h=r[2],f=u-s,g=d-l,p=f*f+g*g;if(p<1e-12)a=Math.log(h/c)/t,i=function(e){return[s+e*f,l+e*g,c*Math.exp(t*e*a)]};else{var m=Math.sqrt(p),y=(h*h-c*c+o*p)/(2*c*n*m),v=(h*h-c*c-o*p)/(2*h*n*m),x=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(v*v+1)-v);a=(w-x)/t,i=function(e){var o,r=e*a,i=It(x),u=c/(n*m)*(i*(o=t*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(e){return((e=Math.exp(e))-1/e)/2}(x));return[s+u*f,l+u*g,c*i/It(t*r+x)]}}return i.duration=1e3*a*t/Math.SQRT2,i}return r.rho=function(t){var n=Math.max(.001,+t),o=n*n;return e(n,o,o*o)},r}(Math.SQRT2,2,4),$t=0,Lt=0,Tt=0,Bt=1e3,jt=0,Vt=0,Ht=0,Xt="object"==typeof performance&&performance.now?performance:Date,Yt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Zt(){return Vt||(Yt(Wt),Vt=Xt.now()+Ht)}function Wt(){Vt=0}function Ut(){this._call=this._time=this._next=null}function Ft(e,t,n){var o=new Ut;return o.restart(e,t,n),o}function Kt(){Vt=(jt=Xt.now())+Ht,$t=Lt=0;try{!function(){Zt(),++$t;for(var e,t=At;t;)(e=Vt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--$t}()}finally{$t=0,function(){var e,t,n=At,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:At=t);Dt=e,qt(o)}(),Vt=0}}function Gt(){var e=Xt.now(),t=e-jt;t>Bt&&(Ht-=t,jt=e)}function qt(e){$t||(Lt&&(Lt=clearTimeout(Lt)),e-Vt>24?(e<1/0&&(Lt=setTimeout(Kt,e-Xt.now()-Ht)),Tt&&(Tt=clearInterval(Tt))):(Tt||(jt=Xt.now(),Tt=setInterval(Gt,Bt)),$t=1,Yt(Kt)))}function Qt(e,t,n){var o=new Ut;return t=null==t?0:+t,o.restart((n=>{o.stop(),e(n+t)}),t,n),o}Ut.prototype=Ft.prototype={constructor:Ut,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Zt():+n)+(null==t?0:+t),this._next||Dt===this||(Dt?Dt._next=this:At=this,Dt=this),this._call=e,this._time=n,qt()},stop:function(){this._call&&(this._call=null,this._time=1/0,qt())}};var Jt=a("start","end","cancel","interrupt"),en=[],tn=0,nn=1,on=2,rn=3,an=4,sn=5,ln=6;function cn(e,t,n,o,r,i){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var o,r=e.__transition;function i(e){n.state=nn,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)}function a(i){var c,u,d,h;if(n.state!==nn)return l();for(c in r)if((h=r[c]).name===n.name){if(h.state===rn)return Qt(a);h.state===an?(h.state=ln,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+c<t&&(h.state=ln,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[c])}if(Qt((function(){n.state===rn&&(n.state=an,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=on,n.on.call("start",e,e.__data__,n.index,n.group),n.state===on){for(n.state=rn,o=new Array(d=n.tween.length),c=0,u=-1;c<d;++c)(h=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(o[++u]=h);o.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(l),n.state=sn,1),i=-1,a=o.length;++i<a;)o[i].call(e,r);n.state===sn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){for(var o in n.state=ln,n.timer.stop(),delete r[t],r)return;delete e.__transition}r[t]=n,n.timer=Ft(i,0,n.time)}(e,n,{name:t,index:o,group:r,on:Jt,tween:en,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:tn})}function un(e,t){var n=hn(e,t);if(n.state>tn)throw new Error("too late; already scheduled");return n}function dn(e,t){var n=hn(e,t);if(n.state>rn)throw new Error("too late; already running");return n}function hn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function fn(e,t){var n,o,r,i=e.__transition,a=!0;if(i){for(r in t=null==t?null:t+"",i)(n=i[r]).name===t?(o=n.state>on&&n.state<sn,n.state=ln,n.timer.stop(),n.on.call(o?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[r]):a=!1;a&&delete e.__transition}}function gn(e,t){var n,o;return function(){var r=dn(this,e),i=r.tween;if(i!==n)for(var a=0,s=(o=n=i).length;a<s;++a)if(o[a].name===t){(o=o.slice()).splice(a,1);break}r.tween=o}}function pn(e,t,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=dn(this,e),a=i.tween;if(a!==o){r=(o=a).slice();for(var s={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function mn(e,t,n){var o=e._id;return e.each((function(){var e=dn(this,o);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return hn(e,o).value[t]}}function yn(e,t){var n;return("number"==typeof t?bt:t instanceof tt?wt:(n=tt(t))?(t=n,wt):Ct)(e,t)}function vn(e){return function(){this.removeAttribute(e)}}function xn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wn(e,t,n){var o,r,i=n+"";return function(){var a=this.getAttribute(e);return a===i?null:a===o?r:r=t(o=a,n)}}function bn(e,t,n){var o,r,i=n+"";return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===o?r:r=t(o=a,n)}}function Sn(e,t,n){var o,r,i;return function(){var a,s,l=n(this);if(null!=l)return(a=this.getAttribute(e))===(s=l+"")?null:a===o&&s===r?i:(r=s,i=t(o=a,l));this.removeAttribute(e)}}function En(e,t,n){var o,r,i;return function(){var a,s,l=n(this);if(null!=l)return(a=this.getAttributeNS(e.space,e.local))===(s=l+"")?null:a===o&&s===r?i:(r=s,i=t(o=a,l));this.removeAttributeNS(e.space,e.local)}}function Cn(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,r)),n}return r._value=t,r}function _n(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,r)),n}return r._value=t,r}function Mn(e,t){return function(){un(this,e).delay=+t.apply(this,arguments)}}function Nn(e,t){return t=+t,function(){un(this,e).delay=t}}function kn(e,t){return function(){dn(this,e).duration=+t.apply(this,arguments)}}function Pn(e,t){return t=+t,function(){dn(this,e).duration=t}}var zn=be.prototype.constructor;function On(e){return function(){this.style.removeProperty(e)}}var In=0;function An(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Dn(){return++In}var Rn=be.prototype;An.prototype={constructor:An,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=y(e));for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a)for(var s,l,c=o[a],u=c.length,d=i[a]=new Array(u),h=0;h<u;++h)(s=c[h])&&(l=e.call(s,s.__data__,h,c))&&("__data__"in s&&(l.__data__=s.__data__),d[h]=l,cn(d[h],t,n,h,d,hn(s,n)));return new An(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=x(e));for(var o=this._groups,r=o.length,i=[],a=[],s=0;s<r;++s)for(var l,c=o[s],u=c.length,d=0;d<u;++d)if(l=c[d]){for(var h,f=e.call(l,l.__data__,d,c),g=hn(l,n),p=0,m=f.length;p<m;++p)(h=f[p])&&cn(h,t,n,p,f,g);i.push(f),a.push(l)}return new An(i,a,t,n)},selectChild:Rn.selectChild,selectChildren:Rn.selectChildren,filter:function(e){"function"!=typeof e&&(e=b(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a=t[r],s=a.length,l=o[r]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&l.push(i);return new An(o,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),a=new Array(o),s=0;s<i;++s)for(var l,c=t[s],u=n[s],d=c.length,h=a[s]=new Array(d),f=0;f<d;++f)(l=c[f]||u[f])&&(h[f]=l);for(;s<o;++s)a[s]=t[s];return new An(a,this._parents,this._name,this._id)},selection:function(){return new zn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=Dn(),o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],l=s.length,c=0;c<l;++c)if(a=s[c]){var u=hn(a,t);cn(a,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new An(o,this._parents,e,n)},call:Rn.call,nodes:Rn.nodes,node:Rn.node,size:Rn.size,empty:Rn.empty,each:Rn.each,on:function(e,t){var n=this._id;return arguments.length<2?hn(this.node(),n).on.on(e):this.each(function(e,t,n){var o,r,i=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?un:dn;return function(){var a=i(this,e),s=a.on;s!==o&&(r=(o=s).copy()).on(t,n),a.on=r}}(n,e,t))},attr:function(e,t){var n=h(e),o="transform"===n?Ot:yn;return this.attrTween(e,"function"==typeof t?(n.local?En:Sn)(n,o,mn(this,"attr."+e,t)):null==t?(n.local?xn:vn)(n):(n.local?bn:wn)(n,o,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var o=h(e);return this.tween(n,(o.local?Cn:_n)(o,t))},style:function(e,t,n){var o="transform"==(e+="")?zt:yn;return null==t?this.styleTween(e,function(e,t){var n,o,r;return function(){var i=Y(this,e),a=(this.style.removeProperty(e),Y(this,e));return i===a?null:i===n&&a===o?r:r=t(n=i,o=a)}}(e,o)).on("end.style."+e,On(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var o,r,i;return function(){var a=Y(this,e),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(e),l=s=Y(this,e)),a===l?null:a===o&&l===r?i:(r=l,i=t(o=a,s))}}(e,o,mn(this,"style."+e,t))).each(function(e,t){var n,o,r,i,a="style."+t,s="end."+a;return function(){var l=dn(this,e),c=l.on,u=null==l.value[a]?i||(i=On(t)):void 0;c===n&&r===u||(o=(n=c).copy()).on(s,r=u),l.on=o}}(this._id,e)):this.styleTween(e,function(e,t,n){var o,r,i=n+"";return function(){var a=Y(this,e);return a===i?null:a===o?r:r=t(o=a,n)}}(e,o,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(null==t)return this.tween(o,null);if("function"!=typeof t)throw new Error;return this.tween(o,function(e,t,n){var o,r;function i(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&function(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}(e,i,n)),o}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(mn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function o(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&function(e){return function(t){this.textContent=e.call(this,t)}}(o)),t}return o._value=e,o}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o,r=hn(this.node(),n).tween,i=0,a=r.length;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((null==t?gn:pn)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Mn:Nn)(t,e)):hn(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?kn:Pn)(t,e)):hn(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){dn(this,e).ease=t}}(t,e)):hn(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;dn(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,o=n._id,r=n.size();return new Promise((function(i,a){var s={value:a},l={value:function(){0==--r&&i()}};n.each((function(){var n=dn(this,o),r=n.on;r!==e&&((t=(e=r).copy())._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),n.on=t})),0===r&&i()}))},[Symbol.iterator]:Rn[Symbol.iterator]};var $n={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function Ln(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}be.prototype.interrupt=function(e){return this.each((function(){fn(this,e)}))},be.prototype.transition=function(e){var t,n;e instanceof An?(t=e._id,e=e._name):(t=Dn(),(n=$n).time=Zt(),e=null==e?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],l=s.length,c=0;c<l;++c)(a=s[c])&&cn(a,e,t,c,s,n||Ln(a,t));return new An(o,this._parents,e,t)};var Tn=e=>()=>e;function Bn(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function jn(e,t,n){this.k=e,this.x=t,this.y=n}jn.prototype={constructor:jn,scale:function(e){return 1===e?this:new jn(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new jn(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vn=new jn(1,0,0);function Hn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Vn;return e.__zoom}function Xn(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function Zn(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Wn(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function Un(){return this.__zoom||Vn}function Fn(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Kn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Gn(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function qn(){var e,t,n,o=Zn,r=Wn,i=Gn,s=Fn,l=Kn,c=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],d=250,h=Rt,f=a("start","zoom","end"),g=500,p=150,m=0,y=10;function v(e){e.property("__zoom",Un).on("wheel.zoom",_,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",N).filter(l).on("touchstart.zoom",k).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(e,t){return(t=Math.max(c[0],Math.min(c[1],t)))===e.k?e:new jn(t,e.x,e.y)}function w(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new jn(e.k,o,r)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function S(e,t,n,o){e.on("start.zoom",(function(){E(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){E(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,i=arguments,a=E(e,i).event(o),s=r.apply(e,i),l=null==n?b(s):"function"==typeof n?n.apply(e,i):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),u=e.__zoom,d="function"==typeof t?t.apply(e,i):t,f=h(u.invert(l).concat(c/u.k),d.invert(l).concat(c/d.k));return function(e){if(1===e)e=d;else{var t=f(e),n=c/t[2];e=new jn(n,l[0]-t[0]*n,l[1]-t[1]*n)}a.zoom(null,e)}}))}function E(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function _(e,...t){if(o.apply(this,arguments)){var n=E(this,t).event(e),r=this.__zoom,a=Math.max(c[0],Math.min(c[1],r.k*Math.pow(2,s.apply(this,arguments)))),l=Ee(e);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=r.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(r.k===a)return;n.mouse=[l,r.invert(l)],fn(this),n.start()}Yn(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),p),n.zoom("mouse",i(w(x(r,a),n.mouse[0],n.mouse[1]),n.extent,u))}}function M(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,a=E(this,t,!0).event(e),s=Se(e.view).on("mousemove.zoom",(function(e){if(Yn(e),!a.moved){var t=e.clientX-c,n=e.clientY-d;a.moved=t*t+n*n>m}a.event(e).zoom("mouse",i(w(a.that.__zoom,a.mouse[0]=Ee(e,r),a.mouse[1]),a.extent,u))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),Pe(e.view,a.moved),Yn(e),a.event(e).end()}),!0),l=Ee(e,r),c=e.clientX,d=e.clientY;ke(e.view),Xn(e),a.mouse=[l,this.__zoom.invert(l)],fn(this),a.start()}}function N(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,a=Ee(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),l=n.k*(e.shiftKey?.5:2),c=i(w(x(n,l),a,s),r.apply(this,t),u);Yn(e),d>0?Se(this).transition().duration(d).call(S,c,a,e):Se(this).call(v.transform,c,a,e)}}function k(n,...r){if(o.apply(this,arguments)){var i,a,s,l,c=n.touches,u=c.length,d=E(this,r,n.changedTouches.length===u).event(n);for(Xn(n),a=0;a<u;++a)l=[l=Ee(s=c[a],this),this.__zoom.invert(l),s.identifier],d.touch0?d.touch1||d.touch0[2]===l[2]||(d.touch1=l,d.taps=0):(d.touch0=l,i=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(d.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),g)),fn(this),d.start())}}function P(e,...t){if(this.__zooming){var n,o,r,a,s=E(this,t).event(e),l=e.changedTouches,c=l.length;for(Yn(e),n=0;n<c;++n)r=Ee(o=l[n],this),s.touch0&&s.touch0[2]===o.identifier?s.touch0[0]=r:s.touch1&&s.touch1[2]===o.identifier&&(s.touch1[0]=r);if(o=s.that.__zoom,s.touch1){var d=s.touch0[0],h=s.touch0[1],f=s.touch1[0],g=s.touch1[1],p=(p=f[0]-d[0])*p+(p=f[1]-d[1])*p,m=(m=g[0]-h[0])*m+(m=g[1]-h[1])*m;o=x(o,Math.sqrt(p/m)),r=[(d[0]+f[0])/2,(d[1]+f[1])/2],a=[(h[0]+g[0])/2,(h[1]+g[1])/2]}else{if(!s.touch0)return;r=s.touch0[0],a=s.touch0[1]}s.zoom("touch",i(w(o,r,a),s.extent,u))}}function z(e,...o){if(this.__zooming){var r,i,a=E(this,o).event(e),s=e.changedTouches,l=s.length;for(Xn(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),g),r=0;r<l;++r)i=s[r],a.touch0&&a.touch0[2]===i.identifier?delete a.touch0:a.touch1&&a.touch1[2]===i.identifier&&delete a.touch1;if(a.touch1&&!a.touch0&&(a.touch0=a.touch1,delete a.touch1),a.touch0)a.touch0[1]=this.__zoom.invert(a.touch0[0]);else if(a.end(),2===a.taps&&(i=Ee(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<y)){var c=Se(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return v.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",Un),e!==r?S(e,t,n,o):r.interrupt().each((function(){E(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},v.scaleBy=function(e,t,n,o){v.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},v.scaleTo=function(e,t,n,o){v.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,a=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,s=o.invert(a),l="function"==typeof t?t.apply(this,arguments):t;return i(w(x(o,l),a,s),e,u)}),n,o)},v.translateBy=function(e,t,n,o){v.transform(e,(function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),u)}),null,o)},v.translateTo=function(e,t,n,o,a){v.transform(e,(function(){var e=r.apply(this,arguments),a=this.__zoom,s=null==o?b(e):"function"==typeof o?o.apply(this,arguments):o;return i(Vn.translate(s[0],s[1]).scale(a.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,u)}),o,a)},C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=Se(this.that).datum();f.call(e,this.that,new Bn(e,{sourceEvent:this.sourceEvent,target:v,type:e,transform:this.that.__zoom,dispatch:f}),t)}},v.wheelDelta=function(e){return arguments.length?(s="function"==typeof e?e:Tn(+e),v):s},v.filter=function(e){return arguments.length?(o="function"==typeof e?e:Tn(!!e),v):o},v.touchable=function(e){return arguments.length?(l="function"==typeof e?e:Tn(!!e),v):l},v.extent=function(e){return arguments.length?(r="function"==typeof e?e:Tn([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),v):r},v.scaleExtent=function(e){return arguments.length?(c[0]=+e[0],c[1]=+e[1],v):[c[0],c[1]]},v.translateExtent=function(e){return arguments.length?(u[0][0]=+e[0][0],u[1][0]=+e[1][0],u[0][1]=+e[0][1],u[1][1]=+e[1][1],v):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},v.constrain=function(e){return arguments.length?(i=e,v):i},v.duration=function(e){return arguments.length?(d=+e,v):d},v.interpolate=function(e){return arguments.length?(h=e,v):h},v.on=function(){var e=f.on.apply(f,arguments);return e===f?v:e},v.clickDistance=function(e){return arguments.length?(m=(e=+e)*e,v):Math.sqrt(m)},v.tapDistance=function(e){return arguments.length?(y=+e,v):y},v}Hn.prototype=jn.prototype;const Qn={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${n?o:n}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`},Jn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eo=["Enter"," ","Escape"];var to,no,oo,ro,io,ao;function so(e,t){if(!e&&!t)return!0;if(!e||!t||e.size!==t.size)return!1;if(!e.size&&!t.size)return!0;for(const n of e.keys())if(!t.has(n))return!1;return!0}function lo(e,t,n){if(!n)return;const o=[];e.forEach(((e,n)=>{t?.has(n)||o.push(e)})),o.length&&n(o)}e.ConnectionMode=void 0,(to=e.ConnectionMode||(e.ConnectionMode={})).Strict="strict",to.Loose="loose",e.PanOnScrollMode=void 0,(no=e.PanOnScrollMode||(e.PanOnScrollMode={})).Free="free",no.Vertical="vertical",no.Horizontal="horizontal",e.SelectionMode=void 0,(oo=e.SelectionMode||(e.SelectionMode={})).Partial="partial",oo.Full="full",e.ConnectionLineType=void 0,(ro=e.ConnectionLineType||(e.ConnectionLineType={})).Bezier="default",ro.Straight="straight",ro.Step="step",ro.SmoothStep="smoothstep",ro.SimpleBezier="simplebezier",e.MarkerType=void 0,(io=e.MarkerType||(e.MarkerType={})).Arrow="arrow",io.ArrowClosed="arrowclosed",e.Position=void 0,(ao=e.Position||(e.Position={})).Left="left",ao.Top="top",ao.Right="right",ao.Bottom="bottom";const co=e=>"id"in e&&"source"in e&&"target"in e,uo=(e,t=[0,0])=>{const{width:n,height:o}=Bo(e),r="internals"in e?e.internals.positionAbsolute:e.position,i=e.origin||t,a=n*i[0],s=o*i[1];return{position:{x:e.position.x-a,y:e.position.y-s},positionAbsolute:{x:r.x-a,y:r.y-s}}},ho=(e,t={nodeOrigin:[0,0]})=>{if(0===e.length)return{x:0,y:0,width:0,height:0};const n=e.reduce(((e,n)=>{const o=Mo(n,t.nodeOrigin);return So(e,o)}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Co(n)},fo=(e,t={nodeOrigin:[0,0]})=>{if(0===e.size)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach((e=>{if(null==t.filter||t.filter(e)){const o=Mo(e,t.nodeOrigin);n=So(n,o)}})),Co(n)},go=(e,t,[n,o,r]=[0,0,1],i=!1,a=!1,s=[0,0])=>{const l={...Do(t,[n,o,r]),width:t.width/r,height:t.height/r},c=[];for(const[,t]of e){const{measured:e,selectable:n=!0,hidden:o=!1}=t,r=e.width??t.width??t.initialWidth??null,u=e.height??t.height??t.initialHeight??null;if(a&&!n||o)continue;const d=ko(l,_o(t,s));(null===r||null===u||i&&d>0||d>=(r??0)*(u??0)||t.dragging)&&c.push(t)}return c},po=(e,t)=>{const n=new Set;return e.forEach((e=>{n.add(e.id)})),t.filter((e=>n.has(e.source)||n.has(e.target)))};function mo({nodeLookup:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i,nodeOrigin:a=[0,0]},s){const l=[],c=s?.nodes?new Set(s.nodes.map((e=>e.id))):null;if(e.forEach((e=>{!(e.measured.width&&e.measured.height&&(s?.includeHiddenNodes||!e.hidden))||c&&!c.has(e.id)||l.push(e)})),l.length>0){const e=ho(l,{nodeOrigin:a}),c=$o(e,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return o.setViewport(c,{duration:s?.duration}),!0}return!1}function yo({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const a=n.get(e),s=a.parentId?n.get(a.parentId):void 0,{x:l,y:c}=s?uo(s,s.origin||o).positionAbsolute:{x:0,y:0};let u=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.measured?.width??0),t[1][1]-(e.measured?.height??0)]]:t}(a,a.extent||r);if("parent"!==a.extent||a.expandParent)s&&To(a.extent)&&(u=[[a.extent[0][0]+l,a.extent[0][1]+c],[a.extent[1][0]+l,a.extent[1][1]+c]]);else if(s){const e=a.measured.width,t=a.measured.height,n=s.measured.width,r=s.measured.height;if(e&&t&&n&&r){const i=a.origin||o,s=l+e*i[0],d=c+t*i[1];u=[[s,d],[s+n-e,d+r-t]]}}else i?.("005",Qn.error005());const d=To(u)?xo(t,u):t;return{position:{x:d.x-l,y:d.y-c},positionAbsolute:d}}const vo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),xo=(e={x:0,y:0},t)=>({x:vo(e.x,t[0][0],t[1][0]),y:vo(e.y,t[0][1],t[1][1])}),wo=(e,t,n)=>e<t?vo(Math.abs(e-t),1,50)/50:e>n?-vo(Math.abs(e-n),1,50)/50:0,bo=(e,t)=>[20*wo(e.x,35,t.width-35),20*wo(e.y,35,t.height-35)],So=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Eo=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Co=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),_o=(e,t=[0,0])=>{const{x:n,y:o}=uo(e,t).positionAbsolute;return{x:n,y:o,width:e.measured?.width??e.width??0,height:e.measured?.height??e.height??0}},Mo=(e,t=[0,0])=>{const{x:n,y:o}=uo(e,t).positionAbsolute;return{x:n,y:o,x2:n+(e.measured?.width??e.width??0),y2:o+(e.measured?.height??e.height??0)}},No=(e,t)=>Co(So(Eo(e),Eo(t))),ko=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Po=e=>zo(e.width)&&zo(e.height)&&zo(e.x)&&zo(e.y),zo=e=>!isNaN(e)&&isFinite(e),Oo=(e,t)=>{},Io=({x:e,y:t,width:n,height:o,origin:r=[0,0]})=>!n||!o||r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:e,y:t}:{x:e-n*r[0],y:t-o*r[1]},Ao=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Do=({x:e,y:t},[n,o,r],i=!1,a=[1,1])=>{const s={x:(e-n)/r,y:(t-o)/r};return i?Ao(s,a):s},Ro=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),$o=(e,t,n,o,r,i)=>{const a=t/(e.width*(1+i)),s=n/(e.height*(1+i)),l=Math.min(a,s),c=vo(l,o,r);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},Lo=()=>"undefined"!=typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function To(e){return void 0!==e&&"parent"!==e}function Bo(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function jo(e){return void 0!==(e.measured?.width??e.width??e.initialWidth)&&void 0!==(e.measured?.height??e.height??e.initialHeight)}function Vo(e,t,n,o=[0,0]){let r=t;const i={...e};for(;r;){const e=n.get(r);if(r=e?.parentId,e){const t=e.origin||o,n=(e.measured.width??0)*t[0],r=(e.measured.height??0)*t[1];i.x+=e.position.x-n,i.y+=e.position.y-r}}return i}function Ho(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o}){const{x:r,y:i}=Fo(e),a=Do({x:r,y:i},o),{x:s,y:l}=n?Ao(a,t):a;return{xSnapped:s,ySnapped:l,...a}}const Xo=e=>({width:e.offsetWidth,height:e.offsetHeight}),Yo=e=>e.getRootNode?.()||window?.document,Zo=["INPUT","SELECT","TEXTAREA"];function Wo(e){const t=e.composedPath?.()?.[0]||e.target;return Zo.includes(t?.nodeName)||t?.hasAttribute("contenteditable")||!!t?.closest(".nokey")}const Uo=e=>"clientX"in e,Fo=(e,t)=>{const n=Uo(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Ko=(e,t,n,o,r=[0,0])=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const a=Array.from(i),s=n.left+n.width*r[0],l=n.top+n.height*r[1];return a.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-s)/o,y:(t.top-l)/o,...Xo(e)}}))};function Go({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s}){const l=.125*e+.375*r+.375*a+.125*n,c=.125*t+.375*i+.375*s+.125*o;return[l,c,Math.abs(l-e),Math.abs(c-t)]}function qo(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function Qo({pos:t,x1:n,y1:o,x2:r,y2:i,c:a}){switch(t){case e.Position.Left:return[n-qo(n-r,a),o];case e.Position.Right:return[n+qo(r-n,a),o];case e.Position.Top:return[n,o-qo(o-i,a)];case e.Position.Bottom:return[n,o+qo(i-o,a)]}}function Jo({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,curvature:s=.25}){const[l,c]=Qo({pos:o,x1:t,y1:n,x2:r,y2:i,c:s}),[u,d]=Qo({pos:a,x1:r,y1:i,x2:t,y2:n,c:s}),[h,f,g,p]=Go({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${t},${n} C${l},${c} ${u},${d} ${r},${i}`,h,f,g,p]}function er({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,a=Math.abs(o-t)/2;return[i,o<t?o+a:o-a,r,a]}function tr({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=So(Mo(e),Mo(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return ko(a,Co(i))>0}const nr=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,or=(e,t)=>{if(!e.source||!e.target)return t;let n;return n=co(e)?{...e}:{...e,id:nr(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:(null===n.sourceHandle&&delete n.sourceHandle,null===n.targetHandle&&delete n.targetHandle,t.concat(n))};function rr({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,a,s]=er({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,a,s]}const ir={[e.Position.Left]:{x:-1,y:0},[e.Position.Right]:{x:1,y:0},[e.Position.Top]:{x:0,y:-1},[e.Position.Bottom]:{x:0,y:1}},ar=({source:t,sourcePosition:n=e.Position.Bottom,target:o})=>n===e.Position.Left||n===e.Position.Right?t.x<o.x?{x:1,y:0}:{x:-1,y:0}:t.y<o.y?{x:0,y:1}:{x:0,y:-1},sr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function lr({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,borderRadius:s=5,centerX:l,centerY:c,offset:u=20}){const[d,h,f,g,p]=function({source:t,sourcePosition:n=e.Position.Bottom,target:o,targetPosition:r=e.Position.Top,center:i,offset:a}){const s=ir[n],l=ir[r],c={x:t.x+s.x*a,y:t.y+s.y*a},u={x:o.x+l.x*a,y:o.y+l.y*a},d=ar({source:c,sourcePosition:n,target:u}),h=0!==d.x?"x":"y",f=d[h];let g,p,m=[];const y={x:0,y:0},v={x:0,y:0},[x,w,b,S]=er({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(s[h]*l[h]==-1){g=i.x??x,p=i.y??w;const e=[{x:g,y:c.y},{x:g,y:u.y}],t=[{x:c.x,y:p},{x:u.x,y:p}];m=s[h]===f?"x"===h?e:t:"x"===h?t:e}else{const e=[{x:c.x,y:u.y}],i=[{x:u.x,y:c.y}];if(m="x"===h?s.x===f?i:e:s.y===f?e:i,n===r){const e=Math.abs(t[h]-o[h]);if(e<=a){const n=Math.min(a-1,a-e);s[h]===f?y[h]=(c[h]>t[h]?-1:1)*n:v[h]=(u[h]>o[h]?-1:1)*n}}if(n!==r){const t="x"===h?"y":"x",n=s[h]===l[t],o=c[t]>u[t],r=c[t]<u[t];(1===s[h]&&(!n&&o||n&&r)||1!==s[h]&&(!n&&r||n&&o))&&(m="x"===h?e:i)}const d={x:c.x+y.x,y:c.y+y.y},x={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(x.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(x.y-m[0].y))?(g=(d.x+x.x)/2,p=m[0].y):(g=m[0].x,p=(d.y+x.y)/2)}return[[t,{x:c.x+y.x,y:c.y+y.y},...m,{x:u.x+v.x,y:u.y+v.y},o],g,p,b,S]}({source:{x:t,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:a,center:{x:l,y:c},offset:u});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(sr(e,t)/2,sr(t,n)/2,o),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a)return`L ${i+r*(e.x<n.x?-1:1)},${a}Q ${i},${a} ${i},${a+r*(e.y<n.y?1:-1)}`;const s=e.x<n.x?1:-1;return`L ${i},${a+r*(e.y<n.y?-1:1)}Q ${i},${a} ${i+r*s},${a}`}(d[n-1],t,d[n+1],s):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),h,f,g,p]}function cr(e){return e&&!(!e.internals.handleBounds&&!e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ur(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,"source"===o.type?t.push(o):"target"===o.type&&n.push(o);return{source:t,target:n}}function dr(t,n,o=null){const r=(o?.x??0)+n.internals.positionAbsolute.x,i=(o?.y??0)+n.internals.positionAbsolute.y,{width:a,height:s}=o??Bo(n);switch(t){case e.Position.Top:return[r+a/2,i];case e.Position.Right:return[r+a,i+s/2];case e.Position.Bottom:return[r+a/2,i+s];case e.Position.Left:return[r,i+s/2]}}function hr(e,t){return e&&(t?e.find((e=>e.id===t)):e[0])||null}function fr(e,t){if(!e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`}function gr(t,n,o,r,i){let a=.5;"start"===i?a=0:"end"===i&&(a=1);let s=[(t.x+t.width*a)*n.zoom+n.x,t.y*n.zoom+n.y-r],l=[-100*a,-100];switch(o){case e.Position.Right:s=[(t.x+t.width)*n.zoom+n.x+r,(t.y+t.height*a)*n.zoom+n.y],l=[0,-100*a];break;case e.Position.Bottom:s[1]=(t.y+t.height)*n.zoom+n.y+r,l[1]=0;break;case e.Position.Left:s=[t.x*n.zoom+n.x-r,(t.y+t.height*a)*n.zoom+n.y],l=[-100,-100*a]}return`translate(${s[0]}px, ${s[1]}px) translate(${l[0]}%, ${l[1]}%)`}function pr(e,t={nodeOrigin:[0,0],elevateNodesOnSelect:!0,defaults:{}}){const n=t?.elevateNodesOnSelect?1e3:0;for(const[,o]of e){const r=o.parentId;if(!r)continue;if(!e.has(r))throw new Error(`Parent node ${r} not found`);const i=e.get(r),{x:a,y:s,z:l}=yr(o,e,{...o.position,z:(zo(o.zIndex)?o.zIndex:0)+(o.selected?n:0)},i?.origin??t.nodeOrigin),c=o.internals.positionAbsolute,u=a!==c.x||s!==c.y;(u||l!==o.internals.z)&&(o.internals={...o.internals,positionAbsolute:u?{x:a,y:s}:c,z:l})}}function mr(e,t,n,o={nodeOrigin:[0,0],elevateNodesOnSelect:!0,defaults:{},checkEquality:!0}){const r=new Map(t);t.clear(),n.clear();const i=o?.elevateNodesOnSelect?1e3:0;e.forEach((e=>{let a=r.get(e.id);if(o.checkEquality&&e===a?.internals.userNode||(a={...o.defaults,...e,measured:{width:e.measured?.width,height:e.measured?.height},internals:{positionAbsolute:e.position,handleBounds:a?.internals.handleBounds,z:(zo(e.zIndex)?e.zIndex:0)+(e.selected?i:0),userNode:e}}),t.set(e.id,a),e.parentId){const t=n.get(e.parentId);t?t.push(a):n.set(e.parentId,[a])}})),n.size>0&&pr(t,o)}function yr(e,t,n,o=[0,0]){if(!e.parentId)return n;const r=t.get(e.parentId),i=uo(r,o).position;return yr(r,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(r.internals.z??0)>(n.z??0)?r.internals.z??0:n.z??0},r.origin||o)}function vr(e,t,n,o){const r=[],i=new Map;for(const n of e){const e=t.get(n.parentId);if(!e)continue;const r=i.get(n.parentId)?.expandedRect??_o(e,e.origin??o),a=No(r,n.rect);i.set(n.parentId,{expandedRect:a,parent:e})}return i.size>0&&i.forEach((({expandedRect:t,parent:o},i)=>{const{position:a}=uo(o,o.origin),s=Bo(o),l=t.x<a.x?Math.round(Math.abs(a.x-t.x)):0,c=t.y<a.y?Math.round(Math.abs(a.y-t.y)):0;if(l>0||c>0){r.push({id:i,type:"position",position:{x:a.x-l,y:a.y-c}});const t=n.get(i);t?.forEach((t=>{e.some((e=>e.id===t.id))||r.push({id:t.id,type:"position",position:{x:t.position.x+l,y:t.position.y+c}})}))}(s.width<t.width||s.height<t.height)&&r.push({id:i,type:"dimensions",setAttributes:!0,dimensions:{width:Math.max(s.width,Math.round(t.width)),height:Math.max(s.height,Math.round(t.height))}})})),r}function xr(e,t,n){e.clear(),t.clear();for(const o of n){const{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=o,s=`${n}-source-${i}`,l=`${r}-target-${a}`,c=e.get(s)||new Map,u=e.get(l)||new Map,d={edgeId:o.id,source:n,target:r,sourceHandle:i,targetHandle:a};t.set(o.id,o),e.set(s,c.set(`${r}-${a}`,d)),e.set(l,u.set(`${n}-${i}`,d))}}function wr(e,t){if(null===e||null===t)return!1;const n=Array.isArray(e)?e:[e],o=Array.isArray(t)?t:[t];if(n.length!==o.length)return!1;for(let e=0;e<n.length;e++)if(n[e].id!==o[e].id||n[e].type!==o[e].type||!Object.is(n[e].data,o[e].data))return!1;return!0}function br(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return!!n&&(!!n.selected||br(n,t))}function Sr(e,t,n){let o=e;do{if(o?.matches(t))return!0;if(o===n)return!1;o=o.parentElement}while(o);return!1}function Er({nodeId:e,dragItems:t,nodeLookup:n}){const o=[];for(const[e,r]of t){const t=n.get(e)?.internals.userNode;t&&o.push({...t,position:r.position})}if(!e)return[o[0],o];const r=n.get(e).internals.userNode;return[{...r,position:t.get(e)?.position||r.position},o]}function Cr({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},a=0,s=new Map,l=!1,c={x:0,y:0},u=null,d=!1,h=null,f=!1;return{update:function({noDragClassName:g,handleSelector:p,domNode:m,isSelectable:y,nodeId:v}){function x({x:e,y:n},r){const{nodeLookup:a,nodeExtent:l,snapGrid:c,snapToGrid:u,nodeOrigin:d,onNodeDrag:h,onSelectionDrag:f,onError:g,updateNodePositions:p}=t();i={x:e,y:n};let m=!1,y={x:0,y:0,x2:0,y2:0};if(s.size>1&&l){const e=fo(s,{nodeOrigin:d});y=Eo(e)}for(const[t,o]of s){let r={x:e-o.distance.x,y:n-o.distance.y};u&&(r=Ao(r,c));let i=[[l[0][0],l[0][1]],[l[1][0],l[1][1]]];if(s.size>1&&l&&!o.extent){const{positionAbsolute:e}=o.internals,t=e.x-y.x+l[0][0],n=e.x+o.measured.width-y.x2+l[1][0];i=[[t,e.y-y.y+l[0][1]],[n,e.y+o.measured.height-y.y2+l[1][1]]]}const{position:h,positionAbsolute:f}=yo({nodeId:t,nextPosition:r,nodeLookup:a,nodeExtent:i,nodeOrigin:d,onError:g});m=m||o.position.x!==h.x||o.position.y!==h.y,o.position=h,o.internals.positionAbsolute=f}if(m&&(p(s,!0),r&&(o||h||!v&&f))){const[e,t]=Er({nodeId:v,dragItems:s,nodeLookup:a});o?.(r,s,e,t),h?.(r,e,t),v||f?.(r,t)}}function w(){if(!u)return;const[e,n]=bo(c,u);if(0!==e||0!==n){const{transform:o,panBy:r}=t();i.x=(i.x??0)-e/o[2],i.y=(i.y??0)-n/o[2],r({x:e,y:n})&&x(i,null)}a=requestAnimationFrame(w)}function b(o){const{nodeLookup:r,multiSelectionActive:a,nodesDraggable:l,transform:c,snapGrid:u,snapToGrid:h,selectNodesOnDrag:f,onNodeDragStart:g,onSelectionDragStart:p,unselectNodesAndEdges:m}=t();d=!0,f&&y||a||!v||r.get(v)?.selected||m(),y&&f&&v&&e?.(v);const x=Ho(o.sourceEvent,{transform:c,snapGrid:u,snapToGrid:h});if(i=x,s=function(e,t,n,o){const r=new Map;for(const[i,a]of e)if((a.selected||a.id===o)&&(!a.parentId||!br(a,e))&&(a.draggable||t&&void 0===a.draggable)){const t=e.get(i);t&&r.set(i,{id:i,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return r}(r,l,x,v),s.size>0&&(n||g||!v&&p)){const[e,t]=Er({nodeId:v,dragItems:s,nodeLookup:r});n?.(o.sourceEvent,s,e,t),g?.(o.sourceEvent,e,t),v||p?.(o.sourceEvent,t)}}h=Se(m);const S=$e().on("start",(e=>{const{domNode:n,nodeDragThreshold:o,transform:r,snapGrid:a,snapToGrid:s}=t();f=!1,0===o&&b(e);const l=Ho(e.sourceEvent,{transform:r,snapGrid:a,snapToGrid:s});i=l,u=n?.getBoundingClientRect()||null,c=Fo(e.sourceEvent,u)})).on("drag",(e=>{const{autoPanOnNodeDrag:n,transform:o,snapGrid:r,snapToGrid:a,nodeDragThreshold:h}=t(),g=Ho(e.sourceEvent,{transform:o,snapGrid:r,snapToGrid:a});if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(f=!0),!f){if(!l&&n&&d&&(l=!0,w()),!d){const t=g.xSnapped-(i.x??0),n=g.ySnapped-(i.y??0);Math.sqrt(t*t+n*n)>h&&b(e)}(i.x!==g.xSnapped||i.y!==g.ySnapped)&&s&&d&&(c=Fo(e.sourceEvent,u),x(g,e.sourceEvent))}})).on("end",(e=>{if(d&&!f&&(l=!1,d=!1,cancelAnimationFrame(a),s.size>0)){const{nodeLookup:n,updateNodePositions:o,onNodeDragStop:i,onSelectionDragStop:a}=t();if(o(s,!1),r||i||!v&&a){const[t,o]=Er({nodeId:v,dragItems:s,nodeLookup:n});r?.(e.sourceEvent,s,t,o),i?.(e.sourceEvent,t,o),v||a?.(e.sourceEvent,o)}}})).filter((e=>{const t=e.target;return!e.button&&(!g||!Sr(t,`.${g}`,m))&&(!p||Sr(t,p,m))}));h.call(S)},destroy:function(){h?.on(".drag",null)}}}function _r(e,t,n,o){return(t[n]||[]).reduce(((t,r)=>(`${e.id}-${r.id}-${n}`!==o&&t.push({id:r.id||null,type:n,nodeId:e.id,x:e.internals.positionAbsolute.x+r.x+r.width/2,y:e.internals.positionAbsolute.y+r.y+r.height/2}),t)),[])}function Mr(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Nr(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}const kr=()=>!0;let Pr=null;function zr(t,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:a,doc:s,lib:l,flowId:c,isValidConnection:u=kr}){const d="target"===a,h=n?s.querySelector(`.${l}-flow__handle[data-id="${c}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:f,y:g}=Fo(t),p=s.elementFromPoint(f,g),m=p?.classList.contains(`${l}-flow__handle`)?p:h,y={handleDomNode:m,isValid:!1,connection:null,endHandle:null};if(m){const t=Mr(void 0,m),n=m.getAttribute("data-nodeid"),a=m.getAttribute("data-handleid"),s=m.classList.contains("connectable"),l=m.classList.contains("connectableend");if(!n)return y;const c={source:d?n:r,sourceHandle:d?a:i,target:d?r:n,targetHandle:d?i:a};y.connection=c;s&&l&&(o===e.ConnectionMode.Strict?d&&"source"===t||!d&&"target"===t:n!==r||a!==i)&&(y.endHandle={nodeId:n,handleId:a,type:t},y.isValid=u(c))}return y}const Or={onPointerDown:function(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:a,domNode:s,nodeLookup:l,lib:c,autoPanOnConnect:u,flowId:d,panBy:h,cancelConnection:f,onConnectStart:g,onConnect:p,onConnectEnd:m,isValidConnection:y=kr,onEdgeUpdateEnd:v,updateConnection:x,getTransform:w,getConnectionStartHandle:b}){const S=Yo(e.target);let E,C=0;const{x:_,y:M}=Fo(e),N=S?.elementFromPoint(_,M),k=Mr(i,N),P=s?.getBoundingClientRect();if(!P||!k)return;let z=Fo(e,P),O=!1,I=null,A=!1,D=null;const R=function({nodeLookup:e,nodeId:t,handleId:n,handleType:o}){const r=[];for(const[,i]of e)if(i.internals.handleBounds){const e=`${t}-${n}-${o}`,a=_r(i,i.internals.handleBounds,"source",e),s=_r(i,i.internals.handleBounds,"target",e);r.push(...a,...s)}return r}({nodeLookup:l,nodeId:r,handleId:o,handleType:k});function $(){if(!u||!P)return;const[e,t]=bo(z,P);h({x:e,y:t}),C=requestAnimationFrame($)}function L(e){b()||T(e);const i=w();z=Fo(e,P),E=function(e,t,n){let o=[],r=1/0;for(const i of n){const n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));n<=t&&(n<r?o=[i]:n===r&&o.push(i),r=n)}return o.length?1===o.length?o[0]:o.find((e=>"target"===e.type))||o[0]:null}(Do(z,i,!1,[1,1]),n,R),O||($(),O=!0);const s=zr(e,{handle:E,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:a?"target":"source",isValidConnection:y,doc:S,lib:c,flowId:d});D=s.handleDomNode,I=s.connection,A=s.isValid,x({connectionStartHandle:Pr,connectionPosition:E&&A?Ro({x:E.x,y:E.y},i):z,connectionStatus:Nr(!!E,A),connectionEndHandle:s.endHandle})}function T(e){(E||D)&&I&&A&&p?.(I),m?.(e),i&&v?.(e),f(),cancelAnimationFrame(C),O=!1,A=!1,I=null,D=null,Pr=null,S.removeEventListener("mousemove",L),S.removeEventListener("mouseup",T),S.removeEventListener("touchmove",L),S.removeEventListener("touchend",T)}Pr={nodeId:r,handleId:o,type:k},x({connectionPosition:z,connectionStatus:null,connectionStartHandle:Pr,connectionEndHandle:null}),g?.(e,{nodeId:r,handleId:o,handleType:k}),S.addEventListener("mousemove",L),S.addEventListener("mouseup",T),S.addEventListener("touchmove",L),S.addEventListener("touchend",T)},isValid:zr};const Ir=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Ar=e=>({x:e.x,y:e.y,zoom:e.k}),Dr=({x:e,y:t,zoom:n})=>Vn.translate(e,t).scale(n),Rr=(e,t)=>e.target.closest(`.${t}`),$r=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),Lr=(e,t=0)=>"number"==typeof t&&t>0?e.transition().duration(t):e,Tr=e=>{const t=e.ctrlKey&&Lo()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t};function Br({domNode:t,minZoom:n,maxZoom:o,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:s,onPanZoomEnd:l,onTransformChange:c,onDraggingChange:u}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=t.getBoundingClientRect(),f=qn().scaleExtent([n,o]).translateExtent(r),g=Se(t).call(f);x({x:i.x,y:i.y,zoom:vo(i.zoom,n,o)},[[0,0],[h.width,h.height]],r);const p=g.on("wheel.zoom"),m=g.on("dblclick.zoom");function y(e,t){g&&f?.transform(Lr(g,t?.duration),e)}function v(){f.on("zoom",null)}function x(e,t,n){const o=Dr(e),r=f?.constrain()(o,t,n);return r&&y(r),r}return f.wheelDelta(Tr),{update:function({noWheelClassName:t,noPanClassName:n,onPaneContextMenu:o,userSelectionActive:r,panOnScroll:i,panOnDrag:h,panOnScrollMode:y,panOnScrollSpeed:x,preventScrolling:w,zoomOnPinch:b,zoomOnScroll:S,zoomOnDoubleClick:E,zoomActivationKeyPressed:C,lib:_}){r&&!d.isZoomingOrPanning&&v();const M=i&&!C&&!r?function({zoomPanValues:t,noWheelClassName:n,d3Selection:o,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:s,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Rr(d,n))return!1;d.preventDefault(),d.stopImmediatePropagation();const h=o.property("__zoom").k||1;if(d.ctrlKey&&s){const e=Ee(d),t=Tr(d),n=h*Math.pow(2,t);return void r.scaleTo(o,n,e,d)}const f=1===d.deltaMode?20:1;let g=i===e.PanOnScrollMode.Vertical?0:d.deltaX*f,p=i===e.PanOnScrollMode.Horizontal?0:d.deltaY*f;!Lo()&&d.shiftKey&&i!==e.PanOnScrollMode.Vertical&&(g=d.deltaY*f,p=0),r.translateBy(o,-g/h*a,-p/h*a,{internal:!0});const m=Ar(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling||(t.isPanScrolling=!0,l?.(d,m)),t.isPanScrolling&&(c?.(d,m),t.panScrollTimeout=setTimeout((()=>{u?.(d,m),t.isPanScrolling=!1}),150))}}({zoomPanValues:d,noWheelClassName:t,d3Selection:g,d3Zoom:f,panOnScrollMode:y,panOnScrollSpeed:x,zoomOnPinch:b,onPanZoomStart:s,onPanZoom:a,onPanZoomEnd:l}):function({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){if(!t&&"wheel"===o.type&&!o.ctrlKey||Rr(o,e))return null;o.preventDefault(),n.call(this,o,r)}}({noWheelClassName:t,preventScrolling:w,d3ZoomHandler:p});if(g.on("wheel.zoom",M,{passive:!1}),!r){const e=function({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=Ar(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,"mousedown"===o.sourceEvent?.type&&t(!0),n&&n?.(o.sourceEvent,r)}}({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:s});f.on("start",e);const t=function({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!(!n||!$r(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,Ar(i.transform))}}({zoomPanValues:d,panOnDrag:h,onPaneContextMenu:!!o,onPanZoom:a,onTransformChange:c});f.on("zoom",t);const n=function({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&$r(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,o(!1),r&&Ir(e.prevViewport,a.transform))){const t=Ar(a.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout((()=>{r?.(a.sourceEvent,t)}),n?150:0)}}}({zoomPanValues:d,panOnDrag:h,panOnScroll:i,onPaneContextMenu:o,onPanZoomEnd:l,onDraggingChange:u});f.on("end",n)}const N=function({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:s,noPanClassName:l,lib:c}){return u=>{const d=e||t,h=n&&u.ctrlKey;if(1===u.button&&"mousedown"===u.type&&(Rr(u,`${c}-flow__node`)||Rr(u,`${c}-flow__edge`)))return!0;if(!(o||d||r||i||n))return!1;if(a)return!1;if(Rr(u,s)&&"wheel"===u.type)return!1;if(Rr(u,l)&&("wheel"!==u.type||r&&"wheel"===u.type&&!e))return!1;if(!n&&u.ctrlKey&&"wheel"===u.type)return!1;if(!n&&"touchstart"===u.type&&u.touches?.length>1)return u.preventDefault(),!1;if(!d&&!r&&!h&&"wheel"===u.type)return!1;if(!o&&("mousedown"===u.type||"touchstart"===u.type))return!1;if(Array.isArray(o)&&!o.includes(u.button)&&"mousedown"===u.type)return!1;const f=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||"wheel"===u.type)&&f}}({zoomActivationKeyPressed:C,panOnDrag:h,zoomOnScroll:S,panOnScroll:i,zoomOnDoubleClick:E,zoomOnPinch:b,userSelectionActive:r,noPanClassName:n,noWheelClassName:t,lib:_});f.filter(N),E?g.on("dblclick.zoom",m):g.on("dblclick.zoom",null)},destroy:v,setViewport:function(e,t){const n=Dr(e);return y(n,t),n},setViewportConstrained:x,getViewport:function(){const e=g?Hn(g.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},scaleTo:function(e,t){g&&f?.scaleTo(Lr(g,t?.duration),e)},scaleBy:function(e,t){g&&f?.scaleBy(Lr(g,t?.duration),e)},setScaleExtent:function(e){f?.scaleExtent(e)},setTranslateExtent:function(e){f?.translateExtent(e)},syncViewport:function(e){if(g){const t=Dr(e),n=g.property("__zoom");n.k===e.zoom&&n.x===e.x&&n.y===e.y||f?.transform(g,t,null,{sync:!0})}}}}var jr;!function(e){e.Line="line",e.Handle="handle"}(jr||(jr={}));const Vr=["top-left","top-right","bottom-left","bottom-right"],Hr=["top","right","bottom","left"];function Xr(e,t){return Math.max(0,t-e)}function Yr(e,t){return Math.max(0,e-t)}function Zr(e,t,n){return Math.max(0,t-e,e-n)}function Wr(e,t){return e?!t:t}const Ur={width:0,height:0,x:0,y:0},Fr={...Ur,pointerX:0,pointerY:0,aspectRatio:1};function Kr(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,s=n[0]*i,l=n[1]*a;return[[o-s,r-l],[o+i-s,r+a-l]]}function Gr({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=Se(e);return{update:function({controlPosition:e,boundaries:a,keepAspectRatio:s,onResizeStart:l,onResize:c,onResizeEnd:u,shouldResize:d}){let h={...Ur},f={...Fr};const g=function(e){return{isHorizontal:e.includes("right")||e.includes("left"),isVertical:e.includes("bottom")||e.includes("top"),affectsX:e.includes("left"),affectsY:e.includes("top")}}(e);let p,m,y,v,x=[];const w=$e().on("start",(e=>{const{nodeLookup:o,transform:r,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n();if(p=o.get(t),!p)return;const{xSnapped:c,ySnapped:u}=Ho(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:a});h={width:p.measured?.width??0,height:p.measured?.height??0,x:p.position.x??0,y:p.position.y??0},f={...h,pointerX:c,pointerY:u,aspectRatio:h.width/h.height},m=void 0,("parent"===p.extent||p.expandParent)&&(m=o.get(p.parentId),m&&"parent"===p.extent&&(y=function(e){return[[0,0],[e.measured.width,e.measured.height]]}(m))),x=[],v=void 0;for(const[e,n]of o)if(n.parentId===t&&(x.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){const e=Kr(n,p,n.origin??s);v=v?[[Math.min(e[0][0],v[0][0]),Math.min(e[0][1],v[0][1])],[Math.max(e[1][0],v[1][0]),Math.max(e[1][1],v[1][1])]]:e}l?.(e,{...h})})).on("drag",(e=>{const{transform:t,snapGrid:r,snapToGrid:i,nodeOrigin:l}=n(),u=Ho(e.sourceEvent,{transform:t,snapGrid:r,snapToGrid:i}),w=[];if(!p)return;const{x:b,y:S,width:E,height:C}=h,_={},M=p.origin??l,{width:N,height:k,x:P,y:z}=function(e,t,n,o,r,i,a,s){let{affectsX:l,affectsY:c}=t;const{isHorizontal:u,isVertical:d}=t,h=u&&d,{xSnapped:f,ySnapped:g}=n,{minWidth:p,maxWidth:m,minHeight:y,maxHeight:v}=o,{x:x,y:w,width:b,height:S,aspectRatio:E}=e;let C=Math.floor(u?f-e.pointerX:0),_=Math.floor(d?g-e.pointerY:0);const M=b+(l?-C:C),N=S+(c?-_:_),k=-i[0]*b,P=-i[1]*S;let z=Zr(M,p,m),O=Zr(N,y,v);if(a){let e=0,t=0;l&&C<0?e=Xr(x+C+k,a[0][0]):!l&&C>0&&(e=Yr(x+M+k,a[1][0])),c&&_<0?t=Xr(w+_+P,a[0][1]):!c&&_>0&&(t=Yr(w+N+P,a[1][1])),z=Math.max(z,e),O=Math.max(O,t)}if(s){let e=0,t=0;l&&C>0?e=Yr(x+C,s[0][0]):!l&&C<0&&(e=Xr(x+M,s[1][0])),c&&_>0?t=Yr(w+_,s[0][1]):!c&&_<0&&(t=Xr(w+N,s[1][1])),z=Math.max(z,e),O=Math.max(O,t)}if(r){if(u){const e=Zr(M/E,y,v)*E;if(z=Math.max(z,e),a){let e=0;e=!l&&!c||l&&!c&&h?Yr(w+P+M/E,a[1][1])*E:Xr(w+P+(l?C:-C)/E,a[0][1])*E,z=Math.max(z,e)}if(s){let e=0;e=!l&&!c||l&&!c&&h?Xr(w+M/E,s[1][1])*E:Yr(w+(l?C:-C)/E,s[0][1])*E,z=Math.max(z,e)}}if(d){const e=Zr(N*E,p,m)/E;if(O=Math.max(O,e),a){let e=0;e=!l&&!c||c&&!l&&h?Yr(x+N*E+k,a[1][0])/E:Xr(x+(c?_:-_)*E+k,a[0][0])/E,O=Math.max(O,e)}if(s){let e=0;e=!l&&!c||c&&!l&&h?Xr(x+N*E,s[1][0])/E:Yr(x+(c?_:-_)*E,s[0][0])/E,O=Math.max(O,e)}}}_+=_<0?O:-O,C+=C<0?z:-z,r&&(h?M>N*E?_=(Wr(l,c)?-C:C)/E:C=(Wr(l,c)?-_:_)*E:u?(_=C/E,c=l):(C=_*E,l=c));const I=l?x+C:x,A=c?w+_:w;return{width:b+(l?-C:C),height:S+(c?-_:_),x:i[0]*C*(l?-1:1)+I,y:i[1]*_*(c?-1:1)+A}}(f,g,u,a,s,M,y,v),O=N!==E,I=k!==C,A=P!==b&&O,D=z!==S&&I;if(!(A||D||O||I))return;if((A||D||1===M[0]||1==M[1])&&(_.x=A?P:h.x,_.y=D?z:h.y,h.x=_.x,h.y=_.y,m&&p.expandParent&&(_.x&&_.x<0&&(h.x=0,f.x=f.x-_.x),_.y&&_.y<0&&(h.y=0,f.y=f.y-_.y)),x.length>0)){const e=P-b,t=z-S;for(const n of x)n.position={x:n.position.x-e+M[0]*(N-E),y:n.position.y-t+M[1]*(k-C)},w.push(n)}(O||I)&&(_.width=O?N:h.width,_.height=I?k:h.height,h.width=_.width,h.height=_.height);const R=function({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const a=e-t,s=n-o,l=[a>0?1:a<0?-1:0,s>0?1:s<0?-1:0];return a&&r&&(l[0]=-1*l[0]),s&&i&&(l[1]=-1*l[1]),l}({width:h.width,prevWidth:E,height:h.height,prevHeight:C,affectsX:g.affectsX,affectsY:g.affectsY}),$={...h,direction:R},L=d?.(e,$);!1!==L&&(c?.(e,$),o(_,w))})).on("end",(e=>{u?.(e,{...h}),r?.()}));i.call(w)},destroy:function(){i.on(".drag",null)}}}function qr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qr,Jr,ei,ti={exports:{}},ni={},oi={exports:{}},ri={};function ii(){return Jr||(Jr=1,oi.exports=function(){if(Qr)return ri;Qr=1;var e=n,t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=e.useState,r=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function s(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!t(e,o)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),l=o({inst:{value:n,getSnapshot:t}}),c=l[0].inst,u=l[1];return i((function(){c.value=n,c.getSnapshot=t,s(c)&&u({inst:c})}),[e,n,t]),r((function(){return s(c)&&u({inst:c}),e((function(){s(c)&&u({inst:c})}))}),[e]),a(n),n};return ri.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,ri}()),oi.exports}
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactFlow={},e.jsxRuntime,e.React,e.ReactDOM)}(this,(function(e,t,n,o){"use strict";function r(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=r(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var i={value:()=>{}};function a(){for(var e,t=0,n=arguments.length,o={};t<n;++t){if(!(e=arguments[t]+"")||e in o||/[\s.]/.test(e))throw new Error("illegal type: "+e);o[e]=[]}return new s(o)}function s(e){this._=e}function l(e,t){for(var n,o=0,r=e.length;o<r;++o)if((n=e[o]).name===t)return n.value}function c(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=i,e=e.slice(0,o).concat(e.slice(o+1));break}return null!=n&&e.push({name:t,value:n}),e}s.prototype=a.prototype={constructor:s,on:function(e,t){var n,o,r=this._,i=(o=r,(e+"").trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!o.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++a<s;)if(n=(e=i[a]).type)r[n]=c(r[n],e.name,t);else if(null==t)for(n in r)r[n]=c(r[n],e.name,null);return this}for(;++a<s;)if((n=(e=i[a]).type)&&(n=l(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new s(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,o,r=new Array(n),i=0;i<n;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(o=this._[e]).length;i<n;++i)o[i].value.apply(t,r)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};var u="http://www.w3.org/1999/xhtml",d={svg:"http://www.w3.org/2000/svg",xhtml:u,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function h(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),d.hasOwnProperty(t)?{space:d[t],local:e}:e}function f(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===u&&t.documentElement.namespaceURI===u?t.createElement(e):t.createElementNS(n,e)}}function g(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function p(e){var t=h(e);return(t.local?g:f)(t)}function m(){}function y(e){return null==e?m:function(){return this.querySelector(e)}}function v(){return[]}function x(e){return null==e?v:function(){return this.querySelectorAll(e)}}function w(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}function b(e){return function(){return this.matches(e)}}function S(e){return function(t){return t.matches(e)}}var E=Array.prototype.find;function C(){return this.firstElementChild}var _=Array.prototype.filter;function M(){return Array.from(this.children)}function N(e){return new Array(e.length)}function k(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function P(e,t,n,o,r,i){for(var a,s=0,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new k(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function z(e,t,n,o,r,i,a){var s,l,c,u=new Map,d=t.length,h=i.length,f=new Array(d);for(s=0;s<d;++s)(l=t[s])&&(f[s]=c=a.call(l,l.__data__,s,t)+"",u.has(c)?r[s]=l:u.set(c,l));for(s=0;s<h;++s)c=a.call(e,i[s],s,i)+"",(l=u.get(c))?(o[s]=l,l.__data__=i[s],u.delete(c)):n[s]=new k(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&u.get(f[s])===l&&(r[s]=l)}function O(e){return e.__data__}function I(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function A(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function R(e){return function(){this.removeAttribute(e)}}function D(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $(e,t){return function(){this.setAttribute(e,t)}}function L(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function T(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function B(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function j(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function V(e){return function(){this.style.removeProperty(e)}}function H(e,t,n){return function(){this.style.setProperty(e,t,n)}}function X(e,t,n){return function(){var o=t.apply(this,arguments);null==o?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Y(e,t){return e.style.getPropertyValue(t)||j(e).getComputedStyle(e,null).getPropertyValue(t)}function Z(e){return function(){delete this[e]}}function W(e,t){return function(){this[e]=t}}function F(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function K(e){return e.trim().split(/^|\s+/)}function G(e){return e.classList||new q(e)}function q(e){this._node=e,this._names=K(e.getAttribute("class")||"")}function U(e,t){for(var n=G(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Q(e,t){for(var n=G(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function J(e){return function(){U(this,e)}}function ee(e){return function(){Q(this,e)}}function te(e,t){return function(){(t.apply(this,arguments)?U:Q)(this,e)}}function ne(){this.textContent=""}function oe(e){return function(){this.textContent=e}}function re(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function ie(){this.innerHTML=""}function ae(e){return function(){this.innerHTML=e}}function se(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function le(){this.nextSibling&&this.parentNode.appendChild(this)}function ce(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ue(){return null}function de(){var e=this.parentNode;e&&e.removeChild(this)}function he(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ge(e){return function(){var t=this.__on;if(t){for(var n,o=0,r=-1,i=t.length;o<i;++o)n=t[o],e.type&&n.type!==e.type||n.name!==e.name?t[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?t.length=r:delete this.__on}}}function pe(e,t,n){return function(){var o,r=this.__on,i=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(r)for(var a=0,s=r.length;a<s;++a)if((o=r[a]).type===e.type&&o.name===e.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=t);this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function me(e,t,n){var o=j(e),r=o.CustomEvent;"function"==typeof r?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function ye(e,t){return function(){return me(this,e,t)}}function ve(e,t){return function(){return me(this,e,t.apply(this,arguments))}}k.prototype={constructor:k,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}},q.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var xe=[null];function we(e,t){this._groups=e,this._parents=t}function be(){return new we([[document.documentElement]],xe)}function Se(e){return"string"==typeof e?new we([[document.querySelector(e)]],[document.documentElement]):new we([[e]],xe)}function Ee(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,[(o=o.matrixTransform(t.getScreenCTM().inverse())).x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}we.prototype=be.prototype={constructor:we,select:function(e){"function"!=typeof e&&(e=y(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a,s=t[r],l=s.length,c=o[r]=new Array(l),u=0;u<l;++u)(i=s[u])&&(a=e.call(i,i.__data__,u,s))&&("__data__"in i&&(a.__data__=i.__data__),c[u]=a);return new we(o,this._parents)},selectAll:function(e){e="function"==typeof e?w(e):x(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var a,s=t[i],l=s.length,c=0;c<l;++c)(a=s[c])&&(o.push(e.call(a,a.__data__,c,s)),r.push(a));return new we(o,r)},selectChild:function(e){return this.select(null==e?C:function(e){return function(){return E.call(this.children,e)}}("function"==typeof e?e:S(e)))},selectChildren:function(e){return this.selectAll(null==e?M:function(e){return function(){return _.call(this.children,e)}}("function"==typeof e?e:S(e)))},filter:function(e){"function"!=typeof e&&(e=b(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a=t[r],s=a.length,l=o[r]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&l.push(i);return new we(o,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,O);var n,o=t?z:P,r=this._parents,i=this._groups;"function"!=typeof e&&(n=e,e=function(){return n});for(var a=i.length,s=new Array(a),l=new Array(a),c=new Array(a),u=0;u<a;++u){var d=r[u],h=i[u],f=h.length,g=I(e.call(d,d&&d.__data__,u,r)),p=g.length,m=l[u]=new Array(p),y=s[u]=new Array(p);o(d,h,m,y,c[u]=new Array(f),g,t);for(var v,x,w=0,b=0;w<p;++w)if(v=m[w]){for(w>=b&&(b=w+1);!(x=y[b])&&++b<p;);v._next=x||null}}return(s=new we(s,r))._enter=l,s._exit=c,s},enter:function(){return new we(this._enter||this._groups.map(N),this._parents)},exit:function(){return new we(this._exit||this._groups.map(N),this._parents)},join:function(e,t,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof e?(o=e(o))&&(o=o.selection()):o=o.append(e+""),null!=t&&(r=t(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c,u=n[l],d=o[l],h=u.length,f=s[l]=new Array(h),g=0;g<h;++g)(c=u[g]||d[g])&&(f[g]=c);for(;l<r;++l)s[l]=n[l];return new we(s,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o,r=e[t],i=r.length-1,a=r[i];--i>=0;)(o=r[i])&&(a&&4^o.compareDocumentPosition(a)&&a.parentNode.insertBefore(o,a),a=o);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=A);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var a,s=n[i],l=s.length,c=r[i]=new Array(l),u=0;u<l;++u)(a=s[u])&&(c[u]=a);c.sort(t)}return new we(r,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var a=o[r];if(a)return a}return null},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r,i=t[n],a=0,s=i.length;a<s;++a)(r=i[a])&&e.call(r,r.__data__,a,i);return this},attr:function(e,t){var n=h(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==t?n.local?D:R:"function"==typeof t?n.local?B:T:n.local?L:$)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?V:"function"==typeof t?X:H)(e,t,null==n?"":n)):Y(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?Z:"function"==typeof t?F:W)(e,t)):this.node()[e]},classed:function(e,t){var n=K(e+"");if(arguments.length<2){for(var o=G(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof t?te:t?J:ee)(n,t))},text:function(e){return arguments.length?this.each(null==e?ne:("function"==typeof e?re:oe)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?ie:("function"==typeof e?se:ae)(e)):this.node().innerHTML},raise:function(){return this.each(le)},lower:function(){return this.each(ce)},append:function(e){var t="function"==typeof e?e:p(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:p(e),o=null==t?ue:"function"==typeof t?t:y(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(de)},clone:function(e){return this.select(e?fe:he)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var o,r,i=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=i.length;if(!(arguments.length<2)){for(s=t?pe:ge,o=0;o<a;++o)this.each(s(i[o],t,n));return this}var s=this.node().__on;if(s)for(var l,c=0,u=s.length;c<u;++c)for(o=0,l=s[c];o<a;++o)if((r=i[o]).type===l.type&&r.name===l.name)return l.value},dispatch:function(e,t){return this.each(("function"==typeof t?ve:ye)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o,r=e[t],i=0,a=r.length;i<a;++i)(o=r[i])&&(yield o)}};const Ce={passive:!1},_e={capture:!0,passive:!1};function Me(e){e.stopImmediatePropagation()}function Ne(e){e.preventDefault(),e.stopImmediatePropagation()}function ke(e){var t=e.document.documentElement,n=Se(e).on("dragstart.drag",Ne,_e);"onselectstart"in t?n.on("selectstart.drag",Ne,_e):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Pe(e,t){var n=e.document.documentElement,o=Se(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ne,_e),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var ze=e=>()=>e;function Oe(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}function Ie(e){return!e.ctrlKey&&!e.button}function Ae(){return this.parentNode}function Re(e,t){return null==t?{x:e.x,y:e.y}:t}function De(){return navigator.maxTouchPoints||"ontouchstart"in this}function $e(){var e,t,n,o,r=Ie,i=Ae,s=Re,l=De,c={},u=a("start","drag","end"),d=0,h=0;function f(e){e.on("mousedown.drag",g).filter(l).on("touchstart.drag",y).on("touchmove.drag",v,Ce).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(a,s){if(!o&&r.call(this,a,s)){var l=w(this,i.call(this,a,s),a,s,"mouse");l&&(Se(a.view).on("mousemove.drag",p,_e).on("mouseup.drag",m,_e),ke(a.view),Me(a),n=!1,e=a.clientX,t=a.clientY,l("start",a))}}function p(o){if(Ne(o),!n){var r=o.clientX-e,i=o.clientY-t;n=r*r+i*i>h}c.mouse("drag",o)}function m(e){Se(e.view).on("mousemove.drag mouseup.drag",null),Pe(e.view,n),Ne(e),c.mouse("end",e)}function y(e,t){if(r.call(this,e,t)){var n,o,a=e.changedTouches,s=i.call(this,e,t),l=a.length;for(n=0;n<l;++n)(o=w(this,s,e,t,a[n].identifier,a[n]))&&(Me(e),o("start",e,a[n]))}}function v(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=c[o[t].identifier])&&(Ne(e),n("drag",e,o[t]))}function x(e){var t,n,r=e.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<i;++t)(n=c[r[t].identifier])&&(Me(e),n("end",e,r[t]))}function w(e,t,n,o,r,i){var a,l,h,g=u.copy(),p=Ee(i||n,t);if(null!=(h=s.call(e,new Oe("beforestart",{sourceEvent:n,target:f,identifier:r,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:g}),o)))return a=h.x-p[0]||0,l=h.y-p[1]||0,function n(i,s,u){var m,y=p;switch(i){case"start":c[r]=n,m=d++;break;case"end":delete c[r],--d;case"drag":p=Ee(u||s,t),m=d}g.call(i,e,new Oe(i,{sourceEvent:s,subject:h,target:f,identifier:r,active:m,x:p[0]+a,y:p[1]+l,dx:p[0]-y[0],dy:p[1]-y[1],dispatch:g}),o)}}return f.filter=function(e){return arguments.length?(r="function"==typeof e?e:ze(!!e),f):r},f.container=function(e){return arguments.length?(i="function"==typeof e?e:ze(e),f):i},f.subject=function(e){return arguments.length?(s="function"==typeof e?e:ze(e),f):s},f.touchable=function(e){return arguments.length?(l="function"==typeof e?e:ze(!!e),f):l},f.on=function(){var e=u.on.apply(u,arguments);return e===u?f:e},f.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,f):Math.sqrt(h)},f}function Le(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Te(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Be(){}Oe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var je=.7,Ve=1/je,He="\\s*([+-]?\\d+)\\s*",Xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ye="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ze=/^#([0-9a-f]{3,8})$/,We=new RegExp(`^rgb\\(${He},${He},${He}\\)$`),Fe=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),Ke=new RegExp(`^rgba\\(${He},${He},${He},${Xe}\\)$`),Ge=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${Xe}\\)$`),qe=new RegExp(`^hsl\\(${Xe},${Ye},${Ye}\\)$`),Ue=new RegExp(`^hsla\\(${Xe},${Ye},${Ye},${Xe}\\)$`),Qe={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};function Je(){return this.rgb().formatHex()}function et(){return this.rgb().formatRgb()}function tt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ze.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?nt(t):3===n?new it(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?ot(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?ot(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=We.exec(e))?new it(t[1],t[2],t[3],1):(t=Fe.exec(e))?new it(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Ke.exec(e))?ot(t[1],t[2],t[3],t[4]):(t=Ge.exec(e))?ot(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=qe.exec(e))?dt(t[1],t[2]/100,t[3]/100,1):(t=Ue.exec(e))?dt(t[1],t[2]/100,t[3]/100,t[4]):Qe.hasOwnProperty(e)?nt(Qe[e]):"transparent"===e?new it(NaN,NaN,NaN,0):null}function nt(e){return new it(e>>16&255,e>>8&255,255&e,1)}function ot(e,t,n,o){return o<=0&&(e=t=n=NaN),new it(e,t,n,o)}function rt(e,t,n,o){return 1===arguments.length?((r=e)instanceof Be||(r=tt(r)),r?new it((r=r.rgb()).r,r.g,r.b,r.opacity):new it):new it(e,t,n,null==o?1:o);var r}function it(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}function at(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}`}function st(){const e=lt(this.opacity);return`${1===e?"rgb(":"rgba("}${ct(this.r)}, ${ct(this.g)}, ${ct(this.b)}${1===e?")":`, ${e})`}`}function lt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ct(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ut(e){return((e=ct(e))<16?"0":"")+e.toString(16)}function dt(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ft(e,t,n,o)}function ht(e){if(e instanceof ft)return new ft(e.h,e.s,e.l,e.opacity);if(e instanceof Be||(e=tt(e)),!e)return new ft;if(e instanceof ft)return e;var t=(e=e.rgb()).r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),a=NaN,s=i-r,l=(i+r)/2;return s?(a=t===i?(n-o)/s+6*(n<o):n===i?(o-t)/s+2:(t-n)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new ft(a,s,l,e.opacity)}function ft(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}function gt(e){return(e=(e||0)%360)<0?e+360:e}function pt(e){return Math.max(0,Math.min(1,e||0))}function mt(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}Le(Be,tt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Je,formatHex:Je,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ht(this).formatHsl()},formatRgb:et,toString:et}),Le(it,rt,Te(Be,{brighter(e){return e=null==e?Ve:Math.pow(Ve,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?je:Math.pow(je,e),new it(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new it(ct(this.r),ct(this.g),ct(this.b),lt(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:at,formatHex:at,formatHex8:function(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}${ut(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:st,toString:st})),Le(ft,(function(e,t,n,o){return 1===arguments.length?ht(e):new ft(e,t,n,null==o?1:o)}),Te(Be,{brighter(e){return e=null==e?Ve:Math.pow(Ve,e),new ft(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?je:Math.pow(je,e),new ft(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new it(mt(e>=240?e-240:e+120,r,o),mt(e,r,o),mt(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new ft(gt(this.h),pt(this.s),pt(this.l),lt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=lt(this.opacity);return`${1===e?"hsl(":"hsla("}${gt(this.h)}, ${100*pt(this.s)}%, ${100*pt(this.l)}%${1===e?")":`, ${e})`}`}}));var yt=e=>()=>e;function vt(e){return 1==(e=+e)?xt:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}(t,n,e):yt(isNaN(t)?n:t)}}function xt(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):yt(isNaN(e)?t:e)}var wt=function e(t){var n=vt(t);function o(e,t){var o=n((e=rt(e)).r,(t=rt(t)).r),r=n(e.g,t.g),i=n(e.b,t.b),a=xt(e.opacity,t.opacity);return function(t){return e.r=o(t),e.g=r(t),e.b=i(t),e.opacity=a(t),e+""}}return o.gamma=e,o}(1);function bt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var St=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Et=new RegExp(St.source,"g");function Ct(e,t){var n,o,r,i=St.lastIndex=Et.lastIndex=0,a=-1,s=[],l=[];for(e+="",t+="";(n=St.exec(e))&&(o=Et.exec(t));)(r=o.index)>i&&(r=t.slice(i,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(o=o[0])?s[a]?s[a]+=o:s[++a]=o:(s[++a]=null,l.push({i:a,x:bt(n,o)})),i=Et.lastIndex;return i<t.length&&(r=t.slice(i),s[a]?s[a]+=r:s[++a]=r),s.length<2?l[0]?function(e){return function(t){return e(t)+""}}(l[0].x):function(e){return function(){return e}}(t):(t=l.length,function(e){for(var n,o=0;o<t;++o)s[(n=l[o]).i]=n.x(e);return s.join("")})}var _t,Mt=180/Math.PI,Nt={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function kt(e,t,n,o,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(s=Math.sqrt(n*n+o*o))&&(n/=s,o/=s,l/=s),e*o<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Mt,skewX:Math.atan(l)*Mt,scaleX:a,scaleY:s}}function Pt(e,t,n,o){function r(e){return e.length?e.pop()+" ":""}return function(i,a){var s=[],l=[];return i=e(i),a=e(a),function(e,o,r,i,a,s){if(e!==r||o!==i){var l=a.push("translate(",null,t,null,n);s.push({i:l-4,x:bt(e,r)},{i:l-2,x:bt(o,i)})}else(r||i)&&a.push("translate("+r+t+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,l),function(e,t,n,i){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:bt(e,t)})):t&&n.push(r(n)+"rotate("+t+o)}(i.rotate,a.rotate,s,l),function(e,t,n,i){e!==t?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:bt(e,t)}):t&&n.push(r(n)+"skewX("+t+o)}(i.skewX,a.skewX,s,l),function(e,t,n,o,i,a){if(e!==n||t!==o){var s=i.push(r(i)+"scale(",null,",",null,")");a.push({i:s-4,x:bt(e,n)},{i:s-2,x:bt(t,o)})}else 1===n&&1===o||i.push(r(i)+"scale("+n+","+o+")")}(i.scaleX,i.scaleY,a.scaleX,a.scaleY,s,l),i=a=null,function(e){for(var t,n=-1,o=l.length;++n<o;)s[(t=l[n]).i]=t.x(e);return s.join("")}}}var zt=Pt((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Nt:kt(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),Ot=Pt((function(e){return null==e?Nt:(_t||(_t=document.createElementNS("http://www.w3.org/2000/svg","g")),_t.setAttribute("transform",e),(e=_t.transform.baseVal.consolidate())?kt((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):Nt)}),", ",")",")");function It(e){return((e=Math.exp(e))+1/e)/2}var At,Rt,Dt=function e(t,n,o){function r(e,r){var i,a,s=e[0],l=e[1],c=e[2],u=r[0],d=r[1],h=r[2],f=u-s,g=d-l,p=f*f+g*g;if(p<1e-12)a=Math.log(h/c)/t,i=function(e){return[s+e*f,l+e*g,c*Math.exp(t*e*a)]};else{var m=Math.sqrt(p),y=(h*h-c*c+o*p)/(2*c*n*m),v=(h*h-c*c-o*p)/(2*h*n*m),x=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(v*v+1)-v);a=(w-x)/t,i=function(e){var o,r=e*a,i=It(x),u=c/(n*m)*(i*(o=t*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(e){return((e=Math.exp(e))-1/e)/2}(x));return[s+u*f,l+u*g,c*i/It(t*r+x)]}}return i.duration=1e3*a*t/Math.SQRT2,i}return r.rho=function(t){var n=Math.max(.001,+t),o=n*n;return e(n,o,o*o)},r}(Math.SQRT2,2,4),$t=0,Lt=0,Tt=0,Bt=1e3,jt=0,Vt=0,Ht=0,Xt="object"==typeof performance&&performance.now?performance:Date,Yt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Zt(){return Vt||(Yt(Wt),Vt=Xt.now()+Ht)}function Wt(){Vt=0}function Ft(){this._call=this._time=this._next=null}function Kt(e,t,n){var o=new Ft;return o.restart(e,t,n),o}function Gt(){Vt=(jt=Xt.now())+Ht,$t=Lt=0;try{!function(){Zt(),++$t;for(var e,t=At;t;)(e=Vt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--$t}()}finally{$t=0,function(){var e,t,n=At,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:At=t);Rt=e,Ut(o)}(),Vt=0}}function qt(){var e=Xt.now(),t=e-jt;t>Bt&&(Ht-=t,jt=e)}function Ut(e){$t||(Lt&&(Lt=clearTimeout(Lt)),e-Vt>24?(e<1/0&&(Lt=setTimeout(Gt,e-Xt.now()-Ht)),Tt&&(Tt=clearInterval(Tt))):(Tt||(jt=Xt.now(),Tt=setInterval(qt,Bt)),$t=1,Yt(Gt)))}function Qt(e,t,n){var o=new Ft;return t=null==t?0:+t,o.restart((n=>{o.stop(),e(n+t)}),t,n),o}Ft.prototype=Kt.prototype={constructor:Ft,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Zt():+n)+(null==t?0:+t),this._next||Rt===this||(Rt?Rt._next=this:At=this,Rt=this),this._call=e,this._time=n,Ut()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ut())}};var Jt=a("start","end","cancel","interrupt"),en=[],tn=0,nn=1,on=2,rn=3,an=4,sn=5,ln=6;function cn(e,t,n,o,r,i){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var o,r=e.__transition;function i(e){n.state=nn,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)}function a(i){var c,u,d,h;if(n.state!==nn)return l();for(c in r)if((h=r[c]).name===n.name){if(h.state===rn)return Qt(a);h.state===an?(h.state=ln,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+c<t&&(h.state=ln,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[c])}if(Qt((function(){n.state===rn&&(n.state=an,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=on,n.on.call("start",e,e.__data__,n.index,n.group),n.state===on){for(n.state=rn,o=new Array(d=n.tween.length),c=0,u=-1;c<d;++c)(h=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(o[++u]=h);o.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(l),n.state=sn,1),i=-1,a=o.length;++i<a;)o[i].call(e,r);n.state===sn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){for(var o in n.state=ln,n.timer.stop(),delete r[t],r)return;delete e.__transition}r[t]=n,n.timer=Kt(i,0,n.time)}(e,n,{name:t,index:o,group:r,on:Jt,tween:en,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:tn})}function un(e,t){var n=hn(e,t);if(n.state>tn)throw new Error("too late; already scheduled");return n}function dn(e,t){var n=hn(e,t);if(n.state>rn)throw new Error("too late; already running");return n}function hn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function fn(e,t){var n,o,r,i=e.__transition,a=!0;if(i){for(r in t=null==t?null:t+"",i)(n=i[r]).name===t?(o=n.state>on&&n.state<sn,n.state=ln,n.timer.stop(),n.on.call(o?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[r]):a=!1;a&&delete e.__transition}}function gn(e,t){var n,o;return function(){var r=dn(this,e),i=r.tween;if(i!==n)for(var a=0,s=(o=n=i).length;a<s;++a)if(o[a].name===t){(o=o.slice()).splice(a,1);break}r.tween=o}}function pn(e,t,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=dn(this,e),a=i.tween;if(a!==o){r=(o=a).slice();for(var s={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function mn(e,t,n){var o=e._id;return e.each((function(){var e=dn(this,o);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return hn(e,o).value[t]}}function yn(e,t){var n;return("number"==typeof t?bt:t instanceof tt?wt:(n=tt(t))?(t=n,wt):Ct)(e,t)}function vn(e){return function(){this.removeAttribute(e)}}function xn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wn(e,t,n){var o,r,i=n+"";return function(){var a=this.getAttribute(e);return a===i?null:a===o?r:r=t(o=a,n)}}function bn(e,t,n){var o,r,i=n+"";return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===o?r:r=t(o=a,n)}}function Sn(e,t,n){var o,r,i;return function(){var a,s,l=n(this);if(null!=l)return(a=this.getAttribute(e))===(s=l+"")?null:a===o&&s===r?i:(r=s,i=t(o=a,l));this.removeAttribute(e)}}function En(e,t,n){var o,r,i;return function(){var a,s,l=n(this);if(null!=l)return(a=this.getAttributeNS(e.space,e.local))===(s=l+"")?null:a===o&&s===r?i:(r=s,i=t(o=a,l));this.removeAttributeNS(e.space,e.local)}}function Cn(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,r)),n}return r._value=t,r}function _n(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,r)),n}return r._value=t,r}function Mn(e,t){return function(){un(this,e).delay=+t.apply(this,arguments)}}function Nn(e,t){return t=+t,function(){un(this,e).delay=t}}function kn(e,t){return function(){dn(this,e).duration=+t.apply(this,arguments)}}function Pn(e,t){return t=+t,function(){dn(this,e).duration=t}}var zn=be.prototype.constructor;function On(e){return function(){this.style.removeProperty(e)}}var In=0;function An(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Rn(){return++In}var Dn=be.prototype;An.prototype={constructor:An,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=y(e));for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a)for(var s,l,c=o[a],u=c.length,d=i[a]=new Array(u),h=0;h<u;++h)(s=c[h])&&(l=e.call(s,s.__data__,h,c))&&("__data__"in s&&(l.__data__=s.__data__),d[h]=l,cn(d[h],t,n,h,d,hn(s,n)));return new An(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=x(e));for(var o=this._groups,r=o.length,i=[],a=[],s=0;s<r;++s)for(var l,c=o[s],u=c.length,d=0;d<u;++d)if(l=c[d]){for(var h,f=e.call(l,l.__data__,d,c),g=hn(l,n),p=0,m=f.length;p<m;++p)(h=f[p])&&cn(h,t,n,p,f,g);i.push(f),a.push(l)}return new An(i,a,t,n)},selectChild:Dn.selectChild,selectChildren:Dn.selectChildren,filter:function(e){"function"!=typeof e&&(e=b(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a=t[r],s=a.length,l=o[r]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&l.push(i);return new An(o,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),a=new Array(o),s=0;s<i;++s)for(var l,c=t[s],u=n[s],d=c.length,h=a[s]=new Array(d),f=0;f<d;++f)(l=c[f]||u[f])&&(h[f]=l);for(;s<o;++s)a[s]=t[s];return new An(a,this._parents,this._name,this._id)},selection:function(){return new zn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=Rn(),o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],l=s.length,c=0;c<l;++c)if(a=s[c]){var u=hn(a,t);cn(a,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new An(o,this._parents,e,n)},call:Dn.call,nodes:Dn.nodes,node:Dn.node,size:Dn.size,empty:Dn.empty,each:Dn.each,on:function(e,t){var n=this._id;return arguments.length<2?hn(this.node(),n).on.on(e):this.each(function(e,t,n){var o,r,i=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?un:dn;return function(){var a=i(this,e),s=a.on;s!==o&&(r=(o=s).copy()).on(t,n),a.on=r}}(n,e,t))},attr:function(e,t){var n=h(e),o="transform"===n?Ot:yn;return this.attrTween(e,"function"==typeof t?(n.local?En:Sn)(n,o,mn(this,"attr."+e,t)):null==t?(n.local?xn:vn)(n):(n.local?bn:wn)(n,o,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var o=h(e);return this.tween(n,(o.local?Cn:_n)(o,t))},style:function(e,t,n){var o="transform"==(e+="")?zt:yn;return null==t?this.styleTween(e,function(e,t){var n,o,r;return function(){var i=Y(this,e),a=(this.style.removeProperty(e),Y(this,e));return i===a?null:i===n&&a===o?r:r=t(n=i,o=a)}}(e,o)).on("end.style."+e,On(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var o,r,i;return function(){var a=Y(this,e),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(e),l=s=Y(this,e)),a===l?null:a===o&&l===r?i:(r=l,i=t(o=a,s))}}(e,o,mn(this,"style."+e,t))).each(function(e,t){var n,o,r,i,a="style."+t,s="end."+a;return function(){var l=dn(this,e),c=l.on,u=null==l.value[a]?i||(i=On(t)):void 0;c===n&&r===u||(o=(n=c).copy()).on(s,r=u),l.on=o}}(this._id,e)):this.styleTween(e,function(e,t,n){var o,r,i=n+"";return function(){var a=Y(this,e);return a===i?null:a===o?r:r=t(o=a,n)}}(e,o,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(null==t)return this.tween(o,null);if("function"!=typeof t)throw new Error;return this.tween(o,function(e,t,n){var o,r;function i(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&function(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}(e,i,n)),o}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(mn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function o(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&function(e){return function(t){this.textContent=e.call(this,t)}}(o)),t}return o._value=e,o}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o,r=hn(this.node(),n).tween,i=0,a=r.length;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((null==t?gn:pn)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Mn:Nn)(t,e)):hn(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?kn:Pn)(t,e)):hn(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){dn(this,e).ease=t}}(t,e)):hn(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;dn(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,o=n._id,r=n.size();return new Promise((function(i,a){var s={value:a},l={value:function(){0==--r&&i()}};n.each((function(){var n=dn(this,o),r=n.on;r!==e&&((t=(e=r).copy())._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),n.on=t})),0===r&&i()}))},[Symbol.iterator]:Dn[Symbol.iterator]};var $n={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function Ln(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}be.prototype.interrupt=function(e){return this.each((function(){fn(this,e)}))},be.prototype.transition=function(e){var t,n;e instanceof An?(t=e._id,e=e._name):(t=Rn(),(n=$n).time=Zt(),e=null==e?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],l=s.length,c=0;c<l;++c)(a=s[c])&&cn(a,e,t,c,s,n||Ln(a,t));return new An(o,this._parents,e,t)};var Tn=e=>()=>e;function Bn(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function jn(e,t,n){this.k=e,this.x=t,this.y=n}jn.prototype={constructor:jn,scale:function(e){return 1===e?this:new jn(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new jn(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vn=new jn(1,0,0);function Hn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Vn;return e.__zoom}function Xn(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function Zn(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Wn(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function Fn(){return this.__zoom||Vn}function Kn(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Gn(){return navigator.maxTouchPoints||"ontouchstart"in this}function qn(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function Un(){var e,t,n,o=Zn,r=Wn,i=qn,s=Kn,l=Gn,c=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],d=250,h=Dt,f=a("start","zoom","end"),g=500,p=150,m=0,y=10;function v(e){e.property("__zoom",Fn).on("wheel.zoom",_,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",N).filter(l).on("touchstart.zoom",k).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(e,t){return(t=Math.max(c[0],Math.min(c[1],t)))===e.k?e:new jn(t,e.x,e.y)}function w(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new jn(e.k,o,r)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function S(e,t,n,o){e.on("start.zoom",(function(){E(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){E(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,i=arguments,a=E(e,i).event(o),s=r.apply(e,i),l=null==n?b(s):"function"==typeof n?n.apply(e,i):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),u=e.__zoom,d="function"==typeof t?t.apply(e,i):t,f=h(u.invert(l).concat(c/u.k),d.invert(l).concat(c/d.k));return function(e){if(1===e)e=d;else{var t=f(e),n=c/t[2];e=new jn(n,l[0]-t[0]*n,l[1]-t[1]*n)}a.zoom(null,e)}}))}function E(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function _(e,...t){if(o.apply(this,arguments)){var n=E(this,t).event(e),r=this.__zoom,a=Math.max(c[0],Math.min(c[1],r.k*Math.pow(2,s.apply(this,arguments)))),l=Ee(e);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=r.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(r.k===a)return;n.mouse=[l,r.invert(l)],fn(this),n.start()}Yn(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),p),n.zoom("mouse",i(w(x(r,a),n.mouse[0],n.mouse[1]),n.extent,u))}}function M(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,a=E(this,t,!0).event(e),s=Se(e.view).on("mousemove.zoom",(function(e){if(Yn(e),!a.moved){var t=e.clientX-c,n=e.clientY-d;a.moved=t*t+n*n>m}a.event(e).zoom("mouse",i(w(a.that.__zoom,a.mouse[0]=Ee(e,r),a.mouse[1]),a.extent,u))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),Pe(e.view,a.moved),Yn(e),a.event(e).end()}),!0),l=Ee(e,r),c=e.clientX,d=e.clientY;ke(e.view),Xn(e),a.mouse=[l,this.__zoom.invert(l)],fn(this),a.start()}}function N(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,a=Ee(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),l=n.k*(e.shiftKey?.5:2),c=i(w(x(n,l),a,s),r.apply(this,t),u);Yn(e),d>0?Se(this).transition().duration(d).call(S,c,a,e):Se(this).call(v.transform,c,a,e)}}function k(n,...r){if(o.apply(this,arguments)){var i,a,s,l,c=n.touches,u=c.length,d=E(this,r,n.changedTouches.length===u).event(n);for(Xn(n),a=0;a<u;++a)l=[l=Ee(s=c[a],this),this.__zoom.invert(l),s.identifier],d.touch0?d.touch1||d.touch0[2]===l[2]||(d.touch1=l,d.taps=0):(d.touch0=l,i=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(d.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),g)),fn(this),d.start())}}function P(e,...t){if(this.__zooming){var n,o,r,a,s=E(this,t).event(e),l=e.changedTouches,c=l.length;for(Yn(e),n=0;n<c;++n)r=Ee(o=l[n],this),s.touch0&&s.touch0[2]===o.identifier?s.touch0[0]=r:s.touch1&&s.touch1[2]===o.identifier&&(s.touch1[0]=r);if(o=s.that.__zoom,s.touch1){var d=s.touch0[0],h=s.touch0[1],f=s.touch1[0],g=s.touch1[1],p=(p=f[0]-d[0])*p+(p=f[1]-d[1])*p,m=(m=g[0]-h[0])*m+(m=g[1]-h[1])*m;o=x(o,Math.sqrt(p/m)),r=[(d[0]+f[0])/2,(d[1]+f[1])/2],a=[(h[0]+g[0])/2,(h[1]+g[1])/2]}else{if(!s.touch0)return;r=s.touch0[0],a=s.touch0[1]}s.zoom("touch",i(w(o,r,a),s.extent,u))}}function z(e,...o){if(this.__zooming){var r,i,a=E(this,o).event(e),s=e.changedTouches,l=s.length;for(Xn(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),g),r=0;r<l;++r)i=s[r],a.touch0&&a.touch0[2]===i.identifier?delete a.touch0:a.touch1&&a.touch1[2]===i.identifier&&delete a.touch1;if(a.touch1&&!a.touch0&&(a.touch0=a.touch1,delete a.touch1),a.touch0)a.touch0[1]=this.__zoom.invert(a.touch0[0]);else if(a.end(),2===a.taps&&(i=Ee(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<y)){var c=Se(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return v.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",Fn),e!==r?S(e,t,n,o):r.interrupt().each((function(){E(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},v.scaleBy=function(e,t,n,o){v.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},v.scaleTo=function(e,t,n,o){v.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,a=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,s=o.invert(a),l="function"==typeof t?t.apply(this,arguments):t;return i(w(x(o,l),a,s),e,u)}),n,o)},v.translateBy=function(e,t,n,o){v.transform(e,(function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),u)}),null,o)},v.translateTo=function(e,t,n,o,a){v.transform(e,(function(){var e=r.apply(this,arguments),a=this.__zoom,s=null==o?b(e):"function"==typeof o?o.apply(this,arguments):o;return i(Vn.translate(s[0],s[1]).scale(a.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,u)}),o,a)},C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=Se(this.that).datum();f.call(e,this.that,new Bn(e,{sourceEvent:this.sourceEvent,target:v,type:e,transform:this.that.__zoom,dispatch:f}),t)}},v.wheelDelta=function(e){return arguments.length?(s="function"==typeof e?e:Tn(+e),v):s},v.filter=function(e){return arguments.length?(o="function"==typeof e?e:Tn(!!e),v):o},v.touchable=function(e){return arguments.length?(l="function"==typeof e?e:Tn(!!e),v):l},v.extent=function(e){return arguments.length?(r="function"==typeof e?e:Tn([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),v):r},v.scaleExtent=function(e){return arguments.length?(c[0]=+e[0],c[1]=+e[1],v):[c[0],c[1]]},v.translateExtent=function(e){return arguments.length?(u[0][0]=+e[0][0],u[1][0]=+e[1][0],u[0][1]=+e[0][1],u[1][1]=+e[1][1],v):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},v.constrain=function(e){return arguments.length?(i=e,v):i},v.duration=function(e){return arguments.length?(d=+e,v):d},v.interpolate=function(e){return arguments.length?(h=e,v):h},v.on=function(){var e=f.on.apply(f,arguments);return e===f?v:e},v.clickDistance=function(e){return arguments.length?(m=(e=+e)*e,v):Math.sqrt(m)},v.tapDistance=function(e){return arguments.length?(y=+e,v):y},v}Hn.prototype=jn.prototype;const Qn={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${n?o:n}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`},Jn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eo=["Enter"," ","Escape"];var to,no,oo,ro,io,ao;function so(e,t){if(!e&&!t)return!0;if(!e||!t||e.size!==t.size)return!1;if(!e.size&&!t.size)return!0;for(const n of e.keys())if(!t.has(n))return!1;return!0}function lo(e,t,n){if(!n)return;const o=[];e.forEach(((e,n)=>{t?.has(n)||o.push(e)})),o.length&&n(o)}e.ConnectionMode=void 0,(to=e.ConnectionMode||(e.ConnectionMode={})).Strict="strict",to.Loose="loose",e.PanOnScrollMode=void 0,(no=e.PanOnScrollMode||(e.PanOnScrollMode={})).Free="free",no.Vertical="vertical",no.Horizontal="horizontal",e.SelectionMode=void 0,(oo=e.SelectionMode||(e.SelectionMode={})).Partial="partial",oo.Full="full",e.ConnectionLineType=void 0,(ro=e.ConnectionLineType||(e.ConnectionLineType={})).Bezier="default",ro.Straight="straight",ro.Step="step",ro.SmoothStep="smoothstep",ro.SimpleBezier="simplebezier",e.MarkerType=void 0,(io=e.MarkerType||(e.MarkerType={})).Arrow="arrow",io.ArrowClosed="arrowclosed",e.Position=void 0,(ao=e.Position||(e.Position={})).Left="left",ao.Top="top",ao.Right="right",ao.Bottom="bottom";const co=e=>"id"in e&&"source"in e&&"target"in e,uo=(e,t=[0,0])=>{const{width:n,height:o}=Bo(e),r="internals"in e?e.internals.positionAbsolute:e.position,i=e.origin||t,a=n*i[0],s=o*i[1];return{position:{x:e.position.x-a,y:e.position.y-s},positionAbsolute:{x:r.x-a,y:r.y-s}}},ho=(e,t={nodeOrigin:[0,0]})=>{if(0===e.length)return{x:0,y:0,width:0,height:0};const n=e.reduce(((e,n)=>{const o=Mo(n,t.nodeOrigin);return So(e,o)}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Co(n)},fo=(e,t={nodeOrigin:[0,0]})=>{if(0===e.size)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach((e=>{if(null==t.filter||t.filter(e)){const o=Mo(e,t.nodeOrigin);n=So(n,o)}})),Co(n)},go=(e,t,[n,o,r]=[0,0,1],i=!1,a=!1,s=[0,0])=>{const l={...Ro(t,[n,o,r]),width:t.width/r,height:t.height/r},c=[];for(const[,t]of e){const{measured:e,selectable:n=!0,hidden:o=!1}=t,r=e.width??t.width??t.initialWidth??null,u=e.height??t.height??t.initialHeight??null;if(a&&!n||o)continue;const d=ko(l,_o(t,s));(null===r||null===u||i&&d>0||d>=(r??0)*(u??0)||t.dragging)&&c.push(t)}return c},po=(e,t)=>{const n=new Set;return e.forEach((e=>{n.add(e.id)})),t.filter((e=>n.has(e.source)||n.has(e.target)))};function mo({nodeLookup:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i,nodeOrigin:a=[0,0]},s){const l=[],c=s?.nodes?new Set(s.nodes.map((e=>e.id))):null;if(e.forEach((e=>{!(e.measured.width&&e.measured.height&&(s?.includeHiddenNodes||!e.hidden))||c&&!c.has(e.id)||l.push(e)})),l.length>0){const e=ho(l,{nodeOrigin:a}),c=$o(e,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return o.setViewport(c,{duration:s?.duration}),!0}return!1}function yo({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const a=n.get(e),s=a.parentId?n.get(a.parentId):void 0,{x:l,y:c}=s?uo(s,s.origin||o).positionAbsolute:{x:0,y:0};let u=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.measured?.width??0),t[1][1]-(e.measured?.height??0)]]:t}(a,a.extent||r);if("parent"!==a.extent||a.expandParent)s&&To(a.extent)&&(u=[[a.extent[0][0]+l,a.extent[0][1]+c],[a.extent[1][0]+l,a.extent[1][1]+c]]);else if(s){const e=a.measured.width,t=a.measured.height,n=s.measured.width,r=s.measured.height;if(e&&t&&n&&r){const i=a.origin||o,s=l+e*i[0],d=c+t*i[1];u=[[s,d],[s+n-e,d+r-t]]}}else i?.("005",Qn.error005());const d=To(u)?xo(t,u):t;return{position:{x:d.x-l,y:d.y-c},positionAbsolute:d}}const vo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),xo=(e={x:0,y:0},t)=>({x:vo(e.x,t[0][0],t[1][0]),y:vo(e.y,t[0][1],t[1][1])}),wo=(e,t,n)=>e<t?vo(Math.abs(e-t),1,50)/50:e>n?-vo(Math.abs(e-n),1,50)/50:0,bo=(e,t)=>[20*wo(e.x,35,t.width-35),20*wo(e.y,35,t.height-35)],So=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Eo=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Co=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),_o=(e,t=[0,0])=>{const{x:n,y:o}=uo(e,t).positionAbsolute;return{x:n,y:o,width:e.measured?.width??e.width??0,height:e.measured?.height??e.height??0}},Mo=(e,t=[0,0])=>{const{x:n,y:o}=uo(e,t).positionAbsolute;return{x:n,y:o,x2:n+(e.measured?.width??e.width??0),y2:o+(e.measured?.height??e.height??0)}},No=(e,t)=>Co(So(Eo(e),Eo(t))),ko=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Po=e=>zo(e.width)&&zo(e.height)&&zo(e.x)&&zo(e.y),zo=e=>!isNaN(e)&&isFinite(e),Oo=(e,t)=>{},Io=({x:e,y:t,width:n,height:o,origin:r=[0,0]})=>!n||!o||r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:e,y:t}:{x:e-n*r[0],y:t-o*r[1]},Ao=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ro=({x:e,y:t},[n,o,r],i=!1,a=[1,1])=>{const s={x:(e-n)/r,y:(t-o)/r};return i?Ao(s,a):s},Do=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),$o=(e,t,n,o,r,i)=>{const a=t/(e.width*(1+i)),s=n/(e.height*(1+i)),l=Math.min(a,s),c=vo(l,o,r);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},Lo=()=>"undefined"!=typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function To(e){return void 0!==e&&"parent"!==e}function Bo(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function jo(e){return void 0!==(e.measured?.width??e.width??e.initialWidth)&&void 0!==(e.measured?.height??e.height??e.initialHeight)}function Vo(e,t,n,o=[0,0]){let r=t;const i={...e};for(;r;){const e=n.get(r);if(r=e?.parentId,e){const t=e.origin||o,n=(e.measured.width??0)*t[0],r=(e.measured.height??0)*t[1];i.x+=e.position.x-n,i.y+=e.position.y-r}}return i}function Ho(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o}){const{x:r,y:i}=Ko(e),a=Ro({x:r,y:i},o),{x:s,y:l}=n?Ao(a,t):a;return{xSnapped:s,ySnapped:l,...a}}const Xo=e=>({width:e.offsetWidth,height:e.offsetHeight}),Yo=e=>e.getRootNode?.()||window?.document,Zo=["INPUT","SELECT","TEXTAREA"];function Wo(e){const t=e.composedPath?.()?.[0]||e.target;return Zo.includes(t?.nodeName)||t?.hasAttribute("contenteditable")||!!t?.closest(".nokey")}const Fo=e=>"clientX"in e,Ko=(e,t)=>{const n=Fo(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Go=(e,t,n,o,r=[0,0])=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const a=Array.from(i),s=n.left+n.width*r[0],l=n.top+n.height*r[1];return a.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-s)/o,y:(t.top-l)/o,...Xo(e)}}))};function qo({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s}){const l=.125*e+.375*r+.375*a+.125*n,c=.125*t+.375*i+.375*s+.125*o;return[l,c,Math.abs(l-e),Math.abs(c-t)]}function Uo(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function Qo({pos:t,x1:n,y1:o,x2:r,y2:i,c:a}){switch(t){case e.Position.Left:return[n-Uo(n-r,a),o];case e.Position.Right:return[n+Uo(r-n,a),o];case e.Position.Top:return[n,o-Uo(o-i,a)];case e.Position.Bottom:return[n,o+Uo(i-o,a)]}}function Jo({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,curvature:s=.25}){const[l,c]=Qo({pos:o,x1:t,y1:n,x2:r,y2:i,c:s}),[u,d]=Qo({pos:a,x1:r,y1:i,x2:t,y2:n,c:s}),[h,f,g,p]=qo({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${t},${n} C${l},${c} ${u},${d} ${r},${i}`,h,f,g,p]}function er({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,a=Math.abs(o-t)/2;return[i,o<t?o+a:o-a,r,a]}function tr({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=So(Mo(e),Mo(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return ko(a,Co(i))>0}const nr=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,or=(e,t)=>{if(!e.source||!e.target)return t;let n;return n=co(e)?{...e}:{...e,id:nr(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:(null===n.sourceHandle&&delete n.sourceHandle,null===n.targetHandle&&delete n.targetHandle,t.concat(n))};function rr({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,a,s]=er({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,a,s]}const ir={[e.Position.Left]:{x:-1,y:0},[e.Position.Right]:{x:1,y:0},[e.Position.Top]:{x:0,y:-1},[e.Position.Bottom]:{x:0,y:1}},ar=({source:t,sourcePosition:n=e.Position.Bottom,target:o})=>n===e.Position.Left||n===e.Position.Right?t.x<o.x?{x:1,y:0}:{x:-1,y:0}:t.y<o.y?{x:0,y:1}:{x:0,y:-1},sr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function lr({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,borderRadius:s=5,centerX:l,centerY:c,offset:u=20}){const[d,h,f,g,p]=function({source:t,sourcePosition:n=e.Position.Bottom,target:o,targetPosition:r=e.Position.Top,center:i,offset:a}){const s=ir[n],l=ir[r],c={x:t.x+s.x*a,y:t.y+s.y*a},u={x:o.x+l.x*a,y:o.y+l.y*a},d=ar({source:c,sourcePosition:n,target:u}),h=0!==d.x?"x":"y",f=d[h];let g,p,m=[];const y={x:0,y:0},v={x:0,y:0},[x,w,b,S]=er({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(s[h]*l[h]==-1){g=i.x??x,p=i.y??w;const e=[{x:g,y:c.y},{x:g,y:u.y}],t=[{x:c.x,y:p},{x:u.x,y:p}];m=s[h]===f?"x"===h?e:t:"x"===h?t:e}else{const e=[{x:c.x,y:u.y}],i=[{x:u.x,y:c.y}];if(m="x"===h?s.x===f?i:e:s.y===f?e:i,n===r){const e=Math.abs(t[h]-o[h]);if(e<=a){const n=Math.min(a-1,a-e);s[h]===f?y[h]=(c[h]>t[h]?-1:1)*n:v[h]=(u[h]>o[h]?-1:1)*n}}if(n!==r){const t="x"===h?"y":"x",n=s[h]===l[t],o=c[t]>u[t],r=c[t]<u[t];(1===s[h]&&(!n&&o||n&&r)||1!==s[h]&&(!n&&r||n&&o))&&(m="x"===h?e:i)}const d={x:c.x+y.x,y:c.y+y.y},x={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(x.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(x.y-m[0].y))?(g=(d.x+x.x)/2,p=m[0].y):(g=m[0].x,p=(d.y+x.y)/2)}return[[t,{x:c.x+y.x,y:c.y+y.y},...m,{x:u.x+v.x,y:u.y+v.y},o],g,p,b,S]}({source:{x:t,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:a,center:{x:l,y:c},offset:u});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(sr(e,t)/2,sr(t,n)/2,o),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a)return`L ${i+r*(e.x<n.x?-1:1)},${a}Q ${i},${a} ${i},${a+r*(e.y<n.y?1:-1)}`;const s=e.x<n.x?1:-1;return`L ${i},${a+r*(e.y<n.y?-1:1)}Q ${i},${a} ${i+r*s},${a}`}(d[n-1],t,d[n+1],s):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),h,f,g,p]}function cr(e){return e&&!(!e.internals.handleBounds&&!e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ur(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,"source"===o.type?t.push(o):"target"===o.type&&n.push(o);return{source:t,target:n}}function dr(t,n,o=e.Position.Left){const r=(n?.x??0)+t.internals.positionAbsolute.x,i=(n?.y??0)+t.internals.positionAbsolute.y,{width:a,height:s}=n??Bo(t);switch(n?.position??o){case e.Position.Top:return[r+a/2,i];case e.Position.Right:return[r+a,i+s/2];case e.Position.Bottom:return[r+a/2,i+s];case e.Position.Left:return[r,i+s/2]}}function hr(e,t){return e&&(t?e.find((e=>e.id===t)):e[0])||null}function fr(e,t){if(!e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`}function gr(t,n,o,r,i){let a=.5;"start"===i?a=0:"end"===i&&(a=1);let s=[(t.x+t.width*a)*n.zoom+n.x,t.y*n.zoom+n.y-r],l=[-100*a,-100];switch(o){case e.Position.Right:s=[(t.x+t.width)*n.zoom+n.x+r,(t.y+t.height*a)*n.zoom+n.y],l=[0,-100*a];break;case e.Position.Bottom:s[1]=(t.y+t.height)*n.zoom+n.y+r,l[1]=0;break;case e.Position.Left:s=[t.x*n.zoom+n.x-r,(t.y+t.height*a)*n.zoom+n.y],l=[-100,-100*a]}return`translate(${s[0]}px, ${s[1]}px) translate(${l[0]}%, ${l[1]}%)`}function pr(e,t={nodeOrigin:[0,0],elevateNodesOnSelect:!0,defaults:{}}){const n=t?.elevateNodesOnSelect?1e3:0;for(const[,o]of e){const r=o.parentId;if(!r)continue;if(!e.has(r))throw new Error(`Parent node ${r} not found`);const i=e.get(r),{x:a,y:s,z:l}=yr(o,e,{...o.position,z:(zo(o.zIndex)?o.zIndex:0)+(o.selected?n:0)},i?.origin??t.nodeOrigin),c=o.internals.positionAbsolute,u=a!==c.x||s!==c.y;(u||l!==o.internals.z)&&(o.internals={...o.internals,positionAbsolute:u?{x:a,y:s}:c,z:l})}}function mr(e,t,n,o={nodeOrigin:[0,0],elevateNodesOnSelect:!0,defaults:{},checkEquality:!0}){const r=new Map(t);t.clear(),n.clear();const i=o?.elevateNodesOnSelect?1e3:0;e.forEach((e=>{let a=r.get(e.id);if(o.checkEquality&&e===a?.internals.userNode||(a={...o.defaults,...e,measured:{width:e.measured?.width,height:e.measured?.height},internals:{positionAbsolute:e.position,handleBounds:a?.internals.handleBounds,z:(zo(e.zIndex)?e.zIndex:0)+(e.selected?i:0),userNode:e}}),t.set(e.id,a),e.parentId){const t=n.get(e.parentId);t?t.push(a):n.set(e.parentId,[a])}})),n.size>0&&pr(t,o)}function yr(e,t,n,o=[0,0]){if(!e.parentId)return n;const r=t.get(e.parentId),i=uo(r,o).position;return yr(r,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(r.internals.z??0)>(n.z??0)?r.internals.z??0:n.z??0},r.origin||o)}function vr(e,t,n,o){const r=[],i=new Map;for(const n of e){const e=t.get(n.parentId);if(!e)continue;const r=i.get(n.parentId)?.expandedRect??_o(e,e.origin??o),a=No(r,n.rect);i.set(n.parentId,{expandedRect:a,parent:e})}return i.size>0&&i.forEach((({expandedRect:t,parent:o},i)=>{const{position:a}=uo(o,o.origin),s=Bo(o),l=t.x<a.x?Math.round(Math.abs(a.x-t.x)):0,c=t.y<a.y?Math.round(Math.abs(a.y-t.y)):0;if(l>0||c>0){r.push({id:i,type:"position",position:{x:a.x-l,y:a.y-c}});const t=n.get(i);t?.forEach((t=>{e.some((e=>e.id===t.id))||r.push({id:t.id,type:"position",position:{x:t.position.x+l,y:t.position.y+c}})}))}(s.width<t.width||s.height<t.height)&&r.push({id:i,type:"dimensions",setAttributes:!0,dimensions:{width:Math.max(s.width,Math.round(t.width)),height:Math.max(s.height,Math.round(t.height))}})})),r}function xr(e,t,n){e.clear(),t.clear();for(const o of n){const{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=o,s=`${n}-source-${i}`,l=`${r}-target-${a}`,c=e.get(s)||new Map,u=e.get(l)||new Map,d={edgeId:o.id,source:n,target:r,sourceHandle:i,targetHandle:a};t.set(o.id,o),e.set(s,c.set(`${r}-${a}`,d)),e.set(l,u.set(`${n}-${i}`,d))}}function wr(e,t){if(null===e||null===t)return!1;const n=Array.isArray(e)?e:[e],o=Array.isArray(t)?t:[t];if(n.length!==o.length)return!1;for(let e=0;e<n.length;e++)if(n[e].id!==o[e].id||n[e].type!==o[e].type||!Object.is(n[e].data,o[e].data))return!1;return!0}function br(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return!!n&&(!!n.selected||br(n,t))}function Sr(e,t,n){let o=e;do{if(o?.matches(t))return!0;if(o===n)return!1;o=o.parentElement}while(o);return!1}function Er({nodeId:e,dragItems:t,nodeLookup:n}){const o=[];for(const[e,r]of t){const t=n.get(e)?.internals.userNode;t&&o.push({...t,position:r.position})}if(!e)return[o[0],o];const r=n.get(e).internals.userNode;return[{...r,position:t.get(e)?.position||r.position},o]}function Cr({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},a=0,s=new Map,l=!1,c={x:0,y:0},u=null,d=!1,h=null,f=!1;return{update:function({noDragClassName:g,handleSelector:p,domNode:m,isSelectable:y,nodeId:v}){function x({x:e,y:n},r){const{nodeLookup:a,nodeExtent:l,snapGrid:c,snapToGrid:u,nodeOrigin:d,onNodeDrag:h,onSelectionDrag:f,onError:g,updateNodePositions:p}=t();i={x:e,y:n};let m=!1,y={x:0,y:0,x2:0,y2:0};if(s.size>1&&l){const e=fo(s,{nodeOrigin:d});y=Eo(e)}for(const[t,o]of s){let r={x:e-o.distance.x,y:n-o.distance.y};u&&(r=Ao(r,c));let i=[[l[0][0],l[0][1]],[l[1][0],l[1][1]]];if(s.size>1&&l&&!o.extent){const{positionAbsolute:e}=o.internals,t=e.x-y.x+l[0][0],n=e.x+o.measured.width-y.x2+l[1][0];i=[[t,e.y-y.y+l[0][1]],[n,e.y+o.measured.height-y.y2+l[1][1]]]}const{position:h,positionAbsolute:f}=yo({nodeId:t,nextPosition:r,nodeLookup:a,nodeExtent:i,nodeOrigin:d,onError:g});m=m||o.position.x!==h.x||o.position.y!==h.y,o.position=h,o.internals.positionAbsolute=f}if(m&&(p(s,!0),r&&(o||h||!v&&f))){const[e,t]=Er({nodeId:v,dragItems:s,nodeLookup:a});o?.(r,s,e,t),h?.(r,e,t),v||f?.(r,t)}}function w(){if(!u)return;const[e,n]=bo(c,u);if(0!==e||0!==n){const{transform:o,panBy:r}=t();i.x=(i.x??0)-e/o[2],i.y=(i.y??0)-n/o[2],r({x:e,y:n})&&x(i,null)}a=requestAnimationFrame(w)}function b(o){const{nodeLookup:r,multiSelectionActive:a,nodesDraggable:l,transform:c,snapGrid:u,snapToGrid:h,selectNodesOnDrag:f,onNodeDragStart:g,onSelectionDragStart:p,unselectNodesAndEdges:m}=t();d=!0,f&&y||a||!v||r.get(v)?.selected||m(),y&&f&&v&&e?.(v);const x=Ho(o.sourceEvent,{transform:c,snapGrid:u,snapToGrid:h});if(i=x,s=function(e,t,n,o){const r=new Map;for(const[i,a]of e)if((a.selected||a.id===o)&&(!a.parentId||!br(a,e))&&(a.draggable||t&&void 0===a.draggable)){const t=e.get(i);t&&r.set(i,{id:i,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return r}(r,l,x,v),s.size>0&&(n||g||!v&&p)){const[e,t]=Er({nodeId:v,dragItems:s,nodeLookup:r});n?.(o.sourceEvent,s,e,t),g?.(o.sourceEvent,e,t),v||p?.(o.sourceEvent,t)}}h=Se(m);const S=$e().on("start",(e=>{const{domNode:n,nodeDragThreshold:o,transform:r,snapGrid:a,snapToGrid:s}=t();f=!1,0===o&&b(e);const l=Ho(e.sourceEvent,{transform:r,snapGrid:a,snapToGrid:s});i=l,u=n?.getBoundingClientRect()||null,c=Ko(e.sourceEvent,u)})).on("drag",(e=>{const{autoPanOnNodeDrag:n,transform:o,snapGrid:r,snapToGrid:a,nodeDragThreshold:h}=t(),g=Ho(e.sourceEvent,{transform:o,snapGrid:r,snapToGrid:a});if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(f=!0),!f){if(!l&&n&&d&&(l=!0,w()),!d){const t=g.xSnapped-(i.x??0),n=g.ySnapped-(i.y??0);Math.sqrt(t*t+n*n)>h&&b(e)}(i.x!==g.xSnapped||i.y!==g.ySnapped)&&s&&d&&(c=Ko(e.sourceEvent,u),x(g,e.sourceEvent))}})).on("end",(e=>{if(d&&!f&&(l=!1,d=!1,cancelAnimationFrame(a),s.size>0)){const{nodeLookup:n,updateNodePositions:o,onNodeDragStop:i,onSelectionDragStop:a}=t();if(o(s,!1),r||i||!v&&a){const[t,o]=Er({nodeId:v,dragItems:s,nodeLookup:n});r?.(e.sourceEvent,s,t,o),i?.(e.sourceEvent,t,o),v||a?.(e.sourceEvent,o)}}})).filter((e=>{const t=e.target;return!e.button&&(!g||!Sr(t,`.${g}`,m))&&(!p||Sr(t,p,m))}));h.call(S)},destroy:function(){h?.on(".drag",null)}}}function _r(e,t,n,o){return(t[n]||[]).reduce(((t,r)=>{if(`${e.id}-${r.id}-${n}`!==o){const[o,i]=dr(e,r);t.push({id:r.id||null,type:n,nodeId:e.id,x:o,y:i})}return t}),[])}function Mr(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Nr(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}const kr=()=>!0;let Pr=null;function zr(t,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:a,doc:s,lib:l,flowId:c,isValidConnection:u=kr}){const d="target"===a,h=n?s.querySelector(`.${l}-flow__handle[data-id="${c}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:f,y:g}=Ko(t),p=s.elementFromPoint(f,g),m=p?.classList.contains(`${l}-flow__handle`)?p:h,y={handleDomNode:m,isValid:!1,connection:null,endHandle:null};if(m){const t=Mr(void 0,m),n=m.getAttribute("data-nodeid"),a=m.getAttribute("data-handleid"),s=m.classList.contains("connectable"),l=m.classList.contains("connectableend");if(!n)return y;const c={source:d?n:r,sourceHandle:d?a:i,target:d?r:n,targetHandle:d?i:a};y.connection=c;const h=s&&l&&(o===e.ConnectionMode.Strict?d&&"source"===t||!d&&"target"===t:n!==r||a!==i);y.isValid=h&&u(c),y.endHandle={nodeId:n,handleId:a,type:t,position:m.getAttribute("data-handlepos")}}return y}const Or={onPointerDown:function(t,{connectionMode:n,connectionRadius:o,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:s,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:h,panBy:f,cancelConnection:g,onConnectStart:p,onConnect:m,onConnectEnd:y,isValidConnection:v=kr,onReconnectEnd:x,updateConnection:w,getTransform:b,getConnectionStartHandle:S}){const E=Yo(t.target);let C,_=0;const{x:M,y:N}=Ko(t),k=E?.elementFromPoint(M,N),P=Mr(a,k),z=l?.getBoundingClientRect();if(!z||!P)return;let O=Ko(t,z),I=!1,A=null,R=!1,D=null;const $=function({nodeLookup:e,nodeId:t,handleId:n,handleType:o}){const r=[];for(const[,i]of e)if(i.internals.handleBounds){const e=`${t}-${n}-${o}`,a=_r(i,i.internals.handleBounds,"source",e),s=_r(i,i.internals.handleBounds,"target",e);r.push(...a,...s)}return r}({nodeLookup:c,nodeId:i,handleId:r,handleType:P});function L(){if(!d||!z)return;const[e,t]=bo(O,z);f({x:e,y:t}),_=requestAnimationFrame(L)}function T(e){S()||B(e);const t=b();O=Ko(e,z),C=function(e,t,n){let o=[],r=1/0;for(const i of n){const n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));n<=t&&(n<r?o=[i]:n===r&&o.push(i),r=n)}return o.length?1===o.length?o[0]:o.find((e=>"target"===e.type))||o[0]:null}(Ro(O,t,!1,[1,1]),o,$),I||(L(),I=!0);const a=zr(e,{handle:C,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:s?"target":"source",isValidConnection:v,doc:E,lib:u,flowId:h});D=a.handleDomNode,A=a.connection,R=a.isValid,w({connectionStartHandle:Pr,connectionPosition:C&&R?Do({x:C.x,y:C.y},t):O,connectionStatus:Nr(!!C,R),connectionEndHandle:a.endHandle})}function B(e){(C||D)&&A&&R&&m?.(A),y?.(e),a&&x?.(e),g(),cancelAnimationFrame(_),I=!1,R=!1,A=null,D=null,Pr=null,E.removeEventListener("mousemove",T),E.removeEventListener("mouseup",B),E.removeEventListener("touchmove",T),E.removeEventListener("touchend",B)}Pr={nodeId:i,handleId:r,type:P,position:k?.getAttribute("data-handlepos")||e.Position.Top},w({connectionPosition:O,connectionStatus:null,connectionStartHandle:Pr,connectionEndHandle:null}),p?.(t,{nodeId:i,handleId:r,handleType:P}),E.addEventListener("mousemove",T),E.addEventListener("mouseup",B),E.addEventListener("touchmove",T),E.addEventListener("touchend",B)},isValid:zr};const Ir=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Ar=e=>({x:e.x,y:e.y,zoom:e.k}),Rr=({x:e,y:t,zoom:n})=>Vn.translate(e,t).scale(n),Dr=(e,t)=>e.target.closest(`.${t}`),$r=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),Lr=(e,t=0)=>"number"==typeof t&&t>0?e.transition().duration(t):e,Tr=e=>{const t=e.ctrlKey&&Lo()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t};function Br({domNode:t,minZoom:n,maxZoom:o,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:s,onPanZoomEnd:l,onTransformChange:c,onDraggingChange:u}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=t.getBoundingClientRect(),f=Un().scaleExtent([n,o]).translateExtent(r),g=Se(t).call(f);x({x:i.x,y:i.y,zoom:vo(i.zoom,n,o)},[[0,0],[h.width,h.height]],r);const p=g.on("wheel.zoom"),m=g.on("dblclick.zoom");function y(e,t){g&&f?.transform(Lr(g,t?.duration),e)}function v(){f.on("zoom",null)}function x(e,t,n){const o=Rr(e),r=f?.constrain()(o,t,n);return r&&y(r),r}return f.wheelDelta(Tr),{update:function({noWheelClassName:t,noPanClassName:n,onPaneContextMenu:o,userSelectionActive:r,panOnScroll:i,panOnDrag:h,panOnScrollMode:y,panOnScrollSpeed:x,preventScrolling:w,zoomOnPinch:b,zoomOnScroll:S,zoomOnDoubleClick:E,zoomActivationKeyPressed:C,lib:_}){r&&!d.isZoomingOrPanning&&v();const M=i&&!C&&!r?function({zoomPanValues:t,noWheelClassName:n,d3Selection:o,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:s,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Dr(d,n))return!1;d.preventDefault(),d.stopImmediatePropagation();const h=o.property("__zoom").k||1;if(d.ctrlKey&&s){const e=Ee(d),t=Tr(d),n=h*Math.pow(2,t);return void r.scaleTo(o,n,e,d)}const f=1===d.deltaMode?20:1;let g=i===e.PanOnScrollMode.Vertical?0:d.deltaX*f,p=i===e.PanOnScrollMode.Horizontal?0:d.deltaY*f;!Lo()&&d.shiftKey&&i!==e.PanOnScrollMode.Vertical&&(g=d.deltaY*f,p=0),r.translateBy(o,-g/h*a,-p/h*a,{internal:!0});const m=Ar(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling||(t.isPanScrolling=!0,l?.(d,m)),t.isPanScrolling&&(c?.(d,m),t.panScrollTimeout=setTimeout((()=>{u?.(d,m),t.isPanScrolling=!1}),150))}}({zoomPanValues:d,noWheelClassName:t,d3Selection:g,d3Zoom:f,panOnScrollMode:y,panOnScrollSpeed:x,zoomOnPinch:b,onPanZoomStart:s,onPanZoom:a,onPanZoomEnd:l}):function({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){if(!t&&"wheel"===o.type&&!o.ctrlKey||Dr(o,e))return null;o.preventDefault(),n.call(this,o,r)}}({noWheelClassName:t,preventScrolling:w,d3ZoomHandler:p});if(g.on("wheel.zoom",M,{passive:!1}),!r){const e=function({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=Ar(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,"mousedown"===o.sourceEvent?.type&&t(!0),n&&n?.(o.sourceEvent,r)}}({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:s});f.on("start",e);const t=function({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!(!n||!$r(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,Ar(i.transform))}}({zoomPanValues:d,panOnDrag:h,onPaneContextMenu:!!o,onPanZoom:a,onTransformChange:c});f.on("zoom",t);const n=function({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&$r(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,o(!1),r&&Ir(e.prevViewport,a.transform))){const t=Ar(a.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout((()=>{r?.(a.sourceEvent,t)}),n?150:0)}}}({zoomPanValues:d,panOnDrag:h,panOnScroll:i,onPaneContextMenu:o,onPanZoomEnd:l,onDraggingChange:u});f.on("end",n)}const N=function({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:s,noPanClassName:l,lib:c}){return u=>{const d=e||t,h=n&&u.ctrlKey;if(1===u.button&&"mousedown"===u.type&&(Dr(u,`${c}-flow__node`)||Dr(u,`${c}-flow__edge`)))return!0;if(!(o||d||r||i||n))return!1;if(a)return!1;if(Dr(u,s)&&"wheel"===u.type)return!1;if(Dr(u,l)&&("wheel"!==u.type||r&&"wheel"===u.type&&!e))return!1;if(!n&&u.ctrlKey&&"wheel"===u.type)return!1;if(!n&&"touchstart"===u.type&&u.touches?.length>1)return u.preventDefault(),!1;if(!d&&!r&&!h&&"wheel"===u.type)return!1;if(!o&&("mousedown"===u.type||"touchstart"===u.type))return!1;if(Array.isArray(o)&&!o.includes(u.button)&&"mousedown"===u.type)return!1;const f=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||"wheel"===u.type)&&f}}({zoomActivationKeyPressed:C,panOnDrag:h,zoomOnScroll:S,panOnScroll:i,zoomOnDoubleClick:E,zoomOnPinch:b,userSelectionActive:r,noPanClassName:n,noWheelClassName:t,lib:_});f.filter(N),E?g.on("dblclick.zoom",m):g.on("dblclick.zoom",null)},destroy:v,setViewport:function(e,t){const n=Rr(e);return y(n,t),n},setViewportConstrained:x,getViewport:function(){const e=g?Hn(g.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},scaleTo:function(e,t){g&&f?.scaleTo(Lr(g,t?.duration),e)},scaleBy:function(e,t){g&&f?.scaleBy(Lr(g,t?.duration),e)},setScaleExtent:function(e){f?.scaleExtent(e)},setTranslateExtent:function(e){f?.translateExtent(e)},syncViewport:function(e){if(g){const t=Rr(e),n=g.property("__zoom");n.k===e.zoom&&n.x===e.x&&n.y===e.y||f?.transform(g,t,null,{sync:!0})}}}}var jr;!function(e){e.Line="line",e.Handle="handle"}(jr||(jr={}));const Vr=["top-left","top-right","bottom-left","bottom-right"],Hr=["top","right","bottom","left"];function Xr(e,t){return Math.max(0,t-e)}function Yr(e,t){return Math.max(0,e-t)}function Zr(e,t,n){return Math.max(0,t-e,e-n)}function Wr(e,t){return e?!t:t}const Fr={width:0,height:0,x:0,y:0},Kr={...Fr,pointerX:0,pointerY:0,aspectRatio:1};function Gr(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,s=n[0]*i,l=n[1]*a;return[[o-s,r-l],[o+i-s,r+a-l]]}function qr({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=Se(e);return{update:function({controlPosition:e,boundaries:a,keepAspectRatio:s,onResizeStart:l,onResize:c,onResizeEnd:u,shouldResize:d}){let h={...Fr},f={...Kr};const g=function(e){return{isHorizontal:e.includes("right")||e.includes("left"),isVertical:e.includes("bottom")||e.includes("top"),affectsX:e.includes("left"),affectsY:e.includes("top")}}(e);let p,m,y,v,x=[];const w=$e().on("start",(e=>{const{nodeLookup:o,transform:r,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n();if(p=o.get(t),!p)return;const{xSnapped:c,ySnapped:u}=Ho(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:a});h={width:p.measured?.width??0,height:p.measured?.height??0,x:p.position.x??0,y:p.position.y??0},f={...h,pointerX:c,pointerY:u,aspectRatio:h.width/h.height},m=void 0,("parent"===p.extent||p.expandParent)&&(m=o.get(p.parentId),m&&"parent"===p.extent&&(y=function(e){return[[0,0],[e.measured.width,e.measured.height]]}(m))),x=[],v=void 0;for(const[e,n]of o)if(n.parentId===t&&(x.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){const e=Gr(n,p,n.origin??s);v=v?[[Math.min(e[0][0],v[0][0]),Math.min(e[0][1],v[0][1])],[Math.max(e[1][0],v[1][0]),Math.max(e[1][1],v[1][1])]]:e}l?.(e,{...h})})).on("drag",(e=>{const{transform:t,snapGrid:r,snapToGrid:i,nodeOrigin:l}=n(),u=Ho(e.sourceEvent,{transform:t,snapGrid:r,snapToGrid:i}),w=[];if(!p)return;const{x:b,y:S,width:E,height:C}=h,_={},M=p.origin??l,{width:N,height:k,x:P,y:z}=function(e,t,n,o,r,i,a,s){let{affectsX:l,affectsY:c}=t;const{isHorizontal:u,isVertical:d}=t,h=u&&d,{xSnapped:f,ySnapped:g}=n,{minWidth:p,maxWidth:m,minHeight:y,maxHeight:v}=o,{x:x,y:w,width:b,height:S,aspectRatio:E}=e;let C=Math.floor(u?f-e.pointerX:0),_=Math.floor(d?g-e.pointerY:0);const M=b+(l?-C:C),N=S+(c?-_:_),k=-i[0]*b,P=-i[1]*S;let z=Zr(M,p,m),O=Zr(N,y,v);if(a){let e=0,t=0;l&&C<0?e=Xr(x+C+k,a[0][0]):!l&&C>0&&(e=Yr(x+M+k,a[1][0])),c&&_<0?t=Xr(w+_+P,a[0][1]):!c&&_>0&&(t=Yr(w+N+P,a[1][1])),z=Math.max(z,e),O=Math.max(O,t)}if(s){let e=0,t=0;l&&C>0?e=Yr(x+C,s[0][0]):!l&&C<0&&(e=Xr(x+M,s[1][0])),c&&_>0?t=Yr(w+_,s[0][1]):!c&&_<0&&(t=Xr(w+N,s[1][1])),z=Math.max(z,e),O=Math.max(O,t)}if(r){if(u){const e=Zr(M/E,y,v)*E;if(z=Math.max(z,e),a){let e=0;e=!l&&!c||l&&!c&&h?Yr(w+P+M/E,a[1][1])*E:Xr(w+P+(l?C:-C)/E,a[0][1])*E,z=Math.max(z,e)}if(s){let e=0;e=!l&&!c||l&&!c&&h?Xr(w+M/E,s[1][1])*E:Yr(w+(l?C:-C)/E,s[0][1])*E,z=Math.max(z,e)}}if(d){const e=Zr(N*E,p,m)/E;if(O=Math.max(O,e),a){let e=0;e=!l&&!c||c&&!l&&h?Yr(x+N*E+k,a[1][0])/E:Xr(x+(c?_:-_)*E+k,a[0][0])/E,O=Math.max(O,e)}if(s){let e=0;e=!l&&!c||c&&!l&&h?Xr(x+N*E,s[1][0])/E:Yr(x+(c?_:-_)*E,s[0][0])/E,O=Math.max(O,e)}}}_+=_<0?O:-O,C+=C<0?z:-z,r&&(h?M>N*E?_=(Wr(l,c)?-C:C)/E:C=(Wr(l,c)?-_:_)*E:u?(_=C/E,c=l):(C=_*E,l=c));const I=l?x+C:x,A=c?w+_:w;return{width:b+(l?-C:C),height:S+(c?-_:_),x:i[0]*C*(l?-1:1)+I,y:i[1]*_*(c?-1:1)+A}}(f,g,u,a,s,M,y,v),O=N!==E,I=k!==C,A=P!==b&&O,R=z!==S&&I;if(!(A||R||O||I))return;if((A||R||1===M[0]||1==M[1])&&(_.x=A?P:h.x,_.y=R?z:h.y,h.x=_.x,h.y=_.y,m&&p.expandParent&&(_.x&&_.x<0&&(h.x=0,f.x=f.x-_.x),_.y&&_.y<0&&(h.y=0,f.y=f.y-_.y)),x.length>0)){const e=P-b,t=z-S;for(const n of x)n.position={x:n.position.x-e+M[0]*(N-E),y:n.position.y-t+M[1]*(k-C)},w.push(n)}(O||I)&&(_.width=O?N:h.width,_.height=I?k:h.height,h.width=_.width,h.height=_.height);const D=function({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const a=e-t,s=n-o,l=[a>0?1:a<0?-1:0,s>0?1:s<0?-1:0];return a&&r&&(l[0]=-1*l[0]),s&&i&&(l[1]=-1*l[1]),l}({width:h.width,prevWidth:E,height:h.height,prevHeight:C,affectsX:g.affectsX,affectsY:g.affectsY}),$={...h,direction:D},L=d?.(e,$);!1!==L&&(c?.(e,$),o(_,w))})).on("end",(e=>{u?.(e,{...h}),r?.()}));i.call(w)},destroy:function(){i.on(".drag",null)}}}function Ur(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qr,Jr,ei,ti={exports:{}},ni={},oi={exports:{}},ri={};function ii(){return Jr||(Jr=1,oi.exports=function(){if(Qr)return ri;Qr=1;var e=n,t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=e.useState,r=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function s(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!t(e,o)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),l=o({inst:{value:n,getSnapshot:t}}),c=l[0].inst,u=l[1];return i((function(){c.value=n,c.getSnapshot=t,s(c)&&u({inst:c})}),[e,n,t]),r((function(){return s(c)&&u({inst:c}),e((function(){s(c)&&u({inst:c})}))}),[e]),a(n),n};return ri.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,ri}()),oi.exports}
2
2
  /**
3
3
  * @license React
4
4
  * use-sync-external-store-shim/with-selector.production.min.js
@@ -7,4 +7,4 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */ti.exports=function(){if(ei)return ni;ei=1;var e=n,t=ii(),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,s=e.useMemo,l=e.useDebugValue;return ni.useSyncExternalStoreWithSelector=function(e,t,n,c,u){var d=i(null);if(null===d.current){var h={hasValue:!1,value:null};d.current=h}else h=d.current;d=s((function(){function e(e){if(!a){if(a=!0,r=e,e=c(e),void 0!==u&&h.hasValue){var t=h.value;if(u(t,e))return i=t}return i=e}if(t=i,o(r,e))return t;var n=c(e);return void 0!==u&&u(t,n)?t:(r=e,i=n)}var r,i,a=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,c,u]);var f=r(e,d[0],d[1]);return a((function(){h.hasValue=!0,h.value=f}),[f]),l(f),f},ni}();var ai=qr(ti.exports);const si=e=>{let t;const n=new Set,o=(e,o)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=o?o:"object"!=typeof r)?r:Object.assign({},t,r),n.forEach((n=>n(t,e)))}},r=()=>t,i={setState:o,getState:r,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{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()}};return t=e(o,r,i),i},{useSyncExternalStoreWithSelector:li}=ai;function ci(e,t=e.getState,o){const r=li(e.subscribe,e.getState,e.getServerState||e.getState,t,o);return n.useDebugValue(r),r}const ui=(e,t)=>{const n=(e=>e?si(e):si)(e),o=(e,o=t)=>ci(n,e,o);return Object.assign(o,n),o},di=n.createContext(null),hi=di.Provider,fi=Qn.error001();function gi(e,t){const o=n.useContext(di);if(null===o)throw new Error(fi);return ci(o,e,t)}function pi(){const e=n.useContext(di);if(null===e)throw new Error(fi);return n.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe})),[e])}const mi={display:"none"},yi={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},vi="react-flow__node-desc",xi="react-flow__edge-desc",wi="react-flow__aria-live",bi=e=>e.ariaLiveMessage;function Si({rfId:e}){const n=gi(bi);return t.jsx("div",{id:`${wi}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:yi,children:n})}function Ei({rfId:e,disableKeyboardA11y:n}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{id:`${vi}-${e}`,style:mi,children:["Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),t.jsx("div",{id:`${xi}-${e}`,style:mi,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!n&&t.jsx(Si,{rfId:e})]})}const Ci=e=>e.userSelectionActive?"none":"all";function _i({position:e="top-left",children:n,className:o,style:i,...a}){const s=gi(Ci),l=`${e}`.split("-");return t.jsx("div",{className:r(["react-flow__panel",o,...l]),style:{...i,pointerEvents:s},...a,children:n})}function Mi({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(_i,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}function Ni(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}const ki=e=>{const t=[],n=[];for(const[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(const[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Pi=e=>e.id;function zi(e,t){return Ni(e.selectedNodes.map(Pi),t.selectedNodes.map(Pi))&&Ni(e.selectedEdges.map(Pi),t.selectedEdges.map(Pi))}function Oi({onSelectionChange:e}){const t=pi(),{selectedNodes:o,selectedEdges:r}=gi(ki,zi);return n.useEffect((()=>{const n={nodes:o,edges:r};e?.(n),t.getState().onSelectionChangeHandlers.forEach((e=>e(n)))}),[o,r,e]),null}const Ii=e=>!!e.onSelectionChangeHandlers;function Ai({onSelectionChange:e}){const n=gi(Ii);return e||n?t.jsx(Oi,{onSelectionChange:e}):null}const Di=[0,0],Ri={x:0,y:0,zoom:1},$i=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","nodesConnectable","nodesFocusable","edgesFocusable","edgesUpdatable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","onBeforeDelete","debug","rfId"],Li=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Ti={translateExtent:Jn,nodeOrigin:Di,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Bi(e){const{setNodes:t,setEdges:o,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:s,reset:l,setDefaultNodesAndEdges:c}=gi(Li,Ni),u=pi();n.useEffect((()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Ti,l()})),[]);const d=n.useRef(Ti);return n.useEffect((()=>{for(const n of $i){const l=e[n];l!==d.current[n]&&(void 0!==e[n]&&("nodes"===n?t(l):"edges"===n?o(l):"minZoom"===n?r(l):"maxZoom"===n?i(l):"translateExtent"===n?a(l):"nodeExtent"===n?s(l):"fitView"===n?u.setState({fitViewOnInit:l}):"fitViewOptions"===n?u.setState({fitViewOnInitOptions:l}):u.setState({[n]:l})))}d.current=e}),$i.map((t=>e[t]))),null}function ji(){return"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):null}const Vi="undefined"!=typeof document?document:null;function Hi(e=null,t={target:Vi,actInsideInputWithModifier:!0}){const[o,r]=n.useState(!1),i=n.useRef(!1),a=n.useRef(new Set([])),[s,l]=n.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return n.useEffect((()=>{const n=t?.target||Vi;if(null!==e){const e=e=>{i.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Wo(e))return!1;const n=Yi(e.code,l);a.current.add(e[n]),Xi(s,a.current,!1)&&(e.preventDefault(),r(!0))},o=e=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Wo(e))return!1;const n=Yi(e.code,l);Xi(s,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[n]),"Meta"===e.key&&a.current.clear(),i.current=!1},c=()=>{a.current.clear(),r(!1)};return n?.addEventListener("keydown",e),n?.addEventListener("keyup",o),window.addEventListener("blur",c),window.addEventListener("contextmenu",c),()=>{n?.removeEventListener("keydown",e),n?.removeEventListener("keyup",o),window.removeEventListener("blur",c),window.removeEventListener("contextmenu",c)}}}),[e,r]),o}function Xi(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function Yi(e,t){return t.includes(e)?"code":"key"}const Zi=()=>{const e=pi();return n.useMemo((()=>({zoomIn:t=>e.getState().panZoom?.scaleBy(1.2,{duration:t?.duration}),zoomOut:t=>e.getState().panZoom?.scaleBy(1/1.2,{duration:t?.duration}),zoomTo:(t,n)=>e.getState().panZoom?.scaleTo(t,{duration:n?.duration}),getZoom:()=>e.getState().transform[2],setViewport:(t,n)=>{const{transform:[o,r,i],panZoom:a}=e.getState();a?.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},{duration:n?.duration})},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>{const{nodeLookup:n,width:o,height:r,nodeOrigin:i,minZoom:a,maxZoom:s,panZoom:l}=e.getState();return!!l&&mo({nodeLookup:n,width:o,height:r,nodeOrigin:i,minZoom:a,maxZoom:s,panZoom:l},t)},setCenter:(t,n,o)=>{const{width:r,height:i,maxZoom:a,panZoom:s}=e.getState(),l=void 0!==o?.zoom?o.zoom:a,c=r/2-t*l,u=i/2-n*l;s?.setViewport({x:c,y:u,zoom:l},{duration:o?.duration})},fitBounds:(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:a,panZoom:s}=e.getState(),l=$o(t,o,r,i,a,n?.padding??.1);s?.setViewport(l,{duration:n?.duration})},screenToFlowPosition:(t,n={snapToGrid:!0})=>{const{transform:o,snapGrid:r,domNode:i}=e.getState();if(!i)return t;const{x:a,y:s}=i.getBoundingClientRect(),l={x:t.x-a,y:t.y-s};return Do(l,o,n.snapToGrid,r)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),a=Ro(t,n);return{x:a.x+r,y:a.y+i}}})),[])};function Wi(e,t){const n=[],o=new Map;for(const t of e)if("add"!==t.type)if("remove"===t.type||"replace"===t.type)o.set(t.id,[t]);else{const e=o.get(t.id);e?e.push(t):o.set(t.id,[t])}else n.push(t.item);for(const e of t){const t=o.get(e.id);if(!t){n.push(e);continue}if("remove"===t[0].type)continue;if("replace"===t[0].type){n.push({...t[0].item});continue}const r={...e};for(const e of t)Ui(e,r);n.push(r)}return n}function Ui(e,t){switch(e.type){case"select":t.selected=e.selected;break;case"position":void 0!==e.position&&(t.position=e.position),void 0!==e.dragging&&(t.dragging=e.dragging);break;case"dimensions":void 0!==e.dimensions&&(t.measured??={},t.measured.width=e.dimensions.width,t.measured.height=e.dimensions.height,e.setAttributes&&(t.width=e.dimensions.width,t.height=e.dimensions.height)),"boolean"==typeof e.resizing&&(t.resizing=e.resizing)}}function Fi(e,t){return Wi(e,t)}function Ki(e,t){return Wi(e,t)}function Gi(e,t){return{id:e,type:"select",selected:t}}function qi(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const e=t.has(r);void 0===i.selected&&!e||i.selected===e||(n&&(i.selected=e),o.push(Gi(i.id,e)))}return o}function Qi({items:e=[],lookup:t}){const n=[],o=new Map(e.map((e=>[e.id,e])));for(const o of e){const e=t.get(o.id),r=e?.internals?.userNode??e;void 0!==r&&r!==o&&n.push({id:o.id,item:o,type:"replace"}),void 0===r&&n.push({item:o,type:"add"})}for(const[e]of t){void 0===o.get(e)&&n.push({id:e,type:"remove"})}return n}function Ji(e){return{id:e.id,type:"remove"}}const ea=e=>(e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e))(e),ta=e=>co(e);function na(e){return n.forwardRef(e)}const oa="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function ra(e){const[t,o]=n.useState(!1),[r]=n.useState((()=>function(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}((()=>o(!0)))));return oa((()=>{if(!t)return void r.reset();const n=r.get();n.length&&(e(n),r.reset()),o(!1)}),[t]),r}const ia=n.createContext(null);function aa({children:e}){const o=pi(),r=ra(n.useCallback((e=>{const{nodes:t=[],setNodes:n,hasDefaultNodes:r,onNodesChange:i,nodeLookup:a}=o.getState();let s=t;for(const t of e)s="function"==typeof t?t(s):t;r?n(s):i&&i(Qi({items:s,lookup:a}))}),[])),i=ra(n.useCallback((e=>{const{edges:t=[],setEdges:n,hasDefaultEdges:r,onEdgesChange:i,edgeLookup:a}=o.getState();let s=t;for(const t of e)s="function"==typeof t?t(s):t;r?n(s):i&&i(Qi({items:s,lookup:a}))}),[])),a=n.useMemo((()=>({nodeQueue:r,edgeQueue:i})),[]);return t.jsx(ia.Provider,{value:a,children:e})}const sa=e=>!!e.panZoom;function la(){const e=Zi(),t=pi(),o=function(){const e=n.useContext(ia);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}(),r=gi(sa),i=n.useMemo((()=>{const e=e=>t.getState().nodeLookup.get(e),n=e=>{o.nodeQueue.push(e)},r=e=>{o.edgeQueue.push(e)},i=e=>{const{nodeLookup:n,nodeOrigin:o}=t.getState(),r=ea(e)?e:n.get(e.id),i=r.parentId?Vo(r.position,r.parentId,n,o):r.position,a={id:r.id,position:i,width:r.measured?.width??r.width,height:r.measured?.height??r.height,data:r.data};return _o(a)},a=(e,t,o={replace:!1})=>{n((n=>n.map((n=>{if(n.id===e){const e="function"==typeof t?t(n):t;return o.replace&&ea(e)?e:{...n,...e}}return n}))))},s=(e,t,n={replace:!1})=>{r((o=>o.map((o=>{if(o.id===e){const e="function"==typeof t?t(o):t;return n.replace&&ta(e)?e:{...o,...e}}return o}))))};return{getNodes:()=>t.getState().nodes.map((e=>({...e}))),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:n,setEdges:r,addNodes:e=>{const t=Array.isArray(e)?e:[e];o.nodeQueue.push((e=>[...e,...t]))},addEdges:e=>{const t=Array.isArray(e)?e:[e];o.edgeQueue.push((e=>[...e,...t]))},toObject:()=>{const{nodes:e=[],edges:n=[],transform:o}=t.getState(),[r,i,a]=o;return{nodes:e.map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:r,y:i,zoom:a}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{const{nodes:o,edges:r,onNodesDelete:i,onEdgesDelete:a,triggerNodeChanges:s,triggerEdgeChanges:l,onDelete:c,onBeforeDelete:u}=t.getState(),{nodes:d,edges:h}=await async function({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map((e=>e.id))),a=[];for(const e of n){if(!1===e.deletable)continue;const t=i.has(e.id),n=!t&&e.parentId&&a.find((t=>t.id===e.parentId));(t||n)&&a.push(e)}const s=new Set(t.map((e=>e.id))),l=o.filter((e=>!1!==e.deletable)),c=po(a,l);for(const e of l)s.has(e.id)&&!c.find((t=>t.id===e.id))&&c.push(e);if(!r)return{edges:c,nodes:a};const u=await r({nodes:a,edges:c});return"boolean"==typeof u?u?{edges:c,nodes:a}:{edges:[],nodes:[]}:u}({nodesToRemove:e,edgesToRemove:n,nodes:o,edges:r,onBeforeDelete:u}),f=h.length>0,g=d.length>0;if(f){const e=h.map(Ji);a?.(h),l(e)}if(g){const e=d.map(Ji);i?.(d),s(e)}return(g||f)&&c?.({nodes:d,edges:h}),{deletedNodes:d,deletedEdges:h}},getIntersectingNodes:(e,n=!0,o)=>{const r=Po(e),a=r?e:i(e),s=void 0!==o;return a?(o||t.getState().nodes).filter((o=>{const i=t.getState().nodeLookup.get(o.id);if(i&&!r&&(o.id===e.id||!i.internals.positionAbsolute))return!1;const l=_o(s?o:i),c=ko(l,a);return n&&c>0||c>=a.width*a.height})):[]},isNodeIntersecting:(e,t,n=!0)=>{const o=Po(e)?e:i(e);if(!o)return!1;const r=ko(o,t);return n&&r>0||r>=o.width*o.height},updateNode:a,updateNodeData:(e,t,n={replace:!1})=>{a(e,(e=>{const o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}}),n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,(e=>{const o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}}),n)}}}),[]);return n.useMemo((()=>({...i,...e,viewportInitialized:r})),[r])}const ca=e=>e.selected,ua={actInsideInputWithModifier:!1};const da={position:"absolute",width:"100%",height:"100%",top:0,left:0},ha=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib});function fa({onPaneContextMenu:o,zoomOnScroll:r=!0,zoomOnPinch:i=!0,panOnScroll:a=!1,panOnScrollSpeed:s=.5,panOnScrollMode:l=e.PanOnScrollMode.Free,zoomOnDoubleClick:c=!0,panOnDrag:u=!0,defaultViewport:d,translateExtent:h,minZoom:f,maxZoom:g,zoomActivationKeyCode:p,preventScrolling:m=!0,children:y,noWheelClassName:v,noPanClassName:x,onViewportChange:w,isControlledViewport:b}){const S=pi(),E=n.useRef(null),{userSelectionActive:C,lib:_}=gi(ha,Ni),M=Hi(p),N=n.useRef();return function(e){const t=pi();n.useEffect((()=>{const n=()=>{if(!e.current)return!1;const n=Xo(e.current);0!==n.height&&0!==n.width||t.getState().onError?.("004",Qn.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener("resize",n);const t=new ResizeObserver((()=>n()));return t.observe(e.current),()=>{window.removeEventListener("resize",n),t&&e.current&&t.unobserve(e.current)}}}),[])}(E),n.useEffect((()=>{if(E.current){N.current=Br({domNode:E.current,minZoom:f,maxZoom:g,translateExtent:h,viewport:d,onTransformChange:e=>{w?.({x:e[0],y:e[1],zoom:e[2]}),b||S.setState({transform:e})},onDraggingChange:e=>S.setState({paneDragging:e}),onPanZoomStart:(e,t)=>{const{onViewportChangeStart:n,onMoveStart:o}=S.getState();o?.(e,t),n?.(t)},onPanZoom:(e,t)=>{const{onViewportChange:n,onMove:o}=S.getState();o?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{const{onViewportChangeEnd:n,onMoveEnd:o}=S.getState();o?.(e,t),n?.(t)}});const{x:e,y:t,zoom:n}=N.current.getViewport();return S.setState({panZoom:N.current,transform:[e,t,n],domNode:E.current.closest(".react-flow")}),()=>{N.current?.destroy()}}}),[]),n.useEffect((()=>{N.current?.update({onPaneContextMenu:o,zoomOnScroll:r,zoomOnPinch:i,panOnScroll:a,panOnScrollSpeed:s,panOnScrollMode:l,zoomOnDoubleClick:c,panOnDrag:u,zoomActivationKeyPressed:M,preventScrolling:m,noPanClassName:x,userSelectionActive:C,noWheelClassName:v,lib:_})}),[o,r,i,a,s,l,c,u,M,m,x,C,v,_]),t.jsx("div",{className:"react-flow__renderer",ref:E,style:da,children:y})}const ga=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function pa(){const{userSelectionActive:e,userSelectionRect:n}=gi(ga,Ni);return e&&n?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const ma=(e,t)=>n=>{n.target===t.current&&e?.(n)},ya=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging});function va({isSelecting:o,selectionMode:i=e.SelectionMode.Full,panOnDrag:a,onSelectionStart:s,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:h,onPaneMouseMove:f,onPaneMouseLeave:g,children:p}){const m=n.useRef(null),y=pi(),v=n.useRef(0),x=n.useRef(0),w=n.useRef(),b=n.useRef(new Map),{userSelectionActive:S,elementsSelectable:E,dragging:C}=gi(ya,Ni),_=()=>{y.setState({userSelectionActive:!1,userSelectionRect:null}),v.current=0,x.current=0},M=e=>{c?.(e),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},N=d?e=>d(e):void 0,k=E&&(o||S);return t.jsxs("div",{className:r(["react-flow__pane",{draggable:a,dragging:C,selection:o}]),onClick:k?void 0:ma(M,m),onContextMenu:ma((e=>{Array.isArray(a)&&a?.includes(2)?e.preventDefault():u?.(e)}),m),onWheel:ma(N,m),onMouseEnter:k?void 0:h,onMouseDown:k?e=>{const{resetSelectedElements:t,domNode:n,edgeLookup:r}=y.getState();if(w.current=n?.getBoundingClientRect(),!E||!o||0!==e.button||e.target!==m.current||!w.current)return;b.current=new Map;for(const[e,t]of r)b.current.set(t.source,b.current.get(t.source)?.add(e)||new Set([e])),b.current.set(t.target,b.current.get(t.target)?.add(e)||new Set([e]));const{x:i,y:a}=Fo(e.nativeEvent,w.current);t(),y.setState({userSelectionRect:{width:0,height:0,startX:i,startY:a,x:i,y:a}}),s?.(e)}:void 0,onMouseMove:k?t=>{const{userSelectionRect:n,edgeLookup:r,transform:a,nodeOrigin:s,nodeLookup:l,triggerNodeChanges:c,triggerEdgeChanges:u}=y.getState();if(!o||!w.current||!n)return;const{x:d,y:h}=Fo(t.nativeEvent,w.current),{startX:f,startY:g}=n,p={startX:f,startY:g,x:d<f?d:f,y:h<g?h:g,width:Math.abs(d-f),height:Math.abs(h-g)},m=go(l,p,a,i===e.SelectionMode.Partial,!0,s),S=new Set,E=new Set;for(const e of m){E.add(e.id);const t=b.current.get(e.id);if(t)for(const e of t)S.add(e)}if(v.current!==E.size){v.current=E.size;c(qi(l,E,!0))}if(x.current!==S.size){x.current=S.size;u(qi(r,S))}y.setState({userSelectionRect:p,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onMouseUp:k?e=>{if(0!==e.button)return;const{userSelectionRect:t}=y.getState();!S&&t&&e.target===m.current&&M?.(e),y.setState({nodesSelectionActive:v.current>0}),_(),l?.(e)}:void 0,onMouseLeave:k?e=>{S&&(y.setState({nodesSelectionActive:v.current>0}),l?.(e)),_()}:g,ref:m,style:da,children:[p,t.jsx(pa,{})]})}function xa({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:s,onError:l}=t.getState(),c=s.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&a)&&(i({nodes:[c],edges:[]}),requestAnimationFrame((()=>o?.current?.blur()))):r([e])):l?.("012",Qn.error012(e))}function wa({nodeRef:e,disabled:t=!1,noDragClassName:o,handleSelector:r,nodeId:i,isSelectable:a}){const s=pi(),[l,c]=n.useState(!1),u=n.useRef();return n.useEffect((()=>{u.current=Cr({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{xa({id:t,store:s,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})}),[]),n.useEffect((()=>{if(t)u.current?.destroy();else if(e.current)return u.current?.update({noDragClassName:o,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i}),()=>{u.current?.destroy()}}),[o,r,t,a,e,i]),l}const ba=e=>t=>t.selected&&(t.draggable||e&&void 0===t.draggable);function Sa(){const e=pi();return n.useCallback((t=>{const{nodeExtent:n,snapToGrid:o,snapGrid:r,nodesDraggable:i,onError:a,updateNodePositions:s,nodeLookup:l,nodeOrigin:c}=e.getState(),u=new Map,d=ba(i),h=o?r[0]:5,f=o?r[1]:5,g=t.direction.x*h*t.factor,p=t.direction.y*f*t.factor;for(const[,e]of l){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+g,y:e.internals.positionAbsolute.y+p};o&&(t=Ao(t,r));const{position:i,positionAbsolute:s}=yo({nodeId:e.id,nextPosition:t,nodeLookup:l,nodeExtent:n,nodeOrigin:c,onError:a});e.position=i,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)}),[])}const Ea=n.createContext(null),Ca=Ea.Provider;Ea.Consumer;const _a=()=>n.useContext(Ea),Ma=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId});const Na=n.memo(na((function({type:n="source",position:o=e.Position.Top,isValidConnection:i,isConnectable:a=!0,isConnectableStart:s=!0,isConnectableEnd:l=!0,id:c,onConnect:u,children:d,className:h,onMouseDown:f,onTouchStart:g,...p},m){const y=c||null,v="target"===n,x=pi(),w=_a(),{connectOnClick:b,noPanClassName:S,rfId:E}=gi(Ma,Ni),{connectingFrom:C,connectingTo:_,clickConnecting:M,isPossibleEndHandle:N,connectionInProcess:k,valid:P}=gi(((t,n,o)=>r=>{const{connectionStartHandle:i,connectionEndHandle:a,connectionClickStartHandle:s,connectionMode:l,connectionStatus:c}=r,u=a?.nodeId===t&&a?.handleId===n&&a?.type===o;return{connectingFrom:i?.nodeId===t&&i?.handleId===n&&i?.type===o,connectingTo:u,clickConnecting:s?.nodeId===t&&s?.handleId===n&&s?.type===o,isPossibleEndHandle:l===e.ConnectionMode.Strict?i?.type!==o:t!==i?.nodeId||n!==i?.handleId,connectionInProcess:!!i,valid:u&&"valid"===c}})(w,y,n),Ni);w||x.getState().onError?.("010",Qn.error010());const z=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=x.getState(),r={...t,...e};if(o){const{edges:e,setEdges:t}=x.getState();t(or(r,e))}n?.(r),u?.(r)},O=e=>{if(!w)return;const t=Uo(e.nativeEvent);if(s&&(t&&0===e.button||!t)){const t=x.getState();Or.onPointerDown(e.nativeEvent,{autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:v,handleId:y,nodeId:w,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:t.onConnectEnd,updateConnection:t.updateConnection,onConnect:z,isValidConnection:i||t.isValidConnection,getTransform:()=>x.getState().transform,getConnectionStartHandle:()=>x.getState().connectionStartHandle})}t?f?.(e):g?.(e)};return t.jsx("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":o,"data-id":`${E}-${w}-${y}-${n}`,className:r(["react-flow__handle",`react-flow__handle-${o}`,"nodrag",S,h,{source:!v,target:v,connectable:a,connectablestart:s,connectableend:l,clickconnecting:M,connectingfrom:C,connectingto:_,valid:P,connectionindicator:a&&(!k||N)&&(k?l:s)}]),onMouseDown:O,onTouchStart:O,onClick:b?e=>{const{onClickConnectStart:t,onClickConnectEnd:o,connectionClickStartHandle:r,connectionMode:a,isValidConnection:l,lib:c,rfId:u}=x.getState();if(!w||!r&&!s)return;if(!r)return t?.(e.nativeEvent,{nodeId:w,handleId:y,handleType:n}),void x.setState({connectionClickStartHandle:{nodeId:w,type:n,handleId:y}});const d=Yo(e.target),h=i||l,{connection:f,isValid:g}=Or.isValid(e.nativeEvent,{handle:{nodeId:w,id:y,type:n},connectionMode:a,fromNodeId:r.nodeId,fromHandleId:r.handleId||null,fromType:r.type,isValidConnection:h,flowId:u,doc:d,lib:c});g&&f&&z(f),o?.(e),x.setState({connectionClickStartHandle:null})}:void 0,ref:m,...p,children:d})})));const ka={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Pa={input:function({data:n,isConnectable:o,sourcePosition:r=e.Position.Bottom}){return t.jsxs(t.Fragment,{children:[n?.label,t.jsx(Na,{type:"source",position:r,isConnectable:o})]})},default:function({data:n,isConnectable:o,targetPosition:r=e.Position.Top,sourcePosition:i=e.Position.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(Na,{type:"target",position:r,isConnectable:o}),n?.label,t.jsx(Na,{type:"source",position:i,isConnectable:o})]})},output:function({data:n,isConnectable:o,targetPosition:r=e.Position.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(Na,{type:"target",position:r,isConnectable:o}),n?.label]})},group:function(){return null}};const za=e=>{const{width:t,height:n,x:o,y:r}=fo(e.nodeLookup,{nodeOrigin:e.nodeOrigin,filter:e=>!!e.selected});return{width:zo(t)?t:null,height:zo(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function Oa({onSelectionContextMenu:e,noPanClassName:o,disableKeyboardA11y:i}){const a=pi(),{width:s,height:l,transformString:c,userSelectionActive:u}=gi(za,Ni),d=Sa(),h=n.useRef(null);if(n.useEffect((()=>{i||h.current?.focus({preventScroll:!0})}),[i]),wa({nodeRef:h}),u||!s||!l)return null;const f=e?t=>{const n=a.getState().nodes.filter((e=>e.selected));e(t,n)}:void 0;return t.jsx("div",{className:r(["react-flow__nodesselection","react-flow__container",o]),style:{transform:c},children:t.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:i?void 0:-1,onKeyDown:i?void 0:e=>{Object.prototype.hasOwnProperty.call(ka,e.key)&&d({direction:ka[e.key],factor:e.shiftKey?4:1})},style:{width:s,height:l}})})}const Ia=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Aa({children:e,onPaneClick:o,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:s,onPaneScroll:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:h,onSelectionStart:f,onSelectionEnd:g,multiSelectionKeyCode:p,panActivationKeyCode:m,zoomActivationKeyCode:y,elementsSelectable:v,zoomOnScroll:x,zoomOnPinch:w,panOnScroll:b,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:C,panOnDrag:_,defaultViewport:M,translateExtent:N,minZoom:k,maxZoom:P,preventScrolling:z,onSelectionContextMenu:O,noWheelClassName:I,noPanClassName:A,disableKeyboardA11y:D,onViewportChange:R,isControlledViewport:$}){const{nodesSelectionActive:L,userSelectionActive:T}=gi(Ia),B=Hi(u),j=Hi(m),V=j||_,H=j||b,X=B||T||d&&!0!==V;return function({deleteKeyCode:e,multiSelectionKeyCode:t}){const o=pi(),{deleteElements:r}=la(),i=Hi(e,ua),a=Hi(t);n.useEffect((()=>{if(i){const{edges:e,nodes:t}=o.getState();r({nodes:t.filter(ca),edges:e.filter(ca)}),o.setState({nodesSelectionActive:!1})}}),[i]),n.useEffect((()=>{o.setState({multiSelectionActive:a})}),[a])}({deleteKeyCode:c,multiSelectionKeyCode:p}),t.jsx(fa,{onPaneContextMenu:s,elementsSelectable:v,zoomOnScroll:x,zoomOnPinch:w,panOnScroll:H,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:C,panOnDrag:!B&&V,defaultViewport:M,translateExtent:N,minZoom:k,maxZoom:P,zoomActivationKeyCode:y,preventScrolling:z,noWheelClassName:I,noPanClassName:A,onViewportChange:R,isControlledViewport:$,children:t.jsxs(va,{onSelectionStart:f,onSelectionEnd:g,onPaneClick:o,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:s,onPaneScroll:l,panOnDrag:V,isSelecting:!!X,selectionMode:h,children:[e,L&&t.jsx(Oa,{onSelectionContextMenu:O,noPanClassName:A,disableKeyboardA11y:D})]})})}Aa.displayName="FlowRenderer";const Da=n.memo(Aa),Ra=e=>t=>e?go(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map((e=>e.id)):Array.from(t.nodeLookup.keys());const $a=e=>e.updateNodeInternals;function La({id:e,onClick:o,onMouseEnter:i,onMouseMove:a,onMouseLeave:s,onContextMenu:l,onDoubleClick:c,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:f,resizeObserver:g,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:y,rfId:v,nodeTypes:x,nodeExtent:w,nodeOrigin:b,onError:S}){const{node:E,internals:C,isParent:_}=gi((t=>{const n=t.nodeLookup.get(e),o=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:o}}),Ni);let M=E.type||"default",N=x?.[M]||Pa[M];void 0===N&&(S?.("003",Qn.error003(M)),M="default",N=Pa.default);const k=!!(E.draggable||u&&void 0===E.draggable),P=!!(E.selectable||d&&void 0===E.selectable),z=!!(E.connectable||h&&void 0===E.connectable),O=!!(E.focusable||f&&void 0===E.focusable),I=pi(),A=jo(E),D=function({node:e,nodeType:t,hasDimensions:o,resizeObserver:r}){const i=pi(),a=n.useRef(null),s=n.useRef(null),l=n.useRef(e.sourcePosition),c=n.useRef(e.targetPosition),u=n.useRef(t),d=o&&!!e.internals.handleBounds;return n.useEffect((()=>{!a.current||e.hidden||d&&s.current===a.current||(s.current&&r?.unobserve(s.current),r?.observe(a.current),s.current=a.current)}),[d,e.hidden]),n.useEffect((()=>()=>{s.current&&(r?.unobserve(s.current),s.current=null)}),[]),n.useEffect((()=>{if(a.current){const n=u.current!==t,o=l.current!==e.sourcePosition,r=c.current!==e.targetPosition;(n||o||r)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}}),[e.id,t,e.sourcePosition,e.targetPosition]),a}({node:E,nodeType:M,hasDimensions:A,resizeObserver:g}),R=wa({nodeRef:D,disabled:E.hidden||!k,noDragClassName:p,handleSelector:E.dragHandle,nodeId:e,isSelectable:P}),$=Sa();if(E.hidden)return null;const L=Bo(E),T=function(e){return void 0===e.internals.handleBounds?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}(E),B=w?xo(C.positionAbsolute,w):C.positionAbsolute,j=Io({...B,...L,origin:E.origin||b}),V=P||k||o||i||a||s,H=i?e=>i(e,{...C.userNode}):void 0,X=a?e=>a(e,{...C.userNode}):void 0,Y=s?e=>s(e,{...C.userNode}):void 0,Z=l?e=>l(e,{...C.userNode}):void 0,W=c?e=>c(e,{...C.userNode}):void 0;return t.jsx("div",{className:r(["react-flow__node",`react-flow__node-${M}`,{[m]:k},E.className,{selected:E.selected,selectable:P,parent:_,draggable:k,dragging:R}]),ref:D,style:{zIndex:C.z,transform:`translate(${j.x}px,${j.y}px)`,pointerEvents:V?"all":"none",visibility:A?"visible":"hidden",...E.style,...T},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:X,onMouseLeave:Y,onContextMenu:Z,onClick:t=>{const{selectNodesOnDrag:n,nodeDragThreshold:r}=I.getState();P&&(!n||!k||r>0)&&xa({id:e,store:I,nodeRef:D}),o&&o(t,{...C.userNode})},onDoubleClick:W,onKeyDown:O?t=>{if(!Wo(t.nativeEvent)&&!y)if(eo.includes(t.key)&&P){const n="Escape"===t.key;xa({id:e,store:I,unselect:n,nodeRef:D})}else k&&E.selected&&Object.prototype.hasOwnProperty.call(ka,t.key)&&(I.setState({ariaLiveMessage:`Moved selected node ${t.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~B.x}, y: ${~~B.y}`}),$({direction:ka[t.key],factor:t.shiftKey?4:1}))}:void 0,tabIndex:O?0:void 0,role:O?"button":void 0,"aria-describedby":y?void 0:`${vi}-${v}`,"aria-label":E.ariaLabel,children:t.jsx(Ca,{value:e,children:t.jsx(N,{id:e,data:E.data,type:M,positionAbsoluteX:B.x,positionAbsoluteY:B.y,selected:E.selected,selectable:P,draggable:k,deletable:E.deletable??!0,isConnectable:z,sourcePosition:E.sourcePosition,targetPosition:E.targetPosition,dragging:R,dragHandle:E.dragHandle,zIndex:C.z,parentId:E.parentId,...L})})})}const Ta=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ba(e){const{nodesDraggable:o,nodesConnectable:r,nodesFocusable:i,elementsSelectable:a,onError:s}=gi(Ta,Ni),l=(c=e.onlyRenderVisibleElements,gi(n.useCallback(Ra(c),[c]),Ni));var c;const u=function(){const e=gi($a),[t]=n.useState((()=>"undefined"==typeof ResizeObserver?null:new ResizeObserver((t=>{const n=new Map;t.forEach((e=>{const t=e.target.getAttribute("data-id");n.set(t,{id:t,nodeElement:e.target,force:!0})})),e(n)}))));return n.useEffect((()=>()=>{t?.disconnect()}),[t]),t}();return t.jsx("div",{className:"react-flow__nodes",style:da,children:l.map((n=>t.jsx(La,{id:n,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,nodeOrigin:e.nodeOrigin,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:u,nodesDraggable:o,nodesConnectable:r,nodesFocusable:i,elementsSelectable:a,onError:s},n)))})}Ba.displayName="NodeRenderer";const ja=n.memo(Ba);const Va={[e.MarkerType.Arrow]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[e.MarkerType.ArrowClosed]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Ha=({id:e,type:o,color:r,width:i=12.5,height:a=12.5,markerUnits:s="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const u=function(e){const t=pi();return n.useMemo((()=>Object.prototype.hasOwnProperty.call(Va,e)?Va[e]:(t.getState().onError?.("009",Qn.error009(e)),null)),[e])}(o);return u?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:c,refX:"0",refY:"0",children:t.jsx(u,{color:r,strokeWidth:l})}):null},Xa=({defaultColor:e,rfId:o})=>{const r=gi((e=>e.edges)),i=gi((e=>e.defaultEdgeOptions)),a=n.useMemo((()=>{const t=function(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce(((e,a)=>([a.markerStart||o,a.markerEnd||r].forEach((o=>{if(o&&"object"==typeof o){const r=fr(o,t);i.has(r)||(e.push({id:r,color:o.color||n,...o}),i.add(r))}})),e)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))}(r,{id:o,defaultColor:e,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd});return t}),[r,i,o,e]);return a.length?t.jsx("svg",{className:"react-flow__marker",children:t.jsx("defs",{children:a.map((e=>t.jsx(Ha,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id)))})}):null};Xa.displayName="MarkerDefinitions";var Ya=n.memo(Xa);function Za({x:e,y:o,label:i,labelStyle:a={},labelShowBg:s=!0,labelBgStyle:l={},labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...f}){const[g,p]=n.useState({x:1,y:0,width:0,height:0}),m=r(["react-flow__edge-textwrapper",h]),y=n.useRef(null);return n.useEffect((()=>{if(y.current){const e=y.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[i]),void 0!==i&&i?t.jsxs("g",{transform:`translate(${e-g.width/2} ${o-g.height/2})`,className:m,visibility:g.width?"visible":"hidden",...f,children:[s&&t.jsx("rect",{width:g.width+2*c[0],x:-c[0],y:-c[1],height:g.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:u,ry:u}),t.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:y,style:a,children:i}),d]}):null}Za.displayName="EdgeText";const Wa=n.memo(Za);function Ua({id:e,path:n,labelX:o,labelY:i,label:a,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:g,className:p,interactionWidth:m=20}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{id:e,style:h,d:n,fill:"none",className:r(["react-flow__edge-path",p]),markerEnd:f,markerStart:g}),m&&t.jsx("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),a&&zo(o)&&zo(i)?t.jsx(Wa,{x:o,y:i,label:a,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function Fa({pos:t,x1:n,y1:o,x2:r,y2:i}){return t===e.Position.Left||t===e.Position.Right?[.5*(n+r),o]:[n,.5*(o+i)]}function Ka({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top}){const[s,l]=Fa({pos:o,x1:t,y1:n,x2:r,y2:i}),[c,u]=Fa({pos:a,x1:r,y1:i,x2:t,y2:n}),[d,h,f,g]=Go({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${t},${n} C${s},${l} ${c},${u} ${r},${i}`,d,h,f,g]}function Ga(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:a,targetY:s,sourcePosition:l=e.Position.Bottom,targetPosition:c=e.Position.Top,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:x})=>{const[w,b,S]=Ka({sourceX:r,sourceY:i,sourcePosition:l,targetX:a,targetY:s,targetPosition:c}),E=o.isInternal?void 0:n;return t.jsx(Ua,{id:E,path:w,labelX:b,labelY:S,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:x})}))}const qa=Ga({isInternal:!1}),Qa=Ga({isInternal:!0});function Ja(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:a,targetY:s,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,sourcePosition:p=e.Position.Bottom,targetPosition:m=e.Position.Top,markerEnd:y,markerStart:v,pathOptions:x,interactionWidth:w})=>{const[b,S,E]=lr({sourceX:r,sourceY:i,sourcePosition:p,targetX:a,targetY:s,targetPosition:m,borderRadius:x?.borderRadius,offset:x?.offset}),C=o.isInternal?void 0:n;return t.jsx(Ua,{id:C,path:b,labelX:S,labelY:E,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:v,interactionWidth:w})}))}qa.displayName="SimpleBezierEdge",Qa.displayName="SimpleBezierEdgeInternal";const es=Ja({isInternal:!1}),ts=Ja({isInternal:!0});function ns(e){return n.memo((({id:o,...r})=>{const i=e.isInternal?void 0:o;return t.jsx(es,{...r,id:i,pathOptions:n.useMemo((()=>({borderRadius:0,offset:r.pathOptions?.offset})),[r.pathOptions?.offset])})}))}es.displayName="SmoothStepEdge",ts.displayName="SmoothStepEdgeInternal";const os=ns({isInternal:!1}),rs=ns({isInternal:!0});function is(e){return n.memo((({id:n,sourceX:o,sourceY:r,targetX:i,targetY:a,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:p,interactionWidth:m})=>{const[y,v,x]=rr({sourceX:o,sourceY:r,targetX:i,targetY:a}),w=e.isInternal?void 0:n;return t.jsx(Ua,{id:w,path:y,labelX:v,labelY:x,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:p,interactionWidth:m})}))}os.displayName="StepEdge",rs.displayName="StepEdgeInternal";const as=is({isInternal:!1}),ss=is({isInternal:!0});function ls(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:a,targetY:s,sourcePosition:l=e.Position.Bottom,targetPosition:c=e.Position.Top,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,pathOptions:x,interactionWidth:w})=>{const[b,S,E]=Jo({sourceX:r,sourceY:i,sourcePosition:l,targetX:a,targetY:s,targetPosition:c,curvature:x?.curvature}),C=o.isInternal?void 0:n;return t.jsx(Ua,{id:C,path:b,labelX:S,labelY:E,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:w})}))}as.displayName="StraightEdge",ss.displayName="StraightEdgeInternal";const cs=ls({isInternal:!1}),us=ls({isInternal:!0});cs.displayName="BezierEdge",us.displayName="BezierEdgeInternal";const ds={default:us,straight:ss,step:rs,smoothstep:ts,simplebezier:Qa},hs={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},fs=(t,n,o)=>o===e.Position.Left?t-n:o===e.Position.Right?t+n:t,gs=(t,n,o)=>o===e.Position.Top?t-n:o===e.Position.Bottom?t+n:t,ps="react-flow__edgeupdater";function ms({position:e,centerX:n,centerY:o,radius:i=10,onMouseDown:a,onMouseEnter:s,onMouseOut:l,type:c}){return t.jsx("circle",{onMouseDown:a,onMouseEnter:s,onMouseOut:l,className:r([ps,`${ps}-${c}`]),cx:fs(n,i,e),cy:gs(o,i,e),r:i,stroke:"transparent",fill:"transparent"})}function ys({isUpdatable:e,edgeUpdaterRadius:n,edge:o,targetHandleId:r,sourceHandleId:i,sourceX:a,sourceY:s,targetX:l,targetY:c,sourcePosition:u,targetPosition:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g,setUpdating:p,setUpdateHover:m}){const y=pi(),v=(e,t)=>{if(0!==e.button)return;const{autoPanOnConnect:n,domNode:a,isValidConnection:s,connectionMode:l,connectionRadius:c,lib:u,onConnectStart:d,onConnectEnd:m,cancelConnection:v,nodeLookup:x,rfId:w,panBy:b,updateConnection:S}=y.getState(),E=t?o.target:o.source,C=(t?r:i)||null,_=t?"target":"source",M=t;p(!0),f?.(e,o,_);Or.onPointerDown(e.nativeEvent,{autoPanOnConnect:n,connectionMode:l,connectionRadius:c,domNode:a,handleId:C,nodeId:E,nodeLookup:x,isTarget:M,edgeUpdaterType:_,lib:u,flowId:w,cancelConnection:v,panBy:b,isValidConnection:s,onConnect:e=>h?.(o,e),onConnectStart:d,onConnectEnd:m,onEdgeUpdateEnd:e=>{p(!1),g?.(e,o,_)},updateConnection:S,getTransform:()=>y.getState().transform,getConnectionStartHandle:()=>y.getState().connectionStartHandle})},x=()=>m(!0),w=()=>m(!1);return t.jsxs(t.Fragment,{children:[("source"===e||!0===e)&&t.jsx(ms,{position:u,centerX:a,centerY:s,radius:n,onMouseDown:e=>v(e,!0),onMouseEnter:x,onMouseOut:w,type:"source"}),("target"===e||!0===e)&&t.jsx(ms,{position:d,centerX:l,centerY:c,radius:n,onMouseDown:e=>v(e,!1),onMouseEnter:x,onMouseOut:w,type:"target"})]})}function vs({id:o,edgesFocusable:i,edgesUpdatable:a,elementsSelectable:s,onClick:l,onDoubleClick:c,onContextMenu:u,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,edgeUpdaterRadius:g,onEdgeUpdate:p,onEdgeUpdateStart:m,onEdgeUpdateEnd:y,rfId:v,edgeTypes:x,noPanClassName:w,onError:b,disableKeyboardA11y:S}){let E=gi((e=>e.edgeLookup.get(o)));const C=gi((e=>e.defaultEdgeOptions));E=C?{...C,...E}:E;let _=E.type||"default",M=x?.[_]||ds[_];void 0===M&&(b?.("011",Qn.error011(_)),_="default",M=ds.default);const N=!!(E.focusable||i&&void 0===E.focusable),k=void 0!==p&&(E.updatable||a&&void 0===E.updatable),P=!!(E.selectable||s&&void 0===E.selectable),z=n.useRef(null),[O,I]=n.useState(!1),[A,D]=n.useState(!1),R=pi(),{zIndex:$,sourceX:L,sourceY:T,targetX:B,targetY:j,sourcePosition:V,targetPosition:H}=gi(n.useCallback((t=>{const n=t.nodeLookup.get(E.source),r=t.nodeLookup.get(E.target);if(!n||!r)return{zIndex:E.zIndex,...hs};const i=function(t){const{sourceNode:n,targetNode:o}=t;if(!cr(n)||!cr(o))return null;const r=n.internals.handleBounds||ur(n.handles),i=o.internals.handleBounds||ur(o.handles),a=hr(r?.source??[],t.sourceHandle),s=hr(t.connectionMode===e.ConnectionMode.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),t.targetHandle),l=a?.position||e.Position.Bottom,c=s?.position||e.Position.Top;if(!a||!s)return t.onError?.("008",Qn.error008(a?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const[u,d]=dr(l,n,a),[h,f]=dr(c,o,s);return{sourceX:u,sourceY:d,targetX:h,targetY:f,sourcePosition:l,targetPosition:c}}({id:o,sourceNode:n,targetNode:r,sourceHandle:E.sourceHandle||null,targetHandle:E.targetHandle||null,connectionMode:t.connectionMode,onError:b}),a=function({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1}){if(!r)return o;const i=n||t.selected||e.selected,a=Math.max(e.internals.z||0,t.internals.z||0,1e3);return o+(i?a:0)}({selected:E.selected,zIndex:E.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect});return{zIndex:a,...i||hs}}),[E.source,E.target,E.sourceHandle,E.targetHandle,E.selected,E.zIndex]),Ni),X=n.useMemo((()=>E.markerStart?`url('#${fr(E.markerStart,v)}')`:void 0),[E.markerStart,v]),Y=n.useMemo((()=>E.markerEnd?`url('#${fr(E.markerEnd,v)}')`:void 0),[E.markerEnd,v]);if(E.hidden||null===L||null===T||null===B||null===j)return null;const Z=c?e=>{c(e,{...E})}:void 0,W=u?e=>{u(e,{...E})}:void 0,U=d?e=>{d(e,{...E})}:void 0,F=h?e=>{h(e,{...E})}:void 0,K=f?e=>{f(e,{...E})}:void 0;return t.jsx("svg",{style:{zIndex:$},children:t.jsxs("g",{className:r(["react-flow__edge",`react-flow__edge-${_}`,E.className,w,{selected:E.selected,animated:E.animated,inactive:!P&&!l,updating:O,selectable:P}]),onClick:e=>{const{addSelectedEdges:t,unselectNodesAndEdges:n,multiSelectionActive:r}=R.getState();P&&(R.setState({nodesSelectionActive:!1}),E.selected&&r?(n({nodes:[],edges:[E]}),z.current?.blur()):t([o])),l&&l(e,E)},onDoubleClick:Z,onContextMenu:W,onMouseEnter:U,onMouseMove:F,onMouseLeave:K,onKeyDown:N?e=>{if(!S&&eo.includes(e.key)&&P){const{unselectNodesAndEdges:t,addSelectedEdges:n}=R.getState();"Escape"===e.key?(z.current?.blur(),t({edges:[E]})):n([o])}}:void 0,tabIndex:N?0:void 0,role:N?"button":"img","data-id":o,"data-testid":`rf__edge-${o}`,"aria-label":null===E.ariaLabel?void 0:E.ariaLabel||`Edge from ${E.source} to ${E.target}`,"aria-describedby":N?`${xi}-${v}`:void 0,ref:z,children:[!A&&t.jsx(M,{id:o,source:E.source,target:E.target,type:E.type,selected:E.selected,animated:E.animated,selectable:P,deletable:E.deletable??!0,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,sourceX:L,sourceY:T,targetX:B,targetY:j,sourcePosition:V,targetPosition:H,data:E.data,style:E.style,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerStart:X,markerEnd:Y,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth}),k&&t.jsx(ys,{edge:E,isUpdatable:k,edgeUpdaterRadius:g,onEdgeUpdate:p,onEdgeUpdateStart:m,onEdgeUpdateEnd:y,sourceX:L,sourceY:T,targetX:B,targetY:j,sourcePosition:V,targetPosition:H,setUpdateHover:I,setUpdating:D,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle})]})})}const xs=e=>({width:e.width,height:e.height,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ws({defaultMarkerColor:e,onlyRenderVisibleElements:o,rfId:r,edgeTypes:i,noPanClassName:a,onEdgeUpdate:s,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:d,onEdgeClick:h,edgeUpdaterRadius:f,onEdgeDoubleClick:g,onEdgeUpdateStart:p,onEdgeUpdateEnd:m,disableKeyboardA11y:y}){const{edgesFocusable:v,edgesUpdatable:x,elementsSelectable:w,onError:b}=gi(xs,Ni),S=(E=o,gi(n.useCallback((e=>{if(!E)return e.edges.map((e=>e.id));const t=[];if(e.width&&e.height)for(const n of e.edges){const o=e.nodeLookup.get(n.source),r=e.nodeLookup.get(n.target);o&&r&&tr({sourceNode:o,targetNode:r,width:e.width,height:e.height,transform:e.transform})&&t.push(n.id)}return t}),[E]),Ni));var E;return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(Ya,{defaultColor:e,rfId:r}),S.map((e=>t.jsx(vs,{id:e,edgesFocusable:v,edgesUpdatable:x,elementsSelectable:w,noPanClassName:a,onEdgeUpdate:s,onContextMenu:l,onMouseEnter:c,onMouseMove:u,onMouseLeave:d,onClick:h,edgeUpdaterRadius:f,onDoubleClick:g,onEdgeUpdateStart:p,onEdgeUpdateEnd:m,rfId:r,onError:b,edgeTypes:i,disableKeyboardA11y:y},e)))]})}ws.displayName="EdgeRenderer";const bs=n.memo(ws),Ss=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Es({children:e}){const n=gi(Ss);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}const Cs=e=>e.panZoom?.syncViewport;const _s={[e.Position.Left]:e.Position.Right,[e.Position.Right]:e.Position.Left,[e.Position.Top]:e.Position.Bottom,[e.Position.Bottom]:e.Position.Top},Ms=({nodeId:o,handleType:r,style:i,type:a=e.ConnectionLineType.Bezier,CustomComponent:s,connectionStatus:l})=>{const{fromNode:c,handleId:u,toX:d,toY:h,connectionMode:f}=gi(n.useCallback((e=>({fromNode:e.nodeLookup.get(o),handleId:e.connectionStartHandle?.handleId,toX:(e.connectionPosition.x-e.transform[0])/e.transform[2],toY:(e.connectionPosition.y-e.transform[1])/e.transform[2],connectionMode:e.connectionMode})),[o]),Ni),g=c?.internals.handleBounds;let p=g?.[r];if(f===e.ConnectionMode.Loose&&(p=p||g?.["source"===r?"target":"source"]),!c||!p)return null;const m=u?p.find((e=>e.id===u)):p[0],y=m?m.x+m.width/2:(c.measured.width??0)/2,v=m?m.y+m.height/2:c.measured.height??0,x=c.internals.positionAbsolute.x+y,w=c.internals.positionAbsolute.y+v,b=m?.position,S=b?_s[b]:null;if(!b||!S)return null;if(s)return t.jsx(s,{connectionLineType:a,connectionLineStyle:i,fromNode:c,fromHandle:m,fromX:x,fromY:w,toX:d,toY:h,fromPosition:b,toPosition:S,connectionStatus:l});let E="";const C={sourceX:x,sourceY:w,sourcePosition:b,targetX:d,targetY:h,targetPosition:S};return a===e.ConnectionLineType.Bezier?[E]=Jo(C):a===e.ConnectionLineType.Step?[E]=lr({...C,borderRadius:0}):a===e.ConnectionLineType.SmoothStep?[E]=lr(C):a===e.ConnectionLineType.SimpleBezier?[E]=Ka(C):E=`M${x},${w} ${d},${h}`,t.jsx("path",{d:E,fill:"none",className:"react-flow__connection-path",style:i})};Ms.displayName="ConnectionLine";const Ns=e=>({nodeId:e.connectionStartHandle?.nodeId,handleType:e.connectionStartHandle?.type,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function ks({containerStyle:e,style:n,type:o,component:i}){const{nodeId:a,handleType:s,nodesConnectable:l,width:c,height:u,connectionStatus:d}=gi(Ns,Ni);return!!(a&&s&&c&&l)?t.jsx("svg",{style:e,width:c,height:u,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:r(["react-flow__connection",d]),children:t.jsx(Ms,{nodeId:a,handleType:s,style:n,type:o,CustomComponent:i,connectionStatus:d})})}):null}const Ps={};function zs(e=Ps){n.useRef(e),pi(),n.useEffect((()=>{}),[e])}function Os({nodeTypes:e,edgeTypes:o,onInit:r,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:s,onEdgeDoubleClick:l,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:h,onSelectionContextMenu:f,onSelectionStart:g,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:y,connectionLineComponent:v,connectionLineContainerStyle:x,selectionKeyCode:w,selectionOnDrag:b,selectionMode:S,multiSelectionKeyCode:E,panActivationKeyCode:C,zoomActivationKeyCode:_,deleteKeyCode:M,onlyRenderVisibleElements:N,elementsSelectable:k,defaultViewport:P,translateExtent:z,minZoom:O,maxZoom:I,preventScrolling:A,defaultMarkerColor:D,zoomOnScroll:R,zoomOnPinch:$,panOnScroll:L,panOnScrollSpeed:T,panOnScrollMode:B,zoomOnDoubleClick:j,panOnDrag:V,onPaneClick:H,onPaneMouseEnter:X,onPaneMouseMove:Y,onPaneMouseLeave:Z,onPaneScroll:W,onPaneContextMenu:U,onEdgeUpdate:F,onEdgeContextMenu:K,onEdgeMouseEnter:G,onEdgeMouseMove:q,onEdgeMouseLeave:Q,edgeUpdaterRadius:J,onEdgeUpdateStart:ee,onEdgeUpdateEnd:te,noDragClassName:ne,noWheelClassName:oe,noPanClassName:re,disableKeyboardA11y:ie,nodeOrigin:ae,nodeExtent:se,rfId:le,viewport:ce,onViewportChange:ue}){return zs(e),zs(o),pi(),n.useRef(!1),n.useEffect((()=>{}),[]),function(e){const t=la(),o=n.useRef(!1);n.useEffect((()=>{!o.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),o.current=!0)}),[e,t.viewportInitialized])}(r),function(e){const t=gi(Cs),o=pi();n.useEffect((()=>{e&&(t?.(e),o.setState({transform:[e.x,e.y,e.zoom]}))}),[e,t])}(ce),t.jsx(Da,{onPaneClick:H,onPaneMouseEnter:X,onPaneMouseMove:Y,onPaneMouseLeave:Z,onPaneContextMenu:U,onPaneScroll:W,deleteKeyCode:M,selectionKeyCode:w,selectionOnDrag:b,selectionMode:S,onSelectionStart:g,onSelectionEnd:p,multiSelectionKeyCode:E,panActivationKeyCode:C,zoomActivationKeyCode:_,elementsSelectable:k,zoomOnScroll:R,zoomOnPinch:$,zoomOnDoubleClick:j,panOnScroll:L,panOnScrollSpeed:T,panOnScrollMode:B,panOnDrag:V,defaultViewport:P,translateExtent:z,minZoom:O,maxZoom:I,onSelectionContextMenu:f,preventScrolling:A,noDragClassName:ne,noWheelClassName:oe,noPanClassName:re,disableKeyboardA11y:ie,onViewportChange:ue,isControlledViewport:!!ce,children:t.jsxs(Es,{children:[t.jsx(bs,{edgeTypes:o,onEdgeClick:a,onEdgeDoubleClick:l,onEdgeUpdate:F,onlyRenderVisibleElements:N,onEdgeContextMenu:K,onEdgeMouseEnter:G,onEdgeMouseMove:q,onEdgeMouseLeave:Q,onEdgeUpdateStart:ee,onEdgeUpdateEnd:te,edgeUpdaterRadius:J,defaultMarkerColor:D,noPanClassName:re,disableKeyboardA11y:ie,rfId:le}),t.jsx(ks,{style:y,type:m,component:v,containerStyle:x}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(ja,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:h,onlyRenderVisibleElements:N,noPanClassName:re,noDragClassName:ne,disableKeyboardA11y:ie,nodeOrigin:ae,nodeExtent:se,rfId:le}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}Os.displayName="GraphView";const Is=n.memo(Os),As=({nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:a,fitView:s}={})=>{const l=new Map,c=new Map,u=new Map,d=new Map,h=r??n??[],f=o??t??[];xr(u,d,h),mr(f,l,c,{nodeOrigin:[0,0],elevateNodesOnSelect:!1});let g=[0,0,1];if(s&&i&&a){const e=fo(l,{nodeOrigin:[0,0],filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),{x:t,y:n,zoom:o}=$o(e,i,a,.5,2,.1);g=[t,n,o]}return{rfId:"1",width:0,height:0,transform:g,nodes:f,nodeLookup:l,parentLookup:c,edges:h,edgeLookup:d,connectionLookup:u,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==o,hasDefaultEdges:void 0!==r,panZoom:null,minZoom:.5,maxZoom:2,translateExtent:Jn,nodeExtent:Jn,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:e.ConnectionMode.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,fitViewOnInit:!1,fitViewDone:!1,fitViewOnInitOptions:void 0,selectNodesOnDrag:!0,multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:Oo,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1}},Ds=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:a})=>{return s=(s,l)=>({...As({nodes:e,edges:t,width:r,height:i,fitView:a,defaultNodes:n,defaultEdges:o}),setNodes:e=>{const{nodeLookup:t,parentLookup:n,nodeOrigin:o,elevateNodesOnSelect:r}=l();mr(e,t,n,{nodeOrigin:o,elevateNodesOnSelect:r,checkEquality:!0}),s({nodes:e})},setEdges:e=>{const{connectionLookup:t,edgeLookup:n}=l();xr(t,n,e),s({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){const{setNodes:t}=l();t(e),s({hasDefaultNodes:!0})}if(t){const{setEdges:e}=l();e(t),s({hasDefaultEdges:!0})}},updateNodeInternals:e=>{const{triggerNodeChanges:t,fitView:n,nodeLookup:o,parentLookup:r,fitViewOnInit:i,fitViewDone:a,fitViewOnInitOptions:c,domNode:u,nodeOrigin:d,debug:h}=l(),{changes:f,updatedInternals:g}=function(e,t,n,o,r){const i=o?.querySelector(".xyflow__viewport");let a=!1;if(!i)return{changes:[],updatedInternals:a};const s=[],l=window.getComputedStyle(i),{m22:c}=new window.DOMMatrixReadOnly(l.transform),u=[];if(e.forEach((e=>{const n=t.get(e.id);if(n?.hidden)n.internals={...n.internals,handleBounds:void 0},a=!0;else if(n){const t=Xo(e.nodeElement),o=n.measured.width!==t.width||n.measured.height!==t.height;if(t.width&&t.height&&(o||!n.internals.handleBounds||e.force)){const i=e.nodeElement.getBoundingClientRect();n.measured=t,n.internals={...n.internals,handleBounds:{source:Ko(".source",e.nodeElement,i,c,n.origin||r),target:Ko(".target",e.nodeElement,i,c,n.origin||r)}},a=!0,o&&(s.push({id:n.id,type:"dimensions",dimensions:t}),n.expandParent&&n.parentId&&u.push({id:n.id,parentId:n.parentId,rect:_o(n,r)}))}}})),u.length>0){const e=vr(u,t,n,r);s.push(...e)}return{changes:s,updatedInternals:a}}(e,o,r,u,d);if(!g)return;pr(o,{nodeOrigin:d});let p=a;!a&&i&&(p=n({...c,nodes:c?.nodes})),s({fitViewDone:p}),f?.length>0&&(h&&console.log("React Flow: trigger node changes",f),t?.(f))},updateNodePositions:(e,t=!1)=>{const n=[],o=[];for(const[r,i]of e){const e={id:r,type:"position",position:i.position,dragging:t};i?.expandParent&&i?.parentId&&e.position&&(n.push({id:r,parentId:i.parentId,rect:{...i.internals.positionAbsolute,width:i.measured.width,height:i.measured.height}}),e.position.x=Math.max(0,e.position.x),e.position.y=Math.max(0,e.position.y)),o.push(e)}if(n.length>0){const{nodeLookup:e,parentLookup:t}=l(),r=vr(n,e,t);o.push(...r)}l().triggerNodeChanges(o)},triggerNodeChanges:e=>{const{onNodesChange:t,setNodes:n,nodes:o,hasDefaultNodes:r,debug:i}=l();e?.length&&(r&&n(Fi(e,o)),i&&console.log("React Flow: trigger node changes",e),t?.(e))},triggerEdgeChanges:e=>{const{onEdgesChange:t,setEdges:n,edges:o,hasDefaultEdges:r,debug:i}=l();e?.length&&(r&&n(Ki(e,o)),i&&console.log("React Flow: trigger edge changes",e),t?.(e))},addSelectedNodes:e=>{const{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=l();t?r(e.map((e=>Gi(e,!0)))):(r(qi(o,new Set([...e]),!0)),i(qi(n)))},addSelectedEdges:e=>{const{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=l();t?i(e.map((e=>Gi(e,!0)))):(i(qi(n,new Set([...e]))),r(qi(o,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{const{edges:n,nodes:o,triggerNodeChanges:r,triggerEdgeChanges:i}=l(),a=t||n,s=(e||o).map((e=>(e.selected=!1,Gi(e.id,!1)))),c=a.map((e=>Gi(e.id,!1)));r(s),i(c)},setMinZoom:e=>{const{panZoom:t,maxZoom:n}=l();t?.setScaleExtent([e,n]),s({minZoom:e})},setMaxZoom:e=>{const{panZoom:t,minZoom:n}=l();t?.setScaleExtent([n,e]),s({maxZoom:e})},setTranslateExtent:e=>{l().panZoom?.setTranslateExtent(e),s({translateExtent:e})},resetSelectedElements:()=>{const{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:o}=l(),r=t.reduce(((e,t)=>t.selected?[...e,Gi(t.id,!1)]:e),[]),i=e.reduce(((e,t)=>t.selected?[...e,Gi(t.id,!1)]:e),[]);n(r),o(i)},setNodeExtent:e=>{const{nodeLookup:t}=l();for(const[,n]of t){const o=xo(n.position,e);t.set(n.id,{...n,internals:{...n.internals,positionAbsolute:o}})}s({nodeExtent:e})},panBy:e=>{const{transform:t,width:n,height:o,panZoom:r,translateExtent:i}=l();return function({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const a=t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}({delta:e,panZoom:r,transform:t,translateExtent:i,width:n,height:o})},fitView:e=>{const{panZoom:t,width:n,height:o,minZoom:r,maxZoom:i,nodeOrigin:a,nodeLookup:s}=l();return!!t&&mo({nodeLookup:s,width:n,height:o,panZoom:t,minZoom:r,maxZoom:i,nodeOrigin:a},e)},cancelConnection:()=>s({connectionStatus:null,connectionStartHandle:null,connectionEndHandle:null}),updateConnection:e=>{const{connectionPosition:t}=l(),n={...e,connectionPosition:e.connectionPosition??t};s(n)},reset:()=>s({...As()})}),l=Object.is,s?ui(s,l):ui;var s,l};function Rs({initialNodes:e,initialEdges:o,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:s,fitView:l,children:c}){const[u]=n.useState((()=>Ds({nodes:e,edges:o,defaultNodes:r,defaultEdges:i,width:a,height:s,fitView:l})));return t.jsx(hi,{value:u,children:t.jsx(aa,{children:c})})}function $s({children:e,nodes:o,edges:r,defaultNodes:i,defaultEdges:a,width:s,height:l,fitView:c}){return n.useContext(di)?t.jsx(t.Fragment,{children:e}):t.jsx(Rs,{initialNodes:o,initialEdges:r,defaultNodes:i,defaultEdges:a,initialWidth:s,initialHeight:l,fitView:c,children:e})}const Ls={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var Ts=na((function({nodes:o,edges:i,defaultNodes:a,defaultEdges:s,className:l,nodeTypes:c,edgeTypes:u,onNodeClick:d,onEdgeClick:h,onInit:f,onMove:g,onMoveStart:p,onMoveEnd:m,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:b,onNodeMouseEnter:S,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:_,onNodeDoubleClick:M,onNodeDragStart:N,onNodeDrag:k,onNodeDragStop:P,onNodesDelete:z,onEdgesDelete:O,onDelete:I,onSelectionChange:A,onSelectionDragStart:D,onSelectionDrag:R,onSelectionDragStop:$,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:B,onBeforeDelete:j,connectionMode:V,connectionLineType:H=e.ConnectionLineType.Bezier,connectionLineStyle:X,connectionLineComponent:Y,connectionLineContainerStyle:Z,deleteKeyCode:W="Backspace",selectionKeyCode:U="Shift",selectionOnDrag:F=!1,selectionMode:K=e.SelectionMode.Full,panActivationKeyCode:G="Space",multiSelectionKeyCode:q=(Lo()?"Meta":"Control"),zoomActivationKeyCode:Q=(Lo()?"Meta":"Control"),snapToGrid:J,snapGrid:ee,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:ne,nodesDraggable:oe,nodesConnectable:re,nodesFocusable:ie,nodeOrigin:ae=Di,edgesFocusable:se,edgesUpdatable:le,elementsSelectable:ce=!0,defaultViewport:ue=Ri,minZoom:de=.5,maxZoom:he=2,translateExtent:fe=Jn,preventScrolling:ge=!0,nodeExtent:pe,defaultMarkerColor:me="#b1b1b7",zoomOnScroll:ye=!0,zoomOnPinch:ve=!0,panOnScroll:xe=!1,panOnScrollSpeed:we=.5,panOnScrollMode:be=e.PanOnScrollMode.Free,zoomOnDoubleClick:Se=!0,panOnDrag:Ee=!0,onPaneClick:Ce,onPaneMouseEnter:_e,onPaneMouseMove:Me,onPaneMouseLeave:Ne,onPaneScroll:ke,onPaneContextMenu:Pe,children:ze,onEdgeUpdate:Oe,onEdgeContextMenu:Ie,onEdgeDoubleClick:Ae,onEdgeMouseEnter:De,onEdgeMouseMove:Re,onEdgeMouseLeave:$e,onEdgeUpdateStart:Le,onEdgeUpdateEnd:Te,edgeUpdaterRadius:Be=10,onNodesChange:je,onEdgesChange:Ve,noDragClassName:He="nodrag",noWheelClassName:Xe="nowheel",noPanClassName:Ye="nopan",fitView:Ze,fitViewOptions:We,connectOnClick:Ue,attributionPosition:Fe,proOptions:Ke,defaultEdgeOptions:Ge,elevateNodesOnSelect:qe,elevateEdgesOnSelect:Qe,disableKeyboardA11y:Je=!1,autoPanOnConnect:et,autoPanOnNodeDrag:tt,connectionRadius:nt,isValidConnection:ot,onError:rt,style:it,id:at,nodeDragThreshold:st,viewport:lt,onViewportChange:ct,width:ut,height:dt,colorMode:ht="light",debug:ft,...gt},pt){const mt=at||"1",yt=function(e){const[t,o]=n.useState("system"===e?null:e);return n.useEffect((()=>{if("system"!==e)return void o(e);const t=ji(),n=()=>o(t?.matches?"dark":"light");return n(),t?.addEventListener("change",n),()=>{t?.removeEventListener("change",n)}}),[e]),null!==t?t:ji()?.matches?"dark":"light"}(ht);return t.jsx("div",{...gt,style:{...it,...Ls},ref:pt,className:r(["react-flow",l,yt]),"data-testid":"rf__wrapper",id:at,children:t.jsxs($s,{nodes:o,edges:i,width:ut,height:dt,fitView:Ze,children:[t.jsx(Is,{onInit:f,onNodeClick:d,onEdgeClick:h,onNodeMouseEnter:S,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:_,onNodeDoubleClick:M,nodeTypes:c,edgeTypes:u,connectionLineType:H,connectionLineStyle:X,connectionLineComponent:Y,connectionLineContainerStyle:Z,selectionKeyCode:U,selectionOnDrag:F,selectionMode:K,deleteKeyCode:W,multiSelectionKeyCode:q,panActivationKeyCode:G,zoomActivationKeyCode:Q,onlyRenderVisibleElements:te,defaultViewport:ue,translateExtent:fe,minZoom:de,maxZoom:he,preventScrolling:ge,zoomOnScroll:ye,zoomOnPinch:ve,zoomOnDoubleClick:Se,panOnScroll:xe,panOnScrollSpeed:we,panOnScrollMode:be,panOnDrag:Ee,onPaneClick:Ce,onPaneMouseEnter:_e,onPaneMouseMove:Me,onPaneMouseLeave:Ne,onPaneScroll:ke,onPaneContextMenu:Pe,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:B,onEdgeUpdate:Oe,onEdgeContextMenu:Ie,onEdgeDoubleClick:Ae,onEdgeMouseEnter:De,onEdgeMouseMove:Re,onEdgeMouseLeave:$e,onEdgeUpdateStart:Le,onEdgeUpdateEnd:Te,edgeUpdaterRadius:Be,defaultMarkerColor:me,noDragClassName:He,noWheelClassName:Xe,noPanClassName:Ye,rfId:mt,disableKeyboardA11y:Je,nodeOrigin:ae,nodeExtent:pe,viewport:lt,onViewportChange:ct}),t.jsx(Bi,{nodes:o,edges:i,defaultNodes:a,defaultEdges:s,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:b,nodesDraggable:oe,nodesConnectable:re,nodesFocusable:ie,edgesFocusable:se,edgesUpdatable:le,elementsSelectable:ce,elevateNodesOnSelect:qe,elevateEdgesOnSelect:Qe,minZoom:de,maxZoom:he,nodeExtent:pe,onNodesChange:je,onEdgesChange:Ve,snapToGrid:J,snapGrid:ee,connectionMode:V,translateExtent:fe,connectOnClick:Ue,defaultEdgeOptions:Ge,fitView:Ze,fitViewOptions:We,onNodesDelete:z,onEdgesDelete:O,onDelete:I,onNodeDragStart:N,onNodeDrag:k,onNodeDragStop:P,onSelectionDrag:R,onSelectionDragStart:D,onSelectionDragStop:$,onMove:g,onMoveStart:p,onMoveEnd:m,noPanClassName:Ye,nodeOrigin:ae,rfId:mt,autoPanOnConnect:et,autoPanOnNodeDrag:tt,onError:rt,connectionRadius:nt,isValidConnection:ot,selectNodesOnDrag:ne,nodeDragThreshold:st,onBeforeDelete:j,debug:ft}),t.jsx(Ai,{onSelectionChange:A}),ze,t.jsx(Mi,{proOptions:Ke,position:Fe}),t.jsx(Ei,{rfId:mt,disableKeyboardA11y:Je})]})})}));const Bs=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");const js=e=>e.domNode?.querySelector(".react-flow__viewport-portal");const Vs=e=>e.nodes;const Hs=e=>e.edges;const Xs=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});const Ys={includeHiddenNodes:!1};const Zs=e=>({startHandle:e.connectionStartHandle,endHandle:e.connectionEndHandle,status:e.connectionStatus,position:e.connectionStartHandle?e.connectionPosition:null});function Ws({dimensions:e,lineWidth:n,variant:o,className:i}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:r(["react-flow__background-pattern",o,i])})}function Us({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:r(["react-flow__background-pattern","dots",n])})}var Fs;e.BackgroundVariant=void 0,(Fs=e.BackgroundVariant||(e.BackgroundVariant={})).Lines="lines",Fs.Dots="dots",Fs.Cross="cross";const Ks={[e.BackgroundVariant.Dots]:1,[e.BackgroundVariant.Lines]:1,[e.BackgroundVariant.Cross]:6},Gs=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function qs({id:o,variant:i=e.BackgroundVariant.Dots,gap:a=20,size:s,lineWidth:l=1,offset:c=2,color:u,bgColor:d,style:h,className:f,patternClassName:g}){const p=n.useRef(null),{transform:m,patternId:y}=gi(Gs,Ni),v=s||Ks[i],x=i===e.BackgroundVariant.Dots,w=i===e.BackgroundVariant.Cross,b=Array.isArray(a)?a:[a,a],S=[b[0]*m[2]||1,b[1]*m[2]||1],E=v*m[2],C=w?[E,E]:S,_=x?[E/c,E/c]:[C[0]/c,C[1]/c],M=`${y}${o||""}`;return t.jsxs("svg",{className:r(["react-flow__background",f]),style:{...h,...da,"--xy-background-color-props":d,"--xy-background-pattern-color-props":u},ref:p,"data-testid":"rf__background",children:[t.jsx("pattern",{id:M,x:m[0]%S[0],y:m[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:x?t.jsx(Us,{radius:E/c,className:g}):t.jsx(Ws,{dimensions:C,lineWidth:l,variant:i,className:g})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}qs.displayName="Background";const Qs=n.memo(qs);function Js(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:t.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function el(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:t.jsx("path",{d:"M0 0h32v4.2H0z"})})}function tl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:t.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function nl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function ol(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function rl({children:e,className:n,...o}){return t.jsx("button",{type:"button",className:r(["react-flow__controls-button",n]),...o,children:e})}const il=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom});function al({style:e,showZoom:n=!0,showFitView:o=!0,showInteractive:i=!0,fitViewOptions:a,onZoomIn:s,onZoomOut:l,onFitView:c,onInteractiveChange:u,className:d,children:h,position:f="bottom-left",orientation:g="vertical","aria-label":p="React Flow controls"}){const m=pi(),{isInteractive:y,minZoomReached:v,maxZoomReached:x}=gi(il,Ni),{zoomIn:w,zoomOut:b,fitView:S}=la(),E="horizontal"===g?"horizontal":"vertical";return t.jsxs(_i,{className:r(["react-flow__controls",E,d]),position:f,style:e,"data-testid":"rf__controls","aria-label":p,children:[n&&t.jsxs(t.Fragment,{children:[t.jsx(rl,{onClick:()=>{w(),s?.()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x,children:t.jsx(Js,{})}),t.jsx(rl,{onClick:()=>{b(),l?.()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v,children:t.jsx(el,{})})]}),o&&t.jsx(rl,{className:"react-flow__controls-fitview",onClick:()=>{S(a),c?.()},title:"fit view","aria-label":"fit view",children:t.jsx(tl,{})}),i&&t.jsx(rl,{className:"react-flow__controls-interactive",onClick:()=>{m.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),u?.(!y)},title:"toggle interactivity","aria-label":"toggle interactivity",children:y?t.jsx(ol,{}):t.jsx(nl,{})}),h]})}al.displayName="Controls";const sl=n.memo(al);const ll=n.memo((function({id:e,x:n,y:o,width:i,height:a,style:s,color:l,strokeColor:c,strokeWidth:u,className:d,borderRadius:h,shapeRendering:f,selected:g,onClick:p}){const{background:m,backgroundColor:y}=s||{},v=l||m||y;return t.jsx("rect",{className:r(["react-flow__minimap-node",{selected:g},d]),x:n,y:o,rx:h,ry:h,width:i,height:a,style:{fill:v,stroke:c,strokeWidth:u},shapeRendering:f,onClick:p?t=>p(t,e):void 0})})),cl=e=>e.nodeOrigin,ul=e=>e.nodes.map((e=>e.id)),dl=e=>e instanceof Function?e:()=>e;const hl=n.memo((function({id:e,nodeOrigin:n,nodeColorFunc:o,nodeStrokeColorFunc:r,nodeClassNameFunc:i,nodeBorderRadius:a,nodeStrokeWidth:s,shapeRendering:l,NodeComponent:c,onClick:u}){const{node:d,x:h,y:f}=gi((t=>{const o=t.nodeLookup.get(e),{x:r,y:i}=uo(o,n).positionAbsolute;return{node:o,x:r,y:i}}),Ni);if(!d||d.hidden||!jo(d))return null;const{width:g,height:p}=Bo(d);return t.jsx(c,{x:h,y:f,width:g,height:p,style:d.style,selected:!!d.selected,className:i(d),color:o(d),borderRadius:a,strokeColor:r(d),strokeWidth:s,shapeRendering:l,onClick:u,id:d.id})}));var fl=n.memo((function({nodeStrokeColor:e,nodeColor:n,nodeClassName:o="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=ll,onClick:s}){const l=gi(ul,Ni),c=gi(cl),u=dl(n),d=dl(e),h=dl(o),f="undefined"==typeof window||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:l.map((e=>t.jsx(hl,{id:e,nodeOrigin:c,nodeColorFunc:u,nodeStrokeColorFunc:d,nodeClassNameFunc:h,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:s,shapeRendering:f},e)))})}));const gl=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?No(fo(e.nodeLookup,{nodeOrigin:e.nodeOrigin}),t):t,rfId:e.rfId,nodeOrigin:e.nodeOrigin,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height}};function pl({style:e,className:o,nodeStrokeColor:i,nodeColor:a,nodeClassName:s="",nodeBorderRadius:l=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:f,maskStrokeWidth:g,position:p="bottom-right",onClick:m,onNodeClick:y,pannable:v=!1,zoomable:x=!1,ariaLabel:w="React Flow mini map",inversePan:b,zoomStep:S=10,offsetScale:E=5}){const C=pi(),_=n.useRef(null),{boundingRect:M,viewBB:N,rfId:k,panZoom:P,translateExtent:z,flowWidth:O,flowHeight:I}=gi(gl,Ni),A=e?.width??200,D=e?.height??150,R=M.width/A,$=M.height/D,L=Math.max(R,$),T=L*A,B=L*D,j=E*L,V=M.x-(T-M.width)/2-j,H=M.y-(B-M.height)/2-j,X=T+2*j,Y=B+2*j,Z=`react-flow__minimap-desc-${k}`,W=n.useRef(0),U=n.useRef();W.current=L,n.useEffect((()=>{if(_.current&&P)return U.current=function({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=Se(e);return{update:function({translateExtent:e,width:i,height:a,zoomStep:s=10,pannable:l=!0,zoomable:c=!0,inversePan:u=!1}){let d=[0,0];const h=qn().on("start",(e=>{"mousedown"!==e.sourceEvent.type&&"touchstart"!==e.sourceEvent.type||(d=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])})).on("zoom",l?r=>{const s=n();if("mousemove"!==r.sourceEvent.type&&"touchmove"!==r.sourceEvent.type||!t)return;const l=[r.sourceEvent.clientX??r.sourceEvent.touches[0].clientX,r.sourceEvent.clientY??r.sourceEvent.touches[0].clientY],c=[l[0]-d[0],l[1]-d[1]];d=l;const h=o()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),f={x:s[0]-c[0]*h,y:s[1]-c[1]*h},g=[[0,0],[i,a]];t.setViewportConstrained({x:f.x,y:f.y,zoom:s[2]},g,e)}:null).on("zoom.wheel",c?e=>{const o=n();if("wheel"!==e.sourceEvent.type||!t)return;const r=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*s,i=o[2]*Math.pow(2,r);t.scaleTo(i)}:null);r.call(h,{})},destroy:function(){r.on("zoom",null)},pointer:Ee}}({domNode:_.current,panZoom:P,getTransform:()=>C.getState().transform,getViewScale:()=>W.current}),()=>{U.current?.destroy()}}),[P]),n.useEffect((()=>{U.current?.update({translateExtent:z,width:O,height:I,inversePan:b,pannable:v,zoomStep:S,zoomable:x})}),[v,x,b,S,z,O,I]);const F=m?e=>{const[t,n]=U.current?.pointer(e)||[0,0];m(e,{x:t,y:n})}:void 0,K=y?n.useCallback(((e,t)=>{const n=C.getState().nodeLookup.get(t);y(e,n)}),[]):void 0;return t.jsx(_i,{position:p,style:{...e,"--xy-minimap-background-color-props":"string"==typeof d?d:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof h?h:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof f?f:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof g?g*L:void 0,"--xy-minimap-node-background-color-props":"string"==typeof a?a:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof i?i:void 0,"--xy-minimap-node-stroke-width-props":"string"==typeof c?c:void 0},className:r(["react-flow__minimap",o]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:A,height:D,viewBox:`${V} ${H} ${X} ${Y}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Z,ref:_,onClick:F,children:[w&&t.jsx("title",{id:Z,children:w}),t.jsx(fl,{onClick:K,nodeColor:a,nodeStrokeColor:i,nodeBorderRadius:l,nodeClassName:s,nodeStrokeWidth:c,nodeComponent:u}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-j},${H-j}h${X+2*j}v${Y+2*j}h${-X-2*j}z\n M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pl.displayName="MiniMap";const ml=n.memo(pl);const yl=n.memo((function({nodeId:e,position:o,variant:i=jr.Handle,className:a,style:s={},children:l,color:c,minWidth:u=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:g=!1,shouldResize:p,onResizeStart:m,onResize:y,onResizeEnd:v}){const x=_a(),w="string"==typeof e?e:x,b=pi(),S=n.useRef(null),E=i===jr.Line?"right":"bottom-right",C=o??E,_=n.useRef(null);n.useEffect((()=>{if(S.current&&w)return _.current||(_.current=Gr({domNode:S.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r}},onChange:(e,t)=>{const{triggerNodeChanges:n,nodeLookup:o,parentLookup:r,nodeOrigin:i}=b.getState(),a=[],s={x:e.x,y:e.y},l=o.get(w);if(l&&l.expandParent&&l.parentId){const t=vr([{id:l.id,parentId:l.parentId,rect:{width:e.width??l.measured.width,height:e.height??l.measured.height,...Vo({x:e.x??l.position.x,y:e.y??l.position.y},l.parentId,o,l.origin??i)}}],o,r,i);a.push(...t),s.x=e.x?Math.max(0,e.x):void 0,s.y=e.y?Math.max(0,e.y):void 0}if(void 0!==s.x&&void 0!==s.y){const e={id:w,type:"position",position:{...s}};a.push(e)}if(void 0!==e.width&&void 0!==e.height){const t={id:w,type:"dimensions",resizing:!0,setAttributes:!0,dimensions:{width:e.width,height:e.height}};a.push(t)}for(const e of t){const t={...e,type:"position"};a.push(t)}n(a)},onEnd:()=>{const e={id:w,type:"dimensions",resizing:!1};b.getState().triggerNodeChanges([e])}})),_.current.update({controlPosition:C,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:f},keepAspectRatio:g,onResizeStart:m,onResize:y,onResizeEnd:v,shouldResize:p}),()=>{_.current?.destroy()}}),[C,u,d,h,f,g,m,y,v,p]);const M=C.split("-"),N=i===jr.Line?"borderColor":"backgroundColor",k=c?{...s,[N]:c}:s;return t.jsx("div",{className:r(["react-flow__resize-control","nodrag",...M,i,a]),ref:S,style:k,children:l})}));const vl=e=>e.domNode?.querySelector(".react-flow__renderer");function xl({children:e}){const t=gi(vl);return t?o.createPortal(e,t):null}const wl=(e,t)=>e.length===t.length&&!e.some(((e,n)=>((e,t)=>e?.internals.positionAbsolute.x!==t?.internals.positionAbsolute.x||e?.internals.positionAbsolute.y!==t?.internals.positionAbsolute.y||e?.measured.width!==t?.measured.width||e?.measured.height!==t?.measured.height||e?.selected!==t?.selected||e?.internals.z!==t?.internals.z)(e,t[n]))),bl=e=>({viewport:{x:e.transform[0],y:e.transform[1],zoom:e.transform[2]},nodeOrigin:e.nodeOrigin,selectedNodesCount:e.nodes.filter((e=>e.selected)).length});e.Background=Qs,e.BaseEdge=Ua,e.BezierEdge=cs,e.ControlButton=rl,e.Controls=sl,e.EdgeLabelRenderer=function({children:e}){const t=gi(Bs);return t?o.createPortal(e,t):null},e.EdgeText=Wa,e.Handle=Na,e.MiniMap=ml,e.NodeResizeControl=yl,e.NodeResizer=function({nodeId:e,isVisible:n=!0,handleClassName:o,handleStyle:r,lineClassName:i,lineStyle:a,color:s,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:h=!1,shouldResize:f,onResizeStart:g,onResize:p,onResizeEnd:m}){return n?t.jsxs(t.Fragment,{children:[Hr.map((n=>t.jsx(yl,{className:i,style:a,nodeId:e,position:n,variant:jr.Line,color:s,minWidth:l,minHeight:c,maxWidth:u,maxHeight:d,onResizeStart:g,keepAspectRatio:h,shouldResize:f,onResize:p,onResizeEnd:m},n))),Vr.map((n=>t.jsx(yl,{className:o,style:r,nodeId:e,position:n,color:s,minWidth:l,minHeight:c,maxWidth:u,maxHeight:d,onResizeStart:g,keepAspectRatio:h,shouldResize:f,onResize:p,onResizeEnd:m},n)))]}):null},e.NodeToolbar=function({nodeId:o,children:i,className:a,style:s,isVisible:l,position:c=e.Position.Top,offset:u=10,align:d="center",...h}){const f=_a(),g=n.useCallback((e=>(Array.isArray(o)?o:[o||f||""]).reduce(((t,n)=>{const o=e.nodeLookup.get(n);return o&&t.push(o),t}),[])),[o,f]),p=gi(g,wl),{viewport:m,nodeOrigin:y,selectedNodesCount:v}=gi(bl,Ni);if(!("boolean"==typeof l?l:1===p.length&&p[0].selected&&1===v)||!p.length)return null;const x=ho(p,{nodeOrigin:y}),w=Math.max(...p.map((e=>e.internals.z+1))),b={position:"absolute",transform:gr(x,m,c,u,d),zIndex:w,...s};return t.jsx(xl,{children:t.jsx("div",{style:b,className:r(["react-flow__node-toolbar",a]),...h,"data-id":p.reduce(((e,t)=>`${e}${t.id} `),"").trim(),children:i})})},e.Panel=_i,e.ReactFlow=Ts,e.ReactFlowProvider=Rs,e.SimpleBezierEdge=qa,e.SmoothStepEdge=es,e.StepEdge=os,e.StraightEdge=as,e.ViewportPortal=function({children:e}){const t=gi(js);return t?o.createPortal(e,t):null},e.addEdge=or,e.applyEdgeChanges=Ki,e.applyNodeChanges=Fi,e.getBezierEdgeCenter=Go,e.getBezierPath=Jo,e.getConnectedEdges=po,e.getEdgeCenter=er,e.getIncomers=(e,t,n)=>{if(!e.id)return[];const o=new Set;return n.forEach((t=>{t.target===e.id&&o.add(t.source)})),t.filter((e=>o.has(e.id)))},e.getNodesBounds=ho,e.getOutgoers=(e,t,n)=>{if(!e.id)return[];const o=new Set;return n.forEach((t=>{t.source===e.id&&o.add(t.target)})),t.filter((e=>o.has(e.id)))},e.getSimpleBezierPath=Ka,e.getSmoothStepPath=lr,e.getStraightPath=rr,e.getViewportForBounds=$o,e.isEdge=ta,e.isNode=ea,e.updateEdge=(e,t,n,o={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return n;if(!n.find((t=>t.id===e.id)))return n;const a={...i,id:o.shouldReplaceId?nr(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter((e=>e.id!==r)).concat(a)},e.useConnection=function(){return gi(Zs,Ni)},e.useEdges=function(){return gi(Hs,Ni)},e.useEdgesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>Ki(e,t)))),[]);return[t,o,r]},e.useHandleConnections=function({type:e,id:t=null,nodeId:o,onConnect:r,onDisconnect:i}){const a=_a(),s=o??a,l=n.useRef(null),c=gi((n=>n.connectionLookup.get(`${s}-${e}-${t}`)),so);return n.useEffect((()=>{if(l.current&&l.current!==c){const e=c??new Map;lo(l.current,e,i),lo(e,l.current,r)}l.current=c??new Map}),[c,r,i]),n.useMemo((()=>Array.from(c?.values()??[])),[c])},e.useInternalNode=function(e){return gi(n.useCallback((t=>t.nodeLookup.get(e)),[e]),Ni)},e.useKeyPress=Hi,e.useNodeId=_a,e.useNodes=function(){return gi(Vs,Ni)},e.useNodesData=function(e){return gi(n.useCallback((t=>{const n=[],o=Array.isArray(e),r=o?e:[e];for(const e of r){const o=t.nodeLookup.get(e);o&&n.push({id:o.id,type:o.type,data:o.data})}return o?n:n[0]??null}),[e]),wr)},e.useNodesInitialized=function(e=Ys){return gi((e=>t=>{if(0===t.nodeLookup.size)return!1;for(const[,{hidden:n,internals:o}]of t.nodeLookup)if((e.includeHiddenNodes||!n)&&(void 0===o.handleBounds||!jo(o.userNode)))return!1;return!0})(e))},e.useNodesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>Fi(e,t)))),[]);return[t,o,r]},e.useOnSelectionChange=function({onChange:e}){const t=pi();n.useEffect((()=>{const n=[...t.getState().onSelectionChangeHandlers,e];return t.setState({onSelectionChangeHandlers:n}),()=>{const n=t.getState().onSelectionChangeHandlers.filter((t=>t!==e));t.setState({onSelectionChangeHandlers:n})}}),[e])},e.useOnViewportChange=function({onStart:e,onChange:t,onEnd:o}){const r=pi();n.useEffect((()=>{r.setState({onViewportChangeStart:e})}),[e]),n.useEffect((()=>{r.setState({onViewportChange:t})}),[t]),n.useEffect((()=>{r.setState({onViewportChangeEnd:o})}),[o])},e.useReactFlow=la,e.useStore=gi,e.useStoreApi=pi,e.useUpdateNodeInternals=function(){const e=pi();return n.useCallback((t=>{const{domNode:n,updateNodeInternals:o}=e.getState(),r=Array.isArray(t)?t:[t],i=new Map;r.forEach((e=>{const t=n?.querySelector(`.react-flow__node[data-id="${e}"]`);t&&i.set(e,{id:e,nodeElement:t,force:!0})})),requestAnimationFrame((()=>o(i)))}),[])},e.useViewport=function(){return gi(Xs,Ni)}}));
10
+ */ti.exports=function(){if(ei)return ni;ei=1;var e=n,t=ii(),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,s=e.useMemo,l=e.useDebugValue;return ni.useSyncExternalStoreWithSelector=function(e,t,n,c,u){var d=i(null);if(null===d.current){var h={hasValue:!1,value:null};d.current=h}else h=d.current;d=s((function(){function e(e){if(!a){if(a=!0,r=e,e=c(e),void 0!==u&&h.hasValue){var t=h.value;if(u(t,e))return i=t}return i=e}if(t=i,o(r,e))return t;var n=c(e);return void 0!==u&&u(t,n)?t:(r=e,i=n)}var r,i,a=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,c,u]);var f=r(e,d[0],d[1]);return a((function(){h.hasValue=!0,h.value=f}),[f]),l(f),f},ni}();var ai=Ur(ti.exports);const si=e=>{let t;const n=new Set,o=(e,o)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=o?o:"object"!=typeof r)?r:Object.assign({},t,r),n.forEach((n=>n(t,e)))}},r=()=>t,i={setState:o,getState:r,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{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()}};return t=e(o,r,i),i},{useSyncExternalStoreWithSelector:li}=ai;function ci(e,t=e.getState,o){const r=li(e.subscribe,e.getState,e.getServerState||e.getState,t,o);return n.useDebugValue(r),r}const ui=(e,t)=>{const n=(e=>e?si(e):si)(e),o=(e,o=t)=>ci(n,e,o);return Object.assign(o,n),o},di=n.createContext(null),hi=di.Provider,fi=Qn.error001();function gi(e,t){const o=n.useContext(di);if(null===o)throw new Error(fi);return ci(o,e,t)}function pi(){const e=n.useContext(di);if(null===e)throw new Error(fi);return n.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe})),[e])}const mi={display:"none"},yi={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},vi="react-flow__node-desc",xi="react-flow__edge-desc",wi="react-flow__aria-live",bi=e=>e.ariaLiveMessage;function Si({rfId:e}){const n=gi(bi);return t.jsx("div",{id:`${wi}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:yi,children:n})}function Ei({rfId:e,disableKeyboardA11y:n}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{id:`${vi}-${e}`,style:mi,children:["Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),t.jsx("div",{id:`${xi}-${e}`,style:mi,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!n&&t.jsx(Si,{rfId:e})]})}const Ci=e=>e.userSelectionActive?"none":"all";function _i({position:e="top-left",children:n,className:o,style:i,...a}){const s=gi(Ci),l=`${e}`.split("-");return t.jsx("div",{className:r(["react-flow__panel",o,...l]),style:{...i,pointerEvents:s},...a,children:n})}function Mi({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(_i,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}function Ni(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}const ki=e=>{const t=[],n=[];for(const[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(const[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Pi=e=>e.id;function zi(e,t){return Ni(e.selectedNodes.map(Pi),t.selectedNodes.map(Pi))&&Ni(e.selectedEdges.map(Pi),t.selectedEdges.map(Pi))}function Oi({onSelectionChange:e}){const t=pi(),{selectedNodes:o,selectedEdges:r}=gi(ki,zi);return n.useEffect((()=>{const n={nodes:o,edges:r};e?.(n),t.getState().onSelectionChangeHandlers.forEach((e=>e(n)))}),[o,r,e]),null}const Ii=e=>!!e.onSelectionChangeHandlers;function Ai({onSelectionChange:e}){const n=gi(Ii);return e||n?t.jsx(Oi,{onSelectionChange:e}):null}const Ri=[0,0],Di={x:0,y:0,zoom:1},$i=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","onBeforeDelete","debug","rfId"],Li=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Ti={translateExtent:Jn,nodeOrigin:Ri,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Bi(e){const{setNodes:t,setEdges:o,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:s,reset:l,setDefaultNodesAndEdges:c}=gi(Li,Ni),u=pi();n.useEffect((()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Ti,l()})),[]);const d=n.useRef(Ti);return n.useEffect((()=>{for(const n of $i){const l=e[n];l!==d.current[n]&&(void 0!==e[n]&&("nodes"===n?t(l):"edges"===n?o(l):"minZoom"===n?r(l):"maxZoom"===n?i(l):"translateExtent"===n?a(l):"nodeExtent"===n?s(l):"fitView"===n?u.setState({fitViewOnInit:l}):"fitViewOptions"===n?u.setState({fitViewOnInitOptions:l}):u.setState({[n]:l})))}d.current=e}),$i.map((t=>e[t]))),null}function ji(){return"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):null}const Vi="undefined"!=typeof document?document:null;function Hi(e=null,t={target:Vi,actInsideInputWithModifier:!0}){const[o,r]=n.useState(!1),i=n.useRef(!1),a=n.useRef(new Set([])),[s,l]=n.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return n.useEffect((()=>{const n=t?.target||Vi;if(null!==e){const e=e=>{i.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Wo(e))return!1;const n=Yi(e.code,l);a.current.add(e[n]),Xi(s,a.current,!1)&&(e.preventDefault(),r(!0))},o=e=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Wo(e))return!1;const n=Yi(e.code,l);Xi(s,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[n]),"Meta"===e.key&&a.current.clear(),i.current=!1},c=()=>{a.current.clear(),r(!1)};return n?.addEventListener("keydown",e),n?.addEventListener("keyup",o),window.addEventListener("blur",c),window.addEventListener("contextmenu",c),()=>{n?.removeEventListener("keydown",e),n?.removeEventListener("keyup",o),window.removeEventListener("blur",c),window.removeEventListener("contextmenu",c)}}}),[e,r]),o}function Xi(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function Yi(e,t){return t.includes(e)?"code":"key"}const Zi=()=>{const e=pi();return n.useMemo((()=>({zoomIn:t=>e.getState().panZoom?.scaleBy(1.2,{duration:t?.duration}),zoomOut:t=>e.getState().panZoom?.scaleBy(1/1.2,{duration:t?.duration}),zoomTo:(t,n)=>e.getState().panZoom?.scaleTo(t,{duration:n?.duration}),getZoom:()=>e.getState().transform[2],setViewport:(t,n)=>{const{transform:[o,r,i],panZoom:a}=e.getState();a?.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},{duration:n?.duration})},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>{const{nodeLookup:n,width:o,height:r,nodeOrigin:i,minZoom:a,maxZoom:s,panZoom:l}=e.getState();return!!l&&mo({nodeLookup:n,width:o,height:r,nodeOrigin:i,minZoom:a,maxZoom:s,panZoom:l},t)},setCenter:(t,n,o)=>{const{width:r,height:i,maxZoom:a,panZoom:s}=e.getState(),l=void 0!==o?.zoom?o.zoom:a,c=r/2-t*l,u=i/2-n*l;s?.setViewport({x:c,y:u,zoom:l},{duration:o?.duration})},fitBounds:(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:a,panZoom:s}=e.getState(),l=$o(t,o,r,i,a,n?.padding??.1);s?.setViewport(l,{duration:n?.duration})},screenToFlowPosition:(t,n={snapToGrid:!0})=>{const{transform:o,snapGrid:r,domNode:i}=e.getState();if(!i)return t;const{x:a,y:s}=i.getBoundingClientRect(),l={x:t.x-a,y:t.y-s};return Ro(l,o,n.snapToGrid,r)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),a=Do(t,n);return{x:a.x+r,y:a.y+i}}})),[])};function Wi(e,t){const n=[],o=new Map;for(const t of e)if("add"!==t.type)if("remove"===t.type||"replace"===t.type)o.set(t.id,[t]);else{const e=o.get(t.id);e?e.push(t):o.set(t.id,[t])}else n.push(t.item);for(const e of t){const t=o.get(e.id);if(!t){n.push(e);continue}if("remove"===t[0].type)continue;if("replace"===t[0].type){n.push({...t[0].item});continue}const r={...e};for(const e of t)Fi(e,r);n.push(r)}return n}function Fi(e,t){switch(e.type){case"select":t.selected=e.selected;break;case"position":void 0!==e.position&&(t.position=e.position),void 0!==e.dragging&&(t.dragging=e.dragging);break;case"dimensions":void 0!==e.dimensions&&(t.measured??={},t.measured.width=e.dimensions.width,t.measured.height=e.dimensions.height,e.setAttributes&&(t.width=e.dimensions.width,t.height=e.dimensions.height)),"boolean"==typeof e.resizing&&(t.resizing=e.resizing)}}function Ki(e,t){return Wi(e,t)}function Gi(e,t){return Wi(e,t)}function qi(e,t){return{id:e,type:"select",selected:t}}function Ui(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const e=t.has(r);void 0===i.selected&&!e||i.selected===e||(n&&(i.selected=e),o.push(qi(i.id,e)))}return o}function Qi({items:e=[],lookup:t}){const n=[],o=new Map(e.map((e=>[e.id,e])));for(const o of e){const e=t.get(o.id),r=e?.internals?.userNode??e;void 0!==r&&r!==o&&n.push({id:o.id,item:o,type:"replace"}),void 0===r&&n.push({item:o,type:"add"})}for(const[e]of t){void 0===o.get(e)&&n.push({id:e,type:"remove"})}return n}function Ji(e){return{id:e.id,type:"remove"}}const ea=e=>(e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e))(e),ta=e=>co(e);function na(e){return n.forwardRef(e)}const oa="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function ra(e){const[t,o]=n.useState(!1),[r]=n.useState((()=>function(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}((()=>o(!0)))));return oa((()=>{if(!t)return void r.reset();const n=r.get();n.length&&(e(n),r.reset()),o(!1)}),[t]),r}const ia=n.createContext(null);function aa({children:e}){const o=pi(),r=ra(n.useCallback((e=>{const{nodes:t=[],setNodes:n,hasDefaultNodes:r,onNodesChange:i,nodeLookup:a}=o.getState();let s=t;for(const t of e)s="function"==typeof t?t(s):t;r?n(s):i&&i(Qi({items:s,lookup:a}))}),[])),i=ra(n.useCallback((e=>{const{edges:t=[],setEdges:n,hasDefaultEdges:r,onEdgesChange:i,edgeLookup:a}=o.getState();let s=t;for(const t of e)s="function"==typeof t?t(s):t;r?n(s):i&&i(Qi({items:s,lookup:a}))}),[])),a=n.useMemo((()=>({nodeQueue:r,edgeQueue:i})),[]);return t.jsx(ia.Provider,{value:a,children:e})}const sa=e=>!!e.panZoom;function la(){const e=Zi(),t=pi(),o=function(){const e=n.useContext(ia);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}(),r=gi(sa),i=n.useMemo((()=>{const e=e=>t.getState().nodeLookup.get(e),n=e=>{o.nodeQueue.push(e)},r=e=>{o.edgeQueue.push(e)},i=e=>{const{nodeLookup:n,nodeOrigin:o}=t.getState(),r=ea(e)?e:n.get(e.id),i=r.parentId?Vo(r.position,r.parentId,n,o):r.position,a={id:r.id,position:i,width:r.measured?.width??r.width,height:r.measured?.height??r.height,data:r.data};return _o(a)},a=(e,t,o={replace:!1})=>{n((n=>n.map((n=>{if(n.id===e){const e="function"==typeof t?t(n):t;return o.replace&&ea(e)?e:{...n,...e}}return n}))))},s=(e,t,n={replace:!1})=>{r((o=>o.map((o=>{if(o.id===e){const e="function"==typeof t?t(o):t;return n.replace&&ta(e)?e:{...o,...e}}return o}))))};return{getNodes:()=>t.getState().nodes.map((e=>({...e}))),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:n,setEdges:r,addNodes:e=>{const t=Array.isArray(e)?e:[e];o.nodeQueue.push((e=>[...e,...t]))},addEdges:e=>{const t=Array.isArray(e)?e:[e];o.edgeQueue.push((e=>[...e,...t]))},toObject:()=>{const{nodes:e=[],edges:n=[],transform:o}=t.getState(),[r,i,a]=o;return{nodes:e.map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:r,y:i,zoom:a}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{const{nodes:o,edges:r,onNodesDelete:i,onEdgesDelete:a,triggerNodeChanges:s,triggerEdgeChanges:l,onDelete:c,onBeforeDelete:u}=t.getState(),{nodes:d,edges:h}=await async function({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map((e=>e.id))),a=[];for(const e of n){if(!1===e.deletable)continue;const t=i.has(e.id),n=!t&&e.parentId&&a.find((t=>t.id===e.parentId));(t||n)&&a.push(e)}const s=new Set(t.map((e=>e.id))),l=o.filter((e=>!1!==e.deletable)),c=po(a,l);for(const e of l)s.has(e.id)&&!c.find((t=>t.id===e.id))&&c.push(e);if(!r)return{edges:c,nodes:a};const u=await r({nodes:a,edges:c});return"boolean"==typeof u?u?{edges:c,nodes:a}:{edges:[],nodes:[]}:u}({nodesToRemove:e,edgesToRemove:n,nodes:o,edges:r,onBeforeDelete:u}),f=h.length>0,g=d.length>0;if(f){const e=h.map(Ji);a?.(h),l(e)}if(g){const e=d.map(Ji);i?.(d),s(e)}return(g||f)&&c?.({nodes:d,edges:h}),{deletedNodes:d,deletedEdges:h}},getIntersectingNodes:(e,n=!0,o)=>{const r=Po(e),a=r?e:i(e),s=void 0!==o;return a?(o||t.getState().nodes).filter((o=>{const i=t.getState().nodeLookup.get(o.id);if(i&&!r&&(o.id===e.id||!i.internals.positionAbsolute))return!1;const l=_o(s?o:i),c=ko(l,a);return n&&c>0||c>=a.width*a.height})):[]},isNodeIntersecting:(e,t,n=!0)=>{const o=Po(e)?e:i(e);if(!o)return!1;const r=ko(o,t);return n&&r>0||r>=o.width*o.height},updateNode:a,updateNodeData:(e,t,n={replace:!1})=>{a(e,(e=>{const o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}}),n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,(e=>{const o="function"==typeof t?t(e):t;return n.replace?{...e,data:o}:{...e,data:{...e.data,...o}}}),n)}}}),[]);return n.useMemo((()=>({...i,...e,viewportInitialized:r})),[r])}const ca=e=>e.selected,ua={actInsideInputWithModifier:!1},da="undefined"==typeof window?window:void 0;const ha={position:"absolute",width:"100%",height:"100%",top:0,left:0},fa=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib});function ga({onPaneContextMenu:o,zoomOnScroll:r=!0,zoomOnPinch:i=!0,panOnScroll:a=!1,panOnScrollSpeed:s=.5,panOnScrollMode:l=e.PanOnScrollMode.Free,zoomOnDoubleClick:c=!0,panOnDrag:u=!0,defaultViewport:d,translateExtent:h,minZoom:f,maxZoom:g,zoomActivationKeyCode:p,preventScrolling:m=!0,children:y,noWheelClassName:v,noPanClassName:x,onViewportChange:w,isControlledViewport:b}){const S=pi(),E=n.useRef(null),{userSelectionActive:C,lib:_}=gi(fa,Ni),M=Hi(p),N=n.useRef();return function(e){const t=pi();n.useEffect((()=>{const n=()=>{if(!e.current)return!1;const n=Xo(e.current);0!==n.height&&0!==n.width||t.getState().onError?.("004",Qn.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener("resize",n);const t=new ResizeObserver((()=>n()));return t.observe(e.current),()=>{window.removeEventListener("resize",n),t&&e.current&&t.unobserve(e.current)}}}),[])}(E),n.useEffect((()=>{if(E.current){N.current=Br({domNode:E.current,minZoom:f,maxZoom:g,translateExtent:h,viewport:d,onTransformChange:e=>{w?.({x:e[0],y:e[1],zoom:e[2]}),b||S.setState({transform:e})},onDraggingChange:e=>S.setState({paneDragging:e}),onPanZoomStart:(e,t)=>{const{onViewportChangeStart:n,onMoveStart:o}=S.getState();o?.(e,t),n?.(t)},onPanZoom:(e,t)=>{const{onViewportChange:n,onMove:o}=S.getState();o?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{const{onViewportChangeEnd:n,onMoveEnd:o}=S.getState();o?.(e,t),n?.(t)}});const{x:e,y:t,zoom:n}=N.current.getViewport();return S.setState({panZoom:N.current,transform:[e,t,n],domNode:E.current.closest(".react-flow")}),()=>{N.current?.destroy()}}}),[]),n.useEffect((()=>{N.current?.update({onPaneContextMenu:o,zoomOnScroll:r,zoomOnPinch:i,panOnScroll:a,panOnScrollSpeed:s,panOnScrollMode:l,zoomOnDoubleClick:c,panOnDrag:u,zoomActivationKeyPressed:M,preventScrolling:m,noPanClassName:x,userSelectionActive:C,noWheelClassName:v,lib:_})}),[o,r,i,a,s,l,c,u,M,m,x,C,v,_]),t.jsx("div",{className:"react-flow__renderer",ref:E,style:ha,children:y})}const pa=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ma(){const{userSelectionActive:e,userSelectionRect:n}=gi(pa,Ni);return e&&n?t.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const ya=(e,t)=>n=>{n.target===t.current&&e?.(n)},va=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging});function xa({isSelecting:o,selectionKeyPressed:i,selectionMode:a=e.SelectionMode.Full,panOnDrag:s,onSelectionStart:l,onSelectionEnd:c,onPaneClick:u,onPaneContextMenu:d,onPaneScroll:h,onPaneMouseEnter:f,onPaneMouseMove:g,onPaneMouseLeave:p,children:m}){const y=n.useRef(null),v=pi(),x=n.useRef(0),w=n.useRef(0),b=n.useRef(),S=n.useRef(new Map),{userSelectionActive:E,elementsSelectable:C,dragging:_}=gi(va,Ni),M=C&&(o||E),N=n.useRef(!1),k=e=>{N.current?N.current=!1:(u?.(e),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1}))},P=h?e=>h(e):void 0;return t.jsxs("div",{className:r(["react-flow__pane",{draggable:s,dragging:_,selection:o}]),onClick:M?void 0:ya(k,y),onContextMenu:ya((e=>{Array.isArray(s)&&s?.includes(2)?e.preventDefault():d?.(e)}),y),onWheel:ya(P,y),onPointerEnter:M?void 0:f,onPointerDown:M?e=>{const{resetSelectedElements:t,domNode:n,edgeLookup:r}=v.getState();if(b.current=n?.getBoundingClientRect(),y.current?.setPointerCapture(e.pointerId),!C||!o||0!==e.button||e.target!==y.current||!b.current)return;S.current=new Map;for(const[e,t]of r)S.current.set(t.source,S.current.get(t.source)?.add(e)||new Set([e])),S.current.set(t.target,S.current.get(t.target)?.add(e)||new Set([e]));const{x:i,y:a}=Ko(e.nativeEvent,b.current);t(),v.setState({userSelectionRect:{width:0,height:0,startX:i,startY:a,x:i,y:a}}),l?.(e)}:g,onPointerMove:M?t=>{const{userSelectionRect:n,edgeLookup:o,transform:r,nodeOrigin:i,nodeLookup:s,triggerNodeChanges:l,triggerEdgeChanges:c}=v.getState();if(!b.current||!n)return;N.current=!0;const{x:u,y:d}=Ko(t.nativeEvent,b.current),{startX:h,startY:f}=n,g={startX:h,startY:f,x:u<h?u:h,y:d<f?d:f,width:Math.abs(u-h),height:Math.abs(d-f)},p=go(s,g,r,a===e.SelectionMode.Partial,!0,i),m=new Set,y=new Set;for(const e of p){y.add(e.id);const t=S.current.get(e.id);if(t)for(const e of t)m.add(e)}if(x.current!==y.size){x.current=y.size;l(Ui(s,y,!0))}if(w.current!==m.size){w.current=m.size;c(Ui(o,m))}v.setState({userSelectionRect:g,userSelectionActive:!0,nodesSelectionActive:!1})}:g,onPointerUp:M?e=>{if(0!==e.button)return;y.current?.releasePointerCapture(e.pointerId);const{userSelectionRect:t}=v.getState();!E&&t&&e.target===y.current&&k?.(e),v.setState({nodesSelectionActive:x.current>0}),v.setState({userSelectionActive:!1,userSelectionRect:null}),x.current=0,w.current=0,c?.(e),i&&(N.current=!1)}:void 0,onPointerLeave:p,ref:y,style:ha,children:[m,t.jsx(ma,{})]})}function wa({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:s,onError:l}=t.getState(),c=s.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&a)&&(i({nodes:[c],edges:[]}),requestAnimationFrame((()=>o?.current?.blur()))):r([e])):l?.("012",Qn.error012(e))}function ba({nodeRef:e,disabled:t=!1,noDragClassName:o,handleSelector:r,nodeId:i,isSelectable:a}){const s=pi(),[l,c]=n.useState(!1),u=n.useRef();return n.useEffect((()=>{u.current=Cr({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{wa({id:t,store:s,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})}),[]),n.useEffect((()=>{if(t)u.current?.destroy();else if(e.current)return u.current?.update({noDragClassName:o,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i}),()=>{u.current?.destroy()}}),[o,r,t,a,e,i]),l}const Sa=e=>t=>t.selected&&(t.draggable||e&&void 0===t.draggable);function Ea(){const e=pi();return n.useCallback((t=>{const{nodeExtent:n,snapToGrid:o,snapGrid:r,nodesDraggable:i,onError:a,updateNodePositions:s,nodeLookup:l,nodeOrigin:c}=e.getState(),u=new Map,d=Sa(i),h=o?r[0]:5,f=o?r[1]:5,g=t.direction.x*h*t.factor,p=t.direction.y*f*t.factor;for(const[,e]of l){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+g,y:e.internals.positionAbsolute.y+p};o&&(t=Ao(t,r));const{position:i,positionAbsolute:s}=yo({nodeId:e.id,nextPosition:t,nodeLookup:l,nodeExtent:n,nodeOrigin:c,onError:a});e.position=i,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)}),[])}const Ca=n.createContext(null),_a=Ca.Provider;Ca.Consumer;const Ma=()=>n.useContext(Ca),Na=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId});const ka=n.memo(na((function({type:n="source",position:o=e.Position.Top,isValidConnection:i,isConnectable:a=!0,isConnectableStart:s=!0,isConnectableEnd:l=!0,id:c,onConnect:u,children:d,className:h,onMouseDown:f,onTouchStart:g,...p},m){const y=c||null,v="target"===n,x=pi(),w=Ma(),{connectOnClick:b,noPanClassName:S,rfId:E}=gi(Na,Ni),{connectingFrom:C,connectingTo:_,clickConnecting:M,isPossibleEndHandle:N,connectionInProcess:k,valid:P}=gi(((t,n,o)=>r=>{const{connectionStartHandle:i,connectionEndHandle:a,connectionClickStartHandle:s,connectionMode:l,connectionStatus:c}=r,u=a?.nodeId===t&&a?.handleId===n&&a?.type===o;return{connectingFrom:i?.nodeId===t&&i?.handleId===n&&i?.type===o,connectingTo:u,clickConnecting:s?.nodeId===t&&s?.handleId===n&&s?.type===o,isPossibleEndHandle:l===e.ConnectionMode.Strict?i?.type!==o:t!==i?.nodeId||n!==i?.handleId,connectionInProcess:!!i,valid:u&&"valid"===c}})(w,y,n),Ni);w||x.getState().onError?.("010",Qn.error010());const z=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=x.getState(),r={...t,...e};if(o){const{edges:e,setEdges:t}=x.getState();t(or(r,e))}n?.(r),u?.(r)},O=e=>{if(!w)return;const t=Fo(e.nativeEvent);if(s&&(t&&0===e.button||!t)){const t=x.getState();Or.onPointerDown(e.nativeEvent,{autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:v,handleId:y,nodeId:w,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:t.onConnectEnd,updateConnection:t.updateConnection,onConnect:z,isValidConnection:i||t.isValidConnection,getTransform:()=>x.getState().transform,getConnectionStartHandle:()=>x.getState().connectionStartHandle})}t?f?.(e):g?.(e)};return t.jsx("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":o,"data-id":`${E}-${w}-${y}-${n}`,className:r(["react-flow__handle",`react-flow__handle-${o}`,"nodrag",S,h,{source:!v,target:v,connectable:a,connectablestart:s,connectableend:l,clickconnecting:M,connectingfrom:C,connectingto:_,valid:P,connectionindicator:a&&(!k||N)&&(k?l:s)}]),onMouseDown:O,onTouchStart:O,onClick:b?e=>{const{onClickConnectStart:t,onClickConnectEnd:o,connectionClickStartHandle:r,connectionMode:a,isValidConnection:l,lib:c,rfId:u}=x.getState();if(!w||!r&&!s)return;if(!r)return t?.(e.nativeEvent,{nodeId:w,handleId:y,handleType:n}),void x.setState({connectionClickStartHandle:{nodeId:w,type:n,handleId:y}});const d=Yo(e.target),h=i||l,{connection:f,isValid:g}=Or.isValid(e.nativeEvent,{handle:{nodeId:w,id:y,type:n},connectionMode:a,fromNodeId:r.nodeId,fromHandleId:r.handleId||null,fromType:r.type,isValidConnection:h,flowId:u,doc:d,lib:c});g&&f&&z(f),o?.(e),x.setState({connectionClickStartHandle:null})}:void 0,ref:m,...p,children:d})})));const Pa={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},za={input:function({data:n,isConnectable:o,sourcePosition:r=e.Position.Bottom}){return t.jsxs(t.Fragment,{children:[n?.label,t.jsx(ka,{type:"source",position:r,isConnectable:o})]})},default:function({data:n,isConnectable:o,targetPosition:r=e.Position.Top,sourcePosition:i=e.Position.Bottom}){return t.jsxs(t.Fragment,{children:[t.jsx(ka,{type:"target",position:r,isConnectable:o}),n?.label,t.jsx(ka,{type:"source",position:i,isConnectable:o})]})},output:function({data:n,isConnectable:o,targetPosition:r=e.Position.Top}){return t.jsxs(t.Fragment,{children:[t.jsx(ka,{type:"target",position:r,isConnectable:o}),n?.label]})},group:function(){return null}};const Oa=e=>{const{width:t,height:n,x:o,y:r}=fo(e.nodeLookup,{nodeOrigin:e.nodeOrigin,filter:e=>!!e.selected});return{width:zo(t)?t:null,height:zo(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function Ia({onSelectionContextMenu:e,noPanClassName:o,disableKeyboardA11y:i}){const a=pi(),{width:s,height:l,transformString:c,userSelectionActive:u}=gi(Oa,Ni),d=Ea(),h=n.useRef(null);if(n.useEffect((()=>{i||h.current?.focus({preventScroll:!0})}),[i]),ba({nodeRef:h}),u||!s||!l)return null;const f=e?t=>{const n=a.getState().nodes.filter((e=>e.selected));e(t,n)}:void 0;return t.jsx("div",{className:r(["react-flow__nodesselection","react-flow__container",o]),style:{transform:c},children:t.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:i?void 0:-1,onKeyDown:i?void 0:e=>{Object.prototype.hasOwnProperty.call(Pa,e.key)&&d({direction:Pa[e.key],factor:e.shiftKey?4:1})},style:{width:s,height:l}})})}const Aa="undefined"==typeof window?window:void 0,Ra=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Da({children:e,onPaneClick:o,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:s,onPaneScroll:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:h,onSelectionStart:f,onSelectionEnd:g,multiSelectionKeyCode:p,panActivationKeyCode:m,zoomActivationKeyCode:y,elementsSelectable:v,zoomOnScroll:x,zoomOnPinch:w,panOnScroll:b,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:C,panOnDrag:_,defaultViewport:M,translateExtent:N,minZoom:k,maxZoom:P,preventScrolling:z,onSelectionContextMenu:O,noWheelClassName:I,noPanClassName:A,disableKeyboardA11y:R,onViewportChange:D,isControlledViewport:$}){const{nodesSelectionActive:L,userSelectionActive:T}=gi(Ra),B=Hi(u,{target:Aa}),j=Hi(m,{target:Aa}),V=j||_,H=j||b,X=B||T||d&&!0!==V;return function({deleteKeyCode:e,multiSelectionKeyCode:t}){const o=pi(),{deleteElements:r}=la(),i=Hi(e,ua),a=Hi(t,{target:da});n.useEffect((()=>{if(i){const{edges:e,nodes:t}=o.getState();r({nodes:t.filter(ca),edges:e.filter(ca)}),o.setState({nodesSelectionActive:!1})}}),[i]),n.useEffect((()=>{o.setState({multiSelectionActive:a})}),[a])}({deleteKeyCode:c,multiSelectionKeyCode:p}),t.jsx(ga,{onPaneContextMenu:s,elementsSelectable:v,zoomOnScroll:x,zoomOnPinch:w,panOnScroll:H,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:C,panOnDrag:!B&&V,defaultViewport:M,translateExtent:N,minZoom:k,maxZoom:P,zoomActivationKeyCode:y,preventScrolling:z,noWheelClassName:I,noPanClassName:A,onViewportChange:D,isControlledViewport:$,children:t.jsxs(xa,{onSelectionStart:f,onSelectionEnd:g,onPaneClick:o,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:s,onPaneScroll:l,panOnDrag:V,isSelecting:!!X,selectionMode:h,selectionKeyPressed:B,children:[e,L&&t.jsx(Ia,{onSelectionContextMenu:O,noPanClassName:A,disableKeyboardA11y:R})]})})}Da.displayName="FlowRenderer";const $a=n.memo(Da),La=e=>t=>e?go(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map((e=>e.id)):Array.from(t.nodeLookup.keys());const Ta=e=>e.updateNodeInternals;function Ba({id:e,onClick:o,onMouseEnter:i,onMouseMove:a,onMouseLeave:s,onContextMenu:l,onDoubleClick:c,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:f,resizeObserver:g,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:y,rfId:v,nodeTypes:x,nodeExtent:w,nodeOrigin:b,onError:S}){const{node:E,internals:C,isParent:_}=gi((t=>{const n=t.nodeLookup.get(e),o=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:o}}),Ni);let M=E.type||"default",N=x?.[M]||za[M];void 0===N&&(S?.("003",Qn.error003(M)),M="default",N=za.default);const k=!!(E.draggable||u&&void 0===E.draggable),P=!!(E.selectable||d&&void 0===E.selectable),z=!!(E.connectable||h&&void 0===E.connectable),O=!!(E.focusable||f&&void 0===E.focusable),I=pi(),A=jo(E),R=function({node:e,nodeType:t,hasDimensions:o,resizeObserver:r}){const i=pi(),a=n.useRef(null),s=n.useRef(null),l=n.useRef(e.sourcePosition),c=n.useRef(e.targetPosition),u=n.useRef(t),d=o&&!!e.internals.handleBounds;return n.useEffect((()=>{!a.current||e.hidden||d&&s.current===a.current||(s.current&&r?.unobserve(s.current),r?.observe(a.current),s.current=a.current)}),[d,e.hidden]),n.useEffect((()=>()=>{s.current&&(r?.unobserve(s.current),s.current=null)}),[]),n.useEffect((()=>{if(a.current){const n=u.current!==t,o=l.current!==e.sourcePosition,r=c.current!==e.targetPosition;(n||o||r)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}}),[e.id,t,e.sourcePosition,e.targetPosition]),a}({node:E,nodeType:M,hasDimensions:A,resizeObserver:g}),D=ba({nodeRef:R,disabled:E.hidden||!k,noDragClassName:p,handleSelector:E.dragHandle,nodeId:e,isSelectable:P}),$=Ea();if(E.hidden)return null;const L=Bo(E),T=function(e){return void 0===e.internals.handleBounds?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}(E),B=w?xo(C.positionAbsolute,w):C.positionAbsolute,j=Io({...B,...L,origin:E.origin||b}),V=P||k||o||i||a||s,H=i?e=>i(e,{...C.userNode}):void 0,X=a?e=>a(e,{...C.userNode}):void 0,Y=s?e=>s(e,{...C.userNode}):void 0,Z=l?e=>l(e,{...C.userNode}):void 0,W=c?e=>c(e,{...C.userNode}):void 0;return t.jsx("div",{className:r(["react-flow__node",`react-flow__node-${M}`,{[m]:k},E.className,{selected:E.selected,selectable:P,parent:_,draggable:k,dragging:D}]),ref:R,style:{zIndex:C.z,transform:`translate(${j.x}px,${j.y}px)`,pointerEvents:V?"all":"none",visibility:A?"visible":"hidden",...E.style,...T},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:X,onMouseLeave:Y,onContextMenu:Z,onClick:t=>{const{selectNodesOnDrag:n,nodeDragThreshold:r}=I.getState();P&&(!n||!k||r>0)&&wa({id:e,store:I,nodeRef:R}),o&&o(t,{...C.userNode})},onDoubleClick:W,onKeyDown:O?t=>{if(!Wo(t.nativeEvent)&&!y)if(eo.includes(t.key)&&P){const n="Escape"===t.key;wa({id:e,store:I,unselect:n,nodeRef:R})}else k&&E.selected&&Object.prototype.hasOwnProperty.call(Pa,t.key)&&(I.setState({ariaLiveMessage:`Moved selected node ${t.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~B.x}, y: ${~~B.y}`}),$({direction:Pa[t.key],factor:t.shiftKey?4:1}))}:void 0,tabIndex:O?0:void 0,role:O?"button":void 0,"aria-describedby":y?void 0:`${vi}-${v}`,"aria-label":E.ariaLabel,children:t.jsx(_a,{value:e,children:t.jsx(N,{id:e,data:E.data,type:M,positionAbsoluteX:B.x,positionAbsoluteY:B.y,selected:E.selected,selectable:P,draggable:k,deletable:E.deletable??!0,isConnectable:z,sourcePosition:E.sourcePosition,targetPosition:E.targetPosition,dragging:D,dragHandle:E.dragHandle,zIndex:C.z,parentId:E.parentId,...L})})})}const ja=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Va(e){const{nodesDraggable:o,nodesConnectable:r,nodesFocusable:i,elementsSelectable:a,onError:s}=gi(ja,Ni),l=(c=e.onlyRenderVisibleElements,gi(n.useCallback(La(c),[c]),Ni));var c;const u=function(){const e=gi(Ta),[t]=n.useState((()=>"undefined"==typeof ResizeObserver?null:new ResizeObserver((t=>{const n=new Map;t.forEach((e=>{const t=e.target.getAttribute("data-id");n.set(t,{id:t,nodeElement:e.target,force:!0})})),e(n)}))));return n.useEffect((()=>()=>{t?.disconnect()}),[t]),t}();return t.jsx("div",{className:"react-flow__nodes",style:ha,children:l.map((n=>t.jsx(Ba,{id:n,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,nodeOrigin:e.nodeOrigin,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:u,nodesDraggable:o,nodesConnectable:r,nodesFocusable:i,elementsSelectable:a,onError:s},n)))})}Va.displayName="NodeRenderer";const Ha=n.memo(Va);const Xa={[e.MarkerType.Arrow]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[e.MarkerType.ArrowClosed]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Ya=({id:e,type:o,color:r,width:i=12.5,height:a=12.5,markerUnits:s="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const u=function(e){const t=pi();return n.useMemo((()=>Object.prototype.hasOwnProperty.call(Xa,e)?Xa[e]:(t.getState().onError?.("009",Qn.error009(e)),null)),[e])}(o);return u?t.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:c,refX:"0",refY:"0",children:t.jsx(u,{color:r,strokeWidth:l})}):null},Za=({defaultColor:e,rfId:o})=>{const r=gi((e=>e.edges)),i=gi((e=>e.defaultEdgeOptions)),a=n.useMemo((()=>{const t=function(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce(((e,a)=>([a.markerStart||o,a.markerEnd||r].forEach((o=>{if(o&&"object"==typeof o){const r=fr(o,t);i.has(r)||(e.push({id:r,color:o.color||n,...o}),i.add(r))}})),e)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))}(r,{id:o,defaultColor:e,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd});return t}),[r,i,o,e]);return a.length?t.jsx("svg",{className:"react-flow__marker",children:t.jsx("defs",{children:a.map((e=>t.jsx(Ya,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id)))})}):null};Za.displayName="MarkerDefinitions";var Wa=n.memo(Za);function Fa({x:e,y:o,label:i,labelStyle:a={},labelShowBg:s=!0,labelBgStyle:l={},labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...f}){const[g,p]=n.useState({x:1,y:0,width:0,height:0}),m=r(["react-flow__edge-textwrapper",h]),y=n.useRef(null);return n.useEffect((()=>{if(y.current){const e=y.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[i]),void 0!==i&&i?t.jsxs("g",{transform:`translate(${e-g.width/2} ${o-g.height/2})`,className:m,visibility:g.width?"visible":"hidden",...f,children:[s&&t.jsx("rect",{width:g.width+2*c[0],x:-c[0],y:-c[1],height:g.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:u,ry:u}),t.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:y,style:a,children:i}),d]}):null}Fa.displayName="EdgeText";const Ka=n.memo(Fa);function Ga({id:e,path:n,labelX:o,labelY:i,label:a,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:g,className:p,interactionWidth:m=20}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{id:e,style:h,d:n,fill:"none",className:r(["react-flow__edge-path",p]),markerEnd:f,markerStart:g}),m&&t.jsx("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),a&&zo(o)&&zo(i)?t.jsx(Ka,{x:o,y:i,label:a,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function qa({pos:t,x1:n,y1:o,x2:r,y2:i}){return t===e.Position.Left||t===e.Position.Right?[.5*(n+r),o]:[n,.5*(o+i)]}function Ua({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top}){const[s,l]=qa({pos:o,x1:t,y1:n,x2:r,y2:i}),[c,u]=qa({pos:a,x1:r,y1:i,x2:t,y2:n}),[d,h,f,g]=qo({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${t},${n} C${s},${l} ${c},${u} ${r},${i}`,d,h,f,g]}function Qa(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:a,targetY:s,sourcePosition:l=e.Position.Bottom,targetPosition:c=e.Position.Top,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:x})=>{const[w,b,S]=Ua({sourceX:r,sourceY:i,sourcePosition:l,targetX:a,targetY:s,targetPosition:c}),E=o.isInternal?void 0:n;return t.jsx(Ga,{id:E,path:w,labelX:b,labelY:S,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:x})}))}const Ja=Qa({isInternal:!1}),es=Qa({isInternal:!0});function ts(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:a,targetY:s,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,sourcePosition:p=e.Position.Bottom,targetPosition:m=e.Position.Top,markerEnd:y,markerStart:v,pathOptions:x,interactionWidth:w})=>{const[b,S,E]=lr({sourceX:r,sourceY:i,sourcePosition:p,targetX:a,targetY:s,targetPosition:m,borderRadius:x?.borderRadius,offset:x?.offset}),C=o.isInternal?void 0:n;return t.jsx(Ga,{id:C,path:b,labelX:S,labelY:E,label:l,labelStyle:c,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:v,interactionWidth:w})}))}Ja.displayName="SimpleBezierEdge",es.displayName="SimpleBezierEdgeInternal";const ns=ts({isInternal:!1}),os=ts({isInternal:!0});function rs(e){return n.memo((({id:o,...r})=>{const i=e.isInternal?void 0:o;return t.jsx(ns,{...r,id:i,pathOptions:n.useMemo((()=>({borderRadius:0,offset:r.pathOptions?.offset})),[r.pathOptions?.offset])})}))}ns.displayName="SmoothStepEdge",os.displayName="SmoothStepEdgeInternal";const is=rs({isInternal:!1}),as=rs({isInternal:!0});function ss(e){return n.memo((({id:n,sourceX:o,sourceY:r,targetX:i,targetY:a,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:p,interactionWidth:m})=>{const[y,v,x]=rr({sourceX:o,sourceY:r,targetX:i,targetY:a}),w=e.isInternal?void 0:n;return t.jsx(Ga,{id:w,path:y,labelX:v,labelY:x,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:p,interactionWidth:m})}))}is.displayName="StepEdge",as.displayName="StepEdgeInternal";const ls=ss({isInternal:!1}),cs=ss({isInternal:!0});function us(o){return n.memo((({id:n,sourceX:r,sourceY:i,targetX:a,targetY:s,sourcePosition:l=e.Position.Bottom,targetPosition:c=e.Position.Top,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,pathOptions:x,interactionWidth:w})=>{const[b,S,E]=Jo({sourceX:r,sourceY:i,sourcePosition:l,targetX:a,targetY:s,targetPosition:c,curvature:x?.curvature}),C=o.isInternal?void 0:n;return t.jsx(Ga,{id:C,path:b,labelX:S,labelY:E,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:g,labelBgBorderRadius:p,style:m,markerEnd:y,markerStart:v,interactionWidth:w})}))}ls.displayName="StraightEdge",cs.displayName="StraightEdgeInternal";const ds=us({isInternal:!1}),hs=us({isInternal:!0});ds.displayName="BezierEdge",hs.displayName="BezierEdgeInternal";const fs={default:hs,straight:cs,step:as,smoothstep:os,simplebezier:es},gs={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},ps=(t,n,o)=>o===e.Position.Left?t-n:o===e.Position.Right?t+n:t,ms=(t,n,o)=>o===e.Position.Top?t-n:o===e.Position.Bottom?t+n:t,ys="react-flow__edgeupdater";function vs({position:e,centerX:n,centerY:o,radius:i=10,onMouseDown:a,onMouseEnter:s,onMouseOut:l,type:c}){return t.jsx("circle",{onMouseDown:a,onMouseEnter:s,onMouseOut:l,className:r([ys,`${ys}-${c}`]),cx:ps(n,i,e),cy:ms(o,i,e),r:i,stroke:"transparent",fill:"transparent"})}function xs({isReconnectable:e,reconnectRadius:n,edge:o,targetHandleId:r,sourceHandleId:i,sourceX:a,sourceY:s,targetX:l,targetY:c,sourcePosition:u,targetPosition:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:g,setReconnecting:p,setUpdateHover:m}){const y=pi(),v=(e,t)=>{if(0!==e.button)return;const{autoPanOnConnect:n,domNode:a,isValidConnection:s,connectionMode:l,connectionRadius:c,lib:u,onConnectStart:d,onConnectEnd:m,cancelConnection:v,nodeLookup:x,rfId:w,panBy:b,updateConnection:S}=y.getState(),E=t?o.target:o.source,C=(t?r:i)||null,_=t?"target":"source",M=t;p(!0),f?.(e,o,_);Or.onPointerDown(e.nativeEvent,{autoPanOnConnect:n,connectionMode:l,connectionRadius:c,domNode:a,handleId:C,nodeId:E,nodeLookup:x,isTarget:M,edgeUpdaterType:_,lib:u,flowId:w,cancelConnection:v,panBy:b,isValidConnection:s,onConnect:e=>h?.(o,e),onConnectStart:d,onConnectEnd:m,onReconnectEnd:e=>{p(!1),g?.(e,o,_)},updateConnection:S,getTransform:()=>y.getState().transform,getConnectionStartHandle:()=>y.getState().connectionStartHandle})},x=()=>m(!0),w=()=>m(!1);return t.jsxs(t.Fragment,{children:[("source"===e||!0===e)&&t.jsx(vs,{position:u,centerX:a,centerY:s,radius:n,onMouseDown:e=>v(e,!0),onMouseEnter:x,onMouseOut:w,type:"source"}),("target"===e||!0===e)&&t.jsx(vs,{position:d,centerX:l,centerY:c,radius:n,onMouseDown:e=>v(e,!1),onMouseEnter:x,onMouseOut:w,type:"target"})]})}function ws({id:o,edgesFocusable:i,edgesReconnectable:a,elementsSelectable:s,onClick:l,onDoubleClick:c,onContextMenu:u,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,reconnectRadius:g,onReconnect:p,onReconnectStart:m,onReconnectEnd:y,rfId:v,edgeTypes:x,noPanClassName:w,onError:b,disableKeyboardA11y:S}){let E=gi((e=>e.edgeLookup.get(o)));const C=gi((e=>e.defaultEdgeOptions));E=C?{...C,...E}:E;let _=E.type||"default",M=x?.[_]||fs[_];void 0===M&&(b?.("011",Qn.error011(_)),_="default",M=fs.default);const N=!!(E.focusable||i&&void 0===E.focusable),k=void 0!==p&&(E.reconnectable||a&&void 0===E.reconnectable),P=!!(E.selectable||s&&void 0===E.selectable),z=n.useRef(null),[O,I]=n.useState(!1),[A,R]=n.useState(!1),D=pi(),{zIndex:$,sourceX:L,sourceY:T,targetX:B,targetY:j,sourcePosition:V,targetPosition:H}=gi(n.useCallback((t=>{const n=t.nodeLookup.get(E.source),r=t.nodeLookup.get(E.target);if(!n||!r)return{zIndex:E.zIndex,...gs};const i=function(t){const{sourceNode:n,targetNode:o}=t;if(!cr(n)||!cr(o))return null;const r=n.internals.handleBounds||ur(n.handles),i=o.internals.handleBounds||ur(o.handles),a=hr(r?.source??[],t.sourceHandle),s=hr(t.connectionMode===e.ConnectionMode.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),t.targetHandle);if(!a||!s)return t.onError?.("008",Qn.error008(a?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const l=a?.position||e.Position.Bottom,c=s?.position||e.Position.Top,[u,d]=dr(n,a,l),[h,f]=dr(o,s,c);return{sourceX:u,sourceY:d,targetX:h,targetY:f,sourcePosition:l,targetPosition:c}}({id:o,sourceNode:n,targetNode:r,sourceHandle:E.sourceHandle||null,targetHandle:E.targetHandle||null,connectionMode:t.connectionMode,onError:b}),a=function({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1}){if(!r)return o;const i=n||t.selected||e.selected,a=Math.max(e.internals.z||0,t.internals.z||0,1e3);return o+(i?a:0)}({selected:E.selected,zIndex:E.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect});return{zIndex:a,...i||gs}}),[E.source,E.target,E.sourceHandle,E.targetHandle,E.selected,E.zIndex]),Ni),X=n.useMemo((()=>E.markerStart?`url('#${fr(E.markerStart,v)}')`:void 0),[E.markerStart,v]),Y=n.useMemo((()=>E.markerEnd?`url('#${fr(E.markerEnd,v)}')`:void 0),[E.markerEnd,v]);if(E.hidden||null===L||null===T||null===B||null===j)return null;const Z=c?e=>{c(e,{...E})}:void 0,W=u?e=>{u(e,{...E})}:void 0,F=d?e=>{d(e,{...E})}:void 0,K=h?e=>{h(e,{...E})}:void 0,G=f?e=>{f(e,{...E})}:void 0;return t.jsx("svg",{style:{zIndex:$},children:t.jsxs("g",{className:r(["react-flow__edge",`react-flow__edge-${_}`,E.className,w,{selected:E.selected,animated:E.animated,inactive:!P&&!l,updating:O,selectable:P}]),onClick:e=>{const{addSelectedEdges:t,unselectNodesAndEdges:n,multiSelectionActive:r}=D.getState();P&&(D.setState({nodesSelectionActive:!1}),E.selected&&r?(n({nodes:[],edges:[E]}),z.current?.blur()):t([o])),l&&l(e,E)},onDoubleClick:Z,onContextMenu:W,onMouseEnter:F,onMouseMove:K,onMouseLeave:G,onKeyDown:N?e=>{if(!S&&eo.includes(e.key)&&P){const{unselectNodesAndEdges:t,addSelectedEdges:n}=D.getState();"Escape"===e.key?(z.current?.blur(),t({edges:[E]})):n([o])}}:void 0,tabIndex:N?0:void 0,role:N?"button":"img","data-id":o,"data-testid":`rf__edge-${o}`,"aria-label":null===E.ariaLabel?void 0:E.ariaLabel||`Edge from ${E.source} to ${E.target}`,"aria-describedby":N?`${xi}-${v}`:void 0,ref:z,children:[!A&&t.jsx(M,{id:o,source:E.source,target:E.target,type:E.type,selected:E.selected,animated:E.animated,selectable:P,deletable:E.deletable??!0,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,sourceX:L,sourceY:T,targetX:B,targetY:j,sourcePosition:V,targetPosition:H,data:E.data,style:E.style,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerStart:X,markerEnd:Y,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth}),k&&t.jsx(xs,{edge:E,isReconnectable:k,reconnectRadius:g,onReconnect:p,onReconnectStart:m,onReconnectEnd:y,sourceX:L,sourceY:T,targetX:B,targetY:j,sourcePosition:V,targetPosition:H,setUpdateHover:I,setReconnecting:R,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle})]})})}const bs=e=>({width:e.width,height:e.height,edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ss({defaultMarkerColor:e,onlyRenderVisibleElements:o,rfId:r,edgeTypes:i,noPanClassName:a,onReconnect:s,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:d,onEdgeClick:h,reconnectRadius:f,onEdgeDoubleClick:g,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:y}){const{edgesFocusable:v,edgesReconnectable:x,elementsSelectable:w,onError:b}=gi(bs,Ni),S=(E=o,gi(n.useCallback((e=>{if(!E)return e.edges.map((e=>e.id));const t=[];if(e.width&&e.height)for(const n of e.edges){const o=e.nodeLookup.get(n.source),r=e.nodeLookup.get(n.target);o&&r&&tr({sourceNode:o,targetNode:r,width:e.width,height:e.height,transform:e.transform})&&t.push(n.id)}return t}),[E]),Ni));var E;return t.jsxs("div",{className:"react-flow__edges",children:[t.jsx(Wa,{defaultColor:e,rfId:r}),S.map((e=>t.jsx(ws,{id:e,edgesFocusable:v,edgesReconnectable:x,elementsSelectable:w,noPanClassName:a,onReconnect:s,onContextMenu:l,onMouseEnter:c,onMouseMove:u,onMouseLeave:d,onClick:h,reconnectRadius:f,onDoubleClick:g,onReconnectStart:p,onReconnectEnd:m,rfId:r,onError:b,edgeTypes:i,disableKeyboardA11y:y},e)))]})}Ss.displayName="EdgeRenderer";const Es=n.memo(Ss),Cs=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function _s({children:e}){const n=gi(Cs);return t.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}const Ms=e=>e.panZoom?.syncViewport;const Ns={[e.Position.Left]:e.Position.Right,[e.Position.Right]:e.Position.Left,[e.Position.Top]:e.Position.Bottom,[e.Position.Bottom]:e.Position.Top},ks=({nodeId:o,handleType:r,style:i,type:a=e.ConnectionLineType.Bezier,CustomComponent:s,connectionStatus:l})=>{const{fromNode:c,handleId:u,toX:d,toY:h,connectionMode:f,endPosition:g,isValid:p}=gi(n.useCallback((e=>({fromNode:e.nodeLookup.get(o),handleId:e.connectionStartHandle?.handleId,toX:(e.connectionPosition.x-e.transform[0])/e.transform[2],toY:(e.connectionPosition.y-e.transform[1])/e.transform[2],connectionMode:e.connectionMode,endPosition:e.connectionEndHandle?.position,isValid:"valid"===e.connectionStatus})),[o]),Ni),m=c?.internals.handleBounds;let y=m?.[r];if(f===e.ConnectionMode.Loose&&(y=y||m?.["source"===r?"target":"source"]),!c||!y)return null;const v=u?y.find((e=>e.id===u)):y[0],x=v?v.x+v.width/2:(c.measured.width??0)/2,w=v?v.y+v.height/2:c.measured.height??0,b=c.internals.positionAbsolute.x+x,S=c.internals.positionAbsolute.y+w,E=v?.position,C=p&&g?g:E?Ns[E]:null;if(!E||!C)return null;if(s)return t.jsx(s,{connectionLineType:a,connectionLineStyle:i,fromNode:c,fromHandle:v,fromX:b,fromY:S,toX:d,toY:h,fromPosition:E,toPosition:C,connectionStatus:l});let _="";const M={sourceX:b,sourceY:S,sourcePosition:E,targetX:d,targetY:h,targetPosition:C};return a===e.ConnectionLineType.Bezier?[_]=Jo(M):a===e.ConnectionLineType.Step?[_]=lr({...M,borderRadius:0}):a===e.ConnectionLineType.SmoothStep?[_]=lr(M):a===e.ConnectionLineType.SimpleBezier?[_]=Ua(M):_=`M${b},${S} ${d},${h}`,t.jsx("path",{d:_,fill:"none",className:"react-flow__connection-path",style:i})};ks.displayName="ConnectionLine";const Ps=e=>({nodeId:e.connectionStartHandle?.nodeId,handleType:e.connectionStartHandle?.type,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function zs({containerStyle:e,style:n,type:o,component:i}){const{nodeId:a,handleType:s,nodesConnectable:l,width:c,height:u,connectionStatus:d}=gi(Ps,Ni);return!!(a&&s&&c&&l)?t.jsx("svg",{style:e,width:c,height:u,className:"react-flow__connectionline react-flow__container",children:t.jsx("g",{className:r(["react-flow__connection",d]),children:t.jsx(ks,{nodeId:a,handleType:s,style:n,type:o,CustomComponent:i,connectionStatus:d})})}):null}const Os={};function Is(e=Os){n.useRef(e),pi(),n.useEffect((()=>{}),[e])}function As({nodeTypes:e,edgeTypes:o,onInit:r,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:s,onEdgeDoubleClick:l,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:h,onSelectionContextMenu:f,onSelectionStart:g,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:y,connectionLineComponent:v,connectionLineContainerStyle:x,selectionKeyCode:w,selectionOnDrag:b,selectionMode:S,multiSelectionKeyCode:E,panActivationKeyCode:C,zoomActivationKeyCode:_,deleteKeyCode:M,onlyRenderVisibleElements:N,elementsSelectable:k,defaultViewport:P,translateExtent:z,minZoom:O,maxZoom:I,preventScrolling:A,defaultMarkerColor:R,zoomOnScroll:D,zoomOnPinch:$,panOnScroll:L,panOnScrollSpeed:T,panOnScrollMode:B,zoomOnDoubleClick:j,panOnDrag:V,onPaneClick:H,onPaneMouseEnter:X,onPaneMouseMove:Y,onPaneMouseLeave:Z,onPaneScroll:W,onPaneContextMenu:F,onEdgeContextMenu:K,onEdgeMouseEnter:G,onEdgeMouseMove:q,onEdgeMouseLeave:U,reconnectRadius:Q,onReconnect:J,onReconnectStart:ee,onReconnectEnd:te,noDragClassName:ne,noWheelClassName:oe,noPanClassName:re,disableKeyboardA11y:ie,nodeOrigin:ae,nodeExtent:se,rfId:le,viewport:ce,onViewportChange:ue}){return Is(e),Is(o),pi(),n.useRef(!1),n.useEffect((()=>{}),[]),function(e){const t=la(),o=n.useRef(!1);n.useEffect((()=>{!o.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),o.current=!0)}),[e,t.viewportInitialized])}(r),function(e){const t=gi(Ms),o=pi();n.useEffect((()=>{e&&(t?.(e),o.setState({transform:[e.x,e.y,e.zoom]}))}),[e,t])}(ce),t.jsx($a,{onPaneClick:H,onPaneMouseEnter:X,onPaneMouseMove:Y,onPaneMouseLeave:Z,onPaneContextMenu:F,onPaneScroll:W,deleteKeyCode:M,selectionKeyCode:w,selectionOnDrag:b,selectionMode:S,onSelectionStart:g,onSelectionEnd:p,multiSelectionKeyCode:E,panActivationKeyCode:C,zoomActivationKeyCode:_,elementsSelectable:k,zoomOnScroll:D,zoomOnPinch:$,zoomOnDoubleClick:j,panOnScroll:L,panOnScrollSpeed:T,panOnScrollMode:B,panOnDrag:V,defaultViewport:P,translateExtent:z,minZoom:O,maxZoom:I,onSelectionContextMenu:f,preventScrolling:A,noDragClassName:ne,noWheelClassName:oe,noPanClassName:re,disableKeyboardA11y:ie,onViewportChange:ue,isControlledViewport:!!ce,children:t.jsxs(_s,{children:[t.jsx(Es,{edgeTypes:o,onEdgeClick:a,onEdgeDoubleClick:l,onReconnect:J,onReconnectStart:ee,onReconnectEnd:te,onlyRenderVisibleElements:N,onEdgeContextMenu:K,onEdgeMouseEnter:G,onEdgeMouseMove:q,onEdgeMouseLeave:U,reconnectRadius:Q,defaultMarkerColor:R,noPanClassName:re,disableKeyboardA11y:ie,rfId:le}),t.jsx(zs,{style:y,type:m,component:v,containerStyle:x}),t.jsx("div",{className:"react-flow__edgelabel-renderer"}),t.jsx(Ha,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:h,onlyRenderVisibleElements:N,noPanClassName:re,noDragClassName:ne,disableKeyboardA11y:ie,nodeOrigin:ae,nodeExtent:se,rfId:le}),t.jsx("div",{className:"react-flow__viewport-portal"})]})})}As.displayName="GraphView";const Rs=n.memo(As),Ds=({nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:a,fitView:s}={})=>{const l=new Map,c=new Map,u=new Map,d=new Map,h=r??n??[],f=o??t??[];xr(u,d,h),mr(f,l,c,{nodeOrigin:[0,0],elevateNodesOnSelect:!1});let g=[0,0,1];if(s&&i&&a){const e=fo(l,{nodeOrigin:[0,0],filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),{x:t,y:n,zoom:o}=$o(e,i,a,.5,2,.1);g=[t,n,o]}return{rfId:"1",width:0,height:0,transform:g,nodes:f,nodeLookup:l,parentLookup:c,edges:h,edgeLookup:d,connectionLookup:u,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==o,hasDefaultEdges:void 0!==r,panZoom:null,minZoom:.5,maxZoom:2,translateExtent:Jn,nodeExtent:Jn,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:e.ConnectionMode.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,fitViewOnInit:!1,fitViewDone:!1,fitViewOnInitOptions:void 0,selectNodesOnDrag:!0,multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:Oo,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1}},$s=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:a})=>{return s=(s,l)=>({...Ds({nodes:e,edges:t,width:r,height:i,fitView:a,defaultNodes:n,defaultEdges:o}),setNodes:e=>{const{nodeLookup:t,parentLookup:n,nodeOrigin:o,elevateNodesOnSelect:r}=l();mr(e,t,n,{nodeOrigin:o,elevateNodesOnSelect:r,checkEquality:!0}),s({nodes:e})},setEdges:e=>{const{connectionLookup:t,edgeLookup:n}=l();xr(t,n,e),s({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){const{setNodes:t}=l();t(e),s({hasDefaultNodes:!0})}if(t){const{setEdges:e}=l();e(t),s({hasDefaultEdges:!0})}},updateNodeInternals:e=>{const{triggerNodeChanges:t,fitView:n,nodeLookup:o,parentLookup:r,fitViewOnInit:i,fitViewDone:a,fitViewOnInitOptions:c,domNode:u,nodeOrigin:d,debug:h}=l(),{changes:f,updatedInternals:g}=function(e,t,n,o,r){const i=o?.querySelector(".xyflow__viewport");let a=!1;if(!i)return{changes:[],updatedInternals:a};const s=[],l=window.getComputedStyle(i),{m22:c}=new window.DOMMatrixReadOnly(l.transform),u=[];if(e.forEach((e=>{const n=t.get(e.id);if(n?.hidden)n.internals={...n.internals,handleBounds:void 0},a=!0;else if(n){const t=Xo(e.nodeElement),o=n.measured.width!==t.width||n.measured.height!==t.height;if(t.width&&t.height&&(o||!n.internals.handleBounds||e.force)){const i=e.nodeElement.getBoundingClientRect();n.measured=t,n.internals={...n.internals,handleBounds:{source:Go(".source",e.nodeElement,i,c,n.origin||r),target:Go(".target",e.nodeElement,i,c,n.origin||r)}},a=!0,o&&(s.push({id:n.id,type:"dimensions",dimensions:t}),n.expandParent&&n.parentId&&u.push({id:n.id,parentId:n.parentId,rect:_o(n,r)}))}}})),u.length>0){const e=vr(u,t,n,r);s.push(...e)}return{changes:s,updatedInternals:a}}(e,o,r,u,d);if(!g)return;pr(o,{nodeOrigin:d});let p=a;!a&&i&&(p=n({...c,nodes:c?.nodes})),s({fitViewDone:p}),f?.length>0&&(h&&console.log("React Flow: trigger node changes",f),t?.(f))},updateNodePositions:(e,t=!1)=>{const n=[],o=[];for(const[r,i]of e){const e={id:r,type:"position",position:i.position,dragging:t};i?.expandParent&&i?.parentId&&e.position&&(n.push({id:r,parentId:i.parentId,rect:{...i.internals.positionAbsolute,width:i.measured.width,height:i.measured.height}}),e.position.x=Math.max(0,e.position.x),e.position.y=Math.max(0,e.position.y)),o.push(e)}if(n.length>0){const{nodeLookup:e,parentLookup:t}=l(),r=vr(n,e,t);o.push(...r)}l().triggerNodeChanges(o)},triggerNodeChanges:e=>{const{onNodesChange:t,setNodes:n,nodes:o,hasDefaultNodes:r,debug:i}=l();e?.length&&(r&&n(Ki(e,o)),i&&console.log("React Flow: trigger node changes",e),t?.(e))},triggerEdgeChanges:e=>{const{onEdgesChange:t,setEdges:n,edges:o,hasDefaultEdges:r,debug:i}=l();e?.length&&(r&&n(Gi(e,o)),i&&console.log("React Flow: trigger edge changes",e),t?.(e))},addSelectedNodes:e=>{const{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=l();t?r(e.map((e=>qi(e,!0)))):(r(Ui(o,new Set([...e]),!0)),i(Ui(n)))},addSelectedEdges:e=>{const{multiSelectionActive:t,edgeLookup:n,nodeLookup:o,triggerNodeChanges:r,triggerEdgeChanges:i}=l();t?i(e.map((e=>qi(e,!0)))):(i(Ui(n,new Set([...e]))),r(Ui(o,new Set,!0)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{const{edges:n,nodes:o,triggerNodeChanges:r,triggerEdgeChanges:i}=l(),a=t||n,s=(e||o).map((e=>(e.selected=!1,qi(e.id,!1)))),c=a.map((e=>qi(e.id,!1)));r(s),i(c)},setMinZoom:e=>{const{panZoom:t,maxZoom:n}=l();t?.setScaleExtent([e,n]),s({minZoom:e})},setMaxZoom:e=>{const{panZoom:t,minZoom:n}=l();t?.setScaleExtent([n,e]),s({maxZoom:e})},setTranslateExtent:e=>{l().panZoom?.setTranslateExtent(e),s({translateExtent:e})},resetSelectedElements:()=>{const{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:o}=l(),r=t.reduce(((e,t)=>t.selected?[...e,qi(t.id,!1)]:e),[]),i=e.reduce(((e,t)=>t.selected?[...e,qi(t.id,!1)]:e),[]);n(r),o(i)},setNodeExtent:e=>{const{nodeLookup:t}=l();for(const[,n]of t){const o=xo(n.position,e);t.set(n.id,{...n,internals:{...n.internals,positionAbsolute:o}})}s({nodeExtent:e})},panBy:e=>{const{transform:t,width:n,height:o,panZoom:r,translateExtent:i}=l();return function({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const a=t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}({delta:e,panZoom:r,transform:t,translateExtent:i,width:n,height:o})},fitView:e=>{const{panZoom:t,width:n,height:o,minZoom:r,maxZoom:i,nodeOrigin:a,nodeLookup:s}=l();return!!t&&mo({nodeLookup:s,width:n,height:o,panZoom:t,minZoom:r,maxZoom:i,nodeOrigin:a},e)},cancelConnection:()=>s({connectionStatus:null,connectionStartHandle:null,connectionEndHandle:null}),updateConnection:e=>{const{connectionPosition:t}=l(),n={...e,connectionPosition:e.connectionPosition??t};s(n)},reset:()=>s({...Ds()})}),l=Object.is,s?ui(s,l):ui;var s,l};function Ls({initialNodes:e,initialEdges:o,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:s,fitView:l,children:c}){const[u]=n.useState((()=>$s({nodes:e,edges:o,defaultNodes:r,defaultEdges:i,width:a,height:s,fitView:l})));return t.jsx(hi,{value:u,children:t.jsx(aa,{children:c})})}function Ts({children:e,nodes:o,edges:r,defaultNodes:i,defaultEdges:a,width:s,height:l,fitView:c}){return n.useContext(di)?t.jsx(t.Fragment,{children:e}):t.jsx(Ls,{initialNodes:o,initialEdges:r,defaultNodes:i,defaultEdges:a,initialWidth:s,initialHeight:l,fitView:c,children:e})}const Bs={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var js=na((function({nodes:o,edges:i,defaultNodes:a,defaultEdges:s,className:l,nodeTypes:c,edgeTypes:u,onNodeClick:d,onEdgeClick:h,onInit:f,onMove:g,onMoveStart:p,onMoveEnd:m,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:b,onNodeMouseEnter:S,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:_,onNodeDoubleClick:M,onNodeDragStart:N,onNodeDrag:k,onNodeDragStop:P,onNodesDelete:z,onEdgesDelete:O,onDelete:I,onSelectionChange:A,onSelectionDragStart:R,onSelectionDrag:D,onSelectionDragStop:$,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:B,onBeforeDelete:j,connectionMode:V,connectionLineType:H=e.ConnectionLineType.Bezier,connectionLineStyle:X,connectionLineComponent:Y,connectionLineContainerStyle:Z,deleteKeyCode:W="Backspace",selectionKeyCode:F="Shift",selectionOnDrag:K=!1,selectionMode:G=e.SelectionMode.Full,panActivationKeyCode:q="Space",multiSelectionKeyCode:U=(Lo()?"Meta":"Control"),zoomActivationKeyCode:Q=(Lo()?"Meta":"Control"),snapToGrid:J,snapGrid:ee,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:ne,nodesDraggable:oe,nodesConnectable:re,nodesFocusable:ie,nodeOrigin:ae=Ri,edgesFocusable:se,edgesReconnectable:le,elementsSelectable:ce=!0,defaultViewport:ue=Di,minZoom:de=.5,maxZoom:he=2,translateExtent:fe=Jn,preventScrolling:ge=!0,nodeExtent:pe,defaultMarkerColor:me="#b1b1b7",zoomOnScroll:ye=!0,zoomOnPinch:ve=!0,panOnScroll:xe=!1,panOnScrollSpeed:we=.5,panOnScrollMode:be=e.PanOnScrollMode.Free,zoomOnDoubleClick:Se=!0,panOnDrag:Ee=!0,onPaneClick:Ce,onPaneMouseEnter:_e,onPaneMouseMove:Me,onPaneMouseLeave:Ne,onPaneScroll:ke,onPaneContextMenu:Pe,children:ze,onReconnect:Oe,onReconnectStart:Ie,onReconnectEnd:Ae,onEdgeContextMenu:Re,onEdgeDoubleClick:De,onEdgeMouseEnter:$e,onEdgeMouseMove:Le,onEdgeMouseLeave:Te,reconnectRadius:Be=10,onNodesChange:je,onEdgesChange:Ve,noDragClassName:He="nodrag",noWheelClassName:Xe="nowheel",noPanClassName:Ye="nopan",fitView:Ze,fitViewOptions:We,connectOnClick:Fe,attributionPosition:Ke,proOptions:Ge,defaultEdgeOptions:qe,elevateNodesOnSelect:Ue,elevateEdgesOnSelect:Qe,disableKeyboardA11y:Je=!1,autoPanOnConnect:et,autoPanOnNodeDrag:tt,connectionRadius:nt,isValidConnection:ot,onError:rt,style:it,id:at,nodeDragThreshold:st,viewport:lt,onViewportChange:ct,width:ut,height:dt,colorMode:ht="light",debug:ft,...gt},pt){const mt=at||"1",yt=function(e){const[t,o]=n.useState("system"===e?null:e);return n.useEffect((()=>{if("system"!==e)return void o(e);const t=ji(),n=()=>o(t?.matches?"dark":"light");return n(),t?.addEventListener("change",n),()=>{t?.removeEventListener("change",n)}}),[e]),null!==t?t:ji()?.matches?"dark":"light"}(ht);return t.jsx("div",{...gt,style:{...it,...Bs},ref:pt,className:r(["react-flow",l,yt]),"data-testid":"rf__wrapper",id:at,children:t.jsxs(Ts,{nodes:o,edges:i,width:ut,height:dt,fitView:Ze,children:[t.jsx(Rs,{onInit:f,onNodeClick:d,onEdgeClick:h,onNodeMouseEnter:S,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:_,onNodeDoubleClick:M,nodeTypes:c,edgeTypes:u,connectionLineType:H,connectionLineStyle:X,connectionLineComponent:Y,connectionLineContainerStyle:Z,selectionKeyCode:F,selectionOnDrag:K,selectionMode:G,deleteKeyCode:W,multiSelectionKeyCode:U,panActivationKeyCode:q,zoomActivationKeyCode:Q,onlyRenderVisibleElements:te,defaultViewport:ue,translateExtent:fe,minZoom:de,maxZoom:he,preventScrolling:ge,zoomOnScroll:ye,zoomOnPinch:ve,zoomOnDoubleClick:Se,panOnScroll:xe,panOnScrollSpeed:we,panOnScrollMode:be,panOnDrag:Ee,onPaneClick:Ce,onPaneMouseEnter:_e,onPaneMouseMove:Me,onPaneMouseLeave:Ne,onPaneScroll:ke,onPaneContextMenu:Pe,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:B,onReconnect:Oe,onReconnectStart:Ie,onReconnectEnd:Ae,onEdgeContextMenu:Re,onEdgeDoubleClick:De,onEdgeMouseEnter:$e,onEdgeMouseMove:Le,onEdgeMouseLeave:Te,reconnectRadius:Be,defaultMarkerColor:me,noDragClassName:He,noWheelClassName:Xe,noPanClassName:Ye,rfId:mt,disableKeyboardA11y:Je,nodeOrigin:ae,nodeExtent:pe,viewport:lt,onViewportChange:ct}),t.jsx(Bi,{nodes:o,edges:i,defaultNodes:a,defaultEdges:s,onConnect:y,onConnectStart:v,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:b,nodesDraggable:oe,nodesConnectable:re,nodesFocusable:ie,edgesFocusable:se,edgesReconnectable:le,elementsSelectable:ce,elevateNodesOnSelect:Ue,elevateEdgesOnSelect:Qe,minZoom:de,maxZoom:he,nodeExtent:pe,onNodesChange:je,onEdgesChange:Ve,snapToGrid:J,snapGrid:ee,connectionMode:V,translateExtent:fe,connectOnClick:Fe,defaultEdgeOptions:qe,fitView:Ze,fitViewOptions:We,onNodesDelete:z,onEdgesDelete:O,onDelete:I,onNodeDragStart:N,onNodeDrag:k,onNodeDragStop:P,onSelectionDrag:D,onSelectionDragStart:R,onSelectionDragStop:$,onMove:g,onMoveStart:p,onMoveEnd:m,noPanClassName:Ye,nodeOrigin:ae,rfId:mt,autoPanOnConnect:et,autoPanOnNodeDrag:tt,onError:rt,connectionRadius:nt,isValidConnection:ot,selectNodesOnDrag:ne,nodeDragThreshold:st,onBeforeDelete:j,debug:ft}),t.jsx(Ai,{onSelectionChange:A}),ze,t.jsx(Mi,{proOptions:Ge,position:Ke}),t.jsx(Ei,{rfId:mt,disableKeyboardA11y:Je})]})})}));const Vs=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");const Hs=e=>e.domNode?.querySelector(".react-flow__viewport-portal");const Xs=e=>e.nodes;const Ys=e=>e.edges;const Zs=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});const Ws={includeHiddenNodes:!1};const Fs=e=>({startHandle:e.connectionStartHandle,endHandle:e.connectionEndHandle,status:e.connectionStatus,position:e.connectionStartHandle?e.connectionPosition:null});function Ks({dimensions:e,lineWidth:n,variant:o,className:i}){return t.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:r(["react-flow__background-pattern",o,i])})}function Gs({radius:e,className:n}){return t.jsx("circle",{cx:e,cy:e,r:e,className:r(["react-flow__background-pattern","dots",n])})}var qs;e.BackgroundVariant=void 0,(qs=e.BackgroundVariant||(e.BackgroundVariant={})).Lines="lines",qs.Dots="dots",qs.Cross="cross";const Us={[e.BackgroundVariant.Dots]:1,[e.BackgroundVariant.Lines]:1,[e.BackgroundVariant.Cross]:6},Qs=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Js({id:o,variant:i=e.BackgroundVariant.Dots,gap:a=20,size:s,lineWidth:l=1,offset:c=2,color:u,bgColor:d,style:h,className:f,patternClassName:g}){const p=n.useRef(null),{transform:m,patternId:y}=gi(Qs,Ni),v=s||Us[i],x=i===e.BackgroundVariant.Dots,w=i===e.BackgroundVariant.Cross,b=Array.isArray(a)?a:[a,a],S=[b[0]*m[2]||1,b[1]*m[2]||1],E=v*m[2],C=w?[E,E]:S,_=x?[E/c,E/c]:[C[0]/c,C[1]/c],M=`${y}${o||""}`;return t.jsxs("svg",{className:r(["react-flow__background",f]),style:{...h,...ha,"--xy-background-color-props":d,"--xy-background-pattern-color-props":u},ref:p,"data-testid":"rf__background",children:[t.jsx("pattern",{id:M,x:m[0]%S[0],y:m[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:x?t.jsx(Gs,{radius:E/c,className:g}):t.jsx(Ks,{dimensions:C,lineWidth:l,variant:i,className:g})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}Js.displayName="Background";const el=n.memo(Js);function tl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:t.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function nl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:t.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ol(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:t.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function rl(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function il(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:t.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function al({children:e,className:n,...o}){return t.jsx("button",{type:"button",className:r(["react-flow__controls-button",n]),...o,children:e})}const sl=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom});function ll({style:e,showZoom:n=!0,showFitView:o=!0,showInteractive:i=!0,fitViewOptions:a,onZoomIn:s,onZoomOut:l,onFitView:c,onInteractiveChange:u,className:d,children:h,position:f="bottom-left",orientation:g="vertical","aria-label":p="React Flow controls"}){const m=pi(),{isInteractive:y,minZoomReached:v,maxZoomReached:x}=gi(sl,Ni),{zoomIn:w,zoomOut:b,fitView:S}=la(),E="horizontal"===g?"horizontal":"vertical";return t.jsxs(_i,{className:r(["react-flow__controls",E,d]),position:f,style:e,"data-testid":"rf__controls","aria-label":p,children:[n&&t.jsxs(t.Fragment,{children:[t.jsx(al,{onClick:()=>{w(),s?.()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x,children:t.jsx(tl,{})}),t.jsx(al,{onClick:()=>{b(),l?.()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v,children:t.jsx(nl,{})})]}),o&&t.jsx(al,{className:"react-flow__controls-fitview",onClick:()=>{S(a),c?.()},title:"fit view","aria-label":"fit view",children:t.jsx(ol,{})}),i&&t.jsx(al,{className:"react-flow__controls-interactive",onClick:()=>{m.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),u?.(!y)},title:"toggle interactivity","aria-label":"toggle interactivity",children:y?t.jsx(il,{}):t.jsx(rl,{})}),h]})}ll.displayName="Controls";const cl=n.memo(ll);const ul=n.memo((function({id:e,x:n,y:o,width:i,height:a,style:s,color:l,strokeColor:c,strokeWidth:u,className:d,borderRadius:h,shapeRendering:f,selected:g,onClick:p}){const{background:m,backgroundColor:y}=s||{},v=l||m||y;return t.jsx("rect",{className:r(["react-flow__minimap-node",{selected:g},d]),x:n,y:o,rx:h,ry:h,width:i,height:a,style:{fill:v,stroke:c,strokeWidth:u},shapeRendering:f,onClick:p?t=>p(t,e):void 0})})),dl=e=>e.nodeOrigin,hl=e=>e.nodes.map((e=>e.id)),fl=e=>e instanceof Function?e:()=>e;const gl=n.memo((function({id:e,nodeOrigin:n,nodeColorFunc:o,nodeStrokeColorFunc:r,nodeClassNameFunc:i,nodeBorderRadius:a,nodeStrokeWidth:s,shapeRendering:l,NodeComponent:c,onClick:u}){const{node:d,x:h,y:f}=gi((t=>{const o=t.nodeLookup.get(e),{x:r,y:i}=uo(o,n).positionAbsolute;return{node:o,x:r,y:i}}),Ni);if(!d||d.hidden||!jo(d))return null;const{width:g,height:p}=Bo(d);return t.jsx(c,{x:h,y:f,width:g,height:p,style:d.style,selected:!!d.selected,className:i(d),color:o(d),borderRadius:a,strokeColor:r(d),strokeWidth:s,shapeRendering:l,onClick:u,id:d.id})}));var pl=n.memo((function({nodeStrokeColor:e,nodeColor:n,nodeClassName:o="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=ul,onClick:s}){const l=gi(hl,Ni),c=gi(dl),u=fl(n),d=fl(e),h=fl(o),f="undefined"==typeof window||window.chrome?"crispEdges":"geometricPrecision";return t.jsx(t.Fragment,{children:l.map((e=>t.jsx(gl,{id:e,nodeOrigin:c,nodeColorFunc:u,nodeStrokeColorFunc:d,nodeClassNameFunc:h,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:s,shapeRendering:f},e)))})}));const ml=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?No(fo(e.nodeLookup,{nodeOrigin:e.nodeOrigin}),t):t,rfId:e.rfId,nodeOrigin:e.nodeOrigin,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height}};function yl({style:e,className:o,nodeStrokeColor:i,nodeColor:a,nodeClassName:s="",nodeBorderRadius:l=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:f,maskStrokeWidth:g,position:p="bottom-right",onClick:m,onNodeClick:y,pannable:v=!1,zoomable:x=!1,ariaLabel:w="React Flow mini map",inversePan:b,zoomStep:S=10,offsetScale:E=5}){const C=pi(),_=n.useRef(null),{boundingRect:M,viewBB:N,rfId:k,panZoom:P,translateExtent:z,flowWidth:O,flowHeight:I}=gi(ml,Ni),A=e?.width??200,R=e?.height??150,D=M.width/A,$=M.height/R,L=Math.max(D,$),T=L*A,B=L*R,j=E*L,V=M.x-(T-M.width)/2-j,H=M.y-(B-M.height)/2-j,X=T+2*j,Y=B+2*j,Z=`react-flow__minimap-desc-${k}`,W=n.useRef(0),F=n.useRef();W.current=L,n.useEffect((()=>{if(_.current&&P)return F.current=function({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=Se(e);return{update:function({translateExtent:e,width:i,height:a,zoomStep:s=10,pannable:l=!0,zoomable:c=!0,inversePan:u=!1}){let d=[0,0];const h=Un().on("start",(e=>{"mousedown"!==e.sourceEvent.type&&"touchstart"!==e.sourceEvent.type||(d=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])})).on("zoom",l?r=>{const s=n();if("mousemove"!==r.sourceEvent.type&&"touchmove"!==r.sourceEvent.type||!t)return;const l=[r.sourceEvent.clientX??r.sourceEvent.touches[0].clientX,r.sourceEvent.clientY??r.sourceEvent.touches[0].clientY],c=[l[0]-d[0],l[1]-d[1]];d=l;const h=o()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),f={x:s[0]-c[0]*h,y:s[1]-c[1]*h},g=[[0,0],[i,a]];t.setViewportConstrained({x:f.x,y:f.y,zoom:s[2]},g,e)}:null).on("zoom.wheel",c?e=>{const o=n();if("wheel"!==e.sourceEvent.type||!t)return;const r=-e.sourceEvent.deltaY*(1===e.sourceEvent.deltaMode?.05:e.sourceEvent.deltaMode?1:.002)*s,i=o[2]*Math.pow(2,r);t.scaleTo(i)}:null);r.call(h,{})},destroy:function(){r.on("zoom",null)},pointer:Ee}}({domNode:_.current,panZoom:P,getTransform:()=>C.getState().transform,getViewScale:()=>W.current}),()=>{F.current?.destroy()}}),[P]),n.useEffect((()=>{F.current?.update({translateExtent:z,width:O,height:I,inversePan:b,pannable:v,zoomStep:S,zoomable:x})}),[v,x,b,S,z,O,I]);const K=m?e=>{const[t,n]=F.current?.pointer(e)||[0,0];m(e,{x:t,y:n})}:void 0,G=y?n.useCallback(((e,t)=>{const n=C.getState().nodeLookup.get(t);y(e,n)}),[]):void 0;return t.jsx(_i,{position:p,style:{...e,"--xy-minimap-background-color-props":"string"==typeof d?d:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof h?h:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof f?f:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof g?g*L:void 0,"--xy-minimap-node-background-color-props":"string"==typeof a?a:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof i?i:void 0,"--xy-minimap-node-stroke-width-props":"string"==typeof c?c:void 0},className:r(["react-flow__minimap",o]),"data-testid":"rf__minimap",children:t.jsxs("svg",{width:A,height:R,viewBox:`${V} ${H} ${X} ${Y}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Z,ref:_,onClick:K,children:[w&&t.jsx("title",{id:Z,children:w}),t.jsx(pl,{onClick:G,nodeColor:a,nodeStrokeColor:i,nodeBorderRadius:l,nodeClassName:s,nodeStrokeWidth:c,nodeComponent:u}),t.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-j},${H-j}h${X+2*j}v${Y+2*j}h${-X-2*j}z\n M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}yl.displayName="MiniMap";const vl=n.memo(yl);const xl=n.memo((function({nodeId:e,position:o,variant:i=jr.Handle,className:a,style:s={},children:l,color:c,minWidth:u=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:g=!1,shouldResize:p,onResizeStart:m,onResize:y,onResizeEnd:v}){const x=Ma(),w="string"==typeof e?e:x,b=pi(),S=n.useRef(null),E=i===jr.Line?"right":"bottom-right",C=o??E,_=n.useRef(null);n.useEffect((()=>{if(S.current&&w)return _.current||(_.current=qr({domNode:S.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:o,nodeOrigin:r}},onChange:(e,t)=>{const{triggerNodeChanges:n,nodeLookup:o,parentLookup:r,nodeOrigin:i}=b.getState(),a=[],s={x:e.x,y:e.y},l=o.get(w);if(l&&l.expandParent&&l.parentId){const t=vr([{id:l.id,parentId:l.parentId,rect:{width:e.width??l.measured.width,height:e.height??l.measured.height,...Vo({x:e.x??l.position.x,y:e.y??l.position.y},l.parentId,o,l.origin??i)}}],o,r,i);a.push(...t),s.x=e.x?Math.max(0,e.x):void 0,s.y=e.y?Math.max(0,e.y):void 0}if(void 0!==s.x&&void 0!==s.y){const e={id:w,type:"position",position:{...s}};a.push(e)}if(void 0!==e.width&&void 0!==e.height){const t={id:w,type:"dimensions",resizing:!0,setAttributes:!0,dimensions:{width:e.width,height:e.height}};a.push(t)}for(const e of t){const t={...e,type:"position"};a.push(t)}n(a)},onEnd:()=>{const e={id:w,type:"dimensions",resizing:!1};b.getState().triggerNodeChanges([e])}})),_.current.update({controlPosition:C,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:f},keepAspectRatio:g,onResizeStart:m,onResize:y,onResizeEnd:v,shouldResize:p}),()=>{_.current?.destroy()}}),[C,u,d,h,f,g,m,y,v,p]);const M=C.split("-"),N=i===jr.Line?"borderColor":"backgroundColor",k=c?{...s,[N]:c}:s;return t.jsx("div",{className:r(["react-flow__resize-control","nodrag",...M,i,a]),ref:S,style:k,children:l})}));const wl=e=>e.domNode?.querySelector(".react-flow__renderer");function bl({children:e}){const t=gi(wl);return t?o.createPortal(e,t):null}const Sl=(e,t)=>e.length===t.length&&!e.some(((e,n)=>((e,t)=>e?.internals.positionAbsolute.x!==t?.internals.positionAbsolute.x||e?.internals.positionAbsolute.y!==t?.internals.positionAbsolute.y||e?.measured.width!==t?.measured.width||e?.measured.height!==t?.measured.height||e?.selected!==t?.selected||e?.internals.z!==t?.internals.z)(e,t[n]))),El=e=>({viewport:{x:e.transform[0],y:e.transform[1],zoom:e.transform[2]},nodeOrigin:e.nodeOrigin,selectedNodesCount:e.nodes.filter((e=>e.selected)).length});e.Background=el,e.BaseEdge=Ga,e.BezierEdge=ds,e.ControlButton=al,e.Controls=cl,e.EdgeLabelRenderer=function({children:e}){const t=gi(Vs);return t?o.createPortal(e,t):null},e.EdgeText=Ka,e.Handle=ka,e.MiniMap=vl,e.NodeResizeControl=xl,e.NodeResizer=function({nodeId:e,isVisible:n=!0,handleClassName:o,handleStyle:r,lineClassName:i,lineStyle:a,color:s,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:h=!1,shouldResize:f,onResizeStart:g,onResize:p,onResizeEnd:m}){return n?t.jsxs(t.Fragment,{children:[Hr.map((n=>t.jsx(xl,{className:i,style:a,nodeId:e,position:n,variant:jr.Line,color:s,minWidth:l,minHeight:c,maxWidth:u,maxHeight:d,onResizeStart:g,keepAspectRatio:h,shouldResize:f,onResize:p,onResizeEnd:m},n))),Vr.map((n=>t.jsx(xl,{className:o,style:r,nodeId:e,position:n,color:s,minWidth:l,minHeight:c,maxWidth:u,maxHeight:d,onResizeStart:g,keepAspectRatio:h,shouldResize:f,onResize:p,onResizeEnd:m},n)))]}):null},e.NodeToolbar=function({nodeId:o,children:i,className:a,style:s,isVisible:l,position:c=e.Position.Top,offset:u=10,align:d="center",...h}){const f=Ma(),g=n.useCallback((e=>(Array.isArray(o)?o:[o||f||""]).reduce(((t,n)=>{const o=e.nodeLookup.get(n);return o&&t.push(o),t}),[])),[o,f]),p=gi(g,Sl),{viewport:m,nodeOrigin:y,selectedNodesCount:v}=gi(El,Ni);if(!("boolean"==typeof l?l:1===p.length&&p[0].selected&&1===v)||!p.length)return null;const x=ho(p,{nodeOrigin:y}),w=Math.max(...p.map((e=>e.internals.z+1))),b={position:"absolute",transform:gr(x,m,c,u,d),zIndex:w,...s};return t.jsx(bl,{children:t.jsx("div",{style:b,className:r(["react-flow__node-toolbar",a]),...h,"data-id":p.reduce(((e,t)=>`${e}${t.id} `),"").trim(),children:i})})},e.Panel=_i,e.ReactFlow=js,e.ReactFlowProvider=Ls,e.SimpleBezierEdge=Ja,e.SmoothStepEdge=ns,e.StepEdge=is,e.StraightEdge=ls,e.ViewportPortal=function({children:e}){const t=gi(Hs);return t?o.createPortal(e,t):null},e.addEdge=or,e.applyEdgeChanges=Gi,e.applyNodeChanges=Ki,e.getBezierEdgeCenter=qo,e.getBezierPath=Jo,e.getConnectedEdges=po,e.getEdgeCenter=er,e.getIncomers=(e,t,n)=>{if(!e.id)return[];const o=new Set;return n.forEach((t=>{t.target===e.id&&o.add(t.source)})),t.filter((e=>o.has(e.id)))},e.getNodesBounds=ho,e.getOutgoers=(e,t,n)=>{if(!e.id)return[];const o=new Set;return n.forEach((t=>{t.source===e.id&&o.add(t.target)})),t.filter((e=>o.has(e.id)))},e.getSimpleBezierPath=Ua,e.getSmoothStepPath=lr,e.getStraightPath=rr,e.getViewportForBounds=$o,e.isEdge=ta,e.isNode=ea,e.reconnectEdge=(e,t,n,o={shouldReplaceId:!0})=>{const{id:r,...i}=e;if(!t.source||!t.target)return n;if(!n.find((t=>t.id===e.id)))return n;const a={...i,id:o.shouldReplaceId?nr(t):r,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter((e=>e.id!==r)).concat(a)},e.useConnection=function(){return gi(Fs,Ni)},e.useEdges=function(){return gi(Ys,Ni)},e.useEdgesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>Gi(e,t)))),[]);return[t,o,r]},e.useHandleConnections=function({type:e,id:t=null,nodeId:o,onConnect:r,onDisconnect:i}){const a=Ma(),s=o??a,l=n.useRef(null),c=gi((n=>n.connectionLookup.get(`${s}-${e}-${t}`)),so);return n.useEffect((()=>{if(l.current&&l.current!==c){const e=c??new Map;lo(l.current,e,i),lo(e,l.current,r)}l.current=c??new Map}),[c,r,i]),n.useMemo((()=>Array.from(c?.values()??[])),[c])},e.useInternalNode=function(e){return gi(n.useCallback((t=>t.nodeLookup.get(e)),[e]),Ni)},e.useKeyPress=Hi,e.useNodeId=Ma,e.useNodes=function(){return gi(Xs,Ni)},e.useNodesData=function(e){return gi(n.useCallback((t=>{const n=[],o=Array.isArray(e),r=o?e:[e];for(const e of r){const o=t.nodeLookup.get(e);o&&n.push({id:o.id,type:o.type,data:o.data})}return o?n:n[0]??null}),[e]),wr)},e.useNodesInitialized=function(e=Ws){return gi((e=>t=>{if(0===t.nodeLookup.size)return!1;for(const[,{hidden:n,internals:o}]of t.nodeLookup)if((e.includeHiddenNodes||!n)&&(void 0===o.handleBounds||!jo(o.userNode)))return!1;return!0})(e))},e.useNodesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>Ki(e,t)))),[]);return[t,o,r]},e.useOnSelectionChange=function({onChange:e}){const t=pi();n.useEffect((()=>{const n=[...t.getState().onSelectionChangeHandlers,e];return t.setState({onSelectionChangeHandlers:n}),()=>{const n=t.getState().onSelectionChangeHandlers.filter((t=>t!==e));t.setState({onSelectionChangeHandlers:n})}}),[e])},e.useOnViewportChange=function({onStart:e,onChange:t,onEnd:o}){const r=pi();n.useEffect((()=>{r.setState({onViewportChangeStart:e})}),[e]),n.useEffect((()=>{r.setState({onViewportChange:t})}),[t]),n.useEffect((()=>{r.setState({onViewportChangeEnd:o})}),[o])},e.useReactFlow=la,e.useStore=gi,e.useStoreApi=pi,e.useUpdateNodeInternals=function(){const e=pi();return n.useCallback((t=>{const{domNode:n,updateNodeInternals:o}=e.getState(),r=Array.isArray(t)?t:[t],i=new Map;r.forEach((e=>{const t=n?.querySelector(`.react-flow__node[data-id="${e}"]`);t&&i.set(e,{id:e,nodeElement:t,force:!0})})),requestAnimationFrame((()=>o(i)))}),[])},e.useViewport=function(){return gi(Zs,Ni)}}));