ima2-gen 2.0.0 → 2.0.2
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.
- package/CHANGELOG.md +150 -0
- package/README.md +12 -12
- package/bin/commands/backfillThumbs.js +24 -0
- package/bin/commands/edit.js +7 -6
- package/bin/commands/gen.js +13 -6
- package/bin/commands/multimode.js +5 -4
- package/bin/commands/node.js +4 -4
- package/bin/ima2.js +21 -11
- package/bin/lib/config-store.js +1 -1
- package/docs/API.md +184 -10
- package/docs/CLI.md +11 -4
- package/docs/FAQ.ko.md +16 -0
- package/docs/FAQ.md +30 -0
- package/docs/PROMPT_STUDIO.md +3 -1
- package/docs/README.ko.md +7 -3
- package/docs/migration/runtime-test-inventory.md +17 -1
- package/lib/agentImageVideoGen.js +261 -0
- package/lib/agentRuntime.js +11 -260
- package/lib/agentSettings.js +1 -1
- package/lib/agyImageAdapter.js +259 -0
- package/lib/capabilities.js +2 -1
- package/lib/configKeys.js +1 -1
- package/lib/errorClassify.js +8 -7
- package/lib/eventBus.js +71 -0
- package/lib/geminiApiImageAdapter.js +179 -0
- package/lib/generationErrors.js +3 -1
- package/lib/grokImageAdapter.js +74 -128
- package/lib/grokImageCore.js +153 -0
- package/lib/grokMultimodeAdapter.js +7 -4
- package/lib/grokRuntime.js +3 -0
- package/lib/grokSizeMapper.js +13 -1
- package/lib/grokVideoAdapter.js +14 -7
- package/lib/grokVideoCanvas.js +13 -0
- package/lib/grokVideoPlannerPrompt.js +53 -6
- package/lib/historyList.js +19 -2
- package/lib/imageModels.js +15 -0
- package/lib/imageThumb.js +38 -0
- package/lib/inflight.js +54 -17
- package/lib/multimodeHelpers.js +10 -0
- package/lib/nodeHelpers.js +59 -0
- package/lib/oauthProxy/prompts.js +30 -36
- package/lib/promptBuilder/systemPrompt.js +2 -5
- package/lib/promptSafetyPolicy.js +1 -5
- package/lib/providerOptions.js +36 -1
- package/lib/responsesFallback.js +53 -44
- package/lib/routeHelpers.js +44 -0
- package/lib/runtimeContext.js +27 -0
- package/lib/ssePublish.js +12 -0
- package/lib/storageMigration.js +1 -1
- package/lib/storyboardPrefix.js +28 -0
- package/lib/thumbBackfill.js +70 -0
- package/lib/vertexAuth.js +44 -0
- package/lib/videoThumb.js +60 -0
- package/package.json +7 -2
- package/routes/agy.js +44 -0
- package/routes/auth.js +242 -0
- package/routes/edit.js +48 -8
- package/routes/events.js +78 -0
- package/routes/generate.js +135 -135
- package/routes/history.js +13 -0
- package/routes/index.js +8 -0
- package/routes/keys.js +254 -0
- package/routes/multimode.js +138 -62
- package/routes/nodes.js +107 -129
- package/routes/quota.js +58 -7
- package/routes/video.js +107 -20
- package/server.js +123 -0
- package/skills/ima2/SKILL.md +98 -21
- package/ui/dist/.vite/manifest.json +12 -12
- package/ui/dist/assets/AgentWorkspace-Dth6YijN.js +3 -0
- package/ui/dist/assets/{CardNewsWorkspace-BN-ga1lG.js → CardNewsWorkspace-Dav3K5CT.js} +2 -2
- package/ui/dist/assets/{NodeCanvas-BbMa4IhI.js → NodeCanvas-C4ifFzB1.js} +2 -2
- package/ui/dist/assets/{PromptBuilderPanel-DRwBJRDQ.js → PromptBuilderPanel-CEcyU9PL.js} +1 -1
- package/ui/dist/assets/{PromptImportDialog-Dp85kHCq.js → PromptImportDialog-CgQ94Gth.js} +2 -2
- package/ui/dist/assets/{PromptImportDiscoverySection-BE8Q8MLD.js → PromptImportDiscoverySection-CuzyzbNI.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-PtH5x0sc.js → PromptImportFolderSection-DHLGlO6l.js} +1 -1
- package/ui/dist/assets/{PromptLibraryPanel-FnM9tHI9.js → PromptLibraryPanel-BOe18we8.js} +2 -2
- package/ui/dist/assets/SettingsWorkspace-Cdgnm4Wa.js +1 -0
- package/ui/dist/assets/index-C5PSahkr.js +1 -0
- package/ui/dist/assets/index-Dn2AhL6d.css +1 -0
- package/ui/dist/assets/index-Tjqx6wUV.js +23 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/AgentWorkspace-C21zqdTZ.js +0 -3
- package/ui/dist/assets/SettingsWorkspace-MARPGyBL.js +0 -1
- package/ui/dist/assets/index-BAFI6htx.js +0 -42
- package/ui/dist/assets/index-BSXxr_Bt.js +0 -1
- package/ui/dist/assets/index-DS-ADE7U.css +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{r as Sr,g as ma,R as ya,a as T,j as E,u as Xn,b as J,i as gn,S as xa,f as wa,c as va,n as ba,d as _a,e as Ea}from"./index-BAFI6htx.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Na={value:()=>{}};function Qt(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Rt(n)}function Rt(e){this._=e}function Sa(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Rt.prototype=Qt.prototype={constructor:Rt,on:function(e,t){var n=this._,o=Sa(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Ca(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=xo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=xo(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Rt(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function Ca(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function xo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Na,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var kn="http://www.w3.org/1999/xhtml";const wo={svg:"http://www.w3.org/2000/svg",xhtml:kn,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)),wo.hasOwnProperty(t)?{space:wo[t],local:e}:e}function Ma(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===kn&&t.documentElement.namespaceURI===kn?t.createElement(e):t.createElementNS(n,e)}}function Ia(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Cr(e){var t=Jt(e);return(t.local?Ia:Ma)(t)}function ka(){}function Yn(e){return e==null?ka:function(){return this.querySelector(e)}}function Aa(e){typeof e!="function"&&(e=Yn(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new ue(o,this._parents)}function Pa(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function $a(){return[]}function Mr(e){return e==null?$a:function(){return this.querySelectorAll(e)}}function Da(e){return function(){return Pa(e.apply(this,arguments))}}function Ta(e){typeof e=="function"?e=Da(e):e=Mr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(o.push(e.call(l,l.__data__,c,s)),r.push(l));return new ue(o,r)}function Ir(e){return function(){return this.matches(e)}}function kr(e){return function(t){return t.matches(e)}}var Ra=Array.prototype.find;function za(e){return function(){return Ra.call(this.children,e)}}function Ha(){return this.firstElementChild}function La(e){return this.select(e==null?Ha:za(typeof e=="function"?e:kr(e)))}var Ba=Array.prototype.filter;function Va(){return Array.from(this.children)}function Oa(e){return function(){return Ba.call(this.children,e)}}function ja(e){return this.selectAll(e==null?Va:Oa(typeof e=="function"?e:kr(e)))}function Fa(e){typeof e!="function"&&(e=Ir(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new ue(o,this._parents)}function Ar(e){return new Array(e.length)}function Xa(){return new ue(this._enter||this._groups.map(Ar),this._parents)}function Ot(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ot.prototype={constructor:Ot,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 Ya(e){return function(){return e}}function Wa(e,t,n,o,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Ot(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Za(e,t,n,o,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,f=new Array(d),h;for(a=0;a<d;++a)(l=t[a])&&(f[a]=h=s.call(l,l.__data__,a,t)+"",c.has(h)?r[a]=l:c.set(h,l));for(a=0;a<u;++a)h=s.call(e,i[a],a,i)+"",(l=c.get(h))?(o[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new Ot(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(f[a])===l&&(r[a]=l)}function Ga(e){return e.__data__}function qa(e,t){if(!arguments.length)return Array.from(this,Ga);var n=t?Za:Wa,o=this._parents,r=this._groups;typeof e!="function"&&(e=Ya(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=o[c],u=r[c],f=u.length,h=Ua(e.call(d,d&&d.__data__,c,o)),g=h.length,y=a[c]=new Array(g),x=s[c]=new Array(g),m=l[c]=new Array(f);n(d,u,y,x,m,h,t);for(var b=0,p=0,w,S;b<g;++b)if(w=y[b]){for(b>=p&&(p=b+1);!(S=x[p])&&++p<g;);w._next=S||null}}return s=new ue(s,o),s._enter=a,s._exit=l,s}function Ua(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ka(){return new ue(this._exit||this._groups.map(Ar),this._parents)}function Qa(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Ja(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=n[l],d=o[l],u=c.length,f=a[l]=new Array(u),h,g=0;g<u;++g)(h=c[g]||d[g])&&(f[g]=h);for(;l<r;++l)a[l]=n[l];return new ue(a,this._parents)}function ec(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function tc(e){e||(e=nc);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new ue(r,this._parents).order()}function nc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function oc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function rc(){return Array.from(this)}function ic(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function sc(){let e=0;for(const t of this)++e;return e}function ac(){return!this.node()}function cc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function lc(e){return function(){this.removeAttribute(e)}}function uc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dc(e,t){return function(){this.setAttribute(e,t)}}function fc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function gc(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 pc(e,t){var n=Jt(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?uc:lc:typeof t=="function"?n.local?gc:hc:n.local?fc:dc)(n,t))}function Pr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function mc(e){return function(){this.style.removeProperty(e)}}function yc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function wc(e,t,n){return arguments.length>1?this.each((t==null?mc:typeof t=="function"?xc:yc)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Pr(e).getComputedStyle(e,null).getPropertyValue(t)}function vc(e){return function(){delete this[e]}}function bc(e,t){return function(){this[e]=t}}function _c(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ec(e,t){return arguments.length>1?this.each((t==null?vc:typeof t=="function"?_c:bc)(e,t)):this.node()[e]}function $r(e){return e.trim().split(/^|\s+/)}function Wn(e){return e.classList||new Dr(e)}function Dr(e){this._node=e,this._names=$r(e.getAttribute("class")||"")}Dr.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 Tr(e,t){for(var n=Wn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Rr(e,t){for(var n=Wn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Nc(e){return function(){Tr(this,e)}}function Sc(e){return function(){Rr(this,e)}}function Cc(e,t){return function(){(t.apply(this,arguments)?Tr:Rr)(this,e)}}function Mc(e,t){var n=$r(e+"");if(arguments.length<2){for(var o=Wn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Cc:t?Nc:Sc)(n,t))}function Ic(){this.textContent=""}function kc(e){return function(){this.textContent=e}}function Ac(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Pc(e){return arguments.length?this.each(e==null?Ic:(typeof e=="function"?Ac:kc)(e)):this.node().textContent}function $c(){this.innerHTML=""}function Dc(e){return function(){this.innerHTML=e}}function Tc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Rc(e){return arguments.length?this.each(e==null?$c:(typeof e=="function"?Tc:Dc)(e)):this.node().innerHTML}function zc(){this.nextSibling&&this.parentNode.appendChild(this)}function Hc(){return this.each(zc)}function Lc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Bc(){return this.each(Lc)}function Vc(e){var t=typeof e=="function"?e:Cr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Oc(){return null}function jc(e,t){var n=typeof e=="function"?e:Cr(e),o=t==null?Oc:typeof t=="function"?t:Yn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Fc(){var e=this.parentNode;e&&e.removeChild(this)}function Xc(){return this.each(Fc)}function Yc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Wc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Zc(e){return this.select(e?Wc:Yc)}function Gc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qc(e){return function(t){e.call(this,t,this.__data__)}}function Uc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Kc(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Qc(e,t,n){return function(){var o=this.__on,r,i=qc(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Jc(e,t,n){var o=Uc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=o[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Qc:Kc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function zr(e,t,n){var o=Pr(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function el(e,t){return function(){return zr(this,e,t)}}function tl(e,t){return function(){return zr(this,e,t.apply(this,arguments))}}function nl(e,t){return this.each((typeof t=="function"?tl:el)(e,t))}function*ol(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var Hr=[null];function ue(e,t){this._groups=e,this._parents=t}function xt(){return new ue([[document.documentElement]],Hr)}function rl(){return this}ue.prototype=xt.prototype={constructor:ue,select:Aa,selectAll:Ta,selectChild:La,selectChildren:ja,filter:Fa,data:qa,enter:Xa,exit:Ka,join:Qa,merge:Ja,selection:rl,order:ec,sort:tc,call:oc,nodes:rc,node:ic,size:sc,empty:ac,each:cc,attr:pc,style:wc,property:Ec,classed:Mc,text:Pc,html:Rc,raise:Hc,lower:Bc,append:Vc,insert:jc,remove:Xc,clone:Zc,datum:Gc,on:Jc,dispatch:nl,[Symbol.iterator]:ol};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Hr)}function il(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=il(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const sl={passive:!1},lt={capture:!0,passive:!1};function pn(e){e.stopImmediatePropagation()}function Xe(e){e.preventDefault(),e.stopImmediatePropagation()}function Lr(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",Xe,lt);"onselectstart"in t?n.on("selectstart.drag",Xe,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Br(e,t){var n=e.document.documentElement,o=le(e).on("dragstart.drag",null);t&&(o.on("click.drag",Xe,lt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ct=e=>()=>e;function An(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}An.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function al(e){return!e.ctrlKey&&!e.button}function cl(){return this.parentNode}function ll(e,t){return t??{x:e.x,y:e.y}}function ul(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vr(){var e=al,t=cl,n=ll,o=ul,r={},i=Qt("start","drag","end"),s=0,a,l,c,d,u=0;function f(w){w.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",m,sl).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,S){if(!(d||!e.call(this,w,S))){var N=p(this,t.call(this,w,S),w,S,"mouse");N&&(le(w.view).on("mousemove.drag",g,lt).on("mouseup.drag",y,lt),Lr(w.view),pn(w),c=!1,a=w.clientX,l=w.clientY,N("start",w))}}function g(w){if(Xe(w),!c){var S=w.clientX-a,N=w.clientY-l;c=S*S+N*N>u}r.mouse("drag",w)}function y(w){le(w.view).on("mousemove.drag mouseup.drag",null),Br(w.view,c),Xe(w),r.mouse("end",w)}function x(w,S){if(e.call(this,w,S)){var N=w.changedTouches,_=t.call(this,w,S),I=N.length,$,O;for($=0;$<I;++$)(O=p(this,_,w,S,N[$].identifier,N[$]))&&(pn(w),O("start",w,N[$]))}}function m(w){var S=w.changedTouches,N=S.length,_,I;for(_=0;_<N;++_)(I=r[S[_].identifier])&&(Xe(w),I("drag",w,S[_]))}function b(w){var S=w.changedTouches,N=S.length,_,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),_=0;_<N;++_)(I=r[S[_].identifier])&&(pn(w),I("end",w,S[_]))}function p(w,S,N,_,I,$){var O=i.copy(),A=de($||N,S),R,V,v;if((v=n.call(w,new An("beforestart",{sourceEvent:N,target:f,identifier:I,active:s,x:A[0],y:A[1],dx:0,dy:0,dispatch:O}),_))!=null)return R=v.x-A[0]||0,V=v.y-A[1]||0,function M(C,P,k){var D=A,H;switch(C){case"start":r[I]=M,H=s++;break;case"end":delete r[I],--s;case"drag":A=de(k||P,S),H=s;break}O.call(C,w,new An(C,{sourceEvent:P,subject:v,target:f,identifier:I,active:H,x:A[0]+R,y:A[1]+V,dx:A[0]-D[0],dy:A[1]-D[1],dispatch:O}),_)}}return f.filter=function(w){return arguments.length?(e=typeof w=="function"?w:Ct(!!w),f):e},f.container=function(w){return arguments.length?(t=typeof w=="function"?w:Ct(w),f):t},f.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Ct(w),f):n},f.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:Ct(!!w),f):o},f.on=function(){var w=i.on.apply(i,arguments);return w===i?f:w},f.clickDistance=function(w){return arguments.length?(u=(w=+w)*w,f):Math.sqrt(u)},f}function Zn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Or(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function wt(){}var ut=.7,jt=1/ut,Ye="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ye="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",dl=/^#([0-9a-f]{3,8})$/,fl=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),hl=new RegExp(`^rgb\\(${ye},${ye},${ye}\\)$`),gl=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${dt}\\)$`),pl=new RegExp(`^rgba\\(${ye},${ye},${ye},${dt}\\)$`),ml=new RegExp(`^hsl\\(${dt},${ye},${ye}\\)$`),yl=new RegExp(`^hsla\\(${dt},${ye},${ye},${dt}\\)$`),vo={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};Zn(wt,Re,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:bo,formatHex:bo,formatHex8:xl,formatHsl:wl,formatRgb:_o,toString:_o});function bo(){return this.rgb().formatHex()}function xl(){return this.rgb().formatHex8()}function wl(){return jr(this).formatHsl()}function _o(){return this.rgb().formatRgb()}function Re(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=dl.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Eo(t):n===3?new ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mt(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=fl.exec(e))?new ce(t[1],t[2],t[3],1):(t=hl.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=gl.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=pl.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ml.exec(e))?Co(t[1],t[2]/100,t[3]/100,1):(t=yl.exec(e))?Co(t[1],t[2]/100,t[3]/100,t[4]):vo.hasOwnProperty(e)?Eo(vo[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function Eo(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function Mt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ce(e,t,n,o)}function vl(e){return e instanceof wt||(e=Re(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function Pn(e,t,n,o){return arguments.length===1?vl(e):new ce(e,t,n,o??1)}function ce(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Zn(ce,Pn,Or(wt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(De(this.r),De(this.g),De(this.b),Ft(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:No,formatHex:No,formatHex8:bl,formatRgb:So,toString:So}));function No(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function bl(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function So(){const e=Ft(this.opacity);return`${e===1?"rgb(":"rgba("}${De(this.r)}, ${De(this.g)}, ${De(this.b)}${e===1?")":`, ${e})`}`}function Ft(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function De(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $e(e){return e=De(e),(e<16?"0":"")+e.toString(16)}function Co(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new fe(e,t,n,o)}function jr(e){if(e instanceof fe)return new fe(e.h,e.s,e.l,e.opacity);if(e instanceof wt||(e=Re(e)),!e)return new fe;if(e instanceof fe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new fe(s,a,l,e.opacity)}function _l(e,t,n,o){return arguments.length===1?jr(e):new fe(e,t,n,o??1)}function fe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Zn(fe,_l,Or(wt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new fe(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,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new ce(mn(e>=240?e-240:e+120,r,o),mn(e,r,o),mn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new fe(Mo(this.h),It(this.s),It(this.l),Ft(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=Ft(this.opacity);return`${e===1?"hsl(":"hsla("}${Mo(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Mo(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function mn(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 Gn=e=>()=>e;function El(e,t){return function(n){return e+n*t}}function Nl(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Sl(e){return(e=+e)==1?Fr:function(t,n){return n-t?Nl(t,n,e):Gn(isNaN(t)?n:t)}}function Fr(e,t){var n=t-e;return n?El(e,n):Gn(isNaN(e)?t:e)}const Xt=(function e(t){var n=Sl(t);function o(r,i){var s=n((r=Pn(r)).r,(i=Pn(i)).r),a=n(r.g,i.g),l=n(r.b,i.b),c=Fr(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return o.gamma=e,o})(1);function Cl(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function Ml(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Il(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=at(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function kl(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function me(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Al(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=at(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var $n=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yn=new RegExp($n.source,"g");function Pl(e){return function(){return e}}function $l(e){return function(t){return e(t)+""}}function Xr(e,t){var n=$n.lastIndex=yn.lastIndex=0,o,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(o=$n.exec(e))&&(r=yn.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:me(o,r)})),n=yn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?$l(l[0].x):Pl(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}function at(e,t){var n=typeof t,o;return t==null||n==="boolean"?Gn(t):(n==="number"?me:n==="string"?(o=Re(t))?(t=o,Xt):Xr:t instanceof Re?Xt:t instanceof Date?kl:Ml(t)?Cl:Array.isArray(t)?Il:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Al:me)(e,t)}var Io=180/Math.PI,Dn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yr(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Io,skewX:Math.atan(l)*Io,scaleX:s,scaleY:a}}var kt;function Dl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Dn:Yr(t.a,t.b,t.c,t.d,t.e,t.f)}function Tl(e){return e==null||(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",e),!(e=kt.transform.baseVal.consolidate()))?Dn:(e=e.matrix,Yr(e.a,e.b,e.c,e.d,e.e,e.f))}function Wr(e,t,n,o){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,h,g){if(c!==u||d!==f){var y=h.push("translate(",null,t,null,n);g.push({i:y-4,x:me(c,u)},{i:y-2,x:me(d,f)})}else(u||f)&&h.push("translate("+u+t+f+n)}function s(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,o)-2,x:me(c,d)})):d&&u.push(r(u)+"rotate("+d+o)}function a(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,o)-2,x:me(c,d)}):d&&u.push(r(u)+"skewX("+d+o)}function l(c,d,u,f,h,g){if(c!==u||d!==f){var y=h.push(r(h)+"scale(",null,",",null,")");g.push({i:y-4,x:me(c,u)},{i:y-2,x:me(d,f)})}else(u!==1||f!==1)&&h.push(r(h)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),s(c.rotate,d.rotate,u,f),a(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(h){for(var g=-1,y=f.length,x;++g<y;)u[(x=f[g]).i]=x.x(h);return u.join("")}}}var Rl=Wr(Dl,"px, ","px)","deg)"),zl=Wr(Tl,", ",")",")"),Hl=1e-12;function ko(e){return((e=Math.exp(e))+1/e)/2}function Ll(e){return((e=Math.exp(e))-1/e)/2}function Bl(e){return((e=Math.exp(2*e))-1)/(e+1)}const zt=(function e(t,n,o){function r(i,s){var a=i[0],l=i[1],c=i[2],d=s[0],u=s[1],f=s[2],h=d-a,g=u-l,y=h*h+g*g,x,m;if(y<Hl)m=Math.log(f/c)/t,x=function(_){return[a+_*h,l+_*g,c*Math.exp(t*_*m)]};else{var b=Math.sqrt(y),p=(f*f-c*c+o*y)/(2*c*n*b),w=(f*f-c*c-o*y)/(2*f*n*b),S=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(w*w+1)-w);m=(N-S)/t,x=function(_){var I=_*m,$=ko(S),O=c/(n*b)*($*Bl(t*I+S)-Ll(S));return[a+O*h,l+O*g,c*$/ko(t*I+S)]}}return x.duration=m*1e3*t/Math.SQRT2,x}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return e(s,a,l)},r})(Math.SQRT2,2,4);var Ze=0,it=0,ot=0,Zr=1e3,Yt,st,Wt=0,ze=0,en=0,ft=typeof performance=="object"&&performance.now?performance:Date,Gr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qn(){return ze||(Gr(Vl),ze=ft.now()+en)}function Vl(){ze=0}function Zt(){this._call=this._time=this._next=null}Zt.prototype=qr.prototype={constructor:Zt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?qn():+n)+(t==null?0:+t),!this._next&&st!==this&&(st?st._next=this:Yt=this,st=this),this._call=e,this._time=n,Tn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Tn())}};function qr(e,t,n){var o=new Zt;return o.restart(e,t,n),o}function Ol(){qn(),++Ze;for(var e=Yt,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function Ao(){ze=(Wt=ft.now())+en,Ze=it=0;try{Ol()}finally{Ze=0,Fl(),ze=0}}function jl(){var e=ft.now(),t=e-Wt;t>Zr&&(en-=t,Wt=e)}function Fl(){for(var e,t=Yt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Yt=n);st=e,Tn(o)}function Tn(e){if(!Ze){it&&(it=clearTimeout(it));var t=e-ze;t>24?(e<1/0&&(it=setTimeout(Ao,e-ft.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Wt=ft.now(),ot=setInterval(jl,Zr)),Ze=1,Gr(Ao))}}function Po(e,t,n){var o=new Zt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Xl=Qt("start","end","cancel","interrupt"),Yl=[],Ur=0,$o=1,Rn=2,Ht=3,Do=4,zn=5,Lt=6;function tn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Wl(e,n,{name:t,index:o,group:r,on:Xl,tween:Yl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ur})}function Un(e,t){var n=pe(e,t);if(n.state>Ur)throw new Error("too late; already scheduled");return n}function we(e,t){var n=pe(e,t);if(n.state>Ht)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Wl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=qr(i,0,n.time);function i(c){n.state=$o,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var d,u,f,h;if(n.state!==$o)return l();for(d in o)if(h=o[d],h.name===n.name){if(h.state===Ht)return Po(s);h.state===Do?(h.state=Lt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[d]):+d<t&&(h.state=Lt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[d])}if(Po(function(){n.state===Ht&&(n.state=Do,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Rn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Rn){for(n.state=Ht,r=new Array(f=n.tween.length),d=0,u=-1;d<f;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=h);r.length=u+1}}function a(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=zn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);n.state===zn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Lt,n.timer.stop(),delete o[t];for(var c in o)return;delete e.__transition}}function Bt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>Rn&&o.state<zn,o.state=Lt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Zl(e){return this.each(function(){Bt(this,e)})}function Gl(e,t){var n,o;return function(){var r=we(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function ql(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=we(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Ul(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=pe(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?Gl:ql)(n,e,t))}function Kn(e,t,n){var o=e._id;return e.each(function(){var r=we(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return pe(r,o).value[t]}}function Kr(e,t){var n;return(typeof t=="number"?me:t instanceof Re?Xt:(n=Re(t))?(t=n,Xt):Xr)(e,t)}function Kl(e){return function(){this.removeAttribute(e)}}function Ql(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Jl(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function eu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function tu(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function nu(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function ou(e,t){var n=Jt(e),o=n==="transform"?zl:Kr;return this.attrTween(e,typeof t=="function"?(n.local?nu:tu)(n,o,Kn(this,"attr."+e,t)):t==null?(n.local?Ql:Kl)(n):(n.local?eu:Jl)(n,o,t))}function ru(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function iu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function su(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&iu(e,i)),n}return r._value=t,r}function au(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&ru(e,i)),n}return r._value=t,r}function cu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Jt(e);return this.tween(n,(o.local?su:au)(o,t))}function lu(e,t){return function(){Un(this,e).delay=+t.apply(this,arguments)}}function uu(e,t){return t=+t,function(){Un(this,e).delay=t}}function du(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lu:uu)(t,e)):pe(this.node(),t).delay}function fu(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function hu(e,t){return t=+t,function(){we(this,e).duration=t}}function gu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?fu:hu)(t,e)):pe(this.node(),t).duration}function pu(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function mu(e){var t=this._id;return arguments.length?this.each(pu(t,e)):pe(this.node(),t).ease}function yu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;we(this,e).ease=n}}function xu(e){if(typeof e!="function")throw new Error;return this.each(yu(this._id,e))}function wu(e){typeof e!="function"&&(e=Ir(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ee(o,this._parents,this._name,this._id)}function vu(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var l=t[a],c=n[a],d=l.length,u=s[a]=new Array(d),f,h=0;h<d;++h)(f=l[h]||c[h])&&(u[h]=f);for(;a<o;++a)s[a]=t[a];return new Ee(s,this._parents,this._name,this._id)}function bu(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 _u(e,t,n){var o,r,i=bu(t)?Un:we;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Eu(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(_u(n,e,t))}function Nu(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Su(){return this.on("end.remove",Nu(this._id))}function Cu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Yn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],l=a.length,c=i[s]=new Array(l),d,u,f=0;f<l;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,tn(c[f],t,n,f,c,pe(d,n)));return new Ee(i,this._parents,t,n)}function Mu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l=o[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),h,g=pe(d,n),y=0,x=f.length;y<x;++y)(h=f[y])&&tn(h,t,n,y,f,g);i.push(f),s.push(d)}return new Ee(i,s,t,n)}var Iu=xt.prototype.constructor;function ku(){return new Iu(this._groups,this._parents)}function Au(e,t){var n,o,r;return function(){var i=We(this,e),s=(this.style.removeProperty(e),We(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Qr(e){return function(){this.style.removeProperty(e)}}function Pu(e,t,n){var o,r=n+"",i;return function(){var s=We(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function $u(e,t,n){var o,r,i;return function(){var s=We(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),We(this,e))),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}function Du(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var l=we(this,e),c=l.on,d=l.value[i]==null?a||(a=Qr(t)):void 0;(c!==n||r!==d)&&(o=(n=c).copy()).on(s,r=d),l.on=o}}function Tu(e,t,n){var o=(e+="")=="transform"?Rl:Kr;return t==null?this.styleTween(e,Au(e,o)).on("end.style."+e,Qr(e)):typeof t=="function"?this.styleTween(e,$u(e,o,Kn(this,"style."+e,t))).each(Du(this._id,e)):this.styleTween(e,Pu(e,o,t),n).on("end.style."+e,null)}function Ru(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function zu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Ru(e,s,n)),o}return i._value=t,i}function Hu(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,zu(e,t,n??""))}function Lu(e){return function(){this.textContent=e}}function Bu(e){return function(){var t=e(this);this.textContent=t??""}}function Vu(e){return this.tween("text",typeof e=="function"?Bu(Kn(this,"text",e)):Lu(e==null?"":e+""))}function Ou(e){return function(t){this.textContent=e.call(this,t)}}function ju(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Ou(r)),t}return o._value=e,o}function Fu(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,ju(e))}function Xu(){for(var e=this._name,t=this._id,n=Jr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=pe(l,t);tn(l,e,n,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ee(o,this._parents,e,n)}function Yu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};n.each(function(){var c=we(this,o),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Wu=0;function Ee(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Jr(){return++Wu}var be=xt.prototype;Ee.prototype={constructor:Ee,select:Cu,selectAll:Mu,selectChild:be.selectChild,selectChildren:be.selectChildren,filter:wu,merge:vu,selection:ku,transition:Xu,call:be.call,nodes:be.nodes,node:be.node,size:be.size,empty:be.empty,each:be.each,on:Eu,attr:ou,attrTween:cu,style:Tu,styleTween:Hu,text:Vu,textTween:Fu,remove:Su,tween:Ul,delay:du,duration:gu,ease:mu,easeVarying:xu,end:Yu,[Symbol.iterator]:be[Symbol.iterator]};function Zu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Gu={time:null,delay:0,duration:250,ease:Zu};function qu(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 Uu(e){var t,n;e instanceof Ee?(t=e._id,e=e._name):(t=Jr(),(n=Gu).time=qn(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&tn(l,e,t,c,s,n||qu(l,t));return new Ee(o,this._parents,e,t)}xt.prototype.interrupt=Zl;xt.prototype.transition=Uu;const At=e=>()=>e;function Ku(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function _e(e,t,n){this.k=e,this.x=t,this.y=n}_e.prototype={constructor:_e,scale:function(e){return e===1?this:new _e(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _e(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 _e(1,0,0);ei.prototype=_e.prototype;function ei(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function xn(e){e.stopImmediatePropagation()}function rt(e){e.preventDefault(),e.stopImmediatePropagation()}function Qu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ju(){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 To(){return this.__zoom||nn}function ed(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function td(){return navigator.maxTouchPoints||"ontouchstart"in this}function nd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function ti(){var e=Qu,t=Ju,n=nd,o=ed,r=td,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=zt,c=Qt("start","zoom","end"),d,u,f,h=500,g=150,y=0,x=10;function m(v){v.property("__zoom",To).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(v,M,C,P){var k=v.selection?v.selection():v;k.property("__zoom",To),v!==k?S(v,M,C,P):k.interrupt().each(function(){N(this,arguments).event(P).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},m.scaleBy=function(v,M,C,P){m.scaleTo(v,function(){var k=this.__zoom.k,D=typeof M=="function"?M.apply(this,arguments):M;return k*D},C,P)},m.scaleTo=function(v,M,C,P){m.transform(v,function(){var k=t.apply(this,arguments),D=this.__zoom,H=C==null?w(k):typeof C=="function"?C.apply(this,arguments):C,B=D.invert(H),L=typeof M=="function"?M.apply(this,arguments):M;return n(p(b(D,L),H,B),k,s)},C,P)},m.translateBy=function(v,M,C,P){m.transform(v,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,P)},m.translateTo=function(v,M,C,P,k){m.transform(v,function(){var D=t.apply(this,arguments),H=this.__zoom,B=P==null?w(D):typeof P=="function"?P.apply(this,arguments):P;return n(nn.translate(B[0],B[1]).scale(H.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof C=="function"?-C.apply(this,arguments):-C),D,s)},P,k)};function b(v,M){return M=Math.max(i[0],Math.min(i[1],M)),M===v.k?v:new _e(M,v.x,v.y)}function p(v,M,C){var P=M[0]-C[0]*v.k,k=M[1]-C[1]*v.k;return P===v.x&&k===v.y?v:new _e(v.k,P,k)}function w(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function S(v,M,C,P){v.on("start.zoom",function(){N(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(P).end()}).tween("zoom",function(){var k=this,D=arguments,H=N(k,D).event(P),B=t.apply(k,D),L=C==null?w(B):typeof C=="function"?C.apply(k,D):C,Z=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),F=k.__zoom,z=typeof M=="function"?M.apply(k,D):M,X=l(F.invert(L).concat(Z/F.k),z.invert(L).concat(Z/z.k));return function(Y){if(Y===1)Y=z;else{var j=X(Y),G=Z/j[2];Y=new _e(G,L[0]-j[0]*G,L[1]-j[1]*G)}H.zoom(null,Y)}})}function N(v,M,C){return!C&&v.__zooming||new _(v,M)}function _(v,M){this.that=v,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,M),this.taps=0}_.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,M){return this.mouse&&v!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var M=le(this.that).datum();c.call(v,this.that,new Ku(v,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:c}),M)}};function I(v,...M){if(!e.apply(this,arguments))return;var C=N(this,M).event(v),P=this.__zoom,k=Math.max(i[0],Math.min(i[1],P.k*Math.pow(2,o.apply(this,arguments)))),D=de(v);if(C.wheel)(C.mouse[0][0]!==D[0]||C.mouse[0][1]!==D[1])&&(C.mouse[1]=P.invert(C.mouse[0]=D)),clearTimeout(C.wheel);else{if(P.k===k)return;C.mouse=[D,P.invert(D)],Bt(this),C.start()}rt(v),C.wheel=setTimeout(H,g),C.zoom("mouse",n(p(b(P,k),C.mouse[0],C.mouse[1]),C.extent,s));function H(){C.wheel=null,C.end()}}function $(v,...M){if(f||!e.apply(this,arguments))return;var C=v.currentTarget,P=N(this,M,!0).event(v),k=le(v.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",Z,!0),D=de(v,C),H=v.clientX,B=v.clientY;Lr(v.view),xn(v),P.mouse=[D,this.__zoom.invert(D)],Bt(this),P.start();function L(F){if(rt(F),!P.moved){var z=F.clientX-H,X=F.clientY-B;P.moved=z*z+X*X>y}P.event(F).zoom("mouse",n(p(P.that.__zoom,P.mouse[0]=de(F,C),P.mouse[1]),P.extent,s))}function Z(F){k.on("mousemove.zoom mouseup.zoom",null),Br(F.view,P.moved),rt(F),P.event(F).end()}}function O(v,...M){if(e.apply(this,arguments)){var C=this.__zoom,P=de(v.changedTouches?v.changedTouches[0]:v,this),k=C.invert(P),D=C.k*(v.shiftKey?.5:2),H=n(p(b(C,D),P,k),t.apply(this,M),s);rt(v),a>0?le(this).transition().duration(a).call(S,H,P,v):le(this).call(m.transform,H,P,v)}}function A(v,...M){if(e.apply(this,arguments)){var C=v.touches,P=C.length,k=N(this,M,v.changedTouches.length===P).event(v),D,H,B,L;for(xn(v),H=0;H<P;++H)B=C[H],L=de(B,this),L=[L,this.__zoom.invert(L),B.identifier],k.touch0?!k.touch1&&k.touch0[2]!==L[2]&&(k.touch1=L,k.taps=0):(k.touch0=L,D=!0,k.taps=1+!!d);d&&(d=clearTimeout(d)),D&&(k.taps<2&&(u=L[0],d=setTimeout(function(){d=null},h)),Bt(this),k.start())}}function R(v,...M){if(this.__zooming){var C=N(this,M).event(v),P=v.changedTouches,k=P.length,D,H,B,L;for(rt(v),D=0;D<k;++D)H=P[D],B=de(H,this),C.touch0&&C.touch0[2]===H.identifier?C.touch0[0]=B:C.touch1&&C.touch1[2]===H.identifier&&(C.touch1[0]=B);if(H=C.that.__zoom,C.touch1){var Z=C.touch0[0],F=C.touch0[1],z=C.touch1[0],X=C.touch1[1],Y=(Y=z[0]-Z[0])*Y+(Y=z[1]-Z[1])*Y,j=(j=X[0]-F[0])*j+(j=X[1]-F[1])*j;H=b(H,Math.sqrt(Y/j)),B=[(Z[0]+z[0])/2,(Z[1]+z[1])/2],L=[(F[0]+X[0])/2,(F[1]+X[1])/2]}else if(C.touch0)B=C.touch0[0],L=C.touch0[1];else return;C.zoom("touch",n(p(H,B,L),C.extent,s))}}function V(v,...M){if(this.__zooming){var C=N(this,M).event(v),P=v.changedTouches,k=P.length,D,H;for(xn(v),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),D=0;D<k;++D)H=P[D],C.touch0&&C.touch0[2]===H.identifier?delete C.touch0:C.touch1&&C.touch1[2]===H.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(H=de(H,this),Math.hypot(u[0]-H[0],u[1]-H[1])<x)){var B=le(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return m.wheelDelta=function(v){return arguments.length?(o=typeof v=="function"?v:At(+v),m):o},m.filter=function(v){return arguments.length?(e=typeof v=="function"?v:At(!!v),m):e},m.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:At(!!v),m):r},m.extent=function(v){return arguments.length?(t=typeof v=="function"?v:At([[+v[0][0],+v[0][1]],[+v[1][0],+v[1][1]]]),m):t},m.scaleExtent=function(v){return arguments.length?(i[0]=+v[0],i[1]=+v[1],m):[i[0],i[1]]},m.translateExtent=function(v){return arguments.length?(s[0][0]=+v[0][0],s[1][0]=+v[1][0],s[0][1]=+v[0][1],s[1][1]=+v[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(v){return arguments.length?(n=v,m):n},m.duration=function(v){return arguments.length?(a=+v,m):a},m.interpolate=function(v){return arguments.length?(l=v,m):l},m.on=function(){var v=c.on.apply(c,arguments);return v===c?m:v},m.clickDistance=function(v){return arguments.length?(y=(v=+v)*v,m):Math.sqrt(y)},m.tapDistance=function(v){return arguments.length?(x=+v,m):x},m}const xe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ht=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ni=["Enter"," ","Escape"],oi={"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 He;(function(e){e.Strict="strict",e.Loose="loose"})(He||(He={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var gt;(function(e){e.Partial="partial",e.Full="full"})(gt||(gt={}));const ri={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var Gt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Gt||(Gt={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const Ro={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top};function ii(e){return e===null?null:e?"valid":"invalid"}const si=e=>"id"in e&&"source"in e&&"target"in e,od=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Qn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vt=(e,t=[0,0])=>{const{width:n,height:o}=Ne(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},rd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):Qn(r)?r:t.nodeLookup.get(r.id));const a=s?qt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return on(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return rn(n)},bt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=on(n,qt(r)),o=!0)}),o?rn(n):{x:0,y:0,width:0,height:0}},Jn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...Et(t,[n,o,r]),width:t.width/r,height:t.height/r},l=[];for(const c of e.values()){const{measured:d,selectable:u=!0,hidden:f=!1}=c;if(s&&!u||f)continue;const h=d.width??c.width??c.initialWidth??null,g=d.height??c.height??c.initialHeight??null,y=pt(a,qe(c)),x=(h??0)*(g??0),m=i&&y>0;(!c.internals.handleBounds||m||y>=x||c.dragging)&&l.push(c)}return l},id=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function sd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function ad({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=sd(e,s),l=bt(a),c=eo(l,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(c,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function ai({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},d=s.origin??o;let u=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",xe.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[l,c],[l+h,c+g]])}else a&&Ue(s.extent)&&(u=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const f=Ue(u)?Le(t,u,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",xe.error015()),{position:{x:f.x-l+(s.measured.width??0)*d[0],y:f.y-c+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function cd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(y=>y.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),l=o.filter(f=>f.deletable!==!1),d=id(s,l);for(const f of l)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!r)return{edges:d,nodes:s};const u=await r({nodes:s,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:s}:{edges:[],nodes:[]}:u}const Ge=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Le=(e={x:0,y:0},t,n)=>({x:Ge(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ge(e.y,t[0][1],t[1][1]-(n?.height??0))});function ci(e,t,n){const{width:o,height:r}=Ne(n),{x:i,y:s}=n.internals.positionAbsolute;return Le(e,[[i,s],[i+o,s+r]],t)}const zo=(e,t,n)=>e<t?Ge(Math.abs(e-t),1,t)/t:e>n?-Ge(Math.abs(e-n),1,t)/t:0,li=(e,t,n=15,o=40)=>{const r=zo(e.x,o,t.width-o)*n,i=zo(e.y,o,t.height-o)*n;return[r,i]},on=(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)}),Hn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),rn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),qe=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:vt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},qt=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:vt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},ui=(e,t)=>rn(on(Hn(e),Hn(t))),pt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Ho=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),ld=(e,t)=>{},_t=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Et=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?_t(a,s):a},Ut=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Oe(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(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function ud(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Oe(e,n),r=Oe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Oe(e.top??e.y??0,n),r=Oe(e.bottom??e.y??0,n),i=Oe(e.left??e.x??0,t),s=Oe(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function dd(e,t,n,o,r,i){const{x:s,y:a}=Ut(e,[t,n,o]),{x:l,y:c}=Ut({x:e.x+e.width,y:e.y+e.height},[t,n,o]),d=r-l,u=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}const eo=(e,t,n,o,r,i)=>{const s=ud(i,t,n),a=(t-s.x)/e.width,l=(n-s.y)/e.height,c=Math.min(a,l),d=Ge(c,o,r),u=e.x+e.width/2,f=e.y+e.height/2,h=t/2-u*d,g=n/2-f*d,y=dd(e,h,g,d,t,n),x={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:d}},mt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ue(e){return e!=null&&e!=="parent"}function Ne(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function di(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function fi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Lo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function fd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function hd(e){return{...oi,...e||{}}}function ct(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=ge(e),a=Et({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:l,y:c}=n?_t(a,t):a;return{xSnapped:l,ySnapped:c,...a}}const to=e=>({width:e.offsetWidth,height:e.offsetHeight}),hi=e=>e?.getRootNode?.()||window?.document,gd=["INPUT","SELECT","TEXTAREA"];function gi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:gd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const pi=e=>"clientX"in e,ge=(e,t)=>{const n=pi(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Bo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...to(s)}})};function mi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=e*.125+r*.375+s*.375+n*.125,c=t*.125+i*.375+a*.375+o*.125,d=Math.abs(l-e),u=Math.abs(c-t);return[l,c,d,u]}function Pt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Vo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case W.Left:return[t-Pt(t-o,i),n];case W.Right:return[t+Pt(o-t,i),n];case W.Top:return[t,n-Pt(n-r,i)];case W.Bottom:return[t,n+Pt(r-n,i)]}}function yi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top,curvature:s=.25}){const[a,l]=Vo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,d]=Vo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[u,f,h,g]=mi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${o},${r}`,u,f,h,g]}function xi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function pd({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function md({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=on(qt(e),qt(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return pt(s,rn(i))>0}const yd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,xd=(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)),wd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||yd;let r;return si(e)?r={...e}:r={...e,id:o(e)},xd(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function wi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=xi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Oo={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},vd=({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},jo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function bd({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:o=W.Top,center:r,offset:i,stepPosition:s}){const a=Oo[t],l=Oo[o],c={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+l.x*i,y:n.y+l.y*i},u=vd({source:c,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],y,x;const m={x:0,y:0},b={x:0,y:0},[,,p,w]=xi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*l[f]===-1){f==="x"?(y=r.x??c.x+(d.x-c.x)*s,x=r.y??(c.y+d.y)/2):(y=r.x??(c.x+d.x)/2,x=r.y??c.y+(d.y-c.y)*s);const I=[{x:y,y:c.y},{x:y,y:d.y}],$=[{x:c.x,y:x},{x:d.x,y:x}];a[f]===h?g=f==="x"?I:$:g=f==="x"?$:I}else{const I=[{x:c.x,y:d.y}],$=[{x:d.x,y:c.y}];if(f==="x"?g=a.x===h?$:I:g=a.y===h?I:$,t===o){const v=Math.abs(e[f]-n[f]);if(v<=i){const M=Math.min(i-1,i-v);a[f]===h?m[f]=(c[f]>e[f]?-1:1)*M:b[f]=(d[f]>n[f]?-1:1)*M}}if(t!==o){const v=f==="x"?"y":"x",M=a[f]===l[v],C=c[v]>d[v],P=c[v]<d[v];(a[f]===1&&(!M&&C||M&&P)||a[f]!==1&&(!M&&P||M&&C))&&(g=f==="x"?I:$)}const O={x:c.x+m.x,y:c.y+m.y},A={x:d.x+b.x,y:d.y+b.y},R=Math.max(Math.abs(O.x-g[0].x),Math.abs(A.x-g[0].x)),V=Math.max(Math.abs(O.y-g[0].y),Math.abs(A.y-g[0].y));R>=V?(y=(O.x+A.x)/2,x=g[0].y):(y=g[0].x,x=(O.y+A.y)/2)}const S={x:c.x+m.x,y:c.y+m.y},N={x:d.x+b.x,y:d.y+b.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],y,x,p,w]}function _d(e,t,n,o){const r=Math.min(jo(e,t)/2,jo(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const c=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*d}`}const a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${s+r*l}Q ${i},${s} ${i+r*a},${s}`}function Ln({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:d=.5}){const[u,f,h,g,y]=bd({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:d});let x=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)x+=_d(u[m-1],u[m],u[m+1],s);return x+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[x,f,h,g,y]}function Fo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ed(e){const{sourceNode:t,targetNode:n}=e;if(!Fo(t)||!Fo(n))return null;const o=t.internals.handleBounds||Xo(t.handles),r=n.internals.handleBounds||Xo(n.handles),i=Yo(o?.source??[],e.sourceHandle),s=Yo(e.connectionMode===He.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",xe.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||W.Bottom,l=s?.position||W.Top,c=Be(t,i,a),d=Be(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:l}}function Xo(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Be(e,t,n=W.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??Ne(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case W.Top:return{x:r+s/2,y:i};case W.Right:return{x:r+s,y:i+a/2};case W.Bottom:return{x:r+s/2,y:i+a};case W.Left:return{x:r,y:i+a/2}}}function Yo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Bn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Nd(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(l=>{if(l&&typeof l=="object"){const c=Bn(l,t);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const vi=1e3,Sd=10,no={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Cd={...no,checkEquality:!0};function oo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Md(e,t,n){const o=oo(no,n);for(const r of e.values())if(r.parentId)io(r,e,t,o);else{const i=vt(r,o.nodeOrigin),s=Ue(r.extent)?r.extent:o.nodeExtent,a=Le(i,s,Ne(r));r.internals.positionAbsolute=a}}function Id(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function ro(e){return e==="manual"}function Vn(e,t,n,o={}){const r=oo(Cd,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!ro(r.zIndexMode)?vi:0;let l=e.length>0,c=!1;t.clear(),n.clear();for(const d of e){let u=s.get(d.id);if(r.checkEquality&&d===u?.internals.userNode)t.set(d.id,u);else{const f=vt(d,r.nodeOrigin),h=Ue(d.extent)?d.extent:r.nodeExtent,g=Le(f,h,Ne(d));u={...r.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:g,handleBounds:Id(d,u),z:bi(d,a,r.zIndexMode),userNode:d}},t.set(d.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),d.parentId&&io(u,t,n,o,i),c||=d.selected??!1}return{nodesInitialized:l,hasSelectedNodes:c}}function kd(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 io(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=oo(no,o),c=e.parentId,d=t.get(c);if(!d){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}kd(e,n),r&&!d.parentId&&d.internals.rootParentIndex===void 0&&l==="auto"&&(d.internals.rootParentIndex=++r.i,d.internals.z=d.internals.z+r.i*Sd),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const u=i&&!ro(l)?vi:0,{x:f,y:h,z:g}=Ad(e,d,s,a,u,l),{positionAbsolute:y}=e.internals,x=f!==y.x||h!==y.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:y,z:g}})}function bi(e,t,n){const o=he(e.zIndex)?e.zIndex:0;return ro(n)?o:o+(e.selected?t:0)}function Ad(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,l=Ne(e),c=vt(e,n),d=Ue(e.extent)?Le(c,e.extent,l):c;let u=Le({x:s+d.x,y:a+d.y},o,l);e.extent==="parent"&&(u=ci(u,l,t));const f=bi(e,r,i),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function so(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const l=i.get(s.parentId)?.expandedRect??qe(a),c=ui(l,s.rect);i.set(s.parentId,{expandedRect:c,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},l)=>{const c=a.internals.positionAbsolute,d=Ne(a),u=a.origin??o,f=s.x<c.x?Math.round(Math.abs(c.x-s.x)):0,h=s.y<c.y?Math.round(Math.abs(c.y-s.y)):0,g=Math.max(d.width,Math.round(s.width)),y=Math.max(d.height,Math.round(s.height)),x=(g-d.width)*u[0],m=(y-d.height)*u[1];(f>0||h>0||x||m)&&(r.push({id:l,type:"position",position:{x:a.position.x-f+x,y:a.position.y-h+m}}),n.get(l)?.forEach(b=>{e.some(p=>p.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(d.width<s.width||d.height<s.height||f||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:g+(f?u[0]*f-x:0),height:y+(h?u[1]*h-m:0)}})}),r}function Pd(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],d=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];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}}),l=!0;continue}const y=to(h.nodeElement),x=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(x||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ue(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=ci(w,y,t.get(g.parentId)):p&&(w=Le(w,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:Bo("source",h.nodeElement,b,u,g.id),target:Bo("target",h.nodeElement,b,u,g.id)}}};t.set(g.id,S),g.parentId&&io(S,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,x&&(c.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:qe(S,r)}))}}if(f.length>0){const h=so(f,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function $d({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Wo(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const l=o.get(s)||new Map;if(o.set(s,l.set(n,t)),i){s=`${r}-${e}-${i}`;const c=o.get(s)||new Map;o.set(s,c.set(n,t))}}function _i(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,l={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},c=`${r}-${s}--${i}-${a}`,d=`${i}-${a}--${r}-${s}`;Wo("source",l,d,e,r,s),Wo("target",l,c,e,i,a),t.set(o.id,o)}}function Ei(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ei(n,t):!1}function Zo(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Dd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Ei(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function wn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const l=n.get(s)?.internals.userNode;l&&r.push({...l,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function Td({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=_t(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Rd({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},d=null,u=!1,f=null,h=!1,g=!1,y=null;function x({noDragClassName:b,handleSelector:p,domNode:w,isSelectable:S,nodeId:N,nodeClickDistance:_=0}){f=le(w);function I({x:R,y:V}){const{nodeLookup:v,nodeExtent:M,snapGrid:C,snapToGrid:P,nodeOrigin:k,onNodeDrag:D,onSelectionDrag:H,onError:B,updateNodePositions:L}=t();i={x:R,y:V};let Z=!1;const F=a.size>1,z=F&&M?Hn(bt(a)):null,X=F&&P?Td({dragItems:a,snapGrid:C,x:R,y:V}):null;for(const[Y,j]of a){if(!v.has(Y))continue;let G={x:R-j.distance.x,y:V-j.distance.y};P&&(G=X?{x:Math.round(G.x+X.x),y:Math.round(G.y+X.y)}:_t(G,C));let Q=null;if(F&&M&&!j.extent&&z){const{positionAbsolute:U}=j.internals,te=U.x-z.x+M[0][0],oe=U.x+j.measured.width-z.x2+M[1][0],ne=U.y-z.y+M[0][1],ae=U.y+j.measured.height-z.y2+M[1][1];Q=[[te,ne],[oe,ae]]}const{position:K,positionAbsolute:q}=ai({nodeId:Y,nextPosition:G,nodeLookup:v,nodeExtent:Q||M,nodeOrigin:k,onError:B});Z=Z||j.position.x!==K.x||j.position.y!==K.y,j.position=K,j.internals.positionAbsolute=q}if(g=g||Z,!!Z&&(L(a,!0),y&&(o||D||!N&&H))){const[Y,j]=wn({nodeId:N,dragItems:a,nodeLookup:v});o?.(y,a,Y,j),D?.(y,Y,j),N||H?.(y,j)}}async function $(){if(!d)return;const{transform:R,panBy:V,autoPanSpeed:v,autoPanOnNodeDrag:M}=t();if(!M){l=!1,cancelAnimationFrame(s);return}const[C,P]=li(c,d,v);(C!==0||P!==0)&&(i.x=(i.x??0)-C/R[2],i.y=(i.y??0)-P/R[2],await V({x:C,y:P})&&I(i)),s=requestAnimationFrame($)}function O(R){const{nodeLookup:V,multiSelectionActive:v,nodesDraggable:M,transform:C,snapGrid:P,snapToGrid:k,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:B,unselectNodesAndEdges:L}=t();u=!0,(!D||!S)&&!v&&N&&(V.get(N)?.selected||L()),S&&D&&N&&e?.(N);const Z=ct(R.sourceEvent,{transform:C,snapGrid:P,snapToGrid:k,containerBounds:d});if(i=Z,a=Dd(V,M,Z,N),a.size>0&&(n||H||!N&&B)){const[F,z]=wn({nodeId:N,dragItems:a,nodeLookup:V});n?.(R.sourceEvent,a,F,z),H?.(R.sourceEvent,F,z),N||B?.(R.sourceEvent,z)}}const A=Vr().clickDistance(_).on("start",R=>{const{domNode:V,nodeDragThreshold:v,transform:M,snapGrid:C,snapToGrid:P}=t();d=V?.getBoundingClientRect()||null,h=!1,g=!1,y=R.sourceEvent,v===0&&O(R),i=ct(R.sourceEvent,{transform:M,snapGrid:C,snapToGrid:P,containerBounds:d}),c=ge(R.sourceEvent,d)}).on("drag",R=>{const{autoPanOnNodeDrag:V,transform:v,snapGrid:M,snapToGrid:C,nodeDragThreshold:P,nodeLookup:k}=t(),D=ct(R.sourceEvent,{transform:v,snapGrid:M,snapToGrid:C,containerBounds:d});if(y=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||N&&!k.has(N))&&(h=!0),!h){if(!l&&V&&u&&(l=!0,$()),!u){const H=ge(R.sourceEvent,d),B=H.x-c.x,L=H.y-c.y;Math.sqrt(B*B+L*L)>P&&O(R)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&a&&u&&(c=ge(R.sourceEvent,d),I(D))}}).on("end",R=>{if(!(!u||h)&&(l=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:V,updateNodePositions:v,onNodeDragStop:M,onSelectionDragStop:C}=t();if(g&&(v(a,!1),g=!1),r||M||!N&&C){const[P,k]=wn({nodeId:N,dragItems:a,nodeLookup:V,dragging:!1});r?.(R.sourceEvent,a,P,k),M?.(R.sourceEvent,P,k),N||C?.(R.sourceEvent,k)}}}).filter(R=>{const V=R.target;return!R.button&&(!b||!Zo(V,`.${b}`,w))&&(!p||Zo(V,p,w))});f.call(A)}function m(){f?.on(".drag",null)}return{update:x,destroy:m}}function zd(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())pt(r,qe(i))>0&&o.push(i);return o}const Hd=250;function Ld(e,t,n,o){let r=[],i=1/0;const s=zd(e,n,t+Hd);for(const a of s){const l=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const c of l){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:d,y:u}=Be(a,c,c.position,!0),f=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(u-e.y,2));f>t||(f<i?(r=[{...c,x:d,y:u}],i=f):f===i&&r.push({...c,x:d,y:u}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(l=>l.type===a)??r[0]}return r[0]}function Ni(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],l=(n?a?.find(c=>c.id===n):a?.[0])??null;return l&&i?{...l,...Be(s,l,l.position,!0)}:l}function Si(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Bd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ci=()=>!0;function Vd(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:y,onConnectEnd:x,isValidConnection:m=Ci,onReconnectEnd:b,updateConnection:p,getTransform:w,getFromHandle:S,autoPanSpeed:N,dragThreshold:_=1,handleDomNode:I}){const $=hi(e.target);let O=0,A;const{x:R,y:V}=ge(e),v=Si(i,I),M=a?.getBoundingClientRect();let C=!1;if(!M||!v)return;const P=Ni(r,v,o,l,t);if(!P)return;let k=ge(e,M),D=!1,H=null,B=!1,L=null;function Z(){if(!d||!M)return;const[K,q]=li(k,M,N);f({x:K,y:q}),O=requestAnimationFrame(Z)}const F={...P,nodeId:r,type:v,position:P.position},z=l.get(r);let Y={inProgress:!0,isValid:null,from:Be(z,F,W.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:z,to:k,toHandle:null,toPosition:Ro[F.position],toNode:null,pointer:k};function j(){C=!0,p(Y),g?.(e,{nodeId:r,handleId:o,handleType:v})}_===0&&j();function G(K){if(!C){const{x:ae,y:Se}=ge(K),ve=ae-R,Ae=Se-V;if(!(ve*ve+Ae*Ae>_*_))return;j()}if(!S()||!F){Q(K);return}const q=w();k=ge(K,M),A=Ld(Et(k,q,!1,[1,1]),n,l,F),D||(Z(),D=!0);const U=Mi(K,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:$,lib:c,flowId:u,nodeLookup:l});L=U.handleDomNode,H=U.connection,B=Bd(!!A,U.isValid);const te=l.get(r),oe=te?Be(te,F,W.Left,!0):Y.from,ne={...Y,from:oe,isValid:B,to:U.toHandle&&B?Ut({x:U.toHandle.x,y:U.toHandle.y},q):k,toHandle:U.toHandle,toPosition:B&&U.toHandle?U.toHandle.position:Ro[F.position],toNode:U.toHandle?l.get(U.toHandle.nodeId):null,pointer:k};p(ne),Y=ne}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(C){(A||L)&&H&&B&&y?.(H);const{inProgress:q,...U}=Y,te={...U,toPosition:Y.toHandle?Y.toPosition:null};x?.(K,te),i&&b?.(K,te)}h(),cancelAnimationFrame(O),D=!1,B=!1,H=null,L=null,$.removeEventListener("mousemove",G),$.removeEventListener("mouseup",Q),$.removeEventListener("touchmove",G),$.removeEventListener("touchend",Q)}}$.addEventListener("mousemove",G),$.addEventListener("mouseup",Q),$.addEventListener("touchmove",G),$.addEventListener("touchend",Q)}function Mi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Ci,nodeLookup:d}){const u=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=ge(e),y=s.elementFromPoint(h,g),x=y?.classList.contains(`${a}-flow__handle`)?y:f,m={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const b=Si(void 0,x),p=x.getAttribute("data-nodeid"),w=x.getAttribute("data-handleid"),S=x.classList.contains("connectable"),N=x.classList.contains("connectableend");if(!p||!b)return m;const _={source:u?p:o,sourceHandle:u?w:r,target:u?o:p,targetHandle:u?r:w};m.connection=_;const $=S&&N&&(n===He.Strict?u&&b==="source"||!u&&b==="target":p!==o||w!==r);m.isValid=$&&c(_),m.toHandle=Ni(p,b,w,d,n,!0)}return m}const On={onPointerDown:Vd,isValid:Mi};function Od({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=le(e);function i({translateExtent:a,width:l,height:c,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),S=p.sourceEvent.ctrlKey&&mt()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,_=w[2]*Math.pow(2,N*S);t.scaleTo(_)};let y=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const w=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],N=[S[0]-y[0],S[1]-y[1]];y=S;const _=o()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),I={x:w[0]-N[0]*_,y:w[1]-N[1]*_},$=[[0,0],[l,c]];t.setViewportConstrained({x:I.x,y:I.y,zoom:w[2]},$,a)},b=ti().on("start",x).on("zoom",u?m:null).on("zoom.wheel",f?g:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:de}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),vn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Ii=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),jd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bn=(e,t=0,n=jd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},ki=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fd({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return d=>{if(je(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(d.ctrlKey&&s){const x=de(d),m=ki(d),b=u*Math.pow(2,m);o.scaleTo(n,b,x,d);return}const f=d.deltaMode===1?20:1;let h=r===Te.Vertical?0:d.deltaX*f,g=r===Te.Horizontal?0:d.deltaY*f;!mt()&&d.shiftKey&&r!==Te.Vertical&&(h=d.deltaY*f,g=0),o.translateBy(n,-(h/u)*i,-(g/u)*i,{internal:!0});const y=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(d,y),e.panScrollTimeout=setTimeout(()=>{c?.(d,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(d,y))}}function Xd({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=je(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Yd({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=sn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Wd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ii(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,sn(i.transform))}}function Zd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ii(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=sn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function Gd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:d}){return u=>{const f=e||t,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(je(u,`${c}-flow__node`)||je(u,`${c}-flow__edge`)))return!0;if(!o&&!f&&!r&&!i&&!n||s||d&&!g||je(u,a)&&g||je(u,l)&&(!g||r&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&u.touches?.length>1)return u.preventDefault(),!1;if(!f&&!r&&!h&&g||!o&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(o)&&!o.includes(u.button)&&u.type==="mousedown")return!1;const y=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&y}}function qd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=ti().scaleExtent([t,n]).translateExtent(o),f=le(e).call(u);b({x:r.x,y:r.y,zoom:Ge(r.zoom,t,n)},[[0,0],[d.width,d.height]],o);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(ki);function y(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).transform(bn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function x({noWheelClassName:A,noPanClassName:R,onPaneContextMenu:V,userSelectionActive:v,panOnScroll:M,panOnDrag:C,panOnScrollMode:P,panOnScrollSpeed:k,preventScrolling:D,zoomOnPinch:H,zoomOnScroll:B,zoomOnDoubleClick:L,zoomActivationKeyPressed:Z,lib:F,onTransformChange:z,connectionInProgress:X,paneClickDistance:Y,selectionOnDrag:j}){v&&!c.isZoomingOrPanning&&m();const G=M&&!Z&&!v;u.clickDistance(j?1/0:!he(Y)||Y<0?0:Y);const Q=G?Fd({zoomPanValues:c,noWheelClassName:A,d3Selection:f,d3Zoom:u,panOnScrollMode:P,panOnScrollSpeed:k,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Xd({noWheelClassName:A,preventScrolling:D,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const q=Yd({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});u.on("start",q);const U=Wd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!V,onPanZoom:i,onTransformChange:z});u.on("zoom",U);const te=Zd({zoomPanValues:c,panOnDrag:C,panOnScroll:M,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:l});u.on("end",te)}const K=Gd({zoomActivationKeyPressed:Z,panOnDrag:C,zoomOnScroll:B,panOnScroll:M,zoomOnDoubleClick:L,zoomOnPinch:H,userSelectionActive:v,noPanClassName:R,noWheelClassName:A,lib:F,connectionInProgress:X});u.filter(K),L?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function b(A,R,V){const v=vn(A),M=u?.constrain()(v,R,V);return M&&await y(M),new Promise(C=>C(M))}async function p(A,R){const V=vn(A);return await y(V,R),new Promise(v=>v(V))}function w(A){if(f){const R=vn(A),V=f.property("__zoom");(V.k!==A.zoom||V.x!==A.x||V.y!==A.y)&&u?.transform(f,R,null,{sync:!0})}}function S(){const A=f?ei(f.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function N(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).scaleTo(bn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function _(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).scaleBy(bn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function I(A){u?.scaleExtent(A)}function $(A){u?.translateExtent(A)}function O(A){const R=!he(A)||A<0?0:A;u?.clickDistance(R)}return{update:x,destroy:m,setViewport:p,setViewportConstrained:b,getViewport:S,scaleTo:N,scaleBy:_,setScaleExtent:I,setTranslateExtent:$,syncViewport:w,setClickDistance:O}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function Ud({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function Go(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Ce(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function $t(e,t,n){return Math.max(0,t-e,e-n)}function qo(e,t){return e?!t:t}function Kd(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:d,isVertical:u}=t,f=d&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:y,maxWidth:x,minHeight:m,maxHeight:b}=o,{x:p,y:w,width:S,height:N,aspectRatio:_}=e;let I=Math.floor(d?h-e.pointerX:0),$=Math.floor(u?g-e.pointerY:0);const O=S+(l?-I:I),A=N+(c?-$:$),R=-i[0]*S,V=-i[1]*N;let v=$t(O,y,x),M=$t(A,m,b);if(s){let k=0,D=0;l&&I<0?k=Ce(p+I+R,s[0][0]):!l&&I>0&&(k=Me(p+O+R,s[1][0])),c&&$<0?D=Ce(w+$+V,s[0][1]):!c&&$>0&&(D=Me(w+A+V,s[1][1])),v=Math.max(v,k),M=Math.max(M,D)}if(a){let k=0,D=0;l&&I>0?k=Me(p+I,a[0][0]):!l&&I<0&&(k=Ce(p+O,a[1][0])),c&&$>0?D=Me(w+$,a[0][1]):!c&&$<0&&(D=Ce(w+A,a[1][1])),v=Math.max(v,k),M=Math.max(M,D)}if(r){if(d){const k=$t(O/_,m,b)*_;if(v=Math.max(v,k),s){let D=0;!l&&!c||l&&!c&&f?D=Me(w+V+O/_,s[1][1])*_:D=Ce(w+V+(l?I:-I)/_,s[0][1])*_,v=Math.max(v,D)}if(a){let D=0;!l&&!c||l&&!c&&f?D=Ce(w+O/_,a[1][1])*_:D=Me(w+(l?I:-I)/_,a[0][1])*_,v=Math.max(v,D)}}if(u){const k=$t(A*_,y,x)/_;if(M=Math.max(M,k),s){let D=0;!l&&!c||c&&!l&&f?D=Me(p+A*_+R,s[1][0])/_:D=Ce(p+(c?$:-$)*_+R,s[0][0])/_,M=Math.max(M,D)}if(a){let D=0;!l&&!c||c&&!l&&f?D=Ce(p+A*_,a[1][0])/_:D=Me(p+(c?$:-$)*_,a[0][0])/_,M=Math.max(M,D)}}}$=$+($<0?M:-M),I=I+(I<0?v:-v),r&&(f?O>A*_?$=(qo(l,c)?-I:I)/_:I=(qo(l,c)?-$:$)*_:d?($=I/_,c=l):(I=$*_,l=c));const C=l?p+I:p,P=c?w+$:w;return{width:S+(l?-I:I),height:N+(c?-$:$),x:i[0]*I*(l?-1:1)+C,y:i[1]*$*(c?-1:1)+P}}const Ai={width:0,height:0,x:0,y:0},Qd={...Ai,pointerX:0,pointerY:0,aspectRatio:1};function Jd(e){return[[0,0],[e.measured.width,e.measured.height]]}function ef(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function tf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:Go("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:y,shouldResize:x}){let m={...Ai},b={...Qd};s={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Go(c)};let p,w=null,S=[],N,_,I,$=!1;const O=Vr().on("start",A=>{const{nodeLookup:R,transform:V,snapGrid:v,snapToGrid:M,nodeOrigin:C,paneDomNode:P}=n();if(p=R.get(t),!p)return;w=P?.getBoundingClientRect()??null;const{xSnapped:k,ySnapped:D}=ct(A.sourceEvent,{transform:V,snapGrid:v,snapToGrid:M,containerBounds:w});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:k,pointerY:D,aspectRatio:m.width/m.height},N=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(N=R.get(p.parentId),_=N&&p.extent==="parent"?Jd(N):void 0),S=[],I=void 0;for(const[H,B]of R)if(B.parentId===t&&(S.push({id:H,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const L=ef(B,p,B.origin??C);I?I=[[Math.min(L[0][0],I[0][0]),Math.min(L[0][1],I[0][1])],[Math.max(L[1][0],I[1][0]),Math.max(L[1][1],I[1][1])]]:I=L}h?.(A,{...m})}).on("drag",A=>{const{transform:R,snapGrid:V,snapToGrid:v,nodeOrigin:M}=n(),C=ct(A.sourceEvent,{transform:R,snapGrid:V,snapToGrid:v,containerBounds:w}),P=[];if(!p)return;const{x:k,y:D,width:H,height:B}=m,L={},Z=p.origin??M,{width:F,height:z,x:X,y:Y}=Kd(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,Z,_,I),j=F!==H,G=z!==B,Q=X!==k&&j,K=Y!==D&&G;if(!Q&&!K&&!j&&!G)return;if((Q||K||Z[0]===1||Z[1]===1)&&(L.x=Q?X:m.x,L.y=K?Y:m.y,m.x=L.x,m.y=L.y,S.length>0)){const oe=X-k,ne=Y-D;for(const ae of S)ae.position={x:ae.position.x-oe+Z[0]*(F-H),y:ae.position.y-ne+Z[1]*(z-B)},P.push(ae)}if((j||G)&&(L.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:m.width,L.height=G&&(!s.resizeDirection||s.resizeDirection==="vertical")?z:m.height,m.width=L.width,m.height=L.height),N&&p.expandParent){const oe=Z[0]*(L.width??0);L.x&&L.x<oe&&(m.x=oe,b.x=b.x-(L.x-oe));const ne=Z[1]*(L.height??0);L.y&&L.y<ne&&(m.y=ne,b.y=b.y-(L.y-ne))}const q=Ud({width:m.width,prevWidth:H,height:m.height,prevHeight:B,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...m,direction:q};x?.(A,U)!==!1&&($=!0,g?.(A,U),o(L,P))}).on("end",A=>{$&&(y?.(A,{...m}),r?.({...m}),$=!1)});i.call(O)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}var _n={exports:{}},En={},Nn={exports:{}},Sn={};var Uo;function nf(){if(Uo)return Sn;Uo=1;var e=Sr();function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(u,f){var h=f(),g=o({inst:{value:h,getSnapshot:f}}),y=g[0].inst,x=g[1];return i(function(){y.value=h,y.getSnapshot=f,l(y)&&x({inst:y})},[u,h,f]),r(function(){return l(y)&&x({inst:y}),u(function(){l(y)&&x({inst:y})})},[u]),s(h),h}function l(u){var f=u.getSnapshot;u=u.value;try{var h=f();return!n(u,h)}catch{return!0}}function c(u,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Sn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Sn}var Ko;function of(){return Ko||(Ko=1,Nn.exports=nf()),Nn.exports}var Qo;function rf(){if(Qo)return En;Qo=1;var e=Sr(),t=of();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return En.useSyncExternalStoreWithSelector=function(c,d,u,f,h){var g=i(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=a(function(){function m(N){if(!b){if(b=!0,p=N,N=f(N),h!==void 0&&y.hasValue){var _=y.value;if(h(_,N))return w=_}return w=N}if(_=w,o(p,N))return _;var I=f(N);return h!==void 0&&h(_,I)?(p=N,_):(p=N,w=I)}var b=!1,p,w,S=u===void 0?null:u;return[function(){return m(d())},S===null?void 0:function(){return m(S())}]},[d,u,f,h]);var x=r(c,g[0],g[1]);return s(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},En}var Jo;function sf(){return Jo||(Jo=1,_n.exports=rf()),_n.exports}var af=sf();const cf=ma(af),lf={},er=e=>{let t;const n=new Set,o=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},r=()=>t,l={setState:o,getState:r,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(lf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(o,r,l);return l},uf=e=>e?er(e):er,{useDebugValue:df}=ya,{useSyncExternalStoreWithSelector:ff}=cf,hf=e=>e;function Pi(e,t=hf,n){const o=ff(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return df(o),o}const tr=(e,t)=>{const n=uf(e),o=(r,i=t)=>Pi(n,r,i);return Object.assign(o,n),o},gf=(e,t)=>e?tr(e,t):tr;function re(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const an=T.createContext(null),pf=an.Provider,$i=xe.error001();function ee(e,t){const n=T.useContext(an);if(n===null)throw new Error($i);return Pi(n,e,t)}function ie(){const e=T.useContext(an);if(e===null)throw new Error($i);return T.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const nr={display:"none"},mf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Di="react-flow__node-desc",Ti="react-flow__edge-desc",yf="react-flow__aria-live",xf=e=>e.ariaLiveMessage,wf=e=>e.ariaLabelConfig;function vf({rfId:e}){const t=ee(xf);return E.jsx("div",{id:`${yf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mf,children:t})}function bf({rfId:e,disableKeyboardA11y:t}){const n=ee(wf);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${Di}-${e}`,style:nr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${Ti}-${e}`,style:nr,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(vf,{rfId:e})]})}const Nt=T.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return E.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Nt.displayName="Panel";function _f({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:E.jsx(Nt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:E.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Ef=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Dt=e=>e.id;function Nf(e,t){return re(e.selectedNodes.map(Dt),t.selectedNodes.map(Dt))&&re(e.selectedEdges.map(Dt),t.selectedEdges.map(Dt))}function Sf({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=ee(Ef,Nf);return T.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Cf=e=>!!e.onSelectionChangeHandlers;function Mf({onSelectionChange:e}){const t=ee(Cf);return e||t?E.jsx(Sf,{onSelectionChange:e}):null}const jn=typeof window<"u"?T.useLayoutEffect:T.useEffect,Ri=[0,0],If={x:0,y:0,zoom:1},kf=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],or=[...kf,"rfId"],Af=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),rr={translateExtent:ht,nodeOrigin:Ri,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Pf(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=ee(Af,re),c=ie();jn(()=>(l(e.defaultNodes,e.defaultEdges),()=>{d.current=rr,a()}),[]);const d=T.useRef(rr);return jn(()=>{for(const u of or){const f=e[u],h=d.current[u];f!==h&&(typeof e[u]>"u"||(u==="nodes"?t(f):u==="edges"?n(f):u==="minZoom"?o(f):u==="maxZoom"?r(f):u==="translateExtent"?i(f):u==="nodeExtent"?s(f):u==="ariaLabelConfig"?c.setState({ariaLabelConfig:hd(f)}):u==="fitView"?c.setState({fitViewQueued:f}):u==="fitViewOptions"?c.setState({fitViewOptions:f}):c.setState({[u]:f})))}d.current=e},or.map(u=>e[u])),null}function ir(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function $f(e){const[t,n]=T.useState(e==="system"?null:e);return T.useEffect(()=>{if(e!=="system"){n(e);return}const o=ir(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:ir()?.matches?"dark":"light"}const sr=typeof document<"u"?document:null;function yt(e=null,t={target:sr,actInsideInputWithModifier:!0}){const[n,o]=T.useState(!1),r=T.useRef(!1),i=T.useRef(new Set([])),[s,a]=T.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
|
|
1
|
+
import{r as Sr,g as ma,R as ya,a as T,j as E,u as Xn,b as J,i as gn,S as xa,f as wa,c as va,n as ba,d as _a,e as Ea}from"./index-Tjqx6wUV.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Na={value:()=>{}};function Qt(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Rt(n)}function Rt(e){this._=e}function Sa(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Rt.prototype=Qt.prototype={constructor:Rt,on:function(e,t){var n=this._,o=Sa(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Ca(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=xo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=xo(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Rt(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function Ca(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function xo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Na,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var kn="http://www.w3.org/1999/xhtml";const wo={svg:"http://www.w3.org/2000/svg",xhtml:kn,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)),wo.hasOwnProperty(t)?{space:wo[t],local:e}:e}function Ma(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===kn&&t.documentElement.namespaceURI===kn?t.createElement(e):t.createElementNS(n,e)}}function Ia(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Cr(e){var t=Jt(e);return(t.local?Ia:Ma)(t)}function ka(){}function Yn(e){return e==null?ka:function(){return this.querySelector(e)}}function Aa(e){typeof e!="function"&&(e=Yn(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new ue(o,this._parents)}function Pa(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function $a(){return[]}function Mr(e){return e==null?$a:function(){return this.querySelectorAll(e)}}function Da(e){return function(){return Pa(e.apply(this,arguments))}}function Ta(e){typeof e=="function"?e=Da(e):e=Mr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(o.push(e.call(l,l.__data__,c,s)),r.push(l));return new ue(o,r)}function Ir(e){return function(){return this.matches(e)}}function kr(e){return function(t){return t.matches(e)}}var Ra=Array.prototype.find;function za(e){return function(){return Ra.call(this.children,e)}}function Ha(){return this.firstElementChild}function La(e){return this.select(e==null?Ha:za(typeof e=="function"?e:kr(e)))}var Ba=Array.prototype.filter;function Va(){return Array.from(this.children)}function Oa(e){return function(){return Ba.call(this.children,e)}}function ja(e){return this.selectAll(e==null?Va:Oa(typeof e=="function"?e:kr(e)))}function Fa(e){typeof e!="function"&&(e=Ir(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new ue(o,this._parents)}function Ar(e){return new Array(e.length)}function Xa(){return new ue(this._enter||this._groups.map(Ar),this._parents)}function Ot(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ot.prototype={constructor:Ot,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 Ya(e){return function(){return e}}function Wa(e,t,n,o,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Ot(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Za(e,t,n,o,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,f=new Array(d),h;for(a=0;a<d;++a)(l=t[a])&&(f[a]=h=s.call(l,l.__data__,a,t)+"",c.has(h)?r[a]=l:c.set(h,l));for(a=0;a<u;++a)h=s.call(e,i[a],a,i)+"",(l=c.get(h))?(o[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new Ot(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(f[a])===l&&(r[a]=l)}function Ga(e){return e.__data__}function qa(e,t){if(!arguments.length)return Array.from(this,Ga);var n=t?Za:Wa,o=this._parents,r=this._groups;typeof e!="function"&&(e=Ya(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=o[c],u=r[c],f=u.length,h=Ua(e.call(d,d&&d.__data__,c,o)),g=h.length,y=a[c]=new Array(g),x=s[c]=new Array(g),m=l[c]=new Array(f);n(d,u,y,x,m,h,t);for(var b=0,p=0,w,S;b<g;++b)if(w=y[b]){for(b>=p&&(p=b+1);!(S=x[p])&&++p<g;);w._next=S||null}}return s=new ue(s,o),s._enter=a,s._exit=l,s}function Ua(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ka(){return new ue(this._exit||this._groups.map(Ar),this._parents)}function Qa(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Ja(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=n[l],d=o[l],u=c.length,f=a[l]=new Array(u),h,g=0;g<u;++g)(h=c[g]||d[g])&&(f[g]=h);for(;l<r;++l)a[l]=n[l];return new ue(a,this._parents)}function ec(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function tc(e){e||(e=nc);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new ue(r,this._parents).order()}function nc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function oc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function rc(){return Array.from(this)}function ic(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function sc(){let e=0;for(const t of this)++e;return e}function ac(){return!this.node()}function cc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function lc(e){return function(){this.removeAttribute(e)}}function uc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dc(e,t){return function(){this.setAttribute(e,t)}}function fc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function gc(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 pc(e,t){var n=Jt(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?uc:lc:typeof t=="function"?n.local?gc:hc:n.local?fc:dc)(n,t))}function Pr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function mc(e){return function(){this.style.removeProperty(e)}}function yc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function wc(e,t,n){return arguments.length>1?this.each((t==null?mc:typeof t=="function"?xc:yc)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Pr(e).getComputedStyle(e,null).getPropertyValue(t)}function vc(e){return function(){delete this[e]}}function bc(e,t){return function(){this[e]=t}}function _c(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ec(e,t){return arguments.length>1?this.each((t==null?vc:typeof t=="function"?_c:bc)(e,t)):this.node()[e]}function $r(e){return e.trim().split(/^|\s+/)}function Wn(e){return e.classList||new Dr(e)}function Dr(e){this._node=e,this._names=$r(e.getAttribute("class")||"")}Dr.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 Tr(e,t){for(var n=Wn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Rr(e,t){for(var n=Wn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Nc(e){return function(){Tr(this,e)}}function Sc(e){return function(){Rr(this,e)}}function Cc(e,t){return function(){(t.apply(this,arguments)?Tr:Rr)(this,e)}}function Mc(e,t){var n=$r(e+"");if(arguments.length<2){for(var o=Wn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Cc:t?Nc:Sc)(n,t))}function Ic(){this.textContent=""}function kc(e){return function(){this.textContent=e}}function Ac(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Pc(e){return arguments.length?this.each(e==null?Ic:(typeof e=="function"?Ac:kc)(e)):this.node().textContent}function $c(){this.innerHTML=""}function Dc(e){return function(){this.innerHTML=e}}function Tc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Rc(e){return arguments.length?this.each(e==null?$c:(typeof e=="function"?Tc:Dc)(e)):this.node().innerHTML}function zc(){this.nextSibling&&this.parentNode.appendChild(this)}function Hc(){return this.each(zc)}function Lc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Bc(){return this.each(Lc)}function Vc(e){var t=typeof e=="function"?e:Cr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Oc(){return null}function jc(e,t){var n=typeof e=="function"?e:Cr(e),o=t==null?Oc:typeof t=="function"?t:Yn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Fc(){var e=this.parentNode;e&&e.removeChild(this)}function Xc(){return this.each(Fc)}function Yc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Wc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Zc(e){return this.select(e?Wc:Yc)}function Gc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qc(e){return function(t){e.call(this,t,this.__data__)}}function Uc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Kc(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Qc(e,t,n){return function(){var o=this.__on,r,i=qc(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Jc(e,t,n){var o=Uc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=o[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Qc:Kc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function zr(e,t,n){var o=Pr(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function el(e,t){return function(){return zr(this,e,t)}}function tl(e,t){return function(){return zr(this,e,t.apply(this,arguments))}}function nl(e,t){return this.each((typeof t=="function"?tl:el)(e,t))}function*ol(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var Hr=[null];function ue(e,t){this._groups=e,this._parents=t}function xt(){return new ue([[document.documentElement]],Hr)}function rl(){return this}ue.prototype=xt.prototype={constructor:ue,select:Aa,selectAll:Ta,selectChild:La,selectChildren:ja,filter:Fa,data:qa,enter:Xa,exit:Ka,join:Qa,merge:Ja,selection:rl,order:ec,sort:tc,call:oc,nodes:rc,node:ic,size:sc,empty:ac,each:cc,attr:pc,style:wc,property:Ec,classed:Mc,text:Pc,html:Rc,raise:Hc,lower:Bc,append:Vc,insert:jc,remove:Xc,clone:Zc,datum:Gc,on:Jc,dispatch:nl,[Symbol.iterator]:ol};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Hr)}function il(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=il(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const sl={passive:!1},lt={capture:!0,passive:!1};function pn(e){e.stopImmediatePropagation()}function Xe(e){e.preventDefault(),e.stopImmediatePropagation()}function Lr(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",Xe,lt);"onselectstart"in t?n.on("selectstart.drag",Xe,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Br(e,t){var n=e.document.documentElement,o=le(e).on("dragstart.drag",null);t&&(o.on("click.drag",Xe,lt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ct=e=>()=>e;function An(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}An.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function al(e){return!e.ctrlKey&&!e.button}function cl(){return this.parentNode}function ll(e,t){return t??{x:e.x,y:e.y}}function ul(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vr(){var e=al,t=cl,n=ll,o=ul,r={},i=Qt("start","drag","end"),s=0,a,l,c,d,u=0;function f(w){w.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",m,sl).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,S){if(!(d||!e.call(this,w,S))){var N=p(this,t.call(this,w,S),w,S,"mouse");N&&(le(w.view).on("mousemove.drag",g,lt).on("mouseup.drag",y,lt),Lr(w.view),pn(w),c=!1,a=w.clientX,l=w.clientY,N("start",w))}}function g(w){if(Xe(w),!c){var S=w.clientX-a,N=w.clientY-l;c=S*S+N*N>u}r.mouse("drag",w)}function y(w){le(w.view).on("mousemove.drag mouseup.drag",null),Br(w.view,c),Xe(w),r.mouse("end",w)}function x(w,S){if(e.call(this,w,S)){var N=w.changedTouches,_=t.call(this,w,S),I=N.length,$,O;for($=0;$<I;++$)(O=p(this,_,w,S,N[$].identifier,N[$]))&&(pn(w),O("start",w,N[$]))}}function m(w){var S=w.changedTouches,N=S.length,_,I;for(_=0;_<N;++_)(I=r[S[_].identifier])&&(Xe(w),I("drag",w,S[_]))}function b(w){var S=w.changedTouches,N=S.length,_,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),_=0;_<N;++_)(I=r[S[_].identifier])&&(pn(w),I("end",w,S[_]))}function p(w,S,N,_,I,$){var O=i.copy(),A=de($||N,S),R,V,v;if((v=n.call(w,new An("beforestart",{sourceEvent:N,target:f,identifier:I,active:s,x:A[0],y:A[1],dx:0,dy:0,dispatch:O}),_))!=null)return R=v.x-A[0]||0,V=v.y-A[1]||0,function M(C,P,k){var D=A,H;switch(C){case"start":r[I]=M,H=s++;break;case"end":delete r[I],--s;case"drag":A=de(k||P,S),H=s;break}O.call(C,w,new An(C,{sourceEvent:P,subject:v,target:f,identifier:I,active:H,x:A[0]+R,y:A[1]+V,dx:A[0]-D[0],dy:A[1]-D[1],dispatch:O}),_)}}return f.filter=function(w){return arguments.length?(e=typeof w=="function"?w:Ct(!!w),f):e},f.container=function(w){return arguments.length?(t=typeof w=="function"?w:Ct(w),f):t},f.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Ct(w),f):n},f.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:Ct(!!w),f):o},f.on=function(){var w=i.on.apply(i,arguments);return w===i?f:w},f.clickDistance=function(w){return arguments.length?(u=(w=+w)*w,f):Math.sqrt(u)},f}function Zn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Or(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function wt(){}var ut=.7,jt=1/ut,Ye="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ye="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",dl=/^#([0-9a-f]{3,8})$/,fl=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),hl=new RegExp(`^rgb\\(${ye},${ye},${ye}\\)$`),gl=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${dt}\\)$`),pl=new RegExp(`^rgba\\(${ye},${ye},${ye},${dt}\\)$`),ml=new RegExp(`^hsl\\(${dt},${ye},${ye}\\)$`),yl=new RegExp(`^hsla\\(${dt},${ye},${ye},${dt}\\)$`),vo={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};Zn(wt,Re,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:bo,formatHex:bo,formatHex8:xl,formatHsl:wl,formatRgb:_o,toString:_o});function bo(){return this.rgb().formatHex()}function xl(){return this.rgb().formatHex8()}function wl(){return jr(this).formatHsl()}function _o(){return this.rgb().formatRgb()}function Re(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=dl.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Eo(t):n===3?new ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mt(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=fl.exec(e))?new ce(t[1],t[2],t[3],1):(t=hl.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=gl.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=pl.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ml.exec(e))?Co(t[1],t[2]/100,t[3]/100,1):(t=yl.exec(e))?Co(t[1],t[2]/100,t[3]/100,t[4]):vo.hasOwnProperty(e)?Eo(vo[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function Eo(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function Mt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ce(e,t,n,o)}function vl(e){return e instanceof wt||(e=Re(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function Pn(e,t,n,o){return arguments.length===1?vl(e):new ce(e,t,n,o??1)}function ce(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Zn(ce,Pn,Or(wt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(De(this.r),De(this.g),De(this.b),Ft(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:No,formatHex:No,formatHex8:bl,formatRgb:So,toString:So}));function No(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function bl(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function So(){const e=Ft(this.opacity);return`${e===1?"rgb(":"rgba("}${De(this.r)}, ${De(this.g)}, ${De(this.b)}${e===1?")":`, ${e})`}`}function Ft(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function De(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $e(e){return e=De(e),(e<16?"0":"")+e.toString(16)}function Co(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new fe(e,t,n,o)}function jr(e){if(e instanceof fe)return new fe(e.h,e.s,e.l,e.opacity);if(e instanceof wt||(e=Re(e)),!e)return new fe;if(e instanceof fe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new fe(s,a,l,e.opacity)}function _l(e,t,n,o){return arguments.length===1?jr(e):new fe(e,t,n,o??1)}function fe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Zn(fe,_l,Or(wt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new fe(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,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new ce(mn(e>=240?e-240:e+120,r,o),mn(e,r,o),mn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new fe(Mo(this.h),It(this.s),It(this.l),Ft(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=Ft(this.opacity);return`${e===1?"hsl(":"hsla("}${Mo(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Mo(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function mn(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 Gn=e=>()=>e;function El(e,t){return function(n){return e+n*t}}function Nl(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Sl(e){return(e=+e)==1?Fr:function(t,n){return n-t?Nl(t,n,e):Gn(isNaN(t)?n:t)}}function Fr(e,t){var n=t-e;return n?El(e,n):Gn(isNaN(e)?t:e)}const Xt=(function e(t){var n=Sl(t);function o(r,i){var s=n((r=Pn(r)).r,(i=Pn(i)).r),a=n(r.g,i.g),l=n(r.b,i.b),c=Fr(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return o.gamma=e,o})(1);function Cl(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function Ml(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Il(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=at(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function kl(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function me(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Al(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=at(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var $n=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yn=new RegExp($n.source,"g");function Pl(e){return function(){return e}}function $l(e){return function(t){return e(t)+""}}function Xr(e,t){var n=$n.lastIndex=yn.lastIndex=0,o,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(o=$n.exec(e))&&(r=yn.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:me(o,r)})),n=yn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?$l(l[0].x):Pl(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}function at(e,t){var n=typeof t,o;return t==null||n==="boolean"?Gn(t):(n==="number"?me:n==="string"?(o=Re(t))?(t=o,Xt):Xr:t instanceof Re?Xt:t instanceof Date?kl:Ml(t)?Cl:Array.isArray(t)?Il:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Al:me)(e,t)}var Io=180/Math.PI,Dn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yr(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Io,skewX:Math.atan(l)*Io,scaleX:s,scaleY:a}}var kt;function Dl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Dn:Yr(t.a,t.b,t.c,t.d,t.e,t.f)}function Tl(e){return e==null||(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",e),!(e=kt.transform.baseVal.consolidate()))?Dn:(e=e.matrix,Yr(e.a,e.b,e.c,e.d,e.e,e.f))}function Wr(e,t,n,o){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,h,g){if(c!==u||d!==f){var y=h.push("translate(",null,t,null,n);g.push({i:y-4,x:me(c,u)},{i:y-2,x:me(d,f)})}else(u||f)&&h.push("translate("+u+t+f+n)}function s(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,o)-2,x:me(c,d)})):d&&u.push(r(u)+"rotate("+d+o)}function a(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,o)-2,x:me(c,d)}):d&&u.push(r(u)+"skewX("+d+o)}function l(c,d,u,f,h,g){if(c!==u||d!==f){var y=h.push(r(h)+"scale(",null,",",null,")");g.push({i:y-4,x:me(c,u)},{i:y-2,x:me(d,f)})}else(u!==1||f!==1)&&h.push(r(h)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),s(c.rotate,d.rotate,u,f),a(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(h){for(var g=-1,y=f.length,x;++g<y;)u[(x=f[g]).i]=x.x(h);return u.join("")}}}var Rl=Wr(Dl,"px, ","px)","deg)"),zl=Wr(Tl,", ",")",")"),Hl=1e-12;function ko(e){return((e=Math.exp(e))+1/e)/2}function Ll(e){return((e=Math.exp(e))-1/e)/2}function Bl(e){return((e=Math.exp(2*e))-1)/(e+1)}const zt=(function e(t,n,o){function r(i,s){var a=i[0],l=i[1],c=i[2],d=s[0],u=s[1],f=s[2],h=d-a,g=u-l,y=h*h+g*g,x,m;if(y<Hl)m=Math.log(f/c)/t,x=function(_){return[a+_*h,l+_*g,c*Math.exp(t*_*m)]};else{var b=Math.sqrt(y),p=(f*f-c*c+o*y)/(2*c*n*b),w=(f*f-c*c-o*y)/(2*f*n*b),S=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(w*w+1)-w);m=(N-S)/t,x=function(_){var I=_*m,$=ko(S),O=c/(n*b)*($*Bl(t*I+S)-Ll(S));return[a+O*h,l+O*g,c*$/ko(t*I+S)]}}return x.duration=m*1e3*t/Math.SQRT2,x}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return e(s,a,l)},r})(Math.SQRT2,2,4);var Ze=0,it=0,ot=0,Zr=1e3,Yt,st,Wt=0,ze=0,en=0,ft=typeof performance=="object"&&performance.now?performance:Date,Gr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qn(){return ze||(Gr(Vl),ze=ft.now()+en)}function Vl(){ze=0}function Zt(){this._call=this._time=this._next=null}Zt.prototype=qr.prototype={constructor:Zt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?qn():+n)+(t==null?0:+t),!this._next&&st!==this&&(st?st._next=this:Yt=this,st=this),this._call=e,this._time=n,Tn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Tn())}};function qr(e,t,n){var o=new Zt;return o.restart(e,t,n),o}function Ol(){qn(),++Ze;for(var e=Yt,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function Ao(){ze=(Wt=ft.now())+en,Ze=it=0;try{Ol()}finally{Ze=0,Fl(),ze=0}}function jl(){var e=ft.now(),t=e-Wt;t>Zr&&(en-=t,Wt=e)}function Fl(){for(var e,t=Yt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Yt=n);st=e,Tn(o)}function Tn(e){if(!Ze){it&&(it=clearTimeout(it));var t=e-ze;t>24?(e<1/0&&(it=setTimeout(Ao,e-ft.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Wt=ft.now(),ot=setInterval(jl,Zr)),Ze=1,Gr(Ao))}}function Po(e,t,n){var o=new Zt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Xl=Qt("start","end","cancel","interrupt"),Yl=[],Ur=0,$o=1,Rn=2,Ht=3,Do=4,zn=5,Lt=6;function tn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Wl(e,n,{name:t,index:o,group:r,on:Xl,tween:Yl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ur})}function Un(e,t){var n=pe(e,t);if(n.state>Ur)throw new Error("too late; already scheduled");return n}function we(e,t){var n=pe(e,t);if(n.state>Ht)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Wl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=qr(i,0,n.time);function i(c){n.state=$o,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var d,u,f,h;if(n.state!==$o)return l();for(d in o)if(h=o[d],h.name===n.name){if(h.state===Ht)return Po(s);h.state===Do?(h.state=Lt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[d]):+d<t&&(h.state=Lt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[d])}if(Po(function(){n.state===Ht&&(n.state=Do,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Rn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Rn){for(n.state=Ht,r=new Array(f=n.tween.length),d=0,u=-1;d<f;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=h);r.length=u+1}}function a(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=zn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);n.state===zn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Lt,n.timer.stop(),delete o[t];for(var c in o)return;delete e.__transition}}function Bt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>Rn&&o.state<zn,o.state=Lt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Zl(e){return this.each(function(){Bt(this,e)})}function Gl(e,t){var n,o;return function(){var r=we(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function ql(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=we(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Ul(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=pe(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?Gl:ql)(n,e,t))}function Kn(e,t,n){var o=e._id;return e.each(function(){var r=we(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return pe(r,o).value[t]}}function Kr(e,t){var n;return(typeof t=="number"?me:t instanceof Re?Xt:(n=Re(t))?(t=n,Xt):Xr)(e,t)}function Kl(e){return function(){this.removeAttribute(e)}}function Ql(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Jl(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function eu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function tu(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function nu(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function ou(e,t){var n=Jt(e),o=n==="transform"?zl:Kr;return this.attrTween(e,typeof t=="function"?(n.local?nu:tu)(n,o,Kn(this,"attr."+e,t)):t==null?(n.local?Ql:Kl)(n):(n.local?eu:Jl)(n,o,t))}function ru(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function iu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function su(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&iu(e,i)),n}return r._value=t,r}function au(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&ru(e,i)),n}return r._value=t,r}function cu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Jt(e);return this.tween(n,(o.local?su:au)(o,t))}function lu(e,t){return function(){Un(this,e).delay=+t.apply(this,arguments)}}function uu(e,t){return t=+t,function(){Un(this,e).delay=t}}function du(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lu:uu)(t,e)):pe(this.node(),t).delay}function fu(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function hu(e,t){return t=+t,function(){we(this,e).duration=t}}function gu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?fu:hu)(t,e)):pe(this.node(),t).duration}function pu(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function mu(e){var t=this._id;return arguments.length?this.each(pu(t,e)):pe(this.node(),t).ease}function yu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;we(this,e).ease=n}}function xu(e){if(typeof e!="function")throw new Error;return this.each(yu(this._id,e))}function wu(e){typeof e!="function"&&(e=Ir(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ee(o,this._parents,this._name,this._id)}function vu(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var l=t[a],c=n[a],d=l.length,u=s[a]=new Array(d),f,h=0;h<d;++h)(f=l[h]||c[h])&&(u[h]=f);for(;a<o;++a)s[a]=t[a];return new Ee(s,this._parents,this._name,this._id)}function bu(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 _u(e,t,n){var o,r,i=bu(t)?Un:we;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Eu(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(_u(n,e,t))}function Nu(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Su(){return this.on("end.remove",Nu(this._id))}function Cu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Yn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],l=a.length,c=i[s]=new Array(l),d,u,f=0;f<l;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,tn(c[f],t,n,f,c,pe(d,n)));return new Ee(i,this._parents,t,n)}function Mu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l=o[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),h,g=pe(d,n),y=0,x=f.length;y<x;++y)(h=f[y])&&tn(h,t,n,y,f,g);i.push(f),s.push(d)}return new Ee(i,s,t,n)}var Iu=xt.prototype.constructor;function ku(){return new Iu(this._groups,this._parents)}function Au(e,t){var n,o,r;return function(){var i=We(this,e),s=(this.style.removeProperty(e),We(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Qr(e){return function(){this.style.removeProperty(e)}}function Pu(e,t,n){var o,r=n+"",i;return function(){var s=We(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function $u(e,t,n){var o,r,i;return function(){var s=We(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),We(this,e))),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}function Du(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var l=we(this,e),c=l.on,d=l.value[i]==null?a||(a=Qr(t)):void 0;(c!==n||r!==d)&&(o=(n=c).copy()).on(s,r=d),l.on=o}}function Tu(e,t,n){var o=(e+="")=="transform"?Rl:Kr;return t==null?this.styleTween(e,Au(e,o)).on("end.style."+e,Qr(e)):typeof t=="function"?this.styleTween(e,$u(e,o,Kn(this,"style."+e,t))).each(Du(this._id,e)):this.styleTween(e,Pu(e,o,t),n).on("end.style."+e,null)}function Ru(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function zu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Ru(e,s,n)),o}return i._value=t,i}function Hu(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,zu(e,t,n??""))}function Lu(e){return function(){this.textContent=e}}function Bu(e){return function(){var t=e(this);this.textContent=t??""}}function Vu(e){return this.tween("text",typeof e=="function"?Bu(Kn(this,"text",e)):Lu(e==null?"":e+""))}function Ou(e){return function(t){this.textContent=e.call(this,t)}}function ju(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Ou(r)),t}return o._value=e,o}function Fu(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,ju(e))}function Xu(){for(var e=this._name,t=this._id,n=Jr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=pe(l,t);tn(l,e,n,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ee(o,this._parents,e,n)}function Yu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};n.each(function(){var c=we(this,o),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Wu=0;function Ee(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Jr(){return++Wu}var be=xt.prototype;Ee.prototype={constructor:Ee,select:Cu,selectAll:Mu,selectChild:be.selectChild,selectChildren:be.selectChildren,filter:wu,merge:vu,selection:ku,transition:Xu,call:be.call,nodes:be.nodes,node:be.node,size:be.size,empty:be.empty,each:be.each,on:Eu,attr:ou,attrTween:cu,style:Tu,styleTween:Hu,text:Vu,textTween:Fu,remove:Su,tween:Ul,delay:du,duration:gu,ease:mu,easeVarying:xu,end:Yu,[Symbol.iterator]:be[Symbol.iterator]};function Zu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Gu={time:null,delay:0,duration:250,ease:Zu};function qu(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 Uu(e){var t,n;e instanceof Ee?(t=e._id,e=e._name):(t=Jr(),(n=Gu).time=qn(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&tn(l,e,t,c,s,n||qu(l,t));return new Ee(o,this._parents,e,t)}xt.prototype.interrupt=Zl;xt.prototype.transition=Uu;const At=e=>()=>e;function Ku(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function _e(e,t,n){this.k=e,this.x=t,this.y=n}_e.prototype={constructor:_e,scale:function(e){return e===1?this:new _e(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _e(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 _e(1,0,0);ei.prototype=_e.prototype;function ei(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function xn(e){e.stopImmediatePropagation()}function rt(e){e.preventDefault(),e.stopImmediatePropagation()}function Qu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ju(){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 To(){return this.__zoom||nn}function ed(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function td(){return navigator.maxTouchPoints||"ontouchstart"in this}function nd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function ti(){var e=Qu,t=Ju,n=nd,o=ed,r=td,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=zt,c=Qt("start","zoom","end"),d,u,f,h=500,g=150,y=0,x=10;function m(v){v.property("__zoom",To).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(v,M,C,P){var k=v.selection?v.selection():v;k.property("__zoom",To),v!==k?S(v,M,C,P):k.interrupt().each(function(){N(this,arguments).event(P).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},m.scaleBy=function(v,M,C,P){m.scaleTo(v,function(){var k=this.__zoom.k,D=typeof M=="function"?M.apply(this,arguments):M;return k*D},C,P)},m.scaleTo=function(v,M,C,P){m.transform(v,function(){var k=t.apply(this,arguments),D=this.__zoom,H=C==null?w(k):typeof C=="function"?C.apply(this,arguments):C,B=D.invert(H),L=typeof M=="function"?M.apply(this,arguments):M;return n(p(b(D,L),H,B),k,s)},C,P)},m.translateBy=function(v,M,C,P){m.transform(v,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,P)},m.translateTo=function(v,M,C,P,k){m.transform(v,function(){var D=t.apply(this,arguments),H=this.__zoom,B=P==null?w(D):typeof P=="function"?P.apply(this,arguments):P;return n(nn.translate(B[0],B[1]).scale(H.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof C=="function"?-C.apply(this,arguments):-C),D,s)},P,k)};function b(v,M){return M=Math.max(i[0],Math.min(i[1],M)),M===v.k?v:new _e(M,v.x,v.y)}function p(v,M,C){var P=M[0]-C[0]*v.k,k=M[1]-C[1]*v.k;return P===v.x&&k===v.y?v:new _e(v.k,P,k)}function w(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function S(v,M,C,P){v.on("start.zoom",function(){N(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(P).end()}).tween("zoom",function(){var k=this,D=arguments,H=N(k,D).event(P),B=t.apply(k,D),L=C==null?w(B):typeof C=="function"?C.apply(k,D):C,Z=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),F=k.__zoom,z=typeof M=="function"?M.apply(k,D):M,X=l(F.invert(L).concat(Z/F.k),z.invert(L).concat(Z/z.k));return function(Y){if(Y===1)Y=z;else{var j=X(Y),G=Z/j[2];Y=new _e(G,L[0]-j[0]*G,L[1]-j[1]*G)}H.zoom(null,Y)}})}function N(v,M,C){return!C&&v.__zooming||new _(v,M)}function _(v,M){this.that=v,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,M),this.taps=0}_.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,M){return this.mouse&&v!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var M=le(this.that).datum();c.call(v,this.that,new Ku(v,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:c}),M)}};function I(v,...M){if(!e.apply(this,arguments))return;var C=N(this,M).event(v),P=this.__zoom,k=Math.max(i[0],Math.min(i[1],P.k*Math.pow(2,o.apply(this,arguments)))),D=de(v);if(C.wheel)(C.mouse[0][0]!==D[0]||C.mouse[0][1]!==D[1])&&(C.mouse[1]=P.invert(C.mouse[0]=D)),clearTimeout(C.wheel);else{if(P.k===k)return;C.mouse=[D,P.invert(D)],Bt(this),C.start()}rt(v),C.wheel=setTimeout(H,g),C.zoom("mouse",n(p(b(P,k),C.mouse[0],C.mouse[1]),C.extent,s));function H(){C.wheel=null,C.end()}}function $(v,...M){if(f||!e.apply(this,arguments))return;var C=v.currentTarget,P=N(this,M,!0).event(v),k=le(v.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",Z,!0),D=de(v,C),H=v.clientX,B=v.clientY;Lr(v.view),xn(v),P.mouse=[D,this.__zoom.invert(D)],Bt(this),P.start();function L(F){if(rt(F),!P.moved){var z=F.clientX-H,X=F.clientY-B;P.moved=z*z+X*X>y}P.event(F).zoom("mouse",n(p(P.that.__zoom,P.mouse[0]=de(F,C),P.mouse[1]),P.extent,s))}function Z(F){k.on("mousemove.zoom mouseup.zoom",null),Br(F.view,P.moved),rt(F),P.event(F).end()}}function O(v,...M){if(e.apply(this,arguments)){var C=this.__zoom,P=de(v.changedTouches?v.changedTouches[0]:v,this),k=C.invert(P),D=C.k*(v.shiftKey?.5:2),H=n(p(b(C,D),P,k),t.apply(this,M),s);rt(v),a>0?le(this).transition().duration(a).call(S,H,P,v):le(this).call(m.transform,H,P,v)}}function A(v,...M){if(e.apply(this,arguments)){var C=v.touches,P=C.length,k=N(this,M,v.changedTouches.length===P).event(v),D,H,B,L;for(xn(v),H=0;H<P;++H)B=C[H],L=de(B,this),L=[L,this.__zoom.invert(L),B.identifier],k.touch0?!k.touch1&&k.touch0[2]!==L[2]&&(k.touch1=L,k.taps=0):(k.touch0=L,D=!0,k.taps=1+!!d);d&&(d=clearTimeout(d)),D&&(k.taps<2&&(u=L[0],d=setTimeout(function(){d=null},h)),Bt(this),k.start())}}function R(v,...M){if(this.__zooming){var C=N(this,M).event(v),P=v.changedTouches,k=P.length,D,H,B,L;for(rt(v),D=0;D<k;++D)H=P[D],B=de(H,this),C.touch0&&C.touch0[2]===H.identifier?C.touch0[0]=B:C.touch1&&C.touch1[2]===H.identifier&&(C.touch1[0]=B);if(H=C.that.__zoom,C.touch1){var Z=C.touch0[0],F=C.touch0[1],z=C.touch1[0],X=C.touch1[1],Y=(Y=z[0]-Z[0])*Y+(Y=z[1]-Z[1])*Y,j=(j=X[0]-F[0])*j+(j=X[1]-F[1])*j;H=b(H,Math.sqrt(Y/j)),B=[(Z[0]+z[0])/2,(Z[1]+z[1])/2],L=[(F[0]+X[0])/2,(F[1]+X[1])/2]}else if(C.touch0)B=C.touch0[0],L=C.touch0[1];else return;C.zoom("touch",n(p(H,B,L),C.extent,s))}}function V(v,...M){if(this.__zooming){var C=N(this,M).event(v),P=v.changedTouches,k=P.length,D,H;for(xn(v),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),D=0;D<k;++D)H=P[D],C.touch0&&C.touch0[2]===H.identifier?delete C.touch0:C.touch1&&C.touch1[2]===H.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(H=de(H,this),Math.hypot(u[0]-H[0],u[1]-H[1])<x)){var B=le(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return m.wheelDelta=function(v){return arguments.length?(o=typeof v=="function"?v:At(+v),m):o},m.filter=function(v){return arguments.length?(e=typeof v=="function"?v:At(!!v),m):e},m.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:At(!!v),m):r},m.extent=function(v){return arguments.length?(t=typeof v=="function"?v:At([[+v[0][0],+v[0][1]],[+v[1][0],+v[1][1]]]),m):t},m.scaleExtent=function(v){return arguments.length?(i[0]=+v[0],i[1]=+v[1],m):[i[0],i[1]]},m.translateExtent=function(v){return arguments.length?(s[0][0]=+v[0][0],s[1][0]=+v[1][0],s[0][1]=+v[0][1],s[1][1]=+v[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(v){return arguments.length?(n=v,m):n},m.duration=function(v){return arguments.length?(a=+v,m):a},m.interpolate=function(v){return arguments.length?(l=v,m):l},m.on=function(){var v=c.on.apply(c,arguments);return v===c?m:v},m.clickDistance=function(v){return arguments.length?(y=(v=+v)*v,m):Math.sqrt(y)},m.tapDistance=function(v){return arguments.length?(x=+v,m):x},m}const xe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ht=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ni=["Enter"," ","Escape"],oi={"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 He;(function(e){e.Strict="strict",e.Loose="loose"})(He||(He={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var gt;(function(e){e.Partial="partial",e.Full="full"})(gt||(gt={}));const ri={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var Gt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Gt||(Gt={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const Ro={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top};function ii(e){return e===null?null:e?"valid":"invalid"}const si=e=>"id"in e&&"source"in e&&"target"in e,od=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Qn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vt=(e,t=[0,0])=>{const{width:n,height:o}=Ne(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},rd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):Qn(r)?r:t.nodeLookup.get(r.id));const a=s?qt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return on(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return rn(n)},bt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=on(n,qt(r)),o=!0)}),o?rn(n):{x:0,y:0,width:0,height:0}},Jn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...Et(t,[n,o,r]),width:t.width/r,height:t.height/r},l=[];for(const c of e.values()){const{measured:d,selectable:u=!0,hidden:f=!1}=c;if(s&&!u||f)continue;const h=d.width??c.width??c.initialWidth??null,g=d.height??c.height??c.initialHeight??null,y=pt(a,qe(c)),x=(h??0)*(g??0),m=i&&y>0;(!c.internals.handleBounds||m||y>=x||c.dragging)&&l.push(c)}return l},id=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function sd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function ad({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=sd(e,s),l=bt(a),c=eo(l,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(c,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function ai({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},d=s.origin??o;let u=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",xe.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[l,c],[l+h,c+g]])}else a&&Ue(s.extent)&&(u=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const f=Ue(u)?Le(t,u,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",xe.error015()),{position:{x:f.x-l+(s.measured.width??0)*d[0],y:f.y-c+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function cd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(y=>y.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),l=o.filter(f=>f.deletable!==!1),d=id(s,l);for(const f of l)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!r)return{edges:d,nodes:s};const u=await r({nodes:s,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:s}:{edges:[],nodes:[]}:u}const Ge=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Le=(e={x:0,y:0},t,n)=>({x:Ge(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ge(e.y,t[0][1],t[1][1]-(n?.height??0))});function ci(e,t,n){const{width:o,height:r}=Ne(n),{x:i,y:s}=n.internals.positionAbsolute;return Le(e,[[i,s],[i+o,s+r]],t)}const zo=(e,t,n)=>e<t?Ge(Math.abs(e-t),1,t)/t:e>n?-Ge(Math.abs(e-n),1,t)/t:0,li=(e,t,n=15,o=40)=>{const r=zo(e.x,o,t.width-o)*n,i=zo(e.y,o,t.height-o)*n;return[r,i]},on=(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)}),Hn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),rn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),qe=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:vt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},qt=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:vt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},ui=(e,t)=>rn(on(Hn(e),Hn(t))),pt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Ho=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),ld=(e,t)=>{},_t=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Et=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?_t(a,s):a},Ut=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Oe(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(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function ud(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Oe(e,n),r=Oe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Oe(e.top??e.y??0,n),r=Oe(e.bottom??e.y??0,n),i=Oe(e.left??e.x??0,t),s=Oe(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function dd(e,t,n,o,r,i){const{x:s,y:a}=Ut(e,[t,n,o]),{x:l,y:c}=Ut({x:e.x+e.width,y:e.y+e.height},[t,n,o]),d=r-l,u=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}const eo=(e,t,n,o,r,i)=>{const s=ud(i,t,n),a=(t-s.x)/e.width,l=(n-s.y)/e.height,c=Math.min(a,l),d=Ge(c,o,r),u=e.x+e.width/2,f=e.y+e.height/2,h=t/2-u*d,g=n/2-f*d,y=dd(e,h,g,d,t,n),x={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:d}},mt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ue(e){return e!=null&&e!=="parent"}function Ne(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function di(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function fi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Lo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function fd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function hd(e){return{...oi,...e||{}}}function ct(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=ge(e),a=Et({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:l,y:c}=n?_t(a,t):a;return{xSnapped:l,ySnapped:c,...a}}const to=e=>({width:e.offsetWidth,height:e.offsetHeight}),hi=e=>e?.getRootNode?.()||window?.document,gd=["INPUT","SELECT","TEXTAREA"];function gi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:gd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const pi=e=>"clientX"in e,ge=(e,t)=>{const n=pi(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Bo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...to(s)}})};function mi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=e*.125+r*.375+s*.375+n*.125,c=t*.125+i*.375+a*.375+o*.125,d=Math.abs(l-e),u=Math.abs(c-t);return[l,c,d,u]}function Pt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Vo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case W.Left:return[t-Pt(t-o,i),n];case W.Right:return[t+Pt(o-t,i),n];case W.Top:return[t,n-Pt(n-r,i)];case W.Bottom:return[t,n+Pt(r-n,i)]}}function yi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top,curvature:s=.25}){const[a,l]=Vo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,d]=Vo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[u,f,h,g]=mi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${o},${r}`,u,f,h,g]}function xi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function pd({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function md({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=on(qt(e),qt(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return pt(s,rn(i))>0}const yd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,xd=(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)),wd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||yd;let r;return si(e)?r={...e}:r={...e,id:o(e)},xd(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function wi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=xi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Oo={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},vd=({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},jo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function bd({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:o=W.Top,center:r,offset:i,stepPosition:s}){const a=Oo[t],l=Oo[o],c={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+l.x*i,y:n.y+l.y*i},u=vd({source:c,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],y,x;const m={x:0,y:0},b={x:0,y:0},[,,p,w]=xi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*l[f]===-1){f==="x"?(y=r.x??c.x+(d.x-c.x)*s,x=r.y??(c.y+d.y)/2):(y=r.x??(c.x+d.x)/2,x=r.y??c.y+(d.y-c.y)*s);const I=[{x:y,y:c.y},{x:y,y:d.y}],$=[{x:c.x,y:x},{x:d.x,y:x}];a[f]===h?g=f==="x"?I:$:g=f==="x"?$:I}else{const I=[{x:c.x,y:d.y}],$=[{x:d.x,y:c.y}];if(f==="x"?g=a.x===h?$:I:g=a.y===h?I:$,t===o){const v=Math.abs(e[f]-n[f]);if(v<=i){const M=Math.min(i-1,i-v);a[f]===h?m[f]=(c[f]>e[f]?-1:1)*M:b[f]=(d[f]>n[f]?-1:1)*M}}if(t!==o){const v=f==="x"?"y":"x",M=a[f]===l[v],C=c[v]>d[v],P=c[v]<d[v];(a[f]===1&&(!M&&C||M&&P)||a[f]!==1&&(!M&&P||M&&C))&&(g=f==="x"?I:$)}const O={x:c.x+m.x,y:c.y+m.y},A={x:d.x+b.x,y:d.y+b.y},R=Math.max(Math.abs(O.x-g[0].x),Math.abs(A.x-g[0].x)),V=Math.max(Math.abs(O.y-g[0].y),Math.abs(A.y-g[0].y));R>=V?(y=(O.x+A.x)/2,x=g[0].y):(y=g[0].x,x=(O.y+A.y)/2)}const S={x:c.x+m.x,y:c.y+m.y},N={x:d.x+b.x,y:d.y+b.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],y,x,p,w]}function _d(e,t,n,o){const r=Math.min(jo(e,t)/2,jo(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const c=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*d}`}const a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${s+r*l}Q ${i},${s} ${i+r*a},${s}`}function Ln({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:d=.5}){const[u,f,h,g,y]=bd({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:d});let x=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)x+=_d(u[m-1],u[m],u[m+1],s);return x+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[x,f,h,g,y]}function Fo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ed(e){const{sourceNode:t,targetNode:n}=e;if(!Fo(t)||!Fo(n))return null;const o=t.internals.handleBounds||Xo(t.handles),r=n.internals.handleBounds||Xo(n.handles),i=Yo(o?.source??[],e.sourceHandle),s=Yo(e.connectionMode===He.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",xe.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||W.Bottom,l=s?.position||W.Top,c=Be(t,i,a),d=Be(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:l}}function Xo(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Be(e,t,n=W.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??Ne(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case W.Top:return{x:r+s/2,y:i};case W.Right:return{x:r+s,y:i+a/2};case W.Bottom:return{x:r+s/2,y:i+a};case W.Left:return{x:r,y:i+a/2}}}function Yo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Bn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Nd(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(l=>{if(l&&typeof l=="object"){const c=Bn(l,t);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const vi=1e3,Sd=10,no={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Cd={...no,checkEquality:!0};function oo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Md(e,t,n){const o=oo(no,n);for(const r of e.values())if(r.parentId)io(r,e,t,o);else{const i=vt(r,o.nodeOrigin),s=Ue(r.extent)?r.extent:o.nodeExtent,a=Le(i,s,Ne(r));r.internals.positionAbsolute=a}}function Id(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function ro(e){return e==="manual"}function Vn(e,t,n,o={}){const r=oo(Cd,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!ro(r.zIndexMode)?vi:0;let l=e.length>0,c=!1;t.clear(),n.clear();for(const d of e){let u=s.get(d.id);if(r.checkEquality&&d===u?.internals.userNode)t.set(d.id,u);else{const f=vt(d,r.nodeOrigin),h=Ue(d.extent)?d.extent:r.nodeExtent,g=Le(f,h,Ne(d));u={...r.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:g,handleBounds:Id(d,u),z:bi(d,a,r.zIndexMode),userNode:d}},t.set(d.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),d.parentId&&io(u,t,n,o,i),c||=d.selected??!1}return{nodesInitialized:l,hasSelectedNodes:c}}function kd(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 io(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=oo(no,o),c=e.parentId,d=t.get(c);if(!d){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}kd(e,n),r&&!d.parentId&&d.internals.rootParentIndex===void 0&&l==="auto"&&(d.internals.rootParentIndex=++r.i,d.internals.z=d.internals.z+r.i*Sd),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const u=i&&!ro(l)?vi:0,{x:f,y:h,z:g}=Ad(e,d,s,a,u,l),{positionAbsolute:y}=e.internals,x=f!==y.x||h!==y.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:y,z:g}})}function bi(e,t,n){const o=he(e.zIndex)?e.zIndex:0;return ro(n)?o:o+(e.selected?t:0)}function Ad(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,l=Ne(e),c=vt(e,n),d=Ue(e.extent)?Le(c,e.extent,l):c;let u=Le({x:s+d.x,y:a+d.y},o,l);e.extent==="parent"&&(u=ci(u,l,t));const f=bi(e,r,i),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function so(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const l=i.get(s.parentId)?.expandedRect??qe(a),c=ui(l,s.rect);i.set(s.parentId,{expandedRect:c,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},l)=>{const c=a.internals.positionAbsolute,d=Ne(a),u=a.origin??o,f=s.x<c.x?Math.round(Math.abs(c.x-s.x)):0,h=s.y<c.y?Math.round(Math.abs(c.y-s.y)):0,g=Math.max(d.width,Math.round(s.width)),y=Math.max(d.height,Math.round(s.height)),x=(g-d.width)*u[0],m=(y-d.height)*u[1];(f>0||h>0||x||m)&&(r.push({id:l,type:"position",position:{x:a.position.x-f+x,y:a.position.y-h+m}}),n.get(l)?.forEach(b=>{e.some(p=>p.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(d.width<s.width||d.height<s.height||f||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:g+(f?u[0]*f-x:0),height:y+(h?u[1]*h-m:0)}})}),r}function Pd(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],d=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];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}}),l=!0;continue}const y=to(h.nodeElement),x=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(x||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ue(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=ci(w,y,t.get(g.parentId)):p&&(w=Le(w,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:Bo("source",h.nodeElement,b,u,g.id),target:Bo("target",h.nodeElement,b,u,g.id)}}};t.set(g.id,S),g.parentId&&io(S,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,x&&(c.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:qe(S,r)}))}}if(f.length>0){const h=so(f,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function $d({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Wo(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const l=o.get(s)||new Map;if(o.set(s,l.set(n,t)),i){s=`${r}-${e}-${i}`;const c=o.get(s)||new Map;o.set(s,c.set(n,t))}}function _i(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,l={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},c=`${r}-${s}--${i}-${a}`,d=`${i}-${a}--${r}-${s}`;Wo("source",l,d,e,r,s),Wo("target",l,c,e,i,a),t.set(o.id,o)}}function Ei(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ei(n,t):!1}function Zo(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Dd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Ei(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function wn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const l=n.get(s)?.internals.userNode;l&&r.push({...l,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function Td({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=_t(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Rd({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},d=null,u=!1,f=null,h=!1,g=!1,y=null;function x({noDragClassName:b,handleSelector:p,domNode:w,isSelectable:S,nodeId:N,nodeClickDistance:_=0}){f=le(w);function I({x:R,y:V}){const{nodeLookup:v,nodeExtent:M,snapGrid:C,snapToGrid:P,nodeOrigin:k,onNodeDrag:D,onSelectionDrag:H,onError:B,updateNodePositions:L}=t();i={x:R,y:V};let Z=!1;const F=a.size>1,z=F&&M?Hn(bt(a)):null,X=F&&P?Td({dragItems:a,snapGrid:C,x:R,y:V}):null;for(const[Y,j]of a){if(!v.has(Y))continue;let G={x:R-j.distance.x,y:V-j.distance.y};P&&(G=X?{x:Math.round(G.x+X.x),y:Math.round(G.y+X.y)}:_t(G,C));let Q=null;if(F&&M&&!j.extent&&z){const{positionAbsolute:U}=j.internals,te=U.x-z.x+M[0][0],oe=U.x+j.measured.width-z.x2+M[1][0],ne=U.y-z.y+M[0][1],ae=U.y+j.measured.height-z.y2+M[1][1];Q=[[te,ne],[oe,ae]]}const{position:K,positionAbsolute:q}=ai({nodeId:Y,nextPosition:G,nodeLookup:v,nodeExtent:Q||M,nodeOrigin:k,onError:B});Z=Z||j.position.x!==K.x||j.position.y!==K.y,j.position=K,j.internals.positionAbsolute=q}if(g=g||Z,!!Z&&(L(a,!0),y&&(o||D||!N&&H))){const[Y,j]=wn({nodeId:N,dragItems:a,nodeLookup:v});o?.(y,a,Y,j),D?.(y,Y,j),N||H?.(y,j)}}async function $(){if(!d)return;const{transform:R,panBy:V,autoPanSpeed:v,autoPanOnNodeDrag:M}=t();if(!M){l=!1,cancelAnimationFrame(s);return}const[C,P]=li(c,d,v);(C!==0||P!==0)&&(i.x=(i.x??0)-C/R[2],i.y=(i.y??0)-P/R[2],await V({x:C,y:P})&&I(i)),s=requestAnimationFrame($)}function O(R){const{nodeLookup:V,multiSelectionActive:v,nodesDraggable:M,transform:C,snapGrid:P,snapToGrid:k,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:B,unselectNodesAndEdges:L}=t();u=!0,(!D||!S)&&!v&&N&&(V.get(N)?.selected||L()),S&&D&&N&&e?.(N);const Z=ct(R.sourceEvent,{transform:C,snapGrid:P,snapToGrid:k,containerBounds:d});if(i=Z,a=Dd(V,M,Z,N),a.size>0&&(n||H||!N&&B)){const[F,z]=wn({nodeId:N,dragItems:a,nodeLookup:V});n?.(R.sourceEvent,a,F,z),H?.(R.sourceEvent,F,z),N||B?.(R.sourceEvent,z)}}const A=Vr().clickDistance(_).on("start",R=>{const{domNode:V,nodeDragThreshold:v,transform:M,snapGrid:C,snapToGrid:P}=t();d=V?.getBoundingClientRect()||null,h=!1,g=!1,y=R.sourceEvent,v===0&&O(R),i=ct(R.sourceEvent,{transform:M,snapGrid:C,snapToGrid:P,containerBounds:d}),c=ge(R.sourceEvent,d)}).on("drag",R=>{const{autoPanOnNodeDrag:V,transform:v,snapGrid:M,snapToGrid:C,nodeDragThreshold:P,nodeLookup:k}=t(),D=ct(R.sourceEvent,{transform:v,snapGrid:M,snapToGrid:C,containerBounds:d});if(y=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||N&&!k.has(N))&&(h=!0),!h){if(!l&&V&&u&&(l=!0,$()),!u){const H=ge(R.sourceEvent,d),B=H.x-c.x,L=H.y-c.y;Math.sqrt(B*B+L*L)>P&&O(R)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&a&&u&&(c=ge(R.sourceEvent,d),I(D))}}).on("end",R=>{if(!(!u||h)&&(l=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:V,updateNodePositions:v,onNodeDragStop:M,onSelectionDragStop:C}=t();if(g&&(v(a,!1),g=!1),r||M||!N&&C){const[P,k]=wn({nodeId:N,dragItems:a,nodeLookup:V,dragging:!1});r?.(R.sourceEvent,a,P,k),M?.(R.sourceEvent,P,k),N||C?.(R.sourceEvent,k)}}}).filter(R=>{const V=R.target;return!R.button&&(!b||!Zo(V,`.${b}`,w))&&(!p||Zo(V,p,w))});f.call(A)}function m(){f?.on(".drag",null)}return{update:x,destroy:m}}function zd(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())pt(r,qe(i))>0&&o.push(i);return o}const Hd=250;function Ld(e,t,n,o){let r=[],i=1/0;const s=zd(e,n,t+Hd);for(const a of s){const l=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const c of l){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:d,y:u}=Be(a,c,c.position,!0),f=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(u-e.y,2));f>t||(f<i?(r=[{...c,x:d,y:u}],i=f):f===i&&r.push({...c,x:d,y:u}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(l=>l.type===a)??r[0]}return r[0]}function Ni(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],l=(n?a?.find(c=>c.id===n):a?.[0])??null;return l&&i?{...l,...Be(s,l,l.position,!0)}:l}function Si(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Bd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ci=()=>!0;function Vd(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:y,onConnectEnd:x,isValidConnection:m=Ci,onReconnectEnd:b,updateConnection:p,getTransform:w,getFromHandle:S,autoPanSpeed:N,dragThreshold:_=1,handleDomNode:I}){const $=hi(e.target);let O=0,A;const{x:R,y:V}=ge(e),v=Si(i,I),M=a?.getBoundingClientRect();let C=!1;if(!M||!v)return;const P=Ni(r,v,o,l,t);if(!P)return;let k=ge(e,M),D=!1,H=null,B=!1,L=null;function Z(){if(!d||!M)return;const[K,q]=li(k,M,N);f({x:K,y:q}),O=requestAnimationFrame(Z)}const F={...P,nodeId:r,type:v,position:P.position},z=l.get(r);let Y={inProgress:!0,isValid:null,from:Be(z,F,W.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:z,to:k,toHandle:null,toPosition:Ro[F.position],toNode:null,pointer:k};function j(){C=!0,p(Y),g?.(e,{nodeId:r,handleId:o,handleType:v})}_===0&&j();function G(K){if(!C){const{x:ae,y:Se}=ge(K),ve=ae-R,Ae=Se-V;if(!(ve*ve+Ae*Ae>_*_))return;j()}if(!S()||!F){Q(K);return}const q=w();k=ge(K,M),A=Ld(Et(k,q,!1,[1,1]),n,l,F),D||(Z(),D=!0);const U=Mi(K,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:$,lib:c,flowId:u,nodeLookup:l});L=U.handleDomNode,H=U.connection,B=Bd(!!A,U.isValid);const te=l.get(r),oe=te?Be(te,F,W.Left,!0):Y.from,ne={...Y,from:oe,isValid:B,to:U.toHandle&&B?Ut({x:U.toHandle.x,y:U.toHandle.y},q):k,toHandle:U.toHandle,toPosition:B&&U.toHandle?U.toHandle.position:Ro[F.position],toNode:U.toHandle?l.get(U.toHandle.nodeId):null,pointer:k};p(ne),Y=ne}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(C){(A||L)&&H&&B&&y?.(H);const{inProgress:q,...U}=Y,te={...U,toPosition:Y.toHandle?Y.toPosition:null};x?.(K,te),i&&b?.(K,te)}h(),cancelAnimationFrame(O),D=!1,B=!1,H=null,L=null,$.removeEventListener("mousemove",G),$.removeEventListener("mouseup",Q),$.removeEventListener("touchmove",G),$.removeEventListener("touchend",Q)}}$.addEventListener("mousemove",G),$.addEventListener("mouseup",Q),$.addEventListener("touchmove",G),$.addEventListener("touchend",Q)}function Mi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Ci,nodeLookup:d}){const u=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=ge(e),y=s.elementFromPoint(h,g),x=y?.classList.contains(`${a}-flow__handle`)?y:f,m={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const b=Si(void 0,x),p=x.getAttribute("data-nodeid"),w=x.getAttribute("data-handleid"),S=x.classList.contains("connectable"),N=x.classList.contains("connectableend");if(!p||!b)return m;const _={source:u?p:o,sourceHandle:u?w:r,target:u?o:p,targetHandle:u?r:w};m.connection=_;const $=S&&N&&(n===He.Strict?u&&b==="source"||!u&&b==="target":p!==o||w!==r);m.isValid=$&&c(_),m.toHandle=Ni(p,b,w,d,n,!0)}return m}const On={onPointerDown:Vd,isValid:Mi};function Od({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=le(e);function i({translateExtent:a,width:l,height:c,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),S=p.sourceEvent.ctrlKey&&mt()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,_=w[2]*Math.pow(2,N*S);t.scaleTo(_)};let y=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const w=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],N=[S[0]-y[0],S[1]-y[1]];y=S;const _=o()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),I={x:w[0]-N[0]*_,y:w[1]-N[1]*_},$=[[0,0],[l,c]];t.setViewportConstrained({x:I.x,y:I.y,zoom:w[2]},$,a)},b=ti().on("start",x).on("zoom",u?m:null).on("zoom.wheel",f?g:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:de}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),vn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Ii=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),jd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bn=(e,t=0,n=jd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},ki=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fd({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return d=>{if(je(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(d.ctrlKey&&s){const x=de(d),m=ki(d),b=u*Math.pow(2,m);o.scaleTo(n,b,x,d);return}const f=d.deltaMode===1?20:1;let h=r===Te.Vertical?0:d.deltaX*f,g=r===Te.Horizontal?0:d.deltaY*f;!mt()&&d.shiftKey&&r!==Te.Vertical&&(h=d.deltaY*f,g=0),o.translateBy(n,-(h/u)*i,-(g/u)*i,{internal:!0});const y=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(d,y),e.panScrollTimeout=setTimeout(()=>{c?.(d,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(d,y))}}function Xd({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=je(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Yd({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=sn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Wd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ii(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,sn(i.transform))}}function Zd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ii(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=sn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function Gd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:d}){return u=>{const f=e||t,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(je(u,`${c}-flow__node`)||je(u,`${c}-flow__edge`)))return!0;if(!o&&!f&&!r&&!i&&!n||s||d&&!g||je(u,a)&&g||je(u,l)&&(!g||r&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&u.touches?.length>1)return u.preventDefault(),!1;if(!f&&!r&&!h&&g||!o&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(o)&&!o.includes(u.button)&&u.type==="mousedown")return!1;const y=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&y}}function qd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=ti().scaleExtent([t,n]).translateExtent(o),f=le(e).call(u);b({x:r.x,y:r.y,zoom:Ge(r.zoom,t,n)},[[0,0],[d.width,d.height]],o);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(ki);function y(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).transform(bn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function x({noWheelClassName:A,noPanClassName:R,onPaneContextMenu:V,userSelectionActive:v,panOnScroll:M,panOnDrag:C,panOnScrollMode:P,panOnScrollSpeed:k,preventScrolling:D,zoomOnPinch:H,zoomOnScroll:B,zoomOnDoubleClick:L,zoomActivationKeyPressed:Z,lib:F,onTransformChange:z,connectionInProgress:X,paneClickDistance:Y,selectionOnDrag:j}){v&&!c.isZoomingOrPanning&&m();const G=M&&!Z&&!v;u.clickDistance(j?1/0:!he(Y)||Y<0?0:Y);const Q=G?Fd({zoomPanValues:c,noWheelClassName:A,d3Selection:f,d3Zoom:u,panOnScrollMode:P,panOnScrollSpeed:k,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Xd({noWheelClassName:A,preventScrolling:D,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const q=Yd({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});u.on("start",q);const U=Wd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!V,onPanZoom:i,onTransformChange:z});u.on("zoom",U);const te=Zd({zoomPanValues:c,panOnDrag:C,panOnScroll:M,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:l});u.on("end",te)}const K=Gd({zoomActivationKeyPressed:Z,panOnDrag:C,zoomOnScroll:B,panOnScroll:M,zoomOnDoubleClick:L,zoomOnPinch:H,userSelectionActive:v,noPanClassName:R,noWheelClassName:A,lib:F,connectionInProgress:X});u.filter(K),L?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function b(A,R,V){const v=vn(A),M=u?.constrain()(v,R,V);return M&&await y(M),new Promise(C=>C(M))}async function p(A,R){const V=vn(A);return await y(V,R),new Promise(v=>v(V))}function w(A){if(f){const R=vn(A),V=f.property("__zoom");(V.k!==A.zoom||V.x!==A.x||V.y!==A.y)&&u?.transform(f,R,null,{sync:!0})}}function S(){const A=f?ei(f.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function N(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).scaleTo(bn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function _(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).scaleBy(bn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function I(A){u?.scaleExtent(A)}function $(A){u?.translateExtent(A)}function O(A){const R=!he(A)||A<0?0:A;u?.clickDistance(R)}return{update:x,destroy:m,setViewport:p,setViewportConstrained:b,getViewport:S,scaleTo:N,scaleBy:_,setScaleExtent:I,setTranslateExtent:$,syncViewport:w,setClickDistance:O}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function Ud({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function Go(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Ce(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function $t(e,t,n){return Math.max(0,t-e,e-n)}function qo(e,t){return e?!t:t}function Kd(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:d,isVertical:u}=t,f=d&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:y,maxWidth:x,minHeight:m,maxHeight:b}=o,{x:p,y:w,width:S,height:N,aspectRatio:_}=e;let I=Math.floor(d?h-e.pointerX:0),$=Math.floor(u?g-e.pointerY:0);const O=S+(l?-I:I),A=N+(c?-$:$),R=-i[0]*S,V=-i[1]*N;let v=$t(O,y,x),M=$t(A,m,b);if(s){let k=0,D=0;l&&I<0?k=Ce(p+I+R,s[0][0]):!l&&I>0&&(k=Me(p+O+R,s[1][0])),c&&$<0?D=Ce(w+$+V,s[0][1]):!c&&$>0&&(D=Me(w+A+V,s[1][1])),v=Math.max(v,k),M=Math.max(M,D)}if(a){let k=0,D=0;l&&I>0?k=Me(p+I,a[0][0]):!l&&I<0&&(k=Ce(p+O,a[1][0])),c&&$>0?D=Me(w+$,a[0][1]):!c&&$<0&&(D=Ce(w+A,a[1][1])),v=Math.max(v,k),M=Math.max(M,D)}if(r){if(d){const k=$t(O/_,m,b)*_;if(v=Math.max(v,k),s){let D=0;!l&&!c||l&&!c&&f?D=Me(w+V+O/_,s[1][1])*_:D=Ce(w+V+(l?I:-I)/_,s[0][1])*_,v=Math.max(v,D)}if(a){let D=0;!l&&!c||l&&!c&&f?D=Ce(w+O/_,a[1][1])*_:D=Me(w+(l?I:-I)/_,a[0][1])*_,v=Math.max(v,D)}}if(u){const k=$t(A*_,y,x)/_;if(M=Math.max(M,k),s){let D=0;!l&&!c||c&&!l&&f?D=Me(p+A*_+R,s[1][0])/_:D=Ce(p+(c?$:-$)*_+R,s[0][0])/_,M=Math.max(M,D)}if(a){let D=0;!l&&!c||c&&!l&&f?D=Ce(p+A*_,a[1][0])/_:D=Me(p+(c?$:-$)*_,a[0][0])/_,M=Math.max(M,D)}}}$=$+($<0?M:-M),I=I+(I<0?v:-v),r&&(f?O>A*_?$=(qo(l,c)?-I:I)/_:I=(qo(l,c)?-$:$)*_:d?($=I/_,c=l):(I=$*_,l=c));const C=l?p+I:p,P=c?w+$:w;return{width:S+(l?-I:I),height:N+(c?-$:$),x:i[0]*I*(l?-1:1)+C,y:i[1]*$*(c?-1:1)+P}}const Ai={width:0,height:0,x:0,y:0},Qd={...Ai,pointerX:0,pointerY:0,aspectRatio:1};function Jd(e){return[[0,0],[e.measured.width,e.measured.height]]}function ef(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function tf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:Go("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:y,shouldResize:x}){let m={...Ai},b={...Qd};s={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Go(c)};let p,w=null,S=[],N,_,I,$=!1;const O=Vr().on("start",A=>{const{nodeLookup:R,transform:V,snapGrid:v,snapToGrid:M,nodeOrigin:C,paneDomNode:P}=n();if(p=R.get(t),!p)return;w=P?.getBoundingClientRect()??null;const{xSnapped:k,ySnapped:D}=ct(A.sourceEvent,{transform:V,snapGrid:v,snapToGrid:M,containerBounds:w});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:k,pointerY:D,aspectRatio:m.width/m.height},N=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(N=R.get(p.parentId),_=N&&p.extent==="parent"?Jd(N):void 0),S=[],I=void 0;for(const[H,B]of R)if(B.parentId===t&&(S.push({id:H,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const L=ef(B,p,B.origin??C);I?I=[[Math.min(L[0][0],I[0][0]),Math.min(L[0][1],I[0][1])],[Math.max(L[1][0],I[1][0]),Math.max(L[1][1],I[1][1])]]:I=L}h?.(A,{...m})}).on("drag",A=>{const{transform:R,snapGrid:V,snapToGrid:v,nodeOrigin:M}=n(),C=ct(A.sourceEvent,{transform:R,snapGrid:V,snapToGrid:v,containerBounds:w}),P=[];if(!p)return;const{x:k,y:D,width:H,height:B}=m,L={},Z=p.origin??M,{width:F,height:z,x:X,y:Y}=Kd(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,Z,_,I),j=F!==H,G=z!==B,Q=X!==k&&j,K=Y!==D&&G;if(!Q&&!K&&!j&&!G)return;if((Q||K||Z[0]===1||Z[1]===1)&&(L.x=Q?X:m.x,L.y=K?Y:m.y,m.x=L.x,m.y=L.y,S.length>0)){const oe=X-k,ne=Y-D;for(const ae of S)ae.position={x:ae.position.x-oe+Z[0]*(F-H),y:ae.position.y-ne+Z[1]*(z-B)},P.push(ae)}if((j||G)&&(L.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:m.width,L.height=G&&(!s.resizeDirection||s.resizeDirection==="vertical")?z:m.height,m.width=L.width,m.height=L.height),N&&p.expandParent){const oe=Z[0]*(L.width??0);L.x&&L.x<oe&&(m.x=oe,b.x=b.x-(L.x-oe));const ne=Z[1]*(L.height??0);L.y&&L.y<ne&&(m.y=ne,b.y=b.y-(L.y-ne))}const q=Ud({width:m.width,prevWidth:H,height:m.height,prevHeight:B,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...m,direction:q};x?.(A,U)!==!1&&($=!0,g?.(A,U),o(L,P))}).on("end",A=>{$&&(y?.(A,{...m}),r?.({...m}),$=!1)});i.call(O)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}var _n={exports:{}},En={},Nn={exports:{}},Sn={};var Uo;function nf(){if(Uo)return Sn;Uo=1;var e=Sr();function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(u,f){var h=f(),g=o({inst:{value:h,getSnapshot:f}}),y=g[0].inst,x=g[1];return i(function(){y.value=h,y.getSnapshot=f,l(y)&&x({inst:y})},[u,h,f]),r(function(){return l(y)&&x({inst:y}),u(function(){l(y)&&x({inst:y})})},[u]),s(h),h}function l(u){var f=u.getSnapshot;u=u.value;try{var h=f();return!n(u,h)}catch{return!0}}function c(u,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Sn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Sn}var Ko;function of(){return Ko||(Ko=1,Nn.exports=nf()),Nn.exports}var Qo;function rf(){if(Qo)return En;Qo=1;var e=Sr(),t=of();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return En.useSyncExternalStoreWithSelector=function(c,d,u,f,h){var g=i(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=a(function(){function m(N){if(!b){if(b=!0,p=N,N=f(N),h!==void 0&&y.hasValue){var _=y.value;if(h(_,N))return w=_}return w=N}if(_=w,o(p,N))return _;var I=f(N);return h!==void 0&&h(_,I)?(p=N,_):(p=N,w=I)}var b=!1,p,w,S=u===void 0?null:u;return[function(){return m(d())},S===null?void 0:function(){return m(S())}]},[d,u,f,h]);var x=r(c,g[0],g[1]);return s(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},En}var Jo;function sf(){return Jo||(Jo=1,_n.exports=rf()),_n.exports}var af=sf();const cf=ma(af),lf={},er=e=>{let t;const n=new Set,o=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},r=()=>t,l={setState:o,getState:r,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(lf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(o,r,l);return l},uf=e=>e?er(e):er,{useDebugValue:df}=ya,{useSyncExternalStoreWithSelector:ff}=cf,hf=e=>e;function Pi(e,t=hf,n){const o=ff(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return df(o),o}const tr=(e,t)=>{const n=uf(e),o=(r,i=t)=>Pi(n,r,i);return Object.assign(o,n),o},gf=(e,t)=>e?tr(e,t):tr;function re(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const an=T.createContext(null),pf=an.Provider,$i=xe.error001();function ee(e,t){const n=T.useContext(an);if(n===null)throw new Error($i);return Pi(n,e,t)}function ie(){const e=T.useContext(an);if(e===null)throw new Error($i);return T.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const nr={display:"none"},mf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Di="react-flow__node-desc",Ti="react-flow__edge-desc",yf="react-flow__aria-live",xf=e=>e.ariaLiveMessage,wf=e=>e.ariaLabelConfig;function vf({rfId:e}){const t=ee(xf);return E.jsx("div",{id:`${yf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mf,children:t})}function bf({rfId:e,disableKeyboardA11y:t}){const n=ee(wf);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${Di}-${e}`,style:nr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${Ti}-${e}`,style:nr,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(vf,{rfId:e})]})}const Nt=T.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return E.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Nt.displayName="Panel";function _f({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:E.jsx(Nt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:E.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Ef=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Dt=e=>e.id;function Nf(e,t){return re(e.selectedNodes.map(Dt),t.selectedNodes.map(Dt))&&re(e.selectedEdges.map(Dt),t.selectedEdges.map(Dt))}function Sf({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=ee(Ef,Nf);return T.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Cf=e=>!!e.onSelectionChangeHandlers;function Mf({onSelectionChange:e}){const t=ee(Cf);return e||t?E.jsx(Sf,{onSelectionChange:e}):null}const jn=typeof window<"u"?T.useLayoutEffect:T.useEffect,Ri=[0,0],If={x:0,y:0,zoom:1},kf=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],or=[...kf,"rfId"],Af=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),rr={translateExtent:ht,nodeOrigin:Ri,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Pf(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=ee(Af,re),c=ie();jn(()=>(l(e.defaultNodes,e.defaultEdges),()=>{d.current=rr,a()}),[]);const d=T.useRef(rr);return jn(()=>{for(const u of or){const f=e[u],h=d.current[u];f!==h&&(typeof e[u]>"u"||(u==="nodes"?t(f):u==="edges"?n(f):u==="minZoom"?o(f):u==="maxZoom"?r(f):u==="translateExtent"?i(f):u==="nodeExtent"?s(f):u==="ariaLabelConfig"?c.setState({ariaLabelConfig:hd(f)}):u==="fitView"?c.setState({fitViewQueued:f}):u==="fitViewOptions"?c.setState({fitViewOptions:f}):c.setState({[u]:f})))}d.current=e},or.map(u=>e[u])),null}function ir(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function $f(e){const[t,n]=T.useState(e==="system"?null:e);return T.useEffect(()=>{if(e!=="system"){n(e);return}const o=ir(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:ir()?.matches?"dark":"light"}const sr=typeof document<"u"?document:null;function yt(e=null,t={target:sr,actInsideInputWithModifier:!0}){const[n,o]=T.useState(!1),r=T.useRef(!1),i=T.useRef(new Set([])),[s,a]=T.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|
|
5
5
|
+`).split(`
|
|
6
6
|
`)),d=c.reduce((u,f)=>u.concat(...f),[]);return[c,d]}return[[],[]]},[e]);return T.useEffect(()=>{const l=t?.target??sr,c=t?.actInsideInputWithModifier??!0;if(e!==null){const d=h=>{if(r.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!r.current||r.current&&!c)&&gi(h))return!1;const y=cr(h.code,a);if(i.current.add(h[y]),ar(s,i.current,!1)){const x=h.composedPath?.()?.[0]||h.target,m=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(r.current||!m)&&h.preventDefault(),o(!0)}},u=h=>{const g=cr(h.code,a);ar(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),r.current=!1},f=()=>{i.current.clear(),o(!1)};return l?.addEventListener("keydown",d),l?.addEventListener("keyup",u),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{l?.removeEventListener("keydown",d),l?.removeEventListener("keyup",u),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,o]),n}function ar(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function cr(e,t){return t.includes(e)?"code":"key"}const Df=()=>{const e=ie();return T.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),l=eo(t,o,r,i,s,n?.padding??.1);return a?(await a.setViewport(l,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:l}=s.getBoundingClientRect(),c={x:t.x-a,y:t.y-l},d=n.snapGrid??r,u=n.snapToGrid??i;return Et(c,o,u,d)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=Ut(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function zi(e,t){const n=[],o=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")o.set(i.id,[i]);else{const s=o.get(i.id);s?s.push(i):o.set(i.id,[i])}for(const i of t){const s=o.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const l of s)Tf(l,a);n.push(a)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Tf(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Hi(e,t){return zi(e,t)}function Li(e,t){return zi(e,t)}function Pe(e,t){return{id:e,type:"select",selected:t}}function Fe(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const s=t.has(r);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),o.push(Pe(i.id,s)))}return o}function lr({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,i]of e.entries()){const s=t.get(i.id),a=s?.internals?.userNode??s;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:"replace"}),a===void 0&&n.push({item:i,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function ur(e){return{id:e.id,type:"remove"}}const dr=e=>od(e),Rf=e=>si(e);function Bi(e){return T.forwardRef(e)}function fr(e){const[t,n]=T.useState(BigInt(0)),[o]=T.useState(()=>zf(()=>n(r=>r+BigInt(1))));return jn(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function zf(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Vi=T.createContext(null);function Hf({children:e}){const t=ie(),n=T.useCallback(a=>{const{nodes:l=[],setNodes:c,hasDefaultNodes:d,onNodesChange:u,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let y=l;for(const m of a)y=typeof m=="function"?m(y):m;let x=lr({items:y,lookup:f});for(const m of g.values())x=m(x);d&&c(y),x.length>0?u?.(x):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:b,setNodes:p}=t.getState();m&&p(b)})},[]),o=fr(n),r=T.useCallback(a=>{const{edges:l=[],setEdges:c,hasDefaultEdges:d,onEdgesChange:u,edgeLookup:f}=t.getState();let h=l;for(const g of a)h=typeof g=="function"?g(h):g;d?c(h):u&&u(lr({items:h,lookup:f}))},[]),i=fr(r),s=T.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return E.jsx(Vi.Provider,{value:s,children:e})}function Lf(){const e=T.useContext(Vi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Bf=e=>!!e.panZoom;function cn(){const e=Df(),t=ie(),n=Lf(),o=ee(Bf),r=T.useMemo(()=>{const i=u=>t.getState().nodeLookup.get(u),s=u=>{n.nodeQueue.push(u)},a=u=>{n.edgeQueue.push(u)},l=u=>{const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=dr(u)?u:f.get(u.id),y=g.parentId?fi(g.position,g.measured,g.parentId,f,h):g.position,x={...g,position:y,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return qe(x)},c=(u,f,h={replace:!1})=>{s(g=>g.map(y=>{if(y.id===u){const x=typeof f=="function"?f(y):f;return h.replace&&dr(x)?x:{...y,...x}}return y}))},d=(u,f,h={replace:!1})=>{a(g=>g.map(y=>{if(y.id===u){const x=typeof f=="function"?f(y):f;return h.replace&&Rf(x)?x:{...y,...x}}return y}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>i(u)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(f=>({...f}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:s,setEdges:a,addNodes:u=>{const f=Array.isArray(u)?u:[u];n.nodeQueue.push(h=>[...h,...f])},addEdges:u=>{const f=Array.isArray(u)?u:[u];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:u=[],edges:f=[],transform:h}=t.getState(),[g,y,x]=h;return{nodes:u.map(m=>({...m})),edges:f.map(m=>({...m})),viewport:{x:g,y,zoom:x}}},deleteElements:async({nodes:u=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:y,onEdgesDelete:x,triggerNodeChanges:m,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:w}=t.getState(),{nodes:S,edges:N}=await cd({nodesToRemove:u,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:w}),_=N.length>0,I=S.length>0;if(_){const $=N.map(ur);x?.(N),b($)}if(I){const $=S.map(ur);y?.(S),m($)}return(I||_)&&p?.({nodes:S,edges:N}),{deletedNodes:S,deletedEdges:N}},getIntersectingNodes:(u,f=!0,h)=>{const g=Ho(u),y=g?u:l(u),x=h!==void 0;return y?(h||t.getState().nodes).filter(m=>{const b=t.getState().nodeLookup.get(m.id);if(b&&!g&&(m.id===u.id||!b.internals.positionAbsolute))return!1;const p=qe(x?m:b),w=pt(p,y);return f&&w>0||w>=p.width*p.height||w>=y.width*y.height}):[]},isNodeIntersecting:(u,f,h=!0)=>{const y=Ho(u)?u:l(u);if(!y)return!1;const x=pt(y,f);return h&&x>0||x>=f.width*f.height||x>=y.width*y.height},updateNode:c,updateNodeData:(u,f,h={replace:!1})=>{c(u,g=>{const y=typeof f=="function"?f(g):f;return h.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},h)},updateEdge:d,updateEdgeData:(u,f,h={replace:!1})=>{d(u,g=>{const y=typeof f=="function"?f(g):f;return h.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},h)},getNodesBounds:u=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return rd(u,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:u,id:f,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${u}${f?`-${f}`:""}`)?.values()??[]),getNodeConnections:({type:u,handleId:f,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${u?f?`-${u}-${f}`:`-${u}`:""}`)?.values()??[]),fitView:async u=>{const f=t.getState().fitViewResolver??fd();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return T.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const hr=e=>e.selected,Vf=typeof window<"u"?window:void 0;function Of({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ie(),{deleteElements:o}=cn(),r=yt(e,{actInsideInputWithModifier:!1}),i=yt(t,{target:Vf});T.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();o({nodes:a.filter(hr),edges:s.filter(hr)}),n.setState({nodesSelectionActive:!1})}},[r]),T.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function jf(e){const t=ie();T.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=to(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",xe.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const ln={position:"absolute",width:"100%",height:"100%",top:0,left:0},Ff=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Xf({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=Te.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:l,translateExtent:c,minZoom:d,maxZoom:u,zoomActivationKeyCode:f,preventScrolling:h=!0,children:g,noWheelClassName:y,noPanClassName:x,onViewportChange:m,isControlledViewport:b,paneClickDistance:p,selectionOnDrag:w}){const S=ie(),N=T.useRef(null),{userSelectionActive:_,lib:I,connectionInProgress:$}=ee(Ff,re),O=yt(f),A=T.useRef();jf(N);const R=T.useCallback(V=>{m?.({x:V[0],y:V[1],zoom:V[2]}),b||S.setState({transform:V})},[m,b]);return T.useEffect(()=>{if(N.current){A.current=qd({domNode:N.current,minZoom:d,maxZoom:u,translateExtent:c,viewport:l,onDraggingChange:C=>S.setState(P=>P.paneDragging===C?P:{paneDragging:C}),onPanZoomStart:(C,P)=>{const{onViewportChangeStart:k,onMoveStart:D}=S.getState();D?.(C,P),k?.(P)},onPanZoom:(C,P)=>{const{onViewportChange:k,onMove:D}=S.getState();D?.(C,P),k?.(P)},onPanZoomEnd:(C,P)=>{const{onViewportChangeEnd:k,onMoveEnd:D}=S.getState();D?.(C,P),k?.(P)}});const{x:V,y:v,zoom:M}=A.current.getViewport();return S.setState({panZoom:A.current,transform:[V,v,M],domNode:N.current.closest(".react-flow")}),()=>{A.current?.destroy()}}},[]),T.useEffect(()=>{A.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:O,preventScrolling:h,noPanClassName:x,userSelectionActive:_,noWheelClassName:y,lib:I,onTransformChange:R,connectionInProgress:$,selectionOnDrag:w,paneClickDistance:p})},[e,t,n,o,r,i,s,a,O,h,x,_,y,I,R,$,w,p]),E.jsx("div",{className:"react-flow__renderer",ref:N,style:ln,children:g})}const Yf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Wf(){const{userSelectionActive:e,userSelectionRect:t}=ee(Yf,re);return e&&t?E.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Cn=(e,t)=>n=>{n.target===t.current&&e?.(n)},Zf=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Gf({isSelecting:e,selectionKeyPressed:t,selectionMode:n=gt.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:a,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:u,onPaneMouseMove:f,onPaneMouseLeave:h,children:g}){const y=ie(),{userSelectionActive:x,elementsSelectable:m,dragging:b,connectionInProgress:p}=ee(Zf,re),w=m&&(e||x),S=T.useRef(null),N=T.useRef(),_=T.useRef(new Set),I=T.useRef(new Set),$=T.useRef(!1),O=k=>{if($.current||p){$.current=!1;return}l?.(k),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},A=k=>{if(Array.isArray(o)&&o?.includes(2)){k.preventDefault();return}c?.(k)},R=d?k=>d(k):void 0,V=k=>{$.current&&(k.stopPropagation(),$.current=!1)},v=k=>{const{domNode:D}=y.getState();if(N.current=D?.getBoundingClientRect(),!N.current)return;const H=k.target===S.current;if(!H&&!!k.target.closest(".nokey")||!e||!(i&&H||t)||k.button!==0||!k.isPrimary)return;k.target?.setPointerCapture?.(k.pointerId),$.current=!1;const{x:Z,y:F}=ge(k.nativeEvent,N.current);y.setState({userSelectionRect:{width:0,height:0,startX:Z,startY:F,x:Z,y:F}}),H||(k.stopPropagation(),k.preventDefault())},M=k=>{const{userSelectionRect:D,transform:H,nodeLookup:B,edgeLookup:L,connectionLookup:Z,triggerNodeChanges:F,triggerEdgeChanges:z,defaultEdgeOptions:X,resetSelectedElements:Y}=y.getState();if(!N.current||!D)return;const{x:j,y:G}=ge(k.nativeEvent,N.current),{startX:Q,startY:K}=D;if(!$.current){const ne=t?0:r;if(Math.hypot(j-Q,G-K)<=ne)return;Y(),s?.(k)}$.current=!0;const q={startX:Q,startY:K,x:j<Q?j:Q,y:G<K?G:K,width:Math.abs(j-Q),height:Math.abs(G-K)},U=_.current,te=I.current;_.current=new Set(Jn(B,q,H,n===gt.Partial,!0).map(ne=>ne.id)),I.current=new Set;const oe=X?.selectable??!0;for(const ne of _.current){const ae=Z.get(ne);if(ae)for(const{edgeId:Se}of ae.values()){const ve=L.get(Se);ve&&(ve.selectable??oe)&&I.current.add(Se)}}if(!Lo(U,_.current)){const ne=Fe(B,_.current,!0);F(ne)}if(!Lo(te,I.current)){const ne=Fe(L,I.current);z(ne)}y.setState({userSelectionRect:q,userSelectionActive:!0,nodesSelectionActive:!1})},C=k=>{k.button===0&&(k.target?.releasePointerCapture?.(k.pointerId),!x&&k.target===S.current&&y.getState().userSelectionRect&&O?.(k),y.setState({userSelectionActive:!1,userSelectionRect:null}),$.current&&(a?.(k),y.setState({nodesSelectionActive:_.current.size>0})))},P=o===!0||Array.isArray(o)&&o.includes(0);return E.jsxs("div",{className:se(["react-flow__pane",{draggable:P,dragging:b,selection:e}]),onClick:w?void 0:Cn(O,S),onContextMenu:Cn(A,S),onWheel:Cn(R,S),onPointerEnter:w?void 0:u,onPointerMove:w?M:f,onPointerUp:w?C:void 0,onPointerDownCapture:w?v:void 0,onClickCapture:w?V:void 0,onPointerLeave:h,ref:S,style:ln,children:[g,E.jsx(Wf,{})]})}function Fn({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:l}=t.getState(),c=a.get(e);if(!c){l?.("012",xe.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Oi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const a=ie(),[l,c]=T.useState(!1),d=T.useRef();return T.useEffect(()=>{d.current=Rd({getStoreItems:()=>a.getState(),onNodeMouseDown:u=>{Fn({id:u,store:a,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})},[]),T.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s}),()=>{d.current?.destroy()}},[n,o,t,i,e,r,s]),l}const qf=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ji(){const e=ie();return T.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:l,nodeLookup:c,nodeOrigin:d}=e.getState(),u=new Map,f=qf(s),h=r?i[0]:5,g=r?i[1]:5,y=n.direction.x*h*n.factor,x=n.direction.y*g*n.factor;for(const[,m]of c){if(!f(m))continue;let b={x:m.internals.positionAbsolute.x+y,y:m.internals.positionAbsolute.y+x};r&&(b=_t(b,i));const{position:p,positionAbsolute:w}=ai({nodeId:m.id,nextPosition:b,nodeLookup:c,nodeExtent:o,nodeOrigin:d,onError:a});m.position=p,m.internals.positionAbsolute=w,u.set(m.id,m)}l(u)},[])}const ao=T.createContext(null),Uf=ao.Provider;ao.Consumer;const Fi=()=>T.useContext(ao),Kf=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Qf=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:a,toHandle:l,isValid:c}=s,d=l?.nodeId===e&&l?.id===t&&l?.type===n;return{connectingFrom:a?.nodeId===e&&a?.id===t&&a?.type===n,connectingTo:d,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:i===He.Strict?a?.type!==n:e!==a?.nodeId||t!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:d&&c}};function Jf({type:e="source",position:t=W.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:l,className:c,onMouseDown:d,onTouchStart:u,...f},h){const g=s||null,y=e==="target",x=ie(),m=Fi(),{connectOnClick:b,noPanClassName:p,rfId:w}=ee(Kf,re),{connectingFrom:S,connectingTo:N,clickConnecting:_,isPossibleEndHandle:I,connectionInProcess:$,clickConnectionInProcess:O,valid:A}=ee(Qf(m,g,e),re);m||x.getState().onError?.("010",xe.error010());const R=M=>{const{defaultEdgeOptions:C,onConnect:P,hasDefaultEdges:k}=x.getState(),D={...C,...M};if(k){const{edges:H,setEdges:B}=x.getState();B(wd(D,H))}P?.(D),a?.(D)},V=M=>{if(!m)return;const C=pi(M.nativeEvent);if(r&&(C&&M.button===0||!C)){const P=x.getState();On.onPointerDown(M.nativeEvent,{handleDomNode:M.currentTarget,autoPanOnConnect:P.autoPanOnConnect,connectionMode:P.connectionMode,connectionRadius:P.connectionRadius,domNode:P.domNode,nodeLookup:P.nodeLookup,lib:P.lib,isTarget:y,handleId:g,nodeId:m,flowId:P.rfId,panBy:P.panBy,cancelConnection:P.cancelConnection,onConnectStart:P.onConnectStart,onConnectEnd:(...k)=>x.getState().onConnectEnd?.(...k),updateConnection:P.updateConnection,onConnect:R,isValidConnection:n||((...k)=>x.getState().isValidConnection?.(...k)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:P.autoPanSpeed,dragThreshold:P.connectionDragThreshold})}C?d?.(M):u?.(M)},v=M=>{const{onClickConnectStart:C,onClickConnectEnd:P,connectionClickStartHandle:k,connectionMode:D,isValidConnection:H,lib:B,rfId:L,nodeLookup:Z,connection:F}=x.getState();if(!m||!k&&!r)return;if(!k){C?.(M.nativeEvent,{nodeId:m,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:m,type:e,id:g}});return}const z=hi(M.target),X=n||H,{connection:Y,isValid:j}=On.isValid(M.nativeEvent,{handle:{nodeId:m,id:g,type:e},connectionMode:D,fromNodeId:k.nodeId,fromHandleId:k.id||null,fromType:k.type,isValidConnection:X,flowId:L,doc:z,lib:B,nodeLookup:Z});j&&Y&&R(Y);const G=structuredClone(F);delete G.inProgress,G.toPosition=G.toHandle?G.toHandle.position:null,P?.(M,G),x.setState({connectionClickStartHandle:null})};return E.jsx("div",{"data-handleid":g,"data-nodeid":m,"data-handlepos":t,"data-id":`${w}-${m}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,c,{source:!y,target:y,connectable:o,connectablestart:r,connectableend:i,clickconnecting:_,connectingfrom:S,connectingto:N,valid:A,connectionindicator:o&&(!$||I)&&($||O?i:r)}]),onMouseDown:V,onTouchStart:V,onClick:b?v:void 0,ref:h,...f,children:l})}const Qe=T.memo(Bi(Jf));function eh({data:e,isConnectable:t,sourcePosition:n=W.Bottom}){return E.jsxs(E.Fragment,{children:[e?.label,E.jsx(Qe,{type:"source",position:n,isConnectable:t})]})}function th({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:o=W.Bottom}){return E.jsxs(E.Fragment,{children:[E.jsx(Qe,{type:"target",position:n,isConnectable:t}),e?.label,E.jsx(Qe,{type:"source",position:o,isConnectable:t})]})}function nh(){return null}function oh({data:e,isConnectable:t,targetPosition:n=W.Top}){return E.jsxs(E.Fragment,{children:[E.jsx(Qe,{type:"target",position:n,isConnectable:t}),e?.label]})}const Kt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},gr={input:eh,default:th,output:oh,group:nh};function rh(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const ih=e=>{const{width:t,height:n,x:o,y:r}=bt(e.nodeLookup,{filter:i=>!!i.selected});return{width:he(t)?t:null,height:he(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function sh({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=ie(),{width:r,height:i,transformString:s,userSelectionActive:a}=ee(ih,re),l=ji(),c=T.useRef(null);T.useEffect(()=>{n||c.current?.focus({preventScroll:!0})},[n]);const d=!a&&r!==null&&i!==null;if(Oi({nodeRef:c,disabled:!d}),!d)return null;const u=e?h=>{const g=o.getState().nodes.filter(y=>y.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(Kt,h.key)&&(h.preventDefault(),l({direction:Kt[h.key],factor:h.shiftKey?4:1}))};return E.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:E.jsx("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:r,height:i}})})}const pr=typeof window<"u"?window:void 0,ah=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Xi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:c,selectionOnDrag:d,selectionMode:u,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:y,zoomActivationKeyCode:x,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:w,panOnScrollSpeed:S,panOnScrollMode:N,zoomOnDoubleClick:_,panOnDrag:I,defaultViewport:$,translateExtent:O,minZoom:A,maxZoom:R,preventScrolling:V,onSelectionContextMenu:v,noWheelClassName:M,noPanClassName:C,disableKeyboardA11y:P,onViewportChange:k,isControlledViewport:D}){const{nodesSelectionActive:H,userSelectionActive:B}=ee(ah,re),L=yt(c,{target:pr}),Z=yt(y,{target:pr}),F=Z||I,z=Z||w,X=d&&F!==!0,Y=L||B||X;return Of({deleteKeyCode:l,multiSelectionKeyCode:g}),E.jsx(Xf,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:z,panOnScrollSpeed:S,panOnScrollMode:N,zoomOnDoubleClick:_,panOnDrag:!L&&F,defaultViewport:$,translateExtent:O,minZoom:A,maxZoom:R,zoomActivationKeyCode:x,preventScrolling:V,noWheelClassName:M,noPanClassName:C,onViewportChange:k,isControlledViewport:D,paneClickDistance:a,selectionOnDrag:X,children:E.jsxs(Gf,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:F,isSelecting:!!Y,selectionMode:u,selectionKeyPressed:L,paneClickDistance:a,selectionOnDrag:X,children:[e,H&&E.jsx(sh,{onSelectionContextMenu:v,noPanClassName:C,disableKeyboardA11y:P})]})})}Xi.displayName="FlowRenderer";const ch=T.memo(Xi),lh=e=>t=>e?Jn(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function uh(e){return ee(T.useCallback(lh(e),[e]),re)}const dh=e=>e.updateNodeInternals;function fh(){const e=ee(dh),[t]=T.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const i=r.target.getAttribute("data-id");o.set(i,{id:i,nodeElement:r.target,force:!0})}),e(o)}));return T.useEffect(()=>()=>{t?.disconnect()},[t]),t}function hh({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=ie(),i=T.useRef(null),s=T.useRef(null),a=T.useRef(e.sourcePosition),l=T.useRef(e.targetPosition),c=T.useRef(t),d=n&&!!e.internals.handleBounds;return T.useEffect(()=>{i.current&&!e.hidden&&(!d||s.current!==i.current)&&(s.current&&o?.unobserve(s.current),o?.observe(i.current),s.current=i.current)},[d,e.hidden]),T.useEffect(()=>()=>{s.current&&(o?.unobserve(s.current),s.current=null)},[]),T.useEffect(()=>{if(i.current){const u=c.current!==t,f=a.current!==e.sourcePosition,h=l.current!==e.targetPosition;(u||f||h)&&(c.current=t,a.current=e.sourcePosition,l.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function gh({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:l,nodesConnectable:c,nodesFocusable:d,resizeObserver:u,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:y,nodeTypes:x,nodeClickDistance:m,onError:b}){const{node:p,internals:w,isParent:S}=ee(j=>{const G=j.nodeLookup.get(e),Q=j.parentLookup.has(e);return{node:G,internals:G.internals,isParent:Q}},re);let N=p.type||"default",_=x?.[N]||gr[N];_===void 0&&(b?.("003",xe.error003(N)),N="default",_=x?.default||gr.default);const I=!!(p.draggable||a&&typeof p.draggable>"u"),$=!!(p.selectable||l&&typeof p.selectable>"u"),O=!!(p.connectable||c&&typeof p.connectable>"u"),A=!!(p.focusable||d&&typeof p.focusable>"u"),R=ie(),V=di(p),v=hh({node:p,nodeType:N,hasDimensions:V,resizeObserver:u}),M=Oi({nodeRef:v,disabled:p.hidden||!I,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:$,nodeClickDistance:m}),C=ji();if(p.hidden)return null;const P=Ne(p),k=rh(p),D=$||I||t||n||o||r,H=n?j=>n(j,{...w.userNode}):void 0,B=o?j=>o(j,{...w.userNode}):void 0,L=r?j=>r(j,{...w.userNode}):void 0,Z=i?j=>i(j,{...w.userNode}):void 0,F=s?j=>s(j,{...w.userNode}):void 0,z=j=>{const{selectNodesOnDrag:G,nodeDragThreshold:Q}=R.getState();$&&(!G||!I||Q>0)&&Fn({id:e,store:R,nodeRef:v}),t&&t(j,{...w.userNode})},X=j=>{if(!(gi(j.nativeEvent)||g)){if(ni.includes(j.key)&&$){const G=j.key==="Escape";Fn({id:e,store:R,unselect:G,nodeRef:v})}else if(I&&p.selected&&Object.prototype.hasOwnProperty.call(Kt,j.key)){j.preventDefault();const{ariaLabelConfig:G}=R.getState();R.setState({ariaLiveMessage:G["node.a11yDescription.ariaLiveMessage"]({direction:j.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),C({direction:Kt[j.key],factor:j.shiftKey?4:1})}}},Y=()=>{if(g||!v.current?.matches(":focus-visible"))return;const{transform:j,width:G,height:Q,autoPanOnNodeFocus:K,setCenter:q}=R.getState();if(!K)return;Jn(new Map([[e,p]]),{x:0,y:0,width:G,height:Q},j,!0).length>0||q(p.position.x+P.width/2,p.position.y+P.height/2,{zoom:j[2]})};return E.jsx("div",{className:se(["react-flow__node",`react-flow__node-${N}`,{[h]:I},p.className,{selected:p.selected,selectable:$,parent:S,draggable:I,dragging:M}]),ref:v,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:V?"visible":"hidden",...p.style,...k},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:B,onMouseLeave:L,onContextMenu:Z,onClick:z,onDoubleClick:F,onKeyDown:A?X:void 0,tabIndex:A?0:void 0,onFocus:A?Y:void 0,role:p.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Di}-${y}`,"aria-label":p.ariaLabel,...p.domAttributes,children:E.jsx(Uf,{value:e,children:E.jsx(_,{id:e,data:p.data,type:N,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:p.selected??!1,selectable:$,draggable:I,deletable:p.deletable??!0,isConnectable:O,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:M,dragHandle:p.dragHandle,zIndex:w.z,parentId:p.parentId,...P})})})}var ph=T.memo(gh);const mh=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Yi(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:i}=ee(mh,re),s=uh(e.onlyRenderVisibleElements),a=fh();return E.jsx("div",{className:"react-flow__nodes",style:ln,children:s.map(l=>E.jsx(ph,{id:l,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},l))})}Yi.displayName="NodeRenderer";const yh=T.memo(Yi);function xh(e){return ee(T.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);i&&s&&md({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),re)}const wh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return E.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},vh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return E.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},mr={[Gt.Arrow]:wh,[Gt.ArrowClosed]:vh};function bh(e){const t=ie();return T.useMemo(()=>Object.prototype.hasOwnProperty.call(mr,e)?mr[e]:(t.getState().onError?.("009",xe.error009(e)),null),[e])}const _h=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const l=bh(t);return l?E.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:E.jsx(l,{color:n,strokeWidth:s})}):null},Wi=({defaultColor:e,rfId:t})=>{const n=ee(i=>i.edges),o=ee(i=>i.defaultEdgeOptions),r=T.useMemo(()=>Nd(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?E.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:E.jsx("defs",{children:r.map(i=>E.jsx(_h,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Wi.displayName="MarkerDefinitions";var Eh=T.memo(Wi);function Zi({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...d}){const[u,f]=T.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",c]),g=T.useRef(null);return T.useEffect(()=>{if(g.current){const y=g.current.getBBox();f({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?E.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:h,visibility:u.width?"visible":"hidden",...d,children:[r&&E.jsx("rect",{width:u.width+2*s[0],x:-s[0],y:-s[1],height:u.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),E.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:o,children:n}),l]}):null}Zi.displayName="EdgeText";const Nh=T.memo(Zi);function un({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:c=20,...d}){return E.jsxs(E.Fragment,{children:[E.jsx("path",{...d,d:e,fill:"none",className:se(["react-flow__edge-path",d.className])}),c?E.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,o&&he(t)&&he(n)?E.jsx(Nh,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function yr({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===W.Left||e===W.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function Gi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top}){const[s,a]=yr({pos:n,x1:e,y1:t,x2:o,y2:r}),[l,c]=yr({pos:i,x1:o,y1:r,x2:e,y2:t}),[d,u,f,h]=mi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${e},${t} C${s},${a} ${l},${c} ${o},${r}`,d,u,f,h]}function qi(e){return T.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:a,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:x,interactionWidth:m})=>{const[b,p,w]=Gi({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a}),S=e.isInternal?void 0:t;return E.jsx(un,{id:S,path:b,labelX:p,labelY:w,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:x,interactionWidth:m})})}const Sh=qi({isInternal:!1}),Ui=qi({isInternal:!0});Sh.displayName="SimpleBezierEdge";Ui.displayName="SimpleBezierEdgeInternal";function Ki(e){return T.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,sourcePosition:h=W.Bottom,targetPosition:g=W.Top,markerEnd:y,markerStart:x,pathOptions:m,interactionWidth:b})=>{const[p,w,S]=Ln({sourceX:n,sourceY:o,sourcePosition:h,targetX:r,targetY:i,targetPosition:g,borderRadius:m?.borderRadius,offset:m?.offset,stepPosition:m?.stepPosition}),N=e.isInternal?void 0:t;return E.jsx(un,{id:N,path:p,labelX:w,labelY:S,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:y,markerStart:x,interactionWidth:b})})}const Qi=Ki({isInternal:!1}),Ji=Ki({isInternal:!0});Qi.displayName="SmoothStepEdge";Ji.displayName="SmoothStepEdgeInternal";function es(e){return T.memo(({id:t,...n})=>{const o=e.isInternal?void 0:t;return E.jsx(Qi,{...n,id:o,pathOptions:T.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Ch=es({isInternal:!1}),ts=es({isInternal:!0});Ch.displayName="StepEdge";ts.displayName="StepEdgeInternal";function ns(e){return T.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:h,markerStart:g,interactionWidth:y})=>{const[x,m,b]=wi({sourceX:n,sourceY:o,targetX:r,targetY:i}),p=e.isInternal?void 0:t;return E.jsx(un,{id:p,path:x,labelX:m,labelY:b,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:h,markerStart:g,interactionWidth:y})})}const Mh=ns({isInternal:!1}),os=ns({isInternal:!0});Mh.displayName="StraightEdge";os.displayName="StraightEdgeInternal";function rs(e){return T.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=W.Bottom,targetPosition:a=W.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:x,pathOptions:m,interactionWidth:b})=>{const[p,w,S]=yi({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a,curvature:m?.curvature}),N=e.isInternal?void 0:t;return E.jsx(un,{id:N,path:p,labelX:w,labelY:S,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:x,interactionWidth:b})})}const Ih=rs({isInternal:!1}),is=rs({isInternal:!0});Ih.displayName="BezierEdge";is.displayName="BezierEdgeInternal";const xr={default:is,straight:os,step:ts,smoothstep:Ji,simplebezier:Ui},wr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},kh=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,Ah=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,vr="react-flow__edgeupdater";function br({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:a}){return E.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:se([vr,`${vr}-${a}`]),cx:kh(t,o,e),cy:Ah(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Ph({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:a,targetPosition:l,onReconnect:c,onReconnectStart:d,onReconnectEnd:u,setReconnecting:f,setUpdateHover:h}){const g=ie(),y=(w,S)=>{if(w.button!==0)return;const{autoPanOnConnect:N,domNode:_,connectionMode:I,connectionRadius:$,lib:O,onConnectStart:A,cancelConnection:R,nodeLookup:V,rfId:v,panBy:M,updateConnection:C}=g.getState(),P=S.type==="target",k=(B,L)=>{f(!1),u?.(B,n,S.type,L)},D=B=>c?.(n,B),H=(B,L)=>{f(!0),d?.(w,n,S.type),A?.(B,L)};On.onPointerDown(w.nativeEvent,{autoPanOnConnect:N,connectionMode:I,connectionRadius:$,domNode:_,handleId:S.id,nodeId:S.nodeId,nodeLookup:V,isTarget:P,edgeUpdaterType:S.type,lib:O,flowId:v,cancelConnection:R,panBy:M,isValidConnection:(...B)=>g.getState().isValidConnection?.(...B)??!0,onConnect:D,onConnectStart:H,onConnectEnd:(...B)=>g.getState().onConnectEnd?.(...B),onReconnectEnd:k,updateConnection:C,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},x=w=>y(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=w=>y(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),p=()=>h(!1);return E.jsxs(E.Fragment,{children:[(e===!0||e==="source")&&E.jsx(br,{position:a,centerX:o,centerY:r,radius:t,onMouseDown:x,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&E.jsx(br,{position:l,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function $h({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:y,noPanClassName:x,onError:m,disableKeyboardA11y:b}){let p=ee(q=>q.edgeLookup.get(e));const w=ee(q=>q.defaultEdgeOptions);p=w?{...w,...p}:p;let S=p.type||"default",N=y?.[S]||xr[S];N===void 0&&(m?.("011",xe.error011(S)),S="default",N=y?.default||xr.default);const _=!!(p.focusable||t&&typeof p.focusable>"u"),I=typeof u<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),$=!!(p.selectable||o&&typeof p.selectable>"u"),O=T.useRef(null),[A,R]=T.useState(!1),[V,v]=T.useState(!1),M=ie(),{zIndex:C,sourceX:P,sourceY:k,targetX:D,targetY:H,sourcePosition:B,targetPosition:L}=ee(T.useCallback(q=>{const U=q.nodeLookup.get(p.source),te=q.nodeLookup.get(p.target);if(!U||!te)return{zIndex:p.zIndex,...wr};const oe=Ed({id:e,sourceNode:U,targetNode:te,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:q.connectionMode,onError:m});return{zIndex:pd({selected:p.selected,zIndex:p.zIndex,sourceNode:U,targetNode:te,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode}),...oe||wr}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),re),Z=T.useMemo(()=>p.markerStart?`url('#${Bn(p.markerStart,g)}')`:void 0,[p.markerStart,g]),F=T.useMemo(()=>p.markerEnd?`url('#${Bn(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||P===null||k===null||D===null||H===null)return null;const z=q=>{const{addSelectedEdges:U,unselectNodesAndEdges:te,multiSelectionActive:oe}=M.getState();$&&(M.setState({nodesSelectionActive:!1}),p.selected&&oe?(te({nodes:[],edges:[p]}),O.current?.blur()):U([e])),r&&r(q,p)},X=i?q=>{i(q,{...p})}:void 0,Y=s?q=>{s(q,{...p})}:void 0,j=a?q=>{a(q,{...p})}:void 0,G=l?q=>{l(q,{...p})}:void 0,Q=c?q=>{c(q,{...p})}:void 0,K=q=>{if(!b&&ni.includes(q.key)&&$){const{unselectNodesAndEdges:U,addSelectedEdges:te}=M.getState();q.key==="Escape"?(O.current?.blur(),U({edges:[p]})):te([e])}};return E.jsx("svg",{style:{zIndex:C},children:E.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${S}`,p.className,x,{selected:p.selected,animated:p.animated,inactive:!$&&!r,updating:A,selectable:$}]),onClick:z,onDoubleClick:X,onContextMenu:Y,onMouseEnter:j,onMouseMove:G,onMouseLeave:Q,onKeyDown:_?K:void 0,tabIndex:_?0:void 0,role:p.ariaRole??(_?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":_?`${Ti}-${g}`:void 0,ref:O,...p.domAttributes,children:[!V&&E.jsx(N,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:$,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:P,sourceY:k,targetX:D,targetY:H,sourcePosition:B,targetPosition:L,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:Z,markerEnd:F,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),I&&E.jsx(Ph,{edge:p,isReconnectable:I,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,sourceX:P,sourceY:k,targetX:D,targetY:H,sourcePosition:B,targetPosition:L,setUpdateHover:R,setReconnecting:v})]})})}var Dh=T.memo($h);const Th=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ss({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,reconnectRadius:u,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:y}){const{edgesFocusable:x,edgesReconnectable:m,elementsSelectable:b,onError:p}=ee(Th,re),w=xh(t);return E.jsxs("div",{className:"react-flow__edges",children:[E.jsx(Eh,{defaultColor:e,rfId:n}),w.map(S=>E.jsx(Dh,{id:S,edgesFocusable:x,edgesReconnectable:m,elementsSelectable:b,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:d,reconnectRadius:u,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:o,disableKeyboardA11y:y},S))]})}ss.displayName="EdgeRenderer";const Rh=T.memo(ss),zh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Hh({children:e}){const t=ee(zh);return E.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Lh(e){const t=cn(),n=T.useRef(!1);T.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Bh=e=>e.panZoom?.syncViewport;function Vh(e){const t=ee(Bh),n=ie();return T.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Oh(e){return e.connection.inProgress?{...e.connection,to:Et(e.connection.to,e.transform)}:{...e.connection}}function jh(e){return Oh}function Fh(e){const t=jh();return ee(t,re)}const Xh=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Yh({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:a,inProgress:l}=ee(Xh,re);return!(i&&r&&l)?null:E.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:E.jsx("g",{className:se(["react-flow__connection",ii(a)]),children:E.jsx(as,{style:t,type:n,CustomComponent:o,isValid:a})})})}const as=({style:e,type:t=Ie.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:a,fromPosition:l,to:c,toNode:d,toHandle:u,toPosition:f,pointer:h}=Fh();if(!r)return;if(n)return E.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:c.x,toY:c.y,fromPosition:l,toPosition:f,connectionStatus:ii(o),toNode:d,toHandle:u,pointer:h});let g="";const y={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:c.x,targetY:c.y,targetPosition:f};switch(t){case Ie.Bezier:[g]=yi(y);break;case Ie.SimpleBezier:[g]=Gi(y);break;case Ie.Step:[g]=Ln({...y,borderRadius:0});break;case Ie.SmoothStep:[g]=Ln(y);break;default:[g]=wi(y)}return E.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};as.displayName="ConnectionLine";const Wh={};function _r(e=Wh){T.useRef(e),ie(),T.useEffect(()=>{},[e])}function Zh(){ie(),T.useRef(!1),T.useEffect(()=>{},[])}function cs({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:d,onSelectionContextMenu:u,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:y,connectionLineComponent:x,connectionLineContainerStyle:m,selectionKeyCode:b,selectionOnDrag:p,selectionMode:w,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:_,deleteKeyCode:I,onlyRenderVisibleElements:$,elementsSelectable:O,defaultViewport:A,translateExtent:R,minZoom:V,maxZoom:v,preventScrolling:M,defaultMarkerColor:C,zoomOnScroll:P,zoomOnPinch:k,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:B,zoomOnDoubleClick:L,panOnDrag:Z,onPaneClick:F,onPaneMouseEnter:z,onPaneMouseMove:X,onPaneMouseLeave:Y,onPaneScroll:j,onPaneContextMenu:G,paneClickDistance:Q,nodeClickDistance:K,onEdgeContextMenu:q,onEdgeMouseEnter:U,onEdgeMouseMove:te,onEdgeMouseLeave:oe,reconnectRadius:ne,onReconnect:ae,onReconnectStart:Se,onReconnectEnd:ve,noDragClassName:Ae,noWheelClassName:Je,noPanClassName:et,disableKeyboardA11y:tt,nodeExtent:dn,rfId:St,viewport:Ve,onViewportChange:nt}){return _r(e),_r(t),Zh(),Lh(n),Vh(Ve),E.jsx(ch,{onPaneClick:F,onPaneMouseEnter:z,onPaneMouseMove:X,onPaneMouseLeave:Y,onPaneContextMenu:G,onPaneScroll:j,paneClickDistance:Q,deleteKeyCode:I,selectionKeyCode:b,selectionOnDrag:p,selectionMode:w,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:_,elementsSelectable:O,zoomOnScroll:P,zoomOnPinch:k,zoomOnDoubleClick:L,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:B,panOnDrag:Z,defaultViewport:A,translateExtent:R,minZoom:V,maxZoom:v,onSelectionContextMenu:u,preventScrolling:M,noDragClassName:Ae,noWheelClassName:Je,noPanClassName:et,disableKeyboardA11y:tt,onViewportChange:nt,isControlledViewport:!!Ve,children:E.jsxs(Hh,{children:[E.jsx(Rh,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:ae,onReconnectStart:Se,onReconnectEnd:ve,onlyRenderVisibleElements:$,onEdgeContextMenu:q,onEdgeMouseEnter:U,onEdgeMouseMove:te,onEdgeMouseLeave:oe,reconnectRadius:ne,defaultMarkerColor:C,noPanClassName:et,disableKeyboardA11y:tt,rfId:St}),E.jsx(Yh,{style:y,type:g,component:x,containerStyle:m}),E.jsx("div",{className:"react-flow__edgelabel-renderer"}),E.jsx(yh,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:d,nodeClickDistance:K,onlyRenderVisibleElements:$,noPanClassName:et,noDragClassName:Ae,disableKeyboardA11y:tt,nodeExtent:dn,rfId:St}),E.jsx("div",{className:"react-flow__viewport-portal"})]})})}cs.displayName="GraphView";const Gh=T.memo(cs),Er=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:l=.5,maxZoom:c=2,nodeOrigin:d,nodeExtent:u,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,y=new Map,x=new Map,m=o??t??[],b=n??e??[],p=d??[0,0],w=u??ht;_i(y,x,m);const{nodesInitialized:S}=Vn(b,h,g,{nodeOrigin:p,nodeExtent:w,zIndexMode:f});let N=[0,0,1];if(s&&r&&i){const _=bt(h,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:I,y:$,zoom:O}=eo(_,r,i,l,c,a?.padding??.1);N=[I,$,O]}return{rfId:"1",width:r??0,height:i??0,transform:N,nodes:b,nodesInitialized:S,nodeLookup:h,parentLookup:g,edges:m,edgeLookup:x,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:l,maxZoom:c,translateExtent:ht,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:He.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...ri},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ld,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:oi,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},qh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:d,nodeExtent:u,zIndexMode:f})=>gf((h,g)=>{async function y(){const{nodeLookup:x,panZoom:m,fitViewOptions:b,fitViewResolver:p,width:w,height:S,minZoom:N,maxZoom:_}=g();m&&(await ad({nodes:x,width:w,height:S,panZoom:m,minZoom:N,maxZoom:_},b),p?.resolve(!0),h({fitViewResolver:null}))}return{...Er({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:l,maxZoom:c,nodeOrigin:d,nodeExtent:u,defaultNodes:n,defaultEdges:o,zIndexMode:f}),setNodes:x=>{const{nodeLookup:m,parentLookup:b,nodeOrigin:p,elevateNodesOnSelect:w,fitViewQueued:S,zIndexMode:N,nodesSelectionActive:_}=g(),{nodesInitialized:I,hasSelectedNodes:$}=Vn(x,m,b,{nodeOrigin:p,nodeExtent:u,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:N}),O=_&&$;S&&I?(y(),h({nodes:x,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):h({nodes:x,nodesInitialized:I,nodesSelectionActive:O})},setEdges:x=>{const{connectionLookup:m,edgeLookup:b}=g();_i(m,b,x),h({edges:x})},setDefaultNodesAndEdges:(x,m)=>{if(x){const{setNodes:b}=g();b(x),h({hasDefaultNodes:!0})}if(m){const{setEdges:b}=g();b(m),h({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:m,nodeLookup:b,parentLookup:p,domNode:w,nodeOrigin:S,nodeExtent:N,debug:_,fitViewQueued:I,zIndexMode:$}=g(),{changes:O,updatedInternals:A}=Pd(x,b,p,w,S,N,$);A&&(Md(b,p,{nodeOrigin:S,nodeExtent:N,zIndexMode:$}),I?(y(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),O?.length>0&&(_&&console.log("React Flow: trigger node changes",O),m?.(O)))},updateNodePositions:(x,m=!1)=>{const b=[];let p=[];const{nodeLookup:w,triggerNodeChanges:S,connection:N,updateConnection:_,onNodesChangeMiddlewareMap:I}=g();for(const[$,O]of x){const A=w.get($),R=!!(A?.expandParent&&A?.parentId&&O?.position),V={id:$,type:"position",position:R?{x:Math.max(0,O.position.x),y:Math.max(0,O.position.y)}:O.position,dragging:m};if(A&&N.inProgress&&N.fromNode.id===A.id){const v=Be(A,N.fromHandle,W.Left,!0);_({...N,from:v})}R&&A.parentId&&b.push({id:$,parentId:A.parentId,rect:{...O.internals.positionAbsolute,width:O.measured.width??0,height:O.measured.height??0}}),p.push(V)}if(b.length>0){const{parentLookup:$,nodeOrigin:O}=g(),A=so(b,w,$,O);p.push(...A)}for(const $ of I.values())p=$(p);S(p)},triggerNodeChanges:x=>{const{onNodesChange:m,setNodes:b,nodes:p,hasDefaultNodes:w,debug:S}=g();if(x?.length){if(w){const N=Hi(x,p);b(N)}S&&console.log("React Flow: trigger node changes",x),m?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:m,setEdges:b,edges:p,hasDefaultEdges:w,debug:S}=g();if(x?.length){if(w){const N=Li(x,p);b(N)}S&&console.log("React Flow: trigger edge changes",x),m?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:S}=g();if(m){const N=x.map(_=>Pe(_,!0));w(N);return}w(Fe(p,new Set([...x]),!0)),S(Fe(b))},addSelectedEdges:x=>{const{multiSelectionActive:m,edgeLookup:b,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:S}=g();if(m){const N=x.map(_=>Pe(_,!0));S(N);return}S(Fe(b,new Set([...x]))),w(Fe(p,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:m}={})=>{const{edges:b,nodes:p,nodeLookup:w,triggerNodeChanges:S,triggerEdgeChanges:N}=g(),_=x||p,I=m||b,$=[];for(const A of _){if(!A.selected)continue;const R=w.get(A.id);R&&(R.selected=!1),$.push(Pe(A.id,!1))}const O=[];for(const A of I)A.selected&&O.push(Pe(A.id,!1));S($),N(O)},setMinZoom:x=>{const{panZoom:m,maxZoom:b}=g();m?.setScaleExtent([x,b]),h({minZoom:x})},setMaxZoom:x=>{const{panZoom:m,minZoom:b}=g();m?.setScaleExtent([b,x]),h({maxZoom:x})},setTranslateExtent:x=>{g().panZoom?.setTranslateExtent(x),h({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:m,triggerNodeChanges:b,triggerEdgeChanges:p,elementsSelectable:w}=g();if(!w)return;const S=m.reduce((_,I)=>I.selected?[..._,Pe(I.id,!1)]:_,[]),N=x.reduce((_,I)=>I.selected?[..._,Pe(I.id,!1)]:_,[]);b(S),p(N)},setNodeExtent:x=>{const{nodes:m,nodeLookup:b,parentLookup:p,nodeOrigin:w,elevateNodesOnSelect:S,nodeExtent:N,zIndexMode:_}=g();x[0][0]===N[0][0]&&x[0][1]===N[0][1]&&x[1][0]===N[1][0]&&x[1][1]===N[1][1]||(Vn(m,b,p,{nodeOrigin:w,nodeExtent:x,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:_}),h({nodeExtent:x}))},panBy:x=>{const{transform:m,width:b,height:p,panZoom:w,translateExtent:S}=g();return $d({delta:x,panZoom:w,transform:m,translateExtent:S,width:b,height:p})},setCenter:async(x,m,b)=>{const{width:p,height:w,maxZoom:S,panZoom:N}=g();if(!N)return Promise.resolve(!1);const _=typeof b?.zoom<"u"?b.zoom:S;return await N.setViewport({x:p/2-x*_,y:w/2-m*_,zoom:_},{duration:b?.duration,ease:b?.ease,interpolate:b?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...ri}})},updateConnection:x=>{h({connection:x})},reset:()=>h({...Er()})}},Object.is);function ls({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:l,fitView:c,nodeOrigin:d,nodeExtent:u,zIndexMode:f,children:h}){const[g]=T.useState(()=>qh({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:c,minZoom:s,maxZoom:a,fitViewOptions:l,nodeOrigin:d,nodeExtent:u,zIndexMode:f}));return E.jsx(pf,{value:g,children:E.jsx(Hf,{children:h})})}function Uh({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h}){return T.useContext(an)?E.jsx(E.Fragment,{children:e}):E.jsx(ls,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:l,initialMinZoom:c,initialMaxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h,children:e})}const Kh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Qh({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:u,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:y,onClickConnectStart:x,onClickConnectEnd:m,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:N,onNodeDragStart:_,onNodeDrag:I,onNodeDragStop:$,onNodesDelete:O,onEdgesDelete:A,onDelete:R,onSelectionChange:V,onSelectionDragStart:v,onSelectionDrag:M,onSelectionDragStop:C,onSelectionContextMenu:P,onSelectionStart:k,onSelectionEnd:D,onBeforeDelete:H,connectionMode:B,connectionLineType:L=Ie.Bezier,connectionLineStyle:Z,connectionLineComponent:F,connectionLineContainerStyle:z,deleteKeyCode:X="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:j=!1,selectionMode:G=gt.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:K=mt()?"Meta":"Control",zoomActivationKeyCode:q=mt()?"Meta":"Control",snapToGrid:U,snapGrid:te,onlyRenderVisibleElements:oe=!1,selectNodesOnDrag:ne,nodesDraggable:ae,autoPanOnNodeFocus:Se,nodesConnectable:ve,nodesFocusable:Ae,nodeOrigin:Je=Ri,edgesFocusable:et,edgesReconnectable:tt,elementsSelectable:dn=!0,defaultViewport:St=If,minZoom:Ve=.5,maxZoom:nt=2,translateExtent:co=ht,preventScrolling:hs=!0,nodeExtent:fn,defaultMarkerColor:gs="#b1b1b7",zoomOnScroll:ps=!0,zoomOnPinch:ms=!0,panOnScroll:ys=!1,panOnScrollSpeed:xs=.5,panOnScrollMode:ws=Te.Free,zoomOnDoubleClick:vs=!0,panOnDrag:bs=!0,onPaneClick:_s,onPaneMouseEnter:Es,onPaneMouseMove:Ns,onPaneMouseLeave:Ss,onPaneScroll:Cs,onPaneContextMenu:Ms,paneClickDistance:Is=1,nodeClickDistance:ks=0,children:As,onReconnect:Ps,onReconnectStart:$s,onReconnectEnd:Ds,onEdgeContextMenu:Ts,onEdgeDoubleClick:Rs,onEdgeMouseEnter:zs,onEdgeMouseMove:Hs,onEdgeMouseLeave:Ls,reconnectRadius:Bs=10,onNodesChange:Vs,onEdgesChange:Os,noDragClassName:js="nodrag",noWheelClassName:Fs="nowheel",noPanClassName:lo="nopan",fitView:uo,fitViewOptions:fo,connectOnClick:Xs,attributionPosition:Ys,proOptions:Ws,defaultEdgeOptions:Zs,elevateNodesOnSelect:Gs=!0,elevateEdgesOnSelect:qs=!1,disableKeyboardA11y:ho=!1,autoPanOnConnect:Us,autoPanOnNodeDrag:Ks,autoPanSpeed:Qs,connectionRadius:Js,isValidConnection:ea,onError:ta,style:na,id:go,nodeDragThreshold:oa,connectionDragThreshold:ra,viewport:ia,onViewportChange:sa,width:aa,height:ca,colorMode:la="light",debug:ua,onScroll:po,ariaLabelConfig:da,zIndexMode:mo="basic",...fa},ha){const hn=go||"1",ga=$f(la),pa=T.useCallback(yo=>{yo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),po?.(yo)},[po]);return E.jsx("div",{"data-testid":"rf__wrapper",...fa,onScroll:pa,style:{...na,...Kh},ref:ha,className:se(["react-flow",r,ga]),id:go,role:"application",children:E.jsxs(Uh,{nodes:e,edges:t,width:aa,height:ca,fitView:uo,fitViewOptions:fo,minZoom:Ve,maxZoom:nt,nodeOrigin:Je,nodeExtent:fn,zIndexMode:mo,children:[E.jsx(Pf,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:g,onConnectEnd:y,onClickConnectStart:x,onClickConnectEnd:m,nodesDraggable:ae,autoPanOnNodeFocus:Se,nodesConnectable:ve,nodesFocusable:Ae,edgesFocusable:et,edgesReconnectable:tt,elementsSelectable:dn,elevateNodesOnSelect:Gs,elevateEdgesOnSelect:qs,minZoom:Ve,maxZoom:nt,nodeExtent:fn,onNodesChange:Vs,onEdgesChange:Os,snapToGrid:U,snapGrid:te,connectionMode:B,translateExtent:co,connectOnClick:Xs,defaultEdgeOptions:Zs,fitView:uo,fitViewOptions:fo,onNodesDelete:O,onEdgesDelete:A,onDelete:R,onNodeDragStart:_,onNodeDrag:I,onNodeDragStop:$,onSelectionDrag:M,onSelectionDragStart:v,onSelectionDragStop:C,onMove:d,onMoveStart:u,onMoveEnd:f,noPanClassName:lo,nodeOrigin:Je,rfId:hn,autoPanOnConnect:Us,autoPanOnNodeDrag:Ks,autoPanSpeed:Qs,onError:ta,connectionRadius:Js,isValidConnection:ea,selectNodesOnDrag:ne,nodeDragThreshold:oa,connectionDragThreshold:ra,onBeforeDelete:H,debug:ua,ariaLabelConfig:da,zIndexMode:mo}),E.jsx(Gh,{onInit:c,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:N,nodeTypes:i,edgeTypes:s,connectionLineType:L,connectionLineStyle:Z,connectionLineComponent:F,connectionLineContainerStyle:z,selectionKeyCode:Y,selectionOnDrag:j,selectionMode:G,deleteKeyCode:X,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:q,onlyRenderVisibleElements:oe,defaultViewport:St,translateExtent:co,minZoom:Ve,maxZoom:nt,preventScrolling:hs,zoomOnScroll:ps,zoomOnPinch:ms,zoomOnDoubleClick:vs,panOnScroll:ys,panOnScrollSpeed:xs,panOnScrollMode:ws,panOnDrag:bs,onPaneClick:_s,onPaneMouseEnter:Es,onPaneMouseMove:Ns,onPaneMouseLeave:Ss,onPaneScroll:Cs,onPaneContextMenu:Ms,paneClickDistance:Is,nodeClickDistance:ks,onSelectionContextMenu:P,onSelectionStart:k,onSelectionEnd:D,onReconnect:Ps,onReconnectStart:$s,onReconnectEnd:Ds,onEdgeContextMenu:Ts,onEdgeDoubleClick:Rs,onEdgeMouseEnter:zs,onEdgeMouseMove:Hs,onEdgeMouseLeave:Ls,reconnectRadius:Bs,defaultMarkerColor:gs,noDragClassName:js,noWheelClassName:Fs,noPanClassName:lo,rfId:hn,disableKeyboardA11y:ho,nodeExtent:fn,viewport:ia,onViewportChange:sa}),E.jsx(Mf,{onSelectionChange:V}),As,E.jsx(_f,{proOptions:Ws,position:Ys}),E.jsx(bf,{rfId:hn,disableKeyboardA11y:ho})]})})}var Jh=Bi(Qh);function eg({dimensions:e,lineWidth:t,variant:n,className:o}){return E.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,o])})}function tg({radius:e,className:t}){return E.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var ke;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ke||(ke={}));const ng={[ke.Dots]:1,[ke.Lines]:1,[ke.Cross]:6},og=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function us({id:e,variant:t=ke.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:a,style:l,className:c,patternClassName:d}){const u=T.useRef(null),{transform:f,patternId:h}=ee(og,re),g=o||ng[t],y=t===ke.Dots,x=t===ke.Cross,m=Array.isArray(n)?n:[n,n],b=[m[0]*f[2]||1,m[1]*f[2]||1],p=g*f[2],w=Array.isArray(i)?i:[i,i],S=x?[p,p]:b,N=[w[0]*f[2]||1+S[0]/2,w[1]*f[2]||1+S[1]/2],_=`${h}${e||""}`;return E.jsxs("svg",{className:se(["react-flow__background",c]),style:{...l,...ln,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:u,"data-testid":"rf__background",children:[E.jsx("pattern",{id:_,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:y?E.jsx(tg,{radius:p/2,className:d}):E.jsx(eg,{dimensions:S,lineWidth:r,variant:t,className:d})}),E.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${_})`})]})}us.displayName="Background";const rg=T.memo(us);function ig(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:E.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function sg(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:E.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ag(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:E.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function cg(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:E.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function lg(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:E.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Tt({children:e,className:t,...n}){return E.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const ug=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function ds({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:l,className:c,children:d,position:u="bottom-left",orientation:f="vertical","aria-label":h}){const g=ie(),{isInteractive:y,minZoomReached:x,maxZoomReached:m,ariaLabelConfig:b}=ee(ug,re),{zoomIn:p,zoomOut:w,fitView:S}=cn(),N=()=>{p(),i?.()},_=()=>{w(),s?.()},I=()=>{S(r),a?.()},$=()=>{g.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),l?.(!y)},O=f==="horizontal"?"horizontal":"vertical";return E.jsxs(Nt,{className:se(["react-flow__controls",O,c]),position:u,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&E.jsxs(E.Fragment,{children:[E.jsx(Tt,{onClick:N,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:m,children:E.jsx(ig,{})}),E.jsx(Tt,{onClick:_,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:x,children:E.jsx(sg,{})})]}),n&&E.jsx(Tt,{className:"react-flow__controls-fitview",onClick:I,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:E.jsx(ag,{})}),o&&E.jsx(Tt,{className:"react-flow__controls-interactive",onClick:$,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:y?E.jsx(lg,{}):E.jsx(cg,{})}),d]})}ds.displayName="Controls";const dg=T.memo(ds);function fg({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:a,strokeWidth:l,className:c,borderRadius:d,shapeRendering:u,selected:f,onClick:h}){const{background:g,backgroundColor:y}=i||{},x=s||g||y;return E.jsx("rect",{className:se(["react-flow__minimap-node",{selected:f},c]),x:t,y:n,rx:d,ry:d,width:o,height:r,style:{fill:x,stroke:a,strokeWidth:l},shapeRendering:u,onClick:h?m=>h(m,e):void 0})}const hg=T.memo(fg),gg=e=>e.nodes.map(t=>t.id),Mn=e=>e instanceof Function?e:()=>e;function pg({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=hg,onClick:s}){const a=ee(gg,re),l=Mn(t),c=Mn(e),d=Mn(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return E.jsx(E.Fragment,{children:a.map(f=>E.jsx(yg,{id:f,nodeColorFunc:l,nodeStrokeColorFunc:c,nodeClassNameFunc:d,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:u},f))})}function mg({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:l}){const{node:c,x:d,y:u,width:f,height:h}=ee(g=>{const y=g.nodeLookup.get(e);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const x=y.internals.userNode,{x:m,y:b}=y.internals.positionAbsolute,{width:p,height:w}=Ne(x);return{node:x,x:m,y:b,width:p,height:w}},re);return!c||c.hidden||!di(c)?null:E.jsx(a,{x:d,y:u,width:f,height:h,style:c.style,selected:!!c.selected,className:o(c),color:t(c),borderRadius:r,strokeColor:n(c),strokeWidth:i,shapeRendering:s,onClick:l,id:c.id})}const yg=T.memo(mg);var xg=T.memo(pg);const wg=200,vg=150,bg=e=>!e.hidden,_g=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?ui(bt(e.nodeLookup,{filter:bg}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Eg="react-flow__minimap-desc";function fs({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:l,maskColor:c,maskStrokeColor:d,maskStrokeWidth:u,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:y=!1,zoomable:x=!1,ariaLabel:m,inversePan:b,zoomStep:p=1,offsetScale:w=5}){const S=ie(),N=T.useRef(null),{boundingRect:_,viewBB:I,rfId:$,panZoom:O,translateExtent:A,flowWidth:R,flowHeight:V,ariaLabelConfig:v}=ee(_g,re),M=e?.width??wg,C=e?.height??vg,P=_.width/M,k=_.height/C,D=Math.max(P,k),H=D*M,B=D*C,L=w*D,Z=_.x-(H-_.width)/2-L,F=_.y-(B-_.height)/2-L,z=H+L*2,X=B+L*2,Y=`${Eg}-${$}`,j=T.useRef(0),G=T.useRef();j.current=D,T.useEffect(()=>{if(N.current&&O)return G.current=Od({domNode:N.current,panZoom:O,getTransform:()=>S.getState().transform,getViewScale:()=>j.current}),()=>{G.current?.destroy()}},[O]),T.useEffect(()=>{G.current?.update({translateExtent:A,width:R,height:V,inversePan:b,pannable:y,zoomStep:p,zoomable:x})},[y,x,b,p,A,R,V]);const Q=h?U=>{const[te,oe]=G.current?.pointer(U)||[0,0];h(U,{x:te,y:oe})}:void 0,K=g?T.useCallback((U,te)=>{const oe=S.getState().nodeLookup.get(te).internals.userNode;g(U,oe)},[]):void 0,q=m??v["minimap.ariaLabel"];return E.jsx(Nt,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*D:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:E.jsxs("svg",{width:M,height:C,viewBox:`${Z} ${F} ${z} ${X}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Y,ref:N,onClick:Q,children:[q&&E.jsx("title",{id:Y,children:q}),E.jsx(xg,{onClick:K,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),E.jsx("path",{className:"react-flow__minimap-mask",d:`M${Z-L},${F-L}h${z+L*2}v${X+L*2}h${-z-L*2}z
|
|
7
|
-
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}fs.displayName="MiniMap";const Ng=T.memo(fs),Sg=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Cg={[Ke.Line]:"right",[Ke.Handle]:"bottom-right"};function Mg({nodeId:e,position:t,variant:n=Ke.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:a=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:y,onResize:x,onResizeEnd:m}){const b=Fi(),p=typeof e=="string"?e:b,w=ie(),S=T.useRef(null),N=n===Ke.Handle,_=ee(T.useCallback(Sg(N&&h),[N,h]),re),I=T.useRef(null),$=t??Cg[n];T.useEffect(()=>{if(!(!S.current||!p))return I.current||(I.current=tf({domNode:S.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:A,transform:R,snapGrid:V,snapToGrid:v,nodeOrigin:M,domNode:C}=w.getState();return{nodeLookup:A,transform:R,snapGrid:V,snapToGrid:v,nodeOrigin:M,paneDomNode:C}},onChange:(A,R)=>{const{triggerNodeChanges:V,nodeLookup:v,parentLookup:M,nodeOrigin:C}=w.getState(),P=[],k={x:A.x,y:A.y},D=v.get(p);if(D&&D.expandParent&&D.parentId){const H=D.origin??C,B=A.width??D.measured.width??0,L=A.height??D.measured.height??0,Z={id:D.id,parentId:D.parentId,rect:{width:B,height:L,...fi({x:A.x??D.position.x,y:A.y??D.position.y},{width:B,height:L},D.parentId,v,H)}},F=so([Z],v,M,C);P.push(...F),k.x=A.x?Math.max(H[0]*B,A.x):void 0,k.y=A.y?Math.max(H[1]*L,A.y):void 0}if(k.x!==void 0&&k.y!==void 0){const H={id:p,type:"position",position:{...k}};P.push(H)}if(A.width!==void 0&&A.height!==void 0){const B={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};P.push(B)}for(const H of R){const B={...H,type:"position"};P.push(B)}V(P)},onEnd:({width:A,height:R})=>{const V={id:p,type:"dimensions",resizing:!1,dimensions:{width:A,height:R}};w.getState().triggerNodeChanges([V])}})),I.current.update({controlPosition:$,boundaries:{minWidth:a,minHeight:l,maxWidth:c,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:y,onResize:x,onResizeEnd:m,shouldResize:g}),()=>{I.current?.destroy()}},[$,a,l,c,d,u,y,x,m,g]);const O=$.split("-");return E.jsx("div",{className:se(["react-flow__resize-control","nodrag",...O,n,o]),ref:S,style:{...r,scale:_,...s&&{[N?"backgroundColor":"borderColor"]:s}},children:i})}T.memo(Mg);const In=5,Vt=240,Ig=180,kg=420,Nr=[{id:"top",position:W.Top},{id:"right",position:W.Right},{id:"bottom",position:W.Bottom},{id:"left",position:W.Left}];function Ag(e){const t=/^(\d+)x(\d+)$/.exec(e??"");if(!t)return Vt;const n=Number(t[1]),o=Number(t[2]);if(!Number.isFinite(n)||!Number.isFinite(o)||n<=0||o<=0)return Vt;const r=Vt*(n/o);return Math.round(Math.min(kg,Math.max(Ig,r)))}function Pg({id:e,data:t,selected:n}){const{t:o}=Xn(),r=t,i=J(z=>z.updateNodePrompt),s=J(z=>z.addNodeReferences),a=J(z=>z.readDroppedImageMetadata),l=J(z=>z.removeNodeReference),c=J(z=>z.generateNode),d=J(z=>z.generateNodeInPlace),u=J(z=>z.generateNodeVariation),f=J(z=>z.animateImage),h=J(z=>z.addChildNode),g=J(z=>z.duplicateBranchRoot),y=J(z=>z.deleteNode),x=T.useRef(null),[m,b]=T.useState(!1),[p,w]=T.useState(!1),S=r.referenceImages??[],N=r.status==="pending"||r.status==="reconciling",_=!N&&S.length<In,I={"--node-preview-w":`${Ag(r.size)}px`,"--node-preview-h":`${Vt}px`},$=T.useCallback(z=>i(e,z.target.value),[e,i]),O=T.useCallback(()=>{c(e)},[e,c]),A=T.useCallback(()=>{d(e)},[e,d]),R=T.useCallback(()=>{u(e)},[e,u]),V=T.useCallback(()=>{r.status==="ready"&&h(e)},[e,r.status,h]),v=T.useCallback(()=>{if(r.status!=="ready"||!r.imageUrl||gn(r.imageUrl))return;const z=r.imageUrl.replace(/^\/generated\//,"");f(z,r.prompt)},[r.status,r.imageUrl,r.prompt,f]),M=T.useCallback(()=>{g(e)},[e,g]),C=T.useCallback(()=>y(e),[e,y]),P=z=>{if(!z)return[];const X=[];for(const Y of Array.from(z)){if(Y.kind!=="file"||!Y.type.startsWith("image/"))continue;const j=Y.getAsFile();j&&X.push(j)}return X},k=async z=>{z.length!==0&&(z.length===1&&await a(z[0],e)||await s(e,z))},D=async z=>{z.preventDefault(),z.stopPropagation(),b(!1);const X=Array.from(z.dataTransfer.files).filter(Y=>Y.type.startsWith("image/"));X.length===1&&await a(X[0],e)||_&&X.length>0&&s(e,X)},H=z=>{z.preventDefault(),z.stopPropagation(),_&&!m&&b(!0)},B=z=>{z.currentTarget.contains(z.relatedTarget)||b(!1)},L=z=>{const X=P(z.clipboardData?.items??null);if(X.length===0||(z.preventDefault(),z.stopPropagation(),!_))return;const Y=In-S.length;s(e,X.slice(0,Y))},F=(()=>{switch(r.status){case"empty":return o("node.empty");case"pending":return o("node.pending");case"reconciling":return r.pendingPhase?o("node.reconcilingPhase",{phase:r.pendingPhase}):o("node.reconciling");case"ready":return[r.webSearchCalls?o("node.readyWithSearch",{elapsed:r.elapsed??"?",searches:r.webSearchCalls}):o("node.ready",{elapsed:r.elapsed??"?"}),r.video?.duration?`${r.video.duration}s`:null,r.video?.resolution??null,r.video?.aspectRatio??null,wa(r.reasoningEffort),va(r.model)].filter(Boolean).join(" · ");case"stale":return r.error?o("node.staleWithError",{error:r.error}):o("node.stale");case"asset-missing":return r.error?o("node.assetMissingWithError",{error:r.error}):o("node.assetMissing");case"error":return o("node.error",{error:r.error??o("node.errorUnknown")});default:return""}})();return E.jsxs("div",{className:`image-node image-node--${r.status}${n?" image-node--selected":""}`,style:I,children:[Nr.map(({id:z,position:X})=>E.jsx(Qe,{type:"target",id:`target-${z}`,position:X,className:`image-node__handle image-node__handle--target image-node__handle--${z}`},`target-${z}`)),E.jsx("div",{className:"image-node__preview",children:r.imageUrl&&r.status!=="asset-missing"?gn(r.imageUrl)?E.jsx("video",{src:r.imageUrl,controls:!0,loop:!0,playsInline:!0,muted:!0,className:"image-node__video nodrag"}):E.jsx("img",{src:r.imageUrl,alt:o("node.nodeImageAlt")}):N&&r.partialImageUrl?E.jsx("img",{className:"image-node__partial",src:r.partialImageUrl,alt:o("node.partialImageAlt")}):N?E.jsx("div",{className:"image-node__skeleton"}):r.status==="asset-missing"?E.jsx("div",{className:"image-node__placeholder",children:o("node.noAsset")}):r.status==="stale"?E.jsx("div",{className:"image-node__placeholder",children:o("node.stateStale")}):E.jsx("div",{className:"image-node__placeholder",children:o("node.noImage")})}),E.jsxs("div",{className:`image-node__composer nodrag${m?" is-dragging":""}`,onDrop:D,onDragOver:H,onDragLeave:B,onPaste:L,children:[S.length>0?E.jsx("div",{className:"image-node__refs",children:S.map((z,X)=>E.jsxs("div",{className:"image-node__ref-chip",title:o("node.refAlt",{n:X+1}),children:[E.jsx("img",{src:z,alt:o("node.refAlt",{n:X+1})}),E.jsx("button",{type:"button",className:"image-node__ref-remove",onClick:()=>l(e,X),disabled:N,"aria-label":o("node.removeRef",{n:X+1}),children:"×"})]},X))}):null,E.jsx("textarea",{className:"image-node__prompt",value:r.prompt,onChange:$,onKeyDown:z=>z.stopPropagation(),placeholder:r.parentServerNodeId?o("node.editPromptPlaceholder"):o("node.promptPlaceholder"),rows:2,disabled:N}),E.jsxs("div",{className:"image-node__composer-bar",children:[E.jsx("button",{type:"button",className:"image-node__attach",onClick:()=>_&&x.current?.click(),disabled:!_,title:r.parentServerNodeId?o("node.nodeRefsUsedWithParent"):o("node.attachRefTitle"),children:o("node.attachRef")}),m?E.jsx("span",{className:"image-node__drop-hint",children:o("node.dropRefs")}):S.length>0?E.jsxs("span",{className:"image-node__ref-count",children:[S.length,"/",In]}):null]}),E.jsx("input",{ref:x,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:z=>{const X=Array.from(z.target.files??[]);X.length>0&&k(X),z.target.value=""}})]}),E.jsxs("div",{className:"image-node__footer nodrag",children:[E.jsx("span",{className:"image-node__status",title:F,children:F}),E.jsxs("div",{className:"image-node__actions",children:[E.jsxs("div",{style:{position:"relative"},children:[E.jsx("button",{type:"button",onClick:()=>w(z=>!z),disabled:!r.prompt?.trim(),title:o("promptLibrary.saveTitle"),"aria-label":o("promptLibrary.saveTitle"),children:"☆"}),p&&E.jsx(xa,{text:r.prompt||"",onClose:()=>w(!1)})]}),r.status==="ready"?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button",onClick:A,disabled:N,title:o("node.regenerateTitle"),"aria-label":o("node.regenerateTitle"),children:"↻"}),E.jsx("button",{type:"button",onClick:R,disabled:N,title:o("node.newVariationTitle"),"aria-label":o("node.newVariationTitle"),children:o("node.newVariation")}),!gn(r.imageUrl)&&E.jsx("button",{type:"button",onClick:v,disabled:N,title:o("node.animateTitle",{fallback:"Animate"}),"aria-label":o("node.animateTitle",{fallback:"Animate"}),children:"▶"})]}):E.jsx("button",{type:"button",className:"image-node__generate",onClick:O,disabled:N,title:o("node.generateTitle"),"aria-label":o("node.generateTitle"),children:o("node.generate")}),r.status==="ready"?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button",onClick:V,title:o("node.addChildTitle"),"aria-label":o("node.addChildTitle"),children:o("node.addChild")}),E.jsx("button",{type:"button",onClick:M,title:o("node.duplicateBranchTitle"),"aria-label":o("node.duplicateBranchTitle"),children:o("node.duplicateBranch")})]}):null,E.jsx("button",{type:"button",onClick:C,className:"image-node__del",title:o("node.deleteTitle"),"aria-label":o("node.deleteTitle"),children:"×"})]})]}),Nr.map(({id:z,position:X})=>E.jsx(Qe,{type:"source",id:`source-${z}`,position:X,className:`image-node__handle image-node__handle--source image-node__handle--${z}`},`source-${z}`))]})}const $g=T.memo(Pg);function Dg(){const{t:e}=Xn(),t=J(b=>b.graphNodes),n=J(b=>b.graphEdges),o=J(b=>b.nodeSelectionMode),r=J(b=>b.nodeBatchRunning),i=J(b=>b.nodeBatchStopping),s=J(b=>b.toggleNodeSelectionMode),a=J(b=>b.selectAllGraphNodes),l=J(b=>b.clearNodeSelection),c=J(b=>b.runNodeBatch),d=J(b=>b.cancelNodeBatch),u=J(b=>b.disconnectEdges),f=t.filter(b=>b.selected).map(b=>b.id),h=n.filter(b=>b.selected).map(b=>b.id),g=new Set(f),y=t.filter(b=>g.has(b.id)&&!ba(b)).length,x=_a(n,f).length,m=b=>{c(b)};return E.jsxs(Nt,{position:"top-center",className:"node-batch-bar nodrag",children:[E.jsx("button",{type:"button",onClick:s,"aria-pressed":o,children:e(o?"nodeBatch.selectionOn":"nodeBatch.selectionOff")}),E.jsx("button",{type:"button",onClick:a,disabled:t.length===0,children:e("nodeBatch.selectAll")}),h.length>0?E.jsx("button",{type:"button",className:"node-batch-bar__danger",onClick:()=>u(h),title:e("edge.disconnectTitle"),"aria-label":e("edge.disconnectTitle"),children:e("edge.disconnect")}):null,f.length>0?E.jsxs(E.Fragment,{children:[E.jsx("span",{className:"node-batch-bar__meta",children:e("nodeBatch.summary",{selected:f.length,missing:y,stale:x})}),E.jsx("button",{type:"button",onClick:()=>m("missing-only"),disabled:r,children:e("nodeBatch.generateMissing")}),E.jsx("button",{type:"button",onClick:()=>m("regenerate-all"),disabled:r,children:e("nodeBatch.regenerateSelected")}),r?E.jsx("button",{type:"button",onClick:d,disabled:i,children:e(i?"nodeBatch.stopping":"nodeBatch.stopRemaining")}):null,E.jsx("button",{type:"button",onClick:l,disabled:r,children:e("nodeBatch.clear")})]}):null]})}function Tg(){const{t:e}=Xn(),t=Ea(),n=J(_=>_.graphNodes),o=J(_=>_.graphEdges),r=J(_=>_.setGraphNodes),i=J(_=>_.setGraphEdges),s=J(_=>_.disconnectEdges),a=J(_=>_.addRootNode),l=J(_=>_.addChildNodeAt),c=J(_=>_.connectNodes),d=J(_=>_.deleteNodes),u=J(_=>_.nodeSelectionMode),f=J(_=>_.selectNodeGraph),h=J(_=>_.sessionLoading),{screenToFlowPosition:g}=cn(),y=T.useRef(null),x=T.useMemo(()=>({imageNode:$g}),[]),m=T.useCallback(_=>r(Hi(_,n)),[n,r]),b=T.useCallback(_=>{const I=_.filter($=>$.type==="remove").map($=>$.id);if(I.length>0){if(u)return;s(I);return}i(Li(_,o))},[s,o,u,i]),p=T.useCallback(_=>{_.source&&_.target&&c(_.source,_.target,_.sourceHandle,_.targetHandle)},[c]),w=T.useCallback((_,I)=>{if(I.isValid)return;const $=I.fromNode?.id;if(!$||I.toNode||I.toHandle)return;const O="touches"in _?_.changedTouches[0].clientX:_.clientX,A="touches"in _?_.changedTouches[0].clientY:_.clientY,R=g({x:O,y:A});l($,R,I.fromHandle?.id??null)},[l,g]),S=T.useCallback(_=>d(_.map(I=>I.id)),[d]),N=T.useCallback((_,I)=>{u&&(_.preventDefault(),f(I.id,_.metaKey||_.ctrlKey))},[u,f]);return E.jsxs("main",{className:"node-canvas",ref:y,children:[h&&E.jsx("div",{className:"node-canvas__loading",children:e("nodeCanvas.loading")}),n.length===0?E.jsx("button",{type:"button",className:"node-canvas__plus",onClick:()=>a(),children:e("nodeCanvas.addFirst")}):E.jsxs(E.Fragment,{children:[E.jsxs(Jh,{nodes:n,edges:o,onNodesChange:m,onEdgesChange:b,onConnect:p,onConnectEnd:w,onNodesDelete:S,onNodeClick:N,nodeTypes:x,connectionMode:He.Loose,connectionRadius:32,selectionOnDrag:u,multiSelectionKeyCode:u?null:void 0,panOnDrag:u?[2]:!0,fitView:!0,deleteKeyCode:u?null:["Delete","Backspace"],proOptions:{hideAttribution:!0},children:[E.jsx(Dg,{}),E.jsx(rg,{gap:24,color:"var(--canvas-grid)"}),E.jsx(dg,{className:"node-canvas__controls"}),!t&&E.jsx(Ng,{pannable:!0,zoomable:!0,maskColor:"var(--minimap-mask)",nodeColor:"var(--minimap-node-fill)",nodeStrokeColor:"var(--minimap-node-stroke)",style:{background:"var(--minimap-bg)",border:"1px solid var(--minimap-border)"}})]}),E.jsx("button",{type:"button",className:"node-canvas__add-root",onClick:()=>a(),title:e("nodeCanvas.addRootTitle"),children:"+"}),E.jsx("div",{className:"node-canvas__hint",children:e("nodeCanvas.hint")})]})]})}function zg(){return E.jsx(ls,{children:E.jsx(Tg,{})})}export{zg as NodeCanvas};
|
|
7
|
+
M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}fs.displayName="MiniMap";const Ng=T.memo(fs),Sg=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Cg={[Ke.Line]:"right",[Ke.Handle]:"bottom-right"};function Mg({nodeId:e,position:t,variant:n=Ke.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:a=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:y,onResize:x,onResizeEnd:m}){const b=Fi(),p=typeof e=="string"?e:b,w=ie(),S=T.useRef(null),N=n===Ke.Handle,_=ee(T.useCallback(Sg(N&&h),[N,h]),re),I=T.useRef(null),$=t??Cg[n];T.useEffect(()=>{if(!(!S.current||!p))return I.current||(I.current=tf({domNode:S.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:A,transform:R,snapGrid:V,snapToGrid:v,nodeOrigin:M,domNode:C}=w.getState();return{nodeLookup:A,transform:R,snapGrid:V,snapToGrid:v,nodeOrigin:M,paneDomNode:C}},onChange:(A,R)=>{const{triggerNodeChanges:V,nodeLookup:v,parentLookup:M,nodeOrigin:C}=w.getState(),P=[],k={x:A.x,y:A.y},D=v.get(p);if(D&&D.expandParent&&D.parentId){const H=D.origin??C,B=A.width??D.measured.width??0,L=A.height??D.measured.height??0,Z={id:D.id,parentId:D.parentId,rect:{width:B,height:L,...fi({x:A.x??D.position.x,y:A.y??D.position.y},{width:B,height:L},D.parentId,v,H)}},F=so([Z],v,M,C);P.push(...F),k.x=A.x?Math.max(H[0]*B,A.x):void 0,k.y=A.y?Math.max(H[1]*L,A.y):void 0}if(k.x!==void 0&&k.y!==void 0){const H={id:p,type:"position",position:{...k}};P.push(H)}if(A.width!==void 0&&A.height!==void 0){const B={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};P.push(B)}for(const H of R){const B={...H,type:"position"};P.push(B)}V(P)},onEnd:({width:A,height:R})=>{const V={id:p,type:"dimensions",resizing:!1,dimensions:{width:A,height:R}};w.getState().triggerNodeChanges([V])}})),I.current.update({controlPosition:$,boundaries:{minWidth:a,minHeight:l,maxWidth:c,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:y,onResize:x,onResizeEnd:m,shouldResize:g}),()=>{I.current?.destroy()}},[$,a,l,c,d,u,y,x,m,g]);const O=$.split("-");return E.jsx("div",{className:se(["react-flow__resize-control","nodrag",...O,n,o]),ref:S,style:{...r,scale:_,...s&&{[N?"backgroundColor":"borderColor"]:s}},children:i})}T.memo(Mg);const In=5,Vt=240,Ig=180,kg=420,Nr=[{id:"top",position:W.Top},{id:"right",position:W.Right},{id:"bottom",position:W.Bottom},{id:"left",position:W.Left}];function Ag(e){const t=/^(\d+)x(\d+)$/.exec(e??"");if(!t)return Vt;const n=Number(t[1]),o=Number(t[2]);if(!Number.isFinite(n)||!Number.isFinite(o)||n<=0||o<=0)return Vt;const r=Vt*(n/o);return Math.round(Math.min(kg,Math.max(Ig,r)))}function Pg({id:e,data:t,selected:n}){const{t:o}=Xn(),r=t,i=J(z=>z.updateNodePrompt),s=J(z=>z.addNodeReferences),a=J(z=>z.readDroppedImageMetadata),l=J(z=>z.removeNodeReference),c=J(z=>z.generateNode),d=J(z=>z.generateNodeInPlace),u=J(z=>z.generateNodeVariation),f=J(z=>z.animateImage),h=J(z=>z.addChildNode),g=J(z=>z.duplicateBranchRoot),y=J(z=>z.deleteNode),x=T.useRef(null),[m,b]=T.useState(!1),[p,w]=T.useState(!1),S=r.referenceImages??[],N=r.status==="pending"||r.status==="reconciling",_=!N&&S.length<In,I={"--node-preview-w":`${Ag(r.size)}px`,"--node-preview-h":`${Vt}px`},$=T.useCallback(z=>i(e,z.target.value),[e,i]),O=T.useCallback(()=>{c(e)},[e,c]),A=T.useCallback(()=>{d(e)},[e,d]),R=T.useCallback(()=>{u(e)},[e,u]),V=T.useCallback(()=>{r.status==="ready"&&h(e)},[e,r.status,h]),v=T.useCallback(()=>{if(r.status!=="ready"||!r.imageUrl||gn(r.imageUrl))return;const z=r.imageUrl.replace(/^\/generated\//,"");f(z,r.prompt)},[r.status,r.imageUrl,r.prompt,f]),M=T.useCallback(()=>{g(e)},[e,g]),C=T.useCallback(()=>y(e),[e,y]),P=z=>{if(!z)return[];const X=[];for(const Y of Array.from(z)){if(Y.kind!=="file"||!Y.type.startsWith("image/"))continue;const j=Y.getAsFile();j&&X.push(j)}return X},k=async z=>{z.length!==0&&(z.length===1&&await a(z[0],e)||await s(e,z))},D=async z=>{z.preventDefault(),z.stopPropagation(),b(!1);const X=Array.from(z.dataTransfer.files).filter(Y=>Y.type.startsWith("image/"));X.length===1&&await a(X[0],e)||_&&X.length>0&&s(e,X)},H=z=>{z.preventDefault(),z.stopPropagation(),_&&!m&&b(!0)},B=z=>{z.currentTarget.contains(z.relatedTarget)||b(!1)},L=z=>{const X=P(z.clipboardData?.items??null);if(X.length===0||(z.preventDefault(),z.stopPropagation(),!_))return;const Y=In-S.length;s(e,X.slice(0,Y))},F=(()=>{switch(r.status){case"empty":return o("node.empty");case"pending":return o("node.pending");case"reconciling":return r.pendingPhase?o("node.reconcilingPhase",{phase:r.pendingPhase}):o("node.reconciling");case"ready":return[r.webSearchCalls?o("node.readyWithSearch",{elapsed:r.elapsed??"?",searches:r.webSearchCalls}):o("node.ready",{elapsed:r.elapsed??"?"}),r.video?.duration?`${r.video.duration}s`:null,r.video?.resolution??null,r.video?.aspectRatio??null,wa(r.reasoningEffort),va(r.model,r.provider)].filter(Boolean).join(" · ");case"stale":return r.error?o("node.staleWithError",{error:r.error}):o("node.stale");case"asset-missing":return r.error?o("node.assetMissingWithError",{error:r.error}):o("node.assetMissing");case"error":return o("node.error",{error:r.error??o("node.errorUnknown")});default:return""}})();return E.jsxs("div",{className:`image-node image-node--${r.status}${n?" image-node--selected":""}`,style:I,children:[Nr.map(({id:z,position:X})=>E.jsx(Qe,{type:"target",id:`target-${z}`,position:X,className:`image-node__handle image-node__handle--target image-node__handle--${z}`},`target-${z}`)),E.jsx("div",{className:"image-node__preview",children:r.imageUrl&&r.status!=="asset-missing"?gn(r.imageUrl)?E.jsx("video",{src:r.imageUrl,controls:!0,loop:!0,playsInline:!0,muted:!0,className:"image-node__video nodrag"}):E.jsx("img",{src:r.imageUrl,alt:o("node.nodeImageAlt")}):N&&r.partialImageUrl?E.jsx("img",{className:"image-node__partial",src:r.partialImageUrl,alt:o("node.partialImageAlt")}):N?E.jsx("div",{className:"image-node__skeleton"}):r.status==="asset-missing"?E.jsx("div",{className:"image-node__placeholder",children:o("node.noAsset")}):r.status==="stale"?E.jsx("div",{className:"image-node__placeholder",children:o("node.stateStale")}):E.jsx("div",{className:"image-node__placeholder",children:o("node.noImage")})}),E.jsxs("div",{className:`image-node__composer nodrag${m?" is-dragging":""}`,onDrop:D,onDragOver:H,onDragLeave:B,onPaste:L,children:[S.length>0?E.jsx("div",{className:"image-node__refs",children:S.map((z,X)=>E.jsxs("div",{className:"image-node__ref-chip",title:o("node.refAlt",{n:X+1}),children:[E.jsx("img",{src:z,alt:o("node.refAlt",{n:X+1})}),E.jsx("button",{type:"button",className:"image-node__ref-remove",onClick:()=>l(e,X),disabled:N,"aria-label":o("node.removeRef",{n:X+1}),children:"×"})]},X))}):null,E.jsx("textarea",{className:"image-node__prompt",value:r.prompt,onChange:$,onKeyDown:z=>z.stopPropagation(),placeholder:r.parentServerNodeId?o("node.editPromptPlaceholder"):o("node.promptPlaceholder"),rows:2,disabled:N}),E.jsxs("div",{className:"image-node__composer-bar",children:[E.jsx("button",{type:"button",className:"image-node__attach",onClick:()=>_&&x.current?.click(),disabled:!_,title:r.parentServerNodeId?o("node.nodeRefsUsedWithParent"):o("node.attachRefTitle"),children:o("node.attachRef")}),m?E.jsx("span",{className:"image-node__drop-hint",children:o("node.dropRefs")}):S.length>0?E.jsxs("span",{className:"image-node__ref-count",children:[S.length,"/",In]}):null]}),E.jsx("input",{ref:x,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:z=>{const X=Array.from(z.target.files??[]);X.length>0&&k(X),z.target.value=""}})]}),E.jsxs("div",{className:"image-node__footer nodrag",children:[E.jsx("span",{className:"image-node__status",title:F,children:F}),E.jsxs("div",{className:"image-node__actions",children:[E.jsxs("div",{style:{position:"relative"},children:[E.jsx("button",{type:"button",onClick:()=>w(z=>!z),disabled:!r.prompt?.trim(),title:o("promptLibrary.saveTitle"),"aria-label":o("promptLibrary.saveTitle"),children:"☆"}),p&&E.jsx(xa,{text:r.prompt||"",onClose:()=>w(!1)})]}),r.status==="ready"?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button",onClick:A,disabled:N,title:o("node.regenerateTitle"),"aria-label":o("node.regenerateTitle"),children:"↻"}),E.jsx("button",{type:"button",onClick:R,disabled:N,title:o("node.newVariationTitle"),"aria-label":o("node.newVariationTitle"),children:o("node.newVariation")}),!gn(r.imageUrl)&&E.jsx("button",{type:"button",onClick:v,disabled:N,title:o("node.animateTitle",{fallback:"Animate"}),"aria-label":o("node.animateTitle",{fallback:"Animate"}),children:"▶"})]}):E.jsx("button",{type:"button",className:"image-node__generate",onClick:O,disabled:N,title:o("node.generateTitle"),"aria-label":o("node.generateTitle"),children:o("node.generate")}),r.status==="ready"?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button",onClick:V,title:o("node.addChildTitle"),"aria-label":o("node.addChildTitle"),children:o("node.addChild")}),E.jsx("button",{type:"button",onClick:M,title:o("node.duplicateBranchTitle"),"aria-label":o("node.duplicateBranchTitle"),children:o("node.duplicateBranch")})]}):null,E.jsx("button",{type:"button",onClick:C,className:"image-node__del",title:o("node.deleteTitle"),"aria-label":o("node.deleteTitle"),children:"×"})]})]}),Nr.map(({id:z,position:X})=>E.jsx(Qe,{type:"source",id:`source-${z}`,position:X,className:`image-node__handle image-node__handle--source image-node__handle--${z}`},`source-${z}`))]})}const $g=T.memo(Pg);function Dg(){const{t:e}=Xn(),t=J(b=>b.graphNodes),n=J(b=>b.graphEdges),o=J(b=>b.nodeSelectionMode),r=J(b=>b.nodeBatchRunning),i=J(b=>b.nodeBatchStopping),s=J(b=>b.toggleNodeSelectionMode),a=J(b=>b.selectAllGraphNodes),l=J(b=>b.clearNodeSelection),c=J(b=>b.runNodeBatch),d=J(b=>b.cancelNodeBatch),u=J(b=>b.disconnectEdges),f=t.filter(b=>b.selected).map(b=>b.id),h=n.filter(b=>b.selected).map(b=>b.id),g=new Set(f),y=t.filter(b=>g.has(b.id)&&!ba(b)).length,x=_a(n,f).length,m=b=>{c(b)};return E.jsxs(Nt,{position:"top-center",className:"node-batch-bar nodrag",children:[E.jsx("button",{type:"button",onClick:s,"aria-pressed":o,children:e(o?"nodeBatch.selectionOn":"nodeBatch.selectionOff")}),E.jsx("button",{type:"button",onClick:a,disabled:t.length===0,children:e("nodeBatch.selectAll")}),h.length>0?E.jsx("button",{type:"button",className:"node-batch-bar__danger",onClick:()=>u(h),title:e("edge.disconnectTitle"),"aria-label":e("edge.disconnectTitle"),children:e("edge.disconnect")}):null,f.length>0?E.jsxs(E.Fragment,{children:[E.jsx("span",{className:"node-batch-bar__meta",children:e("nodeBatch.summary",{selected:f.length,missing:y,stale:x})}),E.jsx("button",{type:"button",onClick:()=>m("missing-only"),disabled:r,children:e("nodeBatch.generateMissing")}),E.jsx("button",{type:"button",onClick:()=>m("regenerate-all"),disabled:r,children:e("nodeBatch.regenerateSelected")}),r?E.jsx("button",{type:"button",onClick:d,disabled:i,children:e(i?"nodeBatch.stopping":"nodeBatch.stopRemaining")}):null,E.jsx("button",{type:"button",onClick:l,disabled:r,children:e("nodeBatch.clear")})]}):null]})}function Tg(){const{t:e}=Xn(),t=Ea(),n=J(_=>_.graphNodes),o=J(_=>_.graphEdges),r=J(_=>_.setGraphNodes),i=J(_=>_.setGraphEdges),s=J(_=>_.disconnectEdges),a=J(_=>_.addRootNode),l=J(_=>_.addChildNodeAt),c=J(_=>_.connectNodes),d=J(_=>_.deleteNodes),u=J(_=>_.nodeSelectionMode),f=J(_=>_.selectNodeGraph),h=J(_=>_.sessionLoading),{screenToFlowPosition:g}=cn(),y=T.useRef(null),x=T.useMemo(()=>({imageNode:$g}),[]),m=T.useCallback(_=>r(Hi(_,n)),[n,r]),b=T.useCallback(_=>{const I=_.filter($=>$.type==="remove").map($=>$.id);if(I.length>0){if(u)return;s(I);return}i(Li(_,o))},[s,o,u,i]),p=T.useCallback(_=>{_.source&&_.target&&c(_.source,_.target,_.sourceHandle,_.targetHandle)},[c]),w=T.useCallback((_,I)=>{if(I.isValid)return;const $=I.fromNode?.id;if(!$||I.toNode||I.toHandle)return;const O="touches"in _?_.changedTouches[0].clientX:_.clientX,A="touches"in _?_.changedTouches[0].clientY:_.clientY,R=g({x:O,y:A});l($,R,I.fromHandle?.id??null)},[l,g]),S=T.useCallback(_=>d(_.map(I=>I.id)),[d]),N=T.useCallback((_,I)=>{u&&(_.preventDefault(),f(I.id,_.metaKey||_.ctrlKey))},[u,f]);return E.jsxs("main",{className:"node-canvas",ref:y,children:[h&&E.jsx("div",{className:"node-canvas__loading",children:e("nodeCanvas.loading")}),n.length===0?E.jsx("button",{type:"button",className:"node-canvas__plus",onClick:()=>a(),children:e("nodeCanvas.addFirst")}):E.jsxs(E.Fragment,{children:[E.jsxs(Jh,{nodes:n,edges:o,onNodesChange:m,onEdgesChange:b,onConnect:p,onConnectEnd:w,onNodesDelete:S,onNodeClick:N,nodeTypes:x,connectionMode:He.Loose,connectionRadius:32,selectionOnDrag:u,multiSelectionKeyCode:u?null:void 0,panOnDrag:u?[2]:!0,fitView:!0,deleteKeyCode:u?null:["Delete","Backspace"],proOptions:{hideAttribution:!0},children:[E.jsx(Dg,{}),E.jsx(rg,{gap:24,color:"var(--canvas-grid)"}),E.jsx(dg,{className:"node-canvas__controls"}),!t&&E.jsx(Ng,{pannable:!0,zoomable:!0,maskColor:"var(--minimap-mask)",nodeColor:"var(--minimap-node-fill)",nodeStrokeColor:"var(--minimap-node-stroke)",style:{background:"var(--minimap-bg)",border:"1px solid var(--minimap-border)"}})]}),E.jsx("button",{type:"button",className:"node-canvas__add-root",onClick:()=>a(),title:e("nodeCanvas.addRootTitle"),children:"+"}),E.jsx("div",{className:"node-canvas__hint",children:e("nodeCanvas.hint")})]})]})}function zg(){return E.jsx(ls,{children:E.jsx(Tg,{})})}export{zg as NodeCanvas};
|