bullpane 0.6.2 → 0.6.3

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.
@@ -1,4 +1,4 @@
1
- import{X as Eo,Y as ma,Z as ya,f as T,j as P}from"./index-CN2nADIL.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var xa={value:()=>{}};function Qt(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Dt(n)}function Dt(e){this._=e}function wa(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Dt.prototype=Qt.prototype={constructor:Dt,on:function(e,t){var n=this._,r=wa(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=va(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=hr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=hr(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Dt(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function va(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function hr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=xa,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Cn="http://www.w3.org/1999/xhtml";const gr={svg:"http://www.w3.org/2000/svg",xhtml:Cn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),gr.hasOwnProperty(t)?{space:gr[t],local:e}:e}function ba(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cn&&t.documentElement.namespaceURI===Cn?t.createElement(e):t.createElementNS(n,e)}}function _a(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function So(e){var t=Jt(e);return(t.local?_a:ba)(t)}function Ea(){}function Fn(e){return e==null?Ea:function(){return this.querySelector(e)}}function Sa(e){typeof e!="function"&&(e=Fn(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=new Array(s),c,u,f=0;f<s;++f)(c=i[f])&&(u=e.call(c,c.__data__,f,i))&&("__data__"in c&&(u.__data__=c.__data__),a[f]=u);return new ue(r,this._parents)}function Na(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ma(){return[]}function No(e){return e==null?Ma:function(){return this.querySelectorAll(e)}}function Ca(e){return function(){return Na(e.apply(this,arguments))}}function Ia(e){typeof e=="function"?e=Ca(e):e=No(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,u=0;u<a;++u)(c=s[u])&&(r.push(e.call(c,c.__data__,u,s)),o.push(c));return new ue(r,o)}function Mo(e){return function(){return this.matches(e)}}function Co(e){return function(t){return t.matches(e)}}var Aa=Array.prototype.find;function ka(e){return function(){return Aa.call(this.children,e)}}function $a(){return this.firstElementChild}function Pa(e){return this.select(e==null?$a:ka(typeof e=="function"?e:Co(e)))}var Ta=Array.prototype.filter;function za(){return Array.from(this.children)}function Da(e){return function(){return Ta.call(this.children,e)}}function Ha(e){return this.selectAll(e==null?za:Da(typeof e=="function"?e:Co(e)))}function La(e){typeof e!="function"&&(e=Mo(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new ue(r,this._parents)}function Io(e){return new Array(e.length)}function Ra(){return new ue(this._enter||this._groups.map(Io),this._parents)}function Bt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Bt.prototype={constructor:Bt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Va(e){return function(){return e}}function Ba(e,t,n,r,o,i){for(var s=0,a,c=t.length,u=i.length;s<u;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new Bt(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Fa(e,t,n,r,o,i,s){var a,c,u=new Map,f=t.length,d=i.length,l=new Array(f),h;for(a=0;a<f;++a)(c=t[a])&&(l[a]=h=s.call(c,c.__data__,a,t)+"",u.has(h)?o[a]=c:u.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=u.get(h))?(r[a]=c,c.__data__=i[a],u.delete(h)):n[a]=new Bt(e,i[a]);for(a=0;a<f;++a)(c=t[a])&&u.get(l[a])===c&&(o[a]=c)}function Oa(e){return e.__data__}function ja(e,t){if(!arguments.length)return Array.from(this,Oa);var n=t?Fa:Ba,r=this._parents,o=this._groups;typeof e!="function"&&(e=Va(e));for(var i=o.length,s=new Array(i),a=new Array(i),c=new Array(i),u=0;u<i;++u){var f=r[u],d=o[u],l=d.length,h=Xa(e.call(f,f&&f.__data__,u,r)),g=h.length,w=a[u]=new Array(g),x=s[u]=new Array(g),m=c[u]=new Array(l);n(f,d,w,x,m,h,t);for(var b=0,p=0,v,N;b<g;++b)if(v=w[b]){for(b>=p&&(p=b+1);!(N=x[p])&&++p<g;);v._next=N||null}}return s=new ue(s,r),s._enter=a,s._exit=c,s}function Xa(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ya(){return new ue(this._exit||this._groups.map(Io),this._parents)}function Wa(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function qa(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),c=0;c<s;++c)for(var u=n[c],f=r[c],d=u.length,l=a[c]=new Array(d),h,g=0;g<d;++g)(h=u[g]||f[g])&&(l[g]=h);for(;c<o;++c)a[c]=n[c];return new ue(a,this._parents)}function Ga(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Za(e){e||(e=Ua);function t(d,l){return d&&l?e(d.__data__,l.__data__):!d-!l}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],a=s.length,c=o[i]=new Array(a),u,f=0;f<a;++f)(u=s[f])&&(c[f]=u);c.sort(t)}return new ue(o,this._parents).order()}function Ua(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ka(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qa(){return Array.from(this)}function Ja(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function ec(){let e=0;for(const t of this)++e;return e}function tc(){return!this.node()}function nc(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&e.call(a,a.__data__,i,o);return this}function rc(e){return function(){this.removeAttribute(e)}}function oc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ic(e,t){return function(){this.setAttribute(e,t)}}function sc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ac(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function uc(e,t){var n=Jt(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?oc:rc:typeof t=="function"?n.local?cc:ac:n.local?sc:ic)(n,t))}function Ao(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lc(e){return function(){this.style.removeProperty(e)}}function fc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function dc(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hc(e,t,n){return arguments.length>1?this.each((t==null?lc:typeof t=="function"?dc:fc)(e,t,n??"")):Ke(this.node(),e)}function Ke(e,t){return e.style.getPropertyValue(t)||Ao(e).getComputedStyle(e,null).getPropertyValue(t)}function gc(e){return function(){delete this[e]}}function pc(e,t){return function(){this[e]=t}}function mc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yc(e,t){return arguments.length>1?this.each((t==null?gc:typeof t=="function"?mc:pc)(e,t)):this.node()[e]}function ko(e){return e.trim().split(/^|\s+/)}function On(e){return e.classList||new $o(e)}function $o(e){this._node=e,this._names=ko(e.getAttribute("class")||"")}$o.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Po(e,t){for(var n=On(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function To(e,t){for(var n=On(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function xc(e){return function(){Po(this,e)}}function wc(e){return function(){To(this,e)}}function vc(e,t){return function(){(t.apply(this,arguments)?Po:To)(this,e)}}function bc(e,t){var n=ko(e+"");if(arguments.length<2){for(var r=On(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?vc:t?xc:wc)(n,t))}function _c(){this.textContent=""}function Ec(e){return function(){this.textContent=e}}function Sc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Nc(e){return arguments.length?this.each(e==null?_c:(typeof e=="function"?Sc:Ec)(e)):this.node().textContent}function Mc(){this.innerHTML=""}function Cc(e){return function(){this.innerHTML=e}}function Ic(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Ac(e){return arguments.length?this.each(e==null?Mc:(typeof e=="function"?Ic:Cc)(e)):this.node().innerHTML}function kc(){this.nextSibling&&this.parentNode.appendChild(this)}function $c(){return this.each(kc)}function Pc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Tc(){return this.each(Pc)}function zc(e){var t=typeof e=="function"?e:So(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Dc(){return null}function Hc(e,t){var n=typeof e=="function"?e:So(e),r=t==null?Dc:typeof t=="function"?t:Fn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Lc(){var e=this.parentNode;e&&e.removeChild(this)}function Rc(){return this.each(Lc)}function Vc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fc(e){return this.select(e?Bc:Vc)}function Oc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function jc(e){return function(t){e.call(this,t,this.__data__)}}function Xc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Yc(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function Wc(e,t,n){return function(){var r=this.__on,o,i=jc(t);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}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 qc(e,t,n){var r=Xc(e+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,u=a.length,f;c<u;++c)for(o=0,f=a[c];o<i;++o)if((s=r[o]).type===f.type&&s.name===f.name)return f.value}return}for(a=t?Wc:Yc,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function zo(e,t,n){var r=Ao(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Gc(e,t){return function(){return zo(this,e,t)}}function Zc(e,t){return function(){return zo(this,e,t.apply(this,arguments))}}function Uc(e,t){return this.each((typeof t=="function"?Zc:Gc)(e,t))}function*Kc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var Do=[null];function ue(e,t){this._groups=e,this._parents=t}function wt(){return new ue([[document.documentElement]],Do)}function Qc(){return this}ue.prototype=wt.prototype={constructor:ue,select:Sa,selectAll:Ia,selectChild:Pa,selectChildren:Ha,filter:La,data:ja,enter:Ra,exit:Ya,join:Wa,merge:qa,selection:Qc,order:Ga,sort:Za,call:Ka,nodes:Qa,node:Ja,size:ec,empty:tc,each:nc,attr:uc,style:hc,property:yc,classed:bc,text:Nc,html:Ac,raise:$c,lower:Tc,append:zc,insert:Hc,remove:Rc,clone:Fc,datum:Oc,on:qc,dispatch:Uc,[Symbol.iterator]:Kc};function ce(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Do)}function Jc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=Jc(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const eu={passive:!1},lt={capture:!0,passive:!1};function gn(e){e.stopImmediatePropagation()}function Ze(e){e.preventDefault(),e.stopImmediatePropagation()}function Ho(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Ze,lt);"onselectstart"in t?n.on("selectstart.drag",Ze,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lo(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ze,lt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Mt=e=>()=>e;function In(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}In.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tu(e){return!e.ctrlKey&&!e.button}function nu(){return this.parentNode}function ru(e,t){return t??{x:e.x,y:e.y}}function ou(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ro(){var e=tu,t=nu,n=ru,r=ou,o={},i=Qt("start","drag","end"),s=0,a,c,u,f,d=0;function l(v){v.on("mousedown.drag",h).filter(r).on("touchstart.drag",x).on("touchmove.drag",m,eu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,N){if(!(f||!e.call(this,v,N))){var E=p(this,t.call(this,v,N),v,N,"mouse");E&&(ce(v.view).on("mousemove.drag",g,lt).on("mouseup.drag",w,lt),Ho(v.view),gn(v),u=!1,a=v.clientX,c=v.clientY,E("start",v))}}function g(v){if(Ze(v),!u){var N=v.clientX-a,E=v.clientY-c;u=N*N+E*E>d}o.mouse("drag",v)}function w(v){ce(v.view).on("mousemove.drag mouseup.drag",null),Lo(v.view,u),Ze(v),o.mouse("end",v)}function x(v,N){if(e.call(this,v,N)){var E=v.changedTouches,M=t.call(this,v,N),_=E.length,S,B;for(S=0;S<_;++S)(B=p(this,M,v,N,E[S].identifier,E[S]))&&(gn(v),B("start",v,E[S]))}}function m(v){var N=v.changedTouches,E=N.length,M,_;for(M=0;M<E;++M)(_=o[N[M].identifier])&&(Ze(v),_("drag",v,N[M]))}function b(v){var N=v.changedTouches,E=N.length,M,_;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),M=0;M<E;++M)(_=o[N[M].identifier])&&(gn(v),_("end",v,N[M]))}function p(v,N,E,M,_,S){var B=i.copy(),$=de(S||E,N),R,D,y;if((y=n.call(v,new In("beforestart",{sourceEvent:E,target:l,identifier:_,active:s,x:$[0],y:$[1],dx:0,dy:0,dispatch:B}),M))!=null)return R=y.x-$[0]||0,D=y.y-$[1]||0,function C(I,k,z){var A=$,H;switch(I){case"start":o[_]=C,H=s++;break;case"end":delete o[_],--s;case"drag":$=de(z||k,N),H=s;break}B.call(I,v,new In(I,{sourceEvent:k,subject:y,target:l,identifier:_,active:H,x:$[0]+R,y:$[1]+D,dx:$[0]-A[0],dy:$[1]-A[1],dispatch:B}),M)}}return l.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Mt(!!v),l):e},l.container=function(v){return arguments.length?(t=typeof v=="function"?v:Mt(v),l):t},l.subject=function(v){return arguments.length?(n=typeof v=="function"?v:Mt(v),l):n},l.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:Mt(!!v),l):r},l.on=function(){var v=i.on.apply(i,arguments);return v===i?l:v},l.clickDistance=function(v){return arguments.length?(d=(v=+v)*v,l):Math.sqrt(d)},l}function jn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Vo(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function vt(){}var ft=.7,Ft=1/ft,Ue="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",iu=/^#([0-9a-f]{3,8})$/,su=new RegExp(`^rgb\\(${Ue},${Ue},${Ue}\\)$`),au=new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`),cu=new RegExp(`^rgba\\(${Ue},${Ue},${Ue},${dt}\\)$`),uu=new RegExp(`^rgba\\(${_e},${_e},${_e},${dt}\\)$`),lu=new RegExp(`^hsl\\(${dt},${_e},${_e}\\)$`),fu=new RegExp(`^hsla\\(${dt},${_e},${_e},${dt}\\)$`),pr={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};jn(vt,Oe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:mr,formatHex:mr,formatHex8:du,formatHsl:hu,formatRgb:yr,toString:yr});function mr(){return this.rgb().formatHex()}function du(){return this.rgb().formatHex8()}function hu(){return Bo(this).formatHsl()}function yr(){return this.rgb().formatRgb()}function Oe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=iu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?xr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Ct(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Ct(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=su.exec(e))?new ae(t[1],t[2],t[3],1):(t=au.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=cu.exec(e))?Ct(t[1],t[2],t[3],t[4]):(t=uu.exec(e))?Ct(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lu.exec(e))?br(t[1],t[2]/100,t[3]/100,1):(t=fu.exec(e))?br(t[1],t[2]/100,t[3]/100,t[4]):pr.hasOwnProperty(e)?xr(pr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function xr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Ct(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function gu(e){return e instanceof vt||(e=Oe(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function An(e,t,n,r){return arguments.length===1?gu(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}jn(ae,An,Vo(vt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Be(this.r),Be(this.g),Be(this.b),Ot(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:wr,formatHex:wr,formatHex8:pu,formatRgb:vr,toString:vr}));function wr(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function pu(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function vr(){const e=Ot(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Ot(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Be(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Be(e),(e<16?"0":"")+e.toString(16)}function br(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,n,r)}function Bo(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof vt||(e=Oe(e)),!e)return new he;if(e instanceof he)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,a=i-o,c=(i+o)/2;return a?(t===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+o:2-i-o,s*=60):a=c>0&&c<1?0:s,new he(s,a,c,e.opacity)}function mu(e,t,n,r){return arguments.length===1?Bo(e):new he(e,t,n,r??1)}function he(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}jn(he,mu,Vo(vt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,e),new he(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new ae(pn(e>=240?e-240:e+120,o,r),pn(e,o,r),pn(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(_r(this.h),It(this.s),It(this.l),Ot(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=Ot(this.opacity);return`${e===1?"hsl(":"hsla("}${_r(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _r(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function pn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Xn=e=>()=>e;function yu(e,t){return function(n){return e+n*t}}function xu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function wu(e){return(e=+e)==1?Fo:function(t,n){return n-t?xu(t,n,e):Xn(isNaN(t)?n:t)}}function Fo(e,t){var n=t-e;return n?yu(e,n):Xn(isNaN(e)?t:e)}const jt=(function e(t){var n=wu(t);function r(o,i){var s=n((o=An(o)).r,(i=An(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),u=Fo(o.opacity,i.opacity);return function(f){return o.r=s(f),o.g=a(f),o.b=c(f),o.opacity=u(f),o+""}}return r.gamma=e,r})(1);function vu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function bu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function _u(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=ct(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function Eu(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function be(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Su(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=ct(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var kn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(kn.source,"g");function Nu(e){return function(){return e}}function Mu(e){return function(t){return e(t)+""}}function Oo(e,t){var n=kn.lastIndex=mn.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=kn.exec(e))&&(o=mn.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(r=r[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,c.push({i:s,x:be(r,o)})),n=mn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?Mu(c[0].x):Nu(t):(t=c.length,function(u){for(var f=0,d;f<t;++f)a[(d=c[f]).i]=d.x(u);return a.join("")})}function ct(e,t){var n=typeof t,r;return t==null||n==="boolean"?Xn(t):(n==="number"?be:n==="string"?(r=Oe(t))?(t=r,jt):Oo:t instanceof Oe?jt:t instanceof Date?Eu:bu(t)?vu:Array.isArray(t)?_u:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Su:be)(e,t)}var Er=180/Math.PI,$n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function jo(e,t,n,r,o,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*Er,skewX:Math.atan(c)*Er,scaleX:s,scaleY:a}}var At;function Cu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$n:jo(t.a,t.b,t.c,t.d,t.e,t.f)}function Iu(e){return e==null||(At||(At=document.createElementNS("http://www.w3.org/2000/svg","g")),At.setAttribute("transform",e),!(e=At.transform.baseVal.consolidate()))?$n:(e=e.matrix,jo(e.a,e.b,e.c,e.d,e.e,e.f))}function Xo(e,t,n,r){function o(u){return u.length?u.pop()+" ":""}function i(u,f,d,l,h,g){if(u!==d||f!==l){var w=h.push("translate(",null,t,null,n);g.push({i:w-4,x:be(u,d)},{i:w-2,x:be(f,l)})}else(d||l)&&h.push("translate("+d+t+l+n)}function s(u,f,d,l){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),l.push({i:d.push(o(d)+"rotate(",null,r)-2,x:be(u,f)})):f&&d.push(o(d)+"rotate("+f+r)}function a(u,f,d,l){u!==f?l.push({i:d.push(o(d)+"skewX(",null,r)-2,x:be(u,f)}):f&&d.push(o(d)+"skewX("+f+r)}function c(u,f,d,l,h,g){if(u!==d||f!==l){var w=h.push(o(h)+"scale(",null,",",null,")");g.push({i:w-4,x:be(u,d)},{i:w-2,x:be(f,l)})}else(d!==1||l!==1)&&h.push(o(h)+"scale("+d+","+l+")")}return function(u,f){var d=[],l=[];return u=e(u),f=e(f),i(u.translateX,u.translateY,f.translateX,f.translateY,d,l),s(u.rotate,f.rotate,d,l),a(u.skewX,f.skewX,d,l),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,d,l),u=f=null,function(h){for(var g=-1,w=l.length,x;++g<w;)d[(x=l[g]).i]=x.x(h);return d.join("")}}}var Au=Xo(Cu,"px, ","px)","deg)"),ku=Xo(Iu,", ",")",")"),$u=1e-12;function Sr(e){return((e=Math.exp(e))+1/e)/2}function Pu(e){return((e=Math.exp(e))-1/e)/2}function Tu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ht=(function e(t,n,r){function o(i,s){var a=i[0],c=i[1],u=i[2],f=s[0],d=s[1],l=s[2],h=f-a,g=d-c,w=h*h+g*g,x,m;if(w<$u)m=Math.log(l/u)/t,x=function(M){return[a+M*h,c+M*g,u*Math.exp(t*M*m)]};else{var b=Math.sqrt(w),p=(l*l-u*u+r*w)/(2*u*n*b),v=(l*l-u*u-r*w)/(2*l*n*b),N=Math.log(Math.sqrt(p*p+1)-p),E=Math.log(Math.sqrt(v*v+1)-v);m=(E-N)/t,x=function(M){var _=M*m,S=Sr(N),B=u/(n*b)*(S*Tu(t*_+N)-Pu(N));return[a+B*h,c+B*g,u*S/Sr(t*_+N)]}}return x.duration=m*1e3*t/Math.SQRT2,x}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},o})(Math.SQRT2,2,4);var Qe=0,st=0,ot=0,Yo=1e3,Xt,at,Yt=0,je=0,en=0,ht=typeof performance=="object"&&performance.now?performance:Date,Wo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yn(){return je||(Wo(zu),je=ht.now()+en)}function zu(){je=0}function Wt(){this._call=this._time=this._next=null}Wt.prototype=qo.prototype={constructor:Wt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Yn():+n)+(t==null?0:+t),!this._next&&at!==this&&(at?at._next=this:Xt=this,at=this),this._call=e,this._time=n,Pn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Pn())}};function qo(e,t,n){var r=new Wt;return r.restart(e,t,n),r}function Du(){Yn(),++Qe;for(var e=Xt,t;e;)(t=je-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qe}function Nr(){je=(Yt=ht.now())+en,Qe=st=0;try{Du()}finally{Qe=0,Lu(),je=0}}function Hu(){var e=ht.now(),t=e-Yt;t>Yo&&(en-=t,Yt=e)}function Lu(){for(var e,t=Xt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Xt=n);at=e,Pn(r)}function Pn(e){if(!Qe){st&&(st=clearTimeout(st));var t=e-je;t>24?(e<1/0&&(st=setTimeout(Nr,e-ht.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Yt=ht.now(),ot=setInterval(Hu,Yo)),Qe=1,Wo(Nr))}}function Mr(e,t,n){var r=new Wt;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Ru=Qt("start","end","cancel","interrupt"),Vu=[],Go=0,Cr=1,Tn=2,Lt=3,Ir=4,zn=5,Rt=6;function tn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Bu(e,n,{name:t,index:r,group:o,on:Ru,tween:Vu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Go})}function Wn(e,t){var n=ye(e,t);if(n.state>Go)throw new Error("too late; already scheduled");return n}function Ee(e,t){var n=ye(e,t);if(n.state>Lt)throw new Error("too late; already running");return n}function ye(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Bu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=qo(i,0,n.time);function i(u){n.state=Cr,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var f,d,l,h;if(n.state!==Cr)return c();for(f in r)if(h=r[f],h.name===n.name){if(h.state===Lt)return Mr(s);h.state===Ir?(h.state=Rt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[f]):+f<t&&(h.state=Rt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[f])}if(Mr(function(){n.state===Lt&&(n.state=Ir,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=Tn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tn){for(n.state=Lt,o=new Array(l=n.tween.length),f=0,d=-1;f<l;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=h);o.length=d+1}}function a(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=zn,1),d=-1,l=o.length;++d<l;)o[d].call(e,f);n.state===zn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Rt,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function Vt(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Tn&&r.state<zn,r.state=Rt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Fu(e){return this.each(function(){Vt(this,e)})}function Ou(e,t){var n,r;return function(){var o=Ee(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function ju(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Ee(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:t,value:n},c=0,u=o.length;c<u;++c)if(o[c].name===t){o[c]=a;break}c===u&&o.push(a)}i.tween=o}}function Xu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ye(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?Ou:ju)(n,e,t))}function qn(e,t,n){var r=e._id;return e.each(function(){var o=Ee(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ye(o,r).value[t]}}function Zo(e,t){var n;return(typeof t=="number"?be:t instanceof Oe?jt:(n=Oe(t))?(t=n,jt):Oo)(e,t)}function Yu(e){return function(){this.removeAttribute(e)}}function Wu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qu(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function Gu(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function Zu(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Uu(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Ku(e,t){var n=Jt(e),r=n==="transform"?ku:Zo;return this.attrTween(e,typeof t=="function"?(n.local?Uu:Zu)(n,r,qn(this,"attr."+e,t)):t==null?(n.local?Wu:Yu)(n):(n.local?Gu:qu)(n,r,t))}function Qu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Ju(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function el(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Ju(e,i)),n}return o._value=t,o}function tl(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Qu(e,i)),n}return o._value=t,o}function nl(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Jt(e);return this.tween(n,(r.local?el:tl)(r,t))}function rl(e,t){return function(){Wn(this,e).delay=+t.apply(this,arguments)}}function ol(e,t){return t=+t,function(){Wn(this,e).delay=t}}function il(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rl:ol)(t,e)):ye(this.node(),t).delay}function sl(e,t){return function(){Ee(this,e).duration=+t.apply(this,arguments)}}function al(e,t){return t=+t,function(){Ee(this,e).duration=t}}function cl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sl:al)(t,e)):ye(this.node(),t).duration}function ul(e,t){if(typeof t!="function")throw new Error;return function(){Ee(this,e).ease=t}}function ll(e){var t=this._id;return arguments.length?this.each(ul(t,e)):ye(this.node(),t).ease}function fl(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ee(this,e).ease=n}}function dl(e){if(typeof e!="function")throw new Error;return this.each(fl(this._id,e))}function hl(e){typeof e!="function"&&(e=Mo(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new Ae(r,this._parents,this._name,this._id)}function gl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var c=t[a],u=n[a],f=c.length,d=s[a]=new Array(f),l,h=0;h<f;++h)(l=c[h]||u[h])&&(d[h]=l);for(;a<r;++a)s[a]=t[a];return new Ae(s,this._parents,this._name,this._id)}function pl(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function ml(e,t,n){var r,o,i=pl(t)?Wn:Ee;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function yl(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(ml(n,e,t))}function xl(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function wl(){return this.on("end.remove",xl(this._id))}function vl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fn(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],c=a.length,u=i[s]=new Array(c),f,d,l=0;l<c;++l)(f=a[l])&&(d=e.call(f,f.__data__,l,a))&&("__data__"in f&&(d.__data__=f.__data__),u[l]=d,tn(u[l],t,n,l,u,ye(f,n)));return new Ae(i,this._parents,t,n)}function bl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=No(e));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var c=r[a],u=c.length,f,d=0;d<u;++d)if(f=c[d]){for(var l=e.call(f,f.__data__,d,c),h,g=ye(f,n),w=0,x=l.length;w<x;++w)(h=l[w])&&tn(h,t,n,w,l,g);i.push(l),s.push(f)}return new Ae(i,s,t,n)}var _l=wt.prototype.constructor;function El(){return new _l(this._groups,this._parents)}function Sl(e,t){var n,r,o;return function(){var i=Ke(this,e),s=(this.style.removeProperty(e),Ke(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Uo(e){return function(){this.style.removeProperty(e)}}function Nl(e,t,n){var r,o=n+"",i;return function(){var s=Ke(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function Ml(e,t,n){var r,o,i;return function(){var s=Ke(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),Ke(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function Cl(e,t){var n,r,o,i="style."+t,s="end."+i,a;return function(){var c=Ee(this,e),u=c.on,f=c.value[i]==null?a||(a=Uo(t)):void 0;(u!==n||o!==f)&&(r=(n=u).copy()).on(s,o=f),c.on=r}}function Il(e,t,n){var r=(e+="")=="transform"?Au:Zo;return t==null?this.styleTween(e,Sl(e,r)).on("end.style."+e,Uo(e)):typeof t=="function"?this.styleTween(e,Ml(e,r,qn(this,"style."+e,t))).each(Cl(this._id,e)):this.styleTween(e,Nl(e,r,t),n).on("end.style."+e,null)}function Al(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function kl(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&Al(e,s,n)),r}return i._value=t,i}function $l(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,kl(e,t,n??""))}function Pl(e){return function(){this.textContent=e}}function Tl(e){return function(){var t=e(this);this.textContent=t??""}}function zl(e){return this.tween("text",typeof e=="function"?Tl(qn(this,"text",e)):Pl(e==null?"":e+""))}function Dl(e){return function(t){this.textContent=e.call(this,t)}}function Hl(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Dl(o)),t}return r._value=e,r}function Ll(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Hl(e))}function Rl(){for(var e=this._name,t=this._id,n=Ko(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,u=0;u<a;++u)if(c=s[u]){var f=ye(c,t);tn(c,e,n,u,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Ae(r,this._parents,e,n)}function Vl(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--o===0&&i()}};n.each(function(){var u=Ee(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),u.on=t}),o===0&&i()})}var Bl=0;function Ae(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ko(){return++Bl}var Ce=wt.prototype;Ae.prototype={constructor:Ae,select:vl,selectAll:bl,selectChild:Ce.selectChild,selectChildren:Ce.selectChildren,filter:hl,merge:gl,selection:El,transition:Rl,call:Ce.call,nodes:Ce.nodes,node:Ce.node,size:Ce.size,empty:Ce.empty,each:Ce.each,on:yl,attr:Ku,attrTween:nl,style:Il,styleTween:$l,text:zl,textTween:Ll,remove:wl,tween:Xu,delay:il,duration:cl,ease:ll,easeVarying:dl,end:Vl,[Symbol.iterator]:Ce[Symbol.iterator]};function Fl(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ol={time:null,delay:0,duration:250,ease:Fl};function jl(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Xl(e){var t,n;e instanceof Ae?(t=e._id,e=e._name):(t=Ko(),(n=Ol).time=Yn(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,u=0;u<a;++u)(c=s[u])&&tn(c,e,t,u,s,n||jl(c,t));return new Ae(r,this._parents,e,t)}wt.prototype.interrupt=Fu;wt.prototype.transition=Xl;const kt=e=>()=>e;function Yl(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Ie(e,t,n){this.k=e,this.x=t,this.y=n}Ie.prototype={constructor:Ie,scale:function(e){return e===1?this:new Ie(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ie(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 nn=new Ie(1,0,0);Qo.prototype=Ie.prototype;function Qo(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function yn(e){e.stopImmediatePropagation()}function it(e){e.preventDefault(),e.stopImmediatePropagation()}function Wl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function ql(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ar(){return this.__zoom||nn}function Gl(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Zl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ul(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Jo(){var e=Wl,t=ql,n=Ul,r=Gl,o=Zl,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Ht,u=Qt("start","zoom","end"),f,d,l,h=500,g=150,w=0,x=10;function m(y){y.property("__zoom",Ar).on("wheel.zoom",_,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",B).filter(o).on("touchstart.zoom",$).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,C,I,k){var z=y.selection?y.selection():y;z.property("__zoom",Ar),y!==z?N(y,C,I,k):z.interrupt().each(function(){E(this,arguments).event(k).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},m.scaleBy=function(y,C,I,k){m.scaleTo(y,function(){var z=this.__zoom.k,A=typeof C=="function"?C.apply(this,arguments):C;return z*A},I,k)},m.scaleTo=function(y,C,I,k){m.transform(y,function(){var z=t.apply(this,arguments),A=this.__zoom,H=I==null?v(z):typeof I=="function"?I.apply(this,arguments):I,F=A.invert(H),V=typeof C=="function"?C.apply(this,arguments):C;return n(p(b(A,V),H,F),z,s)},I,k)},m.translateBy=function(y,C,I,k){m.transform(y,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),s)},null,k)},m.translateTo=function(y,C,I,k,z){m.transform(y,function(){var A=t.apply(this,arguments),H=this.__zoom,F=k==null?v(A):typeof k=="function"?k.apply(this,arguments):k;return n(nn.translate(F[0],F[1]).scale(H.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof I=="function"?-I.apply(this,arguments):-I),A,s)},k,z)};function b(y,C){return C=Math.max(i[0],Math.min(i[1],C)),C===y.k?y:new Ie(C,y.x,y.y)}function p(y,C,I){var k=C[0]-I[0]*y.k,z=C[1]-I[1]*y.k;return k===y.x&&z===y.y?y:new Ie(y.k,k,z)}function v(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function N(y,C,I,k){y.on("start.zoom",function(){E(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(k).end()}).tween("zoom",function(){var z=this,A=arguments,H=E(z,A).event(k),F=t.apply(z,A),V=I==null?v(F):typeof I=="function"?I.apply(z,A):I,j=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),X=z.__zoom,G=typeof C=="function"?C.apply(z,A):C,J=c(X.invert(V).concat(j/X.k),G.invert(V).concat(j/G.k));return function(q){if(q===1)q=G;else{var L=J(q),O=j/L[2];q=new Ie(O,V[0]-L[0]*O,V[1]-L[1]*O)}H.zoom(null,q)}})}function E(y,C,I){return!I&&y.__zooming||new M(y,C)}function M(y,C){this.that=y,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,C),this.taps=0}M.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,C){return this.mouse&&y!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var C=ce(this.that).datum();u.call(y,this.that,new Yl(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:u}),C)}};function _(y,...C){if(!e.apply(this,arguments))return;var I=E(this,C).event(y),k=this.__zoom,z=Math.max(i[0],Math.min(i[1],k.k*Math.pow(2,r.apply(this,arguments)))),A=de(y);if(I.wheel)(I.mouse[0][0]!==A[0]||I.mouse[0][1]!==A[1])&&(I.mouse[1]=k.invert(I.mouse[0]=A)),clearTimeout(I.wheel);else{if(k.k===z)return;I.mouse=[A,k.invert(A)],Vt(this),I.start()}it(y),I.wheel=setTimeout(H,g),I.zoom("mouse",n(p(b(k,z),I.mouse[0],I.mouse[1]),I.extent,s));function H(){I.wheel=null,I.end()}}function S(y,...C){if(l||!e.apply(this,arguments))return;var I=y.currentTarget,k=E(this,C,!0).event(y),z=ce(y.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",j,!0),A=de(y,I),H=y.clientX,F=y.clientY;Ho(y.view),yn(y),k.mouse=[A,this.__zoom.invert(A)],Vt(this),k.start();function V(X){if(it(X),!k.moved){var G=X.clientX-H,J=X.clientY-F;k.moved=G*G+J*J>w}k.event(X).zoom("mouse",n(p(k.that.__zoom,k.mouse[0]=de(X,I),k.mouse[1]),k.extent,s))}function j(X){z.on("mousemove.zoom mouseup.zoom",null),Lo(X.view,k.moved),it(X),k.event(X).end()}}function B(y,...C){if(e.apply(this,arguments)){var I=this.__zoom,k=de(y.changedTouches?y.changedTouches[0]:y,this),z=I.invert(k),A=I.k*(y.shiftKey?.5:2),H=n(p(b(I,A),k,z),t.apply(this,C),s);it(y),a>0?ce(this).transition().duration(a).call(N,H,k,y):ce(this).call(m.transform,H,k,y)}}function $(y,...C){if(e.apply(this,arguments)){var I=y.touches,k=I.length,z=E(this,C,y.changedTouches.length===k).event(y),A,H,F,V;for(yn(y),H=0;H<k;++H)F=I[H],V=de(F,this),V=[V,this.__zoom.invert(V),F.identifier],z.touch0?!z.touch1&&z.touch0[2]!==V[2]&&(z.touch1=V,z.taps=0):(z.touch0=V,A=!0,z.taps=1+!!f);f&&(f=clearTimeout(f)),A&&(z.taps<2&&(d=V[0],f=setTimeout(function(){f=null},h)),Vt(this),z.start())}}function R(y,...C){if(this.__zooming){var I=E(this,C).event(y),k=y.changedTouches,z=k.length,A,H,F,V;for(it(y),A=0;A<z;++A)H=k[A],F=de(H,this),I.touch0&&I.touch0[2]===H.identifier?I.touch0[0]=F:I.touch1&&I.touch1[2]===H.identifier&&(I.touch1[0]=F);if(H=I.that.__zoom,I.touch1){var j=I.touch0[0],X=I.touch0[1],G=I.touch1[0],J=I.touch1[1],q=(q=G[0]-j[0])*q+(q=G[1]-j[1])*q,L=(L=J[0]-X[0])*L+(L=J[1]-X[1])*L;H=b(H,Math.sqrt(q/L)),F=[(j[0]+G[0])/2,(j[1]+G[1])/2],V=[(X[0]+J[0])/2,(X[1]+J[1])/2]}else if(I.touch0)F=I.touch0[0],V=I.touch0[1];else return;I.zoom("touch",n(p(H,F,V),I.extent,s))}}function D(y,...C){if(this.__zooming){var I=E(this,C).event(y),k=y.changedTouches,z=k.length,A,H;for(yn(y),l&&clearTimeout(l),l=setTimeout(function(){l=null},h),A=0;A<z;++A)H=k[A],I.touch0&&I.touch0[2]===H.identifier?delete I.touch0:I.touch1&&I.touch1[2]===H.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(H=de(H,this),Math.hypot(d[0]-H[0],d[1]-H[1])<x)){var F=ce(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return m.wheelDelta=function(y){return arguments.length?(r=typeof y=="function"?y:kt(+y),m):r},m.filter=function(y){return arguments.length?(e=typeof y=="function"?y:kt(!!y),m):e},m.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:kt(!!y),m):o},m.extent=function(y){return arguments.length?(t=typeof y=="function"?y:kt([[+y[0][0],+y[0][1]],[+y[1][0],+y[1][1]]]),m):t},m.scaleExtent=function(y){return arguments.length?(i[0]=+y[0],i[1]=+y[1],m):[i[0],i[1]]},m.translateExtent=function(y){return arguments.length?(s[0][0]=+y[0][0],s[1][0]=+y[1][0],s[0][1]=+y[0][1],s[1][1]=+y[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(y){return arguments.length?(n=y,m):n},m.duration=function(y){return arguments.length?(a=+y,m):a},m.interpolate=function(y){return arguments.length?(c=y,m):c},m.on=function(){var y=u.on.apply(u,arguments);return y===u?m:y},m.clickDistance=function(y){return arguments.length?(w=(y=+y)*y,m):Math.sqrt(w)},m.tapDistance=function(y){return arguments.length?(x=+y,m):x},m}const me={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},gt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ei=["Enter"," ","Escape"],ti={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Je;(function(e){e.Strict="strict",e.Loose="loose"})(Je||(Je={}));var Fe;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Fe||(Fe={}));var pt;(function(e){e.Partial="partial",e.Full="full"})(pt||(pt={}));const ni={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Te;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Te||(Te={}));var qt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qt||(qt={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const kr={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},ri=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Kl=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gn=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),bt=(e,t=[0,0])=>{const{width:n,height:r}=xe(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},Ql=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((o,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):Gn(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,rn(o,Gt(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?on(r):{x:0,y:0,width:0,height:0}},_t=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=rn(n,Gt(o)),r=!0)}),r?on(n):{x:0,y:0,width:0,height:0}},Zn=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/o,c=(t.y-r)/o,u=t.width/o,f=t.height/o,d=[];for(const l of e.values()){const{measured:h,selectable:g=!0,hidden:w=!1}=l;if(s&&!g||w)continue;const x=h.width??l.width??l.initialWidth??0,m=h.height??l.height??l.initialHeight??0,{x:b,y:p}=l.internals.positionAbsolute,v=ai(a,c,u,f,b,p,x,m),N=x*m,E=i&&v>0;(!l.internals.handleBounds||E||v>=N||l.dragging)&&d.push(l)}return d},Jl=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function ef(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let i;if(t!=null&&t.includeHiddenNodes){const{width:s,height:a}=xe(o);i=s>0&&a>0}else i=!!(o.measured.width&&o.measured.height&&!o.hidden);i&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function tf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=ef(e,s),c=_t(a),u=Kn(c,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0}function oi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},f=s.origin??r;let d=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",me.error005());else{const{width:h,height:g}=xe(a);h&&g&&(d=[[c,u],[c+h,u+g]])}else a&&Ye(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const l=Ye(d)?Xe(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",me.error015())),{position:{x:l.x-c+(s.measured.width??0)*f[0],y:l.y-u+(s.measured.height??0)*f[1]},positionAbsolute:l}}async function nf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(l=>l.id)),s=[];for(const l of n){if(l.deletable===!1)continue;const h=i.has(l.id),g=!h&&l.parentId&&s.find(w=>w.id===l.parentId);(h||g)&&s.push(l)}const a=new Set(t.map(l=>l.id)),c=r.filter(l=>l.deletable!==!1),f=Jl(s,c);for(const l of c)a.has(l.id)&&!f.find(g=>g.id===l.id)&&f.push(l);if(!o)return{edges:f,nodes:s};const d=await o({nodes:s,edges:f});return typeof d=="boolean"?d?{edges:f,nodes:s}:{edges:[],nodes:[]}:d}const et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Xe=(e={x:0,y:0},t,n)=>({x:et(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:et(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ii(e,t,n){const{width:r,height:o}=xe(n),{x:i,y:s}=n.internals.positionAbsolute;return Xe(e,[[i,s],[i+r,s+o]],t)}const $r=(e,t,n)=>e<t?et(Math.abs(e-t),1,t)/t:e>n?-et(Math.abs(e-n),1,t)/t:0,Un=(e,t,n=15,r=40)=>{const o=$r(e.x,r,t.width-r)*n,i=$r(e.y,r,t.height-r)*n;return[o,i]},rn=(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)}),Dn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),on=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),mt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Gn(e)?e.internals.positionAbsolute:bt(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Gt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Gn(e)?e.internals.positionAbsolute:bt(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},si=(e,t)=>on(rn(Dn(e),Dn(t))),ai=(e,t,n,r,o,i,s,a)=>{const c=Math.max(0,Math.min(e+n,o+s)-Math.max(e,o)),u=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(c*u)},Zt=(e,t)=>ai(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Pr=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ci=(e,t)=>(n,r)=>{},Et=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),St=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?Et(a,s):a},tt=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function qe(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function rf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=qe(e,n),o=qe(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=qe(e.top??e.y??0,n),o=qe(e.bottom??e.y??0,n),i=qe(e.left??e.x??0,t),s=qe(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function of(e,t,n,r,o,i){const{x:s,y:a}=tt(e,[t,n,r]),{x:c,y:u}=tt({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=o-c,d=i-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(d)}}const Kn=(e,t,n,r,o,i)=>{const s=rf(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),f=et(u,r,o),d=e.x+e.width/2,l=e.y+e.height/2,h=t/2-d*f,g=n/2-l*f,w=of(e,h,g,f,t,n),x={left:Math.min(w.left-s.left,0),top:Math.min(w.top-s.top,0),right:Math.min(w.right-s.right,0),bottom:Math.min(w.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:f}},yt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ye(e){return e!=null&&e!=="parent"}function xe(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function ui(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function li(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Tr(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function sf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function af(e){return{...ti,...e||{}}}function fi(e){return e===null?null:e?"valid":"invalid"}function ut(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=St({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:u}=n?Et(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const Qn=e=>({width:e.offsetWidth,height:e.offsetHeight}),di=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},cf=["INPUT","SELECT","TEXTAREA"];function hi(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:cf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const gi=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=gi(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},zr=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Qn(s)}})};function pi({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+o*.375+s*.375+n*.125,u=t*.125+i*.375+a*.375+r*.125,f=Math.abs(c-e),d=Math.abs(u-t);return[c,u,f,d]}function $t(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Dr({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-$t(t-r,i),n];case W.Right:return[t+$t(r-t,i),n];case W.Top:return[t,n-$t(n-o,i)];case W.Bottom:return[t,n+$t(o-n,i)]}}function mi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=Dr({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[u,f]=Dr({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,l,h,g]=pi({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${a},${c} ${u},${f} ${r},${o}`,d,l,h,g]}function yi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,a=r<t?r+s:r-s;return[i,a,o,s]}function uf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,a=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+a}function lf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=rn(Gt(e),Gt(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return Zt(s,on(i))>0}const ff=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,df=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),hf=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",me.error006()),t;const r=n.getEdgeId||ff;let o;return ri(e)?o={...e}:o={...e,id:r(e)},df(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function xi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=yi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const Hr={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},gf=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Lr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function pf({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=Hr[t],c=Hr[r],u={x:e.x+a.x*i,y:e.y+a.y*i},f={x:n.x+c.x*i,y:n.y+c.y*i},d=gf({source:u,sourcePosition:t,target:f}),l=d.x!==0?"x":"y",h=d[l];let g=[],w,x;const m={x:0,y:0},b={x:0,y:0},[,,p,v]=yi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[l]*c[l]===-1){l==="x"?(w=o.x??u.x+(f.x-u.x)*s,x=o.y??(u.y+f.y)/2):(w=o.x??(u.x+f.x)/2,x=o.y??u.y+(f.y-u.y)*s);const _=[{x:w,y:u.y},{x:w,y:f.y}],S=[{x:u.x,y:x},{x:f.x,y:x}];a[l]===h?g=l==="x"?_:S:g=l==="x"?S:_}else{const _=[{x:u.x,y:f.y}],S=[{x:f.x,y:u.y}];if(l==="x"?g=a.x===h?S:_:g=a.y===h?_:S,t===r){const y=Math.abs(e[l]-n[l]);if(y<=i){const C=Math.min(i-1,i-y);a[l]===h?m[l]=(u[l]>e[l]?-1:1)*C:b[l]=(f[l]>n[l]?-1:1)*C}}if(t!==r){const y=l==="x"?"y":"x",C=a[l]===c[y],I=u[y]>f[y],k=u[y]<f[y];(a[l]===1&&(!C&&I||C&&k)||a[l]!==1&&(!C&&k||C&&I))&&(g=l==="x"?_:S)}const B={x:u.x+m.x,y:u.y+m.y},$={x:f.x+b.x,y:f.y+b.y},R=Math.max(Math.abs(B.x-g[0].x),Math.abs($.x-g[0].x)),D=Math.max(Math.abs(B.y-g[0].y),Math.abs($.y-g[0].y));R>=D?(w=(B.x+$.x)/2,x=g[0].y):(w=g[0].x,x=(B.y+$.y)/2)}const N={x:u.x+m.x,y:u.y+m.y},E={x:f.x+b.x,y:f.y+b.y};return[[e,...N.x!==g[0].x||N.y!==g[0].y?[N]:[],...g,...E.x!==g[g.length-1].x||E.y!==g[g.length-1].y?[E]:[],n],w,x,p,v]}function mf(e,t,n,r){const o=Math.min(Lr(e,t)/2,Lr(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+o*u},${s}Q ${i},${s} ${i},${s+o*f}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+o*c}Q ${i},${s} ${i+o*a},${s}`}function Hn({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:f=.5}){const[d,l,h,g,w]=pf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:u,stepPosition:f});let x=`M${d[0].x} ${d[0].y}`;for(let m=1;m<d.length-1;m++)x+=mf(d[m-1],d[m],d[m+1],s);return x+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[x,l,h,g,w]}function Rr(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function yf(e){var d;const{sourceNode:t,targetNode:n}=e;if(!Rr(t)||!Rr(n))return null;const r=t.internals.handleBounds||Vr(t.handles),o=n.internals.handleBounds||Vr(n.handles),i=Br((r==null?void 0:r.source)??[],e.sourceHandle),s=Br(e.connectionMode===Je.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(d=e.onError)==null||d.call(e,"008",me.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||W.Bottom,c=(s==null?void 0:s.position)||W.Top,u=We(t,i,a),f=We(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:c}}function Vr(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function We(e,t,n=W.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??xe(e);if(r)return{x:o+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:o+s/2,y:i};case W.Right:return{x:o+s,y:i+a/2};case W.Bottom:return{x:o+s/2,y:i+a};case W.Left:return{x:o,y:i+a/2}}}function Br(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ln(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function xf(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const u=Ln(c,t);i.has(u)||(s.push({id:u,color:c.color||n,...c}),i.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const wi=1e3,wf=10,Jn={nodeOrigin:[0,0],nodeExtent:gt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},vf={...Jn,checkEquality:!0};function er(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function bf(e,t,n){const r=er(Jn,n);for(const o of e.values())if(o.parentId)nr(o,e,t,r);else{const i=bt(o,r.nodeOrigin),s=Ye(o.extent)?o.extent:r.nodeExtent,a=Xe(i,s,xe(o));o.internals.positionAbsolute=a}}function _f(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function tr(e){return e==="manual"}function Rn(e,t,n,r={}){var f,d;const o=er(vf,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!tr(o.zIndexMode)?wi:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const l of e){let h=s.get(l.id);if(o.checkEquality&&l===(h==null?void 0:h.internals.userNode))t.set(l.id,h);else{const g=bt(l,o.nodeOrigin),w=Ye(l.extent)?l.extent:o.nodeExtent,x=Xe(g,w,xe(l));h={...o.defaults,...l,measured:{width:(f=l.measured)==null?void 0:f.width,height:(d=l.measured)==null?void 0:d.height},internals:{positionAbsolute:x,handleBounds:_f(l,h),z:vi(l,a,o.zIndexMode),userNode:l}},t.set(l.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),l.parentId&&nr(h,t,n,r,i),u||(u=l.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function Ef(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function nr(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=er(Jn,r),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ef(e,n),o&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++o.i,f.internals.z=f.internals.z+o.i*wf),o&&f.internals.rootParentIndex!==void 0&&(o.i=f.internals.rootParentIndex);const d=i&&!tr(c)?wi:0,{x:l,y:h,z:g}=Sf(e,f,s,a,d,c),{positionAbsolute:w}=e.internals,x=l!==w.x||h!==w.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:l,y:h}:w,z:g}})}function vi(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return tr(n)?r:r+(e.selected?t:0)}function Sf(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),u=bt(e,n),f=Ye(e.extent)?Xe(u,e.extent,c):u;let d=Xe({x:s+f.x,y:a+f.y},r,c);e.extent==="parent"&&(d=ii(d,c,t));const l=vi(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=l?h+1:l}}function rr(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??mt(c),f=si(u,a.rect);i.set(a.parentId,{expandedRect:f,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},u)=>{var p;const f=c.internals.positionAbsolute,d=xe(c),l=c.origin??r,h=a.x<f.x?Math.round(Math.abs(f.x-a.x)):0,g=a.y<f.y?Math.round(Math.abs(f.y-a.y)):0,w=Math.max(d.width,Math.round(a.width)),x=Math.max(d.height,Math.round(a.height)),m=(w-d.width)*l[0],b=(x-d.height)*l[1];(h>0||g>0||m||b)&&(o.push({id:u,type:"position",position:{x:c.position.x-h+m,y:c.position.y-g+b}}),(p=n.get(u))==null||p.forEach(v=>{e.some(N=>N.id===v.id)||o.push({id:v.id,type:"position",position:{x:v.position.x+h,y:v.position.y+g}})})),(d.width<a.width||d.height<a.height||h||g)&&o.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:w+(h?l[0]*h-m:0),height:x+(g?l[1]*g-b:0)}})}),o}function Nf(e,t,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const u=[],f=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(f.transform),l=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const w=Qn(h.nodeElement),x=g.measured.width!==w.width||g.measured.height!==w.height;if(!!(w.width&&w.height&&(x||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ye(g.extent)?g.extent:i;let{positionAbsolute:v}=g.internals;if(g.parentId&&g.extent==="parent"){const E=t.get(g.parentId);E&&(v=ii(v,w,E))}else p&&(v=Xe(v,p,w));const N={...g,measured:w,internals:{...g.internals,positionAbsolute:v,handleBounds:{source:zr("source",h.nodeElement,b,d,g.id),target:zr("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,N),g.parentId&&nr(N,t,n,{nodeOrigin:o,zIndexMode:s}),c=!0,x&&(u.push({id:g.id,type:"dimensions",dimensions:w}),g.expandParent&&g.parentId&&l.push({id:g.id,parentId:g.parentId,rect:mt(N,o)}))}}if(l.length>0){const h=rr(l,t,n,o);u.push(...h)}return{changes:u,updatedInternals:c}}async function Mf({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function Fr(e,t,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),i){s=`${o}-${e}-${i}`;const u=r.get(s)||new Map;r.set(s,u.set(n,t))}}function bi(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},u=`${o}-${s}--${i}-${a}`,f=`${i}-${a}--${o}-${s}`;Fr("source",c,f,e,o,s),Fr("target",c,u,e,i,a),t.set(r.id,r)}}function _i(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:_i(n,t):!1}function Or(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Cf(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!_i(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&o.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function xn({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[u,f]of t){const d=(s=n.get(u))==null?void 0:s.internals.userNode;d&&o.push({...d,position:f.position,dragging:r})}if(!e)return[o[0],o];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:o[0],o]}function If({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=Et(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Af({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},f=null,d=!1,l=null,h=!1,g=!1,w=null;function x({noDragClassName:b,handleSelector:p,domNode:v,isSelectable:N,nodeId:E,nodeClickDistance:M=0}){l=ce(v);function _({x:R,y:D}){const{nodeLookup:y,nodeExtent:C,snapGrid:I,snapToGrid:k,nodeOrigin:z,onNodeDrag:A,onSelectionDrag:H,onError:F,updateNodePositions:V}=t();i={x:R,y:D};let j=!1;const X=a.size>1,G=X&&C?Dn(_t(a)):null,J=X&&k?If({dragItems:a,snapGrid:I,x:R,y:D}):null;for(const[q,L]of a){if(!y.has(q))continue;let O={x:R-L.distance.x,y:D-L.distance.y};k&&(O=J?{x:Math.round(O.x+J.x),y:Math.round(O.y+J.y)}:Et(O,I));let Z=null;if(X&&C&&!L.extent&&G){const{positionAbsolute:K}=L.internals,Q=K.x-G.x+C[0][0],ee=K.x+L.measured.width-G.x2+C[1][0],ne=K.y-G.y+C[0][1],re=K.y+L.measured.height-G.y2+C[1][1];Z=[[Q,ne],[ee,re]]}const{position:U,positionAbsolute:Y}=oi({nodeId:q,nextPosition:O,nodeLookup:y,nodeExtent:Z||C,nodeOrigin:z,onError:F});j=j||L.position.x!==U.x||L.position.y!==U.y,L.position=U,L.internals.positionAbsolute=Y}if(g=g||j,!!j&&(V(a,!0),w&&(r||A||!E&&H))){const[q,L]=xn({nodeId:E,dragItems:a,nodeLookup:y});r==null||r(w,a,q,L),A==null||A(w,q,L),E||H==null||H(w,L)}}async function S(){if(!f)return;const{transform:R,panBy:D,autoPanSpeed:y,autoPanOnNodeDrag:C}=t();if(!C){c=!1,cancelAnimationFrame(s);return}const[I,k]=Un(u,f,y);(I!==0||k!==0)&&(i.x=(i.x??0)-I/R[2],i.y=(i.y??0)-k/R[2],await D({x:I,y:k})&&_(i)),s=requestAnimationFrame(S)}function B(R){var X;const{nodeLookup:D,multiSelectionActive:y,nodesDraggable:C,transform:I,snapGrid:k,snapToGrid:z,selectNodesOnDrag:A,onNodeDragStart:H,onSelectionDragStart:F,unselectNodesAndEdges:V}=t();d=!0,(!A||!N)&&!y&&E&&((X=D.get(E))!=null&&X.selected||V()),N&&A&&E&&(e==null||e(E));const j=ut(R.sourceEvent,{transform:I,snapGrid:k,snapToGrid:z,containerBounds:f});if(i=j,a=Cf(D,C,j,E),a.size>0&&(n||H||!E&&F)){const[G,J]=xn({nodeId:E,dragItems:a,nodeLookup:D});n==null||n(R.sourceEvent,a,G,J),H==null||H(R.sourceEvent,G,J),E||F==null||F(R.sourceEvent,J)}}const $=Ro().clickDistance(M).on("start",R=>{const{domNode:D,nodeDragThreshold:y,transform:C,snapGrid:I,snapToGrid:k}=t();f=(D==null?void 0:D.getBoundingClientRect())||null,h=!1,g=!1,w=R.sourceEvent,y===0&&B(R),i=ut(R.sourceEvent,{transform:C,snapGrid:I,snapToGrid:k,containerBounds:f}),u=pe(R.sourceEvent,f)}).on("drag",R=>{const{autoPanOnNodeDrag:D,transform:y,snapGrid:C,snapToGrid:I,nodeDragThreshold:k,nodeLookup:z}=t(),A=ut(R.sourceEvent,{transform:y,snapGrid:C,snapToGrid:I,containerBounds:f});if(w=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||E&&!z.has(E))&&(h=!0),!h){if(!c&&D&&d&&(c=!0,S()),!d){const H=pe(R.sourceEvent,f),F=H.x-u.x,V=H.y-u.y;Math.sqrt(F*F+V*V)>k&&B(R)}(i.x!==A.xSnapped||i.y!==A.ySnapped)&&a&&d&&(u=pe(R.sourceEvent,f),_(A))}}).on("end",R=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:D,updateNodePositions:y,onNodeDragStop:C,onSelectionDragStop:I}=t();if(g&&(y(a,!1),g=!1),o||C||!E&&I){const[k,z]=xn({nodeId:E,dragItems:a,nodeLookup:D,dragging:!1});o==null||o(R.sourceEvent,a,k,z),C==null||C(R.sourceEvent,k,z),E||I==null||I(R.sourceEvent,z)}}}).filter(R=>{const D=R.target;return!R.button&&(!b||!Or(D,`.${b}`,v))&&(!p||Or(D,p,v))});l.call($)}function m(){l==null||l.on(".drag",null)}return{update:x,destroy:m}}function kf(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Zt(o,mt(i))>0&&r.push(i);return r}const $f=250;function Pf(e,t,n,r){var a,c;let o=[],i=1/0;const s=kf(e,n,t+$f);for(const u of s){const f=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of f){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:l,y:h}=We(u,d,d.position,!0),g=Math.sqrt(Math.pow(l-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(o=[{...d,x:l,y:h}],i=g):g===i&&o.push({...d,x:l,y:h}))}}if(!o.length)return null;if(o.length>1){const u=r.type==="source"?"target":"source";return o.find(f=>f.type===u)??o[0]}return o[0]}function Ei(e,t,n,r,o,i=!1){var u,f,d;const s=r.get(e);if(!s)return null;const a=o==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(l=>l.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...We(s,c,c.position,!0)}:c}function Si(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Tf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ni=()=>!0;function zf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:f,flowId:d,panBy:l,cancelConnection:h,onConnectStart:g,onConnect:w,onConnectEnd:x,isValidConnection:m=Ni,onReconnectEnd:b,updateConnection:p,getTransform:v,getFromHandle:N,autoPanSpeed:E,dragThreshold:M=1,handleDomNode:_}){const S=di(e.target);let B=0,$;const{x:R,y:D}=pe(e),y=Si(i,_),C=a==null?void 0:a.getBoundingClientRect();let I=!1;if(!C||!y)return;const k=Ei(o,y,r,c,t);if(!k)return;let z=pe(e,C),A=!1,H=null,F=!1,V=null;function j(){if(!f||!C)return;const[U,Y]=Un(z,C,E);l({x:U,y:Y}),B=requestAnimationFrame(j)}const X={...k,nodeId:o,type:y,position:k.position},G=c.get(o);let q={inProgress:!0,isValid:null,from:We(G,X,W.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:G,to:z,toHandle:null,toPosition:kr[X.position],toNode:null,pointer:z};function L(){I=!0,p(q),g==null||g(e,{nodeId:o,handleId:r,handleType:y})}M===0&&L();function O(U){if(!I){const{x:re,y:le}=pe(U),we=re-R,ve=le-D;if(!(we*we+ve*ve>M*M))return;L()}if(!N()||!X){Z(U);return}const Y=v();z=pe(U,C),$=Pf(St(z,Y,!1,[1,1]),n,c,X),A||(j(),A=!0);const K=Mi(U,{handle:$,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:S,lib:u,flowId:d,nodeLookup:c});V=K.handleDomNode,H=K.connection,F=Tf(!!$,K.isValid);const Q=c.get(o),ee=Q?We(Q,X,W.Left,!0):q.from,ne={...q,from:ee,isValid:F,to:K.toHandle&&F?tt({x:K.toHandle.x,y:K.toHandle.y},Y):z,toHandle:K.toHandle,toPosition:F&&K.toHandle?K.toHandle.position:kr[X.position],toNode:K.toHandle?c.get(K.toHandle.nodeId):null,pointer:z};p(ne),q=ne}function Z(U){if(!("touches"in U&&U.touches.length>0)){if(I){($||V)&&H&&F&&(w==null||w(H));const{inProgress:Y,...K}=q,Q={...K,toPosition:q.toHandle?q.toPosition:null};x==null||x(U,Q),i&&(b==null||b(U,Q))}h(),cancelAnimationFrame(B),A=!1,F=!1,H=null,V=null,S.removeEventListener("mousemove",O),S.removeEventListener("mouseup",Z),S.removeEventListener("touchmove",O),S.removeEventListener("touchend",Z)}}S.addEventListener("mousemove",O),S.addEventListener("mouseup",Z),S.addEventListener("touchmove",O),S.addEventListener("touchend",Z)}function Mi(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:u=Ni,nodeLookup:f}){const d=i==="target",l=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=pe(e),w=s.elementFromPoint(h,g),x=w!=null&&w.classList.contains(`${a}-flow__handle`)?w:l,m={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const b=Si(void 0,x),p=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),N=x.classList.contains("connectable"),E=x.classList.contains("connectableend");if(!p||!b)return m;const M={source:d?p:r,sourceHandle:d?v:o,target:d?r:p,targetHandle:d?o:v};m.connection=M;const S=N&&E&&(n===Je.Strict?d&&b==="source"||!d&&b==="target":p!==r||v!==o);m.isValid=S&&u(M),m.toHandle=Ei(p,b,v,f,n,!0)}return m}const Vn={onPointerDown:zf,isValid:Mi};function Df({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:u,zoomStep:f=1,pannable:d=!0,zoomable:l=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const v=n(),N=p.sourceEvent.ctrlKey&&yt()?10:1,E=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*f,M=v[2]*Math.pow(2,E*N);t.scaleTo(M)};let w=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(w=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const v=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const N=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],E=[N[0]-w[0],N[1]-w[1]];w=N;const M=r()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),_={x:v[0]-E[0]*M,y:v[1]-E[1]*M},S=[[0,0],[c,u]];t.setViewportConstrained({x:_.x,y:_.y,zoom:v[2]},S,a)},b=Jo().on("start",x).on("zoom",d?m:null).on("zoom.wheel",l?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:de}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),wn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),Pe=(e,t)=>e.target.closest(`.${t}`),Ci=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Hf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,vn=(e,t=0,n=Hf,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},Ii=e=>{const t=e.ctrlKey&&yt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Lf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return f=>{if(Pe(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(f.ctrlKey&&s){const x=de(f),m=Ii(f),b=d*Math.pow(2,m);r.scaleTo(n,b,x,f);return}const l=f.deltaMode===1?20:1;let h=o===Fe.Vertical?0:f.deltaX*l,g=o===Fe.Horizontal?0:f.deltaY*l;!yt()&&f.shiftKey&&o!==Fe.Vertical&&(h=f.deltaY*l,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const w=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c==null||c(f,w):(e.isPanScrolling=!0,a==null||a(f,w)),e.panScrollTimeout=setTimeout(()=>{u==null||u(f,w),e.isPanScrolling=!1},150)}}function Rf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=Pe(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function Vf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=sn(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Bf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&Ci(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((a=i.sourceEvent)!=null&&a.internal)&&(o==null||o(i.sourceEvent,sn(i.transform)))}}function Ff({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&Ci(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=sn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Of({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:u,lib:f,connectionInProgress:d}){return l=>{var m;const h=t||n,g=r&&l.ctrlKey,w=l.type==="wheel";if(l.button===1&&l.type==="mousedown"&&(Pe(l,`${f}-flow__node`)||Pe(l,`${f}-flow__edge`)||Pe(l,`${f}-flow__selection`)||Pe(l,`${f}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!w||Pe(l,c)&&w||Pe(l,u)&&(!w||i&&w&&!t)||!r&&l.ctrlKey&&w)return!1;if(!r&&l.type==="touchstart"&&((m=l.touches)==null?void 0:m.length)>1)return l.preventDefault(),!1;if(!h&&!i&&!g&&w||!o&&(l.type==="mousedown"||l.type==="touchstart")||Array.isArray(o)&&!o.includes(l.button)&&l.type==="mousedown")return!1;const x=Array.isArray(o)&&o.includes(l.button)||!l.button||l.button<=1;return(!l.ctrlKey||w||e)&&x}}function jf({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect();let d=[[0,0],[f.width,f.height]];const l=typeof ResizeObserver<"u"?new ResizeObserver(D=>{const y=D[0];y&&(d=[[0,0],[y.contentRect.width,y.contentRect.height]])}):null;l==null||l.observe(e);const h=Jo().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);v({x:o.x,y:o.y,zoom:et(o.zoom,t,n)},[[0,0],[f.width,f.height]],r);const w=g.on("wheel.zoom"),x=g.on("dblclick.zoom");h.wheelDelta(Ii);async function m(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).transform(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}function b({noWheelClassName:D,noPanClassName:y,onPaneContextMenu:C,userSelectionActive:I,panOnScroll:k,panOnDrag:z,panOnScrollMode:A,panOnScrollSpeed:H,preventScrolling:F,zoomOnPinch:V,zoomOnScroll:j,zoomOnDoubleClick:X,panActivationKeyPressed:G=!1,zoomActivationKeyPressed:J,lib:q,onTransformChange:L,connectionInProgress:O,paneClickDistance:Z,selectionOnDrag:U}){I&&!u.isZoomingOrPanning&&p();const Y=k&&!J&&!I;h.clickDistance(U?1/0:!ge(Z)||Z<0?0:Z);const K=Y?Lf({zoomPanValues:u,noWheelClassName:D,d3Selection:g,d3Zoom:h,panOnScrollMode:A,panOnScrollSpeed:H,zoomOnPinch:V,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Rf({noWheelClassName:D,preventScrolling:F,d3ZoomHandler:w});g.on("wheel.zoom",K,{passive:!1});const Q=Vf({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});h.on("start",Q);const ee=Bf({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!C,onPanZoom:i,onTransformChange:L});h.on("zoom",ee);const ne=Ff({zoomPanValues:u,panOnDrag:z,panOnScroll:k,onPaneContextMenu:C,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=Of({panActivationKeyPressed:G,zoomActivationKeyPressed:J,panOnDrag:z,zoomOnScroll:j,panOnScroll:k,zoomOnDoubleClick:X,zoomOnPinch:V,userSelectionActive:I,noPanClassName:y,noWheelClassName:D,lib:q,connectionInProgress:O});h.filter(re),X?g.on("dblclick.zoom",x):g.on("dblclick.zoom",null)}function p(){h.on("zoom",null)}async function v(D,y,C){const I=wn(D),k=h==null?void 0:h.constrain()(I,y,C);return k&&await m(k),k}async function N(D,y){const C=wn(D);return await m(C,y),C}function E(D){if(g){const y=wn(D),C=g.property("__zoom");(C.k!==D.zoom||C.x!==D.x||C.y!==D.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function M(){const D=g?Qo(g.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}async function _(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).scaleTo(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}async function S(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).scaleBy(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}function B(D){h==null||h.scaleExtent(D)}function $(D){h==null||h.translateExtent(D)}function R(D){const y=!ge(D)||D<0?0:D;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:N,setViewportConstrained:v,getViewport:M,scaleTo:_,scaleBy:S,setScaleExtent:B,setTranslateExtent:$,syncViewport:E,setClickDistance:R}}var nt;(function(e){e.Line="line",e.Handle="handle"})(nt||(nt={}));function Xf({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,a=n-r,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function jr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function ke(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function Pt(e,t,n){return Math.max(0,t-e,e-n)}function Xr(e,t){return e?!t:t}function Yf(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:f,isVertical:d}=t,l=f&&d,{xSnapped:h,ySnapped:g}=n,{minWidth:w,maxWidth:x,minHeight:m,maxHeight:b}=r,{x:p,y:v,width:N,height:E,aspectRatio:M}=e;let _=Math.floor(f?h-e.pointerX:0),S=Math.floor(d?g-e.pointerY:0);const B=N+(c?-_:_),$=E+(u?-S:S),R=-i[0]*N,D=-i[1]*E;let y=Pt(B,w,x),C=Pt($,m,b);if(s){let z=0,A=0;c&&_<0?z=ke(p+_+R,s[0][0]):!c&&_>0&&(z=$e(p+B+R,s[1][0])),u&&S<0?A=ke(v+S+D,s[0][1]):!u&&S>0&&(A=$e(v+$+D,s[1][1])),y=Math.max(y,z),C=Math.max(C,A)}if(a){let z=0,A=0;c&&_>0?z=$e(p+_,a[0][0]):!c&&_<0&&(z=ke(p+B,a[1][0])),u&&S>0?A=$e(v+S,a[0][1]):!u&&S<0&&(A=ke(v+$,a[1][1])),y=Math.max(y,z),C=Math.max(C,A)}if(o){if(f){const z=Pt(B/M,m,b)*M;if(y=Math.max(y,z),s){let A=0;!c&&!u||c&&!u&&l?A=$e(v+D+B/M,s[1][1])*M:A=ke(v+D+(c?_:-_)/M,s[0][1])*M,y=Math.max(y,A)}if(a){let A=0;!c&&!u||c&&!u&&l?A=ke(v+B/M,a[1][1])*M:A=$e(v+(c?_:-_)/M,a[0][1])*M,y=Math.max(y,A)}}if(d){const z=Pt($*M,w,x)/M;if(C=Math.max(C,z),s){let A=0;!c&&!u||u&&!c&&l?A=$e(p+$*M+R,s[1][0])/M:A=ke(p+(u?S:-S)*M+R,s[0][0])/M,C=Math.max(C,A)}if(a){let A=0;!c&&!u||u&&!c&&l?A=ke(p+$*M,a[1][0])/M:A=$e(p+(u?S:-S)*M,a[0][0])/M,C=Math.max(C,A)}}}S=S+(S<0?C:-C),_=_+(_<0?y:-y),o&&(l?B>$*M?S=(Xr(c,u)?-_:_)/M:_=(Xr(c,u)?-S:S)*M:f?(S=_/M,u=c):(_=S*M,c=u));const I=c?p+_:p,k=u?v+S:v;return{width:N+(c?-_:_),height:E+(u?-S:S),x:i[0]*_*(c?-1:1)+I,y:i[1]*S*(u?-1:1)+k}}const Ai={width:0,height:0,x:0,y:0},Wf={...Ai,pointerX:0,pointerY:0,aspectRatio:1};function qf(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[r-a,o-c],[r+i-a,o+s-c]]}function Gf({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:jr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:f,keepAspectRatio:d,resizeDirection:l,onResizeStart:h,onResize:g,onResizeEnd:w,shouldResize:x}){let m={...Ai},b={...Wf};s={boundaries:f,resizeDirection:l,keepAspectRatio:d,controlDirection:jr(u)};let p,v=null,N=[],E,M,_,S=!1;const B=Ro().on("start",$=>{const{nodeLookup:R,transform:D,snapGrid:y,snapToGrid:C,nodeOrigin:I,paneDomNode:k}=n();if(p=R.get(t),!p)return;v=(k==null?void 0:k.getBoundingClientRect())??null;const{xSnapped:z,ySnapped:A}=ut($.sourceEvent,{transform:D,snapGrid:y,snapToGrid:C,containerBounds:v});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:z,pointerY:A,aspectRatio:m.width/m.height},E=void 0,M=Ye(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(E=R.get(p.parentId)),E&&p.extent==="parent"&&(M=[[0,0],[E.measured.width,E.measured.height]]),N=[],_=void 0;for(const[H,F]of R)if(F.parentId===t&&(N.push({id:H,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const V=qf(F,p,F.origin??I);_?_=[[Math.min(V[0][0],_[0][0]),Math.min(V[0][1],_[0][1])],[Math.max(V[1][0],_[1][0]),Math.max(V[1][1],_[1][1])]]:_=V}h==null||h($,{...m})}).on("drag",$=>{const{transform:R,snapGrid:D,snapToGrid:y,nodeOrigin:C}=n(),I=ut($.sourceEvent,{transform:R,snapGrid:D,snapToGrid:y,containerBounds:v}),k=[];if(!p)return;const{x:z,y:A,width:H,height:F}=m,V={},j=p.origin??C,{width:X,height:G,x:J,y:q}=Yf(b,s.controlDirection,I,s.boundaries,s.keepAspectRatio,j,M,_),L=X!==H,O=G!==F,Z=J!==z&&L,U=q!==A&&O;if(!Z&&!U&&!L&&!O)return;if((Z||U||j[0]===1||j[1]===1)&&(V.x=Z?J:m.x,V.y=U?q:m.y,m.x=V.x,m.y=V.y,N.length>0)){const ee=J-z,ne=q-A;for(const re of N)re.position={x:re.position.x-ee+j[0]*(X-H),y:re.position.y-ne+j[1]*(G-F)},k.push(re)}if((L||O)&&(V.width=L&&(!s.resizeDirection||s.resizeDirection==="horizontal")?X:m.width,V.height=O&&(!s.resizeDirection||s.resizeDirection==="vertical")?G:m.height,m.width=V.width,m.height=V.height),E&&p.expandParent){const ee=j[0]*(V.width??0);V.x&&V.x<ee&&(m.x=ee,b.x=b.x-(V.x-ee));const ne=j[1]*(V.height??0);V.y&&V.y<ne&&(m.y=ne,b.y=b.y-(V.y-ne))}const Y=Xf({width:m.width,prevWidth:H,height:m.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),K={...m,direction:Y};(x==null?void 0:x($,K))!==!1&&(S=!0,g==null||g($,K),r(V,k))}).on("end",$=>{S&&(w==null||w($,{...m}),o==null||o({...m}),S=!1)});i.call(B)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var bn={exports:{}},_n={},En={exports:{}},Sn={};/**
1
+ import{X as Eo,Y as ma,Z as ya,f as T,j as P}from"./index-DS8k2gIv.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var xa={value:()=>{}};function Qt(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Dt(n)}function Dt(e){this._=e}function wa(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Dt.prototype=Qt.prototype={constructor:Dt,on:function(e,t){var n=this._,r=wa(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=va(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=hr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=hr(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Dt(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function va(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function hr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=xa,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Cn="http://www.w3.org/1999/xhtml";const gr={svg:"http://www.w3.org/2000/svg",xhtml:Cn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),gr.hasOwnProperty(t)?{space:gr[t],local:e}:e}function ba(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cn&&t.documentElement.namespaceURI===Cn?t.createElement(e):t.createElementNS(n,e)}}function _a(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function So(e){var t=Jt(e);return(t.local?_a:ba)(t)}function Ea(){}function Fn(e){return e==null?Ea:function(){return this.querySelector(e)}}function Sa(e){typeof e!="function"&&(e=Fn(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=new Array(s),c,u,f=0;f<s;++f)(c=i[f])&&(u=e.call(c,c.__data__,f,i))&&("__data__"in c&&(u.__data__=c.__data__),a[f]=u);return new ue(r,this._parents)}function Na(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ma(){return[]}function No(e){return e==null?Ma:function(){return this.querySelectorAll(e)}}function Ca(e){return function(){return Na(e.apply(this,arguments))}}function Ia(e){typeof e=="function"?e=Ca(e):e=No(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,u=0;u<a;++u)(c=s[u])&&(r.push(e.call(c,c.__data__,u,s)),o.push(c));return new ue(r,o)}function Mo(e){return function(){return this.matches(e)}}function Co(e){return function(t){return t.matches(e)}}var Aa=Array.prototype.find;function ka(e){return function(){return Aa.call(this.children,e)}}function $a(){return this.firstElementChild}function Pa(e){return this.select(e==null?$a:ka(typeof e=="function"?e:Co(e)))}var Ta=Array.prototype.filter;function za(){return Array.from(this.children)}function Da(e){return function(){return Ta.call(this.children,e)}}function Ha(e){return this.selectAll(e==null?za:Da(typeof e=="function"?e:Co(e)))}function La(e){typeof e!="function"&&(e=Mo(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new ue(r,this._parents)}function Io(e){return new Array(e.length)}function Ra(){return new ue(this._enter||this._groups.map(Io),this._parents)}function Bt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Bt.prototype={constructor:Bt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Va(e){return function(){return e}}function Ba(e,t,n,r,o,i){for(var s=0,a,c=t.length,u=i.length;s<u;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new Bt(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function Fa(e,t,n,r,o,i,s){var a,c,u=new Map,f=t.length,d=i.length,l=new Array(f),h;for(a=0;a<f;++a)(c=t[a])&&(l[a]=h=s.call(c,c.__data__,a,t)+"",u.has(h)?o[a]=c:u.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=u.get(h))?(r[a]=c,c.__data__=i[a],u.delete(h)):n[a]=new Bt(e,i[a]);for(a=0;a<f;++a)(c=t[a])&&u.get(l[a])===c&&(o[a]=c)}function Oa(e){return e.__data__}function ja(e,t){if(!arguments.length)return Array.from(this,Oa);var n=t?Fa:Ba,r=this._parents,o=this._groups;typeof e!="function"&&(e=Va(e));for(var i=o.length,s=new Array(i),a=new Array(i),c=new Array(i),u=0;u<i;++u){var f=r[u],d=o[u],l=d.length,h=Xa(e.call(f,f&&f.__data__,u,r)),g=h.length,w=a[u]=new Array(g),x=s[u]=new Array(g),m=c[u]=new Array(l);n(f,d,w,x,m,h,t);for(var b=0,p=0,v,N;b<g;++b)if(v=w[b]){for(b>=p&&(p=b+1);!(N=x[p])&&++p<g;);v._next=N||null}}return s=new ue(s,r),s._enter=a,s._exit=c,s}function Xa(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ya(){return new ue(this._exit||this._groups.map(Io),this._parents)}function Wa(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function qa(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),c=0;c<s;++c)for(var u=n[c],f=r[c],d=u.length,l=a[c]=new Array(d),h,g=0;g<d;++g)(h=u[g]||f[g])&&(l[g]=h);for(;c<o;++c)a[c]=n[c];return new ue(a,this._parents)}function Ga(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Za(e){e||(e=Ua);function t(d,l){return d&&l?e(d.__data__,l.__data__):!d-!l}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],a=s.length,c=o[i]=new Array(a),u,f=0;f<a;++f)(u=s[f])&&(c[f]=u);c.sort(t)}return new ue(o,this._parents).order()}function Ua(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ka(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qa(){return Array.from(this)}function Ja(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function ec(){let e=0;for(const t of this)++e;return e}function tc(){return!this.node()}function nc(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&e.call(a,a.__data__,i,o);return this}function rc(e){return function(){this.removeAttribute(e)}}function oc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ic(e,t){return function(){this.setAttribute(e,t)}}function sc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ac(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function uc(e,t){var n=Jt(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?oc:rc:typeof t=="function"?n.local?cc:ac:n.local?sc:ic)(n,t))}function Ao(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lc(e){return function(){this.style.removeProperty(e)}}function fc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function dc(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hc(e,t,n){return arguments.length>1?this.each((t==null?lc:typeof t=="function"?dc:fc)(e,t,n??"")):Ke(this.node(),e)}function Ke(e,t){return e.style.getPropertyValue(t)||Ao(e).getComputedStyle(e,null).getPropertyValue(t)}function gc(e){return function(){delete this[e]}}function pc(e,t){return function(){this[e]=t}}function mc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yc(e,t){return arguments.length>1?this.each((t==null?gc:typeof t=="function"?mc:pc)(e,t)):this.node()[e]}function ko(e){return e.trim().split(/^|\s+/)}function On(e){return e.classList||new $o(e)}function $o(e){this._node=e,this._names=ko(e.getAttribute("class")||"")}$o.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Po(e,t){for(var n=On(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function To(e,t){for(var n=On(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function xc(e){return function(){Po(this,e)}}function wc(e){return function(){To(this,e)}}function vc(e,t){return function(){(t.apply(this,arguments)?Po:To)(this,e)}}function bc(e,t){var n=ko(e+"");if(arguments.length<2){for(var r=On(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?vc:t?xc:wc)(n,t))}function _c(){this.textContent=""}function Ec(e){return function(){this.textContent=e}}function Sc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Nc(e){return arguments.length?this.each(e==null?_c:(typeof e=="function"?Sc:Ec)(e)):this.node().textContent}function Mc(){this.innerHTML=""}function Cc(e){return function(){this.innerHTML=e}}function Ic(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Ac(e){return arguments.length?this.each(e==null?Mc:(typeof e=="function"?Ic:Cc)(e)):this.node().innerHTML}function kc(){this.nextSibling&&this.parentNode.appendChild(this)}function $c(){return this.each(kc)}function Pc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Tc(){return this.each(Pc)}function zc(e){var t=typeof e=="function"?e:So(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Dc(){return null}function Hc(e,t){var n=typeof e=="function"?e:So(e),r=t==null?Dc:typeof t=="function"?t:Fn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Lc(){var e=this.parentNode;e&&e.removeChild(this)}function Rc(){return this.each(Lc)}function Vc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fc(e){return this.select(e?Bc:Vc)}function Oc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function jc(e){return function(t){e.call(this,t,this.__data__)}}function Xc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Yc(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function Wc(e,t,n){return function(){var r=this.__on,o,i=jc(t);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}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 qc(e,t,n){var r=Xc(e+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,u=a.length,f;c<u;++c)for(o=0,f=a[c];o<i;++o)if((s=r[o]).type===f.type&&s.name===f.name)return f.value}return}for(a=t?Wc:Yc,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function zo(e,t,n){var r=Ao(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Gc(e,t){return function(){return zo(this,e,t)}}function Zc(e,t){return function(){return zo(this,e,t.apply(this,arguments))}}function Uc(e,t){return this.each((typeof t=="function"?Zc:Gc)(e,t))}function*Kc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var Do=[null];function ue(e,t){this._groups=e,this._parents=t}function wt(){return new ue([[document.documentElement]],Do)}function Qc(){return this}ue.prototype=wt.prototype={constructor:ue,select:Sa,selectAll:Ia,selectChild:Pa,selectChildren:Ha,filter:La,data:ja,enter:Ra,exit:Ya,join:Wa,merge:qa,selection:Qc,order:Ga,sort:Za,call:Ka,nodes:Qa,node:Ja,size:ec,empty:tc,each:nc,attr:uc,style:hc,property:yc,classed:bc,text:Nc,html:Ac,raise:$c,lower:Tc,append:zc,insert:Hc,remove:Rc,clone:Fc,datum:Oc,on:qc,dispatch:Uc,[Symbol.iterator]:Kc};function ce(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Do)}function Jc(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=Jc(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const eu={passive:!1},lt={capture:!0,passive:!1};function gn(e){e.stopImmediatePropagation()}function Ze(e){e.preventDefault(),e.stopImmediatePropagation()}function Ho(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Ze,lt);"onselectstart"in t?n.on("selectstart.drag",Ze,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lo(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ze,lt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Mt=e=>()=>e;function In(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}In.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tu(e){return!e.ctrlKey&&!e.button}function nu(){return this.parentNode}function ru(e,t){return t??{x:e.x,y:e.y}}function ou(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ro(){var e=tu,t=nu,n=ru,r=ou,o={},i=Qt("start","drag","end"),s=0,a,c,u,f,d=0;function l(v){v.on("mousedown.drag",h).filter(r).on("touchstart.drag",x).on("touchmove.drag",m,eu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,N){if(!(f||!e.call(this,v,N))){var E=p(this,t.call(this,v,N),v,N,"mouse");E&&(ce(v.view).on("mousemove.drag",g,lt).on("mouseup.drag",w,lt),Ho(v.view),gn(v),u=!1,a=v.clientX,c=v.clientY,E("start",v))}}function g(v){if(Ze(v),!u){var N=v.clientX-a,E=v.clientY-c;u=N*N+E*E>d}o.mouse("drag",v)}function w(v){ce(v.view).on("mousemove.drag mouseup.drag",null),Lo(v.view,u),Ze(v),o.mouse("end",v)}function x(v,N){if(e.call(this,v,N)){var E=v.changedTouches,M=t.call(this,v,N),_=E.length,S,B;for(S=0;S<_;++S)(B=p(this,M,v,N,E[S].identifier,E[S]))&&(gn(v),B("start",v,E[S]))}}function m(v){var N=v.changedTouches,E=N.length,M,_;for(M=0;M<E;++M)(_=o[N[M].identifier])&&(Ze(v),_("drag",v,N[M]))}function b(v){var N=v.changedTouches,E=N.length,M,_;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),M=0;M<E;++M)(_=o[N[M].identifier])&&(gn(v),_("end",v,N[M]))}function p(v,N,E,M,_,S){var B=i.copy(),$=de(S||E,N),R,D,y;if((y=n.call(v,new In("beforestart",{sourceEvent:E,target:l,identifier:_,active:s,x:$[0],y:$[1],dx:0,dy:0,dispatch:B}),M))!=null)return R=y.x-$[0]||0,D=y.y-$[1]||0,function C(I,k,z){var A=$,H;switch(I){case"start":o[_]=C,H=s++;break;case"end":delete o[_],--s;case"drag":$=de(z||k,N),H=s;break}B.call(I,v,new In(I,{sourceEvent:k,subject:y,target:l,identifier:_,active:H,x:$[0]+R,y:$[1]+D,dx:$[0]-A[0],dy:$[1]-A[1],dispatch:B}),M)}}return l.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Mt(!!v),l):e},l.container=function(v){return arguments.length?(t=typeof v=="function"?v:Mt(v),l):t},l.subject=function(v){return arguments.length?(n=typeof v=="function"?v:Mt(v),l):n},l.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:Mt(!!v),l):r},l.on=function(){var v=i.on.apply(i,arguments);return v===i?l:v},l.clickDistance=function(v){return arguments.length?(d=(v=+v)*v,l):Math.sqrt(d)},l}function jn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Vo(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function vt(){}var ft=.7,Ft=1/ft,Ue="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",iu=/^#([0-9a-f]{3,8})$/,su=new RegExp(`^rgb\\(${Ue},${Ue},${Ue}\\)$`),au=new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`),cu=new RegExp(`^rgba\\(${Ue},${Ue},${Ue},${dt}\\)$`),uu=new RegExp(`^rgba\\(${_e},${_e},${_e},${dt}\\)$`),lu=new RegExp(`^hsl\\(${dt},${_e},${_e}\\)$`),fu=new RegExp(`^hsla\\(${dt},${_e},${_e},${dt}\\)$`),pr={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};jn(vt,Oe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:mr,formatHex:mr,formatHex8:du,formatHsl:hu,formatRgb:yr,toString:yr});function mr(){return this.rgb().formatHex()}function du(){return this.rgb().formatHex8()}function hu(){return Bo(this).formatHsl()}function yr(){return this.rgb().formatRgb()}function Oe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=iu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?xr(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Ct(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Ct(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=su.exec(e))?new ae(t[1],t[2],t[3],1):(t=au.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=cu.exec(e))?Ct(t[1],t[2],t[3],t[4]):(t=uu.exec(e))?Ct(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lu.exec(e))?br(t[1],t[2]/100,t[3]/100,1):(t=fu.exec(e))?br(t[1],t[2]/100,t[3]/100,t[4]):pr.hasOwnProperty(e)?xr(pr[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function xr(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Ct(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function gu(e){return e instanceof vt||(e=Oe(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function An(e,t,n,r){return arguments.length===1?gu(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}jn(ae,An,Vo(vt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Be(this.r),Be(this.g),Be(this.b),Ot(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:wr,formatHex:wr,formatHex8:pu,formatRgb:vr,toString:vr}));function wr(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function pu(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function vr(){const e=Ot(this.opacity);return`${e===1?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${e===1?")":`, ${e})`}`}function Ot(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Be(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Be(e),(e<16?"0":"")+e.toString(16)}function br(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,n,r)}function Bo(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof vt||(e=Oe(e)),!e)return new he;if(e instanceof he)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,a=i-o,c=(i+o)/2;return a?(t===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+o:2-i-o,s*=60):a=c>0&&c<1?0:s,new he(s,a,c,e.opacity)}function mu(e,t,n,r){return arguments.length===1?Bo(e):new he(e,t,n,r??1)}function he(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}jn(he,mu,Vo(vt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,e),new he(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new ae(pn(e>=240?e-240:e+120,o,r),pn(e,o,r),pn(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new he(_r(this.h),It(this.s),It(this.l),Ot(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=Ot(this.opacity);return`${e===1?"hsl(":"hsla("}${_r(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _r(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function pn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Xn=e=>()=>e;function yu(e,t){return function(n){return e+n*t}}function xu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function wu(e){return(e=+e)==1?Fo:function(t,n){return n-t?xu(t,n,e):Xn(isNaN(t)?n:t)}}function Fo(e,t){var n=t-e;return n?yu(e,n):Xn(isNaN(e)?t:e)}const jt=(function e(t){var n=wu(t);function r(o,i){var s=n((o=An(o)).r,(i=An(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),u=Fo(o.opacity,i.opacity);return function(f){return o.r=s(f),o.g=a(f),o.b=c(f),o.opacity=u(f),o+""}}return r.gamma=e,r})(1);function vu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function bu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function _u(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=ct(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function Eu(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function be(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Su(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=ct(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var kn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(kn.source,"g");function Nu(e){return function(){return e}}function Mu(e){return function(t){return e(t)+""}}function Oo(e,t){var n=kn.lastIndex=mn.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=kn.exec(e))&&(o=mn.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(r=r[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,c.push({i:s,x:be(r,o)})),n=mn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?Mu(c[0].x):Nu(t):(t=c.length,function(u){for(var f=0,d;f<t;++f)a[(d=c[f]).i]=d.x(u);return a.join("")})}function ct(e,t){var n=typeof t,r;return t==null||n==="boolean"?Xn(t):(n==="number"?be:n==="string"?(r=Oe(t))?(t=r,jt):Oo:t instanceof Oe?jt:t instanceof Date?Eu:bu(t)?vu:Array.isArray(t)?_u:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Su:be)(e,t)}var Er=180/Math.PI,$n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function jo(e,t,n,r,o,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*Er,skewX:Math.atan(c)*Er,scaleX:s,scaleY:a}}var At;function Cu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$n:jo(t.a,t.b,t.c,t.d,t.e,t.f)}function Iu(e){return e==null||(At||(At=document.createElementNS("http://www.w3.org/2000/svg","g")),At.setAttribute("transform",e),!(e=At.transform.baseVal.consolidate()))?$n:(e=e.matrix,jo(e.a,e.b,e.c,e.d,e.e,e.f))}function Xo(e,t,n,r){function o(u){return u.length?u.pop()+" ":""}function i(u,f,d,l,h,g){if(u!==d||f!==l){var w=h.push("translate(",null,t,null,n);g.push({i:w-4,x:be(u,d)},{i:w-2,x:be(f,l)})}else(d||l)&&h.push("translate("+d+t+l+n)}function s(u,f,d,l){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),l.push({i:d.push(o(d)+"rotate(",null,r)-2,x:be(u,f)})):f&&d.push(o(d)+"rotate("+f+r)}function a(u,f,d,l){u!==f?l.push({i:d.push(o(d)+"skewX(",null,r)-2,x:be(u,f)}):f&&d.push(o(d)+"skewX("+f+r)}function c(u,f,d,l,h,g){if(u!==d||f!==l){var w=h.push(o(h)+"scale(",null,",",null,")");g.push({i:w-4,x:be(u,d)},{i:w-2,x:be(f,l)})}else(d!==1||l!==1)&&h.push(o(h)+"scale("+d+","+l+")")}return function(u,f){var d=[],l=[];return u=e(u),f=e(f),i(u.translateX,u.translateY,f.translateX,f.translateY,d,l),s(u.rotate,f.rotate,d,l),a(u.skewX,f.skewX,d,l),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,d,l),u=f=null,function(h){for(var g=-1,w=l.length,x;++g<w;)d[(x=l[g]).i]=x.x(h);return d.join("")}}}var Au=Xo(Cu,"px, ","px)","deg)"),ku=Xo(Iu,", ",")",")"),$u=1e-12;function Sr(e){return((e=Math.exp(e))+1/e)/2}function Pu(e){return((e=Math.exp(e))-1/e)/2}function Tu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ht=(function e(t,n,r){function o(i,s){var a=i[0],c=i[1],u=i[2],f=s[0],d=s[1],l=s[2],h=f-a,g=d-c,w=h*h+g*g,x,m;if(w<$u)m=Math.log(l/u)/t,x=function(M){return[a+M*h,c+M*g,u*Math.exp(t*M*m)]};else{var b=Math.sqrt(w),p=(l*l-u*u+r*w)/(2*u*n*b),v=(l*l-u*u-r*w)/(2*l*n*b),N=Math.log(Math.sqrt(p*p+1)-p),E=Math.log(Math.sqrt(v*v+1)-v);m=(E-N)/t,x=function(M){var _=M*m,S=Sr(N),B=u/(n*b)*(S*Tu(t*_+N)-Pu(N));return[a+B*h,c+B*g,u*S/Sr(t*_+N)]}}return x.duration=m*1e3*t/Math.SQRT2,x}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},o})(Math.SQRT2,2,4);var Qe=0,st=0,ot=0,Yo=1e3,Xt,at,Yt=0,je=0,en=0,ht=typeof performance=="object"&&performance.now?performance:Date,Wo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yn(){return je||(Wo(zu),je=ht.now()+en)}function zu(){je=0}function Wt(){this._call=this._time=this._next=null}Wt.prototype=qo.prototype={constructor:Wt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Yn():+n)+(t==null?0:+t),!this._next&&at!==this&&(at?at._next=this:Xt=this,at=this),this._call=e,this._time=n,Pn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Pn())}};function qo(e,t,n){var r=new Wt;return r.restart(e,t,n),r}function Du(){Yn(),++Qe;for(var e=Xt,t;e;)(t=je-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qe}function Nr(){je=(Yt=ht.now())+en,Qe=st=0;try{Du()}finally{Qe=0,Lu(),je=0}}function Hu(){var e=ht.now(),t=e-Yt;t>Yo&&(en-=t,Yt=e)}function Lu(){for(var e,t=Xt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Xt=n);at=e,Pn(r)}function Pn(e){if(!Qe){st&&(st=clearTimeout(st));var t=e-je;t>24?(e<1/0&&(st=setTimeout(Nr,e-ht.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Yt=ht.now(),ot=setInterval(Hu,Yo)),Qe=1,Wo(Nr))}}function Mr(e,t,n){var r=new Wt;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Ru=Qt("start","end","cancel","interrupt"),Vu=[],Go=0,Cr=1,Tn=2,Lt=3,Ir=4,zn=5,Rt=6;function tn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Bu(e,n,{name:t,index:r,group:o,on:Ru,tween:Vu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Go})}function Wn(e,t){var n=ye(e,t);if(n.state>Go)throw new Error("too late; already scheduled");return n}function Ee(e,t){var n=ye(e,t);if(n.state>Lt)throw new Error("too late; already running");return n}function ye(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Bu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=qo(i,0,n.time);function i(u){n.state=Cr,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var f,d,l,h;if(n.state!==Cr)return c();for(f in r)if(h=r[f],h.name===n.name){if(h.state===Lt)return Mr(s);h.state===Ir?(h.state=Rt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[f]):+f<t&&(h.state=Rt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[f])}if(Mr(function(){n.state===Lt&&(n.state=Ir,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=Tn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tn){for(n.state=Lt,o=new Array(l=n.tween.length),f=0,d=-1;f<l;++f)(h=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=h);o.length=d+1}}function a(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=zn,1),d=-1,l=o.length;++d<l;)o[d].call(e,f);n.state===zn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Rt,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function Vt(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Tn&&r.state<zn,r.state=Rt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Fu(e){return this.each(function(){Vt(this,e)})}function Ou(e,t){var n,r;return function(){var o=Ee(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function ju(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Ee(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:t,value:n},c=0,u=o.length;c<u;++c)if(o[c].name===t){o[c]=a;break}c===u&&o.push(a)}i.tween=o}}function Xu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ye(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?Ou:ju)(n,e,t))}function qn(e,t,n){var r=e._id;return e.each(function(){var o=Ee(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ye(o,r).value[t]}}function Zo(e,t){var n;return(typeof t=="number"?be:t instanceof Oe?jt:(n=Oe(t))?(t=n,jt):Oo)(e,t)}function Yu(e){return function(){this.removeAttribute(e)}}function Wu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qu(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function Gu(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function Zu(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Uu(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Ku(e,t){var n=Jt(e),r=n==="transform"?ku:Zo;return this.attrTween(e,typeof t=="function"?(n.local?Uu:Zu)(n,r,qn(this,"attr."+e,t)):t==null?(n.local?Wu:Yu)(n):(n.local?Gu:qu)(n,r,t))}function Qu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Ju(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function el(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Ju(e,i)),n}return o._value=t,o}function tl(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Qu(e,i)),n}return o._value=t,o}function nl(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Jt(e);return this.tween(n,(r.local?el:tl)(r,t))}function rl(e,t){return function(){Wn(this,e).delay=+t.apply(this,arguments)}}function ol(e,t){return t=+t,function(){Wn(this,e).delay=t}}function il(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rl:ol)(t,e)):ye(this.node(),t).delay}function sl(e,t){return function(){Ee(this,e).duration=+t.apply(this,arguments)}}function al(e,t){return t=+t,function(){Ee(this,e).duration=t}}function cl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sl:al)(t,e)):ye(this.node(),t).duration}function ul(e,t){if(typeof t!="function")throw new Error;return function(){Ee(this,e).ease=t}}function ll(e){var t=this._id;return arguments.length?this.each(ul(t,e)):ye(this.node(),t).ease}function fl(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ee(this,e).ease=n}}function dl(e){if(typeof e!="function")throw new Error;return this.each(fl(this._id,e))}function hl(e){typeof e!="function"&&(e=Mo(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new Ae(r,this._parents,this._name,this._id)}function gl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var c=t[a],u=n[a],f=c.length,d=s[a]=new Array(f),l,h=0;h<f;++h)(l=c[h]||u[h])&&(d[h]=l);for(;a<r;++a)s[a]=t[a];return new Ae(s,this._parents,this._name,this._id)}function pl(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function ml(e,t,n){var r,o,i=pl(t)?Wn:Ee;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function yl(e,t){var n=this._id;return arguments.length<2?ye(this.node(),n).on.on(e):this.each(ml(n,e,t))}function xl(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function wl(){return this.on("end.remove",xl(this._id))}function vl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fn(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],c=a.length,u=i[s]=new Array(c),f,d,l=0;l<c;++l)(f=a[l])&&(d=e.call(f,f.__data__,l,a))&&("__data__"in f&&(d.__data__=f.__data__),u[l]=d,tn(u[l],t,n,l,u,ye(f,n)));return new Ae(i,this._parents,t,n)}function bl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=No(e));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var c=r[a],u=c.length,f,d=0;d<u;++d)if(f=c[d]){for(var l=e.call(f,f.__data__,d,c),h,g=ye(f,n),w=0,x=l.length;w<x;++w)(h=l[w])&&tn(h,t,n,w,l,g);i.push(l),s.push(f)}return new Ae(i,s,t,n)}var _l=wt.prototype.constructor;function El(){return new _l(this._groups,this._parents)}function Sl(e,t){var n,r,o;return function(){var i=Ke(this,e),s=(this.style.removeProperty(e),Ke(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function Uo(e){return function(){this.style.removeProperty(e)}}function Nl(e,t,n){var r,o=n+"",i;return function(){var s=Ke(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function Ml(e,t,n){var r,o,i;return function(){var s=Ke(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),Ke(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function Cl(e,t){var n,r,o,i="style."+t,s="end."+i,a;return function(){var c=Ee(this,e),u=c.on,f=c.value[i]==null?a||(a=Uo(t)):void 0;(u!==n||o!==f)&&(r=(n=u).copy()).on(s,o=f),c.on=r}}function Il(e,t,n){var r=(e+="")=="transform"?Au:Zo;return t==null?this.styleTween(e,Sl(e,r)).on("end.style."+e,Uo(e)):typeof t=="function"?this.styleTween(e,Ml(e,r,qn(this,"style."+e,t))).each(Cl(this._id,e)):this.styleTween(e,Nl(e,r,t),n).on("end.style."+e,null)}function Al(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function kl(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&Al(e,s,n)),r}return i._value=t,i}function $l(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,kl(e,t,n??""))}function Pl(e){return function(){this.textContent=e}}function Tl(e){return function(){var t=e(this);this.textContent=t??""}}function zl(e){return this.tween("text",typeof e=="function"?Tl(qn(this,"text",e)):Pl(e==null?"":e+""))}function Dl(e){return function(t){this.textContent=e.call(this,t)}}function Hl(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Dl(o)),t}return r._value=e,r}function Ll(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Hl(e))}function Rl(){for(var e=this._name,t=this._id,n=Ko(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,u=0;u<a;++u)if(c=s[u]){var f=ye(c,t);tn(c,e,n,u,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Ae(r,this._parents,e,n)}function Vl(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--o===0&&i()}};n.each(function(){var u=Ee(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),u.on=t}),o===0&&i()})}var Bl=0;function Ae(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ko(){return++Bl}var Ce=wt.prototype;Ae.prototype={constructor:Ae,select:vl,selectAll:bl,selectChild:Ce.selectChild,selectChildren:Ce.selectChildren,filter:hl,merge:gl,selection:El,transition:Rl,call:Ce.call,nodes:Ce.nodes,node:Ce.node,size:Ce.size,empty:Ce.empty,each:Ce.each,on:yl,attr:Ku,attrTween:nl,style:Il,styleTween:$l,text:zl,textTween:Ll,remove:wl,tween:Xu,delay:il,duration:cl,ease:ll,easeVarying:dl,end:Vl,[Symbol.iterator]:Ce[Symbol.iterator]};function Fl(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ol={time:null,delay:0,duration:250,ease:Fl};function jl(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Xl(e){var t,n;e instanceof Ae?(t=e._id,e=e._name):(t=Ko(),(n=Ol).time=Yn(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,u=0;u<a;++u)(c=s[u])&&tn(c,e,t,u,s,n||jl(c,t));return new Ae(r,this._parents,e,t)}wt.prototype.interrupt=Fu;wt.prototype.transition=Xl;const kt=e=>()=>e;function Yl(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Ie(e,t,n){this.k=e,this.x=t,this.y=n}Ie.prototype={constructor:Ie,scale:function(e){return e===1?this:new Ie(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ie(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 nn=new Ie(1,0,0);Qo.prototype=Ie.prototype;function Qo(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function yn(e){e.stopImmediatePropagation()}function it(e){e.preventDefault(),e.stopImmediatePropagation()}function Wl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function ql(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ar(){return this.__zoom||nn}function Gl(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Zl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ul(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Jo(){var e=Wl,t=ql,n=Ul,r=Gl,o=Zl,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Ht,u=Qt("start","zoom","end"),f,d,l,h=500,g=150,w=0,x=10;function m(y){y.property("__zoom",Ar).on("wheel.zoom",_,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",B).filter(o).on("touchstart.zoom",$).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(y,C,I,k){var z=y.selection?y.selection():y;z.property("__zoom",Ar),y!==z?N(y,C,I,k):z.interrupt().each(function(){E(this,arguments).event(k).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},m.scaleBy=function(y,C,I,k){m.scaleTo(y,function(){var z=this.__zoom.k,A=typeof C=="function"?C.apply(this,arguments):C;return z*A},I,k)},m.scaleTo=function(y,C,I,k){m.transform(y,function(){var z=t.apply(this,arguments),A=this.__zoom,H=I==null?v(z):typeof I=="function"?I.apply(this,arguments):I,F=A.invert(H),V=typeof C=="function"?C.apply(this,arguments):C;return n(p(b(A,V),H,F),z,s)},I,k)},m.translateBy=function(y,C,I,k){m.transform(y,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),s)},null,k)},m.translateTo=function(y,C,I,k,z){m.transform(y,function(){var A=t.apply(this,arguments),H=this.__zoom,F=k==null?v(A):typeof k=="function"?k.apply(this,arguments):k;return n(nn.translate(F[0],F[1]).scale(H.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof I=="function"?-I.apply(this,arguments):-I),A,s)},k,z)};function b(y,C){return C=Math.max(i[0],Math.min(i[1],C)),C===y.k?y:new Ie(C,y.x,y.y)}function p(y,C,I){var k=C[0]-I[0]*y.k,z=C[1]-I[1]*y.k;return k===y.x&&z===y.y?y:new Ie(y.k,k,z)}function v(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function N(y,C,I,k){y.on("start.zoom",function(){E(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(k).end()}).tween("zoom",function(){var z=this,A=arguments,H=E(z,A).event(k),F=t.apply(z,A),V=I==null?v(F):typeof I=="function"?I.apply(z,A):I,j=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),X=z.__zoom,G=typeof C=="function"?C.apply(z,A):C,J=c(X.invert(V).concat(j/X.k),G.invert(V).concat(j/G.k));return function(q){if(q===1)q=G;else{var L=J(q),O=j/L[2];q=new Ie(O,V[0]-L[0]*O,V[1]-L[1]*O)}H.zoom(null,q)}})}function E(y,C,I){return!I&&y.__zooming||new M(y,C)}function M(y,C){this.that=y,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,C),this.taps=0}M.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,C){return this.mouse&&y!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var C=ce(this.that).datum();u.call(y,this.that,new Yl(y,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:u}),C)}};function _(y,...C){if(!e.apply(this,arguments))return;var I=E(this,C).event(y),k=this.__zoom,z=Math.max(i[0],Math.min(i[1],k.k*Math.pow(2,r.apply(this,arguments)))),A=de(y);if(I.wheel)(I.mouse[0][0]!==A[0]||I.mouse[0][1]!==A[1])&&(I.mouse[1]=k.invert(I.mouse[0]=A)),clearTimeout(I.wheel);else{if(k.k===z)return;I.mouse=[A,k.invert(A)],Vt(this),I.start()}it(y),I.wheel=setTimeout(H,g),I.zoom("mouse",n(p(b(k,z),I.mouse[0],I.mouse[1]),I.extent,s));function H(){I.wheel=null,I.end()}}function S(y,...C){if(l||!e.apply(this,arguments))return;var I=y.currentTarget,k=E(this,C,!0).event(y),z=ce(y.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",j,!0),A=de(y,I),H=y.clientX,F=y.clientY;Ho(y.view),yn(y),k.mouse=[A,this.__zoom.invert(A)],Vt(this),k.start();function V(X){if(it(X),!k.moved){var G=X.clientX-H,J=X.clientY-F;k.moved=G*G+J*J>w}k.event(X).zoom("mouse",n(p(k.that.__zoom,k.mouse[0]=de(X,I),k.mouse[1]),k.extent,s))}function j(X){z.on("mousemove.zoom mouseup.zoom",null),Lo(X.view,k.moved),it(X),k.event(X).end()}}function B(y,...C){if(e.apply(this,arguments)){var I=this.__zoom,k=de(y.changedTouches?y.changedTouches[0]:y,this),z=I.invert(k),A=I.k*(y.shiftKey?.5:2),H=n(p(b(I,A),k,z),t.apply(this,C),s);it(y),a>0?ce(this).transition().duration(a).call(N,H,k,y):ce(this).call(m.transform,H,k,y)}}function $(y,...C){if(e.apply(this,arguments)){var I=y.touches,k=I.length,z=E(this,C,y.changedTouches.length===k).event(y),A,H,F,V;for(yn(y),H=0;H<k;++H)F=I[H],V=de(F,this),V=[V,this.__zoom.invert(V),F.identifier],z.touch0?!z.touch1&&z.touch0[2]!==V[2]&&(z.touch1=V,z.taps=0):(z.touch0=V,A=!0,z.taps=1+!!f);f&&(f=clearTimeout(f)),A&&(z.taps<2&&(d=V[0],f=setTimeout(function(){f=null},h)),Vt(this),z.start())}}function R(y,...C){if(this.__zooming){var I=E(this,C).event(y),k=y.changedTouches,z=k.length,A,H,F,V;for(it(y),A=0;A<z;++A)H=k[A],F=de(H,this),I.touch0&&I.touch0[2]===H.identifier?I.touch0[0]=F:I.touch1&&I.touch1[2]===H.identifier&&(I.touch1[0]=F);if(H=I.that.__zoom,I.touch1){var j=I.touch0[0],X=I.touch0[1],G=I.touch1[0],J=I.touch1[1],q=(q=G[0]-j[0])*q+(q=G[1]-j[1])*q,L=(L=J[0]-X[0])*L+(L=J[1]-X[1])*L;H=b(H,Math.sqrt(q/L)),F=[(j[0]+G[0])/2,(j[1]+G[1])/2],V=[(X[0]+J[0])/2,(X[1]+J[1])/2]}else if(I.touch0)F=I.touch0[0],V=I.touch0[1];else return;I.zoom("touch",n(p(H,F,V),I.extent,s))}}function D(y,...C){if(this.__zooming){var I=E(this,C).event(y),k=y.changedTouches,z=k.length,A,H;for(yn(y),l&&clearTimeout(l),l=setTimeout(function(){l=null},h),A=0;A<z;++A)H=k[A],I.touch0&&I.touch0[2]===H.identifier?delete I.touch0:I.touch1&&I.touch1[2]===H.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(H=de(H,this),Math.hypot(d[0]-H[0],d[1]-H[1])<x)){var F=ce(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return m.wheelDelta=function(y){return arguments.length?(r=typeof y=="function"?y:kt(+y),m):r},m.filter=function(y){return arguments.length?(e=typeof y=="function"?y:kt(!!y),m):e},m.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:kt(!!y),m):o},m.extent=function(y){return arguments.length?(t=typeof y=="function"?y:kt([[+y[0][0],+y[0][1]],[+y[1][0],+y[1][1]]]),m):t},m.scaleExtent=function(y){return arguments.length?(i[0]=+y[0],i[1]=+y[1],m):[i[0],i[1]]},m.translateExtent=function(y){return arguments.length?(s[0][0]=+y[0][0],s[1][0]=+y[1][0],s[0][1]=+y[0][1],s[1][1]=+y[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(y){return arguments.length?(n=y,m):n},m.duration=function(y){return arguments.length?(a=+y,m):a},m.interpolate=function(y){return arguments.length?(c=y,m):c},m.on=function(){var y=u.on.apply(u,arguments);return y===u?m:y},m.clickDistance=function(y){return arguments.length?(w=(y=+y)*y,m):Math.sqrt(w)},m.tapDistance=function(y){return arguments.length?(x=+y,m):x},m}const me={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},gt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ei=["Enter"," ","Escape"],ti={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Je;(function(e){e.Strict="strict",e.Loose="loose"})(Je||(Je={}));var Fe;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Fe||(Fe={}));var pt;(function(e){e.Partial="partial",e.Full="full"})(pt||(pt={}));const ni={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Te;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Te||(Te={}));var qt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qt||(qt={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const kr={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},ri=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Kl=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gn=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),bt=(e,t=[0,0])=>{const{width:n,height:r}=xe(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},Ql=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((o,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):Gn(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,rn(o,Gt(a,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?on(r):{x:0,y:0,width:0,height:0}},_t=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=rn(n,Gt(o)),r=!0)}),r?on(n):{x:0,y:0,width:0,height:0}},Zn=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/o,c=(t.y-r)/o,u=t.width/o,f=t.height/o,d=[];for(const l of e.values()){const{measured:h,selectable:g=!0,hidden:w=!1}=l;if(s&&!g||w)continue;const x=h.width??l.width??l.initialWidth??0,m=h.height??l.height??l.initialHeight??0,{x:b,y:p}=l.internals.positionAbsolute,v=ai(a,c,u,f,b,p,x,m),N=x*m,E=i&&v>0;(!l.internals.handleBounds||E||v>=N||l.dragging)&&d.push(l)}return d},Jl=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function ef(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let i;if(t!=null&&t.includeHiddenNodes){const{width:s,height:a}=xe(o);i=s>0&&a>0}else i=!!(o.measured.width&&o.measured.height&&!o.hidden);i&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function tf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=ef(e,s),c=_t(a),u=Kn(c,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0}function oi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},f=s.origin??r;let d=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",me.error005());else{const{width:h,height:g}=xe(a);h&&g&&(d=[[c,u],[c+h,u+g]])}else a&&Ye(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const l=Ye(d)?Xe(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",me.error015())),{position:{x:l.x-c+(s.measured.width??0)*f[0],y:l.y-u+(s.measured.height??0)*f[1]},positionAbsolute:l}}async function nf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(l=>l.id)),s=[];for(const l of n){if(l.deletable===!1)continue;const h=i.has(l.id),g=!h&&l.parentId&&s.find(w=>w.id===l.parentId);(h||g)&&s.push(l)}const a=new Set(t.map(l=>l.id)),c=r.filter(l=>l.deletable!==!1),f=Jl(s,c);for(const l of c)a.has(l.id)&&!f.find(g=>g.id===l.id)&&f.push(l);if(!o)return{edges:f,nodes:s};const d=await o({nodes:s,edges:f});return typeof d=="boolean"?d?{edges:f,nodes:s}:{edges:[],nodes:[]}:d}const et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Xe=(e={x:0,y:0},t,n)=>({x:et(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:et(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ii(e,t,n){const{width:r,height:o}=xe(n),{x:i,y:s}=n.internals.positionAbsolute;return Xe(e,[[i,s],[i+r,s+o]],t)}const $r=(e,t,n)=>e<t?et(Math.abs(e-t),1,t)/t:e>n?-et(Math.abs(e-n),1,t)/t:0,Un=(e,t,n=15,r=40)=>{const o=$r(e.x,r,t.width-r)*n,i=$r(e.y,r,t.height-r)*n;return[o,i]},rn=(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)}),Dn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),on=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),mt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Gn(e)?e.internals.positionAbsolute:bt(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Gt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=Gn(e)?e.internals.positionAbsolute:bt(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},si=(e,t)=>on(rn(Dn(e),Dn(t))),ai=(e,t,n,r,o,i,s,a)=>{const c=Math.max(0,Math.min(e+n,o+s)-Math.max(e,o)),u=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(c*u)},Zt=(e,t)=>ai(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Pr=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ci=(e,t)=>(n,r)=>{},Et=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),St=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?Et(a,s):a},tt=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function qe(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function rf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=qe(e,n),o=qe(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=qe(e.top??e.y??0,n),o=qe(e.bottom??e.y??0,n),i=qe(e.left??e.x??0,t),s=qe(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function of(e,t,n,r,o,i){const{x:s,y:a}=tt(e,[t,n,r]),{x:c,y:u}=tt({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=o-c,d=i-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(f),bottom:Math.floor(d)}}const Kn=(e,t,n,r,o,i)=>{const s=rf(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),f=et(u,r,o),d=e.x+e.width/2,l=e.y+e.height/2,h=t/2-d*f,g=n/2-l*f,w=of(e,h,g,f,t,n),x={left:Math.min(w.left-s.left,0),top:Math.min(w.top-s.top,0),right:Math.min(w.right-s.right,0),bottom:Math.min(w.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:f}},yt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ye(e){return e!=null&&e!=="parent"}function xe(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function ui(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function li(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Tr(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function sf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function af(e){return{...ti,...e||{}}}function fi(e){return e===null?null:e?"valid":"invalid"}function ut(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=pe(e),a=St({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:u}=n?Et(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const Qn=e=>({width:e.offsetWidth,height:e.offsetHeight}),di=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},cf=["INPUT","SELECT","TEXTAREA"];function hi(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:cf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const gi=e=>"clientX"in e,pe=(e,t)=>{var i,s;const n=gi(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},zr=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Qn(s)}})};function pi({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+o*.375+s*.375+n*.125,u=t*.125+i*.375+a*.375+r*.125,f=Math.abs(c-e),d=Math.abs(u-t);return[c,u,f,d]}function $t(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Dr({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-$t(t-r,i),n];case W.Right:return[t+$t(r-t,i),n];case W.Top:return[t,n-$t(n-o,i)];case W.Bottom:return[t,n+$t(o-n,i)]}}function mi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=Dr({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[u,f]=Dr({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[d,l,h,g]=pi({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${a},${c} ${u},${f} ${r},${o}`,d,l,h,g]}function yi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,a=r<t?r+s:r-s;return[i,a,o,s]}function uf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,a=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+a}function lf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=rn(Gt(e),Gt(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return Zt(s,on(i))>0}const ff=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,df=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),hf=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",me.error006()),t;const r=n.getEdgeId||ff;let o;return ri(e)?o={...e}:o={...e,id:r(e)},df(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function xi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=yi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const Hr={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},gf=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Lr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function pf({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=Hr[t],c=Hr[r],u={x:e.x+a.x*i,y:e.y+a.y*i},f={x:n.x+c.x*i,y:n.y+c.y*i},d=gf({source:u,sourcePosition:t,target:f}),l=d.x!==0?"x":"y",h=d[l];let g=[],w,x;const m={x:0,y:0},b={x:0,y:0},[,,p,v]=yi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[l]*c[l]===-1){l==="x"?(w=o.x??u.x+(f.x-u.x)*s,x=o.y??(u.y+f.y)/2):(w=o.x??(u.x+f.x)/2,x=o.y??u.y+(f.y-u.y)*s);const _=[{x:w,y:u.y},{x:w,y:f.y}],S=[{x:u.x,y:x},{x:f.x,y:x}];a[l]===h?g=l==="x"?_:S:g=l==="x"?S:_}else{const _=[{x:u.x,y:f.y}],S=[{x:f.x,y:u.y}];if(l==="x"?g=a.x===h?S:_:g=a.y===h?_:S,t===r){const y=Math.abs(e[l]-n[l]);if(y<=i){const C=Math.min(i-1,i-y);a[l]===h?m[l]=(u[l]>e[l]?-1:1)*C:b[l]=(f[l]>n[l]?-1:1)*C}}if(t!==r){const y=l==="x"?"y":"x",C=a[l]===c[y],I=u[y]>f[y],k=u[y]<f[y];(a[l]===1&&(!C&&I||C&&k)||a[l]!==1&&(!C&&k||C&&I))&&(g=l==="x"?_:S)}const B={x:u.x+m.x,y:u.y+m.y},$={x:f.x+b.x,y:f.y+b.y},R=Math.max(Math.abs(B.x-g[0].x),Math.abs($.x-g[0].x)),D=Math.max(Math.abs(B.y-g[0].y),Math.abs($.y-g[0].y));R>=D?(w=(B.x+$.x)/2,x=g[0].y):(w=g[0].x,x=(B.y+$.y)/2)}const N={x:u.x+m.x,y:u.y+m.y},E={x:f.x+b.x,y:f.y+b.y};return[[e,...N.x!==g[0].x||N.y!==g[0].y?[N]:[],...g,...E.x!==g[g.length-1].x||E.y!==g[g.length-1].y?[E]:[],n],w,x,p,v]}function mf(e,t,n,r){const o=Math.min(Lr(e,t)/2,Lr(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+o*u},${s}Q ${i},${s} ${i},${s+o*f}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+o*c}Q ${i},${s} ${i+o*a},${s}`}function Hn({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:f=.5}){const[d,l,h,g,w]=pf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:u,stepPosition:f});let x=`M${d[0].x} ${d[0].y}`;for(let m=1;m<d.length-1;m++)x+=mf(d[m-1],d[m],d[m+1],s);return x+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[x,l,h,g,w]}function Rr(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function yf(e){var d;const{sourceNode:t,targetNode:n}=e;if(!Rr(t)||!Rr(n))return null;const r=t.internals.handleBounds||Vr(t.handles),o=n.internals.handleBounds||Vr(n.handles),i=Br((r==null?void 0:r.source)??[],e.sourceHandle),s=Br(e.connectionMode===Je.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(d=e.onError)==null||d.call(e,"008",me.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||W.Bottom,c=(s==null?void 0:s.position)||W.Top,u=We(t,i,a),f=We(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:a,targetPosition:c}}function Vr(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function We(e,t,n=W.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??xe(e);if(r)return{x:o+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:o+s/2,y:i};case W.Right:return{x:o+s,y:i+a/2};case W.Bottom:return{x:o+s/2,y:i+a};case W.Left:return{x:o,y:i+a/2}}}function Br(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ln(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function xf(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const u=Ln(c,t);i.has(u)||(s.push({id:u,color:c.color||n,...c}),i.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const wi=1e3,wf=10,Jn={nodeOrigin:[0,0],nodeExtent:gt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},vf={...Jn,checkEquality:!0};function er(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function bf(e,t,n){const r=er(Jn,n);for(const o of e.values())if(o.parentId)nr(o,e,t,r);else{const i=bt(o,r.nodeOrigin),s=Ye(o.extent)?o.extent:r.nodeExtent,a=Xe(i,s,xe(o));o.internals.positionAbsolute=a}}function _f(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function tr(e){return e==="manual"}function Rn(e,t,n,r={}){var f,d;const o=er(vf,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!tr(o.zIndexMode)?wi:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const l of e){let h=s.get(l.id);if(o.checkEquality&&l===(h==null?void 0:h.internals.userNode))t.set(l.id,h);else{const g=bt(l,o.nodeOrigin),w=Ye(l.extent)?l.extent:o.nodeExtent,x=Xe(g,w,xe(l));h={...o.defaults,...l,measured:{width:(f=l.measured)==null?void 0:f.width,height:(d=l.measured)==null?void 0:d.height},internals:{positionAbsolute:x,handleBounds:_f(l,h),z:vi(l,a,o.zIndexMode),userNode:l}},t.set(l.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),l.parentId&&nr(h,t,n,r,i),u||(u=l.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function Ef(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function nr(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=er(Jn,r),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ef(e,n),o&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++o.i,f.internals.z=f.internals.z+o.i*wf),o&&f.internals.rootParentIndex!==void 0&&(o.i=f.internals.rootParentIndex);const d=i&&!tr(c)?wi:0,{x:l,y:h,z:g}=Sf(e,f,s,a,d,c),{positionAbsolute:w}=e.internals,x=l!==w.x||h!==w.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:l,y:h}:w,z:g}})}function vi(e,t,n){const r=ge(e.zIndex)?e.zIndex:0;return tr(n)?r:r+(e.selected?t:0)}function Sf(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=xe(e),u=bt(e,n),f=Ye(e.extent)?Xe(u,e.extent,c):u;let d=Xe({x:s+f.x,y:a+f.y},r,c);e.extent==="parent"&&(d=ii(d,c,t));const l=vi(e,o,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=l?h+1:l}}function rr(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??mt(c),f=si(u,a.rect);i.set(a.parentId,{expandedRect:f,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},u)=>{var p;const f=c.internals.positionAbsolute,d=xe(c),l=c.origin??r,h=a.x<f.x?Math.round(Math.abs(f.x-a.x)):0,g=a.y<f.y?Math.round(Math.abs(f.y-a.y)):0,w=Math.max(d.width,Math.round(a.width)),x=Math.max(d.height,Math.round(a.height)),m=(w-d.width)*l[0],b=(x-d.height)*l[1];(h>0||g>0||m||b)&&(o.push({id:u,type:"position",position:{x:c.position.x-h+m,y:c.position.y-g+b}}),(p=n.get(u))==null||p.forEach(v=>{e.some(N=>N.id===v.id)||o.push({id:v.id,type:"position",position:{x:v.position.x+h,y:v.position.y+g}})})),(d.width<a.width||d.height<a.height||h||g)&&o.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:w+(h?l[0]*h-m:0),height:x+(g?l[1]*g-b:0)}})}),o}function Nf(e,t,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const u=[],f=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(f.transform),l=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const w=Qn(h.nodeElement),x=g.measured.width!==w.width||g.measured.height!==w.height;if(!!(w.width&&w.height&&(x||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ye(g.extent)?g.extent:i;let{positionAbsolute:v}=g.internals;if(g.parentId&&g.extent==="parent"){const E=t.get(g.parentId);E&&(v=ii(v,w,E))}else p&&(v=Xe(v,p,w));const N={...g,measured:w,internals:{...g.internals,positionAbsolute:v,handleBounds:{source:zr("source",h.nodeElement,b,d,g.id),target:zr("target",h.nodeElement,b,d,g.id)}}};t.set(g.id,N),g.parentId&&nr(N,t,n,{nodeOrigin:o,zIndexMode:s}),c=!0,x&&(u.push({id:g.id,type:"dimensions",dimensions:w}),g.expandParent&&g.parentId&&l.push({id:g.id,parentId:g.parentId,rect:mt(N,o)}))}}if(l.length>0){const h=rr(l,t,n,o);u.push(...h)}return{changes:u,updatedInternals:c}}async function Mf({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function Fr(e,t,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),i){s=`${o}-${e}-${i}`;const u=r.get(s)||new Map;r.set(s,u.set(n,t))}}function bi(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},u=`${o}-${s}--${i}-${a}`,f=`${i}-${a}--${o}-${s}`;Fr("source",c,f,e,o,s),Fr("target",c,u,e,i,a),t.set(r.id,r)}}function _i(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:_i(n,t):!1}function Or(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Cf(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!_i(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&o.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function xn({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[u,f]of t){const d=(s=n.get(u))==null?void 0:s.internals.userNode;d&&o.push({...d,position:f.position,dragging:r})}if(!e)return[o[0],o];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:o[0],o]}function If({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=Et(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Af({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},f=null,d=!1,l=null,h=!1,g=!1,w=null;function x({noDragClassName:b,handleSelector:p,domNode:v,isSelectable:N,nodeId:E,nodeClickDistance:M=0}){l=ce(v);function _({x:R,y:D}){const{nodeLookup:y,nodeExtent:C,snapGrid:I,snapToGrid:k,nodeOrigin:z,onNodeDrag:A,onSelectionDrag:H,onError:F,updateNodePositions:V}=t();i={x:R,y:D};let j=!1;const X=a.size>1,G=X&&C?Dn(_t(a)):null,J=X&&k?If({dragItems:a,snapGrid:I,x:R,y:D}):null;for(const[q,L]of a){if(!y.has(q))continue;let O={x:R-L.distance.x,y:D-L.distance.y};k&&(O=J?{x:Math.round(O.x+J.x),y:Math.round(O.y+J.y)}:Et(O,I));let Z=null;if(X&&C&&!L.extent&&G){const{positionAbsolute:K}=L.internals,Q=K.x-G.x+C[0][0],ee=K.x+L.measured.width-G.x2+C[1][0],ne=K.y-G.y+C[0][1],re=K.y+L.measured.height-G.y2+C[1][1];Z=[[Q,ne],[ee,re]]}const{position:U,positionAbsolute:Y}=oi({nodeId:q,nextPosition:O,nodeLookup:y,nodeExtent:Z||C,nodeOrigin:z,onError:F});j=j||L.position.x!==U.x||L.position.y!==U.y,L.position=U,L.internals.positionAbsolute=Y}if(g=g||j,!!j&&(V(a,!0),w&&(r||A||!E&&H))){const[q,L]=xn({nodeId:E,dragItems:a,nodeLookup:y});r==null||r(w,a,q,L),A==null||A(w,q,L),E||H==null||H(w,L)}}async function S(){if(!f)return;const{transform:R,panBy:D,autoPanSpeed:y,autoPanOnNodeDrag:C}=t();if(!C){c=!1,cancelAnimationFrame(s);return}const[I,k]=Un(u,f,y);(I!==0||k!==0)&&(i.x=(i.x??0)-I/R[2],i.y=(i.y??0)-k/R[2],await D({x:I,y:k})&&_(i)),s=requestAnimationFrame(S)}function B(R){var X;const{nodeLookup:D,multiSelectionActive:y,nodesDraggable:C,transform:I,snapGrid:k,snapToGrid:z,selectNodesOnDrag:A,onNodeDragStart:H,onSelectionDragStart:F,unselectNodesAndEdges:V}=t();d=!0,(!A||!N)&&!y&&E&&((X=D.get(E))!=null&&X.selected||V()),N&&A&&E&&(e==null||e(E));const j=ut(R.sourceEvent,{transform:I,snapGrid:k,snapToGrid:z,containerBounds:f});if(i=j,a=Cf(D,C,j,E),a.size>0&&(n||H||!E&&F)){const[G,J]=xn({nodeId:E,dragItems:a,nodeLookup:D});n==null||n(R.sourceEvent,a,G,J),H==null||H(R.sourceEvent,G,J),E||F==null||F(R.sourceEvent,J)}}const $=Ro().clickDistance(M).on("start",R=>{const{domNode:D,nodeDragThreshold:y,transform:C,snapGrid:I,snapToGrid:k}=t();f=(D==null?void 0:D.getBoundingClientRect())||null,h=!1,g=!1,w=R.sourceEvent,y===0&&B(R),i=ut(R.sourceEvent,{transform:C,snapGrid:I,snapToGrid:k,containerBounds:f}),u=pe(R.sourceEvent,f)}).on("drag",R=>{const{autoPanOnNodeDrag:D,transform:y,snapGrid:C,snapToGrid:I,nodeDragThreshold:k,nodeLookup:z}=t(),A=ut(R.sourceEvent,{transform:y,snapGrid:C,snapToGrid:I,containerBounds:f});if(w=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||E&&!z.has(E))&&(h=!0),!h){if(!c&&D&&d&&(c=!0,S()),!d){const H=pe(R.sourceEvent,f),F=H.x-u.x,V=H.y-u.y;Math.sqrt(F*F+V*V)>k&&B(R)}(i.x!==A.xSnapped||i.y!==A.ySnapped)&&a&&d&&(u=pe(R.sourceEvent,f),_(A))}}).on("end",R=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:D,updateNodePositions:y,onNodeDragStop:C,onSelectionDragStop:I}=t();if(g&&(y(a,!1),g=!1),o||C||!E&&I){const[k,z]=xn({nodeId:E,dragItems:a,nodeLookup:D,dragging:!1});o==null||o(R.sourceEvent,a,k,z),C==null||C(R.sourceEvent,k,z),E||I==null||I(R.sourceEvent,z)}}}).filter(R=>{const D=R.target;return!R.button&&(!b||!Or(D,`.${b}`,v))&&(!p||Or(D,p,v))});l.call($)}function m(){l==null||l.on(".drag",null)}return{update:x,destroy:m}}function kf(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Zt(o,mt(i))>0&&r.push(i);return r}const $f=250;function Pf(e,t,n,r){var a,c;let o=[],i=1/0;const s=kf(e,n,t+$f);for(const u of s){const f=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of f){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:l,y:h}=We(u,d,d.position,!0),g=Math.sqrt(Math.pow(l-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(o=[{...d,x:l,y:h}],i=g):g===i&&o.push({...d,x:l,y:h}))}}if(!o.length)return null;if(o.length>1){const u=r.type==="source"?"target":"source";return o.find(f=>f.type===u)??o[0]}return o[0]}function Ei(e,t,n,r,o,i=!1){var u,f,d;const s=r.get(e);if(!s)return null;const a=o==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((f=s.internals.handleBounds)==null?void 0:f.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(l=>l.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...We(s,c,c.position,!0)}:c}function Si(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Tf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ni=()=>!0;function zf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:f,flowId:d,panBy:l,cancelConnection:h,onConnectStart:g,onConnect:w,onConnectEnd:x,isValidConnection:m=Ni,onReconnectEnd:b,updateConnection:p,getTransform:v,getFromHandle:N,autoPanSpeed:E,dragThreshold:M=1,handleDomNode:_}){const S=di(e.target);let B=0,$;const{x:R,y:D}=pe(e),y=Si(i,_),C=a==null?void 0:a.getBoundingClientRect();let I=!1;if(!C||!y)return;const k=Ei(o,y,r,c,t);if(!k)return;let z=pe(e,C),A=!1,H=null,F=!1,V=null;function j(){if(!f||!C)return;const[U,Y]=Un(z,C,E);l({x:U,y:Y}),B=requestAnimationFrame(j)}const X={...k,nodeId:o,type:y,position:k.position},G=c.get(o);let q={inProgress:!0,isValid:null,from:We(G,X,W.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:G,to:z,toHandle:null,toPosition:kr[X.position],toNode:null,pointer:z};function L(){I=!0,p(q),g==null||g(e,{nodeId:o,handleId:r,handleType:y})}M===0&&L();function O(U){if(!I){const{x:re,y:le}=pe(U),we=re-R,ve=le-D;if(!(we*we+ve*ve>M*M))return;L()}if(!N()||!X){Z(U);return}const Y=v();z=pe(U,C),$=Pf(St(z,Y,!1,[1,1]),n,c,X),A||(j(),A=!0);const K=Mi(U,{handle:$,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:m,doc:S,lib:u,flowId:d,nodeLookup:c});V=K.handleDomNode,H=K.connection,F=Tf(!!$,K.isValid);const Q=c.get(o),ee=Q?We(Q,X,W.Left,!0):q.from,ne={...q,from:ee,isValid:F,to:K.toHandle&&F?tt({x:K.toHandle.x,y:K.toHandle.y},Y):z,toHandle:K.toHandle,toPosition:F&&K.toHandle?K.toHandle.position:kr[X.position],toNode:K.toHandle?c.get(K.toHandle.nodeId):null,pointer:z};p(ne),q=ne}function Z(U){if(!("touches"in U&&U.touches.length>0)){if(I){($||V)&&H&&F&&(w==null||w(H));const{inProgress:Y,...K}=q,Q={...K,toPosition:q.toHandle?q.toPosition:null};x==null||x(U,Q),i&&(b==null||b(U,Q))}h(),cancelAnimationFrame(B),A=!1,F=!1,H=null,V=null,S.removeEventListener("mousemove",O),S.removeEventListener("mouseup",Z),S.removeEventListener("touchmove",O),S.removeEventListener("touchend",Z)}}S.addEventListener("mousemove",O),S.addEventListener("mouseup",Z),S.addEventListener("touchmove",O),S.addEventListener("touchend",Z)}function Mi(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:u=Ni,nodeLookup:f}){const d=i==="target",l=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=pe(e),w=s.elementFromPoint(h,g),x=w!=null&&w.classList.contains(`${a}-flow__handle`)?w:l,m={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const b=Si(void 0,x),p=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),N=x.classList.contains("connectable"),E=x.classList.contains("connectableend");if(!p||!b)return m;const M={source:d?p:r,sourceHandle:d?v:o,target:d?r:p,targetHandle:d?o:v};m.connection=M;const S=N&&E&&(n===Je.Strict?d&&b==="source"||!d&&b==="target":p!==r||v!==o);m.isValid=S&&u(M),m.toHandle=Ei(p,b,v,f,n,!0)}return m}const Vn={onPointerDown:zf,isValid:Mi};function Df({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:u,zoomStep:f=1,pannable:d=!0,zoomable:l=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const v=n(),N=p.sourceEvent.ctrlKey&&yt()?10:1,E=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*f,M=v[2]*Math.pow(2,E*N);t.scaleTo(M)};let w=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(w=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const v=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const N=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],E=[N[0]-w[0],N[1]-w[1]];w=N;const M=r()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),_={x:v[0]-E[0]*M,y:v[1]-E[1]*M},S=[[0,0],[c,u]];t.setViewportConstrained({x:_.x,y:_.y,zoom:v[2]},S,a)},b=Jo().on("start",x).on("zoom",d?m:null).on("zoom.wheel",l?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:de}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),wn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),Pe=(e,t)=>e.target.closest(`.${t}`),Ci=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Hf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,vn=(e,t=0,n=Hf,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},Ii=e=>{const t=e.ctrlKey&&yt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Lf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return f=>{if(Pe(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(f.ctrlKey&&s){const x=de(f),m=Ii(f),b=d*Math.pow(2,m);r.scaleTo(n,b,x,f);return}const l=f.deltaMode===1?20:1;let h=o===Fe.Vertical?0:f.deltaX*l,g=o===Fe.Horizontal?0:f.deltaY*l;!yt()&&f.shiftKey&&o!==Fe.Vertical&&(h=f.deltaY*l,g=0),r.translateBy(n,-(h/d)*i,-(g/d)*i,{internal:!0});const w=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c==null||c(f,w):(e.isPanScrolling=!0,a==null||a(f,w)),e.panScrollTimeout=setTimeout(()=>{u==null||u(f,w),e.isPanScrolling=!1},150)}}function Rf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=Pe(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function Vf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=sn(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Bf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&Ci(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((a=i.sourceEvent)!=null&&a.internal)&&(o==null||o(i.sourceEvent,sn(i.transform)))}}function Ff({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&Ci(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=sn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Of({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:u,lib:f,connectionInProgress:d}){return l=>{var m;const h=t||n,g=r&&l.ctrlKey,w=l.type==="wheel";if(l.button===1&&l.type==="mousedown"&&(Pe(l,`${f}-flow__node`)||Pe(l,`${f}-flow__edge`)||Pe(l,`${f}-flow__selection`)||Pe(l,`${f}-flow__nodesselection`)))return!0;if(!o&&!h&&!i&&!s&&!r||a||d&&!w||Pe(l,c)&&w||Pe(l,u)&&(!w||i&&w&&!t)||!r&&l.ctrlKey&&w)return!1;if(!r&&l.type==="touchstart"&&((m=l.touches)==null?void 0:m.length)>1)return l.preventDefault(),!1;if(!h&&!i&&!g&&w||!o&&(l.type==="mousedown"||l.type==="touchstart")||Array.isArray(o)&&!o.includes(l.button)&&l.type==="mousedown")return!1;const x=Array.isArray(o)&&o.includes(l.button)||!l.button||l.button<=1;return(!l.ctrlKey||w||e)&&x}}function jf({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect();let d=[[0,0],[f.width,f.height]];const l=typeof ResizeObserver<"u"?new ResizeObserver(D=>{const y=D[0];y&&(d=[[0,0],[y.contentRect.width,y.contentRect.height]])}):null;l==null||l.observe(e);const h=Jo().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=ce(e).call(h);v({x:o.x,y:o.y,zoom:et(o.zoom,t,n)},[[0,0],[f.width,f.height]],r);const w=g.on("wheel.zoom"),x=g.on("dblclick.zoom");h.wheelDelta(Ii);async function m(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).transform(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}function b({noWheelClassName:D,noPanClassName:y,onPaneContextMenu:C,userSelectionActive:I,panOnScroll:k,panOnDrag:z,panOnScrollMode:A,panOnScrollSpeed:H,preventScrolling:F,zoomOnPinch:V,zoomOnScroll:j,zoomOnDoubleClick:X,panActivationKeyPressed:G=!1,zoomActivationKeyPressed:J,lib:q,onTransformChange:L,connectionInProgress:O,paneClickDistance:Z,selectionOnDrag:U}){I&&!u.isZoomingOrPanning&&p();const Y=k&&!J&&!I;h.clickDistance(U?1/0:!ge(Z)||Z<0?0:Z);const K=Y?Lf({zoomPanValues:u,noWheelClassName:D,d3Selection:g,d3Zoom:h,panOnScrollMode:A,panOnScrollSpeed:H,zoomOnPinch:V,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Rf({noWheelClassName:D,preventScrolling:F,d3ZoomHandler:w});g.on("wheel.zoom",K,{passive:!1});const Q=Vf({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});h.on("start",Q);const ee=Bf({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!C,onPanZoom:i,onTransformChange:L});h.on("zoom",ee);const ne=Ff({zoomPanValues:u,panOnDrag:z,panOnScroll:k,onPaneContextMenu:C,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=Of({panActivationKeyPressed:G,zoomActivationKeyPressed:J,panOnDrag:z,zoomOnScroll:j,panOnScroll:k,zoomOnDoubleClick:X,zoomOnPinch:V,userSelectionActive:I,noPanClassName:y,noWheelClassName:D,lib:q,connectionInProgress:O});h.filter(re),X?g.on("dblclick.zoom",x):g.on("dblclick.zoom",null)}function p(){h.on("zoom",null)}async function v(D,y,C){const I=wn(D),k=h==null?void 0:h.constrain()(I,y,C);return k&&await m(k),k}async function N(D,y){const C=wn(D);return await m(C,y),C}function E(D){if(g){const y=wn(D),C=g.property("__zoom");(C.k!==D.zoom||C.x!==D.x||C.y!==D.y)&&(h==null||h.transform(g,y,null,{sync:!0}))}}function M(){const D=g?Qo(g.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}async function _(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).scaleTo(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}async function S(D,y){return g?new Promise(C=>{h==null||h.interpolate((y==null?void 0:y.interpolate)==="linear"?ct:Ht).scaleBy(vn(g,y==null?void 0:y.duration,y==null?void 0:y.ease,()=>C(!0)),D)}):!1}function B(D){h==null||h.scaleExtent(D)}function $(D){h==null||h.translateExtent(D)}function R(D){const y=!ge(D)||D<0?0:D;h==null||h.clickDistance(y)}return{update:b,destroy:p,setViewport:N,setViewportConstrained:v,getViewport:M,scaleTo:_,scaleBy:S,setScaleExtent:B,setTranslateExtent:$,syncViewport:E,setClickDistance:R}}var nt;(function(e){e.Line="line",e.Handle="handle"})(nt||(nt={}));function Xf({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,a=n-r,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function jr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function ke(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function Pt(e,t,n){return Math.max(0,t-e,e-n)}function Xr(e,t){return e?!t:t}function Yf(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:f,isVertical:d}=t,l=f&&d,{xSnapped:h,ySnapped:g}=n,{minWidth:w,maxWidth:x,minHeight:m,maxHeight:b}=r,{x:p,y:v,width:N,height:E,aspectRatio:M}=e;let _=Math.floor(f?h-e.pointerX:0),S=Math.floor(d?g-e.pointerY:0);const B=N+(c?-_:_),$=E+(u?-S:S),R=-i[0]*N,D=-i[1]*E;let y=Pt(B,w,x),C=Pt($,m,b);if(s){let z=0,A=0;c&&_<0?z=ke(p+_+R,s[0][0]):!c&&_>0&&(z=$e(p+B+R,s[1][0])),u&&S<0?A=ke(v+S+D,s[0][1]):!u&&S>0&&(A=$e(v+$+D,s[1][1])),y=Math.max(y,z),C=Math.max(C,A)}if(a){let z=0,A=0;c&&_>0?z=$e(p+_,a[0][0]):!c&&_<0&&(z=ke(p+B,a[1][0])),u&&S>0?A=$e(v+S,a[0][1]):!u&&S<0&&(A=ke(v+$,a[1][1])),y=Math.max(y,z),C=Math.max(C,A)}if(o){if(f){const z=Pt(B/M,m,b)*M;if(y=Math.max(y,z),s){let A=0;!c&&!u||c&&!u&&l?A=$e(v+D+B/M,s[1][1])*M:A=ke(v+D+(c?_:-_)/M,s[0][1])*M,y=Math.max(y,A)}if(a){let A=0;!c&&!u||c&&!u&&l?A=ke(v+B/M,a[1][1])*M:A=$e(v+(c?_:-_)/M,a[0][1])*M,y=Math.max(y,A)}}if(d){const z=Pt($*M,w,x)/M;if(C=Math.max(C,z),s){let A=0;!c&&!u||u&&!c&&l?A=$e(p+$*M+R,s[1][0])/M:A=ke(p+(u?S:-S)*M+R,s[0][0])/M,C=Math.max(C,A)}if(a){let A=0;!c&&!u||u&&!c&&l?A=ke(p+$*M,a[1][0])/M:A=$e(p+(u?S:-S)*M,a[0][0])/M,C=Math.max(C,A)}}}S=S+(S<0?C:-C),_=_+(_<0?y:-y),o&&(l?B>$*M?S=(Xr(c,u)?-_:_)/M:_=(Xr(c,u)?-S:S)*M:f?(S=_/M,u=c):(_=S*M,c=u));const I=c?p+_:p,k=u?v+S:v;return{width:N+(c?-_:_),height:E+(u?-S:S),x:i[0]*_*(c?-1:1)+I,y:i[1]*S*(u?-1:1)+k}}const Ai={width:0,height:0,x:0,y:0},Wf={...Ai,pointerX:0,pointerY:0,aspectRatio:1};function qf(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[r-a,o-c],[r+i-a,o+s-c]]}function Gf({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:jr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:f,keepAspectRatio:d,resizeDirection:l,onResizeStart:h,onResize:g,onResizeEnd:w,shouldResize:x}){let m={...Ai},b={...Wf};s={boundaries:f,resizeDirection:l,keepAspectRatio:d,controlDirection:jr(u)};let p,v=null,N=[],E,M,_,S=!1;const B=Ro().on("start",$=>{const{nodeLookup:R,transform:D,snapGrid:y,snapToGrid:C,nodeOrigin:I,paneDomNode:k}=n();if(p=R.get(t),!p)return;v=(k==null?void 0:k.getBoundingClientRect())??null;const{xSnapped:z,ySnapped:A}=ut($.sourceEvent,{transform:D,snapGrid:y,snapToGrid:C,containerBounds:v});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:z,pointerY:A,aspectRatio:m.width/m.height},E=void 0,M=Ye(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(E=R.get(p.parentId)),E&&p.extent==="parent"&&(M=[[0,0],[E.measured.width,E.measured.height]]),N=[],_=void 0;for(const[H,F]of R)if(F.parentId===t&&(N.push({id:H,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const V=qf(F,p,F.origin??I);_?_=[[Math.min(V[0][0],_[0][0]),Math.min(V[0][1],_[0][1])],[Math.max(V[1][0],_[1][0]),Math.max(V[1][1],_[1][1])]]:_=V}h==null||h($,{...m})}).on("drag",$=>{const{transform:R,snapGrid:D,snapToGrid:y,nodeOrigin:C}=n(),I=ut($.sourceEvent,{transform:R,snapGrid:D,snapToGrid:y,containerBounds:v}),k=[];if(!p)return;const{x:z,y:A,width:H,height:F}=m,V={},j=p.origin??C,{width:X,height:G,x:J,y:q}=Yf(b,s.controlDirection,I,s.boundaries,s.keepAspectRatio,j,M,_),L=X!==H,O=G!==F,Z=J!==z&&L,U=q!==A&&O;if(!Z&&!U&&!L&&!O)return;if((Z||U||j[0]===1||j[1]===1)&&(V.x=Z?J:m.x,V.y=U?q:m.y,m.x=V.x,m.y=V.y,N.length>0)){const ee=J-z,ne=q-A;for(const re of N)re.position={x:re.position.x-ee+j[0]*(X-H),y:re.position.y-ne+j[1]*(G-F)},k.push(re)}if((L||O)&&(V.width=L&&(!s.resizeDirection||s.resizeDirection==="horizontal")?X:m.width,V.height=O&&(!s.resizeDirection||s.resizeDirection==="vertical")?G:m.height,m.width=V.width,m.height=V.height),E&&p.expandParent){const ee=j[0]*(V.width??0);V.x&&V.x<ee&&(m.x=ee,b.x=b.x-(V.x-ee));const ne=j[1]*(V.height??0);V.y&&V.y<ne&&(m.y=ne,b.y=b.y-(V.y-ne))}const Y=Xf({width:m.width,prevWidth:H,height:m.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),K={...m,direction:Y};(x==null?void 0:x($,K))!==!1&&(S=!0,g==null||g($,K),r(V,k))}).on("end",$=>{S&&(w==null||w($,{...m}),o==null||o({...m}),S=!1)});i.call(B)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var bn={exports:{}},_n={},En={exports:{}},Sn={};/**
2
2
  * @license React
3
3
  * use-sync-external-store-shim.production.js
4
4
  *