ima2-gen 3.12.1 → 3.12.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.
Files changed (42) hide show
  1. package/docs/migration/runtime-test-inventory.md +9 -1
  2. package/package.json +5 -4
  3. package/ui/dist/.vite/manifest.json +37 -37
  4. package/ui/dist/assets/AgentWorkspace-CW1x4uOl.js +3 -0
  5. package/ui/dist/assets/AssetGenWorkspace-B7tTK0Sx.css +1 -0
  6. package/ui/dist/assets/AssetGenWorkspace-BQkdilsH.js +2 -0
  7. package/ui/dist/assets/AssetsWorkspace-BdptASFf.css +1 -0
  8. package/ui/dist/assets/AssetsWorkspace-CYSkmYU-.js +1 -0
  9. package/ui/dist/assets/{CardNewsWorkspace-DGOw6UH_.js → CardNewsWorkspace-nBKX5TXr.js} +2 -2
  10. package/ui/dist/assets/GenerationRequestLogPanel-CWqbfNis.js +1 -0
  11. package/ui/dist/assets/{HomeWorkspace-CuJY4Jr6.js → HomeWorkspace-CxqIGhb9.js} +1 -1
  12. package/ui/dist/assets/KeyingPanel-CtGvO6-u.js +1 -0
  13. package/ui/dist/assets/NodeCanvas-m41ECrFJ.js +7 -0
  14. package/ui/dist/assets/{PromptBuilderPanel-Dt4gO_Rb.js → PromptBuilderPanel-ChOoMAVA.js} +1 -1
  15. package/ui/dist/assets/PromptImportDialog-8hDG8MeK.js +2 -0
  16. package/ui/dist/assets/{PromptImportDiscoverySection-Bmyt_NVl.js → PromptImportDiscoverySection-D2_TAuLm.js} +1 -1
  17. package/ui/dist/assets/{PromptImportFolderSection-DGqoTx-h.js → PromptImportFolderSection-qv0qhTwq.js} +1 -1
  18. package/ui/dist/assets/PromptLibraryPanel-BPOD61FZ.js +2 -0
  19. package/ui/dist/assets/SettingsWorkspace-BKgXN2l9.js +1 -0
  20. package/ui/dist/assets/SpriteRecipeWorkspace-D8gHgnt8.js +1 -0
  21. package/ui/dist/assets/index-Bzt4YWub.js +5 -0
  22. package/ui/dist/assets/index-DB9EfKr6.css +1 -0
  23. package/ui/dist/assets/index-DTEhasVd.js +30 -0
  24. package/ui/dist/assets/{pptxgen.es-Cza43xx3.js → pptxgen.es-BEVsR2-i.js} +1 -1
  25. package/ui/dist/assets/useAgentDialogFocus-Dyj_bA5Q.js +1 -0
  26. package/ui/dist/index.html +2 -2
  27. package/ui/dist/assets/AgentWorkspace-CKAWZD7U.js +0 -3
  28. package/ui/dist/assets/AssetGenWorkspace-Dkr80l12.css +0 -1
  29. package/ui/dist/assets/AssetGenWorkspace-wsNksO-Q.js +0 -2
  30. package/ui/dist/assets/AssetsWorkspace-Bgk5sj1a.js +0 -1
  31. package/ui/dist/assets/AssetsWorkspace-BkUjPPKU.css +0 -1
  32. package/ui/dist/assets/GenerationRequestLogPanel-BGatd8qE.js +0 -1
  33. package/ui/dist/assets/KeyingPanel-DYJN_oNF.js +0 -1
  34. package/ui/dist/assets/NodeCanvas-fil6cXN8.js +0 -7
  35. package/ui/dist/assets/PromptImportDialog-uyJdrdTs.js +0 -2
  36. package/ui/dist/assets/PromptLibraryPanel-BIi5_Rvq.js +0 -2
  37. package/ui/dist/assets/SettingsWorkspace-CVying69.js +0 -1
  38. package/ui/dist/assets/SpriteRecipeWorkspace-ztdiDwSf.js +0 -1
  39. package/ui/dist/assets/index-BPKt0DUF.css +0 -1
  40. package/ui/dist/assets/index-CumGbxai.js +0 -5
  41. package/ui/dist/assets/index-TU0_IXQH.js +0 -30
  42. package/ui/dist/assets/useAgentDialogFocus-D741d8_6.js +0 -1
@@ -0,0 +1,7 @@
1
+ import{r as Gr,g as qa,R as Ua,a as E,j as p,u as ce,b as Q,i as Vt,S as Ka,f as Qa,c as Ja,d as ec,n as tc,e as nc,w as oc,h as rc,k as qr,l as ic,m as sc,o as ac,p as cc,q as lc,s as Ct,t as uc}from"./index-DTEhasVd.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 dc={value:()=>{}};function an(){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 Ft(n)}function Ft(e){this._=e}function fc(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}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,o=fc(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=hc(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]=Ao(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ao(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 Ft(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 hc(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Ao(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=dc,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var zn="http://www.w3.org/1999/xhtml";const Po={svg:"http://www.w3.org/2000/svg",xhtml:zn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Po.hasOwnProperty(t)?{space:Po[t],local:e}:e}function pc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zn&&t.documentElement.namespaceURI===zn?t.createElement(e):t.createElementNS(n,e)}}function gc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ur(e){var t=cn(e);return(t.local?gc:pc)(t)}function mc(){}function oo(e){return e==null?mc:function(){return this.querySelector(e)}}function yc(e){typeof e!="function"&&(e=oo(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),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new de(o,this._parents)}function xc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wc(){return[]}function Kr(e){return e==null?wc:function(){return this.querySelectorAll(e)}}function vc(e){return function(){return xc(e.apply(this,arguments))}}function bc(e){typeof e=="function"?e=vc(e):e=Kr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new de(o,r)}function Qr(e){return function(){return this.matches(e)}}function Jr(e){return function(t){return t.matches(e)}}var _c=Array.prototype.find;function Sc(e){return function(){return _c.call(this.children,e)}}function Nc(){return this.firstElementChild}function Ec(e){return this.select(e==null?Nc:Sc(typeof e=="function"?e:Jr(e)))}var Cc=Array.prototype.filter;function Ic(){return Array.from(this.children)}function Mc(e){return function(){return Cc.call(this.children,e)}}function kc(e){return this.selectAll(e==null?Ic:Mc(typeof e=="function"?e:Jr(e)))}function Tc(e){typeof e!="function"&&(e=Qr(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]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new de(o,this._parents)}function ei(e){return new Array(e.length)}function Ac(){return new de(this._enter||this._groups.map(ei),this._parents)}function qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}qt.prototype={constructor:qt,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 Pc(e){return function(){return e}}function Dc(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new qt(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function $c(e,t,n,o,r,i,s){var a,c,l=new Map,u=t.length,f=i.length,d=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(d[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?r[a]=c:l.set(h,c));for(a=0;a<f;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(o[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new qt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(d[a])===c&&(r[a]=c)}function jc(e){return e.__data__}function Rc(e,t){if(!arguments.length)return Array.from(this,jc);var n=t?$c:Dc,o=this._parents,r=this._groups;typeof e!="function"&&(e=Pc(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=o[l],f=r[l],d=f.length,h=Hc(e.call(u,u&&u.__data__,l,o)),m=h.length,v=a[l]=new Array(m),x=s[l]=new Array(m),y=c[l]=new Array(d);n(u,f,v,x,y,h,t);for(var w=0,g=0,b,C;w<m;++w)if(b=v[w]){for(w>=g&&(g=w+1);!(C=x[g])&&++g<m;);b._next=C||null}}return s=new de(s,o),s._enter=a,s._exit=c,s}function Hc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Oc(){return new de(this._exit||this._groups.map(ei),this._parents)}function zc(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 Lc(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),c=0;c<s;++c)for(var l=n[c],u=o[c],f=l.length,d=a[c]=new Array(f),h,m=0;m<f;++m)(h=l[m]||u[m])&&(d[m]=h);for(;c<r;++c)a[c]=n[c];return new de(a,this._parents)}function Bc(){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 Vc(e){e||(e=Fc);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}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,c=r[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new de(r,this._parents).order()}function Fc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Yc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Xc(){return Array.from(this)}function Wc(){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 Zc(){let e=0;for(const t of this)++e;return e}function Gc(){return!this.node()}function qc(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 Uc(e){return function(){this.removeAttribute(e)}}function Kc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qc(e,t){return function(){this.setAttribute(e,t)}}function Jc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function el(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tl(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 nl(e,t){var n=cn(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?Kc:Uc:typeof t=="function"?n.local?tl:el:n.local?Jc:Qc)(n,t))}function ti(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ol(e){return function(){this.style.removeProperty(e)}}function rl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function il(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function sl(e,t,n){return arguments.length>1?this.each((t==null?ol:typeof t=="function"?il:rl)(e,t,n??"")):ot(this.node(),e)}function ot(e,t){return e.style.getPropertyValue(t)||ti(e).getComputedStyle(e,null).getPropertyValue(t)}function al(e){return function(){delete this[e]}}function cl(e,t){return function(){this[e]=t}}function ll(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function ul(e,t){return arguments.length>1?this.each((t==null?al:typeof t=="function"?ll:cl)(e,t)):this.node()[e]}function ni(e){return e.trim().split(/^|\s+/)}function ro(e){return e.classList||new oi(e)}function oi(e){this._node=e,this._names=ni(e.getAttribute("class")||"")}oi.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 ri(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function ii(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function dl(e){return function(){ri(this,e)}}function fl(e){return function(){ii(this,e)}}function hl(e,t){return function(){(t.apply(this,arguments)?ri:ii)(this,e)}}function pl(e,t){var n=ni(e+"");if(arguments.length<2){for(var o=ro(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?hl:t?dl:fl)(n,t))}function gl(){this.textContent=""}function ml(e){return function(){this.textContent=e}}function yl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function xl(e){return arguments.length?this.each(e==null?gl:(typeof e=="function"?yl:ml)(e)):this.node().textContent}function wl(){this.innerHTML=""}function vl(e){return function(){this.innerHTML=e}}function bl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function _l(e){return arguments.length?this.each(e==null?wl:(typeof e=="function"?bl:vl)(e)):this.node().innerHTML}function Sl(){this.nextSibling&&this.parentNode.appendChild(this)}function Nl(){return this.each(Sl)}function El(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Cl(){return this.each(El)}function Il(e){var t=typeof e=="function"?e:Ur(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ml(){return null}function kl(e,t){var n=typeof e=="function"?e:Ur(e),o=t==null?Ml:typeof t=="function"?t:oo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Tl(){var e=this.parentNode;e&&e.removeChild(this)}function Al(){return this.each(Tl)}function Pl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Dl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $l(e){return this.select(e?Dl:Pl)}function jl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Rl(e){return function(t){e.call(this,t,this.__data__)}}function Hl(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 Ol(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 zl(e,t,n){return function(){var o=this.__on,r,i=Rl(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 Ll(e,t,n){var o=Hl(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?zl:Ol,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function si(e,t,n){var o=ti(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 Bl(e,t){return function(){return si(this,e,t)}}function Vl(e,t){return function(){return si(this,e,t.apply(this,arguments))}}function Fl(e,t){return this.each((typeof t=="function"?Vl:Bl)(e,t))}function*Yl(){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 ai=[null];function de(e,t){this._groups=e,this._parents=t}function It(){return new de([[document.documentElement]],ai)}function Xl(){return this}de.prototype=It.prototype={constructor:de,select:yc,selectAll:bc,selectChild:Ec,selectChildren:kc,filter:Tc,data:Rc,enter:Ac,exit:Oc,join:zc,merge:Lc,selection:Xl,order:Bc,sort:Vc,call:Yc,nodes:Xc,node:Wc,size:Zc,empty:Gc,each:qc,attr:nl,style:sl,property:ul,classed:pl,text:xl,html:_l,raise:Nl,lower:Cl,append:Il,insert:kl,remove:Al,clone:$l,datum:jl,on:Ll,dispatch:Fl,[Symbol.iterator]:Yl};function ue(e){return typeof e=="string"?new de([[document.querySelector(e)]],[document.documentElement]):new de([[e]],ai)}function Wl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=Wl(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 Zl={passive:!1},yt={capture:!0,passive:!1};function Sn(e){e.stopImmediatePropagation()}function tt(e){e.preventDefault(),e.stopImmediatePropagation()}function ci(e){var t=e.document.documentElement,n=ue(e).on("dragstart.drag",tt,yt);"onselectstart"in t?n.on("selectstart.drag",tt,yt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function li(e,t){var n=e.document.documentElement,o=ue(e).on("dragstart.drag",null);t&&(o.on("click.drag",tt,yt),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 Dt=e=>()=>e;function Ln(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Ln.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Gl(e){return!e.ctrlKey&&!e.button}function ql(){return this.parentNode}function Ul(e,t){return t??{x:e.x,y:e.y}}function Kl(){return navigator.maxTouchPoints||"ontouchstart"in this}function ui(){var e=Gl,t=ql,n=Ul,o=Kl,r={},i=an("start","drag","end"),s=0,a,c,l,u,f=0;function d(b){b.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",y,Zl).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(b,C){if(!(u||!e.call(this,b,C))){var S=g(this,t.call(this,b,C),b,C,"mouse");S&&(ue(b.view).on("mousemove.drag",m,yt).on("mouseup.drag",v,yt),ci(b.view),Sn(b),l=!1,a=b.clientX,c=b.clientY,S("start",b))}}function m(b){if(tt(b),!l){var C=b.clientX-a,S=b.clientY-c;l=C*C+S*S>f}r.mouse("drag",b)}function v(b){ue(b.view).on("mousemove.drag mouseup.drag",null),li(b.view,l),tt(b),r.mouse("end",b)}function x(b,C){if(e.call(this,b,C)){var S=b.changedTouches,N=t.call(this,b,C),k=S.length,P,L;for(P=0;P<k;++P)(L=g(this,N,b,C,S[P].identifier,S[P]))&&(Sn(b),L("start",b,S[P]))}}function y(b){var C=b.changedTouches,S=C.length,N,k;for(N=0;N<S;++N)(k=r[C[N].identifier])&&(tt(b),k("drag",b,C[N]))}function w(b){var C=b.changedTouches,S=C.length,N,k;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),N=0;N<S;++N)(k=r[C[N].identifier])&&(Sn(b),k("end",b,C[N]))}function g(b,C,S,N,k,P){var L=i.copy(),T=he(P||S,C),O,H,_;if((_=n.call(b,new Ln("beforestart",{sourceEvent:S,target:d,identifier:k,active:s,x:T[0],y:T[1],dx:0,dy:0,dispatch:L}),N))!=null)return O=_.x-T[0]||0,H=_.y-T[1]||0,function I(M,A,$){var j=T,z;switch(M){case"start":r[k]=I,z=s++;break;case"end":delete r[k],--s;case"drag":T=he($||A,C),z=s;break}L.call(M,b,new Ln(M,{sourceEvent:A,subject:_,target:d,identifier:k,active:z,x:T[0]+O,y:T[1]+H,dx:T[0]-j[0],dy:T[1]-j[1],dispatch:L}),N)}}return d.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Dt(!!b),d):e},d.container=function(b){return arguments.length?(t=typeof b=="function"?b:Dt(b),d):t},d.subject=function(b){return arguments.length?(n=typeof b=="function"?b:Dt(b),d):n},d.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:Dt(!!b),d):o},d.on=function(){var b=i.on.apply(i,arguments);return b===i?d:b},d.clickDistance=function(b){return arguments.length?(f=(b=+b)*b,d):Math.sqrt(f)},d}function io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function di(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Mt(){}var xt=.7,Ut=1/xt,nt="\\s*([+-]?\\d+)\\s*",wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Se="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ql=/^#([0-9a-f]{3,8})$/,Jl=new RegExp(`^rgb\\(${nt},${nt},${nt}\\)$`),eu=new RegExp(`^rgb\\(${Se},${Se},${Se}\\)$`),tu=new RegExp(`^rgba\\(${nt},${nt},${nt},${wt}\\)$`),nu=new RegExp(`^rgba\\(${Se},${Se},${Se},${wt}\\)$`),ou=new RegExp(`^hsl\\(${wt},${Se},${Se}\\)$`),ru=new RegExp(`^hsla\\(${wt},${Se},${Se},${wt}\\)$`),Do={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};io(Mt,Xe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$o,formatHex:$o,formatHex8:iu,formatHsl:su,formatRgb:jo,toString:jo});function $o(){return this.rgb().formatHex()}function iu(){return this.rgb().formatHex8()}function su(){return fi(this).formatHsl()}function jo(){return this.rgb().formatRgb()}function Xe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ql.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ro(t):n===3?new le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$t(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$t(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=Jl.exec(e))?new le(t[1],t[2],t[3],1):(t=eu.exec(e))?new le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tu.exec(e))?$t(t[1],t[2],t[3],t[4]):(t=nu.exec(e))?$t(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ou.exec(e))?zo(t[1],t[2]/100,t[3]/100,1):(t=ru.exec(e))?zo(t[1],t[2]/100,t[3]/100,t[4]):Do.hasOwnProperty(e)?Ro(Do[e]):e==="transparent"?new le(NaN,NaN,NaN,0):null}function Ro(e){return new le(e>>16&255,e>>8&255,e&255,1)}function $t(e,t,n,o){return o<=0&&(e=t=n=NaN),new le(e,t,n,o)}function au(e){return e instanceof Mt||(e=Xe(e)),e?(e=e.rgb(),new le(e.r,e.g,e.b,e.opacity)):new le}function Bn(e,t,n,o){return arguments.length===1?au(e):new le(e,t,n,o??1)}function le(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}io(le,Bn,di(Mt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new le(Fe(this.r),Fe(this.g),Fe(this.b),Kt(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:Ho,formatHex:Ho,formatHex8:cu,formatRgb:Oo,toString:Oo}));function Ho(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function cu(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function Oo(){const e=Kt(this.opacity);return`${e===1?"rgb(":"rgba("}${Fe(this.r)}, ${Fe(this.g)}, ${Fe(this.b)}${e===1?")":`, ${e})`}`}function Kt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Fe(e),(e<16?"0":"")+e.toString(16)}function zo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new pe(e,t,n,o)}function fi(e){if(e instanceof pe)return new pe(e.h,e.s,e.l,e.opacity);if(e instanceof Mt||(e=Xe(e)),!e)return new pe;if(e instanceof pe)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,c=(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/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new pe(s,a,c,e.opacity)}function lu(e,t,n,o){return arguments.length===1?fi(e):new pe(e,t,n,o??1)}function pe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}io(pe,lu,di(Mt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new pe(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 le(Nn(e>=240?e-240:e+120,r,o),Nn(e,r,o),Nn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new pe(Lo(this.h),jt(this.s),jt(this.l),Kt(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=Kt(this.opacity);return`${e===1?"hsl(":"hsla("}${Lo(this.h)}, ${jt(this.s)*100}%, ${jt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Lo(e){return e=(e||0)%360,e<0?e+360:e}function jt(e){return Math.max(0,Math.min(1,e||0))}function Nn(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 so=e=>()=>e;function uu(e,t){return function(n){return e+n*t}}function du(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 fu(e){return(e=+e)==1?hi:function(t,n){return n-t?du(t,n,e):so(isNaN(t)?n:t)}}function hi(e,t){var n=t-e;return n?uu(e,n):so(isNaN(e)?t:e)}const Qt=(function e(t){var n=fu(t);function o(r,i){var s=n((r=Bn(r)).r,(i=Bn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=hi(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return o.gamma=e,o})(1);function hu(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 pu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function gu(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]=pt(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 mu(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function _e(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function yu(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]=pt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Vn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,En=new RegExp(Vn.source,"g");function xu(e){return function(){return e}}function wu(e){return function(t){return e(t)+""}}function pi(e,t){var n=Vn.lastIndex=En.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=Vn.exec(e))&&(r=En.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,c.push({i:s,x:_e(o,r)})),n=En.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?wu(c[0].x):xu(t):(t=c.length,function(l){for(var u=0,f;u<t;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}function pt(e,t){var n=typeof t,o;return t==null||n==="boolean"?so(t):(n==="number"?_e:n==="string"?(o=Xe(t))?(t=o,Qt):pi:t instanceof Xe?Qt:t instanceof Date?mu:pu(t)?hu:Array.isArray(t)?gu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?yu:_e)(e,t)}var Bo=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gi(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Bo,skewX:Math.atan(c)*Bo,scaleX:s,scaleY:a}}var Rt;function vu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:gi(t.a,t.b,t.c,t.d,t.e,t.f)}function bu(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Fn:(e=e.matrix,gi(e.a,e.b,e.c,e.d,e.e,e.f))}function mi(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,u,f,d,h,m){if(l!==f||u!==d){var v=h.push("translate(",null,t,null,n);m.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function s(l,u,f,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:_e(l,u)})):u&&f.push(r(f)+"rotate("+u+o)}function a(l,u,f,d){l!==u?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:_e(l,u)}):u&&f.push(r(f)+"skewX("+u+o)}function c(l,u,f,d,h,m){if(l!==f||u!==d){var v=h.push(r(h)+"scale(",null,",",null,")");m.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f!==1||d!==1)&&h.push(r(h)+"scale("+f+","+d+")")}return function(l,u){var f=[],d=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,f,d),s(l.rotate,u.rotate,f,d),a(l.skewX,u.skewX,f,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,d),l=u=null,function(h){for(var m=-1,v=d.length,x;++m<v;)f[(x=d[m]).i]=x.x(h);return f.join("")}}}var _u=mi(vu,"px, ","px)","deg)"),Su=mi(bu,", ",")",")"),Nu=1e-12;function Vo(e){return((e=Math.exp(e))+1/e)/2}function Eu(e){return((e=Math.exp(e))-1/e)/2}function Cu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yt=(function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],f=s[1],d=s[2],h=u-a,m=f-c,v=h*h+m*m,x,y;if(v<Nu)y=Math.log(d/l)/t,x=function(N){return[a+N*h,c+N*m,l*Math.exp(t*N*y)]};else{var w=Math.sqrt(v),g=(d*d-l*l+o*v)/(2*l*n*w),b=(d*d-l*l-o*v)/(2*d*n*w),C=Math.log(Math.sqrt(g*g+1)-g),S=Math.log(Math.sqrt(b*b+1)-b);y=(S-C)/t,x=function(N){var k=N*y,P=Vo(C),L=l/(n*w)*(P*Cu(t*k+C)-Eu(C));return[a+L*h,c+L*m,l*P/Vo(t*k+C)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r})(Math.SQRT2,2,4);var rt=0,ft=0,lt=0,yi=1e3,Jt,ht,en=0,We=0,ln=0,vt=typeof performance=="object"&&performance.now?performance:Date,xi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return We||(xi(Iu),We=vt.now()+ln)}function Iu(){We=0}function tn(){this._call=this._time=this._next=null}tn.prototype=wi.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ao():+n)+(t==null?0:+t),!this._next&&ht!==this&&(ht?ht._next=this:Jt=this,ht=this),this._call=e,this._time=n,Yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yn())}};function wi(e,t,n){var o=new tn;return o.restart(e,t,n),o}function Mu(){ao(),++rt;for(var e=Jt,t;e;)(t=We-e._time)>=0&&e._call.call(void 0,t),e=e._next;--rt}function Fo(){We=(en=vt.now())+ln,rt=ft=0;try{Mu()}finally{rt=0,Tu(),We=0}}function ku(){var e=vt.now(),t=e-en;t>yi&&(ln-=t,en=e)}function Tu(){for(var e,t=Jt,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:Jt=n);ht=e,Yn(o)}function Yn(e){if(!rt){ft&&(ft=clearTimeout(ft));var t=e-We;t>24?(e<1/0&&(ft=setTimeout(Fo,e-vt.now()-ln)),lt&&(lt=clearInterval(lt))):(lt||(en=vt.now(),lt=setInterval(ku,yi)),rt=1,xi(Fo))}}function Yo(e,t,n){var o=new tn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Au=an("start","end","cancel","interrupt"),Pu=[],vi=0,Xo=1,Xn=2,Xt=3,Wo=4,Wn=5,Wt=6;function un(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Du(e,n,{name:t,index:o,group:r,on:Au,tween:Pu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vi})}function co(e,t){var n=xe(e,t);if(n.state>vi)throw new Error("too late; already scheduled");return n}function Ne(e,t){var n=xe(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Du(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=wi(i,0,n.time);function i(l){n.state=Xo,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,f,d,h;if(n.state!==Xo)return c();for(u in o)if(h=o[u],h.name===n.name){if(h.state===Xt)return Yo(s);h.state===Wo?(h.state=Wt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[u]):+u<t&&(h.state=Wt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[u])}if(Yo(function(){n.state===Xt&&(n.state=Wo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Xn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xn){for(n.state=Xt,r=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=h);r.length=f+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wn,1),f=-1,d=r.length;++f<d;)r[f].call(e,u);n.state===Wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wt,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Zt(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>Xn&&o.state<Wn,o.state=Wt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function $u(e){return this.each(function(){Zt(this,e)})}function ju(e,t){var n,o;return function(){var r=Ne(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 Ru(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Ne(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function Hu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=xe(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?ju:Ru)(n,e,t))}function lo(e,t,n){var o=e._id;return e.each(function(){var r=Ne(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return xe(r,o).value[t]}}function bi(e,t){var n;return(typeof t=="number"?_e:t instanceof Xe?Qt:(n=Xe(t))?(t=n,Qt):pi)(e,t)}function Ou(e){return function(){this.removeAttribute(e)}}function zu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Lu(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 Bu(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 Vu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Fu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Yu(e,t){var n=cn(e),o=n==="transform"?Su:bi;return this.attrTween(e,typeof t=="function"?(n.local?Fu:Vu)(n,o,lo(this,"attr."+e,t)):t==null?(n.local?zu:Ou)(n):(n.local?Bu:Lu)(n,o,t))}function Xu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Wu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Zu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Wu(e,i)),n}return r._value=t,r}function Gu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Xu(e,i)),n}return r._value=t,r}function qu(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=cn(e);return this.tween(n,(o.local?Zu:Gu)(o,t))}function Uu(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function Ku(e,t){return t=+t,function(){co(this,e).delay=t}}function Qu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Uu:Ku)(t,e)):xe(this.node(),t).delay}function Ju(e,t){return function(){Ne(this,e).duration=+t.apply(this,arguments)}}function ed(e,t){return t=+t,function(){Ne(this,e).duration=t}}function td(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ju:ed)(t,e)):xe(this.node(),t).duration}function nd(e,t){if(typeof t!="function")throw new Error;return function(){Ne(this,e).ease=t}}function od(e){var t=this._id;return arguments.length?this.each(nd(t,e)):xe(this.node(),t).ease}function rd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ne(this,e).ease=n}}function id(e){if(typeof e!="function")throw new Error;return this.each(rd(this._id,e))}function sd(e){typeof e!="function"&&(e=Qr(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]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Pe(o,this._parents,this._name,this._id)}function ad(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 c=t[a],l=n[a],u=c.length,f=s[a]=new Array(u),d,h=0;h<u;++h)(d=c[h]||l[h])&&(f[h]=d);for(;a<o;++a)s[a]=t[a];return new Pe(s,this._parents,this._name,this._id)}function cd(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 ld(e,t,n){var o,r,i=cd(t)?co:Ne;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function ud(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(ld(n,e,t))}function dd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fd(){return this.on("end.remove",dd(this._id))}function hd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oo(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),u,f,d=0;d<c;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),l[d]=f,un(l[d],t,n,d,l,xe(u,n)));return new Pe(i,this._parents,t,n)}function pd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Kr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var d=e.call(u,u.__data__,f,c),h,m=xe(u,n),v=0,x=d.length;v<x;++v)(h=d[v])&&un(h,t,n,v,d,m);i.push(d),s.push(u)}return new Pe(i,s,t,n)}var gd=It.prototype.constructor;function md(){return new gd(this._groups,this._parents)}function yd(e,t){var n,o,r;return function(){var i=ot(this,e),s=(this.style.removeProperty(e),ot(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function _i(e){return function(){this.style.removeProperty(e)}}function xd(e,t,n){var o,r=n+"",i;return function(){var s=ot(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function wd(e,t,n){var o,r,i;return function(){var s=ot(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),ot(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function vd(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=Ne(this,e),l=c.on,u=c.value[i]==null?a||(a=_i(t)):void 0;(l!==n||r!==u)&&(o=(n=l).copy()).on(s,r=u),c.on=o}}function bd(e,t,n){var o=(e+="")=="transform"?_u:bi;return t==null?this.styleTween(e,yd(e,o)).on("end.style."+e,_i(e)):typeof t=="function"?this.styleTween(e,wd(e,o,lo(this,"style."+e,t))).each(vd(this._id,e)):this.styleTween(e,xd(e,o,t),n).on("end.style."+e,null)}function _d(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Sd(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&_d(e,s,n)),o}return i._value=t,i}function Nd(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,Sd(e,t,n??""))}function Ed(e){return function(){this.textContent=e}}function Cd(e){return function(){var t=e(this);this.textContent=t??""}}function Id(e){return this.tween("text",typeof e=="function"?Cd(lo(this,"text",e)):Ed(e==null?"":e+""))}function Md(e){return function(t){this.textContent=e.call(this,t)}}function kd(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Md(r)),t}return o._value=e,o}function Td(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,kd(e))}function Ad(){for(var e=this._name,t=this._id,n=Si(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=xe(c,t);un(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Pe(o,this._parents,e,n)}function Pd(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=Ne(this,o),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var Dd=0;function Pe(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Si(){return++Dd}var ke=It.prototype;Pe.prototype={constructor:Pe,select:hd,selectAll:pd,selectChild:ke.selectChild,selectChildren:ke.selectChildren,filter:sd,merge:ad,selection:md,transition:Ad,call:ke.call,nodes:ke.nodes,node:ke.node,size:ke.size,empty:ke.empty,each:ke.each,on:ud,attr:Yu,attrTween:qu,style:bd,styleTween:Nd,text:Id,textTween:Td,remove:fd,tween:Hu,delay:Qu,duration:td,ease:od,easeVarying:id,end:Pd,[Symbol.iterator]:ke[Symbol.iterator]};function $d(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jd={time:null,delay:0,duration:250,ease:$d};function Rd(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 Hd(e){var t,n;e instanceof Pe?(t=e._id,e=e._name):(t=Si(),(n=jd).time=ao(),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,c,l=0;l<a;++l)(c=s[l])&&un(c,e,t,l,s,n||Rd(c,t));return new Pe(o,this._parents,e,t)}It.prototype.interrupt=$u;It.prototype.transition=Hd;const Ht=e=>()=>e;function Od(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 Te(e,t,n){this.k=e,this.x=t,this.y=n}Te.prototype={constructor:Te,scale:function(e){return e===1?this:new Te(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Te(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 dn=new Te(1,0,0);Ni.prototype=Te.prototype;function Ni(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}function Cn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function zd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ld(){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 Zo(){return this.__zoom||dn}function Bd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Vd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fd(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 Ei(){var e=zd,t=Ld,n=Fd,o=Bd,r=Vd,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Yt,l=an("start","zoom","end"),u,f,d,h=500,m=150,v=0,x=10;function y(_){_.property("__zoom",Zo).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",L).filter(r).on("touchstart.zoom",T).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,I,M,A){var $=_.selection?_.selection():_;$.property("__zoom",Zo),_!==$?C(_,I,M,A):$.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},y.scaleBy=function(_,I,M,A){y.scaleTo(_,function(){var $=this.__zoom.k,j=typeof I=="function"?I.apply(this,arguments):I;return $*j},M,A)},y.scaleTo=function(_,I,M,A){y.transform(_,function(){var $=t.apply(this,arguments),j=this.__zoom,z=M==null?b($):typeof M=="function"?M.apply(this,arguments):M,V=j.invert(z),B=typeof I=="function"?I.apply(this,arguments):I;return n(g(w(j,B),z,V),$,s)},M,A)},y.translateBy=function(_,I,M,A){y.transform(_,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),s)},null,A)},y.translateTo=function(_,I,M,A,$){y.transform(_,function(){var j=t.apply(this,arguments),z=this.__zoom,V=A==null?b(j):typeof A=="function"?A.apply(this,arguments):A;return n(dn.translate(V[0],V[1]).scale(z.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof M=="function"?-M.apply(this,arguments):-M),j,s)},A,$)};function w(_,I){return I=Math.max(i[0],Math.min(i[1],I)),I===_.k?_:new Te(I,_.x,_.y)}function g(_,I,M){var A=I[0]-M[0]*_.k,$=I[1]-M[1]*_.k;return A===_.x&&$===_.y?_:new Te(_.k,A,$)}function b(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function C(_,I,M,A){_.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var $=this,j=arguments,z=S($,j).event(A),V=t.apply($,j),B=M==null?b(V):typeof M=="function"?M.apply($,j):M,W=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Y=$.__zoom,G=typeof I=="function"?I.apply($,j):I,J=c(Y.invert(B).concat(W/Y.k),G.invert(B).concat(W/G.k));return function(R){if(R===1)R=G;else{var D=J(R),F=W/D[2];R=new Te(F,B[0]-D[0]*F,B[1]-D[1]*F)}z.zoom(null,R)}})}function S(_,I,M){return!M&&_.__zooming||new N(_,I)}function N(_,I){this.that=_,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,I),this.taps=0}N.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,I){return this.mouse&&_!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var I=ue(this.that).datum();l.call(_,this.that,new Od(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),I)}};function k(_,...I){if(!e.apply(this,arguments))return;var M=S(this,I).event(_),A=this.__zoom,$=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,o.apply(this,arguments)))),j=he(_);if(M.wheel)(M.mouse[0][0]!==j[0]||M.mouse[0][1]!==j[1])&&(M.mouse[1]=A.invert(M.mouse[0]=j)),clearTimeout(M.wheel);else{if(A.k===$)return;M.mouse=[j,A.invert(j)],Zt(this),M.start()}ut(_),M.wheel=setTimeout(z,m),M.zoom("mouse",n(g(w(A,$),M.mouse[0],M.mouse[1]),M.extent,s));function z(){M.wheel=null,M.end()}}function P(_,...I){if(d||!e.apply(this,arguments))return;var M=_.currentTarget,A=S(this,I,!0).event(_),$=ue(_.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",W,!0),j=he(_,M),z=_.clientX,V=_.clientY;ci(_.view),Cn(_),A.mouse=[j,this.__zoom.invert(j)],Zt(this),A.start();function B(Y){if(ut(Y),!A.moved){var G=Y.clientX-z,J=Y.clientY-V;A.moved=G*G+J*J>v}A.event(Y).zoom("mouse",n(g(A.that.__zoom,A.mouse[0]=he(Y,M),A.mouse[1]),A.extent,s))}function W(Y){$.on("mousemove.zoom mouseup.zoom",null),li(Y.view,A.moved),ut(Y),A.event(Y).end()}}function L(_,...I){if(e.apply(this,arguments)){var M=this.__zoom,A=he(_.changedTouches?_.changedTouches[0]:_,this),$=M.invert(A),j=M.k*(_.shiftKey?.5:2),z=n(g(w(M,j),A,$),t.apply(this,I),s);ut(_),a>0?ue(this).transition().duration(a).call(C,z,A,_):ue(this).call(y.transform,z,A,_)}}function T(_,...I){if(e.apply(this,arguments)){var M=_.touches,A=M.length,$=S(this,I,_.changedTouches.length===A).event(_),j,z,V,B;for(Cn(_),z=0;z<A;++z)V=M[z],B=he(V,this),B=[B,this.__zoom.invert(B),V.identifier],$.touch0?!$.touch1&&$.touch0[2]!==B[2]&&($.touch1=B,$.taps=0):($.touch0=B,j=!0,$.taps=1+!!u);u&&(u=clearTimeout(u)),j&&($.taps<2&&(f=B[0],u=setTimeout(function(){u=null},h)),Zt(this),$.start())}}function O(_,...I){if(this.__zooming){var M=S(this,I).event(_),A=_.changedTouches,$=A.length,j,z,V,B;for(ut(_),j=0;j<$;++j)z=A[j],V=he(z,this),M.touch0&&M.touch0[2]===z.identifier?M.touch0[0]=V:M.touch1&&M.touch1[2]===z.identifier&&(M.touch1[0]=V);if(z=M.that.__zoom,M.touch1){var W=M.touch0[0],Y=M.touch0[1],G=M.touch1[0],J=M.touch1[1],R=(R=G[0]-W[0])*R+(R=G[1]-W[1])*R,D=(D=J[0]-Y[0])*D+(D=J[1]-Y[1])*D;z=w(z,Math.sqrt(R/D)),V=[(W[0]+G[0])/2,(W[1]+G[1])/2],B=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(M.touch0)V=M.touch0[0],B=M.touch0[1];else return;M.zoom("touch",n(g(z,V,B),M.extent,s))}}function H(_,...I){if(this.__zooming){var M=S(this,I).event(_),A=_.changedTouches,$=A.length,j,z;for(Cn(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),j=0;j<$;++j)z=A[j],M.touch0&&M.touch0[2]===z.identifier?delete M.touch0:M.touch1&&M.touch1[2]===z.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(z=he(z,this),Math.hypot(f[0]-z[0],f[1]-z[1])<x)){var V=ue(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:Ht(+_),y):o},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Ht(!!_),y):e},y.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Ht(!!_),y):r},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:Ht([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),y):t},y.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],y):[i[0],i[1]]},y.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(_){return arguments.length?(n=_,y):n},y.duration=function(_){return arguments.length?(a=+_,y):a},y.interpolate=function(_){return arguments.length?(c=_,y):c},y.on=function(){var _=l.on.apply(l,arguments);return _===l?y:_},y.clickDistance=function(_){return arguments.length?(v=(_=+_)*_,y):Math.sqrt(v)},y.tapDistance=function(_){return arguments.length?(x=+_,y):x},y}const ye={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle: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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},bt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ci=["Enter"," ","Escape"],Ii={"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 Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var Ye;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ye||(Ye={}));var _t;(function(e){e.Partial="partial",e.Full="full"})(_t||(_t={}));const Mi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Re;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Re||(Re={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Go={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function ki(e){return e===null?null:e?"valid":"invalid"}const Ti=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Yd=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uo=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),kt=(e,t=[0,0])=>{const{width:n,height:o}=we(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Xd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const o=e.reduce((r,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):uo(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,fn(r,on(a,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?hn(o):{x:0,y:0,width:0,height:0}},Tt=(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=fn(n,on(r)),o=!0)}),o?hn(n):{x:0,y:0,width:0,height:0}},fo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/r,c=(t.y-o)/r,l=t.width/r,u=t.height/r,f=[];for(const d of e.values()){const{measured:h,selectable:m=!0,hidden:v=!1}=d;if(s&&!m||v)continue;const x=h.width??d.width??d.initialWidth??0,y=h.height??d.height??d.initialHeight??0,{x:w,y:g}=d.internals.positionAbsolute,b=$i(a,c,l,u,w,g,x,y),C=x*y,S=i&&b>0;(!d.internals.handleBounds||S||b>=C||d.dragging)&&f.push(d)}return f},Wd=(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 Zd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:a}=we(r);i=s>0&&a>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function Gd({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const a=Zd(e,s),c=Tt(a),l=po(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!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:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const{width:h,height:m}=we(a);h&&m&&(f=[[c,l],[c+h,l+m]])}else a&&qe(s.extent)&&(f=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const d=qe(f)?Ge(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:d.x-c+(s.measured.width??0)*u[0],y:d.y-l+(s.measured.height??0)*u[1]},positionAbsolute:d}}async function qd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),m=!h&&d.parentId&&s.find(v=>v.id===d.parentId);(h||m)&&s.push(d)}const a=new Set(t.map(d=>d.id)),c=o.filter(d=>d.deletable!==!1),u=Wd(s,c);for(const d of c)a.has(d.id)&&!u.find(m=>m.id===d.id)&&u.push(d);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const it=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ge=(e={x:0,y:0},t,n)=>({x:it(e.x,t[0][0],t[1][0]-(n?.width??0)),y:it(e.y,t[0][1],t[1][1]-(n?.height??0))});function Pi(e,t,n){const{width:o,height:r}=we(n),{x:i,y:s}=n.internals.positionAbsolute;return Ge(e,[[i,s],[i+o,s+r]],t)}const qo=(e,t,n)=>e<t?it(Math.abs(e-t),1,t)/t:e>n?-it(Math.abs(e-n),1,t)/t:0,ho=(e,t,n=15,o=40)=>{const r=qo(e.x,o,t.width-o)*n,i=qo(e.y,o,t.height-o)*n;return[r,i]},fn=(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)}),Zn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),hn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),St=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:kt(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}},on=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:kt(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)}},Di=(e,t)=>hn(fn(Zn(e),Zn(t))),$i=(e,t,n,o,r,i,s,a)=>{const c=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,i+a)-Math.max(t,i));return Math.ceil(c*l)},rn=(e,t)=>$i(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Uo=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ji=(e,t)=>(n,o)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?At(a,s):a},st=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Qe(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Ud(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Qe(e,n),r=Qe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Qe(e.top??e.y??0,n),r=Qe(e.bottom??e.y??0,n),i=Qe(e.left??e.x??0,t),s=Qe(e.right??e.x??0,t);return{top: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 Kd(e,t,n,o,r,i){const{x:s,y:a}=st(e,[t,n,o]),{x:c,y:l}=st({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-c,f=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(f)}}const po=(e,t,n,o,r,i)=>{const s=Ud(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=it(l,o,r),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*u,m=n/2-d*u,v=Kd(e,h,m,u,t,n),x={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:m-x.top+x.bottom,zoom:u}},Nt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function qe(e){return e!=null&&e!=="parent"}function we(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ri(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Hi(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 Ko(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Qd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Jd(e){return{...Ii,...e||{}}}function gt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=me(e),a=Pt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const go=e=>({width:e.offsetWidth,height:e.offsetHeight}),Oi=e=>e?.getRootNode?.()||window?.document,ef=["INPUT","SELECT","TEXTAREA"];function zi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:ef.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Li=e=>"clientX"in e,me=(e,t)=>{const n=Li(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)}},Qo=(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,...go(s)}})};function Bi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,u=Math.abs(c-e),f=Math.abs(l-t);return[c,l,u,f]}function Ot(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Ot(t-o,i),n];case X.Right:return[t+Ot(o-t,i),n];case X.Top:return[t,n-Ot(n-r,i)];case X.Bottom:return[t,n+Ot(r-n,i)]}}function Vi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Jo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,u]=Jo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,h,m]=Bi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${o},${r}`,f,d,h,m]}function Fi({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 tf({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 nf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=fn(on(e),on(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 rn(s,hn(i))>0}const of=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,rf=(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)),sf=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",ye.error006()),t;const o=n.getEdgeId||of;let r;return Ti(e)?r={...e}:r={...e,id:o(e)},rf(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Yi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Fi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const er={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},af=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.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},tr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cf({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=er[t],c=er[o],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},f=af({source:l,sourcePosition:t,target:u}),d=f.x!==0?"x":"y",h=f[d];let m=[],v,x;const y={x:0,y:0},w={x:0,y:0},[,,g,b]=Fi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*c[d]===-1){d==="x"?(v=r.x??l.x+(u.x-l.x)*s,x=r.y??(l.y+u.y)/2):(v=r.x??(l.x+u.x)/2,x=r.y??l.y+(u.y-l.y)*s);const k=[{x:v,y:l.y},{x:v,y:u.y}],P=[{x:l.x,y:x},{x:u.x,y:x}];a[d]===h?m=d==="x"?k:P:m=d==="x"?P:k}else{const k=[{x:l.x,y:u.y}],P=[{x:u.x,y:l.y}];if(d==="x"?m=a.x===h?P:k:m=a.y===h?k:P,t===o){const _=Math.abs(e[d]-n[d]);if(_<=i){const I=Math.min(i-1,i-_);a[d]===h?y[d]=(l[d]>e[d]?-1:1)*I:w[d]=(u[d]>n[d]?-1:1)*I}}if(t!==o){const _=d==="x"?"y":"x",I=a[d]===c[_],M=l[_]>u[_],A=l[_]<u[_];(a[d]===1&&(!I&&M||I&&A)||a[d]!==1&&(!I&&A||I&&M))&&(m=d==="x"?k:P)}const L={x:l.x+y.x,y:l.y+y.y},T={x:u.x+w.x,y:u.y+w.y},O=Math.max(Math.abs(L.x-m[0].x),Math.abs(T.x-m[0].x)),H=Math.max(Math.abs(L.y-m[0].y),Math.abs(T.y-m[0].y));O>=H?(v=(L.x+T.x)/2,x=m[0].y):(v=m[0].x,x=(L.y+T.y)/2)}const C={x:l.x+y.x,y:l.y+y.y},S={x:u.x+w.x,y:u.y+w.y};return[[e,...C.x!==m[0].x||C.y!==m[0].y?[C]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],v,x,g,b]}function lf(e,t,n,o){const r=Math.min(tr(e,t)/2,tr(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 l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Gn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[f,d,h,m,v]=cf({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let x=`M${f[0].x} ${f[0].y}`;for(let y=1;y<f.length-1;y++)x+=lf(f[y-1],f[y],f[y+1],s);return x+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[x,d,h,m,v]}function nr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function uf(e){const{sourceNode:t,targetNode:n}=e;if(!nr(t)||!nr(n))return null;const o=t.internals.handleBounds||or(t.handles),r=n.internals.handleBounds||or(n.handles),i=rr(o?.source??[],e.sourceHandle),s=rr(e.connectionMode===Ze.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",ye.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,c=s?.position||X.Top,l=Ue(t,i,a),u=Ue(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function or(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 Ue(e,t,n=X.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??we(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function rr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function qn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function df(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(c=>{if(c&&typeof c=="object"){const l=qn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Xi=1e3,ff=10,mo={nodeOrigin:[0,0],nodeExtent:bt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},hf={...mo,checkEquality:!0};function yo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function pf(e,t,n){const o=yo(mo,n);for(const r of e.values())if(r.parentId)wo(r,e,t,o);else{const i=kt(r,o.nodeOrigin),s=qe(r.extent)?r.extent:o.nodeExtent,a=Ge(i,s,we(r));r.internals.positionAbsolute=a}}function gf(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 xo(e){return e==="manual"}function Un(e,t,n,o={}){const r=yo(hf,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!xo(r.zIndexMode)?Xi:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const u of e){let f=s.get(u.id);if(r.checkEquality&&u===f?.internals.userNode)t.set(u.id,f);else{const d=kt(u,r.nodeOrigin),h=qe(u.extent)?u.extent:r.nodeExtent,m=Ge(d,h,we(u));f={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:gf(u,f),z:Wi(u,a,r.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),u.parentId&&wo(f,t,n,o,i),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function mf(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 wo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yo(mo,o),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mf(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*ff),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!xo(c)?Xi:0,{x:d,y:h,z:m}=yf(e,u,s,a,f,c),{positionAbsolute:v}=e.internals,x=d!==v.x||h!==v.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:d,y:h}:v,z:m}})}function Wi(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return xo(n)?o:o+(e.selected?t:0)}function yf(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=we(e),l=kt(e,n),u=qe(e.extent)?Ge(l,e.extent,c):l;let f=Ge({x:s+u.x,y:a+u.y},o,c);e.extent==="parent"&&(f=Pi(f,c,t));const d=Wi(e,r,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function vo(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 c=i.get(s.parentId)?.expandedRect??St(a),l=Di(c,s.rect);i.set(s.parentId,{expandedRect:l,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const l=a.internals.positionAbsolute,u=we(a),f=a.origin??o,d=s.x<l.x?Math.round(Math.abs(l.x-s.x)):0,h=s.y<l.y?Math.round(Math.abs(l.y-s.y)):0,m=Math.max(u.width,Math.round(s.width)),v=Math.max(u.height,Math.round(s.height)),x=(m-u.width)*f[0],y=(v-u.height)*f[1];(d>0||h>0||x||y)&&(r.push({id:c,type:"position",position:{x:a.position.x-d+x,y:a.position.y-h+y}}),n.get(c)?.forEach(w=>{e.some(g=>g.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+d,y:w.position.y+h}})})),(u.width<s.width||u.height<s.height||d||h)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:m+(d?f[0]*d-x:0),height:v+(h?f[1]*h-y:0)}})}),r}function xf(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:f}=new window.DOMMatrixReadOnly(u.transform),d=[];for(const h of e.values()){const m=t.get(h.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),c=!0;continue}const v=go(h.nodeElement),x=m.measured.width!==v.width||m.measured.height!==v.height;if(!!(v.width&&v.height&&(x||!m.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),g=qe(m.extent)?m.extent:i;let{positionAbsolute:b}=m.internals;if(m.parentId&&m.extent==="parent"){const S=t.get(m.parentId);S&&(b=Pi(b,v,S))}else g&&(b=Ge(b,g,v));const C={...m,measured:v,internals:{...m.internals,positionAbsolute:b,handleBounds:{source:Qo("source",h.nodeElement,w,f,m.id),target:Qo("target",h.nodeElement,w,f,m.id)}}};t.set(m.id,C),m.parentId&&wo(C,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,x&&(l.push({id:m.id,type:"dimensions",dimensions:v}),m.expandParent&&m.parentId&&d.push({id:m.id,parentId:m.parentId,rect:St(C,r)}))}}if(d.length>0){const h=vo(d,t,n,r);l.push(...h)}return{changes:l,updatedInternals:c}}async function wf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function ir(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 c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function Zi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;ir("source",c,u,e,r,s),ir("target",c,l,e,i,a),t.set(o.id,o)}}function Gi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Gi(n,t):!1}function sr(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function vf(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Gi(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 In({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,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 bf({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=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function _f({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,f=!1,d=null,h=!1,m=!1,v=null;function x({noDragClassName:w,handleSelector:g,domNode:b,isSelectable:C,nodeId:S,nodeClickDistance:N=0}){d=ue(b);function k({x:O,y:H}){const{nodeLookup:_,nodeExtent:I,snapGrid:M,snapToGrid:A,nodeOrigin:$,onNodeDrag:j,onSelectionDrag:z,onError:V,updateNodePositions:B}=t();i={x:O,y:H};let W=!1;const Y=a.size>1,G=Y&&I?Zn(Tt(a)):null,J=Y&&A?bf({dragItems:a,snapGrid:M,x:O,y:H}):null;for(const[R,D]of a){if(!_.has(R))continue;let F={x:O-D.distance.x,y:H-D.distance.y};A&&(F=J?{x:Math.round(F.x+J.x),y:Math.round(F.y+J.y)}:At(F,M));let q=null;if(Y&&I&&!D.extent&&G){const{positionAbsolute:U}=D.internals,ee=U.x-G.x+I[0][0],ne=U.x+D.measured.width-G.x2+I[1][0],re=U.y-G.y+I[0][1],ae=U.y+D.measured.height-G.y2+I[1][1];q=[[ee,re],[ne,ae]]}const{position:K,positionAbsolute:Z}=Ai({nodeId:R,nextPosition:F,nodeLookup:_,nodeExtent:q||I,nodeOrigin:$,onError:V});W=W||D.position.x!==K.x||D.position.y!==K.y,D.position=K,D.internals.positionAbsolute=Z}if(m=m||W,!!W&&(B(a,!0),v&&(o||j||!S&&z))){const[R,D]=In({nodeId:S,dragItems:a,nodeLookup:_});o?.(v,a,R,D),j?.(v,R,D),S||z?.(v,D)}}async function P(){if(!u)return;const{transform:O,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:I}=t();if(!I){c=!1,cancelAnimationFrame(s);return}const[M,A]=ho(l,u,_);(M!==0||A!==0)&&(i.x=(i.x??0)-M/O[2],i.y=(i.y??0)-A/O[2],await H({x:M,y:A})&&k(i)),s=requestAnimationFrame(P)}function L(O){const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:I,transform:M,snapGrid:A,snapToGrid:$,selectNodesOnDrag:j,onNodeDragStart:z,onSelectionDragStart:V,unselectNodesAndEdges:B}=t();f=!0,(!j||!C)&&!_&&S&&(H.get(S)?.selected||B()),C&&j&&S&&e?.(S);const W=gt(O.sourceEvent,{transform:M,snapGrid:A,snapToGrid:$,containerBounds:u});if(i=W,a=vf(H,I,W,S),a.size>0&&(n||z||!S&&V)){const[Y,G]=In({nodeId:S,dragItems:a,nodeLookup:H});n?.(O.sourceEvent,a,Y,G),z?.(O.sourceEvent,Y,G),S||V?.(O.sourceEvent,G)}}const T=ui().clickDistance(N).on("start",O=>{const{domNode:H,nodeDragThreshold:_,transform:I,snapGrid:M,snapToGrid:A}=t();u=H?.getBoundingClientRect()||null,h=!1,m=!1,v=O.sourceEvent,_===0&&L(O),i=gt(O.sourceEvent,{transform:I,snapGrid:M,snapToGrid:A,containerBounds:u}),l=me(O.sourceEvent,u)}).on("drag",O=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:I,snapToGrid:M,nodeDragThreshold:A,nodeLookup:$}=t(),j=gt(O.sourceEvent,{transform:_,snapGrid:I,snapToGrid:M,containerBounds:u});if(v=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||S&&!$.has(S))&&(h=!0),!h){if(!c&&H&&f&&(c=!0,P()),!f){const z=me(O.sourceEvent,u),V=z.x-l.x,B=z.y-l.y;Math.sqrt(V*V+B*B)>A&&L(O)}(i.x!==j.xSnapped||i.y!==j.ySnapped)&&a&&f&&(l=me(O.sourceEvent,u),k(j))}}).on("end",O=>{if(!f||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,f=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:I,onSelectionDragStop:M}=t();if(m&&(_(a,!1),m=!1),r||I||!S&&M){const[A,$]=In({nodeId:S,dragItems:a,nodeLookup:H,dragging:!1});r?.(O.sourceEvent,a,A,$),I?.(O.sourceEvent,A,$),S||M?.(O.sourceEvent,$)}}}).filter(O=>{const H=O.target;return!O.button&&(!w||!sr(H,`.${w}`,b))&&(!g||sr(H,g,b))});d.call(T)}function y(){d?.on(".drag",null)}return{update:x,destroy:y}}function Sf(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())rn(r,St(i))>0&&o.push(i);return o}const Nf=250;function Ef(e,t,n,o){let r=[],i=1/0;const s=Sf(e,n,t+Nf);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const l of c){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:u,y:f}=Ue(a,l,l.position,!0),d=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...l,x:u,y:f}],i=d):d===i&&r.push({...l,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function qi(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??[]],c=(n?a?.find(l=>l.id===n):a?.[0])??null;return c&&i?{...c,...Ue(s,c,c.position,!0)}:c}function Ui(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Cf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ki=()=>!0;function If(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:h,onConnectStart:m,onConnect:v,onConnectEnd:x,isValidConnection:y=Ki,onReconnectEnd:w,updateConnection:g,getTransform:b,getFromHandle:C,autoPanSpeed:S,dragThreshold:N=1,handleDomNode:k}){const P=Oi(e.target);let L=0,T;const{x:O,y:H}=me(e),_=Ui(i,k),I=a?.getBoundingClientRect();let M=!1;if(!I||!_)return;const A=qi(r,_,o,c,t);if(!A)return;let $=me(e,I),j=!1,z=null,V=!1,B=null;function W(){if(!u||!I)return;const[K,Z]=ho($,I,S);d({x:K,y:Z}),L=requestAnimationFrame(W)}const Y={...A,nodeId:r,type:_,position:A.position},G=c.get(r);let R={inProgress:!0,isValid:null,from:Ue(G,Y,X.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:G,to:$,toHandle:null,toPosition:Go[Y.position],toNode:null,pointer:$};function D(){M=!0,g(R),m?.(e,{nodeId:r,handleId:o,handleType:_})}N===0&&D();function F(K){if(!M){const{x:ae,y:Ee}=me(K),ve=ae-O,be=Ee-H;if(!(ve*ve+be*be>N*N))return;D()}if(!C()||!Y){q(K);return}const Z=b();$=me(K,I),T=Ef(Pt($,Z,!1,[1,1]),n,c,Y),j||(W(),j=!0);const U=Qi(K,{handle:T,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:P,lib:l,flowId:f,nodeLookup:c});B=U.handleDomNode,z=U.connection,V=Cf(!!T,U.isValid);const ee=c.get(r),ne=ee?Ue(ee,Y,X.Left,!0):R.from,re={...R,from:ne,isValid:V,to:U.toHandle&&V?st({x:U.toHandle.x,y:U.toHandle.y},Z):$,toHandle:U.toHandle,toPosition:V&&U.toHandle?U.toHandle.position:Go[Y.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null,pointer:$};g(re),R=re}function q(K){if(!("touches"in K&&K.touches.length>0)){if(M){(T||B)&&z&&V&&v?.(z);const{inProgress:Z,...U}=R,ee={...U,toPosition:R.toHandle?R.toPosition:null};x?.(K,ee),i&&w?.(K,ee)}h(),cancelAnimationFrame(L),j=!1,V=!1,z=null,B=null,P.removeEventListener("mousemove",F),P.removeEventListener("mouseup",q),P.removeEventListener("touchmove",F),P.removeEventListener("touchend",q)}}P.addEventListener("mousemove",F),P.addEventListener("mouseup",q),P.addEventListener("touchmove",F),P.addEventListener("touchend",q)}function Qi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=Ki,nodeLookup:u}){const f=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:m}=me(e),v=s.elementFromPoint(h,m),x=v?.classList.contains(`${a}-flow__handle`)?v:d,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=Ui(void 0,x),g=x.getAttribute("data-nodeid"),b=x.getAttribute("data-handleid"),C=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!g||!w)return y;const N={source:f?g:o,sourceHandle:f?b:r,target:f?o:g,targetHandle:f?r:b};y.connection=N;const P=C&&S&&(n===Ze.Strict?f&&w==="source"||!f&&w==="target":g!==o||b!==r);y.isValid=P&&l(N),y.toHandle=qi(g,w,b,u,n,!0)}return y}const Kn={onPointerDown:If,isValid:Qi};function Mf({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ue(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const b=n(),C=g.sourceEvent.ctrlKey&&Nt()?10:1,S=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,N=b[2]*Math.pow(2,S*C);t.scaleTo(N)};let v=[0,0];const x=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(v=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const b=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const C=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],S=[C[0]-v[0],C[1]-v[1]];v=C;const N=o()*Math.max(b[2],Math.log(b[2]))*(h?-1:1),k={x:b[0]-S[0]*N,y:b[1]-S[1]*N},P=[[0,0],[c,l]];t.setViewportConstrained({x:k.x,y:k.y,zoom:b[2]},P,a)},w=Ei().on("start",x).on("zoom",f?y:null).on("zoom.wheel",d?m:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:he}}const pn=e=>({x:e.x,y:e.y,zoom:e.k}),Mn=({x:e,y:t,zoom:n})=>dn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Ji=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kn=(e,t=0,n=kf,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},es=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Tf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(je(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const x=he(u),y=es(u),w=f*Math.pow(2,y);o.scaleTo(n,w,x,u);return}const d=u.deltaMode===1?20:1;let h=r===Ye.Vertical?0:u.deltaX*d,m=r===Ye.Horizontal?0:u.deltaY*d;!Nt()&&u.shiftKey&&r!==Ye.Vertical&&(h=u.deltaY*d,m=0),o.translateBy(n,-(h/f)*i,-(m/f)*i,{internal:!0});const v=pn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,v):(e.isPanScrolling=!0,a?.(u,v)),e.panScrollTimeout=setTimeout(()=>{l?.(u,v),e.isPanScrolling=!1},150)}}function Af({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 Pf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=pn(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 Df({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ji(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,pn(i.transform))}}function $f({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ji(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=pn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function jf({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:f}){return d=>{const h=t||n,m=o&&d.ctrlKey,v=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(je(d,`${u}-flow__node`)||je(d,`${u}-flow__edge`)||je(d,`${u}-flow__selection`)||je(d,`${u}-flow__nodesselection`)))return!0;if(!r&&!h&&!i&&!s&&!o||a||f&&!v||je(d,c)&&v||je(d,l)&&(!v||i&&v&&!t)||!o&&d.ctrlKey&&v)return!1;if(!o&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!h&&!i&&!m&&v||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const x=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||v||e)&&x}}function Rf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let f=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(H=>{const _=H[0];_&&(f=[[0,0],[_.contentRect.width,_.contentRect.height]])}):null)?.observe(e);const h=Ei().extent(()=>f).scaleExtent([t,n]).translateExtent(o),m=ue(e).call(h);b({x:r.x,y:r.y,zoom:it(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const v=m.on("wheel.zoom"),x=m.on("dblclick.zoom");h.wheelDelta(es);async function y(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).transform(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function w({noWheelClassName:H,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:A,panOnDrag:$,panOnScrollMode:j,panOnScrollSpeed:z,preventScrolling:V,zoomOnPinch:B,zoomOnScroll:W,zoomOnDoubleClick:Y,panActivationKeyPressed:G=!1,zoomActivationKeyPressed:J,lib:R,onTransformChange:D,connectionInProgress:F,paneClickDistance:q,selectionOnDrag:K}){M&&!l.isZoomingOrPanning&&g();const Z=A&&!J&&!M;h.clickDistance(K?1/0:!ge(q)||q<0?0:q);const U=Z?Tf({zoomPanValues:l,noWheelClassName:H,d3Selection:m,d3Zoom:h,panOnScrollMode:j,panOnScrollSpeed:z,zoomOnPinch:B,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Af({noWheelClassName:H,preventScrolling:V,d3ZoomHandler:v});m.on("wheel.zoom",U,{passive:!1});const ee=Pf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",ee);const ne=Df({zoomPanValues:l,panOnDrag:$,onPaneContextMenu:!!I,onPanZoom:i,onTransformChange:D});h.on("zoom",ne);const re=$f({zoomPanValues:l,panOnDrag:$,panOnScroll:A,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});h.on("end",re);const ae=jf({panActivationKeyPressed:G,zoomActivationKeyPressed:J,panOnDrag:$,zoomOnScroll:W,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:B,userSelectionActive:M,noPanClassName:_,noWheelClassName:H,lib:R,connectionInProgress:F});h.filter(ae),Y?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function g(){h.on("zoom",null)}async function b(H,_,I){const M=Mn(H),A=h?.constrain()(M,_,I);return A&&await y(A),A}async function C(H,_){const I=Mn(H);return await y(I,_),I}function S(H){if(m){const _=Mn(H),I=m.property("__zoom");(I.k!==H.zoom||I.x!==H.x||I.y!==H.y)&&h?.transform(m,_,null,{sync:!0})}}function N(){const H=m?Ni(m.node()):{x:0,y:0,k:1};return{x:H.x,y:H.y,zoom:H.k}}async function k(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleTo(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}async function P(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleBy(kn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function L(H){h?.scaleExtent(H)}function T(H){h?.translateExtent(H)}function O(H){const _=!ge(H)||H<0?0:H;h?.clickDistance(_)}return{update:w,destroy:g,setViewport:C,setViewportConstrained:b,getViewport:N,scaleTo:k,scaleBy:P,setScaleExtent:L,setTranslateExtent:T,syncViewport:S,setClickDistance:O}}var at;(function(e){e.Line="line",e.Handle="handle"})(at||(at={}));function Hf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function ar(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 De(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function zt(e,t,n){return Math.max(0,t-e,e-n)}function cr(e,t){return e?!t:t}function Of(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:h,ySnapped:m}=n,{minWidth:v,maxWidth:x,minHeight:y,maxHeight:w}=o,{x:g,y:b,width:C,height:S,aspectRatio:N}=e;let k=Math.floor(u?h-e.pointerX:0),P=Math.floor(f?m-e.pointerY:0);const L=C+(c?-k:k),T=S+(l?-P:P),O=-i[0]*C,H=-i[1]*S;let _=zt(L,v,x),I=zt(T,y,w);if(s){let $=0,j=0;c&&k<0?$=De(g+k+O,s[0][0]):!c&&k>0&&($=$e(g+L+O,s[1][0])),l&&P<0?j=De(b+P+H,s[0][1]):!l&&P>0&&(j=$e(b+T+H,s[1][1])),_=Math.max(_,$),I=Math.max(I,j)}if(a){let $=0,j=0;c&&k>0?$=$e(g+k,a[0][0]):!c&&k<0&&($=De(g+L,a[1][0])),l&&P>0?j=$e(b+P,a[0][1]):!l&&P<0&&(j=De(b+T,a[1][1])),_=Math.max(_,$),I=Math.max(I,j)}if(r){if(u){const $=zt(L/N,y,w)*N;if(_=Math.max(_,$),s){let j=0;!c&&!l||c&&!l&&d?j=$e(b+H+L/N,s[1][1])*N:j=De(b+H+(c?k:-k)/N,s[0][1])*N,_=Math.max(_,j)}if(a){let j=0;!c&&!l||c&&!l&&d?j=De(b+L/N,a[1][1])*N:j=$e(b+(c?k:-k)/N,a[0][1])*N,_=Math.max(_,j)}}if(f){const $=zt(T*N,v,x)/N;if(I=Math.max(I,$),s){let j=0;!c&&!l||l&&!c&&d?j=$e(g+T*N+O,s[1][0])/N:j=De(g+(l?P:-P)*N+O,s[0][0])/N,I=Math.max(I,j)}if(a){let j=0;!c&&!l||l&&!c&&d?j=De(g+T*N,a[1][0])/N:j=$e(g+(l?P:-P)*N,a[0][0])/N,I=Math.max(I,j)}}}P=P+(P<0?I:-I),k=k+(k<0?_:-_),r&&(d?L>T*N?P=(cr(c,l)?-k:k)/N:k=(cr(c,l)?-P:P)*N:u?(P=k/N,l=c):(k=P*N,c=l));const M=c?g+k:g,A=l?b+P:b;return{width:C+(c?-k:k),height:S+(l?-P:P),x:i[0]*k*(c?-1:1)+M,y:i[1]*P*(l?-1:1)+A}}const ts={width:0,height:0,x:0,y:0},zf={...ts,pointerX:0,pointerY:0,aspectRatio:1};function Lf(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,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Bf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ue(e);let s={controlDirection:ar("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:m,onResizeEnd:v,shouldResize:x}){let y={...ts},w={...zf};s={boundaries:u,resizeDirection:d,keepAspectRatio:f,controlDirection:ar(l)};let g,b=null,C=[],S,N,k,P=!1;const L=ui().on("start",T=>{const{nodeLookup:O,transform:H,snapGrid:_,snapToGrid:I,nodeOrigin:M,paneDomNode:A}=n();if(g=O.get(t),!g)return;b=A?.getBoundingClientRect()??null;const{xSnapped:$,ySnapped:j}=gt(T.sourceEvent,{transform:H,snapGrid:_,snapToGrid:I,containerBounds:b});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},w={...y,pointerX:$,pointerY:j,aspectRatio:y.width/y.height},S=void 0,N=qe(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(S=O.get(g.parentId)),S&&g.extent==="parent"&&(N=[[0,0],[S.measured.width,S.measured.height]]),C=[],k=void 0;for(const[z,V]of O)if(V.parentId===t&&(C.push({id:z,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const B=Lf(V,g,V.origin??M);k?k=[[Math.min(B[0][0],k[0][0]),Math.min(B[0][1],k[0][1])],[Math.max(B[1][0],k[1][0]),Math.max(B[1][1],k[1][1])]]:k=B}h?.(T,{...y})}).on("drag",T=>{const{transform:O,snapGrid:H,snapToGrid:_,nodeOrigin:I}=n(),M=gt(T.sourceEvent,{transform:O,snapGrid:H,snapToGrid:_,containerBounds:b}),A=[];if(!g)return;const{x:$,y:j,width:z,height:V}=y,B={},W=g.origin??I,{width:Y,height:G,x:J,y:R}=Of(w,s.controlDirection,M,s.boundaries,s.keepAspectRatio,W,N,k),D=Y!==z,F=G!==V,q=J!==$&&D,K=R!==j&&F;if(!q&&!K&&!D&&!F)return;if((q||K||W[0]===1||W[1]===1)&&(B.x=q?J:y.x,B.y=K?R:y.y,y.x=B.x,y.y=B.y,C.length>0)){const ne=J-$,re=R-j;for(const ae of C)ae.position={x:ae.position.x-ne+W[0]*(Y-z),y:ae.position.y-re+W[1]*(G-V)},A.push(ae)}if((D||F)&&(B.width=D&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:y.width,B.height=F&&(!s.resizeDirection||s.resizeDirection==="vertical")?G:y.height,y.width=B.width,y.height=B.height),S&&g.expandParent){const ne=W[0]*(B.width??0);B.x&&B.x<ne&&(y.x=ne,w.x=w.x-(B.x-ne));const re=W[1]*(B.height??0);B.y&&B.y<re&&(y.y=re,w.y=w.y-(B.y-re))}const Z=Hf({width:y.width,prevWidth:z,height:y.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...y,direction:Z};x?.(T,U)!==!1&&(P=!0,m?.(T,U),o(B,A))}).on("end",T=>{P&&(v?.(T,{...y}),r?.({...y}),P=!1)});i.call(L)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var Tn={exports:{}},An={},Pn={exports:{}},Dn={};var lr;function Vf(){if(lr)return Dn;lr=1;var e=Gr();function t(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(f,d){var h=d(),m=o({inst:{value:h,getSnapshot:d}}),v=m[0].inst,x=m[1];return i(function(){v.value=h,v.getSnapshot=d,c(v)&&x({inst:v})},[f,h,d]),r(function(){return c(v)&&x({inst:v}),f(function(){c(v)&&x({inst:v})})},[f]),s(h),h}function c(f){var d=f.getSnapshot;f=f.value;try{var h=d();return!n(f,h)}catch{return!0}}function l(f,d){return d()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Dn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Dn}var ur;function Ff(){return ur||(ur=1,Pn.exports=Vf()),Pn.exports}var dr;function Yf(){if(dr)return An;dr=1;var e=Gr(),t=Ff();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return An.useSyncExternalStoreWithSelector=function(l,u,f,d,h){var m=i(null);if(m.current===null){var v={hasValue:!1,value:null};m.current=v}else v=m.current;m=a(function(){function y(S){if(!w){if(w=!0,g=S,S=d(S),h!==void 0&&v.hasValue){var N=v.value;if(h(N,S))return b=N}return b=S}if(N=b,o(g,S))return N;var k=d(S);return h!==void 0&&h(N,k)?(g=S,N):(g=S,b=k)}var w=!1,g,b,C=f===void 0?null:f;return[function(){return y(u())},C===null?void 0:function(){return y(C())}]},[u,f,d,h]);var x=r(l,m[0],m[1]);return s(function(){v.hasValue=!0,v.value=x},[x]),c(x),x},An}var fr;function Xf(){return fr||(fr=1,Tn.exports=Yf()),Tn.exports}var Wf=Xf();const Zf=qa(Wf),Gf={},hr=e=>{let t;const n=new Set,o=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(m=>m(t,h))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Gf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,c);return c},qf=e=>e?hr(e):hr,{useDebugValue:Uf}=Ua,{useSyncExternalStoreWithSelector:Kf}=Zf,Qf=e=>e;function ns(e,t=Qf,n){const o=Kf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Uf(o),o}const pr=(e,t)=>{const n=qf(e),o=(r,i=t)=>ns(n,r,i);return Object.assign(o,n),o},Jf=(e,t)=>e?pr(e,t):pr;function ie(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 gn=E.createContext(null),eh=gn.Provider,os=ye.error001("react");function te(e,t){const n=E.useContext(gn);if(n===null)throw new Error(os);return ns(n,e,t)}function oe(){const e=E.useContext(gn);if(e===null)throw new Error(os);return E.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gr={display:"none"},th={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},rs="react-flow__node-desc",is="react-flow__edge-desc",nh="react-flow__aria-live",oh=e=>e.ariaLiveMessage,rh=e=>e.ariaLabelConfig;function ih({rfId:e}){const t=te(oh);return p.jsx("div",{id:`${nh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:th,children:t})}function sh({rfId:e,disableKeyboardA11y:t}){const n=te(rh);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${rs}-${e}`,style:gr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${is}-${e}`,style:gr,children:n["edge.a11yDescription.default"]}),!t&&p.jsx(ih,{rfId:e})]})}const Ke=E.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return p.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Ke.displayName="Panel";const mr="https://reactflow.dev?utm_source=attribution";function ah({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:p.jsx(Ke,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${mr}`,children:p.jsx("a",{href:mr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const ch=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}},Lt=e=>e.id;function lh(e,t){return ie(e.selectedNodes.map(Lt),t.selectedNodes.map(Lt))&&ie(e.selectedEdges.map(Lt),t.selectedEdges.map(Lt))}function uh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:o}=te(ch,lh);return E.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const dh=e=>!!e.onSelectionChangeHandlers;function fh({onSelectionChange:e}){const t=te(dh);return e||t?p.jsx(uh,{onSelectionChange:e}):null}const ss=[0,0],hh={x:0,y:0,zoom:1},ph=["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"],yr=[...ph,"rfId"],gh=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}),xr={translateExtent:bt,nodeOrigin:ss,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function mh(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(gh,ie),l=oe();E.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=xr,a()}),[]);const u=E.useRef(xr);return E.useEffect(()=>{for(const f of yr){const d=e[f],h=u.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?l.setState({ariaLabelConfig:Jd(d)}):f==="fitView"?l.setState({fitViewQueued:d}):f==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[f]:d})))}u.current=e},yr.map(f=>e[f])),null}function wr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function yh(e){const[t,n]=E.useState(e==="system"?null:e);return E.useEffect(()=>{if(e!=="system"){n(e);return}const o=wr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:wr()?.matches?"dark":"light"}const vr=typeof document<"u"?document:null;function Et(e=null,t={target:vr,actInsideInputWithModifier:!0}){const[n,o]=E.useState(!1),r=E.useRef(!1),i=E.useRef(new Set([])),[s,a]=E.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace(/\+/g,`
2
+ `).replace(`
3
+
4
+ `,`
5
+ +`).split(`
6
+ `)),u=l.reduce((f,d)=>f.concat(...d),[]);return[l,u]}return[[],[]]},[e]);return E.useEffect(()=>{const c=t?.target??vr,l=t?.actInsideInputWithModifier??!0;if(e!==null){const u=h=>{if(r.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!r.current||r.current&&!l)&&zi(h))return!1;const v=_r(h.code,a);if(i.current.add(h[v]),br(s,i.current,!1)){const x=h.composedPath?.()?.[0]||h.target,y=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(r.current||!y)&&h.preventDefault(),o(!0)}},f=h=>{const m=_r(h.code,a);br(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(h[m]),h.key==="Meta"&&i.current.clear(),r.current=!1},d=()=>{i.current.clear(),o(!1)};return c?.addEventListener("keydown",u),c?.addEventListener("keyup",f),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{c?.removeEventListener("keydown",u),c?.removeEventListener("keyup",f),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,o]),n}function br(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function _r(e,t){return t.includes(e)?"code":"key"}const xh=()=>{const e=oe();return E.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):!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),!0):!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(),c=po(t,o,r,i,s,n?.padding??.1);return a?(await a.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},u=n.snapGrid??r,f=n.snapToGrid??i;return Pt(l,o,f,u)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=st(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function as(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 c of s)wh(c,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 wh(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 cs(e,t){return as(e,t)}function ls(e,t){return as(e,t)}function Be(e,t){return{id:e,type:"select",selected:t}}function Je(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(Be(i.id,s)))}return o}function Sr({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 Nr(e){return{id:e.id,type:"remove"}}const vh=ji();function bh(e,t,n={}){return sf(e,t,{...n,onError:n.onError??vh})}const Er=e=>Yd(e),_h=e=>Ti(e);function us(e){return E.forwardRef(e)}const ds=typeof window<"u"?E.useLayoutEffect:E.useEffect;function Cr(e){const[t,n]=E.useState(BigInt(0)),[o]=E.useState(()=>Sh(()=>n(r=>r+BigInt(1))));return ds(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Sh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const fs=E.createContext(null);function Nh({children:e}){const t=oe(),n=E.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:u,onNodesChange:f,nodeLookup:d,fitViewQueued:h,onNodesChangeMiddlewareMap:m}=t.getState();let v=c;for(const y of a)v=typeof y=="function"?y(v):y;let x=Sr({items:v,lookup:d});for(const y of m.values())x=y(x);u&&l(v),x.length>0?f?.(x):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:w,setNodes:g}=t.getState();y&&g(w)})},[]),o=Cr(n),r=E.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:u,onEdgesChange:f,edgeLookup:d}=t.getState();let h=c;for(const m of a)h=typeof m=="function"?m(h):m;u?l(h):f&&f(Sr({items:h,lookup:d}))},[]),i=Cr(r),s=E.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return p.jsx(fs.Provider,{value:s,children:e})}function Eh(){const e=E.useContext(fs);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Ch=e=>!!e.panZoom;function mn(){const e=xh(),t=oe(),n=Eh(),o=te(Ch),r=E.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),s=f=>{n.nodeQueue.push(f)},a=f=>{n.edgeQueue.push(f)},c=f=>{const{nodeLookup:d,nodeOrigin:h}=t.getState(),m=Er(f)?f:d.get(f.id),v=m.parentId?Hi(m.position,m.measured,m.parentId,d,h):m.position,x={...m,position:v,width:m.measured?.width??m.width,height:m.measured?.height??m.height};return St(x)},l=(f,d,h={replace:!1})=>{s(m=>m.map(v=>{if(v.id===f){const x=typeof d=="function"?d(v):d;return h.replace&&Er(x)?x:{...v,...x}}return v}))},u=(f,d,h={replace:!1})=>{a(m=>m.map(v=>{if(v.id===f){const x=typeof d=="function"?d(v):d;return h.replace&&_h(x)?x:{...v,...x}}return v}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>i(f)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(d=>({...d}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:s,setEdges:a,addNodes:f=>{const d=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...d])},addEdges:f=>{const d=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...d])},toObject:()=>{const{nodes:f=[],edges:d=[],transform:h}=t.getState(),[m,v,x]=h;return{nodes:f.map(y=>({...y})),edges:d.map(y=>({...y})),viewport:{x:m,y:v,zoom:x}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:h,edges:m,onNodesDelete:v,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:w,onDelete:g,onBeforeDelete:b}=t.getState(),{nodes:C,edges:S}=await qd({nodesToRemove:f,edgesToRemove:d,nodes:h,edges:m,onBeforeDelete:b}),N=S.length>0,k=C.length>0;if(N){const P=S.map(Nr);x?.(S),w(P)}if(k){const P=C.map(Nr);v?.(C),y(P)}return(k||N)&&g?.({nodes:C,edges:S}),{deletedNodes:C,deletedEdges:S}},getIntersectingNodes:(f,d=!0,h)=>{const m=Uo(f),v=m?f:c(f),x=h!==void 0;return v?(h||t.getState().nodes).filter(y=>{const w=t.getState().nodeLookup.get(y.id);if(w&&!m&&(y.id===f.id||!w.internals.positionAbsolute))return!1;const g=St(x?y:w),b=rn(g,v);return d&&b>0||b>=g.width*g.height||b>=v.width*v.height}):[]},isNodeIntersecting:(f,d,h=!0)=>{const v=Uo(f)?f:c(f);if(!v)return!1;const x=rn(v,d);return h&&x>0||x>=d.width*d.height||x>=v.width*v.height},updateNode:l,updateNodeData:(f,d,h={replace:!1})=>{l(f,m=>{const v=typeof d=="function"?d(m):d;return h.replace?{...m,data:v}:{...m,data:{...m.data,...v}}},h)},updateEdge:u,updateEdgeData:(f,d,h={replace:!1})=>{u(f,m=>{const v=typeof d=="function"?d(m):d;return h.replace?{...m,data:v}:{...m,data:{...m.data,...v}}},h)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:h}=t.getState();return Xd(f,{nodeLookup:d,nodeOrigin:h})},getHandleConnections:({type:f,id:d,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${f}${d?`-${d}`:""}`)?.values()??[]),getNodeConnections:({type:f,handleId:d,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${f?d?`-${f}-${d}`:`-${f}`:""}`)?.values()??[]),fitView:async f=>{const d=t.getState().fitViewResolver??Qd();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:d}),n.nodeQueue.push(h=>[...h]),d.promise}}},[]);return E.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const Ir=e=>e.selected,Ih=typeof window<"u"?window:void 0;function Mh({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=oe(),{deleteElements:o}=mn(),r=Et(e,{actInsideInputWithModifier:!1}),i=Et(t,{target:Ih});E.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();o({nodes:a.filter(Ir),edges:s.filter(Ir)}),n.setState({nodesSelectionActive:!1})}},[r]),E.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function kh(e){const t=oe();E.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=go(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",ye.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 yn={position:"absolute",width:"100%",height:"100%",top:0,left:0},Th=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Ah({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panActivationKeyPressed:r,panOnScrollSpeed:i=.5,panOnScrollMode:s=Ye.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:f,maxZoom:d,zoomActivationKeyCode:h,preventScrolling:m=!0,children:v,noWheelClassName:x,noPanClassName:y,onViewportChange:w,isControlledViewport:g,paneClickDistance:b,selectionOnDrag:C}){const S=oe(),N=E.useRef(null),{userSelectionActive:k,lib:P,connectionInProgress:L}=te(Th,ie),T=Et(h),O=E.useRef();kh(N);const H=E.useCallback(_=>{w?.({x:_[0],y:_[1],zoom:_[2]}),g||S.setState({transform:_})},[w,g]);return E.useEffect(()=>{if(N.current){O.current=Rf({domNode:N.current,minZoom:f,maxZoom:d,translateExtent:u,viewport:l,onDraggingChange:A=>S.setState($=>$.paneDragging===A?$:{paneDragging:A}),onPanZoomStart:(A,$)=>{const{onViewportChangeStart:j,onMoveStart:z}=S.getState();z?.(A,$),j?.($)},onPanZoom:(A,$)=>{const{onViewportChange:j,onMove:z}=S.getState();z?.(A,$),j?.($)},onPanZoomEnd:(A,$)=>{const{onViewportChangeEnd:j,onMoveEnd:z}=S.getState();z?.(A,$),j?.($)}});const{x:_,y:I,zoom:M}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[_,I,M],domNode:N.current.closest(".react-flow")}),()=>{O.current?.destroy()}}},[]),E.useEffect(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panActivationKeyPressed:r,panOnScrollSpeed:i,panOnScrollMode:s,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:T,preventScrolling:m,noPanClassName:y,userSelectionActive:k,noWheelClassName:x,lib:P,onTransformChange:H,connectionInProgress:L,selectionOnDrag:C,paneClickDistance:b})},[e,t,n,o,r,i,s,a,c,T,m,y,k,x,P,H,L,C,b]),p.jsx("div",{className:"react-flow__renderer",ref:N,style:yn,children:v})}const Ph=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Dh(){const{userSelectionActive:e,userSelectionRect:t}=te(Ph,ie);return e&&t?p.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 $n=(e,t)=>n=>{n.target===t.current&&e?.(n)},$h=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function jh({isSelecting:e,selectionKeyPressed:t,selectionMode:n=_t.Full,panOnDrag:o,autoPanOnSelection:r,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:f,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:m,children:v}){const x=E.useRef(0),y=oe(),{userSelectionActive:w,elementsSelectable:g,dragging:b,panBy:C,autoPanSpeed:S}=te($h,ie),N=g&&(e||w),k=E.useRef(null),P=E.useRef(),L=E.useRef(new Set),T=E.useRef(new Set),O=E.useRef(!1),H=E.useRef(!1),_=E.useRef({x:0,y:0}),I=E.useRef(!1),M=D=>{if(H.current||O.current||y.getState().connection.inProgress){H.current=!1,O.current=!1;return}l?.(D),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},A=D=>{if(Array.isArray(o)&&o?.includes(2)){D.preventDefault();return}u?.(D)},$=f?D=>f(D):void 0,j=D=>{H.current&&(D.stopPropagation(),H.current=!1)},z=D=>{if(D.pointerType==="touch"&&o!==!1&&!t)return;const{domNode:F,transform:q}=y.getState();if(P.current=F?.getBoundingClientRect(),!P.current)return;const K=D.target===k.current;if(!K&&!!D.target.closest(".nokey")||!e||!(s&&K||t)||D.button!==0||!D.isPrimary)return;D.target?.setPointerCapture?.(D.pointerId),H.current=!1;const{x:ee,y:ne}=me(D.nativeEvent,P.current),re=Pt({x:ee,y:ne},q);y.setState({userSelectionRect:{width:0,height:0,startX:re.x,startY:re.y,x:ee,y:ne}}),K||(D.stopPropagation(),D.preventDefault())};function V(D,F){const{userSelectionRect:q}=y.getState();if(!q)return;const{transform:K,nodeLookup:Z,edgeLookup:U,connectionLookup:ee,triggerNodeChanges:ne,triggerEdgeChanges:re,defaultEdgeOptions:ae}=y.getState(),Ee={x:q.startX,y:q.startY},{x:ve,y:be}=st(Ee,K),Ce={startX:Ee.x,startY:Ee.y,x:D<ve?D:ve,y:F<be?F:be,width:Math.abs(D-ve),height:Math.abs(F-be)},ct=L.current,Oe=T.current;L.current=new Set(fo(Z,Ce,K,n===_t.Partial,!0).map(fe=>fe.id)),T.current=new Set;const ze=ae?.selectable??!0;for(const fe of L.current){const Ie=ee.get(fe);if(Ie)for(const{edgeId:Me}of Ie.values()){const Le=U.get(Me);Le&&(Le.selectable??ze)&&T.current.add(Me)}}if(!Ko(ct,L.current)){const fe=Je(Z,L.current,!0);ne(fe)}if(!Ko(Oe,T.current)){const fe=Je(U,T.current);re(fe)}y.setState({userSelectionRect:Ce,userSelectionActive:!0,nodesSelectionActive:!1})}function B(){if(!r||!P.current)return;const[D,F]=ho(_.current,P.current,S);C({x:D,y:F}).then(q=>{if(!H.current||!q){x.current=requestAnimationFrame(B);return}const{x:K,y:Z}=_.current;V(K,Z),x.current=requestAnimationFrame(B)})}const W=()=>{cancelAnimationFrame(x.current),x.current=0,I.current=!1};E.useEffect(()=>()=>W(),[]);const Y=D=>{const{userSelectionRect:F,transform:q,resetSelectedElements:K}=y.getState();if(!P.current||!F)return;const{x:Z,y:U}=me(D.nativeEvent,P.current);_.current={x:Z,y:U};const ee=st({x:F.startX,y:F.startY},q);if(!H.current){const ne=t?0:i;if(Math.hypot(Z-ee.x,U-ee.y)<=ne)return;K(),a?.(D)}H.current=!0,I.current||(B(),I.current=!0),V(Z,U)},G=D=>{if(!N){D.target===k.current&&y.getState().connection.inProgress&&(O.current=!0);return}D.button===0&&(D.target?.releasePointerCapture?.(D.pointerId),!w&&D.target===k.current&&y.getState().userSelectionRect&&M?.(D),y.setState({userSelectionActive:!1,userSelectionRect:null}),H.current&&(c?.(D),y.setState({nodesSelectionActive:L.current.size>0})),W())},J=D=>{D.target?.releasePointerCapture?.(D.pointerId),W()},R=o===!0||Array.isArray(o)&&o.includes(0);return p.jsxs("div",{className:se(["react-flow__pane",{draggable:R,dragging:b,selection:e}]),onClick:N?void 0:$n(M,k),onContextMenu:$n(A,k),onWheel:$n($,k),onPointerEnter:N?void 0:d,onPointerMove:N?Y:h,onPointerUp:G,onPointerCancel:N?J:void 0,onPointerDownCapture:N?z:void 0,onClickCapture:N?j:void 0,onPointerLeave:m,ref:k,style:yn,children:[v,p.jsx(Dh,{})]})}function Qn({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c?.("012",ye.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function hs({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const a=oe(),[c,l]=E.useState(!1),u=E.useRef();return E.useEffect(()=>{if(!t)return u.current=_f({getStoreItems:()=>a.getState(),onNodeMouseDown:f=>{Qn({id:f,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,a,e]),E.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s})},[n,o,t,i,e,r,s]),c}const Rh=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ps(){const e=oe();return E.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:u}=e.getState(),f=new Map,d=Rh(s),h=r?i[0]:5,m=r?i[1]:5,v=n.direction.x*h*n.factor,x=n.direction.y*m*n.factor;for(const[,y]of l){if(!d(y))continue;let w={x:y.internals.positionAbsolute.x+v,y:y.internals.positionAbsolute.y+x};r&&(w=At(w,i));const{position:g,positionAbsolute:b}=Ai({nodeId:y.id,nextPosition:w,nodeLookup:l,nodeExtent:o,nodeOrigin:u,onError:a});y.position=g,y.internals.positionAbsolute=b,f.set(y.id,y)}c(f)},[])}const bo=E.createContext(null),Hh=bo.Provider;bo.Consumer;const gs=()=>E.useContext(bo),Oh=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),ms=E.createContext(null);function zh({children:e}){const t=te(Oh,ie);return p.jsx(ms.Provider,{value:t,children:e})}function Lh(){const e=E.useContext(ms);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Bh={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Vh=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:a,toHandle:c,isValid:l}=s;if(!a&&!r)return Bh;const u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:a?.nodeId===e&&a?.id===t&&a?.type===n,connectingTo:u,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:i===Ze.Strict?a?.type!==n:e!==a?.nodeId||t!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:u&&l}};function Fh({type:e="source",position:t=X.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:l,onMouseDown:u,onTouchStart:f,...d},h){const m=s||null,v=e==="target",x=oe(),y=gs(),{connectOnClick:w,noPanClassName:g,rfId:b}=Lh(),{connectingFrom:C,connectingTo:S,clickConnecting:N,isPossibleEndHandle:k,connectionInProcess:P,clickConnectionInProcess:L,valid:T}=te(Vh(y,m,e),ie);y||x.getState().onError?.("010",ye.error010());const O=I=>{const{defaultEdgeOptions:M,onConnect:A,hasDefaultEdges:$}=x.getState(),j={...M,...I};if($){const{edges:z,setEdges:V,onError:B}=x.getState();V(bh(j,z,{onError:B}))}A?.(j),a?.(j)},H=I=>{if(!y)return;const M=Li(I.nativeEvent);if(r&&(M&&I.button===0||!M)){const A=x.getState();Kn.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:A.autoPanOnConnect,connectionMode:A.connectionMode,connectionRadius:A.connectionRadius,domNode:A.domNode,nodeLookup:A.nodeLookup,lib:A.lib,isTarget:v,handleId:m,nodeId:y,flowId:A.rfId,panBy:A.panBy,cancelConnection:A.cancelConnection,onConnectStart:A.onConnectStart,onConnectEnd:(...$)=>x.getState().onConnectEnd?.(...$),updateConnection:A.updateConnection,onConnect:O,isValidConnection:n||((...$)=>x.getState().isValidConnection?.(...$)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:A.autoPanSpeed,dragThreshold:A.connectionDragThreshold})}M?u?.(I):f?.(I)},_=I=>{const{onClickConnectStart:M,onClickConnectEnd:A,connectionClickStartHandle:$,connectionMode:j,isValidConnection:z,lib:V,rfId:B,nodeLookup:W,connection:Y}=x.getState();if(!y||!$&&!r)return;if(!$){M?.(I.nativeEvent,{nodeId:y,handleId:m,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:m}});return}const G=Oi(I.target),J=n||z,{connection:R,isValid:D}=Kn.isValid(I.nativeEvent,{handle:{nodeId:y,id:m,type:e},connectionMode:j,fromNodeId:$.nodeId,fromHandleId:$.id||null,fromType:$.type,isValidConnection:J,flowId:B,doc:G,lib:V,nodeLookup:W});D&&R&&O(R);const F=structuredClone(Y);delete F.inProgress,F.toPosition=F.toHandle?F.toHandle.position:null,A?.(I,F),x.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":m,"data-nodeid":y,"data-handlepos":t,"data-id":`${b}-${y}-${m}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,l,{source:!v,target:v,connectable:o,connectablestart:r,connectableend:i,clickconnecting:N,connectingfrom:C,connectingto:S,valid:T,connectionindicator:o&&(!P||k)&&(P||L?i:r)}]),onMouseDown:H,onTouchStart:H,onClick:w?_:void 0,ref:h,...d,children:c})}const He=E.memo(us(Fh));function Yh({data:e,isConnectable:t,sourcePosition:n=X.Bottom}){return p.jsxs(p.Fragment,{children:[e?.label,p.jsx(He,{type:"source",position:n,isConnectable:t})]})}function Xh({data:e,isConnectable:t,targetPosition:n=X.Top,sourcePosition:o=X.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(He,{type:"target",position:n,isConnectable:t}),e?.label,p.jsx(He,{type:"source",position:o,isConnectable:t})]})}function Wh(){return null}function Zh({data:e,isConnectable:t,targetPosition:n=X.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(He,{type:"target",position:n,isConnectable:t}),e?.label]})}const sn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Mr={input:Yh,default:Xh,output:Zh,group:Wh};function Gh(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 qh=e=>{const{width:t,height:n,x:o,y:r}=Tt(e.nodeLookup,{filter:i=>!!i.selected});return{width:ge(t)?t:null,height:ge(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 Uh({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=oe(),{width:r,height:i,transformString:s,userSelectionActive:a}=te(qh,ie),c=ps(),l=E.useRef(null);E.useEffect(()=>{n||l.current?.focus({preventScroll:!0})},[n]);const u=!a&&r!==null&&i!==null;if(hs({nodeRef:l,disabled:!u}),!u)return null;const f=e?h=>{const m=o.getState().nodes.filter(v=>v.selected);e(h,m)}:void 0,d=h=>{Object.prototype.hasOwnProperty.call(sn,h.key)&&(h.preventDefault(),c({direction:sn[h.key],factor:h.shiftKey?4:1}))};return p.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:p.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:i}})})}const kr=typeof window<"u"?window:void 0,Kh=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function ys({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:f,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:m,panActivationKeyCode:v,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:g,panOnScroll:b,panOnScrollSpeed:C,panOnScrollMode:S,zoomOnDoubleClick:N,panOnDrag:k,autoPanOnSelection:P,defaultViewport:L,translateExtent:T,minZoom:O,maxZoom:H,preventScrolling:_,onSelectionContextMenu:I,noWheelClassName:M,noPanClassName:A,disableKeyboardA11y:$,onViewportChange:j,isControlledViewport:z}){const{nodesSelectionActive:V,userSelectionActive:B}=te(Kh,ie),W=Et(l,{target:kr}),Y=Et(v,{target:kr}),G=Y||k,J=Y||b,R=u&&G!==!0,D=W||B||R;return Mh({deleteKeyCode:c,multiSelectionKeyCode:m}),p.jsx(Ah,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:g,panOnScroll:J,panActivationKeyPressed:Y,panOnScrollSpeed:C,panOnScrollMode:S,zoomOnDoubleClick:N,panOnDrag:!W&&G,defaultViewport:L,translateExtent:T,minZoom:O,maxZoom:H,zoomActivationKeyCode:x,preventScrolling:_,noWheelClassName:M,noPanClassName:A,onViewportChange:j,isControlledViewport:z,paneClickDistance:a,selectionOnDrag:R,children:p.jsxs(jh,{onSelectionStart:d,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:G,autoPanOnSelection:P,isSelecting:!!D,selectionMode:f,selectionKeyPressed:W,paneClickDistance:a,selectionOnDrag:R,children:[e,V&&p.jsx(Uh,{onSelectionContextMenu:I,noPanClassName:A,disableKeyboardA11y:$})]})})}ys.displayName="FlowRenderer";const Qh=E.memo(ys),Jh=e=>t=>e?fo(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 ep(e){return te(E.useCallback(Jh(e),[e]),ie)}const tp=e=>e.updateNodeInternals;function np(){const e=te(tp),[t]=E.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 E.useEffect(()=>()=>{t?.disconnect()},[t]),t}function op({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=oe(),i=E.useRef(null),s=E.useRef(null),a=E.useRef(e.sourcePosition),c=E.useRef(e.targetPosition),l=E.useRef(t),u=n&&!!e.internals.handleBounds;return E.useEffect(()=>{i.current&&!e.hidden&&(!u||s.current!==i.current)&&(s.current&&o?.unobserve(s.current),o?.observe(i.current),s.current=i.current)},[u,e.hidden]),E.useEffect(()=>()=>{s.current&&(o?.unobserve(s.current),s.current=null)},[]),E.useEffect(()=>{if(i.current){const f=l.current!==t,d=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||d||h)&&(l.current=t,a.current=e.sourcePosition,c.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 rp({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:f,noDragClassName:d,noPanClassName:h,disableKeyboardA11y:m,rfId:v,nodeTypes:x,nodeClickDistance:y,onError:w}){const{node:g,internals:b,isParent:C}=te(D=>{const F=D.nodeLookup.get(e),q=D.parentLookup.has(e);return{node:F,internals:F.internals,isParent:q}},ie);let S=g.type||"default",N=x?.[S]||Mr[S];N===void 0&&(w?.("003",ye.error003(S)),S="default",N=x?.default||Mr.default);const k=!!(g.draggable||a&&typeof g.draggable>"u"),P=!!(g.selectable||c&&typeof g.selectable>"u"),L=!!(g.connectable||l&&typeof g.connectable>"u"),T=!!(g.focusable||u&&typeof g.focusable>"u"),O=oe(),H=Ri(g),_=op({node:g,nodeType:S,hasDimensions:H,resizeObserver:f}),I=hs({nodeRef:_,disabled:g.hidden||!k,noDragClassName:d,handleSelector:g.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:y}),M=ps();if(g.hidden)return null;const A=we(g),$=Gh(g),j=P||k||t||n||o||r,z=n?D=>n(D,{...b.userNode}):void 0,V=o?D=>o(D,{...b.userNode}):void 0,B=r?D=>r(D,{...b.userNode}):void 0,W=i?D=>i(D,{...b.userNode}):void 0,Y=s?D=>s(D,{...b.userNode}):void 0,G=D=>{const{selectNodesOnDrag:F,nodeDragThreshold:q}=O.getState();P&&(!F||!k||q>0)&&Qn({id:e,store:O,nodeRef:_}),t&&t(D,{...b.userNode})},J=D=>{if(!(zi(D.nativeEvent)||m)){if(Ci.includes(D.key)&&P){const F=D.key==="Escape";Qn({id:e,store:O,unselect:F,nodeRef:_})}else if(k&&g.selected&&Object.prototype.hasOwnProperty.call(sn,D.key)){D.preventDefault();const{ariaLabelConfig:F}=O.getState();O.setState({ariaLiveMessage:F["node.a11yDescription.ariaLiveMessage"]({direction:D.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:sn[D.key],factor:D.shiftKey?4:1})}}},R=()=>{if(m||!_.current?.matches(":focus-visible"))return;const{transform:D,width:F,height:q,autoPanOnNodeFocus:K,setCenter:Z}=O.getState();if(!K)return;fo(new Map([[e,g]]),{x:0,y:0,width:F,height:q},D,!0).length>0||Z(g.position.x+A.width/2,g.position.y+A.height/2,{zoom:D[2]})};return p.jsx("div",{className:se(["react-flow__node",`react-flow__node-${S}`,{[h]:k},g.className,{selected:g.selected,selectable:P,parent:C,draggable:k,dragging:I}]),ref:_,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:j?"all":"none",visibility:H?"visible":"hidden",...g.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:z,onMouseMove:V,onMouseLeave:B,onContextMenu:W,onClick:G,onDoubleClick:Y,onKeyDown:T?J:void 0,tabIndex:T?0:void 0,onFocus:T?R:void 0,role:g.ariaRole??(T?"group":void 0),"aria-roledescription":"node","aria-describedby":m?void 0:`${rs}-${v}`,"aria-label":g.ariaLabel,...g.domAttributes,children:p.jsx(Hh,{value:e,children:p.jsx(N,{id:e,data:g.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:g.selected??!1,selectable:P,draggable:k,deletable:g.deletable??!0,isConnectable:L,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:I,dragHandle:g.dragHandle,zIndex:b.z,parentId:g.parentId,...A})})})}var ip=E.memo(rp);const sp=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function xs(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,onError:r}=te(sp,ie),i=ep(e.onlyRenderVisibleElements),s=np();return p.jsx("div",{className:"react-flow__nodes",style:yn,children:i.map(a=>p.jsx(ip,{id:a,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:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:r},a))})}xs.displayName="NodeRenderer";const ap=E.memo(xs);function cp(e){return te(E.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&&nf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),ie)}const lp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return p.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},up=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return p.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Tr={[nn.Arrow]:lp,[nn.ArrowClosed]:up};function dp(e){const t=oe();return E.useMemo(()=>Object.prototype.hasOwnProperty.call(Tr,e)?Tr[e]:(t.getState().onError?.("009",ye.error009(e)),null),[e])}const fp=({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 c=dp(t);return c?p.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:p.jsx(c,{color:n,strokeWidth:s})}):null},ws=({defaultColor:e,rfId:t})=>{const n=te(i=>i.edges),o=te(i=>i.defaultEdgeOptions),r=E.useMemo(()=>df(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:r.map(i=>p.jsx(fp,{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};ws.displayName="MarkerDefinitions";var hp=E.memo(ws);function vs({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...u}){const[f,d]=E.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",l]),m=E.useRef(null);return E.useEffect(()=>{if(m.current){const v=m.current.getBBox();d({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?p.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...u,children:[r&&p.jsx("rect",{width:f.width+2*s[0],x:-s[0],y:-s[1],height:f.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),p.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:m,style:o,children:n}),c]}):null}vs.displayName="EdgeText";const pp=E.memo(vs);function xn({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...u,d:e,fill:"none",className:se(["react-flow__edge-path",u.className])}),l?p.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&ge(t)&&ge(n)?p.jsx(pp,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function Ar({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===X.Left||e===X.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function bs({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top}){const[s,a]=Ar({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,l]=Ar({pos:i,x1:o,y1:r,x2:e,y2:t}),[u,f,d,h]=Bi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${s},${a} ${c},${l} ${o},${r}`,u,f,d,h]}function _s(e){return E.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:m,markerEnd:v,markerStart:x,interactionWidth:y})=>{const[w,g,b]=bs({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a}),C=e.isInternal?void 0:t;return p.jsx(xn,{id:C,path:w,labelX:g,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:m,markerEnd:v,markerStart:x,interactionWidth:y})})}const gp=_s({isInternal:!1}),Ss=_s({isInternal:!0});gp.displayName="SimpleBezierEdge";Ss.displayName="SimpleBezierEdgeInternal";function Ns(e){return E.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,sourcePosition:h=X.Bottom,targetPosition:m=X.Top,markerEnd:v,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[g,b,C]=Gn({sourceX:n,sourceY:o,sourcePosition:h,targetX:r,targetY:i,targetPosition:m,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),S=e.isInternal?void 0:t;return p.jsx(xn,{id:S,path:g,labelX:b,labelY:C,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:v,markerStart:x,interactionWidth:w})})}const Es=Ns({isInternal:!1}),Cs=Ns({isInternal:!0});Es.displayName="SmoothStepEdge";Cs.displayName="SmoothStepEdgeInternal";function Is(e){return E.memo(({id:t,...n})=>{const o=e.isInternal?void 0:t;return p.jsx(Es,{...n,id:o,pathOptions:E.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const mp=Is({isInternal:!1}),Ms=Is({isInternal:!0});mp.displayName="StepEdge";Ms.displayName="StepEdgeInternal";function ks(e){return E.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:m,interactionWidth:v})=>{const[x,y,w]=Yi({sourceX:n,sourceY:o,targetX:r,targetY:i}),g=e.isInternal?void 0:t;return p.jsx(xn,{id:g,path:x,labelX:y,labelY:w,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:m,interactionWidth:v})})}const yp=ks({isInternal:!1}),Ts=ks({isInternal:!0});yp.displayName="StraightEdge";Ts.displayName="StraightEdgeInternal";function As(e){return E.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=X.Bottom,targetPosition:a=X.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:m,markerEnd:v,markerStart:x,pathOptions:y,interactionWidth:w})=>{const[g,b,C]=Vi({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a,curvature:y?.curvature}),S=e.isInternal?void 0:t;return p.jsx(xn,{id:S,path:g,labelX:b,labelY:C,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:m,markerEnd:v,markerStart:x,interactionWidth:w})})}const xp=As({isInternal:!1}),Ps=As({isInternal:!0});xp.displayName="BezierEdge";Ps.displayName="BezierEdgeInternal";const Pr={default:Ps,straight:Ts,step:Ms,smoothstep:Cs,simplebezier:Ss},Dr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},wp=(e,t,n)=>n===X.Left?e-t:n===X.Right?e+t:e,vp=(e,t,n)=>n===X.Top?e-t:n===X.Bottom?e+t:e,$r="react-flow__edgeupdater";function jr({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:a}){return p.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:se([$r,`${$r}-${a}`]),cx:wp(t,o,e),cy:vp(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function bp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:f,setReconnecting:d,setUpdateHover:h}){const m=oe(),v=(b,C)=>{if(b.button!==0)return;const{autoPanOnConnect:S,domNode:N,connectionMode:k,connectionRadius:P,lib:L,onConnectStart:T,cancelConnection:O,nodeLookup:H,rfId:_,panBy:I,updateConnection:M}=m.getState(),A=C.type==="target",$=(V,B)=>{d(!1),f?.(V,n,C.type,B)},j=V=>l?.(n,V),z=(V,B)=>{d(!0),u?.(b,n,C.type),T?.(V,B)};Kn.onPointerDown(b.nativeEvent,{autoPanOnConnect:S,connectionMode:k,connectionRadius:P,domNode:N,handleId:C.id,nodeId:C.nodeId,nodeLookup:H,isTarget:A,edgeUpdaterType:C.type,lib:L,flowId:_,cancelConnection:O,panBy:I,isValidConnection:(...V)=>m.getState().isValidConnection?.(...V)??!0,onConnect:j,onConnectStart:z,onConnectEnd:(...V)=>m.getState().onConnectEnd?.(...V),onReconnectEnd:$,updateConnection:M,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},x=b=>v(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=b=>v(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>h(!0),g=()=>h(!1);return p.jsxs(p.Fragment,{children:[(e===!0||e==="source")&&p.jsx(jr,{position:a,centerX:o,centerY:r,radius:t,onMouseDown:x,onMouseEnter:w,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&p.jsx(jr,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:y,onMouseEnter:w,onMouseOut:g,type:"target"})]})}function _p({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,rfId:m,edgeTypes:v,noPanClassName:x,onError:y,disableKeyboardA11y:w}){let g=te(Z=>Z.edgeLookup.get(e));const b=te(Z=>Z.defaultEdgeOptions);g=b?{...b,...g}:g;let C=g.type||"default",S=v?.[C]||Pr[C];S===void 0&&(y?.("011",ye.error011(C)),C="default",S=v?.default||Pr.default);const N=!!(g.focusable||t&&typeof g.focusable>"u"),k=typeof f<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),P=!!(g.selectable||o&&typeof g.selectable>"u"),L=E.useRef(null),[T,O]=E.useState(!1),[H,_]=E.useState(!1),I=oe(),{zIndex:M=g.zIndex,sourceX:A,sourceY:$,targetX:j,targetY:z,sourcePosition:V,targetPosition:B}=te(E.useCallback(Z=>{const U=Z.nodeLookup.get(g.source),ee=Z.nodeLookup.get(g.target);if(!U||!ee)return Dr;const ne=uf({id:e,sourceNode:U,targetNode:ee,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:Z.connectionMode,onError:y}),re=tf({selected:g.selected,zIndex:g.zIndex,sourceNode:U,targetNode:ee,elevateOnSelect:Z.elevateEdgesOnSelect,zIndexMode:Z.zIndexMode});return{...ne||Dr,zIndex:re}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex,y]),ie),W=E.useMemo(()=>g.markerStart?`url('#${qn(g.markerStart,m)}')`:void 0,[g.markerStart,m]),Y=E.useMemo(()=>g.markerEnd?`url('#${qn(g.markerEnd,m)}')`:void 0,[g.markerEnd,m]);if(g.hidden||A===null||$===null||j===null||z===null)return null;const G=Z=>{const{addSelectedEdges:U,unselectNodesAndEdges:ee,multiSelectionActive:ne}=I.getState();P&&(I.setState({nodesSelectionActive:!1}),g.selected&&ne?(ee({nodes:[],edges:[g]}),L.current?.blur()):U([e])),r&&r(Z,g)},J=i?Z=>{i(Z,{...g})}:void 0,R=s?Z=>{s(Z,{...g})}:void 0,D=a?Z=>{a(Z,{...g})}:void 0,F=c?Z=>{c(Z,{...g})}:void 0,q=l?Z=>{l(Z,{...g})}:void 0,K=Z=>{if(!w&&Ci.includes(Z.key)&&P){const{unselectNodesAndEdges:U,addSelectedEdges:ee}=I.getState();Z.key==="Escape"?(L.current?.blur(),U({edges:[g]})):ee([e])}};return p.jsx("svg",{style:{zIndex:M},children:p.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${C}`,g.className,x,{selected:g.selected,animated:g.animated,inactive:!P&&!r,updating:T,selectable:P}]),onClick:G,onDoubleClick:J,onContextMenu:R,onMouseEnter:D,onMouseMove:F,onMouseLeave:q,onKeyDown:N?K:void 0,tabIndex:N?0:void 0,role:g.ariaRole??(N?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":N?`${is}-${m}`:void 0,ref:L,...g.domAttributes,children:[!H&&p.jsx(S,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:P,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:A,sourceY:$,targetX:j,targetY:z,sourcePosition:V,targetPosition:B,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:W,markerEnd:Y,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),k&&p.jsx(bp,{edge:g,isReconnectable:k,reconnectRadius:u,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,sourceX:A,sourceY:$,targetX:j,targetY:z,sourcePosition:V,targetPosition:B,setUpdateHover:O,setReconnecting:_})]})})}var Sp=E.memo(_p);const Np=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ds({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:h,onReconnectEnd:m,disableKeyboardA11y:v}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,onError:g}=te(Np,ie),b=cp(t);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(hp,{defaultColor:e,rfId:n}),b.map(C=>p.jsx(Sp,{id:C,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:w,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:f,onDoubleClick:d,onReconnectStart:h,onReconnectEnd:m,rfId:n,onError:g,edgeTypes:o,disableKeyboardA11y:v},C))]})}Ds.displayName="EdgeRenderer";const Ep=E.memo(Ds),Rr=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Cp({children:e}){const t=oe(),n=E.useRef(null),[o]=E.useState(()=>t.getState().transform);return ds(()=>{let r=null;const i=()=>{const s=t.getState().transform;r&&s[0]===r[0]&&s[1]===r[1]&&s[2]===r[2]||(r=s,n.current&&(n.current.style.transform=Rr(s)))};return i(),t.subscribe(i)},[t]),p.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Rr(o)},children:e})}function Ip(e){const t=mn(),n=E.useRef(!1);E.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Mp=e=>e.panZoom?.syncViewport;function kp(e){const t=te(Mp),n=oe();return E.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Tp(e){return e.connection.inProgress?{...e.connection,to:Pt(e.connection.to,e.transform)}:{...e.connection}}function Ap(e){return Tp}function Pp(e){const t=Ap();return te(t,ie)}const Dp=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function $p({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:a,inProgress:c}=te(Dp,ie);return!(i&&r&&c)?null:p.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:se(["react-flow__connection",ki(a)]),children:p.jsx($s,{style:t,type:n,CustomComponent:o,isValid:a})})})}const $s=({style:e,type:t=Re.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:l,toNode:u,toHandle:f,toPosition:d,pointer:h}=Pp();if(!r)return;if(n)return p.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:d,connectionStatus:ki(o),toNode:u,toHandle:f,pointer:h});let m="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:d};switch(t){case Re.Bezier:[m]=Vi(v);break;case Re.SimpleBezier:[m]=bs(v);break;case Re.Step:[m]=Gn({...v,borderRadius:0});break;case Re.SmoothStep:[m]=Gn(v);break;default:[m]=Yi(v)}return p.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};$s.displayName="ConnectionLine";const jp={};function Hr(e=jp){E.useRef(e),oe(),E.useEffect(()=>{},[e])}function Rp(){oe(),E.useRef(!1),E.useEffect(()=>{},[])}function js({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:h,connectionLineType:m,connectionLineStyle:v,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:w,selectionOnDrag:g,selectionMode:b,multiSelectionKeyCode:C,panActivationKeyCode:S,zoomActivationKeyCode:N,deleteKeyCode:k,onlyRenderVisibleElements:P,elementsSelectable:L,defaultViewport:T,translateExtent:O,minZoom:H,maxZoom:_,preventScrolling:I,defaultMarkerColor:M,zoomOnScroll:A,zoomOnPinch:$,panOnScroll:j,panOnScrollSpeed:z,panOnScrollMode:V,zoomOnDoubleClick:B,panOnDrag:W,autoPanOnSelection:Y,onPaneClick:G,onPaneMouseEnter:J,onPaneMouseMove:R,onPaneMouseLeave:D,onPaneScroll:F,onPaneContextMenu:q,paneClickDistance:K,nodeClickDistance:Z,onEdgeContextMenu:U,onEdgeMouseEnter:ee,onEdgeMouseMove:ne,onEdgeMouseLeave:re,reconnectRadius:ae,onReconnect:Ee,onReconnectStart:ve,onReconnectEnd:be,noDragClassName:Ce,noWheelClassName:ct,noPanClassName:Oe,disableKeyboardA11y:ze,nodeExtent:fe,rfId:Ie,viewport:Me,onViewportChange:Le,nodesDraggable:vn}){return Hr(e),Hr(t),Rp(),Ip(n),kp(Me),p.jsx(Qh,{onPaneClick:G,onPaneMouseEnter:J,onPaneMouseMove:R,onPaneMouseLeave:D,onPaneContextMenu:q,onPaneScroll:F,paneClickDistance:K,deleteKeyCode:k,selectionKeyCode:w,selectionOnDrag:g,selectionMode:b,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:C,panActivationKeyCode:S,zoomActivationKeyCode:N,elementsSelectable:L,zoomOnScroll:A,zoomOnPinch:$,zoomOnDoubleClick:B,panOnScroll:j,panOnScrollSpeed:z,panOnScrollMode:V,panOnDrag:W,autoPanOnSelection:Y,defaultViewport:T,translateExtent:O,minZoom:H,maxZoom:_,onSelectionContextMenu:f,preventScrolling:I,noDragClassName:Ce,noWheelClassName:ct,noPanClassName:Oe,disableKeyboardA11y:ze,onViewportChange:Le,isControlledViewport:!!Me,children:p.jsxs(Cp,{children:[p.jsx(Ep,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:Ee,onReconnectStart:ve,onReconnectEnd:be,onlyRenderVisibleElements:P,onEdgeContextMenu:U,onEdgeMouseEnter:ee,onEdgeMouseMove:ne,onEdgeMouseLeave:re,reconnectRadius:ae,defaultMarkerColor:M,noPanClassName:Oe,disableKeyboardA11y:ze,rfId:Ie}),p.jsx($p,{style:v,type:m,component:x,containerStyle:y}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(ap,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:Z,onlyRenderVisibleElements:P,noPanClassName:Oe,noDragClassName:Ce,disableKeyboardA11y:ze,nodeExtent:fe,rfId:Ie,nodesDraggable:vn}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}js.displayName="GraphView";const Hp=E.memo(js),Op=ji(),Or=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:f,zIndexMode:d="basic"}={})=>{const h=new Map,m=new Map,v=new Map,x=new Map,y=o??t??[],w=n??e??[],g=u??[0,0],b=f??bt;Zi(v,x,y);const{nodesInitialized:C}=Un(w,h,m,{nodeOrigin:g,nodeExtent:b,zIndexMode:d});let S=[0,0,1];if(s&&r&&i){const N=Tt(h,{filter:T=>!!((T.width||T.initialWidth)&&(T.height||T.initialHeight))}),{x:k,y:P,zoom:L}=po(N,r,i,c,l,a?.padding??.1);S=[k,P,L]}return{rfId:"1",width:r??0,height:i??0,transform:S,nodes:w,nodesInitialized:C,nodeLookup:h,parentLookup:m,edges:y,edgeLookup:x,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:bt,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ze.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,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:{...Mi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Op,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ii,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},zp=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:f,zIndexMode:d})=>Jf((h,m)=>{async function v(){const{nodeLookup:x,panZoom:y,fitViewOptions:w,fitViewResolver:g,width:b,height:C,minZoom:S,maxZoom:N}=m();y&&(await Gd({nodes:x,width:b,height:C,panZoom:y,minZoom:S,maxZoom:N},w),g?.resolve(!0),h({fitViewResolver:null}))}return{...Or({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:f,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:x=>{const{nodeLookup:y,parentLookup:w,nodeOrigin:g,nodeExtent:b,elevateNodesOnSelect:C,fitViewQueued:S,zIndexMode:N,nodesSelectionActive:k}=m(),{nodesInitialized:P,hasSelectedNodes:L}=Un(x,y,w,{nodeOrigin:g,nodeExtent:b,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:N}),T=k&&L;S&&P?(v(),h({nodes:x,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:T})):h({nodes:x,nodesInitialized:P,nodesSelectionActive:T})},setEdges:x=>{const{connectionLookup:y,edgeLookup:w}=m();Zi(y,w,x),h({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:w}=m();w(x),h({hasDefaultNodes:!0})}if(y){const{setEdges:w}=m();w(y),h({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:w,parentLookup:g,domNode:b,nodeOrigin:C,nodeExtent:S,debug:N,fitViewQueued:k,zIndexMode:P}=m(),{changes:L,updatedInternals:T}=xf(x,w,g,b,C,S,P);T&&(pf(w,g,{nodeOrigin:C,nodeExtent:S,zIndexMode:P}),k?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),L?.length>0&&(N&&console.log("React Flow: trigger node changes",L),y?.(L)))},updateNodePositions:(x,y=!1)=>{const w=[];let g=[];const{nodeLookup:b,triggerNodeChanges:C,connection:S,updateConnection:N,onNodesChangeMiddlewareMap:k}=m();for(const[P,L]of x){const T=b.get(P),O=!!(T?.expandParent&&T?.parentId&&L?.position),H={id:P,type:"position",position:O?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:y};if(T&&S.inProgress&&S.fromNode.id===T.id){const _=Ue(T,S.fromHandle,X.Left,!0);N({...S,from:_})}O&&T.parentId&&w.push({id:P,parentId:T.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),g.push(H)}if(w.length>0){const{parentLookup:P,nodeOrigin:L}=m(),T=vo(w,b,P,L);g.push(...T)}for(const P of k.values())g=P(g);C(g)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:w,nodes:g,hasDefaultNodes:b,debug:C}=m();if(x?.length){if(b){const S=cs(x,g);w(S)}C&&console.log("React Flow: trigger node changes",x),y?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:w,edges:g,hasDefaultEdges:b,debug:C}=m();if(x?.length){if(b){const S=ls(x,g);w(S)}C&&console.log("React Flow: trigger edge changes",x),y?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:g,triggerNodeChanges:b,triggerEdgeChanges:C}=m();if(y){const S=x.map(N=>Be(N,!0));b(S);return}b(Je(g,new Set([...x]),!0)),C(Je(w))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:g,triggerNodeChanges:b,triggerEdgeChanges:C}=m();if(y){const S=x.map(N=>Be(N,!0));C(S);return}C(Je(w,new Set([...x]))),b(Je(g,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:w,nodes:g,nodeLookup:b,triggerNodeChanges:C,triggerEdgeChanges:S}=m(),N=x||g,k=y||w,P=[];for(const T of N){if(!T.selected)continue;const O=b.get(T.id);O&&(O.selected=!1),P.push(Be(T.id,!1))}const L=[];for(const T of k)T.selected&&L.push(Be(T.id,!1));C(P),S(L)},setMinZoom:x=>{const{panZoom:y,maxZoom:w}=m();y?.setScaleExtent([x,w]),h({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:w}=m();y?.setScaleExtent([w,x]),h({maxZoom:x})},setTranslateExtent:x=>{m().panZoom?.setTranslateExtent(x),h({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:w,triggerEdgeChanges:g,elementsSelectable:b}=m();if(!b)return;const C=y.reduce((N,k)=>k.selected?[...N,Be(k.id,!1)]:N,[]),S=x.reduce((N,k)=>k.selected?[...N,Be(k.id,!1)]:N,[]);w(C),g(S)},setNodeExtent:x=>{const{nodes:y,nodeLookup:w,parentLookup:g,nodeOrigin:b,elevateNodesOnSelect:C,nodeExtent:S,zIndexMode:N}=m();x[0][0]===S[0][0]&&x[0][1]===S[0][1]&&x[1][0]===S[1][0]&&x[1][1]===S[1][1]||(Un(y,w,g,{nodeOrigin:b,nodeExtent:x,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:N}),h({nodeExtent:x}))},panBy:x=>{const{transform:y,width:w,height:g,panZoom:b,translateExtent:C}=m();return wf({delta:x,panZoom:b,transform:y,translateExtent:C,width:w,height:g})},setCenter:async(x,y,w)=>{const{width:g,height:b,maxZoom:C,panZoom:S}=m();if(!S)return!1;const N=typeof w?.zoom<"u"?w.zoom:C;return await S.setViewport({x:g/2-x*N,y:b/2-y*N,zoom:N},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),!0},cancelConnection:()=>{h({connection:{...Mi}})},updateConnection:x=>{h({connection:x})},reset:()=>h({...Or()})}},Object.is);function Rs({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:f,zIndexMode:d,children:h}){const[m]=E.useState(()=>zp({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:l,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:u,nodeExtent:f,zIndexMode:d}));return p.jsx(eh,{value:m,children:p.jsx(Nh,{children:p.jsx(zh,{children:h})})})}function Lp({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:f,nodeExtent:d,zIndexMode:h}){return E.useContext(gn)?p.jsx(p.Fragment,{children:e}):p.jsx(Rs,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:f,nodeExtent:d,zIndexMode:h,children:e})}const Bp={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Vp({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:f,onMoveEnd:d,onConnect:h,onConnectStart:m,onConnectEnd:v,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:w,onNodeMouseMove:g,onNodeMouseLeave:b,onNodeContextMenu:C,onNodeDoubleClick:S,onNodeDragStart:N,onNodeDrag:k,onNodeDragStop:P,onNodesDelete:L,onEdgesDelete:T,onDelete:O,onSelectionChange:H,onSelectionDragStart:_,onSelectionDrag:I,onSelectionDragStop:M,onSelectionContextMenu:A,onSelectionStart:$,onSelectionEnd:j,onBeforeDelete:z,connectionMode:V,connectionLineType:B=Re.Bezier,connectionLineStyle:W,connectionLineComponent:Y,connectionLineContainerStyle:G,deleteKeyCode:J="Backspace",selectionKeyCode:R="Shift",selectionOnDrag:D=!1,selectionMode:F=_t.Full,panActivationKeyCode:q="Space",multiSelectionKeyCode:K=Nt()?"Meta":"Control",zoomActivationKeyCode:Z=Nt()?"Meta":"Control",snapToGrid:U,snapGrid:ee,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:re,nodesDraggable:ae,autoPanOnNodeFocus:Ee,nodesConnectable:ve,nodesFocusable:be,nodeOrigin:Ce=ss,edgesFocusable:ct,edgesReconnectable:Oe,elementsSelectable:ze=!0,defaultViewport:fe=hh,minZoom:Ie=.5,maxZoom:Me=2,translateExtent:Le=bt,preventScrolling:vn=!0,nodeExtent:bn,defaultMarkerColor:Ws="#b1b1b7",zoomOnScroll:Zs=!0,zoomOnPinch:Gs=!0,panOnScroll:qs=!1,panOnScrollSpeed:Us=.5,panOnScrollMode:Ks=Ye.Free,zoomOnDoubleClick:Qs=!0,panOnDrag:Js=!0,onPaneClick:ea,onPaneMouseEnter:ta,onPaneMouseMove:na,onPaneMouseLeave:oa,onPaneScroll:ra,onPaneContextMenu:ia,paneClickDistance:sa=1,nodeClickDistance:aa=0,children:ca,onReconnect:la,onReconnectStart:ua,onReconnectEnd:da,onEdgeContextMenu:fa,onEdgeDoubleClick:ha,onEdgeMouseEnter:pa,onEdgeMouseMove:ga,onEdgeMouseLeave:ma,reconnectRadius:ya=10,onNodesChange:xa,onEdgesChange:wa,noDragClassName:va="nodrag",noWheelClassName:ba="nowheel",noPanClassName:So="nopan",fitView:No,fitViewOptions:Eo,connectOnClick:_a,attributionPosition:Sa,proOptions:Na,defaultEdgeOptions:Ea,elevateNodesOnSelect:Ca=!0,elevateEdgesOnSelect:Ia=!1,disableKeyboardA11y:Co=!1,autoPanOnConnect:Ma,autoPanOnNodeDrag:ka,autoPanOnSelection:Ta=!0,autoPanSpeed:Aa,connectionRadius:Pa,isValidConnection:Da,onError:$a,style:ja,id:Io,nodeDragThreshold:Ra,connectionDragThreshold:Ha,viewport:Oa,onViewportChange:za,width:La,height:Ba,colorMode:Va="light",debug:Fa,onScroll:Mo,ariaLabelConfig:Ya,zIndexMode:ko="basic",...Xa},Wa){const _n=Io||"1",Za=yh(Va),Ga=E.useCallback(To=>{To.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Mo?.(To)},[Mo]);return p.jsx("div",{"data-testid":"rf__wrapper",...Xa,onScroll:Ga,style:{...ja,...Bp},ref:Wa,className:se(["react-flow",r,Za]),id:Io,role:"application",children:p.jsxs(Lp,{nodes:e,edges:t,width:La,height:Ba,fitView:No,fitViewOptions:Eo,minZoom:Ie,maxZoom:Me,nodeOrigin:Ce,nodeExtent:bn,zIndexMode:ko,children:[p.jsx(mh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:m,onConnectEnd:v,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:ae,autoPanOnNodeFocus:Ee,nodesConnectable:ve,nodesFocusable:be,edgesFocusable:ct,edgesReconnectable:Oe,elementsSelectable:ze,elevateNodesOnSelect:Ca,elevateEdgesOnSelect:Ia,minZoom:Ie,maxZoom:Me,nodeExtent:bn,onNodesChange:xa,onEdgesChange:wa,snapToGrid:U,snapGrid:ee,connectionMode:V,translateExtent:Le,connectOnClick:_a,defaultEdgeOptions:Ea,fitView:No,fitViewOptions:Eo,onNodesDelete:L,onEdgesDelete:T,onDelete:O,onNodeDragStart:N,onNodeDrag:k,onNodeDragStop:P,onSelectionDrag:I,onSelectionDragStart:_,onSelectionDragStop:M,onMove:u,onMoveStart:f,onMoveEnd:d,noPanClassName:So,nodeOrigin:Ce,rfId:_n,autoPanOnConnect:Ma,autoPanOnNodeDrag:ka,autoPanSpeed:Aa,onError:$a,connectionRadius:Pa,isValidConnection:Da,selectNodesOnDrag:re,nodeDragThreshold:Ra,connectionDragThreshold:Ha,onBeforeDelete:z,debug:Fa,ariaLabelConfig:Ya,zIndexMode:ko}),p.jsx(Hp,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:g,onNodeMouseLeave:b,onNodeContextMenu:C,onNodeDoubleClick:S,nodeTypes:i,edgeTypes:s,connectionLineType:B,connectionLineStyle:W,connectionLineComponent:Y,connectionLineContainerStyle:G,selectionKeyCode:R,selectionOnDrag:D,selectionMode:F,deleteKeyCode:J,multiSelectionKeyCode:K,panActivationKeyCode:q,zoomActivationKeyCode:Z,onlyRenderVisibleElements:ne,defaultViewport:fe,translateExtent:Le,minZoom:Ie,maxZoom:Me,preventScrolling:vn,zoomOnScroll:Zs,zoomOnPinch:Gs,zoomOnDoubleClick:Qs,panOnScroll:qs,panOnScrollSpeed:Us,panOnScrollMode:Ks,panOnDrag:Js,autoPanOnSelection:Ta,onPaneClick:ea,onPaneMouseEnter:ta,onPaneMouseMove:na,onPaneMouseLeave:oa,onPaneScroll:ra,onPaneContextMenu:ia,paneClickDistance:sa,nodeClickDistance:aa,onSelectionContextMenu:A,onSelectionStart:$,onSelectionEnd:j,onReconnect:la,onReconnectStart:ua,onReconnectEnd:da,onEdgeContextMenu:fa,onEdgeDoubleClick:ha,onEdgeMouseEnter:pa,onEdgeMouseMove:ga,onEdgeMouseLeave:ma,reconnectRadius:ya,defaultMarkerColor:Ws,noDragClassName:va,noWheelClassName:ba,noPanClassName:So,rfId:_n,disableKeyboardA11y:Co,nodeExtent:bn,viewport:Oa,onViewportChange:za,nodesDraggable:ae}),p.jsx(fh,{onSelectionChange:H}),ca,p.jsx(ah,{proOptions:Na,position:Sa}),p.jsx(sh,{rfId:_n,disableKeyboardA11y:Co})]})})}var Fp=us(Vp);function Yp({dimensions:e,lineWidth:t,variant:n,className:o}){return p.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 Xp({radius:e,className:t}){return p.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var Ae;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ae||(Ae={}));const Wp={[Ae.Dots]:1,[Ae.Lines]:1,[Ae.Cross]:6},Zp=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Hs({id:e,variant:t=Ae.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:a,style:c,className:l,patternClassName:u}){const f=E.useRef(null),{transform:d,patternId:h}=te(Zp,ie),m=o||Wp[t],v=t===Ae.Dots,x=t===Ae.Cross,y=Array.isArray(n)?n:[n,n],w=[y[0]*d[2]||1,y[1]*d[2]||1],g=m*d[2],b=Array.isArray(i)?i:[i,i],C=x?[g,g]:w,S=[b[0]*d[2]+C[0]/2,b[1]*d[2]+C[1]/2],N=`${h}${e||""}`;return p.jsxs("svg",{className:se(["react-flow__background",l]),style:{...c,...yn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:f,"data-testid":"rf__background",children:[p.jsx("pattern",{id:N,x:d[0]%w[0],y:d[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:v?p.jsx(Xp,{radius:g/2,className:u}):p.jsx(Yp,{dimensions:C,lineWidth:r,variant:t,className:u})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${N})`})]})}Hs.displayName="Background";const Gp=E.memo(Hs);function qp(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Up(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Kp(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 Qp(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Jp(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Bt({children:e,className:t,...n}){return p.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const eg=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Os({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:l,children:u,position:f="bottom-left",orientation:d="vertical","aria-label":h}){const m=oe(),{isInteractive:v,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:w}=te(eg,ie),{zoomIn:g,zoomOut:b,fitView:C}=mn(),S=()=>{g(),i?.()},N=()=>{b(),s?.()},k=()=>{C(r),a?.()},P=()=>{m.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c?.(!v)},L=d==="horizontal"?"horizontal":"vertical";return p.jsxs(Ke,{className:se(["react-flow__controls",L,l]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??w["controls.ariaLabel"],children:[t&&p.jsxs(p.Fragment,{children:[p.jsx(Bt,{onClick:S,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:y,children:p.jsx(qp,{})}),p.jsx(Bt,{onClick:N,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:x,children:p.jsx(Up,{})})]}),n&&p.jsx(Bt,{className:"react-flow__controls-fitview",onClick:k,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:p.jsx(Kp,{})}),o&&p.jsx(Bt,{className:"react-flow__controls-interactive",onClick:P,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:v?p.jsx(Jp,{}):p.jsx(Qp,{})}),u]})}Os.displayName="Controls";const tg=E.memo(Os);function ng({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:a,strokeWidth:c,className:l,borderRadius:u,shapeRendering:f,selected:d,onClick:h}){const{background:m,backgroundColor:v}=i||{},x=s||m||v;return p.jsx("rect",{className:se(["react-flow__minimap-node",{selected:d},l]),x:t,y:n,rx:u,ry:u,width:o,height:r,style:{fill:x,stroke:a,strokeWidth:c},shapeRendering:f,onClick:h?y=>h(y,e):void 0})}const og=E.memo(ng),rg=e=>e.nodes.map(t=>t.id),jn=e=>e instanceof Function?e:()=>e;function ig({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=og,onClick:s}){const a=te(rg,ie),c=jn(t),l=jn(e),u=jn(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:a.map(d=>p.jsx(ag,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:f},d))})}function sg({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:l,x:u,y:f,width:d,height:h}=te(m=>{const v=m.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const x=v.internals.userNode,{x:y,y:w}=v.internals.positionAbsolute,{width:g,height:b}=we(x);return{node:x,x:y,y:w,width:g,height:b}},ie);return!l||l.hidden||!Ri(l)?null:p.jsx(a,{x:u,y:f,width:d,height:h,style:l.style,selected:!!l.selected,className:o(l),color:t(l),borderRadius:r,strokeColor:n(l),strokeWidth:i,shapeRendering:s,onClick:c,id:l.id})}const ag=E.memo(sg);var cg=E.memo(ig);const lg=200,ug=150,dg=e=>!e.hidden,fg=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?Di(Tt(e.nodeLookup,{filter:dg}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},zr=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,hg=(e,t)=>zr(e.viewBB,t.viewBB)&&zr(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,pg="react-flow__minimap-desc";function zs({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:f,position:d="bottom-right",onClick:h,onNodeClick:m,pannable:v=!1,zoomable:x=!1,ariaLabel:y,inversePan:w,zoomStep:g=1,offsetScale:b=5}){const C=oe(),S=E.useRef(null),{boundingRect:N,viewBB:k,rfId:P,panZoom:L,translateExtent:T,flowWidth:O,flowHeight:H,ariaLabelConfig:_}=te(fg,hg),I=e?.width??lg,M=e?.height??ug,A=N.width/I,$=N.height/M,j=Math.max(A,$),z=j*I,V=j*M,B=b*j,W=N.x-(z-N.width)/2-B,Y=N.y-(V-N.height)/2-B,G=z+B*2,J=V+B*2,R=`${pg}-${P}`,D=E.useRef(0),F=E.useRef();D.current=j,E.useEffect(()=>{if(S.current&&L)return F.current=Mf({domNode:S.current,panZoom:L,getTransform:()=>C.getState().transform,getViewScale:()=>D.current}),()=>{F.current?.destroy()}},[L]),E.useEffect(()=>{F.current?.update({translateExtent:T,width:O,height:H,inversePan:w,pannable:v,zoomStep:g,zoomable:x})},[v,x,w,g,T,O,H]);const q=h?U=>{const[ee,ne]=F.current?.pointer(U)||[0,0];h(U,{x:ee,y:ne})}:void 0,K=m?E.useCallback((U,ee)=>{const ne=C.getState().nodeLookup.get(ee).internals.userNode;m(U,ne)},[]):void 0,Z=y??_["minimap.ariaLabel"];return p.jsx(Ke,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*j: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:p.jsxs("svg",{width:I,height:M,viewBox:`${W} ${Y} ${G} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":R,ref:S,onClick:q,children:[Z&&p.jsx("title",{id:R,children:Z}),p.jsx(cg,{onClick:K,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-B},${Y-B}h${G+B*2}v${J+B*2}h${-G-B*2}z
7
+ M${k.x},${k.y}h${k.width}v${k.height}h${-k.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}zs.displayName="MiniMap";const gg=E.memo(zs),mg=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,yg={[at.Line]:"right",[at.Handle]:"bottom-right"};function xg({nodeId:e,position:t,variant:n=at.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:d,autoScale:h=!0,shouldResize:m,onResizeStart:v,onResize:x,onResizeEnd:y}){const w=gs(),g=typeof e=="string"?e:w,b=oe(),C=E.useRef(null),S=n===at.Handle,N=te(E.useCallback(mg(S&&h),[S,h]),ie),k=E.useRef(null),P=t??yg[n];E.useEffect(()=>{if(!(!C.current||!g))return k.current||(k.current=Bf({domNode:C.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:T,transform:O,snapGrid:H,snapToGrid:_,nodeOrigin:I,domNode:M}=b.getState();return{nodeLookup:T,transform:O,snapGrid:H,snapToGrid:_,nodeOrigin:I,paneDomNode:M}},onChange:(T,O)=>{const{triggerNodeChanges:H,nodeLookup:_,parentLookup:I,nodeOrigin:M}=b.getState(),A=[],$={x:T.x,y:T.y},j=_.get(g);if(j&&j.expandParent&&j.parentId){const z=j.origin??M,V=T.width??j.measured.width??0,B=T.height??j.measured.height??0,W={id:j.id,parentId:j.parentId,rect:{width:V,height:B,...Hi({x:T.x??j.position.x,y:T.y??j.position.y},{width:V,height:B},j.parentId,_,z)}},Y=vo([W],_,I,M);A.push(...Y),$.x=T.x?Math.max(z[0]*V,T.x):void 0,$.y=T.y?Math.max(z[1]*B,T.y):void 0}if($.x!==void 0&&$.y!==void 0){const z={id:g,type:"position",position:{...$}};A.push(z)}if(T.width!==void 0&&T.height!==void 0){const V={id:g,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:T.width,height:T.height}};A.push(V)}for(const z of O){const V={...z,type:"position"};A.push(V)}H(A)},onEnd:({width:T,height:O})=>{const H={id:g,type:"dimensions",resizing:!1,dimensions:{width:T,height:O}};b.getState().triggerNodeChanges([H])}})),k.current.update({controlPosition:P,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:f,resizeDirection:d,onResizeStart:v,onResize:x,onResizeEnd:y,shouldResize:m}),()=>{k.current?.destroy()}},[P,a,c,l,u,f,v,x,y,m]);const L=P.split("-");return p.jsx("div",{className:se(["react-flow__resize-control","nodrag",...L,n,o]),ref:C,style:{...r,scale:N,...s&&{[S?"backgroundColor":"borderColor"]:s}},children:i})}E.memo(xg);const Rn=5,Gt=240,wg=180,vg=420,Lr=[{id:"top",position:X.Top},{id:"right",position:X.Right},{id:"bottom",position:X.Bottom},{id:"left",position:X.Left}];function bg(e,t){const n=ec({model:e.model,provider:e.provider,mediaType:Vt(e.imageUrl)?"video":"image",videoContinuity:e.videoContinuity});return n.derivation?t(`provenance.${n.derivation}`):null}function _g(e){const t=/^(\d+)x(\d+)$/.exec(e??"");if(!t)return Gt;const n=Number(t[1]),o=Number(t[2]);if(!Number.isFinite(n)||!Number.isFinite(o)||n<=0||o<=0)return Gt;const r=Gt*(n/o);return Math.round(Math.min(vg,Math.max(wg,r)))}function Sg({id:e,data:t,selected:n}){const{t:o}=ce(),r=t,i=Q(R=>R.updateNodePrompt),s=Q(R=>R.addNodeReferences),a=Q(R=>R.addNodeReferenceFromUrl),c=Q(R=>R.readDroppedImageMetadata),l=Q(R=>R.removeNodeReference),u=Q(R=>R.generateNode),f=Q(R=>R.generateNodeInPlace),d=Q(R=>R.generateNodeVariation),h=Q(R=>R.animateImage),m=Q(R=>R.addChildNode),v=Q(R=>R.duplicateBranchRoot),x=Q(R=>R.deleteNode),y=E.useRef(null),[w,g]=E.useState(!1),[b,C]=E.useState(!1),S=r.referenceImages??[],N=r.status==="pending"||r.status==="reconciling",k=!N&&S.length<Rn,P={"--node-preview-w":`${_g(r.size)}px`,"--node-preview-h":`${Gt}px`},L=E.useCallback(R=>i(e,R.target.value),[e,i]),T=E.useCallback(()=>{u(e)},[e,u]),O=E.useCallback(()=>{f(e)},[e,f]),H=E.useCallback(()=>{d(e)},[e,d]),_=E.useCallback(()=>{r.status==="ready"&&m(e)},[e,r.status,m]),I=E.useCallback(()=>{if(r.status!=="ready"||!r.imageUrl||Vt(r.imageUrl))return;const R=r.imageUrl.replace(/^\/generated\//,"");h(R,r.prompt)},[r.status,r.imageUrl,r.prompt,h]),M=E.useCallback(()=>{v(e)},[e,v]),A=E.useCallback(()=>x(e),[e,x]),$=R=>{if(!R)return[];const D=[];for(const F of Array.from(R)){if(F.kind!=="file"||!F.type.startsWith("image/"))continue;const q=F.getAsFile();q&&D.push(q)}return D},j=async R=>{R.length!==0&&(R.length===1&&await c(R[0],e)||await s(e,R))},z=async R=>{R.preventDefault(),R.stopPropagation(),g(!1);const D=R.dataTransfer.getData("application/ima2-ref");if(D){if(!k)return;try{const q=JSON.parse(D),K=q.url||q.image;K&&a(e,K,q.filename)}catch{}return}const F=Array.from(R.dataTransfer.files).filter(q=>q.type.startsWith("image/"));F.length===1&&await c(F[0],e)||k&&F.length>0&&s(e,F)},V=R=>{R.preventDefault(),R.stopPropagation(),k&&!w&&g(!0)},B=R=>{R.currentTarget.contains(R.relatedTarget)||g(!1)},W=R=>{const D=$(R.clipboardData?.items??null);if(D.length===0||(R.preventDefault(),R.stopPropagation(),!k))return;const F=Rn-S.length;s(e,D.slice(0,F))},G=(()=>{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,Qa(r.reasoningEffort),Ja(r.model,r.provider),bg(r,o)].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.errorInfo?.message??r.error??o("node.errorUnknown")});default:return""}})(),J=r.status==="error"?r.errorInfo?.action??"retry":null;return p.jsxs("div",{className:`image-node image-node--${r.status}${n?" image-node--selected":""}`,style:P,children:[Lr.map(({id:R,position:D})=>p.jsx(He,{type:"target",id:`target-${R}`,position:D,className:`image-node__handle image-node__handle--target image-node__handle--${R}`},`target-${R}`)),p.jsx("div",{className:"image-node__preview",children:r.imageUrl&&r.status!=="asset-missing"?Vt(r.imageUrl)?p.jsx("video",{src:r.imageUrl,controls:!0,loop:!0,playsInline:!0,muted:!0,className:"image-node__video nodrag"}):p.jsx("img",{src:r.imageUrl,alt:o("node.nodeImageAlt")}):N&&r.partialImageUrl?p.jsx("img",{className:"image-node__partial",src:r.partialImageUrl,alt:o("node.partialImageAlt")}):N?p.jsx("div",{className:"image-node__skeleton"}):r.status==="asset-missing"?p.jsx("div",{className:"image-node__placeholder",children:o("node.noAsset")}):r.status==="stale"?p.jsx("div",{className:"image-node__placeholder",children:o("node.stateStale")}):p.jsx("div",{className:"image-node__placeholder",children:o("node.noImage")})}),p.jsxs("div",{className:`image-node__composer nodrag${w?" is-dragging":""}`,onDrop:z,onDragOver:V,onDragLeave:B,onPaste:W,children:[S.length>0?p.jsx("div",{className:"image-node__refs",children:S.map((R,D)=>p.jsxs("div",{className:"image-node__ref-chip",title:o("node.refAlt",{n:D+1}),children:[p.jsx("img",{src:R,alt:o("node.refAlt",{n:D+1})}),p.jsx("button",{type:"button",className:"image-node__ref-remove",onClick:()=>l(e,D),disabled:N,"aria-label":o("node.removeRef",{n:D+1}),children:"×"})]},D))}):null,p.jsx("textarea",{className:"image-node__prompt",value:r.prompt,onChange:L,onKeyDown:R=>R.stopPropagation(),placeholder:r.parentServerNodeId?o("node.editPromptPlaceholder"):o("node.promptPlaceholder"),rows:2,disabled:N}),p.jsxs("div",{className:"image-node__composer-bar",children:[p.jsx("button",{type:"button",className:"image-node__attach",onClick:()=>k&&y.current?.click(),disabled:!k,title:r.parentServerNodeId?o("node.nodeRefsUsedWithParent"):o("node.attachRefTitle"),children:o("node.attachRef")}),w?p.jsx("span",{className:"image-node__drop-hint",children:o("node.dropRefs")}):S.length>0?p.jsxs("span",{className:"image-node__ref-count",children:[S.length,"/",Rn]}):null]}),p.jsx("input",{ref:y,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:R=>{const D=Array.from(R.target.files??[]);D.length>0&&j(D),R.target.value=""}})]}),p.jsxs("div",{className:"image-node__footer nodrag",children:[p.jsx("span",{className:"image-node__status",title:r.errorInfo?.code?`${G} [${r.errorInfo.code}]`:G,children:G}),J==="retry"?p.jsx("button",{type:"button",className:"image-node__retry",onClick:O,disabled:N,title:o("node.retryTitle"),children:o("node.retry")}):J==="auth"?p.jsx("span",{className:"image-node__error-cta",children:o("node.errorAuthCta")}):J==="fix-input"?p.jsx("span",{className:"image-node__error-cta",children:o("node.errorFixCta")}):null,p.jsxs("div",{className:"image-node__actions",children:[p.jsxs("div",{style:{position:"relative"},children:[p.jsx("button",{type:"button",onClick:()=>C(R=>!R),disabled:!r.prompt?.trim(),title:o("promptLibrary.saveTitle"),"aria-label":o("promptLibrary.saveTitle"),"aria-haspopup":"dialog","aria-expanded":b,children:p.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",width:"15",height:"15",children:p.jsx("path",{d:"M6.5 3.75h11a.75.75 0 0 1 .75.75v15.03a.5.5 0 0 1-.77.42L12 16.4l-5.48 3.55a.5.5 0 0 1-.77-.42V4.5a.75.75 0 0 1 .75-.75Z",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})})}),b&&p.jsx(Ka,{text:r.prompt||"",onClose:()=>C(!1)})]}),r.status==="ready"?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",onClick:O,disabled:N,title:o("node.regenerateTitle"),"aria-label":o("node.regenerateTitle"),children:"↻"}),p.jsx("button",{type:"button",onClick:H,disabled:N,title:o("node.newVariationTitle"),"aria-label":o("node.newVariationTitle"),children:o("node.newVariation")}),!Vt(r.imageUrl)&&p.jsx("button",{type:"button",onClick:I,disabled:N,title:o("node.animateTitle",{fallback:"Animate"}),"aria-label":o("node.animateTitle",{fallback:"Animate"}),children:"▶"})]}):p.jsx("button",{type:"button",className:"image-node__generate",onClick:T,disabled:N,title:o("node.generateTitle"),"aria-label":o("node.generateTitle"),children:o("node.generate")}),r.status==="ready"?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",onClick:_,title:o("node.addChildTitle"),"aria-label":o("node.addChildTitle"),children:o("node.addChild")}),p.jsx("button",{type:"button",onClick:M,title:o("node.duplicateBranchTitle"),"aria-label":o("node.duplicateBranchTitle"),children:o("node.duplicateBranch")})]}):null,p.jsx("button",{type:"button",onClick:A,className:"image-node__del",title:o("node.deleteTitle"),"aria-label":o("node.deleteTitle"),children:"×"})]})]}),Lr.map(({id:R,position:D})=>p.jsx(He,{type:"source",id:`source-${R}`,position:D,className:`image-node__handle image-node__handle--source image-node__handle--${R}`},`source-${R}`))]})}const Ng=E.memo(Sg);function Eg(){const{t:e}=ce(),t=Q(w=>w.graphNodes),n=Q(w=>w.graphEdges),o=Q(w=>w.nodeSelectionMode),r=Q(w=>w.nodeBatchRunning),i=Q(w=>w.nodeBatchStopping),s=Q(w=>w.toggleNodeSelectionMode),a=Q(w=>w.selectAllGraphNodes),c=Q(w=>w.clearNodeSelection),l=Q(w=>w.runNodeBatch),u=Q(w=>w.cancelNodeBatch),f=Q(w=>w.disconnectEdges),d=t.filter(w=>w.selected).map(w=>w.id),h=n.filter(w=>w.selected).map(w=>w.id),m=new Set(d),v=t.filter(w=>m.has(w.id)&&w.type!=="elementReferenceNode"&&!tc(w)).length,x=nc(n,d).length,y=w=>{l(w)};return p.jsxs(Ke,{position:"top-center",className:"node-batch-bar nodrag",children:[p.jsx("button",{type:"button",onClick:s,"aria-pressed":o,children:e(o?"nodeBatch.selectionOn":"nodeBatch.selectionOff")}),p.jsx("button",{type:"button",onClick:a,disabled:t.length===0,children:e("nodeBatch.selectAll")}),h.length>0?p.jsx("button",{type:"button",className:"node-batch-bar__danger",onClick:()=>f(h),title:e("edge.disconnectTitle"),"aria-label":e("edge.disconnectTitle"),children:e("edge.disconnect")}):null,d.length>0?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"node-batch-bar__meta",children:e("nodeBatch.summary",{selected:d.length,missing:v,stale:x})}),p.jsx("button",{type:"button",onClick:()=>y("missing-only"),disabled:r,children:e("nodeBatch.generateMissing")}),p.jsx("button",{type:"button",onClick:()=>y("regenerate-all"),disabled:r,children:e("nodeBatch.regenerateSelected")}),r?p.jsx("button",{type:"button",onClick:u,disabled:i,children:e(i?"nodeBatch.stopping":"nodeBatch.stopRemaining")}):null,p.jsx("button",{type:"button",onClick:c,disabled:r,children:e("nodeBatch.clear")})]}):null]})}function Cg({data:e,selected:t}){const{t:n}=ce(),o=E.useCallback(()=>{e.elementId&&(e.onOpenAssets?e.onOpenAssets(e.elementId):window.dispatchEvent(new CustomEvent("ima2:open-assets-detail",{detail:{assetId:e.elementId}})))},[e]),r=e.elementName??n("nodeStudio.elementNode.untitled");return p.jsxs("div",{className:`element-reference-node${t?" is-selected":""}${e.missing?" is-missing":""}${e.compact?" is-compact":""}`,onDoubleClick:o,style:{"--element-thumb":e.thumbnailUrl?`url(${JSON.stringify(e.thumbnailUrl)})`:"none"},children:[p.jsx(He,{type:"source",id:"refs",position:X.Right,className:"element-reference-node__handle element-reference-node__handle--refs","aria-label":n("nodeStudio.elementNode.referencesOutput")}),p.jsx(He,{type:"source",id:"notes",position:X.Bottom,className:"element-reference-node__handle element-reference-node__handle--notes","aria-label":n("nodeStudio.elementNode.notesOutput")}),p.jsxs("div",{className:"element-reference-node__header",children:[p.jsx("span",{className:"element-reference-node__kind",children:n("nodeStudio.elementNode.kind")}),p.jsx("strong",{children:r})]}),p.jsxs("div",{className:"element-reference-node__body",children:[p.jsx("div",{className:"element-reference-node__thumbnail","aria-hidden":"true"}),e.compact?null:p.jsxs("div",{children:[p.jsx("span",{className:"element-reference-node__ref-count",children:n(e.refCount===1?"nodeStudio.elementNode.referenceCountOne":"nodeStudio.elementNode.referenceCount",{count:e.refCount})}),e.notesPreview?p.jsx("p",{children:e.notesPreview}):null]})]}),e.missing?p.jsx("p",{className:"element-reference-node__warning",role:"alert",children:n("nodeStudio.elementNode.missing")}):null]})}const Ig=E.memo(Cg);function Hn({title:e,description:t,action:n,disabled:o,onClick:r}){return p.jsxs("button",{type:"button",className:"node-empty-state__choice",disabled:o,onClick:r,children:[p.jsx("span",{className:"node-empty-state__choice-title",children:e}),p.jsx("span",{className:"node-empty-state__choice-description",children:t}),p.jsx("span",{className:"node-empty-state__choice-action",children:n})]})}function Mg({hasRecentGraph:e,onStartBlank:t,onOpenTemplates:n,onResumeRecent:o}){const{t:r}=ce();return p.jsxs("section",{className:"node-empty-state","aria-labelledby":"node-empty-state-title",children:[p.jsxs("div",{className:"node-empty-state__intro",children:[p.jsx("p",{className:"node-empty-state__eyebrow",children:r("nodeStudio.name")}),p.jsx("h2",{id:"node-empty-state-title",children:r("nodeStudio.empty.title")}),p.jsx("p",{children:r("nodeStudio.empty.description")})]}),p.jsxs("div",{className:"node-empty-state__choices",children:[p.jsx(Hn,{title:r("nodeStudio.empty.blankTitle"),description:r("nodeStudio.empty.blankDescription"),action:r("nodeStudio.empty.blankAction"),onClick:t}),p.jsx(Hn,{title:r("nodeStudio.empty.templateTitle"),description:r("nodeStudio.empty.templateDescription"),action:r("nodeStudio.empty.templateAction"),onClick:n}),p.jsx(Hn,{title:r("nodeStudio.empty.recentTitle"),description:r(e?"nodeStudio.empty.recentDescription":"nodeStudio.empty.recentUnavailable"),action:r("nodeStudio.empty.recentAction"),disabled:!e,onClick:()=>{o()}})]})]})}const Jn=["oauth","api","grok","gemini-api"];function Br(e,t){return{id:`variant-${e+1}`,label:t,provider:Jn[e%Jn.length],model:"",size:""}}function kg(e){return{id:e.id,label:e.label.trim(),provider:e.provider,settingsPatch:{...e.model.trim()?{model:e.model.trim()}:{},...e.size.trim()?{size:e.size.trim()}:{}}}}function Tg({sourceLabel:e,onApply:t,onClose:n}){const{t:o}=ce(),[r,i]=E.useState(()=>[0,1].map(f=>Br(f,o("nodeStudio.branch.defaultVariant",{index:f+1})))),s=E.useRef(2),a=(f,d)=>{i(h=>h.map((m,v)=>v===f?{...m,...d}:m))},c=f=>i(d=>d.filter((h,m)=>m!==f)),l=()=>i(f=>{if(f.length>=4)return f;const d=s.current++,h=Br(d,o("nodeStudio.branch.defaultVariant",{index:d+1}));return[...f,h]}),u=()=>t(r.map(kg));return p.jsxs("section",{className:"node-template-picker",role:"document",children:[p.jsxs("header",{children:[p.jsxs("div",{children:[p.jsx("p",{className:"node-template-picker__eyebrow",children:o("nodeStudio.branch.eyebrow")}),p.jsx("h2",{id:"node-branch-dialog-title",children:o("nodeStudio.branch.title")}),p.jsx("p",{children:e})]}),p.jsx("button",{type:"button","aria-label":o("nodeStudio.branch.close"),onClick:n,children:"×"})]}),p.jsx("div",{className:"node-template-picker__sections",children:r.map((f,d)=>p.jsxs("fieldset",{className:"node-template-picker__card",children:[p.jsx("legend",{children:o("nodeStudio.branch.variantLegend",{index:d+1})}),p.jsxs("label",{className:"node-template-picker__search",children:[p.jsx("span",{children:o("nodeStudio.branch.label")}),p.jsx("input",{autoFocus:d===0,value:f.label,onChange:h=>a(d,{label:h.target.value})})]}),p.jsxs("label",{className:"node-template-picker__search",children:[p.jsx("span",{children:o("nodeStudio.branch.provider")}),p.jsx("select",{value:f.provider,onChange:h=>a(d,{provider:h.target.value}),children:Jn.map(h=>p.jsx("option",{value:h,children:h},h))})]}),p.jsxs("label",{className:"node-template-picker__search",children:[p.jsx("span",{children:o("nodeStudio.branch.modelOverride")}),p.jsx("input",{value:f.model,onChange:h=>a(d,{model:h.target.value}),placeholder:o("nodeStudio.branch.currentModel")})]}),p.jsxs("label",{className:"node-template-picker__search",children:[p.jsx("span",{children:o("nodeStudio.branch.sizeOverride")}),p.jsx("input",{value:f.size,onChange:h=>a(d,{size:h.target.value}),placeholder:o("nodeStudio.branch.currentSize")})]}),p.jsx("button",{type:"button",disabled:r.length<=2,onClick:()=>c(d),children:o("nodeStudio.branch.remove")})]},f.id))}),p.jsxs("footer",{children:[p.jsx("button",{type:"button",disabled:r.length>=4,onClick:l,children:o("nodeStudio.branch.add")}),p.jsx("span",{}),p.jsx("button",{type:"button",onClick:n,children:o("nodeStudio.branch.cancel")}),p.jsx("button",{type:"button",className:"node-template-picker__copy",disabled:r.some(f=>!f.label.trim()),onClick:u,children:o("nodeStudio.branch.create")})]})]})}const Ag={prompt:["prompt","element-notes"],image:["image","images","mask","element-refs","any-media"],images:["images","element-refs","any-media"],video:["video","any-media"],mask:["mask","any-media"],"element-refs":["image","images","element-refs","any-media"],"element-notes":["prompt","element-notes"],settings:["settings"],"any-media":["image","images","video","mask","any-media"]};function eo(e,t){const n=t.equivalentHandleIds??[t.handleId];return typeof e=="string"&&n.includes(e)}function Pg(e,t,n){return n.some(o=>o.source===e.nodeId&&o.target===t.nodeId&&eo(o.sourceHandle,e)&&eo(o.targetHandle,t))}function Dg(e,t){return t.some(n=>n.target===e.nodeId&&eo(n.targetHandle,e))}function Ls(e,t){return Ag[e].includes(t)}function Bs(e,t,n){return e.direction!=="output"||t.direction!=="input"?{allowed:!1,reason:"SAME_DIRECTION"}:e.nodeId===t.nodeId?{allowed:!1,reason:"SELF_EDGE"}:Pg(e,t,n.edges)?{allowed:!1,reason:"DUPLICATE_EDGE"}:Ls(e.type,t.type)?oc(n.edges,e.nodeId,t.nodeId)?{allowed:!1,reason:"CYCLE"}:!t.acceptsMany&&Dg(t,n.edges)?{allowed:!1,reason:"CARDINALITY"}:{allowed:!0}:{allowed:!1,reason:"TYPE_MISMATCH"}}const $g={input:"nodeStudio.palette.categories.input",generate:"nodeStudio.palette.categories.generate",transform:"nodeStudio.palette.categories.transform",reference:"nodeStudio.palette.categories.reference",output:"nodeStudio.palette.categories.output"},dt=["input","generate","transform","reference","output"];function et(e,t,n){const o=`nodeStudio.commands.${t.type}.${n}`,r=e(o);return r===o?t[n]:r}function jg(e,t){const n=`nodeStudio.portTypes.${t}`,o=e(n);return o===n?t:o}function Rg(e,t,n){const o=t.toLocaleLowerCase(),r=et(n,e,"label").toLocaleLowerCase();return r.startsWith(o)?0:r.includes(o)?1:e.keywords.some(i=>i.toLocaleLowerCase().includes(o))?2:et(n,e,"description").toLocaleLowerCase().includes(o)?3:-1}function Hg(e,t){return t?t.direction==="output"&&e.inputPorts.some(n=>Ls(t.type,n.type)):!0}function Og({open:e,anchor:t,sourcePort:n,commands:o,recentCommandTypes:r=[],onInsert:i,onClose:s}){const{t:a}=ce(),c=E.useId(),l=E.useRef(null),[u,f]=E.useState(""),[d,h]=E.useState(0),m=E.useMemo(()=>o.filter(S=>Hg(S,n)).map(S=>({command:S,score:Rg(S,u,a)})).filter(S=>!u||S.score>=0).sort((S,N)=>S.score-N.score||et(a,S.command,"label").localeCompare(et(a,N.command,"label"))).map(S=>S.command),[o,u,n,a]),v=u?m:[...r.map(S=>m.find(N=>N.type===S)).filter(S=>!!S).slice(0,5),...m.filter(S=>!r.includes(S.type))],x=E.useMemo(()=>dt.flatMap(S=>v.filter(N=>N.category===S)),[v]);if(E.useEffect(()=>{e&&(f(""),h(0),requestAnimationFrame(()=>l.current?.focus()))},[e]),E.useEffect(()=>{h(S=>Math.min(S,Math.max(0,x.length-1)))},[x.length]),!e)return null;const y=()=>{const S=x[d];S&&i(S)},w=S=>{if(S.stopPropagation(),S.key==="Escape")S.preventDefault(),s();else if(S.key==="ArrowDown")S.preventDefault(),h(N=>(N+1)%Math.max(1,x.length));else if(S.key==="ArrowUp")S.preventDefault(),h(N=>(N-1+x.length)%Math.max(1,x.length));else if(S.key==="Home")S.preventDefault(),h(0);else if(S.key==="End")S.preventDefault(),h(Math.max(0,x.length-1));else if(S.key==="Enter")S.preventDefault(),y();else if(S.key==="Tab"){S.preventDefault();const N=x[d]?.category,k=dt.indexOf(N??"input"),P=dt.slice(k+1).concat(dt.slice(0,k)).find(L=>L!==N&&x.some(T=>T.category===L));P&&h(x.findIndex(L=>L.category===P))}else(S.metaKey||S.ctrlKey)&&S.key==="Backspace"&&(S.preventDefault(),f(""))},g=n?jg(a,n.type):null,b=Math.max(8,Math.min(t.clientX,window.innerWidth-372)),C=Math.max(8,Math.min(t.clientY,window.innerHeight-220));return p.jsxs("section",{className:"node-command-palette",style:{left:b,top:C},"aria-label":a("nodeStudio.palette.ariaLabel"),children:[p.jsx("input",{ref:l,className:"node-command-palette__search",value:u,onChange:S=>f(S.target.value),onKeyDown:w,placeholder:g?a("nodeStudio.palette.compatiblePlaceholder",{portType:g}):a("nodeStudio.palette.searchPlaceholder"),"aria-controls":c,"aria-activedescendant":x[d]?`${c}-${x[d].type}`:void 0}),g?p.jsx("p",{className:"node-command-palette__filter",children:a("nodeStudio.palette.filter",{portType:g})}):null,x.length===0?p.jsx("p",{className:"node-command-palette__empty",children:g?a("nodeStudio.palette.emptyCompatible",{portType:g}):a("nodeStudio.palette.emptySearch")}):p.jsx("div",{className:"node-command-palette__list",id:c,role:"listbox","aria-label":a("nodeStudio.palette.commandsAria"),children:dt.map(S=>{const N=x.filter(k=>k.category===S);return N.length?p.jsxs("section",{children:[p.jsx("h3",{children:a($g[S])}),N.map(k=>{const P=x.indexOf(k);return p.jsxs("button",{id:`${c}-${k.type}`,type:"button",role:"option","aria-selected":P===d,className:P===d?"is-active":"",onPointerEnter:()=>h(P),onClick:()=>i(k),children:[p.jsx("span",{children:et(a,k,"label")}),p.jsx("small",{children:et(a,k,"description")})]},k.type)})]},S):null})})]})}const to="application/ima2-node-element";function _o(e){return{clientId:e,serverNodeId:null,parentServerNodeId:null,prompt:"",imageUrl:null,status:"empty",pendingRequestId:null,pendingPhase:null}}function Vs(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function zg(e){const t=Vs(e.data),n=t.nodeType==="element-reference";return{...e,id:e.id,type:n?"elementReferenceNode":"imageNode",position:e.position??{x:0,y:0},data:{..._o(e.id),...t,clientId:e.id,status:t.status==="ready"?"ready":"empty",pendingRequestId:null,pendingPhase:null}}}function Lg(e){return{...e,id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle==="output"?"source-right":e.sourceHandle,targetHandle:e.targetHandle==="input"?"target-left":e.targetHandle}}function Bg(e){return{nodes:e.nodes.map(zg),edges:e.edges.map(Lg)}}function Fs(e,t){const n=new Set(e.map(o=>o.id));return n.size!==e.length||new Set(t.map(o=>o.id)).size!==t.length||t.some(o=>!n.has(o.source)||!n.has(o.target))||ic(e,t)?!1:e.every(o=>o.type!=="elementReferenceNode"||Vs(o.data).nodeType==="element-reference")}function wn(e){if(!Fs(e.nodes,e.edges))return!1;Q.getState().recordGraphHistory(`commit-${e.reason}`);const t=rc(e.nodes,e.edges);return Q.setState({graphNodes:t,graphEdges:e.edges}),Q.getState().scheduleGraphSave(),!0}function Vg(e,t){if(t.createdNodeIds.length===0||t.createdEdgeIds.length===0)return{ok:!1};const n={nodes:[...e.nodes,...t.nodes],edges:[...e.edges,...t.edges]};return Fs(n.nodes,n.edges)?{ok:!0,graph:n}:{ok:!1}}function Fg(e){const t=qr(),n={id:t,type:"imageNode",position:e.position,data:_o(t)};if(!e.sourcePort)return{nodes:[...e.graph.nodes,n],edges:e.graph.edges};const o={id:`${e.sourcePort.nodeId}:${e.sourcePort.handleId}->${t}:target-left`,source:e.sourcePort.nodeId,target:t,sourceHandle:e.sourcePort.handleId,targetHandle:"target-left"};return{nodes:[...e.graph.nodes,n],edges:[...e.graph.edges,o]}}function Yg(e){try{const t=JSON.parse(e);return t.version===1&&t.assetKind==="element"&&typeof t.elementId=="string"&&t.elementId.length>0?t:null}catch{return null}}function Xg(e){const t=e.metadata?.refs,n=Array.isArray(t)?t.find(o=>typeof o=="string"&&o.length>0):null;return n?`/generated/${n.split("/").map(encodeURIComponent).join("/")}`:null}function Wg(e,t){if(e.kind!=="element")return null;const n=Array.isArray(e.metadata?.refs)?e.metadata.refs:[],o=qr();return{id:o,type:"elementReferenceNode",position:t,data:{..._o(o),nodeType:"element-reference",elementId:e.id,elementName:e.name,thumbnailUrl:Xg(e),refCount:n.length,notesPreview:e.notes??"",revision:e.updatedAt,missing:!1}}}function Zg(e){return{version:1,assetKind:"element",elementId:e}}function Gg(e,t){e.dataTransfer.effectAllowed="copy",e.dataTransfer.setData(to,JSON.stringify(Zg(t.id)))}function qg({disabled:e=!1,onAdd:t}){const{t:n}=ce(),[o,r]=E.useState([]),[i,s]=E.useState("loading");return E.useEffect(()=>{let a=!0;return(async()=>{try{const c=await sc();a&&(r(c),s("ready"))}catch{a&&s("error")}})(),()=>{a=!1}},[]),p.jsxs("aside",{className:"node-element-tray","aria-label":n("nodeStudio.elements.ariaLabel"),children:[p.jsxs("header",{children:[p.jsx("strong",{children:n("nodeStudio.elements.title")}),p.jsx("span",{children:n("nodeStudio.elements.hint")})]}),i==="loading"?p.jsx("p",{role:"status",children:n("nodeStudio.elements.loading")}):null,i==="error"?p.jsx("p",{role:"alert",children:n("nodeStudio.elements.loadError")}):null,i==="ready"&&o.length===0?p.jsx("p",{children:n("nodeStudio.elements.empty")}):null,p.jsx("div",{className:"node-element-tray__list",children:o.map(a=>{const c=ac(a);return p.jsxs("article",{className:"node-element-tray__item",draggable:!e,onDragStart:l=>Gg(l,a),children:[c?p.jsx("img",{src:`/generated/${c.split("/").map(encodeURIComponent).join("/")}`,alt:""}):p.jsx("span",{className:"node-element-tray__placeholder","aria-hidden":"true"}),p.jsx("span",{title:a.name,children:a.name}),p.jsx("button",{type:"button",disabled:e,onClick:()=>{t(a)},children:n("nodeStudio.elements.addToCanvas")})]},a.id)})})]})}function Ug(e,t){const n=t.toLocaleLowerCase();return[e.name,...e.tags].some(o=>o.toLocaleLowerCase().includes(n))}function Kg({template:e}){const{t}=ce(),n=e.preview??[];return p.jsx("div",{className:"node-template-picker__preview","aria-label":t("nodeStudio.templates.previewAria",{name:e.name}),children:n.length?n.map(o=>p.jsx("span",{className:"node-template-picker__preview-node",style:{left:`${o.x}%`,top:`${o.y}%`},children:o.label},o.id)):p.jsx("span",{className:"node-template-picker__preview-empty",children:t(e.nodeCount===1?"nodeStudio.templates.nodeCountOne":"nodeStudio.templates.nodeCount",{count:e.nodeCount})})})}function Vr({template:e,selected:t,onSelect:n,onRename:o,onDelete:r}){const{t:i}=ce();return p.jsxs("article",{className:`node-template-picker__card${t?" is-selected":""}`,children:[p.jsxs("button",{type:"button",className:"node-template-picker__card-main",onClick:n,onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),n())},"aria-pressed":t,children:[p.jsx(Kg,{template:e}),p.jsxs("span",{className:"node-template-picker__card-copy",children:[p.jsx("strong",{children:e.name}),p.jsx("span",{children:e.description}),p.jsxs("small",{children:[i(e.nodeCount===1?"nodeStudio.templates.nodeCountOne":"nodeStudio.templates.nodeCount",{count:e.nodeCount})," · ",i(e.terminalCount===1?"nodeStudio.templates.outputCountOne":"nodeStudio.templates.outputCount",{count:e.terminalCount})]})]})]}),p.jsx("div",{className:"node-template-picker__tags",children:e.tags.map(s=>p.jsx("span",{children:s},s))}),e.source==="user"&&(o||r)?p.jsxs("div",{className:"node-template-picker__card-actions",children:[o?p.jsx("button",{type:"button",onClick:o,children:i("nodeStudio.templates.rename")}):null,r?p.jsx("button",{type:"button",onClick:r,children:i("nodeStudio.templates.delete")}):null]}):null]})}function Qg({templates:e,loading:t=!1,error:n=null,onCopy:o,onClose:r,onRename:i,onDelete:s}){const{t:a}=ce(),[c,l]=E.useState(""),[u,f]=E.useState(null),d=E.useMemo(()=>e.filter(w=>Ug(w,c)),[c,e]),h=d.find(w=>w.id===u)??null,m=d.filter(w=>w.source==="seed"),v=d.filter(w=>w.source==="user"),x=()=>{h&&o(h)},y=w=>{window.confirm(a("nodeStudio.templates.deleteConfirm",{name:w.name}))&&s?.(w)};return p.jsxs("section",{className:"node-template-picker",role:"dialog","aria-modal":"true","aria-labelledby":"node-template-picker-title",children:[p.jsxs("header",{children:[p.jsxs("div",{children:[p.jsx("p",{className:"node-template-picker__eyebrow",children:a("nodeStudio.name")}),p.jsx("h2",{id:"node-template-picker-title",children:a("nodeStudio.templates.title")})]}),p.jsx("button",{type:"button","aria-label":a("nodeStudio.templates.close"),onClick:r,children:"×"})]}),p.jsxs("label",{className:"node-template-picker__search",children:[p.jsx("span",{children:a("nodeStudio.templates.searchLabel")}),p.jsx("input",{autoFocus:!0,value:c,onChange:w=>l(w.target.value),placeholder:a("nodeStudio.templates.searchPlaceholder")})]}),t?p.jsx("p",{className:"node-template-picker__state",role:"status",children:a("nodeStudio.templates.loading")}):null,n?p.jsx("p",{className:"node-template-picker__state is-error",role:"alert",children:n}):null,!t&&!n&&d.length===0?p.jsx("p",{className:"node-template-picker__state",children:a("nodeStudio.templates.empty",{query:c})}):null,!t&&!n?p.jsxs("div",{className:"node-template-picker__sections",children:[m.length?p.jsxs("section",{children:[p.jsx("h3",{children:a("nodeStudio.templates.starter")}),p.jsx("div",{className:"node-template-picker__grid",children:m.map(w=>p.jsx(Vr,{template:w,selected:w.id===u,onSelect:()=>f(w.id)},w.id))})]}):null,v.length?p.jsxs("section",{children:[p.jsx("h3",{children:a("nodeStudio.templates.yours")}),p.jsx("div",{className:"node-template-picker__grid",children:v.map(w=>p.jsx(Vr,{template:w,selected:w.id===u,onSelect:()=>f(w.id),onRename:i?()=>i(w):void 0,onDelete:s?()=>y(w):void 0},w.id))})]}):null]}):null,p.jsxs("footer",{children:[p.jsx("button",{type:"button",onClick:r,children:a("nodeStudio.templates.cancel")}),p.jsx("button",{type:"button",className:"node-template-picker__copy",disabled:!h,onClick:x,children:a("nodeStudio.templates.copy")})]})]})}function Fr({children:e,onClose:t}){const n=cc(!0,t);return p.jsx("div",{ref:n,className:"node-studio-dialog-backdrop",onPointerDown:o=>{o.target===o.currentTarget&&t()},children:e})}function Jg({studio:e,graphEmpty:t,disabled:n,onAddRoot:o}){const{t:r}=ce();return p.jsxs(p.Fragment,{children:[p.jsxs(Ke,{position:"top-right",className:"node-studio-toolbar",children:[p.jsx("button",{type:"button",disabled:n,onClick:o,children:r("nodeStudio.toolbar.addImage")}),p.jsx("button",{type:"button",disabled:n,onClick:e.openTemplates,children:r("nodeStudio.toolbar.templates")}),p.jsx("button",{type:"button",disabled:n||t,onClick:e.saveTemplate,children:r("nodeStudio.toolbar.saveTemplate")}),p.jsx("button",{type:"button",disabled:n||!e.selectedSource,onClick:e.openBranch,children:r("nodeStudio.toolbar.branch")})]}),p.jsx(Ke,{position:"top-left",className:"node-studio-element-panel",children:p.jsx(qg,{disabled:n,onAdd:e.addElement})}),p.jsx(Og,{open:!!e.palette,anchor:e.palette?.anchor??{clientX:0,clientY:0},sourcePort:e.palette?.sourcePort,commands:e.commands,onInsert:e.insertCommand,onClose:e.closePalette}),e.templateOpen?p.jsx(Fr,{onClose:e.closeOverlays,children:p.jsx(Qg,{templates:e.templates,loading:e.templateLoading,error:e.templateError,onCopy:e.copyTemplate,onRename:e.renameTemplate,onDelete:e.removeTemplate,onClose:e.closeOverlays})}):null,e.branchOpen&&e.selectedSource?p.jsx(Fr,{onClose:e.closeOverlays,children:p.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"node-branch-dialog-title",children:p.jsx(Tg,{sourceLabel:e.selectedSource.data.prompt||e.selectedSource.id,onApply:e.applyBranch,onClose:e.closeOverlays})})}):null,p.jsx("div",{className:"node-studio-status",role:"status","aria-live":"polite","aria-atomic":"true",children:e.status})]})}const em=[{type:"image-generate",label:"Image generation",description:"Add an image node to the workflow.",category:"generate",keywords:["image","generate","prompt"],inputPorts:[{id:"image-input",type:"image"}],outputPorts:[{id:"image-output",type:"image"}],createData:()=>({})}];function Ys(e){return e instanceof HTMLElement&&e.matches("input, textarea, select, [contenteditable=true]")}function tm(e,t){return e===t||e instanceof HTMLElement&&e.classList.contains("react-flow__pane")}function nm(e,t,n){return Ys(e.target)||!tm(e.target,t)?!1:e.key==="/"||e.key===" "&&n}function om(e){return Ys(e.target)||!(e.metaKey||e.ctrlKey)||e.altKey||e.key!=="z"&&e.key!=="Z"?null:e.shiftKey?"redo":"undo"}function rm(e){const t=e?.getBoundingClientRect();return t?{clientX:t.left+t.width/2,clientY:t.top+Math.min(180,t.height/2)}:{clientX:320,clientY:180}}const im=320,sm=420;function On(){return{nodes:[],edges:[],createdNodeIds:[],createdEdgeIds:[]}}function am(e){return new Set(e.map(t=>t.id)).size===e.length}function no(e,t){let n=1,o=e;for(;t.has(o);)o=`${e}-${n++}`;return t.add(o),o}function cm(e){return JSON.parse(JSON.stringify(e))}function lm(e,t,n,o){const r=(t-.5)*im;return{x:Math.max(0,...o.nodes.map(s=>s.position.x))+sm,y:e.position.y+r}}function Yr(e,t,n,o,r){const i={...cm(e.data),...r?n.settingsPatch:{},clientId:t,serverNodeId:null,parentServerNodeId:null,pendingRequestId:null,pendingPhase:null,status:"empty"};return r&&n.provider&&(i.provider=n.provider),{...e,id:t,position:o,data:i}}function Xr(e,t,n,o){const r=no(`${t}:${e.sourceHandle??"auto"}->${n}:${e.targetHandle??"auto"}`,o);return{...e,id:r,source:t,target:n}}function um(e){const t=e.graph.nodes.find(i=>i.id===e.sourceNodeId),n=e.graph.edges.find(i=>i.source===e.sourceNodeId),o=n&&e.graph.nodes.find(i=>i.id===n.target),r=o?e.graph.edges.filter(i=>i.target===o.id):[];return t&&o&&r.length>0?{generator:o,inputEdges:r}:null}function dm(e){if(e.variants.length<2||e.variants.length>4||!am(e.variants))return On();const t=um(e);if(!t)return On();const n=new Set(e.graph.nodes.map(c=>c.id)),o=new Set(e.graph.edges.map(c=>c.id)),r=e.graph.edges.find(c=>c.source===t.generator.id),i=r&&e.graph.nodes.find(c=>c.id===r.target);if(r&&!i)return On();const s=[],a=[];for(const[c,l]of e.variants.entries()){const u=no(`${t.generator.id}-branch-${l.id}`,n),f=lm(t.generator,c,e.axis,e.graph),d=Yr(t.generator,u,l,f,!0);s.push(d);for(const h of t.inputEdges)a.push(Xr(h,h.source,u,o));if(i&&r){const h=no(`${i.id}-branch-${l.id}`,n),m={x:f.x+i.position.x-t.generator.position.x,y:f.y+i.position.y-t.generator.position.y},v=Yr(i,h,l,m,!1);s.push(v),a.push(Xr(r,u,h,o))}}return{nodes:s,edges:a,createdNodeIds:s.map(c=>c.id),createdEdgeIds:a.map(c=>c.id)}}function fm(e){const{t}=ce(),[n,o]=E.useState(!1),r=E.useMemo(()=>{const s=e.nodes.filter(a=>a.selected&&a.type==="imageNode");return s.length===1&&e.edges.some(a=>a.source===s[0].id)?s[0]:null},[e.edges,e.nodes]),i=E.useCallback(s=>{if(!r){e.showToast(t("nodeStudio.branch.selectSourceError"),!0);return}const a=dm({graph:{nodes:e.nodes,edges:e.edges},sourceNodeId:r.id,variants:s,axis:"horizontal"}),c=Vg({nodes:e.nodes,edges:e.edges},a);if(!c.ok||!wn({...c.graph,reason:"branch"})){e.showToast(t("nodeStudio.branch.applyError"),!0);return}o(!1),e.restoreFocus(),requestAnimationFrame(()=>{e.fitView({padding:.16,duration:180})})},[e,r,t]);return{branchOpen:n,selectedSource:r,setBranchOpen:o,applyBranch:i}}const Wr=["target-top","target-right","target-bottom","target-left"],Zr=["source-top","source-right","source-bottom","source-left"],hm=[...Wr.map(e=>({nodeType:"imageNode",flowHandleId:e,logicalPortId:"image-input",direction:"input",type:"image",acceptsMany:!1,equivalentHandleIds:Wr})),...Zr.map(e=>({nodeType:"imageNode",flowHandleId:e,logicalPortId:"image-output",direction:"output",type:"image",acceptsMany:!0,equivalentHandleIds:Zr})),{nodeType:"elementReferenceNode",flowHandleId:"refs",logicalPortId:"element-refs-output",direction:"output",type:"element-refs",acceptsMany:!0,equivalentHandleIds:["refs"]},{nodeType:"elementReferenceNode",flowHandleId:"notes",logicalPortId:"element-notes-output",direction:"output",type:"element-notes",acceptsMany:!0,equivalentHandleIds:["notes"]}];function mt(e,t,n){if(!t)return null;const o=e.type==="elementReferenceNode"?"elementReferenceNode":e.type==="imageNode"?"imageNode":null;if(!o)return null;const r=hm.find(i=>i.nodeType===o&&i.flowHandleId===t&&i.direction===n);return r?{nodeId:e.id,handleId:r.flowHandleId,logicalPortId:r.logicalPortId,equivalentHandleIds:r.equivalentHandleIds,direction:r.direction,type:r.type,acceptsMany:r.acceptsMany}:null}function pm(e,t,n){const o=t.find(a=>a.id===e.source),r=t.find(a=>a.id===e.target);if(!o||!r)return!1;const i=mt(o,e.sourceHandle,"output"),s=mt(r,e.targetHandle,"input");return!i||!s?!1:Bs(i,s,{edges:n}).allowed}function gm(e){return"changedTouches"in e?{clientX:e.changedTouches[0].clientX,clientY:e.changedTouches[0].clientY}:{clientX:e.clientX,clientY:e.clientY}}function mm(e){const[t,n]=E.useState(null),o=E.useCallback(a=>pm(a,e.nodes,e.edges),[e]),r=E.useCallback(a=>{const c=e.nodes.find(h=>h.id===a.source),l=e.nodes.find(h=>h.id===a.target),u=c?mt(c,a.sourceHandle,"output"):null,f=l?mt(l,a.targetHandle,"input"):null;if(!u||!f){e.surfaceReason("UNKNOWN_PORT");return}const d=Bs(u,f,{nodes:e.nodes,edges:e.edges});if(!d.allowed){e.surfaceReason(d.reason);return}e.connectNodes(a.source,a.target,a.sourceHandle,a.targetHandle)},[e]),i=E.useCallback((a,c)=>{if(c.isValid||c.toNode||c.toHandle)return;const l=c.fromNode?e.nodes.find(f=>f.id===c.fromNode?.id):null,u=l?mt(l,c.fromHandle?.id,"output"):null;if(!u){e.surfaceReason("UNKNOWN_PORT");return}n({anchor:gm(a),sourcePort:u})},[e]),s=E.useCallback(a=>{if(a.type!=="image-generate"||!t)return;const c=e.screenToFlowPosition({x:t.anchor.clientX,y:t.anchor.clientY}),l=Fg({graph:{nodes:e.nodes,edges:e.edges},position:c,sourcePort:t.sourcePort});if(!wn({...l,reason:"palette"})){e.surfaceReason("UNKNOWN_PORT");return}n(null),e.restoreFocus()},[e,t]);return{palette:t,setPalette:n,onConnect:r,onConnectEnd:i,insertCommand:s,isValidConnection:o}}function ym(e){const{t}=ce(),n=E.useCallback(async(s,a)=>{try{const c=await lc(s),l=Wg(c.asset,a);if(!l){e.showToast(t("nodeStudio.elementController.onlyElements"),!0);return}const u={nodes:[...e.nodes,l],edges:e.edges};wn({...u,reason:"element-drop"})||e.showToast(t("nodeStudio.elementController.invalid"),!0)}catch{e.showToast(t("nodeStudio.elementController.addError"),!0)}},[e,t]),o=E.useCallback(async s=>{const a=e.wrapperRef.current?.getBoundingClientRect(),c=a?{x:a.left+a.width/2,y:a.top+a.height/2}:{x:320,y:240};try{await n(s.id,e.screenToFlowPosition(c))}catch{e.showToast(t("nodeStudio.elementController.addError"),!0)}},[n,e,t]),r=E.useCallback(async s=>{s.preventDefault();const a=Yg(s.dataTransfer.getData(to));if(a)try{await n(a.elementId,e.screenToFlowPosition({x:s.clientX,y:s.clientY}))}catch{e.showToast(t("nodeStudio.elementController.addError"),!0)}},[n,e,t]),i=E.useCallback(s=>{s.dataTransfer.types.includes(to)&&(s.preventDefault(),s.dataTransfer.dropEffect="copy")},[]);return{addElement:o,onDropElement:r,onDragOver:i}}const Xs={"Content-Type":"application/json"};async function xm(){try{return(await Ct("/api/node-templates")).templates}catch(e){throw e instanceof Error?e:new Error(String(e))}}async function wm(e){try{return(await Ct("/api/node-templates",{method:"POST",headers:Xs,body:JSON.stringify(e)})).template}catch(t){throw t instanceof Error?t:new Error(String(t))}}async function vm(e){try{return(await Ct(`/api/node-templates/${encodeURIComponent(e)}/instantiate`,{method:"POST"})).graph}catch(t){throw t instanceof Error?t:new Error(String(t))}}async function bm(e,t){try{return(await Ct(`/api/node-templates/${encodeURIComponent(e)}`,{method:"PATCH",headers:Xs,body:JSON.stringify({name:t})})).template}catch(n){throw n instanceof Error?n:new Error(String(n))}}async function _m(e){try{await Ct(`/api/node-templates/${encodeURIComponent(e)}`,{method:"DELETE"})}catch(t){throw t instanceof Error?t:new Error(String(t))}}function Sm(e){const{t}=ce(),[n,o]=E.useState(!1),[r,i]=E.useState(!1),[s,a]=E.useState(null),[c,l]=E.useState([]),u=E.useCallback(async()=>{o(!0),i(!0),a(null);try{l(await xm())}catch{a(t("nodeStudio.templates.loadError"))}finally{i(!1)}},[t]),f=E.useCallback(async d=>{if(!(e.nodes.length>0&&!window.confirm(t("nodeStudio.templates.replaceConfirm")))){i(!0),a(null);try{const h=Bg(await vm(d.id));if(!wn({...h,reason:"template"})){a(t("nodeStudio.templates.invalidGraph"));return}o(!1),e.restoreFocus(),requestAnimationFrame(()=>{e.fitView({padding:.16,duration:180})})}catch{a(t("nodeStudio.templates.copyError"))}finally{i(!1)}}},[e,t]);return{templateOpen:n,templateLoading:r,templateError:s,templates:c,setTemplateOpen:o,openTemplates:u,copyTemplate:f,setters:{setTemplates:l,setTemplateError:a}}}function Nm(e,t){const{t:n}=ce(),o=E.useCallback(async()=>{const s=window.prompt(n("nodeStudio.templates.namePrompt"));if(s?.trim())try{const a=await wm({name:s.trim(),graph:{nodes:e.nodes,edges:e.edges}});t.setTemplates(c=>[...c.filter(l=>l.id!==a.id),a]),e.showToast(n("nodeStudio.templates.saved"))}catch{e.showToast(n("nodeStudio.templates.saveError"),!0)}},[e,t,n]),r=E.useCallback(async s=>{const a=window.prompt(n("nodeStudio.templates.renamePrompt"),s.name);if(a?.trim())try{const c=await bm(s.id,a.trim());t.setTemplates(l=>l.map(u=>u.id===c.id?c:u))}catch{t.setTemplateError(n("nodeStudio.templates.renameError"))}},[t,n]),i=E.useCallback(async s=>{try{await _m(s.id),t.setTemplates(a=>a.filter(c=>c.id!==s.id))}catch{t.setTemplateError(n("nodeStudio.templates.deleteError"))}},[t,n]);return{saveTemplate:o,renameTemplate:r,removeTemplate:i}}const Em={SAME_DIRECTION:"nodeStudio.compatibility.sameDirection",TYPE_MISMATCH:"nodeStudio.compatibility.typeMismatch",CARDINALITY:"nodeStudio.compatibility.cardinality",SELF_EDGE:"nodeStudio.compatibility.selfEdge",DUPLICATE_EDGE:"nodeStudio.compatibility.duplicateEdge",CYCLE:"nodeStudio.compatibility.cycle",UNKNOWN_PORT:"nodeStudio.compatibility.unknownPort"};function Cm(e){const{t}=ce(),n=Q(T=>T.graphNodes),o=Q(T=>T.graphEdges),r=Q(T=>T.sessions),i=Q(T=>T.activeSessionId),s=Q(T=>T.switchSession),a=Q(T=>T.connectNodes),c=Q(T=>T.undoGraph),l=Q(T=>T.redoGraph),u=Q(T=>T.showToast),{fitView:f,screenToFlowPosition:d}=mn(),[h,m]=E.useState(""),v=E.useCallback(()=>requestAnimationFrame(()=>e.current?.focus()),[e]),x=E.useCallback(T=>{const O=t(Em[T]);m(O),u(O,!0)},[u,t]),y={nodes:n,edges:o,fitView:f,restoreFocus:v,showToast:u},w=Sm(y),g=Nm(y,w.setters),b=mm({nodes:n,edges:o,connectNodes:a,screenToFlowPosition:d,surfaceReason:x,restoreFocus:v}),C=fm(y),S=ym({nodes:n,edges:o,wrapperRef:e,screenToFlowPosition:d,showToast:u}),N=E.useMemo(()=>r.filter(T=>T.id!==i&&T.nodeCount>0).sort((T,O)=>O.updatedAt-T.updatedAt)[0]??null,[i,r]),k=E.useCallback(()=>{b.setPalette(null),w.setTemplateOpen(!1),C.setBranchOpen(!1),v()},[C.setBranchOpen,b.setPalette,v,w.setTemplateOpen]),P=E.useCallback(T=>{const O=om(T);if(O){(O==="undo"?c():l())&&(T.preventDefault(),u(t(O==="undo"?"graph.undone":"graph.redone")));return}if(T.key==="Escape"&&(b.palette||w.templateOpen||C.branchOpen)){T.preventDefault(),k();return}nm(T,e.current,n.length===0)&&(T.preventDefault(),b.setPalette({anchor:rm(e.current)}))},[C.branchOpen,k,b.palette,b.setPalette,n.length,l,u,t,w.templateOpen,c,e]),L=E.useCallback(async()=>{if(N)try{await s(N.id)}catch{u(t("nodeStudio.empty.resumeError"),!0)}},[N,u,s,t]);return{commands:em,...b,...C,...S,...w,status:h,hasRecentGraph:!!N,onKeyDown:P,resumeRecent:L,closeOverlays:k,closePalette:k,openTemplates:()=>{w.openTemplates()},saveTemplate:()=>{g.saveTemplate()},copyTemplate:w.copyTemplate,renameTemplate:T=>{g.renameTemplate(T)},removeTemplate:T=>{g.removeTemplate(T)},openBranch:()=>C.setBranchOpen(!0)}}function Im(){const{t:e}=ce(),t=uc(),n=Q(g=>g.graphNodes),o=Q(g=>g.graphEdges),r=Q(g=>g.setGraphNodes),i=Q(g=>g.setGraphEdges),s=Q(g=>g.disconnectEdges),a=Q(g=>g.addRootNode),c=Q(g=>g.deleteNodes),l=Q(g=>g.nodeSelectionMode),u=Q(g=>g.selectNodeGraph),f=Q(g=>g.sessionLoading),d=E.useRef(null),h=Cm(d),m=E.useMemo(()=>({imageNode:Ng,elementReferenceNode:Ig}),[]),v=E.useCallback(g=>r(cs(g,n)),[n,r]),x=E.useCallback(g=>{const b=g.filter(C=>C.type==="remove").map(C=>C.id);if(b.length>0){if(l)return;s(b);return}i(ls(g,o))},[s,o,l,i]),y=E.useCallback(g=>c(g.map(b=>b.id)),[c]),w=E.useCallback((g,b)=>{l&&(g.preventDefault(),u(b.id,g.metaKey||g.ctrlKey))},[l,u]);return p.jsxs("main",{className:`node-canvas${n.length===0?" node-canvas--empty":""}`,ref:d,tabIndex:0,onKeyDown:h.onKeyDown,children:[f&&p.jsx("div",{className:"node-canvas__loading",children:e("nodeCanvas.loading")}),p.jsxs(Fp,{nodes:n,edges:o,onNodesChange:v,onEdgesChange:x,onConnect:h.onConnect,onConnectEnd:h.onConnectEnd,isValidConnection:h.isValidConnection,onDragOver:h.onDragOver,onDrop:h.onDropElement,onNodesDelete:y,onNodeClick:w,nodeTypes:m,connectionMode:Ze.Loose,connectionRadius:32,selectionOnDrag:l,multiSelectionKeyCode:l?null:void 0,panOnDrag:l?[2]:!0,fitView:!0,deleteKeyCode:l?null:["Delete","Backspace"],proOptions:{hideAttribution:!0},children:[n.length===0?p.jsx("div",{className:"node-studio-empty-overlay",children:p.jsx(Mg,{hasRecentGraph:h.hasRecentGraph,onStartBlank:()=>{f||a()},onOpenTemplates:h.openTemplates,onResumeRecent:h.resumeRecent})}):null,n.length>0?p.jsx(Eg,{}):null,p.jsx(Jg,{studio:h,graphEmpty:n.length===0,disabled:f,onAddRoot:()=>a()}),p.jsx(Gp,{gap:24,size:1.6,color:"var(--node-canvas-grid)",variant:Ae.Dots}),p.jsx(tg,{className:"node-canvas__controls"}),!t&&p.jsx(gg,{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)"}})]}),n.length>0?p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button",className:"node-canvas__add-root",onClick:()=>a(),title:e("nodeCanvas.addRootTitle"),children:"+"}),p.jsx("div",{className:"node-canvas__hint",children:e("nodeCanvas.hint")})]}):null]})}function km(){return p.jsx(Rs,{children:p.jsx(Im,{})})}export{km as NodeCanvas};