specrails-desktop 2.43.0 → 2.43.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 (43) hide show
  1. package/client/dist/assets/{ActivityFeedPage-DoEMumQS.js → ActivityFeedPage-C7XJ5-bJ.js} +1 -1
  2. package/client/dist/assets/{AgentBrowserCapture-DIh4K0gh.js → AgentBrowserCapture-C_WpXceT.js} +1 -1
  3. package/client/dist/assets/{AgentModeAnalyticsPane-mbq4WEoO.js → AgentModeAnalyticsPane-PEZKjyZS.js} +2 -2
  4. package/client/dist/assets/{AgentModeCodePane-CKh7zuA4.js → AgentModeCodePane-D_Xcq5t5.js} +2 -2
  5. package/client/dist/assets/{AgentModeJobsPane-BDokPiLJ.js → AgentModeJobsPane-CDSkOuNP.js} +1 -1
  6. package/client/dist/assets/{AgentsPage-BFVAZbBj.js → AgentsPage-D577NzIM.js} +1 -1
  7. package/client/dist/assets/{AnalyticsPage-3Y9LuWwz.js → AnalyticsPage-C6ZZI_zg.js} +1 -1
  8. package/client/dist/assets/{CodePage-C9KyuV_C.js → CodePage-B5z5oLnP.js} +1 -1
  9. package/client/dist/assets/{DesktopAnalyticsPage-Bhi54bXQ.js → DesktopAnalyticsPage-D_V9RuGg.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-Dj6mt4ga.js → DocsDialog-Beg82MEe.js} +1 -1
  11. package/client/dist/assets/{DocsPage-24yWglNI.js → DocsPage-BkE4m4wp.js} +1 -1
  12. package/client/dist/assets/{InteractiveJobComposer-C1ucmxQh.js → InteractiveJobComposer-wBBBNaJn.js} +1 -1
  13. package/client/dist/assets/JobDetailModal-BCxue_Do.js +1 -0
  14. package/client/dist/assets/{JobDetailPage-BcajZyuu.js → JobDetailPage-_rIDpNfo.js} +1 -1
  15. package/client/dist/assets/{JobsPage-B9nTZw6e.js → JobsPage-C6xcijbs.js} +1 -1
  16. package/client/dist/assets/{LoopBuilderPage-Oc48iOFW.js → LoopBuilderPage-A-Mt6EjT.js} +1 -1
  17. package/client/dist/assets/{LoopPreviewModal-ae0Fr6SU.js → LoopPreviewModal-DqHiG4Dt.js} +1 -1
  18. package/client/dist/assets/{LoopsPage-CUEqzUBI.js → LoopsPage-B-ketPET.js} +1 -1
  19. package/client/dist/assets/{PluginsPage-C1xtARIx.js → PluginsPage-Dn2jPvJL.js} +1 -1
  20. package/client/dist/assets/{ProjectSettingsDialog-JZzrXFBN.js → ProjectSettingsDialog-CVTj4VLt.js} +1 -1
  21. package/client/dist/assets/{RepositoryDeliveries-CSDsiVUz.js → RepositoryDeliveries-IiQCcndQ.js} +1 -1
  22. package/client/dist/assets/{ReviewPacketPage-x5EfGTiL.js → ReviewPacketPage-BBd617OM.js} +1 -1
  23. package/client/dist/assets/{TemplatePreviewModal-BSyuZxGq.js → TemplatePreviewModal-COHFkUS4.js} +1 -1
  24. package/client/dist/assets/{TicketDetailModalContext-DqyF0so-.js → TicketDetailModalContext-BNa1mdXq.js} +3 -3
  25. package/client/dist/assets/{button-DCBqEaZl.js → button-Ccc9Dc-D.js} +1 -1
  26. package/client/dist/assets/dialog-xXB2q5HJ.js +45 -0
  27. package/client/dist/assets/index-D5n_jg_I.css +2 -0
  28. package/client/dist/assets/index-m5pKr1T6.js +76 -0
  29. package/client/dist/index.html +6 -6
  30. package/docs/guide/en/pipeline/3-batch-implement-and-multi-feature.md +11 -0
  31. package/docs/internals/core-runtime-updates.md +7 -0
  32. package/docs/internals/interactive-jobs.md +53 -0
  33. package/package.json +1 -1
  34. package/server/dist/loop-executors.js +14 -1
  35. package/server/dist/loop-factory.js +24 -5
  36. package/server/dist/loop-run-manager.js +12 -0
  37. package/server/dist/loop-templates.js +14 -33
  38. package/server/dist/rails-router.js +2 -2
  39. package/server/dist/workspace-manager.js +54 -3
  40. package/client/dist/assets/JobDetailModal-DNWmgVHD.js +0 -1
  41. package/client/dist/assets/dialog-SRw01_QU.js +0 -45
  42. package/client/dist/assets/index-DwAmL7m5.css +0 -2
  43. package/client/dist/assets/index-EzrkUb8B.js +0 -76
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{d as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{r as c,s as l}from"./useDesktop-RSMTyy7V.js";import{n as u,t as d}from"./save-B6wGWwBR.js";import{t as f}from"./brain-DI9lHkKY.js";import{t as p}from"./git-branch-BRM0F5GN.js";import{n as m,t as h}from"./square-Ci-PFcFe.js";import{t as g}from"./plus-CsnjfkmX.js";import{t as _}from"./trash-2-BOU3WdZZ.js";import{t as v}from"./triangle-alert-H9T4jAmh.js";import{t as y}from"./upload-DYMjAQ6M.js";import{a as b,l as x,o as S,r as C,t as w}from"./dialog-SRw01_QU.js";import{t as T}from"./utils-BC4DHlz2.js";import{t as E}from"./button-DCBqEaZl.js";import{t as D}from"./project-repositories-DYhTvwQ1.js";import{B as O,Et as k,Ot as A,R as j,V as M,Vt as N,bt as P,ct as F,g as I,h as L,rt as R,ut as z,z as B}from"./index-EzrkUb8B.js";import{a as V,i as H,n as U,o as W,r as G,t as ee}from"./value-s-gzBeyF.js";var te=s(`grid-3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),ne=s(`move-horizontal`,[[`path`,{d:`m18 8 4 4-4 4`,key:`1ak13k`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}]]),re=s(`move-vertical`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m8 18 4 4 4-4`,key:`bh5tu3`}],[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}]]),ie=180/Math.PI,ae={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function oe(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*ie,skewX:Math.atan(c)*ie,scaleX:o,scaleY:s}}var se;function ce(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?ae:oe(t.a,t.b,t.c,t.d,t.e,t.f)}function le(e){return e==null||(se||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),se.setAttribute(`transform`,e),!(e=se.transform.baseVal.consolidate()))?ae:(e=e.matrix,oe(e.a,e.b,e.c,e.d,e.e,e.f))}function ue(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:G(e,i)},{i:c-2,x:G(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:G(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:G(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:G(e,n)},{i:s-2,x:G(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var de=ue(ce,`px, `,`px)`,`deg)`),fe=ue(le,`, `,`)`,`)`),pe=1e-12;function me(e){return((e=Math.exp(e))+1/e)/2}function he(e){return((e=Math.exp(e))-1/e)/2}function ge(e){return((e=Math.exp(2*e))-1)/(e+1)}var _e=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<pe)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=me(y),c=s/(n*g)*(i*ge(t*r+y)-he(y));return[a+c*d,o+c*f,s*i/me(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),K=e(t(),1),q=n();function J(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=J(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var ve={value:()=>{}};function ye(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new be(n)}function be(e){this._=e}function xe(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}be.prototype=ye.prototype={constructor:be,on:function(e,t){var n=this._,r=xe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Se(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Ce(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ce(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new be(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Se(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ce(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=ve,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var we={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Te(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),we.hasOwnProperty(t)?{space:we[t],local:e}:e}function Ee(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function De(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Oe(e){var t=Te(e);return(t.local?De:Ee)(t)}function ke(){}function Ae(e){return e==null?ke:function(){return this.querySelector(e)}}function je(e){typeof e!=`function`&&(e=Ae(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Y(r,this._parents)}function Me(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ne(){return[]}function Pe(e){return e==null?Ne:function(){return this.querySelectorAll(e)}}function Fe(e){return function(){return Me(e.apply(this,arguments))}}function Ie(e){e=typeof e==`function`?Fe(e):Pe(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Y(r,i)}function Le(e){return function(){return this.matches(e)}}function Re(e){return function(t){return t.matches(e)}}var ze=Array.prototype.find;function Be(e){return function(){return ze.call(this.children,e)}}function Ve(){return this.firstElementChild}function He(e){return this.select(e==null?Ve:Be(typeof e==`function`?e:Re(e)))}var Ue=Array.prototype.filter;function We(){return Array.from(this.children)}function Ge(e){return function(){return Ue.call(this.children,e)}}function Ke(e){return this.selectAll(e==null?We:Ge(typeof e==`function`?e:Re(e)))}function qe(e){typeof e!=`function`&&(e=Le(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Y(r,this._parents)}function Je(e){return Array(e.length)}function Ye(){return new Y(this._enter||this._groups.map(Je),this._parents)}function Xe(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Xe.prototype={constructor:Xe,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 Ze(e){return function(){return e}}function Qe(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new Xe(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function $e(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new Xe(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function et(e){return e.__data__}function tt(e,t){if(!arguments.length)return Array.from(this,et);var n=t?$e:Qe,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Ze(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=nt(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Y(o,r),o._enter=s,o._exit=c,o}function nt(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function rt(){return new Y(this._exit||this._groups.map(Je),this._parents)}function it(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function at(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Y(s,this._parents)}function ot(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function st(e){e||=ct;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Y(i,this._parents).order()}function ct(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function lt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ut(){return Array.from(this)}function dt(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function ft(){let e=0;for(let t of this)++e;return e}function pt(){return!this.node()}function mt(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function ht(e){return function(){this.removeAttribute(e)}}function gt(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _t(e,t){return function(){this.setAttribute(e,t)}}function vt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function yt(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function bt(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 xt(e,t){var n=Te(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?gt:ht:typeof t==`function`?n.local?bt:yt:n.local?vt:_t)(n,t))}function St(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Ct(e){return function(){this.style.removeProperty(e)}}function wt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Tt(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Et(e,t,n){return arguments.length>1?this.each((t==null?Ct:typeof t==`function`?Tt:wt)(e,t,n??``)):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||St(e).getComputedStyle(e,null).getPropertyValue(t)}function Ot(e){return function(){delete this[e]}}function kt(e,t){return function(){this[e]=t}}function At(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function jt(e,t){return arguments.length>1?this.each((t==null?Ot:typeof t==`function`?At:kt)(e,t)):this.node()[e]}function Mt(e){return e.trim().split(/^|\s+/)}function Nt(e){return e.classList||new Pt(e)}function Pt(e){this._node=e,this._names=Mt(e.getAttribute(`class`)||``)}Pt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Ft(e,t){for(var n=Nt(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function It(e,t){for(var n=Nt(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Lt(e){return function(){Ft(this,e)}}function Rt(e){return function(){It(this,e)}}function zt(e,t){return function(){(t.apply(this,arguments)?Ft:It)(this,e)}}function Bt(e,t){var n=Mt(e+``);if(arguments.length<2){for(var r=Nt(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?zt:t?Lt:Rt)(n,t))}function Vt(){this.textContent=``}function Ht(e){return function(){this.textContent=e}}function Ut(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function Wt(e){return arguments.length?this.each(e==null?Vt:(typeof e==`function`?Ut:Ht)(e)):this.node().textContent}function Gt(){this.innerHTML=``}function Kt(e){return function(){this.innerHTML=e}}function qt(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function Jt(e){return arguments.length?this.each(e==null?Gt:(typeof e==`function`?qt:Kt)(e)):this.node().innerHTML}function Yt(){this.nextSibling&&this.parentNode.appendChild(this)}function Xt(){return this.each(Yt)}function Zt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Qt(){return this.each(Zt)}function $t(e){var t=typeof e==`function`?e:Oe(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function en(){return null}function tn(e,t){var n=typeof e==`function`?e:Oe(e),r=t==null?en:typeof t==`function`?t:Ae(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function nn(){var e=this.parentNode;e&&e.removeChild(this)}function rn(){return this.each(nn)}function an(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function on(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function sn(e){return this.select(e?on:an)}function cn(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function ln(e){return function(t){e.call(this,t,this.__data__)}}function un(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function dn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function fn(e,t,n){return function(){var r=this.__on,i,a=ln(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function pn(e,t,n){var r=un(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?fn:dn,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function mn(e,t,n){var r=St(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function hn(e,t){return function(){return mn(this,e,t)}}function gn(e,t){return function(){return mn(this,e,t.apply(this,arguments))}}function _n(e,t){return this.each((typeof t==`function`?gn:hn)(e,t))}function*vn(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var yn=[null];function Y(e,t){this._groups=e,this._parents=t}function bn(){return new Y([[document.documentElement]],yn)}function xn(){return this}Y.prototype=bn.prototype={constructor:Y,select:je,selectAll:Ie,selectChild:He,selectChildren:Ke,filter:qe,data:tt,enter:Ye,exit:rt,join:it,merge:at,selection:xn,order:ot,sort:st,call:lt,nodes:ut,node:dt,size:ft,empty:pt,each:mt,attr:xt,style:Et,property:jt,classed:Bt,text:Wt,html:Jt,raise:Xt,lower:Qt,append:$t,insert:tn,remove:rn,clone:sn,datum:cn,on:pn,dispatch:_n,[Symbol.iterator]:vn};function Sn(e){return typeof e==`string`?new Y([[document.querySelector(e)]],[document.documentElement]):new Y([[e]],yn)}function Cn(e){let t;for(;t=e.sourceEvent;)e=t;return e}function wn(e,t){if(e=Cn(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Tn={passive:!1},En={capture:!0,passive:!1};function Dn(e){e.stopImmediatePropagation()}function On(e){e.preventDefault(),e.stopImmediatePropagation()}function kn(e){var t=e.document.documentElement,n=Sn(e).on(`dragstart.drag`,On,En);`onselectstart`in t?n.on(`selectstart.drag`,On,En):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function An(e,t){var n=e.document.documentElement,r=Sn(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,On,En),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var jn=e=>()=>e;function Mn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,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:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Mn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Nn(e){return!e.ctrlKey&&!e.button}function Pn(){return this.parentNode}function Fn(e,t){return t??{x:e.x,y:e.y}}function In(){return navigator.maxTouchPoints||`ontouchstart`in this}function Ln(){var e=Nn,t=Pn,n=Fn,r=In,i={},a=ye(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,Tn).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(Sn(n.view).on(`mousemove.drag`,m,En).on(`mouseup.drag`,h,En),kn(n.view),Dn(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(On(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){Sn(e.view).on(`mousemove.drag mouseup.drag`,null),An(e.view,l),On(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(Dn(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(On(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(Dn(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=wn(l||r,t),p,m,h;if((h=n.call(e,new Mn(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=wn(l||a,t),_=o;break}u.call(r,e,new Mn(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:jn(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:jn(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:jn(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:jn(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var Rn=0,zn=0,Bn=0,Vn=1e3,Hn,Un,Wn=0,Gn=0,Kn=0,qn=typeof performance==`object`&&performance.now?performance:Date,Jn=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yn(){return Gn||=(Jn(Xn),qn.now()+Kn)}function Xn(){Gn=0}function Zn(){this._call=this._time=this._next=null}Zn.prototype=Qn.prototype={constructor:Zn,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Yn():+n)+(t==null?0:+t),!this._next&&Un!==this&&(Un?Un._next=this:Hn=this,Un=this),this._call=e,this._time=n,rr()},stop:function(){this._call&&(this._call=null,this._time=1/0,rr())}};function Qn(e,t,n){var r=new Zn;return r.restart(e,t,n),r}function $n(){Yn(),++Rn;for(var e=Hn,t;e;)(t=Gn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Rn}function er(){Gn=(Wn=qn.now())+Kn,Rn=zn=0;try{$n()}finally{Rn=0,nr(),Gn=0}}function tr(){var e=qn.now(),t=e-Wn;t>Vn&&(Kn-=t,Wn=e)}function nr(){for(var e,t=Hn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Hn=n);Un=e,rr(r)}function rr(e){Rn||(zn&&=clearTimeout(zn),e-Gn>24?(e<1/0&&(zn=setTimeout(er,e-qn.now()-Kn)),Bn&&=clearInterval(Bn)):(Bn||=(Wn=qn.now(),setInterval(tr,Vn)),Rn=1,Jn(er)))}function ir(e,t,n){var r=new Zn;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var ar=ye(`start`,`end`,`cancel`,`interrupt`),or=[];function sr(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;dr(e,n,{name:t,index:r,group:i,on:ar,tween:or,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function cr(e,t){var n=ur(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function lr(e,t){var n=ur(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function ur(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function dr(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Qn(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return ir(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(ir(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function fr(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function pr(e){return this.each(function(){fr(this,e)})}function mr(e,t){var n,r;return function(){var i=lr(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function hr(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=lr(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function gr(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=ur(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?mr:hr)(n,e,t))}function _r(e,t,n){var r=e._id;return e.each(function(){var e=lr(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return ur(e,r).value[t]}}function vr(e,t){var n;return(typeof t==`number`?G:t instanceof V?H:(n=V(t))?(t=n,H):U)(e,t)}function yr(e){return function(){this.removeAttribute(e)}}function br(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xr(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function Sr(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function Cr(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function wr(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Tr(e,t){var n=Te(e),r=n===`transform`?fe:vr;return this.attrTween(e,typeof t==`function`?(n.local?wr:Cr)(n,r,_r(this,`attr.`+e,t)):t==null?(n.local?br:yr)(n):(n.local?Sr:xr)(n,r,t))}function Er(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Dr(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Or(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Dr(e,i)),n}return i._value=t,i}function kr(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Er(e,i)),n}return i._value=t,i}function Ar(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 Error();var r=Te(e);return this.tween(n,(r.local?Or:kr)(r,t))}function jr(e,t){return function(){cr(this,e).delay=+t.apply(this,arguments)}}function Mr(e,t){return t=+t,function(){cr(this,e).delay=t}}function Nr(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?jr:Mr)(t,e)):ur(this.node(),t).delay}function Pr(e,t){return function(){lr(this,e).duration=+t.apply(this,arguments)}}function Fr(e,t){return t=+t,function(){lr(this,e).duration=t}}function Ir(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Pr:Fr)(t,e)):ur(this.node(),t).duration}function Lr(e,t){if(typeof t!=`function`)throw Error();return function(){lr(this,e).ease=t}}function Rr(e){var t=this._id;return arguments.length?this.each(Lr(t,e)):ur(this.node(),t).ease}function zr(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();lr(this,e).ease=n}}function Br(e){if(typeof e!=`function`)throw Error();return this.each(zr(this._id,e))}function Vr(e){typeof e!=`function`&&(e=Le(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new gi(r,this._parents,this._name,this._id)}function Hr(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new gi(o,this._parents,this._name,this._id)}function Ur(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Wr(e,t,n){var r,i,a=Ur(t)?cr:lr;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Gr(e,t){var n=this._id;return arguments.length<2?ur(this.node(),n).on.on(e):this.each(Wr(n,e,t))}function Kr(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function qr(){return this.on(`end.remove`,Kr(this._id))}function Jr(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ae(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,sr(l[f],t,n,f,l,ur(u,n)));return new gi(a,this._parents,t,n)}function Yr(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Pe(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=ur(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&sr(p,t,n,h,f,m);a.push(f),o.push(u)}return new gi(a,o,t,n)}var Xr=bn.prototype.constructor;function Zr(){return new Xr(this._groups,this._parents)}function Qr(e,t){var n,r,i;return function(){var a=Dt(this,e),o=(this.style.removeProperty(e),Dt(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function $r(e){return function(){this.style.removeProperty(e)}}function ei(e,t,n){var r,i=n+``,a;return function(){var o=Dt(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function ti(e,t,n){var r,i,a;return function(){var o=Dt(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),Dt(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function ni(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=lr(this,e),l=c.on,u=c.value[a]==null?s||=$r(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function ri(e,t,n){var r=(e+=``)==`transform`?de:vr;return t==null?this.styleTween(e,Qr(e,r)).on(`end.style.`+e,$r(e)):typeof t==`function`?this.styleTween(e,ti(e,r,_r(this,`style.`+e,t))).each(ni(this._id,e)):this.styleTween(e,ei(e,r,t),n).on(`end.style.`+e,null)}function ii(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function ai(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&ii(e,a,n)),r}return a._value=t,a}function oi(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,ai(e,t,n??``))}function si(e){return function(){this.textContent=e}}function ci(e){return function(){var t=e(this);this.textContent=t??``}}function li(e){return this.tween(`text`,typeof e==`function`?ci(_r(this,`text`,e)):si(e==null?``:e+``))}function ui(e){return function(t){this.textContent=e.call(this,t)}}function di(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ui(r)),t}return r._value=e,r}function fi(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 Error();return this.tween(t,di(e))}function pi(){for(var e=this._name,t=this._id,n=vi(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=ur(c,t);sr(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new gi(r,this._parents,e,n)}function mi(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=lr(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var hi=0;function gi(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function _i(e){return bn().transition(e)}function vi(){return++hi}var yi=bn.prototype;gi.prototype=_i.prototype={constructor:gi,select:Jr,selectAll:Yr,selectChild:yi.selectChild,selectChildren:yi.selectChildren,filter:Vr,merge:Hr,selection:Zr,transition:pi,call:yi.call,nodes:yi.nodes,node:yi.node,size:yi.size,empty:yi.empty,each:yi.each,on:Gr,attr:Tr,attrTween:Ar,style:ri,styleTween:oi,text:li,textTween:fi,remove:qr,tween:gr,delay:Nr,duration:Ir,ease:Rr,easeVarying:Br,end:mi,[Symbol.iterator]:yi[Symbol.iterator]};function bi(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xi={time:null,delay:0,duration:250,ease:bi};function Si(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function Ci(e){var t,n;e instanceof gi?(t=e._id,e=e._name):(t=vi(),(n=xi).time=Yn(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&sr(c,e,t,l,o,n||Si(c,t));return new gi(r,this._parents,e,t)}bn.prototype.interrupt=pr,bn.prototype.transition=Ci;var wi=e=>()=>e;function Ti(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ei(e,t,n){this.k=e,this.x=t,this.y=n}Ei.prototype={constructor:Ei,scale:function(e){return e===1?this:new Ei(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ei(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 Di=new Ei(1,0,0);Oi.prototype=Ei.prototype;function Oi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Di;return e.__zoom}function ki(e){e.stopImmediatePropagation()}function Ai(e){e.preventDefault(),e.stopImmediatePropagation()}function ji(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function Mi(){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 Ni(){return this.__zoom||Di}function Pi(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Fi(){return navigator.maxTouchPoints||`ontouchstart`in this}function Ii(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function Li(){var e=ji,t=Mi,n=Ii,r=Pi,i=Fi,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=_e,l=ye(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Ni).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Ni),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Di.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Ei(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Ei(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Ei(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Sn(this.that).datum();l.call(e,this.that,new Ti(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=wn(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],fr(this),s.start();Ai(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Sn(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=wn(t,i),l=t.clientX,u=t.clientY;kn(t.view),ki(t),a.mouse=[c,this.__zoom.invert(c)],fr(this),a.start();function d(e){if(Ai(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=wn(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),An(e.view,a.moved),Ai(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=wn(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Ai(r),s>0?Sn(this).transition().duration(s).call(x,d,c,r):Sn(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(ki(t),s=0;s<i;++s)c=r[s],l=wn(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),fr(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(Ai(e),s=0;s<a;++s)c=i[s],l=wn(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(ki(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=wn(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=Sn(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:wi(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:wi(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:wi(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:wi([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var Ri={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},zi=[[-1/0,-1/0],[1/0,1/0]],Bi=[`Enter`,` `,`Escape`],Vi={"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`},Hi;(function(e){e.Strict=`strict`,e.Loose=`loose`})(Hi||={});var Ui;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(Ui||={});var Wi;(function(e){e.Partial=`partial`,e.Full=`full`})(Wi||={});var Gi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},Ki;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(Ki||={});var qi;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(qi||={});var X;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(X||={});var Ji={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function Yi(e){return e===null?null:e?`valid`:`invalid`}var Xi=e=>`id`in e&&`source`in e&&`target`in e,Zi=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),Qi=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),$i=(e,t=[0,0])=>{let{width:n,height:r}=Na(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},ea=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:ha(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):Qi(n)?n:t.nodeLookup.get(n.id)),pa(e,i?_a(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),ta=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=pa(n,_a(e)),r=!0)}),r?ha(n):{x:0,y:0,width:0,height:0}},na=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=ya(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},ra=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function ia(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function aa({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Aa(ta(ia(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function oa({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,Ri.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&Ma(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Ma(d)?la(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,Ri.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function sa({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=ra(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var ca=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),la=(e={x:0,y:0},t,n)=>({x:ca(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ca(e.y,t[0][1],t[1][1]-(n?.height??0))});function ua(e,t,n){let{width:r,height:i}=Na(n),{x:a,y:o}=n.internals.positionAbsolute;return la(e,[[a,o],[a+r,o+i]],t)}var da=(e,t,n)=>e<t?ca(Math.abs(e-t),1,t)/t:e>n?-ca(Math.abs(e-n),1,t)/t:0,fa=(e,t,n=15,r=40)=>[da(e.x,r,t.width-r)*n,da(e.y,r,t.height-r)*n],pa=(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)}),ma=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ha=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ga=(e,t=[0,0])=>{let{x:n,y:r}=Qi(e)?e.internals.positionAbsolute:$i(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},_a=(e,t=[0,0])=>{let{x:n,y:r}=Qi(e)?e.internals.positionAbsolute:$i(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},va=(e,t)=>ha(pa(ma(e),ma(t))),ya=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},ba=(e,t)=>ya(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),xa=e=>Sa(e.width)&&Sa(e.height)&&Sa(e.x)&&Sa(e.y),Sa=e=>!isNaN(e)&&isFinite(e),Ca=(e,t)=>(e,t)=>{},wa=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ta=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?wa(s,o):s},Ea=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Da(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let 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 Oa(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Da(e,n),i=Da(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Da(e.top??e.y??0,n),i=Da(e.bottom??e.y??0,n),a=Da(e.left??e.x??0,t),o=Da(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ka(e,t,n,r,i,a){let{x:o,y:s}=Ea(e,[t,n,r]),{x:c,y:l}=Ea({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Aa=(e,t,n,r,i,a)=>{let o=Oa(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=ca(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=ka(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},ja=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Ma(e){return e!=null&&e!==`parent`}function Na(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Pa(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Fa(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function Ia(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function La(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ra(e){return{...Vi,...e||{}}}function za(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=Ga(e),s=Ta({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?wa(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var Ba=e=>({width:e.offsetWidth,height:e.offsetHeight}),Va=e=>e?.getRootNode?.()||window?.document,Ha=[`INPUT`,`SELECT`,`TEXTAREA`];function Ua(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Ha.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Wa=e=>`clientX`in e,Ga=(e,t)=>{let n=Wa(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},Ka=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Ba(t)}})};function qa({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function Ja(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ya({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case X.Left:return[t-Ja(t-r,a),n];case X.Right:return[t+Ja(r-t,a),n];case X.Top:return[t,n-Ja(n-i,a)];case X.Bottom:return[t,n+Ja(i-n,a)]}}function Xa({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:i,targetPosition:a=X.Top,curvature:o=.25}){let[s,c]=Ya({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Ya({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=qa({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function Za({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function Qa({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function $a({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=pa(_a(e),_a(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),ba({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},ha(a))>0}var eo=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,to=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),no=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,Ri.error006()),t;let r=n.getEdgeId||eo,i;return i=Xi(e)?{...e}:{...e,id:r(e)},to(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function ro({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Za({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var io={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},ao=({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},oo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function so({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:r=X.Top,center:i,offset:a,stepPosition:o}){let s=io[t],c=io[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=ao({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=Za({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function co(e,t,n,r){let i=Math.min(oo(e,t)/2,oo(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function lo({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:i,targetPosition:a=X.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=so({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=co(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function uo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function fo(e){let{sourceNode:t,targetNode:n}=e;if(!uo(t)||!uo(n))return null;let r=t.internals.handleBounds||po(t.handles),i=n.internals.handleBounds||po(n.handles),a=ho(r?.source??[],e.sourceHandle),o=ho(e.connectionMode===Hi.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,Ri.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||X.Bottom,c=o?.position||X.Top,l=mo(t,a,s),u=mo(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function po(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function mo(e,t,n=X.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??Na(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case X.Top:return{x:i+o/2,y:a};case X.Right:return{x:i+o,y:a+s/2};case X.Bottom:return{x:i+o/2,y:a+s};case X.Left:return{x:i,y:a+s/2}}}function ho(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function go(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function _o(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=go(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var vo=1e3,yo=10,bo={nodeOrigin:[0,0],nodeExtent:zi,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},xo={...bo,checkEquality:!0};function So(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Co(e,t,n){let r=So(bo,n);for(let n of e.values())if(n.parentId)Oo(n,e,t,r);else{let e=la($i(n,r.nodeOrigin),Ma(n.extent)?n.extent:r.nodeExtent,Na(n));n.internals.positionAbsolute=e}}function wo(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function To(e){return e===`manual`}function Eo(e,t,n,r={}){let i=So(xo,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!To(i.zIndexMode)?vo:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=la($i(u,i.nodeOrigin),Ma(u.extent)?u.extent:i.nodeExtent,Na(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:wo(u,e),z:ko(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&Oo(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Do(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Oo(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=So(bo,r),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}Do(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*yo),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Ao(e,u,o,s,a&&!To(c)?vo:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function ko(e,t,n){let r=Sa(e.zIndex)?e.zIndex:0;return To(n)?r:r+(e.selected?t:0)}function Ao(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Na(e),l=$i(e,n),u=Ma(e.extent)?la(l,e.extent,c):l,d=la({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=ua(d,c,t));let f=ko(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function jo(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=va(a.get(n.parentId)?.expandedRect??ga(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=Na(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function Mo(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=Ba(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=Ma(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=ua(h,s,t.get(e.parentId)):m&&(h=la(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:Ka(`source`,r.nodeElement,p,d,e.id),target:Ka(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&Oo(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:ga(g,i)}))}}if(f.length>0){let e=jo(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function No({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function Po(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function Fo(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;Po(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),Po(`target`,s,c,e,i,o),t.set(r.id,r)}}function Io(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Io(n,t):!1}function Lo(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function Ro(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Io(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function zo({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function Bo({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=wa(a,t);return{x:o.x-a.x,y:o.y-a.y}}function Vo({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=Sn(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?ma(ta(s)):null,x=v&&l?Bo({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:wa(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=oa({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=zo({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=fa(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=za(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=Ro(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=zo({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=Ln().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=za(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=Ga(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=za(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=Ga(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=Ga(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=zo({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!Lo(t,`.${g}`,v))&&(!_||Lo(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function Ho(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())ba(i,ga(e))>0&&r.push(e);return r}var Uo=250;function Wo(e,t,n,r){let i=[],a=1/0,o=Ho(e,n,t+Uo);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=mo(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function Go(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...mo(o,c,c.position,!0)}:c}function Ko(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function qo(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Jo=()=>!0;function Yo(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=Jo,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=Va(e.target),E=0,D,{x:O,y:k}=Ga(e),A=Ko(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=Go(i,A,r,c,t);if(!N)return;let P=Ga(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=fa(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),H={inProgress:!0,isValid:null,from:mo(V,B,X.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:Ji[B.position],toNode:null,pointer:P};function U(){M=!0,y(H),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&U();function W(e){if(!M){let{x:t,y:n}=Ga(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;U()}if(!x()||!B){G(e);return}let a=b();P=Ga(e,j),D=Wo(Ta(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=Xo(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=qo(!!D,s.isValid);let u=c.get(i),f=u?mo(u,B,X.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?Ea({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:Ji[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),H=p}function G(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=H,r={...n,toPosition:H.toHandle?H.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,W),T.removeEventListener(`mouseup`,G),T.removeEventListener(`touchmove`,W),T.removeEventListener(`touchend`,G)}}T.addEventListener(`mousemove`,W),T.addEventListener(`mouseup`,G),T.addEventListener(`touchmove`,W),T.addEventListener(`touchend`,G)}function Xo(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Jo,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=Ga(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=Ko(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===Hi.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=Go(t,e,a,u,n,!0)}return _}var Zo={onPointerDown:Yo,isValid:Xo};function Qo({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=Sn(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&ja()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=Li().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:wn}}var $o=e=>({x:e.x,y:e.y,zoom:e.k}),es=({x:e,y:t,zoom:n})=>Di.translate(e,t).scale(n),ts=(e,t)=>e.target.closest(`.${t}`),ns=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),rs=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,is=(e,t=0,n=rs,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},as=e=>{let t=e.ctrlKey&&ja()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function os({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(ts(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=wn(u),t=d*2**as(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===Ui.Vertical?0:u.deltaX*f,m=i===Ui.Horizontal?0:u.deltaY*f;!ja()&&u.shiftKey&&i!==Ui.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=$o(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function ss({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=ts(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function cs({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=$o(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function ls({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&ns(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,$o(a.transform))}}function us({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&ns(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=$o(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function ds({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(ts(d,`${l}-flow__node`)||ts(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||ts(d,s)&&m||ts(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function fs({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=Li().scaleExtent([t,n]).translateExtent(r),f=Sn(e).call(d);v({x:i.x,y:i.y,zoom:ca(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(as);async function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?ee:_e).transform(is(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!Sa(E)||E<0?0:E);let k=O?os({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):ss({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});f.on(`wheel.zoom`,k,{passive:!1});let A=cs({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,A);let j=ls({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,j);let M=us({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,M);let N=ds({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(N),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=es(e),i=d?.constrain()(r,t,n);return i&&await h(i),i}async function y(e,t){let n=es(e);return await h(n,t),n}function b(e){if(f){let t=es(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?Oi(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?ee:_e).scaleTo(is(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?ee:_e).scaleBy(is(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!Sa(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var ps;(function(e){e.Line=`line`,e.Handle=`handle`})(ps||={});function ms({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function hs(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function gs(e,t){return Math.max(0,t-e)}function _s(e,t){return Math.max(0,e-t)}function vs(e,t,n){return Math.max(0,t-e,e-n)}function ys(e,t){return e?!t:t}function bs(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=vs(E,h,g),j=vs(D,_,v);if(o){let e=0,t=0;c&&w<0?e=gs(y+w+O,o[0][0]):!c&&w>0&&(e=_s(y+E+O,o[1][0])),l&&T<0?t=gs(b+T+k,o[0][1]):!l&&T>0&&(t=_s(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=_s(y+w,s[0][0]):!c&&w<0&&(e=gs(y+E,s[1][0])),l&&T>0?t=_s(b+T,s[0][1]):!l&&T<0&&(t=gs(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=vs(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?_s(b+k+E/C,o[1][1])*C:gs(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?gs(b+E/C,s[1][1])*C:_s(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=vs(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?_s(y+D*C+O,o[1][0])/C:gs(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?gs(y+D*C,s[1][0])/C:_s(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(ys(c,l)?-w:w)/C:w=(ys(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var xs={width:0,height:0,x:0,y:0},Ss={...xs,pointerX:0,pointerY:0,aspectRatio:1};function Cs(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function ws({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=Sn(e),o={controlDirection:hs(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...xs},h={...Ss};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:hs(e)};let g,_=null,v=[],y,b,x,S=!1,C=Ln().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=za(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=Ma(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Cs(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=za(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=bs(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=ms({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var Ts=e(W(),1),Es=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Ds=e=>e?Es(e):Es,{useDebugValue:Os}=K.default,{useSyncExternalStoreWithSelector:ks}=Ts.default,As=e=>e;function js(e,t=As,n){let r=ks(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Os(r),r}var Ms=(e,t)=>{let n=Ds(e),r=(e,r=t)=>js(n,e,r);return Object.assign(r,n),r},Ns=(e,t)=>e?Ms(e,t):Ms;function Z(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}r();var Ps=(0,K.createContext)(null),Fs=Ps.Provider,Is=Ri.error001(`react`);function Q(e,t){let n=(0,K.useContext)(Ps);if(n===null)throw Error(Is);return js(n,e,t)}function $(){let e=(0,K.useContext)(Ps);if(e===null)throw Error(Is);return(0,K.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Ls={display:`none`},Rs={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},zs=`react-flow__node-desc`,Bs=`react-flow__edge-desc`,Vs=`react-flow__aria-live`,Hs=e=>e.ariaLiveMessage,Us=e=>e.ariaLabelConfig;function Ws({rfId:e}){let t=Q(Hs);return(0,q.jsx)(`div`,{id:`${Vs}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Rs,children:t})}function Gs({rfId:e,disableKeyboardA11y:t}){let n=Q(Us);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{id:`${zs}-${e}`,style:Ls,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,q.jsx)(`div`,{id:`${Bs}-${e}`,style:Ls,children:n[`edge.a11yDescription.default`]}),!t&&(0,q.jsx)(Ws,{rfId:e})]})}var Ks=(0,K.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,q.jsx)(`div`,{className:J([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));Ks.displayName=`Panel`;var qs=`https://reactflow.dev?utm_source=attribution`;function Js({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,q.jsx)(Ks,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${qs}`,children:(0,q.jsx)(`a`,{href:qs,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var Ys=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Xs=e=>e.id;function Zs(e,t){return Z(e.selectedNodes.map(Xs),t.selectedNodes.map(Xs))&&Z(e.selectedEdges.map(Xs),t.selectedEdges.map(Xs))}function Qs({onSelectionChange:e}){let t=$(),{selectedNodes:n,selectedEdges:r}=Q(Ys,Zs);return(0,K.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var $s=e=>!!e.onSelectionChangeHandlers;function ec({onSelectionChange:e}){let t=Q($s);return e||t?(0,q.jsx)(Qs,{onSelectionChange:e}):null}var tc=[0,0],nc={x:0,y:0,zoom:1},rc=[...`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`.split(`.`),`rfId`],ic=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}),ac={translateExtent:zi,nodeOrigin:tc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function oc(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(ic,Z),l=$();(0,K.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=ac,s()}),[]);let u=(0,K.useRef)(ac);return(0,K.useEffect)(()=>{for(let s of rc){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Ra(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},rc.map(t=>e[t])),null}function sc(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function cc(e){let[t,n]=(0,K.useState)(e===`system`?null:e);return(0,K.useEffect)(()=>{if(e!==`system`){n(e);return}let t=sc(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?sc()?.matches?`dark`:`light`:t}var lc=typeof document<`u`?document:null;function uc(e=null,t={target:lc,actInsideInputWithModifier:!0}){let[n,r]=(0,K.useState)(!1),i=(0,K.useRef)(!1),a=(0,K.useRef)(new Set([])),[o,s]=(0,K.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{d as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{r as c,s as l}from"./useDesktop-RSMTyy7V.js";import{n as u,t as d}from"./save-B6wGWwBR.js";import{t as f}from"./brain-DI9lHkKY.js";import{t as p}from"./git-branch-BRM0F5GN.js";import{n as m,t as h}from"./square-Ci-PFcFe.js";import{t as g}from"./plus-CsnjfkmX.js";import{t as _}from"./trash-2-BOU3WdZZ.js";import{t as v}from"./triangle-alert-H9T4jAmh.js";import{t as y}from"./upload-DYMjAQ6M.js";import{a as b,l as x,o as S,r as C,t as w}from"./dialog-xXB2q5HJ.js";import{t as T}from"./utils-BC4DHlz2.js";import{t as E}from"./button-Ccc9Dc-D.js";import{t as D}from"./project-repositories-DYhTvwQ1.js";import{B as O,Et as k,Ot as A,R as j,V as M,Vt as N,bt as P,ct as F,g as I,h as L,rt as R,ut as z,z as B}from"./index-m5pKr1T6.js";import{a as V,i as H,n as U,o as W,r as G,t as ee}from"./value-s-gzBeyF.js";var te=s(`grid-3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),ne=s(`move-horizontal`,[[`path`,{d:`m18 8 4 4-4 4`,key:`1ak13k`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}]]),re=s(`move-vertical`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m8 18 4 4 4-4`,key:`bh5tu3`}],[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}]]),ie=180/Math.PI,ae={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function oe(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*ie,skewX:Math.atan(c)*ie,scaleX:o,scaleY:s}}var se;function ce(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?ae:oe(t.a,t.b,t.c,t.d,t.e,t.f)}function le(e){return e==null||(se||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),se.setAttribute(`transform`,e),!(e=se.transform.baseVal.consolidate()))?ae:(e=e.matrix,oe(e.a,e.b,e.c,e.d,e.e,e.f))}function ue(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:G(e,i)},{i:c-2,x:G(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:G(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:G(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:G(e,n)},{i:s-2,x:G(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var de=ue(ce,`px, `,`px)`,`deg)`),fe=ue(le,`, `,`)`,`)`),pe=1e-12;function me(e){return((e=Math.exp(e))+1/e)/2}function he(e){return((e=Math.exp(e))-1/e)/2}function ge(e){return((e=Math.exp(2*e))-1)/(e+1)}var _e=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<pe)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=me(y),c=s/(n*g)*(i*ge(t*r+y)-he(y));return[a+c*d,o+c*f,s*i/me(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),K=e(t(),1),q=n();function J(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=J(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var ve={value:()=>{}};function ye(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new be(n)}function be(e){this._=e}function xe(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}be.prototype=ye.prototype={constructor:be,on:function(e,t){var n=this._,r=xe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Se(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Ce(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ce(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new be(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Se(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ce(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=ve,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var we={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Te(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),we.hasOwnProperty(t)?{space:we[t],local:e}:e}function Ee(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function De(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Oe(e){var t=Te(e);return(t.local?De:Ee)(t)}function ke(){}function Ae(e){return e==null?ke:function(){return this.querySelector(e)}}function je(e){typeof e!=`function`&&(e=Ae(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Y(r,this._parents)}function Me(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ne(){return[]}function Pe(e){return e==null?Ne:function(){return this.querySelectorAll(e)}}function Fe(e){return function(){return Me(e.apply(this,arguments))}}function Ie(e){e=typeof e==`function`?Fe(e):Pe(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Y(r,i)}function Le(e){return function(){return this.matches(e)}}function Re(e){return function(t){return t.matches(e)}}var ze=Array.prototype.find;function Be(e){return function(){return ze.call(this.children,e)}}function Ve(){return this.firstElementChild}function He(e){return this.select(e==null?Ve:Be(typeof e==`function`?e:Re(e)))}var Ue=Array.prototype.filter;function We(){return Array.from(this.children)}function Ge(e){return function(){return Ue.call(this.children,e)}}function Ke(e){return this.selectAll(e==null?We:Ge(typeof e==`function`?e:Re(e)))}function qe(e){typeof e!=`function`&&(e=Le(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Y(r,this._parents)}function Je(e){return Array(e.length)}function Ye(){return new Y(this._enter||this._groups.map(Je),this._parents)}function Xe(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Xe.prototype={constructor:Xe,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 Ze(e){return function(){return e}}function Qe(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new Xe(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function $e(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new Xe(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function et(e){return e.__data__}function tt(e,t){if(!arguments.length)return Array.from(this,et);var n=t?$e:Qe,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Ze(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=nt(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Y(o,r),o._enter=s,o._exit=c,o}function nt(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function rt(){return new Y(this._exit||this._groups.map(Je),this._parents)}function it(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function at(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Y(s,this._parents)}function ot(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function st(e){e||=ct;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Y(i,this._parents).order()}function ct(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function lt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ut(){return Array.from(this)}function dt(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function ft(){let e=0;for(let t of this)++e;return e}function pt(){return!this.node()}function mt(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function ht(e){return function(){this.removeAttribute(e)}}function gt(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _t(e,t){return function(){this.setAttribute(e,t)}}function vt(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function yt(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function bt(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 xt(e,t){var n=Te(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?gt:ht:typeof t==`function`?n.local?bt:yt:n.local?vt:_t)(n,t))}function St(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Ct(e){return function(){this.style.removeProperty(e)}}function wt(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Tt(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Et(e,t,n){return arguments.length>1?this.each((t==null?Ct:typeof t==`function`?Tt:wt)(e,t,n??``)):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||St(e).getComputedStyle(e,null).getPropertyValue(t)}function Ot(e){return function(){delete this[e]}}function kt(e,t){return function(){this[e]=t}}function At(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function jt(e,t){return arguments.length>1?this.each((t==null?Ot:typeof t==`function`?At:kt)(e,t)):this.node()[e]}function Mt(e){return e.trim().split(/^|\s+/)}function Nt(e){return e.classList||new Pt(e)}function Pt(e){this._node=e,this._names=Mt(e.getAttribute(`class`)||``)}Pt.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Ft(e,t){for(var n=Nt(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function It(e,t){for(var n=Nt(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Lt(e){return function(){Ft(this,e)}}function Rt(e){return function(){It(this,e)}}function zt(e,t){return function(){(t.apply(this,arguments)?Ft:It)(this,e)}}function Bt(e,t){var n=Mt(e+``);if(arguments.length<2){for(var r=Nt(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?zt:t?Lt:Rt)(n,t))}function Vt(){this.textContent=``}function Ht(e){return function(){this.textContent=e}}function Ut(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function Wt(e){return arguments.length?this.each(e==null?Vt:(typeof e==`function`?Ut:Ht)(e)):this.node().textContent}function Gt(){this.innerHTML=``}function Kt(e){return function(){this.innerHTML=e}}function qt(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function Jt(e){return arguments.length?this.each(e==null?Gt:(typeof e==`function`?qt:Kt)(e)):this.node().innerHTML}function Yt(){this.nextSibling&&this.parentNode.appendChild(this)}function Xt(){return this.each(Yt)}function Zt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Qt(){return this.each(Zt)}function $t(e){var t=typeof e==`function`?e:Oe(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function en(){return null}function tn(e,t){var n=typeof e==`function`?e:Oe(e),r=t==null?en:typeof t==`function`?t:Ae(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function nn(){var e=this.parentNode;e&&e.removeChild(this)}function rn(){return this.each(nn)}function an(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function on(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function sn(e){return this.select(e?on:an)}function cn(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function ln(e){return function(t){e.call(this,t,this.__data__)}}function un(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function dn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function fn(e,t,n){return function(){var r=this.__on,i,a=ln(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function pn(e,t,n){var r=un(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?fn:dn,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function mn(e,t,n){var r=St(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function hn(e,t){return function(){return mn(this,e,t)}}function gn(e,t){return function(){return mn(this,e,t.apply(this,arguments))}}function _n(e,t){return this.each((typeof t==`function`?gn:hn)(e,t))}function*vn(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var yn=[null];function Y(e,t){this._groups=e,this._parents=t}function bn(){return new Y([[document.documentElement]],yn)}function xn(){return this}Y.prototype=bn.prototype={constructor:Y,select:je,selectAll:Ie,selectChild:He,selectChildren:Ke,filter:qe,data:tt,enter:Ye,exit:rt,join:it,merge:at,selection:xn,order:ot,sort:st,call:lt,nodes:ut,node:dt,size:ft,empty:pt,each:mt,attr:xt,style:Et,property:jt,classed:Bt,text:Wt,html:Jt,raise:Xt,lower:Qt,append:$t,insert:tn,remove:rn,clone:sn,datum:cn,on:pn,dispatch:_n,[Symbol.iterator]:vn};function Sn(e){return typeof e==`string`?new Y([[document.querySelector(e)]],[document.documentElement]):new Y([[e]],yn)}function Cn(e){let t;for(;t=e.sourceEvent;)e=t;return e}function wn(e,t){if(e=Cn(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Tn={passive:!1},En={capture:!0,passive:!1};function Dn(e){e.stopImmediatePropagation()}function On(e){e.preventDefault(),e.stopImmediatePropagation()}function kn(e){var t=e.document.documentElement,n=Sn(e).on(`dragstart.drag`,On,En);`onselectstart`in t?n.on(`selectstart.drag`,On,En):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function An(e,t){var n=e.document.documentElement,r=Sn(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,On,En),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var jn=e=>()=>e;function Mn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,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:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Mn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Nn(e){return!e.ctrlKey&&!e.button}function Pn(){return this.parentNode}function Fn(e,t){return t??{x:e.x,y:e.y}}function In(){return navigator.maxTouchPoints||`ontouchstart`in this}function Ln(){var e=Nn,t=Pn,n=Fn,r=In,i={},a=ye(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,Tn).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(Sn(n.view).on(`mousemove.drag`,m,En).on(`mouseup.drag`,h,En),kn(n.view),Dn(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(On(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){Sn(e.view).on(`mousemove.drag mouseup.drag`,null),An(e.view,l),On(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(Dn(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(On(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(Dn(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=wn(l||r,t),p,m,h;if((h=n.call(e,new Mn(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=wn(l||a,t),_=o;break}u.call(r,e,new Mn(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:jn(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:jn(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:jn(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:jn(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var Rn=0,zn=0,Bn=0,Vn=1e3,Hn,Un,Wn=0,Gn=0,Kn=0,qn=typeof performance==`object`&&performance.now?performance:Date,Jn=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yn(){return Gn||=(Jn(Xn),qn.now()+Kn)}function Xn(){Gn=0}function Zn(){this._call=this._time=this._next=null}Zn.prototype=Qn.prototype={constructor:Zn,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Yn():+n)+(t==null?0:+t),!this._next&&Un!==this&&(Un?Un._next=this:Hn=this,Un=this),this._call=e,this._time=n,rr()},stop:function(){this._call&&(this._call=null,this._time=1/0,rr())}};function Qn(e,t,n){var r=new Zn;return r.restart(e,t,n),r}function $n(){Yn(),++Rn;for(var e=Hn,t;e;)(t=Gn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Rn}function er(){Gn=(Wn=qn.now())+Kn,Rn=zn=0;try{$n()}finally{Rn=0,nr(),Gn=0}}function tr(){var e=qn.now(),t=e-Wn;t>Vn&&(Kn-=t,Wn=e)}function nr(){for(var e,t=Hn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Hn=n);Un=e,rr(r)}function rr(e){Rn||(zn&&=clearTimeout(zn),e-Gn>24?(e<1/0&&(zn=setTimeout(er,e-qn.now()-Kn)),Bn&&=clearInterval(Bn)):(Bn||=(Wn=qn.now(),setInterval(tr,Vn)),Rn=1,Jn(er)))}function ir(e,t,n){var r=new Zn;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var ar=ye(`start`,`end`,`cancel`,`interrupt`),or=[];function sr(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;dr(e,n,{name:t,index:r,group:i,on:ar,tween:or,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function cr(e,t){var n=ur(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function lr(e,t){var n=ur(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function ur(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function dr(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Qn(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return ir(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(ir(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function fr(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function pr(e){return this.each(function(){fr(this,e)})}function mr(e,t){var n,r;return function(){var i=lr(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function hr(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=lr(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function gr(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=ur(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?mr:hr)(n,e,t))}function _r(e,t,n){var r=e._id;return e.each(function(){var e=lr(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return ur(e,r).value[t]}}function vr(e,t){var n;return(typeof t==`number`?G:t instanceof V?H:(n=V(t))?(t=n,H):U)(e,t)}function yr(e){return function(){this.removeAttribute(e)}}function br(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xr(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function Sr(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function Cr(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function wr(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Tr(e,t){var n=Te(e),r=n===`transform`?fe:vr;return this.attrTween(e,typeof t==`function`?(n.local?wr:Cr)(n,r,_r(this,`attr.`+e,t)):t==null?(n.local?br:yr)(n):(n.local?Sr:xr)(n,r,t))}function Er(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Dr(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Or(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Dr(e,i)),n}return i._value=t,i}function kr(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Er(e,i)),n}return i._value=t,i}function Ar(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 Error();var r=Te(e);return this.tween(n,(r.local?Or:kr)(r,t))}function jr(e,t){return function(){cr(this,e).delay=+t.apply(this,arguments)}}function Mr(e,t){return t=+t,function(){cr(this,e).delay=t}}function Nr(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?jr:Mr)(t,e)):ur(this.node(),t).delay}function Pr(e,t){return function(){lr(this,e).duration=+t.apply(this,arguments)}}function Fr(e,t){return t=+t,function(){lr(this,e).duration=t}}function Ir(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Pr:Fr)(t,e)):ur(this.node(),t).duration}function Lr(e,t){if(typeof t!=`function`)throw Error();return function(){lr(this,e).ease=t}}function Rr(e){var t=this._id;return arguments.length?this.each(Lr(t,e)):ur(this.node(),t).ease}function zr(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();lr(this,e).ease=n}}function Br(e){if(typeof e!=`function`)throw Error();return this.each(zr(this._id,e))}function Vr(e){typeof e!=`function`&&(e=Le(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new gi(r,this._parents,this._name,this._id)}function Hr(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new gi(o,this._parents,this._name,this._id)}function Ur(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Wr(e,t,n){var r,i,a=Ur(t)?cr:lr;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Gr(e,t){var n=this._id;return arguments.length<2?ur(this.node(),n).on.on(e):this.each(Wr(n,e,t))}function Kr(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function qr(){return this.on(`end.remove`,Kr(this._id))}function Jr(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ae(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,sr(l[f],t,n,f,l,ur(u,n)));return new gi(a,this._parents,t,n)}function Yr(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Pe(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=ur(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&sr(p,t,n,h,f,m);a.push(f),o.push(u)}return new gi(a,o,t,n)}var Xr=bn.prototype.constructor;function Zr(){return new Xr(this._groups,this._parents)}function Qr(e,t){var n,r,i;return function(){var a=Dt(this,e),o=(this.style.removeProperty(e),Dt(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function $r(e){return function(){this.style.removeProperty(e)}}function ei(e,t,n){var r,i=n+``,a;return function(){var o=Dt(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function ti(e,t,n){var r,i,a;return function(){var o=Dt(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),Dt(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function ni(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=lr(this,e),l=c.on,u=c.value[a]==null?s||=$r(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function ri(e,t,n){var r=(e+=``)==`transform`?de:vr;return t==null?this.styleTween(e,Qr(e,r)).on(`end.style.`+e,$r(e)):typeof t==`function`?this.styleTween(e,ti(e,r,_r(this,`style.`+e,t))).each(ni(this._id,e)):this.styleTween(e,ei(e,r,t),n).on(`end.style.`+e,null)}function ii(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function ai(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&ii(e,a,n)),r}return a._value=t,a}function oi(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,ai(e,t,n??``))}function si(e){return function(){this.textContent=e}}function ci(e){return function(){var t=e(this);this.textContent=t??``}}function li(e){return this.tween(`text`,typeof e==`function`?ci(_r(this,`text`,e)):si(e==null?``:e+``))}function ui(e){return function(t){this.textContent=e.call(this,t)}}function di(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&ui(r)),t}return r._value=e,r}function fi(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 Error();return this.tween(t,di(e))}function pi(){for(var e=this._name,t=this._id,n=vi(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=ur(c,t);sr(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new gi(r,this._parents,e,n)}function mi(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=lr(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var hi=0;function gi(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function _i(e){return bn().transition(e)}function vi(){return++hi}var yi=bn.prototype;gi.prototype=_i.prototype={constructor:gi,select:Jr,selectAll:Yr,selectChild:yi.selectChild,selectChildren:yi.selectChildren,filter:Vr,merge:Hr,selection:Zr,transition:pi,call:yi.call,nodes:yi.nodes,node:yi.node,size:yi.size,empty:yi.empty,each:yi.each,on:Gr,attr:Tr,attrTween:Ar,style:ri,styleTween:oi,text:li,textTween:fi,remove:qr,tween:gr,delay:Nr,duration:Ir,ease:Rr,easeVarying:Br,end:mi,[Symbol.iterator]:yi[Symbol.iterator]};function bi(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xi={time:null,delay:0,duration:250,ease:bi};function Si(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function Ci(e){var t,n;e instanceof gi?(t=e._id,e=e._name):(t=vi(),(n=xi).time=Yn(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&sr(c,e,t,l,o,n||Si(c,t));return new gi(r,this._parents,e,t)}bn.prototype.interrupt=pr,bn.prototype.transition=Ci;var wi=e=>()=>e;function Ti(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ei(e,t,n){this.k=e,this.x=t,this.y=n}Ei.prototype={constructor:Ei,scale:function(e){return e===1?this:new Ei(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ei(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 Di=new Ei(1,0,0);Oi.prototype=Ei.prototype;function Oi(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Di;return e.__zoom}function ki(e){e.stopImmediatePropagation()}function Ai(e){e.preventDefault(),e.stopImmediatePropagation()}function ji(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function Mi(){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 Ni(){return this.__zoom||Di}function Pi(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Fi(){return navigator.maxTouchPoints||`ontouchstart`in this}function Ii(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function Li(){var e=ji,t=Mi,n=Ii,r=Pi,i=Fi,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=_e,l=ye(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Ni).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Ni),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Di.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Ei(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Ei(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Ei(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Sn(this.that).datum();l.call(e,this.that,new Ti(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=wn(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],fr(this),s.start();Ai(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Sn(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=wn(t,i),l=t.clientX,u=t.clientY;kn(t.view),ki(t),a.mouse=[c,this.__zoom.invert(c)],fr(this),a.start();function d(e){if(Ai(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=wn(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),An(e.view,a.moved),Ai(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=wn(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Ai(r),s>0?Sn(this).transition().duration(s).call(x,d,c,r):Sn(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(ki(t),s=0;s<i;++s)c=r[s],l=wn(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),fr(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(Ai(e),s=0;s<a;++s)c=i[s],l=wn(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(ki(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=wn(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=Sn(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:wi(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:wi(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:wi(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:wi([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var Ri={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},zi=[[-1/0,-1/0],[1/0,1/0]],Bi=[`Enter`,` `,`Escape`],Vi={"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`},Hi;(function(e){e.Strict=`strict`,e.Loose=`loose`})(Hi||={});var Ui;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(Ui||={});var Wi;(function(e){e.Partial=`partial`,e.Full=`full`})(Wi||={});var Gi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},Ki;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(Ki||={});var qi;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(qi||={});var X;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(X||={});var Ji={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function Yi(e){return e===null?null:e?`valid`:`invalid`}var Xi=e=>`id`in e&&`source`in e&&`target`in e,Zi=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),Qi=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),$i=(e,t=[0,0])=>{let{width:n,height:r}=Na(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},ea=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:ha(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):Qi(n)?n:t.nodeLookup.get(n.id)),pa(e,i?_a(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),ta=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=pa(n,_a(e)),r=!0)}),r?ha(n):{x:0,y:0,width:0,height:0}},na=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=ya(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},ra=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function ia(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function aa({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Aa(ta(ia(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function oa({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,Ri.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&Ma(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Ma(d)?la(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,Ri.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function sa({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=ra(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var ca=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),la=(e={x:0,y:0},t,n)=>({x:ca(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ca(e.y,t[0][1],t[1][1]-(n?.height??0))});function ua(e,t,n){let{width:r,height:i}=Na(n),{x:a,y:o}=n.internals.positionAbsolute;return la(e,[[a,o],[a+r,o+i]],t)}var da=(e,t,n)=>e<t?ca(Math.abs(e-t),1,t)/t:e>n?-ca(Math.abs(e-n),1,t)/t:0,fa=(e,t,n=15,r=40)=>[da(e.x,r,t.width-r)*n,da(e.y,r,t.height-r)*n],pa=(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)}),ma=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ha=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ga=(e,t=[0,0])=>{let{x:n,y:r}=Qi(e)?e.internals.positionAbsolute:$i(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},_a=(e,t=[0,0])=>{let{x:n,y:r}=Qi(e)?e.internals.positionAbsolute:$i(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},va=(e,t)=>ha(pa(ma(e),ma(t))),ya=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},ba=(e,t)=>ya(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),xa=e=>Sa(e.width)&&Sa(e.height)&&Sa(e.x)&&Sa(e.y),Sa=e=>!isNaN(e)&&isFinite(e),Ca=(e,t)=>(e,t)=>{},wa=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ta=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?wa(s,o):s},Ea=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Da(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let 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 Oa(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Da(e,n),i=Da(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Da(e.top??e.y??0,n),i=Da(e.bottom??e.y??0,n),a=Da(e.left??e.x??0,t),o=Da(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ka(e,t,n,r,i,a){let{x:o,y:s}=Ea(e,[t,n,r]),{x:c,y:l}=Ea({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Aa=(e,t,n,r,i,a)=>{let o=Oa(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=ca(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=ka(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},ja=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Ma(e){return e!=null&&e!==`parent`}function Na(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Pa(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Fa(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function Ia(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function La(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ra(e){return{...Vi,...e||{}}}function za(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=Ga(e),s=Ta({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?wa(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var Ba=e=>({width:e.offsetWidth,height:e.offsetHeight}),Va=e=>e?.getRootNode?.()||window?.document,Ha=[`INPUT`,`SELECT`,`TEXTAREA`];function Ua(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Ha.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Wa=e=>`clientX`in e,Ga=(e,t)=>{let n=Wa(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},Ka=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Ba(t)}})};function qa({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function Ja(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Ya({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case X.Left:return[t-Ja(t-r,a),n];case X.Right:return[t+Ja(r-t,a),n];case X.Top:return[t,n-Ja(n-i,a)];case X.Bottom:return[t,n+Ja(i-n,a)]}}function Xa({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:i,targetPosition:a=X.Top,curvature:o=.25}){let[s,c]=Ya({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Ya({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=qa({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function Za({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function Qa({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function $a({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=pa(_a(e),_a(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),ba({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},ha(a))>0}var eo=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,to=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),no=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,Ri.error006()),t;let r=n.getEdgeId||eo,i;return i=Xi(e)?{...e}:{...e,id:r(e)},to(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function ro({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Za({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var io={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},ao=({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},oo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function so({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:r=X.Top,center:i,offset:a,stepPosition:o}){let s=io[t],c=io[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=ao({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=Za({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function co(e,t,n,r){let i=Math.min(oo(e,t)/2,oo(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function lo({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:r,targetY:i,targetPosition:a=X.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=so({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=co(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function uo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function fo(e){let{sourceNode:t,targetNode:n}=e;if(!uo(t)||!uo(n))return null;let r=t.internals.handleBounds||po(t.handles),i=n.internals.handleBounds||po(n.handles),a=ho(r?.source??[],e.sourceHandle),o=ho(e.connectionMode===Hi.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,Ri.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||X.Bottom,c=o?.position||X.Top,l=mo(t,a,s),u=mo(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function po(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function mo(e,t,n=X.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??Na(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case X.Top:return{x:i+o/2,y:a};case X.Right:return{x:i+o,y:a+s/2};case X.Bottom:return{x:i+o/2,y:a+s};case X.Left:return{x:i,y:a+s/2}}}function ho(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function go(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function _o(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=go(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var vo=1e3,yo=10,bo={nodeOrigin:[0,0],nodeExtent:zi,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},xo={...bo,checkEquality:!0};function So(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Co(e,t,n){let r=So(bo,n);for(let n of e.values())if(n.parentId)Oo(n,e,t,r);else{let e=la($i(n,r.nodeOrigin),Ma(n.extent)?n.extent:r.nodeExtent,Na(n));n.internals.positionAbsolute=e}}function wo(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function To(e){return e===`manual`}function Eo(e,t,n,r={}){let i=So(xo,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!To(i.zIndexMode)?vo:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=la($i(u,i.nodeOrigin),Ma(u.extent)?u.extent:i.nodeExtent,Na(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:wo(u,e),z:ko(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&Oo(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Do(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Oo(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=So(bo,r),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}Do(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*yo),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Ao(e,u,o,s,a&&!To(c)?vo:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function ko(e,t,n){let r=Sa(e.zIndex)?e.zIndex:0;return To(n)?r:r+(e.selected?t:0)}function Ao(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Na(e),l=$i(e,n),u=Ma(e.extent)?la(l,e.extent,c):l,d=la({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=ua(d,c,t));let f=ko(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function jo(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=va(a.get(n.parentId)?.expandedRect??ga(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=Na(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function Mo(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=Ba(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=Ma(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=ua(h,s,t.get(e.parentId)):m&&(h=la(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:Ka(`source`,r.nodeElement,p,d,e.id),target:Ka(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&Oo(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:ga(g,i)}))}}if(f.length>0){let e=jo(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function No({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function Po(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function Fo(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;Po(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),Po(`target`,s,c,e,i,o),t.set(r.id,r)}}function Io(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Io(n,t):!1}function Lo(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function Ro(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Io(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function zo({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function Bo({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=wa(a,t);return{x:o.x-a.x,y:o.y-a.y}}function Vo({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=Sn(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?ma(ta(s)):null,x=v&&l?Bo({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:wa(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=oa({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=zo({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=fa(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=za(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=Ro(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=zo({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=Ln().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=za(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=Ga(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=za(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=Ga(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=Ga(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=zo({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!Lo(t,`.${g}`,v))&&(!_||Lo(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function Ho(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())ba(i,ga(e))>0&&r.push(e);return r}var Uo=250;function Wo(e,t,n,r){let i=[],a=1/0,o=Ho(e,n,t+Uo);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=mo(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function Go(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...mo(o,c,c.position,!0)}:c}function Ko(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function qo(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Jo=()=>!0;function Yo(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=Jo,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=Va(e.target),E=0,D,{x:O,y:k}=Ga(e),A=Ko(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=Go(i,A,r,c,t);if(!N)return;let P=Ga(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=fa(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),H={inProgress:!0,isValid:null,from:mo(V,B,X.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:Ji[B.position],toNode:null,pointer:P};function U(){M=!0,y(H),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&U();function W(e){if(!M){let{x:t,y:n}=Ga(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;U()}if(!x()||!B){G(e);return}let a=b();P=Ga(e,j),D=Wo(Ta(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=Xo(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=qo(!!D,s.isValid);let u=c.get(i),f=u?mo(u,B,X.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?Ea({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:Ji[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),H=p}function G(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=H,r={...n,toPosition:H.toHandle?H.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,W),T.removeEventListener(`mouseup`,G),T.removeEventListener(`touchmove`,W),T.removeEventListener(`touchend`,G)}}T.addEventListener(`mousemove`,W),T.addEventListener(`mouseup`,G),T.addEventListener(`touchmove`,W),T.addEventListener(`touchend`,G)}function Xo(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Jo,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=Ga(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=Ko(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===Hi.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=Go(t,e,a,u,n,!0)}return _}var Zo={onPointerDown:Yo,isValid:Xo};function Qo({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=Sn(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&ja()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=Li().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:wn}}var $o=e=>({x:e.x,y:e.y,zoom:e.k}),es=({x:e,y:t,zoom:n})=>Di.translate(e,t).scale(n),ts=(e,t)=>e.target.closest(`.${t}`),ns=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),rs=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,is=(e,t=0,n=rs,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},as=e=>{let t=e.ctrlKey&&ja()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function os({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(ts(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=wn(u),t=d*2**as(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===Ui.Vertical?0:u.deltaX*f,m=i===Ui.Horizontal?0:u.deltaY*f;!ja()&&u.shiftKey&&i!==Ui.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=$o(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function ss({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=ts(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function cs({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=$o(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function ls({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&ns(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,$o(a.transform))}}function us({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&ns(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=$o(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function ds({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(ts(d,`${l}-flow__node`)||ts(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||ts(d,s)&&m||ts(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function fs({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=Li().scaleExtent([t,n]).translateExtent(r),f=Sn(e).call(d);v({x:i.x,y:i.y,zoom:ca(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(as);async function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?ee:_e).transform(is(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!Sa(E)||E<0?0:E);let k=O?os({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):ss({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});f.on(`wheel.zoom`,k,{passive:!1});let A=cs({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,A);let j=ls({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,j);let M=us({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,M);let N=ds({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(N),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=es(e),i=d?.constrain()(r,t,n);return i&&await h(i),i}async function y(e,t){let n=es(e);return await h(n,t),n}function b(e){if(f){let t=es(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?Oi(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?ee:_e).scaleTo(is(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?ee:_e).scaleBy(is(f,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!Sa(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var ps;(function(e){e.Line=`line`,e.Handle=`handle`})(ps||={});function ms({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function hs(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function gs(e,t){return Math.max(0,t-e)}function _s(e,t){return Math.max(0,e-t)}function vs(e,t,n){return Math.max(0,t-e,e-n)}function ys(e,t){return e?!t:t}function bs(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=vs(E,h,g),j=vs(D,_,v);if(o){let e=0,t=0;c&&w<0?e=gs(y+w+O,o[0][0]):!c&&w>0&&(e=_s(y+E+O,o[1][0])),l&&T<0?t=gs(b+T+k,o[0][1]):!l&&T>0&&(t=_s(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=_s(y+w,s[0][0]):!c&&w<0&&(e=gs(y+E,s[1][0])),l&&T>0?t=_s(b+T,s[0][1]):!l&&T<0&&(t=gs(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=vs(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?_s(b+k+E/C,o[1][1])*C:gs(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?gs(b+E/C,s[1][1])*C:_s(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=vs(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?_s(y+D*C+O,o[1][0])/C:gs(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?gs(y+D*C,s[1][0])/C:_s(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(ys(c,l)?-w:w)/C:w=(ys(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var xs={width:0,height:0,x:0,y:0},Ss={...xs,pointerX:0,pointerY:0,aspectRatio:1};function Cs(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function ws({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=Sn(e),o={controlDirection:hs(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...xs},h={...Ss};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:hs(e)};let g,_=null,v=[],y,b,x,S=!1,C=Ln().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=za(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=Ma(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Cs(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=za(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=bs(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=ms({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var Ts=e(W(),1),Es=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Ds=e=>e?Es(e):Es,{useDebugValue:Os}=K.default,{useSyncExternalStoreWithSelector:ks}=Ts.default,As=e=>e;function js(e,t=As,n){let r=ks(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Os(r),r}var Ms=(e,t)=>{let n=Ds(e),r=(e,r=t)=>js(n,e,r);return Object.assign(r,n),r},Ns=(e,t)=>e?Ms(e,t):Ms;function Z(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}r();var Ps=(0,K.createContext)(null),Fs=Ps.Provider,Is=Ri.error001(`react`);function Q(e,t){let n=(0,K.useContext)(Ps);if(n===null)throw Error(Is);return js(n,e,t)}function $(){let e=(0,K.useContext)(Ps);if(e===null)throw Error(Is);return(0,K.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Ls={display:`none`},Rs={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},zs=`react-flow__node-desc`,Bs=`react-flow__edge-desc`,Vs=`react-flow__aria-live`,Hs=e=>e.ariaLiveMessage,Us=e=>e.ariaLabelConfig;function Ws({rfId:e}){let t=Q(Hs);return(0,q.jsx)(`div`,{id:`${Vs}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Rs,children:t})}function Gs({rfId:e,disableKeyboardA11y:t}){let n=Q(Us);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{id:`${zs}-${e}`,style:Ls,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,q.jsx)(`div`,{id:`${Bs}-${e}`,style:Ls,children:n[`edge.a11yDescription.default`]}),!t&&(0,q.jsx)(Ws,{rfId:e})]})}var Ks=(0,K.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,q.jsx)(`div`,{className:J([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));Ks.displayName=`Panel`;var qs=`https://reactflow.dev?utm_source=attribution`;function Js({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,q.jsx)(Ks,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${qs}`,children:(0,q.jsx)(`a`,{href:qs,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var Ys=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Xs=e=>e.id;function Zs(e,t){return Z(e.selectedNodes.map(Xs),t.selectedNodes.map(Xs))&&Z(e.selectedEdges.map(Xs),t.selectedEdges.map(Xs))}function Qs({onSelectionChange:e}){let t=$(),{selectedNodes:n,selectedEdges:r}=Q(Ys,Zs);return(0,K.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var $s=e=>!!e.onSelectionChangeHandlers;function ec({onSelectionChange:e}){let t=Q($s);return e||t?(0,q.jsx)(Qs,{onSelectionChange:e}):null}var tc=[0,0],nc={x:0,y:0,zoom:1},rc=[...`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`.split(`.`),`rfId`],ic=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}),ac={translateExtent:zi,nodeOrigin:tc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function oc(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(ic,Z),l=$();(0,K.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=ac,s()}),[]);let u=(0,K.useRef)(ac);return(0,K.useEffect)(()=>{for(let s of rc){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Ra(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},rc.map(t=>e[t])),null}function sc(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function cc(e){let[t,n]=(0,K.useState)(e===`system`?null:e);return(0,K.useEffect)(()=>{if(e!==`system`){n(e);return}let t=sc(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?sc()?.matches?`dark`:`light`:t}var lc=typeof document<`u`?document:null;function uc(e=null,t={target:lc,actInsideInputWithModifier:!0}){let[n,r]=(0,K.useState)(!1),i=(0,K.useRef)(!1),a=(0,K.useRef)(new Set([])),[o,s]=(0,K.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
2
2
  `).replace(`
3
3
 
4
4
  `,`
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{u as i}from"./chunk-KS7C4IRE-DEKu087k.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./brain-DI9lHkKY.js";import{t as s}from"./pencil-C9RkrIPZ.js";import{t as c}from"./square-Ci-PFcFe.js";import{t as l}from"./utils-BC4DHlz2.js";import{t as u}from"./button-DCBqEaZl.js";import{vt as d}from"./index-EzrkUb8B.js";import{r as f,t as p}from"./TemplatePreviewModal-BSyuZxGq.js";var m=e(t(),1),h=e(r(),1),g=n();function _({loop:e,onClose:t}){let{t:n}=a(`loops`),r=i();return(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,h.createPortal)((0,g.jsxs)(`div`,{"data-testid":`loop-preview-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,g.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t,"aria-hidden":!0}),(0,g.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":e.name,className:`relative flex max-h-[80vh] w-full max-w-lg flex-col gap-4 overflow-hidden rounded-xl border border-border/30 bg-popover p-6 shadow-xl backdrop-blur-md`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 pr-6`,children:[(0,g.jsx)(o,{className:`h-4 w-4 shrink-0 text-accent-highlight`}),(0,g.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold text-foreground`,children:e.name}),(0,g.jsxs)(`span`,{className:l(`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide`,e.locked?`border-accent-info/40 bg-accent-info/10 text-accent-info`:e.status===`published`?`border-accent-success/40 bg-accent-success/10 text-accent-success`:`border-border/60 bg-surface/60 text-foreground/60`),children:[e.locked&&(0,g.jsx)(d,{className:`h-2.5 w-2.5`}),e.locked?n(`preview.builtin`):n(`status.${e.status??`draft`}`,{defaultValue:e.status??``})]})]}),e.description&&(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]}),(0,g.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?n(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):n(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,g.jsxs)(`div`,{className:`min-h-0 space-y-1.5 overflow-y-auto pr-1`,children:[(0,g.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:n(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let r=p[e.type]??c,i=f(e);return(0,g.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,g.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[t+1,`.`]}),(0,g.jsx)(r,{className:`h-3.5 w-3.5 text-accent-primary`}),n(`builder.nodes.${e.type}`)]}),i&&(0,g.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground`,children:i})]},e.id)})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[(0,g.jsx)(u,{variant:`ghost`,onClick:t,children:n(`common:actions.close`)}),!e.locked&&(0,g.jsxs)(u,{"data-testid":`loop-preview-open-builder`,onClick:()=>{t(),r(`/loops/${encodeURIComponent(e.id)}/edit`)},children:[(0,g.jsx)(s,{className:`mr-1.5 h-3.5 w-3.5`}),n(`preview.openInBuilder`)]})]})]})]}),document.body)}export{_ as LoopPreviewModal};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{u as i}from"./chunk-KS7C4IRE-DEKu087k.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./brain-DI9lHkKY.js";import{t as s}from"./pencil-C9RkrIPZ.js";import{t as c}from"./square-Ci-PFcFe.js";import{t as l}from"./utils-BC4DHlz2.js";import{t as u}from"./button-Ccc9Dc-D.js";import{vt as d}from"./index-m5pKr1T6.js";import{r as f,t as p}from"./TemplatePreviewModal-COHFkUS4.js";var m=e(t(),1),h=e(r(),1),g=n();function _({loop:e,onClose:t}){let{t:n}=a(`loops`),r=i();return(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,h.createPortal)((0,g.jsxs)(`div`,{"data-testid":`loop-preview-modal`,className:`fixed inset-0 z-[65] flex items-center justify-center p-4`,children:[(0,g.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t,"aria-hidden":!0}),(0,g.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":e.name,className:`relative flex max-h-[80vh] w-full max-w-lg flex-col gap-4 overflow-hidden rounded-xl border border-border/30 bg-popover p-6 shadow-xl backdrop-blur-md`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 pr-6`,children:[(0,g.jsx)(o,{className:`h-4 w-4 shrink-0 text-accent-highlight`}),(0,g.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold text-foreground`,children:e.name}),(0,g.jsxs)(`span`,{className:l(`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide`,e.locked?`border-accent-info/40 bg-accent-info/10 text-accent-info`:e.status===`published`?`border-accent-success/40 bg-accent-success/10 text-accent-success`:`border-border/60 bg-surface/60 text-foreground/60`),children:[e.locked&&(0,g.jsx)(d,{className:`h-2.5 w-2.5`}),e.locked?n(`preview.builtin`):n(`status.${e.status??`draft`}`,{defaultValue:e.status??``})]})]}),e.description&&(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]}),(0,g.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?n(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):n(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,g.jsxs)(`div`,{className:`min-h-0 space-y-1.5 overflow-y-auto pr-1`,children:[(0,g.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:n(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let r=p[e.type]??c,i=f(e);return(0,g.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,g.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[t+1,`.`]}),(0,g.jsx)(r,{className:`h-3.5 w-3.5 text-accent-primary`}),n(`builder.nodes.${e.type}`)]}),i&&(0,g.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-mono text-[11px] text-muted-foreground`,children:i})]},e.id)})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[(0,g.jsx)(u,{variant:`ghost`,onClick:t,children:n(`common:actions.close`)}),!e.locked&&(0,g.jsxs)(u,{"data-testid":`loop-preview-open-builder`,onClick:()=>{t(),r(`/loops/${encodeURIComponent(e.id)}/edit`)},children:[(0,g.jsx)(s,{className:`mr-1.5 h-3.5 w-3.5`}),n(`preview.openInBuilder`)]})]})]})]}),document.body)}export{_ as LoopPreviewModal};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o,r as s,s as c}from"./useDesktop-RSMTyy7V.js";import{t as l}from"./download-CFHyyHcw.js";import{t as u}from"./pencil-C9RkrIPZ.js";import{n as d}from"./square-Ci-PFcFe.js";import{t as f}from"./plus-CsnjfkmX.js";import{t as p}from"./sparkles-DrY8hb0X.js";import{t as m}from"./trash-2-BOU3WdZZ.js";import{t as h}from"./upload-DYMjAQ6M.js";import{a as g,i as _,l as ee,o as te,r as v,t as ne}from"./dialog-SRw01_QU.js";import{t as y}from"./utils-BC4DHlz2.js";import{t as b}from"./button-DCBqEaZl.js";import{t as re}from"./RepositoryScopeSelector-D-RCaknl.js";import{a as x,p as ie,r as S,t as C}from"./provider-capabilities-B-wOHfLP.js";import{H as ae,Ot as w,U as oe,b as T,et as E,g as D,h as O,kt as k,m as A,y as j}from"./index-EzrkUb8B.js";import{n as M}from"./TemplatePreviewModal-BSyuZxGq.js";var N=a(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),P=a(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),F=e(t(),1);function I(e){return{specrailsLoops:1,loops:e.map(e=>({name:e.name,description:e.description,graph:e.graph}))}}function L(e){let t=e;return!!t&&typeof t.name==`string`&&!!t.graph&&typeof t.graph==`object`}function se(e){let t;try{t=JSON.parse(e)}catch{throw Error(`invalid-json`)}let n=(Array.isArray(t)?t:Array.isArray(t?.loops)?t.loops:L(t)?[t]:[]).filter(L);if(n.length===0)throw Error(`no-loops`);return n.map(e=>({name:e.name,description:e.description??null,graph:e.graph}))}function ce(e){return e.length===1?`${e[0].name.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`loop`}.loop.json`:`specrails-loops-${e.length}.json`}var R=[`API`,`Automation`,`CI`,`Database`,`Debugging`,`DevOps`,`Docs`,`Git`,`Maintenance`,`Performance`,`Planning`,`Quality`,`Review`,`Security`,`Testing`];function le(e,t){let n=t.query.trim().toLowerCase(),r=t.categories;return e.filter(e=>r.length>0&&!(e.category&&r.includes(e.category))?!1:!n||`${e.name} ${e.description} ${e.tags.join(` `)} ${e.category??``} ${e.searchTerms??``}`.toLowerCase().includes(n))}function ue(e){let t=new Map;for(let n of e)n.category&&t.set(n.category,(t.get(n.category)??0)+1);let n=[];for(let e of R){let r=t.get(e);r&&(n.push({category:e,count:r}),t.delete(e))}for(let e of[...t.keys()].sort())n.push({category:e,count:t.get(e)});return n}var z=n();function de({loop:e,projects:t,onClose:n,onExecute:r}){let{t:a}=i(`loops`),o=e!==null,[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[y,w]=(0,F.useState)(),E=t.find(e=>e.id===(s||t[0]?.id)),D=(0,F.useMemo)(()=>E?.providers??(E?.provider?[E.provider]:[]),[E]),O=l||D[0]||``,k=(0,F.useMemo)(()=>T(O),[O]),A=x(O),M=f&&(k.some(e=>e.value===f)||A&&oe(f))?f:j(O),N=ie(O,M),P=N.includes(m)?m:C(O,M)??``,I=N.length>0;return(0,z.jsx)(ne,{open:o,onOpenChange:e=>{e||n()},children:(0,z.jsx)(v,{movableResizable:!0,className:`max-w-sm`,children:e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(te,{children:[(0,z.jsx)(ee,{children:a(`run.title`,{name:e.name})}),(0,z.jsx)(_,{children:a(`run.subtitle`)})]}),(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.project`)}),t.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`run.noProjects`)}):(0,z.jsx)(`select`,{"aria-label":a(`run.project`),"data-testid":`run-project-select`,value:s||t[0]?.id,onChange:e=>{c(e.target.value),u(``),p(``),h(``),w(void 0)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,z.jsx)(re,{repositories:E?.repositories??[],value:y,onChange:w}),D.length>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.provider`)}),(0,z.jsx)(`select`,{"aria-label":a(`run.provider`),value:O,onChange:e=>{u(e.target.value),p(``),h(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:D.map(e=>(0,z.jsx)(`option`,{value:e,children:S(e)},e))})]}),k.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.model`)}),A?(0,z.jsx)(ae,{value:M,options:k,ariaLabel:a(`run.model`),testId:`run-model-select`,className:`w-full px-2 py-1 text-xs`,onCommit:e=>{p(e),h(C(O,e)??``)}}):(0,z.jsx)(`select`,{"aria-label":a(`run.model`),"data-testid":`run-model-select`,value:M,onChange:e=>{let t=e.target.value;p(t),h(C(O,t)??``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:k.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),I&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.effort`)}),(0,z.jsx)(`select`,{"aria-label":a(`run.effort`),value:P,onChange:e=>h(e.target.value),className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:N.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsxs)(g,{children:[(0,z.jsx)(b,{variant:`ghost`,onClick:n,children:a(`common:actions.cancel`)}),(0,z.jsxs)(b,{onClick:()=>{let e=s||t[0]?.id;e&&r({projectId:e,...y?{repositoryIds:y}:{},provider:D.length>1?O:void 0,model:k.length>0?M:void 0,effort:I?P:void 0})},disabled:t.length===0,children:[(0,z.jsx)(d,{className:`w-3.5 h-3.5 mr-1.5`}),a(`run.execute`)]})]})]})})})}var B={draft:`bg-accent-secondary/15 text-accent-secondary ring-accent-secondary/40`,published:`bg-accent-success/15 text-accent-success ring-accent-success/40`};function V({status:e}){let{t}=i(`loops`);return(0,z.jsx)(`span`,{className:y(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ring-1 ring-inset`,B[e]),children:t(`status.${e}`)})}function H({onOpenBuilder:e}={}){let{t}=i(`loops`),n=r(),a=(0,F.useCallback)(e=>e.replace(/:/g,`_`),[]),u=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.name`,{defaultValue:n}),[t,a]),d=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.description`,{defaultValue:n}),[t,a]),[h,re]=(0,F.useState)([]),[x,ie]=(0,F.useState)([]),[S,C]=(0,F.useState)([]),[ae,oe]=(0,F.useState)(!0),[T,j]=(0,F.useState)(null),[L,R]=(0,F.useState)(null),[B,V]=(0,F.useState)(`use`),[H,W]=(0,F.useState)(null),[G,pe]=(0,F.useState)(new Set),me=`specrails-desktop:loop-template-filter`,he=(()=>{try{let e=localStorage.getItem(me),t=e?JSON.parse(e):null;return{query:typeof t?.query==`string`?t.query:``,categories:Array.isArray(t?.categories)?t.categories:[]}}catch{return{query:``,categories:[]}}})(),[K,ge]=(0,F.useState)(he.query),[q,_e]=(0,F.useState)(he.categories);(0,F.useEffect)(()=>{try{localStorage.setItem(me,JSON.stringify({query:K,categories:q}))}catch{}},[K,q]);let ve=(0,F.useCallback)(e=>{_e(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),ye=(0,F.useCallback)(()=>{ge(``),_e([])},[]),be=(0,F.useRef)(null),{projects:xe,setActiveProjectId:Se}=s(),Ce=(0,F.useCallback)(e=>{pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),J=(0,F.useCallback)(e=>{if(e.length===0)return;let t=new Blob([JSON.stringify(I(e),null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=ce(e),r.click(),URL.revokeObjectURL(n)},[]),Y=(0,F.useCallback)(async()=>{try{let[e,t]=await Promise.all([D.list(),D.templates()]);re(e),ie(t)}catch{c.error(t(`errors.load`))}finally{oe(!1)}try{C(await D.factoryLoops())}catch{C([])}},[t]);(0,F.useEffect)(()=>{Y()},[Y]);let we=(0,F.useCallback)(async e=>{try{let n=se(await e.text()),{imported:r,skipped:i}=await D.importLoops(n);await Y(),r.length&&c.success(t(`import.done`,{count:r.length})),i.length&&c.warning(t(`import.skipped`,{count:i.length,names:i.join(`, `)})),!r.length&&!i.length&&c.warning(t(`import.invalid`))}catch(e){let n=e instanceof Error?e.message:``;c.error(t(n===`invalid-json`||n===`no-loops`?`import.invalid`:`errors.save`))}},[Y,t]),X=(0,F.useCallback)(t=>{e?e(t):n(`/loops/${t}/edit`)},[e,n]),Te=(0,F.useCallback)(async()=>{try{let e=await D.create({name:t(`newLoopName`)});X(e.id)}catch{c.error(t(`errors.save`))}},[t,X]),Z=(0,F.useCallback)(async e=>{try{let t=await D.fromTemplate(e);X(t.id)}catch{c.error(t(`errors.save`))}},[t,X]),Ee=(0,F.useCallback)(async e=>{try{let t=await D.forkFactory(e);X(t.id)}catch{c.error(t(`errors.save`))}},[t,X]),De=(0,F.useCallback)(async({projectId:e,provider:r,model:i,effort:a,repositoryIds:o})=>{let s=H;if(s){W(null);try{let{loopRunId:l}=await D.runStandalone(e,s.id,{aiEngine:r,model:i,reasoning_effort:a,...o?{repositoryIds:o}:{}});Se(e),n(`/jobs/${l}`),c.success(t(`run.launched`,{name:s.name}))}catch{c.error(t(`errors.save`))}}},[H,n,Se,t]),Oe=(0,F.useCallback)(e=>{V(`fork`),R({id:e.id,name:u(e.id,e.name),description:d(e.id,e.description),tags:e.requiredCapability?[e.requiredCapability]:e.claudeOnly?[`claude-only`]:[],graph:e.graph})},[u,d]),ke=(0,F.useCallback)(async e=>{try{await D.publish(e),await Y()}catch(e){e instanceof O?c.error(t(`errors.publishInvalid`)):c.error(t(`errors.save`))}},[t,Y]),Ae=(0,F.useCallback)(async e=>{try{await D.unpublish(e),await Y()}catch{c.error(t(`errors.save`))}},[t,Y]),je=(0,F.useCallback)(async e=>{try{await D.duplicate(e),await Y()}catch{c.error(t(`errors.save`))}},[t,Y]),Me=(0,F.useCallback)(e=>j(e),[]),Ne=(0,F.useCallback)(async()=>{let e=T;if(e){j(null);try{await D.remove(e),await Y()}catch{c.error(t(`errors.save`))}}},[T,t,Y]),Q=h.filter(e=>e.status===`draft`),$=h.filter(e=>e.status===`published`),Pe=ue(x),Fe=le(x.map(e=>({...e,searchTerms:`${u(e.id,e.name)} ${d(e.id,e.description)} ${e.category?t(`categories.${e.category}`,{defaultValue:e.category}):``}`})),{query:K,categories:q}),Ie=K.trim()!==``||q.length>0;return(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[(0,z.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 py-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(E,{className:`w-5 h-5 text-accent-primary`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:t(`title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:t(`subtitle`)})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G.size>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>J(h.filter(e=>G.has(e.id))),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,z.jsx)(N,{className:`w-3.5 h-3.5`}),t(`actions.export`),` (`,G.size,`)`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>be.current?.click(),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,z.jsx)(P,{className:`w-3.5 h-3.5`}),t(`actions.import`)]}),(0,z.jsx)(`input`,{ref:be,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&we(t),e.target.value=``}}),(0,z.jsxs)(`button`,{type:`button`,onClick:Te,className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium bg-accent-primary text-white hover:bg-accent-primary/90`,children:[(0,z.jsx)(f,{className:`w-3.5 h-3.5`}),t(`newLoop`)]})]})]}),ae?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`…`}):(0,z.jsxs)(`div`,{className:`space-y-8`,children:[Q.length===0&&$.length===0&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t(`empty.title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t(`empty.body`)})]}),$.length>0&&(0,z.jsx)(U,{title:t(`sections.published`),children:$.map(e=>(0,z.jsx)(fe,{loop:e,selected:G.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>X(e.id),onUnpublish:()=>Ae(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id),onRun:A(e.graph)?void 0:()=>W(e)},e.id))}),Q.length>0&&(0,z.jsx)(U,{title:t(`sections.drafts`),children:Q.map(e=>(0,z.jsx)(fe,{loop:e,selected:G.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>X(e.id),onPublish:()=>ke(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id)},e.id))}),S.length>0&&(0,z.jsx)(U,{title:t(`sections.builtIn`),children:S.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`factory-loop-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(E,{className:`w-3.5 h-3.5 text-accent-primary`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:u(e.id,e.name)}),(0,z.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:t(`builtInBadge`)})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:d(e.id,e.description)}),e.launchable===!1&&(0,z.jsxs)(`p`,{className:`text-[11px] text-accent-info/90 flex items-start gap-1.5`,"data-testid":`factory-loop-automatic`,children:[(0,z.jsx)(p,{className:`w-3 h-3 mt-0.5 shrink-0`,"aria-hidden":!0}),t(`automaticOnly`)]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Oe(e),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(w,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void Ee(e.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(k,{className:`w-3 h-3`}),t(`actions.fork`)]})]})]},e.id))}),x.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`sections.templates`)}),(0,z.jsx)(`input`,{type:`search`,value:K,onChange:e=>ge(e.target.value),placeholder:t(`gallery.search`),"aria-label":t(`gallery.search`),"data-testid":`template-search`,className:`h-7 w-48 max-w-full rounded-md border border-border bg-surface/40 px-2.5 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-accent-primary`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,"data-testid":`category-chips`,children:[Pe.map(({category:e,count:n})=>{let r=q.includes(e);return(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ve(e),className:y(`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] border transition-colors`,r?`border-accent-primary bg-accent-primary/15 text-accent-primary`:`border-border bg-surface/40 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[t(`categories.${e}`,{defaultValue:e}),(0,z.jsx)(`span`,{className:`opacity-60 tabular-nums`,children:n})]},e)}),Ie&&(0,z.jsx)(`button`,{type:`button`,onClick:ye,className:`inline-flex items-center h-6 px-2 rounded-full text-[11px] text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}),Fe.length===0?(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,"data-testid":`template-empty`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`gallery.noResults`)}),(0,z.jsx)(`button`,{type:`button`,onClick:ye,className:`mt-2 text-xs text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}):(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:Fe.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`template-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(p,{className:`w-3.5 h-3.5 text-accent-highlight flex-shrink-0`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:u(e.id,e.name)}),e.category&&(0,z.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info flex-shrink-0`,children:t(`categories.${e.category}`,{defaultValue:e.category})})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:d(e.id,e.description)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[A(e.graph)?(0,z.jsx)(`span`,{title:t(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:t(`gallery.needsSpec`)}):(0,z.jsx)(`span`,{title:t(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:t(`gallery.standalone`)}),e.tags.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{V(`use`),R({...e,name:u(e.id,e.name),description:d(e.id,e.description)})},className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(w,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Z(e.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(l,{className:`w-3 h-3`}),t(`actions.use`)]})]})]},e.id))})]})]})]}),(0,z.jsx)(ne,{open:T!==null,onOpenChange:e=>{e||j(null)},children:(0,z.jsxs)(v,{className:`max-w-sm`,children:[(0,z.jsxs)(te,{children:[(0,z.jsxs)(ee,{className:`flex items-center gap-2`,children:[(0,z.jsx)(m,{className:`w-4 h-4 text-destructive`}),h.find(e=>e.id===T)?.name??t(`actions.delete`)]}),(0,z.jsx)(_,{children:t(`confirmDelete`)})]}),(0,z.jsxs)(g,{children:[(0,z.jsx)(b,{variant:`ghost`,onClick:()=>j(null),children:t(`common:actions.cancel`)}),(0,z.jsx)(b,{variant:`destructive`,onClick:()=>void Ne(),children:t(`common:actions.delete`)})]})]})}),(0,z.jsx)(M,{template:L,mode:B,onClose:()=>R(null),onUse:e=>{R(null),B===`fork`?Ee(e):Z(e)}}),(0,z.jsx)(de,{loop:H?{id:H.id,name:H.name}:null,projects:xe.map(e=>({id:e.id,name:e.name,providers:o(e),repositories:e.repositories})),onClose:()=>W(null),onExecute:De})]})}function U({title:e,children:t}){return(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:e}),(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t})]})}function fe({loop:e,selected:t,onToggleSelect:n,onEdit:r,onPublish:a,onUnpublish:o,onDuplicate:s,onExport:c,onDelete:f,onRun:p}){let{t:g}=i(`loops`),_=e.graph?.nodes?.length??0;return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`loop-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,"aria-label":g(`actions.select`,{name:e.name}),className:`accent-accent-primary flex-shrink-0`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.name})]}),(0,z.jsx)(V,{status:e.status})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`card.nodes`,{count:_})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[p&&(0,z.jsx)(W,{icon:d,label:g(`actions.run`),onClick:p}),(0,z.jsx)(W,{icon:u,label:g(`actions.edit`),onClick:r}),a&&(0,z.jsx)(W,{icon:h,label:g(`actions.publish`),onClick:a}),o&&(0,z.jsx)(W,{icon:l,label:g(`actions.unpublish`),onClick:o}),(0,z.jsx)(W,{icon:k,label:g(`actions.duplicate`),onClick:s}),(0,z.jsx)(W,{icon:N,label:g(`actions.export`),onClick:c}),(0,z.jsx)(W,{icon:m,label:g(`actions.delete`),onClick:f,danger:!0})]})]})}function W({icon:e,label:t,onClick:n,danger:r}){return(0,z.jsx)(`button`,{type:`button`,onClick:n,title:t,"aria-label":t,className:y(`inline-flex items-center justify-center w-7 h-7 rounded-md transition-colors`,r?`text-muted-foreground hover:text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,z.jsx)(e,{className:`w-3.5 h-3.5`})})}export{H as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o,r as s,s as c}from"./useDesktop-RSMTyy7V.js";import{t as l}from"./download-CFHyyHcw.js";import{t as u}from"./pencil-C9RkrIPZ.js";import{n as d}from"./square-Ci-PFcFe.js";import{t as f}from"./plus-CsnjfkmX.js";import{t as p}from"./sparkles-DrY8hb0X.js";import{t as m}from"./trash-2-BOU3WdZZ.js";import{t as h}from"./upload-DYMjAQ6M.js";import{a as g,i as _,l as ee,o as te,r as v,t as ne}from"./dialog-xXB2q5HJ.js";import{t as y}from"./utils-BC4DHlz2.js";import{t as b}from"./button-Ccc9Dc-D.js";import{t as re}from"./RepositoryScopeSelector-D-RCaknl.js";import{a as x,p as ie,r as S,t as C}from"./provider-capabilities-B-wOHfLP.js";import{H as ae,Ot as w,U as oe,b as T,et as E,g as D,h as O,kt as k,m as A,y as j}from"./index-m5pKr1T6.js";import{n as M}from"./TemplatePreviewModal-COHFkUS4.js";var N=a(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),P=a(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),F=e(t(),1);function I(e){return{specrailsLoops:1,loops:e.map(e=>({name:e.name,description:e.description,graph:e.graph}))}}function L(e){let t=e;return!!t&&typeof t.name==`string`&&!!t.graph&&typeof t.graph==`object`}function se(e){let t;try{t=JSON.parse(e)}catch{throw Error(`invalid-json`)}let n=(Array.isArray(t)?t:Array.isArray(t?.loops)?t.loops:L(t)?[t]:[]).filter(L);if(n.length===0)throw Error(`no-loops`);return n.map(e=>({name:e.name,description:e.description??null,graph:e.graph}))}function ce(e){return e.length===1?`${e[0].name.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`loop`}.loop.json`:`specrails-loops-${e.length}.json`}var R=[`API`,`Automation`,`CI`,`Database`,`Debugging`,`DevOps`,`Docs`,`Git`,`Maintenance`,`Performance`,`Planning`,`Quality`,`Review`,`Security`,`Testing`];function le(e,t){let n=t.query.trim().toLowerCase(),r=t.categories;return e.filter(e=>r.length>0&&!(e.category&&r.includes(e.category))?!1:!n||`${e.name} ${e.description} ${e.tags.join(` `)} ${e.category??``} ${e.searchTerms??``}`.toLowerCase().includes(n))}function ue(e){let t=new Map;for(let n of e)n.category&&t.set(n.category,(t.get(n.category)??0)+1);let n=[];for(let e of R){let r=t.get(e);r&&(n.push({category:e,count:r}),t.delete(e))}for(let e of[...t.keys()].sort())n.push({category:e,count:t.get(e)});return n}var z=n();function de({loop:e,projects:t,onClose:n,onExecute:r}){let{t:a}=i(`loops`),o=e!==null,[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[y,w]=(0,F.useState)(),E=t.find(e=>e.id===(s||t[0]?.id)),D=(0,F.useMemo)(()=>E?.providers??(E?.provider?[E.provider]:[]),[E]),O=l||D[0]||``,k=(0,F.useMemo)(()=>T(O),[O]),A=x(O),M=f&&(k.some(e=>e.value===f)||A&&oe(f))?f:j(O),N=ie(O,M),P=N.includes(m)?m:C(O,M)??``,I=N.length>0;return(0,z.jsx)(ne,{open:o,onOpenChange:e=>{e||n()},children:(0,z.jsx)(v,{movableResizable:!0,className:`max-w-sm`,children:e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(te,{children:[(0,z.jsx)(ee,{children:a(`run.title`,{name:e.name})}),(0,z.jsx)(_,{children:a(`run.subtitle`)})]}),(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.project`)}),t.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`run.noProjects`)}):(0,z.jsx)(`select`,{"aria-label":a(`run.project`),"data-testid":`run-project-select`,value:s||t[0]?.id,onChange:e=>{c(e.target.value),u(``),p(``),h(``),w(void 0)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,z.jsx)(re,{repositories:E?.repositories??[],value:y,onChange:w}),D.length>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.provider`)}),(0,z.jsx)(`select`,{"aria-label":a(`run.provider`),value:O,onChange:e=>{u(e.target.value),p(``),h(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:D.map(e=>(0,z.jsx)(`option`,{value:e,children:S(e)},e))})]}),k.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.model`)}),A?(0,z.jsx)(ae,{value:M,options:k,ariaLabel:a(`run.model`),testId:`run-model-select`,className:`w-full px-2 py-1 text-xs`,onCommit:e=>{p(e),h(C(O,e)??``)}}):(0,z.jsx)(`select`,{"aria-label":a(`run.model`),"data-testid":`run-model-select`,value:M,onChange:e=>{let t=e.target.value;p(t),h(C(O,t)??``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:k.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),I&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.effort`)}),(0,z.jsx)(`select`,{"aria-label":a(`run.effort`),value:P,onChange:e=>h(e.target.value),className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:N.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsxs)(g,{children:[(0,z.jsx)(b,{variant:`ghost`,onClick:n,children:a(`common:actions.cancel`)}),(0,z.jsxs)(b,{onClick:()=>{let e=s||t[0]?.id;e&&r({projectId:e,...y?{repositoryIds:y}:{},provider:D.length>1?O:void 0,model:k.length>0?M:void 0,effort:I?P:void 0})},disabled:t.length===0,children:[(0,z.jsx)(d,{className:`w-3.5 h-3.5 mr-1.5`}),a(`run.execute`)]})]})]})})})}var B={draft:`bg-accent-secondary/15 text-accent-secondary ring-accent-secondary/40`,published:`bg-accent-success/15 text-accent-success ring-accent-success/40`};function V({status:e}){let{t}=i(`loops`);return(0,z.jsx)(`span`,{className:y(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ring-1 ring-inset`,B[e]),children:t(`status.${e}`)})}function H({onOpenBuilder:e}={}){let{t}=i(`loops`),n=r(),a=(0,F.useCallback)(e=>e.replace(/:/g,`_`),[]),u=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.name`,{defaultValue:n}),[t,a]),d=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.description`,{defaultValue:n}),[t,a]),[h,re]=(0,F.useState)([]),[x,ie]=(0,F.useState)([]),[S,C]=(0,F.useState)([]),[ae,oe]=(0,F.useState)(!0),[T,j]=(0,F.useState)(null),[L,R]=(0,F.useState)(null),[B,V]=(0,F.useState)(`use`),[H,W]=(0,F.useState)(null),[G,pe]=(0,F.useState)(new Set),me=`specrails-desktop:loop-template-filter`,he=(()=>{try{let e=localStorage.getItem(me),t=e?JSON.parse(e):null;return{query:typeof t?.query==`string`?t.query:``,categories:Array.isArray(t?.categories)?t.categories:[]}}catch{return{query:``,categories:[]}}})(),[K,ge]=(0,F.useState)(he.query),[q,_e]=(0,F.useState)(he.categories);(0,F.useEffect)(()=>{try{localStorage.setItem(me,JSON.stringify({query:K,categories:q}))}catch{}},[K,q]);let ve=(0,F.useCallback)(e=>{_e(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),ye=(0,F.useCallback)(()=>{ge(``),_e([])},[]),be=(0,F.useRef)(null),{projects:xe,setActiveProjectId:Se}=s(),Ce=(0,F.useCallback)(e=>{pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),J=(0,F.useCallback)(e=>{if(e.length===0)return;let t=new Blob([JSON.stringify(I(e),null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=ce(e),r.click(),URL.revokeObjectURL(n)},[]),Y=(0,F.useCallback)(async()=>{try{let[e,t]=await Promise.all([D.list(),D.templates()]);re(e),ie(t)}catch{c.error(t(`errors.load`))}finally{oe(!1)}try{C(await D.factoryLoops())}catch{C([])}},[t]);(0,F.useEffect)(()=>{Y()},[Y]);let we=(0,F.useCallback)(async e=>{try{let n=se(await e.text()),{imported:r,skipped:i}=await D.importLoops(n);await Y(),r.length&&c.success(t(`import.done`,{count:r.length})),i.length&&c.warning(t(`import.skipped`,{count:i.length,names:i.join(`, `)})),!r.length&&!i.length&&c.warning(t(`import.invalid`))}catch(e){let n=e instanceof Error?e.message:``;c.error(t(n===`invalid-json`||n===`no-loops`?`import.invalid`:`errors.save`))}},[Y,t]),X=(0,F.useCallback)(t=>{e?e(t):n(`/loops/${t}/edit`)},[e,n]),Te=(0,F.useCallback)(async()=>{try{let e=await D.create({name:t(`newLoopName`)});X(e.id)}catch{c.error(t(`errors.save`))}},[t,X]),Z=(0,F.useCallback)(async e=>{try{let t=await D.fromTemplate(e);X(t.id)}catch{c.error(t(`errors.save`))}},[t,X]),Ee=(0,F.useCallback)(async e=>{try{let t=await D.forkFactory(e);X(t.id)}catch{c.error(t(`errors.save`))}},[t,X]),De=(0,F.useCallback)(async({projectId:e,provider:r,model:i,effort:a,repositoryIds:o})=>{let s=H;if(s){W(null);try{let{loopRunId:l}=await D.runStandalone(e,s.id,{aiEngine:r,model:i,reasoning_effort:a,...o?{repositoryIds:o}:{}});Se(e),n(`/jobs/${l}`),c.success(t(`run.launched`,{name:s.name}))}catch{c.error(t(`errors.save`))}}},[H,n,Se,t]),Oe=(0,F.useCallback)(e=>{V(`fork`),R({id:e.id,name:u(e.id,e.name),description:d(e.id,e.description),tags:e.requiredCapability?[e.requiredCapability]:e.claudeOnly?[`claude-only`]:[],graph:e.graph})},[u,d]),ke=(0,F.useCallback)(async e=>{try{await D.publish(e),await Y()}catch(e){e instanceof O?c.error(t(`errors.publishInvalid`)):c.error(t(`errors.save`))}},[t,Y]),Ae=(0,F.useCallback)(async e=>{try{await D.unpublish(e),await Y()}catch{c.error(t(`errors.save`))}},[t,Y]),je=(0,F.useCallback)(async e=>{try{await D.duplicate(e),await Y()}catch{c.error(t(`errors.save`))}},[t,Y]),Me=(0,F.useCallback)(e=>j(e),[]),Ne=(0,F.useCallback)(async()=>{let e=T;if(e){j(null);try{await D.remove(e),await Y()}catch{c.error(t(`errors.save`))}}},[T,t,Y]),Q=h.filter(e=>e.status===`draft`),$=h.filter(e=>e.status===`published`),Pe=ue(x),Fe=le(x.map(e=>({...e,searchTerms:`${u(e.id,e.name)} ${d(e.id,e.description)} ${e.category?t(`categories.${e.category}`,{defaultValue:e.category}):``}`})),{query:K,categories:q}),Ie=K.trim()!==``||q.length>0;return(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[(0,z.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 py-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(E,{className:`w-5 h-5 text-accent-primary`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:t(`title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:t(`subtitle`)})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G.size>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>J(h.filter(e=>G.has(e.id))),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,z.jsx)(N,{className:`w-3.5 h-3.5`}),t(`actions.export`),` (`,G.size,`)`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>be.current?.click(),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,z.jsx)(P,{className:`w-3.5 h-3.5`}),t(`actions.import`)]}),(0,z.jsx)(`input`,{ref:be,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&we(t),e.target.value=``}}),(0,z.jsxs)(`button`,{type:`button`,onClick:Te,className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium bg-accent-primary text-white hover:bg-accent-primary/90`,children:[(0,z.jsx)(f,{className:`w-3.5 h-3.5`}),t(`newLoop`)]})]})]}),ae?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`…`}):(0,z.jsxs)(`div`,{className:`space-y-8`,children:[Q.length===0&&$.length===0&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t(`empty.title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t(`empty.body`)})]}),$.length>0&&(0,z.jsx)(U,{title:t(`sections.published`),children:$.map(e=>(0,z.jsx)(fe,{loop:e,selected:G.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>X(e.id),onUnpublish:()=>Ae(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id),onRun:A(e.graph)?void 0:()=>W(e)},e.id))}),Q.length>0&&(0,z.jsx)(U,{title:t(`sections.drafts`),children:Q.map(e=>(0,z.jsx)(fe,{loop:e,selected:G.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>X(e.id),onPublish:()=>ke(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id)},e.id))}),S.length>0&&(0,z.jsx)(U,{title:t(`sections.builtIn`),children:S.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`factory-loop-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(E,{className:`w-3.5 h-3.5 text-accent-primary`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:u(e.id,e.name)}),(0,z.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:t(`builtInBadge`)})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:d(e.id,e.description)}),e.launchable===!1&&(0,z.jsxs)(`p`,{className:`text-[11px] text-accent-info/90 flex items-start gap-1.5`,"data-testid":`factory-loop-automatic`,children:[(0,z.jsx)(p,{className:`w-3 h-3 mt-0.5 shrink-0`,"aria-hidden":!0}),t(`automaticOnly`)]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Oe(e),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(w,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void Ee(e.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(k,{className:`w-3 h-3`}),t(`actions.fork`)]})]})]},e.id))}),x.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`sections.templates`)}),(0,z.jsx)(`input`,{type:`search`,value:K,onChange:e=>ge(e.target.value),placeholder:t(`gallery.search`),"aria-label":t(`gallery.search`),"data-testid":`template-search`,className:`h-7 w-48 max-w-full rounded-md border border-border bg-surface/40 px-2.5 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-accent-primary`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,"data-testid":`category-chips`,children:[Pe.map(({category:e,count:n})=>{let r=q.includes(e);return(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ve(e),className:y(`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] border transition-colors`,r?`border-accent-primary bg-accent-primary/15 text-accent-primary`:`border-border bg-surface/40 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[t(`categories.${e}`,{defaultValue:e}),(0,z.jsx)(`span`,{className:`opacity-60 tabular-nums`,children:n})]},e)}),Ie&&(0,z.jsx)(`button`,{type:`button`,onClick:ye,className:`inline-flex items-center h-6 px-2 rounded-full text-[11px] text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}),Fe.length===0?(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,"data-testid":`template-empty`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`gallery.noResults`)}),(0,z.jsx)(`button`,{type:`button`,onClick:ye,className:`mt-2 text-xs text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}):(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:Fe.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`template-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(p,{className:`w-3.5 h-3.5 text-accent-highlight flex-shrink-0`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:u(e.id,e.name)}),e.category&&(0,z.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info flex-shrink-0`,children:t(`categories.${e.category}`,{defaultValue:e.category})})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:d(e.id,e.description)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[A(e.graph)?(0,z.jsx)(`span`,{title:t(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:t(`gallery.needsSpec`)}):(0,z.jsx)(`span`,{title:t(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:t(`gallery.standalone`)}),e.tags.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{V(`use`),R({...e,name:u(e.id,e.name),description:d(e.id,e.description)})},className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(w,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Z(e.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(l,{className:`w-3 h-3`}),t(`actions.use`)]})]})]},e.id))})]})]})]}),(0,z.jsx)(ne,{open:T!==null,onOpenChange:e=>{e||j(null)},children:(0,z.jsxs)(v,{className:`max-w-sm`,children:[(0,z.jsxs)(te,{children:[(0,z.jsxs)(ee,{className:`flex items-center gap-2`,children:[(0,z.jsx)(m,{className:`w-4 h-4 text-destructive`}),h.find(e=>e.id===T)?.name??t(`actions.delete`)]}),(0,z.jsx)(_,{children:t(`confirmDelete`)})]}),(0,z.jsxs)(g,{children:[(0,z.jsx)(b,{variant:`ghost`,onClick:()=>j(null),children:t(`common:actions.cancel`)}),(0,z.jsx)(b,{variant:`destructive`,onClick:()=>void Ne(),children:t(`common:actions.delete`)})]})]})}),(0,z.jsx)(M,{template:L,mode:B,onClose:()=>R(null),onUse:e=>{R(null),B===`fork`?Ee(e):Z(e)}}),(0,z.jsx)(de,{loop:H?{id:H.id,name:H.name}:null,projects:xe.map(e=>({id:e.id,name:e.name,providers:o(e),repositories:e.repositories})),onClose:()=>W(null),onExecute:De})]})}function U({title:e,children:t}){return(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:e}),(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t})]})}function fe({loop:e,selected:t,onToggleSelect:n,onEdit:r,onPublish:a,onUnpublish:o,onDuplicate:s,onExport:c,onDelete:f,onRun:p}){let{t:g}=i(`loops`),_=e.graph?.nodes?.length??0;return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`loop-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,"aria-label":g(`actions.select`,{name:e.name}),className:`accent-accent-primary flex-shrink-0`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.name})]}),(0,z.jsx)(V,{status:e.status})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`card.nodes`,{count:_})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[p&&(0,z.jsx)(W,{icon:d,label:g(`actions.run`),onClick:p}),(0,z.jsx)(W,{icon:u,label:g(`actions.edit`),onClick:r}),a&&(0,z.jsx)(W,{icon:h,label:g(`actions.publish`),onClick:a}),o&&(0,z.jsx)(W,{icon:l,label:g(`actions.unpublish`),onClick:o}),(0,z.jsx)(W,{icon:k,label:g(`actions.duplicate`),onClick:s}),(0,z.jsx)(W,{icon:N,label:g(`actions.export`),onClick:c}),(0,z.jsx)(W,{icon:m,label:g(`actions.delete`),onClick:f,danger:!0})]})]})}function W({icon:e,label:t,onClick:n,danger:r}){return(0,z.jsx)(`button`,{type:`button`,onClick:n,title:t,"aria-label":t,className:y(`inline-flex items-center justify-center w-7 h-7 rounded-md transition-colors`,r?`text-muted-foreground hover:text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,z.jsx)(e,{className:`w-3.5 h-3.5`})})}export{H as default};