angine 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +57 -20
- package/dist/src/colors.d.ts +4 -0
- package/dist/src/colors.js +9 -0
- package/dist/src/colors.js.map +1 -0
- package/dist/src/dashboard.js +3 -1
- package/dist/src/dashboard.js.map +1 -1
- package/dist/src/graph.d.ts +47 -0
- package/dist/src/graph.js +100 -0
- package/dist/src/graph.js.map +1 -0
- package/dist/src/hierarchy.js +1 -1
- package/dist/src/hierarchy.js.map +1 -1
- package/dist/src/model.js +18 -1
- package/dist/src/model.js.map +1 -1
- package/dist/src/reporting.d.ts +1 -1
- package/dist/src/reporting.js +1 -1
- package/dist/src/repositories.d.ts +4 -0
- package/dist/src/repositories.js +60 -0
- package/dist/src/repositories.js.map +1 -0
- package/dist/src/store.d.ts +5 -0
- package/dist/src/store.js +42 -7
- package/dist/src/store.js.map +1 -1
- package/dist/src/types.d.ts +7 -0
- package/docs/releases/v0.1.1.md +21 -0
- package/docs/releasing.md +5 -5
- package/package.json +3 -2
- package/ui/dist/assets/index-DG1yX0hc.js +7 -0
- package/ui/dist/assets/index-Dspuc4WV.css +1 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/index-CKFeQsCF.js +0 -1
- package/ui/dist/assets/index-ClFH-l-k.css +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();var un,te,Ts,ct,ni,Ds,Os,No,jn,Yt,Rs,gr,Xo,Yo,js,Wn={},Un=[],tu=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,dn=Array.isArray;function Ye(e,t){for(var n in t)e[n]=t[n];return e}function mr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function qe(e,t,n){var o,r,i,s={};for(i in t)i=="key"?o=t[i]:i=="ref"?r=t[i]:s[i]=t[i];if(arguments.length>2&&(s.children=arguments.length>3?un.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)s[i]===void 0&&(s[i]=e.defaultProps[i]);return Zt(e,s,o,r,null)}function Zt(e,t,n,o,r){var i={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++Ts,__i:-1,__u:0};return r==null&&te.vnode!=null&&te.vnode(i),i}function Hs(){return{current:null}}function se(e){return e.children}function ze(e,t){this.props=e,this.context=t}function yt(e,t){if(t==null)return e.__?yt(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?yt(e):null}function nu(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,o=[],r=[],i=Ye({},t);i.__v=t.__v+1,te.vnode&&te.vnode(i),yr(e.__P,i,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,o,n??yt(t),!!(32&t.__u),r),i.__v=t.__v,i.__.__k[i.__i]=i,Fs(o,i,r),t.__e=t.__=null,i.__e!=n&&Ls(i)}}function Ls(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Ls(e)}function Zo(e){(!e.__d&&(e.__d=!0)&&ct.push(e)&&!Xn.__r++||ni!=te.debounceRendering)&&((ni=te.debounceRendering)||Ds)(Xn)}function Xn(){try{for(var e,t=1;ct.length;)ct.length>t&&ct.sort(Os),e=ct.shift(),t=ct.length,nu(e)}finally{ct.length=Xn.__r=0}}function zs(e,t,n,o,r,i,s,c,d,l,f){var h,u,p,y,_,v,m=o&&o.__k||Un,S=t.length;for(d=ou(n,t,m,d,S),h=0;h<S;h++)(p=n.__k[h])!=null&&(u=p.__i!=-1&&m[p.__i]||Wn,p.__i=h,v=yr(e,p,u,r,i,s,c,d,l,f),y=p.__e,p.ref&&u.ref!=p.ref&&(u.ref&&_r(u.ref,null,p),f.push(p.ref,p.__c||y,p)),_==null&&y!=null&&(_=y),4&p.__u?(d=Bs(p,d,e),u.__e&&(u.__e=null)):typeof p.type=="function"&&v!==void 0?d=v:y&&(d=y.nextSibling),p.__u&=-7);return n.__e=_,d}function ou(e,t,n,o,r){var i,s,c,d,l,f=n.length,h=f,u=0;for(e.__k=new Array(r),i=0;i<r;i++)(s=t[i])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=e.__k[i]=Zt(null,s,null,null,null):dn(s)?s=e.__k[i]=Zt(se,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[i]=Zt(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[i]=s,d=i+u,s.__=e,s.__b=e.__b+1,c=null,(l=s.__i=ru(s,n,d,h))!=-1&&(h--,(c=n[l])&&(c.__u|=2)),c==null||c.__v==null?(l==-1&&(r>f?u--:r<f&&u++),typeof s.type!="function"&&(s.__u|=4)):l!=d&&(l==d-1?u--:l==d+1?u++:(l>d?u--:u++,s.__u|=4))):e.__k[i]=null;if(h)for(i=0;i<f;i++)(c=n[i])!=null&&(2&c.__u)==0&&(c.__e==o&&(o=yt(c)),Us(c,c));return o}function Bs(e,t,n){var o,r;if(typeof e.type=="function"){for(o=e.__k,r=0;o&&r<o.length;r++)o[r]&&(o[r].__=e,t=Bs(o[r],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=yt(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function tt(e,t){return t=t||[],e==null||typeof e=="boolean"||(dn(e)?e.some(function(n){tt(n,t)}):t.push(e)),t}function ru(e,t,n,o){var r,i,s,c=e.key,d=e.type,l=t[n],f=l!=null&&(2&l.__u)==0;if(l===null&&c==null||f&&c==l.key&&d==l.type)return n;if(o>(f?1:0)){for(r=n-1,i=n+1;r>=0||i<t.length;)if((l=t[s=r>=0?r--:i++])!=null&&(2&l.__u)==0&&c==l.key&&d==l.type)return s}return-1}function oi(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||tu.test(t)?n:n+"px"}function kn(e,t,n,o,r){var i,s;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||oi(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||oi(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")i=t!=(t=t.replace(Rs,"$1")),s=t.toLowerCase(),t=s in e||t=="onFocusOut"||t=="onFocusIn"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?o?n[Yt]=o[Yt]:(n[Yt]=gr,e.addEventListener(t,i?Yo:Xo,i)):e.removeEventListener(t,i?Yo:Xo,i);else{if(r=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function ri(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[jn]==null)t[jn]=gr++;else if(t[jn]<n[Yt])return;return n(te.event?te.event(t):t)}}}function yr(e,t,n,o,r,i,s,c,d,l){var f,h,u,p,y,_,v,m,S,g,w,C,k,E,T,D,L=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),i=[c=t.__e=n.__e]),(f=te.__b)&&f(t);e:if(typeof L=="function"){h=s.length;try{if(S=t.props,g=L.prototype&&L.prototype.render,w=(f=L.contextType)&&o[f.__c],C=f?w?w.props.value:f.__:o,n.__c?m=(u=t.__c=n.__c).__=u.__E:(g?t.__c=u=new L(S,C):(t.__c=u=new ze(S,C),u.constructor=L,u.render=su),w&&w.sub(u),u.state||(u.state={}),u.__n=o,p=u.__d=!0,u.__h=[],u._sb=[]),g&&u.__s==null&&(u.__s=u.state),g&&L.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Ye({},u.__s)),Ye(u.__s,L.getDerivedStateFromProps(S,u.__s))),y=u.props,_=u.state,u.__v=t,p)g&&L.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),g&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(g&&L.getDerivedStateFromProps==null&&S!==y&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(S,C),t.__v==n.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(S,u.__s,C)===!1){t.__v!=n.__v&&(u.props=S,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(O){O&&(O.__=t)}),Un.push.apply(u.__h,u._sb),u._sb=[],u.__h.length&&s.push(u),c=yt(n);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(S,u.__s,C),g&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(y,_,v)})}if(u.context=C,u.props=S,u.__P=e,u.__e=!1,k=te.__r,E=0,g)u.state=u.__s,u.__d=!1,k&&k(t),f=u.render(u.props,u.state,u.context),Un.push.apply(u.__h,u._sb),u._sb=[];else do u.__d=!1,k&&k(t),f=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++E<25);u.state=u.__s,u.getChildContext!=null&&(o=Ye(Ye({},o),u.getChildContext())),g&&!p&&u.getSnapshotBeforeUpdate!=null&&(v=u.getSnapshotBeforeUpdate(y,_)),T=f!=null&&f.type===se&&f.key==null?Ws(f.props.children):f,c=zs(e,dn(T)?T:[T],t,n,o,r,i,s,c,d,l),u.base=t.__e,t.__u&=-161,u.__h.length&&s.push(u),m&&(u.__E=u.__=null)}catch(O){if(s.length=h,t.__v=null,d||i!=null){if(O.then){for(t.__u|=d?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;i!=null&&(i[i.indexOf(c)]=null),t.__e=c}else if(i!=null)for(D=i.length;D--;)mr(i[D])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),O.then||Vs(t),te.__e(O,t,n)}}else i==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=iu(n.__e,t,n,o,r,i,s,d,l);return(f=te.diffed)&&f(t),128&t.__u?void 0:c}function Vs(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Vs))}function Fs(e,t,n){for(var o=0;o<n.length;o++)_r(n[o],n[++o],n[++o]);te.__c&&te.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(i){i.call(r)})}catch(i){te.__e(i,r.__v)}})}function Ws(e){return typeof e!="object"||e==null||e.__b>0?e:dn(e)?e.map(Ws):e.constructor!==void 0?null:Ye({},e)}function iu(e,t,n,o,r,i,s,c,d){var l,f,h,u,p,y,_,v=n.props||Wn,m=t.props,S=t.type;if(S=="svg"?r="http://www.w3.org/2000/svg":S=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(l=0;l<i.length;l++)if((p=i[l])&&"setAttribute"in p==!!S&&(S?p.localName==S:p.nodeType==3)){e=p,i[l]=null;break}}if(e==null){if(S==null)return document.createTextNode(m);e=document.createElementNS(r,S,m.is&&m),c&&(te.__m&&te.__m(t,i),c=!1),i=null}if(S==null)v===m||c&&e.data==m||(e.data=m);else{if(i=S=="textarea"&&m.defaultValue!=null?null:i&&un.call(e.childNodes),!c&&i!=null)for(v={},l=0;l<e.attributes.length;l++)v[(p=e.attributes[l]).name]=p.value;for(l in v)p=v[l],l=="dangerouslySetInnerHTML"?h=p:l=="children"||l in m||l=="value"&&"defaultValue"in m||l=="checked"&&"defaultChecked"in m||kn(e,l,null,p,r);for(l in m)p=m[l],l=="children"?u=p:l=="dangerouslySetInnerHTML"?f=p:l=="value"?y=p:l=="checked"?_=p:c&&typeof p!="function"||v[l]===p||kn(e,l,p,v[l],r);if(f)c||h&&(f.__html==h.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(h&&(e.innerHTML=""),zs(t.type=="template"?e.content:e,dn(u)?u:[u],t,n,o,S=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,s,i?i[0]:n.__k&&yt(n,0),c,d),i!=null)for(l=i.length;l--;)mr(i[l]);c&&S!="textarea"||(l="value",S=="progress"&&y==null?e.removeAttribute("value"):y!=null&&(y!==e[l]||S=="progress"&&!y||S=="option"&&y!=v[l])&&kn(e,l,y,v[l],r),l="checked",_!=null&&_!=e[l]&&kn(e,l,_,v[l],r))}return e}function _r(e,t,n){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(r){te.__e(r,n)}}function Us(e,t,n){var o,r;if(te.unmount&&te.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||_r(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){te.__e(i,t)}o.base=o.__P=o.__n=null}if(o=e.__k)for(r=0;r<o.length;r++)o[r]&&Us(o[r],t,n||typeof e.type!="function");n||mr(e.__e),e.__c=e.__=e.__e=void 0}function su(e,t,n){return this.constructor(e,n)}function At(e,t,n){var o,r,i,s;t==document&&(t=document.documentElement),te.__&&te.__(e,t),r=(o=typeof n=="function")?null:n&&n.__k||t.__k,i=[],s=[],yr(t,e=(!o&&n||t).__k=qe(se,null,[e]),r||Wn,Wn,t.namespaceURI,!o&&n?[n]:r?null:t.firstChild?un.call(t.childNodes):null,i,!o&&n?n:r?r.__e:t.firstChild,o,s),Fs(i,e,s),e.props.children=null}function Xs(e,t){At(e,t,Xs)}function au(e,t,n){var o,r,i,s,c=Ye({},e.props);for(i in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)i=="key"?o=t[i]:i=="ref"?r=t[i]:c[i]=t[i]===void 0&&s!=null?s[i]:t[i];return arguments.length>2&&(c.children=arguments.length>3?un.call(arguments,2):n),Zt(e.type,c,o||e.key,r||e.ref,null)}function Lt(e){function t(n){var o,r;return this.getChildContext||(o=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(i){this.props.value!=i.value&&o.forEach(function(s){s.__e=!0,Zo(s)})},this.sub=function(i){o.add(i);var s=i.componentWillUnmount;i.componentWillUnmount=function(){o&&o.delete(i),s&&s.call(i)}}),n.children}return t.__c="__cC"+js++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,o){return n.children(o)}).contextType=t,t}un=Un.slice,te={__e:function(e,t,n,o){for(var r,i,s;t=t.__;)if((r=t.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(e)),s=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e,o||{}),s=r.__d),s)return r.__E=r}catch(c){e=c}throw e}},Ts=0,ze.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ye({},this.state),typeof e=="function"&&(e=e(Ye({},n),this.props)),e&&Ye(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Zo(this))},ze.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Zo(this))},ze.prototype.render=se,ct=[],Ds=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Os=function(e,t){return e.__v.__b-t.__v.__b},Xn.__r=0,No=Math.random().toString(8),jn="__d"+No,Yt="__a"+No,Rs=/(PointerCapture)$|Capture$/i,gr=0,Xo=ri(!1),Yo=ri(!0),js=0;var cu=0;function a(e,t,n,o,r,i){t||(t={});var s,c,d=t;if("ref"in d)for(c in d={},t)c=="ref"?s=t[c]:d[c]=t[c];var l={type:e,props:d,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--cu,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(s=e.defaultProps))for(c in s)d[c]===void 0&&(d[c]=s[c]);return te.vnode&&te.vnode(l),l}var nt,ue,Io,ii,$t=0,Ys=[],fe=te,si=fe.__b,ai=fe.__r,ci=fe.diffed,li=fe.__c,ui=fe.unmount,di=fe.__;function St(e,t){fe.__h&&fe.__h(ue,e,$t||t),$t=0;var n=ue.__H||(ue.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function J(e){return $t=1,io(Zs,e)}function io(e,t,n){var o=St(nt++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):Zs(void 0,t),function(c){var d=o.__N?o.__N[0]:o.__[0],l=o.t(d,c);d!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=ue,!ue.__f)){var r=function(c,d,l){if(!o.__c.__H)return!0;var f=!1,h=o.__c.props!==c;if(o.__c.__H.__.some(function(p){if(p.__N){f=!0;var y=p.__[0];p.__=p.__N,p.__N=void 0,y!==p.__[0]&&(h=!0)}}),i){var u=i.call(this,c,d,l);return f?u||h:u}return!f||h};ue.__f=!0;var i=ue.shouldComponentUpdate,s=ue.componentWillUpdate;ue.componentWillUpdate=function(c,d,l){if(this.__e){var f=i;i=void 0,r(c,d,l),i=f}s&&s.call(this,c,d,l)},ue.shouldComponentUpdate=r}return o.__N||o.__}function oe(e,t){var n=St(nt++,3);!fe.__s&&br(n.__H,t)&&(n.__=e,n.u=t,ue.__H.__h.push(n))}function rt(e,t){var n=St(nt++,4);!fe.__s&&br(n.__H,t)&&(n.__=e,n.u=t,ue.__h.push(n))}function ne(e){return $t=5,ye(function(){return{current:e}},[])}function vr(e,t,n){$t=6,rt(function(){if(typeof e=="function"){var o=e(t());return function(){e(null),o&&typeof o=="function"&&o()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function ye(e,t){var n=St(nt++,7);return br(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Me(e,t){return $t=8,ye(function(){return e},t)}function it(e){var t=ue.context[e.__c],n=St(nt++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(ue)),t.props.value):e.__}function wr(e,t){fe.useDebugValue&&fe.useDebugValue(t?t(e):e)}function lu(e){var t=St(nt++,10),n=J();return t.__=e,ue.componentDidCatch||(ue.componentDidCatch=function(o,r){t.__&&t.__(o,r),n[1](o)}),[n[0],function(){n[1](void 0)}]}function xr(){var e=St(nt++,11);if(!e.__){for(var t=ue.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function uu(){for(var e;e=Ys.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Hn),t.__h.some(qo),t.__h=[]}catch(n){t.__h=[],fe.__e(n,e.__v)}}}fe.__b=function(e){ue=null,si&&si(e)},fe.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),di&&di(e,t)},fe.__r=function(e){ai&&ai(e),nt=0;var t=(ue=e.__c).__H;t&&(Io===ue?(t.__h=[],ue.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Hn),t.__h.some(qo),t.__h=[],nt=0)),Io=ue},fe.diffed=function(e){ci&&ci(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ys.push(t)!==1&&ii===fe.requestAnimationFrame||((ii=fe.requestAnimationFrame)||du)(uu)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Io=ue=null},fe.__c=function(e,t){t.some(function(n){try{n.__h.some(Hn),n.__h=n.__h.filter(function(o){return!o.__||qo(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],fe.__e(o,n.__v)}}),li&&li(e,t)},fe.unmount=function(e){ui&&ui(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(o){try{Hn(o)}catch(r){t=r}}),n.__H=void 0,t&&fe.__e(t,n.__v))};var fi=typeof requestAnimationFrame=="function";function du(e){var t,n=function(){clearTimeout(o),fi&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);fi&&(t=requestAnimationFrame(n))}function Hn(e){var t=ue,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ue=t}function qo(e){var t=ue;e.__c=e.__(),ue=t}function br(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function Zs(e,t){return typeof t=="function"?t(e):t}function qs(e,t){for(var n in t)e[n]=t[n];return e}function Go(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function Sr(e,t){var n=t(),o=J({t:{__:n,u:t}}),r=o[0].t,i=o[1];return rt(function(){r.__=n,r.u=t,Mo(r)&&i({t:r})},[e,n,t]),oe(function(){return Mo(r)&&i({t:r}),e(function(){Mo(r)&&i({t:r})})},[e]),n}function Mo(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function kr(e){e()}function Er(e){return e}function Cr(){return[!1,kr]}var Nr=rt;function Yn(e,t){this.props=e,this.context=t}function pe(e,t){function n(r){var i=this.props.ref;return i!=r.ref&&i&&(typeof i=="function"?i(null):i.current=null),t?!t(this.props,r)||i!=r.ref:Go(this.props,r)}function o(r){return this.shouldComponentUpdate=n,qe(e,r)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.__f=o.prototype.isReactComponent=!0,o.type=e,o}(Yn.prototype=new ze).isPureReactComponent=!0,Yn.prototype.shouldComponentUpdate=function(e,t){return Go(this.props,e)||Go(this.state,t)};var hi=te.__b;te.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),hi&&hi(e)};var fu=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function so(e){function t(n){var o=qs({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=fu,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var pi=function(e,t){return e==null?null:tt(tt(e).map(t))},Gs={map:pi,forEach:pi,count:function(e){return e?tt(e).length:0},only:function(e){var t=tt(e);if(t.length!==1)throw"Children.only";return t[0]},toArray:tt},hu=te.__e;te.__e=function(e,t,n,o){if(e.then){for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k||[]),r.__c(e,t)}hu(e,t,n,o)};var gi=te.unmount;function Ks(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=qs({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return Ks(o,t,n)})),e}function Qs(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return Qs(o,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function qt(){this.__u=0,this.o=null,this.__b=null}function Js(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function ea(e){var t,n,o,r=null;function i(s){if(t||(t=e()).then(function(c){c&&(r=c.default||c),o=!0},function(c){n=c,o=!0}),n)throw n;if(!o)throw t;return r?qe(r,s):null}return i.displayName="Lazy",i.__f=!0,i}function Ct(){this.i=null,this.l=null}te.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),gi&&gi(e)},(qt.prototype=new ze).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var r=Js(o.__v),i=!1,s=function(){i||o.__z||(i=!0,n.__R=null,r?r(d):d())};n.__R=s;var c=n.__P;n.__P=null;var d=function(){if(!--o.__u){if(o.state.__a){var l=o.state.__a;o.__v.__k[0]=Qs(l,l.__c.__P,l.__c.__O)}var f;for(o.setState({__a:o.__b=null});f=o.o.pop();)f.__P=c,f.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(s,s)},qt.prototype.componentWillUnmount=function(){this.o=[]},qt.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=Ks(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&qe(se,null,e.fallback);return r&&(r.__u&=-33),[qe(se,null,t.__a?null:e.children),r]};var mi=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function pu(e){return this.getChildContext=function(){return e.context},e.children}function gu(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){At(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var o=t.__v;o!==null&&!o.__m&&o.__!==null;)o=o.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:o.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(r,i){this.childNodes.push(r),t.h.insertBefore(r,i)},removeChild:function(r){this.childNodes.splice(this.childNodes.indexOf(r)>>>1,1),t.h.removeChild(r)}}}At(qe(pu,{context:t.context},e.__v),t.v)}function ta(e,t){var n=qe(gu,{__v:e,h:t});return n.containerInfo=t,n}(Ct.prototype=new ze).__a=function(e){var t=this,n=Js(t.__v),o=t.l.get(e);return o[0]++,function(r){var i=function(){t.props.revealOrder?(o.push(r),mi(t,e,o)):r()};n?n(i):i()}},Ct.prototype.render=function(e){this.i=null,this.l=new Map;var t=tt(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},Ct.prototype.componentDidUpdate=Ct.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){mi(e,n,t)})};var na=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,mu=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,yu=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,_u=/[A-Z0-9]/g,vu=typeof document<"u",wu=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};function oa(e,t,n){return t.__k==null&&(t.textContent=""),At(e,t),typeof n=="function"&&n(),e?e.__c:null}function ra(e,t,n){return Xs(e,t),typeof n=="function"&&n(),e?e.__c:null}ze.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(ze.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var yi=te.event;te.event=function(e){return yi&&(e=yi(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var Ir,xu={configurable:!0,get:function(){return this.class}},_i=te.vnode;te.vnode=function(e){typeof e.type=="string"&&(function(t){var n=t.props,o=t.type,r={},i=o.indexOf("-")==-1;for(var s in n){var c=n[s];if(!(s==="value"&&"defaultValue"in n&&c==null||vu&&s==="children"&&o==="noscript"||s==="class"||s==="className")){var d=s.toLowerCase();s==="defaultValue"&&"value"in n&&n.value==null?s="value":s==="download"&&c===!0?c="":d==="translate"&&c==="no"?c=!1:d[0]==="o"&&d[1]==="n"?d==="ondoubleclick"?s="ondblclick":d!=="onchange"||o!=="input"&&o!=="textarea"||wu(n.type)?d==="onfocus"?s="onfocusin":d==="onblur"?s="onfocusout":yu.test(s)&&(s=d):d=s="oninput":i&&mu.test(s)?s=s.replace(_u,"-$&").toLowerCase():c===null&&(c=void 0),d==="oninput"&&r[s=d]&&(s="oninputCapture"),r[s]=c}}o=="select"&&(r.multiple&&Array.isArray(r.value)&&(r.value=tt(n.children).forEach(function(l){l.props.selected=r.value.indexOf(l.props.value)!=-1})),r.defaultValue!=null&&(r.value=tt(n.children).forEach(function(l){l.props.selected=r.multiple?r.defaultValue.indexOf(l.props.value)!=-1:r.defaultValue==l.props.value}))),n.class&&!n.className?(r.class=n.class,Object.defineProperty(r,"className",xu)):n.className&&(r.class=r.className=n.className),t.props=r})(e),e.$$typeof=na,_i&&_i(e)};var vi=te.__r;te.__r=function(e){vi&&vi(e),Ir=e.__c};var wi=te.diffed;te.diffed=function(e){wi&&wi(e);var t=e.props,n=e.__e;n!=null&&e.type==="textarea"&&"value"in t&&t.value!==n.value&&(n.value=t.value==null?"":t.value),Ir=null};var ia={ReactCurrentDispatcher:{current:{readContext:function(e){return Ir.__n[e.__c].props.value},useCallback:Me,useContext:it,useDebugValue:wr,useDeferredValue:Er,useEffect:oe,useId:xr,useImperativeHandle:vr,useInsertionEffect:Nr,useLayoutEffect:rt,useMemo:ye,useReducer:io,useRef:ne,useState:J,useSyncExternalStore:Sr,useTransition:Cr}}},bu="18.3.1";function sa(e){return qe.bind(null,e)}function fn(e){return!!e&&e.$$typeof===na}function aa(e){return fn(e)&&e.type===se}function ca(e){return!!e&&typeof e.displayName=="string"&&e.displayName.indexOf("Memo(")==0}function la(e){return fn(e)?au.apply(null,arguments):e}function ua(e){return!!e.__k&&(At(null,e),!0)}function da(e){return e&&(e.base||e.nodeType===1&&e)||null}var fa=function(e,t){return e(t)},ha=function(e,t){var n,o=te.debounceRendering;te.debounceRendering=function(i){n=i};try{var r=e(t);return n&&n(),r}finally{te.debounceRendering=o}},pa=fn,ga={useState:J,useId:xr,useReducer:io,useEffect:oe,useLayoutEffect:rt,useInsertionEffect:Nr,useTransition:Cr,useDeferredValue:Er,useSyncExternalStore:Sr,startTransition:kr,useRef:ne,useImperativeHandle:vr,useMemo:ye,useCallback:Me,useContext:it,useDebugValue:wr,version:"18.3.1",Children:Gs,render:oa,hydrate:ra,unmountComponentAtNode:ua,createPortal:ta,createElement:qe,createContext:Lt,createFactory:sa,cloneElement:la,createRef:Hs,Fragment:se,isValidElement:fn,isElement:pa,isFragment:aa,isMemo:ca,findDOMNode:da,Component:ze,PureComponent:Yn,memo:pe,forwardRef:so,flushSync:ha,unstable_batchedUpdates:fa,StrictMode:se,Suspense:qt,SuspenseList:Ct,lazy:ea,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:ia};const Su=Object.freeze(Object.defineProperty({__proto__:null,Children:Gs,Component:ze,Fragment:se,PureComponent:Yn,StrictMode:se,Suspense:qt,SuspenseList:Ct,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:ia,cloneElement:la,createContext:Lt,createElement:qe,createFactory:sa,createPortal:ta,createRef:Hs,default:ga,findDOMNode:da,flushSync:ha,forwardRef:so,hydrate:ra,isElement:pa,isFragment:aa,isMemo:ca,isValidElement:fn,lazy:ea,memo:pe,render:oa,startTransition:kr,unmountComponentAtNode:ua,unstable_batchedUpdates:fa,useCallback:Me,useContext:it,useDebugValue:wr,useDeferredValue:Er,useEffect:oe,useErrorBoundary:lu,useId:xr,useImperativeHandle:vr,useInsertionEffect:Nr,useLayoutEffect:rt,useMemo:ye,useReducer:io,useRef:ne,useState:J,useSyncExternalStore:Sr,useTransition:Cr,version:bu},Symbol.toStringTag,{value:"Module"}));function ge(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ge(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var ku={value:()=>{}};function ao(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Ln(n)}function Ln(e){this._=e}function Eu(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Ln.prototype=ao.prototype={constructor:Ln,on:function(e,t){var n=this._,o=Eu(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Cu(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=xi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=xi(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ln(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function Cu(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function xi(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=ku,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Ko="http://www.w3.org/1999/xhtml";const bi={svg:"http://www.w3.org/2000/svg",xhtml:Ko,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function co(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),bi.hasOwnProperty(t)?{space:bi[t],local:e}:e}function Nu(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Ko&&t.documentElement.namespaceURI===Ko?t.createElement(e):t.createElementNS(n,e)}}function Iu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ma(e){var t=co(e);return(t.local?Iu:Nu)(t)}function Mu(){}function Mr(e){return e==null?Mu:function(){return this.querySelector(e)}}function Au(e){typeof e!="function"&&(e=Mr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,c=o[r]=new Array(s),d,l,f=0;f<s;++f)(d=i[f])&&(l=e.call(d,d.__data__,f,i))&&("__data__"in d&&(l.__data__=d.__data__),c[f]=l);return new Ae(o,this._parents)}function $u(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Pu(){return[]}function ya(e){return e==null?Pu:function(){return this.querySelectorAll(e)}}function Tu(e){return function(){return $u(e.apply(this,arguments))}}function Du(e){typeof e=="function"?e=Tu(e):e=ya(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],c=s.length,d,l=0;l<c;++l)(d=s[l])&&(o.push(e.call(d,d.__data__,l,s)),r.push(d));return new Ae(o,r)}function _a(e){return function(){return this.matches(e)}}function va(e){return function(t){return t.matches(e)}}var Ou=Array.prototype.find;function Ru(e){return function(){return Ou.call(this.children,e)}}function ju(){return this.firstElementChild}function Hu(e){return this.select(e==null?ju:Ru(typeof e=="function"?e:va(e)))}var Lu=Array.prototype.filter;function zu(){return Array.from(this.children)}function Bu(e){return function(){return Lu.call(this.children,e)}}function Vu(e){return this.selectAll(e==null?zu:Bu(typeof e=="function"?e:va(e)))}function Fu(e){typeof e!="function"&&(e=_a(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,c=o[r]=[],d,l=0;l<s;++l)(d=i[l])&&e.call(d,d.__data__,l,i)&&c.push(d);return new Ae(o,this._parents)}function wa(e){return new Array(e.length)}function Wu(){return new Ae(this._enter||this._groups.map(wa),this._parents)}function Zn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Zn.prototype={constructor:Zn,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 Uu(e){return function(){return e}}function Xu(e,t,n,o,r,i){for(var s=0,c,d=t.length,l=i.length;s<l;++s)(c=t[s])?(c.__data__=i[s],o[s]=c):n[s]=new Zn(e,i[s]);for(;s<d;++s)(c=t[s])&&(r[s]=c)}function Yu(e,t,n,o,r,i,s){var c,d,l=new Map,f=t.length,h=i.length,u=new Array(f),p;for(c=0;c<f;++c)(d=t[c])&&(u[c]=p=s.call(d,d.__data__,c,t)+"",l.has(p)?r[c]=d:l.set(p,d));for(c=0;c<h;++c)p=s.call(e,i[c],c,i)+"",(d=l.get(p))?(o[c]=d,d.__data__=i[c],l.delete(p)):n[c]=new Zn(e,i[c]);for(c=0;c<f;++c)(d=t[c])&&l.get(u[c])===d&&(r[c]=d)}function Zu(e){return e.__data__}function qu(e,t){if(!arguments.length)return Array.from(this,Zu);var n=t?Yu:Xu,o=this._parents,r=this._groups;typeof e!="function"&&(e=Uu(e));for(var i=r.length,s=new Array(i),c=new Array(i),d=new Array(i),l=0;l<i;++l){var f=o[l],h=r[l],u=h.length,p=Gu(e.call(f,f&&f.__data__,l,o)),y=p.length,_=c[l]=new Array(y),v=s[l]=new Array(y),m=d[l]=new Array(u);n(f,h,_,v,m,p,t);for(var S=0,g=0,w,C;S<y;++S)if(w=_[S]){for(S>=g&&(g=S+1);!(C=v[g])&&++g<y;);w._next=C||null}}return s=new Ae(s,o),s._enter=c,s._exit=d,s}function Gu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ku(){return new Ae(this._exit||this._groups.map(wa),this._parents)}function Qu(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Ju(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),c=new Array(r),d=0;d<s;++d)for(var l=n[d],f=o[d],h=l.length,u=c[d]=new Array(h),p,y=0;y<h;++y)(p=l[y]||f[y])&&(u[y]=p);for(;d<r;++d)c[d]=n[d];return new Ae(c,this._parents)}function ed(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function td(e){e||(e=nd);function t(h,u){return h&&u?e(h.__data__,u.__data__):!h-!u}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],c=s.length,d=r[i]=new Array(c),l,f=0;f<c;++f)(l=s[f])&&(d[f]=l);d.sort(t)}return new Ae(r,this._parents).order()}function nd(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function od(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function rd(){return Array.from(this)}function id(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function sd(){let e=0;for(const t of this)++e;return e}function ad(){return!this.node()}function cd(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,c;i<s;++i)(c=r[i])&&e.call(c,c.__data__,i,r);return this}function ld(e){return function(){this.removeAttribute(e)}}function ud(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dd(e,t){return function(){this.setAttribute(e,t)}}function fd(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hd(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function pd(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 gd(e,t){var n=co(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?ud:ld:typeof t=="function"?n.local?pd:hd:n.local?fd:dd)(n,t))}function xa(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function md(e){return function(){this.style.removeProperty(e)}}function yd(e,t,n){return function(){this.style.setProperty(e,t,n)}}function _d(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function vd(e,t,n){return arguments.length>1?this.each((t==null?md:typeof t=="function"?_d:yd)(e,t,n??"")):Pt(this.node(),e)}function Pt(e,t){return e.style.getPropertyValue(t)||xa(e).getComputedStyle(e,null).getPropertyValue(t)}function wd(e){return function(){delete this[e]}}function xd(e,t){return function(){this[e]=t}}function bd(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Sd(e,t){return arguments.length>1?this.each((t==null?wd:typeof t=="function"?bd:xd)(e,t)):this.node()[e]}function ba(e){return e.trim().split(/^|\s+/)}function Ar(e){return e.classList||new Sa(e)}function Sa(e){this._node=e,this._names=ba(e.getAttribute("class")||"")}Sa.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ka(e,t){for(var n=Ar(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Ea(e,t){for(var n=Ar(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function kd(e){return function(){ka(this,e)}}function Ed(e){return function(){Ea(this,e)}}function Cd(e,t){return function(){(t.apply(this,arguments)?ka:Ea)(this,e)}}function Nd(e,t){var n=ba(e+"");if(arguments.length<2){for(var o=Ar(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Cd:t?kd:Ed)(n,t))}function Id(){this.textContent=""}function Md(e){return function(){this.textContent=e}}function Ad(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function $d(e){return arguments.length?this.each(e==null?Id:(typeof e=="function"?Ad:Md)(e)):this.node().textContent}function Pd(){this.innerHTML=""}function Td(e){return function(){this.innerHTML=e}}function Dd(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Od(e){return arguments.length?this.each(e==null?Pd:(typeof e=="function"?Dd:Td)(e)):this.node().innerHTML}function Rd(){this.nextSibling&&this.parentNode.appendChild(this)}function jd(){return this.each(Rd)}function Hd(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ld(){return this.each(Hd)}function zd(e){var t=typeof e=="function"?e:ma(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Bd(){return null}function Vd(e,t){var n=typeof e=="function"?e:ma(e),o=t==null?Bd:typeof t=="function"?t:Mr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Fd(){var e=this.parentNode;e&&e.removeChild(this)}function Wd(){return this.each(Fd)}function Ud(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xd(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yd(e){return this.select(e?Xd:Ud)}function Zd(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qd(e){return function(t){e.call(this,t,this.__data__)}}function Gd(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Kd(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Qd(e,t,n){return function(){var o=this.__on,r,i=qd(t);if(o){for(var s=0,c=o.length;s<c;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Jd(e,t,n){var o=Gd(e+""),r,i=o.length,s;if(arguments.length<2){var c=this.node().__on;if(c){for(var d=0,l=c.length,f;d<l;++d)for(r=0,f=c[d];r<i;++r)if((s=o[r]).type===f.type&&s.name===f.name)return f.value}return}for(c=t?Qd:Kd,r=0;r<i;++r)this.each(c(o[r],t,n));return this}function Ca(e,t,n){var o=xa(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function ef(e,t){return function(){return Ca(this,e,t)}}function tf(e,t){return function(){return Ca(this,e,t.apply(this,arguments))}}function nf(e,t){return this.each((typeof t=="function"?tf:ef)(e,t))}function*of(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var Na=[null];function Ae(e,t){this._groups=e,this._parents=t}function hn(){return new Ae([[document.documentElement]],Na)}function rf(){return this}Ae.prototype=hn.prototype={constructor:Ae,select:Au,selectAll:Du,selectChild:Hu,selectChildren:Vu,filter:Fu,data:qu,enter:Wu,exit:Ku,join:Qu,merge:Ju,selection:rf,order:ed,sort:td,call:od,nodes:rd,node:id,size:sd,empty:ad,each:cd,attr:gd,style:vd,property:Sd,classed:Nd,text:$d,html:Od,raise:jd,lower:Ld,append:zd,insert:Vd,remove:Wd,clone:Yd,datum:Zd,on:Jd,dispatch:nf,[Symbol.iterator]:of};function Ie(e){return typeof e=="string"?new Ae([[document.querySelector(e)]],[document.documentElement]):new Ae([[e]],Na)}function sf(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Re(e,t){if(e=sf(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const af={passive:!1},en={capture:!0,passive:!1};function Ao(e){e.stopImmediatePropagation()}function It(e){e.preventDefault(),e.stopImmediatePropagation()}function Ia(e){var t=e.document.documentElement,n=Ie(e).on("dragstart.drag",It,en);"onselectstart"in t?n.on("selectstart.drag",It,en):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ma(e,t){var n=e.document.documentElement,o=Ie(e).on("dragstart.drag",null);t&&(o.on("click.drag",It,en),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const En=e=>()=>e;function Qo(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:c,dx:d,dy:l,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:f}})}Qo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function cf(e){return!e.ctrlKey&&!e.button}function lf(){return this.parentNode}function uf(e,t){return t??{x:e.x,y:e.y}}function df(){return navigator.maxTouchPoints||"ontouchstart"in this}function Aa(){var e=cf,t=lf,n=uf,o=df,r={},i=ao("start","drag","end"),s=0,c,d,l,f,h=0;function u(w){w.on("mousedown.drag",p).filter(o).on("touchstart.drag",v).on("touchmove.drag",m,af).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,C){if(!(f||!e.call(this,w,C))){var k=g(this,t.call(this,w,C),w,C,"mouse");k&&(Ie(w.view).on("mousemove.drag",y,en).on("mouseup.drag",_,en),Ia(w.view),Ao(w),l=!1,c=w.clientX,d=w.clientY,k("start",w))}}function y(w){if(It(w),!l){var C=w.clientX-c,k=w.clientY-d;l=C*C+k*k>h}r.mouse("drag",w)}function _(w){Ie(w.view).on("mousemove.drag mouseup.drag",null),Ma(w.view,l),It(w),r.mouse("end",w)}function v(w,C){if(e.call(this,w,C)){var k=w.changedTouches,E=t.call(this,w,C),T=k.length,D,L;for(D=0;D<T;++D)(L=g(this,E,w,C,k[D].identifier,k[D]))&&(Ao(w),L("start",w,k[D]))}}function m(w){var C=w.changedTouches,k=C.length,E,T;for(E=0;E<k;++E)(T=r[C[E].identifier])&&(It(w),T("drag",w,C[E]))}function S(w){var C=w.changedTouches,k=C.length,E,T;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),E=0;E<k;++E)(T=r[C[E].identifier])&&(Ao(w),T("end",w,C[E]))}function g(w,C,k,E,T,D){var L=i.copy(),O=Re(D||k,C),B,N,b;if((b=n.call(w,new Qo("beforestart",{sourceEvent:k,target:u,identifier:T,active:s,x:O[0],y:O[1],dx:0,dy:0,dispatch:L}),E))!=null)return B=b.x-O[0]||0,N=b.y-O[1]||0,function I(M,P,A){var $=O,j;switch(M){case"start":r[T]=I,j=s++;break;case"end":delete r[T],--s;case"drag":O=Re(A||P,C),j=s;break}L.call(M,w,new Qo(M,{sourceEvent:P,subject:b,target:u,identifier:T,active:j,x:O[0]+B,y:O[1]+N,dx:O[0]-$[0],dy:O[1]-$[1],dispatch:L}),E)}}return u.filter=function(w){return arguments.length?(e=typeof w=="function"?w:En(!!w),u):e},u.container=function(w){return arguments.length?(t=typeof w=="function"?w:En(w),u):t},u.subject=function(w){return arguments.length?(n=typeof w=="function"?w:En(w),u):n},u.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:En(!!w),u):o},u.on=function(){var w=i.on.apply(i,arguments);return w===i?u:w},u.clickDistance=function(w){return arguments.length?(h=(w=+w)*w,u):Math.sqrt(h)},u}function $r(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function $a(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function pn(){}var tn=.7,qn=1/tn,Mt="\\s*([+-]?\\d+)\\s*",nn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ze="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ff=/^#([0-9a-f]{3,8})$/,hf=new RegExp(`^rgb\\(${Mt},${Mt},${Mt}\\)$`),pf=new RegExp(`^rgb\\(${Ze},${Ze},${Ze}\\)$`),gf=new RegExp(`^rgba\\(${Mt},${Mt},${Mt},${nn}\\)$`),mf=new RegExp(`^rgba\\(${Ze},${Ze},${Ze},${nn}\\)$`),yf=new RegExp(`^hsl\\(${nn},${Ze},${Ze}\\)$`),_f=new RegExp(`^hsla\\(${nn},${Ze},${Ze},${nn}\\)$`),Si={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};$r(pn,_t,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ki,formatHex:ki,formatHex8:vf,formatHsl:wf,formatRgb:Ei,toString:Ei});function ki(){return this.rgb().formatHex()}function vf(){return this.rgb().formatHex8()}function wf(){return Pa(this).formatHsl()}function Ei(){return this.rgb().formatRgb()}function _t(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=ff.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ci(t):n===3?new ke(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Cn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Cn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=hf.exec(e))?new ke(t[1],t[2],t[3],1):(t=pf.exec(e))?new ke(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=gf.exec(e))?Cn(t[1],t[2],t[3],t[4]):(t=mf.exec(e))?Cn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=yf.exec(e))?Mi(t[1],t[2]/100,t[3]/100,1):(t=_f.exec(e))?Mi(t[1],t[2]/100,t[3]/100,t[4]):Si.hasOwnProperty(e)?Ci(Si[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function Ci(e){return new ke(e>>16&255,e>>8&255,e&255,1)}function Cn(e,t,n,o){return o<=0&&(e=t=n=NaN),new ke(e,t,n,o)}function xf(e){return e instanceof pn||(e=_t(e)),e?(e=e.rgb(),new ke(e.r,e.g,e.b,e.opacity)):new ke}function Jo(e,t,n,o){return arguments.length===1?xf(e):new ke(e,t,n,o??1)}function ke(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}$r(ke,Jo,$a(pn,{brighter(e){return e=e==null?qn:Math.pow(qn,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?tn:Math.pow(tn,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(gt(this.r),gt(this.g),gt(this.b),Gn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ni,formatHex:Ni,formatHex8:bf,formatRgb:Ii,toString:Ii}));function Ni(){return`#${pt(this.r)}${pt(this.g)}${pt(this.b)}`}function bf(){return`#${pt(this.r)}${pt(this.g)}${pt(this.b)}${pt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ii(){const e=Gn(this.opacity);return`${e===1?"rgb(":"rgba("}${gt(this.r)}, ${gt(this.g)}, ${gt(this.b)}${e===1?")":`, ${e})`}`}function Gn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function pt(e){return e=gt(e),(e<16?"0":"")+e.toString(16)}function Mi(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new je(e,t,n,o)}function Pa(e){if(e instanceof je)return new je(e.h,e.s,e.l,e.opacity);if(e instanceof pn||(e=_t(e)),!e)return new je;if(e instanceof je)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,c=i-r,d=(i+r)/2;return c?(t===i?s=(n-o)/c+(n<o)*6:n===i?s=(o-t)/c+2:s=(t-n)/c+4,c/=d<.5?i+r:2-i-r,s*=60):c=d>0&&d<1?0:s,new je(s,c,d,e.opacity)}function Sf(e,t,n,o){return arguments.length===1?Pa(e):new je(e,t,n,o??1)}function je(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}$r(je,Sf,$a(pn,{brighter(e){return e=e==null?qn:Math.pow(qn,e),new je(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?tn:Math.pow(tn,e),new je(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new ke($o(e>=240?e-240:e+120,r,o),$o(e,r,o),$o(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new je(Ai(this.h),Nn(this.s),Nn(this.l),Gn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Gn(this.opacity);return`${e===1?"hsl(":"hsla("}${Ai(this.h)}, ${Nn(this.s)*100}%, ${Nn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ai(e){return e=(e||0)%360,e<0?e+360:e}function Nn(e){return Math.max(0,Math.min(1,e||0))}function $o(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Pr=e=>()=>e;function kf(e,t){return function(n){return e+n*t}}function Ef(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Cf(e){return(e=+e)==1?Ta:function(t,n){return n-t?Ef(t,n,e):Pr(isNaN(t)?n:t)}}function Ta(e,t){var n=t-e;return n?kf(e,n):Pr(isNaN(e)?t:e)}const Kn=(function e(t){var n=Cf(t);function o(r,i){var s=n((r=Jo(r)).r,(i=Jo(i)).r),c=n(r.g,i.g),d=n(r.b,i.b),l=Ta(r.opacity,i.opacity);return function(f){return r.r=s(f),r.g=c(f),r.b=d(f),r.opacity=l(f),r+""}}return o.gamma=e,o})(1);function Nf(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function If(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Mf(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=Gt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(c){for(s=0;s<o;++s)i[s]=r[s](c);return i}}function Af(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function Xe(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function $f(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=Gt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var er=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Po=new RegExp(er.source,"g");function Pf(e){return function(){return e}}function Tf(e){return function(t){return e(t)+""}}function Da(e,t){var n=er.lastIndex=Po.lastIndex=0,o,r,i,s=-1,c=[],d=[];for(e=e+"",t=t+"";(o=er.exec(e))&&(r=Po.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),c[s]?c[s]+=i:c[++s]=i),(o=o[0])===(r=r[0])?c[s]?c[s]+=r:c[++s]=r:(c[++s]=null,d.push({i:s,x:Xe(o,r)})),n=Po.lastIndex;return n<t.length&&(i=t.slice(n),c[s]?c[s]+=i:c[++s]=i),c.length<2?d[0]?Tf(d[0].x):Pf(t):(t=d.length,function(l){for(var f=0,h;f<t;++f)c[(h=d[f]).i]=h.x(l);return c.join("")})}function Gt(e,t){var n=typeof t,o;return t==null||n==="boolean"?Pr(t):(n==="number"?Xe:n==="string"?(o=_t(t))?(t=o,Kn):Da:t instanceof _t?Kn:t instanceof Date?Af:If(t)?Nf:Array.isArray(t)?Mf:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?$f:Xe)(e,t)}var $i=180/Math.PI,tr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Oa(e,t,n,o,r,i){var s,c,d;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(d=e*n+t*o)&&(n-=e*d,o-=t*d),(c=Math.sqrt(n*n+o*o))&&(n/=c,o/=c,d/=c),e*o<t*n&&(e=-e,t=-t,d=-d,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*$i,skewX:Math.atan(d)*$i,scaleX:s,scaleY:c}}var In;function Df(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?tr:Oa(t.a,t.b,t.c,t.d,t.e,t.f)}function Of(e){return e==null||(In||(In=document.createElementNS("http://www.w3.org/2000/svg","g")),In.setAttribute("transform",e),!(e=In.transform.baseVal.consolidate()))?tr:(e=e.matrix,Oa(e.a,e.b,e.c,e.d,e.e,e.f))}function Ra(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,f,h,u,p,y){if(l!==h||f!==u){var _=p.push("translate(",null,t,null,n);y.push({i:_-4,x:Xe(l,h)},{i:_-2,x:Xe(f,u)})}else(h||u)&&p.push("translate("+h+t+u+n)}function s(l,f,h,u){l!==f?(l-f>180?f+=360:f-l>180&&(l+=360),u.push({i:h.push(r(h)+"rotate(",null,o)-2,x:Xe(l,f)})):f&&h.push(r(h)+"rotate("+f+o)}function c(l,f,h,u){l!==f?u.push({i:h.push(r(h)+"skewX(",null,o)-2,x:Xe(l,f)}):f&&h.push(r(h)+"skewX("+f+o)}function d(l,f,h,u,p,y){if(l!==h||f!==u){var _=p.push(r(p)+"scale(",null,",",null,")");y.push({i:_-4,x:Xe(l,h)},{i:_-2,x:Xe(f,u)})}else(h!==1||u!==1)&&p.push(r(p)+"scale("+h+","+u+")")}return function(l,f){var h=[],u=[];return l=e(l),f=e(f),i(l.translateX,l.translateY,f.translateX,f.translateY,h,u),s(l.rotate,f.rotate,h,u),c(l.skewX,f.skewX,h,u),d(l.scaleX,l.scaleY,f.scaleX,f.scaleY,h,u),l=f=null,function(p){for(var y=-1,_=u.length,v;++y<_;)h[(v=u[y]).i]=v.x(p);return h.join("")}}}var Rf=Ra(Df,"px, ","px)","deg)"),jf=Ra(Of,", ",")",")"),Hf=1e-12;function Pi(e){return((e=Math.exp(e))+1/e)/2}function Lf(e){return((e=Math.exp(e))-1/e)/2}function zf(e){return((e=Math.exp(2*e))-1)/(e+1)}const zn=(function e(t,n,o){function r(i,s){var c=i[0],d=i[1],l=i[2],f=s[0],h=s[1],u=s[2],p=f-c,y=h-d,_=p*p+y*y,v,m;if(_<Hf)m=Math.log(u/l)/t,v=function(E){return[c+E*p,d+E*y,l*Math.exp(t*E*m)]};else{var S=Math.sqrt(_),g=(u*u-l*l+o*_)/(2*l*n*S),w=(u*u-l*l-o*_)/(2*u*n*S),C=Math.log(Math.sqrt(g*g+1)-g),k=Math.log(Math.sqrt(w*w+1)-w);m=(k-C)/t,v=function(E){var T=E*m,D=Pi(C),L=l/(n*S)*(D*zf(t*T+C)-Lf(C));return[c+L*p,d+L*y,l*D/Pi(t*T+C)]}}return v.duration=m*1e3*t/Math.SQRT2,v}return r.rho=function(i){var s=Math.max(.001,+i),c=s*s,d=c*c;return e(s,c,d)},r})(Math.SQRT2,2,4);var Tt=0,Ut=0,Vt=0,ja=1e3,Qn,Xt,Jn=0,vt=0,lo=0,on=typeof performance=="object"&&performance.now?performance:Date,Ha=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Tr(){return vt||(Ha(Bf),vt=on.now()+lo)}function Bf(){vt=0}function eo(){this._call=this._time=this._next=null}eo.prototype=La.prototype={constructor:eo,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Tr():+n)+(t==null?0:+t),!this._next&&Xt!==this&&(Xt?Xt._next=this:Qn=this,Xt=this),this._call=e,this._time=n,nr()},stop:function(){this._call&&(this._call=null,this._time=1/0,nr())}};function La(e,t,n){var o=new eo;return o.restart(e,t,n),o}function Vf(){Tr(),++Tt;for(var e=Qn,t;e;)(t=vt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Tt}function Ti(){vt=(Jn=on.now())+lo,Tt=Ut=0;try{Vf()}finally{Tt=0,Wf(),vt=0}}function Ff(){var e=on.now(),t=e-Jn;t>ja&&(lo-=t,Jn=e)}function Wf(){for(var e,t=Qn,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Qn=n);Xt=e,nr(o)}function nr(e){if(!Tt){Ut&&(Ut=clearTimeout(Ut));var t=e-vt;t>24?(e<1/0&&(Ut=setTimeout(Ti,e-on.now()-lo)),Vt&&(Vt=clearInterval(Vt))):(Vt||(Jn=on.now(),Vt=setInterval(Ff,ja)),Tt=1,Ha(Ti))}}function Di(e,t,n){var o=new eo;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Uf=ao("start","end","cancel","interrupt"),Xf=[],za=0,Oi=1,or=2,Bn=3,Ri=4,rr=5,Vn=6;function uo(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Yf(e,n,{name:t,index:o,group:r,on:Uf,tween:Xf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:za})}function Dr(e,t){var n=Ve(e,t);if(n.state>za)throw new Error("too late; already scheduled");return n}function Ge(e,t){var n=Ve(e,t);if(n.state>Bn)throw new Error("too late; already running");return n}function Ve(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Yf(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=La(i,0,n.time);function i(l){n.state=Oi,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var f,h,u,p;if(n.state!==Oi)return d();for(f in o)if(p=o[f],p.name===n.name){if(p.state===Bn)return Di(s);p.state===Ri?(p.state=Vn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete o[f]):+f<t&&(p.state=Vn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete o[f])}if(Di(function(){n.state===Bn&&(n.state=Ri,n.timer.restart(c,n.delay,n.time),c(l))}),n.state=or,n.on.call("start",e,e.__data__,n.index,n.group),n.state===or){for(n.state=Bn,r=new Array(u=n.tween.length),f=0,h=-1;f<u;++f)(p=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(r[++h]=p);r.length=h+1}}function c(l){for(var f=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(d),n.state=rr,1),h=-1,u=r.length;++h<u;)r[h].call(e,f);n.state===rr&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Vn,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Fn(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>or&&o.state<rr,o.state=Vn,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Zf(e){return this.each(function(){Fn(this,e)})}function qf(e,t){var n,o;return function(){var r=Ge(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,c=o.length;s<c;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function Gf(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Ge(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var c={name:t,value:n},d=0,l=r.length;d<l;++d)if(r[d].name===t){r[d]=c;break}d===l&&r.push(c)}i.tween=r}}function Kf(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Ve(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?qf:Gf)(n,e,t))}function Or(e,t,n){var o=e._id;return e.each(function(){var r=Ge(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Ve(r,o).value[t]}}function Ba(e,t){var n;return(typeof t=="number"?Xe:t instanceof _t?Kn:(n=_t(t))?(t=n,Kn):Da)(e,t)}function Qf(e){return function(){this.removeAttribute(e)}}function Jf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function eh(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function th(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function nh(e,t,n){var o,r,i;return function(){var s,c=n(this),d;return c==null?void this.removeAttribute(e):(s=this.getAttribute(e),d=c+"",s===d?null:s===o&&d===r?i:(r=d,i=t(o=s,c)))}}function oh(e,t,n){var o,r,i;return function(){var s,c=n(this),d;return c==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),d=c+"",s===d?null:s===o&&d===r?i:(r=d,i=t(o=s,c)))}}function rh(e,t){var n=co(e),o=n==="transform"?jf:Ba;return this.attrTween(e,typeof t=="function"?(n.local?oh:nh)(n,o,Or(this,"attr."+e,t)):t==null?(n.local?Jf:Qf)(n):(n.local?th:eh)(n,o,t))}function ih(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function sh(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ah(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&sh(e,i)),n}return r._value=t,r}function ch(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&ih(e,i)),n}return r._value=t,r}function lh(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=co(e);return this.tween(n,(o.local?ah:ch)(o,t))}function uh(e,t){return function(){Dr(this,e).delay=+t.apply(this,arguments)}}function dh(e,t){return t=+t,function(){Dr(this,e).delay=t}}function fh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?uh:dh)(t,e)):Ve(this.node(),t).delay}function hh(e,t){return function(){Ge(this,e).duration=+t.apply(this,arguments)}}function ph(e,t){return t=+t,function(){Ge(this,e).duration=t}}function gh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?hh:ph)(t,e)):Ve(this.node(),t).duration}function mh(e,t){if(typeof t!="function")throw new Error;return function(){Ge(this,e).ease=t}}function yh(e){var t=this._id;return arguments.length?this.each(mh(t,e)):Ve(this.node(),t).ease}function _h(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ge(this,e).ease=n}}function vh(e){if(typeof e!="function")throw new Error;return this.each(_h(this._id,e))}function wh(e){typeof e!="function"&&(e=_a(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,c=o[r]=[],d,l=0;l<s;++l)(d=i[l])&&e.call(d,d.__data__,l,i)&&c.push(d);return new ot(o,this._parents,this._name,this._id)}function xh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),c=0;c<i;++c)for(var d=t[c],l=n[c],f=d.length,h=s[c]=new Array(f),u,p=0;p<f;++p)(u=d[p]||l[p])&&(h[p]=u);for(;c<o;++c)s[c]=t[c];return new ot(s,this._parents,this._name,this._id)}function bh(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Sh(e,t,n){var o,r,i=bh(t)?Dr:Ge;return function(){var s=i(this,e),c=s.on;c!==o&&(r=(o=c).copy()).on(t,n),s.on=r}}function kh(e,t){var n=this._id;return arguments.length<2?Ve(this.node(),n).on.on(e):this.each(Sh(n,e,t))}function Eh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Ch(){return this.on("end.remove",Eh(this._id))}function Nh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mr(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var c=o[s],d=c.length,l=i[s]=new Array(d),f,h,u=0;u<d;++u)(f=c[u])&&(h=e.call(f,f.__data__,u,c))&&("__data__"in f&&(h.__data__=f.__data__),l[u]=h,uo(l[u],t,n,u,l,Ve(f,n)));return new ot(i,this._parents,t,n)}function Ih(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ya(e));for(var o=this._groups,r=o.length,i=[],s=[],c=0;c<r;++c)for(var d=o[c],l=d.length,f,h=0;h<l;++h)if(f=d[h]){for(var u=e.call(f,f.__data__,h,d),p,y=Ve(f,n),_=0,v=u.length;_<v;++_)(p=u[_])&&uo(p,t,n,_,u,y);i.push(u),s.push(f)}return new ot(i,s,t,n)}var Mh=hn.prototype.constructor;function Ah(){return new Mh(this._groups,this._parents)}function $h(e,t){var n,o,r;return function(){var i=Pt(this,e),s=(this.style.removeProperty(e),Pt(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Va(e){return function(){this.style.removeProperty(e)}}function Ph(e,t,n){var o,r=n+"",i;return function(){var s=Pt(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function Th(e,t,n){var o,r,i;return function(){var s=Pt(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),Pt(this,e))),s===d?null:s===o&&d===r?i:(r=d,i=t(o=s,c))}}function Dh(e,t){var n,o,r,i="style."+t,s="end."+i,c;return function(){var d=Ge(this,e),l=d.on,f=d.value[i]==null?c||(c=Va(t)):void 0;(l!==n||r!==f)&&(o=(n=l).copy()).on(s,r=f),d.on=o}}function Oh(e,t,n){var o=(e+="")=="transform"?Rf:Ba;return t==null?this.styleTween(e,$h(e,o)).on("end.style."+e,Va(e)):typeof t=="function"?this.styleTween(e,Th(e,o,Or(this,"style."+e,t))).each(Dh(this._id,e)):this.styleTween(e,Ph(e,o,t),n).on("end.style."+e,null)}function Rh(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function jh(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Rh(e,s,n)),o}return i._value=t,i}function Hh(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,jh(e,t,n??""))}function Lh(e){return function(){this.textContent=e}}function zh(e){return function(){var t=e(this);this.textContent=t??""}}function Bh(e){return this.tween("text",typeof e=="function"?zh(Or(this,"text",e)):Lh(e==null?"":e+""))}function Vh(e){return function(t){this.textContent=e.call(this,t)}}function Fh(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Vh(r)),t}return o._value=e,o}function Wh(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Fh(e))}function Uh(){for(var e=this._name,t=this._id,n=Fa(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],c=s.length,d,l=0;l<c;++l)if(d=s[l]){var f=Ve(d,t);uo(d,e,n,l,s,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ot(o,this._parents,e,n)}function Xh(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var c={value:s},d={value:function(){--r===0&&i()}};n.each(function(){var l=Ge(this,o),f=l.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(d)),l.on=t}),r===0&&i()})}var Yh=0;function ot(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Fa(){return++Yh}var Ke=hn.prototype;ot.prototype={constructor:ot,select:Nh,selectAll:Ih,selectChild:Ke.selectChild,selectChildren:Ke.selectChildren,filter:wh,merge:xh,selection:Ah,transition:Uh,call:Ke.call,nodes:Ke.nodes,node:Ke.node,size:Ke.size,empty:Ke.empty,each:Ke.each,on:kh,attr:rh,attrTween:lh,style:Oh,styleTween:Hh,text:Bh,textTween:Wh,remove:Ch,tween:Kf,delay:fh,duration:gh,ease:yh,easeVarying:vh,end:Xh,[Symbol.iterator]:Ke[Symbol.iterator]};function Zh(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var qh={time:null,delay:0,duration:250,ease:Zh};function Gh(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Kh(e){var t,n;e instanceof ot?(t=e._id,e=e._name):(t=Fa(),(n=qh).time=Tr(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],c=s.length,d,l=0;l<c;++l)(d=s[l])&&uo(d,e,t,l,s,n||Gh(d,t));return new ot(o,this._parents,e,t)}hn.prototype.interrupt=Zf;hn.prototype.transition=Kh;const Mn=e=>()=>e;function Qh(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function et(e,t,n){this.k=e,this.x=t,this.y=n}et.prototype={constructor:et,scale:function(e){return e===1?this:new et(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new et(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 fo=new et(1,0,0);Wa.prototype=et.prototype;function Wa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return fo;return e.__zoom}function To(e){e.stopImmediatePropagation()}function Ft(e){e.preventDefault(),e.stopImmediatePropagation()}function Jh(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function ep(){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 ji(){return this.__zoom||fo}function tp(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function np(){return navigator.maxTouchPoints||"ontouchstart"in this}function op(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Ua(){var e=Jh,t=ep,n=op,o=tp,r=np,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],c=250,d=zn,l=ao("start","zoom","end"),f,h,u,p=500,y=150,_=0,v=10;function m(b){b.property("__zoom",ji).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",L).filter(r).on("touchstart.zoom",O).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",N).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(b,I,M,P){var A=b.selection?b.selection():b;A.property("__zoom",ji),b!==A?C(b,I,M,P):A.interrupt().each(function(){k(this,arguments).event(P).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},m.scaleBy=function(b,I,M,P){m.scaleTo(b,function(){var A=this.__zoom.k,$=typeof I=="function"?I.apply(this,arguments):I;return A*$},M,P)},m.scaleTo=function(b,I,M,P){m.transform(b,function(){var A=t.apply(this,arguments),$=this.__zoom,j=M==null?w(A):typeof M=="function"?M.apply(this,arguments):M,z=$.invert(j),V=typeof I=="function"?I.apply(this,arguments):I;return n(g(S($,V),j,z),A,s)},M,P)},m.translateBy=function(b,I,M,P){m.transform(b,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),s)},null,P)},m.translateTo=function(b,I,M,P,A){m.transform(b,function(){var $=t.apply(this,arguments),j=this.__zoom,z=P==null?w($):typeof P=="function"?P.apply(this,arguments):P;return n(fo.translate(z[0],z[1]).scale(j.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof M=="function"?-M.apply(this,arguments):-M),$,s)},P,A)};function S(b,I){return I=Math.max(i[0],Math.min(i[1],I)),I===b.k?b:new et(I,b.x,b.y)}function g(b,I,M){var P=I[0]-M[0]*b.k,A=I[1]-M[1]*b.k;return P===b.x&&A===b.y?b:new et(b.k,P,A)}function w(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function C(b,I,M,P){b.on("start.zoom",function(){k(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(P).end()}).tween("zoom",function(){var A=this,$=arguments,j=k(A,$).event(P),z=t.apply(A,$),V=M==null?w(z):typeof M=="function"?M.apply(A,$):M,Z=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),F=A.__zoom,G=typeof I=="function"?I.apply(A,$):I,ee=d(F.invert(V).concat(Z/F.k),G.invert(V).concat(Z/G.k));return function(X){if(X===1)X=G;else{var H=ee(X),W=Z/H[2];X=new et(W,V[0]-H[0]*W,V[1]-H[1]*W)}j.zoom(null,X)}})}function k(b,I,M){return!M&&b.__zooming||new E(b,I)}function E(b,I){this.that=b,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,I),this.taps=0}E.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,I){return this.mouse&&b!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var I=Ie(this.that).datum();l.call(b,this.that,new Qh(b,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),I)}};function T(b,...I){if(!e.apply(this,arguments))return;var M=k(this,I).event(b),P=this.__zoom,A=Math.max(i[0],Math.min(i[1],P.k*Math.pow(2,o.apply(this,arguments)))),$=Re(b);if(M.wheel)(M.mouse[0][0]!==$[0]||M.mouse[0][1]!==$[1])&&(M.mouse[1]=P.invert(M.mouse[0]=$)),clearTimeout(M.wheel);else{if(P.k===A)return;M.mouse=[$,P.invert($)],Fn(this),M.start()}Ft(b),M.wheel=setTimeout(j,y),M.zoom("mouse",n(g(S(P,A),M.mouse[0],M.mouse[1]),M.extent,s));function j(){M.wheel=null,M.end()}}function D(b,...I){if(u||!e.apply(this,arguments))return;var M=b.currentTarget,P=k(this,I,!0).event(b),A=Ie(b.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",Z,!0),$=Re(b,M),j=b.clientX,z=b.clientY;Ia(b.view),To(b),P.mouse=[$,this.__zoom.invert($)],Fn(this),P.start();function V(F){if(Ft(F),!P.moved){var G=F.clientX-j,ee=F.clientY-z;P.moved=G*G+ee*ee>_}P.event(F).zoom("mouse",n(g(P.that.__zoom,P.mouse[0]=Re(F,M),P.mouse[1]),P.extent,s))}function Z(F){A.on("mousemove.zoom mouseup.zoom",null),Ma(F.view,P.moved),Ft(F),P.event(F).end()}}function L(b,...I){if(e.apply(this,arguments)){var M=this.__zoom,P=Re(b.changedTouches?b.changedTouches[0]:b,this),A=M.invert(P),$=M.k*(b.shiftKey?.5:2),j=n(g(S(M,$),P,A),t.apply(this,I),s);Ft(b),c>0?Ie(this).transition().duration(c).call(C,j,P,b):Ie(this).call(m.transform,j,P,b)}}function O(b,...I){if(e.apply(this,arguments)){var M=b.touches,P=M.length,A=k(this,I,b.changedTouches.length===P).event(b),$,j,z,V;for(To(b),j=0;j<P;++j)z=M[j],V=Re(z,this),V=[V,this.__zoom.invert(V),z.identifier],A.touch0?!A.touch1&&A.touch0[2]!==V[2]&&(A.touch1=V,A.taps=0):(A.touch0=V,$=!0,A.taps=1+!!f);f&&(f=clearTimeout(f)),$&&(A.taps<2&&(h=V[0],f=setTimeout(function(){f=null},p)),Fn(this),A.start())}}function B(b,...I){if(this.__zooming){var M=k(this,I).event(b),P=b.changedTouches,A=P.length,$,j,z,V;for(Ft(b),$=0;$<A;++$)j=P[$],z=Re(j,this),M.touch0&&M.touch0[2]===j.identifier?M.touch0[0]=z:M.touch1&&M.touch1[2]===j.identifier&&(M.touch1[0]=z);if(j=M.that.__zoom,M.touch1){var Z=M.touch0[0],F=M.touch0[1],G=M.touch1[0],ee=M.touch1[1],X=(X=G[0]-Z[0])*X+(X=G[1]-Z[1])*X,H=(H=ee[0]-F[0])*H+(H=ee[1]-F[1])*H;j=S(j,Math.sqrt(X/H)),z=[(Z[0]+G[0])/2,(Z[1]+G[1])/2],V=[(F[0]+ee[0])/2,(F[1]+ee[1])/2]}else if(M.touch0)z=M.touch0[0],V=M.touch0[1];else return;M.zoom("touch",n(g(j,z,V),M.extent,s))}}function N(b,...I){if(this.__zooming){var M=k(this,I).event(b),P=b.changedTouches,A=P.length,$,j;for(To(b),u&&clearTimeout(u),u=setTimeout(function(){u=null},p),$=0;$<A;++$)j=P[$],M.touch0&&M.touch0[2]===j.identifier?delete M.touch0:M.touch1&&M.touch1[2]===j.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(j=Re(j,this),Math.hypot(h[0]-j[0],h[1]-j[1])<v)){var z=Ie(this).on("dblclick.zoom");z&&z.apply(this,arguments)}}}return m.wheelDelta=function(b){return arguments.length?(o=typeof b=="function"?b:Mn(+b),m):o},m.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Mn(!!b),m):e},m.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:Mn(!!b),m):r},m.extent=function(b){return arguments.length?(t=typeof b=="function"?b:Mn([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),m):t},m.scaleExtent=function(b){return arguments.length?(i[0]=+b[0],i[1]=+b[1],m):[i[0],i[1]]},m.translateExtent=function(b){return arguments.length?(s[0][0]=+b[0][0],s[1][0]=+b[1][0],s[0][1]=+b[0][1],s[1][1]=+b[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(b){return arguments.length?(n=b,m):n},m.duration=function(b){return arguments.length?(c=+b,m):c},m.interpolate=function(b){return arguments.length?(d=b,m):d},m.on=function(){var b=l.on.apply(l,arguments);return b===l?m:b},m.clickDistance=function(b){return arguments.length?(_=(b=+b)*b,m):Math.sqrt(_)},m.tapDistance=function(b){return arguments.length?(v=+b,m):v},m}const Be={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Xa=["Enter"," ","Escape"],Ya={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Dt;(function(e){e.Strict="strict",e.Loose="loose"})(Dt||(Dt={}));var mt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(mt||(mt={}));var sn;(function(e){e.Partial="partial",e.Full="full"})(sn||(sn={}));const Za={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var dt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(dt||(dt={}));var to;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(to||(to={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const Hi={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top},qa=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,rp=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Rr=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),gn=(e,t=[0,0])=>{const{width:n,height:o}=Fe(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},ip=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const o=e.reduce((r,i)=>{const s=typeof i=="string";let c=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(c=s?t.nodeLookup.get(i):Rr(i)?i:t.nodeLookup.get(i.id)),c?(n=!0,ho(r,no(c,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?po(o):{x:0,y:0,width:0,height:0}},mn=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=ho(n,no(r)),o=!0)}),o?po(n):{x:0,y:0,width:0,height:0}},jr=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const c=(t.x-n)/r,d=(t.y-o)/r,l=t.width/r,f=t.height/r,h=[];for(const u of e.values()){const{measured:p,selectable:y=!0,hidden:_=!1}=u;if(s&&!y||_)continue;const v=p.width??u.width??u.initialWidth??0,m=p.height??u.height??u.initialHeight??0,{x:S,y:g}=u.internals.positionAbsolute,w=Ja(c,d,l,f,S,g,v,m),C=v*m,k=i&&w>0;(!u.internals.handleBounds||k||w>=C||u.dragging)&&h.push(u)}return h},sp=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function ap(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:c}=Fe(r);i=s>0&&c>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function cp({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const c=ap(e,s),d=mn(c),l=Lr(d,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!0}function Ga({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),c=s.parentId?n.get(s.parentId):void 0,{x:d,y:l}=c?c.internals.positionAbsolute:{x:0,y:0},f=s.origin??o;let h=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!c)i?.("005",Be.error005());else{const{width:p,height:y}=Fe(c);p&&y&&(h=[[d,l],[d+p,l+y]])}else c&&xt(s.extent)&&(h=[[s.extent[0][0]+d,s.extent[0][1]+l],[s.extent[1][0]+d,s.extent[1][1]+l]]);const u=xt(h)?wt(t,h,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",Be.error015()),{position:{x:u.x-d+(s.measured.width??0)*f[0],y:u.y-l+(s.measured.height??0)*f[1]},positionAbsolute:u}}async function lp({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(u=>u.id)),s=[];for(const u of n){if(u.deletable===!1)continue;const p=i.has(u.id),y=!p&&u.parentId&&s.find(_=>_.id===u.parentId);(p||y)&&s.push(u)}const c=new Set(t.map(u=>u.id)),d=o.filter(u=>u.deletable!==!1),f=sp(s,d);for(const u of d)c.has(u.id)&&!f.find(y=>y.id===u.id)&&f.push(u);if(!r)return{edges:f,nodes:s};const h=await r({nodes:s,edges:f});return typeof h=="boolean"?h?{edges:f,nodes:s}:{edges:[],nodes:[]}:h}const Ot=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),wt=(e={x:0,y:0},t,n)=>({x:Ot(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ot(e.y,t[0][1],t[1][1]-(n?.height??0))});function Ka(e,t,n){const{width:o,height:r}=Fe(n),{x:i,y:s}=n.internals.positionAbsolute;return wt(e,[[i,s],[i+o,s+r]],t)}const Li=(e,t,n)=>e<t?Ot(Math.abs(e-t),1,t)/t:e>n?-Ot(Math.abs(e-n),1,t)/t:0,Hr=(e,t,n=15,o=40)=>{const r=Li(e.x,o,t.width-o)*n,i=Li(e.y,o,t.height-o)*n;return[r,i]},ho=(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)}),ir=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),po=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),an=(e,t=[0,0])=>{const{x:n,y:o}=Rr(e)?e.internals.positionAbsolute:gn(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},no=(e,t=[0,0])=>{const{x:n,y:o}=Rr(e)?e.internals.positionAbsolute:gn(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Qa=(e,t)=>po(ho(ir(e),ir(t))),Ja=(e,t,n,o,r,i,s,c)=>{const d=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,i+c)-Math.max(t,i));return Math.ceil(d*l)},oo=(e,t)=>Ja(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),zi=e=>He(e.width)&&He(e.height)&&He(e.x)&&He(e.y),He=e=>!isNaN(e)&&isFinite(e),ec=(e,t)=>(n,o)=>{},yn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_n=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const c={x:(e-n)/r,y:(t-o)/r};return i?yn(c,s):c},Rt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function kt(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function up(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=kt(e,n),r=kt(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=kt(e.top??e.y??0,n),r=kt(e.bottom??e.y??0,n),i=kt(e.left??e.x??0,t),s=kt(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function dp(e,t,n,o,r,i){const{x:s,y:c}=Rt(e,[t,n,o]),{x:d,y:l}=Rt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),f=r-d,h=i-l;return{left:Math.floor(s),top:Math.floor(c),right:Math.floor(f),bottom:Math.floor(h)}}const Lr=(e,t,n,o,r,i)=>{const s=up(i,t,n),c=(t-s.x)/e.width,d=(n-s.y)/e.height,l=Math.min(c,d),f=Ot(l,o,r),h=e.x+e.width/2,u=e.y+e.height/2,p=t/2-h*f,y=n/2-u*f,_=dp(e,p,y,f,t,n),v={left:Math.min(_.left-s.left,0),top:Math.min(_.top-s.top,0),right:Math.min(_.right-s.right,0),bottom:Math.min(_.bottom-s.bottom,0)};return{x:p-v.left+v.right,y:y-v.top+v.bottom,zoom:f}},cn=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function xt(e){return e!=null&&e!=="parent"}function Fe(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function tc(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function nc(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const c=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Bi(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function fp(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function hp(e){return{...Ya,...e||{}}}function oc(e){return e===null?null:e?"valid":"invalid"}function Kt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=Le(e),c=_n({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:d,y:l}=n?yn(c,t):c;return{xSnapped:d,ySnapped:l,...c}}const zr=e=>({width:e.offsetWidth,height:e.offsetHeight}),rc=e=>e?.getRootNode?.()||window?.document,pp=["INPUT","SELECT","TEXTAREA"];function ic(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:pp.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const sc=e=>"clientX"in e,Le=(e,t)=>{const n=sc(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Vi=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const c=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(c.left-n.left)/o,y:(c.top-n.top)/o,...zr(s)}})};function ac({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:c}){const d=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+c*.375+o*.125,f=Math.abs(d-e),h=Math.abs(l-t);return[d,l,f,h]}function An(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Fi({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case q.Left:return[t-An(t-o,i),n];case q.Right:return[t+An(o-t,i),n];case q.Top:return[t,n-An(n-r,i)];case q.Bottom:return[t,n+An(r-n,i)]}}function cc({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:o,targetY:r,targetPosition:i=q.Top,curvature:s=.25}){const[c,d]=Fi({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,f]=Fi({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[h,u,p,y]=ac({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:c,sourceControlY:d,targetControlX:l,targetControlY:f});return[`M${e},${t} C${c},${d} ${l},${f} ${o},${r}`,h,u,p,y]}function lc({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,c=o<t?o+s:o-s;return[i,c,r,s]}function gp({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,c=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+c}function mp({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=ho(no(e),no(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return oo(s,po(i))>0}const yp=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,_p=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),vp=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",Be.error006()),t;const o=n.getEdgeId||yp;let r;return qa(e)?r={...e}:r={...e,id:o(e)},_p(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function uc({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,c]=lc({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,c]}const Wi={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},wp=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.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},Ui=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function xp({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:o=q.Top,center:r,offset:i,stepPosition:s}){const c=Wi[t],d=Wi[o],l={x:e.x+c.x*i,y:e.y+c.y*i},f={x:n.x+d.x*i,y:n.y+d.y*i},h=wp({source:l,sourcePosition:t,target:f}),u=h.x!==0?"x":"y",p=h[u];let y=[],_,v;const m={x:0,y:0},S={x:0,y:0},[,,g,w]=lc({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[u]*d[u]===-1){u==="x"?(_=r.x??l.x+(f.x-l.x)*s,v=r.y??(l.y+f.y)/2):(_=r.x??(l.x+f.x)/2,v=r.y??l.y+(f.y-l.y)*s);const T=[{x:_,y:l.y},{x:_,y:f.y}],D=[{x:l.x,y:v},{x:f.x,y:v}];c[u]===p?y=u==="x"?T:D:y=u==="x"?D:T}else{const T=[{x:l.x,y:f.y}],D=[{x:f.x,y:l.y}];if(u==="x"?y=c.x===p?D:T:y=c.y===p?T:D,t===o){const b=Math.abs(e[u]-n[u]);if(b<=i){const I=Math.min(i-1,i-b);c[u]===p?m[u]=(l[u]>e[u]?-1:1)*I:S[u]=(f[u]>n[u]?-1:1)*I}}if(t!==o){const b=u==="x"?"y":"x",I=c[u]===d[b],M=l[b]>f[b],P=l[b]<f[b];(c[u]===1&&(!I&&M||I&&P)||c[u]!==1&&(!I&&P||I&&M))&&(y=u==="x"?T:D)}const L={x:l.x+m.x,y:l.y+m.y},O={x:f.x+S.x,y:f.y+S.y},B=Math.max(Math.abs(L.x-y[0].x),Math.abs(O.x-y[0].x)),N=Math.max(Math.abs(L.y-y[0].y),Math.abs(O.y-y[0].y));B>=N?(_=(L.x+O.x)/2,v=y[0].y):(_=y[0].x,v=(L.y+O.y)/2)}const C={x:l.x+m.x,y:l.y+m.y},k={x:f.x+S.x,y:f.y+S.y};return[[e,...C.x!==y[0].x||C.y!==y[0].y?[C]:[],...y,...k.x!==y[y.length-1].x||k.y!==y[y.length-1].y?[k]:[],n],_,v,g,w]}function bp(e,t,n,o){const r=Math.min(Ui(e,t)/2,Ui(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*f}`}const c=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${i},${s+r*d}Q ${i},${s} ${i+r*c},${s}`}function sr({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:o,targetY:r,targetPosition:i=q.Top,borderRadius:s=5,centerX:c,centerY:d,offset:l=20,stepPosition:f=.5}){const[h,u,p,y,_]=xp({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:c,y:d},offset:l,stepPosition:f});let v=`M${h[0].x} ${h[0].y}`;for(let m=1;m<h.length-1;m++)v+=bp(h[m-1],h[m],h[m+1],s);return v+=`L${h[h.length-1].x} ${h[h.length-1].y}`,[v,u,p,y,_]}function Xi(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Sp(e){const{sourceNode:t,targetNode:n}=e;if(!Xi(t)||!Xi(n))return null;const o=t.internals.handleBounds||Yi(t.handles),r=n.internals.handleBounds||Yi(n.handles),i=Zi(o?.source??[],e.sourceHandle),s=Zi(e.connectionMode===Dt.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",Be.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=i?.position||q.Bottom,d=s?.position||q.Top,l=bt(t,i,c),f=bt(n,s,d);return{sourceX:l.x,sourceY:l.y,targetX:f.x,targetY:f.y,sourcePosition:c,targetPosition:d}}function Yi(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function bt(e,t,n=q.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:c}=t??Fe(e);if(o)return{x:r+s/2,y:i+c/2};switch(t?.position??n){case q.Top:return{x:r+s/2,y:i};case q.Right:return{x:r+s,y:i+c/2};case q.Bottom:return{x:r+s/2,y:i+c};case q.Left:return{x:r,y:i+c/2}}}function Zi(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function ar(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function kp(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,c)=>([c.markerStart||o,c.markerEnd||r].forEach(d=>{if(d&&typeof d=="object"){const l=ar(d,t);i.has(l)||(s.push({id:l,color:d.color||n,...d}),i.add(l))}}),s),[]).sort((s,c)=>s.id.localeCompare(c.id))}const dc=1e3,Ep=10,Br={nodeOrigin:[0,0],nodeExtent:rn,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Cp={...Br,checkEquality:!0};function Vr(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Np(e,t,n){const o=Vr(Br,n);for(const r of e.values())if(r.parentId)Wr(r,e,t,o);else{const i=gn(r,o.nodeOrigin),s=xt(r.extent)?r.extent:o.nodeExtent,c=wt(i,s,Fe(r));r.internals.positionAbsolute=c}}function Ip(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function Fr(e){return e==="manual"}function cr(e,t,n,o={}){const r=Vr(Cp,o),i={i:0},s=new Map(t),c=r?.elevateNodesOnSelect&&!Fr(r.zIndexMode)?dc:0;let d=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let h=s.get(f.id);if(r.checkEquality&&f===h?.internals.userNode)t.set(f.id,h);else{const u=gn(f,r.nodeOrigin),p=xt(f.extent)?f.extent:r.nodeExtent,y=wt(u,p,Fe(f));h={...r.defaults,...f,measured:{width:f.measured?.width,height:f.measured?.height},internals:{positionAbsolute:y,handleBounds:Ip(f,h),z:fc(f,c,r.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(d=!1),f.parentId&&Wr(h,t,n,o,i),l||=f.selected??!1}return{nodesInitialized:d,hasSelectedNodes:l}}function Mp(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Wr(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:c,zIndexMode:d}=Vr(Br,o),l=e.parentId,f=t.get(l);if(!f){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}Mp(e,n),r&&!f.parentId&&f.internals.rootParentIndex===void 0&&d==="auto"&&(f.internals.rootParentIndex=++r.i,f.internals.z=f.internals.z+r.i*Ep),r&&f.internals.rootParentIndex!==void 0&&(r.i=f.internals.rootParentIndex);const h=i&&!Fr(d)?dc:0,{x:u,y:p,z:y}=Ap(e,f,s,c,h,d),{positionAbsolute:_}=e.internals,v=u!==_.x||p!==_.y;(v||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:u,y:p}:_,z:y}})}function fc(e,t,n){const o=He(e.zIndex)?e.zIndex:0;return Fr(n)?o:o+(e.selected?t:0)}function Ap(e,t,n,o,r,i){const{x:s,y:c}=t.internals.positionAbsolute,d=Fe(e),l=gn(e,n),f=xt(e.extent)?wt(l,e.extent,d):l;let h=wt({x:s+f.x,y:c+f.y},o,d);e.extent==="parent"&&(h=Ka(h,d,t));const u=fc(e,r,i),p=t.internals.z??0;return{x:h.x,y:h.y,z:p>=u?p+1:u}}function Ur(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const c=t.get(s.parentId);if(!c)continue;const d=i.get(s.parentId)?.expandedRect??an(c),l=Qa(d,s.rect);i.set(s.parentId,{expandedRect:l,parent:c})}return i.size>0&&i.forEach(({expandedRect:s,parent:c},d)=>{const l=c.internals.positionAbsolute,f=Fe(c),h=c.origin??o,u=s.x<l.x?Math.round(Math.abs(l.x-s.x)):0,p=s.y<l.y?Math.round(Math.abs(l.y-s.y)):0,y=Math.max(f.width,Math.round(s.width)),_=Math.max(f.height,Math.round(s.height)),v=(y-f.width)*h[0],m=(_-f.height)*h[1];(u>0||p>0||v||m)&&(r.push({id:d,type:"position",position:{x:c.position.x-u+v,y:c.position.y-p+m}}),n.get(d)?.forEach(S=>{e.some(g=>g.id===S.id)||r.push({id:S.id,type:"position",position:{x:S.position.x+u,y:S.position.y+p}})})),(f.width<s.width||f.height<s.height||u||p)&&r.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:y+(u?h[0]*u-v:0),height:_+(p?h[1]*p-m:0)}})}),r}function $p(e,t,n,o,r,i,s){const c=o?.querySelector(".xyflow__viewport");let d=!1;if(!c)return{changes:[],updatedInternals:d};const l=[],f=window.getComputedStyle(c),{m22:h}=new window.DOMMatrixReadOnly(f.transform),u=[];for(const p of e.values()){const y=t.get(p.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),d=!0;continue}const _=zr(p.nodeElement),v=y.measured.width!==_.width||y.measured.height!==_.height;if(!!(_.width&&_.height&&(v||!y.internals.handleBounds||p.force))){const S=p.nodeElement.getBoundingClientRect(),g=xt(y.extent)?y.extent:i;let{positionAbsolute:w}=y.internals;if(y.parentId&&y.extent==="parent"){const k=t.get(y.parentId);k&&(w=Ka(w,_,k))}else g&&(w=wt(w,g,_));const C={...y,measured:_,internals:{...y.internals,positionAbsolute:w,handleBounds:{source:Vi("source",p.nodeElement,S,h,y.id),target:Vi("target",p.nodeElement,S,h,y.id)}}};t.set(y.id,C),y.parentId&&Wr(C,t,n,{nodeOrigin:r,zIndexMode:s}),d=!0,v&&(l.push({id:y.id,type:"dimensions",dimensions:_}),y.expandParent&&y.parentId&&u.push({id:y.id,parentId:y.parentId,rect:an(C,r)}))}}if(u.length>0){const p=Ur(u,t,n,r);l.push(...p)}return{changes:l,updatedInternals:d}}async function Pp({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function qi(e,t,n,o,r,i){let s=r;const c=o.get(s)||new Map;o.set(s,c.set(n,t)),s=`${r}-${e}`;const d=o.get(s)||new Map;if(o.set(s,d.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function hc(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:c=null}=o,d={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:c},l=`${r}-${s}--${i}-${c}`,f=`${i}-${c}--${r}-${s}`;qi("source",d,f,e,r,s),qi("target",d,l,e,i,c),t.set(o.id,o)}}function pc(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:pc(n,t):!1}function Gi(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Tp(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!pc(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const c=e.get(i);c&&r.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function Do({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,c]of t){const d=n.get(s)?.internals.userNode;d&&r.push({...d,position:c.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function Dp({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=yn(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Op({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,c=new Map,d=!1,l={x:0,y:0},f=null,h=!1,u=null,p=!1,y=!1,_=null;function v({noDragClassName:S,handleSelector:g,domNode:w,isSelectable:C,nodeId:k,nodeClickDistance:E=0}){u=Ie(w);function T({x:B,y:N}){const{nodeLookup:b,nodeExtent:I,snapGrid:M,snapToGrid:P,nodeOrigin:A,onNodeDrag:$,onSelectionDrag:j,onError:z,updateNodePositions:V}=t();i={x:B,y:N};let Z=!1;const F=c.size>1,G=F&&I?ir(mn(c)):null,ee=F&&P?Dp({dragItems:c,snapGrid:M,x:B,y:N}):null;for(const[X,H]of c){if(!b.has(X))continue;let W={x:B-H.distance.x,y:N-H.distance.y};P&&(W=ee?{x:Math.round(W.x+ee.x),y:Math.round(W.y+ee.y)}:yn(W,M));let Q=null;if(F&&I&&!H.extent&&G){const{positionAbsolute:K}=H.internals,re=K.x-G.x+I[0][0],ie=K.x+H.measured.width-G.x2+I[1][0],ce=K.y-G.y+I[0][1],me=K.y+H.measured.height-G.y2+I[1][1];Q=[[re,ce],[ie,me]]}const{position:Y,positionAbsolute:U}=Ga({nodeId:X,nextPosition:W,nodeLookup:b,nodeExtent:Q||I,nodeOrigin:A,onError:z});Z=Z||H.position.x!==Y.x||H.position.y!==Y.y,H.position=Y,H.internals.positionAbsolute=U}if(y=y||Z,!!Z&&(V(c,!0),_&&(o||$||!k&&j))){const[X,H]=Do({nodeId:k,dragItems:c,nodeLookup:b});o?.(_,c,X,H),$?.(_,X,H),k||j?.(_,H)}}async function D(){if(!f)return;const{transform:B,panBy:N,autoPanSpeed:b,autoPanOnNodeDrag:I}=t();if(!I){d=!1,cancelAnimationFrame(s);return}const[M,P]=Hr(l,f,b);(M!==0||P!==0)&&(i.x=(i.x??0)-M/B[2],i.y=(i.y??0)-P/B[2],await N({x:M,y:P})&&T(i)),s=requestAnimationFrame(D)}function L(B){const{nodeLookup:N,multiSelectionActive:b,nodesDraggable:I,transform:M,snapGrid:P,snapToGrid:A,selectNodesOnDrag:$,onNodeDragStart:j,onSelectionDragStart:z,unselectNodesAndEdges:V}=t();h=!0,(!$||!C)&&!b&&k&&(N.get(k)?.selected||V()),C&&$&&k&&e?.(k);const Z=Kt(B.sourceEvent,{transform:M,snapGrid:P,snapToGrid:A,containerBounds:f});if(i=Z,c=Tp(N,I,Z,k),c.size>0&&(n||j||!k&&z)){const[F,G]=Do({nodeId:k,dragItems:c,nodeLookup:N});n?.(B.sourceEvent,c,F,G),j?.(B.sourceEvent,F,G),k||z?.(B.sourceEvent,G)}}const O=Aa().clickDistance(E).on("start",B=>{const{domNode:N,nodeDragThreshold:b,transform:I,snapGrid:M,snapToGrid:P}=t();f=N?.getBoundingClientRect()||null,p=!1,y=!1,_=B.sourceEvent,b===0&&L(B),i=Kt(B.sourceEvent,{transform:I,snapGrid:M,snapToGrid:P,containerBounds:f}),l=Le(B.sourceEvent,f)}).on("drag",B=>{const{autoPanOnNodeDrag:N,transform:b,snapGrid:I,snapToGrid:M,nodeDragThreshold:P,nodeLookup:A}=t(),$=Kt(B.sourceEvent,{transform:b,snapGrid:I,snapToGrid:M,containerBounds:f});if(_=B.sourceEvent,(B.sourceEvent.type==="touchmove"&&B.sourceEvent.touches.length>1||k&&!A.has(k))&&(p=!0),!p){if(!d&&N&&h&&(d=!0,D()),!h){const j=Le(B.sourceEvent,f),z=j.x-l.x,V=j.y-l.y;Math.sqrt(z*z+V*V)>P&&L(B)}(i.x!==$.xSnapped||i.y!==$.ySnapped)&&c&&h&&(l=Le(B.sourceEvent,f),T($))}}).on("end",B=>{if(!h||p){p&&c.size>0&&t().updateNodePositions(c,!1);return}if(d=!1,h=!1,cancelAnimationFrame(s),c.size>0){const{nodeLookup:N,updateNodePositions:b,onNodeDragStop:I,onSelectionDragStop:M}=t();if(y&&(b(c,!1),y=!1),r||I||!k&&M){const[P,A]=Do({nodeId:k,dragItems:c,nodeLookup:N,dragging:!1});r?.(B.sourceEvent,c,P,A),I?.(B.sourceEvent,P,A),k||M?.(B.sourceEvent,A)}}}).filter(B=>{const N=B.target;return!B.button&&(!S||!Gi(N,`.${S}`,w))&&(!g||Gi(N,g,w))});u.call(O)}function m(){u?.on(".drag",null)}return{update:v,destroy:m}}function Rp(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())oo(r,an(i))>0&&o.push(i);return o}const jp=250;function Hp(e,t,n,o){let r=[],i=1/0;const s=Rp(e,n,t+jp);for(const c of s){const d=[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]];for(const l of d){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:f,y:h}=bt(c,l,l.position,!0),u=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));u>t||(u<i?(r=[{...l,x:f,y:h}],i=u):u===i&&r.push({...l,x:f,y:h}))}}if(!r.length)return null;if(r.length>1){const c=o.type==="source"?"target":"source";return r.find(d=>d.type===c)??r[0]}return r[0]}function gc(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const c=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],d=(n?c?.find(l=>l.id===n):c?.[0])??null;return d&&i?{...d,...bt(s,d,d.position,!0)}:d}function mc(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Lp(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const yc=()=>!0;function zp(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:c,nodeLookup:d,lib:l,autoPanOnConnect:f,flowId:h,panBy:u,cancelConnection:p,onConnectStart:y,onConnect:_,onConnectEnd:v,isValidConnection:m=yc,onReconnectEnd:S,updateConnection:g,getTransform:w,getFromHandle:C,autoPanSpeed:k,dragThreshold:E=1,handleDomNode:T}){const D=rc(e.target);let L=0,O;const{x:B,y:N}=Le(e),b=mc(i,T),I=c?.getBoundingClientRect();let M=!1;if(!I||!b)return;const P=gc(r,b,o,d,t);if(!P)return;let A=Le(e,I),$=!1,j=null,z=!1,V=null;function Z(){if(!f||!I)return;const[Y,U]=Hr(A,I,k);u({x:Y,y:U}),L=requestAnimationFrame(Z)}const F={...P,nodeId:r,type:b,position:P.position},G=d.get(r);let X={inProgress:!0,isValid:null,from:bt(G,F,q.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:G,to:A,toHandle:null,toPosition:Hi[F.position],toNode:null,pointer:A};function H(){M=!0,g(X),y?.(e,{nodeId:r,handleId:o,handleType:b})}E===0&&H();function W(Y){if(!M){const{x:me,y:$e}=Le(Y),ve=me-B,Ee=$e-N;if(!(ve*ve+Ee*Ee>E*E))return;H()}if(!C()||!F){Q(Y);return}const U=w();A=Le(Y,I),O=Hp(_n(A,U,!1,[1,1]),n,d,F),$||(Z(),$=!0);const K=_c(Y,{handle:O,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:D,lib:l,flowId:h,nodeLookup:d});V=K.handleDomNode,j=K.connection,z=Lp(!!O,K.isValid);const re=d.get(r),ie=re?bt(re,F,q.Left,!0):X.from,ce={...X,from:ie,isValid:z,to:K.toHandle&&z?Rt({x:K.toHandle.x,y:K.toHandle.y},U):A,toHandle:K.toHandle,toPosition:z&&K.toHandle?K.toHandle.position:Hi[F.position],toNode:K.toHandle?d.get(K.toHandle.nodeId):null,pointer:A};g(ce),X=ce}function Q(Y){if(!("touches"in Y&&Y.touches.length>0)){if(M){(O||V)&&j&&z&&_?.(j);const{inProgress:U,...K}=X,re={...K,toPosition:X.toHandle?X.toPosition:null};v?.(Y,re),i&&S?.(Y,re)}p(),cancelAnimationFrame(L),$=!1,z=!1,j=null,V=null,D.removeEventListener("mousemove",W),D.removeEventListener("mouseup",Q),D.removeEventListener("touchmove",W),D.removeEventListener("touchend",Q)}}D.addEventListener("mousemove",W),D.addEventListener("mouseup",Q),D.addEventListener("touchmove",W),D.addEventListener("touchend",Q)}function _c(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:c,flowId:d,isValidConnection:l=yc,nodeLookup:f}){const h=i==="target",u=t?s.querySelector(`.${c}-flow__handle[data-id="${d}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y}=Le(e),_=s.elementFromPoint(p,y),v=_?.classList.contains(`${c}-flow__handle`)?_:u,m={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const S=mc(void 0,v),g=v.getAttribute("data-nodeid"),w=v.getAttribute("data-handleid"),C=v.classList.contains("connectable"),k=v.classList.contains("connectableend");if(!g||!S)return m;const E={source:h?g:o,sourceHandle:h?w:r,target:h?o:g,targetHandle:h?r:w};m.connection=E;const D=C&&k&&(n===Dt.Strict?h&&S==="source"||!h&&S==="target":g!==o||w!==r);m.isValid=D&&l(E),m.toHandle=gc(g,S,w,f,n,!0)}return m}const lr={onPointerDown:zp,isValid:_c};function Bp({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=Ie(e);function i({translateExtent:c,width:d,height:l,zoomStep:f=1,pannable:h=!0,zoomable:u=!0,inversePan:p=!1}){const y=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const w=n(),C=g.sourceEvent.ctrlKey&&cn()?10:1,k=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*f,E=w[2]*Math.pow(2,k*C);t.scaleTo(E)};let _=[0,0];const v=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(_=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},m=g=>{const w=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const C=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],k=[C[0]-_[0],C[1]-_[1]];_=C;const E=o()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),T={x:w[0]-k[0]*E,y:w[1]-k[1]*E},D=[[0,0],[d,l]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},D,c)},S=Ua().on("start",v).on("zoom",h?m:null).on("zoom.wheel",u?y:null);r.call(S,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:Re}}const go=e=>({x:e.x,y:e.y,zoom:e.k}),Oo=({x:e,y:t,zoom:n})=>fo.translate(e,t).scale(n),lt=(e,t)=>e.target.closest(`.${t}`),vc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Vp=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ro=(e,t=0,n=Vp,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},wc=e=>{const t=e.ctrlKey&&cn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fp({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:l}){return f=>{if(lt(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const h=n.property("__zoom").k||1;if(f.ctrlKey&&s){const v=Re(f),m=wc(f),S=h*Math.pow(2,m);o.scaleTo(n,S,v,f);return}const u=f.deltaMode===1?20:1;let p=r===mt.Vertical?0:f.deltaX*u,y=r===mt.Horizontal?0:f.deltaY*u;!cn()&&f.shiftKey&&r!==mt.Vertical&&(p=f.deltaY*u,y=0),o.translateBy(n,-(p/h)*i,-(y/h)*i,{internal:!0});const _=go(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?d?.(f,_):(e.isPanScrolling=!0,c?.(f,_)),e.panScrollTimeout=setTimeout(()=>{l?.(f,_),e.isPanScrolling=!1},150)}}function Wp({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,c=lt(o,e);if(o.ctrlKey&&i&&c&&o.preventDefault(),s||c)return null;o.preventDefault(),n.call(this,o,r)}}function Up({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=go(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Xp({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&vc(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,go(i.transform))}}function Yp({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&vc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const c=go(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,c)},n?150:0)}}}function Zp({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:c,noWheelClassName:d,noPanClassName:l,lib:f,connectionInProgress:h}){return u=>{const p=t||n,y=o&&u.ctrlKey,_=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(lt(u,`${f}-flow__node`)||lt(u,`${f}-flow__edge`)||lt(u,`${f}-flow__selection`)||lt(u,`${f}-flow__nodesselection`)))return!0;if(!r&&!p&&!i&&!s&&!o||c||h&&!_||lt(u,d)&&_||lt(u,l)&&(!_||i&&_&&!t)||!o&&u.ctrlKey&&_)return!1;if(!o&&u.type==="touchstart"&&u.touches?.length>1)return u.preventDefault(),!1;if(!p&&!i&&!y&&_||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||_||e)&&v}}function qp({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:c,onDraggingChange:d}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect();let h=[[0,0],[f.width,f.height]];(typeof ResizeObserver<"u"?new ResizeObserver(N=>{const b=N[0];b&&(h=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null)?.observe(e);const p=Ua().extent(()=>h).scaleExtent([t,n]).translateExtent(o),y=Ie(e).call(p);w({x:r.x,y:r.y,zoom:Ot(r.zoom,t,n)},[[0,0],[f.width,f.height]],o);const _=y.on("wheel.zoom"),v=y.on("dblclick.zoom");p.wheelDelta(wc);async function m(N,b){return y?new Promise(I=>{p?.interpolate(b?.interpolate==="linear"?Gt:zn).transform(Ro(y,b?.duration,b?.ease,()=>I(!0)),N)}):!1}function S({noWheelClassName:N,noPanClassName:b,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:P,panOnDrag:A,panOnScrollMode:$,panOnScrollSpeed:j,preventScrolling:z,zoomOnPinch:V,zoomOnScroll:Z,zoomOnDoubleClick:F,panActivationKeyPressed:G=!1,zoomActivationKeyPressed:ee,lib:X,onTransformChange:H,connectionInProgress:W,paneClickDistance:Q,selectionOnDrag:Y}){M&&!l.isZoomingOrPanning&&g();const U=P&&!ee&&!M;p.clickDistance(Y?1/0:!He(Q)||Q<0?0:Q);const K=U?Fp({zoomPanValues:l,noWheelClassName:N,d3Selection:y,d3Zoom:p,panOnScrollMode:$,panOnScrollSpeed:j,zoomOnPinch:V,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:c}):Wp({noWheelClassName:N,preventScrolling:z,d3ZoomHandler:_});y.on("wheel.zoom",K,{passive:!1});const re=Up({zoomPanValues:l,onDraggingChange:d,onPanZoomStart:s});p.on("start",re);const ie=Xp({zoomPanValues:l,panOnDrag:A,onPaneContextMenu:!!I,onPanZoom:i,onTransformChange:H});p.on("zoom",ie);const ce=Yp({zoomPanValues:l,panOnDrag:A,panOnScroll:P,onPaneContextMenu:I,onPanZoomEnd:c,onDraggingChange:d});p.on("end",ce);const me=Zp({panActivationKeyPressed:G,zoomActivationKeyPressed:ee,panOnDrag:A,zoomOnScroll:Z,panOnScroll:P,zoomOnDoubleClick:F,zoomOnPinch:V,userSelectionActive:M,noPanClassName:b,noWheelClassName:N,lib:X,connectionInProgress:W});p.filter(me),F?y.on("dblclick.zoom",v):y.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function w(N,b,I){const M=Oo(N),P=p?.constrain()(M,b,I);return P&&await m(P),P}async function C(N,b){const I=Oo(N);return await m(I,b),I}function k(N){if(y){const b=Oo(N),I=y.property("__zoom");(I.k!==N.zoom||I.x!==N.x||I.y!==N.y)&&p?.transform(y,b,null,{sync:!0})}}function E(){const N=y?Wa(y.node()):{x:0,y:0,k:1};return{x:N.x,y:N.y,zoom:N.k}}async function T(N,b){return y?new Promise(I=>{p?.interpolate(b?.interpolate==="linear"?Gt:zn).scaleTo(Ro(y,b?.duration,b?.ease,()=>I(!0)),N)}):!1}async function D(N,b){return y?new Promise(I=>{p?.interpolate(b?.interpolate==="linear"?Gt:zn).scaleBy(Ro(y,b?.duration,b?.ease,()=>I(!0)),N)}):!1}function L(N){p?.scaleExtent(N)}function O(N){p?.translateExtent(N)}function B(N){const b=!He(N)||N<0?0:N;p?.clickDistance(b)}return{update:S,destroy:g,setViewport:C,setViewportConstrained:w,getViewport:E,scaleTo:T,scaleBy:D,setScaleExtent:L,setTranslateExtent:O,syncViewport:k,setClickDistance:B}}var jt;(function(e){e.Line="line",e.Handle="handle"})(jt||(jt={}));function Gp({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,c=n-o,d=[s>0?1:s<0?-1:0,c>0?1:c<0?-1:0];return s&&r&&(d[0]=d[0]*-1),c&&i&&(d[1]=d[1]*-1),d}function Ki(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function st(e,t){return Math.max(0,t-e)}function at(e,t){return Math.max(0,e-t)}function $n(e,t,n){return Math.max(0,t-e,e-n)}function Qi(e,t){return e?!t:t}function Kp(e,t,n,o,r,i,s,c){let{affectsX:d,affectsY:l}=t;const{isHorizontal:f,isVertical:h}=t,u=f&&h,{xSnapped:p,ySnapped:y}=n,{minWidth:_,maxWidth:v,minHeight:m,maxHeight:S}=o,{x:g,y:w,width:C,height:k,aspectRatio:E}=e;let T=Math.floor(f?p-e.pointerX:0),D=Math.floor(h?y-e.pointerY:0);const L=C+(d?-T:T),O=k+(l?-D:D),B=-i[0]*C,N=-i[1]*k;let b=$n(L,_,v),I=$n(O,m,S);if(s){let A=0,$=0;d&&T<0?A=st(g+T+B,s[0][0]):!d&&T>0&&(A=at(g+L+B,s[1][0])),l&&D<0?$=st(w+D+N,s[0][1]):!l&&D>0&&($=at(w+O+N,s[1][1])),b=Math.max(b,A),I=Math.max(I,$)}if(c){let A=0,$=0;d&&T>0?A=at(g+T,c[0][0]):!d&&T<0&&(A=st(g+L,c[1][0])),l&&D>0?$=at(w+D,c[0][1]):!l&&D<0&&($=st(w+O,c[1][1])),b=Math.max(b,A),I=Math.max(I,$)}if(r){if(f){const A=$n(L/E,m,S)*E;if(b=Math.max(b,A),s){let $=0;!d&&!l||d&&!l&&u?$=at(w+N+L/E,s[1][1])*E:$=st(w+N+(d?T:-T)/E,s[0][1])*E,b=Math.max(b,$)}if(c){let $=0;!d&&!l||d&&!l&&u?$=st(w+L/E,c[1][1])*E:$=at(w+(d?T:-T)/E,c[0][1])*E,b=Math.max(b,$)}}if(h){const A=$n(O*E,_,v)/E;if(I=Math.max(I,A),s){let $=0;!d&&!l||l&&!d&&u?$=at(g+O*E+B,s[1][0])/E:$=st(g+(l?D:-D)*E+B,s[0][0])/E,I=Math.max(I,$)}if(c){let $=0;!d&&!l||l&&!d&&u?$=st(g+O*E,c[1][0])/E:$=at(g+(l?D:-D)*E,c[0][0])/E,I=Math.max(I,$)}}}D=D+(D<0?I:-I),T=T+(T<0?b:-b),r&&(u?L>O*E?D=(Qi(d,l)?-T:T)/E:T=(Qi(d,l)?-D:D)*E:f?(D=T/E,l=d):(T=D*E,d=l));const M=d?g+T:g,P=l?w+D:w;return{width:C+(d?-T:T),height:k+(l?-D:D),x:i[0]*T*(d?-1:1)+M,y:i[1]*D*(l?-1:1)+P}}const xc={width:0,height:0,x:0,y:0},Qp={...xc,pointerX:0,pointerY:0,aspectRatio:1};function Jp(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,c=n[0]*i,d=n[1]*s;return[[o-c,r-d],[o+i-c,r+s-d]]}function eg({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=Ie(e);let s={controlDirection:Ki("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:l,boundaries:f,keepAspectRatio:h,resizeDirection:u,onResizeStart:p,onResize:y,onResizeEnd:_,shouldResize:v}){let m={...xc},S={...Qp};s={boundaries:f,resizeDirection:u,keepAspectRatio:h,controlDirection:Ki(l)};let g,w=null,C=[],k,E,T;const D=Aa().on("start",L=>{const{nodeLookup:O,transform:B,snapGrid:N,snapToGrid:b,nodeOrigin:I,paneDomNode:M}=n();if(g=O.get(t),!g)return;w=M?.getBoundingClientRect()??null;const{xSnapped:P,ySnapped:A}=Kt(L.sourceEvent,{transform:B,snapGrid:N,snapToGrid:b,containerBounds:w});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},S={...m,pointerX:P,pointerY:A,aspectRatio:m.width/m.height},k=void 0,E=xt(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(k=O.get(g.parentId)),k&&g.extent==="parent"&&(E=[[0,0],[k.measured.width,k.measured.height]]),C=[],T=void 0;for(const[$,j]of O)if(j.parentId===t&&(C.push({id:$,position:{...j.position},extent:j.extent}),j.extent==="parent"||j.expandParent)){const z=Jp(j,g,j.origin??I);T?T=[[Math.min(z[0][0],T[0][0]),Math.min(z[0][1],T[0][1])],[Math.max(z[1][0],T[1][0]),Math.max(z[1][1],T[1][1])]]:T=z}p?.(L,{...m})}).on("drag",L=>{const{transform:O,snapGrid:B,snapToGrid:N,nodeOrigin:b}=n(),I=Kt(L.sourceEvent,{transform:O,snapGrid:B,snapToGrid:N,containerBounds:w}),M=[];if(!g)return;const{x:P,y:A,width:$,height:j}=m,z={},V=g.origin??b,{width:Z,height:F,x:G,y:ee}=Kp(S,s.controlDirection,I,s.boundaries,s.keepAspectRatio,V,E,T),X=Z!==$,H=F!==j,W=G!==P&&X,Q=ee!==A&&H;if(!W&&!Q&&!X&&!H)return;const Y={prevValues:{...m},startX:S.x,startY:S.y,childNodes:C.map(ie=>({...ie,position:{...ie.position}}))};if((W||Q||V[0]===1||V[1]===1)&&(z.x=W?G:m.x,z.y=Q?ee:m.y,m.x=z.x,m.y=z.y,C.length>0)){const ie=G-P,ce=ee-A;for(const me of C)me.position={x:me.position.x-ie+V[0]*(Z-$),y:me.position.y-ce+V[1]*(F-j)},M.push(me)}if((X||H)&&(z.width=X&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Z:m.width,z.height=H&&(!s.resizeDirection||s.resizeDirection==="vertical")?F:m.height,m.width=z.width,m.height=z.height),k&&g.expandParent){const ie=V[0]*(z.width??0);z.x&&z.x<ie&&(m.x=ie,S.x=S.x-(z.x-ie));const ce=V[1]*(z.height??0);z.y&&z.y<ce&&(m.y=ce,S.y=S.y-(z.y-ce))}const U=Gp({width:m.width,prevWidth:$,height:m.height,prevHeight:j,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),K={...m,direction:U};if(v?.(L,K)===!1){m=Y.prevValues,S.x=Y.startX,S.y=Y.startY,C.forEach((ie,ce)=>{ie.position=Y.childNodes[ce].position});return}y?.(L,K),o(z,M)}).on("end",L=>{_?.(L,{...m}),r?.({...m})});i.call(D)}function d(){i.on(".drag",null)}return{update:c,destroy:d}}function tg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ng(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}),n}var jo={exports:{}},Ho={};const bc=ng(Su);var Lo={exports:{}},zo={};var Ji;function og(){if(Ji)return zo;Ji=1;var e=bc;function t(h,u){return h===u&&(h!==0||1/h===1/u)||h!==h&&u!==u}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function c(h,u){var p=u(),y=o({inst:{value:p,getSnapshot:u}}),_=y[0].inst,v=y[1];return i(function(){_.value=p,_.getSnapshot=u,d(_)&&v({inst:_})},[h,p,u]),r(function(){return d(_)&&v({inst:_}),h(function(){d(_)&&v({inst:_})})},[h]),s(p),p}function d(h){var u=h.getSnapshot;h=h.value;try{var p=u();return!n(h,p)}catch{return!0}}function l(h,u){return u()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:c;return zo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,zo}var es;function rg(){return es||(es=1,Lo.exports=og()),Lo.exports}var ts;function ig(){if(ts)return Ho;ts=1;var e=bc,t=rg();function n(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Ho.useSyncExternalStoreWithSelector=function(l,f,h,u,p){var y=i(null);if(y.current===null){var _={hasValue:!1,value:null};y.current=_}else _=y.current;y=c(function(){function m(k){if(!S){if(S=!0,g=k,k=u(k),p!==void 0&&_.hasValue){var E=_.value;if(p(E,k))return w=E}return w=k}if(E=w,o(g,k))return E;var T=u(k);return p!==void 0&&p(E,T)?(g=k,E):(g=k,w=T)}var S=!1,g,w,C=h===void 0?null:h;return[function(){return m(f())},C===null?void 0:function(){return m(C())}]},[f,h,u,p]);var v=r(l,y[0],y[1]);return s(function(){_.hasValue=!0,_.value=v},[v]),d(v),v},Ho}var ns;function sg(){return ns||(ns=1,jo.exports=ig()),jo.exports}var ag=sg();const cg=tg(ag),lg={},os=e=>{let t;const n=new Set,o=(f,h)=>{const u=typeof f=="function"?f(t):f;if(!Object.is(u,t)){const p=t;t=h??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(y=>y(t,p))}},r=()=>t,d={setState:o,getState:r,getInitialState:()=>l,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(lg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,d);return d},ug=e=>e?os(e):os,{useDebugValue:dg}=ga,{useSyncExternalStoreWithSelector:fg}=cg,hg=e=>e;function Sc(e,t=hg,n){const o=fg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return dg(o),o}const rs=(e,t)=>{const n=ug(e),o=(r,i=t)=>Sc(n,r,i);return Object.assign(o,n),o},pg=(e,t)=>e?rs(e,t):rs;function he(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const mo=Lt(null),gg=mo.Provider,kc=Be.error001("react");function le(e,t){const n=it(mo);if(n===null)throw new Error(kc);return Sc(n,e,t)}function de(){const e=it(mo);if(e===null)throw new Error(kc);return ye(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const is={display:"none"},mg={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ec="react-flow__node-desc",Cc="react-flow__edge-desc",yg="react-flow__aria-live",_g=e=>e.ariaLiveMessage,vg=e=>e.ariaLabelConfig;function wg({rfId:e}){const t=le(_g);return a("div",{id:`${yg}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mg,children:t})}function xg({rfId:e,disableKeyboardA11y:t}){const n=le(vg);return a(se,{children:[a("div",{id:`${Ec}-${e}`,style:is,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),a("div",{id:`${Cc}-${e}`,style:is,children:n["edge.a11yDescription.default"]}),!t&&a(wg,{rfId:e})]})}const yo=so(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return a("div",{className:ge(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});yo.displayName="Panel";const ss="https://reactflow.dev?utm_source=attribution";function bg({proOptions:e,position:t="bottom-right"}){return oe(()=>{},[]),e?.hideAttribution?null:a(yo,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${ss}`,children:a("a",{href:ss,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Sg=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Pn=e=>e.id;function kg(e,t){return he(e.selectedNodes.map(Pn),t.selectedNodes.map(Pn))&&he(e.selectedEdges.map(Pn),t.selectedEdges.map(Pn))}function Eg({onSelectionChange:e}){const t=de(),{selectedNodes:n,selectedEdges:o}=le(Sg,kg);return oe(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Cg=e=>!!e.onSelectionChangeHandlers;function Ng({onSelectionChange:e}){const t=le(Cg);return e||t?a(Eg,{onSelectionChange:e}):null}const Nc=[0,0],Ig={x:0,y:0,zoom:1},Mg=["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"],as=[...Mg,"rfId"],Ag=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}),cs={translateExtent:rn,nodeOrigin:Nc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function $g(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:c,setDefaultNodesAndEdges:d}=le(Ag,he),l=de();oe(()=>(d(e.defaultNodes,e.defaultEdges),()=>{f.current=cs,c()}),[]);const f=ne(cs);return oe(()=>{for(const h of as){const u=e[h],p=f.current[h];u!==p&&(typeof e[h]>"u"||(h==="nodes"?t(u):h==="edges"?n(u):h==="minZoom"?o(u):h==="maxZoom"?r(u):h==="translateExtent"?i(u):h==="nodeExtent"?s(u):h==="ariaLabelConfig"?l.setState({ariaLabelConfig:hp(u)}):h==="fitView"?l.setState({fitViewQueued:u}):h==="fitViewOptions"?l.setState({fitViewOptions:u}):l.setState({[h]:u})))}f.current=e},as.map(h=>e[h])),null}function ls(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Pg(e){const[t,n]=J(e==="system"?null:e);return oe(()=>{if(e!=="system"){n(e);return}const o=ls(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:ls()?.matches?"dark":"light"}const us=typeof document<"u"?document:null;function ln(e=null,t={target:us,actInsideInputWithModifier:!0}){const[n,o]=J(!1),r=ne(!1),i=ne(new Set([])),[s,c]=ye(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(h=>typeof h=="string").map(h=>h.replace(/\+/g,`
|
|
2
|
+
`).replace(`
|
|
3
|
+
|
|
4
|
+
`,`
|
|
5
|
+
+`).split(`
|
|
6
|
+
`)),f=l.reduce((h,u)=>h.concat(...u),[]);return[l,f]}return[[],[]]},[e]);return oe(()=>{const d=t?.target??us,l=t?.actInsideInputWithModifier??!0;if(e!==null){const f=p=>{if(r.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!r.current||r.current&&!l)&&ic(p))return!1;const _=fs(p.code,c);if(i.current.add(p[_]),ds(s,i.current,!1)){const v=p.composedPath?.()?.[0]||p.target,m=v?.nodeName==="BUTTON"||v?.nodeName==="A";t.preventDefault!==!1&&(r.current||!m)&&p.preventDefault(),o(!0)}},h=p=>{const y=fs(p.code,c);ds(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(p[y]),p.key==="Meta"&&i.current.clear(),r.current=!1},u=()=>{i.current.clear(),o(!1)};return d?.addEventListener("keydown",f),d?.addEventListener("keyup",h),window.addEventListener("blur",u),window.addEventListener("contextmenu",u),()=>{d?.removeEventListener("keydown",f),d?.removeEventListener("keyup",h),window.removeEventListener("blur",u),window.removeEventListener("contextmenu",u)}}},[e,o]),n}function ds(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function fs(e,t){return t.includes(e)?"code":"key"}const Tg=()=>{const e=de();return ye(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:c}=e.getState(),d=Lr(t,o,r,i,s,n?.padding??.1);return c?(await c.setViewport(d,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:c,y:d}=s.getBoundingClientRect(),l={x:t.x-c,y:t.y-d},f=n.snapGrid??r,h=n.snapToGrid??i;return _n(l,o,h,f)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=Rt(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function Ic(e,t){const n=[],o=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")o.set(i.id,[i]);else{const s=o.get(i.id);s?s.push(i):o.set(i.id,[i])}for(const i of t){const s=o.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const c={...i};for(const d of s)Dg(d,c);n.push(c)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Dg(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Mc(e,t){return Ic(e,t)}function Og(e,t){return Ic(e,t)}function ht(e,t){return{id:e,type:"select",selected:t}}function Nt(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const s=t.has(r);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),o.push(ht(i.id,s)))}return o}function hs({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,i]of e.entries()){const s=t.get(i.id),c=s?.internals?.userNode??s;c!==void 0&&c!==i&&n.push({id:i.id,item:i,type:"replace"}),c===void 0&&n.push({item:i,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function ps(e){return{id:e.id,type:"remove"}}const Rg=ec();function jg(e,t,n={}){return vp(e,t,{...n,onError:n.onError??Rg})}const gs=e=>rp(e),Hg=e=>qa(e);function Ac(e){return so(e)}const $c=typeof window<"u"?rt:oe;function ms(e){const[t,n]=J(BigInt(0)),[o]=J(()=>Lg(()=>n(r=>r+BigInt(1))));return $c(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Lg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Pc=Lt(null);function zg({children:e}){const t=de(),n=Me(c=>{const{nodes:d=[],setNodes:l,hasDefaultNodes:f,onNodesChange:h,nodeLookup:u,fitViewQueued:p,onNodesChangeMiddlewareMap:y}=t.getState();let _=d;for(const m of c)_=typeof m=="function"?m(_):m;let v=hs({items:_,lookup:u});for(const m of y.values())v=m(v);f&&l(_),v.length>0?h?.(v):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:S,setNodes:g}=t.getState();m&&g(S)})},[]),o=ms(n),r=Me(c=>{const{edges:d=[],setEdges:l,hasDefaultEdges:f,onEdgesChange:h,edgeLookup:u}=t.getState();let p=d;for(const y of c)p=typeof y=="function"?y(p):y;f?l(p):h&&h(hs({items:p,lookup:u}))},[]),i=ms(r),s=ye(()=>({nodeQueue:o,edgeQueue:i}),[]);return a(Pc.Provider,{value:s,children:e})}function Bg(){const e=it(Pc);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Vg=e=>!!e.panZoom;function Xr(){const e=Tg(),t=de(),n=Bg(),o=le(Vg),r=ye(()=>{const i=h=>t.getState().nodeLookup.get(h),s=h=>{n.nodeQueue.push(h)},c=h=>{n.edgeQueue.push(h)},d=h=>{const{nodeLookup:u,nodeOrigin:p}=t.getState(),y=gs(h)?h:u.get(h.id),_=y.parentId?nc(y.position,y.measured,y.parentId,u,p):y.position,v={...y,position:_,width:y.measured?.width??y.width,height:y.measured?.height??y.height};return an(v)},l=(h,u,p={replace:!1})=>{s(y=>y.map(_=>{if(_.id===h){const v=typeof u=="function"?u(_):u;return p.replace&&gs(v)?v:{..._,...v}}return _}))},f=(h,u,p={replace:!1})=>{c(y=>y.map(_=>{if(_.id===h){const v=typeof u=="function"?u(_):u;return p.replace&&Hg(v)?v:{..._,...v}}return _}))};return{getNodes:()=>t.getState().nodes.map(h=>({...h})),getNode:h=>i(h)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:h=[]}=t.getState();return h.map(u=>({...u}))},getEdge:h=>t.getState().edgeLookup.get(h),setNodes:s,setEdges:c,addNodes:h=>{const u=Array.isArray(h)?h:[h];n.nodeQueue.push(p=>[...p,...u])},addEdges:h=>{const u=Array.isArray(h)?h:[h];n.edgeQueue.push(p=>[...p,...u])},toObject:()=>{const{nodes:h=[],edges:u=[],transform:p}=t.getState(),[y,_,v]=p;return{nodes:h.map(m=>({...m})),edges:u.map(m=>({...m})),viewport:{x:y,y:_,zoom:v}}},deleteElements:async({nodes:h=[],edges:u=[]})=>{const{nodes:p,edges:y,onNodesDelete:_,onEdgesDelete:v,triggerNodeChanges:m,triggerEdgeChanges:S,onDelete:g,onBeforeDelete:w}=t.getState(),{nodes:C,edges:k}=await lp({nodesToRemove:h,edgesToRemove:u,nodes:p,edges:y,onBeforeDelete:w}),E=k.length>0,T=C.length>0;if(E){const D=k.map(ps);v?.(k),S(D)}if(T){const D=C.map(ps);_?.(C),m(D)}return(T||E)&&g?.({nodes:C,edges:k}),{deletedNodes:C,deletedEdges:k}},getIntersectingNodes:(h,u=!0,p)=>{const y=zi(h),_=y?h:d(h),v=p!==void 0;return _?(p||t.getState().nodes).filter(m=>{const S=t.getState().nodeLookup.get(m.id);if(S&&!y&&(m.id===h.id||!S.internals.positionAbsolute))return!1;const g=an(v?m:S),w=oo(g,_);return u&&w>0||w>=g.width*g.height||w>=_.width*_.height}):[]},isNodeIntersecting:(h,u,p=!0)=>{const _=zi(h)?h:d(h);if(!_)return!1;const v=oo(_,u);return p&&v>0||v>=u.width*u.height||v>=_.width*_.height},updateNode:l,updateNodeData:(h,u,p={replace:!1})=>{l(h,y=>{const _=typeof u=="function"?u(y):u;return p.replace?{...y,data:_}:{...y,data:{...y.data,..._}}},p)},updateEdge:f,updateEdgeData:(h,u,p={replace:!1})=>{f(h,y=>{const _=typeof u=="function"?u(y):u;return p.replace?{...y,data:_}:{...y,data:{...y.data,..._}}},p)},getNodesBounds:h=>{const{nodeLookup:u,nodeOrigin:p}=t.getState();return ip(h,{nodeLookup:u,nodeOrigin:p})},getHandleConnections:({type:h,id:u,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}-${h}${u?`-${u}`:""}`)?.values()??[]),getNodeConnections:({type:h,handleId:u,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}${h?u?`-${h}-${u}`:`-${h}`:""}`)?.values()??[]),fitView:async h=>{const u=t.getState().fitViewResolver??fp();return t.setState({fitViewQueued:!0,fitViewOptions:h,fitViewResolver:u}),n.nodeQueue.push(p=>[...p]),u.promise}}},[]);return ye(()=>({...r,...e,viewportInitialized:o}),[o])}const ys=e=>e.selected,Fg=typeof window<"u"?window:void 0;function Wg({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=de(),{deleteElements:o}=Xr(),r=ln(e,{actInsideInputWithModifier:!1}),i=ln(t,{target:Fg});oe(()=>{if(r){const{edges:s,nodes:c}=n.getState();o({nodes:c.filter(ys),edges:s.filter(ys)}),n.setState({nodesSelectionActive:!1})}},[r]),oe(()=>{n.setState({multiSelectionActive:i})},[i])}function Ug(e){const t=de();oe(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=zr(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",Be.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const _o={position:"absolute",width:"100%",height:"100%",top:0,left:0},Xg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Yg({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panActivationKeyPressed:r,panOnScrollSpeed:i=.5,panOnScrollMode:s=mt.Free,zoomOnDoubleClick:c=!0,panOnDrag:d=!0,defaultViewport:l,translateExtent:f,minZoom:h,maxZoom:u,zoomActivationKeyCode:p,preventScrolling:y=!0,children:_,noWheelClassName:v,noPanClassName:m,onViewportChange:S,isControlledViewport:g,paneClickDistance:w,selectionOnDrag:C}){const k=de(),E=ne(null),{userSelectionActive:T,lib:D,connectionInProgress:L}=le(Xg,he),O=ln(p),B=ne();Ug(E);const N=Me(b=>{S?.({x:b[0],y:b[1],zoom:b[2]}),g||k.setState({transform:b})},[S,g]);return oe(()=>{if(E.current){B.current=qp({domNode:E.current,minZoom:h,maxZoom:u,translateExtent:f,viewport:l,onDraggingChange:P=>k.setState(A=>A.paneDragging===P?A:{paneDragging:P}),onPanZoomStart:(P,A)=>{const{onViewportChangeStart:$,onMoveStart:j}=k.getState();j?.(P,A),$?.(A)},onPanZoom:(P,A)=>{const{onViewportChange:$,onMove:j}=k.getState();j?.(P,A),$?.(A)},onPanZoomEnd:(P,A)=>{const{onViewportChangeEnd:$,onMoveEnd:j}=k.getState();j?.(P,A),$?.(A)}});const{x:b,y:I,zoom:M}=B.current.getViewport();return k.setState({panZoom:B.current,transform:[b,I,M],domNode:E.current.closest(".react-flow")}),()=>{B.current?.destroy()}}},[]),oe(()=>{B.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panActivationKeyPressed:r,panOnScrollSpeed:i,panOnScrollMode:s,zoomOnDoubleClick:c,panOnDrag:d,zoomActivationKeyPressed:O,preventScrolling:y,noPanClassName:m,userSelectionActive:T,noWheelClassName:v,lib:D,onTransformChange:N,connectionInProgress:L,selectionOnDrag:C,paneClickDistance:w})},[e,t,n,o,r,i,s,c,d,O,y,m,T,v,D,N,L,C,w]),a("div",{className:"react-flow__renderer",ref:E,style:_o,children:_})}const Zg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function qg(){const{userSelectionActive:e,userSelectionRect:t}=le(Zg,he);return e&&t?a("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Bo=(e,t)=>n=>{n.target===t.current&&e?.(n)},Gg=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Kg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=sn.Full,panOnDrag:o,autoPanOnSelection:r,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:c,onSelectionEnd:d,onPaneClick:l,onPaneContextMenu:f,onPaneScroll:h,onPaneMouseEnter:u,onPaneMouseMove:p,onPaneMouseLeave:y,children:_}){const v=ne(0),m=de(),{userSelectionActive:S,elementsSelectable:g,dragging:w,panBy:C,autoPanSpeed:k}=le(Gg,he),E=g&&(e||S),T=ne(null),D=ne(),L=ne(new Set),O=ne(new Set),B=ne(!1),N=ne(!1),b=ne({x:0,y:0}),I=ne(!1),M=H=>{if(N.current||B.current||m.getState().connection.inProgress){N.current=!1,B.current=!1;return}l?.(H),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},P=H=>{if(Array.isArray(o)&&o?.includes(2)){H.preventDefault();return}f?.(H)},A=h?H=>h(H):void 0,$=H=>{N.current&&(H.stopPropagation(),N.current=!1)},j=H=>{if(H.pointerType==="touch"&&o!==!1&&!t)return;const{domNode:W,transform:Q}=m.getState();if(D.current=W?.getBoundingClientRect(),!D.current)return;const Y=H.target===T.current;if(!Y&&!!H.target.closest(".nokey")||!e||!(s&&Y||t)||H.button!==0||!H.isPrimary)return;H.target?.setPointerCapture?.(H.pointerId),N.current=!1;const{x:re,y:ie}=Le(H.nativeEvent,D.current),ce=_n({x:re,y:ie},Q);m.setState({userSelectionRect:{width:0,height:0,startX:ce.x,startY:ce.y,x:re,y:ie}}),Y||(H.stopPropagation(),H.preventDefault())};function z(H,W){const{userSelectionRect:Q}=m.getState();if(!Q)return;const{transform:Y,nodeLookup:U,edgeLookup:K,connectionLookup:re,triggerNodeChanges:ie,triggerEdgeChanges:ce,defaultEdgeOptions:me}=m.getState(),$e={x:Q.startX,y:Q.startY},{x:ve,y:Ee}=Rt($e,Y),we={startX:$e.x,startY:$e.y,x:H<ve?H:ve,y:W<Ee?W:Ee,width:Math.abs(H-ve),height:Math.abs(W-Ee)},We=L.current,xe=O.current;L.current=new Set(jr(U,we,Y,n===sn.Partial,!0).map(Ce=>Ce.id)),O.current=new Set;const _e=me?.selectable??!0;for(const Ce of L.current){const Pe=re.get(Ce);if(Pe)for(const{edgeId:De}of Pe.values()){const Oe=K.get(De);Oe&&(Oe.selectable??_e)&&O.current.add(De)}}if(!Bi(We,L.current)){const Ce=Nt(U,L.current,!0);ie(Ce)}if(!Bi(xe,O.current)){const Ce=Nt(K,O.current);ce(Ce)}m.setState({userSelectionRect:we,userSelectionActive:!0,nodesSelectionActive:!1})}function V(){if(!r||!D.current)return;const[H,W]=Hr(b.current,D.current,k);C({x:H,y:W}).then(Q=>{if(!N.current||!Q){v.current=requestAnimationFrame(V);return}const{x:Y,y:U}=b.current;z(Y,U),v.current=requestAnimationFrame(V)})}const Z=()=>{cancelAnimationFrame(v.current),v.current=0,I.current=!1};oe(()=>()=>Z(),[]);const F=H=>{const{userSelectionRect:W,transform:Q,resetSelectedElements:Y}=m.getState();if(!D.current||!W)return;const{x:U,y:K}=Le(H.nativeEvent,D.current);b.current={x:U,y:K};const re=Rt({x:W.startX,y:W.startY},Q);if(!N.current){const ie=t?0:i;if(Math.hypot(U-re.x,K-re.y)<=ie)return;Y(),c?.(H)}N.current=!0,I.current||(V(),I.current=!0),z(U,K)},G=H=>{if(!E){H.target===T.current&&m.getState().connection.inProgress&&(B.current=!0);return}H.button===0&&(H.target?.releasePointerCapture?.(H.pointerId),!S&&H.target===T.current&&m.getState().userSelectionRect&&M?.(H),m.setState({userSelectionActive:!1,userSelectionRect:null}),N.current&&(d?.(H),m.setState({nodesSelectionActive:L.current.size>0})),Z())},ee=H=>{H.target?.releasePointerCapture?.(H.pointerId),Z()},X=o===!0||Array.isArray(o)&&o.includes(0);return a("div",{className:ge(["react-flow__pane",{draggable:X,dragging:w,selection:e}]),onClick:E?void 0:Bo(M,T),onContextMenu:Bo(P,T),onWheel:Bo(A,T),onPointerEnter:E?void 0:u,onPointerMove:E?F:p,onPointerUp:G,onPointerCancel:E?ee:void 0,onPointerDownCapture:E?j:void 0,onClickCapture:E?$:void 0,onPointerLeave:y,ref:T,style:_o,children:[_,a(qg,{})]})}function ur({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:c,onError:d}=t.getState(),l=c.get(e);if(!l){d?.("012",Be.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&s)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Tc({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const c=de(),[d,l]=J(!1),f=ne();return oe(()=>{if(!t)return f.current=Op({getStoreItems:()=>c.getState(),onNodeMouseDown:h=>{ur({id:h,store:c,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{f.current?.destroy(),f.current=void 0}},[t,c,e]),oe(()=>{t||!e.current||!f.current||f.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s})},[n,o,t,i,e,r,s]),d}const Qg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Dc(){const e=de();return Me(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:c,updateNodePositions:d,nodeLookup:l,nodeOrigin:f}=e.getState(),h=new Map,u=Qg(s),p=r?i[0]:5,y=r?i[1]:5,_=n.direction.x*p*n.factor,v=n.direction.y*y*n.factor;for(const[,m]of l){if(!u(m))continue;let S={x:m.internals.positionAbsolute.x+_,y:m.internals.positionAbsolute.y+v};r&&(S=yn(S,i));const{position:g,positionAbsolute:w}=Ga({nodeId:m.id,nextPosition:S,nodeLookup:l,nodeExtent:o,nodeOrigin:f,onError:c});m.position=g,m.internals.positionAbsolute=w,h.set(m.id,m)}d(h)},[])}const Yr=Lt(null),Jg=Yr.Provider;Yr.Consumer;const Oc=()=>it(Yr),em=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Rc=Lt(null);function tm({children:e}){const t=le(em,he);return a(Rc.Provider,{value:t,children:e})}function nm(){const e=it(Rc);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const om={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},rm=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:c,toHandle:d,isValid:l}=s;if(!c&&!r)return om;const f=d?.nodeId===e&&d?.id===t&&d?.type===n;return{connectingFrom:c?.nodeId===e&&c?.id===t&&c?.type===n,connectingTo:f,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:i===Dt.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!r,valid:f&&l}};function im({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:c,children:d,className:l,onMouseDown:f,onTouchStart:h,...u},p){const y=s||null,_=e==="target",v=de(),m=Oc(),{connectOnClick:S,noPanClassName:g,rfId:w}=nm(),{connectingFrom:C,connectingTo:k,clickConnecting:E,isPossibleEndHandle:T,connectionInProcess:D,clickConnectionInProcess:L,valid:O}=le(rm(m,y,e),he);m||v.getState().onError?.("010",Be.error010());const B=I=>{const{defaultEdgeOptions:M,onConnect:P,hasDefaultEdges:A}=v.getState(),$={...M,...I};if(A){const{edges:j,setEdges:z,onError:V}=v.getState();z(jg($,j,{onError:V}))}P?.($),c?.($)},N=I=>{if(!m)return;const M=sc(I.nativeEvent);if(r&&(M&&I.button===0||!M)){const P=v.getState();lr.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:P.autoPanOnConnect,connectionMode:P.connectionMode,connectionRadius:P.connectionRadius,domNode:P.domNode,nodeLookup:P.nodeLookup,lib:P.lib,isTarget:_,handleId:y,nodeId:m,flowId:P.rfId,panBy:P.panBy,cancelConnection:P.cancelConnection,onConnectStart:P.onConnectStart,onConnectEnd:(...A)=>v.getState().onConnectEnd?.(...A),updateConnection:P.updateConnection,onConnect:B,isValidConnection:n||((...A)=>v.getState().isValidConnection?.(...A)??!0),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:P.autoPanSpeed,dragThreshold:P.connectionDragThreshold})}M?f?.(I):h?.(I)},b=I=>{const{onClickConnectStart:M,onClickConnectEnd:P,connectionClickStartHandle:A,connectionMode:$,isValidConnection:j,lib:z,rfId:V,nodeLookup:Z,connection:F}=v.getState();if(!m||!A&&!r)return;if(!A){M?.(I.nativeEvent,{nodeId:m,handleId:y,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:m,type:e,id:y}});return}const G=rc(I.target),ee=n||j,{connection:X,isValid:H}=lr.isValid(I.nativeEvent,{handle:{nodeId:m,id:y,type:e},connectionMode:$,fromNodeId:A.nodeId,fromHandleId:A.id||null,fromType:A.type,isValidConnection:ee,flowId:V,doc:G,lib:z,nodeLookup:Z});H&&X&&B(X);const W=structuredClone(F);delete W.inProgress,W.toPosition=W.toHandle?W.toHandle.position:null,P?.(I,W),v.setState({connectionClickStartHandle:null})};return a("div",{"data-handleid":y,"data-nodeid":m,"data-handlepos":t,"data-id":`${w}-${m}-${y}-${e}`,className:ge(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,l,{source:!_,target:_,connectable:o,connectablestart:r,connectableend:i,clickconnecting:E,connectingfrom:C,connectingto:k,valid:O,connectionindicator:o&&(!D||T)&&(D||L?i:r)}]),onMouseDown:N,onTouchStart:N,onClick:S?b:void 0,ref:p,...u,children:d})}const Ht=pe(Ac(im));function sm({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return a(se,{children:[e?.label,a(Ht,{type:"source",position:n,isConnectable:t})]})}function am({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:o=q.Bottom}){return a(se,{children:[a(Ht,{type:"target",position:n,isConnectable:t}),e?.label,a(Ht,{type:"source",position:o,isConnectable:t})]})}function cm(){return null}function lm({data:e,isConnectable:t,targetPosition:n=q.Top}){return a(se,{children:[a(Ht,{type:"target",position:n,isConnectable:t}),e?.label]})}const ro={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},_s={input:sm,default:am,output:lm,group:cm};function um(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const dm=e=>{const{width:t,height:n,x:o,y:r}=mn(e.nodeLookup,{filter:i=>!!i.selected});return{width:He(t)?t:null,height:He(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function fm({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=de(),{width:r,height:i,transformString:s,userSelectionActive:c}=le(dm,he),d=Dc(),l=ne(null);oe(()=>{n||l.current?.focus({preventScroll:!0})},[n]);const f=!c&&r!==null&&i!==null;if(Tc({nodeRef:l,disabled:!f}),!f)return null;const h=e?p=>{const y=o.getState().nodes.filter(_=>_.selected);e(p,y)}:void 0,u=p=>{Object.prototype.hasOwnProperty.call(ro,p.key)&&(p.preventDefault(),d({direction:ro[p.key],factor:p.shiftKey?4:1}))};return a("div",{className:ge(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:a("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:u,style:{width:r,height:i}})})}const vs=typeof window<"u"?window:void 0,hm=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function jc({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:c,deleteKeyCode:d,selectionKeyCode:l,selectionOnDrag:f,selectionMode:h,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:y,panActivationKeyCode:_,zoomActivationKeyCode:v,elementsSelectable:m,zoomOnScroll:S,zoomOnPinch:g,panOnScroll:w,panOnScrollSpeed:C,panOnScrollMode:k,zoomOnDoubleClick:E,panOnDrag:T,autoPanOnSelection:D,defaultViewport:L,translateExtent:O,minZoom:B,maxZoom:N,preventScrolling:b,onSelectionContextMenu:I,noWheelClassName:M,noPanClassName:P,disableKeyboardA11y:A,onViewportChange:$,isControlledViewport:j}){const{nodesSelectionActive:z,userSelectionActive:V}=le(hm,he),Z=ln(l,{target:vs}),F=ln(_,{target:vs}),G=F||T,ee=F||w,X=f&&G!==!0,H=Z||V||X;return Wg({deleteKeyCode:d,multiSelectionKeyCode:y}),a(Yg,{onPaneContextMenu:i,elementsSelectable:m,zoomOnScroll:S,zoomOnPinch:g,panOnScroll:ee,panActivationKeyPressed:F,panOnScrollSpeed:C,panOnScrollMode:k,zoomOnDoubleClick:E,panOnDrag:!Z&&G,defaultViewport:L,translateExtent:O,minZoom:B,maxZoom:N,zoomActivationKeyCode:v,preventScrolling:b,noWheelClassName:M,noPanClassName:P,onViewportChange:$,isControlledViewport:j,paneClickDistance:c,selectionOnDrag:X,children:a(Kg,{onSelectionStart:u,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:G,autoPanOnSelection:D,isSelecting:!!H,selectionMode:h,selectionKeyPressed:Z,paneClickDistance:c,selectionOnDrag:X,children:[e,z&&a(fm,{onSelectionContextMenu:I,noPanClassName:P,disableKeyboardA11y:A})]})})}jc.displayName="FlowRenderer";const pm=pe(jc),gm=e=>t=>e?jr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function mm(e){return le(Me(gm(e),[e]),he)}const ym=e=>e.updateNodeInternals;function _m(){const e=le(ym),[t]=J(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const i=r.target.getAttribute("data-id");o.set(i,{id:i,nodeElement:r.target,force:!0})}),e(o)}));return oe(()=>()=>{t?.disconnect()},[t]),t}function vm({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=de(),i=ne(null),s=ne(null),c=ne(e.sourcePosition),d=ne(e.targetPosition),l=ne(t),f=n&&!!e.internals.handleBounds;return oe(()=>{i.current&&!e.hidden&&(!f||s.current!==i.current)&&(s.current&&o?.unobserve(s.current),o?.observe(i.current),s.current=i.current)},[f,e.hidden]),oe(()=>()=>{s.current&&(o?.unobserve(s.current),s.current=null)},[]),oe(()=>{if(i.current){const h=l.current!==t,u=c.current!==e.sourcePosition,p=d.current!==e.targetPosition;(h||u||p)&&(l.current=t,c.current=e.sourcePosition,d.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function wm({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:c,elementsSelectable:d,nodesConnectable:l,nodesFocusable:f,resizeObserver:h,noDragClassName:u,noPanClassName:p,disableKeyboardA11y:y,rfId:_,nodeTypes:v,nodeClickDistance:m,onError:S}){const{node:g,internals:w,isParent:C}=le(H=>{const W=H.nodeLookup.get(e),Q=H.parentLookup.has(e);return{node:W,internals:W.internals,isParent:Q}},he);let k=g.type||"default",E=v?.[k]||_s[k];E===void 0&&(S?.("003",Be.error003(k)),k="default",E=v?.default||_s.default);const T=!!(g.draggable||c&&typeof g.draggable>"u"),D=!!(g.selectable||d&&typeof g.selectable>"u"),L=!!(g.connectable||l&&typeof g.connectable>"u"),O=!!(g.focusable||f&&typeof g.focusable>"u"),B=de(),N=tc(g),b=vm({node:g,nodeType:k,hasDimensions:N,resizeObserver:h}),I=Tc({nodeRef:b,disabled:g.hidden||!T,noDragClassName:u,handleSelector:g.dragHandle,nodeId:e,isSelectable:D,nodeClickDistance:m}),M=Dc();if(g.hidden)return null;const P=Fe(g),A=um(g),$=D||T||t||n||o||r,j=n?H=>n(H,{...w.userNode}):void 0,z=o?H=>o(H,{...w.userNode}):void 0,V=r?H=>r(H,{...w.userNode}):void 0,Z=i?H=>i(H,{...w.userNode}):void 0,F=s?H=>s(H,{...w.userNode}):void 0,G=H=>{const{selectNodesOnDrag:W,nodeDragThreshold:Q}=B.getState();D&&(!W||!T||Q>0)&&ur({id:e,store:B,nodeRef:b}),t&&t(H,{...w.userNode})},ee=H=>{if(!(ic(H.nativeEvent)||y)){if(Xa.includes(H.key)&&D){const W=H.key==="Escape";ur({id:e,store:B,unselect:W,nodeRef:b})}else if(T&&g.selected&&Object.prototype.hasOwnProperty.call(ro,H.key)){H.preventDefault();const{ariaLabelConfig:W}=B.getState();B.setState({ariaLiveMessage:W["node.a11yDescription.ariaLiveMessage"]({direction:H.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),M({direction:ro[H.key],factor:H.shiftKey?4:1})}}},X=()=>{if(y||!b.current?.matches(":focus-visible"))return;const{transform:H,width:W,height:Q,autoPanOnNodeFocus:Y,setCenter:U}=B.getState();if(!Y)return;jr(new Map([[e,g]]),{x:0,y:0,width:W,height:Q},H,!0).length>0||U(g.position.x+P.width/2,g.position.y+P.height/2,{zoom:H[2]})};return a("div",{className:ge(["react-flow__node",`react-flow__node-${k}`,{[p]:T},g.className,{selected:g.selected,selectable:D,parent:C,draggable:T,dragging:I}]),ref:b,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:$?"all":"none",visibility:N?"visible":"hidden",...g.style,...A},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:j,onMouseMove:z,onMouseLeave:V,onContextMenu:Z,onClick:G,onDoubleClick:F,onKeyDown:O?ee:void 0,tabIndex:O?0:void 0,onFocus:O?X:void 0,role:g.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${Ec}-${_}`,"aria-label":g.ariaLabel,...g.domAttributes,children:a(Jg,{value:e,children:a(E,{id:e,data:g.data,type:k,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:g.selected??!1,selectable:D,draggable:T,deletable:g.deletable??!0,isConnectable:L,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:I,dragHandle:g.dragHandle,zIndex:w.z,parentId:g.parentId,...P})})})}var xm=pe(wm);const bm=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Hc(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,onError:r}=le(bm,he),i=mm(e.onlyRenderVisibleElements),s=_m();return a("div",{className:"react-flow__nodes",style:_o,children:i.map(c=>a(xm,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:r},c))})}Hc.displayName="NodeRenderer";const Sm=pe(Hc);function km(e){return le(Me(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);i&&s&&mp({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),he)}const Em=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return a("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Cm=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return a("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ws={[to.Arrow]:Em,[to.ArrowClosed]:Cm};function Nm(e){const t=de();return ye(()=>Object.prototype.hasOwnProperty.call(ws,e)?ws[e]:(t.getState().onError?.("009",Be.error009(e)),null),[e])}const Im=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:c="auto-start-reverse"})=>{const d=Nm(t);return d?a("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:c,refX:"0",refY:"0",children:a(d,{color:n,strokeWidth:s})}):null},Lc=({defaultColor:e,rfId:t})=>{const n=le(i=>i.edges),o=le(i=>i.defaultEdgeOptions),r=ye(()=>kp(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?a("svg",{className:"react-flow__marker","aria-hidden":"true",children:a("defs",{children:r.map(i=>a(Im,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Lc.displayName="MarkerDefinitions";var Mm=pe(Lc);function zc({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:c=2,children:d,className:l,...f}){const[h,u]=J({x:1,y:0,width:0,height:0}),p=ge(["react-flow__edge-textwrapper",l]),y=ne(null);return oe(()=>{if(y.current){const _=y.current.getBBox();u({x:_.x,y:_.y,width:_.width,height:_.height})}},[n]),n?a("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:p,visibility:h.width?"visible":"hidden",...f,children:[r&&a("rect",{width:h.width+2*s[0],x:-s[0],y:-s[1],height:h.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:c,ry:c}),a("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:y,style:o,children:n}),d]}):null}zc.displayName="EdgeText";const Am=pe(zc);function vo({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:d,interactionWidth:l=20,...f}){return a(se,{children:[a("path",{...f,d:e,fill:"none",className:ge(["react-flow__edge-path",f.className])}),l?a("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&He(t)&&He(n)?a(Am,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:d}):null]})}function xs({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===q.Left||e===q.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function Bc({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:o,targetY:r,targetPosition:i=q.Top}){const[s,c]=xs({pos:n,x1:e,y1:t,x2:o,y2:r}),[d,l]=xs({pos:i,x1:o,y1:r,x2:e,y2:t}),[f,h,u,p]=ac({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:c,targetControlX:d,targetControlY:l});return[`M${e},${t} C${s},${c} ${d},${l} ${o},${r}`,f,h,u,p]}function Vc(e){return pe(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:c,label:d,labelStyle:l,labelShowBg:f,labelBgStyle:h,labelBgPadding:u,labelBgBorderRadius:p,style:y,markerEnd:_,markerStart:v,interactionWidth:m})=>{const[S,g,w]=Bc({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:c}),C=e.isInternal?void 0:t;return a(vo,{id:C,path:S,labelX:g,labelY:w,label:d,labelStyle:l,labelShowBg:f,labelBgStyle:h,labelBgPadding:u,labelBgBorderRadius:p,style:y,markerEnd:_,markerStart:v,interactionWidth:m})})}const $m=Vc({isInternal:!1}),Fc=Vc({isInternal:!0});$m.displayName="SimpleBezierEdge";Fc.displayName="SimpleBezierEdgeInternal";function Wc(e){return pe(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:c,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:u,sourcePosition:p=q.Bottom,targetPosition:y=q.Top,markerEnd:_,markerStart:v,pathOptions:m,interactionWidth:S})=>{const[g,w,C]=sr({sourceX:n,sourceY:o,sourcePosition:p,targetX:r,targetY:i,targetPosition:y,borderRadius:m?.borderRadius,offset:m?.offset,stepPosition:m?.stepPosition}),k=e.isInternal?void 0:t;return a(vo,{id:k,path:g,labelX:w,labelY:C,label:s,labelStyle:c,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:u,markerEnd:_,markerStart:v,interactionWidth:S})})}const Uc=Wc({isInternal:!1}),Xc=Wc({isInternal:!0});Uc.displayName="SmoothStepEdge";Xc.displayName="SmoothStepEdgeInternal";function Yc(e){return pe(({id:t,...n})=>{const o=e.isInternal?void 0:t;return a(Uc,{...n,id:o,pathOptions:ye(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Pm=Yc({isInternal:!1}),Zc=Yc({isInternal:!0});Pm.displayName="StepEdge";Zc.displayName="StepEdgeInternal";function qc(e){return pe(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:c,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:u,markerEnd:p,markerStart:y,interactionWidth:_})=>{const[v,m,S]=uc({sourceX:n,sourceY:o,targetX:r,targetY:i}),g=e.isInternal?void 0:t;return a(vo,{id:g,path:v,labelX:m,labelY:S,label:s,labelStyle:c,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:u,markerEnd:p,markerStart:y,interactionWidth:_})})}const Tm=qc({isInternal:!1}),Gc=qc({isInternal:!0});Tm.displayName="StraightEdge";Gc.displayName="StraightEdgeInternal";function Kc(e){return pe(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=q.Bottom,targetPosition:c=q.Top,label:d,labelStyle:l,labelShowBg:f,labelBgStyle:h,labelBgPadding:u,labelBgBorderRadius:p,style:y,markerEnd:_,markerStart:v,pathOptions:m,interactionWidth:S})=>{const[g,w,C]=cc({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:c,curvature:m?.curvature}),k=e.isInternal?void 0:t;return a(vo,{id:k,path:g,labelX:w,labelY:C,label:d,labelStyle:l,labelShowBg:f,labelBgStyle:h,labelBgPadding:u,labelBgBorderRadius:p,style:y,markerEnd:_,markerStart:v,interactionWidth:S})})}const Dm=Kc({isInternal:!1}),Qc=Kc({isInternal:!0});Dm.displayName="BezierEdge";Qc.displayName="BezierEdgeInternal";const bs={default:Qc,straight:Gc,step:Zc,smoothstep:Xc,simplebezier:Fc},Ss={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Om=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,Rm=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,ks="react-flow__edgeupdater";function Es({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:c}){return a("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:ge([ks,`${ks}-${c}`]),cx:Om(t,o,e),cy:Rm(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function jm({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:c,targetPosition:d,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,setReconnecting:u,setUpdateHover:p}){const y=de(),_=(w,C)=>{if(w.button!==0)return;const{autoPanOnConnect:k,domNode:E,connectionMode:T,connectionRadius:D,lib:L,onConnectStart:O,cancelConnection:B,nodeLookup:N,rfId:b,panBy:I,updateConnection:M}=y.getState(),P=C.type==="target",A=(z,V)=>{u(!1),h?.(z,n,C.type,V)},$=z=>l?.(n,z),j=(z,V)=>{u(!0),f?.(w,n,C.type),O?.(z,V)};lr.onPointerDown(w.nativeEvent,{autoPanOnConnect:k,connectionMode:T,connectionRadius:D,domNode:E,handleId:C.id,nodeId:C.nodeId,nodeLookup:N,isTarget:P,edgeUpdaterType:C.type,lib:L,flowId:b,cancelConnection:B,panBy:I,isValidConnection:(...z)=>y.getState().isValidConnection?.(...z)??!0,onConnect:$,onConnectStart:j,onConnectEnd:(...z)=>y.getState().onConnectEnd?.(...z),onReconnectEnd:A,updateConnection:M,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},v=w=>_(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=w=>_(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),S=()=>p(!0),g=()=>p(!1);return a(se,{children:[(e===!0||e==="source")&&a(Es,{position:c,centerX:o,centerY:r,radius:t,onMouseDown:v,onMouseEnter:S,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&a(Es,{position:d,centerX:i,centerY:s,radius:t,onMouseDown:m,onMouseEnter:S,onMouseOut:g,type:"target"})]})}function Hm({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:c,onMouseMove:d,onMouseLeave:l,reconnectRadius:f,onReconnect:h,onReconnectStart:u,onReconnectEnd:p,rfId:y,edgeTypes:_,noPanClassName:v,onError:m,disableKeyboardA11y:S}){let g=le(U=>U.edgeLookup.get(e));const w=le(U=>U.defaultEdgeOptions);g=w?{...w,...g}:g;let C=g.type||"default",k=_?.[C]||bs[C];k===void 0&&(m?.("011",Be.error011(C)),C="default",k=_?.default||bs.default);const E=!!(g.focusable||t&&typeof g.focusable>"u"),T=typeof h<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),D=!!(g.selectable||o&&typeof g.selectable>"u"),L=ne(null),[O,B]=J(!1),[N,b]=J(!1),I=de(),{zIndex:M=g.zIndex,sourceX:P,sourceY:A,targetX:$,targetY:j,sourcePosition:z,targetPosition:V}=le(Me(U=>{const K=U.nodeLookup.get(g.source),re=U.nodeLookup.get(g.target);if(!K||!re)return Ss;const ie=Sp({id:e,sourceNode:K,targetNode:re,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:U.connectionMode,onError:m}),ce=gp({selected:g.selected,zIndex:g.zIndex,sourceNode:K,targetNode:re,elevateOnSelect:U.elevateEdgesOnSelect,zIndexMode:U.zIndexMode});return{...ie||Ss,zIndex:ce}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex,m]),he),Z=ye(()=>g.markerStart?`url('#${ar(g.markerStart,y)}')`:void 0,[g.markerStart,y]),F=ye(()=>g.markerEnd?`url('#${ar(g.markerEnd,y)}')`:void 0,[g.markerEnd,y]);if(g.hidden||P===null||A===null||$===null||j===null)return null;const G=U=>{const{addSelectedEdges:K,unselectNodesAndEdges:re,multiSelectionActive:ie}=I.getState();D&&(I.setState({nodesSelectionActive:!1}),g.selected&&ie?(re({nodes:[],edges:[g]}),L.current?.blur()):K([e])),r&&r(U,g)},ee=i?U=>{i(U,{...g})}:void 0,X=s?U=>{s(U,{...g})}:void 0,H=c?U=>{c(U,{...g})}:void 0,W=d?U=>{d(U,{...g})}:void 0,Q=l?U=>{l(U,{...g})}:void 0,Y=U=>{if(!S&&Xa.includes(U.key)&&D){const{unselectNodesAndEdges:K,addSelectedEdges:re}=I.getState();U.key==="Escape"?(L.current?.blur(),K({edges:[g]})):re([e])}};return a("svg",{style:{zIndex:M},children:a("g",{className:ge(["react-flow__edge",`react-flow__edge-${C}`,g.className,v,{selected:g.selected,animated:g.animated,inactive:!D&&!r,updating:O,selectable:D}]),onClick:G,onDoubleClick:ee,onContextMenu:X,onMouseEnter:H,onMouseMove:W,onMouseLeave:Q,onKeyDown:E?Y:void 0,tabIndex:E?0:void 0,role:g.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":E?`${Cc}-${y}`:void 0,ref:L,...g.domAttributes,children:[!N&&a(k,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:D,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:P,sourceY:A,targetX:$,targetY:j,sourcePosition:z,targetPosition:V,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:Z,markerEnd:F,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),T&&a(jm,{edge:g,isReconnectable:T,reconnectRadius:f,onReconnect:h,onReconnectStart:u,onReconnectEnd:p,sourceX:P,sourceY:A,targetX:$,targetY:j,sourcePosition:z,targetPosition:V,setUpdateHover:B,setReconnecting:b})]})})}var Lm=pe(Hm);const zm=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Jc({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:l,onEdgeClick:f,reconnectRadius:h,onEdgeDoubleClick:u,onReconnectStart:p,onReconnectEnd:y,disableKeyboardA11y:_}){const{edgesFocusable:v,edgesReconnectable:m,elementsSelectable:S,onError:g}=le(zm,he),w=km(t);return a("div",{className:"react-flow__edges",children:[a(Mm,{defaultColor:e,rfId:n}),w.map(C=>a(Lm,{id:C,edgesFocusable:v,edgesReconnectable:m,elementsSelectable:S,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:c,onMouseMove:d,onMouseLeave:l,onClick:f,reconnectRadius:h,onDoubleClick:u,onReconnectStart:p,onReconnectEnd:y,rfId:n,onError:g,edgeTypes:o,disableKeyboardA11y:_},C))]})}Jc.displayName="EdgeRenderer";const Bm=pe(Jc),Cs=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Vm({children:e}){const t=de(),n=ne(null),[o]=J(()=>t.getState().transform);return $c(()=>{let r=null;const i=()=>{const s=t.getState().transform;r&&s[0]===r[0]&&s[1]===r[1]&&s[2]===r[2]||(r=s,n.current&&(n.current.style.transform=Cs(s)))};return i(),t.subscribe(i)},[t]),a("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Cs(o)},children:e})}function Fm(e){const t=Xr(),n=ne(!1);oe(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Wm=e=>e.panZoom?.syncViewport;function Um(e){const t=le(Wm),n=de();return oe(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Xm(e){return e.connection.inProgress?{...e.connection,to:_n(e.connection.to,e.transform)}:{...e.connection}}function Ym(e){return Xm}function Zm(e){const t=Ym();return le(t,he)}const qm=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Gm({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:c,inProgress:d}=le(qm,he);return!(i&&r&&d)?null:a("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:a("g",{className:ge(["react-flow__connection",oc(c)]),children:a(el,{style:t,type:n,CustomComponent:o,isValid:c})})})}const el=({style:e,type:t=dt.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:c,fromPosition:d,to:l,toNode:f,toHandle:h,toPosition:u,pointer:p}=Zm();if(!r)return;if(n)return a(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:c,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:d,toPosition:u,connectionStatus:oc(o),toNode:f,toHandle:h,pointer:p});let y="";const _={sourceX:i.x,sourceY:i.y,sourcePosition:d,targetX:l.x,targetY:l.y,targetPosition:u};switch(t){case dt.Bezier:[y]=cc(_);break;case dt.SimpleBezier:[y]=Bc(_);break;case dt.Step:[y]=sr({..._,borderRadius:0});break;case dt.SmoothStep:[y]=sr(_);break;default:[y]=uc(_)}return a("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};el.displayName="ConnectionLine";const Km={};function Ns(e=Km){ne(e),de(),oe(()=>{},[e])}function Qm(){de(),ne(!1),oe(()=>{},[])}function tl({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:l,onNodeContextMenu:f,onSelectionContextMenu:h,onSelectionStart:u,onSelectionEnd:p,connectionLineType:y,connectionLineStyle:_,connectionLineComponent:v,connectionLineContainerStyle:m,selectionKeyCode:S,selectionOnDrag:g,selectionMode:w,multiSelectionKeyCode:C,panActivationKeyCode:k,zoomActivationKeyCode:E,deleteKeyCode:T,onlyRenderVisibleElements:D,elementsSelectable:L,defaultViewport:O,translateExtent:B,minZoom:N,maxZoom:b,preventScrolling:I,defaultMarkerColor:M,zoomOnScroll:P,zoomOnPinch:A,panOnScroll:$,panOnScrollSpeed:j,panOnScrollMode:z,zoomOnDoubleClick:V,panOnDrag:Z,autoPanOnSelection:F,onPaneClick:G,onPaneMouseEnter:ee,onPaneMouseMove:X,onPaneMouseLeave:H,onPaneScroll:W,onPaneContextMenu:Q,paneClickDistance:Y,nodeClickDistance:U,onEdgeContextMenu:K,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:me,onReconnect:$e,onReconnectStart:ve,onReconnectEnd:Ee,noDragClassName:we,noWheelClassName:We,noPanClassName:xe,disableKeyboardA11y:_e,nodeExtent:Ce,rfId:Pe,viewport:De,onViewportChange:Oe,nodesDraggable:zt}){return Ns(e),Ns(t),Qm(),Fm(n),Um(De),a(pm,{onPaneClick:G,onPaneMouseEnter:ee,onPaneMouseMove:X,onPaneMouseLeave:H,onPaneContextMenu:Q,onPaneScroll:W,paneClickDistance:Y,deleteKeyCode:T,selectionKeyCode:S,selectionOnDrag:g,selectionMode:w,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:k,zoomActivationKeyCode:E,elementsSelectable:L,zoomOnScroll:P,zoomOnPinch:A,zoomOnDoubleClick:V,panOnScroll:$,panOnScrollSpeed:j,panOnScrollMode:z,panOnDrag:Z,autoPanOnSelection:F,defaultViewport:O,translateExtent:B,minZoom:N,maxZoom:b,onSelectionContextMenu:h,preventScrolling:I,noDragClassName:we,noWheelClassName:We,noPanClassName:xe,disableKeyboardA11y:_e,onViewportChange:Oe,isControlledViewport:!!De,children:a(Vm,{children:[a(Bm,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:$e,onReconnectStart:ve,onReconnectEnd:Ee,onlyRenderVisibleElements:D,onEdgeContextMenu:K,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:me,defaultMarkerColor:M,noPanClassName:xe,disableKeyboardA11y:_e,rfId:Pe}),a(Gm,{style:_,type:y,component:v,containerStyle:m}),a("div",{className:"react-flow__edgelabel-renderer"}),a(Sm,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:l,onNodeContextMenu:f,nodeClickDistance:U,onlyRenderVisibleElements:D,noPanClassName:xe,noDragClassName:we,disableKeyboardA11y:_e,nodeExtent:Ce,rfId:Pe,nodesDraggable:zt}),a("div",{className:"react-flow__viewport-portal"})]})})}tl.displayName="GraphView";const Jm=pe(tl),e0=ec(),Is=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:c,minZoom:d=.5,maxZoom:l=2,nodeOrigin:f,nodeExtent:h,zIndexMode:u="basic"}={})=>{const p=new Map,y=new Map,_=new Map,v=new Map,m=o??t??[],S=n??e??[],g=f??[0,0],w=h??rn;hc(_,v,m);const{nodesInitialized:C}=cr(S,p,y,{nodeOrigin:g,nodeExtent:w,zIndexMode:u});let k=[0,0,1];if(s&&r&&i){const E=mn(p,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:T,y:D,zoom:L}=Lr(E,r,i,d,l,c?.padding??.1);k=[T,D,L]}return{rfId:"1",width:r??0,height:i??0,transform:k,nodes:S,nodesInitialized:C,nodeLookup:p,parentLookup:y,edges:m,edgeLookup:v,connectionLookup:_,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:d,maxZoom:l,translateExtent:rn,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Dt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:c,fitViewResolver:null,connection:{...Za},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:e0,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ya,zIndexMode:u,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},t0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:c,minZoom:d,maxZoom:l,nodeOrigin:f,nodeExtent:h,zIndexMode:u})=>pg((p,y)=>{async function _(){const{nodeLookup:v,panZoom:m,fitViewOptions:S,fitViewResolver:g,width:w,height:C,minZoom:k,maxZoom:E}=y();m&&(await cp({nodes:v,width:w,height:C,panZoom:m,minZoom:k,maxZoom:E},S),g?.resolve(!0),p({fitViewResolver:null}))}return{...Is({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:c,minZoom:d,maxZoom:l,nodeOrigin:f,nodeExtent:h,defaultNodes:n,defaultEdges:o,zIndexMode:u}),setNodes:v=>{const{nodeLookup:m,parentLookup:S,nodeOrigin:g,nodeExtent:w,elevateNodesOnSelect:C,fitViewQueued:k,zIndexMode:E,nodesSelectionActive:T}=y(),{nodesInitialized:D,hasSelectedNodes:L}=cr(v,m,S,{nodeOrigin:g,nodeExtent:w,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:E}),O=T&&L;k&&D?(_(),p({nodes:v,nodesInitialized:D,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):p({nodes:v,nodesInitialized:D,nodesSelectionActive:O})},setEdges:v=>{const{connectionLookup:m,edgeLookup:S}=y();hc(m,S,v),p({edges:v})},setDefaultNodesAndEdges:(v,m)=>{if(v){const{setNodes:S}=y();S(v),p({hasDefaultNodes:!0})}if(m){const{setEdges:S}=y();S(m),p({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:m,nodeLookup:S,parentLookup:g,domNode:w,nodeOrigin:C,nodeExtent:k,debug:E,fitViewQueued:T,zIndexMode:D}=y(),{changes:L,updatedInternals:O}=$p(v,S,g,w,C,k,D);O&&(Np(S,g,{nodeOrigin:C,nodeExtent:k,zIndexMode:D}),T?(_(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),L?.length>0&&(E&&console.log("React Flow: trigger node changes",L),m?.(L)))},updateNodePositions:(v,m=!1)=>{const S=[];let g=[];const{nodeLookup:w,triggerNodeChanges:C,connection:k,updateConnection:E,onNodesChangeMiddlewareMap:T}=y();for(const[D,L]of v){const O=w.get(D),B=!!(O?.expandParent&&O?.parentId&&L?.position),N={id:D,type:"position",position:B?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:m};if(O&&k.inProgress&&k.fromNode.id===O.id){const b=bt(O,k.fromHandle,q.Left,!0);E({...k,from:b})}B&&O.parentId&&S.push({id:D,parentId:O.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),g.push(N)}if(S.length>0){const{parentLookup:D,nodeOrigin:L}=y(),O=Ur(S,w,D,L);g.push(...O)}for(const D of T.values())g=D(g);C(g)},triggerNodeChanges:v=>{const{onNodesChange:m,setNodes:S,nodes:g,hasDefaultNodes:w,debug:C}=y();if(v?.length){if(w){const k=Mc(v,g);S(k)}C&&console.log("React Flow: trigger node changes",v),m?.(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:m,setEdges:S,edges:g,hasDefaultEdges:w,debug:C}=y();if(v?.length){if(w){const k=Og(v,g);S(k)}C&&console.log("React Flow: trigger edge changes",v),m?.(v)}},addSelectedNodes:v=>{const{multiSelectionActive:m,edgeLookup:S,nodeLookup:g,triggerNodeChanges:w,triggerEdgeChanges:C}=y();if(m){const k=v.map(E=>ht(E,!0));w(k);return}w(Nt(g,new Set([...v]),!0)),C(Nt(S))},addSelectedEdges:v=>{const{multiSelectionActive:m,edgeLookup:S,nodeLookup:g,triggerNodeChanges:w,triggerEdgeChanges:C}=y();if(m){const k=v.map(E=>ht(E,!0));C(k);return}C(Nt(S,new Set([...v]))),w(Nt(g,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:m}={})=>{const{edges:S,nodes:g,nodeLookup:w,triggerNodeChanges:C,triggerEdgeChanges:k}=y(),E=v||g,T=m||S,D=[];for(const O of E){if(!O.selected)continue;const B=w.get(O.id);B&&(B.selected=!1),D.push(ht(O.id,!1))}const L=[];for(const O of T)O.selected&&L.push(ht(O.id,!1));C(D),k(L)},setMinZoom:v=>{const{panZoom:m,maxZoom:S}=y();m?.setScaleExtent([v,S]),p({minZoom:v})},setMaxZoom:v=>{const{panZoom:m,minZoom:S}=y();m?.setScaleExtent([S,v]),p({maxZoom:v})},setTranslateExtent:v=>{y().panZoom?.setTranslateExtent(v),p({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:m,triggerNodeChanges:S,triggerEdgeChanges:g,elementsSelectable:w}=y();if(!w)return;const C=m.reduce((E,T)=>T.selected?[...E,ht(T.id,!1)]:E,[]),k=v.reduce((E,T)=>T.selected?[...E,ht(T.id,!1)]:E,[]);S(C),g(k)},setNodeExtent:v=>{const{nodes:m,nodeLookup:S,parentLookup:g,nodeOrigin:w,elevateNodesOnSelect:C,nodeExtent:k,zIndexMode:E}=y();v[0][0]===k[0][0]&&v[0][1]===k[0][1]&&v[1][0]===k[1][0]&&v[1][1]===k[1][1]||(cr(m,S,g,{nodeOrigin:w,nodeExtent:v,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:E}),p({nodeExtent:v}))},panBy:v=>{const{transform:m,width:S,height:g,panZoom:w,translateExtent:C}=y();return Pp({delta:v,panZoom:w,transform:m,translateExtent:C,width:S,height:g})},setCenter:async(v,m,S)=>{const{width:g,height:w,maxZoom:C,panZoom:k}=y();if(!k)return!1;const E=typeof S?.zoom<"u"?S.zoom:C;return await k.setViewport({x:g/2-v*E,y:w/2-m*E,zoom:E},{duration:S?.duration,ease:S?.ease,interpolate:S?.interpolate}),!0},cancelConnection:()=>{p({connection:{...Za}})},updateConnection:v=>{p({connection:v})},reset:()=>p({...Is()})}},Object.is);function n0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:c,initialFitViewOptions:d,fitView:l,nodeOrigin:f,nodeExtent:h,zIndexMode:u,children:p}){const[y]=J(()=>t0({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:l,minZoom:s,maxZoom:c,fitViewOptions:d,nodeOrigin:f,nodeExtent:h,zIndexMode:u}));return a(gg,{value:y,children:a(zg,{children:a(tm,{children:p})})})}function o0({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:c,fitViewOptions:d,minZoom:l,maxZoom:f,nodeOrigin:h,nodeExtent:u,zIndexMode:p}){return it(mo)?a(se,{children:e}):a(n0,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:c,initialFitViewOptions:d,initialMinZoom:l,initialMaxZoom:f,nodeOrigin:h,nodeExtent:u,zIndexMode:p,children:e})}const r0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function i0({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:c,onEdgeClick:d,onInit:l,onMove:f,onMoveStart:h,onMoveEnd:u,onConnect:p,onConnectStart:y,onConnectEnd:_,onClickConnectStart:v,onClickConnectEnd:m,onNodeMouseEnter:S,onNodeMouseMove:g,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:k,onNodeDragStart:E,onNodeDrag:T,onNodeDragStop:D,onNodesDelete:L,onEdgesDelete:O,onDelete:B,onSelectionChange:N,onSelectionDragStart:b,onSelectionDrag:I,onSelectionDragStop:M,onSelectionContextMenu:P,onSelectionStart:A,onSelectionEnd:$,onBeforeDelete:j,connectionMode:z,connectionLineType:V=dt.Bezier,connectionLineStyle:Z,connectionLineComponent:F,connectionLineContainerStyle:G,deleteKeyCode:ee="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:H=!1,selectionMode:W=sn.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:Y=cn()?"Meta":"Control",zoomActivationKeyCode:U=cn()?"Meta":"Control",snapToGrid:K,snapGrid:re,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ce,nodesDraggable:me,autoPanOnNodeFocus:$e,nodesConnectable:ve,nodesFocusable:Ee,nodeOrigin:we=Nc,edgesFocusable:We,edgesReconnectable:xe,elementsSelectable:_e=!0,defaultViewport:Ce=Ig,minZoom:Pe=.5,maxZoom:De=2,translateExtent:Oe=rn,preventScrolling:zt=!0,nodeExtent:Bt,defaultMarkerColor:vn="#b1b1b7",zoomOnScroll:bo=!0,zoomOnPinch:wn=!0,panOnScroll:be=!1,panOnScrollSpeed:So=.5,panOnScrollMode:xn=mt.Free,zoomOnDoubleClick:bn=!0,panOnDrag:Sn=!0,onPaneClick:ko,onPaneMouseEnter:x,onPaneMouseMove:R,onPaneMouseLeave:ae,onPaneScroll:Ue,onPaneContextMenu:Ne,paneClickDistance:Eo=1,nodeClickDistance:hl=0,children:pl,onReconnect:gl,onReconnectStart:ml,onReconnectEnd:yl,onEdgeContextMenu:_l,onEdgeDoubleClick:vl,onEdgeMouseEnter:wl,onEdgeMouseMove:xl,onEdgeMouseLeave:bl,reconnectRadius:Sl=10,onNodesChange:kl,onEdgesChange:El,noDragClassName:Cl="nodrag",noWheelClassName:Nl="nowheel",noPanClassName:Zr="nopan",fitView:qr,fitViewOptions:Gr,connectOnClick:Il,attributionPosition:Ml,proOptions:Al,defaultEdgeOptions:$l,elevateNodesOnSelect:Pl=!0,elevateEdgesOnSelect:Tl=!1,disableKeyboardA11y:Kr=!1,autoPanOnConnect:Dl,autoPanOnNodeDrag:Ol,autoPanOnSelection:Rl=!0,autoPanSpeed:jl,connectionRadius:Hl,isValidConnection:Ll,onError:zl,style:Bl,id:Qr,nodeDragThreshold:Vl,connectionDragThreshold:Fl,viewport:Wl,onViewportChange:Ul,width:Xl,height:Yl,colorMode:Zl="light",debug:ql,onScroll:Jr,ariaLabelConfig:Gl,zIndexMode:ei="basic",...Kl},Ql){const Co=Qr||"1",Jl=Pg(Zl),eu=Me(ti=>{ti.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Jr?.(ti)},[Jr]);return a("div",{"data-testid":"rf__wrapper",...Kl,onScroll:eu,style:{...Bl,...r0},ref:Ql,className:ge(["react-flow",r,Jl]),id:Qr,role:"application",children:a(o0,{nodes:e,edges:t,width:Xl,height:Yl,fitView:qr,fitViewOptions:Gr,minZoom:Pe,maxZoom:De,nodeOrigin:we,nodeExtent:Bt,zIndexMode:ei,children:[a($g,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:p,onConnectStart:y,onConnectEnd:_,onClickConnectStart:v,onClickConnectEnd:m,nodesDraggable:me,autoPanOnNodeFocus:$e,nodesConnectable:ve,nodesFocusable:Ee,edgesFocusable:We,edgesReconnectable:xe,elementsSelectable:_e,elevateNodesOnSelect:Pl,elevateEdgesOnSelect:Tl,minZoom:Pe,maxZoom:De,nodeExtent:Bt,onNodesChange:kl,onEdgesChange:El,snapToGrid:K,snapGrid:re,connectionMode:z,translateExtent:Oe,connectOnClick:Il,defaultEdgeOptions:$l,fitView:qr,fitViewOptions:Gr,onNodesDelete:L,onEdgesDelete:O,onDelete:B,onNodeDragStart:E,onNodeDrag:T,onNodeDragStop:D,onSelectionDrag:I,onSelectionDragStart:b,onSelectionDragStop:M,onMove:f,onMoveStart:h,onMoveEnd:u,noPanClassName:Zr,nodeOrigin:we,rfId:Co,autoPanOnConnect:Dl,autoPanOnNodeDrag:Ol,autoPanSpeed:jl,onError:zl,connectionRadius:Hl,isValidConnection:Ll,selectNodesOnDrag:ce,nodeDragThreshold:Vl,connectionDragThreshold:Fl,onBeforeDelete:j,debug:ql,ariaLabelConfig:Gl,zIndexMode:ei}),a(Jm,{onInit:l,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:S,onNodeMouseMove:g,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:k,nodeTypes:i,edgeTypes:s,connectionLineType:V,connectionLineStyle:Z,connectionLineComponent:F,connectionLineContainerStyle:G,selectionKeyCode:X,selectionOnDrag:H,selectionMode:W,deleteKeyCode:ee,multiSelectionKeyCode:Y,panActivationKeyCode:Q,zoomActivationKeyCode:U,onlyRenderVisibleElements:ie,defaultViewport:Ce,translateExtent:Oe,minZoom:Pe,maxZoom:De,preventScrolling:zt,zoomOnScroll:bo,zoomOnPinch:wn,zoomOnDoubleClick:bn,panOnScroll:be,panOnScrollSpeed:So,panOnScrollMode:xn,panOnDrag:Sn,autoPanOnSelection:Rl,onPaneClick:ko,onPaneMouseEnter:x,onPaneMouseMove:R,onPaneMouseLeave:ae,onPaneScroll:Ue,onPaneContextMenu:Ne,paneClickDistance:Eo,nodeClickDistance:hl,onSelectionContextMenu:P,onSelectionStart:A,onSelectionEnd:$,onReconnect:gl,onReconnectStart:ml,onReconnectEnd:yl,onEdgeContextMenu:_l,onEdgeDoubleClick:vl,onEdgeMouseEnter:wl,onEdgeMouseMove:xl,onEdgeMouseLeave:bl,reconnectRadius:Sl,defaultMarkerColor:vn,noDragClassName:Cl,noWheelClassName:Nl,noPanClassName:Zr,rfId:Co,disableKeyboardA11y:Kr,nodeExtent:Bt,viewport:Wl,onViewportChange:Ul,nodesDraggable:me}),a(Ng,{onSelectionChange:N}),pl,a(bg,{proOptions:Al,position:Ml}),a(xg,{rfId:Co,disableKeyboardA11y:Kr})]})})}var s0=Ac(i0);function a0({dimensions:e,lineWidth:t,variant:n,className:o}){return a("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ge(["react-flow__background-pattern",n,o])})}function c0({radius:e,className:t}){return a("circle",{cx:e,cy:e,r:e,className:ge(["react-flow__background-pattern","dots",t])})}var ft;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ft||(ft={}));const l0={[ft.Dots]:1,[ft.Lines]:1,[ft.Cross]:6},u0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function nl({id:e,variant:t=ft.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:c,style:d,className:l,patternClassName:f}){const h=ne(null),{transform:u,patternId:p}=le(u0,he),y=o||l0[t],_=t===ft.Dots,v=t===ft.Cross,m=Array.isArray(n)?n:[n,n],S=[m[0]*u[2]||1,m[1]*u[2]||1],g=y*u[2],w=Array.isArray(i)?i:[i,i],C=v?[g,g]:S,k=[w[0]*u[2]+C[0]/2,w[1]*u[2]+C[1]/2],E=`${p}${e||""}`;return a("svg",{className:ge(["react-flow__background",l]),style:{...d,..._o,"--xy-background-color-props":c,"--xy-background-pattern-color-props":s},ref:h,"data-testid":"rf__background",children:[a("pattern",{id:E,x:u[0]%S[0],y:u[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:_?a(c0,{radius:g/2,className:f}):a(a0,{dimensions:C,lineWidth:r,variant:t,className:f})}),a("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}nl.displayName="Background";const d0=pe(nl);function f0(){return a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:a("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function h0(){return a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:a("path",{d:"M0 0h32v4.2H0z"})})}function p0(){return a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:a("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function g0(){return a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function m0(){return a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Tn({children:e,className:t,...n}){return a("button",{type:"button",className:ge(["react-flow__controls-button",t]),...n,children:e})}const y0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function ol({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:c,onInteractiveChange:d,className:l,children:f,position:h="bottom-left",orientation:u="vertical","aria-label":p}){const y=de(),{isInteractive:_,minZoomReached:v,maxZoomReached:m,ariaLabelConfig:S}=le(y0,he),{zoomIn:g,zoomOut:w,fitView:C}=Xr(),k=()=>{g(),i?.()},E=()=>{w(),s?.()},T=()=>{C(r),c?.()},D=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),d?.(!_)};return a(yo,{className:ge(["react-flow__controls",u==="horizontal"?"horizontal":"vertical",l]),position:h,style:e,"data-testid":"rf__controls","aria-label":p??S["controls.ariaLabel"],children:[t&&a(se,{children:[a(Tn,{onClick:k,className:"react-flow__controls-zoomin",title:S["controls.zoomIn.ariaLabel"],"aria-label":S["controls.zoomIn.ariaLabel"],disabled:m,children:a(f0,{})}),a(Tn,{onClick:E,className:"react-flow__controls-zoomout",title:S["controls.zoomOut.ariaLabel"],"aria-label":S["controls.zoomOut.ariaLabel"],disabled:v,children:a(h0,{})})]}),n&&a(Tn,{className:"react-flow__controls-fitview",onClick:T,title:S["controls.fitView.ariaLabel"],"aria-label":S["controls.fitView.ariaLabel"],children:a(p0,{})}),o&&a(Tn,{className:"react-flow__controls-interactive",onClick:D,title:S["controls.interactive.ariaLabel"],"aria-label":S["controls.interactive.ariaLabel"],children:_?a(m0,{}):a(g0,{})}),f]})}ol.displayName="Controls";const _0=pe(ol);function v0({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:c,strokeWidth:d,className:l,borderRadius:f,shapeRendering:h,selected:u,onClick:p}){const{background:y,backgroundColor:_}=i||{},v=s||y||_;return a("rect",{className:ge(["react-flow__minimap-node",{selected:u},l]),x:t,y:n,rx:f,ry:f,width:o,height:r,style:{fill:v,stroke:c,strokeWidth:d},shapeRendering:h,onClick:p?m=>p(m,e):void 0})}const w0=pe(v0),x0=e=>e.nodes.map(t=>t.id),Vo=e=>e instanceof Function?e:()=>e;function b0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=w0,onClick:s}){const c=le(x0,he),d=Vo(t),l=Vo(e),f=Vo(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return a(se,{children:c.map(u=>a(k0,{id:u,nodeColorFunc:d,nodeStrokeColorFunc:l,nodeClassNameFunc:f,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:h},u))})}function S0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:c,onClick:d}){const{node:l,x:f,y:h,width:u,height:p}=le(y=>{const _=y.nodeLookup.get(e);if(!_)return{node:void 0,x:0,y:0,width:0,height:0};const v=_.internals.userNode,{x:m,y:S}=_.internals.positionAbsolute,{width:g,height:w}=Fe(v);return{node:v,x:m,y:S,width:g,height:w}},he);return!l||l.hidden||!tc(l)?null:a(c,{x:f,y:h,width:u,height:p,style:l.style,selected:!!l.selected,className:o(l),color:t(l),borderRadius:r,strokeColor:n(l),strokeWidth:i,shapeRendering:s,onClick:d,id:l.id})}const k0=pe(S0);var E0=pe(b0);const C0=200,N0=150,I0=e=>!e.hidden,M0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};let n=!1;for(const o of e.nodeLookup.values())if(!o.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Qa(mn(e.nodeLookup,{filter:I0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Ms=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,A0=(e,t)=>Ms(e.viewBB,t.viewBB)&&Ms(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,$0="react-flow__minimap-desc";function rl({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:c,bgColor:d,maskColor:l,maskStrokeColor:f,maskStrokeWidth:h,position:u="bottom-right",onClick:p,onNodeClick:y,pannable:_=!1,zoomable:v=!1,ariaLabel:m,inversePan:S,zoomStep:g=1,offsetScale:w=5}){const C=de(),k=ne(null),{boundingRect:E,panZoom:T,viewBB:D,rfId:L,translateExtent:O,flowWidth:B,flowHeight:N,ariaLabelConfig:b}=le(M0,A0),I=e?.width??C0,M=e?.height??N0,P=E.width/I,A=E.height/M,$=Math.max(P,A),j=$*I,z=$*M,V=w*$,Z=E.x-(j-E.width)/2-V,F=E.y-(z-E.height)/2-V,G=j+V*2,ee=z+V*2,X=`${$0}-${L}`,H=ne(0),W=ne();H.current=$,oe(()=>{const re=C.getState().panZoom;if(k.current&&re)return W.current=Bp({domNode:k.current,panZoom:re,getTransform:()=>C.getState().transform,getViewScale:()=>H.current}),()=>{W.current?.destroy()}},[T]),oe(()=>{W.current?.update({translateExtent:O,width:B,height:N,inversePan:S,pannable:_,zoomStep:g,zoomable:v})},[_,v,S,g,O,B,N]);const Q=p?re=>{const[ie,ce]=W.current?.pointer(re)||[0,0];p(re,{x:ie,y:ce})}:void 0,Y=Me((re,ie)=>{const ce=C.getState().nodeLookup.get(ie).internals.userNode;y?.(re,ce)},[y]),U=y?Y:void 0,K=m??b["minimap.ariaLabel"];return a(yo,{position:u,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof h=="number"?h*$:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:ge(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:a("svg",{width:I,height:M,viewBox:`${Z} ${F} ${G} ${ee}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":X,ref:k,onClick:Q,children:[K&&a("title",{id:X,children:K}),a(E0,{onClick:U,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:c}),a("path",{className:"react-flow__minimap-mask",d:`M${Z-V},${F-V}h${G+V*2}v${ee+V*2}h${-G-V*2}z
|
|
7
|
+
M${D.x},${D.y}h${D.width}v${D.height}h${-D.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}rl.displayName="MiniMap";const P0=pe(rl),T0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,D0={[jt.Line]:"right",[jt.Handle]:"bottom-right"};function O0({nodeId:e,position:t,variant:n=jt.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:c=10,minHeight:d=10,maxWidth:l=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:u,autoScale:p=!0,shouldResize:y,onResizeStart:_,onResize:v,onResizeEnd:m}){const S=Oc(),g=typeof e=="string"?e:S,w=de(),C=ne(null),k=n===jt.Handle,E=le(Me(T0(k&&p),[k,p]),he),T=ne(null),D=t??D0[n];oe(()=>{if(!(!C.current||!g))return T.current||(T.current=eg({domNode:C.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:O,transform:B,snapGrid:N,snapToGrid:b,nodeOrigin:I,domNode:M}=w.getState();return{nodeLookup:O,transform:B,snapGrid:N,snapToGrid:b,nodeOrigin:I,paneDomNode:M}},onChange:(O,B)=>{const{triggerNodeChanges:N,nodeLookup:b,parentLookup:I,nodeOrigin:M}=w.getState(),P=[],A={x:O.x,y:O.y},$=b.get(g);if($&&$.expandParent&&$.parentId){const j=$.origin??M,z=O.width??$.measured.width??0,V=O.height??$.measured.height??0,Z={id:$.id,parentId:$.parentId,rect:{width:z,height:V,...nc({x:O.x??$.position.x,y:O.y??$.position.y},{width:z,height:V},$.parentId,b,j)}},F=Ur([Z],b,I,M);P.push(...F),A.x=O.x?Math.max(j[0]*z,O.x):void 0,A.y=O.y?Math.max(j[1]*V,O.y):void 0}if(A.x!==void 0&&A.y!==void 0){const j={id:g,type:"position",position:{...A}};P.push(j)}if(O.width!==void 0&&O.height!==void 0){const z={id:g,type:"dimensions",resizing:!0,setAttributes:u?u==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};P.push(z)}for(const j of B){const z={...j,type:"position"};P.push(z)}N(P)},onEnd:({width:O,height:B})=>{const N={id:g,type:"dimensions",resizing:!1,dimensions:{width:O,height:B}};w.getState().triggerNodeChanges([N])}})),T.current.update({controlPosition:D,boundaries:{minWidth:c,minHeight:d,maxWidth:l,maxHeight:f},keepAspectRatio:h,resizeDirection:u,onResizeStart:_,onResize:v,onResizeEnd:m,shouldResize:y}),()=>{T.current?.destroy()}},[D,c,d,l,f,h,_,v,m,y]);const L=D.split("-");return a("div",{className:ge(["react-flow__resize-control","nodrag",...L,n,o]),ref:C,style:{...r,scale:E,...s&&{[k?"backgroundColor":"borderColor"]:s}},children:i})}pe(O0);function R0(e){let t=2166136261;for(const n of e)t=Math.imul(t^n.charCodeAt(0),16777619)>>>0;return"#"+[0,8,16].map(n=>(60+(t>>>n&255)%111).toString(16).padStart(2,"0")).join("")}const il=e=>e.color||R0(e.id),dr=(e,t,n)=>n&&e.missions[n]?.color||il(e.projects[t]||{id:t});function j0(e,t,n={},o){let r=[],i=[],s=0;const c=t.query.trim().toLowerCase(),d=(...g)=>g.join(" ").toLowerCase().includes(c),l=(g,w,C,k)=>r.push({id:g,type:"work",position:{x:w,y:C},data:k}),f=(g,w,C)=>i.push({id:`${g}:${w}`,source:g,target:w,type:"smoothstep",style:{stroke:C,strokeWidth:1.5}});for(const g of Object.values(e.projects).filter(w=>!w.archivedAt&&(t.project==="all"||w.id===t.project)).sort((w,C)=>w.name.localeCompare(C.name)||w.id.localeCompare(C.id))){const w=s,C=[];for(const k of Object.values(e.missions).filter(E=>E.projectId===g.id&&!E.archivedAt).sort((E,T)=>E.name.localeCompare(T.name)||E.id.localeCompare(T.id))){const E=Object.values(e.tasks).filter(N=>N.missionId===k.id),T=E.filter(N=>(t.agent==="all"||N.updatedBy===t.agent)&&(t.status==="all"||N.status===t.status)&&d(g.name,k.name,N.title,N.note)).sort((N,b)=>N.createdAt.localeCompare(b.createdAt)||N.id.localeCompare(b.id)),D=t.agent==="all"||Object.values(e.sessions).some(N=>N.agent===t.agent&&(N.missionId===k.id||N.missionIds?.includes(k.id)));if(!T.length&&!(E.length===0&&t.status==="all"&&D&&d(g.name,k.name)))continue;const L=s,O=dr(e,g.id,k.id);for(const N of T)l(N.id,800,s*170,{label:N.title,kind:"Task",status:N.status,color:O,href:`#/tasks/${encodeURIComponent(N.id)}`,summary:`${N.updatedBy} · ${N.status==="completed"?"100%":N.status==="todo"?"0%":N.progress!==void 0?`${N.progress}%`:"Progress not reported"}`}),f(k.id,N.id,O),s++;T.length||s++;const B=(L+s-1)*85;l(k.id,400,B,{label:k.name,kind:"Mission",status:k.status,color:O,href:`#/missions/${encodeURIComponent(k.id)}`,summary:`${T.length} ${t.status==="all"&&t.agent==="all"&&!c?"":"matching "}tasks`}),C.push(k.id),f(g.id,k.id,O),s+=.35}!C.length&&!(t.agent==="all"&&t.status==="all"&&d(g.name)&&!Object.values(e.missions).some(k=>k.projectId===g.id&&!k.archivedAt))||(C.length||s++,l(g.id,0,(w+s-1)*85,{label:g.name,kind:"Project",status:"active",color:dr(e,g.id),href:`#/projects/${encodeURIComponent(g.id)}`,summary:`${C.length} missions`}),s++)}const h={projects:r.filter(g=>g.data.kind==="Project").length,missions:r.filter(g=>g.data.kind==="Mission").length,tasks:r.filter(g=>g.data.kind==="Task").length},u=i,p=new Set(o?.projects),y=new Set(o?.missions);for(const g of r)g.data.childCount=u.filter(w=>w.source===g.id).length,g.data.expanded=!o||(g.data.kind==="Project"?p.has(g.id):y.has(g.id));if(o){const g=new Set(r.filter(E=>E.data.kind==="Project").map(E=>E.id)),w=new Set(u.filter(E=>g.has(E.source)&&p.has(E.source)).map(E=>E.target)),C=new Set(u.filter(E=>w.has(E.source)&&y.has(E.source)).map(E=>E.target));r=r.filter(E=>g.has(E.id)||w.has(E.id)||C.has(E.id));const k=new Set(r.map(E=>E.id));i=i.filter(E=>k.has(E.source)&&k.has(E.target))}const _=new Map(r.map(g=>[g.id,g])),v=g=>i.filter(w=>w.source===g).map(w=>_.get(w.target));let m=0;for(const g of r.filter(w=>w.data.kind==="Project")){const w=v(g.id),C=w.some(L=>v(L.id).length>0),k=Math.min(C?2:3,Math.max(1,w.length)),E=C?540:260,T=k*E;g.position={x:m+(T-220)/2,y:0};let D=180;for(let L=0;L<w.length;L+=k){const O=w.slice(L,L+k);let B=0;for(const[N,b]of O.entries()){const I=v(b.id),M=Math.min(2,Math.max(1,I.length)),P=m+N*E;b.position={x:P+(E-220)/2,y:D};const A=P+(E-(M===2?480:220))/2;for(const[$,j]of I.entries())j.position={x:A+$%2*260,y:D+160+Math.floor($/2)*150};B=Math.max(B,Math.ceil(I.length/2))}D+=B?160+B*150+50:156}m+=T+70}o&&p.size===0&&r.filter(g=>g.data.kind==="Project").forEach((g,w)=>{g.position={x:w%3*260,y:Math.floor(w/3)*156}});const S=[...Object.values(n)];for(const g of r)if(n[g.id])g.position=n[g.id];else{for(;S.some(w=>Math.abs(w.x-g.position.x)<240&&Math.abs(w.y-g.position.y)<136);)g.position={x:g.position.x,y:g.position.y+156};S.push(g.position)}return{nodes:r,edges:i,counts:h}}const sl={active:"Active",planned:"Planned",running:"Running",todo:"To do",in_progress:"In progress",blocked:"Blocked",completed:"Completed",failed:"Failed",cancelled:"Cancelled"},fr="angine-graph-manual-positions-compact-v5";function H0(){try{const e=JSON.parse(localStorage.getItem(fr)||"{}");return Object.fromEntries(Object.entries(e).filter(([,t])=>t&&Number.isFinite(t.x)&&Number.isFinite(t.y)))}catch{return{}}}function L0({data:e}){return a("div",{class:"graph-card",style:{borderInlineStart:`4px solid ${e.color}`},children:[a(Ht,{type:"target",position:q.Top,isConnectable:!1}),a("div",{class:"graph-card-top",children:[a("span",{children:e.kind}),a("span",{class:`badge ${e.status}`,children:sl[e.status]||e.status})]}),a("a",{class:"nodrag",href:e.href,title:e.label,children:[e.label,a("span",{"aria-hidden":"true",children:" ↗"})]}),a("p",{children:e.summary}),!!e.childCount&&e.toggle&&a("button",{class:"nodrag graph-expand","aria-expanded":e.expanded,onClick:e.toggle,children:[e.expanded?"− Hide":"+ Show"," ",e.kind==="Project"?"missions":"tasks"]}),a(Ht,{type:"source",position:q.Bottom,isConnectable:!1})]})}const z0={work:L0};function B0({state:e,filters:t,setFilters:n,reset:o}){const r=ne(H0()),i=ne({...r.current}),[s,c]=J([]),[d,l]=J(null),[f,h]=J(0),u=ne(""),[p,y]=J([]),[_,v]=J([]),m=!!(t.query||t.project!=="all"||t.agent!=="all"||t.status!=="all"),S=(N,b)=>{u.current=b==="Project"?N:e.missions[N]?.projectId||"",(b==="Project"?y:v)(M=>M.includes(N)?M.filter(P=>P!==N):[...M,N]),i.current={...r.current},c([]),h(M=>M+1)},g=()=>{u.current="",r.current={},y([]),v([]),i.current={},c([]),h(N=>N+1),o()},w=ne(""),C=()=>{const N=s.find(I=>I.id===u.current)||s.find(I=>I.data.kind==="Project")||s[0],b=document.querySelector(".graph-canvas")?.clientWidth||1e3;if(!p.length&&!m){d?.fitView({padding:.15,minZoom:.65,maxZoom:.9,duration:250});return}N&&d?.setViewport({x:b/2-(N.position.x+110)*.9,y:45-N.position.y*.9,zoom:.9},{duration:250})},k=()=>{d?.fitView({padding:.2,minZoom:.65,maxZoom:1,duration:250})};oe(()=>{const N=JSON.stringify([t.project,t.agent,t.status,t.query,f,p,_]);d&&s.length&&w.current!==N&&(w.current=N,requestAnimationFrame(C)),s.length||(w.current="")},[d,s.length,t.project,t.agent,t.status,t.query,f,p,_]);const E=ye(()=>j0(e,t,i.current,{projects:m?Object.keys(e.projects):p,missions:m?Object.keys(e.missions):_}),[e,t.project,t.agent,t.status,t.query,f,p,_]),T=()=>{try{localStorage.setItem(fr,JSON.stringify(r.current))}catch{}};oe(()=>{c(N=>{const b=new Map(N.map(I=>[I.id,I]));return E.nodes.map(I=>{const M=b.get(I.id)?.position||I.position;return i.current[I.id]=M,{...b.get(I.id),...I,position:M,data:{...I.data,toggle:m?void 0:()=>S(I.id,I.data.kind)}}})})},[E]),oe(()=>{for(const N of s)i.current[N.id]=N.position;T()},[s]);const D=Object.values(e.projects).filter(N=>!N.archivedAt).sort((N,b)=>N.name.localeCompare(b.name)),L=[...new Set([...Object.values(e.sessions).map(N=>N.agent),...Object.values(e.tasks).map(N=>N.updatedBy)])].sort(),O=!!(t.query||t.project!=="all"||t.agent!=="all"||t.status!=="all");return a("section",{class:"graph-view",children:[a("div",{class:"graph-heading",children:[a("div",{children:[a("h1",{children:"Work graph"}),a("p",{children:"Projects → Missions → Tasks · Live from agent reports"})]}),a("div",{class:"graph-actions",children:[a("button",{class:"secondary-button",onClick:k,children:"Fit view"}),a("button",{class:"secondary-button",onClick:g,children:"All projects"}),a("button",{class:"secondary-button",onClick:()=>{i.current={...r.current},c([]),y(Object.keys(e.projects)),v(Object.keys(e.missions)),h(N=>N+1)},children:"Expand all"}),a("button",{class:"secondary-button",onClick:()=>{r.current={},i.current={};try{localStorage.removeItem(fr)}catch{}c([]),h(N=>N+1)},children:"Auto arrange"})]})]}),a("div",{class:"toolbar graph-toolbar",children:[a("label",{class:"search",children:[a("span",{"aria-hidden":"true",children:"⌕"}),a("input",{"aria-label":"Search graph",placeholder:"Search projects, missions, tasks…",value:t.query,onInput:N=>n({query:N.currentTarget.value})})]}),a("label",{class:"filter-label",children:[a("span",{children:"Project"}),a("select",{"aria-label":"Graph project",value:t.project,onChange:N=>n({project:N.currentTarget.value}),children:[a("option",{value:"all",children:"All projects"}),D.map(N=>a("option",{value:N.id,children:N.name},N.id))]})]}),a("label",{class:"filter-label",children:[a("span",{children:"Agent"}),a("select",{"aria-label":"Graph agent",value:t.agent,onChange:N=>n({agent:N.currentTarget.value}),children:[a("option",{value:"all",children:"All agents"}),L.map(N=>a("option",{value:N,children:N},N))]})]}),a("label",{class:"filter-label",children:[a("span",{children:"Task status"}),a("select",{"aria-label":"Graph task status",value:t.status,onChange:N=>n({status:N.currentTarget.value}),children:[a("option",{value:"all",children:"All statuses"}),["todo","in_progress","blocked","completed","failed","cancelled"].map(N=>a("option",{value:N,children:sl[N]},N))]})]}),O&&a("button",{class:"clear-filters",onClick:o,children:"Reset"})]}),a("div",{class:"graph-meta",children:[a("span",{children:[E.counts.projects," projects · ",E.counts.missions," missions · ",E.counts.tasks," tasks · ",E.nodes.length," nodes shown"]}),a("span",{children:"Show missions and tasks to explore · Drag to arrange · Scroll to zoom"})]}),a("div",{class:"graph-canvas",role:"region","aria-label":"Interactive project mission and task graph",children:E.nodes.length?a(s0,{nodes:s,edges:E.edges,nodeTypes:z0,onNodesChange:N=>c(b=>Mc(N,b)),onNodeDragStop:(N,b)=>{i.current[b.id]=b.position,r.current[b.id]=b.position,T()},onInit:l,defaultViewport:{x:40,y:40,zoom:.9},minZoom:.3,maxZoom:2,nodesConnectable:!1,edgesReconnectable:!1,deleteKeyCode:null,children:[a(d0,{gap:22,size:1}),a(_0,{showInteractive:!1,showFitView:!1}),a(P0,{pannable:!0,zoomable:!0,nodeColor:N=>String(N.data.color||"#94a3b8")})]}):a("div",{class:"empty",children:[a("h2",{children:O?"No work matches these filters":"Your graph will grow here"}),a("p",{children:O?"Try another project, agent, or task status.":"Ask a connected agent to report a mission. Its project and tasks will appear automatically."}),O?a("button",{class:"secondary-button",onClick:o,children:"Clear filters"}):a("a",{href:"#/agents",children:"Check agent connections"})]})})]})}const Wt=(e,t,n)=>e?{borderInlineStart:`3px solid ${dr(e,t,n)}`}:void 0;function V0({project:e,mission:t,mutate:n}){const[o,r]=J(!1),i=t?{missionId:t.id}:{projectId:e.id},s=async d=>{r(!0);try{await n("color",{...i,color:d})}finally{r(!1)}},c=t?t.color:e.color;return a("div",{class:"color-control",children:[a("label",{children:[a("span",{children:t?"Mission color":"Project color"}),a("input",{type:"color","aria-label":t?"Choose mission color override":"Choose project color",value:c||il(e),disabled:o,onChange:d=>{s(d.currentTarget.value)}})]}),a("p",{children:t?c?"Custom color for this mission and its tasks.":"Inherits the project color.":"Used by all missions and tasks without an override."}),c&&a("button",{class:"text-button",disabled:o,onClick:()=>{s(null)},children:t?"Use project color":"Reset to automatic"}),o&&a("span",{role:"status",children:"Saving…"})]})}function As(){return Object.fromEntries([["claude","Other"],["codex","Other"],["grok","Other"]].map(([e,t])=>{const n=`${e}-default`,o={id:`profile_${n}`,key:n,name:`${e[0].toUpperCase()+e.slice(1)} / ${t}`,agent:e,context:t,isDefault:!0};return[o.id,o]}))}function Qt(e,t=60,n=Date.now()){return t>0&&["running","in_progress","blocked"].includes(e.status)&&n-Date.parse(e.updatedAt)>=t*6e4}function F0(e,t){return!e||t.seq<=e.seq?[]:Object.values(t.tasks).filter(n=>{const o=e.tasks[n.id];return o&&o.status!==n.status&&["completed","blocked"].includes(n.status)&&!t.projects[n.projectId]?.archivedAt&&!t.missions?.[n.missionId]?.archivedAt})}const W0=e=>`prj_${e}`,$s=e=>e?.path.split(/[\\/]/).filter(Boolean).pop()||"Project";function U0(e,t,n){return JSON.parse(JSON.stringify({id:e.projectId,key:n?.key||$s(t),workspaceId:e.workspaceId,name:n?.name||$s(t),description:n?.description,color:n?.color,status:"active",createdAt:n&&n.createdAt<e.createdAt?n.createdAt:e.createdAt,updatedAt:n&&n.updatedAt>e.updatedAt?n.updatedAt:e.updatedAt,archivedAt:n?.archivedAt}))}function X0(e){if(e.schemaVersion!==void 0&&e.schemaVersion!==1&&e.schemaVersion!==2)throw new Error("Unsupported Angine state version");if(e.schemaVersion===2)return{...e,missions:e.missions||{},profiles:e.profiles||As()};const t={},n={},o=e.workspaces||{};for(const s of Object.values(e.projects||{})){const c={...s,projectId:W0(s.workspaceId)};t[c.id]=c,n[c.projectId]=U0(c,o[c.workspaceId],n[c.projectId])}const r={};for(const s of Object.values(e.tasks||{})){const c=t[s.projectId];r[s.id]={...s,missionId:s.missionId||s.projectId,projectId:c?.projectId||s.projectId}}const i={};for(const s of Object.values(e.sessions||{})){const c=s.missionIds||s.projectIds||[s.projectId];i[s.id]={...s,missionId:s.missionId||s.projectId,missionIds:c,projectId:t[s.projectId]?.projectId||s.projectId,projectIds:[...new Set(c.map(d=>t[d]?.projectId||d))]}}return{schemaVersion:2,seq:e.seq||0,workspaces:o,projects:n,missions:t,tasks:r,sessions:i,profiles:e.profiles||As()}}function al(e,t){return!!(e.projects[t.projectId]?.archivedAt||e.missions?.[t.missionId]?.archivedAt)}const Y0=3,Z0=75e3;function wo(e,t=Date.now()){return!e.closedAt&&t-Date.parse(e.lastSeenAt)<Z0?"connected":"disconnected"}function cl(e,t){return t?e?.reporters.find(n=>n.id===t):void 0}function q0(e,t=Date.now()){const n=new Map;for(const o of e){const r=JSON.stringify([o.agent,o.profileId||o.profileKey||"default"]);let i=n.get(r);i||(i={id:r,agent:o.agent,profileId:o.profileId,profileKey:o.profileKey,reporters:[],connected:0,sentUpdates:0,connectedOnly:0,issues:0},n.set(r,i)),i.reporters.push(o);const s=wo(o,t)==="connected";s&&i.connected++,o.successfulReports>0?i.sentUpdates++:s&&i.connectedOnly++,o.issue&&i.issues++}return[...n.values()].map(o=>({...o,reporters:o.reporters.sort((r,i)=>+!!i.issue-+!!r.issue||+(i.successfulReports>0)-+(r.successfulReports>0)||(i.lastReportAt||"").localeCompare(r.lastReportAt||"")||i.startedAt.localeCompare(r.startedAt))})).sort((o,r)=>r.issues-o.issues||o.agent.localeCompare(r.agent))}function ll(e,t,n,o,r=Date.now()){return t.filter(i=>!e.projects[i.projectId]?.archivedAt&&!e.missions?.[i.missionId]?.archivedAt).flatMap(i=>{if(i.status==="blocked")return[{task:i,reason:i.blocker?.nextStep||i.blocker?.reason||"Blocked — open for details"}];if(i.status==="failed")return[{task:i,reason:"Agent reported failure"}];if(i.status!=="in_progress")return[];const s=cl(n,e.sessions[i.updatedBySessionId||""]?.reporterId);return s?.issue?[{task:i,reason:"Reporter needs attention"}]:s&&wo(s,r)==="disconnected"?[{task:i,reason:"Reporter disconnected — task status unconfirmed"}]:Qt(i,o,r)?[{task:i,reason:"No recent task update"}]:[]})}const Fo=e=>e[0].toUpperCase()+e.slice(1),hr=e=>e?new Date(e).toLocaleString():"No reports yet";function G0(){const[e,t]=J(null),[n,o]=J("checking");return oe(()=>{let r=!1,i=!1;const s=new AbortController,c=async()=>{if(!i){i=!0;try{const l=await fetch("/api/health",{signal:s.signal});if(r)return;if(l.status===404){o("outdated"),t(null);return}if(!l.ok)throw new Error;const f=await l.json();if(r)return;t(f),o(f.protocolVersion===Y0?"ready":"outdated")}catch{r||(o("unavailable"),t(null))}finally{i=!1}}};c();const d=setInterval(()=>{c()},15e3);return()=>{r=!0,s.abort(),clearInterval(d)}},[]),{health:e,compatibility:n}}function K0({compatibility:e}){return e!=="outdated"?null:a("div",{class:"server-notice",role:"status",children:[a("strong",{children:"Update the running server"}),a("span",{children:["Run ",a("code",{children:"angine restart"}),", refresh this page, then restart your agent sessions. New controls need the updated server."]})]})}function ul({reporter:e}){const t=e?wo(e):"unknown";return a("span",{class:`reporter-health ${t}`,title:"This describes the Angine reporter connection, not whether the agent is currently working.",children:[a("span",{}),t==="connected"?"Reporter connected":t==="disconnected"?"Reporter disconnected":"Connection not tracked"]})}function Q0({health:e,session:t}){const n=cl(e,t.reporterId);return a("div",{class:"reporting-details",children:[a(ul,{reporter:n}),a("p",{children:["Last task report: ",hr(t.lastSeenAt)]}),n&&a("p",{children:[n.successfulReports," accepted · ",n.failedReports," rejected reports since server start"]}),a("p",{children:"Task status is agent reported. A connection heartbeat does not confirm task progress."})]})}const J0=e=>e.issue==="profile_missing"?"Profile not found. Check the configured profile key.":e.issue==="reporter_outdated"?"Restart this agent session to load the updated reporter.":e.issue==="report_rejected"?"A report was rejected. Check its profile and task keys; the next accepted report clears this warning.":"";function ey({health:e,compatibility:t,profile:n,profiles:o={}}){const[r,i]=J(!1),s=(e?.reporters||[]).filter(h=>!n||h.profileId===n.id||h.profileKey===n.key&&h.agent===n.agent).sort((h,u)=>u.lastSeenAt.localeCompare(h.lastSeenAt)),c=q0(s),d=s.filter(h=>wo(h)==="connected").length,l=n?["mcp","--agent",n.agent,"--profile",n.key]:void 0,f=n?JSON.stringify({command:"angine",args:l},null,2):"angine setup";return a("section",{class:"panel connection-panel",children:[a("div",{class:"panel-heading",children:[a("h2",{children:"Connections"}),a("span",{children:t==="ready"?`${d} connected`:t==="outdated"?"Server update needed":t==="checking"?"Checking…":"Unable to check"})]}),a("p",{class:"muted",children:"Connected means the integration is reachable. “Sent updates” counts reporters that submitted work since the server started; “connected only” means no work updates in that time. Neither confirms the agent is currently working."}),c.map(h=>a("details",{class:"connection-group",children:[a("summary",{children:[a("span",{children:[a("strong",{children:[o[h.profileId||""]?.name||Fo(h.agent),!h.profileId&&h.profileKey?` · ${h.profileKey}`:""]}),a("span",{children:[h.connected," connected · ",h.sentUpdates," sent updates · ",h.connectedOnly," connected only"]})]}),a("span",{class:h.issues?"connection-issue":"connection-group-expand",children:h.issues?`${h.issues} need attention`:`${h.reporters.length} reporters`})]}),a("div",{class:"connection-group-rows",children:h.reporters.map(u=>a("div",{class:"connection-row",children:[a("div",{children:[a("strong",{children:[Fo(u.agent)," · ",u.id.slice(0,8)]}),a(ul,{reporter:u}),a("span",{children:u.lastReportAt?`Last known report: ${hr(u.lastReportAt)}`:"No task updates received in this server session"}),u.issue&&a("p",{class:"connection-issue",children:J0(u)})]}),a("details",{children:[a("summary",{children:"Details"}),a("dl",{children:[a("dt",{children:"Profile"}),a("dd",{children:o[u.profileId||""]?.name||u.profileKey||"Agent default"}),a("dt",{children:"Reporter version"}),a("dd",{children:u.version||"Unknown"}),a("dt",{children:"Last heartbeat"}),a("dd",{children:hr(u.lastSeenAt)}),a("dt",{children:"Accepted since server start"}),a("dd",{children:u.successfulReports}),a("dt",{children:"Rejected since server start"}),a("dd",{children:u.failedReports}),a("dt",{children:"Reporter ID"}),a("dd",{children:u.id}),u.sourceSessionId&&a(se,{children:[a("dt",{children:"Agent session"}),a("dd",{children:u.sourceSessionId})]})]})]})]},u.id))})]},h.id)),!s.length&&a("p",{class:"muted",children:["No tracked connections ",n?"for this profile ":"","yet. Restart your configured agent session to load the updated reporter."]}),a("details",{class:"connect-instructions",children:[a("summary",{children:n?"Connect this profile":"Connect an agent"}),a("p",{children:n?"Use this configuration for the agent’s Angine MCP connection. The profile key assigns its reports here.":"Run setup once, then restart Claude or Codex sessions. Setup registers their local MCP reporter."}),a("pre",{children:f}),a("button",{class:"secondary-button",onClick:async()=>{try{await navigator.clipboard.writeText(f),i(!0)}catch{i(!1)}},children:r?"Copied":"Copy setup"}),a("p",{class:"muted",children:"After reconnecting, ask the agent to use Angine’s check_connection tool. A successful check confirms the reporter and profile; reports will appear when the agent sends work updates."}),n?.isDefault&&a("p",{class:"muted",children:["This is the default profile for ",Fo(n.agent),". Existing connections without an explicit profile key use it automatically."]})]})]})}function ty({state:e,tasks:t,health:n,staleMinutes:o}){const r=ll(e,t,n,o),i=t.filter(s=>s.status==="in_progress").length;return a("details",{class:`attention-summary ${r.length?"has-attention":""}`,children:[a("summary",{children:[a("span",{children:[a("strong",{children:r.length?`${r.length} need attention`:"No tasks need attention"}),a("span",{children:[i," in progress · Based on the current filters"]})]}),a("span",{class:"attention-expand",children:"View details"})]}),a("div",{class:"attention-items",children:[r.slice(0,10).map(({task:s,reason:c})=>a("a",{href:`#/tasks/${encodeURIComponent(s.id)}`,children:[a("strong",{children:s.title}),a("span",{class:"attention-context",children:[a("b",{children:"Project:"})," ",e.projects[s.projectId]?.name||"Unknown project"," ",a("span",{"aria-hidden":"true",children:" / "}),a("b",{children:"Mission:"})," ",e.missions[s.missionId]?.name||"Unknown mission"]}),a("span",{class:"attention-reason",children:c})]},s.id)),!r.length&&a("p",{class:"muted",children:"No blocked, failed, stale, or tracked disconnected tasks in this view. This is based on reports received, not independent verification of the work."}),r.length>10&&a("p",{class:"muted",children:"Showing the first 10. Use the task filters to review the remaining work."})]})]})}const Wo={agent:"all",status:"all",project:"all",mission:"all",profile:"all",query:"",staleOnly:!1},Jt=e=>({codex:"Codex",claude:"Claude",grok:"Grok",external:"External"})[(e||"external").trim()]||e||"External",Te=(e,t)=>`#/${e}${t?`/${encodeURIComponent(t)}`:""}`;function dl(e,t){try{return JSON.parse(localStorage.getItem(e)||"null")??t}catch{return t}}function fl(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function ny(e){const[t,n]=J(()=>dl("angine-filters-v1",{}));oe(()=>fl("angine-filters-v1",t),[t]);const o={...Wo,...t[e]},r=i=>n(s=>({...s,[e]:{...Wo,...s[e],...i}}));return{filters:o,set:r,reset:()=>r({...Wo}),resetAll:()=>n({})}}function oy(){const[e,t]=J(()=>{const n=dl("angine-preferences-v1",{staleMinutes:60,notifications:!1});return{staleMinutes:[0,15,60,240,1440].includes(n.staleMinutes)?n.staleMinutes:60,notifications:n.notifications===!0}});return oe(()=>fl("angine-preferences-v1",e),[e]),{preferences:e,setPreferences:t}}function ry(e,t){const n=ne(null);oe(()=>{if(!e)return;const o=F0(n.current,e);if(n.current=e,!t||!o.length||typeof Notification>"u"||Notification.permission!=="granted")return;const r=o.filter(d=>d.status==="completed").length,i=o.length-r,s=o.length===1?`Angine · Task ${o[0].status}`:"Angine · Work updated",c=o.length===1?o[0].title:[r?`${r} completed`:"",i?`${i} blocked`:""].filter(Boolean).join(" · ");try{const d=new Notification(s,{body:c,tag:"angine-work-update"});d.onclick=()=>{window.focus(),location.hash=Te("tasks",o[0].id).slice(1),d.close()}}catch{}},[e,t])}async function iy(e,t){if(!(await fetch("/api/dashboard/session")).ok)throw new Error("Run angine restart in your terminal to load the new dashboard controls, then refresh this page and save again.");const o=await fetch(`/api/dashboard/${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-Angine-UI":"1"},body:JSON.stringify(t)}),r=await o.json();if(!o.ok)throw new Error(r.error||"Could not save the change.");return r.state}function xo(e,t){if(t)return t?.profileId?e.profiles?.[t.profileId]:Object.values(e.profiles||{}).find(n=>n.isDefault&&n.agent===(t?.agent||"external"))}function pr(e,t){return xo(e,e.sessions[t.updatedBySessionId||""])||Object.values(e.profiles||{}).find(n=>n.isDefault&&n.agent===(t.updatedBy||"external"))}function Dn({item:e,minutes:t}){return t>0&&Qt(e,t)?a("span",{class:"stale-tag",title:`No reported update since ${new Date(e.updatedAt).toLocaleString()}`,children:"Stale"}):null}function sy({profile:e,mutate:t,close:n}){const[o,r]=J(()=>e||{agent:"external",context:"Personal",isDefault:!0}),[i,s]=J(!1),c={name:"A name you recognise in Angine, such as Team Agent or Development Agent.",agent:"The agent reporting the work: claude, codex, grok, or another agent name. Use external for a generic reporter. This must match the reporter’s agent type.",key:"A unique ID for this profile, such as team-agent. Use this key in the reporter’s --profile setting to link its reports here. It cannot be changed after saving.",context:"What you use this agent for, such as Work or Personal. This label helps you identify and filter its work.",ownerName:"Optional. The person using this agent. Enter the name yourself; Angine does not read it from the agent account.",ownerEmail:"Optional. The owner’s email for identifying whose work this is. It is not used to sign in or send email.",accountLabel:"Optional. A nickname for the account, such as Company account or Personal account. Enter a label, never a password or API key.",description:"Optional. A short note explaining what this profile is used for, such as development and code reviews."},d=(l,f,h=!1,u=160)=>a("label",{children:[f,a("input",{type:l==="ownerEmail"?"email":"text",required:h,readOnly:!!(e&&(l==="agent"||l==="key")),maxLength:u,value:String(o[l]??""),"aria-describedby":`profile-help-${l}`,onInput:p=>r({...o,[l]:p.currentTarget.value})}),a("span",{class:"field-help",id:`profile-help-${l}`,children:c[l]})]});return a("form",{class:"panel profile-form",onSubmit:async l=>{l.preventDefault(),s(!0);const f=await t("profiles",o);s(!1),f&&n()},children:[a("div",{class:"panel-heading",children:[a("h2",{children:e?"Edit profile":"New agent profile"}),a("button",{type:"button",class:"text-button",onClick:n,children:"Close"})]}),a("div",{class:"form-grid",children:[d("name","Profile name",!0),d("agent","Agent type",!0,80),d("key","Stable profile key",!0),d("context","Context (Work, Personal…)",!0,80),d("ownerName","Owner name"),d("ownerEmail","Owner email"),d("accountLabel","Account label"),d("description","Description",!1,500)]}),a("label",{class:"check-label",children:[a("input",{type:"checkbox","aria-describedby":"profile-help-default",checked:o.isDefault===!0,onChange:l=>r({...o,isDefault:l.currentTarget.checked})}),"Default profile for this agent type"]}),a("p",{class:"field-help",id:"profile-help-default",children:"Reports from this agent type use this profile when no profile key is specified. For example, making this the Claude default labels Claude reports with this profile. Only one profile can be the default for each agent type."}),a("p",{class:"muted",children:"Saving creates the profile. To link reports, make it the default or configure the agent’s Angine reporter with this profile key. Saving does not start or configure an agent."}),a("button",{class:"primary-button",disabled:i,children:i?"Saving…":"Save profile"})]})}function ay({state:e,profileId:t,mutate:n,taskRow:o,health:r,compatibility:i}){const[s,c]=J(null),d=Object.values(e.profiles||{}).sort((_,v)=>_.name.localeCompare(v.name)),l=t?e.profiles?.[t]:void 0,f=_=>Object.values(e.sessions).filter(v=>xo(e,v)?.id===_.id),h=_=>Object.values(e.tasks).filter(v=>pr(e,v)?.id===_.id&&!al(e,v)),u=_=>{const v=new Set([...h(_).map(m=>m.projectId),...f(_).flatMap(m=>m.projectIds||[m.projectId])]);return Object.values(e.projects).filter(m=>v.has(m.id)&&!m.archivedAt)},p=_=>{const v=new Set([...h(_).map(m=>m.missionId),...f(_).flatMap(m=>m.missionIds||[m.missionId])]);return Object.values(e.missions).filter(m=>v.has(m.id)&&!m.archivedAt&&!e.projects[m.projectId]?.archivedAt)},y=_=>{const v=f(_).sort((C,k)=>k.lastSeenAt.localeCompare(C.lastSeenAt)),m=C=>v.find(k=>k.id!==C.id&&C.parentAgentId===k.agentId&&C.sourceSessionId&&k.sourceSessionId===C.sourceSessionId&&k.workspaceId===C.workspaceId),S=[],g=new Set,w=(C,k)=>{g.has(C.id)||(g.add(C.id),S.push({session:C,depth:k}),v.filter(E=>m(E)?.id===C.id).forEach(E=>w(E,k+1)))};return v.filter(C=>!m(C)).forEach(C=>w(C,0)),v.forEach(C=>w(C,0)),S};return t&&!l?a("div",{class:"empty",children:[a("h2",{children:"Profile not found"}),a("a",{href:Te("agents"),children:"All agents"})]}):a(se,{children:[a("div",{class:"view-heading",children:[a("div",{children:[a("h1",{children:l?.name||"Agents & sessions"}),a("p",{children:l?`${l.context} · ${Jt(l.agent)}`:"Profiles, collaboration, and reported agent sessions."})]}),a("button",{class:"primary-button",onClick:()=>c(l||"new"),children:l?"Edit profile":"Add profile"})]}),s&&a(sy,{profile:s==="new"?void 0:s,mutate:n,close:()=>c(null)},s==="new"?"new":s.id),a(ey,{profiles:e.profiles,health:r,compatibility:i,profile:l}),l?a(se,{children:[a("nav",{class:"breadcrumbs",children:[a("a",{href:Te("agents"),children:"Agents"}),a("span",{children:"/"}),a("span",{children:l.name})]}),a("div",{class:"profile-summary panel",children:[a("span",{children:[u(l).length," projects"]}),a("span",{children:[p(l).length," missions"]}),a("span",{children:[h(l).length," tasks"]}),a("span",{children:[f(l).length," sessions"]}),l.ownerName&&a("span",{children:["Owner: ",l.ownerName]}),l.ownerEmail&&a("span",{children:l.ownerEmail}),l.accountLabel&&a("span",{children:["Account: ",l.accountLabel]})]}),a("section",{class:"panel",children:[a("h2",{children:"Projects"}),a("div",{class:"linked-projects",children:[u(l).map(_=>a("a",{href:Te("projects",_.id),children:[_.name,a("span",{children:_.status})]})),!u(l).length&&a("p",{class:"muted",children:"No projects reported for this profile yet."})]})]}),a("section",{class:"panel",children:[a("h2",{children:"Missions"}),a("div",{class:"linked-projects",children:[p(l).map(_=>a("a",{href:Te("missions",_.id),children:[_.name,a("span",{children:[e.projects[_.projectId]?.name," · ",_.status]})]},_.id)),!p(l).length&&a("p",{class:"muted",children:"No missions reported for this profile yet."})]})]}),a("section",{class:"panel",children:[a("h2",{children:"Tasks"}),a("div",{class:"task-table",children:h(l).map(o)})]}),a("section",{class:"panel",children:[a("h2",{children:"Sessions & child agents"}),a("div",{class:"sessions-view",children:[y(l).map(({session:_,depth:v})=>a("div",{class:"session-card",style:{marginLeft:`${Math.min(v,4)*20}px`},children:[a("strong",{children:_.agentId||Jt(_.agent)}),a("span",{children:[_.parentAgentId?`Child of ${_.parentAgentId}`:"Reporter session"," · Last report ",new Date(_.lastSeenAt).toLocaleString()]}),a("dl",{children:[a("dt",{children:"Angine session"}),a("dd",{children:_.id}),_.sourceSessionId&&a(se,{children:[a("dt",{children:"Agent session"}),a("dd",{children:_.sourceSessionId})]}),a("dt",{children:"Projects"}),a("dd",{children:(_.projectIds||[_.projectId]).map(m=>a("a",{class:"session-project",href:Te("projects",m),children:e.projects[m]?.name||m}))}),a("dt",{children:"Missions"}),a("dd",{children:(_.missionIds||[_.missionId]).map(m=>a("a",{class:"session-project",href:Te("missions",m),children:e.missions[m]?.name||m}))}),a("dt",{children:"Latest task reports"}),a("dd",{children:Object.values(e.tasks).filter(m=>m.updatedBySessionId===_.id).map(m=>a("a",{class:"session-project",href:Te("tasks",m.id),children:m.title}))})]})]},_.id)),!f(l).length&&a("p",{class:"muted",children:"Sessions appear when this agent reports work. Child links require reported parent IDs."})]})]})]}):a("div",{class:"profile-grid",children:d.map(_=>a("article",{class:"panel profile-card",children:[a("div",{class:"panel-heading",children:[a("a",{href:Te("agents",_.id),children:a("h2",{children:_.name})}),a("button",{class:"text-button",onClick:()=>c(_),children:"Edit"})]}),a("div",{class:"profile-labels",children:[a("span",{children:Jt(_.agent)}),a("span",{children:_.context}),_.isDefault&&a("span",{children:"Default"})]}),_.description&&a("p",{class:"muted",children:_.description}),_.ownerName&&a("p",{class:"muted",children:[_.ownerName,_.ownerEmail?` · ${_.ownerEmail}`:""]}),a("a",{class:"profile-counts",href:Te("agents",_.id),children:[a("span",{children:[u(_).length," projects"]}),a("span",{children:[p(_).length," missions"]}),a("span",{children:[h(_).length," tasks"]}),a("span",{children:[f(_).length," sessions ↗"]})]})]},_.id))})]})}function cy({task:e,state:t,mutate:n}){const[o,r]=J(e.blocker?.reason||""),[i,s]=J(e.blocker?.nextStep||""),[c,d]=J(e.blocker?.owner||""),[l,f]=J(e.relatedTaskKeys||[]),[h,u]=J(!1),[p,y]=J(!1),_=Object.values(t.tasks).filter(m=>m.missionId===e.missionId&&m.id!==e.id),v=_.filter(m=>l.includes(m.key)||m.relatedTaskKeys?.includes(e.key));return a("section",{class:"panel",children:[a("h2",{children:e.status==="blocked"?"Blocker & related work":"Related work"}),v.length?a("div",{class:"related-links",children:v.map(m=>a("a",{href:Te("tasks",m.id),children:[m.title,a("span",{children:[Jt(m.updatedBy)," · ",m.status.replaceAll("_"," ")]})]}))}):a("p",{class:"muted",children:"Link related tasks from any agent working in this mission."}),a("form",{class:"workflow-form",onSubmit:async m=>{m.preventDefault(),u(!0);const S=await n("task-details",{taskId:e.id,relatedTaskKeys:l,...e.status==="blocked"?{blocker:o.trim()?{reason:o,nextStep:i,owner:c}:null}:{}});u(!1),y(S)},children:[e.status==="blocked"&&a(se,{children:[a("label",{children:["What is blocking this task?",a("textarea",{maxLength:500,value:o,onInput:m=>{r(m.currentTarget.value),y(!1)},placeholder:e.note||"Describe the blocker…"})]}),a("label",{children:["What needs to happen next?",a("textarea",{maxLength:500,value:i,onInput:m=>{s(m.currentTarget.value),y(!1)}})]}),a("label",{children:["Who can unblock it?",a("input",{maxLength:160,value:c,onInput:m=>{d(m.currentTarget.value),y(!1)}})]})]}),a("label",{children:["Related tasks",a("select",{multiple:!0,onChange:m=>{f(Array.from(m.currentTarget.selectedOptions).map(S=>S.value)),y(!1)},size:Math.min(5,Math.max(2,_.length)),children:_.map(m=>a("option",{value:m.key,selected:l.includes(m.key),children:[m.title," · ",Jt(m.updatedBy)]}))})]}),a("p",{class:"muted",children:"Select related tasks; use ⌘ or Ctrl to select more than one. Shared project and mission keys link work across agents automatically."}),a("button",{class:"primary-button",disabled:h,children:h?"Saving…":"Save details"}),p&&a("span",{class:"saved-message",children:"Saved"})]})]})}function ly({state:e,mutate:t}){const n=[...Object.values(e.projects).filter(o=>o.archivedAt).map(o=>({...o,kind:"projects"})),...Object.values(e.missions).filter(o=>o.archivedAt).map(o=>({...o,kind:"missions"}))].sort((o,r)=>r.archivedAt.localeCompare(o.archivedAt));return a(se,{children:[a("div",{class:"view-heading",children:a("div",{children:[a("h1",{children:["Archive ",a("span",{class:"section-count",children:n.length})]}),a("p",{children:"Projects and missions hidden from the main views. Tasks and history are preserved."})]})}),a("div",{class:"panel archive-list",children:[n.map(o=>a("div",{children:[a("a",{href:Te(o.kind,o.id),children:[a("strong",{children:o.name}),a("span",{children:[o.kind==="missions"?`Mission · ${e.projects[o.projectId]?.name||""}`:"Project"," · Archived ",new Date(o.archivedAt).toLocaleString()]}),o.kind==="missions"&&e.projects[o.projectId]?.archivedAt&&a("span",{children:"Restore the parent project to make this mission visible."})]}),a("button",{class:"secondary-button",onClick:()=>t("archive",{projectId:o.id,archived:!1}),children:"Restore"})]},o.id)),!n.length&&a("p",{class:"muted",children:"No archived projects or missions."})]})]})}function uy({preferences:e,setPreferences:t,resetFilters:n}){const[o,r]=J("");return a(se,{children:[a("div",{class:"view-heading",children:a("div",{children:[a("h1",{children:"Preferences"}),a("p",{children:"Activity indicators, saved filters, and optional alerts."})]})}),a("section",{class:"panel settings-panel",children:[a("h2",{children:"Stale activity"}),a("label",{children:["Flag active work after no reported update for",a("select",{value:e.staleMinutes,onChange:i=>t({...e,staleMinutes:Number(i.currentTarget.value)}),children:[a("option",{value:0,children:"Off"}),a("option",{value:15,children:"15 minutes"}),a("option",{value:60,children:"1 hour"}),a("option",{value:240,children:"4 hours"}),a("option",{value:1440,children:"1 day"})]})]}),a("p",{class:"muted",children:"Stale describes reporting activity. It does not change a task's status."})]}),a("section",{class:"panel settings-panel",children:[a("h2",{children:"Saved filters"}),a("p",{class:"muted",children:"Project, mission, agent, profile, status, and search selections are remembered separately for each view on this device."}),a("button",{class:"secondary-button",onClick:()=>{n(),r("Saved filters reset.")},children:"Reset saved filters"})]}),a("section",{class:"panel settings-panel",children:[a("h2",{children:"Desktop notifications"}),a("p",{class:"muted",children:"Optional alerts for tasks that finish or become blocked. The dashboard must remain open."}),a("button",{class:"secondary-button",onClick:async()=>{if(e.notifications){t({...e,notifications:!1}),r("Notifications disabled.");return}if(typeof Notification>"u"){r("This browser does not support desktop notifications.");return}try{await Notification.requestPermission()==="granted"?(t({...e,notifications:!0}),r("Notifications enabled.")):r("Notification permission was not granted.")}catch{r("Notifications are unavailable in this browser.")}},children:e.notifications?"Disable notifications":"Enable notifications"}),a("p",{class:"muted",role:"status",children:o})]})]})}const Je={todo:"To do",in_progress:"In progress",blocked:"Blocked",completed:"Completed",failed:"Failed",cancelled:"Cancelled",planned:"Planned",running:"Running",active:"Active"},Qe=e=>e?.trim()||"external",ut=e=>({codex:"Codex",claude:"Claude",grok:"Grok",external:"External"})[Qe(e)]||Qe(e),Et=e=>{const t=Math.max(0,Math.floor((Date.now()-Date.parse(e))/6e4));return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:`${Math.floor(t/1440)}d ago`},Uo=e=>e.status==="completed"?100:e.status==="todo"?0:e.progress,Se=(e,t)=>`#/${e}${t?`/${encodeURIComponent(t)}`:""}`;function On({status:e}){return a("span",{class:`badge ${e}`,children:[a("span",{class:"status-dot"}),Je[e]||e]})}function Rn({value:e,caption:t="Progress"}){return a("div",{class:"progress",children:[a("div",{class:"progress-label",children:[a("span",{children:t}),a("strong",{children:e==null?"Not reported":`${Math.round(e)}%`})]}),a("div",{class:`track ${e==null?"unknown":""}`,role:e==null?void 0:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e,children:e!=null&&a("span",{style:{width:`${e}%`}})})]})}function dy({session:e,state:t,health:n}){const o=xo(t,e);return a("div",{class:"reporter",children:[a("div",{class:"reporter-title",children:[a("span",{class:"avatar",children:ut(e.agent).slice(0,1)}),a("div",{children:[a("strong",{children:o?.name||ut(e.agent)}),a("span",{children:[e.agentId||"Reporter"," · ",Et(e.lastSeenAt)]})]})]}),a("dl",{children:[o&&a(se,{children:[a("dt",{children:"Profile"}),a("dd",{children:a("a",{href:Se("agents",o.id),children:o.name})})]}),o?.ownerName&&a(se,{children:[a("dt",{children:"Owner"}),a("dd",{children:[o.ownerName,o.ownerEmail?` · ${o.ownerEmail}`:""]})]}),a("dt",{children:"Worktree / workspace"}),a("dd",{children:[t.workspaces[e.workspaceId]?.path,t.workspaces[e.workspaceId]?.branch&&a("span",{children:[" · ",t.workspaces[e.workspaceId].branch]})]}),a("dt",{children:"Angine session"}),a("dd",{children:e.id}),e.sourceSessionId&&a(se,{children:[a("dt",{children:"Agent session"}),a("dd",{children:e.sourceSessionId})]}),e.parentAgentId&&a(se,{children:[a("dt",{children:"Parent agent"}),a("dd",{children:e.parentAgentId})]}),e.accountLabel&&a(se,{children:[a("dt",{children:"Account"}),a("dd",{children:e.accountLabel})]})]}),a(Q0,{health:n,session:e})]})}function Ps({status:e,items:t,kind:n,limit:o,row:r}){const i=ne(null),[s,c]=J(),d=t.length>o;return rt(()=>{const l=i.current;if(!l||!d){c(void 0);return}const f=Array.from(l.children).slice(0,o),h=()=>c(Math.ceil(f.reduce((p,y)=>p+y.getBoundingClientRect().height,0)));h();const u=new ResizeObserver(h);return u.observe(l),f.forEach(p=>u.observe(p)),()=>u.disconnect()},[t,o,d]),a("section",{class:"project-status-section","aria-labelledby":`${n}-${e}`,children:[a("div",{class:"status-section-heading",children:[a("h2",{id:`${n}-${e}`,children:[a("span",{class:`section-status-dot ${e}`}),Je[e],a("span",{class:"section-count",children:t.length})]}),a("span",{children:d?`Latest ${o} shown · Scroll for ${t.length-o} more`:"Newest updates first"})]}),a("div",{class:"project-list panel",children:[a("div",{class:n==="tasks"?"task-list-head":"project-list-head","aria-hidden":"true",children:[a("span",{children:n==="tasks"?"Task":n==="missions"?"Mission":"Project"}),a("span",{children:"Status"}),a("span",{children:"Progress"}),n!=="tasks"&&a("span",{children:"Agent"}),a("span",{children:"Updated"}),a("span",{})]}),a("div",{class:`project-scroll ${d?"has-overflow":""}`,ref:i,style:d&&s?{maxHeight:`${s}px`}:void 0,tabIndex:d?0:void 0,role:d?"region":void 0,"aria-label":d?`${Je[e]} ${n}, scroll to see all ${t.length}`:void 0,children:t.length?t.map(r):a("div",{class:"status-section-empty",children:["No ",Je[e].toLowerCase()," ",n," in this view."]})})]})]})}function fy(){const[e,t]=J(null),[n,o]=J(location.hash.slice(1)||"/projects"),[r="projects",i]=n.split("/").filter(Boolean);let s="";try{s=decodeURIComponent(i||"")}catch{}const{filters:c,set:d,reset:l,resetAll:f}=ny(r),{agent:h,status:u,project:p,mission:y,profile:_,query:v,staleOnly:m}=c,{preferences:S,setPreferences:g}=oy(),{health:w,compatibility:C}=G0();ry(e,S.notifications);const[k,E]=J(""),[T,D]=J([]),[L,O]=J(!1),B=ne(null),[N,b]=J(),[,I]=J(0),M=x=>t(R=>R&&R.seq>x.seq?R:X0(x)),P=async(x,R)=>{E("");try{return M(await iy(x,R)),!0}catch(ae){return E(ae.message),!1}};oe(()=>{const x=()=>{o(location.hash.slice(1)||"/projects"),window.scrollTo(0,0)};return window.addEventListener("hashchange",x),()=>window.removeEventListener("hashchange",x)},[]),oe(()=>{fetch("/api/state").then(ae=>{if(!ae.ok)throw new Error;return ae.json()}).then(M).catch(()=>O(!1));const x=new EventSource("/api/events");x.addEventListener("state",ae=>{M(JSON.parse(ae.data)),O(!0)}),x.onerror=()=>O(!1);const R=setInterval(()=>I(ae=>ae+1),3e4);return()=>{x.close(),clearInterval(R)}},[]),rt(()=>{const x=B.current;if(r!=="board"||!x)return;const R=()=>b(Math.max(260,window.innerHeight-x.getBoundingClientRect().top-24));R();const ae=new ResizeObserver(R);return x.parentElement&&ae.observe(x.parentElement),window.addEventListener("resize",R),()=>{ae.disconnect(),window.removeEventListener("resize",R)}},[r,!!e]);const A=r==="tasks"&&s?e?.tasks[s]:void 0,$=A?e?.missions[A.missionId]:(r==="missions"||r==="projects")&&s?e?.missions[s]:void 0,j=$?e?.projects[$.projectId]:r==="projects"&&s?e?.projects[e?.projectAliases?.[s]||s]:void 0,z=$?`missions/${encodeURIComponent($.id)}`:j?`projects/${encodeURIComponent(j.id)}`:"";oe(()=>{if(D([]),!z)return;let x=!0;return fetch(`/api/${z}/events`).then(R=>{if(!R.ok)throw new Error;return R.json()}).then(R=>{x&&D(R)}).catch(()=>{}),()=>{x=!1}},[z,e?.seq]);const V=x=>x.sort((R,ae)=>ae.updatedAt.localeCompare(R.updatedAt)),Z=V(Object.values(e?.tasks||{})),F=V(Object.values(e?.missions||{})),G=V(Object.values(e?.projects||{})).filter(x=>!x.archivedAt),ee=F.filter(x=>!x.archivedAt&&!e?.projects[x.projectId]?.archivedAt),X=Z.filter(x=>e?.missions[x.missionId]&&!al(e,x)),H=Object.values(e?.sessions||{}),W=[...new Set([...H.map(x=>Qe(x.agent)),...X.map(x=>Qe(x.updatedBy))])].sort(),Q=x=>[...new Set([...x.workspaceIds||[x.workspaceId],...H.filter(R=>R.missionId===x.id||R.missionIds?.includes(x.id)).map(R=>R.workspaceId)])].map(R=>e?.workspaces[R]).filter(Boolean),Y=x=>Z.filter(R=>R.missionId===x),U=x=>ee.filter(R=>R.projectId===x),K=x=>X.filter(R=>R.projectId===x),re=x=>[...new Set([...Y(x).map(R=>Qe(R.updatedBy)),...H.filter(R=>R.missionId===x||R.missionIds?.includes(x)).map(R=>Qe(R.agent))])],ie=x=>[...new Set([...Z.filter(R=>R.projectId===x).map(R=>Qe(R.updatedBy)),...H.filter(R=>R.projectId===x||R.projectIds?.includes(x)).map(R=>Qe(R.agent))])],ce=(x,R)=>[...new Set([...x.map(ae=>e?pr(e,ae)?.id:void 0),...R.map(ae=>e?xo(e,ae)?.id:void 0)])],me=x=>ce(Z.filter(R=>R.projectId===x),H.filter(R=>R.projectId===x||R.projectIds?.includes(x))),$e=x=>ce(Y(x),H.filter(R=>R.missionId===x||R.missionIds?.includes(x))),ve=G.filter(x=>(h==="all"||ie(x.id).includes(h))&&(_==="all"||me(x.id).includes(_))),Ee=ee.filter(x=>(p==="all"||x.projectId===p)&&(h==="all"||re(x.id).includes(h))&&(_==="all"||$e(x.id).includes(_)));oe(()=>{if(e){if(e.projectAliases?.[p]){d({project:e.projectAliases[p]});return}if(e.missions[p]){d({project:e.missions[p].projectId,mission:p});return}if(p!=="all"&&!ve.some(x=>x.id===p)){d({project:"all",mission:"all"});return}y!=="all"&&!Ee.some(x=>x.id===y)&&d({mission:"all"}),r==="projects"&&!["all","active"].includes(u)&&d({status:"all"})}},[e,r,h,_,p,y,u]);const we=(...x)=>x.join(" ").toLowerCase().includes(v.toLowerCase().trim()),We=ee.filter(x=>(p==="all"||x.projectId===p)&&(y==="all"||x.id===y)&&(h==="all"||re(x.id).includes(h))&&(_==="all"||$e(x.id).includes(_))&&(!m||Qt(x,S.staleMinutes))&&(r!=="missions"||u==="all"||x.status===u)&&we(x.name,x.description,e?.projects[x.projectId]?.name)),xe=ve.filter(x=>(p==="all"||x.id===p)&&(!m||U(x.id).some(R=>Qt(R,S.staleMinutes)))&&(we(x.name,x.description,e?.workspaces[x.workspaceId]?.path)||U(x.id).some(R=>we(R.name,R.description)))),_e=X.filter(x=>(p==="all"||x.projectId===p)&&(y==="all"||x.missionId===y)&&(h==="all"||Qe(x.updatedBy)===h)&&(_==="all"||e&&pr(e,x)?.id===_)&&(!m||Qt(x,S.staleMinutes))&&(u==="all"||x.status===u)&&we(x.title,x.note,e?.missions[x.missionId]?.name,e?.projects[x.projectId]?.name)),Ce=r==="projects"?X.filter(x=>xe.some(R=>R.id===x.projectId)):r==="missions"?X.filter(x=>We.some(R=>R.id===x.missionId)):_e,Pe=x=>{const R=x.filter(ae=>ae.status!=="cancelled");return R.length?Math.round(R.filter(ae=>ae.status==="completed").length/R.length*100):0},De=x=>d({agent:x,...x!=="all"&&_!=="all"&&e?.profiles[_]?.agent!==x?{profile:"all"}:{}}),Oe=x=>a("a",{class:"task-row",style:Wt(e,x.projectId,x.missionId),href:Se("tasks",x.id),children:[a("div",{class:"task-row-main",children:[a("span",{class:`task-status ${x.status}`}),a("div",{children:[a("strong",{children:x.title}),a("span",{children:[e?.projects[x.projectId]?.name," / ",e?.missions[x.missionId]?.name," · ",ut(x.updatedBy)," ",a(Dn,{item:x,minutes:S.staleMinutes})]})]})]}),a(On,{status:x.status}),a(Rn,{value:Uo(x)}),a("span",{class:"row-time",children:Et(x.updatedAt)}),a("span",{class:"row-arrow",children:"↗"})]},x.id),zt=x=>a("a",{class:"project-row",style:Wt(e,x.projectId,x.id),href:Se("missions",x.id),children:[a("div",{class:"project-row-main",children:[a("strong",{children:[x.name," ",a(Dn,{item:x,minutes:S.staleMinutes})]}),a("span",{children:[e?.projects[x.projectId]?.name,Q(x).some(R=>R?.branch)?` · ${[...new Set(Q(x).map(R=>R?.branch).filter(Boolean))].join(" · ")}`:""]}),x.description&&a("p",{children:x.description})]}),a(On,{status:x.status}),a(Rn,{value:Pe(Y(x.id)),caption:`${Y(x.id).filter(R=>R.status==="completed").length} / ${Y(x.id).filter(R=>R.status!=="cancelled").length} tasks`}),a("span",{class:"project-row-agents",children:re(x.id).map(ut).join(" · ")||"External"}),a("span",{class:"row-time",children:Et(x.updatedAt)}),a("span",{class:"row-arrow",children:"↗"})]},x.id),Bt=x=>{const R=U(x.id),ae=R.filter(Ne=>Ne.status==="running").length,Ue=e?ll(e,K(x.id),w,S.staleMinutes).length:0;return a("a",{class:"project-row",style:Wt(e,x.id),href:Se("projects",x.id),children:[a("div",{class:"project-row-main",children:[a("strong",{children:x.name}),a("span",{children:[R.length," missions · ",K(x.id).length," tasks",Ue?` · ${Ue} need attention`:""]}),x.description&&a("p",{children:x.description})]}),a(On,{status:"active"}),a("div",{class:"project-mission-count",children:[a("strong",{children:[ae," running"]}),a("span",{children:[R.filter(Ne=>Ne.status==="completed").length," completed missions"]})]}),a("span",{class:"project-row-agents",children:ie(x.id).map(ut).join(" · ")||"External"}),a("span",{class:"row-time",children:Et(x.updatedAt)}),a("span",{class:"row-arrow",children:"↗"})]},x.id)},vn=(x,R="all")=>a("div",{class:"project-sections",children:["running","planned","blocked","completed","failed","cancelled"].filter(ae=>(R==="all"||R===ae)&&(!["planned","blocked"].includes(ae)||x.some(Ue=>Ue.status===ae)||R===ae)).map(ae=>a(Ps,{status:ae,kind:"missions",items:x.filter(Ue=>Ue.status===ae),limit:ae==="running"?10:5,row:zt},ae))}),bo=x=>a("div",{class:"activity",children:x.length?x.slice(-40).reverse().map(R=>a("div",{children:[a("span",{class:"activity-dot"}),a("div",{children:[a("strong",{children:R.type.startsWith("task.")?R.type==="task.removed"?"Task removed":`${R.type==="task.created"?"Created · ":""}${Je[String(R.payload.status)]||"Updated"}`:R.type.replace(R.type.startsWith("project.")&&R.payload.status!=="active"?"project.":"never.","mission.").replaceAll("."," ")}),R.payload.note&&a("p",{children:String(R.payload.note)}),a("span",{children:new Date(R.timestamp).toLocaleString()})]})]},R.seq)):a("p",{class:"muted",children:"No recorded activity yet."})}),wn=!!s,be=A||$||j,So=j&&be&&(r!=="tasks"||A)&&(r!=="missions"||$),xn=A?H.filter(x=>x.id===A.updatedBySessionId):$?H.filter(x=>x.missionId===$.id||x.missionIds?.includes($.id)):j?H.filter(x=>x.projectId===j.id||x.projectIds?.includes(j.id)):[],bn=r==="projects"&&$?"missions":r,Sn=(x,R,ae,Ue)=>a("label",{class:"filter-label project-picker",children:[a("span",{children:x}),a("select",{"aria-label":`Filter by ${x.toLowerCase()}`,value:R,onChange:Ne=>Ue(Ne.currentTarget.value),children:[a("option",{value:"all",children:["All ",x.toLowerCase(),"s"]}),[...ae].sort((Ne,Eo)=>Ne.name.localeCompare(Eo.name)).map(Ne=>a("option",{value:Ne.id,children:Ne.name},Ne.id))]})]}),ko=r==="projects"?["active"]:r==="missions"?["running","planned","blocked","completed","failed","cancelled"]:["todo","in_progress","blocked","completed","failed","cancelled"];return a("div",{class:"shell",children:[a("header",{class:"topbar",children:[a("a",{class:"brand",href:Se("projects"),children:[a("span",{class:"brand-mark"}),"Angine"]}),a("nav",{"aria-label":"Main navigation",children:["projects","missions","tasks","board","tree","agents","archive","settings"].map(x=>a("a",{href:Se(x),class:bn===x?"active":"","aria-current":bn===x?"page":void 0,children:x==="tree"?"Graph":x==="settings"?"Preferences":x[0].toUpperCase()+x.slice(1)},x))}),a("div",{class:"connection",children:[a("span",{class:L?"live-dot":"offline-dot"}),L?"Dashboard live":"Dashboard reconnecting"]})]}),a("main",{class:wn?"detail-page":"overview-page",children:[a(K0,{compatibility:C}),k&&a("div",{class:"error-banner",role:"alert",children:[k,a("button",{class:"text-button",onClick:()=>E(""),children:"Dismiss"})]}),e?r==="agents"?a(ay,{health:w,compatibility:C,state:e,profileId:s||void 0,mutate:P,taskRow:Oe}):r==="archive"?a(ly,{state:e,mutate:P}):r==="settings"?a(uy,{preferences:S,setPreferences:g,resetFilters:f}):r==="tree"?a(B0,{state:e,filters:c,setFilters:d,reset:l}):wn?So&&j&&be?a(se,{children:[a("nav",{class:"breadcrumbs","aria-label":"Breadcrumb",children:[a("a",{href:Se("projects"),children:"Projects"}),a("span",{children:"/"}),$?a(se,{children:[a("a",{href:Se("projects",j.id),children:j.name}),a("span",{children:"/"}),A?a(se,{children:[a("a",{href:Se("missions",$.id),children:$.name}),a("span",{children:"/"}),a("span",{children:"Task"})]}):a("span",{children:$.name})]}):a("span",{children:j.name})]}),a("div",{class:"page-heading detail-heading mission-heading",style:Wt(e,j.id,$?.id),children:[a("div",{children:[a("div",{class:"overline",children:[A?"TASK":$?"MISSION":"PROJECT"," ",a("span",{children:be.key})]}),a("h1",{children:A?.title||$?.name||j.name}),a("div",{class:"heading-meta",children:[a(On,{status:be.status}),a("span",{children:["Updated ",Et(be.updatedAt)]}),$&&a(Dn,{item:A||$,minutes:S.staleMinutes}),!A&&a("button",{class:"secondary-button",onClick:()=>P("archive",{projectId:be.id,archived:!("archivedAt"in be&&be.archivedAt)}),children:["archivedAt"in be&&be.archivedAt?"Restore":"Archive"," ",$?"mission":"project"]}),(j.archivedAt||$?.archivedAt)&&a("span",{children:"Archived"})]})]}),$?a("div",{class:"heading-progress",children:a(Rn,{value:A?Uo(A):Pe(Y($.id)),caption:A?"Task progress":"Tasks completed"})}):a("div",{class:"project-overview-counts",children:[a("strong",{children:U(j.id).length}),a("span",{children:"missions"}),a("strong",{children:K(j.id).length}),a("span",{children:"tasks"})]})]}),a("div",{class:"detail-grid",children:[a("div",{class:"detail-main",children:[a("section",{class:"panel",children:[a("h2",{children:"Overview"}),A&&a("p",{class:"report-provenance",children:["Status reported by ",ut(A.updatedBy)," · ",new Date(A.updatedAt).toLocaleString(),a("span",{children:"Completion is agent reported; test results are not independently verified."})]}),a("p",{class:"description",children:be.description||($?"No description provided.":"Missions collect the goals and tasks for this project. Completing a mission does not close the project.")}),A?.note&&a("div",{class:"latest-update",children:[a("div",{class:"overline",children:"LATEST UPDATE"}),a("p",{children:A.note})]})]}),!$&&a("section",{children:[a("div",{class:"panel-heading",children:[a("h2",{children:"Missions"}),a("span",{children:U(j.id).length})]}),vn(j.archivedAt?F.filter(x=>x.projectId===j.id):U(j.id))]}),A&&a(cy,{task:A,state:e,mutate:P},A.id),$&&(!A||Y($.id).some(x=>x.parentKey===A.key))&&a("section",{class:"panel",children:[a("div",{class:"panel-heading",children:[a("h2",{children:A?"Subtasks":"Tasks"}),a("span",{children:(A?Y($.id).filter(x=>x.parentKey===A.key):Y($.id)).length})]}),a("div",{class:"task-table",children:(A?Y($.id).filter(x=>x.parentKey===A.key):Y($.id)).map(Oe)})]}),a("section",{class:"panel",children:[a("h2",{children:"Activity"}),bo(T.filter(x=>A?x.taskId===A.id:!x.type.startsWith("session.")))]})]}),a("div",{class:"detail-info",children:[a("section",{class:"panel",children:[a("h2",{children:"Details"}),!A&&a(V0,{project:j,mission:$,mutate:P}),a("dl",{children:[a("dt",{children:"Project"}),a("dd",{children:a("a",{href:Se("projects",j.id),children:j.name})}),$&&a(se,{children:[a("dt",{children:"Mission"}),a("dd",{children:a("a",{href:Se("missions",$.id),children:$.name})})]}),a("dt",{children:$?"Worktrees / workspaces":"Workspace"}),a("dd",{children:$?Q($).map(x=>a("div",{children:[x.path,x.branch&&a("strong",{children:[" · ",x.branch]})]},x.id)):e.workspaces[j.workspaceId]?.repositoryPath||e.workspaces[j.workspaceId]?.path}),a("dt",{children:"Created"}),a("dd",{children:new Date(be.createdAt).toLocaleString()}),A?.parentKey&&a(se,{children:[a("dt",{children:"Parent task"}),a("dd",{children:Y(A.missionId).find(x=>x.key===A.parentKey)?a("a",{href:Se("tasks",Y(A.missionId).find(x=>x.key===A.parentKey).id),children:A.parentKey}):A.parentKey})]})]})]}),a("section",{class:"panel",children:[a("h2",{children:A?"Reporting agent":"Reporter sessions"}),xn.map(x=>a(dy,{session:x,state:e,health:w},x.id)),!xn.length&&a("p",{class:"muted",children:"No reporter session available for this item."})]})]})]})]}):a("div",{class:"empty",children:[a("h2",{children:"This page is unavailable"}),a("a",{href:Se("projects"),children:"Return to projects"})]}):a(se,{children:[a("div",{class:"overview-toolbar",children:[a("div",{class:"stats",children:r==="projects"?a(se,{children:[a("div",{children:[a("strong",{children:xe.length}),a("span",{children:"Projects"})]}),a("div",{children:[a("strong",{children:ee.filter(x=>xe.some(R=>R.id===x.projectId)&&x.status==="running").length}),a("span",{children:"Running missions"})]}),a("div",{children:[a("strong",{children:ee.filter(x=>xe.some(R=>R.id===x.projectId)&&x.status==="completed").length}),a("span",{children:"Completed missions"})]})]}):["all",r==="missions"?"running":"in_progress","blocked","completed","failed","cancelled"].map(x=>a("div",{children:[a("strong",{children:r==="missions"?x==="all"?We.length:We.filter(R=>R.status===x).length:x==="all"?_e.length:_e.filter(R=>R.status===x).length}),a("span",{children:x==="all"?"Total":Je[x]})]},x))}),a("div",{class:"toolbar",children:[a("label",{class:"search",children:[a("span",{"aria-hidden":"true",children:"⌕"}),a("input",{"aria-label":"Search work",placeholder:"Search projects, missions, tasks…",value:v,onInput:x=>d({query:x.currentTarget.value})})]}),a("label",{class:"filter-label",children:[a("span",{children:"Agent"}),a("select",{"aria-label":"Filter by agent",value:h,onChange:x=>De(x.currentTarget.value),children:[a("option",{value:"all",children:"All agents"}),W.map(x=>a("option",{value:x,children:ut(x)},x))]})]}),r!=="projects"&&Sn("Project",p,ve,x=>d({project:x,mission:"all"})),["tasks","board"].includes(r)&&Sn("Mission",y,Ee,x=>d({mission:x})),r!=="projects"&&a("label",{class:"filter-label",children:[a("span",{children:"Status"}),a("select",{"aria-label":"Filter by status",value:u,onChange:x=>d({status:x.currentTarget.value}),children:[a("option",{value:"all",children:"All statuses"}),ko.map(x=>a("option",{value:x,children:Je[x]},x))]})]}),a("details",{class:"more-filters",children:[a("summary",{children:["More filters",_!=="all"||m?" · On":""]}),a("div",{class:"extra-filters",children:[a("label",{class:"filter-label",children:[a("span",{children:"Profile"}),a("select",{"aria-label":"Filter by profile",value:_,onChange:x=>d({profile:x.currentTarget.value}),children:[a("option",{value:"all",children:"All profiles"}),Object.values(e.profiles).filter(x=>h==="all"||x.agent===h).map(x=>a("option",{value:x.id,children:x.name},x.id))]})]}),a("label",{class:"filter-label",children:[a("span",{children:"Activity"}),a("select",{"aria-label":"Filter stale activity",value:m?"stale":"all",onChange:x=>d({staleOnly:x.currentTarget.value==="stale"}),children:[a("option",{value:"all",children:"All activity"}),a("option",{value:"stale",children:"Stale only"})]})]})]})]}),(v||h!=="all"||u!=="all"||_!=="all"||m||p!=="all"||y!=="all")&&a("button",{class:"clear-filters",onClick:l,children:"Reset"})]})]}),a(ty,{state:e,tasks:Ce,health:w,staleMinutes:S.staleMinutes}),r==="board"?a("div",{class:"board",ref:B,style:N?{height:`${N}px`}:void 0,children:["todo","in_progress","blocked","completed","failed","cancelled"].map(x=>a("section",{class:"board-column",children:[a("div",{class:"column-heading",children:[a("span",{class:`task-status ${x}`}),a("h2",{children:Je[x]}),a("span",{children:_e.filter(R=>R.status===x).length})]}),a("div",{class:"board-stack",tabIndex:0,role:"region","aria-label":`${Je[x]} tasks, scroll this column`,children:[_e.filter(R=>R.status===x).map(R=>a("a",{class:"board-card",style:Wt(e,R.projectId,R.missionId),href:Se("tasks",R.id),children:[a("span",{class:"board-project",children:[e.projects[R.projectId]?.name," / ",e.missions[R.missionId]?.name]}),a("strong",{children:[R.title," ",a(Dn,{item:R,minutes:S.staleMinutes})]}),R.blocker?.nextStep&&a("p",{class:"blocker-next",children:["Next: ",R.blocker.nextStep]}),R.note&&a("p",{children:R.note}),a(Rn,{value:Uo(R)}),a("div",{class:"board-footer",children:[a("span",{children:ut(R.updatedBy)}),a("span",{children:Et(R.updatedAt)})]})]},R.id)),!_e.some(R=>R.status===x)&&a("div",{class:"column-empty",children:"No tasks"})]})]},x))}):r==="tasks"?a("div",{class:"project-sections",children:["in_progress","todo","blocked","completed","failed","cancelled"].filter(x=>(u==="all"||u===x)&&(!["todo","blocked"].includes(x)||_e.some(R=>R.status===x)||u===x)).map(x=>a(Ps,{status:x,kind:"tasks",items:_e.filter(R=>R.status===x),limit:x==="in_progress"?10:5,row:Oe},x))}):r==="missions"?vn(We,u):a("div",{class:"project-list panel",children:[a("div",{class:"project-list-head","aria-hidden":"true",children:[a("span",{children:"Project"}),a("span",{children:"Status"}),a("span",{children:"Missions"}),a("span",{children:"Agents"}),a("span",{children:"Updated"}),a("span",{})]}),xe.map(Bt),!xe.length&&a("div",{class:"status-section-empty",children:"No projects match these filters."})]})]}):a("div",{class:"empty",children:a("h2",{children:"Loading your work…"})}),a("footer",{class:"footer",children:[a("span",{children:"Angine"}),a("span",{children:"Stored locally on this device"})]})]})]})}At(a(fy,{}),document.getElementById("app"));
|